@@ -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.8 ' ;
9+ const PLUGIN_VERSION = '0.1.0 ' ;
1010const MARKETPLACE_NAME = 'syncable' ;
1111const MARKETPLACE_REPO = 'syncable-dev/syncable-cli' ;
1212
@@ -173,32 +173,23 @@ function enablePluginInSettings(): void {
173173 * 2. Fall back to manual: write cache files + update settings.json
174174 */
175175export async function installClaudePlugin ( skills : Skill [ ] ) : Promise < { cacheDir : string ; skillCount : number } > {
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.
176+ // Try the official CLI first — this registers the marketplace and plugin
177+ // in Claude Code's settings. We still do a manual write afterwards because
178+ // the CLI-cached version may be stale or missing skills.
181179 await tryClaudeCliInstall ( ) ;
182180
183181 const cacheDir = getClaudePluginCacheDir ( ) ;
182+ const pluginRootDir = path . dirname ( cacheDir ) ; // .../syncable-cli-skills/
184183
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 ) ;
184+ // Nuke the ENTIRE plugin cache (all versions) and recreate fresh.
185+ // This prevents version mismatches, stale caches, and — critically —
186+ // removes any .orphaned_at marker that Claude Code writes when a cached
187+ // version doesn't match the marketplace catalog.
188188 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.
197- const skillsDir = path . join ( cacheDir , 'skills' ) ;
198- if ( fs . existsSync ( skillsDir ) ) {
199- fs . rmSync ( skillsDir , { recursive : true } ) ;
189+ fs . rmSync ( pluginRootDir , { recursive : true , force : true } ) ;
200190 }
201191
192+ // Write every skill into a clean cache directory.
202193 for ( const skill of skills ) {
203194 const results = transformForClaude ( skill ) ;
204195 for ( const { relativePath, content } of results ) {
0 commit comments