Files
vercel__vercel-plugin/hooks/registry-skill-metadata.mjs
John Lindquist 8d4fda5a60 refactor: complete engine-native orchestrator flow
Align the shipped architecture around engine-native rules and the zero-bundle
runtime so orchestration, documentation, and maintenance all reflect the
same source of truth.

Remove the pre-engine build and template pipeline to eliminate dead paths
that were masking drift and making test failures harder to reason about.

Make session-start installation honor registry-backed skills accurately,
including per-registry grouping and alias slugs, so first-session cache
warming can produce a usable zero-bundle cache instead of leaving mapped
skills unresolved.

Update doctor coverage and supporting tests so the orchestrator branch
catches hook-registration regressions and cache-resolution mistakes before
release.

Ploop-Iter: 1
2026-04-02 04:32:53 -06:00

47 lines
1.6 KiB
JavaScript

// hooks/src/registry-skill-metadata.mts
import { existsSync, readFileSync } from "fs";
import { join } from "path";
import { pluginRoot as resolvePluginRoot } from "./hook-env.mjs";
function loadRegistrySkillMetadata(rootDir = resolvePluginRoot()) {
const metadata = /* @__PURE__ */ new Map();
const manifestPaths = [
join(rootDir, "generated", "skill-rules.json"),
join(rootDir, "..", "generated", "skill-rules.json")
];
const manifestPath = manifestPaths.find((candidate) => existsSync(candidate));
if (!manifestPath) {
return metadata;
}
try {
const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
for (const [skill, raw] of Object.entries(manifest.skills ?? {})) {
if (typeof raw.registry !== "string" || raw.registry.trim() === "") continue;
metadata.set(skill, {
registry: raw.registry,
registrySlug: typeof raw.registrySlug === "string" && raw.registrySlug.trim() !== "" ? raw.registrySlug : skill
});
}
} catch {
return metadata;
}
return metadata;
}
function buildRegistryAliasMap(rootDir = resolvePluginRoot()) {
const aliases = /* @__PURE__ */ new Map();
for (const [skill, metadata] of loadRegistrySkillMetadata(rootDir)) {
if (metadata.registrySlug !== skill) {
aliases.set(metadata.registrySlug, skill);
}
}
return aliases;
}
function canonicalizeInstalledSkillNames(skillNames, rootDir = resolvePluginRoot()) {
const aliases = buildRegistryAliasMap(rootDir);
return [...new Set(skillNames.map((skill) => aliases.get(skill) ?? skill))].sort();
}
export {
buildRegistryAliasMap,
canonicalizeInstalledSkillNames,
loadRegistrySkillMetadata
};