prizmkit 1.1.192 → 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 (56) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/dev-pipeline/README.md +23 -34
  3. package/bundled/dev-pipeline/assets/feature-list-example.json +0 -1
  4. package/bundled/dev-pipeline/assets/skill-subagent-integration.md +3 -0
  5. package/bundled/dev-pipeline/prizmkit_runtime/config.py +24 -2
  6. package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +2 -0
  7. package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +89 -40
  8. package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +9 -1
  9. package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +0 -22
  10. package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +11 -7
  11. package/bundled/dev-pipeline/prizmkit_runtime/processes.py +26 -20
  12. package/bundled/dev-pipeline/prizmkit_runtime/reset.py +37 -4
  13. package/bundled/dev-pipeline/prizmkit_runtime/reset_preserve.py +20 -41
  14. package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +74 -36
  15. package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +0 -66
  16. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +271 -52
  17. package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +51 -13
  18. package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +43 -15
  19. package/bundled/dev-pipeline/prizmkit_runtime/stream_progress.py +27 -24
  20. package/bundled/dev-pipeline/prizmkit_runtime/task_checkout.py +0 -1
  21. package/bundled/dev-pipeline/scripts/check-session-status.py +13 -1
  22. package/bundled/dev-pipeline/scripts/continuation.py +2 -3
  23. package/bundled/dev-pipeline/scripts/detect-stuck.py +19 -5
  24. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +6 -14
  25. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +13 -8
  26. package/bundled/dev-pipeline/scripts/init-change-artifact.py +17 -2
  27. package/bundled/dev-pipeline/scripts/prompt_framework.py +39 -21
  28. package/bundled/dev-pipeline/scripts/update-checkpoint.py +27 -0
  29. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +1 -1
  30. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +6 -6
  31. package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +1 -1
  32. package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +1 -1
  33. package/bundled/skills/_metadata.json +1 -1
  34. package/package.json +1 -1
  35. package/bundled/dev-pipeline/tests/_helpers.py +0 -418
  36. package/bundled/dev-pipeline/tests/conftest.py +0 -73
  37. package/bundled/dev-pipeline/tests/live_ai_cli_log_smoke.py +0 -208
  38. package/bundled/dev-pipeline/tests/test_auto_skip.py +0 -1806
  39. package/bundled/dev-pipeline/tests/test_checkpoint_state.py +0 -1439
  40. package/bundled/dev-pipeline/tests/test_daemon_and_scripts.py +0 -257
  41. package/bundled/dev-pipeline/tests/test_e2e_pipeline_run.py +0 -500
  42. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +0 -1654
  43. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +0 -629
  44. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +0 -2973
  45. package/bundled/dev-pipeline/tests/test_recovery_workflow.py +0 -321
  46. package/bundled/dev-pipeline/tests/test_repository_bootstrap.py +0 -251
  47. package/bundled/dev-pipeline/tests/test_reset_modes.py +0 -1196
  48. package/bundled/dev-pipeline/tests/test_reset_preserve.py +0 -872
  49. package/bundled/dev-pipeline/tests/test_runner_bookkeeping.py +0 -766
  50. package/bundled/dev-pipeline/tests/test_runner_lifecycle.py +0 -1257
  51. package/bundled/dev-pipeline/tests/test_runtime_commit.py +0 -1113
  52. package/bundled/dev-pipeline/tests/test_runtime_helper.py +0 -380
  53. package/bundled/dev-pipeline/tests/test_session_launch.py +0 -1101
  54. package/bundled/dev-pipeline/tests/test_stream_progress.py +0 -585
  55. package/bundled/dev-pipeline/tests/test_unified_cli.py +0 -3625
  56. package/bundled/dev-pipeline/tests/test_utils.py +0 -170
@@ -1,380 +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_default_excludes_skip_framework_and_cache_directories(self, tmp_path):
62
- for rel in (
63
- ".prizmkit/internal.py",
64
- ".claude/cmd.py",
65
- ".agents/skill.py",
66
- ".venv/lib.py",
67
- ".next/chunk.py",
68
- "target/gen.py",
69
- "coverage/cov.py",
70
- "src/real.py",
71
- ):
72
- target = tmp_path / rel
73
- target.parent.mkdir(parents=True, exist_ok=True)
74
- target.write_text("needle_token = 1\n", encoding="utf-8")
75
-
76
- sources = run_helper("artifact", "source-files", str(tmp_path), "--ext", ".py", "--json")
77
- assert json.loads(sources.stdout)["files"] == ["src/real.py"]
78
-
79
- search = run_helper("text", "search", str(tmp_path), "--pattern", "needle_token", "--json")
80
- assert json.loads(search.stdout)["match"] == ["src/real.py"]
81
-
82
- def test_text_search_count_and_contains_markers(self, tmp_path):
83
- target = tmp_path / "notes.md"
84
- target.write_text("alpha\nbeta alpha\n", encoding="utf-8")
85
-
86
- search = run_helper("text", "search", str(tmp_path), "--pattern", "alpha")
87
- assert first_line(search) == "FOUND"
88
- assert "count: 2" in search.stdout
89
-
90
- count = run_helper("text", "count", str(tmp_path), "--pattern", "alpha")
91
- assert first_line(count) == "COUNT"
92
- assert "count: 2" in count.stdout
93
-
94
- contains = run_helper("text", "contains", str(target), "--pattern", "beta")
95
- assert first_line(contains) == "GATE:PASS"
96
- missing = run_helper("text", "contains", str(target), "--pattern", "gamma")
97
- assert first_line(missing) == "GATE:MISSING"
98
-
99
- def test_final_verdict_requires_last_final_result_section(self, tmp_path):
100
- report = tmp_path / "review-report.md"
101
- report.write_text(
102
- "# Review Report\n\n## Status: IN_PROGRESS\n\n"
103
- "## Main Review Round 1\n\n- Note: incidental PASS text\n",
104
- encoding="utf-8",
105
- )
106
- incomplete = run_helper("text", "final-verdict", str(report))
107
- assert incomplete.returncode != 0
108
- assert first_line(incomplete) == "REVIEW_INCOMPLETE"
109
-
110
- report.write_text(
111
- report.read_text(encoding="utf-8")
112
- + "\n## Final Result\n\n- Verdict: PASS\n- Summary: done\n",
113
- encoding="utf-8",
114
- )
115
- complete = run_helper("text", "final-verdict", str(report))
116
- assert complete.returncode == 0
117
- assert first_line(complete) == "REVIEW_PASS"
118
- assert "verdict: PASS" in complete.stdout
119
-
120
- def test_final_verdict_uses_last_final_result_and_rejects_unknown_value(self, tmp_path):
121
- report = tmp_path / "review-report.md"
122
- report.write_text(
123
- "## Final Result\n- Verdict: PASS\n\n"
124
- "## Final Result\n- Verdict: NEEDS_FIXES\n",
125
- encoding="utf-8",
126
- )
127
- needs_fixes = run_helper("text", "final-verdict", str(report))
128
- assert needs_fixes.returncode == 0
129
- assert first_line(needs_fixes) == "REVIEW_NEEDS_FIXES"
130
-
131
- report.write_text("## Final Result\n- Verdict: BLOCKED\n", encoding="utf-8")
132
- retired = run_helper("text", "final-verdict", str(report))
133
- assert retired.returncode != 0
134
- assert first_line(retired) == "REVIEW_INVALID"
135
-
136
- report.write_text("## Final Result\n- Verdict: UNKNOWN\n", encoding="utf-8")
137
- invalid = run_helper("text", "final-verdict", str(report))
138
- assert invalid.returncode != 0
139
- assert first_line(invalid) == "REVIEW_INVALID"
140
-
141
- def test_final_verdict_rejects_pass_when_verification_failed_or_findings_unfixed(self, tmp_path):
142
- report = tmp_path / "review-report.md"
143
- report.write_text(
144
- "## Final Verification\n- Status: FAILED\n\n## Final Result\n- Verdict: PASS\n",
145
- encoding="utf-8",
146
- )
147
- failed_verif = run_helper("text", "final-verdict", str(report))
148
- assert failed_verif.returncode != 0
149
- assert first_line(failed_verif) == "REVIEW_INVALID"
150
-
151
- report.write_text(
152
- "## Final Result\n- Verdict: PASS\n- Accepted Findings: 2\n- Fixed Findings: 1\n- Unresolved Findings: 0\n",
153
- encoding="utf-8",
154
- )
155
- unfixed = run_helper("text", "final-verdict", str(report))
156
- assert unfixed.returncode != 0
157
- assert first_line(unfixed) == "REVIEW_INVALID"
158
-
159
- report.write_text(
160
- "## Final Verification\n- Status: COMPLETED\n\n"
161
- "## Final Result\n- Verdict: PASS\n- Accepted Findings: 1\n- Fixed Findings: 1\n- Unresolved Findings: 0\n",
162
- encoding="utf-8",
163
- )
164
- valid = run_helper("text", "final-verdict", str(report))
165
- assert valid.returncode == 0
166
- assert first_line(valid) == "REVIEW_PASS"
167
-
168
-
169
- class TestPlatformExecutableAndPortHelpers:
170
- def test_platform_detection_and_skill_lookup_follow_config(self, tmp_path, monkeypatch):
171
- project = tmp_path / "project"
172
- skill_dir = project / ".agents" / "skills" / "playwright-cli"
173
- skill_dir.mkdir(parents=True)
174
- (project / ".prizmkit").mkdir()
175
- (project / ".prizmkit" / "config.json").write_text(
176
- json.dumps({"platform": "codex", "ai_cli": "codex"}), encoding="utf-8"
177
- )
178
- monkeypatch.delenv("PRIZMKIT_PLATFORM", raising=False)
179
-
180
- detect = run_helper("platform", "detect", "--project-root", str(project), "--json")
181
- payload = json.loads(detect.stdout)
182
- assert payload["marker"] == "CODEX"
183
- assert payload["platform"] == "codex"
184
- assert payload["source"] == "config:ai_cli"
185
-
186
- skill = run_helper("platform", "skill", "playwright-cli", "--project-root", str(project), "--json")
187
- payload = json.loads(skill.stdout)
188
- assert payload["marker"] == "SKILL_EXISTS"
189
- assert payload["platform"] == "codex"
190
- assert payload["path"].endswith(".agents/skills/playwright-cli")
191
-
192
- def test_read_platform_conventions_uses_resolved_main_memory_file(self, tmp_path, monkeypatch):
193
- from scripts.utils import read_platform_conventions
194
-
195
- project = tmp_path / "project"
196
- (project / ".prizmkit").mkdir(parents=True)
197
- (project / ".prizmkit" / "config.json").write_text(
198
- json.dumps({"platform": "codex", "ai_cli": "codex"}), encoding="utf-8"
199
- )
200
- (project / "AGENTS.md").write_text("### Project Conventions\n", encoding="utf-8")
201
- (project / "AGENTS.private.md").write_text("framework protocol\n", encoding="utf-8")
202
- monkeypatch.delenv("PRIZMKIT_PLATFORM", raising=False)
203
-
204
- assert read_platform_conventions(project) == "`AGENTS.md`"
205
-
206
- (project / ".prizmkit" / "config.json").write_text(
207
- json.dumps({"platform": "codebuddy", "ai_cli": "cbc"}), encoding="utf-8"
208
- )
209
- (project / "CODEBUDDY.md").write_text("### Infrastructure\n", encoding="utf-8")
210
- (project / "CODEBUDDY.private.md").write_text("framework protocol\n", encoding="utf-8")
211
-
212
- assert read_platform_conventions(project) == "`CODEBUDDY.md`"
213
- assert ".private.md" not in read_platform_conventions(project)
214
-
215
- def test_codebuddy_cli_env_wins_over_filesystem_markers(self, tmp_path, monkeypatch):
216
- from prizmkit_runtime.platform_detection import resolve_platform
217
-
218
- project = tmp_path / "project"
219
- (project / ".claude" / "agents").mkdir(parents=True)
220
- monkeypatch.delenv("PRIZMKIT_PLATFORM", raising=False)
221
- resolution = resolve_platform(project, env={"CODEBUDDY_CLI": "cbc"})
222
-
223
- assert resolution.platform == "codebuddy"
224
- assert resolution.source == "environment:CODEBUDDY_CLI"
225
-
226
- def test_manifest_platform_list_selects_a_concrete_prompt_host(self, tmp_path, monkeypatch):
227
- from prizmkit_runtime.platform_detection import resolve_platform
228
-
229
- project = tmp_path / "project"
230
- (project / ".prizmkit").mkdir(parents=True)
231
- (project / ".prizmkit" / "manifest.json").write_text(
232
- json.dumps({"platform": "claude,cursor"}), encoding="utf-8"
233
- )
234
- monkeypatch.delenv("PRIZMKIT_PLATFORM", raising=False)
235
- resolution = resolve_platform(project, env={"PATH": ""})
236
- assert resolution.platform == "claude"
237
- assert resolution.source == "manifest:platform"
238
-
239
- def test_manifest_both_platform_does_not_fall_through_to_filesystem(self, tmp_path, monkeypatch):
240
- from prizmkit_runtime.platform_detection import resolve_platform
241
-
242
- project = tmp_path / "project"
243
- (project / ".prizmkit").mkdir(parents=True)
244
- (project / ".prizmkit" / "manifest.json").write_text(
245
- json.dumps({"platform": "both"}), encoding="utf-8"
246
- )
247
- (project / ".claude" / "commands").mkdir(parents=True)
248
- monkeypatch.delenv("PRIZMKIT_PLATFORM", raising=False)
249
- resolution = resolve_platform(project, env={"PATH": ""})
250
- assert resolution.platform == ""
251
- assert resolution.source == "unresolved:manifest:platform"
252
-
253
- def test_executable_check_and_version_use_shutil_and_direct_subprocess(self, tmp_path):
254
- executable = tmp_path / "tool.py"
255
- executable.write_text("#!/usr/bin/env python3\nprint('tool 1.2.3')\n", encoding="utf-8")
256
- executable.chmod(0o755)
257
- env_path = f"{tmp_path}{os.pathsep}{os.environ.get('PATH', '')}"
258
-
259
- result = subprocess.run(
260
- [sys.executable, str(HELPER_SCRIPT), "executable", "check", "tool.py"],
261
- env={**os.environ, "PATH": env_path},
262
- text=True,
263
- stdout=subprocess.PIPE,
264
- stderr=subprocess.PIPE,
265
- check=False,
266
- )
267
- assert first_line(result) == "INSTALLED"
268
-
269
- version = subprocess.run(
270
- [sys.executable, str(HELPER_SCRIPT), "executable", "version", "tool.py", "--arg=--version"],
271
- env={**os.environ, "PATH": env_path},
272
- text=True,
273
- stdout=subprocess.PIPE,
274
- stderr=subprocess.PIPE,
275
- check=False,
276
- )
277
- assert first_line(version) == "VERSION"
278
- assert "version: tool 1.2.3" in version.stdout
279
-
280
- def test_port_check_reports_free_and_in_use(self):
281
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
282
- sock.bind(("127.0.0.1", 0))
283
- sock.listen(1)
284
- port = sock.getsockname()[1]
285
- try:
286
- in_use = run_helper("port", "check", str(port))
287
- assert first_line(in_use) == "PORT_IN_USE"
288
- finally:
289
- sock.close()
290
- free = run_helper("port", "check", str(port))
291
- assert first_line(free) == "PORT_FREE"
292
-
293
-
294
- class TestProcessAndEntrypointHelpers:
295
- def test_process_start_status_and_cleanup(self, tmp_path):
296
- sleeper = tmp_path / "sleep.py"
297
- sleeper.write_text("import time\ntime.sleep(30)\n", encoding="utf-8")
298
- pid_file = tmp_path / "server.pid"
299
-
300
- start = run_helper(
301
- "process",
302
- "start",
303
- "--pid-file",
304
- str(pid_file),
305
- "--",
306
- sys.executable,
307
- str(sleeper),
308
- )
309
- assert first_line(start) == "PROCESS_STARTED"
310
- pid = int(pid_file.read_text(encoding="utf-8").strip())
311
- try:
312
- status = run_helper("process", "status-pid", str(pid))
313
- assert first_line(status) == "PROCESS_RUNNING"
314
- finally:
315
- cleanup = run_helper("process", "cleanup-pid", str(pid), "--grace-seconds", "0.2")
316
- assert first_line(cleanup) in {"PROCESS_TERMINATED", "PROCESS_NOT_RUNNING"}
317
-
318
- def test_cleanup_port_is_deterministic_without_lsof(self):
319
- result = run_helper("process", "cleanup-port", "9")
320
- assert first_line(result) in {"PORT_FREE", "UNSUPPORTED"}
321
- assert "lsof" not in result.stdout.lower()
322
-
323
- def test_canonical_cli_exposes_helper_group(self, tmp_path):
324
- existing = tmp_path / "exists.txt"
325
- existing.write_text("ok", encoding="utf-8")
326
- result = subprocess.run(
327
- [sys.executable, str(CLI_PATH), "helper", "artifact", "exists", str(existing)],
328
- cwd=REPO_ROOT,
329
- text=True,
330
- stdout=subprocess.PIPE,
331
- stderr=subprocess.PIPE,
332
- check=False,
333
- )
334
- assert result.returncode == 0
335
- assert first_line(result) == "EXISTS"
336
-
337
- def test_web_wait_ready_accepts_local_http_server(self):
338
- import threading
339
- from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
340
-
341
- class Handler(BaseHTTPRequestHandler):
342
- def do_GET(self):
343
- self.send_response(200)
344
- self.end_headers()
345
- self.wfile.write(b"ok")
346
-
347
- def log_message(self, *args):
348
- pass
349
-
350
- server = ThreadingHTTPServer(("127.0.0.1", 0), Handler)
351
- port = server.server_address[1]
352
- thread = threading.Thread(target=server.serve_forever, daemon=True)
353
- thread.start()
354
- try:
355
- ready = run_helper(
356
- "web",
357
- "wait-ready",
358
- "--url",
359
- f"http://127.0.0.1:{port}",
360
- "--timeout",
361
- "2",
362
- "--interval",
363
- "0.05",
364
- )
365
- assert first_line(ready) == "READY"
366
- finally:
367
- server.shutdown()
368
- server.server_close()
369
-
370
- not_ready = run_helper(
371
- "web",
372
- "wait-ready",
373
- "--url",
374
- "http://127.0.0.1:9",
375
- "--timeout",
376
- "0.1",
377
- "--interval",
378
- "0.05",
379
- )
380
- assert first_line(not_ready) == "NOT_READY"