add-coder 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -339,6 +339,7 @@ Tasks (实验性) 双向 ✅ 已实现 长任务持久化
339
339
  | Demo 仓库演示 | 提供完整示例仓库,展示 Policy-Update-Loop 与 Report 体系的端到端闭环实践 |--|
340
340
  | MCP 能力重构 | ✅ v0.2.9 MCP 工具链架构升级,提升审计与门禁工具的可扩展性和独立部署能力 | 2026-07/23/add-coder-mcp-restructure-plan-v1.md |
341
341
  | Hook 通知升级 | ✅ v0.2.9 Hook 拦截事件 jsonl → fs.watch → record_dev_operation 落库 + Notification + 治理信号 | 2026-07/24/add-coder-hook-notify-upgrade-plan-v1.md |
342
+ | ide插件 | 解耦ADD范式代码和被治理项目的代码 |在做了,大家拭目以待吧,让编程更有趣,我的目标其实不在于IDE,我的工作顺手的事情 |
342
343
  | 对话记忆增强 | 长期项目知识记忆和plan级别的稀疏记忆 |--|
343
344
 
344
345
 
@@ -381,13 +382,13 @@ Traditional AI development: Chat → Generate code → Dig through chat history
381
382
  | Auditing relies on developer discipline | The **MCP audit toolchain** automatically records every operation; system gateways enforce checks |
382
383
  | No traceability | Audit events are naturally linked: Plan → Spec → Task → Step → Tool Call, forming a complete evidence chain |
383
384
 
384
- ### ② Caijuehub Rule Engine: From Sync to Three Domains
385
+ ### ② Caijuehub The Centralized Adjudication Layer: From Sync to Three Domains
385
386
 
386
- Caijuehub is add-coder's first implementation of **TOML declaration → auto-generated strategy → business code consumption**. From the initial sync --patch experiment to today's three-domain coverage spanning HITL and DPS, the evolution proves the extensibility of centralized decision layers. Details: [docs/caijuehub.md](./docs/caijuehub.md).
387
+ Caijuehub is add-coder's first implementation of **TOML declaration → auto-generated strategy → business code consumption**. From the initial sync --patch experiment to today's three-domain coverage spanning HITL and DPS, the evolution proves the extensibility of the centralized adjudication layer. Details: [docs/caijuehub.md](./docs/caijuehub.md).
387
388
 
388
389
  | Domain | Rules File | Consumer | Description |
389
390
  |--------|---------|--------|------|
390
- | sync --patch | `sync-rules.toml` | `sync.ts` | **First centralized decision hot-update in npm history** (eating my own dog food: add-coder manages its own template sync via caijuehub) |
391
+ | sync --patch | `sync-rules.toml` | `sync.ts` | **First centralized adjudication hot-update in npm history** (eating my own dog food: add-coder manages its own template sync via caijuehub) |
391
392
  | HITL Approval | `hitl-interaction-rules.toml` | `hitl.ts` | Per-IDE interaction mode declaration |
392
393
  | DPS Scoring | `dps-scoring-rules.toml` | `gateway.ts` | Doc quality gateway: semantic/entropy/CPM/structure 4D weights+thresholds, AI self-tuning without touching code |
393
394
 
@@ -616,7 +617,8 @@ npx add-coder init
616
617
  ┌────────────┘
617
618
 
618
619
  ┌─────────────────────────────────────┐
619
- Caijuehub Rule Engine
620
+ Caijuehub Centralized
621
+ │ Adjudication Layer │
620
622
  │ TOML-Driven Policy System │
621
623
  │ Detect / Adapt / Prisma / Write — │
622
624
  │ Fully Configurable │
package/dist/index.js CHANGED
@@ -305,7 +305,21 @@ var SYNC_PRISMA_CONFIG = {
305
305
  ON_FIELD_CONFLICT: "interactive",
306
306
  ON_MISSING_FIELD: "interactive",
307
307
  ON_EXTRA_FIELD: "ignore",
308
- PROMPT: "add-coder \u6807\u51C6 add.prisma \u4E0E\u6D88\u8D39\u65B9 schema \u5B58\u5728\u5DEE\u5F02\u3002"
308
+ PROMPT: "add-coder \u6807\u51C6 add.prisma \u4E0E\u6D88\u8D39\u65B9 schema \u5B58\u5728\u5DEE\u5F02\u3002",
309
+ POST_SYNC: {
310
+ HEADER: "\u4E0B\u4E00\u6B65\u6309\u4F60\u7684\u573A\u666F\u9009\u62E9\u8FC1\u79FB\u547D\u4EE4:",
311
+ FINAL: "npx prisma generate",
312
+ MANAGED_ACTIONS: [
313
+ { label: "\u5F00\u53D1\u73AF\u5883\uFF08\u751F\u6210\u65B0\u8FC1\u79FB+\u540C\u6B65\u672C\u5730\u5E93\uFF09", cmd: "npx prisma migrate dev" },
314
+ { label: "\u751F\u4EA7/CI\uFF08\u53EA\u5E94\u7528\u5DF2\u6709\u8FC1\u79FB\uFF09", cmd: "npx prisma migrate deploy" },
315
+ { label: "\u4E0D\u786E\u5B9A\uFF1F\u5148\u67E5\u72B6\u6001", cmd: "npx prisma migrate status" }
316
+ ],
317
+ P3005: { hint: "\u82E5\u62A5 P3005\uFF08\u5E93\u6709\u8868\u4F46\u65E0\u8FC1\u79FB\u8BB0\u5F55\uFF09= \u9700\u5148\u57FA\u7EBF\u5316:", cmd: "npx prisma migrate resolve --applied <\u8FC1\u79FB\u540D>\uFF0C\u518D\u6267\u884C deploy" },
318
+ UNMANAGED_ACTIONS: [
319
+ { label: "\u9996\u6B21\u63A5\u5165\u8FC1\u79FB\u7BA1\u7406\uFF08\u7A7A\u5E93\uFF09", cmd: "npx prisma migrate dev --name init" },
320
+ { label: "\u5E93\u5DF2\u6709\u8868\uFF08db push \u5EFA\u8FC7\uFF09", hint: "\u5148\u624B\u52A8\u57FA\u7EBF\u5316\uFF0C\u518D deploy:", steps: ["npx prisma migrate diff --from-empty --to-schema-datamodel <schema\u6587\u4EF6> --script", "\u5C06\u8F93\u51FA\u5199\u5165 prisma/migrations/<\u65F6\u95F4\u6233>_init/migration.sql", "npx prisma migrate resolve --applied <\u65F6\u95F4\u6233>_init"] }
321
+ ]
322
+ }
309
323
  };
310
324
 
311
325
  // src/cli/writer.ts
@@ -1294,6 +1308,28 @@ async function syncCommand(options = {}) {
1294
1308
  console.log(`\u540C\u6B65\u5B8C\u6210: \u65B0\u5EFA ${result.created}, \u8DF3\u8FC7 ${result.skipped}`);
1295
1309
  await checkPrismaDiff(projectRoot, options);
1296
1310
  }
1311
+ function printMigrateGuidance(targetPath, changed) {
1312
+ const g = SYNC_PRISMA_CONFIG.POST_SYNC;
1313
+ const isManaged = existsSync8(resolve6(dirname4(targetPath), "migrations"));
1314
+ const actions = isManaged ? g.MANAGED_ACTIONS : g.UNMANAGED_ACTIONS;
1315
+ console.log(` \u25B6 \u5DF2\u5199\u5165 ${changed} \u5904\u53D8\u66F4\uFF0C${g.HEADER}`);
1316
+ for (const a of actions) {
1317
+ if ("cmd" in a && "label" in a) {
1318
+ const prefix = isManaged ? "\u251C\u2500" : "\u251C\u2500";
1319
+ console.log(` ${prefix} ${a.label}: ${a.cmd}`);
1320
+ } else if ("steps" in a) {
1321
+ const item = a;
1322
+ console.log(` \u2514\u2500 ${item.label}:`);
1323
+ if (item.hint) console.log(` \u26A0\uFE0F ${item.hint}`);
1324
+ for (const s of item.steps) console.log(` ${s}`);
1325
+ }
1326
+ }
1327
+ if (isManaged) {
1328
+ console.log(` \u26A0\uFE0F ${g.P3005.hint}`);
1329
+ console.log(` ${g.P3005.cmd}`);
1330
+ }
1331
+ console.log(` \u26A0\uFE0F \u6240\u6709\u573A\u666F\u6536\u5C3E: ${g.FINAL}`);
1332
+ }
1297
1333
  async function checkPrismaDiff(projectRoot, options) {
1298
1334
  if (!options.patch) return;
1299
1335
  const basePath = resolve6(projectRoot, SYNC_PRISMA_CONFIG.BASE_SCHEMA);
@@ -1311,6 +1347,7 @@ async function checkPrismaDiff(projectRoot, options) {
1311
1347
  return;
1312
1348
  }
1313
1349
  const targetExists = existsSync8(targetPath);
1350
+ let modifiedCount = 0;
1314
1351
  console.log(`
1315
1352
  \u26A0\uFE0F Prisma schema \u5DEE\u5F02\u68C0\u6D4B:`);
1316
1353
  console.log(` \u57FA\u51C6: ${result.baseSchema} (add-coder \u6807\u51C6)`);
@@ -1342,6 +1379,7 @@ async function checkPrismaDiff(projectRoot, options) {
1342
1379
  },
1343
1380
  execute() {
1344
1381
  const n = injectMissingModels(result.targetPath, selected);
1382
+ modifiedCount += n;
1345
1383
  console.log(` \u2705 \u5DF2\u5C06 ${n} \u4E2A\u6A21\u578B/\u679A\u4E3E\u6CE8\u5165 ${result.targetPath}`);
1346
1384
  return Promise.resolve(n);
1347
1385
  }
@@ -1370,6 +1408,7 @@ async function checkPrismaDiff(projectRoot, options) {
1370
1408
  },
1371
1409
  execute() {
1372
1410
  const n = overwriteFieldLines(targetPath, basePath, d.name, d.conflicts);
1411
+ modifiedCount += n;
1373
1412
  console.log(` \u2705 \u5DF2\u8986\u76D6 ${n} \u4E2A\u51B2\u7A81\u5B57\u6BB5`);
1374
1413
  return Promise.resolve(n);
1375
1414
  }
@@ -1390,6 +1429,7 @@ async function checkPrismaDiff(projectRoot, options) {
1390
1429
  },
1391
1430
  execute() {
1392
1431
  const n = injectFieldLines(targetPath, basePath, d.name, d.missingFields);
1432
+ modifiedCount += n;
1393
1433
  console.log(` \u2705 \u5DF2\u8865\u5145 ${n} \u4E2A\u5B57\u6BB5`);
1394
1434
  return Promise.resolve(n);
1395
1435
  }
@@ -1417,7 +1457,11 @@ async function checkPrismaDiff(projectRoot, options) {
1417
1457
  if (targetExists) {
1418
1458
  console.log(`
1419
1459
  ${SYNC_PRISMA_CONFIG.PROMPT}`);
1420
- console.log(` \u25B6 \u8BF7\u8FD0\u884C: npx prisma migrate dev && npx prisma generate`);
1460
+ if (modifiedCount > 0) {
1461
+ printMigrateGuidance(targetPath, modifiedCount);
1462
+ } else {
1463
+ console.log(` \u25B6 \u76EE\u6807 schema \u5DF2\u662F\u6700\u65B0\uFF08\u672A\u9009\u62E9\u4EFB\u4F55\u53D8\u66F4\uFF09\uFF0C\u65E0\u9700\u8FC1\u79FB\u64CD\u4F5C`);
1464
+ }
1421
1465
  } else {
1422
1466
  console.log(`
1423
1467
  \u76EE\u6807 schema \u6587\u4EF6\u4E0D\u5B58\u5728: ${result.targetPath}`);
@@ -1425,7 +1469,9 @@ async function checkPrismaDiff(projectRoot, options) {
1425
1469
  writeFileSync4(targetPath, "// add.prisma \u2014 ADD \u6CBB\u7406\u6A21\u578B\n\n", "utf-8");
1426
1470
  const n = injectMissingModels(targetPath, result.missing);
1427
1471
  console.log(` \u2705 \u5DF2\u521B\u5EFA\u5E76\u6CE8\u5165 ${n} \u4E2A\u6A21\u578B/\u679A\u4E3E`);
1428
- console.log(` \u25B6 \u8BF7\u8FD0\u884C: npx prisma migrate dev && npx prisma generate`);
1472
+ if (n > 0) {
1473
+ printMigrateGuidance(targetPath, n);
1474
+ }
1429
1475
  }
1430
1476
  }
1431
1477
  async function handleDiffAction(action, ctx) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "add-coder",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
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": {
@@ -48,7 +48,6 @@
48
48
  "zod": "^4.4.3"
49
49
  },
50
50
  "peerDependencies": {
51
- "@prisma/adapter-libsql": "^7.0.0",
52
51
  "@prisma/adapter-pg": "^7.0.0",
53
52
  "@prisma/client": "^7.0.0",
54
53
  "dotenv": "*",
@@ -71,13 +70,10 @@
71
70
  "optional": false
72
71
  },
73
72
  "@prisma/adapter-pg": {
74
- "optional": true
75
- },
76
- "@prisma/adapter-libsql": {
77
- "optional": true
73
+ "optional": false
78
74
  },
79
75
  "@xenova/transformers": {
80
- "optional": true
76
+ "optional": false
81
77
  }
82
78
  },
83
79
  "devDependencies": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "_version": "0.3.6",
2
+ "_version": "0.3.7",
3
3
  "adapters/claude/hooks/doc-format-guard.sh": "ec59ad3f",
4
4
  "adapters/claude/hooks/lib/common.sh": "db321ef6",
5
5
  "adapters/claude/hooks/lib/context-inject.sh": "4132f203",