settingSources に project を追加し、CLAUDE.md の読み込みを SDK に委譲
手動で CLAUDE.md を読み込んでいた loadProjectContext を削除し、 SDK の settingSources: ['project'] でプロジェクトコンテキストを自動解決するよう変更
This commit is contained in:
parent
cc7f73dc3e
commit
a49d3af7a9
@ -103,3 +103,10 @@ describe('SdkOptionsBuilder.build() — mcpServers', () => {
|
|||||||
expect(sdkOptions.permissionMode).toBe('acceptEdits');
|
expect(sdkOptions.permissionMode).toBe('acceptEdits');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('SdkOptionsBuilder.build() — settingSources', () => {
|
||||||
|
it('includes project in settingSources', () => {
|
||||||
|
const options = buildSdkOptions({ cwd: '/test' });
|
||||||
|
expect(options.settingSources).toEqual(['project']);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@ -57,6 +57,7 @@ export class SdkOptionsBuilder {
|
|||||||
const sdkOptions: Options = {
|
const sdkOptions: Options = {
|
||||||
cwd: this.options.cwd,
|
cwd: this.options.cwd,
|
||||||
permissionMode,
|
permissionMode,
|
||||||
|
settingSources: ['project'],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.options.model) sdkOptions.model = this.options.model;
|
if (this.options.model) sdkOptions.model = this.options.model;
|
||||||
|
|||||||
@ -26,5 +26,4 @@ export {
|
|||||||
createSessionLog,
|
createSessionLog,
|
||||||
finalizeSessionLog,
|
finalizeSessionLog,
|
||||||
loadSessionLog,
|
loadSessionLog,
|
||||||
loadProjectContext,
|
|
||||||
} from './session.js';
|
} from './session.js';
|
||||||
|
|||||||
@ -198,23 +198,6 @@ export class SessionManager {
|
|||||||
return JSON.parse(content) as SessionLog;
|
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();
|
const defaultManager = new SessionManager();
|
||||||
@ -265,10 +248,6 @@ export function loadSessionLog(filepath: string): SessionLog | null {
|
|||||||
return defaultManager.loadSessionLog(filepath);
|
return defaultManager.loadSessionLog(filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadProjectContext(projectDir: string): string {
|
|
||||||
return defaultManager.loadProjectContext(projectDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract failure information from an NDJSON session log file.
|
* Extract failure information from an NDJSON session log file.
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user