@sniper.ai/core 1.0.1 → 3.0.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.
- package/README.md +119 -39
- package/agents/analyst.md +30 -0
- package/agents/architect.md +36 -0
- package/agents/backend-dev.md +43 -0
- package/agents/code-reviewer.md +72 -0
- package/agents/frontend-dev.md +43 -0
- package/agents/fullstack-dev.md +44 -0
- package/agents/gate-reviewer.md +62 -0
- package/agents/lead-orchestrator.md +51 -0
- package/agents/product-manager.md +38 -0
- package/agents/qa-engineer.md +37 -0
- package/agents/retro-analyst.md +98 -0
- package/checklists/discover.yaml +23 -0
- package/checklists/implement.yaml +28 -0
- package/checklists/ingest-document.yaml +18 -0
- package/checklists/ingest-extract.yaml +13 -0
- package/checklists/ingest-scan.yaml +18 -0
- package/checklists/multi-faceted-review.yaml +56 -0
- package/checklists/plan.yaml +36 -0
- package/checklists/refactor-analyze.yaml +18 -0
- package/checklists/review.yaml +28 -0
- package/claude-md.template +42 -0
- package/config.template.yaml +156 -0
- package/hooks/settings-hooks.json +31 -0
- package/hooks/signal-hooks.json +11 -0
- package/package.json +23 -5
- package/personas/cognitive/devils-advocate.md +24 -0
- package/personas/cognitive/performance-focused.md +23 -0
- package/personas/cognitive/security-first.md +24 -0
- package/protocols/explore.yaml +18 -0
- package/protocols/feature.yaml +45 -0
- package/protocols/full.yaml +63 -0
- package/protocols/hotfix.yaml +19 -0
- package/protocols/ingest.yaml +39 -0
- package/protocols/patch.yaml +30 -0
- package/protocols/refactor.yaml +41 -0
- package/schemas/checkpoint.schema.yaml +133 -0
- package/schemas/cost.schema.yaml +97 -0
- package/schemas/dependency-graph.schema.yaml +37 -0
- package/schemas/gate-result.schema.yaml +101 -0
- package/schemas/knowledge-manifest.schema.yaml +39 -0
- package/schemas/live-status.schema.yaml +122 -0
- package/schemas/protocol.schema.yaml +100 -0
- package/schemas/retro.schema.yaml +95 -0
- package/schemas/revert-plan.schema.yaml +40 -0
- package/schemas/signal.schema.yaml +39 -0
- package/schemas/velocity.schema.yaml +52 -0
- package/schemas/workspace-lock.schema.yaml +34 -0
- package/schemas/workspace.schema.yaml +82 -0
- package/skills/sniper-flow/SKILL.md +243 -0
- package/skills/sniper-flow-headless/SKILL.md +105 -0
- package/skills/sniper-init/SKILL.md +103 -0
- package/skills/sniper-review/SKILL.md +49 -0
- package/skills/sniper-status/SKILL.md +79 -0
- package/templates/architecture.md +23 -0
- package/templates/checkpoint.yaml +27 -0
- package/templates/codebase-overview.md +19 -0
- package/templates/cost.yaml +23 -0
- package/templates/custom-protocol.yaml +98 -0
- package/templates/knowledge-manifest.yaml +32 -0
- package/templates/live-status.yaml +26 -0
- package/templates/multi-faceted-review-report.md +28 -0
- package/templates/review-report.md +25 -0
- package/templates/signal-record.yaml +37 -0
- package/templates/spec.md +28 -0
- package/templates/story.md +19 -0
- package/templates/velocity.yaml +9 -0
- package/templates/workspace-config.yaml +44 -0
- package/framework/checklists/code-review.md +0 -33
- package/framework/checklists/discover-review.md +0 -33
- package/framework/checklists/doc-review.md +0 -39
- package/framework/checklists/plan-review.md +0 -52
- package/framework/checklists/sprint-review.md +0 -41
- package/framework/checklists/story-review.md +0 -30
- package/framework/claude-md.template +0 -37
- package/framework/commands/sniper-compose.md +0 -237
- package/framework/commands/sniper-discover.md +0 -397
- package/framework/commands/sniper-doc.md +0 -441
- package/framework/commands/sniper-init.md +0 -372
- package/framework/commands/sniper-plan.md +0 -608
- package/framework/commands/sniper-review.md +0 -305
- package/framework/commands/sniper-solve.md +0 -375
- package/framework/commands/sniper-sprint.md +0 -601
- package/framework/commands/sniper-status.md +0 -276
- package/framework/config.template.yaml +0 -117
- package/framework/personas/cognitive/devils-advocate.md +0 -30
- package/framework/personas/cognitive/mentor-explainer.md +0 -29
- package/framework/personas/cognitive/performance-focused.md +0 -30
- package/framework/personas/cognitive/security-first.md +0 -29
- package/framework/personas/cognitive/systems-thinker.md +0 -29
- package/framework/personas/cognitive/user-empathetic.md +0 -29
- package/framework/personas/domain/.gitkeep +0 -0
- package/framework/personas/process/analyst.md +0 -29
- package/framework/personas/process/architect.md +0 -30
- package/framework/personas/process/developer.md +0 -32
- package/framework/personas/process/doc-analyst.md +0 -63
- package/framework/personas/process/doc-reviewer.md +0 -62
- package/framework/personas/process/doc-writer.md +0 -42
- package/framework/personas/process/product-manager.md +0 -32
- package/framework/personas/process/qa-engineer.md +0 -31
- package/framework/personas/process/scrum-master.md +0 -31
- package/framework/personas/process/ux-designer.md +0 -31
- package/framework/personas/technical/ai-ml.md +0 -33
- package/framework/personas/technical/api-design.md +0 -32
- package/framework/personas/technical/backend.md +0 -32
- package/framework/personas/technical/database.md +0 -32
- package/framework/personas/technical/frontend.md +0 -33
- package/framework/personas/technical/infrastructure.md +0 -32
- package/framework/personas/technical/security.md +0 -34
- package/framework/settings.template.json +0 -6
- package/framework/spawn-prompts/_template.md +0 -22
- package/framework/teams/discover.yaml +0 -57
- package/framework/teams/doc.yaml +0 -76
- package/framework/teams/plan.yaml +0 -86
- package/framework/teams/solve.yaml +0 -48
- package/framework/teams/sprint.yaml +0 -68
- package/framework/templates/architecture.md +0 -72
- package/framework/templates/brief.md +0 -52
- package/framework/templates/doc-api.md +0 -53
- package/framework/templates/doc-guide.md +0 -35
- package/framework/templates/doc-readme.md +0 -49
- package/framework/templates/epic.md +0 -33
- package/framework/templates/personas.md +0 -118
- package/framework/templates/prd.md +0 -69
- package/framework/templates/risks.md +0 -64
- package/framework/templates/security.md +0 -90
- package/framework/templates/sprint-review.md +0 -32
- package/framework/templates/story.md +0 -37
- package/framework/templates/ux-spec.md +0 -54
- package/framework/workflows/discover-only.md +0 -39
- package/framework/workflows/full-lifecycle.md +0 -56
- package/framework/workflows/quick-feature.md +0 -44
- package/framework/workflows/sprint-cycle.md +0 -47
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sniper-flow
|
|
3
|
+
description: Execute a SNIPER protocol — the core execution engine
|
|
4
|
+
arguments:
|
|
5
|
+
- name: protocol
|
|
6
|
+
description: Protocol to run (full, feature, patch, ingest, explore, refactor, hotfix). Auto-detected if omitted.
|
|
7
|
+
required: false
|
|
8
|
+
- name: resume
|
|
9
|
+
description: Resume from last checkpoint
|
|
10
|
+
required: false
|
|
11
|
+
type: boolean
|
|
12
|
+
- name: phase
|
|
13
|
+
description: Start from a specific phase (skips earlier phases)
|
|
14
|
+
required: false
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# /sniper-flow
|
|
18
|
+
|
|
19
|
+
You are the SNIPER protocol execution engine. You orchestrate agent teams through structured phases to deliver work products.
|
|
20
|
+
|
|
21
|
+
## Protocol Selection
|
|
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)
|
|
62
|
+
|
|
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
|
|
66
|
+
|
|
67
|
+
This allows users to override built-in protocols or define entirely new ones.
|
|
68
|
+
|
|
69
|
+
## Phase Execution Loop
|
|
70
|
+
|
|
71
|
+
For each phase in the protocol:
|
|
72
|
+
|
|
73
|
+
### 0. Pre-Phase Setup
|
|
74
|
+
|
|
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
|
|
80
|
+
|
|
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
|
|
86
|
+
|
|
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
|
|
93
|
+
|
|
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
|
+
```
|
|
100
|
+
|
|
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
|
+
```
|
|
147
|
+
|
|
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
|
+
```
|
|
154
|
+
|
|
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
|
|
159
|
+
|
|
160
|
+
### 6. Write Checkpoint
|
|
161
|
+
After all agents complete (or fail), write a checkpoint:
|
|
162
|
+
```yaml
|
|
163
|
+
# .sniper/checkpoints/<protocol>-<phase>-<timestamp>.yaml
|
|
164
|
+
protocol: <name>
|
|
165
|
+
phase: <phase>
|
|
166
|
+
timestamp: <ISO 8601>
|
|
167
|
+
status: completed | failed
|
|
168
|
+
agents: [status per agent]
|
|
169
|
+
token_usage: [phase + cumulative]
|
|
170
|
+
commits: [git SHAs produced during this phase]
|
|
171
|
+
```
|
|
172
|
+
|
|
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
|
|
178
|
+
|
|
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/`
|
|
184
|
+
|
|
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
|
|
189
|
+
|
|
190
|
+
### 9. Advance Phase
|
|
191
|
+
Move to the next phase in the protocol. If this was the last phase, complete the protocol.
|
|
192
|
+
|
|
193
|
+
## Protocol Completion
|
|
194
|
+
|
|
195
|
+
When all phases complete:
|
|
196
|
+
1. Write final checkpoint
|
|
197
|
+
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
|
|
200
|
+
|
|
201
|
+
## Cost Tracking
|
|
202
|
+
|
|
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
|
|
227
|
+
|
|
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
|
|
234
|
+
|
|
235
|
+
## Rules
|
|
236
|
+
|
|
237
|
+
- ALWAYS read `.sniper/config.yaml` before spawning any agent
|
|
238
|
+
- ALWAYS checkpoint between phases
|
|
239
|
+
- ALWAYS respect token budgets
|
|
240
|
+
- NEVER skip a gate — every phase transition goes through its gate
|
|
241
|
+
- NEVER advance past a failed blocking gate check
|
|
242
|
+
- NEVER implement code yourself — delegate all work to agents
|
|
243
|
+
- When `human_approval` is required, present clear options and wait
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sniper-init
|
|
3
|
+
description: Initialize SNIPER v3 in a new or existing project
|
|
4
|
+
arguments:
|
|
5
|
+
- name: language
|
|
6
|
+
description: Primary language (auto-detected if omitted)
|
|
7
|
+
required: false
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# /sniper-init
|
|
11
|
+
|
|
12
|
+
Initialize SNIPER v3 framework in the current project.
|
|
13
|
+
|
|
14
|
+
## Process
|
|
15
|
+
|
|
16
|
+
### 1. Check Existing State
|
|
17
|
+
|
|
18
|
+
- If `.sniper/config.yaml` exists, ask user: "SNIPER is already initialized. Reinitialize? (existing config will be backed up)"
|
|
19
|
+
- If reinitializing, copy `.sniper/config.yaml` to `.sniper/config.yaml.bak`
|
|
20
|
+
|
|
21
|
+
### 2. Auto-Detect Project
|
|
22
|
+
|
|
23
|
+
Scan the project directory to detect:
|
|
24
|
+
|
|
25
|
+
**Language** (check in order):
|
|
26
|
+
- `tsconfig.json` or `*.ts` files → TypeScript
|
|
27
|
+
- `package.json` → JavaScript
|
|
28
|
+
- `pyproject.toml` or `requirements.txt` → Python
|
|
29
|
+
- `go.mod` → Go
|
|
30
|
+
- `Cargo.toml` → Rust
|
|
31
|
+
- `pom.xml` or `build.gradle` → Java
|
|
32
|
+
- Fall back to `--language` argument or ask user
|
|
33
|
+
|
|
34
|
+
**Package Manager**:
|
|
35
|
+
- `pnpm-lock.yaml` → pnpm
|
|
36
|
+
- `yarn.lock` → yarn
|
|
37
|
+
- `bun.lockb` → bun
|
|
38
|
+
- `package-lock.json` → npm
|
|
39
|
+
- `uv.lock` → uv
|
|
40
|
+
- `poetry.lock` → poetry
|
|
41
|
+
|
|
42
|
+
**Framework**:
|
|
43
|
+
- `next.config.*` → Next.js
|
|
44
|
+
- `nuxt.config.*` → Nuxt
|
|
45
|
+
- `vite.config.*` → Vite
|
|
46
|
+
- `angular.json` → Angular
|
|
47
|
+
|
|
48
|
+
**Test Runner**:
|
|
49
|
+
- `vitest.config.*` → Vitest
|
|
50
|
+
- `jest.config.*` → Jest
|
|
51
|
+
- `pytest.ini` or `conftest.py` → Pytest
|
|
52
|
+
|
|
53
|
+
**Commands** (from package.json scripts or Makefile):
|
|
54
|
+
- Look for `test`, `lint`, `build`, `typecheck` scripts
|
|
55
|
+
|
|
56
|
+
### 3. Gather User Input
|
|
57
|
+
|
|
58
|
+
Ask the user (with auto-detected defaults pre-filled):
|
|
59
|
+
1. Project name (default: directory name)
|
|
60
|
+
2. Project type (saas, api, mobile, cli, library, monorepo)
|
|
61
|
+
3. One-line description
|
|
62
|
+
4. Max concurrent teammates (default: 5)
|
|
63
|
+
5. Confirm detected stack
|
|
64
|
+
|
|
65
|
+
### 4. Scaffold Structure
|
|
66
|
+
|
|
67
|
+
Create the following directory structure:
|
|
68
|
+
```
|
|
69
|
+
.sniper/
|
|
70
|
+
config.yaml ← Generated from template + user input + auto-detection
|
|
71
|
+
checkpoints/
|
|
72
|
+
gates/
|
|
73
|
+
retros/
|
|
74
|
+
self-reviews/
|
|
75
|
+
checklists/ ← Copied from @sniper.ai/core/checklists/
|
|
76
|
+
.claude/
|
|
77
|
+
agents/ ← Copied from @sniper.ai/core/agents/
|
|
78
|
+
settings.json ← Merge hooks from @sniper.ai/core/hooks/
|
|
79
|
+
docs/
|
|
80
|
+
CLAUDE.md ← Generated from template
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 5. Apply Plugins
|
|
84
|
+
|
|
85
|
+
If plugins are configured (or auto-detected):
|
|
86
|
+
1. Read each plugin's `plugin.yaml`
|
|
87
|
+
2. Merge plugin commands into config
|
|
88
|
+
3. Copy plugin mixins to `.claude/personas/cognitive/`
|
|
89
|
+
4. Merge plugin hooks into `.claude/settings.json`
|
|
90
|
+
|
|
91
|
+
### 6. Confirm
|
|
92
|
+
|
|
93
|
+
Display summary:
|
|
94
|
+
- Files created/modified
|
|
95
|
+
- Detected stack
|
|
96
|
+
- Suggested next step: "Run `/sniper-flow` to start your first protocol"
|
|
97
|
+
|
|
98
|
+
## Rules
|
|
99
|
+
|
|
100
|
+
- NEVER overwrite existing project source files
|
|
101
|
+
- ALWAYS back up existing config before reinitializing
|
|
102
|
+
- ALWAYS show the user what will be created before doing it
|
|
103
|
+
- Respect `.gitignore` — add `.sniper/checkpoints/` and `.sniper/gates/` if not present
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sniper-review
|
|
3
|
+
description: Manually trigger a review gate for the current phase
|
|
4
|
+
arguments:
|
|
5
|
+
- name: phase
|
|
6
|
+
description: Phase to review (defaults to current phase from live-status)
|
|
7
|
+
required: false
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# /sniper-review
|
|
11
|
+
|
|
12
|
+
Manually trigger a quality gate review. Use this when you want to run gate checks outside of the normal protocol flow.
|
|
13
|
+
|
|
14
|
+
## Process
|
|
15
|
+
|
|
16
|
+
### 1. Determine Phase
|
|
17
|
+
|
|
18
|
+
- If `--phase` is specified, use it
|
|
19
|
+
- Otherwise, read `.sniper/live-status.yaml` for the current phase
|
|
20
|
+
- If no active phase, ask the user which phase checklist to run
|
|
21
|
+
|
|
22
|
+
### 2. Load Checklist
|
|
23
|
+
|
|
24
|
+
Read the checklist from `.sniper/checklists/<phase>.yaml` (or from `.claude/` if scaffolded there).
|
|
25
|
+
|
|
26
|
+
### 3. Run Checks
|
|
27
|
+
|
|
28
|
+
Spawn a gate-reviewer agent to execute the checklist:
|
|
29
|
+
- Use the Task tool with the gate-reviewer agent definition
|
|
30
|
+
- Pass the checklist path and phase name
|
|
31
|
+
- Wait for the gate result
|
|
32
|
+
|
|
33
|
+
### 4. Present Results
|
|
34
|
+
|
|
35
|
+
Display the gate result:
|
|
36
|
+
- Overall: PASS or FAIL
|
|
37
|
+
- Each check with status and any output
|
|
38
|
+
- Blocking failures highlighted
|
|
39
|
+
- Suggestions for fixing failures
|
|
40
|
+
|
|
41
|
+
### 5. Write Result
|
|
42
|
+
|
|
43
|
+
Save the gate result to `.sniper/gates/<phase>-<timestamp>.yaml`.
|
|
44
|
+
|
|
45
|
+
## Rules
|
|
46
|
+
|
|
47
|
+
- This is a manual trigger — it does NOT advance the protocol phase
|
|
48
|
+
- Always write results to `.sniper/gates/` for audit trail
|
|
49
|
+
- If checks reference commands that don't exist in config, skip with a warning
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sniper-status
|
|
3
|
+
description: Show current SNIPER protocol progress and cost
|
|
4
|
+
arguments: []
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /sniper-status
|
|
8
|
+
|
|
9
|
+
Display the current state of SNIPER in this project.
|
|
10
|
+
|
|
11
|
+
## Process
|
|
12
|
+
|
|
13
|
+
### 1. Read State Files
|
|
14
|
+
|
|
15
|
+
Read the following files (skip if they don't exist):
|
|
16
|
+
- `.sniper/config.yaml` — Project configuration
|
|
17
|
+
- `.sniper/live-status.yaml` — Active protocol progress
|
|
18
|
+
- `.sniper/cost.yaml` — Token usage tracking
|
|
19
|
+
|
|
20
|
+
If `.sniper/config.yaml` doesn't exist, display: "SNIPER is not initialized. Run `/sniper-init` first."
|
|
21
|
+
|
|
22
|
+
### 2. Display Status
|
|
23
|
+
|
|
24
|
+
Format and display:
|
|
25
|
+
|
|
26
|
+
**Project Info**:
|
|
27
|
+
- Project name and type
|
|
28
|
+
- Stack summary (language, framework, database)
|
|
29
|
+
- Plugins installed
|
|
30
|
+
|
|
31
|
+
**Protocol Status** (if active):
|
|
32
|
+
- Protocol name and current phase
|
|
33
|
+
- Phase progress (completed/total phases)
|
|
34
|
+
- Agent status per active phase
|
|
35
|
+
- Gate results for completed phases
|
|
36
|
+
|
|
37
|
+
**Cost Summary** (if tracking enabled):
|
|
38
|
+
- Tokens used vs budget
|
|
39
|
+
- Budget percentage with visual bar
|
|
40
|
+
- Warning if approaching soft/hard cap
|
|
41
|
+
|
|
42
|
+
**Recent Activity**:
|
|
43
|
+
- Last 3 checkpoints with timestamps
|
|
44
|
+
- Last gate result
|
|
45
|
+
|
|
46
|
+
**Velocity Trends** (if velocity data exists):
|
|
47
|
+
- Read `.sniper/memory/velocity.yaml`
|
|
48
|
+
- Show last 5 executions per protocol with tokens used
|
|
49
|
+
- Show calibrated budget vs configured budget comparison
|
|
50
|
+
- Show trend direction: ↑ (increasing usage), ↓ (decreasing usage), → (stable)
|
|
51
|
+
|
|
52
|
+
### 3. Format Output
|
|
53
|
+
|
|
54
|
+
Use clear formatting:
|
|
55
|
+
```
|
|
56
|
+
Project: my-app (saas)
|
|
57
|
+
Stack: TypeScript, Next.js, PostgreSQL
|
|
58
|
+
|
|
59
|
+
Protocol: feature (phase 2/3)
|
|
60
|
+
Phase: implement [===========-----] 68%
|
|
61
|
+
backend-dev: implementing (3/5 tasks)
|
|
62
|
+
qa-engineer: waiting
|
|
63
|
+
|
|
64
|
+
Gates:
|
|
65
|
+
plan: PASS (2025-01-15)
|
|
66
|
+
|
|
67
|
+
Cost: 245K / 800K tokens (31%)
|
|
68
|
+
[======--------------] 31%
|
|
69
|
+
|
|
70
|
+
Velocity:
|
|
71
|
+
feature: 612K avg (calibrated: 750K, configured: 800K) →
|
|
72
|
+
patch: 145K avg (calibrated: 180K, configured: 200K) ↓
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Rules
|
|
76
|
+
|
|
77
|
+
- Read-only — this skill never modifies any files
|
|
78
|
+
- If no protocol is active, show config summary only
|
|
79
|
+
- If cost tracking is disabled, skip cost section
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
<!-- Budget: 4000 tokens max -->
|
|
3
|
+
|
|
4
|
+
## Context
|
|
5
|
+
<!-- ~400 tokens: Technical context, constraints, existing system landscape -->
|
|
6
|
+
|
|
7
|
+
## Decisions
|
|
8
|
+
<!-- ~800 tokens: Key architectural decisions with rationale -->
|
|
9
|
+
<!-- For each decision: Context | Options Considered | Decision | Consequences -->
|
|
10
|
+
|
|
11
|
+
## Components
|
|
12
|
+
<!-- ~1000 tokens: Component breakdown with responsibilities -->
|
|
13
|
+
<!-- For each component: Name | Responsibility | Dependencies | Owner -->
|
|
14
|
+
|
|
15
|
+
## Data Model
|
|
16
|
+
<!-- ~600 tokens: Core entities and relationships -->
|
|
17
|
+
|
|
18
|
+
## API Contracts
|
|
19
|
+
<!-- ~800 tokens: Key API interfaces including error cases -->
|
|
20
|
+
<!-- For each endpoint: Method | Path | Request | Response | Errors -->
|
|
21
|
+
|
|
22
|
+
## Infrastructure
|
|
23
|
+
<!-- ~400 tokens: Deployment, scaling, monitoring considerations -->
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Phase checkpoint — snapshot of protocol state
|
|
2
|
+
protocol: ""
|
|
3
|
+
phase: ""
|
|
4
|
+
timestamp: ""
|
|
5
|
+
status: "" # in_progress | completed | failed
|
|
6
|
+
|
|
7
|
+
agents:
|
|
8
|
+
- name: ""
|
|
9
|
+
status: "" # active | completed | failed
|
|
10
|
+
tasks_completed: 0
|
|
11
|
+
tasks_total: 0
|
|
12
|
+
|
|
13
|
+
gate_result: null # null if gate not yet run
|
|
14
|
+
# gate_result:
|
|
15
|
+
# result: pass | fail
|
|
16
|
+
# blocking_failures: 0
|
|
17
|
+
|
|
18
|
+
artifacts_produced: []
|
|
19
|
+
# - path: docs/spec.md
|
|
20
|
+
# status: draft | complete
|
|
21
|
+
|
|
22
|
+
token_usage:
|
|
23
|
+
phase_tokens: 0
|
|
24
|
+
cumulative_tokens: 0
|
|
25
|
+
budget_remaining: 0
|
|
26
|
+
|
|
27
|
+
notes: ""
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Codebase Overview
|
|
2
|
+
<!-- Budget: 2000 tokens max -->
|
|
3
|
+
|
|
4
|
+
## Architecture
|
|
5
|
+
<!-- ~400 tokens: High-level architecture pattern and key design decisions -->
|
|
6
|
+
|
|
7
|
+
## Key Modules
|
|
8
|
+
<!-- ~500 tokens: Core modules/packages with responsibilities -->
|
|
9
|
+
| Module | Path | Responsibility |
|
|
10
|
+
|--------|------|---------------|
|
|
11
|
+
|
|
12
|
+
## Data Flow
|
|
13
|
+
<!-- ~400 tokens: How data moves through the system -->
|
|
14
|
+
|
|
15
|
+
## Conventions
|
|
16
|
+
<!-- ~400 tokens: Coding patterns, naming conventions, project-specific rules -->
|
|
17
|
+
|
|
18
|
+
## Risks
|
|
19
|
+
<!-- ~300 tokens: Technical debt, fragile areas, known issues -->
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Cost tracking for protocol execution
|
|
2
|
+
protocol: ""
|
|
3
|
+
started_at: ""
|
|
4
|
+
budget: 0
|
|
5
|
+
|
|
6
|
+
phases: []
|
|
7
|
+
# - name: discover
|
|
8
|
+
# started_at: ""
|
|
9
|
+
# completed_at: ""
|
|
10
|
+
# tokens_used: 0
|
|
11
|
+
# agents:
|
|
12
|
+
# - name: analyst
|
|
13
|
+
# tokens_used: 0
|
|
14
|
+
|
|
15
|
+
totals:
|
|
16
|
+
tokens_used: 0
|
|
17
|
+
budget_remaining: 0
|
|
18
|
+
budget_percent_used: 0
|
|
19
|
+
|
|
20
|
+
enforcement:
|
|
21
|
+
warn_threshold: 0.7 # Warn at 70% budget
|
|
22
|
+
soft_cap: 0.9 # Soft cap at 90% — agents must justify continuation
|
|
23
|
+
hard_cap: 1.0 # Hard cap at 100% — stop execution
|