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
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
import importlib.util
|
|
6
5
|
import json
|
|
7
6
|
import os
|
|
8
7
|
import queue
|
|
@@ -17,6 +16,7 @@ from collections.abc import Callable, Mapping, Sequence
|
|
|
17
16
|
from dataclasses import dataclass, field
|
|
18
17
|
from pathlib import Path
|
|
19
18
|
|
|
19
|
+
from .atomic_io import write_json_atomic
|
|
20
20
|
from .checkpoint_state import load_checkpoint_state
|
|
21
21
|
from .heartbeat import HeartbeatConfig, HeartbeatMonitor, HeartbeatState, observe_heartbeat_state, write_stale_marker
|
|
22
22
|
from .launch_profiles import HeadlessLaunchProfile
|
|
@@ -30,6 +30,7 @@ from .processes import (
|
|
|
30
30
|
terminate_process_tree,
|
|
31
31
|
)
|
|
32
32
|
from .status import ProgressSummary
|
|
33
|
+
from .stream_progress import ProgressTracker, SemanticLogNormalizer
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
@dataclass(frozen=True)
|
|
@@ -67,6 +68,7 @@ class AISessionConfig:
|
|
|
67
68
|
heartbeat_stale_threshold_seconds: float = 0
|
|
68
69
|
stale_kill_grace_seconds: float = 10
|
|
69
70
|
live_progress_interval_seconds: float = 30
|
|
71
|
+
heartbeat_interval_seconds: float = 1.0
|
|
70
72
|
live_banner: bool = True
|
|
71
73
|
suppress_stream_output: bool = False
|
|
72
74
|
codex_subagent_timeout_seconds: int = 3300
|
|
@@ -139,6 +141,8 @@ def _default_help_runner(command: Sequence[str]) -> str:
|
|
|
139
141
|
stdout=subprocess.PIPE,
|
|
140
142
|
stderr=subprocess.STDOUT,
|
|
141
143
|
text=True,
|
|
144
|
+
encoding="utf-8",
|
|
145
|
+
errors="replace",
|
|
142
146
|
check=False,
|
|
143
147
|
timeout=10,
|
|
144
148
|
)
|
|
@@ -155,6 +159,8 @@ def _default_cursor_probe_runner(command: Sequence[str]) -> str:
|
|
|
155
159
|
stdout=subprocess.PIPE,
|
|
156
160
|
stderr=subprocess.STDOUT,
|
|
157
161
|
text=True,
|
|
162
|
+
encoding="utf-8",
|
|
163
|
+
errors="replace",
|
|
158
164
|
check=False,
|
|
159
165
|
timeout=10,
|
|
160
166
|
)
|
|
@@ -178,11 +184,14 @@ def detect_stream_json_support(
|
|
|
178
184
|
if len(raw_command) >= 2 and raw_command[0] == raw_command[-1] and raw_command[0] in "'\""
|
|
179
185
|
else raw_command
|
|
180
186
|
)
|
|
181
|
-
|
|
182
|
-
unquoted
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
187
|
+
if len(unquoted) >= 3 and unquoted[1:3] in {":\\", ":/"} and unquoted.lower().endswith((".exe", ".cmd", ".bat")):
|
|
188
|
+
command_token = unquoted
|
|
189
|
+
else:
|
|
190
|
+
try:
|
|
191
|
+
tokens = shlex.split(raw_command)
|
|
192
|
+
command_token = tokens[0] if tokens else raw_command
|
|
193
|
+
except ValueError:
|
|
194
|
+
command_token = raw_command.split()[0].strip("'\"")
|
|
186
195
|
command_name = command_token.replace("\\", "/").rsplit("/", 1)[-1].lower()
|
|
187
196
|
for suffix in (".exe", ".cmd", ".bat"):
|
|
188
197
|
if command_name.endswith(suffix):
|
|
@@ -320,14 +329,15 @@ def build_ai_session_command(config: AISessionConfig) -> AISessionCommand:
|
|
|
320
329
|
return AISessionCommand(tuple(argv), prompt, "cursor", "stdin", prompt)
|
|
321
330
|
|
|
322
331
|
if platform == "claude":
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
prompt
|
|
332
|
+
use_stdin = os.name == "nt"
|
|
333
|
+
argv = [config.cli_command, "-p"]
|
|
334
|
+
if not use_stdin:
|
|
335
|
+
argv.append(prompt)
|
|
336
|
+
argv.extend([
|
|
327
337
|
"--dangerously-skip-permissions",
|
|
328
338
|
"--disallowedTools",
|
|
329
339
|
"EnterWorktree",
|
|
330
|
-
]
|
|
340
|
+
])
|
|
331
341
|
if config.verbose or config.use_stream_json:
|
|
332
342
|
argv.append("--verbose")
|
|
333
343
|
if config.use_stream_json:
|
|
@@ -337,7 +347,13 @@ def build_ai_session_command(config: AISessionConfig) -> AISessionCommand:
|
|
|
337
347
|
if config.model:
|
|
338
348
|
argv.extend(["--model", config.model])
|
|
339
349
|
argv.extend(config.extra_args)
|
|
340
|
-
return AISessionCommand(
|
|
350
|
+
return AISessionCommand(
|
|
351
|
+
tuple(argv),
|
|
352
|
+
prompt if use_stdin else None,
|
|
353
|
+
"claude",
|
|
354
|
+
"stdin" if use_stdin else "argument",
|
|
355
|
+
prompt,
|
|
356
|
+
)
|
|
341
357
|
|
|
342
358
|
if platform == "codex":
|
|
343
359
|
argv = [
|
|
@@ -424,8 +440,11 @@ def recover_session_log(session_log: Path, backup_log: Path, min_size: int = 102
|
|
|
424
440
|
recovered = True
|
|
425
441
|
cleaned = False
|
|
426
442
|
if backup_log.exists():
|
|
427
|
-
|
|
428
|
-
|
|
443
|
+
try:
|
|
444
|
+
backup_log.unlink()
|
|
445
|
+
cleaned = True
|
|
446
|
+
except OSError:
|
|
447
|
+
cleaned = False
|
|
429
448
|
return LogRecoveryResult(
|
|
430
449
|
recovered=recovered,
|
|
431
450
|
cleaned_backup=cleaned,
|
|
@@ -679,22 +698,7 @@ class _FallbackProgressTracker:
|
|
|
679
698
|
|
|
680
699
|
|
|
681
700
|
def _load_stream_parser_classes() -> tuple[type | None, type | None]:
|
|
682
|
-
|
|
683
|
-
spec = importlib.util.spec_from_file_location("prizmkit_parse_stream_progress", parser_path)
|
|
684
|
-
if spec is None or spec.loader is None:
|
|
685
|
-
return None, None
|
|
686
|
-
module = importlib.util.module_from_spec(spec)
|
|
687
|
-
spec.loader.exec_module(module)
|
|
688
|
-
return (
|
|
689
|
-
getattr(module, "ProgressTracker", None),
|
|
690
|
-
getattr(module, "SemanticLogNormalizer", None),
|
|
691
|
-
)
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
def _load_progress_tracker_class():
|
|
695
|
-
"""Backward-compatible access to the shared aggregate tracker class."""
|
|
696
|
-
tracker_class, _ = _load_stream_parser_classes()
|
|
697
|
-
return tracker_class
|
|
701
|
+
return ProgressTracker, SemanticLogNormalizer
|
|
698
702
|
|
|
699
703
|
|
|
700
704
|
def _fallback_semantic_output(line: str, event: object | None) -> str:
|
|
@@ -710,13 +714,6 @@ def _fallback_semantic_output(line: str, event: object | None) -> str:
|
|
|
710
714
|
return f"[OUTPUT] event={event_type}\n"
|
|
711
715
|
|
|
712
716
|
|
|
713
|
-
def _write_progress_summary(progress_path: Path | None, summary: ProgressSummary) -> None:
|
|
714
|
-
if progress_path is None:
|
|
715
|
-
return
|
|
716
|
-
progress_path.parent.mkdir(parents=True, exist_ok=True)
|
|
717
|
-
progress_path.write_text(json.dumps(summary.to_dict(), indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
|
718
|
-
|
|
719
|
-
|
|
720
717
|
def _progress_refresh_key(data: Mapping[str, object]) -> tuple[object, ...]:
|
|
721
718
|
event_counts = data.get("event_type_counts")
|
|
722
719
|
return (
|
|
@@ -735,8 +732,7 @@ def _progress_refresh_key(data: Mapping[str, object]) -> tuple[object, ...]:
|
|
|
735
732
|
|
|
736
733
|
|
|
737
734
|
def _write_progress_data(progress_path: Path, data: Mapping[str, object]) -> None:
|
|
738
|
-
progress_path
|
|
739
|
-
progress_path.write_text(json.dumps(data, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
|
735
|
+
write_json_atomic(progress_path, dict(data), indent=2, sort_keys=True, ensure_ascii=True, fsync=False)
|
|
740
736
|
|
|
741
737
|
|
|
742
738
|
def _start_idle_progress_refresh(
|
|
@@ -751,8 +747,13 @@ def _start_idle_progress_refresh(
|
|
|
751
747
|
|
|
752
748
|
def maybe_write(force: bool = False) -> None:
|
|
753
749
|
nonlocal last_key
|
|
754
|
-
|
|
755
|
-
|
|
750
|
+
if getattr(tracker, "SUPPORTS_UNLOCKED_CHILD_REFRESH", False):
|
|
751
|
+
tracker.refresh_child_session_activity(lock=tracker_lock)
|
|
752
|
+
with tracker_lock:
|
|
753
|
+
data = tracker.to_dict(refresh_child_activity=False)
|
|
754
|
+
else:
|
|
755
|
+
with tracker_lock:
|
|
756
|
+
data = tracker.to_dict()
|
|
756
757
|
key = _progress_refresh_key(data)
|
|
757
758
|
if force or key != last_key:
|
|
758
759
|
_write_progress_data(progress_path, data)
|
|
@@ -1151,6 +1152,18 @@ def _reader_thread(
|
|
|
1151
1152
|
backup_fh.flush()
|
|
1152
1153
|
if live_output:
|
|
1153
1154
|
_emit_live_output(rendered)
|
|
1155
|
+
if (
|
|
1156
|
+
refresh_progress is not None
|
|
1157
|
+
and isinstance(event, dict)
|
|
1158
|
+
and (
|
|
1159
|
+
event.get("type") in {"result", "turn.completed", "turn.failed", "agent_end"}
|
|
1160
|
+
or event.get("event") == "result"
|
|
1161
|
+
)
|
|
1162
|
+
):
|
|
1163
|
+
try:
|
|
1164
|
+
refresh_progress(True)
|
|
1165
|
+
except Exception:
|
|
1166
|
+
pass
|
|
1154
1167
|
if normalizer is not None:
|
|
1155
1168
|
trailing = normalizer.finish()
|
|
1156
1169
|
if trailing:
|
|
@@ -1160,8 +1173,13 @@ def _reader_thread(
|
|
|
1160
1173
|
backup_fh.flush()
|
|
1161
1174
|
if live_output:
|
|
1162
1175
|
_emit_live_output(trailing)
|
|
1163
|
-
|
|
1164
|
-
|
|
1176
|
+
if getattr(tracker, "SUPPORTS_UNLOCKED_CHILD_REFRESH", False):
|
|
1177
|
+
tracker.refresh_child_session_activity(lock=tracker_lock)
|
|
1178
|
+
with tracker_lock:
|
|
1179
|
+
final_data = tracker.to_dict(refresh_child_activity=False)
|
|
1180
|
+
else:
|
|
1181
|
+
with tracker_lock:
|
|
1182
|
+
final_data = tracker.to_dict()
|
|
1165
1183
|
finally:
|
|
1166
1184
|
if refresh_progress is not None:
|
|
1167
1185
|
try:
|
|
@@ -1174,7 +1192,10 @@ def _reader_thread(
|
|
|
1174
1192
|
if not final_data:
|
|
1175
1193
|
try:
|
|
1176
1194
|
with tracker_lock:
|
|
1177
|
-
|
|
1195
|
+
if getattr(tracker, "SUPPORTS_UNLOCKED_CHILD_REFRESH", False):
|
|
1196
|
+
final_data = tracker.to_dict(refresh_child_activity=False)
|
|
1197
|
+
else:
|
|
1198
|
+
final_data = tracker.to_dict()
|
|
1178
1199
|
except Exception:
|
|
1179
1200
|
final_data = {}
|
|
1180
1201
|
try:
|
|
@@ -1255,52 +1276,16 @@ class AISessionLauncher:
|
|
|
1255
1276
|
if self.config.live_output and self.config.live_banner:
|
|
1256
1277
|
_emit_session_start(self.config, command, session_log, backup_log)
|
|
1257
1278
|
|
|
1258
|
-
handle = launch_process(spec, stderr=subprocess.STDOUT)
|
|
1259
|
-
assert handle.popen is not None
|
|
1260
|
-
reader_result_queue: queue.Queue[dict[str, object]] = queue.Queue(maxsize=1)
|
|
1261
|
-
reader = threading.Thread(
|
|
1262
|
-
target=_reader_thread,
|
|
1263
|
-
args=(
|
|
1264
|
-
handle.popen.stdout,
|
|
1265
|
-
session_log,
|
|
1266
|
-
backup_log,
|
|
1267
|
-
reader_result_queue,
|
|
1268
|
-
self.config.progress_path,
|
|
1269
|
-
self.config.live_output and self.config.verbose and not self.config.suppress_stream_output,
|
|
1270
|
-
self.config.platform,
|
|
1271
|
-
),
|
|
1272
|
-
daemon=True,
|
|
1273
|
-
)
|
|
1274
|
-
reader.start()
|
|
1275
|
-
if handle.popen.stdin is not None:
|
|
1276
|
-
if command.stdin_text is not None:
|
|
1277
|
-
handle.popen.stdin.write(command.stdin_text)
|
|
1278
|
-
handle.popen.stdin.close()
|
|
1279
|
-
|
|
1280
|
-
heartbeat = None
|
|
1281
1279
|
live_progress_interval = max(1.0, float(self.config.live_progress_interval_seconds or 30))
|
|
1282
1280
|
kill_threshold_seconds = max(0.0, float(self.config.stale_kill_threshold_seconds or 0))
|
|
1283
1281
|
stale_threshold_seconds = max(0.0, float(self.config.heartbeat_stale_threshold_seconds or 0))
|
|
1284
1282
|
if stale_threshold_seconds <= 0:
|
|
1285
1283
|
stale_threshold_seconds = kill_threshold_seconds
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
handle,
|
|
1292
|
-
HeartbeatConfig(
|
|
1293
|
-
heartbeat_file=heartbeat_path,
|
|
1294
|
-
session_log=session_log,
|
|
1295
|
-
progress_file=self.config.progress_path,
|
|
1296
|
-
marker_dir=session_log.parent,
|
|
1297
|
-
interval_seconds=0.1,
|
|
1298
|
-
stale_after_seconds=stale_threshold_seconds,
|
|
1299
|
-
kill_after_seconds=kill_threshold_seconds,
|
|
1300
|
-
grace_seconds=self.config.stale_kill_grace_seconds,
|
|
1301
|
-
),
|
|
1302
|
-
)
|
|
1303
|
-
heartbeat.start()
|
|
1284
|
+
heartbeat_interval = (
|
|
1285
|
+
min(1.0, max(0.05, kill_threshold_seconds / 4.0))
|
|
1286
|
+
if 0 < kill_threshold_seconds < 4.0
|
|
1287
|
+
else min(5.0, max(0.5, float(self.config.heartbeat_interval_seconds or 1.0)))
|
|
1288
|
+
)
|
|
1304
1289
|
|
|
1305
1290
|
started = time.time()
|
|
1306
1291
|
timed_out = False
|
|
@@ -1309,7 +1294,70 @@ class AISessionLauncher:
|
|
|
1309
1294
|
last_progress_line = ""
|
|
1310
1295
|
last_progress_emit = 0.0
|
|
1311
1296
|
display_heartbeat_state = None
|
|
1297
|
+
handle: ProcessHandle | None = None
|
|
1298
|
+
reader: threading.Thread | None = None
|
|
1299
|
+
stdin_writer: threading.Thread | None = None
|
|
1300
|
+
heartbeat: HeartbeatMonitor | None = None
|
|
1301
|
+
interrupted = False
|
|
1302
|
+
launcher_aborted = False
|
|
1303
|
+
reader_result_queue: queue.Queue[dict[str, object]] = queue.Queue(maxsize=1)
|
|
1304
|
+
|
|
1312
1305
|
try:
|
|
1306
|
+
handle = launch_process(spec, stderr=subprocess.STDOUT)
|
|
1307
|
+
assert handle.popen is not None
|
|
1308
|
+
reader = threading.Thread(
|
|
1309
|
+
target=_reader_thread,
|
|
1310
|
+
args=(
|
|
1311
|
+
handle.popen.stdout,
|
|
1312
|
+
session_log,
|
|
1313
|
+
backup_log,
|
|
1314
|
+
reader_result_queue,
|
|
1315
|
+
self.config.progress_path,
|
|
1316
|
+
self.config.live_output and self.config.verbose and not self.config.suppress_stream_output,
|
|
1317
|
+
self.config.platform,
|
|
1318
|
+
),
|
|
1319
|
+
daemon=True,
|
|
1320
|
+
)
|
|
1321
|
+
reader.start()
|
|
1322
|
+
|
|
1323
|
+
heartbeat_path = self.config.heartbeat_path
|
|
1324
|
+
if heartbeat_path is None and kill_threshold_seconds > 0:
|
|
1325
|
+
heartbeat_path = session_log.with_name("heartbeat.json")
|
|
1326
|
+
if heartbeat_path is not None:
|
|
1327
|
+
heartbeat = HeartbeatMonitor(
|
|
1328
|
+
handle,
|
|
1329
|
+
HeartbeatConfig(
|
|
1330
|
+
heartbeat_file=heartbeat_path,
|
|
1331
|
+
session_log=session_log,
|
|
1332
|
+
progress_file=self.config.progress_path,
|
|
1333
|
+
marker_dir=session_log.parent,
|
|
1334
|
+
interval_seconds=heartbeat_interval,
|
|
1335
|
+
stale_after_seconds=stale_threshold_seconds,
|
|
1336
|
+
kill_after_seconds=kill_threshold_seconds,
|
|
1337
|
+
grace_seconds=self.config.stale_kill_grace_seconds,
|
|
1338
|
+
),
|
|
1339
|
+
)
|
|
1340
|
+
heartbeat.start()
|
|
1341
|
+
|
|
1342
|
+
if handle.popen.stdin is not None:
|
|
1343
|
+
stdin_pipe = handle.popen.stdin
|
|
1344
|
+
stdin_text = command.stdin_text
|
|
1345
|
+
|
|
1346
|
+
def _write_stdin() -> None:
|
|
1347
|
+
try:
|
|
1348
|
+
if stdin_text is not None:
|
|
1349
|
+
stdin_pipe.write(stdin_text)
|
|
1350
|
+
except (BrokenPipeError, OSError):
|
|
1351
|
+
pass
|
|
1352
|
+
finally:
|
|
1353
|
+
try:
|
|
1354
|
+
stdin_pipe.close()
|
|
1355
|
+
except (BrokenPipeError, OSError):
|
|
1356
|
+
pass
|
|
1357
|
+
|
|
1358
|
+
stdin_writer = threading.Thread(target=_write_stdin, name="prizmkit-stdin", daemon=True)
|
|
1359
|
+
stdin_writer.start()
|
|
1360
|
+
|
|
1313
1361
|
while True:
|
|
1314
1362
|
timeout = 0.2
|
|
1315
1363
|
if self.config.total_timeout_seconds is not None:
|
|
@@ -1339,59 +1387,92 @@ class AISessionLauncher:
|
|
|
1339
1387
|
stale_threshold_seconds=stale_threshold_seconds,
|
|
1340
1388
|
)
|
|
1341
1389
|
last_progress_emit = now
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
progress_path=self.config.progress_path,
|
|
1352
|
-
checkpoint_path=self.config.checkpoint_path,
|
|
1353
|
-
heartbeat_state=monitor_state,
|
|
1354
|
-
)
|
|
1355
|
-
except Exception as diagnostic_error:
|
|
1356
|
-
_emit_interrupt_line(
|
|
1357
|
-
f"diagnostic collection failed error={type(diagnostic_error).__name__}; "
|
|
1358
|
-
"continuing existing process-tree cleanup"
|
|
1390
|
+
|
|
1391
|
+
if self.config.live_output and (not self.config.verbose or self.config.suppress_stream_output):
|
|
1392
|
+
final_heartbeat_state = _display_heartbeat_state(
|
|
1393
|
+
session_log,
|
|
1394
|
+
self.config.progress_path,
|
|
1395
|
+
heartbeat.state if heartbeat is not None else None,
|
|
1396
|
+
display_heartbeat_state,
|
|
1397
|
+
interval_seconds=live_progress_interval,
|
|
1398
|
+
stale_threshold_seconds=stale_threshold_seconds,
|
|
1359
1399
|
)
|
|
1400
|
+
display_heartbeat_state = final_heartbeat_state
|
|
1401
|
+
if final_heartbeat_state.details == "progress":
|
|
1402
|
+
final_line = _compact_progress_line(
|
|
1403
|
+
started,
|
|
1404
|
+
session_log,
|
|
1405
|
+
self.config.progress_path,
|
|
1406
|
+
final_heartbeat_state,
|
|
1407
|
+
checkpoint_path=self.config.checkpoint_path,
|
|
1408
|
+
stale_threshold_seconds=stale_threshold_seconds,
|
|
1409
|
+
)
|
|
1410
|
+
if final_line != last_progress_line:
|
|
1411
|
+
_emit_live_line(final_line)
|
|
1412
|
+
last_progress_line = final_line
|
|
1413
|
+
except KeyboardInterrupt as interruption:
|
|
1414
|
+
interrupted = True
|
|
1360
1415
|
with shield_interruption_signals():
|
|
1361
|
-
|
|
1416
|
+
monitor_state = heartbeat.state if heartbeat is not None else display_heartbeat_state
|
|
1417
|
+
if handle is not None:
|
|
1418
|
+
try:
|
|
1419
|
+
_emit_ai_interruption_received(
|
|
1420
|
+
interruption,
|
|
1421
|
+
command=command,
|
|
1422
|
+
handle=handle,
|
|
1423
|
+
started_epoch=started,
|
|
1424
|
+
session_log=session_log,
|
|
1425
|
+
progress_path=self.config.progress_path,
|
|
1426
|
+
checkpoint_path=self.config.checkpoint_path,
|
|
1427
|
+
heartbeat_state=monitor_state,
|
|
1428
|
+
)
|
|
1429
|
+
except Exception as diagnostic_error:
|
|
1430
|
+
_emit_interrupt_line(
|
|
1431
|
+
f"diagnostic collection failed error={type(diagnostic_error).__name__}; "
|
|
1432
|
+
"continuing existing process-tree cleanup"
|
|
1433
|
+
)
|
|
1434
|
+
termination = terminate_process_tree(
|
|
1435
|
+
handle,
|
|
1436
|
+
"interrupted",
|
|
1437
|
+
grace_seconds=self.config.stale_kill_grace_seconds,
|
|
1438
|
+
)
|
|
1439
|
+
_emit_ai_interruption_termination(termination)
|
|
1440
|
+
raise
|
|
1441
|
+
except Exception:
|
|
1442
|
+
launcher_aborted = True
|
|
1443
|
+
if handle is not None:
|
|
1444
|
+
terminate_process_tree(
|
|
1362
1445
|
handle,
|
|
1363
|
-
"
|
|
1446
|
+
"launcher_error",
|
|
1364
1447
|
grace_seconds=self.config.stale_kill_grace_seconds,
|
|
1365
1448
|
)
|
|
1366
|
-
_emit_ai_interruption_termination(termination)
|
|
1367
1449
|
raise
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
stale_marker = heartbeat_result.marker_path
|
|
1450
|
+
finally:
|
|
1451
|
+
if stdin_writer is not None:
|
|
1452
|
+
stdin_writer.join(timeout=1.0)
|
|
1453
|
+
if reader is not None and not interrupted and not launcher_aborted:
|
|
1454
|
+
reader.join(timeout=1.5)
|
|
1455
|
+
if (
|
|
1456
|
+
reader.is_alive()
|
|
1457
|
+
and handle is not None
|
|
1458
|
+
and handle.popen is not None
|
|
1459
|
+
and handle.popen.poll() is not None
|
|
1460
|
+
):
|
|
1461
|
+
terminate_process_tree(handle, "lingering_child_pipes", grace_seconds=0.5)
|
|
1462
|
+
reader.join(timeout=3.5)
|
|
1463
|
+
heartbeat_result = heartbeat.stop() if heartbeat is not None else None
|
|
1464
|
+
if reader is not None and (interrupted or launcher_aborted):
|
|
1465
|
+
reader.join(timeout=1.0)
|
|
1466
|
+
if not interrupted and not launcher_aborted and heartbeat_result and heartbeat_result.killed:
|
|
1467
|
+
termination_reason = heartbeat_result.reason
|
|
1468
|
+
stale_marker = heartbeat_result.marker_path
|
|
1469
|
+
if interrupted:
|
|
1470
|
+
try:
|
|
1471
|
+
recover_session_log(session_log, backup_log)
|
|
1472
|
+
except OSError:
|
|
1473
|
+
pass
|
|
1474
|
+
|
|
1475
|
+
assert handle is not None and handle.popen is not None
|
|
1395
1476
|
if termination_reason is None and kill_threshold_seconds > 0 and handle.popen.returncode is None:
|
|
1396
1477
|
stale_marker = write_stale_marker(
|
|
1397
1478
|
session_log.parent,
|
|
@@ -1417,7 +1498,7 @@ class AISessionLauncher:
|
|
|
1417
1498
|
merged_progress.update(reader_progress)
|
|
1418
1499
|
fallback_summary = ProgressSummary()
|
|
1419
1500
|
if self.config.progress_path is not None:
|
|
1420
|
-
self.config.progress_path
|
|
1501
|
+
_write_progress_data(self.config.progress_path, merged_progress)
|
|
1421
1502
|
final_summary = _summary_from_progress_dict(merged_progress, fallback_summary)
|
|
1422
1503
|
ended = time.time()
|
|
1423
1504
|
result = AISessionResult(
|
|
@@ -72,7 +72,6 @@ def default_status_targets(paths: RuntimePaths) -> dict[str, StatusTarget]:
|
|
|
72
72
|
return {
|
|
73
73
|
"feature": StatusTarget("feature", paths.feature_plan, paths.feature_state_dir),
|
|
74
74
|
"bugfix": StatusTarget("bugfix", paths.bugfix_plan, paths.bugfix_state_dir),
|
|
75
|
-
"refactor": StatusTarget("refactor", paths.refactor_plan, paths.refactor_state_dir),
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
|
|
@@ -87,7 +86,6 @@ class AggregateStatusResult:
|
|
|
87
86
|
_FAMILY_PLAN_KEYS = {
|
|
88
87
|
"feature": "features",
|
|
89
88
|
"bugfix": "bugs",
|
|
90
|
-
"refactor": "refactors",
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
|
|
@@ -154,7 +152,7 @@ def aggregate_family_status(
|
|
|
154
152
|
sections: list[str] = []
|
|
155
153
|
failed = False
|
|
156
154
|
|
|
157
|
-
for family in ("feature", "bugfix"
|
|
155
|
+
for family in ("feature", "bugfix"):
|
|
158
156
|
target = targets[family]
|
|
159
157
|
label = family.upper()
|
|
160
158
|
body: str
|