@c4a/context-cli 0.6.1-beta.3 → 0.6.1-beta.5
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.
- package/README.md +22 -9
- package/README.zh-CN.md +12 -8
- package/cli.js +76339 -69108
- package/docs/quickstart.md +7 -0
- package/package.json +4 -3
- package/plugins/README.md +7 -2
- package/plugins/README_CN.md +7 -2
- package/plugins/VERSION +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/commands/continue.md +17 -3
- package/plugins/claude/commands/init.md +7 -4
- package/plugins/codex/.codex-plugin/plugin.json +2 -2
- package/plugins/codex/skills/continue/SKILL.md +17 -3
- package/plugins/codex/skills/init/SKILL.md +6 -3
- package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
- package/plugins/cursor/commands/context-continue.md +17 -3
- package/plugins/cursor/commands/context-init.md +7 -4
- package/plugins/skills/context-continue/SKILL.md +17 -3
- package/plugins/skills/context-init/SKILL.md +6 -3
- package/providers/context/actions/accept-package-templates.yaml +5 -0
- package/providers/context/actions/align-next.yaml +1 -0
- package/providers/context/codes.yaml +2 -0
- package/providers/context/graphs/workspace.yaml +26 -1
- package/providers/context/manifest.json +67 -40
- package/providers/context/provider.yaml +1 -1
- package/providers/context/resources/diagnostics/projection-stale.md +13 -0
- package/providers/context/resources/dialogue/document-classification.md +2 -1
- package/providers/context/resources/dialogue/package-output.md +5 -7
- package/providers/context/resources/manuals/guides/package-outputs.md +40 -37
- package/providers/context/resources/manuals/reference/package-templates.md +36 -48
- package/providers/context/resources/manuals/reference/project-api.md +139 -17
- package/providers/context/resources/manuals/reference/template-variables.md +12 -11
- package/providers/context/resources/procedures/close-and-build.md +3 -1
- package/providers/context/resources/procedures/code-extraction.md +22 -2
- package/providers/context/resources/procedures/document-capture.md +14 -0
- package/providers/context/resources/procedures/document-classification.md +3 -0
- package/providers/context/resources/procedures/package-output.md +17 -11
- package/providers/context/resources/procedures/prose-align.md +45 -0
- package/providers/context/resources/procedures/source-boundary.md +6 -0
- package/providers/context/resources/procedures/source-capture-detailed.md +10 -0
- package/providers/context/resources/semantic/align/candidate-resolution.md +4 -2
- package/providers/context/resources/semantic/align/structure-planning.md +8 -5
- 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 |
|
|
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
|
-
##
|
|
66
|
+
## Flat Package Roots
|
|
67
67
|
|
|
68
|
-
`name` identifies the
|
|
69
|
-
|
|
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"
|
|
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/
|
|
92
|
-
guides
|
|
93
|
-
rules
|
|
94
|
-
feats
|
|
85
|
+
wikis/index.md
|
|
86
|
+
guides/...
|
|
87
|
+
rules/...
|
|
88
|
+
feats/...
|
|
95
89
|
```
|
|
96
90
|
|
|
97
|
-
The builder
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
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}}` |
|
|
132
|
-
| `{{namespacedKnowledge}}` |
|
|
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
|
|
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
|
|
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
|
-
|
|
245
|
-
`src/package-templates/kb/**`
|
|
246
|
-
specific skills, prompts, routing rules,
|
|
247
|
-
package
|
|
248
|
-
|
|
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: "
|
|
311
|
-
|
|
312
|
-
|
|
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,
|
|
59
|
-
|
|
60
|
-
`containment` only
|
|
61
|
-
|
|
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
|
|
@@ -330,9 +338,17 @@ Register each source with
|
|
|
330
338
|
flag: `--url`, `--doc-token`, or `--wiki-token`. Multiple documents may share
|
|
331
339
|
one date batch; when `--module` is omitted, the CLI derives an opaque,
|
|
332
340
|
credential-safe module id. Capture reads the
|
|
333
|
-
remote document through the CLI runner
|
|
334
|
-
|
|
335
|
-
|
|
341
|
+
remote document through the CLI runner as structured Docx XML. Context keeps a
|
|
342
|
+
redacted XML audit asset, projects supported blocks deterministically into
|
|
343
|
+
readable Markdown, and registers external resources such as document citations,
|
|
344
|
+
images, video, whiteboards, and Base references in the snapshot manifest even
|
|
345
|
+
when their binary content is not downloaded. The projection does not infer or
|
|
346
|
+
summarize document meaning. Its fidelity report closes discovered blocks against
|
|
347
|
+
converted and intentionally skipped blocks; a non-empty unsupported block is a
|
|
348
|
+
fidelity error and prevents downstream Review until capture support is fixed.
|
|
349
|
+
Snapshot files live under `sources/lark/<date>/` as sibling document files
|
|
350
|
+
tracked by one date-level `manifest.json`. Access credentials and transient
|
|
351
|
+
signed media URLs are not written into the workspace.
|
|
336
352
|
|
|
337
353
|
Use a typed document reference in project declarations:
|
|
338
354
|
|
|
@@ -380,15 +396,56 @@ context run align:file:<source-name>:architecture --view structure-summary --inp
|
|
|
380
396
|
context run align:file:<source-name>:architecture --stage --input <structure.yaml> --format json
|
|
381
397
|
```
|
|
382
398
|
|
|
399
|
+
When `workflow.current.batch` is present, several independent document slots
|
|
400
|
+
can be prepared in one Agent pass and validated or staged through one command:
|
|
401
|
+
|
|
402
|
+
```yaml
|
|
403
|
+
schema: context.prose.structure-batch.v1
|
|
404
|
+
items:
|
|
405
|
+
- phase_id: align:file:<source-a>:architecture
|
|
406
|
+
input: .tmp/agent-payloads/<source-a>-structure.yaml
|
|
407
|
+
- phase_id: align:file:<source-b>:architecture
|
|
408
|
+
input: .tmp/agent-payloads/<source-b>-structure.yaml
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
```bash
|
|
412
|
+
context run --batch-input .tmp/agent-payloads/prose-structure-batch.yaml --validate --format json
|
|
413
|
+
context run --batch-input .tmp/agent-payloads/prose-structure-batch.yaml --stage --managed --format json
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
Batch preflight validates every payload before writing. Stage writes ready
|
|
417
|
+
slots serially; it does not merge documents or decide their semantic shape.
|
|
418
|
+
|
|
419
|
+
Align results expose a recommended `payload_target.path` under
|
|
420
|
+
`.tmp/agent-payloads/`. Agents should use it for transient structure inputs and
|
|
421
|
+
may remove the file after a successful stage. The CLI continues to accept an
|
|
422
|
+
explicit alternative path; this is an authoring convention, not validation.
|
|
423
|
+
|
|
424
|
+
For the ordinary path, `read-plan` is a complete authoring packet: it includes
|
|
425
|
+
the payload contract, a budgeted canonical source-ref map, exact source-body
|
|
426
|
+
resources, and a direct `--stage` command. Read the bodies, author the payload,
|
|
427
|
+
and run that stage command. Request `source-index` only when the packet reports
|
|
428
|
+
omitted refs, and request `existing-knowledge` only when reusing or checking an
|
|
429
|
+
approved identity. The separate schema and validate views are optional
|
|
430
|
+
diagnostic tools, not required lifecycle steps.
|
|
431
|
+
|
|
383
432
|
`--validate`, `--stage`, and `--confirm` are mutually exclusive operations. An
|
|
384
433
|
`--input` without an operation is rejected unless the selected view explicitly
|
|
385
434
|
consumes that input. Deterministic boundary repairs run internally before the
|
|
386
|
-
result is returned.
|
|
435
|
+
result is returned. `self_healed` includes input/output Section counts, the
|
|
436
|
+
number of original Sections split, and structural reason codes. Stage performs validation before writing and returns the
|
|
437
|
+
same diagnostics on failure; in managed mode, a valid stage also confirms the
|
|
438
|
+
structure. Successful standalone validation returns a stage command with the
|
|
387
439
|
same file path. JSON run output keeps `next_action` first;
|
|
388
440
|
schema and full reports stay behind explicit Views, while `--verbose` restores
|
|
389
441
|
the full phase result and repeated contracts. Long diagnostics return a compact
|
|
390
442
|
first page plus an exact diagnostics continuation command.
|
|
391
443
|
|
|
444
|
+
Validation returns `state: ready | repair-required | invalid`. Only `ready`
|
|
445
|
+
sets `valid: true` and may proceed to stage. `error_free: true` with
|
|
446
|
+
`state: repair-required` means no error diagnostic remains, but a declared
|
|
447
|
+
confirmation blocker still requires repair; it is not a successful result.
|
|
448
|
+
|
|
392
449
|
`existing-knowledge` is the authoring-time lookup for approved identities. It
|
|
393
450
|
returns stable NodeRefs, ViewRefs, titles, tags, collections, and section counts
|
|
394
451
|
without exposing workspace storage paths. `--query` performs deterministic
|
|
@@ -420,7 +477,20 @@ After capture, the capture phase itself exposes collection-neutral `read-plan`,
|
|
|
420
477
|
Status selects `route.document.classification-required` until every captured
|
|
421
478
|
target has an evidence-backed, user-confirmed align declaration. Align then
|
|
422
479
|
adds `schema` and `structure-summary` for structure work. Agents should not
|
|
423
|
-
|
|
480
|
+
scan `sources/` or `.tmp` to invent evidence. They may read only the exact
|
|
481
|
+
source-body files selected as required resources by the current Route; those
|
|
482
|
+
files carry stable content digests and must be read in full before a receipt is
|
|
483
|
+
reported. Read all required direct paths, then execute the Route's single
|
|
484
|
+
`resources.after_read.command`; the CLI writes and carries the merged receipt
|
|
485
|
+
set without requiring Agent-authored JSON. That acknowledgement response
|
|
486
|
+
already contains the re-evaluated `workflow.current`, so no additional status
|
|
487
|
+
command is needed.
|
|
488
|
+
|
|
489
|
+
Generated Context Views use the same content-addressed rule. Materialization
|
|
490
|
+
returns a receipt-set path and an exact post-read command. Read the complete
|
|
491
|
+
file, then execute that command; unchanged content remains current across
|
|
492
|
+
workflow revisions, while write and external commands still require the exact
|
|
493
|
+
current revision.
|
|
424
494
|
|
|
425
495
|
Compile `read-plan`, `blockers`, and `diagnostics` Views are workspace-read-only
|
|
426
496
|
and may run concurrently. Compile `--validate`, compile `--stage`, structure
|
|
@@ -457,9 +527,9 @@ compile:file:<source-name>:architecture
|
|
|
457
527
|
compile:lark:<source-name>:architecture
|
|
458
528
|
```
|
|
459
529
|
|
|
460
|
-
Compile requires confirmed
|
|
461
|
-
structure for the compile round; if the user wants to change nodes,
|
|
462
|
-
ownership, or relationships, return to the align/structure gate.
|
|
530
|
+
Compile requires confirmed CLI-managed lifecycle structure. It freezes the
|
|
531
|
+
current structure for the compile round; if the user wants to change nodes,
|
|
532
|
+
section ownership, or relationships, return to the align/structure gate.
|
|
463
533
|
|
|
464
534
|
Common commands:
|
|
465
535
|
|
|
@@ -543,7 +613,7 @@ package from a larger monorepo source.
|
|
|
543
613
|
Use `context source inspect <date>/<module>` to list detected module/package
|
|
544
614
|
boundaries before choosing the source. Use `context run <phase-id> --dry-run
|
|
545
615
|
--format json` to check the resolved modules, file counts, symbol counts, and
|
|
546
|
-
candidate estimate before writing
|
|
616
|
+
candidate estimate before writing the ignored lifecycle candidate ledger. The dry-run
|
|
547
617
|
preview also includes `knowledgeTree` and `knowledgePathExamples`, which show
|
|
548
618
|
where approved Markdown will land after review apply.
|
|
549
619
|
Its module and total summaries distinguish `discoveredFiles`, `analyzedFiles`,
|
|
@@ -586,6 +656,56 @@ lookup exact when multiple files contain the same symbol name, kind, and digest;
|
|
|
586
656
|
the complete ref remains opaque to agents. New pages keep only top-level
|
|
587
657
|
`candidate_fingerprint` and do not emit `code_origin`.
|
|
588
658
|
|
|
659
|
+
### `extractCustom`
|
|
660
|
+
|
|
661
|
+
Use a project-owned extractor when code facts cannot be represented by the
|
|
662
|
+
TypeScript symbol extractor, for example a language-specific parser or an
|
|
663
|
+
aggregated repository protocol:
|
|
664
|
+
|
|
665
|
+
```ts
|
|
666
|
+
extractCustom({
|
|
667
|
+
id: "extract:service:protocol",
|
|
668
|
+
sources: [service],
|
|
669
|
+
collection: "codegraph",
|
|
670
|
+
extract: async ({ projectRoot }) => ({
|
|
671
|
+
candidates: [{
|
|
672
|
+
nodeRef: "service/protocol",
|
|
673
|
+
kind: "protocol",
|
|
674
|
+
visibility: "exported",
|
|
675
|
+
module: "service",
|
|
676
|
+
markdown: renderProtocol(projectRoot),
|
|
677
|
+
evidence: [{
|
|
678
|
+
source: "20260811/service",
|
|
679
|
+
file: "src/protocol.ts",
|
|
680
|
+
symbol: "protocol",
|
|
681
|
+
kind: "variable",
|
|
682
|
+
digest: "0123456789ab",
|
|
683
|
+
}],
|
|
684
|
+
review: {
|
|
685
|
+
title: "Service protocol",
|
|
686
|
+
summary: "Aggregated protocol boundary.",
|
|
687
|
+
signals: ["source-backed"],
|
|
688
|
+
reason: "Review the project-owned extraction.",
|
|
689
|
+
},
|
|
690
|
+
}],
|
|
691
|
+
}),
|
|
692
|
+
});
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
`sources` is the complete registered repo scope for the phase. Every candidate
|
|
696
|
+
and edge carries structured `evidence`; the CLI validates that evidence against
|
|
697
|
+
the declared sources, creates canonical `source_ref` values, writes the symbol
|
|
698
|
+
index, candidate ledger and Review snapshots atomically, and records a phase
|
|
699
|
+
fingerprint. `context status` therefore treats this phase exactly like another
|
|
700
|
+
pending code extraction target, and Review can verify snapshot freshness
|
|
701
|
+
without a placeholder `extractTs` phase.
|
|
702
|
+
|
|
703
|
+
The extractor returns knowledge semantics (`nodeRef`, rendered Markdown,
|
|
704
|
+
Review summary and source-backed evidence). It must not write `knowledge/`,
|
|
705
|
+
`.tmp/context-runtime/lifecycle/candidates.jsonl`, extraction fingerprints or
|
|
706
|
+
Review snapshots directly. Context owns those files and preserves rejected and
|
|
707
|
+
unchanged-approved decisions across reruns.
|
|
708
|
+
|
|
589
709
|
### `reviewValidity`
|
|
590
710
|
|
|
591
711
|
Declare the review step for a collection:
|
|
@@ -625,7 +745,8 @@ structure slots and every declared `pendingStructureTargets` item in the round;
|
|
|
625
745
|
codegraph waits for every pending extract phase in the confirmed module round.
|
|
626
746
|
Candidate count/hash therefore describes the complete current batch rather than
|
|
627
747
|
one page, source slot, or module. Deterministic close later merges all active
|
|
628
|
-
slots into `knowledge/structure.yaml
|
|
748
|
+
slots into `knowledge/structure.yaml`, retains only their source, collection,
|
|
749
|
+
and consumed snapshot hash as `source_inputs`, then removes the lifecycle slots.
|
|
629
750
|
|
|
630
751
|
`status.structureBatch` lists unclassified, configuration-required, pending,
|
|
631
752
|
and active structure slots together with the execution policy for the round.
|
|
@@ -656,8 +777,9 @@ customPhase("custom:20260712/sample:review", async (ctx) => {
|
|
|
656
777
|
});
|
|
657
778
|
```
|
|
658
779
|
|
|
659
|
-
Custom phases are an escape hatch.
|
|
660
|
-
|
|
780
|
+
Custom phases are an orchestration escape hatch. Use `extractCustom()` instead
|
|
781
|
+
when project code needs to publish codegraph candidates. The supported runtime
|
|
782
|
+
helpers are:
|
|
661
783
|
|
|
662
784
|
- `ctx.ensureSources(...)` for repo source readiness.
|
|
663
785
|
- `ctx.extract.ts(...)` for declared TypeScript extraction.
|
|
@@ -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 |
|
|
101
|
-
| `namespacedKnowledge` | boolean |
|
|
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
|
|
104
|
-
| `guidesRoot` | string | Final guides root
|
|
105
|
-
| `rulesRoot` | string | Final rules root
|
|
106
|
-
| `featsRoot` | string | Final feats root
|
|
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
|
|
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
|
|
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
|
|
247
|
-
|
|
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,25 @@ 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
|
|
30
|
-
|
|
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.
|
|
45
|
+
|
|
46
|
+
When the built-in TypeScript extractor cannot represent the code source, use a
|
|
47
|
+
declared `extractCustom` phase. The project-owned callback returns candidate
|
|
48
|
+
semantics plus structured source evidence; Context owns canonical refs,
|
|
49
|
+
fingerprints, candidate storage, Review snapshots, freshness, and rerun cleanup.
|
|
50
|
+
Do not use a generic `customPhase` callback to write lifecycle files directly.
|
|
@@ -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.
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
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/`.
|
|
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`.
|
|
@@ -30,6 +30,12 @@ them. A date-only inspection addresses the batch; `<date>/<module>` addresses
|
|
|
30
30
|
one source. Register a confirmed multi-source request as one serial batch
|
|
31
31
|
mutation instead of running registry writes in parallel.
|
|
32
32
|
|
|
33
|
+
To retire a registered source, first run `context source remove <source-id>
|
|
34
|
+
--format json`. This is a read-only preview that lists every project, candidate,
|
|
35
|
+
or approved-knowledge reference. Only after those references are intentionally
|
|
36
|
+
resolved may the route use `--yes`; the CLI never silently deletes referenced
|
|
37
|
+
knowledge or another source's materialized files.
|
|
38
|
+
|
|
33
39
|
Repository readiness checks are mechanical and may run after the boundary is
|
|
34
40
|
registered. Clone, fetch, checkout, install, build, test, and other external
|
|
35
41
|
repository operations need separate authority. File and remote-document
|