The design language that makes your AI harness better at design.
JavaScript
Fix Vercel API endpoints for unified skills directory structure
Paul Bakausc0ba2b8124fc
diff --git a/api/commands.js b/api/commands.jsindex 2f36b1639..24e429c2b 100644--- a/api/commands.js+++ b/api/commands.js@@ -1,4 +1,4 @@-import { readdirSync, readFileSync } from "fs";+import { readdirSync, readFileSync, statSync, existsSync } from "fs";import { join, dirname } from "path";import { fileURLToPath } from "url";@@ -8,28 +8,34 @@ const PROJECT_ROOT = join(__dirname, "..");export default function handler(req, res) {try {- const sourceDir = join(PROJECT_ROOT, "source");- const commandsDir = join(sourceDir, "commands");+ const skillsDir = join(PROJECT_ROOT, "source", "skills");- const files = readdirSync(commandsDir);+ const entries = readdirSync(skillsDir);const commands = [];- for (const file of files) {- if (file.endsWith(".md")) {- const content = readFileSync(join(commandsDir, file), "utf-8");- const frontmatterMatch = content.match(/^---\n([\s\S]+?)\n---/);-- if (frontmatterMatch) {- const frontmatter = frontmatterMatch[1];- const nameMatch = frontmatter.match(/name:\s*(.+)/);- const descMatch = frontmatter.match(/description:\s*(.+)/);-- commands.push({- id: file.replace(".md", ""),- name: nameMatch?.[1]?.trim() || file.replace(".md", ""),- description: descMatch?.[1]?.trim() || "No description available",- });- }+ for (const entry of entries) {+ const entryPath = join(skillsDir, entry);+ if (!statSync(entryPath).isDirectory()) continue;++ const skillMd = join(entryPath, "SKILL.md");+ if (!existsSync(skillMd)) continue;++ const content = readFileSync(skillMd, "utf-8");+ const frontmatterMatch = content.match(/^---\n([\s\S]+?)\n---/);++ if (frontmatterMatch) {+ const frontmatter = frontmatterMatch[1];+ const userInvokable = /user-invokable:\s*true/.test(frontmatter);+ if (!userInvokable) continue;++ const nameMatch = frontmatter.match(/name:\s*(.+)/);+ const descMatch = frontmatter.match(/description:\s*(.+)/);++ commands.push({+ id: entry,+ name: nameMatch?.[1]?.trim() || entry,+ description: descMatch?.[1]?.trim() || "No description available",+ });}}diff --git a/api/skills.js b/api/skills.jsindex 355f4c78b..788f9effb 100644--- a/api/skills.js+++ b/api/skills.js@@ -1,4 +1,4 @@-import { readdirSync, readFileSync } from "fs";+import { readdirSync, readFileSync, statSync, existsSync } from "fs";import { join, dirname } from "path";import { fileURLToPath } from "url";@@ -8,28 +8,31 @@ const PROJECT_ROOT = join(__dirname, "..");export default function handler(req, res) {try {- const sourceDir = join(PROJECT_ROOT, "source");- const skillsDir = join(sourceDir, "skills");+ const skillsDir = join(PROJECT_ROOT, "source", "skills");- const files = readdirSync(skillsDir);+ const entries = readdirSync(skillsDir);const skills = [];- for (const file of files) {- if (file.endsWith(".md")) {- const content = readFileSync(join(skillsDir, file), "utf-8");- const frontmatterMatch = content.match(/^---\n([\s\S]+?)\n---/);-- if (frontmatterMatch) {- const frontmatter = frontmatterMatch[1];- const nameMatch = frontmatter.match(/name:\s*(.+)/);- const descMatch = frontmatter.match(/description:\s*(.+)/);-- skills.push({- id: file.replace(".md", ""),- name: nameMatch?.[1]?.trim() || file.replace(".md", ""),- description: descMatch?.[1]?.trim() || "No description available",- });- }+ for (const entry of entries) {+ const entryPath = join(skillsDir, entry);+ if (!statSync(entryPath).isDirectory()) continue;++ const skillMd = join(entryPath, "SKILL.md");+ if (!existsSync(skillMd)) continue;++ const content = readFileSync(skillMd, "utf-8");+ const frontmatterMatch = content.match(/^---\n([\s\S]+?)\n---/);++ if (frontmatterMatch) {+ const frontmatter = frontmatterMatch[1];+ const nameMatch = frontmatter.match(/name:\s*(.+)/);+ const descMatch = frontmatter.match(/description:\s*(.+)/);++ skills.push({+ id: entry,+ name: nameMatch?.[1]?.trim() || entry,+ description: descMatch?.[1]?.trim() || "No description available",+ });}}@@ -39,4 +42,3 @@ export default function handler(req, res) {res.status(500).json({ error: error.message });}}-diff --git a/vercel.json b/vercel.jsonindex 0810af773..c6b2360c2 100644--- a/vercel.json+++ b/vercel.json@@ -4,7 +4,7 @@"outputDirectory": "build","functions": {"api/**/*.js": {- "includeFiles": "source/**,dist/**"+ "includeFiles": "source/**,dist/**,scripts/**"}},"rewrites": [