prizmkit 1.1.190 → 1.1.192

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/bin/create-prizmkit.js +4 -4
  2. package/bundled/VERSION.json +3 -3
  3. package/bundled/adapters/antigravity/assets/prizmkit-hook.cjs +150 -0
  4. package/bundled/adapters/antigravity/hooks-adapter.js +195 -0
  5. package/bundled/adapters/antigravity/paths.js +14 -0
  6. package/bundled/adapters/antigravity/rules-adapter.js +54 -0
  7. package/bundled/adapters/antigravity/skill-adapter.js +38 -0
  8. package/bundled/adapters/codex/skill-adapter.js +28 -8
  9. package/bundled/adapters/cursor/skill-adapter.js +13 -4
  10. package/bundled/adapters/pi/skill-adapter.js +28 -7
  11. package/bundled/dev-pipeline/.env.example +4 -12
  12. package/bundled/dev-pipeline/README.md +21 -15
  13. package/bundled/dev-pipeline/assets/skill-subagent-integration.md +3 -6
  14. package/bundled/dev-pipeline/prizmkit_runtime/atomic_io.py +48 -0
  15. package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +66 -23
  16. package/bundled/dev-pipeline/prizmkit_runtime/cli.py +10 -7
  17. package/bundled/dev-pipeline/prizmkit_runtime/commands.py +2 -21
  18. package/bundled/dev-pipeline/prizmkit_runtime/config.py +29 -70
  19. package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +125 -67
  20. package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +89 -442
  21. package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +93 -49
  22. package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +1 -3
  23. package/bundled/dev-pipeline/prizmkit_runtime/paths.py +0 -6
  24. package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +49 -18
  25. package/bundled/dev-pipeline/prizmkit_runtime/processes.py +206 -151
  26. package/bundled/dev-pipeline/prizmkit_runtime/reset.py +2 -23
  27. package/bundled/dev-pipeline/prizmkit_runtime/reset_preserve.py +15 -134
  28. package/bundled/dev-pipeline/prizmkit_runtime/results.py +25 -0
  29. package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +68 -83
  30. package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +15 -5
  31. package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +1 -29
  32. package/bundled/dev-pipeline/prizmkit_runtime/runner_prompts.py +0 -2
  33. package/bundled/dev-pipeline/prizmkit_runtime/runner_status.py +7 -2
  34. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +282 -217
  35. package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +124 -122
  36. package/bundled/dev-pipeline/prizmkit_runtime/runtime_helper.py +90 -9
  37. package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +369 -154
  38. package/bundled/dev-pipeline/prizmkit_runtime/status.py +3 -3
  39. package/bundled/dev-pipeline/prizmkit_runtime/stream_progress.py +2780 -0
  40. package/bundled/dev-pipeline/prizmkit_runtime/task_checkout.py +27 -101
  41. package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +58 -4
  42. package/bundled/dev-pipeline/scripts/check-session-status.py +43 -19
  43. package/bundled/dev-pipeline/scripts/continuation.py +6 -4
  44. package/bundled/dev-pipeline/scripts/detect-stuck.py +28 -28
  45. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +7 -2
  46. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +7 -2
  47. package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +10 -7
  48. package/bundled/dev-pipeline/scripts/init-change-artifact.py +8 -2
  49. package/bundled/dev-pipeline/scripts/init-pipeline.py +14 -69
  50. package/bundled/dev-pipeline/scripts/parse-stream-progress.py +31 -2328
  51. package/bundled/dev-pipeline/scripts/patch-completion-notes.py +4 -24
  52. package/bundled/dev-pipeline/scripts/prompt_framework.py +56 -9
  53. package/bundled/dev-pipeline/scripts/status_common.py +591 -0
  54. package/bundled/dev-pipeline/scripts/update-bug-status.py +85 -463
  55. package/bundled/dev-pipeline/scripts/update-checkpoint.py +227 -65
  56. package/bundled/dev-pipeline/scripts/update-feature-status.py +76 -509
  57. package/bundled/dev-pipeline/scripts/utils.py +10 -15
  58. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +4 -4
  59. package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +7 -0
  60. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +1 -1
  61. package/bundled/dev-pipeline/templates/sections/artifact-manifest.md +1 -1
  62. package/bundled/dev-pipeline/templates/sections/bugfix-phase-manual-verification.md +1 -1
  63. package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +1 -1
  64. package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +2 -1
  65. package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +1 -1
  66. package/bundled/dev-pipeline/templates/sections/phase-browser-verification-auto.md +1 -1
  67. package/bundled/dev-pipeline/templates/sections/phase-browser-verification-opencli.md +2 -2
  68. package/bundled/dev-pipeline/templates/sections/phase-browser-verification.md +2 -2
  69. package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +2 -1
  70. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +1 -1
  71. package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +3 -6
  72. package/bundled/dev-pipeline/templates/session-status-schema.json +2 -5
  73. package/bundled/dev-pipeline/tests/_helpers.py +418 -0
  74. package/bundled/dev-pipeline/tests/conftest.py +45 -1
  75. package/bundled/dev-pipeline/tests/live_ai_cli_log_smoke.py +1 -0
  76. package/bundled/dev-pipeline/tests/test_auto_skip.py +4 -69
  77. package/bundled/dev-pipeline/tests/test_checkpoint_state.py +126 -1
  78. package/bundled/dev-pipeline/tests/test_daemon_and_scripts.py +257 -0
  79. package/bundled/dev-pipeline/tests/test_e2e_pipeline_run.py +500 -0
  80. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +59 -117
  81. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +12 -10
  82. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +561 -3094
  83. package/bundled/dev-pipeline/tests/test_recovery_workflow.py +7 -8
  84. package/bundled/dev-pipeline/tests/test_repository_bootstrap.py +0 -1
  85. package/bundled/dev-pipeline/tests/test_reset_modes.py +15 -27
  86. package/bundled/dev-pipeline/tests/test_reset_preserve.py +54 -139
  87. package/bundled/dev-pipeline/tests/test_runner_bookkeeping.py +766 -0
  88. package/bundled/dev-pipeline/tests/test_runner_lifecycle.py +1257 -0
  89. package/bundled/dev-pipeline/tests/test_runtime_helper.py +97 -20
  90. package/bundled/dev-pipeline/tests/test_session_launch.py +1101 -0
  91. package/bundled/dev-pipeline/tests/test_stream_progress.py +585 -0
  92. package/bundled/dev-pipeline/tests/test_unified_cli.py +490 -2006
  93. package/bundled/dev-pipeline/tests/test_utils.py +3 -3
  94. package/bundled/rules/USAGE.md +1 -0
  95. package/bundled/skills/_metadata.json +9 -63
  96. package/bundled/skills/app-planner/SKILL.md +32 -303
  97. package/bundled/skills/app-planner/references/app-design-guide.md +0 -4
  98. package/bundled/skills/app-planner/references/generated-plan-review.md +2 -1
  99. package/bundled/skills/app-planner/references/project-brief-guide.md +14 -0
  100. package/bundled/skills/app-planner/references/project-conventions-discovery.md +4 -6
  101. package/bundled/skills/app-planner/references/project-state-detection.md +2 -3
  102. package/bundled/skills/bug-fix-workflow/SKILL.md +1 -2
  103. package/bundled/skills/bug-fix-workflow/references/bug-diagnosis.md +4 -7
  104. package/bundled/skills/bug-planner/SKILL.md +54 -435
  105. package/bundled/skills/bug-planner/references/generated-plan-review.md +3 -2
  106. package/bundled/skills/bug-planner/references/input-formats.md +32 -0
  107. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +4 -6
  108. package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +4 -28
  109. package/bundled/skills/feature-pipeline-launcher/SKILL.md +4 -6
  110. package/bundled/skills/feature-pipeline-launcher/references/configuration.md +4 -28
  111. package/bundled/skills/feature-planner/SKILL.md +60 -439
  112. package/bundled/skills/feature-planner/assets/planning-guide.md +1 -1
  113. package/bundled/skills/feature-planner/references/completeness-review.md +34 -0
  114. package/bundled/skills/feature-planner/references/decomposition-patterns.md +2 -2
  115. package/bundled/skills/feature-planner/references/error-recovery.md +1 -1
  116. package/bundled/skills/feature-planner/references/generated-plan-review.md +3 -2
  117. package/bundled/skills/feature-planner/references/incremental-feature-planning.md +3 -1
  118. package/bundled/skills/feature-workflow/SKILL.md +1 -2
  119. package/bundled/skills/prizmkit/SKILL.md +7 -1
  120. package/bundled/skills/prizmkit-code-review/SKILL.md +14 -6
  121. package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +7 -4
  122. package/bundled/skills/prizmkit-code-review/references/review-report-template.md +16 -0
  123. package/bundled/skills/prizmkit-code-review/scripts/render_review_report.py +58 -20
  124. package/bundled/skills/prizmkit-implement/SKILL.md +1 -1
  125. package/bundled/skills/prizmkit-init/SKILL.md +25 -128
  126. package/bundled/skills/prizmkit-init/assets/project-brief-template.md +3 -3
  127. package/bundled/skills/prizmkit-init/references/config-schema.md +2 -2
  128. package/bundled/skills/prizmkit-plan/SKILL.md +6 -8
  129. package/bundled/skills/prizmkit-plan/references/clarify-guide.md +1 -1
  130. package/bundled/skills/prizmkit-plan/references/independent-plan-review.md +5 -2
  131. package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +6 -5
  132. package/bundled/skills/prizmkit-prizm-docs/SKILL.md +1 -13
  133. package/bundled/skills/prizmkit-prizm-docs/assets/prizm-docs-format.md +1 -1
  134. package/bundled/skills/prizmkit-prizm-docs/references/op-init.md +1 -1
  135. package/bundled/skills/prizmkit-prizm-docs/references/op-update.md +1 -1
  136. package/bundled/skills/prizmkit-retrospective/SKILL.md +6 -4
  137. package/bundled/skills/prizmkit-test/SKILL.md +25 -133
  138. package/bundled/skills/prizmkit-test/references/independent-test-review.md +5 -2
  139. package/bundled/skills/prizmkit-test/references/test-coverage-model.md +6 -0
  140. package/bundled/skills/prizmkit-workflow/SKILL.md +2 -3
  141. package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +4 -3
  142. package/bundled/skills/recovery-workflow/SKILL.md +7 -7
  143. package/bundled/skills/recovery-workflow/evals/evals.json +1 -1
  144. package/bundled/skills/recovery-workflow/references/detection.md +1 -3
  145. package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +0 -6
  146. package/bundled/templates/project-memory-template.md +1 -2
  147. package/package.json +1 -1
  148. package/src/ai-cli-launch.js +1 -1
  149. package/src/clean.js +40 -4
  150. package/src/config.js +64 -4
  151. package/src/detect-platform.js +10 -6
  152. package/src/external-skills.js +2 -2
  153. package/src/index.js +1 -0
  154. package/src/manifest.js +1 -1
  155. package/src/platforms.js +6 -2
  156. package/src/prompts.js +11 -3
  157. package/src/scaffold.js +87 -11
  158. package/src/upgrade.js +9 -3
  159. package/bundled/dev-pipeline/SCHEMA_ANALYSIS.md +0 -53
  160. package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +0 -649
  161. package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +0 -463
  162. package/bundled/dev-pipeline/scripts/update-refactor-status.py +0 -1512
  163. package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +0 -240
  164. package/bundled/dev-pipeline/templates/refactor-list-schema.json +0 -266
  165. package/bundled/dev-pipeline/templates/sections/refactor-critical-paths.md +0 -15
  166. package/bundled/dev-pipeline/templates/sections/refactor-mission.md +0 -9
  167. package/bundled/dev-pipeline/templates/sections/refactor-phase-commit-report.md +0 -24
  168. package/bundled/dev-pipeline/templates/sections/refactor-phase-implement.md +0 -16
  169. package/bundled/dev-pipeline/templates/sections/refactor-phase-init.md +0 -9
  170. package/bundled/dev-pipeline/templates/sections/refactor-phase-plan.md +0 -22
  171. package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +0 -19
  172. package/bundled/dev-pipeline/templates/sections/refactor-phase-test.md +0 -24
  173. package/bundled/dev-pipeline/templates/sections/refactor-reminders.md +0 -12
  174. package/bundled/dev-pipeline/templates/sections/refactor-session-context.md +0 -6
  175. package/bundled/dev-pipeline/templates/sections/refactor-task-contract.md +0 -52
  176. package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +0 -478
  177. package/bundled/skills/feature-planner/assets/evaluation-guide.md +0 -44
  178. package/bundled/skills/refactor-pipeline-launcher/SKILL.md +0 -219
  179. package/bundled/skills/refactor-pipeline-launcher/references/configuration.md +0 -78
  180. package/bundled/skills/refactor-planner/SKILL.md +0 -467
  181. package/bundled/skills/refactor-planner/assets/planning-guide.md +0 -291
  182. package/bundled/skills/refactor-planner/references/behavior-preservation.md +0 -187
  183. package/bundled/skills/refactor-planner/references/error-recovery.md +0 -45
  184. package/bundled/skills/refactor-planner/references/fast-path.md +0 -59
  185. package/bundled/skills/refactor-planner/references/generated-plan-review.md +0 -107
  186. package/bundled/skills/refactor-planner/references/planning-phases.md +0 -172
  187. package/bundled/skills/refactor-planner/references/refactor-scoping-guide.md +0 -230
  188. package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +0 -1120
  189. package/bundled/skills/refactor-workflow/SKILL.md +0 -205
@@ -6,7 +6,6 @@ import copy
6
6
  import json
7
7
  import os
8
8
  import shlex
9
- import shutil
10
9
  import tempfile
11
10
  import time
12
11
  from contextlib import ExitStack
@@ -19,19 +18,13 @@ from .checkpoint_state import (
19
18
  rewind_checkpoint_for_implementation,
20
19
  )
21
20
  from .gitops import (
22
- BranchContext,
23
- WorktreePolicy,
24
- WorktreeRuntimeContext,
25
21
  create_branch_from_base,
26
- ensure_linked_worktree,
27
22
  local_branch_exists,
28
23
  registered_worktrees,
29
- worktree_runtime_context,
30
24
  )
31
25
  from .runner_models import RunnerFamily
32
26
  from .task_checkout import (
33
27
  CHECKOUT_MODE_BRANCH,
34
- CHECKOUT_MODE_WORKTREE,
35
28
  TaskCheckout,
36
29
  TaskCheckoutError,
37
30
  load_task_checkout,
@@ -71,7 +64,6 @@ class RootRecovery:
71
64
  status_path: Path
72
65
  status_data: dict[str, Any]
73
66
  replacement_checkout: TaskCheckout | None = None
74
- replacement_worktree: WorktreeRuntimeContext | None = None
75
67
  source_artifact: Path | None = None
76
68
  target_artifact: Path | None = None
77
69
  checkpoint_target: Path | None = None
@@ -98,7 +90,7 @@ class PreserveRuntimeResetResult:
98
90
  if self.no_targets:
99
91
  return (
100
92
  f"No failed {family.kind} tasks require preserve-runtime recovery.",
101
- "No plan, status, checkout, checkpoint, branch, worktree, session, or artifact state changed.",
93
+ "No plan, status, checkout, checkpoint, branch, session, or artifact state changed.",
102
94
  )
103
95
  if not self.ok:
104
96
  return (
@@ -123,7 +115,7 @@ class PreserveRuntimeResetResult:
123
115
  lines.append(f"Replacement checkout: {item_id}: {old_branch} -> {new_branch}")
124
116
  lines.extend(
125
117
  (
126
- "Existing sessions, checkpoints, artifacts, branches, worktrees, and task work were not deleted.",
118
+ "Existing sessions, checkpoints, artifacts, branches, and task work were not deleted.",
127
119
  "Reset did not start a runner. Run separately:",
128
120
  "python3 ./.prizmkit/dev-pipeline/cli.py "
129
121
  f"run {family.kind} {shlex.quote(str(list_path))}",
@@ -400,40 +392,7 @@ def _preflight_root(
400
392
  if registration.branch == checkout.active_dev_branch
401
393
  ]
402
394
  execution_root = project_root
403
- old_runtime: WorktreeRuntimeContext | None = None
404
- if checkout.checkout_mode == CHECKOUT_MODE_WORKTREE:
405
- recorded_worktree = Path(checkout.worktree_path).resolve()
406
- old_runtime = worktree_runtime_context(
407
- BranchContext(
408
- checkout.base_branch,
409
- checkout.active_dev_branch,
410
- project_root,
411
- ),
412
- WorktreePolicy(True, True, True, recorded_worktree.parent),
413
- )
414
- if not old_runtime.is_cleanup_path_safe() or old_runtime.worktree_path != recorded_worktree:
415
- blockers.append(
416
- f"{item.item_id}: recorded worktree path is unsafe or inconsistent: {recorded_worktree}"
417
- )
418
- execution_root = recorded_worktree
419
- if branch_exists:
420
- if not recorded_worktree.is_dir():
421
- blockers.append(
422
- f"{item.item_id}: recorded worktree directory is missing: {recorded_worktree}"
423
- )
424
- if not any(
425
- registration.path == recorded_worktree
426
- and registration.branch == checkout.active_dev_branch
427
- for registration in registrations
428
- ):
429
- blockers.append(
430
- f"{item.item_id}: recorded branch/worktree registration is inconsistent"
431
- )
432
- elif any(registration.path == recorded_worktree for registration in registrations):
433
- blockers.append(
434
- f"{item.item_id}: missing branch still has a conflicting registered worktree"
435
- )
436
- elif checkout.checkout_mode == CHECKOUT_MODE_BRANCH:
395
+ if checkout.checkout_mode == CHECKOUT_MODE_BRANCH:
437
396
  if branch_exists and any(
438
397
  registration.path != project_root.resolve()
439
398
  for registration in active_registration
@@ -447,16 +406,13 @@ def _preflight_root(
447
406
  )
448
407
 
449
408
  replacement_checkout: TaskCheckout | None = None
450
- replacement_worktree: WorktreeRuntimeContext | None = None
451
409
  if not branch_exists and not blockers:
452
410
  try:
453
- replacement_branch, replacement_worktree = _replacement_identity(
411
+ replacement_branch = _replacement_identity(
454
412
  family,
455
413
  item,
456
- checkout,
457
414
  project_root,
458
415
  registrations,
459
- old_runtime,
460
416
  )
461
417
  replacement_checkout = TaskCheckout.active(
462
418
  family.task_type,
@@ -464,11 +420,6 @@ def _preflight_root(
464
420
  replacement_branch,
465
421
  checkout.base_branch,
466
422
  checkout_mode=checkout.checkout_mode,
467
- worktree_path=(
468
- str(replacement_worktree.worktree_path)
469
- if replacement_worktree is not None
470
- else ""
471
- ),
472
423
  )
473
424
  except (TaskCheckoutError, ValueError) as exc:
474
425
  blockers.append(str(exc))
@@ -496,37 +447,16 @@ def _preflight_root(
496
447
  )
497
448
 
498
449
  source_artifact: Path | None = None
499
- target_artifact = _artifact_path(family, item, execution_root)
450
+ target_artifact = _artifact_path(family, item, project_root)
500
451
  checkpoint_target: Path | None = None
501
452
  checkpoint_data: dict[str, Any] | None = None
502
453
  if replacement_checkout is not None and not blockers:
503
- if checkout.checkout_mode == CHECKOUT_MODE_WORKTREE:
504
- source_artifact = _existing_artifact_source(
505
- family,
506
- item,
507
- execution_root,
508
- project_root,
509
- )
510
- if replacement_worktree is None:
511
- blockers.append(f"{item.item_id}: replacement worktree was not resolved")
512
- else:
513
- target_artifact = _artifact_path(
514
- family,
515
- item,
516
- replacement_worktree.worktree_path,
517
- )
518
- if target_artifact.exists():
519
- blockers.append(
520
- f"{item.item_id}: replacement artifact destination already exists: {target_artifact}"
521
- )
522
- else:
523
- source_artifact = _existing_artifact_source(
524
- family,
525
- item,
526
- project_root,
527
- project_root,
528
- )
529
- target_artifact = _artifact_path(family, item, project_root)
454
+ source_artifact = _existing_artifact_source(
455
+ family,
456
+ item,
457
+ project_root,
458
+ project_root,
459
+ )
530
460
 
531
461
  source_checkpoint = (
532
462
  source_artifact / "workflow-checkpoint.json"
@@ -540,11 +470,7 @@ def _preflight_root(
540
470
  checkpoint_data = rewind_checkpoint_for_implementation(
541
471
  source_data,
542
472
  path=checkpoint_target,
543
- project_root=(
544
- replacement_worktree.worktree_path
545
- if replacement_worktree is not None
546
- else project_root
547
- ),
473
+ project_root=project_root,
548
474
  )
549
475
  except (OSError, json.JSONDecodeError, ValueError) as exc:
550
476
  blockers.append(
@@ -560,7 +486,6 @@ def _preflight_root(
560
486
  status_path=status_path,
561
487
  status_data=status_data,
562
488
  replacement_checkout=replacement_checkout,
563
- replacement_worktree=replacement_worktree,
564
489
  source_artifact=source_artifact,
565
490
  target_artifact=target_artifact,
566
491
  checkpoint_target=checkpoint_target,
@@ -573,35 +498,17 @@ def _preflight_root(
573
498
  def _replacement_identity(
574
499
  family: RunnerFamily,
575
500
  item: PreservePlanItem,
576
- checkout: TaskCheckout,
577
501
  project_root: Path,
578
502
  registrations,
579
- old_runtime: WorktreeRuntimeContext | None,
580
- ) -> tuple[str, WorktreeRuntimeContext | None]:
503
+ ) -> str:
581
504
  stamp = time.strftime("%Y%m%d%H%M%S", time.gmtime())
582
- worktree_root = old_runtime.worktree_root if old_runtime is not None else None
583
505
  registered_branches = {registration.branch for registration in registrations}
584
- registered_paths = {registration.path for registration in registrations}
585
506
  for suffix in range(1000):
586
507
  ending = "" if suffix == 0 else f"-{suffix}"
587
508
  branch = f"{family.branch_prefix}/{item.item_id}-resume-{stamp}{ending}"
588
509
  if local_branch_exists(project_root, branch) or branch in registered_branches:
589
510
  continue
590
- runtime = None
591
- if checkout.checkout_mode == CHECKOUT_MODE_WORKTREE:
592
- if worktree_root is None:
593
- continue
594
- runtime = worktree_runtime_context(
595
- BranchContext(checkout.base_branch, branch, project_root),
596
- WorktreePolicy(True, True, True, worktree_root),
597
- )
598
- if (
599
- not runtime.is_cleanup_path_safe()
600
- or runtime.worktree_path.exists()
601
- or runtime.worktree_path.resolve() in registered_paths
602
- ):
603
- continue
604
- return branch, runtime
511
+ return branch
605
512
  raise ValueError(f"{item.item_id}: cannot allocate a collision-safe replacement checkout")
606
513
 
607
514
 
@@ -661,20 +568,13 @@ def _writability_blockers(
661
568
  f"{recovery.item.item_id} checkout identity",
662
569
  ),
663
570
  ]
664
- if recovery.checkpoint_target is not None and recovery.replacement_worktree is None:
571
+ if recovery.checkpoint_target is not None:
665
572
  checks.append(
666
573
  (
667
574
  recovery.checkpoint_target,
668
575
  f"{recovery.item.item_id} workflow checkpoint",
669
576
  )
670
577
  )
671
- if recovery.replacement_worktree is not None:
672
- checks.append(
673
- (
674
- recovery.replacement_worktree.worktree_root,
675
- f"{recovery.item.item_id} replacement worktree root",
676
- )
677
- )
678
578
  for path, label in checks:
679
579
  if not _path_writable(path):
680
580
  blockers.append(f"{label} is not writable: {path}")
@@ -711,25 +611,6 @@ def _apply_recovery(
711
611
  raise RuntimeError(
712
612
  f"{recovery.item.item_id}: replacement branch creation failed: {detail or 'unknown Git error'}"
713
613
  )
714
- if recovery.replacement_worktree is not None:
715
- setup = ensure_linked_worktree(recovery.replacement_worktree)
716
- if not setup.ok:
717
- detail = "; ".join(
718
- result.stderr.strip() or result.stdout.strip()
719
- for result in setup.results
720
- if result.return_code != 0
721
- )
722
- raise RuntimeError(
723
- f"{recovery.item.item_id}: replacement worktree creation failed: "
724
- f"{detail or setup.reason}"
725
- )
726
- if recovery.source_artifact is not None and recovery.target_artifact is not None:
727
- recovery.target_artifact.parent.mkdir(parents=True, exist_ok=True)
728
- shutil.copytree(
729
- recovery.source_artifact,
730
- recovery.target_artifact,
731
- symlinks=True,
732
- )
733
614
 
734
615
  for recovery in recoveries:
735
616
  if recovery.checkpoint_target is not None and recovery.checkpoint_data is not None:
@@ -0,0 +1,25 @@
1
+ """Shared command result model for canonical runtime handlers."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+
7
+
8
+ @dataclass(frozen=True)
9
+ class CommandResult:
10
+ """Result returned by runtime command handlers."""
11
+
12
+ exit_code: int
13
+ title: str
14
+ message: str
15
+ details: tuple[str, ...] = ()
16
+ stdout: str | None = None
17
+ stderr: str | None = None
18
+
19
+ def render(self) -> str:
20
+ """Render a deterministic human-readable result."""
21
+ if self.stdout is not None:
22
+ return self.stdout
23
+ lines = [self.title, self.message]
24
+ lines.extend(self.details)
25
+ return "\n".join(line for line in lines if line)
@@ -8,14 +8,17 @@ legacy ordering around branch creation and final status updates.
8
8
  from __future__ import annotations
9
9
 
10
10
  import json
11
- from collections.abc import Sequence
11
+ from collections.abc import Mapping, Sequence
12
12
  from dataclasses import dataclass
13
13
  from pathlib import Path
14
14
 
15
+ from .atomic_io import write_text_atomic
15
16
  from .gitops import (
16
17
  UNTRACKED_TRANSIENT_EXCLUDES,
17
18
  GitCommandResult,
18
19
  addable_task_paths,
20
+ literal_pathspecs,
21
+ parse_status_record_paths,
19
22
  run_git_command,
20
23
  visible_task_paths,
21
24
  )
@@ -88,48 +91,6 @@ def _unique_paths(paths: Sequence[str]) -> tuple[str, ...]:
88
91
  return tuple(dict.fromkeys(path for path in paths if path))
89
92
 
90
93
 
91
- def _literal_pathspecs(paths: Sequence[str]) -> tuple[str, ...]:
92
- return tuple(f":(top,literal){path}" for path in paths)
93
-
94
-
95
- def _preflight_add_paths(
96
- project_root: Path,
97
- paths: Sequence[str],
98
- ) -> tuple[tuple[str, ...], GitCommandResult | None]:
99
- """Skip paths already staged as deletions while retaining exact path handling."""
100
- indexed_result = run_git_command(project_root, ("ls-files", "-z", "--", *_literal_pathspecs(paths)))
101
- if indexed_result.return_code != 0:
102
- return (), indexed_result
103
- indexed = set(indexed_result.stdout.split("\0"))
104
- add_paths = tuple(
105
- path
106
- for path in paths
107
- if path in indexed or (project_root / path).exists() or (project_root / path).is_symlink()
108
- )
109
- return add_paths, None
110
-
111
-
112
- def _status_record_paths(stdout: str) -> tuple[str, ...]:
113
- """Decode exact paths from NUL-delimited porcelain-v1 records."""
114
- records = stdout.split("\0")
115
- changed: list[str] = []
116
- index = 0
117
- while index < len(records):
118
- record = records[index]
119
- index += 1
120
- if not record:
121
- continue
122
- if len(record) < 4 or record[2] != " ":
123
- continue
124
- status = record[:2]
125
- changed.append(record[3:])
126
- if "R" in status or "C" in status:
127
- if index < len(records) and records[index]:
128
- changed.append(records[index])
129
- index += 1
130
- return _unique_paths(changed)
131
-
132
-
133
94
  def _preflight_workspace(project_root: Path) -> tuple[PreflightWorkspace | None, GitCommandResult | None]:
134
95
  tracked_result = _tracked_status_result(project_root)
135
96
  if tracked_result.return_code != 0:
@@ -138,7 +99,7 @@ def _preflight_workspace(project_root: Path) -> tuple[PreflightWorkspace | None,
138
99
  if untracked_result.return_code != 0:
139
100
  return None, untracked_result
140
101
 
141
- tracked = _status_record_paths(tracked_result.stdout)
102
+ tracked = parse_status_record_paths(tracked_result.stdout)
142
103
  visible_untracked = _unique_paths(untracked_result.stdout.split("\0"))
143
104
  unsafe_local = tuple(path for path in tracked if path in LOCAL_ONLY_PLATFORM_PATHS)
144
105
  return PreflightWorkspace(tracked, visible_untracked, unsafe_local), None
@@ -202,10 +163,6 @@ def _remaining_preflight_changes(project_root: Path) -> GitCommandResult:
202
163
  )
203
164
 
204
165
 
205
- def _visible_status_result(project_root: Path) -> GitCommandResult:
206
- return run_git_command(project_root, ("status", "--porcelain", "--", "."))
207
-
208
-
209
166
  def _paths_from_status(stdout: str) -> tuple[str, ...]:
210
167
  changed: list[str] = []
211
168
  seen: set[str] = set()
@@ -264,12 +221,12 @@ def commit_preflight_ready_changes(project_root: Path, item_id: str) -> Bookkeep
264
221
  paths = workspace.preservable
265
222
  if not paths:
266
223
  return BookkeepingResult(attempted=False, committed=False)
267
- pathspecs = _literal_pathspecs(paths)
268
- add_paths, add_paths_failure = _preflight_add_paths(project_root, paths)
269
- if add_paths_failure is not None:
270
- return BookkeepingResult(attempted=True, committed=False, result=add_paths_failure)
224
+ pathspecs = literal_pathspecs(paths)
225
+ add_paths, add_paths_result = addable_task_paths(project_root, paths)
226
+ if add_paths_result.return_code != 0:
227
+ return BookkeepingResult(attempted=True, committed=False, result=add_paths_result)
271
228
  if add_paths:
272
- add_result = run_git_command(project_root, ("add", "-A", "-f", "--", *_literal_pathspecs(add_paths)))
229
+ add_result = run_git_command(project_root, ("add", "-A", "-f", "--", *literal_pathspecs(add_paths)))
273
230
  if add_result.return_code != 0:
274
231
  return BookkeepingResult(attempted=True, committed=False, result=add_result)
275
232
  result = run_git_command(
@@ -284,16 +241,7 @@ def commit_preflight_ready_changes(project_root: Path, item_id: str) -> Bookkeep
284
241
  return BookkeepingResult(attempted=True, committed=True, result=result)
285
242
 
286
243
 
287
- def commit_task_branch_changes(
288
- project_root: Path,
289
- family: RunnerFamily,
290
- item_id: str,
291
- status: str,
292
- ) -> BookkeepingResult:
293
- """Commit task branch code, artifacts, and status without switching branches."""
294
- message = f"chore({item_id}): save {family.kind} {status} state"
295
- if status == "completed":
296
- message = f"chore({item_id}): complete {family.kind} task"
244
+ def _commit_visible_task_paths(project_root: Path, commit_message_args: tuple[str, ...]) -> BookkeepingResult:
297
245
  paths, status_result = visible_task_paths(project_root)
298
246
  if status_result.return_code != 0:
299
247
  return BookkeepingResult(attempted=True, committed=False, result=status_result)
@@ -303,16 +251,29 @@ def commit_task_branch_changes(
303
251
  if indexed_result.return_code != 0:
304
252
  return BookkeepingResult(attempted=True, committed=False, result=indexed_result)
305
253
  if add_paths:
306
- add_result = run_git_command(project_root, ("add", "-A", "--", *_literal_pathspecs(add_paths)))
254
+ add_result = run_git_command(project_root, ("add", "-A", "--", *literal_pathspecs(add_paths)))
307
255
  if add_result.return_code != 0:
308
256
  return BookkeepingResult(attempted=True, committed=False, result=add_result)
309
257
  result = run_git_command(
310
258
  project_root,
311
- ("commit", "--no-verify", "-m", message, "--", *_literal_pathspecs(paths)),
259
+ ("commit", "--no-verify", *commit_message_args, "--", *literal_pathspecs(paths)),
312
260
  )
313
261
  return BookkeepingResult(attempted=True, committed=result.return_code == 0, result=result)
314
262
 
315
263
 
264
+ def commit_task_branch_changes(
265
+ project_root: Path,
266
+ family: RunnerFamily,
267
+ item_id: str,
268
+ status: str,
269
+ ) -> BookkeepingResult:
270
+ """Commit task branch code, artifacts, and status without switching branches."""
271
+ message = f"chore({item_id}): save {family.kind} {status} state"
272
+ if status == "completed":
273
+ message = f"chore({item_id}): complete {family.kind} task"
274
+ return _commit_visible_task_paths(project_root, ("-m", message))
275
+
276
+
316
277
  def commit_wip_changes(
317
278
  project_root: Path,
318
279
  family: RunnerFamily,
@@ -320,32 +281,15 @@ def commit_wip_changes(
320
281
  status: str,
321
282
  ) -> BookkeepingResult:
322
283
  """Commit all Git-visible task-branch changes as preserved WIP."""
323
- paths, status_result = visible_task_paths(project_root)
324
- if status_result.return_code != 0:
325
- return BookkeepingResult(attempted=True, committed=False, result=status_result)
326
- if not paths:
327
- return BookkeepingResult(attempted=False, committed=False)
328
- add_paths, indexed_result = addable_task_paths(project_root, paths)
329
- if indexed_result.return_code != 0:
330
- return BookkeepingResult(attempted=True, committed=False, result=indexed_result)
331
- if add_paths:
332
- add_result = run_git_command(project_root, ("add", "-A", "--", *_literal_pathspecs(add_paths)))
333
- if add_result.return_code != 0:
334
- return BookkeepingResult(attempted=True, committed=False, result=add_result)
335
- result = run_git_command(
284
+ return _commit_visible_task_paths(
336
285
  project_root,
337
286
  (
338
- "commit",
339
- "--no-verify",
340
287
  "-m",
341
288
  f"wip({item_id}): preserve {family.kind} {status} state",
342
289
  "-m",
343
290
  "Pipeline preserved task branch work without merging it to the base branch.",
344
- "--",
345
- *_literal_pathspecs(paths),
346
291
  ),
347
292
  )
348
- return BookkeepingResult(attempted=True, committed=result.return_code == 0, result=result)
349
293
 
350
294
 
351
295
  def commit_pre_branch_bookkeeping(project_root: Path, family: RunnerFamily, item_id: str) -> BookkeepingResult:
@@ -356,3 +300,44 @@ def commit_pre_branch_bookkeeping(project_root: Path, family: RunnerFamily, item
356
300
  def commit_final_bookkeeping(project_root: Path, family: RunnerFamily, item_id: str, status: str) -> BookkeepingResult:
357
301
  """Commit final runner-owned status changes on the current task branch."""
358
302
  return commit_bookkeeping_changes(project_root, family, item_id, f"chore({item_id}): update {family.kind} status {status}")
303
+
304
+
305
+ def sync_terminal_failure_bookkeeping_to_base(
306
+ project_root: Path,
307
+ family: RunnerFamily,
308
+ item_id: str,
309
+ status: str,
310
+ snapshots: Mapping[Path, str],
311
+ ) -> BookkeepingResult:
312
+ """Persist and commit terminal failure bookkeeping on the returned base branch."""
313
+ if not snapshots:
314
+ return BookkeepingResult(attempted=False, committed=False)
315
+ resolved_root = project_root.resolve()
316
+ synced_rel_paths: list[str] = []
317
+ for path, text in snapshots.items():
318
+ if path.is_file():
319
+ try:
320
+ if path.read_text(encoding="utf-8") == text:
321
+ continue
322
+ except OSError:
323
+ pass
324
+ write_text_atomic(path, text)
325
+ try:
326
+ rel = path.resolve().relative_to(resolved_root).as_posix()
327
+ except ValueError:
328
+ continue
329
+ synced_rel_paths.append(rel)
330
+ if not synced_rel_paths:
331
+ return BookkeepingResult(attempted=False, committed=False)
332
+ changed = _changed_paths_in(project_root, synced_rel_paths)
333
+ if not changed:
334
+ return BookkeepingResult(attempted=False, committed=False)
335
+ pathspecs = literal_pathspecs(changed)
336
+ add = run_git_command(project_root, ("add", "-A", "--", *pathspecs))
337
+ if add.return_code != 0:
338
+ return BookkeepingResult(attempted=True, committed=False, result=add)
339
+ commit = run_git_command(
340
+ project_root,
341
+ ("commit", "--no-verify", "-m", f"chore({item_id}): record {family.kind} status {status}", "--", *pathspecs),
342
+ )
343
+ return BookkeepingResult(attempted=True, committed=commit.return_code == 0, result=commit)
@@ -46,12 +46,13 @@ def classify_session(
46
46
  prompt: PromptGenerationResult | None = None,
47
47
  previous_fingerprint: object | None = None,
48
48
  previous_no_progress_count: int = 0,
49
+ stream_json: bool = True,
49
50
  ) -> SessionClassification:
50
51
  """Classify raw AI session signals using semantic checkpoint authority."""
51
52
  fingerprint = progress_fingerprint(project_root, prompt)
52
53
  checkpoint = _workflow_checkpoint(prompt, project_root)
53
54
  if checkpoint is not None and not checkpoint.valid:
54
- session_status = WORKFLOW_SKIPPED if _is_terminal_success(result) else "crashed"
55
+ session_status = WORKFLOW_SKIPPED if _is_terminal_success(result, stream_json=stream_json) else "crashed"
55
56
  return SessionClassification(
56
57
  session_status,
57
58
  reason=f"invalid_workflow_checkpoint:{checkpoint.error_code}",
@@ -76,7 +77,7 @@ def classify_session(
76
77
  progress_fingerprint=fingerprint,
77
78
  checkpoint_state=checkpoint.semantic_snapshot,
78
79
  )
79
- if _is_terminal_success(result) and checkpoint is not None and checkpoint.semantic_complete:
80
+ if _is_terminal_success(result, stream_json=stream_json) and checkpoint is not None and checkpoint.semantic_complete:
80
81
  return SessionClassification(
81
82
  "success",
82
83
  reason="terminal_success_with_semantic_checkpoint",
@@ -111,7 +112,16 @@ def classify_session(
111
112
  no_progress_count=no_progress_count,
112
113
  checkpoint_state=semantic,
113
114
  )
114
- if _is_terminal_success(result):
115
+ if _is_terminal_success(result, stream_json=stream_json):
116
+ if checkpoint is not None and checkpoint.valid:
117
+ failed_step = next((step for step in checkpoint.steps if step.status == "failed"), None)
118
+ if failed_step is not None:
119
+ return SessionClassification(
120
+ WORKFLOW_BLOCKED,
121
+ reason=f"failed_checkpoint_step:{failed_step.id}",
122
+ progress_fingerprint=fingerprint,
123
+ checkpoint_state=semantic,
124
+ )
115
125
  reason = "no_semantic_completion"
116
126
  if checkpoint is not None and checkpoint.semantic.error_code:
117
127
  reason = f"{reason}:{checkpoint.semantic.error_code}"
@@ -172,14 +182,14 @@ def progress_fingerprint(project_root: Path, prompt: PromptGenerationResult | No
172
182
  }
173
183
 
174
184
 
175
- def _is_terminal_success(result: AISessionResult) -> bool:
185
+ def _is_terminal_success(result: AISessionResult, *, stream_json: bool = True) -> bool:
176
186
  return (
177
187
  result.exit_code in (0, None)
178
188
  and not result.timed_out
179
189
  and result.termination_reason not in {"timeout", "stale_session"}
180
190
  and not result.fatal_error_code
181
191
  and not result.progress_summary.fatal_error_code
182
- and result.progress_summary.result_subtype == "success"
192
+ and (not stream_json or result.progress_summary.result_subtype == "success")
183
193
  )
184
194
 
185
195
 
@@ -37,7 +37,6 @@ class RunnerEnvironment:
37
37
 
38
38
  stop_on_failure: bool = False
39
39
  auto_push: bool = False
40
- use_worktree: bool = False
41
40
  dev_branch: str = ""
42
41
  verbose: bool = False
43
42
  live_output: bool = True
@@ -45,7 +44,6 @@ class RunnerEnvironment:
45
44
  heartbeat_stale_threshold_seconds: int = 600
46
45
  stale_kill_threshold_seconds: int = 600
47
46
  max_retries: int = 3
48
- strict_behavior_check: bool = True
49
47
 
50
48
  @classmethod
51
49
  def from_env(cls, env: Mapping[str, str] | None = None) -> "RunnerEnvironment":
@@ -53,7 +51,6 @@ class RunnerEnvironment:
53
51
  return cls(
54
52
  stop_on_failure=_truthy(values.get("STOP_ON_FAILURE")),
55
53
  auto_push=_truthy(values.get("AUTO_PUSH")),
56
- use_worktree=_truthy(values.get("USE_WORKTREE")),
57
54
  dev_branch=values.get("DEV_BRANCH", ""),
58
55
  verbose=_truthy(values.get("VERBOSE")),
59
56
  live_output=not _falsey(values.get("PRIZMKIT_LIVE_OUTPUT")),
@@ -65,7 +62,6 @@ class RunnerEnvironment:
65
62
  ),
66
63
  stale_kill_threshold_seconds=_int_value(values, "STALE_KILL_THRESHOLD", 600),
67
64
  max_retries=max(0, _int_value(values, "MAX_RETRIES", 3)),
68
- strict_behavior_check=not _falsey(values.get("STRICT_BEHAVIOR_CHECK")),
69
65
  )
70
66
 
71
67
 
@@ -80,8 +76,6 @@ class RunnerInvocation:
80
76
  max_retries: int | None = None
81
77
  max_infra_retries: int = 3
82
78
  dry_run: bool = False
83
- clean: bool = False
84
- no_reset: bool = False
85
79
  resume_phase: str = "null"
86
80
  help_requested: bool = False
87
81
  unknown_args: tuple[str, ...] = ()
@@ -208,7 +202,7 @@ class PipelineRunResult:
208
202
  details: tuple[str, ...] = ()
209
203
 
210
204
 
211
- FAMILY_KINDS = ("feature", "bugfix", "refactor")
205
+ FAMILY_KINDS = ("feature", "bugfix")
212
206
 
213
207
 
214
208
  def family_for(kind: str, paths: RuntimePaths) -> RunnerFamily:
@@ -242,20 +236,6 @@ def family_for(kind: str, paths: RuntimePaths) -> RunnerFamily:
242
236
  branch_prefix="bugfix",
243
237
  artifact_root_name="bugfix",
244
238
  )
245
- if kind == "refactor":
246
- return RunnerFamily(
247
- kind="refactor",
248
- id_prefix="R-",
249
- list_key="refactors",
250
- list_arg="--refactor-list",
251
- item_id_arg="--refactor-id",
252
- state_dir=paths.refactor_state_dir,
253
- plan_path=paths.refactor_plan,
254
- updater_script=script_dir / "update-refactor-status.py",
255
- prompt_script=script_dir / "generate-refactor-prompt.py",
256
- branch_prefix="refactor",
257
- artifact_root_name="refactor",
258
- )
259
239
  raise ValueError(f"Unsupported runner family: {kind}")
260
240
 
261
241
 
@@ -272,8 +252,6 @@ def parse_invocation(
272
252
  max_retries: int | None = None
273
253
  max_infra_retries = 3
274
254
  dry_run = False
275
- clean = False
276
- no_reset = False
277
255
  resume_phase = "null"
278
256
  unknown: list[str] = []
279
257
  positional: list[str] = []
@@ -286,10 +264,6 @@ def parse_invocation(
286
264
  help_requested = True
287
265
  elif arg == "--dry-run":
288
266
  dry_run = True
289
- elif arg == "--clean":
290
- clean = True
291
- elif arg == "--no-reset":
292
- no_reset = True
293
267
  elif arg == "--features" and index + 1 < len(args):
294
268
  index += 1
295
269
  item_filter = args[index]
@@ -332,8 +306,6 @@ def parse_invocation(
332
306
  max_retries=max_retries,
333
307
  max_infra_retries=max_infra_retries,
334
308
  dry_run=dry_run,
335
- clean=clean,
336
- no_reset=no_reset,
337
309
  resume_phase=resume_phase or "null",
338
310
  help_requested=help_requested,
339
311
  unknown_args=tuple(unknown),