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 +31 -25
- package/bin/beatsheet.js +2 -0
- package/bin/register-fallback.mjs +23 -0
- package/bin/resolve-fallback.mjs +83 -0
- package/package.json +4 -3
- package/skill/SKILL.md +63 -42
- package/skill/reference/scene-techniques.md +4 -2
- package/skill/scripts/beats.ts +4 -12
- package/skill/scripts/catalogue.ts +9 -7
- package/src/args.ts +5 -0
- package/src/cli.ts +6 -12
- package/src/commands.ts +7 -7
- package/src/default-project.config.ts +9 -0
- package/src/packages.ts +17 -0
- package/src/paths.ts +15 -0
- package/src/project.ts +50 -15
- package/src/render/browser.ts +98 -14
- package/src/samples.ts +6 -6
- package/src/server/api.ts +31 -0
- package/src/server/server.ts +8 -1
- package/src/server/vite.ts +34 -6
- package/src/skill.ts +39 -3
- package/src/speech.ts +4 -4
- package/studio/index.html +2 -2
- package/studio/{main-YAPVEB24.js → main-KMYDBWZH.js} +10 -10
- package/studio/{styles-TKESX5FY.css → styles-NJ2CULOW.css} +1 -1
package/src/skill.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { spawn } from 'node:child_process';
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
+
import { pathToFileURL } from 'node:url';
|
|
6
|
+
import { beatsheetPackageDirs } from './packages';
|
|
5
7
|
import { CLI_DIR } from './paths';
|
|
6
8
|
import type { Log } from './commands';
|
|
7
9
|
|
|
@@ -20,6 +22,38 @@ export function skillDir(cliDir: string = CLI_DIR): string | null {
|
|
|
20
22
|
return null;
|
|
21
23
|
}
|
|
22
24
|
|
|
25
|
+
/**
|
|
26
|
+
* The library tour, a finished example video, and the folder of the images it shows: the package's copy in
|
|
27
|
+
* skill/examples/library (scripts/copy-skill.mjs), else the checkout's examples/library. Null when neither exists.
|
|
28
|
+
*/
|
|
29
|
+
export function libraryTourSource(cliDir: string = CLI_DIR): { video: string; assets: string } | null {
|
|
30
|
+
const packaged = path.join(cliDir, 'skill', 'examples', 'library');
|
|
31
|
+
const checkout = path.resolve(cliDir, '../../examples/library');
|
|
32
|
+
const candidates = [
|
|
33
|
+
{ video: path.join(packaged, 'library-tour.video.json'), assets: path.join(packaged, 'assets') },
|
|
34
|
+
{ video: path.join(checkout, 'videos', 'library-tour.video.json'), assets: path.join(checkout, 'assets') },
|
|
35
|
+
];
|
|
36
|
+
return candidates.find((c) => fs.existsSync(c.video)) ?? null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* `beatsheet paths`: the version and where the sources of @beatsheet/core and @beatsheet/scenes, the skill
|
|
41
|
+
* and the example videos are, one per line, for an agent that wants to read them. A missing skill or tour
|
|
42
|
+
* reads "(not found)".
|
|
43
|
+
*/
|
|
44
|
+
export function pathsReport(cliDir: string = CLI_DIR): string[] {
|
|
45
|
+
const { version } = JSON.parse(fs.readFileSync(path.join(cliDir, 'package.json'), 'utf8')) as { version: string };
|
|
46
|
+
const { core, scenes } = beatsheetPackageDirs(cliDir);
|
|
47
|
+
const tour = libraryTourSource(cliDir);
|
|
48
|
+
return [
|
|
49
|
+
`beatsheet ${version}`,
|
|
50
|
+
`core ${path.join(core, 'src')}`,
|
|
51
|
+
`scenes ${path.join(scenes, 'src')}`,
|
|
52
|
+
`skill ${skillDir(cliDir) ?? '(not found)'}`,
|
|
53
|
+
`examples ${tour ? path.dirname(tour.video) : '(not found)'}`,
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
|
|
23
57
|
/** Where `skill install` puts the skill without --dir: Claude Code's personal skills folder. */
|
|
24
58
|
export function defaultSkillsDir(home: string = os.homedir()): string {
|
|
25
59
|
return path.join(home, '.claude', 'skills');
|
|
@@ -53,21 +87,23 @@ export function installSkill(o: InstallSkillOptions, log: Log): string {
|
|
|
53
87
|
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
54
88
|
fs.cpSync(from, target, { recursive: true });
|
|
55
89
|
log(`installed the beatsheet skill in ${target}`);
|
|
56
|
-
log('Claude Code picks it up in its next session
|
|
90
|
+
log('Claude Code picks it up in its next session: run `npx beatsheet studio` in a folder for your videos and tell Claude Code your idea there, or type /beatsheet.');
|
|
57
91
|
return target;
|
|
58
92
|
}
|
|
59
93
|
|
|
60
94
|
/**
|
|
61
95
|
* Runs one of the skill's helper scripts in a child process (TypeScript through tsx) with the user's cwd and
|
|
62
96
|
* args; resolves with its exit code. The script resolves `@beatsheet/core` and `beatsheet` from where it lies:
|
|
63
|
-
* the installed package, or the checkout's root node_modules
|
|
97
|
+
* the installed package, or the checkout's root node_modules; the project's config falls back to the CLI's
|
|
98
|
+
* @beatsheet packages (bin/register-fallback.mjs) when the project has none.
|
|
64
99
|
*/
|
|
65
100
|
export async function runSkillScript(name: SkillScript, args: string[], cwd: string, dir: string | null = skillDir()): Promise<number> {
|
|
66
101
|
if (!dir) throw new Error('this beatsheet package has no skill/ folder');
|
|
67
102
|
const script = path.join(dir, 'scripts', `${name}.ts`);
|
|
68
103
|
if (!fs.existsSync(script)) throw new Error(`no script ${script}`);
|
|
69
104
|
const tsx = import.meta.resolve('tsx');
|
|
70
|
-
const
|
|
105
|
+
const fallback = pathToFileURL(path.join(CLI_DIR, 'bin', 'register-fallback.mjs')).href;
|
|
106
|
+
const child = spawn(process.execPath, ['--import', tsx, '--import', fallback, script, ...args], { cwd, stdio: 'inherit' });
|
|
71
107
|
return new Promise((resolve, reject) => {
|
|
72
108
|
child.on('error', reject);
|
|
73
109
|
child.on('exit', (code, signal) => resolve(code ?? (signal ? 1 : 0)));
|
package/src/speech.ts
CHANGED
|
@@ -126,13 +126,13 @@ export function packageImportEntry(manifest: unknown): string | null {
|
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
128
|
* The plugins as the project sees them: `@beatsheet/voice-<engine>` found in the node_modules folders
|
|
129
|
-
* Node searches from the
|
|
129
|
+
* Node searches from the project root (its package.json), its entry for import()
|
|
130
130
|
* (packageImportEntry: an ESM-only package with only an "import" export works too) imported with a
|
|
131
131
|
* dynamic import(), its `createEngine()` (or default export) called once. The engine is kept: one
|
|
132
132
|
* model load per process.
|
|
133
133
|
*/
|
|
134
|
-
export function projectSpeechPlugins(
|
|
135
|
-
const req = createRequire(path.resolve(
|
|
134
|
+
export function projectSpeechPlugins(root: string, importer: (url: string) => Promise<unknown> = (url) => import(url)): SpeechPlugins {
|
|
135
|
+
const req = createRequire(path.join(path.resolve(root), 'package.json'));
|
|
136
136
|
const engines = new Map<string, Promise<SpeechEngine>>();
|
|
137
137
|
/** The plugin's package.json, or null when no node_modules folder has it. */
|
|
138
138
|
const manifest = (engine: string): string | null => {
|
|
@@ -150,7 +150,7 @@ export function projectSpeechPlugins(configPath: string, importer: (url: string)
|
|
|
150
150
|
if (known) return known;
|
|
151
151
|
const loading = (async (): Promise<SpeechEngine> => {
|
|
152
152
|
const pkgJson = manifest(engine);
|
|
153
|
-
if (!pkgJson) throw new Error(pluginMissingMessage(engine, path.
|
|
153
|
+
if (!pkgJson) throw new Error(pluginMissingMessage(engine, path.resolve(root)));
|
|
154
154
|
const pkg = pluginPackage(engine);
|
|
155
155
|
let entry: string | null;
|
|
156
156
|
try {
|
package/studio/index.html
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
<link rel="icon" href="favicon.ico" sizes="48x48">
|
|
12
12
|
<link rel="icon" href="icons/icon.svg" type="image/svg+xml">
|
|
13
13
|
<link rel="apple-touch-icon" href="icons/apple-touch-icon.png">
|
|
14
|
-
<style>:root{--bg:#141518;--panel:#1b1c20;--panel-2:#22242a;--panel-3:#2a2d34;--border:#30333b;--border-strong:#3d414b;--text:#e4e5e9;--muted:#959aa5;--faint:#6b707b;--accent:#7aa2f7;--accent-soft:rgba(122, 162, 247, .16);--warn:#e0b85c;--error:#f07a7a;--ok:#7fcf96;--scene:#2b3140;--scene-sel:#34405c;--playhead:#f2f3f5;--radius:6px;--font:system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;--mono:ui-monospace, "SF Mono", Menlo, Consolas, monospace;color-scheme:dark}*{box-sizing:border-box}html,body{margin:0;height:100%}body{background:var(--bg);color:var(--text);font:13px/1.45 var(--font);overflow:hidden}app-root{display:flex;flex-direction:column;height:100vh}</style><link rel="stylesheet" href="styles-
|
|
14
|
+
<style>:root{--bg:#141518;--panel:#1b1c20;--panel-2:#22242a;--panel-3:#2a2d34;--border:#30333b;--border-strong:#3d414b;--text:#e4e5e9;--muted:#959aa5;--faint:#6b707b;--accent:#7aa2f7;--accent-soft:rgba(122, 162, 247, .16);--warn:#e0b85c;--error:#f07a7a;--ok:#7fcf96;--scene:#2b3140;--scene-sel:#34405c;--playhead:#f2f3f5;--radius:6px;--font:system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;--mono:ui-monospace, "SF Mono", Menlo, Consolas, monospace;color-scheme:dark}*{box-sizing:border-box}html,body{margin:0;height:100%}body{background:var(--bg);color:var(--text);font:13px/1.45 var(--font);overflow:hidden}app-root{display:flex;flex-direction:column;height:100vh}</style><link rel="stylesheet" href="styles-NJ2CULOW.css" media="print" data-beasties-media="all"><noscript><link rel="stylesheet" href="styles-NJ2CULOW.css"></noscript></head>
|
|
15
15
|
<body>
|
|
16
16
|
<app-root></app-root>
|
|
17
|
-
<script src="main-
|
|
17
|
+
<script src="main-KMYDBWZH.js" type="module"></script><script>document.querySelectorAll('link[data-beasties-media]').forEach(function(l){l.media=l.getAttribute('data-beasties-media');l.removeAttribute('data-beasties-media')})</script></body>
|
|
18
18
|
</html>
|