@comate/zulu 1.2.1-beta.2 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/comate-engine/assets/skills/auto-commit-comate/SKILL.md +260 -0
- package/comate-engine/assets/skills/auto-commit-comate/references/data_structures.md +189 -0
- package/comate-engine/assets/skills/auto-commit-comate/references/new_version_instruction.md +209 -0
- package/comate-engine/assets/skills/auto-commit-comate/references/old_version_instruction.md +208 -0
- package/comate-engine/assets/skills/auto-commit-comate/scripts/git_diff_cli.py +196 -0
- package/comate-engine/assets/skills/{smart-commit → auto-commit-comate}/scripts/git_utils.py +20 -10
- package/comate-engine/assets/skills/{smart-commit → auto-commit-comate}/scripts/icafe/client.py +69 -40
- package/comate-engine/assets/skills/{smart-commit → auto-commit-comate}/scripts/icafe/farseer.py +8 -9
- package/comate-engine/assets/skills/{smart-commit → auto-commit-comate}/scripts/icafe/matching.py +65 -9
- package/comate-engine/assets/skills/auto-commit-comate/scripts/match_card_cli.py +37 -0
- package/comate-engine/assets/skills/cnap-comate/SKILL.md +157 -0
- package/comate-engine/assets/skills/cnap-comate/references/cases.md +198 -0
- package/comate-engine/assets/skills/cnap-comate/references/deploy-troubleshoot.md +15 -0
- package/comate-engine/assets/skills/cnap-comate/references/install.md +43 -0
- package/comate-engine/assets/skills/cnap-comate/references/kubectl.md +55 -0
- package/comate-engine/assets/skills/cnap-comate/references/login.md +125 -0
- package/comate-engine/assets/skills/cnap-comate/references/oncall.md +24 -0
- package/comate-engine/assets/skills/cnap-comate/scripts/install_cnap_cli.sh +36 -0
- package/comate-engine/assets/skills/code-security/SKILL.md +176 -0
- package/comate-engine/assets/skills/code-security/references/credential_hosting.md +102 -0
- package/comate-engine/assets/skills/code-security/references/vul_repair_sensitive.md +219 -0
- package/comate-engine/assets/skills/code-security/scripts/build_repair_info.py +0 -0
- package/comate-engine/assets/skills/code-security/scripts/credential_hosting.py +99 -0
- package/comate-engine/assets/skills/code-security/scripts/credential_poll.py +350 -0
- package/comate-engine/assets/skills/code-security/scripts/http_client.py +173 -0
- package/comate-engine/assets/skills/code-security/scripts/parse_scan_result.py +301 -0
- package/comate-engine/assets/skills/code-security/scripts/repair_vulnerability.py +261 -0
- package/comate-engine/assets/skills/code-security/scripts/report_chat.py +198 -0
- package/comate-engine/assets/skills/code-security/scripts/scan_vulnerability.py +316 -0
- package/comate-engine/assets/skills/code-security-comate/SKILL.md +219 -0
- package/comate-engine/assets/skills/code-security-comate/references/credential_hosting.md +102 -0
- package/comate-engine/assets/skills/code-security-comate/references/vul_repair-go_sql_injection.md +399 -0
- package/comate-engine/assets/skills/code-security-comate/references/vul_repair-java_sql_injection.md +591 -0
- package/comate-engine/assets/skills/code-security-comate/references/vul_repair-php_sql_injection.md +318 -0
- package/comate-engine/assets/skills/code-security-comate/references/vul_repair-python_sql_injection.md +198 -0
- package/comate-engine/assets/skills/code-security-comate/references/vul_repair_sensitive.md +219 -0
- package/comate-engine/assets/skills/code-security-comate/scripts/credential_hosting.py +87 -0
- package/comate-engine/assets/skills/code-security-comate/scripts/credential_poll.py +345 -0
- package/comate-engine/assets/skills/code-security-comate/scripts/http_client.py +173 -0
- package/comate-engine/assets/skills/code-security-comate/scripts/parse_scan_result.py +392 -0
- package/comate-engine/assets/skills/code-security-comate/scripts/repair_vulnerability.py +245 -0
- package/comate-engine/assets/skills/code-security-comate/scripts/report_chat.py +145 -0
- package/comate-engine/assets/skills/code-security-comate/scripts/scan_vulnerability.py +444 -0
- package/comate-engine/assets/skills/code-security-comate/scripts/utils.py +153 -0
- package/comate-engine/assets/skills/comate-docs-comate/SKILL.md +148 -0
- package/comate-engine/assets/skills/comate-docs-comate/references/doc-map-extended.md +78 -0
- package/comate-engine/assets/skills/comate-docs-comate/references/models-and-billing.md +51 -0
- package/comate-engine/assets/skills/comate-docs-comate/references/product-overview.md +73 -0
- package/comate-engine/assets/skills/comate-docs-comate/references/query_content.md +83 -0
- package/comate-engine/assets/skills/comate-docs-comate/references/query_repo.md +57 -0
- package/comate-engine/assets/skills/comate-docs-comate/scripts/ku_operator.py +1575 -0
- package/comate-engine/assets/skills/create-image-comate/SKILL.md +278 -0
- package/comate-engine/assets/skills/create-skill-comate/SKILL.md +308 -217
- package/comate-engine/assets/skills/create-skill-comate/agents/analyzer.md +274 -0
- package/comate-engine/assets/skills/create-skill-comate/agents/comparator.md +202 -0
- package/comate-engine/assets/skills/create-skill-comate/agents/grader.md +223 -0
- package/comate-engine/assets/skills/create-skill-comate/assets/eval_review.html +146 -0
- package/comate-engine/assets/skills/create-skill-comate/eval-viewer/generate_review.py +489 -0
- package/comate-engine/assets/skills/create-skill-comate/eval-viewer/viewer.html +1325 -0
- package/comate-engine/assets/skills/create-skill-comate/references/schemas.md +430 -0
- package/comate-engine/assets/skills/create-skill-comate/scripts/__init__.py +0 -0
- package/comate-engine/assets/skills/create-skill-comate/scripts/__pycache__/__init__.cpython-311.pyc +0 -0
- package/comate-engine/assets/skills/create-skill-comate/scripts/__pycache__/aggregate_benchmark.cpython-311.pyc +0 -0
- package/comate-engine/assets/skills/create-skill-comate/scripts/aggregate_benchmark.py +412 -0
- package/comate-engine/assets/skills/create-skill-comate/scripts/generate_report.py +334 -0
- package/comate-engine/assets/skills/create-skill-comate/scripts/package_skill.py +140 -0
- package/comate-engine/assets/skills/create-skill-comate/scripts/utils.py +53 -0
- package/comate-engine/assets/skills/find-skills-comate/SKILL.md +15 -12
- package/comate-engine/assets/skills/find-skills-comate/scripts/fetch_skills.py +32 -3
- package/comate-engine/assets/skills/get-ugate-token-comate/SKILL.md +159 -0
- package/comate-engine/assets/skills/get-ugate-token-comate/getUgateToken.py +150 -0
- package/comate-engine/assets/skills/icafe-comate/SKILL.md +240 -0
- package/comate-engine/assets/skills/icafe-comate/references/ai-workflows.md +233 -0
- package/comate-engine/assets/skills/icafe-comate/references/commands.md +1147 -0
- package/comate-engine/assets/skills/icafe-comate/references/error-handling.md +164 -0
- package/comate-engine/assets/skills/icafe-comate/references/git-auto-bindcard-workflow.md +201 -0
- package/comate-engine/assets/skills/icafe-comate/references/git-bindcard-workflow.md +327 -0
- package/comate-engine/assets/skills/icafe-comate/references/iql-syntax.md +327 -0
- package/comate-engine/assets/skills/icafe-comate/references/platform-concepts.md +317 -0
- package/comate-engine/assets/skills/icafe-comate/references/smart-create-workflow.md +171 -0
- package/comate-engine/assets/skills/icafe-comate/references/smart-find-workflow.md +127 -0
- package/comate-engine/assets/skills/icafe-comate/references/smart-update-workflow.md +118 -0
- package/comate-engine/assets/skills/icode-comate/SKILL.md +366 -0
- package/comate-engine/assets/skills/icode-comate/references/api/add_reviewers.md +44 -0
- package/comate-engine/assets/skills/icode-comate/references/api/build_fetch_command.md +89 -0
- package/comate-engine/assets/skills/icode-comate/references/api/check_repo_permission.md +89 -0
- package/comate-engine/assets/skills/icode-comate/references/api/create_branch.md +79 -0
- package/comate-engine/assets/skills/icode-comate/references/api/create_draft_comment.md +109 -0
- package/comate-engine/assets/skills/icode-comate/references/api/get_ai_cr_result.md +190 -0
- package/comate-engine/assets/skills/icode-comate/references/api/get_ai_review.md +97 -0
- package/comate-engine/assets/skills/icode-comate/references/api/get_diff_content.md +92 -0
- package/comate-engine/assets/skills/icode-comate/references/api/get_diff_file.md +88 -0
- package/comate-engine/assets/skills/icode-comate/references/api/get_machine_check.md +73 -0
- package/comate-engine/assets/skills/icode-comate/references/api/get_my_reviews.md +115 -0
- package/comate-engine/assets/skills/icode-comate/references/api/get_person_commit.md +89 -0
- package/comate-engine/assets/skills/icode-comate/references/api/get_person_repo.md +63 -0
- package/comate-engine/assets/skills/icode-comate/references/api/get_repo_branch.md +62 -0
- package/comate-engine/assets/skills/icode-comate/references/api/get_repo_config.md +91 -0
- package/comate-engine/assets/skills/icode-comate/references/api/get_repo_members.md +118 -0
- package/comate-engine/assets/skills/icode-comate/references/api/get_repo_reviews.md +91 -0
- package/comate-engine/assets/skills/icode-comate/references/api/get_review_comments.md +87 -0
- package/comate-engine/assets/skills/icode-comate/references/api/get_review_info.md +81 -0
- package/comate-engine/assets/skills/icode-comate/references/api/get_submit_settings.md +105 -0
- package/comate-engine/assets/skills/icode-comate/references/api/icode-api.md +86 -0
- package/comate-engine/assets/skills/icode-comate/references/api/publish_comments.md +72 -0
- package/comate-engine/assets/skills/icode-comate/references/api/set_review_score.md +58 -0
- package/comate-engine/assets/skills/icode-comate/references/api/start_ai_review.md +77 -0
- package/comate-engine/assets/skills/icode-comate/references/api/submit_review.md +50 -0
- package/comate-engine/assets/skills/icode-comate/references/api/trigger_ai_cr.md +63 -0
- package/comate-engine/assets/skills/icode-comate/references/feature/add-reviewer.md +92 -0
- package/comate-engine/assets/skills/icode-comate/references/feature/fix-machine-check.md +144 -0
- package/comate-engine/assets/skills/icode-comate/references/feature/merge-cr.md +100 -0
- package/comate-engine/assets/skills/icode-comate/references/feature/ssh-setup.md +106 -0
- package/comate-engine/assets/skills/icode-comate/references/feature/submit-acr.md +135 -0
- package/comate-engine/assets/skills/icode-comate/references/feature/submit-cr.md +123 -0
- package/comate-engine/assets/skills/icode-comate/references/git/clone.md +67 -0
- package/comate-engine/assets/skills/icode-comate/references/git/icode-git.md +68 -0
- package/comate-engine/assets/skills/icode-comate/references/git/push.md +64 -0
- package/comate-engine/assets/skills/icode-comate/references/git/push_cr.md +103 -0
- package/comate-engine/assets/skills/icode-comate/references/install.md +144 -0
- package/comate-engine/assets/skills/icode-comate/references/login.md +111 -0
- package/comate-engine/assets/skills/icode-comate/scripts/add-reviewer.sh +154 -0
- package/comate-engine/assets/skills/icode-comate/scripts/common.sh +145 -0
- package/comate-engine/assets/skills/icode-comate/scripts/fix-machine-check.sh +131 -0
- package/comate-engine/assets/skills/icode-comate/scripts/merge-cr.sh +105 -0
- package/comate-engine/assets/skills/icode-comate/scripts/ssh-setup.sh +159 -0
- package/comate-engine/assets/skills/icode-comate/scripts/submit-acr.sh +236 -0
- package/comate-engine/assets/skills/icode-comate/scripts/submit-cr.sh +104 -0
- package/comate-engine/assets/skills/icode-comate/scripts/test-preflight.sh +89 -0
- package/comate-engine/assets/skills/ku-operator-comate/SKILL.md +121 -0
- package/comate-engine/assets/skills/ku-operator-comate/examples.md +190 -0
- package/comate-engine/assets/skills/ku-operator-comate/references/add_member.md +49 -0
- package/comate-engine/assets/skills/ku-operator-comate/references/change_scope.md +38 -0
- package/comate-engine/assets/skills/ku-operator-comate/references/copy_doc.md +50 -0
- package/comate-engine/assets/skills/ku-operator-comate/references/create_doc.md +61 -0
- package/comate-engine/assets/skills/ku-operator-comate/references/delete_doc.md +31 -0
- package/comate-engine/assets/skills/ku-operator-comate/references/edit_content.md +568 -0
- package/comate-engine/assets/skills/ku-operator-comate/references/move_doc.md +45 -0
- package/comate-engine/assets/skills/ku-operator-comate/references/query_comment.md +79 -0
- package/comate-engine/assets/skills/ku-operator-comate/references/query_content.md +83 -0
- package/comate-engine/assets/skills/ku-operator-comate/references/query_flowchart.md +84 -0
- package/comate-engine/assets/skills/ku-operator-comate/references/query_permission.md +38 -0
- package/comate-engine/assets/skills/ku-operator-comate/references/query_recent_view.md +67 -0
- package/comate-engine/assets/skills/ku-operator-comate/references/query_repo.md +57 -0
- package/comate-engine/assets/skills/ku-operator-comate/references/query_user_info.md +37 -0
- package/comate-engine/assets/skills/ku-operator-comate/references/update_member.md +41 -0
- package/comate-engine/assets/skills/ku-operator-comate/references/upload_attachment.md +52 -0
- package/comate-engine/assets/skills/ku-operator-comate/scripts/ku_operator.py +1575 -0
- package/comate-engine/node_modules/better-sqlite3/node_modules/.bin/prebuild-install +2 -2
- package/comate-engine/node_modules/tree-sitter-bash/node_modules/.bin/node-gyp-build +2 -2
- package/comate-engine/node_modules/tree-sitter-bash/node_modules/.bin/node-gyp-build-optional +2 -2
- package/comate-engine/node_modules/tree-sitter-bash/node_modules/.bin/node-gyp-build-test +2 -2
- package/comate-engine/package.json +2 -0
- package/comate-engine/server.js +170 -46
- package/dist/bundle/index.js +8 -8
- package/package.json +1 -1
- package/comate-engine/assets/skills/figma2code-comate/codeConnect.md +0 -37
- package/comate-engine/assets/skills/figma2code-comate/designToken.md +0 -3
- package/comate-engine/assets/skills/figma2code-comate/f2cMcp.md +0 -59
- package/comate-engine/assets/skills/smart-commit/SKILL.md +0 -646
- package/comate-engine/node_modules/@comate/plugin-host/dist/index-AZIho4HV.js +0 -1
- package/comate-engine/node_modules/@comate/plugin-host/dist/user-BIpzRUfb.js +0 -44
- package/comate-engine/node_modules/better-sqlite3/build/Release/better_sqlite3.node +0 -0
- /package/comate-engine/assets/skills/{smart-commit → auto-commit-comate}/references/issue_type_mapping.json +0 -0
- /package/comate-engine/assets/skills/{smart-commit → auto-commit-comate}/references/query_reference.md +0 -0
- /package/comate-engine/assets/skills/{smart-commit → auto-commit-comate}/scripts/compat.py +0 -0
- /package/comate-engine/assets/skills/{smart-commit → auto-commit-comate}/scripts/create_card_cli.py +0 -0
- /package/comate-engine/assets/skills/{smart-commit → auto-commit-comate}/scripts/icafe/__init__.py +0 -0
- /package/comate-engine/assets/skills/{smart-commit → auto-commit-comate}/scripts/logger.py +0 -0
- /package/comate-engine/assets/skills/{smart-commit → auto-commit-comate}/scripts/recognize_card_cli.py +0 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: auto-commit
|
|
3
|
+
description: 当用户完成代码修改、需要提交代码时,必须使用此 skill,而非直接执行 git commit。自动获取 git diff、匹配 iCafe 活跃卡片、生成 commit message,并引导用户完成绑定卡片和代码提交。
|
|
4
|
+
metadata:
|
|
5
|
+
enableWhen:
|
|
6
|
+
- isInternal
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# 智能提交助手
|
|
10
|
+
|
|
11
|
+
## 版本信息
|
|
12
|
+
|
|
13
|
+
- **IDE 名称**: ${COMATE_IDE_NAME}
|
|
14
|
+
- **插件版本**: ${COMATE_PLUGIN_VERSION}
|
|
15
|
+
- **用户名**: ${COMATE_USERNAME}
|
|
16
|
+
|
|
17
|
+
## 概述
|
|
18
|
+
|
|
19
|
+
本技能将当前工作区的 git diff 与用户在 iCafe 上的活跃卡片进行匹配,支持选择已有卡片或新建卡片,自动生成 commit message 并完成提交。
|
|
20
|
+
|
|
21
|
+
**调起即执行,流程完全固定,不做任何意图分析。**
|
|
22
|
+
|
|
23
|
+
## 流程总览
|
|
24
|
+
|
|
25
|
+
根据前置检查结果,流程分为两条主线:
|
|
26
|
+
|
|
27
|
+
- **iCode 仓库** (`is_icode_repo = true`):步骤 0 → 1+2(并行) → 3 → 4 → 5 → 6 → 7 → 8 → 9
|
|
28
|
+
- **非 iCode 仓库** (`is_icode_repo = false`):步骤 0 → 2 → 7 → 8 → 9(跳过 1/3/4/5/6,commit message 不带卡片 ID)
|
|
29
|
+
|
|
30
|
+
**版本交互方式:** 根据步骤 0a 判定的版本,后续命令和交互有差异:
|
|
31
|
+
- **新版本**:参考 `references/new_version_instruction.md`。**新版本下 Agent 必须通过 `__interactive:` UI 组件与用户交互(步骤 4 用 `__interactive:icafe-cards`,步骤 8 用 `__interactive:git-commit`),禁止用纯文本输出替代 UI。**
|
|
32
|
+
- **旧版本**:参考 `references/old_version_instruction.md`
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 步骤 0:前置检查(串行执行,完全静默)
|
|
37
|
+
|
|
38
|
+
**整个前置检查过程完全静默,禁止输出任何版本、兼容性相关信息。**
|
|
39
|
+
|
|
40
|
+
### 0a. 版本兼容性检查(纯文本判断,无需命令)
|
|
41
|
+
|
|
42
|
+
通过检查「版本信息」占位符是否被替换来判断:
|
|
43
|
+
1. IDE 名称仍含 `COMATE_IDE_NAME`(未替换)→ **旧版本**
|
|
44
|
+
2. 插件版本仍含 `COMATE_PLUGIN_VERSION`(未替换)→ **旧版本**
|
|
45
|
+
3. 版本号 < `4.3.0` → **旧版本**
|
|
46
|
+
4. 否则 → **新版本**
|
|
47
|
+
|
|
48
|
+
新版本命令加 `__silent:` 前缀,旧版本不加。**继续执行 0b。**
|
|
49
|
+
|
|
50
|
+
### 0b. 开关检查 + Python 检测 + iCode 仓库检测(三条命令并行)
|
|
51
|
+
|
|
52
|
+
**说明:命令 1 的开关检查读取用户本地配置(`enableSmartCommit`),是用户个人的开关偏好。步骤 1 中的 `result.disabled` 是服务端/空间级别的开关,两者独立,互不替代。**
|
|
53
|
+
|
|
54
|
+
#### 命令 1:开关检查(纯 shell,无外部依赖)
|
|
55
|
+
|
|
56
|
+
**macOS / Linux:**
|
|
57
|
+
```
|
|
58
|
+
[__silent: ]cat ~/.comate/settings.json 2>/dev/null || echo "{}"
|
|
59
|
+
```
|
|
60
|
+
**Windows(cmd):**
|
|
61
|
+
```
|
|
62
|
+
[__silent: ]type "%USERPROFILE%\.comate\settings.json" 2>NUL || echo {}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
解析输出 JSON,检查 `enableSmartCommit` 字段:
|
|
66
|
+
- `false` → 立即结束 skill,不再输出任何内容
|
|
67
|
+
- `true`/不存在/文件不存在(输出 `{}`) → 继续
|
|
68
|
+
|
|
69
|
+
#### 命令 2:Python 可用性检测
|
|
70
|
+
|
|
71
|
+
**macOS / Linux:**
|
|
72
|
+
```
|
|
73
|
+
[__silent: ]python3 --version 2>/dev/null || python --version 2>/dev/null
|
|
74
|
+
```
|
|
75
|
+
**Windows(cmd):**
|
|
76
|
+
```
|
|
77
|
+
[__silent: ]python --version 2>NUL || python3 --version 2>NUL || py -3 --version 2>NUL
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
- 成功 → 记住**输出中实际成功的命令名**(`python3`/`python`/`py -3`),后续所有 `python3` 替换为该命令名
|
|
81
|
+
- 全部失败 → 标记 `python_available = false`,后续步骤 1 直接进入"iCafe 获取失败降级"流程,步骤 2 中 Agent 直接执行 git 命令获取 diff
|
|
82
|
+
|
|
83
|
+
#### 命令 3:iCode 仓库检测
|
|
84
|
+
|
|
85
|
+
对第一个 workspace 执行:
|
|
86
|
+
```
|
|
87
|
+
[__silent: ]cd <第一个workspace_path> && git remote -v
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
检查输出是否包含 `icode.baidu.com`:包含 → `is_icode_repo = true`,不包含或失败 → `is_icode_repo = false`。
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 步骤 1:获取 iCafe 数据
|
|
95
|
+
|
|
96
|
+
执行:
|
|
97
|
+
```bash
|
|
98
|
+
[__silent: ]python3 <skill_directory>/scripts/match_card_cli.py --username "${COMATE_USERNAME}"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
解析 stdout 的 JSON 为 `result`。先检查 `result.disabled`,为 `True` 则立即结束。
|
|
102
|
+
|
|
103
|
+
**失败降级**:脚本报错/超时/非 JSON → 标记 `icafe_failed = true`,跳过步骤 3-6,直接进入步骤 7 生成无卡片 commit message。
|
|
104
|
+
|
|
105
|
+
**并行执行:步骤 1 和步骤 2 无依赖,必须在同一次响应中同时发出所有命令。** 例如 2 个 workspace 时 = 1(iCafe)+ 2(git diff)+ 1(git log)= 4 条并行命令。
|
|
106
|
+
|
|
107
|
+
## 步骤 2:获取 git diff(支持多 workspace)
|
|
108
|
+
|
|
109
|
+
**⚠️ 多 Workspace 必须逐一执行:** Agent 必须从环境上下文的 `Workspace Path` 中读取**所有**路径,对每一个路径分别执行下方命令。**即使只有部分 workspace 有变更,也必须对所有 workspace 都执行一次**,禁止只对第一个 workspace 执行后就跳过其余的。
|
|
110
|
+
|
|
111
|
+
对每个 workspace 执行:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
[__silent: ]python3 <skill_directory>/scripts/git_diff_cli.py --workspace <workspace_path>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
同时对第一个 workspace 并行执行获取 commit 风格:
|
|
118
|
+
```bash
|
|
119
|
+
[__silent: ]cd <第一个workspace_path> && git log --oneline -n 20
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Agent 从 git log 分析 `commit_style`(前缀格式、语言、描述风格),供步骤 3/7 生成 commit message 时保持风格一致。**不输出任何内容。**
|
|
123
|
+
|
|
124
|
+
脚本输出 JSON 格式、以及如何构建 `workspace_diffs` 和 `diff_summary`,详见 `references/data_structures.md`(包含脚本输出示例和合并规则)。
|
|
125
|
+
|
|
126
|
+
**无变更提前退出**:所有 workspace 均无变更 → 输出以下文本并结束,禁止继续执行后续步骤:
|
|
127
|
+
```
|
|
128
|
+
ℹ️ 当前工作区没有检测到代码变更,无需提交。
|
|
129
|
+
|
|
130
|
+
你可以先修改代码,之后再使用 /auto-commit 提交。
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Agent 内部基于 diff 内容生成 `defaults.title`(建卡默认标题):取前 3 个变更文件名,生成格式为 `"优化 xxx, yyy 相关功能"`,写入 `result["defaults"]["title"]`。
|
|
134
|
+
|
|
135
|
+
同时,Agent 内部分析 diff 内容推断**卡片类型**(Bug/Story/Task 等),若推断的类型存在于 `result.available_types` 中,更新 `result.defaults.type_id` 和 `result.defaults.type_name`。推断规则:
|
|
136
|
+
- Bug 修复(错误修复、异常处理、边界条件修正) → 匹配 "Bug"
|
|
137
|
+
- 新增功能(新文件、新 API、UI 变更) → 匹配 "Story" 或 "Feature"
|
|
138
|
+
- 重构/优化(格式化、性能优化、配置修改) → 匹配 "Task"
|
|
139
|
+
- 基础设施变更(依赖升级、构建脚本) → 匹配 "Tech Feature" 或 "Tech Task"
|
|
140
|
+
- 无法推断或类型不在可用列表中 → 保持脚本返回的默认值不覆盖
|
|
141
|
+
|
|
142
|
+
## 步骤 3:语义匹配(内部完成,禁止输出)
|
|
143
|
+
|
|
144
|
+
对 `result.cards` 中每张卡片按以下维度评分(0-100):
|
|
145
|
+
- **语义相关性**(主要):diff 修改的模块、函数、业务逻辑是否与卡片标题描述的任务相关
|
|
146
|
+
- **类型匹配度**(次要):diff 的变更性质(修复 bug、新增功能、重构等)是否与卡片类型吻合
|
|
147
|
+
|
|
148
|
+
按 score 降序排序,过滤 score < 30 的卡片。
|
|
149
|
+
|
|
150
|
+
确定 `viewMode`:过滤后有卡片 → `"list"`,无卡片 → `"create"`。
|
|
151
|
+
|
|
152
|
+
生成 `recommended_commit_message`:基于 diff + 匹配卡片 + `commit_style` 生成,保持与项目历史风格一致。具体规则:
|
|
153
|
+
- 历史 message 使用 Conventional Commits(如 `feat:`, `fix:`)→ 沿用
|
|
154
|
+
- 历史 message 使用中文 → 生成中文;英文 → 生成英文
|
|
155
|
+
- 历史 message 使用 `<卡片ID> <描述>` → 沿用
|
|
156
|
+
- 无法识别明确风格 → 默认 `<spacePrefix>-<sequence> <简要描述>`
|
|
157
|
+
|
|
158
|
+
## 步骤 4:展示卡片选择
|
|
159
|
+
|
|
160
|
+
**上下文快捷匹配:** 如果对话中用户已指定卡片(卡片 ID、iCafe 链接等),直接作为 `selected_card`,跳过 UI。
|
|
161
|
+
|
|
162
|
+
**否则,必须展示卡片选择 UI,禁止自行替用户选择或创建卡片。** 根据版本展示交互 UI,参考对应 reference 文件。**新版本必须使用 `__interactive:icafe-cards` 展示,禁止用文本列表替代。**
|
|
163
|
+
|
|
164
|
+
## 步骤 5:处理用户操作
|
|
165
|
+
|
|
166
|
+
根据版本处理用户选择/创建/跳过,参考对应 reference 文件。
|
|
167
|
+
|
|
168
|
+
**创建卡片命令模板:**
|
|
169
|
+
```
|
|
170
|
+
[__silent: ]cd <用户项目目录> && python3 <skill_directory>/scripts/create_card_cli.py --title "<card.title>" --space-prefix "<card.spacePrefix>" --type-name "<card.typeName>" --username "${COMATE_USERNAME}"
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## 步骤 6:存储关联的 iCafe 卡片 ID
|
|
174
|
+
|
|
175
|
+
拿到 `selected_card` 后**必须**立即执行:
|
|
176
|
+
```
|
|
177
|
+
run_command(command="__interactive:set-icafe-issue-id {\"issueId\":\"<spacePrefix>-<sequence>\"}")
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
例如 `selected_card` 为 `{"sequence": "200", "spacePrefix": "dkx", ...}` 时:
|
|
181
|
+
```
|
|
182
|
+
run_command(command='__interactive:set-icafe-issue-id {"issueId":"dkx-200"}')
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## 步骤 7:判断是否展示提交确认
|
|
186
|
+
|
|
187
|
+
Agent 内部分析以下信号判断是否展示提交确认,**不输出任何内容**:
|
|
188
|
+
|
|
189
|
+
**展示的信号(满足任意一条):**
|
|
190
|
+
- 当前对话中用户明确表示"完成了"、"可以提交"等意图
|
|
191
|
+
- git diff 的代码变更是完整的、可独立运行的
|
|
192
|
+
- 对话上下文表明任务已结束
|
|
193
|
+
|
|
194
|
+
**不展示(仅输出 message):**
|
|
195
|
+
- 用户表示还有后续修改
|
|
196
|
+
- 代码变更不完整
|
|
197
|
+
- 对话上下文表明任务仍在进行
|
|
198
|
+
|
|
199
|
+
完整则进入步骤 8 展示确认 UI,未完整则仅输出建议的 commit message。
|
|
200
|
+
|
|
201
|
+
非 iCode 仓库的 commit message 不带卡片 ID 前缀。
|
|
202
|
+
|
|
203
|
+
## 步骤 8:展示提交确认
|
|
204
|
+
|
|
205
|
+
根据版本展示确认 UI,参考对应 reference 文件。**新版本必须使用 `__interactive:git-commit` 展示,禁止用文本替代。** payload 必须严格遵循 `references/data_structures.md` 中「步骤 8 提交确认 payload」的结构定义,禁止自行发明字段或扁平化结构。
|
|
206
|
+
|
|
207
|
+
## 步骤 9:执行提交 + 输出结果
|
|
208
|
+
|
|
209
|
+
根据版本处理提交,参考对应 reference 文件。
|
|
210
|
+
|
|
211
|
+
**推送方式:** 统一使用 `git push origin HEAD:refs/for/<branch>` 推送到 Gerrit 代码评审。
|
|
212
|
+
|
|
213
|
+
### 最终输出格式
|
|
214
|
+
|
|
215
|
+
**提交成功:**
|
|
216
|
+
```
|
|
217
|
+
✅ 已完成提交
|
|
218
|
+
|
|
219
|
+
提交信息:
|
|
220
|
+
- Commit: <commit_hash>
|
|
221
|
+
- Message: <commit_message>
|
|
222
|
+
- 绑定卡片: <space_prefix>-<sequence>(仅 iCode 仓库)
|
|
223
|
+
- 分支: <branch_name>
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
**取消提交:**
|
|
227
|
+
```
|
|
228
|
+
⏸️ 提交已取消
|
|
229
|
+
|
|
230
|
+
建议 commit message 已准备好:
|
|
231
|
+
<commit_message>
|
|
232
|
+
|
|
233
|
+
绑定卡片:<space_prefix>-<sequence> (<card_title>)(仅 iCode 仓库)
|
|
234
|
+
|
|
235
|
+
你可以稍后使用 `git commit -m "<message>"` 手动提交
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**判断不展示 UI(直接输出 message):**
|
|
239
|
+
```
|
|
240
|
+
📝 Commit message 已准备好
|
|
241
|
+
|
|
242
|
+
建议 commit message:
|
|
243
|
+
<commit_message>
|
|
244
|
+
|
|
245
|
+
绑定卡片:<space_prefix>-<sequence> (<card_title>)(仅 iCode 仓库)
|
|
246
|
+
|
|
247
|
+
代码变更未完成,请确认后再提交
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
旧版本 IDE 提交成功后额外提示推送命令。
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## 配置
|
|
255
|
+
|
|
256
|
+
**认证**:token 按优先级读取 `COMATE_AUTH_TOKEN` 环境变量 → `~/.comate/login` 文件。
|
|
257
|
+
|
|
258
|
+
**跨平台**:所有 `python3` 替换为步骤 0b 检测到的命令名;Windows 上 `cd` 改为 `cd /d`,错误抑制用 `2>NUL`。
|
|
259
|
+
|
|
260
|
+
**卡片链接**:`https://console.cloud.baidu-int.com/devops/icafe/issue/{space_prefix}-{card_sequence}/show`
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# 数据结构与 Payload 构造参考
|
|
2
|
+
|
|
3
|
+
本文档包含 auto-commit skill 各步骤中涉及的数据结构定义和 payload 构造规则。Agent 在需要构建具体数据时参考此文档。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 步骤 1:match_card_cli.py 返回值(result 对象)
|
|
8
|
+
|
|
9
|
+
| 字段 | 说明 |
|
|
10
|
+
|------|------|
|
|
11
|
+
| cards | 简化卡片列表:sequence, title, type, status |
|
|
12
|
+
| space_prefix | 空间前缀(如 "dkx") |
|
|
13
|
+
| space_id | 空间数字 ID |
|
|
14
|
+
| space_name | 空间名称 |
|
|
15
|
+
| final_iql | 实际执行的完整 IQL |
|
|
16
|
+
| available_types | 可绑定卡片类型列表:[{id, name}, ...] |
|
|
17
|
+
| available_spaces | 可访问空间列表:[{id, prefix, name, types}, ...] |
|
|
18
|
+
| defaults | 默认表单值:{title, type_id, type_name, space_id} |
|
|
19
|
+
| disabled | 服务端/空间级别开关,为 True 时立即结束 skill |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 步骤 2:git_diff_cli.py 输出格式
|
|
24
|
+
|
|
25
|
+
每个 workspace 执行 `git_diff_cli.py` 后输出的 JSON:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"workspace": "/path/to/project",
|
|
30
|
+
"changed_files": [
|
|
31
|
+
{"file": "src/App.tsx", "insertions": 76, "deletions": 66}
|
|
32
|
+
],
|
|
33
|
+
"untracked_files": ["src/NewFile.tsx"],
|
|
34
|
+
"stat_summary": "2 files, +106, -66",
|
|
35
|
+
"has_changes": true,
|
|
36
|
+
"diff_content": "<tracked diff + untracked diff>",
|
|
37
|
+
"truncated": false
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Agent 构建的数据结构
|
|
42
|
+
|
|
43
|
+
#### workspace_diffs(按 workspace 独立存储)
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
workspace_diffs = {
|
|
47
|
+
"<workspace_path>": {
|
|
48
|
+
"changed_files": [...], // 脚本输出的 changed_files
|
|
49
|
+
"stat_summary": "...",
|
|
50
|
+
"has_changes": true/false
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### diff_summary(合并后用于语义匹配)
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
diff_summary = {
|
|
59
|
+
"changed_files": [...], # 所有 workspace 的文件路径(多 workspace 时加标识)
|
|
60
|
+
"stat_summary": "...", # 合并统计
|
|
61
|
+
"diff_content": "...", # 各 workspace diff_content 拼接,超 500 行截断
|
|
62
|
+
"truncated": true/false
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
合并规则:各 workspace 的 `diff_content` 按 workspace 分段拼接,总计超 500 行截断。所有 `has_changes` 为 false 时,`diff_summary` 设为 `null`。
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## 步骤 4:卡片选择 payload(新版本 UI)
|
|
71
|
+
|
|
72
|
+
通过 `__interactive:icafe-cards <payload JSON>` 展示。
|
|
73
|
+
|
|
74
|
+
### ⚠️ 字段命名强约束
|
|
75
|
+
|
|
76
|
+
payload 使用 **camelCase**,但脚本 `match_card_cli.py` 返回的是 **snake_case**。Agent 必须在构造 payload 时完成转换,禁止将脚本原始字段名直接传入:
|
|
77
|
+
|
|
78
|
+
| 脚本返回(snake_case) | payload 字段(camelCase) |
|
|
79
|
+
|------------------------|--------------------------|
|
|
80
|
+
| `space_prefix` | `spacePrefix` |
|
|
81
|
+
| `space_id` | `spaceId` |
|
|
82
|
+
| `space_name` | `spaceName` |
|
|
83
|
+
| `available_spaces` | `availableSpaces` |
|
|
84
|
+
| `defaults.type_id` | `defaults.typeId` |
|
|
85
|
+
| `defaults.type_name` | `defaults.typeName` |
|
|
86
|
+
|
|
87
|
+
**❌ 禁止直接使用脚本原始字段名:**
|
|
88
|
+
```json
|
|
89
|
+
{"cards":[],"space_prefix":"dkx","space_id":12345,"space_name":"测试空间","view_mode":"list"}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**✅ 正确结构(camelCase):**
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"cards": [],
|
|
96
|
+
"spacePrefix": "dkx",
|
|
97
|
+
"spaceId": 12345,
|
|
98
|
+
"spaceName": "测试空间",
|
|
99
|
+
"availableSpaces": [{"id": 12345, "prefix": "dkx", "name": "测试空间", "types": [{"id": "5009", "name": "Bug"}]}],
|
|
100
|
+
"viewMode": "list",
|
|
101
|
+
"defaults": {
|
|
102
|
+
"title": "推荐标题",
|
|
103
|
+
"typeId": "5009",
|
|
104
|
+
"typeName": "Bug",
|
|
105
|
+
"spaceId": 12345
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
字段直接从 `result` 对象映射:`cards` 已按匹配度排序,`viewMode` 由步骤 3 确定,`defaults` 中的 `title`/`typeName` 由 Agent 根据 diff 语义生成。
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## 步骤 8:提交确认 payload(新版本 UI)
|
|
115
|
+
|
|
116
|
+
通过 `__interactive:git-commit <payload JSON>` 展示。
|
|
117
|
+
|
|
118
|
+
Agent 仅对 `hasChanges: true` 的 workspace 执行 `git branch -vv` + `git branch -r --sort=-committerdate`(`__silent:` 前缀),无变更的 workspace 跳过分支查询。多 workspace 的分支查询命令必须并行发出。
|
|
119
|
+
|
|
120
|
+
### ⚠️ payload 顶层结构强约束
|
|
121
|
+
|
|
122
|
+
**顶层有且仅有 3 个字段,字段名使用 camelCase:**
|
|
123
|
+
|
|
124
|
+
| 顶层字段 | 类型 | 说明 |
|
|
125
|
+
|----------|------|------|
|
|
126
|
+
| `commitMessage` | string | commit message(注意:不是 `commit_message`) |
|
|
127
|
+
| `boundCard` | object \| null | 绑定的 iCafe 卡片(注意:不是 `icafe_card`) |
|
|
128
|
+
| `workspaces` | array | workspace 数组(注意:是复数 `workspaces`,不是单数 `workspace`) |
|
|
129
|
+
|
|
130
|
+
**❌ 禁止出现在顶层的字段(常见错误):**
|
|
131
|
+
- `workspace`(单数字符串)→ 应为 `workspaces`(复数数组)
|
|
132
|
+
- `commit_message`(snake_case)→ 应为 `commitMessage`(camelCase)
|
|
133
|
+
- `changed_files` → 应嵌套在 `workspaces[].diffSummary.changed_files`
|
|
134
|
+
- `icafe_card` → 应为 `boundCard`
|
|
135
|
+
- 任何其他扁平化字段
|
|
136
|
+
|
|
137
|
+
**❌ 错误示例(绝对禁止生成此结构):**
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"commit_message": "study-ai-823 fix: ...",
|
|
141
|
+
"workspace": "/path/to/repo",
|
|
142
|
+
"changed_files": [{"file": "src/service.go", "insertions": 16, "deletions": 8}],
|
|
143
|
+
"icafe_card": {"sequence": 823, "title": "...", "spacePrefix": "study-ai"}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**✅ 正确结构(即使只有 1 个 workspace 也必须用数组):**
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"commitMessage": "dkx-200 修复登录问题",
|
|
151
|
+
"boundCard": {"sequence": "200", "title": "修复登录问题", "type": "Bug", "status": "开发中", "spacePrefix": "dkx"},
|
|
152
|
+
"workspaces": [
|
|
153
|
+
{
|
|
154
|
+
"workspace": "/path/to/frontend-app",
|
|
155
|
+
"repoName": "frontend-app",
|
|
156
|
+
"currentBranch": "feature/xxx",
|
|
157
|
+
"remoteBranches": [{"name": "feature/xxx", "isCurrent": true}, {"name": "main", "isCurrent": false}],
|
|
158
|
+
"hasChanges": true,
|
|
159
|
+
"diffSummary": {
|
|
160
|
+
"changed_files": [{"file": "src/App.tsx", "insertions": 76, "deletions": 66}],
|
|
161
|
+
"stat_summary": "2 files, +100, -78"
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"workspace": "/path/to/shared-utils",
|
|
166
|
+
"repoName": "shared-utils",
|
|
167
|
+
"currentBranch": "",
|
|
168
|
+
"remoteBranches": [],
|
|
169
|
+
"hasChanges": false,
|
|
170
|
+
"diffSummary": null
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 字段构造规则
|
|
177
|
+
|
|
178
|
+
- `commitMessage`:iCode 仓库格式 `"<spacePrefix>-<sequence> <描述>"`;非 iCode 仓库不带卡片 ID
|
|
179
|
+
- `boundCard`:步骤 5 选定的卡片,非 iCode 或无卡片时为 `null`
|
|
180
|
+
- `workspaces`:必须包含所有 workspace(含无变更的)
|
|
181
|
+
- `repoName`:路径最后一段
|
|
182
|
+
- `currentBranch`:有变更时从 `git branch -vv` 解析,无变更时空字符串
|
|
183
|
+
- `remoteBranches`:有变更时从 `git branch -r` 解析,跳过含 `->` 的行(HEAD 指针),去掉 `origin/` 前缀,标记当前追踪分支为 `isCurrent: true`,最多 10 个分支(当前追踪分支必须包含)
|
|
184
|
+
- `diffSummary`:有变更时用 `workspace_diffs` 中的 `changed_files` + `stat_summary`,无变更时 `null`
|
|
185
|
+
|
|
186
|
+
### 用户操作返回
|
|
187
|
+
|
|
188
|
+
- 确认:`{"action": "submit", "repos": [{"workspace": "...", "commitMessage": "...", "branch": "..."}]}`
|
|
189
|
+
- 取消:`{"action": "cancel"}`
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# 新版本 IDE 交互指南
|
|
2
|
+
|
|
3
|
+
本文档适用于**新版本 IDE**(IDE 名称占位符已替换、插件版本 ≥ 4.1.0)的交互方式。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 全局规则
|
|
8
|
+
|
|
9
|
+
**⚠️ 全局静默要求:整个流程中 Agent 仅通过 `__interactive:` UI 组件与用户交互。除步骤 9 的最终结果文字外,Agent 禁止向用户输出任何文字内容,包括但不限于:**
|
|
10
|
+
- **过渡性话语**:如 "Now I have the data"、"Let me perform matching"、"让我分析一下"
|
|
11
|
+
- **内部分析过程**:如 "Card 26: xxx - Score: 95"、"Matching analysis:"、匹配评分细节
|
|
12
|
+
- **状态说明**:如 "has_good_match: true"、"Cards sorted by score"
|
|
13
|
+
- **JSON 数据或代码片段**
|
|
14
|
+
|
|
15
|
+
**Agent 应在内部完成所有思考后,直接调用对应的 `run_command`,不在工具调用之间输出任何文字。**
|
|
16
|
+
|
|
17
|
+
**⚠️ 重要:所有 `run_command` 调用(`__interactive:` 除外)必须加 `__silent:` 前缀。唯一例外是步骤 9 的 git commit 命令,需要展示提交结果给用户。**
|
|
18
|
+
|
|
19
|
+
**⚠️ 禁止额外命令:Agent 不得在流程步骤之外自行执行任何 shell 命令(如 `git status`、`ls` 等)。iCafe 数据由步骤 1 的 Python 脚本获取,git diff 由步骤 2 中 Agent 按规定命令获取。**
|
|
20
|
+
|
|
21
|
+
**⚠️ 工作目录规则:Skill 执行时的工作目录可能不是用户项目目录。当命令需要在用户项目目录下执行时(如 git 操作、Python 脚本),必须在命令中加 `cd <用户项目目录> &&` 切换目录。但 `__silent:` 或 `__interactive:` 前缀必须始终在命令最开头。**
|
|
22
|
+
|
|
23
|
+
**⚠️ 多 Workspace 规则:用户可能打开了多个代码库(multi-root workspace)。环境上下文中的 `Workspace Path` 会列出所有 workspace 路径。在步骤 2 和步骤 8 中,Agent 必须对每个 workspace 分别执行 git 命令,不可只处理第一个 workspace 后忽略其余的。**
|
|
24
|
+
|
|
25
|
+
正确格式:
|
|
26
|
+
```
|
|
27
|
+
__silent: cd /path/to/project && git add .
|
|
28
|
+
__interactive:icafe-cards {...}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
错误格式(禁止):
|
|
32
|
+
```
|
|
33
|
+
cd /path/to/project && __silent: git add .
|
|
34
|
+
cd /path/to/project && __interactive:icafe-cards {...}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 步骤 1:获取 iCafe 数据(新版本命令)
|
|
40
|
+
|
|
41
|
+
使用 SKILL.md 步骤 1 中定义的命令模板,**加 `__silent:` 前缀**执行。
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 步骤 2:获取 git diff(新版本命令)
|
|
46
|
+
|
|
47
|
+
使用 SKILL.md 步骤 2 中定义的命令模板,**加 `__silent:` 前缀**执行。
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 步骤 4:展示卡片选择(交互式 UI)
|
|
52
|
+
|
|
53
|
+
调用 `run_command` 展示卡片选择/新建 UI,**禁止在调用前输出任何文字**:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
run_command(command="__interactive:icafe-cards <payload JSON>")
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
payload 构造方法 — 用 `result` 中的字段和匹配结果拼接 JSON:
|
|
60
|
+
```python
|
|
61
|
+
import json
|
|
62
|
+
payload = json.dumps({
|
|
63
|
+
"cards": result["cards"], # 已按匹配度排序
|
|
64
|
+
"spacePrefix": result["space_prefix"],
|
|
65
|
+
"spaceId": result["space_id"],
|
|
66
|
+
"spaceName": result["space_name"],
|
|
67
|
+
"availableSpaces": result["available_spaces"],
|
|
68
|
+
"viewMode": viewMode, # "list" 或 "create"
|
|
69
|
+
"defaults": {
|
|
70
|
+
"title": result["defaults"]["title"],
|
|
71
|
+
"typeId": result["defaults"]["type_id"],
|
|
72
|
+
"typeName": result["defaults"]["type_name"],
|
|
73
|
+
"spaceId": result["space_id"]
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
command = f"__interactive:icafe-cards {payload}"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
完整示例 command 值:
|
|
80
|
+
```
|
|
81
|
+
__interactive:icafe-cards {"cards":[{"sequence":"200","title":"修复登录问题","type":"Bug","status":"开发中"}],"spacePrefix":"dkx","spaceId":12345,"spaceName":"测试空间","viewMode":"list","availableSpaces":[{"id":12345,"prefix":"dkx","name":"测试空间","types":[{"id":"5009","name":"Bug"},{"id":"5007","name":"Story"}]}],"defaults":{"title":"修复登录验证码刷新问题","typeId":"5009","typeName":"Bug","spaceId":12345}}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 步骤 5:处理用户操作(新版本 IDE)
|
|
87
|
+
|
|
88
|
+
UI 组件返回 JSON,可能的 action 值:
|
|
89
|
+
|
|
90
|
+
| action | 含义 | 处理方式 |
|
|
91
|
+
|--------|------|----------|
|
|
92
|
+
| `select` | 选择已有卡片 | 保存 `card` 中的卡片信息,继续步骤 7 |
|
|
93
|
+
| `recognize` | 链接或卡片 ID 识别 | 调用 `recognize_card_cli.py` 获取卡片详情,继续步骤 7 |
|
|
94
|
+
| `create` | 新建卡片 | 调用 `create_card_cli.py` 创建卡片,继续步骤 7 |
|
|
95
|
+
| `skip` | 跳过 | 输出"已跳过卡片绑定和代码提交。",**结束 skill** |
|
|
96
|
+
| `do_not_show_again` | 不再提示 | 输出"已关闭推荐卡片提示。",**结束 skill** |
|
|
97
|
+
|
|
98
|
+
**recognize 处理:**
|
|
99
|
+
```
|
|
100
|
+
__silent: cd <用户项目目录> && python3 <skill_directory>/scripts/recognize_card_cli.py --link "<用户返回的link>"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**create 处理:**
|
|
104
|
+
|
|
105
|
+
使用 SKILL.md 步骤 5 中定义的「创建卡片命令模板」,**加 `__silent:` 前缀**执行。
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 步骤 8:展示提交确认(交互式 UI)
|
|
110
|
+
|
|
111
|
+
调用 `run_command` 展示提交确认 UI:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
run_command(command="__interactive:git-commit <payload JSON>")
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Agent 仅对 **`hasChanges: true` 的 workspace** 执行 `git branch -vv` + `git branch -r --sort=-committerdate`(使用 `__silent:` 前缀)。**无变更的 workspace 跳过分支查询,`currentBranch` 和 `remoteBranches` 使用空值。** 多 workspace 时,不同 workspace 的分支查询命令必须在同一次响应中并行发出。然后构造 payload:
|
|
118
|
+
|
|
119
|
+
**⚠️ 重要:`workspaces` 数组必须包含环境上下文 `Workspace Path` 中列出的所有 workspace,不可遗漏。** 即使某个 workspace 没有变更(`hasChanges: false`),也必须包含在数组中。
|
|
120
|
+
|
|
121
|
+
**⚠️ payload 顶层结构强约束(必须严格遵守):**
|
|
122
|
+
- 顶层有且仅有 3 个字段:`commitMessage`、`boundCard`、`workspaces`
|
|
123
|
+
- **`workspaces` 是复数(数组),不是单数 `workspace`(字符串)**——即使只有 1 个 workspace 也必须用数组
|
|
124
|
+
- 使用 camelCase 命名:`commitMessage` 不是 `commit_message`,`boundCard` 不是 `icafe_card`
|
|
125
|
+
- `changed_files` 必须嵌套在 `workspaces[].diffSummary` 内,禁止放在顶层
|
|
126
|
+
|
|
127
|
+
**❌ 禁止生成的扁平化结构:**
|
|
128
|
+
```json
|
|
129
|
+
{"commit_message":"xxx","workspace":"/path","changed_files":[...],"icafe_card":{...}}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
payload 结构(多 workspace 格式):
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"commitMessage": "dkx-200 修复登录问题",
|
|
136
|
+
"boundCard": {"sequence": "200", "title": "修复登录问题", "type": "Bug", "status": "开发中", "spacePrefix": "dkx"},
|
|
137
|
+
"workspaces": [
|
|
138
|
+
{
|
|
139
|
+
"workspace": "/path/to/frontend-app",
|
|
140
|
+
"repoName": "frontend-app",
|
|
141
|
+
"currentBranch": "feature/xxx",
|
|
142
|
+
"remoteBranches": [{"name": "feature/xxx", "isCurrent": true}, {"name": "main", "isCurrent": false}],
|
|
143
|
+
"hasChanges": true,
|
|
144
|
+
"diffSummary": {
|
|
145
|
+
"changed_files": [{"file": "src/App.tsx", "insertions": 76, "deletions": 66}],
|
|
146
|
+
"stat_summary": "2 files, +100, -78"
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"workspace": "/path/to/shared-utils",
|
|
151
|
+
"repoName": "shared-utils",
|
|
152
|
+
"currentBranch": "",
|
|
153
|
+
"remoteBranches": [],
|
|
154
|
+
"hasChanges": false,
|
|
155
|
+
"diffSummary": null
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**构造规则:**
|
|
162
|
+
- `commitMessage`:基于 diff 和绑定卡片生成的 commit message。iCode 仓库格式为 `"<spacePrefix>-<sequence> <brief_description>"`;非 iCode 仓库不带卡片 ID 前缀,仅生成描述性 message
|
|
163
|
+
- `boundCard`:步骤 5 中选定的卡片信息。非 iCode 仓库或无卡片时为 `null`
|
|
164
|
+
- `workspaces`:对每个 workspace 目录,使用步骤 2 中构建的 `workspace_diffs` 数据:
|
|
165
|
+
- `workspace`:绝对路径
|
|
166
|
+
- `repoName`:路径的最后一段
|
|
167
|
+
- `currentBranch`:有变更时从 `git branch -vv` 解析当前分支名,无变更时为空字符串
|
|
168
|
+
- `remoteBranches`:有变更时从 `git branch -r` 解析远程分支列表;无变更时为空数组。解析规则:
|
|
169
|
+
1. 跳过包含 `->` 的行(如 `origin/HEAD -> origin/master`,这是 HEAD 指针,不是分支)
|
|
170
|
+
2. 对每一行 trim 后去掉 `origin/` 前缀,得到分支名
|
|
171
|
+
3. 从 `git branch -vv` 输出中解析当前分支的远程追踪分支名,将匹配的分支标记为 `isCurrent: true`,其余为 `false`
|
|
172
|
+
4. 最多取 10 个分支(当前追踪分支必须包含在内),按最近活跃排序
|
|
173
|
+
- `hasChanges`:该 workspace 是否有变更(`workspace_diffs[path].has_changes`)
|
|
174
|
+
- `diffSummary`:有变更时为 `workspace_diffs[path]` 中的 `changed_files` + `stat_summary`,无变更时为 `null`
|
|
175
|
+
|
|
176
|
+
**顶层不再有旧的 `currentBranch`/`remoteBranches`/`diffSummary` 字段。**
|
|
177
|
+
|
|
178
|
+
完整示例 command 值:
|
|
179
|
+
```
|
|
180
|
+
__interactive:git-commit {"commitMessage":"dkx-200 修复登录验证码刷新问题","boundCard":{"sequence":"200","title":"修复登录问题","type":"Bug","status":"开发中","spacePrefix":"dkx"},"workspaces":[{"workspace":"/home/user/frontend-app","repoName":"frontend-app","currentBranch":"feature/login-fix","remoteBranches":[{"name":"feature/login-fix","isCurrent":true},{"name":"main","isCurrent":false}],"hasChanges":true,"diffSummary":{"changed_files":[{"file":"src/login.ts","insertions":15,"deletions":3}],"stat_summary":"1 file, +15, -3"}}]}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
用户操作后,tool output 返回 JSON:
|
|
184
|
+
- 确认提交:`{"action": "submit", "repos": [{"workspace": "...", "commitMessage": "...", "branch": "..."}]}`
|
|
185
|
+
- 取消提交:`{"action": "cancel"}`
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## 步骤 9:执行提交(新版本 IDE)
|
|
190
|
+
|
|
191
|
+
从 tool output 解析用户操作:
|
|
192
|
+
|
|
193
|
+
**如果是 action === "submit":**
|
|
194
|
+
|
|
195
|
+
UI 返回的结果格式:
|
|
196
|
+
```json
|
|
197
|
+
{"action": "submit", "repos": [{"workspace": "/path/to/repo", "commitMessage": "dkx-200 修复...", "branch": "feature/xxx"}]}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Agent 收到后,对 `repos` 数组中的每个仓库自主决定执行方式:
|
|
201
|
+
- `cd` 到对应 workspace 目录
|
|
202
|
+
- 执行 `git add .`、`git commit -m "<commitMessage>"`(git commit 命令不使用 `__silent:`,展示提交结果给用户)
|
|
203
|
+
- 如果用户选择了特定分支且不是当前分支,先 `git checkout` 切换
|
|
204
|
+
- **推送方式根据仓库类型区分:**
|
|
205
|
+
- 统一使用 `git push origin HEAD:refs/for/<branch>` 推送到 Gerrit 代码评审
|
|
206
|
+
- 多仓库时逐个执行,每个仓库独立处理
|
|
207
|
+
|
|
208
|
+
**如果是 action === "cancel":**
|
|
209
|
+
- 输出"已取消提交"
|