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
@@ -1,303 +0,0 @@
1
- """Tests for the cross-platform prompt runtime helper CLI."""
2
-
3
- import json
4
- import os
5
- import socket
6
- import subprocess
7
- import sys
8
- from pathlib import Path
9
-
10
- REPO_ROOT = Path(__file__).resolve().parents[2]
11
- PIPELINE_ROOT = REPO_ROOT / "dev-pipeline"
12
- HELPER_SCRIPT = PIPELINE_ROOT / "scripts" / "prizmkit-runtime-helper.py"
13
- CLI_PATH = PIPELINE_ROOT / "cli.py"
14
-
15
- if str(PIPELINE_ROOT) not in sys.path:
16
- sys.path.insert(0, str(PIPELINE_ROOT))
17
-
18
-
19
- def run_helper(*args, cwd=None):
20
- return subprocess.run(
21
- [sys.executable, str(HELPER_SCRIPT), *args],
22
- cwd=cwd or REPO_ROOT,
23
- text=True,
24
- stdout=subprocess.PIPE,
25
- stderr=subprocess.PIPE,
26
- check=False,
27
- )
28
-
29
-
30
- def first_line(result):
31
- return result.stdout.splitlines()[0]
32
-
33
-
34
- class TestArtifactAndTextHelpers:
35
- def test_exists_ensure_dir_touch_list_tree_and_source_files(self, tmp_path):
36
- missing = run_helper("artifact", "exists", str(tmp_path / "missing"))
37
- assert first_line(missing) == "MISSING"
38
-
39
- ready = run_helper("artifact", "ensure-dir", str(tmp_path / "src"))
40
- assert first_line(ready) == "DIR_READY"
41
- touched = run_helper("artifact", "touch", str(tmp_path / "src" / "app.py"))
42
- assert first_line(touched) == "TOUCHED"
43
- (tmp_path / "src" / "README.md").write_text("hello helper\n", encoding="utf-8")
44
- (tmp_path / "src" / "ignored.bin").write_bytes(b"\x00")
45
-
46
- listing = run_helper("artifact", "list", str(tmp_path / "src"))
47
- assert first_line(listing) == "LIST"
48
- assert "file:README.md" in listing.stdout
49
- assert "file:app.py" in listing.stdout
50
-
51
- tree = run_helper("artifact", "tree", str(tmp_path), "--max-depth", "2")
52
- assert first_line(tree) == "TREE"
53
- assert "entry: src/" in tree.stdout
54
- assert "entry: src/app.py" in tree.stdout
55
-
56
- sources = run_helper("artifact", "source-files", str(tmp_path), "--ext", ".py", "--json")
57
- payload = json.loads(sources.stdout)
58
- assert payload["marker"] == "SOURCE_FILES"
59
- assert payload["files"] == ["src/app.py"]
60
-
61
- def test_text_search_count_and_contains_markers(self, tmp_path):
62
- target = tmp_path / "notes.md"
63
- target.write_text("alpha\nbeta alpha\n", encoding="utf-8")
64
-
65
- search = run_helper("text", "search", str(tmp_path), "--pattern", "alpha")
66
- assert first_line(search) == "FOUND"
67
- assert "count: 2" in search.stdout
68
-
69
- count = run_helper("text", "count", str(tmp_path), "--pattern", "alpha")
70
- assert first_line(count) == "COUNT"
71
- assert "count: 2" in count.stdout
72
-
73
- contains = run_helper("text", "contains", str(target), "--pattern", "beta")
74
- assert first_line(contains) == "GATE:PASS"
75
- missing = run_helper("text", "contains", str(target), "--pattern", "gamma")
76
- assert first_line(missing) == "GATE:MISSING"
77
-
78
- def test_final_verdict_requires_last_final_result_section(self, tmp_path):
79
- report = tmp_path / "review-report.md"
80
- report.write_text(
81
- "# Review Report\n\n## Status: IN_PROGRESS\n\n"
82
- "## Main Review Round 1\n\n- Note: incidental PASS text\n",
83
- encoding="utf-8",
84
- )
85
- incomplete = run_helper("text", "final-verdict", str(report))
86
- assert incomplete.returncode != 0
87
- assert first_line(incomplete) == "REVIEW_INCOMPLETE"
88
-
89
- report.write_text(
90
- report.read_text(encoding="utf-8")
91
- + "\n## Final Result\n\n- Verdict: PASS\n- Summary: done\n",
92
- encoding="utf-8",
93
- )
94
- complete = run_helper("text", "final-verdict", str(report))
95
- assert complete.returncode == 0
96
- assert first_line(complete) == "REVIEW_PASS"
97
- assert "verdict: PASS" in complete.stdout
98
-
99
- def test_final_verdict_uses_last_final_result_and_rejects_unknown_value(self, tmp_path):
100
- report = tmp_path / "review-report.md"
101
- report.write_text(
102
- "## Final Result\n- Verdict: PASS\n\n"
103
- "## Final Result\n- Verdict: NEEDS_FIXES\n",
104
- encoding="utf-8",
105
- )
106
- needs_fixes = run_helper("text", "final-verdict", str(report))
107
- assert needs_fixes.returncode == 0
108
- assert first_line(needs_fixes) == "REVIEW_NEEDS_FIXES"
109
-
110
- report.write_text("## Final Result\n- Verdict: BLOCKED\n", encoding="utf-8")
111
- retired = run_helper("text", "final-verdict", str(report))
112
- assert retired.returncode != 0
113
- assert first_line(retired) == "REVIEW_INVALID"
114
-
115
- report.write_text("## Final Result\n- Verdict: UNKNOWN\n", encoding="utf-8")
116
- invalid = run_helper("text", "final-verdict", str(report))
117
- assert invalid.returncode != 0
118
- assert first_line(invalid) == "REVIEW_INVALID"
119
-
120
-
121
- class TestPlatformExecutableAndPortHelpers:
122
- def test_platform_detection_and_skill_lookup_follow_config(self, tmp_path, monkeypatch):
123
- project = tmp_path / "project"
124
- skill_dir = project / ".agents" / "skills" / "playwright-cli"
125
- skill_dir.mkdir(parents=True)
126
- (project / ".prizmkit").mkdir()
127
- (project / ".prizmkit" / "config.json").write_text(
128
- json.dumps({"platform": "codex", "ai_cli": "codex"}), encoding="utf-8"
129
- )
130
- monkeypatch.delenv("PRIZMKIT_PLATFORM", raising=False)
131
-
132
- detect = run_helper("platform", "detect", "--project-root", str(project), "--json")
133
- payload = json.loads(detect.stdout)
134
- assert payload["marker"] == "CODEX"
135
- assert payload["platform"] == "codex"
136
- assert payload["source"] == "config:ai_cli"
137
-
138
- skill = run_helper("platform", "skill", "playwright-cli", "--project-root", str(project), "--json")
139
- payload = json.loads(skill.stdout)
140
- assert payload["marker"] == "SKILL_EXISTS"
141
- assert payload["platform"] == "codex"
142
- assert payload["path"].endswith(".agents/skills/playwright-cli")
143
-
144
- def test_read_platform_conventions_uses_resolved_main_memory_file(self, tmp_path, monkeypatch):
145
- from scripts.utils import read_platform_conventions
146
-
147
- project = tmp_path / "project"
148
- (project / ".prizmkit").mkdir(parents=True)
149
- (project / ".prizmkit" / "config.json").write_text(
150
- json.dumps({"platform": "codex", "ai_cli": "codex"}), encoding="utf-8"
151
- )
152
- (project / "AGENTS.md").write_text("### Project Conventions\n", encoding="utf-8")
153
- (project / "AGENTS.private.md").write_text("framework protocol\n", encoding="utf-8")
154
- monkeypatch.delenv("PRIZMKIT_PLATFORM", raising=False)
155
-
156
- assert read_platform_conventions(project) == "`AGENTS.md`"
157
-
158
- (project / ".prizmkit" / "config.json").write_text(
159
- json.dumps({"platform": "codebuddy", "ai_cli": "cbc"}), encoding="utf-8"
160
- )
161
- (project / "CODEBUDDY.md").write_text("### Infrastructure\n", encoding="utf-8")
162
- (project / "CODEBUDDY.private.md").write_text("framework protocol\n", encoding="utf-8")
163
-
164
- assert read_platform_conventions(project) == "`CODEBUDDY.md`"
165
- assert ".private.md" not in read_platform_conventions(project)
166
-
167
- def test_codebuddy_cli_env_wins_over_filesystem_markers(self, tmp_path, monkeypatch):
168
- from prizmkit_runtime.platform_detection import resolve_platform
169
-
170
- project = tmp_path / "project"
171
- (project / ".claude" / "agents").mkdir(parents=True)
172
- monkeypatch.delenv("PRIZMKIT_PLATFORM", raising=False)
173
- resolution = resolve_platform(project, env={"CODEBUDDY_CLI": "cbc"})
174
-
175
- assert resolution.platform == "codebuddy"
176
- assert resolution.source == "environment:CODEBUDDY_CLI"
177
-
178
- def test_manifest_platform_list_selects_a_concrete_prompt_host(self, tmp_path, monkeypatch):
179
- from prizmkit_runtime.platform_detection import resolve_platform
180
-
181
- project = tmp_path / "project"
182
- (project / ".prizmkit").mkdir(parents=True)
183
- (project / ".prizmkit" / "manifest.json").write_text(
184
- json.dumps({"platform": "claude,cursor"}), encoding="utf-8"
185
- )
186
- monkeypatch.delenv("PRIZMKIT_PLATFORM", raising=False)
187
- resolution = resolve_platform(project, env={"PATH": ""})
188
- assert resolution.platform == "claude"
189
- assert resolution.source == "manifest:platform"
190
-
191
- def test_manifest_both_platform_does_not_fall_through_to_filesystem(self, tmp_path, monkeypatch):
192
- from prizmkit_runtime.platform_detection import resolve_platform
193
-
194
- project = tmp_path / "project"
195
- (project / ".prizmkit").mkdir(parents=True)
196
- (project / ".prizmkit" / "manifest.json").write_text(
197
- json.dumps({"platform": "both"}), encoding="utf-8"
198
- )
199
- (project / ".claude" / "commands").mkdir(parents=True)
200
- monkeypatch.delenv("PRIZMKIT_PLATFORM", raising=False)
201
- resolution = resolve_platform(project, env={"PATH": ""})
202
- assert resolution.platform == ""
203
- assert resolution.source == "unresolved:manifest:platform"
204
-
205
- def test_executable_check_and_version_use_shutil_and_direct_subprocess(self, tmp_path):
206
- executable = tmp_path / "tool.py"
207
- executable.write_text("#!/usr/bin/env python3\nprint('tool 1.2.3')\n", encoding="utf-8")
208
- executable.chmod(0o755)
209
- env_path = f"{tmp_path}{os.pathsep}{os.environ.get('PATH', '')}"
210
-
211
- result = subprocess.run(
212
- [sys.executable, str(HELPER_SCRIPT), "executable", "check", "tool.py"],
213
- env={**os.environ, "PATH": env_path},
214
- text=True,
215
- stdout=subprocess.PIPE,
216
- stderr=subprocess.PIPE,
217
- check=False,
218
- )
219
- assert first_line(result) == "INSTALLED"
220
-
221
- version = subprocess.run(
222
- [sys.executable, str(HELPER_SCRIPT), "executable", "version", "tool.py", "--arg=--version"],
223
- env={**os.environ, "PATH": env_path},
224
- text=True,
225
- stdout=subprocess.PIPE,
226
- stderr=subprocess.PIPE,
227
- check=False,
228
- )
229
- assert first_line(version) == "VERSION"
230
- assert "version: tool 1.2.3" in version.stdout
231
-
232
- def test_port_check_reports_free_and_in_use(self):
233
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
234
- sock.bind(("127.0.0.1", 0))
235
- sock.listen(1)
236
- port = sock.getsockname()[1]
237
- try:
238
- in_use = run_helper("port", "check", str(port))
239
- assert first_line(in_use) == "PORT_IN_USE"
240
- finally:
241
- sock.close()
242
- free = run_helper("port", "check", str(port))
243
- assert first_line(free) == "PORT_FREE"
244
-
245
-
246
- class TestProcessAndEntrypointHelpers:
247
- def test_process_start_status_and_cleanup(self, tmp_path):
248
- sleeper = tmp_path / "sleep.py"
249
- sleeper.write_text("import time\ntime.sleep(30)\n", encoding="utf-8")
250
- pid_file = tmp_path / "server.pid"
251
-
252
- start = run_helper(
253
- "process",
254
- "start",
255
- "--pid-file",
256
- str(pid_file),
257
- "--",
258
- sys.executable,
259
- str(sleeper),
260
- )
261
- assert first_line(start) == "PROCESS_STARTED"
262
- pid = int(pid_file.read_text(encoding="utf-8").strip())
263
-
264
- status = run_helper("process", "status-pid", str(pid))
265
- assert first_line(status) == "PROCESS_RUNNING"
266
-
267
- cleanup = run_helper("process", "cleanup-pid", str(pid), "--grace-seconds", "0.2")
268
- assert first_line(cleanup) in {"PROCESS_TERMINATED", "PROCESS_NOT_RUNNING"}
269
-
270
- def test_cleanup_port_is_deterministic_without_lsof(self):
271
- result = run_helper("process", "cleanup-port", "9")
272
- assert first_line(result) in {"PORT_FREE", "UNSUPPORTED"}
273
- assert "lsof" not in result.stdout.lower()
274
-
275
- def test_canonical_cli_exposes_helper_group(self, tmp_path):
276
- existing = tmp_path / "exists.txt"
277
- existing.write_text("ok", encoding="utf-8")
278
- result = subprocess.run(
279
- [sys.executable, str(CLI_PATH), "helper", "artifact", "exists", str(existing)],
280
- cwd=REPO_ROOT,
281
- text=True,
282
- stdout=subprocess.PIPE,
283
- stderr=subprocess.PIPE,
284
- check=False,
285
- )
286
- assert result.returncode == 0
287
- assert first_line(result) == "EXISTS"
288
-
289
- def test_web_wait_ready_accepts_local_http_server(self, tmp_path):
290
- server = tmp_path / "server.py"
291
- server.write_text(
292
- "from http.server import HTTPServer, BaseHTTPRequestHandler\n"
293
- "class H(BaseHTTPRequestHandler):\n"
294
- " def do_GET(self):\n"
295
- " self.send_response(200); self.end_headers(); self.wfile.write(b'ok')\n"
296
- " def log_message(self, *args): pass\n"
297
- "HTTPServer(('127.0.0.1', 0), H).serve_forever()\n",
298
- encoding="utf-8",
299
- )
300
- # Use helper process start for coverage, then skip fixed URL because the
301
- # child selects an ephemeral port that is not externally reported.
302
- result = run_helper("web", "wait-ready", "--url", "http://127.0.0.1:9", "--timeout", "0.1", "--interval", "0.05")
303
- assert first_line(result) == "NOT_READY"