frontend-project-context 1.6.0 → 1.8.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 (60) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +101 -48
  3. package/UPGRADING.md +30 -1
  4. package/docs/05-ACCEPTANCE-CONTRACT.md +20 -1
  5. package/docs/08-INSTALLATION-AND-DISTRIBUTION.md +62 -22
  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/27-TEAM-SHARED-CONTEXT-DIRECTION-DISCUSSION.md +30 -0
  15. package/docs/28-REAL-PROJECT-ONBOARDING-CLOSURE-DESIGN.md +534 -0
  16. package/docs/AI-PROJECT-INITIALIZATION.md +89 -0
  17. package/docs/README.md +34 -6
  18. package/docs/USER-AND-AI-OPERATION-MANUAL.md +87 -40
  19. package/examples/README.md +6 -6
  20. package/examples/package.json +1 -1
  21. package/migration-manifest.json +42 -8
  22. package/package.json +2 -2
  23. package/schemas/adaptive-context-bundle.schema.json +70 -0
  24. package/schemas/capabilities.schema.json +37 -8
  25. package/schemas/context-query.schema.json +69 -0
  26. package/schemas/coverage-audit.schema.json +32 -0
  27. package/schemas/evidence-bundle.schema.json +2 -2
  28. package/schemas/host-promotion-evidence.schema.json +33 -0
  29. package/schemas/initialization-instruction.schema.json +60 -0
  30. package/schemas/migration-manifest.schema.json +3 -3
  31. package/schemas/migration-plan.schema.json +2 -2
  32. package/schemas/project-status.schema.json +5 -4
  33. package/schemas/projection-lock.schema.json +1 -1
  34. package/schemas/routing-index.schema.json +58 -0
  35. package/schemas/truth-reconciliation-input.schema.json +60 -0
  36. package/schemas/truth-reconciliation-review-bundle.schema.json +155 -0
  37. package/schemas/upgrade-assessment.schema.json +2 -2
  38. package/schemas/upgrade-result-bundle.schema.json +1 -1
  39. package/src/project-context/a130-evaluation.mjs +91 -0
  40. package/src/project-context/adaptive-context-schema.mjs +392 -0
  41. package/src/project-context/adaptive-context.mjs +547 -0
  42. package/src/project-context/ai-entry.mjs +11 -9
  43. package/src/project-context/assist.mjs +4 -2
  44. package/src/project-context/capabilities.mjs +32 -0
  45. package/src/project-context/checker.mjs +4 -3
  46. package/src/project-context/cli.mjs +55 -5
  47. package/src/project-context/contract-schema.mjs +1 -1
  48. package/src/project-context/discovery.mjs +7 -7
  49. package/src/project-context/exchange-schema.mjs +6 -5
  50. package/src/project-context/initialization-instruction.mjs +42 -0
  51. package/src/project-context/maintenance.mjs +2 -2
  52. package/src/project-context/migration-manifest.mjs +7 -5
  53. package/src/project-context/project-status.mjs +14 -3
  54. package/src/project-context/project-store.mjs +27 -2
  55. package/src/project-context/renderer.mjs +75 -1
  56. package/src/project-context/source-reader.mjs +63 -30
  57. package/src/project-context/task-context.mjs +14 -2
  58. package/src/project-context/truth-reconciliation-schema.mjs +488 -0
  59. package/src/project-context/truth-reconciliation.mjs +543 -0
  60. package/src/project-context/upgrade-schema.mjs +5 -1
package/docs/README.md CHANGED
@@ -8,6 +8,18 @@
8
8
 
9
9
  固定产品身份、内核、永久边界、v1 完成条件、真实项目规则、需求分类和阶段停止规则。动态的当前事实、授权和下一步由 `PROJECT_STATE.json` 唯一记录;其他文档与宪法冲突时,以宪法为准。
10
10
 
11
+ ## 讨论记录
12
+
13
+ [27-TEAM-SHARED-CONTEXT-DIRECTION-DISCUSSION.md](./27-TEAM-SHARED-CONTEXT-DIRECTION-DISCUSSION.md)
14
+
15
+ 记录 `2026-09-14` 关于“让团队共同拥有同一份项目上下文”的产品意义、真实项目应用重点,以及 Stateful Agent、Persistent KV 和增量上下文的远期讨论方向。该文档仅供团队查看和继续讨论,不是冻结设计、路线或实现授权。
16
+
17
+ ## 已冻结、待实现设计
18
+
19
+ [28-REAL-PROJECT-ONBOARDING-CLOSURE-DESIGN.md](./28-REAL-PROJECT-ONBOARDING-CLOSURE-DESIGN.md)
20
+
21
+ 基于 `2026-09-15` 在真实 `dtg-tmc-pc` 隔离副本中的正式接入与无历史 Host 接管过程,`1.8.0 — Real Project Onboarding Closure` 冻结并完成:包内唯一初始化指令、严格 targetRoot、目标入口治理、完整 proposal 一次语义确认、AI Entry renderer 4、project-status schema 2、O-01 至 O-12 以及无历史 Host 发布门。实现与 Host 验收事实见 `docs/28` 第 13、14 节;当前只执行用户另行授权的发布流程。
22
+
11
23
  ## 支持性设计文档
12
24
 
13
25
  1. [01-PRODUCT-CORE.md](./01-PRODUCT-CORE.md)
@@ -48,7 +60,7 @@
48
60
 
49
61
  10. [14-FORMAL-RELEASE-READINESS.md](./14-FORMAL-RELEASE-READINESS.md)
50
62
 
51
- 记录 `1.0.0` 正式发布、`1.0.1` README/metadata patch 与 `1.2.0` AI Exchange Boundary 发布:包边界、项目接入、CI、迁移、验收、registry 完整性和不伪造公共仓库链接的决定。
63
+ 记录 `1.0.0`、`1.0.1`、`1.2.0`、`1.3.x` 与 `1.6.0` 正式发布:包边界、项目接入、CI、迁移、验收、registry 完整性和不伪造公共仓库链接的决定。
52
64
 
53
65
  11. [15-SOURCE-LIFECYCLE-CLOSURE-DESIGN.md](./15-SOURCE-LIFECYCLE-CLOSURE-DESIGN.md)
54
66
 
@@ -80,22 +92,38 @@
80
92
 
81
93
  18. [22-PHASE-C-TARGET-UPGRADE-PROTOCOL-DESIGN.md](./22-PHASE-C-TARGET-UPGRADE-PROTOCOL-DESIGN.md)
82
94
 
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 发布候选流程,真实目标项目验收仍未授权。
95
+ 冻结并记录 `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 独立复验均已通过,真实目标项目验收仍未授权。
96
+
97
+ 19. [23-ADAPTIVE-BOUNDED-TASK-CONTEXT-DESIGN.md](./23-ADAPTIVE-BOUNDED-TASK-CONTEXT-DESIGN.md)
98
+
99
+ 用反证方式冻结并记录 `1.7.0` 初始本地实现与历史复验;当前 docs/26 统一修复已在其上完成,完整回归增至 194/194。历史真实 Host/Provider 复验仍为完整 8/8、自适应 7/8,新的复验与发布均未授权。
100
+
101
+ 20. [24-A130-REAL-HOST-TARGET-PROJECT-COMPARISON.md](./24-A130-REAL-HOST-TARGET-PROJECT-COMPARISON.md)
102
+
103
+ 记录 `dtg-tmc-pc` 上首次对照及 A-130R 后的成对复验。复验中自适应首包降至 5,283 字节,但质量仍为 7/8,对照完整臂为 8/8,且 tokens、命令数与耗时均未改善,故 A-130 严格失败;原目标仓库始终未修改。
104
+
105
+ 21. [25-REAL-PROJECT-SOURCE-OF-TRUTH-MAINTENANCE-DESIGN.md](./25-REAL-PROJECT-SOURCE-OF-TRUTH-MAINTENANCE-DESIGN.md)
106
+
107
+ 冻结真实项目全量应用下的真源维护设计,并完成隔离协议 fixture。裁定失败后的机器闭环已由 docs/26 升级为 Truth Reconciliation Input/Review Bundle schema 2、previous Review 绑定与可验证终态;A-144、Sidecar 和真实项目写入仍未授权。
108
+
109
+ 22. [26-A130-QUALITY-CLOSURE-AND-ADAPTIVE-DELIVERY-REPAIR-DESIGN.md](./26-A130-QUALITY-CLOSURE-AND-ADAPTIVE-DELIVERY-REPAIR-DESIGN.md)
110
+
111
+ 冻结并完成 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
112
 
85
113
  ## 历史证据
86
114
 
87
- 19. [06-HISTORICAL-PROTOTYPE.md](./06-HISTORICAL-PROTOTYPE.md)
88
- 20. [07-REAL-TASK-EVIDENCE.md](./07-REAL-TASK-EVIDENCE.md)
115
+ 23. [06-HISTORICAL-PROTOTYPE.md](./06-HISTORICAL-PROTOTYPE.md)
116
+ 24. [07-REAL-TASK-EVIDENCE.md](./07-REAL-TASK-EVIDENCE.md)
89
117
 
90
118
  历史文档只解释为什么不再建设任务执行 Harness。它们不是程序需求、工作流或授权来源。
91
119
 
92
120
  ## Beta 证据
93
121
 
94
- 21. [09-B0-DTG-TMC-MOBILE.md](./09-B0-DTG-TMC-MOBILE.md)
122
+ 25. [09-B0-DTG-TMC-MOBILE.md](./09-B0-DTG-TMC-MOBILE.md)
95
123
 
96
124
  记录首次真实项目只读接入、通用修补和同项目回归。报告中的历史“下一步”不再产生新需求。
97
125
 
98
- 22. [10-B0-DTG-TMC-PC.md](./10-B0-DTG-TMC-PC.md)
126
+ 26. [10-B0-DTG-TMC-PC.md](./10-B0-DTG-TMC-PC.md)
99
127
 
100
128
  记录第二个真实项目只读接入和跨项目对比:核心链路与首轮通用修补再次通过。产品宪法已经停止继续寻找项目和扩充技术发现白名单。
101
129
 
@@ -1,6 +1,6 @@
1
1
  # Frontend Project Context 操作手册
2
2
 
3
- > 适用版本:`frontend-project-context@1.3.1`
3
+ > 适用版本:`frontend-project-context@1.8.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.8.0
105
105
  ```
106
106
 
107
107
  建议在 `package.json` 中提供稳定入口:
@@ -120,18 +120,38 @@ 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 instructions --project . --prompt
125
+ npm exec --offline -- project-context capabilities --project . --json
126
+ npm exec --offline -- project-context status --project . --json
125
127
  ```
126
128
 
127
- `capabilities` 在项目未初始化时也可用,适合 AI Host 先查询当前包版本、schema、支持的 action kind 和永久边界。
129
+ 所有正式命令都通过 `npm exec --offline -- project-context` 或上面的项目脚本调用。`--offline` 会在本地依赖缺失时失败封闭,不能退回 registry 下载无关的同名 `project-context` 包。持久初始化必须发生在精确版本安装之后,避免后续补装依赖改变已登记的 `package.json` source digest。
128
130
 
129
- ## 5. 首次接入 SOP
131
+ `instructions` `capabilities` 在项目未初始化时也可用。初始化的唯一规范正文是 [AI-PROJECT-INITIALIZATION.md](./AI-PROJECT-INITIALIZATION.md);本手册只引用它,不另行定义执行顺序。
130
132
 
131
- ### 1 步:只读预览初始化结果
133
+ `1.8.0` AI Entry renderer 4 固定离线项目本地 CLI 入口,并要求 clean 状态的真实任务先运行 task/path `context`、消费实际命中的 item IDs、scope 与 read targets。既有 renderer 1/2/3 不会被静默覆盖,升级后会报告 stale,必须先预览并获得明确写入授权再 republish。
134
+
135
+ ### 4.3 全新初始化不是普通升级
136
+
137
+ 再次运行 `setup` 会复用现有 store,不会 reset,也不会把已经批准的英文 statement 自动翻译成中文。确需使用正式包全新初始化时,必须先:
138
+
139
+ 1. 导出并人工核对现有 Contract 中的 policy、validation-description、manual source 和批准决定;
140
+ 2. 使用当前所有权记录预览并显式执行 `remove-entry`,只移除受管区域,保留 `AGENTS.md` 其余人工内容;
141
+ 3. 由人明确授权外部工具精确清理可丢弃的 `.project-context`,确认 `status.initialization.state=uninitialized`;
142
+ 4. 先安装精确版本,再按第 5 节重新 setup、审查、录入和批准被保留的人工规则;
143
+ 5. 如果 `AGENTS.md` 同时是 active source,发布新 AI Entry 后继续完成预期的 source review、accept 和受影响 item 重新批准,直到 `check/status` 为 clean。
144
+
145
+ 工具没有自动 reset 命令,也不会把删除 store、翻译批准规则或接受 source drift 伪装成普通升级。
146
+
147
+ ## 5. 唯一初始化指令与底层原语参考
148
+
149
+ 首次接入只遵循 [AI-PROJECT-INITIALIZATION.md](./AI-PROJECT-INITIALIZATION.md)。下面保留的是单个 CLI 原语的参数参考,不是可由 Host 自行拼装的第二套初始化流程;语义审查、执行顺序、临时工件清理和完成门均以包内唯一指令为准。
150
+
151
+ ### 底层参考:setup 只读 preview
132
152
 
133
153
  ```bash
134
- npx project-context setup \
154
+ npm exec --offline -- project-context setup \
135
155
  --project . \
136
156
  --id my-project \
137
157
  --name "My Project" \
@@ -148,12 +168,12 @@ npx project-context setup \
148
168
 
149
169
  此时项目文件应保持不变。
150
170
 
151
- ### 2 步:明确同意创建 store 和 proposal
171
+ ### 底层参考:setup 的显式 bootstrap 写入
152
172
 
153
173
  确认项目 ID、名称和 proposal 路径后执行:
154
174
 
155
175
  ```bash
156
- npx project-context setup \
176
+ npm exec --offline -- project-context setup \
157
177
  --project . \
158
178
  --id my-project \
159
179
  --name "My Project" \
@@ -164,7 +184,7 @@ npx project-context setup \
164
184
 
165
185
  `setup --write` 只代表允许创建三个 store 和一份 create-only proposal,**不代表批准 proposal,也不代表允许生成 AGENTS/Ruler 投影**。
166
186
 
167
- ### 3 步:AI 只按 work unit 渐进读取
187
+ ### 底层参考:读取 work unit
168
188
 
169
189
  AI 应:
170
190
 
@@ -175,7 +195,7 @@ AI 应:
175
195
  5. 需要额外来源时,先说明原因并把它列为 source 候选;
176
196
  6. 不以“代码存在”推导出“团队长期 policy”。
177
197
 
178
- ### 第 4 步:补充来源和候选合同项
198
+ ### 底层参考:补充来源和候选合同项
179
199
 
180
200
  支持的来源类型:
181
201
 
@@ -188,7 +208,7 @@ AI 应:
188
208
  先预览,再在对象无误后重复同一命令并加 `--write`:
189
209
 
190
210
  ```bash
191
- npx project-context register \
211
+ npm exec --offline -- project-context register \
192
212
  --project . \
193
213
  --id source.package \
194
214
  --kind file \
@@ -198,7 +218,7 @@ npx project-context register \
198
218
  创建合同项 proposal:
199
219
 
200
220
  ```bash
201
- npx project-context propose \
221
+ npm exec --offline -- project-context propose \
202
222
  --project . \
203
223
  --id policy.ui-copy \
204
224
  --kind policy \
@@ -224,7 +244,7 @@ scope 只有:
224
244
  - `path-prefix`:指定目录及其后代;
225
245
  - `file`:单个文件。
226
246
 
227
- ### 第 5 步:人工集中审查
247
+ ### 底层参考:审查视图字段
228
248
 
229
249
  AI 必须先展示:
230
250
 
@@ -255,10 +275,10 @@ AI 必须先展示:
255
275
  应该没问题。
256
276
  ```
257
277
 
258
- ### 6 步:批准精确 ID
278
+ ### 底层参考:批准精确 ID
259
279
 
260
280
  ```bash
261
- npx project-context approve \
281
+ npm exec --offline -- project-context approve \
262
282
  --project . \
263
283
  --proposal .project-context/policy.ui-copy.proposal.json \
264
284
  --ids policy.ui-copy \
@@ -267,12 +287,12 @@ npx project-context approve \
267
287
 
268
288
  先看 preview,确认无误后才加 `--write`。一份 proposal 中未被 `--ids` 点名的 item 不会自动获得批准。
269
289
 
270
- ### 第 7 步:生成上下文和投影
290
+ ### 底层参考:生成上下文和投影
271
291
 
272
292
  为目标路径生成临时上下文:
273
293
 
274
294
  ```bash
275
- npx project-context context \
295
+ npm exec --offline -- project-context context \
276
296
  --project . \
277
297
  --path src \
278
298
  --locale zh-CN
@@ -281,7 +301,7 @@ npx project-context context \
281
301
  生成 AGENTS 投影:
282
302
 
283
303
  ```bash
284
- npx project-context publish \
304
+ npm exec --offline -- project-context publish \
285
305
  --project . \
286
306
  --target agents \
287
307
  --output src/AGENTS.md \
@@ -291,7 +311,7 @@ npx project-context publish \
291
311
  或生成 Ruler 投影:
292
312
 
293
313
  ```bash
294
- npx project-context publish \
314
+ npm exec --offline -- project-context publish \
295
315
  --project . \
296
316
  --target ruler \
297
317
  --output .ruler/project-context.md \
@@ -302,10 +322,10 @@ npx project-context publish \
302
322
 
303
323
  如果根 `AGENTS.md` 由人工或其他工具管理,不要覆盖。可以改为在无冲突的子目录生成受管 `AGENTS.md`,或使用 `.ruler/` 投影。
304
324
 
305
- ### 第 8 步:检查并提交
325
+ ### 底层参考:检查结果
306
326
 
307
327
  ```bash
308
- npx project-context check --project .
328
+ npm exec --offline -- project-context check --project .
309
329
  ```
310
330
 
311
331
  `check` clean 后,提交三个 store 和团队明确采用的受管投影。proposal 通常不提交。
@@ -315,7 +335,7 @@ npx project-context check --project .
315
335
  一般任务不需要重新扫描整个仓库。先根据任务的真实修改目标生成 Context Bundle:
316
336
 
317
337
  ```bash
318
- npx project-context context \
338
+ npm exec --offline -- project-context context \
319
339
  --project . \
320
340
  --path src/features/order \
321
341
  --path src/shared/request.ts \
@@ -325,6 +345,26 @@ npx project-context context \
325
345
 
326
346
  `--task` 是当次临时约束,只会进入这份 bundle,不会写回 Contract,也不会扩大开发权限。
327
347
 
348
+ `1.7.0` 本地实现也支持由 Host 提供 schema 1 Context Query,把原始任务文本、target paths、topics、changed paths、三个 snapshot 和软/硬预算一次传入:
349
+
350
+ ```bash
351
+ npm exec --offline -- project-context context-query \
352
+ --project . \
353
+ --input .project-context/context-query.json \
354
+ --json
355
+ ```
356
+
357
+ `--json` 用于 Host 审查健康、deferred 目录与字节计量;真正传给模型时使用同一查询的 `--prompt`,不要把整份审查 JSON 当成模型上下文。小 Contract 中完整 Context 更小时会自动回退到完整投影。普通局部任务使用 `initial` + `snapshot-and-signal-bound`;证据不足时把前一份 bundle 保存后,以 `expanded` query 配合 `--previous` 增量扩展;要求绝对当前新鲜度时使用 `strict-current` 或 `complete`。policy/validation 不因软预算被截断,硬预算不足会返回 blocked。
358
+
359
+ 初始化、覆盖规则变化或显式审计时运行:
360
+
361
+ ```bash
362
+ npm exec --offline -- project-context coverage-audit --project . --json
363
+ npm exec --offline -- project-context index-context --project . --json
364
+ ```
365
+
366
+ `coverage-audit` 只证明已批准 coverage profile 的声明范围;不会输出“全部项目真源已发现”。`index-context` 默认只预览,从 Contract 确定性重建;只有人明确需要缓存时才加 `--write`,生成的 `.project-context/derived/routing-index.json` 不是 store 或真源。
367
+
328
368
  推荐把下面四类信息一起给外部 Coding Agent:
329
369
 
330
370
  1. 当次任务目标和验收标准;
@@ -335,7 +375,7 @@ npx project-context context \
335
375
  完成业务修改后,由外部 Agent、IDE 或 CI 把真实 changed paths 传给 `sync`:
336
376
 
337
377
  ```bash
338
- npx project-context sync \
378
+ npm exec --offline -- project-context sync \
339
379
  --project . \
340
380
  --changed-path src/features/order/detail.ts \
341
381
  --changed-path src/shared/request.ts \
@@ -361,7 +401,7 @@ check / sync
361
401
  ### 7.1 先一次汇总变化
362
402
 
363
403
  ```bash
364
- npx project-context sync --project . --json
404
+ npm exec --offline -- project-context sync --project . --json
365
405
  ```
366
406
 
367
407
  AI 应先交付变化清单,不应直接写入:
@@ -376,7 +416,7 @@ AI 应先交付变化清单,不应直接写入:
376
416
  ### 7.2 精确审查单个来源
377
417
 
378
418
  ```bash
379
- npx project-context review-source \
419
+ npm exec --offline -- project-context review-source \
380
420
  --project . \
381
421
  --id source.package \
382
422
  --json
@@ -387,7 +427,7 @@ npx project-context review-source \
387
427
  只有人确认 new digest 和完整 affected item IDs 后,才预览:
388
428
 
389
429
  ```bash
390
- npx project-context accept-source-change \
430
+ npm exec --offline -- project-context accept-source-change \
391
431
  --project . \
392
432
  --id source.package \
393
433
  --expected-digest sha256:NEW_DIGEST \
@@ -401,7 +441,7 @@ npx project-context accept-source-change \
401
441
  修订前必须使用当前 item digest:
402
442
 
403
443
  ```bash
404
- npx project-context revise \
444
+ npm exec --offline -- project-context revise \
405
445
  --project . \
406
446
  --id policy.ui-copy \
407
447
  --expected-item-digest sha256:CURRENT_ITEM_DIGEST \
@@ -417,7 +457,7 @@ npx project-context revise \
417
457
  废弃 item:
418
458
 
419
459
  ```bash
420
- npx project-context deprecate \
460
+ npm exec --offline -- project-context deprecate \
421
461
  --project . \
422
462
  --id policy.ui-copy \
423
463
  --expected-item-digest sha256:CURRENT_ITEM_DIGEST \
@@ -428,7 +468,7 @@ npx project-context deprecate \
428
468
  重新批准 pending item:
429
469
 
430
470
  ```bash
431
- npx project-context approve \
471
+ npm exec --offline -- project-context approve \
432
472
  --project . \
433
473
  --pending \
434
474
  --ids fact.node-version validation.check \
@@ -465,10 +505,10 @@ npx project-context approve \
465
505
  ### 8.1 查询协议能力
466
506
 
467
507
  ```bash
468
- npx project-context capabilities --project . --json
508
+ npm exec --offline -- project-context capabilities --project . --json
469
509
  ```
470
510
 
471
- `1.3.1` 支持八类 Action Plan action:
511
+ `1.7.0` 支持十类 Action Plan action:
472
512
 
473
513
  - `register-source`;
474
514
  - `propose-item`;
@@ -477,7 +517,9 @@ npx project-context capabilities --project . --json
477
517
  - `deprecate-item`;
478
518
  - `deprecate-source`;
479
519
  - `request-item-approval`;
480
- - `publish-projection`。
520
+ - `publish-projection`;
521
+ - `publish-ai-entry`;
522
+ - `remove-ai-entry`。
481
523
 
482
524
  ### 8.2 AI 生成无权限 Action Plan
483
525
 
@@ -488,7 +530,7 @@ Action Plan 中不得包含 Provider 调用、shell、Git、业务代码写入
488
530
  ### 8.3 只读预检
489
531
 
490
532
  ```bash
491
- npx project-context preflight \
533
+ npm exec --offline -- project-context preflight \
492
534
  --project . \
493
535
  --plan .project-context/action-plan.json \
494
536
  --json
@@ -542,7 +584,7 @@ Plan 是宿主提供的外部任务工件,不是 Contract,不授予执行权
542
584
  首阶段:
543
585
 
544
586
  ```bash
545
- npx project-context stage-context \
587
+ npm exec --offline -- project-context stage-context \
546
588
  --project . \
547
589
  --plan task-context-plan.json \
548
590
  --stage stage-understand \
@@ -553,7 +595,7 @@ npx project-context stage-context \
553
595
  后续阶段:
554
596
 
555
597
  ```bash
556
- npx project-context stage-context \
598
+ npm exec --offline -- project-context stage-context \
557
599
  --project . \
558
600
  --plan task-context-plan.json \
559
601
  --stage stage-render \
@@ -592,7 +634,7 @@ Task Context Plan
592
634
  ### 9.4 合并前只读审查
593
635
 
594
636
  ```bash
595
- npx project-context integration-review \
637
+ npm exec --offline -- project-context integration-review \
596
638
  --project . \
597
639
  --plan task-context-plan.json \
598
640
  --receipt stage-understand.receipt.json \
@@ -611,7 +653,7 @@ npx project-context integration-review \
611
653
  ### 10.1 本地只读看板
612
654
 
613
655
  ```bash
614
- npx project-context dashboard --project . > project-context-dashboard.html
656
+ npm exec --offline -- project-context dashboard --project . > project-context-dashboard.html
615
657
  ```
616
658
 
617
659
  Dashboard 是 stdout 生成的自包含离线 HTML,不会自动打开浏览器,不会修改 Contract。HTML 通常不提交。
@@ -669,6 +711,7 @@ npm run context:check
669
711
  | 现象 | 原因 | 处理 |
670
712
  | --- | --- | --- |
671
713
  | 命令显示了结果但文件没变 | 没有 `--write`,只做了 preview | 审查预览后,对同一条命令显式加 `--write` |
714
+ | 本地没有 `project-context` 命令 | 精确开发依赖尚未安装,或不在 npm script 环境 | 先经人授权安装 `frontend-project-context@1.7.0`,再使用 `npm exec --offline -- project-context`;不要运行 `npx project-context` |
672
715
  | `source-changed` | 来源内容与上次人工确认 digest 不同 | `sync` → `review-source` → 人确认 → `accept-source-change` → revise/deprecate/reapprove |
673
716
  | `source-missing` | 已登记本地来源不存在 | 先判断是移动、暂时缺失还是永久退役;不自动修复 |
674
717
  | `projection-ownership-conflict` | 受管投影被人或其他工具修改,或目标本就不属于本工具 | 保留现有文件,人判断合并、换路径或重新建立 ownership;不强制覆盖 |
@@ -769,6 +812,7 @@ Receipt 只记录阶段证据,不代表人已验收、合并或批准长期规
769
812
 
770
813
  | 命令 | 用途 | 是否可写 |
771
814
  | --- | --- | --- |
815
+ | `instructions` | 返回包内唯一初始化指令、digest 与 resolved targetRoot | 否 |
772
816
  | `capabilities` | 查询版本、schema、action kind 和永久边界 | 否 |
773
817
  | `setup` | 聚合安全初始化、保守 discovery 和 Assist Bundle | 仅显式 `--write` |
774
818
  | `init` | 创建空的三个 store | 仅显式 `--write` |
@@ -777,6 +821,9 @@ Receipt 只记录阶段证据,不代表人已验收、合并或批准长期规
777
821
  | `propose` | 创建待审的合同项 | 仅保存 proposal 时 `--write` |
778
822
  | `approve` | 批准 proposal 或 pending 中的精确 ID | 仅显式 `--write` |
779
823
  | `context` | 按路径/任务编译最小上下文 | 否 |
824
+ | `context-query` | 按任务编译自适应证据闭包、健康、新鲜度和预算 | 否 |
825
+ | `coverage-audit` | 审计声明范围内的登记覆盖 | 否 |
826
+ | `index-context` | 构建可删除的派生路由索引 | 仅显式 `--write` |
780
827
  | `publish` | 生成受管 AGENTS 或 Ruler 投影 | 仅显式 `--write` |
781
828
  | `check` | 检测来源、合同和投影漂移 | 否 |
782
829
  | `sync` | 聚合变化、影响集、路径信号和维护工作单元 | 否 |
@@ -793,5 +840,5 @@ Receipt 只记录阶段证据,不代表人已验收、合并或批准长期规
793
840
  完整且以当前安装版本为准的语法,始终通过以下命令查看:
794
841
 
795
842
  ```bash
796
- npx project-context --help
843
+ npm exec --offline -- project-context --help
797
844
  ```
@@ -2,10 +2,10 @@
2
2
 
3
3
  包实际发布后,把 [package.json](./package.json) 中的脚本和 devDependency 合并到项目,并把 [project-context-check.yml](./project-context-check.yml) 复制到 `.github/workflows/project-context-check.yml`。
4
4
 
5
- 维护者首次初始化:
5
+ 维护者首次初始化前先读取包内唯一指令;后续命令由该指令和一次集中语义确认驱动:
6
6
 
7
7
  ```bash
8
- npm run context:setup -- --id my-project --name "My Project" --write --json
8
+ npm exec --offline -- project-context instructions --project . --prompt
9
9
  ```
10
10
 
11
11
  为完全新窗口写入稳定入口并查询治理健康:
@@ -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.8.0"
18
18
  }
19
19
  }
@@ -22,19 +22,28 @@
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 8 and exchange protocol 8.", "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 8.", "state": "regenerate"},
32
+ "hostPromotionEvidence": {"reason": "Host Promotion Evidence is short-lived and remains bound to exact code, artifact, and Project Context snapshots.", "state": "regenerate"},
33
+ "initializationInstruction": {"reason": "Schema 1 is package-derived from the exact installed instruction and resolved target root.", "state": "regenerate"},
29
34
  "integrationReviewBundle": {"reason": "Short-lived integration review bundles must be regenerated against current baselines.", "state": "regenerate"},
35
+ "projectStatus": {"reason": "Schema 2 separates governance health from Contract readiness and task-context routing.", "state": "regenerate"},
30
36
  "reviewBundle": {"reason": "Review Bundle schema 2 remains readable but short-lived reviews must be regenerated when their baselines change.", "state": "regenerate"},
37
+ "routingIndex": {"reason": "Routing Index schema 1 is disposable derived data and must be rebuilt from the current Contract.", "state": "invalidate"},
31
38
  "stageContextBundle": {"reason": "Short-lived stage context bundles must be regenerated against current receipts.", "state": "regenerate"},
32
39
  "stageReceipt": {"reason": "Existing receipts remain evidence but do not grant next-stage or upgrade authority.", "state": "preserve"},
33
40
  "taskContextPlan": {"reason": "Short-lived task plans must be regenerated when their project baselines change.", "state": "regenerate"}
41
+ ,"truthReconciliationInput": {"reason": "Schema 1 inputs lack previous-review-bound resolution attempts; regenerate as schema 2 from the current baseline.", "state": "regenerate"}
42
+ ,"truthReconciliationReviewBundle": {"reason": "Schema 1 reviews lack finding digests and machine-verifiable resolution outcomes; recompute as schema 2.", "state": "regenerate"}
34
43
  },
35
44
  "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"},
45
+ "manifestDigest": "sha256:be29e7ee930d34533380e6d2408f614fc7406ad3491a1657776d904bcc5ebacf",
46
+ "package": {"name": "frontend-project-context", "version": "1.8.0"},
38
47
  "paths": [
39
48
  {
40
49
  "acceptance": ["project-context-clean", "target-renderers-current"],
@@ -59,21 +68,46 @@
59
68
  "migrationIds": ["upgrade.republish-ai-entry.v1", "upgrade.republish-projection.v1"],
60
69
  "requiresHumanReview": false,
61
70
  "rollbackClass": "package-only"
71
+ },
72
+ {
73
+ "acceptance": ["project-context-clean", "target-renderers-current"],
74
+ "classification": "package-only",
75
+ "fromVersion": "1.6.0",
76
+ "migrationIds": ["upgrade.republish-ai-entry.v1"],
77
+ "requiresHumanReview": false,
78
+ "rollbackClass": "package-only"
79
+ },
80
+ {
81
+ "acceptance": ["project-context-clean", "target-renderers-current"],
82
+ "classification": "package-only",
83
+ "fromVersion": "1.7.0",
84
+ "migrationIds": ["upgrade.republish-ai-entry.v1"],
85
+ "requiresHumanReview": false,
86
+ "rollbackClass": "package-only"
62
87
  }
63
88
  ],
64
89
  "protocols": {
65
90
  "actionPlan": {"readable": [1, 2], "written": 2},
91
+ "adaptiveContextBundle": {"readable": [2], "written": 2},
92
+ "contextQuery": {"readable": [2], "written": 2},
93
+ "coverageAudit": {"readable": [1], "written": 1},
66
94
  "evidenceBundle": {"readable": [1], "written": 1},
67
95
  "evidenceInput": {"readable": [1], "written": 1},
68
- "exchange": {"readable": [4], "written": 4},
96
+ "exchange": {"readable": [4, 5, 6, 7, 8], "written": 8},
97
+ "hostPromotionEvidence": {"readable": [1], "written": 1},
98
+ "initializationInstruction": {"readable": [1], "written": 1},
69
99
  "integrationReviewBundle": {"readable": [1], "written": 1},
100
+ "projectStatus": {"readable": [1, 2], "written": 2},
70
101
  "reviewBundle": {"readable": [1, 2], "written": 2},
102
+ "routingIndex": {"readable": [1, 2], "written": 2},
71
103
  "stageContextBundle": {"readable": [1], "written": 1},
72
104
  "stageReceipt": {"readable": [1], "written": 1},
73
- "taskContextPlan": {"readable": [1], "written": 1}
105
+ "taskContextPlan": {"readable": [1], "written": 1},
106
+ "truthReconciliationInput": {"readable": [2], "written": 2},
107
+ "truthReconciliationReviewBundle": {"readable": [2], "written": 2}
74
108
  },
75
109
  "renderers": {
76
- "aiEntry": {"readable": [1], "written": 1},
110
+ "aiEntry": {"readable": [1, 2, 3, 4], "written": 4},
77
111
  "projection": {"readable": [1, 2, 3], "written": 3}
78
112
  },
79
113
  "rollback": {"automatic": false, "defaultClass": "package-only", "externalRestoreRequired": true},
@@ -84,5 +118,5 @@
84
118
  "proposal": {"readable": [1], "written": [1]},
85
119
  "sourceLock": {"readable": [1], "written": [1]}
86
120
  },
87
- "upgradeFrom": ["1.3.1", "1.4.0", "1.5.0"]
121
+ "upgradeFrom": ["1.3.1", "1.4.0", "1.5.0", "1.6.0", "1.7.0"]
88
122
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frontend-project-context",
3
- "version": "1.6.0",
3
+ "version": "1.8.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/onboarding-closure.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": {