prizmkit 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled/VERSION.json +5 -0
- package/bundled/adapters/claude/agent-adapter.js +108 -0
- package/bundled/adapters/claude/command-adapter.js +104 -0
- package/bundled/adapters/claude/paths.js +35 -0
- package/bundled/adapters/claude/rules-adapter.js +77 -0
- package/bundled/adapters/claude/settings-adapter.js +73 -0
- package/bundled/adapters/claude/team-adapter.js +183 -0
- package/bundled/adapters/codebuddy/agent-adapter.js +43 -0
- package/bundled/adapters/codebuddy/paths.js +29 -0
- package/bundled/adapters/codebuddy/settings-adapter.js +47 -0
- package/bundled/adapters/codebuddy/skill-adapter.js +68 -0
- package/bundled/adapters/codebuddy/team-adapter.js +46 -0
- package/bundled/adapters/shared/frontmatter.js +77 -0
- package/bundled/agents/prizm-dev-team-coordinator.md +142 -0
- package/bundled/agents/prizm-dev-team-dev.md +99 -0
- package/bundled/agents/prizm-dev-team-pm.md +114 -0
- package/bundled/agents/prizm-dev-team-reviewer.md +119 -0
- package/bundled/dev-pipeline/README.md +482 -0
- package/bundled/dev-pipeline/assets/feature-list-example.json +147 -0
- package/bundled/dev-pipeline/assets/prizm-dev-team-integration.md +138 -0
- package/bundled/dev-pipeline/launch-bugfix-daemon.sh +425 -0
- package/bundled/dev-pipeline/launch-daemon.sh +549 -0
- package/bundled/dev-pipeline/reset-feature.sh +209 -0
- package/bundled/dev-pipeline/retry-bug.sh +344 -0
- package/bundled/dev-pipeline/retry-feature.sh +338 -0
- package/bundled/dev-pipeline/run-bugfix.sh +638 -0
- package/bundled/dev-pipeline/run.sh +845 -0
- package/bundled/dev-pipeline/scripts/check-session-status.py +158 -0
- package/bundled/dev-pipeline/scripts/detect-stuck.py +385 -0
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +598 -0
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +402 -0
- package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +294 -0
- package/bundled/dev-pipeline/scripts/init-dev-team.py +134 -0
- package/bundled/dev-pipeline/scripts/init-pipeline.py +335 -0
- package/bundled/dev-pipeline/scripts/update-bug-status.py +748 -0
- package/bundled/dev-pipeline/scripts/update-feature-status.py +1076 -0
- package/bundled/dev-pipeline/templates/bootstrap-prompt.md +262 -0
- package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +159 -0
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +291 -0
- package/bundled/dev-pipeline/templates/feature-list-schema.json +112 -0
- package/bundled/dev-pipeline/templates/session-status-schema.json +77 -0
- package/bundled/skills/_metadata.json +267 -0
- package/bundled/skills/app-planner/SKILL.md +580 -0
- package/bundled/skills/app-planner/assets/planning-guide.md +313 -0
- package/bundled/skills/app-planner/scripts/validate-and-generate.py +758 -0
- package/bundled/skills/bug-planner/SKILL.md +235 -0
- package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +252 -0
- package/bundled/skills/dev-pipeline-launcher/SKILL.md +223 -0
- package/bundled/skills/prizm-kit/SKILL.md +151 -0
- package/bundled/skills/prizm-kit/assets/claude-md-template.md +38 -0
- package/bundled/skills/prizm-kit/assets/codebuddy-md-template.md +35 -0
- package/bundled/skills/prizm-kit/assets/hooks/prizm-commit-hook.json +15 -0
- package/bundled/skills/prizmkit-adr-manager/SKILL.md +68 -0
- package/bundled/skills/prizmkit-adr-manager/assets/adr-template.md +26 -0
- package/bundled/skills/prizmkit-analyze/SKILL.md +194 -0
- package/bundled/skills/prizmkit-api-doc-generator/SKILL.md +56 -0
- package/bundled/skills/prizmkit-bug-fix-workflow/SKILL.md +351 -0
- package/bundled/skills/prizmkit-bug-reproducer/SKILL.md +62 -0
- package/bundled/skills/prizmkit-ci-cd-generator/SKILL.md +54 -0
- package/bundled/skills/prizmkit-clarify/SKILL.md +52 -0
- package/bundled/skills/prizmkit-code-review/SKILL.md +70 -0
- package/bundled/skills/prizmkit-committer/SKILL.md +117 -0
- package/bundled/skills/prizmkit-db-migration/SKILL.md +65 -0
- package/bundled/skills/prizmkit-dependency-health/SKILL.md +123 -0
- package/bundled/skills/prizmkit-deployment-strategy/SKILL.md +58 -0
- package/bundled/skills/prizmkit-error-triage/SKILL.md +55 -0
- package/bundled/skills/prizmkit-implement/SKILL.md +47 -0
- package/bundled/skills/prizmkit-init/SKILL.md +156 -0
- package/bundled/skills/prizmkit-log-analyzer/SKILL.md +55 -0
- package/bundled/skills/prizmkit-monitoring-setup/SKILL.md +75 -0
- package/bundled/skills/prizmkit-onboarding-generator/SKILL.md +70 -0
- package/bundled/skills/prizmkit-perf-profiler/SKILL.md +55 -0
- package/bundled/skills/prizmkit-plan/SKILL.md +54 -0
- package/bundled/skills/prizmkit-plan/assets/plan-template.md +37 -0
- package/bundled/skills/prizmkit-prizm-docs/SKILL.md +140 -0
- package/bundled/skills/prizmkit-prizm-docs/assets/PRIZM-SPEC.md +943 -0
- package/bundled/skills/prizmkit-retrospective/SKILL.md +79 -0
- package/bundled/skills/prizmkit-security-audit/SKILL.md +130 -0
- package/bundled/skills/prizmkit-specify/SKILL.md +52 -0
- package/bundled/skills/prizmkit-specify/assets/spec-template.md +37 -0
- package/bundled/skills/prizmkit-summarize/SKILL.md +51 -0
- package/bundled/skills/prizmkit-summarize/assets/registry-template.md +18 -0
- package/bundled/skills/prizmkit-tasks/SKILL.md +50 -0
- package/bundled/skills/prizmkit-tasks/assets/tasks-template.md +21 -0
- package/bundled/skills/prizmkit-tech-debt-tracker/SKILL.md +139 -0
- package/bundled/team/prizm-dev-team.json +47 -0
- package/bundled/templates/claude-md-template.md +38 -0
- package/bundled/templates/codebuddy-md-template.md +35 -0
- package/package.json +2 -1
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# ============================================================
|
|
5
|
+
# dev-pipeline/launch-bugfix-daemon.sh - Daemon wrapper for run-bugfix.sh
|
|
6
|
+
#
|
|
7
|
+
# Manages run-bugfix.sh as a background daemon process with PID tracking,
|
|
8
|
+
# log consolidation, and lifecycle commands.
|
|
9
|
+
#
|
|
10
|
+
# Usage:
|
|
11
|
+
# ./launch-bugfix-daemon.sh start [bug-fix-list.json] [--env "KEY=VAL ..."]
|
|
12
|
+
# ./launch-bugfix-daemon.sh stop
|
|
13
|
+
# ./launch-bugfix-daemon.sh status
|
|
14
|
+
# ./launch-bugfix-daemon.sh logs [--lines N] [--follow]
|
|
15
|
+
# ./launch-bugfix-daemon.sh restart [bug-fix-list.json] [--env "KEY=VAL ..."]
|
|
16
|
+
#
|
|
17
|
+
# Files managed:
|
|
18
|
+
# bugfix-state/.pipeline.pid - PID of the background run-bugfix.sh process
|
|
19
|
+
# bugfix-state/pipeline-daemon.log - Consolidated stdout+stderr
|
|
20
|
+
# ============================================================
|
|
21
|
+
|
|
22
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
23
|
+
STATE_DIR="$SCRIPT_DIR/bugfix-state"
|
|
24
|
+
PID_FILE="$STATE_DIR/.pipeline.pid"
|
|
25
|
+
LOG_FILE="$STATE_DIR/pipeline-daemon.log"
|
|
26
|
+
RUN_SCRIPT="$SCRIPT_DIR/run-bugfix.sh"
|
|
27
|
+
|
|
28
|
+
# Colors
|
|
29
|
+
RED='\033[0;31m'
|
|
30
|
+
GREEN='\033[0;32m'
|
|
31
|
+
YELLOW='\033[1;33m'
|
|
32
|
+
BLUE='\033[0;34m'
|
|
33
|
+
BOLD='\033[1m'
|
|
34
|
+
NC='\033[0m'
|
|
35
|
+
|
|
36
|
+
log_info() { echo -e "${BLUE}[INFO]${NC} $*" >&2; }
|
|
37
|
+
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*" >&2; }
|
|
38
|
+
log_error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
|
|
39
|
+
log_success() { echo -e "${GREEN}[OK]${NC} $*" >&2; }
|
|
40
|
+
|
|
41
|
+
# ============================================================
|
|
42
|
+
# Helpers
|
|
43
|
+
# ============================================================
|
|
44
|
+
|
|
45
|
+
is_running() {
|
|
46
|
+
if [[ ! -f "$PID_FILE" ]]; then
|
|
47
|
+
return 1
|
|
48
|
+
fi
|
|
49
|
+
local pid
|
|
50
|
+
pid=$(cat "$PID_FILE" 2>/dev/null) || return 1
|
|
51
|
+
if [[ -z "$pid" ]]; then
|
|
52
|
+
return 1
|
|
53
|
+
fi
|
|
54
|
+
if kill -0 "$pid" 2>/dev/null; then
|
|
55
|
+
return 0
|
|
56
|
+
else
|
|
57
|
+
return 1
|
|
58
|
+
fi
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get_pid() {
|
|
62
|
+
if [[ -f "$PID_FILE" ]]; then
|
|
63
|
+
cat "$PID_FILE" 2>/dev/null || echo ""
|
|
64
|
+
else
|
|
65
|
+
echo ""
|
|
66
|
+
fi
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
clean_stale_pid() {
|
|
70
|
+
if [[ -f "$PID_FILE" ]]; then
|
|
71
|
+
local pid
|
|
72
|
+
pid=$(get_pid)
|
|
73
|
+
if [[ -n "$pid" ]] && ! kill -0 "$pid" 2>/dev/null; then
|
|
74
|
+
rm -f "$PID_FILE"
|
|
75
|
+
log_warn "Cleaned stale PID file (process $pid no longer running)"
|
|
76
|
+
fi
|
|
77
|
+
fi
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# ============================================================
|
|
81
|
+
# start
|
|
82
|
+
# ============================================================
|
|
83
|
+
|
|
84
|
+
cmd_start() {
|
|
85
|
+
local bug_list=""
|
|
86
|
+
local env_overrides=""
|
|
87
|
+
|
|
88
|
+
while [[ $# -gt 0 ]]; do
|
|
89
|
+
case "$1" in
|
|
90
|
+
--env) shift; env_overrides="${1:-}"; shift ;;
|
|
91
|
+
*) bug_list="$1"; shift ;;
|
|
92
|
+
esac
|
|
93
|
+
done
|
|
94
|
+
|
|
95
|
+
if [[ -z "$bug_list" ]]; then
|
|
96
|
+
bug_list="bug-fix-list.json"
|
|
97
|
+
fi
|
|
98
|
+
if [[ ! "$bug_list" = /* ]]; then
|
|
99
|
+
bug_list="$(cd "$(dirname "$bug_list")" 2>/dev/null && pwd)/$(basename "$bug_list")"
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
if [[ ! -f "$bug_list" ]]; then
|
|
103
|
+
log_error "Bug fix list not found: $bug_list"
|
|
104
|
+
log_error "Run the bug-planner skill first to generate bug-fix-list.json"
|
|
105
|
+
exit 2
|
|
106
|
+
fi
|
|
107
|
+
|
|
108
|
+
if [[ ! -x "$RUN_SCRIPT" ]]; then
|
|
109
|
+
log_error "run-bugfix.sh not found or not executable: $RUN_SCRIPT"
|
|
110
|
+
exit 2
|
|
111
|
+
fi
|
|
112
|
+
|
|
113
|
+
clean_stale_pid
|
|
114
|
+
|
|
115
|
+
if is_running; then
|
|
116
|
+
local pid
|
|
117
|
+
pid=$(get_pid)
|
|
118
|
+
log_error "Bugfix pipeline is already running (PID: $pid)"
|
|
119
|
+
log_error "Use './launch-bugfix-daemon.sh stop' first, or './launch-bugfix-daemon.sh restart'"
|
|
120
|
+
exit 1
|
|
121
|
+
fi
|
|
122
|
+
|
|
123
|
+
mkdir -p "$STATE_DIR"
|
|
124
|
+
|
|
125
|
+
local env_cmd=""
|
|
126
|
+
if [[ -n "$env_overrides" ]]; then
|
|
127
|
+
env_cmd="env $env_overrides"
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
local start_time
|
|
131
|
+
start_time=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
|
|
132
|
+
|
|
133
|
+
log_info "Launching bugfix pipeline..."
|
|
134
|
+
log_info "Bug fix list: $bug_list"
|
|
135
|
+
log_info "Log file: $LOG_FILE"
|
|
136
|
+
|
|
137
|
+
{
|
|
138
|
+
echo ""
|
|
139
|
+
echo "================================================================"
|
|
140
|
+
echo " Bugfix Pipeline Daemon Started: $start_time"
|
|
141
|
+
echo " Bug fix list: $bug_list"
|
|
142
|
+
if [[ -n "$env_overrides" ]]; then
|
|
143
|
+
echo " Environment: $env_overrides"
|
|
144
|
+
fi
|
|
145
|
+
echo "================================================================"
|
|
146
|
+
echo ""
|
|
147
|
+
} >> "$LOG_FILE"
|
|
148
|
+
|
|
149
|
+
if [[ -n "$env_cmd" ]]; then
|
|
150
|
+
nohup $env_cmd "$RUN_SCRIPT" run "$bug_list" >> "$LOG_FILE" 2>&1 &
|
|
151
|
+
else
|
|
152
|
+
nohup "$RUN_SCRIPT" run "$bug_list" >> "$LOG_FILE" 2>&1 &
|
|
153
|
+
fi
|
|
154
|
+
local pipeline_pid=$!
|
|
155
|
+
disown "$pipeline_pid" 2>/dev/null || true
|
|
156
|
+
|
|
157
|
+
echo "$pipeline_pid" > "$PID_FILE"
|
|
158
|
+
|
|
159
|
+
python3 -c "
|
|
160
|
+
import json
|
|
161
|
+
from datetime import datetime
|
|
162
|
+
data = {
|
|
163
|
+
'pid': $pipeline_pid,
|
|
164
|
+
'pipeline_type': 'bugfix',
|
|
165
|
+
'started_at': '$start_time',
|
|
166
|
+
'bug_list': '$bug_list',
|
|
167
|
+
'env_overrides': '$env_overrides',
|
|
168
|
+
'log_file': '$LOG_FILE'
|
|
169
|
+
}
|
|
170
|
+
with open('$STATE_DIR/.pipeline-meta.json', 'w') as f:
|
|
171
|
+
json.dump(data, f, indent=2)
|
|
172
|
+
" 2>/dev/null || true
|
|
173
|
+
|
|
174
|
+
sleep 2
|
|
175
|
+
if is_running; then
|
|
176
|
+
log_success "Bugfix pipeline started successfully (PID: $pipeline_pid)"
|
|
177
|
+
log_info "Monitor logs: ./launch-bugfix-daemon.sh logs --follow"
|
|
178
|
+
log_info "Check status: ./launch-bugfix-daemon.sh status"
|
|
179
|
+
echo "{\"success\": true, \"pid\": $pipeline_pid, \"log_file\": \"$LOG_FILE\", \"started_at\": \"$start_time\"}"
|
|
180
|
+
else
|
|
181
|
+
log_error "Bugfix pipeline process died immediately after launch"
|
|
182
|
+
log_error "Check log for errors: tail -20 $LOG_FILE"
|
|
183
|
+
rm -f "$PID_FILE"
|
|
184
|
+
exit 1
|
|
185
|
+
fi
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
# ============================================================
|
|
189
|
+
# stop
|
|
190
|
+
# ============================================================
|
|
191
|
+
|
|
192
|
+
cmd_stop() {
|
|
193
|
+
if [[ ! -f "$PID_FILE" ]]; then
|
|
194
|
+
log_info "Bugfix pipeline is not running (no PID file)"
|
|
195
|
+
echo '{"success": true, "message": "not running"}'
|
|
196
|
+
return 0
|
|
197
|
+
fi
|
|
198
|
+
|
|
199
|
+
local pid
|
|
200
|
+
pid=$(get_pid)
|
|
201
|
+
|
|
202
|
+
if [[ -z "$pid" ]]; then
|
|
203
|
+
log_info "Bugfix pipeline is not running (empty PID file)"
|
|
204
|
+
rm -f "$PID_FILE"
|
|
205
|
+
echo '{"success": true, "message": "not running"}'
|
|
206
|
+
return 0
|
|
207
|
+
fi
|
|
208
|
+
|
|
209
|
+
if ! kill -0 "$pid" 2>/dev/null; then
|
|
210
|
+
log_info "Bugfix pipeline is not running (process $pid already exited)"
|
|
211
|
+
rm -f "$PID_FILE"
|
|
212
|
+
echo '{"success": true, "message": "already exited"}'
|
|
213
|
+
return 0
|
|
214
|
+
fi
|
|
215
|
+
|
|
216
|
+
log_info "Stopping bugfix pipeline (PID: $pid)..."
|
|
217
|
+
kill -TERM "$pid" 2>/dev/null || true
|
|
218
|
+
|
|
219
|
+
local waited=0
|
|
220
|
+
while [[ $waited -lt 30 ]]; do
|
|
221
|
+
if ! kill -0 "$pid" 2>/dev/null; then
|
|
222
|
+
break
|
|
223
|
+
fi
|
|
224
|
+
sleep 1
|
|
225
|
+
waited=$((waited + 1))
|
|
226
|
+
done
|
|
227
|
+
|
|
228
|
+
if kill -0 "$pid" 2>/dev/null; then
|
|
229
|
+
log_warn "Process did not exit after 30s, sending SIGKILL..."
|
|
230
|
+
kill -9 "$pid" 2>/dev/null || true
|
|
231
|
+
sleep 1
|
|
232
|
+
fi
|
|
233
|
+
|
|
234
|
+
rm -f "$PID_FILE"
|
|
235
|
+
|
|
236
|
+
if ! kill -0 "$pid" 2>/dev/null; then
|
|
237
|
+
log_success "Bugfix pipeline stopped"
|
|
238
|
+
echo "{\"success\": true, \"pid\": $pid, \"message\": \"stopped\"}"
|
|
239
|
+
else
|
|
240
|
+
log_error "Failed to stop bugfix pipeline (PID: $pid)"
|
|
241
|
+
echo "{\"success\": false, \"pid\": $pid, \"message\": \"failed to stop\"}"
|
|
242
|
+
exit 1
|
|
243
|
+
fi
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
# ============================================================
|
|
247
|
+
# status
|
|
248
|
+
# ============================================================
|
|
249
|
+
|
|
250
|
+
cmd_status() {
|
|
251
|
+
clean_stale_pid
|
|
252
|
+
|
|
253
|
+
if ! is_running; then
|
|
254
|
+
log_info "Bugfix pipeline is not running"
|
|
255
|
+
|
|
256
|
+
if [[ -f "$STATE_DIR/.pipeline-meta.json" ]]; then
|
|
257
|
+
local last_bug_list
|
|
258
|
+
last_bug_list=$(python3 -c "
|
|
259
|
+
import json
|
|
260
|
+
with open('$STATE_DIR/.pipeline-meta.json') as f:
|
|
261
|
+
print(json.load(f).get('bug_list', ''))
|
|
262
|
+
" 2>/dev/null || echo "")
|
|
263
|
+
|
|
264
|
+
if [[ -n "$last_bug_list" && -f "$last_bug_list" ]]; then
|
|
265
|
+
echo "" >&2
|
|
266
|
+
log_info "Last run bug fix progress:"
|
|
267
|
+
python3 "$SCRIPT_DIR/scripts/update-bug-status.py" \
|
|
268
|
+
--bug-list "$last_bug_list" \
|
|
269
|
+
--state-dir "$STATE_DIR" \
|
|
270
|
+
--action status >&2 2>/dev/null || true
|
|
271
|
+
echo "" >&2
|
|
272
|
+
fi
|
|
273
|
+
fi
|
|
274
|
+
|
|
275
|
+
echo '{"running": false}'
|
|
276
|
+
return 1
|
|
277
|
+
fi
|
|
278
|
+
|
|
279
|
+
local pid
|
|
280
|
+
pid=$(get_pid)
|
|
281
|
+
|
|
282
|
+
local started_at=""
|
|
283
|
+
local bug_list_path=""
|
|
284
|
+
if [[ -f "$STATE_DIR/.pipeline-meta.json" ]]; then
|
|
285
|
+
started_at=$(python3 -c "
|
|
286
|
+
import json
|
|
287
|
+
with open('$STATE_DIR/.pipeline-meta.json') as f:
|
|
288
|
+
print(json.load(f).get('started_at', ''))
|
|
289
|
+
" 2>/dev/null || echo "")
|
|
290
|
+
bug_list_path=$(python3 -c "
|
|
291
|
+
import json
|
|
292
|
+
with open('$STATE_DIR/.pipeline-meta.json') as f:
|
|
293
|
+
print(json.load(f).get('bug_list', ''))
|
|
294
|
+
" 2>/dev/null || echo "")
|
|
295
|
+
fi
|
|
296
|
+
|
|
297
|
+
log_success "Bugfix pipeline is running (PID: $pid)"
|
|
298
|
+
if [[ -n "$started_at" ]]; then
|
|
299
|
+
log_info "Started at: $started_at"
|
|
300
|
+
fi
|
|
301
|
+
log_info "Log file: $LOG_FILE"
|
|
302
|
+
|
|
303
|
+
if [[ -n "$bug_list_path" && -f "$bug_list_path" ]]; then
|
|
304
|
+
echo "" >&2
|
|
305
|
+
python3 "$SCRIPT_DIR/scripts/update-bug-status.py" \
|
|
306
|
+
--bug-list "$bug_list_path" \
|
|
307
|
+
--state-dir "$STATE_DIR" \
|
|
308
|
+
--action status >&2 2>/dev/null || true
|
|
309
|
+
echo "" >&2
|
|
310
|
+
fi
|
|
311
|
+
|
|
312
|
+
if [[ -f "$LOG_FILE" ]]; then
|
|
313
|
+
log_info "--- Last 5 log lines ---"
|
|
314
|
+
tail -5 "$LOG_FILE" >&2 || true
|
|
315
|
+
echo "" >&2
|
|
316
|
+
fi
|
|
317
|
+
|
|
318
|
+
local progress_json=""
|
|
319
|
+
if [[ -n "$bug_list_path" && -f "$bug_list_path" ]]; then
|
|
320
|
+
progress_json=$(python3 -c "
|
|
321
|
+
import json, os
|
|
322
|
+
bl = json.load(open('$bug_list_path'))
|
|
323
|
+
bugs = bl.get('bugs', [])
|
|
324
|
+
total = len(bugs)
|
|
325
|
+
counts = {'completed': 0, 'in_progress': 0, 'failed': 0, 'pending': 0, 'needs_info': 0}
|
|
326
|
+
for bug in bugs:
|
|
327
|
+
bid = bug.get('id', '')
|
|
328
|
+
sp = os.path.join('$STATE_DIR', 'bugs', bid, 'status.json')
|
|
329
|
+
if os.path.isfile(sp):
|
|
330
|
+
fs = json.load(open(sp))
|
|
331
|
+
st = fs.get('status', 'pending')
|
|
332
|
+
else:
|
|
333
|
+
st = 'pending'
|
|
334
|
+
if st in counts:
|
|
335
|
+
counts[st] += 1
|
|
336
|
+
else:
|
|
337
|
+
counts['pending'] += 1
|
|
338
|
+
pct = round(counts['completed'] / total * 100, 1) if total > 0 else 0
|
|
339
|
+
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}))
|
|
340
|
+
" 2>/dev/null || echo "")
|
|
341
|
+
fi
|
|
342
|
+
|
|
343
|
+
if [[ -n "$progress_json" ]]; then
|
|
344
|
+
echo "{\"running\": true, \"pid\": $pid, \"pipeline_type\": \"bugfix\", \"log_file\": \"$LOG_FILE\", \"started_at\": \"$started_at\", \"bug_list\": \"$bug_list_path\", \"progress\": $progress_json}"
|
|
345
|
+
else
|
|
346
|
+
echo "{\"running\": true, \"pid\": $pid, \"pipeline_type\": \"bugfix\", \"log_file\": \"$LOG_FILE\", \"started_at\": \"$started_at\", \"bug_list\": \"$bug_list_path\"}"
|
|
347
|
+
fi
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
# ============================================================
|
|
351
|
+
# logs
|
|
352
|
+
# ============================================================
|
|
353
|
+
|
|
354
|
+
cmd_logs() {
|
|
355
|
+
local lines=50
|
|
356
|
+
local follow=false
|
|
357
|
+
|
|
358
|
+
while [[ $# -gt 0 ]]; do
|
|
359
|
+
case "$1" in
|
|
360
|
+
--lines|-n) shift; lines="${1:-50}"; shift ;;
|
|
361
|
+
--follow|-f) follow=true; shift ;;
|
|
362
|
+
*) log_error "Unknown option: $1"; exit 1 ;;
|
|
363
|
+
esac
|
|
364
|
+
done
|
|
365
|
+
|
|
366
|
+
if [[ ! -f "$LOG_FILE" ]]; then
|
|
367
|
+
log_info "No log file found at $LOG_FILE"
|
|
368
|
+
exit 0
|
|
369
|
+
fi
|
|
370
|
+
|
|
371
|
+
if [[ "$follow" == true ]]; then
|
|
372
|
+
log_info "Following $LOG_FILE (Ctrl+C to stop)..."
|
|
373
|
+
echo "" >&2
|
|
374
|
+
tail -f "$LOG_FILE"
|
|
375
|
+
else
|
|
376
|
+
tail -"$lines" "$LOG_FILE"
|
|
377
|
+
fi
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
# ============================================================
|
|
381
|
+
# restart
|
|
382
|
+
# ============================================================
|
|
383
|
+
|
|
384
|
+
cmd_restart() {
|
|
385
|
+
cmd_stop 2>/dev/null || true
|
|
386
|
+
sleep 1
|
|
387
|
+
cmd_start "$@"
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
# ============================================================
|
|
391
|
+
# Entry point
|
|
392
|
+
# ============================================================
|
|
393
|
+
|
|
394
|
+
show_help() {
|
|
395
|
+
cat <<'HELP'
|
|
396
|
+
Usage: launch-bugfix-daemon.sh <command> [options]
|
|
397
|
+
|
|
398
|
+
Commands:
|
|
399
|
+
start [bug-fix-list.json] [--env "K=V ..."] Start bugfix pipeline in background
|
|
400
|
+
stop Gracefully stop pipeline
|
|
401
|
+
status Check if pipeline is running
|
|
402
|
+
logs [--lines N] [--follow] View pipeline logs
|
|
403
|
+
restart [bug-fix-list.json] [--env "K=V ..."] Stop + start pipeline
|
|
404
|
+
help Show this help
|
|
405
|
+
|
|
406
|
+
Examples:
|
|
407
|
+
./launch-bugfix-daemon.sh start # Start with default bug-fix-list.json
|
|
408
|
+
./launch-bugfix-daemon.sh start my-bugs.json # Start with custom bug list
|
|
409
|
+
./launch-bugfix-daemon.sh start --env "MAX_RETRIES=5"
|
|
410
|
+
./launch-bugfix-daemon.sh status # Check if running (JSON on stdout)
|
|
411
|
+
./launch-bugfix-daemon.sh logs --follow # Live log tailing
|
|
412
|
+
./launch-bugfix-daemon.sh stop # Graceful shutdown
|
|
413
|
+
./launch-bugfix-daemon.sh restart # Stop + start
|
|
414
|
+
HELP
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
case "${1:-help}" in
|
|
418
|
+
start) shift; cmd_start "$@" ;;
|
|
419
|
+
stop) cmd_stop ;;
|
|
420
|
+
status) cmd_status ;;
|
|
421
|
+
logs|log) shift; cmd_logs "$@" ;;
|
|
422
|
+
restart) shift; cmd_restart "$@" ;;
|
|
423
|
+
help|--help|-h) show_help ;;
|
|
424
|
+
*) log_error "Unknown command: $1"; echo "" >&2; show_help; exit 1 ;;
|
|
425
|
+
esac
|