diff --git a/mods/model-router/hooks/register.test.ts b/mods/model-router/hooks/register.test.ts index 1b2e66a..b06055d 100644 --- a/mods/model-router/hooks/register.test.ts +++ b/mods/model-router/hooks/register.test.ts @@ -7544,6 +7544,32 @@ test('GUARD: a model-loaded skill, rowed or not, opens it', async ( expect(denied(await write($, `${ROOT}/src/a.ts`))).toBe('') }) +for (const ref of ['modern-web-guidance', 'find-docs']) { + test(`GUARD: the reference skill ${ref} does not open it`, async ( + $, on) => { + await guardRig($, on) + await $.tool.call({ tool: 'Skill', skill: ref } as never) + await endTurn($) + expect(denied(await write($, `${ROOT}/src/a.ts`))).toContain(GUARD) + }) +} + +test('GUARD: a typed reference skill does not open it', async ($, on) => { + await guardRig($, on) + await typed($, '/modern-web-guidance dialog') + await skillPrompt($, 'modern-web-guidance') + await endTurn($) + expect(denied(await write($, `${ROOT}/src/a.ts`))).toContain(GUARD) +}) + +test('GUARD: a reference skill inside a run keeps it open', async ($, on) => { + await guardRig($, on) + await typeFeat($) + await $.tool.call({ tool: 'Skill', skill: 'modern-web-guidance' } as never) + await endTurn($) + expect(denied(await write($, `${ROOT}/src/a.ts`))).toBe('') +}) + test('GUARD: a Skill call inside a sub-agent does not open it', async ( $, on) => { await guardRig($, on) diff --git a/mods/model-router/hooks/register.ts b/mods/model-router/hooks/register.ts index 721d3ec..2be5329 100644 --- a/mods/model-router/hooks/register.ts +++ b/mods/model-router/hooks/register.ts @@ -187,6 +187,11 @@ const PROJECT_SOURCES: ReadonlySet = new Set([ // shortcut: the frontmatter model of other types is invisible to the hook; // widen the set when the engine exposes it on agent.offer. const INHERITING_AGENTS: ReadonlySet = new Set(['general-purpose']) +// Reference skills read docs (pinned web guides, library docs) and write no +// code: loading one never opens the write guard (user decision 2026-11-22). +const REFERENCE_SKILLS: ReadonlySet = new Set([ + 'modern-web-guidance', 'find-docs', +]) // PostModelSwitch sources a person chose (auto and resume are not). const USER_SWITCH: ReadonlySet = new Set([ 'command', 'picker', 'sdk', @@ -3814,7 +3819,8 @@ type Armed = { row: Picked | undefined; typed: boolean } function armTypedSkill($: Api, st: State, skill: string): Armed { const row = skillRow(st, skill) const typed = typedPath(st, skill) !== undefined - if (typed) st.skillRun = true // unrowed too: its body is the user's + // Unrowed too: its body is the user's. A reference skill writes no code. + if (typed && !REFERENCE_SKILLS.has(skill)) st.skillRun = true if (row === undefined || !typed) return { row: undefined, typed } routeMainBySkill(st, skill, row, true) refresh($, st) @@ -4428,7 +4434,7 @@ async function onModelSwitch($: Api, st: State, e: SwitchIn): Promise { // held while sub-agents (skill executors) still write; no throw source known. // Limit: an unrowed typed skill latches through the typed-fallback path // (typedPath) only when no sub-agent is live; the model's own Skill call -// latches it anyway. +// latches it anyway. A reference skill (REFERENCE_SKILLS) never latches. const DOC_FILE = /\.(md|txt)$/i const GUARD_REASON = 'model-router: code is written inside a skill run. ' + @@ -4631,7 +4637,8 @@ function registerSkills(on: On, st: State): void { const out = await next(e) const refused = typeof out !== 'object' || out === null || 'deny' in out || (out as { isError?: unknown }).isError === true - if (e.agentId === undefined && !refused) st.skillRun = true + if (e.agentId === undefined && !refused && + !REFERENCE_SKILLS.has(skill)) st.skillRun = true return out } finally { st.skillCalls -= 1