sam-agents 0.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.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +92 -0
  3. package/bin/cli.js +320 -0
  4. package/package.json +36 -0
  5. package/templates/.claude/commands/sam/core/agents/sam.md +6 -0
  6. package/templates/.claude/commands/sam/core/workflows/autonomous-tdd.md +6 -0
  7. package/templates/.claude/commands/sam/sam/agents/argus.md +6 -0
  8. package/templates/.claude/commands/sam/sam/agents/atlas.md +6 -0
  9. package/templates/.claude/commands/sam/sam/agents/dyna.md +6 -0
  10. package/templates/.claude/commands/sam/sam/agents/iris.md +6 -0
  11. package/templates/.claude/commands/sam/sam/agents/sage.md +6 -0
  12. package/templates/.claude/commands/sam/sam/agents/titan.md +6 -0
  13. package/templates/_sam/_config/agent-manifest.csv +8 -0
  14. package/templates/_sam/_config/agents/sam-architect.customize.yaml +13 -0
  15. package/templates/_sam/_config/agents/sam-dev.customize.yaml +13 -0
  16. package/templates/_sam/_config/agents/sam-reviewer.customize.yaml +13 -0
  17. package/templates/_sam/_config/agents/sam-sam.customize.yaml +13 -0
  18. package/templates/_sam/_config/agents/sam-tech-writer.customize.yaml +13 -0
  19. package/templates/_sam/_config/agents/sam-test.customize.yaml +13 -0
  20. package/templates/_sam/_config/agents/sam-ux-designer.customize.yaml +13 -0
  21. package/templates/_sam/_config/ides/claude-code.yaml +6 -0
  22. package/templates/_sam/_config/manifest.yaml +13 -0
  23. package/templates/_sam/_config/workflow-manifest.csv +2 -0
  24. package/templates/_sam/agents/architect.md +69 -0
  25. package/templates/_sam/agents/dev.md +97 -0
  26. package/templates/_sam/agents/reviewer.md +138 -0
  27. package/templates/_sam/agents/tech-writer.md +147 -0
  28. package/templates/_sam/agents/test.md +120 -0
  29. package/templates/_sam/agents/ux-designer.md +141 -0
  30. package/templates/_sam/core/agents/sam-master.md +91 -0
  31. package/templates/_sam/core/config.yaml +31 -0
  32. package/templates/_sam/core/workflows/autonomous-tdd/steps/step-01-validate-prd.md +213 -0
  33. package/templates/_sam/core/workflows/autonomous-tdd/steps/step-02-generate-stories.md +266 -0
  34. package/templates/_sam/core/workflows/autonomous-tdd/steps/step-03-tdd-loop.md +422 -0
  35. package/templates/_sam/core/workflows/autonomous-tdd/steps/step-04-complete.md +356 -0
  36. package/templates/_sam/core/workflows/autonomous-tdd/templates/pipeline-status.yaml +108 -0
  37. package/templates/_sam/core/workflows/autonomous-tdd/workflow.md +311 -0
@@ -0,0 +1,422 @@
1
+ ---
2
+ step: 3
3
+ name: tdd-loop
4
+ description: Execute TDD RED-GREEN-REFACTOR cycle for each story
5
+ agents: [test, dev, reviewer]
6
+ ---
7
+
8
+ # Step 3: TDD Implementation Loop
9
+
10
+ **Purpose:** Implement each story using strict Test-Driven Development methodology: RED (failing tests) → GREEN (make tests pass) → REFACTOR (improve code).
11
+
12
+ ---
13
+
14
+ ## ENTRY CONDITIONS
15
+
16
+ - Phase 2 complete (stories generated)
17
+ - Stories available in `stories/` directory
18
+ - Pipeline status has story list with priorities
19
+
20
+ ---
21
+
22
+ ## MAIN LOOP
23
+
24
+ ```
25
+ FOR each story in priority order:
26
+ IF story.status == 'pending':
27
+ execute_tdd_cycle(story)
28
+
29
+ IF all stories complete OR all remaining stories blocked:
30
+ EXIT loop
31
+
32
+ PROCEED to Phase 4
33
+ ```
34
+
35
+ ---
36
+
37
+ ## TDD CYCLE PER STORY
38
+
39
+ ### 3.1 RED Phase - Write Failing Tests
40
+
41
+ **Agent:** Murat (Test Architect)
42
+
43
+ **Input:**
44
+ - Story file with acceptance criteria
45
+ - Existing test patterns (if any)
46
+ - Project test framework configuration
47
+
48
+ **Process:**
49
+
50
+ ```yaml
51
+ red_phase:
52
+ steps:
53
+ 1_analyze_ac:
54
+ action: "Parse acceptance criteria from story file"
55
+ output: "List of testable assertions"
56
+
57
+ 2_design_tests:
58
+ action: "Design test cases for each AC"
59
+ coverage:
60
+ - happy_path: "Main success scenarios"
61
+ - edge_cases: "Boundary conditions"
62
+ - error_cases: "Error handling"
63
+
64
+ 3_write_tests:
65
+ action: "Write test code"
66
+ format: "Follow project test conventions"
67
+ requirement: "Tests MUST fail (no implementation yet)"
68
+
69
+ 4_verify_failure:
70
+ action: "Run tests"
71
+ expected: "All tests fail"
72
+ if_any_pass: "HALT - investigate existing implementation"
73
+
74
+ 5_document:
75
+ action: "Update story file with test info"
76
+ update: "red_phase.completed = true"
77
+ ```
78
+
79
+ **Test Template:**
80
+
81
+ ```typescript
82
+ // tests/epic-1-story-1.test.ts
83
+
84
+ describe('Story: User can log in with email and password', () => {
85
+
86
+ describe('AC1: Successful Login', () => {
87
+ it('should authenticate user with valid credentials', async () => {
88
+ // Arrange
89
+ const credentials = { email: 'user@example.com', password: 'valid123' };
90
+
91
+ // Act
92
+ const result = await login(credentials);
93
+
94
+ // Assert - THIS MUST FAIL (login not implemented)
95
+ expect(result.success).toBe(true);
96
+ expect(result.token).toBeDefined();
97
+ });
98
+
99
+ it('should redirect to dashboard after login', async () => {
100
+ // ... test that will fail
101
+ });
102
+ });
103
+
104
+ describe('AC2: Invalid Credentials', () => {
105
+ it('should return error for wrong password', async () => {
106
+ // ... test that will fail
107
+ });
108
+ });
109
+
110
+ describe('AC3: Empty Fields', () => {
111
+ it('should validate empty email', async () => {
112
+ // ... test that will fail
113
+ });
114
+ });
115
+ });
116
+ ```
117
+
118
+ **Gate: RED Phase Complete**
119
+
120
+ ```yaml
121
+ red_phase_gate:
122
+ required:
123
+ - all_ac_have_tests: true
124
+ - all_tests_failing: true
125
+ - failure_reason: "missing implementation" # Not errors
126
+
127
+ on_pass:
128
+ update_status: "red"
129
+ proceed_to: "green_phase"
130
+
131
+ on_fail:
132
+ if: "tests pass unexpectedly"
133
+ action: "HALT and investigate"
134
+
135
+ if: "test errors (not failures)"
136
+ action: "Fix test code, retry"
137
+ ```
138
+
139
+ ---
140
+
141
+ ### 3.2 GREEN Phase - Implement Until Tests Pass
142
+
143
+ **Agent:** Amelia (Developer)
144
+
145
+ **Input:**
146
+ - Story file with tasks
147
+ - Failing tests from RED phase
148
+ - Project codebase access
149
+
150
+ **Process:**
151
+
152
+ ```yaml
153
+ green_phase:
154
+ steps:
155
+ 1_review_tests:
156
+ action: "Understand what tests expect"
157
+ output: "Implementation plan"
158
+
159
+ 2_implement_task:
160
+ action: "Write minimum code for current task"
161
+ principle: "Make tests pass, nothing more"
162
+
163
+ 3_run_tests:
164
+ action: "Execute test suite"
165
+ check: "Which tests pass now?"
166
+
167
+ 4_iterate:
168
+ if: "tests still failing"
169
+ action: "Continue implementation"
170
+ retry_limit: 3
171
+
172
+ if: "all tests pass"
173
+ action: "Proceed to unit tests"
174
+
175
+ 5_add_unit_tests:
176
+ action: "Add unit tests for implementation details"
177
+ coverage: "Test internal logic not covered by AC tests"
178
+
179
+ 6_verify_all_green:
180
+ action: "Run full test suite"
181
+ required: "ALL tests pass (AC + unit + existing)"
182
+ ```
183
+
184
+ **Implementation Loop:**
185
+
186
+ ```
187
+ attempt = 0
188
+ max_attempts = 3
189
+
190
+ WHILE attempt < max_attempts:
191
+ implement_next_task()
192
+ result = run_tests()
193
+
194
+ IF result.all_pass:
195
+ BREAK # Success!
196
+
197
+ IF result.some_pass AND result.progress:
198
+ continue # Making progress
199
+
200
+ IF result.no_progress:
201
+ attempt += 1
202
+ analyze_failure()
203
+ adjust_approach()
204
+
205
+ IF attempt >= max_attempts:
206
+ mark_story_blocked("GREEN phase failed after max retries")
207
+ CONTINUE to next story
208
+ ```
209
+
210
+ **Gate: GREEN Phase Complete**
211
+
212
+ ```yaml
213
+ green_phase_gate:
214
+ required:
215
+ - all_acceptance_tests_pass: true
216
+ - all_unit_tests_pass: true
217
+ - no_regression: true # Existing tests still pass
218
+ - code_compiles: true
219
+
220
+ on_pass:
221
+ update_status: "green"
222
+ proceed_to: "refactor_phase"
223
+
224
+ on_fail:
225
+ increment_retry_count
226
+ if: retry_count < max_retries
227
+ action: "Continue implementation"
228
+
229
+ if: retry_count >= max_retries
230
+ action: "Mark story BLOCKED, continue to next story"
231
+ ```
232
+
233
+ ---
234
+
235
+ ### 3.3 REFACTOR Phase - Review and Improve
236
+
237
+ **Agent:** Marcus (Code Reviewer)
238
+
239
+ **Input:**
240
+ - Implemented code (GREEN state)
241
+ - Story file with AC
242
+ - Test results
243
+
244
+ **Process:**
245
+
246
+ ```yaml
247
+ refactor_phase:
248
+ steps:
249
+ 1_verify_green:
250
+ action: "Confirm all tests passing"
251
+ required: true
252
+
253
+ 2_review_code:
254
+ action: "Adversarial code review"
255
+ checklist:
256
+ - correctness: "Matches AC?"
257
+ - testing: "Adequate coverage?"
258
+ - security: "OWASP top 10?"
259
+ - performance: "Efficient?"
260
+ - maintainability: "Clean code?"
261
+
262
+ 3_document_issues:
263
+ action: "List all issues found"
264
+ minimum: 3 # Find at least 3 things
265
+ categorize: [critical, moderate, minor]
266
+
267
+ 4_auto_fix:
268
+ action: "Fix issues where possible"
269
+ after_each_fix: "Run tests"
270
+ if_tests_break: "Revert fix"
271
+
272
+ 5_verify_green:
273
+ action: "Confirm all tests still passing"
274
+ required: true
275
+
276
+ 6_document_remaining:
277
+ action: "Document issues needing manual attention"
278
+ if_critical_remain: "Loop back to GREEN"
279
+ ```
280
+
281
+ **Review Output:**
282
+
283
+ ```markdown
284
+ ## Code Review: epic-1-story-1
285
+
286
+ ### Issues Found: 5
287
+
288
+ #### Critical (0)
289
+ None
290
+
291
+ #### Moderate (2)
292
+ 1. **Missing input validation** - `login.ts:23`
293
+ - Risk: Potential injection
294
+ - Fix: Added validation ✓
295
+
296
+ 2. **No rate limiting** - `auth-controller.ts:45`
297
+ - Risk: Brute force attacks
298
+ - Fix: Added rate limiter ✓
299
+
300
+ #### Minor (3)
301
+ 1. Variable naming: `res` → `response` ✓
302
+ 2. Missing JSDoc on public function ✓
303
+ 3. Console.log left in code ✓
304
+
305
+ ### Tests After Fixes
306
+ ✓ All 12 tests passing
307
+
308
+ ### Recommendation
309
+ APPROVED - All issues addressed, tests green
310
+ ```
311
+
312
+ **Gate: REFACTOR Phase Complete**
313
+
314
+ ```yaml
315
+ refactor_phase_gate:
316
+ required:
317
+ - review_completed: true
318
+ - no_critical_issues: true
319
+ - no_moderate_issues: true # All fixed
320
+ - all_tests_passing: true
321
+
322
+ on_pass:
323
+ update_status: "done"
324
+ proceed_to: "next_story"
325
+
326
+ on_fail:
327
+ if: "critical/moderate issues remain"
328
+ action: "Loop back to GREEN phase with fix instructions"
329
+
330
+ if: "tests broken by refactor"
331
+ action: "Revert, try alternative fix"
332
+ ```
333
+
334
+ ---
335
+
336
+ ## UPDATE STATE (Per Story)
337
+
338
+ ```yaml
339
+ # Update pipeline-status.yaml after each phase
340
+
341
+ stories:
342
+ - id: "epic-1-story-1"
343
+ status: "done" # pending → red → green → refactor → done
344
+
345
+ red_phase:
346
+ completed: true
347
+ completed_at: "<timestamp>"
348
+ tests_written: 8
349
+ tests_failing: 8
350
+
351
+ green_phase:
352
+ completed: true
353
+ completed_at: "<timestamp>"
354
+ retry_count: 1
355
+ tests_passing: 12 # 8 AC + 4 unit
356
+
357
+ refactor_phase:
358
+ completed: true
359
+ completed_at: "<timestamp>"
360
+ issues_found: 5
361
+ issues_fixed: 5
362
+ issues_remaining: 0
363
+ ```
364
+
365
+ ---
366
+
367
+ ## BLOCKED STORY HANDLING
368
+
369
+ When a story cannot complete after max retries:
370
+
371
+ ```yaml
372
+ blocked_story:
373
+ id: "epic-1-story-3"
374
+ status: "blocked"
375
+ blocked_at: "<timestamp>"
376
+ blocked_phase: "green" # Where it got stuck
377
+
378
+ failure_details:
379
+ attempts: 3
380
+ last_error: "Cannot resolve dependency injection"
381
+ tests_passing: 3
382
+ tests_failing: 2
383
+
384
+ recommendation: "Manual intervention required"
385
+ ```
386
+
387
+ **Continue to next story** - don't halt entire pipeline for one blocked story.
388
+
389
+ ---
390
+
391
+ ## LOOP EXIT CONDITIONS
392
+
393
+ ```yaml
394
+ exit_conditions:
395
+ success:
396
+ - all_stories_status: "done"
397
+
398
+ partial_success:
399
+ - some_stories: "done"
400
+ - some_stories: "blocked"
401
+ - action: "Proceed to Phase 4, report blocked stories"
402
+
403
+ failure:
404
+ - all_stories: "blocked"
405
+ - action: "Halt pipeline, generate failure report"
406
+ ```
407
+
408
+ ---
409
+
410
+ ## AUTONOMOUS BEHAVIOR
411
+
412
+ In autonomous mode:
413
+ - **No human prompts** between phases
414
+ - **Automatic retry** up to max_retry_attempts
415
+ - **Skip blocked stories** and continue
416
+ - **Log everything** for post-run analysis
417
+
418
+ ---
419
+
420
+ ## NEXT STEP
421
+
422
+ On loop complete → Load `step-04-complete.md`