Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(review): disable native project doc discovery (#5888)
Tsai Yuan3ea90999d01f
diff --git a/packages/maker-core/src/agents/codex/index.test.ts b/packages/maker-core/src/agents/codex/index.test.tsindex f7975b3842..e87286cba7 100644--- a/packages/maker-core/src/agents/codex/index.test.ts+++ b/packages/maker-core/src/agents/codex/index.test.ts@@ -2000,8 +2000,9 @@ describe('CodexAgent permissions', () => {expect.objectContaining({ name: 'review_view_image' }),]);} else {- expect(threadStart.config).not.toHaveProperty('project_doc_max_bytes');expect(threadStart).not.toHaveProperty('dynamicTools');+ expect(threadStart.config).toHaveProperty('project_root_markers', []);+ expect(threadStart.config).not.toHaveProperty('project_doc_max_bytes');}expect(threadStart.config).not.toHaveProperty(['windows.sandbox']);expect((threadStart.config as Record<string, unknown>)['skills.config']).toEqual([diff --git a/packages/maker-core/src/agents/codex/index.ts b/packages/maker-core/src/agents/codex/index.tsindex addc90dd6c..d74bf83e62 100644--- a/packages/maker-core/src/agents/codex/index.ts+++ b/packages/maker-core/src/agents/codex/index.ts@@ -6485,6 +6485,10 @@ assertRouteCurrent();: {}),...(reviewMode? {+ // Keep project instructions inside the approved Review root.+ // An empty marker list stops Codex from walking above cwd while+ // still loading an AGENTS.md located in cwd itself.+ ...(process.platform === 'win32' ? {} : { project_root_markers: [] }),// Windows native sandboxes cannot enforce this split read scope.// Keep the deny policy, and route evidence reads through the host.// Native AGENTS discovery also invokes that incompatible sandbox.diff --git a/packages/maker-core/src/agents/codex/review-start.native.test.ts b/packages/maker-core/src/agents/codex/review-start.native.test.tsindex cd10dfd73f..055a2833c5 100644--- a/packages/maker-core/src/agents/codex/review-start.native.test.ts+++ b/packages/maker-core/src/agents/codex/review-start.native.test.ts@@ -15,6 +15,111 @@ const logger: Logger = {child: () => logger,};+describe.skipIf(!binaryPath || process.platform !== 'darwin')('macOS Codex Review with real app-server', () => {+ it('starts without reading an ancestor AGENTS.md outside the review workspace', async () => {+ const root = await mkdtemp(path.join(tmpdir(), 'cindy-review-project-doc-'));+ const home = path.join(root, 'codex');+ const workingDir = path.join(root, 'repo', 'work');+ const projectRule = 'ANCESTOR_PROJECT_RULE_MUST_NOT_REACH_REVIEW';+ const workspaceRule = 'WORKSPACE_PROJECT_RULE_MUST_REACH_REVIEW';+ const reviewEvidence = 'CINDY_STRUCTURED_REVIEW_EVIDENCE';+ const requests: unknown[] = [];+ const server = createServer(async (req, res) => {+ const chunks = [];+ for await (const chunk of req) chunks.push(chunk);+ const request = JSON.parse(Buffer.concat(chunks).toString());+ requests.push(request);+ const reviewResult = JSON.stringify(request).includes(reviewEvidence)+ ? 'P2 fixture finding: structured review evidence reached the model'+ : 'fixture failure: structured review evidence missing';+ res.writeHead(200, { 'content-type': 'text/event-stream', connection: 'close' });+ const events = [+ { type: 'response.created', response: { id: 'response-fixture' } },+ { type: 'response.output_item.done', item: { type: 'message', role: 'assistant', id: 'message-fixture',+ content: [{ type: 'output_text', text: reviewResult }] } },+ { type: 'response.completed', response: { id: 'response-fixture',+ usage: { input_tokens: 1, output_tokens: 1, total_tokens: 2 } } },+ ];+ res.end(events.map((event) => `event: ${event.type}\ndata: ${JSON.stringify(event)}\n\n`).join(''));+ });+ let agent: CodexAgent | undefined;+ try {+ await mkdir(home);+ await mkdir(path.join(root, 'repo', '.git'), { recursive: true });+ await mkdir(workingDir, { recursive: true });+ await writeFile(path.join(root, 'repo', 'AGENTS.md'), projectRule);+ await writeFile(path.join(workingDir, 'AGENTS.md'), workspaceRule);+ await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve));+ const endpoint = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;+ await writeFile(path.join(home, 'config.toml'), [+ 'model="fixture-model"',+ 'model_provider="fixture"',+ 'cli_auth_credentials_store="ephemeral"',+ 'check_for_update_on_startup=false',+ '[analytics]', 'enabled=false',+ '[model_providers.fixture]', 'name="Fixture"',+ `base_url="${endpoint}"`, 'wire_api="responses"',+ 'requires_openai_auth=false', 'request_max_retries=0',+ ].join('\n'));+ agent = new CodexAgent({+ binaryPath: binaryPath!, logger, runtimeConfig: {},+ resolveCodexLocalAuthPolicy: () => 'isolated',+ prepareCodexExtraSpawnConfig: async () => ({+ extraArgs: [], extraEnv: {}, codexProxyActive: true,+ }),+ auth: {+ getState: async () => ({ authenticated: true }),+ triggerLogin: async () => ({ authenticated: true }),+ logout: async () => {},+ getAuthEnv: async () => ({+ HOME: root, USERPROFILE: root, APPDATA: root, LOCALAPPDATA: root,+ CODEX_HOME: home, TMPDIR: root,+ OPENAI_API_KEY: '', CODEX_API_KEY: '',+ HTTP_PROXY: 'http://127.0.0.1:1', HTTPS_PROXY: 'http://127.0.0.1:1',+ ALL_PROXY: 'http://127.0.0.1:1', NO_PROXY: '127.0.0.1,localhost',+ }),+ },+ });+ const handle = await agent.startSession({+ sessionId: 'review-project-doc', providerId: 'cprov-fixture',+ model: 'fixture-model', workingDir, reviewMode: true,+ makerMemoryEnabled: false,+ });+ const receivedEvents: unknown[] = [];+ const events = (async () => {+ for await (const event of handle.events()) {+ receivedEvents.push(event);+ if (event.type === 'error') throw new Error(JSON.stringify(event));+ if (event.type === 'done') return;+ }+ })();+ await handle.send({ type: 'user', content: `Review the fixture: ${reviewEvidence}` }, { throwOnStartFailure: true });+ await events;+ expect(requests).toHaveLength(1);+ const requestPayload = JSON.stringify(requests);+ expect(requestPayload).toContain(reviewEvidence);+ expect(requestPayload).toContain(workspaceRule);+ expect(requestPayload).not.toContain(projectRule);+ expect(JSON.stringify(receivedEvents)).toContain(+ 'P2 fixture finding: structured review evidence reached the model',+ );+ await handle.close();+ } finally {+ try {+ await agent?.dispose();+ } finally {+ try {+ if (server.listening) {+ await new Promise<void>((resolve) => server.close(() => resolve()));+ }+ } finally {+ await rm(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });+ }+ }+ }+ }, 30_000);+});+describe.skipIf(!binaryPath || process.platform !== 'win32')('Windows Codex Review with real app-server', () => {it.each([{ binary: binaryPath!, configuredMemory: false, compatible: true, providerId: 'cprov-fixture', model: 'fixture-model' },