prizmkit 1.1.196 → 1.1.197

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 (106) hide show
  1. package/bin/create-prizmkit.js +0 -2
  2. package/bundled/VERSION.json +3 -3
  3. package/bundled/adapters/antigravity/assets/prizmkit-hook.cjs +1 -1
  4. package/bundled/adapters/antigravity/rules-adapter.js +1 -13
  5. package/bundled/adapters/claude/paths.js +0 -1
  6. package/bundled/adapters/codex/paths.js +0 -1
  7. package/bundled/adapters/codex/settings-adapter.js +1 -1
  8. package/bundled/adapters/cursor/assets/prizmkit-hook.cjs +1 -1
  9. package/bundled/adapters/cursor/rules-adapter.js +1 -13
  10. package/bundled/adapters/pi/paths.js +0 -1
  11. package/bundled/dev-pipeline/.env.example +2 -2
  12. package/bundled/dev-pipeline/README.md +6 -5
  13. package/bundled/dev-pipeline/assets/skill-subagent-integration.md +2 -2
  14. package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +15 -25
  15. package/bundled/dev-pipeline/prizmkit_runtime/iterate.py +1 -69
  16. package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +1 -114
  17. package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +2 -2
  18. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +78 -0
  19. package/bundled/dev-pipeline/prizmkit_runtime/runtime_helper.py +4 -234
  20. package/bundled/dev-pipeline/prizmkit_runtime/status.py +0 -5
  21. package/bundled/dev-pipeline/prizmkit_runtime/stream_progress.py +9 -1
  22. package/bundled/dev-pipeline/scripts/feature_list_contract.py +0 -43
  23. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +15 -76
  24. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +9 -112
  25. package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +0 -13
  26. package/bundled/dev-pipeline/scripts/init-pipeline.py +0 -1
  27. package/bundled/dev-pipeline/scripts/prompt_framework.py +0 -79
  28. package/bundled/dev-pipeline/scripts/status_common.py +150 -4
  29. package/bundled/dev-pipeline/scripts/update-bug-status.py +20 -2
  30. package/bundled/dev-pipeline/scripts/update-feature-status.py +20 -2
  31. package/bundled/dev-pipeline/scripts/utils.py +6 -0
  32. package/bundled/dev-pipeline/templates/bootstrap-prompt.md +4 -5
  33. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +5 -101
  34. package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +0 -35
  35. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +4 -52
  36. package/bundled/dev-pipeline/templates/feature-list-schema.json +0 -25
  37. package/bundled/dev-pipeline/templates/iterate/evaluate-prompt.md +5 -16
  38. package/bundled/dev-pipeline/templates/iterate/evaluation-schema.json +1 -58
  39. package/bundled/dev-pipeline/templates/iterate/headless-plan-prompt.md +1 -12
  40. package/bundled/dev-pipeline/templates/sections/artifact-manifest.md +0 -1
  41. package/bundled/dev-pipeline/templates/sections/bugfix-phase-commit-report.md +0 -1
  42. package/bundled/dev-pipeline/templates/sections/bugfix-phase-diagnose-plan.md +2 -2
  43. package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +1 -1
  44. package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +1 -1
  45. package/bundled/dev-pipeline/templates/sections/bugfix-reminders.md +0 -2
  46. package/bundled/dev-pipeline/templates/sections/bugfix-session-context.md +0 -1
  47. package/bundled/dev-pipeline/templates/sections/bugfix-task-contract.md +0 -5
  48. package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +1 -2
  49. package/bundled/dev-pipeline/templates/sections/feature-completion-summary.md +1 -1
  50. package/bundled/dev-pipeline/templates/sections/phase-commit-full.md +3 -3
  51. package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +3 -3
  52. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +3 -3
  53. package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +1 -1
  54. package/bundled/dev-pipeline/templates/sections/retrospective.md +3 -3
  55. package/bundled/dev-pipeline/templates/sections/runtime-commit-handoff.md +1 -1
  56. package/bundled/rules/USAGE.md +5 -19
  57. package/bundled/rules/general/coding-baseline.md +2 -2
  58. package/bundled/rules/prizm/prizm-progressive-loading.md +2 -1
  59. package/bundled/skills/_metadata.json +4 -4
  60. package/bundled/skills/app-planner/SKILL.md +1 -1
  61. package/bundled/skills/app-planner/references/generated-plan-review.md +1 -1
  62. package/bundled/skills/app-planner/references/rules-configuration.md +6 -7
  63. package/bundled/skills/app-planner/scripts/validate-rules-configuration.py +2 -20
  64. package/bundled/skills/bug-planner/SKILL.md +5 -6
  65. package/bundled/skills/bug-planner/assets/bug-confirmation-template.md +1 -1
  66. package/bundled/skills/bug-planner/references/input-formats.md +2 -2
  67. package/bundled/skills/bug-planner/references/schema-validation.md +0 -1
  68. package/bundled/skills/bug-planner/scripts/validate-bug-list.py +2 -9
  69. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +36 -25
  70. package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +32 -26
  71. package/bundled/skills/feature-pipeline-launcher/SKILL.md +33 -25
  72. package/bundled/skills/feature-pipeline-launcher/references/configuration.md +32 -26
  73. package/bundled/skills/feature-planner/SKILL.md +4 -10
  74. package/bundled/skills/feature-planner/references/completeness-review.md +2 -2
  75. package/bundled/skills/feature-planner/references/new-project-planning.md +0 -1
  76. package/bundled/skills/feature-planner/scripts/validate-and-generate.py +1 -25
  77. package/bundled/skills/iterate-pipeline-launcher/SKILL.md +53 -42
  78. package/bundled/skills/iterate-pipeline-launcher/references/configuration.md +47 -43
  79. package/bundled/skills/prizmkit-code-review/SKILL.md +1 -1
  80. package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +2 -2
  81. package/bundled/skills/prizmkit-implement/SKILL.md +1 -1
  82. package/bundled/skills/prizmkit-init/SKILL.md +6 -7
  83. package/bundled/skills/prizmkit-init/references/config-schema.md +5 -9
  84. package/bundled/skills/prizmkit-init/references/rules/layer-detection.md +1 -1
  85. package/bundled/skills/prizmkit-plan/SKILL.md +1 -1
  86. package/bundled/skills/prizmkit-retrospective/SKILL.md +3 -3
  87. package/bundled/skills/prizmkit-retrospective/references/rule-evolution-steps.md +11 -17
  88. package/bundled/skills/prizmkit-workflow/SKILL.md +6 -3
  89. package/bundled/skills/prizmkit-workflow/references/cold-start-rules.md +8 -7
  90. package/bundled/templates/project-memory-template.md +2 -1
  91. package/package.json +1 -1
  92. package/src/clean.js +29 -7
  93. package/src/config.js +13 -15
  94. package/src/index.js +1 -5
  95. package/src/manifest.js +3 -6
  96. package/src/platforms.js +0 -14
  97. package/src/scaffold.js +93 -313
  98. package/src/upgrade.js +32 -31
  99. package/bundled/adapters/claude/rules-adapter.js +0 -25
  100. package/bundled/adapters/codebuddy/rules-adapter.js +0 -30
  101. package/bundled/adapters/codex/rules-adapter.js +0 -30
  102. package/bundled/adapters/pi/rules-adapter.js +0 -13
  103. package/bundled/dev-pipeline/templates/sections/bugfix-phase-manual-verification.md +0 -10
  104. package/bundled/dev-pipeline/templates/sections/phase-browser-verification.md +0 -111
  105. package/bundled/skills/bug-planner/references/verification.md +0 -26
  106. package/bundled/skills/feature-planner/references/browser-interaction.md +0 -39
@@ -1,4 +1,4 @@
1
- """Shared AI platform and skill path detection for prompt/runtime helpers."""
1
+ """Shared AI platform detection for prompt/runtime helpers."""
2
2
 
3
3
  from __future__ import annotations
4
4
 
@@ -52,26 +52,6 @@ class PlatformResolution:
52
52
  notes: tuple[str, ...] = ()
53
53
 
54
54
 
55
- @dataclass(frozen=True)
56
- class SkillCandidate:
57
- """One possible filesystem location for a skill."""
58
-
59
- platform: str
60
- scope: str
61
- path: Path
62
-
63
-
64
- @dataclass(frozen=True)
65
- class SkillResolution:
66
- """Resolved skill lookup result."""
67
-
68
- marker: str
69
- platform: str
70
- skill: str
71
- path: Path | None
72
- candidates: tuple[SkillCandidate, ...]
73
-
74
-
75
55
  _PLATFORM_MARKERS = {
76
56
  "claude": (".claude/commands", ".claude/skills"),
77
57
  "codex": (".agents/skills",),
@@ -82,40 +62,6 @@ _PLATFORM_MARKERS = {
82
62
  }
83
63
 
84
64
 
85
- _PLATFORM_SKILL_PATTERNS = {
86
- "claude": (
87
- ("project-command-file", ".claude/commands/{skill}.md"),
88
- ("project-command-dir", ".claude/commands/{skill}"),
89
- ("project-skill", ".claude/skills/{skill}"),
90
- ("home-skill", "~/.claude/skills/{skill}"),
91
- ),
92
- "codex": (
93
- ("project-skill", ".agents/skills/{skill}"),
94
- ("project-codex-skill", ".codex/skills/{skill}"),
95
- ),
96
- "codebuddy": (
97
- ("project-skill", ".codebuddy/skills/{skill}"),
98
- ("home-skill", "~/.codebuddy/skills/{skill}"),
99
- ("legacy-home-skill", "~/.cbc/skills/{skill}"),
100
- ),
101
- "pi": (
102
- ("project-skill", ".pi/skills/{skill}"),
103
- ("project-agent-skill", ".agents/skills/{skill}"),
104
- ("home-skill", "~/.pi/agent/skills/{skill}"),
105
- ),
106
- "cursor": (
107
- ("project-skill", ".cursor/skills/{skill}"),
108
- ("project-agent-skill", ".agents/skills/{skill}"),
109
- ("home-skill", "~/.cursor/skills/{skill}"),
110
- ),
111
- "antigravity": (
112
- ("project-plugin-skill", ".agents/plugins/prizmkit/skills/{skill}"),
113
- ("project-agent-skill", ".agents/skills/{skill}"),
114
- ("home-skill", "~/.gemini/config/skills/{skill}"),
115
- ),
116
- }
117
-
118
-
119
65
  def read_json_object(path: str | Path) -> dict:
120
66
  """Read a JSON object, returning an empty dict when unavailable."""
121
67
  try:
@@ -268,62 +214,3 @@ def resolve_platform(project_root: str | Path, env: Mapping[str, str] | None = N
268
214
  "or install Claude/Codex/CodeBuddy/Pi/Cursor/Antigravity platform files.",
269
215
  ),
270
216
  )
271
-
272
-
273
- def _expand_skill_pattern(project_root: Path, skill: str, platform: str, scope: str, pattern: str) -> SkillCandidate:
274
- rendered = pattern.format(skill=skill)
275
- if rendered.startswith("~"):
276
- path = Path(rendered).expanduser()
277
- else:
278
- path = project_root / rendered
279
- return SkillCandidate(platform=platform, scope=scope, path=path.resolve())
280
-
281
-
282
- def skill_candidates(project_root: str | Path, skill: str, platform: str) -> tuple[SkillCandidate, ...]:
283
- """Return deterministic candidate locations for a skill on one platform."""
284
- normalized = valid_prompt_platform(platform)
285
- if not normalized:
286
- return ()
287
- root = Path(project_root).expanduser().resolve()
288
- return tuple(
289
- _expand_skill_pattern(root, skill, normalized, scope, pattern)
290
- for scope, pattern in _PLATFORM_SKILL_PATTERNS[normalized]
291
- )
292
-
293
-
294
- def _candidate_matches(candidate: SkillCandidate, skill: str, *, prefix: bool) -> bool:
295
- path = candidate.path
296
- if path.exists():
297
- return True
298
- if not prefix:
299
- return False
300
- parent = path.parent
301
- if not parent.is_dir():
302
- return False
303
- return any(child.name.startswith(skill) for child in parent.iterdir())
304
-
305
-
306
- def resolve_skill(
307
- project_root: str | Path,
308
- skill: str,
309
- *,
310
- platform: str = "auto",
311
- env: Mapping[str, str] | None = None,
312
- prefix: bool = False,
313
- ) -> SkillResolution:
314
- """Resolve a skill path for the selected platform."""
315
- normalized_skill = str(skill or "").strip()
316
- selected_platform = valid_prompt_platform(platform)
317
- if platform == "auto" or not platform:
318
- selected_platform = resolve_platform(project_root, env=env).platform
319
- if not selected_platform:
320
- return SkillResolution("NOT_INSTALLED", "", normalized_skill, None, ())
321
-
322
- candidates = skill_candidates(project_root, normalized_skill, selected_platform)
323
- for candidate in candidates:
324
- if _candidate_matches(candidate, normalized_skill, prefix=prefix):
325
- if candidate.path.exists():
326
- return SkillResolution("SKILL_EXISTS", selected_platform, normalized_skill, candidate.path, candidates)
327
- matches = sorted(child for child in candidate.path.parent.iterdir() if child.name.startswith(normalized_skill))
328
- return SkillResolution("SKILL_EXISTS", selected_platform, normalized_skill, matches[0].resolve(), candidates)
329
- return SkillResolution("SKILL_MISSING", selected_platform, normalized_skill, None, candidates)
@@ -35,7 +35,7 @@ class RunnerFamily:
35
35
  class RunnerEnvironment:
36
36
  """Legacy runner environment controls modeled as one cohesive unit."""
37
37
 
38
- stop_on_failure: bool = False
38
+ stop_on_failure: bool = True
39
39
  auto_push: bool = False
40
40
  dev_branch: str = ""
41
41
  verbose: bool = False
@@ -49,7 +49,7 @@ class RunnerEnvironment:
49
49
  def from_env(cls, env: Mapping[str, str] | None = None) -> "RunnerEnvironment":
50
50
  values = dict(os.environ if env is None else env)
51
51
  return cls(
52
- stop_on_failure=_truthy(values.get("STOP_ON_FAILURE")),
52
+ stop_on_failure=not _falsey(values.get("STOP_ON_FAILURE")),
53
53
  auto_push=_truthy(values.get("AUTO_PUSH")),
54
54
  dev_branch=values.get("DEV_BRANCH", ""),
55
55
  verbose=_truthy(values.get("VERBOSE")),
@@ -1549,6 +1549,12 @@ def _complete_success_merge(
1549
1549
  raise RuntimeError(f"Task {item_id} checkout identity disappeared before completion")
1550
1550
  complete_task_checkout_locked(family.state_dir, checkout)
1551
1551
  _emit_success(f"Merged {branch_name} into {base_branch}")
1552
+ artifact_dir = _artifact_path_for_item(paths.project_root, status_family, item_id, {})
1553
+ if not (artifact_dir / "retrospective-result.json").is_file() and execution_root != paths.project_root:
1554
+ fallback_dir = _artifact_path_for_item(execution_root, status_family, item_id, {})
1555
+ if (fallback_dir / "retrospective-result.json").is_file():
1556
+ artifact_dir = fallback_dir
1557
+ _emit_pending_rule_proposals_for_item(family, item_id, artifact_dir, paths.project_root)
1552
1558
  return new_status
1553
1559
  abort_in_progress_git_operation(paths.project_root)
1554
1560
  _emit_warning(
@@ -1771,6 +1777,78 @@ def _artifact_path_for_item(project_root: Path, family: RunnerFamily, item_id: s
1771
1777
  return project_root / ".prizmkit" / family.artifact_root_name / item_id
1772
1778
 
1773
1779
 
1780
+ def _emit_pending_rule_proposals_for_item(
1781
+ family: RunnerFamily,
1782
+ item_id: str,
1783
+ artifact_dir: Path | None,
1784
+ project_root: Path,
1785
+ ) -> list[dict[str, str]]:
1786
+ """Log RULES_PROPOSED entries from retrospective-result.json on completion."""
1787
+ candidate_dirs: list[Path] = []
1788
+ if artifact_dir is not None:
1789
+ candidate_dirs.append(artifact_dir)
1790
+ resolved_dir = _artifact_path_for_item(project_root, family, item_id, {})
1791
+ if resolved_dir not in candidate_dirs:
1792
+ candidate_dirs.append(resolved_dir)
1793
+ if family.kind == "feature":
1794
+ exact_dir = project_root / ".prizmkit" / "specs" / item_id
1795
+ if exact_dir not in candidate_dirs:
1796
+ candidate_dirs.append(exact_dir)
1797
+
1798
+ result_file = next(
1799
+ (candidate / "retrospective-result.json" for candidate in candidate_dirs if (candidate / "retrospective-result.json").is_file()),
1800
+ None,
1801
+ )
1802
+ if result_file is None:
1803
+ return []
1804
+ try:
1805
+ payload = json.loads(result_file.read_text(encoding="utf-8"))
1806
+ except (OSError, ValueError, TypeError):
1807
+ return []
1808
+ if not isinstance(payload, dict):
1809
+ return []
1810
+ rule_evolution = payload.get("rule_evolution")
1811
+ if not isinstance(rule_evolution, dict) or rule_evolution.get("status") != "RULES_PROPOSED":
1812
+ return []
1813
+ proposals = rule_evolution.get("proposals")
1814
+ if not isinstance(proposals, list):
1815
+ return []
1816
+
1817
+ normalized: list[dict[str, str]] = []
1818
+ for entry in proposals:
1819
+ if not isinstance(entry, dict):
1820
+ continue
1821
+ target_path = entry.get("target_path")
1822
+ clause = entry.get("clause")
1823
+ reason = entry.get("reason")
1824
+ if (
1825
+ isinstance(target_path, str)
1826
+ and target_path.strip()
1827
+ and isinstance(clause, str)
1828
+ and clause.strip()
1829
+ and isinstance(reason, str)
1830
+ and reason.strip()
1831
+ ):
1832
+ normalized.append(
1833
+ {
1834
+ "target_path": target_path.strip(),
1835
+ "clause": clause.strip(),
1836
+ "reason": reason.strip(),
1837
+ }
1838
+ )
1839
+ if not normalized:
1840
+ return []
1841
+
1842
+ try:
1843
+ display_path = result_file.relative_to(project_root).as_posix()
1844
+ except ValueError:
1845
+ display_path = str(result_file)
1846
+ _emit_info(f"Pending rule proposals for {item_id} (manual confirmation required; see {display_path}):")
1847
+ for proposal in normalized:
1848
+ _emit_info(f" - [{proposal['target_path']}] {proposal['clause']} ({proposal['reason']})")
1849
+ return normalized
1850
+
1851
+
1774
1852
  def _feature_slug(feature_id: str, title: str) -> str:
1775
1853
  import re
1776
1854
 
@@ -1,10 +1,9 @@
1
1
  """Cross-platform helper CLI for prompt runtime operations.
2
2
 
3
3
  The helpers in this module use Python standard-library APIs for file checks,
4
- source discovery, text search, platform detection, executable checks, port
5
- readiness, process cleanup, and lightweight browser-readiness polling. Stdout
6
- starts with deterministic markers so generated AI prompts can branch on text
7
- instead of shell exit-code chains.
4
+ source discovery, text search, and review-verdict parsing. Stdout starts with
5
+ deterministic markers so generated AI prompts can branch on text instead of
6
+ shell exit-code chains.
8
7
  """
9
8
 
10
9
  from __future__ import annotations
@@ -12,21 +11,10 @@ from __future__ import annotations
12
11
  import argparse
13
12
  import json
14
13
  import os
15
- import shutil
16
- import socket
17
- import subprocess
18
- import sys
19
- import time
20
- import urllib.error
21
- import urllib.request
22
- from dataclasses import asdict, dataclass
14
+ from dataclasses import dataclass
23
15
  from pathlib import Path
24
16
  from typing import Any
25
17
 
26
- from .paths import resolve_runtime_paths
27
- from .platform_detection import resolve_platform, resolve_skill
28
- from .processes import is_pid_running, terminate_pid_tree
29
-
30
18
  SOURCE_EXTENSIONS = (
31
19
  ".js",
32
20
  ".jsx",
@@ -327,149 +315,6 @@ def _text_final_verdict(args: argparse.Namespace) -> HelperResult:
327
315
  return HelperResult(marker, True, {"path": str(target), "verdict": verdict})
328
316
 
329
317
 
330
- def _platform_detect(args: argparse.Namespace) -> HelperResult:
331
- paths = resolve_runtime_paths(project_root=args.project_root, pipeline_root=args.pipeline_root)
332
- resolution = resolve_platform(paths.project_root)
333
- marker = resolution.platform.upper() if resolution.platform else "NOT_INSTALLED"
334
- return HelperResult(marker, bool(resolution.platform), {"platform": resolution.platform, "source": resolution.source, "notes": list(resolution.notes)})
335
-
336
-
337
- def _platform_skill(args: argparse.Namespace) -> HelperResult:
338
- paths = resolve_runtime_paths(project_root=args.project_root, pipeline_root=args.pipeline_root)
339
- resolution = resolve_skill(paths.project_root, args.skill, platform=args.platform, prefix=args.prefix)
340
- fields = {
341
- "platform": resolution.platform,
342
- "skill": resolution.skill,
343
- "path": str(resolution.path) if resolution.path else None,
344
- "candidates": [asdict(candidate) | {"path": str(candidate.path)} for candidate in resolution.candidates],
345
- }
346
- return HelperResult(resolution.marker, resolution.marker == "SKILL_EXISTS", fields)
347
-
348
-
349
- def _executable_check(args: argparse.Namespace) -> HelperResult:
350
- executable = shutil.which(args.name)
351
- return HelperResult("INSTALLED" if executable else "NOT_INSTALLED", bool(executable), {"name": args.name, "path": executable})
352
-
353
-
354
- def _executable_version(args: argparse.Namespace) -> HelperResult:
355
- executable = shutil.which(args.name)
356
- if not executable:
357
- return HelperResult("NOT_INSTALLED", False, {"name": args.name}, 1)
358
- command = [executable, *(args.arg or ["--version"])]
359
- try:
360
- completed = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, timeout=args.timeout, check=False)
361
- except (OSError, subprocess.TimeoutExpired) as exc:
362
- return HelperResult("VERSION_ERROR", False, {"name": args.name, "error": type(exc).__name__}, 1)
363
- output = (completed.stdout or completed.stderr or "").strip().splitlines()
364
- return HelperResult("VERSION", completed.returncode == 0, {"name": args.name, "path": executable, "version": output[0] if output else "", "return_code": completed.returncode}, completed.returncode)
365
-
366
-
367
- def _port_check(args: argparse.Namespace) -> HelperResult:
368
- port = int(args.port)
369
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
370
- try:
371
- sock.settimeout(float(args.timeout))
372
- in_use = sock.connect_ex((args.host, port)) == 0
373
- finally:
374
- sock.close()
375
- return HelperResult("PORT_IN_USE" if in_use else "PORT_FREE", not in_use, {"host": args.host, "port": port})
376
-
377
-
378
- def _process_status_pid(args: argparse.Namespace) -> HelperResult:
379
- pid = int(args.pid)
380
- running = is_pid_running(pid)
381
- return HelperResult("PROCESS_RUNNING" if running else "PROCESS_NOT_RUNNING", running, {"pid": pid})
382
-
383
-
384
- def _process_cleanup_pid(args: argparse.Namespace) -> HelperResult:
385
- pid = int(args.pid)
386
- result = terminate_pid_tree(pid, "runtime_helper_cleanup", grace_seconds=float(args.grace_seconds))
387
- marker = "PROCESS_TERMINATED" if result.terminated else "PROCESS_NOT_RUNNING" if not is_pid_running(pid) else "PROCESS_CLEANUP_FAILED"
388
- return HelperResult(marker, marker != "PROCESS_CLEANUP_FAILED", {"pid": pid, "forced": result.forced, "details": list(result.details)})
389
-
390
-
391
- def _process_cleanup_port(args: argparse.Namespace) -> HelperResult:
392
- # The Python standard library cannot portably map listening ports to owning
393
- # PIDs on all supported platforms without shelling out to lsof/netstat/taskkill.
394
- # Keep this deterministic and safe instead of pretending cleanup happened.
395
- port_result = _port_check(argparse.Namespace(port=args.port, host=args.host, timeout=args.timeout))
396
- marker = "PORT_FREE" if port_result.marker == "PORT_FREE" else "UNSUPPORTED"
397
- ok = marker == "PORT_FREE"
398
- return HelperResult(marker, ok, {"host": args.host, "port": int(args.port), "reason": "pid_lookup_by_port_not_available_in_python_stdlib"}, 0 if ok else 2)
399
-
400
-
401
- def _process_start(args: argparse.Namespace) -> HelperResult:
402
- command = list(args.command)
403
- if command and command[0] == "--":
404
- command = command[1:]
405
- if not command:
406
- return HelperResult("PROCESS_START_FAILED", False, {"reason": "missing_command"}, 2)
407
- cwd = _path(args.cwd or ".")
408
- opened_handles = []
409
- stdout_target = subprocess.DEVNULL
410
- stderr_target = subprocess.DEVNULL
411
- try:
412
- if args.stdout:
413
- stdout_path = _path(args.stdout)
414
- stdout_path.parent.mkdir(parents=True, exist_ok=True)
415
- stdout_target = open(stdout_path, "a", encoding="utf-8")
416
- opened_handles.append(stdout_target)
417
- if args.stderr:
418
- stderr_path = _path(args.stderr)
419
- stderr_path.parent.mkdir(parents=True, exist_ok=True)
420
- stderr_target = open(stderr_path, "a", encoding="utf-8")
421
- opened_handles.append(stderr_target)
422
- process = subprocess.Popen(
423
- [str(part) for part in command],
424
- cwd=cwd,
425
- stdout=stdout_target,
426
- stderr=stderr_target,
427
- stdin=subprocess.DEVNULL,
428
- start_new_session=(os.name != "nt"),
429
- creationflags=getattr(subprocess, "CREATE_NEW_PROCESS_GROUP", 0) if os.name == "nt" else 0,
430
- )
431
- except OSError as exc:
432
- return HelperResult("PROCESS_START_FAILED", False, {"reason": type(exc).__name__, "error": str(exc)}, 1)
433
- finally:
434
- for target in opened_handles:
435
- try:
436
- target.close()
437
- except OSError:
438
- pass
439
- if args.pid_file:
440
- pid_file = _path(args.pid_file)
441
- pid_file.parent.mkdir(parents=True, exist_ok=True)
442
- pid_file.write_text(f"{process.pid}\n", encoding="utf-8")
443
- return HelperResult("PROCESS_STARTED", True, {"pid": process.pid, "pid_file": str(_path(args.pid_file)) if args.pid_file else None})
444
-
445
-
446
- def _status_is_ready(status: int, expected_statuses: list[int] | None) -> bool:
447
- if expected_statuses:
448
- return status in expected_statuses
449
- return status < 500
450
-
451
-
452
- def _web_wait_ready(args: argparse.Namespace) -> HelperResult:
453
- deadline = time.monotonic() + float(args.timeout)
454
- statuses: list[str] = []
455
- while time.monotonic() <= deadline:
456
- try:
457
- request = urllib.request.Request(args.url, method="GET")
458
- with urllib.request.urlopen(request, timeout=float(args.request_timeout)) as response:
459
- status = int(response.status)
460
- statuses.append(str(status))
461
- if _status_is_ready(status, args.status):
462
- return HelperResult("READY", True, {"url": args.url, "status": status})
463
- except urllib.error.HTTPError as exc:
464
- statuses.append(str(exc.code))
465
- if _status_is_ready(int(exc.code), args.status):
466
- return HelperResult("READY", True, {"url": args.url, "status": int(exc.code)})
467
- except (OSError, urllib.error.URLError, TimeoutError) as exc:
468
- statuses.append(type(exc).__name__)
469
- time.sleep(float(args.interval))
470
- return HelperResult("NOT_READY", False, {"url": args.url, "observed": statuses[-5:]}, 1)
471
-
472
-
473
318
  def build_parser() -> argparse.ArgumentParser:
474
319
  parser = argparse.ArgumentParser(prog="prizmkit-runtime-helper", description="Cross-platform PrizmKit prompt runtime helper CLI.")
475
320
  subparsers = parser.add_subparsers(dest="group", required=True)
@@ -529,81 +374,6 @@ def build_parser() -> argparse.ArgumentParser:
529
374
  _add_json(final_verdict)
530
375
  final_verdict.set_defaults(func=_text_final_verdict)
531
376
 
532
- platform = subparsers.add_parser("platform", help="AI platform and skill detection")
533
- platform_sub = platform.add_subparsers(dest="action", required=True)
534
- detect = platform_sub.add_parser("detect", help="Detect current AI platform")
535
- detect.add_argument("--project-root")
536
- detect.add_argument("--pipeline-root")
537
- _add_json(detect)
538
- detect.set_defaults(func=_platform_detect)
539
- skill = platform_sub.add_parser("skill", help="Detect a platform skill")
540
- skill.add_argument("skill")
541
- skill.add_argument("--platform", default="auto")
542
- skill.add_argument("--project-root")
543
- skill.add_argument("--pipeline-root")
544
- skill.add_argument("--prefix", action="store_true")
545
- _add_json(skill)
546
- skill.set_defaults(func=_platform_skill)
547
-
548
- executable = subparsers.add_parser("executable", help="Executable checks")
549
- executable_sub = executable.add_subparsers(dest="action", required=True)
550
- check = executable_sub.add_parser("check", help="Check executable availability")
551
- check.add_argument("name")
552
- _add_json(check)
553
- check.set_defaults(func=_executable_check)
554
- version = executable_sub.add_parser("version", help="Run executable version command")
555
- version.add_argument("name")
556
- version.add_argument("--arg", action="append", default=None)
557
- version.add_argument("--timeout", type=float, default=10.0)
558
- _add_json(version)
559
- version.set_defaults(func=_executable_version)
560
-
561
- port = subparsers.add_parser("port", help="Port readiness helpers")
562
- port_sub = port.add_subparsers(dest="action", required=True)
563
- port_check = port_sub.add_parser("check", help="Check whether a TCP port is in use")
564
- port_check.add_argument("port", type=int)
565
- port_check.add_argument("--host", default="127.0.0.1")
566
- port_check.add_argument("--timeout", type=float, default=0.5)
567
- _add_json(port_check)
568
- port_check.set_defaults(func=_port_check)
569
-
570
- process = subparsers.add_parser("process", help="Process lifecycle helpers")
571
- process_sub = process.add_subparsers(dest="action", required=True)
572
- start = process_sub.add_parser("start", help="Start a process and optionally write a PID file")
573
- start.add_argument("--pid-file")
574
- start.add_argument("--cwd")
575
- start.add_argument("--stdout")
576
- start.add_argument("--stderr")
577
- start.add_argument("command", nargs=argparse.REMAINDER)
578
- _add_json(start)
579
- start.set_defaults(func=_process_start)
580
- status_pid = process_sub.add_parser("status-pid", help="Check whether a PID is running")
581
- status_pid.add_argument("pid", type=int)
582
- _add_json(status_pid)
583
- status_pid.set_defaults(func=_process_status_pid)
584
- cleanup_pid = process_sub.add_parser("cleanup-pid", help="Best-effort cleanup by PID")
585
- cleanup_pid.add_argument("pid", type=int)
586
- cleanup_pid.add_argument("--grace-seconds", type=float, default=2.0)
587
- _add_json(cleanup_pid)
588
- cleanup_pid.set_defaults(func=_process_cleanup_pid)
589
- cleanup_port = process_sub.add_parser("cleanup-port", help="Best-effort cleanup by port when supported")
590
- cleanup_port.add_argument("port", type=int)
591
- cleanup_port.add_argument("--host", default="127.0.0.1")
592
- cleanup_port.add_argument("--timeout", type=float, default=0.5)
593
- _add_json(cleanup_port)
594
- cleanup_port.set_defaults(func=_process_cleanup_port)
595
-
596
- web = subparsers.add_parser("web", help="Browser/server readiness helpers")
597
- web_sub = web.add_subparsers(dest="action", required=True)
598
- wait_ready = web_sub.add_parser("wait-ready", help="Wait for an HTTP endpoint to be ready")
599
- wait_ready.add_argument("--url", required=True)
600
- wait_ready.add_argument("--timeout", type=float, default=30.0)
601
- wait_ready.add_argument("--interval", type=float, default=2.0)
602
- wait_ready.add_argument("--request-timeout", type=float, default=2.0)
603
- wait_ready.add_argument("--status", action="append", type=int, default=None)
604
- _add_json(wait_ready)
605
- wait_ready.set_defaults(func=_web_wait_ready)
606
-
607
377
  return parser
608
378
 
609
379
 
@@ -206,7 +206,6 @@ def read_iterate_status(paths: RuntimePaths) -> dict[str, object]:
206
206
  "consecutive_failures": 0,
207
207
  "consecutive_no_progress": 0,
208
208
  "last_verdict": None,
209
- "last_evidence_mode": None,
210
209
  "pending_decisions_exists": pending_file.is_file(),
211
210
  "summary": "",
212
211
  }
@@ -244,7 +243,6 @@ def read_iterate_status(paths: RuntimePaths) -> dict[str, object]:
244
243
  "started_at": state.get("started_at"),
245
244
  "updated_at": state.get("updated_at"),
246
245
  "last_verdict": state.get("last_verdict"),
247
- "last_evidence_mode": state.get("last_evidence_mode"),
248
246
  "pending_decisions_exists": pending_file.is_file(),
249
247
  "summary": state.get("summary") or "",
250
248
  }
@@ -252,7 +250,6 @@ def read_iterate_status(paths: RuntimePaths) -> dict[str, object]:
252
250
  snapshot["last_round"] = {
253
251
  "round": last_round.get("round"),
254
252
  "verdict": last_round.get("verdict"),
255
- "evidence_mode": last_round.get("evidence_mode"),
256
253
  "appended_ids": last_round.get("appended_ids") or [],
257
254
  "completed_ids": last_round.get("completed_ids") or [],
258
255
  "failed_ids": last_round.get("failed_ids") or [],
@@ -280,8 +277,6 @@ def _format_iterate_status_text(snapshot: Mapping[str, object]) -> str:
280
277
  lines.append(f"pause_reason: {snapshot.get('pause_reason')}")
281
278
  if snapshot.get("last_verdict"):
282
279
  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
280
  if snapshot.get("focus"):
286
281
  lines.append(f"focus: {snapshot.get('focus')}")
287
282
  if snapshot.get("pending_decisions_exists"):
@@ -18,7 +18,7 @@ from .atomic_io import write_json_atomic
18
18
  # Ordered pipeline phases — index defines forward-only progression.
19
19
  # Phase detection is monotonic: once a phase is reached, earlier phases
20
20
  # cannot be re-entered (prevents false positives from file content mentions).
21
- PHASE_ORDER = ["plan", "implement", "code-review", "retrospective", "commit"]
21
+ PHASE_ORDER = ["plan", "implement", "code-review", "test", "summary", "retrospective", "commit"]
22
22
 
23
23
  # Keywords for phase detection.
24
24
  # "strong" keywords are skill invocations — high confidence, but still
@@ -46,6 +46,14 @@ PHASE_KEYWORDS = {
46
46
  "strong": ["prizmkit-code-review"],
47
47
  "weak": ["code review", "review verdict", "reviewing"],
48
48
  },
49
+ "test": {
50
+ "strong": ["prizmkit-test"],
51
+ "weak": ["test-report.md", "test-result.json", "regression ring"],
52
+ },
53
+ "summary": {
54
+ "strong": ["completion-summary", "bug-report"],
55
+ "weak": ["completion-summary.json", "fix-report.md"],
56
+ },
49
57
  "retrospective": {
50
58
  "strong": ["prizmkit-retrospective"],
51
59
  "weak": [
@@ -77,7 +77,6 @@ CURRENT_FEATURE_FIELDS = {
77
77
  "model",
78
78
  "completion_notes",
79
79
  "user_context",
80
- "browser_interaction",
81
80
  "testing",
82
81
  }
83
82
  # Historical lists may still carry these keys. They are ignored residue, not
@@ -85,13 +84,6 @@ CURRENT_FEATURE_FIELDS = {
85
84
  LEFTOVER_IGNORED_FEATURE_FIELDS = {"session_granularity", "sub_features"}
86
85
  FEATURE_ID_RE = re.compile(r"^F-\d{3}(-[A-Z])?$")
87
86
 
88
- UI_KEYWORDS_RE = re.compile(
89
- r"\b(click|button|modal|page|form|display|navigate|tab|input|opens|shows|"
90
- r"renders|visible|redirect|download|upload|preview|select|toggle|dropdown|"
91
- r"popup|toast|menu)\b",
92
- re.IGNORECASE,
93
- )
94
-
95
87
 
96
88
  @dataclass(frozen=True)
97
89
  class ContractOperationResult:
@@ -211,26 +203,6 @@ detect_cycles = _detect_cycles
211
203
  # ---------------------------------------------------------------------------
212
204
 
213
205
 
214
- def _validate_browser_interaction(label: str, browser_interaction: Any, errors: list[str]) -> None:
215
- if browser_interaction is None:
216
- return
217
- if not isinstance(browser_interaction, dict):
218
- errors.append(f"{label}: browser_interaction must be an object")
219
- return
220
- tool = browser_interaction.get("tool")
221
- if tool is not None and tool != "playwright-cli":
222
- errors.append(
223
- f"{label}: browser_interaction.tool must be 'playwright-cli', got {tool!r}"
224
- )
225
- blocking = browser_interaction.get("blocking")
226
- if blocking is not None and not isinstance(blocking, bool):
227
- errors.append(f"{label}: browser_interaction.blocking must be a boolean")
228
- verify_steps = browser_interaction.get("verify_steps")
229
- if verify_steps is not None:
230
- if not isinstance(verify_steps, list) or not all(isinstance(s, str) for s in verify_steps):
231
- errors.append(f"{label}: browser_interaction.verify_steps must be an array of strings")
232
-
233
-
234
206
  def validate_feature_list(data: Any, is_new_plan: bool = True) -> dict[str, Any]:
235
207
  """Validate a parsed feature-list structure in parity with validate-and-generate.py."""
236
208
  errors: list[str] = []
@@ -305,9 +277,6 @@ def validate_feature_list(data: Any, is_new_plan: bool = True) -> dict[str, Any]
305
277
 
306
278
  seen_ids: set[Any] = set()
307
279
  complexity_dist = {"low": 0, "medium": 0, "high": 0, "critical": 0}
308
- has_frontend = bool(
309
- isinstance(global_context, dict) and global_context.get("frontend_framework")
310
- )
311
280
 
312
281
  for idx, feat in enumerate(features):
313
282
  label = f"features[{idx}]"
@@ -401,18 +370,6 @@ def validate_feature_list(data: Any, is_new_plan: bool = True) -> dict[str, Any]
401
370
  else:
402
371
  complexity_dist[complexity] += 1
403
372
 
404
- _validate_browser_interaction(label, feat.get("browser_interaction"), errors)
405
-
406
- if has_frontend and feat.get("status") != "completed":
407
- criteria_list = feat.get("acceptance_criteria", [])
408
- if isinstance(criteria_list, list):
409
- criteria_text = " ".join(c for c in criteria_list if isinstance(c, str))
410
- if UI_KEYWORDS_RE.search(criteria_text) and feat.get("browser_interaction") is None:
411
- warnings.append(
412
- f"{label}: has UI acceptance criteria but no browser_interaction "
413
- "field. Consider adding browser verification."
414
- )
415
-
416
373
  # 3. Dependency validation
417
374
  all_ids = {f.get("id") for f in features if isinstance(f, dict)}
418
375
  for idx, feat in enumerate(features):