Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog.d/fix-codex-prompt-cleanup-plan-mode-prompt-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
important: regression
---
**`/codex challenge` and `/codex consult` no longer stop for a /careful delete warning at the end of every run.** Their cleanup deleted the prompt file through a variable the safety check could not resolve, so it asked every time; the cleanup now uses a guarded variable the check accepts. Thanks @dmfrede (#4841).

- **The Codex second-model review in `/plan-eng-review` and `/plan-ceo-review` works in Claude Code plan mode again.** The prompt file was created under `$TMPDIR`, where plan mode refuses Write, so Codex never started. It is now created in the project's `.gstack/tmp/` (never through a symlinked `.gstack` folder) and deleted with a plain `rm` of that one path. Thanks @mcp10 (#4842).
2 changes: 1 addition & 1 deletion codex/sections/challenge-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ if grep -qiE "auth|login|unauthorized" "$TMPERR" 2>/dev/null; then
"$_CODEX_PROBE" log-event codex_auth_failed
fi
bun --no-env-file --config=/dev/null ~/.claude/skills/gstack/lib/outside-review-result.ts --label 'Codex challenge' --exit "$_CODEX_EXIT" --stderr "$TMPERR" --events "$TMPRESP.events" execution "$TMPRESP"
rm -f "$TMPRESP" "$TMPRESP.events" "$PROMPT_FILE"
rm -f "$TMPRESP" "$TMPRESP.events" "${PROMPT_FILE:?}"
```

`VERDICT: unavailable` means the challenge did not run (its line names why, such as a
Expand Down
2 changes: 1 addition & 1 deletion codex/sections/challenge-mode.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ if grep -qiE "auth|login|unauthorized" "$TMPERR" 2>/dev/null; then
"$_CODEX_PROBE" log-event codex_auth_failed
fi
bun --no-env-file --config=/dev/null ~/.claude/skills/gstack/lib/outside-review-result.ts --label 'Codex challenge' --exit "$_CODEX_EXIT" --stderr "$TMPERR" --events "$TMPRESP.events" execution "$TMPRESP"
rm -f "$TMPRESP" "$TMPRESP.events" "$PROMPT_FILE"
rm -f "$TMPRESP" "$TMPRESP.events" "${PROMPT_FILE:?}"
```

`VERDICT: unavailable` means the challenge did not run (its line names why, such as a
Expand Down
2 changes: 1 addition & 1 deletion codex/sections/consult-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ elif [ "$_CODEX_EXIT" != "0" ]; then
"$_CODEX_PROBE" log-event codex_nonzero_exit "$_LABEL:$_CODEX_EXIT"
fi
bun --no-env-file --config=/dev/null ~/.claude/skills/gstack/lib/outside-review-result.ts --label 'Codex consult' --exit "$_CODEX_EXIT" --stderr "$TMPERR" --events "$TMPRESP.events" execution "$TMPRESP"
rm -f "$PROMPT_FILE"
rm -f "${PROMPT_FILE:?}"
```

`VERDICT: unavailable` means Codex did not answer from a working
Expand Down
2 changes: 1 addition & 1 deletion codex/sections/consult-mode.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ elif [ "$_CODEX_EXIT" != "0" ]; then
"$_CODEX_PROBE" log-event codex_nonzero_exit "$_LABEL:$_CODEX_EXIT"
fi
bun --no-env-file --config=/dev/null ~/.claude/skills/gstack/lib/outside-review-result.ts --label 'Codex consult' --exit "$_CODEX_EXIT" --stderr "$TMPERR" --events "$TMPRESP.events" execution "$TMPRESP"
rm -f "$PROMPT_FILE"
rm -f "${PROMPT_FILE:?}"
```

`VERDICT: unavailable` means Codex did not answer from a working
Expand Down
8 changes: 4 additions & 4 deletions plan-ceo-review/sections/review-sections.md
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,12 @@ THE PLAN:

**If `CODEX_MODE: ready` — run Codex:**

Run this block for `ready`, in the one foreground Bash call described below.
Run this block for `ready`, in the one foreground Bash call.
Its opening harness guard rechecks the fresh shell: exit 78 uses the same Native
fallback below, never a replacement provider. Finish termination before fallback and consume only
completed output. Use private temporary paths, with no background jobs.
completed output. No background jobs.

Create a private prompt file: run `umask 077; mktemp "${TMPDIR:-/tmp}/gstack-plan-prompt.XXXXXXXX"` in Bash and keep the returned path. Use Write to put the **complete prompt and context**, including actual plan/spec/source, in that file. Substitute its shell-quoted path for `<prepared-prompt-file>`; never interpolate user text into shell source. Request severity (Critical, High, Medium or Low) per finding and the prompt's Recommendation and VERDICT lines.
Create a private prompt file: run `[ ! -L .gstack -a ! -L .gstack/tmp ] && mkdir -p -m700 .gstack/tmp && mktemp "$PWD/.gstack/tmp/gstack-plan-prompt.XXXXXX"` and keep the returned path. Use Write to put the **complete prompt and context**, including actual plan/spec/source, in it. Substitute its shell-quoted path for `<prepared-prompt-file>`; never interpolate user text into shell source. Request severity (Critical, High, Medium or Low) per finding and the prompt's Recommendation and VERDICT lines.

```bash
# GSTACK_ACTIVE_HOST names the harness, never the model.
Expand Down Expand Up @@ -495,7 +495,7 @@ esac
echo 'OUTSIDE_STATUS: completed provider=codex host=claude'
```

Use Bash `timeout: 360000`; show the full response in a `tool-output` fence. Require successful execution and valid markers. Refusal, empty/malformed output, missing Recommendation: <action> because <reason> markers, timeout or CLI failure means `outside_status: unavailable`. P0/P1 findings block like native ones; `OUTSIDE_STATUS: unverified` is missing coverage. Use the caller's fallback; missing coverage is never clean/PASS. After either outcome, delete only your private prompt; scratch cleanup is automatic.
Use Bash `timeout: 360000`; show the full response in a `tool-output` fence. Require successful execution and valid markers. Refusal, empty/malformed output, missing Recommendation: <action> because <reason> markers, timeout or CLI failure means `outside_status: unavailable`. P0/P1 findings block like native ones; `OUTSIDE_STATUS: unverified` is missing coverage. Use the caller's fallback; missing coverage is never clean/PASS. After either outcome, run `rm -- '<prepared-prompt-file>'`; scratch cleanup is automatic.

Present the full output verbatim:

Expand Down
8 changes: 4 additions & 4 deletions plan-eng-review/sections/review-sections.md
Original file line number Diff line number Diff line change
Expand Up @@ -966,12 +966,12 @@ THE PLAN:

**If `CODEX_MODE: ready` — run Codex:**

Run this block for `ready`, in the one foreground Bash call described below.
Run this block for `ready`, in the one foreground Bash call.
Its opening harness guard rechecks the fresh shell: exit 78 uses the same Native
fallback below, never a replacement provider. Finish termination before fallback and consume only
completed output. Use private temporary paths, with no background jobs.
completed output. No background jobs.

Create a private prompt file: run `umask 077; mktemp "${TMPDIR:-/tmp}/gstack-plan-prompt.XXXXXXXX"` in Bash and keep the returned path. Use Write to put the **complete prompt and context**, including actual plan/spec/source, in that file. Substitute its shell-quoted path for `<prepared-prompt-file>`; never interpolate user text into shell source. Request severity (Critical, High, Medium or Low) per finding and the prompt's Recommendation and VERDICT lines.
Create a private prompt file: run `[ ! -L .gstack -a ! -L .gstack/tmp ] && mkdir -p -m700 .gstack/tmp && mktemp "$PWD/.gstack/tmp/gstack-plan-prompt.XXXXXX"` and keep the returned path. Use Write to put the **complete prompt and context**, including actual plan/spec/source, in it. Substitute its shell-quoted path for `<prepared-prompt-file>`; never interpolate user text into shell source. Request severity (Critical, High, Medium or Low) per finding and the prompt's Recommendation and VERDICT lines.

```bash
# GSTACK_ACTIVE_HOST names the harness, never the model.
Expand Down Expand Up @@ -1010,7 +1010,7 @@ esac
echo 'OUTSIDE_STATUS: completed provider=codex host=claude'
```

Use Bash `timeout: 360000`; show the full response in a `tool-output` fence. Require successful execution and valid markers. Refusal, empty/malformed output, missing Recommendation: <action> because <reason> markers, timeout or CLI failure means `outside_status: unavailable`. P0/P1 findings block like native ones; `OUTSIDE_STATUS: unverified` is missing coverage. Use the caller's fallback; missing coverage is never clean/PASS. After either outcome, delete only your private prompt; scratch cleanup is automatic.
Use Bash `timeout: 360000`; show the full response in a `tool-output` fence. Require successful execution and valid markers. Refusal, empty/malformed output, missing Recommendation: <action> because <reason> markers, timeout or CLI failure means `outside_status: unavailable`. P0/P1 findings block like native ones; `OUTSIDE_STATUS: unverified` is missing coverage. Use the caller's fallback; missing coverage is never clean/PASS. After either outcome, run `rm -- '<prepared-prompt-file>'`; scratch cleanup is automatic.

Present the full output verbatim:

Expand Down
4 changes: 2 additions & 2 deletions scripts/resolvers/outside-voice-steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,10 @@ function codexPlanReviewRun(ctx: TemplateContext, ceo: boolean, needsApprovalRea
// (gates 40477638211 and 40454750574: every judge sample read "(or unverified)" as a branch nothing can enter).
return `**If \`CODEX_MODE: ready\` — run ${outsideVoiceFor(ctx).label}:**
${['plan-ceo-review', 'plan-eng-review'].includes(ctx.skillName) ? `Run this block for \`ready\`, in the one foreground Bash call described below.
${['plan-ceo-review', 'plan-eng-review'].includes(ctx.skillName) ? `Run this block for \`ready\`, in the one foreground Bash call.
Its opening harness guard rechecks the fresh shell: exit 78 uses the same Native
fallback below, never a replacement provider. Finish termination before fallback and consume only
completed output. Use private temporary paths, with no background jobs.` : `Run the selected backend in the one foreground Bash invocation described below.
completed output. No background jobs.` : `Run the selected backend in the one foreground Bash invocation described below.
Finish a failed attempt's termination before fallback; consume only its completed
output. No background jobs or shared temporary paths.`}
Expand Down
7 changes: 4 additions & 3 deletions scripts/resolvers/outside-voice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,17 @@ export function outsideVoiceInvocation(ctx: TemplateContext, requested: OutsideC
: planRecommendation
? "Request severity (Critical, High, Medium or Low) per finding and the prompt's Recommendation and VERDICT lines."
: `Request severity (Critical, High, Medium or Low) per finding, a Recommendation: <action> because <reason> line, and ${VERDICT_LAST_LINE}.`;
const preparation = `${['plan-ceo-review', 'plan-eng-review'].includes(ctx.skillName)
? 'Create a private prompt file: run `umask 077; mktemp "${TMPDIR:-/tmp}/gstack-plan-prompt.XXXXXXXX"` in Bash and keep the returned path. Use Write to put the **complete prompt and context**, including actual plan/spec/source, in that file'
const planPrompt = ['plan-ceo-review', 'plan-eng-review'].includes(ctx.skillName);
const preparation = `${planPrompt
? 'Create a private prompt file: run `[ ! -L .gstack -a ! -L .gstack/tmp ] && mkdir -p -m700 .gstack/tmp && mktemp "$PWD/.gstack/tmp/gstack-plan-prompt.XXXXXX"` and keep the returned path. Use Write to put the **complete prompt and context**, including actual plan/spec/source, in it'
: 'Write the **complete prompt and context**, including actual plan/spec/source, to a private file'}${outsideVoiceFor(ctx).id === 'claude-code' ? ' (Claude Code has no tools, git or path access)' : ''}. Substitute its shell-quoted path for \`<prepared-prompt-file>\`; never interpolate user text into shell source. ${completion}`;
return `${preparation}
\`\`\`bash
${outsideVoiceCommand(ctx, opts)}
\`\`\`
Use Bash \`timeout: ${gateMs}\`; show the full response in a \`tool-output\` fence. Require successful execution and valid markers. Refusal, empty/malformed output, missing ${planRecommendation ? 'Recommendation: <action> because <reason>' : opts.purpose === 'design-direction' ? 'Recommendation' : 'score/severity/completion'} markers, timeout or CLI failure means \`outside_status: unavailable\`. P0/P1 findings block like native ones; \`OUTSIDE_STATUS: unverified\` is missing coverage. ${opts.purpose === 'design-direction' ? 'Continue completed proposals; native completion does not count as outside coverage.' : opts.nativeAlreadyRequired === 'dispatched' ? 'A dispatched native pass runs once either way; outside output cannot complete it.' : opts.nativeAlreadyRequired ? 'Retain the required native pass without duplicating it; it cannot complete outside coverage.' : "Use the caller's fallback; missing coverage is never clean/PASS."} After either outcome, delete only your private prompt; scratch cleanup is automatic.`;
Use Bash \`timeout: ${gateMs}\`; show the full response in a \`tool-output\` fence. Require successful execution and valid markers. Refusal, empty/malformed output, missing ${planRecommendation ? 'Recommendation: <action> because <reason>' : opts.purpose === 'design-direction' ? 'Recommendation' : 'score/severity/completion'} markers, timeout or CLI failure means \`outside_status: unavailable\`. P0/P1 findings block like native ones; \`OUTSIDE_STATUS: unverified\` is missing coverage. ${opts.purpose === 'design-direction' ? 'Continue completed proposals; native completion does not count as outside coverage.' : opts.nativeAlreadyRequired === 'dispatched' ? 'A dispatched native pass runs once either way; outside output cannot complete it.' : opts.nativeAlreadyRequired ? 'Retain the required native pass without duplicating it; it cannot complete outside coverage.' : "Use the caller's fallback; missing coverage is never clean/PASS."} After either outcome, ${planPrompt ? "run `rm -- '<prepared-prompt-file>'`" : 'delete only your private prompt'}; scratch cleanup is automatic.`;
}

/**
Expand Down
12 changes: 8 additions & 4 deletions test/autoplan-dual-voice-fixture.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import * as path from 'node:path';
import { spawnSync } from 'node:child_process';

const ROOT = path.resolve(import.meta.dir, '..');
// The plan skills' own prompt-file command (#4842): it creates the prompt in the project's .gstack/tmp/.
const PROMPT_CREATE = [...fs.readFileSync(path.join(ROOT, 'plan-ceo-review/sections/review-sections.md'), 'utf8')
.matchAll(/`([^`\n]+)`/g)].map(m => m[1]).filter(s => s.includes('gstack-plan-prompt'));
if (PROMPT_CREATE.length !== 1) throw Error('expected one plan prompt-file command, found ' + PROMPT_CREATE.length);
const ORIGINAL_PLAN = `# Test Plan: add /greet skill
## Context
Expand Down Expand Up @@ -175,13 +179,13 @@ mock.module(${JSON.stringify(path.join(ROOT, 'test/helpers/session-runner.ts'))}
if (scenario === 'temp' || scenario === 'temp-retry') {
const {hermeticChildEnv, getHermeticDirs} = await import(${JSON.stringify(path.join(ROOT, 'test/helpers/hermetic-env.ts'))});
// Same final environment merge as session-runner. The original cf74
// command created its file in inherited shard TMPDIR, beside both roots.
// command created its file in inherited shard TMPDIR, beside both roots;
// the generated command now creates it inside the project (#4842).
const env = hermeticChildEnv({GSTACK_HEADLESS: '1', ...opts.env});
const defaults = getHermeticDirs();
const cleanupFiles = [];
try {
const command = 'umask 077; mktemp "$' + '{TMPDIR:-/tmp}/gstack-plan-prompt.XXXXXXXX"';
const made = spawnSync('bash', ['-c', command], {cwd, env, encoding: 'utf8', timeout: 5000});
const made = spawnSync('bash', ['-c', ${JSON.stringify(PROMPT_CREATE[0])}], {cwd, env, encoding: 'utf8', timeout: 5000});
if (made.error || made.status !== 0) throw Error('Actual prompt mktemp failed: ' + made.stderr);
const prompt = made.stdout.trim();
const freeRoot = fs.realpathSync(${JSON.stringify(directory)});
Expand Down Expand Up @@ -277,7 +281,7 @@ await import(${JSON.stringify(path.join(ROOT, 'test/skill-e2e-autoplan-dual-voic
const temp = attempt.temp;
const expected = path.join(attempt.env.HOME, 'tmp');
expect(temp.env).toEqual({TMPDIR: expected, TEMP: expected, TMP: expected});
expect(path.dirname(temp.prompt)).toBe(expected);
expect(path.dirname(temp.prompt)).toBe(path.join(attempt.cwd, '.gstack', 'tmp'));
expect(temp.directoryMode).toBe(0o700);
expect(temp.promptMode).toBe(0o600);
expect(temp.owned.claudeVoiceFired).toBe(true);
Expand Down
18 changes: 9 additions & 9 deletions test/fixtures/skill-md-size-allowlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,53 @@
"agy/gstack-autoplan": 109163,
"agy/gstack-plan-design-review": 109100,
"agy/gstack-plan-devex-review": 115130,
"agy/gstack-plan-eng-review": 143744,
"agy/gstack-plan-eng-review": 143742,
"agy/gstack-review": 104939,
"codex/gstack-autoplan": 107431,
"codex/gstack-plan-design-review": 110375,
"codex/gstack-plan-devex-review": 114416,
"codex/gstack-plan-eng-review": 142687,
"codex/gstack-plan-eng-review": 142685,
"codex/gstack-review": 104273,
"copilot/gstack-autoplan": 108606,
"copilot/gstack-plan-design-review": 109366,
"copilot/gstack-plan-devex-review": 114592,
"copilot/gstack-plan-eng-review": 143909,
"copilot/gstack-plan-eng-review": 143907,
"copilot/gstack-review": 104520,
"cursor/gstack-autoplan": 107838,
"cursor/gstack-plan-design-review": 107908,
"cursor/gstack-plan-devex-review": 113862,
"cursor/gstack-plan-eng-review": 142499,
"cursor/gstack-plan-eng-review": 142497,
"cursor/gstack-review": 122992,
"factory/gstack-autoplan": 110116,
"factory/gstack-plan-design-review": 111006,
"factory/gstack-plan-devex-review": 117225,
"factory/gstack-plan-eng-review": 145607,
"factory/gstack-plan-eng-review": 145605,
"factory/gstack-review": 126765,
"gbrain/gstack-autoplan": 108245,
"gbrain/gstack-plan-eng-review": 125054,
"gemini/gstack-autoplan": 108396,
"gemini/gstack-plan-design-review": 109194,
"gemini/gstack-plan-devex-review": 114420,
"gemini/gstack-plan-eng-review": 143742,
"gemini/gstack-plan-eng-review": 143740,
"gemini/gstack-review": 104342,
"hermes/gstack-autoplan": 108250,
"hermes/gstack-plan-eng-review": 125007,
"kiro/gstack-autoplan": 107612,
"kiro/gstack-plan-design-review": 107754,
"kiro/gstack-plan-devex-review": 113714,
"kiro/gstack-plan-eng-review": 142361,
"kiro/gstack-plan-eng-review": 142359,
"kiro/gstack-review": 122816,
"openclaw/gstack-autoplan": 108068,
"openclaw/gstack-plan-eng-review": 123553,
"opencode/gstack-autoplan": 108587,
"opencode/gstack-plan-design-review": 109222,
"opencode/gstack-plan-devex-review": 114470,
"opencode/gstack-plan-eng-review": 143768,
"opencode/gstack-plan-eng-review": 143766,
"opencode/gstack-review": 123614,
"slate/gstack-autoplan": 107725,
"slate/gstack-plan-design-review": 107831,
"slate/gstack-plan-devex-review": 113788,
"slate/gstack-plan-eng-review": 142430,
"slate/gstack-plan-eng-review": 142428,
"slate/gstack-review": 122904
}
}
Loading
Loading