prizmkit 1.1.161 → 1.1.164
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.
- package/bin/create-prizmkit.js +4 -4
- package/bundled/VERSION.json +3 -3
- package/bundled/adapters/cursor/assets/prizmkit-hook.cjs +65 -0
- package/bundled/adapters/cursor/hooks-adapter.js +139 -0
- package/bundled/adapters/cursor/paths.js +11 -0
- package/bundled/adapters/cursor/rules-adapter.js +49 -0
- package/bundled/adapters/cursor/skill-adapter.js +27 -0
- package/bundled/dev-pipeline/README.md +21 -6
- package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +3 -25
- package/bundled/dev-pipeline/prizmkit_runtime/config.py +71 -14
- package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +28 -4
- package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +5 -2
- package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +21 -3
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +82 -9
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +123 -0
- package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +123 -28
- package/bundled/dev-pipeline/prizmkit_runtime/status.py +2 -0
- package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +1 -42
- package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +43 -6
- package/bundled/dev-pipeline/scripts/init-pipeline.py +46 -8
- package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +41 -6
- package/bundled/dev-pipeline/scripts/parse-stream-progress.py +143 -27
- package/bundled/dev-pipeline/scripts/update-bug-status.py +8 -4
- package/bundled/dev-pipeline/scripts/update-feature-status.py +12 -8
- package/bundled/dev-pipeline/scripts/update-refactor-status.py +8 -4
- package/bundled/dev-pipeline/scripts/utils.py +3 -12
- package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +4 -2
- package/bundled/dev-pipeline/templates/feature-list-schema.json +4 -2
- package/bundled/dev-pipeline/templates/refactor-list-schema.json +4 -2
- package/bundled/dev-pipeline/tests/live_ai_cli_log_smoke.py +2 -1
- package/bundled/dev-pipeline/tests/test_checkpoint_state.py +5 -23
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +2 -2
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +452 -6
- package/bundled/dev-pipeline/tests/test_runtime_commit.py +138 -1
- package/bundled/dev-pipeline/tests/test_unified_cli.py +406 -30
- package/bundled/dev-pipeline/tests/test_utils.py +23 -0
- package/bundled/rules/USAGE.md +3 -0
- package/bundled/skills/_metadata.json +1 -1
- package/bundled/skills/bug-planner/SKILL.md +0 -1
- package/bundled/skills/bug-planner/references/verification.md +0 -2
- package/bundled/skills/bug-planner/scripts/validate-bug-list.py +37 -7
- package/bundled/skills/feature-planner/SKILL.md +5 -8
- package/bundled/skills/feature-planner/scripts/validate-and-generate.py +43 -19
- package/bundled/skills/prizmkit-init/SKILL.md +1 -1
- package/bundled/skills/prizmkit-init/references/config-schema.md +2 -2
- package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +2 -3
- package/bundled/skills/prizmkit-prizm-docs/assets/prizm-docs-format.md +1 -1
- package/bundled/skills/prizmkit-prizm-docs/references/op-init.md +1 -1
- package/bundled/skills/refactor-planner/SKILL.md +1 -3
- package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +38 -9
- package/package.json +4 -2
- package/src/ai-cli-launch.js +9 -2
- package/src/clean.js +42 -6
- package/src/config.js +51 -10
- package/src/detect-platform.js +30 -8
- package/src/external-skills.js +33 -99
- package/src/index.js +5 -0
- package/src/manifest.js +30 -4
- package/src/platforms.js +11 -4
- package/src/prompts.js +12 -4
- package/src/scaffold.js +75 -4
- package/src/upgrade.js +15 -14
|
@@ -984,7 +984,85 @@ def test_runtime_config_resolves_pi_from_config_and_installed_marker(tmp_path):
|
|
|
984
984
|
assert unresolved.command is None
|
|
985
985
|
|
|
986
986
|
|
|
987
|
-
def
|
|
987
|
+
def test_runtime_config_resolves_and_validates_cursor_agent(tmp_path, monkeypatch):
|
|
988
|
+
import prizmkit_runtime.config as runtime_config
|
|
989
|
+
from prizmkit_runtime.config import resolve_ai_client, validate_effort
|
|
990
|
+
from prizmkit_runtime.paths import resolve_runtime_paths
|
|
991
|
+
from prizmkit_runtime.platform_detection import platform_from_command
|
|
992
|
+
|
|
993
|
+
assert platform_from_command(r"C:\Tools\agent.exe") == "cursor"
|
|
994
|
+
assert platform_from_command(r"C:\Program Files\Cursor\agent.cmd") == "cursor"
|
|
995
|
+
|
|
996
|
+
project = tmp_path / "project"
|
|
997
|
+
pipeline = project / ".prizmkit" / "dev-pipeline"
|
|
998
|
+
pipeline.mkdir(parents=True)
|
|
999
|
+
paths = resolve_runtime_paths(pipeline_root=pipeline)
|
|
1000
|
+
|
|
1001
|
+
(project / ".prizmkit" / "config.json").write_text('{"ai_cli":"agent"}', encoding="utf-8")
|
|
1002
|
+
configured = resolve_ai_client(paths, env={"PATH": ""})
|
|
1003
|
+
assert configured.command == "agent"
|
|
1004
|
+
assert configured.platform == "cursor"
|
|
1005
|
+
assert configured.launch_profile is None
|
|
1006
|
+
effort = validate_effort("high", "cursor")
|
|
1007
|
+
assert effort.valid is False
|
|
1008
|
+
assert effort.supported_values == ()
|
|
1009
|
+
assert "no documented effort parameter" in effort.message
|
|
1010
|
+
|
|
1011
|
+
(project / ".prizmkit" / "config.json").unlink()
|
|
1012
|
+
(project / ".prizmkit" / "manifest.json").write_text('{"platform":"cursor"}', encoding="utf-8")
|
|
1013
|
+
monkeypatch.setattr(runtime_config.shutil, "which", lambda name, path=None: "/tools/agent" if name == "agent" else None)
|
|
1014
|
+
monkeypatch.setattr(
|
|
1015
|
+
runtime_config.subprocess,
|
|
1016
|
+
"run",
|
|
1017
|
+
lambda *args, **kwargs: subprocess.CompletedProcess(
|
|
1018
|
+
args[0], 0, "Cursor Agent\n--print --force --trust --output-format", ""
|
|
1019
|
+
),
|
|
1020
|
+
)
|
|
1021
|
+
detected = resolve_ai_client(paths, env={"PATH": "/tools"})
|
|
1022
|
+
assert detected.command == "agent"
|
|
1023
|
+
assert detected.platform == "cursor"
|
|
1024
|
+
assert detected.source == "prizmkit-manifest:platform"
|
|
1025
|
+
|
|
1026
|
+
monkeypatch.setattr(
|
|
1027
|
+
runtime_config.subprocess,
|
|
1028
|
+
"run",
|
|
1029
|
+
lambda *args, **kwargs: subprocess.CompletedProcess(
|
|
1030
|
+
args[0], 1, "Cursor Agent --print --force --trust --output-format", "",
|
|
1031
|
+
),
|
|
1032
|
+
)
|
|
1033
|
+
rejected_nonzero = resolve_ai_client(paths, env={"PATH": "/tools"})
|
|
1034
|
+
assert rejected_nonzero.command is None
|
|
1035
|
+
|
|
1036
|
+
monkeypatch.setattr(
|
|
1037
|
+
runtime_config.subprocess,
|
|
1038
|
+
"run",
|
|
1039
|
+
lambda *args, **kwargs: subprocess.CompletedProcess(args[0], 0, "unrelated agent", ""),
|
|
1040
|
+
)
|
|
1041
|
+
rejected = resolve_ai_client(paths, env={"PATH": "/tools"})
|
|
1042
|
+
assert rejected.command is None
|
|
1043
|
+
assert rejected.platform == "cursor"
|
|
1044
|
+
assert rejected.source == "unresolved:prizmkit-manifest:platform"
|
|
1045
|
+
|
|
1046
|
+
# Adding Cursor markers must not displace the established installed-host
|
|
1047
|
+
# precedence when legacy metadata is absent.
|
|
1048
|
+
(project / ".prizmkit" / "manifest.json").unlink()
|
|
1049
|
+
(project / ".claude" / "commands").mkdir(parents=True)
|
|
1050
|
+
(project / ".claude" / "commands" / "prizmkit.md").write_text("fixture\n", encoding="utf-8")
|
|
1051
|
+
(project / ".cursor" / "skills" / "prizmkit").mkdir(parents=True)
|
|
1052
|
+
(project / ".cursor" / "skills" / "prizmkit" / "SKILL.md").write_text("fixture\n", encoding="utf-8")
|
|
1053
|
+
monkeypatch.setattr(
|
|
1054
|
+
runtime_config.shutil,
|
|
1055
|
+
"which",
|
|
1056
|
+
lambda name, path=None: f"/tools/{name}" if name in {"claude", "agent"} else None,
|
|
1057
|
+
)
|
|
1058
|
+
preserved = resolve_ai_client(paths, env={"PATH": "/tools"})
|
|
1059
|
+
assert preserved.command == "claude"
|
|
1060
|
+
assert preserved.platform == "claude"
|
|
1061
|
+
assert preserved.source == "installed-platform:claude"
|
|
1062
|
+
|
|
1063
|
+
|
|
1064
|
+
def test_stream_json_support_detection_matches_provider_rules(monkeypatch):
|
|
1065
|
+
import prizmkit_runtime.sessions as sessions
|
|
988
1066
|
from prizmkit_runtime.sessions import detect_stream_json_support
|
|
989
1067
|
|
|
990
1068
|
def help_runner(command):
|
|
@@ -994,18 +1072,33 @@ def test_stream_json_support_detection_matches_provider_rules():
|
|
|
994
1072
|
return "--output-format stream-json"
|
|
995
1073
|
if tuple(command) == ("pi", "--help"):
|
|
996
1074
|
return "--mode --approve --no-session --tools --model --thinking"
|
|
1075
|
+
if tuple(command) == ("agent", "--version"):
|
|
1076
|
+
return "Cursor Agent 2026.1"
|
|
1077
|
+
if tuple(command) == ("agent", "--help"):
|
|
1078
|
+
return "Cursor Agent --print --force --trust --output-format stream-json"
|
|
997
1079
|
return ""
|
|
998
1080
|
|
|
999
1081
|
codebuddy = detect_stream_json_support("cbc", "codebuddy", help_runner)
|
|
1000
1082
|
codex = detect_stream_json_support("codex", "codex", help_runner)
|
|
1001
1083
|
claude = detect_stream_json_support("claude", "claude", help_runner)
|
|
1002
1084
|
pi = detect_stream_json_support("pi", "pi", help_runner)
|
|
1085
|
+
cursor = detect_stream_json_support("agent", "cursor", help_runner)
|
|
1003
1086
|
unsupported = detect_stream_json_support("other", "claude", lambda _cmd: "plain help")
|
|
1004
1087
|
|
|
1005
1088
|
assert codebuddy.enabled and codebuddy.format == "stream-json"
|
|
1006
1089
|
assert codex.enabled and codex.format == "codex-json"
|
|
1007
1090
|
assert claude.enabled and claude.format == "stream-json"
|
|
1008
1091
|
assert pi.enabled and pi.format == "pi-json"
|
|
1092
|
+
assert cursor.enabled and cursor.format == "cursor-stream-json"
|
|
1093
|
+
assert detect_stream_json_support("agent", "cursor", lambda _cmd: "unrelated --output-format").enabled is False
|
|
1094
|
+
monkeypatch.setattr(
|
|
1095
|
+
sessions.subprocess,
|
|
1096
|
+
"run",
|
|
1097
|
+
lambda *args, **kwargs: subprocess.CompletedProcess(
|
|
1098
|
+
args[0], 1, "Cursor Agent --print --force --trust --output-format", "",
|
|
1099
|
+
),
|
|
1100
|
+
)
|
|
1101
|
+
assert detect_stream_json_support("agent", "cursor").enabled is False
|
|
1009
1102
|
assert detect_stream_json_support("pi", "pi", lambda _cmd: "--mode").enabled is False
|
|
1010
1103
|
assert unsupported.enabled is False
|
|
1011
1104
|
|
|
@@ -1089,6 +1182,25 @@ def test_ai_session_command_builders_match_unix_runtime_snapshot(tmp_path):
|
|
|
1089
1182
|
assert "hello" not in pi.argv
|
|
1090
1183
|
assert not ({"--effort", "--sandbox", "--output-format", "--disallowedTools", "-y"} & set(pi.argv))
|
|
1091
1184
|
|
|
1185
|
+
cursor = build_ai_session_command(
|
|
1186
|
+
AISessionConfig(
|
|
1187
|
+
cli_command="agent",
|
|
1188
|
+
platform="cursor",
|
|
1189
|
+
model="cursor-model",
|
|
1190
|
+
prompt_path=prompt,
|
|
1191
|
+
cwd=project,
|
|
1192
|
+
use_stream_json=True,
|
|
1193
|
+
)
|
|
1194
|
+
)
|
|
1195
|
+
assert cursor.argv == (
|
|
1196
|
+
"agent", "--print", "--force", "--trust", "--output-format", "stream-json",
|
|
1197
|
+
"--model", "cursor-model",
|
|
1198
|
+
)
|
|
1199
|
+
assert cursor.stdin_text == "hello"
|
|
1200
|
+
assert cursor.prompt_mode == "stdin"
|
|
1201
|
+
assert "hello" not in cursor.argv
|
|
1202
|
+
assert not ({"--effort", "--sandbox", "--worktree", "--disallowedTools", "-y", "--yolo"} & set(cursor.argv))
|
|
1203
|
+
|
|
1092
1204
|
|
|
1093
1205
|
def test_custom_ai_session_command_builder_injects_prompt_and_tokenizes_extra_args(tmp_path):
|
|
1094
1206
|
from prizmkit_runtime.launch_profiles import HeadlessLaunchProfile
|
|
@@ -1192,6 +1304,21 @@ def test_start_command_serialization_redacts_prompt_and_preserves_provider_flags
|
|
|
1192
1304
|
assert pi.startswith("pi --mode json --approve --no-session")
|
|
1193
1305
|
assert secret_prompt not in pi
|
|
1194
1306
|
|
|
1307
|
+
cursor = format_start_command(
|
|
1308
|
+
build_ai_session_command(
|
|
1309
|
+
AISessionConfig(
|
|
1310
|
+
cli_command="agent",
|
|
1311
|
+
platform="cursor",
|
|
1312
|
+
model=None,
|
|
1313
|
+
prompt_path=prompt,
|
|
1314
|
+
cwd=project,
|
|
1315
|
+
use_stream_json=True,
|
|
1316
|
+
)
|
|
1317
|
+
)
|
|
1318
|
+
)
|
|
1319
|
+
assert cursor == "agent --print --force --trust --output-format stream-json"
|
|
1320
|
+
assert secret_prompt not in cursor
|
|
1321
|
+
|
|
1195
1322
|
custom = format_start_command(
|
|
1196
1323
|
build_ai_session_command(
|
|
1197
1324
|
AISessionConfig(
|
|
@@ -1822,12 +1949,13 @@ def test_progress_parser_normalizes_claude_subagents_without_double_counting(tmp
|
|
|
1822
1949
|
|
|
1823
1950
|
data = tracker.to_dict()
|
|
1824
1951
|
|
|
1825
|
-
|
|
1826
|
-
assert
|
|
1827
|
-
assert
|
|
1828
|
-
assert
|
|
1829
|
-
assert "
|
|
1830
|
-
assert "
|
|
1952
|
+
statistics = data["subagent_statistics"]
|
|
1953
|
+
assert statistics["source"] == "session_log"
|
|
1954
|
+
assert statistics["spawned"] == 1
|
|
1955
|
+
assert statistics["active"] == 0
|
|
1956
|
+
assert statistics["states"] == [{"status": "completed", "count": 1}]
|
|
1957
|
+
assert "task-1" in statistics["observed_ids"]
|
|
1958
|
+
assert "tool-1" in statistics["parent_activity_ids"]
|
|
1831
1959
|
assert all("bash" not in record["id"] for record in data["subagent_statistics"]["records"])
|
|
1832
1960
|
|
|
1833
1961
|
|
|
@@ -1863,11 +1991,12 @@ def test_progress_parser_normalizes_codebuddy_agent_tools_with_deduplication():
|
|
|
1863
1991
|
data = tracker.to_dict()
|
|
1864
1992
|
|
|
1865
1993
|
assert data["cb_session_id"] == "cb-session"
|
|
1866
|
-
|
|
1867
|
-
assert
|
|
1868
|
-
assert
|
|
1869
|
-
assert
|
|
1870
|
-
assert
|
|
1994
|
+
statistics = data["subagent_statistics"]
|
|
1995
|
+
assert statistics["providers"] == ["codebuddy"]
|
|
1996
|
+
assert statistics["spawned"] == 1
|
|
1997
|
+
assert statistics["active"] == 1
|
|
1998
|
+
assert {item["status"] for item in statistics["states"]} == {"running"}
|
|
1999
|
+
assert len(statistics["records"]) == 1
|
|
1871
2000
|
assert data["subagent_statistics"]["records"][0]["metadata"]["tool"] == "Agent"
|
|
1872
2001
|
|
|
1873
2002
|
|
|
@@ -1898,10 +2027,11 @@ def test_progress_parser_normalizes_codex_collab_metadata_with_missing_fields():
|
|
|
1898
2027
|
assert data["stop_reason"] == "completed"
|
|
1899
2028
|
assert data["is_active"] is False
|
|
1900
2029
|
assert data["child_thread_ids"] == ["thread-a", "thread-b"]
|
|
1901
|
-
|
|
1902
|
-
assert
|
|
1903
|
-
assert
|
|
1904
|
-
assert
|
|
2030
|
+
statistics = data["subagent_statistics"]
|
|
2031
|
+
assert statistics["spawned"] == 2
|
|
2032
|
+
assert statistics["active"] == 1
|
|
2033
|
+
assert {state["status"]: state["count"] for state in statistics["states"]} == {"running": 1, "completed": 1}
|
|
2034
|
+
assert statistics["child_activity_source"] == "filesystem_liveness_only"
|
|
1905
2035
|
|
|
1906
2036
|
|
|
1907
2037
|
def test_progress_parser_keeps_child_files_liveness_only(tmp_path, monkeypatch):
|
|
@@ -1929,8 +2059,8 @@ def test_progress_parser_keeps_child_files_liveness_only(tmp_path, monkeypatch):
|
|
|
1929
2059
|
tracker.refresh_child_session_activity(force=True)
|
|
1930
2060
|
second = tracker.to_dict()
|
|
1931
2061
|
|
|
1932
|
-
assert first["
|
|
1933
|
-
assert second["
|
|
2062
|
+
assert first["subagent_statistics"]["spawned"] == 1
|
|
2063
|
+
assert second["subagent_statistics"]["spawned"] == 1
|
|
1934
2064
|
assert second["child_total_bytes"] > first["child_total_bytes"]
|
|
1935
2065
|
assert second["child_session_files"]
|
|
1936
2066
|
assert second["child_activity_source"] == "filesystem_liveness_only"
|
|
@@ -2211,8 +2341,8 @@ def test_custom_session_launch_writes_existing_logs_and_progress(tmp_path):
|
|
|
2211
2341
|
progress_data = json.loads(progress.read_text(encoding="utf-8"))
|
|
2212
2342
|
assert progress_data["event_type_counts"]["result"] == 1
|
|
2213
2343
|
assert progress_data["has_usage"] is True
|
|
2214
|
-
assert progress_data["
|
|
2215
|
-
assert progress_data["
|
|
2344
|
+
assert progress_data["subagent_statistics"]["source"] == "session_log"
|
|
2345
|
+
assert progress_data["subagent_statistics"]["spawned"] == 0
|
|
2216
2346
|
assert progress_data["subagent_statistics"]["providers"] == []
|
|
2217
2347
|
assert progress_data["child_activity_source"] == "filesystem_liveness_only"
|
|
2218
2348
|
|
|
@@ -2312,9 +2442,11 @@ def test_compact_progress_line_hides_stale_until_no_progress(tmp_path):
|
|
|
2312
2442
|
{
|
|
2313
2443
|
"child_total_bytes": 2 * 1024 * 1024,
|
|
2314
2444
|
"child_session_files": [{"path": "a"}, {"path": "b"}],
|
|
2315
|
-
"
|
|
2316
|
-
|
|
2317
|
-
|
|
2445
|
+
"subagent_statistics": {
|
|
2446
|
+
"spawned": 5,
|
|
2447
|
+
"active": 2,
|
|
2448
|
+
"states": [{"status": "running", "count": 2}, {"status": "completed", "count": 3}],
|
|
2449
|
+
},
|
|
2318
2450
|
"current_phase": "stream-derived-phase",
|
|
2319
2451
|
"current_tool": "Read",
|
|
2320
2452
|
"message_count": 465,
|
|
@@ -2694,8 +2826,7 @@ def test_idle_progress_refresh_updates_child_activity_without_parent_output(tmp_
|
|
|
2694
2826
|
"current_tool": "Task",
|
|
2695
2827
|
"current_phase": "implement",
|
|
2696
2828
|
"total_tool_calls": 1,
|
|
2697
|
-
"
|
|
2698
|
-
"subagent_spawn_count": 1,
|
|
2829
|
+
"subagent_statistics": {"active": 1, "spawned": 1},
|
|
2699
2830
|
"child_activity_signature": f"child:{self.calls}",
|
|
2700
2831
|
"child_total_bytes": self.calls,
|
|
2701
2832
|
"fatal_error_code": "",
|
|
@@ -2787,10 +2918,13 @@ def test_session_summary_reports_normalized_subagents_and_child_liveness(tmp_pat
|
|
|
2787
2918
|
session_log.write_text("one\ntwo\n", encoding="utf-8")
|
|
2788
2919
|
progress.write_text(
|
|
2789
2920
|
json.dumps({
|
|
2790
|
-
"
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2921
|
+
"subagent_statistics": {
|
|
2922
|
+
"spawned": 2,
|
|
2923
|
+
"active": 1,
|
|
2924
|
+
"states": [{"status": "running", "count": 1}, {"status": "completed", "count": 1}],
|
|
2925
|
+
"providers": ["claude"],
|
|
2926
|
+
"source": "session_log",
|
|
2927
|
+
},
|
|
2794
2928
|
"child_total_bytes": 2048,
|
|
2795
2929
|
"child_session_files": [{"path": "child-a"}],
|
|
2796
2930
|
}),
|
|
@@ -2843,7 +2977,7 @@ def test_ai_interruption_diagnostics_are_detailed_console_only(tmp_path, capsys)
|
|
|
2843
2977
|
"current_tool_input_summary": "secret-command-must-not-be-logged",
|
|
2844
2978
|
"message_count": 455,
|
|
2845
2979
|
"total_tool_calls": 453,
|
|
2846
|
-
"
|
|
2980
|
+
"subagent_statistics": {"active": 0, "spawned": 0},
|
|
2847
2981
|
}
|
|
2848
2982
|
),
|
|
2849
2983
|
encoding="utf-8",
|
|
@@ -4293,3 +4427,245 @@ def test_git_recovery_helpers_create_branch_without_checkout_and_report_registra
|
|
|
4293
4427
|
for registration in registrations
|
|
4294
4428
|
)
|
|
4295
4429
|
|
|
4430
|
+
|
|
4431
|
+
def test_cursor_stream_json_progress_and_semantic_log_contract(tmp_path):
|
|
4432
|
+
parser = _load_progress_parser_module()
|
|
4433
|
+
tracker = parser.ProgressTracker(tmp_path / "session.log")
|
|
4434
|
+
normalizer = parser.SemanticLogNormalizer()
|
|
4435
|
+
events = [
|
|
4436
|
+
{
|
|
4437
|
+
"type": "system",
|
|
4438
|
+
"subtype": "init",
|
|
4439
|
+
"apiKeySource": "login",
|
|
4440
|
+
"cwd": str(tmp_path),
|
|
4441
|
+
"session_id": "cursor-session",
|
|
4442
|
+
"model": "Cursor Model",
|
|
4443
|
+
"permissionMode": "default",
|
|
4444
|
+
},
|
|
4445
|
+
{
|
|
4446
|
+
"type": "assistant",
|
|
4447
|
+
"message": {"role": "assistant", "content": [{"type": "text", "text": "Reading the file"}]},
|
|
4448
|
+
"session_id": "cursor-session",
|
|
4449
|
+
},
|
|
4450
|
+
{
|
|
4451
|
+
"type": "tool_call",
|
|
4452
|
+
"subtype": "started",
|
|
4453
|
+
"call_id": "read-1",
|
|
4454
|
+
"tool_call": {"readToolCall": {"args": {"path": "README.md"}}},
|
|
4455
|
+
"session_id": "cursor-session",
|
|
4456
|
+
},
|
|
4457
|
+
{
|
|
4458
|
+
"type": "tool_call",
|
|
4459
|
+
"subtype": "completed",
|
|
4460
|
+
"call_id": "read-1",
|
|
4461
|
+
"tool_call": {
|
|
4462
|
+
"readToolCall": {
|
|
4463
|
+
"args": {"path": "README.md"},
|
|
4464
|
+
"result": {"success": {"content": "large file content", "totalLines": 10}},
|
|
4465
|
+
}
|
|
4466
|
+
},
|
|
4467
|
+
"session_id": "cursor-session",
|
|
4468
|
+
},
|
|
4469
|
+
{
|
|
4470
|
+
"type": "tool_call",
|
|
4471
|
+
"subtype": "started",
|
|
4472
|
+
"call_id": "task-1",
|
|
4473
|
+
"tool_call": {"function": {"name": "Task", "arguments": "{\"prompt\":\"inspect\"}"}},
|
|
4474
|
+
"session_id": "cursor-session",
|
|
4475
|
+
},
|
|
4476
|
+
{
|
|
4477
|
+
"type": "tool_call",
|
|
4478
|
+
"subtype": "completed",
|
|
4479
|
+
"call_id": "task-1",
|
|
4480
|
+
"tool_call": {"function": {"name": "Task", "arguments": "{}", "result": {"success": "done"}}},
|
|
4481
|
+
"session_id": "cursor-session",
|
|
4482
|
+
},
|
|
4483
|
+
{
|
|
4484
|
+
"type": "result",
|
|
4485
|
+
"subtype": "success",
|
|
4486
|
+
"is_error": False,
|
|
4487
|
+
"result": "Done",
|
|
4488
|
+
"session_id": "cursor-session",
|
|
4489
|
+
"unknown_future_field": {"safe": True},
|
|
4490
|
+
},
|
|
4491
|
+
]
|
|
4492
|
+
|
|
4493
|
+
rendered = ""
|
|
4494
|
+
for event in events:
|
|
4495
|
+
tracker.process_event(event)
|
|
4496
|
+
rendered += normalizer.process_event(event)
|
|
4497
|
+
rendered += normalizer.finish()
|
|
4498
|
+
data = tracker.to_dict()
|
|
4499
|
+
|
|
4500
|
+
assert data["event_format"] == "cursor-stream-json"
|
|
4501
|
+
assert data["cursor_session_id"] == "cursor-session"
|
|
4502
|
+
assert data["claude_session_id"] == ""
|
|
4503
|
+
assert data["result_subtype"] == "success"
|
|
4504
|
+
assert data["total_tool_calls"] == 2
|
|
4505
|
+
tool_counts = {item["name"]: item["count"] for item in data["tool_calls"]}
|
|
4506
|
+
assert tool_counts["Read"] == 1
|
|
4507
|
+
assert tool_counts["Task"] == 1
|
|
4508
|
+
assert data["subagent_statistics"]["spawned"] == 1
|
|
4509
|
+
assert data["terminal_result_text"] == "Done"
|
|
4510
|
+
assert "[ACTION] Read" in rendered
|
|
4511
|
+
assert "[OBSERVATION] Read" in rendered
|
|
4512
|
+
assert "<18 chars>" in rendered
|
|
4513
|
+
assert "[SESSION_END] status=success" in rendered
|
|
4514
|
+
|
|
4515
|
+
|
|
4516
|
+
def test_claude_init_with_shared_fields_is_not_misclassified_as_cursor(tmp_path):
|
|
4517
|
+
from prizmkit_runtime.sessions import parse_stream_progress_lines
|
|
4518
|
+
|
|
4519
|
+
parser = _load_progress_parser_module()
|
|
4520
|
+
tracker = parser.ProgressTracker(tmp_path / "session.log", provider_hint="claude")
|
|
4521
|
+
event = {
|
|
4522
|
+
"type": "system",
|
|
4523
|
+
"subtype": "init",
|
|
4524
|
+
"apiKeySource": "login",
|
|
4525
|
+
"permissionMode": "bypassPermissions",
|
|
4526
|
+
"session_id": "claude-session",
|
|
4527
|
+
}
|
|
4528
|
+
tracker.process_event(event)
|
|
4529
|
+
data = tracker.to_dict()
|
|
4530
|
+
assert data["event_format"] == "stream-json"
|
|
4531
|
+
assert data["claude_session_id"] == "claude-session"
|
|
4532
|
+
assert data["cursor_session_id"] == ""
|
|
4533
|
+
|
|
4534
|
+
summary = parse_stream_progress_lines((json.dumps(event),), provider_hint="claude")
|
|
4535
|
+
assert summary.claude_session_id == "claude-session"
|
|
4536
|
+
assert summary.cursor_session_id == ""
|
|
4537
|
+
|
|
4538
|
+
|
|
4539
|
+
def test_cursor_stream_errors_and_malformed_lines_fail_safely(tmp_path):
|
|
4540
|
+
from prizmkit_runtime.sessions import parse_stream_progress_lines
|
|
4541
|
+
|
|
4542
|
+
parser = _load_progress_parser_module()
|
|
4543
|
+
tracker = parser.ProgressTracker(tmp_path / "session.log")
|
|
4544
|
+
tracker.process_event({
|
|
4545
|
+
"type": "system",
|
|
4546
|
+
"subtype": "init",
|
|
4547
|
+
"apiKeySource": "env",
|
|
4548
|
+
"session_id": "cursor-error-session",
|
|
4549
|
+
})
|
|
4550
|
+
tracker.process_event({
|
|
4551
|
+
"type": "tool_call",
|
|
4552
|
+
"subtype": "completed",
|
|
4553
|
+
"call_id": "write-1",
|
|
4554
|
+
"tool_call": {
|
|
4555
|
+
"writeToolCall": {
|
|
4556
|
+
"args": {"path": "blocked.txt", "fileText": "secret"},
|
|
4557
|
+
"result": {"failure": {"message": "permission denied"}},
|
|
4558
|
+
}
|
|
4559
|
+
},
|
|
4560
|
+
"session_id": "cursor-error-session",
|
|
4561
|
+
})
|
|
4562
|
+
tracker.process_event({
|
|
4563
|
+
"type": "error",
|
|
4564
|
+
"message": "Cursor Agent permission denied by policy",
|
|
4565
|
+
"session_id": "cursor-error-session",
|
|
4566
|
+
})
|
|
4567
|
+
data = tracker.to_dict()
|
|
4568
|
+
assert data["event_format"] == "cursor-stream-json"
|
|
4569
|
+
assert data["cursor_session_id"] == "cursor-error-session"
|
|
4570
|
+
assert data["current_tool"] is None
|
|
4571
|
+
assert any("permission denied" in str(item) for item in data["errors"])
|
|
4572
|
+
assert data["result_subtype"] == ""
|
|
4573
|
+
|
|
4574
|
+
summary = parse_stream_progress_lines((
|
|
4575
|
+
"not-json",
|
|
4576
|
+
json.dumps({
|
|
4577
|
+
"type": "system",
|
|
4578
|
+
"subtype": "init",
|
|
4579
|
+
"apiKeySource": "login",
|
|
4580
|
+
"session_id": "cursor-summary",
|
|
4581
|
+
}),
|
|
4582
|
+
json.dumps({"type": "error", "message": "permission denied by user", "session_id": "cursor-summary"}),
|
|
4583
|
+
), provider_hint="cursor")
|
|
4584
|
+
assert summary.cursor_session_id == "cursor-summary"
|
|
4585
|
+
assert summary.claude_session_id == ""
|
|
4586
|
+
assert summary.permission_denial_count == 1
|
|
4587
|
+
assert summary.result_subtype == ""
|
|
4588
|
+
|
|
4589
|
+
|
|
4590
|
+
def test_cursor_session_launcher_uses_stdin_and_task_checkout(tmp_path):
|
|
4591
|
+
from prizmkit_runtime.sessions import AISessionConfig, AISessionLauncher
|
|
4592
|
+
|
|
4593
|
+
checkout = tmp_path / "checkout"
|
|
4594
|
+
checkout.mkdir()
|
|
4595
|
+
prompt = tmp_path / "prompt.md"
|
|
4596
|
+
prompt_text = "cursor coordinator prompt " * 1000
|
|
4597
|
+
prompt.write_text(prompt_text, encoding="utf-8")
|
|
4598
|
+
fake_agent = tmp_path / "agent"
|
|
4599
|
+
fake_agent.write_text(
|
|
4600
|
+
"#!/usr/bin/env python3\n"
|
|
4601
|
+
"import json, pathlib, sys\n"
|
|
4602
|
+
"pathlib.Path('cursor-argv.json').write_text(json.dumps(sys.argv[1:]))\n"
|
|
4603
|
+
"pathlib.Path('cursor-stdin.txt').write_text(sys.stdin.read())\n"
|
|
4604
|
+
"print(json.dumps({'type':'system','subtype':'init','apiKeySource':'login','cwd':str(pathlib.Path.cwd()),'session_id':'cursor-live','model':'fake','permissionMode':'default'}), flush=True)\n"
|
|
4605
|
+
"print(json.dumps({'type':'result','subtype':'success','is_error':False,'result':'ok','session_id':'cursor-live'}), flush=True)\n",
|
|
4606
|
+
encoding="utf-8",
|
|
4607
|
+
)
|
|
4608
|
+
fake_agent.chmod(0o755)
|
|
4609
|
+
session_log = tmp_path / "session.log"
|
|
4610
|
+
progress = tmp_path / "progress.json"
|
|
4611
|
+
|
|
4612
|
+
result = AISessionLauncher(
|
|
4613
|
+
AISessionConfig(
|
|
4614
|
+
cli_command=str(fake_agent),
|
|
4615
|
+
platform="cursor",
|
|
4616
|
+
model="fake-model",
|
|
4617
|
+
prompt_path=prompt,
|
|
4618
|
+
cwd=checkout,
|
|
4619
|
+
log_path=session_log,
|
|
4620
|
+
progress_path=progress,
|
|
4621
|
+
use_stream_json=True,
|
|
4622
|
+
)
|
|
4623
|
+
).run()
|
|
4624
|
+
|
|
4625
|
+
argv = json.loads((checkout / "cursor-argv.json").read_text(encoding="utf-8"))
|
|
4626
|
+
assert argv == ["--print", "--force", "--trust", "--output-format", "stream-json", "--model", "fake-model"]
|
|
4627
|
+
assert prompt_text not in json.dumps(argv)
|
|
4628
|
+
assert (checkout / "cursor-stdin.txt").read_text(encoding="utf-8") == prompt_text
|
|
4629
|
+
assert result.exit_code == 0
|
|
4630
|
+
assert result.progress_summary.result_subtype == "success"
|
|
4631
|
+
assert result.progress_summary.cursor_session_id == "cursor-live"
|
|
4632
|
+
assert result.progress_summary.claude_session_id == ""
|
|
4633
|
+
assert "cursor coordinator prompt" not in session_log.read_text(encoding="utf-8")
|
|
4634
|
+
|
|
4635
|
+
|
|
4636
|
+
def test_cursor_support_is_hidden_but_tracked_project_configuration_is_committable(tmp_path):
|
|
4637
|
+
from prizmkit_runtime.gitops import (
|
|
4638
|
+
HIDDEN_TOOL_WORKTREE_EXCLUDES,
|
|
4639
|
+
WORKTREE_PLATFORM_SUPPORT_DIRS,
|
|
4640
|
+
git_status_safe,
|
|
4641
|
+
visible_task_paths,
|
|
4642
|
+
)
|
|
4643
|
+
|
|
4644
|
+
assert ".cursor" in WORKTREE_PLATFORM_SUPPORT_DIRS
|
|
4645
|
+
assert ":(top,exclude).cursor" in HIDDEN_TOOL_WORKTREE_EXCLUDES
|
|
4646
|
+
assert ":(top,exclude,glob).cursor/**" in HIDDEN_TOOL_WORKTREE_EXCLUDES
|
|
4647
|
+
|
|
4648
|
+
project = tmp_path / "project"
|
|
4649
|
+
project.mkdir()
|
|
4650
|
+
subprocess.run(["git", "init", "-q"], cwd=project, check=True)
|
|
4651
|
+
subprocess.run(["git", "config", "user.name", "Test User"], cwd=project, check=True)
|
|
4652
|
+
subprocess.run(["git", "config", "user.email", "test@example.invalid"], cwd=project, check=True)
|
|
4653
|
+
tracked_rule = project / ".cursor" / "rules" / "user-owned.mdc"
|
|
4654
|
+
tracked_rule.parent.mkdir(parents=True)
|
|
4655
|
+
tracked_rule.write_text("tracked\n", encoding="utf-8")
|
|
4656
|
+
subprocess.run(["git", "add", ".cursor/rules/user-owned.mdc"], cwd=project, check=True)
|
|
4657
|
+
subprocess.run(["git", "commit", "-qm", "fixture"], cwd=project, check=True)
|
|
4658
|
+
|
|
4659
|
+
tracked_rule.write_text("changed\n", encoding="utf-8")
|
|
4660
|
+
materialized = project / ".cursor" / "skills" / "prizmkit" / "SKILL.md"
|
|
4661
|
+
materialized.parent.mkdir(parents=True)
|
|
4662
|
+
materialized.write_text("support\n", encoding="utf-8")
|
|
4663
|
+
|
|
4664
|
+
paths, result = visible_task_paths(project)
|
|
4665
|
+
assert result.return_code == 0
|
|
4666
|
+
assert ".cursor/rules/user-owned.mdc" in paths
|
|
4667
|
+
assert ".cursor/skills/prizmkit/SKILL.md" not in paths
|
|
4668
|
+
safe_status = git_status_safe(project)
|
|
4669
|
+
assert ".cursor/rules/user-owned.mdc" in safe_status
|
|
4670
|
+
assert ".cursor/skills/prizmkit/SKILL.md" not in safe_status
|
|
4671
|
+
|
|
@@ -9,6 +9,7 @@ from utils import (
|
|
|
9
9
|
write_json_file,
|
|
10
10
|
pad_right,
|
|
11
11
|
_build_progress_bar,
|
|
12
|
+
detect_project_context,
|
|
12
13
|
stable_topological_order,
|
|
13
14
|
)
|
|
14
15
|
|
|
@@ -88,6 +89,28 @@ class TestBuildProgressBar:
|
|
|
88
89
|
assert "50%" in bar
|
|
89
90
|
|
|
90
91
|
|
|
92
|
+
# ---------------------------------------------------------------------------
|
|
93
|
+
# detect_project_context
|
|
94
|
+
# ---------------------------------------------------------------------------
|
|
95
|
+
|
|
96
|
+
class TestDetectProjectContext:
|
|
97
|
+
def test_node_detection_returns_only_canonical_context_keys(self, tmp_path):
|
|
98
|
+
(tmp_path / "package.json").write_text(
|
|
99
|
+
json.dumps({"dependencies": {"react": "latest", "express": "latest"}}),
|
|
100
|
+
encoding="utf-8",
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
detected = detect_project_context(str(tmp_path))
|
|
104
|
+
|
|
105
|
+
assert detected == {
|
|
106
|
+
"language": "JavaScript",
|
|
107
|
+
"runtime": "Node.js",
|
|
108
|
+
"frontend_framework": "React",
|
|
109
|
+
"backend_framework": "Express.js",
|
|
110
|
+
"project_type": "fullstack",
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
91
114
|
# ---------------------------------------------------------------------------
|
|
92
115
|
# stable_topological_order
|
|
93
116
|
# ---------------------------------------------------------------------------
|
package/bundled/rules/USAGE.md
CHANGED
|
@@ -56,6 +56,9 @@ npx prizmkit install . --rules none
|
|
|
56
56
|
|----------|------------------|--------|
|
|
57
57
|
| Claude Code | `.claude/rules/<name>.md` | Markdown + YAML frontmatter |
|
|
58
58
|
| CodeBuddy | `.codebuddy/rules/<name>.mdc` | `.mdc` format (auto-converted) |
|
|
59
|
+
| Codex | `.agents/rules/<name>.md` | Behavioral Markdown guidance |
|
|
60
|
+
| Pi | `.pi/rules/<name>.md` | Behavioral Markdown guidance |
|
|
61
|
+
| Cursor | `.cursor/rules/<name>.mdc` | Always-applied `.mdc` without temporal metadata |
|
|
59
62
|
|
|
60
63
|
Rule names use `category/filename` path format (e.g., `prizm/prizm-documentation`). During installation, the last segment is used as the filename (`prizm-documentation.md`).
|
|
61
64
|
|
|
@@ -444,7 +444,6 @@ Key points:
|
|
|
444
444
|
- Critical/high severity bugs require clear automated, manual, or hybrid verification evidence.
|
|
445
445
|
- Medium/low severity bugs use the smallest verification that proves the fix and guards against regression.
|
|
446
446
|
- `browser_interaction` is supported for UI-reproducible bugs; `verification_type` still declares whether verification is automated, manual, or hybrid.
|
|
447
|
-
- Do not generate `critic` or `critic_count`; those fields are fully removed and validators reject them.
|
|
448
447
|
|
|
449
448
|
---
|
|
450
449
|
|
|
@@ -25,5 +25,3 @@ Use `browser_interaction` for UI-reproducible bugs.
|
|
|
25
25
|
- `tool: playwright-cli` is best for local dev-server verification in an isolated browser.
|
|
26
26
|
- `tool: opencli` is best when an existing Chrome login/session or third-party integration cookies are needed.
|
|
27
27
|
- `verify_steps` should describe what to prove, not low-level click scripts.
|
|
28
|
-
|
|
29
|
-
Do not emit `critic` or `critic_count`; those fields are retired and validators reject them.
|