-
Notifications
You must be signed in to change notification settings - Fork 2
workspace_docs_path_inside_repo
Resolution (see agent_go/run_server_with_logging.sh and workspace/utils/path.go):
-
Option C shipped: shell-exported
WORKSPACE_DOCS_PATHwins (captured before.envsourcing, so Docker paths can't leak into native mode) → existing non-empty repo-localworkspace-docs/keeps working → new installs default to~/Documents/mcp-agent-workspace. -
Path containment shipped (open question 6):
ResolveUserPathrejects any resolution escaping the workspace root —..traversal through the documents API is closed. - Also related: the workspace server now binds
127.0.0.1in native mode (--host/BIND_HOST), since the unauthenticated API's bind address is its access control.
The original analysis is preserved below for context.
When run_server_with_logging.sh --with-workspace runs, workspace-docs/ is mounted from inside the project tree (coding-agent-loop/workspace-docs/). The LLM sees absolute paths like /Users/<user>/ai-work/coding-agent-loop/workspace-docs/foo.md when reading or writing files. From there it can — and does — traverse upward into sibling directories (agent_go/, frontend/, mcpagent/, etc.) and read project source files that have nothing to do with the user's workspace.
This both pollutes the agent's context with irrelevant code and creates a soft confidentiality issue for anyone running the binary against a workspace that should be sandboxed.
agent_go/run_server_with_logging.sh lines 404–408:
# Always use local workspace-docs for native workspace (ignore Docker paths from .env)
WORKSPACE_DOCS_PATH="${SCRIPT_DIR}/../workspace-docs"
mkdir -p "$WORKSPACE_DOCS_PATH"
WORKSPACE_DOCS_PATH="$(cd "$WORKSPACE_DOCS_PATH" && pwd)"
export WORKSPACE_DOCS_PATHThe script unconditionally overwrites WORKSPACE_DOCS_PATH, throwing away anything the caller exported. The comment explains why: .env files in this project commonly contain Docker paths like /app/workspace-docs that would break native mode. The heavy-handed fix also blocks legitimate shell overrides.
The env var itself is already plumbed everywhere it needs to be (pkg/workspace/execute_shell_command.go, pkg/orchestrator/base_orchestrator_folder_guard.go, pkg/workspace/diff_patch_workspace_file.go, pkg/fsutil/atomic.go, desktop/main.js, docker-compose.yml, etc.). The shell script is the only place that ignores it.
- LLM regularly reads project source files that aren't part of the user workspace.
- Workspace paths leak
/Users/<user>/ai-work/coding-agent-loop/...into agent context, making prompts non-portable across machines. - Anyone wanting to keep notes outside the repo has to edit the script.
- Capture
WORKSPACE_DOCS_PATHfrom the shell before.envis sourced; if non-empty, use it; otherwise fall back to${SCRIPT_DIR}/../workspace-docs. - Pros: zero impact on existing setups; users who care opt in via
~/.zshrc. - Cons: default still has the original problem, so most users won't benefit.
- Default to e.g.
~/Documents/mcp-agent-workspaceor~/Library/Application Support/mcp-agent/workspace-docs. - Pros: solves the problem for everyone by default.
- Cons: existing content in
coding-agent-loop/workspace-docsbecomes invisible until the user moves it or sets the env var back. We have a lot of existing content — a silent default flip would surprise people.
- If
WORKSPACE_DOCS_PATHis set → use it. - Else if
${SCRIPT_DIR}/../workspace-docsexists and is non-empty → use it (preserves current behavior). - Else fall back to
~/Documents/mcp-agent-workspace. - Pros: no surprise migration; new installs get the safe default.
- Cons: the rule is harder to reason about; "why is my notes folder in two places" support questions.
-
Default location. If we change it, which folder convention?
-
~/Library/Application Support/mcp-agent/workspace-docs(Apple convention, hidden) -
~/Documents/mcp-agent-workspace(Finder-visible, iCloud-syncable) -
~/.local/share/mcp-agent/workspace-docs(XDG, cross-platform-friendly) -
~/mcp-agent/workspace-docs(simple, clutters home)
-
-
Migration story. Do we ship a one-shot migration script, or document the
mvin the bug fix and let users run it manually? -
Symlink as bridge? A symlink from
coding-agent-loop/workspace-docs→~/...would let both old and new code paths resolve to the same content during a transition. Worth supporting? -
Frontend / Electron.
desktop/main.jsalso readsWORKSPACE_DOCS_PATH. Confirm it picks up the same env var without script changes. -
Docker / production. The current "ignore .env" hack exists because compose sets
/app/workspace-docs. Need to verify the new logic doesn't regress prod by sourcingWORKSPACE_DOCS_PATH=/app/...from.envand using it on a developer Mac. (Capturing from shell env before.envsource addresses this.) -
Path containment. Even with workspace-docs moved out of the repo, the workspace tools still hand out absolute paths. Should we additionally enforce path containment in the workspace server (reject any
..resolution that escapesWORKSPACE_DOCS_PATH) so that this class of bug can't recur?
-
agent_go/run_server_with_logging.sh— hardcoded path (lines 404–408),.envsourcing (lines 317–327) -
agent_go/pkg/workspace/execute_shell_command.go— consumes the env var -
agent_go/pkg/workspace/diff_patch_workspace_file.go— consumes the env var -
agent_go/pkg/orchestrator/base_orchestrator_folder_guard.go— folder containment guard -
agent_go/pkg/fsutil/atomic.go— file ops -
desktop/main.js— Electron-side workspace path -
docker-compose.yml,docker-compose.prod.yml— set the Docker/app/workspace-docsvalue -
docs/core/native_workspace_mode.md— needs doc update once decision is made
None purely via env right now — the script overwrites WORKSPACE_DOCS_PATH. Manual workarounds:
- Edit
run_server_with_logging.shline 405 locally and point it at the desired path. - Or symlink
coding-agent-loop/workspace-docsto a folder outside the repo (ln -s ~/Documents/mcp-agent-workspace coding-agent-loop/workspace-docs). The script will still resolve to the in-repo path, but the actual storage lives elsewhere.
Auto-synced from docs/ on main. Edit there, not here.