tdd-enforcer 0.1.2 → 0.1.4

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.
@@ -2,7 +2,7 @@ import { join, relative } from "node:path";
2
2
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
3
3
  import { isToolCallEventType, isBashToolResult } from "@earendil-works/pi-coding-agent";
4
4
  import { isAllowed } from "../../engine/enforce.js";
5
- import { changesSinceSnapshot, restoreFiles } from "../../engine/git.js";
5
+ import { changesSinceSnapshot } from "../../engine/git.js";
6
6
  import { loadTddState } from "./helpers.js";
7
7
  import { tddLog } from "./log.js";
8
8
 
@@ -98,23 +98,22 @@ export function registerHooks(pi: ExtensionAPI): void {
98
98
  return;
99
99
  }
100
100
 
101
- tddLog(tddDir, "INFO", "tool_result: reverting violations", {
101
+ tddLog(tddDir, "WARN", "tool_result: locked files modified by bash", {
102
102
  phase,
103
103
  violations,
104
- allChanged: changed,
105
104
  });
106
105
 
107
- restoreFiles(root, violations);
108
-
109
106
  const existingText = event.content.map((c) => ("text" in c ? c.text : "")).join("");
110
107
  return {
108
+ isError: true,
111
109
  content: [
112
110
  {
113
111
  type: "text",
114
112
  text:
115
113
  existingText +
116
- `\n\n⚠️ TDD: Bash modified files locked in ${phase.toUpperCase()} phase. ` +
117
- `Reverted: ${violations.join(", ")}`,
114
+ `\n\n ${phase.toUpperCase()}: bash modified locked files: ${violations.join(", ")}\n` +
115
+ `next_tdd_phase blocked until reverted. ` +
116
+ `Inspect with: cd .pi/tdd && git diff HEAD -- ${violations[0]}`,
118
117
  },
119
118
  ],
120
119
  };
@@ -1,7 +1,7 @@
1
1
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
2
2
  import { existsSync } from "node:fs";
3
3
  import { join } from "node:path";
4
- import { loadPhaseState, loadConfig, savePhaseState, initGit } from "../../engine/index.js";
4
+ import { loadPhaseState, loadConfig, savePhaseState, initGit, snapshot } from "../../engine/index.js";
5
5
  import { registerTools } from "./tools.js";
6
6
  import { registerHooks } from "./hooks.js";
7
7
  import { loadTddState } from "./helpers.js";
@@ -80,6 +80,12 @@ export default function (pi: ExtensionAPI) {
80
80
  tddLog(tddDir, "DEBUG", "tdd:on: git repo already exists");
81
81
  }
82
82
 
83
+ // Snapshot working tree so stale baseline doesn't nuke user changes
84
+ snapshot(root, state.current);
85
+ tddLog(tddDir, "INFO", "tdd:on: snapshot taken", {
86
+ phase: state.current,
87
+ });
88
+
83
89
  state.enabled = true;
84
90
  savePhaseState(root, state);
85
91
  tddLog(tddDir, "INFO", "tdd:on: enabled", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tdd-enforcer",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "keywords": [
6
6
  "pi-package"