@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.
- package/README.md +65 -170
- package/README.zh-CN.md +52 -129
- package/docs/README.md +9 -10
- package/docs/README.zh-CN.md +6 -7
- package/docs/getting-started.md +73 -428
- package/docs/guides/agent-guide.md +94 -518
- package/docs/guides/code-indexer-skill-authoring.md +24 -13
- package/docs/guides/markdown-indexer-skill-authoring.md +14 -14
- package/docs/reference/code-extractors.md +29 -121
- package/docs/reference/indexer-provider-protocol.md +43 -110
- package/docs/reference/package-templates.md +2 -3
- package/docs/reference/project-api.md +52 -986
- package/index.d.ts +10 -8
- package/index.js +4739 -7103
- package/indexerAgentStepProtocol.d.ts +1366 -7649
- package/indexerArtifact.d.ts +225 -0
- package/indexerArtifactDependencies.d.ts +41 -39
- package/indexerArtifactResult.d.ts +219 -252
- package/indexerAuthorizedWorksetView.d.ts +368 -0
- package/indexerBaseQuestionAmendment.d.ts +484 -280
- package/indexerBenchmark.d.ts +16 -16
- package/indexerCandidateCompile.d.ts +66 -60
- package/indexerCapabilityGroupEvidence.d.ts +6 -6
- package/indexerCatalogFallback.d.ts +122 -128
- package/indexerCollectionMapping.d.ts +13 -13
- package/indexerContentLayers.d.ts +8 -8
- package/indexerContractOverlay.d.ts +10 -10
- package/indexerControlledInvocation.d.ts +12 -12
- package/indexerControlledProgram.d.ts +2467 -2797
- package/indexerCoreExports.d.ts +6 -6
- package/indexerCustomizationDraft.d.ts +3315 -2091
- package/indexerCustomizationLadder.d.ts +2 -2
- package/indexerDependencyView.d.ts +108 -108
- package/indexerEffectiveArtifact.d.ts +1134 -0
- package/indexerEvidenceAdapterAuthorityMerge.d.ts +48 -0
- package/indexerEvidenceAdapterResult.d.ts +52 -52
- package/indexerExampleDecision.d.ts +128 -128
- package/indexerExampleIdentity.d.ts +6 -6
- package/indexerGeneratedAuthoringAudit.d.ts +18 -18
- package/indexerIncrementalImpact.d.ts +16 -16
- package/indexerInspectorWorksetProjection.d.ts +6 -0
- package/indexerInventoryDisposition.d.ts +70 -70
- package/indexerLayerComposition.d.ts +2139 -373
- package/indexerLayoutChange.d.ts +10 -10
- package/indexerLayoutProposalSet.d.ts +71 -66
- package/indexerLayoutResolver.d.ts +53 -48
- package/indexerLayoutTransition.d.ts +0 -50
- package/indexerLifecycle.d.ts +0 -13
- package/indexerMainLifecycle.d.ts +10 -0
- package/indexerMainRunLedger.d.ts +138 -11
- package/indexerMainRunProtocol.d.ts +1406 -785
- package/indexerMainWorkset.d.ts +460 -206
- package/indexerMaterialGapLedger.d.ts +13 -2904
- package/indexerOverlayQuestionAmendment.d.ts +491 -287
- package/indexerOverlayQuestionApplyProposal.d.ts +1022 -614
- package/indexerParserCapabilityCatalog.d.ts +136 -0
- package/indexerParserCoordinate.d.ts +16 -16
- package/indexerParserDependencyIntent.d.ts +22 -0
- package/indexerParserExecutionPlan.d.ts +388 -0
- package/indexerParserFactView.d.ts +42 -22
- package/indexerPartitionConvergence.d.ts +0 -3
- package/indexerPartitionInventory.d.ts +2 -0
- package/indexerPartitionPlan.d.ts +101 -99
- package/indexerPhysicalArtifactManifest.d.ts +8 -8
- package/indexerPostAuthorComposition.d.ts +116 -1156
- package/indexerPostAuthorRunLedger.d.ts +1434 -280
- package/indexerPrimaryProjection.d.ts +10 -10
- package/indexerPrimaryResultView.d.ts +435 -0
- package/indexerProfileContract.d.ts +181 -181
- package/indexerProgramExecutionAuthorization.d.ts +12 -12
- package/indexerProgramRunProtocol.d.ts +2141 -2749
- package/indexerProjectProposal.d.ts +496 -292
- package/indexerProjectedArtifactFanOutAudit.d.ts +0 -3
- package/indexerProtocolCommon.d.ts +4 -1
- package/indexerProvider.d.ts +134 -218
- package/indexerProviderComposition.d.ts +53 -53
- package/indexerProviderResolution.d.ts +12 -12
- package/indexerProviderResolutionAction.d.ts +14 -14
- package/indexerProviderRouting.d.ts +923 -515
- package/indexerProviderSelectionProposal.d.ts +893 -485
- package/indexerQuestionAuthority.d.ts +46 -47
- package/indexerReaderTargetInventory.d.ts +8 -8
- package/indexerRegistry.d.ts +765 -357
- package/indexerRequirementConfirmation.d.ts +98 -98
- package/indexerRequirementLifecycle.d.ts +224 -224
- package/indexerResultReconciliation.d.ts +204 -5919
- package/indexerResultReconciliationRun.d.ts +0 -1
- package/indexerRunEnvelope.d.ts +20 -20
- package/indexerSemanticInput.d.ts +3678 -0
- package/indexerStructuredDeclaration.d.ts +57 -53
- package/indexerSubjectCatalog.d.ts +14 -14
- package/indexerSubjectIdentity.d.ts +2 -2
- package/indexerSubjectKeyAuthority.d.ts +31 -30
- package/indexerTemplateRendering.d.ts +64 -64
- package/indexerToolSnapshot.d.ts +8 -8
- package/package.json +1 -1
- package/phases.d.ts +3 -183
- package/codeIndexPlan.d.ts +0 -158
- package/indexerAuditFacts.d.ts +0 -66
- package/indexerAuditOverrideReadiness.d.ts +0 -27
- package/indexerAuditProtocol.d.ts +0 -238
- package/indexerAuditRevision.d.ts +0 -726
- package/indexerAuditRevisionActions.d.ts +0 -236
- package/indexerMaterialAnswer.d.ts +0 -738
- package/indexerMaterialAnswerActualization.d.ts +0 -91
- package/indexerMaterialAnswerExecutionPlan.d.ts +0 -2887
- package/indexerMaterialAnswerFlow.d.ts +0 -63
- package/indexerMaterialAnswerLayout.d.ts +0 -76
- package/indexerMaterialAnswerReview.d.ts +0 -217
- package/indexerMaterialAnswerReviewRoute.d.ts +0 -6145
- package/indexerMaterialAnswerRunLedger.d.ts +0 -918
- package/indexerMaterialAnswerRunProtocol.d.ts +0 -1253
- package/indexerMaterialQuestionExclusion.d.ts +0 -129
- package/indexerMaterialQuestionWorkset.d.ts +0 -508
- package/indexerPlannedMaterialAnswer.d.ts +0 -116
- package/indexerProfileMetricAudit.d.ts +0 -218
- package/indexerWorksetRead.d.ts +0 -287
package/docs/getting-started.md
CHANGED
|
@@ -1,470 +1,115 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Getting Started
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
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
|
|
10
|
+
context init ./context
|
|
11
|
+
cd ./context
|
|
118
12
|
```
|
|
119
13
|
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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("
|
|
38
|
+
const docs = source("product-docs", { type: "file" });
|
|
240
39
|
|
|
241
40
|
export default defineProject({
|
|
242
41
|
sources: [docs],
|
|
243
|
-
phases: [
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
56
|
+
## 4. Let the lifecycle prepare Indexers
|
|
351
57
|
|
|
352
|
-
|
|
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
|
-
|
|
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
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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
|
-
|
|
373
|
-
|
|
374
|
-
declare it with `kbPackage()`.
|
|
75
|
+
Do not manually create a second extraction or Markdown pipeline in
|
|
76
|
+
`src/index.ts`.
|
|
375
77
|
|
|
376
|
-
|
|
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
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
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
|
-
|
|
391
|
-
|
|
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
|
-
|
|
88
|
+
After approval, `close` writes the accepted pages under readable paths such as:
|
|
398
89
|
|
|
399
90
|
```text
|
|
400
|
-
|
|
401
|
-
|
|
91
|
+
knowledge/codeindex/component-lib/button.md
|
|
92
|
+
knowledge/architecture/product-docs/component-contract.md
|
|
402
93
|
```
|
|
403
94
|
|
|
404
|
-
|
|
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
|
-
|
|
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
|
-
|
|
419
|
-
|
|
420
|
-
|
|
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
|
-
|
|
428
|
-
|
|
429
|
-
|
|
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
|
-
|
|
107
|
+
## Troubleshooting boundary
|
|
468
108
|
|
|
469
|
-
|
|
470
|
-
|
|
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.
|