@c4a/context 0.6.0-beta.5 → 0.6.0-beta.7
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 +1 -1
- package/docs/getting-started.md +113 -49
- package/docs/guides/agent-dialogue.md +32 -23
- package/docs/guides/agent-guide.md +133 -58
- package/docs/reference/package-templates.md +7 -1
- package/docs/reference/project-api.md +240 -49
- package/index.js +190 -102
- package/package.json +1 -1
- package/sources.d.ts +22 -0
package/README.md
CHANGED
package/docs/getting-started.md
CHANGED
|
@@ -18,18 +18,17 @@ 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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
identity fields, not path strings:
|
|
21
|
+
First decide what one source should mean for this workspace. Document sources
|
|
22
|
+
use one date name (`YYYYMMDD`). Repo sources use two levels: the date is a
|
|
23
|
+
capture batch and `--module` identifies the concrete package or code boundary.
|
|
24
|
+
Several repo modules can therefore be registered under the same date. Use the
|
|
25
|
+
confirmed package/module identity for `--module`; do not invent semantic source
|
|
26
|
+
suffixes from prose or content. ViewRef/NodeRef are identity fields, not path
|
|
27
|
+
strings:
|
|
29
28
|
|
|
30
29
|
```text
|
|
31
30
|
knowledge/<collection>/<containment>/<slug>.md
|
|
32
|
-
repo:<
|
|
31
|
+
repo:<date>/<module>#symbol:...
|
|
33
32
|
file:<source-name>/<document>#span:...
|
|
34
33
|
lark:<source-name>/<document>#span:...
|
|
35
34
|
dist/<source-name>-kb/...
|
|
@@ -54,46 +53,105 @@ For a Lark / Feishu document, register a Lark source with exactly one identity
|
|
|
54
53
|
form, then declare `captureLark`, `alignProse`, `compileProse`, and
|
|
55
54
|
`reviewValidity`.
|
|
56
55
|
|
|
56
|
+
File and Lark sources use the same date-batch shape as repo sources. Multiple
|
|
57
|
+
documents belong under one date instead of receiving `-2` / `-A` suffixes:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
context source add lark 20260712 --module user-manual --url <wiki-url>
|
|
61
|
+
context source add lark 20260712 --module migration-guide --url <wiki-url>
|
|
62
|
+
context source add file 20260712 --module local-manual --local ../manual
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
When these sources are supplied together, they can be registered in one locked
|
|
66
|
+
batch. Save the following as YAML/JSON or pipe it through stdin:
|
|
67
|
+
|
|
68
|
+
```yaml
|
|
69
|
+
sources:
|
|
70
|
+
- type: repo
|
|
71
|
+
module: component-lib
|
|
72
|
+
local: ../component-lib
|
|
73
|
+
- type: lark
|
|
74
|
+
url: <wiki-url>
|
|
75
|
+
- type: file
|
|
76
|
+
local: ../manual
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
context source add batch 20260712 --input sources.yaml --format json
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Do not run multiple `context source add` commands concurrently. All source
|
|
84
|
+
registry writes use one project lock and atomic replacement; if the lock is
|
|
85
|
+
held, wait for the active command and retry.
|
|
86
|
+
|
|
87
|
+
The command returns each concrete derived document module; use that value in a
|
|
88
|
+
declaration such as `source("20260712", "wiki-<digest>", { type: "lark" })`.
|
|
89
|
+
Snapshots are written as sibling files under `sources/lark|file/20260712/` with
|
|
90
|
+
one date-level `manifest.json`; phase ids and manifest entries use the logical
|
|
91
|
+
`YYYYMMDD/module` identity without creating a module subdirectory.
|
|
92
|
+
|
|
93
|
+
If several documents were requested together, register and declare every
|
|
94
|
+
module first. An explicit request to capture/read those exact paths or URLs is
|
|
95
|
+
the read confirmation for that requested batch; do not ask again after
|
|
96
|
+
registration. Merely mentioning a possible source is not permission.
|
|
97
|
+
`context status --format json` returns all remaining capture phases in
|
|
98
|
+
`routing.command_plan`. Every item is marked `after-human-confirmation`, so one
|
|
99
|
+
explicit confirmation can authorize the complete requested batch without
|
|
100
|
+
pausing for another date name or collection choice between modules. If any
|
|
101
|
+
module lacks a declaration, status returns `needs-capture-phase` and a precise
|
|
102
|
+
`routing.configuration` action instead of an unexecutable command.
|
|
103
|
+
|
|
104
|
+
When the workspace also contains repo sources, Context prioritizes untouched
|
|
105
|
+
code after all document captures finish: status returns `ready-to-extract`
|
|
106
|
+
until the code extraction round is current, then returns to document
|
|
107
|
+
investigation. An existing document structure/compile gate is never interrupted.
|
|
108
|
+
|
|
57
109
|
For a single component package, use the package directory as the repo source
|
|
58
110
|
boundary:
|
|
59
111
|
|
|
60
112
|
```bash
|
|
61
|
-
context source add repo \
|
|
113
|
+
context source add repo 20260712 \
|
|
114
|
+
--module component-lib \
|
|
62
115
|
--local ../component-lib \
|
|
63
116
|
--remote <git-remote-url> \
|
|
64
117
|
--ref <commit-sha-or-prefix>
|
|
65
|
-
context source ensure
|
|
66
|
-
context source inspect
|
|
118
|
+
context source ensure 20260712
|
|
119
|
+
context source inspect 20260712/component-lib
|
|
67
120
|
```
|
|
68
121
|
|
|
122
|
+
If `component-lib` and the Context workspace are inside the same Git checkout,
|
|
123
|
+
the CLI stores the repo root relative to the workspace even when `--local` was
|
|
124
|
+
absolute. The module symlink target is relative as well, so the checkout can be
|
|
125
|
+
moved without rewriting source metadata. External checkouts may keep an
|
|
126
|
+
absolute repo root.
|
|
127
|
+
|
|
128
|
+
Repo batches must be valid calendar dates in `YYYYMMDD` form; suffixes such as
|
|
129
|
+
`20260712-A` are rejected. `source ensure <date>` and `source inspect <date>`
|
|
130
|
+
operate on every repo module registered under that date. A full
|
|
131
|
+
`<date>/<module>` selector still targets one module.
|
|
132
|
+
|
|
69
133
|
For a monorepo or subspace, choose the boundary deliberately:
|
|
70
134
|
|
|
71
|
-
-
|
|
72
|
-
|
|
73
|
-
-
|
|
74
|
-
|
|
75
|
-
namespace.
|
|
135
|
+
- Register each confirmed package/subdirectory with its own `--module` under
|
|
136
|
+
the same date batch.
|
|
137
|
+
- A parent monorepo registration is an inspection boundary only when it resolves
|
|
138
|
+
to multiple packages; extraction remains bound to concrete registered modules.
|
|
76
139
|
|
|
77
|
-
The long-term multi-module
|
|
140
|
+
The long-term multi-module knowledge shape is stable across capture dates:
|
|
78
141
|
|
|
79
142
|
```text
|
|
80
|
-
knowledge/codegraph/
|
|
81
|
-
knowledge/codegraph/
|
|
143
|
+
knowledge/codegraph/module-a/...
|
|
144
|
+
knowledge/codegraph/module-b/...
|
|
82
145
|
```
|
|
83
146
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
package
|
|
87
|
-
|
|
147
|
+
The CLI records each module's git root and subpath, then materializes
|
|
148
|
+
`sources/repo/<date>/<module>` to the scoped view. Do not rely on
|
|
149
|
+
`extractTs.include` to select a package; `include` is only a file filter inside
|
|
150
|
+
one selected module.
|
|
88
151
|
|
|
89
|
-
|
|
90
|
-
`sources/repo/<source-name>` to the scoped view. Do not register the monorepo root and
|
|
91
|
-
rely on `extractTs.include` to select a package; `include` is only a file filter
|
|
92
|
-
inside the selected source boundary.
|
|
93
|
-
|
|
94
|
-
If the user first registers a monorepo root, run `context source inspect <source-name>`
|
|
152
|
+
If the user first registers a monorepo root, run `context source inspect <date>/<module>`
|
|
95
153
|
before extraction. Show the listed module paths to the user as a tree and
|
|
96
|
-
register
|
|
154
|
+
register each chosen package path under the same date. The
|
|
97
155
|
inspect output includes package names, manifest paths, versions when available,
|
|
98
156
|
and suggested `context source add` commands.
|
|
99
157
|
|
|
@@ -120,7 +178,7 @@ import {
|
|
|
120
178
|
source,
|
|
121
179
|
} from "@c4a/context";
|
|
122
180
|
|
|
123
|
-
const docs = source("20260704");
|
|
181
|
+
const docs = source("20260704", "product-docs", { type: "file" });
|
|
124
182
|
|
|
125
183
|
export default defineProject({
|
|
126
184
|
sources: [docs],
|
|
@@ -139,9 +197,9 @@ normal sequence is:
|
|
|
139
197
|
|
|
140
198
|
1. capture the source into committed snapshots;
|
|
141
199
|
2. investigate evidence and confirm `unapproved/structure.yaml`;
|
|
142
|
-
3. compile source-bound
|
|
143
|
-
4. review/apply
|
|
144
|
-
5. run close, verify
|
|
200
|
+
3. compile every source-bound View from confirmed structure;
|
|
201
|
+
4. review/apply the complete candidate batch once;
|
|
202
|
+
5. run close once, then verify and build when packages are declared.
|
|
145
203
|
|
|
146
204
|
Do not read `sources/` or raw Markdown directly after entering the Context
|
|
147
205
|
workflow; use the evidence views and `source_ref` values returned by the CLI.
|
|
@@ -153,7 +211,7 @@ Edit `src/index.ts`:
|
|
|
153
211
|
```ts
|
|
154
212
|
import { defineProject, extractTs, reviewValidity, source } from "@c4a/context";
|
|
155
213
|
|
|
156
|
-
const componentLib = source("
|
|
214
|
+
const componentLib = source("20260712", "component-lib");
|
|
157
215
|
|
|
158
216
|
export default defineProject({
|
|
159
217
|
sources: [componentLib],
|
|
@@ -169,8 +227,8 @@ Inspect and run:
|
|
|
169
227
|
|
|
170
228
|
```bash
|
|
171
229
|
context run --list
|
|
172
|
-
context run extract:
|
|
173
|
-
context run extract:
|
|
230
|
+
context run extract:20260712/component-lib:codegraph --dry-run
|
|
231
|
+
context run extract:20260712/component-lib:codegraph
|
|
174
232
|
```
|
|
175
233
|
|
|
176
234
|
When operating through an Agent, use `--dry-run --format json` as the CLI
|
|
@@ -179,18 +237,23 @@ implementation for a no-write preview. For extract phases it returns a
|
|
|
179
237
|
candidate estimates, `knowledgeTree`, `knowledgePathExamples`, and module-level
|
|
180
238
|
hints. Treat that preview as the scope check before producing draft candidates.
|
|
181
239
|
|
|
182
|
-
The
|
|
183
|
-
|
|
240
|
+
The codegraph path keeps the stable module identity. The date stays in the repo
|
|
241
|
+
source ref and phase id, not in the knowledge path:
|
|
184
242
|
|
|
185
243
|
```text
|
|
186
|
-
knowledge/<
|
|
244
|
+
knowledge/codegraph/<module>/symbol/<slug>.md
|
|
187
245
|
```
|
|
188
246
|
|
|
189
247
|
Show the tree/path preview to the user before first extraction and describe it
|
|
190
|
-
as a preview without writing candidates. If the
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
248
|
+
as a preview without writing candidates. If the module or path shape is not
|
|
249
|
+
what the user expects, fix the module registration before extraction. An
|
|
250
|
+
extra repeated package segment below the module may indicate an over-broad
|
|
251
|
+
boundary.
|
|
252
|
+
|
|
253
|
+
When one confirmed round contains several repo modules, preview and run their
|
|
254
|
+
extract phases sequentially but defer the human gate until every phase finishes.
|
|
255
|
+
The final Codegraph Review contains the combined draft set; do not review one
|
|
256
|
+
module at a time.
|
|
194
257
|
|
|
195
258
|
## 4. Review
|
|
196
259
|
|
|
@@ -200,7 +263,8 @@ context review html architecture --open
|
|
|
200
263
|
|
|
201
264
|
Use the generated HTML page to approve or reject candidates. If the browser does
|
|
202
265
|
not open automatically, use the emitted `file://` URL. When
|
|
203
|
-
finished, open `Payload` and copy the
|
|
266
|
+
finished, open `Payload` and copy the review decision Payload into the agent chat.
|
|
267
|
+
Uniform decisions use one JSON line; exceptions add JSONL lines. The
|
|
204
268
|
agent writes that pasted payload to a normal temporary file under the workspace
|
|
205
269
|
`.tmp/` directory and runs:
|
|
206
270
|
|
|
@@ -284,7 +348,7 @@ import {
|
|
|
284
348
|
source,
|
|
285
349
|
} from "@c4a/context";
|
|
286
350
|
|
|
287
|
-
const componentLib = source("
|
|
351
|
+
const componentLib = source("20260712", "component-lib");
|
|
288
352
|
|
|
289
353
|
export default defineProject({
|
|
290
354
|
sources: [componentLib],
|
|
@@ -299,7 +363,7 @@ export default defineProject({
|
|
|
299
363
|
path: "src/package-templates/kb",
|
|
300
364
|
vars: { displayName: "Component Library KB" },
|
|
301
365
|
},
|
|
302
|
-
select: { include: ["codegraph/
|
|
366
|
+
select: { include: ["codegraph/component-lib/**"] },
|
|
303
367
|
}),
|
|
304
368
|
],
|
|
305
369
|
});
|
|
@@ -312,7 +376,7 @@ of the agent knowledge-base package:
|
|
|
312
376
|
llmsPackage({
|
|
313
377
|
name: "component-lib-llms",
|
|
314
378
|
template: "src/package-templates/llms",
|
|
315
|
-
select: { include: ["codegraph/
|
|
379
|
+
select: { include: ["codegraph/component-lib/**"] },
|
|
316
380
|
});
|
|
317
381
|
```
|
|
318
382
|
|
|
@@ -54,7 +54,7 @@ Bad:
|
|
|
54
54
|
|
|
55
55
|
```text
|
|
56
56
|
Please provide source name:
|
|
57
|
-
context source add repo <
|
|
57
|
+
context source add repo <date> --module <module> --local <repo-or-subdir>
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
Good:
|
|
@@ -66,22 +66,17 @@ 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
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
knowledge/<
|
|
75
|
-
repo
|
|
76
|
-
dist/<source-name>-kb/...
|
|
69
|
+
The CLI uses today's local date (`YYYYMMDD`) as the repo batch. Each confirmed
|
|
70
|
+
package is registered as a module under that date, so the same batch can contain
|
|
71
|
+
web, Lynx, and shared modules without `-A/-B/-C` suffixes. The concrete selector
|
|
72
|
+
`YYYYMMDD/module` becomes part of source refs and phase ids, while approved
|
|
73
|
+
knowledge uses the stable module name without the date:
|
|
74
|
+
knowledge/codegraph/<module>/...
|
|
75
|
+
repo:YYYYMMDD/<module>#...
|
|
77
76
|
|
|
78
|
-
If today's
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
For a multi-module subspace package shape, the date source name can group
|
|
82
|
-
children like:
|
|
83
|
-
knowledge/codegraph/product-ui/component-web/...
|
|
84
|
-
knowledge/codegraph/product-ui/component-lynx/...
|
|
77
|
+
If today's batch already exists, add the next confirmed code or document module
|
|
78
|
+
to it; do not add a sequence number automatically. File/Lark registration
|
|
79
|
+
returns a `YYYYMMDD/module` identity and never requires a second flat date name.
|
|
85
80
|
|
|
86
81
|
For the current first extraction, I will still ask you to confirm the concrete
|
|
87
82
|
package/subdirectory boundary before reading code.
|
|
@@ -104,8 +99,8 @@ Good:
|
|
|
104
99
|
The source is registered, but registration did not read the document body.
|
|
105
100
|
|
|
106
101
|
The next operation will read this local Markdown file or folder and write a
|
|
107
|
-
committed
|
|
108
|
-
|
|
102
|
+
committed sibling file under `sources/file/<date>/`, tracked by that date's single `manifest.json`. The concrete
|
|
103
|
+
`YYYYMMDD/module` identity is returned by `context source add file`. That snapshot is used
|
|
109
104
|
later for review, verify, and fresh-clone reproduction.
|
|
110
105
|
|
|
111
106
|
Please confirm that I may read this document source now. After you confirm, I
|
|
@@ -119,8 +114,8 @@ For Lark / Feishu:
|
|
|
119
114
|
The source is registered, but registration did not fetch the remote document.
|
|
120
115
|
|
|
121
116
|
The next operation will read the Lark/Feishu document you provided and write a
|
|
122
|
-
normalized
|
|
123
|
-
date
|
|
117
|
+
normalized sibling file under `sources/lark/<date>/`, tracked by that date's single `manifest.json`. Several requested
|
|
118
|
+
documents may share the date; each has its own module and snapshot. The snapshot is
|
|
124
119
|
committed by default so verify can work offline and after a fresh clone. Access
|
|
125
120
|
credentials stay in the Lark CLI; they are not written to this workspace. If
|
|
126
121
|
your business repository wants to ignore this snapshot, that is a repository
|
|
@@ -180,6 +175,13 @@ a simple structure draft. It still goes through structure confirmation and
|
|
|
180
175
|
source-bound compile; there is no separate shortcut that writes final page body
|
|
181
176
|
directly from capture.
|
|
182
177
|
|
|
178
|
+
Validator-required page splits and continuous-source Section splits are not a
|
|
179
|
+
new approval round. Apply the returned repair route, validate until
|
|
180
|
+
`confirmation_ready=true`, then stage and present the automatically opened HTML
|
|
181
|
+
report for one final structure confirmation. If evidence leaves multiple
|
|
182
|
+
incompatible semantic structures, ask only that design question and explicitly
|
|
183
|
+
say it is not the final report-based review.
|
|
184
|
+
|
|
183
185
|
## Extraction Scope Gate
|
|
184
186
|
|
|
185
187
|
Bad:
|
|
@@ -187,7 +189,7 @@ Bad:
|
|
|
187
189
|
```text
|
|
188
190
|
是否按 Context 默认范围继续?
|
|
189
191
|
extractTs({
|
|
190
|
-
source: source("
|
|
192
|
+
source: source("20260712", "component-lib"),
|
|
191
193
|
collection: "codegraph",
|
|
192
194
|
// include defaults to ["src/**/*.{ts,tsx}"]
|
|
193
195
|
// exportedOnly defaults to true
|
|
@@ -248,6 +250,11 @@ You do not need to save a payload file; I will write a temporary file and run
|
|
|
248
250
|
the apply command.
|
|
249
251
|
```
|
|
250
252
|
|
|
253
|
+
For a multi-View document or multi-module code round, use this wording only
|
|
254
|
+
after the CLI reports that the complete batch is prepared. Do not ask the user
|
|
255
|
+
to review one page or module while other confirmed items in the same round are
|
|
256
|
+
still being generated.
|
|
257
|
+
|
|
251
258
|
For a repeated codegraph run with no Review delta, say instead:
|
|
252
259
|
|
|
253
260
|
```text
|
|
@@ -260,8 +267,10 @@ For an explicitly requested CI/CD path, say:
|
|
|
260
267
|
|
|
261
268
|
```text
|
|
262
269
|
I will run the codegraph phase with --auto-promote. It will apply only
|
|
263
|
-
deterministic code add/update/remove deltas,
|
|
264
|
-
|
|
270
|
+
deterministic code add/update/remove deltas, refresh deterministic close when
|
|
271
|
+
needed, run verification, and fail the pipeline if close or verification fails.
|
|
272
|
+
Package build remains a separate publishing step. Semantic knowledge still
|
|
273
|
+
requires Review.
|
|
265
274
|
```
|
|
266
275
|
|
|
267
276
|
## Package Gate
|