mografy 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +16 -9
  2. package/lib/node_modules/@mografy/cli/bin/locate.mjs +2 -22
  3. package/lib/node_modules/@mografy/cli/dist/add.d.ts +0 -1
  4. package/lib/node_modules/@mografy/cli/dist/add.js +6 -24
  5. package/lib/node_modules/@mografy/cli/dist/commands/help.js +5 -2
  6. package/lib/node_modules/@mografy/cli/dist/examples.js +4 -4
  7. package/lib/node_modules/@mografy/cli/dist/index.js +70 -16
  8. package/lib/node_modules/@mografy/cli/dist/mcp/hosts.d.ts +1 -1
  9. package/lib/node_modules/@mografy/cli/dist/mcp/hosts.js +6 -3
  10. package/lib/node_modules/@mografy/cli/dist/paths.d.ts +4 -3
  11. package/lib/node_modules/@mografy/cli/dist/paths.js +6 -5
  12. package/lib/node_modules/@mografy/cli/dist/project-args.d.ts +4 -3
  13. package/lib/node_modules/@mografy/cli/dist/project-args.js +7 -4
  14. package/lib/node_modules/@mografy/cli/dist/project-install.d.ts +44 -0
  15. package/lib/node_modules/@mografy/cli/dist/project-install.js +208 -0
  16. package/lib/node_modules/@mografy/cli/dist/showcase.js +4 -4
  17. package/lib/node_modules/@mografy/cli/dist/skill-hint.js +4 -2
  18. package/lib/node_modules/@mografy/cli/dist/templates.d.ts +1 -1
  19. package/lib/node_modules/@mografy/cli/dist/templates.js +17 -5
  20. package/lib/node_modules/@mografy/cli/package.json +1 -1
  21. package/lib/node_modules/@mografy/core/dist/guide.d.ts +12 -12
  22. package/lib/node_modules/@mografy/core/dist/guide.js +3 -3
  23. package/lib/node_modules/@mografy/core/dist/protocol.d.ts +6 -0
  24. package/lib/node_modules/@mografy/core/dist/skill-text.d.ts +22 -22
  25. package/lib/node_modules/@mografy/core/dist/skill-text.js +22 -22
  26. package/lib/node_modules/@mografy/core/package.json +1 -1
  27. package/lib/node_modules/@mografy/render/dist/ffmpeg.d.ts +1 -1
  28. package/lib/node_modules/@mografy/render/dist/ffmpeg.js +3 -2
  29. package/lib/node_modules/@mografy/render/package.json +1 -1
  30. package/lib/node_modules/@mografy/runtime/package.json +1 -1
  31. package/lib/node_modules/@mografy/server/dist/index.d.ts +1 -0
  32. package/lib/node_modules/@mografy/server/dist/index.js +1 -0
  33. package/lib/node_modules/@mografy/server/dist/installation.d.ts +31 -2
  34. package/lib/node_modules/@mografy/server/dist/installation.js +75 -5
  35. package/lib/node_modules/@mografy/server/dist/project.d.ts +5 -0
  36. package/lib/node_modules/@mografy/server/dist/project.js +2 -2
  37. package/lib/node_modules/@mografy/server/dist/workspace.d.ts +5 -0
  38. package/lib/node_modules/@mografy/server/dist/workspace.js +20 -6
  39. package/lib/node_modules/@mografy/server/package.json +1 -1
  40. package/lib/node_modules/@mografy/web/dist/app.css +1 -1
  41. package/lib/node_modules/@mografy/web/dist/app.js +26 -14
  42. package/lib/node_modules/@mografy/web/package.json +1 -1
  43. package/package.json +2 -1
  44. package/templates/README.md +35 -0
  45. package/templates/ai-chat-stream-wide.ts +132 -0
  46. package/templates/ai-chat-stream.ts +86 -0
  47. package/templates/before-after-wide.ts +120 -0
  48. package/templates/before-after.ts +111 -0
  49. package/templates/browser-window-wide.ts +155 -0
  50. package/templates/bullet-points-wide.ts +89 -0
  51. package/templates/callout-wide.ts +151 -0
  52. package/templates/callout.ts +135 -0
  53. package/templates/caption-highlight.ts +117 -0
  54. package/templates/caption-pop.ts +121 -0
  55. package/templates/caption-stack.ts +84 -0
  56. package/templates/caption-subtitle-wide.ts +86 -0
  57. package/templates/caption-subtitle.ts +115 -0
  58. package/templates/caption-word.ts +107 -0
  59. package/templates/catalog.json +2400 -0
  60. package/templates/chapter-title-wide.ts +62 -0
  61. package/templates/click-zoom.ts +139 -0
  62. package/templates/cta-endcard-wide.ts +127 -0
  63. package/templates/cta-endcard.ts +119 -0
  64. package/templates/desktop-follow.ts +198 -0
  65. package/templates/device-stack.ts +135 -0
  66. package/templates/editorial.ts +260 -0
  67. package/templates/feature-grid-wide.ts +109 -0
  68. package/templates/fonts/Anton-Regular.woff2 +0 -0
  69. package/templates/fonts/Inter-500-latin.ttf +0 -0
  70. package/templates/fonts/Inter-600-latin.ttf +0 -0
  71. package/templates/fonts/Inter-700-latin.ttf +0 -0
  72. package/templates/fonts/Inter-800-latin.ttf +0 -0
  73. package/templates/fonts/LICENSE-Inter.txt +133 -0
  74. package/templates/fonts/OFL-Anton.txt +93 -0
  75. package/templates/growth-bars-wide.ts +85 -0
  76. package/templates/hook-impact.ts +58 -0
  77. package/templates/hook-number.ts +90 -0
  78. package/templates/hook-question.ts +88 -0
  79. package/templates/kit.ts +140 -0
  80. package/templates/laptop-frame-wide.ts +163 -0
  81. package/templates/logo-tagline-wide.ts +81 -0
  82. package/templates/logo-tagline.ts +93 -0
  83. package/templates/logo-wall-wide.ts +65 -0
  84. package/templates/montage.ts +273 -0
  85. package/templates/multi-window-wide.ts +135 -0
  86. package/templates/name-lower-wide.ts +97 -0
  87. package/templates/phone-recording.ts +154 -0
  88. package/templates/product-hero-wide.ts +72 -0
  89. package/templates/push-transition-wide.ts +75 -0
  90. package/templates/push-transition.ts +83 -0
  91. package/templates/quote-wide.ts +92 -0
  92. package/templates/review-cards.ts +83 -0
  93. package/templates/stat-count-wide.ts +73 -0
  94. package/templates/stat-count.ts +100 -0
  95. package/templates/terminal-wide.ts +115 -0
  96. package/templates/three-steps.ts +92 -0
  97. package/templates/title-wide.ts +55 -0
  98. package/templates/tsconfig.json +17 -0
  99. package/templates/type-input.ts +107 -0
  100. package/lib/node_modules/@mografy/cli/dist/launcher.d.ts +0 -18
  101. package/lib/node_modules/@mografy/cli/dist/launcher.js +0 -126
@@ -0,0 +1,208 @@
1
+ // `npx mografy@latest init [folder]` without a global install: the project gets its own copy of the `mografy`
2
+ // package, so `npx mografy dev` inside it runs that copy (no download, works offline) and `npm run dev` does the same.
3
+ // Running `npx mografy@latest init` again in the project only moves that copy to the newer version; the scene,
4
+ // mografy.json and the user's files are never touched. The project also gets this version's Skill for both hosts
5
+ // (.agents/skills/mografy for Codex and others, .claude/skills/mografy for Claude Code), so nothing is installed
6
+ // globally. A source checkout has no package to install and its own Skill, so it skips both.
7
+ import { spawnSync } from 'node:child_process';
8
+ import { cp, mkdir, readFile } from 'node:fs/promises';
9
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
10
+ import { existsSync } from 'node:fs';
11
+ import { sharedSkillFiles } from '@mografy/core';
12
+ import { atomicWrite, installation, queueProjectWrite, WORKSPACE_FILE } from '@mografy/server';
13
+ import { VERSION } from './commands/help.js';
14
+ import { newerVersion } from './package-update.js';
15
+ /** The scripts a project gets; existing scripts with the same name are kept. */
16
+ const SCRIPTS = { dev: 'mografy dev', check: 'mografy check', review: 'mografy review', export: 'mografy export' };
17
+ /** What `npm install` installs: this exact version, or `MOGRAFY_PACKAGE_SPEC` (a tarball path, for tests). */
18
+ export const packageSpec = () => process.env.MOGRAFY_PACKAGE_SPEC || `mografy@${VERSION}`;
19
+ /** Write or merge the project's package.json: private, with `mografy` as a dev dependency and the shortcuts. */
20
+ export function writeProjectManifest(dir, name, spec = packageSpec()) {
21
+ return queueProjectWrite(dir, async () => {
22
+ const file = join(dir, 'package.json');
23
+ const current = await readFile(file, 'utf8').then(text => JSON.parse(text), () => undefined);
24
+ const manifest = current ?? { name: npmName(name), private: true };
25
+ manifest.scripts = { ...SCRIPTS, ...manifest.scripts };
26
+ // npm install rewrites the range; a tarball path stays as given.
27
+ manifest.devDependencies = { ...manifest.devDependencies, mografy: spec.startsWith('mografy@') ? VERSION : spec };
28
+ await atomicWrite(file, JSON.stringify(manifest, null, 2) + '\n');
29
+ });
30
+ }
31
+ /** Keep node_modules out of Git next to the template's entries. */
32
+ export function ignoreNodeModules(dir) {
33
+ return queueProjectWrite(dir, async () => {
34
+ const file = join(dir, '.gitignore');
35
+ const text = await readFile(file, 'utf8').catch(() => '');
36
+ if (text.split(/\r?\n/).some(line => /^\/?node_modules\/?$/.test(line.trim())))
37
+ return;
38
+ await atomicWrite(file, `${text}${text && !text.endsWith('\n') ? '\n' : ''}node_modules/\n`);
39
+ });
40
+ }
41
+ /** Write this version's Skill into the project for both hosts; links in it point to GitHub. */
42
+ export function writeProjectSkill(dir) {
43
+ return queueProjectWrite(dir, async () => {
44
+ for (const host of ['.agents', '.claude']) {
45
+ for (const [file, contents] of Object.entries(sharedSkillFiles().mografy)) {
46
+ const path = join(dir, host, 'skills', 'mografy', file);
47
+ if (await readFile(path, 'utf8').catch(() => undefined) !== contents)
48
+ await atomicWrite(path, contents);
49
+ }
50
+ }
51
+ });
52
+ }
53
+ const npmName = (name) => name.toLowerCase().replace(/[^a-z0-9._-]+/g, '-').replace(/^[._-]+|-+$/g, '') || 'mografy-project';
54
+ /**
55
+ * Give the project its own copy of Mografy. Returns false (with the reason printed) when npm fails, so `init`
56
+ * still leaves a usable project that `npx mografy@latest dev` can open.
57
+ */
58
+ export async function installIntoProject(dir, name, log = (line) => console.log(line)) {
59
+ if (installation.kind !== 'package')
60
+ return false;
61
+ const spec = packageSpec();
62
+ await writeProjectSkill(dir);
63
+ await writeProjectManifest(dir, name, spec);
64
+ await ignoreNodeModules(dir);
65
+ log(`Installing ${spec.startsWith('mografy@') ? spec : 'mografy'} into this folder (not global)…`);
66
+ const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
67
+ const result = spawnSync(npm, ['install', '--save-dev', '--no-audit', '--no-fund', spec], { cwd: dir, stdio: 'inherit', shell: process.platform === 'win32' });
68
+ if (result.status === 0)
69
+ return true;
70
+ log(`npm install did not finish${result.error ? ` (${result.error.message})` : ''}. The project is ready; run \`npm install\` in it later, or open it with \`npx mografy@latest dev\`.`);
71
+ return false;
72
+ }
73
+ /**
74
+ * `npx mografy@latest` (a bare `dev`) inside a project that has its own copy: when that copy is older than the
75
+ * running version, install this version into the project and say so. Nothing happens from a source checkout, from
76
+ * the project's own copy, or in a project without one.
77
+ */
78
+ export async function updateProjectCopy(dir, log = (line) => console.log(line)) {
79
+ if (installation.kind !== 'package')
80
+ return false;
81
+ const local = join(dir, 'node_modules', 'mografy');
82
+ if (resolve(installation.root) === resolve(local))
83
+ return false;
84
+ const installed = await readFile(join(local, 'package.json'), 'utf8').then(text => JSON.parse(text).version, () => undefined);
85
+ if (!installed || !newerVersion(VERSION, installed))
86
+ return false;
87
+ log(`This project has Mografy ${installed}; updating it to ${VERSION}.`);
88
+ const name = await folderLabel(dir);
89
+ if (isWorkspace(dir))
90
+ await writeWorkspace(dir, name);
91
+ return installIntoProject(dir, name, log);
92
+ }
93
+ /** The workspace or project whose own copy of Mografy is running (`<folder>/node_modules/mografy`), if it is one. */
94
+ export function runningProject(root = installation.root, kind = installation.kind) {
95
+ if (kind !== 'package' || basename(dirname(root)) !== 'node_modules')
96
+ return undefined;
97
+ const project = dirname(dirname(root));
98
+ return existsSync(join(project, WORKSPACE_FILE)) || existsSync(join(project, 'mografy.json')) ? project : undefined;
99
+ }
100
+ /**
101
+ * A project's own copy keeps its tools in the project too, untouched by PATH: FFmpeg downloads into
102
+ * node_modules/.cache/mografy/tools (kept across updates, removed with the folder) and PATH's ffmpeg is not used;
103
+ * a Chromium shell, needed only when there is no Chrome or Edge, goes next to it. Explicit settings still win.
104
+ */
105
+ export function useProjectTools(env = process.env, project = runningProject()) {
106
+ if (!project)
107
+ return false;
108
+ const cache = join(project, 'node_modules', '.cache', 'mografy');
109
+ env.MOGRAFY_TOOLS ??= join(cache, 'tools');
110
+ env.MOGRAFY_SYSTEM_FFMPEG ??= '0';
111
+ env.PLAYWRIGHT_BROWSERS_PATH ??= join(cache, 'browsers');
112
+ return true;
113
+ }
114
+ // ---------------------------------------------------------------- workspace
115
+ /** The folders every workspace has, with the note each one carries (an empty folder would not show what it is for). */
116
+ export const WORKSPACE_FOLDERS = {
117
+ projects: `# projects
118
+
119
+ Your films, one folder each (a folder with a mografy.json). Ask Claude or Codex in the workspace for a new animation and
120
+ it is created here, or run \`npx mografy init projects/<name>\`. The built-in components are in projects/.components.
121
+
122
+ Open the player: \`npx mografy dev\` (or \`npx mografy dev projects/<name>\`). Export: \`npx mografy export projects/<name>\`;
123
+ the video is saved in projects/<name>/renders/.
124
+ `,
125
+ examples: `# examples
126
+
127
+ Reference films to watch, study and build on. \`npx mografy add\` lists them; \`npx mografy add <film>\` copies one here
128
+ (\`npx mografy add <film> projects/<name>\` makes it a project of your own instead). The player lists them as examples.
129
+ `,
130
+ templates: `# templates
131
+
132
+ Mografy Templates: finished scene modules (hooks, captions, product screens, end cards) with their fonts, copied from
133
+ this version of Mografy and replaced when it updates. Do not edit them here: \`npx mografy add <template...> projects/<name>\`
134
+ copies them into a project, where they are yours to change.
135
+ `,
136
+ };
137
+ const WORKSPACE_GUIDE = `# Mografy workspace
138
+
139
+ This folder is a Mografy workspace, set up by \`npx mografy@latest init\`. Mografy and its Skill are installed here
140
+ (node_modules/mografy, .agents/skills/mografy, .claude/skills/mografy), not globally. Every command below runs from this
141
+ folder or any folder inside it, and defaults to it.
142
+
143
+ - projects/ the user's films, one project each (mografy.json + scenes/). Create a new film with
144
+ \`npx mografy init projects/<name>\`, never in the workspace root.
145
+ - examples/ reference films: \`npx mografy add <film>\` copies one here. Read them, do not edit them in place.
146
+ - templates/ Mografy Templates for \`npx mografy add <template...> projects/<name>\`. Do not edit them here.
147
+
148
+ Open the player: \`npx mografy dev\`. Check, review and export a project: \`npx mografy check|review|export projects/<name>\`.
149
+ MCP: \`npx -y mografy mcp\` started in this folder works with this workspace. Update: \`npx mografy@latest init\` here.
150
+ Before writing a scene, use the Mografy Skill.
151
+ `;
152
+ export const isWorkspace = (dir) => existsSync(join(dir, WORKSPACE_FILE));
153
+ /** `<target>` is `workspace` itself or inside it. */
154
+ export function insideFolder(workspace, target) {
155
+ const rel = relative(resolve(workspace), resolve(target));
156
+ return rel === '' || (rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel));
157
+ }
158
+ /**
159
+ * Where `init <name>` creates a project inside a workspace: a folder named directly in the workspace root
160
+ * (`init my-film` typed there) goes into projects/, so a project never sits beside node_modules; any deeper path is
161
+ * used as given.
162
+ */
163
+ export function workspaceProjectDir(workspace, target) {
164
+ const ws = resolve(workspace), dir = resolve(target);
165
+ return dirname(dir) === ws && !(basename(dir) in WORKSPACE_FOLDERS) ? join(ws, 'projects', basename(dir)) : dir;
166
+ }
167
+ async function folderLabel(dir) {
168
+ for (const file of [WORKSPACE_FILE, 'mografy.json']) {
169
+ const name = await readFile(join(dir, file), 'utf8').then(text => JSON.parse(text).name, () => undefined);
170
+ if (name)
171
+ return name;
172
+ }
173
+ return basename(resolve(dir)) || 'mografy-project';
174
+ }
175
+ /**
176
+ * Make `dir` a workspace, or bring one up to this version: the marker, projects/, examples/ and templates/ with their
177
+ * notes, the guide for agents, and this version's templates. Never creates a project and never touches projects/ or
178
+ * examples/ contents.
179
+ */
180
+ export function writeWorkspace(dir, name = basename(resolve(dir))) {
181
+ return queueProjectWrite(dir, async () => {
182
+ await mkdir(dir, { recursive: true });
183
+ const marker = join(dir, WORKSPACE_FILE);
184
+ const current = await readFile(marker, 'utf8').then(text => JSON.parse(text), () => undefined);
185
+ if (!current)
186
+ await atomicWrite(marker, JSON.stringify({ version: 1, name }, null, 2) + '\n');
187
+ for (const [folder, note] of Object.entries(WORKSPACE_FOLDERS)) {
188
+ await mkdir(join(dir, folder), { recursive: true });
189
+ if (!existsSync(join(dir, folder, 'README.md')))
190
+ await atomicWrite(join(dir, folder, 'README.md'), note);
191
+ }
192
+ const bundled = join(installation.root, 'templates');
193
+ if (resolve(bundled) !== resolve(dir, 'templates') && existsSync(join(bundled, 'catalog.json')))
194
+ await cp(bundled, join(dir, 'templates'), { recursive: true, force: true, filter: source => basename(source) !== 'README.md' || dirname(source) !== bundled });
195
+ const agents = join(dir, 'AGENTS.md');
196
+ const guide = await readFile(agents, 'utf8').catch(() => undefined);
197
+ if (guide === undefined || guide.startsWith('# Mografy workspace'))
198
+ await atomicWrite(agents, WORKSPACE_GUIDE);
199
+ if (!existsSync(join(dir, 'CLAUDE.md')))
200
+ await atomicWrite(join(dir, 'CLAUDE.md'), '@AGENTS.md\n');
201
+ const ignore = join(dir, '.gitignore');
202
+ const text = await readFile(ignore, 'utf8').catch(() => '');
203
+ const missing = ['.mografy/', 'renders/'].filter(entry => !text.split(/\r?\n/).some(line => line.trim() === entry));
204
+ if (missing.length)
205
+ await atomicWrite(ignore, `${text}${text && !text.endsWith('\n') ? '\n' : ''}${missing.join('\n')}\n`);
206
+ });
207
+ }
208
+ //# sourceMappingURL=project-install.js.map
@@ -4,7 +4,7 @@
4
4
  import { mkdir, readdir, writeFile } from 'node:fs/promises';
5
5
  import { dirname, join, normalize, resolve, sep } from 'node:path';
6
6
  import { inflateRawSync } from 'node:zlib';
7
- import { libraryDir } from '@mografy/server';
7
+ import { referenceFilmsDir } from '@mografy/server';
8
8
  import { displayPath } from './paths.js';
9
9
  export const SHOWCASE_URL = (process.env.MOGRAFY_SHOWCASE_URL ?? 'https://www.mografy.app/showcase').replace(/\/$/, '');
10
10
  export const filmUrl = (name) => `${SHOWCASE_URL}/films/${name}.zip`;
@@ -87,9 +87,9 @@ export async function extractZip(zip, dest) {
87
87
  export async function installShowcase(name, target, fetchImpl = fetch) {
88
88
  if (!isShowcaseFilm(name))
89
89
  throw new Error(`Unknown showcase film: ${name}\nShowcase films:\n${showcaseList()}`);
90
- const dest = resolve(target ?? join(libraryDir(), name));
90
+ const dest = resolve(target ?? join(referenceFilmsDir(), name));
91
91
  if (await readdir(dest).then(() => true, () => false))
92
- throw new Error(`${displayPath(dest)} already exists. Pass another folder: mografy add ${name} <folder>`);
92
+ throw new Error(`${displayPath(dest)} already exists. Pass another folder: npx mografy add ${name} <folder>`);
93
93
  const url = filmUrl(name);
94
94
  console.log(`Downloading ${name} from ${url}…`);
95
95
  const response = await fetchImpl(url).catch(error => { throw new Error(`Could not download ${name}: ${error.message}. Check the connection, or get it from ${SHOWCASE_URL}`); });
@@ -104,6 +104,6 @@ export async function installShowcase(name, target, fetchImpl = fetch) {
104
104
  }
105
105
  export function printShowcase(name, dest, bytes) {
106
106
  console.log(`Downloaded the showcase film ${name} (${(bytes / 1048576).toFixed(1)} MB) to ${displayPath(dest)}`);
107
- console.log(`\nWatch it: mografy dev ${displayPath(dest)}\nRead first: scenes/ and style.md, then references/examples.md in the Mografy Skill`);
107
+ console.log(`\nWatch it: npx mografy dev ${displayPath(dest)}\nRead first: scenes/ and style.md, then references/examples.md in the Mografy Skill`);
108
108
  }
109
109
  //# sourceMappingURL=showcase.js.map
@@ -4,12 +4,14 @@
4
4
  import { existsSync } from 'node:fs';
5
5
  import { homedir } from 'node:os';
6
6
  import { join } from 'node:path';
7
- import { installation } from '@mografy/server';
7
+ import { installation, workspaceDir } from '@mografy/server';
8
8
  export const SKILL_INSTALL = 'npx skills add mografy/mografy -g';
9
9
  /** Where agents find a Skill named mografy: the project's own folders, then the user's (both hosts). */
10
10
  export const skillLocations = (project, home = homedir()) => [project, home].flatMap(base => ['.agents', '.claude'].map(host => join(base, host, 'skills', 'mografy', 'SKILL.md')));
11
11
  export function skillHint(project, log = (line) => console.log(line), home) {
12
- if (installation.kind !== 'package' || skillLocations(project, home).some(file => existsSync(file)))
12
+ const workspace = workspaceDir();
13
+ const found = [...skillLocations(project, home), ...(workspace ? skillLocations(workspace, home) : [])].some(file => existsSync(file));
14
+ if (installation.kind !== 'package' || found)
13
15
  return false;
14
16
  log(`Tip: agents need the Mografy Skill to write scenes. Install it once with:\n ${SKILL_INSTALL}`);
15
17
  return true;
@@ -1,4 +1,4 @@
1
- /** This installation's root folder (see `installation` in @mografy/server). */
1
+ /** The checkout or workspace whose templates/ is read first (see `workspaceRoot`). */
2
2
  export declare const ROOT: string;
3
3
  export interface TemplateEntry {
4
4
  id: string;
@@ -5,10 +5,10 @@
5
5
  import { mkdir, readFile, writeFile } from 'node:fs/promises';
6
6
  import { dirname, join, relative, sep } from 'node:path';
7
7
  import { createInLibrary, createProject, installation, isProject } from '@mografy/server';
8
- import { displayPath } from './paths.js';
8
+ import { displayPath, workspaceRoot } from './paths.js';
9
9
  import { exists, repoFile } from './github.js';
10
- /** This installation's root folder (see `installation` in @mografy/server). */
11
- export const ROOT = installation.root;
10
+ /** The checkout or workspace whose templates/ is read first (see `workspaceRoot`). */
11
+ export const ROOT = workspaceRoot;
12
12
  /** Fonts every template uses: Inter 500–800 for body, UI and the montage type; Anton for editorial headlines. */
13
13
  export const TEMPLATE_FONTS = [
14
14
  ...[500, 600, 700, 800].map(weight => ({ from: `templates/fonts/Inter-${weight}-latin.ttf`, to: `assets/Inter-${weight}-latin.ttf`, family: 'Inter', weight })),
@@ -93,6 +93,18 @@ export async function templateProject(workspaceRoot, dir, ids) {
93
93
  });
94
94
  return { dir: made, created: true };
95
95
  }
96
+ /**
97
+ * The runtime types a project's tsconfig.json points to: this installation's; in a workspace, the copy in its own
98
+ * node_modules when it has one (an npx download can be cleaned away); in another checkout, that checkout's build.
99
+ */
100
+ async function runtimeTypesFor(root) {
101
+ if (root === installation.root)
102
+ return installation.runtimeTypes;
103
+ const local = join(root, 'node_modules', 'mografy', 'lib', 'node_modules', '@mografy', 'runtime', 'dist', 'index.d.ts');
104
+ if (installation.kind === 'package')
105
+ return await exists(local) ? local : installation.runtimeTypes;
106
+ return join(root, 'packages/runtime/dist/index.d.ts');
107
+ }
96
108
  /**
97
109
  * Editor support for a project's scenes: a tsconfig.json that resolves `@mografy/runtime` to this installation's
98
110
  * types, so templates open without "Cannot find module" or implicit `any` errors. Mografy's own build never reads it.
@@ -102,7 +114,7 @@ export async function writeEditorConfig(workspaceRoot, dir) {
102
114
  const file = join(dir, 'tsconfig.json');
103
115
  if (await exists(file))
104
116
  return false;
105
- const types = relative(dir, workspaceRoot === installation.root ? installation.runtimeTypes : join(workspaceRoot, 'packages/runtime/dist/index.d.ts')).split(sep).join('/');
117
+ const types = relative(dir, await runtimeTypesFor(workspaceRoot)).split(sep).join('/');
106
118
  const config = {
107
119
  '//': "Editor support only. Mografy's build resolves @mografy/runtime itself.",
108
120
  compilerOptions: {
@@ -170,7 +182,7 @@ export function printTemplatesDone(dir, ids, created, aspect, skipped) {
170
182
  '',
171
183
  created ? `Created ${displayPath(dir)} (${aspect}) with a scene that plays ${ids.length > 1 ? 'the templates in order' : 'the template'}: scenes/main.ts` : `Templates are in ${displayPath(dir)}/scenes/templates/.`,
172
184
  ...skipped.length ? [`Not in the sequence (other aspect ratio): ${skipped.join(', ')}. Use them in a ${aspect === '9:16' ? '16:9' : '9:16'} project.`] : [],
173
- created ? `Open it: mografy dev ${displayPath(dir)}` : 'Play one inside your film:',
185
+ created ? `Open it: npx mografy dev ${displayPath(dir)}` : 'Play one inside your film:',
174
186
  ...created ? [] : [` import * as ${camel(first)} from './templates/${first}.js';`, ` import { play } from './templates/kit.js';`, ` play(ctx, time, 2.0, ${camel(first)}, { /* params */ });`],
175
187
  'Guide: .agents/skills/mografy/references/templates.md',
176
188
  ];
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mografy/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "private": true,