ccg-workflow 1.7.79 → 1.7.81

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/README.md CHANGED
@@ -17,7 +17,7 @@ A multi-model collaboration development system where Claude Code orchestrates Co
17
17
 
18
18
  - **Zero-config model routing** — Frontend tasks automatically go to Gemini, backend tasks to Codex. No manual switching.
19
19
  - **Security by design** — External models have no write access. They return patches; Claude reviews before applying.
20
- - **26 slash commands** — From planning to execution, git workflow to code review, all accessible via `/ccg:*`.
20
+ - **27 slash commands** — From planning to execution, git workflow to code review, all accessible via `/ccg:*`.
21
21
  - **Spec-driven development** — Integrates [OPSX](https://github.com/fission-ai/opsx) to turn vague requirements into verifiable constraints, eliminating AI improvisation.
22
22
 
23
23
  ## Architecture
@@ -141,6 +141,7 @@ Supports: npm, homebrew, curl, powershell, cmd.
141
141
  | Command | Description |
142
142
  |---------|-------------|
143
143
  | `/ccg:init` | Initialize project CLAUDE.md |
144
+ | `/ccg:context` | Project context management (.context/ init, log, compress, history) |
144
145
 
145
146
  ## Workflow Guides
146
147
 
@@ -352,4 +353,4 @@ MIT
352
353
 
353
354
  ---
354
355
 
355
- v1.7.79 | [Issues](https://github.com/fengshao1227/ccg-workflow/issues) | [Contributing](./CONTRIBUTING.md)
356
+ v1.7.81 | [Issues](https://github.com/fengshao1227/ccg-workflow/issues) | [Contributing](./CONTRIBUTING.md)
package/README.zh-CN.md CHANGED
@@ -17,7 +17,7 @@ Claude Code 编排 Codex + Gemini 的多模型协作开发系统。前端任务
17
17
 
18
18
  - **零配置模型路由** — 前端任务自动走 Gemini,后端任务自动走 Codex,无需手动切换。
19
19
  - **安全设计** — 外部模型无写入权限,仅返回 Patch,由 Claude 审核后应用。
20
- - **26 个斜杠命令** — 从规划到执行、Git 工作流到代码审查,通过 `/ccg:*` 一站式访问。
20
+ - **27 个斜杠命令** — 从规划到执行、Git 工作流到代码审查,通过 `/ccg:*` 一站式访问。
21
21
  - **规范驱动开发** — 集成 [OPSX](https://github.com/fission-ai/opsx),将模糊需求变成可验证约束,让 AI 没法自由发挥。
22
22
 
23
23
  ## 架构
@@ -141,6 +141,7 @@ npx ccg-workflow menu # 选择「安装 Claude Code」
141
141
  | 命令 | 说明 |
142
142
  |------|------|
143
143
  | `/ccg:init` | 初始化项目 CLAUDE.md |
144
+ | `/ccg:context` | 项目上下文管理(.context 初始化/日志/压缩/历史) |
144
145
 
145
146
  ## 工作流指南
146
147
 
@@ -196,7 +197,7 @@ npx ccg-workflow menu # 选择「安装 Claude Code」
196
197
 
197
198
  ```
198
199
  ~/.claude/
199
- ├── commands/ccg/ # 26 个斜杠命令
200
+ ├── commands/ccg/ # 27 个斜杠命令
200
201
  ├── agents/ccg/ # 子智能体
201
202
  ├── skills/ccg/ # 质量关卡 + 多 Agent 协同
202
203
  ├── bin/codeagent-wrapper
@@ -352,4 +353,4 @@ MIT
352
353
 
353
354
  ---
354
355
 
355
- v1.7.79 | [Issues](https://github.com/fengshao1227/ccg-workflow/issues) | [参与贡献](./CONTRIBUTING.md)
356
+ v1.7.81 | [Issues](https://github.com/fengshao1227/ccg-workflow/issues) | [参与贡献](./CONTRIBUTING.md)
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import cac from 'cac';
3
3
  import ansis from 'ansis';
4
- import { z as diagnoseMcpConfig, A as isWindows, B as readClaudeCodeConfig, C as fixWindowsMcpConfig, D as writeClaudeCodeConfig, r as readCcgConfig, b as initI18n, a as i18n, s as showMainMenu, i as init, E as configMcp, F as version } from './shared/ccg-workflow.O8zwMZ2s.mjs';
4
+ import { z as diagnoseMcpConfig, A as isWindows, B as readClaudeCodeConfig, C as fixWindowsMcpConfig, D as writeClaudeCodeConfig, r as readCcgConfig, b as initI18n, a as i18n, s as showMainMenu, i as init, E as configMcp, F as version } from './shared/ccg-workflow.DLkUGirT.mjs';
5
5
  import 'inquirer';
6
6
  import 'node:child_process';
7
7
  import 'node:util';
package/dist/index.d.mts CHANGED
@@ -83,6 +83,7 @@ interface InstallResult {
83
83
  installedCommands: string[];
84
84
  installedPrompts: string[];
85
85
  installedSkills?: number;
86
+ installedRules?: boolean;
86
87
  errors: string[];
87
88
  configPath: string;
88
89
  binPath?: string;
@@ -149,6 +150,7 @@ interface UninstallResult {
149
150
  removedPrompts: string[];
150
151
  removedAgents: string[];
151
152
  removedSkills: string[];
153
+ removedRules: boolean;
152
154
  removedBin: boolean;
153
155
  errors: string[];
154
156
  }
package/dist/index.d.ts CHANGED
@@ -83,6 +83,7 @@ interface InstallResult {
83
83
  installedCommands: string[];
84
84
  installedPrompts: string[];
85
85
  installedSkills?: number;
86
+ installedRules?: boolean;
86
87
  errors: string[];
87
88
  configPath: string;
88
89
  binPath?: string;
@@ -149,6 +150,7 @@ interface UninstallResult {
149
150
  removedPrompts: string[];
150
151
  removedAgents: string[];
151
152
  removedSkills: string[];
153
+ removedRules: boolean;
152
154
  removedBin: boolean;
153
155
  errors: string[];
154
156
  }
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { c as changeLanguage, x as checkForUpdates, y as compareVersions, d as createDefaultConfig, e as createDefaultRouting, g as getCcgDir, f as getConfigPath, t as getCurrentVersion, v as getLatestVersion, j as getWorkflowById, h as getWorkflowConfigs, a as i18n, i as init, b as initI18n, l as installAceTool, m as installAceToolRs, k as installWorkflows, p as migrateToV1_4_0, q as needsMigration, r as readCcgConfig, s as showMainMenu, o as uninstallAceTool, n as uninstallWorkflows, u as update, w as writeCcgConfig } from './shared/ccg-workflow.O8zwMZ2s.mjs';
1
+ export { c as changeLanguage, x as checkForUpdates, y as compareVersions, d as createDefaultConfig, e as createDefaultRouting, g as getCcgDir, f as getConfigPath, t as getCurrentVersion, v as getLatestVersion, j as getWorkflowById, h as getWorkflowConfigs, a as i18n, i as init, b as initI18n, l as installAceTool, m as installAceToolRs, k as installWorkflows, p as migrateToV1_4_0, q as needsMigration, r as readCcgConfig, s as showMainMenu, o as uninstallAceTool, n as uninstallWorkflows, u as update, w as writeCcgConfig } from './shared/ccg-workflow.DLkUGirT.mjs';
2
2
  import 'ansis';
3
3
  import 'inquirer';
4
4
  import 'node:child_process';
@@ -10,7 +10,7 @@ import { parse, stringify } from 'smol-toml';
10
10
  import i18next from 'i18next';
11
11
  import ora from 'ora';
12
12
 
13
- const version = "1.7.79";
13
+ const version = "1.7.81";
14
14
 
15
15
  function isWindows() {
16
16
  return process.platform === "win32";
@@ -503,6 +503,17 @@ const WORKFLOW_CONFIGS = [
503
503
  order: 3,
504
504
  description: "\u8BFB\u53D6 /ccg:plan \u8BA1\u5212\u6587\u4EF6\uFF0CCodex \u5168\u6743\u6267\u884C + \u591A\u6A21\u578B\u5BA1\u6838",
505
505
  descriptionEn: "Read plan file from /ccg:plan, Codex executes + multi-model review"
506
+ },
507
+ {
508
+ id: "context",
509
+ name: "\u9879\u76EE\u4E0A\u4E0B\u6587\u7BA1\u7406",
510
+ nameEn: "Project Context Manager",
511
+ category: "development",
512
+ commands: ["context"],
513
+ defaultSelected: true,
514
+ order: 4,
515
+ description: "\u521D\u59CB\u5316 .context \u76EE\u5F55\u3001\u8BB0\u5F55\u51B3\u7B56\u65E5\u5FD7\u3001\u538B\u7F29\u5F52\u6863\u3001\u67E5\u770B\u5386\u53F2",
516
+ descriptionEn: "Init .context dir, log decisions, compress, view history"
506
517
  }
507
518
  ];
508
519
  function getWorkflowConfigs() {
@@ -748,6 +759,28 @@ ${workflow.description}
748
759
  result.success = false;
749
760
  }
750
761
  }
762
+ const rulesTemplateDir = join(templateDir, "rules");
763
+ const rulesDestDir = join(installDir, "rules");
764
+ if (await fs.pathExists(rulesTemplateDir)) {
765
+ try {
766
+ await fs.ensureDir(rulesDestDir);
767
+ const rulesFiles = await fs.readdir(rulesTemplateDir);
768
+ for (const file of rulesFiles) {
769
+ if (file.endsWith(".md")) {
770
+ const srcFile = join(rulesTemplateDir, file);
771
+ const destFile = join(rulesDestDir, file);
772
+ if (force || !await fs.pathExists(destFile)) {
773
+ const templateContent = await fs.readFile(srcFile, "utf-8");
774
+ const processedContent = replaceHomePathsInTemplate(templateContent, installDir);
775
+ await fs.writeFile(destFile, processedContent, "utf-8");
776
+ }
777
+ }
778
+ }
779
+ result.installedRules = true;
780
+ } catch (error) {
781
+ result.errors.push(`Failed to install rules: ${error}`);
782
+ }
783
+ }
751
784
  try {
752
785
  const binDir = join(installDir, "bin");
753
786
  await fs.ensureDir(binDir);
@@ -793,6 +826,7 @@ async function uninstallWorkflows(installDir) {
793
826
  removedPrompts: [],
794
827
  removedAgents: [],
795
828
  removedSkills: [],
829
+ removedRules: false,
796
830
  removedBin: false,
797
831
  errors: []
798
832
  };
@@ -800,6 +834,7 @@ async function uninstallWorkflows(installDir) {
800
834
  join(installDir, ".ccg", "prompts");
801
835
  const agentsDir = join(installDir, "agents", "ccg");
802
836
  const skillsDir = join(installDir, "skills", "ccg");
837
+ const rulesDir = join(installDir, "rules");
803
838
  const binDir = join(installDir, "bin");
804
839
  const ccgConfigDir = join(installDir, ".ccg");
805
840
  if (await fs.pathExists(commandsDir)) {
@@ -850,6 +885,20 @@ async function uninstallWorkflows(installDir) {
850
885
  result.success = false;
851
886
  }
852
887
  }
888
+ if (await fs.pathExists(rulesDir)) {
889
+ try {
890
+ const ccgRuleFiles = ["ccg-skills.md", "ccg-grok-search.md"];
891
+ for (const ruleFile of ccgRuleFiles) {
892
+ const rulePath = join(rulesDir, ruleFile);
893
+ if (await fs.pathExists(rulePath)) {
894
+ await fs.remove(rulePath);
895
+ result.removedRules = true;
896
+ }
897
+ }
898
+ } catch (error) {
899
+ result.errors.push(`Failed to remove rules: ${error}`);
900
+ }
901
+ }
853
902
  if (await fs.pathExists(binDir)) {
854
903
  try {
855
904
  const wrapperName = process.platform === "win32" ? "codeagent-wrapper.exe" : "codeagent-wrapper";
@@ -3121,6 +3170,12 @@ async function init(options = {}) {
3121
3170
  console.log(` ${ansis.green("\u2713")} ${result.installedSkills} skills installed (quality gates + multi-agent)`);
3122
3171
  console.log(ansis.gray(" \u2192 ~/.claude/skills/"));
3123
3172
  }
3173
+ if (result.installedRules) {
3174
+ console.log();
3175
+ console.log(ansis.cyan(" Rules:"));
3176
+ console.log(` ${ansis.green("\u2713")} quality gate auto-trigger rules`);
3177
+ console.log(ansis.gray(" \u2192 ~/.claude/rules/ccg-skills.md"));
3178
+ }
3124
3179
  if (result.errors.length > 0) {
3125
3180
  console.log();
3126
3181
  console.log(ansis.red(` \u26A0 ${i18n.t("init:installationErrors")}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccg-workflow",
3
- "version": "1.7.79",
3
+ "version": "1.7.81",
4
4
  "description": "Claude + Codex + Gemini multi-model collaboration system - smart routing development workflow",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@10.17.1",
@@ -54,6 +54,7 @@
54
54
  "templates/commands/team-exec.md",
55
55
  "templates/commands/team-review.md",
56
56
  "templates/commands/codex-exec.md",
57
+ "templates/commands/context.md",
57
58
  "templates/commands/agents/",
58
59
  "templates/prompts/codex/",
59
60
  "templates/prompts/gemini/analyzer.md",
@@ -65,7 +66,8 @@
65
66
  "templates/prompts/gemini/tester.md",
66
67
  "templates/prompts/claude/",
67
68
  "templates/output-styles/",
68
- "templates/skills/"
69
+ "templates/skills/",
70
+ "templates/rules/"
69
71
  ],
70
72
  "scripts": {
71
73
  "dev": "tsx src/cli.ts",
@@ -68,7 +68,36 @@ description: '智能 Git 提交:分析改动生成 Conventional Commit 信息
68
68
 
69
69
  **语言**:根据最近 50 次提交判断中文/英文
70
70
 
71
- ### 阶段 5:执行提交
71
+ ### 📦 阶段 5:Context 自动归档(若 .context/ 存在)
72
+
73
+ `[模式:上下文归档]`
74
+
75
+ **前置判断**:
76
+ - 若 `.context/` 目录不存在 → 在提交成功后输出提示:`💡 建议执行 /ccg:context init 启用决策追踪`,不阻断
77
+ - 若 `.context/` 存在 → 执行以下步骤
78
+
79
+ **从 git diff 自动生成 ContextEntry**:
80
+
81
+ 1. 获取当前分支名:`git branch --show-current`
82
+ 2. 获取暂存区变更:`git diff --cached --stat` + `git diff --cached`(完整 diff)
83
+ 3. **分析 diff 生成 ContextEntry**:
84
+ - `summary`:从阶段 4 生成的 commit message 中取首行
85
+ - `decisions`:分析 diff 中的关键变更(新增依赖、架构调整、接口变更、配置修改),推断决策理由
86
+ - `bugs`:若 commit type 为 `fix`,从 diff 中提取 bug 症状、根因、修复方式
87
+ - `changes.files`:从 `git diff --cached --name-only` 提取
88
+ - `tests`:若变更包含测试文件,记录测试相关信息
89
+ 4. **合并 session.log**(可选):若 `.context/current/branches/<branch>/session.log` 存在且非空,将其中的手动记录合并到 decisions/bugs 中,然后清空 session.log
90
+ 5. **脱敏**:扫描 token/key/password/secret 模式 → 替换为 `[REDACTED]`
91
+ 6. **追加**:将 ContextEntry 作为一行追加到 `.context/history/commits.jsonl`
92
+ 7. **重生成**:更新 `.context/history/commits.md` 人类视图
93
+ 8. **暂存**:`git add .context/history/`
94
+ 9. **Trailer**:在 commit message 中添加 `Context-Id: <uuid>` trailer
95
+
96
+ **ContextEntry 格式**参见 `/ccg:context` 命令中的 Schema 定义。
97
+
98
+ **失败降级**:若归档过程出错,不阻断提交。写入 minimal ContextEntry(仅 summary + files),继续正常提交。
99
+
100
+ ### ✅ 阶段 6:执行提交
72
101
 
73
102
  `[模式:执行]`
74
103
 
@@ -0,0 +1,332 @@
1
+ ---
2
+ description: '项目上下文管理:初始化 .context 目录、记录决策日志、压缩归档、查看历史'
3
+ ---
4
+
5
+ # Context - 项目上下文管理
6
+
7
+ 管理 `.context/` 目录结构,为 LLM 工具提供决策审计链。
8
+
9
+ ## 使用方法
10
+
11
+ ```bash
12
+ /context <subcommand> [options]
13
+ ```
14
+
15
+ ## 子命令
16
+
17
+ | 子命令 | 说明 |
18
+ |--------|------|
19
+ | `init` | 初始化 `.context/` 目录结构 |
20
+ | `log <message>` | (可选)手动追加备注到 session.log,commit 时会合并 |
21
+ | `show` | 查看当前分支的 session.log |
22
+ | `compress` | 压缩 session.log → uncommit.md(手动预览用) |
23
+ | `history` | 查看 history/commits.md |
24
+ | `squash <ids...>` | 合并多条 history 记录(配合 git squash) |
25
+
26
+ > **核心用法**:`init` 一次,之后只管开发。`/ccg:commit` 提交时自动从 git diff 分析决策并归档到 history/。`log` 仅在你想手动补充备注时使用。
27
+
28
+ ---
29
+
30
+ ## 执行工作流
31
+
32
+ ### 子命令:init
33
+
34
+ `[模式:初始化]`
35
+
36
+ 在当前项目根目录创建 `.context/` 结构:
37
+
38
+ 1. 检测项目根目录(查找 `.git/`)
39
+ 2. 若 `.context/` 已存在,跳过已有文件,仅补全缺失
40
+ 3. 创建以下结构:
41
+
42
+ ```
43
+ .context/
44
+ ├── .gitignore
45
+ ├── .gitattributes
46
+ ├── prefs/
47
+ │ ├── coding-style.md
48
+ │ └── workflow.md
49
+ ├── current/
50
+ │ └── branches/
51
+ │ └── .gitkeep
52
+ └── history/
53
+ ├── commits.jsonl
54
+ ├── commits.md
55
+ └── archives/
56
+ └── .gitkeep
57
+ ```
58
+
59
+ 4. **创建 `.context/.gitignore`**:
60
+
61
+ ```gitignore
62
+ # Ephemeral workspace — never commit
63
+ current/
64
+
65
+ # Raw interaction logs — always local only
66
+ **/session.log
67
+ **/session.raw.log
68
+ **/*.session.log
69
+ **/*.raw.log
70
+
71
+ # Editor / temp
72
+ **/*.tmp
73
+ **/*.bak
74
+ **/*.swp
75
+ ```
76
+
77
+ 5. **创建 `.context/.gitattributes`**:
78
+
79
+ ```
80
+ # JSONL append-only: 'union' merge reduces conflicts
81
+ history/commits.jsonl merge=union
82
+ history/archives/*.jsonl merge=union
83
+ ```
84
+
85
+ 6. **创建 `.context/prefs/coding-style.md`**(团队编码规范模板):
86
+
87
+ ```markdown
88
+ # Coding Style Guide
89
+
90
+ > 此文件定义团队编码规范,所有 LLM 工具在修改代码时必须遵守。
91
+ > 提交到 Git,团队共享。
92
+
93
+ ## General
94
+ - Prefer small, reviewable changes; avoid unrelated refactors.
95
+ - Keep functions short (<50 lines); avoid deep nesting (≤3 levels).
96
+ - Name things explicitly; no single-letter variables except loop counters.
97
+ - Handle errors explicitly; never swallow errors silently.
98
+
99
+ ## Language-Specific
100
+ <!-- 根据项目语言补充,例如:-->
101
+ <!-- ### TypeScript -->
102
+ <!-- - Use strict mode; prefer `interface` over `type` for object shapes. -->
103
+
104
+ ## Git Commits
105
+ - Conventional Commits, imperative mood.
106
+ - Atomic commits: one logical change per commit.
107
+
108
+ ## Testing
109
+ - Every feat/fix MUST include corresponding tests.
110
+ - Coverage must not decrease.
111
+ - Fix flow: write failing test FIRST, then fix code.
112
+
113
+ ## Security
114
+ - Never log secrets (tokens/keys/cookies/JWT).
115
+ - Validate inputs at trust boundaries.
116
+ ```
117
+
118
+ 7. **创建 `.context/prefs/workflow.md`**(LLM 工作流规则):
119
+
120
+ ```markdown
121
+ # Development Workflow Rules
122
+
123
+ > 此文件定义 LLM 开发工作流的强制规则。
124
+ > 所有 LLM 工具在执行任务时必须遵守,不可跳过任何步骤。
125
+
126
+ ## Full Flow (MUST follow, no exceptions)
127
+
128
+ ### feat (新功能)
129
+ 1. 理解需求,分析影响范围
130
+ 2. 读取现有代码,理解模式
131
+ 3. 编写实现代码
132
+ 4. 编写对应测试
133
+ 5. 运行测试,修复失败
134
+ 6. 更新文档(若 API 变更)
135
+ 7. 自查 lint / type-check
136
+
137
+ ### fix (缺陷修复)
138
+ 1. 复现问题,确认症状
139
+ 2. 定位根因
140
+ 3. 编写失败测试(先有红灯)
141
+ 4. 修复代码
142
+ 5. 验证测试通过(变绿灯)
143
+ 6. 回归测试
144
+
145
+ ### refactor (重构)
146
+ 1. 确保现有测试通过
147
+ 2. 小步重构,每步可验证
148
+ 3. 重构后测试必须全部通过
149
+ 4. 不改变外部行为
150
+
151
+ ## Context Logging (决策记录)
152
+
153
+ 当你做出以下决策时,MUST 追加到 `.context/current/branches/<当前分支>/session.log`:
154
+
155
+ 1. **方案选择**:选 A 不选 B 时,记录原因
156
+ 2. **Bug 发现与修复**:根因 + 修复方法 + 教训
157
+ 3. **API/架构决策**:接口设计选择
158
+ 4. **放弃的方案**:为什么放弃
159
+
160
+ 追加格式:
161
+
162
+ ## <ISO-8601 时间>
163
+ **Decision**: <你选择了什么>
164
+ **Alternatives**: <被排除的方案>
165
+ **Reason**: <为什么>
166
+ **Risk**: <潜在风险>
167
+ ```
168
+
169
+ 8. **创建 `.context/history/commits.jsonl`**(空文件)
170
+
171
+ 9. **创建 `.context/history/commits.md`**(人类视图模板):
172
+
173
+ ```markdown
174
+ # Commit Decision History
175
+
176
+ > 此文件是 `commits.jsonl` 的人类可读视图,可由工具重生成。
177
+ > Canonical store: `commits.jsonl` (JSONL, append-only)
178
+
179
+ | Date | Context-Id | Commit | Summary | Decisions | Bugs | Risk |
180
+ |------|-----------|--------|---------|-----------|------|------|
181
+ ```
182
+
183
+ 10. **注入 CLAUDE.md 引用**(若项目存在 CLAUDE.md):
184
+
185
+ 检测项目根目录是否有 `CLAUDE.md`,若有则在末尾追加:
186
+
187
+ ```markdown
188
+
189
+ ## .context 项目上下文
190
+
191
+ > 项目使用 `.context/` 管理开发决策上下文。
192
+
193
+ - 编码规范:`.context/prefs/coding-style.md`
194
+ - 工作流规则:`.context/prefs/workflow.md`
195
+ - 决策历史:`.context/history/commits.md`
196
+
197
+ **规则**:修改代码前必读 prefs/,做决策时按 workflow.md 规则记录日志。
198
+ ```
199
+
200
+ 11. 输出初始化结果摘要
201
+
202
+ ---
203
+
204
+ ### 子命令:log
205
+
206
+ `[模式:记录]`
207
+
208
+ 1. 获取当前 Git 分支名:`git branch --show-current`
209
+ 2. 确保 `.context/current/branches/<branch>/` 目录存在
210
+ 3. 将 `<message>` 以结构化格式追加到 `session.log`:
211
+
212
+ ```markdown
213
+ ## <ISO-8601 当前时间>
214
+ <message>
215
+ ```
216
+
217
+ ---
218
+
219
+ ### 子命令:show
220
+
221
+ `[模式:查看]`
222
+
223
+ 1. 获取当前分支名
224
+ 2. 读取 `.context/current/branches/<branch>/session.log`
225
+ 3. 若不存在,提示 "当前分支暂无决策日志"
226
+ 4. 输出内容
227
+
228
+ ---
229
+
230
+ ### 子命令:compress
231
+
232
+ `[模式:压缩]`
233
+
234
+ 将 `session.log` 压缩为结构化 `uncommit.md`,供提交前审查。
235
+
236
+ 1. 读取 `.context/current/branches/<branch>/session.log`
237
+ 2. 若为空,提示无内容可压缩
238
+ 3. **脱敏**:扫描并替换潜在敏感信息(token/key/password → `[REDACTED]`)
239
+ 4. **结构化提取**:从日志中提取 decisions / bugs / alternatives
240
+ 5. **生成 uncommit.md**:
241
+
242
+ ```markdown
243
+ # Pre-commit Summary: <branch-name>
244
+
245
+ | Time | Summary | Decision | Method | Result & Bug |
246
+ |------|---------|----------|--------|--------------|
247
+ | ... | ... | ... | ... | ... |
248
+ ```
249
+
250
+ 6. 输出压缩结果供用户审查
251
+ 7. 提示用户:确认后可执行 `/ccg:commit` 提交
252
+
253
+ ---
254
+
255
+ ### 子命令:history
256
+
257
+ `[模式:查看]`
258
+
259
+ 1. 读取 `.context/history/commits.md`
260
+ 2. 若不存在,提示 "暂无历史记录,请先使用 /ccg:context init"
261
+ 3. 输出内容
262
+ 4. 若用户指定文件路径,从 `commits.jsonl` 检索 `changes.files` 包含该路径的条目
263
+
264
+ ---
265
+
266
+ ### 子命令:squash
267
+
268
+ `[模式:合并]`
269
+
270
+ 配合 `git squash` 使用,合并多条 ContextEntry。
271
+
272
+ 1. 接收 Context-Id 列表
273
+ 2. 从 `commits.jsonl` 读取对应条目
274
+ 3. 生成新的聚合 ContextEntry:
275
+ - 新 `context_id`(UUIDv7)
276
+ - `Context-Refs` = 所有被 squash 的 ids
277
+ - 合并 decisions / bugs / changes
278
+ 4. 追加到 `commits.jsonl`
279
+ 5. 重生成 `commits.md`
280
+
281
+ ---
282
+
283
+ ## ContextEntry Schema (v1.0.0)
284
+
285
+ 每条 JSONL 记录格式:
286
+
287
+ ```json
288
+ {
289
+ "schema_version": "1.0.0",
290
+ "context_id": "<UUIDv7>",
291
+ "created_at": "<ISO-8601>",
292
+ "producer": {
293
+ "tool": "<tool-name>",
294
+ "llm": { "provider": "<provider>", "model": "<model>" }
295
+ },
296
+ "git": {
297
+ "branch": "<branch>",
298
+ "commit_sha": "<short-sha>",
299
+ "trailers": { "Context-Id": "<uuid>" }
300
+ },
301
+ "summary": "<one-line summary>",
302
+ "decisions": [{
303
+ "title": "<decision title>",
304
+ "rationale": "<why>",
305
+ "tradeoffs": ["<tradeoff>"],
306
+ "assumptions": ["<assumption>"],
307
+ "rejected_alternatives": [{ "option": "<alt>", "reason": "<why rejected>" }],
308
+ "side_effects": ["<side effect>"]
309
+ }],
310
+ "bugs": [{
311
+ "symptom": "<what happened>",
312
+ "root_cause": "<why>",
313
+ "fix": "<how fixed>",
314
+ "lesson": "<takeaway>"
315
+ }],
316
+ "changes": { "files": ["<path>"] },
317
+ "tests": [{ "command": "<cmd>", "result": "<pass/fail>", "coverage": "<pct>" }],
318
+ "privacy": { "classification": "internal", "redactions_applied": true }
319
+ }
320
+ ```
321
+
322
+ ---
323
+
324
+ ## 关键规则
325
+
326
+ 1. **prefs/ 提交到 Git** — 团队共享编码规范
327
+ 2. **current/ 永不提交** — 原始日志仅本地
328
+ 3. **history/ 提交到 Git** — 永久决策归档
329
+ 4. **commits.jsonl 是 canonical** — commits.md 可重生成
330
+ 5. **UUIDv7 为主键** — 不依赖 commit SHA(rebase-safe)
331
+ 6. **merge=union** — JSONL append 冲突自动合并
332
+ 7. **脱敏先于一切** — 任何写入 history 前必须脱敏
@@ -48,3 +48,11 @@ You are a senior technical analyst specializing in architecture evaluation, solu
48
48
  3. **Options** - Alternative approaches with pros/cons
49
49
  4. **Recommendation** - Preferred approach with rationale
50
50
  5. **Action Items** - Concrete next steps
51
+
52
+ ## .context Awareness
53
+
54
+ If the project has a `.context/` directory:
55
+ 1. Read `.context/prefs/coding-style.md` and `.context/prefs/workflow.md` before analysis
56
+ 2. Use rules from prefs/ as evaluation criteria
57
+ 3. When analyzing, check `.context/history/commits.jsonl` for related past decisions
58
+ 4. Document your key decisions and trade-offs clearly in your output (they will be captured for future context)
@@ -44,3 +44,11 @@ You are a senior backend architect specializing in scalable API design, database
44
44
  2. **Architecture Decision** - Key design choices with rationale
45
45
  3. **Implementation** - Unified Diff Patch
46
46
  4. **Considerations** - Performance, security, scaling notes
47
+
48
+ ## .context Awareness
49
+
50
+ If the project has a `.context/` directory:
51
+ 1. Read `.context/prefs/coding-style.md` and `.context/prefs/workflow.md` before designing
52
+ 2. Follow all coding conventions defined in prefs/
53
+ 3. Check `.context/history/commits.jsonl` for past architectural decisions on related modules
54
+ 4. In your Architecture Decision section, clearly state: rationale, rejected alternatives, assumptions, and potential side effects (these will be captured as ContextEntry for future reference)
@@ -64,3 +64,11 @@ You are a senior debugging specialist focusing on backend systems, API issues, d
64
64
  ### Probable Root Cause
65
65
  [Conclusion with reasoning]
66
66
  ```
67
+
68
+ ## .context Awareness
69
+
70
+ If the project has a `.context/` directory:
71
+ 1. Read `.context/prefs/workflow.md` for project-specific debugging rules
72
+ 2. Check `.context/history/commits.jsonl` for past bugs on related files — search `bugs[]` and `changes.files` fields
73
+ 3. Past decision context (assumptions, rejected alternatives) may reveal why code was written a certain way
74
+ 4. Document your diagnosis clearly: symptom, root cause, fix, and lesson learned (will be captured for future context)
@@ -72,3 +72,10 @@ You are a senior performance engineer specializing in backend optimization, data
72
72
  - Expected After: [metrics]
73
73
  - How to measure: [commands/tools]
74
74
  ```
75
+
76
+ ## .context Awareness
77
+
78
+ If the project has a `.context/` directory:
79
+ 1. Read `.context/prefs/coding-style.md` for project performance conventions
80
+ 2. Check `.context/history/commits.jsonl` for past optimization decisions — avoid re-doing work or reverting previous optimizations without reason
81
+ 3. Document optimization trade-offs clearly in your output (will be captured for future context)
@@ -64,3 +64,10 @@ RECOMMENDATION: [PASS/NEEDS_IMPROVEMENT]
64
64
  2. **Critical Issues** - Must fix before merge
65
65
  3. **Suggestions** - Nice to have improvements
66
66
  4. **Positive Notes** - What's done well
67
+
68
+ ## .context Awareness
69
+
70
+ If the project has a `.context/` directory:
71
+ 1. Read `.context/prefs/coding-style.md` as the primary review standard
72
+ 2. Read `.context/prefs/workflow.md` to verify the full development flow was followed (tests written, docs updated, etc.)
73
+ 3. Check `.context/history/commits.jsonl` for past decisions on the same files — flag if current changes contradict previous architectural decisions without justification
@@ -53,3 +53,10 @@ You are a senior test engineer specializing in backend testing, API testing, and
53
53
  2. **Test Cases** - List of scenarios to cover
54
54
  3. **Implementation** - Unified Diff Patch for test files
55
55
  4. **Coverage Notes** - What's covered and what's not
56
+
57
+ ## .context Awareness
58
+
59
+ If the project has a `.context/` directory:
60
+ 1. Read `.context/prefs/coding-style.md` for testing conventions (naming, patterns, coverage requirements)
61
+ 2. Read `.context/prefs/workflow.md` to understand required test flow (e.g., failing test first for bug fixes)
62
+ 3. Check `.context/history/commits.jsonl` for past bugs on related files — ensure regression tests cover previously fixed issues
@@ -51,3 +51,11 @@ You are a senior UI/UX analyst specializing in design systems, user experience e
51
51
  3. **Technical Considerations** - Frontend architecture impact
52
52
  4. **Options** - Alternative approaches with trade-offs
53
53
  5. **Recommendation** - Preferred approach with rationale
54
+
55
+ ## .context Awareness
56
+
57
+ If the project has a `.context/` directory:
58
+ 1. Read `.context/prefs/coding-style.md` and `.context/prefs/workflow.md` before analysis
59
+ 2. Use rules from prefs/ as evaluation criteria
60
+ 3. When analyzing, check `.context/history/commits.jsonl` for related past decisions
61
+ 4. Document your key decisions and trade-offs clearly in your output (they will be captured for future context)
@@ -45,3 +45,11 @@ You are a senior frontend architect specializing in UI/UX design systems, compon
45
45
  2. **Architecture Decision** - Key design choices with rationale
46
46
  3. **Implementation Plan** - Step-by-step with pseudo-code
47
47
  4. **Considerations** - Performance, accessibility, maintainability notes
48
+
49
+ ## .context Awareness
50
+
51
+ If the project has a `.context/` directory:
52
+ 1. Read `.context/prefs/coding-style.md` and `.context/prefs/workflow.md` before designing
53
+ 2. Follow all coding conventions defined in prefs/
54
+ 3. Check `.context/history/commits.jsonl` for past architectural decisions on related components
55
+ 4. In your Architecture Decision section, clearly state: rationale, rejected alternatives, assumptions, and potential side effects (these will be captured as ContextEntry for future reference)
@@ -68,3 +68,11 @@ You are a senior frontend debugging specialist focusing on UI issues, component
68
68
  ### Probable Root Cause
69
69
  [Conclusion with reasoning]
70
70
  ```
71
+
72
+ ## .context Awareness
73
+
74
+ If the project has a `.context/` directory:
75
+ 1. Read `.context/prefs/workflow.md` for project-specific debugging rules
76
+ 2. Check `.context/history/commits.jsonl` for past bugs on related components — search `bugs[]` and `changes.files` fields
77
+ 3. Past decision context (assumptions, rejected alternatives) may reveal why UI was built a certain way
78
+ 4. Document your diagnosis clearly: symptom, root cause, fix, and lesson learned (will be captured for future context)
@@ -54,3 +54,11 @@ You are a senior frontend developer specializing in React applications, responsi
54
54
  2. **Design Decisions** - UI/UX choices with rationale
55
55
  3. **Implementation** - Unified Diff Patch
56
56
  4. **Usage Example** - How to use the component
57
+
58
+ ## .context Awareness
59
+
60
+ If the project has a `.context/` directory:
61
+ 1. Read `.context/prefs/coding-style.md` and `.context/prefs/workflow.md` before coding
62
+ 2. Follow all conventions (naming, patterns, testing requirements)
63
+ 3. When making design decisions (choosing component patterns, state management, etc.), clearly state rationale and rejected alternatives in your output
64
+ 4. Follow the full development flow from workflow.md (implement → test → docs)
@@ -75,3 +75,10 @@ You are a senior frontend performance engineer specializing in React optimizatio
75
75
  - Expected after: [score]
76
76
  - How to measure: [tools]
77
77
  ```
78
+
79
+ ## .context Awareness
80
+
81
+ If the project has a `.context/` directory:
82
+ 1. Read `.context/prefs/coding-style.md` for project performance conventions
83
+ 2. Check `.context/history/commits.jsonl` for past optimization decisions — avoid re-doing work or reverting previous optimizations without reason
84
+ 3. Document optimization trade-offs clearly in your output (will be captured for future context)
@@ -71,3 +71,10 @@ RECOMMENDATION: [PASS/NEEDS_IMPROVEMENT]
71
71
  3. **Design Issues** - Inconsistencies
72
72
  4. **Suggestions** - Improvements
73
73
  5. **Positive Notes** - What's done well
74
+
75
+ ## .context Awareness
76
+
77
+ If the project has a `.context/` directory:
78
+ 1. Read `.context/prefs/coding-style.md` as the primary review standard
79
+ 2. Read `.context/prefs/workflow.md` to verify the full development flow was followed (tests written, docs updated, etc.)
80
+ 3. Check `.context/history/commits.jsonl` for past decisions on the same components — flag if current changes contradict previous design decisions without justification
@@ -59,3 +59,10 @@ You are a senior test engineer specializing in frontend testing, component testi
59
59
  2. **Test Cases** - Scenarios to cover
60
60
  3. **Implementation** - Unified Diff Patch for test files
61
61
  4. **Accessibility Notes** - a11y test coverage
62
+
63
+ ## .context Awareness
64
+
65
+ If the project has a `.context/` directory:
66
+ 1. Read `.context/prefs/coding-style.md` for testing conventions (naming, patterns, coverage requirements)
67
+ 2. Read `.context/prefs/workflow.md` to understand required test flow (e.g., failing test first for bug fixes)
68
+ 3. Check `.context/history/commits.jsonl` for past bugs on related components — ensure regression tests cover previously fixed issues
@@ -0,0 +1,63 @@
1
+ # CCG Quality Gates — Auto-trigger Rules
2
+
3
+ When working in a project, automatically invoke the corresponding quality gate skills based on the scenario below. These skills are installed at `~/.claude/skills/ccg/` and can be called directly.
4
+
5
+ ## Trigger Rules
6
+
7
+ ### New Module Created
8
+
9
+ When a new module/package/directory is created with source code:
10
+
11
+ ```
12
+ /gen-docs <module-path> → Generate README.md + DESIGN.md skeleton
13
+ ↓ (after development)
14
+ /verify-module <module-path> → Check structure completeness
15
+
16
+ /verify-security <module-path> → Scan for security vulnerabilities
17
+ ```
18
+
19
+ ### Code Changes > 30 Lines
20
+
21
+ When a single task produces code changes exceeding 30 lines:
22
+
23
+ ```
24
+ /verify-change → Analyze change impact, check doc sync
25
+
26
+ /verify-quality <changed-path> → Check complexity, code smells, naming
27
+ ```
28
+
29
+ ### Security-Related Changes
30
+
31
+ When changes involve authentication, authorization, encryption, input validation, or secrets management:
32
+
33
+ ```
34
+ /verify-security <changed-path> → Scan for vulnerabilities
35
+ ```
36
+
37
+ ### Refactoring
38
+
39
+ When refactoring existing code:
40
+
41
+ ```
42
+ /verify-change → Ensure docs reflect the refactoring
43
+
44
+ /verify-quality <refactored-path> → Verify quality improved
45
+
46
+ /verify-security <refactored-path> → No new vulnerabilities introduced
47
+ ```
48
+
49
+ ## Execution Rules
50
+
51
+ 1. **Non-blocking** — Quality gates produce reports but do NOT block delivery unless Critical issues are found
52
+ 2. **Chainable** — Run gates in the order specified above; skip if previous gate fails
53
+ 3. **Silent on pass** — Only report findings; do not output "all clear" messages for every gate
54
+ 4. **Critical = must fix** — Only `Critical` / `High` severity findings require action before delivery
55
+ 5. **Idempotent** — Safe to re-run; same input produces same output
56
+
57
+ ## Multi-Agent Coordination
58
+
59
+ When a task involves 3+ independent files/modules or 2+ parallel workflows, refer to the multi-agent orchestration skill at `~/.claude/skills/ccg/orchestration/multi-agent/SKILL.md` for:
60
+
61
+ - Agent role assignment (Lead / Scout / Worker / Soldier / Drone)
62
+ - File ownership locking (one writer per file at any time)
63
+ - Task decomposition strategy (by file, by module, or by pipeline)