Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
},
"metadata": {
"description": "Syncable CLI skills for AI coding agents — project analysis, security, vulnerabilities, dependencies, IaC validation, and cloud deployment.",
"version": "0.1.0"
"version": "0.1.8"
},
"plugins": [
{
"name": "syncable-cli-skills",
"source": "./installer/plugins/syncable-cli-skills",
"description": "Syncable CLI skills for project analysis, security scanning, vulnerability detection, dependency auditing, IaC validation, Kubernetes optimization, and cloud deployment.",
"version": "0.1.0",
"version": "0.1.8",
"author": {
"name": "Syncable",
"email": "support@syncable.dev"
Expand Down
2 changes: 1 addition & 1 deletion installer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "syncable-cli-skills",
"version": "0.1.5",
"version": "0.1.8",
"type": "module",
"description": "Install Syncable CLI skills for AI coding agents (Claude Code, Cursor, Windsurf, Codex, Gemini CLI)",
"license": "GPL-3.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "syncable-cli-skills",
"description": "Syncable CLI skills for project analysis, security scanning, vulnerability detection, dependency auditing, IaC validation, Kubernetes optimization, and cloud deployment.",
"version": "0.1.0",
"version": "0.1.8",
"author": {
"name": "Syncable",
"email": "support@syncable.dev"
Expand Down
52 changes: 49 additions & 3 deletions installer/scripts/copy-skills.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pkg from 'fs-extra';
const { copySync, removeSync, existsSync } = pkg;
import { resolve, dirname } from 'path';
const { copySync, removeSync, existsSync, mkdirpSync, writeFileSync, readdirSync, readFileSync } = pkg;
import { resolve, dirname, basename } from 'path';
import { fileURLToPath } from 'url';

const __dirname = dirname(fileURLToPath(import.meta.url));
Expand All @@ -12,7 +12,53 @@ if (!existsSync(source)) {
process.exit(1);
}

// Copy raw skills to installer/skills/ (used by the npm package at runtime)
removeSync(dest);
copySync(source, dest);

console.log(`Copied skills from ${source} to ${dest}`);

// Also regenerate installer/plugins/syncable-cli-skills/skills/
// so the Claude Code marketplace plugin stays in sync with the source skills.
const pluginSkillsDir = resolve(__dirname, '..', 'plugins', 'syncable-cli-skills', 'skills');
removeSync(pluginSkillsDir);

function transformSkillFile(filePath) {
const raw = readFileSync(filePath, 'utf-8');
// Parse YAML frontmatter (---\n...\n---\n)
const match = raw.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
if (!match) return null;

const frontmatterRaw = match[1];
const body = match[2];

// Extract description value (handles multi-line descriptions with quotes)
const descMatch = frontmatterRaw.match(/^description:\s*(.+)$/m);
if (!descMatch) return null;

const desc = descMatch[1].trim().replace(/^["']|["']$/g, '');
const safeDesc = desc.replace(/"/g, '\\"');

return `---\ndescription: "${safeDesc}"\n---\n${body}`;
}

let skillCount = 0;
for (const category of ['commands', 'workflows']) {
const categoryDir = resolve(source, category);
if (!existsSync(categoryDir)) continue;

for (const file of readdirSync(categoryDir)) {
if (!file.endsWith('.md')) continue;
const skillName = basename(file, '.md');
const content = transformSkillFile(resolve(categoryDir, file));
if (!content) {
console.warn(`Warning: could not parse frontmatter for ${file}, skipping`);
continue;
}
const outDir = resolve(pluginSkillsDir, skillName);
mkdirpSync(outDir);
writeFileSync(resolve(outDir, 'SKILL.md'), content);
skillCount++;
}
}

console.log(`Generated ${skillCount} plugin skills at ${pluginSkillsDir}`);
50 changes: 28 additions & 22 deletions installer/src/transformers/claude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { TransformResult } from './types.js';
import { execCommand, commandExists } from '../utils.js';

const PLUGIN_NAME = 'syncable-cli-skills';
const PLUGIN_VERSION = '0.1.0';
const PLUGIN_VERSION = '0.1.8';
const MARKETPLACE_NAME = 'syncable';
const MARKETPLACE_REPO = 'syncable-dev/syncable-cli';

Expand All @@ -19,8 +19,6 @@ export function transformForClaude(skill: Skill): TransformResult[] {

const safeDesc = skill.frontmatter.description
.replace(/"/g, '\\"')
.replace(/: /g, ' - ')
.replace(/Trigger on:.*$/, '')
.trim();

const content = `---\ndescription: "${safeDesc}"\n---\n\n${skill.body}`;
Expand Down Expand Up @@ -154,14 +152,15 @@ function enablePluginInSettings(): void {
settings.extraKnownMarketplaces = {};
}
const marketplaces = settings.extraKnownMarketplaces as Record<string, unknown>;
if (!marketplaces[MARKETPLACE_NAME]) {
marketplaces[MARKETPLACE_NAME] = {
source: {
source: 'github',
repo: MARKETPLACE_REPO,
},
};
}
// Always overwrite the marketplace entry to ensure it is canonical and free
// of non-standard fields (e.g. a stale "path" override added by Claude Code
// dev-mode that causes the plugin to be loaded from the local filesystem).
marketplaces[MARKETPLACE_NAME] = {
source: {
source: 'github',
repo: MARKETPLACE_REPO,
},
};

fs.mkdirSync(path.dirname(settingsFile), { recursive: true });
fs.writeFileSync(settingsFile, JSON.stringify(settings, null, 2));
Expand All @@ -174,22 +173,32 @@ function enablePluginInSettings(): void {
* 2. Fall back to manual: write cache files + update settings.json
*/
export async function installClaudePlugin(skills: Skill[]): Promise<{ cacheDir: string; skillCount: number }> {
// ── Attempt 1: Official CLI ────────────────────────────────────────
const cliSuccess = await tryClaudeCliInstall();
if (cliSuccess) {
return { cacheDir: getClaudePluginCacheDir(), skillCount: skills.length };
}
// Try the official CLI first — this handles enabledPlugins registration.
// We don't return early on success because the CLI may have cached an old
// version of the plugin that is missing the skills directory (e.g. from a
// previous install before skills were added, or from a stale npx cache).
// We always write skills directly to the cache so they're guaranteed to exist.
await tryClaudeCliInstall();

// ── Attempt 2: Manual write + settings.json ────────────────────────
const cacheDir = getClaudePluginCacheDir();

// Clear old skills
// Remove stale older-version cache entries so Claude Code doesn't load an
// empty/outdated version instead of the current one.
const pluginRootDir = path.dirname(cacheDir);
if (fs.existsSync(pluginRootDir)) {
for (const entry of fs.readdirSync(pluginRootDir)) {
if (entry !== PLUGIN_VERSION) {
fs.rmSync(path.join(pluginRootDir, entry), { recursive: true, force: true });
}
}
}

// Clear old skills and rewrite them so the cache is always up to date.
const skillsDir = path.join(cacheDir, 'skills');
if (fs.existsSync(skillsDir)) {
fs.rmSync(skillsDir, { recursive: true });
}

// Write each skill
for (const skill of skills) {
const results = transformForClaude(skill);
for (const { relativePath, content } of results) {
Expand All @@ -199,10 +208,7 @@ export async function installClaudePlugin(skills: Skill[]): Promise<{ cacheDir:
}
}

// Write plugin manifest
writePluginManifest(cacheDir);

// Enable in settings.json (THE KEY FIX)
enablePluginInSettings();

return { cacheDir, skillCount: skills.length };
Expand Down
4 changes: 3 additions & 1 deletion installer/src/transformers/codex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Skill } from '../skills.js';
import { TransformResult } from './types.js';

export function transformForCodex(skill: Skill): TransformResult[] {
const content = `---\nname: ${skill.frontmatter.name}\ndescription: ${skill.frontmatter.description}\n---\n\n${skill.body}`;
const safeName = skill.frontmatter.name.replace(/"/g, '\\"');
const safeDesc = skill.frontmatter.description.replace(/"/g, '\\"');
const content = `---\nname: "${safeName}"\ndescription: "${safeDesc}"\n---\n\n${skill.body}`;
return [{ relativePath: `${skill.frontmatter.name}/SKILL.md`, content }];
}
3 changes: 2 additions & 1 deletion installer/src/transformers/cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { TransformResult } from './types.js';

export function transformForCursor(skill: Skill): TransformResult[] {
const filename = skill.frontmatter.name + '.mdc';
const content = `---\ndescription: "Syncable CLI: ${skill.frontmatter.description}"\nglobs:\nalwaysApply: true\n---\n\n${skill.body}`;
const safeDesc = skill.frontmatter.description.replace(/"/g, '\\"');
const content = `---\ndescription: "Syncable CLI: ${safeDesc}"\nglobs:\nalwaysApply: true\n---\n\n${skill.body}`;
return [{ relativePath: filename, content }];
}
3 changes: 2 additions & 1 deletion installer/src/transformers/windsurf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { TransformResult } from './types.js';

export function transformForWindsurf(skill: Skill): TransformResult[] {
const filename = skill.frontmatter.name + '.md';
const content = `---\ntrigger: always\ndescription: "Syncable CLI: ${skill.frontmatter.description}"\n---\n\n${skill.body}`;
const safeDesc = skill.frontmatter.description.replace(/"/g, '\\"');
const content = `---\ntrigger: always\ndescription: "Syncable CLI: ${safeDesc}"\n---\n\n${skill.body}`;
return [{ relativePath: filename, content }];
}
6 changes: 3 additions & 3 deletions installer/tests/transformers/codex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ describe('transformForCodex', () => {
expect(result[0].relativePath).toBe('syncable-analyze/SKILL.md');
});

it('preserves frontmatter in SKILL.md', () => {
it('preserves frontmatter in SKILL.md with quoted values', () => {
const result = transformForCodex(sampleSkill);
expect(result[0].content).toContain('name: syncable-analyze');
expect(result[0].content).toContain('description: Use when analyzing a project');
expect(result[0].content).toContain('name: "syncable-analyze"');
expect(result[0].content).toContain('description: "Use when analyzing a project"');
});

it('preserves body content', () => {
Expand Down
Loading