fix(subagent-acp): reject an empty config cwd at load

path.resolve('') is the process cwd, so an empty configured cwd would
silently reintroduce the launch-directory fallback the parent-session
cwd resolution removed. Fail at plugin load with an actionable message
instead.
This commit is contained in:
Yichen Jiang
2026-07-19 15:56:32 +08:00
parent 05f0c12880
commit b758a7496b
4 changed files with 32 additions and 11 deletions

View File

@@ -199,6 +199,22 @@ describe('cwd resolution', () => {
expect(text(result.output)).toBe(`${realpathSync(absolute)}\n${absolute}`)
})
it('rejects an empty config cwd at load', async () => {
// `path.resolve('')` is the process cwd, so an empty string would silently
// reintroduce the launch-directory fallback this resolution removed.
const ctx = new Context()
await ctx.plugin(SubagentService)
await expect(ctx.plugin(acp, {
providerName: 'acp',
command: 'true',
args: [],
cwd: '',
permission: 'reject',
env: {},
})).rejects.toThrow('config cwd must not be empty')
await ctx.fiber.dispose()
})
it('rejects a config cwd that is not an accessible directory at load', async () => {
const ctx = new Context()
await ctx.plugin(SubagentService)