Merge pull request #1993 from zhangxy-zju/fix/subagent-output-language

fix(subagent): append output-language.md to subagent system prompt and prioritize project-level settings
This commit is contained in:
tanzhenxin 2026-03-02 17:08:52 +08:00 committed by GitHub
commit 74f5b76754
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 173 additions and 5 deletions

View file

@ -380,4 +380,62 @@ describe('languageUtils', () => {
expect(fs.writeFileSync).not.toHaveBeenCalled();
});
});
describe('output-language.md path resolution priority', () => {
it('should prefer project-level path over global path', () => {
const projectPath = '/project/.qwen/output-language.md';
const globalPath = '/mock/home/.qwen/output-language.md';
vi.mocked(fs.existsSync).mockImplementation((p) => {
if (p.toString() === projectPath) return true;
if (p.toString() === globalPath) return true;
return false;
});
let resolvedPath: string | undefined;
if (fs.existsSync(projectPath)) {
resolvedPath = projectPath;
} else if (fs.existsSync(globalPath)) {
resolvedPath = globalPath;
}
expect(resolvedPath).toBe(projectPath);
});
it('should fall back to global path when project-level does not exist', () => {
const projectPath = '/project/.qwen/output-language.md';
const globalPath = '/mock/home/.qwen/output-language.md';
vi.mocked(fs.existsSync).mockImplementation((p) => {
if (p.toString() === projectPath) return false;
if (p.toString() === globalPath) return true;
return false;
});
let resolvedPath: string | undefined;
if (fs.existsSync(projectPath)) {
resolvedPath = projectPath;
} else if (fs.existsSync(globalPath)) {
resolvedPath = globalPath;
}
expect(resolvedPath).toBe(globalPath);
});
it('should return undefined when neither path exists', () => {
const projectPath = '/project/.qwen/output-language.md';
const globalPath = '/mock/home/.qwen/output-language.md';
vi.mocked(fs.existsSync).mockReturnValue(false);
let resolvedPath: string | undefined;
if (fs.existsSync(projectPath)) {
resolvedPath = projectPath;
} else if (fs.existsSync(globalPath)) {
resolvedPath = globalPath;
}
expect(resolvedPath).toBeUndefined();
});
});
});