From 8db476839d134a470588ed1657bad7b4182bdc65 Mon Sep 17 00:00:00 2001 From: "lixuefei.1313" Date: Tue, 23 Dec 2025 19:42:04 +0800 Subject: [PATCH] docs(.trae,common/changes): add Trae job docs and PR flow updates --- .trae/documents/auto-flow.solo.md | 34 ++++ .trae/documents/auto-test.solo.md | 60 +++++++ .trae/documents/changelog-rush-smart.solo.md | 24 +++ .trae/documents/create-branch.solo.md | 20 +++ .trae/documents/pr-create.solo.md | 52 ++++++ .trae/jobs/README.md | 18 +- .trae/jobs/auto-flow.md | 95 ++++++++++ .trae/jobs/{autotest.md => auto-test.md} | 12 +- .trae/jobs/autotest.request.md | 21 --- .trae/jobs/changelog-rush-smart.md | 82 +++++++++ .trae/jobs/create-branch.md | 52 ++++++ .trae/jobs/pr-create.md | 167 ++++++++++++++++++ ...dd-auto-flow-in-trae_2025-12-23-06-19.json | 11 ++ .../src/component/geo/geo-coordinate.ts | 10 +- packages/vchart/src/region/interface.ts | 5 + 15 files changed, 626 insertions(+), 37 deletions(-) create mode 100644 .trae/documents/auto-flow.solo.md create mode 100644 .trae/documents/auto-test.solo.md create mode 100644 .trae/documents/changelog-rush-smart.solo.md create mode 100644 .trae/documents/create-branch.solo.md create mode 100644 .trae/documents/pr-create.solo.md create mode 100644 .trae/jobs/auto-flow.md rename .trae/jobs/{autotest.md => auto-test.md} (94%) delete mode 100644 .trae/jobs/autotest.request.md create mode 100644 .trae/jobs/changelog-rush-smart.md create mode 100644 .trae/jobs/create-branch.md create mode 100644 .trae/jobs/pr-create.md create mode 100644 common/changes/@visactor/vchart/feat-add-auto-flow-in-trae_2025-12-23-06-19.json diff --git a/.trae/documents/auto-flow.solo.md b/.trae/documents/auto-flow.solo.md new file mode 100644 index 0000000000..d0825567f1 --- /dev/null +++ b/.trae/documents/auto-flow.solo.md @@ -0,0 +1,34 @@ +# Auto Flow(串行编排)Solo 使用说明 + +- 入口文件:`./.trae/jobs/auto-flow.md` +- 流程:分支预检查 → 自动化测试 → Rush 变更日志 → 创建 PR + +## 参数 +- `baseBranch`:默认 `develop` +- `lang`:`zh|en`,默认 `zh` +- `labels`:默认 `[changelog, test]` +- `topic`:可选;用于 PR 标题优化(未提供时用当前分支名) +- `message`:可选;作为 PR body 摘要 +- `bumpType`:默认 `auto` +- `notCommit`:默认 `true` +- `head`:可选;未提供时自动推导当前分支 + +## 前置 +- 若需自动创建 PR 或聚合 Issue 标题,请先设置 `GITHUB_TOKEN`(参考 `./.trae/github-token.local.md`) + +## 使用(Solo) +- 在聊天中发起:“执行 Auto Flow(.trae/jobs/auto-flow.md)”,可附加: + - `topic: feature-legend` + - `message: 'docs: chore(trae): add auto-flow'` + - `mode: browser`(默认以浏览器创建 PR,输出可复制内容与 compare URL) + - (可选)`openBrowser: true`(自动打开浏览器) + +## 输出 +- `autotest_report`:`./.trae/jobs/autotest.report.local.md` +- `rush_change_entries`:`common/changes/**` +- `pr_url`:PR 链接(若已创建) + +## 人工检查 +- 单测后检查报告与覆盖率摘要 +- 变更日志后检查 `common/changes/**` +- PR 前检查标题与正文信息;如需补充 body,请人工完善后再创建 diff --git a/.trae/documents/auto-test.solo.md b/.trae/documents/auto-test.solo.md new file mode 100644 index 0000000000..1508ed6f56 --- /dev/null +++ b/.trae/documents/auto-test.solo.md @@ -0,0 +1,60 @@ +# Autotest(差异驱动单元测试生成)Solo 使用说明 + +- 入口文件:`./.trae/jobs/auto-test.md` +- 作用:根据 `develop...HEAD` 的代码差异,自动生成/更新测试用例与快照,并运行覆盖率与报告 + +## 参数 +- `sinceBranch`:默认 `develop` +- `project`:默认 `auto`(自动识别变更包);可指定如 `@visactor/vchart` +- `mode`:`full`(默认) +- `noSnapshot`:是否跳过快照,默认 `false` +- `onlyNew`:仅生成新的自动化区块,默认 `false` +- `reportFormat`:`md|json`,默认 `md` +- `applyManualOverrides`:应用人工覆写,默认 `true` +- `replaceAutogen`:允许替换已有 `autogen:` 块,默认 `false` +- `dryRun`:仅预览不写文件,默认 `false` +- `preview`:是否预览模式,默认 `false` +- `stopOnError`:遇错停止,默认 `true` +- `focusChangedOnly`:仅聚焦变更,默认 `true` +- `snapshotStrategy`:`combined`(默认) +- `tempReportPath`:默认 `./.trae/output/autotest.report.local.md` +- `mockDefaults`:默认 `time=fixed(2020-01-01T00:00:00Z)`、`random=seed(42)` + +## 使用(Solo) +- 最简:在聊天中发起“执行 Auto Test Job(.trae/jobs/auto-test.md)” +- 指定包:`project: '@visactor/vchart'` +- 指定输出格式:`reportFormat: 'json'` + +## 输出 +- `test_files`:新增/更新的 `.test.ts` +- `snapshots`:快照文件 +- `coverage_report`:覆盖率摘要 +- `manual_nodes`:需人工处理的用例占位 +- `temp_markdown_report`:临时报告(默认写入 `./.trae/output/autotest.report.local.md`) + +## 成功标准 +- `tests_generated_for_changed_exports` +- `compile_without_errors` +- `coverage_increase_or_maintained` + +## 人工覆写示例 +```yaml +manual_overrides: + - target: packages/vchart/src/util/color.ts#parseColor + mocks: + date: fixed(2020-01-01T00:00:00Z) + random: seed(42) + inputs: + - { args: ['#ff0000'], desc: '基本路径' } + - { args: ['invalid'], desc: '异常路径' } + asserts: + - { expect: 'toEqual', value: { r: 255, g: 0, b: 0 } } +``` + +## 运行与诊断 +- 我会自动执行 `rush run -p -s test` 与 `test-cov` +- TypeScript 诊断与覆盖率结果会写入临时报告以便复核 + +## 注意事项 +- 若差异范围为空,建议指定 `project` 以运行目标包测试 +- 对低覆盖模块,建议补充手动测试并复跑 Auto Test 以提升覆盖率 diff --git a/.trae/documents/changelog-rush-smart.solo.md b/.trae/documents/changelog-rush-smart.solo.md new file mode 100644 index 0000000000..6d6819b84e --- /dev/null +++ b/.trae/documents/changelog-rush-smart.solo.md @@ -0,0 +1,24 @@ +# Changelog(Rush 智能变更日志)Solo 使用说明 + +- 入口文件:`./.trae/jobs/changelog-rush-smart.md` +- 作用:对齐并增强 `change-all.ts`,生成 Rush 变更条目(`common/changes/**`) + +## 参数 +- `sinceBranch`:默认 `develop` +- `message`:可选;若为空自动生成富摘要 +- `bumpType`:`auto|major|minor|patch`,默认 `auto` +- `notCommit`:是否跳过 `git commit`,默认 `true` +- `githubToken`:可选,聚合 Issue 标题时需要 + +## 使用(Solo) +- 在聊天中发起:“执行 Changelog Job(.trae/jobs/changelog-rush-smart.md)”,可附加: + - `message: 'docs: chore(trae): add auto-flow'` + - `bumpType: patch` + +## 输出 +- `rush_change_entries`:新增的变更条目路径集合 +- `computed_bump_type`:自动判定的 bump 类型 +- `final_message`:最终用于 `rush change` 的消息 + +## 人工检查 +- 复核 `common/changes/**` 的内容(包名、类型、comment),必要时重新执行并覆盖 `message/bumpType` diff --git a/.trae/documents/create-branch.solo.md b/.trae/documents/create-branch.solo.md new file mode 100644 index 0000000000..2e1f20ac18 --- /dev/null +++ b/.trae/documents/create-branch.solo.md @@ -0,0 +1,20 @@ +# Create Branch Job(Solo 使用说明) + +- 入口文件:`./.trae/jobs/create-branch.md` +- 适用场景:需要在本地通过 Job 统一创建开发分支 + +## 参数 +- `baseBranch`:默认 `develop` +- `branchPrefix`:默认 `chore/trae` +- `topic`:必填,主题描述(例如 `feature-legend`) +- `useDateSuffix`:是否追加日期后缀,默认 `true` + +## 使用(Solo) +- 在聊天中发起:“执行 Create Branch Job(.trae/jobs/create-branch.md)”,并传入: + - `topic: feature-legend` + +## 输出 +- `branch_name`:生成的分支名 + +## 人工检查 +- 执行完成后:`git status` 确认当前分支与工作树状态 diff --git a/.trae/documents/pr-create.solo.md b/.trae/documents/pr-create.solo.md new file mode 100644 index 0000000000..d3e0f8c9ef --- /dev/null +++ b/.trae/documents/pr-create.solo.md @@ -0,0 +1,52 @@ +# PR 创建 Job(Solo 使用说明) + +- 入口文件:`./.trae/jobs/pr-create.md` +- 作用:依据仓库 PR 模版生成正文并创建 PR + +## 参数 +- `base`:默认 `develop` +- `head`:可选;未提供时自动推导当前分支 +- `title`:必填;PR 标题 +- `lang`:`zh|en`,默认 `zh` +- `labels`:可选标签数组 +- `draft`:是否草稿,默认 `false` +- `useGhCli`:是否使用 `gh` 创建,默认 `true` +- `mode`:`auto|gh|rest|browser`(默认 `auto`,优先浏览器免安装) +- `localBodyFile`:是否生成本地可复制正文文件(默认 `false`) +- `openBrowser`:是否自动打开 compare URL(默认 `true`) +- `commitBeforeCreate`:创建 PR 前是否自动提交未提交变更(默认 `false`) +- `commitMessage`:自动提交的 commit 消息(默认 `chore: auto commit before pr`) +- `commitAllowEmpty`:是否允许空提交(默认 `false`) +- `pushAfterCommit`:提交后是否自动推送当前分支(默认 `true`) +- `commitMessageStrategy`:提交信息生成策略(`auto|topic|manual`,默认 `auto`) + - `auto`:按变更内容自动判定类型(`docs|test|chore`)、作用域(包名或顶层目录),主题取 `message` 首行或自动摘要 + - `topic`:主题优先使用 `title`/外层 `topic` + - `manual`:使用 `commitMessage` + +## 前置(登录/令牌) +- 优先方案:使用 GitHub CLI(`gh`)并已登录 → 不需要额外令牌 +- 备选方案:无 `gh` 时提供 `GITHUB_TOKEN`(参见 `./.trae/github-token.local.md`) +- 兜底方案:生成浏览器 compare URL,使用你浏览器的登录态手动创建 PR + +## 使用(Solo) +- 在聊天中发起:“执行 PR Job(.trae/jobs/pr-create.md)”,并传: + - `title: '[Auto] feature-legend'` + - (可选)`head: chore/trae-feature-legend-20251222-1030` + - (可选)`mode: auto|gh|rest|browser`(默认 `auto`) + - (可选)`localBodyFile: true|false`(默认 `false`) + - (可选)`openBrowser: true|false`(默认 `true`) + - (可选)`commitBeforeCreate: true`、`commitMessage: 'chore: auto commit before pr'`、`pushAfterCommit: true` + - (可选)`commitMessageStrategy: auto` + +## 正文准备 +- 若 `message` 已包含摘要与关联信息,可直接作为 body +- 若需要补充,请先人工完善 body 文本,再执行创建(不生成临时文件) + +## 输出 +- `pr_url`:创建的 PR 链接(`gh/rest`) +- `compare_url`:浏览器 compare 页面(`browser`) +- `generated_title`:建议标题(便于复制) +- `generated_body_preview`:建议正文(便于复制) + +## 人工检查 +- 提交前检查标题、关联链接与 Changelog 摘要是否完整 diff --git a/.trae/jobs/README.md b/.trae/jobs/README.md index d262cdb3df..3eef56aedd 100644 --- a/.trae/jobs/README.md +++ b/.trae/jobs/README.md @@ -11,8 +11,8 @@ ## 通用字段 -- `Task`:任务标识,例如 `Autotest (diff-with-develop)`。 -- `Parameters`:运行参数,例如 `sinceBranch`、`project`、`mode`、`noSnapshot`、`onlyNew`、`reportFormat`。 +- `Task`:任务标识,例如 `Auto Test (diff-with-develop)`。 +- `Parameters`:运行参数,例如 `sinceBranch`、`project`、`mode`、`noSnapshot`、`onlyNew`、`reportFormat`、`tempReportPath`。 - `ExecutionHints`(可选):执行提示,如是否跳过快照、是否仅分析、不写补丁、选择包。 - `StepsOverride`(可选):覆盖默认执行步骤的命令或动作(如自定义 diff 命令)。 @@ -20,7 +20,7 @@ ``` # Task -Autotest (diff-with-develop) +Auto Test (diff-with-develop) # Parameters sinceBranch: develop @@ -43,14 +43,15 @@ reportFormat: md ## 使用方式 -- 推荐入口文件:`.trae/jobs/autotest.md`(已提供,含参数、步骤、人工覆写与成功标准) -- 最简用法(默认参数):在聊天中发起“执行 Autotest Job(.trae/jobs/autotest.md)”。 +- 推荐入口文件:`.trae/jobs/auto-test.md`(已提供,含参数、步骤、人工覆写与成功标准) +- 最简用法(默认参数):在聊天中发起“执行 Auto Test Job(.trae/jobs/auto-test.md)”。 - 可选覆盖参数:`project=@visactor/vchart-theme`、`reportFormat=json`、`replaceAutogen=true` 等。 -- 我将按 `.trae/jobs/autotest.md` 的步骤顺序执行:采集差异、分析缺口、生成/更新测试(含函数级注释)、运行覆盖率、生成报告、插入人工节点。 +- 我将按 `.trae/jobs/auto-test.md` 的步骤顺序执行:采集差异、分析缺口、生成/更新测试(含函数级注释)、运行覆盖率、生成报告、插入人工节点。 ## 结果与报告 - 报告以 `reportFormat` 指定(`md` 或 `json`)。 +- 默认临时报告写入 `./.trae/output/autotest.report.local.md`(可通过 `tempReportPath` 覆盖)。 - 我会附带执行日志摘要、受影响包、生成/跳过的测试、覆盖率与人工节点清单。 ## 旧方案清理 @@ -58,7 +59,7 @@ reportFormat: md - 旧的“工作流模版”文件与文档已移除: - `.trae/workflows/autotest.diff-with-develop.json` - `docs/autotest-workflow.md` -- 现仅保留 Job 文件方案(`.trae/jobs/autotest.md`)。 +- 现仅保留 Job 文件方案(`.trae/jobs/auto-test.md`)。 ## 默认参数(参考) @@ -73,6 +74,7 @@ reportFormat: md - `dryRun=false` - `preview=false` - `stopOnError=true` -- `focusChangedOnly=true` +- `focusChangedOnly=false` - `snapshotStrategy=combined` +- `tempReportPath=./.trae/output/autotest.report.local.md` - `mockDefaults: time=fixed(2020-01-01T00:00:00Z), random=seed(42)` diff --git a/.trae/jobs/auto-flow.md b/.trae/jobs/auto-flow.md new file mode 100644 index 0000000000..015eb762bf --- /dev/null +++ b/.trae/jobs/auto-flow.md @@ -0,0 +1,95 @@ +--- +job: release-prep-pipeline +intent: prepare-release +version: v1 +domain: pipeline +runner: trae-solo +parameters: + baseBranch: develop + lang: zh + labels: + - changelog + - test + topic: '' + message: '' + bumpType: auto + notCommit: true + head: '' + mode: auto + commitBeforeFlow: true + commitAllowEmpty: false + pushAfterCommit: true + commitMessageStrategy: auto + enforceCommit: true + commitRetry: 1 +required_parameters: [] +outputs: + - autotest_report + - rush_change_entries + - pr_url +success_criteria: + - flow_completed +--- + +# Auto Flow Job(分支 → 单测 → 变更日志 →PR 串行编排) + +## 参数检查 + +- 分支参数 `head` 可选:若未提供,将通过 `git rev-parse --abbrev-ref HEAD` 推导当前分支 +- 建议提供 `topic` 以优化 PR 标题;未提供时将回退为当前分支名 + +## 步骤 + +1. 分支预检查 + +- 运行 `git rev-parse --abbrev-ref HEAD` 获取当前分支作为 `head` +- 确认当前分支不是 `main`/`develop`,且工作树状态符合提交规范 +- 人工检查点:如不在开发分支,请先自行创建并切换到正确分支 + + 1.1 自动提交未提交变更(当 `commitBeforeFlow==true`) + +- 检查工作树:`git status --porcelain` +- 若存在未提交变更: + - `git add --all` + - 生成提交信息(按 `commitMessageStrategy`): + - `auto`:类型 `chore`;作用域为顶层或包名(如 `vchart`);主题为 `sync changes before Auto Flow` + - 最终示例:`chore(vchart): sync changes before Auto Flow` + - 运行 `git commit {{#commitAllowEmpty}}--allow-empty{{/commitAllowEmpty}} -m ""` + - 若 `pushAfterCommit==true`:`git push -u origin {{head}}` + - 提交后校验(当 `enforceCommit==true`): + - 运行 `git status --porcelain`,若非空则视为失败;进行最多 `commitRetry` 次重试(`git add --all && git commit -m ''`),仍失败则中止流程并提示处理 +- 若 `commitBeforeFlow==false` 且存在未提交变更:直接失败并提示先完成提交 + +2. 运行差异驱动单测 + +- 执行 Job:`.trae/jobs/auto-test.md` +- 传参:`sinceBranch={{baseBranch}}`(其余沿用默认) +- 接收输出:`autotest_report=.trae/output/autotest.report.local.md` +- 人工检查点:打开临时报告,确认新增/更新测试与覆盖率 + +3. 生成 Rush 变更日志 + +- 执行 Job:`.trae/jobs/changelog-rush-smart.md` +- 传参:`sinceBranch={{baseBranch}}`、`message={{message}}`、`bumpType={{bumpType}}`、`notCommit={{notCommit}}` +- 接收输出:`rush_change_entries` +- 人工检查点:检查 `common/changes/**` 条目与摘要 + +4. 创建 PR + +- 执行 Job:`.trae/jobs/pr-create.md` +- 传参: + - `base={{baseBranch}}` + - `head={{head}}` + - `title='[Auto] {{topic || head}}'` + - `lang={{lang}}` + - `labels={{labels}}` + - `message={{message}}`(用于正文摘要) + - `bumpType={{bumpType}}` + - `mode={{mode}}`(auto 优先 gh → token → 浏览器 URL) + - `commitBeforeCreate=false`(已在 1.1 阶段完成自动提交) +- 接收输出:`pr_url` +- 人工检查点:最终确认并提交 + +5. 完成 + +- 标记 `flow_completed`,返回 `autotest_report`、`rush_change_entries` 与 `pr_url` diff --git a/.trae/jobs/autotest.md b/.trae/jobs/auto-test.md similarity index 94% rename from .trae/jobs/autotest.md rename to .trae/jobs/auto-test.md index acf9b3b68c..4d556199ee 100644 --- a/.trae/jobs/autotest.md +++ b/.trae/jobs/auto-test.md @@ -12,13 +12,13 @@ parameters: onlyNew: false reportFormat: md applyManualOverrides: true - replaceAutogen: false + replaceAutogen: true dryRun: false preview: false stopOnError: true - focusChangedOnly: true + focusChangedOnly: false snapshotStrategy: combined - tempReportPath: .trae/jobs/autotest.report.local.md + tempReportPath: .trae/output/autotest.report.local.md mockDefaults: time: fixed(2020-01-01T00:00:00Z) random: seed(42) @@ -39,7 +39,7 @@ success_criteria: manual_overrides: [] --- -# Autotest Job(差异驱动单元测试自动生成) +# Auto Test Job(差异驱动单元测试自动生成) ## 步骤 @@ -131,7 +131,7 @@ manual_overrides: ## 执行(Solo 模式) -- 最简用法(使用默认参数):在聊天中发起“执行 Autotest Job(.trae/jobs/autotest.md)”。 +- 最简用法(使用默认参数):在聊天中发起“执行 Auto Test Job(.trae/jobs/auto-test.md)”。 - 可选覆盖参数示例:`project=@visactor/vchart-theme`、`reportFormat=json`、`replaceAutogen=true`。 - 我将按上述步骤顺序执行,并返回报告与人工节点处理结果。 -- 临时报告路径可通过 `tempReportPath` 覆盖,默认:`.trae/jobs/autotest.report.local.md`。 +- 临时报告路径可通过 `tempReportPath` 覆盖,默认:`.trae/output/autotest.report.local.md`。 diff --git a/.trae/jobs/autotest.request.md b/.trae/jobs/autotest.request.md deleted file mode 100644 index 5ecd56f3e6..0000000000 --- a/.trae/jobs/autotest.request.md +++ /dev/null @@ -1,21 +0,0 @@ -# Task -Autotest (diff-with-develop) - -# Parameters -sinceBranch: develop -project: '' -mode: full -noSnapshot: false -onlyNew: false -reportFormat: md - -# ExecutionHints -- skipWrite: false -- stopOnError: true - -# StepsOverride -# 如需覆盖默认步骤,取消下面行的注释并按需修改 -# - git fetch --all --prune -# - git diff --name-status --diff-filter=AMR develop...HEAD -# - rush run -s test -# - rush run -s test-cov diff --git a/.trae/jobs/changelog-rush-smart.md b/.trae/jobs/changelog-rush-smart.md new file mode 100644 index 0000000000..fbbde29082 --- /dev/null +++ b/.trae/jobs/changelog-rush-smart.md @@ -0,0 +1,82 @@ +--- +job: generate-rush-changes-smart +intent: rush-change-smart +version: v1 +domain: release +runner: trae-solo +parameters: + sinceBranch: develop + message: '' + bumpType: auto + notCommit: true + githubToken: '' +required_parameters: [] +outputs: + - rush_change_entries + - computed_bump_type + - final_message +success_criteria: + - rush_changes_generated + - commitlint_passed +manual_overrides: [] +--- + +# Changelog Job(智能 Rush 变更日志生成) + +## 参数检查 + +- 无必填参数,均有默认值 +- 如需“关联 Issue 标题”自动聚合,请提供 `githubToken` + +## 步骤 + +1. 采集差异与提交 + +- 运行 `git diff --name-only {{sinceBranch}}...HEAD`,按文件路径映射到变更包 +- 运行 `git log --pretty=%H:::%s {{sinceBranch}}...HEAD`,收集提交主题 + +2. 自动判定 bumpType(可被参数覆盖) + +- 规则: + - 含 `BREAKING CHANGE` 或 `!` → `major` + - 含 `feat` → `minor` + - 其余(`fix|perf|refactor|docs|chore|test`)→ `patch` +- 若 `parameters.bumpType != auto`,则使用显式值 +- 将结果写入输出:`computed_bump_type` + +3. 构建富消息(可被参数覆盖) + +- 若 `parameters.message` 为空: + - 提取关键提交的主题(优先 `feat`/`fix`)形成“提交概览” + - 从提交中解析 `#`,调用 GitHub API 读取 Issue 标题(需 `githubToken`),形成“关联 Issue” + - 构建最终消息:首行摘要 + 提交概览 + 关联 Issue + 影响包 +- 将最终消息写入输出:`final_message` + +4. 提交信息校验 + +- 使用 `common/autoinstallers/lint/commitlint.config.js` 与本地 `commitlint` 执行校验 +- 命令:`echo "{{final_message}}" | commitlint --config common/autoinstallers/lint/commitlint.config.js` + +5. 生成 Rush 变更条目 + +- 执行 `rush change --bulk --bump-type '{{computed_bump_type}}' --message '{{final_message}}'` +- 输出文件位于 `common/changes/**`,收集为 `rush_change_entries` + +6. 可选提交 + +- 若 `notCommit != true`: + - 运行 `git add --all` + - 运行 `git commit -m 'docs: update changlog of rush'` + +7. 人工检查点 + +- 展示 `rush_change_entries`:路径、包名、bumpType、摘要 +- 如摘要需细化,编辑 `parameters.message` 或在二次执行中通过 `manual_overrides` 指定 + +## manual_overrides 示例 + +```yaml +manual_overrides: + - bumpType: minor + message: 'feat(core): 新增交互缩放配置,修复事件抛出问题 (#123)' +``` diff --git a/.trae/jobs/create-branch.md b/.trae/jobs/create-branch.md new file mode 100644 index 0000000000..7fc334ff4c --- /dev/null +++ b/.trae/jobs/create-branch.md @@ -0,0 +1,52 @@ +--- +job: create-dev-branch +intent: gitflow-create-branch +version: v1 +domain: git +runner: trae-solo +parameters: + baseBranch: develop + branchPrefix: chore/trae + topic: '' + useDateSuffix: true +required_parameters: + - topic +outputs: + - branch_name +success_criteria: + - branch_created + - clean_working_tree +--- + +# Create Branch Job(创建开发分支) + +## 参数检查 + +- 必填参数:`topic` +- 若未提供:请在执行入口中补充 `topic`(示例:`topic: perf-legend-opt`),再继续后续步骤。 + +## 步骤 + +1. 同步基础分支 + +- 运行 `git fetch --all --prune` +- 运行 `git checkout {{baseBranch}} && git pull origin {{baseBranch}}` + +2. 生成分支名 + +- 命名规则:`{{branchPrefix}}-{{topic}}-{{YYYYMMDD-HHMM}}` +- 将生成的分支名写入输出:`branch_name` + +3. 创建分支 + +- 运行 `git checkout -b {{branch_name}}` + +4. 人工检查点 + +- 运行 `git status` 并确认: + - 当前分支为 `{{branch_name}}` + - 工作树干净或仅包含预期改动 + +## 结果 + +- 成功则输出 `branch_name`,并保证后续任务在该分支上执行。 diff --git a/.trae/jobs/pr-create.md b/.trae/jobs/pr-create.md new file mode 100644 index 0000000000..5843884e99 --- /dev/null +++ b/.trae/jobs/pr-create.md @@ -0,0 +1,167 @@ +--- +job: create-pr +intent: github-pr +version: v1 +domain: github +runner: trae-solo +parameters: + base: develop + head: '' + title: '' + lang: zh + labels: [] + draft: false + useGhCli: true + mode: auto # auto|gh|rest|browser + localBodyFile: false + openBrowser: true + commitBeforeCreate: false + commitMessage: '' + commitAllowEmpty: false + pushAfterCommit: true + commitMessageStrategy: auto # auto|topic|manual +required_parameters: + - title +inputs: + autotestReport: .trae/output/autotest.report.local.md + rushChangesDir: common/changes + bumpType: '' + message: '' +outputs: + - pr_url + - compare_url + - generated_title + - generated_body_preview +success_criteria: + - pr_created +--- + +# PR Job(根据模版创建 Pull Request) + +## 参数检查 + +- 必填参数:`title` +- 分支参数 `head` 可选:若未提供,将在执行阶段通过 `git rev-parse --abbrev-ref HEAD` 推导当前分支 + +## 步骤 + +1. 提交未提交的变更并推送(可选) + +- 获取 `head`:若未提供,通过 `git rev-parse --abbrev-ref HEAD` 推导 +- 检查工作树:`git status --porcelain` +- 若存在未提交变更且 `commitBeforeCreate == true`: + - 运行 `git add --all` + - 生成提交信息(按 `commitMessageStrategy`): + - `auto`: + - 类型判定:包含 `docs/` → `docs`;包含 `__tests__`/`*.test.*` → `test`;否则 → `chore` + - 作用域:变更路径为 `packages//...` 时取 ``;否则取顶层目录(如 `docs`、`tools`、`common`、`.trae`) + - 主题:若提供 `message` 则使用其首行摘要;否则生成 `sync changes before PR ( files)` 并附加关键作用域 + - 结果示例:`chore(vchart,tools): sync changes before PR (5 files)` + - `topic`:使用 `title` 或外层 `topic` 作为主题,类型与作用域同上 + - `manual`:使用显式 `commitMessage` + - 运行 `git commit {{#commitAllowEmpty}}--allow-empty{{/commitAllowEmpty}} -m "{{}}"` + - 若 `pushAfterCommit == true`:运行 `git push -u origin {{head}}` +- 人工检查点: + - 若存在未提交变更但未开启自动提交,请先人工完成提交与推送再继续创建 PR + +2. 选择 PR 模版 + +- 当 `{{lang}} == zh`:使用 `.github/PULL_REQUEST_TEMPLATE/pr_cn.md` +- 否则使用 `.github/PULL_REQUEST_TEMPLATE.md` + +3. 准备正文 + +- 若已提供完整 `message`(摘要)与必要信息(关联链接等),可直接使用作为 PR body +- 若需要补充人工内容:提示用户完善 body 文本后再继续(不生成临时文件) + +- 生成可复制内容: +- `generated_title = [Auto] {{title || (topic || head)}}` +- 生成完整 PR 正文预览(Markdown 代码块),基于 `.github/PULL_REQUEST_TEMPLATE/pr_cn.md` 自动填充: + - 勾选项:`{{branch_type_checks}}`(如:新功能、Workflow 等) + - 关联:`{{issue_links}}`、`{{related_pr_links}}`、`{{bugserver_ids}}` + - 背景与方案:`{{background_solution}}`(从 `message` 与上下文生成) + - Changelog 表:`{{changelog_en}}` 与 `{{changelog_zh}}`(解析 `common/changes/**`) + - 自测勾选项:`{{self_check_items}}` + - Summary 与 Walkthrough:`{{summary_text}}`、`{{walkthrough_text}}`(包含分支、模板来源、测试摘要) +- 代码块示例结构: + + ```markdown + ### 🤔 这个分支是... + + - [x] 新功能 + - [x] Workflow + + ### 🔗 相关 issue 链接 + + {{issue_links}} + + ### 🔗 相关的 PR 链接 + + {{related_pr_links}} + + ### 🐞 Bugserver 用例 id + + {{bugserver_ids}} + + ### 💡 问题的背景&解决方案 + + {{background_solution}} + + ### 📝 Changelog + + | Language | Changelog | + | ---------- | ---------------- | + | 🇺🇸 English | {{changelog_en}} | + | 🇨🇳 Chinese | {{changelog_zh}} | + + ### ☑️ 自测 + + {{self_check_items}} + + --- + + ### 🚀 Summary + + {{summary_text}} + + ### 🔍 Walkthrough + + {{walkthrough_text}} + ``` + +- 若 `localBodyFile=true`:以完整代码块形式写入 `./.trae/output/pr.body.local.md`(被忽略提交) + +4. 人工检查点 + +- 若 body 需要补充,请人工完成后继续(不生成临时文件) + +5. 创建 PR + +- 模式选择: + + - `auto`:优先使用 `gh`(若已安装并登录);其次使用 `GITHUB_TOKEN` 的 REST;最后提供浏览器 URL 手动创建 + - `gh`:使用 GitHub CLI 创建(需本机已登录) + - `rest`:使用 `GITHUB_TOKEN` 调用 REST API 创建 + - `browser`:生成 compare URL,打开浏览器页面手动确认 + +- 检测与执行: + - 若未提供 `head`:先运行 `git rev-parse --abbrev-ref HEAD` 以推导当前分支 + - 检测 `gh`:`command -v gh` 成功则执行: + - `gh pr create --base {{base}} --title "{{title}}" --body "{{message}}" --head {{head}} {{#labels}}--label {{labels}}{{/labels}} {{#draft}}--draft{{/draft}}` + - 若无 `gh` 而存在 `GITHUB_TOKEN`:使用 REST API `POST /repos/{owner}/{repo}/pulls`,body 使用 `{{message}}` + - 否则生成 compare URL: + - `compare_url = https://github.com/VisActor/VChart/compare/{{base}}...{{head}}?expand=1` + - 输出 `generated_title` 与以完整 Markdown 代码块格式的 `generated_body_preview`,便于直接复制到 PR 页面;若 `openBrowser=true` 在 macOS 运行 `open {{compare_url}}` + +6. 结果 + +- 返回 `pr_url`,并在成功标准中标记为 `pr_created` +- 在 `browser` 模式:返回 `compare_url`、`generated_title` 与完整的 `generated_body_preview` + (其中 `generated_body_preview` 为包含所有模板栏目且已自动填充的 Markdown 代码块) + +## 额外提示 + +- 自动创建 PR 有三种方式: + - 本机已登录 `gh`:无需额外令牌(SSH 仅用于 git 操作,API 权限由 `gh` 登录提供) + - 本机无 `gh`:提供 `GITHUB_TOKEN` 用 REST API 创建 + - 两者都不可用:生成 compare URL,使用浏览器登录后手动创建 diff --git a/common/changes/@visactor/vchart/feat-add-auto-flow-in-trae_2025-12-23-06-19.json b/common/changes/@visactor/vchart/feat-add-auto-flow-in-trae_2025-12-23-06-19.json new file mode 100644 index 0000000000..e41a8f7680 --- /dev/null +++ b/common/changes/@visactor/vchart/feat-add-auto-flow-in-trae_2025-12-23-06-19.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "docs: chore(trae): add Trae jobs: auto-flow, smart changelog, PR pipeline", + "type": "patch", + "packageName": "@visactor/vchart" + } + ], + "packageName": "@visactor/vchart", + "email": "lixuef1313@163.com" +} diff --git a/packages/vchart/src/component/geo/geo-coordinate.ts b/packages/vchart/src/component/geo/geo-coordinate.ts index 3db4d04bb7..5dc42f74b2 100644 --- a/packages/vchart/src/component/geo/geo-coordinate.ts +++ b/packages/vchart/src/component/geo/geo-coordinate.ts @@ -129,8 +129,14 @@ export class GeoCoordinate extends BaseComponent implements IGeo // this.rescaleMark(); } + /** + * 处理图表缩放事件,按 zoomRate 调整缩放强度 + * 使用幂次映射保持缩放因子始终为正:scale' = (zoomDelta)^zoomRate + */ private _handleChartZoom = (params: ZoomEventParams, event?: BaseEventParams['event']) => { - let scale = params.zoomDelta; + const rate = isValid(this._spec.zoomRate) ? Math.max(0, this._spec.zoomRate as number) : 1; + const delta = Math.max(params.zoomDelta, 1e-6); + let scale = Math.pow(delta, rate); // check if the next scale will outrange const _lastActualScale = this._actualScale; this._actualScale *= scale; @@ -397,7 +403,7 @@ export class GeoCoordinate extends BaseComponent implements IGeo _compareSpec(spec: IGeoRegionSpec, prevSpec: IGeoRegionSpec) { const result = super._compareSpec(spec, prevSpec); if (!result.reMake) { - result.reMake = ['roam', 'longitudeField', 'latitudeField', 'projection', 'zoomLimit'].some(k => { + result.reMake = ['roam', 'longitudeField', 'latitudeField', 'projection', 'zoomLimit', 'zoomRate'].some(k => { return !isEqual(prevSpec?.[k as keyof IGeoRegionSpec], spec[k as keyof IGeoRegionSpec]); }); } diff --git a/packages/vchart/src/region/interface.ts b/packages/vchart/src/region/interface.ts index d2e08bbf24..c6dad6fba1 100644 --- a/packages/vchart/src/region/interface.ts +++ b/packages/vchart/src/region/interface.ts @@ -103,6 +103,11 @@ export interface IGeoRegionSpec extends IRegionSpec { */ max?: number; }; + /** + * 缩放速率(比例因子),用于加速或减缓缩放 + * @default 1 + */ + zoomRate?: number; } export type RegionSpec = IRegionSpec | IGeoRegionSpec;