mografy 0.1.1 → 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 +10 -8
- 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 -5
- package/lib/node_modules/@mografy/cli/dist/examples.js +4 -4
- package/lib/node_modules/@mografy/cli/dist/index.js +59 -29
- 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-install.d.ts +18 -1
- package/lib/node_modules/@mografy/cli/dist/project-install.js +103 -7
- 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/package.json +1 -1
- package/lib/node_modules/@mografy/runtime/package.json +1 -1
- 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.js +9 -5
- 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,22 +1,24 @@
|
|
|
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
|
-
npx mografy@latest init # creates ./mografy: a
|
|
7
|
+
npx mografy@latest init # creates ./mografy: a workspace with Mografy and its agent Skill inside
|
|
8
8
|
cd mografy
|
|
9
9
|
npx mografy dev # open the editor (or: npm run dev)
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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.
|
|
15
17
|
|
|
16
18
|
You don't install FFmpeg or Chromium: Chrome or Edge renders checks and exports, and FFmpeg downloads into the
|
|
17
|
-
|
|
18
|
-
`npx mografy setup`. Templates
|
|
19
|
-
when `mografy add` needs them.
|
|
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.
|
|
20
22
|
|
|
21
23
|
Optional, for every folder: `npm install -g mografy` and `npx skills add mografy/mografy -g`.
|
|
22
24
|
|
|
@@ -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,9 +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
|
|
24
|
-
row('npx mografy
|
|
25
|
-
row('npx mografy
|
|
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'),
|
|
26
27
|
row('mografy dev', 'Open the player: built-in animations and your projects'),
|
|
27
28
|
row('mografy dev <project>', 'Open a project in the player'),
|
|
28
29
|
]),
|
|
@@ -36,7 +37,7 @@ export function helpText(color) {
|
|
|
36
37
|
]),
|
|
37
38
|
section('Add', [
|
|
38
39
|
row('mografy add', 'List the reference films, helpers and templates you can add'),
|
|
39
|
-
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)'),
|
|
40
41
|
row('mografy add <helper...> [project]', 'Add helpers to a project: cinema, cjk, three, music, walkthrough, stage'),
|
|
41
42
|
row('mografy add <template...> [project]', 'Add Mografy Templates: hooks, captions, screens, end cards (9:16 and 16:9)'),
|
|
42
43
|
row('', '--force replaces helper and template files you changed'),
|
|
@@ -44,7 +45,6 @@ export function helpText(color) {
|
|
|
44
45
|
section('Manage', [
|
|
45
46
|
row('mografy stop [project]', "Stop a project's player"),
|
|
46
47
|
row('mografy update [--check]', 'Update Mografy, or only check for updates'),
|
|
47
|
-
row('mografy install-command', 'Put the mografy command on PATH'),
|
|
48
48
|
row('mografy setup [ffmpeg|chromium]', 'Download FFmpeg and the Chromium shell now, not on first use'),
|
|
49
49
|
row('mografy setup --check', 'Show which FFmpeg and Chromium exports use'),
|
|
50
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,15 +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 { installIntoProject, updateProjectCopy, useProjectTools } from './project-install.js';
|
|
21
|
+
import { insideFolder, installIntoProject, isWorkspace, updateProjectCopy, useProjectTools, workspaceProjectDir, writeWorkspace } from './project-install.js';
|
|
22
22
|
import { readFile } from 'node:fs/promises';
|
|
23
|
-
import { join, relative } from 'node:path';
|
|
23
|
+
import { basename, join, relative } from 'node:path';
|
|
24
24
|
export { displayPath } from './paths.js';
|
|
25
25
|
export { openBrowser };
|
|
26
26
|
export async function main(argv = process.argv.slice(2)) {
|
|
27
27
|
useProjectTools();
|
|
28
28
|
const { flags, rest } = parse(argv);
|
|
29
|
-
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']);
|
|
30
30
|
const command = rest[0] && commands.has(rest[0]) ? rest.shift() : 'dev';
|
|
31
31
|
const explicit = rest[0] !== undefined;
|
|
32
32
|
if (argv.includes('--help') || argv.includes('-h') || command === 'help') {
|
|
@@ -70,14 +70,6 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
70
70
|
return packageUpdate(flags.updateCheck);
|
|
71
71
|
return updateInstallation(workspaceRoot, flags.updateCheck);
|
|
72
72
|
}
|
|
73
|
-
// Installation must not initialize components or consult a previous project's state.
|
|
74
|
-
if (command === 'install-command') {
|
|
75
|
-
if (installation.kind === 'package') {
|
|
76
|
-
console.log('npm already put the mografy command on PATH.');
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
return installCommand(workspaceRoot);
|
|
80
|
-
}
|
|
81
73
|
if (command === 'add') {
|
|
82
74
|
if (!rest.length) {
|
|
83
75
|
console.log(await addList());
|
|
@@ -97,8 +89,9 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
97
89
|
const dir = explicit
|
|
98
90
|
? command === 'init' ? resolve(rest[0]) : await resolveProjectArg(rest[0])
|
|
99
91
|
: command === 'init'
|
|
100
|
-
// Bare `init`: the
|
|
101
|
-
|
|
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'))
|
|
102
95
|
: configured
|
|
103
96
|
? resolve(configured)
|
|
104
97
|
: await implicitProject(command);
|
|
@@ -114,7 +107,7 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
114
107
|
}
|
|
115
108
|
// `npx mografy@latest` inside a project with its own older copy: move that copy to this version first.
|
|
116
109
|
if (!explicit)
|
|
117
|
-
await updateProjectCopy(dir);
|
|
110
|
+
await updateProjectCopy(workspaceDir() ?? dir);
|
|
118
111
|
await refreshSkill(workspaceRoot);
|
|
119
112
|
skillHint(dir);
|
|
120
113
|
await ensureAgentFiles(dir);
|
|
@@ -135,25 +128,18 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
135
128
|
}
|
|
136
129
|
return dev(dir, flags);
|
|
137
130
|
}
|
|
138
|
-
// `mografy init [folder]`: a new project (agents use it too). From the npm package
|
|
139
|
-
//
|
|
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.
|
|
140
133
|
case 'init': {
|
|
141
|
-
|
|
142
|
-
|
|
134
|
+
if (installation.kind === 'package')
|
|
135
|
+
return initPackage(dir);
|
|
136
|
+
if (await hasProject(dir))
|
|
143
137
|
console.log(`${displayPath(dir)} is already a Mografy project; its scenes and settings stay as they are.`);
|
|
144
138
|
else {
|
|
145
139
|
await createProject(dir);
|
|
146
140
|
console.log(`Created project: ${displayPath(dir)}`);
|
|
147
141
|
}
|
|
148
|
-
|
|
149
|
-
if (await installIntoProject(dir, name)) {
|
|
150
|
-
const folder = relative(process.cwd(), dir);
|
|
151
|
-
const into = folder ? ` cd ${/\s/.test(folder) ? JSON.stringify(folder) : folder}\n` : '';
|
|
152
|
-
console.log(`\nMografy ${VERSION} and its Skill are installed in this project, not globally. Next:\n${into} npx mografy dev open the player (or: npm run dev)\nThen open Claude Code or Codex in this folder and describe the animation.\nTo update later, run \`npx mografy@latest\` in this folder.`);
|
|
153
|
-
}
|
|
154
|
-
else if (installation.kind !== 'package') {
|
|
155
|
-
console.log(`Run \`mografy dev ${displayPath(dir)}\` to open it, then describe the animation to Claude or Codex.`);
|
|
156
|
-
}
|
|
142
|
+
console.log(`Run \`mografy dev ${displayPath(dir)}\` to open it, then describe the animation to Claude or Codex.`);
|
|
157
143
|
return;
|
|
158
144
|
}
|
|
159
145
|
case 'check': return checkProject(dir, flags.motion);
|
|
@@ -172,5 +158,49 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
172
158
|
}
|
|
173
159
|
}
|
|
174
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
|
+
}
|
|
175
205
|
export { HELP };
|
|
176
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);
|
|
@@ -17,7 +17,7 @@ export declare function installIntoProject(dir: string, name: string, log?: (lin
|
|
|
17
17
|
* the project's own copy, or in a project without one.
|
|
18
18
|
*/
|
|
19
19
|
export declare function updateProjectCopy(dir: string, log?: (line: string) => void): Promise<boolean>;
|
|
20
|
-
/** The project whose own copy of Mografy is running (`<
|
|
20
|
+
/** The workspace or project whose own copy of Mografy is running (`<folder>/node_modules/mografy`), if it is one. */
|
|
21
21
|
export declare function runningProject(root?: string, kind?: "package" | "source"): string | undefined;
|
|
22
22
|
/**
|
|
23
23
|
* A project's own copy keeps its tools in the project too, untouched by PATH: FFmpeg downloads into
|
|
@@ -25,3 +25,20 @@ export declare function runningProject(root?: string, kind?: "package" | "source
|
|
|
25
25
|
* a Chromium shell, needed only when there is no Chrome or Edge, goes next to it. Explicit settings still win.
|
|
26
26
|
*/
|
|
27
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>;
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
// (.agents/skills/mografy for Codex and others, .claude/skills/mografy for Claude Code), so nothing is installed
|
|
6
6
|
// globally. A source checkout has no package to install and its own Skill, so it skips both.
|
|
7
7
|
import { spawnSync } from 'node:child_process';
|
|
8
|
-
import { readFile } from 'node:fs/promises';
|
|
9
|
-
import { basename, dirname, join, resolve } from 'node:path';
|
|
8
|
+
import { cp, mkdir, readFile } from 'node:fs/promises';
|
|
9
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
10
10
|
import { existsSync } from 'node:fs';
|
|
11
11
|
import { sharedSkillFiles } from '@mografy/core';
|
|
12
|
-
import { atomicWrite, installation, queueProjectWrite } from '@mografy/server';
|
|
12
|
+
import { atomicWrite, installation, queueProjectWrite, WORKSPACE_FILE } from '@mografy/server';
|
|
13
13
|
import { VERSION } from './commands/help.js';
|
|
14
14
|
import { newerVersion } from './package-update.js';
|
|
15
15
|
/** The scripts a project gets; existing scripts with the same name are kept. */
|
|
@@ -62,7 +62,7 @@ export async function installIntoProject(dir, name, log = (line) => console.log(
|
|
|
62
62
|
await writeProjectSkill(dir);
|
|
63
63
|
await writeProjectManifest(dir, name, spec);
|
|
64
64
|
await ignoreNodeModules(dir);
|
|
65
|
-
log(`Installing ${spec.startsWith('mografy@') ? spec : 'mografy'} into this
|
|
65
|
+
log(`Installing ${spec.startsWith('mografy@') ? spec : 'mografy'} into this folder (not global)…`);
|
|
66
66
|
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
67
67
|
const result = spawnSync(npm, ['install', '--save-dev', '--no-audit', '--no-fund', spec], { cwd: dir, stdio: 'inherit', shell: process.platform === 'win32' });
|
|
68
68
|
if (result.status === 0)
|
|
@@ -85,15 +85,17 @@ export async function updateProjectCopy(dir, log = (line) => console.log(line))
|
|
|
85
85
|
if (!installed || !newerVersion(VERSION, installed))
|
|
86
86
|
return false;
|
|
87
87
|
log(`This project has Mografy ${installed}; updating it to ${VERSION}.`);
|
|
88
|
-
const name = await
|
|
88
|
+
const name = await folderLabel(dir);
|
|
89
|
+
if (isWorkspace(dir))
|
|
90
|
+
await writeWorkspace(dir, name);
|
|
89
91
|
return installIntoProject(dir, name, log);
|
|
90
92
|
}
|
|
91
|
-
/** The project whose own copy of Mografy is running (`<
|
|
93
|
+
/** The workspace or project whose own copy of Mografy is running (`<folder>/node_modules/mografy`), if it is one. */
|
|
92
94
|
export function runningProject(root = installation.root, kind = installation.kind) {
|
|
93
95
|
if (kind !== 'package' || basename(dirname(root)) !== 'node_modules')
|
|
94
96
|
return undefined;
|
|
95
97
|
const project = dirname(dirname(root));
|
|
96
|
-
return existsSync(join(project, 'mografy.json')) ? project : undefined;
|
|
98
|
+
return existsSync(join(project, WORKSPACE_FILE)) || existsSync(join(project, 'mografy.json')) ? project : undefined;
|
|
97
99
|
}
|
|
98
100
|
/**
|
|
99
101
|
* A project's own copy keeps its tools in the project too, untouched by PATH: FFmpeg downloads into
|
|
@@ -109,4 +111,98 @@ export function useProjectTools(env = process.env, project = runningProject()) {
|
|
|
109
111
|
env.PLAYWRIGHT_BROWSERS_PATH ??= join(cache, 'browsers');
|
|
110
112
|
return true;
|
|
111
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
|
+
}
|
|
112
208
|
//# sourceMappingURL=project-install.js.map
|