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(codex): 兼容无换行补丁元数据

DavidShen1450f16d2863
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 43bbad74f3..46c2c2e8bf 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -4469,12 +4469,12 @@
},
"review": {
"turn": {
- "title": "このターンの変更",
+ "title": "このメッセージの変更",
"currentWorkspace": "現在のワークスペース",
- "localOnly": "ターン単位の正確な変更は、リモートタスクではまだ利用できません。",
- "partialNotice": "このターンには正確に追跡できないコマンドまたはツールの書き込みが含まれます。以下は取得できた一部のみで、完全なパッチではありません。",
+ "localOnly": "メッセージ単位の正確な変更は、リモートタスクではまだ利用できません。",
+ "partialNotice": "このメッセージには正確に追跡できないコマンドまたはツールの書き込みが含まれます。以下は取得できた一部のみで、完全なパッチではありません。",
"emptyTitle": "記録された変更はありません",
- "emptyDesc": "このターンで保存されたパッチに表示可能なファイル変更はありません。"
+ "emptyDesc": "このメッセージで保存されたパッチに表示可能なファイル変更はありません。"
},
"fileCount_one": "{{count}} ファイル",
"fileCount_other": "{{count}} ファイル",
diff --git a/packages/maker-core/src/agents/codex/index.test.ts b/packages/maker-core/src/agents/codex/index.test.ts
index 7fd9270267..28798ee3cb 100644
--- a/packages/maker-core/src/agents/codex/index.test.ts
+++ b/packages/maker-core/src/agents/codex/index.test.ts
@@ -19349,6 +19349,49 @@ describe('CodexAgent context window reporting', () => {
await handle.close();
});
+ it('composes overlapping descendant hunks with no-newline metadata', async () => {
+ const agent = new CodexAgent(createDeps());
+ const host = installFakeHost(agent);
+ const handle = await agent.startSession({
+ sessionId: 'session-overlapping-no-newline-diff',
+ model: 'gpt-5.4',
+ workingDir: '/repo',
+ });
+ const events: AgentEvent[] = [];
+ void (async () => {
+ for await (const event of handle.events()) events.push(event);
+ })();
+ const handlers = host.getThreadHandlers();
+ if (!handlers?.descendantThreadStarted || !handlers.descendantNotification) {
+ throw new Error('expected descendant handlers');
+ }
+
+ handlers.turnStarted?.({ threadId: 'start-thread-id', turn: { id: 'turn-overlap-no-newline' } });
+ handlers.turnDiffUpdated?.({
+ threadId: 'start-thread-id',
+ turnId: 'turn-overlap-no-newline',
+ diff: 'diff --git a/shared.txt b/shared.txt\n--- a/shared.txt\n+++ b/shared.txt\n@@ -1 +1 @@\n-old\n\\ No newline at end of file\n+root\n\\ No newline at end of file',
+ });
+ handlers.descendantThreadStarted({
+ thread: { id: 'child-overlap-no-newline', parentThreadId: 'start-thread-id' },
+ });
+ handlers.descendantNotification('child-overlap-no-newline', 'turn/diff/updated', {
+ threadId: 'child-overlap-no-newline',
+ turnId: 'child-overlap-no-newline-turn',
+ diff: 'diff --git a/shared.txt b/shared.txt\n--- a/shared.txt\n+++ b/shared.txt\n@@ -1 +1 @@\n-root\n\\ No newline at end of file\n+child\n\\ No newline at end of file',
+ });
+
+ await vi.waitFor(() => {
+ const last = events.filter((event) => event.type === 'turn_diff').at(-1);
+ const data = last?.data as { diff?: string; isComplete?: boolean } | undefined;
+ expect(data?.isComplete).toBe(true);
+ expect(data?.diff).toContain('-old');
+ expect(data?.diff).toContain('+child');
+ });
+
+ await handle.close();
+ });
+
it('composes an overlapping pure deletion at the preimage line', async () => {
const agent = new CodexAgent(createDeps());
const host = installFakeHost(agent);
diff --git a/packages/maker-core/src/agents/codex/index.ts b/packages/maker-core/src/agents/codex/index.ts
index 18542fa09b..dfd1c941af 100644
--- a/packages/maker-core/src/agents/codex/index.ts
+++ b/packages/maker-core/src/agents/codex/index.ts
@@ -1257,6 +1257,7 @@ function parseTurnDiffHunk(raw: string): ParsedTurnDiffHunk | null {
const oldLines: string[] = [];
const newLines: string[] = [];
for (const line of lines) {
+ if (line === '\\ No newline at end of file') continue;
if (line.startsWith('\\')) return null;
const prefix = line[0];
const content = line.slice(1);