@c4a/context 0.6.1 → 0.6.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.
@@ -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 `context status`.
9
- 3. Execute safe mechanical CLI `next:` steps instead of merely reporting them.
10
- Stop and ask at `Human gate:` next steps, placeholder next steps, human
11
- decision gates, or external source-repo operations.
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 [Agent Dialogue](./agent-dialogue.md).
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 the commands returned by that loop. Eligible classification, extraction
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 required dialogue patterns are in
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,29 +76,45 @@ 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
- - `unapproved/entities.jsonl` is the committed draft/rejected/deprecated ledger.
65
- - `knowledge/` contains approved Markdown.
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 Entrypoints
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
 
76
107
  | Task | Current route |
77
108
  |---|---|
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
- | 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`. |
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, updates that directory's single `manifest.json`, and mechanically materializes supported Lark resources. Do not download or rewrite embedded resources outside the CLI. |
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 `unapproved/structure.yaml`. Validation does not equal user confirmation; only confirmed lifecycle state may enter prose compile. |
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/`, `unapproved/`, `dist/`, or `.tmp` to simulate lifecycle actions. |
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>/<containment>/<slug>.md
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
- Prose align/compile paths derive from collection, containment, and slug.
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 `routing.command_plan`: run
155
- `immediate` items directly and run `after-human-confirmation` items only after
156
- the current conversation contains that confirmation. Do not ask for another
157
- date name or repeat the collection gate per document.
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` `routing` as the complete protocol for the
162
- current step:
197
+ Treat `context status --format json` `workflow.current` as the complete
198
+ protocol for the current step:
163
199
 
164
- - `human_gate.required` says whether user input is required;
165
- - `human_gate.kind` says which product decision is being made;
166
- - `human_gate.confirmation` and `persistence` distinguish conversation-only
167
- permission from decisions persisted by a workspace command;
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
- - `commands_available` reports whether a command plan exists; and
171
- - `command_plan[].availability` says whether each command runs immediately or
172
- only after user confirmation.
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 status is `captured-ready-to-classify`, execute its immediate capture-phase
183
- evidence commands before adding align/compile declarations. Inspect every
184
- unclassified target, explain the evidence behind the proposed mainline
185
- collection, and wait for user confirmation. Filenames, URLs, source titles, and
186
- collection names are hints, not sufficient classification evidence by
187
- themselves.
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. Do not infer a command
208
- from prose when `commands_available=false`; complete the returned configuration
209
- action and rerun status instead.
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. Status reports
215
- `needs-extract-phase` with `routing.configuration` until that confirmed scope is
216
- declared; only a declared phase can advance to `ready-to-extract` and return an
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 `ready-to-extract` over document investigation.
222
- Complete the code extraction and its batch Review before starting prose align.
223
- Once a document structure draft exists, keep that current human gate and do not
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. Always inspect
263
- `next_action.human_gate`: `continue-codegraph-batch` means run status and finish
264
- the remaining confirmed module phases. Open one Review only after
265
- `pendingExtractPhases` is empty and the returned gate is `true`.
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 `unapproved/entities.jsonl`.
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. repair validator blockers until `confirmation_ready=true`, stage the
335
- structure, open its HTML report, then ask the user to confirm it because
336
- confirmation freezes paths, section ownership, relationships, and compile
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. When validate returns
360
- `repair_confirmation_blockers`, follow its repair route without asking for
361
- preliminary approval. `--repair suggested-splits` mechanically handles
362
- non-contiguous source Sections. For oversized Views, use the returned child
363
- View and contains-edge suggestions while classifying child Nodes from evidence.
364
- Stage only after
365
- `confirmation_ready=true`; stage opens the final `structure-summary` report for
366
- the structure confirmation gate. Ask a separate structure-design question only
367
- when evidence supports multiple incompatible semantic choices, and make clear
368
- that it is not final review. Do not inspect `sources/` or `.tmp` directly.
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> --view node-context --source <view-ref> --format json
375
- context run compile:<type>:<source>:<collection> --view schema --format json
376
- context run compile:<type>:<source>:<collection> --validate --input <compile-actions.yaml> --format json
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 each confirmed View sequentially, but do not stop for Review after each
381
- write. Follow `continue_compile_batch` until no planned View remains; then open
382
- one collection-level Review, apply one Payload, and run close once.
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
- Default compile actions should mirror source spans into `verbatim` body and
385
- attach summary/kind/source refs. Explicit reader-visible content is not part of
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 `context status` says `needs-package-output`, treat it as a human gate.
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>/index.md
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
- directories. `context build` generates child directory indexes such as
426
- `<okf-root>/<group>/index.md` for deeper navigation.
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
 
@@ -0,0 +1,115 @@
1
+ # Lark Resource Materialization
2
+
3
+ Lark documents can contain evidence that is not present in the readable text
4
+ body. Context handles these resources mechanically during `captureLark`; the
5
+ Agent does not download, summarize, or reconstruct them itself.
6
+
7
+ ## Resource policy
8
+
9
+ | Resource | Default capture behavior |
10
+ |---|---|
11
+ | Image and attachment | Download the original file and link it from the Markdown projection. |
12
+ | Sheet | Read the complete selected sheet, render a Markdown table, and retain a CSV snapshot. |
13
+ | Base | Read the selected table/view with pagination, render a Markdown table, and retain a canonical JSON snapshot. |
14
+ | Whiteboard and diagram | Retain a readable preview plus the raw structured export. |
15
+ | Synced block | Resolve the exact source block, project its body, and retain a Markdown evidence snapshot. |
16
+ | Poll | Preserve exported options and metadata as non-interactive Markdown; warn when the export omits them. |
17
+ | Bookmark, citation, sub-document, chat, and generic embed | Preserve a stable navigation reference and provenance. |
18
+ | Video | Preserve a stable reference by default; download only when `resources.videos` is `bundle`. |
19
+
20
+ Required inline resources fail closed when their stable identity, bytes, or
21
+ complete structured data cannot be obtained. When the remote API explicitly
22
+ confirms that a referenced whiteboard or diagram no longer exists, Context
23
+ preserves an unavailable-resource notice with the reason code
24
+ `document.resource.source-missing`, reports a warning, and continues capture;
25
+ it does not pretend that the deleted content was materialized. When the current
26
+ identity can read the document body but the API explicitly returns
27
+ `authorization/permission_denied` for an embedded resource, Context records
28
+ `document.resource.permission-denied`, keeps the stable resource identity in
29
+ the audit layer, renders the same unavailable-resource notice, and continues
30
+ with a warning. Missing scopes, transient network errors, malformed payloads,
31
+ and unclassified authorization failures still block capture. Reference-only
32
+ resources remain explicit in the capture report. Unknown non-empty XML blocks
33
+ stay auditable in the raw XML and receive a warning; the CLI does not infer
34
+ their meaning.
35
+
36
+ ## Storage lifecycle
37
+
38
+ Resources have three distinct locations:
39
+
40
+ ```text
41
+ sources/lark/<date>/
42
+ ├── <module>.md
43
+ ├── manifest.json
44
+ └── assets/<module>/
45
+ ├── source.xml
46
+ ├── capture-report.json
47
+ └── materialized/**
48
+ knowledge/assets/<resource-kind>/<content-sha256>.<ext>
49
+ dist/<package>/others/assets/<resource-kind>/<content-sha256>.<ext>
50
+ ```
51
+
52
+ - `sources/` is the captured source and audit layer. `source.xml` preserves the
53
+ structured source, one `capture-report.json` closes fidelity and resource
54
+ handling for the document, and `materialized/` contains downloaded files and
55
+ structured exports. Resource descriptors are consolidated in the report;
56
+ capture does not create one metadata file per embedded resource.
57
+ - The date-level `manifest.json` is a compact inventory. It records hashes,
58
+ asset roles, the report path, and status summaries without duplicating the
59
+ complete report.
60
+ - `knowledge/assets/` contains only resources referenced by approved pages.
61
+ Paths are content-addressed, so identical bytes are reused and changed bytes
62
+ produce a new identity. Review apply rewrites page links mechanically;
63
+ verification compares the underlying content identity, so this deterministic
64
+ path projection does not count as a change to a verbatim section.
65
+ Markdown files below `knowledge/assets/` remain evidence resources and are
66
+ never interpreted as approved knowledge pages or structure views.
67
+ - `others/assets/` is the portable package projection. Build copies only
68
+ resources referenced by selected package pages and rewrites their relative
69
+ links. Audit-only source files are not distributed.
70
+
71
+ Deleting an approved page allows unreferenced `knowledge/assets` files to be
72
+ cleaned. A missing approved or packaged resource is a verification error rather
73
+ than a silent broken link.
74
+
75
+ Source assets are part of the reproducible evidence snapshot and should not be
76
+ ignored when the workspace is versioned. Repositories with many binary source
77
+ assets can use Git LFS for `materialized/` while keeping Markdown, XML, JSON, and
78
+ CSV directly reviewable in Git. The workspace must remain private when the
79
+ captured source or screenshots are access-controlled.
80
+
81
+ ## SDK configuration
82
+
83
+ Defaults are suitable for ordinary documents:
84
+
85
+ ```ts
86
+ captureLark({ source: handbook });
87
+ ```
88
+
89
+ Projects can opt into bundled video and adjust deterministic byte limits:
90
+
91
+ ```ts
92
+ captureLark({
93
+ source: handbook,
94
+ resources: {
95
+ videos: "bundle",
96
+ maxBytesPerResource: 20 * 1024 * 1024,
97
+ maxTotalBytes: 200 * 1024 * 1024,
98
+ },
99
+ });
100
+ ```
101
+
102
+ The limits are capture constraints, not semantic filters. Context does not
103
+ decide which resources are important from their business content.
104
+
105
+ ## Agent behavior
106
+
107
+ Use the capture command returned by the current Route. Inspect the structured
108
+ resource summary and fidelity diagnostics; do not manually edit `sources/`,
109
+ `knowledge/assets/`, or package links. Required materialization failures other
110
+ than a confirmed source-side deletion or an explicit resource-level permission
111
+ denial must be resolved by recapturing after access or source problems are
112
+ fixed. Accepted failures remain visible as warnings and unavailable-resource
113
+ notices; they are never represented as downloaded evidence. Review shows
114
+ available previews, references, and warnings so the human or managed policy can
115
+ assess the page with its non-text evidence.