Skip to content

feat: let the agent move and rename workspace files - #57

Merged
bencode merged 2 commits into
mainfrom
feat/agent-move
Oct 1, 2026
Merged

bencode merged 2 commits into
mainfrom
feat/agent-move

Conversation

@bencode

@bencode bencode commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Why

Now that files live on folder paths (#52), the agent can create files in folders, but it cannot reorganize the ones that exist. Today it can only write text copies and leave the originals behind, and it cannot touch PDFs, Word files or images at all.

What changes

  • New agent tool move({ fileId, path }) → { fileId, from, path }. It covers both moving and renaming.
    • Paths are validated like write: docs/a.md, ./docs/a.md and /workspace/docs/a.md are all accepted. write and move now share one validator, agentWorkspacePath.
    • The id, the revision and the content are kept. The revision is kept on purpose, so an unsaved source draft of the file does not turn into a false conflict when it is saved later.
    • The preview kind follows the new extension, so notes.txt → notes.md now renders as Markdown.
    • A move is refused, with the library left unchanged, when:
      • another file already has the target path (ignoring case)
      • the target is a folder, or would sit inside a file
      • the file is a chat attachment
      • the file is missing
      • the path is invalid
    • A rename that only changes case is allowed.
  • data/file-store.ts: moveStoredFile runs in a single read-write transaction.
  • The mover reaches the tools the same way the writer does: file library → workbench → workspace context → workspace tools.
  • shell/use-workspace.ts: when the open document moves, the address follows it to the new path. Before, the address went to /files and the document closed.
  • resource-tree.tsx: the active file's folders are revealed whenever its path changes, not only when another file becomes active.
  • System prompt: use move rather than writing copies to organize files.

Not handled

  • Relative image links inside a moved Markdown file can break.
  • Folder export never deletes, so the old path stays on disk.
  • There is no UI rename yet.

Tests

  • File store: a move keeps the id, revision and content, recomputes the preview kind, and allows a case-only rename. Each refusal leaves the library untouched.
  • Tool: accepts the /workspace/ prefix, reports from, and rejects ...
  • Workbench integration: the model moves the open document into guides/. The tab stays selected, the folder unfolds and the file stays highlighted. I confirmed that this test fails without the address-follow change.

pnpm check passes. The known flaky "deletes only what this tab asked for" integration test can still fail under full-suite load, as it does on main.

A new move tool takes a file id and a new path. The id, revision and content
stay, the preview kind follows the new extension, and an open document keeps
its tab and address. Moves onto another file's path, across a file and folder
of the same name, or of chat attachments are refused.
The file tree revealed a file's folders only when another file became active,
so a file moved while open stayed hidden behind folded folders whenever its
address was an id. Revealing follows the active file's path instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant