CommandCodeAI / CommandCodeAI/command-code

vision input fails

Offen
#559 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Keine Sprachdaten
Sterne
4k
Forks
350
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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)

  1. 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.
  2. @filepath references silently skip binary files
    src/utils/file-references.ts → processFileReferences:
    if ("binary" === i.contentType) continue; // images vanish entirely
  3. 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.
  4. 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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit src/tools/read-file/read-file.ts und src/utils/file-references.ts und vergleiche anschließend deren Binärverarbeitung mit src/utils/clipboard-image.ts. Reproduziere das Problem mit cmd -p anhand eines lokalen Bildes und verfolge, wie die Datei das Modell erreicht; abgeschlossen ist die Aufgabe, wenn unterstützte Bilddateien, einschließlich der im Issue genannten Formate, im headless mode vision content erzeugen, statt nur Text zu liefern oder übersprungen zu werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
ai, cli
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.