beatsheet 0.1.0 → 0.2.0

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.
package/README.md CHANGED
@@ -7,13 +7,30 @@ sound together.
7
7
 
8
8
  ## Start
9
9
 
10
+ In an empty folder (no install, no config):
11
+
10
12
  ```bash
11
- mkdir my-videos && cd my-videos && npm init -y
12
- npm install -D beatsheet @beatsheet/core @beatsheet/scenes
13
- npx playwright install chromium-headless-shell # once per machine, for check, stills and render
13
+ npx beatsheet skill install
14
+ npx beatsheet studio
15
+ # tell your agent: "I've got an idea for a new beatsheet video - here it is: …"
14
16
  ```
15
17
 
16
- `beatsheet.config.ts` in that folder:
18
+ `skill install` copies the agent skill for Claude Code to `~/.claude/skills/beatsheet` (`--dir` for another folder;
19
+ `--force` refreshes it after an update). `studio` serves the editor at http://localhost:4321 (`--open` opens it in
20
+ your browser) and, in an empty folder, shows what to tell the agent; the agent's first video appears there once it is
21
+ saved. *Open the library tour* copies a finished video (a tour of the built-in scene types) and its images into the
22
+ folder. The agent researches the change, plans the story, writes the video file, checks stills and renders both
23
+ formats; you fine-tune it in the studio.
24
+
25
+ ```bash
26
+ npx beatsheet check videos/<name>.video.json # validation, layout and read-time warnings
27
+ npx beatsheet render videos/<name>.video.json --format 16:9,4:5
28
+ npx beatsheet paths # where beatsheet's sources, skill and examples are
29
+ npx beatsheet --help # every command and flag
30
+ ```
31
+
32
+ A folder without `beatsheet.config.ts` uses the neutral default theme and the built-in scene types. Add a config
33
+ only for a brand theme or a scene type of your own, then restart the studio:
17
34
 
18
35
  ```ts
19
36
  import { defineProject } from '@beatsheet/core';
@@ -22,37 +39,26 @@ import { builtinScenes, defaultTheme } from '@beatsheet/scenes';
22
39
  export default defineProject({ name: 'my-videos', theme: defaultTheme, scenes: builtinScenes });
23
40
  ```
24
41
 
25
- A first video to open and change: the library tour that comes with beatsheet (a tour of the built-in scene types,
26
- with its images):
42
+ Its imports resolve to beatsheet's own copies of `@beatsheet/core` and `@beatsheet/scenes`. The folder's `.ts`
43
+ files load as ES modules when its `package.json` declares no `"type"`, so `require`, `__dirname` and
44
+ `module.exports` don't work in a config.
27
45
 
28
- ```bash
29
- mkdir -p videos assets
30
- cp node_modules/beatsheet/skill/examples/library/library-tour.video.json videos/
31
- cp -R node_modules/beatsheet/skill/examples/library/assets/tour assets/
32
- npx beatsheet check videos/library-tour.video.json
33
- ```
34
-
35
- ```bash
36
- npx beatsheet studio --open # editor + gallery of every scene type at http://localhost:4321
37
- npx beatsheet check videos/library-tour.video.json # validation, layout and read-time warnings
38
- npx beatsheet render videos/library-tour.video.json --format 16:9,4:5
39
- npx beatsheet --help # every command and flag
40
- ```
46
+ ## Pin versions or add your own npm packages
41
47
 
42
- ## With Claude Code
48
+ A scene type that needs npm packages of its own (gsap, three.js), or a project that pins beatsheet's version,
49
+ installs beatsheet into the folder; that install then wins over npx's:
43
50
 
44
51
  ```bash
45
- npx beatsheet skill install # copies the skill to ~/.claude/skills/beatsheet (--dir for another folder)
52
+ npm init -y
53
+ npm install -D beatsheet @beatsheet/core @beatsheet/scenes
46
54
  ```
47
55
 
48
- Then ask for a launch, release or feature video in the project folder, or type `/beatsheet`. The agent researches
49
- the change, plans the story, writes the video file, checks stills and renders both formats; you fine-tune it in the
50
- studio. Run `npx beatsheet skill install --force` after updating beatsheet.
51
-
52
56
  ## Notes
53
57
 
54
58
  - Node 20.19+ or 22.12+. ffmpeg comes with `ffmpeg-static`; npm 11 may ask you to approve the install scripts of
55
59
  `ffmpeg-static` (it downloads ffmpeg) and `esbuild` (it runs TypeScript): `npm approve-scripts ffmpeg-static esbuild`.
60
+ - Chromium downloads itself on the first `check`, `stills` or `render` (about 100 MB, once per machine).
61
+ `BEATSHEET_CHROMIUM` points at a Chromium of your own; `BEATSHEET_NO_DOWNLOAD=1` turns the download off.
56
62
  - Voice-over (`beatsheet speak`) needs `@beatsheet/voice-kokoro`, which is not on npm yet.
57
63
  - MIT licensed. The studio bundles Angular and rxjs; their licences are in `studio/3rdpartylicenses.txt`. The
58
64
  `ffmpeg-static` binary it runs is a GPL build of ffmpeg, used as a separate program.
package/bin/beatsheet.js CHANGED
@@ -3,6 +3,8 @@
3
3
  import { register } from 'tsx/esm/api';
4
4
 
5
5
  register();
6
+ // After tsx: a project without its own install imports @beatsheet/* from the CLI's copies.
7
+ await import('./register-fallback.mjs');
6
8
  const { main } = await import('../src/cli.ts');
7
9
  const code = await main(process.argv.slice(2));
8
10
  // Exit when the event loop is empty rather than with process.exit(): onnxruntime-node (loaded by a
@@ -0,0 +1,23 @@
1
+ // A project's @beatsheet/core and @beatsheet/scenes imports fall back to the CLI's copies when the
2
+ // project has none (npx beatsheet in a fresh folder). Imported by bin/beatsheet.js after tsx's
3
+ // register(), and passed with --import after tsx to the skill scripts' child processes.
4
+ import Module, { createRequire, register } from 'node:module';
5
+ import { BEATSHEET_PACKAGE } from './resolve-fallback.mjs';
6
+
7
+ const parentURL = new URL('../package.json', import.meta.url).href;
8
+
9
+ // import: registered after tsx, so these hooks see tsx's resolution fail first.
10
+ register(new URL('./resolve-fallback.mjs', import.meta.url), { data: { parentURL } });
11
+
12
+ // require: tsx loads a .ts file outside a "type": "module" package (an empty folder's
13
+ // beatsheet.config.ts) as CommonJS, and its require() calls bypass the import hooks.
14
+ const cliRequire = createRequire(parentURL);
15
+ const resolveFilename = Module._resolveFilename;
16
+ Module._resolveFilename = function (request, ...rest) {
17
+ try {
18
+ return resolveFilename.call(this, request, ...rest);
19
+ } catch (err) {
20
+ if (!BEATSHEET_PACKAGE.test(request) || err?.code !== 'MODULE_NOT_FOUND') throw err;
21
+ return cliRequire.resolve(request);
22
+ }
23
+ };
@@ -0,0 +1,83 @@
1
+ // Node module-customization hooks (registered by bin/register-fallback.mjs): a project without its
2
+ // own install (npx beatsheet in a fresh folder) imports @beatsheet/core and @beatsheet/scenes from
3
+ // the CLI's copies. A project's own install still wins: the fallback runs only when that fails.
4
+ // A project's TypeScript files load as ES modules where its package.json declares no "type" (an
5
+ // empty folder has none), so they share the CLI's @beatsheet/core instead of a CommonJS copy.
6
+ // Plain .mjs because hooks run on a loader thread that tsx's registration may not cover.
7
+
8
+ import fs from 'node:fs';
9
+ import path from 'node:path';
10
+ import { fileURLToPath, pathToFileURL } from 'node:url';
11
+
12
+ // The same pattern as BEATSHEET_PACKAGE in src/packages.ts (bin/ cannot import TypeScript).
13
+ export const BEATSHEET_PACKAGE = /^@beatsheet\/(core|scenes)(\/|$)/;
14
+
15
+ /** The CLI's package.json URL: the fallback resolves from there. */
16
+ let parentURL;
17
+
18
+ export function initialize(data) {
19
+ parentURL = data?.parentURL;
20
+ }
21
+
22
+ export async function resolve(specifier, context, next) {
23
+ let resolved;
24
+ try {
25
+ resolved = await next(specifier, context);
26
+ } catch (err) {
27
+ if (!parentURL || !BEATSHEET_PACKAGE.test(specifier) || err?.code !== 'ERR_MODULE_NOT_FOUND') throw err;
28
+ return next(specifier, { ...context, parentURL });
29
+ }
30
+ return forcedModule(resolved.url) ? { ...resolved, url: withoutCommonJsQuery(resolved.url), format: 'module' } : resolved;
31
+ }
32
+
33
+ /**
34
+ * tsx (Node 20, 22) marks a file it took for CommonJS with query parameters of its own
35
+ * (tsx-commonjs-export-preparse, tsx-commonjs-virtual-query), the latter repeating the query
36
+ * inside the path. A forced module drops them and keeps any other query (a config's ?v=).
37
+ */
38
+ function withoutCommonJsQuery(url) {
39
+ const u = new URL(url);
40
+ const clean = pathToFileURL(filePath(u));
41
+ for (const [key, value] of u.searchParams) if (!key.startsWith('tsx-commonjs-')) clean.searchParams.append(key, value);
42
+ clean.hash = u.hash;
43
+ return clean.href;
44
+ }
45
+
46
+ /** The file of a file: URL, without tsx's query in its path. */
47
+ function filePath(u) {
48
+ const bare = new URL(u.href);
49
+ bare.search = '';
50
+ bare.hash = '';
51
+ return fileURLToPath(bare).split('?')[0];
52
+ }
53
+
54
+ const TS_FILE = /\.(ts|mts|tsx)$/;
55
+
56
+ /** The "type" of the package.json nearest to each folder (undefined: none, or none declared). */
57
+ const scopeTypes = new Map();
58
+
59
+ function scopeType(dir) {
60
+ if (scopeTypes.has(dir)) return scopeTypes.get(dir);
61
+ let type;
62
+ const file = path.join(dir, 'package.json');
63
+ if (fs.existsSync(file)) {
64
+ try {
65
+ type = JSON.parse(fs.readFileSync(file, 'utf8')).type;
66
+ } catch {
67
+ type = undefined;
68
+ }
69
+ } else {
70
+ const parent = path.dirname(dir);
71
+ type = parent === dir ? undefined : scopeType(parent);
72
+ }
73
+ scopeTypes.set(dir, type);
74
+ return type;
75
+ }
76
+
77
+ /** A project TypeScript file (not in node_modules) whose package scope declares no "type". */
78
+ function forcedModule(url) {
79
+ if (!url.startsWith('file:')) return false;
80
+ const file = filePath(new URL(url));
81
+ if (!TS_FILE.test(file) || file.split(path.sep).includes('node_modules')) return false;
82
+ return scopeType(path.dirname(file)) === undefined;
83
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "beatsheet",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Short launch and feature videos as structured data: a JSON file per video, a local editor, frame-exact MP4 renders",
5
5
  "license": "MIT",
6
6
  "author": "Dominik Strasser",
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "type": "module",
15
15
  "bin": {
16
- "beatsheet": "./bin/beatsheet.js"
16
+ "beatsheet": "bin/beatsheet.js"
17
17
  },
18
18
  "exports": {
19
19
  ".": "./src/index.ts"
@@ -25,7 +25,8 @@
25
25
  "postpack": "node scripts/postpack.mjs"
26
26
  },
27
27
  "dependencies": {
28
- "@beatsheet/core": "0.1.0",
28
+ "@beatsheet/core": "0.2.0",
29
+ "@beatsheet/scenes": "0.2.0",
29
30
  "ffmpeg-static": "^5.3.0",
30
31
  "playwright": "1.63.0",
31
32
  "tsx": "^4.20.0",
package/skill/SKILL.md CHANGED
@@ -12,17 +12,27 @@ without you. Its direction (goal, tone, message, voice) is the user's: ask it be
12
12
 
13
13
  ## Where things are
14
14
 
15
- A project is any folder with `beatsheet.config.ts` (theme + scene types); run every command from there. beatsheet
16
- comes in one of two setups; tell which from the project folder before anything else:
17
-
18
- - **npm** (the usual one): the project's `package.json` has `beatsheet`, `@beatsheet/core` and `@beatsheet/scenes`,
19
- their sources in `node_modules`: `<core>` is `node_modules/@beatsheet/core/src`, `<scenes>` is
20
- `node_modules/@beatsheet/scenes/src`. No project yet: section 4, New project.
21
- - **A beatsheet checkout** (the repo, for work on beatsheet itself; it has `packages/` and `skills/beatsheet`):
22
- `<core>` is `packages/core/src`, `<scenes>` is `packages/scenes/src`. Projects are `projects/<name>/`, each its
23
- own git repo cloned there (`projects/` is git-ignored; a project needs no install, it uses the checkout's root
24
- `node_modules`); `examples/` holds beatsheet's own projects, `library` and `beatsheet-promo`. Read the
25
- checkout's `README.md` once.
15
+ A project is the folder the user runs beatsheet in: its `videos/*.video.json`, their images in `assets/`, and
16
+ `beatsheet.config.ts` (theme + scene types) when it has one. Without a config it uses the default theme and the
17
+ built-in scenes; run every command from that folder. Every command is `npx -y beatsheet …`: nothing to install,
18
+ and a project that has beatsheet in its own `node_modules` runs that copy instead. Before anything else, run once:
19
+
20
+ ```bash
21
+ npx -y beatsheet paths
22
+ ```
23
+
24
+ If `paths` is an unknown command, the project's own beatsheet is older than this skill: suggest
25
+ `npm install -D beatsheet@latest @beatsheet/core@latest @beatsheet/scenes@latest`, then run `paths` again.
26
+
27
+ It prints the version, then `core` (that path is `<core>` below), `scenes` (`<scenes>`), `skill` and `examples` (the
28
+ library tour: `library-tour.video.json`, its `*.plan.md` and its images in `assets/`; in a checkout
29
+ `examples/library/videos`, the images in `examples/library/assets`). No project yet: section 4, New project.
30
+
31
+ **A beatsheet checkout** (the repo, for work on beatsheet itself; it has `packages/` and `skills/beatsheet`):
32
+ `paths` prints `packages/core/src` and `packages/scenes/src`. Projects are `projects/<name>/`, each its own git
33
+ repo cloned there (`projects/` is git-ignored; a project needs no install, it uses the checkout's root
34
+ `node_modules`); `examples/` holds beatsheet's own projects, `library` and `beatsheet-promo`. Read the checkout's
35
+ `README.md` once.
26
36
 
27
37
  | What | Where |
28
38
  |---|---|
@@ -30,14 +40,14 @@ comes in one of two setups; tell which from the project folder before anything e
30
40
  | Scene props | `<scenes>/<category>/<type>.ts`: the zod schema at the top is the prop reference; its `samples` are ready-made props |
31
41
  | Authoring kit | `@beatsheet/scenes/kit` (`<scenes>/kit.ts`): what a scene type of your own imports besides `@beatsheet/core` |
32
42
  | Scene techniques | `reference/scene-techniques.md` next to this file: SVG, masks, CSS 3D, canvas, shaders, three.js, GSAP, each seeked, with costs |
33
- | Catalogue | `npx beatsheet catalogue [--props]` from a project: every scene type by category with props, beat ids and samples, the theme's sounds and music (each track's tempo and beat length), generated from the code |
34
- | Gallery | `npx beatsheet studio`, top bar → Gallery (or `/player/?mode=gallery`): every sample of every type playing, in any format; sound board; music browser |
43
+ | Catalogue | `npx -y beatsheet catalogue [--props]` from a project: every scene type by category with props, beat ids and samples, the theme's sounds and music (each track's tempo and beat length), generated from the code |
44
+ | Gallery | `npx -y beatsheet studio`, top bar → Gallery (or `/player/?mode=gallery`): every sample of every type playing, in any format; sound board; music browser |
35
45
  | Contract | `<core>/types.ts` (`VideoDoc`, `SceneType`, `Theme`) |
36
- | Finished examples | the project's own `videos/*.video.json`; `examples/library/` next to this file (the library tour: built-in types only; its images in `assets/` there); in a checkout `examples/*/videos/` instead (`beatsheet-promo`: some scenes use that project's own `timeline-hero` type) and `projects/*/videos/`; each with its `*.plan.md` |
37
- | Beat times | `npx beatsheet beats videos/<name>.video.json`: every scene's beats with gap, time in the scene and in the video, and the time left after the last beat |
46
+ | Finished examples | the project's own `videos/*.video.json`; the `examples` folder `paths` prints (the library tour: built-in types only; its images in `assets/` there); in a checkout `examples/*/videos/` instead (`beatsheet-promo`: some scenes use that project's own `timeline-hero` type) and `projects/*/videos/`; each with its `*.plan.md` |
47
+ | Beat times | `npx -y beatsheet beats videos/<name>.video.json`: every scene's beats with gap, time in the scene and in the video, and the time left after the last beat |
38
48
 
39
- CLI: `npx beatsheet <check|stills|render|studio> …` from the project folder; `npx beatsheet --help` for flags.
40
- To see what a scene type looks like before using it: `npx beatsheet stills --samples --type <id> --format 16:9,4:5 --sheet`
49
+ CLI: `npx -y beatsheet <check|stills|render|studio> …` from the project folder; `npx -y beatsheet --help` for flags.
50
+ To see what a scene type looks like before using it: `npx -y beatsheet stills --samples --type <id> --format 16:9,4:5 --sheet`
41
51
  and Read the sheets (`out/stills/samples-<id>-*-sheet*.png`).
42
52
 
43
53
  ## 1. Inspect
@@ -166,9 +176,14 @@ from the theme; never write audio code for one video.
166
176
  end on a type from `rules.outro`. `check` reports each broken rule as an error at its field.
167
177
  `rules.ignoreWarnings` lists warning ids the project has switched off for all its videos (`check` counts them
168
178
  as silenced); leave the list as it is unless the user asks (section 7).
169
- - **New project (npm):** in the folder the user picks (`git init` only when it is not in a repo yet; a remote only
170
- when the user asks): `npm init -y`, `npm install -D beatsheet @beatsheet/core @beatsheet/scenes`, then
171
- `beatsheet.config.ts`:
179
+ - **New project:** in the folder the user picks (`git init` only when it is not in a repo yet; a remote only when
180
+ the user asks). It needs no install and no config: write `videos/<name>.video.json` (its images in `assets/`)
181
+ and a `.gitignore` with `out/`, `scratch/` and `node_modules/`. A studio already open on the empty folder shows
182
+ the first video as soon as it is saved. Chromium downloads itself on the first `check`, `stills` or `render`
183
+ (about 100 MB, once per machine); `BEATSHEET_CHROMIUM` points at a Chromium of your own, and
184
+ `BEATSHEET_NO_DOWNLOAD=1` turns the download off.
185
+ - **`beatsheet.config.ts`:** write one only for a brand theme (Theme, below) or a scene type of the project's own
186
+ (6. A scene type of your own):
172
187
 
173
188
  ```ts
174
189
  import { defineProject } from '@beatsheet/core';
@@ -177,14 +192,19 @@ from the theme; never write audio code for one video.
177
192
  export default defineProject({ name: '<name>', theme: defaultTheme, scenes: builtinScenes });
178
193
  ```
179
194
 
180
- and a `.gitignore` with `out/`, `scratch/` and `node_modules/`. Rendering needs Chromium once:
181
- `npx playwright install chromium-headless-shell` when `render` or `check` says it is missing. A project with
182
- tests or a scene type of its own also gets `"type": "module"`, `typescript` and `vitest` as dev dependencies,
183
- and a `tsconfig.json` with `"module": "ESNext"`, `"moduleResolution": "bundler"`, `"lib": ["ES2023", "DOM"]`,
184
- `"strict": true`, `"noEmit": true`. Theme and brand: below.
195
+ Then tell the user to restart the studio (`npx -y beatsheet studio`): a studio that started without a config
196
+ keeps the default theme and the built-in scenes until then. The imports resolve without an install (to
197
+ beatsheet's own copies). The project's `.ts` files load as ES modules when its `package.json` declares no
198
+ `"type"`: `import` and `export` only, no `require`, `__dirname` or `module.exports`.
199
+ - **npm install:** `npm init -y` and `npm install -D beatsheet @beatsheet/core @beatsheet/scenes` only for a scene
200
+ type that needs npm packages of its own (gsap, three.js: they go into the same `package.json`) or to pin
201
+ versions; the local install then wins over npx's. A project with tests also gets `"type": "module"`,
202
+ `typescript` and `vitest` as dev dependencies, and a `tsconfig.json` with `"module": "ESNext"`,
203
+ `"moduleResolution": "bundler"`, `"lib": ["ES2023", "DOM"]`, `"strict": true`, `"noEmit": true`.
185
204
  - **New project (checkout):** create `projects/<name>/` as a git repo of its own (`git init`; a remote only when the user
186
- asks). It needs one file, `beatsheet.config.ts`: copy `examples/beatsheet-promo/beatsheet.config.ts`, set `name`
187
- and remove the `timelineHero` import and entry (that scene type belongs to beatsheet-promo). No install and no
205
+ asks). For a brand theme or a scene type of its own it needs `beatsheet.config.ts`: copy
206
+ `examples/beatsheet-promo/beatsheet.config.ts`, set `name` and remove the `timelineHero` import and entry (that
207
+ scene type belongs to beatsheet-promo). No install and no
188
208
  workspace entry: `@beatsheet/core`, `@beatsheet/scenes` and the `beatsheet` CLI resolve from the checkout's root
189
209
  `node_modules`. Add a `.gitignore` with `out/`, `scratch/` and `node_modules/`. Only a project with tests or a
190
210
  scene type of its own also needs `package.json` and `tsconfig.json`: copy them from `examples/beatsheet-promo`,
@@ -282,7 +302,7 @@ scene's start; it borrows its time (d = `duration`) from the scenes around it:
282
302
  **Cuts on the beat: write rough durations, then `snap`.** The track keeps one tempo for the whole video, a beat
283
303
  grid from 0 s, and each scene's music switches in on the first beat at or after its cut (a cut off the beat lets the
284
304
  previous scene's music run on to the next beat, and `check` warns). Never add up beat times yourself. Write each
285
- scene `duration` roughly, in seconds (`4.7`), then run `npx beatsheet snap videos/<name>.video.json`: it rewrites
305
+ scene `duration` roughly, in seconds (`4.7`), then run `npx -y beatsheet snap videos/<name>.video.json`: it rewrites
286
306
  every duration to the nearest length that ends on the beat, prints each change (`hook 4.7 s → 4.655 s`) and
287
307
  leaves the rest of the file as it is. Run it again after every edit that changes a duration or the track; a second
288
308
  run changes nothing. It never cuts a scene below its last beat, its transitions or its spoken narration. It cannot
@@ -403,7 +423,8 @@ them in the studio; only the picture is code.
403
423
 
404
424
  **Where.** In the project: `scenes/<id>.ts`, registered in `beatsheet.config.ts`
405
425
  (`scenes: [...builtinScenes, myScene]`), importing `@beatsheet/core` and the authoring kit `@beatsheet/scenes/kit`
406
- (never copy library code). The project's own npm packages (GSAP, three.js) go into its `package.json`. The worked
426
+ (never copy library code; a config that is new needs a studio restart, section 4). A type that imports only those needs no install;
427
+ one with npm packages of its own (GSAP, three.js) gets the install in 4. Project and theme. The worked
407
428
  example, with its test (in a checkout): `examples/beatsheet-promo/scenes/timeline-hero.ts` (GSAP), used in
408
429
  `videos/beatsheet-craft.video.json`. When a type is generic and the user wants it in the library (a checkout only):
409
430
  `packages/scenes/src/<category>/<id>.ts`, registered in that category's `index.ts`. Start from a similar type
@@ -457,12 +478,12 @@ The contract:
457
478
  command output; the nearest ancestor's mark applies.
458
479
  - `destroy()` releases what the scene holds (a GSAP timeline, a WebGL context): all scenes are mounted at once.
459
480
 
460
- Dev loop, from the project: keep the gallery open (`npx beatsheet studio` → Gallery; it reloads on save and lists
481
+ Dev loop, from the project: keep the gallery open (`npx -y beatsheet studio` → Gallery; it reloads on save and lists
461
482
  project types like built-in ones), then
462
- `npx beatsheet check --samples --type <id>` (0 layout issues in all four formats),
463
- `npx beatsheet stills --samples --type <id> --format 16:9,4:5 --sheet` (Read the sheets; judge them as a designer:
483
+ `npx -y beatsheet check --samples --type <id>` (0 layout issues in all four formats),
484
+ `npx -y beatsheet stills --samples --type <id> --format 16:9,4:5 --sheet` (Read the sheets; judge them as a designer:
464
485
  is this the frame someone would screenshot?), and for anything beyond plain DOM
465
- `npx beatsheet frames videos/<name>.video.json --scene <id> --backwards` (two
486
+ `npx -y beatsheet frames videos/<name>.video.json --scene <id> --backwards` (two
466
487
  renders and a pass from the last frame to the first, compared frame by frame, with the ms per frame). `check --samples` does not measure read time: use the type in the video
467
488
  and run `check videos/<name>.video.json` too (about 3 words per second over all text that is not marked as
468
489
  texture). Tests: a project writes a `test/<id>.spec.ts` (vitest with `jsdom`; in a checkout copy
@@ -521,7 +542,7 @@ set it on every narrated video meant for a feed (muted autoplay). `"narration":
521
542
  is the written form when the spoken text is respelled ("sixteen by nine" spoken, "16:9" shown); `"captions": false`
522
543
  on a scene hides its caption (a scene whose own text says the same).
523
544
 
524
- Then `npx beatsheet speak videos/<name>.video.json` (first run loads the model for ~15 s; each line takes about a
545
+ Then `npx -y beatsheet speak videos/<name>.video.json` (first run loads the model for ~15 s; each line takes about a
525
546
  quarter of its length) and commit `videos/speech/` with the video. Needs `@beatsheet/voice-kokoro` installed in the
526
547
  project; it is not on npm yet and comes with a beatsheet checkout. If `speak` says it is missing, tell the user
527
548
  (it is GPL-3.0 licensed, see the README) instead of installing it yourself. Speech never changes durations: `check` tells you what does not fit.
@@ -530,10 +551,10 @@ project; it is not on npm yet and comes with a beatsheet checkout. If `speak` sa
530
551
 
531
552
  Loop until all three are clean:
532
553
 
533
- 1. `npx beatsheet check videos/<name>.video.json` ends with `ok: 0 errors, 0 warnings`. Layout issues name the
554
+ 1. `npx -y beatsheet check videos/<name>.video.json` ends with `ok: 0 errors, 0 warnings`. Layout issues name the
534
555
  scene, element, format and time. An off-beat end reads
535
556
  `scene "live" ends 0.2 s off the beat (upbeat-pulse, 120 bpm): 4.5 s lands on it`: run
536
- `npx beatsheet snap videos/<name>.video.json`, which puts every scene on the beat at once, and check again.
557
+ `npx -y beatsheet snap videos/<name>.video.json`, which puts every scene on the beat at once, and check again.
537
558
  `image "<file>.svg" has live text …` names an SVG image whose text can render a few pixels differently
538
559
  depending on the frames sought before: add `text-rendering="geometricPrecision"` to its `<svg>` element, or
539
560
  convert the text to outlines (ask before changing a logo someone else supplied).
@@ -550,7 +571,7 @@ Loop until all three are clean:
550
571
  report, and never silence one to reach a clean check. The run then ends with
551
572
  `ok: 0 errors, 0 warnings, 1 silenced (svg-text)`: that is clean. Errors and layout issues cannot be
552
573
  silenced, and an id that names no warning is itself an error.
553
- 2. `npx beatsheet stills videos/<name>.video.json --format 16:9,4:5 --transitions --sheet`, then **open both
574
+ 2. `npx -y beatsheet stills videos/<name>.video.json --format 16:9,4:5 --transitions --sheet`, then **open both
554
575
  sheets with the Read tool** (`out/stills/<name>-16x9-sheet-transitions.png`, `…-4x5-sheet-transitions.png`).
555
576
  Tiles run in time order, 4 per row: each scene's settled still (0.4 s before its end) and the stills of every
556
577
  transition that is not a cut. `dip`: one, the outgoing scene half faded. `slide`, `zoom`: two, the outgoing
@@ -584,7 +605,7 @@ A clean `check` is not a finished video: it cannot see a weak frame.
584
605
 
585
606
  ## 8. Render and deliver
586
607
 
587
- `npx beatsheet render videos/<name>.video.json --format 16:9,4:5` (about a minute per format; run it in the
608
+ `npx -y beatsheet render videos/<name>.video.json --format 16:9,4:5` (about a minute per format; run it in the
588
609
  background) writes `out/<name>-16x9.mp4`, `out/<name>-4x5.mp4` and the posters `out/<name>-16x9.jpg`,
589
610
  `out/<name>-4x5.jpg`; the poster is baked in as frame 0. For a silent GIF per format add `--gif` (or `--gif-only`):
590
611
  small by default (12 fps, 800 px wide, ~0.5-0.8 MB for 20 s), `--gif-preset medium|large`, `--gif-scene <id>` or
@@ -597,7 +618,7 @@ Tell the user: the MP4 and poster paths, the video, plan and share files, one se
597
618
  true on the posting day (version, surface), and how to fine-tune it themselves:
598
619
 
599
620
  ```bash
600
- cd <project folder> && npx beatsheet studio --open
621
+ cd <project folder> && npx -y beatsheet studio --open
601
622
  ```
602
623
 
603
624
  (In a checkout, build the studio first, in the repo root, once and after studio changes:
@@ -617,10 +638,10 @@ hides its caption and edits the narration's written form.
617
638
  |---|---|
618
639
  | Tone, message or music inferred from the brand's site and built without asking | 2. Direction: one AskUserQuestion call before the plan; a calm site can still want a bold video |
619
640
  | Absolute times converted into many gap overrides | Durations plus default beats; override single gaps |
620
- | Every scene on the default `dip`, every text on the default `fade` | Pick both from the direction: the tone's row, then the two tables in 5. Write the video || Scene durations off the music's beat (3.4 s under `upbeat-pulse`) | Rough durations, then `npx beatsheet snap <file>` (no beat arithmetic): 5. Write the video |
641
+ | Every scene on the default `dip`, every text on the default `fade` | Pick both from the direction: the tone's row, then the two tables in 5. Write the video || Scene durations off the music's beat (3.4 s under `upbeat-pulse`) | Rough durations, then `npx -y beatsheet snap <file>` (no beat arithmetic): 5. Write the video |
621
642
  | Narration that reads the screen out, or "16:9" in a spoken line | A line that adds to the screen; numbers and symbols spelled as spoken ("sixteen by nine") |
622
643
  | A narrated video for a feed without captions | `"captions": true`: feeds autoplay muted |
623
- | Rendered a narrated video without `speak` | `render` stops on a missing clip: run `beatsheet speak <file>` first, commit `speech/` |
644
+ | Rendered a narrated video without `speak` | `render` stops on a missing clip: run `npx -y beatsheet speak <file>` first, commit `speech/` |
624
645
  | Output text invented ("✓ Success!") | Copy the real string from the code, a test or a run |
625
646
  | Rendered because `check` passed | Look at both sheets first |
626
647
  | Only 16:9 looked at | 4:5 overflows first; check and look at it too |
@@ -634,4 +655,4 @@ hides its caption and edits the narration's written form.
634
655
  | `font-size:64px` or `font-weight:600` in a new scene type | A type role and a weight token (`var(--bs-text-heading)`, `var(--bs-weight-display)`) |
635
656
  | A claim that is true only on a beta or an undeployed surface | Name it in the plan and the report; the project README says how to check |
636
657
  | A shell `$` prompt in front of an API or MCP call | `message` or `output` step instead of `command` |
637
- | `check`/`stills` can't start a browser | `npx playwright install chromium-headless-shell` |
658
+ | `check`/`stills` can't start a browser | The error names why Chromium's download failed (often no network): run the command again once that is fixed (it tries the download again), or set `BEATSHEET_CHROMIUM` to a Chromium binary |
@@ -212,7 +212,8 @@ layer.destroy();
212
212
 
213
213
  ## three.js
214
214
 
215
- Use it for real 3D: an object turning, a scene with light. Install it in the project (`npm i three`).
215
+ Use it for real 3D: an object turning, a scene with light. Install it in the project with the skill's install line,
216
+ so beatsheet and three.js land in one install: `npm install -D beatsheet @beatsheet/core @beatsheet/scenes three`.
216
217
 
217
218
  ```ts
218
219
  import * as THREE from 'three';
@@ -255,7 +256,8 @@ renderer.forceContextLoss();
255
256
 
256
257
  Use it when a sequence is easier to write as a timeline than as formulas: many staggered parts, overshoots,
257
258
  choreography. Worked example with its test: `examples/beatsheet-promo/scenes/timeline-hero.ts`. Install it in the
258
- project (`npm i gsap`; free to use, not open source: its licence applies to the project).
259
+ project with the skill's install line, `npm install -D beatsheet @beatsheet/core @beatsheet/scenes gsap` (free to use,
260
+ not open source: its licence applies to the project).
259
261
 
260
262
  ```ts
261
263
  import gsap from 'gsap';
@@ -6,24 +6,16 @@
6
6
  */
7
7
  import fs from 'node:fs';
8
8
  import path from 'node:path';
9
- import { pathToFileURL } from 'node:url';
10
- import { parseDoc, resolveTimeline, type ProjectConfig } from '@beatsheet/core';
11
-
12
- function findConfig(from: string): string {
13
- for (let dir = path.resolve(from); ; dir = path.dirname(dir)) {
14
- const candidate = path.join(dir, 'beatsheet.config.ts');
15
- if (fs.existsSync(candidate)) return candidate;
16
- if (path.dirname(dir) === dir) throw new Error(`no beatsheet.config.ts above ${from}`);
17
- }
18
- }
9
+ import { discoverProject } from 'beatsheet';
10
+ import { parseDoc, resolveTimeline } from '@beatsheet/core';
19
11
 
20
12
  const file = process.argv[2];
21
13
  if (!file) {
22
14
  console.error('usage: npx beatsheet beats videos/<name>.video.json');
23
15
  process.exit(2);
24
16
  }
25
- const configPath = findConfig(path.dirname(path.resolve(file)));
26
- const project = ((await import(pathToFileURL(configPath).href)) as { default: ProjectConfig }).default;
17
+ // The nearest beatsheet.config.ts up from the video, else the default project (default theme, built-in scenes).
18
+ const project = (await discoverProject(path.resolve(file))).config;
27
19
  const timeline = resolveTimeline(parseDoc(JSON.parse(fs.readFileSync(file, 'utf8'))), project);
28
20
  const s2 = (n: number): string => n.toFixed(2).padStart(6);
29
21
 
@@ -1,19 +1,20 @@
1
1
  /**
2
2
  * Prints the scene, sound and music catalogue of a project as Markdown, from the code:
3
3
  * npx beatsheet catalogue [path/to/beatsheet.config.ts] [--props]
4
- * Default config: ./beatsheet.config.ts (run it from a project folder). --props adds every prop with its label,
4
+ * Default: the nearest beatsheet.config.ts up from the current folder, else the default project (default theme,
5
+ * built-in scenes). --props adds every prop with its label,
5
6
  * nested fields included (`nodes[].icon`), an enum with its values (the icon names).
6
7
  * Music lists each track's tempo and beat length: scene durations in whole beats keep every cut on the beat.
7
8
  */
8
- import path from 'node:path';
9
- import { pathToFileURL } from 'node:url';
9
+ import { discoverProject, loadProject } from 'beatsheet';
10
10
  import { MUSIC_CATEGORIES, SCENE_CATEGORIES, SOUND_CATEGORIES, beatSeconds, isFileTrack, sceneSamples, trackBpm, trackParts, z } from '@beatsheet/core';
11
- import type { MusicTrack, ProjectConfig, SceneType } from '@beatsheet/core';
11
+ import type { MusicTrack, SceneType } from '@beatsheet/core';
12
12
 
13
13
  const args = process.argv.slice(2);
14
14
  const withProps = args.includes('--props');
15
- const configPath = path.resolve(args.find((a) => !a.startsWith('--')) ?? 'beatsheet.config.ts');
16
- const project = ((await import(pathToFileURL(configPath).href)) as { default: ProjectConfig }).default;
15
+ const configPath = args.find((a) => !a.startsWith('--'));
16
+ const context = configPath ? await loadProject(configPath) : await discoverProject(process.cwd());
17
+ const project = context.config;
17
18
 
18
19
  interface JsonNode {
19
20
  type?: string | string[];
@@ -75,7 +76,8 @@ function tempo(track: MusicTrack): string {
75
76
  return bpm === undefined ? '–' : `${bpm} bpm · beat ${Math.round(beatSeconds(bpm) * 1000) / 1000} s`;
76
77
  }
77
78
 
78
- const out: string[] = [`# ${project.name}: scene types, sounds and music`, ''];
79
+ // The context's name: the config's, else the folder's (the default project's config has none).
80
+ const out: string[] = [`# ${context.name}: scene types, sounds and music`, ''];
79
81
  const groups = [...SCENE_CATEGORIES.map((c) => ({ id: c.id as string, title: c.title })), { id: 'other', title: 'Other' }];
80
82
  for (const g of groups) {
81
83
  const types = project.scenes.filter((t) => (t.category ?? 'other') === g.id);
package/src/args.ts CHANGED
@@ -16,6 +16,7 @@ export type Command =
16
16
  | { cmd: 'check-samples'; types?: string[]; samples?: string[]; formats?: FormatId[] }
17
17
  | { cmd: 'stills-samples'; types?: string[]; samples?: string[]; formats?: FormatId[]; sheet: boolean; clean?: boolean; out?: string }
18
18
  | { cmd: 'skill-install'; dir?: string; force: boolean }
19
+ | { cmd: 'paths' }
19
20
  | { cmd: 'script'; name: SkillScript; args: string[] };
20
21
 
21
22
  export class UsageError extends Error {}
@@ -46,6 +47,7 @@ Usage:
46
47
  beatsheet check --samples [--type cta,terminal] [--sample default,long] [--format 16:9,4:5,1:1,9:16]
47
48
  beatsheet stills --samples [--type cta] [--sample long] [--format 4:5] [--sheet] [--clean] [--out dir]
48
49
  beatsheet skill install [--dir ~/.claude/skills] [--force]
50
+ beatsheet paths where beatsheet's sources, skill and examples are (for agents)
49
51
  beatsheet catalogue [beatsheet.config.ts] [--props]
50
52
  beatsheet beats <file>
51
53
  beatsheet frames <file> [--format 16:9] [--scene <id>] [--backwards]
@@ -198,6 +200,9 @@ export function parseCli(argv: string[]): Command {
198
200
  const { values } = parse(args, { dir: { type: 'string' }, force: { type: 'boolean' } }, false);
199
201
  return { cmd: 'skill-install', dir: str(values.dir), force: values.force === true };
200
202
  }
203
+ case 'paths':
204
+ parse(rest, {}, false);
205
+ return { cmd: 'paths' };
201
206
  case 'catalogue':
202
207
  case 'beats':
203
208
  case 'frames':
package/src/cli.ts CHANGED
@@ -2,25 +2,16 @@ import { createRequire } from 'node:module';
2
2
  import path from 'node:path';
3
3
  import { parseCli, USAGE, UsageError } from './args';
4
4
  import { CheckFailed, formatPath, runCheck, runRender, runSpeak, runStills, runStudio, type Log } from './commands';
5
+ import { userCwd } from './paths';
5
6
  import { errorMessage } from './project';
6
7
  import { runCheckSamples, runStillsSamples } from './samples';
7
- import { defaultSkillsDir, installSkill, runSkillScript } from './skill';
8
+ import { defaultSkillsDir, installSkill, pathsReport, runSkillScript } from './skill';
8
9
  import { runSnap } from './snap';
9
10
 
10
11
  const log: Log = (line) => process.stdout.write(line + '\n');
11
12
  const logError: Log = (line) => process.stderr.write(line + '\n');
12
13
 
13
- /**
14
- * The folder the user ran the command in. `npx beatsheet` inside a workspace package's subfolder
15
- * runs with the package root as cwd; npm keeps the original in INIT_CWD, used when it lies below
16
- * the cwd (an outer `npm run -w <pkg>` sets it above the cwd, where the cwd is right).
17
- */
18
- export function userCwd(env: NodeJS.ProcessEnv = process.env, cwd: string = process.cwd()): string {
19
- const init = env.INIT_CWD;
20
- if (!init) return cwd;
21
- const rel = path.relative(cwd, path.resolve(init));
22
- return rel && !rel.startsWith('..') && !path.isAbsolute(rel) ? path.resolve(init) : cwd;
23
- }
14
+ export { userCwd };
24
15
 
25
16
  /** Runs the CLI; resolves with the exit code (studio resolves when the server stops). */
26
17
  export async function main(argv: string[]): Promise<number> {
@@ -70,6 +61,9 @@ export async function main(argv: string[]): Promise<number> {
70
61
  case 'skill-install':
71
62
  installSkill({ dir: cmd.dir === undefined ? defaultSkillsDir() : path.resolve(userCwd(), cmd.dir), force: cmd.force }, log);
72
63
  return 0;
64
+ case 'paths':
65
+ for (const line of pathsReport()) log(line);
66
+ return 0;
73
67
  case 'script':
74
68
  return await runSkillScript(cmd.name, cmd.args, userCwd());
75
69
  case 'studio': {