fix: extract codex section instead of copying full SKILL.md in E2E test

The codex-offered-design-review test was failing with error_api because
reading the full plan-design-review/SKILL.md (1331 lines, 77KB) bloated
the agent context to 142k tokens, exceeding API limits. All 3 retry
attempts failed consistently.

Fix: extract only the codex/outside-voice section (~180 lines) instead
of copying the full file. Follows the CLAUDE.md rule: "NEVER copy a
full SKILL.md file into an E2E test fixture." Applied to all 4 skills
in the test suite for consistency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-03-31 07:44:08 -07:00
parent f44be6dbd8
commit 30e6747814
+26 -5
View File
@@ -660,13 +660,34 @@ describeIfSelected('Codex Offering E2E', [
run('git', ['add', '.']);
run('git', ['commit', '-m', 'init']);
// Copy all 4 SKILL.md files
// Extract codex/outside-voice sections only (not full SKILL.md — avoids context bloat)
for (const skill of ['office-hours', 'plan-ceo-review', 'plan-design-review', 'plan-eng-review']) {
fs.mkdirSync(path.join(testDir, skill), { recursive: true });
fs.copyFileSync(
path.join(ROOT, skill, 'SKILL.md'),
path.join(testDir, skill, 'SKILL.md'),
);
const full = fs.readFileSync(path.join(ROOT, skill, 'SKILL.md'), 'utf-8');
// Find the codex/outside-voice section and extract ~200 lines around it
const lines = full.split('\n');
const codexIdx = lines.findIndex(l => /which codex.*CODEX_AVAILABLE/i.test(l));
if (codexIdx >= 0) {
// Go back to find the section heading
let start = codexIdx;
for (let i = codexIdx - 1; i >= Math.max(0, codexIdx - 30); i--) {
if (lines[i].startsWith('## ') || lines[i].startsWith('### ') || /outside voice|design outside/i.test(lines[i])) {
start = i;
break;
}
}
const end = Math.min(lines.length, codexIdx + 150);
fs.writeFileSync(
path.join(testDir, skill, 'SKILL.md'),
lines.slice(start, end).join('\n'),
);
} else {
// Fallback: copy full file if no codex section found
fs.copyFileSync(
path.join(ROOT, skill, 'SKILL.md'),
path.join(testDir, skill, 'SKILL.md'),
);
}
}
});