add-coder 0.3.35 → 0.3.37
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 +101 -42
- package/README.md +63 -18
- package/dist/index.js +3 -3
- package/package.json +2 -2
- package/templates/.add-coder-src-hash.json +74 -73
- package/templates/adapters/claude/hooks/doc-format-guard.mjs +4 -0
- package/templates/adapters/claude/hooks/notification.mjs +4 -0
- package/templates/adapters/claude/hooks/permission-denied.mjs +4 -0
- package/templates/adapters/claude/hooks/permission-gate.mjs +4 -0
- package/templates/adapters/claude/hooks/post-tool-use.mjs +4 -0
- package/templates/adapters/claude/hooks/pre-compact.mjs +4 -0
- package/templates/adapters/claude/hooks/pre-tool-use.mjs +4 -0
- package/templates/adapters/claude/hooks/prompt-submit.mjs +4 -0
- package/templates/adapters/claude/hooks/session-end.mjs +4 -0
- package/templates/adapters/claude/hooks/session-start.mjs +4 -0
- package/templates/adapters/claude/hooks/stop-check.mjs +87 -6
- package/templates/adapters/claude/hooks/stop-failure.mjs +4 -0
- package/templates/adapters/claude/hooks/subagent-guard.mjs +4 -0
- package/templates/adapters/claude/hooks/subagent-stop.mjs +4 -0
- package/templates/adapters/codex/hooks/doc-format-guard.mjs +4 -0
- package/templates/adapters/codex/hooks/notification.mjs +4 -0
- package/templates/adapters/codex/hooks/permission-gate.mjs +4 -0
- package/templates/adapters/codex/hooks/post-tool-failure.mjs +4 -0
- package/templates/adapters/codex/hooks/post-tool-use.mjs +4 -0
- package/templates/adapters/codex/hooks/pre-compact.mjs +4 -0
- package/templates/adapters/codex/hooks/pre-tool-use.mjs +4 -0
- package/templates/adapters/codex/hooks/prompt-submit.mjs +4 -0
- package/templates/adapters/codex/hooks/session-end.mjs +4 -0
- package/templates/adapters/codex/hooks/session-start.mjs +4 -0
- package/templates/adapters/codex/hooks/stop-check.mjs +87 -6
- package/templates/adapters/codex/hooks/subagent-guard.mjs +4 -0
- package/templates/adapters/codex/hooks/subagent-stop.mjs +4 -0
- package/templates/adapters/qoder/hooks/doc-format-guard.mjs +4 -0
- package/templates/adapters/qoder/hooks/notification.mjs +4 -0
- package/templates/adapters/qoder/hooks/permission-gate.mjs +4 -0
- package/templates/adapters/qoder/hooks/post-tool-failure.mjs +4 -0
- package/templates/adapters/qoder/hooks/post-tool-use.mjs +4 -0
- package/templates/adapters/qoder/hooks/pre-compact.mjs +4 -0
- package/templates/adapters/qoder/hooks/pre-tool-use.mjs +4 -0
- package/templates/adapters/qoder/hooks/prompt-submit.mjs +4 -0
- package/templates/adapters/qoder/hooks/review-checklist.mjs +4 -0
- package/templates/adapters/qoder/hooks/session-end.mjs +4 -0
- package/templates/adapters/qoder/hooks/session-start.mjs +4 -0
- package/templates/adapters/qoder/hooks/stop-check.mjs +87 -6
- package/templates/adapters/qoder/hooks/subagent-guard.mjs +4 -0
- package/templates/adapters/qoder/hooks/subagent-stop.mjs +4 -0
- package/templates/adapters/trae/hooks/doc-format-guard.mjs +4 -0
- package/templates/adapters/trae/hooks/notification.mjs +4 -0
- package/templates/adapters/trae/hooks/permission-gate.mjs +4 -0
- package/templates/adapters/trae/hooks/post-tool-failure.mjs +4 -0
- package/templates/adapters/trae/hooks/post-tool-use.mjs +4 -0
- package/templates/adapters/trae/hooks/pre-compact.mjs +4 -0
- package/templates/adapters/trae/hooks/pre-tool-use.mjs +4 -0
- package/templates/adapters/trae/hooks/prompt-submit.mjs +4 -0
- package/templates/adapters/trae/hooks/session-end.mjs +4 -0
- package/templates/adapters/trae/hooks/session-start.mjs +4 -0
- package/templates/adapters/trae/hooks/stop-check.mjs +87 -6
- package/templates/adapters/trae/hooks/subagent-guard.mjs +4 -0
- package/templates/adapters/trae/hooks/subagent-stop.mjs +4 -0
- package/templates/adapters/vscode/hooks/doc-format-guard.mjs +4 -0
- package/templates/adapters/vscode/hooks/notification.mjs +4 -0
- package/templates/adapters/vscode/hooks/permission-gate.mjs +4 -0
- package/templates/adapters/vscode/hooks/post-tool-failure.mjs +4 -0
- package/templates/adapters/vscode/hooks/post-tool-use.mjs +4 -0
- package/templates/adapters/vscode/hooks/pre-compact.mjs +4 -0
- package/templates/adapters/vscode/hooks/pre-tool-use.mjs +4 -0
- package/templates/adapters/vscode/hooks/prompt-submit.mjs +4 -0
- package/templates/adapters/vscode/hooks/session-end.mjs +4 -0
- package/templates/adapters/vscode/hooks/session-start.mjs +4 -0
- package/templates/adapters/vscode/hooks/stop-check.mjs +87 -6
- package/templates/adapters/vscode/hooks/subagent-guard.mjs +4 -0
- package/templates/adapters/vscode/hooks/subagent-stop.mjs +4 -0
- package/templates/core/governance/rules.ts +4 -0
- package/templates/core/governance/stop-router.ts +101 -7
- package/templates/core/scripts/db-ensure.sh +33 -2
- package/templates/core/scripts/mcp-server/shared/dps-spec-ref.ts +17 -0
- package/templates/core/scripts/mcp-server/tools/gateway/check_dps.ts +3 -4
- package/templates/core/scripts/mcp-server/tools/gateway/check_spec_sync.ts +2 -2
package/README.en.md
CHANGED
|
@@ -48,32 +48,73 @@ ADD paradigm + Qoder: cache hit rate 99.31%, only 2,426 MISS tokens/req
|
|
|
48
48
|
|
|
49
49
|
### ③ Gateway-Driven, Not Free-Form Conversation
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
> **Others retry; add-coder gates.** Quality should not depend on the model's mood that day.
|
|
52
|
+
|
|
53
|
+
Traditional AI coding is "you say, I do" — quality rests entirely on the LLM's form in the moment. add-coder embeds **dual quality gateways** in the architecture — not "suggestions" but **architectural blocks**: without passing the gate, a Step cannot advance.
|
|
54
|
+
|
|
55
|
+
| Dimension | Typical practice | add-coder's dual gateways |
|
|
56
|
+
|-----------|------------------|---------------------------|
|
|
57
|
+
| **Basis** | Model self-assessment / human eyeballing | **DPS**: semantics (TF-IDF/Jaccard) + entropy (Shannon/Deng) + CPM critical path + structural completeness; **RAHS**: scope fidelity / type safety / audit completeness / Spec compliance / phase symmetry |
|
|
58
|
+
| **Force** | "Please make sure…" in a prompt | Cannot enter Step 1 without passing DPS (`PASS=80`, threshold sourced from `dps-scoring-rules.toml`); nothing is released without RAHS (≥90) |
|
|
59
|
+
| **Reproducibility** | Ask the model twice, get two answers | Same document + same parameters = same score; per-dimension scores plus a weakness list — explainable, comparable, regression-testable |
|
|
60
|
+
| **Tuning** | Edit code, edit prompts, re-release | **caijuehub TOML declarations**: score → read weaknesses → tune → re-score, without touching code |
|
|
61
|
+
| **Weights** | Hand-tuned once, then frozen | **FFT adaptive weights** that evolve with audit data — DPS parameters are data, not magic numbers |
|
|
62
|
+
| **Negative feedback** | "Just regenerate it" | A failed gate pinpoints the weak dimension; gate results are collected idempotently (Gate → `MetricSnapshot`) into the memory loop for review |
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
DPS (Documentation Precision Score) — semantics + entropy + CPM critical path + structural completeness → 4-dimension composite + FFT adaptive weights
|
|
66
|
+
RAHS (Runtime Architecture Health Score) — scope fidelity + type safety + audit completeness + Spec compliance + phase symmetry → ≥ 90 passes
|
|
56
67
|
```
|
|
57
68
|
|
|
58
|
-
|
|
69
|
+
> Thresholds and parameters live in a readable TOML source of truth (`dps-scoring-rules.toml`), not magic numbers; `check_dps` resolves spec references across five adapters (qoder / claude / add / vscode / codex·trae, covered by `tests/dps-adapter.test.ts`).
|
|
59
70
|
|
|
60
71
|
### ④ Cross-Session Memory, Not Per-Session Amnesia
|
|
61
72
|
|
|
62
|
-
|
|
73
|
+
> **Other tools "remember". add-coder governs memory.** Memory is not a context-engineering problem — it is a governance problem.
|
|
63
74
|
|
|
64
|
-
|
|
65
|
-
- **Plan Index** — All Plans are centrally indexed via `index.md`, supporting fuzzy-match quick lookup
|
|
66
|
-
- **DevLog Timeline** — Every operation is written to the `{YYYY-MM}/{DD}/` timeline, enabling full historical state traceability
|
|
75
|
+
The fatal flaw of AI conversations: architectural decisions from last session, bugs fixed, agreements reached — all forgotten in the next conversation. Most AI coding tools treat "memory" as **session/repo-level text excerpts plus vector search** — pasting slices of old chats or files back into context. That answers "was it seen", not "does it count, should it be injected, who is accountable when it is wrong". add-coder's memory is a **governed knowledge layer**: every conclusion carries evidence, every recall can be replayed, every revision leaves a trace, every cross-boundary leak can be sampled.
|
|
67
76
|
|
|
68
|
-
|
|
77
|
+
**The gap is structural, not a recall-rate gap**
|
|
69
78
|
|
|
70
|
-
|
|
79
|
+
| Dimension | Typical "memory" | add-coder memory loop (since v0.3.35) |
|
|
80
|
+
|-----------|------------------|---------------------------------------|
|
|
81
|
+
| **Write path** | Auto-extract, active immediately | **Candidate-only**: `propose_memory` lands CANDIDATE (dedup + secret scan + conflict detection); it turns ACTIVE only after human adjudication via `resolve_memory`, and `approve` requires ≥1 piece of evidence |
|
|
82
|
+
| **Grounding** | The memory text is its own justification | **Evidence chain**: conclusions and sources are separated; collection is idempotent (`sourceRef=<gate>:<planKeyword>:<runId>`; replays never duplicate); `get_memory` exposes provenance and the supersession chain |
|
|
83
|
+
| **Timing** | Similarity-triggered, can fire anytime | **Deterministic waypoint recall**: fires on ADD stage waypoints only (Plan draft / Spec draft / DPS / RAHS / Handoff), specificity-first word lists; produced synchronously on the Hook side, executed on the MCP side |
|
|
84
|
+
| **Retrieval** | Single-channel vector similarity | **FTS × vector, RRF-fused, then governed rerank** (scope / kind / importance / confidence / mandatory constraints − stale / conflict / redundancy), trimmed to a token budget |
|
|
85
|
+
| **Explainability** | Result only | Every hit carries `whySelected` / `scoreBreakdown` / `recallId`; `rankingVersion` stores the config snapshot — **the same recall can be replayed** |
|
|
86
|
+
| **Degradation** | No explicit contract | Without pgvector / sqlite-vec it runs FTS-only and returns `degradedMode` explicitly — never silently distorted |
|
|
87
|
+
| **Correction** | Delete or overwrite | **Governance state machine**: submit_review / approve / reject / stale / supersede / archive / restore, with scope-compatible supersession — memory can be *falsified*, not merely overwritten |
|
|
88
|
+
| **Boundaries** | No scope isolation | Eight-level scope isolation (ORGANIZATION / REPOSITORY / BRANCH / MODULE / PATH / SYMBOL / PLAN / SPEC) + cross-repo leakage sampling in `get_memory_health` |
|
|
89
|
+
| **Weighting** | Hard-coded weights | Feedback stats (channel × rank × outcome) / cold-start fitting / Kalman online estimation / FFT cadence diagnostics (never direct ranking); **the weight snapshot is the single source of truth for ranking parameters** |
|
|
71
90
|
|
|
72
|
-
|
|
91
|
+
**Two layers**
|
|
92
|
+
|
|
93
|
+
- **Document layer** (since v0.3.25) — Handoff documents (auto-generated each session end, auto-loaded next session) · Plan index (`index.md`, fuzzy lookup) · DevLog timeline (`{YYYY-MM}/{DD}/`, fully traceable)
|
|
94
|
+
- **Knowledge layer** (the v0.3.35 memory loop) — candidate-only intake → idempotent evidence collection (whitelisted tool events → `evidence-queue.jsonl` → async consumption → `MetricSnapshot`) → waypoint recall → hybrid recall + governed rerank → feedback-driven calibration, every step on the record
|
|
95
|
+
|
|
96
|
+
**Switches**: `ADD_MEMORY_RECALL_MODE=off|shadow|inject` (default `shadow`: recall runs and is audited, but is not injected yet) · `ADD_MEMORY_MAX_TOKENS` (default 600) · `ADD_MEMORY_EVIDENCE` (default `on`).
|
|
97
|
+
|
|
98
|
+
> Honest disclosure: measured Hybrid `MRR@5` 0.4867 < the 0.75 threshold (FTS-only 0.6551, Recall@5 0.9592) — the threshold stays put; data-driven calibration replaces hand-tuning. The capability runs, can be inspected and can be adjudicated — no metric inflation.
|
|
99
|
+
> Source layout, tables and dev workflow: [DEVELOPMENT.md](./DEVELOPMENT.md) §十七.
|
|
100
|
+
|
|
101
|
+
### ⑤ Policy-Update-Loop: Self-Evolving Governance
|
|
102
|
+
|
|
103
|
+
> **Static templates rot; closed-loop governance evolves.** Rules are not frozen constants — they are parameters that audit data can move.
|
|
104
|
+
> (The scaffold itself does not include the end-to-end boundary-report loop yet; a DEMO repo will illustrate the Policy-Update-Loop and Report system.)
|
|
105
|
+
|
|
106
|
+
```text
|
|
73
107
|
Execute → Audit → Boundary Report → Rule Adjustment → Next Execution
|
|
74
108
|
```
|
|
75
109
|
|
|
76
|
-
|
|
110
|
+
| Dimension | Static rules / templates | add-coder Policy-Update-Loop |
|
|
111
|
+
|-----------|--------------------------|------------------------------|
|
|
112
|
+
| **Where rules live** | Hard-coded in code and prompts; changing them means a release | caijuehub TOML declarations: rule sources → generated constants → inlined into artifacts; **edit rules, not code** |
|
|
113
|
+
| **Where rules come from** | Thresholds picked by intuition | Fed by audit data: DPS **FFT adaptive weights**; `check_doc_similarity` quantitatively re-checks look-alike documents |
|
|
114
|
+
| **Feedback loop** | None | **Execute → Audit (✓ live)**: hook interception / file-write events → jsonl → MCP resident consumer → DevOperation persistence (`HOOK_INTERCEPT`, idempotent dedup) |
|
|
115
|
+
| **Consistency** | Each endpoint implements its own, behaviour drifts | One governance contract layer + a five-endpoint consistency matrix asserting each behaviour (dangerous-command blocking / sensitive-file anchoring / audit event surface / protocol shape / zero governance duplication) |
|
|
116
|
+
| **Evidence of evolution** | No trail | Every interception, score and adjudication lands in the audit store — queryable, countable, reproducible |
|
|
117
|
+
| **Not closed yet** | — | Boundary reports (Runtime Report) end-to-end pending the DEMO repo (disclosed as-is) |
|
|
77
118
|
|
|
78
119
|
### ⑥ Multi-IDE Hooks as the Governance Layer
|
|
79
120
|
|
|
@@ -88,13 +129,28 @@ Hooks are not "notification push" — they are the **IDE runtime interception la
|
|
|
88
129
|
|
|
89
130
|
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.
|
|
90
131
|
|
|
91
|
-
| IDE | Governance Doc |
|
|
132
|
+
| IDE | Governance Doc | Registrable events | Hook Config (direct node invocation) |
|
|
92
133
|
|---|---|---|---|
|
|
93
|
-
| Claude Code | [ADD-governance-claude-code.md](./templates/core/docs/ADD-governance-claude-code.md) |
|
|
94
|
-
| Qoder CN | [ADD-governance-qoder-cn.md](./templates/core/docs/ADD-governance-qoder-cn.md) |
|
|
95
|
-
| VS Code Copilot | [ADD-governance-vscode-copilot.md](./templates/core/docs/ADD-governance-vscode-copilot.md) | 10/
|
|
96
|
-
| Trae | [ADD-governance-trae.md](./templates/core/docs/ADD-governance-trae.md) | 6/
|
|
97
|
-
| Codex | [ADD-governance-codex.md](./templates/core/docs/ADD-governance-codex.md) |
|
|
134
|
+
| Claude Code | [ADD-governance-claude-code.md](./templates/core/docs/ADD-governance-claude-code.md) | 11/16 | `.claude/hooks/*.mjs` (settings.json command) |
|
|
135
|
+
| Qoder CN | [ADD-governance-qoder-cn.md](./templates/core/docs/ADD-governance-qoder-cn.md) | 11/16 | `.qoder/hooks/*.mjs` (settings.json command) |
|
|
136
|
+
| VS Code Copilot | [ADD-governance-vscode-copilot.md](./templates/core/docs/ADD-governance-vscode-copilot.md) | 10/16 | `.vscode/hooks/*.mjs` (Agent Host dual channel) |
|
|
137
|
+
| Trae | [ADD-governance-trae.md](./templates/core/docs/ADD-governance-trae.md) | 6/16 | `hooks.json` → `.trae/hooks/*.mjs` |
|
|
138
|
+
| Codex | [ADD-governance-codex.md](./templates/core/docs/ADD-governance-codex.md) | 5/16 | `.codex/hooks.json` → `.codex/hooks/*.mjs` |
|
|
139
|
+
|
|
140
|
+
### ⑦ Codex Native Integration (v0.3.25)
|
|
141
|
+
|
|
142
|
+
> **Not a bolted-on MCP server, but governance landing natively.** "Templates generated" ≠ "end-to-end verified" — this is a 6-step path that has actually been exercised.
|
|
143
|
+
|
|
144
|
+
| Dimension | Typical integration | add-coder × Codex |
|
|
145
|
+
|-----------|--------------------|-------------------|
|
|
146
|
+
| **Setup cost** | Hand-written launcher scripts | Three CLI steps: `init --adapter=codex` → `--print-mcp-config` (no writes, no project init) → paste, or `--write-user-config` (backup first, duplicate-safe) |
|
|
147
|
+
| **Governance surface** | Tool calls only, no lifecycle governance | **Native hooks**: `.codex/hooks.json` → `.codex/hooks/*.mjs` (14 entry artifacts pre-baked in the package, invoked by `node`; 5/16 native events registrable today, the rest already placeheld, enabled with zero code once the event model grows) |
|
|
148
|
+
| **Approval** | Ask in chat | **Native HITL**: `create_hitl` takes the MCP Apps branch (no high-dimensional `inputRequired` in Codex); when the panel cannot render, it falls back to a markdown proposal + instance HTML, and verdicts are still persisted |
|
|
149
|
+
| **Runtime state** | No way to tell whether the new artifacts are running | **Four-state artifact/process freshness** + `.mcp-restart-required` marker: `sync` names the server that needs a restart |
|
|
150
|
+
| **Multi-project** | A pasted-wrong config silently connects to the wrong DB | `env.PROJECT_ROOT` injected at render time; a mismatched config makes mcp-server exit on startup (process-layer contract §4) |
|
|
151
|
+
| **Platform** | WSL required / paths patched by hand | win32 automatically emits a native `cmd /c npx.cmd` branch |
|
|
152
|
+
|
|
153
|
+
> Disclosed as-is: some Codex builds (measured `26.908`) do not render the approval widget; approval then goes through the markdown proposal + instance HTML + a chat verdict — the path works and verdicts are still persisted.
|
|
98
154
|
|
|
99
155
|
---
|
|
100
156
|
|
|
@@ -205,7 +261,7 @@ npx add-coder init
|
|
|
205
261
|
┌──────┐ ┌──────┐ ┌──────────┐ ┌──────┐ ┌──────┐
|
|
206
262
|
│Claude│ │Qoder │ │ VS Code │ │ Trae │ │Codex │
|
|
207
263
|
│Hooks │ │Hooks │ │ Config │ │Hooks │ │Hooks │
|
|
208
|
-
│
|
|
264
|
+
│11/16 │ │11/16 │ │ 10/16 │ │ 6/16 │ │ 5/16 │
|
|
209
265
|
└──────┘ └──────┘ └──────────┘ └──────┘ └──────┘
|
|
210
266
|
│
|
|
211
267
|
┌────────────┘
|
|
@@ -227,7 +283,7 @@ npx add-coder init
|
|
|
227
283
|
> **Recommended**: Run PostgreSQL via Podman/Docker, reference config:
|
|
228
284
|
> ```yaml
|
|
229
285
|
> postgres:
|
|
230
|
-
> image: docker.io/
|
|
286
|
+
> image: docker.io/pgvector/pgvector:pg16
|
|
231
287
|
> ports: ["127.0.0.1:5433:5432"]
|
|
232
288
|
> environment:
|
|
233
289
|
> POSTGRES_DB: mydb
|
|
@@ -246,7 +302,7 @@ npx add-coder init
|
|
|
246
302
|
|------|-------------|
|
|
247
303
|
| Demo Repo | A full example repository showcasing end-to-end closed-loop practice of Policy-Update-Loop and the Report system |
|
|
248
304
|
| MCP Restructure | MCP toolchain architecture upgrade, improving audit and gateway tool extensibility and standalone deployment capability |
|
|
249
|
-
| Memory Enhancement |
|
|
305
|
+
| Memory Enhancement | ✅ **Delivered in v0.3.35**: idempotent evidence collection + deterministic waypoint recall + hybrid FTS×vector recall (RRF fusion + governed rerank) + Handoff Digest candidates + a ranking calibration foundation; defaults to `shadow` mode (recall runs and is audited, not injected yet) |
|
|
250
306
|
|
|
251
307
|
---
|
|
252
308
|
<details id="chinese-readme">
|
|
@@ -270,31 +326,34 @@ npx add-coder init
|
|
|
270
326
|
| 无关联性 | Plan → Spec → Task → Step → Tool Call,形成完整证据链 |
|
|
271
327
|
|
|
272
328
|
### ② 门禁驱动,而非自由对话
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
这不是「建议」,是**架构阻断** — 不通过闸门的 Step 无法推进到下一步。
|
|
329
|
+
|
|
330
|
+
> **别的工具靠「再试一次」,add-coder 靠「先过闸门」。**
|
|
331
|
+
|
|
332
|
+
DPS(Documentation Precision Score)= 语义 + 熵 + CPM 关键路径 + 结构完整度四维复合 + FFT 自适应权重(`PASS=80`);RAHS = 范围保真 / 类型安全 / 审计完整 / Spec 合规 / 阶段对称(≥90)。这不是「建议」,是**架构阻断**——不过闸门,Step 推进不了;阈值与权重都是可读 TOML 真源(`dps-scoring-rules.toml`),改规则不改代码。
|
|
278
333
|
|
|
279
334
|
### ③ 跨轮记忆,而非每轮失忆
|
|
280
|
-
|
|
281
|
-
-
|
|
282
|
-
|
|
335
|
+
|
|
336
|
+
> **别的工具在「记」,add-coder 在「治理记忆」。** 记忆不是上下文工程,是治理工程。
|
|
337
|
+
|
|
338
|
+
多数工具的记忆 = 会话/仓库级文本摘录 + 向量检索(解决「看过」);add-coder 是**受治理的知识层**:候选制入库(approve 需 ≥1 证据)· 证据链 + 幂等采证 · 位点确定性召回 · FTS×向量 RRF 融合 + 治理重排 · 召回可重放(`recallId` / `rankingVersion`)· 治理状态机可证伪(supersede 强制 scope 兼容)· 八级 scope 隔离 + 越库泄漏抽查 · 权重快照即排序参数单一事实源。
|
|
339
|
+
|
|
340
|
+
**落地**:文档层(Handoff / Plan 索引 / DevLog 时序)+ 知识层(v0.3.35 记忆闭环,全链条留痕);开关 `ADD_MEMORY_RECALL_MODE` 默认 `shadow`(召回照跑照审计、暂不注入)。
|
|
341
|
+
**如实登记**:Hybrid `MRR@5` 0.4867 < 0.75 门槛,门槛不下调,由排序校准线程以数据校准替代手调。
|
|
283
342
|
|
|
284
343
|
### ④ Policy-Update-Loop:治理自我进化
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
344
|
+
|
|
345
|
+
> **静态模板会腐化,闭环治理会进化。**
|
|
346
|
+
|
|
347
|
+
执行 → 审计(✓ 已接入:hook 拦截 / 文件写入 → jsonl → MCP 常驻消费 → DevOperation 幂等落库)→ 规则调整(✓ 已接入:caijuehub 改规则不改代码 · DPS FFT 自适应权重 · `check_doc_similarity` 量化复检);边界报告(Runtime Report)端到端实践待 DEMO 仓库演示。
|
|
289
348
|
|
|
290
349
|
### ⑤ 多 IDE 的 Hook 即治理层
|
|
291
350
|
| IDE | 治理文档 | 覆盖事件 | Hook 配置 |
|
|
292
351
|
|---|---|---|---|
|
|
293
|
-
| Claude Code | [ADD-governance-claude-code.md](./templates/core/docs/ADD-governance-claude-code.md) |
|
|
294
|
-
| Qoder CN | [ADD-governance-qoder-cn.md](./templates/core/docs/ADD-governance-qoder-cn.md) |
|
|
295
|
-
| VS Code Copilot | [ADD-governance-vscode-copilot.md](./templates/core/docs/ADD-governance-vscode-copilot.md) | 10/
|
|
296
|
-
| Trae | [ADD-governance-trae.md](./templates/core/docs/ADD-governance-trae.md) | 6/
|
|
297
|
-
| Codex | [ADD-governance-codex.md](./templates/core/docs/ADD-governance-codex.md) |
|
|
352
|
+
| Claude Code | [ADD-governance-claude-code.md](./templates/core/docs/ADD-governance-claude-code.md) | 11/16 | `.claude/hooks/*.mjs`(settings.json command) |
|
|
353
|
+
| Qoder CN | [ADD-governance-qoder-cn.md](./templates/core/docs/ADD-governance-qoder-cn.md) | 11/16 | `.qoder/hooks/*.mjs`(settings.json command) |
|
|
354
|
+
| VS Code Copilot | [ADD-governance-vscode-copilot.md](./templates/core/docs/ADD-governance-vscode-copilot.md) | 10/16 | `.vscode/hooks/*.mjs`(Agent Host 双通道) |
|
|
355
|
+
| Trae | [ADD-governance-trae.md](./templates/core/docs/ADD-governance-trae.md) | 6/16 | `hooks.json` → `.trae/hooks/*.mjs` |
|
|
356
|
+
| Codex | [ADD-governance-codex.md](./templates/core/docs/ADD-governance-codex.md) | 5/16 | `.codex/hooks.json` → `.codex/hooks/*.mjs` |
|
|
298
357
|
|
|
299
358
|
## 快速开始
|
|
300
359
|
```bash
|
|
@@ -318,7 +377,7 @@ npx add-coder init
|
|
|
318
377
|
|---|---|
|
|
319
378
|
| `record_dev_operation` | 记录开发操作审计 |
|
|
320
379
|
| `query_audit_logs` | 按 planKeyword / targetId 查询审计记录 |
|
|
321
|
-
| `check_dps` | DPS
|
|
380
|
+
| `check_dps` | DPS 闸门(`PASS=80`,阈值以 `dps-scoring-rules.toml` 为准) |
|
|
322
381
|
| `check_rahs` | RAHS 闸门(< 90% BLOCKED) |
|
|
323
382
|
|
|
324
383
|
## 前置条件
|
|
@@ -329,7 +388,7 @@ npx add-coder init
|
|
|
329
388
|
|---|---|
|
|
330
389
|
| Demo 仓库演示 | Policy-Update-Loop 与 Report 体系端到端闭环实践 |
|
|
331
390
|
| MCP 能力重构 | MCP 工具链架构升级 |
|
|
332
|
-
| 对话记忆增强 |
|
|
391
|
+
| 对话记忆增强 | ✅ **v0.3.35 记忆闭环落地**:幂等采证 + 位点确定性召回 + FTS×向量混合召回 + Handoff Digest 候选 + 排序校准基座;默认 `shadow` 模式 |
|
|
333
392
|
|
|
334
393
|
> 📦 [更新日志](./CHANGELOG.md)
|
|
335
394
|
</details>
|
package/README.md
CHANGED
|
@@ -95,7 +95,18 @@ ADD 范式 + Qoder: cache 命中率 99.31%, 每次请求 MISS 仅 2,426 toke
|
|
|
95
95
|
|
|
96
96
|
### ④ 门禁驱动,而非自由对话
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
> **别的工具靠「再试一次」,add-coder 靠「先过闸门」。** 质量不该取决于模型当天的状态。
|
|
99
|
+
|
|
100
|
+
传统 AI coding 是「你说我做」,质量完全依赖 LLM 当下的发挥。add-coder 在架构里嵌入**双质量闸门**——不是「建议」,是**架构阻断**:不过闸门,Step 推进不了。
|
|
101
|
+
|
|
102
|
+
| 维度 | 常见做法 | add-coder 双闸门 |
|
|
103
|
+
|------|---------|------------------|
|
|
104
|
+
| **判据** | 模型自评 / 人工肉眼 | **DPS**:语义(TF-IDF/Jaccard)+ 熵(香农/Deng)+ CPM 关键路径 + 结构完整度四维复合;**RAHS**:范围保真 / 类型安全 / 审计完整 / Spec 合规 / 阶段对称五维 |
|
|
105
|
+
| **强制力** | 提示词里的「请确保…」 | 未过 DPS(`PASS=80`,阈值以 `dps-scoring-rules.toml` 为准)进不了 Step 1;未过 RAHS(≥90)不放行 |
|
|
106
|
+
| **可复现** | 每次问模型答案都不一样 | 同一文档 + 同一参数 = 同一分数;分维分值 + 弱项清单,可解释、可对比、可回归 |
|
|
107
|
+
| **调参** | 改代码、改提示词、重发版 | **caijuehub TOML 声明**:跑分 → 看弱项 → 调参 → 再跑分,改规则不改代码 |
|
|
108
|
+
| **权重** | 手调一次就固化 | **FFT 自适应权重**:随审计数据演进——DPS 参数是数据,不是魔数 |
|
|
109
|
+
| **负反馈** | 只能「再生成一遍」 | 门禁失败直接定位弱项维度;门禁结果幂等采证(Gate → `MetricSnapshot`)进入记忆闭环复盘 |
|
|
99
110
|
|
|
100
111
|
```
|
|
101
112
|
DPS (Documentation Precision Score) — TF-IDF/Jaccard 语义 + 香农/Deng 熵 + CPM 关键路径 + 结构完整度
|
|
@@ -104,29 +115,54 @@ RAHS (Runtime Architecture Health Score) — 运行时架构健康度
|
|
|
104
115
|
→ 五维判定:范围保真 + 类型安全 + 审计完整 + Spec 合规 + 阶段对称,≥ 90 通过
|
|
105
116
|
```
|
|
106
117
|
|
|
107
|
-
|
|
118
|
+
> 阈值与参数都是可读的 TOML 真源(`dps-scoring-rules.toml`),不是魔数;`check_dps` 已适配五端 spec 引用解析(qoder / claude / add / vscode / codex·trae,`tests/dps-adapter.test.ts` 覆盖)。
|
|
108
119
|
|
|
109
120
|
### ⑤ 跨轮记忆,而非每轮失忆
|
|
110
121
|
|
|
111
|
-
|
|
122
|
+
> **别的工具在「记」,add-coder 在「治理记忆」。** 记忆不是上下文工程,是治理工程。
|
|
123
|
+
|
|
124
|
+
AI 对话的致命缺陷:上次讨论的架构决策、已修复的 Bug、达成的约定,下轮对话全部遗忘。多数 AI 编码工具的「记忆」是**会话/仓库级文本摘录 + 向量检索**——把历史对话或文件切片塞回上下文,解决的是「看过」,不解决「算不算数、该不该带、带错了谁负责」。add-coder 的记忆是**受治理的知识层**:每条结论有证据、每次召回可重放、每次修订留痕迹、每次越界可抽查。
|
|
125
|
+
|
|
126
|
+
**差距在结构,不在召回率**
|
|
127
|
+
|
|
128
|
+
| 维度 | 常见「记忆」做法 | add-coder 记忆闭环(v0.3.35 起) |
|
|
129
|
+
|------|------------------|-----------------------------------|
|
|
130
|
+
| **写入** | 自动摘录,直接生效 | **候选制**:`propose_memory` 落 CANDIDATE(去重 + 密钥扫描 + 冲突检测),人工裁决 `resolve_memory` 后才 ACTIVE,approve 需 ≥1 条证据 |
|
|
131
|
+
| **依据** | 记忆文本本身即依据 | **证据链**:结论与来源分离,采证幂等(`sourceRef=<gate>:<planKeyword>:<runId>`,重放不重复入库),`get_memory` 可查 provenance 与 supersession 链 |
|
|
132
|
+
| **时机** | 相似度触发,随时可能召回 | **位点确定性召回**:命中 ADD 阶段位点(Plan 起草 / Spec 起草 / DPS / RAHS / Handoff)才触发,词表按特异性优先;Hook 侧同步产出、MCP 侧执行 |
|
|
133
|
+
| **召回** | 单通道向量相似度 | **FTS × 向量双通道 RRF 融合 + 治理重排**(scope / kind / 重要度 / 置信度 / 强约束 − stale / 冲突 / 冗余),token 预算裁剪后注入 |
|
|
134
|
+
| **可解释** | 只给结果 | 每条结果带 `whySelected` / `scoreBreakdown` / `recallId`,`rankingVersion` 记录配置快照——**同一次召回可以重放** |
|
|
135
|
+
| **降级** | 无显式契约 | 无 pgvector / sqlite-vec 环境按 FTS-only 运行并显式返回 `degradedMode`,不静默失真 |
|
|
136
|
+
| **纠错** | 只能删或覆盖 | **治理状态机**:submit_review / approve / reject / stale / supersede / archive / restore,supersede 强制 scope 兼容——记忆可以「被证伪」,不是只能被覆盖 |
|
|
137
|
+
| **越界** | 无 scope 隔离 | 八级 scope 隔离(ORGANIZATION / REPOSITORY / BRANCH / MODULE / PATH / SYMBOL / PLAN / SPEC)+ `get_memory_health` 越库泄漏抽查 |
|
|
138
|
+
| **调权** | 权重写死 | 反馈统计(通道 × 位次 × outcome)/ 冷启动拟合 / Kalman 在线估计 / FFT 节奏诊断(不直接产出排序);**权重快照即排序参数单一事实源** |
|
|
112
139
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
-
|
|
140
|
+
**两层落地**
|
|
141
|
+
|
|
142
|
+
- **文档层**(v0.3.25 起)—— Handoff 文档(每轮 Session 结束自动生成、下轮自动加载)· Plan 索引(`index.md` 集中索引 + 模糊匹配)· DevLog 时序(`{YYYY-MM}/{DD}/` 全量可回溯)
|
|
143
|
+
- **知识层**(v0.3.35 记忆闭环)—— 候选制入库 → 幂等采证(白名单工具事件 → `evidence-queue.jsonl` → 异步消费 → `MetricSnapshot`)→ 位点召回 → 混合召回 + 治理重排 → 反馈回流校准,全链条留痕
|
|
144
|
+
|
|
145
|
+
**开关**:`ADD_MEMORY_RECALL_MODE=off|shadow|inject`(默认 `shadow`:召回照跑照审计、暂不注入上下文)· `ADD_MEMORY_MAX_TOKENS`(默认 600)· `ADD_MEMORY_EVIDENCE`(默认 `on`)。
|
|
146
|
+
|
|
147
|
+
> 如实登记:Hybrid `MRR@5` 实测 0.4867 < 0.75 门槛(FTS-only 0.6551、Recall@5 0.9592)——**门槛不下调**,由排序校准线程以数据校准替代手调:记忆能力可跑、可查、可裁决,不靠指标注水。
|
|
148
|
+
> 真源落点、表结构、开发流程见 [DEVELOPMENT.md](./DEVELOPMENT.md) §十七。
|
|
116
149
|
|
|
117
150
|
### ⑥ Policy-Update-Loop:治理自我进化
|
|
118
151
|
|
|
119
|
-
|
|
152
|
+
> **静态模板会腐化,闭环治理会进化。** 规则不是写死的常量,是能被审计数据推动的参数。
|
|
120
153
|
|
|
121
154
|
```
|
|
122
155
|
执行 → 审计 → 边界报告 → 规则调整 → 下一轮执行
|
|
123
156
|
```
|
|
124
157
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
158
|
+
| 维度 | 静态规则 / 模板 | add-coder Policy-Update-Loop |
|
|
159
|
+
|------|----------------|------------------------------|
|
|
160
|
+
| **规则载体** | 写死在代码与提示词里,改动要发版 | caijuehub TOML 声明式:规则真源 → 生成常量 → 产物内联,**改规则不改代码** |
|
|
161
|
+
| **规则来源** | 拍脑袋定阈值 | 审计数据反哺:DPS 四维 **FFT 自适应权重**随历史调权;`check_doc_similarity` 量化复检形似义异文档 |
|
|
162
|
+
| **反馈回路** | 无 | **执行 → 审计(✓ 已接入)**:hook 拦截 / 文件写入事件 → jsonl → MCP 常驻消费 → DevOperation 落库(`HOOK_INTERCEPT` 幂等去重) |
|
|
163
|
+
| **一致性** | 各端各自实现,行为漂移 | 治理契约层单一实现 + 五端一致性矩阵逐项断言(危险命令拦截 / 敏感文件锚定 / 审计事件面 / 协议形态 / 治理零复制) |
|
|
164
|
+
| **演进证据** | 无留痕 | 每次拦截、每次判分、每次裁决都进审计库——可回查、可统计、可复算 |
|
|
165
|
+
| **尚未闭环** | — | 边界报告(Runtime Report)端到端实践待 [DEMO 仓库](#-预告)演示(如实登记) |
|
|
130
166
|
|
|
131
167
|
### ⑦ 多 IDE 的 Hook 即治理层
|
|
132
168
|
|
|
@@ -185,7 +221,16 @@ tasks.md §IDE JSON → TodoWrite → IDE 面板
|
|
|
185
221
|
|
|
186
222
|
### ⑪ Codex MCP 原生接入(v0.3.25)
|
|
187
223
|
|
|
188
|
-
>
|
|
224
|
+
> **不是给 Codex 外挂一个 MCP,而是把治理原生落进去。** 「已生成模板」≠「端到端已验证」——以下是**实测打通的 6 步**。
|
|
225
|
+
|
|
226
|
+
| 维度 | 常见接入方式 | add-coder × Codex |
|
|
227
|
+
|------|-------------|-------------------|
|
|
228
|
+
| **接入成本** | 手写启动脚本、自己包装 | 三步 CLI:`init --adapter=codex` → `--print-mcp-config`(不写盘、不初始化项目)→ 粘贴或 `--write-user-config`(先备份 + 防重复) |
|
|
229
|
+
| **治理面** | 只有工具调用,没有生命周期治理 | **原生 hooks**:`.codex/hooks.json` → `.codex/hooks/*.mjs`(14 个入口产物随包预烘焙、`node` 直调;Codex 原生事件可注册 5/16,其余产物已占位,事件扩展后零代码启用) |
|
|
230
|
+
| **审批** | 只能在聊天里问一句 | **HITL 原生**:`create_hitl` 走 MCP Apps 分流(不在 Codex 展开高维 `inputRequired`),面板不可用时回退 markdown 提案 + 实例 HTML,结论照常落库 / 落文档 |
|
|
231
|
+
| **运行态** | 改完产物,不知道跑的是不是新码 | **产物-进程新鲜度四态** + 重启标记 `.mcp-restart-required`:`sync` 后点名告警该重启哪个 server |
|
|
232
|
+
| **多项目** | 配置粘错就连错库且无感 | `env.PROJECT_ROOT` 渲染时注入;错配时 mcp-server 启动即校验退出(进程层契约 §4) |
|
|
233
|
+
| **平台** | 依赖 WSL / 手工改路径 | win32 自动输出 `cmd /c npx.cmd` 原生分支(PowerShell 场景不再绕 WSL) |
|
|
189
234
|
|
|
190
235
|
```bash
|
|
191
236
|
# 1. 安装 add-coder(已安装可跳过)
|
|
@@ -206,9 +251,9 @@ add-coder init --adapter=codex --write-user-config
|
|
|
206
251
|
# 6. 验证:Codex 中发现 add_coder MCP Server,完整工具集可调用(29 tools)
|
|
207
252
|
```
|
|
208
253
|
|
|
209
|
-
|
|
254
|
+
**命名兼容**:MCP Server ID 归一化为 `add_coder`(连字符→下划线,Codex 约束)。
|
|
210
255
|
|
|
211
|
-
|
|
256
|
+
> 如实登记:Codex 部分 build(实测 `26.908`)不渲染审批 widget,此时审批走 markdown 提案 + 实例 HTML + 聊天拍板——链路可用,结论照常落库 / 落文档。
|
|
212
257
|
|
|
213
258
|
---
|
|
214
259
|
|
|
@@ -436,7 +481,7 @@ Tasks (实验性) 双向 ✅ 已实现 长任务持久化
|
|
|
436
481
|
> **推荐**:使用 Podman/Docker 运行 PostgreSQL,参考配置:
|
|
437
482
|
> ```yaml
|
|
438
483
|
> postgres:
|
|
439
|
-
> image: docker.io/
|
|
484
|
+
> image: docker.io/pgvector/pgvector:pg16
|
|
440
485
|
> ports: ["127.0.0.1:5433:5432"]
|
|
441
486
|
> environment:
|
|
442
487
|
> POSTGRES_DB: <your-db>
|
|
@@ -457,7 +502,7 @@ Tasks (实验性) 双向 ✅ 已实现 长任务持久化
|
|
|
457
502
|
| MCP 能力重构 | ✅ v0.2.9 MCP 工具链架构升级,提升审计与门禁工具的可扩展性和独立部署能力 | 2026-07/23/add-coder-mcp-restructure-plan-v1.md |
|
|
458
503
|
| Hook 通知升级 | ✅ v0.2.9 Hook 拦截事件 jsonl → fs.watch → record_dev_operation 落库 + Notification + 治理信号 | 2026-07/24/add-coder-hook-notify-upgrade-plan-v1.md |
|
|
459
504
|
| ide插件 | 解耦ADD范式代码和被治理项目的代码 |在做了,大家拭目以待吧,让编程更有趣,我的目标其实不在于IDE,我的工作顺手的事情 |
|
|
460
|
-
| 对话记忆增强 |
|
|
505
|
+
| 对话记忆增强 | ✅ **v0.3.35 记忆闭环落地**:幂等采证 + 位点确定性召回 + FTS×向量混合召回(RRF 融合 + 治理重排)+ Handoff Digest 候选 + 排序权重校准基座;默认 `shadow` 模式(召回照跑照审计、暂不注入) | 门槛未下调:Hybrid MRR@5 0.4867 < 0.75,由校准线程以数据逼近 |
|
|
461
506
|
|
|
462
507
|
---
|
|
463
508
|
|
|
@@ -905,7 +950,7 @@ npx add-coder stack --clear # clear tech-stack setting (neutral)
|
|
|
905
950
|
> **Recommended**: Run PostgreSQL via Podman/Docker, reference config:
|
|
906
951
|
> ```yaml
|
|
907
952
|
> postgres:
|
|
908
|
-
> image: docker.io/
|
|
953
|
+
> image: docker.io/pgvector/pgvector:pg16
|
|
909
954
|
> ports: ["127.0.0.1:5433:5432"]
|
|
910
955
|
> environment:
|
|
911
956
|
> POSTGRES_DB: mydb
|
package/dist/index.js
CHANGED
|
@@ -1119,7 +1119,7 @@ async function ensureSplitDb(projectRoot, opts) {
|
|
|
1119
1119
|
`POSTGRES_DB=${dbName}`,
|
|
1120
1120
|
"-p",
|
|
1121
1121
|
`127.0.0.1:${port}:5432`,
|
|
1122
|
-
"docker.io/
|
|
1122
|
+
"docker.io/pgvector/pgvector:pg16"
|
|
1123
1123
|
], { timeout: 6e4 });
|
|
1124
1124
|
if (r.status !== 0) {
|
|
1125
1125
|
throw new Error(`\u72EC\u7ACB ADD \u5E93\u5BB9\u5668\u542F\u52A8\u5931\u8D25\uFF08\u9000\u51FA\u7801 ${r.status}\uFF09: ${r.stderr.trim().slice(0, 200)}`);
|
|
@@ -1183,7 +1183,7 @@ async function provisionDevUrl(projectRoot) {
|
|
|
1183
1183
|
"POSTGRES_DB=dev",
|
|
1184
1184
|
"-p",
|
|
1185
1185
|
`127.0.0.1:${port}:5432`,
|
|
1186
|
-
"docker.io/
|
|
1186
|
+
"docker.io/pgvector/pgvector:pg16"
|
|
1187
1187
|
], { timeout: 6e4 });
|
|
1188
1188
|
if (r.status !== 0) return null;
|
|
1189
1189
|
const url = `postgresql://postgres:postgres@127.0.0.1:${port}/dev?schema=public`;
|
|
@@ -1810,7 +1810,7 @@ async function resolveDbCredentials(force) {
|
|
|
1810
1810
|
function composeContent(projectName) {
|
|
1811
1811
|
return `services:
|
|
1812
1812
|
postgres:
|
|
1813
|
-
image: docker.io/
|
|
1813
|
+
image: docker.io/pgvector/pgvector:pg16
|
|
1814
1814
|
container_name: \${PROJECT_NAME:-${projectName}}-postgres
|
|
1815
1815
|
restart: unless-stopped
|
|
1816
1816
|
ports:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "add-coder",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.37",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "[codein2027](https://github.com/xiaomingming92/codein2027) - A complete scaffolding for building the ADD programming paradigm, the implementation layer for AI code governance. Core principle: Audit as Infrastructure. Breaks the black-box programming process and cross-session amnesia, evolving programming paradigms into an auditable, traceable, and convergent new era. npx-ready.\n\n[codein2027](https://github.com/xiaomingming92/codein2027) 快速构建 ADD 编程范式的完整脚手架——AI 代码治理的落地方案。以「审计即基础设施」为核心,彻底打破编程过程黑盒与跨轮失忆,让编程范式进化为可审计、可追溯、可收敛的新时代。npx 即用,人人可体验。",
|
|
6
6
|
"repository": {
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"@prisma/client": "^7.0.0",
|
|
54
54
|
"dotenv": "*",
|
|
55
55
|
"find-up": "^8.0.0",
|
|
56
|
-
"prisma": "^7.0.0",
|
|
57
56
|
"pg": "^8.16.0",
|
|
57
|
+
"prisma": "^7.0.0",
|
|
58
58
|
"tsx": ">=4",
|
|
59
59
|
"vector-cosine-similarity": "^1.8.0"
|
|
60
60
|
},
|