@c4a/context 0.6.1-beta.2 → 0.6.1-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -117,11 +117,12 @@ include `{{packageName}}`, `{{displayName}}`, `{{knowledgeCount}}`,
117
117
  `{{knowledgeGroups}}`, `{{knowledgeItems}}`, `{{knowledgeTree}}`, and
118
118
  `{{buildInventory}}`.
119
119
 
120
- Every KB package defaults `distribution.knowledgeNamespace` to its package
121
- `name`, producing a short single-level knowledge directory. Set the field
122
- explicitly when a multi-segment namespace such as
123
- `personal-user.123/package` is required. Context isolates OKF roots under the
124
- complete value; Skill names remain author-maintained and independent.
120
+ Every KB package emits flat roots such as `wikis/`, `guides/`, `rules/`, and
121
+ `feats/`. The package `name` defines only the `dist/<package-name>/` boundary;
122
+ it is not repeated inside knowledge paths. Context still accepts
123
+ `distribution.knowledgeNamespace` from older workspaces, but the legacy value
124
+ no longer changes build output and new declarations do not need it. Skill names
125
+ remain author-maintained and independent.
125
126
 
126
127
  For advanced routing and retrieval, a template may carry a local script such as
127
128
  `query.ts`, with a Skill describing when and how an Agent should call it. The
@@ -134,7 +135,8 @@ The SDK stays declarative. It may describe reads, writes, phases, review, and
134
135
  package selection, but the CLI owns source materialization, capture, extraction,
135
136
  review application, approved Markdown materialization, verification, and build.
136
137
  Do not replace CLI lifecycle operations with direct edits to `sources/`,
137
- `unapproved/`, `knowledge/`, or `dist/`.
138
+ `knowledge/`, `dist/`, or the ignored `.tmp/context-runtime/lifecycle/` runtime
139
+ state. The CLI owns that runtime state and removes it after a successful close.
138
140
 
139
141
  ## Documentation
140
142
 
package/README.zh-CN.md CHANGED
@@ -97,15 +97,16 @@ kb/
97
97
 
98
98
  模板使用 Handlebars 变量,可以作用于文件内容和路径。常用变量包括 `{{packageName}}`、`{{displayName}}`、`{{knowledgeCount}}`、`{{knowledgeGroups}}`、`{{knowledgeItems}}`、`{{knowledgeTree}}` 和 `{{buildInventory}}`。
99
99
 
100
- 每个 KB 包默认使用包 `name` 作为 `distribution.knowledgeNamespace`,生成简短的
101
- 单级知识目录。需要 `personal-user.123/package` 这类多段目录时可以显式配置该字段。
102
- Context 会按照完整 namespace 隔离各个 OKF 根目录;Skill 名称仍由作者独立维护。
100
+ 每个 KB 包直接输出扁平的 `wikis/`、`guides/`、`rules/`、`feats/` 等根目录;包 `name`
101
+ 只用于确定 `dist/<package-name>/` 边界,不会再次写入知识路径。旧工作区中的
102
+ `distribution.knowledgeNamespace` 仍可被读取,但不再改变构建结果;新声明无需配置它。
103
+ Skill 名称继续由作者独立维护。
103
104
 
104
105
  如果需要更强的路由和检索能力,模板可以携带 `query.ts` 一类本地脚本,再由 Skill 约定 Agent 何时、如何调用。Skill 也可以把 Agent 路由到 MCP、CLI 或其他工具,组成适合当前知识包的 Agentic Search 流程。
105
106
 
106
107
  ## 状态边界
107
108
 
108
- SDK 只负责声明。它可以描述读取、写入、阶段、审核和知识包选择,但来源物化、内容读取、代码提取、审核应用、正式知识写入、质量验证和构建都由 CLI 负责。不要通过直接编辑 `sources/`、`unapproved/`、`knowledge/` `dist/` 来替代 CLI 生命周期操作。
109
+ SDK 只负责声明。它可以描述读取、写入、阶段、审核和知识包选择,但来源物化、内容读取、代码提取、审核应用、正式知识写入、质量验证和构建都由 CLI 负责。不要通过直接编辑 `sources/`、`knowledge/`、`dist/` 或被忽略的 `.tmp/context-runtime/lifecycle/` 运行态来替代 CLI 生命周期操作;成功 close 后 CLI 会清理该运行态。
109
110
 
110
111
  ## 参考文档
111
112
 
@@ -13,10 +13,21 @@ bun install
13
13
  context status --format json
14
14
  ```
15
15
 
16
+ Use `--language zh-CN` (or `--language en`) during initialization when the
17
+ generated README, AGENTS contract, and package starter templates should use a
18
+ specific language. Context stores this choice in `package.json`; it does not
19
+ guess from the shell locale or Agent conversation.
20
+
16
21
  Use `--dev` when testing a local link or prepared pack before the matching SDK
17
22
  version is published. It writes a `file:` dependency to the SDK resolved beside
18
23
  the active CLI. Published users can omit it and install the versioned SDK from
19
24
  the registry.
25
+
26
+ Without `project-dir`, init uses the dedicated `context/` directory. Initializing
27
+ inside a non-empty directory that is not already a Context workspace is blocked
28
+ before any files are written; use the returned `--allow-nonempty` command only
29
+ after confirming that the existing files should share the workspace root.
30
+
20
31
  When operating through an Agent plugin, use the installed Context continuation
21
32
  entry from the project root after initialization. It consumes
22
33
  `workflow.current`, loads only the selected resources, and calls lower-level
@@ -216,7 +227,7 @@ continuation entry. The
216
227
  normal sequence is:
217
228
 
218
229
  1. capture the source into committed snapshots;
219
- 2. investigate evidence and confirm `unapproved/structure.yaml`;
230
+ 2. investigate evidence and confirm the CLI-managed lifecycle structure;
220
231
  3. compile every source-bound View from confirmed structure;
221
232
  4. review/apply the complete candidate batch once;
222
233
  5. run close once, then verify and build when packages are declared.
@@ -287,18 +298,21 @@ context review html architecture --open
287
298
  Use the generated HTML page to approve or reject candidates. If the browser does
288
299
  not open automatically, use the emitted `file://` URL. When
289
300
  finished, open `Payload` and copy the review decision Payload into the agent chat.
290
- Uniform decisions use one JSON line; exceptions add JSONL lines. The
291
- agent writes that pasted payload to a normal temporary file under the workspace
292
- `.tmp/` directory and runs:
301
+ Uniform decisions use one JSON line; exceptions add JSONL lines. The agent
302
+ writes that pasted payload to the recommended workspace scratch area,
303
+ `.tmp/agent-payloads/`, and runs:
293
304
 
294
305
  ```bash
295
306
  context review apply <payload-file>
296
307
  ```
297
308
 
298
309
  Do not hand-write approved Markdown. `context review apply` owns materialization
299
- from `unapproved/entities.jsonl` into `knowledge/`.
300
- Do not store review payloads through scratch files outside `.tmp/` or by
301
- editing workspace config.
310
+ from the CLI-managed lifecycle candidate ledger into `knowledge/`. The runtime
311
+ ledger is ignored and is removed after a successful close; durable rejected
312
+ candidate fingerprints, when any, are kept in `knowledge/decisions.json`.
313
+ The location is a recommendation rather than a CLI restriction. Do not create a
314
+ top-level scratch directory or edit workspace config merely to retain a review
315
+ payload.
302
316
 
303
317
  ## 5. Build Packages
304
318
 
@@ -326,14 +340,11 @@ Choose an agent knowledge-base package when agents should consume the reviewed
326
340
  knowledge as a reusable package. After the user chooses this output shape,
327
341
  declare it with `kbPackage()`.
328
342
 
329
- The package name becomes its stable single-level knowledge namespace by
330
- default. Ask for a custom namespace only when the user needs another value. An
331
- explicit namespace may contain several concise lowercase path segments, such
332
- as `group/package` or `personal-user.123/package`; each segment may use letters
333
- and numbers joined by hyphens or dots. Do not infer custom values from
334
- downstream platform identifiers. Ask separately whether the author wants a
335
- short Skill prefix, then maintain the complete final Skill directory name in
336
- the template.
343
+ The package name already identifies the surrounding `dist/` directory. The OKF
344
+ roots inside it stay flat (`wikis/`, `guides/`, `rules/`, and `feats/`), so do
345
+ not ask for a second distribution namespace. Ask separately whether the author
346
+ wants a short Skill prefix, then maintain the complete final Skill directory
347
+ name in the template.
337
348
 
338
349
  The default `knowledge-query` skill teaches agents how to query copied OKF root
339
350
  directories structure-first, starting with `wikis/`, cite
@@ -30,6 +30,14 @@ without another question. Review uses the CLI's atomic `context review
30
30
  approve-all ... --managed` route; valid structure staging records
31
31
  `confirmed_by: managed-session`.
32
32
 
33
+ After the first managed status evaluation, use
34
+ `context run --managed --until blocked-or-complete --format json` when the
35
+ current work can advance through consecutive mechanical routes. The CLI
36
+ executes only a unique immediate non-read command, re-evaluates after each
37
+ receipt, and stops before Agent interpretation, configuration, missing
38
+ authority, diagnostics, or multiple commands. Continue from the returned
39
+ `workflow.current`.
40
+
33
41
  This is execution authority, not project configuration. Do not add it to
34
42
  `defineProject`, environment files, or committed workspace state, and do not
35
43
  carry it into a new conversation. It never grants a new source boundary or
@@ -68,11 +76,21 @@ node_modules/@c4a/context/docs/reference/package-templates.md
68
76
 
69
77
  - `src/index.ts` declares sources, phases, and packages.
70
78
  - `sources/repo/index.yaml`, `sources/file/index.yaml`, and `sources/lark/index.yaml` declare sources.
71
- - `unapproved/entities.jsonl` is the committed draft/rejected/deprecated ledger.
72
- - `knowledge/` contains approved Markdown.
79
+ - `.tmp/context-runtime/lifecycle/` is the ignored, CLI-managed draft candidate
80
+ ledger and confirmed structure state for an open lifecycle round.
81
+ - `knowledge/` contains approved Markdown, the durable
82
+ `knowledge/structure.yaml` projection, and (only when needed) the compact
83
+ `knowledge/decisions.json` rejected candidate ID-to-fingerprint map.
84
+ - `knowledge/structure.yaml.source_inputs` contains only source, collection,
85
+ and consumed snapshot hash for closed prose targets. It lets status detect a
86
+ changed or unfinished target without retaining lifecycle snapshots.
73
87
  - `dist/` contains generated package outputs.
88
+ - `.tmp/agent-payloads/` is the recommended location for transient inputs written
89
+ by the Agent for CLI commands. It is not enforced, but avoids introducing
90
+ top-level scratch directories; remove these files after the corresponding
91
+ stage or apply succeeds unless the user explicitly wants to retain them.
74
92
  - file and Lark documents from one date live as sibling files under `sources/file/<date>/` and `sources/lark/<date>/`; each date directory has one shared `manifest.json`.
75
- - `.tmp/context-runtime/` contains ignored runtime cache, logs, review HTML, previews, and locks.
93
+ - `.tmp/context-runtime/` contains ignored runtime cache, logs, review HTML, previews, and locks. Successful close removes completed lifecycle and review runtime state.
76
94
 
77
95
  Do not create hidden workspace state directories.
78
96
 
@@ -91,12 +109,12 @@ Present only the current workflow surface:
91
109
  | Register a knowledge boundary | `context source add file/lark/repo ...`, followed by the matching project phase declaration. Source registration is a user-confirmed boundary decision. |
92
110
  | Capture document sources | Run the declared `capture:file:<date>/<module>` or `capture:lark:<date>/<module>` phase only after read permission. Capture writes a sibling document file under the matching date directory and updates that directory's single `manifest.json`. |
93
111
  | Investigate captured material | Use `context status` and the returned `context run align:<type>:<source>:<collection> --view ...` commands. Evidence views drive reading; raw directory grep is not the workflow. |
94
- | Confirm prose structure | `alignProse` validates and stages `unapproved/structure.yaml`. Validation does not equal user confirmation; only confirmed lifecycle state may enter prose compile. |
112
+ | Confirm prose structure | `alignProse` validates and stages CLI-managed lifecycle structure. Validation does not equal user confirmation; only confirmed lifecycle state may enter prose compile. |
95
113
  | Compile source-bound drafts | `compileProse` turns confirmed structure into source-bound draft pages. It does not approve knowledge. |
96
114
  | Review and apply | Use `context review html` and `context review apply`. Approved prose pages are source-mirrored; rewrite/compression problems should return to structure/compile repair before apply. |
97
115
  | Close, verify, build | Run `context close`, `context verify`, then `context build`. Close derives `knowledge/structure.yaml`, approved edge projection, and the final verify gate. |
98
116
  | Code extraction | Use `context source inspect <source-name>` and the declared extract phase preview before code draft writes. |
99
- | Source retraction | Follow the current status or lifecycle command if one exists. Do not delete `sources/`, `knowledge/`, `unapproved/`, `dist/`, or `.tmp` to simulate lifecycle actions. |
117
+ | Source retraction | Follow the current status or lifecycle command if one exists. Do not delete `sources/`, `knowledge/`, `dist/`, or `.tmp` to simulate lifecycle actions. |
100
118
 
101
119
  Judgment behavior is part of evidence views, source span resolvers, repair
102
120
  hints, review/status diagnostics, OKF indexes, and package query discipline. Do
@@ -127,8 +145,9 @@ align:lark:<source-name>:architecture
127
145
  dist/<source-name>-kb/
128
146
  ```
129
147
 
130
- Prose align/compile paths derive from collection and slug. `containment` is
131
- optional and should be supplied only for an intentional parent/child hierarchy;
148
+ Every prose View requires a stable filename `slug`. The CLI derives its path
149
+ from collection, slug, and optional `containment`; omit `path` from the input.
150
+ Supply `containment` only for an intentional parent/child hierarchy;
132
151
  independent collection entries stay directly under the collection.
133
152
  Codegraph paths use the registered date/module grouping before the symbol slug.
134
153
 
@@ -327,7 +346,7 @@ knowledge/codegraph/<module>/symbol/<slug>.md
327
346
  If the module or resulting path shape looks wrong, stop and repair the
328
347
  module registration before running extraction. An extra repeated package
329
348
  segment below the module may indicate an over-broad source boundary. Do not write ad hoc scripts to
330
- count packages, parse `package.json`, or sample `unapproved/entities.jsonl`.
349
+ count packages, parse `package.json`, or sample the lifecycle candidate ledger.
331
350
 
332
351
  ## Review Rules
333
352
 
@@ -372,6 +391,7 @@ context run align:<type>:<source>:<collection> --view read-plan --format json
372
391
  context run align:<type>:<source>:<collection> --view source-index --compact --format json
373
392
  context run align:<type>:<source>:<collection> --view span-detail --span <source-ref> --format json
374
393
  context run align:<type>:<source>:<collection> --view span-text --span <source-ref> --format json
394
+ context run align:<type>:<source>:<collection> --view existing-knowledge --query <title-or-stable-ref> --format json
375
395
  context run align:<type>:<source>:<collection> --view schema --format json
376
396
  context run align:<type>:<source>:<collection> --validate --input <structure.yaml> --format json
377
397
  context run align:<type>:<source>:<collection> --view structure-summary --input <structure.yaml> --format json
@@ -380,9 +400,12 @@ context run align:<type>:<source>:<collection> --stage --input <structure.yaml>
380
400
 
381
401
  Read source material only through these evidence views. `source-index` gives a
382
402
  compact refs-first map when run with `--compact`; use `span-detail` /
383
- `span-text` only for exact evidence. The CLI applies deterministic boundary
384
- repairs internally and returns only blockers that need Agent judgment. For
385
- oversized Views, use the returned structural diagnostics while classifying
403
+ `span-text` only for exact evidence. Before introducing a new Node identity,
404
+ use the targeted `existing-knowledge` View returned by the read plan to inspect
405
+ approved stable refs; do not inspect `knowledge/**` directly. The CLI applies
406
+ deterministic boundary repairs internally and returns only blockers that need
407
+ Agent judgment. For oversized Views, use the returned structural diagnostics
408
+ while classifying
386
409
  child Nodes from evidence. Stage only after validation state is `ready`; stage
387
410
  opens the final `structure-summary` report for the current Route's confirmation
388
411
  gate. Ask a separate structure-design question only when evidence supports
@@ -430,15 +453,11 @@ dist/<name>-kb/
430
453
  This is an agent knowledge-base package. It is the recommended first output for
431
454
  agent consumption; the internal `skills/` folder follows agent installation
432
455
  conventions.
433
- The package name is the default single-level
434
- `distribution.knowledgeNamespace`. Ask for an override only when the user
435
- needs another value; an explicit namespace may contain several concise
436
- lowercase path segments, such as `group/package` or
437
- `personal-user.123/package`, with letters and numbers joined by hyphens or
438
- dots. The namespace applies only to OKF output roots. Ask separately whether
439
- the author wants a short Skill prefix; if so, maintain the complete final Skill
440
- directory name in the template. Do not infer custom values from downstream
441
- platform identifiers.
456
+ The package name already identifies the surrounding `dist/` directory. Its OKF
457
+ roots stay flat (`wikis/`, `guides/`, `rules/`, and `feats/`), so do not ask for
458
+ a second distribution namespace. Ask separately whether the author wants a
459
+ short Skill prefix; if so, maintain the complete final Skill directory name in
460
+ the template.
442
461
  The default `knowledge-query` skill teaches agents to query copied OKF root
443
462
  directories structure-first, starting with `wikis/`, cite
444
463
  page/section evidence, use structure/build metadata when present, and report
@@ -43,8 +43,7 @@ least one `SKILL.md` and `wikis/index.md`.
43
43
  The default `src/package-templates/kb/` template is only a starting point.
44
44
  Inspect the generated `dist/<package-name>/` before calling it usable.
45
45
 
46
- KB packages use their package name as a single-level knowledge namespace by
47
- default:
46
+ KB packages use flat package-relative knowledge roots:
48
47
 
49
48
  ```ts
50
49
  kbPackage({
@@ -53,44 +52,43 @@ kbPackage({
53
52
  });
54
53
  ```
55
54
 
56
- This keeps the build folder name independent from install paths and produces
57
- paths such as:
55
+ The package name already identifies the surrounding build folder, so the
56
+ output does not repeat it inside each root:
58
57
 
59
58
  ```text
60
59
  skills/knowledge-query/SKILL.md
61
- wikis/component-lib-kb/index.md
62
- guides/component-lib-kb/...
63
- rules/component-lib-kb/...
64
- feats/component-lib-kb/...
60
+ wikis/index.md
61
+ guides/...
62
+ rules/...
63
+ feats/...
65
64
  ```
66
65
 
67
- Ask for a custom namespace only when the user needs something other than the
68
- package name. An explicit value may contain multiple safe lowercase path
69
- segments:
70
-
71
- ```ts
72
- distribution: { knowledgeNamespace: "platform/component-lib" }
73
- ```
74
-
75
- Each segment may contain letters and numbers joined by hyphens or dots; keep
76
- the complete value concise and stable. Context treats it as an opaque knowledge
77
- path and does not infer downstream platform identifiers or classify package
78
- content.
66
+ Do not ask for another distribution namespace. Older workspaces may still
67
+ contain `distribution.knowledgeNamespace`; Context accepts that legacy input
68
+ without using it to shape the package.
79
69
 
80
70
  Skill names are separate. Ask whether the author wants a short optional Skill
81
71
  prefix, then maintain the complete final template directory name directly—for
82
- example `skills/android-query/SKILL.md`. Context never prepends the knowledge
83
- namespace to a Skill name.
72
+ example `skills/android-query/SKILL.md`. Package-root layout never renames a
73
+ Skill.
84
74
 
85
- The default `knowledge-query` skill carries the structure-first query
86
- discipline: start from OKF directory indexes, use
75
+ The default `knowledge-query` Skill is a complete generic query entry. It
76
+ carries the structure-first query discipline: start from OKF directory indexes, use
87
77
  `context-build-inventory.json` edge records for package-visible relationships,
88
78
  inspect page `sources` / `context:section` source_ref metadata, cite
89
79
  page/section evidence, and report explicit gaps when the package does not cover
90
80
  a requested fact. It does not treat direct grep over bundled OKF root
91
- directories as the primary discovery path. Users can edit any template file
92
- under `src/package-templates/kb/` before build to create their own skills,
93
- prompts, routing rules, or package instructions.
81
+ directories as the primary discovery path. Its final template-author section
82
+ requires package authors to replace or edit the generic routing when the
83
+ package needs project-specific terminology, entry points, known limits, or
84
+ task workflows. Authors may explicitly accept the generic default when it is
85
+ intentionally sufficient.
86
+
87
+ The same inventory exposes `structure.relationship_coverage`. It records
88
+ whether selected codegraph pages have current source-backed AST relationship
89
+ metadata, how many codegraph views were selected, and how many package-visible
90
+ edges were emitted. An empty edge list is therefore explicit evidence of a
91
+ coverage state, not permission to invent a dependency.
94
92
 
95
93
  The generated `wikis/` directory is the default OKF root and follows the C4A OKF
96
94
  Profile. Internal production collections are mapped into package OKF roots such
@@ -103,9 +101,8 @@ contain Markdown with OKF fields and C4A extension fields at the top level, plus
103
101
  `visibility`, and `code_symbols` are not nested under `context`, and page
104
102
  frontmatter does not contain `source_refs`. The package root is an agent
105
103
  package; the OKF-compatible interchange surface is the selected OKF root
106
- subtrees under `dist/<package-name>/`. The required logical template entry is
107
- `wikis/index.md`; a namespaced package writes it to
108
- `wikis/<knowledge-namespace>/index.md`.
104
+ subtrees under `dist/<package-name>/`. The required template entry and final
105
+ output path are both `wikis/index.md`.
109
106
 
110
107
  Current collection mapping:
111
108
 
@@ -136,7 +133,8 @@ occupies `wikis/**/index.md`.
136
133
  Tell the user it can be edited before build to describe the package scope,
137
134
  intended users, and query guidance.
138
135
 
139
- The default root index is a starter, not a finished information architecture.
136
+ The default root index is a usable generic entry, not a project-specific
137
+ information architecture.
140
138
  It links directly to pages in small child directories and to a child
141
139
  `index.md` when that directory exceeds the configured navigation threshold.
142
140
  The default threshold is 50 selected knowledge pages. Use Handlebars variables such as
@@ -144,6 +142,13 @@ The default threshold is 50 selected knowledge pages. Use Handlebars variables s
144
142
  custom navigation. Before customizing it, read
145
143
  `node_modules/@c4a/context/docs/reference/template-variables.md`.
146
144
 
145
+ Newly initialized generic templates must be replaced, edited, or explicitly
146
+ accepted before the first build. `context status` exposes that choice as a
147
+ package template Review Gate. Use only the revision-bound command returned by
148
+ that Route to accept an unchanged generic default; edit files under
149
+ `src/package-templates/` when customizing. Context compares file digests and
150
+ records the decision without evaluating the meaning of template prose.
151
+
147
152
  Template paths are rendered before selected knowledge is copied. A rendered
148
153
  template path must not collide with a selected knowledge path. If the build
149
154
  reports a collision, rename the template file or exclude that knowledge path
@@ -230,12 +235,10 @@ We can also skip package output for now and keep only knowledge/.
230
235
  Which one should I declare first?
231
236
  ```
232
237
 
233
- If the user chooses the Agent knowledge-base package, explain that its package
234
- name is already the default knowledge namespace. Ask for an override only when
235
- the user needs a different single- or multi-segment path. Ask separately whether
236
- its Skills need a short prefix. Treat these as independent choices: the
237
- knowledge namespace controls only OKF roots, while the author maintains final
238
- Skill names.
238
+ If the user chooses the Agent knowledge-base package, explain that its OKF
239
+ roots are flat within `dist/<package-name>/`; do not ask for a second namespace.
240
+ Ask whether its Skills need a short prefix. The author maintains final Skill
241
+ names independently from package paths.
239
242
 
240
243
  Do not offer `both` as a shortcut. If the user wants multiple outputs, add one
241
244
  package first, verify the shape, then add another package after confirmation.
@@ -52,20 +52,15 @@ llmsPackage({
52
52
  | `template` | yes | Project-relative template directory or `{ path, vars }`. |
53
53
  | `select` | no | Approved knowledge selector. Omit to include all approved knowledge. Supports internal `collections`, OKF `okfRoots`, and `include` / `exclude` path patterns relative to `knowledge/`. |
54
54
  | `navigation` | no | KB directory-index policy. Defaults to `{ foldDirectoryIndexes: true, maxInlineEntries: 50 }`. |
55
- | `distribution` | no | Final knowledge-root namespace for a KB package. Defaults to `{ knowledgeNamespace: name }`; set it explicitly for a custom single- or multi-segment path. |
55
+ | `distribution` | no | Legacy input accepted from older workspaces. It no longer changes package paths and should not be added to new declarations. |
56
56
 
57
57
  `template` is required. Do not call `kbPackage({ name })` or
58
58
  `llmsPackage({ name })`.
59
59
 
60
- ## Knowledge Distribution Namespace
60
+ ## Flat Package Roots
61
61
 
62
- `name` identifies the build folder under `dist/` and is also the default
63
- single-level `distribution.knowledgeNamespace`. An explicit namespace may be
64
- one segment or a slash-separated sequence of safe lowercase path segments. A
65
- segment may contain letters and numbers joined by hyphens or dots, allowing
66
- identifiers such as `personal-user.123/package`. Keep every segment short,
67
- stable, and recognizable. Context treats the complete value as an opaque
68
- knowledge path and does not assign downstream meanings to individual segments.
62
+ `name` identifies the package boundary under `dist/`. Context does not repeat
63
+ that name inside the package's knowledge roots.
69
64
 
70
65
  Templates keep a logical, consumer-neutral layout:
71
66
 
@@ -77,39 +72,32 @@ rules/...
77
72
  feats/...
78
73
  ```
79
74
 
80
- For `name: "component-lib-kb"` with no explicit distribution, `context build`
81
- writes:
75
+ For `name: "component-lib-kb"`, `context build` writes:
82
76
 
83
77
  ```text
84
78
  skills/knowledge-query/SKILL.md
85
- wikis/component-lib-kb/index.md
86
- guides/component-lib-kb/...
87
- rules/component-lib-kb/...
88
- feats/component-lib-kb/...
79
+ wikis/index.md
80
+ guides/...
81
+ rules/...
82
+ feats/...
89
83
  ```
90
84
 
91
- The builder applies the knowledge mapping to template paths, copied knowledge,
92
- generated indexes, links, and inventory records. It does not apply the
93
- knowledge namespace to `skills/`, rewrite Markdown prose, or infer path
94
- segments from downstream platform identifiers. An explicit
95
- `distribution: { knowledgeNamespace: "platform/component-lib" }` produces the
96
- same shape under that multi-segment namespace instead.
97
-
98
- Because every KB package has a knowledge namespace, Skill templates must not
99
- hard-code flat package paths such as `wikis/index.md` or
100
- `rules/standards/index.md`.
101
- Use `{{wikisRoot}}`, `{{rulesRoot}}`, `{{guidesRoot}}`, or `{{featsRoot}}`
102
- instead. `context build` and `context status` reject flat Markdown links and
103
- inline-code paths in `skills/**/*.md` with
104
- `package/template-namespace-reference-flat`. This check is generic package
105
- validation; it does not depend on a downstream registry or distribution tool.
85
+ The builder maps copied knowledge, generated indexes, links, and inventory
86
+ records into these roots without rewriting Markdown prose or inferring a
87
+ downstream registry identity. New declarations should omit `distribution`.
88
+ Older declarations that still contain `distribution.knowledgeNamespace` remain
89
+ loadable, but the value does not change output paths or the build fingerprint.
90
+
91
+ Use `{{wikisRoot}}`, `{{rulesRoot}}`, `{{guidesRoot}}`, or `{{featsRoot}}` in
92
+ Skill templates so references share the package-root contract. These variables
93
+ render to the flat root names above.
106
94
 
107
95
  Each rendered Skill must live at `skills/<skill-name>/SKILL.md`, and its YAML
108
96
  frontmatter `name` must equal `<skill-name>`. Use `{{skillName}}` in custom
109
97
  Skill templates. Skill names are author-maintained: when a short prefix is
110
98
  useful, rename the template directory to the complete final name, such as
111
99
  `skills/android-query/`; Context does not derive it from
112
- `knowledgeNamespace`.
100
+ the package name.
113
101
 
114
102
  ## Template Variables
115
103
 
@@ -122,8 +110,8 @@ Built-in variables:
122
110
  |---|---|
123
111
  | `{{packageName}}` | Package name from the declaration. |
124
112
  | `{{packageKind}}` | `kb` or `llms`. |
125
- | `{{knowledgeNamespace}}` | Final KB knowledge namespace. Defaults to the package name; empty only for non-KB packages. |
126
- | `{{namespacedKnowledge}}` | Whether the package is a KB package with a knowledge namespace. |
113
+ | `{{knowledgeNamespace}}` | Legacy configured namespace when an older workspace still declares one; otherwise empty. Do not use it for new output paths. |
114
+ | `{{namespacedKnowledge}}` | Always `false`; retained only so older templates remain renderable. |
127
115
  | `{{skillName}}` | Current author-maintained Skill directory name. |
128
116
  | `{{skillPath}}` | Current Skill's final package-relative `SKILL.md` path. |
129
117
  | `{{wikisRoot}}`, `{{guidesRoot}}`, `{{rulesRoot}}`, `{{featsRoot}}` | Final package-relative OKF root paths. |
@@ -181,14 +169,14 @@ The default kb template includes:
181
169
  query copied knowledge pages structure-first, cite page/section evidence, use
182
170
  `context-build-inventory.json` edge records for package-visible
183
171
  relationships, and report gaps instead of inventing unsupported answers. The
172
+ build inventory also exposes `structure.relationship_coverage` so a consumer
173
+ can distinguish an observed zero-edge result from unknown relationship
174
+ coverage. The
184
175
  default entry OKF root is `wikis/`; packages that select additional internal
185
176
  collections expose
186
177
  `guides/`, `rules/`, or `feats/` indexes when those roots are selected.
187
178
  - `wikis/index.md`, the editable OKF bundle entry page for the generated
188
- `dist/<package-name>/wikis/<knowledge-namespace>/` directory.
189
-
190
- These are logical template paths. The package distribution namespace changes
191
- their final output paths as described above.
179
+ `dist/<package-name>/wikis/` directory.
192
180
 
193
181
  During `context build`, the root `wikis/index.md` is rendered from the template.
194
182
  The builder always provides an index for every selected OKF root. With the
@@ -199,7 +187,7 @@ its pages instead of producing one index per path segment.
199
187
  ## OKF Directory Indexes
200
188
 
201
189
  The generated
202
- `dist/<package-name>/wikis/<knowledge-namespace>/` tree is the required default
190
+ `dist/<package-name>/wikis/` tree is the required default
203
191
  KB entry surface. Internal collections are mapped into OKF roots during build:
204
192
  `codegraph`, `business`, and `product` go to `wikis/`; `architecture`, `sop`,
205
193
  `faq`, `decision`, and `incident` go to `guides/`; `standards` and `test` go to
@@ -235,11 +223,13 @@ Default navigation rules:
235
223
  an index path selected by the current navigation policy are rejected during
236
224
  build/status preflight.
237
225
 
238
- Users are expected to customize these template files. Edit
239
- `src/package-templates/kb/**` before `context build` to define project
240
- specific skills, prompts, routing rules, and package instructions. Do not add a
241
- package-name skill by default; add one only when the user wants project-specific
242
- behavior beyond knowledge lookup.
226
+ The generated templates are complete generic defaults. Before publishing,
227
+ package authors should replace or edit `src/package-templates/kb/**` when the
228
+ package needs project-specific skills, prompts, routing rules, terminology, or
229
+ package instructions. If the generic behavior is intentionally sufficient,
230
+ explicitly accept the unchanged default through the package-template Review
231
+ Route. Do not add a package-name Skill by default; add one only when the user
232
+ wants project-specific behavior beyond knowledge lookup.
243
233
 
244
234
  ## C4A OKF Profile
245
235
 
@@ -301,11 +291,9 @@ relationship citations inside the package instead of assuming the workspace
301
291
  `knowledge/structure.yaml` file is bundled.
302
292
 
303
293
  For KB packages, the inventory records `package.distribution` as
304
- `layout: "namespaced"` with the final `knowledge_namespace` and OKF root paths.
305
- Non-KB package types can remain `layout: "flat"`. Selected file and group
306
- records expose both the logical `okf_root` and final `okf_root_path`, so
307
- installers can inspect the layout without parsing paths or rewriting package
308
- content.
294
+ `layout: "flat"`, `knowledge_namespace: null`, and the four package-relative
295
+ OKF roots. Selected file and group records expose both the logical `okf_root`
296
+ and final `okf_root_path`, so consumers do not need to infer paths.
309
297
 
310
298
  Build expects approved knowledge to be closed when the project has source-bound
311
299
  document knowledge. When `workflow.current.reason_code` is