Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(shared): preserve comma file references

DavidShen8519157e0a2c
diff --git a/packages/maker-shared/src/__tests__/pluginResults.test.ts b/packages/maker-shared/src/__tests__/pluginResults.test.ts
index f4994452cf..61d92ee512 100644
--- a/packages/maker-shared/src/__tests__/pluginResults.test.ts
+++ b/packages/maker-shared/src/__tests__/pluginResults.test.ts
@@ -80,6 +80,21 @@ describe('portable plugin results', () => {
expect(files('[报告](' + url + ')')).toEqual([{ url, title: 'report[final].pdf' }]);
expect(files(JSON.stringify({ note: 'Saved ' + url }))).toEqual([{ url, title: 'report[final].pdf' }]);
});
+ it.each([
+ 'xdt-file:///tmp/report,final.pdf',
+ 'xdt-file:///C:/reports/report,final.pdf',
+ 'xdt-file://open?path=/tmp/report,final.pdf',
+ 'xdt-file://open?path=%2Ftmp%2Freport%2Cfinal.pdf',
+ ])('preserves commas in file names without extracting source fixtures: %s', (url) => {
+ const expected = [{ url, title: 'report,final.pdf' }];
+ expect(files('[报告](' + url + ')')).toEqual(expected);
+ expect(files('Saved "' + url + '"')).toEqual(expected);
+ expect(files(JSON.stringify({ note: 'Saved ' + url }))).toEqual(expected);
+ expect(files(JSON.stringify([url]))).toEqual(expected);
+ const source = 'const urls = ["' + url + '", "xdt-file:///tmp/fixture.pdf"];';
+ expect(files(source)).toEqual([]);
+ expect(files(JSON.stringify({ text: source }))).toEqual([]);
+ });
it.each(["'", '"', String.fromCharCode(96)])('keeps prose links quoted with %s without reviving source literals', (quote) => {
const url = 'xdt-file:///tmp/report.pdf';
const prose = 'Saved ' + quote + url + quote;
diff --git a/packages/maker-shared/src/payloadSummary.ts b/packages/maker-shared/src/payloadSummary.ts
index fdb3ddc0dc..065c881bb6 100644
--- a/packages/maker-shared/src/payloadSummary.ts
+++ b/packages/maker-shared/src/payloadSummary.ts
@@ -466,7 +466,7 @@ export function extractPayloadToolCardIds(text: string): string[] {
export interface PayloadToolFile { url: string; title: string }
-const TOOL_FILE_URL_RE = /xdt-file:\/\/[^\s"'<>\\)`},;]+/g;
+const TOOL_FILE_URL_RE = /xdt-file:\/\/[^\s"'<>\\)`};]+/g;
function absoluteToolFilePath(url: string): string | null {
try {