@senseihq/emaki-cli 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +69 -2
- package/package.json +44 -4
- package/plugin/.claude-plugin/plugin.json +19 -0
- package/plugin/PLAYBOOK.md +137 -0
- package/plugin/README.md +51 -0
- package/plugin/agents/fact-checker.md +28 -0
- package/plugin/agents/localizer.md +34 -0
- package/plugin/agents/scene-builder.md +43 -0
- package/plugin/agents/story-planner.md +42 -0
- package/plugin/agents/story-writer.md +34 -0
- package/plugin/agents/visual-reviewer.md +33 -0
- package/plugin/modules/campaign/README.md +30 -0
- package/plugin/modules/campaign/calendar.csv +2 -0
- package/plugin/modules/campaign/day-script.template.md +42 -0
- package/plugin/modules/posting-desk/README.md +37 -0
- package/plugin/skills/emaki/SKILL.md +107 -0
- package/plugin/skills/emaki/references/01-interview.md +68 -0
- package/plugin/skills/emaki/references/02-architecture.md +69 -0
- package/plugin/skills/emaki/references/03-content-model.md +68 -0
- package/plugin/skills/emaki/references/04-scene-authoring.md +99 -0
- package/plugin/skills/emaki/references/05-voice-and-video.md +97 -0
- package/plugin/skills/emaki/references/06-i18n.md +37 -0
- package/plugin/skills/emaki/references/07-quality-gates.md +44 -0
- package/plugin/skills/emaki/references/08-feedback-loop.md +32 -0
- package/plugin/skills/emaki/references/09-publishing.md +14 -0
- package/plugin/skills/story-build/SKILL.md +37 -0
- package/plugin/skills/story-localize/SKILL.md +24 -0
- package/plugin/skills/story-media/SKILL.md +38 -0
- package/plugin/skills/story-publish/SKILL.md +36 -0
- package/plugin/skills/story-review/SKILL.md +29 -0
- package/plugin/templates/brief.md +32 -0
- package/plugin/templates/change-request.md +7 -0
- package/plugin/templates/changelog.md +4 -0
- package/plugin/templates/decisions.md +5 -0
- package/plugin/templates/glossary.md +4 -0
- package/plugin/templates/item-card.md +34 -0
- package/plugin/templates/outline.md +19 -0
- package/plugin/templates/review-sheet.md +12 -0
- package/plugin/templates/style-guide.md +21 -0
- package/plugin/templates/tracker.md +11 -0
- package/src/api.js +20 -0
- package/src/campaign.js +157 -0
- package/src/capture.js +205 -0
- package/src/carousel.js +91 -0
- package/src/config.js +32 -0
- package/src/day-script.js +66 -0
- package/src/desk-client.js +37 -0
- package/src/desk-plan.js +57 -0
- package/src/films.js +152 -0
- package/src/http.js +30 -0
- package/src/index.js +353 -0
- package/src/init.js +110 -0
- package/src/media.js +236 -0
- package/src/migrate.js +67 -0
- package/src/plugin.js +106 -0
- package/src/publish.js +118 -0
- package/src/stage.js +107 -0
- package/src/stories.js +66 -0
- package/src/tts.js +290 -0
- package/src/upload/instagram.js +34 -0
- package/src/upload/youtube.js +90 -0
- package/src/util.js +66 -0
- package/src/voice.js +295 -0
- package/src/youtube-text.js +58 -0
- package/templates/content/films/index.json +1 -0
- package/templates/content/films/measure-the-right-work/film.json +68 -0
- package/templates/content/films/measure-the-right-work/look.css +17 -0
- package/templates/content/films/measure-the-right-work/scene-close.json +153 -0
- package/templates/content/films/measure-the-right-work/scene-groups.json +99 -0
- package/templates/content/films/measure-the-right-work/scene-hook.json +96 -0
- package/templates/content/films/measure-the-right-work/scene-pair.json +190 -0
- package/templates/content/films/measure-the-right-work/scene-problem.json +162 -0
- package/templates/content/films/measure-the-right-work/score.js +19 -0
- package/templates/content/films/measure-the-right-work/strings/en.json +50 -0
- package/templates/content/films/measure-the-right-work/strings/es.json +50 -0
- package/templates/content/films/measure-the-right-work/timing.en.json +24 -0
- package/templates/content/films/measure-the-right-work/timing.es.json +24 -0
- package/templates/content/films/measure-the-right-work/voice/en/close.m4a +0 -0
- package/templates/content/films/measure-the-right-work/voice/en/groups.m4a +0 -0
- package/templates/content/films/measure-the-right-work/voice/en/hook.m4a +0 -0
- package/templates/content/films/measure-the-right-work/voice/en/pair.m4a +0 -0
- package/templates/content/films/measure-the-right-work/voice/en/problem.m4a +0 -0
- package/templates/content/films/measure-the-right-work/voice/en.json +7 -0
- package/templates/content/films/measure-the-right-work/voice/es/close.m4a +0 -0
- package/templates/content/films/measure-the-right-work/voice/es/groups.m4a +0 -0
- package/templates/content/films/measure-the-right-work/voice/es/hook.m4a +0 -0
- package/templates/content/films/measure-the-right-work/voice/es/pair.m4a +0 -0
- package/templates/content/films/measure-the-right-work/voice/es/problem.m4a +0 -0
- package/templates/content/films/measure-the-right-work/voice/es.json +7 -0
- package/templates/content/logos/brand.svg +1 -0
- package/templates/content/site.json +10 -0
- package/templates/content/stories/en/measure-the-right-work.json +13 -0
- package/templates/content/stories/es/measure-the-right-work.json +13 -0
- package/templates/content/stories/index.json +12 -0
- package/templates/content/ui/en.json +1 -0
- package/templates/content/ui/es.json +1 -0
- package/templates/emaki.config.json +67 -0
- package/templates/film/look.css +17 -0
- package/templates/film/scene-close.json +153 -0
- package/templates/film/scene-template.json +71 -0
- package/templates/film/score.js +12 -0
package/src/http.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// HTTP for the media pipeline (stage, publish): one injectable fetch, and failures as MotionErrors that name the
|
|
2
|
+
// method, the URL without its query (where tokens travel) and the response status and text. Credentials go in headers
|
|
3
|
+
// or bodies, never into a message.
|
|
4
|
+
import { die } from './util.js'
|
|
5
|
+
|
|
6
|
+
const bare = (url) => String(url).split('?')[0]
|
|
7
|
+
|
|
8
|
+
/** Sends one request; a non-2xx answer or a network error stops the run. Returns the Response. */
|
|
9
|
+
export async function call(fetchFn, method, url, { body, headers = {} } = {}) {
|
|
10
|
+
let r
|
|
11
|
+
try {
|
|
12
|
+
r = await fetchFn(url, { method, body, headers })
|
|
13
|
+
} catch (e) {
|
|
14
|
+
die(`${method} ${bare(url)}: ${e instanceof Error ? e.message : e}`)
|
|
15
|
+
}
|
|
16
|
+
if (!r.ok) die(`${method} ${bare(url)} → ${r.status}: ${(await r.text()).slice(0, 400)}`)
|
|
17
|
+
return r
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** call() and parse the JSON answer ({} for an empty body). */
|
|
21
|
+
export async function callJson(fetchFn, method, url, opts) {
|
|
22
|
+
const text = await (await call(fetchFn, method, url, opts)).text()
|
|
23
|
+
return text ? JSON.parse(text) : {}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Dies naming every missing variable: credentials come from the environment (or CI secrets) only. */
|
|
27
|
+
export function need(env, ...names) {
|
|
28
|
+
const missing = names.filter((n) => !env[n])
|
|
29
|
+
if (missing.length) die(`missing ${missing.join(', ')}: set them in the environment (or CI secrets), never in emaki.config.json`)
|
|
30
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
// emaki: set a project up for motion stories, install the Claude plugin, and run the production steps
|
|
4
|
+
// (validate, sheet, voice, fit, render, build) per film and per locale.
|
|
5
|
+
import sade from 'sade'
|
|
6
|
+
import pkg from '../package.json' with { type: 'json' }
|
|
7
|
+
import { project } from './config.js'
|
|
8
|
+
import { manifest, newFilm, validate } from './films.js'
|
|
9
|
+
import { migrate } from './migrate.js'
|
|
10
|
+
import { MotionError, parseOpts } from './util.js'
|
|
11
|
+
|
|
12
|
+
const prog = sade('emaki')
|
|
13
|
+
prog.version(pkg.version)
|
|
14
|
+
|
|
15
|
+
/** Runs a command; a MotionError prints its message and exits 1, anything else is a bug and shows its stack. */
|
|
16
|
+
const act = (fn) => async (...args) => {
|
|
17
|
+
try {
|
|
18
|
+
await fn(...args)
|
|
19
|
+
} catch (e) {
|
|
20
|
+
if (e instanceof MotionError) {
|
|
21
|
+
console.error(`emaki: ${e.message}`)
|
|
22
|
+
process.exit(1)
|
|
23
|
+
}
|
|
24
|
+
throw e
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const P = () => project()
|
|
28
|
+
const loc = (o, p) => o.locale ?? p.site.defaultLocale
|
|
29
|
+
|
|
30
|
+
prog.command('init')
|
|
31
|
+
.describe('Set this project up: sample content, emaki.config.json, the film source and the /show capture route.')
|
|
32
|
+
.option('--framework', 'sveltekit | svelte | react | next | vue | nuxt | vanilla (default: detected)')
|
|
33
|
+
.option('--content', 'Content folder', 'content')
|
|
34
|
+
.option('--no-sample', 'Skip the sample film')
|
|
35
|
+
.option('--plugin', 'Also install the Claude plugin (skills, agents, playbook)', true)
|
|
36
|
+
.action(act(async (o) => {
|
|
37
|
+
const { init } = await import('./init.js')
|
|
38
|
+
const r = init({ framework: o.framework, content: o.content, sample: o.sample !== false })
|
|
39
|
+
console.info(`framework: ${r.framework}`)
|
|
40
|
+
r.wrote.forEach((f) => console.info(` wrote ${f}`))
|
|
41
|
+
r.kept.forEach((f) => console.info(` kept ${f} (exists)`))
|
|
42
|
+
if (o.plugin !== false) {
|
|
43
|
+
const { installPlugin, report } = await import('./plugin.js')
|
|
44
|
+
const x = installPlugin()
|
|
45
|
+
report('skill', x.skills); report('agent', x.agents); report('file', x.extras)
|
|
46
|
+
}
|
|
47
|
+
console.info(`\nNext:\n npm i ${r.packages.join(' ')}\n npm i -D playwright && npx playwright install chromium (sheet, render)\n npx emaki validate && npx emaki tts-check`)
|
|
48
|
+
console.info('Then in Claude: "build our motion stories" (the emaki skill interviews you and plans the work).')
|
|
49
|
+
}))
|
|
50
|
+
|
|
51
|
+
prog.command('plugin install')
|
|
52
|
+
.describe('Install the Claude plugin into .claude/: every skill and agent, plus the playbook and templates.')
|
|
53
|
+
.option('--force', 'Overwrite what exists', false)
|
|
54
|
+
.action(act(async (o) => {
|
|
55
|
+
const { installPlugin, report } = await import('./plugin.js')
|
|
56
|
+
const x = installPlugin({ force: o.force })
|
|
57
|
+
report('skill', x.skills); report('agent', x.agents); report('file', x.extras)
|
|
58
|
+
}))
|
|
59
|
+
|
|
60
|
+
prog.command('skills [sub]')
|
|
61
|
+
.describe('List the bundled skills, or add some: emaki skills add <name...> | --all')
|
|
62
|
+
.option('--all', 'Every skill', false)
|
|
63
|
+
.option('--force', 'Overwrite', false)
|
|
64
|
+
.action(act(async (sub, o) => {
|
|
65
|
+
const { listSkills, installSkills, report } = await import('./plugin.js')
|
|
66
|
+
if (sub === 'add') return report('skill', installSkills(o.all ? listSkills().map((s) => s.name) : o._, { force: o.force }))
|
|
67
|
+
for (const s of listSkills()) console.info(`${s.name}\n ${s.description}`)
|
|
68
|
+
console.info('\nInstall with: emaki skills add <name> [...] (or --all)')
|
|
69
|
+
}))
|
|
70
|
+
|
|
71
|
+
prog.command('agents [sub]')
|
|
72
|
+
.describe('List the bundled agents, or add some: emaki agents add <name...> | --all')
|
|
73
|
+
.option('--all', 'Every agent', false)
|
|
74
|
+
.option('--force', 'Overwrite', false)
|
|
75
|
+
.action(act(async (sub, o) => {
|
|
76
|
+
const { listAgents, installAgents, report } = await import('./plugin.js')
|
|
77
|
+
if (sub === 'add') return report('agent', installAgents(o.all ? listAgents().map((a) => a.name) : o._, { force: o.force }))
|
|
78
|
+
for (const a of listAgents()) console.info(`${a.name}\n ${a.description}`)
|
|
79
|
+
console.info('\nInstall with: emaki agents add <name> [...] (or --all)')
|
|
80
|
+
}))
|
|
81
|
+
|
|
82
|
+
prog.command('manifest')
|
|
83
|
+
.describe('Write content/films/index.json (the fetch loader reads it).')
|
|
84
|
+
.action(act(() => { const r = manifest(P()); console.info(`${r.count} films → ${r.path}`) }))
|
|
85
|
+
|
|
86
|
+
prog.command('validate [slug]')
|
|
87
|
+
.describe('Check the contracts: files, scene ids, {{keys}} in every locale, voice lines, story bodies.')
|
|
88
|
+
.action(act((slug) => {
|
|
89
|
+
const r = validate(P(), slug)
|
|
90
|
+
r.lines.forEach((l) => console.info(l))
|
|
91
|
+
console.info(r.problems ? `${r.problems} problem(s)` : 'ok')
|
|
92
|
+
if (r.problems) process.exitCode = 1
|
|
93
|
+
}))
|
|
94
|
+
|
|
95
|
+
prog.command('migrate <from>')
|
|
96
|
+
.describe('Move a sensei-hq.com-style site (src/lib/motion, src/lib/content/articles, films/) into content/ and production/. Never overwrites.')
|
|
97
|
+
.option('--locale', 'The locale the site was written in', 'en')
|
|
98
|
+
.action(act((from, o) => {
|
|
99
|
+
const p = P(), r = migrate(p, from, { locale: o.locale })
|
|
100
|
+
r.wrote.forEach((f) => console.info(` wrote ${f}`))
|
|
101
|
+
if (r.kept.length) console.info(` kept ${r.kept.length} existing file(s)`)
|
|
102
|
+
const v = validate(project())
|
|
103
|
+
v.lines.forEach((l) => console.info(l))
|
|
104
|
+
console.info(v.problems ? `${v.problems} problem(s) left: fix them, then \`emaki validate\`` : 'migrated; emaki validate: ok')
|
|
105
|
+
if (v.problems) process.exitCode = 1
|
|
106
|
+
}))
|
|
107
|
+
|
|
108
|
+
prog.command('new <slug>')
|
|
109
|
+
.describe('Scaffold a story and its film in every locale.')
|
|
110
|
+
.option('--scenes', 'Scene ids, comma separated (close is added last)', 'hook,idea,how')
|
|
111
|
+
.option('--title', 'Film title')
|
|
112
|
+
.option('--date', 'Publish date YYYY-MM-DD (default today)')
|
|
113
|
+
.action(act((slug, o) => {
|
|
114
|
+
const r = newFilm(P(), slug, { scenes: o.scenes, title: o.title, date: o.date })
|
|
115
|
+
console.info(`scaffolded ${r.slug}: ${r.scenes} scenes, ${r.locales} locale(s). Next: write the scenes, then \`emaki sheet ${r.slug}\`.`)
|
|
116
|
+
}))
|
|
117
|
+
|
|
118
|
+
prog.command('sheet <slug>')
|
|
119
|
+
.describe('Contact sheet: each scene\'s final picture in both orientations (needs Playwright).')
|
|
120
|
+
.option('--locale', 'Locale (default: the site default)')
|
|
121
|
+
.option('--url', 'A running site (default: start the dev server)')
|
|
122
|
+
.option('--at', 'scene:t,scene:t instead of each scene\'s final picture')
|
|
123
|
+
.action(act(async (slug, o) => {
|
|
124
|
+
const { sheet } = await import('./capture.js')
|
|
125
|
+
const p = P()
|
|
126
|
+
await sheet(p, slug, { locale: loc(o, p), url: o.url, at: o.at })
|
|
127
|
+
}))
|
|
128
|
+
|
|
129
|
+
prog.command('tts-check')
|
|
130
|
+
.describe('Which voice provider each locale uses, whether it is ready here, and which offline engines exist.')
|
|
131
|
+
.action(act(async () => {
|
|
132
|
+
const { ttsCheck } = await import('./voice.js')
|
|
133
|
+
const r = ttsCheck(P())
|
|
134
|
+
for (const x of r.rows) console.info(`${x.locale}: ${x.provider ? `${x.provider} (${x.label}) ${x.ready ? 'ready' : `not ready: ${x.note}`}` : 'no provider set'}`)
|
|
135
|
+
console.info(`offline engines on this machine: ${r.offline.join(', ') || 'none'}`)
|
|
136
|
+
}))
|
|
137
|
+
|
|
138
|
+
prog.command('set-voice')
|
|
139
|
+
.describe('Choose the voice provider for a locale (or "default"); options with --opt key=value. Keys stay in env vars.')
|
|
140
|
+
.option('--locale', 'Locale, a language, or default', 'default')
|
|
141
|
+
.option('--provider', 'piper | kokoro | macos | espeak | elevenlabs | openai | azure | google | polly | manual')
|
|
142
|
+
.option('--opt', 'key=value (voice, voice_id, model, instructions, rate, …); repeatable')
|
|
143
|
+
.action(act(async (o) => {
|
|
144
|
+
const { setVoice } = await import('./voice.js')
|
|
145
|
+
if (!o.provider) throw new MotionError('--provider is required')
|
|
146
|
+
const r = setVoice(P(), o.locale, o.provider, parseOpts(o.opt))
|
|
147
|
+
r.dropped.forEach((k) => console.info(`dropped "${k}": keys belong in environment variables, not emaki.config.json`))
|
|
148
|
+
console.info(`voice.${o.locale} = ${JSON.stringify(r.block)}`)
|
|
149
|
+
}))
|
|
150
|
+
|
|
151
|
+
prog.command('voices')
|
|
152
|
+
.describe('List the voices a provider offers for a locale.')
|
|
153
|
+
.option('--locale', 'Locale (default: the site default)')
|
|
154
|
+
.option('--provider', 'Override the configured provider')
|
|
155
|
+
.action(act(async (o) => {
|
|
156
|
+
const { listVoices } = await import('./voice.js')
|
|
157
|
+
const p = P()
|
|
158
|
+
for (const v of await listVoices(p, loc(o, p), o.provider)) console.info(v)
|
|
159
|
+
}))
|
|
160
|
+
|
|
161
|
+
prog.command('voice <slug>')
|
|
162
|
+
.describe('Synthesise the takes from voice/<locale>.json with the configured provider.')
|
|
163
|
+
.option('--locale', 'Locale (default: the site default)')
|
|
164
|
+
.option('--only', 'Take numbers, e.g. 2,5')
|
|
165
|
+
.option('--provider', 'Override the configured provider for this run')
|
|
166
|
+
.option('--opt', 'key=value override, e.g. voice=nova; repeatable')
|
|
167
|
+
.action(act(async (slug, o) => {
|
|
168
|
+
const { voice } = await import('./voice.js')
|
|
169
|
+
const p = P()
|
|
170
|
+
await voice(p, slug, { locale: loc(o, p), only: o.only, provider: o.provider, opts: parseOpts(o.opt) })
|
|
171
|
+
}))
|
|
172
|
+
|
|
173
|
+
prog.command('fit <slug>')
|
|
174
|
+
.describe('Fit each scene\'s running time to its take: timing.<locale>.json.')
|
|
175
|
+
.option('--locale', 'Locale (default: the site default)')
|
|
176
|
+
.option('--check', 'Report only; write nothing', false)
|
|
177
|
+
.action(act(async (slug, o) => {
|
|
178
|
+
const { fit } = await import('./voice.js')
|
|
179
|
+
const p = P()
|
|
180
|
+
const r = fit(p, slug, { locale: loc(o, p), check: o.check })
|
|
181
|
+
console.info(`${'scene'.padEnd(12)} ${'design'.padStart(6)} ${'holds'.padStart(6)} ${'take'.padStart(6)} ${'runs'.padStart(6)}`)
|
|
182
|
+
for (const x of r.rows)
|
|
183
|
+
console.info(`${x.scene.padEnd(12)} ${x.design.toFixed(1).padStart(6)} ${x.holds.toFixed(1).padStart(6)} ${x.take.toFixed(1).padStart(6)} ${x.runs.toFixed(1).padStart(6)}${x.longer ? ' ← longer' : x.shorter ? ' ← shorter' : ''}${x.take ? '' : ' (no take)'}`)
|
|
184
|
+
console.info(`total ${r.total.toFixed(1)} s (${loc(o, p)})${r.written ? `\nwrote ${r.path}` : ''}`)
|
|
185
|
+
}))
|
|
186
|
+
|
|
187
|
+
prog.command('voice-web <slug>')
|
|
188
|
+
.describe('Narration for the browser: each take as voice/<locale>/<scene>.m4a, and its start in timing.<locale>.json (needs ffmpeg).')
|
|
189
|
+
.option('--locale', 'Locale (default: the site default)')
|
|
190
|
+
.action(act(async (slug, o) => {
|
|
191
|
+
const { voiceWeb } = await import('./voice.js')
|
|
192
|
+
const p = P()
|
|
193
|
+
const r = voiceWeb(p, slug, { locale: loc(o, p), log: (l) => console.info(`wrote ${l}`) })
|
|
194
|
+
for (const f of r.removed) console.info(`removed ${f} (no take)`)
|
|
195
|
+
console.info(`wrote ${r.timing}`)
|
|
196
|
+
}))
|
|
197
|
+
|
|
198
|
+
prog.command('render <slug>')
|
|
199
|
+
.describe('Capture the picture frame by frame (with the score) and the covers (needs Playwright + ffmpeg).')
|
|
200
|
+
.option('--locale', 'Locale (default: the site default)')
|
|
201
|
+
.option('--url', 'A running site (default: start the dev server)')
|
|
202
|
+
.option('--o', 'both | landscape | portrait', 'both')
|
|
203
|
+
.option('--fps', 'Frames per second', 30)
|
|
204
|
+
.option('--from', 'Start at this film time (s)', 0)
|
|
205
|
+
.option('--to', 'Stop at this film time (s; default the end)')
|
|
206
|
+
.option('--out', 'Output: a .mp4 file (one layout) or a folder (default production/<slug>/<locale>/render/)')
|
|
207
|
+
.option('--music', 'synth (the film\'s score) | export (audio of production/<slug>/<locale>/<slug>.mp4) | none', 'synth')
|
|
208
|
+
.option('--audio-only', 'Lay the music on the existing render; capture no frames', false)
|
|
209
|
+
.option('--cover-only', 'Just save the cover frames', false)
|
|
210
|
+
.action(act(async (slug, o) => {
|
|
211
|
+
const { render } = await import('./capture.js')
|
|
212
|
+
const p = P()
|
|
213
|
+
await render(p, slug, {
|
|
214
|
+
locale: loc(o, p), url: o.url, o: o.o, fps: Number(o.fps), from: Number(o.from), to: o.to == null ? undefined : Number(o.to),
|
|
215
|
+
out: o.out, music: o.music, audioOnly: o['audio-only'], coverOnly: o['cover-only']
|
|
216
|
+
})
|
|
217
|
+
}))
|
|
218
|
+
|
|
219
|
+
prog.command('build <slug>')
|
|
220
|
+
.describe('Final videos: picture + voice + ducked score, captions (.srt/.vtt and burned in), -14 LUFS.')
|
|
221
|
+
.option('--locale', 'Locale (default: the site default)')
|
|
222
|
+
.option('--no-captions', 'Do not burn captions in')
|
|
223
|
+
.option('--check', 'Print each scene\'s take, freeze and start; build nothing', false)
|
|
224
|
+
.option('--out', 'Output folder (default production/<slug>/<locale>/out/)')
|
|
225
|
+
.action(act(async (slug, o) => {
|
|
226
|
+
const { build } = await import('./voice.js')
|
|
227
|
+
const p = P()
|
|
228
|
+
build(p, slug, { locale: loc(o, p), noCaptions: o.captions === false, check: o.check, out: o.out })
|
|
229
|
+
}))
|
|
230
|
+
|
|
231
|
+
// After the build: stage for approval on the posting desk, or publish straight to a platform. Credentials come from
|
|
232
|
+
// the environment only (STAGER_*, MEDIA_URL_SECRET, YT_*, IG_*; see the README).
|
|
233
|
+
const list = (v) => [v ?? []].flat().flatMap((x) => String(x).split(',')).map((x) => x.trim()).filter(Boolean)
|
|
234
|
+
|
|
235
|
+
prog.command('stage <slug>')
|
|
236
|
+
.describe('Upload a finished piece\'s media and post text to the posting desk for approval (STAGER_CLIENT_ID/SECRET).')
|
|
237
|
+
.option('--channels', 'youtube,instagram_reel,instagram_carousel,x (default: all)')
|
|
238
|
+
.option('--locale', 'Locale (default: the site default)')
|
|
239
|
+
.option('--dry-run', 'Print the posts; send nothing', false)
|
|
240
|
+
.action(act(async (slug, o) => {
|
|
241
|
+
const { stage } = await import('./stage.js')
|
|
242
|
+
await stage(P(), slug, { locale: o.locale, channels: o.channels ? list(o.channels) : undefined, dryRun: o['dry-run'] })
|
|
243
|
+
}))
|
|
244
|
+
|
|
245
|
+
prog.command('stage status [slug]')
|
|
246
|
+
.describe('Report each piece\'s script and what is produced to the desk\'s plan.')
|
|
247
|
+
.option('--locale', 'Locale (default: the site default)')
|
|
248
|
+
.action(act(async (slug, o) => {
|
|
249
|
+
const { productionStatus } = await import('./desk-plan.js')
|
|
250
|
+
await productionStatus(P(), slug, { locale: o.locale })
|
|
251
|
+
}))
|
|
252
|
+
|
|
253
|
+
prog.command('stage requests')
|
|
254
|
+
.describe('The open motion requests from the desk, with their threads.')
|
|
255
|
+
.action(act(async () => {
|
|
256
|
+
const { deskRequests } = await import('./desk-plan.js')
|
|
257
|
+
await deskRequests(P())
|
|
258
|
+
}))
|
|
259
|
+
|
|
260
|
+
prog.command('stage reply <id> [text]')
|
|
261
|
+
.describe('Answer a motion request; --working or --done moves it on.')
|
|
262
|
+
.option('--working', 'Mark it working', false)
|
|
263
|
+
.option('--done', 'Mark it done', false)
|
|
264
|
+
.action(act(async (id, text, o) => {
|
|
265
|
+
if (o.working && o.done) throw new MotionError('--working or --done, not both')
|
|
266
|
+
const { deskReply } = await import('./desk-plan.js')
|
|
267
|
+
await deskReply(P(), id, text ?? '', { status: o.done ? 'done' : o.working ? 'working' : undefined })
|
|
268
|
+
}))
|
|
269
|
+
|
|
270
|
+
prog.command('publish <channel> [slug]')
|
|
271
|
+
.describe('Post a finished film straight to youtube or instagram and record the link (YT_* / IG_* keys).')
|
|
272
|
+
.option('--locale', 'Locale (default: the site default)')
|
|
273
|
+
.option('--privacy', 'YouTube: public | unlisted | private', 'unlisted')
|
|
274
|
+
.option('--update', 'YouTube: refresh this uploaded video id in place (no re-upload)')
|
|
275
|
+
.option('--force-new', 'YouTube: upload even when an id is already recorded', false)
|
|
276
|
+
.option('--description-mode', 'With --update: prepend | replace', 'prepend')
|
|
277
|
+
.option('--video-url', 'Instagram: public MP4 URL (skips staging on the desk)')
|
|
278
|
+
.option('--cover-url', 'Instagram: public JPEG URL for the cover (with --video-url)')
|
|
279
|
+
.option('--dry-run', 'Print exactly what would post; touch nothing', false)
|
|
280
|
+
.option('--verify', 'Check the credentials (read-only) and name the account', false)
|
|
281
|
+
.action(act(async (channel, slug, o) => {
|
|
282
|
+
if (!o.verify && !slug) throw new MotionError('a slug is required (or --verify)')
|
|
283
|
+
const { publish } = await import('./publish.js')
|
|
284
|
+
await publish(P(), channel, slug, {
|
|
285
|
+
locale: o.locale, privacy: o.privacy, update: o.update && String(o.update), forceNew: o['force-new'], descriptionMode: o['description-mode'],
|
|
286
|
+
videoUrl: o['video-url'], coverUrl: o['cover-url'], dryRun: o['dry-run'], verify: o.verify
|
|
287
|
+
})
|
|
288
|
+
}))
|
|
289
|
+
|
|
290
|
+
prog.command('carousel [slug]')
|
|
291
|
+
.describe('Render a campaign day\'s Instagram carousel (1080×1350 PNGs) from its day script (needs Playwright).')
|
|
292
|
+
.option('--all', 'Every day script', false)
|
|
293
|
+
.option('--locale', 'Locale (default: the site default)')
|
|
294
|
+
.action(act(async (slug, o) => {
|
|
295
|
+
const { carousel } = await import('./carousel.js')
|
|
296
|
+
await carousel(P(), [slug, ...o._].filter(Boolean).map(String), { all: o.all, locale: o.locale })
|
|
297
|
+
}))
|
|
298
|
+
|
|
299
|
+
prog.command('campaign status')
|
|
300
|
+
.describe('What is due, and for each day what exists: story, film, takes, render, Short, carousel, posts.')
|
|
301
|
+
.option('--days', 'How many days', 14)
|
|
302
|
+
.option('--from', 'First date YYYY-MM-DD (default: today in the site\'s time zone)')
|
|
303
|
+
.action(act(async (o) => {
|
|
304
|
+
const { campaignStatus } = await import('./campaign.js')
|
|
305
|
+
const yes = (b) => (b ? 'yes' : ' - ')
|
|
306
|
+
console.info(`${'date'.padEnd(10)} ${'topic'.padEnd(11)} ${'title'.padEnd(46)} story film takes rndr short car posts`)
|
|
307
|
+
for (const r of campaignStatus(P(), { from: o.from && String(o.from), days: Number(o.days) })) {
|
|
308
|
+
const head = `${r.date} ${r.topic.slice(0, 11).padEnd(11)} ${r.title.slice(0, 46).padEnd(46)}`
|
|
309
|
+
if (!r.script) { console.info(`${head} (no day script yet)`); continue }
|
|
310
|
+
const posts = ['youtube', 'instagram', 'x'].map((k) => (r.posts[k] ? k[0].toUpperCase() : '·')).join('')
|
|
311
|
+
console.info(`${head} ${yes(r.story)} ${yes(r.film)} ${String(r.takes).padStart(4)} ${yes(r.render)} ${yes(r.built)} ${String(r.carousel).padStart(3)} ${posts}`)
|
|
312
|
+
}
|
|
313
|
+
console.info('\nposts: Y = YouTube, I = Instagram, X = X; · = not yet')
|
|
314
|
+
}))
|
|
315
|
+
|
|
316
|
+
prog.command('campaign shortfilm <slug>')
|
|
317
|
+
.describe('Set up a Short\'s film (scenes and voice lines) from its day script\'s voiceover table.')
|
|
318
|
+
.option('--locale', 'Locale (default: the site default)')
|
|
319
|
+
.action(act(async (slug, o) => {
|
|
320
|
+
const { shortFilm } = await import('./campaign.js')
|
|
321
|
+
const r = shortFilm(P(), slug, { locale: o.locale })
|
|
322
|
+
console.info(`wrote ${r.path}: ${r.scenes} beats. Next: build the scenes, then \`emaki voice ${slug}\`, \`emaki fit ${slug}\`, \`emaki render ${slug} --o portrait\`.`)
|
|
323
|
+
}))
|
|
324
|
+
|
|
325
|
+
prog.command('campaign posted <slug>')
|
|
326
|
+
.describe('Record where a piece was posted: the campaign ledger and the story\'s social links.')
|
|
327
|
+
.option('--youtube', 'Video id or URL')
|
|
328
|
+
.option('--instagram', 'Post URL')
|
|
329
|
+
.option('--x', 'Post URL')
|
|
330
|
+
.action(act(async (slug, o) => {
|
|
331
|
+
const { campaignPosted } = await import('./campaign.js')
|
|
332
|
+
const s = (v) => (v === undefined || v === true ? undefined : String(v))
|
|
333
|
+
const r = campaignPosted(P(), slug, { youtube: s(o.youtube), instagram: s(o.instagram), x: s(o.x) })
|
|
334
|
+
console.info(`recorded ${slug}: ${JSON.stringify(r)}. Commit content/stories/index.json; the next build links the posts.`)
|
|
335
|
+
}))
|
|
336
|
+
|
|
337
|
+
prog.command('campaign due')
|
|
338
|
+
.describe('The piece for one day (default today in the site\'s time zone), as JSON, for automation.')
|
|
339
|
+
.option('--date', 'YYYY-MM-DD')
|
|
340
|
+
.action(act(async (o) => {
|
|
341
|
+
const { campaignDue } = await import('./campaign.js')
|
|
342
|
+
console.info(JSON.stringify(campaignDue(P(), { date: o.date && String(o.date) }), null, 2))
|
|
343
|
+
}))
|
|
344
|
+
|
|
345
|
+
prog.command('campaign calendar')
|
|
346
|
+
.describe('Rewrite CALENDAR.md in the campaign folder from calendar.csv.')
|
|
347
|
+
.action(act(async () => {
|
|
348
|
+
const { campaignCalendar } = await import('./campaign.js')
|
|
349
|
+
const r = campaignCalendar(P())
|
|
350
|
+
console.info(`wrote ${r.path} (${r.days} days)`)
|
|
351
|
+
}))
|
|
352
|
+
|
|
353
|
+
prog.parse(process.argv)
|
package/src/init.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// `emaki init`: sets a project up for motion stories. Adds the sample content (one film in en + es), a
|
|
2
|
+
// emaki.config.json, and the framework glue: a film source (Vite globs, or the fetch loader) and the /show capture
|
|
3
|
+
// route where the framework allows writing one. Never overwrites a file that exists.
|
|
4
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
5
|
+
import { dirname, join } from 'node:path'
|
|
6
|
+
import { TEMPLATES } from './films.js'
|
|
7
|
+
import { load, save } from './util.js'
|
|
8
|
+
|
|
9
|
+
/** Which framework a project uses, from its package.json. */
|
|
10
|
+
export function detectFramework(cwd) {
|
|
11
|
+
const pj = join(cwd, 'package.json')
|
|
12
|
+
if (!existsSync(pj)) return 'vanilla'
|
|
13
|
+
const p = load(pj), deps = { ...p.dependencies, ...p.devDependencies }
|
|
14
|
+
if (deps['@sveltejs/kit']) return 'sveltekit'
|
|
15
|
+
if (deps.svelte) return 'svelte'
|
|
16
|
+
if (deps.next) return 'next'
|
|
17
|
+
if (deps.nuxt) return 'nuxt'
|
|
18
|
+
if (deps.react) return 'react'
|
|
19
|
+
if (deps.vue) return 'vue'
|
|
20
|
+
return 'vanilla'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const PACKAGES = {
|
|
24
|
+
sveltekit: ['@senseihq/emaki', '@senseihq/emaki-svelte'],
|
|
25
|
+
svelte: ['@senseihq/emaki', '@senseihq/emaki-svelte'],
|
|
26
|
+
react: ['@senseihq/emaki', '@senseihq/emaki-react'],
|
|
27
|
+
next: ['@senseihq/emaki', '@senseihq/emaki-react'],
|
|
28
|
+
vue: ['@senseihq/emaki', '@senseihq/emaki-vue'],
|
|
29
|
+
nuxt: ['@senseihq/emaki', '@senseihq/emaki-vue'],
|
|
30
|
+
vanilla: ['@senseihq/emaki']
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const GLOBS = (content) => `const g = {
|
|
34
|
+
films: import.meta.glob('/${content}/films/*/film.json', { eager: true, import: 'default' }),
|
|
35
|
+
scenes: import.meta.glob('/${content}/films/*/scene-*.json', { import: 'default' }),
|
|
36
|
+
strings: import.meta.glob('/${content}/films/*/strings/*.json', { import: 'default' }),
|
|
37
|
+
timings: import.meta.glob('/${content}/films/*/timing*.json', { eager: true, import: 'default' }),
|
|
38
|
+
raw: import.meta.glob(['/${content}/films/*/*.js', '/${content}/films/*/look.css'], { query: '?raw', import: 'default' }),
|
|
39
|
+
index: import.meta.glob('/${content}/stories/index.json', { eager: true, import: 'default' }),
|
|
40
|
+
bodies: import.meta.glob('/${content}/stories/*/*.json', { import: 'default' }),
|
|
41
|
+
logos: import.meta.glob('/${content}/logos/*.svg', { eager: true, query: '?raw', import: 'default' }),
|
|
42
|
+
site: import.meta.glob('/${content}/site.json', { eager: true, import: 'default' }),
|
|
43
|
+
voice: import.meta.glob('/${content}/films/*/voice/*/*.m4a', { eager: true, query: '?url', import: 'default' }),
|
|
44
|
+
};`
|
|
45
|
+
|
|
46
|
+
const viteSourceFile = (content) => `// Where films and stories come from (written by \`emaki init\`). Vite expands these globs at build time, so every
|
|
47
|
+
// film under /${content} is bundled; scene files and sounds load on demand. Call startMotion() once on the client.
|
|
48
|
+
import { setupMotion } from '@senseihq/emaki';
|
|
49
|
+
import { viteSource } from '@senseihq/emaki/loaders/vite';
|
|
50
|
+
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
+
${GLOBS(content)}
|
|
53
|
+
|
|
54
|
+
export const { filmSource, contentSource, logos, site } = viteSource(g as any);
|
|
55
|
+
|
|
56
|
+
let started = false;
|
|
57
|
+
export function startMotion() {
|
|
58
|
+
if (started) return;
|
|
59
|
+
started = true;
|
|
60
|
+
setupMotion({ source: filmSource, site, logos });
|
|
61
|
+
}
|
|
62
|
+
`
|
|
63
|
+
|
|
64
|
+
const FILES = {
|
|
65
|
+
sveltekit: (c) => ({
|
|
66
|
+
'src/lib/emaki-source.ts': viteSourceFile(c),
|
|
67
|
+
'src/routes/show/[film]/+page.ts': `// The capture page the video pipeline drives; client-only.\nexport const ssr = false;\nexport const prerender = false;\nexport const load = ({ params, url }) => ({\n film: params.film,\n capture: url.searchParams.get('capture') === '1',\n layout: url.searchParams.get('o') === 'portrait' ? 'portrait' : 'landscape',\n locale: url.searchParams.get('locale') ?? 'en',\n src: url.searchParams.get('src') === 'json' || url.searchParams.get('src') === 'js' ? url.searchParams.get('src') : undefined,\n mode: url.searchParams.get('mode') === 'dark' ? 'dark' : 'light',\n});\n`,
|
|
68
|
+
'src/routes/show/[film]/+page.svelte': `<script lang="ts">\n import { ShowPage } from '@senseihq/emaki-svelte';\n import { startMotion } from '$lib/emaki-source';\n let { data } = $props();\n startMotion();\n</script>\n\n<ShowPage film={data.film} layout={data.layout} locale={data.locale} capture={data.capture} src={data.src} mode={data.mode} />\n`
|
|
69
|
+
}),
|
|
70
|
+
svelte: (c) => ({ 'src/emaki-source.ts': viteSourceFile(c) }),
|
|
71
|
+
react: (c) => ({ 'src/emaki-source.ts': viteSourceFile(c) }),
|
|
72
|
+
vue: (c) => ({ 'src/emaki-source.ts': viteSourceFile(c) }),
|
|
73
|
+
next: () => ({
|
|
74
|
+
'app/show/[film]/page.tsx': `'use client';\n// The capture page the video pipeline drives. Films are read at runtime from /public/content (emaki manifest\n// writes content/films/index.json; copy or symlink content/ into public/).\nimport { useEffect, useState } from 'react';\nimport { useSearchParams, useParams } from 'next/navigation';\nimport { setupMotion } from '@senseihq/emaki';\nimport { fetchFilmSource } from '@senseihq/emaki/loaders/fetch';\nimport { ShowPage } from '@senseihq/emaki-react';\n\nexport default function Page() {\n const { film } = useParams<{ film: string }>();\n const q = useSearchParams();\n const [ready, setReady] = useState(false);\n useEffect(() => { setupMotion({ source: fetchFilmSource('/content') }); setReady(true); }, []);\n if (!ready) return null;\n return <ShowPage film={film} capture={q.get('capture') === '1'} layout={q.get('o') === 'portrait' ? 'portrait' : 'landscape'} locale={q.get('locale') ?? 'en'} src={(q.get('src') as 'json' | 'js' | null) ?? undefined} mode={q.get('mode') === 'dark' ? 'dark' : 'light'} />;\n}\n`
|
|
75
|
+
}),
|
|
76
|
+
nuxt: () => ({}),
|
|
77
|
+
vanilla: () => ({
|
|
78
|
+
'motion.ts': `// Plain pages: films are read at runtime from /content (run \`emaki manifest\` after adding films).\nimport { setupMotion, installCapture } from '@senseihq/emaki';\nimport { fetchFilmSource } from '@senseihq/emaki/loaders/fetch';\nimport { defineMotionElements } from '@senseihq/emaki/elements';\n\nsetupMotion({ source: fetchFilmSource('/content') });\ndefineMotionElements(); // <motion-scene film=… scene=…> and <motion-show film=…>\n\n// The capture page: /show.html?film=<slug>&capture=1&o=landscape&locale=en\nconst q = new URLSearchParams(location.search);\nif (q.get('capture') === '1') installCapture(document.getElementById('stage')!, q.get('film')!, q.get('o') === 'portrait' ? 'portrait' : 'landscape', q.get('locale') ?? 'en', { src: (q.get('src') as 'json' | 'js' | null) ?? undefined, mode: q.get('mode') === 'dark' ? 'dark' : 'light' });\n`
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function init({ cwd = process.cwd(), framework, content = 'content', sample = true } = {}) {
|
|
83
|
+
const fw = framework ?? detectFramework(cwd)
|
|
84
|
+
const wrote = [], kept = []
|
|
85
|
+
const write = (rel, text) => {
|
|
86
|
+
const f = join(cwd, rel)
|
|
87
|
+
if (existsSync(f)) return kept.push(rel)
|
|
88
|
+
mkdirSync(dirname(f), { recursive: true })
|
|
89
|
+
writeFileSync(f, text)
|
|
90
|
+
wrote.push(rel)
|
|
91
|
+
}
|
|
92
|
+
if (sample && !existsSync(join(cwd, content))) {
|
|
93
|
+
cpSync(join(TEMPLATES, 'content'), join(cwd, content), { recursive: true })
|
|
94
|
+
wrote.push(`${content}/ (sample film "measure-the-right-work" in en + es)`)
|
|
95
|
+
} else if (existsSync(join(cwd, content))) kept.push(`${content}/`)
|
|
96
|
+
const cfgPath = join(cwd, 'emaki.config.json')
|
|
97
|
+
if (!existsSync(cfgPath)) {
|
|
98
|
+
const cfg = JSON.parse(readFileSync(join(TEMPLATES, 'emaki.config.json'), 'utf-8'))
|
|
99
|
+
cfg.content = content
|
|
100
|
+
if (fw === 'sveltekit') cfg.coversDir = 'static/covers'
|
|
101
|
+
cfg.showPath = fw === 'vanilla' ? '/show.html?film={slug}&capture=1&o={layout}&locale={locale}' : cfg.showPath
|
|
102
|
+
save(cfgPath, cfg)
|
|
103
|
+
wrote.push('emaki.config.json')
|
|
104
|
+
} else kept.push('emaki.config.json')
|
|
105
|
+
for (const [rel, text] of Object.entries(FILES[fw](content))) write(rel, text)
|
|
106
|
+
const gi = join(cwd, '.gitignore')
|
|
107
|
+
const ignore = existsSync(gi) ? readFileSync(gi, 'utf-8') : ''
|
|
108
|
+
if (!/^production\/?$/m.test(ignore)) { writeFileSync(gi, ignore + (ignore && !ignore.endsWith('\n') ? '\n' : '') + '# motion stories: takes, renders, sheets (never deployed)\nproduction/\n'); wrote.push('.gitignore (production/)') }
|
|
109
|
+
return { framework: fw, packages: PACKAGES[fw], wrote, kept }
|
|
110
|
+
}
|