fix(cli): honor workspace_dir from config.yaml when --workspace not provided (#90)#91
Open
draix wants to merge 1 commit into
Open
fix(cli): honor workspace_dir from config.yaml when --workspace not provided (#90)#91draix wants to merge 1 commit into
draix wants to merge 1 commit into
Conversation
…rovided (MiniMax-AI#90) Previously, the CLI entry point (mini_agent/cli.py::main) ignored 'workspace_dir' from config.yaml entirely: when '--workspace' was omitted, it fell straight back to Path.cwd(). This mirrors the precedence already used by the ACP adapter (mini_agent/acp/__init__.py): CLI arg > config.agent.workspace_dir > Path.cwd(). The resolution is moved into run_agent() after the config has been loaded, behind a new resolve_workspace_dir() helper that expands '~' and resolves relative paths against the current cwd (so e.g. './workspace' becomes '<cwd>/workspace'). Adds tests/test_cli_workspace.py covering the precedence, the relative-path case from the issue repro, the '~' expansion case, and the empty-config fallback to cwd. Closes MiniMax-AI#90
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #90 —
workspace_dirconfigured inconfig.yamlis ignored by the CLI mode.When the user does not pass
--workspace, the CLI currently falls back directly toPath.cwd()and never readsworkspace_dirfromconfig.yaml. This PR makes the CLI honour the same precedence the ACP adapter already uses:--workspace(CLI) >workspace_dir(config.yaml) >Path.cwd()Reproduction (from the issue)
config.yaml:Run:
Before this PR:
Expected (and after this PR):
What changed
mini_agent/cli.pyresolve_workspace_dir(cli_workspace, config)helper that implements the precedence: CLI arg >config.agent.workspace_dir>Path.cwd(). It expands~and resolves relative paths against the current cwd, so./workspacebecomes<cwd>/workspace— matching the behaviour described in the issue.main()no longer pre-resolves the workspace path before the config is loaded. Instead it passes the rawargs.workspace(orNone) torun_agent(), which resolves the final workspace right after loading the config.mini_agent/acp/__init__.py::MiniMaxACPAgent.newSession:tests/test_cli_workspace.py(new)--workspacewins overconfig.workspace_dir.--workspace, the value fromconfig.yamlis used../workspacein config resolves against the current cwd (regression test for the exact repro in config.yaml中的workspace_dir 配置在 CLI 模式下未生效 #90).workspace_dirin config falls back toPath.cwd().~/...inworkspace_diris expanded to the user home directory.Test plan
Full test suite was also run; the pre-existing failures on
main(missingmini_agent/config/config.yaml, API keys, and an unrelated pydantic issue intest_acp_invalid_session) are not introduced by this PR.Notes
--workspaceis provided.workspace_dirinconfig.yaml—Path.cwd()is still the last-resort default.Path.mkdir(parents=True, exist_ok=True)call previously made bymain()is preserved insiderun_agent()after the workspace is resolved.Closes #90