@c4a/context-cli 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.
Files changed (57) hide show
  1. package/README.md +19 -4
  2. package/cli.js +5330 -3154
  3. package/package.json +2 -2
  4. package/plugin/skills/skill-continue-workflow/SKILL.md +26 -2
  5. package/plugin/skills/skill-prose-align/SKILL.md +32 -15
  6. package/plugin/skills/skill-prose-align/references/internal-procedures/structure-planning.md +5 -3
  7. package/plugin/skills/skill-prose-compile/SKILL.md +27 -13
  8. package/plugin/skills/skill-review-gate/SKILL.md +33 -10
  9. package/plugin/skills/skill-source-scope/SKILL.md +165 -105
  10. package/plugin/skills/skill-source-scope/references/capture-source.md +32 -12
  11. package/plugins/VERSION +1 -1
  12. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  13. package/plugins/claude/skills/skill-continue-workflow/SKILL.md +26 -2
  14. package/plugins/claude/skills/skill-prose-align/SKILL.md +32 -15
  15. package/plugins/claude/skills/skill-prose-align/references/internal-procedures/structure-planning.md +5 -3
  16. package/plugins/claude/skills/skill-prose-compile/SKILL.md +27 -13
  17. package/plugins/claude/skills/skill-review-gate/SKILL.md +33 -10
  18. package/plugins/claude/skills/skill-source-scope/SKILL.md +165 -105
  19. package/plugins/claude/skills/skill-source-scope/references/capture-source.md +32 -12
  20. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  21. package/plugins/codex/skills/continue/references/internal-procedures/skill-continue-workflow.md +26 -2
  22. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning.md +5 -3
  23. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-align.md +32 -15
  24. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile.md +27 -13
  25. package/plugins/codex/skills/continue/references/internal-procedures/skill-review-gate.md +33 -10
  26. package/plugins/codex/skills/continue/references/internal-procedures/skill-source-scope/references/capture-source.md +32 -12
  27. package/plugins/codex/skills/continue/references/internal-procedures/skill-source-scope.md +165 -105
  28. package/plugins/codex/skills/init/references/internal-procedures/skill-continue-workflow.md +26 -2
  29. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning.md +5 -3
  30. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-align.md +32 -15
  31. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile.md +27 -13
  32. package/plugins/codex/skills/init/references/internal-procedures/skill-review-gate.md +33 -10
  33. package/plugins/codex/skills/init/references/internal-procedures/skill-source-scope/references/capture-source.md +32 -12
  34. package/plugins/codex/skills/init/references/internal-procedures/skill-source-scope.md +165 -105
  35. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  36. package/plugins/cursor/skills/skill-continue-workflow/SKILL.md +26 -2
  37. package/plugins/cursor/skills/skill-prose-align/SKILL.md +32 -15
  38. package/plugins/cursor/skills/skill-prose-align/references/internal-procedures/structure-planning.md +5 -3
  39. package/plugins/cursor/skills/skill-prose-compile/SKILL.md +27 -13
  40. package/plugins/cursor/skills/skill-review-gate/SKILL.md +33 -10
  41. package/plugins/cursor/skills/skill-source-scope/SKILL.md +165 -105
  42. package/plugins/cursor/skills/skill-source-scope/references/capture-source.md +32 -12
  43. package/plugins/skills/context-continue/references/internal-procedures/skill-continue-workflow.md +26 -2
  44. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning.md +5 -3
  45. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-align.md +32 -15
  46. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile.md +27 -13
  47. package/plugins/skills/context-continue/references/internal-procedures/skill-review-gate.md +33 -10
  48. package/plugins/skills/context-continue/references/internal-procedures/skill-source-scope/references/capture-source.md +32 -12
  49. package/plugins/skills/context-continue/references/internal-procedures/skill-source-scope.md +165 -105
  50. package/plugins/skills/context-init/references/internal-procedures/skill-continue-workflow.md +26 -2
  51. package/plugins/skills/context-init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning.md +5 -3
  52. package/plugins/skills/context-init/references/internal-procedures/skill-prose-align.md +32 -15
  53. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile.md +27 -13
  54. package/plugins/skills/context-init/references/internal-procedures/skill-review-gate.md +33 -10
  55. package/plugins/skills/context-init/references/internal-procedures/skill-source-scope/references/capture-source.md +32 -12
  56. package/plugins/skills/context-init/references/internal-procedures/skill-source-scope.md +165 -105
  57. package/scripts/postinstall.mjs +68 -129
@@ -21,24 +21,21 @@ Choose and validate what may become draft knowledge.
21
21
  file source, or Lark/Feishu document. Current CLI can execute repo sources,
22
22
  local file sources, and Lark document capture through the declared flow.
23
23
  - Treat source registration as a knowledge-boundary decision, not a parameter
24
- prompt. Do not invent semantic source names from paths, filenames, or source
25
- body content. By default, omit the source name and let the CLI use today's
26
- date (`YYYYMMDD`) as the source namespace. Explain that this namespace appears
27
- in source refs, phase ids, and package naming; approved knowledge paths are
28
- derived later from collection, containment, and slug.
29
- - If the default date source name already exists, stop and ask the user which
30
- explicit date name to use. Do not auto-append sequence numbers and do not
31
- summarize the source theme as a fallback.
24
+ prompt. Repo, file, and Lark sources use today's date as a batch. Multiple
25
+ modules or documents share that date; never auto-append `-A/-B/-C` or ask for
26
+ a second flat date name. File/Lark modules may be supplied with `--module`;
27
+ otherwise the CLI derives a safe module from the local path or opaque
28
+ document identity.
29
+ - When the user supplies multiple sources together, register them with one
30
+ `context source add batch [YYYYMMDD] --input <yaml|json|->` command. Never run
31
+ multiple mutating `context source add` commands in parallel. Single-source
32
+ commands use the same project write lock and must be retried serially when
33
+ the CLI reports that the lock is held.
32
34
  - Do not infer a source from cwd, parent directories, package names, monorepo
33
35
  layout, or git remote.
34
- - In monorepos, one source may conceptually be the whole repo/subspace or one
35
- package/subdirectory. If the user wants one package manual, prefer the
36
- package/subdirectory. If the user wants one unified knowledge product across
37
- modules, explain that the date source namespace can be used in codegraph
38
- NodeRefs when extraction rules derive grouped refs. Current repo extraction
39
- still requires choosing a concrete single-module extraction boundary before
40
- running extraction; do not run extraction against an ambiguous multi-module
41
- source.
36
+ - In monorepos, inspect the package tree, then register each selected
37
+ package/subdirectory as a module under the same date. Do not extract an
38
+ ambiguous parent module.
42
39
  - `extractTs.include` filters files inside the selected source; it is not a
43
40
  package/module selector.
44
41
  - Do not ask users to add `exports`, `main`, `bin`, or a new entry file to the
@@ -51,10 +48,18 @@ Choose and validate what may become draft knowledge.
51
48
  when every matched file is the intended scope.
52
49
  - TypeScript extraction follows tsconfig/jsconfig `extends`, `baseUrl`, and
53
50
  `paths`. Aliases such as `@/` do not require changes to the source repository.
54
- - Use `context source inspect <source-name> --format json` for module choices.
51
+ - Use `context source inspect <date>/<module> --format json` for module choices.
55
52
  - Before first real extraction, generate a no-write preview and show module
56
53
  counts plus `knowledgeTree` / `knowledgePathExamples` to the user. Use
57
54
  `--dry-run` only in the command you execute, not as the user-facing label.
55
+ - During a declared multi-module extraction round, treat
56
+ `next_action.human_gate=false` as mechanical continuation: finish every
57
+ pending extract phase before opening one combined Review page.
58
+ - When captured file/Lark sources coexist with an unprocessed repo source,
59
+ process code first while document structure is still untouched. Follow the
60
+ `ready-to-extract` route and explain that document align resumes after the
61
+ code extraction/review round. Do not interrupt a document structure or
62
+ compile gate that has already started.
58
63
  - Human-facing explanations must describe the extraction impact first: what code
59
64
  files are read, what symbols become draft knowledge, what is skipped, and what
60
65
  review gate follows. Do not lead with `extractTs`, `include`, `exportedOnly`,
@@ -62,6 +67,13 @@ Choose and validate what may become draft knowledge.
62
67
  - Document capture has its own gate. After a file or Lark source is registered,
63
68
  ask for permission before reading the source body, then show the capture
64
69
  summary before handing off to material investigation and structure drafting.
70
+ If the user explicitly asked to capture, ingest, fetch, read, or include the
71
+ exact path/URL, that request already grants read permission; do not ask again
72
+ after registration. Mere mention, source discussion, and register-only
73
+ requests do not grant permission, and an explicit refusal always wins.
74
+ When the user requested several documents together, that confirmation covers
75
+ those explicit modules: declare them all, then execute every capture command
76
+ returned by `context status` before asking another source question.
65
77
  Do not default to one page per document, and do not create final draft pages
66
78
  directly from capture.
67
79
  - For capture routing, output handling, missing dependency recovery, and final
@@ -83,11 +95,11 @@ Ask for a knowledge source in plain language and map it to the supported path:
83
95
 
84
96
  | User source | What to ask for | Current handling |
85
97
  |---|---|---|
86
- | Local code repo | knowledge boundary and local repo path | Register with `context source add repo --local <path>` unless the user explicitly provides a date source name. CLI records git root + optional `subpath`; `sources/repo/YYYYMMDD` becomes an ignored symlink to the chosen repo/subdir view. |
87
- | Local monorepo package/module | whether the source is the whole repo/subspace or one package/subdir; chosen path | Register the chosen boundary as the repo source. If the user wants one package manual, register that package/subdir. If the user wants a unified subspace manual, register the subspace. Do not use `extractTs.include` as a package selector. |
98
+ | Local code repo | date batch, concrete module name, and local repo/package path | Register with `context source add repo [YYYYMMDD] --module <module> --local <path>`. CLI records git root + optional `subpath`; when the Context workspace and source share a Git root, an absolute input is stored relative to the workspace. `sources/repo/YYYYMMDD/<module>` becomes an ignored relative symlink to that module view. |
99
+ | Local monorepo package/module | which concrete packages/subdirs belong to this batch | Register every confirmed boundary as a module under the same date. Do not create `YYYYMMDD-A/B/C`, and do not use `extractTs.include` as a package selector. |
88
100
  | Remote Git repo | knowledge boundary, remote URL, pinned commit/ref, desired package/subdir, and permission to clone | CLI does not clone automatically. After explicit user approval, the agent may clone/checkout to an ignored local path, then register that local checkout. Cloned source content must not be committed. |
89
- | Local Markdown / document file or folder | document boundary, local path, include glob or include-list if needed, and permission to read the source body | Register with `context source add file --local <path>`, declare the matching capture phase, then hand off to material investigation and structure drafting after capture. Do not run capture before the user confirms read permission. |
90
- | Lark / Feishu document | document URL/token, intended collection, and permission to read remotely | Register with `context source add lark` plus exactly one of `--url`, `--doc-token`, or `--wiki-token`; declare the matching capture phase, then hand off to material investigation and structure drafting after capture. Explain that capture writes a committed snapshot under `sources/lark/YYYYMMDD/`, supports offline verify/fresh clone reproduction, and does not write credentials. Do not fetch through ad hoc scripts. |
101
+ | Local Markdown / document file or folder | date batch, document module boundary, local path, include glob or include-list if needed, and permission to read the source body | Register with `context source add file [YYYYMMDD] --module <module> --local <path>`; `--module` may be omitted when the path-derived name is sufficient. Documents from the same date are written as sibling files under `sources/file/YYYYMMDD/` and share that date's `manifest.json`. |
102
+ | Lark / Feishu document | date batch, document module, URL/token, intended collection, and permission to read remotely | Register each document with `context source add lark [YYYYMMDD] --module <module>` plus exactly one identity flag. Documents from the same date are written as sibling files under `sources/lark/YYYYMMDD/` and share that date's `manifest.json`. Omit `--module` when the CLI-derived opaque identity is acceptable. |
91
103
 
92
104
  When asking for a document mainline collection, do not ask only "which
93
105
  collection?". Explain every available option in product language:
@@ -118,34 +130,30 @@ knowledge source. Use the user's language and explain that this is a boundary
118
130
  choice:
119
131
 
120
132
  ```text
121
- You are choosing what one source means for this knowledge workspace.
122
- The date source name becomes part of source refs and phase ids. Approved knowledge
123
- paths are derived later from collection, containment, and slug. NodeRef and
124
- ViewRef are identity fields, not path strings.
133
+ You are choosing which code modules belong to one dated source batch.
134
+ The date is the source directory/batch; each concrete module has its own
135
+ extraction, source ref, phase id, and stable codegraph subtree. The date is not
136
+ part of the knowledge path.
125
137
 
126
138
  If the source is one package:
127
- knowledge/codegraph/YYYYMMDD/...
128
- repo:YYYYMMDD#symbol:...
129
- capture:file:YYYYMMDD
130
- dist/YYYYMMDD-kb/
139
+ knowledge/codegraph/<module>/...
140
+ repo:YYYYMMDD/<module>#symbol:...
131
141
 
132
142
  If the source is one document source:
133
143
  knowledge/architecture/entity/example.md
134
- file:YYYYMMDD/getting-started.md#span:...
135
- align:file:YYYYMMDD:architecture
136
- dist/YYYYMMDD-kb/
137
-
138
- If the source is a parent monorepo/subspace namespace, later multi-module
139
- outputs can be shaped like:
140
- knowledge/codegraph/YYYYMMDD/component-web/...
141
- knowledge/codegraph/YYYYMMDD/component-lynx/...
144
+ file:YYYYMMDD/getting-started/index.md#span:...
145
+ align:file:YYYYMMDD/getting-started:architecture
146
+ dist/<name>-kb/
147
+
148
+ If the date batch contains several repo modules, outputs are shaped like:
149
+ knowledge/codegraph/module-a/...
150
+ knowledge/codegraph/module-b/...
142
151
  ```
143
152
 
144
- If the source already points at one package/module root, the source namespace
145
- is still the date name. An extra module/package segment is only expected when
146
- the chosen source boundary intentionally covers multiple modules. In the
147
- current workflow, treat that parent source as a planning/inspection boundary
148
- first; choose a concrete package/subdirectory source before real extraction.
153
+ Every repo source has both levels, even when the batch contains only one module.
154
+ The date groups capture work; the module is the extraction boundary and
155
+ project-wide codegraph identity. Do not register the same repo module name under
156
+ another date; refresh it through its existing date/module selector.
149
157
 
150
158
  When the user has already provided a path, describe the current interpretation
151
159
  and use the CLI date default:
@@ -154,17 +162,14 @@ and use the CLI date default:
154
162
  I am treating this path as the source boundary:
155
163
  <path>
156
164
 
157
- If this path is one package/module, the date source name will be used in
158
- source refs such as repo:YYYYMMDD#...
165
+ If this path is one package/module, it will be registered under today's date
166
+ and use refs such as repo:YYYYMMDD/<module>#...
159
167
 
160
- If this path is a parent monorepo/subspace that contains multiple modules, the
161
- date source name becomes the parent source namespace for grouped codegraph NodeRefs
162
- when extraction derives those refs:
163
- knowledge/codegraph/YYYYMMDD/<module-name>/...
168
+ If this path contains multiple modules, I will show the detected tree and
169
+ register each selected module under the same date. Knowledge paths stay stable:
170
+ knowledge/codegraph/<module-name>/...
164
171
 
165
- For the current extraction flow, a multi-module parent source is used for
166
- inspection/planning first. Before reading code, we still need a concrete
167
- package/subdirectory boundary.
172
+ Extraction will still run separately for each module.
168
173
  ```
169
174
 
170
175
  Then ask for one of:
@@ -175,9 +180,8 @@ Then ask for one of:
175
180
  - Lark/Feishu document URL.
176
181
 
177
182
  Do not ask "what is the source name?" as the first or only question. Ask what
178
- they want the knowledge source to cover, then use the date default. Ask for an
179
- explicit date name only when today's source name already exists or the user
180
- asks to override it.
183
+ they want the knowledge source to cover, then use the date default. For repo
184
+ sources, ask which concrete module/package is being registered.
181
185
 
182
186
  Good user-facing wording:
183
187
 
@@ -186,27 +190,21 @@ Next we need to add a knowledge source.
186
190
 
187
191
  If you only want a manual for the component package, choose that package
188
192
  directory as the source boundary, for example:
189
- name: YYYYMMDD
193
+ batch: YYYYMMDD
194
+ module: component-lib
190
195
  path: /repo/packages/component-lib
191
196
 
192
- If you want one manual for the whole subspace, choose the subspace root:
193
- name: YYYYMMDD
194
- path: /repo/subspaces/product-ui
195
-
196
- The date name is not just a label. It will appear in source refs such as
197
- repo:YYYYMMDD#... and in phase ids such as extract:YYYYMMDD:codegraph.
198
- Approved paths are derived from collection, containment, and slug. NodeRef and
199
- ViewRef are identity fields, not path strings.
197
+ The date is one batch, not one module. The concrete selector appears in refs
198
+ and phases such as repo:YYYYMMDD/component-lib#... and
199
+ extract:YYYYMMDD/component-lib:codegraph.
200
200
 
201
- For a unified subspace package shape, the date source name
202
- lets the output group child modules under that namespace:
203
- knowledge/codegraph/YYYYMMDD/component-web/...
204
- knowledge/codegraph/YYYYMMDD/component-lynx/...
201
+ One date can group multiple registered modules while knowledge omits the date:
202
+ knowledge/codegraph/module-a/...
203
+ knowledge/codegraph/module-b/...
205
204
 
206
- Current extraction can inspect a parent source, but it should extract from a
207
- confirmed single package/subdirectory source. If this path is a parent source,
208
- I will show the module tree first and ask which package(s) to use before
209
- reading code.
205
+ Extraction still runs per concrete module. If a path contains several packages,
206
+ I will show the module tree first and register each chosen package under this
207
+ same date before reading code.
210
208
  ```
211
209
 
212
210
  Mention the CLI command only as an implementation detail after the user chooses
@@ -221,10 +219,46 @@ For a local repo source, ask for:
221
219
  After the user provides the choice, run:
222
220
 
223
221
  ```bash
224
- context source add repo --local <repo-or-subdir>
225
- context source ensure
222
+ context source add repo [YYYYMMDD] --module <module> --local <repo-or-subdir>
223
+ context source ensure [YYYYMMDD|YYYYMMDD/module]
226
224
  ```
227
225
 
226
+ For several repo/file/Lark modules confirmed in one request, prefer one batch
227
+ payload instead of parallel commands:
228
+
229
+ ```yaml
230
+ sources:
231
+ - type: repo
232
+ module: module-a
233
+ local: ../monorepo/packages/module-a
234
+ - type: repo
235
+ module: module-b
236
+ local: ../monorepo/packages/module-b
237
+ - type: lark
238
+ url: https://example.larksuite.com/wiki/example
239
+ ```
240
+
241
+ ```bash
242
+ context source add batch [YYYYMMDD] --input <sources.yaml|json|-> --format json
243
+ ```
244
+
245
+ The CLI validates batch identities, holds one project write lock, and writes
246
+ registries atomically. It processes items in payload order. If a runtime item
247
+ fails, the error reports completed items; fix it and rerun the same payload,
248
+ because source registration is idempotent. Do not patch registry YAML manually.
249
+ Repo items require `module`. File and Lark items may omit it; the CLI returns a
250
+ derived lowercase path-safe module. If derived identities collide, provide
251
+ explicit distinct modules and rerun the unchanged batch boundary.
252
+
253
+ The repo batch must be a valid calendar date. The CLI rejects suffixes such as
254
+ `YYYYMMDD-A`. A date-only `source ensure` or `source inspect` selector operates
255
+ on every repo module registered in that batch; append `/module` to target one.
256
+ If `--local` is absolute but the selected module and Context workspace belong
257
+ to the same Git repository, expect the registry to store the Git root relative
258
+ to the workspace plus `subpath`. The materialized source symlink also uses a
259
+ relative target, so moving the repository as a unit keeps it valid. A source in
260
+ a different Git repository may retain its absolute checkout root.
261
+
228
262
  Add `--remote` / `--ref` only when the user gave explicit values.
229
263
 
230
264
  For a remote Git repo source, ask for permission before clone/checkout. If the
@@ -235,40 +269,52 @@ cloned source content.
235
269
  For local Markdown/MDX document sources, after the user confirms the boundary, run:
236
270
 
237
271
  ```bash
238
- context source add file --local <file-or-folder>
272
+ context source add file [YYYYMMDD] --module <module> --local <file-or-folder>
239
273
  ```
240
274
 
241
- Use an explicit `<name>` only when the user has approved a non-default date
242
- source name. Otherwise run `context source add file --local <file-or-folder>`.
275
+ The date is the batch and the module is the concrete document boundary. Multiple
276
+ file modules may share one date. `--module` may be omitted when the CLI-derived
277
+ path slug is adequate; do not stop merely because another document already uses
278
+ today's date.
243
279
 
244
280
  Default file capture handles Markdown. If `context source add file`,
245
281
  `context source inspect`, `context status`, or capture output reports that the
246
282
  source looks like an MDX documentation site, stop at the source boundary gate
247
283
  and ask the user to confirm that interpretation before changing `src/index.ts`.
248
284
  For MDX documentation sites that use `_meta.json` route metadata, declare
249
- `captureFile({ source: source("<date-name>"), processor: mdxJsonDocs() })` in
285
+ `captureFile({ source: source("<date>", "<module>", { type: "file" }), processor: mdxJsonDocs() })` in
250
286
  `src/index.ts`; included `_meta.json` files are route metadata, and the CLI
251
287
  generates `__context_route_metadata.md` as mechanical route evidence. Use
252
288
  `--include` only when the approved boundary is narrower than the folder. For a
253
289
  long fixed batch, prefer `--include-list <file>` with one include per line;
254
290
  blank lines and `#` comments are ignored. Then explain that the next operation
255
- reads the approved document files and writes a committed snapshot under
256
- `sources/file/YYYYMMDD/`. After the user confirms read permission, summarize the
291
+ reads the approved document files and writes sibling files in one date batch.
292
+ The CLI manages their shared capture metadata. After the user confirms read permission, summarize the
257
293
  `src/index.ts` change or show an equivalent diff summary, and run the capture
258
294
  phase.
259
295
  Apply [references/capture-source.md](references/capture-source.md) for route
260
296
  selection, dependency recovery, output handling, and final reporting, using the
261
297
  current capture phase command returned by `context status`.
262
298
 
263
- For Lark/Feishu document sources, register the source but do not fetch content
299
+ For Lark/Feishu document sources, register every requested document under the
300
+ same date batch but do not fetch content
264
301
  with ad hoc scripts. Explain which remote document or wiki token will be read,
265
- that the snapshot is written under `sources/lark/YYYYMMDD/`, that committed
302
+ that each document is written under `sources/lark/YYYYMMDD/` beside the other documents in that date batch, that one shared `manifest.json` tracks them, that committed
266
303
  snapshots enable offline verify and fresh-clone reproduction, that whether to
267
304
  add extra ignore rules is a business repository decision, and that access
268
305
  credentials are not written to the workspace. Use the declared capture/align
269
306
  flow only after the user confirms remote reading. After declaring
270
- `captureLark({ source: source("<date-name>") })`, summarize the `src/index.ts`
307
+ `captureLark({ source: source("<date>", "<module>", { type: "lark" }) })`, summarize the `src/index.ts`
271
308
  change or show an equivalent diff summary.
309
+ When the user adds more documents to an already confirmed batch and says they
310
+ belong together, inherit the confirmed mainline collection and read permission
311
+ for those explicitly supplied URLs. Register and declare all modules before
312
+ capture; do not ask for another date name or repeat the same collection gate.
313
+ If `context status --format json` returns multiple items in
314
+ `routing.command_plan` while state is `needs-capture`, run every
315
+ `after-human-confirmation` item in order after the current conversation contains
316
+ permission. After one module completes, status should retain only the
317
+ uncaptured modules; do not reopen the batch boundary gate between them.
272
318
  Apply [references/capture-source.md](references/capture-source.md) for route
273
319
  selection, dependency recovery, output handling, and final reporting, using the
274
320
  current capture phase command returned by `context status`.
@@ -278,23 +324,21 @@ current capture phase command returned by `context status`.
278
324
  If a registered source may contain multiple packages, run:
279
325
 
280
326
  ```bash
281
- context source inspect <source-name> --format json
327
+ context source inspect <date>/<module> --format json
282
328
  ```
283
329
 
284
330
  Present the detected module/package paths from that CLI output as a tree. Explain
285
331
  the choices without exposing internal API names first:
286
332
 
287
- - for the current executable flow, register one package/subdirectory as its
288
- own source when the user wants a focused package manual;
289
- - if the user is designing a unified subspace knowledge base, keep the
290
- date source namespace as the namespace decision, but do not run extraction
291
- until the concrete module extraction boundary is confirmed.
333
+ - register each chosen package/subdirectory as a module in the current date
334
+ batch;
335
+ - extraction, Review, and verification remain independent per concrete module.
292
336
 
293
337
  Wait for the user to choose. If the user chooses `packages/button`, register it
294
- as a separate source such as:
338
+ as another module in the same date batch:
295
339
 
296
340
  ```bash
297
- context source add repo --local <repo>/packages/button
341
+ context source add repo <date> --module button --local <repo>/packages/button
298
342
  ```
299
343
 
300
344
  Do not model a monorepo package choice as `include: ["packages/button/src/**"]`
@@ -309,7 +353,7 @@ the capture summary first:
309
353
  - document count;
310
354
  - title tree, heading tree, or source span distribution from the CLI output;
311
355
  - available reading budget and evidence views;
312
- - snapshot path under `sources/file|lark/YYYYMMDD/`;
356
+ - flat document path under `sources/file|lark/YYYYMMDD/` and the date-level `manifest.json`;
313
357
  - the fact that approved pages are planned through
314
358
  `unapproved/structure.yaml` before compile;
315
359
  - whether the source is local file/folder evidence or Lark/Feishu evidence.
@@ -371,8 +415,8 @@ I will first generate a preview without writing candidates. The preview will
371
415
  show counts plus the planned `knowledge/` tree.
372
416
  ```
373
417
 
374
- Only after the user confirms this product-level scope, declare the chosen date
375
- source with `source("YYYYMMDD")`, add the TypeScript extraction phase, and add
418
+ Only after the user confirms this product-level scope, declare the chosen repo
419
+ module with `source("YYYYMMDD", "<module>")`, add the TypeScript extraction phase, and add
376
420
  the human review phase. Use `include` only for a file-level filter within the
377
421
  chosen source boundary. If the package has no standard detected entry, keep the
378
422
  source repository unchanged and ask whether its intended knowledge surface is:
@@ -385,6 +429,11 @@ source repository unchanged and ask whether its intended knowledge surface is:
385
429
  Mention the internal API names only in code-change summaries, or when the user
386
430
  asks for implementation details.
387
431
 
432
+ When the user confirms several modules as one extraction round, declare all of
433
+ their source-specific extract phases before writing candidates. Preview every
434
+ phase first, summarize the combined scope once, and ask for one scope
435
+ confirmation for that round.
436
+
388
437
  ### Step 5 — Show The Pre-extraction Preview
389
438
 
390
439
  Before real extraction, run the CLI no-write preview:
@@ -408,14 +457,13 @@ containment, and slug; NodeRef/ViewRef are identity fields, not path strings:
408
457
  knowledge/<collection>/<containment>/<slug>.md
409
458
  ```
410
459
 
411
- If date source name, package name, module list, candidate estimate, or path shape is
412
- not what the user expects, stop and repair the source boundary or explicit date name
460
+ If date batch, module name, module list, candidate estimate, or path shape is
461
+ not what the user expects, stop and repair the source boundary or module registration
413
462
  before extraction.
414
463
 
415
- For a single-module code source, a repeated path like
416
- `knowledge/codegraph/<date-source-name>/<package-name>/...` is usually a schema
417
- problem or a wrong source boundary. Stop before extraction if the preview shows
418
- that shape unexpectedly.
464
+ For code sources, `knowledge/codegraph/<module>/...` is the expected shape;
465
+ the date remains in source refs and phase ids. An additional repeated package segment below `<module>` may indicate an
466
+ over-broad boundary; stop if the preview shows that unexpectedly.
419
467
 
420
468
  Do not present this as a CLI option or as "Context default options" to the
421
469
  user. Present it as the actual proposed knowledge impact: code area read,
@@ -431,10 +479,14 @@ matches it, run:
431
479
  context run <extract-phase-id>
432
480
  ```
433
481
 
434
- Read the structured result before routing. For codegraph, the first run returns
435
- all code candidates with `next_action.human_gate=true`; later runs return only
482
+ Read the structured result before routing. A codegraph phase that produces
483
+ candidates returns `continue-codegraph-batch` with `human_gate=false`; run the
484
+ returned status command and continue any remaining confirmed extract phases.
485
+ Only when status has no `pendingExtractPhases` and returns `needs-review` should
486
+ the Agent open one collection-level Codegraph Review. The first round includes
487
+ all candidates across the confirmed modules; later rounds include only
436
488
  added/updated/removed symbols, while unchanged approved symbols stay approved.
437
- If `next_action.human_gate=false`, do not open Review and continue with status.
489
+ Do not open Review after each module.
438
490
 
439
491
  Only when the user explicitly requests a non-interactive CI/CD codegraph sync,
440
492
  run:
@@ -443,9 +495,17 @@ run:
443
495
  context run <extract-phase-id> --auto-promote --format json
444
496
  ```
445
497
 
446
- This applies deterministic codegraph deltas and verifies them. A nonzero exit or
447
- verification issue is a pipeline failure. Never use `--auto-promote` for prose
448
- or semantic collections.
498
+ This applies deterministic codegraph deltas, refreshes deterministic close when
499
+ needed, and verifies the result. Read `autoPromotion.close` and
500
+ `autoPromotion.verify`; a nonzero exit or close/verification issue is a pipeline
501
+ failure. Run `context build` separately when the pipeline publishes packages.
502
+ Never use `--auto-promote` for prose or semantic collections.
503
+
504
+ If an upgraded workspace reports `approved-source-ref-ambiguous` for pre-file-aware
505
+ beta.5 codegraph refs, preserve the existing approval decisions. Rerun the
506
+ declared codegraph extraction phase to produce the current file-aware symbol
507
+ index, then run `context review migrate-codegraph-refs` and `context verify`.
508
+ Tell the user this is evidence metadata migration and does not reopen Review.
449
509
 
450
510
  If the preview reports modules outside the confirmed source boundary, do not
451
511
  run extraction. Ask the user to choose the corrected source boundary.
@@ -13,14 +13,27 @@ tools:
13
13
  Current capture discipline for document sources. The executable path is source
14
14
  registration plus the declared capture phase flow:
15
15
 
16
- - local Markdown/MDX file source: `context source add file --local <path>`
17
- followed by `context run capture:file:<source-name> --format json`;
18
- - Lark/Feishu source: `context source add lark ...` followed by
19
- `context run capture:lark:<source-name> --format json`;
16
+ - local Markdown/MDX file source: `context source add file [YYYYMMDD] --module <module> --local <path>`
17
+ followed by `context run capture:file:YYYYMMDD/<module> --format json`;
18
+ - Lark/Feishu source: `context source add lark [YYYYMMDD] --module <module> ...`
19
+ followed by `context run capture:lark:YYYYMMDD/<module> --format json`;
20
20
  - refresh: rerun the same declared capture phase after status or the user asks
21
21
  for recapture.
22
22
 
23
23
  Use only commands surfaced by the current status output or capture phase.
24
+ For a user-confirmed multi-document batch, `context status --format json`
25
+ returns every uncaptured module in `routing.command_plan`. Run the complete
26
+ list in order; a successful module is omitted from the next status result.
27
+ When the user explicitly asks to capture, ingest, fetch, read, or include exact
28
+ file/Lark paths or URLs, that request is the read permission for those sources;
29
+ do not repeat the question after registration. A mere mention, possible-source
30
+ discussion, or register-only request is not permission, and an explicit refusal
31
+ always wins.
32
+ Register several file/Lark/repo sources with `context source add batch [date]
33
+ --input <yaml|json|->`; do not launch multiple `source add` processes in
34
+ parallel. Repo batch items require `module`; file/Lark items may omit it and use
35
+ the module returned by the CLI. A write-lock error means another Context mutation is active: wait for
36
+ it to finish and retry rather than editing registry files.
24
37
 
25
38
  ---
26
39
 
@@ -53,8 +66,9 @@ Before choosing a local Markdown capture route, honor the surrounding task conte
53
66
 
54
67
  - One or more local `.md` / `.mdx` files or a local documentation folder to ingest →
55
68
  register one file source with the user-confirmed boundary:
56
- `context source add file --local <file-or-folder>`. The CLI returns the date
57
- source name (`YYYYMMDD`) to use in project phases. For an explicit
69
+ `context source add file [YYYYMMDD] --module <module> --local <file-or-folder>`.
70
+ The CLI returns the `YYYYMMDD/module` identity to use in project phases. More
71
+ than one file module may share the date. For an explicit
58
72
  batch inside a broader folder, preserve the user's include list on source
59
73
  registration. Default file capture handles `.md`. If the CLI reports
60
74
  document-site files such as `.mdx`, `_meta.json`, sidebars, or docs config,
@@ -66,15 +80,17 @@ Before choosing a local Markdown capture route, honor the surrounding task conte
66
80
  `__context_route_metadata.md` as mechanical route evidence; it also extracts
67
81
  static MDX component props/children into `__context_mdx_component_text.md`
68
82
  when components carry user-facing text. Declare
69
- `captureFile({ source: source("<source-name>"), processor: mdxJsonDocs() })`, then
70
- run `context run capture:file:<source-name> --format json`. If the selected MDX page
83
+ `captureFile({ source: source("<date>", "<module>", { type: "file" }), processor: mdxJsonDocs() })`, then
84
+ run `context run capture:file:<date>/<module> --format json`. If the selected MDX page
71
85
  is empty or only mounts runtime-rendered content, tell the user that capture
72
86
  found a document-site shell and ask for the rendered-site or data-source
73
87
  boundary instead of inventing body text.
74
88
  - A Lark/Feishu URL, doc token, or wiki token → register one Lark source:
75
- `context source add lark --url <url>` or the matching token flag.
76
- Declare `captureLark({ source: source("<source-name>") })`, then run
77
- `context run capture:lark:<source-name> --format json`.
89
+ `context source add lark [YYYYMMDD] --module <module> --url <url>` or the
90
+ matching token flag. Register every requested document under the same date;
91
+ do not ask for `YYYYMMDD-2`. Declare
92
+ `captureLark({ source: source("<date>", "<module>", { type: "lark" }) })`,
93
+ then run `context run capture:lark:<date>/<module> --format json`.
78
94
  - Mixed local document and Lark document batches are separate sources unless
79
95
  the current CLI explicitly offers a combined source contract. Do not write an
80
96
  Agent-side URL/file loop.
@@ -99,7 +115,11 @@ registration; do not read file bodies before capture permission is clear.
99
115
  Report the CLI output verbatim. If the CLI reports `N sources changed`, suggest the right next step:
100
116
 
101
117
  - Run `context status --format json` and use its `state`, `routing`, and
102
- `next_commands`.
118
+ `command_plan`; if status returns `needs-capture-phase`, first perform the
119
+ exact `routing.configuration` edit and rerun status.
120
+ - While status remains `needs-capture`, execute every returned capture command
121
+ for the already confirmed batch before asking another naming, collection, or
122
+ read-permission question.
103
123
  - If status reports `captured-ready-to-investigate`, suggest the returned
104
124
  `context run align:<type>:<source>:<collection> --view read-plan --format json`
105
125
  command and hand off to `skill-prose-align`.
package/plugins/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0-beta.5
1
+ 0.6.0-beta.7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "context",
3
3
  "description": "Maintain a project-local knowledge workspace through init and next-step agent guidance.",
4
- "version": "0.6.0-beta.5",
4
+ "version": "0.6.0-beta.7",
5
5
  "author": {
6
6
  "name": "c4a"
7
7
  },
@@ -24,6 +24,10 @@ Continue an existing Context workspace from its current state.
24
24
  workflow; do not treat the host repository root as the workspace.
25
25
  - There is no `context continue` CLI command. Start with `context status`.
26
26
  - `context status` and CLI diagnostics are the source of truth.
27
+ - Inspect `declarationGraph` and `configurationGaps`. Before structure
28
+ confirmation they are configuration warnings; after confirmation, a missing
29
+ compile route is a hard gate. Never substitute a compile phase from another
30
+ collection.
27
31
  - Execute safe mechanical `next:` steps; stop at semantic choices and human
28
32
  gates.
29
33
  - Delegate source/scope decisions to
@@ -65,6 +69,10 @@ Capture phases are not safe mechanical commands by default. `capture:file:*`
65
69
  and `capture:lark:*` read local or remote source bodies and update committed
66
70
  snapshots, so they require the source read-permission gate unless the current
67
71
  turn already contains explicit user confirmation for that exact source.
72
+ An explicit request to capture, ingest, fetch, read, or include the exact
73
+ file/Lark path or URL is that confirmation; do not ask again after registration.
74
+ Mere mention, source discussion, or a register-only request is not confirmation,
75
+ and an explicit refusal always overrides inferred permission.
68
76
 
69
77
  ## Human Gates
70
78
 
@@ -117,10 +125,20 @@ do not forward a long raw transcript unless requested.
117
125
 
118
126
  ### Step 2 — Route The State
119
127
 
120
- 1. If status says `missing-source` or `needs-capture`,
128
+ 1. If status says `missing-source`, `needs-capture-phase`, `needs-capture`,
129
+ `needs-extract-phase`, or `ready-to-extract`,
121
130
  source boundary/name is unclear, source scope is unclear, or an extract
122
131
  phase needs first-run scope confirmation, follow
123
132
  `${CLAUDE_PLUGIN_ROOT}/skills/skill-source-scope/SKILL.md`.
133
+ When `routing.configuration` is present, make only that declared project
134
+ configuration change and rerun status. Otherwise follow
135
+ `routing.command_plan`: run `immediate` items directly and wait for current-
136
+ conversation confirmation before `after-human-confirmation` items.
137
+ For mixed sources, status intentionally returns `ready-to-extract` before
138
+ `captured-ready-to-investigate` while all document snapshots are captured,
139
+ document structure is untouched, and code extraction is missing, pending,
140
+ or stale. Explain that code is processed first, then follow the exact
141
+ extraction preview/rerun command.
124
142
  2. If status says `captured-ready-to-investigate` or `needs-structure`, or the
125
143
  user asks to split, merge, classify, relate, or semantically organize
126
144
  document evidence before draft pages exist, follow
@@ -129,7 +147,9 @@ do not forward a long raw transcript unless requested.
129
147
  to turn confirmed structure into source-bound draft pages, follow
130
148
  `${CLAUDE_PLUGIN_ROOT}/skills/skill-prose-compile/SKILL.md`.
131
149
  4. If the latest phase result has `next_action.human_gate=false`, follow its
132
- command and do not invent a Review gate. If status says
150
+ command and do not invent a Review gate. This includes
151
+ `continue_compile_batch` and `continue-codegraph-batch`: finish the whole
152
+ prepared round first. If status says
133
153
  `compile-ready-for-review`, or the latest result has
134
154
  `next_action.human_gate=true`, follow
135
155
  `${CLAUDE_PLUGIN_ROOT}/skills/skill-review-gate/SKILL.md`.
@@ -173,3 +193,7 @@ usable; inspect generated package structure when package output is involved.
173
193
  conclusion and use the CLI view.
174
194
 
175
195
  </procedures>
196
+ If top-level `state`, `next`, or `routing.command_plan` contradicts
197
+ `draftCandidates`, `pendingReview`, `close.state`, package freshness, or verify
198
+ counts, stop instead of rerunning a completed phase. Report
199
+ `status-route-conflict` and preserve the detailed status output for diagnosis.