diff --git a/examples/node/enter-spec-mode.ts b/examples/node/enter-spec-mode.ts index ad1c269..b145273 100644 --- a/examples/node/enter-spec-mode.ts +++ b/examples/node/enter-spec-mode.ts @@ -31,7 +31,7 @@ import { const tempDir = await realpath( await mkdtemp(join(tmpdir(), 'droid-sdk-enter-spec-')) ); -const outputPath = join(tempDir, 'hello.txt'); +const outputPath = join(tempDir, 'hello.md'); /** True when a tool call only writes the file that the prompt asks for. */ function writesOnlyOutputFile(details: ToolConfirmationDetails): boolean { @@ -100,7 +100,8 @@ try { // The handler cancels shell commands, so the prompt asks for a file tool. for await (const message of session.stream( - `Create ${outputPath} containing "hello". Write it with a file editing tool, not a shell command.` + `Create ${outputPath}, a short Markdown note that says hello. ` + + 'Write it with a file editing tool, not a shell command.' )) { if (message.type === DroidMessageType.Result && !message.success) { throw new Error( @@ -112,7 +113,7 @@ try { await session.close(); } - console.log(await readFile(outputPath, 'utf8')); + console.log(`\nhello.md:\n${await readFile(outputPath, 'utf8')}`); } finally { await rm(tempDir, { recursive: true, force: true }); } diff --git a/examples/node/spec-mode-new-session.ts b/examples/node/spec-mode-new-session.ts index ccfb2e1..82da7c3 100644 --- a/examples/node/spec-mode-new-session.ts +++ b/examples/node/spec-mode-new-session.ts @@ -38,7 +38,7 @@ import { const tempDir = await realpath( await mkdtemp(join(tmpdir(), 'droid-sdk-spec-')) ); -const outputPath = join(tempDir, 'hello.txt'); +const outputPath = join(tempDir, 'hello.md'); /** True when a tool call only writes the file that the prompt asks for. */ function writesOnlyOutputFile(details: ToolConfirmationDetails): boolean { @@ -115,7 +115,7 @@ try { try { // The handler cancels shell commands, so the prompt asks for a file tool. for await (const message of session.stream( - `Plan then create ${outputPath} containing "Hello from Droid". ` + + `Plan then create ${outputPath}, a short Markdown note titled "Hello from Droid". ` + 'Write it with a file editing tool, not a shell command.' )) { if (message.type === DroidMessageType.Result && !message.success) { diff --git a/examples/node/spec-mode-same-session.ts b/examples/node/spec-mode-same-session.ts index 580d7fb..01040e9 100644 --- a/examples/node/spec-mode-same-session.ts +++ b/examples/node/spec-mode-same-session.ts @@ -37,7 +37,7 @@ import { const tempDir = await realpath( await mkdtemp(join(tmpdir(), 'droid-sdk-spec-')) ); -const outputPath = join(tempDir, 'hello.txt'); +const outputPath = join(tempDir, 'hello.md'); /** True when a tool call only writes the file that the prompt asks for. */ function writesOnlyOutputFile(details: ToolConfirmationDetails): boolean { @@ -115,7 +115,7 @@ try { try { // The handler cancels shell commands, so the prompt asks for a file tool. for await (const message of session.stream( - `Plan then create ${outputPath} containing "Hello from Droid". ` + + `Plan then create ${outputPath}, a short Markdown note titled "Hello from Droid". ` + 'Write it with a file editing tool, not a shell command.' )) { if (message.type === DroidMessageType.Result && !message.success) { diff --git a/scripts/run-examples.mjs b/scripts/run-examples.mjs index 4c9227d..e760579 100644 --- a/scripts/run-examples.mjs +++ b/scripts/run-examples.mjs @@ -181,11 +181,17 @@ export const EXAMPLES = { timeoutSec: 420, checks: [ exitZero(), - custom('file contains hello', (ctx) => ({ - ok: /^\s*"?hello"?\s*$/im.test( - ctx.stdout.trim().split('\n').pop() ?? '' - ), - })), + // The proposed plan is printed first and may mention hello too, so check + // only the note printed after the last marker. + custom('the note says hello', (ctx) => { + const marker = '\nhello.md:\n'; + const index = ctx.stdout.lastIndexOf(marker); + return { + ok: + index !== -1 && + containsAnyWord(ctx.stdout.slice(index + marker.length), ['hello']), + }; + }), sessionFilesContain( 'ExitSpecMode', 'Droid proposed a spec (ExitSpecMode)'