@sniper.ai/core 3.0.0 → 3.1.0

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.
@@ -12,7 +12,7 @@ phases:
12
12
  checklist: ingest-scan
13
13
  human_approval: false
14
14
  outputs:
15
- - docs/codebase-overview.md
15
+ - .sniper/artifacts/codebase-overview.md # Living master doc — not per-protocol
16
16
 
17
17
  - name: document
18
18
  description: Generate documentation from code analysis
@@ -23,7 +23,7 @@ phases:
23
23
  checklist: ingest-document
24
24
  human_approval: false
25
25
  outputs:
26
- - docs/spec.md
26
+ - .sniper/artifacts/spec.md # Living master doc — not per-protocol
27
27
 
28
28
  - name: extract
29
29
  description: Extract conventions, patterns, and anti-patterns
@@ -36,4 +36,7 @@ phases:
36
36
  outputs:
37
37
  - .sniper/conventions.yaml
38
38
 
39
+ # Note: ingest protocols write to master docs (.sniper/artifacts/spec.md, .sniper/artifacts/codebase-overview.md)
40
+ # rather than per-protocol directories (.sniper/artifacts/{protocol_id}/). A meta.yaml and registry entry
41
+ # are still created by /sniper-flow, but the artifact directory may be empty.
39
42
  auto_retro: false
@@ -25,6 +25,6 @@ phases:
25
25
  checklist: review
26
26
  human_approval: true
27
27
  outputs:
28
- - docs/review-report.md
28
+ - .sniper/artifacts/{protocol_id}/review-report.md
29
29
 
30
30
  auto_retro: false # Patches are too small for retros
@@ -8,11 +8,12 @@ phases:
8
8
  agents:
9
9
  - analyst
10
10
  spawn_strategy: single
11
+ interactive_review: true # Let user review the analysis before refactoring
11
12
  gate:
12
13
  checklist: refactor-analyze
13
14
  human_approval: false
14
15
  outputs:
15
- - docs/spec.md
16
+ - .sniper/artifacts/{protocol_id}/plan.md # Analysis/plan for this refactor
16
17
 
17
18
  - name: implement
18
19
  description: Apply refactoring changes
@@ -20,6 +21,7 @@ phases:
20
21
  - fullstack-dev
21
22
  spawn_strategy: single
22
23
  plan_approval: false
24
+ doc_sync: true # Run doc-writer after this phase to update living docs
23
25
  gate:
24
26
  checklist: implement
25
27
  human_approval: false
@@ -36,6 +38,6 @@ phases:
36
38
  checklist: review
37
39
  human_approval: true
38
40
  outputs:
39
- - docs/review-report.md
41
+ - .sniper/artifacts/{protocol_id}/review-report.md
40
42
 
41
43
  auto_retro: true
@@ -0,0 +1,58 @@
1
+ $schema: "https://json-schema.org/draft/2020-12/schema"
2
+ $id: "https://sniper.ai/schemas/protocol-meta"
3
+ title: ProtocolMeta
4
+ description: Metadata for a protocol run, stored at .sniper/artifacts/{protocol_id}/meta.yaml.
5
+ type: object
6
+ required:
7
+ - id
8
+ - protocol
9
+ - status
10
+ - started
11
+ properties:
12
+ id:
13
+ type: string
14
+ pattern: "^SNPR-\\d{8}-[a-f0-9]{4}$"
15
+ description: Timestamp-based protocol ID (e.g., SNPR-20260307-a3f2).
16
+ protocol:
17
+ type: string
18
+ description: Protocol name (full, feature, patch, etc.).
19
+ description:
20
+ type: string
21
+ description: Human-readable description of what this protocol run does.
22
+ status:
23
+ type: string
24
+ enum: [in_progress, completed, failed, cancelled]
25
+ description: Current status of the protocol run.
26
+ started:
27
+ type: string
28
+ format: date-time
29
+ description: ISO 8601 timestamp of when the protocol started.
30
+ completed:
31
+ type: string
32
+ format: date-time
33
+ description: ISO 8601 timestamp of when the protocol completed.
34
+ agents:
35
+ type: array
36
+ items:
37
+ type: string
38
+ description: List of agent names used in this run.
39
+ token_usage:
40
+ type: integer
41
+ minimum: 0
42
+ description: Total tokens consumed during this run.
43
+ gate_results:
44
+ type: object
45
+ additionalProperties:
46
+ type: string
47
+ enum: [pass, fail]
48
+ description: Gate results per phase.
49
+ stories_count:
50
+ type: integer
51
+ minimum: 0
52
+ description: Number of stories created.
53
+ commits:
54
+ type: array
55
+ items:
56
+ type: string
57
+ description: Git commit SHAs produced during this run.
58
+ additionalProperties: true
@@ -18,226 +18,179 @@ arguments:
18
18
 
19
19
  You are the SNIPER protocol execution engine. You orchestrate agent teams through structured phases to deliver work products.
20
20
 
21
- ## Protocol Selection
21
+ ## 1. Select Protocol
22
22
 
23
- If `--protocol` is specified, use it directly. Otherwise, auto-detect:
24
-
25
- 1. Read `.sniper/config.yaml` for routing rules
26
- 2. If this is a new project (no source files), use `full`
27
- 3. If resuming (`--resume`), read the last checkpoint to determine protocol
28
- 4. Otherwise, estimate scope:
29
- - Analyze the user's request complexity
30
- - `hotfix` — Critical/urgent production fix ("critical", "urgent", "production down", "hotfix")
31
- - `patch` — Bug fix or small change (< 5 files likely affected)
32
- - `feature` — New feature or significant enhancement (5-20 files)
33
- - `full` — New project, major rework, or multi-component change (20+ files)
34
- - `ingest` — User wants to understand/document an existing codebase
35
- - `explore` — Exploratory analysis, understanding, or research ("what is", "how does", "analyze", "explore")
36
- - `refactor` — Code improvement without new features ("refactor", "clean up", "improve", "reorganize")
37
-
38
- Announce the selected protocol and ask for confirmation before proceeding.
39
-
40
- ### Trigger Table Evaluation
41
-
42
- After auto-detection, evaluate trigger tables from `.sniper/config.yaml`:
43
-
44
- 1. Read `triggers` array from config
45
- 2. Get changed files via `git diff --name-only` (or `git status` for new files)
46
- 3. For each trigger entry, glob-match changed files against `pattern`
47
- 4. If a trigger matches:
48
- - If `protocol` is specified, it can override the auto-detected protocol
49
- - If `agent` is specified, that agent is added to the phase's agent list
50
- 5. Trigger matches are additive — they refine the selection, not replace it
51
- 6. Log which triggers matched and what they changed
52
-
53
- ## Resume Support
54
-
55
- When `--resume` is specified:
56
- 1. Read the latest checkpoint from `.sniper/checkpoints/`
57
- 2. Determine which phase was in progress and which agents were active
58
- 3. Re-spawn agents that had incomplete tasks
59
- 4. Continue from the checkpoint state
60
-
61
- ## Protocol Resolution (Custom Protocols — Feature 6)
23
+ ```
24
+ --protocol given? → Use it directly
25
+ --resume given? → Read latest checkpoint from .sniper/checkpoints/, resume from that phase
26
+ --phase given? → Use auto-detected protocol, skip to specified phase
27
+ Otherwise → Auto-detect (see below), confirm with user before proceeding
28
+ ```
62
29
 
63
- When resolving a protocol name, check in order:
64
- 1. `.sniper/protocols/<name>.yaml` User-defined custom protocols take priority
65
- 2. Core protocols from `@sniper.ai/core/protocols/<name>.yaml` — Built-in protocols
30
+ **Auto-detection** match user intent, no file reads needed:
31
+ | Keywords | Protocol |
32
+ |----------|----------|
33
+ | "critical", "urgent", "production down", "hotfix" | `hotfix` |
34
+ | Bug fix, small change (< 5 files) | `patch` |
35
+ | New feature, significant enhancement | `feature` |
36
+ | New project, major rework, multi-component | `full` |
37
+ | Understand, document existing codebase | `ingest` |
38
+ | "what is", "how does", "analyze", research | `explore` |
39
+ | "refactor", "clean up", "improve", "reorganize" | `refactor` |
66
40
 
67
- This allows users to override built-in protocols or define entirely new ones.
41
+ After auto-detection, check trigger tables: run `git diff --name-only` and match against `.sniper/config.yaml` `triggers` section. Trigger overrides take precedence.
68
42
 
69
- ## Phase Execution Loop
43
+ **Protocol resolution order:** `.sniper/protocols/<name>.yaml` (custom) → `@sniper.ai/core/protocols/<name>.yaml` (built-in).
70
44
 
71
- For each phase in the protocol:
45
+ ## 2. Initialize Protocol
72
46
 
73
- ### 0. Pre-Phase Setup
47
+ 1. **Generate protocol ID:** `SNPR-YYYYMMDD-XXXX` where XXXX is a random 4-char hex suffix (e.g., `SNPR-20260307-a3f2`). No registry parsing needed.
48
+ 2. **Create artifact directory:** `mkdir -p .sniper/artifacts/{protocol_id}/`
49
+ 3. **Write metadata:** Create `.sniper/artifacts/{protocol_id}/meta.yaml` with id, protocol, description, status: in_progress, started timestamp.
50
+ 4. **Append to registry:** Add a row to `.sniper/artifacts/registry.md`. If registry doesn't exist, create it with a header row first.
74
51
 
75
- **Load Workspace Context (Feature 1):**
76
- If a workspace exists (`.sniper-workspace/` in a parent directory):
77
- 1. Read `.sniper-workspace/config.yaml`
78
- 2. Extract `shared.conventions` and `shared.anti_patterns`
79
- 3. These will be injected into agent context in step 2
52
+ ## 3. Phase Execution Loop
80
53
 
81
- **Load Relevant Signals (Feature 8):**
82
- 1. Read `.sniper/memory/signals/` for signal records
83
- 2. Match signals by `affected_files` (files that will be touched in this phase) and `relevance_tags`
84
- 3. Select top 10 most relevant signals
85
- 4. These will be injected as "## Recent Learnings" in agent context in step 2
54
+ For each phase in the protocol, execute these 5 steps:
86
55
 
87
- **Check Workspace Conflicts (Feature 5):**
88
- If a workspace exists:
89
- 1. Check `.sniper-workspace/locks/` for advisory file locks
90
- 2. If any files that this phase's agents will modify are locked by another project, flag the conflict
91
- 3. Present conflicts to the user and wait for resolution before proceeding
92
- 4. Acquire advisory locks for files this phase will modify
56
+ ### Setup
93
57
 
94
- ### 1. Read Phase Configuration
95
- ```
96
- Read the protocol YAML get phase definition
97
- Read .sniper/config.yaml get agent config, ownership, commands
98
- Read .sniper/memory/velocity.yaml → check for calibrated budget (if exists)
99
- ```
58
+ 1. Read protocol YAML for the current phase definition
59
+ 2. Read `.sniper/config.yaml` for agent config, ownership, commands
60
+ 3. Check `.sniper/memory/velocity.yaml` for calibrated budget use it if available, otherwise use configured budget. Log which source is used.
61
+ 4. Compose agents per [Reference: Agent Composition](#reference-agent-composition)
100
62
 
101
- **Velocity-Aware Budget Selection:**
102
- - Check `.sniper/memory/velocity.yaml` for a `calibrated_budget` for the current protocol
103
- - If a calibrated budget exists and differs from the configured budget, use the calibrated budget
104
- - Log which budget source is being used: "Using calibrated budget (X tokens)" or "Using configured budget (X tokens)"
105
- - The calibrated budget takes precedence over `config.routing.budgets`
106
-
107
- ### 2. Compose Agents
108
- For each agent in the phase:
109
- 1. Read the base agent definition from `.claude/agents/<name>.md`
110
- 2. Check config for mixins: `config.agents.mixins.<agent-name>`
111
- 3. If mixins exist, read each mixin from `.claude/personas/cognitive/<mixin>.md`
112
- 4. The agent's full prompt = base definition + concatenated mixins
113
-
114
- **Load Domain Knowledge (Feature 9):**
115
- After composing the base agent:
116
- 1. Check if the agent definition has a `knowledge_sources` field in its YAML frontmatter
117
- 2. If present, read `.sniper/knowledge/manifest.yaml`
118
- 3. For each source referenced by the agent, read the corresponding file from `.sniper/knowledge/`
119
- 4. Truncate content to stay within `config.knowledge.max_total_tokens` (default: 50000 tokens)
120
- 5. Append matched knowledge as `## Domain Knowledge` section in the agent's prompt
121
-
122
- **Inject Workspace Conventions (Feature 1):**
123
- If workspace conventions were loaded in step 0:
124
- 1. Append shared conventions as `## Workspace Conventions` section
125
- 2. Append anti-patterns as `## Anti-Patterns (Workspace)` section
126
-
127
- **Inject Recent Signals (Feature 8):**
128
- If relevant signals were loaded in step 0:
129
- 1. Format each signal as: `- [<type>] <summary> (<affected_files>)`
130
- 2. Append as `## Recent Learnings` section in the agent's prompt
131
-
132
- ### 3. Determine Spawn Strategy
133
- Based on the protocol's `spawn_strategy` for this phase:
134
- - `single` — Use the Task tool directly (one agent, no team overhead)
135
- - `team` — Use TeamCreate + Task tool (multiple agents working in parallel)
136
-
137
- ### 4. Spawn Agents
138
- For `single` spawn:
139
- ```
140
- Task tool with:
141
- - subagent_type: general-purpose
142
- - model: from agent frontmatter or config default
143
- - prompt: composed agent prompt + task assignment
144
- - mode: "plan" if plan_approval is true, else "bypassPermissions"
145
- - isolation: "worktree" if agent has isolation: worktree
146
- ```
63
+ ### Execute
147
64
 
148
- For `team` spawn:
149
- ```
150
- TeamCreate create team for this phase
151
- TaskCreate create tasks with dependencies from protocol
152
- Task tool spawn each teammate with team_name
153
- ```
65
+ 1. Determine spawn strategy from protocol phase definition (`single`, `sequential`, `parallel`, or `team`)
66
+ 2. Spawn agents per [Reference: Spawn Strategies](#reference-spawn-strategies)
67
+ 3. Monitor via TaskList if an agent is blocked, investigate and guide via SendMessage
68
+ 4. If an agent crashes: note the failure, continue with remaining agents
69
+ 5. After all parallel agents complete: coordinate worktree merges per [Reference: Merge Coordination](#reference-merge-coordination)
154
70
 
155
- ### 5. Monitor Progress
156
- - Use TaskList to monitor agent task completion
157
- - If an agent is blocked, investigate and provide guidance via SendMessage
158
- - If an agent fails, note the failure and continue with other agents
71
+ ### Checkpoint
159
72
 
160
- ### 6. Write Checkpoint
161
- After all agents complete (or fail), write a checkpoint:
73
+ Write checkpoint to `.sniper/checkpoints/{protocol_id}-{phase}-{timestamp}.yaml`:
162
74
  ```yaml
163
- # .sniper/checkpoints/<protocol>-<phase>-<timestamp>.yaml
164
75
  protocol: <name>
76
+ protocol_id: <SNPR-YYYYMMDD-XXXX>
165
77
  phase: <phase>
166
78
  timestamp: <ISO 8601>
167
79
  status: completed | failed
168
80
  agents: [status per agent]
169
81
  token_usage: [phase + cumulative]
170
- commits: [git SHAs produced during this phase]
82
+ commits: [git SHAs produced]
171
83
  ```
172
84
 
173
- **Record Git Commits (Feature 2):**
174
- After agents complete, capture commits for logical revert support:
175
- 1. Run `git log --oneline <start-sha>..HEAD` to find new commits since the phase started
176
- 2. Record each commit's SHA, message, and the agent that produced it
177
- 3. Include the `commits` array in the checkpoint YAML
85
+ Update `.sniper/live-status.yaml` with current phase, agent statuses, and cost percentage.
86
+
87
+ ### Gate
178
88
 
179
- ### 7. Run Gate
180
- Trigger the gate-reviewer for this phase:
181
- 1. Write `.sniper/pending-gate.yaml` with the phase name and checklist reference
182
- 2. Spawn gate-reviewer agent (or let the Stop hook trigger it)
183
- 3. Read the gate result from `.sniper/gates/`
89
+ 1. Write `.sniper/pending-gate.yaml` with phase name and checklist reference
90
+ 2. Spawn gate-reviewer agent with the `{protocol_id}` for path resolution
91
+ 3. Read gate result from `.sniper/gates/`
92
+ 4. **If phase has `interactive_review: true`:** present artifacts for review per [Reference: Interactive Review](#reference-interactive-review). User must explicitly approve before advancing.
93
+ 5. **Gate pass + `human_approval: false`:** advance
94
+ 6. **Gate pass + `human_approval: true` + not already approved via interactive review:** present results, wait for approval
95
+ 7. **Gate pass + `human_approval: true` + already approved via interactive review:** advance (don't ask twice)
96
+ 8. **Gate fail:** identify blocking failures, reassign to appropriate agents, re-run gate. After 3 failures: escalate to user.
184
97
 
185
- ### 8. Process Gate Result
186
- - If gate passes AND `human_approval: false` → advance to next phase
187
- - If gate passes AND `human_approval: true` → present results to user, wait for approval
188
- - If gate fails → identify blocking failures, reassign to appropriate agents, re-run gate
98
+ ### Advance
189
99
 
190
- ### 9. Advance Phase
191
- Move to the next phase in the protocol. If this was the last phase, complete the protocol.
100
+ 1. If phase has `doc_sync: true`: spawn `doc-writer` agent to update `CLAUDE.md`, `README.md`, and `docs/architecture.md` based on the git diff from this phase. Use `Edit` for surgical updates.
101
+ 2. Move to next phase. If this was the last phase, go to [Protocol Completion](#4-protocol-completion).
192
102
 
193
- ## Protocol Completion
103
+ ## 4. Protocol Completion
194
104
 
195
- When all phases complete:
196
105
  1. Write final checkpoint
197
106
  2. Update `.sniper/live-status.yaml` with `status: completed`
198
- 3. If `auto_retro: true` in the protocol, trigger retro-analyst
199
- 4. Present summary to user: phases completed, gate results, token usage
107
+ 3. Update `.sniper/artifacts/{protocol_id}/meta.yaml` with final status, token usage, commits, agents used
108
+ 4. Update `.sniper/artifacts/registry.md` entry from `in_progress` to `completed`
109
+ 5. Present summary: phases completed, gate results, token usage
110
+ 6. If `auto_retro: true` in protocol: spawn `retro-analyst` as background task (see [Reference: Retrospective](#reference-retrospective))
200
111
 
201
112
  ## Cost Tracking
202
113
 
203
- Throughout execution:
204
- 1. Maintain `.sniper/cost.yaml` with token usage per phase and agent
205
- 2. At each checkpoint, check usage against budget thresholds:
206
- - `warn_threshold` Log a warning but continue
207
- - `soft_cap` — Pause and ask user whether to continue
208
- - `hard_cap` — Stop execution, save checkpoint for potential resume
209
- 3. Read thresholds from `.sniper/config.yaml` cost section
210
-
211
- ## Merge Coordination
212
-
213
- For agents working in worktrees:
214
- 1. After all implementation agents complete, attempt to merge each worktree
215
- 2. If merge conflicts occur:
216
- - Identify conflicting files
217
- - Assign conflict resolution to the agent who owns the conflicting files
218
- - Re-run tests after resolution
219
- 3. The orchestrator coordinates merges — agents never merge their own worktrees
220
-
221
- ## Live Status Updates
222
-
223
- Keep `.sniper/live-status.yaml` current:
224
- - Update `current_phase` and agent statuses as work progresses
225
- - Update `cost.percent` at checkpoints
226
- - Set `next_action` to a human-readable description of what's happening
114
+ Maintain `.sniper/cost.yaml` throughout execution. At each checkpoint:
115
+ - `warn_threshold` log warning, continue
116
+ - `soft_cap` pause, ask user whether to continue
117
+ - `hard_cap` checkpoint and stop gracefully
227
118
 
228
- ## Error Handling
229
-
230
- - If an agent crashes, note the failure and checkpoint state
231
- - If a gate fails 3 times, escalate to the user with a summary of failures
232
- - If cost exceeds hard cap, save checkpoint and stop gracefully
233
- - Never lose work — always checkpoint before stopping
119
+ Read thresholds from `.sniper/config.yaml` cost section.
234
120
 
235
121
  ## Rules
236
122
 
237
- - ALWAYS read `.sniper/config.yaml` before spawning any agent
123
+ - ALWAYS generate a protocol ID and create `.sniper/artifacts/{protocol_id}/` before spawning any agent
238
124
  - ALWAYS checkpoint between phases
239
125
  - ALWAYS respect token budgets
126
+ - ALWAYS present the plan for interactive review when `interactive_review: true`
240
127
  - NEVER skip a gate — every phase transition goes through its gate
241
128
  - NEVER advance past a failed blocking gate check
242
129
  - NEVER implement code yourself — delegate all work to agents
243
130
  - When `human_approval` is required, present clear options and wait
131
+
132
+ ---
133
+
134
+ ## Reference: Agent Composition
135
+
136
+ For each agent in the phase, build the full prompt by layering these sources. Each layer is optional except the base.
137
+
138
+ | Layer | Source | If missing |
139
+ |-------|--------|------------|
140
+ | 1. Base agent | `.claude/agents/<name>.md` | FATAL — abort phase |
141
+ | 2. Mixins | `.claude/personas/cognitive/<mixin>.md` (from `config.agents.mixins.<agent>`) | WARN — skip mixin, continue |
142
+ | 3. Domain knowledge | `.sniper/knowledge/manifest.yaml` → referenced files (from agent's `knowledge_sources` frontmatter) | SKIP — no knowledge section |
143
+ | 4. Workspace conventions | `.sniper-workspace/config.yaml` → `shared.conventions` and `shared.anti_patterns` | SKIP — no workspace section |
144
+ | 5. Signals | `.sniper/memory/signals/` → top 10 most relevant by `affected_files` and `relevance_tags` | SKIP — no signals section |
145
+
146
+ The composed prompt = base definition + concatenated mixin content + `## Domain Knowledge` section + `## Workspace Conventions` section + `## Anti-Patterns (Workspace)` section + `## Recent Learnings` section (formatted as `- [<type>] <summary> (<affected_files>)`).
147
+
148
+ Replace all `{protocol_id}` placeholders in the composed prompt with the actual protocol ID.
149
+
150
+ Truncate domain knowledge content to stay within `config.knowledge.max_total_tokens` (default: 50000 tokens).
151
+
152
+ ## Reference: Spawn Strategies
153
+
154
+ **`single`** — One agent via Task tool. No team overhead.
155
+ ```
156
+ Task tool: prompt = composed agent prompt + task assignment
157
+ mode: "plan" if plan_approval is true, else "bypassPermissions"
158
+ isolation: "worktree" if agent has isolation: worktree
159
+ ```
160
+
161
+ **`sequential`** — Agents run one-after-another via Task tool. Output from each feeds into the next as context.
162
+
163
+ **`parallel`** — Agents run concurrently via Task tool with `run_in_background: true`. Each agent works in its own worktree. Wait for all to complete.
164
+
165
+ **`team`** — Full Agent Team via TeamCreate + shared task list + messaging. Use for large work requiring inter-agent coordination during execution.
166
+ ```
167
+ TeamCreate → create team for this phase
168
+ TaskCreate → create tasks with dependencies from protocol
169
+ Task tool → spawn each teammate with team_name
170
+ ```
171
+
172
+ ## Reference: Merge Coordination
173
+
174
+ For agents working in worktrees (after all implementation agents complete):
175
+ 1. Attempt to merge each worktree
176
+ 2. If merge conflicts: identify conflicting files, assign resolution to the file owner, re-run tests after resolution
177
+ 3. The orchestrator coordinates merges — agents never merge their own worktrees
178
+
179
+ ## Reference: Interactive Review
180
+
181
+ When a phase has `interactive_review: true`:
182
+
183
+ 1. Read produced artifacts from `.sniper/artifacts/{protocol_id}/` (e.g., `plan.md`, `prd.md`, `stories/`)
184
+ 2. Present a structured summary: key architectural decisions, component overview, story count, open questions
185
+ 3. Offer options:
186
+ - **Approve** — continue to next phase
187
+ - **Request changes** — describe changes (architect/PM will revise, then re-present)
188
+ - **Edit directly** — user modifies plan files, says "done", re-validate via gate
189
+ 4. Only advance after explicit user approval
190
+
191
+ ## Reference: Retrospective
192
+
193
+ When `auto_retro: true`, after protocol completion:
194
+ 1. Spawn `retro-analyst` as a background Task with: protocol ID, checkpoint history, gate results, cost data
195
+ 2. The retro-analyst writes a report to `.sniper/retros/{protocol_id}.yaml`, updates `.sniper/memory/velocity.yaml` with execution metrics, and calculates calibrated budgets if 5+ data points exist
196
+ 3. Runs in background — user doesn't wait for it
@@ -76,7 +76,6 @@ Create the following directory structure:
76
76
  .claude/
77
77
  agents/ ← Copied from @sniper.ai/core/agents/
78
78
  settings.json ← Merge hooks from @sniper.ai/core/hooks/
79
- docs/
80
79
  CLAUDE.md ← Generated from template
81
80
  ```
82
81
 
@@ -16,7 +16,7 @@ gate_result: null # null if gate not yet run
16
16
  # blocking_failures: 0
17
17
 
18
18
  artifacts_produced: []
19
- # - path: docs/spec.md
19
+ # - path: .sniper/artifacts/spec.md
20
20
  # status: draft | complete
21
21
 
22
22
  token_usage:
@@ -49,7 +49,7 @@ phases:
49
49
  # outputs (optional): Expected artifacts this phase produces.
50
50
  # Used for tracking and checkpoint reporting.
51
51
  outputs:
52
- - docs/design.md
52
+ - .sniper/artifacts/{protocol_id}/design.md
53
53
 
54
54
  # ── Phase 2: Implement ─────────────────────────────────────
55
55
  - name: implement
@@ -91,7 +91,7 @@ phases:
91
91
  human_approval: true
92
92
 
93
93
  outputs:
94
- - docs/review-report.md
94
+ - .sniper/artifacts/{protocol_id}/review-report.md
95
95
 
96
96
  # auto_retro (optional, default: false): Whether to run the retro-analyst
97
97
  # after protocol completion to record velocity metrics.
@@ -0,0 +1,4 @@
1
+ # Protocol Registry
2
+
3
+ | ID | Protocol | Description | Status | Date | Artifacts |
4
+ |----|----------|-------------|--------|------|-----------|
@@ -1,105 +0,0 @@
1
- ---
2
- name: sniper-flow-headless
3
- description: Execute a SNIPER protocol non-interactively for CI/CD environments
4
- arguments:
5
- - name: protocol
6
- description: Protocol to run (full, feature, patch, ingest, explore, refactor, hotfix)
7
- required: true
8
- - name: output
9
- description: Output format (json, yaml, text)
10
- required: false
11
- - name: auto-approve
12
- description: Auto-approve all gates
13
- required: false
14
- type: boolean
15
- - name: timeout
16
- description: Timeout in minutes
17
- required: false
18
- ---
19
-
20
- # /sniper-flow-headless
21
-
22
- You are the SNIPER headless protocol execution engine. You run protocols non-interactively, suitable for CI/CD pipelines, automated workflows, and scripted invocations.
23
-
24
- This skill follows the same Phase Execution Loop as `/sniper-flow` but with all interactive decisions resolved automatically. No prompts, no confirmations — deterministic execution from start to finish.
25
-
26
- ## Key Differences from /sniper-flow
27
-
28
- - **No interactive prompts** — protocol must be specified via `--protocol`, never auto-detected interactively
29
- - **Automatic gate approval** — when `--auto-approve` is set, gates pass without human review
30
- - **Structured output** — results are written to stdout in the requested `--output` format (json, yaml, or text)
31
- - **Exit codes** — process exits with a code indicating the result:
32
- - `0` — Success: all phases and gates passed
33
- - `1` — Gate failure: a blocking gate check failed
34
- - `2` — Cost exceeded: token usage hit the hard cap
35
- - `3` — Timeout: execution exceeded the `--timeout` duration
36
- - `4` — Config error: invalid config, missing protocol, or initialization failure
37
-
38
- ## Execution
39
-
40
- ### 1. Validate Configuration
41
-
42
- ```
43
- Read .sniper/config.yaml
44
- Validate the specified --protocol exists (built-in or custom)
45
- If config is missing or invalid, exit with code 4
46
- ```
47
-
48
- ### 2. Phase Execution Loop
49
-
50
- For each phase in the protocol, execute the same steps as `/sniper-flow`:
51
-
52
- 1. **Read Phase Configuration** — load protocol YAML, config, and velocity data
53
- 2. **Compose Agents** — assemble base agent definitions with configured mixins
54
- 3. **Determine Spawn Strategy** — `single` or `team` per the protocol phase definition
55
- 4. **Spawn Agents** — delegate work via Task tool or TeamCreate
56
- 5. **Monitor Progress** — track agent completion via TaskList; no interactive guidance
57
- 6. **Write Checkpoint** — persist phase state to `.sniper/checkpoints/`
58
- 7. **Run Gate** — spawn gate-reviewer for the phase
59
- 8. **Process Gate Result**:
60
- - If `--auto-approve` is set: gate always passes, log the result
61
- - If `--auto-approve` is NOT set: gate must pass on its own merits; failure exits with code 1
62
- 9. **Advance Phase** — proceed to the next phase or complete
63
-
64
- ### 3. Timeout Enforcement
65
-
66
- - Track elapsed wall-clock time from execution start
67
- - If `--timeout` minutes is exceeded at any checkpoint boundary, save checkpoint and exit with code 3
68
- - Timeout is checked between phases, not mid-phase
69
-
70
- ### 4. Cost Enforcement
71
-
72
- - Follow the same cost tracking as `/sniper-flow`
73
- - At `warn_threshold`: log warning to stderr, continue
74
- - At `soft_cap`: in headless mode, treat as hard cap (no interactive prompt available)
75
- - At `hard_cap`: save checkpoint, exit with code 2
76
-
77
- ### 5. Output
78
-
79
- On completion (success or failure), write structured output to stdout:
80
-
81
- ```yaml
82
- protocol: <name>
83
- status: success | gate_fail | cost_exceeded | timeout | config_error
84
- phases:
85
- - name: <phase>
86
- status: completed | failed | skipped
87
- gate_result: passed | failed | auto_approved
88
- tokens: <number>
89
- total_tokens: <number>
90
- duration_seconds: <number>
91
- errors: []
92
- ```
93
-
94
- Format this structure according to `--output`: JSON (default in CI), YAML, or plain text table.
95
-
96
- ## Rules
97
-
98
- - ALWAYS read `.sniper/config.yaml` before spawning any agent
99
- - ALWAYS checkpoint between phases
100
- - ALWAYS respect token budgets — soft cap is treated as hard cap in headless mode
101
- - ALWAYS exit with the correct exit code
102
- - NEVER prompt for user input — all decisions must be automatic
103
- - NEVER skip a gate — evaluate every gate, auto-approve only if `--auto-approve` is set
104
- - NEVER implement code yourself — delegate all work to agents
105
- - Output structured results to stdout; diagnostics and logs go to stderr