prizmkit 1.1.191 → 1.1.193

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/bundled/VERSION.json +3 -3
  2. package/bundled/adapters/antigravity/skill-adapter.js +13 -4
  3. package/bundled/adapters/codex/skill-adapter.js +28 -8
  4. package/bundled/adapters/cursor/skill-adapter.js +13 -4
  5. package/bundled/adapters/pi/skill-adapter.js +28 -7
  6. package/bundled/dev-pipeline/.env.example +4 -12
  7. package/bundled/dev-pipeline/README.md +28 -44
  8. package/bundled/dev-pipeline/assets/feature-list-example.json +0 -1
  9. package/bundled/dev-pipeline/assets/skill-subagent-integration.md +6 -6
  10. package/bundled/dev-pipeline/prizmkit_runtime/atomic_io.py +48 -0
  11. package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +66 -23
  12. package/bundled/dev-pipeline/prizmkit_runtime/cli.py +10 -7
  13. package/bundled/dev-pipeline/prizmkit_runtime/commands.py +2 -21
  14. package/bundled/dev-pipeline/prizmkit_runtime/config.py +48 -78
  15. package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +127 -67
  16. package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +158 -462
  17. package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +102 -50
  18. package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +1 -25
  19. package/bundled/dev-pipeline/prizmkit_runtime/paths.py +0 -6
  20. package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +47 -21
  21. package/bundled/dev-pipeline/prizmkit_runtime/processes.py +217 -156
  22. package/bundled/dev-pipeline/prizmkit_runtime/reset.py +39 -27
  23. package/bundled/dev-pipeline/prizmkit_runtime/reset_preserve.py +34 -174
  24. package/bundled/dev-pipeline/prizmkit_runtime/results.py +25 -0
  25. package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +133 -110
  26. package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +15 -5
  27. package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +1 -95
  28. package/bundled/dev-pipeline/prizmkit_runtime/runner_prompts.py +0 -2
  29. package/bundled/dev-pipeline/prizmkit_runtime/runner_status.py +7 -2
  30. package/bundled/dev-pipeline/prizmkit_runtime/runners.py +540 -262
  31. package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +175 -135
  32. package/bundled/dev-pipeline/prizmkit_runtime/runtime_helper.py +90 -9
  33. package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +214 -133
  34. package/bundled/dev-pipeline/prizmkit_runtime/status.py +1 -3
  35. package/bundled/dev-pipeline/prizmkit_runtime/stream_progress.py +2783 -0
  36. package/bundled/dev-pipeline/prizmkit_runtime/task_checkout.py +27 -102
  37. package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +58 -4
  38. package/bundled/dev-pipeline/scripts/check-session-status.py +56 -20
  39. package/bundled/dev-pipeline/scripts/continuation.py +8 -7
  40. package/bundled/dev-pipeline/scripts/detect-stuck.py +47 -33
  41. package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +13 -16
  42. package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +20 -10
  43. package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +10 -7
  44. package/bundled/dev-pipeline/scripts/init-change-artifact.py +25 -4
  45. package/bundled/dev-pipeline/scripts/init-pipeline.py +14 -69
  46. package/bundled/dev-pipeline/scripts/parse-stream-progress.py +31 -2616
  47. package/bundled/dev-pipeline/scripts/patch-completion-notes.py +4 -24
  48. package/bundled/dev-pipeline/scripts/prompt_framework.py +85 -20
  49. package/bundled/dev-pipeline/scripts/status_common.py +591 -0
  50. package/bundled/dev-pipeline/scripts/update-bug-status.py +85 -463
  51. package/bundled/dev-pipeline/scripts/update-checkpoint.py +254 -65
  52. package/bundled/dev-pipeline/scripts/update-feature-status.py +76 -509
  53. package/bundled/dev-pipeline/scripts/utils.py +5 -12
  54. package/bundled/dev-pipeline/templates/bootstrap-tier3.md +5 -5
  55. package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +7 -0
  56. package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +7 -7
  57. package/bundled/dev-pipeline/templates/sections/artifact-manifest.md +1 -1
  58. package/bundled/dev-pipeline/templates/sections/bugfix-phase-manual-verification.md +1 -1
  59. package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +1 -1
  60. package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +2 -1
  61. package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +1 -1
  62. package/bundled/dev-pipeline/templates/sections/phase-browser-verification-auto.md +1 -1
  63. package/bundled/dev-pipeline/templates/sections/phase-browser-verification-opencli.md +2 -2
  64. package/bundled/dev-pipeline/templates/sections/phase-browser-verification.md +2 -2
  65. package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +2 -1
  66. package/bundled/dev-pipeline/templates/sections/phase-review-full.md +1 -1
  67. package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +3 -6
  68. package/bundled/dev-pipeline/templates/session-status-schema.json +2 -5
  69. package/bundled/skills/_metadata.json +9 -63
  70. package/bundled/skills/app-planner/SKILL.md +32 -303
  71. package/bundled/skills/app-planner/references/app-design-guide.md +0 -4
  72. package/bundled/skills/app-planner/references/generated-plan-review.md +2 -1
  73. package/bundled/skills/app-planner/references/project-brief-guide.md +14 -0
  74. package/bundled/skills/app-planner/references/project-conventions-discovery.md +4 -6
  75. package/bundled/skills/app-planner/references/project-state-detection.md +2 -3
  76. package/bundled/skills/bug-fix-workflow/SKILL.md +1 -2
  77. package/bundled/skills/bug-fix-workflow/references/bug-diagnosis.md +4 -7
  78. package/bundled/skills/bug-planner/SKILL.md +54 -435
  79. package/bundled/skills/bug-planner/references/generated-plan-review.md +3 -2
  80. package/bundled/skills/bug-planner/references/input-formats.md +32 -0
  81. package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +4 -6
  82. package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +4 -28
  83. package/bundled/skills/feature-pipeline-launcher/SKILL.md +4 -6
  84. package/bundled/skills/feature-pipeline-launcher/references/configuration.md +4 -28
  85. package/bundled/skills/feature-planner/SKILL.md +60 -439
  86. package/bundled/skills/feature-planner/assets/planning-guide.md +1 -1
  87. package/bundled/skills/feature-planner/references/completeness-review.md +34 -0
  88. package/bundled/skills/feature-planner/references/decomposition-patterns.md +2 -2
  89. package/bundled/skills/feature-planner/references/error-recovery.md +1 -1
  90. package/bundled/skills/feature-planner/references/generated-plan-review.md +3 -2
  91. package/bundled/skills/feature-planner/references/incremental-feature-planning.md +3 -1
  92. package/bundled/skills/feature-workflow/SKILL.md +1 -2
  93. package/bundled/skills/prizmkit/SKILL.md +7 -1
  94. package/bundled/skills/prizmkit-code-review/SKILL.md +14 -6
  95. package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +7 -4
  96. package/bundled/skills/prizmkit-code-review/references/review-report-template.md +16 -0
  97. package/bundled/skills/prizmkit-code-review/scripts/render_review_report.py +58 -20
  98. package/bundled/skills/prizmkit-implement/SKILL.md +1 -1
  99. package/bundled/skills/prizmkit-init/SKILL.md +24 -127
  100. package/bundled/skills/prizmkit-init/assets/project-brief-template.md +3 -3
  101. package/bundled/skills/prizmkit-plan/SKILL.md +6 -8
  102. package/bundled/skills/prizmkit-plan/references/clarify-guide.md +1 -1
  103. package/bundled/skills/prizmkit-plan/references/independent-plan-review.md +5 -2
  104. package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +6 -5
  105. package/bundled/skills/prizmkit-prizm-docs/SKILL.md +1 -13
  106. package/bundled/skills/prizmkit-prizm-docs/references/op-update.md +1 -1
  107. package/bundled/skills/prizmkit-retrospective/SKILL.md +6 -4
  108. package/bundled/skills/prizmkit-test/SKILL.md +25 -133
  109. package/bundled/skills/prizmkit-test/references/independent-test-review.md +5 -2
  110. package/bundled/skills/prizmkit-test/references/test-coverage-model.md +6 -0
  111. package/bundled/skills/prizmkit-workflow/SKILL.md +2 -3
  112. package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +4 -3
  113. package/bundled/skills/recovery-workflow/SKILL.md +7 -7
  114. package/bundled/skills/recovery-workflow/evals/evals.json +1 -1
  115. package/bundled/skills/recovery-workflow/references/detection.md +1 -3
  116. package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +0 -6
  117. package/bundled/templates/project-memory-template.md +1 -2
  118. package/package.json +1 -1
  119. package/src/scaffold.js +28 -7
  120. package/bundled/dev-pipeline/SCHEMA_ANALYSIS.md +0 -53
  121. package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +0 -649
  122. package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +0 -463
  123. package/bundled/dev-pipeline/scripts/update-refactor-status.py +0 -1512
  124. package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +0 -240
  125. package/bundled/dev-pipeline/templates/refactor-list-schema.json +0 -266
  126. package/bundled/dev-pipeline/templates/sections/refactor-critical-paths.md +0 -15
  127. package/bundled/dev-pipeline/templates/sections/refactor-mission.md +0 -9
  128. package/bundled/dev-pipeline/templates/sections/refactor-phase-commit-report.md +0 -24
  129. package/bundled/dev-pipeline/templates/sections/refactor-phase-implement.md +0 -16
  130. package/bundled/dev-pipeline/templates/sections/refactor-phase-init.md +0 -9
  131. package/bundled/dev-pipeline/templates/sections/refactor-phase-plan.md +0 -22
  132. package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +0 -19
  133. package/bundled/dev-pipeline/templates/sections/refactor-phase-test.md +0 -24
  134. package/bundled/dev-pipeline/templates/sections/refactor-reminders.md +0 -12
  135. package/bundled/dev-pipeline/templates/sections/refactor-session-context.md +0 -6
  136. package/bundled/dev-pipeline/templates/sections/refactor-task-contract.md +0 -52
  137. package/bundled/dev-pipeline/tests/conftest.py +0 -29
  138. package/bundled/dev-pipeline/tests/live_ai_cli_log_smoke.py +0 -208
  139. package/bundled/dev-pipeline/tests/test_auto_skip.py +0 -1871
  140. package/bundled/dev-pipeline/tests/test_checkpoint_state.py +0 -1314
  141. package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +0 -1712
  142. package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +0 -627
  143. package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +0 -478
  144. package/bundled/dev-pipeline/tests/test_python_runner_parity.py +0 -5641
  145. package/bundled/dev-pipeline/tests/test_recovery_workflow.py +0 -322
  146. package/bundled/dev-pipeline/tests/test_repository_bootstrap.py +0 -252
  147. package/bundled/dev-pipeline/tests/test_reset_modes.py +0 -1208
  148. package/bundled/dev-pipeline/tests/test_reset_preserve.py +0 -957
  149. package/bundled/dev-pipeline/tests/test_runtime_commit.py +0 -1113
  150. package/bundled/dev-pipeline/tests/test_runtime_helper.py +0 -303
  151. package/bundled/dev-pipeline/tests/test_unified_cli.py +0 -5504
  152. package/bundled/dev-pipeline/tests/test_utils.py +0 -170
  153. package/bundled/skills/feature-planner/assets/evaluation-guide.md +0 -44
  154. package/bundled/skills/refactor-pipeline-launcher/SKILL.md +0 -219
  155. package/bundled/skills/refactor-pipeline-launcher/references/configuration.md +0 -78
  156. package/bundled/skills/refactor-planner/SKILL.md +0 -467
  157. package/bundled/skills/refactor-planner/assets/planning-guide.md +0 -291
  158. package/bundled/skills/refactor-planner/references/behavior-preservation.md +0 -187
  159. package/bundled/skills/refactor-planner/references/error-recovery.md +0 -45
  160. package/bundled/skills/refactor-planner/references/fast-path.md +0 -59
  161. package/bundled/skills/refactor-planner/references/generated-plan-review.md +0 -107
  162. package/bundled/skills/refactor-planner/references/planning-phases.md +0 -172
  163. package/bundled/skills/refactor-planner/references/refactor-scoping-guide.md +0 -230
  164. package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +0 -1120
  165. package/bundled/skills/refactor-workflow/SKILL.md +0 -205
@@ -1,322 +0,0 @@
1
- """Behavior tests for the canonical detector-only Recovery Workflow."""
2
-
3
- from __future__ import annotations
4
-
5
- import importlib.util
6
- import json
7
- import subprocess
8
- import sys
9
- from pathlib import Path
10
-
11
-
12
- REPO_ROOT = Path(__file__).resolve().parents[2]
13
- DETECTOR_PATH = (
14
- REPO_ROOT
15
- / "core"
16
- / "skills"
17
- / "orchestration-skill"
18
- / "workflows"
19
- / "recovery-workflow"
20
- / "scripts"
21
- / "detect-recovery-state.py"
22
- )
23
- STATE_DIRS = {
24
- "feature": "features",
25
- "bugfix": "bugfix",
26
- "refactor": "refactor",
27
- }
28
-
29
-
30
- def _load_detector(name: str):
31
- spec = importlib.util.spec_from_file_location(name, DETECTOR_PATH)
32
- assert spec is not None and spec.loader is not None
33
- module = importlib.util.module_from_spec(spec)
34
- spec.loader.exec_module(module)
35
- return module
36
-
37
-
38
- def _git(project: Path, *args: str) -> str:
39
- result = subprocess.run(
40
- ["git", *args],
41
- cwd=project,
42
- check=True,
43
- text=True,
44
- stdout=subprocess.PIPE,
45
- stderr=subprocess.PIPE,
46
- )
47
- return result.stdout.strip()
48
-
49
-
50
- def _init_repository(project: Path) -> None:
51
- project.mkdir()
52
- _git(project, "init", "-b", "main")
53
- _git(project, "config", "user.email", "detector@example.com")
54
- _git(project, "config", "user.name", "Detector Test")
55
- (project / "README.md").write_text("detector fixture\n", encoding="utf-8")
56
- _git(project, "add", "README.md")
57
- _git(project, "commit", "-m", "fixture")
58
-
59
-
60
- def _write_checkout(
61
- project: Path,
62
- family: str,
63
- task_id: str,
64
- branch: str,
65
- *,
66
- state: str = "active",
67
- worktree_path: str | None = None,
68
- ) -> Path:
69
- checkout = project / ".prizmkit" / "state" / STATE_DIRS[family] / task_id / "checkout.json"
70
- checkout.parent.mkdir(parents=True, exist_ok=True)
71
- checkout.write_text(
72
- json.dumps(
73
- {
74
- "task_type": family,
75
- "task_id": task_id,
76
- "state": state,
77
- "active_dev_branch": branch,
78
- "base_branch": "main",
79
- "checkout_mode": "worktree" if worktree_path else "branch",
80
- "worktree_path": worktree_path,
81
- }
82
- )
83
- + "\n",
84
- encoding="utf-8",
85
- )
86
- return checkout
87
-
88
-
89
- def _write_raw_checkout(
90
- project: Path,
91
- family: str,
92
- directory_id: str,
93
- payload: dict[str, object],
94
- ) -> Path:
95
- checkout = (
96
- project
97
- / ".prizmkit"
98
- / "state"
99
- / STATE_DIRS[family]
100
- / directory_id
101
- / "checkout.json"
102
- )
103
- checkout.parent.mkdir(parents=True, exist_ok=True)
104
- checkout.write_text(json.dumps(payload) + "\n", encoding="utf-8")
105
- return checkout
106
-
107
-
108
- def _repository_snapshot(project: Path) -> tuple[str, str, str]:
109
- return (
110
- _git(project, "branch", "--show-current"),
111
- _git(project, "for-each-ref", "--format=%(refname):%(objectname)", "refs/heads"),
112
- _git(project, "status", "--porcelain=v1", "--untracked-files=all"),
113
- )
114
-
115
-
116
- def _historical_snapshot(historical: Path) -> dict[str, bytes]:
117
- return {
118
- path.relative_to(historical).as_posix(): path.read_bytes()
119
- for path in historical.rglob("*")
120
- if path.is_file()
121
- }
122
-
123
-
124
- def test_single_active_checkout_reports_operation_first_command_without_mutation(tmp_path):
125
- project = tmp_path / "project"
126
- _init_repository(project)
127
- branch = "dev/F-061-resume"
128
- _git(project, "branch", branch)
129
- checkout = _write_checkout(project, "feature", "F-061", branch)
130
- before = _repository_snapshot(project)
131
-
132
- result = subprocess.run(
133
- [sys.executable, str(DETECTOR_PATH), "--project-root", str(project)],
134
- cwd=project,
135
- check=False,
136
- text=True,
137
- stdout=subprocess.PIPE,
138
- stderr=subprocess.PIPE,
139
- )
140
- report = json.loads(result.stdout)
141
-
142
- assert result.returncode == 0
143
- assert result.stderr == ""
144
- assert report["detected"] is True
145
- assert report["selection_required"] is False
146
- assert report["current_branch"] == "main"
147
- assert len(report["candidates"]) == 1
148
- candidate = report["candidates"][0]
149
- assert candidate["family"] == "feature"
150
- assert candidate["task_id"] == "F-061"
151
- assert candidate["branch"] == branch
152
- assert candidate["checkout_path"] == checkout.relative_to(project).as_posix()
153
- assert candidate["worktree_path"] is None
154
- assert candidate["continue_command"] == (
155
- "python3 ./.prizmkit/dev-pipeline/cli.py run feature F-061"
156
- )
157
- assert _repository_snapshot(project) == before
158
- assert not (project / ".prizmkit" / "state" / "recovery").exists()
159
-
160
-
161
- def test_multiple_candidates_remain_skill_owned_and_ignore_historical_recovery_data(tmp_path):
162
- project = tmp_path / "project"
163
- _init_repository(project)
164
- branches = {
165
- "feature": ("F-002", "dev/F-002-resume"),
166
- "bugfix": ("B-007", "fix/B-007-resume"),
167
- }
168
- for task_id, branch in branches.values():
169
- _git(project, "branch", branch)
170
- for family, (task_id, branch) in branches.items():
171
- _write_checkout(project, family, task_id, branch)
172
-
173
- historical = project / ".prizmkit" / "state" / "recovery" / "old-session"
174
- historical.mkdir(parents=True)
175
- (historical / "detection.json").write_text(
176
- '{"detected": true, "legacy": true}\n', encoding="utf-8"
177
- )
178
- history_before = _historical_snapshot(historical)
179
- repository_before = _repository_snapshot(project)
180
- detector = _load_detector("recovery_workflow_multiple")
181
-
182
- report = detector.build_report(project)
183
-
184
- assert report["detected"] is True
185
- assert report["selection_required"] is True
186
- assert [candidate["task_id"] for candidate in report["candidates"]] == ["F-002", "B-007"]
187
- assert [candidate["continue_command"] for candidate in report["candidates"]] == [
188
- "python3 ./.prizmkit/dev-pipeline/cli.py run feature F-002",
189
- "python3 ./.prizmkit/dev-pipeline/cli.py run bugfix B-007",
190
- ]
191
- assert _repository_snapshot(project) == repository_before
192
- assert _historical_snapshot(historical) == history_before
193
- assert sorted(path.name for path in historical.parent.iterdir()) == ["old-session"]
194
-
195
-
196
- def test_zero_candidates_filters_invalid_records_without_history_fallback_or_session_creation(tmp_path):
197
- project = tmp_path / "project"
198
- _init_repository(project)
199
- completed_branch = "fix/B-003-complete"
200
- wrong_family_branch = "dev/B-999-wrong-family"
201
- _git(project, "branch", completed_branch)
202
- _git(project, "branch", wrong_family_branch)
203
- _write_checkout(
204
- project,
205
- "bugfix",
206
- "B-003",
207
- completed_branch,
208
- state="completed",
209
- )
210
- _write_checkout(project, "feature", "B-999", wrong_family_branch)
211
- _write_checkout(project, "refactor", "R-008", "refactor/R-008-missing")
212
-
213
- historical = project / ".prizmkit" / "state" / "recovery" / "historical-only"
214
- historical.mkdir(parents=True)
215
- (historical / "bootstrap-prompt.md").write_text("do not read or delete\n", encoding="utf-8")
216
- history_before = _historical_snapshot(historical)
217
- repository_before = _repository_snapshot(project)
218
- detector = _load_detector("recovery_workflow_empty")
219
-
220
- report = detector.build_report(project)
221
-
222
- assert report == {
223
- "detected": False,
224
- "current_branch": "main",
225
- "candidates": [],
226
- "message": "No active interrupted pipeline task branch was found.",
227
- }
228
- assert _repository_snapshot(project) == repository_before
229
- assert _historical_snapshot(historical) == history_before
230
- assert sorted(path.name for path in historical.parent.iterdir()) == ["historical-only"]
231
-
232
-
233
- def test_detector_rejects_malformed_or_mismatched_checkout_identity(tmp_path):
234
- project = tmp_path / "project"
235
- _init_repository(project)
236
- invalid_records = (
237
- (
238
- "feature",
239
- "F-not-an-id",
240
- "dev/F-not-an-id",
241
- {
242
- "task_type": "feature",
243
- "task_id": "F-not-an-id",
244
- "state": "active",
245
- "active_dev_branch": "dev/F-not-an-id",
246
- "base_branch": "main",
247
- "checkout_mode": "branch",
248
- },
249
- ),
250
- (
251
- "bugfix",
252
- "B-004",
253
- "bugfix/B-004-missing-id",
254
- {
255
- "task_type": "bugfix",
256
- "state": "active",
257
- "active_dev_branch": "bugfix/B-004-missing-id",
258
- "base_branch": "main",
259
- "checkout_mode": "branch",
260
- },
261
- ),
262
- (
263
- "refactor",
264
- "R-005",
265
- "refactor/R-005-wrong-type",
266
- {
267
- "task_type": "feature",
268
- "task_id": "R-005",
269
- "state": "active",
270
- "active_dev_branch": "refactor/R-005-wrong-type",
271
- "base_branch": "main",
272
- "checkout_mode": "branch",
273
- },
274
- ),
275
- (
276
- "feature",
277
- "F-006",
278
- "dev/F-006-path-mismatch",
279
- {
280
- "task_type": "feature",
281
- "task_id": "F-007",
282
- "state": "active",
283
- "active_dev_branch": "dev/F-006-path-mismatch",
284
- "base_branch": "main",
285
- "checkout_mode": "branch",
286
- },
287
- ),
288
- )
289
- for family, directory_id, branch, payload in invalid_records:
290
- _git(project, "branch", branch)
291
- _write_raw_checkout(project, family, directory_id, payload)
292
-
293
- detector = _load_detector("recovery_workflow_invalid_identity")
294
-
295
- assert detector.detect_candidates(project) == []
296
-
297
-
298
- def test_recovery_workflow_metadata_matches_detector_only_contract():
299
- metadata = json.loads((REPO_ROOT / "core" / "skills" / "_metadata.json").read_text())
300
- recovery = metadata["skills"]["recovery-workflow"]
301
- description = recovery["description"].lower()
302
-
303
- assert recovery["hasScripts"] is True
304
- assert "active feature, bugfix, or refactor checkout records" in description
305
- assert "operation-first" in description
306
- assert "direct requirement" not in description
307
-
308
-
309
- def test_canonical_recovery_and_cli_guidance_has_no_retired_contracts():
310
- env_example = (REPO_ROOT / "dev-pipeline" / ".env.example").read_text(encoding="utf-8")
311
- readme = (REPO_ROOT / "README.md").read_text(encoding="utf-8")
312
- readme_en = (REPO_ROOT / "README_EN.md").read_text(encoding="utf-8")
313
-
314
- assert "cli.py feature run" not in env_example
315
- assert "cli.py run feature" in env_example
316
- assert "从断点继续" not in readme
317
- assert "reset/clean/unskip/complete" not in readme
318
- assert "reset/clean/reset_state/complete" in readme
319
- assert "Auto-detect + resume from breakpoint" not in readme_en
320
- assert "interrupted at Phase 4" not in readme_en
321
- assert "Resumes from Phase 5" not in readme_en
322
- assert "Does not execute the command or infer a lifecycle phase" in readme_en
@@ -1,252 +0,0 @@
1
- """Git bootstrap for projects that have no repository or no commits yet."""
2
-
3
- import json
4
- import subprocess
5
- from pathlib import Path
6
-
7
- import pytest
8
-
9
- PIPELINE_ROOT = Path(__file__).resolve().parents[1]
10
-
11
-
12
- def _git(project, *args, check=True):
13
- return subprocess.run(
14
- ["git", "-C", str(project), *args],
15
- check=check,
16
- stdout=subprocess.PIPE,
17
- stderr=subprocess.PIPE,
18
- text=True,
19
- )
20
-
21
-
22
- def _init_unborn(project, branch):
23
- project.mkdir(parents=True, exist_ok=True)
24
- _git(project, "init", "-b", branch)
25
-
26
-
27
- def _identity(project):
28
- _git(project, "config", "user.email", "test@example.com")
29
- _git(project, "config", "user.name", "Test")
30
-
31
-
32
- def test_current_branch_reads_unborn_branch_name(tmp_path):
33
- from prizmkit_runtime.gitops import current_branch, default_branch
34
-
35
- project = tmp_path / "unborn"
36
- _init_unborn(project, "master")
37
-
38
- assert current_branch(project) == "master"
39
- assert default_branch(project) == "master"
40
-
41
-
42
- def test_current_branch_is_empty_outside_a_repository(tmp_path):
43
- from prizmkit_runtime.gitops import current_branch
44
-
45
- assert current_branch(tmp_path) == ""
46
-
47
-
48
- def test_default_branch_uses_the_checked_out_branch_when_main_also_exists(tmp_path):
49
- from prizmkit_runtime.gitops import default_branch
50
-
51
- project = tmp_path / "develop-repo"
52
- _init_unborn(project, "develop")
53
- _identity(project)
54
- _git(project, "commit", "--allow-empty", "-m", "init")
55
- _git(project, "branch", "main")
56
-
57
- assert default_branch(project) == "develop"
58
-
59
-
60
- def test_task_branch_resolves_back_to_the_primary_it_left(tmp_path):
61
- from prizmkit_runtime.gitops import (
62
- BranchContext,
63
- branch_create_plan,
64
- branch_ensure_return,
65
- current_branch,
66
- default_branch,
67
- run_git_plan,
68
- )
69
-
70
- project = tmp_path / "trunk-repo"
71
- _init_unborn(project, "trunk")
72
- _identity(project)
73
- _git(project, "commit", "--allow-empty", "-m", "init")
74
- _git(project, "branch", "main")
75
- created = run_git_plan(project, branch_create_plan(BranchContext("trunk", "dev/F-001-custom", project)))
76
- assert created.ok
77
- assert current_branch(project) == "dev/F-001-custom"
78
- assert default_branch(project) == "trunk"
79
-
80
- returned = branch_ensure_return(project, "trunk", "dev/F-001-custom")
81
- assert returned.ok
82
- assert current_branch(project) == "trunk"
83
-
84
-
85
- def test_default_branch_prefers_an_existing_main_or_master_commit(tmp_path):
86
- from prizmkit_runtime.gitops import default_branch
87
-
88
- main_repo = tmp_path / "main-repo"
89
- _init_unborn(main_repo, "main")
90
- _identity(main_repo)
91
- (main_repo / "README").write_text("main\n", encoding="utf-8")
92
- _git(main_repo, "add", "README")
93
- _git(main_repo, "commit", "-m", "init")
94
- assert default_branch(main_repo) == "main"
95
-
96
- master_repo = tmp_path / "master-repo"
97
- _init_unborn(master_repo, "master")
98
- _identity(master_repo)
99
- (master_repo / "README").write_text("master\n", encoding="utf-8")
100
- _git(master_repo, "add", "README")
101
- _git(master_repo, "commit", "-m", "init")
102
- assert default_branch(master_repo) == "master"
103
-
104
-
105
- def test_missing_repository_can_create_a_task_branch_after_preflight(tmp_path):
106
- from prizmkit_runtime.gitops import (
107
- BranchContext,
108
- branch_create_plan,
109
- current_branch,
110
- default_branch,
111
- ensure_branch_has_commit,
112
- ensure_git_repository,
113
- local_branch_exists,
114
- run_git_plan,
115
- )
116
- from prizmkit_runtime.runner_bookkeeping import commit_preflight_ready_changes
117
-
118
- project = tmp_path / "fresh"
119
- project.mkdir()
120
- (project / "README").write_text("framework\n", encoding="utf-8")
121
-
122
- created = ensure_git_repository(project)
123
- assert created.return_code == 0
124
- assert created.args[0] == "init"
125
- again = ensure_git_repository(project)
126
- assert again.args[0] == "rev-parse"
127
-
128
- base = current_branch(project)
129
- assert base
130
- assert base != "HEAD"
131
- assert default_branch(project) == base
132
-
133
- preflight = commit_preflight_ready_changes(project, "F-001")
134
- assert preflight.committed
135
- assert ensure_branch_has_commit(project).args[0] == "rev-parse"
136
- assert local_branch_exists(project, base)
137
- assert not local_branch_exists(project, "this-branch-does-not-exist")
138
-
139
- plan = run_git_plan(project, branch_create_plan(BranchContext(base, "dev/F-001-fresh", project)))
140
- assert plan.ok
141
- assert local_branch_exists(project, "dev/F-001-fresh")
142
- assert _git(project, "merge-base", "--is-ancestor", base, "dev/F-001-fresh").returncode == 0
143
-
144
-
145
- def test_unborn_master_preflight_branches_from_master_not_main(tmp_path):
146
- from prizmkit_runtime.gitops import (
147
- BranchContext,
148
- branch_create_plan,
149
- current_branch,
150
- default_branch,
151
- local_branch_exists,
152
- run_git_plan,
153
- )
154
- from prizmkit_runtime.runner_bookkeeping import commit_preflight_ready_changes
155
-
156
- project = tmp_path / "master-only"
157
- _init_unborn(project, "master")
158
- _identity(project)
159
- (project / ".gitignore").write_text(".prizmkit/*\n", encoding="utf-8")
160
-
161
- assert current_branch(project) == "master"
162
- assert default_branch(project) == "master"
163
- preflight = commit_preflight_ready_changes(project, "F-001")
164
- assert preflight.committed
165
- assert _git(project, "rev-parse", "--abbrev-ref", "HEAD").stdout.strip() == "master"
166
- assert not local_branch_exists(project, "main")
167
-
168
- plan = run_git_plan(project, branch_create_plan(BranchContext("master", "dev/F-001-master", project)))
169
- assert plan.ok
170
- assert local_branch_exists(project, "dev/F-001-master")
171
-
172
-
173
- def test_empty_repository_gets_an_initial_commit_before_branching(tmp_path):
174
- from prizmkit_runtime.gitops import (
175
- BranchContext,
176
- branch_create_plan,
177
- current_branch,
178
- ensure_branch_has_commit,
179
- ensure_git_repository,
180
- local_branch_exists,
181
- run_git_plan,
182
- )
183
-
184
- project = tmp_path / "empty"
185
- project.mkdir()
186
- assert ensure_git_repository(project).return_code == 0
187
- base = current_branch(project)
188
- born = ensure_branch_has_commit(project)
189
- assert born.return_code == 0
190
- assert born.args[0] == "commit"
191
- assert local_branch_exists(project, base)
192
- plan = run_git_plan(project, branch_create_plan(BranchContext(base, "dev/F-001-empty", project)))
193
- assert plan.ok
194
-
195
-
196
- def test_runner_uses_real_master_when_recorded_base_main_does_not_exist(monkeypatch, tmp_path):
197
- from prizmkit_runtime import runners
198
- from prizmkit_runtime.gitops import local_branch_exists
199
- from prizmkit_runtime.runner_models import family_for, parse_invocation
200
- from prizmkit_runtime.task_checkout import TaskCheckout, load_task_checkout, persist_task_checkout
201
-
202
- monkeypatch.delenv("USE_WORKTREE", raising=False)
203
- monkeypatch.delenv("DEV_BRANCH", raising=False)
204
- monkeypatch.setattr(
205
- runners,
206
- "load_runtime_config",
207
- lambda paths: type("Config", (), {
208
- "ai_client": type("Client", (), {"command": "fake-ai", "platform": "codebuddy", "launch_profile": None})(),
209
- "model": "",
210
- "effort": None,
211
- "effort_validation": type("Effort", (), {"valid": True, "message": ""})(),
212
- })(),
213
- )
214
-
215
- paths = tmp_path / "project"
216
- _init_unborn(paths, "master")
217
- _identity(paths)
218
- (paths / ".prizmkit" / "plans").mkdir(parents=True)
219
- (paths / "README").write_text("ready\n", encoding="utf-8")
220
- _git(paths, "add", "README")
221
- _git(paths, "commit", "-m", "chore: ready for F-001")
222
-
223
- from prizmkit_runtime.paths import resolve_runtime_paths
224
-
225
- runtime_paths = resolve_runtime_paths(
226
- pipeline_root=PIPELINE_ROOT,
227
- project_root=paths,
228
- )
229
- family = family_for("feature", runtime_paths)
230
- invocation = parse_invocation(family, "run", ())
231
- invocation = invocation.__class__(**{**invocation.__dict__, "list_path": runtime_paths.feature_plan})
232
- persist_task_checkout(
233
- family.state_dir,
234
- TaskCheckout.active("feature", "F-001", "dev/F-001-poison", "main"),
235
- )
236
-
237
- def stop_after_branch(*_args, **_kwargs):
238
- raise RuntimeError("stop-after-branch")
239
-
240
- monkeypatch.setattr(runners, "start_item", stop_after_branch)
241
-
242
- with pytest.raises(RuntimeError, match="stop-after-branch"):
243
- runners._process_item(family, invocation, "F-001", runtime_paths, initial_metadata={})
244
-
245
- checkout = load_task_checkout(family.state_dir, family.task_type, "F-001")
246
- assert checkout is not None
247
- assert checkout.base_branch == "master"
248
- assert checkout.active_dev_branch == "dev/F-001-poison"
249
- assert local_branch_exists(paths, "dev/F-001-poison")
250
- assert _git(paths, "merge-base", "--is-ancestor", "master", "dev/F-001-poison").returncode == 0
251
- stored = json.loads((family.state_dir / "F-001" / "checkout.json").read_text(encoding="utf-8"))
252
- assert stored["base_branch"] == "master"