diff --git a/src/cli/utils.ts b/src/cli/utils.ts index 8396d1a..e1e7415 100644 --- a/src/cli/utils.ts +++ b/src/cli/utils.ts @@ -11,19 +11,25 @@ export function resolvePath(raw: string): string { return resolve(raw); } -export function ensureWorkspace(rawPath: string): string { +export function ensureWorkspace(rawPath: string, createIfMissing = true): string { const path = resolvePath(rawPath); if (!existsSync(path)) { - mkdirSync(path, { recursive: true }); + if (createIfMissing) { + mkdirSync(path, { recursive: true }); + } else { + throw new Error( + `Workspace does not exist: ${path}\nRun 'nanobot onboard' to initialize.`, + ); + } } return path; } export function syncTemplates(workspacePath: string): string[] { - // Get project root relative to this file + // Get project root relative to this file (src/cli/utils.ts) const currentFile = fileURLToPath(import.meta.url); const srcDir = dirname(currentFile); - const projectRoot = resolve(srcDir, '..'); + const projectRoot = resolve(srcDir, '..', '..'); const templatesDir = resolve(projectRoot, 'templates'); if (!existsSync(templatesDir)) {