devflow-kit 1.0.0 → 1.2.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.
Files changed (134) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +35 -11
  3. package/dist/cli.js +5 -1
  4. package/dist/commands/ambient.d.ts +18 -0
  5. package/dist/commands/ambient.js +136 -0
  6. package/dist/commands/init.d.ts +2 -0
  7. package/dist/commands/init.js +97 -10
  8. package/dist/commands/memory.d.ts +22 -0
  9. package/dist/commands/memory.js +175 -0
  10. package/dist/commands/uninstall.js +72 -5
  11. package/dist/plugins.js +74 -3
  12. package/dist/utils/post-install.d.ts +12 -0
  13. package/dist/utils/post-install.js +82 -1
  14. package/dist/utils/safe-delete-install.d.ts +7 -0
  15. package/dist/utils/safe-delete-install.js +40 -5
  16. package/package.json +2 -1
  17. package/plugins/devflow-accessibility/.claude-plugin/plugin.json +15 -0
  18. package/plugins/devflow-ambient/.claude-plugin/plugin.json +7 -0
  19. package/plugins/devflow-ambient/README.md +49 -0
  20. package/plugins/devflow-ambient/commands/ambient.md +110 -0
  21. package/plugins/devflow-ambient/skills/ambient-router/SKILL.md +89 -0
  22. package/plugins/devflow-ambient/skills/ambient-router/references/skill-catalog.md +68 -0
  23. package/plugins/devflow-audit-claude/.claude-plugin/plugin.json +1 -1
  24. package/plugins/devflow-code-review/.claude-plugin/plugin.json +1 -4
  25. package/plugins/devflow-code-review/agents/reviewer.md +8 -0
  26. package/plugins/devflow-code-review/commands/code-review-teams.md +11 -1
  27. package/plugins/devflow-code-review/commands/code-review.md +12 -2
  28. package/plugins/devflow-core-skills/.claude-plugin/plugin.json +3 -6
  29. package/plugins/devflow-core-skills/skills/docs-framework/SKILL.md +10 -6
  30. package/plugins/devflow-core-skills/skills/test-driven-development/SKILL.md +139 -0
  31. package/plugins/devflow-core-skills/skills/test-driven-development/references/rationalization-prevention.md +111 -0
  32. package/plugins/devflow-debug/.claude-plugin/plugin.json +1 -1
  33. package/plugins/devflow-frontend-design/.claude-plugin/plugin.json +15 -0
  34. package/plugins/devflow-go/.claude-plugin/plugin.json +15 -0
  35. package/plugins/devflow-go/skills/go/SKILL.md +187 -0
  36. package/plugins/devflow-go/skills/go/references/concurrency.md +312 -0
  37. package/plugins/devflow-go/skills/go/references/detection.md +129 -0
  38. package/plugins/devflow-go/skills/go/references/patterns.md +232 -0
  39. package/plugins/devflow-go/skills/go/references/violations.md +205 -0
  40. package/plugins/devflow-implement/.claude-plugin/plugin.json +1 -3
  41. package/plugins/devflow-implement/agents/coder.md +11 -6
  42. package/plugins/devflow-java/.claude-plugin/plugin.json +15 -0
  43. package/plugins/devflow-java/skills/java/SKILL.md +183 -0
  44. package/plugins/devflow-java/skills/java/references/detection.md +120 -0
  45. package/plugins/devflow-java/skills/java/references/modern-java.md +270 -0
  46. package/plugins/devflow-java/skills/java/references/patterns.md +235 -0
  47. package/plugins/devflow-java/skills/java/references/violations.md +213 -0
  48. package/plugins/devflow-python/.claude-plugin/plugin.json +15 -0
  49. package/plugins/devflow-python/skills/python/SKILL.md +188 -0
  50. package/plugins/devflow-python/skills/python/references/async.md +220 -0
  51. package/plugins/devflow-python/skills/python/references/detection.md +128 -0
  52. package/plugins/devflow-python/skills/python/references/patterns.md +226 -0
  53. package/plugins/devflow-python/skills/python/references/violations.md +204 -0
  54. package/plugins/devflow-react/.claude-plugin/plugin.json +15 -0
  55. package/plugins/{devflow-core-skills → devflow-react}/skills/react/SKILL.md +1 -1
  56. package/plugins/{devflow-core-skills → devflow-react}/skills/react/references/patterns.md +3 -3
  57. package/plugins/devflow-resolve/.claude-plugin/plugin.json +1 -1
  58. package/plugins/devflow-rust/.claude-plugin/plugin.json +15 -0
  59. package/plugins/devflow-rust/skills/rust/SKILL.md +193 -0
  60. package/plugins/devflow-rust/skills/rust/references/detection.md +131 -0
  61. package/plugins/devflow-rust/skills/rust/references/ownership.md +242 -0
  62. package/plugins/devflow-rust/skills/rust/references/patterns.md +210 -0
  63. package/plugins/devflow-rust/skills/rust/references/violations.md +191 -0
  64. package/plugins/devflow-self-review/.claude-plugin/plugin.json +1 -1
  65. package/plugins/devflow-specify/.claude-plugin/plugin.json +1 -1
  66. package/plugins/devflow-typescript/.claude-plugin/plugin.json +15 -0
  67. package/plugins/{devflow-core-skills → devflow-typescript}/skills/typescript/references/patterns.md +3 -3
  68. package/scripts/hooks/ambient-prompt.sh +48 -0
  69. package/scripts/hooks/background-memory-update.sh +49 -8
  70. package/scripts/hooks/ensure-memory-gitignore.sh +17 -0
  71. package/scripts/hooks/pre-compact-memory.sh +12 -6
  72. package/scripts/hooks/session-start-memory.sh +50 -8
  73. package/scripts/hooks/stop-update-memory.sh +10 -6
  74. package/shared/agents/coder.md +11 -6
  75. package/shared/agents/reviewer.md +8 -0
  76. package/shared/skills/ambient-router/SKILL.md +89 -0
  77. package/shared/skills/ambient-router/references/skill-catalog.md +68 -0
  78. package/shared/skills/docs-framework/SKILL.md +10 -6
  79. package/shared/skills/go/SKILL.md +187 -0
  80. package/shared/skills/go/references/concurrency.md +312 -0
  81. package/shared/skills/go/references/detection.md +129 -0
  82. package/shared/skills/go/references/patterns.md +232 -0
  83. package/shared/skills/go/references/violations.md +205 -0
  84. package/shared/skills/java/SKILL.md +183 -0
  85. package/shared/skills/java/references/detection.md +120 -0
  86. package/shared/skills/java/references/modern-java.md +270 -0
  87. package/shared/skills/java/references/patterns.md +235 -0
  88. package/shared/skills/java/references/violations.md +213 -0
  89. package/shared/skills/python/SKILL.md +188 -0
  90. package/shared/skills/python/references/async.md +220 -0
  91. package/shared/skills/python/references/detection.md +128 -0
  92. package/shared/skills/python/references/patterns.md +226 -0
  93. package/shared/skills/python/references/violations.md +204 -0
  94. package/shared/skills/react/SKILL.md +1 -1
  95. package/shared/skills/react/references/patterns.md +3 -3
  96. package/shared/skills/rust/SKILL.md +193 -0
  97. package/shared/skills/rust/references/detection.md +131 -0
  98. package/shared/skills/rust/references/ownership.md +242 -0
  99. package/shared/skills/rust/references/patterns.md +210 -0
  100. package/shared/skills/rust/references/violations.md +191 -0
  101. package/shared/skills/test-driven-development/SKILL.md +139 -0
  102. package/shared/skills/test-driven-development/references/rationalization-prevention.md +111 -0
  103. package/shared/skills/typescript/references/patterns.md +3 -3
  104. package/src/templates/managed-settings.json +14 -0
  105. package/plugins/devflow-code-review/skills/react/SKILL.md +0 -276
  106. package/plugins/devflow-code-review/skills/react/references/patterns.md +0 -1331
  107. package/plugins/devflow-core-skills/skills/accessibility/SKILL.md +0 -229
  108. package/plugins/devflow-core-skills/skills/accessibility/references/detection.md +0 -171
  109. package/plugins/devflow-core-skills/skills/accessibility/references/patterns.md +0 -670
  110. package/plugins/devflow-core-skills/skills/accessibility/references/violations.md +0 -419
  111. package/plugins/devflow-core-skills/skills/frontend-design/SKILL.md +0 -254
  112. package/plugins/devflow-core-skills/skills/frontend-design/references/detection.md +0 -184
  113. package/plugins/devflow-core-skills/skills/frontend-design/references/patterns.md +0 -511
  114. package/plugins/devflow-core-skills/skills/frontend-design/references/violations.md +0 -453
  115. package/plugins/devflow-core-skills/skills/react/references/violations.md +0 -565
  116. package/plugins/devflow-implement/skills/accessibility/SKILL.md +0 -229
  117. package/plugins/devflow-implement/skills/accessibility/references/detection.md +0 -171
  118. package/plugins/devflow-implement/skills/accessibility/references/patterns.md +0 -670
  119. package/plugins/devflow-implement/skills/accessibility/references/violations.md +0 -419
  120. package/plugins/devflow-implement/skills/frontend-design/SKILL.md +0 -254
  121. package/plugins/devflow-implement/skills/frontend-design/references/detection.md +0 -184
  122. package/plugins/devflow-implement/skills/frontend-design/references/patterns.md +0 -511
  123. package/plugins/devflow-implement/skills/frontend-design/references/violations.md +0 -453
  124. /package/plugins/{devflow-code-review → devflow-accessibility}/skills/accessibility/SKILL.md +0 -0
  125. /package/plugins/{devflow-code-review → devflow-accessibility}/skills/accessibility/references/detection.md +0 -0
  126. /package/plugins/{devflow-code-review → devflow-accessibility}/skills/accessibility/references/patterns.md +0 -0
  127. /package/plugins/{devflow-code-review → devflow-accessibility}/skills/accessibility/references/violations.md +0 -0
  128. /package/plugins/{devflow-code-review → devflow-frontend-design}/skills/frontend-design/SKILL.md +0 -0
  129. /package/plugins/{devflow-code-review → devflow-frontend-design}/skills/frontend-design/references/detection.md +0 -0
  130. /package/plugins/{devflow-code-review → devflow-frontend-design}/skills/frontend-design/references/patterns.md +0 -0
  131. /package/plugins/{devflow-code-review → devflow-frontend-design}/skills/frontend-design/references/violations.md +0 -0
  132. /package/plugins/{devflow-code-review → devflow-react}/skills/react/references/violations.md +0 -0
  133. /package/plugins/{devflow-core-skills → devflow-typescript}/skills/typescript/SKILL.md +0 -0
  134. /package/plugins/{devflow-core-skills → devflow-typescript}/skills/typescript/references/violations.md +0 -0
@@ -0,0 +1,48 @@
1
+ #!/bin/bash
2
+
3
+ # Ambient Mode: UserPromptSubmit Hook
4
+ # Injects a classification preamble before every user prompt so Claude applies
5
+ # relevant skill loading via the ambient-router skill.
6
+ # Zero file I/O beyond stdin — static injection only.
7
+
8
+ set -euo pipefail
9
+
10
+ # jq is required to parse hook input JSON — silently no-op if missing
11
+ if ! command -v jq &>/dev/null; then exit 0; fi
12
+
13
+ INPUT=$(cat)
14
+
15
+ CWD=$(echo "$INPUT" | jq -r '.cwd // ""' 2>/dev/null)
16
+ if [ -z "$CWD" ]; then
17
+ exit 0
18
+ fi
19
+
20
+ PROMPT=$(echo "$INPUT" | jq -r '.prompt // ""' 2>/dev/null)
21
+
22
+ # Skip slash commands — they have their own orchestration
23
+ if [[ "$PROMPT" == /* ]]; then
24
+ exit 0
25
+ fi
26
+
27
+ # Skip single-word confirmations (< 2 words)
28
+ WORD_COUNT=$(echo "$PROMPT" | wc -w | tr -d ' ')
29
+ if [ "$WORD_COUNT" -lt 2 ]; then
30
+ exit 0
31
+ fi
32
+
33
+ # Inject classification preamble
34
+ PREAMBLE="AMBIENT MODE ACTIVE: Before responding, silently classify this prompt:
35
+ Intent: BUILD | DEBUG | REVIEW | PLAN | EXPLORE | CHAT
36
+ Depth: QUICK (no overhead) | STANDARD (load skills) | ESCALATE (suggest /command)
37
+
38
+ If STANDARD+: Read the ambient-router skill for classification details and skill selection matrix. For BUILD tasks, also load test-driven-development skill and enforce RED-GREEN-REFACTOR.
39
+
40
+ If QUICK: Respond normally without stating classification.
41
+ Only state classification aloud for STANDARD/ESCALATE."
42
+
43
+ jq -n --arg ctx "$PREAMBLE" '{
44
+ "hookSpecificOutput": {
45
+ "hookEventName": "UserPromptSubmit",
46
+ "additionalContext": $ctx
47
+ }
48
+ }'
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Background Working Memory Updater
4
4
  # Called by stop-update-memory.sh as a detached background process.
5
- # Resumes the parent session headlessly to update .docs/WORKING-MEMORY.md.
5
+ # Resumes the parent session headlessly to update .memory/WORKING-MEMORY.md.
6
6
  # On failure: logs error, does nothing (no fallback).
7
7
 
8
8
  set -euo pipefail
@@ -12,8 +12,8 @@ SESSION_ID="$2"
12
12
  MEMORY_FILE="$3"
13
13
  CLAUDE_BIN="$4"
14
14
 
15
- LOG_FILE="$CWD/.docs/.working-memory-update.log"
16
- LOCK_DIR="$CWD/.docs/.working-memory.lock"
15
+ LOG_FILE="$CWD/.memory/.working-memory-update.log"
16
+ LOCK_DIR="$CWD/.memory/.working-memory.lock"
17
17
 
18
18
  # --- Logging ---
19
19
 
@@ -102,20 +102,60 @@ fi
102
102
 
103
103
  # Build instruction
104
104
  if [ -n "$EXISTING_MEMORY" ]; then
105
- INSTRUCTION="Update the file $MEMORY_FILE with working memory from this session. The file already has content — possibly from a concurrent session that just wrote it moments ago. Merge this session's context with the existing content to produce a single unified working memory snapshot. Both this session and the existing content represent fresh, concurrent work — integrate both fully. Working memory captures what's active now, not a changelog. Deduplicate overlapping information. Keep under 100 lines total. Use the same structure: ## Now, ## Decisions, ## Modified Files, ## Context, ## Session Log.
105
+ PATTERNS_INSTRUCTION=""
106
+ PATTERNS_FILE="$CWD/.memory/PROJECT-PATTERNS.md"
107
+ EXISTING_PATTERNS=""
108
+ if [ -f "$PATTERNS_FILE" ]; then
109
+ EXISTING_PATTERNS=$(cat "$PATTERNS_FILE")
110
+ PATTERNS_INSTRUCTION="
111
+
112
+ Also update $PATTERNS_FILE by APPENDING any new recurring patterns discovered during this session. Do NOT overwrite existing entries — only add new ones. Skip if no new patterns were observed. Format each entry as: - **Pattern name**: Brief description (discovered: YYYY-MM-DD). Keep patterns.md under 40 entries. When approaching the limit, consolidate related patterns into broader entries rather than adding duplicates.
113
+
114
+ Existing patterns:
115
+ $EXISTING_PATTERNS"
116
+ else
117
+ PATTERNS_INSTRUCTION="
118
+
119
+ If recurring patterns were observed during this session (coding conventions, architectural decisions, team preferences, tooling quirks), create $PATTERNS_FILE with entries formatted as: - **Pattern name**: Brief description (discovered: YYYY-MM-DD). Only create this file if genuine patterns were observed — do not fabricate entries."
120
+ fi
121
+
122
+ INSTRUCTION="Update the file $MEMORY_FILE with working memory from this session. The file already has content — possibly from a concurrent session that just wrote it moments ago. Merge this session's context with the existing content to produce a single unified working memory snapshot. Both this session and the existing content represent fresh, concurrent work — integrate both fully. Working memory captures what's active now, not a changelog. Deduplicate overlapping information. Keep under 120 lines total. Use the same structure: ## Now, ## Progress, ## Decisions, ## Modified Files, ## Context, ## Session Log.
123
+
124
+ ## Progress tracks Done (completed items), Remaining (next steps), and Blockers (if any). Keep each sub-list to 1-3 items. This section reflects current work state, not historical logs.
125
+
126
+ ## Decisions entries must include date and status. Format: - **[Decision]** — [rationale] (YYYY-MM-DD) [ACTIVE|SUPERSEDED]. Mark superseded decisions rather than deleting them.${PATTERNS_INSTRUCTION}
106
127
 
107
128
  Existing content:
108
129
  $EXISTING_MEMORY"
109
130
  else
110
- INSTRUCTION="Create the file $MEMORY_FILE with working memory from this session. Keep under 100 lines. Use this structure:
131
+ PATTERNS_INSTRUCTION=""
132
+ PATTERNS_FILE="$CWD/.memory/PROJECT-PATTERNS.md"
133
+ if [ -f "$PATTERNS_FILE" ]; then
134
+ EXISTING_PATTERNS=$(cat "$PATTERNS_FILE")
135
+ PATTERNS_INSTRUCTION="
136
+
137
+ Also update $PATTERNS_FILE by APPENDING any new recurring patterns discovered during this session. Do NOT overwrite existing entries — only add new ones. Skip if no new patterns were observed. Format each entry as: - **Pattern name**: Brief description (discovered: YYYY-MM-DD). Keep patterns.md under 40 entries. When approaching the limit, consolidate related patterns into broader entries rather than adding duplicates.
138
+
139
+ Existing patterns:
140
+ $EXISTING_PATTERNS"
141
+ else
142
+ PATTERNS_INSTRUCTION="
143
+
144
+ If recurring patterns were observed during this session (coding conventions, architectural decisions, team preferences, tooling quirks), create $PATTERNS_FILE with entries formatted as: - **Pattern name**: Brief description (discovered: YYYY-MM-DD). Only create this file if genuine patterns were observed — do not fabricate entries."
145
+ fi
146
+
147
+ INSTRUCTION="Create the file $MEMORY_FILE with working memory from this session. Keep under 120 lines. Use this structure:
111
148
 
112
149
  # Working Memory
113
150
 
114
151
  ## Now
115
152
  <!-- Current focus, status, blockers (1-3 bullets) -->
116
153
 
154
+ ## Progress
155
+ <!-- Done: completed items (1-3). Remaining: next steps (1-3). Blockers: if any. -->
156
+
117
157
  ## Decisions
118
- <!-- Key decisions made this session with brief rationale -->
158
+ <!-- Format: - **[Decision]** [rationale] (YYYY-MM-DD) [ACTIVE|SUPERSEDED] -->
119
159
 
120
160
  ## Modified Files
121
161
  <!-- File paths only, most recent first -->
@@ -129,7 +169,7 @@ else
129
169
  <!-- Chronological summary of work done today (2-5 bullets) -->
130
170
 
131
171
  ### This Week
132
- <!-- Broader multi-day context if relevant -->"
172
+ <!-- Broader multi-day context if relevant -->${PATTERNS_INSTRUCTION}"
133
173
  fi
134
174
 
135
175
  # Resume session headlessly to perform the update
@@ -138,7 +178,8 @@ TIMEOUT=120 # Normal runtime 30-60s; 2x margin
138
178
  DEVFLOW_BG_UPDATER=1 env -u CLAUDECODE "$CLAUDE_BIN" -p \
139
179
  --resume "$SESSION_ID" \
140
180
  --model haiku \
141
- --dangerously-skip-permissions \
181
+ --tools "Write" \
182
+ --allowedTools "Write($CWD/.memory/WORKING-MEMORY.md)" "Write($CWD/.memory/PROJECT-PATTERNS.md)" \
142
183
  --no-session-persistence \
143
184
  --output-format text \
144
185
  "$INSTRUCTION" \
@@ -0,0 +1,17 @@
1
+ #!/bin/bash
2
+ # Ensures .memory/ exists and .gitignore entries are configured.
3
+ # Called from stop and pre-compact hooks. Idempotent, ~1μs after first run.
4
+ # Usage: source ensure-memory-gitignore.sh "$CWD"
5
+
6
+ _MEMORY_DIR="$1/.memory"
7
+
8
+ # Create .memory/ if needed
9
+ mkdir -p "$_MEMORY_DIR" 2>/dev/null || return 1
10
+
11
+ # One-time .gitignore setup (marker prevents repeated checks)
12
+ if [ ! -f "$_MEMORY_DIR/.gitignore-configured" ] && [ -e "$1/.git" ]; then
13
+ for _entry in ".memory/" ".docs/"; do
14
+ grep -qxF "$_entry" "$1/.gitignore" 2>/dev/null || echo "$_entry" >> "$1/.gitignore"
15
+ done
16
+ touch "$_MEMORY_DIR/.gitignore-configured"
17
+ fi
@@ -18,12 +18,10 @@ if [ -z "$CWD" ]; then
18
18
  exit 0
19
19
  fi
20
20
 
21
- # Only activate in DevFlow-initialized projects
22
- if [ ! -d "$CWD/.docs" ]; then
23
- exit 0
24
- fi
21
+ # Auto-create .memory/ and ensure .gitignore entries (idempotent after first run)
22
+ source "$(cd "$(dirname "$0")" && pwd)/ensure-memory-gitignore.sh" "$CWD" || exit 0
25
23
 
26
- BACKUP_FILE="$CWD/.docs/working-memory-backup.json"
24
+ BACKUP_FILE="$CWD/.memory/backup.json"
27
25
 
28
26
  # Capture git state
29
27
  GIT_BRANCH=""
@@ -39,6 +37,12 @@ if cd "$CWD" 2>/dev/null && git rev-parse --git-dir >/dev/null 2>&1; then
39
37
  GIT_DIFF_STAT=$(git diff --stat HEAD 2>/dev/null || echo "")
40
38
  fi
41
39
 
40
+ # Snapshot current WORKING-MEMORY.md (preserves session context through compaction)
41
+ MEMORY_SNAPSHOT=""
42
+ if [ -f "$CWD/.memory/WORKING-MEMORY.md" ]; then
43
+ MEMORY_SNAPSHOT=$(cat "$CWD/.memory/WORKING-MEMORY.md")
44
+ fi
45
+
42
46
  # Write backup JSON
43
47
  jq -n \
44
48
  --arg ts "$TIMESTAMP" \
@@ -46,9 +50,11 @@ jq -n \
46
50
  --arg status "$GIT_STATUS" \
47
51
  --arg log "$GIT_LOG" \
48
52
  --arg diff "$GIT_DIFF_STAT" \
53
+ --arg memory "$MEMORY_SNAPSHOT" \
49
54
  '{
50
55
  timestamp: $ts,
51
56
  trigger: "pre-compact",
57
+ memory_snapshot: $memory,
52
58
  git: {
53
59
  branch: $branch,
54
60
  status: $status,
@@ -59,7 +65,7 @@ jq -n \
59
65
 
60
66
  # Bootstrap minimal WORKING-MEMORY.md if none exists yet
61
67
  # This ensures SessionStart has context to inject after compaction
62
- MEMORY_FILE="$CWD/.docs/WORKING-MEMORY.md"
68
+ MEMORY_FILE="$CWD/.memory/WORKING-MEMORY.md"
63
69
  if [ ! -f "$MEMORY_FILE" ] && [ -n "$GIT_BRANCH" ]; then
64
70
  {
65
71
  echo "# Working Memory"
@@ -1,7 +1,7 @@
1
1
  #!/bin/bash
2
2
 
3
3
  # Working Memory: SessionStart Hook
4
- # Reads .docs/WORKING-MEMORY.md and injects it as additionalContext for the new session.
4
+ # Reads .memory/WORKING-MEMORY.md and injects it as additionalContext for the new session.
5
5
  # Also captures fresh git state so Claude knows what's changed since the memory was written.
6
6
  # Adds staleness warning if memory is >1 hour old.
7
7
 
@@ -17,12 +17,7 @@ if [ -z "$CWD" ]; then
17
17
  exit 0
18
18
  fi
19
19
 
20
- # Only activate in DevFlow-initialized projects
21
- if [ ! -d "$CWD/.docs" ]; then
22
- exit 0
23
- fi
24
-
25
- MEMORY_FILE="$CWD/.docs/WORKING-MEMORY.md"
20
+ MEMORY_FILE="$CWD/.memory/WORKING-MEMORY.md"
26
21
 
27
22
  # No memory file = nothing to restore (fresh project or first session)
28
23
  if [ ! -f "$MEMORY_FILE" ]; then
@@ -31,6 +26,13 @@ fi
31
26
 
32
27
  MEMORY_CONTENT=$(cat "$MEMORY_FILE")
33
28
 
29
+ # Read accumulated patterns if they exist
30
+ PATTERNS_FILE="$CWD/.memory/PROJECT-PATTERNS.md"
31
+ PATTERNS_CONTENT=""
32
+ if [ -f "$PATTERNS_FILE" ]; then
33
+ PATTERNS_CONTENT=$(cat "$PATTERNS_FILE")
34
+ fi
35
+
34
36
  # Compute staleness warning
35
37
  if stat --version &>/dev/null 2>&1; then
36
38
  FILE_MTIME=$(stat -c %Y "$MEMORY_FILE")
@@ -40,6 +42,30 @@ fi
40
42
  NOW=$(date +%s)
41
43
  AGE=$(( NOW - FILE_MTIME ))
42
44
 
45
+ # Check for pre-compact memory snapshot (compaction recovery)
46
+ BACKUP_FILE="$CWD/.memory/backup.json"
47
+ COMPACT_NOTE=""
48
+ if [ -f "$BACKUP_FILE" ]; then
49
+ BACKUP_MEMORY=$(jq -r '.memory_snapshot // ""' "$BACKUP_FILE" 2>/dev/null)
50
+ if [ -n "$BACKUP_MEMORY" ]; then
51
+ BACKUP_TS=$(jq -r '.timestamp // ""' "$BACKUP_FILE" 2>/dev/null)
52
+ BACKUP_EPOCH=0
53
+ if [ -n "$BACKUP_TS" ]; then
54
+ BACKUP_EPOCH=$(date -j -f "%Y-%m-%dT%H:%M:%SZ" "$BACKUP_TS" +%s 2>/dev/null \
55
+ || date -d "$BACKUP_TS" +%s 2>/dev/null \
56
+ || echo "0")
57
+ fi
58
+ if [ "$BACKUP_EPOCH" -gt "$FILE_MTIME" ]; then
59
+ COMPACT_NOTE="
60
+ --- PRE-COMPACT SNAPSHOT ($BACKUP_TS) ---
61
+ Context was compacted. This snapshot may contain decisions or progress not yet in working memory.
62
+
63
+ $BACKUP_MEMORY
64
+ "
65
+ fi
66
+ fi
67
+ fi
68
+
43
69
  STALE_WARNING=""
44
70
  if [ "$AGE" -gt 3600 ]; then
45
71
  HOURS=$(( AGE / 3600 ))
@@ -62,7 +88,18 @@ fi
62
88
  # Build context string
63
89
  CONTEXT="${STALE_WARNING}--- WORKING MEMORY (from previous session) ---
64
90
 
65
- ${MEMORY_CONTENT}
91
+ ${MEMORY_CONTENT}"
92
+
93
+ # Insert accumulated patterns between working memory and git state
94
+ if [ -n "$PATTERNS_CONTENT" ]; then
95
+ CONTEXT="${CONTEXT}
96
+
97
+ --- PROJECT PATTERNS (accumulated) ---
98
+
99
+ ${PATTERNS_CONTENT}"
100
+ fi
101
+
102
+ CONTEXT="${CONTEXT}
66
103
 
67
104
  --- CURRENT GIT STATE ---
68
105
  Branch: ${GIT_BRANCH}
@@ -75,6 +112,11 @@ Uncommitted changes:
75
112
  ${GIT_STATUS}"
76
113
  fi
77
114
 
115
+ if [ -n "$COMPACT_NOTE" ]; then
116
+ CONTEXT="${CONTEXT}
117
+ ${COMPACT_NOTE}"
118
+ fi
119
+
78
120
  # Output as additionalContext JSON envelope (Claude sees it as system context, not user-visible)
79
121
  jq -n --arg ctx "$CONTEXT" '{
80
122
  "hookSpecificOutput": {
@@ -1,7 +1,7 @@
1
1
  #!/bin/bash
2
2
 
3
3
  # Working Memory: Stop Hook
4
- # Spawns a background process to update .docs/WORKING-MEMORY.md asynchronously.
4
+ # Spawns a background process to update .memory/WORKING-MEMORY.md asynchronously.
5
5
  # The session ends immediately — no visible edit in the TUI.
6
6
  # On failure: does nothing (stale memory is better than fake data).
7
7
 
@@ -16,21 +16,25 @@ if ! command -v jq &>/dev/null; then exit 0; fi
16
16
 
17
17
  INPUT=$(cat)
18
18
 
19
- # Only activate in projects with .docs/ directory (DevFlow-initialized projects)
19
+ # Resolve project directory bail if missing
20
20
  CWD=$(echo "$INPUT" | jq -r '.cwd // ""' 2>/dev/null)
21
- if [ -z "$CWD" ] || [ ! -d "$CWD/.docs" ]; then
21
+ if [ -z "$CWD" ]; then
22
22
  exit 0
23
23
  fi
24
24
 
25
+ # Auto-create .memory/ and ensure .gitignore entries (idempotent after first run)
26
+ SCRIPT_DIR_EARLY="$(cd "$(dirname "$0")" && pwd)"
27
+ source "$SCRIPT_DIR_EARLY/ensure-memory-gitignore.sh" "$CWD" || exit 0
28
+
25
29
  # Logging (shared log file with background updater; [stop-hook] prefix distinguishes)
26
- MEMORY_FILE="$CWD/.docs/WORKING-MEMORY.md"
27
- LOG_FILE="$CWD/.docs/.working-memory-update.log"
30
+ MEMORY_FILE="$CWD/.memory/WORKING-MEMORY.md"
31
+ LOG_FILE="$CWD/.memory/.working-memory-update.log"
28
32
  log() { echo "[$(date -u '+%Y-%m-%dT%H:%M:%SZ')] [stop-hook] $1" >> "$LOG_FILE"; }
29
33
 
30
34
  # Throttle: skip if stop hook was triggered within the last 2 minutes
31
35
  # Uses a marker file touched BEFORE spawning the updater — prevents race condition
32
36
  # where multiple hooks see stale WORKING-MEMORY.md mtime and all bypass throttle.
33
- TRIGGER_MARKER="$CWD/.docs/.working-memory-last-trigger"
37
+ TRIGGER_MARKER="$CWD/.memory/.working-memory-last-trigger"
34
38
  if [ -f "$TRIGGER_MARKER" ]; then
35
39
  if stat --version &>/dev/null 2>&1; then
36
40
  MARKER_MTIME=$(stat -c %Y "$TRIGGER_MARKER")
@@ -2,7 +2,7 @@
2
2
  name: Coder
3
3
  description: Autonomous task implementation on feature branch. Implements, tests, and commits.
4
4
  model: inherit
5
- skills: core-patterns, git-safety, implementation-patterns, git-workflow, typescript, react, test-patterns, input-validation, accessibility, frontend-design
5
+ skills: core-patterns, git-safety, implementation-patterns, git-workflow, test-patterns, input-validation
6
6
  ---
7
7
 
8
8
  # Coder Agent
@@ -33,11 +33,16 @@ You receive from orchestrator:
33
33
 
34
34
  2. **Reference handoff** (if PRIOR_PHASE_SUMMARY provided): Use summary to validate your understanding of prior work, not as the sole source of truth. The actual code is authoritative.
35
35
 
36
- 3. **Load domain skills**: Based on DOMAIN hint, apply relevant patterns:
37
- - `backend`: typescript, implementation-patterns, input-validation
38
- - `frontend`: react, typescript, accessibility, frontend-design
39
- - `tests`: test-patterns, typescript
40
- - `fullstack`: all of the above
36
+ 3. **Load domain skills**: Based on DOMAIN hint and files in scope, dynamically load relevant language/ecosystem skills by reading their SKILL.md. Only load skills that are installed:
37
+ - `backend` (TypeScript): Read `~/.claude/skills/typescript/SKILL.md`, `~/.claude/skills/input-validation/SKILL.md`
38
+ - `backend` (Go): Read `~/.claude/skills/go/SKILL.md`
39
+ - `backend` (Java): Read `~/.claude/skills/java/SKILL.md`
40
+ - `backend` (Python): Read `~/.claude/skills/python/SKILL.md`
41
+ - `backend` (Rust): Read `~/.claude/skills/rust/SKILL.md`
42
+ - `frontend`: Read `~/.claude/skills/react/SKILL.md`, `~/.claude/skills/typescript/SKILL.md`, `~/.claude/skills/accessibility/SKILL.md`, `~/.claude/skills/frontend-design/SKILL.md`
43
+ - `tests`: Read `~/.claude/skills/test-patterns/SKILL.md`, `~/.claude/skills/typescript/SKILL.md`
44
+ - `fullstack`: Combine backend + frontend skills
45
+ - If a Read fails (skill not installed), skip it silently and continue.
41
46
 
42
47
  4. **Implement the plan**: Work through execution steps systematically, creating and modifying files. Follow existing patterns. Type everything. Use Result types if codebase uses them.
43
48
 
@@ -34,6 +34,10 @@ The orchestrator provides:
34
34
  | `react` | `~/.claude/skills/react/SKILL.md` |
35
35
  | `accessibility` | `~/.claude/skills/accessibility/SKILL.md` |
36
36
  | `frontend-design` | `~/.claude/skills/frontend-design/SKILL.md` |
37
+ | `go` | `~/.claude/skills/go/SKILL.md` |
38
+ | `java` | `~/.claude/skills/java/SKILL.md` |
39
+ | `python` | `~/.claude/skills/python/SKILL.md` |
40
+ | `rust` | `~/.claude/skills/rust/SKILL.md` |
37
41
 
38
42
  ## Responsibilities
39
43
 
@@ -117,3 +121,7 @@ Report format for `{output_path}`:
117
121
  | react | If .tsx/.jsx files changed |
118
122
  | accessibility | If .tsx/.jsx files changed |
119
123
  | frontend-design | If .tsx/.jsx/.css/.scss files changed |
124
+ | go | If .go files changed |
125
+ | java | If .java files changed |
126
+ | python | If .py files changed |
127
+ | rust | If .rs files changed |
@@ -0,0 +1,89 @@
1
+ ---
2
+ name: ambient-router
3
+ description: >-
4
+ Classify user intent and response depth for ambient mode. Auto-loads relevant
5
+ skills without explicit command invocation. Used by /ambient command and
6
+ always-on UserPromptSubmit hook.
7
+ user-invocable: false
8
+ allowed-tools: Read, Grep, Glob
9
+ ---
10
+
11
+ # Ambient Router
12
+
13
+ Classify user intent and auto-load relevant skills. Zero overhead for simple requests, skill injection for substantive work, workflow nudges for complex tasks.
14
+
15
+ ## Iron Law
16
+
17
+ > **PROPORTIONAL RESPONSE**
18
+ >
19
+ > Match effort to intent. Never apply heavyweight processes to lightweight requests.
20
+ > A chat question gets zero overhead. A 3-file feature gets 2-3 skills. A system
21
+ > refactor gets a nudge toward `/implement`. Misclassification in either direction
22
+ > is a failure.
23
+
24
+ ---
25
+
26
+ ## Step 1: Classify Intent
27
+
28
+ Determine what the user is trying to do from their prompt.
29
+
30
+ | Intent | Signal Words / Patterns | Examples |
31
+ |--------|------------------------|---------|
32
+ | **BUILD** | "add", "create", "implement", "build", "write", "make" | "add a login form", "create an API endpoint" |
33
+ | **DEBUG** | "fix", "bug", "broken", "failing", "error", "why does" | "fix the auth error", "why is this test failing" |
34
+ | **REVIEW** | "check", "look at", "review", "is this ok", "any issues" | "check this function", "any issues with this?" |
35
+ | **PLAN** | "how should", "design", "architecture", "approach", "strategy" | "how should I structure auth?", "what's the approach for caching?" |
36
+ | **EXPLORE** | "what is", "where is", "find", "show me", "explain", "how does" | "where is the config?", "explain this function" |
37
+ | **CHAT** | greetings, meta-questions, confirmations, short responses | "thanks", "yes", "what can you do?" |
38
+
39
+ **Ambiguous prompts:** Default to the lowest-overhead classification. "Update the README" → BUILD/STANDARD. Git operations like "commit this" → QUICK.
40
+
41
+ ## Step 2: Classify Depth
42
+
43
+ Determine how much enforcement the prompt warrants.
44
+
45
+ | Depth | Criteria | Action |
46
+ |-------|----------|--------|
47
+ | **QUICK** | CHAT intent. EXPLORE with no analytical depth ("where is X?"). Git/devops operations (commit, push, merge, branch, pr, deploy, reinstall). Single-word continuations. | Respond normally. Zero overhead. Do not state classification. |
48
+ | **STANDARD** | BUILD/DEBUG/REVIEW/PLAN intent (any word count). EXPLORE with analytical depth ("analyze our X", "discuss how Y works"). | Read and apply 2-3 relevant skills from the selection matrix below. State classification briefly. |
49
+ | **ESCALATE** | Multi-file architectural change, system-wide scope, > 5 files. Detailed implementation plan (100+ words with plan structure). | Respond at best effort + recommend: "This looks like it would benefit from `/implement` for full lifecycle management." |
50
+
51
+ ## Step 3: Select Skills (STANDARD depth only)
52
+
53
+ Based on classified intent, read the following skills to inform your response.
54
+
55
+ | Intent | Primary Skills | Secondary (if file type matches) |
56
+ |--------|---------------|----------------------------------|
57
+ | **BUILD** | test-driven-development, implementation-patterns | typescript (.ts), react (.tsx/.jsx), go (.go), java (.java), python (.py), rust (.rs), frontend-design (CSS/UI), input-validation (forms/API), security-patterns (auth/crypto) |
58
+ | **DEBUG** | test-patterns, core-patterns | git-safety (if git operations involved) |
59
+ | **REVIEW** | self-review, core-patterns | test-patterns |
60
+ | **PLAN** | implementation-patterns | core-patterns |
61
+
62
+ **Excluded from ambient** (review-command-only): review-methodology, complexity-patterns, consistency-patterns, database-patterns, dependencies-patterns, documentation-patterns, regression-patterns, architecture-patterns, accessibility.
63
+
64
+ See `references/skill-catalog.md` for the full skill-to-intent mapping with file pattern triggers.
65
+
66
+ ## Step 4: Apply
67
+
68
+ - **QUICK:** Respond directly. No preamble, no classification statement.
69
+ - **STANDARD:** State classification briefly: `Ambient: BUILD/STANDARD. Loading: test-driven-development, implementation-patterns.` Then read the selected skills and apply their patterns to your response. For BUILD intent, enforce RED-GREEN-REFACTOR from test-driven-development.
70
+ - **ESCALATE:** Respond with your best effort, then append: `> This task spans multiple files/systems. Consider \`/implement\` for full lifecycle (exploration → planning → implementation → review).`
71
+
72
+ ---
73
+
74
+ ## Transparency Rules
75
+
76
+ 1. **QUICK → silent.** No classification output.
77
+ 2. **STANDARD → brief statement.** One line: intent, depth, skills loaded.
78
+ 3. **ESCALATE → recommendation.** Best-effort response + workflow nudge.
79
+ 4. **Never lie about classification.** If uncertain, say so.
80
+ 5. **Never over-classify.** When in doubt, go one tier lower.
81
+
82
+ ## Edge Cases
83
+
84
+ | Case | Handling |
85
+ |------|----------|
86
+ | Mixed intent ("fix this bug and add a test") | Use the higher-overhead intent (BUILD > DEBUG) |
87
+ | Continuation of previous conversation | Inherit previous classification unless prompt clearly shifts |
88
+ | User explicitly requests no enforcement | Respect immediately — classify as QUICK |
89
+ | Prompt references specific DevFlow command | Skip ambient — the command has its own orchestration |
@@ -0,0 +1,68 @@
1
+ # Ambient Router — Skill Catalog
2
+
3
+ Full mapping of DevFlow skills to ambient intents and file-type triggers. The ambient-router SKILL.md references this for detailed selection logic.
4
+
5
+ ## Skills Available for Ambient Loading
6
+
7
+ These skills may be loaded during STANDARD-depth ambient routing.
8
+
9
+ ### BUILD Intent
10
+
11
+ | Skill | When to Load | File Patterns |
12
+ |-------|-------------|---------------|
13
+ | test-driven-development | Always for BUILD | `*.ts`, `*.tsx`, `*.js`, `*.jsx`, `*.py` |
14
+ | implementation-patterns | Always for BUILD | Any code file |
15
+ | typescript | TypeScript files in scope | `*.ts`, `*.tsx` |
16
+ | react | React components in scope | `*.tsx`, `*.jsx` |
17
+ | frontend-design | UI/styling work | `*.css`, `*.scss`, `*.tsx` with styling keywords |
18
+ | input-validation | Forms, APIs, user input | Files with form/input/validation keywords |
19
+ | go | Go files in scope | `*.go` |
20
+ | java | Java files in scope | `*.java` |
21
+ | python | Python files in scope | `*.py` |
22
+ | rust | Rust files in scope | `*.rs` |
23
+ | security-patterns | Auth, crypto, secrets | Files with auth/token/crypto/password keywords |
24
+
25
+ ### DEBUG Intent
26
+
27
+ | Skill | When to Load | File Patterns |
28
+ |-------|-------------|---------------|
29
+ | test-patterns | Always for DEBUG | Any test-related context |
30
+ | core-patterns | Always for DEBUG | Any code file |
31
+ | git-safety | Git operations involved | User mentions git, rebase, merge, etc. |
32
+
33
+ ### REVIEW Intent
34
+
35
+ | Skill | When to Load | File Patterns |
36
+ |-------|-------------|---------------|
37
+ | self-review | Always for REVIEW | Any code file |
38
+ | core-patterns | Always for REVIEW | Any code file |
39
+ | test-patterns | Test files in scope | `*.test.*`, `*.spec.*` |
40
+
41
+ ### PLAN Intent
42
+
43
+ | Skill | When to Load | File Patterns |
44
+ |-------|-------------|---------------|
45
+ | implementation-patterns | Always for PLAN | Any planning context |
46
+ | core-patterns | Architectural planning | System design discussions |
47
+
48
+ ## Skills Excluded from Ambient
49
+
50
+ These skills are loaded only by explicit DevFlow commands (primarily `/code-review`):
51
+
52
+ - review-methodology — Full review process (6-step, 3-category classification)
53
+ - complexity-patterns — Cyclomatic complexity, deep nesting analysis
54
+ - consistency-patterns — Naming convention, pattern deviation detection
55
+ - database-patterns — Index analysis, query optimization, migration safety
56
+ - dependencies-patterns — CVE detection, license audit, outdated packages
57
+ - documentation-patterns — Doc drift, stale comments, missing API docs
58
+ - regression-patterns — Lost functionality, broken exports, behavioral changes
59
+ - architecture-patterns — SOLID analysis, coupling detection, layering issues
60
+ - accessibility — WCAG compliance, ARIA roles, keyboard navigation
61
+ - performance-patterns — N+1 queries, memory leaks, caching opportunities
62
+
63
+ ## Selection Limits
64
+
65
+ - **Maximum 3 skills** per ambient response (primary + up to 2 secondary)
66
+ - **Primary skills** are always loaded for the classified intent
67
+ - **Secondary skills** are loaded only when file patterns match conversation context
68
+ - If more than 3 skills seem relevant, this is an ESCALATE signal
@@ -32,10 +32,14 @@ All generated documentation lives under `.docs/` in the project root:
32
32
  │ ├── {timestamp}.md
33
33
  │ ├── compact/{timestamp}.md
34
34
  │ └── INDEX.md
35
- ├── swarm/ # Swarm operation state
36
- ├── state.json
37
- └── plans/
38
- └── WORKING-MEMORY.md # Auto-maintained by Stop hook (overwritten)
35
+ └── swarm/ # Swarm operation state
36
+ ├── state.json
37
+ └── plans/
38
+
39
+ .memory/
40
+ ├── WORKING-MEMORY.md # Auto-maintained by Stop hook (overwritten)
41
+ ├── PROJECT-PATTERNS.md # Accumulated patterns (merged across sessions)
42
+ └── backup.json # Pre-compact git state snapshot
39
43
  ```
40
44
 
41
45
  ---
@@ -92,7 +96,7 @@ source .devflow/scripts/docs-helpers.sh 2>/dev/null || {
92
96
  | Agent | Output Location | Behavior |
93
97
  |-------|-----------------|----------|
94
98
  | Reviewer | `.docs/reviews/{branch-slug}/{type}-report.{timestamp}.md` | Creates new |
95
- | Working Memory | `.docs/WORKING-MEMORY.md` | Overwrites (auto-maintained by Stop hook) |
99
+ | Working Memory | `.memory/WORKING-MEMORY.md` | Overwrites (auto-maintained by Stop hook) |
96
100
 
97
101
  ### Agents That Don't Persist
98
102
 
@@ -120,7 +124,7 @@ When creating or modifying persisting agents:
120
124
 
121
125
  This framework is used by:
122
126
  - **Review agents**: Creates review reports
123
- - **Working Memory hooks**: Auto-maintains `.docs/WORKING-MEMORY.md`
127
+ - **Working Memory hooks**: Auto-maintains `.memory/WORKING-MEMORY.md`
124
128
 
125
129
  All persisting agents should load this skill to ensure consistent documentation.
126
130