@c4a/context-cli 0.6.18 → 0.6.19

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 (46) hide show
  1. package/README.md +6 -2
  2. package/README.zh-CN.md +5 -2
  3. package/cli.js +8551 -5388
  4. package/docs/document-optimization.md +35 -11
  5. package/docs/document-optimization.zh-CN.md +29 -9
  6. package/package.json +2 -2
  7. package/plugins/VERSION +1 -1
  8. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  9. package/plugins/claude/commands/context.md +36 -6
  10. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  11. package/plugins/codex/skills/context/SKILL.md +36 -6
  12. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  13. package/plugins/cursor/commands/c4a-context.md +36 -6
  14. package/plugins/skills/c4a-context/SKILL.md +36 -6
  15. package/providers/context/actions/apply-code-index-guidance.yaml +5 -0
  16. package/providers/context/actions/maintain-evidence.yaml +1 -1
  17. package/providers/context/actions/migrate-codeindex.yaml +5 -0
  18. package/providers/context/actions/register-source-batch.yaml +1 -1
  19. package/providers/context/actions/restore-repository-sources.yaml +1 -1
  20. package/providers/context/codes.yaml +2 -0
  21. package/providers/context/graphs/workspace.yaml +32 -2
  22. package/providers/context/manifest.json +76 -58
  23. package/providers/context/provider.yaml +1 -1
  24. package/providers/context/resources/dialogue/code-extraction.md +12 -0
  25. package/providers/context/resources/dialogue/document-classification.md +1 -1
  26. package/providers/context/resources/dialogue/knowledge-review.md +7 -1
  27. package/providers/context/resources/dialogue/source-boundary.md +9 -1
  28. package/providers/context/resources/dialogue/workflow-mode-after-capture.md +11 -8
  29. package/providers/context/resources/dialogue/workflow-mode-after-creation.md +6 -4
  30. package/providers/context/resources/manuals/guides/lark-resources.md +7 -0
  31. package/providers/context/resources/manuals/guides/package-outputs.md +3 -3
  32. package/providers/context/resources/manuals/reference/code-extractors.md +5 -4
  33. package/providers/context/resources/manuals/reference/package-templates.md +18 -10
  34. package/providers/context/resources/manuals/reference/project-api.md +47 -22
  35. package/providers/context/resources/procedures/close-and-build.md +24 -9
  36. package/providers/context/resources/procedures/code-extraction.md +35 -11
  37. package/providers/context/resources/procedures/code-index-audit.md +53 -13
  38. package/providers/context/resources/procedures/document-capture.md +9 -0
  39. package/providers/context/resources/procedures/document-optimization.md +69 -21
  40. package/providers/context/resources/procedures/document-revision.md +11 -6
  41. package/providers/context/resources/procedures/knowledge-review.md +4 -1
  42. package/providers/context/resources/procedures/source-boundary.md +20 -8
  43. package/providers/context/resources/semantic/align/structure-planning.md +4 -4
  44. package/providers/context/resources/semantic/code-index/classification.md +8 -5
  45. package/providers/context/schemas/document-optimization-decisions.schema.json +29 -6
  46. package/providers/context/schemas/source-batch-input.schema.json +18 -3
@@ -1,9 +1,8 @@
1
1
  # Document revisions
2
2
 
3
- New workspaces enable conservative document optimization by default. It is a
4
- build phase for source-backed prose that repairs presentation-level Markdown,
5
- links, and obvious local errors without changing the approved knowledge page or
6
- broadly rewriting its meaning.
3
+ New workspaces enable source-constrained editorial revision by default. It is a
4
+ build phase for source-backed prose that improves publication value and
5
+ readability without changing the approved knowledge page or inventing facts.
7
6
 
8
7
  To opt out during initialization:
9
8
 
@@ -19,9 +18,22 @@ context optimize-docs disable
19
18
  context status --format json
20
19
  ```
21
20
 
22
- When enabled, the workflow plans only new or changed fragments. The Agent may
23
- keep a fragment unchanged or apply a conservative replacement. Only changed
24
- pages receive a full revision beside their approved page:
21
+ When enabled, the workflow plans only new or changed source Sections. For each
22
+ Section the CLI reports mechanical signals and allowed actions. The Agent may
23
+ keep it, repair local presentation, reshape it within the same source boundary,
24
+ or omit it when the CLI confirms a non-knowledge reason. Only changed pages
25
+ receive a full revision beside their approved page:
26
+
27
+ Signals are review leads rather than a complete readability verdict. The Agent
28
+ must read every Section. Keeping a signaled Section requires a concrete,
29
+ decision-only assessment explaining why each signal is a false positive or why
30
+ editing would reduce source fidelity. The assessment names every reported
31
+ signal code so the CLI can verify complete coverage; it is never published.
32
+ Time, cost, workload, batch size, or delivery pressure are not valid keep or
33
+ defer reasons. Fully managed operation applies all safe repairs, reshapes, and
34
+ eligible omissions autonomously; only genuinely unavailable semantic input is
35
+ batched for the user. A large fragment set must meet the same quality standard
36
+ as a single fragment.
25
37
 
26
38
  ```text
27
39
  knowledge/guides/setup.md
@@ -32,10 +44,21 @@ The `__revision.md` suffix is reserved. Default knowledge discovery, structure,
32
44
  search, and package selection exclude revision files. Validation and build
33
45
  associate a revision with its sibling base page and apply it under the original
34
46
  package path. A revision stores only the base digest that cannot be inferred;
35
- its path and revised fragments are derived. Unchanged fragments inside a full
47
+ its path and revised Sections are derived. Unchanged Sections inside a full
36
48
  revision are inferred. A page with no changes stores only one derived negative
37
49
  cache key below `.tmp/context-runtime/document-optimization/`; replacement
38
- prose and fragment metadata are not duplicated there.
50
+ prose and Section metadata are not duplicated there.
51
+
52
+ Typical repair candidates are Markdown syntax, spacing, empty table rows, and
53
+ descriptive labels for links whose purpose is already present. Reshape handles
54
+ wide tables, long cells, mixed images and links, or long prose by creating a
55
+ clearer structure inside the same Section. Unanswered question sets, empty
56
+ placeholders, decision-free drafts, duplicates, and obsolete-only Sections may
57
+ be omitted. Questions with answers, limitations with an action, and
58
+ deprecations with a replacement remain knowledge. Link targets, images, code,
59
+ commands, numbers, identifiers, conditions, and source references are protected
60
+ through validation. Ambiguous currency, ownership, or sensitive values appear
61
+ together in the plan's `input_requests` and require one batched user decision.
39
62
 
40
63
  After capture, review, or build, a user may ask conversationally to correct one
41
64
  existing knowledge page. Start the correction by title, approved path, or
@@ -47,8 +70,9 @@ context revise "<title, approved path, or ViewRef>" --format json
47
70
 
48
71
  Context starts `route.document-revision.requested` only after resolving one
49
72
  page. Ambiguous requests return candidates instead of guessing. Edit
50
- reader-visible prose without changing provenance or `context:section`
51
- boundaries, then run `context optimize-docs validate`. A valid correction ends
73
+ reader-visible prose within existing `context:section` boundaries without
74
+ changing provenance or protected values, then run `context optimize-docs
75
+ validate`. A valid correction ends
52
76
  the request and the next Route offers a package build when output is stale. If
53
77
  broad document optimization was disabled, this entry activates only the target
54
78
  page and keeps every other eligible page out of the pending batch. If upstream
@@ -1,7 +1,7 @@
1
1
  # 文档修订页
2
2
 
3
- 新工作区默认开启保守的文档编译优化。它是面向来源可追溯正文的构建阶段,只修复
4
- Markdown 排版、链接和明显的局部错误,不修改正式知识页,也不大段改写原意。
3
+ 新工作区默认开启来源约束的编辑修订。它是面向来源可追溯正文的构建阶段,在不修改
4
+ 正式知识页、不补写事实的前提下,提高发布内容的知识价值和可读性。
5
5
 
6
6
  初始化时如需关闭:
7
7
 
@@ -17,8 +17,9 @@ context optimize-docs disable
17
17
  context status --format json
18
18
  ```
19
19
 
20
- 开启后,工作流只规划新增或发生变化的片段。Agent 可以保持片段不变,或提交
21
- 保守的局部替换。只有实际改写的页面才在原文旁生成完整修订页:
20
+ 开启后,工作流只规划新增或发生变化的来源 Section。CLI 为每个 Section 枚举机械
21
+ 信号和允许动作;Agent 可以保持不变、局部修复、在同一来源边界内重排,或在 CLI
22
+ 确认其属于无知识价值内容时省略。只有实际变化的页面才在原文旁生成完整修订页:
22
23
 
23
24
  ```text
24
25
  knowledge/guides/setup.md
@@ -27,9 +28,28 @@ knowledge/guides/setup__revision.md
27
28
 
28
29
  `__revision.md` 是保留后缀。默认知识发现、结构、检索和包选择都排除修订页;
29
30
  校验和构建根据文件名把它关联回同目录原文,并仍按原文件名输出。修订页只额外
30
- 记录无法推导的原文摘要;原文路径和修订片段由文件名与正文差异推导。完整修订
31
- 页中未变化的片段直接推导为 `keep`;整页都不修改时,运行时只保存一个页级负
32
- 缓存键,不重复保存改写正文或片段元数据。
31
+ 记录无法推导的原文摘要;原文路径和修订 Section 由文件名与正文差异推导。完整修订
32
+ 页中未变化的 Section 直接推导为 `keep`;整页都不修改时,运行时只保存一个页级负
33
+ 缓存键,不重复保存改写正文或 Section 元数据。
34
+
35
+ 局部修复适用于 Markdown、空白、空表格行,以及来源已经说明用途的链接名称。结构
36
+ 重排适用于宽表格、长单元格、图片与链接混排或过长段落,但不能跨 Section 搬运事实。
37
+ 未回答的问题集合、空占位、没有结论的草稿、重复内容和只有旧稿的 Section 可以省略;
38
+ 有答案的问句、有影响和动作的限制、带替代方案的废弃说明仍属于知识。链接目标、图片、
39
+ 代码、命令、数字、标识符、条件和来源引用由 CLI 机械保护。事实时效、职责或敏感值不
40
+ 明确时,CLI 会把相关 Section 集中列入计划的 `input_requests`,工作流只询问用户一次,
41
+ 不会自动省略。
42
+
43
+ 机械信号只是审阅线索,不代表最终结论,也不是完整的可读性检查。Agent 必须阅读每个
44
+ Section;若对带信号的 Section 选择 `keep`,需要在本次决策中逐段说明信号为何误报,
45
+ 或修改为何会损害来源忠实度,并在说明中逐一写出对应的信号 code,供 CLI 机械核对覆盖
46
+ 是否完整。CLI 会拒绝没有具体说明或漏掉信号的 `keep`,但这段说明只用于当前决策审计,
47
+ 不会写入正式知识、修订页或构建产物。部分信号误报也不能成为整批保持不变的理由。
48
+
49
+ 时间、成本、工作量、批次规模或赶进度都不是 `keep`、跳过或延期的有效理由。全托管
50
+ 模式下,Agent 应自动完成所有安全的局部修复、结构重排和允许省略,直到当前批次收敛;
51
+ 只有确实无法从当前 Section 或来源证据取得的语义信息,才集中向用户询问一次。片段多
52
+ 不能降低质量标准,也不能把整批默认判为 `keep`。
33
53
 
34
54
  工作区采集、审核或构建完成后,用户可以直接通过对话要求修正某篇知识。Agent
35
55
  先使用标题、正式知识路径或 ViewRef 启动修订:
@@ -40,8 +60,8 @@ context revise "<标题、正式知识路径或 ViewRef>" --format json
40
60
 
41
61
  CLI 只在目标唯一时创建或复用该页修订,并由 Agent Graph 返回
42
62
  `route.document-revision.requested`。若有多个候选,Agent 必须依据当前对话选定,
43
- 否则询问用户。Agent 只编辑面向读者的正文,不修改来源信息和
44
- `context:section` 边界,随后运行 `context optimize-docs validate`。校验成功后,
63
+ 否则询问用户。Agent 只在已有 `context:section` 内编辑面向读者的正文,不修改来源
64
+ 信息、Section 边界和受保护值,随后运行 `context optimize-docs validate`。校验成功后,
45
65
  请求自动结束;若产物因此过期,下一条 Route 会直接提示重新构建。即使工作区
46
66
  此前关闭了整库文档编译优化,这个入口也只激活目标页面,不会让其他页面进入
47
67
  待优化队列。上游内容变化后,旧修订页会成为冲突,不会被静默应用。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/context-cli",
3
- "version": "0.6.18",
3
+ "version": "0.6.19",
4
4
  "type": "module",
5
5
  "description": "Local runtime and Agent integration for traceable knowledge production",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@c4a/agent-graph": "0.2.6",
27
- "@c4a/context": "0.6.18",
27
+ "@c4a/context": "0.6.19",
28
28
  "commander": "^11.0.0",
29
29
  "fast-xml-parser": "^5.10.1",
30
30
  "handlebars": "^4.7.8",
package/plugins/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.18
1
+ 0.6.19
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "c4a",
3
3
  "description": "Start or continue a project-local knowledge workspace through one graph-routed entry.",
4
- "version": "0.6.18",
4
+ "version": "0.6.19",
5
5
  "author": {
6
6
  "name": "c4a"
7
7
  },
@@ -26,6 +26,18 @@ Run:
26
26
  context entry [project-dir] --language <language> --format json
27
27
  ```
28
28
 
29
+ If the request does not already choose ordinary review or fully managed
30
+ operation, first use the read-only entry result to state a short execution
31
+ plan, then ask the user to choose once. Explain that ordinary review pauses at
32
+ human Gates and presents HTML reports, while fully managed operation resolves
33
+ delegatable Gates within this conversation but still stops for permissions,
34
+ hard validation, or non-delegatable decisions. Prefer the host's native choice
35
+ UI. When initialization already needs a confirmation or missing option, combine
36
+ the mode choice with that question instead of adding another round. Keep the
37
+ answer only in this conversation and do not ask again after initialization,
38
+ capture, or resume. An explicit request for review, human confirmation, fully
39
+ managed work, or no further review already resolves this choice.
40
+
29
41
  Use the user's explicit language choice when present; otherwise pass `zh-CN`
30
42
  for a Chinese conversation and `en` for an English conversation. Pass
31
43
  `project-dir`, `--name`, `--dev`, or `--debug` only when the user explicitly
@@ -91,12 +103,14 @@ before workflow evaluation. Debugging records traces below
91
103
  source evidence.
92
104
 
93
105
  Document optimization is enabled by default for newly initialized workspaces.
94
- It conservatively repairs formatting, Markdown, links, and obvious local errors
95
- without broadly rewriting source-backed prose. It keeps approved pages
96
- source-faithful and stores only changed full-page revisions beside them as
97
- `knowledge/**/*__revision.md`. Default knowledge discovery excludes those
98
- reserved sidecars; validation and package compilation apply them to the
99
- matching base page.
106
+ It performs source-constrained editorial revision: the CLI identifies
107
+ readability and knowledge-value signals, and the Agent may keep, repair,
108
+ reshape, or safely omit content only inside its existing source Section. It
109
+ must preserve facts, link targets, images, code, numbers, identifiers, and
110
+ source evidence. Approved pages remain source-faithful; only changed full-page
111
+ revisions are stored beside them as `knowledge/**/*__revision.md`. Default
112
+ knowledge discovery excludes those reserved sidecars, and internal editorial
113
+ audit state is not included in package output.
100
114
 
101
115
  For an existing workspace, respect its current `package.json` setting. Run
102
116
  `context optimize-docs enable` or `context optimize-docs disable` only when the
@@ -123,6 +137,14 @@ The managed loop executes only Route-selected work and returns the current
123
137
  host execution, diagnostics, or a non-unique plan needs attention. Resume from
124
138
  that returned Route; never reconstruct a command from an earlier step.
125
139
 
140
+ Code knowledge is published under `codeindex`. Context mechanically audits each
141
+ module's input analysis, stable boundaries, facts, explanation, evidence scope,
142
+ and page shape without producing a total score. In fully managed operation,
143
+ follow returned repair actions automatically; after three failed revisions of
144
+ the same module problem, stop at the one aggregated human-guidance Gate. If a
145
+ legacy workspace returns `route.extract.codeindex-migration-required`, execute
146
+ only its migration command; do not rename `codegraph` paths manually.
147
+
126
148
  ### Follow the current Route
127
149
 
128
150
  Treat `workflow.current` as the current-step authority:
@@ -168,6 +190,14 @@ Explain, ask, confirm, and summarize in the user's current conversation
168
190
  language. Keep commands, flags, paths, ids, status values, JSONL keys,
169
191
  `source_ref` values, and copied CLI tokens unchanged.
170
192
 
193
+ Keep a conversation-local list of HTML review reports that the user actually
194
+ used to make a review decision. Preserve each exact report URL or local path
195
+ and its reviewed scope when the Route provides them. In the final completion
196
+ summary, include one compact `Review reports` section containing those exact
197
+ references. Do not scan workspace internals to reconstruct the list, persist a
198
+ second ledger, invent a public URL, or describe an inaccessible report or a
199
+ fully managed/force approval as user-reviewed.
200
+
171
201
  When the user explicitly asks to publish a completed build, treat publication
172
202
  as a downstream distribution step outside the Context Route. Use only an
173
203
  explicitly installed distribution tool and its documented complete-output
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c4a",
3
- "version": "0.6.18",
3
+ "version": "0.6.19",
4
4
  "description": "Start or continue a project-local knowledge workspace through one graph-routed entry.",
5
5
  "author": {
6
6
  "name": "c4a"
@@ -18,7 +18,7 @@
18
18
  "skills": "./skills/",
19
19
  "interface": {
20
20
  "displayName": "C4A Context",
21
- "shortDescription": "Initialize and advance a local, source-linked project knowledge workspace.\nv0.6.18",
21
+ "shortDescription": "Initialize and advance a local, source-linked project knowledge workspace.\nv0.6.19",
22
22
  "longDescription": "Create a Context workspace and use agent-guided next steps to register sources, run extraction, review candidates, build package outputs, and verify health without silently mutating source repositories.",
23
23
  "developerName": "c4a",
24
24
  "category": "Productivity",
@@ -38,6 +38,18 @@ Run:
38
38
  context entry [project-dir] --language <language> --format json
39
39
  ```
40
40
 
41
+ If the request does not already choose ordinary review or fully managed
42
+ operation, first use the read-only entry result to state a short execution
43
+ plan, then ask the user to choose once. Explain that ordinary review pauses at
44
+ human Gates and presents HTML reports, while fully managed operation resolves
45
+ delegatable Gates within this conversation but still stops for permissions,
46
+ hard validation, or non-delegatable decisions. Prefer the host's native choice
47
+ UI. When initialization already needs a confirmation or missing option, combine
48
+ the mode choice with that question instead of adding another round. Keep the
49
+ answer only in this conversation and do not ask again after initialization,
50
+ capture, or resume. An explicit request for review, human confirmation, fully
51
+ managed work, or no further review already resolves this choice.
52
+
41
53
  Use the user's explicit language choice when present; otherwise pass `zh-CN`
42
54
  for a Chinese conversation and `en` for an English conversation. Pass
43
55
  `project-dir`, `--name`, `--dev`, or `--debug` only when the user explicitly
@@ -103,12 +115,14 @@ before workflow evaluation. Debugging records traces below
103
115
  source evidence.
104
116
 
105
117
  Document optimization is enabled by default for newly initialized workspaces.
106
- It conservatively repairs formatting, Markdown, links, and obvious local errors
107
- without broadly rewriting source-backed prose. It keeps approved pages
108
- source-faithful and stores only changed full-page revisions beside them as
109
- `knowledge/**/*__revision.md`. Default knowledge discovery excludes those
110
- reserved sidecars; validation and package compilation apply them to the
111
- matching base page.
118
+ It performs source-constrained editorial revision: the CLI identifies
119
+ readability and knowledge-value signals, and the Agent may keep, repair,
120
+ reshape, or safely omit content only inside its existing source Section. It
121
+ must preserve facts, link targets, images, code, numbers, identifiers, and
122
+ source evidence. Approved pages remain source-faithful; only changed full-page
123
+ revisions are stored beside them as `knowledge/**/*__revision.md`. Default
124
+ knowledge discovery excludes those reserved sidecars, and internal editorial
125
+ audit state is not included in package output.
112
126
 
113
127
  For an existing workspace, respect its current `package.json` setting. Run
114
128
  `context optimize-docs enable` or `context optimize-docs disable` only when the
@@ -135,6 +149,14 @@ The managed loop executes only Route-selected work and returns the current
135
149
  host execution, diagnostics, or a non-unique plan needs attention. Resume from
136
150
  that returned Route; never reconstruct a command from an earlier step.
137
151
 
152
+ Code knowledge is published under `codeindex`. Context mechanically audits each
153
+ module's input analysis, stable boundaries, facts, explanation, evidence scope,
154
+ and page shape without producing a total score. In fully managed operation,
155
+ follow returned repair actions automatically; after three failed revisions of
156
+ the same module problem, stop at the one aggregated human-guidance Gate. If a
157
+ legacy workspace returns `route.extract.codeindex-migration-required`, execute
158
+ only its migration command; do not rename `codegraph` paths manually.
159
+
138
160
  ### Follow the current Route
139
161
 
140
162
  Treat `workflow.current` as the current-step authority:
@@ -180,6 +202,14 @@ Explain, ask, confirm, and summarize in the user's current conversation
180
202
  language. Keep commands, flags, paths, ids, status values, JSONL keys,
181
203
  `source_ref` values, and copied CLI tokens unchanged.
182
204
 
205
+ Keep a conversation-local list of HTML review reports that the user actually
206
+ used to make a review decision. Preserve each exact report URL or local path
207
+ and its reviewed scope when the Route provides them. In the final completion
208
+ summary, include one compact `Review reports` section containing those exact
209
+ references. Do not scan workspace internals to reconstruct the list, persist a
210
+ second ledger, invent a public URL, or describe an inaccessible report or a
211
+ fully managed/force approval as user-reviewed.
212
+
183
213
  When the user explicitly asks to publish a completed build, treat publication
184
214
  as a downstream distribution step outside the Context Route. Use only an
185
215
  explicitly installed distribution tool and its documented complete-output
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "c4a",
3
3
  "displayName": "C4A Context",
4
- "version": "0.6.18",
4
+ "version": "0.6.19",
5
5
  "description": "Start or continue a project-local knowledge workspace through one graph-routed entry.",
6
6
  "author": {
7
7
  "name": "Context4AI",
@@ -30,6 +30,18 @@ Run:
30
30
  context entry [project-dir] --language <language> --format json
31
31
  ```
32
32
 
33
+ If the request does not already choose ordinary review or fully managed
34
+ operation, first use the read-only entry result to state a short execution
35
+ plan, then ask the user to choose once. Explain that ordinary review pauses at
36
+ human Gates and presents HTML reports, while fully managed operation resolves
37
+ delegatable Gates within this conversation but still stops for permissions,
38
+ hard validation, or non-delegatable decisions. Prefer the host's native choice
39
+ UI. When initialization already needs a confirmation or missing option, combine
40
+ the mode choice with that question instead of adding another round. Keep the
41
+ answer only in this conversation and do not ask again after initialization,
42
+ capture, or resume. An explicit request for review, human confirmation, fully
43
+ managed work, or no further review already resolves this choice.
44
+
33
45
  Use the user's explicit language choice when present; otherwise pass `zh-CN`
34
46
  for a Chinese conversation and `en` for an English conversation. Pass
35
47
  `project-dir`, `--name`, `--dev`, or `--debug` only when the user explicitly
@@ -95,12 +107,14 @@ before workflow evaluation. Debugging records traces below
95
107
  source evidence.
96
108
 
97
109
  Document optimization is enabled by default for newly initialized workspaces.
98
- It conservatively repairs formatting, Markdown, links, and obvious local errors
99
- without broadly rewriting source-backed prose. It keeps approved pages
100
- source-faithful and stores only changed full-page revisions beside them as
101
- `knowledge/**/*__revision.md`. Default knowledge discovery excludes those
102
- reserved sidecars; validation and package compilation apply them to the
103
- matching base page.
110
+ It performs source-constrained editorial revision: the CLI identifies
111
+ readability and knowledge-value signals, and the Agent may keep, repair,
112
+ reshape, or safely omit content only inside its existing source Section. It
113
+ must preserve facts, link targets, images, code, numbers, identifiers, and
114
+ source evidence. Approved pages remain source-faithful; only changed full-page
115
+ revisions are stored beside them as `knowledge/**/*__revision.md`. Default
116
+ knowledge discovery excludes those reserved sidecars, and internal editorial
117
+ audit state is not included in package output.
104
118
 
105
119
  For an existing workspace, respect its current `package.json` setting. Run
106
120
  `context optimize-docs enable` or `context optimize-docs disable` only when the
@@ -127,6 +141,14 @@ The managed loop executes only Route-selected work and returns the current
127
141
  host execution, diagnostics, or a non-unique plan needs attention. Resume from
128
142
  that returned Route; never reconstruct a command from an earlier step.
129
143
 
144
+ Code knowledge is published under `codeindex`. Context mechanically audits each
145
+ module's input analysis, stable boundaries, facts, explanation, evidence scope,
146
+ and page shape without producing a total score. In fully managed operation,
147
+ follow returned repair actions automatically; after three failed revisions of
148
+ the same module problem, stop at the one aggregated human-guidance Gate. If a
149
+ legacy workspace returns `route.extract.codeindex-migration-required`, execute
150
+ only its migration command; do not rename `codegraph` paths manually.
151
+
130
152
  ### Follow the current Route
131
153
 
132
154
  Treat `workflow.current` as the current-step authority:
@@ -172,6 +194,14 @@ Explain, ask, confirm, and summarize in the user's current conversation
172
194
  language. Keep commands, flags, paths, ids, status values, JSONL keys,
173
195
  `source_ref` values, and copied CLI tokens unchanged.
174
196
 
197
+ Keep a conversation-local list of HTML review reports that the user actually
198
+ used to make a review decision. Preserve each exact report URL or local path
199
+ and its reviewed scope when the Route provides them. In the final completion
200
+ summary, include one compact `Review reports` section containing those exact
201
+ references. Do not scan workspace internals to reconstruct the list, persist a
202
+ second ledger, invent a public URL, or describe an inaccessible report or a
203
+ fully managed/force approval as user-reviewed.
204
+
175
205
  When the user explicitly asks to publish a completed build, treat publication
176
206
  as a downstream distribution step outside the Context Route. Use only an
177
207
  explicitly installed distribution tool and its documented complete-output
@@ -38,6 +38,18 @@ Run:
38
38
  context entry [project-dir] --language <language> --format json
39
39
  ```
40
40
 
41
+ If the request does not already choose ordinary review or fully managed
42
+ operation, first use the read-only entry result to state a short execution
43
+ plan, then ask the user to choose once. Explain that ordinary review pauses at
44
+ human Gates and presents HTML reports, while fully managed operation resolves
45
+ delegatable Gates within this conversation but still stops for permissions,
46
+ hard validation, or non-delegatable decisions. Prefer the host's native choice
47
+ UI. When initialization already needs a confirmation or missing option, combine
48
+ the mode choice with that question instead of adding another round. Keep the
49
+ answer only in this conversation and do not ask again after initialization,
50
+ capture, or resume. An explicit request for review, human confirmation, fully
51
+ managed work, or no further review already resolves this choice.
52
+
41
53
  Use the user's explicit language choice when present; otherwise pass `zh-CN`
42
54
  for a Chinese conversation and `en` for an English conversation. Pass
43
55
  `project-dir`, `--name`, `--dev`, or `--debug` only when the user explicitly
@@ -103,12 +115,14 @@ before workflow evaluation. Debugging records traces below
103
115
  source evidence.
104
116
 
105
117
  Document optimization is enabled by default for newly initialized workspaces.
106
- It conservatively repairs formatting, Markdown, links, and obvious local errors
107
- without broadly rewriting source-backed prose. It keeps approved pages
108
- source-faithful and stores only changed full-page revisions beside them as
109
- `knowledge/**/*__revision.md`. Default knowledge discovery excludes those
110
- reserved sidecars; validation and package compilation apply them to the
111
- matching base page.
118
+ It performs source-constrained editorial revision: the CLI identifies
119
+ readability and knowledge-value signals, and the Agent may keep, repair,
120
+ reshape, or safely omit content only inside its existing source Section. It
121
+ must preserve facts, link targets, images, code, numbers, identifiers, and
122
+ source evidence. Approved pages remain source-faithful; only changed full-page
123
+ revisions are stored beside them as `knowledge/**/*__revision.md`. Default
124
+ knowledge discovery excludes those reserved sidecars, and internal editorial
125
+ audit state is not included in package output.
112
126
 
113
127
  For an existing workspace, respect its current `package.json` setting. Run
114
128
  `context optimize-docs enable` or `context optimize-docs disable` only when the
@@ -135,6 +149,14 @@ The managed loop executes only Route-selected work and returns the current
135
149
  host execution, diagnostics, or a non-unique plan needs attention. Resume from
136
150
  that returned Route; never reconstruct a command from an earlier step.
137
151
 
152
+ Code knowledge is published under `codeindex`. Context mechanically audits each
153
+ module's input analysis, stable boundaries, facts, explanation, evidence scope,
154
+ and page shape without producing a total score. In fully managed operation,
155
+ follow returned repair actions automatically; after three failed revisions of
156
+ the same module problem, stop at the one aggregated human-guidance Gate. If a
157
+ legacy workspace returns `route.extract.codeindex-migration-required`, execute
158
+ only its migration command; do not rename `codegraph` paths manually.
159
+
138
160
  ### Follow the current Route
139
161
 
140
162
  Treat `workflow.current` as the current-step authority:
@@ -180,6 +202,14 @@ Explain, ask, confirm, and summarize in the user's current conversation
180
202
  language. Keep commands, flags, paths, ids, status values, JSONL keys,
181
203
  `source_ref` values, and copied CLI tokens unchanged.
182
204
 
205
+ Keep a conversation-local list of HTML review reports that the user actually
206
+ used to make a review decision. Preserve each exact report URL or local path
207
+ and its reviewed scope when the Route provides them. In the final completion
208
+ summary, include one compact `Review reports` section containing those exact
209
+ references. Do not scan workspace internals to reconstruct the list, persist a
210
+ second ledger, invent a public URL, or describe an inaccessible report or a
211
+ fully managed/force approval as user-reviewed.
212
+
183
213
  When the user explicitly asks to publish a completed build, treat publication
184
214
  as a downstream distribution step outside the Context Route. Use only an
185
215
  explicitly installed distribution tool and its documented complete-output
@@ -0,0 +1,5 @@
1
+ schema: agent-graph.action.v1
2
+ id: apply-code-index-guidance
3
+ runner: host
4
+ effect: write
5
+ handler: context.project.apply-code-index-guidance
@@ -2,5 +2,5 @@ schema: agent-graph.action.v1
2
2
  id: maintain-evidence
3
3
  runner: command
4
4
  effect: write
5
- command: context review maintain --input - --format json
5
+ command: context review maintain --input .tmp/agent-payloads/evidence-maintenance.json --format json
6
6
  inputSchema: schemas/evidence-maintenance-input.schema.json
@@ -0,0 +1,5 @@
1
+ schema: agent-graph.action.v1
2
+ id: migrate-codeindex
3
+ runner: host
4
+ effect: write
5
+ handler: context.code-index.migrate
@@ -3,5 +3,5 @@ id: register-source-batch
3
3
  description: Register the source batch explicitly confirmed in the current conversation.
4
4
  runner: command
5
5
  effect: write
6
- command: context source add batch --input - --format json
6
+ command: context source add batch --input .tmp/agent-payloads/source-batch.json --format json
7
7
  inputSchema: schemas/source-batch-input.schema.json
@@ -3,5 +3,5 @@ id: restore-repository-sources
3
3
  description: Restore registered repository sources from user-confirmed local paths or explicit clones.
4
4
  runner: command
5
5
  effect: external
6
- command: context source restore --input - --format json
6
+ command: context source restore --input .tmp/agent-payloads/repository-source-recovery.json --format json
7
7
  inputSchema: schemas/repository-source-recovery.schema.json
@@ -30,8 +30,10 @@ codes:
30
30
  - { code: route.extract.scale-limit-exceeded, kind: route-reason, summary: At least one index unit exceeds the supported page limit., document: resources/procedures/code-extraction.md }
31
31
  - { code: route.extract.pending-target, kind: route-reason, summary: Extract the next pending code target before another workflow family., document: resources/procedures/code-extraction.md }
32
32
  - { code: route.extract.audit-input-required, kind: route-reason, summary: The code-index audit requires specific source or protocol material that is not currently available., document: resources/procedures/code-index-audit.md }
33
+ - { code: route.extract.audit-guidance-required, kind: route-reason, summary: One or more code-index units still fail absolute quality bounds after three revisions and require one aggregated human direction., document: resources/procedures/code-index-audit.md }
33
34
  - { code: route.extract.audit-revision-required, kind: route-reason, summary: Revise the code-index plan and content for issues confirmed by the Agent audit., document: resources/procedures/code-index-audit.md }
34
35
  - { code: route.extract.audit-required, kind: route-reason, summary: The complete proposed code index requires one Agent semantic audit decision., document: resources/procedures/code-index-audit.md }
36
+ - { code: route.extract.codeindex-migration-required, kind: route-reason, summary: This workspace still uses the legacy codegraph collection and must be migrated deterministically before code extraction continues., document: resources/procedures/code-extraction.md }
35
37
  - { code: route.document.classification-required, kind: route-reason, summary: A captured document needs an evidence-backed collection decision., document: resources/procedures/document-classification.md }
36
38
  - { code: route.prose.configuration-required, kind: route-reason, summary: A document target is missing a complete prose lifecycle declaration., document: resources/procedures/project-configuration.md }
37
39
  - { code: route.structure.pending-target, kind: route-reason, summary: Prepare the next document structure slot from source evidence., document: resources/procedures/prose-align.md }
@@ -384,6 +384,17 @@ nodes:
384
384
  recommended:
385
385
  - resources/manuals/reference/code-extractors.md
386
386
 
387
+ - id: migrate-codeindex
388
+ kind: action
389
+ reasonCode: route.extract.codeindex-migration-required
390
+ action: actions/migrate-codeindex.yaml
391
+ satisfiedBy:
392
+ - path: extract.migration_required
393
+ equals: false
394
+ resources:
395
+ required:
396
+ - resources/procedures/code-extraction.md
397
+
387
398
  - id: preview-extraction-batch
388
399
  kind: action
389
400
  reasonCode: route.extract.preview-required
@@ -458,6 +469,23 @@ nodes:
458
469
  - resources/dialogue/human-gates.md
459
470
  - resources/views/code-index-audit.yaml
460
471
 
472
+ - id: resolve-code-index-audit-guidance
473
+ kind: gate
474
+ reasonCode: route.extract.audit-guidance-required
475
+ resolutionAction: actions/apply-code-index-guidance.yaml
476
+ gate:
477
+ id: code-index-audit-guidance
478
+ prompt: Review the aggregated three-round code-index quality report and provide one scope, profile, source-material, or indexing direction for the failed modules.
479
+ delegatable: false
480
+ satisfiedBy:
481
+ - path: extract.audit_guidance_required
482
+ equals: false
483
+ resources:
484
+ required:
485
+ - resources/procedures/code-index-audit.md
486
+ - resources/dialogue/human-gates.md
487
+ - resources/views/code-index-audit.yaml
488
+
461
489
  - id: revise-code-index-audit
462
490
  kind: action
463
491
  reasonCode: route.extract.audit-revision-required
@@ -731,13 +759,15 @@ edges:
731
759
  - { from: authorize-document-capture, to: capture-next, kind: gatedBy }
732
760
  - { from: capture-next, to: choose-extraction-scope }
733
761
  - { from: choose-extraction-scope, to: configure-code-extraction, kind: gatedBy }
734
- - { from: configure-code-extraction, to: resolve-extraction-capability }
762
+ - { from: configure-code-extraction, to: migrate-codeindex }
763
+ - { from: migrate-codeindex, to: resolve-extraction-capability }
735
764
  - { from: resolve-extraction-capability, to: preview-extraction-batch }
736
765
  - { from: preview-extraction-batch, to: repair-extraction-ownership }
737
766
  - { from: repair-extraction-ownership, to: revise-extraction-scale }
738
767
  - { from: revise-extraction-scale, to: extract-next }
739
768
  - { from: extract-next, to: resolve-code-index-audit-input }
740
- - { from: resolve-code-index-audit-input, to: revise-code-index-audit, kind: gatedBy }
769
+ - { from: resolve-code-index-audit-input, to: resolve-code-index-audit-guidance, kind: gatedBy }
770
+ - { from: resolve-code-index-audit-guidance, to: revise-code-index-audit, kind: gatedBy }
741
771
  - { from: revise-code-index-audit, to: audit-code-index }
742
772
  - { from: audit-code-index, to: review-current-batch }
743
773
  - { from: review-current-batch, to: apply-managed-review, kind: gatedBy }