autoworkflow 3.1.5 → 3.6.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/.claude/commands/analyze.md +19 -0
- package/.claude/commands/audit.md +26 -0
- package/.claude/commands/build.md +39 -0
- package/.claude/commands/commit.md +25 -0
- package/.claude/commands/fix.md +23 -0
- package/.claude/commands/plan.md +18 -0
- package/.claude/commands/suggest.md +23 -0
- package/.claude/commands/verify.md +18 -0
- package/.claude/hooks/post-bash-router.sh +20 -0
- package/.claude/hooks/post-commit.sh +140 -0
- package/.claude/hooks/post-edit.sh +190 -17
- package/.claude/hooks/pre-edit.sh +221 -0
- package/.claude/hooks/session-check.sh +90 -0
- package/.claude/settings.json +56 -6
- package/.claude/settings.local.json +5 -1
- package/.claude/skills/actix.md +337 -0
- package/.claude/skills/alembic.md +504 -0
- package/.claude/skills/angular.md +237 -0
- package/.claude/skills/api-design.md +187 -0
- package/.claude/skills/aspnet-core.md +377 -0
- package/.claude/skills/astro.md +245 -0
- package/.claude/skills/auth-clerk.md +327 -0
- package/.claude/skills/auth-firebase.md +367 -0
- package/.claude/skills/auth-nextauth.md +359 -0
- package/.claude/skills/auth-supabase.md +368 -0
- package/.claude/skills/axum.md +386 -0
- package/.claude/skills/blazor.md +456 -0
- package/.claude/skills/chi.md +348 -0
- package/.claude/skills/code-review.md +133 -0
- package/.claude/skills/csharp.md +296 -0
- package/.claude/skills/css-modules.md +325 -0
- package/.claude/skills/cypress.md +343 -0
- package/.claude/skills/debugging.md +133 -0
- package/.claude/skills/diesel.md +392 -0
- package/.claude/skills/django.md +301 -0
- package/.claude/skills/docker.md +319 -0
- package/.claude/skills/doctrine.md +473 -0
- package/.claude/skills/documentation.md +182 -0
- package/.claude/skills/dotnet.md +409 -0
- package/.claude/skills/drizzle.md +293 -0
- package/.claude/skills/echo.md +321 -0
- package/.claude/skills/eloquent.md +256 -0
- package/.claude/skills/emotion.md +426 -0
- package/.claude/skills/entity-framework.md +370 -0
- package/.claude/skills/express.md +316 -0
- package/.claude/skills/fastapi.md +329 -0
- package/.claude/skills/fastify.md +299 -0
- package/.claude/skills/fiber.md +315 -0
- package/.claude/skills/flask.md +322 -0
- package/.claude/skills/gin.md +342 -0
- package/.claude/skills/git.md +116 -0
- package/.claude/skills/github-actions.md +353 -0
- package/.claude/skills/go.md +377 -0
- package/.claude/skills/gorm.md +409 -0
- package/.claude/skills/graphql.md +478 -0
- package/.claude/skills/hibernate.md +379 -0
- package/.claude/skills/hono.md +306 -0
- package/.claude/skills/java.md +400 -0
- package/.claude/skills/jest.md +313 -0
- package/.claude/skills/jpa.md +282 -0
- package/.claude/skills/kotlin.md +347 -0
- package/.claude/skills/kubernetes.md +363 -0
- package/.claude/skills/laravel.md +414 -0
- package/.claude/skills/mcp-browser.md +320 -0
- package/.claude/skills/mcp-database.md +219 -0
- package/.claude/skills/mcp-fetch.md +241 -0
- package/.claude/skills/mcp-filesystem.md +204 -0
- package/.claude/skills/mcp-github.md +217 -0
- package/.claude/skills/mcp-memory.md +240 -0
- package/.claude/skills/mcp-search.md +218 -0
- package/.claude/skills/mcp-slack.md +262 -0
- package/.claude/skills/micronaut.md +388 -0
- package/.claude/skills/mongodb.md +319 -0
- package/.claude/skills/mongoose.md +355 -0
- package/.claude/skills/mysql.md +281 -0
- package/.claude/skills/nestjs.md +335 -0
- package/.claude/skills/nextjs-app-router.md +260 -0
- package/.claude/skills/nextjs-pages.md +172 -0
- package/.claude/skills/nuxt.md +202 -0
- package/.claude/skills/openapi.md +489 -0
- package/.claude/skills/performance.md +199 -0
- package/.claude/skills/php.md +398 -0
- package/.claude/skills/playwright.md +371 -0
- package/.claude/skills/postgresql.md +257 -0
- package/.claude/skills/prisma.md +293 -0
- package/.claude/skills/pydantic.md +304 -0
- package/.claude/skills/pytest.md +313 -0
- package/.claude/skills/python.md +272 -0
- package/.claude/skills/quarkus.md +377 -0
- package/.claude/skills/react.md +230 -0
- package/.claude/skills/redis.md +391 -0
- package/.claude/skills/refactoring.md +143 -0
- package/.claude/skills/remix.md +246 -0
- package/.claude/skills/rest-api.md +490 -0
- package/.claude/skills/rocket.md +366 -0
- package/.claude/skills/rust.md +341 -0
- package/.claude/skills/sass.md +380 -0
- package/.claude/skills/sea-orm.md +382 -0
- package/.claude/skills/security.md +167 -0
- package/.claude/skills/sequelize.md +395 -0
- package/.claude/skills/spring-boot.md +416 -0
- package/.claude/skills/sqlalchemy.md +269 -0
- package/.claude/skills/sqlx-rust.md +408 -0
- package/.claude/skills/state-jotai.md +346 -0
- package/.claude/skills/state-mobx.md +353 -0
- package/.claude/skills/state-pinia.md +431 -0
- package/.claude/skills/state-redux.md +337 -0
- package/.claude/skills/state-tanstack-query.md +434 -0
- package/.claude/skills/state-zustand.md +340 -0
- package/.claude/skills/styled-components.md +403 -0
- package/.claude/skills/svelte.md +238 -0
- package/.claude/skills/sveltekit.md +207 -0
- package/.claude/skills/symfony.md +437 -0
- package/.claude/skills/tailwind.md +279 -0
- package/.claude/skills/terraform.md +394 -0
- package/.claude/skills/testing-library.md +371 -0
- package/.claude/skills/trpc.md +426 -0
- package/.claude/skills/typeorm.md +368 -0
- package/.claude/skills/vitest.md +330 -0
- package/.claude/skills/vue.md +202 -0
- package/.claude/skills/warp.md +365 -0
- package/README.md +163 -52
- package/package.json +1 -1
- package/system/triggers.md +256 -17
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# AutoWorkflow Pre-Edit Hook
|
|
3
|
+
# Runs on: PreToolUse for Write/Edit tools
|
|
4
|
+
# Purpose: Enforce plan approval before implementation
|
|
5
|
+
#
|
|
6
|
+
# This hook implements the plan_approval_gate enforcement
|
|
7
|
+
# It BLOCKS Write/Edit operations if plan hasn't been approved
|
|
8
|
+
|
|
9
|
+
# Colors
|
|
10
|
+
RED='\033[0;31m'
|
|
11
|
+
GREEN='\033[0;32m'
|
|
12
|
+
YELLOW='\033[1;33m'
|
|
13
|
+
CYAN='\033[0;36m'
|
|
14
|
+
BOLD='\033[1m'
|
|
15
|
+
DIM='\033[2m'
|
|
16
|
+
NC='\033[0m'
|
|
17
|
+
|
|
18
|
+
# State directory
|
|
19
|
+
STATE_DIR=".claude/.autoworkflow"
|
|
20
|
+
|
|
21
|
+
# State files
|
|
22
|
+
PHASE_FILE="$STATE_DIR/phase"
|
|
23
|
+
TASK_TYPE_FILE="$STATE_DIR/task-type"
|
|
24
|
+
PLAN_APPROVED_FILE="$STATE_DIR/plan-approved"
|
|
25
|
+
SUGGESTIONS_SHOWN_FILE="$STATE_DIR/suggestions-shown"
|
|
26
|
+
CURRENT_TURN_EDITS_FILE="$STATE_DIR/current-turn-edits"
|
|
27
|
+
SELECTED_ITEMS_FILE="$STATE_DIR/selected-items"
|
|
28
|
+
|
|
29
|
+
# Get current phase
|
|
30
|
+
get_phase() {
|
|
31
|
+
if [ -f "$PHASE_FILE" ]; then
|
|
32
|
+
cat "$PHASE_FILE"
|
|
33
|
+
else
|
|
34
|
+
echo "IDLE"
|
|
35
|
+
fi
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# Get task type
|
|
39
|
+
get_task_type() {
|
|
40
|
+
if [ -f "$TASK_TYPE_FILE" ]; then
|
|
41
|
+
cat "$TASK_TYPE_FILE"
|
|
42
|
+
else
|
|
43
|
+
echo "unknown"
|
|
44
|
+
fi
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
# Check if plan is approved
|
|
48
|
+
is_plan_approved() {
|
|
49
|
+
if [ -f "$PLAN_APPROVED_FILE" ]; then
|
|
50
|
+
local status=$(cat "$PLAN_APPROVED_FILE")
|
|
51
|
+
[ "$status" = "true" ] && return 0
|
|
52
|
+
fi
|
|
53
|
+
return 1
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
# Check if suggestions were shown (for feature tasks)
|
|
57
|
+
suggestions_shown() {
|
|
58
|
+
if [ -f "$SUGGESTIONS_SHOWN_FILE" ]; then
|
|
59
|
+
local status=$(cat "$SUGGESTIONS_SHOWN_FILE")
|
|
60
|
+
[ "$status" = "true" ] && return 0
|
|
61
|
+
fi
|
|
62
|
+
return 1
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# Get number of edits in current turn
|
|
66
|
+
get_turn_edit_count() {
|
|
67
|
+
if [ -f "$CURRENT_TURN_EDITS_FILE" ]; then
|
|
68
|
+
cat "$CURRENT_TURN_EDITS_FILE"
|
|
69
|
+
else
|
|
70
|
+
echo "0"
|
|
71
|
+
fi
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
# Increment turn edit count
|
|
75
|
+
increment_turn_edits() {
|
|
76
|
+
local current=$(get_turn_edit_count)
|
|
77
|
+
local next=$((current + 1))
|
|
78
|
+
echo "$next" > "$CURRENT_TURN_EDITS_FILE"
|
|
79
|
+
echo "$next"
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
# Check if user has selected items to implement
|
|
83
|
+
has_selected_items() {
|
|
84
|
+
if [ -f "$SELECTED_ITEMS_FILE" ]; then
|
|
85
|
+
local content=$(cat "$SELECTED_ITEMS_FILE")
|
|
86
|
+
[ -n "$content" ] && return 0
|
|
87
|
+
fi
|
|
88
|
+
return 1
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# Check if task type requires approval
|
|
92
|
+
requires_approval() {
|
|
93
|
+
local task_type="$1"
|
|
94
|
+
case "$task_type" in
|
|
95
|
+
# These task types require plan approval
|
|
96
|
+
feature|fix|refactor|perf|security|test)
|
|
97
|
+
return 0
|
|
98
|
+
;;
|
|
99
|
+
# These can proceed without explicit approval
|
|
100
|
+
docs|style|config|query)
|
|
101
|
+
return 1
|
|
102
|
+
;;
|
|
103
|
+
# Unknown defaults to requiring approval
|
|
104
|
+
*)
|
|
105
|
+
return 0
|
|
106
|
+
;;
|
|
107
|
+
esac
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
# Main check
|
|
111
|
+
main() {
|
|
112
|
+
local phase=$(get_phase)
|
|
113
|
+
local task_type=$(get_task_type)
|
|
114
|
+
|
|
115
|
+
# Skip check if no task is active
|
|
116
|
+
if [ "$phase" = "IDLE" ]; then
|
|
117
|
+
exit 0
|
|
118
|
+
fi
|
|
119
|
+
|
|
120
|
+
# Skip check for task types that don't require approval
|
|
121
|
+
if ! requires_approval "$task_type"; then
|
|
122
|
+
exit 0
|
|
123
|
+
fi
|
|
124
|
+
|
|
125
|
+
# Skip check if already in IMPLEMENT or later phases
|
|
126
|
+
case "$phase" in
|
|
127
|
+
IMPLEMENT|VERIFY|FIX|AUDIT|PRE_COMMIT|COMMIT|UPDATE)
|
|
128
|
+
# Already past approval, allow edits
|
|
129
|
+
exit 0
|
|
130
|
+
;;
|
|
131
|
+
esac
|
|
132
|
+
|
|
133
|
+
# Check if we're in a pre-approval phase
|
|
134
|
+
if [ "$phase" = "ANALYZE" ] || [ "$phase" = "PLAN" ]; then
|
|
135
|
+
if ! is_plan_approved; then
|
|
136
|
+
echo ""
|
|
137
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
138
|
+
echo -e "${RED}${BOLD}⛔ AUTOWORKFLOW: PLAN APPROVAL REQUIRED${NC}"
|
|
139
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
140
|
+
echo ""
|
|
141
|
+
echo -e "${CYAN}Current Phase:${NC} $phase"
|
|
142
|
+
echo -e "${CYAN}Task Type:${NC} $task_type"
|
|
143
|
+
echo -e "${CYAN}Plan Approved:${NC} NO"
|
|
144
|
+
echo ""
|
|
145
|
+
echo "Cannot edit files before plan approval."
|
|
146
|
+
echo ""
|
|
147
|
+
echo -e "${BOLD}Required workflow:${NC}"
|
|
148
|
+
echo " 1. Complete ANALYZE phase (read relevant files)"
|
|
149
|
+
echo " 2. Present PLAN with suggestions"
|
|
150
|
+
echo " 3. Wait for user approval"
|
|
151
|
+
echo " 4. THEN implement"
|
|
152
|
+
echo ""
|
|
153
|
+
echo -e "${DIM}To approve, user must say: yes, proceed, approved, go ahead${NC}"
|
|
154
|
+
echo ""
|
|
155
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
156
|
+
echo ""
|
|
157
|
+
|
|
158
|
+
# Exit with error to BLOCK the edit
|
|
159
|
+
exit 1
|
|
160
|
+
fi
|
|
161
|
+
fi
|
|
162
|
+
|
|
163
|
+
# CHECK: Suggestions must be shown for feature tasks before implementing
|
|
164
|
+
if [ "$task_type" = "feature" ] && [ "$phase" = "IMPLEMENT" ]; then
|
|
165
|
+
if ! suggestions_shown; then
|
|
166
|
+
echo ""
|
|
167
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
168
|
+
echo -e "${RED}${BOLD}⛔ AUTOWORKFLOW: SUGGESTIONS REQUIRED${NC}"
|
|
169
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
170
|
+
echo ""
|
|
171
|
+
echo -e "${CYAN}Task Type:${NC} feature"
|
|
172
|
+
echo ""
|
|
173
|
+
echo "For feature tasks, you MUST show 3-tier suggestions first:"
|
|
174
|
+
echo ""
|
|
175
|
+
echo " 🔴 Required - Must implement"
|
|
176
|
+
echo " 🟡 Recommended - Should implement"
|
|
177
|
+
echo " 🟢 Optional - Nice to have"
|
|
178
|
+
echo ""
|
|
179
|
+
echo "Show suggestions, let user select items, THEN implement."
|
|
180
|
+
echo ""
|
|
181
|
+
echo -e "${DIM}To mark suggestions shown: echo 'true' > $SUGGESTIONS_SHOWN_FILE${NC}"
|
|
182
|
+
echo ""
|
|
183
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
184
|
+
echo ""
|
|
185
|
+
exit 1
|
|
186
|
+
fi
|
|
187
|
+
fi
|
|
188
|
+
|
|
189
|
+
# CHECK: One fix at a time (max 1 edit per turn in FIX phase)
|
|
190
|
+
if [ "$phase" = "FIX" ]; then
|
|
191
|
+
local edit_count=$(get_turn_edit_count)
|
|
192
|
+
if [ "$edit_count" -ge 1 ]; then
|
|
193
|
+
echo ""
|
|
194
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
195
|
+
echo -e "${YELLOW}${BOLD}⚠ AUTOWORKFLOW: ONE FIX AT A TIME${NC}"
|
|
196
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
197
|
+
echo ""
|
|
198
|
+
echo -e "${CYAN}Edits this turn:${NC} $edit_count"
|
|
199
|
+
echo ""
|
|
200
|
+
echo "Fix ONE issue at a time, then verify."
|
|
201
|
+
echo ""
|
|
202
|
+
echo "This ensures:"
|
|
203
|
+
echo " 1. Easier to track what changed"
|
|
204
|
+
echo " 2. Errors caught early"
|
|
205
|
+
echo " 3. User can review incrementally"
|
|
206
|
+
echo ""
|
|
207
|
+
echo "Wait for verification to complete before next fix."
|
|
208
|
+
echo ""
|
|
209
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
210
|
+
echo ""
|
|
211
|
+
exit 1
|
|
212
|
+
fi
|
|
213
|
+
# Track this edit
|
|
214
|
+
increment_turn_edits > /dev/null
|
|
215
|
+
fi
|
|
216
|
+
|
|
217
|
+
# All checks passed, allow edit
|
|
218
|
+
exit 0
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
main
|
|
@@ -28,6 +28,80 @@ PHASE_FILE="$STATE_DIR/phase"
|
|
|
28
28
|
TASK_TYPE_FILE="$STATE_DIR/task-type"
|
|
29
29
|
BLUEPRINT_CHECK_FILE="$STATE_DIR/blueprint-checked"
|
|
30
30
|
TASK_DESCRIPTION_FILE="$STATE_DIR/task-description"
|
|
31
|
+
PLAN_APPROVED_FILE="$STATE_DIR/plan-approved"
|
|
32
|
+
CHANGED_FILES_FILE="$STATE_DIR/changed-files"
|
|
33
|
+
SESSION_RESUMED_FILE="$STATE_DIR/session-resumed"
|
|
34
|
+
CURRENT_TURN_EDITS_FILE="$STATE_DIR/current-turn-edits"
|
|
35
|
+
SUGGESTIONS_SHOWN_FILE="$STATE_DIR/suggestions-shown"
|
|
36
|
+
|
|
37
|
+
# Check for resumable session state
|
|
38
|
+
check_session_resume() {
|
|
39
|
+
# Only show resume prompt once per session
|
|
40
|
+
if [ -f "$SESSION_RESUMED_FILE" ]; then
|
|
41
|
+
return 1
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
# Check if there's a previous session with active state
|
|
45
|
+
if [ -f "$PHASE_FILE" ]; then
|
|
46
|
+
local phase=$(cat "$PHASE_FILE")
|
|
47
|
+
|
|
48
|
+
# Only prompt for non-idle, non-complete states
|
|
49
|
+
if [ "$phase" != "IDLE" ] && [ "$phase" != "" ] && [ "$phase" != "COMMIT" ]; then
|
|
50
|
+
local task_type=""
|
|
51
|
+
local verify_iter="0"
|
|
52
|
+
local plan_approved="false"
|
|
53
|
+
local changed_count="0"
|
|
54
|
+
|
|
55
|
+
[ -f "$TASK_TYPE_FILE" ] && task_type=$(cat "$TASK_TYPE_FILE")
|
|
56
|
+
[ -f "$STATE_DIR/verify-iteration" ] && verify_iter=$(cat "$STATE_DIR/verify-iteration")
|
|
57
|
+
[ -f "$PLAN_APPROVED_FILE" ] && plan_approved=$(cat "$PLAN_APPROVED_FILE")
|
|
58
|
+
[ -f "$CHANGED_FILES_FILE" ] && changed_count=$(wc -l < "$CHANGED_FILES_FILE" 2>/dev/null | tr -d ' ')
|
|
59
|
+
|
|
60
|
+
echo ""
|
|
61
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
62
|
+
echo -e "${CYAN}${BOLD}📍 AUTOWORKFLOW: SESSION RESUME${NC}"
|
|
63
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
64
|
+
echo ""
|
|
65
|
+
echo -e "${BOLD}Previous session state detected:${NC}"
|
|
66
|
+
echo ""
|
|
67
|
+
echo -e " ${CYAN}Phase:${NC} $phase"
|
|
68
|
+
[ -n "$task_type" ] && echo -e " ${CYAN}Task type:${NC} $task_type"
|
|
69
|
+
echo -e " ${CYAN}Plan approved:${NC} $plan_approved"
|
|
70
|
+
echo -e " ${CYAN}Verify attempts:${NC} $verify_iter/10"
|
|
71
|
+
[ "$changed_count" -gt 0 ] 2>/dev/null && echo -e " ${CYAN}Changed files:${NC} $changed_count"
|
|
72
|
+
echo ""
|
|
73
|
+
|
|
74
|
+
# Show changed files if any
|
|
75
|
+
if [ -f "$CHANGED_FILES_FILE" ] && [ "$changed_count" -gt 0 ] 2>/dev/null; then
|
|
76
|
+
echo -e "${DIM}Pending changes:${NC}"
|
|
77
|
+
head -5 "$CHANGED_FILES_FILE" | while read file; do
|
|
78
|
+
echo -e " ${DIM}- $file${NC}"
|
|
79
|
+
done
|
|
80
|
+
[ "$changed_count" -gt 5 ] 2>/dev/null && echo -e " ${DIM}... and $((changed_count - 5)) more${NC}"
|
|
81
|
+
echo ""
|
|
82
|
+
fi
|
|
83
|
+
|
|
84
|
+
# Show workflow position
|
|
85
|
+
local workflow=$(get_workflow "$task_type")
|
|
86
|
+
echo -e "${DIM}Workflow: $workflow${NC}"
|
|
87
|
+
echo -e "${DIM} ↑ Current: $phase${NC}"
|
|
88
|
+
echo ""
|
|
89
|
+
|
|
90
|
+
echo "Continue from $phase phase, or start fresh?"
|
|
91
|
+
echo ""
|
|
92
|
+
echo -e "${DIM}(Say 'continue' to resume, or describe new task to start fresh)${NC}"
|
|
93
|
+
echo ""
|
|
94
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
95
|
+
echo ""
|
|
96
|
+
|
|
97
|
+
# Mark that we've shown the resume prompt
|
|
98
|
+
touch "$SESSION_RESUMED_FILE"
|
|
99
|
+
return 0
|
|
100
|
+
fi
|
|
101
|
+
fi
|
|
102
|
+
|
|
103
|
+
return 1
|
|
104
|
+
}
|
|
31
105
|
|
|
32
106
|
# Generate session ID if new session
|
|
33
107
|
init_session() {
|
|
@@ -39,6 +113,8 @@ init_session() {
|
|
|
39
113
|
rm -f "$STATE_DIR/changed-files" 2>/dev/null
|
|
40
114
|
rm -f "$BLUEPRINT_CHECK_FILE" 2>/dev/null
|
|
41
115
|
rm -f "$TASK_TYPE_FILE" 2>/dev/null
|
|
116
|
+
rm -f "$PLAN_APPROVED_FILE" 2>/dev/null
|
|
117
|
+
rm -f "$SESSION_RESUMED_FILE" 2>/dev/null
|
|
42
118
|
return 0 # New session
|
|
43
119
|
fi
|
|
44
120
|
return 1 # Existing session
|
|
@@ -321,6 +397,12 @@ show_state() {
|
|
|
321
397
|
fi
|
|
322
398
|
}
|
|
323
399
|
|
|
400
|
+
# Reset turn-based state (called each user turn)
|
|
401
|
+
reset_turn_state() {
|
|
402
|
+
# Reset edit counter for this turn
|
|
403
|
+
echo "0" > "$CURRENT_TURN_EDITS_FILE"
|
|
404
|
+
}
|
|
405
|
+
|
|
324
406
|
# Main execution
|
|
325
407
|
main() {
|
|
326
408
|
local is_new_session=false
|
|
@@ -330,11 +412,19 @@ main() {
|
|
|
330
412
|
is_new_session=true
|
|
331
413
|
fi
|
|
332
414
|
|
|
415
|
+
# Reset turn state on each user message
|
|
416
|
+
reset_turn_state
|
|
417
|
+
|
|
333
418
|
# Check if init is needed (package installed but not set up)
|
|
334
419
|
if check_init_needed; then
|
|
335
420
|
exit 0
|
|
336
421
|
fi
|
|
337
422
|
|
|
423
|
+
# Check for session resume (only on existing sessions)
|
|
424
|
+
if [ "$is_new_session" = false ]; then
|
|
425
|
+
check_session_resume
|
|
426
|
+
fi
|
|
427
|
+
|
|
338
428
|
# Check for missing blueprint (triggers auto-audit)
|
|
339
429
|
check_blueprint
|
|
340
430
|
|
package/.claude/settings.json
CHANGED
|
@@ -18,6 +18,30 @@
|
|
|
18
18
|
]
|
|
19
19
|
}
|
|
20
20
|
],
|
|
21
|
+
"PreToolUse": [
|
|
22
|
+
{
|
|
23
|
+
"matcher": "Write|Edit",
|
|
24
|
+
"hooks": [
|
|
25
|
+
{
|
|
26
|
+
"type": "command",
|
|
27
|
+
"command": "./.claude/hooks/pre-edit.sh",
|
|
28
|
+
"timeout": 5,
|
|
29
|
+
"statusMessage": "Checking plan approval..."
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"matcher": "Bash",
|
|
35
|
+
"hooks": [
|
|
36
|
+
{
|
|
37
|
+
"type": "command",
|
|
38
|
+
"command": "./.claude/hooks/pre-tool-router.sh \"$TOOL_INPUT\"",
|
|
39
|
+
"timeout": 300,
|
|
40
|
+
"statusMessage": "Checking workflow gates..."
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
],
|
|
21
45
|
"PostToolUse": [
|
|
22
46
|
{
|
|
23
47
|
"matcher": "Write|Edit",
|
|
@@ -29,17 +53,15 @@
|
|
|
29
53
|
"statusMessage": "Running verification..."
|
|
30
54
|
}
|
|
31
55
|
]
|
|
32
|
-
}
|
|
33
|
-
],
|
|
34
|
-
"PreToolUse": [
|
|
56
|
+
},
|
|
35
57
|
{
|
|
36
58
|
"matcher": "Bash",
|
|
37
59
|
"hooks": [
|
|
38
60
|
{
|
|
39
61
|
"type": "command",
|
|
40
|
-
"command": "./.claude/hooks/
|
|
41
|
-
"timeout":
|
|
42
|
-
"statusMessage": "Checking
|
|
62
|
+
"command": "./.claude/hooks/post-bash-router.sh \"$TOOL_INPUT\"",
|
|
63
|
+
"timeout": 30,
|
|
64
|
+
"statusMessage": "Checking post-command actions..."
|
|
43
65
|
}
|
|
44
66
|
]
|
|
45
67
|
}
|
|
@@ -56,6 +78,34 @@
|
|
|
56
78
|
"ANALYZE → PLAN → CONFIRM → IMPLEMENT → VERIFY → AUDIT → COMMIT → UPDATE",
|
|
57
79
|
"```",
|
|
58
80
|
"",
|
|
81
|
+
"### CRITICAL: ONE FIX AT A TIME RULE",
|
|
82
|
+
"**This is NON-NEGOTIABLE and applies to ALL projects (TypeScript, PHP, Python, Go, Rust, etc.):**",
|
|
83
|
+
"",
|
|
84
|
+
"1. **NEVER batch multiple fixes** - Fix ONE issue, verify, then move to next",
|
|
85
|
+
"2. **MUST show 3-tier suggestions FIRST** before any fix:",
|
|
86
|
+
" - 🔴 Required (must fix)",
|
|
87
|
+
" - 🟡 Recommended (should fix)",
|
|
88
|
+
" - 🟢 Optional (nice to have)",
|
|
89
|
+
"3. **MUST WAIT for user to select** which items to implement",
|
|
90
|
+
"4. **After user selects**, implement ONE item at a time",
|
|
91
|
+
"5. **Verify after EACH fix** before moving to the next",
|
|
92
|
+
"",
|
|
93
|
+
"❌ WRONG: 'I found 14 issues, let me fix them all'",
|
|
94
|
+
"✅ RIGHT: 'I found 14 issues. Here are my suggestions: [show tiers]. Which would you like me to fix first?'",
|
|
95
|
+
"",
|
|
96
|
+
"",
|
|
97
|
+
"### Skill Loading (CRITICAL)",
|
|
98
|
+
"When executing ANY command from .claude/commands/:",
|
|
99
|
+
"1. Read the command's YAML frontmatter",
|
|
100
|
+
"2. Check for `skills_required` array",
|
|
101
|
+
"3. For EACH skill listed, READ the file from `.claude/skills/` BEFORE executing",
|
|
102
|
+
"4. Apply the knowledge from skills during command execution",
|
|
103
|
+
"",
|
|
104
|
+
"Example: `/audit` has `skills_required: [security.md, code-review.md]`",
|
|
105
|
+
"→ Read `.claude/skills/security.md` first",
|
|
106
|
+
"→ Read `.claude/skills/code-review.md` second",
|
|
107
|
+
"→ THEN execute the audit with this knowledge loaded",
|
|
108
|
+
"",
|
|
59
109
|
"### Auto-Triggers (Hooks enforce these)",
|
|
60
110
|
"1. **SESSION START**: If instructions/BLUEPRINT.md missing → AUTO-RUN audit (no permission needed)",
|
|
61
111
|
"2. **AFTER CODE CHANGES**: Run `npm run verify` automatically. Fix errors until passing (max 10 iterations)",
|
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
"Bash(npm run typecheck:*)",
|
|
12
12
|
"Bash(git add:*)",
|
|
13
13
|
"Bash(git commit -m \"$\\(cat <<''EOF''\nfeat\\(hooks\\): implement full auto-trigger system with blocking gates\n\n- Add 7 new hook scripts for workflow automation:\n - session-check.sh: Init, blueprint check, task classification\n - post-edit.sh: Auto-verify with loop tracking \\(max 10 iterations\\)\n - pre-tool-router.sh: Route Bash commands to appropriate checks\n - pre-commit-check.sh: All 7 gate checks with blocking \\(exit 1\\)\n - phase-transition.sh: State management and gate enforcement\n - audit-runner.sh: UI enforcement + circular dependency checks\n - blueprint-generator.sh: Auto-scan project structure\n\n- Pre-commit gate now checks:\n - TypeScript errors\n - ESLint warnings\n - TODO/FIXME comments\n - console.log statements\n - Orphan features \\(UI enforcement\\)\n - Circular dependencies\n - Conventional commit format\n\n- State tracking in .claude/.autoworkflow/:\n - phase, task-type, verify-iteration, audit-iteration\n - verify-status, audit-status, plan-approved\n\n- Updated CLAUDE.md files with:\n - Slash commands table\n - Hook files reference\n - Hook integration section\n\nCo-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>\nEOF\n\\)\")",
|
|
14
|
-
"Bash(git commit:*)"
|
|
14
|
+
"Bash(git commit:*)",
|
|
15
|
+
"Bash(unzip:*)",
|
|
16
|
+
"Bash(node:*)",
|
|
17
|
+
"Bash(echo:*)",
|
|
18
|
+
"Bash(ls:*)"
|
|
15
19
|
]
|
|
16
20
|
}
|
|
17
21
|
}
|