fix(codex-config): stop rejecting env values that start with "-"

--env's value is the RHS of one KEY=VALUE argv element, never its own
argv position, so a leading "-" can never be parsed as a flag — unlike
the key, which stays validated as an identifier. assertArg's leading-dash
guard was reused for the value too, refusing ordinary values like "-1".
Split it into assertEnvValue (no leading-dash check) for values only.
This commit is contained in:
2026-09-09 01:22:12 +07:00
parent acff059e92
commit 42db57ee18
2 changed files with 33 additions and 1 deletions
+14
View File
@@ -189,6 +189,20 @@ describe("codex-cli argv construction", () => {
}
});
it("accepts an env value starting with '-' — it's the RHS of one KEY=VALUE argv element, never a flag", async () => {
const restore = stubCodex();
try {
const result = await cli.mcpAdd({
name: "docs",
command: "node",
env: { OFFSET: "-1" },
});
assert.deepEqual(argvOf(result), ["mcp", "add", "docs", "--env", "OFFSET=-1", "--", "node"]);
} finally {
restore();
}
});
it("builds mcp list / remove argvs", async () => {
const restore = stubCodex();
try {