prizmkit 1.1.191 → 1.1.193
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 +3 -3
- package/bundled/adapters/antigravity/skill-adapter.js +13 -4
- package/bundled/adapters/codex/skill-adapter.js +28 -8
- package/bundled/adapters/cursor/skill-adapter.js +13 -4
- package/bundled/adapters/pi/skill-adapter.js +28 -7
- package/bundled/dev-pipeline/.env.example +4 -12
- package/bundled/dev-pipeline/README.md +28 -44
- package/bundled/dev-pipeline/assets/feature-list-example.json +0 -1
- package/bundled/dev-pipeline/assets/skill-subagent-integration.md +6 -6
- package/bundled/dev-pipeline/prizmkit_runtime/atomic_io.py +48 -0
- package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +66 -23
- package/bundled/dev-pipeline/prizmkit_runtime/cli.py +10 -7
- package/bundled/dev-pipeline/prizmkit_runtime/commands.py +2 -21
- package/bundled/dev-pipeline/prizmkit_runtime/config.py +48 -78
- package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +127 -67
- package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +158 -462
- package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +102 -50
- package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +1 -25
- package/bundled/dev-pipeline/prizmkit_runtime/paths.py +0 -6
- package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +47 -21
- package/bundled/dev-pipeline/prizmkit_runtime/processes.py +217 -156
- package/bundled/dev-pipeline/prizmkit_runtime/reset.py +39 -27
- package/bundled/dev-pipeline/prizmkit_runtime/reset_preserve.py +34 -174
- package/bundled/dev-pipeline/prizmkit_runtime/results.py +25 -0
- package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +133 -110
- package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +15 -5
- package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +1 -95
- package/bundled/dev-pipeline/prizmkit_runtime/runner_prompts.py +0 -2
- package/bundled/dev-pipeline/prizmkit_runtime/runner_status.py +7 -2
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +540 -262
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +175 -135
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_helper.py +90 -9
- package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +214 -133
- package/bundled/dev-pipeline/prizmkit_runtime/status.py +1 -3
- package/bundled/dev-pipeline/prizmkit_runtime/stream_progress.py +2783 -0
- package/bundled/dev-pipeline/prizmkit_runtime/task_checkout.py +27 -102
- package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +58 -4
- package/bundled/dev-pipeline/scripts/check-session-status.py +56 -20
- package/bundled/dev-pipeline/scripts/continuation.py +8 -7
- package/bundled/dev-pipeline/scripts/detect-stuck.py +47 -33
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +13 -16
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +20 -10
- package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +10 -7
- package/bundled/dev-pipeline/scripts/init-change-artifact.py +25 -4
- package/bundled/dev-pipeline/scripts/init-pipeline.py +14 -69
- package/bundled/dev-pipeline/scripts/parse-stream-progress.py +31 -2616
- package/bundled/dev-pipeline/scripts/patch-completion-notes.py +4 -24
- package/bundled/dev-pipeline/scripts/prompt_framework.py +85 -20
- package/bundled/dev-pipeline/scripts/status_common.py +591 -0
- package/bundled/dev-pipeline/scripts/update-bug-status.py +85 -463
- package/bundled/dev-pipeline/scripts/update-checkpoint.py +254 -65
- package/bundled/dev-pipeline/scripts/update-feature-status.py +76 -509
- package/bundled/dev-pipeline/scripts/utils.py +5 -12
- package/bundled/dev-pipeline/templates/bootstrap-tier3.md +5 -5
- package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +7 -0
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +7 -7
- package/bundled/dev-pipeline/templates/sections/artifact-manifest.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-manual-verification.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +2 -1
- package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification-auto.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification-opencli.md +2 -2
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification.md +2 -2
- package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +2 -1
- package/bundled/dev-pipeline/templates/sections/phase-review-full.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +3 -6
- package/bundled/dev-pipeline/templates/session-status-schema.json +2 -5
- package/bundled/skills/_metadata.json +9 -63
- package/bundled/skills/app-planner/SKILL.md +32 -303
- package/bundled/skills/app-planner/references/app-design-guide.md +0 -4
- package/bundled/skills/app-planner/references/generated-plan-review.md +2 -1
- package/bundled/skills/app-planner/references/project-brief-guide.md +14 -0
- package/bundled/skills/app-planner/references/project-conventions-discovery.md +4 -6
- package/bundled/skills/app-planner/references/project-state-detection.md +2 -3
- package/bundled/skills/bug-fix-workflow/SKILL.md +1 -2
- package/bundled/skills/bug-fix-workflow/references/bug-diagnosis.md +4 -7
- package/bundled/skills/bug-planner/SKILL.md +54 -435
- package/bundled/skills/bug-planner/references/generated-plan-review.md +3 -2
- package/bundled/skills/bug-planner/references/input-formats.md +32 -0
- package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +4 -6
- package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +4 -28
- package/bundled/skills/feature-pipeline-launcher/SKILL.md +4 -6
- package/bundled/skills/feature-pipeline-launcher/references/configuration.md +4 -28
- package/bundled/skills/feature-planner/SKILL.md +60 -439
- package/bundled/skills/feature-planner/assets/planning-guide.md +1 -1
- package/bundled/skills/feature-planner/references/completeness-review.md +34 -0
- package/bundled/skills/feature-planner/references/decomposition-patterns.md +2 -2
- package/bundled/skills/feature-planner/references/error-recovery.md +1 -1
- package/bundled/skills/feature-planner/references/generated-plan-review.md +3 -2
- package/bundled/skills/feature-planner/references/incremental-feature-planning.md +3 -1
- package/bundled/skills/feature-workflow/SKILL.md +1 -2
- package/bundled/skills/prizmkit/SKILL.md +7 -1
- package/bundled/skills/prizmkit-code-review/SKILL.md +14 -6
- package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +7 -4
- package/bundled/skills/prizmkit-code-review/references/review-report-template.md +16 -0
- package/bundled/skills/prizmkit-code-review/scripts/render_review_report.py +58 -20
- package/bundled/skills/prizmkit-implement/SKILL.md +1 -1
- package/bundled/skills/prizmkit-init/SKILL.md +24 -127
- package/bundled/skills/prizmkit-init/assets/project-brief-template.md +3 -3
- package/bundled/skills/prizmkit-plan/SKILL.md +6 -8
- package/bundled/skills/prizmkit-plan/references/clarify-guide.md +1 -1
- package/bundled/skills/prizmkit-plan/references/independent-plan-review.md +5 -2
- package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +6 -5
- package/bundled/skills/prizmkit-prizm-docs/SKILL.md +1 -13
- package/bundled/skills/prizmkit-prizm-docs/references/op-update.md +1 -1
- package/bundled/skills/prizmkit-retrospective/SKILL.md +6 -4
- package/bundled/skills/prizmkit-test/SKILL.md +25 -133
- package/bundled/skills/prizmkit-test/references/independent-test-review.md +5 -2
- package/bundled/skills/prizmkit-test/references/test-coverage-model.md +6 -0
- package/bundled/skills/prizmkit-workflow/SKILL.md +2 -3
- package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +4 -3
- package/bundled/skills/recovery-workflow/SKILL.md +7 -7
- package/bundled/skills/recovery-workflow/evals/evals.json +1 -1
- package/bundled/skills/recovery-workflow/references/detection.md +1 -3
- package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +0 -6
- package/bundled/templates/project-memory-template.md +1 -2
- package/package.json +1 -1
- package/src/scaffold.js +28 -7
- package/bundled/dev-pipeline/SCHEMA_ANALYSIS.md +0 -53
- package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +0 -649
- package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +0 -463
- package/bundled/dev-pipeline/scripts/update-refactor-status.py +0 -1512
- package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +0 -240
- package/bundled/dev-pipeline/templates/refactor-list-schema.json +0 -266
- package/bundled/dev-pipeline/templates/sections/refactor-critical-paths.md +0 -15
- package/bundled/dev-pipeline/templates/sections/refactor-mission.md +0 -9
- package/bundled/dev-pipeline/templates/sections/refactor-phase-commit-report.md +0 -24
- package/bundled/dev-pipeline/templates/sections/refactor-phase-implement.md +0 -16
- package/bundled/dev-pipeline/templates/sections/refactor-phase-init.md +0 -9
- package/bundled/dev-pipeline/templates/sections/refactor-phase-plan.md +0 -22
- package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +0 -19
- package/bundled/dev-pipeline/templates/sections/refactor-phase-test.md +0 -24
- package/bundled/dev-pipeline/templates/sections/refactor-reminders.md +0 -12
- package/bundled/dev-pipeline/templates/sections/refactor-session-context.md +0 -6
- package/bundled/dev-pipeline/templates/sections/refactor-task-contract.md +0 -52
- package/bundled/dev-pipeline/tests/conftest.py +0 -29
- package/bundled/dev-pipeline/tests/live_ai_cli_log_smoke.py +0 -208
- package/bundled/dev-pipeline/tests/test_auto_skip.py +0 -1871
- package/bundled/dev-pipeline/tests/test_checkpoint_state.py +0 -1314
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +0 -1712
- package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +0 -627
- package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +0 -478
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +0 -5641
- package/bundled/dev-pipeline/tests/test_recovery_workflow.py +0 -322
- package/bundled/dev-pipeline/tests/test_repository_bootstrap.py +0 -252
- package/bundled/dev-pipeline/tests/test_reset_modes.py +0 -1208
- package/bundled/dev-pipeline/tests/test_reset_preserve.py +0 -957
- package/bundled/dev-pipeline/tests/test_runtime_commit.py +0 -1113
- package/bundled/dev-pipeline/tests/test_runtime_helper.py +0 -303
- package/bundled/dev-pipeline/tests/test_unified_cli.py +0 -5504
- package/bundled/dev-pipeline/tests/test_utils.py +0 -170
- package/bundled/skills/feature-planner/assets/evaluation-guide.md +0 -44
- package/bundled/skills/refactor-pipeline-launcher/SKILL.md +0 -219
- package/bundled/skills/refactor-pipeline-launcher/references/configuration.md +0 -78
- package/bundled/skills/refactor-planner/SKILL.md +0 -467
- package/bundled/skills/refactor-planner/assets/planning-guide.md +0 -291
- package/bundled/skills/refactor-planner/references/behavior-preservation.md +0 -187
- package/bundled/skills/refactor-planner/references/error-recovery.md +0 -45
- package/bundled/skills/refactor-planner/references/fast-path.md +0 -59
- package/bundled/skills/refactor-planner/references/generated-plan-review.md +0 -107
- package/bundled/skills/refactor-planner/references/planning-phases.md +0 -172
- package/bundled/skills/refactor-planner/references/refactor-scoping-guide.md +0 -230
- package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +0 -1120
- package/bundled/skills/refactor-workflow/SKILL.md +0 -205
|
@@ -3,13 +3,12 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import json
|
|
6
|
-
import os
|
|
7
|
-
import shutil
|
|
8
6
|
import threading
|
|
9
7
|
import time
|
|
10
|
-
from dataclasses import dataclass
|
|
8
|
+
from dataclasses import dataclass
|
|
11
9
|
from pathlib import Path
|
|
12
10
|
|
|
11
|
+
from .atomic_io import write_json_atomic
|
|
13
12
|
from .processes import ProcessHandle, is_process_running, terminate_process_tree
|
|
14
13
|
|
|
15
14
|
|
|
@@ -25,6 +24,7 @@ class HeartbeatConfig:
|
|
|
25
24
|
stale_after_seconds: float = 300
|
|
26
25
|
kill_after_seconds: float = 600
|
|
27
26
|
grace_seconds: float = 10
|
|
27
|
+
active_tool_max_silence_seconds: float | None = None
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
@dataclass(frozen=True)
|
|
@@ -38,6 +38,8 @@ class HeartbeatState:
|
|
|
38
38
|
log_size: int = 0
|
|
39
39
|
progress_signature: str = ""
|
|
40
40
|
child_activity_signature: str = ""
|
|
41
|
+
tool_silent_since_epoch: float | None = None
|
|
42
|
+
fatal_error_code: str = ""
|
|
41
43
|
|
|
42
44
|
|
|
43
45
|
@dataclass(frozen=True)
|
|
@@ -59,16 +61,22 @@ def _file_size(path: Path | None) -> int:
|
|
|
59
61
|
return 0
|
|
60
62
|
|
|
61
63
|
|
|
62
|
-
def
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
def _read_progress_observation(path: Path | None) -> tuple[str, str, bool, str] | None:
|
|
65
|
+
"""Read progress.json once; return None on transient read/decode failure."""
|
|
66
|
+
if path is None:
|
|
67
|
+
return "", "", False, ""
|
|
65
68
|
try:
|
|
69
|
+
if not path.is_file():
|
|
70
|
+
return "", "", False, ""
|
|
66
71
|
data = json.loads(path.read_text(encoding="utf-8"))
|
|
67
|
-
except (OSError, json.JSONDecodeError):
|
|
68
|
-
return
|
|
72
|
+
except (OSError, UnicodeDecodeError, json.JSONDecodeError):
|
|
73
|
+
return None
|
|
74
|
+
if not isinstance(data, dict):
|
|
75
|
+
return None
|
|
69
76
|
current_tool = data.get("current_tool")
|
|
70
77
|
tool_active = isinstance(current_tool, str) and bool(current_tool.strip())
|
|
71
78
|
child_signature = str(data.get("child_activity_signature") or "")
|
|
79
|
+
fatal_error_code = str(data.get("fatal_error_code") or "")
|
|
72
80
|
subagent_statistics = data.get("subagent_statistics")
|
|
73
81
|
if not isinstance(subagent_statistics, dict):
|
|
74
82
|
subagent_statistics = {}
|
|
@@ -81,12 +89,20 @@ def _progress_signature(path: Path | None) -> tuple[str, str, bool]:
|
|
|
81
89
|
int(subagent_statistics.get("spawned") or 0),
|
|
82
90
|
child_signature,
|
|
83
91
|
int(data.get("child_total_bytes") or 0),
|
|
84
|
-
|
|
92
|
+
fatal_error_code,
|
|
85
93
|
data.get("terminal_result_text") or "",
|
|
86
94
|
],
|
|
87
95
|
separators=(",", ":"),
|
|
88
96
|
)
|
|
89
|
-
return signature, child_signature, tool_active
|
|
97
|
+
return signature, child_signature, tool_active, fatal_error_code
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _effective_active_tool_ceiling(config: HeartbeatConfig) -> float | None:
|
|
101
|
+
if config.active_tool_max_silence_seconds is not None:
|
|
102
|
+
return max(0.0, float(config.active_tool_max_silence_seconds))
|
|
103
|
+
if config.kill_after_seconds > 0:
|
|
104
|
+
return max(float(config.kill_after_seconds) * 3.0, 1800.0)
|
|
105
|
+
return None
|
|
90
106
|
|
|
91
107
|
|
|
92
108
|
def observe_heartbeat_state(
|
|
@@ -96,20 +112,51 @@ def observe_heartbeat_state(
|
|
|
96
112
|
"""Observe log/progress activity and compute staleness."""
|
|
97
113
|
now = time.time()
|
|
98
114
|
log_size = _file_size(config.session_log)
|
|
99
|
-
|
|
115
|
+
obs = _read_progress_observation(config.progress_file)
|
|
116
|
+
if obs is None:
|
|
117
|
+
progress_signature = previous.progress_signature if previous else ""
|
|
118
|
+
child_signature = previous.child_activity_signature if previous else ""
|
|
119
|
+
tool_active = False
|
|
120
|
+
fatal_error_code = previous.fatal_error_code if previous else ""
|
|
121
|
+
else:
|
|
122
|
+
progress_signature, child_signature, tool_active, fatal_error_code = obs
|
|
123
|
+
|
|
100
124
|
prev_log_size = previous.log_size if previous else 0
|
|
101
|
-
|
|
125
|
+
real_progress = (
|
|
102
126
|
previous is None
|
|
103
127
|
or log_size > prev_log_size
|
|
104
128
|
or (progress_signature and progress_signature != previous.progress_signature)
|
|
105
129
|
or (child_signature and child_signature != previous.child_activity_signature)
|
|
106
|
-
or tool_active
|
|
107
130
|
)
|
|
131
|
+
|
|
132
|
+
tool_silent_since: float | None = None
|
|
133
|
+
tool_deferred = False
|
|
134
|
+
if real_progress:
|
|
135
|
+
tool_deferred = tool_active
|
|
136
|
+
if tool_active:
|
|
137
|
+
tool_silent_since = now
|
|
138
|
+
elif tool_active:
|
|
139
|
+
prior_since = previous.tool_silent_since_epoch if previous else None
|
|
140
|
+
tool_silent_since = (
|
|
141
|
+
prior_since
|
|
142
|
+
if prior_since is not None
|
|
143
|
+
else (previous.last_seen_epoch if previous and previous.last_seen_epoch is not None else now)
|
|
144
|
+
)
|
|
145
|
+
ceiling = _effective_active_tool_ceiling(config)
|
|
146
|
+
if ceiling is None or (now - tool_silent_since) < ceiling:
|
|
147
|
+
tool_deferred = True
|
|
148
|
+
|
|
149
|
+
progressed = real_progress or tool_deferred
|
|
108
150
|
if progressed:
|
|
109
151
|
last_seen_epoch = now
|
|
110
152
|
stale_seconds = 0.0
|
|
111
153
|
else:
|
|
112
|
-
|
|
154
|
+
if tool_active and tool_silent_since is not None:
|
|
155
|
+
last_seen_epoch = tool_silent_since
|
|
156
|
+
else:
|
|
157
|
+
last_seen_epoch = (
|
|
158
|
+
previous.last_seen_epoch if previous and previous.last_seen_epoch is not None else now
|
|
159
|
+
)
|
|
113
160
|
stale_seconds = max(0.0, now - last_seen_epoch)
|
|
114
161
|
stale = bool(config.stale_after_seconds > 0 and stale_seconds >= config.stale_after_seconds)
|
|
115
162
|
details = "progress" if progressed else "no progress"
|
|
@@ -121,6 +168,8 @@ def observe_heartbeat_state(
|
|
|
121
168
|
log_size=log_size,
|
|
122
169
|
progress_signature=progress_signature,
|
|
123
170
|
child_activity_signature=child_signature,
|
|
171
|
+
tool_silent_since_epoch=tool_silent_since,
|
|
172
|
+
fatal_error_code=fatal_error_code,
|
|
124
173
|
)
|
|
125
174
|
|
|
126
175
|
|
|
@@ -133,16 +182,6 @@ def _marker_number(value: float) -> int | float:
|
|
|
133
182
|
return int(normalized) if normalized.is_integer() else normalized
|
|
134
183
|
|
|
135
184
|
|
|
136
|
-
def _progress_fatal_error_code(path: Path | None) -> str:
|
|
137
|
-
if path is None or not path.is_file():
|
|
138
|
-
return ""
|
|
139
|
-
try:
|
|
140
|
-
data = json.loads(path.read_text(encoding="utf-8"))
|
|
141
|
-
except (OSError, json.JSONDecodeError):
|
|
142
|
-
return ""
|
|
143
|
-
return str(data.get("fatal_error_code") or "")
|
|
144
|
-
|
|
145
|
-
|
|
146
185
|
def write_stale_marker(
|
|
147
186
|
marker_dir: Path,
|
|
148
187
|
*,
|
|
@@ -151,7 +190,7 @@ def write_stale_marker(
|
|
|
151
190
|
threshold: float,
|
|
152
191
|
fatal_error_code: str | None = None,
|
|
153
192
|
) -> Path:
|
|
154
|
-
"""Write a stale/fatal marker compatible with
|
|
193
|
+
"""Write a stale/fatal marker compatible with expected artifact shape."""
|
|
155
194
|
marker_dir.mkdir(parents=True, exist_ok=True)
|
|
156
195
|
marker_path = marker_dir / "stale-kill.json"
|
|
157
196
|
payload = {
|
|
@@ -162,7 +201,7 @@ def write_stale_marker(
|
|
|
162
201
|
}
|
|
163
202
|
if fatal_error_code:
|
|
164
203
|
payload["fatal_error_code"] = fatal_error_code
|
|
165
|
-
marker_path
|
|
204
|
+
write_json_atomic(marker_path, payload, indent=None, sort_keys=True, ensure_ascii=True, fsync=False)
|
|
166
205
|
return marker_path
|
|
167
206
|
|
|
168
207
|
|
|
@@ -173,7 +212,7 @@ def write_fatal_marker(
|
|
|
173
212
|
stale_seconds: float,
|
|
174
213
|
threshold: float,
|
|
175
214
|
) -> tuple[Path, Path]:
|
|
176
|
-
"""Write
|
|
215
|
+
"""Write fatal-error and stale-kill marker files."""
|
|
177
216
|
marker_dir.mkdir(parents=True, exist_ok=True)
|
|
178
217
|
payload = {
|
|
179
218
|
"killed_at": _utc_marker_time(),
|
|
@@ -184,9 +223,8 @@ def write_fatal_marker(
|
|
|
184
223
|
}
|
|
185
224
|
fatal_path = marker_dir / "fatal-error.json"
|
|
186
225
|
stale_path = marker_dir / "stale-kill.json"
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
stale_path.write_text(encoded, encoding="utf-8")
|
|
226
|
+
write_json_atomic(fatal_path, payload, indent=None, sort_keys=True, ensure_ascii=True, fsync=False)
|
|
227
|
+
write_json_atomic(stale_path, payload, indent=None, sort_keys=True, ensure_ascii=True, fsync=False)
|
|
190
228
|
return fatal_path, stale_path
|
|
191
229
|
|
|
192
230
|
|
|
@@ -211,7 +249,15 @@ class HeartbeatMonitor:
|
|
|
211
249
|
if self._thread is not None:
|
|
212
250
|
return
|
|
213
251
|
self.config.heartbeat_file.parent.mkdir(parents=True, exist_ok=True)
|
|
214
|
-
|
|
252
|
+
write_json_atomic(
|
|
253
|
+
self.config.heartbeat_file,
|
|
254
|
+
{
|
|
255
|
+
"last_seen_epoch": time.time(),
|
|
256
|
+
"stale": False,
|
|
257
|
+
"stale_seconds": 0.0,
|
|
258
|
+
"details": "started",
|
|
259
|
+
},
|
|
260
|
+
)
|
|
215
261
|
self._thread = threading.Thread(target=self._run, name="prizmkit-heartbeat", daemon=True)
|
|
216
262
|
self._thread.start()
|
|
217
263
|
|
|
@@ -220,50 +266,56 @@ class HeartbeatMonitor:
|
|
|
220
266
|
if not is_process_running(self.handle):
|
|
221
267
|
break
|
|
222
268
|
self._state = observe_heartbeat_state(self.config, self._state)
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
269
|
+
write_json_atomic(
|
|
270
|
+
self.config.heartbeat_file,
|
|
271
|
+
{
|
|
272
|
+
"last_seen_epoch": self._state.last_seen_epoch,
|
|
273
|
+
"stale": self._state.stale,
|
|
274
|
+
"stale_seconds": self._state.stale_seconds,
|
|
275
|
+
"details": self._state.details,
|
|
276
|
+
},
|
|
277
|
+
indent=None,
|
|
278
|
+
sort_keys=True,
|
|
279
|
+
ensure_ascii=True,
|
|
280
|
+
fsync=False,
|
|
235
281
|
)
|
|
236
|
-
fatal_error_code =
|
|
282
|
+
fatal_error_code = self._state.fatal_error_code
|
|
237
283
|
if fatal_error_code:
|
|
238
|
-
marker_dir = self.config.marker_dir or (
|
|
284
|
+
marker_dir = self.config.marker_dir or (
|
|
285
|
+
self.config.session_log.parent if self.config.session_log else self.config.heartbeat_file.parent
|
|
286
|
+
)
|
|
239
287
|
_fatal_path, self._marker_path = write_fatal_marker(
|
|
240
288
|
marker_dir,
|
|
241
289
|
fatal_error_code=fatal_error_code,
|
|
242
290
|
stale_seconds=self._state.stale_seconds,
|
|
243
291
|
threshold=self.config.stale_after_seconds,
|
|
244
292
|
)
|
|
245
|
-
terminate_process_tree(self.handle, fatal_error_code, grace_seconds=self.config.grace_seconds)
|
|
246
293
|
self._killed = True
|
|
247
294
|
self._reason = fatal_error_code
|
|
295
|
+
terminate_process_tree(self.handle, fatal_error_code, grace_seconds=self.config.grace_seconds)
|
|
248
296
|
break
|
|
249
|
-
should_kill = bool(
|
|
297
|
+
should_kill = bool(
|
|
298
|
+
self.config.kill_after_seconds > 0 and self._state.stale_seconds >= self.config.kill_after_seconds
|
|
299
|
+
)
|
|
250
300
|
if should_kill:
|
|
251
|
-
marker_dir = self.config.marker_dir or (
|
|
301
|
+
marker_dir = self.config.marker_dir or (
|
|
302
|
+
self.config.session_log.parent if self.config.session_log else self.config.heartbeat_file.parent
|
|
303
|
+
)
|
|
252
304
|
self._marker_path = write_stale_marker(
|
|
253
305
|
marker_dir,
|
|
254
306
|
reason="stale_session",
|
|
255
307
|
stale_seconds=self._state.stale_seconds,
|
|
256
308
|
threshold=self.config.kill_after_seconds,
|
|
257
309
|
)
|
|
258
|
-
terminate_process_tree(self.handle, "stale_session", grace_seconds=self.config.grace_seconds)
|
|
259
310
|
self._killed = True
|
|
260
311
|
self._reason = "stale_session"
|
|
312
|
+
terminate_process_tree(self.handle, "stale_session", grace_seconds=self.config.grace_seconds)
|
|
261
313
|
break
|
|
262
314
|
|
|
263
315
|
def stop(self) -> HeartbeatStopResult:
|
|
264
316
|
self._stop_event.set()
|
|
265
317
|
if self._thread is not None:
|
|
266
|
-
self._thread.join(timeout=max(
|
|
318
|
+
self._thread.join(timeout=max(2.0, self.config.grace_seconds + 2.0))
|
|
267
319
|
return HeartbeatStopResult(
|
|
268
320
|
killed=self._killed,
|
|
269
321
|
reason=self._reason,
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
import os
|
|
6
|
-
import subprocess
|
|
7
|
-
import sys
|
|
8
5
|
from collections.abc import Mapping, Sequence
|
|
9
6
|
from dataclasses import dataclass, field
|
|
10
7
|
from pathlib import Path
|
|
@@ -16,23 +13,21 @@ UTILITY_ENTRYPOINTS = {
|
|
|
16
13
|
"detect-stuck": "scripts/detect-stuck.py",
|
|
17
14
|
"generate-bootstrap-prompt": "scripts/generate-bootstrap-prompt.py",
|
|
18
15
|
"generate-bugfix-prompt": "scripts/generate-bugfix-prompt.py",
|
|
19
|
-
"generate-refactor-prompt": "scripts/generate-refactor-prompt.py",
|
|
20
16
|
"init-bugfix-pipeline": "scripts/init-bugfix-pipeline.py",
|
|
21
17
|
"init-change-artifact": "scripts/init-change-artifact.py",
|
|
22
18
|
"init-pipeline": "scripts/init-pipeline.py",
|
|
23
|
-
"init-refactor-pipeline": "scripts/init-refactor-pipeline.py",
|
|
24
19
|
"parse-stream-progress": "scripts/parse-stream-progress.py",
|
|
25
20
|
"patch-completion-notes": "scripts/patch-completion-notes.py",
|
|
26
21
|
"prizmkit-runtime-helper": "scripts/prizmkit-runtime-helper.py",
|
|
27
22
|
"update-bug-status": "scripts/update-bug-status.py",
|
|
28
23
|
"update-checkpoint": "scripts/update-checkpoint.py",
|
|
29
24
|
"update-feature-status": "scripts/update-feature-status.py",
|
|
30
|
-
"update-refactor-status": "scripts/update-refactor-status.py",
|
|
31
25
|
}
|
|
32
26
|
|
|
33
27
|
UTILITY_LIBRARY_ONLY = {
|
|
34
28
|
"continuation.py": "shared continuation helpers imported by prompt generators",
|
|
35
29
|
"prompt_framework.py": "shared prompt rendering and checkpoint helpers imported by prompt generators",
|
|
30
|
+
"status_common.py": "shared status, continuation, and auto-skip helpers imported by status updaters",
|
|
36
31
|
"utils.py": "shared utility helpers imported by runtime scripts",
|
|
37
32
|
}
|
|
38
33
|
|
|
@@ -88,22 +83,3 @@ def describe_existing_entrypoint(
|
|
|
88
83
|
entrypoint_kind=kind,
|
|
89
84
|
entrypoint_name=name,
|
|
90
85
|
)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
def run_existing_entrypoint(invocation: ScriptInvocation) -> subprocess.CompletedProcess[str]:
|
|
94
|
-
"""Run a Python utility entrypoint through a standard-library subprocess bridge."""
|
|
95
|
-
process_env = None
|
|
96
|
-
if invocation.environment_overrides:
|
|
97
|
-
process_env = {**os.environ, **invocation.environment_overrides}
|
|
98
|
-
command = invocation.command_line()
|
|
99
|
-
if invocation.script_path.suffix == ".py":
|
|
100
|
-
command = (sys.executable, *command)
|
|
101
|
-
return subprocess.run(
|
|
102
|
-
command,
|
|
103
|
-
cwd=invocation.cwd,
|
|
104
|
-
env=process_env,
|
|
105
|
-
text=True,
|
|
106
|
-
stdout=subprocess.PIPE,
|
|
107
|
-
stderr=subprocess.PIPE,
|
|
108
|
-
check=False,
|
|
109
|
-
)
|
|
@@ -19,10 +19,8 @@ class RuntimePaths:
|
|
|
19
19
|
specs_dir: Path
|
|
20
20
|
feature_plan: Path
|
|
21
21
|
bugfix_plan: Path
|
|
22
|
-
refactor_plan: Path
|
|
23
22
|
feature_state_dir: Path
|
|
24
23
|
bugfix_state_dir: Path
|
|
25
|
-
refactor_state_dir: Path
|
|
26
24
|
layout: str
|
|
27
25
|
|
|
28
26
|
def path_values(self) -> tuple[Path, ...]:
|
|
@@ -37,10 +35,8 @@ class RuntimePaths:
|
|
|
37
35
|
self.specs_dir,
|
|
38
36
|
self.feature_plan,
|
|
39
37
|
self.bugfix_plan,
|
|
40
|
-
self.refactor_plan,
|
|
41
38
|
self.feature_state_dir,
|
|
42
39
|
self.bugfix_state_dir,
|
|
43
|
-
self.refactor_state_dir,
|
|
44
40
|
)
|
|
45
41
|
|
|
46
42
|
|
|
@@ -99,9 +95,7 @@ def resolve_runtime_paths(
|
|
|
99
95
|
specs_dir=specs_dir,
|
|
100
96
|
feature_plan=plans_dir / "feature-list.json",
|
|
101
97
|
bugfix_plan=plans_dir / "bug-fix-list.json",
|
|
102
|
-
refactor_plan=plans_dir / "refactor-list.json",
|
|
103
98
|
feature_state_dir=state_dir / "features",
|
|
104
99
|
bugfix_state_dir=state_dir / "bugfix",
|
|
105
|
-
refactor_state_dir=state_dir / "refactor",
|
|
106
100
|
layout=layout,
|
|
107
101
|
)
|
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import json
|
|
6
6
|
import os
|
|
7
|
+
import shlex
|
|
7
8
|
import shutil
|
|
8
9
|
from collections.abc import Mapping
|
|
9
10
|
from dataclasses import dataclass
|
|
@@ -14,7 +15,7 @@ PLATFORM_IDS = ("codebuddy", "claude", "codex", "pi", "cursor", "antigravity")
|
|
|
14
15
|
PLATFORM_INPUT_HELP = (
|
|
15
16
|
"codebuddy, claude, codex, pi, cursor, antigravity, a comma-separated list of those, or all"
|
|
16
17
|
)
|
|
17
|
-
|
|
18
|
+
CLI_BY_PLATFORM = {
|
|
18
19
|
"codebuddy": "cbc",
|
|
19
20
|
"claude": "claude",
|
|
20
21
|
"codex": "codex",
|
|
@@ -22,6 +23,24 @@ _CLI_BY_PLATFORM = {
|
|
|
22
23
|
"cursor": "agent",
|
|
23
24
|
"antigravity": "agy",
|
|
24
25
|
}
|
|
26
|
+
_CLI_BY_PLATFORM = CLI_BY_PLATFORM
|
|
27
|
+
INSTALLED_PLATFORM_ORDER = ("pi", "codex", "claude", "codebuddy", "cursor", "antigravity")
|
|
28
|
+
INSTALLED_SKILL_MARKERS = {
|
|
29
|
+
"pi": ".pi/skills/prizmkit/SKILL.md",
|
|
30
|
+
"codex": ".agents/skills/prizmkit/SKILL.md",
|
|
31
|
+
"claude": ".claude/commands/prizmkit.md",
|
|
32
|
+
"codebuddy": ".codebuddy/skills/prizmkit/SKILL.md",
|
|
33
|
+
"cursor": ".cursor/skills/prizmkit/SKILL.md",
|
|
34
|
+
"antigravity": ".agents/plugins/prizmkit/skills/prizmkit/SKILL.md",
|
|
35
|
+
}
|
|
36
|
+
INSTALLED_MARKER_DIRS = (
|
|
37
|
+
".codebuddy",
|
|
38
|
+
".claude",
|
|
39
|
+
".agents/skills",
|
|
40
|
+
".pi",
|
|
41
|
+
".cursor",
|
|
42
|
+
".agents/plugins/prizmkit",
|
|
43
|
+
)
|
|
25
44
|
|
|
26
45
|
|
|
27
46
|
@dataclass(frozen=True)
|
|
@@ -107,27 +126,30 @@ def read_json_object(path: str | Path) -> dict:
|
|
|
107
126
|
return data if isinstance(data, dict) else {}
|
|
108
127
|
|
|
109
128
|
|
|
110
|
-
def platform_from_command(command: object) -> str:
|
|
129
|
+
def platform_from_command(command: object, *, allow_substring: bool = True) -> str:
|
|
111
130
|
"""Map an AI CLI command/config value to a PrizmKit platform name."""
|
|
112
|
-
|
|
113
|
-
if not
|
|
131
|
+
raw = str(command or "").strip()
|
|
132
|
+
if not raw:
|
|
114
133
|
return ""
|
|
115
|
-
unquoted =
|
|
116
|
-
|
|
117
|
-
unquoted
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
134
|
+
unquoted = raw[1:-1] if len(raw) >= 2 and raw[0] == raw[-1] and raw[0] in "'\"" else raw
|
|
135
|
+
if len(unquoted) >= 3 and unquoted[1:3] in {":\\", ":/"} and unquoted.lower().endswith((".exe", ".cmd", ".bat")):
|
|
136
|
+
token = unquoted
|
|
137
|
+
else:
|
|
138
|
+
try:
|
|
139
|
+
tokens = shlex.split(raw)
|
|
140
|
+
token = tokens[0] if tokens else raw
|
|
141
|
+
except ValueError:
|
|
142
|
+
token = raw.split()[0].strip("'\"")
|
|
143
|
+
base = os.path.basename(token).replace("\\", "/").rsplit("/", 1)[-1].lower()
|
|
122
144
|
for suffix in (".exe", ".cmd", ".bat"):
|
|
123
145
|
if base.endswith(suffix):
|
|
124
146
|
base = base[: -len(suffix)]
|
|
125
147
|
break
|
|
126
|
-
if base in ("claude", "claude-code") or "claude" in base:
|
|
148
|
+
if base in ("claude", "claude-code") or (allow_substring and "claude" in base):
|
|
127
149
|
return "claude"
|
|
128
|
-
if base in ("codex", "openai-codex") or "codex" in base:
|
|
150
|
+
if base in ("codex", "openai-codex") or (allow_substring and "codex" in base):
|
|
129
151
|
return "codex"
|
|
130
|
-
if base in ("cbc", "codebuddy") or "codebuddy" in base:
|
|
152
|
+
if base in ("cbc", "codebuddy") or (allow_substring and "codebuddy" in base):
|
|
131
153
|
return "codebuddy"
|
|
132
154
|
if base == "pi":
|
|
133
155
|
return "pi"
|
|
@@ -200,7 +222,10 @@ def resolve_platform(project_root: str | Path, env: Mapping[str, str] | None = N
|
|
|
200
222
|
return PlatformResolution(explicit, "environment:PRIZMKIT_PLATFORM")
|
|
201
223
|
|
|
202
224
|
for env_name in ("AI_CLI", "CLAUDECODE", "CLAUDE_CODE", "CODEBUDDY_CLI"):
|
|
203
|
-
|
|
225
|
+
raw_env = environment.get(env_name, "")
|
|
226
|
+
if env_name in {"CLAUDECODE", "CLAUDE_CODE"} and str(raw_env).strip().lower() in {"1", "true", "yes"}:
|
|
227
|
+
return PlatformResolution("claude", f"environment:{env_name}")
|
|
228
|
+
detected = platform_from_command(raw_env)
|
|
204
229
|
if detected:
|
|
205
230
|
return PlatformResolution(detected, f"environment:{env_name}")
|
|
206
231
|
|
|
@@ -209,12 +234,6 @@ def resolve_platform(project_root: str | Path, env: Mapping[str, str] | None = N
|
|
|
209
234
|
detected = platform_from_command(config.get(key, ""))
|
|
210
235
|
if detected:
|
|
211
236
|
return PlatformResolution(detected, f"config:{key}")
|
|
212
|
-
try:
|
|
213
|
-
detected = prompt_host_from_platform_field(config.get("platform", ""), environment)
|
|
214
|
-
except PlatformSelectionError as exc:
|
|
215
|
-
return PlatformResolution("", "unresolved:config:platform", (str(exc),))
|
|
216
|
-
if detected:
|
|
217
|
-
return PlatformResolution(detected, "config:platform")
|
|
218
237
|
|
|
219
238
|
manifest = read_json_object(root / ".prizmkit" / "manifest.json")
|
|
220
239
|
options = manifest.get("options", {}) if isinstance(manifest.get("options"), dict) else {}
|
|
@@ -229,6 +248,13 @@ def resolve_platform(project_root: str | Path, env: Mapping[str, str] | None = N
|
|
|
229
248
|
if detected:
|
|
230
249
|
return PlatformResolution(detected, "manifest:platform")
|
|
231
250
|
|
|
251
|
+
try:
|
|
252
|
+
detected = prompt_host_from_platform_field(config.get("platform", ""), environment)
|
|
253
|
+
except PlatformSelectionError as exc:
|
|
254
|
+
return PlatformResolution("", "unresolved:config:platform", (str(exc),))
|
|
255
|
+
if detected:
|
|
256
|
+
return PlatformResolution(detected, "config:platform")
|
|
257
|
+
|
|
232
258
|
for platform in SUPPORTED_PLATFORMS:
|
|
233
259
|
for marker in _PLATFORM_MARKERS[platform]:
|
|
234
260
|
if (root / marker).is_dir():
|