import assert from 'node:assert/strict' import { spawnSync } from 'node:child_process' import { existsSync, readFileSync } from 'node:fs' import { dirname, join } from 'node:path' import test from 'node:test' import { fileURLToPath } from 'node:url' import { cleanup, tempDir, write } from './helpers.mjs' const here = dirname(fileURLToPath(import.meta.url)) const overlay = join(here, '..', 'subagent-models.yml') const script = join(here, '..', 'install.sh') test('overlay enables model selection for both routes and depth 2', () => { assert.ok(existsSync(overlay), 'dsh/subagent-models.yml is missing') const text = readFileSync(overlay, 'utf8') assert.match(text, /id: subagent-model-selection-settings/) assert.match(text, /model: deepseek-flash/) assert.match(text, /model: deepseek-v4-pro/) assert.match(text, /id: subagent\n\s+config:\n\s+maxDepth: 2/) assert.match(text, /headless/) }) test('install.sh --check reports the overlay and the profile depth', () => { const home = tempDir() try { const dshHome = join(home, '.dsh') const env = { ...process.env, HOME: home, DSH_HOME: dshHome } const missing = spawnSync('bash', [script, '--check'], { env, encoding: 'utf8' }) assert.match(missing.stderr, /subagent maxDepth is not 2/) write(join(dshHome, 'profiles', 'desktop', 'cordis.patch.yml'), '- id: subagent\n config:\n maxDepth: 2\n') const present = spawnSync('bash', [script, '--check'], { env, encoding: 'utf8' }) assert.match(present.stdout, /ok: subagent overlay/) assert.match(present.stdout, /ok: subagent maxDepth=2/) } finally { cleanup(home) } })