@c4a/context-cli 0.5.35-beta.1 → 0.5.35-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/context-cli",
3
- "version": "0.5.35-beta.1",
3
+ "version": "0.5.35-beta.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "context": "./cli.js"
package/plugin/README.md CHANGED
@@ -67,7 +67,7 @@ From your project directory:
67
67
 
68
68
  1. **Init** — `/context:init` creates the `.context/` workspace;
69
69
  2. **Capture** — `/context:capture <url-or-path>` pulls in Feishu docs, local Markdown, code snapshots, and so on;
70
- 3. **Code projection** — for code snapshots, `/context:compile --code <source-slug>` materializes package/category/symbol Nodes such as `pkg`, `pkg/components`, and `pkg/symbol/button`;
70
+ 3. **Code projection** — for code snapshots, `/context:compile code <source-slug>` materializes package/category/symbol Nodes such as `pkg`, `pkg/components`, and `pkg/symbol/button`;
71
71
  4. **Align** — `/context:align` places prose material onto the Node structure, including docs or examples that should attach to existing code symbol Nodes;
72
72
  5. **Compile** — `/context:compile` lets the AI turn prose material into structured Sections;
73
73
  6. **Query** — `/context:query <question>` answers from local knowledge, citing Node and Section; code workspaces can filter mixed evidence with `--evidence code|prose|all`;
@@ -67,7 +67,7 @@ bun add -g @c4a/context-cli
67
67
 
68
68
  1. **初始化** — `/context:init` 创建 `.context/` 工作目录;
69
69
  2. **采集** — `/context:capture <url-or-path>` 拉取飞书文档、本地 Markdown、代码快照等原始资料;
70
- 3. **代码投影** — 对代码快照执行 `/context:compile --code <source-slug>`,生成 `pkg`、`pkg/components`、`pkg/symbol/button` 这类 package/category/symbol Node;
70
+ 3. **代码投影** — 对代码快照执行 `/context:compile code <source-slug>`,生成 `pkg`、`pkg/components`、`pkg/symbol/button` 这类 package/category/symbol Node;
71
71
  4. **对齐** — `/context:align` 将文档原料归位至 Node 结构,包括挂靠到已有 code symbol Node 的手册、示例和经验;
72
72
  5. **编译** — `/context:compile` 由 AI 将文档原料加工为结构化 Section;
73
73
  6. **检索** — `/context:query <问题>` 在本地知识中查询答案,返回 Node 与 Section 级引用;代码工作区可用 `--evidence code|prose|all` 区分代码证据和文档证据;
@@ -8,39 +8,50 @@ allowed-tools: Bash(context:*)
8
8
 
9
9
  Run the beta.8 align workflow. `/context:align` is the user entrypoint; internal stages are workflow payloads, not public slash commands.
10
10
 
11
- If `$ARGUMENTS` contains `--code`, run `context align --code [slug]` and report that dry-run projection plan. This route is CLI-owned, writes no workflow/process files, and is the same deterministic plan implementation used by `context compile --code`.
11
+ If `$ARGUMENTS` contains `--code`, run `context align --code [slug]` and report that dry-run projection plan. This route is CLI-owned, writes no workflow/process files, and is the same deterministic plan implementation used by `context compile code`.
12
12
 
13
13
  Keep the prompt shape stable: read fixed schema/protocol first, then existing knowledge lookup, then the current source-specific payload. Do not reorder CLI JSON, add timestamps, or invent scratch paths.
14
14
 
15
- 1. Run `context align --scan --format json`. Use the returned workflow payload name, scope id, digest, and `next_command` / `show_command` fields as the continuation handles.
16
- - If the align-segments payload includes `generation_policy`, use it as the language contract for generated Node titles, summaries, rationale prose, and planned Section wording. Source-bound Section wording should stay close to the cited source language when it differs from the workspace language. Preserve product names, code identifiers, slugs, flags, `block_id` handles, and citation tokens exactly when needed.
15
+ ### Step 1 Scan
16
+
17
+ Run `context align --scan --format json`. Use the returned workflow payload name, scope id, digest, and `next_command` / `show_command` fields as the continuation handles.
18
+ - Read `align_route.next_command` before choosing any write path. Direct routes finalize immediately; batched routes are the only routes that use coarse-read and candidate ops.
19
+ - If the align-segments payload includes `generation_policy`, use it as the language contract for generated Node titles, Node summaries, rationale prose, and planned Section wording. Source-bound Section wording should stay close to the cited source language when it differs from the workspace language. Section summaries may later follow either the workspace language or the source-bound content language. Preserve product names, code identifiers, slugs, flags, `block_id` handles, and citation tokens exactly when needed.
17
20
  - Source titles and headings are ordinary evidence only. Do not automatically copy them into Node titles or aliases; classify the evidence referent first, then choose a title that fits the final Node type.
18
- 2. Read schema and payloads through CLI only:
21
+ ### Step 2 Read Schemas And Views
22
+
23
+ Read schema and payloads through CLI only:
19
24
  - `context schema align-segments`
20
- - `context schema align-coarse-read`
21
- - `context schema align-candidate-ops`
22
- - `context schema align-candidate-ledger`
23
- - `context schema align-candidate-aggregate`
24
25
  - `context schema align-structure-decision`
26
+ - If `align_route.next_command` points to `context align --coarse-read -`, also read `context schema align-coarse-read`, `context schema align-candidate-ops`, `context schema align-candidate-ledger`, and `context schema align-candidate-aggregate`.
25
27
  - `context workflow show --payload align-segments --view segment --unwrap --format json`
26
28
  - `context workflow show --payload align-segments --view source-mapping --unwrap --format json`
27
- - `context workflow show --payload align-segments --view blocks --token-budget 2000 --unwrap --format json`
28
- - `context workflow show --payload align-segments --view windows --unwrap --format json`
29
- - Drill into content only with semantic filters such as `--source <source-id>`, `--heading <prefix>`, `--window <window-id|src-N:M>`, or a larger `--token-budget <n>`. `src-N:M` means the M-th window under the `source_alias` shown by `--view windows`. If a budgeted view returns `truncated: true`, follow its `how_to_explore[]` commands before increasing the budget.
29
+ - `context workflow show --payload align-segments --view blocks --token-budget 8000 --unwrap --format json`
30
+ - `context workflow show --payload align-segments --view windows --page-size 10 --compact-hints --unwrap --format json`
31
+ - Default `source-mapping` is a compact per-source index; add `--source <source-id>` only when you need that source's block id map. `blocks` is the text-bearing view: budgeted rows include full block `text` plus `text_preview`, so do not call another full-text path just to read selected align blocks.
32
+ - Drill into content only with semantic filters such as `--source <source-id>`, `--heading <prefix>`, `--window <window-id|src-N:M[,selector...]>`, or a larger `--token-budget <n>`. `src-N:M` means the M-th window under the `source_alias` shown by `--view windows`; comma-separated selectors fetch several windows in one call. When a paged blocks view returns `page.next_token` or `next_command`, follow `next_command` to continue the same view. Use `window_read_plan`, `windows[].read_strategy`, `windows[].content_size`, `windows[].selector`, and `windows[].batch_selector` to skip low-signal windows, use inline tiny windows, batch neighboring small windows, or drill only selected large windows. The preferred agent reading band is roughly 15K-30K chars / 4K-8K tokens; 50K chars / 12K tokens is an acceptable upper band for a single focused read. Rerun the windows view without `--compact-hints` only when exact per-row commands are needed.
30
33
  - `--unwrap` only removes the workflow metadata envelope. It does not turn a summary view into detail output.
31
- 3. Reuse existing knowledge before inventing candidates. For named terms or entities, prefer `context mdrive glossary match <name>` and `context mdrive node list --format json` over direct file reads. Treat `match.kind`, `match.matched`, and `match.rank` as stable lookup hints: exact title/slug/alias hits should usually reuse the existing Node instead of creating another one.
32
- - Apply packaged `context:skill-align-workflow` Node classification gates before candidate ops and again before finalize: Action requires scale plus process evidence; Entity requires a concrete A/B tag or pure `term`; Domain requires child Nodes; fake Entities need at least two suspicious signals before downgrade. Scope/process words in a source title, such as "方案", "架构", "流程", "策略", or "演练", are review signals for the title/type choice, not proof that the Node is an Entity.
34
+ ### Step 3 Reuse Existing Knowledge
35
+
36
+ Reuse existing knowledge before inventing candidates. For named terms or entities, prefer `context mdrive glossary match <name>` and `context mdrive node list --format json` over direct file reads. Treat `match.kind`, `match.matched`, and `match.rank` as stable lookup hints: exact title/slug/alias hits should usually reuse the existing Node instead of creating another one.
37
+ - Apply packaged `context:skill-align-workflow` Node classification gates before finalize; in batched routes, also apply them before candidate ops. Action requires scale plus process evidence; Entity requires a concrete A/B tag or pure `term`; Domain requires child Nodes; fake Entities need at least two suspicious signals before downgrade. Scope/process words in a source title, such as "方案", "架构", "流程", "策略", or "演练", are review signals for the title/type choice, not proof that the Node is an Entity.
33
38
  - Code projection Nodes are reusable knowledge handles. When prose evidence should attach to an existing code symbol Node, reuse the code slug (for example `pkg/symbol/button`) instead of creating a parallel document Node. If that code slug is not already in finalized prose ownership, declare it in the current `nodes[]` with the same node type and compatible tags/title, add the desired `planned_sections`, and point `sections[].owner` plus `block_ownership[].owners` at that slug. Do not cite `aspect:code:*` source refs from prose Sections; prose Sections cite only the current document evidence.
34
- 4. Submit generated workflow payloads directly through stdin, preferably as JSON. Use YAML schemas only for reading examples when helpful; generated artifacts should avoid YAML quoting/indentation failure loops. Do not create `/tmp` or workspace scratch files for align payloads. The CLI owns ids, reducer validation, workflow payload storage, and mechanical aggregate. You own semantic discovery, Node type/tag decisions, structure decisions, and user-facing questions.
35
- - Save coarse-read with `context align --coarse-read - --format json`.
36
- The latest `align-coarse-read` payload is only the most recent checkpoint; durable multi-source reading notes are stored under `align-candidate-ledger.source_readings`.
37
- Prefer omitting `schema_version` in generated coarse-read JSON; the CLI infers single-source vs batch from shape. For multiple sources, submit one envelope with `coarse_reads[]`; each entry must use the current coarse-read fields (`source_id`, `density_profile`, `reading_anchors`, `section_proposals`), not retired `reading_notes` / `block_readings`.
38
- - Submit each candidate batch with `context align --ops - --format json`. Prefer omitting `schema_version`; the CLI normalizes candidate ops to the current schema. Keep `batch_id`, `ops[]`, and current op field names from `context schema align-candidate-ops`.
39
+ ### Step 4 Follow The Route
40
+
41
+ Submit generated workflow payloads directly through stdin, preferably as JSON. Use YAML schemas only for reading examples when helpful; generated artifacts should avoid YAML quoting/indentation failure loops. Do not create `/tmp` or workspace scratch files for align payloads. The CLI owns ids, reducer validation, workflow payload storage, and mechanical aggregate. You own semantic discovery, Node type/tag decisions, structure decisions, and user-facing questions.
42
+ - If `align_route.next_command` points to `context align --finalize -`, skip coarse-read, candidate ops, ledger, and aggregate. Build the `align-structure-decision` and submit the returned finalize command.
43
+ - If `align_route.next_command` points to `context align --coarse-read -`, save coarse-read with `context align --coarse-read - --format json`. The latest `align-coarse-read` payload is only the most recent checkpoint; durable multi-source reading notes are stored under `align-candidate-ledger.source_readings`. Prefer omitting `schema_version` in generated coarse-read JSON; the CLI infers single-source vs batch from shape. For multiple sources, submit one envelope with `coarse_reads[]`; each entry must use the current coarse-read fields (`source_id`, `density_profile`, `reading_anchors`, `section_proposals`), not retired `reading_notes` / `block_readings`.
44
+ - Only after batched coarse-read is stored, submit each candidate batch with `context align --ops - --format json`. Prefer omitting `schema_version`; the CLI normalizes candidate ops to the current schema. Keep `batch_id`, `ops[]`, and current op field names from `context schema align-candidate-ops`.
39
45
  - `--ledger-digest <digest>` is optional. Usually omit it and let the CLI merge against the current ledger; pass it only when you intentionally want stale-batch rejection for a high-assurance retry.
40
- - Read the resulting payloads with `context workflow show --payload align-candidate-ledger --view ledger --unwrap --format json` and `context workflow show --payload align-candidate-aggregate --view aggregate --unwrap --format json`. To revisit one source's coarse-read notes, add `--source <source-id>` to the ledger view; candidates do not carry source ids, so add `--status` or `--candidate-id` only when you also need candidate rows.
46
+ - For batched routes, read the resulting payloads with `context workflow show --payload align-candidate-ledger --view ledger --unwrap --format json` and `context workflow show --payload align-candidate-aggregate --view aggregate --unwrap --format json`. To revisit one source's coarse-read notes, add `--source <source-id>` to the ledger view; candidates do not carry source ids, so add `--status` or `--candidate-id` only when you also need candidate rows.
41
47
  - Review `anomaly_signals[]` as warnings: fix clear mistakes with another ops batch, otherwise continue to finalize and carry the warning rationale in your final decision/report.
42
- 5. If any CLI command returns `agent_hints[]`, follow those hints before retrying. Legacy-protocol hints mean the submitted payload or schema name is retired; switch to the beta.8 schema named in the hint instead of adapting old fields.
43
- 6. Finalize only with `align-structure-decision`:
48
+ ### Step 5 Follow Hints
49
+
50
+ If any CLI command returns `agent_hints[]`, follow those hints before retrying. Legacy-protocol hints mean the submitted payload or schema name is retired; switch to the beta.8 schema named in the hint instead of adapting old fields.
51
+
52
+ ### Step 6 — Finalize
53
+
54
+ Finalize only with `align-structure-decision`:
44
55
 
45
56
  ```bash
46
57
  context align --finalize -
@@ -57,7 +68,7 @@ If finalize returns an `align-finalize-draft` payload, patch that saved draft wi
57
68
  }
58
69
  ```
59
70
 
60
- Submit the patch with `context align --finalize-patch - --format json`. Add `--payload-digest` only when you intentionally want an explicit stale guard.
71
+ Submit the patch with `context align patch draft --input - --format json`. Add `--payload-digest` only when you intentionally want an explicit stale guard.
61
72
 
62
73
  After a successful finalize, use a targeted ownership patch for small role corrections only; do not resubmit the whole structure just to move a few blocks between `context_only`, `ignored`, `owned`, or `shared`:
63
74
 
@@ -77,13 +88,15 @@ After a successful finalize, use a targeted ownership patch for small role corre
77
88
  }
78
89
  ```
79
90
 
80
- Submit it with `context align --ownership-patch - --format json`. Keep `base_digest` in the patch body when you want stale ownership rejection. Use `context schema align-ownership-patch` for the exact shape.
91
+ Submit it with `context align patch ownership --input - --format json`. Keep `base_digest` in the patch body when you want stale ownership rejection. Use `context schema align-ownership-patch` for the exact shape.
81
92
 
82
93
  If `align-segments.incremental.mode` is `incremental`, the finalize step is a delta merge: submit only the Nodes and block ownership supported by the current scanned sources, and reference previous finalized Nodes when they are parents, dependencies, domain children, owners, or visibility targets. Absence of an old Node or edge is not a delete signal. Do not redeclare an old parent/domain just to attach a new child. `sections[].owner` must be a Node declared in the current payload; previous finalized Nodes can be referenced structurally but do not receive new section plans from this incremental payload. Existing or previously removed Node slugs cannot change `node_type`; `context align --scan --full` does not bypass that guard. Use a new slug for a different type, or retire the old slug through `context drop` or explicit structure correction before re-aligning.
83
94
 
84
95
  For code-projection Nodes, distinguish "reuse the existing knowledge file" from "previous finalized prose ownership". A freshly projected code Node may exist in `knowledge/` but not yet appear in finalized ownership. To attach current prose evidence to it, declare that same slug in the current finalize payload and plan only prose-owned Sections for the current evidence; the compile step will merge the prose source and Sections into the existing code Node while preserving code metadata and code-owned Sections.
85
96
 
86
- `nodes[].planned_sections` is the distinct set of Section kinds planned for that Node. List each kind at most once; do not copy `sections[].section_kind` one-for-one when a Node has multiple Sections of the same kind.
97
+ `nodes[].planned_sections` is the distinct set of Section kinds used as compile scaffolding for that Node, not a hard completion gate. List each kind at most once; do not copy `sections[].section_kind` one-for-one when a Node has multiple Sections of the same kind.
98
+
99
+ Each `sections[].block_ids` entry must be one contiguous run of citation-eligible blocks from one source. If one conceptual Section spans gaps, split it into multiple `sections[]` plans or include the intervening citation-eligible blocks. The CLI rejects non-contiguous plans at finalize so compile does not have to rediscover the split later.
87
100
 
88
101
  For large finalize decisions, use `block_ownership_defaults[]` instead of enumerating every block. Each default names a `source_id` plus the same ownership fields as a block-level entry except `block_id`; the CLI expands it across that source's coverable blocks. Put only exceptions in `block_ownership[]`, which override defaults for their `block_id`. Keep the payload on stdin; do not generate temp JSON files just to list hundreds of ownership rows.
89
102
 
@@ -100,8 +113,17 @@ Do not submit legacy candidate tables, old patch payloads, or full-tree proposal
100
113
  - Semantic boundary failures should become downgrade warnings or unresolved items. Do not retry the same semantic judgment in a loop.
101
114
  - Hard reference failures must be repaired at the exact op/path with a valid id/ref from the current payload. Use CLI `agent_hints[]` as the repair contract when present.
102
115
  - Do not read or modify source snapshots, caches, or rendered workflow artifacts with generic tools. Use `context workflow show`, schema commands, payload name, scope id, digest, and candidate ids as the workflow contract.
103
- - Do not pipe `context ... --format json` through `jq`, `head`, `tail`, `sed`, `cat`, `2>&1`, Python, Node.js, or shell scripts. Do not read host persisted output files such as Claude `tool-results/**`. Consume complete CLI stdout directly. Use semantic views plus `--source` / `--heading` / `--window` / `--token-budget` and returned `how_to_explore[]` when the payload is too large.
116
+ - Do not pipe `context ... --format json` through `jq`, `head`, `tail`, `sed`, `cat`, `2>&1`, Python, Node.js, or shell scripts. Do not read host persisted output files such as Claude `tool-results/**`. Consume complete CLI stdout directly. Use semantic views plus `--source` / `--heading` / `--window` / `--token-budget`, returned `next_command`, and returned `how_to_explore[]` when the payload is too large.
104
117
 
105
118
  ## Final Report
106
119
 
107
- Report in the user's language. Include final Node counts by type, unresolved ownership count, workflow payload identifiers, and the next step (`/context:compile` or another `/context:align` pass for unresolved structure).
120
+ Report in the user's conversation language. Translate section headings into the user's language instead of copying the English labels below verbatim. Optimize for human readability: use Node titles instead of slugs in prose, human-readable Node types (`domain` / `entity` / `action`) instead of internal flags, and Section kind names instead of mount-matrix identifiers. Do not surface workflow payload digests, scope ids, block hashes, snapshot digests, or absolute file paths.
121
+
122
+ Stable structure:
123
+
124
+ 1. Completion headline. Single line with total Node count and the breakdown by Node type (for example "12 Nodes: 2 domain · 8 entity · 2 action"). Capture data from the finalize result's `summary`.
125
+ 2. Node structure tree. Render the finalized Node graph as a tree grouped by domain when domains exist (`domain` Node → its `entity` / `action` children; standalone Nodes appear at root). Show the Node title and Node type for each entry, and mark `[new]` / `[modified]` / `[reused]` per Node based on the finalize delta against the previous finalized ownership. Use the same tree for incremental delta finalize; do not omit reused Nodes referenced as parents or dependencies of changed Nodes.
126
+ 3. Variance summary. Bullet list of counts: new Nodes, modified Nodes, reused Nodes, removed Nodes (when any), planned Sections (total across `nodes[].planned_sections`), unresolved ownership items, and any structure-decision warnings. Show every counter so the user can verify nothing unexpected fired, including zeros for new/modified/removed.
127
+ 4. Next step. Single command suggestion: `/context:compile` when there is compile work to do; another `/context:align` pass only when unresolved structure remains.
128
+
129
+ Do not include raw `align-segments` digests, scope ids, or workflow payload identifiers in the report. Those belong in earlier troubleshooting output, not in the completion summary.
@@ -10,7 +10,7 @@ missing-dependency install flow) lives inline here per the slash-command
10
10
  length exemption for self-contained slash commands.
11
11
  -->
12
12
 
13
- ## Your task
13
+ ## Your Task
14
14
 
15
15
  Capture is entirely CLI-driven — your role is to route the right `context capture` invocation and relay its output. Never hand-write captured source snapshots: the CLI owns normalisation (NFC, BOM strip, line endings) and the `content_hash` contract, so any manual edit breaks idempotency.
16
16
 
@@ -56,20 +56,35 @@ EOF
56
56
 
57
57
  Do not pipe the heredoc through another command, and do not discover files with `find` / `ls` when the user already supplied the paths.
58
58
 
59
- ### Output handling
59
+ ### Output Handling
60
60
 
61
61
  Report the CLI output verbatim. If the CLI reports `N sources changed`, suggest the right next step:
62
62
 
63
63
  - Run `context status --format json` and use its `next_step.command` / `workflow.next_step`.
64
64
  - If status says aligned knowledge is missing or alignment is required → suggest `/context:align`.
65
65
  - If status says compile work is pending for Markdown / evidence-backed knowledge → suggest `/context:compile`. Mention `/context:align` only if the user wants to revise the structure.
66
- - If the capture was code-only and status reports pending code projection, suggest the CLI-owned code route: `/context:compile --code <source-slug>` or `context compile --code <source-slug>`, followed by `context compile --close` when the CLI asks for close.
66
+ - If the capture was code-only and status reports pending code projection, suggest the CLI-owned code route: `/context:compile code <source-slug>` or `context compile code <source-slug>`, followed by `context compile close` when the CLI asks for close.
67
67
 
68
- Never suggest prose compile or hand-built code knowledge for a code-only source. Code snapshots become active knowledge only through `context compile --code`, which materializes package/category/symbol Nodes deterministically.
68
+ Never suggest prose compile or hand-built code knowledge for a code-only source. Code snapshots become active knowledge only through `context compile code`, which materializes package/category/symbol Nodes deterministically.
69
69
 
70
70
  If capture is rejected with `agent_hints[].code = "workflow-cross-family-rejected"`, do **not** run `context workflow abandon ...` automatically. First run or ask the user to run `context workflow status --format json` and explain that another workflow is active in this workspace. Continue that workflow when it is the intended task; ask the user before abandoning it when the user wants to discard that in-progress work. If the user expected a different repository/workspace, change to the confirmed workspace root before retrying capture.
71
71
 
72
- ### Missing dependency recovery
72
+ ## Final Report
73
+
74
+ Report in the user's conversation language. Translate section headings into the user's language instead of copying the English labels below verbatim. Optimize for human readability: use document titles instead of source ids, package names instead of `aspect:code:*` strings, and human-readable kind labels ("local markdown", "Feishu doc", "code package") instead of internal tokens. Do not surface content hashes, snapshot digests, workflow payload ids, or absolute file paths.
75
+
76
+ Stable structure:
77
+
78
+ 1. Completion headline. Single line with the action verb plus core counts: how many sources were captured this round, broken down by `new` / `updated` / `unchanged`. Capture data from `context capture ... --format json` `result.summary` (or per-source statuses when no aggregate is returned).
79
+ 2. Per-source list grouped by status. Show each captured source under one of three groups (`new` / `updated` / `unchanged`); within each group list the document title (`source.title`), kind label, and a short delta indicator for updated sources (for example added/removed line counts when the CLI returns them; otherwise "content changed"). Cache-hit code packages belong in `unchanged`. Omit groups that are empty.
80
+ 3. Pending workflow signals. When `context status --view summary --format json` reports follow-up work tied to this capture (sources pending align, sources pending compile, refreshed sources pending recompile, code sources pending projection), summarize each as a single line naming the work and which sources are affected. Omit the section entirely when there is no pending follow-up.
81
+ 4. Next step. Single command suggestion driven by status: `/context:align` when structure work is pending, `/context:compile` when prose compile work is pending, `context compile code <slug>` (or `/context:compile code <slug>`) when code projection is pending. If nothing is pending, say so explicitly.
82
+
83
+ Do not include raw CLI diagnostics, agent_hints content, schema names, or workflow payload identifiers in the report. Those belong in earlier troubleshooting output, not in the completion summary.
84
+
85
+ ## Reference
86
+
87
+ ### Missing Dependency Recovery
73
88
 
74
89
  If the CLI returns `agent_hints[]` with `code: "capture-code-typescript-plugin-missing"`, stop and surface the hint. Ask the user once for permission to run `agent_hints[0].command` (the CLI has already picked the correct package manager — `npm install -g` or `bun install -g` — based on how `context` itself was installed). If approved, run that exact command via `Bash` and then retry the original capture; if declined, leave the command visible for manual install. Never substitute a different package manager or version.
75
90
 
@@ -81,7 +96,7 @@ If the CLI prints a missing-dependency error like `lark-cli not installed`, walk
81
96
  4. Stop on any failure; surface stderr verbatim.
82
97
  5. After success, tell the user to re-run their original `/context:*` command themselves.
83
98
 
84
- ### Language policy
99
+ ### Language Policy
85
100
 
86
101
  Your prose to the user follows the user's conversation language. CLI commands, flag names, URLs, env-var names, binary names, source-ids stay English.
87
102
 
@@ -93,5 +108,5 @@ Your prose to the user follows the user's conversation language. CLI commands, f
93
108
  - In `--format json`, code capture runner cache state is authoritative in `result.runner.cacheMode`: `prepared` means a workspace runner was prepared, `cached` means workspace cache hit, and `bypass` means `--no-runner-cache` used a temporary runner directory instead of the workspace runner cache.
94
109
  - Aspect snapshots default to `evidence.mode: none`. Prose-like custom aspects must opt in with `evidence: { mode: block }` in `aspects/<name>/aspect.yaml` before they generate evidence manifests. Invalid `evidence.mode` values are reported as `evidence-policy-invalid`; they are not silently treated as `none`.
95
110
  - Code aspect snapshots ship with `evidence.mode: none`; symbols/files/edges are indexed inside the code bucket. Do not ask users to inspect or repair a code `.evidence` manifest.
96
- - Code aspect capture writes raw code snapshots first. Materialize them with `context compile --code <slug>` (or no slug for all actionable code sources) before prose align needs to attach documentation to code Nodes.
111
+ - Code aspect capture writes raw code snapshots first. Materialize them with `context compile code <slug>` (or no slug for all actionable code sources) before prose align needs to attach documentation to code Nodes.
97
112
  - On duplicate capture of the same URL: identical `content_hash` → CLI skips with `unchanged`; different hash → CLI appends a new snapshot.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  description: "Compile the confirmed align plan into knowledge articles: draft, semantic reconciliation, apply, then close."
3
- argument-hint: "[--plan]"
3
+ argument-hint: "[--plan|code <slug>]"
4
4
  allowed-tools: Bash(context:*)
5
5
  ---
6
6
 
@@ -11,7 +11,7 @@ belongs here rather than split across skill references.
11
11
  The agent protocol itself still delegates to internal packaged procedures.
12
12
  -->
13
13
 
14
- ## Your task
14
+ ## Your Task
15
15
 
16
16
  Synthesise the finalized align plan into knowledge through semantic CLI operations. If the user explicitly authorized托管/全自动/delegated mode at the start of this conversation, create the compile workflow with `--delegated`; otherwise stay in manual/default mode. The agent produces compile draft JSON per Node; the CLI owns storage, rendering, verification, and workflow payload persistence. Read workflow payloads with `context workflow show`; write through `context compile`, `context reconcile`, and `context mdrive` operations, never through direct workspace file tools.
17
17
 
@@ -21,28 +21,31 @@ Naming convention:
21
21
  - `context ...` names CLI primitives.
22
22
  - Internal packaged procedures invoked by slash workflows are not user slash commands. Do not invent extra slash-command entrypoints for draft or close stages.
23
23
 
24
- Modes:
24
+ ### Modes
25
25
 
26
26
  - **Default (no flag)** — draft plan + semantic reconciliation + apply writes + close.
27
- - **`--plan`** (opt-in when `$ARGUMENTS` contains `--plan`) — per Node, run `context compile --draft <slug> --input - --plan` so the CLI validates stdin draft content without writing active knowledge; surface a user-facing change list (new knowledge, replaced knowledge, unchanged knowledge, and why) while keeping internal Section ids / source refs in details only when needed, then **stop at the end of the per-Node loop — do NOT run close**. The user re-runs `/context:compile` without `--plan` to apply; that run does the real writes + close.
28
- - **`--code [slug]`** — run the CLI-owned code projection route directly with `context compile --code [slug]`, report its output, then stop. This route does not enter doctor/draft/reconcile and uses the same deterministic implementation as `context align --code`. It materializes code snapshots into package/category/symbol Nodes; run `context compile --close` afterward only when the CLI asks for close.
27
+ - **`--plan`** (opt-in when `$ARGUMENTS` contains `--plan`) — per Node, run `context compile draft <slug> --input -` so the CLI validates stdin draft content without writing active knowledge; surface a user-facing change list (new knowledge, replaced knowledge, unchanged knowledge, and why) while keeping internal Section ids / source refs in details only when needed, then **stop at the end of the per-Node loop — do NOT run close**. The user re-runs `/context:compile` without `--plan` to apply; that run does the real writes + close.
28
+ - **`code [slug]`** — run the CLI-owned code projection route directly with `context compile code [slug]`, report its output, then stop. This route does not enter doctor/draft/reconcile and uses the same deterministic implementation as `context align --code`. It materializes code snapshots into package/category/symbol Nodes; run `context compile close` afterward only when the CLI asks for close.
29
29
 
30
- Delegated workflow mode:
30
+ ### Delegated Workflow Mode
31
31
 
32
- - If the user explicitly authorized托管/全自动/delegated mode at the start of this conversation, add `--delegated` to the first compile workflow-creating command, preferably `context compile --scan-changes --delegated --format json`. Do not add it for vague "continue" / "继续" permission.
33
- - `--delegated` is a workflow-level authorization, not a per-review override. It only lets the CLI auto-accept low-risk weak lexical support when `source_support.missing_hard_terms` is empty; missing hard facts, type drift, schema errors, ownership/structure challenges, and destructive gates still block.
32
+ - If the user explicitly authorized托管/全自动/delegated mode at the start of this conversation, add `--delegated` to the first compile workflow-creating command, preferably `context compile scan --delegated --format json`. Do not add it for vague "continue" / "继续" permission.
33
+ - `--delegated` is a workflow-level authorization, not a per-review override. It only lets the CLI auto-accept low-risk defaults: weak lexical support with empty `source_support.missing_hard_terms`, or supported `keep_separate` decisions whose candidates have no duplicate/conflict/archive/reanchor risk and no pinned target Section. Missing hard facts, type drift, schema errors, ownership/structure challenges, user-confirmation gates, and destructive gates still block.
34
34
  - Never hand-author `decided_by: delegated_agent`; the CLI injects it only inside a delegated compile workflow.
35
35
 
36
- Language policy: your explanatory prose and final reports follow the user's conversation language. Node titles, summaries, and user-facing draft explanations follow `NodeContext.generation_policy.language` when the CLI provides it. Source-bound compile draft `content` should stay close to the cited source language when it differs from the workspace language; do not translate cited English facts into Chinese just to match the workspace. Section `summary` is a compact reader/query aid derived from `content`; source_support hard-term matching checks `content`, not `summary`. Preserve product names, code identifiers, CLI flags, slugs, `block_id` / `source_ref` tokens, and exact quoted evidence as printed. CLI stdout/stderr, the canonical `processing <slug>` lines, paths, slugs, block ids, source refs, issue codes, flags, and command names stay as printed.
36
+ ### Shared Policies
37
+
38
+ Language policy: your explanatory prose and final reports follow the user's conversation language. Node titles, Node summaries, and user-facing draft explanations follow `NodeContext.generation_policy.language` when the CLI provides it. Source-bound compile draft `content` should stay close to the cited source language when it differs from the workspace language; do not translate cited English facts into Chinese just to match the workspace. Section `summary` is a compact reader/query aid derived from `content` and may follow either the workspace language or the source-bound `content` language; do not patch it merely to switch languages. source_support hard-term matching checks `content`, not `summary`. For `example` Sections that cite a code/config/command fence, keep `content` centered on the cited fenced block and put framing prose in `summary`; split prose into a separate action only when it cites its own evidence. Preserve product names, code identifiers, CLI flags, slugs, `block_id` / `source_ref` tokens, and exact quoted evidence as printed. CLI stdout/stderr, the canonical `processing <slug>` lines, paths, slugs, block ids, source refs, issue codes, flags, and command names stay as printed.
37
39
 
38
40
  Stable prompt/output policy: keep fixed protocol, schema, mount matrix, and workspace lookup context before per-Node payloads. For repeated Nodes, use the same command order and consume CLI JSON as-is. Do not add current timestamps, random ids, storage paths, or host absolute paths to draft payloads or reports unless the CLI explicitly returned them as semantic workspace facts.
39
41
 
40
- Preflight:
42
+ ## Preflight
41
43
 
42
44
  1. Run `context doctor`; output-align group must be green. If it reports missing aligned knowledge, tell the user to run `/context:align` and stop. Incremental cache group warnings are informational here; only output-align errors block compile.
43
45
  2. Run `context mdrive workspace stats --format json`, `context source list --format json`, and `context status --format json`; record the before counts and `STATUS.semantic.refreshed_source_pending_compile.source_ids[]`. This status means newer raw snapshots exist; it does not mean finalized ownership or `node.sources[]` are already refreshed.
44
- 3. Run `context compile --scan-changes --format json` and parse the JSON as `COMPILE_WORKSET`. If delegated workflow mode is explicitly authorized, run `context compile --scan-changes --delegated --format json` for this first scan instead. `--scan-changes` is the only workset scan flag; `--plan` is reserved for draft validation.
45
- - If `context workflow status --format json` has `current: null` but `last_published` is present, continue with `context compile --scan-changes`; the published finalized ownership is still the workspace structure truth. Use `context workflow list --format json` only when you need lineage/history diagnostics.
46
+ 3. Run `context compile scan --format json` and parse the JSON as `COMPILE_WORKSET`. If delegated workflow mode is explicitly authorized, run `context compile scan --delegated --format json` for this first scan instead. `context compile scan` is the only workset scan entrypoint; `/context:compile --plan` controls whether the workflow stops before writing.
47
+ - If `COMPILE_WORKSET.compile_route` is present, treat it as the current advisory route. It does not replace evidence inspection: for every Node that needs a draft, read that Node's source-refs view before writing content, then use `context compile cycle` as the default write path. Enter manual review only when cycle returns it.
48
+ - If `context workflow status --format json` has `current: null` but `last_published` is present, continue with `context compile scan`; the published finalized ownership is still the workspace structure truth. Use `context workflow list --format json` only when you need lineage/history diagnostics.
46
49
  - Compile JSON may include `source_finalize`; use it as lineage for the finalized ownership that produced the current Node set and citation ownership.
47
50
  - If `COMPILE_WORKSET.reason` is `no-changed-nodes` and there are no refreshed sources pending compile, report `no changed nodes`; stop before invoking the draft procedure, running any draft command, or running close.
48
51
  - If `COMPILE_WORKSET.status` is `unknown-input`, continue conservatively using the Nodes listed in `COMPILE_WORKSET.nodes`; keep the `unknown_inputs[]` reasons in the final report.
@@ -56,48 +59,48 @@ Semantic decision schema discovery: run `context schema semantic-decisions` for
56
59
 
57
60
  Do not use Python, Node.js, shell, or other ad-hoc scripts to preprocess, filter, summarize, or inspect ReconcileContext / review payloads. Do not use `ls`, `find`, `rg`, `cat`, or similar ad-hoc commands to inspect workspace storage or temporary workflow artifacts. Consume the structured output from `context reconcile prepare` and `context reconcile review` directly, and pass agent-authored draft/decision payloads through stdin rather than scratch files. Never extract `review.apply_document` manually; the CLI applies the ready review artifact stored under the current workflow scope.
58
61
 
59
- Refreshed-source loop:
62
+ ## Refreshed Source Loop
63
+
64
+ Skip this section unless `STATUS.semantic.refreshed_source_pending_compile.source_ids[]` is non-empty or `context compile scan` returns a refresh-related next action. This is a real recovery path, not the default compile path.
60
65
 
61
- 1. If `STATUS.semantic.refreshed_source_pending_compile.source_ids[]` is non-empty, process each source id before the per-Node draft loop. Compile context refreshes deterministic stale source ownership when possible; if the CLI reports `source-ownership-stale`, rerun `context align --scan` and finalize before compiling that source.
62
- 2. Run `context reconcile prepare --mode refresh --source <source-id> --format json`. Feed stdout to packaged `context:skill-semantic-reconcile`; the output includes `workflow_payload.digest` for review. Do not reconstruct the semantic decision shape from memory.
63
- - The prepare output omits refresh sections whose evidence block hash is unchanged. If it returns a single `status: "unchanged"` / `change_status: "unchanged"` item, report that no semantic refresh decisions are needed for that source and continue with the filtered compile workset.
64
- 3. Pass the skill output to `context reconcile review --decisions - --view status`. Use stdout for readiness/issues/questions; apply reads the ready review artifact from the workflow scope. Resolve questions exactly like the per-Node loop, including `support_confirmation`, `scope_review_required`, and `omit_confirmation` handling.
65
- 4. Default mode only: run plain `context reconcile apply` after `context reconcile review` returns `ready_to_apply: true`; the CLI loads the unique ready review for the current workflow scope. If questions were answered, rerun review on the updated decisions to refresh the ready artifact, then run `context reconcile apply` again. In `--plan` mode, stop after review and report the not-written refresh decisions.
66
- 5. After all refreshed sources are applied in default mode, run `context compile --scan-changes --format json --ignore-source <source-id>` with one `--ignore-source` flag for each refresh-applied source. Use that filtered result for the per-Node loop. This does not rebuild section fingerprints early; it only removes Nodes whose remaining changed blocks came entirely from sources already handled by refresh reconciliation. If a Node still has changed blocks from other sources, unknown inputs, or full-context reasons, keep it in the ordinary per-Node loop.
66
+ For each refreshed source id, run `context reconcile prepare --mode refresh --source <source-id> --format json`, pass the payload to packaged `context:skill-semantic-reconcile`, review with `context reconcile review --decisions - --view status`, then apply with plain `context reconcile apply` when ready. If the prepare output says the source is unchanged, report no refresh decisions and continue. After applying refreshed sources in default mode, rerun `context compile scan --format json --ignore-source <source-id>` for each refresh-applied source and use that filtered workset for the per-Node loop.
67
67
 
68
- Per-Node loop:
68
+ ## Per-Node Loop
69
69
 
70
70
  Process Nodes sequentially. `/context:compile` may cover a multi-Node workset, but each Node must finish its own `context → draft → prepare → review → apply` loop before you apply another Node. Do not run multiple Node draft/reconcile/apply chains in parallel or bury several Node failures inside one shell batch. Capture/align can be broad; compile write decisions must be per-Node and complete.
71
71
 
72
- 1. For every workset Node, run `context compile --context <slug> --format json`. If the refreshed-source loop applied any source, append the same `--ignore-source <source-id>` flags used for the filtered workset. The JSON stdout is a compact summary with workflow payload handles; do not extract digests by hand. First inspect citation handles with `context compile --context <slug> --view source-refs --token-budget 2000 --format json` or `context workflow show --payload node-context --view source-refs --token-budget 2000 --unwrap --format json`; this source-refs view is only a projection of `NodeContext.raw_snippets[]`, not a separate data source. If it returns `truncated: true`, follow `how_to_explore[]` to narrow by `--source` / `--heading` or expand the budget. Only expand the durable NodeContext when you are ready to pass its returned `.value` object to the draft skill. NodeContext is derived only from finalized ownership: `primary_evidence` and citation-eligible `shared_evidence` may be cited; `context_only` and every secondary shared snippet are background only and must not be cited. If NodeContext includes `generation_policy`, apply it to generated titles, summaries, and user-facing explanations; for source-bound draft `content`, prefer the cited source language when it differs. Do not default Node titles/summaries to English scaffolding such as "How-To", "Strategy", or "Architecture" when the workspace language is not English. `context compile --context <slug> --request-full-text <block_id> --format json` may expose visible evidence text for inspection, including primary evidence; read expanded page text from `request_full_text.pages[].text`. Long blocks are returned as line-bounded pages with `request_full_text.pages[].next_command`; follow that command to continue reading the same block. `raw_snippets[].quote` mirrors the same page text beside source_ref metadata, but `request_full_text.pages[]` is the explicit page API. Do not use file tools to bypass the page. Full-text inspection does not promote secondary shared evidence into citation eligibility; if the block should support this Node, emit `pending_ownership_challenge` or `structure_challenge` instead of writing a Section. When the workset requires full context, the NodeContext payload has `incremental.status: "full-context"` with the `unknown_inputs[]` reasons from the same entrypoint. `incremental.locator_only_changes[]` entries with `agent_action: "none"` are close-time maintenance only; do not draft them. The CLI stores the durable NodeContext and coverage candidates as workflow payloads, not root scratch files. Do not expand the context with direct file tools; the NodeContext payload is the evidence boundary. Prefer citation-eligible refs for citeable evidence and treat `context_only` as background. Do not repeatedly slice saved NodeContext JSON manually; use source-refs, coverage-summary, coverage detail filters, and returned `how_to_explore[]`.
73
- 2. Invoke packaged `context:skill-compile-draft` and follow its procedure to emit draft JSON. Do not reconstruct the draft shape or Section classification rules from memory; the draft skill carries the canonical kind priority, mount matrix, examples, and reflection gates. Section writes use `content` plus optional `summary`; new Sections do not need `section_id`, and the op is exactly `op: "add"` because compile-draft `actions[]` already targets Sections. Do not use align-style op names such as `add_section` or `propose_section`. Cite raw via `source_refs: [...]` chosen from `raw_snippets[].source_ref`; use a single-element array for one citation, and use multiple refs only when the Section content actually consumes all of them. The CLI may auto-narrow over-wide citations and leaves removed refs uncovered. The CLI rejects retired `body` / `detail` / `raw`, singular `source_ref`, and quoted-evidence fields with canonical repair hints. If a note or changed raw snippet should be reviewed but intentionally not written, emit `op: "skip"` with the relevant `source_refs: [...]`; a bare skip is only for deterministic no-op cases. If a NodeContext contains only navigation or placeholder evidence (`Parent` / `Children` / `Related` / `Relations`, "no detailed content", etc.), emit `skip`; do not create a low-value `description` Section from that navigation line just to satisfy the workflow.
74
- 3. Fast path: pass the draft to `context compile --node-cycle <slug> --input - --accept-safe-defaults --format json`. This validates the draft, prepares reconcile, reviews mechanically safe defaults, and applies only when no semantic judgment remains. If stdout returns `status: "applied"`, continue to the next Node. If it returns `status: "partial-applied"` or `status: "review-required"`, use the returned `prepare` / `review` handles and continue with the manual path below for only the remaining questions/issues; do not rerun the earlier context/source-ref reads. When you need to patch a remaining action after prepare, run `context compile --draft-status <slug> --format json`; each action backed by the latest prepare payload includes `reconcile_item_id` and `source_support`, so use that claim id instead of guessing.
75
- 4. Manual path: pass the draft to `context compile --draft <slug> --input - --plan --prepare --format json`. This validates schema, source refs, and mount matrix, stores the compile draft as a workflow payload, and prepares the semantic reconcile payload without writing active knowledge. Default stdout is a compact prepare summary; use it to inspect readiness. If semantic judgment is needed, load the full prepare payload with `context workflow show --payload prepare --unwrap --format json` and feed that full payload to packaged `context:skill-compile-judge`. The judge output is the decision input for `context reconcile review`; keep `skill-semantic-reconcile` for refresh/drop or non-compile reconcile flows. For triage-only inspection, use `context workflow show --payload prepare --view issues --unwrap --format json`; add `--status unsupported`, `--status weak`, `--item-id <claim-id>`, or `--page-size <n>` instead of expanding huge prepare payloads. If all pending items are mechanically safe defaults, prefer `context reconcile review --accept-safe-defaults --view status` instead of invoking the skill. If most items are safe and only a few need explicit decisions, combine `--accept-safe-defaults` with `--decisions -` and submit only those explicit decisions. If the CLI returns draft revision hints, use `context compile --draft-status <slug> --format json` and `context compile --draft-patch <slug> --input - --plan` so only the affected action is revised; draft-status includes the action `reconcile_item_id` after prepare, plus `source_support`, so `act_005` and `claim-005` stay mechanically linked. Draft-patch `schema_version` may be omitted, or use `patch_schema_version` from draft-status if you include it. Then rerun `context compile --draft <slug> --plan --prepare --format json` with no `--input`; it reloads the saved patched draft. On hard rejection after a draft session is saved, read `context compile --draft-status <slug> --format json`, patch only the failed actions, and retry.
76
- 5. Review the prepared context before accepting defaults. Treat lexical `source_support` as a diagnostic; final support and relation judgment belong to `context:skill-compile-judge`, which must compare only listed candidates and include the same-source-ref multi-kind semantic-role check. Do not copy raw text merely to raise matched-term counts; there is no separate default `evidence-echo` warning, and preserved prose/bullets are valid only when they are active user-facing knowledge. Treat `temporal_prior` and candidate `temporal_disposition` as context for your rationale only; they do not change `default_decision` or make merge/supersede mechanically safe. If the prepare output has `items: []`, use its `next_decisions_template` as the decisions document for review; do not pass the whole prepare context as `--decisions`.
77
- - If `agent_hints[]` contains `compact-source-low-coverage` or `dense-source-low-coverage`, return to the same compile draft and add actions for the suggested uncovered evidence before semantic review. Treat the reported coverage count (`covered/total`, remaining snippets) as a required self-check, not polish. A supported first quote only proves that one action is valid; it does not prove the Node is complete.
78
- - If close later reports unresolved coverage, first inspect `context workflow show --payload coverage-candidates --view coverage-summary --token-budget 2000 --unwrap --format json`. Use `available_actions[]` and, when needed, narrow with `context workflow show --payload coverage-candidates --view coverage --type <issue-type> --token-budget 2000 --unwrap --format json` or `--node <slug>`. Then use `context compile --context <slug> --cover-uncovered-only --format json` to start a targeted repair draft, or `context compile --coverage-skip-unresolved --coverage-disposition-node <slug> --reason "<reason>"` only when all unresolved candidates for that node are intentionally excluded for the same reason. Use targeted `coverage-disposition` only when candidates need different outcomes.
79
- 6. Pass the judge skill output to `context reconcile review --decisions - --view status`. Use stdout for compact readiness/issues/questions. If questions are returned, ask the user in business language and convert unresolved `ask_user` items into final actions before applying. For `support_confirmation`, use `question.group_key` when present: group only questions that share that key and are all ordinary content-compression checks; ask once with a compact list of claims and cited evidence. If the user confirms the group, keep each final write action and add `decided_by: user`. Do not group questions that add new facts, have missing hard facts, or have different source/evidence boundaries. If review reports unsupported evidence, revise the draft or rerun the judge with corrected source_refs rather than forcing a decision. For `scope_review_required`, run `context:skill-semantic-reconcile` once more over the prepare context and current decisions before asking the user; if it still cannot resolve the scope, ask the user. For `omit_confirmation`, ask the user; only a confirmed no-write answer may become `action: omit` with `decided_by: user`. Never mark `decided_by: user` on your own; auto mode or permission to continue is not user confirmation.
80
- 7. Default mode only: run plain `context reconcile apply` after `context reconcile review --view status` returns `ready_to_apply: true`; the CLI applies the unique ready review for the current workflow scope. If questions were answered, rerun review on the updated decisions, then run `context reconcile apply` again. This writes active knowledge, verifies, and records the semantic ledger. In `--plan` mode, stop after review and report the not-written decisions.
81
- 8. Persistent failure stop and surface the full rejection list; never edit rendered files to bypass.
72
+ 1. Prepare evidence for every workset Node.
73
+ - **1a. Get NodeContext.** Run `context compile context <slug> --format json`. If the refreshed-source loop applied any source, append the same `--ignore-source <source-id>` flags used for the filtered workset. The JSON stdout is a compact summary with workflow payload handles; do not extract digests by hand. Only expand the durable NodeContext when you are ready to pass its returned `.value` object to the draft skill.
74
+ - **1b. Inspect citation refs.** First inspect citation handles with `context compile context <slug> --view source-refs --token-budget 2000 --format json` or `context workflow show --payload node-context --view source-refs --token-budget 2000 --unwrap --format json`; this source-refs view is only a projection of `NodeContext.raw_snippets[]`, not a separate data source. Planned Section rows may include `quote_full_text` for example code fences and long paragraph/table evidence already counted in the view budget; use it directly instead of doing a second full-text request for the same row. If the view returns `page.next_token` or `next_command`, follow `next_command` to continue the same source-refs view. If it returns `truncated: true`, follow `how_to_explore[]` to narrow by `--source` / `--heading` or expand the budget.
75
+ - **1c. Request full text only when needed.** `context compile context <slug> --request-full-text <block_id> --view text --format json` exposes visible evidence text through the narrow text view; read expanded page text from `items[].text`. Long blocks are returned as line-bounded pages with `items[].next_command`; follow that command to continue reading the same block. `request_full_text.pages[].text` and `raw_snippets[].quote` may appear in full NodeContext outputs as mirrors, but the agent-facing expansion path is `--view text`. Do not use file tools to bypass the page.
76
+ - **1d. Respect evidence boundaries.** NodeContext is derived only from finalized ownership: `primary_evidence` and citation-eligible `shared_evidence` may be cited; `context_only` and every secondary shared snippet are background only and must not be cited. Full-text inspection does not promote secondary shared evidence into citation eligibility; if the block should support this Node, emit `pending_ownership_challenge` or `structure_challenge` instead of writing a Section. If NodeContext includes `generation_policy`, apply it to generated titles, summaries, and user-facing explanations; for source-bound draft `content`, prefer the cited source language when it differs. Do not default Node titles/summaries to English scaffolding such as "How-To", "Strategy", or "Architecture" when the workspace language is not English.
77
+ - **1e. Use workflow views instead of files.** When the workset requires full context, the NodeContext payload has `incremental.status: "full-context"` with the `unknown_inputs[]` reasons from the same entrypoint. `incremental.locator_only_changes[]` entries with `agent_action: "none"` are close-time maintenance only; do not draft them. The CLI stores the durable NodeContext and coverage candidates as workflow payloads, not root scratch files. Do not expand the context with direct file tools; the NodeContext payload is the evidence boundary. Prefer citation-eligible refs for citeable evidence and treat `context_only` as background. Do not repeatedly slice saved NodeContext JSON manually; use source-refs, coverage-summary, coverage detail filters, and returned `how_to_explore[]`.
78
+ 2. Invoke packaged `context:skill-compile-draft` and follow its procedure to emit draft JSON. Do not reconstruct the draft shape or Section classification rules from memory; the draft skill carries the canonical kind priority, mount matrix, examples, and reflection gates. Section writes use `content` plus optional `summary`; new Sections do not need `section_id`, and the op is exactly `op: "add"` because compile-draft `actions[]` already targets Sections. Do not use align-style op names such as `add_section` or `propose_section`. Cite raw via `source_refs: [...]` chosen from `raw_snippets[].source_ref`; use a single-element array for one citation, and use multiple refs only when the Section content actually consumes all of them. The CLI may report over-wide citation narrowing; `removed_lead_in_source_refs` are framing/navigation refs to keep unless you verify they add no meaning, while `removed_redundant_source_refs` are cleanup candidates. The CLI rejects retired `body` / `detail` / `raw`, singular `source_ref`, and quoted-evidence fields with canonical repair hints. If a note or changed raw snippet should be reviewed but intentionally not written, emit `op: "skip"` with the relevant `source_refs: [...]`; a bare skip is only for deterministic no-op cases. If a NodeContext contains only navigation or placeholder evidence (`Parent` / `Children` / `Related` / `Relations`, "no detailed content", etc.), emit `skip`; do not create a low-value `description` Section from that navigation line just to satisfy the workflow.
79
+ 3. Fast path: pass the draft to `context compile cycle <slug> --input - --accept-safe-defaults --format json`. This validates the draft, prepares reconcile, reviews mechanically safe defaults, and applies only when no semantic judgment remains. If stdout returns `status: "applied"`, continue to the next Node. If it returns `status: "partial-applied"` or `status: "review-required"`, use the returned `prepare` / `review` handles and continue with the manual path below for only the remaining questions/issues; do not rerun the earlier context/source-ref reads. When you need to patch a remaining action after prepare, run `context compile draft-status <slug> --format json`; each action backed by the latest prepare payload includes `reconcile_item_id` and `source_support`, so use that claim id instead of guessing. To patch and continue in one call, pass a compile draft-patch payload to the same node-cycle command; use `op: "replace_action"`, `action_id`, and `action`, not align-style `op/path/value`.
80
+ 4. Conditional manual path: enter this only when `cycle` returns `partial-applied`, `review-required`, a draft revision hint, or a coverage/source-support issue that cannot be resolved by a compile draft-patch. Use the returned `prepare` / `review` handles and CLI `agent_hints[]`; do not restart the Node from context reads. If semantic judgment is needed, load `context workflow show --payload prepare --unwrap --format json`, feed it to packaged `context:skill-compile-judge`, then pass the judge decisions to `context reconcile review --decisions - --view status`. Apply with plain `context reconcile apply` only when review says `ready_to_apply: true`. If questions are returned, ask the user in business language; never mark `decided_by: user` on your own.
81
+ 5. Coverage repair: if compile or close reports uncovered required evidence, first inspect `context workflow show --payload coverage-candidates --view coverage-summary --token-budget 2000 --unwrap --format json`, then narrow with `--view coverage` filters. Use `context compile context <slug> --cover-uncovered-only --format json` for targeted repair drafts. Use coverage skip/disposition only when the candidate is intentionally excluded and the CLI exposes that action.
82
+ 6. Persistent failure → stop and surface the full rejection list; never edit rendered files to bypass.
83
+
84
+ ## Close
82
85
 
83
- Close (default mode only — skip entirely in `--plan` mode):
86
+ Default mode only — skip entirely in `--plan` mode.
84
87
 
85
- 1. Invoke packaged `context:skill-compile-close`; it triggers `context compile --close`, which refreshes locator-only evidence, canonicalizes source refs, compacts derived knowledge files, verifies the final workspace, rebuilds section fingerprints, and refreshes the incremental cache.
88
+ 1. Invoke packaged `context:skill-compile-close`; it triggers `context compile close`, which refreshes locator-only evidence, canonicalizes source refs, compacts derived knowledge files, verifies the final workspace, rebuilds section fingerprints, and refreshes the incremental cache.
86
89
  2. Run `context verify` as a second pass if the skill escalated any issue. Run `context mdrive workspace stats --format json` and `context source list --format json` and diff against the before counts.
87
90
  3. Run `context mdrive node list --format json` to collect semantic node handles for the final report. Use `node_class` to keep concrete entities, term definitions, domains, and actions visibly separated. If the user explicitly asks for file links, use an explicit human/report view when available; those links are user inspection aids, not workflow inputs.
88
91
 
89
- `context compile --close` may archive explicit debug scratch files through the CLI-owned output lifecycle. Normal compile state lives in workflow-scoped payloads. Current align state is internal CLI state, not a file protocol. Do not move, delete, or archive workspace output files yourself; the CLI owns that lifecycle.
92
+ `context compile close` may archive explicit debug scratch files through the CLI-owned output lifecycle. Normal compile state lives in workflow-scoped payloads. Current align state is internal CLI state, not a file protocol. Do not move, delete, or archive workspace output files yourself; the CLI owns that lifecycle.
90
93
 
91
94
  Close only projects finalized Nodes that materialize as a CLI-written knowledge article or as an explicit no-write placeholder declared by align with `planned_sections: []`. A compile skip action records reviewed no-write evidence, but it does not by itself turn an arbitrary finalized Node into a placeholder.
92
95
 
93
- In plan mode, your final report is the aggregated user-facing change list across all Nodes + "re-run `/context:compile` without `--plan` to apply"; do not run `context compile --close` or `context verify` (they only make sense against a real write).
96
+ In plan mode, your final report is the aggregated user-facing change list across all Nodes + "re-run `/context:compile` without `--plan` to apply"; do not run `context compile close` or `context verify` (they only make sense against a real write).
94
97
 
95
- Never claim success unless `context compile --close` exited 0 and `context verify` is green. The only exception is the `no-changed-nodes` gate, where you report that compile stopped before draft and no files were written. Never hand-write rendered knowledge, index, or changelog files — the CLI is the sole writer.
98
+ Never claim success unless `context compile close` exited 0 and `context verify` is green. The only exception is the `no-changed-nodes` gate, where you report that compile stopped before draft and no files were written. Never hand-write rendered knowledge, index, or changelog files — the CLI is the sole writer.
96
99
  Never use Read / Glob / Grep / Write against workspace storage; use `context workflow`, `context compile`, `context reconcile`, `context source`, `context query`, and `context mdrive`.
97
100
  For large draft payloads, feed stdin directly into the `context compile` command with a heredoc. Do not pipe a heredoc through another command and do not redirect generated content into workspace files. Do not pipe `context ... --format json` through `python3`, `node`, `jq`, `sed`, `cat`, `2>&1`, or shell fallback wrappers. For draft schema discovery, run `context schema compile-draft` for readable YAML or `context schema compile-draft --format json` for machine-readable JSON:
98
101
 
99
102
  ```bash
100
- context compile --draft billing-api --input - --plan --prepare --format json <<'JSON'
103
+ context compile draft billing-api --input - --prepare --format json <<'JSON'
101
104
  {
102
105
  "schema_version": "compile.draft.v2",
103
106
  "target_node": "billing-api",
@@ -116,7 +119,7 @@ JSON
116
119
  For reviewed no-write material, keep the evidence in the skip action so semantic review can record it:
117
120
 
118
121
  ```bash
119
- context compile --draft billing-api --input - --plan --prepare --format json <<'JSON'
122
+ context compile draft billing-api --input - --prepare --format json <<'JSON'
120
123
  {
121
124
  "schema_version": "compile.draft.v2",
122
125
  "target_node": "billing-api",
@@ -134,7 +137,7 @@ JSON
134
137
  For navigation-only or placeholder-only context, no active Section is the correct result:
135
138
 
136
139
  ```bash
137
- context compile --draft billing-api --input - --plan --prepare --format json <<'JSON'
140
+ context compile draft billing-api --input - --prepare --format json <<'JSON'
138
141
  {
139
142
  "schema_version": "compile.draft.v2",
140
143
  "target_node": "billing-api",
@@ -148,19 +151,19 @@ context compile --draft billing-api --input - --plan --prepare --format json <<'
148
151
  JSON
149
152
  ```
150
153
 
151
- Final report contract (default mode):
154
+ ## Final Report Contract
152
155
 
153
156
  - Report in the user's conversation language.
154
157
  - Keep a stable structure with these semantic sections; translate section headings into the user's conversation language instead of copying these English labels verbatim:
155
158
  1. Completion headline.
156
159
  2. Semantic apply table. Include refreshed-source rows first in source-id order when the refreshed-source loop ran, then one row per Node in align frontmatter order. Columns: target (source id or Node title/slug), type (`refresh` or Node type), and the `context reconcile apply --format json` counts: `applied`, `skipped`, `merged`, `superseded`, `kept_separate`, `omitted`, and `questions_resolved`. Include `reanchored`, `removed_unsupported`, and `split_then_reanchored` only when non-zero.
157
- 3. Close stage with `context compile --close` result, final node/section totals, verify status, changelog stamp, incremental counts (`recompiled`, `locator_updates`, `canonical_source_ref_updates`, `rebuilt`), section fingerprint rebuild count, and archive status / archived file count when reported by CLI. Do not use close output as the semantic apply summary; aggregate the per-Node `context reconcile apply` results from Step 6.
160
+ 3. Close stage with `context compile close` result, final node/section totals, verify status, changelog stamp, incremental counts (`recompiled`, `locator_updates`, `canonical_source_ref_updates`, `rebuilt`), section fingerprint rebuild count, and archive status / archived file count when reported by CLI. Do not use close output as the semantic apply summary; aggregate the per-Node `context reconcile apply` results from Step 6.
158
161
  4. Before/after status diff table with at least total nodes, node counts by type, total sections, and last compile time.
159
162
  5. Knowledge objects by semantic handle. Include every Node slug and `node_class` returned by `context mdrive node list --format json`; group or label term definitions separately from concrete entities when useful. Include human-readable links only when an explicit human/report view returns them, and state that they are not workflow inputs.
160
163
  6. Optional next step only when there is a concrete useful follow-up (for example recapture stale material or run `/context:align` to revise structure).
161
164
  - Do not say the user can inspect files without providing links.
162
165
 
163
- Final report contract (`--plan` mode):
166
+ ## Plan Mode Final Report Contract
164
167
 
165
168
  - Use the same stable shape where possible, but make the headline clearly indicate that this was a plan-only run.
166
169
  - Replace the close-stage section with a not-written section and tell the user to re-run `/context:compile` without `--plan` to apply.
@@ -4,7 +4,7 @@ argument-hint: "<free text | url | source-id | question>"
4
4
  allowed-tools: Bash(context:*)
5
5
  ---
6
6
 
7
- ## Your task
7
+ ## Your Task
8
8
 
9
9
  Inspect `$ARGUMENTS` and delegate to the most appropriate subcommand. Route without running anything of your own first — let the target subcommand drive.
10
10
 
@@ -4,7 +4,7 @@ argument-hint: "<source-id|url> [--reason <text>] [--yes]"
4
4
  allowed-tools: Bash(context:*)
5
5
  ---
6
6
 
7
- ## Your task
7
+ ## Your Task
8
8
 
9
9
  Retract a source without losing the audit trail. The CLI owns source resolution, impact planning, semantic decision application, knowledge cleanup, source stamp, changelog append, and verify; the agent presents the impact plan and waits for confirmation.
10
10
 
@@ -23,3 +23,16 @@ Language policy: any prose you speak directly to the user follows the user's con
23
23
  Never Read / Glob / Grep / Write workspace files directly. All workspace access goes through semantic CLI commands such as `context drop --plan`, `context reconcile prepare --mode drop`, `context reconcile review`, `context drop --apply-plan`, and `context source`. If you need the semantic decision shape, run `context schema semantic-decisions` for JSON or `context schema semantic-decisions --format yaml` for readable YAML; do not infer it from memory.
24
24
  Never use Python, Node.js, shell scripts, `ls`, `find`, `rg`, `cat`, or similar ad-hoc commands to inspect or preprocess workspace storage or temporary workflow artifacts. Consume CLI JSON/YAML/text outputs directly. Do not pipe `context ... --format json` through `python3`, `node`, `jq`, `sed`, `cat`, `2>&1`, or shell fallback wrappers.
25
25
  Plan handoff is workflow-scoped. Run `context drop --plan <target> --format json`; the CLI stores the drop-plan payload in the current workflow. `--save-output` is only for an explicit human-readable scratch copy and must not be passed to later steps.
26
+
27
+ ## Final Report
28
+
29
+ Report in the user's conversation language. Translate section headings into the user's language instead of copying the English labels below verbatim. Optimize for human readability: name the dropped source by its title, use Node titles instead of slugs, and use Section kind plus heading for each archived Section. Do not surface source ids, content hashes, archive directory paths, semantic ledger ids, or workflow payload identifiers.
30
+
31
+ Stable structure:
32
+
33
+ 1. Completion headline. Single line naming the dropped source by title plus verify status (for example "「<source title>」 dropped, verify ok"). Capture data from `context drop --apply-plan --format json`.
34
+ 2. Affected Node tree. Group archived Sections by their owning Node. Each Node entry shows the Node title and Node type; below it list the archived Sections with their kind plus a short heading/preview that identifies which Section was archived (not the section id). Include Nodes whose alias mappings or visibility changed even when no Section was archived. Omit the tree entirely when the plan was a no-op or alias-reindex-only.
35
+ 3. Variance summary. Bullet list of counts: archived Sections, affected Nodes, semantic decisions applied, and the final verify status. Show every counter so the user can verify nothing unexpected fired, including zeros.
36
+ 4. Next step. Single command suggestion: `/context:status` to inspect the current knowledge distribution, or `/context:purge` when the user wants to permanently clear the archived snapshots.
37
+
38
+ Do not include raw drop-plan digests, archive directory paths, or workflow payload identifiers in the report. Those belong in earlier troubleshooting output, not in the completion summary.
@@ -4,7 +4,7 @@ argument-hint: "<path> [--format json|jsonl|pretty]"
4
4
  allowed-tools: Bash(context:*)
5
5
  ---
6
6
 
7
- ## Your task
7
+ ## Your Task
8
8
 
9
9
  Run `context extract $ARGUMENTS` and stream the CLI's stdout back to the user.
10
10
 
@@ -10,7 +10,7 @@ UX before `context init` runs) lives inline here per the slash-command
10
10
  length exemption for self-contained slash commands.
11
11
  -->
12
12
 
13
- ## Your task
13
+ ## Your Task
14
14
 
15
15
  Initialize a context workspace, including layout, default-language, and focus confirmation before creating it.
16
16
 
@@ -4,7 +4,7 @@ argument-hint: "[--yes]"
4
4
  allowed-tools: Bash(context:*)
5
5
  ---
6
6
 
7
- ## Your task
7
+ ## Your Task
8
8
 
9
9
  Purge the workspace archive. This is destructive: it deletes all restorable
10
10
  source/knowledge artifacts created by `context drop --apply-plan`.
@@ -4,7 +4,7 @@ argument-hint: "<question>"
4
4
  allowed-tools: Bash(context:*)
5
5
  ---
6
6
 
7
- ## Your task
7
+ ## Your Task
8
8
 
9
9
  Naming convention:
10
10