@anime-studio/cli 0.0.0-stage → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -2
  3. package/dist/bin.d.ts +3 -0
  4. package/dist/bin.d.ts.map +1 -0
  5. package/dist/bin.js +238 -0
  6. package/dist/bin.js.map +1 -0
  7. package/dist/describe.d.ts +7 -0
  8. package/dist/describe.d.ts.map +1 -0
  9. package/dist/describe.js +48 -0
  10. package/dist/describe.js.map +1 -0
  11. package/dist/doctor.d.ts +44 -0
  12. package/dist/doctor.d.ts.map +1 -0
  13. package/dist/doctor.js +121 -0
  14. package/dist/doctor.js.map +1 -0
  15. package/dist/index.d.ts +11 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +11 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/load.d.ts +13 -0
  20. package/dist/load.d.ts.map +1 -0
  21. package/dist/load.js +41 -0
  22. package/dist/load.js.map +1 -0
  23. package/dist/skills.d.ts +28 -0
  24. package/dist/skills.d.ts.map +1 -0
  25. package/dist/skills.js +56 -0
  26. package/dist/skills.js.map +1 -0
  27. package/package.json +55 -3
  28. package/skills/animestudio/SKILL.md +165 -0
  29. package/skills/animestudio/examples/first-frame.ts +54 -0
  30. package/skills/animestudio/examples/hello.scene.json +50 -0
  31. package/skills/animestudio/examples/hello.sequence.json +13 -0
  32. package/skills/animestudio/examples/remotion/Root.tsx +25 -0
  33. package/skills/animestudio/examples/remotion/index.ts +5 -0
  34. package/skills/animestudio/examples/render-video.ts +110 -0
  35. package/skills/animestudio/references/packages.md +54 -0
  36. package/skills/animestudio/references/rendering.md +127 -0
  37. package/skills/animestudio/references/scene-format.md +101 -0
  38. package/skills/animestudio/references/validation-and-debugging.md +67 -0
  39. package/skills/animestudio-animation/SKILL.md +176 -0
  40. package/skills/animestudio-animation/examples/gestures.ts +55 -0
  41. package/skills/animestudio-animation/examples/hold.ts +82 -0
  42. package/skills/animestudio-animation/examples/knockdown.ts +68 -0
  43. package/skills/animestudio-animation/examples/sheet.ts +80 -0
  44. package/skills/animestudio-animation/examples/walk-wave-run.ts +59 -0
  45. package/skills/animestudio-animation/references/clips.md +103 -0
  46. package/skills/animestudio-animation/references/director-beats.md +48 -0
  47. package/skills/animestudio-animation/references/holding.md +106 -0
  48. package/skills/animestudio-animation/references/locomotion.md +86 -0
  49. package/skills/animestudio-animation/references/timing.md +89 -0
  50. package/skills/animestudio-characters/SKILL.md +211 -0
  51. package/skills/animestudio-characters/examples/cast.ts +63 -0
  52. package/skills/animestudio-characters/examples/human.ts +52 -0
  53. package/skills/animestudio-characters/examples/import-svg.ts +68 -0
  54. package/skills/animestudio-characters/examples/lumo.svg +36 -0
  55. package/skills/animestudio-characters/examples/sprout.toon.json +116 -0
  56. package/skills/animestudio-characters/examples/sprout.ts +48 -0
  57. package/skills/animestudio-characters/examples/turnaround.ts +91 -0
  58. package/skills/animestudio-characters/references/custom-rig.md +139 -0
  59. package/skills/animestudio-characters/references/import-svg.md +59 -0
  60. package/skills/animestudio-characters/references/look-options.md +143 -0
  61. package/skills/animestudio-characters/references/rig-surface.md +62 -0
  62. package/skills/animestudio-script/SKILL.md +164 -0
  63. package/skills/animestudio-script/examples/director.ts +143 -0
  64. package/skills/animestudio-script/examples/sheet.ts +58 -0
  65. package/skills/animestudio-script/examples/short.ts +193 -0
  66. package/skills/animestudio-script/references/actions.md +84 -0
  67. package/skills/animestudio-script/references/dialogue-lipsync.md +87 -0
  68. package/skills/animestudio-script/references/director.md +110 -0
  69. package/skills/animestudio-script/references/shots-and-editing.md +79 -0
  70. package/skills/animestudio-script/references/writing-for-animation.md +84 -0
  71. package/skills/animestudio-sets/SKILL.md +232 -0
  72. package/skills/animestudio-sets/examples/hillside.scene.json +93 -0
  73. package/skills/animestudio-sets/examples/render-scene.ts +35 -0
  74. package/skills/animestudio-sets/examples/sets.ts +257 -0
  75. package/skills/animestudio-sets/references/drawing-sets.md +119 -0
  76. package/skills/animestudio-sets/references/fx.md +92 -0
  77. package/skills/animestudio-sets/references/lighting-camera.md +93 -0
  78. package/skills/animestudio-sets/references/scene-fields.md +132 -0
package/dist/load.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import type { Issue, SceneAssets, SceneDoc } from "@anime-studio/core";
2
+ export declare const readJson: (path: string) => unknown;
3
+ /** Loads the characters and lip sync files referenced by a scene (paths relative to the scene). Throws on the first file that cannot be read. */
4
+ export declare function loadSceneAssets(scenePath: string, scene: SceneDoc): SceneAssets;
5
+ /**
6
+ * Loads a scene's assets, reporting every file that cannot be read or parsed as an issue at
7
+ * `characters.<id>` / `lipsync.<id>` instead of throwing (for `toon validate`).
8
+ */
9
+ export declare function tryLoadSceneAssets(scenePath: string, scene: SceneDoc): {
10
+ assets: SceneAssets;
11
+ issues: Issue[];
12
+ };
13
+ //# sourceMappingURL=load.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAc,WAAW,EAAE,QAAQ,EAAW,MAAM,oBAAoB,CAAC;AAE5F,eAAO,MAAM,QAAQ,SAAU,MAAM,KAAG,OAAiD,CAAC;AAE1F,iJAAiJ;AACjJ,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,WAAW,CAI/E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,KAAK,EAAE,CAAA;CAAE,CAsB/G"}
package/dist/load.js ADDED
@@ -0,0 +1,41 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, resolve } from "node:path";
3
+ export const readJson = (path) => JSON.parse(readFileSync(path, "utf8"));
4
+ /** Loads the characters and lip sync files referenced by a scene (paths relative to the scene). Throws on the first file that cannot be read. */
5
+ export function loadSceneAssets(scenePath, scene) {
6
+ const { assets, issues } = tryLoadSceneAssets(scenePath, scene);
7
+ if (issues.length)
8
+ throw new Error(`${issues[0].path}: ${issues[0].message}`);
9
+ return assets;
10
+ }
11
+ /**
12
+ * Loads a scene's assets, reporting every file that cannot be read or parsed as an issue at
13
+ * `characters.<id>` / `lipsync.<id>` instead of throwing (for `toon validate`).
14
+ */
15
+ export function tryLoadSceneAssets(scenePath, scene) {
16
+ const base = dirname(resolve(scenePath));
17
+ const issues = [];
18
+ const load = (section, id, rel) => {
19
+ try {
20
+ return readJson(resolve(base, rel));
21
+ }
22
+ catch (e) {
23
+ issues.push({ path: `${section}.${id}`, message: `cannot load "${rel}": ${e.message}`, severity: "error" });
24
+ return undefined;
25
+ }
26
+ };
27
+ const characters = {};
28
+ for (const [id, path] of Object.entries(scene.characters ?? {})) {
29
+ const doc = load("characters", id, path);
30
+ if (doc)
31
+ characters[id] = doc;
32
+ }
33
+ const lipsync = {};
34
+ for (const [id, path] of Object.entries(scene.lipsync ?? {})) {
35
+ const doc = load("lipsync", id, path);
36
+ if (doc)
37
+ lipsync[id] = doc;
38
+ }
39
+ return { assets: { characters, lipsync }, issues };
40
+ }
41
+ //# sourceMappingURL=load.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load.js","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG7C,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;AAE1F,iJAAiJ;AACjJ,MAAM,UAAU,eAAe,CAAC,SAAiB,EAAE,KAAe;IAChE,MAAM,EAAE,MAAM,EAAE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CAAC;IAC/C,KAAK,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,CAAC;QAC7D,MAAM,GAAG,GAAG,IAAI,CAAa,SAAS,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;QAClD,IAAI,GAAG;YAAE,OAAO,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;IAC7B,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC;AACrD,CAAC"}
@@ -0,0 +1,28 @@
1
+ /** An agent skill shipped with animeStudio: its folder name and its frontmatter description. */
2
+ export interface SkillInfo {
3
+ name: string;
4
+ description: string;
5
+ dir: string;
6
+ }
7
+ /**
8
+ * Where the skills are: next to the published package (`skills/`, copied there by the build), or —
9
+ * run from the repository's sources — the repository's own `skills/`.
10
+ */
11
+ export declare function skillsSource(): string;
12
+ /** Every skill shipped with animeStudio. */
13
+ export declare function listSkills(source?: string): SkillInfo[];
14
+ export interface InstallSkillsOptions {
15
+ /** Folder the skills go into (default `~/.claude/skills`, or `.claude/skills` with `project`). */
16
+ dir?: string;
17
+ /** Install into the current project's `.claude/skills` instead of the user's. */
18
+ project?: boolean;
19
+ /** Only these skills (default: all). */
20
+ only?: string[];
21
+ }
22
+ /**
23
+ * Installs the animeStudio agent skills (each `skills/<name>/` folder with its SKILL.md, references
24
+ * and examples) where Claude Code and other agents load skills from. An earlier copy of the same
25
+ * skill is replaced; other skills in the folder are left alone. Returns the installed folders.
26
+ */
27
+ export declare function installSkills(opts?: InstallSkillsOptions): string[];
28
+ //# sourceMappingURL=skills.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../src/skills.ts"],"names":[],"mappings":"AAIA,gGAAgG;AAChG,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAQrC;AAWD,4CAA4C;AAC5C,wBAAgB,UAAU,CAAC,MAAM,SAAiB,GAAG,SAAS,EAAE,CAK/D;AAED,MAAM,WAAW,oBAAoB;IACnC,kGAAkG;IAClG,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wCAAwC;IACxC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,GAAE,oBAAyB,GAAG,MAAM,EAAE,CAevE"}
package/dist/skills.js ADDED
@@ -0,0 +1,56 @@
1
+ import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { join, resolve } from "node:path";
4
+ /**
5
+ * Where the skills are: next to the published package (`skills/`, copied there by the build), or —
6
+ * run from the repository's sources — the repository's own `skills/`.
7
+ */
8
+ export function skillsSource() {
9
+ const here = import.meta.dirname;
10
+ // From the sources (src/) the repository's skills are the current ones; a built package has its copy.
11
+ const order = here.endsWith("src") ? [resolve(here, "..", "..", "..", "skills")] : [resolve(here, "..", "skills")];
12
+ for (const dir of order) {
13
+ if (existsSync(dir) && statSync(dir).isDirectory())
14
+ return dir;
15
+ }
16
+ throw new Error("animeStudio skills not found (expected a skills/ folder next to the package)");
17
+ }
18
+ /** The frontmatter `description` of a SKILL.md (one line or a folded block). */
19
+ function description(skillMd) {
20
+ const fm = /^---\n([\s\S]*?)\n---/.exec(skillMd)?.[1] ?? "";
21
+ const m = /^description:\s*(?:[>|]-?\s*\n((?:[ \t]+.*\n?)+)|(.*))$/m.exec(fm);
22
+ if (!m)
23
+ return "";
24
+ const raw = m[1] ? m[1].split("\n").map((l) => l.trim()).join(" ") : m[2];
25
+ return raw.trim().replace(/^["']|["']$/g, "");
26
+ }
27
+ /** Every skill shipped with animeStudio. */
28
+ export function listSkills(source = skillsSource()) {
29
+ return readdirSync(source)
30
+ .filter((n) => existsSync(join(source, n, "SKILL.md")))
31
+ .sort()
32
+ .map((name) => ({ name, dir: join(source, name), description: description(readFileSync(join(source, name, "SKILL.md"), "utf8")) }));
33
+ }
34
+ /**
35
+ * Installs the animeStudio agent skills (each `skills/<name>/` folder with its SKILL.md, references
36
+ * and examples) where Claude Code and other agents load skills from. An earlier copy of the same
37
+ * skill is replaced; other skills in the folder are left alone. Returns the installed folders.
38
+ */
39
+ export function installSkills(opts = {}) {
40
+ const dest = resolve(opts.dir ?? (opts.project ? join(process.cwd(), ".claude", "skills") : join(homedir(), ".claude", "skills")));
41
+ const skills = listSkills().filter((s) => !opts.only?.length || opts.only.includes(s.name));
42
+ if (opts.only?.length) {
43
+ const unknown = opts.only.filter((n) => !skills.some((s) => s.name === n));
44
+ if (unknown.length)
45
+ throw new Error(`unknown skill: ${unknown.join(", ")} (see toon skills list)`);
46
+ }
47
+ mkdirSync(dest, { recursive: true });
48
+ return skills.map((s) => {
49
+ const to = join(dest, s.name);
50
+ rmSync(to, { recursive: true, force: true });
51
+ // Rendered example output and dependencies are not part of a skill.
52
+ cpSync(s.dir, to, { recursive: true, filter: (src) => !/[\\/](out|node_modules)$/.test(src) });
53
+ return to;
54
+ });
55
+ }
56
+ //# sourceMappingURL=skills.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skills.js","sourceRoot":"","sources":["../src/skills.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrG,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAS1C;;;GAGG;AACH,MA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IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;QAC3E,IAAI,OAAO,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IACrG,CAAC;IACD,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACrC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACtB,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAC9B,MAAM,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7C,oEAAoE;QACpE,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC/F,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "@anime-studio/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.1",
4
+ "description": "The toon CLI for animeStudio: validate, describe, render, debug and lip sync character and scene documents.",
5
+ "keywords": [
6
+ "animation",
7
+ "cartoon",
8
+ "2d-animation",
9
+ "svg",
10
+ "character-animation",
11
+ "animestudio",
12
+ "cli"
13
+ ],
14
+ "license": "MIT",
15
+ "author": "Dener Fernandes (https://github.com/denerFernandes)",
16
+ "homepage": "https://github.com/denerFernandes/animeStudio/tree/master/packages/cli#readme",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/denerFernandes/animeStudio.git",
20
+ "directory": "packages/cli"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/denerFernandes/animeStudio/issues"
24
+ },
25
+ "type": "module",
26
+ "main": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js"
32
+ }
33
+ },
34
+ "bin": {
35
+ "toon": "./dist/bin.js"
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "skills",
40
+ "README.md",
41
+ "LICENSE"
42
+ ],
43
+ "engines": {
44
+ "node": ">=22"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public"
48
+ },
49
+ "dependencies": {
50
+ "@anime-studio/core": "0.2.1",
51
+ "@anime-studio/rigid": "0.2.1",
52
+ "@anime-studio/lipsync": "0.2.1",
53
+ "@anime-studio/import-svg": "0.2.1"
54
+ },
55
+ "devDependencies": {
56
+ "tsx": "^4.23.15"
57
+ }
6
58
  }
@@ -0,0 +1,165 @@
1
+ ---
2
+ name: animestudio
3
+ description: Start here to make cartoon animation with animeStudio (@anime-studio/* on npm). Covers installing the packages, the character → scene → frame → video pipeline, validating and debugging toon.json / scene.json / sequence.json documents with the `toon` CLI, and rendering a still, a whole MP4 without a browser, or a Remotion video. Use it whenever someone wants to render an animation video, write or fix a scene.json, or use animeStudio as a library; it points to the sibling skills for characters, sets, scripts and animation.
4
+ ---
5
+
6
+ # animeStudio: using the engine
7
+
8
+ animeStudio is a **deterministic 2D / 2.5D cartoon animation engine** written in TypeScript.
9
+ Everything is data and every frame is a pure function:
10
+
11
+ ```
12
+ pose = f(document, time) // same document + same time → the same SVG, byte for byte
13
+ ```
14
+
15
+ - A **character** (`*.toon.json`, `format: "toon"`) is a rig: SVG art on a skeleton with IK,
16
+ physics, controls (emotions, look-at, visemes, views) and clips (idle, walk, wave…).
17
+ - A **scene** (`*.scene.json`, `format: "toon-scene"`) places actors, props and background layers
18
+ and lists timed **script** actions (`play`, `walkTo`, `say`, `lookAt`, `camera`, `fx`…).
19
+ - A **sequence** (`*.sequence.json`, `format: "toon-sequence"`) strings scenes into shots with
20
+ transitions.
21
+ - Rendering = `evaluateScene(scene, t)` → `frameToSVG(frame)` → rasterize. Because frames are
22
+ pure, render them in any order and in parallel.
23
+
24
+ You are a **library user**: build documents and render them. Never patch the engine to get a
25
+ motion; if the engine cannot do something, say so (the engine owns behaviour).
26
+
27
+ ## Sibling skills (read the one that matches the task)
28
+
29
+ | Task | Skill |
30
+ |---|---|
31
+ | Building or editing characters (`cartoonCharacter`, looks, hand-made rigs, SVG import) | `animestudio-characters` |
32
+ | Sets / backgrounds, props, lighting, camera work | `animestudio-sets` |
33
+ | Turning a story or script into scenes: dialogue, lip sync, shots, the director (`@anime-studio/director`) | `animestudio-script` |
34
+ | Motion: clips, walks, runs, gestures, holding objects, falls, timing | `animestudio-animation` |
35
+
36
+ This skill covers what all of them share: install, pipeline, validation, rendering.
37
+
38
+ ## Install
39
+
40
+ Node.js 22+, ES modules. Install only what you need:
41
+
42
+ ```bash
43
+ npm install @anime-studio/core @anime-studio/kit # engine + ready-made TV-cartoon characters
44
+ npm install @anime-studio/rigid # rigid-body props (needed for prepareScene)
45
+ npm install -g @anime-studio/cli # the `toon` command (or: npx @anime-studio/cli …)
46
+ npm install @anime-studio/remotion remotion @remotion/media react # only for Remotion renders
47
+ ```
48
+
49
+ Run TypeScript with `npx tsx file.ts`. Inside the animeStudio repo itself, the workspace already
50
+ resolves `@anime-studio/*` to the sources and the CLI is `npx tsx packages/cli/src/bin.ts`.
51
+ Which package does what, and when to reach for each: [references/packages.md](references/packages.md).
52
+
53
+ ## The pipeline
54
+
55
+ 1. **Characters.** Prefer the kit: `cartoonCharacter(look)` turns a short look (build, skin, hair,
56
+ clothes) into a full 2.5D rig with 12 drawn angles, ~15 emotions and ~50 clips. Save it as a
57
+ `.toon.json` if a JSON scene or the CLI must load it. Details: `animestudio-characters`.
58
+ 2. **Describe before you write.** `toon describe hero.toon.json` lists the real control values,
59
+ clip names (with loop / stride) and channels. Never guess a clip or emotion name.
60
+ 3. **Scene.** Write the `*.scene.json` (or build the same object in TS): size, fps, duration,
61
+ `characters`, `layers`, `actors`, `props`, `script`. Essentials and the action catalogue:
62
+ [references/scene-format.md](references/scene-format.md).
63
+ 4. **Validate** with `toon validate` until it prints ✓, then `toon debug` (see below).
64
+ 5. **Look at frames** before rendering a video: one still at each key beat.
65
+ 6. **Render** the video: browserless (frames → ffmpeg) or Remotion.
66
+
67
+ Runnable versions of every step are in [examples/](examples/) (run from anywhere with
68
+ `npx tsx <path>`; outputs go to `examples/out/`):
69
+
70
+ | File | What it shows |
71
+ |---|---|
72
+ | [examples/first-frame.ts](examples/first-frame.ts) | Two kit characters, `hello.scene.json` loaded, validated, one frame → SVG → PNG |
73
+ | [examples/hello.scene.json](examples/hello.scene.json) | A small valid scene: idle loops, `walkTo`, `lookAt`, `wave`, `say` with text, emotions, `fx`, a camera move |
74
+ | [examples/render-video.ts](examples/render-video.ts) | Whole MP4 from a scene **or** sequence: pooled frames, rsvg-convert, ffmpeg, audio mix; `--frames N` for a quick check |
75
+ | [examples/hello.sequence.json](examples/hello.sequence.json) | Three shots of the scene with a crossfade and an iris |
76
+ | [examples/remotion/](examples/remotion/) | `Root.tsx` + `index.ts`: the same scene as a Remotion `<Composition>` |
77
+
78
+ Run `first-frame.ts` first: it writes `out/maya.toon.json` and `out/kai.toon.json`, the files the
79
+ JSON examples reference.
80
+
81
+ ## A first frame in code
82
+
83
+ ```ts
84
+ import { evaluateScene, frameToSVG, validateScene } from "@anime-studio/core";
85
+ import { cartoonCharacter } from "@anime-studio/kit";
86
+ import { prepareScene } from "@anime-studio/rigid";
87
+
88
+ const maya = cartoonCharacter({ name: "Maya", build: "woman", female: true, skin: "#a8704f",
89
+ hair: "puffs", hairColor: "#2a1b14", top: "jacket", topColor: "#ff6b5b",
90
+ bottom: "pants", bottomColor: "#2f3a5c", shoes: "sneakers" });
91
+ const doc = { format: "toon-scene", version: 1, width: 1280, height: 720, fps: 30, duration: 3,
92
+ characters: { maya: "maya.toon.json" }, // path only read by loaders; ignored when assets are given
93
+ actors: [{ id: "maya", character: "maya", x: 640, y: 660, scale: 0.8 }],
94
+ script: [
95
+ { at: 0, actor: "maya", action: "play", clip: "idle", loop: true, layer: -1 },
96
+ { at: 0.5, actor: "maya", action: "play", clip: "wave", duration: 2 },
97
+ ] } as const;
98
+ const assets = { characters: { maya } };
99
+ const v = validateScene(doc, assets); // with assets: the script is compiled and checked
100
+ if (!v.ok) throw new Error(v.issues.map((i) => `${i.path}: ${i.message}`).join("\n"));
101
+ const scene = await prepareScene(doc as any, assets); // compileScene + rigid-body bake
102
+ const svg = frameToSVG(evaluateScene(scene, 1.2)); // standalone SVG string
103
+ // then: rsvg-convert -w 1280 frame.svg -o frame.png
104
+ ```
105
+
106
+ ## Validate and debug (do this every time)
107
+
108
+ ```bash
109
+ toon validate my.scene.json # schema → assets → full compile; every error has a JSON path
110
+ toon describe hero.toon.json # the character's real controls, clips, anchors, channels
111
+ toon render my.scene.json --time 2.5 -o f.svg # one frame (rigid bodies simulated) → rsvg-convert
112
+ toon debug my.scene.json [--from s --to s] # frame-by-frame library checks: NaN, broken refs, pops, jumps
113
+ toon doctor video.mp4 my.scene.json # after a render: flickers / unpainted nodes (Remotion debug strip)
114
+ ```
115
+
116
+ Fix every reported path; messages name the bad id and list the valid ones. The errors you will
117
+ meet, and what validation does **not** catch:
118
+ [references/validation-and-debugging.md](references/validation-and-debugging.md).
119
+
120
+ ## Render
121
+
122
+ - **Still:** `frameToSVG(evaluateScene(scene, t))` → `rsvg-convert -w <width> in.svg -o out.png`.
123
+ Then actually look at the PNG.
124
+ - **MP4 without a browser** (fast, no Chrome, the repo's own promo videos use it): evaluate each
125
+ frame, write SVG, `rsvg-convert` to PNG in a pool of ~8 jobs, `ffmpeg -c:v libx264 -crf 14
126
+ -pix_fmt yuv420p`, mix `scene.audio` events with `adelay`. See
127
+ [examples/render-video.ts](examples/render-video.ts).
128
+ - **Remotion:** `<Composition component={ToonComposition} {...toonMetadata(scene)}
129
+ defaultProps={{ scene, assets }} />`; sequences use `ToonSequenceComposition`.
130
+
131
+ Pipelines, quality settings, sequences, Remotion setup and their pitfalls:
132
+ [references/rendering.md](references/rendering.md).
133
+
134
+ ## Golden rules
135
+
136
+ 1. **Never invent names.** Clips, emotions, views, fx types, actions and fields come from
137
+ `toon describe`, `toon validate` messages or the docs. The format rejects unknown fields
138
+ (`Unrecognized key`), but an unknown **pose value** (`emotion: "glad"`) passes validation and
139
+ silently does nothing — check pose values against `toon describe`.
140
+ 2. **Validate with assets.** `validateScene(doc)` without assets only checks the schema; pass
141
+ `{ characters, lipsync }` (or use `toon validate`, which loads them) to compile the script.
142
+ 3. **Render with `prepareScene`** (`@anime-studio/rigid`), not bare `compileScene`, whenever props
143
+ have a `body`; otherwise rigid bodies never move. It is harmless without bodies.
144
+ 4. **Every actor gets a looping base clip**: `{ "action": "play", "clip": "idle", "loop": true,
145
+ "layer": -1 }` at `at: 0`, or it freezes between actions.
146
+ 5. **Prefer high-level actions over raw tracks**: `walkTo` (stride-matched, no sliding), `say`,
147
+ `pose`, `lookAt`, `fall`/`getUp`, `camera` with `follow`/`frame`. Never fake a walk with `x`
148
+ tracks or a fall with `rotation`.
149
+ 6. **Tracks hold their first key before it.** Give every channel you change later an explicit
150
+ value at `t = 0`.
151
+ 7. **One `walkTo` at a time per actor.** A second one takes over the first from where the actor
152
+ is (no error is raised), which is rarely what you meant.
153
+ 8. **Coordinates**: px, y down, degrees clockwise, seconds. Actor `x, y` is the point between the
154
+ feet on the ground; a character faces right unless `flip: true`.
155
+ 9. **Look before you ship.** Render stills at the key beats and open them; then render the video.
156
+ A short `--frames` run proves the whole pipeline before a long encode.
157
+ 10. **Rasterize with PNG frames and CRF ≈ 14**; JPEG rings round cartoon lines.
158
+
159
+ ## Documentation (exhaustive references)
160
+
161
+ - Format: https://github.com/denerFernandes/animeStudio/blob/master/docs/FORMAT.md
162
+ - API: https://github.com/denerFernandes/animeStudio/blob/master/docs/API.md
163
+ - AI authoring guide: https://github.com/denerFernandes/animeStudio/blob/master/docs/AI_GUIDE.md
164
+ - Director: https://github.com/denerFernandes/animeStudio/blob/master/docs/DIRECTOR.md
165
+ - JSON Schemas: `toon schema --out schemas` (point `"$schema"` at them for editor completion)
@@ -0,0 +1,54 @@
1
+ /**
2
+ * First frame: build two kit characters, load a scene document, validate it, render one frame to
3
+ * SVG and PNG.
4
+ *
5
+ * npx tsx first-frame.ts [time=2.6]
6
+ *
7
+ * Writes out/maya.toon.json and out/kai.toon.json (the files hello.scene.json references, so
8
+ * `toon validate hello.scene.json` works afterwards), out/frame.svg and out/frame.png
9
+ * (needs `rsvg-convert` on PATH: `brew install librsvg` / `apt install librsvg2-bin`).
10
+ */
11
+ import { execFileSync } from "node:child_process";
12
+ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
13
+ import { join } from "node:path";
14
+ import { type SceneDoc, evaluateScene, frameToSVG, validateScene } from "@anime-studio/core";
15
+ import { type CartoonLook, cartoonCharacter } from "@anime-studio/kit";
16
+ import { prepareScene } from "@anime-studio/rigid";
17
+
18
+ const dir = import.meta.dirname;
19
+ const out = join(dir, "out");
20
+ mkdirSync(out, { recursive: true });
21
+
22
+ // 1. Characters: a kit character is a whole rig (12 drawn angles, emotions, ~50 clips) from a look.
23
+ const looks: Record<string, CartoonLook> = {
24
+ maya: {
25
+ name: "Maya", build: "woman", female: true, skin: "#a8704f", hair: "puffs", hairColor: "#2a1b14",
26
+ top: "jacket", topColor: "#ff6b5b", bottom: "pants", bottomColor: "#2f3a5c", shoes: "sneakers", shoeColor: "#f4f1ea",
27
+ },
28
+ kai: {
29
+ name: "Kai", build: "teen", skin: "#f2c9a6", hair: "spiky", hairColor: "#2b3a8c", top: "tee", topColor: "#ffc93c",
30
+ bottom: "shorts", bottomColor: "#2ec4b6", shoes: "sneakers", shoeColor: "#e2584a", socks: "#ffffff",
31
+ },
32
+ };
33
+ const characters = Object.fromEntries(Object.entries(looks).map(([id, look]) => [id, cartoonCharacter(look)]));
34
+ // Save them as documents so the scene's `characters` paths resolve for the CLI.
35
+ for (const [id, doc] of Object.entries(characters)) writeFileSync(join(out, `${id}.toon.json`), JSON.stringify(doc));
36
+
37
+ // 2. Scene: plain JSON. When assets are passed in code, the paths in `characters` are not read.
38
+ const doc = JSON.parse(readFileSync(join(dir, "hello.scene.json"), "utf8")) as SceneDoc;
39
+
40
+ // 3. Validate with the assets: compiles the script too, so unknown clips/emotions are reported.
41
+ const check = validateScene(doc, { characters });
42
+ for (const i of check.issues) console.log(`${i.severity} ${i.path}: ${i.message}`);
43
+ if (!check.ok) process.exit(1);
44
+
45
+ // 4. Compile (+ rigid-body bake; harmless without bodies) and evaluate one frame: pure, any order.
46
+ const scene = await prepareScene(doc, { characters });
47
+ const t = Number(process.argv[2] ?? 2.6);
48
+ const svg = join(out, "frame.svg");
49
+ writeFileSync(svg, frameToSVG(evaluateScene(scene, t)));
50
+
51
+ // 5. Rasterize. rsvg-convert renders the engine's SVG faithfully and needs no browser.
52
+ const png = join(out, "frame.png");
53
+ execFileSync("rsvg-convert", ["-w", String(doc.width), "-o", png, svg]);
54
+ console.log(`t=${t}s → ${png}`);
@@ -0,0 +1,50 @@
1
+ {
2
+ "format": "toon-scene",
3
+ "version": 1,
4
+ "width": 1280,
5
+ "height": 720,
6
+ "fps": 30,
7
+ "duration": 4,
8
+ "background": "#cfeaf5",
9
+ "characters": {
10
+ "maya": "out/maya.toon.json",
11
+ "kai": "out/kai.toon.json"
12
+ },
13
+ "camera": { "x": 640, "y": 360, "zoom": 1 },
14
+ "layers": [
15
+ {
16
+ "id": "sky",
17
+ "parallax": 0,
18
+ "z": -100,
19
+ "art": "<defs><linearGradient id='sky' x1='0' y1='0' x2='0' y2='1'><stop offset='0' stop-color='#8fd3f4'/><stop offset='1' stop-color='#e6f6fb'/></linearGradient></defs><rect x='-200' y='-200' width='1680' height='1120' fill='url(#sky)'/>"
20
+ },
21
+ {
22
+ "id": "hills",
23
+ "parallax": 0.5,
24
+ "z": -80,
25
+ "art": "<path d='M-300 600 Q 200 430 640 560 T 1600 540 L 1600 900 L -300 900 Z' fill='#9ad27c'/>"
26
+ },
27
+ {
28
+ "id": "ground",
29
+ "z": -60,
30
+ "art": "<rect x='-400' y='660' width='2080' height='400' fill='#6db84f'/><path d='M-400 660 H1680' stroke='#4f9a3a' stroke-width='6'/>"
31
+ }
32
+ ],
33
+ "actors": [
34
+ { "id": "maya", "character": "maya", "x": 260, "y": 660, "scale": 0.8 },
35
+ { "id": "kai", "character": "kai", "x": 980, "y": 660, "scale": 0.8, "flip": true }
36
+ ],
37
+ "script": [
38
+ { "at": 0, "actor": "maya", "action": "play", "clip": "idle", "loop": true, "layer": -1, "fadeIn": 0 },
39
+ { "at": 0, "actor": "kai", "action": "play", "clip": "idle", "loop": true, "layer": -1, "fadeIn": 0 },
40
+ { "at": 0, "actor": "kai", "action": "lookAt", "target": "maya" },
41
+ { "at": 0.2, "actor": "maya", "action": "walkTo", "x": 560, "duration": 1.6 },
42
+ { "at": 1.0, "actor": "maya", "action": "lookAt", "target": "kai" },
43
+ { "at": 1.7, "actor": "maya", "action": "play", "clip": "wave", "duration": 1.8, "fadeIn": 0.25, "fadeOut": 0.35 },
44
+ { "at": 1.8, "actor": "maya", "action": "pose", "control": "emotion", "value": "happy", "duration": 0.3 },
45
+ { "at": 1.8, "actor": "maya", "action": "say", "text": "Hi Kai! Ready to animate?", "duration": 1.6 },
46
+ { "at": 2.35, "action": "fx", "type": "surprise", "actor": "kai" },
47
+ { "at": 2.4, "actor": "kai", "action": "pose", "control": "emotion", "value": "joy", "duration": 0.3 },
48
+ { "at": 2.0, "action": "camera", "zoom": 1.12, "y": 380, "duration": 1.8 }
49
+ ]
50
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "format": "toon-sequence",
3
+ "version": 1,
4
+ "width": 1280,
5
+ "height": 720,
6
+ "fps": 30,
7
+ "scenes": { "hello": "hello.scene.json" },
8
+ "shots": [
9
+ { "scene": "hello", "duration": 1.8 },
10
+ { "scene": "hello", "from": 1.8, "transition": { "type": "crossfade", "duration": 0.4 } },
11
+ { "scene": "hello", "from": 0, "duration": 1.2, "transition": { "type": "iris", "target": "maya", "duration": 0.8 } }
12
+ ]
13
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * A Remotion root rendering hello.scene.json with <ToonComposition>.
3
+ * Install: npm i @anime-studio/core @anime-studio/remotion remotion @remotion/cli @remotion/media react react-dom
4
+ * The character files are the ones first-frame.ts writes to out/.
5
+ */
6
+ import type { SceneDoc, ToonDoc } from "@anime-studio/core";
7
+ import { ToonComposition, toonMetadata } from "@anime-studio/remotion";
8
+ import { Composition } from "remotion";
9
+ import kai from "../out/kai.toon.json";
10
+ import maya from "../out/maya.toon.json";
11
+ import hello from "../hello.scene.json";
12
+
13
+ const scene = hello as unknown as SceneDoc;
14
+ // Assets are passed parsed: the paths in the scene's `characters` map are not read here.
15
+ // Audio paths in the scene resolve with staticFile() (files in public/) unless you pass resolveAudio.
16
+ const assets = { characters: { maya: maya as unknown as ToonDoc, kai: kai as unknown as ToonDoc }, lipsync: {} };
17
+
18
+ export const RemotionRoot = () => (
19
+ <Composition
20
+ id="Hello"
21
+ component={ToonComposition}
22
+ {...toonMetadata(scene)}
23
+ defaultProps={{ scene, assets }}
24
+ />
25
+ );
@@ -0,0 +1,5 @@
1
+ // Remotion entry point: `npx remotion studio remotion/index.ts`, `npx remotion render remotion/index.ts Hello out/hello.mp4`.
2
+ import { registerRoot } from "remotion";
3
+ import { RemotionRoot } from "./Root";
4
+
5
+ registerRoot(RemotionRoot);