From 40a022afd9e5f15db74fb9208c4ec423d799f945 Mon Sep 17 00:00:00 2001 From: Xubin Ren Date: Tue, 17 Mar 2026 05:01:34 +0000 Subject: [PATCH] fix(onboard): use configured workspace path on setup --- nanobot/cli/commands.py | 3 ++- tests/test_commands.py | 12 +++++++----- tests/test_config_migration.py | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/nanobot/cli/commands.py b/nanobot/cli/commands.py index 47f7316..a1a6341 100644 --- a/nanobot/cli/commands.py +++ b/nanobot/cli/commands.py @@ -282,7 +282,8 @@ def onboard(): save_config(config) console.print(f"[green]✓[/green] Config refreshed at {config_path} (existing values preserved)") else: - save_config(Config()) + config = Config() + save_config(config) console.print(f"[green]✓[/green] Created config at {config_path}") console.print("[dim]Config template now uses `maxTokens` + `contextWindowTokens`; `memoryWindow` is no longer a runtime setting.[/dim]") diff --git a/tests/test_commands.py b/tests/test_commands.py index b09c955..ce36a6d 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -45,7 +45,7 @@ def mock_paths(): mock_ws.return_value = workspace_dir mock_sc.side_effect = lambda config: config_file.write_text("{}") - yield config_file, workspace_dir + yield config_file, workspace_dir, mock_ws if base_dir.exists(): shutil.rmtree(base_dir) @@ -53,7 +53,7 @@ def mock_paths(): def test_onboard_fresh_install(mock_paths): """No existing config — should create from scratch.""" - config_file, workspace_dir = mock_paths + config_file, workspace_dir, mock_ws = mock_paths result = runner.invoke(app, ["onboard"]) @@ -64,11 +64,13 @@ def test_onboard_fresh_install(mock_paths): assert config_file.exists() assert (workspace_dir / "AGENTS.md").exists() assert (workspace_dir / "memory" / "MEMORY.md").exists() + expected_workspace = Config().workspace_path + assert mock_ws.call_args.args == (expected_workspace,) def test_onboard_existing_config_refresh(mock_paths): """Config exists, user declines overwrite — should refresh (load-merge-save).""" - config_file, workspace_dir = mock_paths + config_file, workspace_dir, _ = mock_paths config_file.write_text('{"existing": true}') result = runner.invoke(app, ["onboard"], input="n\n") @@ -82,7 +84,7 @@ def test_onboard_existing_config_refresh(mock_paths): def test_onboard_existing_config_overwrite(mock_paths): """Config exists, user confirms overwrite — should reset to defaults.""" - config_file, workspace_dir = mock_paths + config_file, workspace_dir, _ = mock_paths config_file.write_text('{"existing": true}') result = runner.invoke(app, ["onboard"], input="y\n") @@ -95,7 +97,7 @@ def test_onboard_existing_config_overwrite(mock_paths): def test_onboard_existing_workspace_safe_create(mock_paths): """Workspace exists — should not recreate, but still add missing templates.""" - config_file, workspace_dir = mock_paths + config_file, workspace_dir, _ = mock_paths workspace_dir.mkdir(parents=True) config_file.write_text("{}") diff --git a/tests/test_config_migration.py b/tests/test_config_migration.py index f800fb5..2a446b7 100644 --- a/tests/test_config_migration.py +++ b/tests/test_config_migration.py @@ -76,7 +76,7 @@ def test_onboard_refresh_rewrites_legacy_config_template(tmp_path, monkeypatch) ) monkeypatch.setattr("nanobot.config.loader.get_config_path", lambda: config_path) - monkeypatch.setattr("nanobot.cli.commands.get_workspace_path", lambda: workspace) + monkeypatch.setattr("nanobot.cli.commands.get_workspace_path", lambda _workspace=None: workspace) result = runner.invoke(app, ["onboard"], input="n\n") @@ -109,7 +109,7 @@ def test_onboard_refresh_backfills_missing_channel_fields(tmp_path, monkeypatch) ) monkeypatch.setattr("nanobot.config.loader.get_config_path", lambda: config_path) - monkeypatch.setattr("nanobot.cli.commands.get_workspace_path", lambda: workspace) + monkeypatch.setattr("nanobot.cli.commands.get_workspace_path", lambda _workspace=None: workspace) monkeypatch.setattr( "nanobot.channels.registry.discover_all", lambda: {