prizmkit 1.1.192 → 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/dev-pipeline/README.md +23 -34
- package/bundled/dev-pipeline/assets/feature-list-example.json +0 -1
- package/bundled/dev-pipeline/assets/skill-subagent-integration.md +3 -0
- package/bundled/dev-pipeline/prizmkit_runtime/config.py +24 -2
- package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +2 -0
- package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +89 -40
- package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +9 -1
- package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +0 -22
- package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +11 -7
- package/bundled/dev-pipeline/prizmkit_runtime/processes.py +26 -20
- package/bundled/dev-pipeline/prizmkit_runtime/reset.py +37 -4
- package/bundled/dev-pipeline/prizmkit_runtime/reset_preserve.py +20 -41
- package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +74 -36
- package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +0 -66
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +271 -52
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +51 -13
- package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +43 -15
- package/bundled/dev-pipeline/prizmkit_runtime/stream_progress.py +27 -24
- package/bundled/dev-pipeline/prizmkit_runtime/task_checkout.py +0 -1
- package/bundled/dev-pipeline/scripts/check-session-status.py +13 -1
- package/bundled/dev-pipeline/scripts/continuation.py +2 -3
- package/bundled/dev-pipeline/scripts/detect-stuck.py +19 -5
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +6 -14
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +13 -8
- package/bundled/dev-pipeline/scripts/init-change-artifact.py +17 -2
- package/bundled/dev-pipeline/scripts/prompt_framework.py +39 -21
- package/bundled/dev-pipeline/scripts/update-checkpoint.py +27 -0
- package/bundled/dev-pipeline/templates/bootstrap-tier3.md +1 -1
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +6 -6
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +1 -1
- package/bundled/skills/_metadata.json +1 -1
- package/package.json +1 -1
- package/bundled/dev-pipeline/tests/_helpers.py +0 -418
- package/bundled/dev-pipeline/tests/conftest.py +0 -73
- package/bundled/dev-pipeline/tests/live_ai_cli_log_smoke.py +0 -208
- package/bundled/dev-pipeline/tests/test_auto_skip.py +0 -1806
- package/bundled/dev-pipeline/tests/test_checkpoint_state.py +0 -1439
- package/bundled/dev-pipeline/tests/test_daemon_and_scripts.py +0 -257
- package/bundled/dev-pipeline/tests/test_e2e_pipeline_run.py +0 -500
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +0 -1654
- package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +0 -629
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +0 -2973
- package/bundled/dev-pipeline/tests/test_recovery_workflow.py +0 -321
- package/bundled/dev-pipeline/tests/test_repository_bootstrap.py +0 -251
- package/bundled/dev-pipeline/tests/test_reset_modes.py +0 -1196
- package/bundled/dev-pipeline/tests/test_reset_preserve.py +0 -872
- package/bundled/dev-pipeline/tests/test_runner_bookkeeping.py +0 -766
- package/bundled/dev-pipeline/tests/test_runner_lifecycle.py +0 -1257
- package/bundled/dev-pipeline/tests/test_runtime_commit.py +0 -1113
- package/bundled/dev-pipeline/tests/test_runtime_helper.py +0 -380
- package/bundled/dev-pipeline/tests/test_session_launch.py +0 -1101
- package/bundled/dev-pipeline/tests/test_stream_progress.py +0 -585
- package/bundled/dev-pipeline/tests/test_unified_cli.py +0 -3625
- package/bundled/dev-pipeline/tests/test_utils.py +0 -170
|
@@ -14,11 +14,12 @@ from collections.abc import Iterator, Mapping
|
|
|
14
14
|
from contextlib import contextmanager
|
|
15
15
|
from pathlib import Path
|
|
16
16
|
|
|
17
|
-
from .atomic_io import write_json_atomic
|
|
17
|
+
from .atomic_io import write_json_atomic, write_text_atomic
|
|
18
18
|
from .checkpoint_state import load_checkpoint_state
|
|
19
19
|
from .config import load_env_file, load_runtime_config
|
|
20
20
|
from .gitops import (
|
|
21
21
|
BranchContext,
|
|
22
|
+
_is_generated_task_branch,
|
|
22
23
|
abort_in_progress_git_operation,
|
|
23
24
|
branch_create_plan,
|
|
24
25
|
branch_ensure_return,
|
|
@@ -33,6 +34,7 @@ from .gitops import (
|
|
|
33
34
|
restore_runtime_wip,
|
|
34
35
|
run_git_command,
|
|
35
36
|
run_git_plan,
|
|
37
|
+
safe_task_branch_prefix,
|
|
36
38
|
)
|
|
37
39
|
from .processes import RuntimeInterruption, describe_interruption, shield_interruption_signals
|
|
38
40
|
from .results import CommandResult
|
|
@@ -151,7 +153,17 @@ def _run_pipeline(family: RunnerFamily, invocation: RunnerInvocation, paths) ->
|
|
|
151
153
|
)
|
|
152
154
|
|
|
153
155
|
while True:
|
|
154
|
-
|
|
156
|
+
try:
|
|
157
|
+
next_result = get_next(family, invocation, paths.project_root)
|
|
158
|
+
except KeyboardInterrupt:
|
|
159
|
+
with shield_interruption_signals():
|
|
160
|
+
return PipelineRunResult(
|
|
161
|
+
False,
|
|
162
|
+
processed,
|
|
163
|
+
"interrupted",
|
|
164
|
+
"interrupted",
|
|
165
|
+
_render_item_statuses(item_statuses),
|
|
166
|
+
)
|
|
155
167
|
details = _render_item_statuses(item_statuses)
|
|
156
168
|
if not next_result.ok:
|
|
157
169
|
return PipelineRunResult(False, processed, "get_next_failed", details=(next_result.text,))
|
|
@@ -223,11 +235,11 @@ def _run_pipeline(family: RunnerFamily, invocation: RunnerInvocation, paths) ->
|
|
|
223
235
|
if final_status == "completed":
|
|
224
236
|
_emit_info(f"Pausing 5s before next {family.kind}...")
|
|
225
237
|
continue
|
|
226
|
-
if final_status == "pending":
|
|
227
|
-
continue
|
|
228
238
|
details = _render_item_statuses(item_statuses)
|
|
229
239
|
if _runner_env_for_paths(paths).stop_on_failure:
|
|
230
240
|
return PipelineRunResult(False, processed, "stop_on_failure", final_status, details)
|
|
241
|
+
if final_status == "pending":
|
|
242
|
+
continue
|
|
231
243
|
|
|
232
244
|
|
|
233
245
|
_COMPLETION_COMPATIBLE_STATUSES = {"completed"}
|
|
@@ -295,26 +307,80 @@ def _max_retries(invocation: RunnerInvocation, paths=None) -> int:
|
|
|
295
307
|
return _runner_env_for_paths(paths).max_retries if paths is not None else RunnerEnvironment.from_env().max_retries
|
|
296
308
|
|
|
297
309
|
|
|
298
|
-
def _emit_item_header(
|
|
310
|
+
def _emit_item_header(
|
|
311
|
+
family: RunnerFamily,
|
|
312
|
+
invocation: RunnerInvocation,
|
|
313
|
+
item_id: str,
|
|
314
|
+
metadata: dict[str, object],
|
|
315
|
+
paths=None,
|
|
316
|
+
) -> None:
|
|
299
317
|
title = str(metadata.get("title") or metadata.get("description") or "").strip()
|
|
300
318
|
title_text = f" — {title}" if title else ""
|
|
301
319
|
retry_count = int(metadata.get("retry_count") or 0)
|
|
302
320
|
infra_count = int(metadata.get("infra_error_count") or 0)
|
|
303
321
|
_emit_separator()
|
|
304
322
|
_emit_info(f"{_family_label(family)}: {item_id}{title_text}")
|
|
305
|
-
_emit_info(f"Code retry: {retry_count} / {_max_retries(invocation)}")
|
|
323
|
+
_emit_info(f"Code retry: {retry_count} / {_max_retries(invocation, paths)}")
|
|
306
324
|
_emit_info(f"Infrastructure retry: {infra_count} / {invocation.max_infra_retries}")
|
|
307
325
|
_emit_separator()
|
|
308
326
|
|
|
309
327
|
|
|
328
|
+
def _candidate_task_prefixes(family: RunnerFamily) -> tuple[str, ...]:
|
|
329
|
+
base = family.branch_prefix
|
|
330
|
+
return (base, f"prizmkit/{base}", f"prizmkit-{base}")
|
|
331
|
+
|
|
332
|
+
|
|
310
333
|
def _is_recovery_side_effect_branch(branch: str, family: RunnerFamily, item_id: str) -> bool:
|
|
311
|
-
return bool(branch) and
|
|
334
|
+
return bool(branch) and "-recovery-" in branch and any(
|
|
335
|
+
branch.startswith(f"{prefix}/{item_id}-") for prefix in _candidate_task_prefixes(family)
|
|
336
|
+
)
|
|
312
337
|
|
|
313
338
|
|
|
314
339
|
def _is_current_task_branch(branch: str, family: RunnerFamily, item_id: str) -> bool:
|
|
315
340
|
if not branch or _is_recovery_side_effect_branch(branch, family, item_id):
|
|
316
341
|
return False
|
|
317
|
-
return
|
|
342
|
+
return any(
|
|
343
|
+
branch == f"{prefix}/{item_id}" or branch.startswith(f"{prefix}/{item_id}-")
|
|
344
|
+
for prefix in _candidate_task_prefixes(family)
|
|
345
|
+
)
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
_STATUS_RECOVERY_FIELDS = (
|
|
349
|
+
"retry_count",
|
|
350
|
+
"infra_error_count",
|
|
351
|
+
"continuation_pending",
|
|
352
|
+
"continuation_reason",
|
|
353
|
+
"continuation_count",
|
|
354
|
+
"context_overflow_count",
|
|
355
|
+
"previous_session_id",
|
|
356
|
+
"last_context_overflow_session_id",
|
|
357
|
+
"last_progress_fingerprint",
|
|
358
|
+
"no_progress_count",
|
|
359
|
+
"resume_from_phase",
|
|
360
|
+
"current_stage",
|
|
361
|
+
"next_stage",
|
|
362
|
+
"stage_result",
|
|
363
|
+
"repair_scope",
|
|
364
|
+
"repair_round",
|
|
365
|
+
"blocked_reason",
|
|
366
|
+
"terminal_status",
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
def _backfill_status_recovery_metadata(enriched: dict[str, object], state_dir: Path, item_id: str) -> None:
|
|
371
|
+
status_path = state_dir / item_id / "status.json"
|
|
372
|
+
if not status_path.is_file():
|
|
373
|
+
return
|
|
374
|
+
try:
|
|
375
|
+
status_data = json.loads(status_path.read_text(encoding="utf-8"))
|
|
376
|
+
except (OSError, json.JSONDecodeError):
|
|
377
|
+
return
|
|
378
|
+
if not isinstance(status_data, dict):
|
|
379
|
+
return
|
|
380
|
+
for key in _STATUS_RECOVERY_FIELDS:
|
|
381
|
+
if key not in enriched or enriched[key] in (None, ""):
|
|
382
|
+
if key in status_data and status_data[key] is not None:
|
|
383
|
+
enriched[key] = status_data[key]
|
|
318
384
|
|
|
319
385
|
|
|
320
386
|
def _with_recovery_metadata(
|
|
@@ -324,6 +390,7 @@ def _with_recovery_metadata(
|
|
|
324
390
|
checkout: TaskCheckout | None = None,
|
|
325
391
|
) -> dict[str, object]:
|
|
326
392
|
enriched = dict(metadata)
|
|
393
|
+
_backfill_status_recovery_metadata(enriched, family.state_dir, item_id)
|
|
327
394
|
checkout = checkout or load_task_checkout(family.state_dir, family.task_type, item_id)
|
|
328
395
|
if checkout is not None:
|
|
329
396
|
if checkout.is_active:
|
|
@@ -367,7 +434,11 @@ def _resolve_base_branch(project_root: Path, metadata: dict[str, object], active
|
|
|
367
434
|
detected_default = default_branch(project_root)
|
|
368
435
|
if detected_default == "HEAD":
|
|
369
436
|
detected_default = ""
|
|
370
|
-
if
|
|
437
|
+
if (
|
|
438
|
+
_is_generated_task_branch(active)
|
|
439
|
+
or _is_current_task_branch(active, family, item_id)
|
|
440
|
+
or _is_recovery_side_effect_branch(active, family, item_id)
|
|
441
|
+
):
|
|
371
442
|
resolved = detected_default
|
|
372
443
|
else:
|
|
373
444
|
resolved = active or detected_default
|
|
@@ -379,7 +450,14 @@ def _resolve_base_branch(project_root: Path, metadata: dict[str, object], active
|
|
|
379
450
|
return resolved
|
|
380
451
|
|
|
381
452
|
|
|
382
|
-
def _resolve_working_branch(
|
|
453
|
+
def _resolve_working_branch(
|
|
454
|
+
family: RunnerFamily,
|
|
455
|
+
item_id: str,
|
|
456
|
+
metadata: dict[str, object],
|
|
457
|
+
env: RunnerEnvironment,
|
|
458
|
+
active_branch: str,
|
|
459
|
+
project_root: Path | None = None,
|
|
460
|
+
) -> str:
|
|
383
461
|
recorded = str(metadata.get("active_dev_branch") or "").strip()
|
|
384
462
|
if recorded and not _is_recovery_side_effect_branch(recorded, family, item_id):
|
|
385
463
|
return recorded
|
|
@@ -387,7 +465,8 @@ def _resolve_working_branch(family: RunnerFamily, item_id: str, metadata: dict[s
|
|
|
387
465
|
return env.dev_branch
|
|
388
466
|
if _is_current_task_branch(active_branch, family, item_id):
|
|
389
467
|
return active_branch
|
|
390
|
-
|
|
468
|
+
prefix = safe_task_branch_prefix(project_root, family.branch_prefix) if project_root is not None else family.branch_prefix
|
|
469
|
+
return _default_branch_name(family, item_id, prefix=prefix)
|
|
391
470
|
|
|
392
471
|
|
|
393
472
|
def _emit_branch_setup_result(branch_context: BranchContext, result) -> None:
|
|
@@ -398,8 +477,6 @@ def _emit_branch_setup_result(branch_context: BranchContext, result) -> None:
|
|
|
398
477
|
_emit_info(f"Created and checked out branch: {branch_context.working_branch} (from {branch_context.base_branch})")
|
|
399
478
|
elif reused:
|
|
400
479
|
_emit_info(f"Reusing branch: {branch_context.working_branch} (from {branch_context.base_branch})")
|
|
401
|
-
else:
|
|
402
|
-
_emit_info(f"Dev branch: {branch_context.working_branch}")
|
|
403
480
|
_emit_info(f"Dev branch: {branch_context.working_branch}")
|
|
404
481
|
|
|
405
482
|
|
|
@@ -531,6 +608,33 @@ def _validate_effort_config(config) -> None:
|
|
|
531
608
|
raise RuntimeError(effort_validation.message)
|
|
532
609
|
|
|
533
610
|
|
|
611
|
+
def _resolve_stream_json_support(config) -> bool:
|
|
612
|
+
if getattr(config.ai_client, "launch_profile", None) is not None:
|
|
613
|
+
return False
|
|
614
|
+
stream_support = detect_stream_json_support(config.ai_client.command, config.ai_client.platform)
|
|
615
|
+
enabled = bool(getattr(stream_support, "enabled", False))
|
|
616
|
+
notes = getattr(stream_support, "notes", ()) or ()
|
|
617
|
+
if config.ai_client.platform == "cursor" and not enabled:
|
|
618
|
+
details = "; ".join(notes) or "required stream-json flags were not found"
|
|
619
|
+
raise RuntimeError(
|
|
620
|
+
"Cursor Agent CLI is incompatible with PrizmKit headless execution: "
|
|
621
|
+
f"{details}. Install or update Cursor Agent and verify `agent --help`."
|
|
622
|
+
)
|
|
623
|
+
if config.ai_client.platform == "antigravity" and not enabled:
|
|
624
|
+
details = "; ".join(notes) or "required stream-json flags were not found"
|
|
625
|
+
raise RuntimeError(
|
|
626
|
+
"Antigravity CLI is incompatible with PrizmKit headless execution: "
|
|
627
|
+
f"{details}. Install or update Antigravity CLI (`agy`) and verify `agy --help`."
|
|
628
|
+
)
|
|
629
|
+
return enabled
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
def _bookkeeping_list_kwargs(family: RunnerFamily, invocation: RunnerInvocation) -> dict[str, Path]:
|
|
633
|
+
if invocation.list_path != family.plan_path:
|
|
634
|
+
return {"list_path": invocation.list_path}
|
|
635
|
+
return {}
|
|
636
|
+
|
|
637
|
+
|
|
534
638
|
def _preview_item(
|
|
535
639
|
family: RunnerFamily,
|
|
536
640
|
invocation: RunnerInvocation,
|
|
@@ -546,7 +650,7 @@ def _preview_item(
|
|
|
546
650
|
metadata = _with_recovery_metadata(family, item_id, initial_metadata)
|
|
547
651
|
retry_count = int(metadata.get("retry_count") or 0)
|
|
548
652
|
session_id = f"{item_id}-dry-run"
|
|
549
|
-
_emit_item_header(family, invocation, item_id, metadata)
|
|
653
|
+
_emit_item_header(family, invocation, item_id, metadata, paths)
|
|
550
654
|
with tempfile.TemporaryDirectory(prefix="prizmkit-dry-run-") as temporary:
|
|
551
655
|
session_paths = SessionPaths.for_item(Path(temporary), item_id, session_id)
|
|
552
656
|
prompt = generate_prompt(
|
|
@@ -583,6 +687,7 @@ def _process_item_locked(
|
|
|
583
687
|
if not config.ai_client.command:
|
|
584
688
|
raise RuntimeError("No supported AI CLI command was found")
|
|
585
689
|
_validate_effort_config(config)
|
|
690
|
+
stream_json = _resolve_stream_json_support(config)
|
|
586
691
|
|
|
587
692
|
repository = ensure_git_repository(paths.project_root)
|
|
588
693
|
if repository.return_code != 0:
|
|
@@ -598,8 +703,11 @@ def _process_item_locked(
|
|
|
598
703
|
raise RuntimeError(f"Task {item_id} is completed; run explicit reset or clean before rerunning")
|
|
599
704
|
metadata = _with_recovery_metadata(family, item_id, initial_metadata, checkout)
|
|
600
705
|
base_branch = _resolve_base_branch(paths.project_root, metadata, active_branch, family, item_id)
|
|
601
|
-
branch_name = _resolve_working_branch(family, item_id, metadata, env, active_branch)
|
|
706
|
+
branch_name = _resolve_working_branch(family, item_id, metadata, env, active_branch, paths.project_root)
|
|
602
707
|
branch_context = BranchContext(base_branch, branch_name, paths.project_root)
|
|
708
|
+
initial_branch_ref_existed = bool(
|
|
709
|
+
active_branch and active_branch != "HEAD" and local_branch_exists(paths.project_root, active_branch)
|
|
710
|
+
)
|
|
603
711
|
reusing_checkout = checkout is not None and checkout.is_active
|
|
604
712
|
execution_root = paths.project_root
|
|
605
713
|
session_id = ""
|
|
@@ -629,10 +737,14 @@ def _process_item_locked(
|
|
|
629
737
|
raise RuntimeError(f"Cannot create the initial commit before {family.kind} task {item_id}: {first}")
|
|
630
738
|
if born.args and born.args[0] == "commit":
|
|
631
739
|
_emit_info(f"Git: created initial commit before {family.kind} task {item_id}")
|
|
740
|
+
if (not initial_branch_ref_existed or not local_branch_exists(paths.project_root, base_branch)) and (
|
|
741
|
+
preflight.committed or (born.args and born.args[0] == "commit")
|
|
742
|
+
):
|
|
632
743
|
active_branch = current_branch(paths.project_root)
|
|
633
744
|
if not local_branch_exists(paths.project_root, base_branch):
|
|
634
745
|
base_branch = _resolve_base_branch(paths.project_root, metadata, active_branch, family, item_id)
|
|
635
|
-
|
|
746
|
+
branch_name = _resolve_working_branch(family, item_id, metadata, env, active_branch, paths.project_root)
|
|
747
|
+
branch_context = BranchContext(base_branch, branch_name, paths.project_root)
|
|
636
748
|
|
|
637
749
|
if (
|
|
638
750
|
checkout is not None
|
|
@@ -655,6 +767,15 @@ def _process_item_locked(
|
|
|
655
767
|
checkout = reserve_task_checkout_locked(family.state_dir, checkout_candidate)
|
|
656
768
|
_emit_info(f"Checkout: reserved task identity at {family.state_dir / item_id / 'checkout.json'}")
|
|
657
769
|
|
|
770
|
+
base_bookkeeping_snapshots: dict[Path, str] = {}
|
|
771
|
+
if reusing_checkout and active_branch != branch_name:
|
|
772
|
+
for candidate in (invocation.list_path, family.state_dir / item_id / "status.json"):
|
|
773
|
+
if candidate.is_file():
|
|
774
|
+
try:
|
|
775
|
+
base_bookkeeping_snapshots[candidate] = candidate.read_text(encoding="utf-8")
|
|
776
|
+
except OSError:
|
|
777
|
+
pass
|
|
778
|
+
|
|
658
779
|
branch_result = run_git_plan(paths.project_root, branch_create_plan(branch_context))
|
|
659
780
|
_emit_branch_setup_result(branch_context, branch_result)
|
|
660
781
|
if not branch_result.ok:
|
|
@@ -671,7 +792,13 @@ def _process_item_locked(
|
|
|
671
792
|
base_branch=base_branch,
|
|
672
793
|
)
|
|
673
794
|
if update.ok:
|
|
674
|
-
commit_final_bookkeeping(
|
|
795
|
+
commit_final_bookkeeping(
|
|
796
|
+
paths.project_root,
|
|
797
|
+
family,
|
|
798
|
+
item_id,
|
|
799
|
+
_status_from_update(update),
|
|
800
|
+
**_bookkeeping_list_kwargs(family, invocation),
|
|
801
|
+
)
|
|
675
802
|
return _status_from_update(update)
|
|
676
803
|
return "infra_error"
|
|
677
804
|
|
|
@@ -703,8 +830,17 @@ def _process_item_locked(
|
|
|
703
830
|
)
|
|
704
831
|
else:
|
|
705
832
|
_emit_info(f"Recovery: no Runtime-owned WIP tip to restore for {item_id}")
|
|
706
|
-
|
|
707
|
-
|
|
833
|
+
for snapshot_path, expected_text in base_bookkeeping_snapshots.items():
|
|
834
|
+
current_text = None
|
|
835
|
+
if snapshot_path.is_file():
|
|
836
|
+
try:
|
|
837
|
+
current_text = snapshot_path.read_text(encoding="utf-8")
|
|
838
|
+
except OSError:
|
|
839
|
+
current_text = None
|
|
840
|
+
if current_text != expected_text:
|
|
841
|
+
write_text_atomic(snapshot_path, expected_text)
|
|
842
|
+
|
|
843
|
+
_emit_item_header(family, invocation, item_id, metadata, paths)
|
|
708
844
|
status_root = paths.project_root
|
|
709
845
|
status_family = family
|
|
710
846
|
status_invocation = invocation
|
|
@@ -754,7 +890,12 @@ def _process_item_locked(
|
|
|
754
890
|
start = start_item(status_family, status_invocation, item_id, status_root)
|
|
755
891
|
if not start.ok:
|
|
756
892
|
raise RuntimeError(start.text)
|
|
757
|
-
commit_pre_branch_bookkeeping(
|
|
893
|
+
commit_pre_branch_bookkeeping(
|
|
894
|
+
status_root,
|
|
895
|
+
status_family,
|
|
896
|
+
item_id,
|
|
897
|
+
**_bookkeeping_list_kwargs(status_family, status_invocation),
|
|
898
|
+
)
|
|
758
899
|
|
|
759
900
|
previous_fingerprint = metadata.get("last_progress_fingerprint")
|
|
760
901
|
previous_no_progress_count = int(metadata.get("no_progress_count") or 0)
|
|
@@ -810,22 +951,6 @@ def _process_item_locked(
|
|
|
810
951
|
continuation=continuation,
|
|
811
952
|
)
|
|
812
953
|
_emit_prompt_summary(prompt, session_id)
|
|
813
|
-
stream_json = False
|
|
814
|
-
if getattr(config.ai_client, "launch_profile", None) is None:
|
|
815
|
-
stream_support = detect_stream_json_support(config.ai_client.command, config.ai_client.platform)
|
|
816
|
-
stream_json = stream_support.enabled
|
|
817
|
-
if config.ai_client.platform == "cursor" and not stream_json:
|
|
818
|
-
details = "; ".join(stream_support.notes) or "required stream-json flags were not found"
|
|
819
|
-
raise RuntimeError(
|
|
820
|
-
"Cursor Agent CLI is incompatible with PrizmKit headless execution: "
|
|
821
|
-
f"{details}. Install or update Cursor Agent and verify `agent --help`."
|
|
822
|
-
)
|
|
823
|
-
if config.ai_client.platform == "antigravity" and not stream_json:
|
|
824
|
-
details = "; ".join(stream_support.notes) or "required stream-json flags were not found"
|
|
825
|
-
raise RuntimeError(
|
|
826
|
-
"Antigravity CLI is incompatible with PrizmKit headless execution: "
|
|
827
|
-
f"{details}. Install or update Antigravity CLI (`agy`) and verify `agy --help`."
|
|
828
|
-
)
|
|
829
954
|
base_head = run_git_command(execution_root, ("rev-parse", "HEAD")).stdout.strip()
|
|
830
955
|
session_result = AISessionLauncher(
|
|
831
956
|
AISessionConfig(
|
|
@@ -952,7 +1077,13 @@ def _process_item_locked(
|
|
|
952
1077
|
new_status,
|
|
953
1078
|
update_data,
|
|
954
1079
|
)
|
|
955
|
-
commit_final_bookkeeping(
|
|
1080
|
+
commit_final_bookkeeping(
|
|
1081
|
+
status_root,
|
|
1082
|
+
status_family,
|
|
1083
|
+
item_id,
|
|
1084
|
+
new_status,
|
|
1085
|
+
**_bookkeeping_list_kwargs(status_family, status_invocation),
|
|
1086
|
+
)
|
|
956
1087
|
wip = _save_failure_wip(execution_root, family, item_id, new_status)
|
|
957
1088
|
if not getattr(wip, "ok", True):
|
|
958
1089
|
_emit_warning(f"WIP preservation failed for {item_id}; leaving the task checkout active")
|
|
@@ -1335,7 +1466,13 @@ def _complete_success_merge(
|
|
|
1335
1466
|
status_invocation,
|
|
1336
1467
|
item_id,
|
|
1337
1468
|
)
|
|
1338
|
-
final_bookkeeping = commit_final_bookkeeping(
|
|
1469
|
+
final_bookkeeping = commit_final_bookkeeping(
|
|
1470
|
+
status_root,
|
|
1471
|
+
status_family,
|
|
1472
|
+
item_id,
|
|
1473
|
+
new_status,
|
|
1474
|
+
**_bookkeeping_list_kwargs(status_family, status_invocation),
|
|
1475
|
+
)
|
|
1339
1476
|
task_commit = commit_task_branch_changes(execution_root, family, item_id, new_status)
|
|
1340
1477
|
finalization_committed = getattr(final_bookkeeping, "ok", True) and getattr(task_commit, "ok", True)
|
|
1341
1478
|
if not finalization_committed:
|
|
@@ -1366,7 +1503,13 @@ def _complete_success_merge(
|
|
|
1366
1503
|
raise RuntimeError(update.text)
|
|
1367
1504
|
_emit_update_summary(family, item_id, update)
|
|
1368
1505
|
commit_missing_status = _status_from_update(update)
|
|
1369
|
-
commit_final_bookkeeping(
|
|
1506
|
+
commit_final_bookkeeping(
|
|
1507
|
+
status_root,
|
|
1508
|
+
status_family,
|
|
1509
|
+
item_id,
|
|
1510
|
+
commit_missing_status,
|
|
1511
|
+
**_bookkeeping_list_kwargs(status_family, status_invocation),
|
|
1512
|
+
)
|
|
1370
1513
|
_save_failure_wip(execution_root, family, item_id, commit_missing_status)
|
|
1371
1514
|
return commit_missing_status
|
|
1372
1515
|
|
|
@@ -1390,11 +1533,13 @@ def _complete_success_merge(
|
|
|
1390
1533
|
complete_task_checkout_locked(family.state_dir, checkout)
|
|
1391
1534
|
_emit_success(f"Merged {branch_name} into {base_branch}")
|
|
1392
1535
|
return new_status
|
|
1536
|
+
abort_in_progress_git_operation(paths.project_root)
|
|
1393
1537
|
_emit_warning(
|
|
1394
1538
|
f"Merge failed for {item_id} ({branch_name} -> {base_branch}); "
|
|
1395
1539
|
"aborted in-progress git operation and recorded merge_conflict"
|
|
1396
1540
|
)
|
|
1397
|
-
|
|
1541
|
+
if current_branch(paths.project_root) == base_branch and branch_name and local_branch_exists(paths.project_root, branch_name):
|
|
1542
|
+
run_git_command(paths.project_root, ("checkout", branch_name))
|
|
1398
1543
|
|
|
1399
1544
|
_write_session_status(
|
|
1400
1545
|
session_paths,
|
|
@@ -1422,12 +1567,47 @@ def _complete_success_merge(
|
|
|
1422
1567
|
raise RuntimeError(update.text)
|
|
1423
1568
|
_emit_update_summary(family, item_id, update)
|
|
1424
1569
|
merged_status = _status_from_update(update)
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1570
|
+
update_data = update.data if isinstance(update.data, dict) else {}
|
|
1571
|
+
failure_bookkeeping = _capture_terminal_failure_bookkeeping(
|
|
1572
|
+
status_family,
|
|
1573
|
+
status_invocation,
|
|
1574
|
+
item_id,
|
|
1575
|
+
merged_status,
|
|
1576
|
+
update_data,
|
|
1577
|
+
)
|
|
1578
|
+
if current_branch(paths.project_root) == branch_name or not local_branch_exists(paths.project_root, branch_name):
|
|
1579
|
+
commit_final_bookkeeping(
|
|
1580
|
+
status_root,
|
|
1581
|
+
status_family,
|
|
1582
|
+
item_id,
|
|
1583
|
+
merged_status,
|
|
1584
|
+
**_bookkeeping_list_kwargs(status_family, status_invocation),
|
|
1585
|
+
)
|
|
1586
|
+
wip = _save_failure_wip(execution_root, family, item_id, merged_status)
|
|
1587
|
+
if getattr(wip, "ok", True):
|
|
1588
|
+
returned = branch_ensure_return(paths.project_root, base_branch, branch_name)
|
|
1589
|
+
if not returned.ok:
|
|
1590
|
+
_emit_warning(f"Could not safely return to {base_branch}; leaving {branch_name} active")
|
|
1591
|
+
elif failure_bookkeeping:
|
|
1592
|
+
synced = sync_terminal_failure_bookkeeping_to_base(
|
|
1593
|
+
status_root,
|
|
1594
|
+
status_family,
|
|
1595
|
+
item_id,
|
|
1596
|
+
merged_status,
|
|
1597
|
+
failure_bookkeeping,
|
|
1598
|
+
)
|
|
1599
|
+
if synced.attempted and not synced.ok:
|
|
1600
|
+
_emit_warning(f"Could not commit {item_id} terminal status bookkeeping on {base_branch}")
|
|
1601
|
+
elif failure_bookkeeping and current_branch(paths.project_root) == base_branch:
|
|
1602
|
+
synced = sync_terminal_failure_bookkeeping_to_base(
|
|
1603
|
+
status_root,
|
|
1604
|
+
status_family,
|
|
1605
|
+
item_id,
|
|
1606
|
+
merged_status,
|
|
1607
|
+
failure_bookkeeping,
|
|
1608
|
+
)
|
|
1609
|
+
if synced.attempted and not synced.ok:
|
|
1610
|
+
_emit_warning(f"Could not commit {item_id} terminal status bookkeeping on {base_branch}")
|
|
1431
1611
|
return merged_status
|
|
1432
1612
|
|
|
1433
1613
|
|
|
@@ -1444,12 +1624,17 @@ def _capture_terminal_failure_bookkeeping(
|
|
|
1444
1624
|
update_data: Mapping[str, object],
|
|
1445
1625
|
) -> dict[Path, str]:
|
|
1446
1626
|
"""Snapshot terminal failure status files before branch return reverts the checkout."""
|
|
1447
|
-
if new_status not in {"failed", "skipped", "auto_skipped"}:
|
|
1627
|
+
if new_status not in {"failed", "skipped", "auto_skipped", "needs_info"}:
|
|
1448
1628
|
return {}
|
|
1449
1629
|
candidates: list[Path] = [
|
|
1450
1630
|
invocation.list_path,
|
|
1451
1631
|
family.state_dir / item_id / "status.json",
|
|
1452
1632
|
]
|
|
1633
|
+
raw_auto_skipped = update_data.get("auto_skipped")
|
|
1634
|
+
if isinstance(raw_auto_skipped, list):
|
|
1635
|
+
for entry in raw_auto_skipped:
|
|
1636
|
+
if isinstance(entry, str) and entry.strip():
|
|
1637
|
+
candidates.append(family.state_dir / entry.strip() / "status.json")
|
|
1453
1638
|
for key in ("auto_skipped_features", "auto_skipped_bugs"):
|
|
1454
1639
|
entries = update_data.get(key)
|
|
1455
1640
|
if not isinstance(entries, list):
|
|
@@ -1486,7 +1671,12 @@ def _record_setup_failure(
|
|
|
1486
1671
|
status_invocation = invocation
|
|
1487
1672
|
start = start_item(status_family, status_invocation, item_id, status_root)
|
|
1488
1673
|
if start.ok:
|
|
1489
|
-
commit_pre_branch_bookkeeping(
|
|
1674
|
+
commit_pre_branch_bookkeeping(
|
|
1675
|
+
status_root,
|
|
1676
|
+
status_family,
|
|
1677
|
+
item_id,
|
|
1678
|
+
**_bookkeeping_list_kwargs(status_family, status_invocation),
|
|
1679
|
+
)
|
|
1490
1680
|
update = update_item(
|
|
1491
1681
|
status_family,
|
|
1492
1682
|
status_invocation,
|
|
@@ -1498,8 +1688,26 @@ def _record_setup_failure(
|
|
|
1498
1688
|
base_branch=base_branch,
|
|
1499
1689
|
)
|
|
1500
1690
|
new_status = _status_from_update(update) if update.ok else "infra_error"
|
|
1691
|
+
update_data = update.data if isinstance(getattr(update, "data", None), dict) else {}
|
|
1692
|
+
failure_bookkeeping = (
|
|
1693
|
+
_capture_terminal_failure_bookkeeping(
|
|
1694
|
+
status_family,
|
|
1695
|
+
status_invocation,
|
|
1696
|
+
item_id,
|
|
1697
|
+
new_status,
|
|
1698
|
+
update_data,
|
|
1699
|
+
)
|
|
1700
|
+
if update.ok
|
|
1701
|
+
else {}
|
|
1702
|
+
)
|
|
1501
1703
|
if update.ok:
|
|
1502
|
-
commit_final_bookkeeping(
|
|
1704
|
+
commit_final_bookkeeping(
|
|
1705
|
+
status_root,
|
|
1706
|
+
status_family,
|
|
1707
|
+
item_id,
|
|
1708
|
+
new_status,
|
|
1709
|
+
**_bookkeeping_list_kwargs(status_family, status_invocation),
|
|
1710
|
+
)
|
|
1503
1711
|
wip = _save_failure_wip(status_root, family, item_id, new_status)
|
|
1504
1712
|
else:
|
|
1505
1713
|
wip = None
|
|
@@ -1507,7 +1715,17 @@ def _record_setup_failure(
|
|
|
1507
1715
|
current_branch(project_root) == branch_name
|
|
1508
1716
|
and getattr(wip, "ok", True)
|
|
1509
1717
|
):
|
|
1510
|
-
branch_ensure_return(project_root, base_branch, branch_name)
|
|
1718
|
+
returned = branch_ensure_return(project_root, base_branch, branch_name)
|
|
1719
|
+
if getattr(returned, "ok", True) and failure_bookkeeping:
|
|
1720
|
+
synced = sync_terminal_failure_bookkeeping_to_base(
|
|
1721
|
+
status_root,
|
|
1722
|
+
status_family,
|
|
1723
|
+
item_id,
|
|
1724
|
+
new_status,
|
|
1725
|
+
failure_bookkeeping,
|
|
1726
|
+
)
|
|
1727
|
+
if synced.attempted and not synced.ok:
|
|
1728
|
+
_emit_warning(f"Could not commit {item_id} terminal status bookkeeping on {base_branch}")
|
|
1511
1729
|
return new_status
|
|
1512
1730
|
|
|
1513
1731
|
|
|
@@ -1583,8 +1801,9 @@ def _status_from_update(update_result) -> str:
|
|
|
1583
1801
|
return "unknown"
|
|
1584
1802
|
|
|
1585
1803
|
|
|
1586
|
-
def _default_branch_name(family: RunnerFamily, item_id: str) -> str:
|
|
1587
|
-
|
|
1804
|
+
def _default_branch_name(family: RunnerFamily, item_id: str, prefix: str | None = None) -> str:
|
|
1805
|
+
branch_prefix = prefix or family.branch_prefix
|
|
1806
|
+
return f"{branch_prefix}/{item_id}-{time.strftime('%Y%m%d%H%M%S')}"
|
|
1588
1807
|
|
|
1589
1808
|
|
|
1590
1809
|
def _session_id(item_id: str) -> str:
|
|
@@ -36,6 +36,35 @@ _SENSITIVE_NAMES = {
|
|
|
36
36
|
"secrets.json",
|
|
37
37
|
}
|
|
38
38
|
_SENSITIVE_SUFFIXES = {".pem", ".p12", ".pfx"}
|
|
39
|
+
_RUNTIME_INTERNAL_PREFIXES = (
|
|
40
|
+
".prizmkit/state",
|
|
41
|
+
".prizmkit/dev-pipeline",
|
|
42
|
+
".prizmkit/scripts",
|
|
43
|
+
".prizmkit/manifest.json",
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
_PIPELINE_INTERNAL_METADATA_FILES = frozenset(
|
|
48
|
+
{
|
|
49
|
+
"workflow-checkpoint.json",
|
|
50
|
+
"runtime-commit-request.json",
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
_PIPELINE_ARTIFACT_ROOTS = (".prizmkit/specs/", ".prizmkit/bugfix/")
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _is_runtime_internal_path(path: str) -> bool:
|
|
57
|
+
normalized = path.replace("\\", "/")
|
|
58
|
+
while normalized.startswith(("./", "/")):
|
|
59
|
+
normalized = normalized[2:] if normalized.startswith("./") else normalized[1:]
|
|
60
|
+
if any(
|
|
61
|
+
normalized == prefix or normalized.startswith(f"{prefix}/")
|
|
62
|
+
for prefix in _RUNTIME_INTERNAL_PREFIXES
|
|
63
|
+
):
|
|
64
|
+
return True
|
|
65
|
+
return normalized.startswith(_PIPELINE_ARTIFACT_ROOTS) and (
|
|
66
|
+
normalized.rsplit("/", 1)[-1] in _PIPELINE_INTERNAL_METADATA_FILES
|
|
67
|
+
)
|
|
39
68
|
|
|
40
69
|
|
|
41
70
|
@dataclass(frozen=True)
|
|
@@ -492,7 +521,7 @@ def _workspace_changed_paths(
|
|
|
492
521
|
)
|
|
493
522
|
visible = [
|
|
494
523
|
path for path in _status_record_paths(result.stdout)
|
|
495
|
-
if path not in local_paths
|
|
524
|
+
if path not in local_paths and not _is_runtime_internal_path(path)
|
|
496
525
|
]
|
|
497
526
|
return tuple(dict.fromkeys(visible)), ""
|
|
498
527
|
|
|
@@ -550,7 +579,7 @@ def _staged_bookkeeping_paths(
|
|
|
550
579
|
)
|
|
551
580
|
return tuple(
|
|
552
581
|
path for path in staged.stdout.split("\0")
|
|
553
|
-
if path and path in local_paths
|
|
582
|
+
if path and (path in local_paths or _is_runtime_internal_path(path))
|
|
554
583
|
)
|
|
555
584
|
|
|
556
585
|
|
|
@@ -563,16 +592,25 @@ def _stage_workspace(
|
|
|
563
592
|
staged = _git(project_root, "add", "-A", "--", ".")
|
|
564
593
|
if staged.return_code != 0:
|
|
565
594
|
return staged
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
595
|
+
local_paths = _runtime_bookkeeping_paths(
|
|
596
|
+
project_root,
|
|
597
|
+
checkpoint_path=checkpoint_path,
|
|
598
|
+
request_path=request_path,
|
|
599
|
+
)
|
|
600
|
+
cached = _git(project_root, "diff", "--cached", "--name-only", "--no-renames", "-z")
|
|
601
|
+
if cached.return_code != 0:
|
|
602
|
+
return cached
|
|
603
|
+
exclude_paths = sorted(
|
|
604
|
+
{
|
|
605
|
+
path
|
|
606
|
+
for path in cached.stdout.split("\0")
|
|
607
|
+
if path and (path in local_paths or _is_runtime_internal_path(path))
|
|
608
|
+
}
|
|
609
|
+
| set(local_paths)
|
|
610
|
+
)
|
|
611
|
+
if not exclude_paths:
|
|
612
|
+
return staged
|
|
613
|
+
local_pathspecs = [f":(top,literal){path}" for path in exclude_paths]
|
|
576
614
|
return _git(project_root, "reset", "-q", "HEAD", "--", *local_pathspecs)
|
|
577
615
|
|
|
578
616
|
|
|
@@ -603,7 +641,7 @@ def _workspace_has_unstaged_candidates(
|
|
|
603
641
|
path
|
|
604
642
|
for output in (unstaged.stdout, untracked.stdout)
|
|
605
643
|
for path in output.split("\0")
|
|
606
|
-
if path and path not in local_paths
|
|
644
|
+
if path and path not in local_paths and not _is_runtime_internal_path(path)
|
|
607
645
|
}
|
|
608
646
|
return bool(candidates)
|
|
609
647
|
|