@sniper.ai/core 1.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.
Files changed (67) hide show
  1. package/README.md +73 -0
  2. package/framework/checklists/code-review.md +33 -0
  3. package/framework/checklists/discover-review.md +33 -0
  4. package/framework/checklists/doc-review.md +39 -0
  5. package/framework/checklists/plan-review.md +52 -0
  6. package/framework/checklists/sprint-review.md +41 -0
  7. package/framework/checklists/story-review.md +30 -0
  8. package/framework/claude-md.template +37 -0
  9. package/framework/commands/sniper-compose.md +237 -0
  10. package/framework/commands/sniper-discover.md +397 -0
  11. package/framework/commands/sniper-doc.md +441 -0
  12. package/framework/commands/sniper-init.md +372 -0
  13. package/framework/commands/sniper-plan.md +608 -0
  14. package/framework/commands/sniper-review.md +305 -0
  15. package/framework/commands/sniper-solve.md +375 -0
  16. package/framework/commands/sniper-sprint.md +601 -0
  17. package/framework/commands/sniper-status.md +276 -0
  18. package/framework/config.template.yaml +117 -0
  19. package/framework/personas/cognitive/devils-advocate.md +30 -0
  20. package/framework/personas/cognitive/mentor-explainer.md +29 -0
  21. package/framework/personas/cognitive/performance-focused.md +30 -0
  22. package/framework/personas/cognitive/security-first.md +29 -0
  23. package/framework/personas/cognitive/systems-thinker.md +29 -0
  24. package/framework/personas/cognitive/user-empathetic.md +29 -0
  25. package/framework/personas/domain/.gitkeep +0 -0
  26. package/framework/personas/process/analyst.md +29 -0
  27. package/framework/personas/process/architect.md +30 -0
  28. package/framework/personas/process/developer.md +32 -0
  29. package/framework/personas/process/doc-analyst.md +63 -0
  30. package/framework/personas/process/doc-reviewer.md +62 -0
  31. package/framework/personas/process/doc-writer.md +42 -0
  32. package/framework/personas/process/product-manager.md +32 -0
  33. package/framework/personas/process/qa-engineer.md +31 -0
  34. package/framework/personas/process/scrum-master.md +31 -0
  35. package/framework/personas/process/ux-designer.md +31 -0
  36. package/framework/personas/technical/ai-ml.md +33 -0
  37. package/framework/personas/technical/api-design.md +32 -0
  38. package/framework/personas/technical/backend.md +32 -0
  39. package/framework/personas/technical/database.md +32 -0
  40. package/framework/personas/technical/frontend.md +33 -0
  41. package/framework/personas/technical/infrastructure.md +32 -0
  42. package/framework/personas/technical/security.md +34 -0
  43. package/framework/settings.template.json +6 -0
  44. package/framework/spawn-prompts/_template.md +22 -0
  45. package/framework/teams/discover.yaml +57 -0
  46. package/framework/teams/doc.yaml +76 -0
  47. package/framework/teams/plan.yaml +86 -0
  48. package/framework/teams/solve.yaml +48 -0
  49. package/framework/teams/sprint.yaml +68 -0
  50. package/framework/templates/architecture.md +72 -0
  51. package/framework/templates/brief.md +52 -0
  52. package/framework/templates/doc-api.md +53 -0
  53. package/framework/templates/doc-guide.md +35 -0
  54. package/framework/templates/doc-readme.md +49 -0
  55. package/framework/templates/epic.md +33 -0
  56. package/framework/templates/personas.md +118 -0
  57. package/framework/templates/prd.md +69 -0
  58. package/framework/templates/risks.md +64 -0
  59. package/framework/templates/security.md +90 -0
  60. package/framework/templates/sprint-review.md +32 -0
  61. package/framework/templates/story.md +37 -0
  62. package/framework/templates/ux-spec.md +54 -0
  63. package/framework/workflows/discover-only.md +39 -0
  64. package/framework/workflows/full-lifecycle.md +56 -0
  65. package/framework/workflows/quick-feature.md +44 -0
  66. package/framework/workflows/sprint-cycle.md +47 -0
  67. package/package.json +30 -0
@@ -0,0 +1,441 @@
1
+ # /sniper-doc -- Generate or Update Project Documentation (Parallel Team)
2
+
3
+ You are executing the `/sniper-doc` command. Your job is to spawn a documentation team that analyzes the project, generates documentation, and validates it. You are the **team lead** -- you coordinate, you do NOT produce artifacts yourself. Follow every step below precisely.
4
+
5
+ **Arguments:** $ARGUMENTS
6
+
7
+ ---
8
+
9
+ ## Step 0: Pre-Flight Checks
10
+
11
+ Perform ALL of the following checks before proceeding. Adjust behavior based on what exists.
12
+
13
+ ### 0a. Detect Project Mode
14
+
15
+ 1. Check if `.sniper/config.yaml` exists and `project.name` is not empty.
16
+ 2. **If config exists (SNIPER project):**
17
+ - Set mode = `sniper`
18
+ - Read `state.artifacts` to see which artifacts exist (brief, PRD, architecture, etc.)
19
+ - These artifacts are primary sources for documentation generation
20
+ 3. **If config does not exist (standalone project):**
21
+ - Set mode = `standalone`
22
+ - The team will infer everything from the codebase itself
23
+ - Check for common project files: `package.json`, `Cargo.toml`, `pyproject.toml`, `go.mod`, `pom.xml`
24
+ - If none found, STOP and print: "No project metadata found. Cannot generate documentation for an empty directory."
25
+
26
+ ### 0b. Check Existing Documentation
27
+
28
+ 1. Check if `README.md` exists at the project root.
29
+ 2. Check if `docs/` directory exists and what files are in it.
30
+ 3. If documentation already exists, default to **update mode** (preserve manual edits via managed sections).
31
+ 4. If no documentation exists, default to **generate mode** (full generation).
32
+
33
+ ### 0c. Verify Framework Files (SNIPER mode only)
34
+
35
+ Check that these files exist:
36
+ - `.sniper/teams/doc.yaml`
37
+ - `.sniper/spawn-prompts/_template.md`
38
+ - `.sniper/checklists/doc-review.md`
39
+ - `.sniper/personas/process/doc-analyst.md`
40
+ - `.sniper/personas/process/doc-writer.md`
41
+ - `.sniper/personas/process/doc-reviewer.md`
42
+ - `.sniper/personas/cognitive/user-empathetic.md`
43
+ - `.sniper/personas/cognitive/mentor-explainer.md`
44
+ - `.sniper/personas/cognitive/devils-advocate.md`
45
+
46
+ If any are missing, print a warning listing the missing files but continue if at least the team YAML exists.
47
+
48
+ ---
49
+
50
+ ## Step 1: Determine Documentation Scope
51
+
52
+ Ask the user what documentation they want to generate. Present a selection prompt:
53
+
54
+ > **Documentation Mode:**
55
+ > 1. Generate new docs (full generation)
56
+ > 2. Update existing docs (incremental — preserves manual edits)
57
+ >
58
+ > **What to generate:** (select all that apply)
59
+ > - README.md
60
+ > - Setup guide (docs/setup.md)
61
+ > - Architecture overview (docs/architecture.md)
62
+ > - API reference (docs/api.md)
63
+ > - Contributing guide (CONTRIBUTING.md)
64
+ > - Security policy (SECURITY.md)
65
+ > - Changelog (CHANGELOG.md)
66
+ > - Deployment guide (docs/deployment.md)
67
+ > - UI/Component guide (docs/ui-guide.md)
68
+
69
+ If `$ARGUMENTS` contains "all", skip the prompt and generate everything.
70
+ If `$ARGUMENTS` contains specific doc types (e.g., "readme api setup"), generate only those.
71
+ If `$ARGUMENTS` contains "update", force update mode.
72
+
73
+ Store the user's selections for the team.
74
+
75
+ ---
76
+
77
+ ## Step 2: Read Team Definition
78
+
79
+ 1. Read `.sniper/teams/doc.yaml` in full.
80
+ 2. Parse out:
81
+ - `team_name` (should be `sniper-doc`)
82
+ - The list of `teammates` with their `name`, `compose` layers, and `tasks`
83
+ - The `coordination` rules (analyst → writer handoff)
84
+ - The `review_gate` section (checklist path and mode)
85
+ 3. Store these values for subsequent steps.
86
+
87
+ ---
88
+
89
+ ## Step 3: Read Project Context
90
+
91
+ Gather the context that teammates will need:
92
+
93
+ 1. **SNIPER mode:**
94
+ - Read `.sniper/config.yaml` fully — extract `project.name`, `project.description`, `project.type`, `stack`, `domain_packs`, and `ownership` sections.
95
+ - If `domain_packs` is not empty, read domain pack context files.
96
+ - Check which SNIPER artifacts exist in `docs/`: brief.md, prd.md, architecture.md, ux-spec.md, security.md, epics/, stories/
97
+ - Read the relevant templates: doc-readme.md, doc-guide.md, doc-api.md
98
+
99
+ 2. **Standalone mode:**
100
+ - Read project metadata from package.json / Cargo.toml / pyproject.toml / go.mod
101
+ - Scan the project structure (top 3 levels of directories)
102
+ - Identify key source directories, test directories, config files
103
+ - Read the relevant templates: doc-readme.md, doc-guide.md, doc-api.md
104
+
105
+ ---
106
+
107
+ ## Step 4: Compose Spawn Prompts
108
+
109
+ For each teammate in the team YAML, compose a spawn prompt by assembling persona layers.
110
+
111
+ ### Teammate: doc-analyst
112
+
113
+ 1. Read these persona layer files:
114
+ - Process: `.sniper/personas/process/doc-analyst.md`
115
+ - Technical: SKIP (null in team YAML)
116
+ - Cognitive: `.sniper/personas/cognitive/user-empathetic.md`
117
+ - Domain: If `domain_packs` is set, read domain context. Otherwise skip.
118
+
119
+ 2. Read the spawn prompt template: `.sniper/spawn-prompts/_template.md`
120
+
121
+ 3. Assemble the spawn prompt by filling the template:
122
+ - `{name}` = "doc-analyst"
123
+ - `{process_layer}` = contents of doc-analyst.md
124
+ - `{technical_layer}` = "No specific technical lens for this role."
125
+ - `{cognitive_layer}` = contents of user-empathetic.md
126
+ - `{domain_layer}` = domain context if available, otherwise "No domain pack configured."
127
+ - `{ownership}` = the `docs` ownership paths from config.yaml (or `["docs/", "README.md"]` in standalone mode)
128
+
129
+ 4. Append to the spawn prompt:
130
+ ```
131
+ ## Your Task
132
+ **Task ID:** analyze-project
133
+ **Task Name:** Analyze Project Structure & Artifacts
134
+ **Output File:** docs/.sniper-doc-index.json
135
+ **Mode:** {sniper | standalone}
136
+
137
+ Scan the entire project and produce a documentation index. The user has requested
138
+ these doc types: {list of selected doc types from Step 1}.
139
+
140
+ Documentation mode: {generate | update}
141
+
142
+ {If update mode:}
143
+ Check existing documentation files for `<!-- sniper:managed:start -->` tags.
144
+ Note which docs have managed sections and which are fully manual.
145
+
146
+ ## Project Context
147
+ - **Project:** {project.name or inferred name}
148
+ - **Type:** {project.type or inferred type}
149
+ - **Description:** {project.description or inferred description}
150
+ - **Stack:** {summary of stack section or inferred stack}
151
+
152
+ ## Instructions
153
+ 1. Scan the project root and src/ directories to map the codebase structure.
154
+ 2. If SNIPER artifacts exist (docs/brief.md, docs/prd.md, docs/architecture.md, etc.), inventory them as source material.
155
+ 3. Identify API routes/endpoints, models/schemas, config files, Docker files, and test files.
156
+ 4. For each requested doc type, determine if it: exists and is current, exists but is stale, or is missing.
157
+ 5. Write the doc index to `docs/.sniper-doc-index.json`.
158
+ 6. When complete, message the team lead that your task is done.
159
+ ```
160
+
161
+ ### Teammate: doc-writer
162
+
163
+ 1. Read these persona layer files:
164
+ - Process: `.sniper/personas/process/doc-writer.md`
165
+ - Technical: Read the technical persona matching the project's primary stack. If `stack.backend` is `node-express`, use `backend.md`. If `stack.frontend` is `react`, use `frontend.md`. In standalone mode, infer from the project. If unclear, skip.
166
+ - Cognitive: `.sniper/personas/cognitive/mentor-explainer.md`
167
+ - Domain: Same as doc-analyst.
168
+
169
+ 2. Assemble using the same template pattern:
170
+ - `{name}` = "doc-writer"
171
+ - `{ownership}` = the `docs` ownership paths plus `README.md`, `CONTRIBUTING.md`, `SECURITY.md`, `CHANGELOG.md`
172
+
173
+ 3. Append task context for **write-readme**:
174
+ ```
175
+ ## Your Tasks
176
+
177
+ ### Task 1: Generate README.md
178
+ **Task ID:** write-readme
179
+ **Output File:** README.md
180
+ **Template:** .sniper/templates/doc-readme.md
181
+
182
+ Write the project README. Read the doc index at docs/.sniper-doc-index.json first
183
+ to understand available sources. Follow the template structure.
184
+
185
+ {If update mode:}
186
+ The README already exists. Only modify content within `<!-- sniper:managed:start -->`
187
+ and `<!-- sniper:managed:end -->` tags. Preserve everything outside those tags.
188
+ If no managed tags exist, treat the entire file as manual and append new content
189
+ inside managed tags at the end.
190
+
191
+ ### Task 2: Generate Documentation Guides
192
+ **Task ID:** write-guides
193
+ **Output Files:** docs/{selected guides}
194
+ **Template:** .sniper/templates/doc-guide.md (for general guides), .sniper/templates/doc-api.md (for API reference)
195
+
196
+ Generate the following documentation files: {list of selected doc types minus README}.
197
+ Read the doc index for source material. Follow templates.
198
+
199
+ {If update mode:}
200
+ For existing docs, respect managed section boundaries. For new docs, wrap all
201
+ content in managed tags.
202
+
203
+ ## Instructions
204
+ 1. Wait for the doc-analyst to complete the doc index.
205
+ 2. Read `docs/.sniper-doc-index.json` to understand what sources are available.
206
+ 3. For README: read the doc-readme template, read source materials, write README.md.
207
+ 4. For each guide: read the appropriate template, read source materials, write the file.
208
+ 5. Every code example must come from or be verified against the actual codebase.
209
+ 6. When both tasks are complete, message the team lead.
210
+ ```
211
+
212
+ ### Teammate: doc-reviewer
213
+
214
+ 1. Read these persona layer files:
215
+ - Process: `.sniper/personas/process/doc-reviewer.md`
216
+ - Technical: SKIP (null)
217
+ - Cognitive: `.sniper/personas/cognitive/devils-advocate.md`
218
+ - Domain: SKIP (null)
219
+
220
+ 2. Assemble using the same template pattern:
221
+ - `{name}` = "doc-reviewer"
222
+ - `{ownership}` = `["docs/"]`
223
+
224
+ 3. Append task context:
225
+ ```
226
+ ## Your Task
227
+ **Task ID:** review-docs
228
+ **Task Name:** Review & Validate Documentation
229
+ **Output File:** docs/.sniper-doc-review.md
230
+
231
+ Review all generated documentation for accuracy and completeness.
232
+
233
+ ## Instructions
234
+ 1. Wait for the doc-writer to complete all documentation.
235
+ 2. Read every generated documentation file.
236
+ 3. Cross-reference code examples against the actual codebase.
237
+ 4. Verify shell commands reference real scripts and binaries.
238
+ 5. Check internal links between docs.
239
+ 6. Check that setup instructions produce a working environment.
240
+ 7. Write the review report to docs/.sniper-doc-review.md.
241
+ 8. When complete, message the team lead with a summary (pass/fail count).
242
+ ```
243
+
244
+ ---
245
+
246
+ ## Step 5: Create the Agent Team
247
+
248
+ Use the TeamCreate tool to create the team:
249
+
250
+ ```
251
+ TeamCreate:
252
+ team_name: "sniper-doc"
253
+ description: "SNIPER Documentation: Generate/update docs for {project name}"
254
+ ```
255
+
256
+ ---
257
+
258
+ ## Step 6: Create Tasks in the Shared Task List
259
+
260
+ Create tasks with dependencies matching the team YAML.
261
+
262
+ ### Task 1: Analyze Project
263
+
264
+ ```
265
+ TaskCreate:
266
+ subject: "Analyze Project Structure & Artifacts"
267
+ description: "Scan the codebase and SNIPER artifacts. Produce documentation index at docs/.sniper-doc-index.json. Determine what docs exist, what's missing, what's stale."
268
+ activeForm: "Analyzing project structure"
269
+ ```
270
+
271
+ ### Task 2: Generate README
272
+
273
+ ```
274
+ TaskCreate:
275
+ subject: "Generate README.md"
276
+ description: "Write the project README from artifacts and codebase analysis. Follow doc-readme template. Output: README.md"
277
+ activeForm: "Writing README.md"
278
+ ```
279
+ Set dependency: blocked_by Task 1.
280
+
281
+ ### Task 3: Generate Documentation Guides
282
+
283
+ ```
284
+ TaskCreate:
285
+ subject: "Generate Documentation Guides"
286
+ description: "Generate selected documentation files (setup, architecture, API, deployment, etc.) based on doc index. Output: docs/ directory"
287
+ activeForm: "Writing documentation guides"
288
+ ```
289
+ Set dependency: blocked_by Task 1.
290
+
291
+ ### Task 4: Review Documentation
292
+
293
+ ```
294
+ TaskCreate:
295
+ subject: "Review & Validate Documentation"
296
+ description: "Review all generated docs for accuracy, completeness, consistency. Verify code examples, links, and setup instructions. Output: docs/.sniper-doc-review.md"
297
+ activeForm: "Reviewing documentation"
298
+ ```
299
+ Set dependency: blocked_by Task 2 AND Task 3.
300
+
301
+ ---
302
+
303
+ ## Step 7: Spawn Teammates
304
+
305
+ Spawn each teammate using the Task tool. Use the composed spawn prompts from Step 4.
306
+
307
+ For each teammate, spawn using:
308
+ - `team_name`: "sniper-doc"
309
+ - `name`: the teammate name from the YAML (doc-analyst, doc-writer, doc-reviewer)
310
+ - The full composed spawn prompt as the instruction
311
+
312
+ Spawn all three teammates. The doc-analyst works first (unblocked), the doc-writer waits for the index, and the doc-reviewer waits for the writer.
313
+
314
+ After spawning, assign each task to its corresponding teammate using TaskUpdate with the `owner` field:
315
+ - Task 1 (Analyze Project) -> owner: "doc-analyst"
316
+ - Task 2 (Generate README) -> owner: "doc-writer"
317
+ - Task 3 (Generate Guides) -> owner: "doc-writer"
318
+ - Task 4 (Review Docs) -> owner: "doc-reviewer"
319
+
320
+ Mark Task 1 as `in_progress`. Tasks 2, 3, 4 remain `pending` (blocked).
321
+
322
+ ---
323
+
324
+ ## Step 8: Enter Delegate Mode
325
+
326
+ **You are now the team lead. You do NOT produce artifacts.**
327
+
328
+ Your responsibilities during execution:
329
+ 1. Monitor task progress via TaskList
330
+ 2. When doc-analyst completes, unblock Tasks 2 and 3 — message doc-writer that the index is ready
331
+ 3. When doc-writer completes both tasks, unblock Task 4 — message doc-reviewer to begin review
332
+ 4. Respond to teammate messages (questions, blockers, completion notifications)
333
+ 5. Track which teammates have completed their work
334
+
335
+ **Do NOT:**
336
+ - Write any documentation files yourself
337
+ - Modify teammate artifacts
338
+ - Analyze the codebase yourself
339
+
340
+ Wait for all teammates to report completion.
341
+
342
+ ---
343
+
344
+ ## Step 9: Verify Artifacts Exist
345
+
346
+ Once all teammates report completion:
347
+
348
+ 1. Verify `docs/.sniper-doc-index.json` exists and is valid JSON.
349
+ 2. Verify each requested documentation file exists and is non-empty.
350
+ 3. Verify `docs/.sniper-doc-review.md` exists.
351
+ 4. If any file is missing or empty, message the responsible teammate and ask them to complete it.
352
+ 5. Do NOT proceed to Step 10 until all files exist.
353
+
354
+ ---
355
+
356
+ ## Step 10: Run Review Gate
357
+
358
+ Read the review gate configuration from the team YAML: `review_gate.mode` and `review_gate.checklist`.
359
+
360
+ 1. Read the review report at `docs/.sniper-doc-review.md` (produced by the doc-reviewer).
361
+ 2. Read the review checklist at `.sniper/checklists/doc-review.md`.
362
+ 3. Cross-reference the review report with the checklist.
363
+ 4. Compile a gate summary.
364
+
365
+ ### Gate Decision
366
+
367
+ The doc gate mode is **flexible**:
368
+
369
+ - **If there are no FAIL items in the review report:** Auto-advance. Print the summary.
370
+ - **If there are FAIL items:** Present the failures to the user and ask:
371
+ > "The documentation review found {N} critical issues. Would you like to:
372
+ > 1. Have the writer fix the issues
373
+ > 2. Accept the docs as-is
374
+ > 3. Stop and fix manually"
375
+
376
+ If option 1: Message doc-writer with the specific failures, wait for fixes, then re-run review.
377
+ If option 2: Proceed.
378
+ If option 3: STOP.
379
+
380
+ ---
381
+
382
+ ## Step 11: Clean Up and Shut Down Team
383
+
384
+ ### Remove Temporary Files
385
+
386
+ The `docs/.sniper-doc-index.json` file is an intermediate artifact. Ask the user if they want to keep it (useful for future incremental updates) or delete it.
387
+
388
+ ### Shut Down Teammates
389
+
390
+ Send a shutdown request to each teammate:
391
+ - Send shutdown_request to "doc-analyst"
392
+ - Send shutdown_request to "doc-writer"
393
+ - Send shutdown_request to "doc-reviewer"
394
+
395
+ Wait for all teammates to acknowledge shutdown.
396
+
397
+ ---
398
+
399
+ ## Step 12: Present Results
400
+
401
+ Print a formatted summary:
402
+
403
+ ```
404
+ ============================================
405
+ SNIPER Doc: Documentation Complete
406
+ ============================================
407
+
408
+ Mode: {sniper | standalone}
409
+ Action: {generate | update}
410
+
411
+ Files Generated/Updated:
412
+ - README.md [generated | updated]
413
+ - docs/setup.md [generated | updated | skipped]
414
+ - docs/architecture.md [generated | updated | skipped]
415
+ - docs/api.md [generated | updated | skipped]
416
+ - ...
417
+
418
+ Review:
419
+ Passed: {count}/{total} checks
420
+ Warnings: {count}
421
+ Critical: {count}
422
+
423
+ ============================================
424
+ Documentation is ready for review.
425
+ Run `/sniper-doc update` anytime to refresh.
426
+ ============================================
427
+ ```
428
+
429
+ ---
430
+
431
+ ## IMPORTANT RULES
432
+
433
+ - You are the LEAD. You coordinate. You do NOT write documentation yourself.
434
+ - The doc-analyst MUST complete before the doc-writer starts.
435
+ - The doc-writer MUST complete before the doc-reviewer starts.
436
+ - If `$ARGUMENTS` contains "dry-run", perform Steps 0-4 only (compose prompts) and print them without spawning.
437
+ - If `$ARGUMENTS` contains "skip-review", skip the doc-reviewer teammate entirely (only spawn analyst and writer).
438
+ - `/sniper-doc` does NOT modify lifecycle state in config.yaml — it is a utility, not a phase.
439
+ - In update mode, NEVER overwrite content outside `<!-- sniper:managed -->` tags.
440
+ - All file paths are relative to the project root.
441
+ - This command works regardless of current lifecycle phase — it can run during discover, plan, or sprint.