mirror of
https://github.com/supabase/agent-skills.git
synced 2026-01-26 19:09:51 +08:00
refactor: complete unified build system foundation
- Renamed package from postgres-best-practices-build to skills-build - Moved postgres build logic to src/postgres/ - Added shared types for skill configuration (SkillConfig, SkillType, Resource) - Created skills-config.ts registry for managing multiple skills - Added CLI interface (cli.ts) for validate/build commands - Updated package.json scripts to use new CLI Postgres build verified and working. Ready for supabase module implementation. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
39
packages/skills-build/src/cli.ts
Normal file
39
packages/skills-build/src/cli.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { getAllSkillNames } from "./skills-config.js";
|
||||
import * as postgres from "./postgres/build.js";
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const command = args[0]; // validate or build
|
||||
const skillFlag = args.indexOf("--skill");
|
||||
const specificSkill = skillFlag !== -1 ? args[skillFlag + 1] : null;
|
||||
|
||||
async function main() {
|
||||
if (!command || !["validate", "build"].includes(command)) {
|
||||
console.error("Usage: tsx src/cli.ts <validate|build> [--skill <skill-name>]");
|
||||
console.error("Available skills:", getAllSkillNames().join(", "));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const skillsToProcess = specificSkill ? [specificSkill] : getAllSkillNames();
|
||||
|
||||
console.log(`Running ${command} for skills:`, skillsToProcess.join(", "));
|
||||
|
||||
for (const skillName of skillsToProcess) {
|
||||
if (skillName === "postgres-best-practices") {
|
||||
console.log(`\n[${skillName}] Running ${command}...`);
|
||||
if (command === "build") {
|
||||
await postgres.buildAgents();
|
||||
}
|
||||
// TODO: Add validate support
|
||||
} else if (skillName === "supabase") {
|
||||
console.log(`\n[${skillName}] Skipping (not implemented yet)`);
|
||||
// TODO: Implement supabase build/validate
|
||||
}
|
||||
}
|
||||
|
||||
console.log("\n✅ Done!");
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error("Error:", error);
|
||||
process.exit(1);
|
||||
});
|
||||
34
packages/skills-build/src/skills-config.ts
Normal file
34
packages/skills-build/src/skills-config.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import type { SkillConfig } from "./types.js";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
const BUILD_DIR = join(__dirname, "..");
|
||||
|
||||
export const SKILLS: Record<string, SkillConfig> = {
|
||||
"postgres-best-practices": {
|
||||
name: "postgres-best-practices",
|
||||
type: "rule-based",
|
||||
skillDir: join(BUILD_DIR, "../skills/postgres-best-practices"),
|
||||
agentsOutput: join(BUILD_DIR, "../skills/postgres-best-practices/AGENTS.md"),
|
||||
metadataFile: join(BUILD_DIR, "../skills/postgres-best-practices/metadata.json"),
|
||||
},
|
||||
"supabase": {
|
||||
name: "supabase",
|
||||
type: "reference-based",
|
||||
skillDir: join(BUILD_DIR, "../skills/supabase"),
|
||||
agentsOutput: join(BUILD_DIR, "../skills/supabase/AGENTS.md"),
|
||||
metadataFile: join(BUILD_DIR, "../skills/supabase/metadata.json"),
|
||||
},
|
||||
};
|
||||
|
||||
// Get skill config by name
|
||||
export function getSkillConfig(name: string): SkillConfig | undefined {
|
||||
return SKILLS[name];
|
||||
}
|
||||
|
||||
// Get all skill names
|
||||
export function getAllSkillNames(): string[] {
|
||||
return Object.keys(SKILLS);
|
||||
}
|
||||
@@ -57,3 +57,29 @@ export interface ValidationResult {
|
||||
errors: string[];
|
||||
warnings: string[];
|
||||
}
|
||||
|
||||
// Skill configuration types
|
||||
export type SkillType = "rule-based" | "reference-based";
|
||||
|
||||
export interface SkillConfig {
|
||||
name: string;
|
||||
type: SkillType;
|
||||
skillDir: string;
|
||||
agentsOutput: string;
|
||||
metadataFile: string;
|
||||
}
|
||||
|
||||
// Reference-based skill types (for supabase)
|
||||
export interface Resource {
|
||||
path: string;
|
||||
title: string;
|
||||
content: string;
|
||||
featureArea: string;
|
||||
type: "hub" | "sub-resource";
|
||||
}
|
||||
|
||||
export interface ReferenceParseResult {
|
||||
resource: Resource | null;
|
||||
errors: string[];
|
||||
warnings: string[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user