← Back to PRs

#8014: fix(media-understanding): support legacy {file} placeholder in CLI audio args

by Glucksberg open 2026-02-03 13:14 View on GitHub →
size: S experienced-contributor
## Summary Clean cherry-pick of #5925 - contains only the `{file}` placeholder fix without the 70+ unrelated commits. Adds `normalizePlaceholders()` to convert intuitive single-brace placeholders to the standard double-brace format before template substitution. ## Problem When using `tools.media.audio.models` with `type: "cli"`, the `{file}` placeholder in the `args` array was passed literally instead of being substituted with the actual audio file path. ```json { "tools": { "media": { "audio": { "models": [{ "type": "cli", "command": "whisper", "args": ["{file}", "--model", "large-v3-turbo"] }] } } } } ``` Error: `Error opening input file {file}.` ## Solution Add legacy placeholder normalization that converts intuitive single-brace placeholders before `applyTemplate()` is called. ### Supported aliases: - `{file}`, `{input}`, `{media}` → `{{MediaPath}}` - `{output}`, `{output_dir}` → `{{OutputDir}}` - `{output_base}` → `{{OutputBase}}` - `{prompt}` → `{{Prompt}}` - `{media_dir}` → `{{MediaDir}}` Case-insensitive matching for user convenience. ## Testing - Added comprehensive unit tests for `normalizePlaceholders()` - All tests pass - Build verified ## Replaces This is a clean version of #5925, which had accumulated 70+ commits from various merges. This PR contains only the essential fix. Fixes #5845 <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR fixes CLI media-audio arg templating by normalizing legacy single-brace placeholders like `{file}`/`{output}` into the existing double-brace template format (e.g. `{{MediaPath}}`) before calling `applyTemplate()` in `runCliEntry`. A new unit test file was added to validate placeholder normalization behavior across aliases and case-insensitive inputs. <h3>Confidence Score: 2/5</h3> - Not safe to merge as-is due to a parsing/compilation issue in the main runner module. - The new helper is placed before an `import type` block in `runner.ts`, which is invalid in ESM/TypeScript and should break builds. The functional change is otherwise small and well-scoped, but the current file structure needs correction and the tests currently validate a duplicated implementation rather than the production one. - src/media-understanding/runner.ts; src/media-understanding/runner.placeholders.test.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs