tdd-enforcer 0.3.5 → 0.3.6
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 +1 -1
- package/adapters/pi/index.test.ts +0 -77
- package/adapters/pi/index.ts +0 -28
- package/package.json +41 -41
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ pi install npm:tdd-enforcer
|
|
|
29
29
|
|
|
30
30
|
### 2. Ask the agent to set up TDD
|
|
31
31
|
|
|
32
|
-
Tell the agent to configure TDD for your project, using the tdd-enforcer skill to create `.pi/tdd/rules.json` with the right file globs and test commands for your stack.
|
|
32
|
+
Tell the agent to configure TDD for your project, using the `tdd-enforcer` skill to create `.pi/tdd/rules.json` with the right file globs and test commands for your stack.
|
|
33
33
|
|
|
34
34
|
### 3. Enable TDD
|
|
35
35
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
2
|
import {
|
|
3
|
-
handleBeforeAgentStart,
|
|
4
3
|
handleTddJump,
|
|
5
4
|
handleTddOff,
|
|
6
5
|
handleTddOn,
|
|
@@ -418,80 +417,4 @@ describe("handleTddJump", () => {
|
|
|
418
417
|
});
|
|
419
418
|
});
|
|
420
419
|
|
|
421
|
-
// ── handleBeforeAgentStart ──────────────────────────────────────────────────
|
|
422
420
|
|
|
423
|
-
describe("handleBeforeAgentStart", () => {
|
|
424
|
-
let mockLoadTddState: ReturnType<typeof vi.fn>;
|
|
425
|
-
|
|
426
|
-
function makeDeps(overrides = {}) {
|
|
427
|
-
return {
|
|
428
|
-
loadTddState: mockLoadTddState,
|
|
429
|
-
...overrides,
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
function _makeEvent(): { systemPrompt: string } {
|
|
434
|
-
return { systemPrompt: "" };
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
beforeEach(() => {
|
|
438
|
-
vi.clearAllMocks();
|
|
439
|
-
mockLoadTddState = vi.fn();
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
it("returns instructions when TDD enabled", async () => {
|
|
443
|
-
mockLoadTddState.mockReturnValue({
|
|
444
|
-
ok: true,
|
|
445
|
-
state: { enabled: true, current: "red" },
|
|
446
|
-
config: {
|
|
447
|
-
blockedInRed: [],
|
|
448
|
-
blockedInGreen: [],
|
|
449
|
-
testCommands: [],
|
|
450
|
-
timeoutSeconds: 30,
|
|
451
|
-
},
|
|
452
|
-
});
|
|
453
|
-
const result = await handleBeforeAgentStart(
|
|
454
|
-
{ systemPrompt: "" } as any,
|
|
455
|
-
{ cwd: "/test" } as any,
|
|
456
|
-
makeDeps(),
|
|
457
|
-
);
|
|
458
|
-
expect(result).toBeDefined();
|
|
459
|
-
expect(result?.systemPrompt).toContain("TDD enforcement");
|
|
460
|
-
expect(result?.systemPrompt).toContain("locked files will be blocked");
|
|
461
|
-
expect(result?.systemPrompt).toContain("cycle so reverting is cheap");
|
|
462
|
-
expect(result?.systemPrompt).not.toContain("next_tdd_phase");
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
it("returns undefined when TDD not setup", async () => {
|
|
466
|
-
mockLoadTddState.mockReturnValue({
|
|
467
|
-
ok: false,
|
|
468
|
-
reason: "Missing .pi/tdd/",
|
|
469
|
-
});
|
|
470
|
-
const result = await handleBeforeAgentStart(
|
|
471
|
-
{ systemPrompt: "" } as any,
|
|
472
|
-
{ cwd: "/test" } as any,
|
|
473
|
-
makeDeps(),
|
|
474
|
-
);
|
|
475
|
-
expect(result).toBeUndefined();
|
|
476
|
-
});
|
|
477
|
-
|
|
478
|
-
it("returns disabled message when TDD was disabled", async () => {
|
|
479
|
-
mockLoadTddState.mockReturnValue({
|
|
480
|
-
ok: true,
|
|
481
|
-
state: { enabled: false, current: "red" },
|
|
482
|
-
config: {
|
|
483
|
-
blockedInRed: [],
|
|
484
|
-
blockedInGreen: [],
|
|
485
|
-
testCommands: [],
|
|
486
|
-
timeoutSeconds: 30,
|
|
487
|
-
},
|
|
488
|
-
});
|
|
489
|
-
const result = await handleBeforeAgentStart(
|
|
490
|
-
{ systemPrompt: "" } as any,
|
|
491
|
-
{ cwd: "/test" } as any,
|
|
492
|
-
makeDeps(),
|
|
493
|
-
);
|
|
494
|
-
expect(result).toBeDefined();
|
|
495
|
-
expect(result?.systemPrompt).toContain("was disabled");
|
|
496
|
-
});
|
|
497
|
-
});
|
package/adapters/pi/index.ts
CHANGED
|
@@ -152,30 +152,6 @@ export async function handleTddStatus(
|
|
|
152
152
|
);
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
export async function handleBeforeAgentStart(
|
|
156
|
-
event: { systemPrompt: string },
|
|
157
|
-
ctx: { cwd: string },
|
|
158
|
-
deps: {
|
|
159
|
-
loadTddState: typeof loadTddState;
|
|
160
|
-
},
|
|
161
|
-
): Promise<{ systemPrompt: string } | undefined> {
|
|
162
|
-
const tdd = deps.loadTddState(ctx.cwd);
|
|
163
|
-
if (!tdd.ok) return;
|
|
164
|
-
|
|
165
|
-
if (tdd.state.enabled) {
|
|
166
|
-
return {
|
|
167
|
-
systemPrompt:
|
|
168
|
-
event.systemPrompt +
|
|
169
|
-
"\n\nYou are working under TDD enforcement. Each phase restricts which files you can modify — locked files will be blocked automatically.\n" +
|
|
170
|
-
"Minimise the scope of each TDD cycle so reverting is cheap.",
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
return {
|
|
174
|
-
systemPrompt:
|
|
175
|
-
event.systemPrompt +
|
|
176
|
-
"\n\nTDD enforcement was disabled. File restrictions are no longer enforced.",
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
155
|
|
|
180
156
|
export async function handleTddJump(
|
|
181
157
|
phase: "red" | "green" | "refactor",
|
|
@@ -332,8 +308,4 @@ export default function (pi: ExtensionAPI) {
|
|
|
332
308
|
|
|
333
309
|
registerTools(pi);
|
|
334
310
|
registerHooks(pi);
|
|
335
|
-
|
|
336
|
-
pi.on("before_agent_start", (event, ctx) =>
|
|
337
|
-
handleBeforeAgentStart(event, ctx, { loadTddState }),
|
|
338
|
-
);
|
|
339
311
|
}
|
package/package.json
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
2
|
+
"name": "tdd-enforcer",
|
|
3
|
+
"version": "0.3.6",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "TDD enforcer extension for the pi coding agent — enforces Red-Green-Refactor phases with file access restrictions and transition gates",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Cyclone1070 <hoangmai1070@gmail.com>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/Cyclone1070/tdd-enforcer.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/Cyclone1070/tdd-enforcer/issues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/Cyclone1070/tdd-enforcer#readme",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"check": "biome check --write . && vitest run",
|
|
18
|
+
"lint": "biome check .",
|
|
19
|
+
"lint:fix": "biome check --write .",
|
|
20
|
+
"test": "vitest run"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"pi-package"
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"picomatch": "^4.0.4"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@biomejs/biome": "^2.5.0",
|
|
30
|
+
"@earendil-works/pi-coding-agent": "^0.79.6",
|
|
31
|
+
"@types/node": "^25.9.3",
|
|
32
|
+
"typebox": "^1.2.16",
|
|
33
|
+
"vitest": "^3"
|
|
34
|
+
},
|
|
35
|
+
"pi": {
|
|
36
|
+
"extensions": [
|
|
37
|
+
"./adapters/pi/index.ts"
|
|
38
|
+
],
|
|
39
|
+
"skills": [
|
|
40
|
+
"./skills"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
43
|
}
|