From d647ce9f7d44fdd1481e6a78a307ccab50b3be05 Mon Sep 17 00:00:00 2001 From: Yichen Jiang Date: Tue, 11 Aug 2026 21:18:37 +0800 Subject: [PATCH] test(agent-presets): assert the derived root through the shipped bundles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new default's whole claim is that a launcher configuring nothing still finds a person's presets, and nothing asserted it through a real composition — `user-root.spec.ts` plugs the service directly, and every other lane pins `includeUserRoot: false` so the machine's home cannot decide a golden. This lane boots the real base and web-app bundles with only the shipped root patched in, points `$DSH_HOME` at a temp home before boot (the derived root is resolved when the plugin is constructed), and asserts a preset placed there is listed as `user`, reported healthy, authorable, and mountable into an agent whose tool catalog it decides. --- apps/cli/tests/web-agent-presets.e2e.ts | 60 +++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/apps/cli/tests/web-agent-presets.e2e.ts b/apps/cli/tests/web-agent-presets.e2e.ts index d554202b04..b83cec9704 100644 --- a/apps/cli/tests/web-agent-presets.e2e.ts +++ b/apps/cli/tests/web-agent-presets.e2e.ts @@ -634,6 +634,66 @@ describe('a delegated child', () => { }) }) +describe('a launcher that configures no writable root', () => { + // The claim this default exists for, asserted through the real shipped + // bundles rather than a hand-built context: `apps/cli` patches in only the + // system root, and a person's own presets are found anyway because the + // roster derives `/.agent-presets` itself. `$DSH_HOME` is pointed + // at a temp home BEFORE boot — the derived root is resolved when the plugin + // is constructed, and an unpinned run would read the developer's own. + let derivedCtx: Context + let previousHome: string | undefined + + beforeAll(async () => { + const home = await mkdtemp(join(tmpdir(), 'dsh-preset-derived-')) + previousHome = process.env.DSH_HOME + process.env.DSH_HOME = home + await mkdir(join(home, '.agent-presets', 'derived-mine'), { recursive: true }) + await writeFile( + join(home, '.agent-presets', 'derived-mine', 'agent.cordis.yml'), + '- id: tool-todo\n name: \'@deepseek-ai/dsh-tool-todo\'\n config:\n allowParallelInProgress: true\n', + ) + const settingsFile = join(await mkdtemp(join(tmpdir(), 'dsh-preset-derived-settings-')), 'settings.yaml') + await writeFile(settingsFile, '{}\n') + // Only the shipped root, exactly what `composeProfile` supplies; the + // writable one is the roster's own default rather than this patch's job. + derivedCtx = await bootWeb(settingsFile, [{ + id: 'agent-presets', + config: { + default: 'standard', + roots: [{ path: join(CONFIG_DIR, 'agent-presets'), trust: 'system' }], + includeUserRoot: true, + }, + }]) + }, 120_000) + + afterAll(async () => { + if (previousHome === undefined) delete process.env.DSH_HOME + else process.env.DSH_HOME = previousHome + await derivedCtx.fiber.dispose() + }) + + it('discovers and mounts a preset the person authored under the harness home', async () => { + const listed = await derivedCtx.agentPresets.list() + + const mine = listed.find(preset => preset.id === 'derived-mine') + expect(mine).toMatchObject({ trust: 'user' }) + // Omitted rather than undefined: a healthy row carries no `broken` key. + expect(mine?.broken).toBeUndefined() + expect(derivedCtx.agentPresets.authorable).toBe(true) + + const handle = await derivedCtx.agents.create({ + sessionId: SessionId('preset-derived-root'), + setup: agentCtx => derivedCtx.agentPresets.mount(agentCtx, 'derived-mine').then(() => undefined), + }) + try { + expect(toolNames(derivedCtx, handle.agent)).toContain('todo_write') + } finally { + await handle.dispose() + } + }) +}) + describe('authoring a preset on the shipped composition', () => { let authorCtx: Context let userRoot: string