@c4a/context 0.6.0-beta.4 → 0.6.0-beta.6
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 +54 -22
- package/docs/guides/agent-guide.md +149 -55
- package/docs/reference/package-templates.md +7 -1
- package/docs/reference/project-api.md +250 -48
- package/index.d.ts +1 -1
- package/index.js +220 -103
- package/package.json +1 -1
- package/phases.d.ts +9 -0
- 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,53 +95,104 @@ 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
|
+
Do not infer permission from the presence of a command. Do not infer a command
|
|
156
|
+
from prose when `commands_available=false`; complete the returned configuration
|
|
157
|
+
action and rerun status instead.
|
|
127
158
|
|
|
128
159
|
Extraction scope is also a human gate. If no extract phase is declared, explain
|
|
129
160
|
what code area and symbol policy will become draft knowledge, then ask which
|
|
130
161
|
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
|
-
|
|
162
|
+
repository to choose packages or globs on the user's behalf. Status reports
|
|
163
|
+
`needs-extract-phase` with `routing.configuration` until that confirmed scope is
|
|
164
|
+
declared; only a declared phase can advance to `ready-to-extract` and return an
|
|
165
|
+
executable preview or extraction command.
|
|
166
|
+
|
|
167
|
+
For a fresh mixed-source workspace, capture every confirmed file/Lark source
|
|
168
|
+
first. If repo code is still unprocessed and document structure has not started,
|
|
169
|
+
`context status` prioritizes `ready-to-extract` over document investigation.
|
|
170
|
+
Complete the code extraction and its batch Review before starting prose align.
|
|
171
|
+
Once a document structure draft exists, keep that current human gate and do not
|
|
172
|
+
switch workflows mid-review.
|
|
173
|
+
|
|
174
|
+
For monorepos, the date is one registration batch and every selected package is
|
|
175
|
+
a module under it. Stable codegraph paths omit that batch date and therefore
|
|
176
|
+
look like `knowledge/codegraph/module-a/...` and
|
|
177
|
+
`knowledge/codegraph/module-b/...`. Date/module remains in phase ids and
|
|
178
|
+
repo source refs. Use the whole repo/subspace
|
|
179
|
+
only for inspection when it contains multiple modules. If the user chooses
|
|
180
|
+
`packages/button`, register it with `--module button` under the same date and
|
|
181
|
+
write `extractTs({ source: source("20260712", "button"), ... })`. Do not use
|
|
142
182
|
`include: ["packages/button/src/**"]` to choose a package from a larger source;
|
|
143
|
-
`include` only filters files inside the selected source.
|
|
183
|
+
`include` only filters files inside the selected source. Repo module names are
|
|
184
|
+
project-wide codegraph identities; refresh an existing module through its
|
|
185
|
+
original date/module selector instead of reusing its name under a later date.
|
|
186
|
+
|
|
187
|
+
For a non-standard package, configure source-relative `entries` on `extractTs`;
|
|
188
|
+
every entry must match `include`. If the user wants all declarations in the
|
|
189
|
+
selected files instead of public API reachability, use `mode: "scan"`, which
|
|
190
|
+
needs no entries and defaults to including internal symbols. Never add an entry
|
|
191
|
+
file or package manifest field to the source repository solely to make Context
|
|
192
|
+
run.
|
|
144
193
|
|
|
145
194
|
Follow the source inspection pattern when scope is unclear: run
|
|
146
|
-
`context source inspect <
|
|
195
|
+
`context source inspect <date>/<module> --format json`, show the candidate package
|
|
147
196
|
paths from that CLI output, wait for the user to choose the package path(s), then
|
|
148
197
|
declare sources/phases. If the extraction preview reports modules outside the
|
|
149
198
|
confirmed source boundary, stop before review and repair the source declaration.
|
|
@@ -151,33 +200,65 @@ confirmed source boundary, stop before review and repair the source declaration.
|
|
|
151
200
|
Before running extraction, prefer:
|
|
152
201
|
|
|
153
202
|
```bash
|
|
154
|
-
context source inspect <
|
|
203
|
+
context source inspect <date>/<module> --format json
|
|
155
204
|
context run <extract-phase-id> --dry-run --format json
|
|
156
205
|
```
|
|
157
206
|
|
|
158
|
-
|
|
207
|
+
After the preview, run codegraph extraction normally unless the user explicitly
|
|
208
|
+
asked for CI/CD automation. The first normal run requires Review for all code
|
|
209
|
+
candidates. Subsequent normal runs require Review only for added, changed, or
|
|
210
|
+
removed symbols; unchanged approved symbols stay approved. Always inspect
|
|
211
|
+
`next_action.human_gate`: `continue-codegraph-batch` means run status and finish
|
|
212
|
+
the remaining confirmed module phases. Open one Review only after
|
|
213
|
+
`pendingExtractPhases` is empty and the returned gate is `true`.
|
|
214
|
+
|
|
215
|
+
For a non-interactive pipeline, use `context run <extract-phase-id>
|
|
216
|
+
--auto-promote --format json`. This flag applies only to codegraph, applies its
|
|
217
|
+
deterministic deltas, refreshes deterministic close when needed, runs verify,
|
|
218
|
+
and fails the command if close or verify fails. Read `autoPromotion.close` and
|
|
219
|
+
`autoPromotion.verify` before continuing. Package build remains explicit: when
|
|
220
|
+
the pipeline publishes packages, run `context build` after successful auto
|
|
221
|
+
promotion. Never use auto promotion for semantic knowledge collections.
|
|
222
|
+
|
|
223
|
+
If verify reports `approved-source-ref-ambiguous` on approved codegraph pages
|
|
224
|
+
created by beta.5, do not send those pages back through Review and do not filter
|
|
225
|
+
approved symbols away. Rerun the declared codegraph extraction phase to refresh
|
|
226
|
+
the trusted file-aware symbol index, then run `context review
|
|
227
|
+
migrate-codegraph-refs` and `context verify`. Tell the user that this preserves
|
|
228
|
+
their decisions and approved content while upgrading evidence metadata. If the
|
|
229
|
+
reported ref already contains `<file>:<symbol>:<kind>`, treat it as a duplicate
|
|
230
|
+
symbol-index defect instead of a legacy migration.
|
|
231
|
+
|
|
232
|
+
Use the preview `mode`, optional `entries`, `preview.sources[].modules[]`,
|
|
233
|
+
`candidateEstimate`, and `agent_hints`
|
|
159
234
|
fields as the authoritative scope check. To the user, call it a preview without
|
|
160
235
|
writing candidates; avoid the internal CLI term. Also show `knowledgeTree` and
|
|
161
|
-
`knowledgePathExamples` before first extraction.
|
|
162
|
-
|
|
236
|
+
`knowledgePathExamples` before first extraction.
|
|
237
|
+
|
|
238
|
+
Treat `NO_ENTRY_DETECTED` as a configuration failure: choose explicit
|
|
239
|
+
`entries`, or use `mode: "scan"` when the intended scope is all matched files;
|
|
240
|
+
never report an empty extraction as success. Report discovered, AST-analyzed,
|
|
241
|
+
skipped, symbol, and relation counts separately. The extractor follows
|
|
242
|
+
tsconfig/jsconfig `baseUrl` and `paths`, so do not ask users to rewrite `@/`
|
|
243
|
+
imports solely for Context. Explain the concrete output shape:
|
|
163
244
|
|
|
164
245
|
```text
|
|
165
|
-
knowledge/<
|
|
246
|
+
knowledge/codegraph/<module>/symbol/<slug>.md
|
|
166
247
|
```
|
|
167
248
|
|
|
168
|
-
If the
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
root should not repeat the package name in the path. A source rename after
|
|
172
|
-
extraction is a migration, not a cosmetic change. Do not write ad hoc scripts to
|
|
249
|
+
If the module or resulting path shape looks wrong, stop and repair the
|
|
250
|
+
module registration before running extraction. An extra repeated package
|
|
251
|
+
segment below the module may indicate an over-broad source boundary. Do not write ad hoc scripts to
|
|
173
252
|
count packages, parse `package.json`, or sample `unapproved/entities.jsonl`.
|
|
174
253
|
|
|
175
254
|
## Review Rules
|
|
176
255
|
|
|
177
|
-
- Use `context review html <collection> --open` for visual review.
|
|
178
|
-
|
|
256
|
+
- Use `context review html <collection> --open --format json` for visual review.
|
|
257
|
+
Check `opened`: say the browser opened only when it is `true`; otherwise
|
|
258
|
+
report `open_error` and provide the emitted `file_url` plus `absolute_path`.
|
|
179
259
|
- Use `context review list <collection>` only for a textual overview.
|
|
180
|
-
- Ask the user to paste the copied
|
|
260
|
+
- Ask the user to paste the copied review decision Payload into chat. Uniform
|
|
261
|
+
decisions use one JSON line; exceptions add JSONL lines. The agent writes
|
|
181
262
|
that pasted payload to a temporary scratch file and runs `context review apply
|
|
182
263
|
<payload-file>` only after the user has reviewed and provided the payload.
|
|
183
264
|
- Do not synthesize review payloads from HTML, JSON, runtime snapshots, or
|
|
@@ -187,7 +268,7 @@ count packages, parse `package.json`, or sample `unapproved/entities.jsonl`.
|
|
|
187
268
|
`context review approve <candidate-id> --collection <collection>` /
|
|
188
269
|
`context review reject <candidate-id> --collection <collection>` or `--all`.
|
|
189
270
|
These commands still enforce the scoped candidate-id gate.
|
|
190
|
-
- Do not expand compact review
|
|
271
|
+
- Do not expand the compact review decision Payload into pretty JSON unless the user asks.
|
|
191
272
|
- Do not edit approved Markdown by hand as part of review apply.
|
|
192
273
|
|
|
193
274
|
## Prose Align And Compile Rules
|
|
@@ -198,8 +279,10 @@ product sequence:
|
|
|
198
279
|
1. investigate material through Context evidence views;
|
|
199
280
|
2. propose a structure draft with nodes, section plans, supported edges, and
|
|
200
281
|
unresolved items;
|
|
201
|
-
3.
|
|
202
|
-
|
|
282
|
+
3. repair validator blockers until `confirmation_ready=true`, stage the
|
|
283
|
+
structure, open its HTML report, then ask the user to confirm it because
|
|
284
|
+
confirmation freezes paths, section ownership, relationships, and compile
|
|
285
|
+
order for this round;
|
|
203
286
|
4. compile source-bound draft pages from confirmed structure;
|
|
204
287
|
5. send compiled drafts through human review, then close and build.
|
|
205
288
|
|
|
@@ -221,9 +304,16 @@ context run align:<type>:<source>:<collection> --stage --input <structure.yaml>
|
|
|
221
304
|
|
|
222
305
|
Read source material only through these evidence views. `source-index` gives a
|
|
223
306
|
compact refs-first map when run with `--compact`; use `span-detail` /
|
|
224
|
-
`span-text` only for exact evidence.
|
|
225
|
-
|
|
226
|
-
|
|
307
|
+
`span-text` only for exact evidence. When validate returns
|
|
308
|
+
`repair_confirmation_blockers`, follow its repair route without asking for
|
|
309
|
+
preliminary approval. `--repair suggested-splits` mechanically handles
|
|
310
|
+
non-contiguous source Sections. For oversized Views, use the returned child
|
|
311
|
+
View and contains-edge suggestions while classifying child Nodes from evidence.
|
|
312
|
+
Stage only after
|
|
313
|
+
`confirmation_ready=true`; stage opens the final `structure-summary` report for
|
|
314
|
+
the structure confirmation gate. Ask a separate structure-design question only
|
|
315
|
+
when evidence supports multiple incompatible semantic choices, and make clear
|
|
316
|
+
that it is not final review. Do not inspect `sources/` or `.tmp` directly.
|
|
227
317
|
|
|
228
318
|
Compile:
|
|
229
319
|
|
|
@@ -235,6 +325,10 @@ context run compile:<type>:<source>:<collection> --validate --input <compile-act
|
|
|
235
325
|
context run compile:<type>:<source>:<collection> --stage --input <compile-actions.yaml> --format json
|
|
236
326
|
```
|
|
237
327
|
|
|
328
|
+
Compile each confirmed View sequentially, but do not stop for Review after each
|
|
329
|
+
write. Follow `continue_compile_batch` until no planned View remains; then open
|
|
330
|
+
one collection-level Review, apply one Payload, and run close once.
|
|
331
|
+
|
|
238
332
|
Default compile actions should mirror source spans into `verbatim` body and
|
|
239
333
|
attach summary/kind/source refs. Explicit reader-visible content is not part of
|
|
240
334
|
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.
|