Skip to content

Turn one illustration into an animated 2D mesh avatar with a coding agent and a local editor

Keep stdin closed for codex exec in npm run create

shinshin86aab58fc16ee3
diff --git a/tests/create-avatar.test.ts b/tests/create-avatar.test.ts
index ab5c445..77f9a6b 100644
--- a/tests/create-avatar.test.ts
+++ b/tests/create-avatar.test.ts
@@ -7,10 +7,10 @@ const root = fileURLToPath(new URL('..', import.meta.url));
const ready = async () => ['node', 'packages', 'uv', 'python', 'chromium'].map(id => ({ id, status: 'ok', message: id }));
function harness({ files = [] as string[], statuses = {} as Record<string, number | null>, environment = ready } = {}) {
- const calls: { command: string; args: string[] }[] = [], logs: string[] = [], errors: string[] = [];
+ const calls: { command: string; args: string[]; options?: { stdio?: unknown } }[] = [], logs: string[] = [], errors: string[] = [];
const existing = new Set(files);
- const run = async (command: string, args: string[]) => {
- calls.push({ command, args });
+ const run = async (command: string, args: string[], options?: { stdio?: unknown }) => {
+ calls.push({ command, args, options });
const key = command === process.execPath ? 'vite' : `${command} ${args[0]}`;
if (key === 'codex exec' && !(key in statuses)) {
const name = args.at(-1)!.match(/in projects\/([^ ]+) by/)![1];
@@ -50,6 +50,7 @@ describe('npm run create', () => {
expect(calls.map(call => `${call.command === process.execPath ? 'vite' : call.command} ${call.args[0]}`)).toEqual(['uv run', 'codex exec', 'vite ' + join(root, 'node_modules/vite/bin/vite.js')]);
expect(calls[0].args).toEqual(['run', 'tools/new-project.py', '/work/mio.png', 'mio']);
expect(calls[1].args.slice(0, 6)).toEqual(['exec', '--approve-for-me', '-C', root, '--add-dir', '/cache/uv']);
+ expect(calls[1].options?.stdio).toEqual(['ignore', 'inherit', 'inherit']);
expect(calls[2].args).toContain('/?project=mio');
});
diff --git a/tools/create.mjs b/tools/create.mjs
index af105b3..9ff0ed0 100644
--- a/tools/create.mjs
+++ b/tools/create.mjs
@@ -135,8 +135,9 @@ export async function create(argv, deps = {}) {
log(t.agent);
// Codex works in its sandbox and asks for more only to run Chromium and similar tools;
// --approve-for-me has those requests reviewed automatically instead of by a person.
+ // Its stdin stays closed: codex exec would otherwise wait to append piped input to the prompt.
const cache = await read('uv', ['cache', 'dir']);
- const agent = await run('codex', ['exec', '--approve-for-me', '-C', root, ...(cache ? ['--add-dir', cache] : []), agentPrompt(name, options)]);
+ const agent = await run('codex', ['exec', '--approve-for-me', '-C', root, ...(cache ? ['--add-dir', cache] : []), agentPrompt(name, options)], { stdio: ['ignore', 'inherit', 'inherit'] });
if (agent !== 0) { error(t.agentFailed(agent)); return agent ?? 1; }
const project = join(root, 'projects', name);
if (!exists(join(project, 'rig.json')) || !exists(join(project, 'built', 'base.png'))) { error(t.incomplete(name)); return 1; }