From a49d3af7a9465509448b917b542d104daf98f364 Mon Sep 17 00:00:00 2001 From: nrslib <38722970+nrslib@users.noreply.github.com> Date: Tue, 24 Feb 2026 16:48:43 +0900 Subject: [PATCH] =?UTF-8?q?settingSources=20=E3=81=AB=20project=20?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=80=81CLAUDE.md=20?= =?UTF-8?q?=E3=81=AE=E8=AA=AD=E3=81=BF=E8=BE=BC=E3=81=BF=E3=82=92=20SDK=20?= =?UTF-8?q?=E3=81=AB=E5=A7=94=E8=AD=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 手動で CLAUDE.md を読み込んでいた loadProjectContext を削除し、 SDK の settingSources: ['project'] でプロジェクトコンテキストを自動解決するよう変更 --- src/__tests__/permission-mode.test.ts | 7 +++++++ src/infra/claude/options-builder.ts | 1 + src/infra/fs/index.ts | 1 - src/infra/fs/session.ts | 21 --------------------- 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/__tests__/permission-mode.test.ts b/src/__tests__/permission-mode.test.ts index 6599232..886a962 100644 --- a/src/__tests__/permission-mode.test.ts +++ b/src/__tests__/permission-mode.test.ts @@ -103,3 +103,10 @@ describe('SdkOptionsBuilder.build() — mcpServers', () => { expect(sdkOptions.permissionMode).toBe('acceptEdits'); }); }); + +describe('SdkOptionsBuilder.build() — settingSources', () => { + it('includes project in settingSources', () => { + const options = buildSdkOptions({ cwd: '/test' }); + expect(options.settingSources).toEqual(['project']); + }); +}); diff --git a/src/infra/claude/options-builder.ts b/src/infra/claude/options-builder.ts index 8b0cba7..02176af 100644 --- a/src/infra/claude/options-builder.ts +++ b/src/infra/claude/options-builder.ts @@ -57,6 +57,7 @@ export class SdkOptionsBuilder { const sdkOptions: Options = { cwd: this.options.cwd, permissionMode, + settingSources: ['project'], }; if (this.options.model) sdkOptions.model = this.options.model; diff --git a/src/infra/fs/index.ts b/src/infra/fs/index.ts index 1b143ae..9c18038 100644 --- a/src/infra/fs/index.ts +++ b/src/infra/fs/index.ts @@ -26,5 +26,4 @@ export { createSessionLog, finalizeSessionLog, loadSessionLog, - loadProjectContext, } from './session.js'; diff --git a/src/infra/fs/session.ts b/src/infra/fs/session.ts index 34ea8a7..d8b8f4a 100644 --- a/src/infra/fs/session.ts +++ b/src/infra/fs/session.ts @@ -198,23 +198,6 @@ export class SessionManager { return JSON.parse(content) as SessionLog; } - /** Load project context (CLAUDE.md files) */ - loadProjectContext(projectDir: string): string { - const contextParts: string[] = []; - - const rootClaudeMd = join(projectDir, 'CLAUDE.md'); - if (existsSync(rootClaudeMd)) { - contextParts.push(readFileSync(rootClaudeMd, 'utf-8')); - } - - const dotClaudeMd = join(projectDir, '.claude', 'CLAUDE.md'); - if (existsSync(dotClaudeMd)) { - contextParts.push(readFileSync(dotClaudeMd, 'utf-8')); - } - - return contextParts.join('\n\n---\n\n'); - } - } const defaultManager = new SessionManager(); @@ -265,10 +248,6 @@ export function loadSessionLog(filepath: string): SessionLog | null { return defaultManager.loadSessionLog(filepath); } -export function loadProjectContext(projectDir: string): string { - return defaultManager.loadProjectContext(projectDir); -} - /** * Extract failure information from an NDJSON session log file. *