@c4a/context-cli 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.
Files changed (56) hide show
  1. package/README.md +17 -2
  2. package/cli.js +20831 -18799
  3. package/package.json +2 -2
  4. package/plugin/skills/skill-continue-workflow/SKILL.md +25 -2
  5. package/plugin/skills/skill-prose-align/SKILL.md +25 -9
  6. package/plugin/skills/skill-prose-align/references/internal-procedures/structure-planning.md +5 -3
  7. package/plugin/skills/skill-prose-compile/SKILL.md +17 -5
  8. package/plugin/skills/skill-review-gate/SKILL.md +38 -9
  9. package/plugin/skills/skill-source-scope/SKILL.md +197 -102
  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 +25 -2
  14. package/plugins/claude/skills/skill-prose-align/SKILL.md +25 -9
  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 +17 -5
  17. package/plugins/claude/skills/skill-review-gate/SKILL.md +38 -9
  18. package/plugins/claude/skills/skill-source-scope/SKILL.md +197 -102
  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 +25 -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 +25 -9
  24. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile.md +17 -5
  25. package/plugins/codex/skills/continue/references/internal-procedures/skill-review-gate.md +38 -9
  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 +197 -102
  28. package/plugins/codex/skills/init/references/internal-procedures/skill-continue-workflow.md +25 -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 +25 -9
  31. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile.md +17 -5
  32. package/plugins/codex/skills/init/references/internal-procedures/skill-review-gate.md +38 -9
  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 +197 -102
  35. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  36. package/plugins/cursor/skills/skill-continue-workflow/SKILL.md +25 -2
  37. package/plugins/cursor/skills/skill-prose-align/SKILL.md +25 -9
  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 +17 -5
  40. package/plugins/cursor/skills/skill-review-gate/SKILL.md +38 -9
  41. package/plugins/cursor/skills/skill-source-scope/SKILL.md +197 -102
  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 +25 -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 +25 -9
  46. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile.md +17 -5
  47. package/plugins/skills/context-continue/references/internal-procedures/skill-review-gate.md +38 -9
  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 +197 -102
  50. package/plugins/skills/context-init/references/internal-procedures/skill-continue-workflow.md +25 -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 +25 -9
  53. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile.md +17 -5
  54. package/plugins/skills/context-init/references/internal-procedures/skill-review-gate.md +38 -9
  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 +197 -102
@@ -21,30 +21,45 @@ 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
- - Use `context source inspect <source-name> --format json` for module choices.
41
+ - Do not ask users to add `exports`, `main`, `bin`, or a new entry file to the
42
+ source repository solely for extraction. Standard package entries are
43
+ auto-detected; non-standard API roots belong in Context-owned
44
+ `extractTs.entries`. When the confirmed scope is all declarations in matched
45
+ files, use `mode: "scan"` instead of inventing an entry.
46
+ - Empty or undetected entries must return `NO_ENTRY_DETECTED`; never treat an
47
+ empty extraction as success. Configure `entries`, or choose scan mode only
48
+ when every matched file is the intended scope.
49
+ - TypeScript extraction follows tsconfig/jsconfig `extends`, `baseUrl`, and
50
+ `paths`. Aliases such as `@/` do not require changes to the source repository.
51
+ - Use `context source inspect <date>/<module> --format json` for module choices.
45
52
  - Before first real extraction, generate a no-write preview and show module
46
53
  counts plus `knowledgeTree` / `knowledgePathExamples` to the user. Use
47
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.
48
63
  - Human-facing explanations must describe the extraction impact first: what code
49
64
  files are read, what symbols become draft knowledge, what is skipped, and what
50
65
  review gate follows. Do not lead with `extractTs`, `include`, `exportedOnly`,
@@ -52,6 +67,13 @@ Choose and validate what may become draft knowledge.
52
67
  - Document capture has its own gate. After a file or Lark source is registered,
53
68
  ask for permission before reading the source body, then show the capture
54
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.
55
77
  Do not default to one page per document, and do not create final draft pages
56
78
  directly from capture.
57
79
  - For capture routing, output handling, missing dependency recovery, and final
@@ -73,11 +95,11 @@ Ask for a knowledge source in plain language and map it to the supported path:
73
95
 
74
96
  | User source | What to ask for | Current handling |
75
97
  |---|---|---|
76
- | 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. |
77
- | 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. |
78
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. |
79
- | 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. |
80
- | 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. |
81
103
 
82
104
  When asking for a document mainline collection, do not ask only "which
83
105
  collection?". Explain every available option in product language:
@@ -108,34 +130,30 @@ knowledge source. Use the user's language and explain that this is a boundary
108
130
  choice:
109
131
 
110
132
  ```text
111
- You are choosing what one source means for this knowledge workspace.
112
- The date source name becomes part of source refs and phase ids. Approved knowledge
113
- paths are derived later from collection, containment, and slug. NodeRef and
114
- 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.
115
137
 
116
138
  If the source is one package:
117
- knowledge/codegraph/YYYYMMDD/...
118
- repo:YYYYMMDD#symbol:...
119
- capture:file:YYYYMMDD
120
- dist/YYYYMMDD-kb/
139
+ knowledge/codegraph/<module>/...
140
+ repo:YYYYMMDD/<module>#symbol:...
121
141
 
122
142
  If the source is one document source:
123
143
  knowledge/architecture/entity/example.md
124
- file:YYYYMMDD/getting-started.md#span:...
125
- align:file:YYYYMMDD:architecture
126
- dist/YYYYMMDD-kb/
127
-
128
- If the source is a parent monorepo/subspace namespace, later multi-module
129
- outputs can be shaped like:
130
- knowledge/codegraph/YYYYMMDD/component-web/...
131
- 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/...
132
151
  ```
133
152
 
134
- If the source already points at one package/module root, the source namespace
135
- is still the date name. An extra module/package segment is only expected when
136
- the chosen source boundary intentionally covers multiple modules. In the
137
- current workflow, treat that parent source as a planning/inspection boundary
138
- 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.
139
157
 
140
158
  When the user has already provided a path, describe the current interpretation
141
159
  and use the CLI date default:
@@ -144,17 +162,14 @@ and use the CLI date default:
144
162
  I am treating this path as the source boundary:
145
163
  <path>
146
164
 
147
- If this path is one package/module, the date source name will be used in
148
- 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>#...
149
167
 
150
- If this path is a parent monorepo/subspace that contains multiple modules, the
151
- date source name becomes the parent source namespace for grouped codegraph NodeRefs
152
- when extraction derives those refs:
153
- 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>/...
154
171
 
155
- For the current extraction flow, a multi-module parent source is used for
156
- inspection/planning first. Before reading code, we still need a concrete
157
- package/subdirectory boundary.
172
+ Extraction will still run separately for each module.
158
173
  ```
159
174
 
160
175
  Then ask for one of:
@@ -165,9 +180,8 @@ Then ask for one of:
165
180
  - Lark/Feishu document URL.
166
181
 
167
182
  Do not ask "what is the source name?" as the first or only question. Ask what
168
- they want the knowledge source to cover, then use the date default. Ask for an
169
- explicit date name only when today's source name already exists or the user
170
- 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.
171
185
 
172
186
  Good user-facing wording:
173
187
 
@@ -176,27 +190,21 @@ Next we need to add a knowledge source.
176
190
 
177
191
  If you only want a manual for the component package, choose that package
178
192
  directory as the source boundary, for example:
179
- name: YYYYMMDD
193
+ batch: YYYYMMDD
194
+ module: component-lib
180
195
  path: /repo/packages/component-lib
181
196
 
182
- If you want one manual for the whole subspace, choose the subspace root:
183
- name: YYYYMMDD
184
- path: /repo/subspaces/product-ui
185
-
186
- The date name is not just a label. It will appear in source refs such as
187
- repo:YYYYMMDD#... and in phase ids such as extract:YYYYMMDD:codegraph.
188
- Approved paths are derived from collection, containment, and slug. NodeRef and
189
- 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.
190
200
 
191
- For a unified subspace package shape, the date source name
192
- lets the output group child modules under that namespace:
193
- knowledge/codegraph/YYYYMMDD/component-web/...
194
- 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/...
195
204
 
196
- Current extraction can inspect a parent source, but it should extract from a
197
- confirmed single package/subdirectory source. If this path is a parent source,
198
- I will show the module tree first and ask which package(s) to use before
199
- 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.
200
208
  ```
201
209
 
202
210
  Mention the CLI command only as an implementation detail after the user chooses
@@ -211,10 +219,46 @@ For a local repo source, ask for:
211
219
  After the user provides the choice, run:
212
220
 
213
221
  ```bash
214
- context source add repo --local <repo-or-subdir>
215
- context source ensure
222
+ context source add repo [YYYYMMDD] --module <module> --local <repo-or-subdir>
223
+ context source ensure [YYYYMMDD|YYYYMMDD/module]
216
224
  ```
217
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
+
218
262
  Add `--remote` / `--ref` only when the user gave explicit values.
219
263
 
220
264
  For a remote Git repo source, ask for permission before clone/checkout. If the
@@ -225,40 +269,52 @@ cloned source content.
225
269
  For local Markdown/MDX document sources, after the user confirms the boundary, run:
226
270
 
227
271
  ```bash
228
- context source add file --local <file-or-folder>
272
+ context source add file [YYYYMMDD] --module <module> --local <file-or-folder>
229
273
  ```
230
274
 
231
- Use an explicit `<name>` only when the user has approved a non-default date
232
- 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.
233
279
 
234
280
  Default file capture handles Markdown. If `context source add file`,
235
281
  `context source inspect`, `context status`, or capture output reports that the
236
282
  source looks like an MDX documentation site, stop at the source boundary gate
237
283
  and ask the user to confirm that interpretation before changing `src/index.ts`.
238
284
  For MDX documentation sites that use `_meta.json` route metadata, declare
239
- `captureFile({ source: source("<date-name>"), processor: mdxJsonDocs() })` in
285
+ `captureFile({ source: source("<date>", "<module>", { type: "file" }), processor: mdxJsonDocs() })` in
240
286
  `src/index.ts`; included `_meta.json` files are route metadata, and the CLI
241
287
  generates `__context_route_metadata.md` as mechanical route evidence. Use
242
288
  `--include` only when the approved boundary is narrower than the folder. For a
243
289
  long fixed batch, prefer `--include-list <file>` with one include per line;
244
290
  blank lines and `#` comments are ignored. Then explain that the next operation
245
- reads the approved document files and writes a committed snapshot under
246
- `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
247
293
  `src/index.ts` change or show an equivalent diff summary, and run the capture
248
294
  phase.
249
295
  Apply [references/capture-source.md](references/capture-source.md) for route
250
296
  selection, dependency recovery, output handling, and final reporting, using the
251
297
  current capture phase command returned by `context status`.
252
298
 
253
- 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
254
301
  with ad hoc scripts. Explain which remote document or wiki token will be read,
255
- 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
256
303
  snapshots enable offline verify and fresh-clone reproduction, that whether to
257
304
  add extra ignore rules is a business repository decision, and that access
258
305
  credentials are not written to the workspace. Use the declared capture/align
259
306
  flow only after the user confirms remote reading. After declaring
260
- `captureLark({ source: source("<date-name>") })`, summarize the `src/index.ts`
307
+ `captureLark({ source: source("<date>", "<module>", { type: "lark" }) })`, summarize the `src/index.ts`
261
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.
262
318
  Apply [references/capture-source.md](references/capture-source.md) for route
263
319
  selection, dependency recovery, output handling, and final reporting, using the
264
320
  current capture phase command returned by `context status`.
@@ -268,23 +324,21 @@ current capture phase command returned by `context status`.
268
324
  If a registered source may contain multiple packages, run:
269
325
 
270
326
  ```bash
271
- context source inspect <source-name> --format json
327
+ context source inspect <date>/<module> --format json
272
328
  ```
273
329
 
274
330
  Present the detected module/package paths from that CLI output as a tree. Explain
275
331
  the choices without exposing internal API names first:
276
332
 
277
- - for the current executable flow, register one package/subdirectory as its
278
- own source when the user wants a focused package manual;
279
- - if the user is designing a unified subspace knowledge base, keep the
280
- date source namespace as the namespace decision, but do not run extraction
281
- 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.
282
336
 
283
337
  Wait for the user to choose. If the user chooses `packages/button`, register it
284
- as a separate source such as:
338
+ as another module in the same date batch:
285
339
 
286
340
  ```bash
287
- context source add repo --local <repo>/packages/button
341
+ context source add repo <date> --module button --local <repo>/packages/button
288
342
  ```
289
343
 
290
344
  Do not model a monorepo package choice as `include: ["packages/button/src/**"]`
@@ -299,7 +353,7 @@ the capture summary first:
299
353
  - document count;
300
354
  - title tree, heading tree, or source span distribution from the CLI output;
301
355
  - available reading budget and evidence views;
302
- - snapshot path under `sources/file|lark/YYYYMMDD/`;
356
+ - flat document path under `sources/file|lark/YYYYMMDD/` and the date-level `manifest.json`;
303
357
  - the fact that approved pages are planned through
304
358
  `unapproved/structure.yaml` before compile;
305
359
  - whether the source is local file/folder evidence or Lark/Feishu evidence.
@@ -361,11 +415,24 @@ I will first generate a preview without writing candidates. The preview will
361
415
  show counts plus the planned `knowledge/` tree.
362
416
  ```
363
417
 
364
- Only after the user confirms this product-level scope, declare the chosen date
365
- 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
366
420
  the human review phase. Use `include` only for a file-level filter within the
367
- chosen source boundary. Mention the internal API names only in code-change
368
- summaries, or when the user asks for implementation details.
421
+ chosen source boundary. If the package has no standard detected entry, keep the
422
+ source repository unchanged and ask whether its intended knowledge surface is:
423
+
424
+ - a public API graph rooted at specific files — configure source-relative
425
+ `entries` that are also matched by `include`; or
426
+ - all declarations in the matched files — configure `mode: "scan"`, which uses
427
+ no entries and includes internal symbols by default.
428
+
429
+ Mention the internal API names only in code-change summaries, or when the user
430
+ asks for implementation details.
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.
369
436
 
370
437
  ### Step 5 — Show The Pre-extraction Preview
371
438
 
@@ -378,7 +445,8 @@ context run <extract-phase-id> --dry-run --format json
378
445
  Show the user:
379
446
 
380
447
  - resolved source and module/package list;
381
- - file, symbol, and candidate estimate counts;
448
+ - discovered, AST-analyzed, skipped, symbol, relation, and candidate estimate
449
+ counts, including each skipped reason;
382
450
  - `knowledgeTree`;
383
451
  - several `knowledgePathExamples`.
384
452
 
@@ -389,14 +457,13 @@ containment, and slug; NodeRef/ViewRef are identity fields, not path strings:
389
457
  knowledge/<collection>/<containment>/<slug>.md
390
458
  ```
391
459
 
392
- If date source name, package name, module list, candidate estimate, or path shape is
393
- 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
394
462
  before extraction.
395
463
 
396
- For a single-module code source, a repeated path like
397
- `knowledge/codegraph/<date-source-name>/<package-name>/...` is usually a schema
398
- problem or a wrong source boundary. Stop before extraction if the preview shows
399
- 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.
400
467
 
401
468
  Do not present this as a CLI option or as "Context default options" to the
402
469
  user. Present it as the actual proposed knowledge impact: code area read,
@@ -412,6 +479,34 @@ matches it, run:
412
479
  context run <extract-phase-id>
413
480
  ```
414
481
 
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
488
+ added/updated/removed symbols, while unchanged approved symbols stay approved.
489
+ Do not open Review after each module.
490
+
491
+ Only when the user explicitly requests a non-interactive CI/CD codegraph sync,
492
+ run:
493
+
494
+ ```bash
495
+ context run <extract-phase-id> --auto-promote --format json
496
+ ```
497
+
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.
509
+
415
510
  If the preview reports modules outside the confirmed source boundary, do not
416
511
  run extraction. Ask the user to choose the corrected source boundary.
417
512
 
@@ -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.4
1
+ 0.6.0-beta.6
@@ -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.4",
4
+ "version": "0.6.0-beta.6",
5
5
  "author": {
6
6
  "name": "c4a"
7
7
  },
@@ -65,6 +65,10 @@ Capture phases are not safe mechanical commands by default. `capture:file:*`
65
65
  and `capture:lark:*` read local or remote source bodies and update committed
66
66
  snapshots, so they require the source read-permission gate unless the current
67
67
  turn already contains explicit user confirmation for that exact source.
68
+ An explicit request to capture, ingest, fetch, read, or include the exact
69
+ file/Lark path or URL is that confirmation; do not ask again after registration.
70
+ Mere mention, source discussion, or a register-only request is not confirmation,
71
+ and an explicit refusal always overrides inferred permission.
68
72
 
69
73
  ## Human Gates
70
74
 
@@ -117,10 +121,20 @@ do not forward a long raw transcript unless requested.
117
121
 
118
122
  ### Step 2 — Route The State
119
123
 
120
- 1. If status says `missing-source` or `needs-capture`,
124
+ 1. If status says `missing-source`, `needs-capture-phase`, `needs-capture`,
125
+ `needs-extract-phase`, or `ready-to-extract`,
121
126
  source boundary/name is unclear, source scope is unclear, or an extract
122
127
  phase needs first-run scope confirmation, follow
123
128
  `${CLAUDE_PLUGIN_ROOT}/skills/skill-source-scope/SKILL.md`.
129
+ When `routing.configuration` is present, make only that declared project
130
+ configuration change and rerun status. Otherwise follow
131
+ `routing.command_plan`: run `immediate` items directly and wait for current-
132
+ conversation confirmation before `after-human-confirmation` items.
133
+ For mixed sources, status intentionally returns `ready-to-extract` before
134
+ `captured-ready-to-investigate` while all document snapshots are captured,
135
+ document structure is untouched, and code extraction is missing, pending,
136
+ or stale. Explain that code is processed first, then follow the exact
137
+ extraction preview/rerun command.
124
138
  2. If status says `captured-ready-to-investigate` or `needs-structure`, or the
125
139
  user asks to split, merge, classify, relate, or semantically organize
126
140
  document evidence before draft pages exist, follow
@@ -128,7 +142,12 @@ do not forward a long raw transcript unless requested.
128
142
  3. If status says `needs-prose-compile` or `structure-ready`, or the user asks
129
143
  to turn confirmed structure into source-bound draft pages, follow
130
144
  `${CLAUDE_PLUGIN_ROOT}/skills/skill-prose-compile/SKILL.md`.
131
- 4. If status says `compile-ready-for-review` or review is needed, follow
145
+ 4. If the latest phase result has `next_action.human_gate=false`, follow its
146
+ command and do not invent a Review gate. This includes
147
+ `continue_compile_batch` and `continue-codegraph-batch`: finish the whole
148
+ prepared round first. If status says
149
+ `compile-ready-for-review`, or the latest result has
150
+ `next_action.human_gate=true`, follow
132
151
  `${CLAUDE_PLUGIN_ROOT}/skills/skill-review-gate/SKILL.md`.
133
152
  5. If status says `compile-close-needed`, run `context close --format json`
134
153
  unless CLI diagnostics require human repair, then return to **Step 1**.
@@ -170,3 +189,7 @@ usable; inspect generated package structure when package output is involved.
170
189
  conclusion and use the CLI view.
171
190
 
172
191
  </procedures>
192
+ If top-level `state`, `next`, or `routing.command_plan` contradicts
193
+ `draftCandidates`, `pendingReview`, `close.state`, package freshness, or verify
194
+ counts, stop instead of rerunning a completed phase. Report
195
+ `status-route-conflict` and preserve the detailed status output for diagnosis.