import assert from 'node:assert/strict';
import test from 'node:test';
import { RESUME_PROMPT_VERSION, workerResumePrompt } from '../src/execution-prompts.js';

test('resume prompt is versioned, concise, state-authoritative, and separate from assignment prose', () => {
  const workerId = `wrk_${crypto.randomUUID()}`;
  const text = workerResumePrompt({ workerId, reason: 'auto_resume', sequence: 7 });
  assert.equal(RESUME_PROMPT_VERSION, 1);
  assert.match(text, new RegExp(workerId));
  assert.match(text, /Execution attempt: 7 \(auto_resume\)/);
  assert.match(text, /Recover authoritative state using the ChatGPT Orchestrator MCP/);
  assert.match(text, /Do not redo completed work/);
  assert.match(text, /worker\.complete/);
  assert.match(text, /worker\.await_human/);
  assert.match(text, /continuation-state output contract/);
  assert.doesNotMatch(text, /click Retry|Retry button|browser state|full assignment/i);
  assert.ok(text.length < 1_500);
});

test('resume prompt does not require a sequence number', () => {
  const workerId = `wrk_${crypto.randomUUID()}`;
  const text = workerResumePrompt({ workerId, reason: 'recovery' });
  assert.match(text, new RegExp(workerId));
  assert.doesNotMatch(text, /Execution attempt:/);
});
