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.
- package/README.md +16 -9
- package/lib/node_modules/@mografy/cli/bin/locate.mjs +2 -22
- package/lib/node_modules/@mografy/cli/dist/add.d.ts +0 -1
- package/lib/node_modules/@mografy/cli/dist/add.js +6 -24
- package/lib/node_modules/@mografy/cli/dist/commands/help.js +5 -2
- package/lib/node_modules/@mografy/cli/dist/examples.js +4 -4
- package/lib/node_modules/@mografy/cli/dist/index.js +70 -16
- package/lib/node_modules/@mografy/cli/dist/mcp/hosts.d.ts +1 -1
- package/lib/node_modules/@mografy/cli/dist/mcp/hosts.js +6 -3
- package/lib/node_modules/@mografy/cli/dist/paths.d.ts +4 -3
- package/lib/node_modules/@mografy/cli/dist/paths.js +6 -5
- package/lib/node_modules/@mografy/cli/dist/project-args.d.ts +4 -3
- package/lib/node_modules/@mografy/cli/dist/project-args.js +7 -4
- package/lib/node_modules/@mografy/cli/dist/project-install.d.ts +44 -0
- package/lib/node_modules/@mografy/cli/dist/project-install.js +208 -0
- package/lib/node_modules/@mografy/cli/dist/showcase.js +4 -4
- package/lib/node_modules/@mografy/cli/dist/skill-hint.js +4 -2
- package/lib/node_modules/@mografy/cli/dist/templates.d.ts +1 -1
- package/lib/node_modules/@mografy/cli/dist/templates.js +17 -5
- package/lib/node_modules/@mografy/cli/package.json +1 -1
- package/lib/node_modules/@mografy/core/dist/guide.d.ts +12 -12
- package/lib/node_modules/@mografy/core/dist/guide.js +3 -3
- package/lib/node_modules/@mografy/core/dist/protocol.d.ts +6 -0
- package/lib/node_modules/@mografy/core/dist/skill-text.d.ts +22 -22
- package/lib/node_modules/@mografy/core/dist/skill-text.js +22 -22
- package/lib/node_modules/@mografy/core/package.json +1 -1
- package/lib/node_modules/@mografy/render/dist/ffmpeg.d.ts +1 -1
- package/lib/node_modules/@mografy/render/dist/ffmpeg.js +3 -2
- package/lib/node_modules/@mografy/render/package.json +1 -1
- package/lib/node_modules/@mografy/runtime/package.json +1 -1
- package/lib/node_modules/@mografy/server/dist/index.d.ts +1 -0
- package/lib/node_modules/@mografy/server/dist/index.js +1 -0
- package/lib/node_modules/@mografy/server/dist/installation.d.ts +31 -2
- package/lib/node_modules/@mografy/server/dist/installation.js +75 -5
- package/lib/node_modules/@mografy/server/dist/project.d.ts +5 -0
- package/lib/node_modules/@mografy/server/dist/project.js +2 -2
- package/lib/node_modules/@mografy/server/dist/workspace.d.ts +5 -0
- package/lib/node_modules/@mografy/server/dist/workspace.js +20 -6
- package/lib/node_modules/@mografy/server/package.json +1 -1
- package/lib/node_modules/@mografy/web/dist/app.css +1 -1
- package/lib/node_modules/@mografy/web/dist/app.js +26 -14
- package/lib/node_modules/@mografy/web/package.json +1 -1
- package/package.json +2 -1
- package/templates/README.md +35 -0
- package/templates/ai-chat-stream-wide.ts +132 -0
- package/templates/ai-chat-stream.ts +86 -0
- package/templates/before-after-wide.ts +120 -0
- package/templates/before-after.ts +111 -0
- package/templates/browser-window-wide.ts +155 -0
- package/templates/bullet-points-wide.ts +89 -0
- package/templates/callout-wide.ts +151 -0
- package/templates/callout.ts +135 -0
- package/templates/caption-highlight.ts +117 -0
- package/templates/caption-pop.ts +121 -0
- package/templates/caption-stack.ts +84 -0
- package/templates/caption-subtitle-wide.ts +86 -0
- package/templates/caption-subtitle.ts +115 -0
- package/templates/caption-word.ts +107 -0
- package/templates/catalog.json +2400 -0
- package/templates/chapter-title-wide.ts +62 -0
- package/templates/click-zoom.ts +139 -0
- package/templates/cta-endcard-wide.ts +127 -0
- package/templates/cta-endcard.ts +119 -0
- package/templates/desktop-follow.ts +198 -0
- package/templates/device-stack.ts +135 -0
- package/templates/editorial.ts +260 -0
- package/templates/feature-grid-wide.ts +109 -0
- package/templates/fonts/Anton-Regular.woff2 +0 -0
- package/templates/fonts/Inter-500-latin.ttf +0 -0
- package/templates/fonts/Inter-600-latin.ttf +0 -0
- package/templates/fonts/Inter-700-latin.ttf +0 -0
- package/templates/fonts/Inter-800-latin.ttf +0 -0
- package/templates/fonts/LICENSE-Inter.txt +133 -0
- package/templates/fonts/OFL-Anton.txt +93 -0
- package/templates/growth-bars-wide.ts +85 -0
- package/templates/hook-impact.ts +58 -0
- package/templates/hook-number.ts +90 -0
- package/templates/hook-question.ts +88 -0
- package/templates/kit.ts +140 -0
- package/templates/laptop-frame-wide.ts +163 -0
- package/templates/logo-tagline-wide.ts +81 -0
- package/templates/logo-tagline.ts +93 -0
- package/templates/logo-wall-wide.ts +65 -0
- package/templates/montage.ts +273 -0
- package/templates/multi-window-wide.ts +135 -0
- package/templates/name-lower-wide.ts +97 -0
- package/templates/phone-recording.ts +154 -0
- package/templates/product-hero-wide.ts +72 -0
- package/templates/push-transition-wide.ts +75 -0
- package/templates/push-transition.ts +83 -0
- package/templates/quote-wide.ts +92 -0
- package/templates/review-cards.ts +83 -0
- package/templates/stat-count-wide.ts +73 -0
- package/templates/stat-count.ts +100 -0
- package/templates/terminal-wide.ts +115 -0
- package/templates/three-steps.ts +92 -0
- package/templates/title-wide.ts +55 -0
- package/templates/tsconfig.json +17 -0
- package/templates/type-input.ts +107 -0
- package/lib/node_modules/@mografy/cli/dist/launcher.d.ts +0 -18
- package/lib/node_modules/@mografy/cli/dist/launcher.js +0 -126
package/README.md
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
# Mografy
|
|
2
2
|
|
|
3
3
|
Local Canvas motion design for Claude Code and Codex. Scenes are TypeScript modules drawn as a pure function of time;
|
|
4
|
-
`mografy dev` previews them live and `mografy export` writes MP4, WebM, MOV, Lottie or SVGA.
|
|
4
|
+
`npx mografy dev` previews them live and `npx mografy export` writes MP4, WebM, MOV, Lottie or SVGA.
|
|
5
5
|
|
|
6
6
|
```sh
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
mografy dev
|
|
7
|
+
npx mografy@latest init # creates ./mografy: a workspace with Mografy and its agent Skill inside
|
|
8
|
+
cd mografy
|
|
9
|
+
npx mografy dev # open the editor (or: npm run dev)
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
The workspace has `projects/` (your films), `examples/` (reference films from `npx mografy add <film>`) and
|
|
13
|
+
`templates/` (Mografy Templates), and every command run inside it defaults to it. Open Claude Code or Codex in the
|
|
14
|
+
`mografy` folder and describe the animation; it is created in `projects/`. Everything lives in that folder: nothing is
|
|
15
|
+
installed globally, and deleting the folder removes it. `npx mografy@latest init my-workspace` names the folder.
|
|
16
|
+
To update, run `npx mografy@latest init` inside it.
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
the
|
|
16
|
-
Templates
|
|
18
|
+
You don't install FFmpeg or Chromium: Chrome or Edge renders checks and exports, and FFmpeg downloads into the
|
|
19
|
+
workspace the first time you export a video (a Chromium shell too, only without Chrome or Edge), or ahead of time with
|
|
20
|
+
`npx mografy setup`. Templates come with the package; helpers and reference films download from GitHub
|
|
21
|
+
when `npx mografy add` needs them.
|
|
17
22
|
|
|
18
|
-
|
|
23
|
+
Optional, for every folder: `npm install -g mografy` and `npx skills add mografy/mografy -g`.
|
|
24
|
+
|
|
25
|
+
Documentation and the source: https://github.com/mografy/mografy
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
// The one place that decides which Mografy checkout runs
|
|
2
|
-
//
|
|
3
|
-
// stay a single file with no dependencies. A checkout around the current folder is used only when it was installed on
|
|
1
|
+
// The one place that decides which Mografy checkout runs; bin/mografy.js imports it. It must stay a single file with
|
|
2
|
+
// no dependencies. A checkout around the current folder is used only when it was installed on
|
|
4
3
|
// this computer (listed in the trust file), so a downloaded folder that imitates one cannot run its code.
|
|
5
4
|
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
6
5
|
import { homedir } from 'node:os';
|
|
7
6
|
import { dirname, join } from 'node:path';
|
|
8
|
-
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
9
7
|
|
|
10
8
|
const real = dir => { try { return realpathSync(dir); } catch { return dir; } };
|
|
11
9
|
const defaultTrust = () => join(homedir(), '.mografy', 'trusted-checkouts');
|
|
@@ -25,21 +23,3 @@ export function checkoutAround(start, { trustFile = defaultTrust(), own } = {})
|
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
export const warnUntrusted = dir => console.error(`mografy: ignoring ${dir} because it was not installed on this computer. Run pnpm install there to use it.`);
|
|
28
|
-
|
|
29
|
-
/** Launcher entry: `node locate.mjs --launch <installed bin> <trust file> [mografy arguments]`. */
|
|
30
|
-
async function launch([installedBin, trustFile, ...args]) {
|
|
31
|
-
const found = checkoutAround(process.cwd(), { trustFile });
|
|
32
|
-
let bin;
|
|
33
|
-
if (found?.trusted) { const local = join(found.path, 'packages/cli/bin/mografy.js'); if (existsSync(local)) bin = local; }
|
|
34
|
-
else if (found) warnUntrusted(found.dir);
|
|
35
|
-
if (!bin && existsSync(installedBin)) bin = installedBin;
|
|
36
|
-
if (!bin) {
|
|
37
|
-
console.error(`mografy: the Mografy folder this command was installed from no longer exists:\n ${installedBin}\nRun mografy from inside your Mografy folder, or repair this command once from there:\n node packages/cli/bin/mografy.js install-command`);
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
process.argv = [process.argv[0], bin, ...args];
|
|
41
|
-
process.env.MOGRAFY_CHECKOUT_CHECKED = '1';
|
|
42
|
-
await import(pathToFileURL(bin).href);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (process.argv[2] === '--launch' && real(process.argv[1]) === real(fileURLToPath(import.meta.url))) await launch(process.argv.slice(3));
|
|
@@ -16,4 +16,3 @@ export declare function addList(): Promise<string>;
|
|
|
16
16
|
* and nothing is ever added silently to another, last-opened project.
|
|
17
17
|
*/
|
|
18
18
|
export declare function runAdd(plan: AddPlan, workspaceRoot: string, target: (name?: string) => Promise<string | undefined>, force?: boolean, isProject?: (dir: string) => Promise<boolean>): Promise<void>;
|
|
19
|
-
export declare function addSuggestions(): Promise<string>;
|
|
@@ -6,14 +6,6 @@ import { addExtra, EXTRAS, extrasList, printAdd } from './extras.js';
|
|
|
6
6
|
import { copyExample, examplesList, listExamples, printExample } from './examples.js';
|
|
7
7
|
import { installShowcase, isShowcaseFilm, printShowcase, SHOWCASE_URL, showcaseList } from './showcase.js';
|
|
8
8
|
import { addTemplate, isTemplate, listTemplates, printTemplate, printTemplatesDone, ROOT, templateProject, templatesList } from './templates.js';
|
|
9
|
-
/** What `mografy install-command` suggests next: [arguments, why]. Films first, then helpers for a project. */
|
|
10
|
-
const SUGGESTED = [
|
|
11
|
-
['hook-impact cta-endcard projects/my-post', 'Start a 9:16 post from Mografy Templates (creates the project)'],
|
|
12
|
-
['stage-invoices', 'Start a product UI loop from a Stage reference film'],
|
|
13
|
-
['film-starter', 'Download the 20 s model film from the showcase: one camera, one shot table, one light to follow'],
|
|
14
|
-
['mografy-montage', 'Download a 60 s reference film from the showcase to watch and study'],
|
|
15
|
-
['music cjk', 'In a project: the score generator, Chinese and Japanese type'],
|
|
16
|
-
];
|
|
17
9
|
export async function addKind(name) {
|
|
18
10
|
if (EXTRAS[name])
|
|
19
11
|
return 'helper';
|
|
@@ -41,7 +33,7 @@ export async function planAdd(args) {
|
|
|
41
33
|
if (templates.length)
|
|
42
34
|
plan.templates = templates;
|
|
43
35
|
if (plan.films.length && (plan.helpers.length || templates.length) || plan.target !== undefined && plan.films.length > 1)
|
|
44
|
-
throw new Error('Add reference films and helpers separately; a folder can follow one film:\n mografy add <film> [folder]\n mografy add <helper...> [project]');
|
|
36
|
+
throw new Error('Add reference films and helpers separately; a folder can follow one film:\n npx mografy add <film> [folder]\n npx mografy add <helper...> [project]');
|
|
45
37
|
return plan;
|
|
46
38
|
}
|
|
47
39
|
export async function addList() {
|
|
@@ -59,9 +51,9 @@ export async function addList() {
|
|
|
59
51
|
await templatesList(),
|
|
60
52
|
'',
|
|
61
53
|
'Usage:',
|
|
62
|
-
' mografy add <film> [folder]',
|
|
63
|
-
' mografy add <helper...> [project] for example: mografy add music cjk',
|
|
64
|
-
' mografy add <template...> [project]
|
|
54
|
+
' npx mografy add <film> [folder]',
|
|
55
|
+
' npx mografy add <helper...> [project] for example: npx mografy add music cjk',
|
|
56
|
+
' npx mografy add <template...> [project] for example: npx mografy add hook-impact cta-endcard projects/my-film',
|
|
65
57
|
' (a missing project is created for the templates)',
|
|
66
58
|
].join('\n');
|
|
67
59
|
}
|
|
@@ -92,8 +84,8 @@ export async function runAdd(plan, workspaceRoot, target, force = false, isProje
|
|
|
92
84
|
if (!dir || !await isProject(dir)) {
|
|
93
85
|
const named = plan.target ?? 'projects/<name>';
|
|
94
86
|
throw new Error(`${dir ? `${dir} has no mografy.json` : 'This folder is not a Mografy project'}, so there is nowhere to add ${plan.helpers.join(', ')}.\n`
|
|
95
|
-
+ ` Name the project: mografy add ${plan.helpers.join(' ')} ${named}\n`
|
|
96
|
-
+ ` Or start one from templates, which creates the project: mografy add hook-impact ${named}`);
|
|
87
|
+
+ ` Name the project: npx mografy add ${plan.helpers.join(' ')} ${named}\n`
|
|
88
|
+
+ ` Or start one from templates, which creates the project: npx mografy add hook-impact ${named}`);
|
|
97
89
|
}
|
|
98
90
|
for (const [i, name] of plan.helpers.entries()) {
|
|
99
91
|
if (i)
|
|
@@ -110,14 +102,4 @@ export async function runAdd(plan, workspaceRoot, target, force = false, isProje
|
|
|
110
102
|
const all = await listTemplates(workspaceRoot), aspect = all.find(s => s.id === templates[0]).aspect;
|
|
111
103
|
printTemplatesDone(dir, templates, created, aspect, created ? templates.filter(id => all.find(s => s.id === id).aspect !== aspect) : []);
|
|
112
104
|
}
|
|
113
|
-
export async function addSuggestions() {
|
|
114
|
-
const films = new Set((await listExamples()).map(e => e.name)), templates = new Set((await listTemplates(ROOT)).map(t => t.id));
|
|
115
|
-
// Every name must exist in this installation; a trailing folder (projects/…) is not a name.
|
|
116
|
-
const rows = SUGGESTED.filter(([args]) => args.split(' ').filter(name => !name.includes('/')).every(name => EXTRAS[name] || films.has(name) || isShowcaseFilm(name) || templates.has(name)));
|
|
117
|
-
if (!rows.length)
|
|
118
|
-
return '';
|
|
119
|
-
const all = [...rows.map(([args, why]) => [`mografy add ${args}`, why]), ['mografy add', 'List every template, reference film and helper']];
|
|
120
|
-
const width = Math.max(...all.map(([command]) => command.length));
|
|
121
|
-
return `\n\nNext, add what your films need:\n${all.map(([command, why]) => ` ${command.padEnd(width)} ${why}`).join('\n')}`;
|
|
122
|
-
}
|
|
123
105
|
//# sourceMappingURL=add.js.map
|
|
@@ -20,6 +20,10 @@ export function helpText(color) {
|
|
|
20
20
|
return [
|
|
21
21
|
` ${teal('●')} ${bold('Mografy')} ${dim(VERSION)}\n ${dim('Local Canvas animation for Claude Code and Codex. Claude creates. Mografy shows.')}`,
|
|
22
22
|
section('Start', [
|
|
23
|
+
row('npx mografy@latest init [folder]', 'New workspace in ./mografy (or [folder]): projects/, examples/, templates/ and its own Mografy'),
|
|
24
|
+
row('npx mografy init projects/<name>', 'Inside a workspace: a new project in projects/'),
|
|
25
|
+
row('npx mografy dev', 'Inside the workspace (cd mografy): open the player'),
|
|
26
|
+
row('npx mografy@latest init', 'Inside the workspace: update its Mografy and templates'),
|
|
23
27
|
row('mografy dev', 'Open the player: built-in animations and your projects'),
|
|
24
28
|
row('mografy dev <project>', 'Open a project in the player'),
|
|
25
29
|
]),
|
|
@@ -33,7 +37,7 @@ export function helpText(color) {
|
|
|
33
37
|
]),
|
|
34
38
|
section('Add', [
|
|
35
39
|
row('mografy add', 'List the reference films, helpers and templates you can add'),
|
|
36
|
-
row('mografy add <film> [folder]', 'Copy a reference film into
|
|
40
|
+
row('mografy add <film> [folder]', 'Copy a reference film into examples/ (outside a workspace: the library)'),
|
|
37
41
|
row('mografy add <helper...> [project]', 'Add helpers to a project: cinema, cjk, three, music, walkthrough, stage'),
|
|
38
42
|
row('mografy add <template...> [project]', 'Add Mografy Templates: hooks, captions, screens, end cards (9:16 and 16:9)'),
|
|
39
43
|
row('', '--force replaces helper and template files you changed'),
|
|
@@ -41,7 +45,6 @@ export function helpText(color) {
|
|
|
41
45
|
section('Manage', [
|
|
42
46
|
row('mografy stop [project]', "Stop a project's player"),
|
|
43
47
|
row('mografy update [--check]', 'Update Mografy, or only check for updates'),
|
|
44
|
-
row('mografy install-command', 'Put the mografy command on PATH'),
|
|
45
48
|
row('mografy setup [ffmpeg|chromium]', 'Download FFmpeg and the Chromium shell now, not on first use'),
|
|
46
49
|
row('mografy setup --check', 'Show which FFmpeg and Chromium exports use'),
|
|
47
50
|
row('mografy mcp', 'Local MCP server on stdio: check, frames, review, export for MCP clients'),
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// downloaded from the same repository on GitHub, file by file, the first time it is added.
|
|
5
5
|
import { cp, mkdir, readdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
6
6
|
import { basename, dirname, join, resolve, sep } from 'node:path';
|
|
7
|
-
import { EXAMPLES_DIR, isProject,
|
|
7
|
+
import { EXAMPLES_DIR, isProject, referenceFilmsDir } from '@mografy/server';
|
|
8
8
|
import { downloadRepoFile } from './github.js';
|
|
9
9
|
import { displayPath } from './paths.js';
|
|
10
10
|
/**
|
|
@@ -72,9 +72,9 @@ export async function copyExample(name, target) {
|
|
|
72
72
|
const film = list.find(e => e.name === name);
|
|
73
73
|
if (!film)
|
|
74
74
|
throw new Error(`Unknown example: ${name}\nAvailable examples:\n${await examplesList()}`);
|
|
75
|
-
const dest = resolve(target ?? join(
|
|
75
|
+
const dest = resolve(target ?? join(referenceFilmsDir(), name));
|
|
76
76
|
if (await readdir(dest).then(() => true, () => false))
|
|
77
|
-
throw new Error(`${displayPath(dest)} already exists. Pass another folder: mografy add ${name} <folder>`);
|
|
77
|
+
throw new Error(`${displayPath(dest)} already exists. Pass another folder: npx mografy add ${name} <folder>`);
|
|
78
78
|
if (film.installed)
|
|
79
79
|
await cp(join(EXAMPLES_DIR, name), dest, { recursive: true, errorOnExist: true, filter: source => !SKIP.has(basename(source)) });
|
|
80
80
|
else
|
|
@@ -116,6 +116,6 @@ export async function downloadExample(name, dest, fetchImpl = fetch) {
|
|
|
116
116
|
}
|
|
117
117
|
export function printExample(name, dest) {
|
|
118
118
|
console.log(`Copied the reference film ${name} to ${displayPath(dest)}`);
|
|
119
|
-
console.log(`\nWatch it: mografy dev ${displayPath(dest)}\nRead first: scenes/ (the shot table, the camera, the drawing), then references/examples.md in the Mografy Skill`);
|
|
119
|
+
console.log(`\nWatch it: npx mografy dev ${displayPath(dest)}\nRead first: scenes/ (the shot table, the camera, the drawing), then references/examples.md in the Mografy Skill`);
|
|
120
120
|
}
|
|
121
121
|
//# sourceMappingURL=examples.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// Mografy CLI: read the command line and hand each command to its module.
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { sendApi } from '@mografy/core';
|
|
4
|
-
import { createProject, ensureAgentFiles, findServer, installation, libraryDir, rememberProject } from '@mografy/server';
|
|
4
|
+
import { createProject, ensureAgentFiles, findServer, installation, libraryDir, rememberProject, workspaceDir } from '@mografy/server';
|
|
5
5
|
import { displayPath, workspaceRoot } from './paths.js';
|
|
6
6
|
import { exportBatch, exportProject, projectsIn } from './export.js';
|
|
7
|
-
import { installCommand } from './launcher.js';
|
|
8
7
|
import { updateInstallation } from './update.js';
|
|
9
8
|
import { packageUpdate } from './package-update.js';
|
|
10
9
|
import { refreshSkill } from './skills.js';
|
|
11
10
|
import { skillHint } from './skill-hint.js';
|
|
12
11
|
import { addList, planAdd, runAdd } from './add.js';
|
|
12
|
+
import { writeEditorConfig } from './templates.js';
|
|
13
13
|
import { parse } from './options.js';
|
|
14
14
|
import { fromHome, hasProject, implicitProject, resolveProjectArg } from './project-args.js';
|
|
15
15
|
import { checkProject } from './commands/check.js';
|
|
@@ -18,11 +18,15 @@ import { HELP, VERSION, helpText } from './commands/help.js';
|
|
|
18
18
|
import { reviewProject } from './commands/review.js';
|
|
19
19
|
import { setup } from './commands/setup.js';
|
|
20
20
|
import { runMcp } from './mcp/index.js';
|
|
21
|
+
import { insideFolder, installIntoProject, isWorkspace, updateProjectCopy, useProjectTools, workspaceProjectDir, writeWorkspace } from './project-install.js';
|
|
22
|
+
import { readFile } from 'node:fs/promises';
|
|
23
|
+
import { basename, join, relative } from 'node:path';
|
|
21
24
|
export { displayPath } from './paths.js';
|
|
22
25
|
export { openBrowser };
|
|
23
26
|
export async function main(argv = process.argv.slice(2)) {
|
|
27
|
+
useProjectTools();
|
|
24
28
|
const { flags, rest } = parse(argv);
|
|
25
|
-
const commands = new Set(['dev', 'init', 'check', 'review', 'export', 'render', 'stop', '
|
|
29
|
+
const commands = new Set(['dev', 'init', 'check', 'review', 'export', 'render', 'stop', 'update', 'add', 'setup', 'mcp', 'help']);
|
|
26
30
|
const command = rest[0] && commands.has(rest[0]) ? rest.shift() : 'dev';
|
|
27
31
|
const explicit = rest[0] !== undefined;
|
|
28
32
|
if (argv.includes('--help') || argv.includes('-h') || command === 'help') {
|
|
@@ -66,14 +70,6 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
66
70
|
return packageUpdate(flags.updateCheck);
|
|
67
71
|
return updateInstallation(workspaceRoot, flags.updateCheck);
|
|
68
72
|
}
|
|
69
|
-
// Installation must not initialize components or consult a previous project's state.
|
|
70
|
-
if (command === 'install-command') {
|
|
71
|
-
if (installation.kind === 'package') {
|
|
72
|
-
console.log('npm already put the mografy command on PATH.');
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
return installCommand(workspaceRoot);
|
|
76
|
-
}
|
|
77
73
|
if (command === 'add') {
|
|
78
74
|
if (!rest.length) {
|
|
79
75
|
console.log(await addList());
|
|
@@ -93,7 +89,9 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
93
89
|
const dir = explicit
|
|
94
90
|
? command === 'init' ? resolve(rest[0]) : await resolveProjectArg(rest[0])
|
|
95
91
|
: command === 'init'
|
|
96
|
-
|
|
92
|
+
// Bare `init`: the workspace around the current folder (update its Mografy), else the current folder when it is
|
|
93
|
+
// a project made by an earlier version (update it), else a new workspace in ./mografy.
|
|
94
|
+
? workspaceDir() ?? (await hasProject(process.cwd()) ? process.cwd() : resolve('mografy'))
|
|
97
95
|
: configured
|
|
98
96
|
? resolve(configured)
|
|
99
97
|
: await implicitProject(command);
|
|
@@ -107,6 +105,9 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
107
105
|
+ ` Open the player: mografy dev (built-in animations and your projects)\n`
|
|
108
106
|
+ ` New animation: ask Claude or Codex`);
|
|
109
107
|
}
|
|
108
|
+
// `npx mografy@latest` inside a project with its own older copy: move that copy to this version first.
|
|
109
|
+
if (!explicit)
|
|
110
|
+
await updateProjectCopy(workspaceDir() ?? dir);
|
|
110
111
|
await refreshSkill(workspaceRoot);
|
|
111
112
|
skillHint(dir);
|
|
112
113
|
await ensureAgentFiles(dir);
|
|
@@ -127,11 +128,20 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
127
128
|
}
|
|
128
129
|
return dev(dir, flags);
|
|
129
130
|
}
|
|
130
|
-
//
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
// `mografy init [folder]`: a new project (agents use it too). From the npm package it makes or updates a workspace
|
|
132
|
+
// instead, see initPackage.
|
|
133
|
+
case 'init': {
|
|
134
|
+
if (installation.kind === 'package')
|
|
135
|
+
return initPackage(dir);
|
|
136
|
+
if (await hasProject(dir))
|
|
137
|
+
console.log(`${displayPath(dir)} is already a Mografy project; its scenes and settings stay as they are.`);
|
|
138
|
+
else {
|
|
139
|
+
await createProject(dir);
|
|
140
|
+
console.log(`Created project: ${displayPath(dir)}`);
|
|
141
|
+
}
|
|
142
|
+
console.log(`Run \`mografy dev ${displayPath(dir)}\` to open it, then describe the animation to Claude or Codex.`);
|
|
134
143
|
return;
|
|
144
|
+
}
|
|
135
145
|
case 'check': return checkProject(dir, flags.motion);
|
|
136
146
|
case 'review': return reviewProject(dir, flags.video);
|
|
137
147
|
case 'export':
|
|
@@ -148,5 +158,49 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
148
158
|
}
|
|
149
159
|
}
|
|
150
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* `npx mografy@latest init [folder]` from the npm package:
|
|
163
|
+
* - outside a workspace: a new workspace (./mografy, or the folder) with projects/, examples/ and templates/ and its
|
|
164
|
+
* own copy of Mografy and the Skill. No project is created: the player opens on the built-in components, and the
|
|
165
|
+
* first film is made in projects/ when the user asks for one.
|
|
166
|
+
* - the workspace itself (bare `init` anywhere inside it): update its copy, folders and templates.
|
|
167
|
+
* - a folder inside the workspace: a new project there (`init my-film` in the root goes to projects/my-film); the
|
|
168
|
+
* workspace's copy of Mografy serves it, so nothing is installed.
|
|
169
|
+
* - a project made by an earlier version (mografy.json in the folder, no workspace): update its copy as before.
|
|
170
|
+
*/
|
|
171
|
+
async function initPackage(target) {
|
|
172
|
+
const cd = (dir) => { const folder = relative(process.cwd(), dir); return folder ? ` cd ${/\s/.test(folder) ? JSON.stringify(folder) : folder}\n` : ''; };
|
|
173
|
+
const workspace = workspaceDir() ?? (isWorkspace(target) ? target : undefined);
|
|
174
|
+
if (workspace && insideFolder(workspace, target) && resolve(target) !== resolve(workspace)) {
|
|
175
|
+
const dir = workspaceProjectDir(workspace, target);
|
|
176
|
+
if (await hasProject(dir)) {
|
|
177
|
+
console.log(`${displayPath(dir)} is already a Mografy project.`);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
await createProject(dir);
|
|
181
|
+
await writeEditorConfig(workspace, dir);
|
|
182
|
+
const shown = relative(workspace, dir).split('\\').join('/');
|
|
183
|
+
console.log(`Created project: ${shown} (in the workspace ${fromHome(workspace)})\nOpen it: npx mografy dev ${shown}`);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const updating = workspace !== undefined && resolve(target) === resolve(workspace);
|
|
187
|
+
if (!updating && await hasProject(target)) {
|
|
188
|
+
console.log(`${displayPath(target)} is a Mografy project made by an earlier version; its scenes and settings stay as they are.`);
|
|
189
|
+
const name = JSON.parse(await readFile(join(target, 'mografy.json'), 'utf8')).name ?? 'mografy-project';
|
|
190
|
+
if (await installIntoProject(target, name))
|
|
191
|
+
console.log(`\nUpdated to Mografy ${VERSION}. This folder is a single project. For a workspace with projects/, examples/ and templates/, run \`npx mografy@latest init <name>\` in the folder above it (it creates <name> there), then move this project into <name>/projects/.`);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const dir = updating ? workspace : target;
|
|
195
|
+
const existed = isWorkspace(dir);
|
|
196
|
+
const name = basename(resolve(dir));
|
|
197
|
+
await writeWorkspace(dir, name);
|
|
198
|
+
console.log(existed ? `Updating the Mografy workspace ${fromHome(dir)}; your projects stay as they are.` : `Created the Mografy workspace ${fromHome(dir)}: projects/, examples/, templates/`);
|
|
199
|
+
if (await installIntoProject(dir, name)) {
|
|
200
|
+
console.log(`\nMografy ${VERSION} and its Skill are installed in this workspace, not globally. Next:\n${cd(dir)} npx mografy dev open the player (or: npm run dev)\n`
|
|
201
|
+
+ `Then open Claude Code or Codex in the workspace folder (${fromHome(dir)}) and describe the animation; new films go into projects/.\n`
|
|
202
|
+
+ `Reference films: npx mografy add (they go into examples/). To update later, run \`npx mografy@latest init\` in this folder.`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
151
205
|
export { HELP };
|
|
152
206
|
//# sourceMappingURL=index.js.map
|
|
@@ -30,7 +30,7 @@ export declare class Hosts {
|
|
|
30
30
|
private opened;
|
|
31
31
|
/**
|
|
32
32
|
* A project path: absolute, relative to the current folder, a folder name in the projects library, or a path inside
|
|
33
|
-
* the Mografy installation. Without one, MOGRAFY_PROJECT or the project in the current folder.
|
|
33
|
+
* the Mografy installation or workspace. Without one, MOGRAFY_PROJECT or the project in the current folder.
|
|
34
34
|
*/
|
|
35
35
|
resolve(arg: unknown): Promise<string>;
|
|
36
36
|
private require;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// Which process hosts a project for the MCP server: the running player when there is one (so the player and the
|
|
2
2
|
// agent see the same result and share one Chromium), otherwise a Project this process opens and keeps for a while.
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
3
4
|
import { realpath } from 'node:fs/promises';
|
|
4
5
|
import { isAbsolute, join, resolve } from 'node:path';
|
|
5
6
|
import { readApiResponse, sendApi } from '@mografy/core';
|
|
6
|
-
import { Project, findServer, isProject, libraryDir } from '@mografy/server';
|
|
7
|
+
import { Project, WORKSPACE_FILE, findServer, isProject, libraryDir } from '@mografy/server';
|
|
7
8
|
import { workspaceRoot } from '../paths.js';
|
|
9
|
+
const isWorkspace = (dir) => existsSync(join(dir, WORKSPACE_FILE));
|
|
8
10
|
/** The player answers 409 when it has switched to another project; this host then falls back to its own. */
|
|
9
11
|
class Switched extends Error {
|
|
10
12
|
}
|
|
@@ -60,12 +62,13 @@ export class Hosts {
|
|
|
60
62
|
opened = new Map();
|
|
61
63
|
/**
|
|
62
64
|
* A project path: absolute, relative to the current folder, a folder name in the projects library, or a path inside
|
|
63
|
-
* the Mografy installation. Without one, MOGRAFY_PROJECT or the project in the current folder.
|
|
65
|
+
* the Mografy installation or workspace. Without one, MOGRAFY_PROJECT or the project in the current folder.
|
|
64
66
|
*/
|
|
65
67
|
async resolve(arg) {
|
|
66
68
|
const value = typeof arg === 'string' && arg.trim() ? arg.trim() : undefined;
|
|
67
69
|
if (!value) {
|
|
68
|
-
|
|
70
|
+
// MOGRAFY_PROJECT may name a workspace (that is where the server works, see workspaceDir) rather than one project.
|
|
71
|
+
if (process.env.MOGRAFY_PROJECT && !isWorkspace(resolve(process.env.MOGRAFY_PROJECT)))
|
|
69
72
|
return this.require(resolve(process.env.MOGRAFY_PROJECT));
|
|
70
73
|
if (await isProject(process.cwd()))
|
|
71
74
|
return realpath(process.cwd());
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Where Mografy's folders are: the repository root of a checkout, or the workspace `npx mografy@latest init` made
|
|
3
|
+
* (found from the current folder), else the installation's own folder. See `workspaceDir` in @mografy/server.
|
|
4
|
+
*/
|
|
2
5
|
export declare const workspaceRoot: string;
|
|
3
|
-
/** The `mografy` entry script the PATH launcher runs (packages/cli/bin/mografy.js in a checkout). */
|
|
4
|
-
export declare const CLI_BIN: string;
|
|
5
6
|
/** Keep terminal output useful without exposing the user's absolute home path. */
|
|
6
7
|
export declare function displayPath(value: string): string;
|
|
7
8
|
export declare function requireProject(dir: string): Promise<void>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { homedir } from 'node:os';
|
|
2
2
|
import { isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
3
|
-
import { installation, isProject } from '@mografy/server';
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import { installation, isProject, workspaceDir } from '@mografy/server';
|
|
4
|
+
/**
|
|
5
|
+
* Where Mografy's folders are: the repository root of a checkout, or the workspace `npx mografy@latest init` made
|
|
6
|
+
* (found from the current folder), else the installation's own folder. See `workspaceDir` in @mografy/server.
|
|
7
|
+
*/
|
|
8
|
+
export const workspaceRoot = workspaceDir() ?? installation.root;
|
|
8
9
|
/** Keep terminal output useful without exposing the user's absolute home path. */
|
|
9
10
|
export function displayPath(value) {
|
|
10
11
|
const absolute = resolve(value);
|
|
@@ -2,9 +2,10 @@ import { isProject as hasProject } from '@mografy/server';
|
|
|
2
2
|
export { hasProject };
|
|
3
3
|
/**
|
|
4
4
|
* Bare project commands are convenient inside Mografy's own workspace, where
|
|
5
|
-
* the player can resume the last library project.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* the player can resume the last library project. Elsewhere a bare `dev` opens
|
|
6
|
+
* the player on the library (its last project, or the built-in components), the
|
|
7
|
+
* way `npx mografy dev` is meant to start; other commands require an actual
|
|
8
|
+
* project context, so none of them can act on a scene from another checkout.
|
|
8
9
|
*/
|
|
9
10
|
export declare function implicitProject(command: string): Promise<string>;
|
|
10
11
|
/** Show a path from the user's home, so it is clear which checkout or repository it is in. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Which project a command means, from its arguments and the current folder.
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
4
|
-
import { defaultProject, isProject as hasProject } from '@mografy/server';
|
|
4
|
+
import { defaultProject, isProject as hasProject, libraryProject } from '@mografy/server';
|
|
5
5
|
import { displayPath, workspaceRoot } from './paths.js';
|
|
6
6
|
export { hasProject };
|
|
7
7
|
function isInsideWorkspace(value) {
|
|
@@ -10,9 +10,10 @@ function isInsideWorkspace(value) {
|
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Bare project commands are convenient inside Mografy's own workspace, where
|
|
13
|
-
* the player can resume the last library project.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* the player can resume the last library project. Elsewhere a bare `dev` opens
|
|
14
|
+
* the player on the library (its last project, or the built-in components), the
|
|
15
|
+
* way `npx mografy dev` is meant to start; other commands require an actual
|
|
16
|
+
* project context, so none of them can act on a scene from another checkout.
|
|
16
17
|
*/
|
|
17
18
|
export async function implicitProject(command) {
|
|
18
19
|
const cwd = process.cwd();
|
|
@@ -20,6 +21,8 @@ export async function implicitProject(command) {
|
|
|
20
21
|
return cwd;
|
|
21
22
|
if (isInsideWorkspace(cwd))
|
|
22
23
|
return defaultProject(cwd);
|
|
24
|
+
if (command === 'dev')
|
|
25
|
+
return libraryProject();
|
|
23
26
|
throw new Error(`No mografy.json found in ${displayPath(cwd)}. Run \`mografy ${command} <project>\` or change into a Mografy project.`);
|
|
24
27
|
}
|
|
25
28
|
/** Show a path from the user's home, so it is clear which checkout or repository it is in. */
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** What `npm install` installs: this exact version, or `MOGRAFY_PACKAGE_SPEC` (a tarball path, for tests). */
|
|
2
|
+
export declare const packageSpec: () => string;
|
|
3
|
+
/** Write or merge the project's package.json: private, with `mografy` as a dev dependency and the shortcuts. */
|
|
4
|
+
export declare function writeProjectManifest(dir: string, name: string, spec?: string): Promise<void>;
|
|
5
|
+
/** Keep node_modules out of Git next to the template's entries. */
|
|
6
|
+
export declare function ignoreNodeModules(dir: string): Promise<void>;
|
|
7
|
+
/** Write this version's Skill into the project for both hosts; links in it point to GitHub. */
|
|
8
|
+
export declare function writeProjectSkill(dir: string): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Give the project its own copy of Mografy. Returns false (with the reason printed) when npm fails, so `init`
|
|
11
|
+
* still leaves a usable project that `npx mografy@latest dev` can open.
|
|
12
|
+
*/
|
|
13
|
+
export declare function installIntoProject(dir: string, name: string, log?: (line: string) => void): Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* `npx mografy@latest` (a bare `dev`) inside a project that has its own copy: when that copy is older than the
|
|
16
|
+
* running version, install this version into the project and say so. Nothing happens from a source checkout, from
|
|
17
|
+
* the project's own copy, or in a project without one.
|
|
18
|
+
*/
|
|
19
|
+
export declare function updateProjectCopy(dir: string, log?: (line: string) => void): Promise<boolean>;
|
|
20
|
+
/** The workspace or project whose own copy of Mografy is running (`<folder>/node_modules/mografy`), if it is one. */
|
|
21
|
+
export declare function runningProject(root?: string, kind?: "package" | "source"): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* A project's own copy keeps its tools in the project too, untouched by PATH: FFmpeg downloads into
|
|
24
|
+
* node_modules/.cache/mografy/tools (kept across updates, removed with the folder) and PATH's ffmpeg is not used;
|
|
25
|
+
* a Chromium shell, needed only when there is no Chrome or Edge, goes next to it. Explicit settings still win.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useProjectTools(env?: NodeJS.ProcessEnv, project?: string | undefined): boolean;
|
|
28
|
+
/** The folders every workspace has, with the note each one carries (an empty folder would not show what it is for). */
|
|
29
|
+
export declare const WORKSPACE_FOLDERS: Record<string, string>;
|
|
30
|
+
export declare const isWorkspace: (dir: string) => boolean;
|
|
31
|
+
/** `<target>` is `workspace` itself or inside it. */
|
|
32
|
+
export declare function insideFolder(workspace: string, target: string): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Where `init <name>` creates a project inside a workspace: a folder named directly in the workspace root
|
|
35
|
+
* (`init my-film` typed there) goes into projects/, so a project never sits beside node_modules; any deeper path is
|
|
36
|
+
* used as given.
|
|
37
|
+
*/
|
|
38
|
+
export declare function workspaceProjectDir(workspace: string, target: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Make `dir` a workspace, or bring one up to this version: the marker, projects/, examples/ and templates/ with their
|
|
41
|
+
* notes, the guide for agents, and this version's templates. Never creates a project and never touches projects/ or
|
|
42
|
+
* examples/ contents.
|
|
43
|
+
*/
|
|
44
|
+
export declare function writeWorkspace(dir: string, name?: string): Promise<void>;
|