frontend-project-context 1.6.0 → 1.7.0

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +92 -46
  3. package/UPGRADING.md +22 -1
  4. package/docs/05-ACCEPTANCE-CONTRACT.md +20 -1
  5. package/docs/08-INSTALLATION-AND-DISTRIBUTION.md +44 -21
  6. package/docs/14-FORMAL-RELEASE-READINESS.md +9 -5
  7. package/docs/19-POST-1.3.1-AI-TAKEOVER-EVIDENCE-AND-UPGRADE-PLAN.md +5 -5
  8. package/docs/20-PHASE-A-AI-TAKEOVER-AND-HEALTH-CLOSURE-DESIGN.md +11 -11
  9. package/docs/22-PHASE-C-TARGET-UPGRADE-PROTOCOL-DESIGN.md +4 -4
  10. package/docs/23-ADAPTIVE-BOUNDED-TASK-CONTEXT-DESIGN.md +432 -0
  11. package/docs/24-A130-REAL-HOST-TARGET-PROJECT-COMPARISON.md +210 -0
  12. package/docs/25-REAL-PROJECT-SOURCE-OF-TRUTH-MAINTENANCE-DESIGN.md +409 -0
  13. package/docs/26-A130-QUALITY-CLOSURE-AND-ADAPTIVE-DELIVERY-REPAIR-DESIGN.md +609 -0
  14. package/docs/README.md +22 -6
  15. package/docs/USER-AND-AI-OPERATION-MANUAL.md +73 -30
  16. package/examples/README.md +4 -4
  17. package/examples/package.json +1 -1
  18. package/migration-manifest.json +30 -8
  19. package/package.json +2 -2
  20. package/schemas/adaptive-context-bundle.schema.json +70 -0
  21. package/schemas/capabilities.schema.json +20 -6
  22. package/schemas/context-query.schema.json +69 -0
  23. package/schemas/coverage-audit.schema.json +32 -0
  24. package/schemas/evidence-bundle.schema.json +2 -2
  25. package/schemas/host-promotion-evidence.schema.json +33 -0
  26. package/schemas/migration-manifest.schema.json +3 -3
  27. package/schemas/migration-plan.schema.json +2 -2
  28. package/schemas/projection-lock.schema.json +1 -1
  29. package/schemas/routing-index.schema.json +58 -0
  30. package/schemas/truth-reconciliation-input.schema.json +60 -0
  31. package/schemas/truth-reconciliation-review-bundle.schema.json +155 -0
  32. package/schemas/upgrade-assessment.schema.json +2 -2
  33. package/schemas/upgrade-result-bundle.schema.json +1 -1
  34. package/src/project-context/a130-evaluation.mjs +91 -0
  35. package/src/project-context/adaptive-context-schema.mjs +392 -0
  36. package/src/project-context/adaptive-context.mjs +547 -0
  37. package/src/project-context/ai-entry.mjs +9 -9
  38. package/src/project-context/assist.mjs +4 -2
  39. package/src/project-context/capabilities.mjs +18 -0
  40. package/src/project-context/checker.mjs +4 -3
  41. package/src/project-context/cli.mjs +40 -5
  42. package/src/project-context/contract-schema.mjs +1 -1
  43. package/src/project-context/discovery.mjs +7 -7
  44. package/src/project-context/exchange-schema.mjs +6 -5
  45. package/src/project-context/maintenance.mjs +2 -2
  46. package/src/project-context/migration-manifest.mjs +7 -5
  47. package/src/project-context/renderer.mjs +75 -1
  48. package/src/project-context/source-reader.mjs +63 -30
  49. package/src/project-context/task-context.mjs +14 -2
  50. package/src/project-context/truth-reconciliation-schema.mjs +488 -0
  51. package/src/project-context/truth-reconciliation.mjs +543 -0
  52. package/src/project-context/upgrade-schema.mjs +5 -1
package/docs/README.md CHANGED
@@ -48,7 +48,7 @@
48
48
 
49
49
  10. [14-FORMAL-RELEASE-READINESS.md](./14-FORMAL-RELEASE-READINESS.md)
50
50
 
51
- 记录 `1.0.0` 正式发布、`1.0.1` README/metadata patch 与 `1.2.0` AI Exchange Boundary 发布:包边界、项目接入、CI、迁移、验收、registry 完整性和不伪造公共仓库链接的决定。
51
+ 记录 `1.0.0`、`1.0.1`、`1.2.0`、`1.3.x` 与 `1.6.0` 正式发布:包边界、项目接入、CI、迁移、验收、registry 完整性和不伪造公共仓库链接的决定。
52
52
 
53
53
  11. [15-SOURCE-LIFECYCLE-CLOSURE-DESIGN.md](./15-SOURCE-LIFECYCLE-CLOSURE-DESIGN.md)
54
54
 
@@ -80,22 +80,38 @@
80
80
 
81
81
  18. [22-PHASE-C-TARGET-UPGRADE-PROTOCOL-DESIGN.md](./22-PHASE-C-TARGET-UPGRADE-PROTOCOL-DESIGN.md)
82
82
 
83
- 冻结并记录 `1.6.0` Phase C 本地实现:只读 `upgrade-check/upgrade-plan`、默认 preview/显式写入的 `upgrade-apply`、Migration Manifest schema 2、三份升级工件 schema 1、单步 digest/CAS 收敛、兼容/回滚矩阵与 A-101 至 A-114;当前 120/120 通过,已授权进入公开 npm 发布候选流程,真实目标项目验收仍未授权。
83
+ 冻结并记录 `1.6.0` Phase C 的实现与正式发布:只读 `upgrade-check/upgrade-plan`、默认 preview/显式写入的 `upgrade-apply`、Migration Manifest schema 2、三份升级工件 schema 1、单步 digest/CAS 收敛、兼容/回滚矩阵与 A-101 至 A-114120/120、公共 npm 与 registry 独立复验均已通过,真实目标项目验收仍未授权。
84
+
85
+ 19. [23-ADAPTIVE-BOUNDED-TASK-CONTEXT-DESIGN.md](./23-ADAPTIVE-BOUNDED-TASK-CONTEXT-DESIGN.md)
86
+
87
+ 用反证方式冻结并记录 `1.7.0` 初始本地实现与历史复验;当前 docs/26 统一修复已在其上完成,完整回归增至 194/194。历史真实 Host/Provider 复验仍为完整 8/8、自适应 7/8,新的复验与发布均未授权。
88
+
89
+ 20. [24-A130-REAL-HOST-TARGET-PROJECT-COMPARISON.md](./24-A130-REAL-HOST-TARGET-PROJECT-COMPARISON.md)
90
+
91
+ 记录 `dtg-tmc-pc` 上首次对照及 A-130R 后的成对复验。复验中自适应首包降至 5,283 字节,但质量仍为 7/8,对照完整臂为 8/8,且 tokens、命令数与耗时均未改善,故 A-130 严格失败;原目标仓库始终未修改。
92
+
93
+ 21. [25-REAL-PROJECT-SOURCE-OF-TRUTH-MAINTENANCE-DESIGN.md](./25-REAL-PROJECT-SOURCE-OF-TRUTH-MAINTENANCE-DESIGN.md)
94
+
95
+ 冻结真实项目全量应用下的真源维护设计,并完成隔离协议 fixture。裁定失败后的机器闭环已由 docs/26 升级为 Truth Reconciliation Input/Review Bundle schema 2、previous Review 绑定与可验证终态;A-144、Sidecar 和真实项目写入仍未授权。
96
+
97
+ 22. [26-A130-QUALITY-CLOSURE-AND-ADAPTIVE-DELIVERY-REPAIR-DESIGN.md](./26-A130-QUALITY-CLOSURE-AND-ADAPTIVE-DELIVERY-REPAIR-DESIGN.md)
98
+
99
+ 冻结并完成 A-130 与 Truth Resolution Closure 本地统一修复:A-130D-01 至 A-130D-31 处理评测、scope/lineage、严格 schema、交付和计量;A-130T-01 至 A-130T-10 处理上一 Review 绑定、人工裁定、Contract/外部代码修复分流和机器可验证终态。全量 194/194 通过;Provider 复验与发布仍未授权。
84
100
 
85
101
  ## 历史证据
86
102
 
87
- 19. [06-HISTORICAL-PROTOTYPE.md](./06-HISTORICAL-PROTOTYPE.md)
88
- 20. [07-REAL-TASK-EVIDENCE.md](./07-REAL-TASK-EVIDENCE.md)
103
+ 23. [06-HISTORICAL-PROTOTYPE.md](./06-HISTORICAL-PROTOTYPE.md)
104
+ 24. [07-REAL-TASK-EVIDENCE.md](./07-REAL-TASK-EVIDENCE.md)
89
105
 
90
106
  历史文档只解释为什么不再建设任务执行 Harness。它们不是程序需求、工作流或授权来源。
91
107
 
92
108
  ## Beta 证据
93
109
 
94
- 21. [09-B0-DTG-TMC-MOBILE.md](./09-B0-DTG-TMC-MOBILE.md)
110
+ 25. [09-B0-DTG-TMC-MOBILE.md](./09-B0-DTG-TMC-MOBILE.md)
95
111
 
96
112
  记录首次真实项目只读接入、通用修补和同项目回归。报告中的历史“下一步”不再产生新需求。
97
113
 
98
- 22. [10-B0-DTG-TMC-PC.md](./10-B0-DTG-TMC-PC.md)
114
+ 26. [10-B0-DTG-TMC-PC.md](./10-B0-DTG-TMC-PC.md)
99
115
 
100
116
  记录第二个真实项目只读接入和跨项目对比:核心链路与首轮通用修补再次通过。产品宪法已经停止继续寻找项目和扩充技术发现白名单。
101
117
 
@@ -1,6 +1,6 @@
1
1
  # Frontend Project Context 操作手册
2
2
 
3
- > 适用版本:`frontend-project-context@1.3.1`
3
+ > 适用版本:`frontend-project-context@1.7.0` 发布候选
4
4
  >
5
5
  > 适用对象:项目维护者、开发者、使用 Codex / Claude / Cursor / 其他 Coding Agent 的团队,以及集成该 CLI 的 AI Host Agent。
6
6
  >
@@ -101,7 +101,7 @@ AI 可以提取事实、整理文字、去重、建议 scope/override、生成 p
101
101
  固定为项目开发依赖,使本地与 CI 使用同一版本:
102
102
 
103
103
  ```bash
104
- npm install --save-dev frontend-project-context@1.3.1
104
+ npm install --save-dev frontend-project-context@1.7.0
105
105
  ```
106
106
 
107
107
  建议在 `package.json` 中提供稳定入口:
@@ -120,18 +120,35 @@ npm install --save-dev frontend-project-context@1.3.1
120
120
  试运行:
121
121
 
122
122
  ```bash
123
- npx project-context --help
124
- npx project-context capabilities --project . --json
123
+ npm exec --offline -- project-context --help
124
+ npm exec --offline -- project-context capabilities --project . --json
125
+ npm exec --offline -- project-context status --project . --json
125
126
  ```
126
127
 
128
+ 所有正式命令都通过 `npm exec --offline -- project-context` 或上面的项目脚本调用。`--offline` 会在本地依赖缺失时失败封闭,不能退回 registry 下载无关的同名 `project-context` 包。持久初始化必须发生在精确版本安装之后,避免后续补装依赖改变已登记的 `package.json` source digest。
129
+
127
130
  `capabilities` 在项目未初始化时也可用,适合 AI Host 先查询当前包版本、schema、支持的 action kind 和永久边界。
128
131
 
132
+ `1.7.0` 默认以中文生成 AI Entry 和 discovery 候选的 `statement`,便于中文团队直接审查项目语义;稳定 ID、subject、kind、CLI 命令、JSON 字段、枚举和 marker 继续使用英文。AI Entry renderer 3 同时固定离线项目本地 CLI 入口;既有 renderer 1/2 不会被静默覆盖,升级后会报告 stale,必须先预览并获得明确写入授权,再 republish 为 renderer 3 中文入口。
133
+
134
+ ### 4.3 全新初始化不是普通升级
135
+
136
+ 再次运行 `setup` 会复用现有 store,不会 reset,也不会把已经批准的英文 statement 自动翻译成中文。确需使用正式包全新初始化时,必须先:
137
+
138
+ 1. 导出并人工核对现有 Contract 中的 policy、validation-description、manual source 和批准决定;
139
+ 2. 使用当前所有权记录预览并显式执行 `remove-entry`,只移除受管区域,保留 `AGENTS.md` 其余人工内容;
140
+ 3. 由人明确授权外部工具精确清理可丢弃的 `.project-context`,确认 `status.initialization.state=uninitialized`;
141
+ 4. 先安装精确版本,再按第 5 节重新 setup、审查、录入和批准被保留的人工规则;
142
+ 5. 如果 `AGENTS.md` 同时是 active source,发布新 AI Entry 后继续完成预期的 source review、accept 和受影响 item 重新批准,直到 `check/status` 为 clean。
143
+
144
+ 工具没有自动 reset 命令,也不会把删除 store、翻译批准规则或接受 source drift 伪装成普通升级。
145
+
129
146
  ## 5. 首次接入 SOP
130
147
 
131
148
  ### 第 1 步:只读预览初始化结果
132
149
 
133
150
  ```bash
134
- npx project-context setup \
151
+ npm exec --offline -- project-context setup \
135
152
  --project . \
136
153
  --id my-project \
137
154
  --name "My Project" \
@@ -153,7 +170,7 @@ npx project-context setup \
153
170
  确认项目 ID、名称和 proposal 路径后执行:
154
171
 
155
172
  ```bash
156
- npx project-context setup \
173
+ npm exec --offline -- project-context setup \
157
174
  --project . \
158
175
  --id my-project \
159
176
  --name "My Project" \
@@ -188,7 +205,7 @@ AI 应:
188
205
  先预览,再在对象无误后重复同一命令并加 `--write`:
189
206
 
190
207
  ```bash
191
- npx project-context register \
208
+ npm exec --offline -- project-context register \
192
209
  --project . \
193
210
  --id source.package \
194
211
  --kind file \
@@ -198,7 +215,7 @@ npx project-context register \
198
215
  创建合同项 proposal:
199
216
 
200
217
  ```bash
201
- npx project-context propose \
218
+ npm exec --offline -- project-context propose \
202
219
  --project . \
203
220
  --id policy.ui-copy \
204
221
  --kind policy \
@@ -258,7 +275,7 @@ AI 必须先展示:
258
275
  ### 第 6 步:批准精确 ID
259
276
 
260
277
  ```bash
261
- npx project-context approve \
278
+ npm exec --offline -- project-context approve \
262
279
  --project . \
263
280
  --proposal .project-context/policy.ui-copy.proposal.json \
264
281
  --ids policy.ui-copy \
@@ -272,7 +289,7 @@ npx project-context approve \
272
289
  为目标路径生成临时上下文:
273
290
 
274
291
  ```bash
275
- npx project-context context \
292
+ npm exec --offline -- project-context context \
276
293
  --project . \
277
294
  --path src \
278
295
  --locale zh-CN
@@ -281,7 +298,7 @@ npx project-context context \
281
298
  生成 AGENTS 投影:
282
299
 
283
300
  ```bash
284
- npx project-context publish \
301
+ npm exec --offline -- project-context publish \
285
302
  --project . \
286
303
  --target agents \
287
304
  --output src/AGENTS.md \
@@ -291,7 +308,7 @@ npx project-context publish \
291
308
  或生成 Ruler 投影:
292
309
 
293
310
  ```bash
294
- npx project-context publish \
311
+ npm exec --offline -- project-context publish \
295
312
  --project . \
296
313
  --target ruler \
297
314
  --output .ruler/project-context.md \
@@ -305,7 +322,7 @@ npx project-context publish \
305
322
  ### 第 8 步:检查并提交
306
323
 
307
324
  ```bash
308
- npx project-context check --project .
325
+ npm exec --offline -- project-context check --project .
309
326
  ```
310
327
 
311
328
  `check` clean 后,提交三个 store 和团队明确采用的受管投影。proposal 通常不提交。
@@ -315,7 +332,7 @@ npx project-context check --project .
315
332
  一般任务不需要重新扫描整个仓库。先根据任务的真实修改目标生成 Context Bundle:
316
333
 
317
334
  ```bash
318
- npx project-context context \
335
+ npm exec --offline -- project-context context \
319
336
  --project . \
320
337
  --path src/features/order \
321
338
  --path src/shared/request.ts \
@@ -325,6 +342,26 @@ npx project-context context \
325
342
 
326
343
  `--task` 是当次临时约束,只会进入这份 bundle,不会写回 Contract,也不会扩大开发权限。
327
344
 
345
+ `1.7.0` 本地实现也支持由 Host 提供 schema 1 Context Query,把原始任务文本、target paths、topics、changed paths、三个 snapshot 和软/硬预算一次传入:
346
+
347
+ ```bash
348
+ npm exec --offline -- project-context context-query \
349
+ --project . \
350
+ --input .project-context/context-query.json \
351
+ --json
352
+ ```
353
+
354
+ `--json` 用于 Host 审查健康、deferred 目录与字节计量;真正传给模型时使用同一查询的 `--prompt`,不要把整份审查 JSON 当成模型上下文。小 Contract 中完整 Context 更小时会自动回退到完整投影。普通局部任务使用 `initial` + `snapshot-and-signal-bound`;证据不足时把前一份 bundle 保存后,以 `expanded` query 配合 `--previous` 增量扩展;要求绝对当前新鲜度时使用 `strict-current` 或 `complete`。policy/validation 不因软预算被截断,硬预算不足会返回 blocked。
355
+
356
+ 初始化、覆盖规则变化或显式审计时运行:
357
+
358
+ ```bash
359
+ npm exec --offline -- project-context coverage-audit --project . --json
360
+ npm exec --offline -- project-context index-context --project . --json
361
+ ```
362
+
363
+ `coverage-audit` 只证明已批准 coverage profile 的声明范围;不会输出“全部项目真源已发现”。`index-context` 默认只预览,从 Contract 确定性重建;只有人明确需要缓存时才加 `--write`,生成的 `.project-context/derived/routing-index.json` 不是 store 或真源。
364
+
328
365
  推荐把下面四类信息一起给外部 Coding Agent:
329
366
 
330
367
  1. 当次任务目标和验收标准;
@@ -335,7 +372,7 @@ npx project-context context \
335
372
  完成业务修改后,由外部 Agent、IDE 或 CI 把真实 changed paths 传给 `sync`:
336
373
 
337
374
  ```bash
338
- npx project-context sync \
375
+ npm exec --offline -- project-context sync \
339
376
  --project . \
340
377
  --changed-path src/features/order/detail.ts \
341
378
  --changed-path src/shared/request.ts \
@@ -361,7 +398,7 @@ check / sync
361
398
  ### 7.1 先一次汇总变化
362
399
 
363
400
  ```bash
364
- npx project-context sync --project . --json
401
+ npm exec --offline -- project-context sync --project . --json
365
402
  ```
366
403
 
367
404
  AI 应先交付变化清单,不应直接写入:
@@ -376,7 +413,7 @@ AI 应先交付变化清单,不应直接写入:
376
413
  ### 7.2 精确审查单个来源
377
414
 
378
415
  ```bash
379
- npx project-context review-source \
416
+ npm exec --offline -- project-context review-source \
380
417
  --project . \
381
418
  --id source.package \
382
419
  --json
@@ -387,7 +424,7 @@ npx project-context review-source \
387
424
  只有人确认 new digest 和完整 affected item IDs 后,才预览:
388
425
 
389
426
  ```bash
390
- npx project-context accept-source-change \
427
+ npm exec --offline -- project-context accept-source-change \
391
428
  --project . \
392
429
  --id source.package \
393
430
  --expected-digest sha256:NEW_DIGEST \
@@ -401,7 +438,7 @@ npx project-context accept-source-change \
401
438
  修订前必须使用当前 item digest:
402
439
 
403
440
  ```bash
404
- npx project-context revise \
441
+ npm exec --offline -- project-context revise \
405
442
  --project . \
406
443
  --id policy.ui-copy \
407
444
  --expected-item-digest sha256:CURRENT_ITEM_DIGEST \
@@ -417,7 +454,7 @@ npx project-context revise \
417
454
  废弃 item:
418
455
 
419
456
  ```bash
420
- npx project-context deprecate \
457
+ npm exec --offline -- project-context deprecate \
421
458
  --project . \
422
459
  --id policy.ui-copy \
423
460
  --expected-item-digest sha256:CURRENT_ITEM_DIGEST \
@@ -428,7 +465,7 @@ npx project-context deprecate \
428
465
  重新批准 pending item:
429
466
 
430
467
  ```bash
431
- npx project-context approve \
468
+ npm exec --offline -- project-context approve \
432
469
  --project . \
433
470
  --pending \
434
471
  --ids fact.node-version validation.check \
@@ -465,10 +502,10 @@ npx project-context approve \
465
502
  ### 8.1 查询协议能力
466
503
 
467
504
  ```bash
468
- npx project-context capabilities --project . --json
505
+ npm exec --offline -- project-context capabilities --project . --json
469
506
  ```
470
507
 
471
- `1.3.1` 支持八类 Action Plan action:
508
+ `1.7.0` 支持十类 Action Plan action:
472
509
 
473
510
  - `register-source`;
474
511
  - `propose-item`;
@@ -477,7 +514,9 @@ npx project-context capabilities --project . --json
477
514
  - `deprecate-item`;
478
515
  - `deprecate-source`;
479
516
  - `request-item-approval`;
480
- - `publish-projection`。
517
+ - `publish-projection`;
518
+ - `publish-ai-entry`;
519
+ - `remove-ai-entry`。
481
520
 
482
521
  ### 8.2 AI 生成无权限 Action Plan
483
522
 
@@ -488,7 +527,7 @@ Action Plan 中不得包含 Provider 调用、shell、Git、业务代码写入
488
527
  ### 8.3 只读预检
489
528
 
490
529
  ```bash
491
- npx project-context preflight \
530
+ npm exec --offline -- project-context preflight \
492
531
  --project . \
493
532
  --plan .project-context/action-plan.json \
494
533
  --json
@@ -542,7 +581,7 @@ Plan 是宿主提供的外部任务工件,不是 Contract,不授予执行权
542
581
  首阶段:
543
582
 
544
583
  ```bash
545
- npx project-context stage-context \
584
+ npm exec --offline -- project-context stage-context \
546
585
  --project . \
547
586
  --plan task-context-plan.json \
548
587
  --stage stage-understand \
@@ -553,7 +592,7 @@ npx project-context stage-context \
553
592
  后续阶段:
554
593
 
555
594
  ```bash
556
- npx project-context stage-context \
595
+ npm exec --offline -- project-context stage-context \
557
596
  --project . \
558
597
  --plan task-context-plan.json \
559
598
  --stage stage-render \
@@ -592,7 +631,7 @@ Task Context Plan
592
631
  ### 9.4 合并前只读审查
593
632
 
594
633
  ```bash
595
- npx project-context integration-review \
634
+ npm exec --offline -- project-context integration-review \
596
635
  --project . \
597
636
  --plan task-context-plan.json \
598
637
  --receipt stage-understand.receipt.json \
@@ -611,7 +650,7 @@ npx project-context integration-review \
611
650
  ### 10.1 本地只读看板
612
651
 
613
652
  ```bash
614
- npx project-context dashboard --project . > project-context-dashboard.html
653
+ npm exec --offline -- project-context dashboard --project . > project-context-dashboard.html
615
654
  ```
616
655
 
617
656
  Dashboard 是 stdout 生成的自包含离线 HTML,不会自动打开浏览器,不会修改 Contract。HTML 通常不提交。
@@ -669,6 +708,7 @@ npm run context:check
669
708
  | 现象 | 原因 | 处理 |
670
709
  | --- | --- | --- |
671
710
  | 命令显示了结果但文件没变 | 没有 `--write`,只做了 preview | 审查预览后,对同一条命令显式加 `--write` |
711
+ | 本地没有 `project-context` 命令 | 精确开发依赖尚未安装,或不在 npm script 环境 | 先经人授权安装 `frontend-project-context@1.7.0`,再使用 `npm exec --offline -- project-context`;不要运行 `npx project-context` |
672
712
  | `source-changed` | 来源内容与上次人工确认 digest 不同 | `sync` → `review-source` → 人确认 → `accept-source-change` → revise/deprecate/reapprove |
673
713
  | `source-missing` | 已登记本地来源不存在 | 先判断是移动、暂时缺失还是永久退役;不自动修复 |
674
714
  | `projection-ownership-conflict` | 受管投影被人或其他工具修改,或目标本就不属于本工具 | 保留现有文件,人判断合并、换路径或重新建立 ownership;不强制覆盖 |
@@ -777,6 +817,9 @@ Receipt 只记录阶段证据,不代表人已验收、合并或批准长期规
777
817
  | `propose` | 创建待审的合同项 | 仅保存 proposal 时 `--write` |
778
818
  | `approve` | 批准 proposal 或 pending 中的精确 ID | 仅显式 `--write` |
779
819
  | `context` | 按路径/任务编译最小上下文 | 否 |
820
+ | `context-query` | 按任务编译自适应证据闭包、健康、新鲜度和预算 | 否 |
821
+ | `coverage-audit` | 审计声明范围内的登记覆盖 | 否 |
822
+ | `index-context` | 构建可删除的派生路由索引 | 仅显式 `--write` |
780
823
  | `publish` | 生成受管 AGENTS 或 Ruler 投影 | 仅显式 `--write` |
781
824
  | `check` | 检测来源、合同和投影漂移 | 否 |
782
825
  | `sync` | 聚合变化、影响集、路径信号和维护工作单元 | 否 |
@@ -793,5 +836,5 @@ Receipt 只记录阶段证据,不代表人已验收、合并或批准长期规
793
836
  完整且以当前安装版本为准的语法,始终通过以下命令查看:
794
837
 
795
838
  ```bash
796
- npx project-context --help
839
+ npm exec --offline -- project-context --help
797
840
  ```
@@ -33,9 +33,9 @@ npm run context:preflight -- --plan .project-context/action-plan.json --json
33
33
  采用分阶段上下文协议时,宿主必须把每份前序 Stage Receipt 与生成该 receipt 的 Stage Context Bundle 成对传入:
34
34
 
35
35
  ```bash
36
- npx project-context stage-context --project . --plan task-context-plan.json --stage stage-render \
36
+ npm exec --offline -- project-context stage-context --project . --plan task-context-plan.json --stage stage-render \
37
37
  --receipt stage-understand.receipt.json --receipt-bundle stage-understand.bundle.json --json
38
- npx project-context integration-review --project . --plan task-context-plan.json \
38
+ npm exec --offline -- project-context integration-review --project . --plan task-context-plan.json \
39
39
  --receipt stage-understand.receipt.json --receipt-bundle stage-understand.bundle.json --json
40
40
  ```
41
41
 
@@ -53,8 +53,8 @@ Host 在产品边界外把依赖和 lockfile 固定到精确目标版本后,
53
53
 
54
54
  ```bash
55
55
  npm run context:upgrade-check -- --from-version 1.5.0 --json
56
- npx project-context upgrade-plan --project . --assessment .project-context/upgrade-assessment.json --json
57
- npx project-context upgrade-apply --project . --plan .project-context/migration-plan.json --json
56
+ npm exec --offline -- project-context upgrade-plan --project . --assessment .project-context/upgrade-assessment.json --json
57
+ npm exec --offline -- project-context upgrade-apply --project . --plan .project-context/migration-plan.json --json
58
58
  ```
59
59
 
60
60
  只有人审查精确 plan 后才可为最后一条命令增加 `--write`。每次只执行一个产品自有迁移单元;包管理器、Git、项目测试、独立新窗口复核和临时工件清理由 Host 负责。
@@ -14,6 +14,6 @@
14
14
  "context:upgrade-check": "project-context upgrade-check --project ."
15
15
  },
16
16
  "devDependencies": {
17
- "frontend-project-context": "1.6.0"
17
+ "frontend-project-context": "1.7.0"
18
18
  }
19
19
  }
@@ -22,19 +22,26 @@
22
22
  ],
23
23
  "consumerChanges": {
24
24
  "actionPlan": {"reason": "Action Plan schema 1 and 2 readers remain compatible; writers remain schema 2.", "state": "preserve"},
25
- "capabilities": {"reason": "Consumers must branch on capabilities schema 4 and exchange protocol 4.", "state": "regenerate"},
25
+ "adaptiveContextBundle": {"reason": "Schema 1 Adaptive Context Bundles lack task lineage and strict withheld-delivery semantics; regenerate as schema 2.", "state": "regenerate"},
26
+ "capabilities": {"reason": "Consumers must branch on capabilities schema 7 and exchange protocol 7.", "state": "regenerate"},
27
+ "contextQuery": {"reason": "Context Query schema 1 is short-lived and must use current snapshots.", "state": "regenerate"},
28
+ "coverageAudit": {"reason": "Coverage Audit schema 1 is derived from the current Contract and filesystem evidence.", "state": "regenerate"},
26
29
  "evidenceBundle": {"reason": "Evidence Bundle schema 1 remains readable and separate from upgrade results.", "state": "preserve"},
27
30
  "evidenceInput": {"reason": "Evidence Input schema 1 remains readable and is never rewritten by upgrade.", "state": "preserve"},
28
- "exchange": {"reason": "Exchange protocol capability metadata changes to version 4.", "state": "regenerate"},
31
+ "exchange": {"reason": "Exchange protocol capability metadata changes to version 7.", "state": "regenerate"},
32
+ "hostPromotionEvidence": {"reason": "Host Promotion Evidence is short-lived and remains bound to exact code, artifact, and Project Context snapshots.", "state": "regenerate"},
29
33
  "integrationReviewBundle": {"reason": "Short-lived integration review bundles must be regenerated against current baselines.", "state": "regenerate"},
30
34
  "reviewBundle": {"reason": "Review Bundle schema 2 remains readable but short-lived reviews must be regenerated when their baselines change.", "state": "regenerate"},
35
+ "routingIndex": {"reason": "Routing Index schema 1 is disposable derived data and must be rebuilt from the current Contract.", "state": "invalidate"},
31
36
  "stageContextBundle": {"reason": "Short-lived stage context bundles must be regenerated against current receipts.", "state": "regenerate"},
32
37
  "stageReceipt": {"reason": "Existing receipts remain evidence but do not grant next-stage or upgrade authority.", "state": "preserve"},
33
38
  "taskContextPlan": {"reason": "Short-lived task plans must be regenerated when their project baselines change.", "state": "regenerate"}
39
+ ,"truthReconciliationInput": {"reason": "Schema 1 inputs lack previous-review-bound resolution attempts; regenerate as schema 2 from the current baseline.", "state": "regenerate"}
40
+ ,"truthReconciliationReviewBundle": {"reason": "Schema 1 reviews lack finding digests and machine-verifiable resolution outcomes; recompute as schema 2.", "state": "regenerate"}
34
41
  },
35
42
  "externalEffects": {"automaticUpgrade": false, "businessCode": false, "git": false, "network": false, "packageManager": false, "projectTests": false},
36
- "manifestDigest": "sha256:071f7461ae5669a6d78657bb81ec019a5508919a8f2de8640ba48eaec1343101",
37
- "package": {"name": "frontend-project-context", "version": "1.6.0"},
43
+ "manifestDigest": "sha256:34b1b611ebf31471f2e136eb3f84ad627df612998d0358654e7cdde4713de777",
44
+ "package": {"name": "frontend-project-context", "version": "1.7.0"},
38
45
  "paths": [
39
46
  {
40
47
  "acceptance": ["project-context-clean", "target-renderers-current"],
@@ -59,21 +66,36 @@
59
66
  "migrationIds": ["upgrade.republish-ai-entry.v1", "upgrade.republish-projection.v1"],
60
67
  "requiresHumanReview": false,
61
68
  "rollbackClass": "package-only"
69
+ },
70
+ {
71
+ "acceptance": ["project-context-clean", "target-renderers-current"],
72
+ "classification": "package-only",
73
+ "fromVersion": "1.6.0",
74
+ "migrationIds": ["upgrade.republish-ai-entry.v1"],
75
+ "requiresHumanReview": false,
76
+ "rollbackClass": "package-only"
62
77
  }
63
78
  ],
64
79
  "protocols": {
65
80
  "actionPlan": {"readable": [1, 2], "written": 2},
81
+ "adaptiveContextBundle": {"readable": [2], "written": 2},
82
+ "contextQuery": {"readable": [2], "written": 2},
83
+ "coverageAudit": {"readable": [1], "written": 1},
66
84
  "evidenceBundle": {"readable": [1], "written": 1},
67
85
  "evidenceInput": {"readable": [1], "written": 1},
68
- "exchange": {"readable": [4], "written": 4},
86
+ "exchange": {"readable": [4, 5, 6, 7], "written": 7},
87
+ "hostPromotionEvidence": {"readable": [1], "written": 1},
69
88
  "integrationReviewBundle": {"readable": [1], "written": 1},
70
89
  "reviewBundle": {"readable": [1, 2], "written": 2},
90
+ "routingIndex": {"readable": [1, 2], "written": 2},
71
91
  "stageContextBundle": {"readable": [1], "written": 1},
72
92
  "stageReceipt": {"readable": [1], "written": 1},
73
- "taskContextPlan": {"readable": [1], "written": 1}
93
+ "taskContextPlan": {"readable": [1], "written": 1},
94
+ "truthReconciliationInput": {"readable": [2], "written": 2},
95
+ "truthReconciliationReviewBundle": {"readable": [2], "written": 2}
74
96
  },
75
97
  "renderers": {
76
- "aiEntry": {"readable": [1], "written": 1},
98
+ "aiEntry": {"readable": [1, 2, 3], "written": 3},
77
99
  "projection": {"readable": [1, 2, 3], "written": 3}
78
100
  },
79
101
  "rollback": {"automatic": false, "defaultClass": "package-only", "externalRestoreRequired": true},
@@ -84,5 +106,5 @@
84
106
  "proposal": {"readable": [1], "written": [1]},
85
107
  "sourceLock": {"readable": [1], "written": [1]}
86
108
  },
87
- "upgradeFrom": ["1.3.1", "1.4.0", "1.5.0"]
109
+ "upgradeFrom": ["1.3.1", "1.4.0", "1.5.0", "1.6.0"]
88
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frontend-project-context",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Govern, compile, and verify project-local context for AI coding tools.",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "scripts": {
29
29
  "check": "node --check bin/project-context.mjs && npm test",
30
- "test": "node --test test/project-context/acceptance.test.mjs test/project-context/assist.test.mjs test/project-context/cli.test.mjs test/project-context/dashboard.test.mjs test/project-context/evidence.test.mjs test/project-context/exchange.test.mjs test/project-context/maintenance.test.mjs test/project-context/source-lifecycle.test.mjs test/project-context/task-context.test.mjs test/project-context/takeover.test.mjs test/project-context/upgrade.test.mjs test/release/acceptance.test.mjs",
30
+ "test": "node --test test/project-context/acceptance.test.mjs test/project-context/adaptive-context.test.mjs test/project-context/adaptive-delivery-v2.test.mjs test/project-context/assist.test.mjs test/project-context/cli.test.mjs test/project-context/dashboard.test.mjs test/project-context/evidence.test.mjs test/project-context/exchange.test.mjs test/project-context/maintenance.test.mjs test/project-context/source-lifecycle.test.mjs test/project-context/task-context.test.mjs test/project-context/takeover.test.mjs test/project-context/truth-reconciliation.test.mjs test/project-context/upgrade.test.mjs test/release/acceptance.test.mjs",
31
31
  "prepack": "npm run check"
32
32
  },
33
33
  "engines": {
@@ -0,0 +1,70 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "urn:frontend-project-context:schema:adaptive-context-bundle:2",
4
+ "title": "Frontend Project Context Adaptive Context Bundle",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schemaVersion", "kind", "project", "task", "queryDigest", "taskDigest", "level", "expansionDepth", "snapshots", "routing", "guarantees", "globalHealth", "taskHealth", "targetStates", "hydratedItems", "retainedItemIds", "deferredItems", "sources", "evidenceEdges", "readTargets", "findings", "excluded", "metrics", "budget", "delivery", "bundleDigest"],
8
+ "properties": {
9
+ "schemaVersion": { "const": 2 },
10
+ "kind": { "const": "adaptive-context-bundle" },
11
+ "project": { "type": "object", "additionalProperties": false, "required": ["id", "name"], "properties": { "id": { "type": "string" }, "name": { "type": "string" } } },
12
+ "task": { "$ref": "context-query.schema.json#/properties/task" },
13
+ "queryDigest": { "$ref": "#/$defs/digest" },
14
+ "taskDigest": { "$ref": "#/$defs/digest" },
15
+ "previousBundleDigest": { "$ref": "#/$defs/digest" },
16
+ "level": { "enum": ["initial", "expanded", "complete"] },
17
+ "expansionDepth": { "type": "integer", "minimum": 0, "maximum": 1 },
18
+ "snapshots": { "$ref": "context-query.schema.json#/$defs/snapshots" },
19
+ "routing": { "type": "object", "additionalProperties": false, "required": ["indexDigest", "indexState"], "properties": { "indexDigest": { "$ref": "#/$defs/digest" }, "indexState": { "enum": ["current", "invalid-rebuilt-in-memory", "stale-rebuilt-in-memory", "missing-rebuilt-in-memory"] }, "rejectedDigest": { "$ref": "#/$defs/digest" } } },
20
+ "guarantees": { "type": "object", "additionalProperties": false, "required": ["registrationCoverage", "mandatoryCoverage", "declaredDependencyCoverage", "retrievalStatus", "semanticCompleteness", "freshness"], "properties": { "registrationCoverage": { "type": "string" }, "mandatoryCoverage": { "enum": ["complete", "blocked"] }, "declaredDependencyCoverage": { "enum": ["complete", "missing", "not-declared"] }, "retrievalStatus": { "enum": ["matched", "no-candidate", "ambiguous", "complete"] }, "semanticCompleteness": { "const": "not-claimed" }, "freshness": { "enum": ["strict-current", "snapshot-and-signal-bound"] } } },
21
+ "globalHealth": { "enum": ["clean", "attention", "conflict", "not-checked", "snapshot-stale"] },
22
+ "taskHealth": { "enum": ["ready", "needs-expansion", "blocked"] },
23
+ "targetStates": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": ["path", "state"], "properties": { "path": { "type": "string" }, "state": { "enum": ["existing", "prospective-or-deleted"] } } } },
24
+ "hydratedItems": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": ["id", "kind", "subject", "value", "statement", "scope", "sourceIds", "overrides", "selectionReasons", "itemDigest"], "properties": { "id": { "$ref": "#/$defs/id" }, "kind": { "enum": ["fact", "policy", "reference", "validation-description"] }, "subject": { "$ref": "#/$defs/id" }, "value": {}, "statement": { "type": "string", "minLength": 1 }, "scope": { "$ref": "#/$defs/scope" }, "sourceIds": { "$ref": "#/$defs/ids" }, "overrides": { "$ref": "#/$defs/ids" }, "verification": {}, "selectionReasons": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } }, "itemDigest": { "$ref": "#/$defs/digest" } } } },
25
+ "retainedItemIds": { "type": "array", "uniqueItems": true, "items": { "type": "string" } },
26
+ "deferredItems": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": ["id", "kind", "subject", "scope", "sourceIds", "itemDigest", "reason"], "properties": { "id": { "$ref": "#/$defs/id" }, "kind": { "enum": ["fact", "policy", "reference", "validation-description"] }, "subject": { "$ref": "#/$defs/id" }, "scope": { "$ref": "#/$defs/scope" }, "sourceIds": { "$ref": "#/$defs/ids" }, "itemDigest": { "$ref": "#/$defs/digest" }, "reason": { "const": "applicable-not-selected" } } } },
27
+ "sources": { "type": "array", "items": { "$ref": "#/$defs/sourceEvidence" } },
28
+ "evidenceEdges": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": ["itemId", "sourceId"], "properties": { "itemId": { "type": "string" }, "sourceId": { "type": "string" } } } },
29
+ "readTargets": { "type": "array", "items": { "$ref": "#/$defs/readTarget" } },
30
+ "findings": { "type": "array", "items": { "$ref": "#/$defs/finding" } },
31
+ "excluded": { "type": "array", "uniqueItems": true, "items": { "type": "string" } },
32
+ "metrics": { "type": "object", "additionalProperties": false, "required": ["sourceDigestReads", "sourceBodyReads", "sourceIdentityReads", "hydratedItemCount", "retainedItemCount", "deferredItemCount", "hostToolCalls"], "properties": { "sourceDigestReads": { "type": "integer" }, "sourceBodyReads": { "type": "integer" }, "sourceIdentityReads": { "type": "integer" }, "hydratedItemCount": { "type": "integer" }, "retainedItemCount": { "type": "integer" }, "deferredItemCount": { "type": "integer" }, "hostToolCalls": { "const": 1 } } },
33
+ "budget": { "type": "object", "additionalProperties": false, "required": ["unit", "audit", "delivery", "readTargets"], "properties": { "unit": { "const": "canonical-utf8-bytes" }, "audit": { "$ref": "#/$defs/auditBudget" }, "delivery": { "$ref": "#/$defs/deliveryBudget" }, "readTargets": { "$ref": "#/$defs/readBudget" } } },
34
+ "delivery": {
35
+ "type": "object",
36
+ "additionalProperties": false,
37
+ "required": ["status", "format", "mode", "itemIds", "contentDigest", "utf8Bytes"],
38
+ "properties": {
39
+ "status": { "enum": ["ready", "withheld"] },
40
+ "format": { "const": "project-context-markdown" },
41
+ "mode": { "type": ["string", "null"], "enum": ["adaptive", "complete", null] },
42
+ "itemIds": { "type": "array", "uniqueItems": true, "items": { "type": "string" } },
43
+ "contentDigest": { "oneOf": [{ "$ref": "#/$defs/digest" }, { "type": "null" }] },
44
+ "utf8Bytes": { "type": "integer", "minimum": 0 }
45
+ }
46
+ },
47
+ "bundleDigest": { "$ref": "#/$defs/digest" }
48
+ },
49
+ "$defs": {
50
+ "id": { "type": "string", "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$" },
51
+ "digest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
52
+ "nullableDigest": { "oneOf": [{ "$ref": "#/$defs/digest" }, { "type": "null" }] },
53
+ "ids": { "type": "array", "uniqueItems": true, "items": { "$ref": "#/$defs/id" } },
54
+ "paths": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
55
+ "scope": { "oneOf": [
56
+ { "type": "object", "additionalProperties": false, "required": ["kind"], "properties": { "kind": { "const": "project" } } },
57
+ { "type": "object", "additionalProperties": false, "required": ["kind", "path"], "properties": { "kind": { "enum": ["path-prefix", "file"] }, "path": { "type": "string", "minLength": 1 } } }
58
+ ] },
59
+ "locator": { "oneOf": [
60
+ { "type": "object", "additionalProperties": false, "required": ["path"], "properties": { "path": { "type": "string", "minLength": 1 }, "pointer": { "type": "string" } } },
61
+ { "type": "object", "additionalProperties": false, "required": ["reference"], "properties": { "reference": { "type": "string", "minLength": 1 } } }
62
+ ] },
63
+ "sourceEvidence": { "type": "object", "additionalProperties": false, "required": ["id", "kind", "locator", "sourceDigest", "freshness"], "properties": { "id": { "$ref": "#/$defs/id" }, "kind": { "type": "string", "minLength": 1 }, "locator": { "$ref": "#/$defs/locator" }, "sourceDigest": { "$ref": "#/$defs/digest" }, "freshness": { "enum": ["current", "drifted", "unreadable", "unverifiable-non-local"] }, "expectedDigest": { "$ref": "#/$defs/nullableDigest" }, "actualDigest": { "$ref": "#/$defs/nullableDigest" } } },
64
+ "readTarget": { "type": "object", "additionalProperties": false, "required": ["path", "reason"], "properties": { "path": { "type": "string", "minLength": 1 }, "reason": { "enum": ["task-target", "host-changed-path-signal", "contract-source"] }, "sourceId": { "$ref": "#/$defs/id" } } },
65
+ "finding": { "type": "object", "additionalProperties": false, "required": ["code", "severity"], "properties": { "code": { "type": "string", "minLength": 1 }, "severity": { "enum": ["attention", "needs-expansion", "blocked"] }, "itemId": { "$ref": "#/$defs/id" }, "requiredItemId": { "$ref": "#/$defs/id" }, "sourceId": { "$ref": "#/$defs/id" }, "subject": { "$ref": "#/$defs/id" }, "itemIds": { "$ref": "#/$defs/ids" }, "path": { "type": "string", "minLength": 1 }, "paths": { "$ref": "#/$defs/paths" }, "expected": {}, "actual": {}, "expectedDigest": { "$ref": "#/$defs/nullableDigest" }, "actualDigest": { "$ref": "#/$defs/nullableDigest" }, "reason": { "type": "string", "minLength": 1 }, "state": { "type": "string", "minLength": 1 }, "target": { "type": "integer", "minimum": 0 }, "limit": { "type": "integer", "minimum": 0 }, "required": { "type": "integer", "minimum": 0 }, "conflicts": { "type": "array" }, "projectFinding": {} } },
66
+ "auditBudget": { "type": "object", "additionalProperties": false, "required": ["targetUtf8Bytes", "maxUtf8Bytes", "usedUtf8Bytes"], "properties": { "targetUtf8Bytes": { "type": "integer", "minimum": 1 }, "maxUtf8Bytes": { "type": "integer", "minimum": 1 }, "usedUtf8Bytes": { "type": "integer", "minimum": 1 } } },
67
+ "deliveryBudget": { "type": "object", "additionalProperties": false, "required": ["completeBelowUtf8Bytes", "maxUtf8Bytes", "usedUtf8Bytes"], "properties": { "completeBelowUtf8Bytes": { "type": "integer", "minimum": 1 }, "maxUtf8Bytes": { "type": "integer", "minimum": 1 }, "usedUtf8Bytes": { "type": "integer", "minimum": 0 } } },
68
+ "readBudget": { "type": "object", "additionalProperties": false, "required": ["target", "max", "count"], "properties": { "target": { "type": "integer", "minimum": 1 }, "max": { "type": "integer", "minimum": 1 }, "count": { "type": "integer", "minimum": 0 } } }
69
+ }
70
+ }