@c4a/context 0.6.1 → 0.6.3
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 +25 -6
- package/README.zh-CN.md +128 -0
- package/contracts.d.ts +5 -0
- package/docs/README.md +24 -8
- package/docs/getting-started.md +81 -35
- package/docs/guides/agent-dialogue.md +38 -350
- package/docs/guides/agent-guide.md +144 -94
- package/docs/guides/lark-resources.md +115 -0
- package/docs/guides/package-outputs.md +95 -25
- package/docs/reference/package-templates.md +121 -32
- package/docs/reference/project-api.md +261 -84
- package/docs/reference/template-variables.md +32 -15
- package/index.d.ts +13 -5
- package/index.js +113 -29
- package/package.json +4 -1
- package/phases.d.ts +75 -6
- package/templates/package-templates/kb/AGENTS.md +13 -16
- package/templates/package-templates/kb/skills/knowledge-query/SKILL.md +102 -177
- package/templates/package-templates/kb/skills/knowledge-query/scripts/search.mjs +268 -0
- package/templates/package-templates/kb/wikis/index.md +8 -8
- package/templates/package-templates/llms/llms.txt +0 -1
- package/templates/package-templates.zh-CN/kb/AGENTS.md +30 -0
- package/templates/package-templates.zh-CN/kb/skills/knowledge-query/SKILL.md +99 -0
- package/templates/package-templates.zh-CN/kb/skills/knowledge-query/scripts/search.mjs +268 -0
- package/templates/package-templates.zh-CN/kb/wikis/index.md +39 -0
- package/templates/package-templates.zh-CN/llms/llms.txt +8 -0
- package/templates/project-skills/maintain-project-knowledge/SKILL.md +58 -0
- package/templates/project-skills.zh-CN/maintain-project-knowledge/SKILL.md +48 -0
|
@@ -43,28 +43,80 @@ 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
|
-
|
|
47
|
-
|
|
46
|
+
KB packages use flat package-relative knowledge roots:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
kbPackage({
|
|
50
|
+
name: "component-lib-kb",
|
|
51
|
+
template: "src/package-templates/kb",
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The package name already identifies the surrounding build folder, so the
|
|
56
|
+
output does not repeat it inside each root:
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
skills/knowledge-query/SKILL.md
|
|
60
|
+
wikis/index.md
|
|
61
|
+
guides/...
|
|
62
|
+
rules/...
|
|
63
|
+
feats/...
|
|
64
|
+
others/assets/...
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Do not ask for another distribution namespace. Older workspaces may still
|
|
68
|
+
contain `distribution.knowledgeNamespace`; Context accepts that legacy input
|
|
69
|
+
without using it to shape the package.
|
|
70
|
+
|
|
71
|
+
Skill names are separate. Ask whether the author wants a short optional Skill
|
|
72
|
+
prefix, then maintain the complete final template directory name directly—for
|
|
73
|
+
example `skills/android-query/SKILL.md`. Package-root layout never renames a
|
|
74
|
+
Skill.
|
|
75
|
+
|
|
76
|
+
The default `knowledge-query` Skill is a complete generic query entry. It
|
|
77
|
+
carries the structure-first query discipline: start from OKF directory indexes, use
|
|
48
78
|
`context-build-inventory.json` edge records for package-visible relationships,
|
|
49
79
|
inspect page `sources` / `context:section` source_ref metadata, cite
|
|
50
80
|
page/section evidence, and report explicit gaps when the package does not cover
|
|
51
81
|
a requested fact. It does not treat direct grep over bundled OKF root
|
|
52
|
-
directories as the primary discovery path.
|
|
53
|
-
|
|
54
|
-
|
|
82
|
+
directories as the primary discovery path. When indexes do not narrow the
|
|
83
|
+
scope, or a candidate page is too large to read directly, its bundled
|
|
84
|
+
`scripts/search.mjs` provides deterministic BM25 ranking over mechanically
|
|
85
|
+
bounded Markdown chunks. Search results are leads; page bodies and typed edge
|
|
86
|
+
records remain the evidence. Its final template-author section
|
|
87
|
+
requires package authors to replace or edit the generic routing when the
|
|
88
|
+
package needs project-specific terminology, entry points, known limits, or
|
|
89
|
+
task workflows. Authors may explicitly accept the generic default when it is
|
|
90
|
+
intentionally sufficient.
|
|
91
|
+
|
|
92
|
+
When approved pages reference materialized document resources, Context keeps
|
|
93
|
+
their production copies in content-addressed `knowledge/assets/` paths. Build
|
|
94
|
+
copies only the resources selected by package pages to `others/assets/` and
|
|
95
|
+
rewrites relative Markdown links. Source audit XML and capture reports stay in
|
|
96
|
+
the production workspace; they are not distributed as reader assets. See
|
|
97
|
+
[Lark Resource Materialization](./lark-resources.md).
|
|
98
|
+
|
|
99
|
+
The same inventory exposes `structure.relationship_coverage`. It records
|
|
100
|
+
whether selected codegraph pages have current source-backed AST relationship
|
|
101
|
+
metadata, how many codegraph views were selected, and how many package-visible
|
|
102
|
+
edges were emitted. An empty edge list is therefore explicit evidence of a
|
|
103
|
+
coverage state, not permission to invent a dependency.
|
|
55
104
|
|
|
56
105
|
The generated `wikis/` directory is the default OKF root and follows the C4A OKF
|
|
57
106
|
Profile. Internal production collections are mapped into package OKF roots such
|
|
58
107
|
as `wikis/`, `guides/`, `rules/`, or `feats/`; when selected, `context build`
|
|
59
108
|
copies them into the package and generates root-aware directory indexes for them
|
|
60
|
-
as
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
109
|
+
as needed. Selected OKF roots always have an index; smaller child directories
|
|
110
|
+
are folded into their nearest generated ancestor index by default. These roots
|
|
111
|
+
contain consumer-oriented Markdown with reader-facing frontmatter and no Context
|
|
112
|
+
lifecycle comments. Node identity, source metadata, code symbol lists,
|
|
113
|
+
relationship records, generated-child records, and candidate fingerprints are
|
|
114
|
+
kept out of each page. `context-build-inventory.json` maps distributed paths to
|
|
115
|
+
approved knowledge paths and exposes package-visible structure; exact Section
|
|
116
|
+
evidence remains in the mapped `knowledge/` page. The package root is an agent
|
|
65
117
|
package; the OKF-compatible interchange surface is the selected OKF root
|
|
66
|
-
subtrees under `dist/<package-name
|
|
67
|
-
|
|
118
|
+
subtrees under `dist/<package-name>/`. The required template entry and final
|
|
119
|
+
output path are both `wikis/index.md`.
|
|
68
120
|
|
|
69
121
|
Current collection mapping:
|
|
70
122
|
|
|
@@ -95,13 +147,22 @@ occupies `wikis/**/index.md`.
|
|
|
95
147
|
Tell the user it can be edited before build to describe the package scope,
|
|
96
148
|
intended users, and query guidance.
|
|
97
149
|
|
|
98
|
-
The default root index is a
|
|
99
|
-
|
|
100
|
-
|
|
150
|
+
The default root index is a usable generic entry, not a project-specific
|
|
151
|
+
information architecture.
|
|
152
|
+
It links directly to pages in small child directories and to a child
|
|
153
|
+
`index.md` when that directory exceeds the configured navigation threshold.
|
|
154
|
+
The default threshold is 50 selected knowledge pages. Use Handlebars variables such as
|
|
101
155
|
`knowledgeGroups`, `knowledgeItems`, and `knowledgeTree` when a project needs
|
|
102
156
|
custom navigation. Before customizing it, read
|
|
103
157
|
`node_modules/@c4a/context/docs/reference/template-variables.md`.
|
|
104
158
|
|
|
159
|
+
Newly initialized generic templates must be replaced, edited, or explicitly
|
|
160
|
+
accepted before the first build. `context status` exposes that choice as a
|
|
161
|
+
package template Review Gate. Use only the revision-bound command returned by
|
|
162
|
+
that Route to accept an unchanged generic default; edit files under
|
|
163
|
+
`src/package-templates/` when customizing. Context compares file digests and
|
|
164
|
+
records the decision without evaluating the meaning of template prose.
|
|
165
|
+
|
|
105
166
|
Template paths are rendered before selected knowledge is copied. A rendered
|
|
106
167
|
template path must not collide with a selected knowledge path. If the build
|
|
107
168
|
reports a collision, rename the template file or exclude that knowledge path
|
|
@@ -114,12 +175,12 @@ inside the package. Otherwise `context build` reports a template-boundary
|
|
|
114
175
|
diagnostic. Repair the template under `src/package-templates/`; do not patch
|
|
115
176
|
`dist/` as the durable fix.
|
|
116
177
|
|
|
117
|
-
KB package index links are also checked. `context build` validates
|
|
118
|
-
|
|
119
|
-
bundle-root absolute links
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
178
|
+
KB package index links are also checked. `context build` validates every
|
|
179
|
+
selected OKF root index and generated child `index.md` so relative links and
|
|
180
|
+
OKF bundle-root absolute links resolve inside `dist/<package-name>/`. Broken
|
|
181
|
+
index links are fixed by editing the template, approved knowledge path, or
|
|
182
|
+
package declaration and rerunning `context build`; do not patch `dist/`
|
|
183
|
+
directly as the durable fix.
|
|
123
184
|
|
|
124
185
|
## Alternative Output: LLM Text
|
|
125
186
|
|
|
@@ -154,8 +215,9 @@ knowledge/
|
|
|
154
215
|
|
|
155
216
|
## How To Ask The User
|
|
156
217
|
|
|
157
|
-
When `
|
|
158
|
-
tree. Do not ask the user to pick from
|
|
218
|
+
When `workflow.current.reason_code` is `route.package.output-required`,
|
|
219
|
+
explain the choices with the output tree. Do not ask the user to pick from
|
|
220
|
+
unexplained labels.
|
|
159
221
|
Use the host's native multi-choice tool when available. If unavailable, fall
|
|
160
222
|
back to a short Markdown A/B/C question. The option labels should be:
|
|
161
223
|
agent knowledge-base package, LLM text bundle, and skip package output for now.
|
|
@@ -171,8 +233,8 @@ dist/<name>-kb/
|
|
|
171
233
|
├── skills/knowledge-query/SKILL.md
|
|
172
234
|
└── wikis/
|
|
173
235
|
├── index.md
|
|
174
|
-
├── <group
|
|
175
|
-
└── <group
|
|
236
|
+
├── <group-page>.md
|
|
237
|
+
└── <large-group>/index.md
|
|
176
238
|
|
|
177
239
|
This is best if agents should use the knowledge as a reusable knowledge base.
|
|
178
240
|
|
|
@@ -187,5 +249,13 @@ We can also skip package output for now and keep only knowledge/.
|
|
|
187
249
|
Which one should I declare first?
|
|
188
250
|
```
|
|
189
251
|
|
|
252
|
+
If the user chooses the Agent knowledge-base package, explain that its OKF
|
|
253
|
+
roots are flat within `dist/<package-name>/`; do not ask for a second namespace.
|
|
254
|
+
Ask whether its Skills need a short prefix. The author maintains final Skill
|
|
255
|
+
names independently from package paths.
|
|
256
|
+
|
|
190
257
|
Do not offer `both` as a shortcut. If the user wants multiple outputs, add one
|
|
191
258
|
package first, verify the shape, then add another package after confirmation.
|
|
259
|
+
The default adaptive index policy avoids one-page directory indexes. Configure
|
|
260
|
+
`kbPackage().navigation` when a package needs a different inline-entry
|
|
261
|
+
threshold or a fully expanded index at every directory.
|
|
@@ -27,6 +27,10 @@ kbPackage({
|
|
|
27
27
|
include: ["architecture/component-lib/**", "sop/component-lib/**"],
|
|
28
28
|
exclude: ["**/internal/**"],
|
|
29
29
|
},
|
|
30
|
+
navigation: {
|
|
31
|
+
foldDirectoryIndexes: true,
|
|
32
|
+
maxInlineEntries: 50,
|
|
33
|
+
},
|
|
30
34
|
});
|
|
31
35
|
```
|
|
32
36
|
|
|
@@ -47,10 +51,54 @@ llmsPackage({
|
|
|
47
51
|
| `name` | yes | Lowercase path-safe package name. Output goes to `dist/<name>/`. |
|
|
48
52
|
| `template` | yes | Project-relative template directory or `{ path, vars }`. |
|
|
49
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
|
+
| `navigation` | no | KB directory-index policy. Defaults to `{ foldDirectoryIndexes: true, maxInlineEntries: 50 }`. |
|
|
55
|
+
| `distribution` | no | Legacy input accepted from older workspaces. It no longer changes package paths and should not be added to new declarations. |
|
|
50
56
|
|
|
51
57
|
`template` is required. Do not call `kbPackage({ name })` or
|
|
52
58
|
`llmsPackage({ name })`.
|
|
53
59
|
|
|
60
|
+
## Flat Package Roots
|
|
61
|
+
|
|
62
|
+
`name` identifies the package boundary under `dist/`. Context does not repeat
|
|
63
|
+
that name inside the package's knowledge roots.
|
|
64
|
+
|
|
65
|
+
Templates keep a logical, consumer-neutral layout:
|
|
66
|
+
|
|
67
|
+
```text
|
|
68
|
+
skills/knowledge-query/SKILL.md
|
|
69
|
+
wikis/index.md
|
|
70
|
+
guides/...
|
|
71
|
+
rules/...
|
|
72
|
+
feats/...
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
For `name: "component-lib-kb"`, `context build` writes:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
skills/knowledge-query/SKILL.md
|
|
79
|
+
wikis/index.md
|
|
80
|
+
guides/...
|
|
81
|
+
rules/...
|
|
82
|
+
feats/...
|
|
83
|
+
```
|
|
84
|
+
|
|
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.
|
|
94
|
+
|
|
95
|
+
Each rendered Skill must live at `skills/<skill-name>/SKILL.md`, and its YAML
|
|
96
|
+
frontmatter `name` must equal `<skill-name>`. Use `{{skillName}}` in custom
|
|
97
|
+
Skill templates. Skill names are author-maintained: when a short prefix is
|
|
98
|
+
useful, rename the template directory to the complete final name, such as
|
|
99
|
+
`skills/android-query/`; Context does not derive it from
|
|
100
|
+
the package name.
|
|
101
|
+
|
|
54
102
|
## Template Variables
|
|
55
103
|
|
|
56
104
|
Templates are rendered with Handlebars. Variables are available in both file
|
|
@@ -62,6 +110,11 @@ Built-in variables:
|
|
|
62
110
|
|---|---|
|
|
63
111
|
| `{{packageName}}` | Package name from the declaration. |
|
|
64
112
|
| `{{packageKind}}` | `kb` or `llms`. |
|
|
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. |
|
|
115
|
+
| `{{skillName}}` | Current author-maintained Skill directory name. |
|
|
116
|
+
| `{{skillPath}}` | Current Skill's final package-relative `SKILL.md` path. |
|
|
117
|
+
| `{{wikisRoot}}`, `{{guidesRoot}}`, `{{rulesRoot}}`, `{{featsRoot}}` | Final package-relative OKF root paths. |
|
|
65
118
|
| `{{displayName}}` | Display name. Defaults to a title-cased `packageName`; override with `template.vars.displayName`. |
|
|
66
119
|
| `{{knowledgeCount}}` | Number of selected approved Markdown files. |
|
|
67
120
|
| `{{knowledgeTimestamp}}` | Latest `timestamp` from selected approved Markdown, or `1970-01-01T00:00:00.000Z` when empty. |
|
|
@@ -72,7 +125,7 @@ Built-in variables:
|
|
|
72
125
|
| `{{knowledgeTreeNodes}}` | Nested path tree for custom navigation. |
|
|
73
126
|
| `{{knowledgeTree}}` | Markdown tree preview. |
|
|
74
127
|
| `{{knowledgeItemsMarkdown}}` | Markdown page list. |
|
|
75
|
-
| `{{knowledgeGroupsMarkdown}}` | Markdown
|
|
128
|
+
| `{{knowledgeGroupsMarkdown}}` | Markdown navigation for the current index: direct page links for folded directories and links to generated indexes for expanded directories. |
|
|
76
129
|
|
|
77
130
|
Custom variables come from `template.vars`.
|
|
78
131
|
|
|
@@ -98,7 +151,9 @@ src/package-templates/
|
|
|
98
151
|
│ │ └── index.md
|
|
99
152
|
│ └── skills/
|
|
100
153
|
│ └── knowledge-query/
|
|
101
|
-
│
|
|
154
|
+
│ ├── SKILL.md
|
|
155
|
+
│ └── scripts/
|
|
156
|
+
│ └── search.mjs
|
|
102
157
|
└── llms/
|
|
103
158
|
└── llms.txt
|
|
104
159
|
```
|
|
@@ -116,22 +171,30 @@ The default kb template includes:
|
|
|
116
171
|
query copied knowledge pages structure-first, cite page/section evidence, use
|
|
117
172
|
`context-build-inventory.json` edge records for package-visible
|
|
118
173
|
relationships, and report gaps instead of inventing unsupported answers. The
|
|
174
|
+
build inventory also exposes `structure.relationship_coverage` so a consumer
|
|
175
|
+
can distinguish an observed zero-edge result from unknown relationship
|
|
176
|
+
coverage. The
|
|
119
177
|
default entry OKF root is `wikis/`; packages that select additional internal
|
|
120
178
|
collections expose
|
|
121
179
|
`guides/`, `rules/`, or `feats/` indexes when those roots are selected.
|
|
180
|
+
- `skills/knowledge-query/scripts/search.mjs`, a dependency-free BM25 fallback
|
|
181
|
+
for exact terms, mixed keyword queries, and large Markdown indexes. It chunks
|
|
182
|
+
mechanically, returns inspectable paths and line ranges, and never replaces
|
|
183
|
+
source-backed relationship evidence.
|
|
122
184
|
- `wikis/index.md`, the editable OKF bundle entry page for the generated
|
|
123
185
|
`dist/<package-name>/wikis/` directory.
|
|
124
186
|
|
|
125
187
|
During `context build`, the root `wikis/index.md` is rendered from the template.
|
|
126
|
-
The builder
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
188
|
+
The builder always provides an index for every selected OKF root. With the
|
|
189
|
+
default navigation policy, smaller child directories are folded into their
|
|
190
|
+
nearest generated ancestor index, so a short collection can link directly to
|
|
191
|
+
its pages instead of producing one index per path segment.
|
|
130
192
|
|
|
131
193
|
## OKF Directory Indexes
|
|
132
194
|
|
|
133
|
-
The generated
|
|
134
|
-
|
|
195
|
+
The generated
|
|
196
|
+
`dist/<package-name>/wikis/` tree is the required default
|
|
197
|
+
KB entry surface. Internal collections are mapped into OKF roots during build:
|
|
135
198
|
`codegraph`, `business`, and `product` go to `wikis/`; `architecture`, `sop`,
|
|
136
199
|
`faq`, `decision`, and `incident` go to `guides/`; `standards` and `test` go to
|
|
137
200
|
`rules/`; and `feats` goes to `feats/`. Treat `wikis/` as the structured
|
|
@@ -141,39 +204,48 @@ a relationship.
|
|
|
141
204
|
|
|
142
205
|
Default navigation rules:
|
|
143
206
|
|
|
144
|
-
- `wikis/index.md` is the required default bundle index.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
`
|
|
207
|
+
- `wikis/index.md` is the required default bundle index. Other selected OKF
|
|
208
|
+
roots always use their own `<okf-root>/index.md`.
|
|
209
|
+
- With `foldDirectoryIndexes: true`, a non-root directory gets its own
|
|
210
|
+
`index.md` only when its descendant knowledge-page count is greater than
|
|
211
|
+
`maxInlineEntries`. The default threshold is `50`.
|
|
212
|
+
- A folded directory is not discarded. Its pages are listed in the nearest
|
|
213
|
+
generated ancestor index, grouped by their relative directory path.
|
|
214
|
+
- The threshold counts selected knowledge pages in the path tree. It does not
|
|
215
|
+
inspect Markdown line counts, headings, or content semantics.
|
|
216
|
+
- Set `foldDirectoryIndexes: false` to generate an `index.md` for every
|
|
217
|
+
directory, matching the fully expanded navigation shape.
|
|
149
218
|
- A generated directory index uses OKF frontmatter with `type: Knowledge
|
|
150
219
|
Directory`, `title`, `description`, `tags`, `timestamp`, `resource`,
|
|
151
220
|
`package`, `package_kind`, and `knowledge_count`.
|
|
152
|
-
- Directory indexes list child
|
|
153
|
-
|
|
221
|
+
- Directory indexes list generated child indexes first, then pages from folded
|
|
222
|
+
paths.
|
|
154
223
|
- `context build` validates links in OKF root indexes and generated
|
|
155
224
|
child `index.md` files. Relative links must resolve to files inside
|
|
156
225
|
`dist/<package-name>/`; broken links are reported as
|
|
157
226
|
`package/index-link-invalid`.
|
|
158
227
|
- If a project needs curated default navigation, edit the template-owned
|
|
159
|
-
`wikis/index.md`.
|
|
160
|
-
|
|
161
|
-
|
|
228
|
+
`wikis/index.md`. Template files or copied knowledge pages that collide with
|
|
229
|
+
an index path selected by the current navigation policy are rejected during
|
|
230
|
+
build/status preflight.
|
|
162
231
|
|
|
163
|
-
|
|
164
|
-
`src/package-templates/kb/**`
|
|
165
|
-
specific skills, prompts, routing rules,
|
|
166
|
-
package
|
|
167
|
-
|
|
232
|
+
The generated templates are complete generic defaults. Before publishing,
|
|
233
|
+
package authors should replace or edit `src/package-templates/kb/**` when the
|
|
234
|
+
package needs project-specific skills, prompts, routing rules, terminology, or
|
|
235
|
+
package instructions. If the generic behavior is intentionally sufficient,
|
|
236
|
+
explicitly accept the unchanged default through the package-template Review
|
|
237
|
+
Route. Do not add a package-name Skill by default; add one only when the user
|
|
238
|
+
wants project-specific behavior beyond knowledge lookup.
|
|
168
239
|
|
|
169
|
-
##
|
|
240
|
+
## Context OKF Profiles
|
|
170
241
|
|
|
171
|
-
Approved Markdown
|
|
242
|
+
Approved Markdown under `knowledge/` is the production source of truth:
|
|
172
243
|
|
|
173
244
|
- top-level YAML frontmatter uses OKF fields such as `type`, `title`,
|
|
174
245
|
`description`, `tags`, `timestamp`, and `resource`;
|
|
175
|
-
-
|
|
176
|
-
|
|
246
|
+
- Context production metadata such as `sources`, `node_type`, `visibility`,
|
|
247
|
+
`code_symbols`, relationship records, and `candidate_fingerprint` also lives
|
|
248
|
+
at the top level;
|
|
177
249
|
- do not nest C4A extension metadata under `context`; fields such as
|
|
178
250
|
`context.sources` and `context.code_symbols` are not part of the 0.6 profile;
|
|
179
251
|
- section provenance lives in `<!-- context:section ... source_ref="..." -->`
|
|
@@ -182,6 +254,15 @@ Approved Markdown and kb package OKF output are an OKF superset:
|
|
|
182
254
|
section source refs when needed;
|
|
183
255
|
- do not add `context` or `schema` fields.
|
|
184
256
|
|
|
257
|
+
Package knowledge pages under `dist/<package-name>/` use a consumer projection.
|
|
258
|
+
They retain reader-facing fields such as `title`, `type`, `description`, `tags`,
|
|
259
|
+
`timestamp`, and custom non-lifecycle fields. Node identity, `resource`,
|
|
260
|
+
`sources`, Section evidence comments, and build-only fields are omitted from the
|
|
261
|
+
page. `context-build-inventory.json` records the distributed path, approved
|
|
262
|
+
knowledge path, node identity, source summary, and package-visible structure.
|
|
263
|
+
Maintainers return to the mapped `knowledge/` page for exact `sources` and
|
|
264
|
+
`source_ref` attribution. `knowledge/` is never rewritten by this projection.
|
|
265
|
+
|
|
185
266
|
Accepted section `source_ref` forms:
|
|
186
267
|
|
|
187
268
|
```text
|
|
@@ -191,7 +272,7 @@ src-N#span:<heading-hint> L<start>-<end>@<span-hash>
|
|
|
191
272
|
|
|
192
273
|
The code symbol form includes the source-relative file so same-name symbols in
|
|
193
274
|
different files resolve to one exact symbol-index row. Consumers should still
|
|
194
|
-
treat the complete `source_ref` as opaque.
|
|
275
|
+
treat the complete `source_ref` as opaque. Production codegraph pages keep
|
|
195
276
|
`candidate_fingerprint` at the top level and do not duplicate this evidence in
|
|
196
277
|
`code_origin`.
|
|
197
278
|
|
|
@@ -209,7 +290,7 @@ The OKF-compatible surface is the selected `wikis/`, `guides/`, `rules/`, and
|
|
|
209
290
|
|
|
210
291
|
1. Selects approved Markdown from `knowledge/`.
|
|
211
292
|
2. Renders all files from `template.path`.
|
|
212
|
-
3.
|
|
293
|
+
3. Projects selected approved Markdown into consumer-oriented package pages.
|
|
213
294
|
4. For `llmsPackage`, appends selected knowledge to `llms.txt` when the template
|
|
214
295
|
does not already use `{{knowledge}}` or `{{approvedKnowledge}}`.
|
|
215
296
|
5. Writes deterministic package inventory such as
|
|
@@ -217,7 +298,9 @@ The OKF-compatible surface is the selected `wikis/`, `guides/`, `rules/`, and
|
|
|
217
298
|
6. Writes output under `dist/<package-name>/`.
|
|
218
299
|
|
|
219
300
|
`context-build-inventory.json` records what was selected and why. Each selected
|
|
220
|
-
file includes `selected_by` entries such as `{ "kind": "collection" }
|
|
301
|
+
file includes `selected_by` entries such as `{ "kind": "collection" }` and a
|
|
302
|
+
`production_metadata` object for selected page-level production fields. Child
|
|
303
|
+
and relationship records use the inventory's canonical structure projection,
|
|
221
304
|
`{ "kind": "okf_root" }`, `{ "kind": "include" }`, or
|
|
222
305
|
`{ "kind": "default" }`. The inventory also exposes package-visible typed
|
|
223
306
|
edges under `structure.edge_records`; these records are filtered to edges whose
|
|
@@ -225,9 +308,15 @@ endpoints are present in the selected package. Use those edge records for
|
|
|
225
308
|
relationship citations inside the package instead of assuming the workspace
|
|
226
309
|
`knowledge/structure.yaml` file is bundled.
|
|
227
310
|
|
|
311
|
+
For KB packages, the inventory records `package.distribution` as
|
|
312
|
+
`layout: "flat"`, `knowledge_namespace: null`, and the four package-relative
|
|
313
|
+
OKF roots. Selected file and group records expose both the logical `okf_root`
|
|
314
|
+
and final `okf_root_path`, so consumers do not need to infer paths.
|
|
315
|
+
|
|
228
316
|
Build expects approved knowledge to be closed when the project has source-bound
|
|
229
|
-
document knowledge.
|
|
230
|
-
`
|
|
317
|
+
document knowledge. When `workflow.current.reason_code` is
|
|
318
|
+
`route.close.projection-stale`, run the exact returned close command. Current
|
|
319
|
+
close derives
|
|
231
320
|
`knowledge/structure.yaml`, persists approved edge projection, and runs the
|
|
232
321
|
final verify gate. References, changelog, package index, and section
|
|
233
322
|
fingerprint rebuilds are not current close output; build only packages the
|