@c4a/context-cli 0.6.13 → 0.6.17

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 +6 -0
  2. package/README.zh-CN.md +5 -0
  3. package/cli.js +6114 -3390
  4. package/docs/document-optimization.md +58 -0
  5. package/docs/document-optimization.zh-CN.md +50 -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 +43 -2
  10. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  11. package/plugins/codex/skills/context/SKILL.md +43 -2
  12. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  13. package/plugins/cursor/commands/c4a-context.md +43 -2
  14. package/plugins/skills/c4a-context/SKILL.md +43 -2
  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,58 @@
1
+ # Document revisions
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.
7
+
8
+ To opt out during initialization:
9
+
10
+ ```bash
11
+ context init context --no-optimize-docs
12
+ ```
13
+
14
+ Existing workspaces retain their current setting. Change it explicitly with:
15
+
16
+ ```bash
17
+ context optimize-docs enable
18
+ context optimize-docs disable
19
+ context status --format json
20
+ ```
21
+
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:
25
+
26
+ ```text
27
+ knowledge/guides/setup.md
28
+ knowledge/guides/setup__revision.md
29
+ ```
30
+
31
+ The `__revision.md` suffix is reserved. Default knowledge discovery, structure,
32
+ search, and package selection exclude revision files. Validation and build
33
+ associate a revision with its sibling base page and apply it under the original
34
+ 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
36
+ revision are inferred. A page with no changes stores only one derived negative
37
+ cache key below `.tmp/context-runtime/document-optimization/`; replacement
38
+ prose and fragment metadata are not duplicated there.
39
+
40
+ After capture, review, or build, a user may ask conversationally to correct one
41
+ existing knowledge page. Start the correction by title, approved path, or
42
+ ViewRef:
43
+
44
+ ```bash
45
+ context revise "<title, approved path, or ViewRef>" --format json
46
+ ```
47
+
48
+ Context starts `route.document-revision.requested` only after resolving one
49
+ 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
52
+ the request and the next Route offers a package build when output is stale. If
53
+ broad document optimization was disabled, this entry activates only the target
54
+ page and keeps every other eligible page out of the pending batch. If upstream
55
+ content changes, the revision becomes a conflict and must be reviewed again.
56
+
57
+ Disabling moves active revision pages to Context runtime recovery storage. The
58
+ next build uses approved knowledge directly.
@@ -0,0 +1,50 @@
1
+ # 文档修订页
2
+
3
+ 新工作区默认开启保守的文档编译优化。它是面向来源可追溯正文的构建阶段,只修复
4
+ Markdown 排版、链接和明显的局部错误,不修改正式知识页,也不大段改写原意。
5
+
6
+ 初始化时如需关闭:
7
+
8
+ ```bash
9
+ context init context --no-optimize-docs
10
+ ```
11
+
12
+ 已有工作区保持当前设置,可显式调整:
13
+
14
+ ```bash
15
+ context optimize-docs enable
16
+ context optimize-docs disable
17
+ context status --format json
18
+ ```
19
+
20
+ 开启后,工作流只规划新增或发生变化的片段。Agent 可以保持片段不变,或提交
21
+ 保守的局部替换。只有实际改写的页面才在原文旁生成完整修订页:
22
+
23
+ ```text
24
+ knowledge/guides/setup.md
25
+ knowledge/guides/setup__revision.md
26
+ ```
27
+
28
+ `__revision.md` 是保留后缀。默认知识发现、结构、检索和包选择都排除修订页;
29
+ 校验和构建根据文件名把它关联回同目录原文,并仍按原文件名输出。修订页只额外
30
+ 记录无法推导的原文摘要;原文路径和修订片段由文件名与正文差异推导。完整修订
31
+ 页中未变化的片段直接推导为 `keep`;整页都不修改时,运行时只保存一个页级负
32
+ 缓存键,不重复保存改写正文或片段元数据。
33
+
34
+ 工作区采集、审核或构建完成后,用户可以直接通过对话要求修正某篇知识。Agent
35
+ 先使用标题、正式知识路径或 ViewRef 启动修订:
36
+
37
+ ```bash
38
+ context revise "<标题、正式知识路径或 ViewRef>" --format json
39
+ ```
40
+
41
+ CLI 只在目标唯一时创建或复用该页修订,并由 Agent Graph 返回
42
+ `route.document-revision.requested`。若有多个候选,Agent 必须依据当前对话选定,
43
+ 否则询问用户。Agent 只编辑面向读者的正文,不修改来源信息和
44
+ `context:section` 边界,随后运行 `context optimize-docs validate`。校验成功后,
45
+ 请求自动结束;若产物因此过期,下一条 Route 会直接提示重新构建。即使工作区
46
+ 此前关闭了整库文档编译优化,这个入口也只激活目标页面,不会让其他页面进入
47
+ 待优化队列。上游内容变化后,旧修订页会成为冲突,不会被静默应用。
48
+
49
+ 关闭后,修订页会被移动到 Context 的运行时恢复目录,下一次构建直接使用正式
50
+ 知识。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/context-cli",
3
- "version": "0.6.13",
3
+ "version": "0.6.17",
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.13",
27
+ "@c4a/context": "0.6.17",
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.13
1
+ 0.6.17
@@ -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.13",
4
+ "version": "0.6.17",
5
5
  "author": {
6
6
  "name": "c4a"
7
7
  },
@@ -29,8 +29,11 @@ context entry [project-dir] --language <language> --format json
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
31
  `project-dir`, `--name`, `--dev`, or `--debug` only when the user explicitly
32
- requested that initialization choice. Pass `--managed` only after the user
33
- explicitly authorizes fully managed operation in this conversation.
32
+ requested that initialization choice. New workspaces enable conservative
33
+ document compilation optimization by default. Pass `--no-optimize-docs` only
34
+ when the user explicitly asks to disable it during initialization. Pass
35
+ `--managed` only after the user explicitly authorizes fully managed operation
36
+ in this conversation.
34
37
 
35
38
  If the `context` process itself cannot start because the command is missing
36
39
  (`ENOENT`, or shell exit 127 explicitly identifying `context` as the missing
@@ -59,6 +62,24 @@ 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
85
  Enable debugging only when the user explicitly requests it. If initialization
@@ -69,6 +90,22 @@ before workflow evaluation. Debugging records traces below
69
90
  `.tmp/context-runtime/debug/` but does not grant workflow authority or provide
70
91
  source evidence.
71
92
 
93
+ 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.
100
+
101
+ For an existing workspace, respect its current `package.json` setting. Run
102
+ `context optimize-docs enable` or `context optimize-docs disable` only when the
103
+ user explicitly changes that preference. If initialization is required and the
104
+ user opts out, pass `--no-optimize-docs` through `context entry`; otherwise let
105
+ the default initialization command enable it.
106
+ Follow the resulting Route instead of editing approved knowledge or package
107
+ output by hand.
108
+
72
109
  For explicitly authorized fully managed operation, use:
73
110
 
74
111
  ```bash
@@ -109,6 +146,10 @@ Treat `workflow.current` as the current-step authority:
109
146
  not inside a restricted child sandbox. Follow the Route-selected procedure
110
147
  for its audit and approval contract; never invent a payload, destination, or
111
148
  substitute command.
149
+ Treat a code-extraction batch preview as one Route action. Read its complete
150
+ index-unit report and keep same-kind capability or scale decisions in the
151
+ single returned Gate; do not ask about modules one by one. A non-delegatable
152
+ extraction Gate must stop even in fully managed mode.
112
153
  4. If `configuration` is present, edit only the named project file and use the
113
154
  selected resources as its contract.
114
155
  5. After every action or configuration change, run status again. The managed
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c4a",
3
- "version": "0.6.13",
3
+ "version": "0.6.17",
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.13",
21
+ "shortDescription": "Initialize and advance a local, source-linked project knowledge workspace.\nv0.6.17",
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",
@@ -41,8 +41,11 @@ context entry [project-dir] --language <language> --format json
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
43
  `project-dir`, `--name`, `--dev`, or `--debug` only when the user explicitly
44
- requested that initialization choice. Pass `--managed` only after the user
45
- explicitly authorizes fully managed operation in this conversation.
44
+ requested that initialization choice. New workspaces enable conservative
45
+ document compilation optimization by default. Pass `--no-optimize-docs` only
46
+ when the user explicitly asks to disable it during initialization. Pass
47
+ `--managed` only after the user explicitly authorizes fully managed operation
48
+ in this conversation.
46
49
 
47
50
  If the `context` process itself cannot start because the command is missing
48
51
  (`ENOENT`, or shell exit 127 explicitly identifying `context` as the missing
@@ -71,6 +74,24 @@ 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
97
  Enable debugging only when the user explicitly requests it. If initialization
@@ -81,6 +102,22 @@ before workflow evaluation. Debugging records traces below
81
102
  `.tmp/context-runtime/debug/` but does not grant workflow authority or provide
82
103
  source evidence.
83
104
 
105
+ 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.
112
+
113
+ For an existing workspace, respect its current `package.json` setting. Run
114
+ `context optimize-docs enable` or `context optimize-docs disable` only when the
115
+ user explicitly changes that preference. If initialization is required and the
116
+ user opts out, pass `--no-optimize-docs` through `context entry`; otherwise let
117
+ the default initialization command enable it.
118
+ Follow the resulting Route instead of editing approved knowledge or package
119
+ output by hand.
120
+
84
121
  For explicitly authorized fully managed operation, use:
85
122
 
86
123
  ```bash
@@ -121,6 +158,10 @@ Treat `workflow.current` as the current-step authority:
121
158
  not inside a restricted child sandbox. Follow the Route-selected procedure
122
159
  for its audit and approval contract; never invent a payload, destination, or
123
160
  substitute command.
161
+ Treat a code-extraction batch preview as one Route action. Read its complete
162
+ index-unit report and keep same-kind capability or scale decisions in the
163
+ single returned Gate; do not ask about modules one by one. A non-delegatable
164
+ extraction Gate must stop even in fully managed mode.
124
165
  4. If `configuration` is present, edit only the named project file and use the
125
166
  selected resources as its contract.
126
167
  5. After every action or configuration change, run status again. The managed
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "c4a",
3
3
  "displayName": "C4A Context",
4
- "version": "0.6.13",
4
+ "version": "0.6.17",
5
5
  "description": "Start or continue a project-local knowledge workspace through one graph-routed entry.",
6
6
  "author": {
7
7
  "name": "Context4AI",
@@ -33,8 +33,11 @@ context entry [project-dir] --language <language> --format json
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
35
  `project-dir`, `--name`, `--dev`, or `--debug` only when the user explicitly
36
- requested that initialization choice. Pass `--managed` only after the user
37
- explicitly authorizes fully managed operation in this conversation.
36
+ requested that initialization choice. New workspaces enable conservative
37
+ document compilation optimization by default. Pass `--no-optimize-docs` only
38
+ when the user explicitly asks to disable it during initialization. Pass
39
+ `--managed` only after the user explicitly authorizes fully managed operation
40
+ in this conversation.
38
41
 
39
42
  If the `context` process itself cannot start because the command is missing
40
43
  (`ENOENT`, or shell exit 127 explicitly identifying `context` as the missing
@@ -63,6 +66,24 @@ 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
89
  Enable debugging only when the user explicitly requests it. If initialization
@@ -73,6 +94,22 @@ before workflow evaluation. Debugging records traces below
73
94
  `.tmp/context-runtime/debug/` but does not grant workflow authority or provide
74
95
  source evidence.
75
96
 
97
+ 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.
104
+
105
+ For an existing workspace, respect its current `package.json` setting. Run
106
+ `context optimize-docs enable` or `context optimize-docs disable` only when the
107
+ user explicitly changes that preference. If initialization is required and the
108
+ user opts out, pass `--no-optimize-docs` through `context entry`; otherwise let
109
+ the default initialization command enable it.
110
+ Follow the resulting Route instead of editing approved knowledge or package
111
+ output by hand.
112
+
76
113
  For explicitly authorized fully managed operation, use:
77
114
 
78
115
  ```bash
@@ -113,6 +150,10 @@ Treat `workflow.current` as the current-step authority:
113
150
  not inside a restricted child sandbox. Follow the Route-selected procedure
114
151
  for its audit and approval contract; never invent a payload, destination, or
115
152
  substitute command.
153
+ Treat a code-extraction batch preview as one Route action. Read its complete
154
+ index-unit report and keep same-kind capability or scale decisions in the
155
+ single returned Gate; do not ask about modules one by one. A non-delegatable
156
+ extraction Gate must stop even in fully managed mode.
116
157
  4. If `configuration` is present, edit only the named project file and use the
117
158
  selected resources as its contract.
118
159
  5. After every action or configuration change, run status again. The managed
@@ -41,8 +41,11 @@ context entry [project-dir] --language <language> --format json
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
43
  `project-dir`, `--name`, `--dev`, or `--debug` only when the user explicitly
44
- requested that initialization choice. Pass `--managed` only after the user
45
- explicitly authorizes fully managed operation in this conversation.
44
+ requested that initialization choice. New workspaces enable conservative
45
+ document compilation optimization by default. Pass `--no-optimize-docs` only
46
+ when the user explicitly asks to disable it during initialization. Pass
47
+ `--managed` only after the user explicitly authorizes fully managed operation
48
+ in this conversation.
46
49
 
47
50
  If the `context` process itself cannot start because the command is missing
48
51
  (`ENOENT`, or shell exit 127 explicitly identifying `context` as the missing
@@ -71,6 +74,24 @@ 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
97
  Enable debugging only when the user explicitly requests it. If initialization
@@ -81,6 +102,22 @@ before workflow evaluation. Debugging records traces below
81
102
  `.tmp/context-runtime/debug/` but does not grant workflow authority or provide
82
103
  source evidence.
83
104
 
105
+ 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.
112
+
113
+ For an existing workspace, respect its current `package.json` setting. Run
114
+ `context optimize-docs enable` or `context optimize-docs disable` only when the
115
+ user explicitly changes that preference. If initialization is required and the
116
+ user opts out, pass `--no-optimize-docs` through `context entry`; otherwise let
117
+ the default initialization command enable it.
118
+ Follow the resulting Route instead of editing approved knowledge or package
119
+ output by hand.
120
+
84
121
  For explicitly authorized fully managed operation, use:
85
122
 
86
123
  ```bash
@@ -121,6 +158,10 @@ Treat `workflow.current` as the current-step authority:
121
158
  not inside a restricted child sandbox. Follow the Route-selected procedure
122
159
  for its audit and approval contract; never invent a payload, destination, or
123
160
  substitute command.
161
+ Treat a code-extraction batch preview as one Route action. Read its complete
162
+ index-unit report and keep same-kind capability or scale decisions in the
163
+ single returned Gate; do not ask about modules one by one. A non-delegatable
164
+ extraction Gate must stop even in fully managed mode.
124
165
  4. If `configuration` is present, edit only the named project file and use the
125
166
  selected resources as its contract.
126
167
  5. After every action or configuration change, run status again. The managed
@@ -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 }