@leeovery/claude-technical-workflows 2.1.42 → 2.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 (117) hide show
  1. package/hooks/workflows/compact-recovery.sh +3 -23
  2. package/hooks/workflows/write-session-state.sh +2 -26
  3. package/package.json +1 -1
  4. package/skills/link-dependencies/SKILL.md +0 -1
  5. package/skills/migrate/SKILL.md +0 -1
  6. package/skills/migrate/scripts/migrations/013-discussion-work-type.sh +76 -0
  7. package/skills/migrate/scripts/migrations/014-specification-work-type.sh +76 -0
  8. package/skills/migrate/scripts/migrations/015-plan-work-type.sh +76 -0
  9. package/skills/start-bugfix/SKILL.md +80 -0
  10. package/skills/start-bugfix/references/gather-bug-context.md +75 -0
  11. package/skills/start-bugfix/references/invoke-investigation.md +46 -0
  12. package/skills/start-bugfix/references/topic-name-check.md +59 -0
  13. package/skills/start-discussion/SKILL.md +51 -46
  14. package/skills/start-discussion/references/gather-context.md +54 -10
  15. package/skills/start-discussion/references/handle-selection.md +14 -4
  16. package/skills/start-discussion/references/invoke-skill.md +71 -3
  17. package/skills/start-discussion/references/research-analysis.md +2 -0
  18. package/skills/start-discussion/references/route-scenario.md +39 -0
  19. package/skills/start-discussion/references/validate-topic.md +46 -0
  20. package/skills/start-discussion/scripts/discovery.sh +3 -0
  21. package/skills/start-feature/SKILL.md +28 -84
  22. package/skills/start-feature/references/invoke-discussion.md +8 -4
  23. package/skills/start-feature/references/invoke-research.md +29 -0
  24. package/skills/start-feature/references/invoke-skill.md +35 -0
  25. package/skills/start-feature/references/research-gating.md +65 -0
  26. package/skills/start-feature/references/topic-name-check.md +61 -0
  27. package/skills/start-implementation/SKILL.md +35 -289
  28. package/skills/start-implementation/references/check-dependencies.md +65 -0
  29. package/skills/start-implementation/references/display-plans.md +159 -0
  30. package/skills/start-implementation/references/environment-check.md +45 -0
  31. package/skills/start-implementation/references/invoke-skill.md +42 -0
  32. package/skills/start-implementation/references/route-scenario.md +32 -0
  33. package/skills/start-implementation/references/validate-plan.md +45 -0
  34. package/skills/start-implementation/scripts/discovery.sh +3 -0
  35. package/skills/start-investigation/SKILL.md +145 -0
  36. package/skills/start-investigation/references/gather-context-fresh.md +72 -0
  37. package/skills/start-investigation/references/gather-context.md +31 -0
  38. package/skills/start-investigation/references/invoke-skill.md +54 -0
  39. package/skills/start-investigation/references/route-scenario.md +69 -0
  40. package/skills/start-investigation/references/validate-investigation.md +46 -0
  41. package/skills/start-investigation/scripts/discovery.sh +92 -0
  42. package/skills/start-planning/SKILL.md +32 -72
  43. package/skills/start-planning/references/cross-cutting-context.md +5 -5
  44. package/skills/start-planning/references/invoke-skill.md +27 -4
  45. package/skills/start-planning/references/route-plan-state.md +30 -0
  46. package/skills/start-planning/references/route-scenario.md +38 -0
  47. package/skills/start-planning/references/validate-spec.md +47 -0
  48. package/skills/start-planning/scripts/discovery.sh +7 -0
  49. package/skills/start-research/SKILL.md +17 -6
  50. package/skills/start-research/references/invoke-skill.md +3 -0
  51. package/skills/start-review/SKILL.md +32 -60
  52. package/skills/start-review/references/determine-review-version.md +24 -0
  53. package/skills/start-review/references/display-plans.md +2 -2
  54. package/skills/start-review/references/route-scenario.md +74 -0
  55. package/skills/start-review/references/select-plans.md +8 -6
  56. package/skills/start-review/references/validate-artifacts.md +63 -0
  57. package/skills/start-review/scripts/discovery.sh +3 -0
  58. package/skills/start-specification/SKILL.md +44 -20
  59. package/skills/start-specification/references/check-existing-spec.md +57 -0
  60. package/skills/start-specification/references/check-prerequisites.md +15 -0
  61. package/skills/start-specification/references/handoffs/continue-concluded.md +3 -0
  62. package/skills/start-specification/references/handoffs/continue.md +3 -0
  63. package/skills/start-specification/references/handoffs/create-with-incorporation.md +3 -0
  64. package/skills/start-specification/references/handoffs/create.md +3 -0
  65. package/skills/start-specification/references/handoffs/unify-with-incorporation.md +3 -0
  66. package/skills/start-specification/references/handoffs/unify.md +3 -0
  67. package/skills/start-specification/references/invoke-skill-bridge.md +74 -0
  68. package/skills/start-specification/references/route-scenario.md +23 -0
  69. package/skills/start-specification/references/validate-source.md +91 -0
  70. package/skills/start-specification/scripts/discovery.sh +6 -0
  71. package/skills/status/SKILL.md +6 -3
  72. package/skills/status/scripts/discovery.sh +9 -0
  73. package/skills/technical-discussion/SKILL.md +15 -4
  74. package/skills/technical-discussion/references/template.md +9 -1
  75. package/skills/technical-implementation/SKILL.md +24 -1
  76. package/skills/technical-implementation/references/analysis-loop.md +4 -4
  77. package/skills/technical-implementation/references/task-loop.md +2 -2
  78. package/skills/technical-investigation/SKILL.md +239 -0
  79. package/skills/technical-investigation/references/analysis-patterns.md +181 -0
  80. package/skills/technical-investigation/references/symptom-gathering.md +164 -0
  81. package/skills/technical-investigation/references/template.md +164 -0
  82. package/skills/technical-planning/SKILL.md +24 -1
  83. package/skills/technical-planning/references/author-tasks.md +16 -16
  84. package/skills/technical-planning/references/define-tasks.md +2 -2
  85. package/skills/technical-planning/references/plan-construction.md +11 -30
  86. package/skills/technical-planning/references/plan-review.md +3 -3
  87. package/skills/technical-research/SKILL.md +38 -2
  88. package/skills/technical-review/SKILL.md +1 -2
  89. package/skills/technical-review/references/review-actions-loop.md +43 -1
  90. package/skills/technical-specification/SKILL.md +1 -2
  91. package/skills/technical-specification/references/spec-completion.md +34 -6
  92. package/skills/technical-specification/references/spec-construction.md +1 -1
  93. package/skills/technical-specification/references/spec-review.md +5 -5
  94. package/skills/view-plan/SKILL.md +0 -1
  95. package/skills/workflow/bridge/SKILL.md +82 -0
  96. package/skills/workflow/bridge/references/bugfix-continuation.md +59 -0
  97. package/skills/workflow/bridge/references/feature-continuation.md +60 -0
  98. package/skills/workflow/bridge/references/greenfield-continuation.md +224 -0
  99. package/skills/workflow/bridge/scripts/discovery.sh +512 -0
  100. package/skills/workflow/start/SKILL.md +97 -0
  101. package/skills/workflow/start/references/bugfix-routing.md +117 -0
  102. package/skills/workflow/start/references/feature-routing.md +117 -0
  103. package/skills/workflow/start/references/greenfield-routing.md +140 -0
  104. package/skills/workflow/start/references/work-type-selection.md +83 -0
  105. package/skills/workflow/start/scripts/discovery.sh +577 -0
  106. package/skills/begin-implementation/SKILL.md +0 -162
  107. package/skills/begin-planning/SKILL.md +0 -92
  108. package/skills/begin-review/SKILL.md +0 -90
  109. package/skills/continue-feature/SKILL.md +0 -186
  110. package/skills/continue-feature/references/detect-phase.md +0 -99
  111. package/skills/continue-feature/references/invoke-implementation.md +0 -43
  112. package/skills/continue-feature/references/invoke-planning.md +0 -43
  113. package/skills/continue-feature/references/invoke-review.md +0 -43
  114. package/skills/continue-feature/references/invoke-specification.md +0 -55
  115. package/skills/continue-feature/references/phase-bridge.md +0 -57
  116. package/skills/continue-feature/scripts/discovery.sh +0 -233
  117. package/skills/start-feature/references/phase-bridge.md +0 -37
@@ -0,0 +1,577 @@
1
+ #!/bin/bash
2
+ #
3
+ # Comprehensive workflow discovery for /workflow:start.
4
+ #
5
+ # Scans all workflow directories and groups artifacts by work_type:
6
+ # - greenfield: phase-centric, all topics (work_type: greenfield or unset)
7
+ # - features: topics with work_type: feature
8
+ # - bugfixes: topics with work_type: bugfix (includes investigations)
9
+ #
10
+ # Outputs structured YAML that the skill can consume directly.
11
+ #
12
+
13
+ set -eo pipefail
14
+
15
+ RESEARCH_DIR=".workflows/research"
16
+ DISCUSSION_DIR=".workflows/discussion"
17
+ SPEC_DIR=".workflows/specification"
18
+ PLAN_DIR=".workflows/planning"
19
+ IMPL_DIR=".workflows/implementation"
20
+ REVIEW_DIR=".workflows/review"
21
+ INVESTIGATION_DIR=".workflows/investigation"
22
+
23
+ # Helper: Extract a frontmatter field value from a file
24
+ # Usage: extract_field <file> <field_name>
25
+ extract_field() {
26
+ local file="$1"
27
+ local field="$2"
28
+ local value=""
29
+
30
+ if head -1 "$file" 2>/dev/null | grep -q "^---$"; then
31
+ value=$(sed -n '2,/^---$/p' "$file" 2>/dev/null | \
32
+ grep -i -m1 "^${field}:" | \
33
+ sed -E "s/^${field}:[[:space:]]*//i" || true)
34
+ fi
35
+
36
+ echo "$value"
37
+ }
38
+
39
+ # Start YAML output
40
+ echo "# Workflow Discovery (Unified Entry Point)"
41
+ echo "# Generated: $(date -Iseconds)"
42
+ echo ""
43
+
44
+ #
45
+ # GREENFIELD SECTION (phase-centric view)
46
+ #
47
+ echo "greenfield:"
48
+ echo " research:"
49
+
50
+ research_count=0
51
+ if [ -d "$RESEARCH_DIR" ] && [ -n "$(ls -A "$RESEARCH_DIR" 2>/dev/null)" ]; then
52
+ echo " exists: true"
53
+ echo " files:"
54
+ for file in "$RESEARCH_DIR"/*; do
55
+ [ -f "$file" ] || continue
56
+ name=$(basename "$file" .md)
57
+ echo " - \"$name\""
58
+ research_count=$((research_count + 1))
59
+ done
60
+ echo " count: $research_count"
61
+ else
62
+ echo " exists: false"
63
+ echo " files: []"
64
+ echo " count: 0"
65
+ fi
66
+
67
+ echo ""
68
+ echo " discussions:"
69
+
70
+ greenfield_disc_count=0
71
+ greenfield_disc_concluded=0
72
+ greenfield_disc_in_progress=0
73
+
74
+ if [ -d "$DISCUSSION_DIR" ] && [ -n "$(ls -A "$DISCUSSION_DIR" 2>/dev/null)" ]; then
75
+ first=true
76
+ for file in "$DISCUSSION_DIR"/*.md; do
77
+ [ -f "$file" ] || continue
78
+ name=$(basename "$file" .md)
79
+ status=$(extract_field "$file" "status")
80
+ status=${status:-"in-progress"}
81
+ work_type=$(extract_field "$file" "work_type")
82
+ work_type=${work_type:-"greenfield"}
83
+
84
+ # Only include greenfield discussions
85
+ [ "$work_type" = "greenfield" ] || continue
86
+
87
+ if $first; then
88
+ echo " files:"
89
+ first=false
90
+ fi
91
+
92
+ echo " - name: \"$name\""
93
+ echo " status: \"$status\""
94
+
95
+ greenfield_disc_count=$((greenfield_disc_count + 1))
96
+ [ "$status" = "concluded" ] && greenfield_disc_concluded=$((greenfield_disc_concluded + 1))
97
+ [ "$status" = "in-progress" ] && greenfield_disc_in_progress=$((greenfield_disc_in_progress + 1))
98
+ done
99
+ if $first; then
100
+ echo " files: []"
101
+ fi
102
+ else
103
+ echo " files: []"
104
+ fi
105
+
106
+ echo " count: $greenfield_disc_count"
107
+ echo " concluded: $greenfield_disc_concluded"
108
+ echo " in_progress: $greenfield_disc_in_progress"
109
+
110
+ echo ""
111
+ echo " specifications:"
112
+
113
+ greenfield_spec_count=0
114
+ greenfield_spec_concluded=0
115
+ greenfield_spec_feature=0
116
+ greenfield_spec_crosscutting=0
117
+
118
+ if [ -d "$SPEC_DIR" ] && [ -n "$(ls -A "$SPEC_DIR" 2>/dev/null)" ]; then
119
+ first=true
120
+ for file in "$SPEC_DIR"/*/specification.md; do
121
+ [ -f "$file" ] || continue
122
+ name=$(basename "$(dirname "$file")")
123
+ status=$(extract_field "$file" "status")
124
+ status=${status:-"in-progress"}
125
+ spec_type=$(extract_field "$file" "type")
126
+ spec_type=${spec_type:-"feature"}
127
+ work_type=$(extract_field "$file" "work_type")
128
+ work_type=${work_type:-"greenfield"}
129
+
130
+ # Only include greenfield specs
131
+ [ "$work_type" = "greenfield" ] || continue
132
+
133
+ if $first; then
134
+ echo " files:"
135
+ first=false
136
+ fi
137
+
138
+ echo " - name: \"$name\""
139
+ echo " status: \"$status\""
140
+ echo " type: \"$spec_type\""
141
+
142
+ greenfield_spec_count=$((greenfield_spec_count + 1))
143
+ [ "$status" = "concluded" ] && greenfield_spec_concluded=$((greenfield_spec_concluded + 1))
144
+ [ "$spec_type" = "cross-cutting" ] && greenfield_spec_crosscutting=$((greenfield_spec_crosscutting + 1))
145
+ [ "$spec_type" = "feature" ] && greenfield_spec_feature=$((greenfield_spec_feature + 1))
146
+ done
147
+ if $first; then
148
+ echo " files: []"
149
+ fi
150
+ else
151
+ echo " files: []"
152
+ fi
153
+
154
+ echo " count: $greenfield_spec_count"
155
+ echo " concluded: $greenfield_spec_concluded"
156
+ echo " feature: $greenfield_spec_feature"
157
+ echo " crosscutting: $greenfield_spec_crosscutting"
158
+
159
+ echo ""
160
+ echo " plans:"
161
+
162
+ greenfield_plan_count=0
163
+ greenfield_plan_concluded=0
164
+
165
+ if [ -d "$PLAN_DIR" ] && [ -n "$(ls -A "$PLAN_DIR" 2>/dev/null)" ]; then
166
+ first=true
167
+ for file in "$PLAN_DIR"/*/plan.md; do
168
+ [ -f "$file" ] || continue
169
+ name=$(basename "$(dirname "$file")")
170
+ status=$(extract_field "$file" "status")
171
+ status=${status:-"in-progress"}
172
+ work_type=$(extract_field "$file" "work_type")
173
+ work_type=${work_type:-"greenfield"}
174
+
175
+ # Only include greenfield plans
176
+ [ "$work_type" = "greenfield" ] || continue
177
+
178
+ if $first; then
179
+ echo " files:"
180
+ first=false
181
+ fi
182
+
183
+ echo " - name: \"$name\""
184
+ echo " status: \"$status\""
185
+
186
+ greenfield_plan_count=$((greenfield_plan_count + 1))
187
+ [ "$status" = "concluded" ] && greenfield_plan_concluded=$((greenfield_plan_concluded + 1))
188
+ done
189
+ if $first; then
190
+ echo " files: []"
191
+ fi
192
+ else
193
+ echo " files: []"
194
+ fi
195
+
196
+ echo " count: $greenfield_plan_count"
197
+ echo " concluded: $greenfield_plan_concluded"
198
+
199
+ echo ""
200
+ echo " implementation:"
201
+
202
+ greenfield_impl_count=0
203
+ greenfield_impl_completed=0
204
+
205
+ if [ -d "$IMPL_DIR" ] && [ -n "$(ls -A "$IMPL_DIR" 2>/dev/null)" ]; then
206
+ first=true
207
+ for file in "$IMPL_DIR"/*/tracking.md; do
208
+ [ -f "$file" ] || continue
209
+ topic=$(basename "$(dirname "$file")")
210
+ status=$(extract_field "$file" "status")
211
+ status=${status:-"in-progress"}
212
+ work_type=$(extract_field "$file" "work_type")
213
+ work_type=${work_type:-"greenfield"}
214
+
215
+ # Only include greenfield implementations
216
+ [ "$work_type" = "greenfield" ] || continue
217
+
218
+ if $first; then
219
+ echo " files:"
220
+ first=false
221
+ fi
222
+
223
+ echo " - topic: \"$topic\""
224
+ echo " status: \"$status\""
225
+
226
+ greenfield_impl_count=$((greenfield_impl_count + 1))
227
+ [ "$status" = "completed" ] && greenfield_impl_completed=$((greenfield_impl_completed + 1))
228
+ done
229
+ if $first; then
230
+ echo " files: []"
231
+ fi
232
+ else
233
+ echo " files: []"
234
+ fi
235
+
236
+ echo " count: $greenfield_impl_count"
237
+ echo " completed: $greenfield_impl_completed"
238
+
239
+ echo ""
240
+
241
+ #
242
+ # FEATURES SECTION (topic-centric view for work_type: feature)
243
+ #
244
+ echo "features:"
245
+
246
+ feature_topics=()
247
+ declare -A feature_topic_seen=()
248
+
249
+ # Scan all phases for work_type: feature
250
+ if [ -d "$DISCUSSION_DIR" ]; then
251
+ for file in "$DISCUSSION_DIR"/*.md; do
252
+ [ -f "$file" ] || continue
253
+ work_type=$(extract_field "$file" "work_type")
254
+ if [ "$work_type" = "feature" ]; then
255
+ name=$(basename "$file" .md)
256
+ if [ -z "${feature_topic_seen[$name]+x}" ]; then
257
+ feature_topics+=("$name")
258
+ feature_topic_seen[$name]=1
259
+ fi
260
+ fi
261
+ done
262
+ fi
263
+
264
+ if [ -d "$SPEC_DIR" ]; then
265
+ for file in "$SPEC_DIR"/*/specification.md; do
266
+ [ -f "$file" ] || continue
267
+ work_type=$(extract_field "$file" "work_type")
268
+ if [ "$work_type" = "feature" ]; then
269
+ name=$(basename "$(dirname "$file")")
270
+ if [ -z "${feature_topic_seen[$name]+x}" ]; then
271
+ feature_topics+=("$name")
272
+ feature_topic_seen[$name]=1
273
+ fi
274
+ fi
275
+ done
276
+ fi
277
+
278
+ if [ -d "$PLAN_DIR" ]; then
279
+ for file in "$PLAN_DIR"/*/plan.md; do
280
+ [ -f "$file" ] || continue
281
+ work_type=$(extract_field "$file" "work_type")
282
+ if [ "$work_type" = "feature" ]; then
283
+ name=$(basename "$(dirname "$file")")
284
+ if [ -z "${feature_topic_seen[$name]+x}" ]; then
285
+ feature_topics+=("$name")
286
+ feature_topic_seen[$name]=1
287
+ fi
288
+ fi
289
+ done
290
+ fi
291
+
292
+ feature_count=${#feature_topics[@]}
293
+
294
+ if [ "$feature_count" -eq 0 ]; then
295
+ echo " topics: []"
296
+ else
297
+ echo " topics:"
298
+ for topic in "${feature_topics[@]}"; do
299
+ # Determine phase state for this topic
300
+ disc_exists="false"
301
+ disc_status=""
302
+ disc_file="$DISCUSSION_DIR/${topic}.md"
303
+ if [ -f "$disc_file" ]; then
304
+ disc_exists="true"
305
+ disc_status=$(extract_field "$disc_file" "status")
306
+ disc_status=${disc_status:-"in-progress"}
307
+ fi
308
+
309
+ spec_exists="false"
310
+ spec_status=""
311
+ spec_file="$SPEC_DIR/${topic}/specification.md"
312
+ if [ -f "$spec_file" ]; then
313
+ spec_exists="true"
314
+ spec_status=$(extract_field "$spec_file" "status")
315
+ spec_status=${spec_status:-"in-progress"}
316
+ fi
317
+
318
+ plan_exists="false"
319
+ plan_status=""
320
+ plan_file="$PLAN_DIR/${topic}/plan.md"
321
+ if [ -f "$plan_file" ]; then
322
+ plan_exists="true"
323
+ plan_status=$(extract_field "$plan_file" "status")
324
+ plan_status=${plan_status:-"in-progress"}
325
+ fi
326
+
327
+ impl_exists="false"
328
+ impl_status=""
329
+ impl_file="$IMPL_DIR/${topic}/tracking.md"
330
+ if [ -f "$impl_file" ]; then
331
+ impl_exists="true"
332
+ impl_status=$(extract_field "$impl_file" "status")
333
+ impl_status=${impl_status:-"in-progress"}
334
+ fi
335
+
336
+ review_exists="false"
337
+ if [ -d "$REVIEW_DIR/${topic}" ]; then
338
+ for rdir in "$REVIEW_DIR/${topic}"/r*/; do
339
+ [ -d "$rdir" ] || continue
340
+ [ -f "${rdir}review.md" ] && review_exists="true" && break
341
+ done
342
+ fi
343
+
344
+ # Compute next_phase
345
+ next_phase=""
346
+ if [ "$impl_exists" = "true" ] && [ "$impl_status" = "completed" ] && [ "$review_exists" = "true" ]; then
347
+ next_phase="done"
348
+ elif [ "$impl_exists" = "true" ] && [ "$impl_status" = "completed" ]; then
349
+ next_phase="review"
350
+ elif [ "$impl_exists" = "true" ] && [ "$impl_status" = "in-progress" ]; then
351
+ next_phase="implementation"
352
+ elif [ "$plan_exists" = "true" ] && [ "$plan_status" = "concluded" ]; then
353
+ next_phase="implementation"
354
+ elif [ "$plan_exists" = "true" ]; then
355
+ next_phase="planning"
356
+ elif [ "$spec_exists" = "true" ] && [ "$spec_status" = "concluded" ]; then
357
+ next_phase="planning"
358
+ elif [ "$spec_exists" = "true" ]; then
359
+ next_phase="specification"
360
+ elif [ "$disc_exists" = "true" ] && [ "$disc_status" = "concluded" ]; then
361
+ next_phase="specification"
362
+ elif [ "$disc_exists" = "true" ]; then
363
+ next_phase="discussion"
364
+ else
365
+ next_phase="unknown"
366
+ fi
367
+
368
+ echo " - name: \"$topic\""
369
+ echo " next_phase: \"$next_phase\""
370
+ echo " discussion:"
371
+ echo " exists: $disc_exists"
372
+ [ "$disc_exists" = "true" ] && echo " status: \"$disc_status\""
373
+ echo " specification:"
374
+ echo " exists: $spec_exists"
375
+ [ "$spec_exists" = "true" ] && echo " status: \"$spec_status\""
376
+ echo " plan:"
377
+ echo " exists: $plan_exists"
378
+ [ "$plan_exists" = "true" ] && echo " status: \"$plan_status\""
379
+ echo " implementation:"
380
+ echo " exists: $impl_exists"
381
+ [ "$impl_exists" = "true" ] && echo " status: \"$impl_status\""
382
+ echo " review:"
383
+ echo " exists: $review_exists"
384
+ done
385
+ fi
386
+
387
+ echo " count: $feature_count"
388
+
389
+ echo ""
390
+
391
+ #
392
+ # BUGFIXES SECTION (topic-centric view for work_type: bugfix)
393
+ #
394
+ echo "bugfixes:"
395
+
396
+ bugfix_topics=()
397
+ declare -A bugfix_topic_seen=()
398
+
399
+ # Scan investigation directory first
400
+ if [ -d "$INVESTIGATION_DIR" ]; then
401
+ for file in "$INVESTIGATION_DIR"/*/investigation.md; do
402
+ [ -f "$file" ] || continue
403
+ name=$(basename "$(dirname "$file")")
404
+ if [ -z "${bugfix_topic_seen[$name]+x}" ]; then
405
+ bugfix_topics+=("$name")
406
+ bugfix_topic_seen[$name]=1
407
+ fi
408
+ done
409
+ fi
410
+
411
+ # Scan other phases for work_type: bugfix
412
+ if [ -d "$DISCUSSION_DIR" ]; then
413
+ for file in "$DISCUSSION_DIR"/*.md; do
414
+ [ -f "$file" ] || continue
415
+ work_type=$(extract_field "$file" "work_type")
416
+ if [ "$work_type" = "bugfix" ]; then
417
+ name=$(basename "$file" .md)
418
+ if [ -z "${bugfix_topic_seen[$name]+x}" ]; then
419
+ bugfix_topics+=("$name")
420
+ bugfix_topic_seen[$name]=1
421
+ fi
422
+ fi
423
+ done
424
+ fi
425
+
426
+ if [ -d "$SPEC_DIR" ]; then
427
+ for file in "$SPEC_DIR"/*/specification.md; do
428
+ [ -f "$file" ] || continue
429
+ work_type=$(extract_field "$file" "work_type")
430
+ if [ "$work_type" = "bugfix" ]; then
431
+ name=$(basename "$(dirname "$file")")
432
+ if [ -z "${bugfix_topic_seen[$name]+x}" ]; then
433
+ bugfix_topics+=("$name")
434
+ bugfix_topic_seen[$name]=1
435
+ fi
436
+ fi
437
+ done
438
+ fi
439
+
440
+ if [ -d "$PLAN_DIR" ]; then
441
+ for file in "$PLAN_DIR"/*/plan.md; do
442
+ [ -f "$file" ] || continue
443
+ work_type=$(extract_field "$file" "work_type")
444
+ if [ "$work_type" = "bugfix" ]; then
445
+ name=$(basename "$(dirname "$file")")
446
+ if [ -z "${bugfix_topic_seen[$name]+x}" ]; then
447
+ bugfix_topics+=("$name")
448
+ bugfix_topic_seen[$name]=1
449
+ fi
450
+ fi
451
+ done
452
+ fi
453
+
454
+ bugfix_count=${#bugfix_topics[@]}
455
+
456
+ if [ "$bugfix_count" -eq 0 ]; then
457
+ echo " topics: []"
458
+ else
459
+ echo " topics:"
460
+ for topic in "${bugfix_topics[@]}"; do
461
+ # Determine phase state for this topic (investigation → spec → plan → impl → review)
462
+ inv_exists="false"
463
+ inv_status=""
464
+ inv_file="$INVESTIGATION_DIR/${topic}/investigation.md"
465
+ if [ -f "$inv_file" ]; then
466
+ inv_exists="true"
467
+ inv_status=$(extract_field "$inv_file" "status")
468
+ inv_status=${inv_status:-"in-progress"}
469
+ fi
470
+
471
+ spec_exists="false"
472
+ spec_status=""
473
+ spec_file="$SPEC_DIR/${topic}/specification.md"
474
+ if [ -f "$spec_file" ]; then
475
+ spec_exists="true"
476
+ spec_status=$(extract_field "$spec_file" "status")
477
+ spec_status=${spec_status:-"in-progress"}
478
+ fi
479
+
480
+ plan_exists="false"
481
+ plan_status=""
482
+ plan_file="$PLAN_DIR/${topic}/plan.md"
483
+ if [ -f "$plan_file" ]; then
484
+ plan_exists="true"
485
+ plan_status=$(extract_field "$plan_file" "status")
486
+ plan_status=${plan_status:-"in-progress"}
487
+ fi
488
+
489
+ impl_exists="false"
490
+ impl_status=""
491
+ impl_file="$IMPL_DIR/${topic}/tracking.md"
492
+ if [ -f "$impl_file" ]; then
493
+ impl_exists="true"
494
+ impl_status=$(extract_field "$impl_file" "status")
495
+ impl_status=${impl_status:-"in-progress"}
496
+ fi
497
+
498
+ review_exists="false"
499
+ if [ -d "$REVIEW_DIR/${topic}" ]; then
500
+ for rdir in "$REVIEW_DIR/${topic}"/r*/; do
501
+ [ -d "$rdir" ] || continue
502
+ [ -f "${rdir}review.md" ] && review_exists="true" && break
503
+ done
504
+ fi
505
+
506
+ # Compute next_phase for bugfix pipeline
507
+ next_phase=""
508
+ if [ "$impl_exists" = "true" ] && [ "$impl_status" = "completed" ] && [ "$review_exists" = "true" ]; then
509
+ next_phase="done"
510
+ elif [ "$impl_exists" = "true" ] && [ "$impl_status" = "completed" ]; then
511
+ next_phase="review"
512
+ elif [ "$impl_exists" = "true" ] && [ "$impl_status" = "in-progress" ]; then
513
+ next_phase="implementation"
514
+ elif [ "$plan_exists" = "true" ] && [ "$plan_status" = "concluded" ]; then
515
+ next_phase="implementation"
516
+ elif [ "$plan_exists" = "true" ]; then
517
+ next_phase="planning"
518
+ elif [ "$spec_exists" = "true" ] && [ "$spec_status" = "concluded" ]; then
519
+ next_phase="planning"
520
+ elif [ "$spec_exists" = "true" ]; then
521
+ next_phase="specification"
522
+ elif [ "$inv_exists" = "true" ] && [ "$inv_status" = "concluded" ]; then
523
+ next_phase="specification"
524
+ elif [ "$inv_exists" = "true" ]; then
525
+ next_phase="investigation"
526
+ else
527
+ next_phase="unknown"
528
+ fi
529
+
530
+ echo " - name: \"$topic\""
531
+ echo " next_phase: \"$next_phase\""
532
+ echo " investigation:"
533
+ echo " exists: $inv_exists"
534
+ [ "$inv_exists" = "true" ] && echo " status: \"$inv_status\""
535
+ echo " specification:"
536
+ echo " exists: $spec_exists"
537
+ [ "$spec_exists" = "true" ] && echo " status: \"$spec_status\""
538
+ echo " plan:"
539
+ echo " exists: $plan_exists"
540
+ [ "$plan_exists" = "true" ] && echo " status: \"$plan_status\""
541
+ echo " implementation:"
542
+ echo " exists: $impl_exists"
543
+ [ "$impl_exists" = "true" ] && echo " status: \"$impl_status\""
544
+ echo " review:"
545
+ echo " exists: $review_exists"
546
+ done
547
+ fi
548
+
549
+ echo " count: $bugfix_count"
550
+
551
+ echo ""
552
+
553
+ #
554
+ # STATE SUMMARY
555
+ #
556
+ echo "state:"
557
+
558
+ has_any_work="false"
559
+ if [ "$research_count" -gt 0 ] || [ "$greenfield_disc_count" -gt 0 ] || [ "$greenfield_spec_count" -gt 0 ] || \
560
+ [ "$greenfield_plan_count" -gt 0 ] || [ "$greenfield_impl_count" -gt 0 ] || \
561
+ [ "$feature_count" -gt 0 ] || [ "$bugfix_count" -gt 0 ]; then
562
+ has_any_work="true"
563
+ fi
564
+
565
+ echo " has_any_work: $has_any_work"
566
+ echo " greenfield:"
567
+ echo " research_count: $research_count"
568
+ echo " discussion_count: $greenfield_disc_count"
569
+ echo " discussion_concluded: $greenfield_disc_concluded"
570
+ echo " specification_count: $greenfield_spec_count"
571
+ echo " specification_concluded: $greenfield_spec_concluded"
572
+ echo " plan_count: $greenfield_plan_count"
573
+ echo " plan_concluded: $greenfield_plan_concluded"
574
+ echo " implementation_count: $greenfield_impl_count"
575
+ echo " implementation_completed: $greenfield_impl_completed"
576
+ echo " feature_count: $feature_count"
577
+ echo " bugfix_count: $bugfix_count"