@@ -6,7 +6,7 @@ import { TransformResult } from './types.js';
66import { execCommand , commandExists } from '../utils.js' ;
77
88const PLUGIN_NAME = 'syncable-cli-skills' ;
9- const PLUGIN_VERSION = '0.1.0 ' ;
9+ const PLUGIN_VERSION = '0.1.8 ' ;
1010const MARKETPLACE_NAME = 'syncable' ;
1111const MARKETPLACE_REPO = 'syncable-dev/syncable-cli' ;
1212
@@ -19,8 +19,6 @@ export function transformForClaude(skill: Skill): TransformResult[] {
1919
2020 const safeDesc = skill . frontmatter . description
2121 . replace ( / " / g, '\\"' )
22- . replace ( / : / g, ' - ' )
23- . replace ( / T r i g g e r o n : .* $ / , '' )
2422 . trim ( ) ;
2523
2624 const content = `---\ndescription: "${ safeDesc } "\n---\n\n${ skill . body } ` ;
@@ -154,14 +152,15 @@ function enablePluginInSettings(): void {
154152 settings . extraKnownMarketplaces = { } ;
155153 }
156154 const marketplaces = settings . extraKnownMarketplaces as Record < string , unknown > ;
157- if ( ! marketplaces [ MARKETPLACE_NAME ] ) {
158- marketplaces [ MARKETPLACE_NAME ] = {
159- source : {
160- source : 'github' ,
161- repo : MARKETPLACE_REPO ,
162- } ,
163- } ;
164- }
155+ // Always overwrite the marketplace entry to ensure it is canonical and free
156+ // of non-standard fields (e.g. a stale "path" override added by Claude Code
157+ // dev-mode that causes the plugin to be loaded from the local filesystem).
158+ marketplaces [ MARKETPLACE_NAME ] = {
159+ source : {
160+ source : 'github' ,
161+ repo : MARKETPLACE_REPO ,
162+ } ,
163+ } ;
165164
166165 fs . mkdirSync ( path . dirname ( settingsFile ) , { recursive : true } ) ;
167166 fs . writeFileSync ( settingsFile , JSON . stringify ( settings , null , 2 ) ) ;
@@ -174,22 +173,32 @@ function enablePluginInSettings(): void {
174173 * 2. Fall back to manual: write cache files + update settings.json
175174 */
176175export async function installClaudePlugin ( skills : Skill [ ] ) : Promise < { cacheDir : string ; skillCount : number } > {
177- // ── Attempt 1: Official CLI ────────────────────────────────────────
178- const cliSuccess = await tryClaudeCliInstall ( ) ;
179- if ( cliSuccess ) {
180- return { cacheDir : getClaudePluginCacheDir ( ) , skillCount : skills . length } ;
181- }
176+ // Try the official CLI first — this handles enabledPlugins registration.
177+ // We don't return early on success because the CLI may have cached an old
178+ // version of the plugin that is missing the skills directory (e.g. from a
179+ // previous install before skills were added, or from a stale npx cache).
180+ // We always write skills directly to the cache so they're guaranteed to exist.
181+ await tryClaudeCliInstall ( ) ;
182182
183- // ── Attempt 2: Manual write + settings.json ────────────────────────
184183 const cacheDir = getClaudePluginCacheDir ( ) ;
185184
186- // Clear old skills
185+ // Remove stale older-version cache entries so Claude Code doesn't load an
186+ // empty/outdated version instead of the current one.
187+ const pluginRootDir = path . dirname ( cacheDir ) ;
188+ if ( fs . existsSync ( pluginRootDir ) ) {
189+ for ( const entry of fs . readdirSync ( pluginRootDir ) ) {
190+ if ( entry !== PLUGIN_VERSION ) {
191+ fs . rmSync ( path . join ( pluginRootDir , entry ) , { recursive : true , force : true } ) ;
192+ }
193+ }
194+ }
195+
196+ // Clear old skills and rewrite them so the cache is always up to date.
187197 const skillsDir = path . join ( cacheDir , 'skills' ) ;
188198 if ( fs . existsSync ( skillsDir ) ) {
189199 fs . rmSync ( skillsDir , { recursive : true } ) ;
190200 }
191201
192- // Write each skill
193202 for ( const skill of skills ) {
194203 const results = transformForClaude ( skill ) ;
195204 for ( const { relativePath, content } of results ) {
@@ -199,10 +208,7 @@ export async function installClaudePlugin(skills: Skill[]): Promise<{ cacheDir:
199208 }
200209 }
201210
202- // Write plugin manifest
203211 writePluginManifest ( cacheDir ) ;
204-
205- // Enable in settings.json (THE KEY FIX)
206212 enablePluginInSettings ( ) ;
207213
208214 return { cacheDir, skillCount : skills . length } ;
0 commit comments