From ff16e93713de67312ae029b8bfb6474d75554881 Mon Sep 17 00:00:00 2001 From: Akasha Date: Sun, 22 Mar 2026 16:53:42 -0400 Subject: [PATCH 1/2] fix: skip mount-allowlist write if file already exists /setup overwrote ~/.config/nanoclaw/mount-allowlist.json unconditionally, clobbering any user customizations made after initial setup. Now checks for the file first and skips with a 'skipped' status if it exists. Co-Authored-By: Claude Sonnet 4.6 --- setup/mounts.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/setup/mounts.ts b/setup/mounts.ts index eb2a5f6..a3377d3 100644 --- a/setup/mounts.ts +++ b/setup/mounts.ts @@ -37,6 +37,21 @@ export async function run(args: string[]): Promise { fs.mkdirSync(configDir, { recursive: true }); + if (fs.existsSync(configFile)) { + logger.info( + { configFile }, + 'Mount allowlist already exists — skipping (use --force to overwrite)', + ); + emitStatus('CONFIGURE_MOUNTS', { + PATH: configFile, + ALLOWED_ROOTS: 0, + NON_MAIN_READ_ONLY: 'unknown', + STATUS: 'skipped', + LOG: 'logs/setup.log', + }); + return; + } + let allowedRoots = 0; let nonMainReadOnly = 'true'; From 5f426465981f6e407412847cae7ea67999cb1e01 Mon Sep 17 00:00:00 2001 From: Akasha Date: Mon, 23 Mar 2026 16:57:09 -0400 Subject: [PATCH 2/2] fix: implement --force flag for mount-allowlist overwrite The skip message mentioned --force but parseArgs didn't handle it, making it a false promise. Now --force is parsed and passed through, allowing users to regenerate the mount allowlist when needed. Co-Authored-By: Claude Sonnet 4.6 --- setup/mounts.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/setup/mounts.ts b/setup/mounts.ts index a3377d3..e14d23b 100644 --- a/setup/mounts.ts +++ b/setup/mounts.ts @@ -10,21 +10,23 @@ import { logger } from '../src/logger.js'; import { isRoot } from './platform.js'; import { emitStatus } from './status.js'; -function parseArgs(args: string[]): { empty: boolean; json: string } { +function parseArgs(args: string[]): { empty: boolean; json: string; force: boolean } { let empty = false; let json = ''; + let force = false; for (let i = 0; i < args.length; i++) { if (args[i] === '--empty') empty = true; + if (args[i] === '--force') force = true; if (args[i] === '--json' && args[i + 1]) { json = args[i + 1]; i++; } } - return { empty, json }; + return { empty, json, force }; } export async function run(args: string[]): Promise { - const { empty, json } = parseArgs(args); + const { empty, json, force } = parseArgs(args); const homeDir = os.homedir(); const configDir = path.join(homeDir, '.config', 'nanoclaw'); const configFile = path.join(configDir, 'mount-allowlist.json'); @@ -37,7 +39,7 @@ export async function run(args: string[]): Promise { fs.mkdirSync(configDir, { recursive: true }); - if (fs.existsSync(configFile)) { + if (fs.existsSync(configFile) && !force) { logger.info( { configFile }, 'Mount allowlist already exists — skipping (use --force to overwrite)',