add-coder 0.2.0 → 0.2.2
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 +95 -7
- package/README.md +245 -9
- package/package.json +2 -2
- package/templates/adapters/claude/hooks/doc-format-guard.sh +1 -1
- package/templates/adapters/qoder/hooks/doc-format-guard.sh +1 -1
- package/templates/core/hooks/doc-format-guard.sh +1 -1
- package/templates/core/hooks/lib/context-inject.sh +96 -0
- package/templates/core/hooks/lib/state-detect.sh +104 -0
- package/templates/core/hooks/lib/vocabulary.sh +49 -0
- package/templates/core/hooks/pre-tool-use.sh +112 -59
- package/templates/core/hooks/prompt-submit.sh +32 -35
- package/templates/core/scripts/gen-plan-index.sh +84 -0
- package/templates/core/templates/simple-plan-template.schema.json +5 -5
- package/templates/core/templates/spec-template.schema.json +0 -1
- package/templates/core/templates/standard-plan-template.schema.json +3 -4
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
|
|
|
@@ -181,12 +181,13 @@ npx add-coder init
|
|
|
181
181
|
│ Handoff / DevLog Timeline Docs │
|
|
182
182
|
└─────────────────────────────────────┘
|
|
183
183
|
│
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
+
└──────┘ └──────┘ └──────────┘ └──────┘ └──────┘
|
|
190
191
|
│
|
|
191
192
|
┌────────────┘
|
|
192
193
|
▼
|
|
@@ -226,3 +227,90 @@ npx add-coder init
|
|
|
226
227
|
|------|-------------|
|
|
227
228
|
| Demo Repo | A full example repository showcasing end-to-end closed-loop practice of Policy-Update-Loop and the Report system |
|
|
228
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
|
|
|
@@ -172,15 +172,16 @@ npx add-coder init
|
|
|
172
172
|
│ Handoff / DevLog 时序文档 │
|
|
173
173
|
└─────────────────────────────────────┘
|
|
174
174
|
│
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
+
└──────┘ └──────┘ └──────────┘ └──────┘ └──────┘
|
|
181
182
|
│
|
|
182
|
-
|
|
183
|
-
|
|
183
|
+
|
|
|
184
|
+
▼
|
|
184
185
|
┌─────────────────────────────────────┐
|
|
185
186
|
│ Caijuehub 规则引擎 │
|
|
186
187
|
│ TOML 驱动的策略体系 │
|
|
@@ -216,3 +217,238 @@ npx add-coder init
|
|
|
216
217
|
|------|------|
|
|
217
218
|
| Demo 仓库演示 | 提供完整示例仓库,展示 Policy-Update-Loop 与 Report 体系的端到端闭环实践 |
|
|
218
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
|
+
---
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "add-coder",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "[codein2027](https://github.com/xiaomingming92/codein2027) 快速构建 ADD 编程范式的完整脚手架——AI 代码治理的落地方案。以「审计即基础设施」为核心,彻底打破编程过程黑盒与跨轮失忆,让编程范式进化为可审计、可追溯、可收敛的新时代。npx 即用,人人可体验。",
|
|
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": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/xiaomingming92/add-coder.git"
|
|
@@ -104,7 +104,7 @@ if [ -z "$TEMPLATE_NAME" ]; then
|
|
|
104
104
|
fi
|
|
105
105
|
fi
|
|
106
106
|
|
|
107
|
-
SCHEMA_FILE="$TEMPLATES_DIR/$
|
|
107
|
+
SCHEMA_FILE="$TEMPLATES_DIR/${TEMPLATE_NAME%.md}.schema.json"
|
|
108
108
|
# L84: schema 文件不存在 → 无校验规则,阻断(不允许无规则放行)
|
|
109
109
|
if [ ! -f "$SCHEMA_FILE" ]; then
|
|
110
110
|
echo "⛔ 阻断:模板 ${TEMPLATE_NAME} 缺少对应的 .schema.json 校验规则" >&2
|
|
@@ -104,7 +104,7 @@ if [ -z "$TEMPLATE_NAME" ]; then
|
|
|
104
104
|
fi
|
|
105
105
|
fi
|
|
106
106
|
|
|
107
|
-
SCHEMA_FILE="$TEMPLATES_DIR/$
|
|
107
|
+
SCHEMA_FILE="$TEMPLATES_DIR/${TEMPLATE_NAME%.md}.schema.json"
|
|
108
108
|
# L84: schema 文件不存在 → 无校验规则,阻断(不允许无规则放行)
|
|
109
109
|
if [ ! -f "$SCHEMA_FILE" ]; then
|
|
110
110
|
echo "⛔ 阻断:模板 ${TEMPLATE_NAME} 缺少对应的 .schema.json 校验规则" >&2
|
|
@@ -104,7 +104,7 @@ if [ -z "$TEMPLATE_NAME" ]; then
|
|
|
104
104
|
fi
|
|
105
105
|
fi
|
|
106
106
|
|
|
107
|
-
SCHEMA_FILE="$TEMPLATES_DIR/$
|
|
107
|
+
SCHEMA_FILE="$TEMPLATES_DIR/${TEMPLATE_NAME%.md}.schema.json"
|
|
108
108
|
# L84: schema 文件不存在 → 无校验规则,阻断(不允许无规则放行)
|
|
109
109
|
if [ ! -f "$SCHEMA_FILE" ]; then
|
|
110
110
|
echo "⛔ 阻断:模板 ${TEMPLATE_NAME} 缺少对应的 .schema.json 校验规则" >&2
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# context-inject.sh — 上下文注入模板
|
|
3
|
+
# 共享库
|
|
4
|
+
|
|
5
|
+
# 结构化 SessionStart JSON 注入
|
|
6
|
+
build_session_start_json() {
|
|
7
|
+
local plan="$1" step="$2" round="$3" handoff="$4"
|
|
8
|
+
cat <<EOF
|
|
9
|
+
{
|
|
10
|
+
"continue": true,
|
|
11
|
+
"hookSpecificOutput": {
|
|
12
|
+
"hookEventName": "SessionStart",
|
|
13
|
+
"additionalContext": "上次 ADD 流程未完成:\n Plan: ${plan}\n 轮次: ${round}\n 当前 Step: ${step} (add-route)\n 恢复命令: query_audit_logs({ planKeyword: '${plan}' })\n handoff: ${handoff}"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
EOF
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
# Stop 四象限分流 few-shot 上下文
|
|
20
|
+
build_stop_context() {
|
|
21
|
+
local quadrant="$1" info="$2"
|
|
22
|
+
case "$quadrant" in
|
|
23
|
+
"no_add_no_dev")
|
|
24
|
+
echo "[ADD Stop] 无活跃 Plan,无代码改动。正常结束。"
|
|
25
|
+
;;
|
|
26
|
+
"no_add_has_dev")
|
|
27
|
+
cat <<'EOF'
|
|
28
|
+
[ADD Stop] ⚠️ 检测到代码修改但无活跃 ADD Plan。
|
|
29
|
+
|
|
30
|
+
Plan 不是"文档开销"——它是代码治理的基础设斻。跳过 Plan 的后果:
|
|
31
|
+
· 没有 add-route → 每次改动无法追溯到具体 Task
|
|
32
|
+
· 没有 tasks.md → 后续 AI Session 不知道改了哪些文件
|
|
33
|
+
· 没有 handoff → 交接时上下文全丢,只能靠 git log 猜
|
|
34
|
+
|
|
35
|
+
你必须立即补救,二选一:
|
|
36
|
+
|
|
37
|
+
方案 A — 补 ADD 流程(招安):
|
|
38
|
+
Step 0: 读 .qoder/templates/plan-template.md → 生成 Plan → .qoder/plans/{today}/{keyword}-plan-v1.md
|
|
39
|
+
生成 add-route → check_dps ≥ 85
|
|
40
|
+
Step 1: 扩展 AgentAuditPhase(如需要)
|
|
41
|
+
Step 2: 确认 agentAudit() 通道
|
|
42
|
+
Step 3: 将已写代码关联到 tasks.md
|
|
43
|
+
完成后可正常停止。
|
|
44
|
+
|
|
45
|
+
方案 B — 补不上则回滚:
|
|
46
|
+
如果改动太复杂无法追溯生成 Plan,则:
|
|
47
|
+
① git diff 确认改动范围
|
|
48
|
+
② git checkout -- <改动的文件> 撤回
|
|
49
|
+
③ 告知用户 "以下改动已回滚,请先走 ADD 流程再重新实施: <文件列表>"
|
|
50
|
+
|
|
51
|
+
无论选 A 还是 B,完成后告诉用户下次执行 session-init 恢复上下文。
|
|
52
|
+
EOF
|
|
53
|
+
;;
|
|
54
|
+
"has_add_no_dev")
|
|
55
|
+
echo "[ADD Stop] ADD 流程进行中 (${info}),本次无代码改动。下次继续时执行 session-init 恢复上下文。"
|
|
56
|
+
;;
|
|
57
|
+
"has_add_dev_step02")
|
|
58
|
+
echo "[ADD Stop] ADD Step 0-2: 文档先行/审计准备阶段。无需验收闭环。下一步: 进入 Step 3 代码实现。"
|
|
59
|
+
;;
|
|
60
|
+
"has_add_dev_step3")
|
|
61
|
+
echo "[ADD Stop] ADD Step 3: 代码实现进行中 (${info})。完成后进入 Step 3.5 实现审查。"
|
|
62
|
+
;;
|
|
63
|
+
"has_add_dev_unclosed")
|
|
64
|
+
cat <<'EOF'
|
|
65
|
+
[ADD Stop] ⚠️ 代码已完成但验收未闭环:
|
|
66
|
+
${info}
|
|
67
|
+
|
|
68
|
+
请依次执行(不要等下次会话):
|
|
69
|
+
① Write devlog → handoff 同目录 devlog-{plan}-v{n}.md
|
|
70
|
+
格式: # Devlog: {plan}\n 日期 / Plan / 轮次 / 本轮改了什么 / 验收结果 / 遗留项 / 架构回看
|
|
71
|
+
② Edit handoff → 更新 §验证标准 全部 [x] + 补充审计 ID
|
|
72
|
+
★ 同步: checklist 有新 cuid → handoff ADD-7 表必须对应新增行
|
|
73
|
+
★ Step 0 准入: handoff + add-route + Specs 三元组缺一不可,缺则回退 Step 0.5
|
|
74
|
+
③ Read docs/ → 回看架构文档确认一致性
|
|
75
|
+
④ Edit add-route → 勾选对应 Step [x]
|
|
76
|
+
|
|
77
|
+
以上全部完成后 Agent 才能停止。
|
|
78
|
+
|
|
79
|
+
下次恢复: 读 handoff → 查同目录 devlog-*.md → query_audit_logs
|
|
80
|
+
EOF
|
|
81
|
+
;;
|
|
82
|
+
"has_add_dev_closed")
|
|
83
|
+
echo "[ADD Stop] ✅ 验收闭环: add-route全部[x], devlog已记录, handoff已更新。验收幂等——重复触发不覆盖已有结论。"
|
|
84
|
+
;;
|
|
85
|
+
esac
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
# 写操作前置守卫上下文
|
|
89
|
+
build_pretool_context() {
|
|
90
|
+
local plan="$1" round="$2"
|
|
91
|
+
cat <<EOF
|
|
92
|
+
[ADD PreToolUse] 当前 Plan: ${plan},轮次: ${round}。
|
|
93
|
+
本次写入应属于 ADD Step 3 代码实现阶段。
|
|
94
|
+
完成后执行 record_dev_operation 记录审计。
|
|
95
|
+
EOF
|
|
96
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# state-detect.sh — ADD 活跃流程检测 + dev action 追踪
|
|
3
|
+
# 共享库
|
|
4
|
+
|
|
5
|
+
PROJECT_DIR="${QODER_PROJECT_DIR:-${QODERCN_PROJECT_DIR:-$PWD}}"
|
|
6
|
+
QODER_DIR="$PROJECT_DIR/.qoder"
|
|
7
|
+
PLANS_DIR="$QODER_DIR/plans"
|
|
8
|
+
|
|
9
|
+
# dev action 标记文件(项目级,PreToolUse 写入,Stop 读取)
|
|
10
|
+
DEV_FLAG="/tmp/qoder_dev_$(echo "$PROJECT_DIR" | md5sum 2>/dev/null | cut -c1-8 || echo "default")"
|
|
11
|
+
|
|
12
|
+
# 检测活跃 ADD 流程
|
|
13
|
+
# 返回: "plan_keyword::step_x/total::round_n/total_r::handoff_path::add_route_path" 或 ""
|
|
14
|
+
detect_active_add() {
|
|
15
|
+
local handoff=""
|
|
16
|
+
local today_dir="$PLANS_DIR/$(date +%Y-%m)"
|
|
17
|
+
[ -d "$today_dir" ] && handoff=$(find "$today_dir" -name "*handoff*.md" -mtime -7 -type f 2>/dev/null | head -1)
|
|
18
|
+
[ -z "$handoff" ] && handoff=$(find "$PLANS_DIR" -name "*handoff*.md" -mtime -7 -type f 2>/dev/null | head -1)
|
|
19
|
+
[ -z "$handoff" ] && return 1
|
|
20
|
+
|
|
21
|
+
local plan_kw=$(basename "$handoff" | sed 's/-handoff.*//')
|
|
22
|
+
|
|
23
|
+
# add-route
|
|
24
|
+
local add_route=$(find "$PLANS_DIR" -name "*add-route*.md" -type f 2>/dev/null | head -1)
|
|
25
|
+
|
|
26
|
+
# Step 统计(从 add-route)
|
|
27
|
+
local step_info="?"
|
|
28
|
+
if [ -f "$add_route" ]; then
|
|
29
|
+
local ck=$(grep -c '\[x\]' "$add_route" 2>/dev/null || true)
|
|
30
|
+
local uc=$(grep -c '\[ \]' "$add_route" 2>/dev/null || true)
|
|
31
|
+
ck=${ck:-0}; uc=${uc:-0}
|
|
32
|
+
local total=$((ck + uc))
|
|
33
|
+
[ "$total" -gt 0 ] && step_info="${ck}/${total}"
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
# 轮次统计(从 handoff)
|
|
37
|
+
local round_info="?"
|
|
38
|
+
if grep -q '<第[0-9]轮>' "$handoff" 2>/dev/null; then
|
|
39
|
+
local ck=$(grep -c '\[x\]' "$handoff" 2>/dev/null || true); ck=${ck:-0}
|
|
40
|
+
local total=$(grep -c '<第[0-9]轮>' "$handoff" 2>/dev/null || true); total=${total:-0}
|
|
41
|
+
[ "$total" -gt 0 ] && round_info="${ck}/${total}"
|
|
42
|
+
else
|
|
43
|
+
round_info="1/1"
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
echo "${plan_kw}::${step_info}::${round_info}::${handoff}::${add_route:-none}"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# 标记 dev action
|
|
50
|
+
mark_dev_action() {
|
|
51
|
+
touch "$DEV_FLAG" 2>/dev/null || true
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# 检测 dev action
|
|
55
|
+
has_dev_action() {
|
|
56
|
+
[ -f "$DEV_FLAG" ]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# 清理 dev action 标记(验收闭环后调用)
|
|
60
|
+
clear_dev_action() {
|
|
61
|
+
rm -f "$DEV_FLAG" 2>/dev/null || true
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
# 检查验收完整度,返回 issues 文本
|
|
65
|
+
check_add_completeness() {
|
|
66
|
+
local handoff="$1" add_route="$2"
|
|
67
|
+
local issues=""
|
|
68
|
+
|
|
69
|
+
# devlog(内容已回流至 handoff,检查 handoff 是否含验收结果)
|
|
70
|
+
if [ -f "$handoff" ] && ! grep -qE '验收|收敛|闭环|本轮改了什么|devlog' "$handoff" 2>/dev/null; then
|
|
71
|
+
issues="${issues} [ ] devlog 缺失(handoff 无验收记录)\n"
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
# handoff 验证标准
|
|
75
|
+
if [ -f "$handoff" ]; then
|
|
76
|
+
local uc=$(grep -c '\[ \]' "$handoff" 2>/dev/null || echo "0")
|
|
77
|
+
[ "$uc" -gt 0 ] && issues="${issues} [ ] handoff ${uc} 项未勾选\n"
|
|
78
|
+
fi
|
|
79
|
+
|
|
80
|
+
# add-route Step
|
|
81
|
+
if [ -f "$add_route" ]; then
|
|
82
|
+
local uc=$(grep -c '\[ \]' "$add_route" 2>/dev/null || echo "0")
|
|
83
|
+
[ "$uc" -gt 0 ] && issues="${issues} [ ] add-route ${uc} Step 未闭环\n"
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
echo -e "$issues"
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
# 检查是否已验收(幂等保护)
|
|
90
|
+
# 返回 0 = 未验收,1 = 已验收
|
|
91
|
+
is_already_accepted() {
|
|
92
|
+
local add_route="$1" handoff="$2"
|
|
93
|
+
# add-route Step 8 是否已 [x]
|
|
94
|
+
if [ -f "$add_route" ]; then
|
|
95
|
+
# 检查 Step 8 产出项是否勾选
|
|
96
|
+
if grep -A 10 'Step 8' "$add_route" 2>/dev/null | grep -q '\[x\].*验证并更新项目状态'; then
|
|
97
|
+
# handoff 是否有验收记录
|
|
98
|
+
if [ -f "$handoff" ] && grep -qE '✅.*验收|收敛|全部闭环|全部.*完成' "$handoff" 2>/dev/null; then
|
|
99
|
+
return 0
|
|
100
|
+
fi
|
|
101
|
+
fi
|
|
102
|
+
fi
|
|
103
|
+
return 1
|
|
104
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# vocabulary.sh — 从 vocabulary markdown 表格加载触发词
|
|
3
|
+
# 单一数据源: .qoder/vocabulary/add-governance-vocabulary.md §类别 A-F 表格
|
|
4
|
+
|
|
5
|
+
VOCABULARY_FILE="$PWD/.qoder/vocabulary/add-governance-vocabulary.md"
|
|
6
|
+
|
|
7
|
+
# 输出格式: 优先级::触发词正则::响应文本(:: 避免与触发词内的 | 冲突)
|
|
8
|
+
load_triggers() {
|
|
9
|
+
[ ! -f "$VOCABULARY_FILE" ] && return 1
|
|
10
|
+
sed -n '/^## 类别 A: 文档类型/,/^## 类别 [G-Z]/p' "$VOCABULARY_FILE" \
|
|
11
|
+
| grep -E '^\| (P0|P1|P2) ' \
|
|
12
|
+
| while IFS='|' read -r _ prio raw_trigger action; do
|
|
13
|
+
prio=$(echo "$prio" | xargs)
|
|
14
|
+
trigger=$(echo "$raw_trigger" | sed 's/`//g;s/ *\/ */|/g;s/^ *//;s/ *$//')
|
|
15
|
+
action=$(echo "$action" | xargs)
|
|
16
|
+
[ -z "$trigger" ] && continue
|
|
17
|
+
echo "${prio}::${trigger}::${action}"
|
|
18
|
+
done || true
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
match_trigger() {
|
|
22
|
+
local prompt="$1"
|
|
23
|
+
while IFS= read -r line; do
|
|
24
|
+
[ -z "$line" ] && continue
|
|
25
|
+
local prio="${line%%::*}"
|
|
26
|
+
local rest="${line#*::}"
|
|
27
|
+
local regex="${rest%%::*}"
|
|
28
|
+
local action="${rest#*::}"
|
|
29
|
+
# 跳过开发关键词检测行(由 Layer 2/3 分流处理,特征:超长regex含"修bug")
|
|
30
|
+
if echo "$regex" | grep -qE '修\.\?bug|fix\.\?bug' 2>/dev/null; then
|
|
31
|
+
continue
|
|
32
|
+
fi
|
|
33
|
+
if echo "$prompt" | grep -qiE "$regex" 2>/dev/null; then
|
|
34
|
+
echo "[ADD 触发] ${regex} → ${action}"
|
|
35
|
+
fi
|
|
36
|
+
done < <(load_triggers 2>/dev/null)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
load_dev_keywords() {
|
|
40
|
+
load_triggers 2>/dev/null | while IFS= read -r line; do
|
|
41
|
+
[ -z "$line" ] && continue
|
|
42
|
+
# 只取包含"开发|改功能"的开发关键词检测行
|
|
43
|
+
if echo "$line" | grep -q '开发|改功能' 2>/dev/null; then
|
|
44
|
+
local rest="${line#*::}"
|
|
45
|
+
local regex="${rest%%::*}"
|
|
46
|
+
echo "$regex"
|
|
47
|
+
fi
|
|
48
|
+
done || true
|
|
49
|
+
}
|
|
@@ -1,78 +1,131 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
# pre-tool-use.sh —
|
|
2
|
+
# pre-tool-use.sh — PreToolUse §A§B(阻断模式,通用适配版)
|
|
3
|
+
# §A: Bash 裸写保护 — 拦截所有绕过 IDE 追踪的文件写操作
|
|
4
|
+
# §B: 源码 Plan 关联检查 — 无 Plan 的 src/**/*.ts 编辑阻断
|
|
3
5
|
# 治理卡位 #4: 危险命令拦截 / 模板路径兜底 / 写入前置守卫 / 敏感文件保护
|
|
4
6
|
set -euo pipefail
|
|
5
7
|
|
|
8
|
+
input=$(cat)
|
|
9
|
+
|
|
10
|
+
# 探测 MAGIC_DIR 和 PROJECT_DIR(兼容多种 adapter)
|
|
6
11
|
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
PARENT="$(dirname "$HOOK_DIR")"
|
|
13
|
+
MAGIC_DIR="$(basename "$PARENT")"
|
|
14
|
+
PROJECT_DIR="${CLAUDE_PROJECT_DIR:-${QODER_PROJECT_DIR:-${QODERCN_PROJECT_DIR:-$(dirname "$PARENT")}}}"
|
|
15
|
+
|
|
16
|
+
# ── §A 辅助函数: 阻断日志 ──
|
|
17
|
+
_log_block() {
|
|
18
|
+
local rule="$1" cmd="$2"
|
|
19
|
+
mkdir -p "$PROJECT_DIR/$MAGIC_DIR/debug-dump"
|
|
20
|
+
cat >> "$PROJECT_DIR/$MAGIC_DIR/debug-dump/stdin.log" <<BLOCKLOG
|
|
21
|
+
=== $(date) [BLOCKED by §A: ${rule}] ===
|
|
22
|
+
command: ${cmd:0:300}
|
|
23
|
+
=== DONE ===
|
|
24
|
+
BLOCKLOG
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# ═══════════════ §A: Bash 工具写入保护 ═══════════════
|
|
28
|
+
# 任何通过 Bash 修改文件内容的操作都会绕过 IDE 工具层(Write/SearchReplace),
|
|
29
|
+
# 导致 Plan 关联检查、doc-format-guard、审计追踪全部失效。
|
|
30
|
+
# 因此全局阻断所有可写文件的 Bash 命令,强制走 IDE 工具通道。
|
|
31
|
+
command=$(echo "$input" | jq -r '.tool_input.command // empty')
|
|
32
|
+
if [ -n "$command" ]; then
|
|
33
|
+
|
|
34
|
+
# 检测 1: 脚本解释器 — 可写任意文件,无法解析脚本内容做细粒度拦截
|
|
35
|
+
if echo "$command" | grep -qE '^\s*(python3?|node|ruby|perl|php)(\s|$)'; then
|
|
36
|
+
_reason="禁止通过脚本解释器直接修改文件。请使用 Write 或 SearchReplace 工具操作文件。"
|
|
37
|
+
cat >&2 <<'EOF'
|
|
38
|
+
⛔ [ADD PreToolUse §A] 阻断: 禁止通过脚本解释器直接修改文件。
|
|
39
|
+
|
|
40
|
+
python/node/ruby/perl/php 可在脚本中写入任意文件,绕过:
|
|
41
|
+
· Plan 关联检查(哪个文件属于哪个 ADD Plan?)
|
|
42
|
+
· doc-format-guard(章节/占位符/禁止词校验)
|
|
43
|
+
· 审计追踪(agentAudit 无法感知 Bash 内部的文件变更)
|
|
44
|
+
|
|
45
|
+
→ 请改用 Write 或 SearchReplace 工具操作文件。
|
|
46
|
+
→ 如需运行构建/测试脚本,使用 npx/pnpm/npm 命令。
|
|
47
|
+
EOF
|
|
48
|
+
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"ask\",\"permissionDecisionReason\":\"${_reason}\"}}"
|
|
49
|
+
_log_block "脚本解释器" "$command"
|
|
50
|
+
exit 2
|
|
29
51
|
fi
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
52
|
+
|
|
53
|
+
# 检测 2: sed -i 原地编辑
|
|
54
|
+
if echo "$command" | grep -qE '\bsed\b.*-i'; then
|
|
55
|
+
_reason="禁止通过 sed -i 直接编辑文件。请使用 SearchReplace 工具。"
|
|
56
|
+
cat >&2 <<'EOF'
|
|
57
|
+
⛔ [ADD PreToolUse §A] 阻断: 禁止通过 sed -i 原地编辑文件。
|
|
58
|
+
|
|
59
|
+
sed -i 直接写入文件,绕过 IDE 工具层的所有校验。
|
|
60
|
+
→ 请改用 SearchReplace 工具。
|
|
61
|
+
EOF
|
|
62
|
+
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"ask\",\"permissionDecisionReason\":\"${_reason}\"}}"
|
|
63
|
+
_log_block "sed -i" "$command"
|
|
64
|
+
exit 2
|
|
34
65
|
fi
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
66
|
+
|
|
67
|
+
# 检测 3: 输出重定向 (>/>>) 写入文件
|
|
68
|
+
if echo "$command" | grep -qE '[>]{1,2}\s+\S'; then
|
|
69
|
+
_reason="禁止通过重定向写入文件。请使用 Write 工具。"
|
|
70
|
+
cat >&2 <<'EOF'
|
|
71
|
+
⛔ [ADD PreToolUse §A] 阻断: 禁止通过重定向(>/>>)写入文件。
|
|
72
|
+
|
|
73
|
+
重定向写入绕过 IDE 工具层,变更无法追踪。
|
|
74
|
+
→ 请改用 Write 工具。
|
|
75
|
+
EOF
|
|
76
|
+
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"ask\",\"permissionDecisionReason\":\"${_reason}\"}}"
|
|
77
|
+
_log_block "重定向" "$command"
|
|
78
|
+
exit 2
|
|
39
79
|
fi
|
|
40
|
-
mark_dev_action
|
|
41
|
-
exit 0
|
|
42
|
-
fi
|
|
43
80
|
|
|
44
|
-
#
|
|
45
|
-
if
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
fi
|
|
56
|
-
fi
|
|
81
|
+
# 检测 4: tee / dd 写入
|
|
82
|
+
if echo "$command" | grep -qE '\btee\b|\bdd\b.*of='; then
|
|
83
|
+
_reason="禁止通过 tee/dd 写入文件。请使用 Write 或 SearchReplace 工具。"
|
|
84
|
+
cat >&2 <<'EOF'
|
|
85
|
+
⛔ [ADD PreToolUse §A] 阻断: 禁止通过 tee/dd 写入文件。
|
|
86
|
+
|
|
87
|
+
→ 请改用 Write 或 SearchReplace 工具。
|
|
88
|
+
EOF
|
|
89
|
+
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"ask\",\"permissionDecisionReason\":\"${_reason}\"}}"
|
|
90
|
+
_log_block "tee/dd" "$command"
|
|
91
|
+
exit 2
|
|
57
92
|
fi
|
|
58
93
|
|
|
59
|
-
#
|
|
60
|
-
if echo "$
|
|
61
|
-
|
|
62
|
-
|
|
94
|
+
# 检测 5: cp / mv / touch — 可创建或覆盖文件
|
|
95
|
+
if echo "$command" | grep -qE '^\s*(cp|mv|touch)\b'; then
|
|
96
|
+
_reason="禁止通过 cp/mv/touch 操作文件。请使用 Write 或 SearchReplace 工具。"
|
|
97
|
+
cat >&2 <<'EOF'
|
|
98
|
+
⛔ [ADD PreToolUse §A] 阻断: 禁止通过 cp/mv/touch 操作文件。
|
|
99
|
+
|
|
100
|
+
→ 请改用 Write 或 SearchReplace 工具。
|
|
101
|
+
EOF
|
|
102
|
+
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"ask\",\"permissionDecisionReason\":\"${_reason}\"}}"
|
|
103
|
+
_log_block "cp/mv/touch" "$command"
|
|
104
|
+
exit 2
|
|
63
105
|
fi
|
|
64
106
|
|
|
65
|
-
|
|
107
|
+
# 放行: 构建工具(npx/pnpm/npm/yarn)、版本控制(git)、
|
|
108
|
+
# 只读操作(ls/cat/grep/find/head/tail/wc)、目录操作(mkdir/rmdir) 等
|
|
66
109
|
exit 0
|
|
67
110
|
fi
|
|
68
111
|
|
|
69
|
-
#
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
112
|
+
# ═══════════════ §B: 源码 Plan 关联检查 ═══════════════
|
|
113
|
+
file_path=$(echo "$input" | jq -r '.tool_input.file_path // empty')
|
|
114
|
+
[ -z "$file_path" ] && exit 0
|
|
115
|
+
|
|
116
|
+
if ! echo "$file_path" | grep -qE '(src/|/src/).*\.(ts|tsx)$'; then
|
|
117
|
+
exit 0
|
|
118
|
+
fi
|
|
119
|
+
|
|
120
|
+
MOD=$(basename "$file_path" | sed 's/\.[jt]sx\?$//')
|
|
121
|
+
|
|
122
|
+
MATCHES=$(grep -rl "$MOD" "$PROJECT_DIR/$MAGIC_DIR/plans" "$PROJECT_DIR/$MAGIC_DIR/specs" "$PROJECT_DIR/$MAGIC_DIR/reports" 2>/dev/null | wc -l)
|
|
123
|
+
|
|
124
|
+
if [ "$MATCHES" -gt 0 ]; then
|
|
125
|
+
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"allow\",\"permissionDecisionReason\":\"相关 ADD Plan 已存在\"}}"
|
|
75
126
|
exit 0
|
|
76
127
|
fi
|
|
77
128
|
|
|
78
|
-
|
|
129
|
+
echo "⛔ 阻断: ${file_path} 无相关 ADD Plan。请先创建 Plan(plan-template / simple-plan-template)。" >&2
|
|
130
|
+
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"ask\",\"permissionDecisionReason\":\"无相关 ADD Plan。请用 AskUserQuestion 询问用户选择 plan-template 或 simple-plan-template 创建 Plan。\"}}"
|
|
131
|
+
exit 2
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
#
|
|
2
|
+
# prompt-submit.sh — UserPromptSubmit 触发词智能路由(通用适配版)
|
|
3
3
|
# 治理卡位 #3: Layer 1 精准触发 → Layer 2 阻断 → Layer 3 状态注入
|
|
4
4
|
set -euo pipefail
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
COMMON_LIB="$HOOK_DIR/lib/common.sh"
|
|
10
|
-
[ -f "$COMMON_LIB" ] && source "$COMMON_LIB"
|
|
11
|
-
|
|
12
|
-
export PROJECT_DIR="${CLAUDE_PROJECT_DIR:-$PWD}"
|
|
13
|
-
|
|
14
|
-
input=$(parse_input)
|
|
15
|
-
prompt=$(echo "$input" | grep -o '"prompt"[[:space:]]*:[[:space:]]*"[^"]*"' 2>/dev/null | sed 's/.*: *"\([^"]*\)".*/\1/' || echo "")
|
|
6
|
+
input=$(cat)
|
|
7
|
+
prompt=$(echo "$input" | jq -r '.prompt // empty')
|
|
16
8
|
[ -z "$prompt" ] && exit 0
|
|
17
9
|
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
11
|
+
source "$HOOK_DIR/lib/vocabulary.sh" 2>/dev/null || true
|
|
12
|
+
source "$HOOK_DIR/lib/state-detect.sh" 2>/dev/null || true
|
|
13
|
+
|
|
14
|
+
# ─── Layer 1: 精准 P0 触发词 ───
|
|
15
|
+
matched=$(match_trigger "$prompt" 2>/dev/null || true)
|
|
20
16
|
if [ -n "$matched" ]; then
|
|
17
|
+
# 验收幂等保护: 如果已验收,提示不重复
|
|
21
18
|
if echo "$prompt" | grep -qiE '验收|收敛' 2>/dev/null; then
|
|
22
19
|
add_state=$(detect_active_add 2>/dev/null || true)
|
|
23
20
|
if [ -n "$add_state" ]; then
|
|
@@ -28,9 +25,12 @@ if [ -n "$matched" ]; then
|
|
|
28
25
|
[ADD 验收] ⚠️ 已验收。进入 Review 模式:
|
|
29
26
|
① 重新检查 checklist [T]/[R] 项
|
|
30
27
|
② 审查 audit 记录完整性
|
|
31
|
-
③ 如有差异 → Review 回流至 handoff
|
|
28
|
+
③ 如有差异 → Review 回流至 handoff(增量更新,不覆盖已有结论)
|
|
32
29
|
④ 无差异 → 记录 'Review 已确认,无新发现'
|
|
30
|
+
★ 同步检查: 如 checklist 有新 cuid 但 handoff 审计表缺失 → 更新 handoff ADD-7 表 + query_audit_logs 命令
|
|
33
31
|
EOF
|
|
32
|
+
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
33
|
+
"$HOOK_DIR/review-checklist.sh" "$_handoff" "$_add_route" 2>/dev/null || true
|
|
34
34
|
exit 0
|
|
35
35
|
fi
|
|
36
36
|
fi
|
|
@@ -39,40 +39,37 @@ EOF
|
|
|
39
39
|
exit 0
|
|
40
40
|
fi
|
|
41
41
|
|
|
42
|
-
# ───
|
|
43
|
-
|
|
42
|
+
# ─── 开发关键词检测(动态加载) ───
|
|
43
|
+
dev_kw=$(load_dev_keywords 2>/dev/null || true)
|
|
44
|
+
if [ -z "$dev_kw" ]; then
|
|
44
45
|
exit 0
|
|
45
46
|
fi
|
|
46
47
|
|
|
47
|
-
echo "
|
|
48
|
+
if ! echo "$prompt" | grep -qiE "$dev_kw"; then
|
|
49
|
+
exit 0
|
|
50
|
+
fi
|
|
48
51
|
|
|
49
|
-
# ─── Layer 2:
|
|
52
|
+
# ─── Layer 2/3: 按活跃 ADD 分流 ───
|
|
50
53
|
state=$(detect_active_add 2>/dev/null || true)
|
|
51
54
|
if [ -z "$state" ]; then
|
|
52
|
-
|
|
55
|
+
# Layer 2: 无活跃 ADD → 强制启动
|
|
56
|
+
cat >&2 <<'EOF'
|
|
53
57
|
[ADD 强制规则] 检测到开发任务。你必须先执行 add-paradigm SKILL 完成 ADD 工作流:
|
|
54
58
|
Step 0: 文档先行 (Plan → Review → Specs)
|
|
59
|
+
Step 1: 扩展 AgentAuditPhase
|
|
60
|
+
Step 2: 确认 agentAudit() 通道
|
|
55
61
|
Step 3: 代码实现 + 审计植入
|
|
62
|
+
...
|
|
56
63
|
Step 8: 收敛判断
|
|
57
64
|
如果 add-paradigm SKILL 尚未激活,请先调用它。
|
|
58
65
|
EOF
|
|
59
66
|
exit 2
|
|
60
67
|
fi
|
|
61
68
|
|
|
62
|
-
#
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
当前 Step: ${step}
|
|
69
|
-
handoff: ${handoff}
|
|
70
|
-
EOF
|
|
71
|
-
|
|
72
|
-
# 模板全文注入(tpl-injected 去重)
|
|
73
|
-
TPL_SCRIPT="$HOOK_DIR/lib/preload-templates.sh"
|
|
74
|
-
if [ -f "$TPL_SCRIPT" ]; then
|
|
75
|
-
bash "$TPL_SCRIPT" --full --top 5
|
|
76
|
-
fi
|
|
77
|
-
|
|
69
|
+
# Layer 3: 有活跃 ADD → 注入状态
|
|
70
|
+
plan=$(echo "$state" | awk -F'::' '{print $1}')
|
|
71
|
+
step=$(echo "$state" | awk -F'::' '{print $2}')
|
|
72
|
+
rounds=$(echo "$state" | awk -F'::' '{print $3}')
|
|
73
|
+
handoff=$(echo "$state" | awk -F'::' '{print $4}')
|
|
74
|
+
echo "[ADD 状态] Plan: ${plan}, 轮次: ${rounds}, Step: ${step}, handoff: ${handoff}"
|
|
78
75
|
exit 0
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# 生成 {MAGIC_DIR}/plans/index.md 总览清单 — 按日期分层,每日自动更新
|
|
3
|
+
# 自动探测 MAGIC_DIR(.qoder / .claude / .vscode / .trae / .codex / .add)
|
|
4
|
+
set -e
|
|
5
|
+
|
|
6
|
+
# 探测 MAGIC_DIR:在当前目录向上查找包含 plans/ 的隐藏目录
|
|
7
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
8
|
+
CURRENT="$SCRIPT_DIR"
|
|
9
|
+
MAGIC_DIR=""
|
|
10
|
+
while [ "$CURRENT" != "/" ]; do
|
|
11
|
+
for d in "$CURRENT"/.qoder "$CURRENT"/.claude "$CURRENT"/.vscode "$CURRENT"/.trae "$CURRENT"/.codex "$CURRENT"/.add; do
|
|
12
|
+
if [ -d "$d/plans" ]; then
|
|
13
|
+
MAGIC_DIR="$d"
|
|
14
|
+
break 2
|
|
15
|
+
fi
|
|
16
|
+
done
|
|
17
|
+
CURRENT="$(dirname "$CURRENT")"
|
|
18
|
+
done
|
|
19
|
+
|
|
20
|
+
if [ -z "$MAGIC_DIR" ]; then
|
|
21
|
+
echo "❌ 未找到 MAGIC_DIR(.qoder / .claude / .vscode / .trae / .codex / .add 均无 plans/ 子目录)" >&2
|
|
22
|
+
exit 1
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
PLANS_DIR="$MAGIC_DIR/plans"
|
|
26
|
+
INDEX="$PLANS_DIR/index.md"
|
|
27
|
+
NOW=$(date '+%Y-%m-%d %H:%M:%S')
|
|
28
|
+
TOTAL=$(find "$PLANS_DIR" -mindepth 2 -type f -name '*.md' ! -name 'index.md' | wc -l)
|
|
29
|
+
|
|
30
|
+
# 阶段1:收集数据到临时文件
|
|
31
|
+
TMP=$(mktemp)
|
|
32
|
+
find "$PLANS_DIR" -mindepth 2 -type f -name '*.md' ! -name 'index.md' | sort | while IFS= read -r f; do
|
|
33
|
+
rel="${f#$PLANS_DIR/}"
|
|
34
|
+
month="${rel%%/*}"
|
|
35
|
+
rest="${rel#*/}"
|
|
36
|
+
day="${rest%%/*}"
|
|
37
|
+
fn=$(basename "$rel")
|
|
38
|
+
|
|
39
|
+
case "$fn" in
|
|
40
|
+
*add-route*) tag="add-route" ;;
|
|
41
|
+
*handoff*) tag="handoff" ;;
|
|
42
|
+
*execution*) tag="execution" ;;
|
|
43
|
+
*) tag="plan" ;;
|
|
44
|
+
esac
|
|
45
|
+
|
|
46
|
+
topic=$(head -1 "$f" 2>/dev/null | sed 's/^#\+\s*//' | sed 's/ - .*//' | sed 's/ .*//')
|
|
47
|
+
if [ -z "$topic" ] || [ "${#topic}" -le 3 ]; then
|
|
48
|
+
topic=$(echo "$fn" | sed 's/\.md$//;s/-v[0-9]*$//;s/-plan$//;s/-handoff$//;s/-add-route$//;s/-execution$//;s/^farm-agent-//;s/^team-coordinator-//;s/^co-agent-//;s/^agent-//' | tr '-' ' ')
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
echo "${month}|${day}|${tag}|${fn}|${topic}" >> "$TMP"
|
|
52
|
+
done
|
|
53
|
+
|
|
54
|
+
# 阶段2:写入 index.md
|
|
55
|
+
cat > "$INDEX" << EOF
|
|
56
|
+
# Plans 总览
|
|
57
|
+
|
|
58
|
+
> 自动生成: $NOW | 文档总数: $TOTAL | 下次更新: 每天 2:00 AM
|
|
59
|
+
|
|
60
|
+
EOF
|
|
61
|
+
|
|
62
|
+
prev_month=""
|
|
63
|
+
first=true
|
|
64
|
+
while IFS='|' read -r month day tag fn topic; do
|
|
65
|
+
if [ "$month" != "$prev_month" ]; then
|
|
66
|
+
prev_month="$month"
|
|
67
|
+
first=true
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
if $first; then
|
|
71
|
+
{ echo ""; echo "## $month"; echo ""; echo "| 日 | 类型 | 文档 | 主题 |"; echo "|---|------|------|------|"; } >> "$INDEX"
|
|
72
|
+
first=false
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
echo "| $day | $tag | [$fn]($month/$day/$fn) | $topic |" >> "$INDEX"
|
|
76
|
+
done < <(sort -t'|' -k1,1r -k2,2n "$TMP")
|
|
77
|
+
|
|
78
|
+
rm -f "$TMP"
|
|
79
|
+
|
|
80
|
+
echo "" >> "$INDEX"
|
|
81
|
+
echo "---" >> "$INDEX"
|
|
82
|
+
echo "*索引由 \`$(basename "$MAGIC_DIR")/scripts/gen-plan-index.sh\` 自动生成,勿手动编辑*" >> "$INDEX"
|
|
83
|
+
|
|
84
|
+
echo "✅ index.md 已更新 ($TOTAL 文档)"
|
|
@@ -100,10 +100,10 @@
|
|
|
100
100
|
"{ACTION_2}",
|
|
101
101
|
"{ACTION_3}"
|
|
102
102
|
],
|
|
103
|
-
"forbidden_terms": [
|
|
103
|
+
"forbidden_terms": [
|
|
104
|
+
"Phase",
|
|
104
105
|
"Round",
|
|
105
|
-
"
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
]
|
|
106
|
+
"阶段"
|
|
107
|
+
],
|
|
108
|
+
"forbidden_terms_note": "禁止使用 Phase/Round/阶段 作为 Task 分组词,必须使用模板规定的「轮次」。'步骤'和'轮次'不禁——它们是模板自身的结构关键词。"
|
|
109
109
|
}
|