prizmkit 1.1.193 → 1.1.195

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 (79) hide show
  1. package/bin/create-prizmkit.js +43 -12
  2. package/bundled/VERSION.json +3 -3
  3. package/bundled/dev-pipeline/.env.example +5 -0
  4. package/bundled/dev-pipeline/README.md +2 -1
  5. package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +111 -30
  6. package/bundled/dev-pipeline/prizmkit_runtime/cli.py +44 -3
  7. package/bundled/dev-pipeline/prizmkit_runtime/commands.py +29 -9
  8. package/bundled/dev-pipeline/prizmkit_runtime/config.py +121 -44
  9. package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +190 -37
  10. package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +1 -0
  11. package/bundled/dev-pipeline/prizmkit_runtime/iterate.py +2480 -0
  12. package/bundled/dev-pipeline/prizmkit_runtime/paths.py +3 -0
  13. package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +32 -8
  14. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +29 -12
  15. package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +13 -5
  16. package/bundled/dev-pipeline/prizmkit_runtime/status.py +166 -0
  17. package/bundled/dev-pipeline/scripts/feature_list_contract.py +964 -0
  18. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +18 -40
  19. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +24 -19
  20. package/bundled/dev-pipeline/scripts/prompt_framework.py +24 -8
  21. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +1 -63
  22. package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +8 -6
  23. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +0 -10
  24. package/bundled/dev-pipeline/templates/feature-list-schema.json +8 -6
  25. package/bundled/dev-pipeline/templates/iterate/evaluate-prompt.md +97 -0
  26. package/bundled/dev-pipeline/templates/iterate/evaluation-schema.json +538 -0
  27. package/bundled/dev-pipeline/templates/iterate/headless-plan-prompt.md +66 -0
  28. package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +2 -2
  29. package/bundled/dev-pipeline/templates/sections/runtime-commit-handoff.md +13 -4
  30. package/bundled/rules/USAGE.md +15 -48
  31. package/bundled/rules/_rules-metadata.json +7 -14
  32. package/bundled/rules/general/coding-baseline.md +23 -0
  33. package/bundled/rules/prizm/prizm-progressive-loading.md +2 -2
  34. package/bundled/skills/_metadata.json +12 -42
  35. package/bundled/skills/app-planner/SKILL.md +2 -2
  36. package/bundled/skills/app-planner/references/generated-plan-review.md +2 -2
  37. package/bundled/skills/app-planner/references/project-state-detection.md +1 -1
  38. package/bundled/skills/app-planner/references/rules-configuration.md +158 -88
  39. package/bundled/skills/app-planner/scripts/validate-rules-configuration.py +543 -12
  40. package/bundled/skills/bug-planner/references/verification.md +4 -5
  41. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +20 -14
  42. package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +49 -9
  43. package/bundled/skills/feature-pipeline-launcher/SKILL.md +20 -14
  44. package/bundled/skills/feature-pipeline-launcher/references/configuration.md +49 -9
  45. package/bundled/skills/feature-planner/SKILL.md +3 -3
  46. package/bundled/skills/feature-planner/references/browser-interaction.md +9 -29
  47. package/bundled/skills/iterate-pipeline-launcher/SKILL.md +273 -0
  48. package/bundled/skills/iterate-pipeline-launcher/references/configuration.md +105 -0
  49. package/bundled/skills/prizmkit-code-review/SKILL.md +10 -8
  50. package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +4 -1
  51. package/bundled/skills/prizmkit-code-review/references/review-report-template.md +2 -1
  52. package/bundled/skills/prizmkit-code-review/scripts/render_review_report.py +12 -8
  53. package/bundled/skills/prizmkit-implement/SKILL.md +2 -2
  54. package/bundled/skills/prizmkit-init/SKILL.md +10 -10
  55. package/bundled/skills/prizmkit-init/references/brownfield-deep-init.md +81 -0
  56. package/bundled/skills/prizmkit-plan/SKILL.md +2 -1
  57. package/bundled/skills/prizmkit-plan/assets/plan-template.md +2 -0
  58. package/bundled/skills/prizmkit-prizm-docs/SKILL.md +8 -4
  59. package/bundled/skills/prizmkit-prizm-docs/assets/prizm-docs-format.md +8 -7
  60. package/bundled/skills/prizmkit-prizm-docs/references/op-init.md +33 -16
  61. package/bundled/skills/prizmkit-prizm-docs/references/op-validate.md +1 -1
  62. package/bundled/skills/prizmkit-retrospective/SKILL.md +29 -12
  63. package/bundled/skills/prizmkit-retrospective/references/retrospective-result-schema.json +126 -2
  64. package/bundled/skills/prizmkit-retrospective/references/rule-evolution-steps.md +86 -0
  65. package/bundled/skills/prizmkit-test/SKILL.md +2 -1
  66. package/bundled/skills/prizmkit-workflow/SKILL.md +8 -0
  67. package/bundled/skills/prizmkit-workflow/references/cold-start-rules.md +84 -0
  68. package/bundled/templates/project-memory-template.md +3 -3
  69. package/package.json +1 -1
  70. package/src/clean.js +2 -3
  71. package/src/config.js +52 -39
  72. package/src/index.js +29 -111
  73. package/src/prompts.js +20 -87
  74. package/src/runtime-passthrough.js +324 -0
  75. package/src/scaffold.js +41 -294
  76. package/src/upgrade.js +7 -39
  77. package/bundled/dev-pipeline/templates/sections/phase-browser-verification-auto.md +0 -127
  78. package/bundled/dev-pipeline/templates/sections/phase-browser-verification-opencli.md +0 -124
  79. package/src/external-skills.js +0 -103
@@ -21,6 +21,7 @@ class RuntimePaths:
21
21
  bugfix_plan: Path
22
22
  feature_state_dir: Path
23
23
  bugfix_state_dir: Path
24
+ iterate_state_dir: Path
24
25
  layout: str
25
26
 
26
27
  def path_values(self) -> tuple[Path, ...]:
@@ -37,6 +38,7 @@ class RuntimePaths:
37
38
  self.bugfix_plan,
38
39
  self.feature_state_dir,
39
40
  self.bugfix_state_dir,
41
+ self.iterate_state_dir,
40
42
  )
41
43
 
42
44
 
@@ -97,5 +99,6 @@ def resolve_runtime_paths(
97
99
  bugfix_plan=plans_dir / "bug-fix-list.json",
98
100
  feature_state_dir=state_dir / "features",
99
101
  bugfix_state_dir=state_dir / "bugfix",
102
+ iterate_state_dir=state_dir / "iterate",
100
103
  layout=layout,
101
104
  )
@@ -205,23 +205,47 @@ def commit_bookkeeping_changes(
205
205
  return BookkeepingResult(attempted=True, committed=result.return_code == 0, result=result)
206
206
 
207
207
 
208
- def commit_preflight_ready_changes(project_root: Path, item_id: str) -> BookkeepingResult:
209
- """Preserve tracked changes and visible untracked files before task branch setup."""
208
+ def _validate_preflight_workspace(
209
+ project_root: Path,
210
+ *,
211
+ unsafe_message_prefix: str,
212
+ ) -> tuple[PreflightWorkspace | None, BookkeepingResult | None]:
210
213
  workspace, failure = _preflight_workspace(project_root)
211
214
  if failure is not None:
212
- return BookkeepingResult(attempted=True, committed=False, result=failure)
215
+ return None, BookkeepingResult(attempted=True, committed=False, result=failure)
213
216
  assert workspace is not None
214
217
  if workspace.unsafe_local:
215
- return BookkeepingResult(
218
+ return None, BookkeepingResult(
216
219
  attempted=True,
217
220
  committed=False,
218
- result=_preflight_failure(
219
- "Refusing to auto-commit local-only platform settings: " + ", ".join(workspace.unsafe_local)
220
- ),
221
+ result=_preflight_failure(unsafe_message_prefix + ", ".join(workspace.unsafe_local)),
221
222
  )
222
223
  integrity_failure = _preflight_integrity_failure(project_root, workspace)
223
224
  if integrity_failure is not None:
224
- return BookkeepingResult(attempted=True, committed=False, result=integrity_failure)
225
+ return None, BookkeepingResult(attempted=True, committed=False, result=integrity_failure)
226
+ return workspace, None
227
+
228
+
229
+ def validate_resumed_task_workspace(project_root: Path) -> BookkeepingResult:
230
+ """Validate an active resumed task branch workspace without pre-committing WIP."""
231
+ _workspace, validation_failure = _validate_preflight_workspace(
232
+ project_root,
233
+ unsafe_message_prefix="Refusing to continue with tracked local-only platform settings: ",
234
+ )
235
+ if validation_failure is not None:
236
+ return validation_failure
237
+ return BookkeepingResult(attempted=False, committed=False)
238
+
239
+
240
+ def commit_preflight_ready_changes(project_root: Path, item_id: str) -> BookkeepingResult:
241
+ """Preserve tracked changes and visible untracked files before task branch setup."""
242
+ workspace, validation_failure = _validate_preflight_workspace(
243
+ project_root,
244
+ unsafe_message_prefix="Refusing to auto-commit local-only platform settings: ",
245
+ )
246
+ if validation_failure is not None:
247
+ return validation_failure
248
+ assert workspace is not None
225
249
  paths = workspace.preservable
226
250
  if not paths:
227
251
  return BookkeepingResult(attempted=False, committed=False)
@@ -45,6 +45,7 @@ from .runner_bookkeeping import (
45
45
  commit_task_branch_changes,
46
46
  commit_wip_changes,
47
47
  sync_terminal_failure_bookkeeping_to_base,
48
+ validate_resumed_task_workspace,
48
49
  )
49
50
  from .runner_classification import classify_session, has_branch_completion_evidence, has_completed_artifact_path
50
51
  from .runner_models import (
@@ -674,6 +675,16 @@ def _preview_item(
674
675
  return "dry_run"
675
676
 
676
677
 
678
+ def _raise_preflight_failure(preflight, family_kind: str, item_id: str) -> None:
679
+ detail = ""
680
+ if preflight.result is not None:
681
+ detail = (preflight.result.stderr or preflight.result.stdout).strip()
682
+ _emit_warning(f"Preflight: failed to preserve existing changes before {family_kind} task {item_id}")
683
+ if detail:
684
+ _emit_warning(detail.splitlines()[0][:500])
685
+ raise RuntimeError(f"Preflight dirty workspace preservation failed before {family_kind} task {item_id}")
686
+
687
+
677
688
  def _process_item_locked(
678
689
  family: RunnerFamily,
679
690
  invocation: RunnerInvocation,
@@ -709,6 +720,9 @@ def _process_item_locked(
709
720
  active_branch and active_branch != "HEAD" and local_branch_exists(paths.project_root, active_branch)
710
721
  )
711
722
  reusing_checkout = checkout is not None and checkout.is_active
723
+ resuming_on_active_task_branch = bool(
724
+ reusing_checkout and active_branch == branch_name and initial_branch_ref_existed
725
+ )
712
726
  execution_root = paths.project_root
713
727
  session_id = ""
714
728
  session_paths: SessionPaths | None = None
@@ -716,19 +730,22 @@ def _process_item_locked(
716
730
  infra_error_count: int | None = None
717
731
 
718
732
  try:
719
- preflight = commit_preflight_ready_changes(paths.project_root, item_id)
720
- if preflight.committed:
721
- _emit_info(f"Preflight: preserved existing user-visible changes before {family.kind} task {item_id}")
722
- elif preflight.attempted:
723
- detail = ""
724
- if preflight.result is not None:
725
- detail = (preflight.result.stderr or preflight.result.stdout).strip()
726
- _emit_warning(f"Preflight: failed to preserve existing changes before {family.kind} task {item_id}")
727
- if detail:
728
- _emit_warning(detail.splitlines()[0][:500])
729
- raise RuntimeError(f"Preflight dirty workspace preservation failed before {family.kind} task {item_id}")
733
+ if resuming_on_active_task_branch:
734
+ preflight = validate_resumed_task_workspace(paths.project_root)
735
+ if preflight.attempted and not preflight.committed:
736
+ _raise_preflight_failure(preflight, family.kind, item_id)
737
+ _emit_info(
738
+ f"Preflight: preserving uncommitted workspace in place on resumed branch {branch_name} "
739
+ f"for {family.kind} task {item_id}"
740
+ )
730
741
  else:
731
- _emit_info(f"Preflight: no user-visible changes to preserve before {family.kind} task {item_id}")
742
+ preflight = commit_preflight_ready_changes(paths.project_root, item_id)
743
+ if preflight.committed:
744
+ _emit_info(f"Preflight: preserved existing user-visible changes before {family.kind} task {item_id}")
745
+ elif preflight.attempted:
746
+ _raise_preflight_failure(preflight, family.kind, item_id)
747
+ else:
748
+ _emit_info(f"Preflight: no user-visible changes to preserve before {family.kind} task {item_id}")
732
749
 
733
750
  born = ensure_branch_has_commit(paths.project_root)
734
751
  if born.return_code != 0:
@@ -247,15 +247,23 @@ def prepare_runtime_commit_handoff(
247
247
  raw_steps = data.get("steps")
248
248
  if not isinstance(raw_steps, list):
249
249
  return RuntimeCommitResult("failed", "checkpoint_runtime_prepare_rejected")
250
- committers = [
251
- step for step in raw_steps
250
+ committer_entries = [
251
+ (index, step)
252
+ for index, step in enumerate(raw_steps)
252
253
  if isinstance(step, dict) and step.get("skill") == "prizmkit-committer"
253
254
  ]
254
- if len(committers) != 1:
255
+ if len(committer_entries) != 1:
255
256
  return RuntimeCommitResult("failed", "checkpoint_runtime_prepare_rejected")
256
- committer = committers[0]
257
- if committer.get("status") != "in_progress" or committer.get("stage_result") not in {None, ""}:
257
+ committer_index, committer = committer_entries[0]
258
+ committer_status = committer.get("status")
259
+ if committer_status not in {"pending", "in_progress"} or committer.get("stage_result") not in {None, ""}:
260
+ return RuntimeCommitResult("not_ready", "checkpoint_not_runtime_handoff_candidate")
261
+ if committer_status == "pending" and any(
262
+ not isinstance(step, dict) or step.get("status") not in {"completed", "skipped"}
263
+ for step in raw_steps[:committer_index]
264
+ ):
258
265
  return RuntimeCommitResult("not_ready", "checkpoint_not_runtime_handoff_candidate")
266
+ committer["status"] = "in_progress"
259
267
  committer["stage_result"] = "COMMIT_PENDING"
260
268
 
261
269
  state_key = semantic_state_key(str(data.get("workflow_type") or ""))
@@ -8,6 +8,7 @@ from dataclasses import dataclass, field
8
8
  from pathlib import Path
9
9
 
10
10
  from .paths import RuntimePaths
11
+ from .results import CommandResult
11
12
 
12
13
 
13
14
  @dataclass(frozen=True)
@@ -175,4 +176,169 @@ def aggregate_family_status(
175
176
  body = f"error: {exc}"
176
177
  sections.append(f"{label}\n{'=' * len(label)}\n{body}")
177
178
 
179
+ sections.append(_render_iterate_aggregate_section(paths))
180
+ if sections[-1].startswith("ITERATE\n=======\nerror:"):
181
+ failed = True
182
+
178
183
  return AggregateStatusResult(1 if failed else 0, "\n\n".join(sections))
184
+
185
+
186
+ def read_iterate_status(paths: RuntimePaths) -> dict[str, object]:
187
+ """Read `.prizmkit/state/iterate/` state and ledger without mutating the filesystem."""
188
+ state_dir = paths.iterate_state_dir
189
+ state_file = state_dir / "state.json"
190
+ ledger_file = state_dir / "ledger.json"
191
+ pending_file = state_dir / "pending-decisions.md"
192
+
193
+ if not state_file.exists():
194
+ return {
195
+ "configured": False,
196
+ "status": "not_configured",
197
+ "phase": "stopped",
198
+ "current_round": 0,
199
+ "completed_rounds": 0,
200
+ "rounds_recorded": 0,
201
+ "active_feature_id": None,
202
+ "stop_reason": None,
203
+ "pause_reason": None,
204
+ "focus": "",
205
+ "limits": {},
206
+ "consecutive_failures": 0,
207
+ "consecutive_no_progress": 0,
208
+ "last_verdict": None,
209
+ "last_evidence_mode": None,
210
+ "pending_decisions_exists": pending_file.is_file(),
211
+ "summary": "",
212
+ }
213
+ if not state_file.is_file():
214
+ raise ValueError("malformed iterate state: state.json is not a file")
215
+ state = _load_json_object(state_file, "iterate state.json")
216
+
217
+ rounds_recorded = 0
218
+ last_round: dict[str, object] | None = None
219
+ if ledger_file.exists():
220
+ if not ledger_file.is_file():
221
+ raise ValueError("malformed iterate ledger: ledger.json is not a file")
222
+ ledger = _load_json_object(ledger_file, "iterate ledger.json")
223
+ rounds = ledger.get("rounds")
224
+ if not isinstance(rounds, list):
225
+ raise ValueError("malformed iterate ledger: rounds must be an array")
226
+ rounds_recorded = len(rounds)
227
+ if rounds and isinstance(rounds[-1], dict):
228
+ last_round = dict(rounds[-1])
229
+
230
+ snapshot: dict[str, object] = {
231
+ "configured": True,
232
+ "status": state.get("status") or "unknown",
233
+ "phase": state.get("phase") or "unknown",
234
+ "current_round": state.get("current_round") or 0,
235
+ "completed_rounds": state.get("completed_rounds") or 0,
236
+ "rounds_recorded": rounds_recorded,
237
+ "active_feature_id": state.get("active_feature_id"),
238
+ "stop_reason": state.get("stop_reason"),
239
+ "pause_reason": state.get("pause_reason"),
240
+ "focus": state.get("focus") or "",
241
+ "limits": state.get("limits") if isinstance(state.get("limits"), dict) else {},
242
+ "consecutive_failures": state.get("consecutive_failures") or 0,
243
+ "consecutive_no_progress": state.get("consecutive_no_progress") or 0,
244
+ "started_at": state.get("started_at"),
245
+ "updated_at": state.get("updated_at"),
246
+ "last_verdict": state.get("last_verdict"),
247
+ "last_evidence_mode": state.get("last_evidence_mode"),
248
+ "pending_decisions_exists": pending_file.is_file(),
249
+ "summary": state.get("summary") or "",
250
+ }
251
+ if last_round is not None:
252
+ snapshot["last_round"] = {
253
+ "round": last_round.get("round"),
254
+ "verdict": last_round.get("verdict"),
255
+ "evidence_mode": last_round.get("evidence_mode"),
256
+ "appended_ids": last_round.get("appended_ids") or [],
257
+ "completed_ids": last_round.get("completed_ids") or [],
258
+ "failed_ids": last_round.get("failed_ids") or [],
259
+ "head_before": last_round.get("head_before"),
260
+ "head_after": last_round.get("head_after"),
261
+ }
262
+ return snapshot
263
+
264
+
265
+ def _format_iterate_status_text(snapshot: Mapping[str, object]) -> str:
266
+ if not snapshot.get("configured"):
267
+ return "not configured: iterate state not found"
268
+ lines = [
269
+ f"status: {snapshot.get('status')}",
270
+ f"phase: {snapshot.get('phase')}",
271
+ f"current_round: {snapshot.get('current_round')}",
272
+ f"completed_rounds: {snapshot.get('completed_rounds')}",
273
+ f"rounds_recorded: {snapshot.get('rounds_recorded')}",
274
+ ]
275
+ if snapshot.get("active_feature_id"):
276
+ lines.append(f"active_feature_id: {snapshot.get('active_feature_id')}")
277
+ if snapshot.get("stop_reason"):
278
+ lines.append(f"stop_reason: {snapshot.get('stop_reason')}")
279
+ if snapshot.get("pause_reason"):
280
+ lines.append(f"pause_reason: {snapshot.get('pause_reason')}")
281
+ if snapshot.get("last_verdict"):
282
+ lines.append(f"last_verdict: {snapshot.get('last_verdict')}")
283
+ if snapshot.get("last_evidence_mode"):
284
+ lines.append(f"last_evidence_mode: {snapshot.get('last_evidence_mode')}")
285
+ if snapshot.get("focus"):
286
+ lines.append(f"focus: {snapshot.get('focus')}")
287
+ if snapshot.get("pending_decisions_exists"):
288
+ lines.append("pending_decisions: present")
289
+ if snapshot.get("summary"):
290
+ lines.append(f"summary: {snapshot.get('summary')}")
291
+ return "\n".join(lines)
292
+
293
+
294
+ def _render_iterate_aggregate_section(paths: RuntimePaths) -> str:
295
+ label = "ITERATE"
296
+ try:
297
+ snapshot = read_iterate_status(paths)
298
+ body = _format_iterate_status_text(snapshot)
299
+ except Exception as exc:
300
+ body = f"error: {exc}"
301
+ return f"{label}\n{'=' * len(label)}\n{body}"
302
+
303
+
304
+ def run_iterate_status_command(
305
+ legacy_args: tuple[str, ...],
306
+ paths: RuntimePaths,
307
+ ) -> CommandResult:
308
+ """Handle `status iterate [--json]` read-only without mutating files."""
309
+ json_output = False
310
+ unknown: list[str] = []
311
+ for arg in legacy_args:
312
+ if arg == "--json":
313
+ json_output = True
314
+ else:
315
+ unknown.append(arg)
316
+ if unknown:
317
+ message = f"Unsupported option(s) for status iterate: {', '.join(unknown)}"
318
+ return CommandResult(2, "Python iterate status", message, stderr=message)
319
+
320
+ try:
321
+ snapshot = read_iterate_status(paths)
322
+ except ValueError as exc:
323
+ if json_output:
324
+ return CommandResult(
325
+ 1,
326
+ "Python iterate status",
327
+ str(exc),
328
+ stdout=json.dumps({"error": str(exc)}, ensure_ascii=False),
329
+ stderr=str(exc),
330
+ )
331
+ return CommandResult(1, "Python iterate status", f"error: {exc}", stderr=str(exc))
332
+
333
+ if json_output:
334
+ return CommandResult(
335
+ 0,
336
+ "Python iterate status",
337
+ "ok",
338
+ stdout=json.dumps(snapshot, indent=2, ensure_ascii=False),
339
+ )
340
+ return CommandResult(
341
+ 0,
342
+ "Python iterate status",
343
+ _format_iterate_status_text(snapshot),
344
+ )