Skip to content

CLI file-drop misses quoted relative image paths #15197

@NewTurn2017

Description

@NewTurn2017

Bug Description

Quoted relative local image paths are not detected by the CLI file-drop/single-query image attachment path. This means an input like "./rel image.png" describe this is sent as plain text instead of attaching the image.

Affected files/lines

  • cli.py:1413-1449_detect_file_drop() has a starts_like_path prefilter that accepts unquoted ./ / ../, and quoted absolute / tilde / Windows paths, but not quoted "./..." or "../..." paths.
  • cli.py:1284-1324_split_path_input() already supports quoted path tokens and escaped spaces.
  • cli.py:1327-1362_resolve_attachment_path() already resolves relative paths against TERMINAL_CWD / os.getcwd().
  • tests/cli/test_cli_file_drop.py:133-193 covers escaped spaces, unquoted spaces, file URI, and tilde paths, but not quoted relative paths.

Why this is a bug

The lower-level path parsing/resolution code supports quoted and relative paths, but _detect_file_drop() rejects quoted relative inputs before it reaches that code. Quoting relative paths is a common shell/CLI habit when the filename contains spaces.

Minimal reproduction

From the repo root with the venv active:

source venv/bin/activate
python - <<'PY'
from pathlib import Path
from tempfile import TemporaryDirectory
import os
from cli import _detect_file_drop

with TemporaryDirectory() as td:
    p = Path(td) / 'rel image.png'
    p.write_bytes(b'fake')
    old = os.getcwd()
    os.chdir(td)
    try:
        print(_detect_file_drop('"./rel image.png" describe'))
        print(_detect_file_drop(f'"{p}" describe'))
    finally:
        os.chdir(old)
PY

Actual output observed during review:

None
{'path': PosixPath('.../rel image.png'), 'is_image': True, 'remainder': 'describe'}

Expected behavior

_detect_file_drop('"./rel image.png" describe') should return the same kind of attachment dict as the quoted absolute path case, with remainder == 'describe'.

Suggested investigation direction

Extend the starts_like_path prefilter in _detect_file_drop() to allow quoted relative prefixes ("./, './, "../, '../) and add regression tests in tests/cli/test_cli_file_drop.py. Also consider checking the same path through _collect_query_images() because single-query hermes chat -q '"./rel image.png" ...' depends on this detection path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/cliCLI entry point, hermes_cli/, setup wizardtype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions