autoworkflow 3.8.4 → 3.9.1

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.
@@ -53,6 +53,48 @@ get_task_type() {
53
53
  fi
54
54
  }
55
55
 
56
+ # Reflection prompts (Serena-inspired)
57
+ # These prompt Claude to self-assess before proceeding
58
+ output_reflection_prompt() {
59
+ local phase="$1"
60
+
61
+ echo ""
62
+ echo -e "${CYAN}━━━ REFLECTION CHECK ━━━${NC}"
63
+
64
+ case "$phase" in
65
+ PLAN)
66
+ echo -e "${DIM}Before proceeding to PLAN, verify:${NC}"
67
+ echo " • Have you read ALL relevant files?"
68
+ echo " • Do you understand the existing patterns?"
69
+ echo " • Have you checked BLUEPRINT.md for requirements?"
70
+ echo " • Are there edge cases you haven't considered?"
71
+ ;;
72
+ IMPLEMENT)
73
+ echo -e "${DIM}Before proceeding to IMPLEMENT, verify:${NC}"
74
+ echo " • Does this plan match the original request?"
75
+ echo " • Have you considered all affected files?"
76
+ echo " • Are there simpler alternatives?"
77
+ echo " • Will this introduce breaking changes?"
78
+ ;;
79
+ VERIFY)
80
+ echo -e "${DIM}Before proceeding to VERIFY, verify:${NC}"
81
+ echo " • Is the implementation complete?"
82
+ echo " • Have you handled all edge cases?"
83
+ echo " • Are there TODO/FIXME comments left?"
84
+ echo " • Did you test the happy path mentally?"
85
+ ;;
86
+ COMMIT)
87
+ echo -e "${DIM}Before proceeding to COMMIT, verify:${NC}"
88
+ echo " • Is this work truly complete?"
89
+ echo " • Would you be confident shipping this?"
90
+ echo " • Have you updated BLUEPRINT.md if needed?"
91
+ echo " • Does the commit message accurately describe changes?"
92
+ ;;
93
+ esac
94
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
95
+ echo ""
96
+ }
97
+
56
98
  # Check analyze gate
57
99
  check_analyze_gate() {
58
100
  echo ""
@@ -198,6 +240,13 @@ transition() {
198
240
  echo ""
199
241
  echo -e "${GREEN}✅ Gate passed - Now in ${BOLD}$to${NC} phase"
200
242
  echo ""
243
+
244
+ # Output reflection prompt for the new phase
245
+ output_reflection_prompt "$to"
246
+
247
+ # Prompt to update memories based on completed phase
248
+ prompt_memory_update "$from"
249
+
201
250
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
202
251
  echo ""
203
252
 
@@ -240,6 +289,125 @@ reset_workflow() {
240
289
  echo ""
241
290
  }
242
291
 
292
+ # ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
293
+ # MEMORY SYSTEM v2 (Serena-inspired)
294
+ # Claude edits files directly + hooks prompt at key moments
295
+ # ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
296
+
297
+ MEMORY_DIR="$STATE_DIR/memories"
298
+ mkdir -p "$MEMORY_DIR"
299
+
300
+ # Prompt Claude to update memories (called at phase transitions)
301
+ prompt_memory_update() {
302
+ local phase="$1"
303
+ local memory_type=""
304
+ local prompt_text=""
305
+
306
+ case "$phase" in
307
+ PLAN|CONFIRM)
308
+ memory_type="decisions"
309
+ prompt_text="If you made any architectural or implementation decisions, update .claude/.autoworkflow/memories/decisions.md"
310
+ ;;
311
+ IMPLEMENT|VERIFY)
312
+ memory_type="patterns"
313
+ prompt_text="If you discovered any codebase patterns, update .claude/.autoworkflow/memories/patterns.md"
314
+ ;;
315
+ COMMIT)
316
+ memory_type="context"
317
+ prompt_text="Update .claude/.autoworkflow/memories/context.md with session summary for continuity"
318
+ ;;
319
+ esac
320
+
321
+ if [ -n "$memory_type" ]; then
322
+ echo ""
323
+ echo -e "${CYAN}━━━ MEMORY UPDATE ━━━${NC}"
324
+ echo -e "${DIM}$prompt_text${NC}"
325
+ echo ""
326
+ echo -e "${DIM}Format: Add a new ## Section with date and details${NC}"
327
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━${NC}"
328
+ echo ""
329
+ fi
330
+ }
331
+
332
+ # Prompt to record a blocker (called when errors occur)
333
+ prompt_blocker_update() {
334
+ local error_context="$1"
335
+ echo ""
336
+ echo -e "${YELLOW}━━━ BLOCKER DETECTED ━━━${NC}"
337
+ echo -e "${DIM}Consider recording this in .claude/.autoworkflow/memories/blockers.md${NC}"
338
+ echo ""
339
+ echo -e "${DIM}Include: Issue, Symptoms, Workaround, Status${NC}"
340
+ echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
341
+ echo ""
342
+ }
343
+
344
+ # Load and display memories at session start
345
+ load_memories_summary() {
346
+ echo ""
347
+ echo -e "${CYAN}━━━ PROJECT MEMORIES ━━━${NC}"
348
+
349
+ local has_memories=false
350
+
351
+ # Check decisions
352
+ if [ -f "$MEMORY_DIR/decisions.md" ]; then
353
+ local decision_count=$(grep -c "^## " "$MEMORY_DIR/decisions.md" 2>/dev/null || echo "0")
354
+ if [ "$decision_count" -gt 1 ]; then # More than template
355
+ echo -e " ${GREEN}●${NC} Decisions: $((decision_count - 1)) recorded"
356
+ has_memories=true
357
+ fi
358
+ fi
359
+
360
+ # Check patterns
361
+ if [ -f "$MEMORY_DIR/patterns.md" ]; then
362
+ local pattern_count=$(grep -c "^## " "$MEMORY_DIR/patterns.md" 2>/dev/null || echo "0")
363
+ if [ "$pattern_count" -gt 1 ]; then
364
+ echo -e " ${GREEN}●${NC} Patterns: $((pattern_count - 1)) recorded"
365
+ has_memories=true
366
+ fi
367
+ fi
368
+
369
+ # Check blockers
370
+ if [ -f "$MEMORY_DIR/blockers.md" ]; then
371
+ local blocker_count=$(grep -c "^## " "$MEMORY_DIR/blockers.md" 2>/dev/null || echo "0")
372
+ if [ "$blocker_count" -gt 1 ]; then
373
+ echo -e " ${YELLOW}●${NC} Blockers: $((blocker_count - 1)) recorded"
374
+ has_memories=true
375
+ fi
376
+ fi
377
+
378
+ if [ "$has_memories" = false ]; then
379
+ echo -e " ${DIM}No memories recorded yet${NC}"
380
+ fi
381
+
382
+ echo ""
383
+ echo -e "${DIM}Read with: Read tool on .claude/.autoworkflow/memories/*.md${NC}"
384
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
385
+ echo ""
386
+ }
387
+
388
+ # Load context summary (for session resume)
389
+ load_context() {
390
+ local context_file="$MEMORY_DIR/context.md"
391
+
392
+ if [ -f "$context_file" ]; then
393
+ echo ""
394
+ echo -e "${CYAN}━━━ PREVIOUS SESSION CONTEXT ━━━${NC}"
395
+ # Show just the key sections
396
+ if grep -q "## What Was Done" "$context_file"; then
397
+ echo -e "${BOLD}What Was Done:${NC}"
398
+ sed -n '/## What Was Done/,/## /p' "$context_file" | head -8 | tail -n +2
399
+ fi
400
+ if grep -q "## What Remains" "$context_file"; then
401
+ echo -e "${BOLD}What Remains:${NC}"
402
+ sed -n '/## What Remains/,/## /p' "$context_file" | head -8 | tail -n +2
403
+ fi
404
+ echo ""
405
+ echo -e "${DIM}Full context: .claude/.autoworkflow/memories/context.md${NC}"
406
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
407
+ echo ""
408
+ fi
409
+ }
410
+
243
411
  # Main command dispatcher
244
412
  case "$1" in
245
413
  transition)
@@ -269,6 +437,19 @@ case "$1" in
269
437
  fi
270
438
  echo ""
271
439
  ;;
440
+ # Memory commands v2 (Claude edits files directly)
441
+ memories)
442
+ load_memories_summary
443
+ ;;
444
+ context)
445
+ load_context
446
+ ;;
447
+ blocker)
448
+ prompt_blocker_update "$2"
449
+ ;;
450
+ reflect)
451
+ output_reflection_prompt "$2"
452
+ ;;
272
453
  *)
273
454
  echo "Usage: phase-transition.sh <command> [args]"
274
455
  echo ""
@@ -278,5 +459,17 @@ case "$1" in
278
459
  echo " reject - Record plan rejection"
279
460
  echo " reset - Reset workflow state"
280
461
  echo " status - Show current state"
462
+ echo ""
463
+ echo "Memory Commands (Claude edits files directly):"
464
+ echo " memories - Show memory summary"
465
+ echo " context - Load previous session context"
466
+ echo " blocker - Prompt to record a blocker"
467
+ echo " reflect <phase> - Show reflection prompts"
468
+ echo ""
469
+ echo "Memory Files (edit directly with Claude):"
470
+ echo " .claude/.autoworkflow/memories/decisions.md"
471
+ echo " .claude/.autoworkflow/memories/patterns.md"
472
+ echo " .claude/.autoworkflow/memories/blockers.md"
473
+ echo " .claude/.autoworkflow/memories/context.md"
281
474
  ;;
282
475
  esac
@@ -1,12 +1,21 @@
1
1
  #!/bin/bash
2
2
  # AutoWorkflow Pre-Tool Router
3
3
  # Runs on: PreToolUse for Bash tool
4
- # Purpose: Route commands to appropriate checks
4
+ # Purpose: Route commands to appropriate checks + Mode restrictions (Serena-inspired)
5
5
  #
6
6
  # This router determines what checks to run based on the command being executed
7
+ # It also enforces task-type-aware restrictions (similar to Serena's mode switching)
7
8
 
8
9
  TOOL_INPUT="$1"
9
10
 
11
+ # Colors
12
+ RED='\033[0;31m'
13
+ YELLOW='\033[1;33m'
14
+ CYAN='\033[0;36m'
15
+ BOLD='\033[1m'
16
+ DIM='\033[2m'
17
+ NC='\033[0m'
18
+
10
19
  # Project directory (use env var if set, otherwise current directory)
11
20
  PROJECT_DIR="${CLAUDE_PROJECT_DIR:-.}"
12
21
 
@@ -14,6 +23,135 @@ PROJECT_DIR="${CLAUDE_PROJECT_DIR:-.}"
14
23
  STATE_DIR="$PROJECT_DIR/.claude/.autoworkflow"
15
24
  mkdir -p "$STATE_DIR"
16
25
 
26
+ # Get current task type
27
+ get_task_type() {
28
+ if [ -f "$STATE_DIR/task-type" ]; then
29
+ cat "$STATE_DIR/task-type"
30
+ else
31
+ echo "unknown"
32
+ fi
33
+ }
34
+
35
+ # Get current phase
36
+ get_phase() {
37
+ if [ -f "$STATE_DIR/phase" ]; then
38
+ cat "$STATE_DIR/phase"
39
+ else
40
+ echo "IDLE"
41
+ fi
42
+ }
43
+
44
+ # ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
45
+ # MODE RESTRICTIONS (Serena-inspired)
46
+ # Different task types have different allowed operations
47
+ # ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
48
+
49
+ # Check if command creates new files
50
+ is_file_creation() {
51
+ echo "$TOOL_INPUT" | grep -qE "(touch|mkdir|>|tee|cp.*-r)"
52
+ }
53
+
54
+ # Check if command modifies package dependencies
55
+ is_dependency_change() {
56
+ echo "$TOOL_INPUT" | grep -qE "(npm install|yarn add|pnpm add|pip install|go get)"
57
+ }
58
+
59
+ # Check if command runs database migrations
60
+ is_migration() {
61
+ echo "$TOOL_INPUT" | grep -qE "(migrate|prisma.*push|prisma.*migrate|alembic)"
62
+ }
63
+
64
+ # Check mode restrictions based on task type
65
+ check_mode_restrictions() {
66
+ local task_type=$(get_task_type)
67
+ local phase=$(get_phase)
68
+
69
+ case "$task_type" in
70
+ docs)
71
+ # Docs mode: Only allow documentation-related operations
72
+ if is_file_creation && ! echo "$TOOL_INPUT" | grep -qE "\.(md|txt|rst)"; then
73
+ echo ""
74
+ echo -e "${YELLOW}━━━ MODE RESTRICTION: docs ━━━${NC}"
75
+ echo ""
76
+ echo -e "Task type is ${BOLD}docs${NC} - creating non-documentation files requires approval."
77
+ echo -e "Command: ${DIM}$TOOL_INPUT${NC}"
78
+ echo ""
79
+ echo "If this is intentional, confirm with the user."
80
+ echo ""
81
+ # Warn but don't block
82
+ fi
83
+ ;;
84
+ fix)
85
+ # Fix mode: Warn on new file creation (fixes usually modify existing files)
86
+ if is_file_creation; then
87
+ echo ""
88
+ echo -e "${YELLOW}━━━ MODE RESTRICTION: fix ━━━${NC}"
89
+ echo ""
90
+ echo -e "Task type is ${BOLD}fix${NC} - creating new files is unusual for bug fixes."
91
+ echo -e "Command: ${DIM}$TOOL_INPUT${NC}"
92
+ echo ""
93
+ echo "Consider: Is this truly a fix, or should this be classified as a feature?"
94
+ echo ""
95
+ fi
96
+ if is_dependency_change; then
97
+ echo ""
98
+ echo -e "${YELLOW}━━━ MODE RESTRICTION: fix ━━━${NC}"
99
+ echo ""
100
+ echo -e "Task type is ${BOLD}fix${NC} - adding dependencies for a fix is unusual."
101
+ echo -e "Command: ${DIM}$TOOL_INPUT${NC}"
102
+ echo ""
103
+ echo "Confirm this dependency is necessary for the fix."
104
+ echo ""
105
+ fi
106
+ ;;
107
+ refactor)
108
+ # Refactor mode: Warn on behavior-changing operations
109
+ if is_migration; then
110
+ echo ""
111
+ echo -e "${YELLOW}━━━ MODE RESTRICTION: refactor ━━━${NC}"
112
+ echo ""
113
+ echo -e "Task type is ${BOLD}refactor${NC} - migrations may change behavior."
114
+ echo -e "Command: ${DIM}$TOOL_INPUT${NC}"
115
+ echo ""
116
+ echo "Refactoring should preserve existing behavior."
117
+ echo "Confirm this migration is safe."
118
+ echo ""
119
+ fi
120
+ ;;
121
+ query)
122
+ # Query mode: Read-only, warn on any modifications
123
+ if is_file_creation || is_dependency_change || is_migration; then
124
+ echo ""
125
+ echo -e "${YELLOW}━━━ MODE RESTRICTION: query ━━━${NC}"
126
+ echo ""
127
+ echo -e "Task type is ${BOLD}query${NC} - this should be read-only."
128
+ echo -e "Command: ${DIM}$TOOL_INPUT${NC}"
129
+ echo ""
130
+ echo "Queries should not modify the codebase."
131
+ echo "If modifications are needed, reclassify the task."
132
+ echo ""
133
+ fi
134
+ ;;
135
+ esac
136
+
137
+ # Phase-based restrictions
138
+ if [ "$phase" = "ANALYZE" ] || [ "$phase" = "PLAN" ]; then
139
+ if is_file_creation || is_dependency_change; then
140
+ echo ""
141
+ echo -e "${YELLOW}━━━ PHASE RESTRICTION ━━━${NC}"
142
+ echo ""
143
+ echo -e "Current phase is ${BOLD}$phase${NC} - modifications should wait for IMPLEMENT phase."
144
+ echo -e "Command: ${DIM}$TOOL_INPUT${NC}"
145
+ echo ""
146
+ echo "Complete planning and get approval before making changes."
147
+ echo ""
148
+ fi
149
+ fi
150
+ }
151
+
152
+ # Run mode restriction checks
153
+ check_mode_restrictions
154
+
17
155
  # Check if this is a git commit command
18
156
  is_git_commit() {
19
157
  echo "$TOOL_INPUT" | grep -qE "git\s+commit|git\s+.*commit"
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # This hook implements:
7
7
  # - on:conversation_start trigger
8
- # - on:blueprint_missing trigger (AUTO-RUN audit)
8
+ # - on:blueprint_missing trigger (prompt user for documentation)
9
9
  # - on:init_needed trigger
10
10
  # - on:task_received trigger (task classification)
11
11
 
@@ -37,6 +37,41 @@ SESSION_RESUMED_FILE="$STATE_DIR/session-resumed"
37
37
  CURRENT_TURN_EDITS_FILE="$STATE_DIR/current-turn-edits"
38
38
  SUGGESTIONS_SHOWN_FILE="$STATE_DIR/suggestions-shown"
39
39
 
40
+ # Memory system (Serena-inspired)
41
+ MEMORY_DIR="$STATE_DIR/memories"
42
+ CONTEXT_FILE="$MEMORY_DIR/context.md"
43
+
44
+ # Load previous context if available (Serena-inspired)
45
+ load_previous_context() {
46
+ if [ -f "$CONTEXT_FILE" ]; then
47
+ echo ""
48
+ echo -e "${CYAN}━━━ PREVIOUS SESSION CONTEXT ━━━${NC}"
49
+ echo ""
50
+ # Extract key sections from context file
51
+ if grep -q "## What Was Done" "$CONTEXT_FILE"; then
52
+ echo -e "${BOLD}What Was Done:${NC}"
53
+ sed -n '/## What Was Done/,/## /p' "$CONTEXT_FILE" | head -10 | tail -n +2
54
+ echo ""
55
+ fi
56
+ if grep -q "## What Remains" "$CONTEXT_FILE"; then
57
+ echo -e "${BOLD}What Remains:${NC}"
58
+ sed -n '/## What Remains/,/## /p' "$CONTEXT_FILE" | head -10 | tail -n +2
59
+ echo ""
60
+ fi
61
+ if grep -q "## Key Decisions Made" "$CONTEXT_FILE"; then
62
+ echo -e "${BOLD}Key Decisions:${NC}"
63
+ sed -n '/## Key Decisions Made/,/## /p' "$CONTEXT_FILE" | head -5 | tail -n +2
64
+ echo ""
65
+ fi
66
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
67
+ echo ""
68
+ echo -e "${DIM}Full context: .claude/.autoworkflow/memories/context.md${NC}"
69
+ echo ""
70
+ return 0
71
+ fi
72
+ return 1
73
+ }
74
+
40
75
  # Check for resumable session state
41
76
  check_session_resume() {
42
77
  # Only show resume prompt once per session
@@ -97,6 +132,9 @@ check_session_resume() {
97
132
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
98
133
  echo ""
99
134
 
135
+ # Load previous context if available
136
+ load_previous_context
137
+
100
138
  # Mark that we've shown the resume prompt
101
139
  touch "$SESSION_RESUMED_FILE"
102
140
  return 0
@@ -162,7 +200,7 @@ check_init_needed() {
162
200
  return 1
163
201
  }
164
202
 
165
- # Check for missing BLUEPRINT.md - triggers AUTO audit
203
+ # Check for project documentation - ask user to provide their docs
166
204
  check_blueprint() {
167
205
  # Only check once per session
168
206
  if [ -f "$BLUEPRINT_CHECK_FILE" ]; then
@@ -175,31 +213,47 @@ check_blueprint() {
175
213
  if [ ! -f "instructions/BLUEPRINT.md" ]; then
176
214
  echo ""
177
215
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
178
- echo -e "${RED}${BOLD}⚠️ AUTOWORKFLOW TRIGGER: BLUEPRINT_MISSING${NC}"
216
+ echo -e "${YELLOW}${BOLD}📋 AUTOWORKFLOW: PROJECT DOCUMENTATION NEEDED${NC}"
179
217
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
180
218
  echo ""
181
- echo "instructions/BLUEPRINT.md does not exist."
219
+ echo "No project documentation found."
220
+ echo ""
221
+ echo -e "${BOLD}Please provide your project documentation:${NC}"
222
+ echo ""
223
+ echo " ${CYAN}Option 1:${NC} Point to existing docs"
224
+ echo " • PRD (Product Requirements Document)"
225
+ echo " • Specification document"
226
+ echo " • Userflow document"
227
+ echo " • Implementation guide"
228
+ echo " • Any design/architecture docs"
229
+ echo ""
230
+ echo " ${CYAN}Option 2:${NC} Describe your project"
231
+ echo " • What does this project do?"
232
+ echo " • What are the main features?"
233
+ echo " • What's the tech stack?"
182
234
  echo ""
183
- echo -e "${BOLD}ACTION: RUN PROJECT AUDIT IMMEDIATELY${NC}"
235
+ echo " ${CYAN}Option 3:${NC} Interactive"
236
+ echo " • Say: \"Help me define my project\""
237
+ echo " • I'll ask questions to understand your project"
184
238
  echo ""
185
- echo "Do NOT ask permission to start. Just run these commands now:"
239
+ echo -e "${DIM}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
186
240
  echo ""
187
- echo -e "${CYAN}1.${NC} cat package.json | head -50 ${DIM}# Detect tech stack${NC}"
188
- echo -e "${CYAN}2.${NC} ls -la ${DIM}# See project structure${NC}"
189
- echo -e "${CYAN}3.${NC} ls src/ 2>/dev/null || ls app/ ${DIM}# Find source directory${NC}"
190
- echo -e "${CYAN}4.${NC} find . -name '*.ts' -o -name '*.tsx' | head -20"
241
+ echo -e "${BOLD}When you provide documentation:${NC}"
191
242
  echo ""
192
- echo "Then generate:"
193
- echo " - instructions/AI_RULES.md (tech stack, file structure)"
194
- echo " - instructions/BLUEPRINT.md (features, routes, APIs)"
243
+ echo " Your document = ${GREEN}SINGLE SOURCE OF TRUTH${NC}"
195
244
  echo ""
196
- echo -e "${YELLOW}Only ask user approval to SAVE, not to start scanning.${NC}"
245
+ echo " I will read and understand it"
246
+ echo " • I will reference it for all tasks"
247
+ echo " • No transformation or format conversion"
248
+ echo ""
249
+ echo -e "${DIM}Your document structure is preserved exactly as-is.${NC}"
250
+ echo -e "${DIM}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
197
251
  echo ""
198
252
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
199
253
  echo ""
200
254
 
201
- # Set phase to indicate audit is needed
202
- set_phase "AUDIT_REQUIRED"
255
+ # Set phase to indicate documentation is needed
256
+ set_phase "DOCS_REQUIRED"
203
257
  return 1
204
258
  fi
205
259
 
@@ -367,7 +421,9 @@ output_classification() {
367
421
 
368
422
  # Instructions for this phase
369
423
  echo -e "${DIM}Read relevant files and understand the codebase.${NC}"
370
- echo -e "${DIM}Check instructions/BLUEPRINT.md for requirements.${NC}"
424
+ echo -e "${DIM}Reference user's documentation for requirements.${NC}"
425
+ echo ""
426
+ echo -e "${DIM}💡 Tip: Use 'phase-transition.sh memory-save decisions <key> <value>' to record decisions.${NC}"
371
427
  echo ""
372
428
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
373
429
  echo ""
@@ -406,6 +462,47 @@ reset_turn_state() {
406
462
  echo "0" > "$CURRENT_TURN_EDITS_FILE"
407
463
  }
408
464
 
465
+ # Load and display memories summary (for context awareness)
466
+ show_memories_summary() {
467
+ local has_memories=false
468
+
469
+ # Check if any memories exist (beyond templates)
470
+ for file in "$MEMORY_DIR/decisions.md" "$MEMORY_DIR/patterns.md" "$MEMORY_DIR/blockers.md"; do
471
+ if [ -f "$file" ]; then
472
+ local count=$(grep -c "^## " "$file" 2>/dev/null || echo "0")
473
+ if [ "$count" -gt 1 ]; then
474
+ has_memories=true
475
+ break
476
+ fi
477
+ fi
478
+ done
479
+
480
+ if [ "$has_memories" = true ]; then
481
+ echo ""
482
+ echo -e "${CYAN}━━━ PROJECT MEMORIES ━━━${NC}"
483
+
484
+ if [ -f "$MEMORY_DIR/decisions.md" ]; then
485
+ local count=$(grep -c "^## " "$MEMORY_DIR/decisions.md" 2>/dev/null || echo "0")
486
+ [ "$count" -gt 1 ] && echo -e " ${GREEN}●${NC} Decisions: $((count - 1)) recorded"
487
+ fi
488
+
489
+ if [ -f "$MEMORY_DIR/patterns.md" ]; then
490
+ local count=$(grep -c "^## " "$MEMORY_DIR/patterns.md" 2>/dev/null || echo "0")
491
+ [ "$count" -gt 1 ] && echo -e " ${GREEN}●${NC} Patterns: $((count - 1)) recorded"
492
+ fi
493
+
494
+ if [ -f "$MEMORY_DIR/blockers.md" ]; then
495
+ local count=$(grep -c "^## " "$MEMORY_DIR/blockers.md" 2>/dev/null || echo "0")
496
+ [ "$count" -gt 1 ] && echo -e " ${YELLOW}●${NC} Blockers: $((count - 1)) recorded"
497
+ fi
498
+
499
+ echo ""
500
+ echo -e "${DIM}Read: .claude/.autoworkflow/memories/*.md${NC}"
501
+ echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
502
+ echo ""
503
+ fi
504
+ }
505
+
409
506
  # Main execution
410
507
  main() {
411
508
  local is_new_session=false
@@ -428,9 +525,12 @@ main() {
428
525
  check_session_resume
429
526
  fi
430
527
 
431
- # Check for missing blueprint (triggers auto-audit)
528
+ # Check for missing blueprint (prompts user for documentation)
432
529
  check_blueprint
433
530
 
531
+ # Show memories summary (if any exist)
532
+ show_memories_summary
533
+
434
534
  # Show current state if not idle
435
535
  show_state
436
536
  }
@@ -107,7 +107,7 @@
107
107
  "→ THEN execute the audit with this knowledge loaded",
108
108
  "",
109
109
  "### Auto-Triggers (Hooks enforce these)",
110
- "1. **SESSION START**: If instructions/BLUEPRINT.md missingAUTO-RUN audit (no permission needed)",
110
+ "1. **SESSION START**: If no documentation provided Prompt user for project documentation",
111
111
  "2. **AFTER CODE CHANGES**: Run `npm run verify` automatically. Fix errors until passing (max 10 iterations)",
112
112
  "3. **BEFORE COMMIT**: All 7 gates must pass or commit is BLOCKED:",
113
113
  " - TypeScript errors = 0",
@@ -135,7 +135,7 @@
135
135
  "",
136
136
  "### Required Files",
137
137
  "- Read instructions/AI_RULES.md for coding standards",
138
- "- Read instructions/BLUEPRINT.md for project state",
138
+ "- Reference user's documentation (single source of truth)",
139
139
  "- Read system/router.md to classify task type",
140
140
  "- Read system/gates.md for blocking rules",
141
141
  "",
@@ -144,7 +144,16 @@
144
144
  "- phase: Current phase (ANALYZE, PLAN, etc.)",
145
145
  "- task-type: Classified task type",
146
146
  "- verify-iteration: Current verify loop count",
147
- "- gate-status: Last gate check result"
147
+ "- gate-status: Last gate check result",
148
+ "",
149
+ "### Memory System (Persistent Context)",
150
+ "Edit these files directly using the Edit tool:",
151
+ "- `.claude/.autoworkflow/memories/decisions.md` - After PLAN: record architectural choices",
152
+ "- `.claude/.autoworkflow/memories/patterns.md` - After IMPLEMENT: record discovered patterns",
153
+ "- `.claude/.autoworkflow/memories/blockers.md` - When errors: record issues and workarounds",
154
+ "- `.claude/.autoworkflow/memories/context.md` - Before COMMIT: update session summary",
155
+ "",
156
+ "Format: ## Title, *Date*, Content, ---"
148
157
  ],
149
158
 
150
159
  "workflow": {
@@ -19,7 +19,13 @@
19
19
  "Bash(npm view:*)",
20
20
  "Bash(env)",
21
21
  "Bash(npx autoworkflow update)",
22
- "Bash(grep:*)"
22
+ "Bash(grep:*)",
23
+ "WebFetch(domain:github.com)",
24
+ "WebFetch(domain:medium.com)",
25
+ "WebFetch(domain:apidog.com)",
26
+ "WebFetch(domain:mcpservers.org)",
27
+ "WebFetch(domain:oraios.github.io)",
28
+ "Bash(bash:*)"
23
29
  ]
24
30
  }
25
31
  }