@c4a/context 0.7.1 → 0.7.5
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 +67 -171
- package/README.zh-CN.md +53 -130
- 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 +104 -518
- package/docs/guides/code-indexer-skill-authoring.md +38 -13
- package/docs/guides/indexer-provider-and-customization.md +32 -20
- package/docs/guides/markdown-indexer-skill-authoring.md +22 -13
- 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 +13132 -15249
- package/indexerAgentStepProtocol.d.ts +1326 -8429
- package/indexerArtifact.d.ts +225 -0
- package/indexerArtifactDependencies.d.ts +43 -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/indexerCompositionFactDependencies.d.ts +16 -0
- 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 +142 -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 +5794 -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/README.md
CHANGED
|
@@ -2,206 +2,107 @@
|
|
|
2
2
|
|
|
3
3
|
[简体中文](./README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
`@c4a/context` is the declarative
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
built.
|
|
5
|
+
`@c4a/context` is the declarative SDK used by a Context knowledge workspace.
|
|
6
|
+
Most users work through the Context Agent and CLI; project authors use this
|
|
7
|
+
package to declare source capture and package output.
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
for knowledge-project authors, Agent maintainers, and developers who need to
|
|
14
|
-
understand that project declaration.
|
|
9
|
+
Knowledge authoring has one path: `src/indexers.yaml` selects Indexer Providers
|
|
10
|
+
and owns requirements, profiles, scopes, and customization. Code and Markdown
|
|
11
|
+
knowledge are not produced by project phases in `src/index.ts`.
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
state, execute an Agent, or build packages by itself. Those operations belong
|
|
18
|
-
to the [Context workflow runtime](../context-cli/README.md).
|
|
19
|
-
|
|
20
|
-
## Place in the knowledge workflow
|
|
13
|
+
## Project boundary
|
|
21
14
|
|
|
22
15
|
```text
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
approved knowledge → package output
|
|
16
|
+
sources/*/index.yaml registered source boundaries
|
|
17
|
+
src/index.ts capture and package declarations
|
|
18
|
+
src/indexers.yaml knowledge-authoring authority
|
|
19
|
+
knowledge/ approved, human-readable knowledge
|
|
20
|
+
dist/ reader-facing package output
|
|
21
|
+
.tmp/context-runtime/ recoverable runtime state (not committed)
|
|
30
22
|
```
|
|
31
23
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
- Which registered source boundaries may contribute evidence?
|
|
35
|
-
- Which capture, extraction, alignment, compilation, and review phases exist?
|
|
36
|
-
- Which approved collections belong in each output?
|
|
37
|
-
- Which templates and asset-delivery policies shape the built package?
|
|
24
|
+
`src/index.ts` may declare:
|
|
38
25
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
- `source()` / `allSources()` references;
|
|
27
|
+
- `captureFile()` and `captureLark()` snapshot phases;
|
|
28
|
+
- `customPhase()` for project orchestration that does not publish knowledge;
|
|
29
|
+
- `kbPackage()` and `llmsPackage()` output definitions.
|
|
42
30
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
A Context project follows a sources-to-phases-to-packages model:
|
|
31
|
+
Example:
|
|
46
32
|
|
|
47
33
|
```ts
|
|
48
34
|
import {
|
|
35
|
+
captureFile,
|
|
49
36
|
defineProject,
|
|
50
|
-
extractTs,
|
|
51
37
|
kbPackage,
|
|
52
|
-
reviewValidity,
|
|
53
38
|
source,
|
|
54
39
|
} from "@c4a/context";
|
|
55
40
|
|
|
56
|
-
const
|
|
41
|
+
const docs = source("product-docs", { type: "file" });
|
|
57
42
|
|
|
58
43
|
export default defineProject({
|
|
59
|
-
sources: [
|
|
60
|
-
phases: [
|
|
61
|
-
extractTs({ source: sampleLib, collection: "codeindex" }),
|
|
62
|
-
reviewValidity({ collection: "codeindex" }),
|
|
63
|
-
],
|
|
44
|
+
sources: [docs],
|
|
45
|
+
phases: [captureFile({ source: docs })],
|
|
64
46
|
packages: [
|
|
65
47
|
kbPackage({
|
|
66
|
-
name: "
|
|
67
|
-
template:
|
|
68
|
-
|
|
69
|
-
vars: { displayName: "Sample Library KB" },
|
|
70
|
-
},
|
|
71
|
-
select: { collections: ["codeindex"], okfRoots: ["wikis"] },
|
|
48
|
+
name: "product-kb",
|
|
49
|
+
template: "src/package-templates/kb",
|
|
50
|
+
select: { collections: ["product", "architecture"] },
|
|
72
51
|
}),
|
|
73
52
|
],
|
|
74
53
|
});
|
|
75
54
|
```
|
|
76
55
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
56
|
+
The Context lifecycle discovers or updates `src/indexers.yaml`, runs the
|
|
57
|
+
selected Provider in bounded batches of independently recoverable semantic
|
|
58
|
+
tasks, presents readable Candidate pages for Review, writes only approved
|
|
59
|
+
knowledge, and then builds declared packages. Batch keys and runtime timing
|
|
60
|
+
never enter knowledge identity or package output.
|
|
82
61
|
|
|
83
|
-
## Public
|
|
62
|
+
## Public surface
|
|
84
63
|
|
|
85
64
|
| API | Purpose |
|
|
86
65
|
|---|---|
|
|
87
|
-
| `defineProject()` | Declares the
|
|
88
|
-
| `source()`
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
94
|
-
| `kbPackage()` | Builds an Agent knowledge-base package from approved knowledge and templates. |
|
|
95
|
-
| `llmsPackage()` | Builds a single text bundle for model context or RAG import. |
|
|
96
|
-
|
|
97
|
-
Use `extractCustom()` when a repository needs a non-TypeScript or aggregated
|
|
98
|
-
code extractor. Use `customPhase()` only for orchestration that does not publish
|
|
99
|
-
knowledge candidates; it is not a replacement for source, extraction, Review,
|
|
100
|
-
and package lifecycle rules.
|
|
101
|
-
|
|
102
|
-
Context CLI intentionally does not bundle every language or repository parser.
|
|
103
|
-
Optional structural libraries can be installed by the knowledge project and
|
|
104
|
-
used inside `extractCustom()`:
|
|
105
|
-
|
|
106
|
-
| Package | Structural facts |
|
|
107
|
-
|---|---|
|
|
108
|
-
| `@c4a/extract-go` | Go declarations, imports, calls, and common HTTP route registrations |
|
|
109
|
-
| `@c4a/extract-rush` | Rush projects, tags, entry signals, workspace dependencies, and owner boundaries |
|
|
110
|
-
| `@c4a/extract-ts` | TypeScript extraction plus reusable React Router route facts |
|
|
111
|
-
|
|
112
|
-
These libraries do not create Context phases or candidates by themselves. The
|
|
113
|
-
project maps their deterministic facts to its own candidate identities and
|
|
114
|
-
review summaries; Context continues to own evidence validation, freshness,
|
|
115
|
-
Review, close, and package output.
|
|
116
|
-
|
|
117
|
-
## Knowledge Collections
|
|
118
|
-
|
|
119
|
-
Approved Markdown is organized under `knowledge/<collection>/`:
|
|
120
|
-
|
|
121
|
-
| Collection | What it contains | Typical sources |
|
|
122
|
-
|---|---|---|
|
|
123
|
-
| `codeindex` | Code symbols, modules, and relationships | Code repositories |
|
|
124
|
-
| `business` | Business concepts, roles, and relationships | Business and Lark documents |
|
|
125
|
-
| `product` | Product capabilities and behavior | Product and requirement documents |
|
|
126
|
-
| `architecture` | System structure and design explanations | Architecture and design documents |
|
|
127
|
-
| `sop` | Procedures, runbooks, and operational steps | Handbooks and operation documents |
|
|
128
|
-
| `faq` | Common questions and troubleshooting | FAQs, support documents, experience notes |
|
|
129
|
-
| `decision` | Decisions, alternatives, and trade-offs | Design reviews and decision records |
|
|
130
|
-
| `incident` | Incident timelines, response, and follow-up | Incident reports and retrospectives |
|
|
131
|
-
| `standards` | Normative rules and constraints | Engineering standards and business rules |
|
|
132
|
-
| `test` | Validation rules, scenarios, and acceptance criteria | Test plans and acceptance documents |
|
|
133
|
-
| `feats` | Capability records for a specific use case | Custom project workflows and approved knowledge |
|
|
134
|
-
|
|
135
|
-
Collections are semantic classifications, not final package directories.
|
|
136
|
-
Package build maps selected collections into OKF roots such as `wikis/`,
|
|
137
|
-
`guides/`, `rules/`, and `feats/`. One source may contribute to several
|
|
138
|
-
collections; classification should be based on evidence and user confirmation,
|
|
139
|
-
not filenames.
|
|
140
|
-
|
|
141
|
-
## Package Templates
|
|
142
|
-
|
|
143
|
-
Package declarations point at editable templates under
|
|
144
|
-
`src/package-templates/`. Installed examples are available at:
|
|
66
|
+
| `defineProject()` | Declares the project boundary. |
|
|
67
|
+
| `source()` / `allSources()` | References registered repo, file, or Lark sources. |
|
|
68
|
+
| `captureFile()` / `captureLark()` | Creates deterministic document snapshots. |
|
|
69
|
+
| `mdxJsonDocs()` | Configures the MDX/JSON documentation capture processor. |
|
|
70
|
+
| `customPhase()` | Runs non-knowledge project orchestration. |
|
|
71
|
+
| `kbPackage()` | Builds an Agent-readable knowledge package. |
|
|
72
|
+
| `llmsPackage()` | Builds a text bundle for model or retrieval input. |
|
|
145
73
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
74
|
+
The package also exports the Indexer schemas and validators used by Provider
|
|
75
|
+
authors and the Context runtime. Those APIs describe the same
|
|
76
|
+
`src/indexers.yaml` lifecycle; they are not a second user workflow.
|
|
149
77
|
|
|
150
|
-
|
|
78
|
+
Parser packages such as `@c4a/extract-ts`, `@c4a/extract-go`, and
|
|
79
|
+
`@c4a/extract-rush` are implementation dependencies of Indexer Providers. A
|
|
80
|
+
workspace does not wrap them in project phases.
|
|
81
|
+
|
|
82
|
+
## Knowledge and package output
|
|
83
|
+
|
|
84
|
+
Approved pages live under `knowledge/<collection>/`. Paths and filenames are
|
|
85
|
+
reader-oriented, for example:
|
|
151
86
|
|
|
152
87
|
```text
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|-- skills/
|
|
156
|
-
| `-- knowledge-query/SKILL.md
|
|
157
|
-
`-- wikis/index.md
|
|
88
|
+
knowledge/codeindex/ui-kit/avatar.md
|
|
89
|
+
knowledge/architecture/product-guides/component-input-fields.md
|
|
158
90
|
```
|
|
159
91
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
remain author-maintained and independent.
|
|
175
|
-
|
|
176
|
-
New KB setup should offer `assets: { delivery: "git-raw" }` first. Build
|
|
177
|
-
rewrites resource links to Git raw URLs; committing and publishing the resource
|
|
178
|
-
files remains the package author's responsibility. Non-Git workspaces may use
|
|
179
|
-
an explicit `urlPrefix`; without one they can bundle resources or explicitly
|
|
180
|
-
omit them and retain unresolved references. Bundled delivery may
|
|
181
|
-
install `sharp` in the workspace and configure `assets.optimize`; Context
|
|
182
|
-
itself has no image dependency and never changes source snapshots or approved
|
|
183
|
-
resources.
|
|
184
|
-
|
|
185
|
-
For advanced routing and retrieval, a template may carry a local script such as
|
|
186
|
-
`query.ts`, with a Skill describing when and how an Agent should call it. The
|
|
187
|
-
Skill can also route the Agent to MCP servers, CLI commands, or other tools to
|
|
188
|
-
form a package-specific Agentic Search workflow.
|
|
189
|
-
|
|
190
|
-
Long-lived, multi-source production workspaces can copy
|
|
191
|
-
`templates/project-skills/maintain-project-knowledge/SKILL.md` into their
|
|
192
|
-
`.agents/skills/` directory and customize it with project ownership, source
|
|
193
|
-
impact mappings, and readiness criteria. This project adapter is not included
|
|
194
|
-
in knowledge packages; lifecycle authority remains with the installed Context
|
|
195
|
-
Skill and current Route.
|
|
196
|
-
|
|
197
|
-
## State Boundary
|
|
198
|
-
|
|
199
|
-
The SDK stays declarative. It may describe reads, writes, phases, review, and
|
|
200
|
-
package selection, but the CLI owns source materialization, capture, extraction,
|
|
201
|
-
review application, approved Markdown materialization, verification, and build.
|
|
202
|
-
Do not replace CLI lifecycle operations with direct edits to `sources/`,
|
|
203
|
-
`knowledge/`, `dist/`, or the ignored `.tmp/context-runtime/lifecycle/` runtime
|
|
204
|
-
state. The CLI owns that runtime state and removes it after a successful close.
|
|
92
|
+
Workspace pages keep only metadata required to rebuild or update knowledge.
|
|
93
|
+
Package pages in `dist/` contain the smaller reader projection: useful title,
|
|
94
|
+
kind, summary/tags when present, and content. Internal evidence identities and
|
|
95
|
+
digests stay in runtime artifacts unless recovery requires them.
|
|
96
|
+
|
|
97
|
+
Package templates live under `src/package-templates/`; installed examples are
|
|
98
|
+
available from `node_modules/@c4a/context/templates/package-templates/`.
|
|
99
|
+
|
|
100
|
+
## State boundary
|
|
101
|
+
|
|
102
|
+
Do not directly edit lifecycle files under `.tmp/context-runtime/`. The CLI
|
|
103
|
+
owns Candidate state, Review application, recovery, close, verification, and
|
|
104
|
+
build. Source registries, `src/index.ts`, `src/indexers.yaml`, approved
|
|
105
|
+
`knowledge/`, and package templates are the durable project inputs.
|
|
205
106
|
|
|
206
107
|
## Documentation
|
|
207
108
|
|
|
@@ -209,11 +110,6 @@ state. The CLI owns that runtime state and removes it after a successful close.
|
|
|
209
110
|
- [Getting Started](./docs/getting-started.md)
|
|
210
111
|
- [Agent Guide](./docs/guides/agent-guide.md)
|
|
211
112
|
- [Project API](./docs/reference/project-api.md)
|
|
113
|
+
- [Indexer Provider Protocol](./docs/reference/indexer-provider-protocol.md)
|
|
212
114
|
- [Package Outputs](./docs/guides/package-outputs.md)
|
|
213
|
-
- [Lark Resource Materialization](./docs/guides/lark-resources.md)
|
|
214
115
|
- [Package Templates](./docs/reference/package-templates.md)
|
|
215
|
-
- [Template Variables](./docs/reference/template-variables.md)
|
|
216
|
-
|
|
217
|
-
The [documentation index](./docs/README.md) explains which references should be
|
|
218
|
-
read for each workflow decision. Agents should prefer Route-selected resources
|
|
219
|
-
over preloading every manual.
|
package/README.zh-CN.md
CHANGED
|
@@ -2,183 +2,106 @@
|
|
|
2
2
|
|
|
3
3
|
[English](./README.md)
|
|
4
4
|
|
|
5
|
-
`@c4a/context` 是 Context
|
|
6
|
-
|
|
7
|
-
产物。
|
|
5
|
+
`@c4a/context` 是 Context 知识工作区使用的声明式 SDK。多数用户通过 Context
|
|
6
|
+
Agent 和 CLI 工作;项目作者使用本包声明来源采集与知识包输出。
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
知识生产只有一条路径:`src/indexers.yaml` 选择 Indexer Provider,并管理需求、
|
|
9
|
+
Profile、范围和定制。`src/index.ts` 中的项目阶段不再负责生产代码或 Markdown
|
|
10
|
+
知识。
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
构建知识包。这些操作由 [Context 工作流运行时](../context-cli/README.zh-CN.md)
|
|
15
|
-
负责。
|
|
16
|
-
|
|
17
|
-
## 在知识生产工作流中的位置
|
|
12
|
+
## 项目边界
|
|
18
13
|
|
|
19
14
|
```text
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
正式知识 → 知识包产物
|
|
15
|
+
sources/*/index.yaml 已登记的来源边界
|
|
16
|
+
src/index.ts 采集与知识包声明
|
|
17
|
+
src/indexers.yaml 知识生产的唯一权威配置
|
|
18
|
+
knowledge/ 已批准、可读的知识
|
|
19
|
+
dist/ 面向读者的知识包产物
|
|
20
|
+
.tmp/context-runtime/ 可恢复运行态(不提交)
|
|
27
21
|
```
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
- 哪些已经登记的来源边界可以贡献证据?
|
|
32
|
-
- 存在哪些采集、提取、对齐、编译和审核阶段?
|
|
33
|
-
- 每种产物应该选择哪些正式知识分类?
|
|
34
|
-
- 哪些模板和资源分发策略决定最终包的结构?
|
|
35
|
-
|
|
36
|
-
它不记录当前进度。工作区事实和随包发布的 Workflow Provider 会在运行时选择下一
|
|
37
|
-
条 Route,因此 `src/index.ts` 是项目契约,不是第二套状态机。
|
|
23
|
+
`src/index.ts` 可以声明:
|
|
38
24
|
|
|
39
|
-
|
|
25
|
+
- `source()` / `allSources()` 来源引用;
|
|
26
|
+
- `captureFile()`、`captureLark()` 文档快照阶段;
|
|
27
|
+
- 不发布知识的 `customPhase()` 项目编排;
|
|
28
|
+
- `kbPackage()`、`llmsPackage()` 输出。
|
|
40
29
|
|
|
41
|
-
|
|
30
|
+
示例:
|
|
42
31
|
|
|
43
32
|
```ts
|
|
44
33
|
import {
|
|
34
|
+
captureFile,
|
|
45
35
|
defineProject,
|
|
46
|
-
extractTs,
|
|
47
36
|
kbPackage,
|
|
48
|
-
reviewValidity,
|
|
49
37
|
source,
|
|
50
38
|
} from "@c4a/context";
|
|
51
39
|
|
|
52
|
-
const
|
|
40
|
+
const docs = source("product-docs", { type: "file" });
|
|
53
41
|
|
|
54
42
|
export default defineProject({
|
|
55
|
-
sources: [
|
|
56
|
-
phases: [
|
|
57
|
-
extractTs({ source: sampleLib, collection: "codeindex" }),
|
|
58
|
-
reviewValidity({ collection: "codeindex" }),
|
|
59
|
-
],
|
|
43
|
+
sources: [docs],
|
|
44
|
+
phases: [captureFile({ source: docs })],
|
|
60
45
|
packages: [
|
|
61
46
|
kbPackage({
|
|
62
|
-
name: "
|
|
63
|
-
template:
|
|
64
|
-
|
|
65
|
-
vars: { displayName: "Sample Library KB" },
|
|
66
|
-
},
|
|
67
|
-
select: { collections: ["codeindex"], okfRoots: ["wikis"] },
|
|
47
|
+
name: "product-kb",
|
|
48
|
+
template: "src/package-templates/kb",
|
|
49
|
+
select: { collections: ["product", "architecture"] },
|
|
68
50
|
}),
|
|
69
51
|
],
|
|
70
52
|
});
|
|
71
53
|
```
|
|
72
54
|
|
|
73
|
-
`src/
|
|
74
|
-
|
|
75
|
-
|
|
55
|
+
Context 生命周期负责发现或更新 `src/indexers.yaml`,以有界批次运行彼此独立、可恢复
|
|
56
|
+
的语义任务,展示可读 Candidate 供审核,只写入批准后的知识,最后构建声明的知识包。
|
|
57
|
+
批次标识和运行耗时不会进入知识身份或知识包产物。
|
|
76
58
|
|
|
77
59
|
## 主要 API
|
|
78
60
|
|
|
79
61
|
| API | 用途 |
|
|
80
62
|
|---|---|
|
|
81
|
-
| `defineProject()` |
|
|
82
|
-
| `source()`
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `kbPackage()` | 使用审核通过的知识和模板构建 Agent 知识库。 |
|
|
89
|
-
| `llmsPackage()` | 构建供模型上下文或 RAG 导入使用的单文件文本包。 |
|
|
90
|
-
|
|
91
|
-
非 TypeScript 或需要聚合代码事实时使用 `extractCustom()`。`customPhase()`
|
|
92
|
-
只用于不发布知识候选的项目专用编排,不能绕开来源、提取、审核和打包生命周期。
|
|
93
|
-
|
|
94
|
-
Context CLI 不会把所有语言和仓库解析器都打入自身。知识项目可以按需安装结构
|
|
95
|
-
提取库,并在 `extractCustom()` 中使用:
|
|
96
|
-
|
|
97
|
-
| 包 | 提供的结构事实 |
|
|
98
|
-
|---|---|
|
|
99
|
-
| `@c4a/extract-go` | Go 声明、导入、调用和常见 HTTP 路由注册 |
|
|
100
|
-
| `@c4a/extract-rush` | Rush 项目、标签、入口信号、工作区依赖和所有者边界 |
|
|
101
|
-
| `@c4a/extract-ts` | TypeScript 提取,以及可复用的 React Router 路由事实 |
|
|
63
|
+
| `defineProject()` | 声明项目边界。 |
|
|
64
|
+
| `source()` / `allSources()` | 引用已登记的代码仓库、本地文件或飞书来源。 |
|
|
65
|
+
| `captureFile()` / `captureLark()` | 生成确定性的文档快照。 |
|
|
66
|
+
| `mdxJsonDocs()` | 配置 MDX/JSON 文档采集处理器。 |
|
|
67
|
+
| `customPhase()` | 执行不生产知识的项目编排。 |
|
|
68
|
+
| `kbPackage()` | 构建 Agent 可读的知识包。 |
|
|
69
|
+
| `llmsPackage()` | 构建供模型或检索使用的文本包。 |
|
|
102
70
|
|
|
103
|
-
|
|
104
|
-
|
|
71
|
+
本包也导出 Provider 作者和 Context 运行时使用的 Indexer Schema 与校验器。它们
|
|
72
|
+
描述的仍是同一套 `src/indexers.yaml` 生命周期,不是第二条用户流程。
|
|
105
73
|
|
|
106
|
-
|
|
74
|
+
`@c4a/extract-ts`、`@c4a/extract-go`、`@c4a/extract-rush` 等解析包属于
|
|
75
|
+
Indexer Provider 的实现依赖,工作区不再把它们包装成项目阶段。
|
|
107
76
|
|
|
108
|
-
|
|
77
|
+
## 知识与知识包
|
|
109
78
|
|
|
110
|
-
|
|
111
|
-
|---|---|---|
|
|
112
|
-
| `codeindex` | 代码符号、模块和调用关系 | 代码仓库 |
|
|
113
|
-
| `business` | 业务概念、角色和业务关系 | 业务文档、飞书文档 |
|
|
114
|
-
| `product` | 产品能力、功能行为和产品关系 | 产品文档、需求文档 |
|
|
115
|
-
| `architecture` | 系统结构、模块职责和设计说明 | 架构文档、设计文档 |
|
|
116
|
-
| `sop` | 操作流程、运行手册和处理步骤 | 操作手册、值班文档 |
|
|
117
|
-
| `faq` | 常见问题、解释和排障方法 | FAQ、支持文档、经验记录 |
|
|
118
|
-
| `decision` | 方案选择、取舍和决策背景 | 设计评审、决策记录 |
|
|
119
|
-
| `incident` | 故障过程、处置方式和后续行动 | 故障复盘、事故报告 |
|
|
120
|
-
| `standards` | 必须遵守的规范和约束 | 研发规范、业务规则 |
|
|
121
|
-
| `test` | 验证规则、测试场景和验收标准 | 测试文档、验收说明 |
|
|
122
|
-
| `feats` | 面向具体场景整理的能力记录 | 项目自定义处理和已确认知识 |
|
|
123
|
-
|
|
124
|
-
知识类型是语义分类,不是最终知识包目录。构建时会把选中的类型映射到 `wikis/`、`guides/`、`rules/`、`feats/` 等 OKF 目录。同一份来源可能贡献多种知识,分类应该依据证据和用户确认,而不是文件名。
|
|
125
|
-
|
|
126
|
-
## 知识包模板
|
|
127
|
-
|
|
128
|
-
知识包声明会引用 `src/package-templates/` 下的可编辑模板。安装后的示例位于:
|
|
79
|
+
批准后的知识位于 `knowledge/<collection>/`,目录和文件名面向人阅读,例如:
|
|
129
80
|
|
|
130
81
|
```text
|
|
131
|
-
|
|
82
|
+
knowledge/codeindex/ui-kit/avatar.md
|
|
83
|
+
knowledge/architecture/product-guides/component-input-fields.md
|
|
132
84
|
```
|
|
133
85
|
|
|
134
|
-
|
|
86
|
+
工作区页面只保留后续重建或更新所需的元数据。`dist/` 中的知识包页面使用更小的
|
|
87
|
+
读者投影:有用的标题、类型、摘要/标签(存在时)和正文。内部证据 ID 与摘要除非
|
|
88
|
+
恢复需要,否则只留在运行时 Artifact 中。
|
|
135
89
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|-- AGENTS.md
|
|
139
|
-
|-- skills/
|
|
140
|
-
| `-- knowledge-query/SKILL.md
|
|
141
|
-
`-- wikis/index.md
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
`knowledge-query` Skill 会告诉消费知识包的 Agent 如何浏览索引、读取审核通过的知识并引用证据。项目还可以增加更多 Skills,或者在 `wikis/`、`guides/`、`rules/` 等目录中加入模板文件。
|
|
145
|
-
|
|
146
|
-
模板使用 Handlebars 变量,可以作用于文件内容和路径。常用变量包括 `{{packageName}}`、`{{displayName}}`、`{{knowledgeCount}}`、`{{knowledgeGroups}}`、`{{knowledgeItems}}`、`{{knowledgeTree}}` 和 `{{buildInventory}}`。
|
|
147
|
-
|
|
148
|
-
每个 KB 包直接输出扁平的 `wikis/`、`guides/`、`rules/`、`feats/` 等根目录;包 `name`
|
|
149
|
-
只用于确定 `dist/<package-name>/` 边界,不会再次写入知识路径。旧工作区中的
|
|
150
|
-
`distribution.knowledgeNamespace` 仍可被读取,但不再改变构建结果;新声明无需配置它。
|
|
151
|
-
Skill 名称继续由作者独立维护。
|
|
152
|
-
|
|
153
|
-
新建 KB 时优先选择 `assets: { delivery: "git-raw" }`:构建器把资源链接改写到
|
|
154
|
-
Git raw 地址;资源的提交和发布由知识包作者负责,Context 不做远端探测。
|
|
155
|
-
非 Git 工作区也可以配置显式 `urlPrefix`,引用另一个仓库已经发布的资源;没有
|
|
156
|
-
可用 Git 或显式前缀时,可选择 `delivery: "bundle"` 随包分发,或显式选择
|
|
157
|
-
`delivery: "omit"` 不输出资源并保留失效引用。随包分发还可以在工作区安装 `sharp` 并通过
|
|
158
|
-
`assets.optimize` 仅优化生成的知识包;Context 本身不依赖图片处理库。
|
|
159
|
-
|
|
160
|
-
如果需要更强的路由和检索能力,模板可以携带 `query.ts` 一类本地脚本,再由 Skill 约定 Agent 何时、如何调用。Skill 也可以把 Agent 路由到 MCP、CLI 或其他工具,组成适合当前知识包的 Agentic Search 流程。
|
|
161
|
-
|
|
162
|
-
长期维护、多来源的知识生产工作区可以从
|
|
163
|
-
`templates/project-skills.zh-CN/maintain-project-knowledge/SKILL.md` 复制一份
|
|
164
|
-
项目维护 Skill 到 `.agents/skills/`。它不进入知识包,而是补充项目专属的来源
|
|
165
|
-
归属、仓库变化影响范围和准出标准;Context 生命周期仍由已安装的 Context Skill
|
|
166
|
-
和当前 Route 负责。
|
|
90
|
+
知识包模板位于 `src/package-templates/`;安装后的示例位于
|
|
91
|
+
`node_modules/@c4a/context/templates/package-templates/`。
|
|
167
92
|
|
|
168
93
|
## 状态边界
|
|
169
94
|
|
|
170
|
-
|
|
95
|
+
不要直接修改 `.tmp/context-runtime/` 下的生命周期文件。Candidate 状态、审核应用、
|
|
96
|
+
恢复、close、验证与构建由 CLI 管理。来源注册表、`src/index.ts`、
|
|
97
|
+
`src/indexers.yaml`、批准后的 `knowledge/` 和知识包模板才是长期项目输入。
|
|
171
98
|
|
|
172
99
|
## 参考文档
|
|
173
100
|
|
|
174
|
-
- [文档索引](./docs/README.md)
|
|
101
|
+
- [文档索引](./docs/README.zh-CN.md)
|
|
175
102
|
- [快速开始](./docs/getting-started.md)
|
|
176
103
|
- [Agent 指南](./docs/guides/agent-guide.md)
|
|
177
104
|
- [项目 API](./docs/reference/project-api.md)
|
|
105
|
+
- [Indexer Provider 协议](./docs/reference/indexer-provider-protocol.md)
|
|
178
106
|
- [知识包输出](./docs/guides/package-outputs.md)
|
|
179
|
-
- [飞书资源物化](./docs/guides/lark-resources.md)
|
|
180
107
|
- [知识包模板](./docs/reference/package-templates.md)
|
|
181
|
-
- [模板变量](./docs/reference/template-variables.md)
|
|
182
|
-
|
|
183
|
-
[文档索引](./docs/README.zh-CN.md)说明每类工作流决策应该查看哪些参考资料。Agent
|
|
184
|
-
应优先读取 Route 选择的资源,不要预加载整套手册。
|
package/docs/README.md
CHANGED
|
@@ -8,8 +8,8 @@ These docs ship inside the installed SDK package at:
|
|
|
8
8
|
node_modules/@c4a/context/docs/
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
These manuals explain how a knowledge project declares sources,
|
|
12
|
-
|
|
11
|
+
These manuals explain how a knowledge project declares sources, capture,
|
|
12
|
+
Indexer selection, Review, and package output. They are references inside the larger Agent-driven
|
|
13
13
|
workflow, not a second set of lifecycle instructions.
|
|
14
14
|
|
|
15
15
|
For active knowledge production, start through the installed Context Agent
|
|
@@ -24,7 +24,7 @@ preload the whole manual set.
|
|
|
24
24
|
|---|---|
|
|
25
25
|
| Understand the whole knowledge-project shape | [Getting Started](./getting-started.md) |
|
|
26
26
|
| Know what the Agent may decide or change | [Agent Guide](./guides/agent-guide.md) and [Agent Dialogue](./guides/agent-dialogue.md) |
|
|
27
|
-
| Configure sources,
|
|
27
|
+
| Configure sources, capture, Indexers, or packages | [Project API](./reference/project-api.md) |
|
|
28
28
|
| Author or inspect an Indexer Provider protocol | [Indexer Provider Protocol](./reference/indexer-provider-protocol.md) |
|
|
29
29
|
| Select or customize an Indexer Provider | [Provider Selection and Customization](./guides/indexer-provider-and-customization.md) |
|
|
30
30
|
| Author a Code or Markdown Indexer Skill | [Code Indexer Authoring](./guides/code-indexer-skill-authoring.md) and [Markdown Indexer Authoring](./guides/markdown-indexer-skill-authoring.md) |
|
|
@@ -40,7 +40,7 @@ preload the whole manual set.
|
|
|
40
40
|
- [Agent Dialogue](./guides/agent-dialogue.md) — stable dialogue principles and how route-selected gate resources are discovered.
|
|
41
41
|
- [Package Outputs](./guides/package-outputs.md) — how to choose between an agent knowledge-base package, LLM text, or no package output.
|
|
42
42
|
- [Lark Resource Materialization](./guides/lark-resources.md) — how embedded resources move from source evidence to approved knowledge and package assets.
|
|
43
|
-
- [Project API](./reference/project-api.md) — `defineProject`, sources,
|
|
43
|
+
- [Project API](./reference/project-api.md) — `defineProject`, sources, capture, Indexers, and packages.
|
|
44
44
|
- [Indexer Provider Protocol](./reference/indexer-provider-protocol.md) — manifest, controlled execution, detector/inspector I/O, customization, and staged project apply.
|
|
45
45
|
- [Provider Selection and Customization](./guides/indexer-provider-and-customization.md) — registry-only selection, the six-level customization ladder, upgrade conflicts, debugging, and completion conditions.
|
|
46
46
|
- [Code Indexer Authoring](./guides/code-indexer-skill-authoring.md) — the 23-point Provider Skill release contract and anonymous fixture expectations.
|
|
@@ -49,12 +49,11 @@ preload the whole manual set.
|
|
|
49
49
|
- [Package Templates](./reference/package-templates.md) — `kbPackage`, `llmsPackage`, template variables, and examples.
|
|
50
50
|
- [Template Variables](./reference/template-variables.md) — Handlebars variables, loops, comments, and default knowledge inventories.
|
|
51
51
|
|
|
52
|
-
Approved Markdown
|
|
53
|
-
knowledge pages use
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
each distributed path back to its approved knowledge path. The kb package root may contain agent files; the
|
|
52
|
+
Approved Markdown keeps reader-facing content plus the minimum metadata needed
|
|
53
|
+
to update or rebuild it. Package knowledge pages use an even smaller consumer
|
|
54
|
+
projection. Internal evidence IDs, execution receipts, and transient Review
|
|
55
|
+
state stay in local runtime artifacts. The build inventory maps each distributed
|
|
56
|
+
path back to its approved knowledge path. The kb package root may contain agent files; the
|
|
58
57
|
OKF-compatible surface is its selected `wikis/`, `guides/`, `rules/`, and
|
|
59
58
|
`feats/` subtrees.
|
|
60
59
|
|
package/docs/README.zh-CN.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[English](./README.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
这些手册说明知识项目如何声明来源、采集、Indexer 选择、审核和知识包产物。它们是 Agent
|
|
6
6
|
驱动工作流中的参考资料,不是另一套生命周期指令。
|
|
7
7
|
|
|
8
8
|
进行知识生产时,应先从已安装的 Context Agent 入口开始。Agent 优先消费
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|---|---|
|
|
16
16
|
| 理解完整知识项目的形态 | [Getting Started](./getting-started.md) |
|
|
17
17
|
| 判断 Agent 可以决定或修改什么 | [Agent Guide](./guides/agent-guide.md) 和 [Agent Dialogue](./guides/agent-dialogue.md) |
|
|
18
|
-
|
|
|
18
|
+
| 配置来源、采集、Indexer 或产物 | [Project API](./reference/project-api.md) |
|
|
19
19
|
| 选择或定制 Indexer Provider | [Provider Selection and Customization](./guides/indexer-provider-and-customization.md) |
|
|
20
20
|
| 编写 Code/Markdown Indexer Skill | [Code Indexer Authoring](./guides/code-indexer-skill-authoring.md) 和 [Markdown Indexer Authoring](./guides/markdown-indexer-skill-authoring.md) |
|
|
21
21
|
| 选择代码提取方式 | [Code Extractor Selection](./reference/code-extractors.md) |
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
- [Agent Dialogue](./guides/agent-dialogue.md):稳定的对话原则和 Route-selected Gate 资源发现方式。
|
|
31
31
|
- [Package Outputs](./guides/package-outputs.md):如何选择 Agent 知识包、LLM 文本或不构建产物。
|
|
32
32
|
- [Lark Resource Materialization](./guides/lark-resources.md):内嵌资源如何从来源证据进入正式知识和知识包。
|
|
33
|
-
- [Project API](./reference/project-api.md):`defineProject
|
|
33
|
+
- [Project API](./reference/project-api.md):`defineProject`、来源、采集、Indexer 和知识包声明。
|
|
34
34
|
- [Provider Selection and Customization](./guides/indexer-provider-and-customization.md):registry-only 选择、六级最小定制阶梯、升级冲突、调试与退出条件。
|
|
35
35
|
- [Code Indexer Authoring](./guides/code-indexer-skill-authoring.md):Code Provider Skill 的 23 项作者/发布契约。
|
|
36
36
|
- [Markdown Indexer Authoring](./guides/markdown-indexer-skill-authoring.md):capture/semantic 边界、Section 投影、material answer、编辑策略与局部增量。
|
|
@@ -38,10 +38,9 @@
|
|
|
38
38
|
- [Package Templates](./reference/package-templates.md):`kbPackage`、`llmsPackage`、模板变量和示例。
|
|
39
39
|
- [Template Variables](./reference/template-variables.md):Handlebars 变量、循环、注释和默认知识清单。
|
|
40
40
|
|
|
41
|
-
正式 Markdown
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
将每个分发路径映射回正式知识路径。知识包根目录可以包含 Agent 文件;可交换知识
|
|
41
|
+
正式 Markdown 保留面向读者的内容和后续更新、重建所需的最少元数据。知识包内的
|
|
42
|
+
知识页使用更小的读者投影;内部证据 ID、执行回执和临时审核状态只留在本地运行态。
|
|
43
|
+
构建清单将每个分发路径映射回正式知识路径。知识包根目录可以包含 Agent 文件;可交换知识
|
|
45
44
|
位于所选的 `wikis/`、`guides/`、`rules/` 和 `feats/` 子树。
|
|
46
45
|
|
|
47
46
|
## 已安装模板
|