specweave 0.26.2 → 0.26.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.
Files changed (101) hide show
  1. package/dist/src/config/types.d.ts +1208 -203
  2. package/dist/src/config/types.d.ts.map +1 -1
  3. package/dist/src/init/architecture/types.d.ts +140 -33
  4. package/dist/src/init/architecture/types.d.ts.map +1 -1
  5. package/dist/src/init/compliance/types.d.ts +27 -30
  6. package/dist/src/init/compliance/types.d.ts.map +1 -1
  7. package/dist/src/init/repo/types.d.ts +34 -11
  8. package/dist/src/init/repo/types.d.ts.map +1 -1
  9. package/dist/src/init/research/src/config/types.d.ts +82 -15
  10. package/dist/src/init/research/src/config/types.d.ts.map +1 -1
  11. package/dist/src/init/research/types.d.ts +93 -38
  12. package/dist/src/init/research/types.d.ts.map +1 -1
  13. package/dist/src/init/team/types.d.ts +42 -4
  14. package/dist/src/init/team/types.d.ts.map +1 -1
  15. package/package.json +1 -1
  16. package/plugins/specweave-ado/lib/ado-multi-project-sync.js +0 -1
  17. package/plugins/specweave-jira/lib/enhanced-jira-sync.js +3 -3
  18. package/plugins/specweave/agents/pm/AGENT.md.bak +0 -1893
  19. package/plugins/specweave/hooks/docs-changed.sh.backup +0 -79
  20. package/plugins/specweave/hooks/human-input-required.sh.backup +0 -75
  21. package/plugins/specweave/hooks/lib/migrate-increment-work.sh.bak +0 -245
  22. package/plugins/specweave/hooks/lib/sync-spec-content.sh.bak +0 -149
  23. package/plugins/specweave/hooks/lib/validate-spec-status.sh.bak +0 -163
  24. package/plugins/specweave/hooks/post-first-increment.sh.backup +0 -61
  25. package/plugins/specweave/hooks/post-first-increment.sh.bak +0 -61
  26. package/plugins/specweave/hooks/post-increment-change.sh.backup +0 -98
  27. package/plugins/specweave/hooks/post-increment-completion.sh.backup +0 -231
  28. package/plugins/specweave/hooks/post-increment-planning.sh.backup +0 -1048
  29. package/plugins/specweave/hooks/post-increment-status-change.sh.backup +0 -147
  30. package/plugins/specweave/hooks/post-spec-update.sh.backup +0 -158
  31. package/plugins/specweave/hooks/post-spec-update.sh.bak +0 -158
  32. package/plugins/specweave/hooks/post-user-story-complete.sh.backup +0 -179
  33. package/plugins/specweave/hooks/post-user-story-complete.sh.bak +0 -179
  34. package/plugins/specweave/hooks/pre-command-deduplication.sh.backup +0 -83
  35. package/plugins/specweave/hooks/pre-command-deduplication.sh.bak +0 -83
  36. package/plugins/specweave/hooks/pre-implementation.sh.backup +0 -67
  37. package/plugins/specweave/hooks/pre-task-completion.sh.backup +0 -194
  38. package/plugins/specweave/hooks/pre-tool-use.sh.backup +0 -133
  39. package/plugins/specweave/hooks/user-prompt-submit.sh.backup +0 -386
  40. package/plugins/specweave/hooks/user-prompt-submit.sh.bak +0 -386
  41. package/plugins/specweave/lib/hooks/auto-transition.js.bak +0 -50
  42. package/plugins/specweave/lib/hooks/auto-transition.ts.bak +0 -84
  43. package/plugins/specweave/lib/hooks/git-diff-analyzer.d.js.bak +0 -0
  44. package/plugins/specweave/lib/hooks/git-diff-analyzer.d.ts.bak +0 -89
  45. package/plugins/specweave/lib/hooks/git-diff-analyzer.js.bak +0 -142
  46. package/plugins/specweave/lib/hooks/git-diff-analyzer.ts.bak +0 -269
  47. package/plugins/specweave/lib/hooks/invoke-translator-skill.d.js.bak +0 -0
  48. package/plugins/specweave/lib/hooks/invoke-translator-skill.d.ts.bak +0 -60
  49. package/plugins/specweave/lib/hooks/invoke-translator-skill.js.bak +0 -155
  50. package/plugins/specweave/lib/hooks/invoke-translator-skill.ts.bak +0 -264
  51. package/plugins/specweave/lib/hooks/prepare-reflection-context.d.js.bak +0 -0
  52. package/plugins/specweave/lib/hooks/prepare-reflection-context.d.ts.bak +0 -42
  53. package/plugins/specweave/lib/hooks/prepare-reflection-context.js.bak +0 -110
  54. package/plugins/specweave/lib/hooks/prepare-reflection-context.ts.bak +0 -178
  55. package/plugins/specweave/lib/hooks/reflection-config-loader.d.js.bak +0 -0
  56. package/plugins/specweave/lib/hooks/reflection-config-loader.d.ts.bak +0 -45
  57. package/plugins/specweave/lib/hooks/reflection-config-loader.js.bak +0 -92
  58. package/plugins/specweave/lib/hooks/reflection-config-loader.ts.bak +0 -156
  59. package/plugins/specweave/lib/hooks/reflection-parser.d.js.bak +0 -0
  60. package/plugins/specweave/lib/hooks/reflection-parser.d.ts.bak +0 -33
  61. package/plugins/specweave/lib/hooks/reflection-parser.js.bak +0 -301
  62. package/plugins/specweave/lib/hooks/reflection-parser.ts.bak +0 -484
  63. package/plugins/specweave/lib/hooks/reflection-prompt-builder.d.js.bak +0 -0
  64. package/plugins/specweave/lib/hooks/reflection-prompt-builder.d.ts.bak +0 -56
  65. package/plugins/specweave/lib/hooks/reflection-prompt-builder.js.bak +0 -182
  66. package/plugins/specweave/lib/hooks/reflection-prompt-builder.ts.bak +0 -306
  67. package/plugins/specweave/lib/hooks/reflection-storage.d.js.bak +0 -0
  68. package/plugins/specweave/lib/hooks/reflection-storage.d.ts.bak +0 -64
  69. package/plugins/specweave/lib/hooks/reflection-storage.js.bak +0 -231
  70. package/plugins/specweave/lib/hooks/reflection-storage.ts.bak +0 -369
  71. package/plugins/specweave/lib/hooks/run-self-reflection.d.js.bak +0 -0
  72. package/plugins/specweave/lib/hooks/run-self-reflection.d.ts.bak +0 -43
  73. package/plugins/specweave/lib/hooks/run-self-reflection.js.bak +0 -132
  74. package/plugins/specweave/lib/hooks/run-self-reflection.ts.bak +0 -258
  75. package/plugins/specweave/lib/hooks/sync-cache.js.bak +0 -294
  76. package/plugins/specweave/lib/hooks/sync-living-docs.d.js.bak +0 -1
  77. package/plugins/specweave/lib/hooks/sync-living-docs.d.ts.bak +0 -27
  78. package/plugins/specweave/lib/hooks/sync-living-docs.js.bak +0 -339
  79. package/plugins/specweave/lib/hooks/sync-us-tasks.js.bak +0 -476
  80. package/plugins/specweave/lib/hooks/translate-file.d.js.bak +0 -0
  81. package/plugins/specweave/lib/hooks/translate-file.d.ts.bak +0 -59
  82. package/plugins/specweave/lib/hooks/translate-file.js.bak +0 -289
  83. package/plugins/specweave/lib/hooks/translate-file.ts.bak +0 -428
  84. package/plugins/specweave/lib/hooks/translate-living-docs.d.js.bak +0 -0
  85. package/plugins/specweave/lib/hooks/translate-living-docs.d.ts.bak +0 -13
  86. package/plugins/specweave/lib/hooks/translate-living-docs.js.bak +0 -119
  87. package/plugins/specweave/lib/hooks/translate-living-docs.ts.bak +0 -224
  88. package/plugins/specweave/lib/hooks/update-ac-status.js.bak +0 -51
  89. package/plugins/specweave/lib/hooks/update-ac-status.ts.bak +0 -103
  90. package/plugins/specweave/lib/hooks/update-tasks-md.d.js.bak +0 -1
  91. package/plugins/specweave/lib/hooks/update-tasks-md.d.ts.bak +0 -29
  92. package/plugins/specweave/lib/hooks/update-tasks-md.js.bak +0 -296
  93. package/plugins/specweave/lib/hooks/update-tasks-md.ts.bak +0 -489
  94. package/plugins/specweave-ado/hooks/post-living-docs-update.sh.backup +0 -353
  95. package/plugins/specweave-ado/hooks/post-task-completion.sh.backup +0 -172
  96. package/plugins/specweave-ado/lib/enhanced-ado-sync.js +0 -170
  97. package/plugins/specweave-github/hooks/.specweave/logs/hooks-debug.log +0 -904
  98. package/plugins/specweave-github/hooks/post-task-completion.sh.backup +0 -258
  99. package/plugins/specweave-jira/hooks/post-task-completion.sh.backup +0 -172
  100. package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +0 -738
  101. package/plugins/specweave-release/hooks/post-task-completion.sh.backup +0 -110
@@ -1,386 +0,0 @@
1
- #!/bin/bash
2
-
3
- # SpecWeave UserPromptSubmit Hook
4
- # Fires BEFORE user's command executes (prompt-based hook)
5
- # Purpose: Discipline validation, context injection, command suggestions
6
-
7
- set -euo pipefail
8
-
9
- # Read input JSON from stdin
10
- INPUT=$(cat)
11
-
12
- # Extract prompt from JSON
13
- PROMPT=$(echo "$INPUT" | node -e "
14
- const input = JSON.parse(require('fs').readFileSync(0, 'utf-8'));
15
- console.log(input.prompt || '');
16
- ")
17
-
18
- # ==============================================================================
19
- # DISCIPLINE VALIDATION: Block /specweave:increment if incomplete increments exist
20
- # ==============================================================================
21
-
22
- if echo "$PROMPT" | grep -q "/specweave:increment"; then
23
- # Check increment discipline using check-discipline CLI command
24
- # This enforces WIP limits (max 1 active, hard cap 2)
25
- SPECWEAVE_DIR=".specweave"
26
-
27
- if [[ -d "$SPECWEAVE_DIR/increments" ]]; then
28
- # Run discipline check (exit code: 0=pass, 1=violations, 2=error)
29
- if command -v node >/dev/null 2>&1 && [[ -f "dist/src/core/increment/metadata-manager.js" ]]; then
30
- # Check active increments using MetadataManager
31
- ACTIVE_COUNT=$(node -e "
32
- try {
33
- const { MetadataManager } = require('./dist/src/core/increment/metadata-manager.js');
34
- const active = MetadataManager.getActive();
35
- console.log(active.length);
36
- } catch (e) {
37
- console.error('Error checking active increments:', e.message);
38
- process.exit(2);
39
- }
40
- " 2>/dev/null || echo "0")
41
-
42
- # Hard cap: never >2 active
43
- if [[ "$ACTIVE_COUNT" -ge 2 ]]; then
44
- # Get list of active increments for error message
45
- ACTIVE_LIST=$(node -e "
46
- try {
47
- const { MetadataManager } = require('./dist/src/core/increment/metadata-manager.js');
48
- const active = MetadataManager.getActive();
49
- active.forEach(inc => console.log(' - ' + inc.id + ' [' + inc.type + ']'));
50
- } catch (e) {}
51
- " 2>/dev/null || echo "")
52
-
53
- cat <<EOF
54
- {
55
- "decision": "block",
56
- "reason": "❌ HARD CAP REACHED\n\nYou have $ACTIVE_COUNT active increments (absolute maximum: 2)\n\nActive increments:\n$ACTIVE_LIST\n\n💡 You MUST complete or pause existing work first:\n\n1️⃣ Complete an increment:\n /specweave:done <id>\n\n2️⃣ Pause an increment:\n /specweave:pause <id> --reason=\"...\"\n\n3️⃣ Check status:\n /specweave:status\n\n📝 Multiple hotfixes? Combine them into ONE increment!\n Example: 0009-security-fixes (SQL + XSS + CSRF)\n\n⛔ This limit is enforced for your productivity.\nResearch: 3+ concurrent tasks = 40% slower + more bugs"
57
- }
58
- EOF
59
- exit 0
60
- fi
61
-
62
- # Soft warning: 1 active (recommended limit)
63
- if [[ "$ACTIVE_COUNT" -ge 1 ]]; then
64
- # Get list of active increments for warning
65
- ACTIVE_LIST=$(node -e "
66
- try {
67
- const { MetadataManager } = require('./dist/src/core/increment/metadata-manager.js');
68
- const active = MetadataManager.getActive();
69
- active.forEach(inc => console.log(' - ' + inc.id + ' [' + inc.type + ']'));
70
- } catch (e) {}
71
- " 2>/dev/null || echo "")
72
-
73
- # Just warn, don't block (user can choose to continue)
74
- cat <<EOF
75
- {
76
- "decision": "approve",
77
- "systemMessage": "⚠️ WIP LIMIT REACHED\n\nYou have $ACTIVE_COUNT active increment (recommended limit: 1)\n\nActive increments:\n$ACTIVE_LIST\n\n🧠 Focus Principle: ONE active increment = maximum productivity\nStarting a 2nd increment reduces focus and velocity.\n\n💡 Consider:\n 1️⃣ Complete current work (recommended)\n 2️⃣ Pause current work (/specweave:pause)\n 3️⃣ Continue anyway (accept 20% productivity cost)\n\n⚠️ Emergency hotfix/bug? Use --type=hotfix or --type=bug to bypass this warning."
78
- }
79
- EOF
80
- exit 0
81
- fi
82
- else
83
- # Fallback: check for active/planning status manually
84
- INCOMPLETE_INCREMENTS=$(find "$SPECWEAVE_DIR/increments" -mindepth 1 -maxdepth 1 -type d | while read increment_dir; do
85
- metadata="$increment_dir/metadata.json"
86
- if [[ -f "$metadata" ]]; then
87
- status=$(node -e "
88
- try {
89
- const data = JSON.parse(require('fs').readFileSync('$metadata', 'utf-8'));
90
- console.log(data.status || 'unknown');
91
- } catch (e) {
92
- console.log('unknown');
93
- }
94
- ")
95
-
96
- if [[ "$status" == "active" || "$status" == "planning" ]]; then
97
- echo "$(basename "$increment_dir")"
98
- fi
99
- fi
100
- done)
101
-
102
- if [[ -n "$INCOMPLETE_INCREMENTS" ]]; then
103
- COUNT=$(echo "$INCOMPLETE_INCREMENTS" | wc -l | xargs)
104
-
105
- # Get incomplete task count for migration guidance
106
- MIGRATION_SCRIPT="$(dirname "${BASH_SOURCE[0]}")/lib/migrate-increment-work.sh"
107
- INCOMPLETE_TASKS=""
108
-
109
- for increment in $INCOMPLETE_INCREMENTS; do
110
- if [[ -x "$MIGRATION_SCRIPT" ]]; then
111
- TASK_COUNT=$("$MIGRATION_SCRIPT" count-incomplete "$increment" 2>/dev/null || echo "?")
112
- INCOMPLETE_TASKS="${INCOMPLETE_TASKS}\n - $increment ($TASK_COUNT incomplete tasks)"
113
- else
114
- INCOMPLETE_TASKS="${INCOMPLETE_TASKS}\n - $increment"
115
- fi
116
- done
117
-
118
- cat <<EOF
119
- {
120
- "decision": "block",
121
- "reason": "❌ Cannot create new increment! You have $COUNT incomplete increment(s):$INCOMPLETE_TASKS\n\n💡 **SMART MIGRATION OPTIONS:**\n\n1️⃣ **Transfer Work** (Recommended)\n Move incomplete tasks to new increment:\n \`\`\`bash\n # After creating new increment, run:\n bash plugins/specweave/hooks/lib/migrate-increment-work.sh transfer <old-id> <new-id>\n \`\`\`\n ✅ Clean closure + work continues\n\n2️⃣ **Adjust WIP Limit** (Emergency Only)\n Temporarily allow 3 active increments:\n \`\`\`bash\n bash plugins/specweave/hooks/lib/migrate-increment-work.sh adjust-wip 3\n \`\`\`\n ⚠️ 20% productivity cost, revert ASAP\n\n3️⃣ **Force-Close** (Quick Fix)\n Mark increment as complete (work lost):\n \`\`\`bash\n bash plugins/specweave/hooks/lib/migrate-increment-work.sh force-close <increment-id>\n \`\`\`\n ⚠️ Incomplete work NOT transferred!\n\n📝 **Traditional Options:**\n - /specweave:done <id> # Complete properly\n - /specweave:pause <id> # Pause for later\n - /specweave:abandon <id> # Abandon if obsolete\n\nℹ️ The discipline exists for a reason:\n ✓ Prevents scope creep\n ✓ Ensures completions are tracked\n ✓ Maintains living docs accuracy\n ✓ Keeps work focused"
122
- }
123
- EOF
124
- exit 0
125
- fi
126
- fi
127
- fi
128
- fi
129
-
130
- # ==============================================================================
131
- # PRE-FLIGHT SYNC CHECK: Ensure living docs are fresh before operations
132
- # ==============================================================================
133
-
134
- # Detect increment operations that need fresh data
135
- if echo "$PROMPT" | grep -qE "/(specweave:)?(done|validate|progress|do)"; then
136
- # Extract increment ID from prompt (if provided)
137
- INCREMENT_ID=$(echo "$PROMPT" | grep -oE "[0-9]{4}[a-z0-9-]*" | head -1)
138
-
139
- # If no ID in prompt, try to find active increment
140
- if [[ -z "$INCREMENT_ID" ]] && [[ -d ".specweave/increments" ]]; then
141
- INCREMENT_ID=$(find .specweave/increments -mindepth 1 -maxdepth 1 -type d | while read increment_dir; do
142
- metadata="$increment_dir/metadata.json"
143
- if [[ -f "$metadata" ]]; then
144
- status=$(node -e "
145
- try {
146
- const data = JSON.parse(require('fs').readFileSync('$metadata', 'utf-8'));
147
- if (data.status === 'active') {
148
- console.log('$(basename "$increment_dir")');
149
- }
150
- } catch (e) {}
151
- " 2>/dev/null)
152
-
153
- if [[ -n "$status" ]]; then
154
- echo "$status"
155
- break
156
- fi
157
- fi
158
- done)
159
- fi
160
-
161
- # If we have an increment ID, check freshness
162
- if [[ -n "$INCREMENT_ID" ]]; then
163
- INCREMENT_SPEC=".specweave/increments/$INCREMENT_ID/spec.md"
164
- LIVING_DOCS_SPEC=".specweave/docs/internal/specs/spec-$INCREMENT_ID.md"
165
-
166
- # Check if increment spec exists
167
- if [[ -f "$INCREMENT_SPEC" ]]; then
168
- # Get modification times
169
- if [[ "$(uname)" == "Darwin" ]]; then
170
- # macOS
171
- INCREMENT_MTIME=$(stat -f %m "$INCREMENT_SPEC" 2>/dev/null || echo 0)
172
- LIVING_DOCS_MTIME=$(stat -f %m "$LIVING_DOCS_SPEC" 2>/dev/null || echo 0)
173
- else
174
- # Linux
175
- INCREMENT_MTIME=$(stat -c %Y "$INCREMENT_SPEC" 2>/dev/null || echo 0)
176
- LIVING_DOCS_MTIME=$(stat -c %Y "$LIVING_DOCS_SPEC" 2>/dev/null || echo 0)
177
- fi
178
-
179
- # Check if increment is newer than living docs (or living docs doesn't exist)
180
- if [[ "$INCREMENT_MTIME" -gt "$LIVING_DOCS_MTIME" ]]; then
181
- # Sync needed - run sync-living-docs
182
- PLUGIN_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
183
- SYNC_SCRIPT="$PLUGIN_ROOT/lib/hooks/sync-living-docs.js"
184
-
185
- if [[ -f "$SYNC_SCRIPT" ]]; then
186
- # Run sync (capture output but don't block on errors)
187
- if node "$SYNC_SCRIPT" "$INCREMENT_ID" >/dev/null 2>&1; then
188
- # Success - sync completed
189
- :
190
- else
191
- # Sync failed - log but continue
192
- echo "[WARNING] Pre-flight sync failed for $INCREMENT_ID" >&2
193
- fi
194
- fi
195
- fi
196
- fi
197
- fi
198
- fi
199
-
200
- # ==============================================================================
201
- # SPEC SYNC CHECK: Detect spec.md changes and warn about sync needed
202
- # ==============================================================================
203
-
204
- # Check if spec.md was modified after plan.md (requires sync)
205
- if [[ -d ".specweave/increments" ]]; then
206
- # Find active increment
207
- ACTIVE_INCREMENT_FOR_SYNC=$(find .specweave/increments -mindepth 1 -maxdepth 1 -type d | while read increment_dir; do
208
- metadata="$increment_dir/metadata.json"
209
- if [[ -f "$metadata" ]]; then
210
- status=$(node -e "
211
- try {
212
- const data = JSON.parse(require('fs').readFileSync('$metadata', 'utf-8'));
213
- if (data.status === 'active') {
214
- console.log('$(basename "$increment_dir")');
215
- }
216
- } catch (e) {}
217
- " 2>/dev/null)
218
-
219
- if [[ -n "$status" ]]; then
220
- echo "$status"
221
- break
222
- fi
223
- fi
224
- done)
225
-
226
- if [[ -n "$ACTIVE_INCREMENT_FOR_SYNC" ]]; then
227
- # Check if SpecSyncManager detects changes
228
- if command -v node >/dev/null 2>&1 && [[ -f "dist/src/core/increment/spec-sync-manager.js" ]]; then
229
- SYNC_CHECK=$(node -e "
230
- try {
231
- const { SpecSyncManager } = require('./dist/src/core/increment/spec-sync-manager.js');
232
- const manager = new SpecSyncManager(process.cwd());
233
- const detection = manager.detectSpecChange('$ACTIVE_INCREMENT_FOR_SYNC');
234
-
235
- if (detection.specChanged) {
236
- const message = manager.formatSyncMessage(detection);
237
- console.log(JSON.stringify({ needsSync: true, message }));
238
- } else {
239
- console.log(JSON.stringify({ needsSync: false }));
240
- }
241
- } catch (e) {
242
- console.log(JSON.stringify({ needsSync: false, error: e.message }));
243
- }
244
- " 2>/dev/null || echo '{"needsSync":false}')
245
-
246
- NEEDS_SYNC=$(echo "$SYNC_CHECK" | node -e "
247
- try {
248
- const data = JSON.parse(require('fs').readFileSync(0, 'utf-8'));
249
- console.log(data.needsSync || false);
250
- } catch (e) {
251
- console.log(false);
252
- }
253
- ")
254
-
255
- if [[ "$NEEDS_SYNC" == "true" ]]; then
256
- SYNC_MESSAGE=$(echo "$SYNC_CHECK" | node -e "
257
- try {
258
- const data = JSON.parse(require('fs').readFileSync(0, 'utf-8'));
259
- console.log(data.message || '');
260
- } catch (e) {
261
- console.log('');
262
- }
263
- ")
264
-
265
- # Show sync warning (don't block, just warn)
266
- cat <<EOF
267
- {
268
- "decision": "approve",
269
- "systemMessage": "$SYNC_MESSAGE"
270
- }
271
- EOF
272
- exit 0
273
- fi
274
- fi
275
- fi
276
- fi
277
-
278
- # ==============================================================================
279
- # CONTEXT INJECTION: Add current increment status
280
- # ==============================================================================
281
-
282
- CONTEXT=""
283
-
284
- # Find active increment
285
- if [[ -d ".specweave/increments" ]]; then
286
- ACTIVE_INCREMENT=$(find .specweave/increments -mindepth 1 -maxdepth 1 -type d | while read increment_dir; do
287
- metadata="$increment_dir/metadata.json"
288
- if [[ -f "$metadata" ]]; then
289
- status=$(node -e "
290
- try {
291
- const data = JSON.parse(require('fs').readFileSync('$metadata', 'utf-8'));
292
- if (data.status === 'active') {
293
- console.log('$(basename "$increment_dir")');
294
- }
295
- } catch (e) {}
296
- ")
297
-
298
- if [[ -n "$status" ]]; then
299
- echo "$status"
300
- break
301
- fi
302
- fi
303
- done)
304
-
305
- if [[ -n "$ACTIVE_INCREMENT" ]]; then
306
- # Simple status: parse tasks.md for completion
307
- TASKS_FILE=".specweave/increments/$ACTIVE_INCREMENT/tasks.md"
308
- if [[ -f "$TASKS_FILE" ]]; then
309
- # Count tasks (headers with T-NNN format - both ### and ####)
310
- TOTAL_TASKS=$(grep -cE '^#{3,4}\s*T-[0-9]' "$TASKS_FILE" 2>/dev/null | tr -d '\n' || echo "0")
311
- # Count completed (various formats)
312
- COMPLETED_TASKS=$(grep -cE '(✅ COMPLETE|\[COMPLETED\]|\[x\] Completed)' "$TASKS_FILE" 2>/dev/null | tr -d '\n' || echo "0")
313
-
314
- # Ensure valid numbers
315
- TOTAL_TASKS=${TOTAL_TASKS:-0}
316
- COMPLETED_TASKS=${COMPLETED_TASKS:-0}
317
-
318
- if [[ "$TOTAL_TASKS" -gt 0 ]] 2>/dev/null; then
319
- PERCENTAGE=$(( COMPLETED_TASKS * 100 / TOTAL_TASKS ))
320
- CONTEXT="✓ Active: $ACTIVE_INCREMENT ($COMPLETED_TASKS/$TOTAL_TASKS tasks, $PERCENTAGE%)"
321
- else
322
- CONTEXT="✓ Active: $ACTIVE_INCREMENT"
323
- fi
324
- else
325
- CONTEXT="✓ Active: $ACTIVE_INCREMENT"
326
- fi
327
- fi
328
- fi
329
-
330
- # ==============================================================================
331
- # COMMAND SUGGESTIONS: Guide users to structured workflow
332
- # ==============================================================================
333
-
334
- if echo "$PROMPT" | grep -qiE "(add|create|implement|build|develop)" && ! echo "$PROMPT" | grep -q "/specweave:"; then
335
- if [[ -n "$CONTEXT" ]]; then
336
- CONTEXT="$CONTEXT
337
-
338
- 💡 TIP: Consider using SpecWeave commands for structured development:
339
- - /specweave:increment \"feature name\" # Plan new increment
340
- - /specweave:do # Execute current tasks
341
- - /specweave:progress # Check progress"
342
- fi
343
- fi
344
-
345
- # ==============================================================================
346
- # STATUS LINE REFRESH: Ensure cache is fresh before showing context
347
- # ==============================================================================
348
- # Performance: ~50-100ms (acceptable for UX)
349
- # Frequency: Every user prompt (high coverage)
350
- # Benefit: Catches ALL edge cases (manual edits, resume, direct changes)
351
- #
352
- # Why here? This hook runs on EVERY user prompt, ensuring status line
353
- # is ALWAYS up-to-date before showing context to the user.
354
- #
355
- # Prevents desync scenarios:
356
- # - Manual spec.md edits (status: planning → active)
357
- # - /specweave:resume (status: paused → active)
358
- # - Direct metadata changes (without hook triggers)
359
- # - File system operations bypassing hooks
360
- #
361
- # Background execution: Runs async, doesn't block user prompt
362
-
363
- HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
364
- bash "$HOOK_DIR/lib/update-status-line.sh" 2>/dev/null || true
365
-
366
- # ==============================================================================
367
- # OUTPUT: Approve with context or no context
368
- # ==============================================================================
369
-
370
- if [[ -n "$CONTEXT" ]]; then
371
- cat <<EOF
372
- {
373
- "decision": "approve",
374
- "systemMessage": "$CONTEXT"
375
- }
376
- EOF
377
- else
378
- # Just approve, no extra context
379
- cat <<EOF
380
- {
381
- "decision": "approve"
382
- }
383
- EOF
384
- fi
385
-
386
- exit 0
@@ -1,50 +0,0 @@
1
- #!/usr/bin/env node
2
- import { AutoTransitionManager } from "../../../../dist/src/core/increment/auto-transition-manager.js";
3
- async function main() {
4
- const event = process.argv[2];
5
- const incrementId = process.argv[3];
6
- const force = process.argv.includes("--force");
7
- if (!event || !incrementId) {
8
- console.error("Usage: auto-transition.ts <event> <increment-id> [--force]");
9
- console.error("Events: spec-created, tasks-created, task-started, auto-correct");
10
- console.error("Example: node auto-transition.ts spec-created 0039-ultra-smart-next-command");
11
- process.exit(1);
12
- }
13
- const projectRoot = process.cwd();
14
- const manager = new AutoTransitionManager(projectRoot);
15
- let result;
16
- try {
17
- switch (event) {
18
- case "spec-created":
19
- result = await manager.handleSpecCreated(incrementId);
20
- break;
21
- case "tasks-created":
22
- result = await manager.handleTasksCreated(incrementId);
23
- break;
24
- case "task-started":
25
- result = await manager.handleTaskStarted(incrementId);
26
- break;
27
- case "auto-correct":
28
- result = await manager.autoCorrect(incrementId, force);
29
- break;
30
- default:
31
- console.error(`\u274C Unknown event: ${event}`);
32
- console.error("Valid events: spec-created, tasks-created, task-started, auto-correct");
33
- process.exit(1);
34
- }
35
- if (result.transitioned) {
36
- console.log(`\u2705 Auto-transition: ${result.from} \u2192 ${result.to}`);
37
- console.log(` Reason: ${result.reason}`);
38
- } else {
39
- console.log(`\u2139\uFE0F No transition: ${result.reason}`);
40
- }
41
- process.exit(0);
42
- } catch (error) {
43
- console.error("\u274C Auto-transition error:", error);
44
- process.exit(1);
45
- }
46
- }
47
- const isMainModule = import.meta.url === `file://${process.argv[1]}`;
48
- if (isMainModule) {
49
- main();
50
- }
@@ -1,84 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Auto-Transition Hook Handler
5
- *
6
- * CLI wrapper for AutoTransitionManager
7
- * Called by bash hooks to trigger status transitions
8
- *
9
- * Events:
10
- * - spec-created: When spec.md is created (BACKLOG → PLANNING)
11
- * - tasks-created: When tasks.md is created (PLANNING/BACKLOG → ACTIVE)
12
- * - task-started: When first task is started (PLANNING → ACTIVE)
13
- * - auto-correct: Fix status based on artifacts
14
- *
15
- * Usage:
16
- * node auto-transition.ts spec-created 0039-ultra-smart-next-command
17
- * node auto-transition.ts tasks-created 0039-ultra-smart-next-command
18
- * node auto-transition.ts task-started 0039-ultra-smart-next-command
19
- * node auto-transition.ts auto-correct 0039-ultra-smart-next-command
20
- */
21
-
22
- import { AutoTransitionManager } from '../../../../dist/src/core/increment/auto-transition-manager.js';
23
-
24
- async function main() {
25
- const event = process.argv[2];
26
- const incrementId = process.argv[3];
27
- const force = process.argv.includes('--force');
28
-
29
- if (!event || !incrementId) {
30
- console.error('Usage: auto-transition.ts <event> <increment-id> [--force]');
31
- console.error('Events: spec-created, tasks-created, task-started, auto-correct');
32
- console.error('Example: node auto-transition.ts spec-created 0039-ultra-smart-next-command');
33
- process.exit(1);
34
- }
35
-
36
- const projectRoot = process.cwd();
37
- const manager = new AutoTransitionManager(projectRoot);
38
-
39
- let result;
40
-
41
- try {
42
- switch (event) {
43
- case 'spec-created':
44
- result = await manager.handleSpecCreated(incrementId);
45
- break;
46
-
47
- case 'tasks-created':
48
- result = await manager.handleTasksCreated(incrementId);
49
- break;
50
-
51
- case 'task-started':
52
- result = await manager.handleTaskStarted(incrementId);
53
- break;
54
-
55
- case 'auto-correct':
56
- result = await manager.autoCorrect(incrementId, force);
57
- break;
58
-
59
- default:
60
- console.error(`❌ Unknown event: ${event}`);
61
- console.error('Valid events: spec-created, tasks-created, task-started, auto-correct');
62
- process.exit(1);
63
- }
64
-
65
- // Display result
66
- if (result.transitioned) {
67
- console.log(`✅ Auto-transition: ${result.from} → ${result.to}`);
68
- console.log(` Reason: ${result.reason}`);
69
- } else {
70
- console.log(`ℹ️ No transition: ${result.reason}`);
71
- }
72
-
73
- process.exit(0);
74
- } catch (error) {
75
- console.error('❌ Auto-transition error:', error);
76
- process.exit(1);
77
- }
78
- }
79
-
80
- // Run if executed directly
81
- const isMainModule = import.meta.url === `file://${process.argv[1]}`;
82
- if (isMainModule) {
83
- main();
84
- }
@@ -1,89 +0,0 @@
1
- /**
2
- * Git Diff Analyzer
3
- *
4
- * Extracts modified files from git diff for reflection analysis
5
- * Parses git diff output to get file changes, line counts, and content
6
- *
7
- * @module git-diff-analyzer
8
- */
9
- import { GitDiffInfo } from './types/reflection-types';
10
- /**
11
- * Check if directory is a git repository
12
- * @param dir Directory to check (defaults to cwd)
13
- * @returns True if directory is in a git repository
14
- */
15
- export declare function isGitRepository(dir?: string): boolean;
16
- /**
17
- * Get list of modified files in the working directory
18
- * Includes both staged and unstaged changes
19
- *
20
- * @param cwd Working directory (optional, defaults to process.cwd())
21
- * @returns Array of file paths relative to git root
22
- */
23
- export declare function getModifiedFilesList(cwd?: string): string[];
24
- /**
25
- * Parse git diff numstat output to get line counts
26
- * Format: <added>\t<removed>\t<filename>
27
- *
28
- * @param numstatOutput Output from git diff --numstat
29
- * @returns Map of filename to {added, removed} counts
30
- */
31
- export declare function parseNumstat(numstatOutput: string): Map<string, {
32
- added: number;
33
- removed: number;
34
- }>;
35
- /**
36
- * Get diff content for a specific file
37
- * @param file File path relative to git root
38
- * @param cwd Working directory (optional)
39
- * @returns Diff content as string
40
- */
41
- export declare function getFileDiff(file: string, cwd?: string): string;
42
- /**
43
- * Get current file content
44
- * @param file File path (can be absolute or relative to cwd)
45
- * @param cwd Working directory (optional)
46
- * @returns File content as string, or empty string if file doesn't exist
47
- */
48
- export declare function getFileContent(file: string, cwd?: string): string;
49
- /**
50
- * Get modified files with diff information
51
- * Main function for reflection analysis
52
- *
53
- * @param cwd Working directory (optional, defaults to process.cwd())
54
- * @param maxFiles Maximum number of files to return (optional, defaults to 100)
55
- * @returns Array of GitDiffInfo objects with file changes
56
- */
57
- export declare function getModifiedFiles(cwd?: string, maxFiles?: number): GitDiffInfo[];
58
- /**
59
- * Get summary statistics for modified files
60
- * Useful for reflection metadata
61
- *
62
- * @param modifiedFiles Array of GitDiffInfo objects
63
- * @returns Summary with file count, total lines added/removed
64
- */
65
- export declare function getModifiedFilesSummary(modifiedFiles: GitDiffInfo[]): {
66
- count: number;
67
- linesAdded: number;
68
- linesRemoved: number;
69
- totalChanges: number;
70
- };
71
- /**
72
- * Filter files by extension
73
- * Useful for focusing reflection on specific file types
74
- *
75
- * @param modifiedFiles Array of GitDiffInfo objects
76
- * @param extensions Array of file extensions (e.g., ['.ts', '.js'])
77
- * @returns Filtered array of GitDiffInfo objects
78
- */
79
- export declare function filterFilesByExtension(modifiedFiles: GitDiffInfo[], extensions: string[]): GitDiffInfo[];
80
- /**
81
- * Exclude files matching patterns
82
- * Useful for excluding generated files, test files, etc.
83
- *
84
- * @param modifiedFiles Array of GitDiffInfo objects
85
- * @param patterns Array of glob patterns to exclude
86
- * @returns Filtered array of GitDiffInfo objects
87
- */
88
- export declare function excludeFilesByPattern(modifiedFiles: GitDiffInfo[], patterns: string[]): GitDiffInfo[];
89
- //# sourceMappingURL=git-diff-analyzer.d.ts.map