add-coder 0.1.17 → 0.2.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/README.en.md +108 -10
- package/README.md +254 -17
- package/dist/index.js +72 -98
- package/package.json +2 -2
- package/templates/adapters/claude/hooks/doc-format-guard.sh +164 -9
- package/templates/adapters/claude/hooks/notification.sh +29 -0
- package/templates/adapters/claude/hooks/permission-denied.sh +42 -0
- package/templates/adapters/claude/hooks/post-tool-use.sh +25 -8
- package/templates/adapters/claude/hooks/pre-compact.sh +31 -8
- package/templates/adapters/claude/hooks/pre-tool-use.sh +63 -13
- package/templates/adapters/claude/hooks/prompt-submit.sh +70 -8
- package/templates/adapters/claude/hooks/session-end.sh +21 -0
- package/templates/adapters/claude/hooks/session-start.sh +26 -13
- package/templates/adapters/claude/hooks/stop-check.sh +40 -5
- package/templates/adapters/claude/hooks/stop-failure.sh +44 -0
- package/templates/adapters/claude/hooks/subagent-guard.sh +29 -8
- package/templates/adapters/claude/hooks/subagent-stop.sh +20 -0
- package/templates/adapters/codex/hooks/notification.sh +38 -0
- package/templates/adapters/codex/hooks/post-tool-use.sh +35 -0
- package/templates/adapters/codex/hooks/pre-tool-use.sh +78 -0
- package/templates/adapters/codex/hooks/prompt-submit.sh +78 -0
- package/templates/adapters/codex/hooks/session-start.sh +36 -0
- package/templates/adapters/codex/hooks/stop-check.sh +45 -0
- package/templates/adapters/codex/hooks.json +1 -0
- package/templates/adapters/codex/settings.json +1 -0
- package/templates/adapters/qoder/hooks/doc-format-guard.sh +9 -1
- package/templates/adapters/qoder/hooks/lib/vocabulary.sh +1 -1
- package/templates/adapters/qoder/hooks/notification.sh +8 -5
- package/templates/adapters/qoder/hooks/post-tool-use.sh +21 -11
- package/templates/adapters/qoder/hooks/pre-compact.sh +31 -6
- package/templates/adapters/qoder/hooks/pre-tool-use.sh +66 -64
- package/templates/adapters/qoder/hooks/prompt-submit.sh +12 -2
- package/templates/adapters/qoder/hooks/session-end.sh +24 -0
- package/templates/adapters/qoder/hooks/session-start.sh +22 -7
- package/templates/adapters/qoder/hooks/stop-check.sh +18 -41
- package/templates/adapters/qoder/hooks/subagent-guard.sh +22 -6
- package/templates/adapters/qoder/hooks/subagent-stop.sh +26 -0
- package/templates/adapters/qoder/settings.json +13 -13
- package/templates/adapters/trae/hooks/notification.sh +38 -0
- package/templates/adapters/trae/hooks/post-tool-failure.sh +10 -0
- package/templates/adapters/trae/hooks/post-tool-use.sh +35 -0
- package/templates/adapters/trae/hooks/pre-compact.sh +37 -0
- package/templates/adapters/trae/hooks/pre-tool-use.sh +78 -0
- package/templates/adapters/trae/hooks/prompt-submit.sh +78 -0
- package/templates/adapters/trae/hooks/session-end.sh +21 -0
- package/templates/adapters/trae/hooks/session-start.sh +36 -0
- package/templates/adapters/trae/hooks/stop-check.sh +45 -0
- package/templates/adapters/trae/hooks/subagent-guard.sh +36 -0
- package/templates/adapters/trae/hooks/subagent-stop.sh +20 -0
- package/templates/adapters/trae/hooks.json +1 -0
- package/templates/adapters/trae/settings.json +1 -0
- package/templates/adapters/vscode/.github/hooks/error-occurred.json +1 -0
- package/templates/adapters/vscode/.github/hooks/post-tool-use.json +1 -0
- package/templates/adapters/vscode/.github/hooks/pre-compact.json +1 -0
- package/templates/adapters/vscode/.github/hooks/pre-tool-use.json +14 -0
- package/templates/adapters/vscode/.github/hooks/session-end.json +1 -0
- package/templates/adapters/vscode/.github/hooks/session-start.json +14 -0
- package/templates/adapters/vscode/.github/hooks/stop-check.json +1 -0
- package/templates/adapters/vscode/.github/hooks/subagent-start.json +1 -0
- package/templates/adapters/vscode/.github/hooks/subagent-stop.json +1 -0
- package/templates/adapters/vscode/.github/hooks/user-prompt-submit.json +14 -0
- package/templates/adapters/vscode/hooks/notification.sh +37 -0
- package/templates/adapters/vscode/hooks/post-tool-failure.sh +28 -0
- package/templates/adapters/vscode/hooks/post-tool-use.sh +35 -0
- package/templates/adapters/vscode/hooks/pre-compact.sh +37 -0
- package/templates/adapters/vscode/hooks/pre-tool-use.sh +78 -0
- package/templates/adapters/vscode/hooks/prompt-submit.sh +78 -0
- package/templates/adapters/vscode/hooks/session-end.sh +13 -0
- package/templates/adapters/vscode/hooks/session-start.sh +35 -0
- package/templates/adapters/vscode/hooks/stop-check.sh +53 -0
- package/templates/adapters/vscode/hooks/subagent-guard.sh +37 -0
- package/templates/adapters/vscode/hooks/subagent-stop.sh +12 -0
- package/templates/adapters/vscode/launch.json +1 -1
- package/templates/adapters/vscode/settings.json +2 -3
- package/templates/adapters/vscode/tasks.json +3 -3
- package/templates/core/docs/ADD-governance-claude-code.md +121 -0
- package/templates/core/docs/ADD-governance-codex.md +75 -0
- package/templates/core/docs/ADD-governance-qoder-cn.md +99 -0
- package/templates/core/docs/ADD-governance-trae.md +63 -0
- package/templates/core/docs/ADD-governance-vscode-copilot.md +132 -0
- package/templates/core/hooks/doc-format-guard.sh +164 -9
- package/templates/core/hooks/lib/common.sh +261 -0
- package/templates/core/hooks/lib/preload-templates.sh +187 -0
- package/templates/core/hooks/lib/session-end.sh +76 -0
- package/templates/core/hooks/lib/subagent-stop.sh +90 -0
- package/templates/core/hooks/notification.sh +29 -0
- package/templates/core/hooks/post-tool-use.sh +25 -8
- package/templates/core/hooks/pre-compact.sh +31 -8
- package/templates/core/hooks/pre-tool-use.sh +63 -13
- package/templates/core/hooks/prompt-submit.sh +70 -8
- package/templates/core/hooks/session-end.sh +38 -0
- package/templates/core/hooks/session-start.sh +26 -13
- package/templates/core/hooks/stop-check.sh +40 -5
- package/templates/core/hooks/subagent-stop.sh +47 -0
- package/templates/core/rules/project_rules.md +1 -1
- package/templates/core/scripts/mcp-server.ts +38 -120
- package/templates/core/skills/add-paradigm/SKILL.md +24 -0
- package/templates/core/hooks/lib/context-inject.sh +0 -96
- package/templates/core/hooks/lib/state-detect.sh +0 -104
- package/templates/core/hooks/lib/vocabulary.sh +0 -49
package/README.en.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# add-coder
|
|
2
2
|
|
|
3
|
-
> 🌐 [🀄中文](
|
|
3
|
+
> 🌐 [🀄中文](https://github.com/xiaomingming92/add-coder/blob/main/README.md) | 🔤[English] — ⚠️ This file is temporarily unmaintained. The English translation is now embedded in README.md (scroll to ## 🔤 English README). Will resume standalone maintenance when the community grows.
|
|
4
4
|
|
|
5
5
|
**AI Governance, Implemented** — The complete scaffolding from [codein2027](https://github.com/xiaomingming92/codein2027) for rapidly building the ADD programming paradigm. Built on the core principle of **Audit as Infrastructure**, it shatters the black-box programming process and cross-session amnesia, evolving the programming paradigm into an auditable, traceable, and convergent new era. [NPM](https://www.npmjs.com/package/add-coder) · [GitHub](https://github.com/xiaomingming92/add-coder)
|
|
6
6
|
|
|
@@ -67,7 +67,15 @@ Hooks are not "notification push" — they are the **IDE runtime interception la
|
|
|
67
67
|
| PreCompact | Forces retention of critical document paths during cross-session context compression |
|
|
68
68
|
| PromptSubmit | Injects ADD vocabulary triggers, ensuring zero-latency LLM response to commands like "acceptance" and "gateway" |
|
|
69
69
|
|
|
70
|
-
Each IDE
|
|
70
|
+
Each IDE(Claude Code / Qoder CN / VS Code Copilot / Trae / Codex)has its own hook implementation, but the **governance logic is unified** — the architecture is consistent, only the adapter layer differs.
|
|
71
|
+
|
|
72
|
+
| IDE | Governance Doc | Events Covered | Hook Config |
|
|
73
|
+
|---|---|---|---|
|
|
74
|
+
| Claude Code | [ADD-governance-claude-code.md](./ADD-governance-claude-code.md) | 14/17 | `.claude/hooks/*.sh` |
|
|
75
|
+
| Qoder CN | [ADD-governance-qoder-cn.md](./ADD-governance-qoder-cn.md) | 10/17 | `.qoder/hooks/*.sh` |
|
|
76
|
+
| VS Code Copilot | [ADD-governance-vscode-copilot.md](./ADD-governance-vscode-copilot.md) | 10/17 | `.github/hooks/*.json` → `.vscode/hooks/*.sh` |
|
|
77
|
+
| Trae | [ADD-governance-trae.md](./ADD-governance-trae.md) | 6/17 | `hooks.json` → `.trae/hooks/*.sh` |
|
|
78
|
+
| Codex | [ADD-governance-codex.md](./ADD-governance-codex.md) | 0 native / 14 (via Claude import) | `.codex/hooks.json` |
|
|
71
79
|
|
|
72
80
|
---
|
|
73
81
|
|
|
@@ -116,7 +124,7 @@ npx add-coder init
|
|
|
116
124
|
|
|
117
125
|
| Option | Description |
|
|
118
126
|
|--------|-------------|
|
|
119
|
-
| `--adapter <type>` | Target IDE: claude / qoder / vscode / auto (default) |
|
|
127
|
+
| `--adapter <type>` | Target IDE: claude / qoder / vscode / trae / codex / auto (default) |
|
|
120
128
|
| `--config <path>` | Specify config file |
|
|
121
129
|
| `--yes` | Skip interactions, create new files only |
|
|
122
130
|
| `--force` | Overwrite existing files |
|
|
@@ -127,9 +135,11 @@ npx add-coder init
|
|
|
127
135
|
| Directory | Content |
|
|
128
136
|
|-----------|---------|
|
|
129
137
|
| `.add/` | ADD shared core (skills, agents, docs, scripts, rules, etc.) |
|
|
130
|
-
| `.claude/` | Claude Code adapter (hooks, settings.json) |
|
|
138
|
+
| `.claude/` | Claude Code adapter (hooks, settings.json, mcp.json) |
|
|
131
139
|
| `.qoder/` | Qoder adapter (hooks, settings.json, mcp.json) |
|
|
132
140
|
| `.vscode/` | VS Code adapter (settings.json, tasks.json) |
|
|
141
|
+
| `.trae/` | Trae adapter (hooks.json, settings.json) |
|
|
142
|
+
| `.codex/` | Codex adapter (hooks.json, settings.json) |
|
|
133
143
|
|
|
134
144
|
## MCP Audit Toolchain
|
|
135
145
|
|
|
@@ -171,12 +181,13 @@ npx add-coder init
|
|
|
171
181
|
│ Handoff / DevLog Timeline Docs │
|
|
172
182
|
└─────────────────────────────────────┘
|
|
173
183
|
│
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
184
|
+
┌──────────┬───────────┼───────────┬──────────┐
|
|
185
|
+
▼ ▼ ▼ ▼ ▼
|
|
186
|
+
┌──────┐ ┌──────┐ ┌──────────┐ ┌──────┐ ┌──────┐
|
|
187
|
+
│Claude│ │Qoder │ │ VS Code │ │ Trae │ │Codex │
|
|
188
|
+
│Hooks │ │Hooks │ │ Config │ │Hooks │ │Hooks │
|
|
189
|
+
│14/17 │ │10/17 │ │ 10/17 │ │ 6/17 │ │ 6/17 │
|
|
190
|
+
└──────┘ └──────┘ └──────────┘ └──────┘ └──────┘
|
|
180
191
|
│
|
|
181
192
|
┌────────────┘
|
|
182
193
|
▼
|
|
@@ -216,3 +227,90 @@ npx add-coder init
|
|
|
216
227
|
|------|-------------|
|
|
217
228
|
| Demo Repo | A full example repository showcasing end-to-end closed-loop practice of Policy-Update-Loop and the Report system |
|
|
218
229
|
| MCP Restructure | MCP toolchain architecture upgrade, improving audit and gateway tool extensibility and standalone deployment capability |
|
|
230
|
+
| Memory Enhancement | Long-term project knowledge memory and plan-level sparse memory |
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
<details id="chinese-readme">
|
|
234
|
+
<summary>🀄 中文 README</summary>
|
|
235
|
+
|
|
236
|
+
**AI 代码治理的落地方案** — [codein2027](https://github.com/xiaomingming92/codein2027) 快速构建 ADD 编程范式的完整脚手架。以「审计即基础设施」为核心,彻底打破编程过程黑盒与跨轮失忆,让编程范式进化为可审计、可追溯、可收敛的新时代。 [NPM](https://www.npmjs.com/package/add-coder) · [GitHub](https://github.com/xiaomingming92/add-coder)
|
|
237
|
+
|
|
238
|
+
> 🧭 **从零上手实操?** 请参见 [GUIDE.md](https://github.com/xiaomingming92/add-coder/blob/main/GUIDE.md)
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
npx add-coder init
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## 这不是模板工具,这是架构差异
|
|
245
|
+
|
|
246
|
+
### ① 审计是基础设施,而非事后日志
|
|
247
|
+
| 传统模式 | add-coder |
|
|
248
|
+
|---|---|
|
|
249
|
+
| 日志是 append-only 文本文件 | 审计是 **结构化数据表**(DevOperation + AuditLog),支持按 plan/step/agent/tool 多维查询 |
|
|
250
|
+
| 审计靠开发者自觉记录 | **MCP 审计工具链** 自动记录每次操作 |
|
|
251
|
+
| 无关联性 | Plan → Spec → Task → Step → Tool Call,形成完整证据链 |
|
|
252
|
+
|
|
253
|
+
### ② 门禁驱动,而非自由对话
|
|
254
|
+
```
|
|
255
|
+
DPS (Design-Process Symmetry) — 设计/实现/文档/审计 四维各 25%,< 85% BLOCKED
|
|
256
|
+
RAHS (Runtime Architecture Health Score) — 运行时架构健康度,< 90% BLOCKED
|
|
257
|
+
```
|
|
258
|
+
这不是「建议」,是**架构阻断** — 不通过闸门的 Step 无法推进到下一步。
|
|
259
|
+
|
|
260
|
+
### ③ 跨轮记忆,而非每轮失忆
|
|
261
|
+
- **Handoff 文档** — 每轮 Session 结束时自动生成结构化交接文档
|
|
262
|
+
- **Plan 索引** — 所有 Plan 通过 `index.md` 集中索引
|
|
263
|
+
- **DevLog 时序记录** — 每一步操作写入 `{YYYY-MM}/{DD}/` 时间轴
|
|
264
|
+
|
|
265
|
+
### ④ Policy-Update-Loop:治理自我进化
|
|
266
|
+
```
|
|
267
|
+
执行 → 审计 → 边界报告 → 规则调整 → 下一轮执行
|
|
268
|
+
```
|
|
269
|
+
运行时产生的 Report 会反过来更新 governance rules。
|
|
270
|
+
|
|
271
|
+
### ⑤ 多 IDE 的 Hook 即治理层
|
|
272
|
+
| IDE | 治理文档 | 覆盖事件 | Hook 配置 |
|
|
273
|
+
|---|---|---|---|
|
|
274
|
+
| Claude Code | [ADD-governance-claude-code.md](./ADD-governance-claude-code.md) | 14/17 | `.claude/hooks/*.sh` |
|
|
275
|
+
| Qoder CN | [ADD-governance-qoder-cn.md](./ADD-governance-qoder-cn.md) | 10/17 | `.qoder/hooks/*.sh` |
|
|
276
|
+
| VS Code Copilot | [ADD-governance-vscode-copilot.md](./ADD-governance-vscode-copilot.md) | 10/17 | `.github/hooks/*.json` → `.vscode/hooks/*.sh` |
|
|
277
|
+
| Trae | [ADD-governance-trae.md](./ADD-governance-trae.md) | 6/17 | `hooks.json` → `.trae/hooks/*.sh` |
|
|
278
|
+
| Codex | [ADD-governance-codex.md](./ADD-governance-codex.md) | 0 (原生) / 14 (导入 Claude) | `.codex/hooks.json` |
|
|
279
|
+
|
|
280
|
+
## 快速开始
|
|
281
|
+
```bash
|
|
282
|
+
npx add-coder init
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
| 命令 | 说明 |
|
|
286
|
+
|---|---|
|
|
287
|
+
| `init` | 初始化 ADD 模板,支持 `--adapter claude\|qoder\|vscode\|trae\|codex\|auto` |
|
|
288
|
+
| `sync` | 增量同步缺失文件 |
|
|
289
|
+
| `status` | 检查模板完整性 |
|
|
290
|
+
|
|
291
|
+
| 选项 | 说明 |
|
|
292
|
+
|---|---|
|
|
293
|
+
| `--adapter <type>` | 目标 IDE:claude / qoder / vscode / trae / codex / auto |
|
|
294
|
+
| `--force` | 覆盖已有文件 |
|
|
295
|
+
| `--dry-run` | 预览模式,不写入 |
|
|
296
|
+
|
|
297
|
+
## MCP 审计工具链
|
|
298
|
+
| 工具 | 用途 |
|
|
299
|
+
|---|---|
|
|
300
|
+
| `record_dev_operation` | 记录开发操作审计 |
|
|
301
|
+
| `query_audit_logs` | 按 planKeyword / targetId 查询审计记录 |
|
|
302
|
+
| `check_dps` | DPS 闸门(< 85% BLOCKED) |
|
|
303
|
+
| `check_rahs` | RAHS 闸门(< 90% BLOCKED) |
|
|
304
|
+
|
|
305
|
+
## 前置条件
|
|
306
|
+
- Node.js >= 20 · Prisma ^7.0 · PostgreSQL / SQLite
|
|
307
|
+
|
|
308
|
+
## 🎬 预告
|
|
309
|
+
| 计划 | 说明 |
|
|
310
|
+
|---|---|
|
|
311
|
+
| Demo 仓库演示 | Policy-Update-Loop 与 Report 体系端到端闭环实践 |
|
|
312
|
+
| MCP 能力重构 | MCP 工具链架构升级 |
|
|
313
|
+
| 对话记忆增强 | 长期项目知识记忆和 plan 级别的稀疏记忆 |
|
|
314
|
+
|
|
315
|
+
> 📦 [更新日志](./CHANGELOG.md)
|
|
316
|
+
</details>
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# add-coder
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> 🀄中文 | 🔤[English](#-english-readme)
|
|
4
4
|
|
|
5
5
|
**AI 代码治理的落地方案** — [codein2027](https://github.com/xiaomingming92/codein2027) 快速构建 ADD 编程范式的完整脚手架。以「审计即基础设施」为核心,彻底打破编程过程黑盒与跨轮失忆,让编程范式进化为可审计、可追溯、可收敛的新时代。 [NPM](https://www.npmjs.com/package/add-coder) · [GitHub](https://github.com/xiaomingming92/add-coder)
|
|
6
6
|
|
|
@@ -58,16 +58,17 @@ AI 对话的致命缺陷:上次讨论的架构决策、已修复的 Bug、达
|
|
|
58
58
|
|
|
59
59
|
### ⑤ 多 IDE 的 Hook 即治理层
|
|
60
60
|
|
|
61
|
-
hook 不是「通知推送」,而是 **IDE
|
|
61
|
+
hook 不是「通知推送」,而是 **ADD 范式在 IDE agent 生命周期中的 17 个确定性治理卡位**。每个 IDE(Claude Code / Qoder CN / VS Code Copilot / Trae / Codex)有各自的 hook 机制,但治理逻辑统一——架构一致,适配层不同。
|
|
62
62
|
|
|
63
|
-
|
|
|
64
|
-
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
63
|
+
| IDE | 治理文档 | 覆盖事件 | Hook 配置 |
|
|
64
|
+
|---|---|---|---|
|
|
65
|
+
| Claude Code | [ADD-governance-claude-code.md](./ADD-governance-claude-code.md) | 14/17 | `.claude/hooks/*.sh` |
|
|
66
|
+
| Qoder CN | [ADD-governance-qoder-cn.md](./ADD-governance-qoder-cn.md) | 10/17 | `.qoder/hooks/*.sh` |
|
|
67
|
+
| VS Code Copilot | [ADD-governance-vscode-copilot.md](./ADD-governance-vscode-copilot.md) | 10/17 | `.github/hooks/*.json` → `.vscode/hooks/*.sh` |
|
|
68
|
+
| Trae | [ADD-governance-trae.md](./ADD-governance-trae.md) | 6/17 | `hooks.json` → `.trae/hooks/*.sh` |
|
|
69
|
+
| Codex | [ADD-governance-codex.md](./ADD-governance-codex.md) | 0 (原生) / 14 (导入 Claude) | `.codex/hooks.json` |
|
|
69
70
|
|
|
70
|
-
|
|
71
|
+
> 实施 Plan: [add-coder-hook-full-alignment-plan-v1](./.qoder/plans/2026-07/17/add-coder-hook-full-alignment-plan-v1.md) | 触发源: [GitHub Issue #6](https://github.com/xiaomingming92/add-coder/issues/6)
|
|
71
72
|
|
|
72
73
|
---
|
|
73
74
|
|
|
@@ -171,15 +172,16 @@ npx add-coder init
|
|
|
171
172
|
│ Handoff / DevLog 时序文档 │
|
|
172
173
|
└─────────────────────────────────────┘
|
|
173
174
|
│
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
175
|
+
┌──────────┬───────────┼────────┬─────┐
|
|
176
|
+
▼ ▼ ▼ ▼ ▼
|
|
177
|
+
┌──────┐ ┌──────┐ ┌──────────┐ ┌──────┐ ┌──────┐
|
|
178
|
+
│Claude│ │Qoder │ │ VS Code │ │ Trae │ │Codex │
|
|
179
|
+
│Hooks │ │Hooks │ │ Config │ │Hooks │ │Hooks │
|
|
180
|
+
│14/17 │ │10/17 │ │ 10/17 │ │ 6/17 │ │ 6/17 │
|
|
181
|
+
└──────┘ └──────┘ └──────────┘ └──────┘ └──────┘
|
|
180
182
|
│
|
|
181
|
-
|
|
182
|
-
|
|
183
|
+
|
|
|
184
|
+
▼
|
|
183
185
|
┌─────────────────────────────────────┐
|
|
184
186
|
│ Caijuehub 规则引擎 │
|
|
185
187
|
│ TOML 驱动的策略体系 │
|
|
@@ -215,3 +217,238 @@ npx add-coder init
|
|
|
215
217
|
|------|------|
|
|
216
218
|
| Demo 仓库演示 | 提供完整示例仓库,展示 Policy-Update-Loop 与 Report 体系的端到端闭环实践 |
|
|
217
219
|
| MCP 能力重构 | MCP 工具链架构升级,提升审计与门禁工具的可扩展性和独立部署能力 |
|
|
220
|
+
| 对话记忆增强 | 长期项目知识记忆和plan级别的稀疏记忆 |
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
## 🔤 English README
|
|
226
|
+
|
|
227
|
+
**AI Governance, Implemented** — The complete scaffolding from [codein2027](https://github.com/xiaomingming92/codein2027) for rapidly building the ADD programming paradigm. Built on the core principle of **Audit as Infrastructure**, it shatters the black-box programming process and cross-session amnesia, evolving the programming paradigm into an auditable, traceable, and convergent new era. [NPM](https://www.npmjs.com/package/add-coder) · [GitHub](https://github.com/xiaomingming92/add-coder)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
> 🧭 **Getting hands-on?** See [GUIDE.md](https://github.com/xiaomingming92/add-coder/blob/main/GUIDE.md) — trigger word quick reference, requirements-to-Plan, and full workflow walkthrough.
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
npx add-coder init
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Not a Template Tool — An Architectural Difference
|
|
239
|
+
|
|
240
|
+
There are already plenty of AI coding templates, hook adapters, and MCP scaffolds. What fundamentally sets add-coder apart is not "what files it generates," but a **paradigm shift at the architectural level**:
|
|
241
|
+
|
|
242
|
+
### ① Audit Is Infrastructure, Not After-the-Fact Logging
|
|
243
|
+
|
|
244
|
+
Traditional AI development: Chat → Generate code → Dig through chat history afterward to find "who changed what"
|
|
245
|
+
|
|
246
|
+
| Traditional Model | add-coder |
|
|
247
|
+
|-------------------|-----------|
|
|
248
|
+
| Logs are append-only text files | Audit is a **structured data table** (DevOperation + AuditLog), supporting multi-dimensional queries by plan/step/agent/tool |
|
|
249
|
+
| Auditing relies on developer discipline | The **MCP audit toolchain** automatically records every operation; system gateways enforce checks |
|
|
250
|
+
| No traceability | Audit events are naturally linked: Plan → Spec → Task → Step → Tool Call, forming a complete evidence chain |
|
|
251
|
+
|
|
252
|
+
### ② Gateway-Driven, Not Free-Form Conversation
|
|
253
|
+
|
|
254
|
+
Traditional AI coding is "you say, I do" — quality depends entirely on the LLM's state that day. add-coder embeds **dual quality gateways** into the architecture:
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
DPS (Design-Process Symmetry) — Design / Implementation / Docs / Audit, each weighted 25%, < 85% BLOCKED
|
|
258
|
+
RAHS (Runtime Architecture Health Score) — Runtime architecture health, < 90% BLOCKED
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
These are not "suggestions" — they are **architectural blocks**. A Step cannot advance without passing its gateway.
|
|
262
|
+
|
|
263
|
+
### ③ Cross-Session Memory, Not Per-Session Amnesia
|
|
264
|
+
|
|
265
|
+
The fatal flaw of AI conversations: architectural decisions from last session, bugs fixed, agreements reached — all forgotten in the next conversation. add-coder solves this at the architecture level:
|
|
266
|
+
|
|
267
|
+
- **Handoff Documents** — Automatically generated structured handoff at the end of each session, auto-loaded by the next session
|
|
268
|
+
- **Plan Index** — All Plans are centrally indexed via `index.md`, supporting fuzzy-match quick lookup
|
|
269
|
+
- **DevLog Timeline** — Every operation is written to the `{YYYY-MM}/{DD}/` timeline, enabling full historical state traceability
|
|
270
|
+
|
|
271
|
+
### ④ Policy-Update-Loop: Self-Evolving Governance (the scaffold itself does not include this architectural capability; a DEMO repo will be provided next to better illustrate the Policy-Update-Loop and Report system)
|
|
272
|
+
|
|
273
|
+
Not a static template, but a **closed-loop adaptive system**:
|
|
274
|
+
|
|
275
|
+
```
|
|
276
|
+
Execute → Audit → Boundary Report → Rule Adjustment → Next Execution
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Runtime-generated Reports feed back into governance rules, enabling continuous evolution of governance strategies.
|
|
280
|
+
|
|
281
|
+
### ⑤ Multi-IDE Hooks as the Governance Layer
|
|
282
|
+
|
|
283
|
+
Hooks are not "notification push" — they are the **IDE runtime interception layer**:
|
|
284
|
+
|
|
285
|
+
| Hook Type | Function |
|
|
286
|
+
|-----------|----------|
|
|
287
|
+
| PreToolUse | Validates whitelist before tool invocation, injects context, DPS condition checks |
|
|
288
|
+
| PostToolUse | Automatic audit logging, Plan sync detection, format guarding |
|
|
289
|
+
| PreCompact | Forces retention of critical document paths during cross-session context compression |
|
|
290
|
+
| PromptSubmit | Injects ADD vocabulary triggers, ensuring zero-latency LLM response to commands like "acceptance" and "gateway" |
|
|
291
|
+
|
|
292
|
+
Each IDE(Claude Code / Qoder CN / VS Code Copilot / Trae / Codex)has its own hook implementation, but the **governance logic is unified** — the architecture is consistent, only the adapter layer differs.
|
|
293
|
+
|
|
294
|
+
| IDE | Governance Doc | Events Covered | Hook Config |
|
|
295
|
+
|---|---|---|---|
|
|
296
|
+
| Claude Code | [ADD-governance-claude-code.md](./ADD-governance-claude-code.md) | 14/17 | `.claude/hooks/*.sh` |
|
|
297
|
+
| Qoder CN | [ADD-governance-qoder-cn.md](./ADD-governance-qoder-cn.md) | 10/17 | `.qoder/hooks/*.sh` |
|
|
298
|
+
| VS Code Copilot | [ADD-governance-vscode-copilot.md](./ADD-governance-vscode-copilot.md) | 10/17 | `.github/hooks/*.json` → `.vscode/hooks/*.sh` |
|
|
299
|
+
| Trae | [ADD-governance-trae.md](./ADD-governance-trae.md) | 6/17 | `hooks.json` → `.trae/hooks/*.sh` |
|
|
300
|
+
| Codex | [ADD-governance-codex.md](./ADD-governance-codex.md) | 0 native / 14 (via Claude import) | `.codex/hooks.json` |
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## Quick Start
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
npx add-coder init
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
The first `init` auto-detects your IDE and interactively guides you through database selection (PostgreSQL / SQLite / self-managed), container runtime (podman / docker / self-managed), Prisma initialization, and ADD template deployment.
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
npx add-coder init
|
|
314
|
+
# → Choose IDE (Qoder / Claude / VS Code)
|
|
315
|
+
# → Choose database (PostgreSQL / SQLite / self-managed)
|
|
316
|
+
# → Choose container (podman / docker / self-managed)
|
|
317
|
+
# → prisma init + add.prisma copied
|
|
318
|
+
# → prisma db push (adds new tables only, no data deletion)
|
|
319
|
+
# → prisma generate
|
|
320
|
+
# → ADD governance model ready ✓
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
> **Env file priority**: `.env.development.local` > `.env.development` > `.env.local` > `.env`
|
|
324
|
+
|
|
325
|
+
## Commands
|
|
326
|
+
|
|
327
|
+
| Command | Description |
|
|
328
|
+
|---------|-------------|
|
|
329
|
+
| `init` | Initialize ADD templates, supports `--adapter claude\|qoder\|vscode\|auto` |
|
|
330
|
+
| `sync` | Incrementally sync missing files |
|
|
331
|
+
| `status` | Check template integrity |
|
|
332
|
+
|
|
333
|
+
### init Internal Flow
|
|
334
|
+
|
|
335
|
+
| Step | Action | Description |
|
|
336
|
+
|------|--------|-------------|
|
|
337
|
+
| ① | Detect IDE | Scan for `.qoder/` `.claude/` `.vscode/` existence, or specify via `--adapter` |
|
|
338
|
+
| ② | Load config | Interactive Q&A > `add-coder.config.ts` > auto-detect > defaults |
|
|
339
|
+
| ③ | DB deployment | `db-ensure.sh` starts container/PG connection + `injectPrisma()` Caijue layer (Prisma init → AddUser model copy → db push → generate) |
|
|
340
|
+
| ④ | Render templates | 55 core template files (skills/agents/templates/plans/specs/scripts…) |
|
|
341
|
+
| ⑤ | Deploy adapters | Copy core content to `.add/` `.qoder/` `.claude/` directories, supplement IDE-specific hooks/mcp |
|
|
342
|
+
| ⑥ | Write files | Four modes: interactive / yes / force / dry-run; `.sh` scripts auto `chmod` |
|
|
343
|
+
| ⑦ | Output summary | Created / skipped / overwritten stats + next-step hints |
|
|
344
|
+
|
|
345
|
+
### init Options
|
|
346
|
+
|
|
347
|
+
| Option | Description |
|
|
348
|
+
|--------|-------------|
|
|
349
|
+
| `--adapter <type>` | Target IDE: claude / qoder / vscode / trae / codex / auto (default) |
|
|
350
|
+
| `--config <path>` | Specify config file |
|
|
351
|
+
| `--yes` | Skip interactions, create new files only |
|
|
352
|
+
| `--force` | Overwrite existing files |
|
|
353
|
+
| `--dry-run` | Preview mode, no writes |
|
|
354
|
+
|
|
355
|
+
## Generated Content
|
|
356
|
+
|
|
357
|
+
| Directory | Content |
|
|
358
|
+
|-----------|---------|
|
|
359
|
+
| `.add/` | ADD shared core (skills, agents, docs, scripts, rules, etc.) |
|
|
360
|
+
| `.claude/` | Claude Code adapter (hooks, settings.json, mcp.json) |
|
|
361
|
+
| `.qoder/` | Qoder adapter (hooks, settings.json, mcp.json) |
|
|
362
|
+
| `.vscode/` | VS Code adapter (settings.json, tasks.json) |
|
|
363
|
+
| `.trae/` | Trae adapter (hooks.json, settings.json) |
|
|
364
|
+
| `.codex/` | Codex adapter (hooks.json, settings.json) |
|
|
365
|
+
|
|
366
|
+
## MCP Audit Toolchain
|
|
367
|
+
|
|
368
|
+
`init` automatically deploys the MCP server (`mcp-server.ts`) into the project, loaded by the IDE via `mcp.json`. The following audit and governance tools are provided:
|
|
369
|
+
|
|
370
|
+
| Tool | Purpose | Trigger Scenario |
|
|
371
|
+
|------|---------|-----------------|
|
|
372
|
+
| `record_dev_operation` | Record development operation audits (before/after/reason) | Every file change, config modification |
|
|
373
|
+
| `query_audit_logs` | Query audit records by planKeyword / targetId | Cross-session context recovery, iteration evidence verification |
|
|
374
|
+
| `get_project_context` | Get ADD workflow status snapshot | Fresh conversation start |
|
|
375
|
+
| `get_db_schema` | Get Prisma schema info | Database-related operations |
|
|
376
|
+
| `check_dps` | DPS gateway (Design/Implementation/Docs/Audit, each 25%) | End of Step 0 |
|
|
377
|
+
| `check_rahs` | RAHS gateway (runtime architecture health) | Step 4/8 |
|
|
378
|
+
| `check_add_route_status` | add-route file existence check | Before Step 3 |
|
|
379
|
+
| `check_spec_sync` | Spec doc checkbox status vs. code consistency | After Spec execution |
|
|
380
|
+
| `find_related_docs` | Search related architecture/spec documents | Context understanding |
|
|
381
|
+
|
|
382
|
+
> Full tool list: [MCP Toolchain Specification](https://github.com/xiaomingming92/codein2027/blob/main/docs/大田精准耕播智能决策系统/knowledge/02-规范/%E3%80%8A%E5%BC%80%E5%8F%91%E6%93%8D%E4%BD%9C%E5%AE%A1%E8%AE%A1%E5%AD%98%E6%A1%A3%E8%A7%84%E8%8C%83%E3%80%8B.md).
|
|
383
|
+
|
|
384
|
+
## Architecture Overview
|
|
385
|
+
|
|
386
|
+
```
|
|
387
|
+
┌─────────────┐
|
|
388
|
+
│ ADD Paradigm│
|
|
389
|
+
│ Step 0-9 │
|
|
390
|
+
└──────┬──────┘
|
|
391
|
+
│ Gateway-driven
|
|
392
|
+
┌────────────┼────────────┐
|
|
393
|
+
▼ ▼ ▼
|
|
394
|
+
┌──────────┐ ┌──────────┐ ┌──────────┐
|
|
395
|
+
│DPS Gateway│ │RAHS Gate │ │Compliance│
|
|
396
|
+
└────┬─────┘ └────┬─────┘ └────┬─────┘
|
|
397
|
+
│ │ │
|
|
398
|
+
▼ ▼ ▼
|
|
399
|
+
┌─────────────────────────────────────┐
|
|
400
|
+
│ Audit Infrastructure Layer │
|
|
401
|
+
│ DevOperation / AuditLog Tables │
|
|
402
|
+
│ MCP Audit Toolchain │
|
|
403
|
+
│ Handoff / DevLog Timeline Docs │
|
|
404
|
+
└─────────────────────────────────────┘
|
|
405
|
+
│
|
|
406
|
+
┌──────────┬───────────┼───────────┬──────────┐
|
|
407
|
+
▼ ▼ ▼ ▼ ▼
|
|
408
|
+
┌──────┐ ┌──────┐ ┌──────────┐ ┌──────┐ ┌──────┐
|
|
409
|
+
│Claude│ │Qoder │ │ VS Code │ │ Trae │ │Codex │
|
|
410
|
+
│Hooks │ │Hooks │ │ Config │ │Hooks │ │Hooks │
|
|
411
|
+
│14/17 │ │10/17 │ │ 10/17 │ │ 6/17 │ │ 6/17 │
|
|
412
|
+
└──────┘ └──────┘ └──────────┘ └──────┘ └──────┘
|
|
413
|
+
│
|
|
414
|
+
┌────────────┘
|
|
415
|
+
▼
|
|
416
|
+
┌─────────────────────────────────────┐
|
|
417
|
+
│ Caijuehub Rule Engine │
|
|
418
|
+
│ TOML-Driven Policy System │
|
|
419
|
+
│ Detect / Adapt / Prisma / Write — │
|
|
420
|
+
│ Fully Configurable │
|
|
421
|
+
└─────────────────────────────────────┘
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
## Prerequisites
|
|
425
|
+
|
|
426
|
+
- Node.js >= 20
|
|
427
|
+
- Prisma ^7.0 (auto-detected during `init`, guided installation if missing)
|
|
428
|
+
- PostgreSQL / SQLite (MCP toolchain depends on DevOperation + AuditLog tables)
|
|
429
|
+
|
|
430
|
+
> **Recommended**: Run PostgreSQL via Podman/Docker, reference config:
|
|
431
|
+
> ```yaml
|
|
432
|
+
> postgres:
|
|
433
|
+
> image: docker.io/postgres:16-alpine
|
|
434
|
+
> ports: ["127.0.0.1:5433:5432"]
|
|
435
|
+
> environment:
|
|
436
|
+
> POSTGRES_DB: mydb
|
|
437
|
+
> POSTGRES_USER: admin
|
|
438
|
+
> POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
439
|
+
> ```
|
|
440
|
+
> Mount data volume to `~/data/your_project/postgres/` to avoid data loss on container removal.
|
|
441
|
+
|
|
442
|
+
> 📦 [Changelog](./CHANGELOG.md)
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
## 🎬 Coming Soon
|
|
447
|
+
|
|
448
|
+
| Plan | Description |
|
|
449
|
+
|------|-------------|
|
|
450
|
+
| Demo Repo | A full example repository showcasing end-to-end closed-loop practice of Policy-Update-Loop and the Report system |
|
|
451
|
+
| MCP Restructure | MCP toolchain architecture upgrade, improving audit and gateway tool extensibility and standalone deployment capability |
|
|
452
|
+
| Memory Enhancement | Long-term project knowledge memory and plan-level sparse memory |
|
|
453
|
+
|
|
454
|
+
---
|