mirror of
https://github.com/supabase/agent-skills.git
synced 2026-01-26 19:09:51 +08:00
fix format
This commit is contained in:
@@ -7,7 +7,11 @@ import {
|
||||
validateSkillExists,
|
||||
} from "./config.js";
|
||||
import { parseRuleFile } from "./parser.js";
|
||||
import { filterRulesForProfile, listProfiles, loadProfile } from "./profiles.js";
|
||||
import {
|
||||
filterRulesForProfile,
|
||||
listProfiles,
|
||||
loadProfile,
|
||||
} from "./profiles.js";
|
||||
import type { Metadata, Profile, Rule, Section } from "./types.js";
|
||||
import { validateRuleFile } from "./validate.js";
|
||||
|
||||
@@ -118,10 +122,7 @@ function buildSkill(paths: SkillPaths, profile?: Profile): void {
|
||||
// Check if rules directory exists
|
||||
if (!existsSync(paths.rulesDir)) {
|
||||
console.log(` No rules directory found. Generating empty AGENTS.md.`);
|
||||
writeFileSync(
|
||||
outputFile,
|
||||
`# ${skillTitle}\n\nNo rules defined yet.\n`,
|
||||
);
|
||||
writeFileSync(outputFile, `# ${skillTitle}\n\nNo rules defined yet.\n`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -157,7 +158,9 @@ function buildSkill(paths: SkillPaths, profile?: Profile): void {
|
||||
let filteredRules = rules;
|
||||
if (profile) {
|
||||
filteredRules = filterRulesForProfile(rules, profile);
|
||||
console.log(` Filtered to ${filteredRules.length} rules for profile "${profile.name}"`);
|
||||
console.log(
|
||||
` Filtered to ${filteredRules.length} rules for profile "${profile.name}"`,
|
||||
);
|
||||
}
|
||||
|
||||
// Group rules by section and assign IDs
|
||||
@@ -244,7 +247,9 @@ function buildSkill(paths: SkillPaths, profile?: Profile): void {
|
||||
prerequisites.push(`PostgreSQL ${rule.minVersion}+`);
|
||||
}
|
||||
if (rule.extensions && rule.extensions.length > 0) {
|
||||
prerequisites.push(`Extension${rule.extensions.length > 1 ? "s" : ""}: ${rule.extensions.join(", ")}`);
|
||||
prerequisites.push(
|
||||
`Extension${rule.extensions.length > 1 ? "s" : ""}: ${rule.extensions.join(", ")}`,
|
||||
);
|
||||
}
|
||||
if (prerequisites.length > 0) {
|
||||
output.push(`**Prerequisites:** ${prerequisites.join(" | ")}\n`);
|
||||
@@ -302,7 +307,11 @@ function buildSkill(paths: SkillPaths, profile?: Profile): void {
|
||||
/**
|
||||
* Parse CLI arguments
|
||||
*/
|
||||
function parseArgs(): { skill?: string; profile?: string; allProfiles: boolean } {
|
||||
function parseArgs(): {
|
||||
skill?: string;
|
||||
profile?: string;
|
||||
allProfiles: boolean;
|
||||
} {
|
||||
const args = process.argv.slice(2);
|
||||
let skill: string | undefined;
|
||||
let profile: string | undefined;
|
||||
|
||||
@@ -251,7 +251,8 @@ export function parseRuleFile(
|
||||
const examples = extractExamples(body);
|
||||
|
||||
const tags = frontmatter.tags?.split(",").map((t) => t.trim()) || [];
|
||||
const extensions = frontmatter.extensions?.split(",").map((e) => e.trim()) || [];
|
||||
const extensions =
|
||||
frontmatter.extensions?.split(",").map((e) => e.trim()) || [];
|
||||
|
||||
// Validation warnings
|
||||
if (!explanation || explanation.length < 20) {
|
||||
|
||||
@@ -5,7 +5,10 @@ import type { Profile, Rule } from "./types.js";
|
||||
/**
|
||||
* Load a profile from the profiles directory
|
||||
*/
|
||||
export function loadProfile(profilesDir: string, profileName: string): Profile | null {
|
||||
export function loadProfile(
|
||||
profilesDir: string,
|
||||
profileName: string,
|
||||
): Profile | null {
|
||||
const profileFile = join(profilesDir, `${profileName}.json`);
|
||||
if (!existsSync(profileFile)) {
|
||||
return null;
|
||||
@@ -54,14 +57,20 @@ function compareVersions(a: string, b: string): number {
|
||||
/**
|
||||
* Check if a rule is compatible with a profile
|
||||
*/
|
||||
export function isRuleCompatibleWithProfile(rule: Rule, profile: Profile): boolean {
|
||||
export function isRuleCompatibleWithProfile(
|
||||
rule: Rule,
|
||||
profile: Profile,
|
||||
): boolean {
|
||||
// Check version requirement
|
||||
if (rule.minVersion) {
|
||||
if (compareVersions(rule.minVersion, profile.minVersion) > 0) {
|
||||
// Rule requires a higher version than profile supports
|
||||
return false;
|
||||
}
|
||||
if (profile.maxVersion && compareVersions(rule.minVersion, profile.maxVersion) > 0) {
|
||||
if (
|
||||
profile.maxVersion &&
|
||||
compareVersions(rule.minVersion, profile.maxVersion) > 0
|
||||
) {
|
||||
// Rule requires a version higher than profile's max
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ export interface Rule {
|
||||
references?: string[];
|
||||
tags?: string[];
|
||||
supabaseNotes?: string;
|
||||
minVersion?: string; // Minimum PostgreSQL version required (e.g., "11", "14")
|
||||
extensions?: string[]; // Required PostgreSQL extensions (e.g., ["pg_stat_statements"])
|
||||
minVersion?: string; // Minimum PostgreSQL version required (e.g., "11", "14")
|
||||
extensions?: string[]; // Required PostgreSQL extensions (e.g., ["pg_stat_statements"])
|
||||
}
|
||||
|
||||
export interface Section {
|
||||
|
||||
Reference in New Issue
Block a user