@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
|
@@ -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
|
|
49
|
+
- file and Lark documents from one date live as sibling files under `sources/file/<date>/` and `sources/lark/<date>/`; each date directory has one shared `manifest.json`.
|
|
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:<
|
|
61
|
+
| Capture document sources | Run the declared `capture:file:<date>/<module>` or `capture:lark:<date>/<module>` phase only after read permission. Capture writes a sibling document file under the matching date directory and updates that directory's single `manifest.json`. |
|
|
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,16 +80,14 @@ 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.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
paths are derived from collection, containment, and slug. NodeRef/ViewRef are
|
|
88
|
-
identity fields, not path strings:
|
|
83
|
+
as a source boundary decision. Document sources use today's local date as their
|
|
84
|
+
name. Repo sources use the date as a batch and require the confirmed module
|
|
85
|
+
identity. Do not invent semantic date suffixes. The concrete repo selector
|
|
86
|
+
appears in source refs, phase ids, and codegraph paths:
|
|
89
87
|
|
|
90
88
|
```text
|
|
91
89
|
knowledge/<collection>/<containment>/<slug>.md
|
|
92
|
-
repo:<
|
|
90
|
+
repo:<date>/<module>#symbol:...
|
|
93
91
|
file:<source-name>/<document>#span:...
|
|
94
92
|
lark:<source-name>/<document>#span:...
|
|
95
93
|
capture:file:<source-name>
|
|
@@ -97,50 +95,102 @@ align:lark:<source-name>:architecture
|
|
|
97
95
|
dist/<source-name>-kb/
|
|
98
96
|
```
|
|
99
97
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
planning may choose containment that reflects package/module shape when the
|
|
103
|
-
source boundary intentionally covers multiple modules.
|
|
98
|
+
Prose align/compile paths derive from collection, containment, and slug.
|
|
99
|
+
Codegraph paths use the registered date/module grouping before the symbol slug.
|
|
104
100
|
|
|
105
101
|
Ask what the user wants the source to cover: a single local Markdown/MDX document,
|
|
106
102
|
a local Markdown/MDX directory, an article/documentation repository as a file
|
|
107
|
-
source, a Lark/Feishu document URL or token, a local code repo/package, a
|
|
108
|
-
Git repo/package
|
|
109
|
-
|
|
110
|
-
|
|
103
|
+
source, a Lark/Feishu document URL or token, a local code repo/package, or a
|
|
104
|
+
remote Git repo/package. Repo sources use today's date as one batch and a
|
|
105
|
+
confirmed `--module` identity; do not create date suffixes for separate
|
|
106
|
+
packages. The CLI rejects non-date or impossible repo batch names. Use
|
|
107
|
+
`context source ensure <date>` / `context source inspect <date>` to operate on
|
|
108
|
+
all registered modules in one batch, or `<date>/<module>` for one module.
|
|
109
|
+
If the user supplies several repo/file/Lark sources in one request, create one
|
|
110
|
+
`context source add batch <date> --input <payload> --format json` payload and
|
|
111
|
+
register them under a single project write lock. Never parallelize mutating
|
|
112
|
+
`source add` commands; on a lock-held error, wait and retry.
|
|
111
113
|
|
|
112
114
|
Current execution supports repo sources, local Markdown/MDX file sources, and Lark /
|
|
113
115
|
Feishu document sources. Local
|
|
114
|
-
repo/package sources are registered with `context source add repo --local <path>`;
|
|
115
|
-
the materialized `sources/repo/<
|
|
116
|
-
symlink to the selected checkout or subdirectory view.
|
|
117
|
-
|
|
116
|
+
repo/package sources are registered with `context source add repo [YYYYMMDD] --module <module> --local <path>`;
|
|
117
|
+
the materialized `sources/repo/<date>/<module>` entry is an ignored
|
|
118
|
+
relative symlink to the selected checkout or subdirectory view. If the source
|
|
119
|
+
and Context workspace share a Git root, absolute input is normalized to a
|
|
120
|
+
workspace-relative repo root plus `subpath`; do not rewrite it back to an
|
|
121
|
+
absolute machine path. Local Markdown/MDX sources
|
|
122
|
+
are registered with `context source add file [YYYYMMDD] --module <module> --local <path>` plus any
|
|
118
123
|
needed `--include` patterns, captured with `captureFile`, then planned through
|
|
119
124
|
`alignProse` and compiled with
|
|
120
125
|
`compileProse`. A one-file-to-one-page outcome is a degenerate structure plan,
|
|
121
126
|
not a separate content path. Remote Git operations require explicit user approval before any
|
|
122
127
|
clone/checkout; clone into an ignored local path, checkout the requested commit,
|
|
123
128
|
then register that local checkout. Do not commit cloned source content. Lark /
|
|
124
|
-
Feishu sources are registered as document
|
|
125
|
-
capture phase, and written as committed snapshots
|
|
129
|
+
Feishu sources are registered as document modules under a shared date batch,
|
|
130
|
+
captured through the Lark capture phase, and written as committed snapshots
|
|
131
|
+
as a sibling file under `sources/lark/<date>/`, tracked by the date-level `manifest.json`;
|
|
126
132
|
do not fetch or import Lark content with ad hoc scripts.
|
|
133
|
+
If the user requests multiple documents together, register and declare all of
|
|
134
|
+
them before capture. The user's explicit batch request supplies one read scope
|
|
135
|
+
and one mainline collection choice. Follow `routing.command_plan`: run
|
|
136
|
+
`immediate` items directly and run `after-human-confirmation` items only after
|
|
137
|
+
the current conversation contains that confirmation. Do not ask for another
|
|
138
|
+
date name or repeat the collection gate per document.
|
|
139
|
+
|
|
140
|
+
## Current-step protocol
|
|
141
|
+
|
|
142
|
+
Treat `context status --format json` `routing` as the complete protocol for the
|
|
143
|
+
current step:
|
|
144
|
+
|
|
145
|
+
- `human_gate.required` says whether user input is required;
|
|
146
|
+
- `human_gate.kind` says which product decision is being made;
|
|
147
|
+
- `human_gate.confirmation` and `persistence` distinguish conversation-only
|
|
148
|
+
permission from decisions persisted by a workspace command;
|
|
149
|
+
- `configuration` identifies the exact project file and declaration action when
|
|
150
|
+
no CLI command is valid yet;
|
|
151
|
+
- `commands_available` reports whether a command plan exists; and
|
|
152
|
+
- `command_plan[].availability` says whether each command runs immediately or
|
|
153
|
+
only after user confirmation.
|
|
154
|
+
|
|
155
|
+
Status also returns `declarationGraph` and `configurationGaps`. These expose
|
|
156
|
+
capture, align, compile, and Review coverage for each canonical document source
|
|
157
|
+
and declared align collection. Missing declarations are early warnings while
|
|
158
|
+
structure is still being planned; after confirmation, every collection planned
|
|
159
|
+
by the structure must have an exact compile route for the same source. Do not
|
|
160
|
+
run a compile command from another collection as a fallback. A
|
|
161
|
+
`reviewValidity({ scope: "all" })` declaration covers every collection.
|
|
162
|
+
|
|
163
|
+
Do not infer permission from the presence of a command. Do not infer a command
|
|
164
|
+
from prose when `commands_available=false`; complete the returned configuration
|
|
165
|
+
action and rerun status instead.
|
|
127
166
|
|
|
128
167
|
Extraction scope is also a human gate. If no extract phase is declared, explain
|
|
129
168
|
what code area and symbol policy will become draft knowledge, then ask which
|
|
130
169
|
registered source and file/symbol range to ingest. Do not inspect the source
|
|
131
|
-
repository to choose packages or globs on the user's behalf.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
170
|
+
repository to choose packages or globs on the user's behalf. Status reports
|
|
171
|
+
`needs-extract-phase` with `routing.configuration` until that confirmed scope is
|
|
172
|
+
declared; only a declared phase can advance to `ready-to-extract` and return an
|
|
173
|
+
executable preview or extraction command.
|
|
174
|
+
|
|
175
|
+
For a fresh mixed-source workspace, capture every confirmed file/Lark source
|
|
176
|
+
first. If repo code is still unprocessed and document structure has not started,
|
|
177
|
+
`context status` prioritizes `ready-to-extract` over document investigation.
|
|
178
|
+
Complete the code extraction and its batch Review before starting prose align.
|
|
179
|
+
Once a document structure draft exists, keep that current human gate and do not
|
|
180
|
+
switch workflows mid-review.
|
|
181
|
+
|
|
182
|
+
For monorepos, the date is one registration batch and every selected package is
|
|
183
|
+
a module under it. Stable codegraph paths omit that batch date and therefore
|
|
184
|
+
look like `knowledge/codegraph/module-a/...` and
|
|
185
|
+
`knowledge/codegraph/module-b/...`. Date/module remains in phase ids and
|
|
186
|
+
repo source refs. Use the whole repo/subspace
|
|
187
|
+
only for inspection when it contains multiple modules. If the user chooses
|
|
188
|
+
`packages/button`, register it with `--module button` under the same date and
|
|
189
|
+
write `extractTs({ source: source("20260712", "button"), ... })`. Do not use
|
|
142
190
|
`include: ["packages/button/src/**"]` to choose a package from a larger source;
|
|
143
|
-
`include` only filters files inside the selected source.
|
|
191
|
+
`include` only filters files inside the selected source. Repo module names are
|
|
192
|
+
project-wide codegraph identities; refresh an existing module through its
|
|
193
|
+
original date/module selector instead of reusing its name under a later date.
|
|
144
194
|
|
|
145
195
|
For a non-standard package, configure source-relative `entries` on `extractTs`;
|
|
146
196
|
every entry must match `include`. If the user wants all declarations in the
|
|
@@ -150,7 +200,7 @@ file or package manifest field to the source repository solely to make Context
|
|
|
150
200
|
run.
|
|
151
201
|
|
|
152
202
|
Follow the source inspection pattern when scope is unclear: run
|
|
153
|
-
`context source inspect <
|
|
203
|
+
`context source inspect <date>/<module> --format json`, show the candidate package
|
|
154
204
|
paths from that CLI output, wait for the user to choose the package path(s), then
|
|
155
205
|
declare sources/phases. If the extraction preview reports modules outside the
|
|
156
206
|
confirmed source boundary, stop before review and repair the source declaration.
|
|
@@ -158,7 +208,7 @@ confirmed source boundary, stop before review and repair the source declaration.
|
|
|
158
208
|
Before running extraction, prefer:
|
|
159
209
|
|
|
160
210
|
```bash
|
|
161
|
-
context source inspect <
|
|
211
|
+
context source inspect <date>/<module> --format json
|
|
162
212
|
context run <extract-phase-id> --dry-run --format json
|
|
163
213
|
```
|
|
164
214
|
|
|
@@ -166,13 +216,26 @@ After the preview, run codegraph extraction normally unless the user explicitly
|
|
|
166
216
|
asked for CI/CD automation. The first normal run requires Review for all code
|
|
167
217
|
candidates. Subsequent normal runs require Review only for added, changed, or
|
|
168
218
|
removed symbols; unchanged approved symbols stay approved. Always inspect
|
|
169
|
-
`next_action.human_gate`:
|
|
170
|
-
|
|
219
|
+
`next_action.human_gate`: `continue-codegraph-batch` means run status and finish
|
|
220
|
+
the remaining confirmed module phases. Open one Review only after
|
|
221
|
+
`pendingExtractPhases` is empty and the returned gate is `true`.
|
|
171
222
|
|
|
172
223
|
For a non-interactive pipeline, use `context run <extract-phase-id>
|
|
173
224
|
--auto-promote --format json`. This flag applies only to codegraph, applies its
|
|
174
|
-
deterministic deltas,
|
|
175
|
-
|
|
225
|
+
deterministic deltas, refreshes deterministic close when needed, runs verify,
|
|
226
|
+
and fails the command if close or verify fails. Read `autoPromotion.close` and
|
|
227
|
+
`autoPromotion.verify` before continuing. Package build remains explicit: when
|
|
228
|
+
the pipeline publishes packages, run `context build` after successful auto
|
|
229
|
+
promotion. Never use auto promotion for semantic knowledge collections.
|
|
230
|
+
|
|
231
|
+
If verify reports `approved-source-ref-ambiguous` on approved codegraph pages
|
|
232
|
+
created by beta.5, do not send those pages back through Review and do not filter
|
|
233
|
+
approved symbols away. Rerun the declared codegraph extraction phase to refresh
|
|
234
|
+
the trusted file-aware symbol index, then run `context review
|
|
235
|
+
migrate-codegraph-refs` and `context verify`. Tell the user that this preserves
|
|
236
|
+
their decisions and approved content while upgrading evidence metadata. If the
|
|
237
|
+
reported ref already contains `<file>:<symbol>:<kind>`, treat it as a duplicate
|
|
238
|
+
symbol-index defect instead of a legacy migration.
|
|
176
239
|
|
|
177
240
|
Use the preview `mode`, optional `entries`, `preview.sources[].modules[]`,
|
|
178
241
|
`candidateEstimate`, and `agent_hints`
|
|
@@ -185,26 +248,25 @@ Treat `NO_ENTRY_DETECTED` as a configuration failure: choose explicit
|
|
|
185
248
|
never report an empty extraction as success. Report discovered, AST-analyzed,
|
|
186
249
|
skipped, symbol, and relation counts separately. The extractor follows
|
|
187
250
|
tsconfig/jsconfig `baseUrl` and `paths`, so do not ask users to rewrite `@/`
|
|
188
|
-
imports solely for Context. Explain
|
|
189
|
-
paths derived from collection, containment, and slug:
|
|
251
|
+
imports solely for Context. Explain the concrete output shape:
|
|
190
252
|
|
|
191
253
|
```text
|
|
192
|
-
knowledge/<
|
|
254
|
+
knowledge/codegraph/<module>/symbol/<slug>.md
|
|
193
255
|
```
|
|
194
256
|
|
|
195
|
-
If the
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
root should not repeat the package name in the path. A source rename after
|
|
199
|
-
extraction is a migration, not a cosmetic change. Do not write ad hoc scripts to
|
|
257
|
+
If the module or resulting path shape looks wrong, stop and repair the
|
|
258
|
+
module registration before running extraction. An extra repeated package
|
|
259
|
+
segment below the module may indicate an over-broad source boundary. Do not write ad hoc scripts to
|
|
200
260
|
count packages, parse `package.json`, or sample `unapproved/entities.jsonl`.
|
|
201
261
|
|
|
202
262
|
## Review Rules
|
|
203
263
|
|
|
204
|
-
- Use `context review html <collection> --open` for visual review.
|
|
205
|
-
|
|
264
|
+
- Use `context review html <collection> --open --format json` for visual review.
|
|
265
|
+
Check `opened`: say the browser opened only when it is `true`; otherwise
|
|
266
|
+
report `open_error` and provide the emitted `file_url` plus `absolute_path`.
|
|
206
267
|
- Use `context review list <collection>` only for a textual overview.
|
|
207
|
-
- Ask the user to paste the copied
|
|
268
|
+
- Ask the user to paste the copied review decision Payload into chat. Uniform
|
|
269
|
+
decisions use one JSON line; exceptions add JSONL lines. The agent writes
|
|
208
270
|
that pasted payload to a temporary scratch file and runs `context review apply
|
|
209
271
|
<payload-file>` only after the user has reviewed and provided the payload.
|
|
210
272
|
- Do not synthesize review payloads from HTML, JSON, runtime snapshots, or
|
|
@@ -214,7 +276,7 @@ count packages, parse `package.json`, or sample `unapproved/entities.jsonl`.
|
|
|
214
276
|
`context review approve <candidate-id> --collection <collection>` /
|
|
215
277
|
`context review reject <candidate-id> --collection <collection>` or `--all`.
|
|
216
278
|
These commands still enforce the scoped candidate-id gate.
|
|
217
|
-
- Do not expand compact review
|
|
279
|
+
- Do not expand the compact review decision Payload into pretty JSON unless the user asks.
|
|
218
280
|
- Do not edit approved Markdown by hand as part of review apply.
|
|
219
281
|
|
|
220
282
|
## Prose Align And Compile Rules
|
|
@@ -225,8 +287,10 @@ product sequence:
|
|
|
225
287
|
1. investigate material through Context evidence views;
|
|
226
288
|
2. propose a structure draft with nodes, section plans, supported edges, and
|
|
227
289
|
unresolved items;
|
|
228
|
-
3.
|
|
229
|
-
|
|
290
|
+
3. repair validator blockers until `confirmation_ready=true`, stage the
|
|
291
|
+
structure, open its HTML report, then ask the user to confirm it because
|
|
292
|
+
confirmation freezes paths, section ownership, relationships, and compile
|
|
293
|
+
order for this round;
|
|
230
294
|
4. compile source-bound draft pages from confirmed structure;
|
|
231
295
|
5. send compiled drafts through human review, then close and build.
|
|
232
296
|
|
|
@@ -248,9 +312,16 @@ context run align:<type>:<source>:<collection> --stage --input <structure.yaml>
|
|
|
248
312
|
|
|
249
313
|
Read source material only through these evidence views. `source-index` gives a
|
|
250
314
|
compact refs-first map when run with `--compact`; use `span-detail` /
|
|
251
|
-
`span-text` only for exact evidence.
|
|
252
|
-
|
|
253
|
-
|
|
315
|
+
`span-text` only for exact evidence. When validate returns
|
|
316
|
+
`repair_confirmation_blockers`, follow its repair route without asking for
|
|
317
|
+
preliminary approval. `--repair suggested-splits` mechanically handles
|
|
318
|
+
non-contiguous source Sections. For oversized Views, use the returned child
|
|
319
|
+
View and contains-edge suggestions while classifying child Nodes from evidence.
|
|
320
|
+
Stage only after
|
|
321
|
+
`confirmation_ready=true`; stage opens the final `structure-summary` report for
|
|
322
|
+
the structure confirmation gate. Ask a separate structure-design question only
|
|
323
|
+
when evidence supports multiple incompatible semantic choices, and make clear
|
|
324
|
+
that it is not final review. Do not inspect `sources/` or `.tmp` directly.
|
|
254
325
|
|
|
255
326
|
Compile:
|
|
256
327
|
|
|
@@ -262,6 +333,10 @@ context run compile:<type>:<source>:<collection> --validate --input <compile-act
|
|
|
262
333
|
context run compile:<type>:<source>:<collection> --stage --input <compile-actions.yaml> --format json
|
|
263
334
|
```
|
|
264
335
|
|
|
336
|
+
Compile each confirmed View sequentially, but do not stop for Review after each
|
|
337
|
+
write. Follow `continue_compile_batch` until no planned View remains; then open
|
|
338
|
+
one collection-level Review, apply one Payload, and run close once.
|
|
339
|
+
|
|
265
340
|
Default compile actions should mirror source spans into `verbatim` body and
|
|
266
341
|
attach summary/kind/source refs. Explicit reader-visible content is not part of
|
|
267
342
|
the current compile action contract; split evidence or return to structure
|
|
@@ -182,10 +182,16 @@ Approved Markdown and kb package OKF output are an OKF superset:
|
|
|
182
182
|
Accepted section `source_ref` forms:
|
|
183
183
|
|
|
184
184
|
```text
|
|
185
|
-
src-N#symbol:<symbol-id>:<kind>@<digest>
|
|
185
|
+
src-N#symbol:<file>:<symbol-id>:<kind>@<digest>
|
|
186
186
|
src-N#span:<heading-hint> L<start>-<end>@<span-hash>
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
+
The code symbol form includes the source-relative file so same-name symbols in
|
|
190
|
+
different files resolve to one exact symbol-index row. Consumers should still
|
|
191
|
+
treat the complete `source_ref` as opaque. Codegraph pages keep
|
|
192
|
+
`candidate_fingerprint` at the top level and do not duplicate this evidence in
|
|
193
|
+
`code_origin`.
|
|
194
|
+
|
|
189
195
|
`#span:` refs retain source snapshot line ranges for human review, diffing, and
|
|
190
196
|
stable re-pinning. They resolve against committed file/lark document snapshots,
|
|
191
197
|
not the code symbol index.
|