Version: v7.40.4
File: LifeOS/install/LIFEOS/HERMES/Policy.ts (the import.meta.main block)
Repro
bun LifeOS/install/LIFEOS/HERMES/Policy.ts /tmp/policy.json
# prints the full policy JSON to stdout, exits 0
ls /tmp/policy.json
# No such file or directory
Expected: ✓ policy v… → /tmp/policy.json and the file written.
Actual: the destination argument is discarded, the CLI takes the "no dest → print to stdout" path, and no file is ever written. Exit code is 0, so callers (scripts, test harnesses that generate a policy to a temp path) fail later with a confusing FileNotFoundError on the policy file rather than at the point of the actual bug.
Cause
const launcherIdx = argv.indexOf("--launcher");
// …
const positional = argv.filter((a, i) => a !== "--launcher" && i !== launcherIdx + 1);
When --launcher is not passed, launcherIdx is -1, so the filter condition i !== launcherIdx + 1 becomes i !== 0 — which removes argv[0], the destination path. positional[0] is then undefined and the stdout branch runs.
With --launcher present the CLI behaves correctly; the bug only bites the plain bun Policy.ts <dest> form.
Fix
Guard the sentinel value:
const positional = argv.filter(
(a, i) => a !== "--launcher" && (launcherIdx === -1 || i !== launcherIdx + 1),
);
Happy to send this as a PR (3-line change, no behavior change for the --launcher form).
Version: v7.40.4
File:
LifeOS/install/LIFEOS/HERMES/Policy.ts(theimport.meta.mainblock)Repro
Expected:
✓ policy v… → /tmp/policy.jsonand the file written.Actual: the destination argument is discarded, the CLI takes the "no dest → print to stdout" path, and no file is ever written. Exit code is 0, so callers (scripts, test harnesses that generate a policy to a temp path) fail later with a confusing
FileNotFoundErroron the policy file rather than at the point of the actual bug.Cause
When
--launcheris not passed,launcherIdxis-1, so the filter conditioni !== launcherIdx + 1becomesi !== 0— which removesargv[0], the destination path.positional[0]is thenundefinedand the stdout branch runs.With
--launcherpresent the CLI behaves correctly; the bug only bites the plainbun Policy.ts <dest>form.Fix
Guard the sentinel value:
Happy to send this as a PR (3-line change, no behavior change for the
--launcherform).