From 1dd953d17af0ed2e7daa59f45fa4b3fc7e283767 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Fri, 13 Mar 2026 20:06:59 -0600 Subject: [PATCH] fix: bug in utils path add an optional arg to create config path --- src/cli/utils.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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)) {