Skip to content

feat(agent): let Ask Cmdr look into a file with inspect_file, so "what's this file?" gets a real answer - #67

Closed
vdavid wants to merge 1 commit into
mainfrom
claude/cmdr-file-inspection-tools-922rhs
Closed

feat(agent): let Ask Cmdr look into a file with inspect_file, so "what's this file?" gets a real answer#67
vdavid wants to merge 1 commit into
mainfrom
claude/cmdr-file-inspection-tools-922rhs

Conversation

@vdavid

@vdavid vdavid commented Sep 1, 2026

Copy link
Copy Markdown
Owner

What

One new agent-only read tool, inspect_file, answering "what is this file?" from the file itself. One path per call, typed result:

  • Metadata: name, size (bytes + human), modified (RFC 3339), extension, MIME guess by extension, and detected, the format the leading bytes really are (PDF, PNG, JPEG, GIF, WebP, HEIC, TIFF, BMP, zip, gzip, 7z, rar, tar, SQLite, Mach-O, ELF, UTF-8 text). mime and detected sit side by side so a lying extension shows.
  • Text: a character window (offset + maxChars, default 4,000, cap 16,000) with totalChars and truncated, so a long file is paged, never dumped into the turn.
  • Image: width and height from the header, plus a hint pointing at image_facts for what is in the picture. Image bytes never cross.
  • PDF: header version and pageCountEstimate (a lower bound counted from uncompressed page objects), with an explicit hint that text extraction isn't wired yet.
  • Archive / binary / empty: metadata and the sniffed format only.
  • folder, missing, unreadable, unreachable are typed statuses (ErrorKind-based, no string matching). The read runs on a blocking thread under a 5 s timeout so a hung mount can't wedge a turn.

Wiring: registry entry (consumers: [Agent], access: Read), ToolId::InspectFile, the expected-names and 1:1 view tests, rail labels (askCmdr.tool.inspectFile.* in en, keys regenerated), the refusal copy in view.rs, and the agent/ + agent/tools/ docs. FIXED_PROMPT_OVERHEAD_TOKENS and TOOL_DECLARATION_TOKENS move by the new declaration's estimated cost.

Not done / needs David

  • Consent copy. This is the first tool that egresses arbitrary file contents to the provider. askCmdr.consent.* names only the photo pair today; it has to name file contents too (and CONSENT_COPY_VERSION bumped) before this ships. Human copy, so left for you. Both CLAUDE.mds carry a ❌ for it.
  • PDF text extraction needs a new crate (pdf-extract or lopdf), which needs cargo deny check and a version check I didn't have time for. The result says so honestly instead of returning empty text.
  • Non-English catalogs fall back for the two new labels.
  • Not compiled here. The cloud container lacks GTK dev libraries, so cargo check can't build the Tauri crate. CI is the first build; the budget figures may need a nudge from cost_tests.rs' measured numbers.

🤖 Generated with Claude Code

https://claude.ai/code/session_011RzRP12m1FGqFm7RQcvGYr


Generated by Claude Code

…hat's this file?" gets a real answer

Adds one agent-only read tool, `inspect_file`, that inspects a single file the user points at and returns everything the model needs to describe it: name, size, modified, extension, a MIME guess, the format its leading bytes really are (`detected`, so a lying extension shows beside `mime`), and a typed `content` section per kind.

- Text: a character window (`offset` + `maxChars`, default 4,000, cap 16,000) with honest `totalChars` and `truncated`, so a long file is paged, never dumped into the turn.
- Image: width and height from the header, plus a pointer to `image_facts` for what is in the picture. Image bytes never cross.
- PDF: header version and a `pageCountEstimate` (a lower bound, counted from uncompressed page objects), with an explicit hint that text extraction isn't wired yet.
- Archive, binary, and empty files: metadata and the sniffed format only.
- `folder`, `missing`, `unreadable`, and `unreachable` are typed statuses; the read runs on a blocking thread under a 5 s timeout so a hung mount can't wedge a turn.

Wiring: registry entry (`consumers: [Agent]`, `access: Read`), `ToolId::InspectFile`, the expected-name and 1:1 view tests, the rail label (`askCmdr.tool.inspectFile.*` in `en`, keys regenerated), and the `agent/tools` docs. The fixed prompt overhead and tool-declaration figures move by the new declaration's cost.

Not done, flagged for the human side: this is the first tool that egresses arbitrary file contents to the provider, so the Ask Cmdr consent copy has to name it before release, and the non-English catalogs still fall back for the two new labels. The Rust changes are not compiled here (the cloud container lacks the GTK dev libraries Tauri needs), so CI is the first build.
@vdavid

vdavid commented Sep 4, 2026

Copy link
Copy Markdown
Owner Author

Landed on main already, via rebase, so the hashes don't match. inspect_file is in main with five follow-ups on top: the system prompt telling the model how to read the honesty flags (eebafea40), the security doc naming its five egress items (60430049e), the archive-router rename for discarded-outcome (ccad981c5), and the docs slimming (76d9e8b1e). Nothing here is unmerged. Closing and deleting the branch.

@vdavid vdavid closed this Sep 4, 2026
@vdavid
vdavid deleted the claude/cmdr-file-inspection-tools-922rhs branch September 4, 2026 08:52
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