@c4a/context-cli 0.5.29-beta.17 → 0.5.29-beta.20
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/README.md +3 -3
- package/cli.js +5039 -2615
- package/package.json +1 -1
- package/plugin/README.md +4 -3
- package/plugin/README_CN.md +4 -3
- package/plugin/commands/align.md +40 -4
- package/plugin/commands/capture.md +17 -1
- package/plugin/commands/compile.md +17 -12
- package/plugin/commands/query.md +1 -0
- package/plugin/skills/skill-align-workflow/SKILL.md +42 -9
- package/plugin/skills/skill-align-workflow/references/gates.md +85 -45
- package/plugin/skills/skill-compile-close/SKILL.md +3 -4
- package/plugin/skills/skill-compile-draft/SKILL.md +106 -305
- package/plugin/skills/skill-compile-draft/references/action-domain-gates.md +34 -0
- package/plugin/skills/skill-compile-draft/references/notes.md +34 -0
- package/plugin/skills/skill-compile-draft/references/refresh-and-update.md +71 -0
- package/plugin/skills/skill-compile-draft/references/structural-challenges.md +76 -0
- package/plugin/skills/skill-compile-judge/SKILL.md +106 -0
- package/plugin/skills/skill-context-query/SKILL.md +137 -92
- package/plugin/skills/skill-drop/SKILL.md +2 -3
- package/plugin/skills/skill-semantic-reconcile/SKILL.md +67 -183
- package/plugin/skills/skill-semantic-reconcile/references/leakage-and-ownership.md +31 -0
- package/plugin/skills/skill-semantic-reconcile/references/mode-semantics.md +41 -0
- package/plugin/skills/skill-semantic-reconcile/references/scope-review-and-omit.md +60 -0
- package/plugin/skills/skill-semantic-reconcile/references/temporal-and-evidence.md +66 -0
- package/plugin/skills/skill-semantic-reconcile/references/user-confirmation.md +69 -0
|
@@ -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.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
and
|
|
4
|
+
Packaged skill invoked by `/context:query`; not a user slash command.
|
|
5
|
+
Uses structure-first strategy: explore Node structure via node_search/orientation first,
|
|
6
|
+
then narrow to specific Nodes, then explore relationships. Semantic queries are secondary
|
|
7
|
+
and only when structure queries cannot find the target Node. Always 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 —
|
|
14
|
+
# skill-context-query — structure-first knowledge exploration with citations
|
|
15
15
|
|
|
16
|
-
Answer
|
|
17
|
-
|
|
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
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
- If
|
|
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—explore Node structure via `node_search` or `orientation` to let user choose which Node to focus on.
|
|
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
|
|
|
@@ -53,18 +49,66 @@ Supplemental context can come from:
|
|
|
53
49
|
context query --intent node_search --scope <slug>
|
|
54
50
|
context query --intent impact_analysis --scope <slug>
|
|
55
51
|
context query --intent node_search --refers-to <slug>
|
|
52
|
+
context query --intent description_search --scope <slug> --query "<keywords>"
|
|
56
53
|
```
|
|
57
54
|
|
|
55
|
+
## Query Route Decision Table
|
|
56
|
+
|
|
57
|
+
Choose the `context query` command based on problem intent. **Structure queries take priority.**
|
|
58
|
+
|
|
59
|
+
| Problem intent | Primary command | When to use |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| **Vague question, no Node named** User asks "what is X" / "what are the X types" | `context query --intent orientation` or `context query --intent node_search --query "<keyword>"` | User unsure which Node to focus on; show structure first |
|
|
62
|
+
| **Node explicitly named** User mentions a specific service/system | `context query --intent node_search --scope <slug>` | User wants to explore a specific known Node |
|
|
63
|
+
| **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 |
|
|
64
|
+
| **Detail within known scope** (only after Node chosen) User asks for specific feature/behavior within chosen Node | `context query --intent description_search --scope <slug> --query "<detail>"` | User wants specific detail within an already-chosen Node |
|
|
65
|
+
| **Very specific fact** (fallback, rarely needed) User asks for exact implementation location | `context query "$ARGUMENTS"` | Semantic fallback when structure queries don't suffice |
|
|
66
|
+
| **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 |
|
|
67
|
+
|
|
68
|
+
## Orientation output and budget
|
|
69
|
+
|
|
70
|
+
`context query --intent orientation` is a navigation surface, not answer evidence.
|
|
71
|
+
|
|
72
|
+
- JSON output keeps full Node `summary` fields when present.
|
|
73
|
+
- Text output targets about 2000 tokens total. It prints `[Slug Map]` first, then `[Summary]`.
|
|
74
|
+
- `[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.
|
|
75
|
+
- `[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.
|
|
76
|
+
- Use `context query --intent node_search --scope <slug>` for a Node overview, or `context query --intent description_search --scope <slug> --query "<keywords>"` for details inside that Node.
|
|
77
|
+
- Use `context query --intent orientation --tag <tag>` or `context query --intent orientation --domain <slug>` to reduce the map before choosing a scope.
|
|
78
|
+
- When `slug` and `title` are equivalent after normalization (for example `payment-api` and `Payment API`), text output shows only the slug.
|
|
79
|
+
|
|
80
|
+
## BM25 Search Strategy
|
|
81
|
+
|
|
82
|
+
When using `description_search`, `recall`, or `node_search --query`, the CLI uses BM25 (keyword-based, not embedding-based) for matching. BM25 requires explicit keyword coverage, so queries must be precise:
|
|
83
|
+
|
|
84
|
+
- **Mix bilingual keywords**: Include both Chinese and English terms when querying—e.g., `"<chinese-term> <english-equivalent>"`, `"<product-name> <alternate-name>"`
|
|
85
|
+
- **Include synonyms & aliases**: BM25 is keyword-literal, so if your query doesn't match Section content exactly, try related terms
|
|
86
|
+
- **Use specific terminology**: Add version numbers, API names, or domain-specific terms to narrow results
|
|
87
|
+
- **Scope to reduce noise**: Use `--scope <slug>` to focus on a single Node; broad queries may be blocked or produce low-quality matches
|
|
88
|
+
|
|
89
|
+
Query intents that use BM25:
|
|
90
|
+
- `context query --intent node_search --query "<short-keyword>"` — find candidate Nodes from slug, title, summary, aliases, and tags when direct slug/title/alias matching does not resolve the query
|
|
91
|
+
- `context query --intent description_search --scope <slug> --query "<keywords>"` — find Section details using keyword matching within a known Node
|
|
92
|
+
- `context query --intent recall --profile <profile> --query "<keywords>"` — archive audit and reconciliation queries using keyword matching
|
|
93
|
+
|
|
94
|
+
Do NOT use BM25 strategy for:
|
|
95
|
+
- `context query --intent node_search --scope <slug>` or `--node <slug>` — uses structure, not keywords
|
|
96
|
+
- `context query --intent orientation` — uses structure, not keywords
|
|
97
|
+
- `context query --intent impact_analysis` — uses structure, not keywords
|
|
98
|
+
|
|
58
99
|
## Answer citation shape
|
|
59
100
|
|
|
60
|
-
Use compact citations
|
|
101
|
+
Use compact citations keyed to evidence type:
|
|
61
102
|
|
|
62
103
|
```text
|
|
63
|
-
<claim> [
|
|
104
|
+
Node identity/title: <claim> [slug]
|
|
105
|
+
Section claim: <claim> [node/section]
|
|
106
|
+
Relationship/edge: X → Y [relationship_type]
|
|
107
|
+
Multiple sources: <claim> [node/section, node/section]
|
|
64
108
|
```
|
|
65
109
|
|
|
66
110
|
If multiple Sections support the same claim, cite the strongest one or two.
|
|
67
|
-
|
|
111
|
+
Summarize what each cited Section supports; do not list citations without explanation.
|
|
68
112
|
|
|
69
113
|
## Gap shape
|
|
70
114
|
|
|
@@ -82,103 +126,104 @@ the user's wording indicates newly captured material is not yet knowledge.
|
|
|
82
126
|
|
|
83
127
|
<procedures>
|
|
84
128
|
|
|
85
|
-
## Step 1:
|
|
129
|
+
## Step 1: Classify problem intent
|
|
86
130
|
|
|
87
|
-
|
|
88
|
-
do not run the query.
|
|
131
|
+
Determine what the user is trying to learn. Choose the appropriate command from the Query Route table above.
|
|
89
132
|
|
|
90
|
-
|
|
91
|
-
is broad, ambiguous, or asks what can be queried, run one orientation pass before
|
|
92
|
-
the first evidence query:
|
|
133
|
+
**Classification:**
|
|
93
134
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
135
|
+
- **Vague problem** — user unsure which Node to focus on
|
|
136
|
+
- Indicators: asks "what is X", "what are the X types", "how to understand X", or question without Node anchor
|
|
137
|
+
- Action: Run `context query --intent orientation` to show available Nodes and structure; then pick a Node or ask for narrower scope
|
|
138
|
+
- **Note**: `node_search` uses structure not BM25; orientation always works regardless of workspace content
|
|
97
139
|
|
|
98
|
-
|
|
140
|
+
- **Node explicitly named** — user mentions a specific service/system/concept
|
|
141
|
+
- Indicators: user names a specific Node or system, "tell me about X", "show me X"
|
|
142
|
+
- Action: Run `context query --intent node_search --scope <slug>` to explore that Node
|
|
99
143
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
144
|
+
- **Relationship / impact** — user asks how Nodes relate or what breaks if X changes
|
|
145
|
+
- Indicators: "what depends on X", "impact of X", "relationship between X and Y"
|
|
146
|
+
- Action: Run `context query --intent impact_analysis --scope <slug>` to show dependencies/relationships
|
|
103
147
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
query for the answer; use orientation only for scoped follow-up if the first
|
|
108
|
-
query is insufficient.
|
|
148
|
+
- **Detail within known scope** — user already chose a Node, now asking for specific detail
|
|
149
|
+
- Indicators: (comes after Node is selected) user asks "how does X handle [feature]", "what features does X support"
|
|
150
|
+
- Action: Run `context query --intent description_search --scope <slug> --query "<detail-keywords>"` — use BM25 keywords for precise matching
|
|
109
151
|
|
|
110
|
-
|
|
152
|
+
- **Archive / reconciliation** — user explicitly asks for dedup/audit/coverage
|
|
153
|
+
- Indicators: "find duplicates", "check source coverage"
|
|
154
|
+
- Action: Run `context query --intent recall --profile <reconcile-*> --query "..."`
|
|
155
|
+
- ❌ Never use for ordinary questions
|
|
111
156
|
|
|
112
|
-
|
|
113
|
-
context query "$ARGUMENTS"
|
|
114
|
-
```
|
|
157
|
+
## Step 2: Execute query & interpret response
|
|
115
158
|
|
|
116
|
-
|
|
117
|
-
semantic reconciliation candidates, use recall with the matching profile:
|
|
159
|
+
Run the command from Step 1. Read the CLI output carefully.
|
|
118
160
|
|
|
119
|
-
|
|
120
|
-
- support check / source support → `--profile reconcile-support`
|
|
121
|
-
- refresh / stale source comparison → `--profile reconcile-refresh`
|
|
161
|
+
**Route based on response:**
|
|
122
162
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
163
|
+
- ❌ **Command fails** → Report error and stop
|
|
164
|
+
- ❌ **`miss`** (no knowledge found) → Report no local knowledge and stop
|
|
165
|
+
- ⚠️ **`select`** (multiple candidate Nodes) → Show candidates to user; ask which Node to focus on
|
|
166
|
+
- Then: loop back to Step 1 with chosen Node scope
|
|
167
|
+
- ⚠️ **`broad` / `blocked` recall** → Ask user for narrower scope (specific Node, term, version)
|
|
168
|
+
- Then: loop back to Step 1
|
|
169
|
+
- ⚠️ **`raw-only` / `uncompiled`** → Say "raw source found but not yet in compiled knowledge"
|
|
170
|
+
- Only suggest `/context:align` + `/context:compile` if user wants it compiled
|
|
171
|
+
- ⚠️ **`truncated`** (entries cut off) → Mark answer as "non-exhaustive"
|
|
172
|
+
- Proceed to Step 3; ask for narrowing only if user needs complete inventory
|
|
173
|
+
- ✓ **Entries returned** → Proceed to Step 3
|
|
126
174
|
|
|
127
|
-
|
|
175
|
+
## Step 3: Compose answer from returned structure
|
|
128
176
|
|
|
129
|
-
|
|
177
|
+
Use only the returned Node/Section structure and content. Do not synthesize beyond what was returned.
|
|
130
178
|
|
|
131
|
-
|
|
179
|
+
**Response structure:**
|
|
132
180
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
- Keep a working set of returned rows with `node`, `section`, `kind`, `content`, and non-empty `refers_to_nodes`.
|
|
181
|
+
1. **Start with core answer** — what the structure directly shows
|
|
182
|
+
2. **Cite every claim** — `[node/slug]` for Node identity, `[node/section]` for facts
|
|
183
|
+
3. **Include "Used nodes:" line** — if question named specific Nodes: "Using nodes: `<slug>`, `<slug>`"
|
|
184
|
+
4. **Mark gaps** — if user asked for something not in returned structure: "Gap: no evidence for X"
|
|
185
|
+
5. **Note truncation** — if CLI said `truncated`: "Non-exhaustive result — further narrowing available"
|
|
139
186
|
|
|
140
|
-
|
|
187
|
+
**Example for structure-first query:**
|
|
188
|
+
```
|
|
189
|
+
User asks: "What systems handle X in our architecture?"
|
|
141
190
|
|
|
142
|
-
|
|
143
|
-
|
|
191
|
+
Better query (structure-first):
|
|
192
|
+
context query --intent orientation # Shows all available Nodes
|
|
144
193
|
|
|
145
|
-
|
|
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.
|
|
194
|
+
Returns several candidate Nodes matching the question.
|
|
148
195
|
|
|
149
|
-
|
|
196
|
+
Response:
|
|
197
|
+
"Systems that handle X:
|
|
198
|
+
- **<Node Title 1>** [<slug-1>] — responsibility and scope
|
|
199
|
+
- **<Node Title 2>** [<slug-2>] — responsibility and scope
|
|
150
200
|
|
|
151
|
-
|
|
152
|
-
|
|
201
|
+
To dive deeper into any system, ask me for more details or let me know which Node you want to explore."
|
|
202
|
+
```
|
|
153
203
|
|
|
154
|
-
|
|
155
|
-
|
|
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.
|
|
204
|
+
**Why show structure first?** Even when you know keywords, structure queries reveal the full landscape.
|
|
205
|
+
Agents should explore Nodes first, then use description_search for details within a chosen Node.
|
|
159
206
|
|
|
160
|
-
## Step
|
|
207
|
+
## Step 4: Explore further (if user requests)
|
|
161
208
|
|
|
162
|
-
|
|
209
|
+
Once Node scope is clear, user may ask for deeper exploration.
|
|
163
210
|
|
|
164
|
-
|
|
211
|
+
**Supplemental query triggers:**
|
|
165
212
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
213
|
+
- User asks about Node's relationships/dependencies → `context query --intent impact_analysis --scope <slug>`
|
|
214
|
+
- User asks for full Node content after partial answer → `context query --intent node_search --scope <slug>`
|
|
215
|
+
- User asks specific detail within chosen Node → `context query --intent description_search --scope <slug> --query "<keywords>"`
|
|
216
|
+
- **Use BM25 strategy**: mix Chinese and English keywords for better matching (e.g., mix synonym or translated forms of the search term)
|
|
217
|
+
- User names another Node in `refers_to_nodes` and asks about its relationship → `context query --intent node_search --refers-to <slug>`
|
|
171
218
|
|
|
172
|
-
|
|
219
|
+
**BM25 tips for supplemental queries:**
|
|
220
|
+
- When searching for a detail, include both native and translated forms of terms
|
|
221
|
+
- If first query is too broad, add more specific keywords or domain terminology instead of generic terms
|
|
222
|
+
- Scope helps narrow BM25 results: `--scope <slug> --query "<specific-term> <synonym>"` is more precise than an unscoped broad query
|
|
173
223
|
|
|
174
|
-
|
|
175
|
-
-
|
|
176
|
-
-
|
|
177
|
-
-
|
|
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.
|
|
224
|
+
**Safety:**
|
|
225
|
+
- ❌ Do NOT auto-fetch all `refers_to_nodes`; only query if user asks
|
|
226
|
+
- ❌ Do NOT read workspace files to discover new Nodes
|
|
227
|
+
- ✓ Only supplement with slugs already in returned structure or user's explicit question
|
|
183
228
|
|
|
184
229
|
</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 --
|
|
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 --
|
|
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
|