@c4a/context-cli 0.6.0-beta.7 → 0.6.0-beta.8

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 (67) hide show
  1. package/README.md +9 -3
  2. package/cli.js +15123 -13875
  3. package/package.json +2 -2
  4. package/plugin/README.md +8 -0
  5. package/plugin/README_CN.md +6 -0
  6. package/plugin/skills/skill-continue-workflow/SKILL.md +39 -3
  7. package/plugin/skills/skill-package-output/SKILL.md +16 -3
  8. package/plugin/skills/skill-prose-align/SKILL.md +26 -31
  9. package/plugin/skills/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +6 -12
  10. package/plugin/skills/skill-prose-align/references/internal-procedures/structure-planning.md +16 -10
  11. package/plugin/skills/skill-prose-compile/SKILL.md +26 -27
  12. package/plugin/skills/skill-review-gate/SKILL.md +17 -3
  13. package/plugin/skills/skill-source-scope/SKILL.md +10 -3
  14. package/plugins/README.md +8 -0
  15. package/plugins/README_CN.md +6 -0
  16. package/plugins/VERSION +1 -1
  17. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  18. package/plugins/claude/skills/skill-continue-workflow/SKILL.md +39 -3
  19. package/plugins/claude/skills/skill-package-output/SKILL.md +16 -3
  20. package/plugins/claude/skills/skill-prose-align/SKILL.md +26 -31
  21. package/plugins/claude/skills/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +6 -12
  22. package/plugins/claude/skills/skill-prose-align/references/internal-procedures/structure-planning.md +16 -10
  23. package/plugins/claude/skills/skill-prose-compile/SKILL.md +26 -27
  24. package/plugins/claude/skills/skill-review-gate/SKILL.md +17 -3
  25. package/plugins/claude/skills/skill-source-scope/SKILL.md +10 -3
  26. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  27. package/plugins/codex/skills/continue/references/internal-procedures/skill-continue-workflow.md +39 -3
  28. package/plugins/codex/skills/continue/references/internal-procedures/skill-package-output.md +16 -3
  29. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +6 -12
  30. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning.md +16 -10
  31. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-align.md +26 -31
  32. package/plugins/codex/skills/continue/references/internal-procedures/skill-prose-compile.md +26 -27
  33. package/plugins/codex/skills/continue/references/internal-procedures/skill-review-gate.md +17 -3
  34. package/plugins/codex/skills/continue/references/internal-procedures/skill-source-scope.md +10 -3
  35. package/plugins/codex/skills/init/references/internal-procedures/skill-continue-workflow.md +39 -3
  36. package/plugins/codex/skills/init/references/internal-procedures/skill-package-output.md +16 -3
  37. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +6 -12
  38. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning.md +16 -10
  39. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-align.md +26 -31
  40. package/plugins/codex/skills/init/references/internal-procedures/skill-prose-compile.md +26 -27
  41. package/plugins/codex/skills/init/references/internal-procedures/skill-review-gate.md +17 -3
  42. package/plugins/codex/skills/init/references/internal-procedures/skill-source-scope.md +10 -3
  43. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  44. package/plugins/cursor/skills/skill-continue-workflow/SKILL.md +39 -3
  45. package/plugins/cursor/skills/skill-package-output/SKILL.md +16 -3
  46. package/plugins/cursor/skills/skill-prose-align/SKILL.md +26 -31
  47. package/plugins/cursor/skills/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +6 -12
  48. package/plugins/cursor/skills/skill-prose-align/references/internal-procedures/structure-planning.md +16 -10
  49. package/plugins/cursor/skills/skill-prose-compile/SKILL.md +26 -27
  50. package/plugins/cursor/skills/skill-review-gate/SKILL.md +17 -3
  51. package/plugins/cursor/skills/skill-source-scope/SKILL.md +10 -3
  52. package/plugins/skills/context-continue/references/internal-procedures/skill-continue-workflow.md +39 -3
  53. package/plugins/skills/context-continue/references/internal-procedures/skill-package-output.md +16 -3
  54. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +6 -12
  55. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning.md +16 -10
  56. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-align.md +26 -31
  57. package/plugins/skills/context-continue/references/internal-procedures/skill-prose-compile.md +26 -27
  58. package/plugins/skills/context-continue/references/internal-procedures/skill-review-gate.md +17 -3
  59. package/plugins/skills/context-continue/references/internal-procedures/skill-source-scope.md +10 -3
  60. package/plugins/skills/context-init/references/internal-procedures/skill-continue-workflow.md +39 -3
  61. package/plugins/skills/context-init/references/internal-procedures/skill-package-output.md +16 -3
  62. package/plugins/skills/context-init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning/references/gates.md +6 -12
  63. package/plugins/skills/context-init/references/internal-procedures/skill-prose-align/references/internal-procedures/structure-planning.md +16 -10
  64. package/plugins/skills/context-init/references/internal-procedures/skill-prose-align.md +26 -31
  65. package/plugins/skills/context-init/references/internal-procedures/skill-prose-compile.md +26 -27
  66. package/plugins/skills/context-init/references/internal-procedures/skill-review-gate.md +17 -3
  67. package/plugins/skills/context-init/references/internal-procedures/skill-source-scope.md +10 -3
@@ -16,6 +16,10 @@ Turn captured document evidence into confirmed structure.
16
16
 
17
17
  - Use this after document capture, or when the user asks to split, merge,
18
18
  reorganize, classify, or relate document evidence.
19
+ - When status is `captured-ready-to-classify`, run every returned capture-phase
20
+ evidence command before editing `src/index.ts`. Use the collection-neutral
21
+ title tree, span index, and exact text to propose a mainline collection; wait
22
+ for user confirmation, then declare matching align/compile/review phases.
19
23
  - The first product output is a structure draft, not final page body.
20
24
  - Read source material only through CLI evidence views: `read-plan`,
21
25
  `source-index`, `span-detail`, `span-text`, `schema`, and
@@ -23,18 +27,16 @@ Turn captured document evidence into confirmed structure.
23
27
  and view set returned by the CLI.
24
28
  - Write and validate `context.structure.v1` into `unapproved/structure.yaml`.
25
29
  Stop for user confirmation before compile.
26
- - Before classifying nodes, section plans, edges, support strength, duplicates,
27
- conflicts, ownership, or unresolved items, read only the procedure references
28
- in the CLI `semantic_rules.required` set. Use each returned `reason` to keep
29
- unrelated rules out of the current judgment.
30
+ - Before semantic judgment, use the CLI `semantic-rules` View to page through
31
+ only `semantic_rules.required`. Use each selection `reason` to keep unrelated
32
+ rules out of the current judgment.
30
33
  - Plan source evidence as Sections before promoting any heading to a Node/View.
31
- Local FAQ, decision, incident, warning, or reference fragments normally stay
32
- under the owning View unless source evidence proves independent retrieval
33
- identity.
34
+ Promotion depends on source-backed standalone retrieval identity, not on a
35
+ hard-coded section kind or collection name.
34
36
  - Do not produce or validate a structure payload from this entry file alone. A
35
37
  ruleset already present in the active context may be reused only when both its
36
38
  `handle` and `digest` match. If the context was compacted, the digest changed,
37
- or the rule content is no longer present, read `semantic_rules.required`.
39
+ or the rule content is no longer present, resume the CLI rule-page sequence.
38
40
  - When status reaches `structure-ready` or `needs-prose-compile`, hand off to
39
41
  `skill-prose-compile.md`.
40
42
  - Compile, review, close, verify, and build remain separate gates.
@@ -47,32 +49,19 @@ Use semantic labels, not SDK function names:
47
49
 
48
50
  | Gate | Say this | Do not say this first |
49
51
  |---|---|---|
52
+ | Collection classification | "I have inspected the captured evidence. Based on these source characteristics, I recommend this knowledge category; please confirm before I configure compilation." | Guessing from a filename, URL, or SDK collection enum before investigation |
50
53
  | Material investigation | "I will read the evidence index and source spans through Context, then propose a structure draft." | `alignProse`, `source-index`, `context.structure.v1` |
51
54
  | Structure confirmation | "Confirming this structure freezes page paths, section ownership, and relationships for this compile round." | `unapproved/structure.yaml` as a raw parameter |
52
55
  | Compile handoff | "The structure is confirmed; I will switch to source-bound compile for draft pages." | Continuing to edit structure in compile |
53
56
 
54
57
  ## Runtime Discipline
55
58
 
56
- Use these rules in the current phase-runner flow:
57
-
58
- - Follow the top-level state, `routing.command_plan`, CLI `next_action`, and
59
- CLI-returned `next_command` values for every write. Treat `allowed_actions[]`
60
- as permission for read-only insertions; it is not a menu of alternate write
61
- paths.
62
- - Use `views[].command` / `next_command` for evidence reads, prioritizing the
63
- CLI-designated expected view when present.
64
- - Treat `agent_hints[]` as temporary diagnostics. If an agent hint conflicts
65
- with a top-level `next_action` or status route, follow the top-level route.
66
- - Do not use direct file tools, shell scripts, `jq`, `sed`, `cat`, `head`,
67
- `tail`, Python, or Node.js to inspect `sources/`, `unapproved/`,
68
- `knowledge/`, `dist/`, or CLI-managed `.tmp` as a substitute for Context
69
- views.
70
- - Write digest/hash flags are stale guards. Use the value returned by the CLI;
71
- do not parse stdout fragments or host tool-result files to reconstruct one.
72
- - Delegated execution is only valid when the user explicitly authorizes it in
73
- this conversation. Do not infer it from "continue", "继续", or general trust.
74
- - Run one write at a time. Do not parallelize align stage, compile stage, review
75
- apply, close, or build writes.
59
+ `skill-continue-workflow` owns global state routing; this Skill owns only the
60
+ align phase selected by that route. Use CLI evidence/rule/diagnostic Views,
61
+ follow their exact continuation commands, and treat hints as subordinate to
62
+ `next_action`. Evidence reads may be parallel; stage, confirm, Review apply,
63
+ close, and build writes remain serial. Never reconstruct digest values or
64
+ inspect CLI-managed state files as a substitute for a View.
76
65
  - If a payload is too large for a heredoc, stage it under
77
66
  `.tmp/agent-payloads/<run-id>/...` in the workspace root and redirect stdin
78
67
  from that file. Never reuse fixed `/tmp/c4a-*` names, and never place agent
@@ -118,6 +107,12 @@ confirmation. Do not write `lifecycle.state: confirmed`, `confirmed_by`,
118
107
  `confirmed_at`, or `structure_digest` until the user has explicitly confirmed
119
108
  the structure proposal in the conversation.
120
109
 
110
+ When the current conversation explicitly authorizes fully managed operation,
111
+ use the CLI-returned `--stage --managed` command after successful validation.
112
+ The CLI records `confirmed_by: managed-session`; validation errors and unresolved
113
+ evidence still block confirmation. Never persist managed mode in `defineProject`
114
+ or reuse it in another conversation.
115
+
121
116
  ## Procedure References
122
117
 
123
118
  These are current structure planning rules. They define the source-bound
@@ -200,7 +195,7 @@ Validate:
200
195
  context run align:<type>:<source>:<collection> --validate --input <structure.yaml> --format json
201
196
  ```
202
197
 
203
- Validation returns `structure_summary` and writes a temporary HTML report under
198
+ Validation returns a compact summary and writes a temporary HTML report under
204
199
  `.tmp/context-runtime/reports/`. A validation report with
205
200
  `confirmation_ready=false` is an Agent repair artifact, not a user review gate:
206
201
  do not ask the user to approve it. The staged report produced after
@@ -213,8 +208,8 @@ If the user needs a focused view, run:
213
208
  context run align:<type>:<source>:<collection> --view structure-summary --input <structure.yaml> --format json
214
209
  ```
215
210
 
216
- The CLI response may include a large full `structure_summary` for debugging and
217
- report rendering. For user confirmation, prioritize the first-screen fields:
211
+ The explicit `structure-summary` View returns the full summary for focused
212
+ debugging. For user confirmation, prioritize the default first-screen fields:
218
213
  `review_notice`, `structure_report`, and `structure_summary_compact`. A valid
219
214
  user-facing confirmation prompt must include the report `file_url`, the absolute
220
215
  path fallback, and a compact summary of collections/views/unresolved/diagnostics.
@@ -37,14 +37,13 @@ Compile confirmed document structure into reviewable draft knowledge.
37
37
  Do not write explicit `content`. If the evidence cannot be represented as a
38
38
  faithful mirrored continuous span, split the section or return to prose align
39
39
  for a confirmed structure change.
40
- - Before choosing section kind, summary, skip/update, weak-evidence handling, or
41
- structure repair, read only the procedure references in the CLI
42
- `semantic_rules.required` set. The CLI selects core and conditional rules for
43
- the current node and explains each selection with `reason`.
40
+ - Before semantic judgment, use the CLI `semantic-rules` View to page through
41
+ only `semantic_rules.required`; selection `reason` explains why each rule is
42
+ needed for the current node.
44
43
  - Do not produce or validate compile actions from this entry file alone. A
45
44
  ruleset already present in the active context may be reused only when both its
46
45
  `handle` and `digest` match. If the context was compacted, the digest changed,
47
- or the rule content is no longer present, read `semantic_rules.required`.
46
+ or the rule content is no longer present, resume the CLI rule-page sequence.
48
47
 
49
48
  <reference>
50
49
 
@@ -61,21 +60,16 @@ Use semantic labels, not SDK function names:
61
60
 
62
61
  ## Runtime Discipline
63
62
 
64
- - Follow `context status`, `routing.command_plan`, compile view
65
- `next_action`, and validation diagnostics. Treat CLI commands as the source
66
- of truth.
67
- - Use only the returned `next_action.command` for the next required write.
68
- Treat `allowed_actions[]` as permission for read-only insertions; it is not a
69
- menu of alternate write paths.
70
- - Treat `agent_hints[]` as temporary diagnostics. If an agent hint conflicts
71
- with a status route, compile view `next_action`, or validation result, follow
72
- the top-level route.
73
- - Do not use direct file tools, shell scripts, `jq`, `sed`, `cat`, `head`,
74
- `tail`, Python, or Node.js to inspect `sources/`, `unapproved/`,
75
- `knowledge/`, `dist/`, or CLI-managed `.tmp` as a substitute for Context
76
- views.
77
- - Run one write at a time. Do not parallelize compile stage, review apply,
78
- close, or build writes.
63
+ `skill-continue-workflow` owns global state routing; this Skill owns only the
64
+ compile phase selected by that route. Use CLI context/rule/diagnostic Views and
65
+ their exact continuation commands. Hints are subordinate to `next_action`.
66
+ Never inspect CLI-managed state files as a substitute for a View.
67
+ - Compile `read-plan`, `blockers`, `node-context`, and `schema` Views are
68
+ workspace-read-only and may be fetched in parallel. `--validate`, `--stage`,
69
+ structure confirmation, Review apply, and close remain serial mutations.
70
+ - One planned Section produces one compile action. When evidence contains
71
+ independently retrievable units, split them into sibling Sections in align;
72
+ do not split one planned Section into several compile actions.
79
73
  - One write still means one View, not one human Review. Stage every View in the
80
74
  same confirmed structure sequentially, follow `continue_compile_batch`, and
81
75
  open Review only after the CLI reports that the whole batch is prepared.
@@ -161,12 +155,12 @@ For each node that should become draft knowledge, run:
161
155
  ```bash
162
156
  context run compile:<type>:<source>:<collection> --view node-context --source <view-ref> --format json
163
157
  context run compile:<type>:<source>:<collection> --view schema --format json
158
+ context run compile:<type>:<source>:<collection> --view semantic-rules --source <view-ref> --format json
164
159
  ```
165
160
 
166
- Read only the compile references listed by `semantic_rules.required` before
167
- classifying section kind, summary, support, skip/update, weak evidence, or
168
- structure repair. Do not load the full rule inventory unless the CLI explicitly
169
- returns it as required.
161
+ Follow the semantic-rules `next_action.command` pages before classifying section
162
+ kind, summary, support, skip/update, weak evidence, or structure repair. Do not
163
+ load rules outside the returned required set.
170
164
 
171
165
  Do not treat those references as optional background. They are the current
172
166
  compile drafting, judgment, and semantic-repair procedures.
@@ -236,16 +230,21 @@ After staging, follow `next_action` exactly:
236
230
  - `continue_compile_batch` with `human_gate=false`: move to the returned next
237
231
  View and repeat **Step 2–4**. Do not open Review yet.
238
232
  - `review_candidates` with `human_gate=true`: every planned View in this
239
- confirmed structure is prepared; return to `context status`, then delegate
233
+ confirmed structure slot is prepared; return to `context status`. If
234
+ `pendingStructureTargets` is non-empty, complete those slots first. Delegate
240
235
  one collection-level Review to
241
- `skill-review-gate.md`.
236
+ `skill-review-gate.md` only when status
237
+ reports the complete multi-slot round ready.
238
+ - Use `status.structureBatch` as the complete slot overview. Its evidence Views
239
+ are parallel-safe, its structure mutations are serial, and Review opens once
240
+ after all declared slots are prepared.
242
241
 
243
242
  The CLI blocks Review and close while confirmed Views remain unprepared. Do not
244
243
  turn sequential View writes into sequential user approvals.
245
244
 
246
245
  ### Step 5 — Close Handoff
247
246
 
248
- After the single batch review apply, return to `context status`. If status says
247
+ After the single collection-level batch review apply, return to `context status`. If status says
249
248
  `compile-close-needed`, run deterministic close:
250
249
 
251
250
  ```bash
@@ -16,6 +16,11 @@ Run the human review gate. The user decides approval or rejection.
16
16
  ## TL;DR
17
17
 
18
18
  - The agent never approves or rejects candidates on the user's behalf.
19
+ - Exception: when the current conversation explicitly authorizes fully managed
20
+ operation and status routes a managed Review, run the exact
21
+ `context review approve-all <collection> --managed --format json` (or
22
+ `--all`) command. Do not open HTML, synthesize a Payload, or persist this
23
+ authority in project configuration.
19
24
  - Enter this skill only when the preceding command returns
20
25
  `next_action.human_gate=true`. A no-delta codegraph run returns false and does
21
26
  not need Review.
@@ -45,6 +50,15 @@ Run the human review gate. The user decides approval or rejection.
45
50
 
46
51
  <procedures>
47
52
 
53
+ ### Step 0 — Resolve Managed Review
54
+
55
+ If `context status --managed --format json` returns a managed-session Review
56
+ command, execute that atomic `approve-all` command and return to managed status.
57
+ Candidate scope, ids, fingerprints, structure digests, and source refs remain
58
+ fully validated; any mismatch is an error, not permission to bypass the gate.
59
+ Without explicit current-conversation managed authorization, continue with the
60
+ normal HTML workflow below.
61
+
48
62
  ### Step 1 — Open Review
49
63
 
50
64
  For the internal collection reported by status, run:
@@ -116,9 +130,9 @@ duplicate extract-index defect rather than running the metadata migration.
116
130
 
117
131
  ### Step 5 — Self-verify Checklist
118
132
 
119
- - [ ] Every decision came from the user's copied payload. If not, stop and
120
- discard the agent-authored decision, unless the user explicitly requested a
121
- scoped quick command and that command used `--collection` or `--all`.
133
+ - [ ] Every decision came from the user's copied payload, an explicitly scoped
134
+ quick command, or the current conversation's managed `approve-all` command.
135
+ If not, stop and discard the agent-authored decision.
122
136
  - [ ] Payload was applied through `context review apply`. If not, return to
123
137
  **Step 3**.
124
138
  - [ ] No direct edits were made to `knowledge/` or `unapproved/`. If not, report
@@ -52,6 +52,10 @@ Choose and validate what may become draft knowledge.
52
52
  - Before first real extraction, generate a no-write preview and show module
53
53
  counts plus `knowledgeTree` / `knowledgePathExamples` to the user. Use
54
54
  `--dry-run` only in the command you execute, not as the user-facing label.
55
+ - In explicit current-conversation fully managed mode, an evidence-backed
56
+ collection recommendation and a valid no-write extraction preview may be
57
+ accepted without another question. This never permits inventing a source
58
+ boundary or reading a file/Lark body the user did not authorize.
55
59
  - During a declared multi-module extraction round, treat
56
60
  `next_action.human_gate=false` as mechanical continuation: finish every
57
61
  pending extract phase before opening one combined Review page.
@@ -99,10 +103,13 @@ Ask for a knowledge source in plain language and map it to the supported path:
99
103
  | 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. |
100
104
  | 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. |
101
105
  | 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. |
106
+ | Lark / Feishu document | date batch, document module, URL/token, 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. Choose the mainline collection only after capture investigation. |
103
107
 
104
- When asking for a document mainline collection, do not ask only "which
105
- collection?". Explain every available option in product language:
108
+ When status reaches `captured-ready-to-classify`, run every immediate
109
+ collection-neutral investigation command first. Then ask for a document
110
+ mainline collection with an evidence-backed recommendation; do not ask only
111
+ "which collection?" or infer it from registration metadata. Explain relevant
112
+ options in product language:
106
113
 
107
114
  | Collection | Use when the source is mainly about |
108
115
  |---|---|
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "context",
3
3
  "displayName": "C4A Context",
4
- "version": "0.6.0-beta.7",
4
+ "version": "0.6.0-beta.8",
5
5
  "description": "Maintain a project-local knowledge workspace through init and next-step agent guidance.",
6
6
  "author": {
7
7
  "name": "Context4AI",
@@ -24,10 +24,24 @@ 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
+ - If the user explicitly authorizes fully managed operation in the current
28
+ conversation, start and continue that loop with `context status --managed
29
+ --format json`, then execute its managed `command_plan`. This authority is
30
+ conversation-only: do not write it into `defineProject`, project files, or
31
+ reuse it in a later conversation.
27
32
  - Inspect `declarationGraph` and `configurationGaps`. Before structure
28
33
  confirmation they are configuration warnings; after confirmation, a missing
29
34
  compile route is a hard gate. Never substitute a compile phase from another
30
35
  collection.
36
+ - Treat `unclassifiedDocumentTargets`, `pendingStructureTargets`, and nonterminal
37
+ `structureBatch.slots` as unfinished workspace work even when the
38
+ current approved package is ready. A build closes only the active snapshots;
39
+ it does not prevent a later captured source from entering its own structure
40
+ round.
41
+ - Confirm structure per canonical source + collection slot, but batch Review
42
+ across the declared round. When candidates exist and
43
+ `pendingStructureTargets` is non-empty, follow the pending align route before
44
+ opening Review; deterministic close later merges every active slot.
31
45
  - Execute safe mechanical `next:` steps; stop at semantic choices and human
32
46
  gates.
33
47
  - Delegate source/scope decisions to
@@ -76,6 +90,12 @@ and an explicit refusal always overrides inferred permission.
76
90
 
77
91
  ## Human Gates
78
92
 
93
+ In ordinary mode, follow every gate below. In explicit current-conversation
94
+ managed mode, the CLI may resolve classification, extraction scope, structure
95
+ confirmation, Review, and package-output choices without pausing. It still
96
+ must not infer a source boundary, read an unapproved source body, perform an
97
+ external repository/system operation, or bypass validation/verify errors.
98
+
79
99
  Stop and ask, or wait for user input, for:
80
100
 
81
101
  - `Human gate:` in CLI output.
@@ -120,6 +140,10 @@ Run:
120
140
  context status
121
141
  ```
122
142
 
143
+ Use `context status --managed --format json` instead only when the current
144
+ conversation explicitly contains fully managed authorization. Keep `--managed`
145
+ on commands returned by that status loop; otherwise never add it.
146
+
123
147
  Use the output as evidence. Explain status and next step in the user's language;
124
148
  do not forward a long raw transcript unless requested.
125
149
 
@@ -139,7 +163,12 @@ do not forward a long raw transcript unless requested.
139
163
  document structure is untouched, and code extraction is missing, pending,
140
164
  or stale. Explain that code is processed first, then follow the exact
141
165
  extraction preview/rerun command.
142
- 2. If status says `captured-ready-to-investigate` or `needs-structure`, or the
166
+ 2. If status says `captured-ready-to-classify`, run every immediate
167
+ collection-neutral investigation command, summarize evidence across all
168
+ targets, and ask the user to confirm the proposed mainline collection(s)
169
+ before editing `src/index.ts`. If status says `needs-prose-configuration`, apply only the generic
170
+ `routing.configuration` change in `src/index.ts`, rerun status, and do not
171
+ create a new workspace. If status says `captured-ready-to-investigate` or `needs-structure`, or the
143
172
  user asks to split, merge, classify, relate, or semantically organize
144
173
  document evidence before draft pages exist, follow
145
174
  `../skill-prose-align/SKILL.md`.
@@ -158,6 +187,10 @@ do not forward a long raw transcript unless requested.
158
187
  6. If status says `ready-to-build`, `built`, `needs-package-output`, or approved knowledge exists but
159
188
  package output is not chosen or declared,
160
189
  follow `../skill-package-output/SKILL.md`.
190
+ `built` is terminal only when both `unclassifiedDocumentTargets` and
191
+ `pendingStructureTargets` are empty. Use `structureBatch` for the complete
192
+ multi-source round: evidence Views are parallel-safe; stage, confirm, Review
193
+ apply, and close mutations are serial.
161
194
  7. If the next command is safe per [Safe Mechanical Commands](#safe-mechanical-commands),
162
195
  run it and return to **Step 1**.
163
196
  8. If the next command crosses a [Human Gate](#human-gates), ask or wait; do not
@@ -187,8 +220,11 @@ usable; inspect generated package structure when package output is involved.
187
220
 
188
221
  ### Step 5 — Self-verify Checklist
189
222
 
190
- - [ ] `context status` was run first. If not, return to **Step 1**.
191
- - [ ] No human gate was crossed. If not, stop and report the protocol error.
223
+ - [ ] `context status` (or explicitly authorized `context status --managed`) was
224
+ run first. If not, return to **Step 1**.
225
+ - [ ] No human gate was crossed without either direct user confirmation or the
226
+ current conversation's managed authorization. If not, stop and report the
227
+ protocol error.
192
228
  - [ ] No ad hoc file/script probing replaced CLI views. If not, discard that
193
229
  conclusion and use the CLI view.
194
230
 
@@ -16,6 +16,11 @@ Choose and build a package output from approved knowledge.
16
16
 
17
17
  - Package output is a human choice. Do not add package builders just because an
18
18
  example exists.
19
+ - In explicitly authorized current-conversation fully managed mode, resolve
20
+ this choice from the user's stated deliverable: use an agent knowledge-base
21
+ package for an Agent-facing knowledge workspace, an LLM text bundle only
22
+ when a text/RAG bundle was requested, and skip only when the user asked to
23
+ keep approved Markdown without a package. Do not persist this preference.
19
24
  - Recommend an agent knowledge-base package first for agent consumption.
20
25
  - Present an LLM text bundle as an alternative for a single text/RAG import
21
26
  bundle.
@@ -86,6 +91,12 @@ Explain in the user's conversation language:
86
91
  users can browse from OKF root -> group -> page; `wikis/index.md` is the
87
92
  required default OKF root entry, while selected `guides/`, `rules/`, or
88
93
  `feats/` roots get their own indexes too;
94
+ - the exact mapping is `codegraph`/`business`/`product` -> `wikis/`,
95
+ `architecture`/`sop`/`faq`/`decision`/`incident` -> `guides/`,
96
+ `standards`/`test` -> `rules/`, and `feats` -> `feats/`;
97
+ - `wikis/` is the structured entity-and-relationship layer; guides and rules
98
+ may explain, operationalize, or constrain it, but co-location does not prove
99
+ a relationship;
89
100
  - an LLM text bundle creates one text/RAG import bundle under
90
101
  `dist/<name>-llms/`;
91
102
  - the user can customize `src/package-templates/kb/` before build;
@@ -96,8 +107,8 @@ Explain in the user's conversation language:
96
107
  the structural edge contract and the evidence status from `context verify`;
97
108
  - the user can skip package output for now and keep only `knowledge/`.
98
109
 
99
- Ask which single output to create first using the host's native multi-choice
100
- tool when available. Use semantic option labels:
110
+ Outside managed mode, ask which single output to create first using the host's
111
+ native multi-choice tool when available. Use semantic option labels:
101
112
 
102
113
  - Agent knowledge-base package: for agents to query and cite approved knowledge pages.
103
114
  - LLM text bundle: for one text/RAG import bundle.
@@ -151,7 +162,9 @@ Do not patch `dist/` as the durable fix; edit the template under
151
162
 
152
163
  ### Step 5 — Self-verify Checklist
153
164
 
154
- - [ ] User selected the package output. If not, return to **Step 2**.
165
+ - [ ] The user selected the package output, or explicit current-conversation
166
+ managed mode resolved it from the stated deliverable. If not, return to
167
+ **Step 2**.
155
168
  - [ ] Only one output was added first. If not, ask before continuing with more.
156
169
  - [ ] A kb package template contains `wikis/index.md` and at least one
157
170
  `SKILL.md`.
@@ -16,6 +16,10 @@ Turn captured document evidence into confirmed structure.
16
16
 
17
17
  - Use this after document capture, or when the user asks to split, merge,
18
18
  reorganize, classify, or relate document evidence.
19
+ - When status is `captured-ready-to-classify`, run every returned capture-phase
20
+ evidence command before editing `src/index.ts`. Use the collection-neutral
21
+ title tree, span index, and exact text to propose a mainline collection; wait
22
+ for user confirmation, then declare matching align/compile/review phases.
19
23
  - The first product output is a structure draft, not final page body.
20
24
  - Read source material only through CLI evidence views: `read-plan`,
21
25
  `source-index`, `span-detail`, `span-text`, `schema`, and
@@ -23,18 +27,16 @@ Turn captured document evidence into confirmed structure.
23
27
  and view set returned by the CLI.
24
28
  - Write and validate `context.structure.v1` into `unapproved/structure.yaml`.
25
29
  Stop for user confirmation before compile.
26
- - Before classifying nodes, section plans, edges, support strength, duplicates,
27
- conflicts, ownership, or unresolved items, read only the procedure references
28
- in the CLI `semantic_rules.required` set. Use each returned `reason` to keep
29
- unrelated rules out of the current judgment.
30
+ - Before semantic judgment, use the CLI `semantic-rules` View to page through
31
+ only `semantic_rules.required`. Use each selection `reason` to keep unrelated
32
+ rules out of the current judgment.
30
33
  - Plan source evidence as Sections before promoting any heading to a Node/View.
31
- Local FAQ, decision, incident, warning, or reference fragments normally stay
32
- under the owning View unless source evidence proves independent retrieval
33
- identity.
34
+ Promotion depends on source-backed standalone retrieval identity, not on a
35
+ hard-coded section kind or collection name.
34
36
  - Do not produce or validate a structure payload from this entry file alone. A
35
37
  ruleset already present in the active context may be reused only when both its
36
38
  `handle` and `digest` match. If the context was compacted, the digest changed,
37
- or the rule content is no longer present, read `semantic_rules.required`.
39
+ or the rule content is no longer present, resume the CLI rule-page sequence.
38
40
  - When status reaches `structure-ready` or `needs-prose-compile`, hand off to
39
41
  `../skill-prose-compile/SKILL.md`.
40
42
  - Compile, review, close, verify, and build remain separate gates.
@@ -47,32 +49,19 @@ Use semantic labels, not SDK function names:
47
49
 
48
50
  | Gate | Say this | Do not say this first |
49
51
  |---|---|---|
52
+ | Collection classification | "I have inspected the captured evidence. Based on these source characteristics, I recommend this knowledge category; please confirm before I configure compilation." | Guessing from a filename, URL, or SDK collection enum before investigation |
50
53
  | Material investigation | "I will read the evidence index and source spans through Context, then propose a structure draft." | `alignProse`, `source-index`, `context.structure.v1` |
51
54
  | Structure confirmation | "Confirming this structure freezes page paths, section ownership, and relationships for this compile round." | `unapproved/structure.yaml` as a raw parameter |
52
55
  | Compile handoff | "The structure is confirmed; I will switch to source-bound compile for draft pages." | Continuing to edit structure in compile |
53
56
 
54
57
  ## Runtime Discipline
55
58
 
56
- Use these rules in the current phase-runner flow:
57
-
58
- - Follow the top-level state, `routing.command_plan`, CLI `next_action`, and
59
- CLI-returned `next_command` values for every write. Treat `allowed_actions[]`
60
- as permission for read-only insertions; it is not a menu of alternate write
61
- paths.
62
- - Use `views[].command` / `next_command` for evidence reads, prioritizing the
63
- CLI-designated expected view when present.
64
- - Treat `agent_hints[]` as temporary diagnostics. If an agent hint conflicts
65
- with a top-level `next_action` or status route, follow the top-level route.
66
- - Do not use direct file tools, shell scripts, `jq`, `sed`, `cat`, `head`,
67
- `tail`, Python, or Node.js to inspect `sources/`, `unapproved/`,
68
- `knowledge/`, `dist/`, or CLI-managed `.tmp` as a substitute for Context
69
- views.
70
- - Write digest/hash flags are stale guards. Use the value returned by the CLI;
71
- do not parse stdout fragments or host tool-result files to reconstruct one.
72
- - Delegated execution is only valid when the user explicitly authorizes it in
73
- this conversation. Do not infer it from "continue", "继续", or general trust.
74
- - Run one write at a time. Do not parallelize align stage, compile stage, review
75
- apply, close, or build writes.
59
+ `skill-continue-workflow` owns global state routing; this Skill owns only the
60
+ align phase selected by that route. Use CLI evidence/rule/diagnostic Views,
61
+ follow their exact continuation commands, and treat hints as subordinate to
62
+ `next_action`. Evidence reads may be parallel; stage, confirm, Review apply,
63
+ close, and build writes remain serial. Never reconstruct digest values or
64
+ inspect CLI-managed state files as a substitute for a View.
76
65
  - If a payload is too large for a heredoc, stage it under
77
66
  `.tmp/agent-payloads/<run-id>/...` in the workspace root and redirect stdin
78
67
  from that file. Never reuse fixed `/tmp/c4a-*` names, and never place agent
@@ -118,6 +107,12 @@ confirmation. Do not write `lifecycle.state: confirmed`, `confirmed_by`,
118
107
  `confirmed_at`, or `structure_digest` until the user has explicitly confirmed
119
108
  the structure proposal in the conversation.
120
109
 
110
+ When the current conversation explicitly authorizes fully managed operation,
111
+ use the CLI-returned `--stage --managed` command after successful validation.
112
+ The CLI records `confirmed_by: managed-session`; validation errors and unresolved
113
+ evidence still block confirmation. Never persist managed mode in `defineProject`
114
+ or reuse it in another conversation.
115
+
121
116
  ## Procedure References
122
117
 
123
118
  These are current structure planning rules. They define the source-bound
@@ -200,7 +195,7 @@ Validate:
200
195
  context run align:<type>:<source>:<collection> --validate --input <structure.yaml> --format json
201
196
  ```
202
197
 
203
- Validation returns `structure_summary` and writes a temporary HTML report under
198
+ Validation returns a compact summary and writes a temporary HTML report under
204
199
  `.tmp/context-runtime/reports/`. A validation report with
205
200
  `confirmation_ready=false` is an Agent repair artifact, not a user review gate:
206
201
  do not ask the user to approve it. The staged report produced after
@@ -213,8 +208,8 @@ If the user needs a focused view, run:
213
208
  context run align:<type>:<source>:<collection> --view structure-summary --input <structure.yaml> --format json
214
209
  ```
215
210
 
216
- The CLI response may include a large full `structure_summary` for debugging and
217
- report rendering. For user confirmation, prioritize the first-screen fields:
211
+ The explicit `structure-summary` View returns the full summary for focused
212
+ debugging. For user confirmation, prioritize the default first-screen fields:
218
213
  `review_notice`, `structure_report`, and `structure_summary_compact`. A valid
219
214
  user-facing confirmation prompt must include the report `file_url`, the absolute
220
215
  path fallback, and a compact summary of collections/views/unresolved/diagnostics.
@@ -90,18 +90,12 @@ by source evidence:
90
90
  4. The source gives it independent article identity: owner/date, lifecycle,
91
91
  timeline, tracking record, or cross-cutting support scope.
92
92
 
93
- Hard repairs:
94
-
95
- | Pattern | Repair |
96
- |---|---|
97
- | One local Q&A under a product/system page | `faq` Section under the owning View |
98
- | One-off conclusion or trade-off note | `decision` Section under the owning View |
99
- | Warning/failure note without incident identity | `warning` or `incident` Section under the owning View |
100
- | Reference/link bucket with no body | `unresolved[]` or omit, not an Entity page |
101
- | Many same-source, single-section child Entities under one parent | Merge them into parent Sections unless each child has standalone lookup identity |
102
-
103
- The CLI treats section-like child Views as invalid unless the payload provides
104
- source-backed independent identity through the surrounding structure.
93
+ Use one content-neutral test for every proposed child View: does cited evidence
94
+ support an independent subject identity, enough context to stand alone, and a
95
+ separate retrieval need? A heading, section kind, collection name, or contains
96
+ edge is not sufficient by itself. The CLI warns when many same-source,
97
+ single-section child Entities look mechanically fragmented, but it does not
98
+ reject a page merely because of its content type.
105
99
 
106
100
  ## Entity Tag Rules
107
101
 
@@ -163,11 +163,12 @@ child has an independent product/code object, atomic term, Action, or Domain
163
163
  identity. Also avoid copying the parent `system` / `application` scope tag onto
164
164
  local child aspects; tag a child by what it independently is.
165
165
 
166
- Do not promote local support fragments into child pages. FAQ, decision, and
167
- incident snippets under an owning topic stay as `faq`, `decision`, or
168
- `incident` Sections unless the source proves an independent article, lifecycle,
169
- timeline, owner/date, or cross-cutting retrieval scope. The CLI will reject
170
- section-like child views before confirmation.
166
+ Do not promote a source fragment into a child page solely because it has a
167
+ heading or a recognized section kind. Judge every proposed child with the same
168
+ source-backed criteria: independent subject identity, sufficient context, and
169
+ standalone retrieval value. The CLI may warn about repeated same-source thin
170
+ children, but page granularity remains an evidence-backed structure decision
171
+ for the review report rather than a content-type-specific hard gate.
171
172
 
172
173
  For `node.title` and `node.summary`, follow the workspace/source language
173
174
  surfaced by the current view or the user's instruction. In Chinese workspaces,
@@ -195,9 +196,11 @@ snapshot hash. Section identities are part of the structure gate: choose stable
195
196
  section ids such as `overview`, `behavior`, `constraints`, or a source-backed
196
197
  domain-specific name when the evidence supports it.
197
198
 
198
- Use only CLI-provided `source_refs[]` for section and edge evidence. Do not
199
- invent heading/range/window selectors inside the structure. Treat source heading
200
- changes as section-planning signals: sibling sub-headings under a shared parent
199
+ Use only CLI-provided `source_refs[]` for section and edge evidence. Continuity
200
+ is a per-Section constraint, not a per-View constraint: one View may contain
201
+ many independently retrievable Sections, each with its own continuous mirror.
202
+ Do not invent heading/range/window selectors inside the structure. Treat source
203
+ heading changes as section-planning signals: sibling sub-headings under a shared parent
201
204
  may stay in one Section when they form one coherent semantic topic; headings
202
205
  with no shared parent should usually split unless you intentionally want one
203
206
  Section to span them. If a semantic section would require non-contiguous or
@@ -216,8 +219,11 @@ material to `unresolved[]`.
216
219
 
217
220
  For pure suggested-split repairs, prefer the CLI repair view before hand-editing:
218
221
  `context run align:<type>:<source>:<collection> --repair suggested-splits --input <structure.yaml> --format json`.
219
- It splits non-contiguous Section mirrors. Oversized Views still require the
220
- Agent to apply the returned child-View and contains-edge suggestions while
222
+ It splits non-contiguous Section mirrors and can expand a broad cross-heading
223
+ Section into Markdown structural groups within the same View. Apply the
224
+ non-blocking repair hint when the groups should be independently retrievable;
225
+ otherwise keep the Section and explain the grouping in structure review.
226
+ Oversized Views still require the Agent to apply the returned child-View and contains-edge suggestions while
221
227
  classifying every child Node from evidence. The repair command does not resolve
222
228
  orphan ownership, unsupported evidence, or competing semantic groupings.
223
229