wishforge-ide/scripts/smoke-control.mjs
eust-w 0ef99b1e6d style: add Prettier and EditorConfig, format the codebase
Adds prettier 3.9.8 (exact) with a shared config (single quotes,
120 columns, trailing commas), .prettierignore, .editorconfig and the
`format` / `format:check` scripts, then formats all TypeScript,
JavaScript, CSS, JSON and YAML sources.

Purely mechanical: no behaviour change. Typecheck passes, the vitest
suite and the 74 IDE node tests produce the same results as before
(socket-binding tests still cannot run inside this sandbox).
Previously the longest source line was ~3000 characters; reviewing the
following semantic changes now produces readable diffs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 13:32:43 +08:00

83 lines
3.1 KiB
JavaScript

import assert from 'node:assert/strict';
import { randomUUID } from 'node:crypto';
process.loadEnvFile('.env.local');
const base = process.env.WF_API_URL ?? 'http://127.0.0.1:4000';
const headers = { Authorization: `Bearer ${process.env.WF_DEV_AUTH_TOKEN}`, 'Content-Type': 'application/json' };
const call = async (route, body, extra = {}) => {
const response = await fetch(`${base}${route}`, {
method: body ? 'POST' : 'GET',
headers: { ...headers, ...extra },
body: body ? JSON.stringify(body) : undefined,
});
const result = await response.json();
assert.ok(response.ok, JSON.stringify(result));
return result.data;
};
assert.equal((await fetch(`${base}/v1/projects`)).status, 401);
const project = await call('/v1/projects', {
name: 'Control API QA (no model execution)',
verificationCommands: [['node', '--test']],
});
const input = {
goal: 'Validate REST/MCP submission parity only',
acceptanceCriteria: ['A repeated request returns the same run'],
provider: 'codex',
};
const idempotency = randomUUID();
const submitted = await call(`/v1/projects/${project.id}/wishes`, input, { 'Idempotency-Key': idempotency });
const duplicate = await call(`/v1/projects/${project.id}/wishes`, input, { 'Idempotency-Key': idempotency });
assert.equal(submitted.run_id, duplicate.run_id);
const mcp = async (method, params, id) => {
const response = await fetch(`${base}/mcp`, {
method: 'POST',
headers: { ...headers, Accept: 'application/json, text/event-stream', 'MCP-Protocol-Version': '2025-11-25' },
body: JSON.stringify({ jsonrpc: '2.0', id, method, params }),
});
assert.equal(response.status, 200);
return response.json();
};
const hello = await mcp(
'initialize',
{ protocolVersion: '2025-11-25', capabilities: {}, clientInfo: { name: 'wishforge-local-qa', version: '1.0' } },
1,
);
assert.equal(hello.result.serverInfo.name, 'wishforge');
const tools = await mcp('tools/list', {}, 2);
assert.equal(tools.result.tools.length, 7);
const repeated = await mcp(
'tools/call',
{ name: 'submit_wish', arguments: { project_id: project.id, idempotency_key: idempotency, ...input } },
3,
);
const payload = JSON.parse(repeated.result.content[0].text);
assert.equal(payload.data.run_id, submitted.run_id);
const run = await call(`/v1/runs/${submitted.run_id}`);
assert.equal(run.status, 'waiting');
const events = await call(`/v1/runs/${submitted.run_id}/events`);
assert.equal(events[0].seq, 1);
await call(`/v1/runs/${submitted.run_id}/commands`, { action: 'cancel' }, { 'Idempotency-Key': randomUUID() });
assert.equal((await call(`/v1/runs/${submitted.run_id}`)).status, 'canceled');
assert.equal((await call(`/v1/runs/${submitted.run_id}/delivery`)).accepted, false);
console.log(
JSON.stringify(
{
passed: [
'unauthenticated-denied',
'durable-submit',
'idempotent-retry',
'mcp-initialize',
'mcp-seven-tools',
'rest-mcp-parity',
'events',
'cancel',
'no-fabricated-delivery',
],
fixtureProject: project.id,
fixtureRun: submitted.run_id,
providerCalls: 0,
},
null,
2,
),
);