@c4a/context 0.6.1 → 0.6.2
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 +17 -6
- package/README.zh-CN.md +121 -0
- package/contracts.d.ts +5 -0
- package/docs/README.md +11 -8
- package/docs/getting-started.md +63 -28
- package/docs/guides/agent-dialogue.md +38 -350
- package/docs/guides/agent-guide.md +143 -93
- package/docs/guides/package-outputs.md +87 -25
- package/docs/reference/package-templates.md +121 -32
- package/docs/reference/project-api.md +225 -84
- package/docs/reference/template-variables.md +32 -15
- package/index.d.ts +13 -5
- package/index.js +99 -28
- package/package.json +1 -1
- package/phases.d.ts +65 -6
- package/templates/package-templates/kb/AGENTS.md +13 -16
- package/templates/package-templates/kb/skills/knowledge-query/SKILL.md +101 -177
- package/templates/package-templates/kb/skills/knowledge-query/scripts/search.mjs +264 -0
- package/templates/package-templates/kb/wikis/index.md +8 -8
- package/templates/package-templates.zh-CN/kb/AGENTS.md +30 -0
- package/templates/package-templates.zh-CN/kb/skills/knowledge-query/SKILL.md +99 -0
- package/templates/package-templates.zh-CN/kb/skills/knowledge-query/scripts/search.mjs +264 -0
- package/templates/package-templates.zh-CN/kb/wikis/index.md +39 -0
- package/templates/package-templates.zh-CN/llms/llms.txt +8 -0
|
@@ -5,25 +5,39 @@ This guide is for Coding Agents operating a Context workspace.
|
|
|
5
5
|
## Start Here
|
|
6
6
|
|
|
7
7
|
1. If a public Agent entry is available, use the installed Context continuation command/skill from the project root; the exact slash command or skill name is host-specific.
|
|
8
|
-
2. If you are implementing that entry or operating without plugins, run
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
2. If you are implementing that entry or operating without plugins, run
|
|
9
|
+
`context status --format json`.
|
|
10
|
+
3. Treat `workflow.current` as the current-step authority. Read every
|
|
11
|
+
`resources.required` item, execute only returned commands with their
|
|
12
|
+
revision/authority flags unchanged, and rerun status after each action.
|
|
13
|
+
A phase-local `next_action` may continue pagination or validation inside the
|
|
14
|
+
current operation; it never replaces the workspace route.
|
|
12
15
|
4. Before editing `src/index.ts`, read [Project API](../reference/project-api.md).
|
|
13
16
|
5. Before declaring or repairing packages, read [Package Outputs](./package-outputs.md)
|
|
14
17
|
and [Package Templates](../reference/package-templates.md).
|
|
15
|
-
6. Before asking a human gate question, read
|
|
18
|
+
6. Before asking a human gate question, read the dialogue resource selected in
|
|
19
|
+
`workflow.current.resources.required`; use [Agent Dialogue](./agent-dialogue.md)
|
|
20
|
+
only for stable cross-gate principles.
|
|
16
21
|
|
|
17
22
|
## Current-conversation fully managed mode
|
|
18
23
|
|
|
19
24
|
When the user explicitly requests fully managed operation in the current
|
|
20
25
|
conversation, use `context status --managed --format json` and keep `--managed`
|
|
21
|
-
on
|
|
26
|
+
only on commands that actually include it. Preserve every returned
|
|
27
|
+
revision/authority flag. Eligible classification, extraction
|
|
22
28
|
scope, structure confirmation, Review, and package-output gates may proceed
|
|
23
29
|
without another question. Review uses the CLI's atomic `context review
|
|
24
30
|
approve-all ... --managed` route; valid structure staging records
|
|
25
31
|
`confirmed_by: managed-session`.
|
|
26
32
|
|
|
33
|
+
After the first managed status evaluation, use
|
|
34
|
+
`context run --managed --until blocked-or-complete --format json` when the
|
|
35
|
+
current work can advance through consecutive mechanical routes. The CLI
|
|
36
|
+
executes only a unique immediate non-read command, re-evaluates after each
|
|
37
|
+
receipt, and stops before Agent interpretation, configuration, missing
|
|
38
|
+
authority, diagnostics, or multiple commands. Continue from the returned
|
|
39
|
+
`workflow.current`.
|
|
40
|
+
|
|
27
41
|
This is execution authority, not project configuration. Do not add it to
|
|
28
42
|
`defineProject`, environment files, or committed workspace state, and do not
|
|
29
43
|
carry it into a new conversation. It never grants a new source boundary or
|
|
@@ -44,8 +58,9 @@ protocol text: copy those exactly and do not translate them.
|
|
|
44
58
|
At human gates, explain the product decision and impact before internal API
|
|
45
59
|
details. Do not start with `extractTs`, `include`, `exportedOnly`,
|
|
46
60
|
`reviewValidity`, placeholder commands, or raw TypeScript snippets unless the
|
|
47
|
-
user asks for implementation detail. The
|
|
48
|
-
[Agent Dialogue](./agent-dialogue.md)
|
|
61
|
+
user asks for implementation detail. The current gate's dialogue pattern is
|
|
62
|
+
selected by `workflow.current.resources`; [Agent Dialogue](./agent-dialogue.md)
|
|
63
|
+
explains stable cross-gate principles.
|
|
49
64
|
|
|
50
65
|
## Do Not Self-Discover The SDK
|
|
51
66
|
|
|
@@ -61,15 +76,31 @@ node_modules/@c4a/context/docs/reference/package-templates.md
|
|
|
61
76
|
|
|
62
77
|
- `src/index.ts` declares sources, phases, and packages.
|
|
63
78
|
- `sources/repo/index.yaml`, `sources/file/index.yaml`, and `sources/lark/index.yaml` declare sources.
|
|
64
|
-
-
|
|
65
|
-
|
|
79
|
+
- `.tmp/context-runtime/lifecycle/` is the ignored, CLI-managed draft candidate
|
|
80
|
+
ledger and confirmed structure state for an open lifecycle round.
|
|
81
|
+
- `knowledge/` contains approved Markdown, the durable
|
|
82
|
+
`knowledge/structure.yaml` projection, and (only when needed) the compact
|
|
83
|
+
`knowledge/decisions.json` rejected candidate ID-to-fingerprint map.
|
|
84
|
+
- `knowledge/structure.yaml.source_inputs` contains only source, collection,
|
|
85
|
+
and consumed snapshot hash for closed prose targets. It lets status detect a
|
|
86
|
+
changed or unfinished target without retaining lifecycle snapshots.
|
|
66
87
|
- `dist/` contains generated package outputs.
|
|
88
|
+
- `.tmp/agent-payloads/` is the recommended location for transient inputs written
|
|
89
|
+
by the Agent for CLI commands. It is not enforced, but avoids introducing
|
|
90
|
+
top-level scratch directories; remove these files after the corresponding
|
|
91
|
+
stage or apply succeeds unless the user explicitly wants to retain them.
|
|
67
92
|
- file and Lark documents from one date live as sibling files under `sources/file/<date>/` and `sources/lark/<date>/`; each date directory has one shared `manifest.json`.
|
|
68
|
-
- `.tmp/context-runtime/` contains ignored runtime cache, logs, review HTML, previews, and locks.
|
|
93
|
+
- `.tmp/context-runtime/` contains ignored runtime cache, logs, review HTML, previews, and locks. Successful close removes completed lifecycle and review runtime state.
|
|
69
94
|
|
|
70
95
|
Do not create hidden workspace state directories.
|
|
71
96
|
|
|
72
|
-
## Workflow
|
|
97
|
+
## Workflow resources and entrypoints
|
|
98
|
+
|
|
99
|
+
Long procedures, semantic judgment rules, schemas, and current workspace views
|
|
100
|
+
are published as Context workflow resources. Status returns only the resources
|
|
101
|
+
selected for the current route. Read required resources before acting; use
|
|
102
|
+
recommended resources only when the current evidence or diagnostic needs them.
|
|
103
|
+
Do not preload every workflow resource or SDK manual.
|
|
73
104
|
|
|
74
105
|
Present only the current workflow surface:
|
|
75
106
|
|
|
@@ -78,12 +109,12 @@ Present only the current workflow surface:
|
|
|
78
109
|
| Register a knowledge boundary | `context source add file/lark/repo ...`, followed by the matching project phase declaration. Source registration is a user-confirmed boundary decision. |
|
|
79
110
|
| Capture document sources | Run the declared `capture:file:<date>/<module>` or `capture:lark:<date>/<module>` phase only after read permission. Capture writes a sibling document file under the matching date directory and updates that directory's single `manifest.json`. |
|
|
80
111
|
| Investigate captured material | Use `context status` and the returned `context run align:<type>:<source>:<collection> --view ...` commands. Evidence views drive reading; raw directory grep is not the workflow. |
|
|
81
|
-
| Confirm prose structure | `alignProse` validates and stages
|
|
112
|
+
| Confirm prose structure | `alignProse` validates and stages CLI-managed lifecycle structure. Validation does not equal user confirmation; only confirmed lifecycle state may enter prose compile. |
|
|
82
113
|
| Compile source-bound drafts | `compileProse` turns confirmed structure into source-bound draft pages. It does not approve knowledge. |
|
|
83
114
|
| Review and apply | Use `context review html` and `context review apply`. Approved prose pages are source-mirrored; rewrite/compression problems should return to structure/compile repair before apply. |
|
|
84
115
|
| Close, verify, build | Run `context close`, `context verify`, then `context build`. Close derives `knowledge/structure.yaml`, approved edge projection, and the final verify gate. |
|
|
85
116
|
| Code extraction | Use `context source inspect <source-name>` and the declared extract phase preview before code draft writes. |
|
|
86
|
-
| Source retraction | Follow the current status or lifecycle command if one exists. Do not delete `sources/`, `knowledge/`, `
|
|
117
|
+
| Source retraction | Follow the current status or lifecycle command if one exists. Do not delete `sources/`, `knowledge/`, `dist/`, or `.tmp` to simulate lifecycle actions. |
|
|
87
118
|
|
|
88
119
|
Judgment behavior is part of evidence views, source span resolvers, repair
|
|
89
120
|
hints, review/status diagnostics, OKF indexes, and package query discipline. Do
|
|
@@ -104,7 +135,8 @@ identity. Do not invent semantic date suffixes. The concrete repo selector
|
|
|
104
135
|
appears in source refs, phase ids, and codegraph paths:
|
|
105
136
|
|
|
106
137
|
```text
|
|
107
|
-
knowledge/<collection>/<
|
|
138
|
+
knowledge/<collection>/<slug>.md
|
|
139
|
+
knowledge/<collection>/<containment>/<slug>.md # intentional hierarchy only
|
|
108
140
|
repo:<date>/<module>#symbol:...
|
|
109
141
|
file:<source-name>/<document>#span:...
|
|
110
142
|
lark:<source-name>/<document>#span:...
|
|
@@ -113,7 +145,10 @@ align:lark:<source-name>:architecture
|
|
|
113
145
|
dist/<source-name>-kb/
|
|
114
146
|
```
|
|
115
147
|
|
|
116
|
-
|
|
148
|
+
Every prose View requires a stable filename `slug`. The CLI derives its path
|
|
149
|
+
from collection, slug, and optional `containment`; omit `path` from the input.
|
|
150
|
+
Supply `containment` only for an intentional parent/child hierarchy;
|
|
151
|
+
independent collection entries stay directly under the collection.
|
|
117
152
|
Codegraph paths use the registered date/module grouping before the symbol slug.
|
|
118
153
|
|
|
119
154
|
Ask what the user wants the source to cover: a single local Markdown/MDX document,
|
|
@@ -151,25 +186,34 @@ do not fetch or import Lark content with ad hoc scripts.
|
|
|
151
186
|
If the user requests multiple documents together, register and declare all of
|
|
152
187
|
them before capture. The user's explicit batch request supplies one read scope,
|
|
153
188
|
but it does not imply a mainline collection unless the user explicitly chose
|
|
154
|
-
one. Follow `
|
|
155
|
-
`
|
|
156
|
-
|
|
157
|
-
date name or repeat the collection gate per
|
|
189
|
+
one. Follow `workflow.current.commands`: run `immediate` items directly and run
|
|
190
|
+
`after-human-confirmation` items only after the current conversation contains
|
|
191
|
+
that confirmation. Preserve the returned workflow revision and authority flags
|
|
192
|
+
exactly. Do not ask for another date name or repeat the collection gate per
|
|
193
|
+
document.
|
|
158
194
|
|
|
159
195
|
## Current-step protocol
|
|
160
196
|
|
|
161
|
-
Treat `context status --format json` `
|
|
162
|
-
current step:
|
|
197
|
+
Treat `context status --format json` `workflow.current` as the complete
|
|
198
|
+
protocol for the current step:
|
|
163
199
|
|
|
164
|
-
- `
|
|
165
|
-
|
|
166
|
-
- `
|
|
167
|
-
|
|
200
|
+
- `availability` distinguishes an immediately executable route from a human
|
|
201
|
+
decision or a blocked route;
|
|
202
|
+
- `gate` identifies the decision, its authority, and whether a managed session
|
|
203
|
+
may resolve it;
|
|
168
204
|
- `configuration` identifies the exact project file and declaration action when
|
|
169
205
|
no CLI command is valid yet;
|
|
170
|
-
- `
|
|
171
|
-
|
|
172
|
-
|
|
206
|
+
- `commands[].availability` says whether each command runs immediately or only
|
|
207
|
+
after user confirmation;
|
|
208
|
+
- `resources.required` is the complete mandatory context for this route;
|
|
209
|
+
- `resources.recommended` is optional follow-up context; and
|
|
210
|
+
- `after_action.evaluate` requires status to be evaluated again after the
|
|
211
|
+
action.
|
|
212
|
+
|
|
213
|
+
Read a resource `path` directly. If a resource provides `command`, execute that
|
|
214
|
+
revision-bound Context command and read the returned file. Long procedures and
|
|
215
|
+
semantic rules live in these resources; they are loaded progressively, not
|
|
216
|
+
discarded or shortened into the status response.
|
|
173
217
|
|
|
174
218
|
Status also returns `declarationGraph` and `configurationGaps`. These expose
|
|
175
219
|
capture, align, compile, and Review coverage for each canonical document source
|
|
@@ -179,19 +223,21 @@ by the structure must have an exact compile route for the same source. Do not
|
|
|
179
223
|
run a compile command from another collection as a fallback. A
|
|
180
224
|
`reviewValidity({ scope: "all" })` declaration covers every collection.
|
|
181
225
|
|
|
182
|
-
When
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
collection
|
|
187
|
-
|
|
226
|
+
When `workflow.current.reason_code` is
|
|
227
|
+
`route.document.classification-required`, execute its read-only
|
|
228
|
+
`inspection_action` commands before adding align/compile declarations. Inspect
|
|
229
|
+
every unclassified target, explain the evidence behind the proposed mainline
|
|
230
|
+
collection, and wait for user confirmation. Filenames, URLs, source titles,
|
|
231
|
+
and collection names are hints, not sufficient classification evidence.
|
|
188
232
|
|
|
189
233
|
Also inspect `pendingStructureTargets`. A non-empty list means captured document
|
|
190
234
|
work remains outside the active structure snapshots, even if the current package
|
|
191
235
|
is already built. Follow `needs-prose-configuration` first when declarations are
|
|
192
236
|
missing, then run the exact returned align command. Continue in the same
|
|
193
237
|
workspace; do not replace a valid earlier structure round or create a second
|
|
194
|
-
workspace merely to add the next document.
|
|
238
|
+
workspace merely to add the next document. Missing declarations are selected
|
|
239
|
+
by `route.prose.configuration-required`; do not branch on an old top-level
|
|
240
|
+
`needs-prose-configuration` state.
|
|
195
241
|
|
|
196
242
|
Use `structureBatch` for the complete multi-source slot overview. Evidence View
|
|
197
243
|
commands are workspace-read-only and parallel-safe; structure stage/confirm,
|
|
@@ -204,24 +250,26 @@ another declared slot remains pending in the same round. Compile every View from
|
|
|
204
250
|
all slots first, open one collection-level Review, and let deterministic close
|
|
205
251
|
merge the active slots into `knowledge/structure.yaml`.
|
|
206
252
|
|
|
207
|
-
Do not infer permission from the presence of a command.
|
|
208
|
-
|
|
209
|
-
action
|
|
253
|
+
Do not infer permission from the presence of a command. When
|
|
254
|
+
`workflow.current.commands` is empty, do not derive a lifecycle command from
|
|
255
|
+
prose; complete the returned `configuration` action or resolve the returned
|
|
256
|
+
gate, then rerun status.
|
|
210
257
|
|
|
211
258
|
Extraction scope is also a human gate. If no extract phase is declared, explain
|
|
212
259
|
what code area and symbol policy will become draft knowledge, then ask which
|
|
213
260
|
registered source and file/symbol range to ingest. Do not inspect the source
|
|
214
|
-
repository to choose packages or globs on the user's behalf.
|
|
215
|
-
`
|
|
216
|
-
|
|
261
|
+
repository to choose packages or globs on the user's behalf. The
|
|
262
|
+
`route.extract.configuration-required` Route carries
|
|
263
|
+
`workflow.current.configuration` until that confirmed scope is declared; only
|
|
264
|
+
a declared phase can select `route.extract.pending-target` and return an
|
|
217
265
|
executable preview or extraction command.
|
|
218
266
|
|
|
219
267
|
For a fresh mixed-source workspace, capture every confirmed file/Lark source
|
|
220
268
|
first. If repo code is still unprocessed and document structure has not started,
|
|
221
|
-
`context status` prioritizes `
|
|
222
|
-
Complete
|
|
223
|
-
Once a document structure draft exists, keep that current human
|
|
224
|
-
switch workflows mid-review.
|
|
269
|
+
`context status` prioritizes `route.extract.pending-target` over document
|
|
270
|
+
investigation. Complete code extraction and its batch Review before starting
|
|
271
|
+
prose align. Once a document structure draft exists, keep that current human
|
|
272
|
+
gate and do not switch workflows mid-review.
|
|
225
273
|
|
|
226
274
|
For monorepos, the date is one registration batch and every selected package is
|
|
227
275
|
a module under it. Stable codegraph paths omit that batch date and therefore
|
|
@@ -259,10 +307,11 @@ context run <extract-phase-id> --dry-run --format json
|
|
|
259
307
|
After the preview, run codegraph extraction normally unless the user explicitly
|
|
260
308
|
asked for CI/CD automation. The first normal run requires Review for all code
|
|
261
309
|
candidates. Subsequent normal runs require Review only for added, changed, or
|
|
262
|
-
removed symbols; unchanged approved symbols stay approved.
|
|
263
|
-
`
|
|
264
|
-
|
|
265
|
-
`
|
|
310
|
+
removed symbols; unchanged approved symbols stay approved. After each result,
|
|
311
|
+
run `context status --format json`. `continue-codegraph-batch` only requests
|
|
312
|
+
workspace re-evaluation. Open Review only when
|
|
313
|
+
`workflow.current.gate.id=knowledge-review`; otherwise execute the current
|
|
314
|
+
route.
|
|
266
315
|
|
|
267
316
|
For a non-interactive pipeline, use `context run <extract-phase-id>
|
|
268
317
|
--auto-promote --format json`. This flag applies only to codegraph, applies its
|
|
@@ -272,21 +321,17 @@ and fails the command if close or verify fails. Read `autoPromotion.close` and
|
|
|
272
321
|
the pipeline publishes packages, run `context build` after successful auto
|
|
273
322
|
promotion. Never use auto promotion for semantic knowledge collections.
|
|
274
323
|
|
|
275
|
-
If verify reports `approved-source-ref-ambiguous` on approved codegraph pages
|
|
276
|
-
created by beta.5, do not send those pages back through Review and do not filter
|
|
277
|
-
approved symbols away. Rerun the declared codegraph extraction phase to refresh
|
|
278
|
-
the trusted file-aware symbol index, then run `context review
|
|
279
|
-
migrate-codegraph-refs` and `context verify`. Tell the user that this preserves
|
|
280
|
-
their decisions and approved content while upgrading evidence metadata. If the
|
|
281
|
-
reported ref already contains `<file>:<symbol>:<kind>`, treat it as a duplicate
|
|
282
|
-
symbol-index defect instead of a legacy migration.
|
|
283
|
-
|
|
284
324
|
Use the preview `mode`, optional `entries`, `preview.sources[].modules[]`,
|
|
325
|
+
`entryFiles`, exported/internal symbol counts, `candidateKinds`,
|
|
285
326
|
`candidateEstimate`, and `agent_hints`
|
|
286
327
|
fields as the authoritative scope check. To the user, call it a preview without
|
|
287
328
|
writing candidates; avoid the internal CLI term. Also show `knowledgeTree` and
|
|
288
329
|
`knowledgePathExamples` before first extraction.
|
|
289
330
|
|
|
331
|
+
These are structural extractor facts. Do not turn kind counts or file paths
|
|
332
|
+
into a product-specific recommendation unless the user or Agent supplies that
|
|
333
|
+
judgment.
|
|
334
|
+
|
|
290
335
|
Treat `NO_ENTRY_DETECTED` as a configuration failure: choose explicit
|
|
291
336
|
`entries`, or use `mode: "scan"` when the intended scope is all matched files;
|
|
292
337
|
never report an empty extraction as success. Report discovered, AST-analyzed,
|
|
@@ -301,7 +346,7 @@ knowledge/codegraph/<module>/symbol/<slug>.md
|
|
|
301
346
|
If the module or resulting path shape looks wrong, stop and repair the
|
|
302
347
|
module registration before running extraction. An extra repeated package
|
|
303
348
|
segment below the module may indicate an over-broad source boundary. Do not write ad hoc scripts to
|
|
304
|
-
count packages, parse `package.json`, or sample
|
|
349
|
+
count packages, parse `package.json`, or sample the lifecycle candidate ledger.
|
|
305
350
|
|
|
306
351
|
## Review Rules
|
|
307
352
|
|
|
@@ -320,7 +365,6 @@ count packages, parse `package.json`, or sample `unapproved/entities.jsonl`.
|
|
|
320
365
|
`context review approve <candidate-id> --collection <collection>` /
|
|
321
366
|
`context review reject <candidate-id> --collection <collection>` or `--all`.
|
|
322
367
|
These commands still enforce the scoped candidate-id gate.
|
|
323
|
-
- Do not expand the compact review decision Payload into pretty JSON unless the user asks.
|
|
324
368
|
- Do not edit approved Markdown by hand as part of review apply.
|
|
325
369
|
|
|
326
370
|
## Prose Align And Compile Rules
|
|
@@ -331,10 +375,9 @@ product sequence:
|
|
|
331
375
|
1. investigate material through Context evidence views;
|
|
332
376
|
2. propose a structure draft with nodes, section plans, supported edges, and
|
|
333
377
|
unresolved items;
|
|
334
|
-
3.
|
|
335
|
-
structure, open its HTML report, then
|
|
336
|
-
confirmation
|
|
337
|
-
order for this round;
|
|
378
|
+
3. resolve only the non-mechanical blockers until validation state is `ready`,
|
|
379
|
+
stage the structure, open its HTML report, then follow the current Route's
|
|
380
|
+
structure-confirmation gate;
|
|
338
381
|
4. compile source-bound draft pages from confirmed structure;
|
|
339
382
|
5. send compiled drafts through human review, then close and build.
|
|
340
383
|
|
|
@@ -348,6 +391,7 @@ context run align:<type>:<source>:<collection> --view read-plan --format json
|
|
|
348
391
|
context run align:<type>:<source>:<collection> --view source-index --compact --format json
|
|
349
392
|
context run align:<type>:<source>:<collection> --view span-detail --span <source-ref> --format json
|
|
350
393
|
context run align:<type>:<source>:<collection> --view span-text --span <source-ref> --format json
|
|
394
|
+
context run align:<type>:<source>:<collection> --view existing-knowledge --query <title-or-stable-ref> --format json
|
|
351
395
|
context run align:<type>:<source>:<collection> --view schema --format json
|
|
352
396
|
context run align:<type>:<source>:<collection> --validate --input <structure.yaml> --format json
|
|
353
397
|
context run align:<type>:<source>:<collection> --view structure-summary --input <structure.yaml> --format json
|
|
@@ -356,41 +400,41 @@ context run align:<type>:<source>:<collection> --stage --input <structure.yaml>
|
|
|
356
400
|
|
|
357
401
|
Read source material only through these evidence views. `source-index` gives a
|
|
358
402
|
compact refs-first map when run with `--compact`; use `span-detail` /
|
|
359
|
-
`span-text` only for exact evidence.
|
|
360
|
-
`
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
the structure
|
|
367
|
-
|
|
368
|
-
|
|
403
|
+
`span-text` only for exact evidence. Before introducing a new Node identity,
|
|
404
|
+
use the targeted `existing-knowledge` View returned by the read plan to inspect
|
|
405
|
+
approved stable refs; do not inspect `knowledge/**` directly. The CLI applies
|
|
406
|
+
deterministic boundary repairs internally and returns only blockers that need
|
|
407
|
+
Agent judgment. For oversized Views, use the returned structural diagnostics
|
|
408
|
+
while classifying
|
|
409
|
+
child Nodes from evidence. Stage only after validation state is `ready`; stage
|
|
410
|
+
opens the final `structure-summary` report for the current Route's confirmation
|
|
411
|
+
gate. Ask a separate structure-design question only when evidence supports
|
|
412
|
+
multiple incompatible semantic choices. Do not inspect `sources/` or `.tmp`
|
|
413
|
+
directly.
|
|
369
414
|
|
|
370
415
|
Compile:
|
|
371
416
|
|
|
372
417
|
```bash
|
|
373
418
|
context run compile:<type>:<source>:<collection> --view read-plan --format json
|
|
374
|
-
context run compile:<type>:<source>:<collection> --
|
|
375
|
-
context run compile:<type>:<source>:<collection> --
|
|
376
|
-
context run compile:<type>:<source>:<collection> --
|
|
377
|
-
context run compile:<type>:<source>:<collection> --stage --input <compile-actions.yaml> --format json
|
|
419
|
+
context run compile:<type>:<source>:<collection> --validate --format json
|
|
420
|
+
context run compile:<type>:<source>:<collection> --stage --format json
|
|
421
|
+
context run compile:<type>:<source>:<collection> --view diagnostics --format json
|
|
378
422
|
```
|
|
379
423
|
|
|
380
|
-
Compile
|
|
381
|
-
|
|
382
|
-
|
|
424
|
+
Compile derives every candidate mechanically from the confirmed section ids,
|
|
425
|
+
kinds, ownership, and source spans. One stage command validates the complete
|
|
426
|
+
source/collection slot before atomically writing its candidates. The Agent does
|
|
427
|
+
not author compile actions or rewrite reader-visible body. Re-evaluate status
|
|
428
|
+
after the batch, finish any other structure slots, then open one
|
|
429
|
+
collection-level Review, apply one Payload, and run close once.
|
|
383
430
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
the current compile action contract; split evidence or return to structure
|
|
387
|
-
confirmation instead. Relationships and cross references are structure typed
|
|
388
|
-
edges in current output; this workflow does not render relationship reference
|
|
389
|
-
blocks. Never inject relation markers into verbatim body.
|
|
431
|
+
Relationships and cross references remain structure typed edges; compile does
|
|
432
|
+
not infer them or inject relation markers into verbatim body.
|
|
390
433
|
|
|
391
434
|
## Package Rules
|
|
392
435
|
|
|
393
|
-
If `
|
|
436
|
+
If `workflow.current.reason_code` is `route.package.output-required`, treat it
|
|
437
|
+
as a human gate.
|
|
394
438
|
First read [Package Outputs](./package-outputs.md). Then explain the package
|
|
395
439
|
decision using concrete output trees, not unexplained labels.
|
|
396
440
|
|
|
@@ -402,13 +446,18 @@ dist/<name>-kb/
|
|
|
402
446
|
├── skills/knowledge-query/SKILL.md
|
|
403
447
|
└── wikis/
|
|
404
448
|
├── index.md
|
|
405
|
-
├── <group
|
|
406
|
-
└── <group
|
|
449
|
+
├── <group-page>.md
|
|
450
|
+
└── <large-group>/index.md
|
|
407
451
|
```
|
|
408
452
|
|
|
409
453
|
This is an agent knowledge-base package. It is the recommended first output for
|
|
410
454
|
agent consumption; the internal `skills/` folder follows agent installation
|
|
411
455
|
conventions.
|
|
456
|
+
The package name already identifies the surrounding `dist/` directory. Its OKF
|
|
457
|
+
roots stay flat (`wikis/`, `guides/`, `rules/`, and `feats/`), so do not ask for
|
|
458
|
+
a second distribution namespace. Ask separately whether the author wants a
|
|
459
|
+
short Skill prefix; if so, maintain the complete final Skill directory name in
|
|
460
|
+
the template.
|
|
412
461
|
The default `knowledge-query` skill teaches agents to query copied OKF root
|
|
413
462
|
directories structure-first, starting with `wikis/`, cite
|
|
414
463
|
page/section evidence, use structure/build metadata when present, and report
|
|
@@ -422,8 +471,9 @@ installation files; the OKF-compatible interchange surface is the selected OKF
|
|
|
422
471
|
root directories. Tell the user they can customize
|
|
423
472
|
`src/package-templates/kb/wikis/index.md` before build to describe package
|
|
424
473
|
scope and query guidance. The default root index should list only next-level
|
|
425
|
-
|
|
426
|
-
|
|
474
|
+
entries. By default, `context build` links small directory contents directly
|
|
475
|
+
and generates a child index only when that directory contains more than 50
|
|
476
|
+
selected knowledge pages.
|
|
427
477
|
|
|
428
478
|
Alternative:
|
|
429
479
|
|
|
@@ -43,28 +43,72 @@ least one `SKILL.md` and `wikis/index.md`.
|
|
|
43
43
|
The default `src/package-templates/kb/` template is only a starting point.
|
|
44
44
|
Inspect the generated `dist/<package-name>/` before calling it usable.
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
KB packages use flat package-relative knowledge roots:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
kbPackage({
|
|
50
|
+
name: "component-lib-kb",
|
|
51
|
+
template: "src/package-templates/kb",
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The package name already identifies the surrounding build folder, so the
|
|
56
|
+
output does not repeat it inside each root:
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
skills/knowledge-query/SKILL.md
|
|
60
|
+
wikis/index.md
|
|
61
|
+
guides/...
|
|
62
|
+
rules/...
|
|
63
|
+
feats/...
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Do not ask for another distribution namespace. Older workspaces may still
|
|
67
|
+
contain `distribution.knowledgeNamespace`; Context accepts that legacy input
|
|
68
|
+
without using it to shape the package.
|
|
69
|
+
|
|
70
|
+
Skill names are separate. Ask whether the author wants a short optional Skill
|
|
71
|
+
prefix, then maintain the complete final template directory name directly—for
|
|
72
|
+
example `skills/android-query/SKILL.md`. Package-root layout never renames a
|
|
73
|
+
Skill.
|
|
74
|
+
|
|
75
|
+
The default `knowledge-query` Skill is a complete generic query entry. It
|
|
76
|
+
carries the structure-first query discipline: start from OKF directory indexes, use
|
|
48
77
|
`context-build-inventory.json` edge records for package-visible relationships,
|
|
49
78
|
inspect page `sources` / `context:section` source_ref metadata, cite
|
|
50
79
|
page/section evidence, and report explicit gaps when the package does not cover
|
|
51
80
|
a requested fact. It does not treat direct grep over bundled OKF root
|
|
52
|
-
directories as the primary discovery path.
|
|
53
|
-
|
|
54
|
-
|
|
81
|
+
directories as the primary discovery path. When indexes do not narrow the
|
|
82
|
+
scope, or a candidate page is too large to read directly, its bundled
|
|
83
|
+
`scripts/search.mjs` provides deterministic BM25 ranking over mechanically
|
|
84
|
+
bounded Markdown chunks. Search results are leads; page bodies and typed edge
|
|
85
|
+
records remain the evidence. Its final template-author section
|
|
86
|
+
requires package authors to replace or edit the generic routing when the
|
|
87
|
+
package needs project-specific terminology, entry points, known limits, or
|
|
88
|
+
task workflows. Authors may explicitly accept the generic default when it is
|
|
89
|
+
intentionally sufficient.
|
|
90
|
+
|
|
91
|
+
The same inventory exposes `structure.relationship_coverage`. It records
|
|
92
|
+
whether selected codegraph pages have current source-backed AST relationship
|
|
93
|
+
metadata, how many codegraph views were selected, and how many package-visible
|
|
94
|
+
edges were emitted. An empty edge list is therefore explicit evidence of a
|
|
95
|
+
coverage state, not permission to invent a dependency.
|
|
55
96
|
|
|
56
97
|
The generated `wikis/` directory is the default OKF root and follows the C4A OKF
|
|
57
98
|
Profile. Internal production collections are mapped into package OKF roots such
|
|
58
99
|
as `wikis/`, `guides/`, `rules/`, or `feats/`; when selected, `context build`
|
|
59
100
|
copies them into the package and generates root-aware directory indexes for them
|
|
60
|
-
as
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
101
|
+
as needed. Selected OKF roots always have an index; smaller child directories
|
|
102
|
+
are folded into their nearest generated ancestor index by default. These roots
|
|
103
|
+
contain consumer-oriented Markdown with reader-facing frontmatter and no Context
|
|
104
|
+
lifecycle comments. Node identity, source metadata, code symbol lists,
|
|
105
|
+
relationship records, generated-child records, and candidate fingerprints are
|
|
106
|
+
kept out of each page. `context-build-inventory.json` maps distributed paths to
|
|
107
|
+
approved knowledge paths and exposes package-visible structure; exact Section
|
|
108
|
+
evidence remains in the mapped `knowledge/` page. The package root is an agent
|
|
65
109
|
package; the OKF-compatible interchange surface is the selected OKF root
|
|
66
|
-
subtrees under `dist/<package-name
|
|
67
|
-
|
|
110
|
+
subtrees under `dist/<package-name>/`. The required template entry and final
|
|
111
|
+
output path are both `wikis/index.md`.
|
|
68
112
|
|
|
69
113
|
Current collection mapping:
|
|
70
114
|
|
|
@@ -95,13 +139,22 @@ occupies `wikis/**/index.md`.
|
|
|
95
139
|
Tell the user it can be edited before build to describe the package scope,
|
|
96
140
|
intended users, and query guidance.
|
|
97
141
|
|
|
98
|
-
The default root index is a
|
|
99
|
-
|
|
100
|
-
|
|
142
|
+
The default root index is a usable generic entry, not a project-specific
|
|
143
|
+
information architecture.
|
|
144
|
+
It links directly to pages in small child directories and to a child
|
|
145
|
+
`index.md` when that directory exceeds the configured navigation threshold.
|
|
146
|
+
The default threshold is 50 selected knowledge pages. Use Handlebars variables such as
|
|
101
147
|
`knowledgeGroups`, `knowledgeItems`, and `knowledgeTree` when a project needs
|
|
102
148
|
custom navigation. Before customizing it, read
|
|
103
149
|
`node_modules/@c4a/context/docs/reference/template-variables.md`.
|
|
104
150
|
|
|
151
|
+
Newly initialized generic templates must be replaced, edited, or explicitly
|
|
152
|
+
accepted before the first build. `context status` exposes that choice as a
|
|
153
|
+
package template Review Gate. Use only the revision-bound command returned by
|
|
154
|
+
that Route to accept an unchanged generic default; edit files under
|
|
155
|
+
`src/package-templates/` when customizing. Context compares file digests and
|
|
156
|
+
records the decision without evaluating the meaning of template prose.
|
|
157
|
+
|
|
105
158
|
Template paths are rendered before selected knowledge is copied. A rendered
|
|
106
159
|
template path must not collide with a selected knowledge path. If the build
|
|
107
160
|
reports a collision, rename the template file or exclude that knowledge path
|
|
@@ -114,12 +167,12 @@ inside the package. Otherwise `context build` reports a template-boundary
|
|
|
114
167
|
diagnostic. Repair the template under `src/package-templates/`; do not patch
|
|
115
168
|
`dist/` as the durable fix.
|
|
116
169
|
|
|
117
|
-
KB package index links are also checked. `context build` validates
|
|
118
|
-
|
|
119
|
-
bundle-root absolute links
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
170
|
+
KB package index links are also checked. `context build` validates every
|
|
171
|
+
selected OKF root index and generated child `index.md` so relative links and
|
|
172
|
+
OKF bundle-root absolute links resolve inside `dist/<package-name>/`. Broken
|
|
173
|
+
index links are fixed by editing the template, approved knowledge path, or
|
|
174
|
+
package declaration and rerunning `context build`; do not patch `dist/`
|
|
175
|
+
directly as the durable fix.
|
|
123
176
|
|
|
124
177
|
## Alternative Output: LLM Text
|
|
125
178
|
|
|
@@ -154,8 +207,9 @@ knowledge/
|
|
|
154
207
|
|
|
155
208
|
## How To Ask The User
|
|
156
209
|
|
|
157
|
-
When `
|
|
158
|
-
tree. Do not ask the user to pick from
|
|
210
|
+
When `workflow.current.reason_code` is `route.package.output-required`,
|
|
211
|
+
explain the choices with the output tree. Do not ask the user to pick from
|
|
212
|
+
unexplained labels.
|
|
159
213
|
Use the host's native multi-choice tool when available. If unavailable, fall
|
|
160
214
|
back to a short Markdown A/B/C question. The option labels should be:
|
|
161
215
|
agent knowledge-base package, LLM text bundle, and skip package output for now.
|
|
@@ -171,8 +225,8 @@ dist/<name>-kb/
|
|
|
171
225
|
├── skills/knowledge-query/SKILL.md
|
|
172
226
|
└── wikis/
|
|
173
227
|
├── index.md
|
|
174
|
-
├── <group
|
|
175
|
-
└── <group
|
|
228
|
+
├── <group-page>.md
|
|
229
|
+
└── <large-group>/index.md
|
|
176
230
|
|
|
177
231
|
This is best if agents should use the knowledge as a reusable knowledge base.
|
|
178
232
|
|
|
@@ -187,5 +241,13 @@ We can also skip package output for now and keep only knowledge/.
|
|
|
187
241
|
Which one should I declare first?
|
|
188
242
|
```
|
|
189
243
|
|
|
244
|
+
If the user chooses the Agent knowledge-base package, explain that its OKF
|
|
245
|
+
roots are flat within `dist/<package-name>/`; do not ask for a second namespace.
|
|
246
|
+
Ask whether its Skills need a short prefix. The author maintains final Skill
|
|
247
|
+
names independently from package paths.
|
|
248
|
+
|
|
190
249
|
Do not offer `both` as a shortcut. If the user wants multiple outputs, add one
|
|
191
250
|
package first, verify the shape, then add another package after confirmation.
|
|
251
|
+
The default adaptive index policy avoids one-page directory indexes. Configure
|
|
252
|
+
`kbPackage().navigation` when a package needs a different inline-entry
|
|
253
|
+
threshold or a fully expanded index at every directory.
|