tdd-enforcer 0.1.9 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tdd-enforcer",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -14,6 +14,9 @@
14
14
  "pi": {
15
15
  "extensions": [
16
16
  "./adapters/pi/index.ts"
17
+ ],
18
+ "skills": [
19
+ "./skills"
17
20
  ]
18
21
  }
19
22
  }
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: tdd-init
3
+ description: Use when the TDD enforcer extension reports missing configuration — .pi/tdd/ directory, rules.json, or state.json not found. Also use when starting TDD on a new project.
4
+ ---
5
+
6
+ # TDD Init
7
+
8
+ ## Overview
9
+
10
+ Set up the TDD enforcer. The extension enforces the Red-Green-Refactor cycle by restricting which files the agent can modify per phase.
11
+
12
+ ## What to Create
13
+
14
+ ```
15
+ project-root/
16
+ .pi/
17
+ tdd/
18
+ rules.json # File patterns and test commands
19
+ state.json # Phase state (create, then /tdd:on sets enabled)
20
+ ```
21
+
22
+ ## rules.json
23
+
24
+ ```json
25
+ {
26
+ "allowedRedPhaseFiles": ["tests/**/*.test.ts"],
27
+ "allowedGreenPhaseFiles": ["src/**/*.ts"],
28
+ "testCommands": ["npm run test"],
29
+ "timeoutSeconds": 120
30
+ }
31
+ ```
32
+
33
+ | Field | What | Why |
34
+ |-------|------|-----|
35
+ | `allowedRedPhaseFiles` | Glob patterns for files writable in RED phase | Typically test files |
36
+ | `allowedGreenPhaseFiles` | Glob patterns for files writable in GREEN phase | Typically implementation files |
37
+ | `testCommands` | Non-interactive commands (string or array) | Run on phase transitions to check gate |
38
+ | `timeoutSeconds` | Per-command timeout (default 120) | Prevents hung suites |
39
+
40
+ - Globs are relative to project root
41
+ - Files matching neither set are free in all phases
42
+ - All 3 array fields **must** be non-empty
43
+
44
+ ## state.json
45
+
46
+ ```json
47
+ {
48
+ "enabled": false,
49
+ "current": "red"
50
+ }
51
+ ```
52
+
53
+ Start with `enabled: false`. Run `/tdd:on` — it validates config, initialises the private git repo, snapshots the working tree, and sets `enabled: true`.
54
+
55
+ ## Setup Steps
56
+
57
+ 1. Create `.pi/tdd/` directory
58
+ 2. Create `.pi/tdd/rules.json` with file patterns and test commands
59
+ 3. Create `.pi/tdd/state.json` with `enabled: false, current: "red"`
60
+ 4. Run `/tdd:on` to enable enforcement
61
+
62
+ ## TDD Cycle
63
+
64
+ | Phase | Allowed | Gate to advance |
65
+ |-------|---------|-----------------|
66
+ | RED | Test files only | Tests must fail |
67
+ | GREEN | Implementation files only | Tests must pass |
68
+ | REFACTOR | All files | Tests must pass |
69
+
70
+ Use `next_tdd_phase` to advance, `previous_tdd_phase` to revert.
71
+
72
+ ## Common Patterns
73
+
74
+ **Standard split:**
75
+ ```json
76
+ "allowedRedPhaseFiles": ["tests/**/*.test.ts"],
77
+ "allowedGreenPhaseFiles": ["src/**/*.ts"]
78
+ ```
79
+
80
+ **Monorepo:**
81
+ ```json
82
+ "testCommands": ["npm run test:unit", "npm run test:e2e"]
83
+ ```
84
+
85
+ ## Recovery
86
+
87
+ ```bash
88
+ /tdd:reset # Destroys snapshot history, resets to RED (disabled)
89
+ /tdd:on # Re-enable with fresh snapshot
90
+ ```