prizmkit 1.1.1 → 1.1.4

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 (119) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/adapters/claude/agent-adapter.js +18 -0
  3. package/bundled/adapters/claude/command-adapter.js +1 -27
  4. package/bundled/agents/prizm-dev-team-critic.md +2 -0
  5. package/bundled/agents/prizm-dev-team-dev.md +2 -0
  6. package/bundled/agents/prizm-dev-team-reviewer.md +2 -0
  7. package/bundled/dev-pipeline/README.md +63 -63
  8. package/bundled/dev-pipeline/assets/feature-list-example.json +1 -1
  9. package/bundled/dev-pipeline/assets/prizm-dev-team-integration.md +1 -1
  10. package/bundled/dev-pipeline/{launch-daemon.sh → launch-feature-daemon.sh} +33 -33
  11. package/bundled/dev-pipeline/launch-refactor-daemon.sh +454 -0
  12. package/bundled/dev-pipeline/lib/branch.sh +1 -1
  13. package/bundled/dev-pipeline/reset-feature.sh +3 -3
  14. package/bundled/dev-pipeline/reset-refactor.sh +312 -0
  15. package/bundled/dev-pipeline/{retry-bug.sh → retry-bugfix.sh} +47 -59
  16. package/bundled/dev-pipeline/retry-feature.sh +41 -54
  17. package/bundled/dev-pipeline/retry-refactor.sh +358 -0
  18. package/bundled/dev-pipeline/run-bugfix.sh +41 -0
  19. package/bundled/dev-pipeline/{run.sh → run-feature.sh} +64 -31
  20. package/bundled/dev-pipeline/run-refactor.sh +787 -0
  21. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +398 -10
  22. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +124 -0
  23. package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +419 -0
  24. package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +393 -0
  25. package/bundled/dev-pipeline/scripts/update-refactor-status.py +726 -0
  26. package/bundled/dev-pipeline/templates/agent-prompts/critic-code-challenge.md +13 -0
  27. package/bundled/dev-pipeline/templates/agent-prompts/critic-plan-challenge.md +7 -0
  28. package/bundled/dev-pipeline/templates/agent-prompts/dev-fix.md +7 -0
  29. package/bundled/dev-pipeline/templates/agent-prompts/dev-implement.md +27 -0
  30. package/bundled/dev-pipeline/templates/agent-prompts/dev-resume.md +5 -0
  31. package/bundled/dev-pipeline/templates/agent-prompts/reviewer-analyze.md +5 -0
  32. package/bundled/dev-pipeline/templates/agent-prompts/reviewer-review.md +12 -0
  33. package/bundled/dev-pipeline/templates/bootstrap-tier1.md +33 -2
  34. package/bundled/dev-pipeline/templates/bootstrap-tier2.md +13 -9
  35. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +16 -12
  36. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +22 -4
  37. package/bundled/dev-pipeline/templates/feature-list-schema.json +1 -1
  38. package/bundled/dev-pipeline/templates/refactor-list-schema.json +159 -0
  39. package/bundled/dev-pipeline/templates/sections/ac-verification-checklist.md +13 -0
  40. package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +36 -0
  41. package/bundled/dev-pipeline/templates/sections/failure-log-check.md +2 -1
  42. package/bundled/dev-pipeline/templates/sections/feature-context.md +1 -1
  43. package/bundled/dev-pipeline/templates/sections/phase-analyze-agent.md +11 -7
  44. package/bundled/dev-pipeline/templates/sections/phase-analyze-full.md +11 -7
  45. package/bundled/dev-pipeline/templates/sections/phase-browser-verification.md +5 -1
  46. package/bundled/dev-pipeline/templates/sections/phase-commit-full.md +3 -0
  47. package/bundled/dev-pipeline/templates/sections/phase-commit.md +3 -0
  48. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-agent-suffix.md +3 -0
  49. package/bundled/dev-pipeline/templates/sections/phase-context-snapshot-lite-suffix.md +3 -0
  50. package/bundled/dev-pipeline/templates/sections/phase-critic-code.md +11 -10
  51. package/bundled/dev-pipeline/templates/sections/phase-critic-plan-full.md +12 -10
  52. package/bundled/dev-pipeline/templates/sections/phase-critic-plan.md +11 -9
  53. package/bundled/dev-pipeline/templates/sections/phase-deploy-verification.md +3 -0
  54. package/bundled/dev-pipeline/templates/sections/phase-implement-agent.md +10 -10
  55. package/bundled/dev-pipeline/templates/sections/phase-implement-full.md +12 -16
  56. package/bundled/dev-pipeline/templates/sections/phase-implement-lite.md +3 -0
  57. package/bundled/dev-pipeline/templates/sections/phase-plan-agent.md +3 -0
  58. package/bundled/dev-pipeline/templates/sections/phase-plan-lite.md +3 -0
  59. package/bundled/dev-pipeline/templates/sections/phase-review-agent.md +11 -13
  60. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +12 -20
  61. package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +3 -0
  62. package/bundled/dev-pipeline/templates/sections/phase0-init.md +3 -0
  63. package/bundled/dev-pipeline/templates/sections/phase0-test-baseline.md +3 -0
  64. package/bundled/dev-pipeline/templates/sections/resume-header.md +4 -1
  65. package/bundled/dev-pipeline/templates/sections/test-failure-recovery.md +75 -0
  66. package/bundled/rules/prizm/prizm-commit-workflow.md +1 -0
  67. package/bundled/rules/prizm/prizm-documentation.md +15 -15
  68. package/bundled/rules/prizm/prizm-progressive-loading.md +2 -1
  69. package/bundled/skills/_metadata.json +33 -6
  70. package/bundled/skills/app-planner/SKILL.md +105 -320
  71. package/bundled/skills/app-planner/assets/app-design-guide.md +101 -0
  72. package/bundled/skills/app-planner/references/frontend-design-guide.md +1 -1
  73. package/bundled/skills/app-planner/references/project-brief-guide.md +49 -80
  74. package/bundled/skills/bug-fix-workflow/SKILL.md +2 -2
  75. package/bundled/skills/bug-planner/SKILL.md +68 -5
  76. package/bundled/skills/bug-planner/scripts/validate-bug-list.py +3 -2
  77. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +19 -5
  78. package/bundled/skills/{dev-pipeline-launcher → feature-pipeline-launcher}/SKILL.md +32 -32
  79. package/bundled/skills/feature-planner/SKILL.md +337 -0
  80. package/bundled/skills/{app-planner → feature-planner}/assets/evaluation-guide.md +4 -4
  81. package/bundled/skills/{app-planner → feature-planner}/assets/planning-guide.md +3 -171
  82. package/bundled/skills/{app-planner → feature-planner}/references/browser-interaction.md +6 -5
  83. package/bundled/skills/feature-planner/references/decomposition-patterns.md +75 -0
  84. package/bundled/skills/{app-planner → feature-planner}/references/error-recovery.md +8 -8
  85. package/bundled/skills/{app-planner → feature-planner}/references/incremental-feature-planning.md +1 -1
  86. package/bundled/skills/{app-planner/references/new-app-planning.md → feature-planner/references/new-project-planning.md} +1 -1
  87. package/bundled/skills/{app-planner → feature-planner}/scripts/validate-and-generate.py +4 -4
  88. package/bundled/skills/feature-workflow/SKILL.md +23 -23
  89. package/bundled/skills/prizm-kit/SKILL.md +1 -3
  90. package/bundled/skills/prizm-kit/assets/project-memory-template.md +4 -2
  91. package/bundled/skills/prizmkit-analyze/SKILL.md +2 -5
  92. package/bundled/skills/prizmkit-code-review/SKILL.md +2 -2
  93. package/bundled/skills/prizmkit-committer/SKILL.md +32 -8
  94. package/bundled/skills/prizmkit-deploy/SKILL.md +1 -5
  95. package/bundled/skills/prizmkit-implement/SKILL.md +5 -51
  96. package/bundled/skills/prizmkit-init/SKILL.md +7 -78
  97. package/bundled/skills/prizmkit-plan/SKILL.md +1 -12
  98. package/bundled/skills/prizmkit-prizm-docs/SKILL.md +13 -28
  99. package/bundled/skills/prizmkit-prizm-docs/assets/PRIZM-SPEC.md +52 -1
  100. package/bundled/skills/prizmkit-retrospective/SKILL.md +12 -117
  101. package/bundled/skills/recovery-workflow/SKILL.md +168 -316
  102. package/bundled/skills/recovery-workflow/evals/evals.json +29 -13
  103. package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +232 -274
  104. package/bundled/skills/refactor-pipeline-launcher/SKILL.md +352 -0
  105. package/bundled/skills/refactor-planner/SKILL.md +436 -0
  106. package/bundled/skills/refactor-planner/assets/planning-guide.md +292 -0
  107. package/bundled/skills/refactor-planner/references/behavior-preservation.md +301 -0
  108. package/bundled/skills/refactor-planner/references/refactor-scoping-guide.md +221 -0
  109. package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +786 -0
  110. package/bundled/skills/refactor-workflow/SKILL.md +299 -319
  111. package/bundled/team/prizm-dev-team.json +1 -1
  112. package/package.json +1 -1
  113. package/src/clean.js +3 -3
  114. package/src/scaffold.js +6 -6
  115. package/bundled/skills/prizmkit-plan/assets/spec-template.md +0 -56
  116. package/bundled/skills/prizmkit-plan/references/clarify-guide.md +0 -67
  117. package/src/config.js +0 -504
  118. package/src/prompts.js +0 -210
  119. /package/bundled/skills/{dev-pipeline-launcher → feature-pipeline-launcher}/scripts/preflight-check.py +0 -0
@@ -0,0 +1,454 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # ============================================================
5
+ # dev-pipeline/launch-refactor-daemon.sh - Daemon wrapper for run-refactor.sh
6
+ #
7
+ # Manages run-refactor.sh as a background daemon process with PID tracking,
8
+ # log consolidation, and lifecycle commands.
9
+ #
10
+ # Usage:
11
+ # ./launch-refactor-daemon.sh start [refactor-list.json] [--env "KEY=VAL ..."]
12
+ # ./launch-refactor-daemon.sh stop
13
+ # ./launch-refactor-daemon.sh status
14
+ # ./launch-refactor-daemon.sh logs [--lines N] [--follow]
15
+ # ./launch-refactor-daemon.sh restart [refactor-list.json] [--env "KEY=VAL ..."]
16
+ #
17
+ # NOTE:
18
+ # In AI skill sessions, always use this daemon wrapper.
19
+ # Do NOT call `run-refactor.sh run ...` directly, because foreground sessions may be killed by CLI timeout.
20
+ #
21
+ # Files managed:
22
+ # refactor-state/.pipeline.pid - PID of the background run-refactor.sh process
23
+ # refactor-state/pipeline-daemon.log - Consolidated stdout+stderr
24
+ # ============================================================
25
+
26
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
27
+ STATE_DIR="$SCRIPT_DIR/refactor-state"
28
+ PID_FILE="$STATE_DIR/.pipeline.pid"
29
+ LOG_FILE="$STATE_DIR/pipeline-daemon.log"
30
+ RUN_SCRIPT="$SCRIPT_DIR/run-refactor.sh"
31
+
32
+ # Colors
33
+ RED='\033[0;31m'
34
+ GREEN='\033[0;32m'
35
+ YELLOW='\033[1;33m'
36
+ BLUE='\033[0;34m'
37
+ BOLD='\033[1m'
38
+ NC='\033[0m'
39
+
40
+ log_info() { echo -e "${BLUE}[INFO]${NC} $*" >&2; }
41
+ log_warn() { echo -e "${YELLOW}[WARN]${NC} $*" >&2; }
42
+ log_error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
43
+ log_success() { echo -e "${GREEN}[OK]${NC} $*" >&2; }
44
+
45
+ # ============================================================
46
+ # Helpers
47
+ # ============================================================
48
+
49
+ is_running() {
50
+ if [[ ! -f "$PID_FILE" ]]; then
51
+ return 1
52
+ fi
53
+ local pid
54
+ pid=$(cat "$PID_FILE" 2>/dev/null) || return 1
55
+ if [[ -z "$pid" ]]; then
56
+ return 1
57
+ fi
58
+ if kill -0 "$pid" 2>/dev/null; then
59
+ return 0
60
+ else
61
+ return 1
62
+ fi
63
+ }
64
+
65
+ get_pid() {
66
+ if [[ -f "$PID_FILE" ]]; then
67
+ cat "$PID_FILE" 2>/dev/null || echo ""
68
+ else
69
+ echo ""
70
+ fi
71
+ }
72
+
73
+ clean_stale_pid() {
74
+ if [[ -f "$PID_FILE" ]]; then
75
+ local pid
76
+ pid=$(get_pid)
77
+ if [[ -n "$pid" ]] && ! kill -0 "$pid" 2>/dev/null; then
78
+ rm -f "$PID_FILE"
79
+ log_warn "Cleaned stale PID file (process $pid no longer running)"
80
+ fi
81
+ fi
82
+ }
83
+
84
+ # ============================================================
85
+ # start
86
+ # ============================================================
87
+
88
+ cmd_start() {
89
+ local refactor_list=""
90
+ local env_overrides=""
91
+
92
+ while [[ $# -gt 0 ]]; do
93
+ case "$1" in
94
+ --env) shift; env_overrides="${1:-}"; shift ;;
95
+ *) refactor_list="$1"; shift ;;
96
+ esac
97
+ done
98
+
99
+ if [[ -z "$refactor_list" ]]; then
100
+ refactor_list="refactor-list.json"
101
+ fi
102
+ if [[ ! "$refactor_list" = /* ]]; then
103
+ refactor_list="$(cd "$(dirname "$refactor_list")" 2>/dev/null && pwd)/$(basename "$refactor_list")"
104
+ fi
105
+
106
+ if [[ ! -f "$refactor_list" ]]; then
107
+ log_error "Refactor list not found: $refactor_list"
108
+ log_error "Run the refactor-planner skill first to generate refactor-list.json"
109
+ exit 2
110
+ fi
111
+
112
+ if [[ ! -x "$RUN_SCRIPT" ]]; then
113
+ log_error "run-refactor.sh not found or not executable: $RUN_SCRIPT"
114
+ exit 2
115
+ fi
116
+
117
+ clean_stale_pid
118
+
119
+ if is_running; then
120
+ local pid
121
+ pid=$(get_pid)
122
+ log_error "Refactor pipeline is already running (PID: $pid)"
123
+ log_error "Use './launch-refactor-daemon.sh stop' first, or './launch-refactor-daemon.sh restart'"
124
+ exit 1
125
+ fi
126
+
127
+ mkdir -p "$STATE_DIR"
128
+
129
+ local env_cmd=""
130
+ if [[ -n "$env_overrides" ]]; then
131
+ env_cmd="env $env_overrides"
132
+ fi
133
+
134
+ local start_time
135
+ start_time=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
136
+
137
+ # Rotate log if over 50 MB
138
+ if [[ -f "$LOG_FILE" ]]; then
139
+ local log_bytes
140
+ log_bytes=$(wc -c < "$LOG_FILE" 2>/dev/null | tr -d ' ')
141
+ if [[ "$log_bytes" -gt 52428800 ]]; then
142
+ mv "$LOG_FILE" "${LOG_FILE}.$(date -u '+%Y%m%dT%H%M%S').bak"
143
+ log_info "Log rotated (was $((log_bytes / 1048576))MB): ${LOG_FILE}.bak"
144
+ fi
145
+ fi
146
+
147
+ log_info "Launching refactor pipeline..."
148
+ log_info "Refactor list: $refactor_list"
149
+ log_info "Log file: $LOG_FILE"
150
+
151
+ # Unset CLAUDECODE to allow spawning nested Claude Code sessions.
152
+ # When this daemon is launched from within a Claude Code session, the env var
153
+ # is inherited and blocks child claude processes with "nested sessions" error.
154
+ unset CLAUDECODE 2>/dev/null || true
155
+
156
+ {
157
+ echo ""
158
+ echo "================================================================"
159
+ echo " Refactor Pipeline Daemon Started: $start_time"
160
+ echo " Refactor list: $refactor_list"
161
+ if [[ -n "$env_overrides" ]]; then
162
+ echo " Environment: $env_overrides"
163
+ fi
164
+ echo "================================================================"
165
+ echo ""
166
+ } >> "$LOG_FILE"
167
+
168
+ if [[ -n "$env_cmd" ]]; then
169
+ nohup $env_cmd "$RUN_SCRIPT" run "$refactor_list" >> "$LOG_FILE" 2>&1 &
170
+ else
171
+ nohup "$RUN_SCRIPT" run "$refactor_list" >> "$LOG_FILE" 2>&1 &
172
+ fi
173
+ local pipeline_pid=$!
174
+ disown "$pipeline_pid" 2>/dev/null || true
175
+
176
+ echo "$pipeline_pid" > "$PID_FILE"
177
+
178
+ python3 -c "
179
+ import json
180
+ from datetime import datetime
181
+ data = {
182
+ 'pid': $pipeline_pid,
183
+ 'pipeline_type': 'refactor',
184
+ 'started_at': '$start_time',
185
+ 'refactor_list': '$refactor_list',
186
+ 'env_overrides': '$env_overrides',
187
+ 'log_file': '$LOG_FILE'
188
+ }
189
+ with open('$STATE_DIR/.pipeline-meta.json', 'w') as f:
190
+ json.dump(data, f, indent=2)
191
+ " 2>/dev/null || true
192
+
193
+ sleep 2
194
+ if is_running; then
195
+ log_success "Refactor pipeline started successfully (PID: $pipeline_pid)"
196
+ log_info "Monitor logs: ./launch-refactor-daemon.sh logs --follow"
197
+ log_info "Check status: ./launch-refactor-daemon.sh status"
198
+ echo "{\"success\": true, \"pid\": $pipeline_pid, \"log_file\": \"$LOG_FILE\", \"started_at\": \"$start_time\"}"
199
+ else
200
+ log_error "Refactor pipeline process died immediately after launch"
201
+ log_error "Check log for errors: tail -20 $LOG_FILE"
202
+ rm -f "$PID_FILE"
203
+ exit 1
204
+ fi
205
+ }
206
+
207
+ # ============================================================
208
+ # stop
209
+ # ============================================================
210
+
211
+ cmd_stop() {
212
+ if [[ ! -f "$PID_FILE" ]]; then
213
+ log_info "Refactor pipeline is not running (no PID file)"
214
+ echo '{"success": true, "message": "not running"}'
215
+ return 0
216
+ fi
217
+
218
+ local pid
219
+ pid=$(get_pid)
220
+
221
+ if [[ -z "$pid" ]]; then
222
+ log_info "Refactor pipeline is not running (empty PID file)"
223
+ rm -f "$PID_FILE"
224
+ echo '{"success": true, "message": "not running"}'
225
+ return 0
226
+ fi
227
+
228
+ if ! kill -0 "$pid" 2>/dev/null; then
229
+ log_info "Refactor pipeline is not running (process $pid already exited)"
230
+ rm -f "$PID_FILE"
231
+ echo '{"success": true, "message": "already exited"}'
232
+ return 0
233
+ fi
234
+
235
+ log_info "Stopping refactor pipeline (PID: $pid)..."
236
+ kill -TERM "$pid" 2>/dev/null || true
237
+
238
+ local waited=0
239
+ while [[ $waited -lt 30 ]]; do
240
+ if ! kill -0 "$pid" 2>/dev/null; then
241
+ break
242
+ fi
243
+ sleep 1
244
+ waited=$((waited + 1))
245
+ done
246
+
247
+ if kill -0 "$pid" 2>/dev/null; then
248
+ log_warn "Process did not exit after 30s, sending SIGKILL..."
249
+ kill -9 "$pid" 2>/dev/null || true
250
+ sleep 1
251
+ fi
252
+
253
+ rm -f "$PID_FILE"
254
+
255
+ if ! kill -0 "$pid" 2>/dev/null; then
256
+ log_success "Refactor pipeline stopped"
257
+ echo "{\"success\": true, \"pid\": $pid, \"message\": \"stopped\"}"
258
+ else
259
+ log_error "Failed to stop refactor pipeline (PID: $pid)"
260
+ echo "{\"success\": false, \"pid\": $pid, \"message\": \"failed to stop\"}"
261
+ exit 1
262
+ fi
263
+ }
264
+
265
+ # ============================================================
266
+ # status
267
+ # ============================================================
268
+
269
+ cmd_status() {
270
+ clean_stale_pid
271
+
272
+ if ! is_running; then
273
+ log_info "Refactor pipeline is not running"
274
+
275
+ if [[ -f "$STATE_DIR/.pipeline-meta.json" ]]; then
276
+ local last_refactor_list
277
+ last_refactor_list=$(python3 -c "
278
+ import json
279
+ with open('$STATE_DIR/.pipeline-meta.json') as f:
280
+ print(json.load(f).get('refactor_list', ''))
281
+ " 2>/dev/null || echo "")
282
+
283
+ if [[ -n "$last_refactor_list" && -f "$last_refactor_list" ]]; then
284
+ echo "" >&2
285
+ log_info "Last run refactor progress:"
286
+ python3 "$SCRIPT_DIR/scripts/update-refactor-status.py" \
287
+ --refactor-list "$last_refactor_list" \
288
+ --state-dir "$STATE_DIR" \
289
+ --action status >&2 2>/dev/null || true
290
+ echo "" >&2
291
+ fi
292
+ fi
293
+
294
+ echo '{"running": false}'
295
+ return 1
296
+ fi
297
+
298
+ local pid
299
+ pid=$(get_pid)
300
+
301
+ local started_at=""
302
+ local refactor_list_path=""
303
+ if [[ -f "$STATE_DIR/.pipeline-meta.json" ]]; then
304
+ started_at=$(python3 -c "
305
+ import json
306
+ with open('$STATE_DIR/.pipeline-meta.json') as f:
307
+ print(json.load(f).get('started_at', ''))
308
+ " 2>/dev/null || echo "")
309
+ refactor_list_path=$(python3 -c "
310
+ import json
311
+ with open('$STATE_DIR/.pipeline-meta.json') as f:
312
+ print(json.load(f).get('refactor_list', ''))
313
+ " 2>/dev/null || echo "")
314
+ fi
315
+
316
+ log_success "Refactor pipeline is running (PID: $pid)"
317
+ if [[ -n "$started_at" ]]; then
318
+ log_info "Started at: $started_at"
319
+ fi
320
+ log_info "Log file: $LOG_FILE"
321
+
322
+ if [[ -n "$refactor_list_path" && -f "$refactor_list_path" ]]; then
323
+ echo "" >&2
324
+ python3 "$SCRIPT_DIR/scripts/update-refactor-status.py" \
325
+ --refactor-list "$refactor_list_path" \
326
+ --state-dir "$STATE_DIR" \
327
+ --action status >&2 2>/dev/null || true
328
+ echo "" >&2
329
+ fi
330
+
331
+ if [[ -f "$LOG_FILE" ]]; then
332
+ log_info "--- Last 5 log lines ---"
333
+ tail -5 "$LOG_FILE" >&2 || true
334
+ echo "" >&2
335
+ fi
336
+
337
+ local progress_json=""
338
+ if [[ -n "$refactor_list_path" && -f "$refactor_list_path" ]]; then
339
+ progress_json=$(python3 -c "
340
+ import json, os
341
+ bl = json.load(open('$refactor_list_path'))
342
+ items = bl.get('refactors', [])
343
+ total = len(items)
344
+ counts = {'completed': 0, 'in_progress': 0, 'failed': 0, 'pending': 0, 'needs_info': 0}
345
+ for item in items:
346
+ rid = item.get('id', '')
347
+ sp = os.path.join('$STATE_DIR', 'refactors', rid, 'status.json')
348
+ if os.path.isfile(sp):
349
+ fs = json.load(open(sp))
350
+ st = fs.get('status', 'pending')
351
+ else:
352
+ st = 'pending'
353
+ if st in counts:
354
+ counts[st] += 1
355
+ else:
356
+ counts['pending'] += 1
357
+ pct = round(counts['completed'] / total * 100, 1) if total > 0 else 0
358
+ print(json.dumps({'total': total, 'completed': counts['completed'], 'in_progress': counts['in_progress'], 'failed': counts['failed'], 'pending': counts['pending'], 'needs_info': counts['needs_info'], 'percent': pct}))
359
+ " 2>/dev/null || echo "")
360
+ fi
361
+
362
+ if [[ -n "$progress_json" ]]; then
363
+ echo "{\"running\": true, \"pid\": $pid, \"pipeline_type\": \"refactor\", \"log_file\": \"$LOG_FILE\", \"started_at\": \"$started_at\", \"refactor_list\": \"$refactor_list_path\", \"progress\": $progress_json}"
364
+ else
365
+ echo "{\"running\": true, \"pid\": $pid, \"pipeline_type\": \"refactor\", \"log_file\": \"$LOG_FILE\", \"started_at\": \"$started_at\", \"refactor_list\": \"$refactor_list_path\"}"
366
+ fi
367
+ }
368
+
369
+ # ============================================================
370
+ # logs
371
+ # ============================================================
372
+
373
+ cmd_logs() {
374
+ local lines=50
375
+ local follow=false
376
+
377
+ while [[ $# -gt 0 ]]; do
378
+ case "$1" in
379
+ --lines|-n) shift; lines="${1:-50}"; shift ;;
380
+ --follow|-f) follow=true; shift ;;
381
+ *) log_error "Unknown option: $1"; exit 1 ;;
382
+ esac
383
+ done
384
+
385
+ if [[ ! -f "$LOG_FILE" ]]; then
386
+ log_info "No log file found at $LOG_FILE"
387
+ exit 0
388
+ fi
389
+
390
+ if [[ "$follow" == true ]]; then
391
+ log_info "Following $LOG_FILE (Ctrl+C to stop)..."
392
+ echo "" >&2
393
+ tail -f "$LOG_FILE"
394
+ else
395
+ tail -"$lines" "$LOG_FILE"
396
+ fi
397
+ }
398
+
399
+ # ============================================================
400
+ # restart
401
+ # ============================================================
402
+
403
+ cmd_restart() {
404
+ cmd_stop 2>/dev/null || true
405
+ sleep 1
406
+ cmd_start "$@"
407
+ }
408
+
409
+ # ============================================================
410
+ # Entry point
411
+ # ============================================================
412
+
413
+ show_help() {
414
+ cat <<'HELP'
415
+ Usage: launch-refactor-daemon.sh <command> [options]
416
+
417
+ Commands:
418
+ start [refactor-list.json] [--env "K=V ..."] Start refactor pipeline in background
419
+ stop Gracefully stop pipeline
420
+ status Check if pipeline is running
421
+ logs [--lines N] [--follow] View pipeline logs
422
+ restart [refactor-list.json] [--env "K=V ..."] Stop + start pipeline
423
+ help Show this help
424
+
425
+ Examples:
426
+ ./launch-refactor-daemon.sh start # Start with default refactor-list.json
427
+ ./launch-refactor-daemon.sh start my-refactors.json # Start with custom refactor list
428
+ ./launch-refactor-daemon.sh start --env "MAX_RETRIES=5"
429
+ ./launch-refactor-daemon.sh start --env "STRICT_BEHAVIOR_CHECK=0"
430
+ ./launch-refactor-daemon.sh status # Check if running (JSON on stdout)
431
+ ./launch-refactor-daemon.sh logs --follow # Live log tailing
432
+ ./launch-refactor-daemon.sh stop # Graceful shutdown
433
+ ./launch-refactor-daemon.sh restart # Stop + start
434
+
435
+ Environment Variables (pass via --env):
436
+ MAX_RETRIES Max retries per refactor (default: 3)
437
+ SESSION_TIMEOUT Session timeout in seconds (default: 0 = no limit)
438
+ VERBOSE Set to 1 for verbose AI CLI output
439
+ STRICT_BEHAVIOR_CHECK Force full test suite after each refactor (default: 1)
440
+ HEARTBEAT_INTERVAL Heartbeat log interval in seconds (default: 30)
441
+ DEV_BRANCH Custom dev branch name (default: auto-generated)
442
+ AUTO_PUSH Auto-push to remote after successful refactor (default: 0, set 1 to enable)
443
+ HELP
444
+ }
445
+
446
+ case "${1:-help}" in
447
+ start) shift; cmd_start "$@" ;;
448
+ stop) cmd_stop ;;
449
+ status) cmd_status ;;
450
+ logs|log) shift; cmd_logs "$@" ;;
451
+ restart) shift; cmd_restart "$@" ;;
452
+ help|--help|-h) show_help ;;
453
+ *) log_error "Unknown command: $1"; echo "" >&2; show_help; exit 1 ;;
454
+ esac
@@ -2,7 +2,7 @@
2
2
  # ============================================================
3
3
  # dev-pipeline/lib/branch.sh - Git Branch Lifecycle Library
4
4
  #
5
- # Shared by run.sh and run-bugfix.sh for branch-based serial
5
+ # Shared by run-feature.sh and run-bugfix.sh for branch-based serial
6
6
  # development. Each pipeline run creates a dev branch and all
7
7
  # features/bugs commit directly on it in sequence.
8
8
  #
@@ -117,7 +117,7 @@ if [[ ! -f "$FEATURE_LIST" ]]; then
117
117
  fi
118
118
 
119
119
  if [[ ! -f "$STATE_DIR/pipeline.json" ]]; then
120
- log_error "No pipeline state found. Run './run.sh run' first to initialize."
120
+ log_error "No pipeline state found. Run './run-feature.sh run' first to initialize."
121
121
  exit 1
122
122
  fi
123
123
 
@@ -181,7 +181,7 @@ fi
181
181
 
182
182
  # --run only works with single feature
183
183
  if [[ "$DO_RUN" == true && ${#FEATURE_IDS[@]} -gt 1 ]]; then
184
- log_warn "--run is only supported for single feature reset. Use './run.sh run' to resume pipeline after batch reset."
184
+ log_warn "--run is only supported for single feature reset. Use './run-feature.sh run' to resume pipeline after batch reset."
185
185
  DO_RUN=false
186
186
  fi
187
187
 
@@ -305,7 +305,7 @@ if [[ "$DO_RUN" == true && ${#FEATURE_IDS[@]} -eq 1 ]]; then
305
305
  echo ""
306
306
  exec "$SCRIPT_DIR/retry-feature.sh" "${FEATURE_IDS[0]}" "$FEATURE_LIST"
307
307
  else
308
- log_info " ./dev-pipeline/run.sh run feature-list.json # Resume pipeline from first pending"
308
+ log_info " ./dev-pipeline/run-feature.sh run feature-list.json # Resume pipeline from first pending"
309
309
  if [[ ${#FEATURE_IDS[@]} -eq 1 ]]; then
310
310
  log_info " ./dev-pipeline/retry-feature.sh ${FEATURE_IDS[0]} # Retry single feature"
311
311
  fi