fix(onboard): use configured workspace path on setup
This commit is contained in:
@@ -282,7 +282,8 @@ def onboard():
|
|||||||
save_config(config)
|
save_config(config)
|
||||||
console.print(f"[green]✓[/green] Config refreshed at {config_path} (existing values preserved)")
|
console.print(f"[green]✓[/green] Config refreshed at {config_path} (existing values preserved)")
|
||||||
else:
|
else:
|
||||||
save_config(Config())
|
config = Config()
|
||||||
|
save_config(config)
|
||||||
console.print(f"[green]✓[/green] Created config at {config_path}")
|
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]")
|
console.print("[dim]Config template now uses `maxTokens` + `contextWindowTokens`; `memoryWindow` is no longer a runtime setting.[/dim]")
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ def mock_paths():
|
|||||||
mock_ws.return_value = workspace_dir
|
mock_ws.return_value = workspace_dir
|
||||||
mock_sc.side_effect = lambda config: config_file.write_text("{}")
|
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():
|
if base_dir.exists():
|
||||||
shutil.rmtree(base_dir)
|
shutil.rmtree(base_dir)
|
||||||
@@ -53,7 +53,7 @@ def mock_paths():
|
|||||||
|
|
||||||
def test_onboard_fresh_install(mock_paths):
|
def test_onboard_fresh_install(mock_paths):
|
||||||
"""No existing config — should create from scratch."""
|
"""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"])
|
result = runner.invoke(app, ["onboard"])
|
||||||
|
|
||||||
@@ -64,11 +64,13 @@ def test_onboard_fresh_install(mock_paths):
|
|||||||
assert config_file.exists()
|
assert config_file.exists()
|
||||||
assert (workspace_dir / "AGENTS.md").exists()
|
assert (workspace_dir / "AGENTS.md").exists()
|
||||||
assert (workspace_dir / "memory" / "MEMORY.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):
|
def test_onboard_existing_config_refresh(mock_paths):
|
||||||
"""Config exists, user declines overwrite — should refresh (load-merge-save)."""
|
"""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}')
|
config_file.write_text('{"existing": true}')
|
||||||
|
|
||||||
result = runner.invoke(app, ["onboard"], input="n\n")
|
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):
|
def test_onboard_existing_config_overwrite(mock_paths):
|
||||||
"""Config exists, user confirms overwrite — should reset to defaults."""
|
"""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}')
|
config_file.write_text('{"existing": true}')
|
||||||
|
|
||||||
result = runner.invoke(app, ["onboard"], input="y\n")
|
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):
|
def test_onboard_existing_workspace_safe_create(mock_paths):
|
||||||
"""Workspace exists — should not recreate, but still add missing templates."""
|
"""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)
|
workspace_dir.mkdir(parents=True)
|
||||||
config_file.write_text("{}")
|
config_file.write_text("{}")
|
||||||
|
|
||||||
|
|||||||
@@ -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.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")
|
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.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(
|
monkeypatch.setattr(
|
||||||
"nanobot.channels.registry.discover_all",
|
"nanobot.channels.registry.discover_all",
|
||||||
lambda: {
|
lambda: {
|
||||||
|
|||||||
Reference in New Issue
Block a user