mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-16 09:55:29 +02:00
* feat: add a restricted and supervised Claude Code runner Preserve configured authentication and models while enforcing tool access, strict completion JSON, bounded output and process cleanup. Cover argv, failure handling, session metadata and Windows process containment. * feat: route outside reviews by harness and migrate wrapper installs Use Claude Code from Codex and Codex from other supported hosts, with shared invocation rendering, positive gate validation and per-phase provenance. Rename /claude to /claude-code, repair managed shared and copied installations safely, and generate native Kiro skills. Add installed-workflow, failure-injection and live cross-harness regression coverage. * test: recognize CEO mode labels without terminal spacing The paid workflow rendered SCOPEEXPANSION at option 4, but its driver required a literal space. Match the leading mode title without cursor-spacing artifacts and ignore adjacent preview text. Preserve missing-target failures and downstream posture assertions. * test: isolate plan-count fixtures before starting review workflows Seed the complete test plan in a private git repository before launching Claude, so a bare slash command cannot review the live workspace while a delayed fixture message remains queued. Preserve count thresholds, parsers and budgets. Add initial-context and installed-discovery tests, and retain startup/terminal diagnostics on failed evaluations. * test: stabilize review fixtures and Claude eval startup Preserve source boundaries in workflow judge inputs, isolate CEO mode plans, and wait for interactive trust input readiness. Keep startup failure evidence and retain existing models, budgets, and assertions. Co-Authored-By: OpenAI Codex <noreply@openai.com> * test: classify collapsed review modes and isolate seeded findings Keep review questions out of the setup count when terminal cursor positioning removes spaces. State existing webhook safeguards so the five-finding control measures its seeded defects without accidental extra security and concurrency gaps. Preserve question bands and the paired control. Co-Authored-By: OpenAI Codex <noreply@openai.com> * test: isolate browser daemon state across free shards Co-Authored-By: OpenAI Codex <noreply@openai.com> * test: stabilize native review counting and interactive navigation Co-Authored-By: OpenAI Codex <noreply@openai.com> * chore: prepare v1.82.0.0 release Co-Authored-By: OpenAI Codex <noreply@openai.com> * fix: eliminate browser and process-cleanup test flakes Pin every CI surface to Bun 1.4.0 to avoid extra-stdio finalizers closing reused live sockets. Add an isolated GC/listener regression that fails on Bun 1.3.13, and prevent coordinated rollback to an affected CI runtime. Check renderer cleanup against the render's own staging directory so concurrent renders cannot invalidate the assertion. Make the no-pgrep process-tree walk tolerate disappearing /proc entries, and synchronize its test fixture through child readiness and pipe EOF instead of sleeps. Validation: 9,157 passed, 31 skipped, zero failures across 556 files with retries disabled. Build, all-host generation freshness, and skill checks passed. All three races have failing-before/passing-after regressions. * fix: count completed native review questions in evals * fix: drive review navigation from confirmed native choices * fix: require complete section-loading eval reports * test: isolate telemetry HTTP transport from local assertions * fix: keep review input on the active native question * test: let tunnel revocation daemon choose an available port * test: allocate available ports for pairing and watchdog fixtures * fix: stabilize planning eval navigation and phase reporting * test: isolate installed runtime paths in planning evals * test: stabilize review evidence and concurrent refresh fixtures * fix: resolve design findings before editing the plan * fix: honor and persist disabled outside plan reviews * fix: preserve planning decisions and terminal evidence Load installed host reviews at autoplan phase entry and wait for completed reviewers and saved artifacts. Reuse approved remedies while preserving individual finding decisions. Drive interactive evals from the current terminal viewport, bind native questions across scrolling, and require complete native report evidence. Cover captured stale menus, permission lifecycles, setup classification, and disabled-review tool availability with deterministic regressions. Advance release metadata and the upgrade migration to the unclaimed 1.83.0.0 slot. * fix: drive native review questions and preserve current plans Use the native single-choice keyboard protocol and current terminal viewport, with per-question navigation inside packets and completed-call coverage. Keep permissions, multi-select menus, and Submit controls distinct. Send Autoplan reviewers the amended implementation plan, keep its review record separate, and supply retained application contracts in the chain fixture. Clarify individual DevEx decisions and complete CEO fix options; use one active plan destination for the section-loading report. * fix: preserve complete plan-review decisions * fix: recognize native plan dialogs and reviewer controls * fix: preserve review decisions and phase completion * fix: recognize completed reviews without losing findings * fix: preserve review continuity and native eval completion * test: fix native review completion and eval retry isolation * test: handle native review menus and complete eval fixtures * test: fix native review setup, completion, and isolation failures * test: limit native skill discovery to runtime assets * fix: bind Autoplan reviews to full ordered phase inputs * test: fix planning eval routing, counting, and timeout handling * chore: advance queued release to v1.84.0.0 * fix: preserve complete review inputs and planning decisions * fix: reconcile review approvals and preserve phase obligations * fix: preserve review obligations and unblock eval permissions Carry recorded Autoplan requirements into blind phase inputs, require Eng review approvals before exit, and exercise combined asynchronous flows in CEO reviews. Correct native finding and handoff classification and unblock repeated report edits using scoped request identities. * fix: retain plan requirements and complete native review dialogs * fix: complete native review prompts and retain plan references * fix: preserve review inputs and classify native eval evidence * fix: check competing completion orders in CEO reviews * fix: recognize review decisions and require phase methodology Require the current phase methodology before Autoplan snapshots. Correct substantive decision, closed handoff, and cache-finding classification, and honor the recommended implementation approach in native review dialogs. Add captured-transcript regressions without changing review thresholds, provider models, retries, or deadlines. * test: bind native review decisions and close completed handoffs * fix: complete review dialogs and verify methodology delivery * fix: preserve review evidence and unblock native eval prompts * fix: handle native review question completions * fix: recognize native review narration and controls * fix: count native review decisions and isolate eval fixtures * test: verify seeded review coverage and current artifact permissions * test: isolate model and brain-aware skill renders * fix: repair native workflow evaluation and clarify review steps * fix: stabilize workflow eval evidence and review guidance * test: repair native workflow observation and fixture isolation * fix: recognize completed workflow evidence and owned skill reads * test: repair seeded workflow delivery and completion evidence * test: recognize current review evidence across native forms * test: handle native review variants and permission redraws * fix: honor review preferences and recognize native eval evidence * test: recognize completed review decisions and queued permissions * test: match current review contracts and partial-line edits * test: recognize completed workflow evidence and bounded human waits * fix: preserve review entry gates and native eval interactions * fix: recognize native workflow evidence and preserve review gates * test: recognize current review evidence and preconfigure workflow fixtures * test: recognize completed review findings and scoped artifact permissions * fix: stabilize native workflow review and permission evidence * fix: recognize current review evidence and scoped edit confirmations Clarify Design and engineering review entry instructions and Design scoring. Recognize required legacy coverage and public Autoplan completion recaps. Bind the pending Edit confirmation to its exact file, ordered digest, and one-request approval when a preceding command display remains visible. Keep reviews within their existing size limits and preserve scope gates when extracting workflow fixtures from either supported preamble header. Keep failure outcomes, review thresholds, provider choices, and eval budgets. * fix: recover review workflow progress and eval evidence * fix: recognize valid review evidence and scope selection * test: fix review evidence parsing and repeated artifact prompts * test: recognize valid review decisions and pending native cards * fix(plan-eng-review): keep final navigation consistent with approved tasks * test: recognize valid review evidence and bind legacy diff requests * fix: stabilize review eval evidence and harness repair guidance * docs: update project documentation for v1.85.0.0 Co-Authored-By: OpenAI Codex <noreply@openai.com> * test: fix Windows CI fixtures and credential scan Rebase captured JSON values and filesystem evidence using the appropriate path convention. Compile native fake CLIs on Windows and synchronize pipe holder readiness, with cleanup retained when assertions fail. Assemble synthetic credential fixtures at runtime so the added-line scan keeps enforcing the same gate without flagging its own rejection controls. Discover generated skills directly for the empty-find regression check, avoiding a recursive scan through saved evaluation artifacts and dependencies. * fix: preserve source renders on Windows Compare canonical generator paths using native separators so an output sidecar pointing at the source cannot overwrite its skill or metadata. Keep the regression fixture isolated from the real checkout and expose freshness diagnostics before asserting subprocess status. Detach Windows drain-test pipe holders from the fake provider's automatic child cleanup while preserving the enclosing runner job and its assertions. * fix: clarify outside review fallback and CEO decisions Render one applicable own-harness fallback path and retain native review, disabled policy, and missing-coverage semantics. Align report field names and mode labels, and make the existing per-cut scope approval explicit. Regenerate skill outputs and keep the workflow judge's model, thresholds, and retry policy unchanged. * chore: move release to free version slot (v1.86.0.0) PR #2852 now claims v1.85.0.0. Align the release metadata and rename migration so upgrades from that version still receive it. Co-Authored-By: OpenAI Codex <noreply@openai.com> * fix: include engineering review prerequisites and restore branch context * fix: recognize coverage diagrams and clarify design review instructions * fix: preserve file identities and join Windows test processes --------- Co-authored-by: OpenAI Codex <noreply@openai.com>
443 lines
18 KiB
TypeScript
443 lines
18 KiB
TypeScript
import { describe, test, expect, beforeAll, afterAll } from 'bun:test';
|
|
import { JUDGE_MS, CAPTURE_MS, CAPTURE_LONG_MS } from './helpers/eval-budgets';
|
|
import { runSkillTest } from './helpers/session-runner';
|
|
import {
|
|
ROOT, browseBin, runId, evalsEnabled, selectedTests,
|
|
describeIfSelected, testConcurrentIfSelected,
|
|
copyDirSync, setupBrowseShims, logCost, recordE2E,
|
|
createEvalCollector, finalizeEvalCollector,
|
|
} from './helpers/e2e-helpers';
|
|
import { asideAvailable } from './helpers/aside-available';
|
|
import { startTestServer } from '../browse/test/test-server';
|
|
import { spawnSync } from 'child_process';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import * as os from 'os';
|
|
|
|
const evalCollector = createEvalCollector('e2e-qa-workflow');
|
|
|
|
// /qa and /qa-only drive the Aside browser first and fall back to the gstack
|
|
// browse binary. The browser-driving describes need one of the two — a live
|
|
// Aside or a built browse/dist/browse (CI builds it, so the Linux lane runs
|
|
// the fallback path). Neither → skip, never fail. qa-bootstrap opens no
|
|
// browser and is not gated.
|
|
const browserSelected = evalsEnabled && (asideAvailable() || fs.existsSync(browseBin)) ? selectedTests : [];
|
|
|
|
// The skill's BROWSER SETUP decides Aside vs fallback; the prompt only tells the
|
|
// agent where the fallback binary is (the hermetic HOME has no global install).
|
|
const browserPrompt = (skillMd: string) =>
|
|
`Follow the BROWSER SETUP section in ${skillMd} exactly: it probes for Aside first and falls back to the gstack browse binary. If it falls back, the browse binary is at ${browseBin} (B="${browseBin}"; find-browse is shimmed under browse/bin in this directory). Do not look for any other browser.`;
|
|
|
|
// --- B4: QA skill E2E ---
|
|
|
|
describeIfSelected('QA skill E2E', ['qa-quick'], () => {
|
|
let qaDir: string;
|
|
let testServer: ReturnType<typeof startTestServer>;
|
|
|
|
beforeAll(() => {
|
|
testServer = startTestServer();
|
|
qaDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-qa-'));
|
|
setupBrowseShims(qaDir);
|
|
|
|
// Copy qa skill files into tmpDir
|
|
copyDirSync(path.join(ROOT, 'qa'), path.join(qaDir, 'qa'));
|
|
|
|
// Create report directory
|
|
fs.mkdirSync(path.join(qaDir, 'qa-reports'), { recursive: true });
|
|
});
|
|
|
|
afterAll(() => {
|
|
testServer?.server?.stop();
|
|
try { fs.rmSync(qaDir, { recursive: true, force: true }); } catch {}
|
|
});
|
|
|
|
testConcurrentIfSelected('qa-quick', async () => {
|
|
const result = await runSkillTest({
|
|
prompt: `${browserPrompt('qa/SKILL.md')}
|
|
|
|
The test server is already running at: ${testServer.url}
|
|
Target page: ${testServer.url}/basic.html
|
|
|
|
Read the file qa/SKILL.md for the QA workflow instructions.
|
|
qa is a carved skill: when SKILL.md tells you to Read ~/.claude/skills/gstack/qa/sections/<file>, read qa/sections/<file> in this working directory instead (same content, local copy).
|
|
Skip the preamble bash block, lake intro, telemetry, and contributor mode sections — go straight to the QA workflow.
|
|
|
|
Run a Quick-depth QA test on ${testServer.url}/basic.html
|
|
Do NOT use AskUserQuestion — run Quick tier directly.
|
|
Do NOT try to start a server or discover ports — the URL above is ready.
|
|
Write your report to ${qaDir}/qa-reports/qa-report.md`,
|
|
workingDirectory: qaDir,
|
|
maxTurns: 35,
|
|
timeout: CAPTURE_MS,
|
|
testName: 'qa-quick',
|
|
runId,
|
|
});
|
|
|
|
logCost('/qa quick', result);
|
|
recordE2E(evalCollector, '/qa quick', 'QA skill E2E', result, {
|
|
passed: ['success', 'error_max_turns'].includes(result.exitReason),
|
|
});
|
|
// browseErrors can include false positives from hallucinated paths
|
|
if (result.browseErrors.length > 0) {
|
|
console.warn('/qa quick browse errors (non-fatal):', result.browseErrors);
|
|
}
|
|
// Accept error_max_turns — the agent doing thorough QA work is not a failure
|
|
expect(['success', 'error_max_turns']).toContain(result.exitReason);
|
|
}, CAPTURE_MS);
|
|
}, browserSelected);
|
|
|
|
// --- QA-Only E2E (report-only, no fixes) ---
|
|
|
|
describeIfSelected('QA-Only skill E2E', ['qa-only-no-fix'], () => {
|
|
let qaOnlyDir: string;
|
|
let testServer: ReturnType<typeof startTestServer>;
|
|
|
|
beforeAll(() => {
|
|
testServer = startTestServer();
|
|
qaOnlyDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-qa-only-'));
|
|
setupBrowseShims(qaOnlyDir);
|
|
|
|
// Copy qa-only skill files
|
|
copyDirSync(path.join(ROOT, 'qa-only'), path.join(qaOnlyDir, 'qa-only'));
|
|
|
|
// Copy qa templates (qa-only references qa/templates/qa-report-template.md)
|
|
fs.mkdirSync(path.join(qaOnlyDir, 'qa', 'templates'), { recursive: true });
|
|
fs.copyFileSync(
|
|
path.join(ROOT, 'qa', 'templates', 'qa-report-template.md'),
|
|
path.join(qaOnlyDir, 'qa', 'templates', 'qa-report-template.md'),
|
|
);
|
|
|
|
// Init git repo (qa-only checks for feature branch in diff-aware mode)
|
|
const run = (cmd: string, args: string[]) =>
|
|
spawnSync(cmd, args, { cwd: qaOnlyDir, stdio: 'pipe', timeout: 5000 });
|
|
|
|
run('git', ['init', '-b', 'main']);
|
|
run('git', ['config', 'user.email', 'test@test.com']);
|
|
run('git', ['config', 'user.name', 'Test']);
|
|
fs.writeFileSync(path.join(qaOnlyDir, 'index.html'), '<h1>Test</h1>\n');
|
|
run('git', ['add', '.']);
|
|
run('git', ['commit', '-m', 'initial']);
|
|
});
|
|
|
|
afterAll(() => {
|
|
try { fs.rmSync(qaOnlyDir, { recursive: true, force: true }); } catch {}
|
|
});
|
|
|
|
testConcurrentIfSelected('qa-only-no-fix', async () => {
|
|
const result = await runSkillTest({
|
|
prompt: `${browserPrompt('qa-only/SKILL.md')}
|
|
|
|
Read the file qa-only/SKILL.md for the QA-only workflow instructions.
|
|
Skip the preamble bash block, lake intro, telemetry, and contributor mode sections — go straight to the QA workflow.
|
|
|
|
Run a Quick QA test on ${testServer.url}/qa-eval.html
|
|
Do NOT use AskUserQuestion — run Quick tier directly.
|
|
Write your report to ${qaOnlyDir}/qa-reports/qa-only-report.md`,
|
|
workingDirectory: qaOnlyDir,
|
|
maxTurns: 40,
|
|
allowedTools: ['Bash', 'Read', 'Write', 'Glob'], // NO Edit — the critical guardrail
|
|
timeout: CAPTURE_MS,
|
|
testName: 'qa-only-no-fix',
|
|
runId,
|
|
});
|
|
|
|
logCost('/qa-only', result);
|
|
|
|
// Verify Edit was not used — the critical guardrail for report-only mode.
|
|
// Glob is read-only and may be used for file discovery (e.g. finding SKILL.md).
|
|
const editCalls = result.toolCalls.filter(tc => tc.tool === 'Edit');
|
|
if (editCalls.length > 0) {
|
|
console.warn('qa-only used Edit tool:', editCalls.length, 'times');
|
|
}
|
|
|
|
const exitOk = ['success', 'error_max_turns'].includes(result.exitReason);
|
|
recordE2E(evalCollector, '/qa-only no-fix', 'QA-Only skill E2E', result, {
|
|
passed: exitOk && editCalls.length === 0,
|
|
});
|
|
|
|
expect(editCalls).toHaveLength(0);
|
|
|
|
// Accept error_max_turns — the agent doing thorough QA is not a failure
|
|
expect(['success', 'error_max_turns']).toContain(result.exitReason);
|
|
|
|
// Verify git working tree is still clean (no source modifications)
|
|
const gitStatus = spawnSync('git', ['status', '--porcelain'], {
|
|
cwd: qaOnlyDir, stdio: 'pipe', timeout: 30_000,
|
|
});
|
|
const statusLines = gitStatus.stdout.toString().trim().split('\n').filter(
|
|
(l: string) => l.trim() && !l.includes('.prompt-tmp') && !l.includes('.gstack/') && !l.includes('qa-reports/'),
|
|
);
|
|
expect(statusLines.filter((l: string) => l.startsWith(' M') || l.startsWith('M '))).toHaveLength(0);
|
|
}, CAPTURE_MS);
|
|
}, browserSelected);
|
|
|
|
// --- QA Fix Loop E2E ---
|
|
|
|
describeIfSelected('QA Fix Loop E2E', ['qa-fix-loop'], () => {
|
|
function createQaFixFixture() {
|
|
const qaFixDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-qa-fix-'));
|
|
setupBrowseShims(qaFixDir);
|
|
|
|
// Copy qa skill files
|
|
copyDirSync(path.join(ROOT, 'qa'), path.join(qaFixDir, 'qa'));
|
|
|
|
// Create a simple HTML page with obvious fixable bugs
|
|
fs.writeFileSync(path.join(qaFixDir, 'index.html'), `<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head><meta charset="utf-8"><title>Test App</title></head>
|
|
<body>
|
|
<h1>Welcome to Test App</h1>
|
|
<nav>
|
|
<a href="/about">About</a>
|
|
<a href="/nonexistent-broken-page">Help</a> <!-- BUG: broken link -->
|
|
</nav>
|
|
<form id="contact">
|
|
<input type="text" name="name" placeholder="Name">
|
|
<input type="email" name="email" placeholder="Email">
|
|
<button type="submit" disabled>Send</button> <!-- BUG: permanently disabled -->
|
|
</form>
|
|
<img src="/missing-logo.png"> <!-- BUG: missing alt text -->
|
|
<script>console.error("TypeError: Cannot read property 'map' of undefined");</script> <!-- BUG: console error -->
|
|
</body>
|
|
</html>
|
|
`);
|
|
|
|
// Init git repo with clean working tree
|
|
const run = (cmd: string, args: string[]) =>
|
|
spawnSync(cmd, args, { cwd: qaFixDir, stdio: 'pipe', timeout: 5000 });
|
|
|
|
run('git', ['init', '-b', 'main']);
|
|
run('git', ['config', 'user.email', 'test@test.com']);
|
|
run('git', ['config', 'user.name', 'Test']);
|
|
run('git', ['add', '.']);
|
|
run('git', ['commit', '-m', 'initial commit']);
|
|
|
|
// Start a local server serving from the working directory so fixes are reflected on refresh
|
|
const qaFixServer = Bun.serve({
|
|
port: 0,
|
|
hostname: '127.0.0.1',
|
|
fetch(req) {
|
|
const url = new URL(req.url);
|
|
let filePath = url.pathname === '/' ? '/index.html' : url.pathname;
|
|
filePath = filePath.replace(/^\//, '');
|
|
const fullPath = path.join(qaFixDir, filePath);
|
|
if (!fs.existsSync(fullPath)) {
|
|
return new Response('Not Found', { status: 404 });
|
|
}
|
|
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
return new Response(content, {
|
|
headers: { 'Content-Type': 'text/html' },
|
|
});
|
|
},
|
|
});
|
|
const initial = spawnSync('git', ['rev-parse', 'HEAD'], {
|
|
cwd: qaFixDir, stdio: 'pipe', timeout: 5000,
|
|
});
|
|
if (initial.status !== 0) {
|
|
qaFixServer.stop();
|
|
fs.rmSync(qaFixDir, { recursive: true, force: true });
|
|
throw new Error('QA fixture initial commit failed');
|
|
}
|
|
return { qaFixDir, qaFixServer, initialCommit: initial.stdout.toString().trim() };
|
|
}
|
|
|
|
testConcurrentIfSelected('qa-fix-loop', async () => {
|
|
// A retry must receive the seeded defects again, not the first attempt's fixes.
|
|
const { qaFixDir, qaFixServer, initialCommit } = createQaFixFixture();
|
|
try {
|
|
const qaFixUrl = `http://127.0.0.1:${qaFixServer!.port}`;
|
|
|
|
const result = await runSkillTest({
|
|
prompt: `${browserPrompt('qa/SKILL.md')}
|
|
|
|
Read the file qa/SKILL.md for the QA workflow instructions.
|
|
qa is a carved skill: when SKILL.md tells you to Read ~/.claude/skills/gstack/qa/sections/<file>, read qa/sections/<file> in this working directory instead (same content, local copy).
|
|
Skip the preamble bash block, lake intro, telemetry, and contributor mode sections — go straight to the QA workflow.
|
|
|
|
Run a Quick-tier QA test on ${qaFixUrl}
|
|
The source code for this page is at ${qaFixDir}/index.html — you can fix bugs there.
|
|
Do NOT use AskUserQuestion — run Quick tier directly.
|
|
Write your report to ${qaFixDir}/qa-reports/qa-report.md
|
|
|
|
This is a test+fix loop: find bugs, fix them in the source code, commit each fix, and re-verify.`,
|
|
workingDirectory: qaFixDir,
|
|
maxTurns: 40,
|
|
allowedTools: ['Bash', 'Read', 'Write', 'Edit', 'Glob', 'Grep'],
|
|
timeout: CAPTURE_LONG_MS,
|
|
testName: 'qa-fix-loop',
|
|
runId,
|
|
});
|
|
|
|
logCost('/qa fix loop', result);
|
|
let passed = false;
|
|
try {
|
|
// Accept error_max_turns — fix loop may use many turns
|
|
expect(['success', 'error_max_turns']).toContain(result.exitReason);
|
|
|
|
// Verify at least one fix commit was made beyond the initial commit
|
|
const gitLog = spawnSync('git', ['log', '--oneline'], {
|
|
cwd: qaFixDir, stdio: 'pipe', timeout: 30_000,
|
|
});
|
|
const commits = gitLog.stdout.toString().trim().split('\n');
|
|
console.log(`/qa fix loop: ${commits.length} commits total (1 initial + ${commits.length - 1} fixes)`);
|
|
expect(commits.length).toBeGreaterThan(1);
|
|
|
|
// Verify a committed change to the seeded source, regardless of mutation tool.
|
|
// A report-only commit or an uncommitted edit cannot satisfy this contract.
|
|
const sourceDiff = spawnSync('git', ['diff', '--exit-code', initialCommit, 'HEAD', '--', 'index.html'], {
|
|
cwd: qaFixDir, stdio: 'pipe', timeout: 30_000,
|
|
});
|
|
expect(sourceDiff.status).toBe(1);
|
|
expect(sourceDiff.stdout.toString().trim().length).toBeGreaterThan(0);
|
|
passed = true;
|
|
} finally {
|
|
recordE2E(evalCollector, '/qa fix loop', 'QA Fix Loop E2E', result, { passed });
|
|
}
|
|
} finally {
|
|
qaFixServer.stop();
|
|
try { fs.rmSync(qaFixDir, { recursive: true, force: true }); } catch {}
|
|
}
|
|
}, CAPTURE_LONG_MS);
|
|
}, browserSelected);
|
|
|
|
// --- Test Bootstrap E2E ---
|
|
|
|
describeIfSelected('Test Bootstrap E2E', ['qa-bootstrap'], () => {
|
|
let bootstrapDir: string;
|
|
let bootstrapServer: ReturnType<typeof Bun.serve>;
|
|
|
|
beforeAll(() => {
|
|
bootstrapDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-bootstrap-'));
|
|
setupBrowseShims(bootstrapDir);
|
|
|
|
// Copy qa skill files
|
|
copyDirSync(path.join(ROOT, 'qa'), path.join(bootstrapDir, 'qa'));
|
|
|
|
// Create a minimal Node.js project with NO test framework
|
|
fs.writeFileSync(path.join(bootstrapDir, 'package.json'), JSON.stringify({
|
|
name: 'test-bootstrap-app',
|
|
version: '1.0.0',
|
|
type: 'module',
|
|
}, null, 2));
|
|
|
|
// Create a simple app file with a bug
|
|
fs.writeFileSync(path.join(bootstrapDir, 'app.js'), `
|
|
export function add(a, b) { return a + b; }
|
|
export function subtract(a, b) { return a - b; }
|
|
export function divide(a, b) { return a / b; } // BUG: no zero check
|
|
`);
|
|
|
|
// Create a simple HTML page with a bug
|
|
fs.writeFileSync(path.join(bootstrapDir, 'index.html'), `<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head><meta charset="utf-8"><title>Bootstrap Test</title></head>
|
|
<body>
|
|
<h1>Test App</h1>
|
|
<a href="/nonexistent-page">Broken Link</a>
|
|
<script>console.error("ReferenceError: undefinedVar is not defined");</script>
|
|
</body>
|
|
</html>
|
|
`);
|
|
|
|
// Init git repo
|
|
const run = (cmd: string, args: string[]) =>
|
|
spawnSync(cmd, args, { cwd: bootstrapDir, stdio: 'pipe', timeout: 5000 });
|
|
run('git', ['init', '-b', 'main']);
|
|
run('git', ['config', 'user.email', 'test@test.com']);
|
|
run('git', ['config', 'user.name', 'Test']);
|
|
run('git', ['add', '.']);
|
|
run('git', ['commit', '-m', 'initial commit']);
|
|
|
|
// Serve from working directory
|
|
bootstrapServer = Bun.serve({
|
|
port: 0,
|
|
hostname: '127.0.0.1',
|
|
fetch(req) {
|
|
const url = new URL(req.url);
|
|
let filePath = url.pathname === '/' ? '/index.html' : url.pathname;
|
|
filePath = filePath.replace(/^\//, '');
|
|
const fullPath = path.join(bootstrapDir, filePath);
|
|
if (!fs.existsSync(fullPath)) {
|
|
return new Response('Not Found', { status: 404 });
|
|
}
|
|
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
return new Response(content, {
|
|
headers: { 'Content-Type': 'text/html' },
|
|
});
|
|
},
|
|
});
|
|
});
|
|
|
|
afterAll(() => {
|
|
bootstrapServer?.stop();
|
|
try { fs.rmSync(bootstrapDir, { recursive: true, force: true }); } catch {}
|
|
});
|
|
|
|
testConcurrentIfSelected('qa-bootstrap', async () => {
|
|
// Test ONLY the bootstrap phase — install vitest, create config, write one test
|
|
const bsDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-bs-'));
|
|
|
|
// Minimal Node.js project with no test framework
|
|
fs.writeFileSync(path.join(bsDir, 'package.json'), JSON.stringify({
|
|
name: 'bootstrap-test-app', version: '1.0.0', type: 'module',
|
|
}, null, 2));
|
|
fs.writeFileSync(path.join(bsDir, 'app.js'), `
|
|
export function add(a, b) { return a + b; }
|
|
export function subtract(a, b) { return a - b; }
|
|
export function divide(a, b) { return a / b; }
|
|
`);
|
|
|
|
// Init git repo
|
|
const run = (cmd: string, args: string[]) =>
|
|
spawnSync(cmd, args, { cwd: bsDir, stdio: 'pipe', timeout: 5000 });
|
|
run('git', ['init', '-b', 'main']);
|
|
run('git', ['config', 'user.email', 'test@test.com']);
|
|
run('git', ['config', 'user.name', 'Test']);
|
|
run('git', ['add', '.']);
|
|
run('git', ['commit', '-m', 'initial']);
|
|
|
|
const result = await runSkillTest({
|
|
prompt: `This is a Node.js project with no test framework. It has a package.json and app.js with simple functions (add, subtract, divide).
|
|
|
|
Set up a test framework:
|
|
1. Install vitest: bun add -d vitest
|
|
2. Create vitest.config.ts with a minimal config
|
|
3. Write one test file (app.test.js) that tests the add() function
|
|
4. Run the test to verify it passes
|
|
5. Create TESTING.md explaining how to run tests
|
|
|
|
Do NOT fix any bugs. Do NOT use AskUserQuestion — just pick vitest.`,
|
|
workingDirectory: bsDir,
|
|
maxTurns: 12,
|
|
allowedTools: ['Bash', 'Read', 'Write', 'Edit', 'Glob'],
|
|
timeout: JUDGE_MS,
|
|
testName: 'qa-bootstrap',
|
|
runId,
|
|
});
|
|
|
|
logCost('/qa bootstrap', result);
|
|
|
|
const hasTestConfig = fs.existsSync(path.join(bsDir, 'vitest.config.ts'))
|
|
|| fs.existsSync(path.join(bsDir, 'vitest.config.js'));
|
|
const hasTestFile = fs.readdirSync(bsDir).some(f => f.includes('.test.'));
|
|
const hasTestingMd = fs.existsSync(path.join(bsDir, 'TESTING.md'));
|
|
|
|
recordE2E(evalCollector, '/qa bootstrap', 'Test Bootstrap E2E', result, {
|
|
passed: hasTestConfig && ['success', 'error_max_turns'].includes(result.exitReason),
|
|
});
|
|
|
|
expect(['success', 'error_max_turns']).toContain(result.exitReason);
|
|
expect(hasTestConfig).toBe(true);
|
|
console.log(`Test config: ${hasTestConfig}, Test file: ${hasTestFile}, TESTING.md: ${hasTestingMd}`);
|
|
|
|
try { fs.rmSync(bsDir, { recursive: true, force: true }); } catch {}
|
|
}, JUDGE_MS);
|
|
});
|
|
|
|
// Module-level afterAll — finalize eval collector after all tests complete.
|
|
// Explicit 60s timeout: finalize does a JSON save + cross-run comparison and
|
|
// has been observed at 6.26s, past bun's 5s default hook timeout.
|
|
afterAll(async () => {
|
|
await finalizeEvalCollector(evalCollector);
|
|
}, 60_000);
|