add-coder 0.1.14 → 0.1.17

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 ADDED
@@ -0,0 +1,218 @@
1
+ # add-coder
2
+
3
+ > 🌐 [🀄中文](./README.md) | English
4
+
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
+
7
+
8
+ > 🧭 **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.
9
+
10
+ ```bash
11
+ npx add-coder init
12
+ ```
13
+
14
+ ---
15
+
16
+ ## Not a Template Tool — An Architectural Difference
17
+
18
+ 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**:
19
+
20
+ ### ① Audit Is Infrastructure, Not After-the-Fact Logging
21
+
22
+ Traditional AI development: Chat → Generate code → Dig through chat history afterward to find "who changed what"
23
+
24
+ | Traditional Model | add-coder |
25
+ |-------------------|-----------|
26
+ | Logs are append-only text files | Audit is a **structured data table** (DevOperation + AuditLog), supporting multi-dimensional queries by plan/step/agent/tool |
27
+ | Auditing relies on developer discipline | The **MCP audit toolchain** automatically records every operation; system gateways enforce checks |
28
+ | No traceability | Audit events are naturally linked: Plan → Spec → Task → Step → Tool Call, forming a complete evidence chain |
29
+
30
+ ### ② Gateway-Driven, Not Free-Form Conversation
31
+
32
+ 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:
33
+
34
+ ```
35
+ DPS (Design-Process Symmetry) — Design / Implementation / Docs / Audit, each weighted 25%, < 85% BLOCKED
36
+ RAHS (Runtime Architecture Health Score) — Runtime architecture health, < 90% BLOCKED
37
+ ```
38
+
39
+ These are not "suggestions" — they are **architectural blocks**. A Step cannot advance without passing its gateway.
40
+
41
+ ### ③ Cross-Session Memory, Not Per-Session Amnesia
42
+
43
+ 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:
44
+
45
+ - **Handoff Documents** — Automatically generated structured handoff at the end of each session, auto-loaded by the next session
46
+ - **Plan Index** — All Plans are centrally indexed via `index.md`, supporting fuzzy-match quick lookup
47
+ - **DevLog Timeline** — Every operation is written to the `{YYYY-MM}/{DD}/` timeline, enabling full historical state traceability
48
+
49
+ ### ④ 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)
50
+
51
+ Not a static template, but a **closed-loop adaptive system**:
52
+
53
+ ```
54
+ Execute → Audit → Boundary Report → Rule Adjustment → Next Execution
55
+ ```
56
+
57
+ Runtime-generated Reports feed back into governance rules, enabling continuous evolution of governance strategies.
58
+
59
+ ### ⑤ Multi-IDE Hooks as the Governance Layer
60
+
61
+ Hooks are not "notification push" — they are the **IDE runtime interception layer**:
62
+
63
+ | Hook Type | Function |
64
+ |-----------|----------|
65
+ | PreToolUse | Validates whitelist before tool invocation, injects context, DPS condition checks |
66
+ | PostToolUse | Automatic audit logging, Plan sync detection, format guarding |
67
+ | PreCompact | Forces retention of critical document paths during cross-session context compression |
68
+ | PromptSubmit | Injects ADD vocabulary triggers, ensuring zero-latency LLM response to commands like "acceptance" and "gateway" |
69
+
70
+ Each IDE (Claude/Qoder/VS Code) has its own hook implementation, but the **governance logic is unified** — the architecture is consistent, only the adapter layer differs.
71
+
72
+ ---
73
+
74
+ ## Quick Start
75
+
76
+ ```bash
77
+ npx add-coder init
78
+ ```
79
+
80
+ 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.
81
+
82
+ ```bash
83
+ npx add-coder init
84
+ # → Choose IDE (Qoder / Claude / VS Code)
85
+ # → Choose database (PostgreSQL / SQLite / self-managed)
86
+ # → Choose container (podman / docker / self-managed)
87
+ # → prisma init + add.prisma copied
88
+ # → prisma db push (adds new tables only, no data deletion)
89
+ # → prisma generate
90
+ # → ADD governance model ready ✓
91
+ ```
92
+
93
+ > **Env file priority**: `.env.development.local` > `.env.development` > `.env.local` > `.env`
94
+
95
+ ## Commands
96
+
97
+ | Command | Description |
98
+ |---------|-------------|
99
+ | `init` | Initialize ADD templates, supports `--adapter claude\|qoder\|vscode\|auto` |
100
+ | `sync` | Incrementally sync missing files |
101
+ | `status` | Check template integrity |
102
+
103
+ ### init Internal Flow
104
+
105
+ | Step | Action | Description |
106
+ |------|--------|-------------|
107
+ | ① | Detect IDE | Scan for `.qoder/` `.claude/` `.vscode/` existence, or specify via `--adapter` |
108
+ | ② | Load config | Interactive Q&A > `add-coder.config.ts` > auto-detect > defaults |
109
+ | ③ | DB deployment | `db-ensure.sh` starts container/PG connection + `injectPrisma()` Caijue layer (Prisma init → AddUser model copy → db push → generate) |
110
+ | ④ | Render templates | 55 core template files (skills/agents/templates/plans/specs/scripts…) |
111
+ | ⑤ | Deploy adapters | Copy core content to `.add/` `.qoder/` `.claude/` directories, supplement IDE-specific hooks/mcp |
112
+ | ⑥ | Write files | Four modes: interactive / yes / force / dry-run; `.sh` scripts auto `chmod` |
113
+ | ⑦ | Output summary | Created / skipped / overwritten stats + next-step hints |
114
+
115
+ ### init Options
116
+
117
+ | Option | Description |
118
+ |--------|-------------|
119
+ | `--adapter <type>` | Target IDE: claude / qoder / vscode / auto (default) |
120
+ | `--config <path>` | Specify config file |
121
+ | `--yes` | Skip interactions, create new files only |
122
+ | `--force` | Overwrite existing files |
123
+ | `--dry-run` | Preview mode, no writes |
124
+
125
+ ## Generated Content
126
+
127
+ | Directory | Content |
128
+ |-----------|---------|
129
+ | `.add/` | ADD shared core (skills, agents, docs, scripts, rules, etc.) |
130
+ | `.claude/` | Claude Code adapter (hooks, settings.json) |
131
+ | `.qoder/` | Qoder adapter (hooks, settings.json, mcp.json) |
132
+ | `.vscode/` | VS Code adapter (settings.json, tasks.json) |
133
+
134
+ ## MCP Audit Toolchain
135
+
136
+ `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:
137
+
138
+ | Tool | Purpose | Trigger Scenario |
139
+ |------|---------|-----------------|
140
+ | `record_dev_operation` | Record development operation audits (before/after/reason) | Every file change, config modification |
141
+ | `query_audit_logs` | Query audit records by planKeyword / targetId | Cross-session context recovery, iteration evidence verification |
142
+ | `get_project_context` | Get ADD workflow status snapshot | Fresh conversation start |
143
+ | `get_db_schema` | Get Prisma schema info | Database-related operations |
144
+ | `check_dps` | DPS gateway (Design/Implementation/Docs/Audit, each 25%) | End of Step 0 |
145
+ | `check_rahs` | RAHS gateway (runtime architecture health) | Step 4/8 |
146
+ | `check_add_route_status` | add-route file existence check | Before Step 3 |
147
+ | `check_spec_sync` | Spec doc checkbox status vs. code consistency | After Spec execution |
148
+ | `find_related_docs` | Search related architecture/spec documents | Context understanding |
149
+
150
+ > 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).
151
+
152
+ ## Architecture Overview
153
+
154
+ ```
155
+ ┌─────────────┐
156
+ │ ADD Paradigm│
157
+ │ Step 0-9 │
158
+ └──────┬──────┘
159
+ │ Gateway-driven
160
+ ┌────────────┼────────────┐
161
+ ▼ ▼ ▼
162
+ ┌──────────┐ ┌──────────┐ ┌──────────┐
163
+ │DPS Gateway│ │RAHS Gate │ │Compliance│
164
+ └────┬─────┘ └────┬─────┘ └────┬─────┘
165
+ │ │ │
166
+ ▼ ▼ ▼
167
+ ┌─────────────────────────────────────┐
168
+ │ Audit Infrastructure Layer │
169
+ │ DevOperation / AuditLog Tables │
170
+ │ MCP Audit Toolchain │
171
+ │ Handoff / DevLog Timeline Docs │
172
+ └─────────────────────────────────────┘
173
+
174
+ ┌────────────┼────────────┐
175
+ ▼ ▼ ▼
176
+ ┌──────────┐ ┌──────────┐ ┌──────────┐
177
+ │ Claude │ │ Qoder │ │ VS Code │
178
+ │ Hooks │ │ Hooks │ │ Config │
179
+ └──────────┘ └──────────┘ └──────────┘
180
+
181
+ ┌────────────┘
182
+
183
+ ┌─────────────────────────────────────┐
184
+ │ Caijuehub Rule Engine │
185
+ │ TOML-Driven Policy System │
186
+ │ Detect / Adapt / Prisma / Write — │
187
+ │ Fully Configurable │
188
+ └─────────────────────────────────────┘
189
+ ```
190
+
191
+ ## Prerequisites
192
+
193
+ - Node.js >= 20
194
+ - Prisma ^7.0 (auto-detected during `init`, guided installation if missing)
195
+ - PostgreSQL / SQLite (MCP toolchain depends on DevOperation + AuditLog tables)
196
+
197
+ > **Recommended**: Run PostgreSQL via Podman/Docker, reference config:
198
+ > ```yaml
199
+ > postgres:
200
+ > image: docker.io/postgres:16-alpine
201
+ > ports: ["127.0.0.1:5433:5432"]
202
+ > environment:
203
+ > POSTGRES_DB: mydb
204
+ > POSTGRES_USER: admin
205
+ > POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
206
+ > ```
207
+ > Mount data volume to `~/data/your_project/postgres/` to avoid data loss on container removal.
208
+
209
+ > 📦 [Changelog](./CHANGELOG.md)
210
+
211
+ ---
212
+
213
+ ## 🎬 Coming Soon
214
+
215
+ | Plan | Description |
216
+ |------|-------------|
217
+ | Demo Repo | A full example repository showcasing end-to-end closed-loop practice of Policy-Update-Loop and the Report system |
218
+ | MCP Restructure | MCP toolchain architecture upgrade, improving audit and gateway tool extensibility and standalone deployment capability |
package/README.md CHANGED
@@ -1,7 +1,10 @@
1
1
  # add-coder
2
2
 
3
+ > 🌐 🀄中文 | [English](./README.en.md)
4
+
3
5
  **AI 代码治理的落地方案** — [codein2027](https://github.com/xiaomingming92/codein2027) 快速构建 ADD 编程范式的完整脚手架。以「审计即基础设施」为核心,彻底打破编程过程黑盒与跨轮失忆,让编程范式进化为可审计、可追溯、可收敛的新时代。 [NPM](https://www.npmjs.com/package/add-coder) · [GitHub](https://github.com/xiaomingming92/add-coder)
4
6
 
7
+
5
8
  > 🧭 **从零上手实操?** 请参见 [GUIDE.md](https://github.com/xiaomingming92/add-coder/blob/main/GUIDE.md) — 包含触发词速查、需求转 Plan、完整链路演练。
6
9
 
7
10
  ```bash
@@ -43,7 +46,7 @@ AI 对话的致命缺陷:上次讨论的架构决策、已修复的 Bug、达
43
46
  - **Plan 索引** — 所有 Plan 通过 `index.md` 集中索引,支持模糊匹配快速定位
44
47
  - **DevLog 时序记录** — 每一步操作写入 `{YYYY-MM}/{DD}/` 时间轴,可回溯任意历史状态
45
48
 
46
- ### ④ Policy-Update-Loop:治理自我进化
49
+ ### ④ Policy-Update-Loop:治理自我进化(脚手架不包含此架构能力,接下来会给到DEMO仓库让大家更好理解Policy-Update-Loop和Report体系)
47
50
 
48
51
  不是静态模板,而是**闭环自适应系统**:
49
52
 
@@ -201,3 +204,14 @@ npx add-coder init
201
204
  > POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
202
205
  > ```
203
206
  > 数据卷建议挂载到 `~/data/your_project/postgres/`,避免容器销毁丢失数据。
207
+
208
+ > 📦 [更新日志 (CHANGELOG)](./CHANGELOG.md)
209
+
210
+ ---
211
+
212
+ ## 🎬 预告
213
+
214
+ | 计划 | 说明 |
215
+ |------|------|
216
+ | Demo 仓库演示 | 提供完整示例仓库,展示 Policy-Update-Loop 与 Report 体系的端到端闭环实践 |
217
+ | MCP 能力重构 | MCP 工具链架构升级,提升审计与门禁工具的可扩展性和独立部署能力 |
package/dist/index.js CHANGED
@@ -736,7 +736,7 @@ async function initCommand(options) {
736
736
  }
737
737
  if (db.engine === "postgresql" && db.container && db.container !== "manual") {
738
738
  if (!db.reuseExisting) {
739
- const composeName = db.container === "podman" ? "podman-compose.yml" : "docker-compose.yml";
739
+ const composeName = db.container === "podman" ? "podman-compose.add.yml" : "docker-compose.add.yml";
740
740
  const composePath = resolve4(projectRoot, composeName);
741
741
  if (!options.dryRun && (!existsSync6(composePath) || options.force)) {
742
742
  writeFileSync3(composePath, composeContent(config.projectName || "add-project"), "utf-8");
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "add-coder",
3
- "version": "0.1.14",
3
+ "version": "0.1.17",
4
4
  "private": false,
5
5
  "description": "[codein2027](https://github.com/xiaomingming92/codein2027) 快速构建 ADD 编程范式的完整脚手架——AI 代码治理的落地方案。以「审计即基础设施」为核心,彻底打破编程过程黑盒与跨轮失忆,让编程范式进化为可审计、可追溯、可收敛的新时代。npx 即用,人人可体验。",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/xiaomingming92/add-coder.git"
9
+ },
6
10
  "type": "module",
7
11
  "bin": {
8
12
  "add-coder": "bin/add-coder.js"
@@ -51,13 +51,14 @@ fi
51
51
 
52
52
  # ── 容器模式 ──
53
53
  COMPOSE_CMD=""
54
- if [ "$CONTAINER" = "podman" ]; then COMPOSE_CMD="podman-compose"
55
- elif [ "$CONTAINER" = "docker" ]; then COMPOSE_CMD="docker-compose"
54
+ COMPOSE_FILE=""
55
+ if [ "$CONTAINER" = "podman" ]; then COMPOSE_CMD="podman-compose"; COMPOSE_FILE="podman-compose.add.yml"
56
+ elif [ "$CONTAINER" = "docker" ]; then COMPOSE_CMD="docker-compose"; COMPOSE_FILE="docker-compose.add.yml"
56
57
  else echo "未知容器: $CONTAINER"; exit 1
57
58
  fi
58
59
 
59
- echo ">>> 启动 PostgreSQL ($COMPOSE_CMD up -d) ..."
60
- $COMPOSE_CMD up -d || {
60
+ echo ">>> 启动 PostgreSQL ($COMPOSE_CMD -f $COMPOSE_FILE up -d) ..."
61
+ $COMPOSE_CMD -f "$COMPOSE_FILE" up -d || {
61
62
  echo "容器启动失败,请检查 $COMPOSE_CMD 是否已安装或端口是否冲突"
62
63
  exit 1
63
64
  }
@@ -67,7 +68,7 @@ echo ">>> 等待 PostgreSQL 就绪 ..."
67
68
  MAX_RETRIES=30
68
69
  RETRY=0
69
70
  while [ $RETRY -lt $MAX_RETRIES ]; do
70
- if $COMPOSE_CMD exec -T postgres pg_isready -U "$DB_USER" > /dev/null 2>&1; then
71
+ if $COMPOSE_CMD -f "$COMPOSE_FILE" exec -T postgres pg_isready -U "$DB_USER" > /dev/null 2>&1; then
71
72
  echo "PostgreSQL 已就绪"; break
72
73
  fi
73
74
  sleep 1
@@ -58,22 +58,48 @@
58
58
  ## 四、实施 Task + 依赖图
59
59
 
60
60
  ```
61
- Task 1 ──┐
62
- 可并行
63
- Task 2 ──┘
64
-
65
-
66
- Task 3 ──┐
67
- Task 4 ──┤ 可并行
68
- Task 5 ──┘
69
-
70
-
71
- Task 6 (编译/测试)
61
+ 轮次 1: {轮次名称}
62
+ ├── Task 1.1: {任务描述}({文件})
63
+ └── Task 1.2: {任务描述}({文件})
64
+
65
+
66
+ 轮次 2: {轮次名称}
67
+ ├── Task 2.1: {任务描述}({文件})
68
+ │ │ {产出 被 N.M 消费的标注}
69
+
70
+ ├── Task 2.2: {任务描述}({文件})
71
+ │ │ {消费 2.1 的产出,产出 → 被 N.M 消费}
72
+ │ ▼
73
+ └── Task 2.3: {任务描述}({文件})
74
+
75
+
76
+ 轮次 3: {轮次名称}
77
+ ├── Task 3.1: {任务描述}({文件})
78
+ ├── Task 3.2: {任务描述}({文件})
79
+ └── Task 3.3: {任务描述}({文件})
72
80
  ```
73
81
 
74
- ### Step 0: 文档先行
82
+ ### 轮次 1: {轮次名称}
75
83
 
76
- ### Step N: ...
84
+ | # | 任务 | 文件 | 说明 | 验收 |
85
+ |---|------|------|------|------|
86
+ | 1.1 | {任务名} | `path/to/file.ts` | {做什么} | `tsc --noEmit` |
87
+ | 1.2 | {任务名} | `path/to/file.ts` | {做什么} | `tsc --noEmit` |
88
+
89
+ ### 轮次 2: {轮次名称}
90
+
91
+ | # | 任务 | 文件 | 说明 | 验收 |
92
+ |---|------|------|------|------|
93
+ | 2.1 | {任务名} | `path/to/file.ts` | {做什么} | `tsc --noEmit` + 单测 |
94
+ | 2.2 | {任务名} | `path/to/file.ts` | {做什么} | `tsc --noEmit` + 单测 |
95
+
96
+ ### 轮次 3: {轮次名称}
97
+
98
+ | # | 任务 | 文件 | 说明 | 验收 |
99
+ |---|------|------|------|------|
100
+ | 3.1 | {任务名} | `path/to/file.ts` | {做什么} | `tsc --noEmit` |
101
+ | 3.2 | {任务名} | `path/to/file.ts` | {做什么} | 图编译无异常 |
102
+ | 3.3 | {任务名} | `path/to/file.ts` | {做什么} | 端到端通过 |
77
103
 
78
104
  ---
79
105