@c4a/context 0.6.0-alpha.1 → 0.6.0-beta.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/docs/getting-started.md +28 -18
- package/docs/guides/agent-dialogue.md +12 -15
- package/docs/guides/agent-guide.md +17 -24
- package/docs/reference/project-api.md +29 -12
- package/package.json +1 -1
package/docs/getting-started.md
CHANGED
|
@@ -18,9 +18,12 @@ When operating through an Agent plugin, use the installed Context continuation e
|
|
|
18
18
|
|
|
19
19
|
## 2. Choose And Register A Source Boundary
|
|
20
20
|
|
|
21
|
-
First decide what one source should mean for this workspace.
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
First decide what one source should mean for this workspace. By default, source
|
|
22
|
+
registration omits a name and the CLI uses today's local date (`YYYYMMDD`) as
|
|
23
|
+
the source namespace. Do not derive source names from filenames, directory
|
|
24
|
+
names, or document content. If today's date already exists, pass an explicit
|
|
25
|
+
date name. The source name becomes a stable namespace in source refs, phase ids,
|
|
26
|
+
and package naming. Approved knowledge paths are derived from collection,
|
|
24
27
|
containment, and slug, not directly from the source name. ViewRef/NodeRef are
|
|
25
28
|
identity fields, not path strings:
|
|
26
29
|
|
|
@@ -36,8 +39,14 @@ For a Markdown or MDX document corpus, register a file source and keep the
|
|
|
36
39
|
include list inside the user-approved boundary. Default file capture handles
|
|
37
40
|
Markdown. For MDX documentation sites that use `_meta.json` route metadata,
|
|
38
41
|
declare `captureFile({ source: docs, processor: mdxJsonDocs() })` in
|
|
39
|
-
`src/index.ts`; `_meta.json` files are route metadata,
|
|
40
|
-
|
|
42
|
+
`src/index.ts`; `_meta.json` files are route metadata, and the CLI generates
|
|
43
|
+
mechanical evidence pages for route facts and static MDX component text:
|
|
44
|
+
`__context_route_metadata.md` and `__context_mdx_component_text.md`. If the CLI
|
|
45
|
+
reports that a file source looks like a documentation site but lacks the
|
|
46
|
+
processor, confirm the source boundary and add the processor before capture.
|
|
47
|
+
If the selected page is only a runtime shell, capture the rendered-site source
|
|
48
|
+
or project-specific data source explicitly; do not ask the agent to invent
|
|
49
|
+
missing body text. The concrete command shape is available from
|
|
41
50
|
`context source add file --help`; after registration, declare `captureFile`,
|
|
42
51
|
`alignProse`, `compileProse`, and `reviewValidity`.
|
|
43
52
|
|
|
@@ -49,20 +58,21 @@ For a single component package, use the package directory as the repo source
|
|
|
49
58
|
boundary:
|
|
50
59
|
|
|
51
60
|
```bash
|
|
52
|
-
context source add repo
|
|
61
|
+
context source add repo \
|
|
53
62
|
--local ../component-lib \
|
|
54
63
|
--remote <git-remote-url> \
|
|
55
64
|
--ref <commit-sha-or-prefix>
|
|
56
65
|
context source ensure
|
|
57
|
-
context source inspect
|
|
66
|
+
context source inspect <source-name>
|
|
58
67
|
```
|
|
59
68
|
|
|
60
69
|
For a monorepo or subspace, choose the boundary deliberately:
|
|
61
70
|
|
|
62
71
|
- If the user wants one package manual, point `--local` at that package
|
|
63
|
-
subdirectory and use
|
|
72
|
+
subdirectory and use the CLI-returned date source name in `src/index.ts`.
|
|
64
73
|
- If the user wants one unified manual for the whole subspace, point `--local`
|
|
65
|
-
at the subspace root and use
|
|
74
|
+
at the subspace root and use the CLI-returned date source name as that
|
|
75
|
+
namespace.
|
|
66
76
|
|
|
67
77
|
The long-term multi-module namespace shape is:
|
|
68
78
|
|
|
@@ -77,11 +87,11 @@ package/subdirectory boundary so the initial containment/slug plan stays
|
|
|
77
87
|
focused and does not repeat package names accidentally.
|
|
78
88
|
|
|
79
89
|
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
|
|
90
|
+
`sources/repo/<source-name>` to the scoped view. Do not register the monorepo root and
|
|
81
91
|
rely on `extractTs.include` to select a package; `include` is only a file filter
|
|
82
92
|
inside the selected source boundary.
|
|
83
93
|
|
|
84
|
-
If the user first registers a monorepo root, run `context source inspect <name>`
|
|
94
|
+
If the user first registers a monorepo root, run `context source inspect <source-name>`
|
|
85
95
|
before extraction. Show the listed module paths to the user as a tree and
|
|
86
96
|
register the chosen package path as a separate source for current extraction. The
|
|
87
97
|
inspect output includes package names, manifest paths, versions when available,
|
|
@@ -110,7 +120,7 @@ import {
|
|
|
110
120
|
source,
|
|
111
121
|
} from "@c4a/context";
|
|
112
122
|
|
|
113
|
-
const docs = source("
|
|
123
|
+
const docs = source("20260704");
|
|
114
124
|
|
|
115
125
|
export default defineProject({
|
|
116
126
|
sources: [docs],
|
|
@@ -143,7 +153,7 @@ Edit `src/index.ts`:
|
|
|
143
153
|
```ts
|
|
144
154
|
import { defineProject, extractTs, reviewValidity, source } from "@c4a/context";
|
|
145
155
|
|
|
146
|
-
const componentLib = source("
|
|
156
|
+
const componentLib = source("20260704");
|
|
147
157
|
|
|
148
158
|
export default defineProject({
|
|
149
159
|
sources: [componentLib],
|
|
@@ -159,8 +169,8 @@ Inspect and run:
|
|
|
159
169
|
|
|
160
170
|
```bash
|
|
161
171
|
context run --list
|
|
162
|
-
context run extract:
|
|
163
|
-
context run extract:
|
|
172
|
+
context run extract:20260704:codegraph --dry-run
|
|
173
|
+
context run extract:20260704:codegraph
|
|
164
174
|
```
|
|
165
175
|
|
|
166
176
|
When operating through an Agent, use `--dry-run --format json` as the CLI
|
|
@@ -274,7 +284,7 @@ import {
|
|
|
274
284
|
source,
|
|
275
285
|
} from "@c4a/context";
|
|
276
286
|
|
|
277
|
-
const componentLib = source("
|
|
287
|
+
const componentLib = source("20260704");
|
|
278
288
|
|
|
279
289
|
export default defineProject({
|
|
280
290
|
sources: [componentLib],
|
|
@@ -289,7 +299,7 @@ export default defineProject({
|
|
|
289
299
|
path: "src/package-templates/kb",
|
|
290
300
|
vars: { displayName: "Component Library KB" },
|
|
291
301
|
},
|
|
292
|
-
select: { include: ["codegraph/
|
|
302
|
+
select: { include: ["codegraph/20260704/**"] },
|
|
293
303
|
}),
|
|
294
304
|
],
|
|
295
305
|
});
|
|
@@ -302,7 +312,7 @@ of the agent knowledge-base package:
|
|
|
302
312
|
llmsPackage({
|
|
303
313
|
name: "component-lib-llms",
|
|
304
314
|
template: "src/package-templates/llms",
|
|
305
|
-
select: { include: ["codegraph/
|
|
315
|
+
select: { include: ["codegraph/20260704/**"] },
|
|
306
316
|
});
|
|
307
317
|
```
|
|
308
318
|
|
|
@@ -66,6 +66,8 @@ If you want one manual for only this package, choose the package directory as
|
|
|
66
66
|
the source boundary. If you want one manual for the whole subspace, choose the
|
|
67
67
|
subspace root.
|
|
68
68
|
|
|
69
|
+
The CLI will use today's local date (`YYYYMMDD`) as the source name unless that
|
|
70
|
+
date already exists. Do not invent a name from the folder, filenames, or content.
|
|
69
71
|
The source name becomes part of source refs, phase ids, and package names.
|
|
70
72
|
Approved knowledge paths are derived from collection, containment, and slug;
|
|
71
73
|
NodeRef/ViewRef are identity fields, not path strings:
|
|
@@ -73,18 +75,11 @@ knowledge/<collection>/<containment>/<slug>.md
|
|
|
73
75
|
repo:<source-name>#...
|
|
74
76
|
dist/<source-name>-kb/...
|
|
75
77
|
|
|
76
|
-
If
|
|
77
|
-
|
|
78
|
+
If today's date already exists, ask the user for an explicit date name before
|
|
79
|
+
registration. Do not add a sequence number automatically.
|
|
78
80
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
- if the path is a parent monorepo/subspace, the name is a parent namespace and
|
|
82
|
-
child modules can appear below it later;
|
|
83
|
-
- current extraction should inspect a parent source first, then extract from
|
|
84
|
-
a confirmed package/subdirectory boundary.
|
|
85
|
-
|
|
86
|
-
For a multi-module subspace package shape, a parent name such as product-ui
|
|
87
|
-
can group children like:
|
|
81
|
+
For a multi-module subspace package shape, the date source name can group
|
|
82
|
+
children like:
|
|
88
83
|
knowledge/codegraph/product-ui/component-web/...
|
|
89
84
|
knowledge/codegraph/product-ui/component-lynx/...
|
|
90
85
|
|
|
@@ -109,7 +104,8 @@ Good:
|
|
|
109
104
|
The source is registered, but registration did not read the document body.
|
|
110
105
|
|
|
111
106
|
The next operation will read this local Markdown file or folder and write a
|
|
112
|
-
committed snapshot under `sources/file/<source-name>/`.
|
|
107
|
+
committed snapshot under `sources/file/<source-name>/`. The source name is the
|
|
108
|
+
date name returned by `context source add file --local <path>`. That snapshot is used
|
|
113
109
|
later for review, verify, and fresh-clone reproduction.
|
|
114
110
|
|
|
115
111
|
Please confirm that I may read this document source now. After you confirm, I
|
|
@@ -123,7 +119,8 @@ For Lark / Feishu:
|
|
|
123
119
|
The source is registered, but registration did not fetch the remote document.
|
|
124
120
|
|
|
125
121
|
The next operation will read the Lark/Feishu document you provided and write a
|
|
126
|
-
normalized snapshot under `sources/lark/<source-name>/`. The
|
|
122
|
+
normalized snapshot under `sources/lark/<source-name>/`. The source name is the
|
|
123
|
+
date name returned by `context source add lark ...`. The snapshot is
|
|
127
124
|
committed by default so verify can work offline and after a fresh clone. Access
|
|
128
125
|
credentials stay in the Lark CLI; they are not written to this workspace. If
|
|
129
126
|
your business repository wants to ignore this snapshot, that is a repository
|
|
@@ -174,7 +171,7 @@ phases are not declared yet, then summarize the change. For example:
|
|
|
174
171
|
|
|
175
172
|
```text
|
|
176
173
|
I updated the project flow to add document structure planning and source-bound
|
|
177
|
-
compile for `
|
|
174
|
+
compile for source `20260704`. No approved Markdown is written yet. The next gate
|
|
178
175
|
is a structure draft for your confirmation.
|
|
179
176
|
```
|
|
180
177
|
|
|
@@ -190,7 +187,7 @@ Bad:
|
|
|
190
187
|
```text
|
|
191
188
|
是否按 Context 默认范围继续?
|
|
192
189
|
extractTs({
|
|
193
|
-
source: source("
|
|
190
|
+
source: source("20260704"),
|
|
194
191
|
collection: "codegraph",
|
|
195
192
|
// include defaults to ["src/**/*.{ts,tsx}"]
|
|
196
193
|
// exportedOnly defaults to true
|
|
@@ -46,7 +46,7 @@ node_modules/@c4a/context/docs/reference/package-templates.md
|
|
|
46
46
|
- `unapproved/entities.jsonl` is the committed draft/rejected/deprecated ledger.
|
|
47
47
|
- `knowledge/` contains approved Markdown.
|
|
48
48
|
- `dist/` contains generated package outputs.
|
|
49
|
-
- file and Lark snapshots live under `sources/file/<name>/` and `sources/lark/<name>/`.
|
|
49
|
+
- file and Lark snapshots live under `sources/file/<source-name>/` and `sources/lark/<source-name>/`.
|
|
50
50
|
- `.tmp/context-runtime/` contains ignored runtime cache, logs, review HTML, previews, and locks.
|
|
51
51
|
|
|
52
52
|
Do not create hidden workspace state directories.
|
|
@@ -58,7 +58,7 @@ Present only the current workflow surface:
|
|
|
58
58
|
| Task | Current route |
|
|
59
59
|
|---|---|
|
|
60
60
|
| 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. |
|
|
61
|
-
| Capture document sources | Run the declared `capture:file:<source>` or `capture:lark:<source>` phase only after read permission. Capture writes committed snapshots under `sources/file/<name>/` or `sources/lark/<name>/`. |
|
|
61
|
+
| Capture document sources | Run the declared `capture:file:<source>` or `capture:lark:<source>` phase only after read permission. Capture writes committed snapshots under `sources/file/<source-name>/` or `sources/lark/<source-name>/`. |
|
|
62
62
|
| 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. |
|
|
63
63
|
| Confirm prose structure | `alignProse` validates and stages `unapproved/structure.yaml`. Validation does not equal user confirmation; only confirmed lifecycle state may enter prose compile. |
|
|
64
64
|
| Compile source-bound drafts | `compileProse` turns confirmed structure into source-bound draft pages. It does not approve knowledge. |
|
|
@@ -80,9 +80,12 @@ user first.
|
|
|
80
80
|
|
|
81
81
|
`missing-source` is a human gate. In user-facing language, describe the next
|
|
82
82
|
action as adding a knowledge source, not as filling CLI placeholders. Treat this
|
|
83
|
-
as a source boundary decision. Explain that the
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
as a source boundary decision. Explain that the CLI uses today's local date
|
|
84
|
+
(`YYYYMMDD`) as the source name by default; do not invent a name from cwd,
|
|
85
|
+
parent directories, monorepo layout, package names, git remotes, filenames, or
|
|
86
|
+
document content. The source name appears in source refs and phase ids. Approved
|
|
87
|
+
paths are derived from collection, containment, and slug. NodeRef/ViewRef are
|
|
88
|
+
identity fields, not path strings:
|
|
86
89
|
|
|
87
90
|
```text
|
|
88
91
|
knowledge/<collection>/<containment>/<slug>.md
|
|
@@ -102,26 +105,16 @@ source boundary intentionally covers multiple modules.
|
|
|
102
105
|
Ask what the user wants the source to cover: a single local Markdown/MDX document,
|
|
103
106
|
a local Markdown/MDX directory, an article/documentation repository as a file
|
|
104
107
|
source, a Lark/Feishu document URL or token, a local code repo/package, a remote
|
|
105
|
-
Git repo/package, or a multi-module namespace.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
boundary is clear.
|
|
109
|
-
|
|
110
|
-
If the user already provided a path and the remaining question is only the
|
|
111
|
-
source name, still explain the boundary implication before asking for
|
|
112
|
-
confirmation. A package/module path means the source name becomes the stable
|
|
113
|
-
source-ref, phase-id, and package-output identity. A parent monorepo/subspace
|
|
114
|
-
path means the source name is a source namespace for possible child modules,
|
|
115
|
-
and current extraction must inspect that parent before choosing concrete
|
|
116
|
-
package/subdirectory boundaries. Approved paths still come from collection,
|
|
117
|
-
containment, and slug.
|
|
108
|
+
Git repo/package, or a multi-module namespace. If today's date source name
|
|
109
|
+
already exists, ask for an explicit date name; do not auto-append a sequence.
|
|
110
|
+
Approved paths still come from collection, containment, and slug.
|
|
118
111
|
|
|
119
112
|
Current execution supports repo sources, local Markdown/MDX file sources, and Lark /
|
|
120
113
|
Feishu document sources. Local
|
|
121
|
-
repo/package sources are registered with `context source add repo <
|
|
122
|
-
|
|
114
|
+
repo/package sources are registered with `context source add repo --local <path>`;
|
|
115
|
+
the materialized `sources/repo/<source-name>` entry is an ignored
|
|
123
116
|
symlink to the selected checkout or subdirectory view. Local Markdown/MDX sources
|
|
124
|
-
are registered with `context source add file
|
|
117
|
+
are registered with `context source add file --local <path>` plus any
|
|
125
118
|
needed `--include` patterns, captured with `captureFile`, then planned through
|
|
126
119
|
`alignProse` and compiled with
|
|
127
120
|
`compileProse`. A one-file-to-one-page outcome is a degenerate structure plan,
|
|
@@ -129,7 +122,7 @@ not a separate content path. Remote Git operations require explicit user approva
|
|
|
129
122
|
clone/checkout; clone into an ignored local path, checkout the requested commit,
|
|
130
123
|
then register that local checkout. Do not commit cloned source content. Lark /
|
|
131
124
|
Feishu sources are registered as document sources, captured through the Lark
|
|
132
|
-
capture phase, and written as committed snapshots under `sources/lark/<name>/`;
|
|
125
|
+
capture phase, and written as committed snapshots under `sources/lark/<source-name>/`;
|
|
133
126
|
do not fetch or import Lark content with ad hoc scripts.
|
|
134
127
|
|
|
135
128
|
Extraction scope is also a human gate. If no extract phase is declared, explain
|
|
@@ -138,8 +131,8 @@ registered source and file/symbol range to ingest. Do not inspect the source
|
|
|
138
131
|
repository to choose packages or globs on the user's behalf.
|
|
139
132
|
|
|
140
133
|
For monorepos, one source may conceptually cover the whole repo/subspace or one
|
|
141
|
-
package/subdirectory. Explain that the source name becomes a source-ref and
|
|
142
|
-
phase-id namespace. A parent source name can support grouped codegraph NodeRefs
|
|
134
|
+
package/subdirectory. Explain that the date source name becomes a source-ref and
|
|
135
|
+
phase-id namespace. A parent date source name can support grouped codegraph NodeRefs
|
|
143
136
|
such as `knowledge/codegraph/product-ui/component-web/...` and
|
|
144
137
|
`knowledge/codegraph/product-ui/component-lynx/...`. In the current executable
|
|
145
138
|
flow, use the whole repo/subspace only for inspection/planning. If the user wants
|
|
@@ -19,9 +19,13 @@ declaration list. Put heavy logic in imported transform files.
|
|
|
19
19
|
|
|
20
20
|
## Sources
|
|
21
21
|
|
|
22
|
-
A source is a stable knowledge boundary, not only a display label.
|
|
22
|
+
A source is a stable knowledge boundary, not only a display label. By default,
|
|
23
|
+
`context source add repo/file/lark` uses today's local date (`YYYYMMDD`) as the
|
|
24
|
+
source name. Do not derive the name from filenames, directory names, or document
|
|
25
|
+
content. If today's date already exists, pass an explicit date name. The source
|
|
23
26
|
name becomes a stable identity in source references, phase ids, and package
|
|
24
|
-
naming. Approved knowledge paths are derived from collection, containment, and
|
|
27
|
+
naming. Approved knowledge paths are derived from collection, containment, and
|
|
28
|
+
slug. NodeRef/ViewRef are identity fields, not path strings:
|
|
25
29
|
|
|
26
30
|
```text
|
|
27
31
|
knowledge/<collection>/<containment>/<slug>.md
|
|
@@ -60,8 +64,7 @@ is a repo, file, or lark source:
|
|
|
60
64
|
```ts
|
|
61
65
|
import { source } from "@c4a/context";
|
|
62
66
|
|
|
63
|
-
const
|
|
64
|
-
const docs = source("product-docs");
|
|
67
|
+
const docs = source("20260704");
|
|
65
68
|
```
|
|
66
69
|
|
|
67
70
|
### `allSources("repo")`
|
|
@@ -100,8 +103,19 @@ captureFile({ source: docs, processor: mdxJsonDocs() });
|
|
|
100
103
|
```
|
|
101
104
|
|
|
102
105
|
With that processor, `.md` and `.mdx` are document bodies. Included
|
|
103
|
-
`_meta.json` files are captured as route metadata assets
|
|
104
|
-
`read-plan` / `source-index
|
|
106
|
+
`_meta.json` files are captured as route metadata assets, surfaced in
|
|
107
|
+
`read-plan` / `source-index`, and mechanically projected into
|
|
108
|
+
`__context_route_metadata.md` so route facts can be cited as evidence. The route
|
|
109
|
+
projection records the canonical extensionless route form instead of treating a
|
|
110
|
+
local `.html` URL as the source of truth.
|
|
111
|
+
|
|
112
|
+
MDX component text is extracted separately: string props such as `title`,
|
|
113
|
+
`label`, `description`, `href`, `to`, and component children are projected into
|
|
114
|
+
`__context_mdx_component_text.md` as generated evidence. The original `.mdx`
|
|
115
|
+
file remains in the snapshot unchanged. If a documentation page renders body
|
|
116
|
+
text only at runtime from application code or remote data, configure that
|
|
117
|
+
documentation site as an explicit source boundary instead of hand-writing route
|
|
118
|
+
or body facts.
|
|
105
119
|
|
|
106
120
|
```ts
|
|
107
121
|
captureFile({ source: docs });
|
|
@@ -113,9 +127,11 @@ Phase id:
|
|
|
113
127
|
capture:file:<source-name>
|
|
114
128
|
```
|
|
115
129
|
|
|
116
|
-
Register the source first with `context source add file
|
|
130
|
+
Register the source first with `context source add file --local <path>`.
|
|
117
131
|
The first registration requires `--local`; the registry may later keep `local`
|
|
118
|
-
only as a refresh hint while committed snapshots remain verifiable.
|
|
132
|
+
only as a refresh hint while committed snapshots remain verifiable. If the
|
|
133
|
+
default date source name already exists, pass an explicit date name:
|
|
134
|
+
`context source add file 20260703 --local <path>`.
|
|
119
135
|
|
|
120
136
|
### `captureLark`
|
|
121
137
|
|
|
@@ -132,10 +148,10 @@ Phase id:
|
|
|
132
148
|
capture:lark:<source-name>
|
|
133
149
|
```
|
|
134
150
|
|
|
135
|
-
Register the source first with `context source add lark
|
|
151
|
+
Register the source first with `context source add lark` and exactly one
|
|
136
152
|
identity flag: `--url`, `--doc-token`, or `--wiki-token`. Capture reads the
|
|
137
153
|
remote document through the CLI runner, writes normalized snapshot files under
|
|
138
|
-
`sources/lark/<name>/`, and does not write access credentials into the
|
|
154
|
+
`sources/lark/<source-name>/`, and does not write access credentials into the
|
|
139
155
|
workspace. Multi-document Lark organization goes through `alignProse`; the
|
|
140
156
|
current workflow does not provide a one-step Lark stage shortcut.
|
|
141
157
|
|
|
@@ -247,8 +263,9 @@ Options:
|
|
|
247
263
|
| `transform` | Optional markdown transform function or functions |
|
|
248
264
|
|
|
249
265
|
In monorepos, make the package/subdirectory the source boundary. Register the
|
|
250
|
-
chosen package path with `context source add repo
|
|
251
|
-
|
|
266
|
+
chosen package path with `context source add repo --local <package-dir>` and
|
|
267
|
+
reference the CLI-returned date source name with `source("<source-name>")`.
|
|
268
|
+
Do not use `include` to choose a
|
|
252
269
|
package from a larger monorepo source.
|
|
253
270
|
|
|
254
271
|
Use `context source inspect <source-name>` to list detected module/package
|