@senseihq/emaki-cli 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +34 -2
- package/package.json +42 -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 +23 -0
- package/plugin/modules/campaign/calendar.csv +2 -0
- package/plugin/modules/campaign/day-script.template.md +41 -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 +65 -0
- package/plugin/skills/emaki/references/04-scene-authoring.md +96 -0
- package/plugin/skills/emaki/references/05-voice-and-video.md +64 -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 +11 -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 +36 -0
- package/plugin/skills/story-publish/SKILL.md +22 -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 +9 -0
- package/src/capture.js +169 -0
- package/src/config.js +32 -0
- package/src/films.js +145 -0
- package/src/index.js +195 -0
- package/src/init.js +109 -0
- package/src/plugin.js +106 -0
- package/src/tts.js +290 -0
- package/src/util.js +59 -0
- package/src/voice.js +216 -0
- package/templates/content/films/index.json +1 -0
- package/templates/content/films/measure-the-right-work/film.json +59 -0
- package/templates/content/films/measure-the-right-work/look.css +16 -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/voice/en.json +7 -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 +16 -0
- package/templates/film/scene-close.json +153 -0
- package/templates/film/scene-template.json +71 -0
- package/templates/film/score.js +12 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Publishing, posting and campaigns
|
|
2
|
+
|
|
3
|
+
- **Site**: prerender every published story per locale; rebuild daily (a scheduled build) so date-gated stories go
|
|
4
|
+
live on their day in the site's time zone. Drafts are visible only in preview/admin.
|
|
5
|
+
- **Posting desk** (`modules/posting-desk/`): private admin with preview, reorder ("make next"), change requests and
|
|
6
|
+
approval bound to a content hash; a scheduled poster publishes approved media to YouTube, Instagram and X. Start
|
|
7
|
+
paused, dry-run, YouTube private.
|
|
8
|
+
- **Campaign** (`modules/campaign/`): a calendar of daily shorts with a day script per day (voice table + channel copy),
|
|
9
|
+
built with the same per-item loop.
|
|
10
|
+
- **Analytics**: per story and locale: views, read depth, player starts, sound-on rate, video completion; feed the
|
|
11
|
+
numbers into the next batch's priorities.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: story-build
|
|
3
|
+
description: >
|
|
4
|
+
This skill should be used when the user asks to "build a story", "build the next item", "make the scenes for
|
|
5
|
+
<topic>", "add a new story", "create the motion for this article", or when the emaki program reaches an
|
|
6
|
+
approved item card. It turns one item card into a story body, a film of JSON scenes, strings, sound and a verified
|
|
7
|
+
contact sheet.
|
|
8
|
+
metadata:
|
|
9
|
+
version: "0.1.0"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Build one story
|
|
13
|
+
|
|
14
|
+
Input: an approved item card (`project/items/<slug>.md`), the style guide (`project/style-guide.md`, if the pilot is
|
|
15
|
+
done), and the plugin's `skills/emaki/references/04-scene-authoring.md`.
|
|
16
|
+
|
|
17
|
+
1. **Scaffold**: `emaki new <slug> --scenes <ids> --title "<title>" --date <publish_date>`. Scene
|
|
18
|
+
ids come from the card; `hook` first, `close` last.
|
|
19
|
+
2. **Story body** (default locale): title, dek, one section per idea scene (same ids), points where the card lists
|
|
20
|
+
steps, captions for figures, takeaway = punchline, takeawaySub = the close sub, sources. Plain, direct sentences.
|
|
21
|
+
3. **film.json**: `look` (copy the site's), scene `name`, `dur` (voice words ÷ 2.5 + 2 s, at least 6 s; close 5.5),
|
|
22
|
+
`desc` (one sentence each: what the scene shows).
|
|
23
|
+
4. **Scenes**: for each, write `scene-<id>.json`: board; head (`{{id.eyebrow}}`, `{{id.line}}`, `{{id.sub}}`); the
|
|
24
|
+
artwork from components; tracks timed to the voice line (the head from −0.4 s; each element when the voice names
|
|
25
|
+
it); scene CSS prefixed with the id; the portrait block. Start from the pilot's or the starter's scenes; reuse
|
|
26
|
+
their CSS and patterns. Put every visible word in `strings/<locale>.json`.
|
|
27
|
+
5. **Close**: copy the starter's close scene; set `close.title` (the punchline) and `close.sub`.
|
|
28
|
+
6. **Sound**: `score.js` with a note on each beat and the closing chord; no bed.
|
|
29
|
+
7. **Voice script**: `voice/<locale>.json`, one line per scene, ≤ the scene's speakable time; `say` for hard words.
|
|
30
|
+
8. **Check**: `emaki validate <slug>` must pass; `emaki sheet <slug>` and Read the
|
|
31
|
+
sheet image. Fix overlaps, clipping, misaligned connectors, uneven sizes, crowded edges, missing portrait fit,
|
|
32
|
+
then re-sheet. Check a mid-animation frame for each key beat with `--at`.
|
|
33
|
+
9. **Page**: open the article page (dev server) and screenshot desktop and mobile.
|
|
34
|
+
10. **Report**: the sheet, the page screenshots, one line per scene on what it shows, and anything you assumed. Update
|
|
35
|
+
`project/tracker.md`.
|
|
36
|
+
|
|
37
|
+
Large batches: dispatch the `scene-builder` agent per story with steps 3–8 and the card; do 1–2 and 9–10 yourself.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: story-localize
|
|
3
|
+
description: >
|
|
4
|
+
This skill should be used when the user asks to "translate the stories", "add Spanish", "localise this story",
|
|
5
|
+
"add a language", or "check the French version". It produces a locale's story bodies, scene strings, voice scripts
|
|
6
|
+
and UI strings, validates every key, and verifies the layout in that language.
|
|
7
|
+
metadata:
|
|
8
|
+
version: "0.1.0"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Add or update a locale
|
|
12
|
+
|
|
13
|
+
1. Confirm the locale code (BCP 47) is in `content/site.json` `locales` (add it, plus `rtl` if needed) and that the
|
|
14
|
+
fonts cover its script.
|
|
15
|
+
2. For each story approved in the default locale, dispatch the `localizer` agent with: the default-locale story body,
|
|
16
|
+
`strings/<default>.json`, `voice/<default>.json`, the style guide's wording rules, and any glossary
|
|
17
|
+
(`project/glossary.md`). It writes `stories/<locale>/<slug>.json`, `strings/<locale>.json`, `voice/<locale>.json`
|
|
18
|
+
with identical keys and scene order, adapting idioms and examples, keeping punchlines short.
|
|
19
|
+
3. UI strings: `content/ui/<locale>.json` with the same keys as the default.
|
|
20
|
+
4. `emaki validate` (no missing or unused keys), then `emaki sheet <slug> --locale <locale>`; Read it. Fix
|
|
21
|
+
overflow with wrapping or a `locales.<code>.css` block in the scene, not by shortening the meaning.
|
|
22
|
+
5. RTL locales: check the page direction, the head placement, and any directional art (arrows, timelines).
|
|
23
|
+
6. List what needs a native reviewer (legal or regulated wording always does) and record the review status per story
|
|
24
|
+
in `project/tracker.md`. Media for the locale follows with `story-media`.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: story-media
|
|
3
|
+
description: >
|
|
4
|
+
This skill should be used when the user asks to "record the voiceover", "choose a voice", "set up text to speech", "render the video", "make the Short",
|
|
5
|
+
"build the videos", "fit the timing to the voice", or "make the covers" for a story. It runs voice, fit, render and
|
|
6
|
+
build per locale and checks the delivery list.
|
|
7
|
+
metadata:
|
|
8
|
+
version: "0.1.0"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Voice, timing, video
|
|
12
|
+
|
|
13
|
+
Prerequisites: ffmpeg, Playwright with Chromium (`npm i -D playwright`), the dev server command in `emaki.config.json`, and a voice
|
|
14
|
+
provider per locale (the `emaki` CLI's TTS providers). Never ask for, print or store a key: providers read them from the environment.
|
|
15
|
+
|
|
16
|
+
0. **Voice provider.** Run `emaki tts-check`. For each locale without a provider, ask the user with
|
|
17
|
+
AskUserQuestion (one question, these options, recommended first): *Your organisation's cloud platform: Azure,
|
|
18
|
+
Google Cloud or AWS Polly (Recommended when they have one)*, *Piper: free, offline, private (Recommended
|
|
19
|
+
otherwise)*, *Kokoro: free, offline, most natural (heavier install)*, *ElevenLabs or OpenAI (premium)*, plus
|
|
20
|
+
*Recorded by a person* via the free-text option. Then: install what it needs (pip, a Piper voice file for the
|
|
21
|
+
language), list voices (`emaki voices --locale <l> --provider <p>`), let the user pick or recommend one, save it
|
|
22
|
+
with `emaki set-voice --locale <l> --provider <p> --opt voice=…` (or `--opt model=…` for Piper), and make one
|
|
23
|
+
short sample take for approval before voicing a whole story. A provider that is "not ready" because of a missing key:
|
|
24
|
+
tell the user which environment variable to set and stop; do not continue with a different provider silently.
|
|
25
|
+
Draft timing passes may use `--provider macos` or `espeak`; never publish those takes.
|
|
26
|
+
1. Review `voice/<locale>.json` against the scenes: one line each, spoken length fits, `say` spellings for names.
|
|
27
|
+
2. `emaki voice <slug> --locale <l>` (or `--only 3,5` to redo takes; `--provider manual` prints the
|
|
28
|
+
recording list for a person). Report each take's length; for manual takes, wait for the files.
|
|
29
|
+
3. `emaki fit <slug> --locale <l>`; read the table. If a beat must land on a word, retime the
|
|
30
|
+
scene's tracks (and `score.js`) or add a hold in `timing.<l>.json`, then fit again.
|
|
31
|
+
4. `emaki render <slug> --locale <l> --o both` (picture + score + covers; the 16:9 cover goes to the
|
|
32
|
+
site's covers folder).
|
|
33
|
+
5. `emaki build <slug> --locale <l>` (voice, ducked score, -14 LUFS, captions).
|
|
34
|
+
6. Check the delivery list in `skills/emaki/references/05-voice-and-video.md`: extract frames at the start,
|
|
35
|
+
each scene change and the end with ffmpeg and look at them; confirm durations and captions.
|
|
36
|
+
7. Report the files (paths under `production/<slug>/<l>/out/`), durations, and anything to re-record.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: story-publish
|
|
3
|
+
description: >
|
|
4
|
+
This skill should be used when the user asks to "publish", "release the site", "set up posting", "schedule the
|
|
5
|
+
stories", "set up the posting desk", "plan a campaign", or "post the videos". It runs the release checklist, deploys,
|
|
6
|
+
and sets up the optional posting desk and daily campaign modules.
|
|
7
|
+
metadata:
|
|
8
|
+
version: "0.1.0"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Release and distribution
|
|
12
|
+
|
|
13
|
+
1. **Release checklist** (`skills/emaki/references/07-quality-gates.md`, Gate E): build, prerender per
|
|
14
|
+
locale, hreflang, sitemap, og images, accessibility, performance. Fix before deploying.
|
|
15
|
+
2. **Daily rebuild**: a scheduled build so date-gated stories publish on their day in the site's time zone.
|
|
16
|
+
3. **Posting desk** (only if in scope): follow `modules/posting-desk/README.md`. Ask which identity proxy, database,
|
|
17
|
+
object storage and scheduler the organisation uses; port the reference logic; set it up paused, dry-run,
|
|
18
|
+
YouTube private; test the approval-voids-on-change path; go live one channel at a time with the owner.
|
|
19
|
+
4. **Campaign** (only if in scope): follow `modules/campaign/README.md`: plan the calendar with the owner, write day
|
|
20
|
+
scripts in batches for approval, build each day's story with `story-build` (shorts) and `story-media`, stage for
|
|
21
|
+
approval.
|
|
22
|
+
5. Record what was released in `project/changelog.md` and hand over the runbook (how to add a story, approve, post).
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: story-review
|
|
3
|
+
description: >
|
|
4
|
+
This skill should be used when the user gives feedback on a story ("scene 2 the cards overlap", "make the title
|
|
5
|
+
shorter", "the arrow is off"), asks to "review the stories", "inspect the batch", "check the scenes", or attaches a
|
|
6
|
+
filled review sheet. It inspects stories against the quality gates, turns feedback into change requests, applies
|
|
7
|
+
them in the data, and shows before/after evidence.
|
|
8
|
+
metadata:
|
|
9
|
+
version: "0.1.0"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Inspect, correct, show
|
|
13
|
+
|
|
14
|
+
1. **Collect**: turn each piece of feedback into a change request (story, scene, locale, orientation, time, problem,
|
|
15
|
+
wanted, severity) in `project/reviews/<slug>.md`. Restate a request in one line only when it could be fixed two
|
|
16
|
+
different ways; otherwise proceed.
|
|
17
|
+
2. **Locate**: map the scene name the reviewer used to its id (film.json `name`), and find the component(s). When
|
|
18
|
+
geometry is involved, measure: open the capture page with Playwright and read element boxes (getBoundingClientRect
|
|
19
|
+
relative to the stage) rather than guessing coordinates.
|
|
20
|
+
3. **Fix in the data**: scene JSON (positions, sizes, tracks, CSS), strings, story body. Keep shared rules shared: if
|
|
21
|
+
a fix is a rule (centre connectors on edges; equal card sizes; more space under column headers), apply it to
|
|
22
|
+
similar scenes and add it to `project/style-guide.md`.
|
|
23
|
+
4. **Verify**: `emaki validate`, then `emaki sheet <slug> --at <scene>:<t>` for the affected scenes, in each
|
|
24
|
+
affected locale and both orientations. Read the image; if it is not right, fix again before replying.
|
|
25
|
+
5. **Reply** per request: the after frame (and the before frame when useful), one line on what changed, and any
|
|
26
|
+
knock-on work (a voice take to re-record, a render to redo). Mark requests done in the review file and the tracker.
|
|
27
|
+
6. For an inspection without feedback: run the per-scene checklist in
|
|
28
|
+
`skills/emaki/references/07-quality-gates.md` over every scene's sheet, plus the `visual-reviewer` agent,
|
|
29
|
+
and report findings ranked by severity before fixing.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Project brief
|
|
2
|
+
|
|
3
|
+
**Site:** <name> · <url> · owner: <name, role> · start: <date>
|
|
4
|
+
|
|
5
|
+
## Purpose and audience
|
|
6
|
+
- Purpose: <learning portal / awareness or alert site / product explainers / onboarding>
|
|
7
|
+
- Readers: <who>, on <devices>, arriving from <email / LMS / social / search>
|
|
8
|
+
- Success looks like: <measurable outcome>
|
|
9
|
+
|
|
10
|
+
## Languages
|
|
11
|
+
- Launch: <en, es> · later: <…> · default: <en> · right-to-left: <none>
|
|
12
|
+
- Translation: <Claude drafts, native reviewer approves: name> · voice localised: <yes/no>
|
|
13
|
+
|
|
14
|
+
## Stack and hosting
|
|
15
|
+
- Framework: <React/Next · Svelte/SvelteKit · Vue/Nuxt · Astro> · hosting: <…> · repo: <…>
|
|
16
|
+
|
|
17
|
+
## Media scope
|
|
18
|
+
- Stories: <films 60–90 s / shorts 30–60 s / articles only> · video: <16:9, 9:16>
|
|
19
|
+
- Voice: provider <piper / kokoro / azure / google / polly / openai / elevenlabs / recorded> · voice per locale: <en: …, es: …> · sample approved: <date>
|
|
20
|
+
- Posting desk: <yes/no> · campaign: <yes/no>
|
|
21
|
+
|
|
22
|
+
## Brand and tone
|
|
23
|
+
- Logo: <file> · colours: <…> · fonts: <…> · references: <…>
|
|
24
|
+
- Tone: <plain, direct, …> · reading level: <…> · words/claims to avoid: <…>
|
|
25
|
+
|
|
26
|
+
## Roles
|
|
27
|
+
| Role | Person | Approves |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| Owner | | outline, item cards, look, pilot, each story |
|
|
30
|
+
| Subject expert | | facts |
|
|
31
|
+
| Language reviewer (per locale) | | translations |
|
|
32
|
+
| Legal / compliance | | regulated wording |
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Change request <slug>-<n>
|
|
2
|
+
|
|
3
|
+
- **Where:** scene <id or name> · locale <xx> · orientation <16:9 / 9:16 / figure / page> · time <s or final frame>
|
|
4
|
+
- **Problem:** <what is wrong, as seen>
|
|
5
|
+
- **Wanted:** <what it should be>
|
|
6
|
+
- **Severity:** blocker | should | nice
|
|
7
|
+
- **Status:** open → fixed (by <who>, <date>; before/after: <paths>) → verified
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Item card · <slug>
|
|
2
|
+
|
|
3
|
+
**Title:** <working title> · **Format:** film | short | article · **Topic:** <> · **Publish:** <YYYY-MM-DD>
|
|
4
|
+
**Owner/SME:** <> · **Status:** draft | approved
|
|
5
|
+
|
|
6
|
+
## Audience and objective
|
|
7
|
+
- Audience: <who, what they already know>
|
|
8
|
+
- After this, they will: <know / feel / do, one sentence>
|
|
9
|
+
|
|
10
|
+
## The one message
|
|
11
|
+
<≤ 20 words>
|
|
12
|
+
|
|
13
|
+
## Punchline (closing card, cover, takeaway, last voice line)
|
|
14
|
+
<3–9 words> · sub: <one line>
|
|
15
|
+
|
|
16
|
+
## Scenes
|
|
17
|
+
| # | id | The point (one line) | The picture | Article section | Voice line (draft) |
|
|
18
|
+
|---|---|---|---|---|---|
|
|
19
|
+
| 1 | hook | | | intro | |
|
|
20
|
+
| … | | | | | |
|
|
21
|
+
| n | close | punchline | title + bar + sub, mark right | takeaway | |
|
|
22
|
+
|
|
23
|
+
## Facts and sources
|
|
24
|
+
| Claim | Source (doc, section, URL) | Verified |
|
|
25
|
+
|---|---|---|
|
|
26
|
+
|
|
27
|
+
## Call to action and links
|
|
28
|
+
<what the reader should do next>
|
|
29
|
+
|
|
30
|
+
## Must not say / sensitivities
|
|
31
|
+
<legal wording, claims to avoid>
|
|
32
|
+
|
|
33
|
+
## Open questions
|
|
34
|
+
- <…>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Outline
|
|
2
|
+
|
|
3
|
+
## Site map
|
|
4
|
+
- `/<locale>/` home: featured stories, topics
|
|
5
|
+
- `/<locale>/stories` index: filter by topic, search
|
|
6
|
+
- `/<locale>/stories/<slug>` story: header, film player, sections with figures, takeaway, sources, related
|
|
7
|
+
- `/show/<slug>` story player (and the video capture route)
|
|
8
|
+
- <other pages>
|
|
9
|
+
|
|
10
|
+
## Catalogue
|
|
11
|
+
| # | Slug | Working title | Format | Topic | Priority | Target date | Sources | SME | Status |
|
|
12
|
+
|---|---|---|---|---|---|---|---|---|---|
|
|
13
|
+
| 1 | | | film | | pilot | | | | outline |
|
|
14
|
+
|
|
15
|
+
Status: outline → card drafted → card approved → built → reviewed → approved → localised → media → published.
|
|
16
|
+
|
|
17
|
+
## Order of work
|
|
18
|
+
- **Pilot:** <slug> (why: exercises <cards, a chart, a flow, a list, the close>)
|
|
19
|
+
- **Batch 1:** <slugs> · **Batch 2:** <slugs> · …
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Review · <slug> · round <n>
|
|
2
|
+
|
|
3
|
+
Sheet: <path or link> · Page: <url> · Player: <url> · Video: <path>
|
|
4
|
+
|
|
5
|
+
| Scene | Locale | Orientation | Content | Look | Motion | Text | Notes / change request # |
|
|
6
|
+
|---|---|---|---|---|---|---|---|
|
|
7
|
+
| hook | en | 16:9 | ✓ | ✓ | ✓ | ✓ | |
|
|
8
|
+
| hook | en | 9:16 | | | | | |
|
|
9
|
+
|
|
10
|
+
Article: ✓ / changes · Takeaway: ✓ / changes · Sources: ✓ / changes
|
|
11
|
+
|
|
12
|
+
Decision: approved | changes requested · Reviewer: <name> · Date: <>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Style guide (settled on the pilot; every story follows it)
|
|
2
|
+
|
|
3
|
+
## Look
|
|
4
|
+
- Board, palette, fonts, the accent's use (what matters), the success colour (what's right).
|
|
5
|
+
- Card style, tag style, connector style, chart style.
|
|
6
|
+
|
|
7
|
+
## Layout rules
|
|
8
|
+
- Words left (x 110, w ≈ 700); art right (x 880–1820, y 150–830); 40 px margins.
|
|
9
|
+
- Connectors end on edge centres; repeated cards one size; even spacing; column headers ≥ 40 px above items.
|
|
10
|
+
|
|
11
|
+
## Motion grammar
|
|
12
|
+
- Head arrives at −0.4 s; art builds in the order the voice names it; holds ≥ 1.5 s; camera push 1.00→1.02.
|
|
13
|
+
|
|
14
|
+
## Words
|
|
15
|
+
- Headlines ≤ 9 words; subs ≤ 20; punchlines 3–9; plain, direct, no hype; glossary terms.
|
|
16
|
+
|
|
17
|
+
## Sound
|
|
18
|
+
- Action tones only; a note per beat; the closing chord.
|
|
19
|
+
|
|
20
|
+
## Rules added from reviews
|
|
21
|
+
- <date> <rule> (from change request <id>)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Tracker
|
|
2
|
+
|
|
3
|
+
| Gate | Status | Date | Evidence |
|
|
4
|
+
|---|---|---|---|
|
|
5
|
+
| A · outline approved | | | |
|
|
6
|
+
| B · theme verified | | | |
|
|
7
|
+
| C · pilot approved | | | |
|
|
8
|
+
| E · release | | | |
|
|
9
|
+
|
|
10
|
+
| Slug | Card | Built | Reviewed | Approved | Locales | Media | Published |
|
|
11
|
+
|---|---|---|---|---|---|---|---|
|
package/src/api.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// The same steps as the CLI, as functions (for scripts and CI): project() reads emaki.config.json and content/.
|
|
2
|
+
export { project, SIZES, SUFFIX } from './config.js'
|
|
3
|
+
export { manifest, validate, validateFilm, validateStory, newFilm, keysIn } from './films.js'
|
|
4
|
+
export { voice, fit, build, captions, ttsCheck, setVoice, listVoices, takesFor } from './voice.js'
|
|
5
|
+
export { sheet, render, openSite } from './capture.js'
|
|
6
|
+
export { PROVIDERS, OFFLINE, provider, voiceConfig, TTSError } from './tts.js'
|
|
7
|
+
export { installPlugin, installSkills, installAgents, listSkills, listAgents, parseFrontmatter } from './plugin.js'
|
|
8
|
+
export { init, detectFramework } from './init.js'
|
|
9
|
+
export { MotionError } from './util.js'
|
package/src/capture.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// sheet and render drive the site's capture page in headless Chromium: /show/<slug>?capture=1 installs
|
|
2
|
+
// window.__show = { meta, ready, seek(t), audio() } (installCapture in @senseihq/emaki; ShowPage in each wrapper).
|
|
3
|
+
// Playwright is an optional dependency: `npm i -D playwright && npx playwright install chromium`.
|
|
4
|
+
import { spawn } from 'node:child_process'
|
|
5
|
+
import { mkdirSync, renameSync, writeFileSync, readFileSync } from 'node:fs'
|
|
6
|
+
import { connect } from 'node:net'
|
|
7
|
+
import { join } from 'node:path'
|
|
8
|
+
import { SIZES, SUFFIX } from './config.js'
|
|
9
|
+
import { die, run } from './util.js'
|
|
10
|
+
|
|
11
|
+
async function chromium() {
|
|
12
|
+
try {
|
|
13
|
+
return (await import('playwright')).chromium
|
|
14
|
+
} catch {
|
|
15
|
+
return die('sheet and render need Playwright: npm i -D playwright && npx playwright install chromium')
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const portOpen = (port) => new Promise((ok) => {
|
|
20
|
+
const s = connect({ port, host: '127.0.0.1' })
|
|
21
|
+
s.setTimeout(500)
|
|
22
|
+
s.once('connect', () => { s.destroy(); ok(true) })
|
|
23
|
+
s.once('error', () => ok(false))
|
|
24
|
+
s.once('timeout', () => { s.destroy(); ok(false) })
|
|
25
|
+
})
|
|
26
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms))
|
|
27
|
+
|
|
28
|
+
/** The site to capture: `url` if given (must answer), else the dev server (emaki.config.json devCommand), started if
|
|
29
|
+
* nothing listens on the port yet and stopped afterwards. */
|
|
30
|
+
export async function openSite(p, url) {
|
|
31
|
+
const port = p.cfg.port ?? 5199
|
|
32
|
+
let proc = null
|
|
33
|
+
const base = (url ?? `http://localhost:${port}`).replace(/\/$/, '')
|
|
34
|
+
if (url) {
|
|
35
|
+
try {
|
|
36
|
+
await fetch(url, { signal: AbortSignal.timeout(10000) })
|
|
37
|
+
} catch (e) {
|
|
38
|
+
die(`the site at ${url} is not responding (${e.message}); start it, or leave out --url to let emaki start it`)
|
|
39
|
+
}
|
|
40
|
+
} else if (!(await portOpen(port))) {
|
|
41
|
+
const cmd = (p.cfg.devCommand ?? 'npm run dev -- --port {port} --strictPort').replaceAll('{port}', String(port))
|
|
42
|
+
proc = spawn(cmd, { shell: true, cwd: p.root, stdio: 'ignore', detached: process.platform !== 'win32' })
|
|
43
|
+
let up = false
|
|
44
|
+
for (let i = 0; i < 120 && !(up = await portOpen(port)); i++) await sleep(500)
|
|
45
|
+
if (!up) { stop(); die(`the dev server did not start (${cmd})`) }
|
|
46
|
+
}
|
|
47
|
+
function stop() {
|
|
48
|
+
if (!proc) return
|
|
49
|
+
try { process.kill(-proc.pid) } catch { proc.kill() }
|
|
50
|
+
}
|
|
51
|
+
const showPath = p.cfg.showPath ?? '/show/{slug}?capture=1&o={layout}&locale={locale}'
|
|
52
|
+
return {
|
|
53
|
+
base,
|
|
54
|
+
show: (slug, layout, locale) => base + showPath.replaceAll('{slug}', slug).replaceAll('{layout}', layout).replaceAll('{locale}', locale),
|
|
55
|
+
close: stop
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function openShow(browser, site, slug, layout, locale) {
|
|
60
|
+
const [width, height] = SIZES[layout]
|
|
61
|
+
const page = await browser.newPage({ viewport: { width, height }, deviceScaleFactor: 1 })
|
|
62
|
+
const errors = []
|
|
63
|
+
page.on('pageerror', (e) => errors.push(String(e)))
|
|
64
|
+
await page.goto(site.show(slug, layout, locale))
|
|
65
|
+
await page.waitForFunction(() => window.__show, null, { timeout: 30000 })
|
|
66
|
+
await page.evaluate(() => window.__show.ready)
|
|
67
|
+
return { page, meta: await page.evaluate(() => window.__show.meta), errors }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** A contact sheet: each scene's final picture (or --at scene:t,...) in both orientations, side by side. */
|
|
71
|
+
export async function sheet(p, slug, { locale, url, at, log = console.info } = {}) {
|
|
72
|
+
p.filmDir(slug)
|
|
73
|
+
const out = p.prod(slug, locale, 'sheets')
|
|
74
|
+
mkdirSync(out, { recursive: true })
|
|
75
|
+
const site = await openSite(p, url), shots = []
|
|
76
|
+
const browser = await (await chromium()).launch()
|
|
77
|
+
try {
|
|
78
|
+
for (const layout of ['landscape', 'portrait']) {
|
|
79
|
+
const { page, meta, errors } = await openShow(browser, site, slug, layout, locale)
|
|
80
|
+
const starts = Object.fromEntries(meta.scenes.map((s) => [s.id, [s.start, s.dur]]))
|
|
81
|
+
const pts = at
|
|
82
|
+
? String(at).split(',').map((x) => { const [sid, t] = x.split(':'); return [sid, parseFloat(t)] })
|
|
83
|
+
: Object.entries(starts).map(([sid, [, d]]) => [sid, d - 0.4])
|
|
84
|
+
for (const [i, [sid, t]] of pts.entries()) {
|
|
85
|
+
if (!starts[sid]) die(`no scene "${sid}"`)
|
|
86
|
+
await page.evaluate((x) => window.__show.seek(x), starts[sid][0] + t)
|
|
87
|
+
await page.waitForTimeout(80)
|
|
88
|
+
const f = join(out, `${layout}-${String(i).padStart(2, '0')}-${sid}.jpg`)
|
|
89
|
+
writeFileSync(f, await page.screenshot({ type: 'jpeg', quality: 82 }))
|
|
90
|
+
shots.push({ layout, i, f, sid })
|
|
91
|
+
}
|
|
92
|
+
if (errors.length) log('page errors: ' + errors.slice(0, 3).join(' | '))
|
|
93
|
+
await page.close()
|
|
94
|
+
}
|
|
95
|
+
// Compose in the browser: landscape 960x540 with its portrait 304x540 beside it, three per row.
|
|
96
|
+
const n = shots.filter((s) => s.layout === 'landscape').length, cols = Math.min(3, n), rows = Math.ceil(n / cols)
|
|
97
|
+
const img = (s) => `data:image/jpeg;base64,${readFileSync(s.f).toString('base64')}`
|
|
98
|
+
const cells = shots.map((s) => {
|
|
99
|
+
const r = Math.floor(s.i / cols), c = s.i % cols
|
|
100
|
+
const [x, w] = s.layout === 'landscape' ? [c * 1290, 960] : [c * 1290 + 966, 304]
|
|
101
|
+
return `<img src="${img(s)}" style="position:absolute;left:${x}px;top:${r * 550}px;width:${w}px;height:540px">`
|
|
102
|
+
}).join('')
|
|
103
|
+
const page = await browser.newPage({ viewport: { width: cols * 1290, height: rows * 550 } })
|
|
104
|
+
await page.setContent(`<body style="margin:0;background:#fff;position:relative">${cells}</body>`)
|
|
105
|
+
await page.waitForFunction(() => [...document.images].every((i) => i.complete))
|
|
106
|
+
const dst = join(out, `${slug}-${locale}-sheet.jpg`)
|
|
107
|
+
writeFileSync(dst, await page.screenshot({ type: 'jpeg', quality: 85, fullPage: true }))
|
|
108
|
+
log(`sheet: ${p.rel(dst)}`)
|
|
109
|
+
return dst
|
|
110
|
+
} finally {
|
|
111
|
+
await browser.close()
|
|
112
|
+
site.close()
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Frame-by-frame capture to MP4 (the score as its audio), plus a cover JPEG per orientation. */
|
|
117
|
+
export async function render(p, slug, { locale, url, o = 'both', fps = 30, log = console.info } = {}) {
|
|
118
|
+
p.filmDir(slug)
|
|
119
|
+
const layouts = o === 'both' ? ['landscape', 'portrait'] : [o]
|
|
120
|
+
const out = p.prod(slug, locale, 'render')
|
|
121
|
+
mkdirSync(out, { recursive: true })
|
|
122
|
+
const site = await openSite(p, url), made = []
|
|
123
|
+
const browser = await (await chromium()).launch()
|
|
124
|
+
try {
|
|
125
|
+
let score
|
|
126
|
+
for (const layout of layouts) {
|
|
127
|
+
const { page, meta, errors } = await openShow(browser, site, slug, layout, locale)
|
|
128
|
+
if (score === undefined) {
|
|
129
|
+
const b64 = await page.evaluate(() => window.__show.audio())
|
|
130
|
+
score = b64 ? join(out, 'score.wav') : null
|
|
131
|
+
if (b64) writeFileSync(score, Buffer.from(b64, 'base64'))
|
|
132
|
+
}
|
|
133
|
+
const frames = Math.round(meta.duration * fps)
|
|
134
|
+
const dst = join(out, `${slug}-${locale}-${SUFFIX[layout]}.mp4`), tmp = dst.replace(/\.mp4$/, '.part.mp4')
|
|
135
|
+
const ff = spawn('ffmpeg', ['-y', '-loglevel', 'error', '-f', 'image2pipe', '-framerate', String(fps), '-c:v', 'mjpeg', '-i', '-',
|
|
136
|
+
...(score ? ['-i', score] : []), '-c:v', 'libx264', '-preset', 'medium', '-crf', '18', '-pix_fmt', 'yuv420p',
|
|
137
|
+
...(score ? ['-c:a', 'aac', '-b:a', '192k'] : []), '-t', (frames / fps).toFixed(3), '-movflags', '+faststart', tmp],
|
|
138
|
+
{ stdio: ['pipe', 'inherit', 'inherit'] })
|
|
139
|
+
const done = new Promise((ok, bad) => { ff.on('close', (c) => (c ? bad(new Error('ffmpeg failed')) : ok())); ff.on('error', bad) })
|
|
140
|
+
const t0 = Date.now()
|
|
141
|
+
for (let i = 0; i < frames; i++) {
|
|
142
|
+
await page.evaluate((t) => window.__show.seek(t), i / fps)
|
|
143
|
+
const jpg = await page.screenshot({ type: 'jpeg', quality: 94 })
|
|
144
|
+
if (!ff.stdin.write(jpg)) await new Promise((r) => ff.stdin.once('drain', r))
|
|
145
|
+
if (i % (fps * 10) === 0) log(` ${layout} ${(i / fps).toFixed(1).padStart(6)}s / ${meta.duration.toFixed(1)}s`)
|
|
146
|
+
}
|
|
147
|
+
ff.stdin.end()
|
|
148
|
+
await done.catch((e) => die(e.message))
|
|
149
|
+
if (errors.length) die('the page reported errors: ' + errors.slice(0, 3).join('; '))
|
|
150
|
+
renameSync(tmp, dst)
|
|
151
|
+
await page.evaluate((t) => window.__show.seek(t), meta.cover)
|
|
152
|
+
const cover = join(out, `${slug}-${locale}-cover-${SUFFIX[layout]}.jpg`)
|
|
153
|
+
writeFileSync(cover, await page.screenshot({ type: 'jpeg', quality: 92 }))
|
|
154
|
+
log(` wrote ${p.rel(dst)} (${frames} frames, ${Math.round((Date.now() - t0) / 1000)}s) and ${p.rel(cover)}`)
|
|
155
|
+
if (layout === 'landscape' && p.cfg.coversDir) {
|
|
156
|
+
const siteCover = join(p.root, p.cfg.coversDir, locale === p.site.defaultLocale ? `${slug}.jpg` : `${slug}.${locale}.jpg`)
|
|
157
|
+
mkdirSync(join(siteCover, '..'), { recursive: true })
|
|
158
|
+
run('ffmpeg', ['-y', '-loglevel', 'error', '-i', cover, '-vf', 'scale=1600:-2', '-q:v', '3', siteCover])
|
|
159
|
+
log(` cover for the site: ${p.rel(siteCover)}`)
|
|
160
|
+
}
|
|
161
|
+
made.push(dst)
|
|
162
|
+
await page.close()
|
|
163
|
+
}
|
|
164
|
+
return made
|
|
165
|
+
} finally {
|
|
166
|
+
await browser.close()
|
|
167
|
+
site.close()
|
|
168
|
+
}
|
|
169
|
+
}
|
package/src/config.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// The project a command runs in: emaki.config.json at its root (all optional), content/ (deployed: films, stories,
|
|
2
|
+
// site.json) and production/ (never deployed: takes, renders, sheets).
|
|
3
|
+
import { join, relative } from 'node:path'
|
|
4
|
+
import { die, exists, load } from './util.js'
|
|
5
|
+
|
|
6
|
+
export const SIZES = { landscape: [1920, 1080], portrait: [1080, 1920] }
|
|
7
|
+
export const SUFFIX = { landscape: '16x9', portrait: '9x16' }
|
|
8
|
+
export const KEY = /\{\{\s*([\w.-]+)\s*\}\}/g
|
|
9
|
+
|
|
10
|
+
/** @param {string} [root] */
|
|
11
|
+
export function project(root = process.cwd()) {
|
|
12
|
+
const cfgPath = join(root, 'emaki.config.json')
|
|
13
|
+
const cfg = exists(cfgPath) ? load(cfgPath) : {}
|
|
14
|
+
const content = join(root, cfg.content ?? 'content')
|
|
15
|
+
const production = join(root, cfg.production ?? 'production')
|
|
16
|
+
const films = join(content, 'films')
|
|
17
|
+
const sitePath = join(content, 'site.json')
|
|
18
|
+
const site = exists(sitePath) ? load(sitePath) : { locales: ['en'], defaultLocale: 'en' }
|
|
19
|
+
const p = {
|
|
20
|
+
root, cfg, cfgPath, content, production, films, site,
|
|
21
|
+
lead: cfg.lead ?? 0.6,
|
|
22
|
+
tail: cfg.tail ?? 1.2,
|
|
23
|
+
rel: (x) => relative(root, x) || '.',
|
|
24
|
+
filmDir(slug) {
|
|
25
|
+
const d = join(films, slug)
|
|
26
|
+
if (!exists(join(d, 'film.json'))) die(`no film "${slug}" in ${p.rel(films)}/`)
|
|
27
|
+
return d
|
|
28
|
+
},
|
|
29
|
+
prod: (slug, locale, ...parts) => join(production, slug, locale, ...parts)
|
|
30
|
+
}
|
|
31
|
+
return p
|
|
32
|
+
}
|