Skip to content

0.25.0: Files, an add-on built into every channel - #61

Merged
samifouad merged 2 commits into
mainfrom
claude/files-addon-60
Nov 14, 2026
Merged

samifouad merged 2 commits into
mainfrom
claude/files-addon-60

Conversation

@samifouad

Copy link
Copy Markdown
Member

Files add-on: a default in every channel

gild is file-based under the hood (every channel is a git repository), so every channel now has a Files pane without anyone adding anything. Files is an add-on built into gild: declared like Markdown (src-tauri/addons/files/gild-addon.json, "builtIn": true), listed in Settings › Add-ons as "Files, by gild, built in", with its tools on the same switches and in the same Activity as every other add-on tool. It has no WebAssembly module: its tools touch the channel's repository, which no sandboxed module may, so they are gild's own code (src-tauri/src/store/files.rs), and a third-party manifest claiming general tools or skipping its module is refused.

What changed

  • The pane (src/app/Files.tsx, the shared view kept as it was): a toolbar with New file (a name without an extension becomes .md, and it opens in the Markdown view), New folder (kept in the history by an empty .gitkeep, which the tree hides), Upload (and drag-and-drop onto the pane: dragDropEnabled: false on the window so the HTML drop carries the files), and for the selected file or folder Rename, Move, Delete (an in-page confirmation, role=alertdialog, never a system dialog) and History. Opening a file hands it to the add-on for its type: .md is the Markdown view with Edit; otherwise text, an image preview (data: URL, up to 10 MB), or the name and size with Show in Finder (Explorer / file manager). Folders over 200 entries show 200 at a time ("Show 200 more of N").
  • Panes per channel: a Panes menu beside the tabs hides a pane (Docs, Files) or reorders them. Saved as .gild/addons.json in the channel's repository (a commit by you, "Panes: Files (hidden), Docs"), so it travels with the folder. No existing per-channel file described panes (view.json is the table, acl.json is access), so this is the one new file; check_gild_file validates it on outside edits. An unknown add-on in the file is dropped, one left out is shown after the listed ones. A hidden pane's files and tools stay.
  • Agent tools list_files, read_file, write_file, move_file, delete_file, file_history, generated from the manifest like markdown_* (channel_id prepended). read_file moved from the View group to Files (same implementation). Channel ACL (store.require) and per-agent tool switches apply; every write is one commit under the agent's name and an Activity entry (Activity names them: "wrote a file", "moved a file", …).
  • Hardening (records.rs): commit_changes takes removals too and runs a pure check_path on every path before anything is opened or written (relative, no ./../empty parts, no .git in any case, no backslash or control characters), so a bare repository gets the same check as a folder; disk_path uses it plus the existing no-links walk. A removed file's emptied folders leave the disk, so the folder matches the commit. store/files.rs adds: gild's own files (.gild/, gild.json, .gitignore) can't be changed through Files at all (an agent writing .gild/acl.json would grant itself access); nothing may be written where a file or folder already is, nor at a name this computer's file system wouldn't tell apart (case, Unicode form: folders::identity), nor inside a file; moving a folder into itself, moving onto something, and case-only renames (which the index/disk check would otherwise refuse with a confusing message) are refused with a plain sentence; 50 MB cap per file; the Files grant (*) withdrawn in Settings › Add-ons › Files › Permissions stops every write, for everyone.
  • Version 0.25.0 (package.json, package-lock.json, Cargo.toml, Cargo.lock, README), README updated, base64 crate added (uploads and image previews cross the window boundary as base64).

How to try it

  1. Open any channel: the Files tab is there. New file › Checklist › Enter: Checklist.md opens in the Markdown view; Edit, Save.
  2. New folder › plans; drop a PNG onto the pane (or Upload): it lands in the selected folder and previews.
  3. Select a file › Rename / Move / Delete (confirm in the pane) › History shows the commits. git log in ~/Gild/<workspace>/channels/<channel>/ shows the same commits by you.
  4. Panes beside the tabs: switch Files off, the tab goes; on again, it's back; .gild/addons.json in the channel's folder has it.
  5. Settings › Add-ons: Files, built in, with its six tools; an agent with write access can write_file / move_file / delete_file (Activity logs each; a read-only agent is refused).

Evidence

Run locally on the iMac (rustup 1.100, CARGO_TARGET_DIR in the clone), logs kept in .tmp/:

  • npm run check → exit=0; npm run build → exit=0 (the web job).
  • cargo test --locked --lib --manifest-path src-tauri/Cargo.toml → test result: ok. 90 passed; 0 failed; 2 ignored (exit=0). New tests: addons::tests::the_files_add_on_is_built_in_with_general_tools_and_a_pane, store::files::tests::{files_are_written_moved_and_deleted_as_commits_by_the_caller, hostile_paths_are_refused_before_anything_is_written, uploads_previews_and_the_grant, panes_are_per_channel_in_its_history}, mcp::tests::agents_manage_files_where_they_may_and_every_write_is_theirs (over real HTTP: tools offered, writes as the agent, hostile paths refused, read access can't write, a switched-off tool gone and refused, every call in Activity). records::status is asserted empty after every write (folder and index match the commit).
  • cargo clippy --locked --all-targets --manifest-path src-tauri/Cargo.toml -- -D warnings → exit=0; the same for addons/markdown on wasm32-unknown-unknown → exit=0. No new warnings.
  • The app job, as CI runs it, in a Linux container on this machine (tar … | docker run node:24-bookworm … ci/linux.sh app, COPYFILE_DISABLE=1 so macOS tar adds no ._* files): files: created, renamed, deleted and uploaded through the pane; panes hidden and shown … ci/linux.sh app: ok, exit=0. The new e2e step creates a file and a folder through the toolbar, renames, deletes behind the in-page confirmation, reads the files back from disk and from file_history, uploads a PNG through the pane's command and sees the image preview, hides and shows the Files pane and reads .gild/addons.json.

Revert-proofs (guard removed, test run, guard restored; cargo test … -- <test>):

guard removed test result
own_file check in file_path_ok (gild's .gild/, gild.json) store::files::tests::hostile_paths_are_refused_before_anything_is_written FAILED at files.rs:462 (.gild/acl.json was written)
the identity (case / Unicode form) comparison in free the same test FAILED at files.rs:483: readme.md written beside Readme.md
files_allowed (the Files * grant) store::files::tests::uploads_previews_and_the_grant FAILED at files.rs:532
write_file requiring Access::Write (set to Read) in mcp.rs mcp::tests::agents_manage_files_where_they_may_and_every_write_is_theirs FAILED at mcp.rs:850 (the read-only agent wrote)

All four pass again with the guards back (5 passed; 0 failed).

Left out

  • Drag-and-drop itself isn't driven by the e2e (WebDriver can't drop OS files); the drop handler calls the same upload_files command the e2e exercises, and the Upload button is the same path.
  • The first container run failed in a pre-existing step (the agent's Mentions "Saved." took over 10 s on the 4-CPU container); it passed on the next two runs, so I left that wait alone.
  • The pane's new file / new folder go into the selected item's folder (the label says where); nothing is selected → the top folder.
  • Case-only renames (Readme.md → readme.md) are refused with a two-step hint rather than done, because on a case-insensitive file system the one-commit remove-and-write can't be told from a save made outside gild.

closes #60

-claude

Every channel is a git repository, so every channel has a Files pane: its
files as a tree, open (a .md in the Markdown view; text, an image preview,
or name and size with Show in Finder), new file, new folder, upload and
drag-and-drop, rename, move, delete (confirmed in the pane) and each file's
history from git. Files is declared like any add-on (builtIn: no module, its
tools are gild's own code) and listed in Settings. A channel can hide or
reorder its panes (.gild/addons.json in its repository), never remove one.
Agents get list_files, read_file, write_file, move_file, delete_file and
file_history through the same path as every add-on tool: channel access and
tool switches apply, every write is one commit by the agent and an Activity
entry. Every path is checked before anything is written; gild's own files
and names this computer's file system wouldn't tell apart are refused.

closes #60
@samifouad
samifouad merged commit 85d034a into main Nov 14, 2026
3 checks passed
@samifouad
samifouad deleted the claude/files-addon-60 branch November 14, 2026 10:42
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.

Files add-on: a default in every channel

1 participant