settingSources に project を追加し、CLAUDE.md の読み込みを SDK に委譲

手動で CLAUDE.md を読み込んでいた loadProjectContext を削除し、
SDK の settingSources: ['project'] でプロジェクトコンテキストを自動解決するよう変更
This commit is contained in:
nrslib 2026-02-24 16:48:43 +09:00
parent cc7f73dc3e
commit a49d3af7a9
4 changed files with 8 additions and 22 deletions

View File

@ -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']);
});
});

View File

@ -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;

View File

@ -26,5 +26,4 @@ export {
createSessionLog,
finalizeSessionLog,
loadSessionLog,
loadProjectContext,
} from './session.js';

View File

@ -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.
*