diff --git a/src/commands/install.ts b/src/commands/install.ts index b4c015e..f747a8b 100644 --- a/src/commands/install.ts +++ b/src/commands/install.ts @@ -27,7 +27,9 @@ function isLocalPath(source: string): boolean { source.startsWith('/') || source.startsWith('./') || source.startsWith('../') || - source.startsWith('~/') + source.startsWith('~/') || + source.startsWith('~\\') || // Windows home directory with backslash + /^[a-zA-Z]:[/\\]/.test(source) // Windows drive (C:/ or C:\) ); } @@ -56,10 +58,11 @@ function getRepoName(repoUrl: string): string | null { } /** - * Expand ~ to home directory + * Expand ~ to home directory and normalize path */ function expandPath(source: string): string { - if (source.startsWith('~/')) { + // Support both Unix (~/) and Windows (~\) tilde notation + if (source.startsWith('~/') || source.startsWith('~\\')) { return join(homedir(), source.slice(2)); } return resolve(source); diff --git a/src/commands/sync.ts b/src/commands/sync.ts index d8746eb..7ffee43 100644 --- a/src/commands/sync.ts +++ b/src/commands/sync.ts @@ -1,5 +1,6 @@ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs'; -import { dirname, basename } from 'path'; +import { dirname, basename, resolve, join } from 'path'; +import { homedir } from 'os'; import chalk from 'chalk'; import { checkbox } from '@inquirer/prompts'; import { ExitPromptError } from '@inquirer/core'; @@ -12,11 +13,23 @@ export interface SyncOptions { output?: string; } +/** + * Expand ~ to home directory and resolve path + */ +function expandPath(path: string): string { + // Support both Unix (~/) and Windows (~\) tilde notation + if (path.startsWith('~/') || path.startsWith('~\\')) { + return join(homedir(), path.slice(2)); + } + return resolve(path); +} + /** * Sync installed skills to a markdown file */ export async function syncAgentsMd(options: SyncOptions = {}): Promise { - const outputPath = options.output || 'AGENTS.md'; + const rawOutputPath = options.output || 'AGENTS.md'; + const outputPath = expandPath(rawOutputPath); const outputName = basename(outputPath); // Validate output file is markdown