Working across indexed and non-indexed workspaces
When to use
You need to create or edit files in a sibling directory the user just
cloned (e.g. ../agent-skills) but the agent's edit_file,
list_dir, codebase_search, or view_code_item refuses it with
路径不在workspace下,拒绝请求 / "path is not in workspace".
Problem
Several tools are scoped to the indexed workspaces only (the ones listed in the session's workspace configuration). They won't touch files outside, even if the process has filesystem permission.
Trying to keep inventing ad-hoc cat > file <<EOF heredocs in the
shell is how you get the problems documented in
shell-heredoc-and-multiline-strings.
Solution
Pick one based on what the target needs:
One or two short text files → use the agent's
terminaltool withprintf/tee, quoting carefully.Multiple files, or files with backticks / quotes / multi-line code → write a generator script inside an indexed workspace (e.g.
blade-build/tmp_build_skills.py) that builds a{path: content}dict and writes every file with standardPath.write_text. The generator is plain Python source, soedit_fileis happy to create it. Run it once withpython3, then delete.Read-only exploration (listing, grepping) of the non-indexed directory → use
terminalwithls,find,cat,rg.Large existing file you need to modify →
catit through the terminal to inspect, then apply a smallsed -ior re-emit via the generator-script trick.
Example
Generator-script pattern:
# blade-build/tmp_build_skills.py
from pathlib import Path
ROOT = Path("/Volumes/SanDiskSSD/code/agent-skills")
FILES = {
"README.md": "…",
"skills/foo/SKILL.md": "…",
}
for rel, body in FILES.items():
p = ROOT / rel
p.parent.mkdir(parents=True, exist_ok=True)
p.write_text(body)
print(f"wrote {len(FILES)} files")
Then:
python3 /Volumes/SanDiskSSD/code/blade-build/tmp_build_skills.py
rm /Volumes/SanDiskSSD/code/blade-build/tmp_build_skills.py
Pitfalls
- Don't accidentally commit the generator script to the indexed repo. Either delete it immediately or stage selectively.
codebase_search/view_code_itemwill not see the non-indexed repo even after files are written; fall back togrep+cat.- If the user later adds the sibling repo to the workspace, rerun any cached searches — results from before won't include it.