mirror of
https://github.com/nexu-io/openmotion.git
synced 2026-12-06 04:50:09 +08:00
* feat(library): add growth teardown skill Add the optional openmotion-growth-teardown library Skill. It turns a company name into a sourced growth-map film: a research method for dated growth moves and metric points, the growth.json contract with a validator, an evidence collector (cropped page screenshots, video thumbnails and thumbnail walls, favicons, sitemap list cards), a generator for an editable nine-scene HyperFrames project and a deterministic cue-synchronized score with no third-party audio. Register the Skill in the distribution lists, the standalone library installer and the package tests, and document it in the library index, Skill routing, product architecture and change record. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(library): correct growth teardown build input and number formatting Build from evidence/growth.json so collected images, walls and logos reach the film, keep integer zeros when compacting large values ($10B no longer renders as $1B), and detect the standalone score entry point with fileURLToPath so encoded or Windows paths still write audio. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(library): make growth teardown projects rebuildable Rewrite image, wall and logo paths in the project's growth.json to the copied assets so out/ rebuilds on its own, key thumbnail-wall cache files by video id so a changed query never reuses stale thumbnails, and validate metric point order with the same date parsing the curve uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(library): support standalone growth teardown installs Resolve GSAP from OPENMOTION_HOME as well as the working directory and explain the fix when it is missing, and rewrite existing logo, evidence and wall paths relative to the evidence output so later builds find them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(library): brand growth teardown films as OpenMotion Open each film with the OpenMotion wordmark, lead every scene headline with the OpenMotion mark and sign the outro with the wordmark, while the analysed company keeps its own logo. Read the marks from the design system in a checkout and ship unchanged copies for standalone installs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(studio): list growth teardown on the Skills page Add the growth teardown as an OpenMotion-authored skill under Explainers, with a cover excerpt rendered by the Skill and copy in all supported interface languages. Its detail shows the OpenMotion skill source instead of an upstream repository, and the copied instruction names the OpenMotion skill. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(studio): name the growth teardown card for companies Rename the Skills page card to "Company growth teardown" in every interface language so the card says what it analyses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(studio): name the growth skill card growth reverse-engineering Use "Growth reverse-engineering" for the Skills page card in English and matching names in every other interface language. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(studio): list growth reverse-engineering second on the Skills page Move the OpenMotion growth skill directly after the motionmaxxing entry and pin that order in the Skills page test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(studio): fill the Skills gallery row first Distribute Skills cards across columns in catalog order (card N goes to column N % columns), using the same width breakpoints as before, so the first row reads left to right in catalog order while columns keep their staggered heights. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(growth-teardown): address review notes on validation, stat, docs and card order - --check now requires 1-6 moves per lane and full http(s) source URLs, and requires plays[].stat.value, so these inputs fail with a message instead of crashing the build or rendering "undefined". - Enforce the documented limits: label <= 28, instruction <= 220. - Chinese library README, docs/skills.md and the architecture inventory now name four canonical Library Skills including growth teardown. - Skills page keeps cards in one catalog-ordered DOM list for keyboard and screen readers; measured heights place card N in column N % columns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(growth-teardown): generate brand mirrors and translate the source label - Add the Skill's two brand marks to the design-token mirrors, so npm run design:tokens refreshes them and npm run check fails on drift. - Add the 'OpenMotion skill' source label to all ten Skills UI locales and assert it exists while any Skill has no upstream repository. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: zhanghuihua <zhanghuihua@huihuideMacBook-Pro.local> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: zhanghuihua <zhanghuihua@Mac.lan>
100 lines
5.9 KiB
JavaScript
100 lines
5.9 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import { cp, lstat, mkdir, mkdtemp, readFile, readdir, rename, rm } from 'node:fs/promises';
|
|
import { createHash } from 'node:crypto';
|
|
import { fileURLToPath } from 'node:url';
|
|
import path from 'node:path';
|
|
import { isDeepStrictEqual } from 'node:util';
|
|
import { validateMediaManifest } from '../shared/repository-media.ts';
|
|
|
|
const source = fileURLToPath(new URL('../library/skills/', import.meta.url));
|
|
// Frozen fingerprints identify only the retired, unmodified forwarding folders.
|
|
// Standalone installs have no ownership marker; never remove a folder by name alone.
|
|
const retired = {
|
|
'openmotion-brandkit': { name: 'brandkit', files: {
|
|
'SKILL.md': 'baa4d65961044ca2270046e370612283d3506b8f4edd40d3389403f3b3f9b2d7',
|
|
[path.join('agents', 'openai.yaml')]: '6e52c9f977f57f04230ed5d626813b089dee5bac66a415875c96b574ef849e66',
|
|
} },
|
|
'openmotion-presenter-story': { name: 'presenter-story', files: {
|
|
'SKILL.md': '0013c1a3b460aafc740313dcfa9fcb2655b5221ca951d482163de1ef623f9fdf',
|
|
[path.join('agents', 'openai.yaml')]: '48c3e961a7d04c901bf8d8f00b2dd6fe36ee8ed24bbb6751d450d38e4cb9d292',
|
|
} },
|
|
'openmotion-design-remix': { name: 'motion-design-remix', files: {
|
|
'SKILL.md': 'cd3be67e615d05fa097166709ffabb932ab929cc685b852660c09f70da3f91ba',
|
|
[path.join('agents', 'openai.yaml')]: '53ba8d5b90b65f9b163607acb68367c7f0355e7315175bb6ff2aad864c3cfe1e',
|
|
} },
|
|
};
|
|
// Library Skills that never shipped a retired forwarding folder.
|
|
const current = ['openmotion-growth-teardown'];
|
|
async function snapshot(directory, relative = '') {
|
|
const files = {};
|
|
for (const item of await readdir(path.join(directory, relative), { withFileTypes: true })) {
|
|
const name = path.join(relative, item.name);
|
|
assert(!item.isSymbolicLink(), 'Skill installation requires regular files: ' + name);
|
|
if (item.isDirectory()) Object.assign(files, await snapshot(directory, name));
|
|
else {
|
|
assert(item.isFile(), 'Unsupported Skill entry: ' + name);
|
|
const bytes = await readFile(path.join(directory, name));
|
|
assert(!bytes.subarray(0, 128).toString().startsWith('version https://git-lfs.github.com/spec/v1'),
|
|
'Skill media is not downloaded. Run git lfs pull --include="library/skills/**" --exclude="" before installing a Library Skill.');
|
|
files[name] = createHash('sha256').update(bytes).digest('hex');
|
|
}
|
|
}
|
|
return files;
|
|
}
|
|
|
|
// The destination is explicit; user-owned or different-version content is never overwritten.
|
|
export async function installLibrarySkill(name, destination) {
|
|
assert(Object.hasOwn(retired, name) || current.includes(name), 'Unknown Library Skill: ' + name + '. Use an openmotion-* Library Skill name.');
|
|
const canonical = name;
|
|
assert(destination, 'An explicit destination skills directory is required');
|
|
const media = validateMediaManifest(JSON.parse(await readFile(new URL('../repository-media.json', import.meta.url), 'utf8')));
|
|
for (const file of media.files.filter(file => file.path.startsWith('library/skills/' + canonical + '/'))) {
|
|
const bytes = await readFile(new URL('../' + file.path, import.meta.url)).catch(() => {
|
|
throw new Error('Optional Skill media is missing. Run npm run media:pull -- library/skills/' + canonical);
|
|
});
|
|
assert(bytes.length === file.bytes && createHash('sha256').update(bytes).digest('hex') === file.sha256, 'Optional Skill media does not match repository-media.json');
|
|
}
|
|
const directory = path.resolve(destination), names = [canonical];
|
|
await mkdir(directory, { recursive: true });
|
|
const missing = [];
|
|
for (const skill of names) {
|
|
const target = path.join(directory, skill), expected = await snapshot(path.join(source, skill));
|
|
const present = await lstat(target).catch(error => { if (error.code !== 'ENOENT') throw error; });
|
|
if (present) {
|
|
assert(present.isDirectory() && !present.isSymbolicLink(), 'Skill destination must be a regular directory: ' + target);
|
|
assert.deepEqual(await snapshot(target), expected, 'Existing Skill differs; preserve it and choose another destination: ' + target);
|
|
} else missing.push(skill);
|
|
}
|
|
const legacy = retired[canonical] ?? null, legacyTarget = legacy && path.join(directory, legacy.name);
|
|
const present = legacy && await lstat(legacyTarget).catch(error => { if (error.code !== 'ENOENT') throw error; });
|
|
let removeLegacy = false;
|
|
if (present?.isDirectory() && !present.isSymbolicLink()) {
|
|
try { removeLegacy = isDeepStrictEqual(await snapshot(legacyTarget), legacy.files); }
|
|
catch (error) { if (error.code !== 'ERR_ASSERTION') throw error; }
|
|
}
|
|
const staging = await mkdtemp(path.join(directory, '.openmotion-install-'));
|
|
const backup = path.join(staging, 'retired');
|
|
let movedLegacy = false, preserveBackup = false;
|
|
try {
|
|
for (const skill of missing) await cp(path.join(source, skill), path.join(staging, skill), { recursive: true, force: false, errorOnExist: true });
|
|
if (removeLegacy) { await rename(legacyTarget, backup); movedLegacy = true; }
|
|
for (const skill of missing) await rename(path.join(staging, skill), path.join(directory, skill));
|
|
} catch (error) {
|
|
if (movedLegacy) {
|
|
try { await rename(backup, legacyTarget); }
|
|
catch (restoreError) {
|
|
preserveBackup = true;
|
|
throw new AggregateError([error, restoreError], 'Legacy Skill backup retained at ' + backup);
|
|
}
|
|
}
|
|
throw error;
|
|
} finally { if (!preserveBackup) await rm(staging, { recursive: true, force: true }); }
|
|
return { canonical, entry: path.join(directory, canonical, 'SKILL.md'), installed: names,
|
|
removedLegacy: removeLegacy ? [legacy.name] : [], preservedLegacy: present && !removeLegacy ? [legacy.name] : [] };
|
|
}
|
|
|
|
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
assert.equal(process.argv.length, 4, 'Usage: node scripts/install-library-skill.mjs <skill-name> <destination-skills-directory>');
|
|
console.log(JSON.stringify(await installLibrarySkill(process.argv[2], process.argv[3])));
|
|
}
|