mirror of
https://github.com/garrytan/gstack.git
synced 2026-07-13 03:06:36 +02:00
fix: make skill/template discovery dynamic
Replace hardcoded SKILL_FILES and TEMPLATES arrays in skill-check.ts, gen-skill-docs.ts, and dev-skill.ts with a shared discover-skills.ts utility that scans the filesystem. New skills are now picked up automatically without updating three separate lists. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Shared discovery for SKILL.md and .tmpl files.
|
||||
* Scans root + one level of subdirs, skipping node_modules/.git/dist.
|
||||
*/
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
const SKIP = new Set(['node_modules', '.git', 'dist']);
|
||||
|
||||
function subdirs(root: string): string[] {
|
||||
return fs.readdirSync(root, { withFileTypes: true })
|
||||
.filter(d => d.isDirectory() && !SKIP.has(d.name))
|
||||
.map(d => d.name);
|
||||
}
|
||||
|
||||
export function discoverTemplates(root: string): Array<{ tmpl: string; output: string }> {
|
||||
const dirs = ['', ...subdirs(root)];
|
||||
const results: Array<{ tmpl: string; output: string }> = [];
|
||||
for (const dir of dirs) {
|
||||
const rel = dir ? `${dir}/SKILL.md.tmpl` : 'SKILL.md.tmpl';
|
||||
if (fs.existsSync(path.join(root, rel))) {
|
||||
results.push({ tmpl: rel, output: rel.replace(/\.tmpl$/, '') });
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
export function discoverSkillFiles(root: string): string[] {
|
||||
const dirs = ['', ...subdirs(root)];
|
||||
const results: string[] = [];
|
||||
for (const dir of dirs) {
|
||||
const rel = dir ? `${dir}/SKILL.md` : 'SKILL.md';
|
||||
if (fs.existsSync(path.join(root, rel))) {
|
||||
results.push(rel);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
Reference in New Issue
Block a user