@c4a/context 0.7.0 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/README.md +65 -170
  2. package/README.zh-CN.md +52 -129
  3. package/docs/README.md +9 -10
  4. package/docs/README.zh-CN.md +6 -7
  5. package/docs/getting-started.md +73 -422
  6. package/docs/guides/agent-guide.md +94 -523
  7. package/docs/guides/code-indexer-skill-authoring.md +24 -13
  8. package/docs/guides/markdown-indexer-skill-authoring.md +14 -14
  9. package/docs/reference/code-extractors.md +29 -136
  10. package/docs/reference/indexer-provider-protocol.md +60 -138
  11. package/docs/reference/package-templates.md +2 -3
  12. package/docs/reference/project-api.md +52 -985
  13. package/index.d.ts +12 -10
  14. package/index.js +12749 -15335
  15. package/indexerAgentStepProtocol.d.ts +1366 -7649
  16. package/indexerArtifact.d.ts +225 -0
  17. package/indexerArtifactDependencies.d.ts +41 -39
  18. package/indexerArtifactResult.d.ts +221 -255
  19. package/indexerAuthorizedWorksetView.d.ts +368 -0
  20. package/indexerBaseQuestionAmendment.d.ts +484 -280
  21. package/indexerBenchmark.d.ts +16 -16
  22. package/indexerCandidateCompile.d.ts +206 -16
  23. package/indexerCapabilityGroupEvidence.d.ts +6 -6
  24. package/indexerCatalogFallback.d.ts +122 -128
  25. package/indexerCollectionMapping.d.ts +13 -13
  26. package/indexerContentLayers.d.ts +8 -8
  27. package/{indexerOverlayTrust.d.ts → indexerContractOverlay.d.ts} +23 -569
  28. package/indexerControlledInvocation.d.ts +12 -12
  29. package/indexerControlledProgram.d.ts +2467 -2797
  30. package/indexerCoreExports.d.ts +6 -6
  31. package/indexerCustomizationDraft.d.ts +3315 -2091
  32. package/indexerCustomizationLadder.d.ts +2 -2
  33. package/indexerDependencyView.d.ts +108 -108
  34. package/indexerEffectiveArtifact.d.ts +1134 -0
  35. package/indexerEvidenceAdapterAuthorityMerge.d.ts +48 -0
  36. package/indexerEvidenceAdapterResult.d.ts +52 -52
  37. package/indexerExampleDecision.d.ts +128 -128
  38. package/indexerExampleIdentity.d.ts +6 -6
  39. package/indexerGeneratedAuthoringAudit.d.ts +18 -18
  40. package/indexerIncrementalImpact.d.ts +16 -16
  41. package/indexerInspectorWorksetProjection.d.ts +6 -0
  42. package/indexerInventoryDisposition.d.ts +70 -70
  43. package/indexerLayerComposition.d.ts +2139 -373
  44. package/indexerLayoutChange.d.ts +10 -10
  45. package/indexerLayoutProposalSet.d.ts +71 -66
  46. package/indexerLayoutResolver.d.ts +53 -48
  47. package/indexerLayoutTransition.d.ts +0 -50
  48. package/indexerLifecycle.d.ts +0 -13
  49. package/indexerMainLifecycle.d.ts +10 -0
  50. package/indexerMainRunLedger.d.ts +138 -11
  51. package/indexerMainRunProtocol.d.ts +1406 -785
  52. package/indexerMainWorkset.d.ts +460 -206
  53. package/indexerMaterialGapLedger.d.ts +13 -2904
  54. package/indexerOverlayQuestionAmendment.d.ts +497 -293
  55. package/indexerOverlayQuestionApplyProposal.d.ts +1030 -622
  56. package/indexerParserCapabilityCatalog.d.ts +136 -0
  57. package/indexerParserCoordinate.d.ts +16 -16
  58. package/indexerParserDependencyIntent.d.ts +22 -0
  59. package/indexerParserExecutionPlan.d.ts +388 -0
  60. package/indexerParserFactView.d.ts +42 -22
  61. package/indexerPartitionConvergence.d.ts +0 -3
  62. package/indexerPartitionInventory.d.ts +2 -0
  63. package/indexerPartitionPlan.d.ts +101 -99
  64. package/indexerPhysicalArtifactManifest.d.ts +8 -8
  65. package/indexerPostAuthorComposition.d.ts +116 -1156
  66. package/indexerPostAuthorRunLedger.d.ts +1434 -280
  67. package/indexerPrimaryProjection.d.ts +10 -10
  68. package/indexerPrimaryResultView.d.ts +435 -0
  69. package/indexerProfileContract.d.ts +181 -181
  70. package/indexerProgramExecutionAuthorization.d.ts +12 -12
  71. package/indexerProgramRunProtocol.d.ts +2141 -2749
  72. package/indexerProjectProposal.d.ts +496 -292
  73. package/indexerProjectedArtifactFanOutAudit.d.ts +0 -3
  74. package/indexerProtocolCommon.d.ts +4 -1
  75. package/indexerProvider.d.ts +134 -281
  76. package/indexerProviderComposition.d.ts +53 -53
  77. package/indexerProviderResolution.d.ts +12 -12
  78. package/indexerProviderResolutionAction.d.ts +14 -14
  79. package/indexerProviderRouting.d.ts +923 -515
  80. package/indexerProviderSelectionProposal.d.ts +893 -485
  81. package/indexerQuestionAuthority.d.ts +46 -47
  82. package/indexerReaderTargetInventory.d.ts +8 -8
  83. package/indexerRegistry.d.ts +765 -357
  84. package/indexerRequirementConfirmation.d.ts +98 -98
  85. package/indexerRequirementLifecycle.d.ts +224 -224
  86. package/indexerResultReconciliation.d.ts +204 -5919
  87. package/indexerResultReconciliationRun.d.ts +0 -1
  88. package/indexerRunEnvelope.d.ts +20 -20
  89. package/indexerSemanticInput.d.ts +3678 -0
  90. package/indexerStructuredDeclaration.d.ts +57 -53
  91. package/indexerSubjectCatalog.d.ts +14 -14
  92. package/indexerSubjectIdentity.d.ts +2 -2
  93. package/indexerSubjectKeyAuthority.d.ts +31 -30
  94. package/indexerTemplateRendering.d.ts +64 -64
  95. package/indexerToolSnapshot.d.ts +8 -8
  96. package/package.json +1 -1
  97. package/phases.d.ts +3 -183
  98. package/codeIndexPlan.d.ts +0 -158
  99. package/indexerAuditFacts.d.ts +0 -66
  100. package/indexerAuditOverrideReadiness.d.ts +0 -27
  101. package/indexerAuditProtocol.d.ts +0 -238
  102. package/indexerAuditRevision.d.ts +0 -726
  103. package/indexerAuditRevisionActions.d.ts +0 -236
  104. package/indexerMaterialAnswer.d.ts +0 -738
  105. package/indexerMaterialAnswerActualization.d.ts +0 -91
  106. package/indexerMaterialAnswerExecutionPlan.d.ts +0 -2887
  107. package/indexerMaterialAnswerFlow.d.ts +0 -63
  108. package/indexerMaterialAnswerLayout.d.ts +0 -76
  109. package/indexerMaterialAnswerReview.d.ts +0 -217
  110. package/indexerMaterialAnswerReviewRoute.d.ts +0 -6145
  111. package/indexerMaterialAnswerRunLedger.d.ts +0 -918
  112. package/indexerMaterialAnswerRunProtocol.d.ts +0 -1253
  113. package/indexerMaterialQuestionExclusion.d.ts +0 -129
  114. package/indexerMaterialQuestionWorkset.d.ts +0 -508
  115. package/indexerPlannedMaterialAnswer.d.ts +0 -116
  116. package/indexerProfileMetricAudit.d.ts +0 -218
  117. package/indexerWorksetRead.d.ts +0 -287
@@ -1,464 +1,115 @@
1
- # Knowledge Project Walkthrough
1
+ # Getting Started
2
2
 
3
- This guide shows the common Context workspace shape. The same workspace can
4
- ingest source documents, code repositories, or both. Start with the user's
5
- source boundary, then declare the matching phases in `src/index.ts`.
3
+ Context turns registered code and documents into approved, reader-oriented
4
+ knowledge. The normal user starts through the installed Context Agent entry;
5
+ the Agent follows the Route returned by `context status --format json`.
6
6
 
7
- For normal use, start from the installed Context Agent entry and describe the
8
- knowledge goal. The entry resolves whether it should initialize a workspace,
9
- enter an existing workspace, or continue the current production round:
10
-
11
- ```text
12
- /c4a:context Build a traceable knowledge package from this repository and the
13
- documents I provide. Explain each source and structure decision before asking
14
- for confirmation.
15
- ```
16
-
17
- The remainder of this guide explains the project model behind that
18
- conversation. Command examples are maintainer orientation; an Agent should
19
- prefer the exact command and resources returned by `workflow.current`.
20
-
21
- ## 1. Establish the workspace
22
-
23
- When initialization is required, the Agent runs the exact action returned by
24
- `context entry`. A manual equivalent for automation or source development is:
25
-
26
- ```bash
27
- context init context
28
- cd context
29
- bun install
30
- context status --format json
31
- ```
32
-
33
- Use `--language zh-CN` (or `--language en`) during initialization when the
34
- generated README, AGENTS contract, and package starter templates should use a
35
- specific language. Context stores this choice in `package.json`; it does not
36
- guess from the shell locale or Agent conversation.
37
-
38
- Use `--dev` only when testing a locally linked CLI or a prepared package before
39
- the matching SDK version is published. It writes a `file:` dependency to the SDK
40
- resolved beside the active CLI. Registry installs should use the default command
41
- above so the workspace receives the matching versioned SDK dependency.
42
-
43
- Without `project-dir`, init uses the dedicated `context/` directory. Initializing
44
- inside a non-empty directory that is not already a Context workspace is blocked
45
- before any files are written; use the returned `--allow-nonempty` command only
46
- after confirming that the existing files should share the workspace root.
47
-
48
- After initialization, return to the single installed Context Agent entry from
49
- the project root. It consumes `workflow.current`, loads only the selected
50
- resources, and calls lower-level CLI primitives as needed. Do not introduce a
51
- separate continuation entry.
52
-
53
- ## 2. Choose And Register A Source Boundary
54
-
55
- First decide what one source should mean for this workspace. Document sources
56
- use one date name (`YYYYMMDD`). Repo sources use two levels: the date is a
57
- capture batch and `--module` identifies the concrete package or code boundary.
58
- Several repo modules can therefore be registered under the same date. Use the
59
- confirmed package/module identity for `--module`; do not invent semantic source
60
- suffixes from prose or content. ViewRef/NodeRef are identity fields, not path
61
- strings:
62
-
63
- ```text
64
- knowledge/<collection>/<slug>.md
65
- knowledge/<collection>/<containment>/<slug>.md # intentional hierarchy only
66
- repo:<date>/<module>#symbol:...
67
- file:<source-name>/<document>#span:...
68
- lark:<source-name>/<document>#span:...
69
- dist/<source-name>-kb/...
70
- ```
71
-
72
- For a Markdown or MDX document corpus, register a file source and keep the
73
- include list inside the user-approved boundary. Default file capture handles
74
- Markdown. For MDX documentation sites that use `_meta.json` route metadata,
75
- declare `captureFile({ source: docs, processor: mdxJsonDocs() })` in
76
- `src/index.ts`; `_meta.json` files are route metadata, and the CLI generates
77
- mechanical evidence pages for route facts and static MDX component text:
78
- `__context_route_metadata.md` and `__context_mdx_component_text.md`. If the CLI
79
- reports that a file source looks like a documentation site but lacks the
80
- processor, confirm the source boundary and add the processor before capture.
81
- If the selected page is only a runtime shell, capture the rendered-site source
82
- or project-specific data source explicitly; do not ask the agent to invent
83
- missing body text. The concrete command shape is available from
84
- `context source add file --help`; after registration, declare `captureFile`,
85
- `alignProse`, `compileProse`, and `reviewValidity`.
86
-
87
- For a Lark / Feishu document, register a Lark source with exactly one identity
88
- form, then declare `captureLark`, `alignProse`, `compileProse`, and
89
- `reviewValidity`.
90
-
91
- File and Lark sources use the same date-batch shape as repo sources. Multiple
92
- documents belong under one date instead of receiving `-2` / `-A` suffixes:
93
-
94
- ```bash
95
- context source add lark 20260712 --module user-manual --url <wiki-url>
96
- context source add lark 20260712 --module migration-guide --url <wiki-url>
97
- context source add file 20260712 --module local-manual --local ../manual
98
- ```
99
-
100
- When these sources are supplied together, they can be registered in one locked
101
- batch. Save the following as YAML/JSON or pipe it through stdin:
102
-
103
- ```yaml
104
- sources:
105
- - type: repo
106
- module: component-lib
107
- local: ../component-lib
108
- - type: lark
109
- url: <wiki-url>
110
- - type: file
111
- local: ../manual
112
- ```
7
+ ## 1. Initialize
113
8
 
114
9
  ```bash
115
- context source add batch 20260712 --input sources.yaml --format json
10
+ context init ./context
11
+ cd ./context
116
12
  ```
117
13
 
118
- Do not run multiple `context source add` commands concurrently. All source
119
- registry writes use one project lock and atomic replacement; if the lock is
120
- held, wait for the active command and retry.
121
-
122
- The command returns each concrete derived document module; use that value in a
123
- declaration such as `source("20260712", "wiki-<digest>", { type: "lark" })`.
124
- Snapshots are written as sibling files under `sources/lark|file/20260712/` with
125
- one date-level `manifest.json`; phase ids and manifest entries use the logical
126
- `YYYYMMDD/module` identity without creating a module subdirectory.
127
-
128
- If several documents were requested together, register and declare every
129
- module first. An explicit request to capture/read those exact paths or URLs is
130
- the read confirmation for that requested batch; do not ask again after
131
- registration. Merely mentioning a possible source is not permission.
132
- `context status --format json` returns all remaining capture phases in
133
- `workflow.current.commands`. Every item requiring the confirmed read scope is
134
- marked `after-human-confirmation`, so one explicit confirmation can authorize
135
- the complete requested batch without pausing for another date name or
136
- collection choice between modules. If any module lacks a declaration,
137
- `workflow.current.configuration` identifies the precise project change instead
138
- of returning an unexecutable command. Read every
139
- `workflow.current.resources.required` item before acting; long procedures and
140
- semantic rules remain available as files and are loaded only for the route that
141
- needs them.
14
+ Initialization creates source registries, `src/index.ts`, an empty
15
+ `src/indexers.yaml`, package templates, `knowledge/`, and `dist/`.
142
16
 
143
- After capture, status selects `route.document.classification-required` for
144
- document modules without an align declaration. Run the Gate's returned
145
- collection-neutral inspection commands first; only then propose a mainline
146
- collection and ask for confirmation. Batch read permission does not choose a
147
- collection.
17
+ ## 2. Register source boundaries
148
18
 
149
- When the workspace also contains repo sources, Context prioritizes untouched
150
- code after all document captures finish: the current reason is
151
- `route.extract.pending-target` until the code extraction round is current,
152
- then routing returns to document investigation. An existing document
153
- structure/compile gate is never interrupted.
154
-
155
- For a single component package, use the package directory as the repo source
156
- boundary:
19
+ Examples:
157
20
 
158
21
  ```bash
159
- context source add repo 20260712 \
160
- --module component-lib \
161
- --local ../component-lib \
162
- --remote <git-remote-url> \
163
- --ref <commit-sha-or-prefix>
164
- context source ensure 20260712
165
- context source inspect 20260712/component-lib
166
- ```
167
-
168
- If `component-lib` and the Context workspace are inside the same Git checkout,
169
- the CLI stores the repo root relative to the workspace even when `--local` was
170
- absolute. The module symlink target is relative as well, so the checkout can be
171
- moved without rewriting source metadata. External checkouts may keep an
172
- absolute repo root.
173
-
174
- Repo batches must be valid calendar dates in `YYYYMMDD` form; suffixes such as
175
- `20260712-A` are rejected. `source ensure <date>` and `source inspect <date>`
176
- operate on every repo module registered under that date. A full
177
- `<date>/<module>` selector still targets one module.
178
-
179
- For a monorepo or subspace, choose the boundary deliberately:
180
-
181
- - Register each confirmed package/subdirectory with its own `--module` under
182
- the same date batch.
183
- - A parent monorepo registration is an inspection boundary only when it resolves
184
- to multiple packages; extraction remains bound to concrete registered modules.
185
-
186
- The long-term multi-module knowledge shape is stable across capture dates:
187
-
188
- ```text
189
- knowledge/codeindex/module-a/...
190
- knowledge/codeindex/module-b/...
22
+ context source add repo 20260901 --module component-lib --local ../component-lib
23
+ context source add file product-docs --local ../docs
24
+ context source add lark handbook --doc-token <token>
191
25
  ```
192
26
 
193
- The CLI records each module's git root and subpath, then materializes
194
- `sources/repo/<date>/<module>` to the scoped view. Do not rely on
195
- `extractTs.include` to select a package; `include` is only a file filter inside
196
- one selected module.
27
+ Choose a boundary that matches ownership. For a monorepo, register the package
28
+ or service directory that should own the resulting knowledge rather than the
29
+ whole repository by default.
197
30
 
198
- If the user first registers a monorepo root, run `context source inspect <date>/<module>`
199
- before extraction. Show the listed module paths to the user as a tree and
200
- register each chosen package path under the same date. The
201
- inspect output includes package names, manifest paths, versions when available,
202
- and suggested `context source add` commands.
31
+ ## 3. Declare capture and packages
203
32
 
204
- Remote Git sources need the same boundary decision. Ask for the remote URL, the
205
- pinned commit/ref, and whether the user approves cloning. The CLI does not
206
- clone, checkout, reset, or fetch silently. If registered source material is
207
- missing, the current Route exposes a repository recovery plan. The user chooses
208
- an existing checkout, a bounded local scan, or an explicit shallow/partial clone
209
- of the registered pinned commit. Context validates the remote, commit, and
210
- subpaths, restores local aliases, and materializes module links. Advancing to a
211
- new upstream commit remains a separate source-update decision.
212
-
213
- For a long-lived production workspace with project-specific source ownership or
214
- impact rules, copy the optional maintenance Skill template from
215
- `templates/project-skills/maintain-project-knowledge/SKILL.md` into the
216
- project's `.agents/skills/`, rename it for the project, and edit its project
217
- facts. Keep Context lifecycle commands in the installed Context Skill and
218
- current Route rather than duplicating them in the project Skill.
219
-
220
- ## 3. Declare The Flow
221
-
222
- ### Document Source Flow
223
-
224
- For source documents, keep the project declaration small and let the CLI guide
225
- the evidence views, structure confirmation, deterministic compile projection,
226
- review, and close steps:
33
+ Use `src/index.ts` for capture and output only:
227
34
 
228
35
  ```ts
229
- import {
230
- alignProse,
231
- captureFile,
232
- compileProse,
233
- defineProject,
234
- reviewValidity,
235
- source,
236
- } from "@c4a/context";
36
+ import { captureFile, defineProject, kbPackage, source } from "@c4a/context";
237
37
 
238
- const docs = source("20260704", "product-docs", { type: "file" });
38
+ const docs = source("product-docs", { type: "file" });
239
39
 
240
40
  export default defineProject({
241
41
  sources: [docs],
242
- phases: [
243
- captureFile({ source: docs }),
244
- alignProse({ source: docs, collection: "architecture" }),
245
- compileProse({ source: docs, collection: "architecture" }),
246
- reviewValidity({ collection: "architecture" }),
247
- ],
248
- packages: [],
249
- });
250
- ```
251
-
252
- Then return to the installed Context Agent entry. For maintainer inspection,
253
- `context status --format json` exposes the same current Route. The normal
254
- sequence is:
255
-
256
- 1. capture the source into committed snapshots;
257
- 2. investigate evidence and confirm the CLI-managed lifecycle structure;
258
- 3. compile every source-bound View from confirmed structure;
259
- 4. review/apply the complete candidate batch once;
260
- 5. run close once, then verify and build when packages are declared.
261
-
262
- Do not read `sources/` or raw Markdown directly after entering the Context
263
- workflow; use the evidence views and `source_ref` values returned by the CLI.
264
-
265
- ### Code Source Flow
266
-
267
- Edit `src/index.ts`:
268
-
269
- ```ts
270
- import { defineProject, extractTs, reviewValidity, source } from "@c4a/context";
271
-
272
- const componentLib = source("20260712", "component-lib");
273
-
274
- export default defineProject({
275
- sources: [componentLib],
276
- phases: [
277
- extractTs({ source: componentLib, collection: "codeindex" }),
278
- reviewValidity({ collection: "codeindex" }),
42
+ phases: [captureFile({ source: docs })],
43
+ packages: [
44
+ kbPackage({
45
+ name: "component-kb",
46
+ template: "src/package-templates/kb",
47
+ select: { collections: ["codeindex", "architecture", "product"] },
48
+ }),
279
49
  ],
280
- packages: [],
281
50
  });
282
51
  ```
283
52
 
284
- Inspect and run:
53
+ Repo sources do not need a capture phase. The Code Indexer reads their pinned
54
+ source boundary through its controlled workset.
285
55
 
286
- ```bash
287
- context run --list
288
- context run extract:20260712/component-lib:codeindex --dry-run
289
- context run extract:20260712/component-lib:codeindex
290
- ```
56
+ ## 4. Let the lifecycle prepare Indexers
291
57
 
292
- When operating through an Agent, use `--dry-run --format json` as the CLI
293
- implementation for a no-write preview. For extract phases it returns a
294
- `preview` block with resolved sources, modules, file counts, symbol counts,
295
- resolved entry files, exported/internal counts, symbol-kind counts, candidate
296
- estimates, `knowledgeTree`, `knowledgePathExamples`, and module-level hints.
297
- Treat that preview as a structural scope check before producing draft
298
- candidates; the CLI does not decide which symbols are important to a business
299
- or audience.
58
+ Run the current route and follow its declared next action. The Agent will:
300
59
 
301
- The codeindex path keeps the stable module identity. The date stays in the repo
302
- source ref and phase id, not in the knowledge path:
60
+ 1. turn the user goal into explicit requirements and reader questions;
61
+ 2. inspect source boundaries and select Code or Markdown Providers;
62
+ 3. prepare a registry-only proposal for `src/indexers.yaml`;
63
+ 4. ask only for choices that change scope, ownership, or visible output;
64
+ 5. read the current bounded workset, return one compact Partition decision,
65
+ and review the resulting semantic outline;
66
+ 6. author each accepted subject, run any selected Composer, and let Context
67
+ compile the current Candidate set.
303
68
 
304
- ```text
305
- knowledge/codeindex/<module>/symbol/<slug>.md
306
- ```
69
+ In ordinary mode, a compatible layout pauses twice: once for the semantic
70
+ outline and once for the final Candidate pages. In explicitly authorized fully
71
+ managed mode, the Agent performs both judgments without showing them to the
72
+ user. Destructive or ambiguous changes to an already approved layout always
73
+ stop for a human decision.
307
74
 
308
- Show the tree/path preview to the user before first extraction and describe it
309
- as a preview without writing candidates. If the module or path shape is not
310
- what the user expects, fix the module registration before extraction. An
311
- extra repeated package segment below the module may indicate an over-broad
312
- boundary.
75
+ Do not manually create a second extraction or Markdown pipeline in
76
+ `src/index.ts`.
313
77
 
314
- When one confirmed round contains several repo modules, preview and run their
315
- extract phases sequentially but defer the human gate until every phase finishes.
316
- The final Codegraph Review contains the combined draft set; do not review one
317
- module at a time.
78
+ ## 5. Review Candidates
318
79
 
319
- ## 4. Review
80
+ Review shows readable paths, titles, summaries, and page content. Internal
81
+ evidence IDs remain in runtime artifacts. Approve, reject, or revise based on
82
+ whether the pages answer the intended reader questions and accurately reflect
83
+ the source.
320
84
 
321
- ```bash
322
- context review html architecture --open
323
- ```
324
-
325
- Use the generated HTML page to approve or reject candidates. If the browser does
326
- not open automatically, use the emitted `file://` URL. When
327
- finished, open `Payload` and copy the review decision Payload into the agent chat.
328
- Uniform decisions use one JSON line; exceptions add JSONL lines. The agent
329
- writes that pasted payload to the recommended workspace scratch area,
330
- `.tmp/agent-payloads/`, and runs:
331
-
332
- ```bash
333
- context review apply <payload-file>
334
- ```
335
-
336
- Do not hand-write approved Markdown. `context review apply` owns materialization
337
- from the CLI-managed lifecycle candidate ledger into `knowledge/`. The runtime
338
- ledger is ignored and is removed after a successful close; durable rejected
339
- candidate fingerprints, when any, are kept in `knowledge/decisions.json`.
340
- The location is a recommendation rather than a CLI restriction. Do not create a
341
- top-level scratch directory or edit workspace config merely to retain a review
342
- payload.
85
+ Revision reopens the owning Author or Composer workset and then recompiles the
86
+ same Candidate identity. It does not create a parallel document-editing flow.
343
87
 
344
- ## 5. Build Packages
345
-
346
- This is a product decision point. Before editing `packages`, read
347
- [Package Outputs](./guides/package-outputs.md) and explain the output tree to the
348
- user.
349
-
350
- Recommended first output:
88
+ After approval, `close` writes the accepted pages under readable paths such as:
351
89
 
352
90
  ```text
353
- dist/component-lib-kb/
354
- ├── AGENTS.md
355
- ├── skills/
356
- │ └── knowledge-query/
357
- │ └── SKILL.md
358
- └── wikis/
359
- ├── index.md
360
- ├── <group>/
361
- │ ├── index.md
362
- │ └── ...
363
- └── ...
91
+ knowledge/codeindex/component-lib/button.md
92
+ knowledge/architecture/product-docs/component-contract.md
364
93
  ```
365
94
 
366
- Choose an agent knowledge-base package when agents should consume the reviewed
367
- knowledge as a reusable package. After the user chooses this output shape,
368
- declare it with `kbPackage()`.
369
-
370
- The package name already identifies the surrounding `dist/` directory. The OKF
371
- roots inside it stay flat (`wikis/`, `guides/`, `rules/`, and `feats/`), so do
372
- not ask for a second distribution namespace. Ask separately whether the author
373
- wants a short Skill prefix, then maintain the complete final Skill directory
374
- name in the template.
95
+ The CLI retains only metadata needed to update or rebuild those pages.
375
96
 
376
- The default `knowledge-query` skill teaches agents how to query copied OKF root
377
- directories structure-first, starting with `wikis/`, cite
378
- page/section evidence, inspect structure/build metadata when present, and report
379
- gaps instead of inventing unsupported answers. Before building, tell the user
380
- that `src/package-templates/kb/` is editable: they can change the default skill
381
- wording or add product-specific skills when the package needs behavior beyond
382
- knowledge lookup.
97
+ ## 6. Verify and build
383
98
 
384
- Selected OKF root subtrees such as `wikis/`, `guides/`, `rules/`, and
385
- `feats/` follow the C4A OKF Profile. The package root contains agent files; the
386
- OKF-compatible interchange surface is the selected OKF root directories. Edit
387
- `src/package-templates/kb/wikis/index.md` before build to describe package
388
- scope, intended users, and query guidance; other selected OKF root indexes are
389
- generated unless the template supplies them.
99
+ The workflow verifies approved knowledge, then builds the declared package in
100
+ `dist/<package-name>/`. Package pages are a reader projection and intentionally
101
+ omit runtime evidence IDs and most digests.
390
102
 
391
- Alternative:
392
-
393
- ```text
394
- dist/component-lib-llms/
395
- └── llms.txt
396
- ```
397
-
398
- Choose an LLM text bundle when the user wants one text bundle for model/RAG
399
- import. After the user chooses this output shape, declare it with
400
- `llmsPackage()`.
401
- The user may also skip package output for now and keep only `knowledge/`.
402
-
403
- Do not offer `both` as a shortcut. If multiple outputs are needed, add one
404
- package first, inspect it, then add another after confirmation.
405
-
406
- Copy or create templates under `src/package-templates/`, inspect that they match
407
- the intended output shape, then declare packages. A `kbPackage()` template
408
- must contain at least one `SKILL.md`; the default template also includes
409
- `wikis/index.md`. The default template is a starting point, not proof that the
410
- final package is useful.
411
-
412
- ```ts
413
- import {
414
- defineProject,
415
- extractTs,
416
- reviewValidity,
417
- kbPackage,
418
- source,
419
- } from "@c4a/context";
420
-
421
- const componentLib = source("20260712", "component-lib");
422
-
423
- export default defineProject({
424
- sources: [componentLib],
425
- phases: [
426
- extractTs({ source: componentLib, collection: "codeindex" }),
427
- reviewValidity({ collection: "codeindex" }),
428
- ],
429
- packages: [
430
- kbPackage({
431
- name: "component-lib-kb",
432
- template: {
433
- path: "src/package-templates/kb",
434
- vars: { displayName: "Component Library KB" },
435
- },
436
- select: { include: ["codeindex/component-lib/**"] },
437
- }),
438
- ],
439
- });
440
- ```
441
-
442
- If the user chooses an LLM text bundle instead, declare `llmsPackage()` in place
443
- of the agent knowledge-base package:
444
-
445
- ```ts
446
- llmsPackage({
447
- name: "component-lib-llms",
448
- template: "src/package-templates/llms",
449
- select: { include: ["codeindex/component-lib/**"] },
450
- });
451
- ```
452
-
453
- Build and verify:
454
-
455
- ```bash
456
- context build
457
- context verify
458
- context status
459
- ```
103
+ Source or requirement changes re-enter the same Indexer lifecycle. Successful
104
+ work is recovered from persisted runtime state; successful close clears
105
+ temporary Candidate and Review state.
460
106
 
461
- Outputs are written under `dist/<package-name>/`.
107
+ ## Troubleshooting boundary
462
108
 
463
- After build, inspect `dist/<package-name>/` before calling the package usable.
464
- A clean command exit only means the workspace protocol is valid.
109
+ - Fix a missing or stale source with `context source ...`.
110
+ - Fix capture configuration in `src/index.ts`.
111
+ - Fix knowledge requirements, Provider selection, or customization through the
112
+ `src/indexers.yaml` proposal flow.
113
+ - Fix reader output through Provider instructions/templates, not by adding a
114
+ parallel project phase.
115
+ - Never treat generated `dist/` as source material.