feat(coder): format expanded image references cleanly as [Image: path]

dfcdd4867529 · AtlantisPleb · · parent 6f8b64e1f100

feat(coder): format expanded image references cleanly as [Image: path]

Deploy story

What this commit did to the running system — joined from the forge receipt chain, the part a commit page elsewhere cannot show.

Not deployed through the forge lane

No push, promotion, build, or deploy receipt references this commit (receipts are scanned over a bounded recent window). Changes shipped by full node replacement carry their proof in the release gate receipt instead.

Changed files

  • modified packages/openagents-cli/src/coder-image.ts
  • modified packages/openagents-cli/test/coder-image.test.ts

Diff

2 files changed, +5 -5

packages/openagents-cli/src/coder-image.ts modified +3 -2

@@ -166,7 +166,8 @@ export function mimeTypeForImage(filePath: string): string {

166 166
}
167 167
168 168
/**
169
 * Replace `[Image #N]` references with Markdown image tags or text descriptions.
169
 * Replace `[Image #N]` references with clean file path references for model submission.
170
 * Avoids redundant repetition like `![filename](path)` by formatting as `[Image: path]`.
170 171
 */
171 172
export function expandImageRefsForModel(
172 173
  input: string,

@@ -188,7 +189,7 @@ export function expandImageRefsForModel(

188 189
    const id = parseInt(match[1] ?? "0", 10);
189 190
    const entry = getEntry(id);
190 191
    if (entry !== undefined) {
191
      const replacement = `![${entry.filename}](${entry.path})`;
192
      const replacement = `[Image: ${entry.path}]`;
192 193
      expanded =
193 194
        expanded.slice(0, match.index) +
194 195
        replacement +
packages/openagents-cli/test/coder-image.test.ts modified +2 -3

@@ -5,7 +5,6 @@ import { describe, expect, it } from "vitest";

5 5
import {
6 6
  asImageFilePath,
7 7
  expandImageRefsForModel,
8
  formatImageRef,
9 8
  mimeTypeForImage,
10 9
  parseDroppedImagePaths,
11 10
  removeOuterQuotes,

@@ -86,7 +85,7 @@ describe("coder-image utilities", () => {

86 85
    }
87 86
  });
88 87
89
  it("expands image references and prompt text for model submission", () => {
88
  it("expands image references cleanly without duplicate filenames", () => {
90 89
    const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "openagents-img-test-"));
91 90
    const img = path.join(tmpDir, "chart.png");
92 91
    fs.writeFileSync(img, "fake chart");

@@ -110,7 +109,7 @@ describe("coder-image utilities", () => {

110 109
      const expanded = expandComposerPrompt(composer, pastedText, pastedImages);
111 110
112 111
      expect(expanded).toBe(
113
        `Please analyze ![chart.png](${img}) and read pasted multi\nline text.`,
112
        `Please analyze [Image: ${img}] and read pasted multi\nline text.`,
114 113
      );
115 114
    } finally {
116 115
      fs.rmSync(tmpDir, { recursive: true, force: true });

This page updates live while a promote is in flight · changelog