ace-swarm 2.1.0 → 2.1.2
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/assets/.agents/skills/ace-orchestrator/SKILL.md +40 -337
- package/assets/.agents/skills/ace-orchestrator/references/engineering-bootstrap-playbook.md +360 -0
- package/assets/.agents/skills/astgrep-index/SKILL.md +44 -51
- package/assets/.agents/skills/codemunch/SKILL.md +42 -520
- package/assets/.agents/skills/codemunch/references/ast-driven-protocol.md +543 -0
- package/assets/.agents/skills/codesnipe/SKILL.md +41 -648
- package/assets/.agents/skills/codesnipe/references/dual-codebase-playbook.md +671 -0
- package/assets/.agents/skills/eval-harness/SKILL.md +7 -1
- package/assets/.agents/skills/handoff-lint/SKILL.md +6 -0
- package/assets/.agents/skills/incident-commander/SKILL.md +6 -0
- package/assets/.agents/skills/memory-curator/SKILL.md +7 -1
- package/assets/.agents/skills/release-sentry/SKILL.md +6 -0
- package/assets/.agents/skills/risk-quant/SKILL.md +7 -1
- package/assets/.agents/skills/schema-forge/SKILL.md +7 -1
- package/assets/.agents/skills/skill-auditor/SKILL.md +1 -1
- package/assets/.agents/skills/state-auditor/SKILL.md +7 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +18 -33
- package/dist/helpers.js.map +1 -1
- package/dist/problem-triage.d.ts.map +1 -1
- package/dist/problem-triage.js +19 -0
- package/dist/problem-triage.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,671 +1,64 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: codesnipe
|
|
3
|
-
description:
|
|
4
|
-
|
|
3
|
+
description:
|
|
4
|
+
Compare a HOME codebase with a TARGET codebase by scoring TARGET symbols against HOME first. Use when you need adoption candidates, divergence analysis, bug triangulation, or integration ideas instead of broad repo browsing.
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
# CodeSnipe
|
|
7
|
+
# CodeSnipe
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
a single implementation line from the TARGET, you MUST first build a symbol registry
|
|
11
|
-
of the HOME codebase. Every TARGET symbol you retrieve must first earn a relevance score
|
|
12
|
-
against the HOME registry. Low-scoring symbols are DISCARDED — not read, not summarised,
|
|
13
|
-
not discussed. The sniper does not spray. The sniper fires once, and only at verified targets.
|
|
9
|
+
Use this skill to perform evidence-backed, dual-codebase comparison without wasting attention on low-signal TARGET code.
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
1. "What does TARGET *do* relative to HOME?" — answered by OUTLINE phase only.
|
|
17
|
-
2. "How does TARGET *do it*?" — answered only for symbols that scored ≥ 8 in relevance.
|
|
11
|
+
## Purpose
|
|
18
12
|
|
|
19
|
-
|
|
13
|
+
Build a HOME-aware relevance map so only the most comparable or adoptable TARGET symbols are extracted, analyzed, and handed off.
|
|
20
14
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
## 0. ACE Role Declaration
|
|
24
|
-
|
|
25
|
-
CodeSnipe operates as a `capability-research` module with a **comparative output contract**.
|
|
26
|
-
|
|
27
|
-
- **Emits** `SOURCE_VALIDATED` events per symbol snipe (with relevance score attached).
|
|
28
|
-
- **Emits** `GATE_FAILED` if the HOME registry is empty when TARGET sniping begins.
|
|
29
|
-
- **Writes** to `./agent-state/snipe/` (separate namespace from codemunch artifacts).
|
|
30
|
-
- **Blocks** downstream modules from acting on TARGET patterns that lack HOME context.
|
|
31
|
-
- **Hands off** via `HANDOFF.json` once `SNIPE_COMPARISON.md` is locked and scored.
|
|
32
|
-
|
|
33
|
-
ACE Clarity Protocol headers must be used at each phase boundary.
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## 0.1 MICE Boundaries
|
|
38
|
-
|
|
39
|
-
| Rule | Enforcement |
|
|
40
|
-
|---|---|
|
|
41
|
-
| **Modular** | Compares codebases at symbol level; does NOT modify HOME or TARGET code. |
|
|
42
|
-
| **Interoperable** | All findings written as standardized artifacts in `./agent-state/snipe/`. |
|
|
43
|
-
| **Customizable** | Intent parameter (`steal/compare/debug/integrate`) controls scoring weights. |
|
|
44
|
-
| **Extensible** | New comparison criteria added via scoring formula weights, not ad-hoc rules. |
|
|
45
|
-
|
|
46
|
-
## 0.2 Goal Orientation
|
|
47
|
-
|
|
48
|
-
- `DELETE_PROTOCOL`: Discard all TARGET symbols scoring < 8. No token waste on irrelevant code.
|
|
49
|
-
- `ARTIFACT_PROTOCOL`: Session MUST produce `SNIPE_COMPARISON.md` minimum. No artifact = failed session.
|
|
50
|
-
- `AGENCY_PROTOCOL`: HOME registry drives all TARGET queries. Never read TARGET without HOME context.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## 1. The Dual-Context Model
|
|
57
|
-
|
|
58
|
-
Every CodeSnipe session operates with two explicit roles:
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
HOME = the codebase you OWN, MAINTAIN, or are WORKING ON.
|
|
62
|
-
Source of truth for "what we already do."
|
|
63
|
-
|
|
64
|
-
TARGET = the codebase you are STUDYING, COMPARING AGAINST, or DRAWING FROM.
|
|
65
|
-
Source of potential patterns, ideas, missing features, or alternative
|
|
66
|
-
implementations.
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
**The Relevance Score** gates all TARGET reads:
|
|
70
|
-
|
|
71
|
-
| Score | Signal | Action |
|
|
72
|
-
|---|---|---|
|
|
73
|
-
| 20 | Exact symbol name match in HOME | Read TARGET implementation; direct comparison possible |
|
|
74
|
-
| 12–19 | Structural/semantic overlap with HOME | Read TARGET implementation; likely inspiration or divergence |
|
|
75
|
-
| 8–11 | Partial name or pattern overlap | Read signature only; decide before reading body |
|
|
76
|
-
| 4–7 | Weak thematic connection | Log to KNOWN_UNKNOWNS; do not read |
|
|
77
|
-
| 0–3 | No meaningful connection to HOME | Discard |
|
|
78
|
-
|
|
79
|
-
The scoring formula (adapted from jcodemunch-mcp's weighted search):
|
|
80
|
-
```
|
|
81
|
-
score = 0
|
|
82
|
-
score += 20 if exact name match (HOME symbol name == TARGET symbol name)
|
|
83
|
-
score += 10 if name substring match
|
|
84
|
-
score += 5 per shared word in name
|
|
85
|
-
score += 8 if full signature pattern match (same function shape)
|
|
86
|
-
score += 4 if return type matches a HOME type
|
|
87
|
-
score += 3 if parameter types overlap with HOME types
|
|
88
|
-
score += 5 if TARGET docstring mentions a concept present in HOME
|
|
89
|
-
score += 2 per shared decorator/attribute
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
Compute this BEFORE running any `ast-grep` pattern to read an implementation.
|
|
93
|
-
|
|
94
|
-
---
|
|
95
|
-
|
|
96
|
-
## 2. The Snipe Socratic Stack
|
|
97
|
-
|
|
98
|
-
Run this stack in order. **The first question you cannot answer from the HOME registry
|
|
99
|
-
is your first ast-grep snipe into the TARGET.**
|
|
100
|
-
|
|
101
|
-
**Tier 0 — Establish HOME Baseline**
|
|
102
|
-
1. What symbols does HOME export publicly? (functions, types, classes, constants)
|
|
103
|
-
2. What are HOME's primary design patterns? (builder, registry, pipeline, actor, etc.)
|
|
104
|
-
3. What problems does HOME solve? (one sentence per module)
|
|
105
|
-
4. Where are HOME's extension/plugin points?
|
|
106
|
-
5. What does HOME conspicuously NOT do? (known gaps, TODOs, deferred features)
|
|
107
|
-
|
|
108
|
-
**Tier 1 — Profile TARGET at Outline Level**
|
|
109
|
-
6. What languages and structure does TARGET use?
|
|
110
|
-
7. What is TARGET's stated purpose? Does it overlap with HOME's domain?
|
|
111
|
-
8. What public symbols does TARGET expose? (names only — no implementations yet)
|
|
112
|
-
9. Which TARGET symbol names appear verbatim or approximately in HOME?
|
|
113
|
-
10. Which TARGET module names map to HOME module names?
|
|
114
|
-
|
|
115
|
-
**Tier 2 — Score and Rank**
|
|
116
|
-
11. Which TARGET symbols scored ≥ 12 against HOME? (prime snipe candidates)
|
|
117
|
-
12. Which TARGET symbols represent concepts HOME has TODOs for?
|
|
118
|
-
13. Which TARGET patterns appear 3+ times but are absent from HOME?
|
|
119
|
-
14. Does TARGET solve any HOME Tier-5 Socratic question (known gaps)?
|
|
120
|
-
|
|
121
|
-
**Tier 3 — Precision Extraction (only for score ≥ 8 symbols)**
|
|
122
|
-
15. How does TARGET implement the high-score symbol? (read body now)
|
|
123
|
-
16. What does TARGET do that HOME does differently? (divergence analysis)
|
|
124
|
-
17. Is TARGET's approach adoptable in HOME's architecture without breaking changes?
|
|
125
|
-
18. What would adoption cost? (new dependencies, refactors, interface changes)
|
|
126
|
-
|
|
127
|
-
> **Rule**: Write every scored symbol into `SNIPE_RELEVANCE_MAP.md` immediately.
|
|
128
|
-
> A symbol discussed without a recorded score is a protocol violation.
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
## 3. Execution Protocol
|
|
133
|
-
|
|
134
|
-
### Phase 0 — HOME Registry Build `[STATE_ANALYSIS]`
|
|
135
|
-
|
|
136
|
-
**Never skip this phase.** No TARGET sniping without a complete HOME registry.
|
|
137
|
-
|
|
138
|
-
**Step 1 — HOME public API surface**
|
|
139
|
-
```bash
|
|
140
|
-
# Rust
|
|
141
|
-
ast-grep --pattern 'pub fn $NAME($$$)' --lang rust --json | \
|
|
142
|
-
jq '.[] | {name: .metaVariables.NAME, file: .file, line: .range.start.line}' \
|
|
143
|
-
>> ./agent-state/snipe/HOME_REGISTRY.jsonl
|
|
144
|
-
|
|
145
|
-
ast-grep --pattern 'pub struct $NAME' --lang rust --json | \
|
|
146
|
-
jq '.[] | {name: .metaVariables.NAME, kind: "struct", file: .file}' \
|
|
147
|
-
>> ./agent-state/snipe/HOME_REGISTRY.jsonl
|
|
148
|
-
|
|
149
|
-
ast-grep --pattern 'pub trait $NAME' --lang rust --json | \
|
|
150
|
-
jq '.[] | {name: .metaVariables.NAME, kind: "trait", file: .file}' \
|
|
151
|
-
>> ./agent-state/snipe/HOME_REGISTRY.jsonl
|
|
152
|
-
|
|
153
|
-
# Python
|
|
154
|
-
ast-grep --pattern 'def $NAME($$$):' --lang python --json | \
|
|
155
|
-
jq '.[] | {name: .metaVariables.NAME, kind: "function", file: .file}' \
|
|
156
|
-
>> ./agent-state/snipe/HOME_REGISTRY.jsonl
|
|
157
|
-
|
|
158
|
-
ast-grep --pattern 'class $NAME:' --lang python --json | \
|
|
159
|
-
jq '.[] | {name: .metaVariables.NAME, kind: "class", file: .file}' \
|
|
160
|
-
>> ./agent-state/snipe/HOME_REGISTRY.jsonl
|
|
161
|
-
|
|
162
|
-
# TypeScript / JavaScript
|
|
163
|
-
ast-grep --pattern 'export function $NAME($$$)' --lang ts --json | \
|
|
164
|
-
jq '.[] | {name: .metaVariables.NAME, kind: "function", file: .file}' \
|
|
165
|
-
>> ./agent-state/snipe/HOME_REGISTRY.jsonl
|
|
166
|
-
|
|
167
|
-
ast-grep --pattern 'export class $NAME' --lang ts --json | \
|
|
168
|
-
jq '.[] | {name: .metaVariables.NAME, kind: "class", file: .file}' \
|
|
169
|
-
>> ./agent-state/snipe/HOME_REGISTRY.jsonl
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
**Step 2 — HOME gap map (known unknowns)**
|
|
173
|
-
```bash
|
|
174
|
-
# Extract TODOs, FIXMEs, unimplemented stubs — these are prime adoption targets
|
|
175
|
-
grep -rn "TODO\|FIXME\|HACK\|unimplemented!\|todo!()" \
|
|
176
|
-
--include="*.rs" --include="*.py" --include="*.ts" \
|
|
177
|
-
| grep -v ".git" | head -50 \
|
|
178
|
-
>> ./agent-state/snipe/HOME_GAP_MAP.txt
|
|
179
|
-
|
|
180
|
-
# Rust: unimplemented/todo macros (structural, not comment)
|
|
181
|
-
ast-grep --pattern 'unimplemented!()' --lang rust
|
|
182
|
-
ast-grep --pattern 'todo!()' --lang rust
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
**Step 3 — HOME pattern fingerprint**
|
|
186
|
-
```bash
|
|
187
|
-
# What recurring structural patterns define HOME's style?
|
|
188
|
-
# Rust: error enum pattern
|
|
189
|
-
ast-grep --pattern 'pub enum $NAME { $$$ }' --lang rust | grep -i "err\|Error\|Fail"
|
|
190
|
-
|
|
191
|
-
# Rust: Result-returning public functions (count as percentage of all pub fns)
|
|
192
|
-
ast-grep --pattern 'pub fn $NAME($$$) -> Result<$$$>' --lang rust
|
|
193
|
-
|
|
194
|
-
# Python: decorator usage (marks framework patterns)
|
|
195
|
-
ast-grep --pattern '@$DECORATOR' --lang python --json | \
|
|
196
|
-
jq -r '.[] | .metaVariables.DECORATOR' | sort | uniq -c | sort -rn | head -15
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
**Output**: Write `SNIPE_HOME_REGISTRY.md`:
|
|
200
|
-
```markdown
|
|
201
|
-
# SNIPE_HOME_REGISTRY.md
|
|
202
|
-
Generated: <timestamp>
|
|
203
|
-
HOME Path: <path>
|
|
204
|
-
Language(s): <langs>
|
|
205
|
-
|
|
206
|
-
## Public Symbol Inventory
|
|
207
|
-
| Symbol | Kind | File | Notes |
|
|
208
|
-
|--------|------|------|-------|
|
|
209
|
-
| <name> | fn/class/trait/type | <file> | |
|
|
210
|
-
|
|
211
|
-
## Pattern Fingerprint
|
|
212
|
-
- Primary error handling: <Result/Exception/Either>
|
|
213
|
-
- Primary concurrency: <async/sync/threaded>
|
|
214
|
-
- Decorator/attribute patterns: <list>
|
|
215
|
-
- Extension points: <list>
|
|
216
|
-
|
|
217
|
-
## Known Gaps (from TODOs/unimplemented)
|
|
218
|
-
- <file:line>: <todo text>
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
**Gate**: HOME registry must contain ≥ 1 symbol before proceeding to Phase 1.
|
|
222
|
-
If HOME is empty or inaccessible, emit `GATE_FAILED` and halt.
|
|
223
|
-
|
|
224
|
-
---
|
|
225
|
-
|
|
226
|
-
### Phase 1 — TARGET Outline (No Reads Yet) `[STRATEGY_SELECTOR]`
|
|
227
|
-
|
|
228
|
-
Extract TARGET structure at the symbol-name level only. Zero implementations read.
|
|
229
|
-
|
|
230
|
-
**Step 4 — TARGET skeleton**
|
|
231
|
-
```bash
|
|
232
|
-
# Run from TARGET directory. Mirror HOME's Phase 0 queries exactly.
|
|
233
|
-
cd <TARGET_PATH>
|
|
234
|
-
|
|
235
|
-
# Rust
|
|
236
|
-
ast-grep --pattern 'pub fn $NAME($$$)' --lang rust --json | \
|
|
237
|
-
jq '.[] | {name: .metaVariables.NAME, kind: "function", file: .file}' \
|
|
238
|
-
>> ./agent-state/snipe/TARGET_OUTLINE.jsonl
|
|
239
|
-
|
|
240
|
-
# Python
|
|
241
|
-
ast-grep --pattern 'def $NAME($$$):' --lang python --json | \
|
|
242
|
-
jq '.[] | {name: .metaVariables.NAME, kind: "function", file: .file}' \
|
|
243
|
-
>> ./agent-state/snipe/TARGET_OUTLINE.jsonl
|
|
244
|
-
|
|
245
|
-
# TypeScript
|
|
246
|
-
ast-grep --pattern 'export function $NAME($$$)' --lang ts --json | \
|
|
247
|
-
jq '.[] | {name: .metaVariables.NAME, kind: "function", file: .file}' \
|
|
248
|
-
>> ./agent-state/snipe/TARGET_OUTLINE.jsonl
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
**Step 5 — TARGET structural shape (without reading bodies)**
|
|
252
|
-
```bash
|
|
253
|
-
# Module/file structure
|
|
254
|
-
find . -type f \( -name "*.rs" -o -name "*.py" -o -name "*.ts" \) \
|
|
255
|
-
| grep -v ".git" | sort
|
|
256
|
-
|
|
257
|
-
# Public type surface
|
|
258
|
-
ast-grep --pattern 'pub struct $NAME { $$$ }' --lang rust # Rust types
|
|
259
|
-
ast-grep --pattern 'class $NAME:' --lang python # Python classes
|
|
260
|
-
ast-grep --pattern 'interface $NAME' --lang ts # TS interfaces
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
**Step 6 — TARGET dependency profile**
|
|
264
|
-
```bash
|
|
265
|
-
# What external deps does TARGET use that HOME does not?
|
|
266
|
-
# (Compare against HOME's Cargo.toml / pyproject.toml / package.json)
|
|
267
|
-
cat Cargo.toml | grep -A50 "\[dependencies\]" # Rust
|
|
268
|
-
cat pyproject.toml | grep -A30 "dependencies" # Python
|
|
269
|
-
cat package.json | python3 -c "import sys,json; d=json.load(sys.stdin); [print(k) for k in d.get('dependencies',{}).keys()]" # Node
|
|
270
|
-
|
|
271
|
-
# New deps in TARGET but not HOME = potential new capabilities
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
**Output**: Write `SNIPE_TARGET_OUTLINE.md`:
|
|
275
|
-
```markdown
|
|
276
|
-
# SNIPE_TARGET_OUTLINE.md
|
|
277
|
-
TARGET Path/URL: <path>
|
|
278
|
-
Language(s): <langs>
|
|
279
|
-
Symbol Count: <n>
|
|
280
|
-
|
|
281
|
-
## Symbol Names (outline only)
|
|
282
|
-
| Symbol | Kind | File |
|
|
283
|
-
|--------|------|------|
|
|
284
|
-
| <name> | fn/class/type | <file> |
|
|
285
|
-
|
|
286
|
-
## Dependencies Not in HOME
|
|
287
|
-
- <dep>: <apparent purpose>
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
---
|
|
291
|
-
|
|
292
|
-
### Phase 2 — Relevance Scoring `[EXECUTION_LOG]`
|
|
293
|
-
|
|
294
|
-
This is the **core of CodeSnipe**. No TARGET implementation is read until every symbol
|
|
295
|
-
has a score. Score computation is done against the HOME registry in memory.
|
|
296
|
-
|
|
297
|
-
**Step 7 — Name-match pass**
|
|
298
|
-
```bash
|
|
299
|
-
# For each TARGET symbol name, check if it exists in HOME registry
|
|
300
|
-
# (Run this as a shell one-liner using the JSONL registries)
|
|
15
|
+
## Canonical Use Cases
|
|
301
16
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
<(jq -r '.name' ./agent-state/snipe/TARGET_OUTLINE.jsonl | sort) \
|
|
306
|
-
> ./agent-state/snipe/EXACT_MATCHES.txt
|
|
17
|
+
1. A team wants to adopt a pattern from another repository and needs ranked implementation candidates instead of broad comparison notes.
|
|
18
|
+
2. A bug or gap in the HOME codebase might already be solved in a TARGET codebase, and the team wants precise triangulation.
|
|
19
|
+
3. An integration or competitor study requires knowing what TARGET does relative to HOME before deeper reading begins.
|
|
307
20
|
|
|
308
|
-
|
|
309
|
-
while IFS= read -r target_name; do
|
|
310
|
-
grep -i "$target_name" ./agent-state/snipe/HOME_REGISTRY.jsonl && echo "SUBSTR_MATCH: $target_name"
|
|
311
|
-
done < <(jq -r '.name' ./agent-state/snipe/TARGET_OUTLINE.jsonl) \
|
|
312
|
-
>> ./agent-state/snipe/SUBSTR_MATCHES.txt
|
|
313
|
-
```
|
|
21
|
+
## Inputs
|
|
314
22
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
23
|
+
- HOME codebase path
|
|
24
|
+
- TARGET codebase path or checkout
|
|
25
|
+
- Comparison intent such as `steal`, `compare`, `debug`, or `integrate`
|
|
26
|
+
- ast-grep plus any lightweight registry artifacts already available under `agent-state/snipe/`
|
|
319
27
|
|
|
320
|
-
|
|
321
|
-
# check if TARGET also returns Result-like types
|
|
322
|
-
ast-grep --pattern 'fn $NAME($$$) -> Result<$T, $E>' --lang rust # (run in TARGET)
|
|
323
|
-
ast-grep --pattern 'def $NAME($$$) -> $RETURN:' --lang python # (run in TARGET)
|
|
28
|
+
## Workflow
|
|
324
29
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
30
|
+
1. Build a HOME symbol registry and pattern fingerprint first.
|
|
31
|
+
2. Outline TARGET at the symbol-name and module-shape level without reading implementations.
|
|
32
|
+
3. Score TARGET symbols against HOME and record the relevance map.
|
|
33
|
+
4. Extract only symbols that meet the score threshold, then analyze divergence or adoption fit.
|
|
34
|
+
5. Write the comparison artifacts and handoff recommendation under `agent-state/snipe/`.
|
|
330
35
|
|
|
331
|
-
|
|
332
|
-
```bash
|
|
333
|
-
# Does TARGET have implementations for HOME's known gaps?
|
|
334
|
-
# For each TODO in HOME_GAP_MAP.txt, search TARGET for related symbols
|
|
36
|
+
## Outputs
|
|
335
37
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
done < ./agent-state/snipe/HOME_GAP_MAP.txt
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
**Output**: Write `SNIPE_RELEVANCE_MAP.md`:
|
|
345
|
-
```markdown
|
|
346
|
-
# SNIPE_RELEVANCE_MAP.md
|
|
347
|
-
|
|
348
|
-
## Tier A — Prime Snipe Targets (score ≥ 12)
|
|
349
|
-
| TARGET Symbol | Score | Reason | HOME Counterpart | File |
|
|
350
|
-
|---|---|---|---|---|
|
|
351
|
-
| `parse_file` | 20 | Exact name match | `parse_file` | extractor.py |
|
|
352
|
-
| `LanguageSpec` | 15 | Name+type overlap | `LangConfig` | languages.py |
|
|
353
|
-
|
|
354
|
-
## Tier B — Worth Reading Signature (score 8–11)
|
|
355
|
-
| TARGET Symbol | Score | Reason | File |
|
|
356
|
-
|---|---|---|---|
|
|
357
|
-
|
|
358
|
-
## Tier C — Gap Coverage (HOME TODO resolved by TARGET)
|
|
359
|
-
| HOME Gap | TARGET Symbol | File |
|
|
360
|
-
|---|---|---|
|
|
361
|
-
|
|
362
|
-
## Discarded (score < 8)
|
|
363
|
-
Count: <n> symbols discarded. Not read. Not discussed.
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
---
|
|
367
|
-
|
|
368
|
-
### Phase 3 — Precision Extraction `[EXECUTION_LOG]`
|
|
369
|
-
|
|
370
|
-
**Only Tier A and Tier B symbols reach this phase.**
|
|
371
|
-
|
|
372
|
-
**Step 10 — Snipe Tier A implementations**
|
|
373
|
-
```bash
|
|
374
|
-
# For each Tier A symbol, extract full implementation via ast-grep
|
|
375
|
-
# Replace SYMBOL_NAME with actual name from SNIPE_RELEVANCE_MAP.md
|
|
376
|
-
|
|
377
|
-
# Rust function body
|
|
378
|
-
ast-grep --pattern 'fn SYMBOL_NAME($$$) { $$$ }' --lang rust
|
|
379
|
-
|
|
380
|
-
# Rust with impl context (method)
|
|
381
|
-
ast-grep --pattern 'impl $TYPE { $$$ fn SYMBOL_NAME($$$) { $$$ } $$$ }' --lang rust
|
|
382
|
-
|
|
383
|
-
# Python function body
|
|
384
|
-
ast-grep --pattern 'def SYMBOL_NAME($$$): $$$' --lang python
|
|
385
|
-
|
|
386
|
-
# TypeScript
|
|
387
|
-
ast-grep --pattern 'function SYMBOL_NAME($$$): $RET { $$$ }' --lang ts
|
|
388
|
-
ast-grep --pattern 'SYMBOL_NAME($$$): $RET { $$$ }' --lang ts # method
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
**Step 11 — Divergence extraction (how HOME and TARGET differ)**
|
|
392
|
-
```bash
|
|
393
|
-
# For exact-match symbols (score == 20), extract both HOME and TARGET implementations
|
|
394
|
-
# to compare approaches
|
|
395
|
-
|
|
396
|
-
# HOME implementation
|
|
397
|
-
cd <HOME_PATH>
|
|
398
|
-
ast-grep --pattern 'fn SYMBOL_NAME($$$) { $$$ }' --lang rust > /tmp/home_impl.txt
|
|
399
|
-
|
|
400
|
-
# TARGET implementation
|
|
401
|
-
cd <TARGET_PATH>
|
|
402
|
-
ast-grep --pattern 'fn SYMBOL_NAME($$$) { $$$ }' --lang rust > /tmp/target_impl.txt
|
|
403
|
-
|
|
404
|
-
# Structural diff: how many lines? How many patterns differ?
|
|
405
|
-
wc -l /tmp/home_impl.txt /tmp/target_impl.txt
|
|
406
|
-
diff /tmp/home_impl.txt /tmp/target_impl.txt | head -40
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
**Step 12 — Pattern sniping (recurring TARGET idioms absent from HOME)**
|
|
410
|
-
```bash
|
|
411
|
-
# Idioms seen 3+ times in TARGET but absent from HOME
|
|
412
|
-
|
|
413
|
-
# Example: if TARGET uses a registry pattern
|
|
414
|
-
ast-grep --pattern '$REGISTRY.insert($KEY, $VAL)' --lang rust # (run in TARGET)
|
|
415
|
-
ast-grep --pattern '$REGISTRY[$KEY] = $VAL' --lang python # (run in TARGET)
|
|
416
|
-
|
|
417
|
-
# Check if HOME has equivalent
|
|
418
|
-
ast-grep --pattern '$REGISTRY.insert($KEY, $VAL)' --lang rust # (run in HOME)
|
|
419
|
-
# If 0 results → this is a pattern gap
|
|
420
|
-
|
|
421
|
-
# Extract TARGET's registry pattern instances
|
|
422
|
-
ast-grep --pattern 'PATTERN' --lang rust --json | \
|
|
423
|
-
jq '.[] | {file: .file, line: .range.start.line, text: .text}' \
|
|
424
|
-
>> ./agent-state/snipe/SNIPE_EXTRACTS.jsonl
|
|
425
|
-
```
|
|
426
|
-
|
|
427
|
-
---
|
|
428
|
-
|
|
429
|
-
### Phase 4 — Artifact Generation `[ARTIFACT_UPDATE]`
|
|
430
|
-
|
|
431
|
-
All snipe findings are crystallised into locked artifacts.
|
|
432
|
-
|
|
433
|
-
**Required artifacts:**
|
|
434
|
-
|
|
435
|
-
| Artifact | Contents |
|
|
436
|
-
|---|---|
|
|
437
|
-
| `SNIPE_HOME_REGISTRY.md` | HOME symbol inventory, pattern fingerprint, gap map |
|
|
438
|
-
| `SNIPE_TARGET_OUTLINE.md` | TARGET symbol names, module structure (no implementations) |
|
|
439
|
-
| `SNIPE_RELEVANCE_MAP.md` | Scored symbol table, Tier A/B/C/Discarded |
|
|
440
|
-
| `SNIPE_EXTRACTS.jsonl` | Raw ast-grep output for Tier A/B symbols |
|
|
441
|
-
| `SNIPE_COMPARISON.md` | Final comparison: divergence, adoption cost, inspiration |
|
|
442
|
-
| `EVIDENCE_LOG.md` | All ast-grep command outputs (append-only, shared with codemunch) |
|
|
443
|
-
|
|
444
|
-
**Artifact write protocol:**
|
|
445
|
-
```bash
|
|
446
|
-
# Every snipe command appends to EVIDENCE_LOG
|
|
447
|
-
echo "## Snipe: fn parse_file (TARGET extractor.py)" >> ./agent-state/snipe/EVIDENCE_LOG.md
|
|
448
|
-
ast-grep --pattern 'def parse_file($$$):' --lang python --json \
|
|
449
|
-
>> ./agent-state/snipe/EVIDENCE_LOG.md
|
|
450
|
-
```
|
|
451
|
-
|
|
452
|
-
**Optional artifacts by intent:**
|
|
453
|
-
|
|
454
|
-
| Intent | Extra Artifact |
|
|
455
|
-
|---|---|
|
|
456
|
-
| `steal` | `ADOPTION_PLAN.md` — step-by-step integration into HOME |
|
|
457
|
-
| `compare` | `DIVERGENCE_ANALYSIS.md` — side-by-side of same-named symbols |
|
|
458
|
-
| `debug` | `BUG_TRIANGULATION.md` — TARGET's solution to HOME's bug |
|
|
459
|
-
| `integrate` | `INTERFACE_BRIDGE.md` — data schema + API contract between HOME and TARGET |
|
|
460
|
-
|
|
461
|
-
---
|
|
462
|
-
|
|
463
|
-
### Phase 5 — Synthesis `[VERIFICATION]`
|
|
464
|
-
|
|
465
|
-
Read ONLY the artifacts. Final reasoning pass over structured data, not raw code.
|
|
466
|
-
|
|
467
|
-
**Step 13 — Snipe self-verification checklist**
|
|
468
|
-
- [ ] `SNIPE_HOME_REGISTRY.md` contains ≥ 5 symbols (HOME is meaningfully mapped)
|
|
469
|
-
- [ ] `SNIPE_RELEVANCE_MAP.md` has at least 1 Tier A symbol
|
|
470
|
-
- [ ] Every Tier A symbol in `SNIPE_EXTRACTS.jsonl` has an evidence entry
|
|
471
|
-
- [ ] Tier C gap coverage attempted for all HOME TODO items
|
|
472
|
-
- [ ] Discarded symbol count is documented (proof that low-signal symbols were filtered)
|
|
473
|
-
- [ ] `SNIPE_COMPARISON.md` exists and contains a recommendation
|
|
474
|
-
|
|
475
|
-
**Step 14 — SNIPE_COMPARISON.md structure**
|
|
476
|
-
|
|
477
|
-
```markdown
|
|
478
|
-
# SNIPE_COMPARISON.md
|
|
479
|
-
|
|
480
|
-
## Executive Summary
|
|
481
|
-
HOME: <one sentence>
|
|
482
|
-
TARGET: <one sentence>
|
|
483
|
-
Overlap: <n> exact matches, <n> structural matches
|
|
484
|
-
Key Finding: <one sentence — what's the most important thing TARGET has?>
|
|
485
|
-
|
|
486
|
-
## Tier A Analysis (Direct Comparisons)
|
|
487
|
-
### `symbol_name`
|
|
488
|
-
- **HOME approach**: <2-3 sentences from HOME impl>
|
|
489
|
-
- **TARGET approach**: <2-3 sentences from TARGET impl>
|
|
490
|
-
- **Divergence**: <where/why they differ>
|
|
491
|
-
- **Recommendation**: adopt / adapt / ignore
|
|
492
|
-
|
|
493
|
-
## Tier C Gap Coverage (TARGET solves HOME TODOs)
|
|
494
|
-
| HOME Gap | TARGET Solution | Adoption Complexity |
|
|
495
|
-
|---|---|---|
|
|
496
|
-
|
|
497
|
-
## Pattern Gaps (TARGET idioms absent from HOME)
|
|
498
|
-
| Pattern | Frequency in TARGET | Adoption Note |
|
|
499
|
-
|---|---|---|
|
|
500
|
-
|
|
501
|
-
## Inspiration Extracts
|
|
502
|
-
<curated list of TARGET patterns worth considering, with ast-grep evidence refs>
|
|
503
|
-
```
|
|
504
|
-
|
|
505
|
-
**Step 15 — HANDOFF**
|
|
506
|
-
```json
|
|
507
|
-
{
|
|
508
|
-
"meta": { "timestamp": "<ISO8601>", "skill": "codesnipe", "session_id": "<uuid>" },
|
|
509
|
-
"transition": {
|
|
510
|
-
"from": "capability-research",
|
|
511
|
-
"to": "capability-spec",
|
|
512
|
-
"status": "READY_FOR_HANDOFF",
|
|
513
|
-
"reason": "Dual-codebase comparison complete. Adoption candidates identified."
|
|
514
|
-
},
|
|
515
|
-
"payload": {
|
|
516
|
-
"primary_artifact": "./agent-state/snipe/SNIPE_COMPARISON.md",
|
|
517
|
-
"home_registry": "./agent-state/snipe/SNIPE_HOME_REGISTRY.md",
|
|
518
|
-
"target_outline": "./agent-state/snipe/SNIPE_TARGET_OUTLINE.md",
|
|
519
|
-
"relevance_map": "./agent-state/snipe/SNIPE_RELEVANCE_MAP.md",
|
|
520
|
-
"evidence_pointer": "./agent-state/snipe/EVIDENCE_LOG.md",
|
|
521
|
-
"tier_a_count": "<n>",
|
|
522
|
-
"adoption_candidates": ["<symbol1>", "<symbol2>"]
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
```
|
|
526
|
-
|
|
527
|
-
---
|
|
528
|
-
|
|
529
|
-
## 4. Intent-Specific Modes
|
|
530
|
-
|
|
531
|
-
### `--intent steal`
|
|
532
|
-
Focus: Extract and integrate a specific TARGET pattern into HOME.
|
|
533
|
-
- Phase 0–1 run as normal.
|
|
534
|
-
- Phase 2: Restrict scoring to symbols related to the stated feature.
|
|
535
|
-
- Phase 3: Extract full implementation + dependencies.
|
|
536
|
-
- Phase 4+: Generate `ADOPTION_PLAN.md` with interface changes needed in HOME.
|
|
537
|
-
|
|
538
|
-
### `--intent compare`
|
|
539
|
-
Focus: Understand how TARGET solves a problem HOME also solves.
|
|
540
|
-
- Run Phase 0–3 fully.
|
|
541
|
-
- Phase 4: Generate `DIVERGENCE_ANALYSIS.md` for every Tier A symbol.
|
|
542
|
-
- Emphasis: WHY do they differ, not just HOW.
|
|
543
|
-
|
|
544
|
-
### `--intent debug`
|
|
545
|
-
Focus: HOME has a bug; TARGET may have fixed it.
|
|
546
|
-
- Phase 0: Map HOME bug site via ast-grep (find the failing pattern).
|
|
547
|
-
- Phase 1: Search TARGET for same pattern, look for fixes.
|
|
548
|
-
- Phase 2: Score TARGET fixes by structural similarity to HOME's bug site.
|
|
549
|
-
- Phase 4: Generate `BUG_TRIANGULATION.md`.
|
|
550
|
-
|
|
551
|
-
```bash
|
|
552
|
-
# Snipe a specific bug pattern in TARGET
|
|
553
|
-
# Example: HOME has panics on unwrap(), does TARGET handle this better?
|
|
554
|
-
ast-grep --pattern '$EXPR.unwrap()' --lang rust # (HOME: find all panic sites)
|
|
555
|
-
ast-grep --pattern '$EXPR.unwrap()' --lang rust # (TARGET: compare frequency)
|
|
556
|
-
ast-grep --pattern '$EXPR.unwrap_or($DEFAULT)' --lang rust # (TARGET: safer pattern?)
|
|
557
|
-
ast-grep --pattern 'match $EXPR { Ok($V) => $OK, Err($E) => $ERR }' --lang rust
|
|
558
|
-
```
|
|
559
|
-
|
|
560
|
-
### `--intent integrate`
|
|
561
|
-
Focus: HOME needs to consume or extend TARGET as a library/module.
|
|
562
|
-
- Phase 0: Map HOME's consumption points (where would TARGET connect?).
|
|
563
|
-
- Phase 1: Map TARGET's public API surface (exports, entry points only).
|
|
564
|
-
- Phase 2: Score TARGET exports against HOME consumption points.
|
|
565
|
-
- Phase 4: Generate `INTERFACE_BRIDGE.md` with schema + integration plan.
|
|
566
|
-
|
|
567
|
-
---
|
|
568
|
-
|
|
569
|
-
## 5. ast-grep Snipe Commands Reference
|
|
570
|
-
|
|
571
|
-
### Surgical Symbol Extraction (Tier A reads)
|
|
572
|
-
```bash
|
|
573
|
-
# Named function (any language variant)
|
|
574
|
-
ast-grep --pattern 'fn TARGET_FN($$$) { $$$ }' --lang rust
|
|
575
|
-
ast-grep --pattern 'def TARGET_FN($$$): $$$' --lang python
|
|
576
|
-
ast-grep --pattern 'function TARGET_FN($$$) { $$$ }' --lang ts
|
|
577
|
-
ast-grep --pattern 'TARGET_FN($$$): $RET { $$$ }' --lang ts # method
|
|
578
|
-
|
|
579
|
-
# Named type/class
|
|
580
|
-
ast-grep --pattern 'struct TARGET_TYPE { $$$ }' --lang rust
|
|
581
|
-
ast-grep --pattern 'class TARGET_CLASS: $$$' --lang python
|
|
582
|
-
ast-grep --pattern 'interface TARGET_IFACE { $$$ }' --lang ts
|
|
583
|
-
```
|
|
584
|
-
|
|
585
|
-
### Cross-Codebase Pattern Search
|
|
586
|
-
```bash
|
|
587
|
-
# Run identical patterns in both HOME and TARGET; compare match counts
|
|
588
|
-
# HOME:
|
|
589
|
-
cd <HOME_PATH> && ast-grep --pattern '$EXPR?' --lang rust --json | jq length
|
|
590
|
-
# TARGET:
|
|
591
|
-
cd <TARGET_PATH> && ast-grep --pattern '$EXPR?' --lang rust --json | jq length
|
|
592
|
-
# If TARGET has 5× more ? usage → different error philosophy
|
|
593
|
-
```
|
|
594
|
-
|
|
595
|
-
### Relevance Scoring Helpers
|
|
596
|
-
```bash
|
|
597
|
-
# Count shared symbol names between HOME and TARGET registries
|
|
598
|
-
comm -12 \
|
|
599
|
-
<(jq -r '.name' ./agent-state/snipe/HOME_REGISTRY.jsonl | sort -u) \
|
|
600
|
-
<(jq -r '.name' ./agent-state/snipe/TARGET_OUTLINE.jsonl | sort -u) \
|
|
601
|
-
| wc -l
|
|
602
|
-
|
|
603
|
-
# List all shared names
|
|
604
|
-
comm -12 \
|
|
605
|
-
<(jq -r '.name' ./agent-state/snipe/HOME_REGISTRY.jsonl | sort -u) \
|
|
606
|
-
<(jq -r '.name' ./agent-state/snipe/TARGET_OUTLINE.jsonl | sort -u)
|
|
607
|
-
```
|
|
608
|
-
|
|
609
|
-
---
|
|
610
|
-
|
|
611
|
-
## 6.1 Wrong-Stuff Protocol
|
|
612
|
-
|
|
613
|
-
When comparison reveals issues:
|
|
614
|
-
|
|
615
|
-
| Finding | Classification | Route To |
|
|
616
|
-
|---|---|---|
|
|
617
|
-
| HOME symbol contradicts its own spec | `spec_violation` | `agent-spec` |
|
|
618
|
-
| TARGET pattern reveals HOME implementation gap | `implementation_bug` | `agent-builder` |
|
|
619
|
-
| HOME registry incomplete for comparison | `invalid_source` | re-run Phase 0 |
|
|
620
|
-
| HOME documentation mismatches code structure | `documentation_drift` | `agent-docs` |
|
|
621
|
-
|
|
622
|
-
## 6.2 Anti-Patterns
|
|
623
|
-
|
|
624
|
-
| Anti-Pattern | Correct Behavior |
|
|
625
|
-
|---|---|
|
|
626
|
-
| Reading TARGET without HOME registry | Build HOME registry first (Phase 0); always |
|
|
627
|
-
| Reading symbols scoring < 8 | Discard; log to `KNOWN_UNKNOWNS` only |
|
|
628
|
-
| Comparing without intent parameter | Intent controls scoring weights; always specify |
|
|
629
|
-
| Spraying reads across all TARGET files | Snipe only scored, ranked symbols |
|
|
630
|
-
| Session ends without `SNIPE_COMPARISON.md` | Every session produces comparison artifact |
|
|
631
|
-
|
|
632
|
-
---
|
|
633
|
-
|
|
634
|
-
## 6. Failure Modes & Circuit Breakers
|
|
635
|
-
|
|
636
|
-
| Failure | Signal | Recovery |
|
|
637
|
-
|---|---|---|
|
|
638
|
-
| HOME registry empty | Gate blocks Phase 1 | Re-run Phase 0 with correct HOME path |
|
|
639
|
-
| All TARGET symbols score < 8 | Zero Tier A/B symbols | Log to DECISIONS.md: "TARGET unrelated to HOME"; abort |
|
|
640
|
-
| TARGET language ≠ HOME language | Phase 2 scoring can't use signatures | Score by name and pattern concept only; flag in SNIPE_COMPARISON.md |
|
|
641
|
-
| Target is too large (>500 files) | Outline phase takes too long | Restrict to top-level modules only; flag as `PARTIAL_SNIPE` |
|
|
642
|
-
| Intent changes mid-session | New focus discovered | Re-enter Phase 2 with updated scoring weights; do NOT re-run Phase 0 |
|
|
643
|
-
|
|
644
|
-
---
|
|
38
|
+
- `agent-state/snipe/SNIPE_HOME_REGISTRY.md`
|
|
39
|
+
- `agent-state/snipe/SNIPE_TARGET_OUTLINE.md`
|
|
40
|
+
- `agent-state/snipe/SNIPE_RELEVANCE_MAP.md`
|
|
41
|
+
- `agent-state/snipe/SNIPE_EXTRACTS.jsonl`
|
|
42
|
+
- `agent-state/snipe/SNIPE_COMPARISON.md`
|
|
645
43
|
|
|
646
|
-
##
|
|
44
|
+
## Validation
|
|
647
45
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
46
|
+
- Verify the HOME registry exists before any TARGET implementation read occurs.
|
|
47
|
+
- Verify every discussed TARGET symbol has a recorded relevance score in `SNIPE_RELEVANCE_MAP.md`.
|
|
48
|
+
- Verify the final comparison artifact contains at least one explicit recommendation: adopt, adapt, ignore, or unrelated.
|
|
651
49
|
|
|
652
|
-
|
|
653
|
-
```bash
|
|
654
|
-
# Study how fastapi handles dependency injection vs our framework
|
|
655
|
-
snipe --home ./myapi --target fastapi/fastapi --intent compare
|
|
50
|
+
## References
|
|
656
51
|
|
|
657
|
-
|
|
658
|
-
snipe --home ./build-tool --target ./jcodemunch-mcp --intent steal
|
|
52
|
+
- `references/dual-codebase-playbook.md` preserves the detailed scoring formula, phase recipes, and intent-specific extraction playbooks.
|
|
659
53
|
|
|
660
|
-
|
|
661
|
-
snipe --home ./myparser --target nom-rs/nom --intent debug
|
|
54
|
+
## Compatibility
|
|
662
55
|
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
56
|
+
- `SKILL.md` is the canonical portable contract for this skill.
|
|
57
|
+
- The detailed comparison cookbook lives under `references/` for progressive disclosure and should not replace the top-level contract.
|
|
58
|
+
- The workflow remains portable anywhere HOME/TARGET code can be queried structurally with ast-grep and basic shell tooling.
|
|
666
59
|
|
|
667
|
-
|
|
668
|
-
score all symbols, extract only what earned it, and produce `SNIPE_COMPARISON.md`
|
|
669
|
-
with concrete adoption recommendations.
|
|
60
|
+
## Failure Policy
|
|
670
61
|
|
|
671
|
-
|
|
62
|
+
- If the HOME registry is empty or cannot be built, halt before reading TARGET implementations.
|
|
63
|
+
- If all TARGET symbols score below the threshold, report that the TARGET is unrelated or low-yield instead of forcing comparison.
|
|
64
|
+
- Do not read or summarize unscored TARGET symbols; treat that as a protocol violation.
|