ai-sdlc 0.1.0-alpha.9 → 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.
package/README.md CHANGED
@@ -7,14 +7,15 @@ Agent-first SDLC workflow manager using Claude Agent SDK. A Kanban-style board w
7
7
 
8
8
  ## Features
9
9
 
10
- - 📋 Kanban-style story management (Backlog → Ready → In Progress → Done)
11
- - 🤖 AI-powered agents for each workflow stage
12
- - 🚀 **Full SDLC automation** for individual stories with `--auto --story` (refine research plan implement review)
13
- - 🔄 **Resume workflows after interruption** with `--continue` flag
14
- - 🎨 Customizable themes (auto, light, dark, none)
15
- - 📊 Visual progress tracking with status flags
16
- - Automatic state assessment and action recommendations
17
- - ♻️ Smart phase skipping (automatically skips completed phases)
10
+ - 📋 **Kanban-style story management** (Backlog → Ready → In Progress → Done)
11
+ - 🤖 **AI-powered agents** for each workflow stage (refine, research, plan, implement, review)
12
+ - 🚀 **Full SDLC automation** with `--auto --story` - takes a story from idea to reviewed code
13
+ - 🔴🟢🔵 **TDD Mode** - Optional Test-Driven Development enforcement with Red-Green-Refactor cycles
14
+ - 🔄 **Resume workflows** after interruption with `--continue` flag
15
+ - 👀 **Daemon mode** - Continuously watch for and process new stories with `--watch`
16
+ - 🎨 **Customizable themes** (auto, light, dark, none)
17
+ - 📊 **Visual progress tracking** with status flags [R][P][I][V]
18
+ - ♻️ **Smart phase skipping** - automatically skips completed phases
18
19
 
19
20
  ## Installation
20
21
 
@@ -26,22 +27,33 @@ npm run build
26
27
  ## Quick Start
27
28
 
28
29
  ```bash
29
- # Initialize the .ai-sdlc folder
30
+ # 1. Initialize the project
30
31
  ai-sdlc init
31
32
 
32
- # Add a new story
33
+ # 2. Add a story to the backlog
33
34
  ai-sdlc add "Implement user authentication"
34
35
 
35
- # Run the workflow (process next action)
36
- ai-sdlc run
37
-
38
- # Process all pending actions automatically
39
- ai-sdlc run --auto
36
+ # 3. View your board
37
+ ai-sdlc status
40
38
 
41
- # Resume workflow after interruption
42
- ai-sdlc run --continue
39
+ # 4. Run the full SDLC for a story (refine → research → plan → implement → review)
40
+ ai-sdlc run --auto --story implement-user-authentication
43
41
  ```
44
42
 
43
+ ### Common Commands
44
+
45
+ | Command | Description |
46
+ |---------|-------------|
47
+ | `ai-sdlc status` | View all stories in Kanban board |
48
+ | `ai-sdlc add "title"` | Add a new story to backlog |
49
+ | `ai-sdlc run` | Process next recommended action |
50
+ | `ai-sdlc run --auto` | Process all pending actions |
51
+ | `ai-sdlc run --auto --story <id>` | Full SDLC for one story |
52
+ | `ai-sdlc run --continue` | Resume after interruption |
53
+ | `ai-sdlc run --watch` | Daemon mode - watch for new stories |
54
+ | `ai-sdlc details <id>` | Show story details |
55
+ | `ai-sdlc config` | View/set configuration |
56
+
45
57
  ## CLI Commands
46
58
 
47
59
  ### `init`
@@ -415,6 +427,118 @@ ai-sdlc run --auto --story my-feature --step research
415
427
  - ❌ Running just one specific phase (use `--story --step` instead)
416
428
  - ❌ Interactive workflows requiring manual review between phases
417
429
 
430
+ ## TDD Mode (Test-Driven Development)
431
+
432
+ TDD mode enforces strict Test-Driven Development practices during implementation, ensuring code is developed using the Red-Green-Refactor cycle. This helps eliminate review failures caused by missing or improperly sequenced tests.
433
+
434
+ ### Enabling TDD Mode
435
+
436
+ **Per-story** (recommended for gradual adoption):
437
+
438
+ Add `tdd_enabled: true` to your story's frontmatter:
439
+
440
+ ```yaml
441
+ ---
442
+ id: story-abc123
443
+ title: Add user authentication
444
+ status: ready
445
+ tdd_enabled: true
446
+ ---
447
+ ```
448
+
449
+ **Globally** (for all stories):
450
+
451
+ Add to your `.ai-sdlc.json` config:
452
+
453
+ ```json
454
+ {
455
+ "tdd": {
456
+ "enabled": true
457
+ }
458
+ }
459
+ ```
460
+
461
+ ### How TDD Mode Works
462
+
463
+ When TDD is enabled, the implementation agent follows a strict Red-Green-Refactor cycle for each acceptance criterion:
464
+
465
+ ```
466
+ ┌─────────────────────────────────────────────────────────────────┐
467
+ │ TDD Cycle (per AC) │
468
+ ├─────────────────────────────────────────────────────────────────┤
469
+ │ 🔴 RED → Write failing test → Verify test FAILS │
470
+ │ 🟢 GREEN → Write minimum code → Verify test PASSES │
471
+ │ → → Verify NO regressions │
472
+ │ 🔵 REFACTOR → Improve code quality → Verify ALL tests pass │
473
+ └─────────────────────────────────────────────────────────────────┘
474
+ ```
475
+
476
+ **Cycle enforcement:**
477
+ 1. **RED**: Agent writes a test for the next acceptance criterion, verifies it fails
478
+ 2. **GREEN**: Agent writes minimum code to pass, verifies test passes and no regressions
479
+ 3. **REFACTOR**: Agent improves code quality, verifies all tests still pass
480
+ 4. **Record**: Cycle is recorded to story frontmatter and persisted
481
+ 5. **Repeat**: Process continues until all acceptance criteria are covered
482
+
483
+ ### TDD Validation in Review
484
+
485
+ When TDD is enabled, the review agent validates that:
486
+ - All TDD cycles have complete RED → GREEN → REFACTOR phases
487
+ - All tests remained green after each phase
488
+ - No cycles were skipped or incomplete
489
+
490
+ Violations generate critical review issues that must be addressed.
491
+
492
+ ### TDD Configuration Options
493
+
494
+ ```json
495
+ {
496
+ "tdd": {
497
+ "enabled": false,
498
+ "strictMode": true,
499
+ "maxCycles": 50,
500
+ "requireApprovalPerCycle": false
501
+ }
502
+ }
503
+ ```
504
+
505
+ | Option | Default | Description |
506
+ |--------|---------|-------------|
507
+ | `enabled` | `false` | Enable TDD mode globally (can be overridden per-story) |
508
+ | `strictMode` | `true` | Reserved for future strict enforcement rules |
509
+ | `maxCycles` | `50` | Maximum TDD cycles before stopping (prevents infinite loops) |
510
+ | `requireApprovalPerCycle` | `false` | Reserved for future approval workflow |
511
+
512
+ ### TDD Cycle History
513
+
514
+ TDD cycles are recorded in the story frontmatter for audit and debugging:
515
+
516
+ ```yaml
517
+ tdd_test_history:
518
+ - test_name: "should authenticate valid user"
519
+ test_file: "src/auth/login.test.ts"
520
+ red_timestamp: "2024-01-15T10:00:00.000Z"
521
+ green_timestamp: "2024-01-15T10:05:00.000Z"
522
+ refactor_timestamp: "2024-01-15T10:08:00.000Z"
523
+ all_tests_green: true
524
+ cycle_number: 1
525
+ ```
526
+
527
+ History is trimmed to the last 100 cycles to prevent unbounded growth.
528
+
529
+ ### When to Use TDD Mode
530
+
531
+ **Ideal for:**
532
+ - ✅ New feature development where test coverage is critical
533
+ - ✅ Teams adopting TDD practices
534
+ - ✅ Stories with clear, testable acceptance criteria
535
+ - ✅ Reducing review failures from missing tests
536
+
537
+ **Consider standard mode for:**
538
+ - ❌ Quick fixes or hotfixes where speed is critical
539
+ - ❌ Refactoring tasks without new functionality
540
+ - ❌ Stories without clear testable criteria
541
+
418
542
  ## Daemon/Watch Mode (--watch)
419
543
 
420
544
  The `--watch` flag runs AI-SDLC in daemon mode, continuously monitoring the backlog folder for new stories and automatically processing them through the full workflow pipeline.
@@ -729,12 +853,32 @@ Configuration is stored in `.ai-sdlc.json` at the project root.
729
853
  "requireApprovalBeforePR": false,
730
854
  "autoMergeOnApproval": false
731
855
  },
856
+ "tdd": {
857
+ "enabled": false,
858
+ "strictMode": true,
859
+ "maxCycles": 50,
860
+ "requireApprovalPerCycle": false
861
+ },
732
862
  "defaultLabels": [],
733
863
  "theme": "auto",
734
864
  "settingSources": []
735
865
  }
736
866
  ```
737
867
 
868
+ **Configuration options:**
869
+
870
+ | Section | Option | Default | Description |
871
+ |---------|--------|---------|-------------|
872
+ | `sdlcFolder` | - | `.ai-sdlc` | Folder for story files |
873
+ | `stageGates` | `requireApprovalBeforeImplementation` | `false` | Pause before implementation |
874
+ | `stageGates` | `requireApprovalBeforePR` | `false` | Pause before PR creation |
875
+ | `stageGates` | `autoMergeOnApproval` | `false` | Auto-merge approved PRs |
876
+ | `tdd` | `enabled` | `false` | Enable TDD mode globally |
877
+ | `tdd` | `strictMode` | `true` | Reserved for future use |
878
+ | `tdd` | `maxCycles` | `50` | Max TDD cycles per story |
879
+ | `tdd` | `requireApprovalPerCycle` | `false` | Reserved for future use |
880
+ | `theme` | - | `auto` | Color theme (auto/light/dark/none) |
881
+
738
882
  ### Project Settings with CLAUDE.md
739
883
 
740
884
  The Agent SDK can automatically load custom instructions from a `CLAUDE.md` file in your project's `.claude/` directory. This feature allows teams to share consistent AI behavior across all team members without manually specifying custom instructions.
@@ -1,7 +1,85 @@
1
- import { AgentProgressCallback } from '../core/client.js';
2
- import { AgentResult } from '../types/index.js';
1
+ import { runAgentQuery, AgentProgressCallback } from '../core/client.js';
2
+ import { Story, AgentResult, TDDTestCycle } from '../types/index.js';
3
3
  import { AgentOptions } from './research.js';
4
4
  export type { AgentProgressCallback };
5
+ /**
6
+ * Result from a TDD phase execution
7
+ */
8
+ export interface TDDPhaseResult {
9
+ testName: string;
10
+ testFile: string;
11
+ timestamp: string;
12
+ output: string;
13
+ success: boolean;
14
+ }
15
+ /**
16
+ * Options for TDD phase execution (allows mocking for tests)
17
+ */
18
+ export interface TDDPhaseOptions {
19
+ workingDir: string;
20
+ runAgentQuery?: typeof runAgentQuery;
21
+ onProgress?: AgentProgressCallback;
22
+ }
23
+ /**
24
+ * Options for full TDD implementation (allows mocking for tests)
25
+ */
26
+ export interface TDDImplementationOptions {
27
+ runAgentQuery?: typeof runAgentQuery;
28
+ runSingleTest?: typeof runSingleTest;
29
+ runAllTests?: typeof runAllTests;
30
+ onProgress?: AgentProgressCallback;
31
+ }
32
+ export declare const TDD_SYSTEM_PROMPT = "You are practicing strict Test-Driven Development.\n\nYour workflow MUST follow this exact cycle:\n\n**RED Phase**:\n1. Write ONE test that expresses the next acceptance criterion\n2. The test MUST fail because the functionality doesn't exist\n3. Run the test and verify it fails\n4. Explain why it fails and what it's testing\n\n**GREEN Phase**:\n1. Write the MINIMUM code to make this ONE test pass\n2. Do NOT add extra features\n3. Run the test to verify it passes\n4. Run ALL tests to ensure nothing broke\n\n**REFACTOR Phase**:\n1. Look for improvements (DRY, clarity, performance)\n2. Make changes ONLY if tests stay green\n3. Run ALL tests after each change\n\nComplete one full cycle before starting the next test.\nNever write code before writing a test.\nNever write multiple tests before making the first one pass.";
33
+ /**
34
+ * Run a single test file and return pass/fail result
35
+ */
36
+ export declare function runSingleTest(testFile: string, workingDir: string, testTimeout: number): Promise<{
37
+ passed: boolean;
38
+ output: string;
39
+ }>;
40
+ /**
41
+ * Run all tests and return pass/fail result
42
+ */
43
+ export declare function runAllTests(workingDir: string, testTimeout: number): Promise<{
44
+ passed: boolean;
45
+ output: string;
46
+ }>;
47
+ /**
48
+ * RED Phase: Write a failing test
49
+ *
50
+ * Creates a test that expresses the next acceptance criterion.
51
+ * The test MUST fail because the functionality doesn't exist yet.
52
+ */
53
+ export declare function executeRedPhase(story: Story, cycleNumber: number, options: TDDPhaseOptions): Promise<TDDPhaseResult>;
54
+ /**
55
+ * GREEN Phase: Write minimum code to pass the test
56
+ *
57
+ * Implements just enough code to make the failing test pass.
58
+ * Does NOT add extra features or optimizations.
59
+ */
60
+ export declare function executeGreenPhase(story: Story, cycleNumber: number, testFile: string, options: TDDPhaseOptions): Promise<TDDPhaseResult>;
61
+ /**
62
+ * REFACTOR Phase: Improve code while keeping tests green
63
+ *
64
+ * Improves code quality without changing behavior.
65
+ * All tests must remain passing after each change.
66
+ */
67
+ export declare function executeRefactorPhase(story: Story, cycleNumber: number, testFile: string, options: TDDPhaseOptions): Promise<TDDPhaseResult>;
68
+ /**
69
+ * Record a completed TDD cycle to the story frontmatter
70
+ */
71
+ export declare function recordTDDCycle(cycleNumber: number, redResult: TDDPhaseResult, greenResult: TDDPhaseResult, refactorResult: TDDPhaseResult): TDDTestCycle;
72
+ /**
73
+ * Check if all acceptance criteria have been covered (checked off)
74
+ */
75
+ export declare function checkACCoverage(story: Story): boolean;
76
+ /**
77
+ * Run the full TDD implementation loop
78
+ *
79
+ * Executes Red-Green-Refactor cycles until all acceptance criteria are covered
80
+ * or the maximum number of cycles is reached.
81
+ */
82
+ export declare function runTDDImplementation(story: Story, sdlcRoot: string, options?: TDDImplementationOptions): Promise<AgentResult>;
5
83
  /**
6
84
  * Implementation Agent
7
85
  *
@@ -1 +1 @@
1
- {"version":3,"file":"implementation.d.ts","sourceRoot":"","sources":["../../src/agents/implementation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAS,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,YAAY,EAAE,qBAAqB,EAAE,CAAC;AAgBtC;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,WAAW,CAAC,CA4GtB"}
1
+ {"version":3,"file":"implementation.d.ts","sourceRoot":"","sources":["../../src/agents/implementation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAa,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAI7C,YAAY,EAAE,qBAAqB,EAAE,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,aAAa,CAAC;IACrC,UAAU,CAAC,EAAE,qBAAqB,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,aAAa,CAAC,EAAE,OAAO,aAAa,CAAC;IACrC,aAAa,CAAC,EAAE,OAAO,aAAa,CAAC;IACrC,WAAW,CAAC,EAAE,OA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