- Adicionado estrutura completa do projeto - Configurado MCP server para Premiere Pro - Adicionado documentação e skills - Configurado Gitignore para o projeto
32 lines
7.1 KiB
JavaScript
Executable File
32 lines
7.1 KiB
JavaScript
Executable File
import { createHash } from "node:crypto";
|
|
import { readFile, writeFile } from "node:fs/promises";
|
|
import { dirname, relative, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import ts from "typescript";
|
|
|
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
const stablePath = process.env.PREMIERE_BETA_POINTF_STABLE_DECLARATIONS_PATH ? resolve(process.env.PREMIERE_BETA_POINTF_STABLE_DECLARATIONS_PATH) : resolve(root, "node_modules/@adobe/premierepro/src/premierepro.d.ts");
|
|
const betaPath = process.env.PREMIERE_BETA_POINTF_BETA_DECLARATIONS_PATH ? resolve(process.env.PREMIERE_BETA_POINTF_BETA_DECLARATIONS_PATH) : resolve(root, "node_modules/@adobe/premierepro-beta/src/premierepro.d.ts");
|
|
const outputPath = resolve(root, "src/resources/adobe-beta-pointf-drift.json");
|
|
const normalize = (text) => text.replaceAll("\r\n", "\n").replace(/\s+/g, " ").trim();
|
|
const compare = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
const parse = (text, path) => { const source = ts.createSourceFile(path, text, ts.ScriptTarget.Latest, true); if (source.parseDiagnostics.length) throw new Error(`Adobe PointF declaration parse failed: ${source.parseDiagnostics.map((item) => ts.flattenDiagnosticMessageText(item.messageText, " ")).join("; ")}`); return source; };
|
|
const literal = (source, name) => { const declaration = source.statements.find((item) => ts.isTypeAliasDeclaration(item) && item.name.text === name); if (!declaration || !ts.isTypeLiteralNode(declaration.type)) throw new Error(`Adobe declarations must expose ${name} as a type literal.`); return declaration; };
|
|
const binding = (rootDeclaration, source) => { const member = rootDeclaration.type.members.find((item) => ts.isPropertySignature(item) && item.name && ts.isIdentifier(item.name) && item.name.text === "PointF"); if (!member?.type) throw new Error("Adobe declarations must expose premierepro.PointF as a typed property."); return { symbol: "premierepro.PointF", kind: "property", signature: normalize(member.type.getText(source)) }; };
|
|
const factories = (declaration, source, owner) => declaration.type.members.filter((item) => ts.isConstructSignatureDeclaration(item) || ts.isCallSignatureDeclaration(item)).map((item) => { if (!item.type) throw new Error(`Adobe ${owner} factory signature is missing a return type.`); return { symbol: `${owner}.${ts.isConstructSignatureDeclaration(item) ? "new" : "call"}`, kind: ts.isConstructSignatureDeclaration(item) ? "construct_signature" : "call_signature", signature: `(${item.parameters.map((parameter) => normalize(parameter.getText(source))).join(", ")}) => ${normalize(item.type.getText(source))}` }; }).sort((left, right) => compare(left.symbol, right.symbol));
|
|
const nonFactories = (declaration, source) => declaration.type.members.filter((item) => !ts.isConstructSignatureDeclaration(item) && !ts.isCallSignatureDeclaration(item)).map((item) => normalize(item.getText(source))).sort(compare);
|
|
const [stablePackageText, betaPackageText, stableText, betaText] = await Promise.all([readFile(resolve(root, "node_modules/@adobe/premierepro/package.json"), "utf8"), readFile(resolve(root, "node_modules/@adobe/premierepro-beta/package.json"), "utf8"), readFile(stablePath, "utf8"), readFile(betaPath, "utf8")]);
|
|
const stable = parse(stableText, stablePath), beta = parse(betaText, betaPath), stableRoot = literal(stable, "premierepro"), betaRoot = literal(beta, "premierepro"), stablePoint = literal(stable, "PointF"), betaPoint = literal(beta, "PointF"), betaStatic = literal(beta, "PointFStatic"), stableBinding = binding(stableRoot, stable), betaBinding = binding(betaRoot, beta), stableFactories = factories(stablePoint, stable, "PointF"), betaFactories = factories(betaStatic, beta, "PointFStatic");
|
|
if (stable.statements.some((item) => ts.isTypeAliasDeclaration(item) && item.name.text === "PointFStatic")) throw new Error("Pinned stable declarations unexpectedly expose PointFStatic.");
|
|
if (stableBinding.signature !== "PointF" || betaBinding.signature !== "PointFStatic") throw new Error("Adobe beta declarations must move premierepro.PointF to PointFStatic.");
|
|
const stableShapes = stableFactories.map(({ kind, signature }) => ({ kind, signature })), betaShapes = betaFactories.map(({ kind, signature }) => ({ kind, signature }));
|
|
if (stableFactories.length !== 2 || betaFactories.length !== 2 || JSON.stringify(stableShapes) !== JSON.stringify(betaShapes)) throw new Error("Adobe beta PointFStatic factory signatures must match stable PointF.");
|
|
if (JSON.stringify(nonFactories(stablePoint, stable)) !== JSON.stringify(nonFactories(betaPoint, beta))) throw new Error("Adobe beta PointF non-factory members must match stable PointF.");
|
|
if (factories(betaPoint, beta, "PointF").length) throw new Error("Adobe beta PointF must not retain factory signatures after the static-type migration.");
|
|
const hash = (declaration, source) => createHash("sha256").update(normalize(declaration.getText(source))).digest("hex");
|
|
const inventory = { schemaVersion: 1, scope: { declarations: ["premierepro.PointF", "PointF", "PointFStatic"], semantics: "This records the beta PointF factory-type migration against the pinned stable package. It is static declaration-drift accounting, not beta API support or a complete package diff.", doesNotEstablish: "It does not prove a beta host exposes PointFStatic, that a PointF can be constructed or accepted by another API, that point arithmetic or component-parameter behavior is preserved, or that any MCP action is supported or licensed-host validated." }, sources: { stable: { package: "@adobe/premierepro", version: JSON.parse(stablePackageText).version, declarations: relative(root, stablePath).replaceAll("\\", "/"), pointDeclarationSha256: hash(stablePoint, stable), staticFactoryPresent: false }, beta: { package: "@adobe/premierepro-beta", version: JSON.parse(betaPackageText).version, declarations: relative(root, betaPath).replaceAll("\\", "/"), pointDeclarationSha256: hash(betaPoint, beta), staticDeclarationSha256: hash(betaStatic, beta), staticFactoryPresent: true } }, diff: { betaOnly: [{ symbol: "PointFStatic", kind: "type", signature: normalize(betaStatic.type.getText(beta)) }, ...betaFactories].sort((left, right) => compare(left.symbol, right.symbol)), stableOnly: [], changed: [{ symbol: "premierepro.PointF", stable: stableBinding, beta: betaBinding }, { symbol: "PointF.factorySignatures", stable: { owner: "PointF", entries: stableShapes }, beta: { owner: "PointFStatic", entries: betaShapes } }] } };
|
|
const rendered = `${JSON.stringify(inventory, null, 2)}\n`;
|
|
if (process.argv.includes("--validate-only")) console.log("Validated Adobe beta PointF declaration drift.");
|
|
else if (process.argv.includes("--check")) { let current = ""; try { current = await readFile(outputPath, "utf8"); } catch {} if (current.replaceAll("\r\n", "\n") !== rendered) { console.error("Adobe beta PointF declaration drift inventory is stale. Run npm run adobe:beta-pointf-drift."); process.exitCode = 1; } else console.log("Adobe beta PointF declaration drift inventory is current: 3 beta-only and 2 changed symbols."); }
|
|
else { await writeFile(outputPath, rendered); console.log("Wrote Adobe beta PointF declaration drift inventory: 3 beta-only and 2 changed symbols."); }
|