@c4a/context-cli 0.6.1-beta.2 → 0.6.1-beta.4

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 (57) hide show
  1. package/README.md +20 -9
  2. package/README.zh-CN.md +10 -8
  3. package/cli.js +66051 -62866
  4. package/docs/quickstart.md +13 -0
  5. package/package.json +3 -3
  6. package/plugins/README.md +18 -2
  7. package/plugins/README_CN.md +16 -2
  8. package/plugins/VERSION +1 -1
  9. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  10. package/plugins/claude/commands/continue.md +33 -4
  11. package/plugins/claude/commands/init.md +21 -17
  12. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  13. package/plugins/codex/skills/continue/SKILL.md +33 -4
  14. package/plugins/codex/skills/init/SKILL.md +23 -19
  15. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  16. package/plugins/cursor/commands/context-continue.md +33 -4
  17. package/plugins/cursor/commands/context-init.md +24 -20
  18. package/plugins/skills/context-continue/SKILL.md +33 -4
  19. package/plugins/skills/context-init/SKILL.md +23 -19
  20. package/providers/context/actions/accept-package-templates.yaml +5 -0
  21. package/providers/context/actions/align-next.yaml +1 -1
  22. package/providers/context/actions/apply-managed-review.yaml +0 -1
  23. package/providers/context/actions/apply-structure-confirmation.yaml +0 -1
  24. package/providers/context/actions/capture-next.yaml +0 -1
  25. package/providers/context/actions/compile-next.yaml +0 -1
  26. package/providers/context/actions/configure-code-extraction.yaml +0 -1
  27. package/providers/context/actions/configure-document-capture.yaml +0 -1
  28. package/providers/context/actions/configure-package-output.yaml +0 -1
  29. package/providers/context/actions/configure-prose-lifecycle.yaml +0 -1
  30. package/providers/context/actions/ensure-repository-sources.yaml +1 -1
  31. package/providers/context/actions/extract-next.yaml +0 -1
  32. package/providers/context/actions/repair-project-entry.yaml +0 -1
  33. package/providers/context/actions/repair-workspace-state.yaml +0 -1
  34. package/providers/context/codes.yaml +2 -0
  35. package/providers/context/graphs/workspace.yaml +26 -1
  36. package/providers/context/manifest.json +95 -68
  37. package/providers/context/provider.yaml +1 -1
  38. package/providers/context/resources/diagnostics/projection-stale.md +13 -0
  39. package/providers/context/resources/dialogue/document-classification.md +2 -1
  40. package/providers/context/resources/dialogue/package-output.md +5 -7
  41. package/providers/context/resources/manuals/guides/package-outputs.md +40 -37
  42. package/providers/context/resources/manuals/reference/package-templates.md +36 -48
  43. package/providers/context/resources/manuals/reference/project-api.md +95 -12
  44. package/providers/context/resources/manuals/reference/template-variables.md +12 -11
  45. package/providers/context/resources/procedures/close-and-build.md +3 -2
  46. package/providers/context/resources/procedures/code-extraction.md +16 -2
  47. package/providers/context/resources/procedures/document-capture.md +14 -0
  48. package/providers/context/resources/procedures/document-classification.md +3 -1
  49. package/providers/context/resources/procedures/evidence-maintenance.md +0 -1
  50. package/providers/context/resources/procedures/knowledge-review.md +0 -1
  51. package/providers/context/resources/procedures/package-output.md +17 -11
  52. package/providers/context/resources/procedures/project-configuration.md +0 -1
  53. package/providers/context/resources/procedures/prose-align.md +45 -0
  54. package/providers/context/resources/procedures/verify-and-repair.md +0 -1
  55. package/providers/context/resources/semantic/align/candidate-resolution.md +4 -2
  56. package/providers/context/resources/semantic/align/structure-planning.md +24 -8
  57. package/providers/context/schemas/prose-structure-batch.schema.json +35 -0
@@ -0,0 +1,13 @@
1
+ ---
2
+ schema: agent-graph.resource.v1
3
+ id: diagnostic.projection-stale
4
+ kind: diagnostic
5
+ mediaType: text/markdown
6
+ ---
7
+
8
+ # Approved projection is stale
9
+
10
+ Approved Markdown changed successfully. Its derived `knowledge/structure.yaml`
11
+ projection has not been rebuilt yet. Run only the revision-bound close command
12
+ selected by the current Route. This is an expected lifecycle transition, not a
13
+ content verification failure.
@@ -7,7 +7,8 @@ mediaType: text/markdown
7
7
  # Document-classification dialogue
8
8
 
9
9
  Do not recommend a collection before reading the collection-neutral evidence
10
- view. Summarize the observed document shape, explain one evidence-backed
10
+ view and every required source-body resource. Summarize the observed document
11
+ shape, explain one evidence-backed
11
12
  recommendation, and describe its package root:
12
13
 
13
14
  | Collection | Use when the evidence primarily represents | Package root |
@@ -19,13 +19,11 @@ with more than the configured threshold gets its own child index. Templates
19
19
  under `src/package-templates/` are editable presentation, not a second factual
20
20
  source.
21
21
 
22
- After the user chooses an Agent knowledge-base package, explain that the
23
- package name is its default single-level knowledge namespace. Ask for an
24
- override only when the user needs another single- or multi-segment path. Each
25
- segment may use lowercase letters and numbers joined by hyphens or dots. Ask
26
- separately whether Skills need a short optional prefix, then maintain their
27
- complete final names in the template. Do not expose downstream layout-version
28
- terminology or ask for platform-specific identity fields.
22
+ After the user chooses an Agent knowledge-base package, explain that its
23
+ knowledge roots are flat inside `dist/<package-name>/`; do not ask for a second
24
+ package namespace. Ask whether Skills need a short optional prefix, then
25
+ maintain their complete final names in the template. Do not expose downstream
26
+ layout terminology or ask for platform-specific identity fields.
29
27
 
30
28
  Do not offer a hidden `both` shortcut. If the user wants multiple outputs,
31
29
  declare and inspect one first, then obtain confirmation for the next. Mention
@@ -49,8 +49,7 @@ least one `SKILL.md` and `wikis/index.md`.
49
49
  The default `src/package-templates/kb/` template is only a starting point.
50
50
  Inspect the generated `dist/<package-name>/` before calling it usable.
51
51
 
52
- KB packages use their package name as a single-level knowledge namespace by
53
- default:
52
+ KB packages use flat package-relative knowledge roots:
54
53
 
55
54
  ```ts
56
55
  kbPackage({
@@ -59,44 +58,43 @@ kbPackage({
59
58
  });
60
59
  ```
61
60
 
62
- This keeps the build folder name independent from install paths and produces
63
- paths such as:
61
+ The package name already identifies the surrounding build folder, so the
62
+ output does not repeat it inside each root:
64
63
 
65
64
  ```text
66
65
  skills/knowledge-query/SKILL.md
67
- wikis/component-lib-kb/index.md
68
- guides/component-lib-kb/...
69
- rules/component-lib-kb/...
70
- feats/component-lib-kb/...
66
+ wikis/index.md
67
+ guides/...
68
+ rules/...
69
+ feats/...
71
70
  ```
72
71
 
73
- Ask for a custom namespace only when the user needs something other than the
74
- package name. An explicit value may contain multiple safe lowercase path
75
- segments:
76
-
77
- ```ts
78
- distribution: { knowledgeNamespace: "platform/component-lib" }
79
- ```
80
-
81
- Each segment may contain letters and numbers joined by hyphens or dots; keep
82
- the complete value concise and stable. Context treats it as an opaque knowledge
83
- path and does not infer downstream platform identifiers or classify package
84
- content.
72
+ Do not ask for another distribution namespace. Older workspaces may still
73
+ contain `distribution.knowledgeNamespace`; Context accepts that legacy input
74
+ without using it to shape the package.
85
75
 
86
76
  Skill names are separate. Ask whether the author wants a short optional Skill
87
77
  prefix, then maintain the complete final template directory name directly—for
88
- example `skills/android-query/SKILL.md`. Context never prepends the knowledge
89
- namespace to a Skill name.
78
+ example `skills/android-query/SKILL.md`. Package-root layout never renames a
79
+ Skill.
90
80
 
91
- The default `knowledge-query` skill carries the structure-first query
92
- discipline: start from OKF directory indexes, use
81
+ The default `knowledge-query` Skill is a complete generic query entry. It
82
+ carries the structure-first query discipline: start from OKF directory indexes, use
93
83
  `context-build-inventory.json` edge records for package-visible relationships,
94
84
  inspect page `sources` / `context:section` source_ref metadata, cite
95
85
  page/section evidence, and report explicit gaps when the package does not cover
96
86
  a requested fact. It does not treat direct grep over bundled OKF root
97
- directories as the primary discovery path. Users can edit any template file
98
- under `src/package-templates/kb/` before build to create their own skills,
99
- prompts, routing rules, or package instructions.
87
+ directories as the primary discovery path. Its final template-author section
88
+ requires package authors to replace or edit the generic routing when the
89
+ package needs project-specific terminology, entry points, known limits, or
90
+ task workflows. Authors may explicitly accept the generic default when it is
91
+ intentionally sufficient.
92
+
93
+ The same inventory exposes `structure.relationship_coverage`. It records
94
+ whether selected codegraph pages have current source-backed AST relationship
95
+ metadata, how many codegraph views were selected, and how many package-visible
96
+ edges were emitted. An empty edge list is therefore explicit evidence of a
97
+ coverage state, not permission to invent a dependency.
100
98
 
101
99
  The generated `wikis/` directory is the default OKF root and follows the C4A OKF
102
100
  Profile. Internal production collections are mapped into package OKF roots such
@@ -109,9 +107,8 @@ contain Markdown with OKF fields and C4A extension fields at the top level, plus
109
107
  `visibility`, and `code_symbols` are not nested under `context`, and page
110
108
  frontmatter does not contain `source_refs`. The package root is an agent
111
109
  package; the OKF-compatible interchange surface is the selected OKF root
112
- subtrees under `dist/<package-name>/`. The required logical template entry is
113
- `wikis/index.md`; a namespaced package writes it to
114
- `wikis/<knowledge-namespace>/index.md`.
110
+ subtrees under `dist/<package-name>/`. The required template entry and final
111
+ output path are both `wikis/index.md`.
115
112
 
116
113
  Current collection mapping:
117
114
 
@@ -142,7 +139,8 @@ occupies `wikis/**/index.md`.
142
139
  Tell the user it can be edited before build to describe the package scope,
143
140
  intended users, and query guidance.
144
141
 
145
- The default root index is a starter, not a finished information architecture.
142
+ The default root index is a usable generic entry, not a project-specific
143
+ information architecture.
146
144
  It links directly to pages in small child directories and to a child
147
145
  `index.md` when that directory exceeds the configured navigation threshold.
148
146
  The default threshold is 50 selected knowledge pages. Use Handlebars variables such as
@@ -150,6 +148,13 @@ The default threshold is 50 selected knowledge pages. Use Handlebars variables s
150
148
  custom navigation. Before customizing it, read
151
149
  `node_modules/@c4a/context/docs/reference/template-variables.md`.
152
150
 
151
+ Newly initialized generic templates must be replaced, edited, or explicitly
152
+ accepted before the first build. `context status` exposes that choice as a
153
+ package template Review Gate. Use only the revision-bound command returned by
154
+ that Route to accept an unchanged generic default; edit files under
155
+ `src/package-templates/` when customizing. Context compares file digests and
156
+ records the decision without evaluating the meaning of template prose.
157
+
153
158
  Template paths are rendered before selected knowledge is copied. A rendered
154
159
  template path must not collide with a selected knowledge path. If the build
155
160
  reports a collision, rename the template file or exclude that knowledge path
@@ -236,12 +241,10 @@ We can also skip package output for now and keep only knowledge/.
236
241
  Which one should I declare first?
237
242
  ```
238
243
 
239
- If the user chooses the Agent knowledge-base package, explain that its package
240
- name is already the default knowledge namespace. Ask for an override only when
241
- the user needs a different single- or multi-segment path. Ask separately whether
242
- its Skills need a short prefix. Treat these as independent choices: the
243
- knowledge namespace controls only OKF roots, while the author maintains final
244
- Skill names.
244
+ If the user chooses the Agent knowledge-base package, explain that its OKF
245
+ roots are flat within `dist/<package-name>/`; do not ask for a second namespace.
246
+ Ask whether its Skills need a short prefix. The author maintains final Skill
247
+ names independently from package paths.
245
248
 
246
249
  Do not offer `both` as a shortcut. If the user wants multiple outputs, add one
247
250
  package first, verify the shape, then add another package after confirmation.
@@ -58,20 +58,15 @@ llmsPackage({
58
58
  | `template` | yes | Project-relative template directory or `{ path, vars }`. |
59
59
  | `select` | no | Approved knowledge selector. Omit to include all approved knowledge. Supports internal `collections`, OKF `okfRoots`, and `include` / `exclude` path patterns relative to `knowledge/`. |
60
60
  | `navigation` | no | KB directory-index policy. Defaults to `{ foldDirectoryIndexes: true, maxInlineEntries: 50 }`. |
61
- | `distribution` | no | Final knowledge-root namespace for a KB package. Defaults to `{ knowledgeNamespace: name }`; set it explicitly for a custom single- or multi-segment path. |
61
+ | `distribution` | no | Legacy input accepted from older workspaces. It no longer changes package paths and should not be added to new declarations. |
62
62
 
63
63
  `template` is required. Do not call `kbPackage({ name })` or
64
64
  `llmsPackage({ name })`.
65
65
 
66
- ## Knowledge Distribution Namespace
66
+ ## Flat Package Roots
67
67
 
68
- `name` identifies the build folder under `dist/` and is also the default
69
- single-level `distribution.knowledgeNamespace`. An explicit namespace may be
70
- one segment or a slash-separated sequence of safe lowercase path segments. A
71
- segment may contain letters and numbers joined by hyphens or dots, allowing
72
- identifiers such as `personal-user.123/package`. Keep every segment short,
73
- stable, and recognizable. Context treats the complete value as an opaque
74
- knowledge path and does not assign downstream meanings to individual segments.
68
+ `name` identifies the package boundary under `dist/`. Context does not repeat
69
+ that name inside the package's knowledge roots.
75
70
 
76
71
  Templates keep a logical, consumer-neutral layout:
77
72
 
@@ -83,39 +78,32 @@ rules/...
83
78
  feats/...
84
79
  ```
85
80
 
86
- For `name: "component-lib-kb"` with no explicit distribution, `context build`
87
- writes:
81
+ For `name: "component-lib-kb"`, `context build` writes:
88
82
 
89
83
  ```text
90
84
  skills/knowledge-query/SKILL.md
91
- wikis/component-lib-kb/index.md
92
- guides/component-lib-kb/...
93
- rules/component-lib-kb/...
94
- feats/component-lib-kb/...
85
+ wikis/index.md
86
+ guides/...
87
+ rules/...
88
+ feats/...
95
89
  ```
96
90
 
97
- The builder applies the knowledge mapping to template paths, copied knowledge,
98
- generated indexes, links, and inventory records. It does not apply the
99
- knowledge namespace to `skills/`, rewrite Markdown prose, or infer path
100
- segments from downstream platform identifiers. An explicit
101
- `distribution: { knowledgeNamespace: "platform/component-lib" }` produces the
102
- same shape under that multi-segment namespace instead.
103
-
104
- Because every KB package has a knowledge namespace, Skill templates must not
105
- hard-code flat package paths such as `wikis/index.md` or
106
- `rules/standards/index.md`.
107
- Use `{{wikisRoot}}`, `{{rulesRoot}}`, `{{guidesRoot}}`, or `{{featsRoot}}`
108
- instead. `context build` and `context status` reject flat Markdown links and
109
- inline-code paths in `skills/**/*.md` with
110
- `package/template-namespace-reference-flat`. This check is generic package
111
- validation; it does not depend on a downstream registry or distribution tool.
91
+ The builder maps copied knowledge, generated indexes, links, and inventory
92
+ records into these roots without rewriting Markdown prose or inferring a
93
+ downstream registry identity. New declarations should omit `distribution`.
94
+ Older declarations that still contain `distribution.knowledgeNamespace` remain
95
+ loadable, but the value does not change output paths or the build fingerprint.
96
+
97
+ Use `{{wikisRoot}}`, `{{rulesRoot}}`, `{{guidesRoot}}`, or `{{featsRoot}}` in
98
+ Skill templates so references share the package-root contract. These variables
99
+ render to the flat root names above.
112
100
 
113
101
  Each rendered Skill must live at `skills/<skill-name>/SKILL.md`, and its YAML
114
102
  frontmatter `name` must equal `<skill-name>`. Use `{{skillName}}` in custom
115
103
  Skill templates. Skill names are author-maintained: when a short prefix is
116
104
  useful, rename the template directory to the complete final name, such as
117
105
  `skills/android-query/`; Context does not derive it from
118
- `knowledgeNamespace`.
106
+ the package name.
119
107
 
120
108
  ## Template Variables
121
109
 
@@ -128,8 +116,8 @@ Built-in variables:
128
116
  |---|---|
129
117
  | `{{packageName}}` | Package name from the declaration. |
130
118
  | `{{packageKind}}` | `kb` or `llms`. |
131
- | `{{knowledgeNamespace}}` | Final KB knowledge namespace. Defaults to the package name; empty only for non-KB packages. |
132
- | `{{namespacedKnowledge}}` | Whether the package is a KB package with a knowledge namespace. |
119
+ | `{{knowledgeNamespace}}` | Legacy configured namespace when an older workspace still declares one; otherwise empty. Do not use it for new output paths. |
120
+ | `{{namespacedKnowledge}}` | Always `false`; retained only so older templates remain renderable. |
133
121
  | `{{skillName}}` | Current author-maintained Skill directory name. |
134
122
  | `{{skillPath}}` | Current Skill's final package-relative `SKILL.md` path. |
135
123
  | `{{wikisRoot}}`, `{{guidesRoot}}`, `{{rulesRoot}}`, `{{featsRoot}}` | Final package-relative OKF root paths. |
@@ -187,14 +175,14 @@ The default kb template includes:
187
175
  query copied knowledge pages structure-first, cite page/section evidence, use
188
176
  `context-build-inventory.json` edge records for package-visible
189
177
  relationships, and report gaps instead of inventing unsupported answers. The
178
+ build inventory also exposes `structure.relationship_coverage` so a consumer
179
+ can distinguish an observed zero-edge result from unknown relationship
180
+ coverage. The
190
181
  default entry OKF root is `wikis/`; packages that select additional internal
191
182
  collections expose
192
183
  `guides/`, `rules/`, or `feats/` indexes when those roots are selected.
193
184
  - `wikis/index.md`, the editable OKF bundle entry page for the generated
194
- `dist/<package-name>/wikis/<knowledge-namespace>/` directory.
195
-
196
- These are logical template paths. The package distribution namespace changes
197
- their final output paths as described above.
185
+ `dist/<package-name>/wikis/` directory.
198
186
 
199
187
  During `context build`, the root `wikis/index.md` is rendered from the template.
200
188
  The builder always provides an index for every selected OKF root. With the
@@ -205,7 +193,7 @@ its pages instead of producing one index per path segment.
205
193
  ## OKF Directory Indexes
206
194
 
207
195
  The generated
208
- `dist/<package-name>/wikis/<knowledge-namespace>/` tree is the required default
196
+ `dist/<package-name>/wikis/` tree is the required default
209
197
  KB entry surface. Internal collections are mapped into OKF roots during build:
210
198
  `codegraph`, `business`, and `product` go to `wikis/`; `architecture`, `sop`,
211
199
  `faq`, `decision`, and `incident` go to `guides/`; `standards` and `test` go to
@@ -241,11 +229,13 @@ Default navigation rules:
241
229
  an index path selected by the current navigation policy are rejected during
242
230
  build/status preflight.
243
231
 
244
- Users are expected to customize these template files. Edit
245
- `src/package-templates/kb/**` before `context build` to define project
246
- specific skills, prompts, routing rules, and package instructions. Do not add a
247
- package-name skill by default; add one only when the user wants project-specific
248
- behavior beyond knowledge lookup.
232
+ The generated templates are complete generic defaults. Before publishing,
233
+ package authors should replace or edit `src/package-templates/kb/**` when the
234
+ package needs project-specific skills, prompts, routing rules, terminology, or
235
+ package instructions. If the generic behavior is intentionally sufficient,
236
+ explicitly accept the unchanged default through the package-template Review
237
+ Route. Do not add a package-name Skill by default; add one only when the user
238
+ wants project-specific behavior beyond knowledge lookup.
249
239
 
250
240
  ## C4A OKF Profile
251
241
 
@@ -307,11 +297,9 @@ relationship citations inside the package instead of assuming the workspace
307
297
  `knowledge/structure.yaml` file is bundled.
308
298
 
309
299
  For KB packages, the inventory records `package.distribution` as
310
- `layout: "namespaced"` with the final `knowledge_namespace` and OKF root paths.
311
- Non-KB package types can remain `layout: "flat"`. Selected file and group
312
- records expose both the logical `okf_root` and final `okf_root_path`, so
313
- installers can inspect the layout without parsing paths or rewriting package
314
- content.
300
+ `layout: "flat"`, `knowledge_namespace: null`, and the four package-relative
301
+ OKF roots. Selected file and group records expose both the logical `okf_root`
302
+ and final `okf_root_path`, so consumers do not need to infer paths.
315
303
 
316
304
  Build expects approved knowledge to be closed when the project has source-bound
317
305
  document knowledge. When `workflow.current.reason_code` is
@@ -55,10 +55,11 @@ knowledge/codegraph/module-a/...
55
55
  knowledge/codegraph/module-b/...
56
56
  ```
57
57
 
58
- For prose Views, omit `containment` when the page is an independent collection
59
- entry. The CLI then derives `knowledge/<collection>/<slug>.md`. Set
60
- `containment` only when the approved structure intentionally places the page
61
- under a parent path; it is not a required source/module wrapper.
58
+ For prose Views, provide a stable filename `slug` and omit `path`; the CLI
59
+ derives the path. Omit `containment` when the page is an independent collection
60
+ entry, producing `knowledge/<collection>/<slug>.md`. Set `containment` only
61
+ when the approved structure intentionally places the page under a parent path;
62
+ it is not a required source/module wrapper.
62
63
 
63
64
  The registry stores this as one date entry containing several `modules` entries,
64
65
  and materializes each module at `sources/repo/<date>/<module>`.
@@ -185,7 +186,10 @@ with the next declared command in `workflow.current.commands`.
185
186
  Each command item declares its effect and availability. The current route's
186
187
  `gate` identifies the decision and authority boundary. Write commands are bound
187
188
  to the workflow revision; after one succeeds, rerun status instead of reusing
188
- the old command.
189
+ the old command. An external command also declares
190
+ `execution.target: agent-host`; execute it as a top-level Agent-host action so
191
+ network and credential-store access are not lost inside a restricted child
192
+ sandbox.
189
193
 
190
194
  ### `allSources("repo")`
191
195
 
@@ -251,11 +255,26 @@ context review approve-all <collection> --managed --format json
251
255
  context review approve-all --all --managed --format json
252
256
  ```
253
257
 
258
+ The default JSON result reports counts and change totals without listing every
259
+ candidate id or materialized path. Add `--verbose` only when debugging requires
260
+ the complete candidate and page details.
261
+
254
262
  Managed structure confirmation and Review use only the revision-bound commands
255
263
  returned by `workflow.current`. Source boundaries and unread source bodies,
256
264
  external operations, payload validation, deterministic close, and verification
257
265
  errors are never bypassed.
258
266
 
267
+ For consecutive mechanical routes, the Agent may run:
268
+
269
+ ```bash
270
+ context run --managed --until blocked-or-complete --format json
271
+ ```
272
+
273
+ This is a bounded host loop over the same revisioned routes. It stops before
274
+ read-only interpretation, project configuration, unresolved authority,
275
+ diagnostics, or a non-unique command plan; it does not add another workflow
276
+ entry or make semantic decisions.
277
+
259
278
  ### `captureFile`
260
279
 
261
280
  Capture a registered file source into a committed normalized document snapshot.
@@ -360,6 +379,7 @@ context run align:file:<source-name>:architecture --view read-plan --format json
360
379
  context run align:file:<source-name>:architecture --view source-index --compact --format json
361
380
  context run align:file:<source-name>:architecture --view span-detail --span <source-ref> --format json
362
381
  context run align:file:<source-name>:architecture --view span-text --span <source-ref> --format json
382
+ context run align:file:<source-name>:architecture --view existing-knowledge --query <title-or-stable-ref> --format json
363
383
  context run align:file:<source-name>:architecture --view schema --format json
364
384
  context run align:file:<source-name>:architecture --view semantic-rules --format json
365
385
  context run align:file:<source-name>:architecture --validate --input <structure.yaml> --format json
@@ -368,15 +388,64 @@ context run align:file:<source-name>:architecture --view structure-summary --inp
368
388
  context run align:file:<source-name>:architecture --stage --input <structure.yaml> --format json
369
389
  ```
370
390
 
391
+ When `workflow.current.batch` is present, several independent document slots
392
+ can be prepared in one Agent pass and validated or staged through one command:
393
+
394
+ ```yaml
395
+ schema: context.prose.structure-batch.v1
396
+ items:
397
+ - phase_id: align:file:<source-a>:architecture
398
+ input: .tmp/agent-payloads/<source-a>-structure.yaml
399
+ - phase_id: align:file:<source-b>:architecture
400
+ input: .tmp/agent-payloads/<source-b>-structure.yaml
401
+ ```
402
+
403
+ ```bash
404
+ context run --batch-input .tmp/agent-payloads/prose-structure-batch.yaml --validate --format json
405
+ context run --batch-input .tmp/agent-payloads/prose-structure-batch.yaml --stage --managed --format json
406
+ ```
407
+
408
+ Batch preflight validates every payload before writing. Stage writes ready
409
+ slots serially; it does not merge documents or decide their semantic shape.
410
+
411
+ Align results expose a recommended `payload_target.path` under
412
+ `.tmp/agent-payloads/`. Agents should use it for transient structure inputs and
413
+ may remove the file after a successful stage. The CLI continues to accept an
414
+ explicit alternative path; this is an authoring convention, not validation.
415
+
416
+ For the ordinary path, `read-plan` is a complete authoring packet: it includes
417
+ the payload contract, a budgeted canonical source-ref map, exact source-body
418
+ resources, and a direct `--stage` command. Read the bodies, author the payload,
419
+ and run that stage command. Request `source-index` only when the packet reports
420
+ omitted refs, and request `existing-knowledge` only when reusing or checking an
421
+ approved identity. The separate schema and validate views are optional
422
+ diagnostic tools, not required lifecycle steps.
423
+
371
424
  `--validate`, `--stage`, and `--confirm` are mutually exclusive operations. An
372
425
  `--input` without an operation is rejected unless the selected view explicitly
373
426
  consumes that input. Deterministic boundary repairs run internally before the
374
- result is returned. Successful validation returns a stage command with the
427
+ result is returned. `self_healed` includes input/output Section counts, the
428
+ number of original Sections split, and structural reason codes. Stage performs validation before writing and returns the
429
+ same diagnostics on failure; in managed mode, a valid stage also confirms the
430
+ structure. Successful standalone validation returns a stage command with the
375
431
  same file path. JSON run output keeps `next_action` first;
376
432
  schema and full reports stay behind explicit Views, while `--verbose` restores
377
433
  the full phase result and repeated contracts. Long diagnostics return a compact
378
434
  first page plus an exact diagnostics continuation command.
379
435
 
436
+ Validation returns `state: ready | repair-required | invalid`. Only `ready`
437
+ sets `valid: true` and may proceed to stage. `error_free: true` with
438
+ `state: repair-required` means no error diagnostic remains, but a declared
439
+ confirmation blocker still requires repair; it is not a successful result.
440
+
441
+ `existing-knowledge` is the authoring-time lookup for approved identities. It
442
+ returns stable NodeRefs, ViewRefs, titles, tags, collections, and section counts
443
+ without exposing workspace storage paths. `--query` performs deterministic
444
+ case-insensitive exact/prefix/substring matching; `--collection`,
445
+ `--node-type`, `--page-size`, and the returned continuation command narrow or
446
+ page the same View. Use it after reading source evidence and before introducing
447
+ a new Node identity. Structure validation remains the final duplicate gate.
448
+
380
449
  Align and compile evidence results include `semantic_rules`. Its `required`
381
450
  array is the rule subset selected for the current judgment, with a selection
382
451
  reason and content digest for each rule. `handle`, `digest`, and
@@ -400,7 +469,20 @@ After capture, the capture phase itself exposes collection-neutral `read-plan`,
400
469
  Status selects `route.document.classification-required` until every captured
401
470
  target has an evidence-backed, user-confirmed align declaration. Align then
402
471
  adds `schema` and `structure-summary` for structure work. Agents should not
403
- inspect `sources/` or `.tmp` directly.
472
+ scan `sources/` or `.tmp` to invent evidence. They may read only the exact
473
+ source-body files selected as required resources by the current Route; those
474
+ files carry stable content digests and must be read in full before a receipt is
475
+ reported. Read all required direct paths, then execute the Route's single
476
+ `resources.after_read.command`; the CLI writes and carries the merged receipt
477
+ set without requiring Agent-authored JSON. That acknowledgement response
478
+ already contains the re-evaluated `workflow.current`, so no additional status
479
+ command is needed.
480
+
481
+ Generated Context Views use the same content-addressed rule. Materialization
482
+ returns a receipt-set path and an exact post-read command. Read the complete
483
+ file, then execute that command; unchanged content remains current across
484
+ workflow revisions, while write and external commands still require the exact
485
+ current revision.
404
486
 
405
487
  Compile `read-plan`, `blockers`, and `diagnostics` Views are workspace-read-only
406
488
  and may run concurrently. Compile `--validate`, compile `--stage`, structure
@@ -437,9 +519,9 @@ compile:file:<source-name>:architecture
437
519
  compile:lark:<source-name>:architecture
438
520
  ```
439
521
 
440
- Compile requires confirmed `unapproved/structure.yaml`. It freezes the current
441
- structure for the compile round; if the user wants to change nodes, section
442
- ownership, or relationships, return to the align/structure gate.
522
+ Compile requires confirmed CLI-managed lifecycle structure. It freezes the
523
+ current structure for the compile round; if the user wants to change nodes,
524
+ section ownership, or relationships, return to the align/structure gate.
443
525
 
444
526
  Common commands:
445
527
 
@@ -523,7 +605,7 @@ package from a larger monorepo source.
523
605
  Use `context source inspect <date>/<module>` to list detected module/package
524
606
  boundaries before choosing the source. Use `context run <phase-id> --dry-run
525
607
  --format json` to check the resolved modules, file counts, symbol counts, and
526
- candidate estimate before writing `unapproved/entities.jsonl`. The dry-run
608
+ candidate estimate before writing the ignored lifecycle candidate ledger. The dry-run
527
609
  preview also includes `knowledgeTree` and `knowledgePathExamples`, which show
528
610
  where approved Markdown will land after review apply.
529
611
  Its module and total summaries distinguish `discoveredFiles`, `analyzedFiles`,
@@ -605,7 +687,8 @@ structure slots and every declared `pendingStructureTargets` item in the round;
605
687
  codegraph waits for every pending extract phase in the confirmed module round.
606
688
  Candidate count/hash therefore describes the complete current batch rather than
607
689
  one page, source slot, or module. Deterministic close later merges all active
608
- slots into `knowledge/structure.yaml`.
690
+ slots into `knowledge/structure.yaml`, retains only their source, collection,
691
+ and consumed snapshot hash as `source_inputs`, then removes the lifecycle slots.
609
692
 
610
693
  `status.structureBatch` lists unclassified, configuration-required, pending,
611
694
  and active structure slots together with the execution policy for the round.
@@ -97,13 +97,13 @@ Read node_modules/@c4a/context/docs/reference/template-variables.md.
97
97
  |---|---|---|
98
98
  | `packageName` | string | Package name from `kbPackage()` / `llmsPackage()`. |
99
99
  | `packageKind` | string | `kb` or `llms`. |
100
- | `knowledgeNamespace` | string | KB knowledge namespace; defaults to the package name and may be explicitly overridden. Empty for non-KB packages. |
101
- | `namespacedKnowledge` | boolean | Whether the KB package has a knowledge namespace. |
100
+ | `knowledgeNamespace` | string | Legacy configured namespace when an older workspace still declares one; otherwise empty. It does not change output paths. |
101
+ | `namespacedKnowledge` | boolean | Always `false`; retained so older templates remain renderable. |
102
102
  | `skillsRoot` | string | Skills root, currently `skills`. |
103
- | `wikisRoot` | string | Final wikis root, such as `wikis/component-lib-kb` or `wikis/platform/component-lib`. |
104
- | `guidesRoot` | string | Final guides root, such as `guides/component-lib-kb` or `guides/platform/component-lib`. |
105
- | `rulesRoot` | string | Final rules root, such as `rules/component-lib-kb` or `rules/platform/component-lib`. |
106
- | `featsRoot` | string | Final feats root, such as `feats/component-lib-kb` or `feats/platform/component-lib`. |
103
+ | `wikisRoot` | string | Final wikis root: `wikis`. |
104
+ | `guidesRoot` | string | Final guides root: `guides`. |
105
+ | `rulesRoot` | string | Final rules root: `rules`. |
106
+ | `featsRoot` | string | Final feats root: `feats`. |
107
107
  | `skillName` | string | Author-maintained name of the Skill currently being rendered. Empty outside a `skills/<name>/...` template. |
108
108
  | `skillPath` | string | Final package-relative `SKILL.md` path for the Skill currently being rendered. Empty outside a Skill template. |
109
109
  | `knowledgeCount` | number | Selected approved Markdown file count. |
@@ -145,7 +145,7 @@ Each item contains:
145
145
  | `internal_collection` | Alias for `internalCollection`. |
146
146
  | `collection` | Internal approved collection; alias for `internalCollection`. |
147
147
  | `okf_root` | OKF output root, for example `wikis`, `guides`, `rules`, or `feats`. |
148
- | `okf_root_path` | Final package-relative OKF root; for KB packages it includes the distribution namespace. |
148
+ | `okf_root_path` | Final flat package-relative OKF root. |
149
149
  | `node_ref` | Stable NodeRef from approved frontmatter, for example `entity/button`. |
150
150
  | `view_ref` | Stable ViewRef from approved frontmatter, for example `architecture:entity/button`. |
151
151
  | `pathWithinCollection` | Path below the OKF root, for example `component-lib/symbol/button.md`. |
@@ -183,7 +183,7 @@ Each group contains:
183
183
  | `internalCollection` | Internal approved collection; alias for `collection`. |
184
184
  | `internal_collection` | Alias for `internalCollection`. |
185
185
  | `okf_root` | OKF output root for this group, for example `wikis`, `guides`, `rules`, or `feats`. |
186
- | `okf_root_path` | Final package-relative OKF root; for KB packages it includes the distribution namespace. |
186
+ | `okf_root_path` | Final flat package-relative OKF root. |
187
187
  | `title` | Display title; defaults to `name`, or the OKF root title for a root group. |
188
188
  | `count` | Number of selected pages in this group. |
189
189
  | `hasIndex` | Whether the active package navigation policy generates `indexPath`. |
@@ -242,6 +242,7 @@ non-root directory gets its own index only when it contains more than 50
242
242
  descendant knowledge pages. Configure this with
243
243
  `kbPackage({ navigation: { foldDirectoryIndexes, maxInlineEntries } })`.
244
244
 
245
- The output is only a starter. Edit
246
- `src/package-templates/kb/wikis/index.md` to add project-specific reading
247
- paths, API entry points, or task-focused navigation before `context build`.
245
+ The output is only a starter. Edit the files under
246
+ `src/package-templates/kb/` when the package needs different reading paths or
247
+ navigation before `context build`. An unchanged generated starter must instead
248
+ be explicitly accepted through the current package-template Review Route.
@@ -8,7 +8,9 @@ mediaType: text/markdown
8
8
 
9
9
  Close deterministically derives `knowledge/structure.yaml` from approved
10
10
  Markdown and the confirmed structure snapshots. It validates the rebuilt
11
- projection; it does not rewrite approved page bodies.
11
+ projection; it does not rewrite approved page bodies. Before removing the
12
+ transient snapshots, it retains only each closed prose target's source,
13
+ collection, and consumed snapshot hash under `source_inputs`.
12
14
 
13
15
  Build runs only after close and verification are current. It writes declared
14
16
  packages under `dist/` and records an inventory receipt with added, updated,
@@ -17,4 +19,3 @@ removed, and index changes.
17
19
  Run only the current route command, then evaluate again. A successful build
18
20
  means the currently declared scope is current; newly captured or newly declared
19
21
  targets can reopen earlier graph nodes.
20
-
@@ -26,5 +26,19 @@ semantic knowledge. After confirmation, process exactly one pending extraction
26
26
  target and evaluate again.
27
27
 
28
28
  Do not open Review while another extraction target in the same batch remains.
29
- Unchanged approved symbols do not need another decision; new, changed, or
30
- unapproved candidates remain subject to the current Review policy.
29
+ Unchanged approved or rejected symbols do not need another decision; new or
30
+ changed candidates remain subject to the current Review policy.
31
+
32
+ For TypeScript sources, Context also carries extractor-reported AST relations
33
+ between selected symbols. A relation is projected only when both endpoints
34
+ resolve uniquely inside the selected module; external, unselected, and
35
+ ambiguous endpoints are counted as omissions instead of guessed. The extract
36
+ receipt reports `relationships.detected`, `emitted`, and omission counts.
37
+ Review materializes those source-backed relations with the approved symbol,
38
+ and deterministic close refreshes the typed edge projection.
39
+
40
+ Zero edges remain a valid result. Read `close.relationshipCoverage` or the
41
+ package inventory's `structure.relationship_coverage` to distinguish a current
42
+ source-backed extraction that found no approved edges from an older or
43
+ otherwise unknown relationship mode. Never infer missing edges from symbol
44
+ co-occurrence, filenames, or package size.
@@ -20,6 +20,20 @@ documents grants source-read permission for those named modules. A mention,
20
20
  possible-source discussion, or register-only request does not. An explicit
21
21
  refusal always wins.
22
22
 
23
+ When that permission is already present in the conversation, execute the
24
+ Gate's returned authority-carrying command. In managed mode it runs the
25
+ deterministic capture batch until the next real blocker; in ordinary mode it
26
+ reevaluates status with `context.source-read`. The authority remains in the
27
+ current command chain and is never persisted in the project. Never bypass the
28
+ Route by running a bare capture phase.
29
+
30
+ Document capture is an external action. Execute a returned command with
31
+ `execution.target: agent-host` through the Agent host so its network and
32
+ credential-store access remain available; do not nest it inside a restricted
33
+ child sandbox. If the CLI reports an external-environment requirement, retry
34
+ the same returned command through the host. Never downgrade credential
35
+ protection as a recovery step.
36
+
23
37
  Capture targets are a batch. Process one current target, evaluate status again,
24
38
  and continue until the graph reports the batch complete. Never treat one
25
39
  successful module as completion of the whole batch.