@c4a/context 0.6.1-beta.1 → 0.6.1-beta.3
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 +9 -2
- package/README.zh-CN.md +5 -1
- package/contracts.d.ts +5 -0
- package/docs/README.md +5 -3
- package/docs/getting-started.md +51 -21
- package/docs/guides/agent-dialogue.md +38 -350
- package/docs/guides/agent-guide.md +130 -87
- package/docs/guides/package-outputs.md +69 -16
- package/docs/reference/package-templates.md +103 -20
- package/docs/reference/project-api.md +92 -76
- package/docs/reference/template-variables.md +27 -11
- package/index.d.ts +10 -3
- package/index.js +58 -4
- package/package.json +1 -1
- package/templates/package-templates/kb/AGENTS.md +10 -10
- package/templates/package-templates/kb/skills/knowledge-query/SKILL.md +16 -15
- package/templates/package-templates/kb/wikis/index.md +7 -7
|
@@ -27,6 +27,10 @@ kbPackage({
|
|
|
27
27
|
include: ["architecture/component-lib/**", "sop/component-lib/**"],
|
|
28
28
|
exclude: ["**/internal/**"],
|
|
29
29
|
},
|
|
30
|
+
navigation: {
|
|
31
|
+
foldDirectoryIndexes: true,
|
|
32
|
+
maxInlineEntries: 50,
|
|
33
|
+
},
|
|
30
34
|
});
|
|
31
35
|
```
|
|
32
36
|
|
|
@@ -47,10 +51,66 @@ llmsPackage({
|
|
|
47
51
|
| `name` | yes | Lowercase path-safe package name. Output goes to `dist/<name>/`. |
|
|
48
52
|
| `template` | yes | Project-relative template directory or `{ path, vars }`. |
|
|
49
53
|
| `select` | no | Approved knowledge selector. Omit to include all approved knowledge. Supports internal `collections`, OKF `okfRoots`, and `include` / `exclude` path patterns relative to `knowledge/`. |
|
|
54
|
+
| `navigation` | no | KB directory-index policy. Defaults to `{ foldDirectoryIndexes: true, maxInlineEntries: 50 }`. |
|
|
55
|
+
| `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. |
|
|
50
56
|
|
|
51
57
|
`template` is required. Do not call `kbPackage({ name })` or
|
|
52
58
|
`llmsPackage({ name })`.
|
|
53
59
|
|
|
60
|
+
## Knowledge Distribution Namespace
|
|
61
|
+
|
|
62
|
+
`name` identifies the build folder under `dist/` and is also the default
|
|
63
|
+
single-level `distribution.knowledgeNamespace`. An explicit namespace may be
|
|
64
|
+
one segment or a slash-separated sequence of safe lowercase path segments. A
|
|
65
|
+
segment may contain letters and numbers joined by hyphens or dots, allowing
|
|
66
|
+
identifiers such as `personal-user.123/package`. Keep every segment short,
|
|
67
|
+
stable, and recognizable. Context treats the complete value as an opaque
|
|
68
|
+
knowledge path and does not assign downstream meanings to individual segments.
|
|
69
|
+
|
|
70
|
+
Templates keep a logical, consumer-neutral layout:
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
skills/knowledge-query/SKILL.md
|
|
74
|
+
wikis/index.md
|
|
75
|
+
guides/...
|
|
76
|
+
rules/...
|
|
77
|
+
feats/...
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
For `name: "component-lib-kb"` with no explicit distribution, `context build`
|
|
81
|
+
writes:
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
skills/knowledge-query/SKILL.md
|
|
85
|
+
wikis/component-lib-kb/index.md
|
|
86
|
+
guides/component-lib-kb/...
|
|
87
|
+
rules/component-lib-kb/...
|
|
88
|
+
feats/component-lib-kb/...
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The builder applies the knowledge mapping to template paths, copied knowledge,
|
|
92
|
+
generated indexes, links, and inventory records. It does not apply the
|
|
93
|
+
knowledge namespace to `skills/`, rewrite Markdown prose, or infer path
|
|
94
|
+
segments from downstream platform identifiers. An explicit
|
|
95
|
+
`distribution: { knowledgeNamespace: "platform/component-lib" }` produces the
|
|
96
|
+
same shape under that multi-segment namespace instead.
|
|
97
|
+
|
|
98
|
+
Because every KB package has a knowledge namespace, Skill templates must not
|
|
99
|
+
hard-code flat package paths such as `wikis/index.md` or
|
|
100
|
+
`rules/standards/index.md`.
|
|
101
|
+
Use `{{wikisRoot}}`, `{{rulesRoot}}`, `{{guidesRoot}}`, or `{{featsRoot}}`
|
|
102
|
+
instead. `context build` and `context status` reject flat Markdown links and
|
|
103
|
+
inline-code paths in `skills/**/*.md` with
|
|
104
|
+
`package/template-namespace-reference-flat`. This check is generic package
|
|
105
|
+
validation; it does not depend on a downstream registry or distribution tool.
|
|
106
|
+
|
|
107
|
+
Each rendered Skill must live at `skills/<skill-name>/SKILL.md`, and its YAML
|
|
108
|
+
frontmatter `name` must equal `<skill-name>`. Use `{{skillName}}` in custom
|
|
109
|
+
Skill templates. Skill names are author-maintained: when a short prefix is
|
|
110
|
+
useful, rename the template directory to the complete final name, such as
|
|
111
|
+
`skills/android-query/`; Context does not derive it from
|
|
112
|
+
`knowledgeNamespace`.
|
|
113
|
+
|
|
54
114
|
## Template Variables
|
|
55
115
|
|
|
56
116
|
Templates are rendered with Handlebars. Variables are available in both file
|
|
@@ -62,6 +122,11 @@ Built-in variables:
|
|
|
62
122
|
|---|---|
|
|
63
123
|
| `{{packageName}}` | Package name from the declaration. |
|
|
64
124
|
| `{{packageKind}}` | `kb` or `llms`. |
|
|
125
|
+
| `{{knowledgeNamespace}}` | Final KB knowledge namespace. Defaults to the package name; empty only for non-KB packages. |
|
|
126
|
+
| `{{namespacedKnowledge}}` | Whether the package is a KB package with a knowledge namespace. |
|
|
127
|
+
| `{{skillName}}` | Current author-maintained Skill directory name. |
|
|
128
|
+
| `{{skillPath}}` | Current Skill's final package-relative `SKILL.md` path. |
|
|
129
|
+
| `{{wikisRoot}}`, `{{guidesRoot}}`, `{{rulesRoot}}`, `{{featsRoot}}` | Final package-relative OKF root paths. |
|
|
65
130
|
| `{{displayName}}` | Display name. Defaults to a title-cased `packageName`; override with `template.vars.displayName`. |
|
|
66
131
|
| `{{knowledgeCount}}` | Number of selected approved Markdown files. |
|
|
67
132
|
| `{{knowledgeTimestamp}}` | Latest `timestamp` from selected approved Markdown, or `1970-01-01T00:00:00.000Z` when empty. |
|
|
@@ -72,7 +137,7 @@ Built-in variables:
|
|
|
72
137
|
| `{{knowledgeTreeNodes}}` | Nested path tree for custom navigation. |
|
|
73
138
|
| `{{knowledgeTree}}` | Markdown tree preview. |
|
|
74
139
|
| `{{knowledgeItemsMarkdown}}` | Markdown page list. |
|
|
75
|
-
| `{{knowledgeGroupsMarkdown}}` | Markdown
|
|
140
|
+
| `{{knowledgeGroupsMarkdown}}` | Markdown navigation for the current index: direct page links for folded directories and links to generated indexes for expanded directories. |
|
|
76
141
|
|
|
77
142
|
Custom variables come from `template.vars`.
|
|
78
143
|
|
|
@@ -120,18 +185,22 @@ The default kb template includes:
|
|
|
120
185
|
collections expose
|
|
121
186
|
`guides/`, `rules/`, or `feats/` indexes when those roots are selected.
|
|
122
187
|
- `wikis/index.md`, the editable OKF bundle entry page for the generated
|
|
123
|
-
`dist/<package-name>/wikis
|
|
188
|
+
`dist/<package-name>/wikis/<knowledge-namespace>/` directory.
|
|
189
|
+
|
|
190
|
+
These are logical template paths. The package distribution namespace changes
|
|
191
|
+
their final output paths as described above.
|
|
124
192
|
|
|
125
193
|
During `context build`, the root `wikis/index.md` is rendered from the template.
|
|
126
|
-
The builder
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
194
|
+
The builder always provides an index for every selected OKF root. With the
|
|
195
|
+
default navigation policy, smaller child directories are folded into their
|
|
196
|
+
nearest generated ancestor index, so a short collection can link directly to
|
|
197
|
+
its pages instead of producing one index per path segment.
|
|
130
198
|
|
|
131
199
|
## OKF Directory Indexes
|
|
132
200
|
|
|
133
|
-
The generated
|
|
134
|
-
|
|
201
|
+
The generated
|
|
202
|
+
`dist/<package-name>/wikis/<knowledge-namespace>/` tree is the required default
|
|
203
|
+
KB entry surface. Internal collections are mapped into OKF roots during build:
|
|
135
204
|
`codegraph`, `business`, and `product` go to `wikis/`; `architecture`, `sop`,
|
|
136
205
|
`faq`, `decision`, and `incident` go to `guides/`; `standards` and `test` go to
|
|
137
206
|
`rules/`; and `feats` goes to `feats/`. Treat `wikis/` as the structured
|
|
@@ -141,24 +210,30 @@ a relationship.
|
|
|
141
210
|
|
|
142
211
|
Default navigation rules:
|
|
143
212
|
|
|
144
|
-
- `wikis/index.md` is the required default bundle index.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
`
|
|
213
|
+
- `wikis/index.md` is the required default bundle index. Other selected OKF
|
|
214
|
+
roots always use their own `<okf-root>/index.md`.
|
|
215
|
+
- With `foldDirectoryIndexes: true`, a non-root directory gets its own
|
|
216
|
+
`index.md` only when its descendant knowledge-page count is greater than
|
|
217
|
+
`maxInlineEntries`. The default threshold is `50`.
|
|
218
|
+
- A folded directory is not discarded. Its pages are listed in the nearest
|
|
219
|
+
generated ancestor index, grouped by their relative directory path.
|
|
220
|
+
- The threshold counts selected knowledge pages in the path tree. It does not
|
|
221
|
+
inspect Markdown line counts, headings, or content semantics.
|
|
222
|
+
- Set `foldDirectoryIndexes: false` to generate an `index.md` for every
|
|
223
|
+
directory, matching the fully expanded navigation shape.
|
|
149
224
|
- A generated directory index uses OKF frontmatter with `type: Knowledge
|
|
150
225
|
Directory`, `title`, `description`, `tags`, `timestamp`, `resource`,
|
|
151
226
|
`package`, `package_kind`, and `knowledge_count`.
|
|
152
|
-
- Directory indexes list child
|
|
153
|
-
|
|
227
|
+
- Directory indexes list generated child indexes first, then pages from folded
|
|
228
|
+
paths.
|
|
154
229
|
- `context build` validates links in OKF root indexes and generated
|
|
155
230
|
child `index.md` files. Relative links must resolve to files inside
|
|
156
231
|
`dist/<package-name>/`; broken links are reported as
|
|
157
232
|
`package/index-link-invalid`.
|
|
158
233
|
- If a project needs curated default navigation, edit the template-owned
|
|
159
|
-
`wikis/index.md`.
|
|
160
|
-
|
|
161
|
-
|
|
234
|
+
`wikis/index.md`. Template files or copied knowledge pages that collide with
|
|
235
|
+
an index path selected by the current navigation policy are rejected during
|
|
236
|
+
build/status preflight.
|
|
162
237
|
|
|
163
238
|
Users are expected to customize these template files. Edit
|
|
164
239
|
`src/package-templates/kb/**` before `context build` to define project
|
|
@@ -225,9 +300,17 @@ endpoints are present in the selected package. Use those edge records for
|
|
|
225
300
|
relationship citations inside the package instead of assuming the workspace
|
|
226
301
|
`knowledge/structure.yaml` file is bundled.
|
|
227
302
|
|
|
303
|
+
For KB packages, the inventory records `package.distribution` as
|
|
304
|
+
`layout: "namespaced"` with the final `knowledge_namespace` and OKF root paths.
|
|
305
|
+
Non-KB package types can remain `layout: "flat"`. Selected file and group
|
|
306
|
+
records expose both the logical `okf_root` and final `okf_root_path`, so
|
|
307
|
+
installers can inspect the layout without parsing paths or rewriting package
|
|
308
|
+
content.
|
|
309
|
+
|
|
228
310
|
Build expects approved knowledge to be closed when the project has source-bound
|
|
229
|
-
document knowledge.
|
|
230
|
-
`
|
|
311
|
+
document knowledge. When `workflow.current.reason_code` is
|
|
312
|
+
`route.close.projection-stale`, run the exact returned close command. Current
|
|
313
|
+
close derives
|
|
231
314
|
`knowledge/structure.yaml`, persists approved edge projection, and runs the
|
|
232
315
|
final verify gate. References, changelog, package index, and section
|
|
233
316
|
fingerprint rebuilds are not current close output; build only packages the
|
|
@@ -27,7 +27,8 @@ Codegraph NodeRef/ViewRef and knowledge paths use the stable module name without
|
|
|
27
27
|
the date:
|
|
28
28
|
|
|
29
29
|
```text
|
|
30
|
-
knowledge/<collection>/<
|
|
30
|
+
knowledge/<collection>/<slug>.md
|
|
31
|
+
knowledge/<collection>/<containment>/<slug>.md # only for an intentional hierarchy
|
|
31
32
|
knowledge/codegraph/<module>/symbol/<slug>.md
|
|
32
33
|
repo:<date>/<module>#symbol:...
|
|
33
34
|
file:<date>/<module>/<document>#span:...
|
|
@@ -48,6 +49,11 @@ knowledge/codegraph/module-a/...
|
|
|
48
49
|
knowledge/codegraph/module-b/...
|
|
49
50
|
```
|
|
50
51
|
|
|
52
|
+
For prose Views, omit `containment` when the page is an independent collection
|
|
53
|
+
entry. The CLI then derives `knowledge/<collection>/<slug>.md`. Set
|
|
54
|
+
`containment` only when the approved structure intentionally places the page
|
|
55
|
+
under a parent path; it is not a required source/module wrapper.
|
|
56
|
+
|
|
51
57
|
The registry stores this as one date entry containing several `modules` entries,
|
|
52
58
|
and materializes each module at `sources/repo/<date>/<module>`.
|
|
53
59
|
Repo module names are project-wide codegraph identities and therefore cannot be
|
|
@@ -133,7 +139,7 @@ is a repo, file, or lark source:
|
|
|
133
139
|
```ts
|
|
134
140
|
import { source } from "@c4a/context";
|
|
135
141
|
|
|
136
|
-
const
|
|
142
|
+
const productDocs = source("product-docs");
|
|
137
143
|
```
|
|
138
144
|
|
|
139
145
|
### `source(namespace, module)`
|
|
@@ -165,16 +171,15 @@ siblings under `sources/file|lark/<date>/` and share the date-level
|
|
|
165
171
|
directory level.
|
|
166
172
|
|
|
167
173
|
For a confirmed multi-document request, declare one capture phase per module.
|
|
168
|
-
While any module is uncaptured, `context status --format json`
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
- `needs-capture` with every declared command in `routing.command_plan`.
|
|
174
|
+
While any module is uncaptured, `context status --format json` selects either
|
|
175
|
+
the `route.capture.configuration-required` Route with
|
|
176
|
+
`workflow.current.configuration`, or the `route.capture.pending-target` Route
|
|
177
|
+
with the next declared command in `workflow.current.commands`.
|
|
173
178
|
|
|
174
|
-
Each command
|
|
175
|
-
`
|
|
176
|
-
|
|
177
|
-
|
|
179
|
+
Each command item declares its effect and availability. The current route's
|
|
180
|
+
`gate` identifies the decision and authority boundary. Write commands are bound
|
|
181
|
+
to the workflow revision; after one succeeds, rerun status instead of reusing
|
|
182
|
+
the old command.
|
|
178
183
|
|
|
179
184
|
### `allSources("repo")`
|
|
180
185
|
|
|
@@ -202,7 +207,7 @@ review html/apply`, `context close`, `context verify`, and `context build`.
|
|
|
202
207
|
|
|
203
208
|
### Status declaration coverage
|
|
204
209
|
|
|
205
|
-
`context status --format json` includes a `declarationGraph` and
|
|
210
|
+
`context status --format json --view full` includes a `declarationGraph` and
|
|
206
211
|
`configurationGaps` for document workflows. Each row reports capture, align,
|
|
207
212
|
compile, and Review coverage for a canonical source plus collection. Gaps are
|
|
208
213
|
non-blocking before structure confirmation. Once a structure is confirmed,
|
|
@@ -218,18 +223,20 @@ declarations are complete, status returns the exact align investigation command
|
|
|
218
223
|
for the next target. A built package does not freeze the workspace or require a
|
|
219
224
|
new workspace for later sources.
|
|
220
225
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
226
|
+
`context status --format json` defaults to the compact workflow route, target,
|
|
227
|
+
progress, counts, and aggregated diagnostics. Use `--view full` only when
|
|
228
|
+
source, phase, package, and lifecycle inventories are needed for debugging.
|
|
224
229
|
|
|
225
230
|
### Current-conversation managed execution
|
|
226
231
|
|
|
227
232
|
`context status --managed --format json` exposes
|
|
228
233
|
`executionMode: { mode: "managed", scope: "current-conversation" }` and resolves
|
|
229
234
|
eligible human gates into immediate commands. The flag is deliberately absent
|
|
230
|
-
from `defineProject`: callers
|
|
231
|
-
|
|
232
|
-
|
|
235
|
+
from `defineProject`: callers start each workflow evaluation loop with managed
|
|
236
|
+
status, then execute the returned revision-bound command unchanged. Returned
|
|
237
|
+
commands carry a compact current-conversation marker instead of repeating every
|
|
238
|
+
authority. A later process or conversation gets ordinary human-gated behavior
|
|
239
|
+
by default.
|
|
233
240
|
|
|
234
241
|
Managed Review is atomic and scope-validated:
|
|
235
242
|
|
|
@@ -238,10 +245,21 @@ context review approve-all <collection> --managed --format json
|
|
|
238
245
|
context review approve-all --all --managed --format json
|
|
239
246
|
```
|
|
240
247
|
|
|
241
|
-
Managed structure
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
248
|
+
Managed structure confirmation and Review use only the revision-bound commands
|
|
249
|
+
returned by `workflow.current`. Source boundaries and unread source bodies,
|
|
250
|
+
external operations, payload validation, deterministic close, and verification
|
|
251
|
+
errors are never bypassed.
|
|
252
|
+
|
|
253
|
+
For consecutive mechanical routes, the Agent may run:
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
context run --managed --until blocked-or-complete --format json
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
This is a bounded host loop over the same revisioned routes. It stops before
|
|
260
|
+
read-only interpretation, project configuration, unresolved authority,
|
|
261
|
+
diagnostics, or a non-unique command plan; it does not add another workflow
|
|
262
|
+
entry or make semantic decisions.
|
|
245
263
|
|
|
246
264
|
### `captureFile`
|
|
247
265
|
|
|
@@ -347,6 +365,7 @@ context run align:file:<source-name>:architecture --view read-plan --format json
|
|
|
347
365
|
context run align:file:<source-name>:architecture --view source-index --compact --format json
|
|
348
366
|
context run align:file:<source-name>:architecture --view span-detail --span <source-ref> --format json
|
|
349
367
|
context run align:file:<source-name>:architecture --view span-text --span <source-ref> --format json
|
|
368
|
+
context run align:file:<source-name>:architecture --view existing-knowledge --query <title-or-stable-ref> --format json
|
|
350
369
|
context run align:file:<source-name>:architecture --view schema --format json
|
|
351
370
|
context run align:file:<source-name>:architecture --view semantic-rules --format json
|
|
352
371
|
context run align:file:<source-name>:architecture --validate --input <structure.yaml> --format json
|
|
@@ -355,14 +374,23 @@ context run align:file:<source-name>:architecture --view structure-summary --inp
|
|
|
355
374
|
context run align:file:<source-name>:architecture --stage --input <structure.yaml> --format json
|
|
356
375
|
```
|
|
357
376
|
|
|
358
|
-
`--validate`, `--stage`,
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
377
|
+
`--validate`, `--stage`, and `--confirm` are mutually exclusive operations. An
|
|
378
|
+
`--input` without an operation is rejected unless the selected view explicitly
|
|
379
|
+
consumes that input. Deterministic boundary repairs run internally before the
|
|
380
|
+
result is returned. Successful validation returns a stage command with the
|
|
381
|
+
same file path. JSON run output keeps `next_action` first;
|
|
362
382
|
schema and full reports stay behind explicit Views, while `--verbose` restores
|
|
363
383
|
the full phase result and repeated contracts. Long diagnostics return a compact
|
|
364
384
|
first page plus an exact diagnostics continuation command.
|
|
365
385
|
|
|
386
|
+
`existing-knowledge` is the authoring-time lookup for approved identities. It
|
|
387
|
+
returns stable NodeRefs, ViewRefs, titles, tags, collections, and section counts
|
|
388
|
+
without exposing workspace storage paths. `--query` performs deterministic
|
|
389
|
+
case-insensitive exact/prefix/substring matching; `--collection`,
|
|
390
|
+
`--node-type`, `--page-size`, and the returned continuation command narrow or
|
|
391
|
+
page the same View. Use it after reading source evidence and before introducing
|
|
392
|
+
a new Node identity. Structure validation remains the final duplicate gate.
|
|
393
|
+
|
|
366
394
|
Align and compile evidence results include `semantic_rules`. Its `required`
|
|
367
395
|
array is the rule subset selected for the current judgment, with a selection
|
|
368
396
|
reason and content digest for each rule. `handle`, `digest`, and
|
|
@@ -383,22 +411,22 @@ cross multiple heading paths, without classifying document topics.
|
|
|
383
411
|
|
|
384
412
|
After capture, the capture phase itself exposes collection-neutral `read-plan`,
|
|
385
413
|
`source-index`, `span-detail`, `span-text`, and other read-only evidence views.
|
|
386
|
-
Status
|
|
387
|
-
evidence-backed, user-confirmed align declaration. Align then
|
|
388
|
-
`structure-summary` for structure work. Agents should not
|
|
389
|
-
`.tmp` directly.
|
|
414
|
+
Status selects `route.document.classification-required` until every captured
|
|
415
|
+
target has an evidence-backed, user-confirmed align declaration. Align then
|
|
416
|
+
adds `schema` and `structure-summary` for structure work. Agents should not
|
|
417
|
+
inspect `sources/` or `.tmp` directly.
|
|
390
418
|
|
|
391
|
-
Compile `read-plan`, `blockers`,
|
|
392
|
-
|
|
393
|
-
|
|
419
|
+
Compile `read-plan`, `blockers`, and `diagnostics` Views are workspace-read-only
|
|
420
|
+
and may run concurrently. Compile `--validate`, compile `--stage`, structure
|
|
421
|
+
confirmation, Review apply, and close are serial operations.
|
|
394
422
|
|
|
395
423
|
Structure payloads use `schema_version: "context.structure.v1"` and canonical
|
|
396
424
|
`file:` / `lark:` `#span` source refs. A one-file-to-one-page plan is represented
|
|
397
425
|
as ordinary `nodes[]` and `views[]` in the structure. It does not bypass
|
|
398
426
|
structure confirmation or compile. Continuity applies to each Section, while one View/Page may
|
|
399
|
-
contain multiple independently retrievable continuous Sections.
|
|
400
|
-
|
|
401
|
-
|
|
427
|
+
contain multiple independently retrievable continuous Sections. Deterministic
|
|
428
|
+
boundary splitting is applied internally during validate/stage; it is not a
|
|
429
|
+
separate Agent-authored payload or approval step.
|
|
402
430
|
|
|
403
431
|
### `compileProse`
|
|
404
432
|
|
|
@@ -431,27 +459,22 @@ Common commands:
|
|
|
431
459
|
|
|
432
460
|
```bash
|
|
433
461
|
context run compile:file:<source-name>:architecture --view read-plan --format json
|
|
434
|
-
context run compile:file:<source-name>:architecture --
|
|
435
|
-
context run compile:file:<source-name>:architecture --
|
|
436
|
-
context run compile:file:<source-name>:architecture --
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
by the current compile action contract; split source evidence or return to the
|
|
451
|
-
structure gate instead. The current approved section wire contract accepts `verbatim` and `empty`;
|
|
452
|
-
it does not accept rewritten or mechanical projection modes.
|
|
453
|
-
Relationships stay in `structure.yaml` typed edges in current output; do not
|
|
454
|
-
inject relation markers into verbatim body.
|
|
462
|
+
context run compile:file:<source-name>:architecture --validate --format json
|
|
463
|
+
context run compile:file:<source-name>:architecture --stage --format json
|
|
464
|
+
context run compile:file:<source-name>:architecture --view diagnostics --format json
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
Compile validates the complete confirmed source/collection slot before writing
|
|
468
|
+
any candidate, then materializes the slot atomically. Section bodies are
|
|
469
|
+
source-mirrored from the confirmed spans; the Agent does not create a separate
|
|
470
|
+
compile-actions payload. Each canonical source plus collection remains an
|
|
471
|
+
independent structure slot. When other captured align targets remain pending,
|
|
472
|
+
status routes to those slots before opening one collection-level Review
|
|
473
|
+
payload. `context close` is blocked while a planned View is unprepared, still
|
|
474
|
+
draft, or rejected without a structure revision.
|
|
475
|
+
|
|
476
|
+
Relationships stay in `structure.yaml` typed edges in current output; compile
|
|
477
|
+
does not infer relationships or inject relation markers into verbatim body.
|
|
455
478
|
|
|
456
479
|
### `extractTs`
|
|
457
480
|
|
|
@@ -518,8 +541,12 @@ candidate estimate before writing `unapproved/entities.jsonl`. The dry-run
|
|
|
518
541
|
preview also includes `knowledgeTree` and `knowledgePathExamples`, which show
|
|
519
542
|
where approved Markdown will land after review apply.
|
|
520
543
|
Its module and total summaries distinguish `discoveredFiles`, `analyzedFiles`,
|
|
521
|
-
`skippedFiles`, `symbols`, and `relations
|
|
522
|
-
|
|
544
|
+
`skippedFiles`, `symbols`, and `relations`. Module summaries also expose the
|
|
545
|
+
resolved `entryFiles`, exported/internal symbol counts, and a structural
|
|
546
|
+
`candidateKinds` count. These fields describe extractor output only; the CLI
|
|
547
|
+
does not infer which symbols are meaningful to a particular product or
|
|
548
|
+
audience. Modules with skipped files include the deterministic traversal
|
|
549
|
+
reason, such as files not reachable from exports-mode entries.
|
|
523
550
|
|
|
524
551
|
Phase id shape:
|
|
525
552
|
|
|
@@ -531,8 +558,9 @@ Codegraph extraction has two execution policies:
|
|
|
531
558
|
|
|
532
559
|
- `context run <phase-id>` is the Agent/user default. The first run sends every
|
|
533
560
|
code symbol to Review. Later runs preserve unchanged approved symbols and send
|
|
534
|
-
only `add`, `update`, and `remove` deltas to Review.
|
|
535
|
-
|
|
561
|
+
only `add`, `update`, and `remove` deltas to Review. After every phase result,
|
|
562
|
+
the Agent re-evaluates `context status --format json`; only
|
|
563
|
+
`workflow.current` decides whether Review is now required.
|
|
536
564
|
- `context run <phase-id> --auto-promote` is the explicit CI/CD path. It is valid
|
|
537
565
|
only for `phase.extract.ts` codegraph phases, applies deterministic code deltas
|
|
538
566
|
without Review, refreshes deterministic close when approved knowledge changed,
|
|
@@ -542,8 +570,9 @@ Codegraph extraction has two execution policies:
|
|
|
542
570
|
separate pipeline step; existing package outputs are reported stale.
|
|
543
571
|
|
|
544
572
|
This policy never auto-promotes architecture, business, decision, test, or
|
|
545
|
-
other semantic knowledge. Agents must
|
|
546
|
-
|
|
573
|
+
other semantic knowledge. Agents must not infer a human gate from a phase-local
|
|
574
|
+
result. Human gates and their inspection/resolution Actions are exposed only by
|
|
575
|
+
`workflow.current`.
|
|
547
576
|
|
|
548
577
|
Approved codegraph sections use the local evidence form
|
|
549
578
|
`src-N#symbol:<file>:<symbol>:<kind>@<digest>`. The file segment makes reverse
|
|
@@ -551,19 +580,6 @@ lookup exact when multiple files contain the same symbol name, kind, and digest;
|
|
|
551
580
|
the complete ref remains opaque to agents. New pages keep only top-level
|
|
552
581
|
`candidate_fingerprint` and do not emit `code_origin`.
|
|
553
582
|
|
|
554
|
-
Projects created by the beta.5 protocol can upgrade approved pages without a
|
|
555
|
-
second human decision. Rerun every declared codegraph extraction phase to write
|
|
556
|
-
the current file-aware symbol index, then run:
|
|
557
|
-
|
|
558
|
-
```bash
|
|
559
|
-
context review migrate-codegraph-refs
|
|
560
|
-
context verify
|
|
561
|
-
```
|
|
562
|
-
|
|
563
|
-
Migration resolves each legacy ref against the trusted index and its existing
|
|
564
|
-
origin metadata, removes `code_origin`, preserves the approved body and review
|
|
565
|
-
state, and rolls back all page writes if final verification fails.
|
|
566
|
-
|
|
567
583
|
### `reviewValidity`
|
|
568
584
|
|
|
569
585
|
Declare the review step for a collection:
|
|
@@ -91,6 +91,15 @@ Read node_modules/@c4a/context/docs/reference/template-variables.md.
|
|
|
91
91
|
|---|---|---|
|
|
92
92
|
| `packageName` | string | Package name from `kbPackage()` / `llmsPackage()`. |
|
|
93
93
|
| `packageKind` | string | `kb` or `llms`. |
|
|
94
|
+
| `knowledgeNamespace` | string | KB knowledge namespace; defaults to the package name and may be explicitly overridden. Empty for non-KB packages. |
|
|
95
|
+
| `namespacedKnowledge` | boolean | Whether the KB package has a knowledge namespace. |
|
|
96
|
+
| `skillsRoot` | string | Skills root, currently `skills`. |
|
|
97
|
+
| `wikisRoot` | string | Final wikis root, such as `wikis/component-lib-kb` or `wikis/platform/component-lib`. |
|
|
98
|
+
| `guidesRoot` | string | Final guides root, such as `guides/component-lib-kb` or `guides/platform/component-lib`. |
|
|
99
|
+
| `rulesRoot` | string | Final rules root, such as `rules/component-lib-kb` or `rules/platform/component-lib`. |
|
|
100
|
+
| `featsRoot` | string | Final feats root, such as `feats/component-lib-kb` or `feats/platform/component-lib`. |
|
|
101
|
+
| `skillName` | string | Author-maintained name of the Skill currently being rendered. Empty outside a `skills/<name>/...` template. |
|
|
102
|
+
| `skillPath` | string | Final package-relative `SKILL.md` path for the Skill currently being rendered. Empty outside a Skill template. |
|
|
94
103
|
| `knowledgeCount` | number | Selected approved Markdown file count. |
|
|
95
104
|
| `knowledgeTimestamp` | string | Latest selected approved Markdown `timestamp`, or epoch when empty. |
|
|
96
105
|
| `knowledge` | string | Concatenated selected approved Markdown bundle. Use carefully; it can be large. |
|
|
@@ -100,7 +109,7 @@ Read node_modules/@c4a/context/docs/reference/template-variables.md.
|
|
|
100
109
|
| `knowledgeTreeNodes` | array | Nested path tree for selected pages. Useful for custom navigation. |
|
|
101
110
|
| `knowledgeTree` | string | Markdown tree preview of selected pages. |
|
|
102
111
|
| `knowledgeItemsMarkdown` | string | Markdown list of up to 50 selected pages. |
|
|
103
|
-
| `knowledgeGroupsMarkdown` | string | Markdown
|
|
112
|
+
| `knowledgeGroupsMarkdown` | string | Markdown navigation for the current index. Folded directories render direct page links; expanded directories render links to generated indexes. |
|
|
104
113
|
| `buildInventory` | object | Deterministic package build inventory, including selected files, selected-by reasons, collection summaries, and package-visible edge records. |
|
|
105
114
|
| `buildInventoryJson` | string | Pretty JSON form of `buildInventory`. |
|
|
106
115
|
| `buildInventoryPath` | string | Package-relative inventory path, currently `context-build-inventory.json`. |
|
|
@@ -130,6 +139,7 @@ Each item contains:
|
|
|
130
139
|
| `internal_collection` | Alias for `internalCollection`. |
|
|
131
140
|
| `collection` | Internal approved collection; alias for `internalCollection`. |
|
|
132
141
|
| `okf_root` | OKF output root, for example `wikis`, `guides`, `rules`, or `feats`. |
|
|
142
|
+
| `okf_root_path` | Final package-relative OKF root; for KB packages it includes the distribution namespace. |
|
|
133
143
|
| `node_ref` | Stable NodeRef from approved frontmatter, for example `entity/button`. |
|
|
134
144
|
| `view_ref` | Stable ViewRef from approved frontmatter, for example `architecture:entity/button`. |
|
|
135
145
|
| `pathWithinCollection` | Path below the OKF root, for example `component-lib/symbol/button.md`. |
|
|
@@ -167,10 +177,13 @@ Each group contains:
|
|
|
167
177
|
| `internalCollection` | Internal approved collection; alias for `collection`. |
|
|
168
178
|
| `internal_collection` | Alias for `internalCollection`. |
|
|
169
179
|
| `okf_root` | OKF output root for this group, for example `wikis`, `guides`, `rules`, or `feats`. |
|
|
180
|
+
| `okf_root_path` | Final package-relative OKF root; for KB packages it includes the distribution namespace. |
|
|
170
181
|
| `title` | Display title; defaults to `name`, or the OKF root title for a root group. |
|
|
171
182
|
| `count` | Number of selected pages in this group. |
|
|
183
|
+
| `hasIndex` | Whether the active package navigation policy generates `indexPath`. |
|
|
184
|
+
| `has_index` | Alias for `hasIndex`. |
|
|
172
185
|
| `indexPath` | OKF-root-aware index path, for example `wikis/component-lib/index.md`, `guides/component-lib/index.md`, or `rules/index.md` for a root group. |
|
|
173
|
-
| `indexHrefFromTemplate` | Link from the template file currently being rendered to `indexPath`.
|
|
186
|
+
| `indexHrefFromTemplate` | Link from the template file currently being rendered to `indexPath`. Check `hasIndex` before rendering it. |
|
|
174
187
|
| `indexHrefFromCollectionIndex` | Link from the OKF root index to `indexPath`. |
|
|
175
188
|
| `items` | `knowledgeItems` in the group. |
|
|
176
189
|
|
|
@@ -178,8 +191,11 @@ Example:
|
|
|
178
191
|
|
|
179
192
|
```md
|
|
180
193
|
{{#each knowledgeGroups}}
|
|
181
|
-
##
|
|
194
|
+
## {{title}} ({{count}})
|
|
182
195
|
|
|
196
|
+
{{#if hasIndex}}
|
|
197
|
+
[Open directory index]({{indexHrefFromTemplate}})
|
|
198
|
+
{{/if}}
|
|
183
199
|
{{#each items}}
|
|
184
200
|
- [{{title}}]({{href}}) - {{type}}
|
|
185
201
|
{{/each}}
|
|
@@ -211,14 +227,14 @@ care about.
|
|
|
211
227
|
The default KB template uses the variables above to generate a starter index:
|
|
212
228
|
|
|
213
229
|
- bundle count and timestamp in OKF frontmatter;
|
|
214
|
-
-
|
|
215
|
-
- links to generated directory indexes
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
`context build`
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
230
|
+
- direct page links for directories folded by the active navigation policy;
|
|
231
|
+
- links to generated directory indexes when a directory exceeds the configured
|
|
232
|
+
inline-entry threshold.
|
|
233
|
+
|
|
234
|
+
`context build` always provides selected OKF root indexes. By default, a
|
|
235
|
+
non-root directory gets its own index only when it contains more than 50
|
|
236
|
+
descendant knowledge pages. Configure this with
|
|
237
|
+
`kbPackage({ navigation: { foldDirectoryIndexes, maxInlineEntries } })`.
|
|
222
238
|
|
|
223
239
|
The output is only a starter. Edit
|
|
224
240
|
`src/package-templates/kb/wikis/index.md` to add project-specific reading
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { PackageSelectDefinition } from "./contracts.js";
|
|
1
|
+
import type { PackageNavigationDefinition, PackageSelectDefinition } from "./contracts.js";
|
|
2
2
|
import type { PhaseDefinition, PhaseResourceReference } from "./phases.js";
|
|
3
3
|
import type { ProjectSourceDefinition } from "./sources.js";
|
|
4
|
-
export type { CodegraphCollection, DocumentMainlineCollection, EntityStatus, KnowledgeCollection, MainlineCollection, MarkdownTransform, FileCaptureProcessorDefinition, OkfRoot, PackageKind, PackageSelectDefinition, TopLevelNamespace, } from "./contracts.js";
|
|
5
|
-
export { assertDocumentMainlineCollection, assertKnowledgeCollection, assertMainlineCollection, assertOkfRoot, assertTopLevelNamespace, DOC_MAINLINE_COLLECTIONS, KNOWLEDGE_COLLECTIONS, MAINLINE_COLLECTIONS, OKF_ROOTS, TOP_LEVEL_NAMESPACES, } from "./contracts.js";
|
|
4
|
+
export type { CodegraphCollection, DocumentMainlineCollection, EntityStatus, KnowledgeCollection, MainlineCollection, MarkdownTransform, FileCaptureProcessorDefinition, OkfRoot, PackageKind, PackageNavigationDefinition, PackageSelectDefinition, TopLevelNamespace, } from "./contracts.js";
|
|
5
|
+
export { assertDocumentMainlineCollection, assertKnowledgeCollection, assertMainlineCollection, assertOkfRoot, assertTopLevelNamespace, DOC_MAINLINE_COLLECTIONS, DEFAULT_PACKAGE_NAVIGATION, KNOWLEDGE_COLLECTIONS, MAINLINE_COLLECTIONS, OKF_ROOTS, TOP_LEVEL_NAMESPACES, } from "./contracts.js";
|
|
6
6
|
export { assertDocumentEvidenceSectionMetadata, DOCUMENT_COMPILE_ACTION_SCHEMA_VERSION, DOCUMENT_EVIDENCE_SECTION_VALIDATION_STAGES, DOCUMENT_SECTION_CONTENT_MODES, DOCUMENT_STRUCTURE_SCHEMA_VERSION, } from "./documentEvidence.js";
|
|
7
7
|
export type { DocumentEvidenceSectionMetadata, DocumentEvidenceSectionValidationOptions, DocumentEvidenceSectionValidationStage, DocumentSectionContentMode, } from "./documentEvidence.js";
|
|
8
8
|
export { alignProse, captureFile, captureLark, compileProse, customPhase, extractTs, ExtractTsConfigurationError, NO_ENTRY_DETECTED, mdxJsonDocs, reviewValidity, } from "./phases.js";
|
|
@@ -18,6 +18,9 @@ export type PackageTemplateInput = string | {
|
|
|
18
18
|
path: string;
|
|
19
19
|
vars?: Record<string, TemplateVarValue>;
|
|
20
20
|
};
|
|
21
|
+
export type PackageDistributionDefinition = {
|
|
22
|
+
knowledgeNamespace: string;
|
|
23
|
+
};
|
|
21
24
|
export type BasePackageDefinition = {
|
|
22
25
|
name: string;
|
|
23
26
|
reads: readonly PhaseResourceReference[];
|
|
@@ -28,6 +31,8 @@ export type BasePackageDefinition = {
|
|
|
28
31
|
};
|
|
29
32
|
export type KbPackageDefinition = BasePackageDefinition & {
|
|
30
33
|
kind: "package.kb";
|
|
34
|
+
navigation: PackageNavigationDefinition;
|
|
35
|
+
distribution?: PackageDistributionDefinition;
|
|
31
36
|
};
|
|
32
37
|
export type LlmsPackageDefinition = BasePackageDefinition & {
|
|
33
38
|
kind: "package.llms";
|
|
@@ -47,6 +52,8 @@ export declare const kbPackage: (definition: {
|
|
|
47
52
|
name: string;
|
|
48
53
|
template: PackageTemplateInput;
|
|
49
54
|
select?: PackageSelectDefinition;
|
|
55
|
+
navigation?: Partial<PackageNavigationDefinition>;
|
|
56
|
+
distribution?: PackageDistributionDefinition;
|
|
50
57
|
}) => KbPackageDefinition;
|
|
51
58
|
export declare const llmsPackage: (definition: {
|
|
52
59
|
name: string;
|