prizmkit 1.1.190 → 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/bin/create-prizmkit.js +4 -4
- package/bundled/VERSION.json +3 -3
- package/bundled/adapters/antigravity/assets/prizmkit-hook.cjs +150 -0
- package/bundled/adapters/antigravity/hooks-adapter.js +195 -0
- package/bundled/adapters/antigravity/paths.js +14 -0
- package/bundled/adapters/antigravity/rules-adapter.js +54 -0
- package/bundled/adapters/antigravity/skill-adapter.js +38 -0
- 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 +21 -15
- 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 +29 -70
- package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +125 -67
- package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +89 -442
- 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 +49 -18
- 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 +282 -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 +369 -154
- package/bundled/dev-pipeline/prizmkit_runtime/status.py +3 -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 -2328
- 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 +10 -15
- 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/live_ai_cli_log_smoke.py +1 -0
- 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 +561 -3094
- 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 +490 -2006
- package/bundled/dev-pipeline/tests/test_utils.py +3 -3
- package/bundled/rules/USAGE.md +1 -0
- 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 +25 -128
- package/bundled/skills/prizmkit-init/assets/project-brief-template.md +3 -3
- package/bundled/skills/prizmkit-init/references/config-schema.md +2 -2
- 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/assets/prizm-docs-format.md +1 -1
- package/bundled/skills/prizmkit-prizm-docs/references/op-init.md +1 -1
- 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/ai-cli-launch.js +1 -1
- package/src/clean.js +40 -4
- package/src/config.js +64 -4
- package/src/detect-platform.js +10 -6
- package/src/external-skills.js +2 -2
- package/src/index.js +1 -0
- package/src/manifest.js +1 -1
- package/src/platforms.js +6 -2
- package/src/prompts.js +11 -3
- package/src/scaffold.js +87 -11
- package/src/upgrade.js +9 -3
- 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
|
@@ -4,19 +4,19 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import copy
|
|
6
6
|
import json
|
|
7
|
-
import os
|
|
8
7
|
import re
|
|
9
8
|
import subprocess
|
|
10
|
-
import tempfile
|
|
11
9
|
from dataclasses import dataclass
|
|
12
10
|
from pathlib import Path, PurePosixPath
|
|
13
11
|
from typing import Mapping
|
|
14
12
|
|
|
13
|
+
from .atomic_io import write_json_atomic
|
|
15
14
|
from .checkpoint_state import (
|
|
16
15
|
load_checkpoint_state,
|
|
17
16
|
semantic_state_key,
|
|
18
17
|
validate_checkpoint_data,
|
|
19
18
|
)
|
|
19
|
+
from .gitops import commit_args_without_signing, commit_identity_global_args
|
|
20
20
|
REQUEST_FILENAME = "runtime-commit-request.json"
|
|
21
21
|
REQUEST_SCHEMA_VERSION = 2
|
|
22
22
|
_HEX_COMMIT = re.compile(r"^[0-9a-fA-F]{40,64}$")
|
|
@@ -125,76 +125,21 @@ def finalize_runtime_commit(
|
|
|
125
125
|
return RuntimeCommitResult("failed", "premature_runtime_commit_hash")
|
|
126
126
|
if state.semantic_complete:
|
|
127
127
|
return RuntimeCommitResult("failed", "completed_checkpoint_without_commit")
|
|
128
|
-
|
|
129
|
-
if unmerged.return_code != 0:
|
|
130
|
-
return RuntimeCommitResult("failed", "git_unmerged_state_unavailable")
|
|
131
|
-
if unmerged.stdout.strip():
|
|
132
|
-
return RuntimeCommitResult("failed", "unresolved_merge_state")
|
|
133
|
-
changed, status_error = _workspace_changed_paths(
|
|
128
|
+
head, commit_failure = _stage_and_commit_workspace(
|
|
134
129
|
root,
|
|
135
130
|
checkpoint_path=checkpoint,
|
|
136
131
|
request_path=request_path,
|
|
132
|
+
commit_message=request.commit_message,
|
|
133
|
+
allow_empty_workspace=False,
|
|
137
134
|
)
|
|
138
|
-
if
|
|
139
|
-
return
|
|
140
|
-
if not
|
|
141
|
-
return RuntimeCommitResult("failed", "empty_workspace_change")
|
|
142
|
-
unsafe = next((path for path in changed if _sensitive_commit_path(path)), "")
|
|
143
|
-
if unsafe:
|
|
144
|
-
return RuntimeCommitResult("failed", "sensitive_workspace_path")
|
|
145
|
-
bookkeeping_staged = _staged_bookkeeping_paths(
|
|
146
|
-
root,
|
|
147
|
-
checkpoint_path=checkpoint,
|
|
148
|
-
request_path=request_path,
|
|
149
|
-
)
|
|
150
|
-
if bookkeeping_staged is None:
|
|
151
|
-
return RuntimeCommitResult("failed", "git_staged_set_unavailable")
|
|
152
|
-
if bookkeeping_staged:
|
|
153
|
-
return RuntimeCommitResult("failed", "runtime_bookkeeping_staged")
|
|
154
|
-
staged = _stage_workspace(
|
|
155
|
-
root,
|
|
156
|
-
checkpoint_path=checkpoint,
|
|
157
|
-
request_path=request_path,
|
|
158
|
-
)
|
|
159
|
-
if staged.return_code != 0:
|
|
160
|
-
return RuntimeCommitResult("failed", "git_stage_failed")
|
|
161
|
-
staged_paths = _git(
|
|
162
|
-
root, "diff", "--cached", "--name-only", "--no-renames", "-z",
|
|
163
|
-
)
|
|
164
|
-
if staged_paths.return_code != 0:
|
|
165
|
-
return RuntimeCommitResult("failed", "git_staged_set_unavailable")
|
|
166
|
-
staged_set = {path for path in staged_paths.stdout.split("\0") if path}
|
|
167
|
-
if staged_set != set(changed):
|
|
168
|
-
return RuntimeCommitResult("failed", "staged_workspace_mismatch")
|
|
169
|
-
if not staged_set:
|
|
170
|
-
return RuntimeCommitResult("failed", "empty_staged_change")
|
|
171
|
-
unstaged_candidates = _workspace_has_unstaged_candidates(
|
|
172
|
-
root,
|
|
173
|
-
checkpoint_path=checkpoint,
|
|
174
|
-
request_path=request_path,
|
|
175
|
-
)
|
|
176
|
-
if unstaged_candidates is None:
|
|
177
|
-
return RuntimeCommitResult("failed", "git_workspace_verification_failed")
|
|
178
|
-
if unstaged_candidates:
|
|
179
|
-
return RuntimeCommitResult("failed", "workspace_changed_during_staging")
|
|
180
|
-
committed = _git(
|
|
181
|
-
root,
|
|
182
|
-
"-c", "core.hooksPath=/dev/null",
|
|
183
|
-
"-c", "commit.gpgSign=false",
|
|
184
|
-
"commit", "-m", request.commit_message,
|
|
185
|
-
)
|
|
186
|
-
if committed.return_code != 0:
|
|
187
|
-
return RuntimeCommitResult("failed", "git_commit_failed")
|
|
188
|
-
head_result = _git(root, "rev-parse", "HEAD")
|
|
189
|
-
if head_result.return_code != 0:
|
|
190
|
-
return RuntimeCommitResult("failed", "commit_identity_unavailable")
|
|
191
|
-
head = head_result.stdout.strip()
|
|
192
|
-
if not _matches_prepared_commit(root, request, head):
|
|
135
|
+
if commit_failure is not None:
|
|
136
|
+
return commit_failure
|
|
137
|
+
if not _matches_prepared_commit(root, request, head, checkpoint_path=checkpoint):
|
|
193
138
|
return RuntimeCommitResult("failed", "git_commit_content_mismatch", head)
|
|
194
139
|
hash_error = _record_runtime_commit_hash(request_path, head)
|
|
195
140
|
if hash_error:
|
|
196
141
|
return RuntimeCommitResult("failed", hash_error, head)
|
|
197
|
-
elif _matches_prepared_commit(root, request, head):
|
|
142
|
+
elif _matches_prepared_commit(root, request, head, checkpoint_path=checkpoint):
|
|
198
143
|
if request.runtime_commit_hash and request.runtime_commit_hash.lower() != head.lower():
|
|
199
144
|
return RuntimeCommitResult("failed", "runtime_commit_hash_mismatch")
|
|
200
145
|
recovered = True
|
|
@@ -209,6 +154,7 @@ def finalize_runtime_commit(
|
|
|
209
154
|
checkpoint,
|
|
210
155
|
commit_hash=head,
|
|
211
156
|
base_head=request.base_head,
|
|
157
|
+
project_root=root,
|
|
212
158
|
)
|
|
213
159
|
if checkpoint_error:
|
|
214
160
|
return RuntimeCommitResult("failed", checkpoint_error, head, recovered)
|
|
@@ -355,61 +301,85 @@ def finalize_accepted_workspace_commit(
|
|
|
355
301
|
if head != resolved_base:
|
|
356
302
|
return RuntimeCommitResult("failed", "unexpected_existing_commit")
|
|
357
303
|
|
|
304
|
+
new_head, commit_failure = _stage_and_commit_workspace(
|
|
305
|
+
root,
|
|
306
|
+
checkpoint_path=checkpoint,
|
|
307
|
+
request_path=request_path,
|
|
308
|
+
commit_message=commit_message,
|
|
309
|
+
allow_empty_workspace=True,
|
|
310
|
+
empty_head=head,
|
|
311
|
+
expected_base_head=head,
|
|
312
|
+
)
|
|
313
|
+
if commit_failure is not None:
|
|
314
|
+
return commit_failure
|
|
315
|
+
return RuntimeCommitResult("committed", "accepted_workspace_committed", new_head)
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def _stage_and_commit_workspace(
|
|
319
|
+
root: Path,
|
|
320
|
+
*,
|
|
321
|
+
checkpoint_path: Path,
|
|
322
|
+
request_path: Path,
|
|
323
|
+
commit_message: str,
|
|
324
|
+
allow_empty_workspace: bool,
|
|
325
|
+
empty_head: str = "",
|
|
326
|
+
expected_base_head: str = "",
|
|
327
|
+
) -> tuple[str, RuntimeCommitResult | None]:
|
|
358
328
|
unmerged = _git(root, "ls-files", "-u")
|
|
359
329
|
if unmerged.return_code != 0:
|
|
360
|
-
return RuntimeCommitResult("failed", "git_unmerged_state_unavailable")
|
|
330
|
+
return "", RuntimeCommitResult("failed", "git_unmerged_state_unavailable")
|
|
361
331
|
if unmerged.stdout.strip():
|
|
362
|
-
return RuntimeCommitResult("failed", "unresolved_merge_state")
|
|
332
|
+
return "", RuntimeCommitResult("failed", "unresolved_merge_state")
|
|
363
333
|
|
|
364
334
|
changed, status_error = _workspace_changed_paths(
|
|
365
335
|
root,
|
|
366
|
-
checkpoint_path=
|
|
336
|
+
checkpoint_path=checkpoint_path,
|
|
367
337
|
request_path=request_path,
|
|
368
338
|
)
|
|
369
339
|
if status_error:
|
|
370
|
-
return RuntimeCommitResult("failed", status_error)
|
|
340
|
+
return "", RuntimeCommitResult("failed", status_error)
|
|
371
341
|
if any(_sensitive_commit_path(path) for path in changed):
|
|
372
|
-
return RuntimeCommitResult("failed", "sensitive_workspace_path")
|
|
342
|
+
return "", RuntimeCommitResult("failed", "sensitive_workspace_path")
|
|
373
343
|
bookkeeping_staged = _staged_bookkeeping_paths(
|
|
374
344
|
root,
|
|
375
|
-
checkpoint_path=
|
|
345
|
+
checkpoint_path=checkpoint_path,
|
|
376
346
|
request_path=request_path,
|
|
377
347
|
)
|
|
378
348
|
if bookkeeping_staged is None:
|
|
379
|
-
return RuntimeCommitResult("failed", "git_staged_set_unavailable")
|
|
349
|
+
return "", RuntimeCommitResult("failed", "git_staged_set_unavailable")
|
|
380
350
|
if bookkeeping_staged:
|
|
381
|
-
return RuntimeCommitResult("failed", "runtime_bookkeeping_staged")
|
|
351
|
+
return "", RuntimeCommitResult("failed", "runtime_bookkeeping_staged")
|
|
382
352
|
if not changed:
|
|
383
|
-
|
|
384
|
-
"not_needed",
|
|
385
|
-
|
|
386
|
-
head,
|
|
387
|
-
)
|
|
353
|
+
if allow_empty_workspace:
|
|
354
|
+
return "", RuntimeCommitResult("not_needed", "accepted_workspace_clean", empty_head)
|
|
355
|
+
return "", RuntimeCommitResult("failed", "empty_workspace_change")
|
|
388
356
|
|
|
389
357
|
staged = _stage_workspace(
|
|
390
358
|
root,
|
|
391
|
-
checkpoint_path=
|
|
359
|
+
checkpoint_path=checkpoint_path,
|
|
392
360
|
request_path=request_path,
|
|
393
361
|
)
|
|
394
362
|
if staged.return_code != 0:
|
|
395
|
-
return RuntimeCommitResult("failed", "git_stage_failed")
|
|
363
|
+
return "", RuntimeCommitResult("failed", "git_stage_failed")
|
|
396
364
|
staged_paths = _git(
|
|
397
365
|
root, "diff", "--cached", "--name-only", "--no-renames", "-z",
|
|
398
366
|
)
|
|
399
367
|
if staged_paths.return_code != 0:
|
|
400
|
-
return RuntimeCommitResult("failed", "git_staged_set_unavailable")
|
|
368
|
+
return "", RuntimeCommitResult("failed", "git_staged_set_unavailable")
|
|
401
369
|
staged_set = {path for path in staged_paths.stdout.split("\0") if path}
|
|
402
370
|
if staged_set != set(changed):
|
|
403
|
-
return RuntimeCommitResult("failed", "staged_workspace_mismatch")
|
|
371
|
+
return "", RuntimeCommitResult("failed", "staged_workspace_mismatch")
|
|
372
|
+
if not staged_set:
|
|
373
|
+
return "", RuntimeCommitResult("failed", "empty_staged_change")
|
|
404
374
|
unstaged_candidates = _workspace_has_unstaged_candidates(
|
|
405
375
|
root,
|
|
406
|
-
checkpoint_path=
|
|
376
|
+
checkpoint_path=checkpoint_path,
|
|
407
377
|
request_path=request_path,
|
|
408
378
|
)
|
|
409
379
|
if unstaged_candidates is None:
|
|
410
|
-
return RuntimeCommitResult("failed", "git_workspace_verification_failed")
|
|
380
|
+
return "", RuntimeCommitResult("failed", "git_workspace_verification_failed")
|
|
411
381
|
if unstaged_candidates:
|
|
412
|
-
return RuntimeCommitResult("failed", "workspace_changed_during_staging")
|
|
382
|
+
return "", RuntimeCommitResult("failed", "workspace_changed_during_staging")
|
|
413
383
|
|
|
414
384
|
committed = _git(
|
|
415
385
|
root,
|
|
@@ -418,26 +388,27 @@ def finalize_accepted_workspace_commit(
|
|
|
418
388
|
"commit", "-m", commit_message,
|
|
419
389
|
)
|
|
420
390
|
if committed.return_code != 0:
|
|
421
|
-
return RuntimeCommitResult("failed", "git_commit_failed")
|
|
391
|
+
return "", RuntimeCommitResult("failed", "git_commit_failed")
|
|
422
392
|
new_head_result = _git(root, "rev-parse", "HEAD")
|
|
423
393
|
if new_head_result.return_code != 0:
|
|
424
|
-
return RuntimeCommitResult("failed", "commit_identity_unavailable")
|
|
394
|
+
return "", RuntimeCommitResult("failed", "commit_identity_unavailable")
|
|
425
395
|
new_head = new_head_result.stdout.strip()
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
396
|
+
if expected_base_head:
|
|
397
|
+
parents = _git(root, "show", "-s", "--format=%P", new_head)
|
|
398
|
+
subject = _git(root, "show", "-s", "--format=%s", new_head)
|
|
399
|
+
committed_paths = _git(
|
|
400
|
+
root,
|
|
401
|
+
"diff-tree", "--no-commit-id", "--name-only", "--no-renames", "-r", "-z", new_head,
|
|
402
|
+
)
|
|
403
|
+
if any(result.return_code != 0 for result in (parents, subject, committed_paths)):
|
|
404
|
+
return "", RuntimeCommitResult("failed", "git_commit_content_mismatch", new_head)
|
|
405
|
+
if not (
|
|
406
|
+
parents.stdout.strip().split() == [expected_base_head]
|
|
407
|
+
and subject.stdout.strip() == commit_message
|
|
408
|
+
and {path for path in committed_paths.stdout.split("\0") if path} == staged_set
|
|
409
|
+
):
|
|
410
|
+
return "", RuntimeCommitResult("failed", "git_commit_content_mismatch", new_head)
|
|
411
|
+
return new_head, None
|
|
441
412
|
|
|
442
413
|
|
|
443
414
|
def _load_request(
|
|
@@ -637,7 +608,13 @@ def _workspace_has_unstaged_candidates(
|
|
|
637
608
|
return bool(candidates)
|
|
638
609
|
|
|
639
610
|
|
|
640
|
-
def _matches_prepared_commit(
|
|
611
|
+
def _matches_prepared_commit(
|
|
612
|
+
project_root: Path,
|
|
613
|
+
request: RuntimeCommitRequest,
|
|
614
|
+
head: str,
|
|
615
|
+
*,
|
|
616
|
+
checkpoint_path: Path | None = None,
|
|
617
|
+
) -> bool:
|
|
641
618
|
parents = _git(project_root, "show", "-s", "--format=%P", head)
|
|
642
619
|
subject = _git(project_root, "show", "-s", "--format=%s", head)
|
|
643
620
|
paths = _git(
|
|
@@ -653,13 +630,28 @@ def _matches_prepared_commit(project_root: Path, request: RuntimeCommitRequest,
|
|
|
653
630
|
artifact_prefix + REQUEST_FILENAME,
|
|
654
631
|
artifact_prefix + "workflow-checkpoint.json",
|
|
655
632
|
}
|
|
656
|
-
|
|
633
|
+
if not (
|
|
657
634
|
len(parent_list) == 1
|
|
658
635
|
and parent_list[0].lower() == request.base_head.lower()
|
|
659
636
|
and subject.stdout.strip() == request.commit_message
|
|
660
637
|
and bool(changed)
|
|
661
638
|
and changed.isdisjoint(causal_bookkeeping)
|
|
662
|
-
|
|
639
|
+
and not any(_sensitive_commit_path(path) for path in changed)
|
|
640
|
+
):
|
|
641
|
+
return False
|
|
642
|
+
if checkpoint_path is not None:
|
|
643
|
+
unmerged = _git(project_root, "ls-files", "-u")
|
|
644
|
+
if unmerged.return_code != 0 or unmerged.stdout.strip():
|
|
645
|
+
return False
|
|
646
|
+
request_path = checkpoint_path.parent / REQUEST_FILENAME
|
|
647
|
+
unstaged = _workspace_has_unstaged_candidates(
|
|
648
|
+
project_root,
|
|
649
|
+
checkpoint_path=checkpoint_path,
|
|
650
|
+
request_path=request_path,
|
|
651
|
+
)
|
|
652
|
+
if unstaged is not False:
|
|
653
|
+
return False
|
|
654
|
+
return True
|
|
663
655
|
|
|
664
656
|
|
|
665
657
|
def _record_runtime_commit_hash(path: Path, commit_hash: str) -> str:
|
|
@@ -679,13 +671,24 @@ def _finalize_checkpoint(
|
|
|
679
671
|
*,
|
|
680
672
|
commit_hash: str,
|
|
681
673
|
base_head: str,
|
|
674
|
+
project_root: Path | None = None,
|
|
682
675
|
) -> str:
|
|
683
676
|
"""Finalize COMMITTED and persist the Runtime's verified commit receipt."""
|
|
684
|
-
state = load_checkpoint_state(path)
|
|
677
|
+
state = load_checkpoint_state(path, project_root=project_root)
|
|
685
678
|
if not state.valid:
|
|
686
679
|
return "checkpoint_commit_finalization_rejected"
|
|
687
680
|
if state.semantic_complete:
|
|
688
|
-
|
|
681
|
+
raw_semantic = (
|
|
682
|
+
state.raw_data.get(semantic_state_key(state.semantic.workflow_type), {})
|
|
683
|
+
if isinstance(state.raw_data, Mapping)
|
|
684
|
+
else {}
|
|
685
|
+
)
|
|
686
|
+
if isinstance(raw_semantic, Mapping):
|
|
687
|
+
existing_hash = str(raw_semantic.get("runtime_commit_hash") or "").strip().lower()
|
|
688
|
+
existing_base = str(raw_semantic.get("runtime_base_head") or "").strip().lower()
|
|
689
|
+
if existing_hash == commit_hash.lower() and existing_base == base_head.lower():
|
|
690
|
+
return ""
|
|
691
|
+
return "checkpoint_commit_receipt_mismatch"
|
|
689
692
|
if not state.semantic_commit_ready:
|
|
690
693
|
return "checkpoint_commit_finalization_rejected"
|
|
691
694
|
data = dict(state.raw_data)
|
|
@@ -722,41 +725,40 @@ def _finalize_checkpoint(
|
|
|
722
725
|
"runtime_commit_hash": commit_hash,
|
|
723
726
|
}
|
|
724
727
|
)
|
|
725
|
-
candidate = validate_checkpoint_data(
|
|
728
|
+
candidate = validate_checkpoint_data(
|
|
729
|
+
data, path=path, exists=True, project_root=project_root
|
|
730
|
+
)
|
|
726
731
|
if not candidate.valid or not candidate.semantic_complete:
|
|
727
732
|
return "checkpoint_commit_finalization_rejected"
|
|
728
733
|
if _write_json_atomic(path, data):
|
|
729
734
|
return "checkpoint_commit_finalization_failed"
|
|
730
|
-
finalized = load_checkpoint_state(path)
|
|
735
|
+
finalized = load_checkpoint_state(path, project_root=project_root)
|
|
731
736
|
return "" if finalized.semantic_complete else "checkpoint_commit_finalization_rejected"
|
|
732
737
|
|
|
733
738
|
|
|
734
739
|
def _write_json_atomic(path: Path, data: Mapping[str, object]) -> str:
|
|
735
|
-
temp_path: str | None = None
|
|
736
740
|
try:
|
|
737
|
-
path
|
|
738
|
-
fd, temp_path = tempfile.mkstemp(prefix=f".{path.name}.", suffix=".tmp", dir=path.parent)
|
|
739
|
-
with os.fdopen(fd, "w", encoding="utf-8") as handle:
|
|
740
|
-
json.dump(data, handle, indent=2, ensure_ascii=False)
|
|
741
|
-
handle.write("\n")
|
|
742
|
-
os.replace(temp_path, path)
|
|
741
|
+
write_json_atomic(path, data)
|
|
743
742
|
except OSError:
|
|
744
|
-
if temp_path:
|
|
745
|
-
try:
|
|
746
|
-
os.unlink(temp_path)
|
|
747
|
-
except OSError:
|
|
748
|
-
pass
|
|
749
743
|
return "atomic_json_write_failed"
|
|
750
744
|
return ""
|
|
751
745
|
|
|
752
746
|
|
|
753
747
|
def _git(project_root: Path, *args: str) -> _GitResult:
|
|
748
|
+
command_args = [str(arg) for arg in args]
|
|
749
|
+
global_args: tuple[str, ...] = ()
|
|
750
|
+
if "commit" in command_args:
|
|
751
|
+
commit_idx = command_args.index("commit")
|
|
752
|
+
global_args = commit_identity_global_args(project_root)
|
|
753
|
+
tail = commit_args_without_signing(tuple(command_args[commit_idx:]))
|
|
754
|
+
command_args = [*command_args[:commit_idx], *tail]
|
|
754
755
|
completed = subprocess.run(
|
|
755
|
-
["git", *
|
|
756
|
-
cwd=project_root,
|
|
756
|
+
["git", *global_args, "-C", str(project_root), *command_args],
|
|
757
757
|
stdout=subprocess.PIPE,
|
|
758
758
|
stderr=subprocess.PIPE,
|
|
759
759
|
text=True,
|
|
760
|
+
encoding="utf-8",
|
|
761
|
+
errors="replace",
|
|
760
762
|
check=False,
|
|
761
763
|
)
|
|
762
764
|
return _GitResult(completed.returncode, completed.stdout, completed.stderr)
|
|
@@ -54,12 +54,28 @@ SOURCE_EXTENSIONS = (
|
|
|
54
54
|
|
|
55
55
|
DEFAULT_EXCLUDES = (
|
|
56
56
|
".git",
|
|
57
|
+
".prizmkit",
|
|
58
|
+
".claude",
|
|
59
|
+
".codebuddy",
|
|
60
|
+
".agents",
|
|
61
|
+
".agent",
|
|
62
|
+
".codex",
|
|
63
|
+
".cursor",
|
|
64
|
+
".pi",
|
|
57
65
|
"node_modules",
|
|
58
66
|
"__pycache__",
|
|
59
67
|
".pytest_cache",
|
|
60
68
|
".mypy_cache",
|
|
69
|
+
".venv",
|
|
70
|
+
"venv",
|
|
61
71
|
"dist",
|
|
62
72
|
"build",
|
|
73
|
+
"target",
|
|
74
|
+
"coverage",
|
|
75
|
+
".next",
|
|
76
|
+
".nuxt",
|
|
77
|
+
".turbo",
|
|
78
|
+
".svelte-kit",
|
|
63
79
|
"vendor",
|
|
64
80
|
)
|
|
65
81
|
|
|
@@ -247,13 +263,30 @@ def _text_final_verdict(args: argparse.Namespace) -> HelperResult:
|
|
|
247
263
|
return HelperResult("REVIEW_INCOMPLETE", False, {"path": str(target), "reason": "final_result_missing"}, 1)
|
|
248
264
|
|
|
249
265
|
verdict = ""
|
|
266
|
+
accepted: int | None = None
|
|
267
|
+
fixed: int | None = None
|
|
268
|
+
unresolved: int | None = None
|
|
250
269
|
for line in lines[final_indexes[-1] + 1:]:
|
|
251
270
|
stripped = line.strip()
|
|
252
271
|
if stripped.startswith("## "):
|
|
253
272
|
break
|
|
254
|
-
if stripped.startswith("- Verdict:"):
|
|
273
|
+
if stripped.startswith("- Verdict:") and not verdict:
|
|
255
274
|
verdict = stripped[len("- Verdict:"):].strip()
|
|
256
|
-
|
|
275
|
+
elif stripped.startswith("- Accepted Findings:"):
|
|
276
|
+
try:
|
|
277
|
+
accepted = int(stripped[len("- Accepted Findings:"):].strip())
|
|
278
|
+
except ValueError:
|
|
279
|
+
pass
|
|
280
|
+
elif stripped.startswith("- Fixed Findings:"):
|
|
281
|
+
try:
|
|
282
|
+
fixed = int(stripped[len("- Fixed Findings:"):].strip())
|
|
283
|
+
except ValueError:
|
|
284
|
+
pass
|
|
285
|
+
elif stripped.startswith("- Unresolved Findings:"):
|
|
286
|
+
try:
|
|
287
|
+
unresolved = int(stripped[len("- Unresolved Findings:"):].strip())
|
|
288
|
+
except ValueError:
|
|
289
|
+
pass
|
|
257
290
|
|
|
258
291
|
markers = {
|
|
259
292
|
"PASS": "REVIEW_PASS",
|
|
@@ -262,6 +295,35 @@ def _text_final_verdict(args: argparse.Namespace) -> HelperResult:
|
|
|
262
295
|
marker = markers.get(verdict)
|
|
263
296
|
if not marker:
|
|
264
297
|
return HelperResult("REVIEW_INVALID", False, {"path": str(target), "verdict": verdict or None}, 1)
|
|
298
|
+
|
|
299
|
+
if verdict == "PASS":
|
|
300
|
+
verification_indexes = [
|
|
301
|
+
index
|
|
302
|
+
for index, line in enumerate(lines[: final_indexes[-1]])
|
|
303
|
+
if line.strip() == "## Final Verification"
|
|
304
|
+
]
|
|
305
|
+
if verification_indexes:
|
|
306
|
+
for line in lines[verification_indexes[-1] + 1 : final_indexes[-1]]:
|
|
307
|
+
stripped = line.strip()
|
|
308
|
+
if stripped.startswith("## "):
|
|
309
|
+
break
|
|
310
|
+
if stripped == "- Status: FAILED":
|
|
311
|
+
return HelperResult(
|
|
312
|
+
"REVIEW_INVALID",
|
|
313
|
+
False,
|
|
314
|
+
{"path": str(target), "verdict": verdict, "reason": "final_verification_failed"},
|
|
315
|
+
1,
|
|
316
|
+
)
|
|
317
|
+
if (unresolved is not None and unresolved > 0) or (
|
|
318
|
+
accepted is not None and fixed is not None and fixed != accepted
|
|
319
|
+
):
|
|
320
|
+
return HelperResult(
|
|
321
|
+
"REVIEW_INVALID",
|
|
322
|
+
False,
|
|
323
|
+
{"path": str(target), "verdict": verdict, "reason": "unfixed_or_unresolved_findings"},
|
|
324
|
+
1,
|
|
325
|
+
)
|
|
326
|
+
|
|
265
327
|
return HelperResult(marker, True, {"path": str(target), "verdict": verdict})
|
|
266
328
|
|
|
267
329
|
|
|
@@ -343,9 +405,20 @@ def _process_start(args: argparse.Namespace) -> HelperResult:
|
|
|
343
405
|
if not command:
|
|
344
406
|
return HelperResult("PROCESS_START_FAILED", False, {"reason": "missing_command"}, 2)
|
|
345
407
|
cwd = _path(args.cwd or ".")
|
|
346
|
-
|
|
347
|
-
|
|
408
|
+
opened_handles = []
|
|
409
|
+
stdout_target = subprocess.DEVNULL
|
|
410
|
+
stderr_target = subprocess.DEVNULL
|
|
348
411
|
try:
|
|
412
|
+
if args.stdout:
|
|
413
|
+
stdout_path = _path(args.stdout)
|
|
414
|
+
stdout_path.parent.mkdir(parents=True, exist_ok=True)
|
|
415
|
+
stdout_target = open(stdout_path, "a", encoding="utf-8")
|
|
416
|
+
opened_handles.append(stdout_target)
|
|
417
|
+
if args.stderr:
|
|
418
|
+
stderr_path = _path(args.stderr)
|
|
419
|
+
stderr_path.parent.mkdir(parents=True, exist_ok=True)
|
|
420
|
+
stderr_target = open(stderr_path, "a", encoding="utf-8")
|
|
421
|
+
opened_handles.append(stderr_target)
|
|
349
422
|
process = subprocess.Popen(
|
|
350
423
|
[str(part) for part in command],
|
|
351
424
|
cwd=cwd,
|
|
@@ -358,9 +431,11 @@ def _process_start(args: argparse.Namespace) -> HelperResult:
|
|
|
358
431
|
except OSError as exc:
|
|
359
432
|
return HelperResult("PROCESS_START_FAILED", False, {"reason": type(exc).__name__, "error": str(exc)}, 1)
|
|
360
433
|
finally:
|
|
361
|
-
for target in
|
|
362
|
-
|
|
434
|
+
for target in opened_handles:
|
|
435
|
+
try:
|
|
363
436
|
target.close()
|
|
437
|
+
except OSError:
|
|
438
|
+
pass
|
|
364
439
|
if args.pid_file:
|
|
365
440
|
pid_file = _path(args.pid_file)
|
|
366
441
|
pid_file.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -368,6 +443,12 @@ def _process_start(args: argparse.Namespace) -> HelperResult:
|
|
|
368
443
|
return HelperResult("PROCESS_STARTED", True, {"pid": process.pid, "pid_file": str(_path(args.pid_file)) if args.pid_file else None})
|
|
369
444
|
|
|
370
445
|
|
|
446
|
+
def _status_is_ready(status: int, expected_statuses: list[int] | None) -> bool:
|
|
447
|
+
if expected_statuses:
|
|
448
|
+
return status in expected_statuses
|
|
449
|
+
return status < 500
|
|
450
|
+
|
|
451
|
+
|
|
371
452
|
def _web_wait_ready(args: argparse.Namespace) -> HelperResult:
|
|
372
453
|
deadline = time.monotonic() + float(args.timeout)
|
|
373
454
|
statuses: list[str] = []
|
|
@@ -377,11 +458,11 @@ def _web_wait_ready(args: argparse.Namespace) -> HelperResult:
|
|
|
377
458
|
with urllib.request.urlopen(request, timeout=float(args.request_timeout)) as response:
|
|
378
459
|
status = int(response.status)
|
|
379
460
|
statuses.append(str(status))
|
|
380
|
-
if status
|
|
461
|
+
if _status_is_ready(status, args.status):
|
|
381
462
|
return HelperResult("READY", True, {"url": args.url, "status": status})
|
|
382
463
|
except urllib.error.HTTPError as exc:
|
|
383
464
|
statuses.append(str(exc.code))
|
|
384
|
-
if int(exc.code)
|
|
465
|
+
if _status_is_ready(int(exc.code), args.status):
|
|
385
466
|
return HelperResult("READY", True, {"url": args.url, "status": int(exc.code)})
|
|
386
467
|
except (OSError, urllib.error.URLError, TimeoutError) as exc:
|
|
387
468
|
statuses.append(type(exc).__name__)
|
|
@@ -519,7 +600,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
519
600
|
wait_ready.add_argument("--timeout", type=float, default=30.0)
|
|
520
601
|
wait_ready.add_argument("--interval", type=float, default=2.0)
|
|
521
602
|
wait_ready.add_argument("--request-timeout", type=float, default=2.0)
|
|
522
|
-
wait_ready.add_argument("--status", action="append", type=int, default=
|
|
603
|
+
wait_ready.add_argument("--status", action="append", type=int, default=None)
|
|
523
604
|
_add_json(wait_ready)
|
|
524
605
|
wait_ready.set_defaults(func=_web_wait_ready)
|
|
525
606
|
|