@boyingliu01/xp-gate 0.41.10 → 0.41.56

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 (123) hide show
  1. package/adapters/gate-3.sh +28 -1
  2. package/adapters/gate-6-layers.sh +18 -1
  3. package/bin/xp-gate.js +13 -0
  4. package/gate-3.sh +28 -1
  5. package/gate-6-layers.sh +18 -1
  6. package/gates/python-health.ts +74 -26
  7. package/gates/test-layers.ts +94 -9
  8. package/hooks/gate-3.sh +28 -1
  9. package/hooks/gate-6-layers.sh +18 -1
  10. package/hooks/gate-entries/gate-11-entry.sh +21 -0
  11. package/hooks/gate-entries/gate-2-entry.sh +15 -0
  12. package/hooks/install.sh +15 -3
  13. package/hooks/pre-commit +90 -13
  14. package/hooks/pre-push +10 -1
  15. package/hooks/sprint-gate.sh +101 -13
  16. package/lib/check-alignment-runner.cjs +97 -0
  17. package/lib/check.js +6 -0
  18. package/lib/crap-cli.js +14 -6
  19. package/lib/delphi-setup.js +13 -0
  20. package/lib/doctor-tui.js +205 -102
  21. package/lib/doctor.js +283 -31
  22. package/lib/gate-runner.js +14 -3
  23. package/lib/init-install.js +299 -0
  24. package/lib/init-languages.js +158 -0
  25. package/lib/init-manifest.js +165 -0
  26. package/lib/init-md-injection.js +58 -0
  27. package/lib/init.js +134 -500
  28. package/lib/install-skill.js +66 -1
  29. package/lib/layer-baseline.cjs +94 -0
  30. package/lib/mattpocock-license-verdict.json +7 -0
  31. package/lib/uninstall-skills.js +140 -0
  32. package/lib/uninstall.js +41 -100
  33. package/lib/update-skill.js +9 -1
  34. package/package.json +3 -1
  35. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  36. package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
  37. package/plugins/claude-code/skills/delphi-review/INSTALL.md +22 -3
  38. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +1 -1
  39. package/plugins/claude-code/skills/sprint-flow/references/definition-of-done.md +2 -2
  40. package/plugins/claude-code/skills/sprint-flow/references/phase-3-build.md +1 -1
  41. package/plugins/claude-code/skills/sprint-flow/references/phase-4-verify.md +2 -2
  42. package/plugins/claude-code/skills/sprint-flow/references/phase-6-close.md +17 -0
  43. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
  44. package/plugins/dsh/lib/delphi-evidence.d.ts +59 -0
  45. package/plugins/dsh/lib/delphi-evidence.d.ts.map +1 -0
  46. package/plugins/dsh/lib/delphi-evidence.js +128 -0
  47. package/plugins/dsh/lib/delphi-finding.d.ts +123 -0
  48. package/plugins/dsh/lib/delphi-finding.d.ts.map +1 -0
  49. package/plugins/dsh/lib/delphi-finding.js +332 -0
  50. package/plugins/dsh/lib/delphi-findings-parse.d.ts +29 -0
  51. package/plugins/dsh/lib/delphi-findings-parse.d.ts.map +1 -0
  52. package/plugins/dsh/lib/delphi-findings-parse.js +138 -0
  53. package/plugins/dsh/lib/delphi-ledger.d.ts +55 -0
  54. package/plugins/dsh/lib/delphi-ledger.d.ts.map +1 -0
  55. package/plugins/dsh/lib/delphi-ledger.js +124 -0
  56. package/plugins/dsh/lib/delphi-run.d.ts +7 -0
  57. package/plugins/dsh/lib/delphi-run.d.ts.map +1 -1
  58. package/plugins/dsh/lib/delphi-run.js +48 -18
  59. package/plugins/dsh/lib/delphi-seats.d.ts +34 -0
  60. package/plugins/dsh/lib/delphi-seats.d.ts.map +1 -0
  61. package/plugins/dsh/lib/delphi-seats.js +40 -0
  62. package/plugins/dsh/lib/evidence.d.ts +21 -0
  63. package/plugins/dsh/lib/evidence.d.ts.map +1 -1
  64. package/plugins/dsh/lib/evidence.js +3 -0
  65. package/plugins/dsh/lib/index.d.ts.map +1 -1
  66. package/plugins/dsh/lib/index.js +12 -0
  67. package/plugins/dsh/package.json +1 -1
  68. package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
  69. package/plugins/dsh/skills/delphi-review/INSTALL.md +22 -3
  70. package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
  71. package/plugins/dsh/skills/sprint-flow/references/definition-of-done.md +2 -2
  72. package/plugins/dsh/skills/sprint-flow/references/phase-3-build.md +1 -1
  73. package/plugins/dsh/skills/sprint-flow/references/phase-4-verify.md +2 -2
  74. package/plugins/dsh/skills/sprint-flow/references/phase-6-close.md +17 -0
  75. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
  76. package/plugins/dsh/src/delphi-evidence.test.ts +100 -0
  77. package/plugins/dsh/src/delphi-evidence.ts +201 -0
  78. package/plugins/dsh/src/delphi-finding.test.ts +333 -0
  79. package/plugins/dsh/src/delphi-finding.ts +446 -0
  80. package/plugins/dsh/src/delphi-findings-parse.test.ts +100 -0
  81. package/plugins/dsh/src/delphi-findings-parse.ts +158 -0
  82. package/plugins/dsh/src/delphi-findings.test.ts +4 -0
  83. package/plugins/dsh/src/delphi-ledger.test.ts +210 -0
  84. package/plugins/dsh/src/delphi-ledger.ts +158 -0
  85. package/plugins/dsh/src/delphi-run.test.ts +71 -68
  86. package/plugins/dsh/src/delphi-run.ts +80 -24
  87. package/plugins/dsh/src/delphi-seats.test.ts +117 -0
  88. package/plugins/dsh/src/delphi-seats.ts +50 -0
  89. package/plugins/dsh/src/evidence-findings.test.ts +75 -0
  90. package/plugins/dsh/src/evidence.ts +25 -0
  91. package/plugins/dsh/src/index.ts +14 -0
  92. package/plugins/opencode/package.json +1 -1
  93. package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
  94. package/plugins/opencode/skills/delphi-review/INSTALL.md +22 -3
  95. package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
  96. package/plugins/opencode/skills/sprint-flow/references/definition-of-done.md +2 -2
  97. package/plugins/opencode/skills/sprint-flow/references/phase-3-build.md +1 -1
  98. package/plugins/opencode/skills/sprint-flow/references/phase-4-verify.md +2 -2
  99. package/plugins/opencode/skills/sprint-flow/references/phase-6-close.md +17 -0
  100. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
  101. package/plugins/qoder/plugin.json +1 -1
  102. package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
  103. package/plugins/qoder/skills/delphi-review/INSTALL.md +22 -3
  104. package/plugins/qoder/skills/sprint-flow/AGENTS.md +1 -1
  105. package/plugins/qoder/skills/sprint-flow/references/definition-of-done.md +2 -2
  106. package/plugins/qoder/skills/sprint-flow/references/phase-3-build.md +1 -1
  107. package/plugins/qoder/skills/sprint-flow/references/phase-4-verify.md +2 -2
  108. package/plugins/qoder/skills/sprint-flow/references/phase-6-close.md +17 -0
  109. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
  110. package/principles/index.ts +50 -1
  111. package/scripts/delphi-config-read.cjs +43 -6
  112. package/scripts/delphi-external-review.cjs +69 -12
  113. package/scripts/delphi-prompts.cjs +47 -1
  114. package/skills/delphi-review/AGENTS.md +1 -1
  115. package/skills/delphi-review/INSTALL.md +22 -3
  116. package/skills/sprint-flow/AGENTS.md +1 -1
  117. package/skills/sprint-flow/references/definition-of-done.md +2 -2
  118. package/skills/sprint-flow/references/phase-3-build.md +1 -1
  119. package/skills/sprint-flow/references/phase-4-verify.md +2 -2
  120. package/skills/sprint-flow/references/phase-6-close.md +17 -0
  121. package/skills/test-specification-alignment/AGENTS.md +1 -1
  122. package/sprint-gate.sh +101 -13
  123. package/mutation/stryker-types.ts +0 -14
package/hooks/pre-commit CHANGED
@@ -1,6 +1,13 @@
1
1
  #!/bin/bash
2
2
  _LE_CR=$(tr -cd '\r' < "$0" | wc -c | tr -d '[:space:]'); test "${_LE_CR:-0}" -eq 0 || { printf '%s\n' "======================================================================" "FATAL: hook has CRLF line endings -- bash cannot parse it (#546)." " file: $0" " fix : tr -d '\\r' < \"$0\" > \"$0.tmp\" && mv \"$0.tmp\" \"$0\" && chmod +x \"$0\"" "Or re-sync the installed copy: xp-gate doctor --sync-hooks" "======================================================================" >&2; exit 1; }
3
3
  #
4
+ # shellcheck disable=SC2329,SC2034
5
+ # The directive has to sit immediately above the code it applies to, so the SC2329
6
+ # sites (the gate bodies, dispatched by name from githooks/gate-driver.sh via
7
+ # XP_GATE_ORDER) and the SC2034 ones (read by that driver or a sourced helper) each
8
+ # carry their own suppression. Repeating it 24 times is noise; this note is here so
9
+ # the next reader knows why every one of those functions says "never invoked".
10
+ #
4
11
  # The line above is the #546 line-ending self-check. It MUST stay on the first
5
12
  # executable line, as a SINGLE physical line, using no construct whose keyword
6
13
  # needs a line boundary. All three are load-bearing:
@@ -190,6 +197,7 @@ _resolve_coverage_threshold() {
190
197
  case "$_rct_value" in
191
198
  ''|*[!0-9]*) _rct_value="80"; _rct_src="default (no coverage threshold declared)" ;;
192
199
  esac
200
+ # shellcheck disable=SC2034 # dispatched by name from gate-driver.sh / read by a sourced helper
193
201
  COVERAGE_THRESHOLD_SOURCE="$_rct_src"
194
202
  printf '%s' "$_rct_value"
195
203
  }
@@ -199,6 +207,7 @@ _resolve_coverage_threshold() {
199
207
  # single commit. A field that is always blank is worse than a missing one -- it
200
208
  # looks populated and says nothing. Call the function in this shell instead.
201
209
  _resolve_coverage_threshold >/dev/null
210
+ # shellcheck disable=SC2034 # dispatched by name from gate-driver.sh / read by a sourced helper
202
211
  COVERAGE_THRESHOLD="$_rct_value"
203
212
 
204
213
  # Tier lookups delegate to the generated projection (schema 2).
@@ -289,7 +298,9 @@ if ! declare -F run_without_git_context >/dev/null 2>&1; then
289
298
  fi
290
299
  # END GIT CONTEXT FALLBACK
291
300
 
301
+ # shellcheck disable=SC2034 # dispatched by name from gate-driver.sh / read by a sourced helper
292
302
  PROJECT_GITHOOKS="$(run_without_git_context git rev-parse --show-toplevel 2>/dev/null)/githooks"
303
+ # shellcheck disable=SC2034 # dispatched by name from gate-driver.sh / read by a sourced helper
293
304
  GATES_DIR="$SCRIPT_DIR/gates"
294
305
 
295
306
  # ADAPTER_DIR decides which tree every later lookup searches, so its ORDER comes
@@ -322,6 +333,7 @@ source "$ADAPTER_DIR/adapter-common.sh" 2>/dev/null || {
322
333
  # #505: the ORDER is not written here. HOOK_ADAPTER_TIERS is generated from
323
334
  # src/npm-package/lib/hook-module-resolution.js, which doctor.js reads directly,
324
335
  # so the hook and the diagnostic cannot disagree about which file wins.
336
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
325
337
  resolve_adapter_path() {
326
338
  # ADAPTER templates carry the extension ("{name}.sh"), so pass the bare language
327
339
  # name here. GATE templates are "{name}", so their call passes the full filename.
@@ -350,6 +362,7 @@ resolve_adapter_path() {
350
362
  # This replaces `[ "$CURRENT_LANG" = "python" ]` in the test phase, which could
351
363
  # only ever cover a language someone remembered to name (#794 records that
352
364
  # pattern already being applied twice, once per language).
365
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
353
366
  adapter_declares_coverage_runs_tests() {
354
367
  local scope="${1:-}"
355
368
  if [ -n "$scope" ]; then
@@ -382,6 +395,7 @@ adapter_declares_coverage_runs_tests() {
382
395
  #
383
396
  # What the declaration must NOT do is make the skip silent. Callers report where
384
397
  # the suite actually runs; see gate-5's delegation branch.
398
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
385
399
  adapter_delegates_tests_to_ci() {
386
400
  local scope="${1:-}"
387
401
  if [ -n "$scope" ]; then
@@ -398,6 +412,7 @@ adapter_delegates_tests_to_ci() {
398
412
  }
399
413
 
400
414
  # Where a delegating adapter's suite runs, for the report line.
415
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
401
416
  adapter_test_delegation_target() {
402
417
  if command -v tests_delegated_to_ci_target >/dev/null 2>&1; then
403
418
  local target
@@ -437,19 +452,25 @@ fi
437
452
  # Using a guard prevents recursion when 'exit' is called from inside the trap.
438
453
  # IMPORTANT: Captures exit status FIRST so generate_quality_report cannot override it.
439
454
  _QUALITY_REPORT_DONE=0
455
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
440
456
  _quality_report_on_exit() {
441
457
  local _saved_exit=$?
442
458
  if [ "$_QUALITY_REPORT_DONE" = "1" ]; then
443
- exit $_saved_exit
459
+ exit "$_saved_exit"
444
460
  return
445
461
  fi
446
462
  _QUALITY_REPORT_DONE=1
447
463
  command -v generate_quality_report >/dev/null 2>&1 && generate_quality_report 2>/dev/null || true
448
- exit $_saved_exit
464
+ exit "$_saved_exit"
449
465
  }
450
466
  trap '_quality_report_on_exit' EXIT
451
467
 
452
- PROJECT_ROOT="$(run_without_git_context git rev-parse --show-toplevel 2>/dev/null || echo "$(cd "$SCRIPT_DIR/../.." 2>/dev/null || echo "$SCRIPT_DIR/..")" )"
468
+ _xp_toplevel="$(run_without_git_context git rev-parse --show-toplevel 2>/dev/null || true)"
469
+ if [ -z "$_xp_toplevel" ]; then
470
+ _xp_toplevel="$(cd "$SCRIPT_DIR/../.." 2>/dev/null && pwd || echo "$SCRIPT_DIR/..")"
471
+ fi
472
+ PROJECT_ROOT="$_xp_toplevel"
473
+ unset _xp_toplevel
453
474
  if [[ -d "$PROJECT_ROOT/node_modules/.bin" ]]; then
454
475
  export PATH="$PROJECT_ROOT/node_modules/.bin:$PATH"
455
476
  fi
@@ -489,6 +510,40 @@ if git rev-parse --git-dir >/dev/null 2>&1; then
489
510
  unset _xp_qqp
490
511
  fi
491
512
 
513
+ # ---- RE-ENTRY GUARD (#823)
514
+ #
515
+ # This hook can end up running inside itself. Measured on Windows with a global
516
+ # `core.hooksPath`: a commit stopped at Gate 5 and never returned -- 1h45m, no
517
+ # output, no verdict -- and the process tree showed pre-commit three levels deep:
518
+ #
519
+ # pid 20628 git commit -q -F -
520
+ # └ pid 6440 bash .../hooks/pre-commit
521
+ # └ pid 19624 bash .../hooks/pre-commit
522
+ # └ pid 12032 bash .../hooks/pre-commit
523
+ #
524
+ # The audit journal held every gate except gate-5, which never finished.
525
+ #
526
+ # The trigger was never identified, and this guard deliberately does not need to be
527
+ # it: a hook that can re-enter itself has NO BOUND on its runtime, so the bound is
528
+ # worth having on its own. A refusal in one line is a diagnosis; an afternoon of
529
+ # silence is not.
530
+ #
531
+ # The depth is EXPORTED because the whole mechanism is the value reaching the next
532
+ # process -- an unexported counter resets to 0 in every child and bounds nothing.
533
+ #
534
+ # Escape hatch: XP_GATE_ALLOW_NESTED_HOOKS=1 runs the chain anyway. It exists for a
535
+ # caller that legitimately runs the gates from inside a commit (the Gate 5 fixtures
536
+ # do), and it is opt-in so the default stays safe.
537
+ XP_GATE_HOOK_DEPTH=$(( ${XP_GATE_HOOK_DEPTH:-0} + 1 ))
538
+ export XP_GATE_HOOK_DEPTH
539
+ if [ "$XP_GATE_HOOK_DEPTH" -gt 1 ] && [ "${XP_GATE_ALLOW_NESTED_HOOKS:-0}" != "1" ]; then
540
+ echo "❌ pre-commit is already running (re-entry depth $XP_GATE_HOOK_DEPTH)." >&2
541
+ echo " This hook invoked itself; refusing to recurse. The outer run decides the verdict." >&2
542
+ echo " If you are testing the gates from inside a commit, set XP_GATE_ALLOW_NESTED_HOOKS=1." >&2
543
+ exit 1
544
+ fi
545
+ # ---- END RE-ENTRY GUARD
546
+
492
547
  # ============================================================================
493
548
  # Helper Functions
494
549
  # ============================================================================
@@ -500,6 +555,7 @@ fi
500
555
  # keep npx as fallback for consumer repos relying on a global install.
501
556
  # RUN_TSX_TIMEOUT (e.g. "120s") wraps the invocation in `timeout`.
502
557
  if ! declare -F run_tsx >/dev/null 2>&1; then
558
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
503
559
  run_tsx() {
504
560
  local _root="${PROJECT_ROOT:-$(pwd)}" _timeout=()
505
561
  if [ -n "${RUN_TSX_TIMEOUT:-}" ]; then
@@ -538,6 +594,7 @@ fi
538
594
  # answer. Every detection site uses it; real runs keep the npx fallback, so a
539
595
  # project relying on a global toolchain behaves as before.
540
596
  if ! declare -F run_node_bin >/dev/null 2>&1; then
597
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
541
598
  run_node_bin() {
542
599
  local _probe=0
543
600
  if [ "$1" = "--probe" ]; then
@@ -565,6 +622,7 @@ fi
565
622
  # Parse LCOV file and return coverage percentage
566
623
  # Usage: parse_lcov_coverage <lcov_file>
567
624
  # Returns: coverage percentage (e.g., "85.5")
625
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
568
626
  parse_lcov_coverage() {
569
627
  local lcov_file="$1"
570
628
  local total_lines=0
@@ -579,10 +637,10 @@ parse_lcov_coverage() {
579
637
  while IFS= read -r line; do
580
638
  case "$line" in
581
639
  LF:*)
582
- total_lines=$(echo "$line" | sed 's/LF://')
640
+ total_lines="${line//LF:/}"
583
641
  ;;
584
642
  LH:*)
585
- covered_lines=$(echo "$line" | sed 's/LH://')
643
+ covered_lines="${line//LH:/}"
586
644
  ;;
587
645
  esac
588
646
  done < "$lcov_file"
@@ -609,6 +667,7 @@ parse_lcov_coverage() {
609
667
 
610
668
  # Run command in subdirectory if PROJECT_SUBDIR is set
611
669
  # Usage: run_in_subdir <command>
670
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
612
671
  run_in_subdir() {
613
672
  local cmd="$1"
614
673
 
@@ -619,8 +678,8 @@ run_in_subdir() {
619
678
  if pushd "$PROJECT_SUBDIR" > /dev/null 2>&1; then
620
679
  eval "$cmd"
621
680
  local exit_code=$?
622
- popd > /dev/null 2>&1
623
- return $exit_code
681
+ popd > /dev/null 2>&1 || true
682
+ return "$exit_code"
624
683
  fi
625
684
  return 1
626
685
  else
@@ -632,6 +691,7 @@ run_in_subdir() {
632
691
 
633
692
  # Check if file exists in subdirectory
634
693
  # Usage: file_exists_in_subdir <filename>
694
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
635
695
  file_exists_in_subdir() {
636
696
  local filename="$1"
637
697
 
@@ -768,6 +828,7 @@ _MAX_DURATION_MS=$(node -e "try{const c=JSON.parse(require('fs').readFileSync('$
768
828
 
769
829
  # Get milliseconds timestamp (used by gates for duration measurement)
770
830
  # Issue #370: delegates to now_ms() — node-preferred, regex-validated, cross-platform
831
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
771
832
  gate_start_ms() {
772
833
  now_ms
773
834
  }
@@ -793,6 +854,7 @@ gate_start_ms() {
793
854
  # this file is that narrowing what a commit is checked against is a local
794
855
  # iteration tool, not something that reaches main.
795
856
  XP_GATE_ONLY_GATE_STATE=""
857
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
796
858
  gate_selection_active() {
797
859
  if [ -z "$XP_GATE_ONLY_GATE_STATE" ]; then
798
860
  if [ -n "${XP_GATE_ONLY_GATE:-}" ]; then
@@ -806,6 +868,7 @@ gate_selection_active() {
806
868
 
807
869
  # True when gate $1 should run in this invocation. Empty XP_GATE_ONLY_GATE means
808
870
  # "run everything", which is the only state a real commit should be in.
871
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
809
872
  gate_enabled() {
810
873
  gate_selection_active || return 0
811
874
  case ",${XP_GATE_ONLY_GATE//[[:space:]]/}," in
@@ -829,6 +892,7 @@ gate_enabled() {
829
892
  # is reachable ONLY by a gate that actually passed (PASS / WARN /
830
893
  # PASS_WITH_WARNINGS) with no skip reason attached.
831
894
  # ---------------------------------------------------------------------------
895
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
832
896
  classify_coverage_reason() {
833
897
  local reason="${1:-}"
834
898
  local gate_status="${2:-}"
@@ -862,6 +926,7 @@ classify_coverage_reason() {
862
926
  # from the CURRENTLY CHANGED files, not from a static inventory of the repo, so
863
927
  # a docs-only commit legitimately yields an empty set. Reporting the matrix
864
928
  # without this provenance would repeat the sin the matrix exists to fix.
929
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
865
930
  resolve_languages_source() {
866
931
  local override_langs="${1:-}"
867
932
  local config_langs="${2:-}"
@@ -894,6 +959,7 @@ resolve_languages_source() {
894
959
  # language, and "no reason" + PASS status is precisely what `covered` means.
895
960
  # The scalar only speaks for every language when there is no detail at all
896
961
  # (config-missing / bash<4 paths).
962
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
897
963
  coverage_g6_reason_for() {
898
964
  local lang="${1:-}"
899
965
  local detail="${GATE_6_LANG_REASONS:-}"
@@ -923,6 +989,7 @@ coverage_g6_reason_for() {
923
989
  # Output is a comma-separated list of "name":N pairs WITHOUT surrounding braces,
924
990
  # so the caller can splice it into the report heredoc next to the other
925
991
  # fragments. Empty output when nothing was measured.
992
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
926
993
  gate_timings_json() {
927
994
  local name out=""
928
995
  # Sort by duration descending: the list's natural reader is "what is costing
@@ -941,6 +1008,7 @@ gate_timings_json() {
941
1008
  # Audit helper — records gate execution to .xp-gate/audit.jsonl
942
1009
  # NEVER blocks commit on failure (try/catch around npx tsx).
943
1010
  # Usage: record_gate_audit <gate_id> <gate_name> <passed> <issues_found> <start_ms>
1011
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
944
1012
  record_gate_audit() {
945
1013
  local gate_id="$1"
946
1014
  local gate_name="$2"
@@ -1075,6 +1143,17 @@ record_gate_audit() {
1075
1143
  if [ ! -f "$_audit_cli" ] || [ ! -f "$_local_tsx" ]; then
1076
1144
  return 0
1077
1145
  fi
1146
+ # Optional flags go through an ARRAY: the previous form expanded unquoted
1147
+ # variables, so a value containing a space became two arguments -- and shellcheck
1148
+ # flagged all three. An array carries "no flag" as zero elements, which is what
1149
+ # those `:-}` guards were trying to express.
1150
+ local -a _extra_args=()
1151
+ [ -n "${duration_anomaly_flag:-}" ] && _extra_args+=("$duration_anomaly_flag")
1152
+ [ -n "${duration_reason_flag:-}" ] && _extra_args+=("$duration_reason_flag")
1153
+ [ -n "${_XP_GATE_ATTEMPT:-}" ] && _extra_args+=(--attempt "$_XP_GATE_ATTEMPT")
1154
+ [ -n "${detail:-}" ] && _extra_args+=(--detail "$detail")
1155
+ [ -n "${gate_status_arg:-}" ] && _extra_args+=("$gate_status_arg")
1156
+
1078
1157
  {
1079
1158
  timeout 30 "$_local_tsx" "$_audit_cli" record \
1080
1159
  --gate-id "$gate_id" \
@@ -1082,12 +1161,8 @@ record_gate_audit() {
1082
1161
  --passed "$gate_result" \
1083
1162
  --issues-found "$issues_found" \
1084
1163
  --duration-ms "$duration_ms" \
1085
- $duration_anomaly_flag \
1086
- $duration_reason_flag \
1164
+ "${_extra_args[@]}" \
1087
1165
  --trigger commit \
1088
- ${_XP_GATE_ATTEMPT:+--attempt "$_XP_GATE_ATTEMPT"} \
1089
- ${detail:+--detail "$detail"} \
1090
- $gate_status_arg \
1091
1166
  2>/dev/null
1092
1167
  } &
1093
1168
  disown 2>/dev/null || true
@@ -1105,6 +1180,7 @@ record_gate_audit() {
1105
1180
  # The trap catches the failure on its way OUT rather than adding a record call to
1106
1181
  # all 76 branches, which would rot the first time someone adds branch 77.
1107
1182
  _BLOCKING_RECORDED=""
1183
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
1108
1184
  _record_blocking_exit() {
1109
1185
  local rc=$?
1110
1186
  # 0 = success, nothing to journal.
@@ -1218,6 +1294,7 @@ _record_blocking_exit() {
1218
1294
  # The wrapper below runs the journal first (it needs the exit status before
1219
1295
  # anything else can change $?) and then hands control back to the report trap,
1220
1296
  # which performs the actual exit.
1297
+ # shellcheck disable=SC2329 # dispatched by name from gate-driver.sh / read by a sourced helper
1221
1298
  _xp_gate_on_exit() {
1222
1299
  local _rc=$?
1223
1300
  _record_blocking_exit
@@ -1266,7 +1343,7 @@ _xp_gate_run_chain
1266
1343
  # that the post-commit hook checks to detect --no-verify bypasses
1267
1344
  _wp_marker="$(git rev-parse --git-dir 2>/dev/null)/xp-gate-precommit-marker"
1268
1345
  if [ -n "$_wp_marker" ] && [ "$_wp_marker" != "/xp-gate-precommit-marker" ]; then
1269
- echo "$(date +%s)" > "$_wp_marker"
1346
+ date +%s > "$_wp_marker"
1270
1347
  fi
1271
1348
 
1272
1349
  generate_quality_report
package/hooks/pre-push CHANGED
@@ -1561,7 +1561,16 @@ else
1561
1561
  UI_DETECTION=$(echo "$PUSHED_FILES" | npx -y tsx src/npm-package/lib/ui-detector.ts --push-mode --from-stdin 2>/dev/null)
1562
1562
  UI_DETECT_EXIT=$?
1563
1563
 
1564
- if [ "$UI_DETECT_EXIT" -eq 0 ] && [ -n "$UI_DETECTION" ]; then
1564
+ # #893: the detector signals its VERDICT through the exit code --
1565
+ # `process.exit(result.isUiSprint ? 0 : 1)` -- so exit 1 means "I looked, and
1566
+ # this is not a UI sprint". It is an ANSWER. Reading it as "no answer" sent
1567
+ # every non-UI push into the path-based fallback, which is a conservative
1568
+ # substitute meant for a detector that could not run at all.
1569
+ #
1570
+ # The distinction that matters is whether it PRINTED a verdict, not whether it
1571
+ # exited 0. Exit 0 or 1 with a JSON object on stdout is an answer; anything
1572
+ # else (no output, unparseable output, a loader crash) is not.
1573
+ if [ -n "$UI_DETECTION" ]; then
1565
1574
  IS_UI_SPRINT=$(echo "$UI_DETECTION" | jq -r 'if type == "object" then (.isUiSprint | tostring) else "unknown" end' 2>/dev/null)
1566
1575
  else
1567
1576
  IS_UI_SPRINT=""
@@ -176,6 +176,48 @@ read_phase() {
176
176
 
177
177
  # --- Helper: read delphi verdict ---
178
178
  # Returns verdict string or empty if unreadable
179
+ # --- Helper: an ISO-8601 timestamp as epoch seconds, or empty ---
180
+ # Extracted from read_sprint_age_days so the verdict-vs-sprint comparison (#807) parses
181
+ # dates the same way the age check does. Two parsers would be two chances to disagree.
182
+ iso_to_epoch() {
183
+ local iso="$1"
184
+ [ -n "$iso" ] && [ "$iso" != "null" ] || { echo ""; return; }
185
+ local epoch=""
186
+ # GNU date first, BSD date second, node last.
187
+ epoch=$(date -u -d "$iso" +%s 2>/dev/null || true)
188
+ if [ -z "$epoch" ]; then epoch=$(date -u -j -f "%Y-%m-%dT%H:%M:%S" "${iso%%.*}Z" +%s 2>/dev/null || true); fi
189
+ if [ -z "$epoch" ] && command -v node >/dev/null 2>&1; then
190
+ epoch=$(node -e "const t=Date.parse(process.argv[1]); if(Number.isFinite(t)) console.log(Math.floor(t/1000))" "$iso" 2>/dev/null || true)
191
+ fi
192
+ echo "$epoch"
193
+ }
194
+
195
+ # --- Helper: does the approval belong to the CURRENT sprint? (#807) ---
196
+ # Prints "yes", "no", or "unknown". An approval dated BEFORE the sprint started belongs to
197
+ # a previous sprint and endorses nothing: measured in a consumer repo, a verdict from 22
198
+ # days before the sprint licensed `checks-passed` on every commit afterwards, and the
199
+ # message told the user their change had been reviewed.
200
+ #
201
+ # "unknown" is returned rather than "yes" when either date is unreadable, so the caller can
202
+ # refuse instead of assuming the approval is current.
203
+ approval_is_current() {
204
+ local sprint_started approved_at start_epoch approved_epoch
205
+ sprint_started=$(json_extract "$SPRINT_STATE_JSON" '.started_at // ""' 2>/dev/null || echo "")
206
+ approved_at=$(json_extract "$APPROVED_FILE" '.timestamp // ""' 2>/dev/null || echo "")
207
+ if [ -z "$sprint_started" ] || [ -z "$approved_at" ] \
208
+ || [ "$sprint_started" = "null" ] || [ "$approved_at" = "null" ]; then
209
+ echo "unknown"
210
+ return
211
+ fi
212
+ start_epoch=$(iso_to_epoch "$sprint_started")
213
+ approved_epoch=$(iso_to_epoch "$approved_at")
214
+ if [ -z "$start_epoch" ] || [ -z "$approved_epoch" ]; then
215
+ echo "unknown"
216
+ return
217
+ fi
218
+ if [ "$approved_epoch" -lt "$start_epoch" ]; then echo "no"; else echo "yes"; fi
219
+ }
220
+
179
221
  read_verdict() {
180
222
  if [ ! -f "$APPROVED_FILE" ]; then
181
223
  echo ""
@@ -219,7 +261,23 @@ read_sprint_age_days() {
219
261
  if [ -z "$started" ] || [ "$started" = "null" ]; then
220
262
  started=$(json_extract "$SPRINT_STATE_JSON" '.updated_at // ""' 2>/dev/null || echo "")
221
263
  fi
264
+ # #865: last resort is the state file's own mtime. Without it, a state file
265
+ # written before started_at existed reports "age unknown" forever -- and the
266
+ # measured case was a sprint untouched for over a year whose age could not be
267
+ # computed from the file that had been sitting there unmodified the whole time.
268
+ #
269
+ # mtime is a LOWER bound on idleness, not an exact start: an edit to the file
270
+ # resets it. That is the honest reading -- "nothing has touched this sprint's
271
+ # state since then" -- and it is strictly better than "unknown".
222
272
  if [ -z "$started" ] || [ "$started" = "null" ]; then
273
+ local mtime_epoch now_epoch
274
+ mtime_epoch=$(stat -c %Y "$SPRINT_STATE_JSON" 2>/dev/null || stat -f %m "$SPRINT_STATE_JSON" 2>/dev/null || echo "")
275
+ now_epoch=$(date +%s 2>/dev/null || echo "")
276
+ if [ -n "$mtime_epoch" ] && [ -n "$now_epoch" ] \
277
+ && [ "$mtime_epoch" -gt 0 ] 2>/dev/null && [ "$now_epoch" -gt 0 ] 2>/dev/null; then
278
+ echo $(( (now_epoch - mtime_epoch) / 86400 ))
279
+ return
280
+ fi
223
281
  echo ""
224
282
  return
225
283
  fi
@@ -251,6 +309,20 @@ read_sprint_age_days() {
251
309
  # enough that the reported 12-day case is caught within two days of it firing.
252
310
  SPRINT_STALE_DAYS="${SPRINT_STALE_DAYS:-14}"
253
311
 
312
+ # Whether the sprint looks abandoned (#551, reordered by #865).
313
+ #
314
+ # Sets SPRINT_AGE_DAYS as a side effect, because the caller reports it. Returns 0
315
+ # when the sprint is stale, 1 otherwise -- including when the age is unknown, since
316
+ # an unmeasurable sprint is not evidence of staleness.
317
+ sprint_is_stale() {
318
+ SPRINT_STATUS=$(read_sprint_status)
319
+ SPRINT_AGE_DAYS=$(read_sprint_age_days)
320
+ [ "$SPRINT_STATUS" = "in_progress" ] || return 1
321
+ [ -n "$SPRINT_AGE_DAYS" ] || return 1
322
+ [ "$SPRINT_AGE_DAYS" -ge "$SPRINT_STALE_DAYS" ] 2>/dev/null || return 1
323
+ return 0
324
+ }
325
+
254
326
  # --- Pre-commit mode ---
255
327
  if [ "$MODE" = "pre-commit" ]; then
256
328
  PHASE=$(read_phase)
@@ -267,6 +339,22 @@ if [ "$MODE" = "pre-commit" ]; then
267
339
 
268
340
  # Phase >= 1 means PLAN is completed — delphi-review must be APPROVED
269
341
  if [ "$PHASE" -ge 1 ] 2>/dev/null; then
342
+ # #865: staleness FIRST, before any approval check.
343
+ #
344
+ # This block used to sit after them, so it was only reachable when
345
+ # delphi-reviewed.json existed. A sprint abandoned a year ago but never
346
+ # approved therefore hit "delphi-review not APPROVED" and was DENIED -- the
347
+ # same hard block a sprint opened this morning gets. #551 had already fixed the
348
+ # opposite error (zombie reading as PASS); this is that fix's other side, and
349
+ # the `skip` it should give was unreachable between the two.
350
+ #
351
+ # Ordering is the whole fix: "nobody is driving this sprint" is a fact about
352
+ # the sprint, and it does not become false because an approval file is missing.
353
+ if sprint_is_stale; then
354
+ echo "{\"decision\":\"skip\",\"reason\":\"STALE SPRINT: status=in_progress for ${SPRINT_AGE_DAYS} days (threshold ${SPRINT_STALE_DAYS}) — not certifying it. Finish it (sprint-flow close) or clear .sprint-state/sprint-state.json\"}"
355
+ exit 0
356
+ fi
357
+
270
358
  # Check if delphi-reviewed.json exists
271
359
  if [ ! -f "$APPROVED_FILE" ]; then
272
360
  echo '{"decision":"deny","reason":"delphi-review not APPROVED. Complete Phase 1 before committing code changes."}'
@@ -291,21 +379,21 @@ if [ "$MODE" = "pre-commit" ]; then
291
379
  echo "{\"decision\":\"deny\",\"reason\":\"delphi-review verdict is '${VERDICT}', not APPROVED. Fix issues and re-run: /delphi-review\"}"
292
380
  exit 1
293
381
  fi
294
-
295
- # #551: staleness. A sprint left at status=in_progress past the threshold is
296
- # abandoned, not validated -- reporting PASS for it means the gate cannot
297
- # distinguish an advancing sprint from a forgotten one, and it injects
298
- # ancient phase_history into every unrelated commit's audit trail. SKIP is
299
- # the honest answer: the gate declines to certify a sprint nobody is
300
- # driving, without blocking work that has nothing to do with it.
301
- SPRINT_STATUS=$(read_sprint_status)
302
- SPRINT_AGE_DAYS=$(read_sprint_age_days)
303
- if [ "$SPRINT_STATUS" = "in_progress" ] && [ -n "$SPRINT_AGE_DAYS" ] \
304
- && [ "$SPRINT_AGE_DAYS" -ge "$SPRINT_STALE_DAYS" ] 2>/dev/null; then
305
- echo "{\"decision\":\"skip\",\"reason\":\"STALE SPRINT: status=in_progress for ${SPRINT_AGE_DAYS} days (threshold ${SPRINT_STALE_DAYS}) — not certifying it. Finish it (sprint-flow close) or clear .sprint-state/sprint-state.json\"}"
306
- exit 0
382
+ # #807: the approval must belong to THIS sprint. The verdict file is not cleared when
383
+ # a sprint closes, so a leftover APPROVED endorsed every commit afterwards with the
384
+ # message "delphi-review APPROVED" -- and nothing downstream could notice, because the
385
+ # gate reported success.
386
+ APPROVAL_CURRENT=$(approval_is_current)
387
+ if [ "$APPROVAL_CURRENT" != "yes" ]; then
388
+ echo "{\"decision\":\"deny\",\"reason\":\"delphi-reviewed.json ${APPROVAL_CURRENT} a current approval: verdict=${VERDICT}, approval timestamp=$(json_extract "$APPROVED_FILE" '.timestamp // \"(none)\"' 2>/dev/null), sprint started_at=$(json_extract "$SPRINT_STATE_JSON" '.started_at // \"(none)\"' 2>/dev/null). Re-run: /delphi-review\"}"
389
+ exit 1
307
390
  fi
308
391
 
392
+ # The staleness verdict was taken above, BEFORE the approval checks (#865).
393
+ # It is not repeated here: a second copy would be a second place to keep
394
+ # correct, and the reported defect was precisely this check living in the
395
+ # wrong spot.
396
+
309
397
  # All checks passed. Name the age so "validated" is not an unconditional
310
398
  # claim: a 29-day-old sprint under a 30-day threshold is a very different
311
399
  # situation from one opened today, and the log should say which it is.
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * check-alignment-runner.cjs — Thin argv shim for test-alignment.ts
4
+ *
5
+ * Bridges the `xp-gate check-alignment` CLI to the TypeScript engine without
6
+ * shell-command interpolation of user-supplied paths (#392-#6).
7
+ *
8
+ * It is designed to be launched EITHER way:
9
+ * 1. In-repo (fast path): `node` loads this file after xp-gate.js already
10
+ * called `require('tsx/cjs')`, so requiring `./test-alignment.ts` works.
11
+ * 2. Published global install (zero-install path): `npx -y tsx` runs this
12
+ * file, and npx self-provisions tsx on demand (never a package dep), so
13
+ * `./test-alignment.ts` loads even though the package ships zero deps.
14
+ *
15
+ * All user-supplied paths are passed as discrete argv elements, never embedded
16
+ * into a shell command string, preserving the #392-#6 injection fix.
17
+ */
18
+ 'use strict';
19
+
20
+ const { execFileSync } = require('child_process');
21
+
22
+ // --- argv parsing ----------------------------------------------------------
23
+ function argValue(argv, flag) {
24
+ const idx = argv.indexOf(flag);
25
+ return idx >= 0 && idx + 1 < argv.length ? argv[idx + 1] : undefined;
26
+ }
27
+ function argFlag(argv, flag) {
28
+ return argv.includes(flag);
29
+ }
30
+
31
+ const specPath = argValue(process.argv, '--spec');
32
+ const testDirsArg = argValue(process.argv, '--tests');
33
+ const outputPath = argValue(process.argv, '--output');
34
+ const jsonMode = argFlag(process.argv, '--json');
35
+
36
+ if (!specPath) {
37
+ console.error('check-alignment: --spec <path> is required');
38
+ process.exit(1);
39
+ }
40
+
41
+ const testDirs = testDirsArg ? [testDirsArg] : undefined;
42
+
43
+ let headCommit = 'unknown';
44
+ try {
45
+ headCommit = execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8' }).trim() || 'unknown';
46
+ } catch (err) {
47
+ headCommit = 'unknown';
48
+ }
49
+
50
+ const { runFullAlignment } = require('./test-alignment.ts');
51
+
52
+ let report;
53
+ try {
54
+ report = runFullAlignment({
55
+ specPath,
56
+ testDirs,
57
+ headCommit,
58
+ outputPath: outputPath || undefined,
59
+ });
60
+ } catch (err) {
61
+ console.error('check-alignment failed:', err instanceof Error ? err.message : String(err));
62
+ process.exit(1);
63
+ }
64
+
65
+ if (jsonMode) {
66
+ console.log(JSON.stringify(report, null, 2));
67
+ } else {
68
+ console.log('Status:', report.alignment_status);
69
+ console.log('Score:', report.score);
70
+ console.log('Misaligned:', report.misaligned_tests.length);
71
+
72
+ // #573 (recurrence of #57): a non-PASS verdict used to print only the status
73
+ // and counters. On a real run that read:
74
+ // Status: BLOCKED
75
+ // Score: 0
76
+ // Misaligned: 0
77
+ // which contradicts itself — zero misaligned tests, yet blocked — while the
78
+ // actual reason sat in report.errors that nothing ever printed. A gate that
79
+ // blocks without saying why is not actionable, and the usual response to an
80
+ // unactionable red is to bypass it, which is how dead gates are made.
81
+ if (report.alignment_status !== 'PASS') {
82
+ const reasons = Array.isArray(report.errors) ? report.errors : [];
83
+ if (reasons.length > 0) {
84
+ console.error('Reasons:');
85
+ for (const reason of reasons) console.error(' -', reason);
86
+ } else {
87
+ // Saying so is the point: a blocked verdict with no recorded reason is a
88
+ // defect in whoever produced the report, not something the reader can fix
89
+ // by editing their own files.
90
+ console.error('Reasons: (none recorded) — this is a bug in the report producer:');
91
+ console.error(' a non-PASS alignment verdict must carry at least one entry in report.errors.');
92
+ }
93
+ }
94
+ }
95
+ // Set exitCode instead of process.exit() so buffered stdout (notably the
96
+ // --json document) flushes fully before the process terminates (#392 review).
97
+ process.exitCode = report.alignment_status === 'PASS' ? 0 : 1;
package/lib/check.js CHANGED
@@ -166,6 +166,12 @@ function formatGateTally(tally) {
166
166
  if (tally.warned > 0) parts.push(`${tally.warned} warned`);
167
167
  if (tally.skipped > 0) parts.push(`${tally.skipped} skipped`);
168
168
  parts.push(`${tally.total} total`);
169
+ // #778: seven of seventeen surfaces are structurally absent from the CLI path, and a line
170
+ // reading `9 passed / 1 failed / 7 skipped / 17 total` still reads as a verdict. A skill
171
+ // running this in VERIFY had no way to tell that Code Quality, Tests, Build Integrity,
172
+ // Sprint Flow, File Hygiene and Compiler Strictness were never consulted. The skip COUNT is
173
+ // not enough -- it reads as an ordinary tally; the line has to say it measured a subset.
174
+ if (tally.skipped > 0) parts.push('partial — not a full-gate verdict');
169
175
  return parts.join(' / ');
170
176
  }
171
177
 
package/lib/crap-cli.js CHANGED
@@ -226,12 +226,14 @@ async function handleCrap(argv) {
226
226
 
227
227
  if (!opts.paths || !opts.paths.length) opts.paths = discoverSourcePaths();
228
228
 
229
- const csv = runLizard(opts.paths);
230
- if (csv === null) {
231
- console.error('✗ Could not run lizard. Install it with: pip install --user lizard');
232
- return 1;
233
- }
234
-
229
+ // #804: check the coverage artifact BEFORE scanning. The two have no data dependency --
230
+ // when coverage is absent this function returns 1 whatever lizard said -- and the scan is
231
+ // the expensive half.
232
+ //
233
+ // Measured 2026-11-11 on 8 cores at 20% load: `--paths` defaulting to `['src']` took
234
+ // 10.5 s (36.3 s on another run) and produced 9070 CSV rows that were discarded one line
235
+ // later. A missing coverage file is the MOST COMMON first-use path, so the wait landed
236
+ // on exactly the users with the least idea what was happening.
235
237
  if (!fs.existsSync(opts.coverage)) {
236
238
  // #858: name the artifact that WOULD have been accepted. A user on Node's own
237
239
  // runner is told "npx vitest run --coverage" and reasonably concludes CRAP
@@ -247,6 +249,12 @@ async function handleCrap(argv) {
247
249
  return 1;
248
250
  }
249
251
 
252
+ const csv = runLizard(opts.paths);
253
+ if (csv === null) {
254
+ console.error('✗ Could not run lizard. Install it with: pip install --user lizard');
255
+ return 1;
256
+ }
257
+
250
258
  const functions = parseLizardCsv(csv);
251
259
  const coverage = readFileCoverage(opts.coverage);
252
260
  const joined = joinCoverage(functions, coverage);
@@ -7,6 +7,7 @@
7
7
  // platform retired a model id. This command exists to rebind on purpose.
8
8
 
9
9
  const fs = require('fs');
10
+ const { nativeAgentDeploymentIsWanted, CHANNEL_ENV } = require('./delphi-channel.js');
10
11
  const path = require('path');
11
12
  const { HOME_DIR, CONFIG_DIR } = require('./shared-paths.js');
12
13
 
@@ -165,6 +166,18 @@ async function delphiSetup(args) {
165
166
  if (parsed.uninstall) return uninstallDelphiAgents(parsed.scope, parsed.projectDir);
166
167
  const { models, scope, projectDir } = parsed;
167
168
 
169
+ // #711: honour the machine-level channel preference BEFORE writing anything. A user
170
+ // on `{"channels": ["external"]}` has no use for native agent files -- they are not
171
+ // loaded, and writing them silently reverses an explicit decision. `init` and `doctor`
172
+ // already ask this question; this command is the one people run to REPAIR a binding,
173
+ // so it was the worst place to skip it: the repair reinstalled what they turned off.
174
+ if (!nativeAgentDeploymentIsWanted()) {
175
+ console.log('[delphi-setup] Native Delphi agents are disabled by the channels preference — nothing written.');
176
+ console.log(' To enable them again, set {"channels": ["native"]} (or ["native","external"])');
177
+ console.log(` in ${path.join(CONFIG_DIR, '.delphi-config.json')}, or unset ${CHANNEL_ENV}.`);
178
+ return 0;
179
+ }
180
+
168
181
  const templatesDir = path.join(__dirname, '..', 'plugins', 'qoder', 'agents');
169
182
  const targetDir = scope === 'local'
170
183
  ? path.join(projectDir, '.qoder', 'agents')