@c4a/context 0.7.1 → 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 -428
  6. package/docs/guides/agent-guide.md +94 -518
  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 -121
  10. package/docs/reference/indexer-provider-protocol.md +43 -110
  11. package/docs/reference/package-templates.md +2 -3
  12. package/docs/reference/project-api.md +52 -986
  13. package/index.d.ts +10 -8
  14. package/index.js +4739 -7103
  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 +219 -252
  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 +66 -60
  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/indexerContractOverlay.d.ts +10 -10
  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 +491 -287
  55. package/indexerOverlayQuestionApplyProposal.d.ts +1022 -614
  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 -218
  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,470 +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
- and `reviewValidity`, then let the Context Indexer lifecycle create the
86
- confirmed requirements and exact Provider registry in `src/indexers.yaml`.
87
-
88
- For a Lark / Feishu document, register a Lark source with exactly one identity
89
- form, then declare `captureLark` and `reviewValidity`. Do not add
90
- `alignProse`/`compileProse` to a new workspace; those factories remain only for
91
- explicit migration and repair of older declarations.
92
-
93
- File and Lark sources use the same date-batch shape as repo sources. Multiple
94
- documents belong under one date instead of receiving `-2` / `-A` suffixes:
95
-
96
- ```bash
97
- context source add lark 20260712 --module user-manual --url <wiki-url>
98
- context source add lark 20260712 --module migration-guide --url <wiki-url>
99
- context source add file 20260712 --module local-manual --local ../manual
100
- ```
101
-
102
- When these sources are supplied together, they can be registered in one locked
103
- batch. Save the following as YAML/JSON or pipe it through stdin:
104
-
105
- ```yaml
106
- sources:
107
- - type: repo
108
- module: component-lib
109
- local: ../component-lib
110
- - type: lark
111
- url: <wiki-url>
112
- - type: file
113
- local: ../manual
114
- ```
7
+ ## 1. Initialize
115
8
 
116
9
  ```bash
117
- context source add batch 20260712 --input sources.yaml --format json
10
+ context init ./context
11
+ cd ./context
118
12
  ```
119
13
 
120
- Do not run multiple `context source add` commands concurrently. All source
121
- registry writes use one project lock and atomic replacement; if the lock is
122
- held, wait for the active command and retry.
123
-
124
- The command returns each concrete derived document module; use that value in a
125
- declaration such as `source("20260712", "wiki-<digest>", { type: "lark" })`.
126
- Snapshots are written as sibling files under `sources/lark|file/20260712/` with
127
- one date-level `manifest.json`; phase ids and manifest entries use the logical
128
- `YYYYMMDD/module` identity without creating a module subdirectory.
129
-
130
- If several documents were requested together, register and declare every
131
- module first. An explicit request to capture/read those exact paths or URLs is
132
- the read confirmation for that requested batch; do not ask again after
133
- registration. Merely mentioning a possible source is not permission.
134
- `context status --format json` returns all remaining capture phases in
135
- `workflow.current.commands`. Every item requiring the confirmed read scope is
136
- marked `after-human-confirmation`, so one explicit confirmation can authorize
137
- the complete requested batch without pausing for another date name or
138
- collection choice between modules. If any module lacks a declaration,
139
- `workflow.current.configuration` identifies the precise project change instead
140
- of returning an unexecutable command. Read every
141
- `workflow.current.resources.required` item before acting; long procedures and
142
- semantic rules remain available as files and are loaded only for the route that
143
- needs them.
14
+ Initialization creates source registries, `src/index.ts`, an empty
15
+ `src/indexers.yaml`, package templates, `knowledge/`, and `dist/`.
144
16
 
145
- After capture, status selects `route.indexer.lifecycle-required`. Follow its
146
- `run-indexer-lifecycle` resource and the exact `context indexer ...` outcomes:
147
- confirm the complete requirement set, discover and resolve an exact Markdown
148
- Provider, execute its evidence-bound worksets, reconcile/layout/audit the
149
- Result, and compile the current Candidate batch. Batch read permission does
150
- not choose requirements, a Provider, or a collection.
17
+ ## 2. Register source boundaries
151
18
 
152
- When the workspace also contains repo sources, Context prioritizes untouched
153
- code and document owner cells through that same Indexer Route. It does not
154
- switch to a second extraction or prose lifecycle and does not interrupt an
155
- accepted workset that is already durably recorded.
156
-
157
- For a single component package, use the package directory as the repo source
158
- boundary:
19
+ Examples:
159
20
 
160
21
  ```bash
161
- context source add repo 20260712 \
162
- --module component-lib \
163
- --local ../component-lib \
164
- --remote <git-remote-url> \
165
- --ref <commit-sha-or-prefix>
166
- context source ensure 20260712
167
- context source inspect 20260712/component-lib
168
- ```
169
-
170
- If `component-lib` and the Context workspace are inside the same Git checkout,
171
- the CLI stores the repo root relative to the workspace even when `--local` was
172
- absolute. The module symlink target is relative as well, so the checkout can be
173
- moved without rewriting source metadata. External checkouts may keep an
174
- absolute repo root.
175
-
176
- Repo batches must be valid calendar dates in `YYYYMMDD` form; suffixes such as
177
- `20260712-A` are rejected. `source ensure <date>` and `source inspect <date>`
178
- operate on every repo module registered under that date. A full
179
- `<date>/<module>` selector still targets one module.
180
-
181
- For a monorepo or subspace, choose the boundary deliberately:
182
-
183
- - Register each confirmed package/subdirectory with its own `--module` under
184
- the same date batch.
185
- - A parent monorepo registration is an inspection boundary only when it resolves
186
- to multiple packages; extraction remains bound to concrete registered modules.
187
-
188
- The long-term multi-module knowledge shape is stable across capture dates:
189
-
190
- ```text
191
- knowledge/codeindex/module-a/...
192
- 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>
193
25
  ```
194
26
 
195
- The CLI records each module's git root and subpath, then materializes
196
- `sources/repo/<date>/<module>` to the scoped view. Do not rely on
197
- `extractTs.include` to select a package; `include` is only a file filter inside
198
- 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.
199
30
 
200
- If the user first registers a monorepo root, run `context source inspect <date>/<module>`
201
- before extraction. Show the listed module paths to the user as a tree and
202
- register each chosen package path under the same date. The
203
- inspect output includes package names, manifest paths, versions when available,
204
- and suggested `context source add` commands.
31
+ ## 3. Declare capture and packages
205
32
 
206
- Remote Git sources need the same boundary decision. Ask for the remote URL, the
207
- pinned commit/ref, and whether the user approves cloning. The CLI does not
208
- clone, checkout, reset, or fetch silently. If registered source material is
209
- missing, the current Route exposes a repository recovery plan. The user chooses
210
- an existing checkout, a bounded local scan, or an explicit shallow/partial clone
211
- of the registered pinned commit. Context validates the remote, commit, and
212
- subpaths, restores local aliases, and materializes module links. Advancing to a
213
- new upstream commit remains a separate source-update decision.
214
-
215
- For a long-lived production workspace with project-specific source ownership or
216
- impact rules, copy the optional maintenance Skill template from
217
- `templates/project-skills/maintain-project-knowledge/SKILL.md` into the
218
- project's `.agents/skills/`, rename it for the project, and edit its project
219
- facts. Keep Context lifecycle commands in the installed Context Skill and
220
- current Route rather than duplicating them in the project Skill.
221
-
222
- ## 3. Declare The Flow
223
-
224
- ### Document Source Flow
225
-
226
- For source documents, keep the project declaration small. `src/index.ts`
227
- declares the trusted source/capture/review/package surface; the confirmed
228
- requirements and exact Provider selection live separately in
229
- `src/indexers.yaml`:
33
+ Use `src/index.ts` for capture and output only:
230
34
 
231
35
  ```ts
232
- import {
233
- captureFile,
234
- defineProject,
235
- reviewValidity,
236
- source,
237
- } from "@c4a/context";
36
+ import { captureFile, defineProject, kbPackage, source } from "@c4a/context";
238
37
 
239
- const docs = source("20260704", "product-docs", { type: "file" });
38
+ const docs = source("product-docs", { type: "file" });
240
39
 
241
40
  export default defineProject({
242
41
  sources: [docs],
243
- phases: [
244
- captureFile({ source: docs }),
245
- reviewValidity({ scope: "all" }),
246
- ],
247
- packages: [],
248
- });
249
- ```
250
-
251
- Then return to the installed Context Agent entry. For maintainer inspection,
252
- `context status --format json` exposes the same current Route. The normal
253
- sequence is:
254
-
255
- 1. capture the source into committed snapshots;
256
- 2. confirm requirements and resolve exact Code/Markdown Providers through the
257
- sole Indexer Route;
258
- 3. execute and reconcile evidence-bound worksets, then derive layout and audit
259
- the Result;
260
- 4. compile and review/apply the complete Indexer Candidate batch once;
261
- 5. run close once, then verify and build when packages are declared.
262
-
263
- See [Indexer Provider selection and customization](./guides/indexer-provider-and-customization.md)
264
- for the registry and Provider flow. Existing workspaces that still declare
265
- `alignProse`/`compileProse` may use their explicit diagnostic commands during
266
- migration, but Context does not select them as the default workflow.
267
-
268
- Do not read `sources/` or raw Markdown directly after entering the Context
269
- workflow; use the evidence views and `source_ref` values returned by the CLI.
270
-
271
- ### Code Source Flow
272
-
273
- Edit `src/index.ts`:
274
-
275
- ```ts
276
- import { defineProject, extractTs, reviewValidity, source } from "@c4a/context";
277
-
278
- const componentLib = source("20260712", "component-lib");
279
-
280
- export default defineProject({
281
- sources: [componentLib],
282
- phases: [
283
- extractTs({ source: componentLib, collection: "codeindex" }),
284
- 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
+ }),
285
49
  ],
286
- packages: [],
287
50
  });
288
51
  ```
289
52
 
290
- Inspect and run:
291
-
292
- ```bash
293
- context run --list
294
- context run extract:20260712/component-lib:codeindex --dry-run
295
- context run extract:20260712/component-lib:codeindex
296
- ```
297
-
298
- When operating through an Agent, use `--dry-run --format json` as the CLI
299
- implementation for a no-write preview. For extract phases it returns a
300
- `preview` block with resolved sources, modules, file counts, symbol counts,
301
- resolved entry files, exported/internal counts, symbol-kind counts, candidate
302
- estimates, `knowledgeTree`, `knowledgePathExamples`, and module-level hints.
303
- Treat that preview as a structural scope check before producing draft
304
- candidates; the CLI does not decide which symbols are important to a business
305
- or audience.
306
-
307
- The codeindex path keeps the stable module identity. The date stays in the repo
308
- source ref and phase id, not in the knowledge path:
309
-
310
- ```text
311
- knowledge/codeindex/<module>/symbol/<slug>.md
312
- ```
313
-
314
- Show the tree/path preview to the user before first extraction and describe it
315
- as a preview without writing candidates. If the module or path shape is not
316
- what the user expects, fix the module registration before extraction. An
317
- extra repeated package segment below the module may indicate an over-broad
318
- boundary.
319
-
320
- When one confirmed round contains several repo modules, preview and run their
321
- extract phases sequentially but defer the human gate until every phase finishes.
322
- The final Codegraph Review contains the combined draft set; do not review one
323
- module at a time.
324
-
325
- ## 4. Review
326
-
327
- ```bash
328
- context review html architecture --open
329
- ```
330
-
331
- Use the generated HTML page to approve or reject candidates. If the browser does
332
- not open automatically, use the emitted `file://` URL. When
333
- finished, open `Payload` and copy the review decision Payload into the agent chat.
334
- Uniform decisions use one JSON line; exceptions add JSONL lines. The agent
335
- writes that pasted payload to the recommended workspace scratch area,
336
- `.tmp/agent-payloads/`, and runs:
337
-
338
- ```bash
339
- context review apply <payload-file>
340
- ```
341
-
342
- Do not hand-write approved Markdown. `context review apply` owns materialization
343
- from the CLI-managed lifecycle candidate ledger into `knowledge/`. The runtime
344
- ledger is ignored and is removed after a successful close; durable rejected
345
- candidate fingerprints, when any, are kept in `knowledge/decisions.json`.
346
- The location is a recommendation rather than a CLI restriction. Do not create a
347
- top-level scratch directory or edit workspace config merely to retain a review
348
- payload.
53
+ Repo sources do not need a capture phase. The Code Indexer reads their pinned
54
+ source boundary through its controlled workset.
349
55
 
350
- ## 5. Build Packages
56
+ ## 4. Let the lifecycle prepare Indexers
351
57
 
352
- This is a product decision point. Before editing `packages`, read
353
- [Package Outputs](./guides/package-outputs.md) and explain the output tree to the
354
- user.
58
+ Run the current route and follow its declared next action. The Agent will:
355
59
 
356
- Recommended first output:
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.
357
68
 
358
- ```text
359
- dist/component-lib-kb/
360
- ├── AGENTS.md
361
- ├── skills/
362
- │ └── knowledge-query/
363
- │ └── SKILL.md
364
- └── wikis/
365
- ├── index.md
366
- ├── <group>/
367
- │ ├── index.md
368
- │ └── ...
369
- └── ...
370
- ```
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.
371
74
 
372
- Choose an agent knowledge-base package when agents should consume the reviewed
373
- knowledge as a reusable package. After the user chooses this output shape,
374
- declare it with `kbPackage()`.
75
+ Do not manually create a second extraction or Markdown pipeline in
76
+ `src/index.ts`.
375
77
 
376
- The package name already identifies the surrounding `dist/` directory. The OKF
377
- roots inside it stay flat (`wikis/`, `guides/`, `rules/`, and `feats/`), so do
378
- not ask for a second distribution namespace. Ask separately whether the author
379
- wants a short Skill prefix, then maintain the complete final Skill directory
380
- name in the template.
78
+ ## 5. Review Candidates
381
79
 
382
- The default `knowledge-query` skill teaches agents how to query copied OKF root
383
- directories structure-first, starting with `wikis/`, cite
384
- page/section evidence, inspect structure/build metadata when present, and report
385
- gaps instead of inventing unsupported answers. Before building, tell the user
386
- that `src/package-templates/kb/` is editable: they can change the default skill
387
- wording or add product-specific skills when the package needs behavior beyond
388
- knowledge lookup.
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.
389
84
 
390
- Selected OKF root subtrees such as `wikis/`, `guides/`, `rules/`, and
391
- `feats/` follow the C4A OKF Profile. The package root contains agent files; the
392
- OKF-compatible interchange surface is the selected OKF root directories. Edit
393
- `src/package-templates/kb/wikis/index.md` before build to describe package
394
- scope, intended users, and query guidance; other selected OKF root indexes are
395
- generated unless the template supplies them.
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.
396
87
 
397
- Alternative:
88
+ After approval, `close` writes the accepted pages under readable paths such as:
398
89
 
399
90
  ```text
400
- dist/component-lib-llms/
401
- └── llms.txt
91
+ knowledge/codeindex/component-lib/button.md
92
+ knowledge/architecture/product-docs/component-contract.md
402
93
  ```
403
94
 
404
- Choose an LLM text bundle when the user wants one text bundle for model/RAG
405
- import. After the user chooses this output shape, declare it with
406
- `llmsPackage()`.
407
- The user may also skip package output for now and keep only `knowledge/`.
408
-
409
- Do not offer `both` as a shortcut. If multiple outputs are needed, add one
410
- package first, inspect it, then add another after confirmation.
95
+ The CLI retains only metadata needed to update or rebuild those pages.
411
96
 
412
- Copy or create templates under `src/package-templates/`, inspect that they match
413
- the intended output shape, then declare packages. A `kbPackage()` template
414
- must contain at least one `SKILL.md`; the default template also includes
415
- `wikis/index.md`. The default template is a starting point, not proof that the
416
- final package is useful.
97
+ ## 6. Verify and build
417
98
 
418
- ```ts
419
- import {
420
- defineProject,
421
- extractTs,
422
- reviewValidity,
423
- kbPackage,
424
- source,
425
- } from "@c4a/context";
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.
426
102
 
427
- const componentLib = source("20260712", "component-lib");
428
-
429
- export default defineProject({
430
- sources: [componentLib],
431
- phases: [
432
- extractTs({ source: componentLib, collection: "codeindex" }),
433
- reviewValidity({ collection: "codeindex" }),
434
- ],
435
- packages: [
436
- kbPackage({
437
- name: "component-lib-kb",
438
- template: {
439
- path: "src/package-templates/kb",
440
- vars: { displayName: "Component Library KB" },
441
- },
442
- select: { include: ["codeindex/component-lib/**"] },
443
- }),
444
- ],
445
- });
446
- ```
447
-
448
- If the user chooses an LLM text bundle instead, declare `llmsPackage()` in place
449
- of the agent knowledge-base package:
450
-
451
- ```ts
452
- llmsPackage({
453
- name: "component-lib-llms",
454
- template: "src/package-templates/llms",
455
- select: { include: ["codeindex/component-lib/**"] },
456
- });
457
- ```
458
-
459
- Build and verify:
460
-
461
- ```bash
462
- context build
463
- context verify
464
- context status
465
- ```
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.
466
106
 
467
- Outputs are written under `dist/<package-name>/`.
107
+ ## Troubleshooting boundary
468
108
 
469
- After build, inspect `dist/<package-name>/` before calling the package usable.
470
- 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.