@c4a/context-cli 0.6.1-beta.3 → 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 (41) hide show
  1. package/README.md +20 -9
  2. package/README.zh-CN.md +10 -8
  3. package/cli.js +71833 -69465
  4. package/docs/quickstart.md +7 -0
  5. package/package.json +3 -3
  6. package/plugins/README.md +7 -2
  7. package/plugins/README_CN.md +7 -2
  8. package/plugins/VERSION +1 -1
  9. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  10. package/plugins/claude/commands/continue.md +17 -3
  11. package/plugins/claude/commands/init.md +7 -4
  12. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  13. package/plugins/codex/skills/continue/SKILL.md +17 -3
  14. package/plugins/codex/skills/init/SKILL.md +6 -3
  15. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  16. package/plugins/cursor/commands/context-continue.md +17 -3
  17. package/plugins/cursor/commands/context-init.md +7 -4
  18. package/plugins/skills/context-continue/SKILL.md +17 -3
  19. package/plugins/skills/context-init/SKILL.md +6 -3
  20. package/providers/context/actions/accept-package-templates.yaml +5 -0
  21. package/providers/context/actions/align-next.yaml +1 -0
  22. package/providers/context/codes.yaml +2 -0
  23. package/providers/context/graphs/workspace.yaml +26 -1
  24. package/providers/context/manifest.json +63 -36
  25. package/providers/context/provider.yaml +1 -1
  26. package/providers/context/resources/diagnostics/projection-stale.md +13 -0
  27. package/providers/context/resources/dialogue/document-classification.md +2 -1
  28. package/providers/context/resources/dialogue/package-output.md +5 -7
  29. package/providers/context/resources/manuals/guides/package-outputs.md +40 -37
  30. package/providers/context/resources/manuals/reference/package-templates.md +36 -48
  31. package/providers/context/resources/manuals/reference/project-api.md +75 -12
  32. package/providers/context/resources/manuals/reference/template-variables.md +12 -11
  33. package/providers/context/resources/procedures/close-and-build.md +3 -1
  34. package/providers/context/resources/procedures/code-extraction.md +16 -2
  35. package/providers/context/resources/procedures/document-capture.md +14 -0
  36. package/providers/context/resources/procedures/document-classification.md +3 -0
  37. package/providers/context/resources/procedures/package-output.md +17 -11
  38. package/providers/context/resources/procedures/prose-align.md +45 -0
  39. package/providers/context/resources/semantic/align/candidate-resolution.md +4 -2
  40. package/providers/context/resources/semantic/align/structure-planning.md +8 -5
  41. package/providers/context/schemas/prose-structure-batch.schema.json +35 -0
@@ -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,6 +255,10 @@ 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
@@ -380,15 +388,56 @@ context run align:file:<source-name>:architecture --view structure-summary --inp
380
388
  context run align:file:<source-name>:architecture --stage --input <structure.yaml> --format json
381
389
  ```
382
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
+
383
424
  `--validate`, `--stage`, and `--confirm` are mutually exclusive operations. An
384
425
  `--input` without an operation is rejected unless the selected view explicitly
385
426
  consumes that input. Deterministic boundary repairs run internally before the
386
- 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
387
431
  same file path. JSON run output keeps `next_action` first;
388
432
  schema and full reports stay behind explicit Views, while `--verbose` restores
389
433
  the full phase result and repeated contracts. Long diagnostics return a compact
390
434
  first page plus an exact diagnostics continuation command.
391
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
+
392
441
  `existing-knowledge` is the authoring-time lookup for approved identities. It
393
442
  returns stable NodeRefs, ViewRefs, titles, tags, collections, and section counts
394
443
  without exposing workspace storage paths. `--query` performs deterministic
@@ -420,7 +469,20 @@ After capture, the capture phase itself exposes collection-neutral `read-plan`,
420
469
  Status selects `route.document.classification-required` until every captured
421
470
  target has an evidence-backed, user-confirmed align declaration. Align then
422
471
  adds `schema` and `structure-summary` for structure work. Agents should not
423
- 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.
424
486
 
425
487
  Compile `read-plan`, `blockers`, and `diagnostics` Views are workspace-read-only
426
488
  and may run concurrently. Compile `--validate`, compile `--stage`, structure
@@ -457,9 +519,9 @@ compile:file:<source-name>:architecture
457
519
  compile:lark:<source-name>:architecture
458
520
  ```
459
521
 
460
- Compile requires confirmed `unapproved/structure.yaml`. It freezes the current
461
- structure for the compile round; if the user wants to change nodes, section
462
- 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.
463
525
 
464
526
  Common commands:
465
527
 
@@ -543,7 +605,7 @@ package from a larger monorepo source.
543
605
  Use `context source inspect <date>/<module>` to list detected module/package
544
606
  boundaries before choosing the source. Use `context run <phase-id> --dry-run
545
607
  --format json` to check the resolved modules, file counts, symbol counts, and
546
- candidate estimate before writing `unapproved/entities.jsonl`. The dry-run
608
+ candidate estimate before writing the ignored lifecycle candidate ledger. The dry-run
547
609
  preview also includes `knowledgeTree` and `knowledgePathExamples`, which show
548
610
  where approved Markdown will land after review apply.
549
611
  Its module and total summaries distinguish `discoveredFiles`, `analyzedFiles`,
@@ -625,7 +687,8 @@ structure slots and every declared `pendingStructureTargets` item in the round;
625
687
  codegraph waits for every pending extract phase in the confirmed module round.
626
688
  Candidate count/hash therefore describes the complete current batch rather than
627
689
  one page, source slot, or module. Deterministic close later merges all active
628
- 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.
629
692
 
630
693
  `status.structureBatch` lists unclassified, configuration-required, pending,
631
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,
@@ -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.
@@ -13,6 +13,9 @@ example, or a fixed content-specific prompt.
13
13
  Read the current collection-neutral evidence view, explain a short
14
14
  evidence-backed recommendation and its output implications, then obtain the
15
15
  user decision unless the current session explicitly delegates this gate.
16
+ Read every Route-selected `context.source-body/*` resource in full. Index and
17
+ heading metadata support navigation but are not evidence that the document
18
+ body was read.
16
19
 
17
20
  After the decision, declare the complete align, compile, and review lifecycle
18
21
  for the same canonical source and collection. Re-evaluate instead of assuming
@@ -11,21 +11,27 @@ agents or text consumers. Explain the available Context package kinds and their
11
11
  directory shape before asking the user to choose.
12
12
 
13
13
  After confirmation, declare the package in `src/index.ts` using the SDK schema
14
- resource. Templates may customize presentation, but they must not overwrite
14
+ resource. The current Route's `configuration.contract` lists the supported
15
+ output choices, required fields, mechanical defaults, and follow-up status
16
+ command; do not infer another factory or hidden default. Templates may customize presentation, but they must not overwrite
15
17
  approved knowledge paths or remove required indexes.
16
18
 
17
- An Agent knowledge-base package uses its package name as a stable single-level
18
- knowledge namespace by default. Explain that default after the package name is
19
- confirmed. Ask for a custom namespace only when the user needs another value;
20
- it may contain several concise lowercase path segments, such as
21
- `group/package` or `personal-user.123/package`, with letters and numbers joined
22
- by hyphens or dots. Declare an override as
23
- `kbPackage({ distribution: { knowledgeNamespace } })`; do not derive it from
24
- an unstated downstream identity or rewrite template prose.
19
+ Generated generic templates carry a mechanical digest marker. Before the first
20
+ build, replace or edit the declared template source, or explicitly accept the
21
+ unchanged generic default through the current Route. Editing the template
22
+ changes its digest and resolves the review without a separate command.
23
+ Acceptance records only that decision; Context does not judge template prose
24
+ or infer audience, scope, or navigation semantics.
25
25
 
26
- Ask separately whether the author wants a short optional Skill prefix. If so,
26
+ An Agent knowledge-base package writes flat package-relative roots such as
27
+ `wikis/`, `guides/`, `rules/`, and `feats/`. The package name already provides
28
+ the surrounding `dist/<package-name>/` boundary. Do not ask the user for a
29
+ distribution namespace or add `distribution.knowledgeNamespace` to a new
30
+ declaration.
31
+
32
+ Ask whether the author wants a short optional Skill prefix. If so,
27
33
  maintain the complete final Skill directory name in the template, such as
28
- `skills/android-query/`. Knowledge namespaces never rename Skills.
34
+ `skills/android-query/`. Package-root layout never renames Skills.
29
35
 
30
36
  Package output is incremental: a built package is current only for the approved
31
37
  knowledge and template digests recorded by its receipt.
@@ -14,10 +14,55 @@ and block boundaries when they preserve coherent reading units; fixed line
14
14
  windows are only a fallback for unstructured text. A page may contain multiple
15
15
  sections, each with its own continuous evidence span.
16
16
 
17
+ The default `read-plan` is the authoring packet for ordinary documents. It
18
+ includes the payload contract, a compact canonical source-ref map, exact source
19
+ body resources, the recommended scratch path, and the direct stage command.
20
+ Do not separately request `schema`, `source-index`, or `existing-knowledge`
21
+ unless the packet reports truncation or the task specifically needs an existing
22
+ approved identity. Those views are diagnostics and large-source fallbacks, not
23
+ mandatory workflow steps.
24
+
25
+ Every `context.source-body/*` item selected in `workflow.current.resources`
26
+ is source evidence, not supporting metadata. Read the complete Markdown file
27
+ when its `read_state` is `read-required`. A source index, heading tree, token
28
+ count, or successful capture never substitutes for body reading. A matching
29
+ content digest receipt may be reused only while that text remains available in
30
+ the current conversation. After reading every selected direct path, execute the
31
+ single `resources.after_read.command`. For a generated Context View, execute
32
+ its materialization command, read its complete file, then execute its exact
33
+ `next_action.command`. Context carries the merged receipt file forward. A Route
34
+ revision change does not invalidate unchanged bytes, but every lifecycle
35
+ command remains revision-bound.
36
+
37
+ When the route returns `payload_target`, write the Agent-authored structure input
38
+ to its recommended `.tmp/agent-payloads/` path. This scratch area is separate
39
+ from CLI-owned `.tmp/context-runtime/` and can be discarded after a successful
40
+ stage. The recommendation does not restrict an explicit user-selected path.
41
+
17
42
  Stage all required source/collection slots before batch Review. Structure
18
43
  confirmation is an explicit gate. A confirmation applies only to the staged
19
44
  slot digest shown by the route; if the digest changes, confirm again.
20
45
 
46
+ When the current Route exposes `batch`, author every listed target payload in
47
+ one Agent planning pass, then write the small batch manifest to `batch.input`.
48
+ Use `batch.validate.command` for a read-only all-target check or
49
+ `batch.stage.command` to validate every target before any stage begins and then
50
+ write the ready slots serially. The manifest contains only each `phase_id` and
51
+ its structure payload `input` path; it does not merge document semantics or let
52
+ the CLI choose page structure. A failed preflight writes no slot. If a later
53
+ filesystem write fails, the result identifies completed slots and the Route
54
+ remains recoverable.
55
+
56
+ `--stage` performs the same validation and deterministic self-repair as
57
+ `--validate`; use the separate validation command only for a diagnostics-only
58
+ pass. In a managed conversation, a valid stage also records structure
59
+ confirmation in the same write. Validation states are literal: `ready` may
60
+ stage, `repair-required` may not, and `invalid` contains errors. `valid` is true
61
+ only for `ready`; `error_free` distinguishes a blocker-only result from one
62
+ containing errors. `self_healed` reports the input and output Section counts,
63
+ how many original Sections were split, and the structural reason codes used by
64
+ the repair.
65
+
21
66
  Independent read-only evidence views may run in parallel. Structure stage,
22
67
  confirmation, compile writes, and Review application are serial lifecycle
23
68
  mutations; execute them in the order selected by `workflow.current`.
@@ -45,8 +45,10 @@ Known anomaly kinds:
45
45
  Use stable `node_ref`, `view_ref`, and `section_ref` values from the current
46
46
  `context.structure.v1` payload for in-payload references. A NodeRef should be
47
47
  safe, lower-case, and path-shaped, such as `entity/rspack` or
48
- `domain/build-tooling`. `slug` and `path` are derived fields in the current
49
- flow; do not invent alternate reference aliases.
48
+ `domain/build-tooling`. `slug` is the required stable filename choice for a
49
+ View. `path` is derived from collection, optional containment, and slug; omit
50
+ it or use the exact CLI-derived value. Do not invent alternate reference
51
+ aliases.
50
52
 
51
53
  When an edge or section points at knowledge:
52
54
 
@@ -117,10 +117,13 @@ After source evidence identifies a candidate title or stable ref, run:
117
117
  context run align:<type>:<source>:<collection> --view existing-knowledge --query <title-or-stable-ref> --format json
118
118
  ```
119
119
 
120
- Use the returned pagination command when present. Exact title, NodeRef, ViewRef,
121
- or tag hits should usually reuse the existing Node instead of creating a
122
- duplicate candidate. The lookup is deterministic identity discovery; the Agent
123
- still decides whether the source evidence describes the same concept.
120
+ Use the returned pagination command when present. Exact title, NodeRef, or
121
+ ViewRef hits should usually reuse the existing Node instead of creating a
122
+ duplicate candidate. The lookup returns only the best title/NodeRef/ViewRef
123
+ identity tier. Shared tag matches are summarized separately and never require
124
+ walking the related subgraph merely to determine whether a root identity
125
+ exists. The lookup is deterministic identity discovery; the Agent still
126
+ decides whether the source evidence describes the same concept.
124
127
 
125
128
  When a code projection Node already represents the object, reuse its slug for prose evidence and plan only prose-owned Sections for the current source evidence.
126
129
 
@@ -324,6 +327,6 @@ editing CLI-managed files.
324
327
  - [ ] Node classification used the semantic gates in `structure-planning/references/gates.md`. If not, return to **Step 4**.
325
328
  - [ ] URL/reference ownership followed CLI diagnostics, not static prompt rules. If not, return to **Step 5**.
326
329
  - [ ] The requested align payload passed `context run align:<type>:<source>:<collection> --validate --input - --format json` before stage. If not, return to **Step 6**.
327
- - [ ] No `sources/`, `unapproved/`, `knowledge/`, `dist/`, `.tmp`, host tool-results, or CLI-managed files were read or written with generic tools. If violated, restart from **Step 1**.
330
+ - [ ] No `sources/`, `knowledge/`, `dist/`, `.tmp`, host tool-results, or CLI-managed files were read or written with generic tools. If violated, restart from **Step 1**.
328
331
 
329
332
  </procedures>
@@ -0,0 +1,35 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "context.prose.structure-batch.v1",
4
+ "title": "Context prose structure batch",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schema", "items"],
8
+ "properties": {
9
+ "schema": {
10
+ "const": "context.prose.structure-batch.v1"
11
+ },
12
+ "items": {
13
+ "type": "array",
14
+ "minItems": 1,
15
+ "maxItems": 100,
16
+ "items": {
17
+ "type": "object",
18
+ "additionalProperties": false,
19
+ "required": ["phase_id", "input"],
20
+ "properties": {
21
+ "phase_id": {
22
+ "type": "string",
23
+ "minLength": 1,
24
+ "description": "One declared phase.align.prose id from the current pending structure targets."
25
+ },
26
+ "input": {
27
+ "type": "string",
28
+ "minLength": 1,
29
+ "description": "Project-relative or absolute YAML/JSON context.structure.v1 payload path for this target."
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }