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
@@ -59,7 +59,6 @@ SKILL_WORKFLOW_STAGES.update({
59
59
  FAMILY_PLAN_SKILLS = {
60
60
  "feature-pipeline": "context-snapshot-and-plan",
61
61
  "bugfix-pipeline": "bug-diagnosis-and-plan",
62
- "refactor-pipeline": "prizmkit-plan",
63
62
  }
64
63
  VALID_TERMINAL_STATUSES = {"WORKFLOW_COMPLETED", "WORKFLOW_BLOCKED"}
65
64
  VALID_REPAIR_SCOPES = {
@@ -73,7 +72,6 @@ VALID_REPAIR_SCOPES = {
73
72
  SEMANTIC_STATE_KEYS = {
74
73
  "feature-pipeline": "feature_state",
75
74
  "bugfix-pipeline": "bugfix_state",
76
- "refactor-pipeline": "refactor_state",
77
75
  }
78
76
  LEGACY_FAMILY_REQUIRED_STAGES = {
79
77
  "feature-pipeline": (
@@ -92,15 +90,6 @@ LEGACY_FAMILY_REQUIRED_STAGES = {
92
90
  "prizmkit-committer",
93
91
  "bug-report",
94
92
  ),
95
- "refactor-pipeline": (
96
- "prizmkit-implement",
97
- "prizmkit-code-review",
98
- "prizmkit-test",
99
- "prizmkit-retrospective",
100
- "prizmkit-committer",
101
- "refactor-report",
102
- "completion-summary",
103
- ),
104
93
  }
105
94
 
106
95
  FAMILY_REQUIRED_STAGES = {
@@ -120,15 +109,6 @@ FAMILY_REQUIRED_STAGES = {
120
109
  "prizmkit-retrospective",
121
110
  "prizmkit-committer",
122
111
  ),
123
- "refactor-pipeline": (
124
- "prizmkit-implement",
125
- "prizmkit-code-review",
126
- "prizmkit-test",
127
- "refactor-report",
128
- "completion-summary",
129
- "prizmkit-retrospective",
130
- "prizmkit-committer",
131
- ),
132
112
  }
133
113
 
134
114
 
@@ -549,6 +529,8 @@ def rewind_checkpoint_for_implementation(
549
529
  }
550
530
  )
551
531
  raw_semantic.pop("stage_result", None)
532
+ raw_semantic.pop("runtime_base_head", None)
533
+ raw_semantic.pop("runtime_commit_hash", None)
552
534
  if isinstance(raw_semantic.get("completed_stages"), list):
553
535
  raw_semantic["completed_stages"] = [
554
536
  value
@@ -712,6 +694,13 @@ def _derive_semantic_state(
712
694
  return _semantic_error(workflow_type, current_step, "invalid_blocked_reason", "blocked_reason must be a non-empty string")
713
695
  if terminal_status == "WORKFLOW_BLOCKED" and not blocked_reason:
714
696
  return _semantic_error(workflow_type, current_step, "missing_blocked_reason", "WORKFLOW_BLOCKED requires blocked_reason")
697
+ if terminal_status == "WORKFLOW_BLOCKED" and semantic_status in {"in_progress", "completed"}:
698
+ return _semantic_error(
699
+ workflow_type,
700
+ current_step,
701
+ "blocked_workflow_has_non_failed_status",
702
+ f"WORKFLOW_BLOCKED cannot have status={semantic_status}",
703
+ )
715
704
  if blocked_reason and terminal_status == "WORKFLOW_COMPLETED":
716
705
  return _semantic_error(
717
706
  workflow_type,
@@ -816,8 +805,8 @@ def _derive_semantic_state(
816
805
  if (
817
806
  current_step is not None
818
807
  and current_step.status == "failed"
819
- and current_step.stage_result == "REVIEW_NEEDS_FIXES"
820
- and raw_state.get("stage_result") == "REVIEW_NEEDS_FIXES"
808
+ and current_step.stage_result in {"REVIEW_NEEDS_FIXES", "TEST_NEEDS_FIXES"}
809
+ and raw_state.get("stage_result") in {"REVIEW_NEEDS_FIXES", "TEST_NEEDS_FIXES"}
821
810
  and raw_state.get("next_stage") == "prizmkit-implement"
822
811
  ):
823
812
  next_stage = "prizmkit-implement"
@@ -904,6 +893,56 @@ def _single_step(steps: tuple[CheckpointStep, ...], skill: str) -> CheckpointSte
904
893
  return matches[0] if len(matches) == 1 else None
905
894
 
906
895
 
896
+ def required_step_artifacts_valid(
897
+ raw_step: Mapping[str, Any],
898
+ *,
899
+ index: int = 0,
900
+ checkpoint_path: Path | str | None = None,
901
+ project_root: Path | str | None = None,
902
+ ) -> bool:
903
+ """Validate declared required artifacts for one raw checkpoint step dict."""
904
+ step_id = raw_step.get("id")
905
+ skill = raw_step.get("skill")
906
+ name = raw_step.get("name")
907
+ status = raw_step.get("status")
908
+ if (
909
+ not isinstance(step_id, str)
910
+ or not STEP_ID_PATTERN.match(step_id)
911
+ or not isinstance(skill, str)
912
+ or not skill.strip()
913
+ or not isinstance(name, str)
914
+ or not name.strip()
915
+ or status not in VALID_CHECKPOINT_STATUSES
916
+ ):
917
+ return False
918
+ raw_artifacts = raw_step.get("required_artifacts")
919
+ if raw_artifacts is None:
920
+ artifacts: tuple[str, ...] = ()
921
+ elif isinstance(raw_artifacts, (list, tuple)) and all(isinstance(item, str) for item in raw_artifacts):
922
+ artifacts = tuple(raw_artifacts)
923
+ else:
924
+ return False
925
+ stage_result = raw_step.get("stage_result")
926
+ if stage_result is not None and not isinstance(stage_result, str):
927
+ return False
928
+ depends_on = raw_step.get("depends_on")
929
+ if depends_on is not None and not isinstance(depends_on, str):
930
+ return False
931
+ step = CheckpointStep(
932
+ id=step_id,
933
+ skill=skill.strip(),
934
+ name=name.strip(),
935
+ status=str(status),
936
+ depends_on=depends_on,
937
+ required_artifacts=artifacts,
938
+ stage_result=stage_result,
939
+ index=index,
940
+ )
941
+ resolved_cp = Path(checkpoint_path) if checkpoint_path is not None else None
942
+ resolved_root = Path(project_root) if project_root is not None else None
943
+ return _required_step_artifacts_valid(step, resolved_cp, resolved_root)
944
+
945
+
907
946
  def _required_step_artifacts_valid(
908
947
  step: CheckpointStep,
909
948
  checkpoint_path: Path | None,
@@ -1111,7 +1150,8 @@ def _is_within_root(path: Path, root: Path) -> bool:
1111
1150
  return True
1112
1151
 
1113
1152
 
1114
- def _infer_project_root(checkpoint_path: Path | None) -> Path:
1153
+ def infer_project_root(checkpoint_path: Path | None) -> Path:
1154
+ """Resolve the project root from a conventional ``.prizmkit`` checkpoint path."""
1115
1155
  if checkpoint_path is None:
1116
1156
  return Path.cwd()
1117
1157
  resolved = checkpoint_path.resolve()
@@ -1121,6 +1161,9 @@ def _infer_project_root(checkpoint_path: Path | None) -> Path:
1121
1161
  return resolved.parent
1122
1162
 
1123
1163
 
1164
+ _infer_project_root = infer_project_root
1165
+
1166
+
1124
1167
  def _semantic_error(
1125
1168
  workflow_type: str,
1126
1169
  current_step: CheckpointStep | None,
@@ -6,16 +6,17 @@ import argparse
6
6
  import sys
7
7
  from collections.abc import Sequence
8
8
 
9
- from .commands import CommandResult, handle_diagnostics, handle_runtime_command
9
+ from .commands import handle_diagnostics, handle_runtime_command
10
10
  from .compat import UnsupportedPythonVersion, ensure_supported_python
11
11
  from .paths import resolve_runtime_paths
12
+ from .results import CommandResult as CommandResult
12
13
 
13
14
  DESCRIPTION = (
14
15
  "PrizmKit canonical Python runtime CLI.\n"
15
16
  "Runs operation-first pipeline, status, reset, daemon, diagnostics, and helper commands."
16
17
  )
17
18
 
18
- _FAMILIES = ("feature", "bugfix", "refactor")
19
+ _FAMILIES = ("feature", "bugfix")
19
20
  _GLOBAL_OPTIONS_WITH_VALUES = {"--project-root", "--pipeline-root"}
20
21
  _LEAF_OPTIONS_WITH_VALUES = {
21
22
  "--env",
@@ -47,17 +48,19 @@ def _non_negative_int(value: str) -> int:
47
48
  return parsed
48
49
 
49
50
 
50
- def _add_runner_arguments(parser: argparse.ArgumentParser, family: str) -> None:
51
+ def _add_status_arguments(parser: argparse.ArgumentParser, family: str) -> None:
51
52
  parser.add_argument("operand", nargs="?", help="Optional task ID or family plan path.")
52
53
  parser.add_argument("second_operand", nargs="?", help="Optional family plan path or task ID.")
53
54
  if family == "feature":
54
55
  parser.add_argument("--features", help="Feature ID, range, or comma-separated selection.")
56
+
57
+
58
+ def _add_run_arguments(parser: argparse.ArgumentParser, family: str) -> None:
59
+ _add_status_arguments(parser, family)
55
60
  parser.add_argument("--max-retries", type=_non_negative_int)
56
61
  parser.add_argument("--max-infra-retries", type=_non_negative_int)
57
62
  parser.add_argument("--resume-phase")
58
63
  parser.add_argument("--dry-run", action="store_true")
59
- parser.add_argument("--clean", action="store_true")
60
- parser.add_argument("--no-reset", action="store_true")
61
64
 
62
65
 
63
66
  def _add_run_subparsers(
@@ -67,7 +70,7 @@ def _add_run_subparsers(
67
70
  family_subparsers = run_parser.add_subparsers(dest="run_family", required=True)
68
71
  for family in _FAMILIES:
69
72
  family_parser = family_subparsers.add_parser(family, help=f"Run the {family} pipeline")
70
- _add_runner_arguments(family_parser, family)
73
+ _add_run_arguments(family_parser, family)
71
74
  _set_handler(family_parser, "run", "run", family)
72
75
 
73
76
 
@@ -78,7 +81,7 @@ def _add_status_subparsers(
78
81
  target_subparsers = status_parser.add_subparsers(dest="status_target", required=True)
79
82
  for family in _FAMILIES:
80
83
  family_parser = target_subparsers.add_parser(family, help=f"Show {family} status")
81
- _add_runner_arguments(family_parser, family)
84
+ _add_status_arguments(family_parser, family)
82
85
  _set_handler(family_parser, "status", "status", family)
83
86
  all_parser = target_subparsers.add_parser(
84
87
  "all",
@@ -7,11 +7,12 @@ from dataclasses import dataclass
7
7
  from .compat import MIN_PYTHON
8
8
  from .interoperability import UTILITY_ENTRYPOINTS, describe_existing_entrypoint
9
9
  from .paths import RuntimePaths, resolve_runtime_paths
10
+ from .results import CommandResult as CommandResult
10
11
 
11
12
  RUNTIME_STATUS = "python-runtime-canonical"
12
13
  CANONICAL_RUNTIME_NOTE = "The Python CLI and prizmkit_runtime modules are the canonical runtime."
13
14
  PYTHON_CLI = "dev-pipeline/cli.py"
14
- _FAMILIES = ("feature", "bugfix", "refactor")
15
+ _FAMILIES = ("feature", "bugfix")
15
16
 
16
17
 
17
18
  @dataclass(frozen=True)
@@ -33,26 +34,6 @@ class RuntimeCommand:
33
34
  return (self.group, self.target, self.action)
34
35
 
35
36
 
36
- @dataclass(frozen=True)
37
- class CommandResult:
38
- """Result returned by runtime command handlers."""
39
-
40
- exit_code: int
41
- title: str
42
- message: str
43
- details: tuple[str, ...] = ()
44
- stdout: str | None = None
45
- stderr: str | None = None
46
-
47
- def render(self) -> str:
48
- """Render a deterministic human-readable result."""
49
- if self.stdout is not None:
50
- return self.stdout
51
- lines = [self.title, self.message]
52
- lines.extend(self.details)
53
- return "\n".join(line for line in lines if line)
54
-
55
-
56
37
  def _runtime_invocation(group: str, action: str, target: str | None = None) -> str:
57
38
  if group == "daemon" and target is not None:
58
39
  command = f"daemon {target} {action}"
@@ -8,12 +8,20 @@ import shlex
8
8
  import shutil
9
9
  import subprocess
10
10
  from collections.abc import Mapping
11
- from dataclasses import dataclass
11
+ from dataclasses import dataclass, field
12
12
  from pathlib import Path
13
13
 
14
14
  from .launch_profiles import HeadlessLaunchProfile
15
15
  from .paths import RuntimePaths
16
- from .platform_detection import PlatformSelectionError, parse_platform_selection
16
+ from .platform_detection import (
17
+ CLI_BY_PLATFORM,
18
+ INSTALLED_MARKER_DIRS,
19
+ INSTALLED_PLATFORM_ORDER,
20
+ INSTALLED_SKILL_MARKERS,
21
+ PlatformSelectionError,
22
+ parse_platform_selection,
23
+ platform_from_command,
24
+ )
17
25
 
18
26
 
19
27
  @dataclass(frozen=True)
@@ -65,6 +73,7 @@ class RuntimeConfig:
65
73
  effort: str | None
66
74
  effort_validation: EffortValidationResult
67
75
  runtime_mode: str = "python-runtime-canonical"
76
+ env_values: Mapping[str, str] = field(default_factory=dict)
68
77
 
69
78
 
70
79
  AI_CLIENT_PRECEDENCE = (
@@ -97,6 +106,28 @@ class RuntimeConfigError(ValueError):
97
106
  """Raised when runtime configuration cannot be represented safely."""
98
107
 
99
108
 
109
+ def _strip_env_comment(line: str) -> str:
110
+ """Strip an unquoted `#` comment suffix from a single env line."""
111
+ quote_char: str | None = None
112
+ escaped = False
113
+ for index, char in enumerate(line):
114
+ if escaped:
115
+ escaped = False
116
+ continue
117
+ if char == "\\" and quote_char == '"':
118
+ escaped = True
119
+ continue
120
+ if char in ("'", '"'):
121
+ if quote_char is None:
122
+ quote_char = char
123
+ elif quote_char == char:
124
+ quote_char = None
125
+ continue
126
+ if char == "#" and quote_char is None:
127
+ return line[:index].strip()
128
+ return line.strip()
129
+
130
+
100
131
  def load_env_file(path: Path, base_env: Mapping[str, str] | None = None) -> dict[str, str]:
101
132
  """Load a simple shell-style .env file without overriding base values.
102
133
 
@@ -117,7 +148,7 @@ def load_env_file(path: Path, base_env: Mapping[str, str] | None = None) -> dict
117
148
  line = raw_line.strip()
118
149
  if not line or line.startswith("#"):
119
150
  continue
120
- line = line.split("#", 1)[0].strip()
151
+ line = _strip_env_comment(line)
121
152
  if not line or "=" not in line:
122
153
  continue
123
154
  key, value = line.split("=", 1)
@@ -177,50 +208,11 @@ def _cli_names_for_platform(platform: str | None) -> tuple[str, ...]:
177
208
  hosts = parse_platform_selection(normalized)
178
209
  except PlatformSelectionError:
179
210
  return ()
180
- cli_by_host = {
181
- "codex": ("codex",),
182
- "claude": ("claude",),
183
- "codebuddy": ("cbc",),
184
- "pi": ("pi",),
185
- "cursor": ("agent",),
186
- "antigravity": ("agy",),
187
- }
188
- names: list[str] = []
189
- for host in hosts:
190
- names.extend(cli_by_host[host])
191
- return tuple(names)
211
+ return tuple(CLI_BY_PLATFORM[host] for host in hosts)
192
212
 
193
213
 
194
214
  def _known_platform_from_cli(cli_command: str | None) -> str | None:
195
- if not cli_command or not cli_command.strip():
196
- return None
197
- raw = cli_command.strip()
198
- unquoted = raw[1:-1] if len(raw) >= 2 and raw[0] == raw[-1] and raw[0] in "'\"" else raw
199
- if len(unquoted) >= 3 and unquoted[1:3] in {":\\", ":/"} and unquoted.lower().endswith((".exe", ".cmd", ".bat")):
200
- token = unquoted
201
- else:
202
- try:
203
- token = shlex.split(raw)[0]
204
- except (ValueError, IndexError):
205
- token = raw.split()[0].strip("'\"")
206
- name = token.replace("\\", "/").rsplit("/", 1)[-1].lower()
207
- for suffix in (".exe", ".cmd", ".bat"):
208
- if name.endswith(suffix):
209
- name = name[: -len(suffix)]
210
- break
211
- if name == "claude":
212
- return "claude"
213
- if name == "codex":
214
- return "codex"
215
- if name == "pi":
216
- return "pi"
217
- if name == "agent":
218
- return "cursor"
219
- if name in {"agy", "antigravity"}:
220
- return "antigravity"
221
- if name in {"cbc", "codebuddy"}:
222
- return "codebuddy"
223
- return None
215
+ return platform_from_command(cli_command, allow_substring=False) or None
224
216
 
225
217
 
226
218
  def _concrete_platform(platform: str | None) -> str | None:
@@ -236,6 +228,8 @@ def _cursor_agent_is_verified(executable: str) -> bool:
236
228
  completed = subprocess.run(
237
229
  [executable, argument],
238
230
  text=True,
231
+ encoding="utf-8",
232
+ errors="replace",
239
233
  stdout=subprocess.PIPE,
240
234
  stderr=subprocess.STDOUT,
241
235
  check=False,
@@ -260,7 +254,7 @@ def _resolve_cli_name(cli_name: str, env: Mapping[str, str]) -> str | None:
260
254
  return None
261
255
  if cli_name == "agent" and not _cursor_agent_is_verified(resolved):
262
256
  return None
263
- return cli_name
257
+ return resolved if os.name == "nt" else cli_name
264
258
 
265
259
 
266
260
  def _cli_for_platform(platform: str | None, env: Mapping[str, str]) -> str | None:
@@ -328,30 +322,12 @@ def _installed_platform_cli(
328
322
  paths: RuntimePaths,
329
323
  env: Mapping[str, str],
330
324
  ) -> tuple[str | None, str | None]:
331
- if (paths.project_root / ".pi" / "skills" / "prizmkit" / "SKILL.md").is_file():
332
- resolved = _resolve_cli_name("pi", env)
333
- if resolved:
334
- return resolved, "installed-platform:pi"
335
- if (paths.project_root / ".agents" / "skills" / "prizmkit" / "SKILL.md").is_file():
336
- resolved = _resolve_cli_name("codex", env)
337
- if resolved:
338
- return resolved, "installed-platform:codex"
339
- if (paths.project_root / ".claude" / "commands" / "prizmkit.md").is_file():
340
- resolved = _resolve_cli_name("claude", env)
341
- if resolved:
342
- return resolved, "installed-platform:claude"
343
- if (paths.project_root / ".codebuddy" / "skills" / "prizmkit" / "SKILL.md").is_file():
344
- resolved = _resolve_cli_name("cbc", env)
345
- if resolved:
346
- return resolved, "installed-platform:codebuddy"
347
- if (paths.project_root / ".cursor" / "skills" / "prizmkit" / "SKILL.md").is_file():
348
- resolved = _resolve_cli_name("agent", env)
349
- if resolved:
350
- return resolved, "installed-platform:cursor"
351
- if (paths.project_root / ".agents" / "plugins" / "prizmkit" / "skills" / "prizmkit" / "SKILL.md").is_file():
352
- resolved = _resolve_cli_name("agy", env)
353
- if resolved:
354
- return resolved, "installed-platform:antigravity"
325
+ for platform in INSTALLED_PLATFORM_ORDER:
326
+ marker_path = paths.project_root / INSTALLED_SKILL_MARKERS[platform]
327
+ if marker_path.is_file():
328
+ resolved = _resolve_cli_name(CLI_BY_PLATFORM[platform], env)
329
+ if resolved:
330
+ return resolved, f"installed-platform:{platform}"
355
331
  return None, None
356
332
 
357
333
 
@@ -541,14 +517,7 @@ def load_runtime_config(paths: RuntimePaths, env: Mapping[str, str] | None = Non
541
517
  env_file=paths.prizmkit_dir / ".env",
542
518
  config_file=paths.prizmkit_dir / "config.json",
543
519
  manifest_file=paths.prizmkit_dir / "manifest.json",
544
- installed_platform_markers=(
545
- paths.project_root / ".codebuddy",
546
- paths.project_root / ".claude",
547
- paths.project_root / ".codex",
548
- paths.project_root / ".pi",
549
- paths.project_root / ".cursor",
550
- paths.project_root / ".agents" / "plugins" / "prizmkit",
551
- ),
520
+ installed_platform_markers=tuple(paths.project_root / rel for rel in INSTALLED_MARKER_DIRS),
552
521
  path_entries=_path_entries(runtime_env),
553
522
  sources=("environment", "prizmkit-env", "prizmkit-config", "installed-platform-markers", "PATH"),
554
523
  )
@@ -561,6 +530,7 @@ def load_runtime_config(paths: RuntimePaths, env: Mapping[str, str] | None = Non
561
530
  heartbeat_interval_seconds=_int_from_env(runtime_env, "HEARTBEAT_INTERVAL", _int_from_env(runtime_env, "HEARTBEAT_INTERVAL_SECONDS", 30)),
562
531
  heartbeat_timeout_seconds=_int_from_env(runtime_env, "HEARTBEAT_STALE_THRESHOLD", _int_from_env(runtime_env, "HEARTBEAT_TIMEOUT_SECONDS", 600)),
563
532
  model=runtime_env.get("MODEL"),
564
- effort=effort,
533
+ effort=effort_validation.effort,
565
534
  effort_validation=effort_validation,
535
+ env_values=dict(runtime_env),
566
536
  )