CommandCodeAI / CommandCodeAI/command-code
vision input fails
还没有人认领这个 Issue。
- 主要语言
- 没有语言数据
- 星标
- 4k
- 派生
- 350
- PR 合并指标
- 30 天内没有已合并 PR
描述
Summary
Vision input currently works only through interactive TUI clipboard-paste and drag-drop (detectDroppedImageFile / detectClipboardImage → Jimp → base64 → {type:"image"}).
Environment
- cmd v0.38.2
- Installed via npm i -g command-code (mise)
- macOS (darwin)
- Model: Claude Sonnet 4 (claude-4-sonnet-20250514) — confirmed inputModalities: ["text","image"]
Reproduce
1. Put any JPEG or PNG in the working directory
2. Run:
cmd -p "Describe what you see in test.jpg"
Result: Model responds that it cannot visually inspect the image. Same result for PNG, GIF, WEBP.
Root cause (from inspecting dist/index.mjs)
- read_file returns text-only output for all binary files
src/tools/read-file/read-file.ts → formatOutput:
function formatOutput(e) {
if ("binary" === e.contentType)
return [...,Binary file: ${e.fileType}].join("\n");
// Model only ever sees: "Binary file: image/jpeg"
...
}
No {type: "image"} content block is ever created from a file read. The raw bytes are read into a Buffer but discarded. - @filepath references silently skip binary files
src/utils/file-references.ts → processFileReferences:
if ("binary" === i.contentType) continue; // images vanish entirely - AVIF and other modern formats fall through to the text path
getFileType uses a hardcoded extension map (Ib) with no .avif entry:
Ib = { ".png":"image/png", ".jpg":"image/jpeg", ".jpeg":"image/jpeg",
".gif":"image/gif", ".webp":"image/webp", ".svg":"image/svg+xml",
".bmp":"image/bmp", ".ico":"image/x-icon", ... }
// No .avif, .heic, .heif, .tiff
Since getFileType(".avif") returns "unknown", and isBinaryFile("unknown") returns false (it only matches known MIME values), AVIF files are read as UTF-8 text — producing garbled output rather than being flagged as binary. - Vision content blocks only exist in the TUI paste/drag-drop path
src/utils/clipboard-image.ts → detectDroppedImageFile → Jimp resize → base64 → {type:"image"}. This path is a React/Ink interactive handler and is not reachable in headless mode.
Expected Behavior
..
Actual Behavior
..
Steps to reproduce the issue
..
Command Code Version
latest
Operating System
macOS
Terminal/IDE
No response
Shell
No response
Additional context
No response
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 src/tools/read-file/read-file.ts 和 src/utils/file-references.ts 开始,然后将它们的二进制处理与 src/utils/clipboard-image.ts 进行比较。针对本地图像使用 cmd -p 重现,并跟踪文件如何到达模型;完成标准是,受支持的图像文件(包括 issue 中提到的格式)在 headless mode 下生成 vision content,而不是仅生成文本或被跳过。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- ai, cli
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100