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.
Files changed (165) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/adapters/antigravity/skill-adapter.js +13 -4
  3. package/bundled/adapters/codex/skill-adapter.js +28 -8
  4. package/bundled/adapters/cursor/skill-adapter.js +13 -4
  5. package/bundled/adapters/pi/skill-adapter.js +28 -7
  6. package/bundled/dev-pipeline/.env.example +4 -12
  7. package/bundled/dev-pipeline/README.md +28 -44
  8. package/bundled/dev-pipeline/assets/feature-list-example.json +0 -1
  9. package/bundled/dev-pipeline/assets/skill-subagent-integration.md +6 -6
  10. package/bundled/dev-pipeline/prizmkit_runtime/atomic_io.py +48 -0
  11. package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +66 -23
  12. package/bundled/dev-pipeline/prizmkit_runtime/cli.py +10 -7
  13. package/bundled/dev-pipeline/prizmkit_runtime/commands.py +2 -21
  14. package/bundled/dev-pipeline/prizmkit_runtime/config.py +48 -78
  15. package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +127 -67
  16. package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +158 -462
  17. package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +102 -50
  18. package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +1 -25
  19. package/bundled/dev-pipeline/prizmkit_runtime/paths.py +0 -6
  20. package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +47 -21
  21. package/bundled/dev-pipeline/prizmkit_runtime/processes.py +217 -156
  22. package/bundled/dev-pipeline/prizmkit_runtime/reset.py +39 -27
  23. package/bundled/dev-pipeline/prizmkit_runtime/reset_preserve.py +34 -174
  24. package/bundled/dev-pipeline/prizmkit_runtime/results.py +25 -0
  25. package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +133 -110
  26. package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +15 -5
  27. package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +1 -95
  28. package/bundled/dev-pipeline/prizmkit_runtime/runner_prompts.py +0 -2
  29. package/bundled/dev-pipeline/prizmkit_runtime/runner_status.py +7 -2
  30. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +540 -262
  31. package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +175 -135
  32. package/bundled/dev-pipeline/prizmkit_runtime/runtime_helper.py +90 -9
  33. package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +214 -133
  34. package/bundled/dev-pipeline/prizmkit_runtime/status.py +1 -3
  35. package/bundled/dev-pipeline/prizmkit_runtime/stream_progress.py +2783 -0
  36. package/bundled/dev-pipeline/prizmkit_runtime/task_checkout.py +27 -102
  37. package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +58 -4
  38. package/bundled/dev-pipeline/scripts/check-session-status.py +56 -20
  39. package/bundled/dev-pipeline/scripts/continuation.py +8 -7
  40. package/bundled/dev-pipeline/scripts/detect-stuck.py +47 -33
  41. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +13 -16
  42. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +20 -10
  43. package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +10 -7
  44. package/bundled/dev-pipeline/scripts/init-change-artifact.py +25 -4
  45. package/bundled/dev-pipeline/scripts/init-pipeline.py +14 -69
  46. package/bundled/dev-pipeline/scripts/parse-stream-progress.py +31 -2616
  47. package/bundled/dev-pipeline/scripts/patch-completion-notes.py +4 -24
  48. package/bundled/dev-pipeline/scripts/prompt_framework.py +85 -20
  49. package/bundled/dev-pipeline/scripts/status_common.py +591 -0
  50. package/bundled/dev-pipeline/scripts/update-bug-status.py +85 -463
  51. package/bundled/dev-pipeline/scripts/update-checkpoint.py +254 -65
  52. package/bundled/dev-pipeline/scripts/update-feature-status.py +76 -509
  53. package/bundled/dev-pipeline/scripts/utils.py +5 -12
  54. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +5 -5
  55. package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +7 -0
  56. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +7 -7
  57. package/bundled/dev-pipeline/templates/sections/artifact-manifest.md +1 -1
  58. package/bundled/dev-pipeline/templates/sections/bugfix-phase-manual-verification.md +1 -1
  59. package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +1 -1
  60. package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +2 -1
  61. package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +1 -1
  62. package/bundled/dev-pipeline/templates/sections/phase-browser-verification-auto.md +1 -1
  63. package/bundled/dev-pipeline/templates/sections/phase-browser-verification-opencli.md +2 -2
  64. package/bundled/dev-pipeline/templates/sections/phase-browser-verification.md +2 -2
  65. package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +2 -1
  66. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +1 -1
  67. package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +3 -6
  68. package/bundled/dev-pipeline/templates/session-status-schema.json +2 -5
  69. package/bundled/skills/_metadata.json +9 -63
  70. package/bundled/skills/app-planner/SKILL.md +32 -303
  71. package/bundled/skills/app-planner/references/app-design-guide.md +0 -4
  72. package/bundled/skills/app-planner/references/generated-plan-review.md +2 -1
  73. package/bundled/skills/app-planner/references/project-brief-guide.md +14 -0
  74. package/bundled/skills/app-planner/references/project-conventions-discovery.md +4 -6
  75. package/bundled/skills/app-planner/references/project-state-detection.md +2 -3
  76. package/bundled/skills/bug-fix-workflow/SKILL.md +1 -2
  77. package/bundled/skills/bug-fix-workflow/references/bug-diagnosis.md +4 -7
  78. package/bundled/skills/bug-planner/SKILL.md +54 -435
  79. package/bundled/skills/bug-planner/references/generated-plan-review.md +3 -2
  80. package/bundled/skills/bug-planner/references/input-formats.md +32 -0
  81. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +4 -6
  82. package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +4 -28
  83. package/bundled/skills/feature-pipeline-launcher/SKILL.md +4 -6
  84. package/bundled/skills/feature-pipeline-launcher/references/configuration.md +4 -28
  85. package/bundled/skills/feature-planner/SKILL.md +60 -439
  86. package/bundled/skills/feature-planner/assets/planning-guide.md +1 -1
  87. package/bundled/skills/feature-planner/references/completeness-review.md +34 -0
  88. package/bundled/skills/feature-planner/references/decomposition-patterns.md +2 -2
  89. package/bundled/skills/feature-planner/references/error-recovery.md +1 -1
  90. package/bundled/skills/feature-planner/references/generated-plan-review.md +3 -2
  91. package/bundled/skills/feature-planner/references/incremental-feature-planning.md +3 -1
  92. package/bundled/skills/feature-workflow/SKILL.md +1 -2
  93. package/bundled/skills/prizmkit/SKILL.md +7 -1
  94. package/bundled/skills/prizmkit-code-review/SKILL.md +14 -6
  95. package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +7 -4
  96. package/bundled/skills/prizmkit-code-review/references/review-report-template.md +16 -0
  97. package/bundled/skills/prizmkit-code-review/scripts/render_review_report.py +58 -20
  98. package/bundled/skills/prizmkit-implement/SKILL.md +1 -1
  99. package/bundled/skills/prizmkit-init/SKILL.md +24 -127
  100. package/bundled/skills/prizmkit-init/assets/project-brief-template.md +3 -3
  101. package/bundled/skills/prizmkit-plan/SKILL.md +6 -8
  102. package/bundled/skills/prizmkit-plan/references/clarify-guide.md +1 -1
  103. package/bundled/skills/prizmkit-plan/references/independent-plan-review.md +5 -2
  104. package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +6 -5
  105. package/bundled/skills/prizmkit-prizm-docs/SKILL.md +1 -13
  106. package/bundled/skills/prizmkit-prizm-docs/references/op-update.md +1 -1
  107. package/bundled/skills/prizmkit-retrospective/SKILL.md +6 -4
  108. package/bundled/skills/prizmkit-test/SKILL.md +25 -133
  109. package/bundled/skills/prizmkit-test/references/independent-test-review.md +5 -2
  110. package/bundled/skills/prizmkit-test/references/test-coverage-model.md +6 -0
  111. package/bundled/skills/prizmkit-workflow/SKILL.md +2 -3
  112. package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +4 -3
  113. package/bundled/skills/recovery-workflow/SKILL.md +7 -7
  114. package/bundled/skills/recovery-workflow/evals/evals.json +1 -1
  115. package/bundled/skills/recovery-workflow/references/detection.md +1 -3
  116. package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +0 -6
  117. package/bundled/templates/project-memory-template.md +1 -2
  118. package/package.json +1 -1
  119. package/src/scaffold.js +28 -7
  120. package/bundled/dev-pipeline/SCHEMA_ANALYSIS.md +0 -53
  121. package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +0 -649
  122. package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +0 -463
  123. package/bundled/dev-pipeline/scripts/update-refactor-status.py +0 -1512
  124. package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +0 -240
  125. package/bundled/dev-pipeline/templates/refactor-list-schema.json +0 -266
  126. package/bundled/dev-pipeline/templates/sections/refactor-critical-paths.md +0 -15
  127. package/bundled/dev-pipeline/templates/sections/refactor-mission.md +0 -9
  128. package/bundled/dev-pipeline/templates/sections/refactor-phase-commit-report.md +0 -24
  129. package/bundled/dev-pipeline/templates/sections/refactor-phase-implement.md +0 -16
  130. package/bundled/dev-pipeline/templates/sections/refactor-phase-init.md +0 -9
  131. package/bundled/dev-pipeline/templates/sections/refactor-phase-plan.md +0 -22
  132. package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +0 -19
  133. package/bundled/dev-pipeline/templates/sections/refactor-phase-test.md +0 -24
  134. package/bundled/dev-pipeline/templates/sections/refactor-reminders.md +0 -12
  135. package/bundled/dev-pipeline/templates/sections/refactor-session-context.md +0 -6
  136. package/bundled/dev-pipeline/templates/sections/refactor-task-contract.md +0 -52
  137. package/bundled/dev-pipeline/tests/conftest.py +0 -29
  138. package/bundled/dev-pipeline/tests/live_ai_cli_log_smoke.py +0 -208
  139. package/bundled/dev-pipeline/tests/test_auto_skip.py +0 -1871
  140. package/bundled/dev-pipeline/tests/test_checkpoint_state.py +0 -1314
  141. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +0 -1712
  142. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +0 -627
  143. package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +0 -478
  144. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +0 -5641
  145. package/bundled/dev-pipeline/tests/test_recovery_workflow.py +0 -322
  146. package/bundled/dev-pipeline/tests/test_repository_bootstrap.py +0 -252
  147. package/bundled/dev-pipeline/tests/test_reset_modes.py +0 -1208
  148. package/bundled/dev-pipeline/tests/test_reset_preserve.py +0 -957
  149. package/bundled/dev-pipeline/tests/test_runtime_commit.py +0 -1113
  150. package/bundled/dev-pipeline/tests/test_runtime_helper.py +0 -303
  151. package/bundled/dev-pipeline/tests/test_unified_cli.py +0 -5504
  152. package/bundled/dev-pipeline/tests/test_utils.py +0 -170
  153. package/bundled/skills/feature-planner/assets/evaluation-guide.md +0 -44
  154. package/bundled/skills/refactor-pipeline-launcher/SKILL.md +0 -219
  155. package/bundled/skills/refactor-pipeline-launcher/references/configuration.md +0 -78
  156. package/bundled/skills/refactor-planner/SKILL.md +0 -467
  157. package/bundled/skills/refactor-planner/assets/planning-guide.md +0 -291
  158. package/bundled/skills/refactor-planner/references/behavior-preservation.md +0 -187
  159. package/bundled/skills/refactor-planner/references/error-recovery.md +0 -45
  160. package/bundled/skills/refactor-planner/references/fast-path.md +0 -59
  161. package/bundled/skills/refactor-planner/references/generated-plan-review.md +0 -107
  162. package/bundled/skills/refactor-planner/references/planning-phases.md +0 -172
  163. package/bundled/skills/refactor-planner/references/refactor-scoping-guide.md +0 -230
  164. package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +0 -1120
  165. package/bundled/skills/refactor-workflow/SKILL.md +0 -205
@@ -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
  )
@@ -59,9 +62,16 @@ class BookkeepingResult:
59
62
  return self.result is None or self.result.return_code == 0
60
63
 
61
64
 
62
- def _bookkeeping_paths(project_root: Path, family: RunnerFamily, item_id: str) -> tuple[str, ...]:
65
+ def _bookkeeping_paths(
66
+ project_root: Path,
67
+ family: RunnerFamily,
68
+ item_id: str,
69
+ *,
70
+ list_path: Path | None = None,
71
+ ) -> tuple[str, ...]:
72
+ target_list = list_path if list_path is not None else family.plan_path
63
73
  return (
64
- _repo_path(project_root, family.plan_path),
74
+ _repo_path(project_root, target_list),
65
75
  _repo_path(project_root, family.state_dir / item_id / "status.json"),
66
76
  )
67
77
 
@@ -88,48 +98,6 @@ def _unique_paths(paths: Sequence[str]) -> tuple[str, ...]:
88
98
  return tuple(dict.fromkeys(path for path in paths if path))
89
99
 
90
100
 
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
101
  def _preflight_workspace(project_root: Path) -> tuple[PreflightWorkspace | None, GitCommandResult | None]:
134
102
  tracked_result = _tracked_status_result(project_root)
135
103
  if tracked_result.return_code != 0:
@@ -138,7 +106,7 @@ def _preflight_workspace(project_root: Path) -> tuple[PreflightWorkspace | None,
138
106
  if untracked_result.return_code != 0:
139
107
  return None, untracked_result
140
108
 
141
- tracked = _status_record_paths(tracked_result.stdout)
109
+ tracked = parse_status_record_paths(tracked_result.stdout)
142
110
  visible_untracked = _unique_paths(untracked_result.stdout.split("\0"))
143
111
  unsafe_local = tuple(path for path in tracked if path in LOCAL_ONLY_PLATFORM_PATHS)
144
112
  return PreflightWorkspace(tracked, visible_untracked, unsafe_local), None
@@ -202,31 +170,16 @@ def _remaining_preflight_changes(project_root: Path) -> GitCommandResult:
202
170
  )
203
171
 
204
172
 
205
- def _visible_status_result(project_root: Path) -> GitCommandResult:
206
- return run_git_command(project_root, ("status", "--porcelain", "--", "."))
207
-
208
-
209
- def _paths_from_status(stdout: str) -> tuple[str, ...]:
210
- changed: list[str] = []
211
- seen: set[str] = set()
212
- for line in stdout.splitlines():
213
- if len(line) < 4:
214
- continue
215
- path = line[3:].strip()
216
- paths = path.split(" -> ", 1) if " -> " in path else [path]
217
- for candidate in paths:
218
- candidate = candidate.strip()
219
- if candidate and candidate not in seen:
220
- changed.append(candidate)
221
- seen.add(candidate)
222
- return tuple(changed)
223
-
224
-
225
173
  def _changed_paths_in(project_root: Path, paths: Sequence[str]) -> tuple[str, ...]:
226
- result = run_git_command(project_root, ("status", "--porcelain", "--", *paths))
174
+ if not paths:
175
+ return ()
176
+ result = run_git_command(
177
+ project_root,
178
+ ("status", "--porcelain=v1", "-z", "--", *literal_pathspecs(paths)),
179
+ )
227
180
  if result.return_code != 0:
228
181
  return ()
229
- return _paths_from_status(result.stdout)
182
+ return parse_status_record_paths(result.stdout)
230
183
 
231
184
 
232
185
  def commit_bookkeeping_changes(
@@ -234,13 +187,21 @@ def commit_bookkeeping_changes(
234
187
  family: RunnerFamily,
235
188
  item_id: str,
236
189
  message: str,
190
+ *,
191
+ list_path: Path | None = None,
237
192
  ) -> BookkeepingResult:
238
193
  """Stage and commit only runner-owned bookkeeping paths when present."""
239
- paths = _changed_paths_in(project_root, _bookkeeping_paths(project_root, family, item_id))
194
+ paths = _changed_paths_in(
195
+ project_root,
196
+ _bookkeeping_paths(project_root, family, item_id, list_path=list_path),
197
+ )
240
198
  if not paths:
241
199
  return BookkeepingResult(attempted=False, committed=False)
242
- run_git_command(project_root, ("add", "-A", "--", *paths))
243
- result = run_git_command(project_root, ("commit", "--no-verify", "-m", message, "--", *paths))
200
+ pathspecs = literal_pathspecs(paths)
201
+ add = run_git_command(project_root, ("add", "-A", "--", *pathspecs))
202
+ if add.return_code != 0:
203
+ return BookkeepingResult(attempted=True, committed=False, result=add)
204
+ result = run_git_command(project_root, ("commit", "--no-verify", "-m", message, "--", *pathspecs))
244
205
  return BookkeepingResult(attempted=True, committed=result.return_code == 0, result=result)
245
206
 
246
207
 
@@ -264,12 +225,12 @@ def commit_preflight_ready_changes(project_root: Path, item_id: str) -> Bookkeep
264
225
  paths = workspace.preservable
265
226
  if not paths:
266
227
  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)
228
+ pathspecs = literal_pathspecs(paths)
229
+ add_paths, add_paths_result = addable_task_paths(project_root, paths)
230
+ if add_paths_result.return_code != 0:
231
+ return BookkeepingResult(attempted=True, committed=False, result=add_paths_result)
271
232
  if add_paths:
272
- add_result = run_git_command(project_root, ("add", "-A", "-f", "--", *_literal_pathspecs(add_paths)))
233
+ add_result = run_git_command(project_root, ("add", "-A", "-f", "--", *literal_pathspecs(add_paths)))
273
234
  if add_result.return_code != 0:
274
235
  return BookkeepingResult(attempted=True, committed=False, result=add_result)
275
236
  result = run_git_command(
@@ -284,16 +245,7 @@ def commit_preflight_ready_changes(project_root: Path, item_id: str) -> Bookkeep
284
245
  return BookkeepingResult(attempted=True, committed=True, result=result)
285
246
 
286
247
 
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"
248
+ def _commit_visible_task_paths(project_root: Path, commit_message_args: tuple[str, ...]) -> BookkeepingResult:
297
249
  paths, status_result = visible_task_paths(project_root)
298
250
  if status_result.return_code != 0:
299
251
  return BookkeepingResult(attempted=True, committed=False, result=status_result)
@@ -303,16 +255,29 @@ def commit_task_branch_changes(
303
255
  if indexed_result.return_code != 0:
304
256
  return BookkeepingResult(attempted=True, committed=False, result=indexed_result)
305
257
  if add_paths:
306
- add_result = run_git_command(project_root, ("add", "-A", "--", *_literal_pathspecs(add_paths)))
258
+ add_result = run_git_command(project_root, ("add", "-A", "--", *literal_pathspecs(add_paths)))
307
259
  if add_result.return_code != 0:
308
260
  return BookkeepingResult(attempted=True, committed=False, result=add_result)
309
261
  result = run_git_command(
310
262
  project_root,
311
- ("commit", "--no-verify", "-m", message, "--", *_literal_pathspecs(paths)),
263
+ ("commit", "--no-verify", *commit_message_args, "--", *literal_pathspecs(paths)),
312
264
  )
313
265
  return BookkeepingResult(attempted=True, committed=result.return_code == 0, result=result)
314
266
 
315
267
 
268
+ def commit_task_branch_changes(
269
+ project_root: Path,
270
+ family: RunnerFamily,
271
+ item_id: str,
272
+ status: str,
273
+ ) -> BookkeepingResult:
274
+ """Commit task branch code, artifacts, and status without switching branches."""
275
+ message = f"chore({item_id}): save {family.kind} {status} state"
276
+ if status == "completed":
277
+ message = f"chore({item_id}): complete {family.kind} task"
278
+ return _commit_visible_task_paths(project_root, ("-m", message))
279
+
280
+
316
281
  def commit_wip_changes(
317
282
  project_root: Path,
318
283
  family: RunnerFamily,
@@ -320,39 +285,97 @@ def commit_wip_changes(
320
285
  status: str,
321
286
  ) -> BookkeepingResult:
322
287
  """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(
288
+ return _commit_visible_task_paths(
336
289
  project_root,
337
290
  (
338
- "commit",
339
- "--no-verify",
340
291
  "-m",
341
292
  f"wip({item_id}): preserve {family.kind} {status} state",
342
293
  "-m",
343
294
  "Pipeline preserved task branch work without merging it to the base branch.",
344
- "--",
345
- *_literal_pathspecs(paths),
346
295
  ),
347
296
  )
348
- return BookkeepingResult(attempted=True, committed=result.return_code == 0, result=result)
349
297
 
350
298
 
351
- def commit_pre_branch_bookkeeping(project_root: Path, family: RunnerFamily, item_id: str) -> BookkeepingResult:
299
+ def commit_pre_branch_bookkeeping(
300
+ project_root: Path,
301
+ family: RunnerFamily,
302
+ item_id: str,
303
+ *,
304
+ list_path: Path | None = None,
305
+ ) -> BookkeepingResult:
352
306
  """Commit in-progress status on the current task branch."""
353
- return commit_bookkeeping_changes(project_root, family, item_id, f"chore({item_id}): mark in_progress")
307
+ return commit_bookkeeping_changes(
308
+ project_root,
309
+ family,
310
+ item_id,
311
+ f"chore({item_id}): mark in_progress",
312
+ list_path=list_path,
313
+ )
354
314
 
355
315
 
356
- def commit_final_bookkeeping(project_root: Path, family: RunnerFamily, item_id: str, status: str) -> BookkeepingResult:
316
+ def commit_final_bookkeeping(
317
+ project_root: Path,
318
+ family: RunnerFamily,
319
+ item_id: str,
320
+ status: str,
321
+ *,
322
+ list_path: Path | None = None,
323
+ ) -> BookkeepingResult:
357
324
  """Commit final runner-owned status changes on the current task branch."""
358
- return commit_bookkeeping_changes(project_root, family, item_id, f"chore({item_id}): update {family.kind} status {status}")
325
+ return commit_bookkeeping_changes(
326
+ project_root,
327
+ family,
328
+ item_id,
329
+ f"chore({item_id}): update {family.kind} status {status}",
330
+ list_path=list_path,
331
+ )
332
+
333
+
334
+ def _is_runtime_state_relpath(rel_path: str) -> bool:
335
+ normalized = rel_path.replace("\\", "/")
336
+ while normalized.startswith(("./", "/")):
337
+ normalized = normalized[2:] if normalized.startswith("./") else normalized[1:]
338
+ return normalized == ".prizmkit/state" or normalized.startswith(".prizmkit/state/")
339
+
340
+
341
+ def sync_terminal_failure_bookkeeping_to_base(
342
+ project_root: Path,
343
+ family: RunnerFamily,
344
+ item_id: str,
345
+ status: str,
346
+ snapshots: Mapping[Path, str],
347
+ ) -> BookkeepingResult:
348
+ """Persist terminal failure bookkeeping on base_branch without tracking runtime state."""
349
+ if not snapshots:
350
+ return BookkeepingResult(attempted=False, committed=False)
351
+ resolved_root = project_root.resolve()
352
+ git_candidates: list[str] = []
353
+ for path, text in snapshots.items():
354
+ needs_write = True
355
+ if path.is_file():
356
+ try:
357
+ needs_write = path.read_text(encoding="utf-8") != text
358
+ except OSError:
359
+ needs_write = True
360
+ if needs_write:
361
+ write_text_atomic(path, text)
362
+ try:
363
+ rel = path.resolve().relative_to(resolved_root).as_posix()
364
+ except ValueError:
365
+ continue
366
+ if not _is_runtime_state_relpath(rel):
367
+ git_candidates.append(rel)
368
+ if not git_candidates:
369
+ return BookkeepingResult(attempted=False, committed=False)
370
+ changed = _changed_paths_in(project_root, git_candidates)
371
+ if not changed:
372
+ return BookkeepingResult(attempted=False, committed=False)
373
+ pathspecs = literal_pathspecs(changed)
374
+ add = run_git_command(project_root, ("add", "-A", "--", *pathspecs))
375
+ if add.return_code != 0:
376
+ return BookkeepingResult(attempted=True, committed=False, result=add)
377
+ commit = run_git_command(
378
+ project_root,
379
+ ("commit", "--no-verify", "-m", f"chore({item_id}): record {family.kind} status {status}", "--", *pathspecs),
380
+ )
381
+ 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, ...] = ()
@@ -126,65 +120,6 @@ class SessionPaths:
126
120
  )
127
121
 
128
122
 
129
- @dataclass(frozen=True)
130
- class SemanticCheckpointState:
131
- """Cohesive provider-neutral checkpoint metadata persisted by L4."""
132
-
133
- current_stage: str | None = None
134
- next_stage: str | None = None
135
- stage_result: str | None = None
136
- repair_scope: str | None = None
137
- repair_round: int = 0
138
- blocked_reason: str | None = None
139
- terminal_status: str | None = None
140
-
141
- @classmethod
142
- def from_mapping(cls, value: Mapping[str, object] | None) -> "SemanticCheckpointState":
143
- data = value or {}
144
- return cls(
145
- current_stage=_optional_text(data.get("current_stage")),
146
- next_stage=_optional_text(data.get("next_stage")),
147
- stage_result=_optional_text(data.get("stage_result")),
148
- repair_scope=_optional_text(data.get("repair_scope")),
149
- repair_round=max(0, _safe_int(data.get("repair_round"), 0)),
150
- blocked_reason=_optional_text(data.get("blocked_reason")),
151
- terminal_status=_optional_text(data.get("terminal_status")),
152
- )
153
-
154
- def as_dict(self) -> dict[str, object]:
155
- return {
156
- "current_stage": self.current_stage,
157
- "next_stage": self.next_stage,
158
- "stage_result": self.stage_result,
159
- "repair_scope": self.repair_scope,
160
- "repair_round": self.repair_round,
161
- "blocked_reason": self.blocked_reason,
162
- "terminal_status": self.terminal_status,
163
- }
164
-
165
-
166
- @dataclass(frozen=True)
167
- class ContinuationState:
168
- """Provider-neutral durable handoff inputs for the next AI session."""
169
-
170
- active: bool = False
171
- previous_session_id: str = ""
172
- failure_classification: str = ""
173
- continuation_count: int = 0
174
- context_overflow_count: int = 0
175
- retry_count: int = 0
176
- infra_error_count: int = 0
177
- max_retries: int = 0
178
- max_infra_retries: int = 0
179
- no_progress_count: int = 0
180
- progress_fingerprint: Mapping[str, object] = field(default_factory=dict)
181
- summary_path: Path | None = None
182
- active_dev_branch: str = ""
183
- base_branch: str = ""
184
- fatal_error_code: str = ""
185
- checkpoint_state: SemanticCheckpointState = field(default_factory=SemanticCheckpointState)
186
-
187
-
188
123
  @dataclass(frozen=True)
189
124
  class SessionClassification:
190
125
  """Final runner-owned session outcome before status updater mutation."""
@@ -208,7 +143,7 @@ class PipelineRunResult:
208
143
  details: tuple[str, ...] = ()
209
144
 
210
145
 
211
- FAMILY_KINDS = ("feature", "bugfix", "refactor")
146
+ FAMILY_KINDS = ("feature", "bugfix")
212
147
 
213
148
 
214
149
  def family_for(kind: str, paths: RuntimePaths) -> RunnerFamily:
@@ -242,20 +177,6 @@ def family_for(kind: str, paths: RuntimePaths) -> RunnerFamily:
242
177
  branch_prefix="bugfix",
243
178
  artifact_root_name="bugfix",
244
179
  )
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
180
  raise ValueError(f"Unsupported runner family: {kind}")
260
181
 
261
182
 
@@ -272,8 +193,6 @@ def parse_invocation(
272
193
  max_retries: int | None = None
273
194
  max_infra_retries = 3
274
195
  dry_run = False
275
- clean = False
276
- no_reset = False
277
196
  resume_phase = "null"
278
197
  unknown: list[str] = []
279
198
  positional: list[str] = []
@@ -286,10 +205,6 @@ def parse_invocation(
286
205
  help_requested = True
287
206
  elif arg == "--dry-run":
288
207
  dry_run = True
289
- elif arg == "--clean":
290
- clean = True
291
- elif arg == "--no-reset":
292
- no_reset = True
293
208
  elif arg == "--features" and index + 1 < len(args):
294
209
  index += 1
295
210
  item_filter = args[index]
@@ -332,8 +247,6 @@ def parse_invocation(
332
247
  max_retries=max_retries,
333
248
  max_infra_retries=max_infra_retries,
334
249
  dry_run=dry_run,
335
- clean=clean,
336
- no_reset=no_reset,
337
250
  resume_phase=resume_phase or "null",
338
251
  help_requested=help_requested,
339
252
  unknown_args=tuple(unknown),
@@ -363,13 +276,6 @@ def _falsey(value: str | None) -> bool:
363
276
  return str(value or "").strip().lower() in {"0", "false", "no", "off"}
364
277
 
365
278
 
366
- def _optional_text(value: object) -> str | None:
367
- if value is None:
368
- return None
369
- text = str(value).strip()
370
- return text or None
371
-
372
-
373
279
  def _safe_int(value: object, default: int) -> int:
374
280
  try:
375
281
  return int(str(value))
@@ -112,8 +112,6 @@ def _artifact_path(
112
112
  return Path(str(data["checkpoint_path"])).parent
113
113
  if family.kind == "bugfix":
114
114
  return project_root / ".prizmkit" / "bugfix" / item_id
115
- if family.kind == "refactor":
116
- return project_root / ".prizmkit" / "refactor" / item_id
117
115
  return project_root / ".prizmkit" / family.artifact_root_name / item_id
118
116
 
119
117
 
@@ -3,11 +3,13 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import json
6
+ import os
6
7
  import subprocess
7
8
  import sys
8
9
  from dataclasses import dataclass
9
10
  from pathlib import Path
10
11
 
12
+ from .config import load_env_file
11
13
  from .runner_models import RunnerEnvironment, RunnerFamily, RunnerInvocation
12
14
 
13
15
 
@@ -30,9 +32,12 @@ class StatusCommandResult:
30
32
  return self.stdout.strip() or self.stderr.strip()
31
33
 
32
34
 
33
- def _resolved_max_retries(invocation: RunnerInvocation) -> int:
35
+ def _resolved_max_retries(invocation: RunnerInvocation, project_root: Path | None = None) -> int:
34
36
  if invocation.max_retries is not None:
35
37
  return max(0, invocation.max_retries)
38
+ if project_root is not None:
39
+ merged_env = load_env_file(project_root / ".prizmkit" / ".env", os.environ)
40
+ return RunnerEnvironment.from_env(merged_env).max_retries
36
41
  return RunnerEnvironment.from_env().max_retries
37
42
 
38
43
 
@@ -54,7 +59,7 @@ def run_status_action(
54
59
  checkpoint_state: object | None = None,
55
60
  project_root: Path | None = None,
56
61
  ) -> StatusCommandResult:
57
- max_retries = _resolved_max_retries(invocation) if max_retries is None else max(0, max_retries)
62
+ max_retries = _resolved_max_retries(invocation, project_root) if max_retries is None else max(0, max_retries)
58
63
  command = [
59
64
  sys.executable,
60
65
  str(family.updater_script),