Skip to content

Commit 52fe01e

Browse files
authored
fix: keep permission profile helper backward compatible (#116)
## Why PR #113 added `--permission-profile` to the internal `run-codex-exec` helper as a required Commander option. Existing callers that invoke the helper with the pre-#113 argument set now fail during option parsing, before the existing permission-selection fallback can preserve the legacy `workspace-write` behavior. The established `--sandbox` helper option was already required. Making both helper options optional, as proposed in #115, would broaden the internal interface unnecessarily; only the newly introduced option needs a backward-compatible default. ## What changed - Make `--permission-profile` optional with an empty-string default. - Keep `--sandbox` required so malformed helper invocations still fail early. - Add regression coverage for omitting `--permission-profile` while preserving the legacy `workspace-write` fallback. - Rebuild the checked-in `dist/main.js` bundle. ## Testing - `corepack pnpm test` - `corepack pnpm run check`
1 parent 0d2a018 commit 52fe01e

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

dist/main.js

Lines changed: 4 additions & 3 deletions
Large diffs are not rendered by default.

src/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,10 @@ export async function main() {
150150
"--sandbox <SANDBOX>",
151151
"Legacy sandbox mode override to pass to `codex exec` (may be empty)."
152152
)
153-
.requiredOption(
153+
.option(
154154
"--permission-profile <PROFILE>",
155-
"Permission profile to select through `default_permissions` (may be empty)."
155+
"Permission profile to select through `default_permissions` (may be empty).",
156+
""
156157
)
157158
.requiredOption("--model <model>", "Model the agent should use")
158159
.requiredOption("--effort <effort>", "Reasoning effort the agent should use")

test/runCodexExec.test.mjs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ writeFileSync(args[outputIndex + 1], "fake final message\\n");
7979
"",
8080
"--sandbox",
8181
sandbox,
82-
"--permission-profile",
83-
permissionProfile,
82+
...(permissionProfile == null
83+
? []
84+
: ["--permission-profile", permissionProfile]),
8485
"--model",
8586
"",
8687
"--effort",
@@ -117,6 +118,15 @@ test("preserves workspace-write as the default legacy sandbox", () => {
117118
assert.deepEqual(capturedArgs.slice(-2), ["--sandbox", "workspace-write"]);
118119
});
119120

121+
test("allows permission-profile to be omitted", () => {
122+
const { result, capturedArgs } = runCodexExecWithFakeCodex({
123+
permissionProfile: null,
124+
});
125+
126+
assert.equal(result.status, 0, result.stderr);
127+
assert.deepEqual(capturedArgs.slice(-2), ["--sandbox", "workspace-write"]);
128+
});
129+
120130
test("selects a permission profile without passing --sandbox", () => {
121131
const { result, capturedArgs } = runCodexExecWithFakeCodex({
122132
permissionProfile: "public-review",

0 commit comments

Comments
 (0)