Files
pbakaus_impeccable/tests/oracle/cases/live-generate.mjs
T
d397140a77 Port /impeccable generate to the engine crates
The Node-era server, CLI, hook, and pin halves of the generate command move
into the Rust workspace, with the protocol unchanged:

- crates/live: POST /agent-target is held open on a channel plus a timer
  thread (the manual-apply deferred pattern), releasing its turnstile
  ticket before it parks like /poll; /agent-target-result resolves it;
  /agent-target-claim is the roll call with its renewable lease. SSE
  connections carry the overlay's clientId: a late overlay is replayed
  every pending target, and a disconnect retires that overlay's report,
  releases its lease, and re-judges each roll call. Shutdown drains held
  requests with server_stopping.
- crates/live/src/live_generate.rs: the live-generate verb (the router
  already forwards every live* verb), same flags, verdicts, and
  _instructions, spelled with the engine's self command.
- crates/hook: every entry stands down on live preview markers
  (skipped: live-preview), checking the proposed content and the file on
  disk for hook-before-edit.
- crates/context: pin accepts generate; the crate's command-metadata.json
  copy carries its entry.

Tests: crates/cli/tests/agent_target.rs (six HTTP cases with an SSE reader),
tests/live-agent-target.test.mjs rewritten to drive the binary (28 cases,
registered in the live suite), hook stand-down cases, oracle goldens for
live-generate plus the re-recorded pin list goldens, the e2e prompt
assertion waiting for the journaled event, and the contract documented in
docs/CLI-CONTRACT.md.

AI-assisted: implemented and tested with Claude Code under maintainer
direction.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-09-15 05:45:49 +05:00

45 lines
2.1 KiB
JavaScript

/**
* `live-generate` (the `generate` command's agent-initiated targeting): the
* verdicts the verb decides locally, without a browser, plus the one the
* helper answers when no overlay is attached. Everything that needs an
* overlay (the roll call, leases, replay) is covered by
* tests/live-agent-target.test.mjs and crates/cli/tests/agent_target.rs.
*/
import { LIVE_FILES } from '../live-helpers.mjs';
const NORM = [
['localhost:\\d{4,5}', 'g', 'localhost:<PORT>'],
['"(port|serverPort)":(\\s*)\\d{4,5}', 'g', '"$1":$2<PORT>'],
['Stopped live server on port \\d+\\.', 'g', 'Stopped live server on port <PORT>.'],
];
export default [
{
id: 'live-generate-local-verdicts', workspace: 'live-html', files: [...LIVE_FILES],
// No helper is recorded in the staged workspace, so every step short
// of a valid request ends in the verb's own verdict, and the valid one
// ends in server_not_running.
steps: [
{ verb: 'live-generate', args: ['--help'] },
{ verb: 'live-generate', args: [] },
{ verb: 'live-generate', args: ['--selector'] },
{ verb: 'live-generate', args: ['--selector', 'h1', '--action', 'bold'] },
{ verb: 'live-generate', args: ['--selector', 'h1', '--count', '9'] },
{ verb: 'live-generate', args: ['--selector', 'h1', '--count', 'three'] },
{ verb: 'live-generate', args: ['--selector', 'h1', '--index', '0'] },
{ verb: 'live-generate', args: ['--selector', 'h1', '--wait-for-browser', 'soon'] },
{ verb: 'live-generate', args: ['--selector', 'h1', '--action', 'bolder'] },
],
},
{
id: 'live-generate-no-browser-connected', workspace: 'live-html', files: [...LIVE_FILES], normalize: NORM,
// A running helper with no overlay attached answers at once instead of
// holding the request.
steps: [
{ verb: 'live-server', daemon: true, readyFile: '.impeccable/live/server.json', readyTimeoutMs: 15000 },
{ verb: 'live-generate', args: ['--selector', 'h1', '--action', 'bolder', '--count', '2', '--prompt', 'warmer'] },
{ verb: 'live-server', args: ['stop'] },
],
},
];