Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): recognize triple-quoted source strings
DavidShen2b198022bc51
diff --git a/apps/desktop/src/main/device-link/__tests__/mobileToolProjection.test.ts b/apps/desktop/src/main/device-link/__tests__/mobileToolProjection.test.tsindex 80e25e10af..73fb37e64a 100644--- a/apps/desktop/src/main/device-link/__tests__/mobileToolProjection.test.ts+++ b/apps/desktop/src/main/device-link/__tests__/mobileToolProjection.test.ts@@ -33,6 +33,7 @@ describe('mobile tool projection', () => {+ "const fallback = candidate || 'xdt-file:///tmp/logical.pdf'\n"+ "const paths = names.map(() => 'Open xdt-file:///tmp/callback.pdf')\n"+ 'const combined = "prefix" + "xdt-file:///tmp/combined.pdf"\n'+ + 'path = """Open\nxdt-file:///tmp/triple.pdf"""\n'+ 'path = r"xdt-file:///tmp/python.pdf"\nvar path = @"Open xdt-file:///tmp/csharp.pdf"\n'+ '// fixture: xdt-file:///tmp/comment.pdf\n/* example: xdt-file:///tmp/block.pdf */\n'+ "const list = [/* first */ 'xdt-file:///tmp/a.pdf', // next\n 'xdt-file:///tmp/b.pdf']\n"diff --git a/apps/mobile/src/__tests__/pluginResultRendering.test.ts b/apps/mobile/src/__tests__/pluginResultRendering.test.tsindex f2fb2de93b..a22a7879fb 100644--- a/apps/mobile/src/__tests__/pluginResultRendering.test.ts+++ b/apps/mobile/src/__tests__/pluginResultRendering.test.ts@@ -29,6 +29,7 @@ describe('plugin results are visible outside collapsed tool details', () => {+ "const fallback = candidate || 'xdt-file:///tmp/logical.pdf'\n"+ "const paths = names.map(() => 'Open xdt-file:///tmp/callback.pdf')\n"+ 'const combined = "prefix" + "xdt-file:///tmp/combined.pdf"\n'+ + 'path = """Open\nxdt-file:///tmp/triple.pdf"""\n'+ 'path = r"xdt-file:///tmp/python.pdf"\nvar path = @"Open xdt-file:///tmp/csharp.pdf"\n'+ '// fixture: xdt-file:///tmp/comment.pdf\n/* example: xdt-file:///tmp/block.pdf */\n'+ "const list = [/* first */ 'xdt-file:///tmp/a.pdf', // next\n 'xdt-file:///tmp/b.pdf']";diff --git a/packages/maker-shared/src/__tests__/pluginResults.test.ts b/packages/maker-shared/src/__tests__/pluginResults.test.tsindex d0510aa736..8a7a77aef1 100644--- a/packages/maker-shared/src/__tests__/pluginResults.test.ts+++ b/packages/maker-shared/src/__tests__/pluginResults.test.ts@@ -4,6 +4,31 @@ import { hasVisibleHistoryResult } from '../historyViewProjection.js';const blob = (ext: string) => `cindy-media://blobs/${'a'.repeat(64)}.${ext}`;describe('portable plugin results', () => {+ it.each(["'", '"'])('recognizes triple-quoted source strings using %s', (quote) => {+ const delimiter = quote.repeat(3);+ const url = 'xdt-file:///tmp/triple.pdf';+ for (const body of [url, 'Open\n' + quote + 'example' + quote.repeat(2) + '\n' + url,+ 'Escaped ' + '\\' + delimiter + ' Open ' + url]) {+ for (const prefix of ['', 'r', 'f']) {+ const literal = prefix + delimiter + body + delimiter;+ for (const source of ['path = ' + literal, 'path = "prefix" + ' + literal + ' + "suffix"']) {+ expect(files(source), source).toEqual([]);+ expect(files(JSON.stringify({ text: source })), source).toEqual([]);+ expect(files(source + '\nSaved "' + url + '"')).toEqual([{ url, title: 'triple.pdf' }]);+ expect(files(JSON.stringify({ text: source, _xdt_model_files: [{ url, name: 'Triple' }] })))+ .toEqual([{ url, title: 'Triple' }]);+ }+ expect(files('path = ' + prefix + delimiter + body)).toEqual([]);+ }+ }+ });+ it('preserves hash-prefixed Markdown deliveries and hashes in legacy file names', () => {+ const url = 'xdt-file:///tmp/report#final.pdf';+ for (const text of ['# fixture: ' + url, '## Report: ' + url, '# [report](' + url + ')']) {+ expect(files(text)).toEqual([{ url, title: 'report#final.pdf' }]);+ expect(files(JSON.stringify({ text }))).toEqual([{ url, title: 'report#final.pdf' }]);+ }+ });it.each(["'", '"', String.fromCharCode(96)])('keeps concatenated source literals out of delivered files: %s', (quote) => {const url = 'xdt-file:///tmp/concatenated.pdf';const literal = quote + url + quote;diff --git a/packages/maker-shared/src/payloadSummary.ts b/packages/maker-shared/src/payloadSummary.tsindex f5eae147bc..a9990b7ee0 100644--- a/packages/maker-shared/src/payloadSummary.ts+++ b/packages/maker-shared/src/payloadSummary.ts@@ -508,14 +508,20 @@ function* sourceContextTokens(text: string): Generator<{const start = index;const quote = text[index];if (quote === '"' || quote === "'" || quote === '`') {- index++;+ // Python triple quotes delimit one literal, including internal single or+ // double quotes and newlines. Backticks retain their existing semantics.+ const delimiter = quote !== '`' && text.startsWith(quote.repeat(3), index) ? quote.repeat(3) : quote;+ index += delimiter.length;let closed = false;while (index < text.length) {if (text[index] === '\\') {index = Math.min(index + 2, text.length);- } else if (text[index++] === quote) {+ } else if (text.startsWith(delimiter, index)) {+ index += delimiter.length;closed = true;break;+ } else {+ index++;}}yield { start, end: index, comment: false, closed };