prizmkit 1.1.191 → 1.1.192
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/bundled/VERSION.json +3 -3
- package/bundled/adapters/antigravity/skill-adapter.js +13 -4
- package/bundled/adapters/codex/skill-adapter.js +28 -8
- package/bundled/adapters/cursor/skill-adapter.js +13 -4
- package/bundled/adapters/pi/skill-adapter.js +28 -7
- package/bundled/dev-pipeline/.env.example +4 -12
- package/bundled/dev-pipeline/README.md +5 -10
- package/bundled/dev-pipeline/assets/skill-subagent-integration.md +3 -6
- package/bundled/dev-pipeline/prizmkit_runtime/atomic_io.py +48 -0
- package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +66 -23
- package/bundled/dev-pipeline/prizmkit_runtime/cli.py +10 -7
- package/bundled/dev-pipeline/prizmkit_runtime/commands.py +2 -21
- package/bundled/dev-pipeline/prizmkit_runtime/config.py +24 -76
- package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +125 -67
- package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +77 -430
- package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +93 -49
- package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +1 -3
- package/bundled/dev-pipeline/prizmkit_runtime/paths.py +0 -6
- package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +36 -14
- package/bundled/dev-pipeline/prizmkit_runtime/processes.py +206 -151
- package/bundled/dev-pipeline/prizmkit_runtime/reset.py +2 -23
- package/bundled/dev-pipeline/prizmkit_runtime/reset_preserve.py +15 -134
- package/bundled/dev-pipeline/prizmkit_runtime/results.py +25 -0
- package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +68 -83
- package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +15 -5
- package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +1 -29
- package/bundled/dev-pipeline/prizmkit_runtime/runner_prompts.py +0 -2
- package/bundled/dev-pipeline/prizmkit_runtime/runner_status.py +7 -2
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +276 -217
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +124 -122
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_helper.py +90 -9
- package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +183 -130
- package/bundled/dev-pipeline/prizmkit_runtime/status.py +1 -3
- package/bundled/dev-pipeline/prizmkit_runtime/stream_progress.py +2780 -0
- package/bundled/dev-pipeline/prizmkit_runtime/task_checkout.py +27 -101
- package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +58 -4
- package/bundled/dev-pipeline/scripts/check-session-status.py +43 -19
- package/bundled/dev-pipeline/scripts/continuation.py +6 -4
- package/bundled/dev-pipeline/scripts/detect-stuck.py +28 -28
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +7 -2
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +7 -2
- package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +10 -7
- package/bundled/dev-pipeline/scripts/init-change-artifact.py +8 -2
- package/bundled/dev-pipeline/scripts/init-pipeline.py +14 -69
- package/bundled/dev-pipeline/scripts/parse-stream-progress.py +31 -2616
- package/bundled/dev-pipeline/scripts/patch-completion-notes.py +4 -24
- package/bundled/dev-pipeline/scripts/prompt_framework.py +56 -9
- package/bundled/dev-pipeline/scripts/status_common.py +591 -0
- package/bundled/dev-pipeline/scripts/update-bug-status.py +85 -463
- package/bundled/dev-pipeline/scripts/update-checkpoint.py +227 -65
- package/bundled/dev-pipeline/scripts/update-feature-status.py +76 -509
- package/bundled/dev-pipeline/scripts/utils.py +5 -12
- package/bundled/dev-pipeline/templates/bootstrap-tier3.md +4 -4
- package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +7 -0
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +1 -1
- package/bundled/dev-pipeline/templates/sections/artifact-manifest.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-manual-verification.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +2 -1
- package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification-auto.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification-opencli.md +2 -2
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification.md +2 -2
- package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +2 -1
- package/bundled/dev-pipeline/templates/sections/phase-review-full.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +3 -6
- package/bundled/dev-pipeline/templates/session-status-schema.json +2 -5
- package/bundled/dev-pipeline/tests/_helpers.py +418 -0
- package/bundled/dev-pipeline/tests/conftest.py +45 -1
- package/bundled/dev-pipeline/tests/test_auto_skip.py +4 -69
- package/bundled/dev-pipeline/tests/test_checkpoint_state.py +126 -1
- package/bundled/dev-pipeline/tests/test_daemon_and_scripts.py +257 -0
- package/bundled/dev-pipeline/tests/test_e2e_pipeline_run.py +500 -0
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +59 -117
- package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +12 -10
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +431 -3099
- package/bundled/dev-pipeline/tests/test_recovery_workflow.py +7 -8
- package/bundled/dev-pipeline/tests/test_repository_bootstrap.py +0 -1
- package/bundled/dev-pipeline/tests/test_reset_modes.py +15 -27
- package/bundled/dev-pipeline/tests/test_reset_preserve.py +54 -139
- package/bundled/dev-pipeline/tests/test_runner_bookkeeping.py +766 -0
- package/bundled/dev-pipeline/tests/test_runner_lifecycle.py +1257 -0
- package/bundled/dev-pipeline/tests/test_runtime_helper.py +97 -20
- package/bundled/dev-pipeline/tests/test_session_launch.py +1101 -0
- package/bundled/dev-pipeline/tests/test_stream_progress.py +585 -0
- package/bundled/dev-pipeline/tests/test_unified_cli.py +155 -2034
- package/bundled/dev-pipeline/tests/test_utils.py +3 -3
- package/bundled/skills/_metadata.json +9 -63
- package/bundled/skills/app-planner/SKILL.md +32 -303
- package/bundled/skills/app-planner/references/app-design-guide.md +0 -4
- package/bundled/skills/app-planner/references/generated-plan-review.md +2 -1
- package/bundled/skills/app-planner/references/project-brief-guide.md +14 -0
- package/bundled/skills/app-planner/references/project-conventions-discovery.md +4 -6
- package/bundled/skills/app-planner/references/project-state-detection.md +2 -3
- package/bundled/skills/bug-fix-workflow/SKILL.md +1 -2
- package/bundled/skills/bug-fix-workflow/references/bug-diagnosis.md +4 -7
- package/bundled/skills/bug-planner/SKILL.md +54 -435
- package/bundled/skills/bug-planner/references/generated-plan-review.md +3 -2
- package/bundled/skills/bug-planner/references/input-formats.md +32 -0
- package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +4 -6
- package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +4 -28
- package/bundled/skills/feature-pipeline-launcher/SKILL.md +4 -6
- package/bundled/skills/feature-pipeline-launcher/references/configuration.md +4 -28
- package/bundled/skills/feature-planner/SKILL.md +60 -439
- package/bundled/skills/feature-planner/assets/planning-guide.md +1 -1
- package/bundled/skills/feature-planner/references/completeness-review.md +34 -0
- package/bundled/skills/feature-planner/references/decomposition-patterns.md +2 -2
- package/bundled/skills/feature-planner/references/error-recovery.md +1 -1
- package/bundled/skills/feature-planner/references/generated-plan-review.md +3 -2
- package/bundled/skills/feature-planner/references/incremental-feature-planning.md +3 -1
- package/bundled/skills/feature-workflow/SKILL.md +1 -2
- package/bundled/skills/prizmkit/SKILL.md +7 -1
- package/bundled/skills/prizmkit-code-review/SKILL.md +14 -6
- package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +7 -4
- package/bundled/skills/prizmkit-code-review/references/review-report-template.md +16 -0
- package/bundled/skills/prizmkit-code-review/scripts/render_review_report.py +58 -20
- package/bundled/skills/prizmkit-implement/SKILL.md +1 -1
- package/bundled/skills/prizmkit-init/SKILL.md +24 -127
- package/bundled/skills/prizmkit-init/assets/project-brief-template.md +3 -3
- package/bundled/skills/prizmkit-plan/SKILL.md +6 -8
- package/bundled/skills/prizmkit-plan/references/clarify-guide.md +1 -1
- package/bundled/skills/prizmkit-plan/references/independent-plan-review.md +5 -2
- package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +6 -5
- package/bundled/skills/prizmkit-prizm-docs/SKILL.md +1 -13
- package/bundled/skills/prizmkit-prizm-docs/references/op-update.md +1 -1
- package/bundled/skills/prizmkit-retrospective/SKILL.md +6 -4
- package/bundled/skills/prizmkit-test/SKILL.md +25 -133
- package/bundled/skills/prizmkit-test/references/independent-test-review.md +5 -2
- package/bundled/skills/prizmkit-test/references/test-coverage-model.md +6 -0
- package/bundled/skills/prizmkit-workflow/SKILL.md +2 -3
- package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +4 -3
- package/bundled/skills/recovery-workflow/SKILL.md +7 -7
- package/bundled/skills/recovery-workflow/evals/evals.json +1 -1
- package/bundled/skills/recovery-workflow/references/detection.md +1 -3
- package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +0 -6
- package/bundled/templates/project-memory-template.md +1 -2
- package/package.json +1 -1
- package/src/scaffold.js +28 -7
- package/bundled/dev-pipeline/SCHEMA_ANALYSIS.md +0 -53
- package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +0 -649
- package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +0 -463
- package/bundled/dev-pipeline/scripts/update-refactor-status.py +0 -1512
- package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +0 -240
- package/bundled/dev-pipeline/templates/refactor-list-schema.json +0 -266
- package/bundled/dev-pipeline/templates/sections/refactor-critical-paths.md +0 -15
- package/bundled/dev-pipeline/templates/sections/refactor-mission.md +0 -9
- package/bundled/dev-pipeline/templates/sections/refactor-phase-commit-report.md +0 -24
- package/bundled/dev-pipeline/templates/sections/refactor-phase-implement.md +0 -16
- package/bundled/dev-pipeline/templates/sections/refactor-phase-init.md +0 -9
- package/bundled/dev-pipeline/templates/sections/refactor-phase-plan.md +0 -22
- package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +0 -19
- package/bundled/dev-pipeline/templates/sections/refactor-phase-test.md +0 -24
- package/bundled/dev-pipeline/templates/sections/refactor-reminders.md +0 -12
- package/bundled/dev-pipeline/templates/sections/refactor-session-context.md +0 -6
- package/bundled/dev-pipeline/templates/sections/refactor-task-contract.md +0 -52
- package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +0 -478
- package/bundled/skills/feature-planner/assets/evaluation-guide.md +0 -44
- package/bundled/skills/refactor-pipeline-launcher/SKILL.md +0 -219
- package/bundled/skills/refactor-pipeline-launcher/references/configuration.md +0 -78
- package/bundled/skills/refactor-planner/SKILL.md +0 -467
- package/bundled/skills/refactor-planner/assets/planning-guide.md +0 -291
- package/bundled/skills/refactor-planner/references/behavior-preservation.md +0 -187
- package/bundled/skills/refactor-planner/references/error-recovery.md +0 -45
- package/bundled/skills/refactor-planner/references/fast-path.md +0 -59
- package/bundled/skills/refactor-planner/references/generated-plan-review.md +0 -107
- package/bundled/skills/refactor-planner/references/planning-phases.md +0 -172
- package/bundled/skills/refactor-planner/references/refactor-scoping-guide.md +0 -230
- package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +0 -1120
- package/bundled/skills/refactor-workflow/SKILL.md +0 -205
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
"""End-to-end foreground pipeline execution tests with a real Git repo and fake CLI."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import subprocess
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from _helpers import PIPELINE_ROOT, init_git_repo, make_runtime_paths, write_fake_cli
|
|
11
|
+
|
|
12
|
+
sys.path.insert(0, str(PIPELINE_ROOT))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
_FAKE_CLI_SCRIPT = """#!__PYTHON__
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import json
|
|
19
|
+
import subprocess
|
|
20
|
+
import sys
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _read_prompt() -> str:
|
|
25
|
+
if "-i" in sys.argv:
|
|
26
|
+
idx = sys.argv.index("-i")
|
|
27
|
+
if idx + 1 < len(sys.argv):
|
|
28
|
+
return sys.argv[idx + 1]
|
|
29
|
+
return sys.stdin.read()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _detect_item_id(prompt: str) -> str:
|
|
33
|
+
for candidate in ("F-002", "F-001"):
|
|
34
|
+
if candidate in prompt:
|
|
35
|
+
return candidate
|
|
36
|
+
return "F-001"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _ensure_required_artifact(cwd: Path, rel_path: str, slug: str) -> None:
|
|
40
|
+
target = cwd / rel_path
|
|
41
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
42
|
+
if target.name == "review-report.md":
|
|
43
|
+
target.write_text("# Review Report\\n\\n## Final Result\\n\\n- Verdict: PASS\\n", encoding="utf-8")
|
|
44
|
+
return
|
|
45
|
+
if target.name == "retrospective-result.json":
|
|
46
|
+
target.write_text(
|
|
47
|
+
json.dumps(
|
|
48
|
+
{
|
|
49
|
+
"schema_version": 1,
|
|
50
|
+
"outcome": "RETRO_COMPLETE",
|
|
51
|
+
"result": "NO_DOC_CHANGE",
|
|
52
|
+
"reason": "No documentation changes required",
|
|
53
|
+
"change_paths": [f"src/{slug.replace('-', '_')}.py"],
|
|
54
|
+
"documentation_paths": [],
|
|
55
|
+
"validation": ["passed"],
|
|
56
|
+
},
|
|
57
|
+
indent=2,
|
|
58
|
+
)
|
|
59
|
+
+ "\\n",
|
|
60
|
+
encoding="utf-8",
|
|
61
|
+
)
|
|
62
|
+
return
|
|
63
|
+
if target.name == "test-report.md":
|
|
64
|
+
target.write_text("# Test Report\\n\\n## Final Result\\n\\n- Result: TEST_PASS\\n", encoding="utf-8")
|
|
65
|
+
return
|
|
66
|
+
if target.name == "test-result.json":
|
|
67
|
+
target.write_text(
|
|
68
|
+
json.dumps(
|
|
69
|
+
{
|
|
70
|
+
"schema_version": 1,
|
|
71
|
+
"result": "TEST_PASS",
|
|
72
|
+
"report": "test-report.md",
|
|
73
|
+
"main_review_rounds": 1,
|
|
74
|
+
"independent_review": {
|
|
75
|
+
"status": "downgraded",
|
|
76
|
+
"responses": 0,
|
|
77
|
+
"downgrade_reason": "read-only continuation capability unavailable",
|
|
78
|
+
"final_state_rechecked": False,
|
|
79
|
+
},
|
|
80
|
+
"repair_rounds": 0,
|
|
81
|
+
"production_changed": False,
|
|
82
|
+
"unresolved_items": [],
|
|
83
|
+
},
|
|
84
|
+
indent=2,
|
|
85
|
+
)
|
|
86
|
+
+ "\\n",
|
|
87
|
+
encoding="utf-8",
|
|
88
|
+
)
|
|
89
|
+
return
|
|
90
|
+
if not target.exists():
|
|
91
|
+
if target.suffix == ".json":
|
|
92
|
+
target.write_text(json.dumps({"slug": slug, "status": "completed"}) + "\\n", encoding="utf-8")
|
|
93
|
+
else:
|
|
94
|
+
target.write_text(f"# Artifact for {slug}\\n", encoding="utf-8")
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def main() -> int:
|
|
98
|
+
cwd = Path.cwd()
|
|
99
|
+
prompt = _read_prompt()
|
|
100
|
+
item_id = _detect_item_id(prompt)
|
|
101
|
+
|
|
102
|
+
calls_file = Path(__CALLS_FILE__)
|
|
103
|
+
calls_file.parent.mkdir(parents=True, exist_ok=True)
|
|
104
|
+
with calls_file.open("a", encoding="utf-8") as handle:
|
|
105
|
+
handle.write(f"{item_id}\\n")
|
|
106
|
+
|
|
107
|
+
mode_map = json.loads(__MODE_MAP_JSON__)
|
|
108
|
+
mode = mode_map.get(item_id, "complete")
|
|
109
|
+
|
|
110
|
+
checkpoints = sorted(cwd.glob(".prizmkit/specs/*/workflow-checkpoint.json"))
|
|
111
|
+
checkpoint_path = None
|
|
112
|
+
numeric_prefix = item_id.replace("F-", "").replace("f-", "").zfill(3) + "-"
|
|
113
|
+
for candidate in checkpoints:
|
|
114
|
+
data = json.loads(candidate.read_text(encoding="utf-8"))
|
|
115
|
+
if item_id in (data.get("feature_id"), data.get("item_id")) or candidate.parent.name.startswith(numeric_prefix):
|
|
116
|
+
checkpoint_path = candidate
|
|
117
|
+
break
|
|
118
|
+
if checkpoint_path is None:
|
|
119
|
+
checkpoint_path = checkpoints[-1]
|
|
120
|
+
|
|
121
|
+
artifact_dir = checkpoint_path.parent
|
|
122
|
+
artifact_rel = artifact_dir.relative_to(cwd).as_posix()
|
|
123
|
+
slug = artifact_dir.name
|
|
124
|
+
checkpoint = json.loads(checkpoint_path.read_text(encoding="utf-8"))
|
|
125
|
+
|
|
126
|
+
if mode == "fail_if_called":
|
|
127
|
+
print("unexpected CLI invocation during recovery", file=sys.stderr)
|
|
128
|
+
return 1
|
|
129
|
+
|
|
130
|
+
if mode == "blocked":
|
|
131
|
+
src_file = cwd / "src" / "partial.py"
|
|
132
|
+
src_file.parent.mkdir(parents=True, exist_ok=True)
|
|
133
|
+
src_file.write_text("# blocked partial change\\n", encoding="utf-8")
|
|
134
|
+
reached_implement = False
|
|
135
|
+
for step in checkpoint.get("steps", []):
|
|
136
|
+
skill = step.get("skill")
|
|
137
|
+
if skill == "prizmkit-implement":
|
|
138
|
+
reached_implement = True
|
|
139
|
+
step["status"] = "failed"
|
|
140
|
+
step["stage_result"] = "IMPLEMENT_BLOCKED"
|
|
141
|
+
elif not reached_implement:
|
|
142
|
+
step["status"] = "completed"
|
|
143
|
+
if skill in {"context-snapshot-and-plan", "prizmkit-plan"}:
|
|
144
|
+
step["stage_result"] = "PLAN_READY"
|
|
145
|
+
for rel_artifact in step.get("required_artifacts", []):
|
|
146
|
+
_ensure_required_artifact(cwd, rel_artifact, slug)
|
|
147
|
+
checkpoint["feature_state"] = {
|
|
148
|
+
"schema_version": 1,
|
|
149
|
+
"stage": "implement",
|
|
150
|
+
"status": "failed",
|
|
151
|
+
"stage_result": "IMPLEMENT_BLOCKED",
|
|
152
|
+
"current_stage": "prizmkit-implement",
|
|
153
|
+
"next_stage": None,
|
|
154
|
+
"blocked_reason": "Missing external credential",
|
|
155
|
+
"terminal_status": "WORKFLOW_BLOCKED",
|
|
156
|
+
}
|
|
157
|
+
checkpoint_path.write_text(json.dumps(checkpoint, indent=2) + "\\n", encoding="utf-8")
|
|
158
|
+
print(f"blocked {item_id}")
|
|
159
|
+
return 0
|
|
160
|
+
|
|
161
|
+
src_file = cwd / "src" / f"{slug.replace('-', '_')}.py"
|
|
162
|
+
src_file.parent.mkdir(parents=True, exist_ok=True)
|
|
163
|
+
src_file.write_text(f"FEATURE = {item_id!r}\\n", encoding="utf-8")
|
|
164
|
+
|
|
165
|
+
stage_map = {
|
|
166
|
+
"context-snapshot-and-plan": ("completed", "PLAN_READY"),
|
|
167
|
+
"prizmkit-plan": ("completed", "PLAN_READY"),
|
|
168
|
+
"prizmkit-implement": ("completed", "IMPLEMENTED"),
|
|
169
|
+
"prizmkit-code-review": ("completed", "REVIEW_PASS"),
|
|
170
|
+
"prizmkit-test": ("completed", "TEST_PASS"),
|
|
171
|
+
"completion-summary": ("completed", None),
|
|
172
|
+
"prizmkit-retrospective": ("completed", "RETRO_COMPLETE"),
|
|
173
|
+
"prizmkit-committer": ("in_progress", "COMMIT_PENDING"),
|
|
174
|
+
}
|
|
175
|
+
reached_committer = False
|
|
176
|
+
for step in checkpoint.get("steps", []):
|
|
177
|
+
skill = step.get("skill")
|
|
178
|
+
if skill == "prizmkit-committer":
|
|
179
|
+
reached_committer = True
|
|
180
|
+
step["status"] = "in_progress"
|
|
181
|
+
step["stage_result"] = "COMMIT_PENDING"
|
|
182
|
+
step["required_artifacts"] = [f"{artifact_rel}/runtime-commit-request.json"]
|
|
183
|
+
elif skill in stage_map:
|
|
184
|
+
status, result = stage_map[skill]
|
|
185
|
+
step["status"] = status
|
|
186
|
+
step["stage_result"] = result
|
|
187
|
+
if status == "completed":
|
|
188
|
+
for rel_artifact in step.get("required_artifacts", []):
|
|
189
|
+
_ensure_required_artifact(cwd, rel_artifact, slug)
|
|
190
|
+
if skill == "prizmkit-test":
|
|
191
|
+
_ensure_required_artifact(cwd, f"{artifact_rel}/test-report.md", slug)
|
|
192
|
+
_ensure_required_artifact(cwd, f"{artifact_rel}/test-result.json", slug)
|
|
193
|
+
step["required_artifacts"] = [
|
|
194
|
+
f"{artifact_rel}/test-report.md",
|
|
195
|
+
f"{artifact_rel}/test-result.json",
|
|
196
|
+
]
|
|
197
|
+
elif not reached_committer:
|
|
198
|
+
step["status"] = "completed"
|
|
199
|
+
for rel_artifact in step.get("required_artifacts", []):
|
|
200
|
+
_ensure_required_artifact(cwd, rel_artifact, slug)
|
|
201
|
+
|
|
202
|
+
head = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=cwd, text=True).strip()
|
|
203
|
+
(artifact_dir / "runtime-commit-request.json").write_text(
|
|
204
|
+
json.dumps(
|
|
205
|
+
{
|
|
206
|
+
"schema_version": 2,
|
|
207
|
+
"artifact_dir": artifact_rel,
|
|
208
|
+
"base_head": head,
|
|
209
|
+
"commit_message": f"feat({item_id}): implement {slug}",
|
|
210
|
+
},
|
|
211
|
+
indent=2,
|
|
212
|
+
)
|
|
213
|
+
+ "\\n",
|
|
214
|
+
encoding="utf-8",
|
|
215
|
+
)
|
|
216
|
+
checkpoint["feature_state"] = {
|
|
217
|
+
"schema_version": 1,
|
|
218
|
+
"stage": "committer",
|
|
219
|
+
"status": "in_progress",
|
|
220
|
+
"stage_result": "COMMIT_PENDING",
|
|
221
|
+
"current_stage": "prizmkit-committer",
|
|
222
|
+
"next_stage": "prizmkit-committer",
|
|
223
|
+
"terminal_status": None,
|
|
224
|
+
}
|
|
225
|
+
checkpoint_path.write_text(json.dumps(checkpoint, indent=2) + "\\n", encoding="utf-8")
|
|
226
|
+
print(f"completed {item_id}")
|
|
227
|
+
return 0
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
if __name__ == "__main__":
|
|
231
|
+
raise SystemExit(main())
|
|
232
|
+
"""
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def _git(root: Path, *args: str) -> str:
|
|
236
|
+
completed = subprocess.run(
|
|
237
|
+
["git", *args],
|
|
238
|
+
cwd=root,
|
|
239
|
+
check=True,
|
|
240
|
+
capture_output=True,
|
|
241
|
+
text=True,
|
|
242
|
+
)
|
|
243
|
+
return completed.stdout.strip()
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def _feature_entry(feature_id: str, title: str, *, status: str = "pending") -> dict[str, object]:
|
|
247
|
+
return {
|
|
248
|
+
"id": feature_id,
|
|
249
|
+
"title": title,
|
|
250
|
+
"description": f"Implement {title}",
|
|
251
|
+
"status": status,
|
|
252
|
+
"priority": "P1",
|
|
253
|
+
"dependencies": [],
|
|
254
|
+
"acceptance_criteria": [f"{feature_id} works"],
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def _setup_e2e_repo(
|
|
259
|
+
tmp_path: Path,
|
|
260
|
+
features: list[dict[str, object]],
|
|
261
|
+
mode_map: dict[str, str],
|
|
262
|
+
) -> tuple[object, Path]:
|
|
263
|
+
paths = make_runtime_paths(tmp_path)
|
|
264
|
+
calls_file = tmp_path / "fake-cli-calls.log"
|
|
265
|
+
script_body = (
|
|
266
|
+
_FAKE_CLI_SCRIPT.replace("__PYTHON__", sys.executable)
|
|
267
|
+
.replace("__CALLS_FILE__", repr(str(calls_file)))
|
|
268
|
+
.replace("__MODE_MAP_JSON__", repr(json.dumps(mode_map)))
|
|
269
|
+
)
|
|
270
|
+
fake_cli = write_fake_cli(tmp_path / "bin" / "fake-ai", script_body)
|
|
271
|
+
init_git_repo(
|
|
272
|
+
paths.project_root,
|
|
273
|
+
initial_files={
|
|
274
|
+
"README.md": "# E2E Repo\n",
|
|
275
|
+
".prizmkit/config.json": json.dumps(
|
|
276
|
+
{
|
|
277
|
+
"platform": "claude",
|
|
278
|
+
"ai_cli": str(fake_cli),
|
|
279
|
+
"ai_cli_launch": {"profile": "custom", "prompt_arg": "-i"},
|
|
280
|
+
},
|
|
281
|
+
indent=2,
|
|
282
|
+
)
|
|
283
|
+
+ "\n",
|
|
284
|
+
".prizmkit/plans/feature-list.json": json.dumps(
|
|
285
|
+
{"project": "e2e-test", "features": features},
|
|
286
|
+
indent=2,
|
|
287
|
+
)
|
|
288
|
+
+ "\n",
|
|
289
|
+
},
|
|
290
|
+
)
|
|
291
|
+
return paths, calls_file
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
def test_e2e_foreground_feature_run_commits_merges_and_completes_checkout(monkeypatch, tmp_path):
|
|
295
|
+
from prizmkit_runtime import runners
|
|
296
|
+
from prizmkit_runtime.task_checkout import load_task_checkout
|
|
297
|
+
|
|
298
|
+
paths, calls_file = _setup_e2e_repo(
|
|
299
|
+
tmp_path,
|
|
300
|
+
[_feature_entry("F-001", "Alpha Feature")],
|
|
301
|
+
{"F-001": "complete"},
|
|
302
|
+
)
|
|
303
|
+
monkeypatch.setenv("MAX_RETRIES", "1")
|
|
304
|
+
monkeypatch.setenv("STOP_ON_FAILURE", "1")
|
|
305
|
+
monkeypatch.setattr(runners.time, "sleep", lambda _: None)
|
|
306
|
+
|
|
307
|
+
result = runners.run_pipeline_command("feature", "run", (str(paths.feature_plan),), paths)
|
|
308
|
+
|
|
309
|
+
assert result.exit_code == 0, result.stderr or result.message
|
|
310
|
+
assert calls_file.read_text(encoding="utf-8").splitlines() == ["F-001"]
|
|
311
|
+
assert _git(paths.project_root, "rev-parse", "--abbrev-ref", "HEAD") == "main"
|
|
312
|
+
assert (paths.project_root / "src" / "001_alpha_feature.py").is_file()
|
|
313
|
+
log_subjects = _git(paths.project_root, "log", "-n", "5", "--format=%s")
|
|
314
|
+
assert "feat(F-001): implement 001-alpha-feature" in log_subjects
|
|
315
|
+
|
|
316
|
+
plan = json.loads(paths.feature_plan.read_text(encoding="utf-8"))
|
|
317
|
+
assert plan["features"][0]["status"] == "completed"
|
|
318
|
+
checkout = load_task_checkout(paths.feature_state_dir, "feature", "F-001")
|
|
319
|
+
assert checkout is not None
|
|
320
|
+
assert checkout.is_completed
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
def test_e2e_startup_commit_pending_recovery_completes_and_merges(monkeypatch, tmp_path):
|
|
324
|
+
from prizmkit_runtime import runners
|
|
325
|
+
from prizmkit_runtime.gitops import branch_save_wip
|
|
326
|
+
from prizmkit_runtime.task_checkout import TaskCheckout, load_task_checkout, persist_task_checkout
|
|
327
|
+
|
|
328
|
+
paths, calls_file = _setup_e2e_repo(
|
|
329
|
+
tmp_path,
|
|
330
|
+
[_feature_entry("F-001", "Recoverable Feature", status="in_progress")],
|
|
331
|
+
{"F-001": "fail_if_called"},
|
|
332
|
+
)
|
|
333
|
+
_git(paths.project_root, "checkout", "-b", "dev/F-001")
|
|
334
|
+
base_head = _git(paths.project_root, "rev-parse", "HEAD")
|
|
335
|
+
|
|
336
|
+
artifact_dir = paths.project_root / ".prizmkit" / "specs" / "001-recoverable-feature"
|
|
337
|
+
artifact_dir.mkdir(parents=True, exist_ok=True)
|
|
338
|
+
recovered_src = paths.project_root / "src" / "recovered.py"
|
|
339
|
+
recovered_src.parent.mkdir(parents=True, exist_ok=True)
|
|
340
|
+
recovered_src.write_text("RECOVERED = True\n", encoding="utf-8")
|
|
341
|
+
|
|
342
|
+
(artifact_dir / "test-report.md").write_text(
|
|
343
|
+
"# Test Report\n\n## Final Result\n\n- Result: TEST_PASS\n",
|
|
344
|
+
encoding="utf-8",
|
|
345
|
+
)
|
|
346
|
+
(artifact_dir / "test-result.json").write_text(
|
|
347
|
+
json.dumps(
|
|
348
|
+
{
|
|
349
|
+
"schema_version": 1,
|
|
350
|
+
"result": "TEST_PASS",
|
|
351
|
+
"report": "test-report.md",
|
|
352
|
+
"main_review_rounds": 1,
|
|
353
|
+
"independent_review": {
|
|
354
|
+
"status": "downgraded",
|
|
355
|
+
"responses": 0,
|
|
356
|
+
"downgrade_reason": "read-only continuation capability unavailable",
|
|
357
|
+
"final_state_rechecked": False,
|
|
358
|
+
},
|
|
359
|
+
"repair_rounds": 0,
|
|
360
|
+
"production_changed": False,
|
|
361
|
+
"unresolved_items": [],
|
|
362
|
+
},
|
|
363
|
+
indent=2,
|
|
364
|
+
)
|
|
365
|
+
+ "\n",
|
|
366
|
+
encoding="utf-8",
|
|
367
|
+
)
|
|
368
|
+
(artifact_dir / "completion-summary.json").write_text(
|
|
369
|
+
json.dumps({"status": "completed"}) + "\n",
|
|
370
|
+
encoding="utf-8",
|
|
371
|
+
)
|
|
372
|
+
request_rel = ".prizmkit/specs/001-recoverable-feature/runtime-commit-request.json"
|
|
373
|
+
(artifact_dir / "runtime-commit-request.json").write_text(
|
|
374
|
+
json.dumps(
|
|
375
|
+
{
|
|
376
|
+
"schema_version": 2,
|
|
377
|
+
"artifact_dir": ".prizmkit/specs/001-recoverable-feature",
|
|
378
|
+
"base_head": base_head,
|
|
379
|
+
"commit_message": "feat(F-001): recover pending commit",
|
|
380
|
+
},
|
|
381
|
+
indent=2,
|
|
382
|
+
)
|
|
383
|
+
+ "\n",
|
|
384
|
+
encoding="utf-8",
|
|
385
|
+
)
|
|
386
|
+
checkpoint_path = artifact_dir / "workflow-checkpoint.json"
|
|
387
|
+
checkpoint_path.write_text(
|
|
388
|
+
json.dumps(
|
|
389
|
+
{
|
|
390
|
+
"schema_version": 1,
|
|
391
|
+
"workflow_type": "feature-pipeline",
|
|
392
|
+
"item_id": "F-001",
|
|
393
|
+
"steps": [
|
|
394
|
+
{"id": "S01", "name": "Plan", "skill": "context-snapshot-and-plan", "status": "completed", "stage_result": "PLAN_READY"},
|
|
395
|
+
{"id": "S02", "name": "Implement", "skill": "prizmkit-implement", "status": "completed", "stage_result": "IMPLEMENTED"},
|
|
396
|
+
{"id": "S03", "name": "Code Review", "skill": "prizmkit-code-review", "status": "completed", "stage_result": "REVIEW_PASS"},
|
|
397
|
+
{
|
|
398
|
+
"id": "S04",
|
|
399
|
+
"name": "Test",
|
|
400
|
+
"skill": "prizmkit-test",
|
|
401
|
+
"status": "completed",
|
|
402
|
+
"stage_result": "TEST_PASS",
|
|
403
|
+
"required_artifacts": [
|
|
404
|
+
".prizmkit/specs/001-recoverable-feature/test-report.md",
|
|
405
|
+
".prizmkit/specs/001-recoverable-feature/test-result.json",
|
|
406
|
+
],
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
"id": "S05",
|
|
410
|
+
"name": "Completion Summary",
|
|
411
|
+
"skill": "completion-summary",
|
|
412
|
+
"status": "completed",
|
|
413
|
+
"required_artifacts": [
|
|
414
|
+
".prizmkit/specs/001-recoverable-feature/completion-summary.json",
|
|
415
|
+
],
|
|
416
|
+
},
|
|
417
|
+
{"id": "S06", "name": "Retrospective", "skill": "prizmkit-retrospective", "status": "completed", "stage_result": "RETRO_COMPLETE"},
|
|
418
|
+
{
|
|
419
|
+
"id": "S07",
|
|
420
|
+
"name": "Commit",
|
|
421
|
+
"skill": "prizmkit-committer",
|
|
422
|
+
"status": "in_progress",
|
|
423
|
+
"stage_result": "COMMIT_PENDING",
|
|
424
|
+
"required_artifacts": [request_rel],
|
|
425
|
+
},
|
|
426
|
+
],
|
|
427
|
+
"feature_state": {
|
|
428
|
+
"schema_version": 1,
|
|
429
|
+
"stage": "committer",
|
|
430
|
+
"status": "in_progress",
|
|
431
|
+
"stage_result": "COMMIT_PENDING",
|
|
432
|
+
"current_stage": "prizmkit-committer",
|
|
433
|
+
"next_stage": "prizmkit-committer",
|
|
434
|
+
"terminal_status": None,
|
|
435
|
+
},
|
|
436
|
+
},
|
|
437
|
+
indent=2,
|
|
438
|
+
)
|
|
439
|
+
+ "\n",
|
|
440
|
+
encoding="utf-8",
|
|
441
|
+
)
|
|
442
|
+
(paths.feature_state_dir / "F-001" / "sessions" / "sess-001").mkdir(parents=True, exist_ok=True)
|
|
443
|
+
assert branch_save_wip(paths.project_root, "dev/F-001").ok
|
|
444
|
+
_git(paths.project_root, "checkout", "main")
|
|
445
|
+
|
|
446
|
+
persist_task_checkout(
|
|
447
|
+
paths.feature_state_dir,
|
|
448
|
+
TaskCheckout.active("feature", "F-001", "dev/F-001", "main"),
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
monkeypatch.setenv("STOP_ON_FAILURE", "1")
|
|
452
|
+
monkeypatch.setattr(runners.time, "sleep", lambda _: None)
|
|
453
|
+
result = runners.run_pipeline_command("feature", "run", (str(paths.feature_plan),), paths)
|
|
454
|
+
|
|
455
|
+
assert result.exit_code == 0, result.stderr or result.message
|
|
456
|
+
assert not calls_file.exists()
|
|
457
|
+
assert _git(paths.project_root, "rev-parse", "--abbrev-ref", "HEAD") == "main"
|
|
458
|
+
assert (paths.project_root / "src" / "recovered.py").is_file()
|
|
459
|
+
log_subjects = _git(paths.project_root, "log", "-n", "5", "--format=%s")
|
|
460
|
+
assert "feat(F-001): recover pending commit" in log_subjects
|
|
461
|
+
|
|
462
|
+
plan = json.loads(paths.feature_plan.read_text(encoding="utf-8"))
|
|
463
|
+
assert plan["features"][0]["status"] == "completed"
|
|
464
|
+
checkout = load_task_checkout(paths.feature_state_dir, "feature", "F-001")
|
|
465
|
+
assert checkout is not None
|
|
466
|
+
assert checkout.is_completed
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
def test_e2e_workflow_blocked_fails_closed_without_merge_and_respects_stop_on_failure_zero(monkeypatch, tmp_path):
|
|
470
|
+
from prizmkit_runtime import runners
|
|
471
|
+
|
|
472
|
+
paths, calls_file = _setup_e2e_repo(
|
|
473
|
+
tmp_path,
|
|
474
|
+
[
|
|
475
|
+
_feature_entry("F-001", "Blocked Feature"),
|
|
476
|
+
_feature_entry("F-002", "Followup Feature"),
|
|
477
|
+
],
|
|
478
|
+
{"F-001": "blocked", "F-002": "complete"},
|
|
479
|
+
)
|
|
480
|
+
monkeypatch.setenv("MAX_RETRIES", "1")
|
|
481
|
+
monkeypatch.setenv("STOP_ON_FAILURE", "0")
|
|
482
|
+
monkeypatch.setattr(runners.time, "sleep", lambda _: None)
|
|
483
|
+
|
|
484
|
+
result = runners.run_pipeline_command("feature", "run", (str(paths.feature_plan),), paths)
|
|
485
|
+
|
|
486
|
+
assert result.exit_code == 1
|
|
487
|
+
assert "processed=2" in result.message
|
|
488
|
+
assert calls_file.read_text(encoding="utf-8").splitlines() == ["F-001", "F-002"]
|
|
489
|
+
assert _git(paths.project_root, "rev-parse", "--abbrev-ref", "HEAD") == "main"
|
|
490
|
+
assert not (paths.project_root / "src" / "partial.py").exists()
|
|
491
|
+
assert (paths.project_root / "src" / "002_followup_feature.py").is_file()
|
|
492
|
+
|
|
493
|
+
plan = json.loads(paths.feature_plan.read_text(encoding="utf-8"))
|
|
494
|
+
statuses = {entry["id"]: entry["status"] for entry in plan["features"]}
|
|
495
|
+
assert statuses["F-001"] == "failed"
|
|
496
|
+
assert statuses["F-002"] == "completed"
|
|
497
|
+
|
|
498
|
+
state_f1 = json.loads((paths.feature_state_dir / "F-001" / "status.json").read_text(encoding="utf-8"))
|
|
499
|
+
assert state_f1["terminal_status"] == "WORKFLOW_BLOCKED"
|
|
500
|
+
assert state_f1["needs_attention"] is True
|