Turn one illustration into an animated 2D mesh avatar with a coding agent and a local editor
Add --expressions to npm run create for drawn expression variants
shinshin86f2c2483e4625
diff --git a/README.ja.md b/README.ja.mdindex 35de9b9..c269433 100644--- a/README.ja.md+++ b/README.ja.md@@ -64,7 +64,7 @@ npm run create -- /path/to/your-image.png通常は数十分かかります。Codex のメモは `projects/<name>/HANDOVER.md` に書き出されます。Codex は `--approve-for-me` 付きで動くため、ポーズ確認用の Chromium など sandbox の外でツールを動かす許可は、あなたの代わりに自動レビューが判断します。`--variants` を付けると閉じ目と口の形も描かせます。-このとき画像とマスクが Codex の画像生成に送られます。オプションは `npm run create -- --help` で確認できます。+`--expressions` を付けると、さらに悲しい目・驚いた目・怒った口・悲しい口も描かせます。どちらも画像とマスクが Codex の画像生成に送られます。オプションは `npm run create -- --help` で確認できます。### 2. プロジェクトを開いて確認するdiff --git a/README.md b/README.mdindex f0cc54d..b3aaaf8 100644--- a/README.md+++ b/README.md@@ -85,8 +85,8 @@ npm run create -- /path/to/your-image.pngIt usually takes tens of minutes. Codex writes its notes to `projects/<name>/HANDOVER.md`.It runs with `--approve-for-me`, so its requests to run tools outside its sandbox, such asChromium for the pose review, are reviewed automatically instead of by you. Add `--variants`-to have it draw closed eyes and mouth shapes as well; this sends the image and masks to its-image generator. `npm run create -- --help` lists the options.+to have it draw closed eyes and mouth shapes as well, or `--expressions` to add sad and+surprised eyes and angry and sad mouths; both send the image and masks to its image generator. `npm run create -- --help` lists the options.### 2. Open the project and check itdiff --git a/README.zh.md b/README.zh.mdindex fa30ead..4cd7547 100644--- a/README.zh.md+++ b/README.zh.md@@ -63,7 +63,7 @@ npm run create -- /path/to/your-image.png通常需要几十分钟。Codex 的说明写在 `projects/<name>/HANDOVER.md`。Codex 以 `--approve-for-me`运行,因此在沙箱外运行工具(例如姿势检查用的 Chromium)的请求由自动审核代替你决定。加上-`--variants` 还会绘制闭眼和嘴型,此时图像和遮罩会发送到 Codex 的图像生成器。用+`--variants` 还会绘制闭眼和嘴型;加上 `--expressions` 还会绘制悲伤和惊讶的眼睛以及生气和悲伤的嘴。两者都会把图像和遮罩发送到 Codex 的图像生成器。用`npm run create -- --help` 查看全部选项。### 2. 打开项目并检查diff --git a/tests/create-avatar.test.ts b/tests/create-avatar.test.tsindex 77f9a6b..51f172c 100644--- a/tests/create-avatar.test.ts+++ b/tests/create-avatar.test.ts@@ -27,6 +27,7 @@ describe('npm run create', () => {test('parses the image, name and flags', () => {expect(parseArgs(['a.png', '--name', 'mio', '--variants', '--no-open', '--lang', 'ja'])).toMatchObject({ image: 'a.png', name: 'mio', variants: true, open: false });expect(parseArgs(['--name=mio', 'b.png'])).toMatchObject({ image: 'b.png', name: 'mio', variants: false, open: true });+ expect(parseArgs(['c.png', '--expressions'])).toMatchObject({ variants: true, expressions: true });});test('derives a project name from the file name and skips taken names', () => {@@ -41,7 +42,10 @@ describe('npm run create', () => {expect(plain).toContain('projects/mio/HANDOVER.md');expect(plain).toContain('Step 6: skip it');expect(plain).toContain('do not stage or commit');- expect(agentPrompt('mio', { variants: true })).toContain('the person agreed to send source.png and the masks');+ const variants = agentPrompt('mio', { variants: true });+ expect(variants).toContain('the person agreed to send source.png and the masks');+ expect(variants).toContain('not the optional expression ones');+ expect(agentPrompt('mio', { variants: true, expressions: true })).toContain('eyes_sad, eyes_surprise, mouth_angry, mouth_sad');});test('creates the project, runs Codex and opens the editor on it', async () => {diff --git a/tools/create.mjs b/tools/create.mjsindex 9ff0ed0..cb18cde 100644--- a/tools/create.mjs+++ b/tools/create.mjs@@ -11,10 +11,11 @@ const root = fileURLToPath(new URL('..', import.meta.url));const text = {en: {- usage: 'Usage: npm run create -- <image.png> [--name <name>] [--variants] [--no-open]\n\n'+ usage: 'Usage: npm run create -- <image.png> [--name <name>] [--variants] [--expressions] [--no-open]\n\n'+ ' --name project name under projects/ (default: from the file name)\n'+ ' --variants let Codex send source.png and masks to its image generator for drawn\n'+ ' closed eyes and mouth shapes (Step 6 of the agent guide)\n'+ + ' --expressions also draw sad and surprised eyes and angry and sad mouths (implies --variants)\n'+ ' --no-open do not start the editor when the avatar is ready',missingImage: 'Give the path of a PNG illustration.',noImage: path => `Image not found: ${path}`,@@ -30,10 +31,11 @@ const text = {opening: 'Starting the editor. Press Ctrl+C to stop it.',},ja: {- usage: '使い方: npm run create -- <image.png> [--name <name>] [--variants] [--no-open]\n\n'+ usage: '使い方: npm run create -- <image.png> [--name <name>] [--variants] [--expressions] [--no-open]\n\n'+ ' --name projects/ に作るプロジェクト名(既定: ファイル名から作成)\n'+ ' --variants 閉じ目と口の形の描き分けのため、source.png とマスクを Codex の画像生成に\n'+ ' 送ることを許可する(エージェントガイドの Step 6)\n'+ + ' --expressions 悲しい目・驚いた目・怒った口・悲しい口も描かせる(--variants を含む)\n'+ ' --no-open アバターができてもエディタを起動しない',missingImage: 'PNG のイラストのパスを指定してください。',noImage: path => `画像が見つかりません: ${path}`,@@ -51,11 +53,12 @@ const text = {};export function parseArgs(argv) {- const options = { image: undefined, name: undefined, variants: false, open: true, help: false };+ const options = { image: undefined, name: undefined, variants: false, expressions: false, open: true, help: false };for (let index = 0; index < argv.length; index++) {const arg = argv[index];if (arg === '--help' || arg === '-h') options.help = true;else if (arg === '--variants') options.variants = true;+ else if (arg === '--expressions') options.variants = options.expressions = true;else if (arg === '--no-open') options.open = false;else if (arg === '--name') options.name = argv[++index];else if (arg.startsWith('--name=')) options.name = arg.slice(7);@@ -76,7 +79,7 @@ export function projectName(image, taken = name => existsSync(join(root, 'projec}/** The request Codex runs non-interactively: every question in the guide is answered here. */-export function agentPrompt(name, { variants }) {+export function agentPrompt(name, { variants, expressions = false }) {const project = `projects/${name}`;return [`Create a mesh avatar in ${project} by following docs/agent-guide.md from "Before you start" through Step 7.`,@@ -87,7 +90,7 @@ export function agentPrompt(name, { variants }) {`- Vision check: run it with ${project}/work/vision-check as the folder. If the score fails, stop and explain it in the hand-over notes.`,'- Image warnings (pose, covered face, missing transparency): record them in the hand-over notes and continue.',variants- ? '- Step 6: the person agreed to send source.png and the masks to your built-in image generator. Generate the required variants (closed, half and smiling eyes; mouths あ, half あ, い, お), not the optional expression ones, then run build-sprites and review the poses again.'+ ? `- Step 6: the person agreed to send source.png and the masks to your built-in image generator. Generate the required variants (closed, half and smiling eyes; mouths あ, half あ, い, お)${expressions ? ' and the expression variants (eyes_sad, eyes_surprise, mouth_angry, mouth_sad)' : ', not the optional expression ones'}, then run build-sprites and review the poses again. Generate a variant again when build-sprites rejects it or its pose frames look wrong.`: '- Step 6: skip it. The person did not agree to send the image to an image generator.',`- Step 7: write the hand-over notes to ${project}/HANDOVER.md instead of telling the person. The editor is opened for them, so leave out how to open it.`,'',