@feigi/fleet-ctl 0.0.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 (245) hide show
  1. package/.claude-plugin/plugin.json +9 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +18 -0
  4. package/agents/fleet-finisher.agent.md +7 -0
  5. package/agents/fleet-implementer-alt.agent.md +210 -0
  6. package/agents/fleet-implementer.agent.md +210 -0
  7. package/agents/fleet-merge-bot.agent.md +7 -0
  8. package/agents/fleet-review-comments.agent.md +40 -0
  9. package/agents/fleet-review-correctness.agent.md +43 -0
  10. package/agents/fleet-review-runner.agent.md +73 -0
  11. package/agents/fleet-review-silent-failure.agent.md +49 -0
  12. package/agents/fleet-review-simplify.agent.md +46 -0
  13. package/agents/fleet-review-snapshot.agent.md +24 -0
  14. package/agents/fleet-review-tests.agent.md +46 -0
  15. package/agents/fleet-review-types.agent.md +41 -0
  16. package/agents/fleet-review-verifier.agent.md +29 -0
  17. package/commands/review-and-fix.md +98 -0
  18. package/commands/run-merge-bot.md +357 -0
  19. package/commands/run-team-help.md +17 -0
  20. package/package.json +23 -0
  21. package/scripts/agent-test-dir-prose.test.mjs +59 -0
  22. package/scripts/agent-test.test.mjs +1636 -0
  23. package/scripts/ambient-git-vars-mjs-prose.test.mjs +354 -0
  24. package/scripts/ambient-git-vars-prose.test.mjs +192 -0
  25. package/scripts/ancestry-check-position-prose.test.mjs +175 -0
  26. package/scripts/apply-ruleset.test.mjs +420 -0
  27. package/scripts/arg-header-probes-prose.test.mjs +393 -0
  28. package/scripts/arg.mjs +600 -0
  29. package/scripts/arg.test.mjs +1354 -0
  30. package/scripts/board-cli.test.mjs +694 -0
  31. package/scripts/board-identity.test.mjs +429 -0
  32. package/scripts/board-liveness-banner.test.mjs +119 -0
  33. package/scripts/board-prev-shape.test.mjs +229 -0
  34. package/scripts/board-tryparse-null.test.mjs +119 -0
  35. package/scripts/board.html +471 -0
  36. package/scripts/board.mjs +2037 -0
  37. package/scripts/board.test.mjs +3086 -0
  38. package/scripts/brief-after-cut-prose.test.mjs +53 -0
  39. package/scripts/candidates-exit3-prose.test.mjs +302 -0
  40. package/scripts/candidates.mjs +674 -0
  41. package/scripts/candidates.test.mjs +2101 -0
  42. package/scripts/caveat-unification-prose.test.mjs +98 -0
  43. package/scripts/ci-comment-rot-prose.test.mjs +2025 -0
  44. package/scripts/ci-completes-premise-prose.test.mjs +257 -0
  45. package/scripts/ci-state-prose.test.mjs +113 -0
  46. package/scripts/ci-state.mjs +761 -0
  47. package/scripts/ci-state.test.mjs +1640 -0
  48. package/scripts/ci-vacuous-green.test.mjs +368 -0
  49. package/scripts/citation-sweep-prose.test.mjs +1572 -0
  50. package/scripts/claim-lifecycle.test.mjs +185 -0
  51. package/scripts/claim-ticket.sh +417 -0
  52. package/scripts/claim-ticket.test.mjs +1121 -0
  53. package/scripts/closing-keyword-prose.test.mjs +193 -0
  54. package/scripts/cockpit-launch-idempotent-prose.test.mjs +165 -0
  55. package/scripts/cockpit-tick-nonblocking.test.mjs +210 -0
  56. package/scripts/compute-board.mjs +579 -0
  57. package/scripts/compute-board.test.mjs +1060 -0
  58. package/scripts/compute-spend.mjs +329 -0
  59. package/scripts/compute-spend.test.mjs +451 -0
  60. package/scripts/cross-repo-citation-prose.test.mjs +156 -0
  61. package/scripts/cwd-isolation-pins.mjs +83 -0
  62. package/scripts/dedupe-guard-prose.test.mjs +243 -0
  63. package/scripts/derive-testcmd.sh +239 -0
  64. package/scripts/derive-testcmd.test.mjs +380 -0
  65. package/scripts/diff-stats.mjs +231 -0
  66. package/scripts/diff-stats.test.mjs +408 -0
  67. package/scripts/dispatch-block-golden-prose.test.mjs +1024 -0
  68. package/scripts/dispatch-block-pins-prose.test.mjs +615 -0
  69. package/scripts/drop-merged-label.sh +173 -0
  70. package/scripts/drop-merged-label.test.mjs +480 -0
  71. package/scripts/expected-jobs-prose.test.mjs +80 -0
  72. package/scripts/filing-bar-seat-prose.test.mjs +242 -0
  73. package/scripts/filing-claim-bar-prose.test.mjs +166 -0
  74. package/scripts/finisher-dispatch-premise-prose.test.mjs +312 -0
  75. package/scripts/finisher-halt-prose.test.mjs +106 -0
  76. package/scripts/finisher-name-prose.test.mjs +134 -0
  77. package/scripts/finisher-own-tree-prose.test.mjs +285 -0
  78. package/scripts/finisher-pin-race-prose.test.mjs +339 -0
  79. package/scripts/fix-applier-correction-rules-prose.test.mjs +201 -0
  80. package/scripts/fix-applier-result-file-prose.test.mjs +100 -0
  81. package/scripts/fleet-bootstrap +155 -0
  82. package/scripts/fleet-heartbeat.mjs +272 -0
  83. package/scripts/fleet-heartbeat.test.mjs +450 -0
  84. package/scripts/fleet-provenance +207 -0
  85. package/scripts/fleet-provenance.test.mjs +64 -0
  86. package/scripts/fleet-run +148 -0
  87. package/scripts/fleet-run.test.mjs +90 -0
  88. package/scripts/fleet-state.mjs +400 -0
  89. package/scripts/fleet-state.test.mjs +373 -0
  90. package/scripts/fleet-tick-prose.test.mjs +299 -0
  91. package/scripts/fleet-tick.mjs +832 -0
  92. package/scripts/fleet-tick.test.mjs +1332 -0
  93. package/scripts/force-with-lease-reason-prose.test.mjs +184 -0
  94. package/scripts/frontmatter-allowlist.json +64 -0
  95. package/scripts/frontmatter-check.mjs +256 -0
  96. package/scripts/frontmatter-check.test.mjs +436 -0
  97. package/scripts/git-env.mjs +124 -0
  98. package/scripts/git-env.test.mjs +149 -0
  99. package/scripts/git-status-untracked-mode-sweep.test.mjs +216 -0
  100. package/scripts/gone-walk.test.mjs +213 -0
  101. package/scripts/gp-sep-invariant-prose.test.mjs +188 -0
  102. package/scripts/head-moved-after-label-prose.test.mjs +233 -0
  103. package/scripts/immutable-body-claim-prose.test.mjs +413 -0
  104. package/scripts/implementer-model-tier.test.mjs +643 -0
  105. package/scripts/inflight-citation-prose.test.mjs +144 -0
  106. package/scripts/inflight-exit2-prose.test.mjs +81 -0
  107. package/scripts/inflight-probe-guard-prose.test.mjs +109 -0
  108. package/scripts/inflight-scan-scope-prose.test.mjs +57 -0
  109. package/scripts/inflight.sh +1106 -0
  110. package/scripts/inflight.test.mjs +2984 -0
  111. package/scripts/injection-control-prose.test.mjs +404 -0
  112. package/scripts/install-root-audit.test.mjs +464 -0
  113. package/scripts/instrument-check-prose.test.mjs +235 -0
  114. package/scripts/instruments.sh +394 -0
  115. package/scripts/instruments.test.mjs +787 -0
  116. package/scripts/issue-tracker-prose.test.mjs +71 -0
  117. package/scripts/json.sh +248 -0
  118. package/scripts/json.test.mjs +364 -0
  119. package/scripts/ledger-dispatch.test.mjs +516 -0
  120. package/scripts/ledger-grammar.mjs +85 -0
  121. package/scripts/ledger-grammar.test.mjs +142 -0
  122. package/scripts/ledger-read-require-file.test.mjs +197 -0
  123. package/scripts/ledger.mjs +1753 -0
  124. package/scripts/ledger.test.mjs +3554 -0
  125. package/scripts/line-distance-prose.test.mjs +245 -0
  126. package/scripts/liveness-rationale-prose.test.mjs +83 -0
  127. package/scripts/locale-pin-prose.test.mjs +189 -0
  128. package/scripts/member-outcome-prose.test.mjs +167 -0
  129. package/scripts/member-outcomes-header.test.mjs +148 -0
  130. package/scripts/member-outcomes-prose.test.mjs +63 -0
  131. package/scripts/member-outcomes.mjs +231 -0
  132. package/scripts/member-outcomes.test.mjs +507 -0
  133. package/scripts/member-prompt-prose.test.mjs +161 -0
  134. package/scripts/member-record.mjs +605 -0
  135. package/scripts/member-record.test.mjs +516 -0
  136. package/scripts/member-write-guard.mjs +279 -0
  137. package/scripts/member-write-guard.test.mjs +211 -0
  138. package/scripts/merge-commit-probe-prose.test.mjs +122 -0
  139. package/scripts/merge-gate.mjs +262 -0
  140. package/scripts/merge-gate.test.mjs +613 -0
  141. package/scripts/muted-git-guard-sweep.test.mjs +493 -0
  142. package/scripts/net-ssh-precedence-prose.test.mjs +91 -0
  143. package/scripts/net-watchdog-prose.test.mjs +79 -0
  144. package/scripts/net.sh +409 -0
  145. package/scripts/net.test.mjs +211 -0
  146. package/scripts/no-ci-gate-prose.test.mjs +108 -0
  147. package/scripts/no-undo-audit.sh +1134 -0
  148. package/scripts/no-undo-audit.test.mjs +3965 -0
  149. package/scripts/no-wave.test.mjs +138 -0
  150. package/scripts/node-floor-sweep.test.mjs +611 -0
  151. package/scripts/pointer-target-prose.test.mjs +186 -0
  152. package/scripts/pr-overlap.mjs +417 -0
  153. package/scripts/pr-overlap.test.mjs +695 -0
  154. package/scripts/printf-die-sweep.test.mjs +384 -0
  155. package/scripts/prompt-renderer.mjs +39 -0
  156. package/scripts/prompt-renderer.test.mjs +68 -0
  157. package/scripts/prose-pin.mjs +808 -0
  158. package/scripts/prose-pin.test.mjs +1034 -0
  159. package/scripts/prove-merge.sh +228 -0
  160. package/scripts/prove-merge.test.mjs +995 -0
  161. package/scripts/pull-table-relabel-prose.test.mjs +60 -0
  162. package/scripts/quiet-payload-prose.test.mjs +222 -0
  163. package/scripts/reap.sh +1768 -0
  164. package/scripts/reap.test.mjs +4395 -0
  165. package/scripts/reaping-prose.test.mjs +159 -0
  166. package/scripts/refuter-scratch-prose.test.mjs +135 -0
  167. package/scripts/release-label-required-prose.test.mjs +71 -0
  168. package/scripts/release-label-split-prose.test.mjs +169 -0
  169. package/scripts/release-ticket.sh +1716 -0
  170. package/scripts/release-ticket.test.mjs +5106 -0
  171. package/scripts/renovate-release-contract.test.mjs +379 -0
  172. package/scripts/repo-root.mjs +544 -0
  173. package/scripts/repo-root.test.mjs +873 -0
  174. package/scripts/reporter-output-rule-prose.test.mjs +208 -0
  175. package/scripts/review-agent-report-only.test.mjs +49 -0
  176. package/scripts/review-core-cwd-isolation.test.mjs +374 -0
  177. package/scripts/review-core-reads.test.mjs +478 -0
  178. package/scripts/review-core-refuter-scratch.test.mjs +148 -0
  179. package/scripts/review-core-snapshot-path.test.mjs +777 -0
  180. package/scripts/review-core-specialist-scratch.test.mjs +189 -0
  181. package/scripts/review-core-testcmd.test.mjs +288 -0
  182. package/scripts/review-core-unrun.test.mjs +530 -0
  183. package/scripts/review-core-unverified-discriminant.test.mjs +208 -0
  184. package/scripts/review-core.mjs +1028 -0
  185. package/scripts/review-eval-resolver-path.test.mjs +55 -0
  186. package/scripts/review-eval.mjs +197 -0
  187. package/scripts/review-host-fixture.mjs +73 -0
  188. package/scripts/review-in-run-retry.test.mjs +187 -0
  189. package/scripts/review-no-vendor-dispatch.test.mjs +45 -0
  190. package/scripts/review-path-default.test.mjs +796 -0
  191. package/scripts/review-runner-spawns.test.mjs +93 -0
  192. package/scripts/review-runner.test.mjs +155 -0
  193. package/scripts/review-tier-audit.test.mjs +140 -0
  194. package/scripts/run-artifact-pr-prose.test.mjs +341 -0
  195. package/scripts/run-merge-bot-prose.test.mjs +1391 -0
  196. package/scripts/scratch-partition-invariant-prose.test.mjs +74 -0
  197. package/scripts/scripts-path-citation-sweep.test.mjs +73 -0
  198. package/scripts/section-between-guard-prose.test.mjs +378 -0
  199. package/scripts/select-dimensions.test.mjs +674 -0
  200. package/scripts/shared-refusal.test.mjs +388 -0
  201. package/scripts/shell-traps-prose.test.mjs +507 -0
  202. package/scripts/shortlist.mjs +355 -0
  203. package/scripts/shortlist.test.mjs +366 -0
  204. package/scripts/slow-transport.mjs +72 -0
  205. package/scripts/snapshot-repo.test.mjs +772 -0
  206. package/scripts/snapshot-runner-audience-prose.test.mjs +129 -0
  207. package/scripts/spend-view.test.mjs +312 -0
  208. package/scripts/staleness-qualifier-prose.test.mjs +251 -0
  209. package/scripts/staleness-verdict-prose.test.mjs +142 -0
  210. package/scripts/staleness.mjs +414 -0
  211. package/scripts/staleness.test.mjs +893 -0
  212. package/scripts/stalled-member-liveness-prose.test.mjs +219 -0
  213. package/scripts/stash-prohibition-prose.test.mjs +313 -0
  214. package/scripts/strip-comments.mjs +44 -0
  215. package/scripts/tier-check.mjs +468 -0
  216. package/scripts/tier-check.test.mjs +726 -0
  217. package/scripts/tier-guard-gate-prose.test.mjs +216 -0
  218. package/scripts/tier-outcomes-header.test.mjs +586 -0
  219. package/scripts/tier-outcomes.mjs +441 -0
  220. package/scripts/tier-outcomes.test.mjs +342 -0
  221. package/scripts/tier-roles.mjs +250 -0
  222. package/scripts/tier-roles.test.mjs +316 -0
  223. package/scripts/tracker-block-copy-prose.test.mjs +288 -0
  224. package/scripts/triage-labels-gloss-prose.test.mjs +97 -0
  225. package/scripts/unattended-git-sweep.test.mjs +142 -0
  226. package/scripts/verify-sha-exit2-prose.test.mjs +269 -0
  227. package/scripts/verify-sha.sh +117 -0
  228. package/scripts/verify-sha.test.mjs +693 -0
  229. package/scripts/watcher-degraded-block.test.mjs +372 -0
  230. package/scripts/watcher-key-prose.test.mjs +106 -0
  231. package/scripts/within-run-pair-prose.test.mjs +208 -0
  232. package/scripts/worktree-audit.sh +482 -0
  233. package/scripts/worktree-audit.test.mjs +1407 -0
  234. package/scripts/worktree-head-prose.test.mjs +276 -0
  235. package/scripts/worktree-listing-sweep.test.mjs +217 -0
  236. package/scripts/worktree-model-prose.test.mjs +216 -0
  237. package/scripts/worktree.sh +470 -0
  238. package/skills/next-ticket/SKILL.md +138 -0
  239. package/skills/run-team/SKILL.md +3603 -0
  240. package/skills/run-team/references/ci-and-staleness.md +75 -0
  241. package/skills/run-team/references/correction-tickets.md +37 -0
  242. package/skills/run-team/references/isolation.md +23 -0
  243. package/skills/run-team/references/member-lifecycle.md +73 -0
  244. package/skills/run-team/references/reaping.md +73 -0
  245. package/skills/sizing-a-ticket/SKILL.md +39 -0
@@ -0,0 +1,64 @@
1
+ // The Provenance check's scripts/ digest (ADR 0021): it certifies the whole
2
+ // file set under `<Install root>/scripts`, so a subtree it cannot list must
3
+ // fail the digest rather than shrink it. Driven through the real CLI —
4
+ // fleet-provenance reads `os.homedir()` directly and `process.exit()`s.
5
+ //
6
+ // Every fixture's env is built from scratch (never `...process.env`), so
7
+ // these tests are deterministic regardless of the box they run on.
8
+ import { test } from "node:test";
9
+ import assert from "node:assert/strict";
10
+ import { spawnSync } from "node:child_process";
11
+ import { chmodSync, mkdtempSync, mkdirSync, writeFileSync, symlinkSync } from "node:fs";
12
+ import { tmpdir } from "node:os";
13
+ import { join } from "node:path";
14
+ import { fileURLToPath } from "node:url";
15
+
16
+ const PROVENANCE = fileURLToPath(new URL("./fleet-provenance", import.meta.url));
17
+
18
+ function runProvenance(home) {
19
+ return spawnSync(process.execPath, [PROVENANCE], {
20
+ encoding: "utf8",
21
+ env: { HOME: home, PATH: process.env.PATH },
22
+ });
23
+ }
24
+
25
+ // A marketplace-shaped install whose scripts/ holds a top-level file and one
26
+ // nested subdirectory, with the Resolver placed byte-identical to the
27
+ // installed copy so drift never decides the exit code.
28
+ function fakeInstall() {
29
+ const home = mkdtempSync(join(tmpdir(), "fleet-provenance-home-"));
30
+ const payload = join(home, ".omp", "plugins", "cache", "a");
31
+ const sub = join(payload, "scripts", "sub");
32
+ mkdirSync(sub, { recursive: true });
33
+ writeFileSync(join(payload, "scripts", "fleet-run"), "resolver\n");
34
+ writeFileSync(join(sub, "hidden.mjs"), "nested\n");
35
+ const nm = join(home, ".omp", "plugins", "node_modules");
36
+ mkdirSync(join(nm, "@feigi"), { recursive: true });
37
+ symlinkSync(payload, join(nm, "@feigi", "fleet-ctl"));
38
+ mkdirSync(join(home, ".fleet", "bin"), { recursive: true });
39
+ writeFileSync(join(home, ".fleet", "bin", "fleet-run"), "resolver\n");
40
+ return { home, sub };
41
+ }
42
+
43
+ test("a readable nested subdirectory is digested with the rest of scripts/", () => {
44
+ const { home } = fakeInstall();
45
+ const r = runProvenance(home);
46
+ assert.equal(r.status, 0, `expected success, got status ${r.status}: ${r.stdout}${r.stderr}`);
47
+ assert.match(r.stdout, /scripts\/ digest: sha256 [0-9a-f]{64} \(2 files\)/);
48
+ });
49
+
50
+ test("an unlistable nested subdirectory makes the digest UNAVAILABLE, never a shorter file set", (t) => {
51
+ if (process.platform === "win32" || process.getuid?.() === 0) {
52
+ t.skip("chmod 000 does not deny a directory listing here");
53
+ return;
54
+ }
55
+ const { home, sub } = fakeInstall();
56
+ chmodSync(sub, 0o000);
57
+ try {
58
+ const r = runProvenance(home);
59
+ assert.match(r.stdout, /scripts\/ digest: UNAVAILABLE — cannot list .*sub \(EACCES\)/);
60
+ assert.doesNotMatch(r.stdout, /scripts\/ digest: sha256/);
61
+ } finally {
62
+ chmodSync(sub, 0o755);
63
+ }
64
+ });
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env node
2
+ // The Resolver (#1335, ADR 0003, ADR 0014, ADR 0021, CONTEXT.md § Install
3
+ // "Resolver"). The single door between prose and an installed script: a prose
4
+ // callsite names a SCRIPT, never a path, and this reads omp's own extension
5
+ // package layout to find where that script actually lives right now.
6
+ //
7
+ // RESOLUTION POINT (ADR 0021): `~/.omp/plugins/node_modules/@feigi/fleet-ctl`. Every
8
+ // omp install kind — marketplace, `omp plugin link`, npm — places an entry
9
+ // there (a symlink for marketplace/link, a real directory for npm), and it is
10
+ // the only path common to all three. Its realpath IS the Install root. The
11
+ // marketplace-only `installed_plugins.json` registry is no longer read, so the
12
+ // old multi-entry / scope-ambiguity selection it needed is gone: a
13
+ // node_modules package dir is exactly one path.
14
+ //
15
+ // LANGUAGE CHOICE: node, not POSIX sh. Every other fleet script written in
16
+ // sh sources `json.sh` for JSON escaping because sh has no JSON support of
17
+ // its own; the resolution this file does is a symlink realpath plus (for
18
+ // callers that want the version) one small JSON, and `jq` is not a guaranteed
19
+ // CI dependency — node is (the whole test suite is `node --test`). node's
20
+ // `realpathSync` is exact and already required.
21
+ //
22
+ // SINGLE FILE, ON PURPOSE. `fleet-bootstrap` places a copy of exactly this
23
+ // file at `~/.fleet/bin/fleet-run`, OUTSIDE the plugin (CONTEXT.md's
24
+ // Resolver entry: "cannot resolve itself"). Once there it has no siblings —
25
+ // `scripts/repo-root.mjs`, `scripts/arg.mjs` and every other shared helper
26
+ // in this directory are unreachable from that path. So this file requires
27
+ // nothing from the rest of the plugin (CommonJS, core `node:*` modules
28
+ // only) even though `scripts/fleet-provenance` duplicates a couple of lines
29
+ // of its resolution logic rather than sharing a module with it, for the same
30
+ // reason: a module this file `require()`s would need to travel with it, and
31
+ // nothing else does.
32
+ "use strict";
33
+
34
+ const fs = require("node:fs");
35
+ const path = require("node:path");
36
+ const os = require("node:os");
37
+ const { spawnSync } = require("node:child_process");
38
+
39
+ const NAME = "fleet-run";
40
+ const PLUGIN_KEY = "@feigi/fleet-ctl"; // ADR 0006 name; ADR 0021 — the node_modules package dir, no longer a qualified registry key.
41
+
42
+ function die(message) {
43
+ process.stderr.write(`${NAME}: ${message}\n`);
44
+ process.exit(2);
45
+ }
46
+
47
+ // The Install root: realpath of `~/.omp/plugins/node_modules/@feigi/fleet-ctl`. Never
48
+ // throws — every failure mode (no entry, dangling symlink) is a die() naming
49
+ // the exact path it looked at, so a resolver failure is diagnosable from its
50
+ // own message.
51
+ function resolveInstall() {
52
+ const packagePath = path.join(os.homedir(), ".omp", "plugins", "node_modules", PLUGIN_KEY);
53
+ let isLink = false;
54
+ try {
55
+ isLink = fs.lstatSync(packagePath).isSymbolicLink();
56
+ } catch (e) {
57
+ die(`no omp plugin "${PLUGIN_KEY}" at ${packagePath} (${e.code || e.message})`);
58
+ }
59
+ let installPath;
60
+ try {
61
+ installPath = fs.realpathSync(packagePath);
62
+ } catch (e) {
63
+ die(
64
+ isLink
65
+ ? `omp plugin "${PLUGIN_KEY}" link ${packagePath} is dangling (${e.code || e.message})`
66
+ : `cannot resolve omp plugin "${PLUGIN_KEY}" at ${packagePath} (${e.code || e.message})`,
67
+ );
68
+ }
69
+ return { packagePath, installPath };
70
+ }
71
+
72
+ function scriptPathFor(installPath, script) {
73
+ return path.join(installPath, "scripts", script);
74
+ }
75
+
76
+ function usage() {
77
+ process.stderr.write(
78
+ `usage: ${NAME} <script> [args...]\n`
79
+ + ` ${NAME} --path <script> (print the resolved path; do not exec)\n`
80
+ + ` ${NAME} --root (print the resolved Install root)\n`,
81
+ );
82
+ process.exit(2);
83
+ }
84
+
85
+ function main() {
86
+ const argv = process.argv.slice(2);
87
+
88
+ if (argv.length === 0) usage();
89
+
90
+ if (argv[0] === "--root") {
91
+ if (argv.length !== 1) usage();
92
+ const r = resolveInstall();
93
+ process.stdout.write(r.installPath + "\n");
94
+ return;
95
+ }
96
+
97
+ if (argv[0] === "--path") {
98
+ const script = argv[1];
99
+ if (!script || argv.length !== 2) usage();
100
+ const r = resolveInstall();
101
+ process.stdout.write(scriptPathFor(r.installPath, script) + "\n");
102
+ return;
103
+ }
104
+
105
+ const script = argv[0];
106
+ const args = argv.slice(1);
107
+ const r = resolveInstall();
108
+ const scriptPath = scriptPathFor(r.installPath, script);
109
+
110
+ if (!fs.existsSync(scriptPath)) {
111
+ die(`script not found: ${scriptPath} (resolved via ${r.packagePath})`);
112
+ }
113
+
114
+ // `.mjs` scripts run via node, `.sh` via sh, anything else execs directly
115
+ // (its own shebang decides, and it must be executable — an unreadable or
116
+ // non-executable "anything else" surfaces as the child's own EACCES/ENOENT
117
+ // below, named at the path this already resolved).
118
+ let cmd;
119
+ let cmdArgs;
120
+ if (scriptPath.endsWith(".mjs")) {
121
+ cmd = process.execPath;
122
+ cmdArgs = [scriptPath, ...args];
123
+ } else if (scriptPath.endsWith(".sh")) {
124
+ cmd = "sh";
125
+ cmdArgs = [scriptPath, ...args];
126
+ } else {
127
+ cmd = scriptPath;
128
+ cmdArgs = args;
129
+ }
130
+
131
+ // stdio: "inherit" and no `cwd` override — the caller's cwd and std
132
+ // streams reach the child untouched, which is the "arguments and working
133
+ // directory reach the script unchanged" acceptance criterion.
134
+ const result = spawnSync(cmd, cmdArgs, { stdio: "inherit" });
135
+
136
+ if (result.error) {
137
+ die(`could not exec ${scriptPath}: ${result.error.message}`);
138
+ }
139
+ if (result.signal) {
140
+ process.stderr.write(`${NAME}: ${scriptPath} was killed by ${result.signal}\n`);
141
+ process.exit(1);
142
+ }
143
+ // Pass the child's own exit code through untouched — 2 is reserved for a
144
+ // RESOLVER failure (above), never for what the child itself decided.
145
+ process.exit(result.status === null ? 1 : result.status);
146
+ }
147
+
148
+ main();
@@ -0,0 +1,90 @@
1
+ // The Resolver's single-resolution-point contract (ADR 0014, ADR 0021):
2
+ // fleet-run resolves the Install root as the realpath of
3
+ // `~/.omp/plugins/node_modules/@feigi/fleet-ctl` — the one path every omp install
4
+ // kind (marketplace/link/npm) places — and nothing else. Driven through the
5
+ // real CLI — fleet-run reads `os.homedir()` directly and `process.exit()`s,
6
+ // so it cannot be exercised in-process the way a module-exporting script can.
7
+ //
8
+ // Every fixture's env is built from scratch (never `...process.env`), so
9
+ // these tests are deterministic regardless of the box they run on.
10
+ import { test } from "node:test";
11
+ import assert from "node:assert/strict";
12
+ import { spawnSync } from "node:child_process";
13
+ import { mkdtempSync, mkdirSync, writeFileSync, symlinkSync, realpathSync } from "node:fs";
14
+ import { tmpdir } from "node:os";
15
+ import { join } from "node:path";
16
+ import { fileURLToPath } from "node:url";
17
+
18
+ const FLEET_RUN = fileURLToPath(new URL("./fleet-run", import.meta.url));
19
+
20
+ function runFleetRun(home, args, extraEnv = {}) {
21
+ return spawnSync(process.execPath, [FLEET_RUN, ...args], {
22
+ encoding: "utf8",
23
+ env: { HOME: home, PATH: process.env.PATH, ...extraEnv },
24
+ });
25
+ }
26
+
27
+ // A marketplace/link-shaped install: a real payload dir with a scripts/
28
+ // subtree, symlinked into node_modules/@feigi/fleet-ctl — the shape omp's own
29
+ // installers place. The Install root the resolver reports is the payload's
30
+ // realpath (macOS resolves tmpdir through /private, and the resolver applies
31
+ // realpathSync, so expectations must too).
32
+ function fakeInstall() {
33
+ const home = mkdtempSync(join(tmpdir(), "fleet-run-home-"));
34
+ const payload = join(home, ".omp", "plugins", "cache", "a");
35
+ mkdirSync(join(payload, "scripts"), { recursive: true });
36
+ writeFileSync(join(payload, "scripts", "probe.mjs"), "content\n");
37
+ const nm = join(home, ".omp", "plugins", "node_modules");
38
+ mkdirSync(join(nm, "@feigi"), { recursive: true });
39
+ symlinkSync(payload, join(nm, "@feigi", "fleet-ctl"));
40
+ return { home, payload };
41
+ }
42
+
43
+ test("node_modules/@feigi/fleet-ctl present: --root prints its realpath, no notice", () => {
44
+ const { home, payload } = fakeInstall();
45
+ const r = runFleetRun(home, ["--root"]);
46
+ assert.equal(r.status, 0, `expected success, got status ${r.status}: ${r.stderr}`);
47
+ assert.equal(r.stdout.trim(), realpathSync(payload));
48
+ assert.equal(r.stderr, "", "a single present package dir needs no notice at all");
49
+ });
50
+
51
+ test("node_modules/@feigi/fleet-ctl absent: exit 2, stderr names ~/.omp/plugins/node_modules/@feigi/fleet-ctl", () => {
52
+ const home = mkdtempSync(join(tmpdir(), "fleet-run-home-"));
53
+ const r = runFleetRun(home, ["--root"]);
54
+ assert.equal(r.status, 2, `expected a resolver refusal, got status ${r.status}: ${r.stdout}`);
55
+ assert.match(r.stderr, /no omp plugin "@feigi\/fleet-ctl"/);
56
+ assert.match(r.stderr, /\.omp[/\\]plugins[/\\]node_modules[/\\]@feigi[/\\]fleet-ctl/);
57
+ });
58
+
59
+ test("a dangling link is named as dangling, not as a missing entry", () => {
60
+ const home = mkdtempSync(join(tmpdir(), "fleet-run-home-"));
61
+ const nm = join(home, ".omp", "plugins", "node_modules");
62
+ mkdirSync(join(nm, "@feigi"), { recursive: true });
63
+ symlinkSync(join(home, "does", "not", "exist"), join(nm, "@feigi", "fleet-ctl"));
64
+ const r = runFleetRun(home, ["--root"]);
65
+ assert.equal(r.status, 2);
66
+ assert.match(r.stderr, /dangling/);
67
+ });
68
+
69
+ test("--path prints the resolved script path without executing it", () => {
70
+ const { home, payload } = fakeInstall();
71
+ const r = runFleetRun(home, ["--path", "probe.mjs"]);
72
+ assert.equal(r.status, 0, r.stderr);
73
+ assert.equal(r.stdout.trim(), join(realpathSync(payload), "scripts", "probe.mjs"));
74
+ });
75
+
76
+ test("a bare script name execs the resolved file, arguments and exit code passed through", () => {
77
+ const { home, payload } = fakeInstall();
78
+ writeFileSync(join(payload, "scripts", "echo-args.mjs"), "console.log(JSON.stringify(process.argv.slice(2)));\n");
79
+ const r = runFleetRun(home, ["echo-args.mjs", "a", "b"]);
80
+ assert.equal(r.status, 0, r.stderr);
81
+ assert.deepEqual(JSON.parse(r.stdout.trim()), ["a", "b"]);
82
+ });
83
+
84
+ test("a script that does not exist under the resolved install refuses by name", () => {
85
+ const { home } = fakeInstall();
86
+ const r = runFleetRun(home, ["does-not-exist.mjs"]);
87
+ assert.equal(r.status, 2);
88
+ assert.match(r.stderr, /script not found/);
89
+ assert.match(r.stderr, /does-not-exist\.mjs/);
90
+ });