@c4a/context-cli 0.6.11 → 0.6.16

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/README.md +5 -0
  2. package/README.zh-CN.md +5 -0
  3. package/cli.js +6112 -3389
  4. package/docs/document-optimization.md +62 -0
  5. package/docs/document-optimization.zh-CN.md +54 -0
  6. package/package.json +3 -2
  7. package/plugins/VERSION +1 -1
  8. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  9. package/plugins/claude/commands/context.md +50 -5
  10. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  11. package/plugins/codex/skills/context/SKILL.md +50 -5
  12. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  13. package/plugins/cursor/commands/c4a-context.md +50 -5
  14. package/plugins/skills/c4a-context/SKILL.md +50 -5
  15. package/providers/context/actions/optimize-documents.yaml +6 -0
  16. package/providers/context/actions/preview-extraction-batch.yaml +5 -0
  17. package/providers/context/actions/revise-document.yaml +5 -0
  18. package/providers/context/codes.yaml +6 -0
  19. package/providers/context/graphs/workspace.yaml +118 -3
  20. package/providers/context/manifest.json +242 -26
  21. package/providers/context/provider.yaml +1 -1
  22. package/providers/context/resources/dialogue/code-extraction.md +39 -9
  23. package/providers/context/resources/dialogue/package-output.md +5 -8
  24. package/providers/context/resources/manuals/guides/package-outputs.md +14 -20
  25. package/providers/context/resources/manuals/reference/code-extractors.md +75 -18
  26. package/providers/context/resources/manuals/reference/package-templates.md +26 -33
  27. package/providers/context/resources/manuals/reference/project-api.md +156 -14
  28. package/providers/context/resources/manuals/reference/template-variables.md +4 -3
  29. package/providers/context/resources/procedures/close-and-build.md +5 -0
  30. package/providers/context/resources/procedures/code-extraction.md +86 -13
  31. package/providers/context/resources/procedures/document-optimization.md +43 -0
  32. package/providers/context/resources/procedures/document-revision.md +31 -0
  33. package/providers/context/resources/procedures/package-output.md +10 -34
  34. package/providers/context/resources/semantic/code-index/classification.md +267 -0
  35. package/providers/context/resources/semantic/code-index/templates/adapter.md +109 -0
  36. package/providers/context/resources/semantic/code-index/templates/api-service.md +116 -0
  37. package/providers/context/resources/semantic/code-index/templates/background-runtime.md +109 -0
  38. package/providers/context/resources/semantic/code-index/templates/cli-tool.md +129 -0
  39. package/providers/context/resources/semantic/code-index/templates/contract-source.md +73 -0
  40. package/providers/context/resources/semantic/code-index/templates/cross-module-chain.md +78 -0
  41. package/providers/context/resources/semantic/code-index/templates/derived-source.md +116 -0
  42. package/providers/context/resources/semantic/code-index/templates/domain-service.md +109 -0
  43. package/providers/context/resources/semantic/code-index/templates/event-flow.md +62 -0
  44. package/providers/context/resources/semantic/code-index/templates/monorepo-container.md +124 -0
  45. package/providers/context/resources/semantic/code-index/templates/persistence-boundary.md +56 -0
  46. package/providers/context/resources/semantic/code-index/templates/plugin-extension.md +52 -0
  47. package/providers/context/resources/semantic/code-index/templates/protocol-boundary.md +88 -0
  48. package/providers/context/resources/semantic/code-index/templates/sdk-library.md +132 -0
  49. package/providers/context/resources/semantic/code-index/templates/web-application.md +145 -0
  50. package/providers/context/resources/views/document-optimization-current.yaml +6 -0
  51. package/providers/context/resources/views/extraction-preview.yaml +6 -0
  52. package/providers/context/schemas/document-optimization-decisions.schema.json +34 -0
@@ -0,0 +1,62 @@
1
+ # Document revisions
2
+
3
+ Document optimization is an optional build phase for source-backed prose. It
4
+ repairs presentation-level Markdown without changing the approved knowledge
5
+ page.
6
+
7
+ Enable it during initialization:
8
+
9
+ ```bash
10
+ context init context --optimize-docs
11
+ ```
12
+
13
+ Or enable it in an existing workspace:
14
+
15
+ ```bash
16
+ context optimize-docs enable
17
+ context status --format json
18
+ ```
19
+
20
+ When enabled, the workflow plans only new or changed fragments. The Agent may
21
+ keep a fragment unchanged or apply a conservative replacement. Only changed
22
+ pages receive a full revision beside their approved page:
23
+
24
+ ```text
25
+ knowledge/guides/setup.md
26
+ knowledge/guides/setup__revision.md
27
+ ```
28
+
29
+ The `__revision.md` suffix is reserved. Default knowledge discovery, structure,
30
+ search, and package selection exclude revision files. Validation and build
31
+ associate a revision with its sibling base page and apply it under the original
32
+ package path. A revision stores only the base digest that cannot be inferred;
33
+ its path and revised fragments are derived. Unchanged fragments inside a full
34
+ revision are inferred. A page with no changes stores only one derived negative
35
+ cache key below `.tmp/context-runtime/document-optimization/`; replacement
36
+ prose and fragment metadata are not duplicated there.
37
+
38
+ After capture, review, or build, a user may ask conversationally to correct one
39
+ existing knowledge page. Start the correction by title, approved path, or
40
+ ViewRef:
41
+
42
+ ```bash
43
+ context revise "<title, approved path, or ViewRef>" --format json
44
+ ```
45
+
46
+ Context starts `route.document-revision.requested` only after resolving one
47
+ page. Ambiguous requests return candidates instead of guessing. Edit
48
+ reader-visible prose without changing provenance or `context:section`
49
+ boundaries, then run `context optimize-docs validate`. A valid correction ends
50
+ the request and the next Route offers a package build when output is stale. If
51
+ broad document optimization was disabled, this entry activates only the target
52
+ page and keeps every other eligible page out of the pending batch. If upstream
53
+ content changes, the revision becomes a conflict and must be reviewed again.
54
+
55
+ Disable and restore baseline output with:
56
+
57
+ ```bash
58
+ context optimize-docs disable
59
+ ```
60
+
61
+ Revision pages move to Context runtime recovery storage, and the next build
62
+ uses approved knowledge directly.
@@ -0,0 +1,54 @@
1
+ # 文档修订页
2
+
3
+ 文档编译优化是面向来源可追溯正文的可选构建阶段。它只修复 Markdown
4
+ 排版和明显的局部问题,不修改正式知识页。
5
+
6
+ 初始化时开启:
7
+
8
+ ```bash
9
+ context init context --optimize-docs
10
+ ```
11
+
12
+ 已有工作区可以运行:
13
+
14
+ ```bash
15
+ context optimize-docs enable
16
+ context status --format json
17
+ ```
18
+
19
+ 开启后,工作流只规划新增或发生变化的片段。Agent 可以保持片段不变,或提交
20
+ 保守的局部替换。只有实际改写的页面才在原文旁生成完整修订页:
21
+
22
+ ```text
23
+ knowledge/guides/setup.md
24
+ knowledge/guides/setup__revision.md
25
+ ```
26
+
27
+ `__revision.md` 是保留后缀。默认知识发现、结构、检索和包选择都排除修订页;
28
+ 校验和构建根据文件名把它关联回同目录原文,并仍按原文件名输出。修订页只额外
29
+ 记录无法推导的原文摘要;原文路径和修订片段由文件名与正文差异推导。完整修订
30
+ 页中未变化的片段直接推导为 `keep`;整页都不修改时,运行时只保存一个页级负
31
+ 缓存键,不重复保存改写正文或片段元数据。
32
+
33
+ 工作区采集、审核或构建完成后,用户可以直接通过对话要求修正某篇知识。Agent
34
+ 先使用标题、正式知识路径或 ViewRef 启动修订:
35
+
36
+ ```bash
37
+ context revise "<标题、正式知识路径或 ViewRef>" --format json
38
+ ```
39
+
40
+ CLI 只在目标唯一时创建或复用该页修订,并由 Agent Graph 返回
41
+ `route.document-revision.requested`。若有多个候选,Agent 必须依据当前对话选定,
42
+ 否则询问用户。Agent 只编辑面向读者的正文,不修改来源信息和
43
+ `context:section` 边界,随后运行 `context optimize-docs validate`。校验成功后,
44
+ 请求自动结束;若产物因此过期,下一条 Route 会直接提示重新构建。即使工作区
45
+ 此前没有开启整库文档编译优化,这个入口也只激活目标页面,不会让其他页面进入
46
+ 待优化队列。上游内容变化后,旧修订页会成为冲突,不会被静默应用。
47
+
48
+ 关闭并恢复基础构建结果:
49
+
50
+ ```bash
51
+ context optimize-docs disable
52
+ ```
53
+
54
+ 修订页会被移动到 Context 的运行时恢复目录,下一次构建直接使用正式知识。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/context-cli",
3
- "version": "0.6.11",
3
+ "version": "0.6.16",
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.11",
27
+ "@c4a/context": "0.6.16",
28
28
  "commander": "^11.0.0",
29
29
  "fast-xml-parser": "^5.10.1",
30
30
  "handlebars": "^4.7.8",
@@ -36,6 +36,7 @@
36
36
  "remark-mdx": "^3.1.1",
37
37
  "remark-parse": "^11.0.0",
38
38
  "remark-stringify": "^11.0.0",
39
+ "sharp": "^0.35.3",
39
40
  "typescript": "^5.5.4",
40
41
  "unified": "^11.0.5",
41
42
  "web-tree-sitter": "^0.20.8",
package/plugins/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.11
1
+ 0.6.16
@@ -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.11",
4
+ "version": "0.6.16",
5
5
  "author": {
6
6
  "name": "c4a"
7
7
  },
@@ -28,8 +28,11 @@ context entry [project-dir] --language <language> --format json
28
28
 
29
29
  Use the user's explicit language choice when present; otherwise pass `zh-CN`
30
30
  for a Chinese conversation and `en` for an English conversation. Pass
31
- `project-dir`, `--name`, `--dev`, or `--debug` only when the user explicitly
32
- requested that initialization choice. Pass `--managed` only after the user
31
+ `project-dir`, `--name`, `--dev`, `--debug`, or `--optimize-docs` only when the
32
+ user explicitly requested that initialization choice. Treat requests to enable
33
+ document compilation optimization, document formatting optimization, or
34
+ equivalent conservative build-time cleanup as `--optimize-docs`. Pass
35
+ `--managed` only after the user
33
36
  explicitly authorizes fully managed operation in this conversation.
34
37
 
35
38
  If the `context` process itself cannot start because the command is missing
@@ -59,11 +62,43 @@ Execute only `next_action.command` returned by `context entry`:
59
62
  init`, enter the project root, read the generated `AGENTS.md`, and run this
60
63
  entry again.
61
64
 
65
+ If the user explicitly asks to correct or revise an existing approved or built
66
+ knowledge page, first let `context entry` relocate into the existing workspace
67
+ and evaluate its current Route once. Resolve a blocking workspace diagnostic,
68
+ evidence-maintenance action, or already-pending Review batch first; these may
69
+ change the approved baseline. Before continuing unrelated capture, extraction,
70
+ package configuration, or build work, start the correction with:
71
+
72
+ ```bash
73
+ context revise "<the user's page title, approved path, ViewRef, or wording>" --format json
74
+ ```
75
+
76
+ When the target is unique, run the returned status command and follow
77
+ `route.document-revision.requested`. When candidates are returned, select one
78
+ only if the conversation identifies it uniquely; otherwise ask which page the
79
+ user means. Never edit the approved base page or `dist/` for this operation.
80
+ After the Route validates the revision, continue normally: Context will offer
81
+ the package build when the correction makes its output stale.
82
+
62
83
  ### Conversation modes
63
84
 
64
- Enable debugging only when the user explicitly requests it. Run `context debug
65
- enable` first; debugging records traces below `.tmp/context-runtime/debug/` but
66
- does not grant workflow authority or provide source evidence.
85
+ Enable debugging only when the user explicitly requests it. If initialization
86
+ is required, pass `--debug` to `context entry` and execute its returned
87
+ `context init ... --debug` command; do not run a workspace-only debug command
88
+ before initialization. For an existing workspace, run `context debug enable`
89
+ before workflow evaluation. Debugging records traces below
90
+ `.tmp/context-runtime/debug/` but does not grant workflow authority or provide
91
+ source evidence.
92
+
93
+ Enable document optimization only when the user explicitly requests it. If
94
+ initialization is required, pass `--optimize-docs` through `context entry`; for
95
+ an existing workspace, run `context optimize-docs enable` before workflow
96
+ evaluation. The feature keeps approved pages source-faithful and stores only
97
+ changed full-page revisions beside them as `knowledge/**/*__revision.md`.
98
+ Default knowledge discovery excludes those reserved sidecars; validation and
99
+ package compilation apply them to the matching base page.
100
+ Follow the resulting Route instead of editing approved knowledge or package
101
+ output by hand.
67
102
 
68
103
  For explicitly authorized fully managed operation, use:
69
104
 
@@ -105,6 +140,10 @@ Treat `workflow.current` as the current-step authority:
105
140
  not inside a restricted child sandbox. Follow the Route-selected procedure
106
141
  for its audit and approval contract; never invent a payload, destination, or
107
142
  substitute command.
143
+ Treat a code-extraction batch preview as one Route action. Read its complete
144
+ index-unit report and keep same-kind capability or scale decisions in the
145
+ single returned Gate; do not ask about modules one by one. A non-delegatable
146
+ extraction Gate must stop even in fully managed mode.
108
147
  4. If `configuration` is present, edit only the named project file and use the
109
148
  selected resources as its contract.
110
149
  5. After every action or configuration change, run status again. The managed
@@ -115,6 +154,12 @@ Explain, ask, confirm, and summarize in the user's current conversation
115
154
  language. Keep commands, flags, paths, ids, status values, JSONL keys,
116
155
  `source_ref` values, and copied CLI tokens unchanged.
117
156
 
157
+ When the user explicitly asks to publish a completed build, treat publication
158
+ as a downstream distribution step outside the Context Route. Use only an
159
+ explicitly installed distribution tool and its documented complete-output
160
+ upload command. If no such tool is available, stop after the local build and
161
+ explain that Context itself does not publish to a hosted service.
162
+
118
163
  Do not infer repo sources, extraction scope, review decisions, or package output
119
164
  choices from surrounding files. Do not call source-repo operations such as
120
165
  clone, checkout, reset, fetch, install, build, or test without explicit user
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c4a",
3
- "version": "0.6.11",
3
+ "version": "0.6.16",
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.11",
21
+ "shortDescription": "Initialize and advance a local, source-linked project knowledge workspace.\nv0.6.16",
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",
@@ -40,8 +40,11 @@ context entry [project-dir] --language <language> --format json
40
40
 
41
41
  Use the user's explicit language choice when present; otherwise pass `zh-CN`
42
42
  for a Chinese conversation and `en` for an English conversation. Pass
43
- `project-dir`, `--name`, `--dev`, or `--debug` only when the user explicitly
44
- requested that initialization choice. Pass `--managed` only after the user
43
+ `project-dir`, `--name`, `--dev`, `--debug`, or `--optimize-docs` only when the
44
+ user explicitly requested that initialization choice. Treat requests to enable
45
+ document compilation optimization, document formatting optimization, or
46
+ equivalent conservative build-time cleanup as `--optimize-docs`. Pass
47
+ `--managed` only after the user
45
48
  explicitly authorizes fully managed operation in this conversation.
46
49
 
47
50
  If the `context` process itself cannot start because the command is missing
@@ -71,11 +74,43 @@ Execute only `next_action.command` returned by `context entry`:
71
74
  init`, enter the project root, read the generated `AGENTS.md`, and run this
72
75
  entry again.
73
76
 
77
+ If the user explicitly asks to correct or revise an existing approved or built
78
+ knowledge page, first let `context entry` relocate into the existing workspace
79
+ and evaluate its current Route once. Resolve a blocking workspace diagnostic,
80
+ evidence-maintenance action, or already-pending Review batch first; these may
81
+ change the approved baseline. Before continuing unrelated capture, extraction,
82
+ package configuration, or build work, start the correction with:
83
+
84
+ ```bash
85
+ context revise "<the user's page title, approved path, ViewRef, or wording>" --format json
86
+ ```
87
+
88
+ When the target is unique, run the returned status command and follow
89
+ `route.document-revision.requested`. When candidates are returned, select one
90
+ only if the conversation identifies it uniquely; otherwise ask which page the
91
+ user means. Never edit the approved base page or `dist/` for this operation.
92
+ After the Route validates the revision, continue normally: Context will offer
93
+ the package build when the correction makes its output stale.
94
+
74
95
  ### Conversation modes
75
96
 
76
- Enable debugging only when the user explicitly requests it. Run `context debug
77
- enable` first; debugging records traces below `.tmp/context-runtime/debug/` but
78
- does not grant workflow authority or provide source evidence.
97
+ Enable debugging only when the user explicitly requests it. If initialization
98
+ is required, pass `--debug` to `context entry` and execute its returned
99
+ `context init ... --debug` command; do not run a workspace-only debug command
100
+ before initialization. For an existing workspace, run `context debug enable`
101
+ before workflow evaluation. Debugging records traces below
102
+ `.tmp/context-runtime/debug/` but does not grant workflow authority or provide
103
+ source evidence.
104
+
105
+ Enable document optimization only when the user explicitly requests it. If
106
+ initialization is required, pass `--optimize-docs` through `context entry`; for
107
+ an existing workspace, run `context optimize-docs enable` before workflow
108
+ evaluation. The feature keeps approved pages source-faithful and stores only
109
+ changed full-page revisions beside them as `knowledge/**/*__revision.md`.
110
+ Default knowledge discovery excludes those reserved sidecars; validation and
111
+ package compilation apply them to the matching base page.
112
+ Follow the resulting Route instead of editing approved knowledge or package
113
+ output by hand.
79
114
 
80
115
  For explicitly authorized fully managed operation, use:
81
116
 
@@ -117,6 +152,10 @@ Treat `workflow.current` as the current-step authority:
117
152
  not inside a restricted child sandbox. Follow the Route-selected procedure
118
153
  for its audit and approval contract; never invent a payload, destination, or
119
154
  substitute command.
155
+ Treat a code-extraction batch preview as one Route action. Read its complete
156
+ index-unit report and keep same-kind capability or scale decisions in the
157
+ single returned Gate; do not ask about modules one by one. A non-delegatable
158
+ extraction Gate must stop even in fully managed mode.
120
159
  4. If `configuration` is present, edit only the named project file and use the
121
160
  selected resources as its contract.
122
161
  5. After every action or configuration change, run status again. The managed
@@ -127,6 +166,12 @@ Explain, ask, confirm, and summarize in the user's current conversation
127
166
  language. Keep commands, flags, paths, ids, status values, JSONL keys,
128
167
  `source_ref` values, and copied CLI tokens unchanged.
129
168
 
169
+ When the user explicitly asks to publish a completed build, treat publication
170
+ as a downstream distribution step outside the Context Route. Use only an
171
+ explicitly installed distribution tool and its documented complete-output
172
+ upload command. If no such tool is available, stop after the local build and
173
+ explain that Context itself does not publish to a hosted service.
174
+
130
175
  Do not infer repo sources, extraction scope, review decisions, or package output
131
176
  choices from surrounding files. Do not call source-repo operations such as
132
177
  clone, checkout, reset, fetch, install, build, or test without explicit user
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "c4a",
3
3
  "displayName": "C4A Context",
4
- "version": "0.6.11",
4
+ "version": "0.6.16",
5
5
  "description": "Start or continue a project-local knowledge workspace through one graph-routed entry.",
6
6
  "author": {
7
7
  "name": "Context4AI",
@@ -32,8 +32,11 @@ context entry [project-dir] --language <language> --format json
32
32
 
33
33
  Use the user's explicit language choice when present; otherwise pass `zh-CN`
34
34
  for a Chinese conversation and `en` for an English conversation. Pass
35
- `project-dir`, `--name`, `--dev`, or `--debug` only when the user explicitly
36
- requested that initialization choice. Pass `--managed` only after the user
35
+ `project-dir`, `--name`, `--dev`, `--debug`, or `--optimize-docs` only when the
36
+ user explicitly requested that initialization choice. Treat requests to enable
37
+ document compilation optimization, document formatting optimization, or
38
+ equivalent conservative build-time cleanup as `--optimize-docs`. Pass
39
+ `--managed` only after the user
37
40
  explicitly authorizes fully managed operation in this conversation.
38
41
 
39
42
  If the `context` process itself cannot start because the command is missing
@@ -63,11 +66,43 @@ Execute only `next_action.command` returned by `context entry`:
63
66
  init`, enter the project root, read the generated `AGENTS.md`, and run this
64
67
  entry again.
65
68
 
69
+ If the user explicitly asks to correct or revise an existing approved or built
70
+ knowledge page, first let `context entry` relocate into the existing workspace
71
+ and evaluate its current Route once. Resolve a blocking workspace diagnostic,
72
+ evidence-maintenance action, or already-pending Review batch first; these may
73
+ change the approved baseline. Before continuing unrelated capture, extraction,
74
+ package configuration, or build work, start the correction with:
75
+
76
+ ```bash
77
+ context revise "<the user's page title, approved path, ViewRef, or wording>" --format json
78
+ ```
79
+
80
+ When the target is unique, run the returned status command and follow
81
+ `route.document-revision.requested`. When candidates are returned, select one
82
+ only if the conversation identifies it uniquely; otherwise ask which page the
83
+ user means. Never edit the approved base page or `dist/` for this operation.
84
+ After the Route validates the revision, continue normally: Context will offer
85
+ the package build when the correction makes its output stale.
86
+
66
87
  ### Conversation modes
67
88
 
68
- Enable debugging only when the user explicitly requests it. Run `context debug
69
- enable` first; debugging records traces below `.tmp/context-runtime/debug/` but
70
- does not grant workflow authority or provide source evidence.
89
+ Enable debugging only when the user explicitly requests it. If initialization
90
+ is required, pass `--debug` to `context entry` and execute its returned
91
+ `context init ... --debug` command; do not run a workspace-only debug command
92
+ before initialization. For an existing workspace, run `context debug enable`
93
+ before workflow evaluation. Debugging records traces below
94
+ `.tmp/context-runtime/debug/` but does not grant workflow authority or provide
95
+ source evidence.
96
+
97
+ Enable document optimization only when the user explicitly requests it. If
98
+ initialization is required, pass `--optimize-docs` through `context entry`; for
99
+ an existing workspace, run `context optimize-docs enable` before workflow
100
+ evaluation. The feature keeps approved pages source-faithful and stores only
101
+ changed full-page revisions beside them as `knowledge/**/*__revision.md`.
102
+ Default knowledge discovery excludes those reserved sidecars; validation and
103
+ package compilation apply them to the matching base page.
104
+ Follow the resulting Route instead of editing approved knowledge or package
105
+ output by hand.
71
106
 
72
107
  For explicitly authorized fully managed operation, use:
73
108
 
@@ -109,6 +144,10 @@ Treat `workflow.current` as the current-step authority:
109
144
  not inside a restricted child sandbox. Follow the Route-selected procedure
110
145
  for its audit and approval contract; never invent a payload, destination, or
111
146
  substitute command.
147
+ Treat a code-extraction batch preview as one Route action. Read its complete
148
+ index-unit report and keep same-kind capability or scale decisions in the
149
+ single returned Gate; do not ask about modules one by one. A non-delegatable
150
+ extraction Gate must stop even in fully managed mode.
112
151
  4. If `configuration` is present, edit only the named project file and use the
113
152
  selected resources as its contract.
114
153
  5. After every action or configuration change, run status again. The managed
@@ -119,6 +158,12 @@ Explain, ask, confirm, and summarize in the user's current conversation
119
158
  language. Keep commands, flags, paths, ids, status values, JSONL keys,
120
159
  `source_ref` values, and copied CLI tokens unchanged.
121
160
 
161
+ When the user explicitly asks to publish a completed build, treat publication
162
+ as a downstream distribution step outside the Context Route. Use only an
163
+ explicitly installed distribution tool and its documented complete-output
164
+ upload command. If no such tool is available, stop after the local build and
165
+ explain that Context itself does not publish to a hosted service.
166
+
122
167
  Do not infer repo sources, extraction scope, review decisions, or package output
123
168
  choices from surrounding files. Do not call source-repo operations such as
124
169
  clone, checkout, reset, fetch, install, build, or test without explicit user
@@ -40,8 +40,11 @@ context entry [project-dir] --language <language> --format json
40
40
 
41
41
  Use the user's explicit language choice when present; otherwise pass `zh-CN`
42
42
  for a Chinese conversation and `en` for an English conversation. Pass
43
- `project-dir`, `--name`, `--dev`, or `--debug` only when the user explicitly
44
- requested that initialization choice. Pass `--managed` only after the user
43
+ `project-dir`, `--name`, `--dev`, `--debug`, or `--optimize-docs` only when the
44
+ user explicitly requested that initialization choice. Treat requests to enable
45
+ document compilation optimization, document formatting optimization, or
46
+ equivalent conservative build-time cleanup as `--optimize-docs`. Pass
47
+ `--managed` only after the user
45
48
  explicitly authorizes fully managed operation in this conversation.
46
49
 
47
50
  If the `context` process itself cannot start because the command is missing
@@ -71,11 +74,43 @@ Execute only `next_action.command` returned by `context entry`:
71
74
  init`, enter the project root, read the generated `AGENTS.md`, and run this
72
75
  entry again.
73
76
 
77
+ If the user explicitly asks to correct or revise an existing approved or built
78
+ knowledge page, first let `context entry` relocate into the existing workspace
79
+ and evaluate its current Route once. Resolve a blocking workspace diagnostic,
80
+ evidence-maintenance action, or already-pending Review batch first; these may
81
+ change the approved baseline. Before continuing unrelated capture, extraction,
82
+ package configuration, or build work, start the correction with:
83
+
84
+ ```bash
85
+ context revise "<the user's page title, approved path, ViewRef, or wording>" --format json
86
+ ```
87
+
88
+ When the target is unique, run the returned status command and follow
89
+ `route.document-revision.requested`. When candidates are returned, select one
90
+ only if the conversation identifies it uniquely; otherwise ask which page the
91
+ user means. Never edit the approved base page or `dist/` for this operation.
92
+ After the Route validates the revision, continue normally: Context will offer
93
+ the package build when the correction makes its output stale.
94
+
74
95
  ### Conversation modes
75
96
 
76
- Enable debugging only when the user explicitly requests it. Run `context debug
77
- enable` first; debugging records traces below `.tmp/context-runtime/debug/` but
78
- does not grant workflow authority or provide source evidence.
97
+ Enable debugging only when the user explicitly requests it. If initialization
98
+ is required, pass `--debug` to `context entry` and execute its returned
99
+ `context init ... --debug` command; do not run a workspace-only debug command
100
+ before initialization. For an existing workspace, run `context debug enable`
101
+ before workflow evaluation. Debugging records traces below
102
+ `.tmp/context-runtime/debug/` but does not grant workflow authority or provide
103
+ source evidence.
104
+
105
+ Enable document optimization only when the user explicitly requests it. If
106
+ initialization is required, pass `--optimize-docs` through `context entry`; for
107
+ an existing workspace, run `context optimize-docs enable` before workflow
108
+ evaluation. The feature keeps approved pages source-faithful and stores only
109
+ changed full-page revisions beside them as `knowledge/**/*__revision.md`.
110
+ Default knowledge discovery excludes those reserved sidecars; validation and
111
+ package compilation apply them to the matching base page.
112
+ Follow the resulting Route instead of editing approved knowledge or package
113
+ output by hand.
79
114
 
80
115
  For explicitly authorized fully managed operation, use:
81
116
 
@@ -117,6 +152,10 @@ Treat `workflow.current` as the current-step authority:
117
152
  not inside a restricted child sandbox. Follow the Route-selected procedure
118
153
  for its audit and approval contract; never invent a payload, destination, or
119
154
  substitute command.
155
+ Treat a code-extraction batch preview as one Route action. Read its complete
156
+ index-unit report and keep same-kind capability or scale decisions in the
157
+ single returned Gate; do not ask about modules one by one. A non-delegatable
158
+ extraction Gate must stop even in fully managed mode.
120
159
  4. If `configuration` is present, edit only the named project file and use the
121
160
  selected resources as its contract.
122
161
  5. After every action or configuration change, run status again. The managed
@@ -127,6 +166,12 @@ Explain, ask, confirm, and summarize in the user's current conversation
127
166
  language. Keep commands, flags, paths, ids, status values, JSONL keys,
128
167
  `source_ref` values, and copied CLI tokens unchanged.
129
168
 
169
+ When the user explicitly asks to publish a completed build, treat publication
170
+ as a downstream distribution step outside the Context Route. Use only an
171
+ explicitly installed distribution tool and its documented complete-output
172
+ upload command. If no such tool is available, stop after the local build and
173
+ explain that Context itself does not publish to a hosted service.
174
+
130
175
  Do not infer repo sources, extraction scope, review decisions, or package output
131
176
  choices from surrounding files. Do not call source-repo operations such as
132
177
  clone, checkout, reset, fetch, install, build, or test without explicit user
@@ -0,0 +1,6 @@
1
+ schema: agent-graph.action.v1
2
+ id: optimize-documents
3
+ runner: host
4
+ effect: write
5
+ handler: context.document-optimization.next
6
+ inputSchema: schemas/document-optimization-decisions.schema.json
@@ -0,0 +1,5 @@
1
+ schema: agent-graph.action.v1
2
+ id: preview-extraction-batch
3
+ runner: host
4
+ effect: write
5
+ handler: context.extract.preview-batch
@@ -0,0 +1,5 @@
1
+ schema: agent-graph.action.v1
2
+ id: revise-document
3
+ runner: host
4
+ effect: read
5
+ handler: context.document-revision.next
@@ -24,6 +24,10 @@ codes:
24
24
  - { code: route.capture.pending-target, kind: route-reason, summary: Capture the next declared document target., document: resources/procedures/document-capture.md }
25
25
  - { code: route.extract.scope-required, kind: route-reason, summary: Code extraction scope has not been confirmed., document: resources/procedures/code-extraction.md }
26
26
  - { code: route.extract.configuration-required, kind: route-reason, summary: Registered repository sources are missing extraction declarations., document: resources/procedures/project-configuration.md }
27
+ - { code: route.extract.capability-required, kind: route-reason, summary: One or more code index units require missing material or a narrower plan., document: resources/procedures/code-extraction.md }
28
+ - { code: route.extract.preview-required, kind: route-reason, summary: Preview all pending code index units before candidate writes., document: resources/procedures/code-extraction.md }
29
+ - { code: route.extract.ownership-required, kind: route-reason, summary: Revise the index plan so every projected page has one output owner., document: resources/procedures/code-extraction.md }
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 }
27
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 }
28
32
  - { code: route.document.classification-required, kind: route-reason, summary: A captured document needs an evidence-backed collection decision., document: resources/procedures/document-classification.md }
29
33
  - { 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 }
@@ -38,5 +42,7 @@ codes:
38
42
  - { code: route.package.output-required, kind: route-reason, summary: Approved knowledge has no confirmed package output., document: resources/procedures/package-output.md }
39
43
  - { code: route.package.configuration-required, kind: route-reason, summary: Declare the confirmed package output in the Context project., document: resources/procedures/package-output.md }
40
44
  - { code: route.package.template-review-required, kind: route-reason, summary: "Replace or edit package templates, or explicitly accept the generic defaults.", document: resources/procedures/package-output.md }
45
+ - { code: route.document-revision.requested, kind: route-reason, summary: Apply and validate the user's requested correction on one approved knowledge page., document: resources/procedures/document-revision.md }
46
+ - { code: route.document-optimization.pending, kind: route-reason, summary: Resolve the current source-faithful document revision batch before building packages., document: resources/procedures/document-optimization.md }
41
47
  - { code: route.build.package-stale, kind: route-reason, summary: Build the declared package outputs from current approved knowledge., document: resources/procedures/close-and-build.md }
42
48
  - { code: route.logs.delivery-pending, kind: route-reason, summary: Send locally queued runtime logs through the configured generic sink., document: resources/procedures/close-and-build.md }