@windyroad/tdd 0.1.2-preview.13 → 0.1.3
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/hooks/hooks.json
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
{ "matcher": "Edit|Write", "hooks": [{ "type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/hooks/tdd-enforce-edit.sh" }] }
|
|
8
8
|
],
|
|
9
9
|
"PostToolUse": [
|
|
10
|
-
{ "matcher": "Edit|Write", "hooks": [{ "type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/hooks/tdd-post-write.sh" }] }
|
|
10
|
+
{ "matcher": "Edit|Write", "hooks": [{ "type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/hooks/tdd-post-write.sh" }] },
|
|
11
|
+
{ "matcher": "Skill", "hooks": [{ "type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/hooks/tdd-setup-marker.sh" }] }
|
|
11
12
|
],
|
|
12
13
|
"Stop": [
|
|
13
14
|
{ "hooks": [{ "type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/hooks/tdd-reset.sh" }] }
|
package/hooks/lib/tdd-gate.sh
CHANGED
|
@@ -27,8 +27,8 @@ tdd_classify_file() {
|
|
|
27
27
|
|
|
28
28
|
# Exempt files (not gated)
|
|
29
29
|
case "$FILE_PATH" in
|
|
30
|
-
# Config files
|
|
31
|
-
*.config.*|*.json|*.yml|*.yaml) echo "exempt"; return ;;
|
|
30
|
+
# Config and setup files (test infrastructure)
|
|
31
|
+
*.config.*|*.setup.*|*.json|*.yml|*.yaml) echo "exempt"; return ;;
|
|
32
32
|
# Module configs (*.mjs, *.cjs are config when at root or named as config)
|
|
33
33
|
*.mjs|*.cjs) echo "exempt"; return ;;
|
|
34
34
|
# Styles
|
|
@@ -158,6 +158,7 @@ tdd_cleanup() {
|
|
|
158
158
|
rm -f "$(_tdd_state_file "$SESSION_ID")"
|
|
159
159
|
rm -f "$(_tdd_test_files_file "$SESSION_ID")"
|
|
160
160
|
rm -f "$(_tdd_test_stdout_file "$SESSION_ID")"
|
|
161
|
+
rm -f "/tmp/tdd-setup-active-${SESSION_ID}"
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
# --- Deny Helper ---
|
|
@@ -21,10 +21,14 @@ if [ "$FILE_TYPE" != "impl" ]; then
|
|
|
21
21
|
exit 0
|
|
22
22
|
fi
|
|
23
23
|
|
|
24
|
-
# If no test script configured,
|
|
24
|
+
# If no test script configured, check if setup skill is running
|
|
25
25
|
if ! tdd_has_test_script; then
|
|
26
|
+
# Allow edits if the setup skill is actively running (chicken-and-egg bypass)
|
|
27
|
+
if [ -n "$SESSION_ID" ] && [ -f "/tmp/tdd-setup-active-${SESSION_ID}" ]; then
|
|
28
|
+
exit 0
|
|
29
|
+
fi
|
|
26
30
|
BASENAME=$(basename "$FILE_PATH")
|
|
27
|
-
tdd_deny_json "BLOCKED: Cannot edit '${BASENAME}' because no test script is configured in package.json. Run /wr-tdd:
|
|
31
|
+
tdd_deny_json "BLOCKED: Cannot edit '${BASENAME}' because no test script is configured in package.json. Run /wr-tdd:setup-tests to set up a test framework for this project. TDD enforcement requires a working test runner before implementation code can be written."
|
|
28
32
|
exit 0
|
|
29
33
|
fi
|
|
30
34
|
|
package/hooks/tdd-inject.sh
CHANGED
|
@@ -18,7 +18,7 @@ This project has NO test script configured in package.json. Implementation file
|
|
|
18
18
|
edits (.ts, .tsx, .js, .jsx) are BLOCKED until testing is set up.
|
|
19
19
|
|
|
20
20
|
If the user's task involves writing or editing implementation code, you MUST
|
|
21
|
-
run /wr-tdd:
|
|
21
|
+
run /wr-tdd:setup-tests first to configure a test framework for this project.
|
|
22
22
|
|
|
23
23
|
Test files, config files, docs, and styles are still writable.
|
|
24
24
|
HOOK_OUTPUT
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# PostToolUse:Skill hook — sets a marker when /wr-tdd:setup-tests is invoked.
|
|
3
|
+
# This marker allows tdd-enforce-edit.sh to permit edits during test setup,
|
|
4
|
+
# avoiding the chicken-and-egg problem where the setup skill needs to write
|
|
5
|
+
# .ts/.js files but the enforce hook blocks them.
|
|
6
|
+
|
|
7
|
+
INPUT=$(cat)
|
|
8
|
+
|
|
9
|
+
SKILL_NAME=$(echo "$INPUT" | jq -r '.tool_input.skill // empty') || true
|
|
10
|
+
SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // empty') || true
|
|
11
|
+
|
|
12
|
+
if [ -z "$SESSION_ID" ] || [ -z "$SKILL_NAME" ]; then
|
|
13
|
+
exit 0
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
# Match the TDD setup skill (handles both full and short names)
|
|
17
|
+
case "$SKILL_NAME" in
|
|
18
|
+
*tdd*setup*|*setup*test*)
|
|
19
|
+
touch "/tmp/tdd-setup-active-${SESSION_ID}"
|
|
20
|
+
;;
|
|
21
|
+
esac
|
|
22
|
+
|
|
23
|
+
exit 0
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
2
|
+
name: setup-tests
|
|
3
3
|
description: Set up a test framework for the project. Examines the codebase, recommends a test runner, configures package.json, and creates an example test.
|
|
4
4
|
allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
|
|
5
5
|
---
|