@c4a/context 0.6.0-alpha.1
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 +100 -0
- package/contracts.d.ts +31 -0
- package/docs/README.md +39 -0
- package/docs/getting-started.md +320 -0
- package/docs/guides/agent-dialogue.md +325 -0
- package/docs/guides/agent-guide.md +313 -0
- package/docs/guides/package-outputs.md +171 -0
- package/docs/reference/package-templates.md +274 -0
- package/docs/reference/project-api.md +326 -0
- package/docs/reference/template-variables.md +225 -0
- package/documentEvidence.d.ts +17 -0
- package/index.d.ts +55 -0
- package/index.js +11810 -0
- package/package.json +11 -0
- package/phases.d.ts +169 -0
- package/sources.d.ts +138 -0
- package/templates/package-templates/kb/AGENTS.md +31 -0
- package/templates/package-templates/kb/skills/knowledge-query/SKILL.md +204 -0
- package/templates/package-templates/kb/wikis/index.md +43 -0
- package/templates/package-templates/llms/llms.txt +9 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Package Outputs
|
|
2
|
+
|
|
3
|
+
Package outputs are generated folders under `dist/`. They turn approved
|
|
4
|
+
knowledge from `knowledge/` into a shape that another consumer can install,
|
|
5
|
+
read, or import.
|
|
6
|
+
|
|
7
|
+
Package output is a human decision gate. Do not add package declarations until
|
|
8
|
+
the user chooses the intended consumer and output shape.
|
|
9
|
+
|
|
10
|
+
Package build consumes approved and closed knowledge. If status reports that
|
|
11
|
+
close is required, run deterministic close before build. Current close derives
|
|
12
|
+
`knowledge/structure.yaml`, persists approved edge projection, and runs the
|
|
13
|
+
final verify gate without rewriting approved Markdown. References, changelog,
|
|
14
|
+
package index, and section fingerprint rebuilds are not current close output.
|
|
15
|
+
|
|
16
|
+
## Recommended First Output: Agent Knowledge-Base Package
|
|
17
|
+
|
|
18
|
+
Choose an agent knowledge-base package first when the knowledge should help
|
|
19
|
+
Coding Agents work with the project. After the user chooses this semantic
|
|
20
|
+
output shape, implement it with `kbPackage()`.
|
|
21
|
+
|
|
22
|
+
Typical output:
|
|
23
|
+
|
|
24
|
+
```text
|
|
25
|
+
dist/<package-name>/
|
|
26
|
+
├── AGENTS.md
|
|
27
|
+
├── skills/
|
|
28
|
+
│ └── knowledge-query/
|
|
29
|
+
│ └── SKILL.md
|
|
30
|
+
└── wikis/
|
|
31
|
+
├── index.md
|
|
32
|
+
└── ...
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Choose this when the user wants:
|
|
36
|
+
|
|
37
|
+
- agent-facing guidance generated from the reviewed knowledge;
|
|
38
|
+
- a package that can be installed as an agent knowledge base;
|
|
39
|
+
- a starting point that can later be refined into task-specific skills.
|
|
40
|
+
|
|
41
|
+
The underlying `kbPackage()` declaration requires a template containing at
|
|
42
|
+
least one `SKILL.md` and `wikis/index.md`.
|
|
43
|
+
The default `src/package-templates/kb/` template is only a starting point.
|
|
44
|
+
Inspect the generated `dist/<package-name>/` before calling it usable.
|
|
45
|
+
|
|
46
|
+
The default `knowledge-query` skill carries the structure-first query
|
|
47
|
+
discipline: start from OKF directory indexes, use
|
|
48
|
+
`context-build-inventory.json` edge records for package-visible relationships,
|
|
49
|
+
inspect page `sources` / `context:section` source_ref metadata, cite
|
|
50
|
+
page/section evidence, and report explicit gaps when the package does not cover
|
|
51
|
+
a requested fact. It does not treat direct grep over bundled OKF root
|
|
52
|
+
directories as the primary discovery path. Users can edit any template file
|
|
53
|
+
under `src/package-templates/kb/` before build to create their own skills,
|
|
54
|
+
prompts, routing rules, or package instructions.
|
|
55
|
+
|
|
56
|
+
The generated `wikis/` directory is the default OKF root and follows the C4A OKF
|
|
57
|
+
Profile. Internal production collections are mapped into package OKF roots such
|
|
58
|
+
as `wikis/`, `guides/`, `rules/`, or `feats/`; when selected, `context build`
|
|
59
|
+
copies them into the package and generates root-aware directory indexes for them
|
|
60
|
+
as well. These roots contain Markdown with OKF fields and C4A extension fields at
|
|
61
|
+
the top level, plus
|
|
62
|
+
`context:section` source_ref span comments. C4A extension fields such as `sources`,
|
|
63
|
+
`visibility`, and `code_symbols` are not nested under `context`, and page
|
|
64
|
+
frontmatter does not contain `source_refs`. The package root is an agent
|
|
65
|
+
package; the OKF-compatible interchange surface is the selected OKF root
|
|
66
|
+
subtrees under `dist/<package-name>/`, with `wikis/index.md` as the required
|
|
67
|
+
default KB entry.
|
|
68
|
+
|
|
69
|
+
`index.md` is reserved for OKF bundle and directory indexes. Source documents
|
|
70
|
+
may be named `index.md`, but generated concept pages must use a non-reserved
|
|
71
|
+
name such as `index-page.md`; `context build` rejects copied knowledge that
|
|
72
|
+
occupies `wikis/**/index.md`.
|
|
73
|
+
|
|
74
|
+
`src/package-templates/kb/wikis/index.md` is the bundle entry page template.
|
|
75
|
+
Tell the user it can be edited before build to describe the package scope,
|
|
76
|
+
intended users, and query guidance.
|
|
77
|
+
|
|
78
|
+
The default root index is a starter, not a finished information architecture.
|
|
79
|
+
It lists the next-level directories and lets `context build` generate child
|
|
80
|
+
`index.md` files under selected OKF roots. Use Handlebars variables such as
|
|
81
|
+
`knowledgeGroups`, `knowledgeItems`, and `knowledgeTree` when a project needs
|
|
82
|
+
custom navigation. Before customizing it, read
|
|
83
|
+
`node_modules/@c4a/context/docs/reference/template-variables.md`.
|
|
84
|
+
|
|
85
|
+
Template paths are rendered before selected knowledge is copied. A rendered
|
|
86
|
+
template path must not collide with a selected knowledge path. If the build
|
|
87
|
+
reports a collision, rename the template file or exclude that knowledge path
|
|
88
|
+
with `select.exclude`.
|
|
89
|
+
|
|
90
|
+
Template prose must not become a second knowledge source. If a template
|
|
91
|
+
describes package coverage, scope, known gaps, or known limits, it must cite
|
|
92
|
+
approved knowledge, `context-build-inventory.json`, or rendered structure data
|
|
93
|
+
inside the package. Otherwise `context build` reports a template-boundary
|
|
94
|
+
diagnostic. Repair the template under `src/package-templates/`; do not patch
|
|
95
|
+
`dist/` as the durable fix.
|
|
96
|
+
|
|
97
|
+
KB package index links are also checked. `context build` validates
|
|
98
|
+
`wikis/index.md` and generated child `index.md` files so relative links and OKF
|
|
99
|
+
bundle-root absolute links such as `/wikis/<group>/index.md` resolve inside
|
|
100
|
+
`dist/<package-name>/`. Broken index links are fixed by editing the template,
|
|
101
|
+
approved knowledge path, or package declaration and rerunning `context build`;
|
|
102
|
+
do not patch `dist/` directly as the durable fix.
|
|
103
|
+
|
|
104
|
+
## Alternative Output: LLM Text
|
|
105
|
+
|
|
106
|
+
Choose an LLM text bundle when the user wants a single text bundle for model
|
|
107
|
+
context, RAG import, or manual reading. After the user chooses this semantic
|
|
108
|
+
output shape, implement it with `llmsPackage()`.
|
|
109
|
+
|
|
110
|
+
Typical output:
|
|
111
|
+
|
|
112
|
+
```text
|
|
113
|
+
dist/<package-name>/
|
|
114
|
+
└── llms.txt
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Choose this when the user wants:
|
|
118
|
+
|
|
119
|
+
- one consolidated text file;
|
|
120
|
+
- a format that is easy to copy, index, or upload elsewhere;
|
|
121
|
+
- no agent skill packaging yet.
|
|
122
|
+
|
|
123
|
+
## Skip Package Output
|
|
124
|
+
|
|
125
|
+
The user may choose to stop after approved Markdown. In that case, keep
|
|
126
|
+
`packages: []` and do not run `context build`.
|
|
127
|
+
|
|
128
|
+
Approved knowledge still lives in:
|
|
129
|
+
|
|
130
|
+
```text
|
|
131
|
+
knowledge/
|
|
132
|
+
└── ...
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## How To Ask The User
|
|
136
|
+
|
|
137
|
+
When `context status` is `needs-package-output`, explain the choices with the output
|
|
138
|
+
tree. Do not ask the user to pick from unexplained labels.
|
|
139
|
+
Use the host's native multi-choice tool when available. If unavailable, fall
|
|
140
|
+
back to a short Markdown A/B/C question. The option labels should be:
|
|
141
|
+
agent knowledge-base package, LLM text bundle, and skip package output for now.
|
|
142
|
+
|
|
143
|
+
Recommended question shape:
|
|
144
|
+
|
|
145
|
+
```text
|
|
146
|
+
The reviewed knowledge is approved. The next decision is how to package it.
|
|
147
|
+
|
|
148
|
+
Recommended: agent knowledge-base package
|
|
149
|
+
dist/<name>-kb/
|
|
150
|
+
├── AGENTS.md
|
|
151
|
+
├── skills/knowledge-query/SKILL.md
|
|
152
|
+
└── wikis/
|
|
153
|
+
├── index.md
|
|
154
|
+
├── <group>/index.md
|
|
155
|
+
└── <group>/...
|
|
156
|
+
|
|
157
|
+
This is best if agents should use the knowledge as a reusable knowledge base.
|
|
158
|
+
|
|
159
|
+
Alternative: LLM text bundle
|
|
160
|
+
dist/<name>-llms/
|
|
161
|
+
└── llms.txt
|
|
162
|
+
|
|
163
|
+
This is best if you need one text bundle for model/RAG import.
|
|
164
|
+
|
|
165
|
+
We can also skip package output for now and keep only knowledge/.
|
|
166
|
+
|
|
167
|
+
Which one should I declare first?
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Do not offer `both` as a shortcut. If the user wants multiple outputs, add one
|
|
171
|
+
package first, verify the shape, then add another package after confirmation.
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# Package Templates
|
|
2
|
+
|
|
3
|
+
Packages project approved knowledge into `dist/<package-name>/`.
|
|
4
|
+
|
|
5
|
+
For the user-facing decision process, read
|
|
6
|
+
[Package Outputs](../guides/package-outputs.md) first. This reference only
|
|
7
|
+
documents the API and template behavior.
|
|
8
|
+
|
|
9
|
+
## Package Factories
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { llmsPackage, kbPackage } from "@c4a/context";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### `kbPackage`
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
kbPackage({
|
|
19
|
+
name: "component-lib-kb",
|
|
20
|
+
template: {
|
|
21
|
+
path: "src/package-templates/kb",
|
|
22
|
+
vars: { displayName: "Component Library KB" },
|
|
23
|
+
},
|
|
24
|
+
select: {
|
|
25
|
+
collections: ["architecture", "sop"],
|
|
26
|
+
okfRoots: ["wikis", "guides"],
|
|
27
|
+
include: ["architecture/component-lib/**", "sop/component-lib/**"],
|
|
28
|
+
exclude: ["**/internal/**"],
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### `llmsPackage`
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
llmsPackage({
|
|
37
|
+
name: "component-lib-llms",
|
|
38
|
+
template: "src/package-templates/llms",
|
|
39
|
+
select: { include: ["codegraph/component-lib/**"] },
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Required Fields
|
|
44
|
+
|
|
45
|
+
| Field | Required | Meaning |
|
|
46
|
+
|---|---:|---|
|
|
47
|
+
| `name` | yes | Lowercase path-safe package name. Output goes to `dist/<name>/`. |
|
|
48
|
+
| `template` | yes | Project-relative template directory or `{ path, vars }`. |
|
|
49
|
+
| `select` | no | Approved knowledge selector. Omit to include all approved knowledge. Supports internal `collections`, OKF `okfRoots`, and `include` / `exclude` path patterns relative to `knowledge/`. |
|
|
50
|
+
|
|
51
|
+
`template` is required. Do not call `kbPackage({ name })` or
|
|
52
|
+
`llmsPackage({ name })`.
|
|
53
|
+
|
|
54
|
+
## Template Variables
|
|
55
|
+
|
|
56
|
+
Templates are rendered with Handlebars. Variables are available in both file
|
|
57
|
+
contents and file paths.
|
|
58
|
+
|
|
59
|
+
Built-in variables:
|
|
60
|
+
|
|
61
|
+
| Variable | Meaning |
|
|
62
|
+
|---|---|
|
|
63
|
+
| `{{packageName}}` | Package name from the declaration. |
|
|
64
|
+
| `{{packageKind}}` | `kb` or `llms`. |
|
|
65
|
+
| `{{displayName}}` | Display name. Defaults to a title-cased `packageName`; override with `template.vars.displayName`. |
|
|
66
|
+
| `{{knowledgeCount}}` | Number of selected approved Markdown files. |
|
|
67
|
+
| `{{knowledgeTimestamp}}` | Latest `timestamp` from selected approved Markdown, or `1970-01-01T00:00:00.000Z` when empty. |
|
|
68
|
+
| `{{knowledge}}` | Concatenated selected approved Markdown bundle. |
|
|
69
|
+
| `{{approvedKnowledge}}` | Alias for `{{knowledge}}`. |
|
|
70
|
+
| `{{knowledgeItems}}` | Array of selected approved knowledge page metadata for loops. |
|
|
71
|
+
| `{{knowledgeGroups}}` | Selected approved knowledge pages grouped by OKF root and first directory segment; each item also exposes `internal_collection`. |
|
|
72
|
+
| `{{knowledgeTreeNodes}}` | Nested path tree for custom navigation. |
|
|
73
|
+
| `{{knowledgeTree}}` | Markdown tree preview. |
|
|
74
|
+
| `{{knowledgeItemsMarkdown}}` | Markdown page list. |
|
|
75
|
+
| `{{knowledgeGroupsMarkdown}}` | Markdown first-level group list with links to OKF root index paths. |
|
|
76
|
+
|
|
77
|
+
Custom variables come from `template.vars`.
|
|
78
|
+
|
|
79
|
+
For loops, conditionals, comments, and record fields, read
|
|
80
|
+
[Template Variables](./template-variables.md).
|
|
81
|
+
|
|
82
|
+
## Template Examples
|
|
83
|
+
|
|
84
|
+
Installed examples:
|
|
85
|
+
|
|
86
|
+
```text
|
|
87
|
+
node_modules/@c4a/context/templates/package-templates/kb/
|
|
88
|
+
node_modules/@c4a/context/templates/package-templates/llms/
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Workspace convention:
|
|
92
|
+
|
|
93
|
+
```text
|
|
94
|
+
src/package-templates/
|
|
95
|
+
├── kb/
|
|
96
|
+
│ ├── AGENTS.md
|
|
97
|
+
│ ├── wikis/
|
|
98
|
+
│ │ └── index.md
|
|
99
|
+
│ └── skills/
|
|
100
|
+
│ └── knowledge-query/
|
|
101
|
+
│ └── SKILL.md
|
|
102
|
+
└── llms/
|
|
103
|
+
└── llms.txt
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`kbPackage()` is for an agent knowledge-base package. The package still uses a
|
|
107
|
+
`skills/` folder internally because Claude/Codex consume reusable agent
|
|
108
|
+
instructions from that convention. Its template must contain at least one
|
|
109
|
+
`SKILL.md` file and `wikis/index.md`. A template with only `AGENTS.md` is a
|
|
110
|
+
placeholder document package, not a usable kb package, and `context build`
|
|
111
|
+
rejects it.
|
|
112
|
+
|
|
113
|
+
The default kb template includes:
|
|
114
|
+
|
|
115
|
+
- `skills/knowledge-query/SKILL.md`, a reusable skill that teaches agents to
|
|
116
|
+
query copied knowledge pages structure-first, cite page/section evidence, use
|
|
117
|
+
`context-build-inventory.json` edge records for package-visible
|
|
118
|
+
relationships, and report gaps instead of inventing unsupported answers. The
|
|
119
|
+
default entry OKF root is `wikis/`; packages that select additional internal
|
|
120
|
+
collections expose
|
|
121
|
+
`guides/`, `rules/`, or `feats/` indexes when those roots are selected.
|
|
122
|
+
- `wikis/index.md`, the editable OKF bundle entry page for the generated
|
|
123
|
+
`dist/<package-name>/wikis/` directory.
|
|
124
|
+
|
|
125
|
+
During `context build`, the root `wikis/index.md` is rendered from the template.
|
|
126
|
+
The builder also creates `index.md` files for directories under selected OKF
|
|
127
|
+
roots when a directory does not already contain one. Keep OKF root indexes
|
|
128
|
+
shallow by default: link to the next-level directories there, then let
|
|
129
|
+
child indexes expose their own subdirectories and pages.
|
|
130
|
+
|
|
131
|
+
## OKF Directory Indexes
|
|
132
|
+
|
|
133
|
+
The generated `dist/<package-name>/wikis/` tree is the required default KB
|
|
134
|
+
entry surface. Internal collections are mapped into OKF roots during build:
|
|
135
|
+
wiki-like collections under `wikis/`, guide-like collections under `guides/`,
|
|
136
|
+
rule-like collections under `rules/`, and feature namespace output under
|
|
137
|
+
`feats/`.
|
|
138
|
+
|
|
139
|
+
Default navigation rules:
|
|
140
|
+
|
|
141
|
+
- `wikis/index.md` is the required default bundle index. It should describe the
|
|
142
|
+
package and list only the next-level directories. Other selected OKF roots
|
|
143
|
+
use their own `<okf-root>/index.md` when present or generated.
|
|
144
|
+
- `<okf-root>/<group>/index.md` and deeper directory indexes are generated by
|
|
145
|
+
`context build` when missing.
|
|
146
|
+
- A generated directory index uses OKF frontmatter with `type: Knowledge
|
|
147
|
+
Directory`, `title`, `description`, `tags`, `timestamp`, `resource`,
|
|
148
|
+
`package`, `package_kind`, and `knowledge_count`.
|
|
149
|
+
- Directory indexes list child directories first, then pages directly under the
|
|
150
|
+
directory.
|
|
151
|
+
- `context build` validates links in OKF root indexes and generated
|
|
152
|
+
child `index.md` files. Relative links must resolve to files inside
|
|
153
|
+
`dist/<package-name>/`; broken links are reported as
|
|
154
|
+
`package/index-link-invalid`.
|
|
155
|
+
- If a project needs curated default navigation, edit the template-owned
|
|
156
|
+
`wikis/index.md`. Child `<okf-root>/**/index.md` paths are generated
|
|
157
|
+
directory indexes; template files or copied knowledge pages that collide with
|
|
158
|
+
those paths are rejected during build/status preflight.
|
|
159
|
+
|
|
160
|
+
Users are expected to customize these template files. Edit
|
|
161
|
+
`src/package-templates/kb/**` before `context build` to define project
|
|
162
|
+
specific skills, prompts, routing rules, and package instructions. Do not add a
|
|
163
|
+
package-name skill by default; add one only when the user wants project-specific
|
|
164
|
+
behavior beyond knowledge lookup.
|
|
165
|
+
|
|
166
|
+
## C4A OKF Profile
|
|
167
|
+
|
|
168
|
+
Approved Markdown and kb package OKF output are an OKF superset:
|
|
169
|
+
|
|
170
|
+
- top-level YAML frontmatter uses OKF fields such as `type`, `title`,
|
|
171
|
+
`description`, `tags`, `timestamp`, and `resource`;
|
|
172
|
+
- C4A extension metadata such as `sources`, `visibility`, and `code_symbols`
|
|
173
|
+
also lives at the top level;
|
|
174
|
+
- do not nest C4A extension metadata under `context`; fields such as
|
|
175
|
+
`context.sources` and `context.code_symbols` are not part of the 0.6 profile;
|
|
176
|
+
- section provenance lives in `<!-- context:section ... source_ref="..." -->`
|
|
177
|
+
comments;
|
|
178
|
+
- do not add frontmatter `source_refs`; page-level provenance is derived from
|
|
179
|
+
section source refs when needed;
|
|
180
|
+
- do not add `context` or `schema` fields.
|
|
181
|
+
|
|
182
|
+
Accepted section `source_ref` forms:
|
|
183
|
+
|
|
184
|
+
```text
|
|
185
|
+
src-N#symbol:<symbol-id>:<kind>@<digest>
|
|
186
|
+
src-N#span:<heading-hint> L<start>-<end>@<span-hash>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
`#span:` refs retain source snapshot line ranges for human review, diffing, and
|
|
190
|
+
stable re-pinning. They resolve against committed file/lark document snapshots,
|
|
191
|
+
not the code symbol index.
|
|
192
|
+
|
|
193
|
+
The kb package root may contain agent files such as `AGENTS.md` and `skills/`.
|
|
194
|
+
The OKF-compatible surface is the selected `wikis/`, `guides/`, `rules/`, and
|
|
195
|
+
`feats/` subtrees.
|
|
196
|
+
|
|
197
|
+
## Build Behavior
|
|
198
|
+
|
|
199
|
+
`context build`:
|
|
200
|
+
|
|
201
|
+
1. Selects approved Markdown from `knowledge/`.
|
|
202
|
+
2. Renders all files from `template.path`.
|
|
203
|
+
3. Copies selected approved Markdown into the package output.
|
|
204
|
+
4. For `llmsPackage`, appends selected knowledge to `llms.txt` when the template
|
|
205
|
+
does not already use `{{knowledge}}` or `{{approvedKnowledge}}`.
|
|
206
|
+
5. Writes deterministic package inventory such as
|
|
207
|
+
`context-build-inventory.json`.
|
|
208
|
+
6. Writes output under `dist/<package-name>/`.
|
|
209
|
+
|
|
210
|
+
`context-build-inventory.json` records what was selected and why. Each selected
|
|
211
|
+
file includes `selected_by` entries such as `{ "kind": "collection" }`,
|
|
212
|
+
`{ "kind": "okf_root" }`, `{ "kind": "include" }`, or
|
|
213
|
+
`{ "kind": "default" }`. The inventory also exposes package-visible typed
|
|
214
|
+
edges under `structure.edge_records`; these records are filtered to edges whose
|
|
215
|
+
endpoints are present in the selected package. Use those edge records for
|
|
216
|
+
relationship citations inside the package instead of assuming the workspace
|
|
217
|
+
`knowledge/structure.yaml` file is bundled.
|
|
218
|
+
|
|
219
|
+
Build expects approved knowledge to be closed when the project has source-bound
|
|
220
|
+
document knowledge. If status says `compile-close-needed`, run
|
|
221
|
+
`context close --format json` before build. Current close derives
|
|
222
|
+
`knowledge/structure.yaml`, persists approved edge projection, and runs the
|
|
223
|
+
final verify gate. References, changelog, package index, and section
|
|
224
|
+
fingerprint rebuilds are not current close output; build only packages the
|
|
225
|
+
current closed state.
|
|
226
|
+
|
|
227
|
+
Before writing output, `context build` validates that rendered template paths
|
|
228
|
+
are safe, unique, and do not collide with copied knowledge paths. For example,
|
|
229
|
+
a template file that renders to `wikis/codegraph/foo.md` is rejected if
|
|
230
|
+
selected knowledge such as `knowledge/codegraph/foo.md` maps to that same OKF
|
|
231
|
+
output path. Rename the template file or use `select.exclude` when the
|
|
232
|
+
collision is intentional.
|
|
233
|
+
|
|
234
|
+
After writing KB output, `context build` checks selected OKF root `index.md`
|
|
235
|
+
files and generated child directory indexes. If an index link is broken, fix
|
|
236
|
+
the package template, approved knowledge path, or directory index generation,
|
|
237
|
+
then rerun `context build`; do not patch `dist/` directly as the durable fix.
|
|
238
|
+
|
|
239
|
+
If a template describes package coverage, scope, known gaps, or known limits,
|
|
240
|
+
it must cite approved knowledge, `context-build-inventory.json`, or
|
|
241
|
+
explicitly rendered structure data. Otherwise build reports a
|
|
242
|
+
template-boundary diagnostic. Keep factual claims in approved knowledge and
|
|
243
|
+
structure; templates only package and route that material.
|
|
244
|
+
|
|
245
|
+
After build, inspect the output shape. `context build` and `context verify`
|
|
246
|
+
validate protocol structure; they do not decide whether the selected knowledge
|
|
247
|
+
is meaningful enough for the user.
|
|
248
|
+
|
|
249
|
+
## Select Patterns
|
|
250
|
+
|
|
251
|
+
Package selection is evaluated in this order:
|
|
252
|
+
|
|
253
|
+
1. `collections` filters by internal approved collection, for example
|
|
254
|
+
`architecture`, `sop`, `standards`, or `feats`.
|
|
255
|
+
2. `okfRoots` filters by output root after OKF mapping: `wikis`, `guides`,
|
|
256
|
+
`rules`, or `feats`.
|
|
257
|
+
3. `include` patterns are matched against approved paths relative to
|
|
258
|
+
`knowledge/`.
|
|
259
|
+
4. `exclude` patterns remove matches after the previous filters.
|
|
260
|
+
|
|
261
|
+
Path patterns are relative to `knowledge/`.
|
|
262
|
+
|
|
263
|
+
```ts
|
|
264
|
+
select: {
|
|
265
|
+
collections: ["architecture", "sop"],
|
|
266
|
+
okfRoots: ["wikis", "guides"],
|
|
267
|
+
include: ["architecture/component-lib/**", "sop/component-lib/**"],
|
|
268
|
+
exclude: ["**/internal/**"],
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
If `include` is omitted, all approved knowledge is included unless excluded.
|
|
273
|
+
When `collections` or `okfRoots` are present, a file must pass those filters
|
|
274
|
+
before include/exclude path matching is considered.
|