stoa/packages/skills/scripts/gen-catalog.ts
stoa df91ac630d feat(web+structure): Stoa web app (pages+APIs) vendored from x402, plan.md buildout
- apps/web: Next.js dashboard — pages (/, /skills, /marketplace, /protected) + API routes
  (/api/health, /api/skills, /api/services, /api/x402/weather) adapted from the real x402
  next fullstack example; reads a generated static skills catalog (251 skills, 62 domains)
- generated skills.json catalog (gen-catalog now emits JSON for web + tooling)
- contracts: interfaces/, libraries/ (SafeTransferLib, SignatureLib, StoaTypes), mocks/,
  DeployAtlantic/DeployLocal/ExportAbis scripts — all compile
- sdk: types, errors, addresses, chains, abis modules (wired into barrel; 0 tsc errors)
- mercator: planner (seller scoring), scenario, trace, wallet, demo runners
- examples: numbered demos (05-08,10) + x402 seller server
- config/docs: turbo.json, .prettierrc, eslint.config.js, SUBMISSION.md,
  docs/HACKATHON_SUBMISSION.md, deployments/{pharos-atlantic,localhost}.json
- oss/ (gitignored): cloned x402, pharos-agent-kit, pharos-examples, pharos-skill-engine
2026-06-12 01:03:39 +03:00

57 lines
2.0 KiB
TypeScript

/**
* Generate docs/SKILLS.md from the live skill registry.
* Run: pnpm --filter @stoa/skills exec tsx scripts/gen-catalog.ts
*/
import { writeFileSync } from "node:fs";
import { actionGroups, actions } from "../src/index.js";
const lines: string[] = [];
lines.push("# Stoa Skill Catalog");
lines.push("");
lines.push(`> Auto-generated from the skill registry. **${actions.length} skills** across ` +
`${Object.keys(actionGroups).length} domains.`);
lines.push("");
for (const [group, acts] of Object.entries(actionGroups)) {
lines.push(`## ${group} (${acts.length})`);
lines.push("");
lines.push("| Skill | Description |");
lines.push("|-------|-------------|");
for (const a of acts) {
const desc = a.description.replace(/\n/g, " ").replace(/\|/g, "\\|");
lines.push(`| \`${a.name}\` | ${desc} |`);
}
lines.push("");
}
writeFileSync(new URL("../../../docs/SKILLS.md", import.meta.url), lines.join("\n"));
// Also emit a structured JSON catalog consumed by the web app (apps/web) and other tooling,
// so consumers don't need to import/build @stoa/skills at runtime.
const firstSentence = (s: string): string => {
const cleaned = s.replace(/\n/g, " ").trim();
const dot = cleaned.indexOf(". ");
return dot === -1 ? cleaned : cleaned.slice(0, dot + 1);
};
const catalog = {
totalSkills: actions.length,
totalDomains: Object.keys(actionGroups).length,
domains: Object.entries(actionGroups).map(([domain, acts]) => ({
domain,
count: acts.length,
skills: acts.map((a) => ({ name: a.name, description: firstSentence(a.description) })),
})),
};
const json = JSON.stringify(catalog, null, 2);
writeFileSync(new URL("../generated/skills.json", import.meta.url), json);
// Mirror into the web app so it has a zero-dependency, static data source.
try {
writeFileSync(new URL("../../../apps/web/lib/skills-catalog.json", import.meta.url), json);
} catch {
// apps/web may not exist in all checkouts; ignore.
}
console.log(`Wrote docs/SKILLS.md + generated/skills.json — ${actions.length} skills.`);