@deftai/directive-content 0.59.0 → 0.60.0

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 (184) hide show
  1. package/.githooks/pre-push +10 -9
  2. package/Taskfile.yml +48 -58
  3. package/UPGRADING.md +1 -1
  4. package/docs/assets/directive-lifecycle-diagram.png +0 -0
  5. package/docs/directive-lifecycle.md +73 -0
  6. package/docs/getting-started.md +5 -1
  7. package/package.json +3 -3
  8. package/packs/skills/skills-pack-0.1.json +22 -22
  9. package/scm/github.md +20 -2
  10. package/tasks/change.yml +16 -31
  11. package/tasks/ci.yml +8 -0
  12. package/tasks/commit.yml +12 -19
  13. package/tasks/core.yml +10 -0
  14. package/tasks/engine.yml +42 -0
  15. package/tasks/framework.yml +3 -0
  16. package/tasks/install.yml +20 -19
  17. package/tasks/migrate.yml +26 -15
  18. package/tasks/project.yml +16 -0
  19. package/tasks/toolchain.yml +15 -5
  20. package/tasks/vbrief.yml +4 -3
  21. package/tasks/verify.yml +12 -14
  22. package/scripts/_agents_md.py +0 -494
  23. package/scripts/_cache_fetch.py +0 -635
  24. package/scripts/_cache_quota.py +0 -529
  25. package/scripts/_cache_refresh.py +0 -163
  26. package/scripts/_cache_validate.py +0 -209
  27. package/scripts/_content_root.py +0 -42
  28. package/scripts/_doctor_state.py +0 -277
  29. package/scripts/_event_detect.py +0 -305
  30. package/scripts/_events.py +0 -514
  31. package/scripts/_lifecycle_hygiene.py +0 -568
  32. package/scripts/_pathspec.py +0 -91
  33. package/scripts/_policy_show_cli.py +0 -266
  34. package/scripts/_precutover.py +0 -92
  35. package/scripts/_project_context.py +0 -224
  36. package/scripts/_project_definition_io.py +0 -164
  37. package/scripts/_relocate_snapshot.py +0 -209
  38. package/scripts/_relocate_states.py +0 -343
  39. package/scripts/_resolve_preflight_path.py +0 -152
  40. package/scripts/_safe_subprocess.py +0 -167
  41. package/scripts/_session_start_hook.py +0 -205
  42. package/scripts/_sor_gate_diff.py +0 -365
  43. package/scripts/_stdio_utf8.py +0 -59
  44. package/scripts/_triage_bootstrap_gitignore.py +0 -904
  45. package/scripts/_triage_classify_cli.py +0 -122
  46. package/scripts/_triage_queue_cli.py +0 -625
  47. package/scripts/_triage_scope_cli.py +0 -343
  48. package/scripts/_triage_scope_drift_cli.py +0 -121
  49. package/scripts/_triage_scope_ignores.py +0 -286
  50. package/scripts/_triage_scope_milestone.py +0 -432
  51. package/scripts/_triage_scope_mutations.py +0 -337
  52. package/scripts/_triage_scope_renderers.py +0 -207
  53. package/scripts/_triage_smoketest_stages.py +0 -674
  54. package/scripts/_triage_subscribe_cli.py +0 -140
  55. package/scripts/_triage_welcome_cli.py +0 -421
  56. package/scripts/_vbrief_build.py +0 -239
  57. package/scripts/_vbrief_fidelity.py +0 -479
  58. package/scripts/_vbrief_legacy.py +0 -589
  59. package/scripts/_vbrief_reconciliation.py +0 -883
  60. package/scripts/_vbrief_routing.py +0 -277
  61. package/scripts/_vbrief_safety.py +0 -778
  62. package/scripts/_vbrief_sources.py +0 -312
  63. package/scripts/_vbrief_speckit.py +0 -262
  64. package/scripts/_vbrief_story_quality.py +0 -353
  65. package/scripts/_vbrief_validation.py +0 -299
  66. package/scripts/build_dist.py +0 -412
  67. package/scripts/cache.py +0 -1078
  68. package/scripts/cache_scanner.py +0 -745
  69. package/scripts/candidates_log.py +0 -432
  70. package/scripts/capacity_backfill.py +0 -680
  71. package/scripts/capacity_show.py +0 -653
  72. package/scripts/ci_local.py +0 -689
  73. package/scripts/code_structure_validate.py +0 -765
  74. package/scripts/codebase_default_extractor.py +0 -495
  75. package/scripts/codebase_map.py +0 -304
  76. package/scripts/codebase_map_fresh.py +0 -104
  77. package/scripts/codebase_projection_registry.py +0 -94
  78. package/scripts/codebase_provider.py +0 -582
  79. package/scripts/doctor.py +0 -2552
  80. package/scripts/framework_commands.py +0 -505
  81. package/scripts/gh_rest.py +0 -882
  82. package/scripts/github_auth_modes.py +0 -437
  83. package/scripts/github_body.py +0 -292
  84. package/scripts/ip_risk.py +0 -531
  85. package/scripts/issue_emit.py +0 -670
  86. package/scripts/issue_ingest.py +0 -1064
  87. package/scripts/migrate_preflight.py +0 -418
  88. package/scripts/migrate_vbrief.py +0 -2677
  89. package/scripts/monitor_pr.py +0 -401
  90. package/scripts/pack_migrate_lessons.py +0 -336
  91. package/scripts/pack_migrate_patterns.py +0 -254
  92. package/scripts/pack_migrate_rules.py +0 -350
  93. package/scripts/pack_migrate_skills.py +0 -423
  94. package/scripts/pack_migrate_strategies.py +0 -311
  95. package/scripts/pack_migrate_swarm_spec.py +0 -250
  96. package/scripts/pack_render.py +0 -434
  97. package/scripts/packs_slice.py +0 -712
  98. package/scripts/platform_capabilities.py +0 -336
  99. package/scripts/policy.py +0 -2826
  100. package/scripts/policy_set.py +0 -324
  101. package/scripts/pr_check_closing_keywords.py +0 -524
  102. package/scripts/pr_check_protected_issues.py +0 -267
  103. package/scripts/pr_merge_readiness.py +0 -1004
  104. package/scripts/pr_wait_mergeable.py +0 -669
  105. package/scripts/prd_render.py +0 -159
  106. package/scripts/preflight_architecture_sor.py +0 -974
  107. package/scripts/preflight_branch.py +0 -289
  108. package/scripts/preflight_cache.py +0 -974
  109. package/scripts/preflight_gh.py +0 -721
  110. package/scripts/preflight_implementation.py +0 -272
  111. package/scripts/preflight_story_start.py +0 -838
  112. package/scripts/preflight_wip_cap.py +0 -149
  113. package/scripts/probe_session.py +0 -545
  114. package/scripts/project_render.py +0 -293
  115. package/scripts/quarantine_ext.py +0 -237
  116. package/scripts/reconcile_issues.py +0 -1442
  117. package/scripts/refresh-path.ps1 +0 -107
  118. package/scripts/release.py +0 -2030
  119. package/scripts/release_e2e.py +0 -1011
  120. package/scripts/release_publish.py +0 -486
  121. package/scripts/release_rollback.py +0 -980
  122. package/scripts/relocate.py +0 -1034
  123. package/scripts/resolve_changelog_unreleased.py +0 -667
  124. package/scripts/resolve_version.py +0 -490
  125. package/scripts/resume_conditions.py +0 -706
  126. package/scripts/ritual_sentinel.py +0 -609
  127. package/scripts/roadmap_render.py +0 -635
  128. package/scripts/rule_ownership_lint.py +0 -325
  129. package/scripts/scm.py +0 -591
  130. package/scripts/scope_audit_log.py +0 -387
  131. package/scripts/scope_decompose.py +0 -654
  132. package/scripts/scope_demote.py +0 -509
  133. package/scripts/scope_lifecycle.py +0 -1126
  134. package/scripts/scope_undo.py +0 -772
  135. package/scripts/session_start.py +0 -406
  136. package/scripts/setup_ghx.py +0 -339
  137. package/scripts/setup_windows.ps1 +0 -220
  138. package/scripts/slice_audit.py +0 -585
  139. package/scripts/slice_record.py +0 -530
  140. package/scripts/slice_record_existing.py +0 -692
  141. package/scripts/slug_normalize.py +0 -178
  142. package/scripts/spec_render.py +0 -477
  143. package/scripts/spec_validate.py +0 -238
  144. package/scripts/subagent_monitor.py +0 -658
  145. package/scripts/swarm_complete_cohort.py +0 -644
  146. package/scripts/swarm_launch.py +0 -1206
  147. package/scripts/swarm_readiness.py +0 -554
  148. package/scripts/swarm_verify_review_clean.py +0 -438
  149. package/scripts/swarm_worktrees.py +0 -497
  150. package/scripts/toolchain-check.py +0 -52
  151. package/scripts/triage_actions.py +0 -871
  152. package/scripts/triage_bootstrap.py +0 -1153
  153. package/scripts/triage_bulk.py +0 -630
  154. package/scripts/triage_classify.py +0 -932
  155. package/scripts/triage_help.py +0 -1685
  156. package/scripts/triage_queue.py +0 -1944
  157. package/scripts/triage_reconcile.py +0 -581
  158. package/scripts/triage_refresh.py +0 -643
  159. package/scripts/triage_scope.py +0 -999
  160. package/scripts/triage_scope_drift.py +0 -575
  161. package/scripts/triage_smoketest.py +0 -396
  162. package/scripts/triage_subscribe.py +0 -399
  163. package/scripts/triage_summary.py +0 -1011
  164. package/scripts/triage_welcome.py +0 -1178
  165. package/scripts/ts_check_lane.py +0 -86
  166. package/scripts/validate-links.py +0 -64
  167. package/scripts/validate_strategy_output.py +0 -212
  168. package/scripts/vbrief_activate.py +0 -228
  169. package/scripts/vbrief_migrate_conformance.py +0 -368
  170. package/scripts/vbrief_reconcile_graph.py +0 -306
  171. package/scripts/vbrief_reconcile_labels.py +0 -460
  172. package/scripts/vbrief_reconcile_umbrellas.py +0 -741
  173. package/scripts/vbrief_validate.py +0 -1144
  174. package/scripts/verify-stubs.py +0 -61
  175. package/scripts/verify_capacity.py +0 -160
  176. package/scripts/verify_encoding.py +0 -699
  177. package/scripts/verify_hooks_installed.py +0 -206
  178. package/scripts/verify_investigation.py +0 -360
  179. package/scripts/verify_judgment_gates.py +0 -827
  180. package/scripts/verify_no_task_runtime.py +0 -171
  181. package/scripts/verify_scm_boundary.py +0 -509
  182. package/scripts/verify_session_ritual.py +0 -389
  183. package/scripts/verify_tools.py +0 -426
  184. package/scripts/verify_vbrief_conformance.py +0 -478
@@ -1,418 +0,0 @@
1
- #!/usr/bin/env python3
2
- """migrate_preflight.py -- agent-side environment preflight for ``task migrate:vbrief`` (#793).
3
-
4
- Reifies the prose contract documented in
5
- ``skills/deft-directive-setup/SKILL.md`` § Environment Preflight as a runnable
6
- task so consumers running ``task migrate:vbrief`` directly (not via the
7
- agent-driven setup skill) get the same checks before any destructive mutation
8
- runs.
9
-
10
- Pure stdlib + ``subprocess``. Three-state exit (mirrors
11
- ``scripts/preflight_branch.py`` (#747) and ``scripts/preflight_implementation.py``
12
- (#810) shape):
13
-
14
- - ``0`` -- ready: every check PASS (or non-blocking WARN, e.g. dirty git tree).
15
- - ``1`` -- not-ready: any check FAIL with an actionable remediation pointer.
16
- - ``2`` -- config error: e.g. ``--project-root`` does not exist or is not a
17
- directory. Distinct from FAIL so callers can disambiguate "user can fix"
18
- from "calling environment is wrong".
19
-
20
- The checks are:
21
-
22
- 1. ``uv`` on PATH -- the migrator runs via ``uv run python``; absence is fatal.
23
- 2. v0.20+ layout -- ``<deft-root>/scripts/migrate_vbrief.py`` and
24
- ``<project>/vbrief/`` (with the ``schemas/`` subdirectory carried by the
25
- framework checkout) must exist; absence indicates an incomplete or
26
- pre-cutover checkout.
27
- 3. Document-model state -- delegates to ``scripts/_precutover.py`` so a
28
- generated ``SPECIFICATION.md`` from ``task spec:render`` does not send a
29
- current vBRIEF project through destructive migration.
30
- 4. Git working-tree state -- a dirty tree is reported as WARN (the migrator's
31
- own dirty-tree guard fires with an actionable ``--force`` pointer; we do
32
- NOT block here so ``--dry-run`` previews remain usable). Non-git
33
- directories are also a WARN-level skip rather than a FAIL.
34
-
35
- The intent is to surface every fixable blocker at once, with one line per
36
- check, so operators can resolve them in a single pass instead of fighting
37
- through three separate subprocess error tracebacks.
38
-
39
- Soft-dep on #792 (``cmd_doctor`` uv-detection helper): a local
40
- ``_uv_available()`` is defined here for now to keep this PR self-contained;
41
- when #792 lands a future small follow-up can DRY both surfaces against a
42
- single shared helper.
43
- """
44
-
45
- from __future__ import annotations
46
-
47
- import argparse
48
- import shutil
49
- import subprocess
50
- import sys
51
- from pathlib import Path
52
- from typing import NamedTuple
53
-
54
- sys.path.insert(0, str(Path(__file__).resolve().parent))
55
-
56
- from _content_root import content_root # noqa: E402
57
- from _precutover import ( # noqa: E402
58
- detect_pre_cutover_legacy,
59
- is_current_generated_specification,
60
- is_generated_specification_export,
61
- missing_lifecycle_folders,
62
- )
63
-
64
-
65
- class CheckResult(NamedTuple):
66
- """A single preflight check's outcome.
67
-
68
- Attributes:
69
- name: Short, stable identifier (e.g. ``uv``, ``layout``, ``git-clean``).
70
- status: One of ``PASS`` / ``WARN`` / ``FAIL``.
71
- message: Human-readable remediation pointer or status note.
72
- """
73
-
74
- name: str
75
- status: str # "PASS" | "WARN" | "FAIL"
76
- message: str
77
-
78
-
79
- # ---------------------------------------------------------------------------
80
- # Individual check primitives
81
- # ---------------------------------------------------------------------------
82
-
83
-
84
- def _uv_available() -> bool:
85
- """Return True when the ``uv`` executable is resolvable on PATH.
86
-
87
- Local helper for #793; once #792 lands a shared ``cmd_doctor`` helper a
88
- follow-up should DRY this against a single source of truth (the brief's
89
- ``soft_dep_on: #792`` note).
90
- """
91
- return shutil.which("uv") is not None
92
-
93
-
94
- def check_uv() -> CheckResult:
95
- """Verify ``uv`` is on PATH.
96
-
97
- The migrator dispatches via ``uv run python ...``; without ``uv`` the
98
- consumer hits a raw ``FileNotFoundError`` with no recovery pointer. This
99
- check is the actionable replacement for that traceback.
100
- """
101
- if _uv_available():
102
- return CheckResult("uv", "PASS", "uv is on PATH.")
103
- return CheckResult(
104
- "uv",
105
- "FAIL",
106
- "uv is not on PATH. Install from https://docs.astral.sh/uv/ and re-run.",
107
- )
108
-
109
-
110
- def check_layout(deft_root: Path, project_root: Path) -> CheckResult:
111
- """Verify the framework checkout + project root carry the v0.20+ layout.
112
-
113
- Two pieces are required:
114
-
115
- 1. ``<deft-root>/scripts/migrate_vbrief.py`` -- the migrator script the
116
- ``task migrate:vbrief`` target dispatches to. A missing file means the
117
- framework checkout is incomplete or came from a pre-v0.20 release.
118
- 2. ``<project-root>/vbrief/`` -- the lifecycle root the migrator ingests
119
- into. It is created on first run for greenfield projects, but most
120
- v0.20+ projects already have it; existence here is informational
121
- (``WARN`` when missing, not ``FAIL``).
122
-
123
- The framework's ``vbrief/schemas/`` directory MUST exist on the deft root
124
- too (carried by the checkout, not regenerated) -- absence indicates a
125
- framework checkout problem and is FAIL.
126
- """
127
- migrator = deft_root / "scripts" / "migrate_vbrief.py"
128
- if not migrator.is_file():
129
- return CheckResult(
130
- "layout",
131
- "FAIL",
132
- (
133
- f"Migrator script missing at {migrator}. The framework checkout "
134
- "appears incomplete or pre-v0.20; refresh per "
135
- "deft/QUICK-START.md."
136
- ),
137
- )
138
-
139
- schemas_dir = content_root(deft_root) / "vbrief" / "schemas"
140
- if not schemas_dir.is_dir():
141
- return CheckResult(
142
- "layout",
143
- "FAIL",
144
- (
145
- f"Framework schemas dir missing at {schemas_dir}. Refresh the "
146
- "deft checkout (see deft/QUICK-START.md)."
147
- ),
148
- )
149
-
150
- project_vbrief = project_root / "vbrief"
151
- if not project_vbrief.exists():
152
- return CheckResult(
153
- "layout",
154
- "WARN",
155
- (
156
- f"Project vbrief/ not present at {project_vbrief} -- migrator "
157
- "will create it on first run; this is expected for greenfield "
158
- "projects."
159
- ),
160
- )
161
-
162
- return CheckResult(
163
- "layout",
164
- "PASS",
165
- f"Framework migrator + schemas present; project vbrief/ at {project_vbrief}.",
166
- )
167
-
168
-
169
- def check_git_clean(project_root: Path) -> CheckResult:
170
- """Surface git working-tree state non-blockingly.
171
-
172
- A dirty tree is reported as WARN (not FAIL) because:
173
-
174
- - ``task migrate:vbrief -- --dry-run`` is the recommended preview path and
175
- runs fine against a dirty tree.
176
- - The migrator itself has a dirty-tree guard with a ``--force`` recovery
177
- pointer (#497); double-blocking here would be redundant.
178
-
179
- A non-git directory is also a WARN: the gate has nothing to assert, but
180
- the operator deserves to know the standard recovery path won't apply.
181
- """
182
- try:
183
- proc = subprocess.run(
184
- ["git", "status", "--porcelain"],
185
- cwd=str(project_root),
186
- capture_output=True,
187
- text=True,
188
- check=False,
189
- )
190
- except FileNotFoundError:
191
- return CheckResult(
192
- "git-clean",
193
- "WARN",
194
- (
195
- "git executable not on PATH; skipping working-tree check. "
196
- "Migrator's dirty-tree guard will still fire if applicable."
197
- ),
198
- )
199
-
200
- if proc.returncode != 0:
201
- # Non-zero typically means "not a git repository". Treat as WARN.
202
- return CheckResult(
203
- "git-clean",
204
- "WARN",
205
- (
206
- f"Not a git repository at {project_root} (git exit "
207
- f"{proc.returncode}); skipping working-tree check."
208
- ),
209
- )
210
-
211
- if proc.stdout.strip():
212
- return CheckResult(
213
- "git-clean",
214
- "WARN",
215
- (
216
- "Working tree is dirty. The migrator will refuse to run "
217
- "without --force; preview with `task migrate:vbrief -- "
218
- "--dry-run` first."
219
- ),
220
- )
221
-
222
- return CheckResult("git-clean", "PASS", "Working tree is clean.")
223
-
224
-
225
- def check_document_model(project_root: Path) -> CheckResult:
226
- """Verify migration is aimed at legacy or incomplete document-model state.
227
-
228
- The preflight is a safety check, so it must not send current vBRIEF
229
- projects into the destructive migration path merely because a generated
230
- root ``SPECIFICATION.md`` exists.
231
- """
232
- legacy = detect_pre_cutover_legacy(project_root)
233
- if legacy:
234
- return CheckResult(
235
- "document-model",
236
- "PASS",
237
- "Legacy root artifact(s) detected: " + ", ".join(legacy) + ".",
238
- )
239
-
240
- spec_md = project_root / "SPECIFICATION.md"
241
- if spec_md.is_file():
242
- try:
243
- content = spec_md.read_text(encoding="utf-8", errors="replace")
244
- except OSError:
245
- content = ""
246
- if is_generated_specification_export(project_root, content):
247
- missing = missing_lifecycle_folders(project_root)
248
- if missing:
249
- return CheckResult(
250
- "document-model",
251
- "FAIL",
252
- (
253
- "Generated SPECIFICATION.md detected "
254
- "(source: vbrief/specification.vbrief.json); "
255
- "repair missing lifecycle folder(s) instead of migrating: "
256
- + ", ".join(missing)
257
- + "."
258
- ),
259
- )
260
- if is_current_generated_specification(project_root, content):
261
- return CheckResult(
262
- "document-model",
263
- "FAIL",
264
- (
265
- "Current generated SPECIFICATION.md detected "
266
- "(source: vbrief/specification.vbrief.json); "
267
- "`task migrate:vbrief` is not needed."
268
- ),
269
- )
270
-
271
- vbrief_root = project_root / "vbrief"
272
- if vbrief_root.exists():
273
- missing = missing_lifecycle_folders(project_root)
274
- if missing:
275
- return CheckResult(
276
- "document-model",
277
- "PASS",
278
- "Partial vBRIEF layout detected; missing lifecycle folder(s): "
279
- + ", ".join(missing)
280
- + ".",
281
- )
282
-
283
- return CheckResult(
284
- "document-model",
285
- "WARN",
286
- (
287
- "No legacy root SPECIFICATION.md/PROJECT.md artifacts detected. "
288
- "Migration may have nothing to do."
289
- ),
290
- )
291
-
292
-
293
- # ---------------------------------------------------------------------------
294
- # Aggregate evaluation
295
- # ---------------------------------------------------------------------------
296
-
297
-
298
- def evaluate(deft_root: Path, project_root: Path) -> tuple[int, list[CheckResult]]:
299
- """Run every check and return ``(exit_code, results)``.
300
-
301
- Pure function -- separated from :func:`main` so tests can drive every
302
- state without ``capsys`` plumbing or env-var leak. Mirrors the
303
- ``scripts/preflight_branch.py::evaluate`` surface.
304
-
305
- Exit-code semantics:
306
-
307
- - ``0`` -- every check PASS or WARN.
308
- - ``1`` -- one or more checks FAIL.
309
- - ``2`` is reserved for the CLI :func:`main` to signal config error
310
- (e.g. ``--project-root`` does not exist); :func:`evaluate` itself never
311
- emits 2.
312
- """
313
- results = [
314
- check_uv(),
315
- check_layout(deft_root, project_root),
316
- check_document_model(project_root),
317
- check_git_clean(project_root),
318
- ]
319
- if any(r.status == "FAIL" for r in results):
320
- return 1, results
321
- return 0, results
322
-
323
-
324
- # ---------------------------------------------------------------------------
325
- # CLI plumbing
326
- # ---------------------------------------------------------------------------
327
-
328
-
329
- def _format_result(result: CheckResult) -> str:
330
- """Return the canonical ``CHECK <name>: <STATUS> <message>`` line."""
331
- return f"CHECK {result.name}: {result.status} {result.message}"
332
-
333
-
334
- def _build_parser() -> argparse.ArgumentParser:
335
- parser = argparse.ArgumentParser(
336
- prog="migrate_preflight.py",
337
- description=(
338
- "Agent-side environment preflight for `task migrate:vbrief` "
339
- "(#793). Verifies uv on PATH, v0.20+ layout, document-model "
340
- "state, and git working-tree state before destructive migration "
341
- "mutations."
342
- ),
343
- )
344
- parser.add_argument(
345
- "--project-root",
346
- default=".",
347
- help=("Path to the consumer project root (default: current working " "directory)."),
348
- )
349
- parser.add_argument(
350
- "--deft-root",
351
- default=None,
352
- help=(
353
- "Path to the deft framework checkout (default: parent of this " "script's directory)."
354
- ),
355
- )
356
- parser.add_argument(
357
- "--quiet",
358
- action="store_true",
359
- help="Suppress PASS lines (FAIL/WARN still print).",
360
- )
361
- return parser
362
-
363
-
364
- def main(argv: list[str] | None = None) -> int:
365
- # #814 + parity with scripts/preflight_branch.py: force UTF-8 stdout/stderr
366
- # at entry so the gate's status lines render under Windows cp1252 default
367
- # without a UnicodeEncodeError. Guarded by ``hasattr`` because reconfigure
368
- # is only available on TextIOWrapper streams; ``errors='replace'`` is the
369
- # belt-and-suspenders fallback per #814.
370
- if hasattr(sys.stdout, "reconfigure"):
371
- sys.stdout.reconfigure(encoding="utf-8", errors="replace")
372
- if hasattr(sys.stderr, "reconfigure"):
373
- sys.stderr.reconfigure(encoding="utf-8", errors="replace")
374
-
375
- parser = _build_parser()
376
- args = parser.parse_args(argv)
377
-
378
- project_root = Path(args.project_root).resolve()
379
- if not project_root.exists() or not project_root.is_dir():
380
- print(
381
- f"ERROR: --project-root does not exist or is not a directory: " f"{project_root}",
382
- file=sys.stderr,
383
- )
384
- return 2
385
-
386
- if args.deft_root is None:
387
- # Default: the directory containing scripts/ (this file's parent's
388
- # parent). Mirrors the lookup pattern used by other framework scripts
389
- # invoked via ``uv run python <script>`` from a Taskfile target.
390
- deft_root = Path(__file__).resolve().parent.parent
391
- else:
392
- deft_root = Path(args.deft_root).resolve()
393
- if not deft_root.exists() or not deft_root.is_dir():
394
- print(
395
- f"ERROR: --deft-root does not exist or is not a directory: " f"{deft_root}",
396
- file=sys.stderr,
397
- )
398
- return 2
399
-
400
- code, results = evaluate(deft_root, project_root)
401
-
402
- for result in results:
403
- if args.quiet and result.status == "PASS":
404
- continue
405
- stream = sys.stderr if result.status == "FAIL" else sys.stdout
406
- print(_format_result(result), file=stream)
407
-
408
- if code != 0:
409
- print(
410
- "migrate:preflight FAILED -- resolve the FAIL line(s) above before "
411
- "re-running `task migrate:vbrief`.",
412
- file=sys.stderr,
413
- )
414
- return code
415
-
416
-
417
- if __name__ == "__main__":
418
- sys.exit(main())