@c4a/context-cli 0.5.29-beta.18 → 0.5.29-beta.21

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 (26) hide show
  1. package/README.md +7 -5
  2. package/cli.js +3995 -2165
  3. package/package.json +1 -1
  4. package/plugin/README.md +4 -3
  5. package/plugin/README_CN.md +4 -3
  6. package/plugin/commands/align.md +28 -4
  7. package/plugin/commands/capture.md +5 -3
  8. package/plugin/commands/compile.md +27 -14
  9. package/plugin/commands/query.md +1 -0
  10. package/plugin/skills/skill-align-workflow/SKILL.md +32 -10
  11. package/plugin/skills/skill-align-workflow/references/gates.md +81 -41
  12. package/plugin/skills/skill-compile-close/SKILL.md +4 -1
  13. package/plugin/skills/skill-compile-draft/SKILL.md +108 -279
  14. package/plugin/skills/skill-compile-draft/references/action-domain-gates.md +34 -0
  15. package/plugin/skills/skill-compile-draft/references/notes.md +34 -0
  16. package/plugin/skills/skill-compile-draft/references/refresh-and-update.md +71 -0
  17. package/plugin/skills/skill-compile-draft/references/structural-challenges.md +76 -0
  18. package/plugin/skills/skill-compile-judge/SKILL.md +1 -1
  19. package/plugin/skills/skill-context-query/SKILL.md +141 -94
  20. package/plugin/skills/skill-drop/SKILL.md +2 -3
  21. package/plugin/skills/skill-semantic-reconcile/SKILL.md +70 -185
  22. package/plugin/skills/skill-semantic-reconcile/references/leakage-and-ownership.md +31 -0
  23. package/plugin/skills/skill-semantic-reconcile/references/mode-semantics.md +41 -0
  24. package/plugin/skills/skill-semantic-reconcile/references/scope-review-and-omit.md +60 -0
  25. package/plugin/skills/skill-semantic-reconcile/references/temporal-and-evidence.md +66 -0
  26. package/plugin/skills/skill-semantic-reconcile/references/user-confirmation.md +71 -0
@@ -0,0 +1,34 @@
1
+ # Note snippets
2
+
3
+ Consult this reference when **any `raw_snippets[].source_type` is `"note"`**. Note snippets came from `context capture --note` and carry conversation material (revisions, decisions, brainstorms) rather than primary source documents.
4
+
5
+ ## TL;DR
6
+
7
+ Note snippets are **prioritization hints, not write authority**. `note_intent`, `anchored_to[]`, and `revision_kind` may suggest update / supersede / complement / skip, but they never authorize a write without semantic review.
8
+
9
+ ## How to route a note snippet
10
+
11
+ When a `raw_snippets[]` entry has `source_type: "note"`:
12
+
13
+ 1. **Compare against the anchor first.** If `anchored_to[]` names this Node or one of its Sections, treat that target as the candidate for `update` / `supersede` / `add` (as a complement) / `skip`. **Do not create a new Node** from the note title here — that is an align-time concern.
14
+
15
+ 2. **Use `note_intent` and `revision_kind` to bias the action**:
16
+
17
+ | `note_intent` | typical action |
18
+ |---|---|
19
+ | `revision` | `update` or `supersede` against the anchored Section |
20
+ | `decision` | `add` a `decision` Section when no equivalent exists; otherwise `update` |
21
+ | `brainstorm` | usually `skip` unless the brainstorm explicitly confirms a fact the Node should record |
22
+
23
+ `revision_kind` (`replace` / `clarify` / ...) refines the choice within `revision`.
24
+
25
+ 3. **No-write reviewed-no-write case.** If the note says "don't modify active knowledge yet" or the correct outcome is no-write after review, emit `skip` with `source_refs[]` containing the note's `raw_snippets[].source_ref`. This lets semantic review record `reviewed_no_write` instead of treating the skip as an unreviewed no-op.
26
+
27
+ 4. **Bare skip is not allowed for notes.** A bare `skip` (no `source_refs[]`) is only for deterministic no-op cases such as unchanged input or pure navigation. Notes always carry an anchor and an intent; the skip must cite the note's source_ref.
28
+
29
+ ## Where this lives in the main procedure
30
+
31
+ - **Step 2 — Classify**: run the note-first comparison **before** the generic kind priority chain. If the note resolves to `update` / `supersede` / `skip` (reviewed), record the action and move on; do not also process the same note through the generic chain.
32
+ - **Step 5 — Self-verify**: every note snippet was either consumed by an anchored action or carried into a `skip` with `source_refs[]`.
33
+
34
+ Notes never become structure_challenge or pending_ownership_challenge on their own. If a note describes a structural problem (missing Action, wrong parent, etc.), capture the underlying evidence in raw form and emit the challenge from that — see `references/structural-challenges.md`.
@@ -0,0 +1,71 @@
1
+ # Refresh and update
2
+
3
+ Consult this reference when **any** of the following holds:
4
+
5
+ - `existing.sections[]` is non-empty (Node already has active knowledge; this is a refresh, not a first compile).
6
+ - `incremental.status` is `unchanged` or `full-context` (non-default incremental signals).
7
+ - `incremental.locator_only_changes[]` is non-empty (locator-only deltas without content changes).
8
+
9
+ For first compile of a fresh Node with `incremental.status === "changed-only"`, skip this file.
10
+
11
+ ## Incremental status handling
12
+
13
+ | `incremental.status` | What to do |
14
+ |---|---|
15
+ | `changed-only` (default) | Normal path — main SKILL.md procedure applies as written. |
16
+ | `unchanged` | Emit exactly one `skip` action with a brief reason. Do not iterate snippets. |
17
+ | `full-context` | Draft from the full fallback. **Preserve `unknown_inputs[]` reasons** in any abort/retry explanation so the caller sees why the fallback was needed. |
18
+
19
+ The CLI may deterministically skip unchanged output or update locator-only evidence before writing. **Do not force rewrites to bypass fingerprint skip** — those skips are part of the protocol, not a problem to route around.
20
+
21
+ ## Locator-only changes
22
+
23
+ `incremental.locator_only_changes[]` entries always carry `agent_action: "none"` and `handled_by: "compile-close"`. **Do not emit a draft action for those Sections** unless the same Section also appears in `changed_blocks[]` with a real content change.
24
+
25
+ ## Reconciling with `existing.sections[]`
26
+
27
+ When `existing.sections[]` is non-empty, every `section-N` id you read here is a potential `update` / `supersede` / `deprecate` target. Walk the existing Sections in order and decide:
28
+
29
+ | Raw evidence vs existing Section | op |
30
+ |---|---|
31
+ | Raw still supports the existing claim unchanged | Emit nothing (or one summarising `skip`) |
32
+ | Raw clarifies or rephrases without changing meaning | `update` — same `section-N` stays active |
33
+ | Raw changes meaning (new spec value, reversed decision) | `supersede` — old flips to `deprecated`; new gets fresh `section-N+k` |
34
+ | Raw removes the supporting evidence | `deprecate` with `reason` |
35
+
36
+ ### `supersede` vs `update` semantics
37
+
38
+ `supersede` preserves the audit trail so readers see the prior policy — **critical for specs / decisions / principles**. Use `supersede` whenever the new statement *replaces* the old one's content; use `update` only for typo / wording fixes / detail additions that do not change meaning.
39
+
40
+ `deprecate` is for "old rule removed without replacement". It needs a `reason`.
41
+
42
+ ### `update` / `supersede.new` mechanics
43
+
44
+ - `update` keeps the same `section-N` id; provide new `content` (optional `summary`, optional new `source_refs[]`) but do not include `kind` unless the kind itself is changing.
45
+ - `supersede.new` is a fresh Section; it needs `kind`, `content`, `source_refs[]`, and may carry `summary`, `refers_to_nodes[]`, and `confidence` per the same rules as `add`.
46
+ - `deprecate` only needs `target_section_id` and `reason`. Do not pass `content` or `source_refs[]`.
47
+
48
+ ## Output schema (refresh ops)
49
+
50
+ ```jsonc
51
+ {
52
+ "actions": [
53
+ { "op": "update", "target_section_id": "section-3",
54
+ "content": "...",
55
+ "refers_to_nodes": null,
56
+ "source_refs": ["src-1#api L18-21@c0d4e5f61728"] },
57
+ { "op": "supersede", "target_section_id": "section-5",
58
+ "reason": "raw published a new retention value",
59
+ "new": { "kind": "spec", "content": "...",
60
+ "refers_to_nodes": ["..."],
61
+ "source_refs": ["src-1#limits L30-34@9d1e2f3a4b5c"] } },
62
+ { "op": "deprecate", "target_section_id": "section-2", "reason": "..." }
63
+ ]
64
+ }
65
+ ```
66
+
67
+ ## How this slots into the main procedure
68
+
69
+ - **Step 1 — Sanity-check**: when `existing.sections[]` is non-empty, read every `section-N` id and `status` (active vs deprecated) before classifying snippets. When `incremental.status` is `unchanged`, short-circuit with one `skip`.
70
+ - **Step 2 — Classify**: still walk the kind priority chain for each citation-eligible snippet; the reconciliation table above governs which `op` to emit for snippets that map to an existing Section.
71
+ - **Step 5 — Self-verify**: every `update` / `supersede` / `deprecate` targets a known `section-N` from `existing.sections[]`. If not, return here.
@@ -0,0 +1,76 @@
1
+ # Structural and ownership challenges
2
+
3
+ Consult this reference when the cited evidence **cannot be written as a Section under the current align structure**:
4
+
5
+ - The evidence describes a coherent process that should be its own `action` Node (not a Section here).
6
+ - The evidence implies a missing `depends_on` edge between Nodes.
7
+ - The evidence belongs under a different parent Node.
8
+ - A finalized shared-block split leaves this Node with only secondary, non-citable evidence.
9
+ - A visible `context_only` or secondary-shared block contains facts that need citation, requiring an ownership upgrade.
10
+
11
+ In these cases, do **not** force the content into a Section. Emit a challenge action instead; the CLI stores it as a workflow payload and compile-close exposes it as debt until an align resolution handles it.
12
+
13
+ ## When to challenge vs. when to skip
14
+
15
+ | Situation | Action |
16
+ |---|---|
17
+ | Evidence is a repeatable procedure with steps that clearly warrant a sub-Action | `structure_challenge` with `kind: missing_action_node` |
18
+ | Evidence depends on a Node that the current align graph does not link to this Node | `structure_challenge` with `kind: missing_depends_on_edge` |
19
+ | Evidence belongs under a different parent | `structure_challenge` with `kind: wrong_parent` |
20
+ | A finalized shared block split removed all primary evidence from this Node | `structure_challenge` with `kind: wrong_shared_block_split` |
21
+ | The Node should not exist (its evidence belongs elsewhere) | `structure_challenge` with `kind: extra_action_node` |
22
+ | A `context_only` or secondary-shared block holds facts this Node needs to cite | `pending_ownership_challenge` with `requested_role: "shared"` or `"owned"` |
23
+
24
+ Supported `structure_challenge.kind` values: `missing_action_node`, `extra_action_node`, `wrong_shared_block_split`, `missing_depends_on_edge`, `wrong_parent`.
25
+
26
+ `pending_ownership_challenge.requested_role` is `owned` (the Node should be sole author) or `shared` (the Node should join an existing owners list).
27
+
28
+ ## Required fields
29
+
30
+ ```jsonc
31
+ {
32
+ "op": "structure_challenge",
33
+ "challenge_id": "ch_0001",
34
+ "kind": "missing_action_node",
35
+ "node_slug": "<matches node.slug>",
36
+ "action_tag": "rollout-runbook",
37
+ "summary": "The cited evidence is a repeatable procedure.",
38
+ "source_ref": "src-1#ops L40-55@c0d4e5f61728",
39
+ "reason": "Align must review structure before compile writes process prose."
40
+ }
41
+ ```
42
+
43
+ ```jsonc
44
+ {
45
+ "op": "structure_challenge",
46
+ "challenge_id": "ch_0002",
47
+ "kind": "wrong_shared_block_split",
48
+ "node_slug": "<matches node.slug>",
49
+ "unresolved_target": "rollout-runbook",
50
+ "reason": "The finalized shared block split leaves this Node with only secondary, non-citable evidence."
51
+ }
52
+ ```
53
+
54
+ ```jsonc
55
+ {
56
+ "op": "pending_ownership_challenge",
57
+ "challenge_id": "och_0001",
58
+ "node_slug": "<matches node.slug>",
59
+ "block_id": "2f4b8c1e9a03",
60
+ "requested_role": "shared",
61
+ "reason": "A visible context_only or secondary shared block contains facts that need citation."
62
+ }
63
+ ```
64
+
65
+ Different `kind` values demand different sub-fields. The CLI returns `agent_hints[].correct_shape` on shape errors; follow that hint rather than guessing.
66
+
67
+ ## What these are NOT
68
+
69
+ - **Not a substitute for `skip`** when raw simply has no write-worthy fact for this Node.
70
+ - **Not a Section.** Challenges never appear in active knowledge; they only travel through workflow state.
71
+ - **Not a free upgrade path.** `request_full_text` may expose visible evidence text for inspection, but it does not change citation eligibility. If you need to cite secondary content, emit `pending_ownership_challenge` — do not paraphrase the secondary content into a Section.
72
+
73
+ ## How this slots into the main procedure
74
+
75
+ - **Step 3 — Build actions**: when evidence implies a missing Action, missing `depends_on`, wrong parent, or needed ownership upgrade, emit the corresponding challenge instead of writing a Section.
76
+ - **Step 5 — Self-verify**: no Section write cites a `context_only` or secondary-shared block; if any did, replace the Section with a `pending_ownership_challenge`.
@@ -101,6 +101,6 @@ candidate list is empty, emit `new` with an empty compared list and
101
101
  ### Step 4 — Emit Judge Decisions
102
102
 
103
103
  Return only the `compile.judge-decisions.v1` document. The caller passes it
104
- directly to `context reconcile review --prepare-digest <digest> --decisions -`.
104
+ directly to `context reconcile review --decisions -`.
105
105
 
106
106
  </procedures>
@@ -1,34 +1,30 @@
1
1
  ---
2
2
  name: skill-context-query
3
3
  description: >
4
- Packaged skill invoked by `/context:query`; not a user slash command. The agent uses
5
- `context query` hit/miss/select results first, supplements only with scoped
6
- query views when needed, and answers with Node slug, Section id,
7
- and compact node/section citations plus explicit gaps for unsupported claims.
4
+ Packaged skill invoked by `/context:query`; not a user slash command.
5
+ Uses structure-first strategy: inspect orientation, resolve unknown Nodes with node_lookup,
6
+ open known Nodes with node_view, then query Section details with section_search. Always
7
+ cite Node slug and Section id.
8
8
  Activates when `/context:query` is invoked or when an agent needs to
9
9
  answer a question using local Context workspace knowledge with citations.
10
10
  tools:
11
11
  - Bash
12
12
  ---
13
13
 
14
- # skill-context-query — answer from local knowledge with CLI citations
14
+ # skill-context-query — structure-first knowledge exploration with citations
15
15
 
16
- Answer a user question from the local Context workspace without reading
17
- workspace files directly. The CLI is the only source of local knowledge.
16
+ Answer user questions by exploring the local Context workspace structure first,
17
+ then retrieving specific content within that structure. The CLI is the only source
18
+ of local knowledge; never read workspace files directly.
18
19
 
19
20
  ## TL;DR — Non-negotiables
20
21
 
21
- - First evidence-bearing tool call should be the ordinary default query: `context query "$ARGUMENTS"`. One optional `context query --intent orientation` or empty `context query` call may run before it when this conversation has no usable workspace map; orientation is only for choosing a better query/scope and is never evidence for the answer.
22
- - Do not Read, Glob, Grep, or Write `raw/`, `knowledge/`, `archive/`, `decisions/`, or any workspace file to answer the question.
23
- - Use only `context query` output as evidence. If the CLI returns `miss` or fails, report that result instead of searching files yourself.
24
- - Every key conclusion must cite the returned `node` and `section` handles. Default query output intentionally omits source provenance; do not invent or parse source locators.
25
- - If returned entries do not support a conclusion, mark it as a gap. Do not turn missing local knowledge into a definite answer.
26
- - If the output asks for a narrower scope or shows multiple candidate slugs, choose one only when the user's wording makes it unambiguous; otherwise ask the user which `slug` to use.
27
- - If the output reports a broad, blocked, or truncated recall, follow that diagnostic: ask for a narrower Node, term, version, or scope; when entries are returned but truncated, answer from those entries and state the result is not exhaustive.
28
- - Do not use Python, Node.js, shell scripts, `ls`, `find`, `rg`, `cat`, or similar ad-hoc commands to inspect `WORKSPACE_DIR`, `.context`, or `/tmp` workflow artifacts.
29
- - If the question names a Node title, alias, or slug, state the actual Node slug used in the answer.
30
- - When the first query is insufficient, supplement only with scoped query views named in the Supplemental context section or anchors from entry `refers_to_nodes`.
31
- - Output language follows the user's conversation language. CLI flags, output column names, slugs, and Section ids stay as printed.
22
+ - **Structure first**: When problem is vague, don't do semantic search; inspect `orientation`, use `node_lookup` only to find a slug, and use `node_view` to open a known Node.
23
+ - **CLI only**: Use only `context query` output as evidence. Never Read/Glob/Grep/Write workspace files.
24
+ - **Route by intent**: Classify problem intent (vague / clear Node / relationship / detail) and choose the right command; see Query Route table below.
25
+ - **Orientation is navigation**: `context query --intent orientation` returns a budgeted `[Slug Map]` plus optional `[Summary]` hints for scope choice only; it is not direct answer evidence.
26
+ - **Cite structure**: Every conclusion cites `[node/slug]` or `[node/section]`. If evidence does not support a claim, mark as gap.
27
+ - **Handle diagnostics**: If CLI returns `select`, `miss`, `broad`, `raw-only`, or `truncated`, follow the hint: show user structure to choose from, ask for narrower scope, or suggest workflow.
32
28
 
33
29
  <reference>
34
30
 
@@ -46,25 +42,74 @@ returned row as a small evidence card.
46
42
  | `refers_to_nodes` | Optional supplemental anchors when present |
47
43
  | `slug` | Candidate handle when the output is asking you to choose a Node |
48
44
  | `message` | Miss, broad-query, blocked, or narrowing guidance |
45
+ | `visibility` / `visible:` footer | Completeness signal for `node_view`; when `complete=true` / `visible: complete`, the shown Node Sections are exhaustive and there is no pagination |
49
46
 
50
47
  Supplemental context can come from:
51
48
 
52
49
  ```text
53
- context query --intent node_search --scope <slug>
50
+ context query --intent node_view --scope <slug>
54
51
  context query --intent impact_analysis --scope <slug>
55
- context query --intent node_search --refers-to <slug>
52
+ context query --intent node_view --refers-to <slug>
53
+ context query --intent section_search --scope <slug> --query "<keywords>"
56
54
  ```
57
55
 
56
+ ## Query Route Decision Table
57
+
58
+ Choose the `context query` command based on problem intent. **Structure queries take priority.**
59
+
60
+ | Problem intent | Primary command | When to use |
61
+ |---|---|---|
62
+ | **Vague question, no Node named** User asks "what is X" / "what are the X types" | `context query --intent orientation` or `context query --intent node_lookup --query "<keyword>"` | User unsure which Node to focus on; show structure first |
63
+ | **Node explicitly named** User mentions a specific service/system | `context query --intent node_view --scope <slug>` | User wants to open a specific known Node |
64
+ | **Relationship / impact** User asks what depends on X / impact of changing X | `context query --intent impact_analysis --scope <slug>` | User asks about how a Node connects to others |
65
+ | **Detail within known scope** (only after Node chosen) User asks for specific feature/behavior within chosen Node | `context query --intent section_search --scope <slug> --query "<detail>"` | User wants specific detail within an already-chosen Node |
66
+ | **Very specific fact** (fallback, rarely needed) User asks for exact implementation location | `context query "$ARGUMENTS"` | Semantic fallback when structure queries don't suffice |
67
+ | **Archive / reconciliation** User asks "find duplicates" / "check coverage" | `context query --intent recall --profile <reconcile-dedupe\|reconcile-support\|reconcile-refresh> --query "..."` | Only when user explicitly asks for audit/reconciliation |
68
+
69
+ ## Orientation output and budget
70
+
71
+ `context query --intent orientation` is a navigation surface, not answer evidence.
72
+
73
+ - JSON output keeps full Node `summary` fields when present.
74
+ - Text output targets about 2000 tokens total. It prints `[Slug Map]` first, then `[Summary]`.
75
+ - `[Slug Map]` uses finalized structure relationships and is for choosing the next `--scope <slug>`. If the workspace is too large, deeper layers are folded first.
76
+ - `[Summary]` is truncated before the map. If output is still over budget, the command prints a continuation note. Drill down with scoped queries; there is no page-token pagination.
77
+ - Use `context query --intent node_view --scope <slug>` for a Node overview, or `context query --intent section_search --scope <slug> --query "<keywords>"` for details inside that Node.
78
+ - Use `context query --intent orientation --tag <tag>` or `context query --intent orientation --domain <slug>` to reduce the map before choosing a scope.
79
+ - When `slug` and `title` are equivalent after normalization (for example `payment-api` and `Payment API`), text output shows only the slug.
80
+
81
+ ## BM25 Search Strategy
82
+
83
+ When using `section_search`, `recall`, or `node_lookup`, the CLI uses BM25 (keyword-based, not embedding-based) for matching. BM25 requires explicit keyword coverage, so queries must be precise:
84
+
85
+ - **Mix bilingual keywords**: Include both Chinese and English terms when querying—e.g., `"<chinese-term> <english-equivalent>"`, `"<product-name> <alternate-name>"`
86
+ - **Include synonyms & aliases**: BM25 is keyword-literal, so if your query doesn't match Section content exactly, try related terms
87
+ - **Use specific terminology**: Add version numbers, API names, or domain-specific terms to narrow results
88
+ - **Scope to reduce noise**: Use `--scope <slug>` to focus on a single Node; broad queries may be blocked or produce low-quality matches
89
+
90
+ Query intents that use BM25:
91
+ - `context query --intent node_lookup --query "<short-keyword>"` — find candidate Nodes from slug, title, summary, aliases, and tags when direct slug/title/alias matching does not resolve the query
92
+ - `context query --intent section_search --scope <slug> --query "<keywords>"` — find Section details using keyword matching within a known Node
93
+ - `context query --intent recall --profile <profile> --query "<keywords>"` — archive audit and reconciliation queries using keyword matching
94
+
95
+ Do NOT use BM25 strategy for:
96
+ - `context query --intent node_view --scope <slug>` or `--node <slug>` — uses structure, not keywords
97
+ - `context query --intent orientation` — uses structure, not keywords
98
+ - `context query --intent impact_analysis` — uses structure, not keywords
99
+
58
100
  ## Answer citation shape
59
101
 
60
- Use compact citations next to each key claim:
102
+ Use compact citations keyed to evidence type:
61
103
 
62
104
  ```text
63
- <claim> [node / section]
105
+ Node identity/title: <claim> [slug]
106
+ Section claim: <claim> [node/section]
107
+ Relationship/edge: X → Y [relationship_type]
108
+ Multiple sources: <claim> [node/section, node/section]
64
109
  ```
65
110
 
66
111
  If multiple Sections support the same claim, cite the strongest one or two.
67
- Avoid citation-only dumps: summarize what the cited Section supports.
112
+ Summarize what each cited Section supports; do not list citations without explanation.
68
113
 
69
114
  ## Gap shape
70
115
 
@@ -82,103 +127,105 @@ the user's wording indicates newly captured material is not yet knowledge.
82
127
 
83
128
  <procedures>
84
129
 
85
- ## Step 1: Query
130
+ ## Step 1: Classify problem intent
86
131
 
87
- If `$ARGUMENTS` is empty or whitespace-only, ask the user for a question first;
88
- do not run the query.
132
+ Determine what the user is trying to learn. Choose the appropriate command from the Query Route table above.
89
133
 
90
- If the current conversation has no useful workspace map and the user's question
91
- is broad, ambiguous, or asks what can be queried, run one orientation pass before
92
- the first evidence query:
134
+ **Classification:**
93
135
 
94
- ```bash
95
- context query --intent orientation
96
- ```
136
+ - **Vague problem** — user unsure which Node to focus on
137
+ - Indicators: asks "what is X", "what are the X types", "how to understand X", or question without Node anchor
138
+ - Action: Run `context query --intent orientation` to show available Nodes and structure; then pick a Node or ask for narrower scope
139
+ - **Note**: `node_lookup` resolves unknown Node names; `node_view` opens known Node structure; orientation always works regardless of workspace content
97
140
 
98
- Empty `context query` returns the same orientation map.
141
+ - **Node explicitly named** user mentions a specific service/system/concept
142
+ - Indicators: user names a specific Node or system, "tell me about X", "show me X"
143
+ - Action: Run `context query --intent node_view --scope <slug>` to explore that Node
99
144
 
100
- Orientation returns directly queryable slug/title structure and one query
101
- template. Use it only to choose a scope or show the user what can be queried.
102
- Do not answer from orientation output. Do not cite orientation output.
145
+ - **Relationship / impact** user asks how Nodes relate or what breaks if X changes
146
+ - Indicators: "what depends on X", "impact of X", "relationship between X and Y"
147
+ - Action: Run `context query --intent impact_analysis --scope <slug>` to show dependencies/relationships
103
148
 
104
- If the user already asked a concrete question but this conversation has no
105
- workspace map, you may run `context query --intent orientation` (or empty `context query`) and the first
106
- ordinary `context query "$ARGUMENTS"` concurrently. Use the evidence
107
- query for the answer; use orientation only for scoped follow-up if the first
108
- query is insufficient.
149
+ - **Detail within known scope** — user already chose a Node, now asking for specific detail
150
+ - Indicators: (comes after Node is selected) user asks "how does X handle [feature]", "what features does X support"
151
+ - Action: Run `context query --intent section_search --scope <slug> --query "<detail-keywords>"` use BM25 keywords for precise matching
109
152
 
110
- Run the ordinary query first:
153
+ - **Archive / reconciliation** — user explicitly asks for dedup/audit/coverage
154
+ - Indicators: "find duplicates", "check source coverage"
155
+ - Action: Run `context query --intent recall --profile <reconcile-*> --query "..."`
156
+ - ❌ Never use for ordinary questions
111
157
 
112
- ```bash
113
- context query "$ARGUMENTS"
114
- ```
158
+ ## Step 2: Execute query & interpret response
115
159
 
116
- If the user explicitly asks for archive comparison, source cleanup audit, or
117
- semantic reconciliation candidates, use recall with the matching profile:
160
+ Run the command from Step 1. Read the CLI output carefully.
118
161
 
119
- - duplicate / near duplicate / dedupe → `--profile reconcile-dedupe`
120
- - support check / source support → `--profile reconcile-support`
121
- - refresh / stale source comparison → `--profile reconcile-refresh`
162
+ **Route based on response:**
122
163
 
123
- ```bash
124
- context query --intent recall --profile reconcile-dedupe --query "$ARGUMENTS"
125
- ```
164
+ - ❌ **Command fails** → Report error and stop
165
+ - **`miss`** (no knowledge found) Report no local knowledge and stop
166
+ - ⚠️ **`select`** (multiple candidate Nodes) → Show candidates to user; ask which Node to focus on
167
+ - Then: loop back to Step 1 with chosen Node scope
168
+ - ⚠️ **`broad` / `blocked` recall** → Ask user for narrower scope (specific Node, term, version)
169
+ - Then: loop back to Step 1
170
+ - ⚠️ **`raw-only` / `uncompiled`** → Say "raw source found but not yet in compiled knowledge"
171
+ - Only suggest `/context:align` + `/context:compile` if user wants it compiled
172
+ - ⚠️ **`truncated`** (entries cut off) → Mark answer as "non-exhaustive"
173
+ - Proceed to Step 3; ask for narrowing only if user needs complete inventory
174
+ - ✓ **`node_view` says `visible: complete` / `visibility.complete=true`** → Do not run `section_search` merely to check completeness; use `section_search` only when you need keyword narrowing or ranking inside the Node
175
+ - ✓ **Entries returned** → Proceed to Step 3
126
176
 
127
- Do not use recall archive profiles for ordinary questions.
177
+ ## Step 3: Compose answer from returned structure
128
178
 
129
- ## Step 2: Read and gate
179
+ Use only the returned Node/Section structure and content. Do not synthesize beyond what was returned.
130
180
 
131
- Read the command output before answering.
181
+ **Response structure:**
132
182
 
133
- - If the command fails, report the CLI failure and stop.
134
- - If the output says `miss` or no local knowledge matched, report no local knowledge hit and stop.
135
- - If the output shows candidate slugs instead of evidence rows, ask for a specific `slug`, unless the user's wording already identifies one candidate.
136
- - If the output reports broad or blocked recall, stop and ask for a narrower Node, term, version, or scope before treating missing candidates as evidence of absence.
137
- - If the output reports truncated recall, answer from the returned evidence when entries exist, mark coverage as non-exhaustive, and ask for narrowing only if the user needs a complete inventory.
138
- - Keep a working set of returned rows with `node`, `section`, `kind`, `content`, and non-empty `refers_to_nodes`.
183
+ 1. **Start with core answer** what the structure directly shows
184
+ 2. **Cite every claim** `[node/slug]` for Node identity, `[node/section]` for facts
185
+ 3. **Include "Used nodes:" line** if question named specific Nodes: "Using nodes: `<slug>`, `<slug>`"
186
+ 4. **Mark gaps** if user asked for something not in returned structure: "Gap: no evidence for X"
187
+ 5. **Note truncation** if CLI said `truncated`: "Non-exhaustive result further narrowing available"
139
188
 
140
- ## Step 3: Anchor explicit Node mentions
189
+ **Example for structure-first query:**
190
+ ```
191
+ User asks: "What systems handle X in our architecture?"
141
192
 
142
- If the user's question contains a likely Node title, alias, slug, code symbol,
143
- or version:
193
+ Better query (structure-first):
194
+ context query --intent orientation # Shows all available Nodes
144
195
 
145
- 1. Prefer exact slug, title, or alias matches from the query result.
146
- 2. State the actual Node slug used.
147
- 3. If the candidate set points to multiple plausible slugs, say which slugs were used and keep claims scoped to those slugs.
196
+ Returns several candidate Nodes matching the question.
148
197
 
149
- ## Step 4: Supplement only when needed
198
+ Response:
199
+ "Systems that handle X:
200
+ - **<Node Title 1>** [<slug-1>] — responsibility and scope
201
+ - **<Node Title 2>** [<slug-2>] — responsibility and scope
150
202
 
151
- Use supplemental commands only when the first query has entries but lacks
152
- enough surrounding structure to answer the question.
203
+ To dive deeper into any system, ask me for more details or let me know which Node you want to explore."
204
+ ```
153
205
 
154
- Use supplements per the Supplemental context section, only after the first query
155
- and only for slugs present in returned entries, entry `refers_to_nodes`, or
156
- the user's explicit question. Use `refers_to_nodes` as extra anchors only when
157
- they appear in returned Sections. Do not discover extra anchors by reading
158
- workspace files.
206
+ **Why show structure first?** Even when you know keywords, structure queries reveal the full landscape.
207
+ Agents should explore Nodes first, then use section_search for details within a chosen Node.
159
208
 
160
- ## Step 5: Compose
209
+ ## Step 4: Explore further (if user requests)
161
210
 
162
- Answer only from the query and supplemental outputs.
211
+ Once Node scope is clear, user may ask for deeper exploration.
163
212
 
164
- Required response behavior:
213
+ **Supplemental query triggers:**
165
214
 
166
- 1. Start with the direct answer if evidence supports one.
167
- 2. Cite every key conclusion with Node slug and Section id.
168
- 3. Include a short "Used nodes" line when the question was anchored by title, alias, slug, code symbol, or version.
169
- 4. Include "Gap:" lines for requested points that are not supported.
170
- 5. Include a blocked / broad-query note when recall hints require narrowing, or a truncated/non-exhaustive note when returned evidence is only a subset.
215
+ - User asks about Node's relationships/dependencies `context query --intent impact_analysis --scope <slug>`
216
+ - User asks for full Node content after partial answer → `context query --intent node_view --scope <slug>`
217
+ - User asks specific detail within chosen Node `context query --intent section_search --scope <slug> --query "<keywords>"`
218
+ - **Use BM25 strategy**: mix Chinese and English keywords for better matching (e.g., mix synonym or translated forms of the search term)
219
+ - User names another Node in `refers_to_nodes` and asks about its relationship `context query --intent node_view --refers-to <slug>`
171
220
 
172
- ## Self-check before final answer
221
+ **BM25 tips for supplemental queries:**
222
+ - When searching for a detail, include both native and translated forms of terms
223
+ - If first query is too broad, add more specific keywords or domain terminology instead of generic terms
224
+ - Scope helps narrow BM25 results: `--scope <slug> --query "<specific-term> <synonym>"` is more precise than an unscoped broad query
173
225
 
174
- - [ ] First evidence-bearing tool call was ordinary `context query "$ARGUMENTS"` or an explicit reconcile `--intent recall` query. If an orientation command ran first or concurrently, it was only `context query --intent orientation` or empty `context query`, and an evidence-bearing `context query` command ran before answering — if not, go back to **Step 1**.
175
- - [ ] No direct file Read / Glob / Grep / Write was used against workspace local knowledge — if not, discard that evidence and go back to **Step 1**.
176
- - [ ] No ad-hoc script or shell file traversal was used against `WORKSPACE_DIR`, `.context`, or `/tmp` workflow artifacts — if not, discard that evidence and go back to **Step 1**.
177
- - [ ] Direct answer is given when evidence supports one if not, go back to **Step 5**.
178
- - [ ] Every key conclusion has `node / section` — if not, go back to **Step 5**.
179
- - [ ] If the question carried a Node title / alias / slug / code symbol / version, the answer includes a "Used nodes" line — if not, go back to **Step 3** and **Step 5**.
180
- - [ ] Any unsupported conclusion is marked as a gap — if not, go back to **Step 5**.
181
- - [ ] Recall diagnostics are handled: broad/blocked asks for narrowing; truncated with entries answers with a non-exhaustive note — if not, go back to **Step 2** and **Step 5**.
182
- - [ ] Archive entries appear only for explicit reconcile profiles — if not, go back to **Step 1** with the correct profile.
226
+ **Safety:**
227
+ - Do NOT auto-fetch all `refers_to_nodes`; only query if user asks
228
+ - Do NOT read workspace files to discover new Nodes
229
+ - Only supplement with slugs already in returned structure or user's explicit question
183
230
 
184
231
  </procedures>
@@ -77,7 +77,7 @@ details.
77
77
  ```
78
78
  context drop --plan <source-id|url> --format json
79
79
  context reconcile prepare --mode drop --format json
80
- context reconcile review --prepare-digest <prepare-digest> --decisions - --view status
80
+ context reconcile review --decisions - --view status
81
81
  context drop --apply-plan --reason "<text>" --yes
82
82
  ```
83
83
 
@@ -134,12 +134,11 @@ context reconcile prepare --mode drop --format json
134
134
  ```
135
135
 
136
136
  Invoke the packaged semantic reconcile procedure with that prepare payload. Use
137
- stdout `workflow_payload.digest` as `<prepare-digest>`.
138
137
  Pass the semantic reconcile decision document directly to review, preferably
139
138
  through stdin:
140
139
 
141
140
  ```
142
- context reconcile review --prepare-digest <prepare-digest> --decisions - --view status
141
+ context reconcile review --decisions - --view status
143
142
  ```
144
143
 
145
144
  The review command persists the ready immutable review artifact for the current