@c4a/context 0.6.17 → 0.6.19
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 +5 -5
- package/README.zh-CN.md +5 -5
- package/codeIndexPlan.d.ts +50 -0
- package/contracts.d.ts +2 -1
- package/docs/getting-started.md +12 -12
- package/docs/guides/agent-guide.md +18 -9
- package/docs/guides/lark-resources.md +7 -0
- package/docs/guides/package-outputs.md +3 -3
- package/docs/reference/code-extractors.md +5 -4
- package/docs/reference/package-templates.md +18 -10
- package/docs/reference/project-api.md +56 -24
- package/index.d.ts +2 -2
- package/index.js +12 -8
- package/package.json +1 -1
- package/phases.d.ts +11 -9
- package/templates/package-templates/kb/AGENTS.md +1 -1
- package/templates/package-templates/kb/skills/knowledge-query/SKILL.md +1 -1
- package/templates/package-templates.zh-CN/kb/AGENTS.md +1 -1
- package/templates/package-templates.zh-CN/kb/skills/knowledge-query/SKILL.md +1 -1
package/README.md
CHANGED
|
@@ -58,8 +58,8 @@ const sampleLib = source("20260712", "sample-lib");
|
|
|
58
58
|
export default defineProject({
|
|
59
59
|
sources: [sampleLib],
|
|
60
60
|
phases: [
|
|
61
|
-
extractTs({ source: sampleLib, collection: "
|
|
62
|
-
reviewValidity({ collection: "
|
|
61
|
+
extractTs({ source: sampleLib, collection: "codeindex" }),
|
|
62
|
+
reviewValidity({ collection: "codeindex" }),
|
|
63
63
|
],
|
|
64
64
|
packages: [
|
|
65
65
|
kbPackage({
|
|
@@ -68,7 +68,7 @@ export default defineProject({
|
|
|
68
68
|
path: "src/package-templates/kb",
|
|
69
69
|
vars: { displayName: "Sample Library KB" },
|
|
70
70
|
},
|
|
71
|
-
select: { collections: ["
|
|
71
|
+
select: { collections: ["codeindex"], okfRoots: ["wikis"] },
|
|
72
72
|
}),
|
|
73
73
|
],
|
|
74
74
|
});
|
|
@@ -86,7 +86,7 @@ maintain this declaration from the user's requirements.
|
|
|
86
86
|
|---|---|
|
|
87
87
|
| `defineProject()` | Declares the complete project graph. |
|
|
88
88
|
| `source()` and `allSources()` | References registered repo, file, or Lark source boundaries. |
|
|
89
|
-
| `extractTs()` | Extracts TypeScript/TSX symbols and relationships into `
|
|
89
|
+
| `extractTs()` | Extracts TypeScript/TSX symbols and relationships into `codeindex` candidates. |
|
|
90
90
|
| `extractCustom()` | Runs a project-owned code extractor while Context owns candidate, evidence, freshness, and Review state. |
|
|
91
91
|
| `alignProse()` and `compileProse()` | Structures document evidence and compiles source-bound knowledge candidates. |
|
|
92
92
|
| `reviewValidity()` | Declares the review gate for one collection or the project. |
|
|
@@ -120,7 +120,7 @@ Approved Markdown is organized under `knowledge/<collection>/`:
|
|
|
120
120
|
|
|
121
121
|
| Collection | What it contains | Typical sources |
|
|
122
122
|
|---|---|---|
|
|
123
|
-
| `
|
|
123
|
+
| `codeindex` | Code symbols, modules, and relationships | Code repositories |
|
|
124
124
|
| `business` | Business concepts, roles, and relationships | Business and Lark documents |
|
|
125
125
|
| `product` | Product capabilities and behavior | Product and requirement documents |
|
|
126
126
|
| `architecture` | System structure and design explanations | Architecture and design documents |
|
package/README.zh-CN.md
CHANGED
|
@@ -54,8 +54,8 @@ const sampleLib = source("20260712", "sample-lib");
|
|
|
54
54
|
export default defineProject({
|
|
55
55
|
sources: [sampleLib],
|
|
56
56
|
phases: [
|
|
57
|
-
extractTs({ source: sampleLib, collection: "
|
|
58
|
-
reviewValidity({ collection: "
|
|
57
|
+
extractTs({ source: sampleLib, collection: "codeindex" }),
|
|
58
|
+
reviewValidity({ collection: "codeindex" }),
|
|
59
59
|
],
|
|
60
60
|
packages: [
|
|
61
61
|
kbPackage({
|
|
@@ -64,7 +64,7 @@ export default defineProject({
|
|
|
64
64
|
path: "src/package-templates/kb",
|
|
65
65
|
vars: { displayName: "Sample Library KB" },
|
|
66
66
|
},
|
|
67
|
-
select: { collections: ["
|
|
67
|
+
select: { collections: ["codeindex"], okfRoots: ["wikis"] },
|
|
68
68
|
}),
|
|
69
69
|
],
|
|
70
70
|
});
|
|
@@ -80,7 +80,7 @@ Route 会按需选择维护这份声明所需的操作说明、Schema 和手册
|
|
|
80
80
|
|---|---|
|
|
81
81
|
| `defineProject()` | 声明完整的项目处理图。 |
|
|
82
82
|
| `source()` 和 `allSources()` | 引用已经登记的代码仓库、本地文件或飞书来源边界。 |
|
|
83
|
-
| `extractTs()` | 从 TypeScript/TSX 中提取符号和关系,生成 `
|
|
83
|
+
| `extractTs()` | 从 TypeScript/TSX 中提取符号和关系,生成 `codeindex` 候选。 |
|
|
84
84
|
| `extractCustom()` | 运行项目自有代码提取器,同时由 Context 维护候选、证据、新鲜度和审核状态。 |
|
|
85
85
|
| `alignProse()` 和 `compileProse()` | 整理文档证据,并生成与来源绑定的知识候选。 |
|
|
86
86
|
| `reviewValidity()` | 声明单个知识类型或整个项目的审核门禁。 |
|
|
@@ -109,7 +109,7 @@ Context CLI 不会把所有语言和仓库解析器都打入自身。知识项
|
|
|
109
109
|
|
|
110
110
|
| 知识类型 | 主要内容 | 常见来源 |
|
|
111
111
|
|---|---|---|
|
|
112
|
-
| `
|
|
112
|
+
| `codeindex` | 代码符号、模块和调用关系 | 代码仓库 |
|
|
113
113
|
| `business` | 业务概念、角色和业务关系 | 业务文档、飞书文档 |
|
|
114
114
|
| `product` | 产品能力、功能行为和产品关系 | 产品文档、需求文档 |
|
|
115
115
|
| `architecture` | 系统结构、模块职责和设计说明 | 架构文档、设计文档 |
|
package/codeIndexPlan.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export interface CodeIndexUnitPlan {
|
|
|
27
27
|
facets?: readonly CodeIndexModuleFacet[];
|
|
28
28
|
/** Source-backed reasons for the selected module type. */
|
|
29
29
|
moduleTypeEvidence?: readonly string[];
|
|
30
|
+
/** Source-relative Markdown documents read while classifying this index unit. */
|
|
31
|
+
documents?: readonly string[];
|
|
30
32
|
outputProfile: CodeIndexOutputProfile;
|
|
31
33
|
responsibility: string;
|
|
32
34
|
entries: readonly string[];
|
|
@@ -51,9 +53,57 @@ export interface CodeIndexCapabilityGap {
|
|
|
51
53
|
reason: string;
|
|
52
54
|
requestedMaterial?: string;
|
|
53
55
|
}
|
|
56
|
+
/** Complete source inventory returned by a project adapter for mechanical quality scoring. */
|
|
57
|
+
export interface CodeIndexInspectionInventory {
|
|
58
|
+
indexUnitId: string;
|
|
59
|
+
eligibleFiles: number;
|
|
60
|
+
analyzedFiles: number;
|
|
61
|
+
/** Complete eligible source identities used as the file denominator. */
|
|
62
|
+
eligibleFileTargets: readonly string[];
|
|
63
|
+
/** Complete source identities successfully analyzed by the adapter. */
|
|
64
|
+
analyzedFileTargets: readonly string[];
|
|
65
|
+
eligibleLoc: number;
|
|
66
|
+
analyzedLoc: number;
|
|
67
|
+
documentsDiscovered: number;
|
|
68
|
+
documentsRead: number;
|
|
69
|
+
/** Discovered Markdown identities, relative to the registered source root. */
|
|
70
|
+
documentTargets?: readonly string[];
|
|
71
|
+
/** Root README or documentation entry identities that require complete reading. */
|
|
72
|
+
rootDocumentTargets?: readonly string[];
|
|
73
|
+
/** Discovered document identities read during module classification. */
|
|
74
|
+
readDocumentTargets?: readonly string[];
|
|
75
|
+
/** Documents already referenced by emitted knowledge candidates. */
|
|
76
|
+
referencedDocumentTargets?: readonly string[];
|
|
77
|
+
symbolsDiscovered: number;
|
|
78
|
+
symbolsAnalyzed: number;
|
|
79
|
+
targetSymbols: number;
|
|
80
|
+
exportedSymbols: number;
|
|
81
|
+
/** Stable target identities, normally exported or profile-selected symbol names. */
|
|
82
|
+
targetSymbolIdentities: readonly string[];
|
|
83
|
+
/** Public export identities that must remain discoverable. */
|
|
84
|
+
exportedTargetIdentities: readonly string[];
|
|
85
|
+
entryTargets: readonly string[];
|
|
86
|
+
protocolTargets: readonly string[];
|
|
87
|
+
boundaryTargets?: readonly {
|
|
88
|
+
kind: "entry" | "export" | "route" | "operation" | "handler" | "downstream" | "command" | "event" | "plugin" | "handoff";
|
|
89
|
+
identity: string;
|
|
90
|
+
}[];
|
|
91
|
+
coveredBoundaryTargets?: readonly {
|
|
92
|
+
kind: "entry" | "export" | "route" | "operation" | "handler" | "downstream" | "command" | "event" | "plugin" | "handoff";
|
|
93
|
+
identity: string;
|
|
94
|
+
}[];
|
|
95
|
+
excludedFiles: number;
|
|
96
|
+
/** Complete identities deliberately excluded after discovery. */
|
|
97
|
+
excludedFileTargets: readonly string[];
|
|
98
|
+
excludedReasons: readonly string[];
|
|
99
|
+
parserSkippedFiles: number;
|
|
100
|
+
/** Complete eligible identities that the parser could not analyze. */
|
|
101
|
+
parserSkippedFileTargets: readonly string[];
|
|
102
|
+
}
|
|
54
103
|
export interface CodeIndexInspectionResult {
|
|
55
104
|
findings: readonly CodeIndexInspectionFinding[];
|
|
56
105
|
capabilityGaps?: readonly CodeIndexCapabilityGap[];
|
|
106
|
+
inventories?: readonly CodeIndexInspectionInventory[];
|
|
57
107
|
}
|
|
58
108
|
export interface CodeIndexInspectionContext {
|
|
59
109
|
projectRoot: string;
|
package/contracts.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type DocumentMainlineCollection = "business" | "product" | "architecture" | "sop" | "faq" | "standards" | "decision" | "incident" | "test";
|
|
2
2
|
export type CodegraphCollection = "codegraph";
|
|
3
|
-
export type
|
|
3
|
+
export type CodeIndexCollection = "codeindex" | CodegraphCollection;
|
|
4
|
+
export type MainlineCollection = CodeIndexCollection | DocumentMainlineCollection;
|
|
4
5
|
export type TopLevelNamespace = MainlineCollection | "feats";
|
|
5
6
|
export type OkfRoot = "guides" | "rules" | "wikis" | "feats";
|
|
6
7
|
export type KnowledgeCollection = TopLevelNamespace;
|
package/docs/getting-started.md
CHANGED
|
@@ -186,8 +186,8 @@ For a monorepo or subspace, choose the boundary deliberately:
|
|
|
186
186
|
The long-term multi-module knowledge shape is stable across capture dates:
|
|
187
187
|
|
|
188
188
|
```text
|
|
189
|
-
knowledge/
|
|
190
|
-
knowledge/
|
|
189
|
+
knowledge/codeindex/module-a/...
|
|
190
|
+
knowledge/codeindex/module-b/...
|
|
191
191
|
```
|
|
192
192
|
|
|
193
193
|
The CLI records each module's git root and subpath, then materializes
|
|
@@ -274,8 +274,8 @@ const componentLib = source("20260712", "component-lib");
|
|
|
274
274
|
export default defineProject({
|
|
275
275
|
sources: [componentLib],
|
|
276
276
|
phases: [
|
|
277
|
-
extractTs({ source: componentLib, collection: "
|
|
278
|
-
reviewValidity({ collection: "
|
|
277
|
+
extractTs({ source: componentLib, collection: "codeindex" }),
|
|
278
|
+
reviewValidity({ collection: "codeindex" }),
|
|
279
279
|
],
|
|
280
280
|
packages: [],
|
|
281
281
|
});
|
|
@@ -285,8 +285,8 @@ Inspect and run:
|
|
|
285
285
|
|
|
286
286
|
```bash
|
|
287
287
|
context run --list
|
|
288
|
-
context run extract:20260712/component-lib:
|
|
289
|
-
context run extract:20260712/component-lib:
|
|
288
|
+
context run extract:20260712/component-lib:codeindex --dry-run
|
|
289
|
+
context run extract:20260712/component-lib:codeindex
|
|
290
290
|
```
|
|
291
291
|
|
|
292
292
|
When operating through an Agent, use `--dry-run --format json` as the CLI
|
|
@@ -298,11 +298,11 @@ Treat that preview as a structural scope check before producing draft
|
|
|
298
298
|
candidates; the CLI does not decide which symbols are important to a business
|
|
299
299
|
or audience.
|
|
300
300
|
|
|
301
|
-
The
|
|
301
|
+
The codeindex path keeps the stable module identity. The date stays in the repo
|
|
302
302
|
source ref and phase id, not in the knowledge path:
|
|
303
303
|
|
|
304
304
|
```text
|
|
305
|
-
knowledge/
|
|
305
|
+
knowledge/codeindex/<module>/symbol/<slug>.md
|
|
306
306
|
```
|
|
307
307
|
|
|
308
308
|
Show the tree/path preview to the user before first extraction and describe it
|
|
@@ -423,8 +423,8 @@ const componentLib = source("20260712", "component-lib");
|
|
|
423
423
|
export default defineProject({
|
|
424
424
|
sources: [componentLib],
|
|
425
425
|
phases: [
|
|
426
|
-
extractTs({ source: componentLib, collection: "
|
|
427
|
-
reviewValidity({ collection: "
|
|
426
|
+
extractTs({ source: componentLib, collection: "codeindex" }),
|
|
427
|
+
reviewValidity({ collection: "codeindex" }),
|
|
428
428
|
],
|
|
429
429
|
packages: [
|
|
430
430
|
kbPackage({
|
|
@@ -433,7 +433,7 @@ export default defineProject({
|
|
|
433
433
|
path: "src/package-templates/kb",
|
|
434
434
|
vars: { displayName: "Component Library KB" },
|
|
435
435
|
},
|
|
436
|
-
select: { include: ["
|
|
436
|
+
select: { include: ["codeindex/component-lib/**"] },
|
|
437
437
|
}),
|
|
438
438
|
],
|
|
439
439
|
});
|
|
@@ -446,7 +446,7 @@ of the agent knowledge-base package:
|
|
|
446
446
|
llmsPackage({
|
|
447
447
|
name: "component-lib-llms",
|
|
448
448
|
template: "src/package-templates/llms",
|
|
449
|
-
select: { include: ["
|
|
449
|
+
select: { include: ["codeindex/component-lib/**"] },
|
|
450
450
|
});
|
|
451
451
|
```
|
|
452
452
|
|
|
@@ -146,7 +146,7 @@ action as adding a knowledge source, not as filling CLI placeholders. Treat this
|
|
|
146
146
|
as a source boundary decision. Document sources use today's local date as their
|
|
147
147
|
name. Repo sources use the date as a batch and require the confirmed module
|
|
148
148
|
identity. Do not invent semantic date suffixes. The concrete repo selector
|
|
149
|
-
appears in source refs, phase ids, and
|
|
149
|
+
appears in source refs, phase ids, and codeindex paths:
|
|
150
150
|
|
|
151
151
|
```text
|
|
152
152
|
knowledge/<collection>/<slug>.md
|
|
@@ -178,6 +178,15 @@ If the user supplies several repo/file/Lark sources in one request, create one
|
|
|
178
178
|
register them under a single project write lock. Never parallelize mutating
|
|
179
179
|
`source add` commands; on a lock-held error, wait and retry.
|
|
180
180
|
|
|
181
|
+
Do not select sources from repository layout or Git metadata. After the user
|
|
182
|
+
has named an exact local module or path, however, resolving one unique matching
|
|
183
|
+
directory and reading its Git root, `origin`, and current commit are mechanical
|
|
184
|
+
identity checks. Pass the resolved local path relative to the Context project
|
|
185
|
+
root; when the workspace was initialized in a child `context/` directory,
|
|
186
|
+
recompute sibling paths from that new root. In ordinary and fully managed modes,
|
|
187
|
+
do not request a remote URL again when that confirmed local checkout provides
|
|
188
|
+
it.
|
|
189
|
+
|
|
181
190
|
Current execution supports repo sources, local Markdown/MDX file sources, and Lark /
|
|
182
191
|
Feishu document sources. Local
|
|
183
192
|
repo/package sources are registered with `context source add repo [YYYYMMDD] --module <module> --local <path>`;
|
|
@@ -286,16 +295,16 @@ prose align. Once a document structure draft exists, keep that current human
|
|
|
286
295
|
gate and do not switch workflows mid-review.
|
|
287
296
|
|
|
288
297
|
For monorepos, the date is one registration batch and every selected package is
|
|
289
|
-
a module under it. Stable
|
|
290
|
-
look like `knowledge/
|
|
291
|
-
`knowledge/
|
|
298
|
+
a module under it. Stable codeindex paths omit that batch date and therefore
|
|
299
|
+
look like `knowledge/codeindex/module-a/...` and
|
|
300
|
+
`knowledge/codeindex/module-b/...`. Date/module remains in phase ids and
|
|
292
301
|
repo source refs. Use the whole repo/subspace
|
|
293
302
|
only for inspection when it contains multiple modules. If the user chooses
|
|
294
303
|
`packages/button`, register it with `--module button` under the same date and
|
|
295
304
|
write `extractTs({ source: source("20260712", "button"), ... })`. Do not use
|
|
296
305
|
`include: ["packages/button/src/**"]` to choose a package from a larger source;
|
|
297
306
|
`include` only filters files inside the selected source. Repo module names are
|
|
298
|
-
project-wide
|
|
307
|
+
project-wide codeindex identities; refresh an existing module through its
|
|
299
308
|
original date/module selector instead of reusing its name under a later date.
|
|
300
309
|
|
|
301
310
|
For a non-standard package, configure source-relative `entries` on `extractTs`;
|
|
@@ -318,17 +327,17 @@ context source inspect <date>/<module> --format json
|
|
|
318
327
|
context run <extract-phase-id> --dry-run --format json
|
|
319
328
|
```
|
|
320
329
|
|
|
321
|
-
After the preview, run
|
|
330
|
+
After the preview, run codeindex extraction normally unless the user explicitly
|
|
322
331
|
asked for CI/CD automation. The first normal run requires Review for all code
|
|
323
332
|
candidates. Subsequent normal runs require Review only for added, changed, or
|
|
324
333
|
removed symbols; unchanged approved symbols stay approved. After each result,
|
|
325
|
-
run `context status --format json`. `continue-
|
|
334
|
+
run `context status --format json`. `continue-codeindex-batch` only requests
|
|
326
335
|
workspace re-evaluation. Open Review only when
|
|
327
336
|
`workflow.current.gate.id=knowledge-review`; otherwise execute the current
|
|
328
337
|
route.
|
|
329
338
|
|
|
330
339
|
For a non-interactive pipeline, use `context run <extract-phase-id>
|
|
331
|
-
--auto-promote --format json`. This flag applies only to
|
|
340
|
+
--auto-promote --format json`. This flag applies only to codeindex, applies its
|
|
332
341
|
deterministic deltas, refreshes deterministic close when needed, runs verify,
|
|
333
342
|
and fails the command if close or verify fails. Read `autoPromotion.close` and
|
|
334
343
|
`autoPromotion.verify` before continuing. Package build remains explicit: when
|
|
@@ -354,7 +363,7 @@ tsconfig/jsconfig `baseUrl` and `paths`, so do not ask users to rewrite `@/`
|
|
|
354
363
|
imports solely for Context. Explain the concrete output shape:
|
|
355
364
|
|
|
356
365
|
```text
|
|
357
|
-
knowledge/
|
|
366
|
+
knowledge/codeindex/<module>/symbol/<slug>.md
|
|
358
367
|
```
|
|
359
368
|
|
|
360
369
|
If the module or resulting path shape looks wrong, stop and repair the
|
|
@@ -33,6 +33,13 @@ resources remain explicit in the capture report. Unknown non-empty XML blocks
|
|
|
33
33
|
stay auditable in the raw XML and receive a warning; the CLI does not infer
|
|
34
34
|
their meaning.
|
|
35
35
|
|
|
36
|
+
Document and resource reads share one access identity. Context first uses the
|
|
37
|
+
user identity; it falls back to the bot identity only when user credentials
|
|
38
|
+
are unavailable, never when the source denies permission or reports missing
|
|
39
|
+
scopes. This prevents a capture from mixing document text read by one identity
|
|
40
|
+
with attachments read by another. A bot fallback is reported in the capture
|
|
41
|
+
result and remains subject to the bot's own access boundary.
|
|
42
|
+
|
|
36
43
|
## Storage lifecycle
|
|
37
44
|
|
|
38
45
|
Resources have three distinct locations:
|
|
@@ -105,8 +105,8 @@ capture reports are never distributed as reader assets. See
|
|
|
105
105
|
[Lark Resource Materialization](./lark-resources.md).
|
|
106
106
|
|
|
107
107
|
The same inventory exposes `structure.relationship_coverage`. It records
|
|
108
|
-
whether selected
|
|
109
|
-
metadata, how many
|
|
108
|
+
whether selected codeindex pages have current source-backed AST relationship
|
|
109
|
+
metadata, how many codeindex views were selected, and how many package-visible
|
|
110
110
|
edges were emitted. An empty edge list is therefore explicit evidence of a
|
|
111
111
|
coverage state, not permission to invent a dependency.
|
|
112
112
|
|
|
@@ -130,7 +130,7 @@ Current collection mapping:
|
|
|
130
130
|
|
|
131
131
|
| Internal collection | Package path | Role |
|
|
132
132
|
|---|---|---|
|
|
133
|
-
| `
|
|
133
|
+
| `codeindex` | `wikis/codeindex/` | Source-backed code indexes with optional structured relationships. |
|
|
134
134
|
| `business` | `wikis/business/` | Structured business entities and relationships. |
|
|
135
135
|
| `product` | `wikis/product/` | Structured product entities, behavior, and relationships. |
|
|
136
136
|
| `architecture` | `guides/architecture/` | Architecture explanations and design narratives. |
|
|
@@ -98,7 +98,7 @@ configuration problem, not a Review decision.
|
|
|
98
98
|
|
|
99
99
|
If no current capability can parse the source reliably, stop at configuration
|
|
100
100
|
and report the missing generic capability. Do not silently emit an empty
|
|
101
|
-
|
|
101
|
+
codeindex or reuse an unrelated parser.
|
|
102
102
|
|
|
103
103
|
## Plan Before Parsing
|
|
104
104
|
|
|
@@ -108,7 +108,7 @@ application, adapter, CLI/tool, monorepo container, derived source,
|
|
|
108
108
|
authoritative contract source, or unknown.
|
|
109
109
|
A hybrid module may declare several `moduleTypes` and several behavior `facets`;
|
|
110
110
|
keep one primary `moduleType` for concise reports. Record inspected paths in
|
|
111
|
-
`moduleTypeEvidence`, then read all matching Route-recommended files below
|
|
111
|
+
`moduleTypeEvidence`, record every Markdown file actually read in `documents`, then read all matching Route-recommended files below
|
|
112
112
|
`resources/semantic/code-index/templates/` and combine them into one plan.
|
|
113
113
|
After that, choose exactly one closed output profile: `module-map`,
|
|
114
114
|
`application-map`, `protocol-index`, `service-boundary`, `runtime-map`,
|
|
@@ -130,8 +130,9 @@ selected symbol and permits one owning index unit per source. Use it for an
|
|
|
130
130
|
intentional granular public reference. Use `extractCustom()` for module-level
|
|
131
131
|
aggregation, registries, protocol indexes, cross-module flows, or multiple
|
|
132
132
|
candidate owners over one source; each candidate declares its `module` and
|
|
133
|
-
evidence-scoped `
|
|
134
|
-
|
|
133
|
+
at least one evidence-scoped `section`; there is no page-level Markdown
|
|
134
|
+
fallback. Each section's typed coverage and exact evidence is checked against
|
|
135
|
+
the output profile during preview. Resolve repositories from
|
|
135
136
|
the extractor context's `sources[].absolutePath`, never from a
|
|
136
137
|
machine-specific checkout path. Cross-module flow output must also emit
|
|
137
138
|
source-backed structured edges. Generated clients/models, mirrored sources, legacy
|
|
@@ -41,7 +41,7 @@ kbPackage({
|
|
|
41
41
|
llmsPackage({
|
|
42
42
|
name: "component-lib-llms",
|
|
43
43
|
template: "src/package-templates/llms",
|
|
44
|
-
select: { include: ["
|
|
44
|
+
select: { include: ["codeindex/component-lib/**"] },
|
|
45
45
|
});
|
|
46
46
|
```
|
|
47
47
|
|
|
@@ -259,7 +259,7 @@ its pages instead of producing one index per path segment.
|
|
|
259
259
|
The generated
|
|
260
260
|
`dist/<package-name>/wikis/` tree is the required default
|
|
261
261
|
KB entry surface. Internal collections are mapped into OKF roots during build:
|
|
262
|
-
`
|
|
262
|
+
`codeindex`, `business`, and `product` go to `wikis/`; `architecture`, `sop`,
|
|
263
263
|
`faq`, `decision`, and `incident` go to `guides/`; `standards` and `test` go to
|
|
264
264
|
`rules/`; and `feats` goes to `feats/`. Treat `wikis/` as the structured
|
|
265
265
|
entity-and-relationship layer. Guides and rules may explain, operationalize,
|
|
@@ -307,17 +307,25 @@ wants project-specific behavior beyond knowledge lookup.
|
|
|
307
307
|
|
|
308
308
|
## Context OKF Profiles
|
|
309
309
|
|
|
310
|
-
Approved Markdown under `knowledge/`
|
|
310
|
+
Approved Markdown under `knowledge/` and its deterministic
|
|
311
|
+
`knowledge/structure.yaml` projection form the authoring source of truth:
|
|
311
312
|
|
|
312
313
|
- top-level YAML frontmatter uses OKF fields such as `type`, `title`,
|
|
313
314
|
`description`, `tags`, `timestamp`, and `resource`;
|
|
314
|
-
-
|
|
315
|
-
`
|
|
316
|
-
|
|
315
|
+
- each Markdown page keeps reader fields, stable page identity, `sources`, and a
|
|
316
|
+
small recovery capsule (`resource`, `node_type`, containment fields, and
|
|
317
|
+
relationship mode);
|
|
318
|
+
- large or repeated machine state such as complete `code_symbols`, code
|
|
319
|
+
evidence, relationship records, candidate fingerprints, and optimization
|
|
320
|
+
decisions lives once in the corresponding `structure.yaml` view record;
|
|
321
|
+
- Context readers hydrate that machine state in memory before verify, audit,
|
|
322
|
+
revision, or build. Do not copy a compact page as a new page without using a
|
|
323
|
+
Context authoring command;
|
|
317
324
|
- do not nest Context production metadata under `context`; fields such as
|
|
318
325
|
`context.sources` and `context.code_symbols` are not part of the 0.6 profile;
|
|
319
326
|
- section provenance lives in `<!-- context:section ... source_ref="..." -->`
|
|
320
|
-
comments
|
|
327
|
+
comments. When a Section needs more than one citation, the CLI preserves the
|
|
328
|
+
complete set in its adjacent `context:source_refs` block;
|
|
321
329
|
- do not add frontmatter `source_refs`; page-level provenance is derived from
|
|
322
330
|
section source refs when needed;
|
|
323
331
|
- do not add `context` or `schema` fields.
|
|
@@ -340,7 +348,7 @@ src-N#span:<heading-hint> L<start>-<end>@<span-hash>
|
|
|
340
348
|
|
|
341
349
|
The code symbol form includes the source-relative file so same-name symbols in
|
|
342
350
|
different files resolve to one exact symbol-index row. Consumers should still
|
|
343
|
-
treat the complete `source_ref` as opaque. Production
|
|
351
|
+
treat the complete `source_ref` as opaque. Production codeindex pages keep
|
|
344
352
|
`candidate_fingerprint` at the top level and do not duplicate this evidence in
|
|
345
353
|
`code_origin`.
|
|
346
354
|
|
|
@@ -392,8 +400,8 @@ current closed state.
|
|
|
392
400
|
|
|
393
401
|
Before writing output, `context build` validates that rendered template paths
|
|
394
402
|
are safe, unique, and do not collide with copied knowledge paths. For example,
|
|
395
|
-
a template file that renders to `wikis/
|
|
396
|
-
selected knowledge such as `knowledge/
|
|
403
|
+
a template file that renders to `wikis/codeindex/foo.md` is rejected if
|
|
404
|
+
selected knowledge such as `knowledge/codeindex/foo.md` maps to that same OKF
|
|
397
405
|
output path. Rename the template file or use `select.exclude` when the
|
|
398
406
|
collision is intentional.
|
|
399
407
|
|
|
@@ -29,7 +29,7 @@ the date:
|
|
|
29
29
|
```text
|
|
30
30
|
knowledge/<collection>/<slug>.md
|
|
31
31
|
knowledge/<collection>/<containment>/<slug>.md # only for an intentional hierarchy
|
|
32
|
-
knowledge/
|
|
32
|
+
knowledge/codeindex/<module>/symbol/<slug>.md
|
|
33
33
|
repo:<date>/<module>#symbol:...
|
|
34
34
|
file:<date>/<module>/<document>#span:...
|
|
35
35
|
lark:<date>/<module>/<document>#span:...
|
|
@@ -41,12 +41,12 @@ dist/<source-name>-kb/...
|
|
|
41
41
|
Choose the module boundary before extraction. In a monorepo, register each
|
|
42
42
|
confirmed package/subdirectory under the same date batch. A repo root that
|
|
43
43
|
resolves to multiple modules is for inspection; it is not an extraction unit.
|
|
44
|
-
Approved
|
|
44
|
+
Approved codeindex paths use the stable module name; the date remains only in
|
|
45
45
|
source selectors, phase ids, and evidence refs:
|
|
46
46
|
|
|
47
47
|
```text
|
|
48
|
-
knowledge/
|
|
49
|
-
knowledge/
|
|
48
|
+
knowledge/codeindex/module-a/...
|
|
49
|
+
knowledge/codeindex/module-b/...
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
For prose Views, provide a stable filename `slug` and omit `path`; the CLI
|
|
@@ -57,7 +57,7 @@ it is not a required source/module wrapper.
|
|
|
57
57
|
|
|
58
58
|
The registry stores this as one date entry containing several `modules` entries,
|
|
59
59
|
and materializes each module at `sources/repo/<date>/<module>`.
|
|
60
|
-
Repo module names are project-wide
|
|
60
|
+
Repo module names are project-wide codeindex identities and therefore cannot be
|
|
61
61
|
reused under another date batch. Refresh an existing module through its original
|
|
62
62
|
date/module selector.
|
|
63
63
|
When a repo module and the Context workspace share the same Git root, the CLI
|
|
@@ -402,7 +402,7 @@ alignProse({
|
|
|
402
402
|
```
|
|
403
403
|
|
|
404
404
|
`collection` is an internal knowledge classification, not a package directory.
|
|
405
|
-
Package build maps `
|
|
405
|
+
Package build maps `codeindex`/`business`/`product` to `wikis/`,
|
|
406
406
|
`architecture`/`sop`/`faq`/`decision`/`incident` to `guides/`,
|
|
407
407
|
`standards`/`test` to `rules/`, and `feats` to `feats/`. The complete output
|
|
408
408
|
contract is documented in [Package Outputs](../guides/package-outputs.md).
|
|
@@ -592,7 +592,7 @@ Extract exported TypeScript / TSX symbols into draft candidates:
|
|
|
592
592
|
```ts
|
|
593
593
|
extractTs({
|
|
594
594
|
source: componentLib,
|
|
595
|
-
collection: "
|
|
595
|
+
collection: "codeindex",
|
|
596
596
|
});
|
|
597
597
|
```
|
|
598
598
|
|
|
@@ -601,7 +601,7 @@ Options:
|
|
|
601
601
|
| Field | Meaning |
|
|
602
602
|
|---|---|
|
|
603
603
|
| `source` | `source("date", "module")` for one repo module |
|
|
604
|
-
| `collection` | Code extraction uses `"
|
|
604
|
+
| `collection` | Code extraction uses `"codeindex"` |
|
|
605
605
|
| `include` | Optional glob list inside the selected source; default is `["src/**/*.{ts,tsx}"]` |
|
|
606
606
|
| `mode` | `"exports"` (default) traces public exports from automatic or configured entries; `"scan"` uses every file matched by `include` as an entry root |
|
|
607
607
|
| `entries` | Optional source-relative entry files for `"exports"` mode. They override `package.json` entry detection and live only in the Context project configuration |
|
|
@@ -614,7 +614,7 @@ An explicit index unit records production intent rather than parser settings:
|
|
|
614
614
|
```ts
|
|
615
615
|
extractTs({
|
|
616
616
|
source: componentLib,
|
|
617
|
-
collection: "
|
|
617
|
+
collection: "codeindex",
|
|
618
618
|
indexUnits: [{
|
|
619
619
|
id: "component-public-api",
|
|
620
620
|
inputSources: ["20260712/component-lib"],
|
|
@@ -623,6 +623,7 @@ extractTs({
|
|
|
623
623
|
moduleTypes: ["sdk-library"],
|
|
624
624
|
facets: ["public-api", "plugin-extension"],
|
|
625
625
|
moduleTypeEvidence: ["package.json exports and src/index.ts public entry"],
|
|
626
|
+
documents: ["README.md", "docs/public-api.md"],
|
|
626
627
|
outputProfile: "public-api-reference",
|
|
627
628
|
responsibility: "Document stable exported component contracts.",
|
|
628
629
|
entries: ["src/index.ts"],
|
|
@@ -649,6 +650,9 @@ behaviors such as routing, protocol consumption, events, persistence, plugins,
|
|
|
649
650
|
release, or cross-module chains. `moduleTypeEvidence` records the inspected
|
|
650
651
|
paths that support the classification. Classify first, then read the matching
|
|
651
652
|
Route-provided code-index templates, and only then finish the extraction plan.
|
|
653
|
+
`documents` contains exact source-relative Markdown paths read for that plan;
|
|
654
|
+
Context compares it with discovered module documents instead of treating a
|
|
655
|
+
source-code comment as documentation coverage.
|
|
652
656
|
`lifecycle` is `"authoritative"`, `"generated"`, `"mirrored"`, `"legacy"`,
|
|
653
657
|
or `"vendored"`; derived sources normally use `"provenance-only"` rather
|
|
654
658
|
than duplicating reader-facing pages. These are generic project facts, not
|
|
@@ -674,7 +678,7 @@ editing the source repository:
|
|
|
674
678
|
```ts
|
|
675
679
|
extractTs({
|
|
676
680
|
source: componentLib,
|
|
677
|
-
collection: "
|
|
681
|
+
collection: "codeindex",
|
|
678
682
|
include: ["src/**/*.ts"],
|
|
679
683
|
entries: ["src/api.ts"],
|
|
680
684
|
});
|
|
@@ -734,7 +738,7 @@ remain report signals and do not create another Gate.
|
|
|
734
738
|
Phase id shape:
|
|
735
739
|
|
|
736
740
|
```text
|
|
737
|
-
extract:<source-name-or-repo>:
|
|
741
|
+
extract:<source-name-or-repo>:codeindex
|
|
738
742
|
```
|
|
739
743
|
|
|
740
744
|
Codegraph extraction has two execution policies:
|
|
@@ -745,7 +749,7 @@ Codegraph extraction has two execution policies:
|
|
|
745
749
|
the Agent re-evaluates `context status --format json`; only
|
|
746
750
|
`workflow.current` decides whether Review is now required.
|
|
747
751
|
- `context run <phase-id> --auto-promote` is the explicit CI/CD path. It is valid
|
|
748
|
-
only for `phase.extract.ts`
|
|
752
|
+
only for `phase.extract.ts` codeindex phases, applies deterministic code deltas
|
|
749
753
|
without Review, refreshes deterministic close when approved knowledge changed,
|
|
750
754
|
then runs project verification. Close or verification errors make the command
|
|
751
755
|
fail; JSON output reports applied/materialized/removed counts plus a `close`
|
|
@@ -757,7 +761,7 @@ other semantic knowledge. Agents must not infer a human gate from a phase-local
|
|
|
757
761
|
result. Human gates and their inspection/resolution Actions are exposed only by
|
|
758
762
|
`workflow.current`.
|
|
759
763
|
|
|
760
|
-
Approved
|
|
764
|
+
Approved codeindex sections use the local evidence form
|
|
761
765
|
`src-N#symbol:<file>:<symbol>:<kind>@<digest>`. The file segment makes reverse
|
|
762
766
|
lookup exact when multiple files contain the same symbol name, kind, and digest;
|
|
763
767
|
the complete ref remains opaque to agents. New pages keep only top-level
|
|
@@ -773,7 +777,7 @@ aggregated repository protocol:
|
|
|
773
777
|
extractCustom({
|
|
774
778
|
id: "extract:service:protocol",
|
|
775
779
|
sources: [service],
|
|
776
|
-
collection: "
|
|
780
|
+
collection: "codeindex",
|
|
777
781
|
indexUnits: [{
|
|
778
782
|
id: "service-protocol",
|
|
779
783
|
inputSources: ["20260811/service"],
|
|
@@ -844,6 +848,12 @@ least one source-backed structured edge. `context status` therefore treats this
|
|
|
844
848
|
pending code extraction target, and Review can verify snapshot freshness
|
|
845
849
|
without a placeholder `extractTs` phase.
|
|
846
850
|
|
|
851
|
+
Each `sections[].markdown` value is Section body content only; do not copy the
|
|
852
|
+
template heading into it. Context renders `sections[].title` and rejects nested
|
|
853
|
+
reader headings at the SDK boundary so empty template chapters cannot leak into
|
|
854
|
+
knowledge. Evidence `symbol` and `kind` are canonical-ref tokens and cannot
|
|
855
|
+
contain `:` or `@`; exact qualified signatures remain reader-facing prose.
|
|
856
|
+
|
|
847
857
|
`indexUnits` is also the batch scale and ownership contract. Candidate
|
|
848
858
|
`module` must match one declared unit id or output owner. Older callbacks that
|
|
849
859
|
omit `indexUnits` remain compatible: Context groups candidates by `module` and
|
|
@@ -873,6 +883,21 @@ output profile. Coverage is based on source-backed evidence paths, not Markdown
|
|
|
873
883
|
page count, so one aggregate page can pass while an entry-only static module
|
|
874
884
|
card cannot.
|
|
875
885
|
|
|
886
|
+
For a single-source index unit, Context also scans every represented language
|
|
887
|
+
family and Markdown/MDX file after the unit's declared exclusions. The adapter's
|
|
888
|
+
`eligibleFileTargets` and `eligibleLoc` must cover that independent baseline.
|
|
889
|
+
Configuration files may be evidence, but a hand-picked evidence list cannot be
|
|
890
|
+
reused as the source or LOC denominator. Cross-module-flow units remain scored
|
|
891
|
+
against their declared entry, protocol, operation, and handoff boundaries rather
|
|
892
|
+
than treating several repositories as one source-code page.
|
|
893
|
+
|
|
894
|
+
The same baseline discovers conventional sibling page entries, route-register
|
|
895
|
+
calls in Go router files, and exported receiver operations when a Go handler is
|
|
896
|
+
the declared service source of truth. Every discovered identity must appear in
|
|
897
|
+
the target-symbol and boundary denominators. An aggregate page may summarize
|
|
898
|
+
these identities, but an adapter cannot list one representative sibling and
|
|
899
|
+
silently omit the rest.
|
|
900
|
+
|
|
876
901
|
The extractor returns knowledge semantics (`nodeRef`, rendered Markdown,
|
|
877
902
|
Review summary and source-backed evidence). It must not write `knowledge/`,
|
|
878
903
|
`.tmp/context-runtime/lifecycle/candidates.jsonl`, extraction fingerprints or
|
|
@@ -893,9 +918,9 @@ import { indexGoRepository } from "@c4a/extract-go";
|
|
|
893
918
|
import { extractCustom } from "@c4a/context";
|
|
894
919
|
|
|
895
920
|
extractCustom({
|
|
896
|
-
id: "extract:service:
|
|
921
|
+
id: "extract:service:codeindex",
|
|
897
922
|
sources: [service],
|
|
898
|
-
collection: "
|
|
923
|
+
collection: "codeindex",
|
|
899
924
|
extract: async ({ projectRoot }) => {
|
|
900
925
|
const facts = await indexGoRepository(resolveServiceCheckout(projectRoot));
|
|
901
926
|
return { candidates: buildServiceCandidates(facts) };
|
|
@@ -921,7 +946,7 @@ and its evidence coverage auditable before candidate writes.
|
|
|
921
946
|
Declare the review step for a collection:
|
|
922
947
|
|
|
923
948
|
```ts
|
|
924
|
-
reviewValidity({ collection: "
|
|
949
|
+
reviewValidity({ collection: "codeindex" });
|
|
925
950
|
```
|
|
926
951
|
|
|
927
952
|
Declare one review gate for all current draft collections:
|
|
@@ -933,7 +958,7 @@ reviewValidity({ scope: "all" });
|
|
|
933
958
|
Phase id:
|
|
934
959
|
|
|
935
960
|
```text
|
|
936
|
-
review:
|
|
961
|
+
review:codeindex:validity
|
|
937
962
|
review:all:validity
|
|
938
963
|
```
|
|
939
964
|
|
|
@@ -945,14 +970,21 @@ review html --all --open --format json`, confirm the returned `opened` field,
|
|
|
945
970
|
and wait for the user-copied payload. They should not run the phase as an
|
|
946
971
|
automatic approval step or synthesize a payload themselves.
|
|
947
972
|
|
|
948
|
-
|
|
949
|
-
|
|
973
|
+
One batch-wide path is explicit current-conversation fully managed authority.
|
|
974
|
+
In that mode, follow the `context status --managed` route to
|
|
950
975
|
`context review approve-all ... --managed`; the CLI validates the exact current
|
|
951
976
|
scope before applying one default-approved decision.
|
|
952
977
|
|
|
978
|
+
Ordinary mode has a separate user-confirmed escape path for environments where
|
|
979
|
+
the Review report cannot be opened. Do not advertise it in the initial Review
|
|
980
|
+
prompt. After the user reports that limitation, the exact conversation phrase
|
|
981
|
+
`强制批准` authorizes only the current Route's revision-bound
|
|
982
|
+
`context review approve-all ... --force` command. Other generic approval or
|
|
983
|
+
continue wording does not invoke it.
|
|
984
|
+
|
|
953
985
|
The gate is batch-scoped: prose waits for every planned View across all active
|
|
954
986
|
structure slots and every declared `pendingStructureTargets` item in the round;
|
|
955
|
-
|
|
987
|
+
codeindex waits for every pending extract phase in the confirmed module round.
|
|
956
988
|
Candidate count/hash therefore describes the complete current batch rather than
|
|
957
989
|
one page, source slot, or module. Deterministic close later merges all active
|
|
958
990
|
slots into `knowledge/structure.yaml`, retains only their source, collection,
|
|
@@ -982,13 +1014,13 @@ const sample = source("20260712", "sample");
|
|
|
982
1014
|
|
|
983
1015
|
customPhase("custom:20260712/sample:review", async (ctx) => {
|
|
984
1016
|
await ctx.ensureSources({ source: sample });
|
|
985
|
-
await ctx.extract.ts(extractTs({ source: sample, collection: "
|
|
986
|
-
await ctx.review.html(reviewValidity({ collection: "
|
|
1017
|
+
await ctx.extract.ts(extractTs({ source: sample, collection: "codeindex" }));
|
|
1018
|
+
await ctx.review.html(reviewValidity({ collection: "codeindex" }));
|
|
987
1019
|
});
|
|
988
1020
|
```
|
|
989
1021
|
|
|
990
1022
|
Custom phases are an orchestration escape hatch. Use `extractCustom()` instead
|
|
991
|
-
when project code needs to publish
|
|
1023
|
+
when project code needs to publish codeindex candidates. The supported runtime
|
|
992
1024
|
helpers are:
|
|
993
1025
|
|
|
994
1026
|
- `ctx.ensureSources(...)` for repo source readiness.
|
package/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { PackageNavigationDefinition, PackageSelectDefinition } from "./contracts.js";
|
|
2
2
|
import type { PhaseDefinition, PhaseResourceReference } from "./phases.js";
|
|
3
3
|
import type { ProjectSourceDefinition } from "./sources.js";
|
|
4
|
-
export type { CodegraphCollection, DocumentMainlineCollection, EntityStatus, KnowledgeCollection, MainlineCollection, MarkdownTransform, FileCaptureProcessorDefinition, OkfRoot, PackageKind, PackageNavigationDefinition, PackageSelectDefinition, TopLevelNamespace, } from "./contracts.js";
|
|
4
|
+
export type { CodegraphCollection, CodeIndexCollection, DocumentMainlineCollection, EntityStatus, KnowledgeCollection, MainlineCollection, MarkdownTransform, FileCaptureProcessorDefinition, OkfRoot, PackageKind, PackageNavigationDefinition, PackageSelectDefinition, TopLevelNamespace, } from "./contracts.js";
|
|
5
5
|
export { assertDocumentMainlineCollection, assertKnowledgeCollection, assertMainlineCollection, assertOkfRoot, assertTopLevelNamespace, DOC_MAINLINE_COLLECTIONS, DEFAULT_PACKAGE_NAVIGATION, KNOWLEDGE_COLLECTIONS, MAINLINE_COLLECTIONS, OKF_ROOTS, TOP_LEVEL_NAMESPACES, } from "./contracts.js";
|
|
6
6
|
export { assertDocumentEvidenceSectionMetadata, DOCUMENT_COMPILE_ACTION_SCHEMA_VERSION, DOCUMENT_EVIDENCE_SECTION_VALIDATION_STAGES, DOCUMENT_SECTION_CONTENT_MODES, DOCUMENT_STRUCTURE_SCHEMA_VERSION, } from "./documentEvidence.js";
|
|
7
7
|
export type { DocumentEvidenceSectionMetadata, DocumentEvidenceSectionValidationOptions, DocumentEvidenceSectionValidationStage, DocumentSectionContentMode, } from "./documentEvidence.js";
|
|
8
8
|
export { alignProse, captureFile, captureLark, compileProse, CODE_INDEX_CAPABILITIES, CODE_INDEX_COVERAGE_KINDS, CODE_INDEX_LIFECYCLES, CODE_INDEX_MODULE_FACETS, CODE_INDEX_MODULE_TYPES, CODE_INDEX_OUTPUT_PROFILES, customPhase, extractCustom, extractTs, ExtractTsConfigurationError, NO_ENTRY_DETECTED, requiredCodeIndexCoverage, mdxJsonDocs, reviewValidity, } from "./phases.js";
|
|
9
|
-
export type { AlignProsePhaseDefinition, CaptureFilePhaseDefinition, CaptureLarkPhaseDefinition, CompileProsePhaseDefinition, ContextPhase, ContextPhaseContext, CustomPhaseDefinition, CustomCodeCandidateDraft, CustomCodeCandidateEdge, CustomCodeCandidateSection, CustomCodeCandidateReview, CustomCodeEvidence, CustomCodeExtractionContext, CustomCodeExtractionResult, CustomCodeExtractor, CodeIndexCapability, CodeIndexCapabilityGap, CodeIndexCoverageKind, CodeIndexInspectionAdapter, CodeIndexInspectionContext, CodeIndexInspectionFinding, CodeIndexInspectionFindingKind, CodeIndexInspectionResult, CodeIndexLifecycle, CodeIndexModuleFacet, CodeIndexModuleType, CodeIndexOutputProfile, CodeIndexUnitPlan, ExtractCustomPhaseDefinition, ExtractTsPhaseDefinition, PhaseDefinition, PhaseResourceReference, ReviewValidityPhaseDefinition, ReviewValidityScope, } from "./phases.js";
|
|
9
|
+
export type { AlignProsePhaseDefinition, CaptureFilePhaseDefinition, CaptureLarkPhaseDefinition, CompileProsePhaseDefinition, ContextPhase, ContextPhaseContext, CustomPhaseDefinition, CustomCodeCandidateDraft, CustomCodeCandidateEdge, CustomCodeCandidateSection, CustomCodeCandidateReview, CustomCodeEvidence, CustomCodeExtractionContext, CustomCodeExtractionResult, CustomCodeExtractor, CodeIndexCapability, CodeIndexCapabilityGap, CodeIndexCoverageKind, CodeIndexInspectionAdapter, CodeIndexInspectionContext, CodeIndexInspectionFinding, CodeIndexInspectionFindingKind, CodeIndexInspectionInventory, CodeIndexInspectionResult, CodeIndexLifecycle, CodeIndexModuleFacet, CodeIndexModuleType, CodeIndexOutputProfile, CodeIndexUnitPlan, ExtractCustomPhaseDefinition, ExtractTsPhaseDefinition, PhaseDefinition, PhaseResourceReference, ReviewValidityPhaseDefinition, ReviewValidityScope, } from "./phases.js";
|
|
10
10
|
export { allSources, DEFAULT_FILE_SOURCES_REGISTRY_PATH, DEFAULT_LARK_SOURCES_REGISTRY_PATH, DEFAULT_REPO_SOURCES_REGISTRY_PATH, loadSourcesRegistry, resolveSourceReference, source, } from "./sources.js";
|
|
11
11
|
export type { DocumentSourceDefinition, DocumentSourceReference, DocumentSourceType, FileSourceDefinition, FileSourceReference, FileSourceRegistryEntry, LarkSourceDefinition, LarkSourceReference, LarkSourceRegistryEntry, LoadSourcesRegistryOptions, ProjectSourceDefinition, RepoProjectSourceDefinition, RepoSourceDefinition, RepoSourceReference, RepoSourceRegistryEntry, RepoSourcesRegistry, SourceCollectionReference, SourceDefinition, SourceReference, SourcesRegistry, SourceType, } from "./sources.js";
|
|
12
12
|
export type TemplateVarValue = string | number | boolean | null | Record<string, unknown> | readonly Record<string, unknown>[];
|
package/index.js
CHANGED
|
@@ -6931,7 +6931,7 @@ var DOC_MAINLINE_COLLECTIONS = [
|
|
|
6931
6931
|
"incident",
|
|
6932
6932
|
"test"
|
|
6933
6933
|
];
|
|
6934
|
-
var MAINLINE_COLLECTIONS = ["codegraph", ...DOC_MAINLINE_COLLECTIONS];
|
|
6934
|
+
var MAINLINE_COLLECTIONS = ["codeindex", "codegraph", ...DOC_MAINLINE_COLLECTIONS];
|
|
6935
6935
|
var TOP_LEVEL_NAMESPACES = [...MAINLINE_COLLECTIONS, "feats"];
|
|
6936
6936
|
var OKF_ROOTS = ["guides", "rules", "wikis", "feats"];
|
|
6937
6937
|
var KNOWLEDGE_COLLECTIONS = TOP_LEVEL_NAMESPACES;
|
|
@@ -7158,6 +7158,9 @@ function normalizeIndexUnit(unit, field) {
|
|
|
7158
7158
|
...unit.moduleTypeEvidence === undefined ? {} : {
|
|
7159
7159
|
moduleTypeEvidence: unit.moduleTypeEvidence.map((item, index) => requiredIndexText(item, `${field}.moduleTypeEvidence[${index}]`))
|
|
7160
7160
|
},
|
|
7161
|
+
...unit.documents === undefined ? {} : {
|
|
7162
|
+
documents: [...new Set(unit.documents.map((item, index) => normalizeExtractEntry(requiredIndexText(item, `${field}.documents[${index}]`))))]
|
|
7163
|
+
},
|
|
7161
7164
|
outputProfile: requiredIndexEnum(unit.outputProfile, `${field}.outputProfile`, CODE_INDEX_OUTPUT_PROFILES),
|
|
7162
7165
|
responsibility: requiredIndexText(unit.responsibility, `${field}.responsibility`),
|
|
7163
7166
|
entries: unit.entries.map((entry, index) => requiredIndexText(entry, `${field}.entries[${index}]`)),
|
|
@@ -7377,8 +7380,8 @@ var compileProse = (definition) => {
|
|
|
7377
7380
|
};
|
|
7378
7381
|
var extractTs = (definition) => {
|
|
7379
7382
|
const sourceDefinition = bindSourceType(definition.source, "repo", "extractTs source");
|
|
7380
|
-
if (definition.collection !== "codegraph") {
|
|
7381
|
-
throw new TypeError(`extractTs collection must be codegraph: ${definition.collection}`);
|
|
7383
|
+
if (definition.collection !== "codeindex" && definition.collection !== "codegraph") {
|
|
7384
|
+
throw new TypeError(`extractTs collection must be codeindex or legacy codegraph: ${definition.collection}`);
|
|
7382
7385
|
}
|
|
7383
7386
|
const sourceId = sourceDefinition.kind === "source.collection" ? sourceDefinition.type : sourceDefinition.name;
|
|
7384
7387
|
const mode = definition.mode ?? "exports";
|
|
@@ -7390,11 +7393,12 @@ var extractTs = (definition) => {
|
|
|
7390
7393
|
}
|
|
7391
7394
|
const entries = definition.entries === undefined ? undefined : [...new Set(definition.entries.map(normalizeExtractEntry))];
|
|
7392
7395
|
const defaultSourceName = sourceDefinition.kind === "source.collection" ? sourceDefinition.type : sourceDefinition.name;
|
|
7396
|
+
const defaultOutputOwner = defaultSourceName.split("/").at(-1) ?? defaultSourceName;
|
|
7393
7397
|
const exportedOnly = definition.exportedOnly ?? mode === "exports";
|
|
7394
7398
|
const indexUnits = (definition.indexUnits ?? (sourceDefinition.kind === "source.collection" ? [] : [{
|
|
7395
|
-
id:
|
|
7399
|
+
id: defaultOutputOwner,
|
|
7396
7400
|
inputSources: [defaultSourceName],
|
|
7397
|
-
outputOwner:
|
|
7401
|
+
outputOwner: defaultOutputOwner,
|
|
7398
7402
|
moduleType: mode === "exports" ? "sdk-library" : "unknown",
|
|
7399
7403
|
moduleTypes: [mode === "exports" ? "sdk-library" : "unknown"],
|
|
7400
7404
|
facets: mode === "exports" ? ["public-api"] : [],
|
|
@@ -7448,8 +7452,8 @@ var extractCustom = (definition) => {
|
|
|
7448
7452
|
throw new TypeError("extractCustom id must be a non-empty phase id");
|
|
7449
7453
|
if (definition.sources.length === 0)
|
|
7450
7454
|
throw new TypeError("extractCustom sources must contain at least one repo source");
|
|
7451
|
-
if (definition.collection !== "codegraph") {
|
|
7452
|
-
throw new TypeError(`extractCustom collection must be codegraph: ${definition.collection}`);
|
|
7455
|
+
if (definition.collection !== "codeindex" && definition.collection !== "codegraph") {
|
|
7456
|
+
throw new TypeError(`extractCustom collection must be codeindex or legacy codegraph: ${definition.collection}`);
|
|
7453
7457
|
}
|
|
7454
7458
|
const sources = definition.sources.map((sourceDefinition) => bindSourceType(sourceDefinition, "repo", "extractCustom source"));
|
|
7455
7459
|
const indexUnits = (definition.indexUnits ?? []).map((unit, index) => normalizeIndexUnit(unit, `extractCustom indexUnits[${index}]`));
|
|
@@ -11744,7 +11748,7 @@ var parseRepoSourcesRegistry = (input, registryPath, absolutePath) => {
|
|
|
11744
11748
|
assertSourceName("repo", entry.id, registryPath);
|
|
11745
11749
|
const existingNamespace = moduleNamespaces.get(entry.name);
|
|
11746
11750
|
if (existingNamespace !== undefined && existingNamespace !== namespace) {
|
|
11747
|
-
throw new TypeError(`Duplicate repo module ${JSON.stringify(entry.name)} across date batches ${existingNamespace} and ${namespace} in ${registryPath}; repo module names are project-wide
|
|
11751
|
+
throw new TypeError(`Duplicate repo module ${JSON.stringify(entry.name)} across date batches ${existingNamespace} and ${namespace} in ${registryPath}; repo module names are project-wide code-index identities`);
|
|
11748
11752
|
}
|
|
11749
11753
|
moduleNamespaces.set(entry.name, namespace);
|
|
11750
11754
|
const name = `${namespace}/${entry.name}`;
|
package/package.json
CHANGED
package/phases.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type FileCaptureProcessorDefinition, type KnowledgeCollection, type MarkdownTransform, type PackageKind, type PackageSelectDefinition, type DocumentMainlineCollection } from "./contracts.js";
|
|
1
|
+
import { type FileCaptureProcessorDefinition, type CodeIndexCollection, type KnowledgeCollection, type MarkdownTransform, type PackageKind, type PackageSelectDefinition, type DocumentMainlineCollection } from "./contracts.js";
|
|
2
2
|
import { DOCUMENT_COMPILE_ACTION_SCHEMA_VERSION } from "./documentEvidence.js";
|
|
3
3
|
import { type CodeIndexCoverageKind, type CodeIndexInspectionAdapter, type CodeIndexUnitPlan } from "./codeIndexPlan.js";
|
|
4
4
|
export { CODE_INDEX_CAPABILITIES, CODE_INDEX_COVERAGE_KINDS, CODE_INDEX_LIFECYCLES, CODE_INDEX_MODULE_FACETS, CODE_INDEX_MODULE_TYPES, CODE_INDEX_OUTPUT_PROFILES, ExtractTsConfigurationError, NO_ENTRY_DETECTED, requiredCodeIndexCoverage, } from "./codeIndexPlan.js";
|
|
5
|
-
export type { CodeIndexCapability, CodeIndexCapabilityGap, CodeIndexCoverageKind, CodeIndexInspectionAdapter, CodeIndexInspectionContext, CodeIndexInspectionFinding, CodeIndexInspectionFindingKind, CodeIndexInspectionResult, CodeIndexLifecycle, CodeIndexModuleFacet, CodeIndexModuleType, CodeIndexOutputProfile, CodeIndexUnitPlan, } from "./codeIndexPlan.js";
|
|
5
|
+
export type { CodeIndexCapability, CodeIndexCapabilityGap, CodeIndexCoverageKind, CodeIndexInspectionAdapter, CodeIndexInspectionContext, CodeIndexInspectionFinding, CodeIndexInspectionFindingKind, CodeIndexInspectionInventory, CodeIndexInspectionResult, CodeIndexLifecycle, CodeIndexModuleFacet, CodeIndexModuleType, CodeIndexOutputProfile, CodeIndexUnitPlan, } from "./codeIndexPlan.js";
|
|
6
6
|
import type { DocumentSourceDefinition, DocumentSourceType, FileSourceDefinition, FileSourceReference, LarkSourceDefinition, LarkSourceReference, RepoProjectSourceDefinition, SourceCollectionReference, SourceDefinition } from "./sources.js";
|
|
7
7
|
export type PhaseResourceReference = {
|
|
8
8
|
kind: "source";
|
|
@@ -64,7 +64,7 @@ export type ExtractTsPhaseDefinition = {
|
|
|
64
64
|
reads: readonly PhaseResourceReference[];
|
|
65
65
|
writes: readonly PhaseResourceReference[];
|
|
66
66
|
source: RepoProjectSourceDefinition;
|
|
67
|
-
collection:
|
|
67
|
+
collection: CodeIndexCollection;
|
|
68
68
|
include: readonly string[];
|
|
69
69
|
mode: "exports" | "scan";
|
|
70
70
|
entries?: readonly string[];
|
|
@@ -82,7 +82,9 @@ export type ExtractTsPhaseDefinition = {
|
|
|
82
82
|
export interface CustomCodeEvidence {
|
|
83
83
|
source: string;
|
|
84
84
|
file: string;
|
|
85
|
+
/** Stable canonical-ref token. Do not include ':' or '@'; keep exact signatures in Section prose. */
|
|
85
86
|
symbol: string;
|
|
87
|
+
/** Stable canonical-ref token. Do not include ':' or '@'. */
|
|
86
88
|
kind: string;
|
|
87
89
|
digest: string;
|
|
88
90
|
line?: number;
|
|
@@ -106,6 +108,7 @@ export interface CustomCodeCandidateSection {
|
|
|
106
108
|
id: string;
|
|
107
109
|
kind: CodeIndexCoverageKind;
|
|
108
110
|
title: string;
|
|
111
|
+
/** Reader-facing Section body only. Context renders the heading from title. */
|
|
109
112
|
markdown: string;
|
|
110
113
|
evidence: readonly CustomCodeEvidence[];
|
|
111
114
|
}
|
|
@@ -114,9 +117,8 @@ export interface CustomCodeCandidateDraft {
|
|
|
114
117
|
kind: string;
|
|
115
118
|
visibility: string;
|
|
116
119
|
module: string;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
sections?: readonly CustomCodeCandidateSection[];
|
|
120
|
+
/** Required evidence-scoped sections used to render the page and prove output-profile coverage. */
|
|
121
|
+
sections: readonly CustomCodeCandidateSection[];
|
|
120
122
|
evidence: readonly CustomCodeEvidence[];
|
|
121
123
|
review: CustomCodeCandidateReview;
|
|
122
124
|
edges?: readonly CustomCodeCandidateEdge[];
|
|
@@ -141,7 +143,7 @@ export type ExtractCustomPhaseDefinition = {
|
|
|
141
143
|
reads: readonly PhaseResourceReference[];
|
|
142
144
|
writes: readonly PhaseResourceReference[];
|
|
143
145
|
sources: readonly RepoProjectSourceDefinition[];
|
|
144
|
-
collection:
|
|
146
|
+
collection: CodeIndexCollection;
|
|
145
147
|
indexPlan: "declared" | "inferred";
|
|
146
148
|
indexUnits: readonly CodeIndexUnitPlan[];
|
|
147
149
|
inspect?: CodeIndexInspectionAdapter;
|
|
@@ -239,7 +241,7 @@ export declare const compileProse: (definition: {
|
|
|
239
241
|
}) => CompileProsePhaseDefinition;
|
|
240
242
|
export declare const extractTs: (definition: {
|
|
241
243
|
source: RepoProjectSourceDefinition;
|
|
242
|
-
collection:
|
|
244
|
+
collection: CodeIndexCollection;
|
|
243
245
|
include?: readonly string[];
|
|
244
246
|
mode?: "exports" | "scan";
|
|
245
247
|
entries?: readonly string[];
|
|
@@ -250,7 +252,7 @@ export declare const extractTs: (definition: {
|
|
|
250
252
|
export declare const extractCustom: (definition: {
|
|
251
253
|
id: string;
|
|
252
254
|
sources: readonly RepoProjectSourceDefinition[];
|
|
253
|
-
collection:
|
|
255
|
+
collection: CodeIndexCollection;
|
|
254
256
|
indexUnits?: readonly CodeIndexUnitPlan[];
|
|
255
257
|
inspect?: CodeIndexInspectionAdapter;
|
|
256
258
|
extract: CustomCodeExtractor;
|
|
@@ -18,7 +18,7 @@ Selected OKF root directories such as `{{wikisRoot}}/`, `{{guidesRoot}}/`,
|
|
|
18
18
|
`{{rulesRoot}}/`, and `{{featsRoot}}/` follow an OKF-compatible Context profile:
|
|
19
19
|
OKF fields and Context extension fields stay at the top level, and no `context`
|
|
20
20
|
or `schema` field is emitted. Root mapping:
|
|
21
|
-
`{{wikisRoot}}/` maps from structured `
|
|
21
|
+
`{{wikisRoot}}/` maps from structured `codeindex`, `business`, and `product` knowledge;
|
|
22
22
|
`{{guidesRoot}}/` maps from `architecture`, `sop`, `faq`, `decision`, and `incident`;
|
|
23
23
|
`{{rulesRoot}}/` maps from `standards` and `test`; `{{featsRoot}}/` maps from `feats`. Treat
|
|
24
24
|
`{{wikisRoot}}/` as the entity-and-relationship layer; guides and rules may
|
|
@@ -29,7 +29,7 @@ as evidence rather than relying on memory or frontmatter summaries.
|
|
|
29
29
|
|
|
30
30
|
| Root | Use |
|
|
31
31
|
|---|---|
|
|
32
|
-
| `{{wikisRoot}}/` | Structured entities and relationships from
|
|
32
|
+
| `{{wikisRoot}}/` | Structured entities and relationships from codeindex, business, and product knowledge. |
|
|
33
33
|
| `{{guidesRoot}}/` | Architecture, procedures, FAQs, decisions, incidents, and troubleshooting. |
|
|
34
34
|
| `{{rulesRoot}}/` | Standards, constraints, acceptance criteria, and test scenarios. |
|
|
35
35
|
| `{{featsRoot}}/` | Feature knowledge when selected into the package. |
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
包内可能包含以下 OKF 根目录:
|
|
16
16
|
|
|
17
|
-
- `{{wikisRoot}}/`:结构化实体和关系,对应
|
|
17
|
+
- `{{wikisRoot}}/`:结构化实体和关系,对应 codeindex、business、product。
|
|
18
18
|
- `{{guidesRoot}}/`:架构、流程、FAQ、决策和故障记录。
|
|
19
19
|
- `{{rulesRoot}}/`:标准、约束、验收条件和测试场景。
|
|
20
20
|
- `{{featsRoot}}/`:被选择进入包内的功能知识。
|
|
@@ -20,7 +20,7 @@ description: 查询 {{displayName}} 中经过审核、可追溯来源的知识
|
|
|
20
20
|
|
|
21
21
|
| 根目录 | 用途 |
|
|
22
22
|
|---|---|
|
|
23
|
-
| `{{wikisRoot}}/` | 来自
|
|
23
|
+
| `{{wikisRoot}}/` | 来自 codeindex、business、product 的结构化实体和关系。 |
|
|
24
24
|
| `{{guidesRoot}}/` | 架构、流程、FAQ、决策、故障和排障说明。 |
|
|
25
25
|
| `{{rulesRoot}}/` | 标准、约束、验收条件和测试场景。 |
|
|
26
26
|
| `{{featsRoot}}/` | 被选择进入包内的功能知识。 |
|