@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
package/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# @c4a/context
|
|
2
|
+
|
|
3
|
+
`@c4a/context` is the project-local SDK for Context workspaces.
|
|
4
|
+
|
|
5
|
+
It provides the typed public surface used by `src/index.ts`: source references,
|
|
6
|
+
phase declarations, review declarations, package declarations, and template
|
|
7
|
+
metadata. `@c4a/context-cli` performs the filesystem side effects.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
Published users install through the workspace created by `context init`.
|
|
12
|
+
|
|
13
|
+
For local SDK development:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
./start.sh link
|
|
17
|
+
context init context --dev
|
|
18
|
+
cd context
|
|
19
|
+
bun install
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Tiny Example
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import {
|
|
26
|
+
defineProject,
|
|
27
|
+
extractTs,
|
|
28
|
+
reviewValidity,
|
|
29
|
+
kbPackage,
|
|
30
|
+
source,
|
|
31
|
+
} from "@c4a/context";
|
|
32
|
+
|
|
33
|
+
const sampleLib = source("sample-lib");
|
|
34
|
+
|
|
35
|
+
export default defineProject({
|
|
36
|
+
sources: [sampleLib],
|
|
37
|
+
phases: [
|
|
38
|
+
extractTs({ source: sampleLib, collection: "codegraph" }),
|
|
39
|
+
reviewValidity({ collection: "codegraph" }),
|
|
40
|
+
],
|
|
41
|
+
packages: [
|
|
42
|
+
kbPackage({
|
|
43
|
+
name: "sample-lib-kb",
|
|
44
|
+
template: {
|
|
45
|
+
path: "src/package-templates/kb",
|
|
46
|
+
vars: { displayName: "Sample Library KB" },
|
|
47
|
+
},
|
|
48
|
+
select: { collections: ["codegraph"], okfRoots: ["wikis"] },
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Read Next
|
|
55
|
+
|
|
56
|
+
These files ship inside the installed package at `node_modules/@c4a/context/`:
|
|
57
|
+
|
|
58
|
+
- [Docs index](./docs/README.md)
|
|
59
|
+
- [Getting Started](./docs/getting-started.md)
|
|
60
|
+
- [Agent Guide](./docs/guides/agent-guide.md)
|
|
61
|
+
- [Package Outputs](./docs/guides/package-outputs.md)
|
|
62
|
+
- [Project API](./docs/reference/project-api.md)
|
|
63
|
+
- [Package Templates](./docs/reference/package-templates.md)
|
|
64
|
+
|
|
65
|
+
Template examples ship in:
|
|
66
|
+
|
|
67
|
+
```text
|
|
68
|
+
node_modules/@c4a/context/templates/package-templates/
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Copy them into a workspace under `src/package-templates/` when declaring
|
|
72
|
+
`kbPackage()` or `llmsPackage()`.
|
|
73
|
+
|
|
74
|
+
Approved Markdown lives under internal `knowledge/<collection>/...` paths such
|
|
75
|
+
as `knowledge/codegraph/...` or `knowledge/architecture/...`. During build, the
|
|
76
|
+
CLI maps selected internal collections to OKF output roots such as `wikis/`,
|
|
77
|
+
`guides/`, `rules/`, or `feats/`. OKF fields and Context extension fields live
|
|
78
|
+
at the top level. Do not nest `sources`, `visibility`, or `code_symbols` under
|
|
79
|
+
`context`, and do not add frontmatter `source_refs`. Section provenance lives in
|
|
80
|
+
`context:section` source-ref comments.
|
|
81
|
+
|
|
82
|
+
## Boundary
|
|
83
|
+
|
|
84
|
+
The SDK stays declarative:
|
|
85
|
+
|
|
86
|
+
- `defineProject`
|
|
87
|
+
- `source`, `allSources`
|
|
88
|
+
- `extractTs`, `reviewValidity`, `customPhase`
|
|
89
|
+
- `kbPackage`, `llmsPackage`
|
|
90
|
+
- source registry reading and validation helpers
|
|
91
|
+
|
|
92
|
+
The CLI owns:
|
|
93
|
+
|
|
94
|
+
- source materialization
|
|
95
|
+
- extraction
|
|
96
|
+
- review HTML and review apply
|
|
97
|
+
- approved Markdown materialization
|
|
98
|
+
- package build
|
|
99
|
+
- verification
|
|
100
|
+
- status and next-step guidance
|
package/contracts.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type DocumentMainlineCollection = "business" | "product" | "architecture" | "sop" | "faq" | "standards" | "decision" | "incident" | "test";
|
|
2
|
+
export type CodegraphCollection = "codegraph";
|
|
3
|
+
export type MainlineCollection = CodegraphCollection | DocumentMainlineCollection;
|
|
4
|
+
export type TopLevelNamespace = MainlineCollection | "feats";
|
|
5
|
+
export type OkfRoot = "guides" | "rules" | "wikis" | "feats";
|
|
6
|
+
export type KnowledgeCollection = TopLevelNamespace;
|
|
7
|
+
export type EntityStatus = "draft" | "approved" | "rejected" | "deprecated";
|
|
8
|
+
export type PackageKind = "kb" | "llms";
|
|
9
|
+
export type MarkdownTransform = (markdown: string) => string;
|
|
10
|
+
export type FileCaptureProcessorDefinition = {
|
|
11
|
+
kind: "file.capture.processor.mdx-json-docs";
|
|
12
|
+
include?: readonly string[];
|
|
13
|
+
documentExtensions?: readonly string[];
|
|
14
|
+
routeMetadataFile?: string;
|
|
15
|
+
};
|
|
16
|
+
export type PackageSelectDefinition = {
|
|
17
|
+
collections?: readonly KnowledgeCollection[];
|
|
18
|
+
okfRoots?: readonly OkfRoot[];
|
|
19
|
+
include?: readonly string[];
|
|
20
|
+
exclude?: readonly string[];
|
|
21
|
+
};
|
|
22
|
+
export declare const DOC_MAINLINE_COLLECTIONS: readonly DocumentMainlineCollection[];
|
|
23
|
+
export declare const MAINLINE_COLLECTIONS: readonly MainlineCollection[];
|
|
24
|
+
export declare const TOP_LEVEL_NAMESPACES: readonly TopLevelNamespace[];
|
|
25
|
+
export declare const OKF_ROOTS: readonly OkfRoot[];
|
|
26
|
+
export declare const KNOWLEDGE_COLLECTIONS: readonly KnowledgeCollection[];
|
|
27
|
+
export declare function assertKnowledgeCollection(value: string, field: string): asserts value is KnowledgeCollection;
|
|
28
|
+
export declare function assertDocumentMainlineCollection(value: string, field: string): asserts value is DocumentMainlineCollection;
|
|
29
|
+
export declare function assertMainlineCollection(value: string, field: string): asserts value is MainlineCollection;
|
|
30
|
+
export declare function assertTopLevelNamespace(value: string, field: string): asserts value is TopLevelNamespace;
|
|
31
|
+
export declare function assertOkfRoot(value: string, field: string): asserts value is OkfRoot;
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Context SDK Docs
|
|
2
|
+
|
|
3
|
+
These docs ship inside the installed SDK package at:
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
node_modules/@c4a/context/docs/
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Agents should read these files before editing a Context workspace, especially
|
|
10
|
+
before changing `src/index.ts` or package templates.
|
|
11
|
+
|
|
12
|
+
## Read First
|
|
13
|
+
|
|
14
|
+
- [Getting Started](./getting-started.md) — end-to-end component-library flow.
|
|
15
|
+
- [Agent Guide](./guides/agent-guide.md) — what an agent should do, and what it should not inspect manually.
|
|
16
|
+
- [Agent Dialogue](./guides/agent-dialogue.md) — how agents should explain human gates without exposing internal API details first.
|
|
17
|
+
- [Package Outputs](./guides/package-outputs.md) — how to choose between an agent knowledge-base package, LLM text, or no package output.
|
|
18
|
+
- [Project API](./reference/project-api.md) — `defineProject`, sources, phases, review, and packages.
|
|
19
|
+
- [Package Templates](./reference/package-templates.md) — `kbPackage`, `llmsPackage`, template variables, and examples.
|
|
20
|
+
- [Template Variables](./reference/template-variables.md) — Handlebars variables, loops, comments, and default knowledge inventories.
|
|
21
|
+
|
|
22
|
+
Approved Markdown and kb package OKF output follow the C4A OKF Profile:
|
|
23
|
+
OKF fields and C4A extension fields live at the top level. Do not nest
|
|
24
|
+
`sources`, `visibility`, or `code_symbols` under `context`, and do not add
|
|
25
|
+
frontmatter `source_refs`. Section provenance lives in `context:section`
|
|
26
|
+
source_ref span comments. The kb package root may contain agent files; the
|
|
27
|
+
OKF-compatible surface is its selected `wikis/`, `guides/`, `rules/`, and
|
|
28
|
+
`feats/` subtrees.
|
|
29
|
+
|
|
30
|
+
## Installed Templates
|
|
31
|
+
|
|
32
|
+
Template examples ship in:
|
|
33
|
+
|
|
34
|
+
```text
|
|
35
|
+
node_modules/@c4a/context/templates/package-templates/
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Copy or mirror these into a workspace under `src/package-templates/` when the
|
|
39
|
+
project needs package outputs.
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
This guide shows the common Context workspace shape. The same workspace can
|
|
4
|
+
ingest source documents, code repositories, or both. Start with the user's
|
|
5
|
+
source boundary, then declare the matching phases in `src/index.ts`.
|
|
6
|
+
|
|
7
|
+
## 1. Initialize
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
context init context --dev
|
|
11
|
+
cd context
|
|
12
|
+
bun install
|
|
13
|
+
context status
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Use `--dev` only when testing a locally linked SDK. Published users can omit it.
|
|
17
|
+
When operating through an Agent plugin, use the installed Context continuation entry from the project root after initialization; it reads `context status` and then calls the lower-level CLI primitives as needed. The exact slash command or skill name is host-specific.
|
|
18
|
+
|
|
19
|
+
## 2. Choose And Register A Source Boundary
|
|
20
|
+
|
|
21
|
+
First decide what one source should mean for this workspace. The source name is
|
|
22
|
+
not only a label; it becomes a stable namespace in source refs, phase ids, and
|
|
23
|
+
package naming. Approved knowledge paths are derived from collection,
|
|
24
|
+
containment, and slug, not directly from the source name. ViewRef/NodeRef are
|
|
25
|
+
identity fields, not path strings:
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
knowledge/<collection>/<containment>/<slug>.md
|
|
29
|
+
repo:<source-name>#symbol:...
|
|
30
|
+
file:<source-name>/<document>#span:...
|
|
31
|
+
lark:<source-name>/<document>#span:...
|
|
32
|
+
dist/<source-name>-kb/...
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
For a Markdown or MDX document corpus, register a file source and keep the
|
|
36
|
+
include list inside the user-approved boundary. Default file capture handles
|
|
37
|
+
Markdown. For MDX documentation sites that use `_meta.json` route metadata,
|
|
38
|
+
declare `captureFile({ source: docs, processor: mdxJsonDocs() })` in
|
|
39
|
+
`src/index.ts`; `_meta.json` files are route metadata, not body evidence. The
|
|
40
|
+
concrete command shape is available from
|
|
41
|
+
`context source add file --help`; after registration, declare `captureFile`,
|
|
42
|
+
`alignProse`, `compileProse`, and `reviewValidity`.
|
|
43
|
+
|
|
44
|
+
For a Lark / Feishu document, register a Lark source with exactly one identity
|
|
45
|
+
form, then declare `captureLark`, `alignProse`, `compileProse`, and
|
|
46
|
+
`reviewValidity`.
|
|
47
|
+
|
|
48
|
+
For a single component package, use the package directory as the repo source
|
|
49
|
+
boundary:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
context source add repo component-lib \
|
|
53
|
+
--local ../component-lib \
|
|
54
|
+
--remote <git-remote-url> \
|
|
55
|
+
--ref <commit-sha-or-prefix>
|
|
56
|
+
context source ensure
|
|
57
|
+
context source inspect component-lib
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
For a monorepo or subspace, choose the boundary deliberately:
|
|
61
|
+
|
|
62
|
+
- If the user wants one package manual, point `--local` at that package
|
|
63
|
+
subdirectory and use a source name like `component-lib`.
|
|
64
|
+
- If the user wants one unified manual for the whole subspace, point `--local`
|
|
65
|
+
at the subspace root and use a source name for that subspace.
|
|
66
|
+
|
|
67
|
+
The long-term multi-module namespace shape is:
|
|
68
|
+
|
|
69
|
+
```text
|
|
70
|
+
knowledge/codegraph/product-ui/component-web/...
|
|
71
|
+
knowledge/codegraph/product-ui/component-lynx/...
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
In the current repo extraction flow, a parent monorepo/subspace source is
|
|
75
|
+
for inspection and planning first. Before real extraction, choose the concrete
|
|
76
|
+
package/subdirectory boundary so the initial containment/slug plan stays
|
|
77
|
+
focused and does not repeat package names accidentally.
|
|
78
|
+
|
|
79
|
+
The CLI records the git root and subpath, then materializes
|
|
80
|
+
`sources/repo/<name>` to the scoped view. Do not register the monorepo root and
|
|
81
|
+
rely on `extractTs.include` to select a package; `include` is only a file filter
|
|
82
|
+
inside the selected source boundary.
|
|
83
|
+
|
|
84
|
+
If the user first registers a monorepo root, run `context source inspect <name>`
|
|
85
|
+
before extraction. Show the listed module paths to the user as a tree and
|
|
86
|
+
register the chosen package path as a separate source for current extraction. The
|
|
87
|
+
inspect output includes package names, manifest paths, versions when available,
|
|
88
|
+
and suggested `context source add` commands.
|
|
89
|
+
|
|
90
|
+
Remote Git sources need the same boundary decision. Ask for the remote URL, the
|
|
91
|
+
pinned commit/ref, and whether the user approves cloning. The CLI does not
|
|
92
|
+
clone, checkout, reset, or fetch silently. If source material is missing or at
|
|
93
|
+
the wrong ref, ask the user before running repo operations outside the CLI.
|
|
94
|
+
|
|
95
|
+
## 3. Declare The Flow
|
|
96
|
+
|
|
97
|
+
### Document Source Flow
|
|
98
|
+
|
|
99
|
+
For source documents, keep the project declaration small and let the CLI guide
|
|
100
|
+
the evidence views, structure confirmation, compile action schema, review, and
|
|
101
|
+
close steps:
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import {
|
|
105
|
+
alignProse,
|
|
106
|
+
captureFile,
|
|
107
|
+
compileProse,
|
|
108
|
+
defineProject,
|
|
109
|
+
reviewValidity,
|
|
110
|
+
source,
|
|
111
|
+
} from "@c4a/context";
|
|
112
|
+
|
|
113
|
+
const docs = source("product-docs");
|
|
114
|
+
|
|
115
|
+
export default defineProject({
|
|
116
|
+
sources: [docs],
|
|
117
|
+
phases: [
|
|
118
|
+
captureFile({ source: docs }),
|
|
119
|
+
alignProse({ source: docs, collection: "architecture" }),
|
|
120
|
+
compileProse({ source: docs, collection: "architecture" }),
|
|
121
|
+
reviewValidity({ collection: "architecture" }),
|
|
122
|
+
],
|
|
123
|
+
packages: [],
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Then start from `context status` or the installed Context continue Skill. The
|
|
128
|
+
normal sequence is:
|
|
129
|
+
|
|
130
|
+
1. capture the source into committed snapshots;
|
|
131
|
+
2. investigate evidence and confirm `unapproved/structure.yaml`;
|
|
132
|
+
3. compile source-bound draft pages from confirmed structure;
|
|
133
|
+
4. review/apply approved pages;
|
|
134
|
+
5. run close, verify, and build when packages are declared.
|
|
135
|
+
|
|
136
|
+
Do not read `sources/` or raw Markdown directly after entering the Context
|
|
137
|
+
workflow; use the evidence views and `source_ref` values returned by the CLI.
|
|
138
|
+
|
|
139
|
+
### Code Source Flow
|
|
140
|
+
|
|
141
|
+
Edit `src/index.ts`:
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
import { defineProject, extractTs, reviewValidity, source } from "@c4a/context";
|
|
145
|
+
|
|
146
|
+
const componentLib = source("component-lib");
|
|
147
|
+
|
|
148
|
+
export default defineProject({
|
|
149
|
+
sources: [componentLib],
|
|
150
|
+
phases: [
|
|
151
|
+
extractTs({ source: componentLib, collection: "codegraph" }),
|
|
152
|
+
reviewValidity({ collection: "codegraph" }),
|
|
153
|
+
],
|
|
154
|
+
packages: [],
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Inspect and run:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
context run --list
|
|
162
|
+
context run extract:component-lib:codegraph --dry-run
|
|
163
|
+
context run extract:component-lib:codegraph
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
When operating through an Agent, use `--dry-run --format json` as the CLI
|
|
167
|
+
implementation for a no-write preview. For extract phases it returns a
|
|
168
|
+
`preview` block with resolved sources, modules, file counts, symbol counts,
|
|
169
|
+
candidate estimates, `knowledgeTree`, `knowledgePathExamples`, and module-level
|
|
170
|
+
hints. Treat that preview as the scope check before producing draft candidates.
|
|
171
|
+
|
|
172
|
+
The approved Markdown path is derived before review from collection,
|
|
173
|
+
containment, and slug. NodeRef/ViewRef remain identity fields:
|
|
174
|
+
|
|
175
|
+
```text
|
|
176
|
+
knowledge/<collection>/<containment>/<slug>.md
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Show the tree/path preview to the user before first extraction and describe it
|
|
180
|
+
as a preview without writing candidates. If the source name, optional module
|
|
181
|
+
segment, or path shape is not what the user expects, fix the source registration
|
|
182
|
+
or source boundary before running extraction. A source that already points at
|
|
183
|
+
one package/module root should not repeat the package name in the path.
|
|
184
|
+
|
|
185
|
+
## 4. Review
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
context review html architecture --open
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Use the generated HTML page to approve or reject candidates. If the browser does
|
|
192
|
+
not open automatically, use the emitted `file://` URL. When
|
|
193
|
+
finished, open `Payload` and copy the JSONL payload into the agent chat. The
|
|
194
|
+
agent writes that pasted payload to a normal temporary file under the workspace
|
|
195
|
+
`.tmp/` directory and runs:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
context review apply <payload-file>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Do not hand-write approved Markdown. `context review apply` owns materialization
|
|
202
|
+
from `unapproved/entities.jsonl` into `knowledge/`.
|
|
203
|
+
Do not store review payloads through scratch files outside `.tmp/` or by
|
|
204
|
+
editing workspace config.
|
|
205
|
+
|
|
206
|
+
## 5. Build Packages
|
|
207
|
+
|
|
208
|
+
This is a product decision point. Before editing `packages`, read
|
|
209
|
+
[Package Outputs](./guides/package-outputs.md) and explain the output tree to the
|
|
210
|
+
user.
|
|
211
|
+
|
|
212
|
+
Recommended first output:
|
|
213
|
+
|
|
214
|
+
```text
|
|
215
|
+
dist/component-lib-kb/
|
|
216
|
+
├── AGENTS.md
|
|
217
|
+
├── skills/
|
|
218
|
+
│ └── knowledge-query/
|
|
219
|
+
│ └── SKILL.md
|
|
220
|
+
└── wikis/
|
|
221
|
+
├── index.md
|
|
222
|
+
├── <group>/
|
|
223
|
+
│ ├── index.md
|
|
224
|
+
│ └── ...
|
|
225
|
+
└── ...
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Choose an agent knowledge-base package when agents should consume the reviewed
|
|
229
|
+
knowledge as a reusable package. After the user chooses this output shape,
|
|
230
|
+
declare it with `kbPackage()`.
|
|
231
|
+
|
|
232
|
+
The default `knowledge-query` skill teaches agents how to query copied OKF root
|
|
233
|
+
directories structure-first, starting with `wikis/`, cite
|
|
234
|
+
page/section evidence, inspect structure/build metadata when present, and report
|
|
235
|
+
gaps instead of inventing unsupported answers. Before building, tell the user
|
|
236
|
+
that `src/package-templates/kb/` is editable: they can change the default skill
|
|
237
|
+
wording or add product-specific skills when the package needs behavior beyond
|
|
238
|
+
knowledge lookup.
|
|
239
|
+
|
|
240
|
+
Selected OKF root subtrees such as `wikis/`, `guides/`, `rules/`, and
|
|
241
|
+
`feats/` follow the C4A OKF Profile. The package root contains agent files; the
|
|
242
|
+
OKF-compatible interchange surface is the selected OKF root directories. Edit
|
|
243
|
+
`src/package-templates/kb/wikis/index.md` before build to describe package
|
|
244
|
+
scope, intended users, and query guidance; other selected OKF root indexes are
|
|
245
|
+
generated unless the template supplies them.
|
|
246
|
+
|
|
247
|
+
Alternative:
|
|
248
|
+
|
|
249
|
+
```text
|
|
250
|
+
dist/component-lib-llms/
|
|
251
|
+
└── llms.txt
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Choose an LLM text bundle when the user wants one text bundle for model/RAG
|
|
255
|
+
import. After the user chooses this output shape, declare it with
|
|
256
|
+
`llmsPackage()`.
|
|
257
|
+
The user may also skip package output for now and keep only `knowledge/`.
|
|
258
|
+
|
|
259
|
+
Do not offer `both` as a shortcut. If multiple outputs are needed, add one
|
|
260
|
+
package first, inspect it, then add another after confirmation.
|
|
261
|
+
|
|
262
|
+
Copy or create templates under `src/package-templates/`, inspect that they match
|
|
263
|
+
the intended output shape, then declare packages. A `kbPackage()` template
|
|
264
|
+
must contain at least one `SKILL.md`; the default template also includes
|
|
265
|
+
`wikis/index.md`. The default template is a starting point, not proof that the
|
|
266
|
+
final package is useful.
|
|
267
|
+
|
|
268
|
+
```ts
|
|
269
|
+
import {
|
|
270
|
+
defineProject,
|
|
271
|
+
extractTs,
|
|
272
|
+
reviewValidity,
|
|
273
|
+
kbPackage,
|
|
274
|
+
source,
|
|
275
|
+
} from "@c4a/context";
|
|
276
|
+
|
|
277
|
+
const componentLib = source("component-lib");
|
|
278
|
+
|
|
279
|
+
export default defineProject({
|
|
280
|
+
sources: [componentLib],
|
|
281
|
+
phases: [
|
|
282
|
+
extractTs({ source: componentLib, collection: "codegraph" }),
|
|
283
|
+
reviewValidity({ collection: "codegraph" }),
|
|
284
|
+
],
|
|
285
|
+
packages: [
|
|
286
|
+
kbPackage({
|
|
287
|
+
name: "component-lib-kb",
|
|
288
|
+
template: {
|
|
289
|
+
path: "src/package-templates/kb",
|
|
290
|
+
vars: { displayName: "Component Library KB" },
|
|
291
|
+
},
|
|
292
|
+
select: { include: ["codegraph/component-lib/**"] },
|
|
293
|
+
}),
|
|
294
|
+
],
|
|
295
|
+
});
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
If the user chooses an LLM text bundle instead, declare `llmsPackage()` in place
|
|
299
|
+
of the agent knowledge-base package:
|
|
300
|
+
|
|
301
|
+
```ts
|
|
302
|
+
llmsPackage({
|
|
303
|
+
name: "component-lib-llms",
|
|
304
|
+
template: "src/package-templates/llms",
|
|
305
|
+
select: { include: ["codegraph/component-lib/**"] },
|
|
306
|
+
});
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Build and verify:
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
context build
|
|
313
|
+
context verify
|
|
314
|
+
context status
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Outputs are written under `dist/<package-name>/`.
|
|
318
|
+
|
|
319
|
+
After build, inspect `dist/<package-name>/` before calling the package usable.
|
|
320
|
+
A clean command exit only means the workspace protocol is valid.
|