Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(shared): retain literal percent signs in legacy file paths
DavidShen07e5e74b4006
diff --git a/packages/maker-shared/src/__tests__/pluginResults.test.ts b/packages/maker-shared/src/__tests__/pluginResults.test.tsindex da1a53444e..c1702f3ec3 100644--- a/packages/maker-shared/src/__tests__/pluginResults.test.ts+++ b/packages/maker-shared/src/__tests__/pluginResults.test.ts@@ -7,7 +7,7 @@ describe('portable plugin results', () => {it('preserves the legacy direct-path punctuation alphabet in real references', () => {// #4692 accepted these filename characters. Source filtering must not// redefine the URL alphabet and silently point to a different file.- for (const punctuation of "!#$&'(*+,-.:;=?@[]^_{}~" + String.fromCharCode(96)) {+ for (const punctuation of "!#$%&'(*+,-.:;=?@[]^_{}~" + String.fromCharCode(96)) {const title = 'report' + punctuation + 'final.pdf';const url = 'xdt-file:///tmp/' + title;const expected = [{ url, title }];@@ -63,6 +63,22 @@ describe('portable plugin results', () => {expect(files(JSON.stringify({ _xdt_model_files: [{ url, name: title }] }))).toEqual([{ url, title }]);expect(files(JSON.stringify({ xdt_media_produced: [url] }))).toEqual([{ url, title }]);});+ it.each([+ ['xdt-file:///tmp/report100%.pdf', 'report100%.pdf'],+ ['xdt-file:///C:/reports/report100%.pdf', 'report100%.pdf'],+ ['xdt-file:///tmp/report%ZZ.pdf', 'report%ZZ.pdf'],+ ['xdt-file:///tmp/report%2', 'report%2'],+ ['xdt-file:///tmp/report%FF.pdf', 'report%FF.pdf'],+ ['xdt-file:///tmp/report%20at100%25.pdf', 'report at100%.pdf'],+ ['xdt-file:///tmp/report%2520.pdf', 'report%20.pdf'],+ ['xdt-file://open?path=%2Ftmp%2Freport100%25.pdf', 'report100%.pdf'],+ ])('retains percent file names and decodes valid escapes once: %s', (url, title) => {+ const expected = [{ url, title }];+ expect(files('[report](' + url + ')')).toEqual(expected);+ expect(files(JSON.stringify({ note: url }))).toEqual(expected);+ expect(files(JSON.stringify({ _xdt_model_files: [{ url }] }))).toEqual(expected);+ expect(files('const path = "' + url + '";')).toEqual([]);+ });it.each(['note', 'text', 'output'])('ignores source literals inside JSON %s while retaining real links', (field) => {const source = ["const a = 'xdt-file://open?path=%2Ftmp%2Ffixture.pdf';",diff --git a/packages/maker-shared/src/payloadSummary.ts b/packages/maker-shared/src/payloadSummary.tsindex 2d0a5a0a08..b0f52695cc 100644--- a/packages/maker-shared/src/payloadSummary.ts+++ b/packages/maker-shared/src/payloadSummary.ts@@ -473,9 +473,15 @@ const TOOL_FILE_URL_RE = /xdt-file:\/\/[^\s"<>\\)]+/g;function absoluteToolFilePath(url: string): string | null {try {// Keep both legacy direct-path links and the query-based local/open URLs.- const path = url.startsWith('xdt-file:///')- ? decodeURIComponent(url.slice('xdt-file://'.length))- : new URL(url).searchParams.get('path') ?? '';+ let path: string;+ if (url.startsWith('xdt-file:///')) {+ path = url.slice('xdt-file://'.length);+ // Legacy direct paths may contain a literal percent sign. Decode valid+ // escapes once, but retain the original path if it is not URI-encoded.+ try { path = decodeURIComponent(path); } catch { /* Keep the literal path. */ }+ } else {+ path = new URL(url).searchParams.get('path') ?? '';+ }return path.startsWith('/') || /^[A-Za-z]:[\\/]/.test(path) ? path : null;} catch {return null;