fix(mods): type narrowings for plugin validate --strict (BLK-049)
Claude Code 2.1.323 type-checks mods in validate --strict: three TS2339 in the memory kit, the Bash hook return type, thirteen sites in the model-router kit and the agent.spawn deny arm. Type-only or behaviour-equivalent changes; kits 288/640 unchanged; guards stay fail-open (BDR-136).
This commit is contained in:
1 parent
9ee3fdad23
commit
6433e4d32a
4 files changed
+25
-11
No files matched your search
@@ -186,7 +186,7 @@ async function boot($: Engine, on: On, o: Opts = {}): Promise<World> {
|
||||
}
|
||||
w.runs.push([...e.argv])
|
||||
if (w.proc === 'throw') throw new Error('spawn failed')
|
||||
if (w.proc === 'hang') await new Promise(() => undefined)
|
||||
if (w.proc === 'hang') return await new Promise<never>(() => undefined)
|
||||
const done = w.proc === 'exit2'
|
||||
? { exitCode: 2, stdout: '' } : { exitCode: 0, stdout: w.proc.stdout }
|
||||
return { value: { ...done, stderr: '', isStdoutTruncated: false,
|
||||
@@ -197,7 +197,7 @@ async function boot($: Engine, on: On, o: Opts = {}): Promise<World> {
|
||||
w.asks.push({ model: x.model, prompt: x.prompt, effort: x.effort,
|
||||
maxTokens: x.maxTokens, timeoutMs: x.timeoutMs })
|
||||
if (w.model === 'throw') throw new Error('api down')
|
||||
if (w.model === 'hang') await new Promise(() => undefined)
|
||||
if (w.model === 'hang') return await new Promise<never>(() => undefined)
|
||||
const usage = { input_tokens: 0, output_tokens: 0 }
|
||||
const done = w.model === 'unanswered'
|
||||
? { isAnswered: false, reason: 'api-error', status: 500,
|
||||
@@ -2802,7 +2802,7 @@ const fakeApi = (w: World): Api => ({
|
||||
w.asks.push(a)
|
||||
return { isAnswered: true, text: (w.model as { text: string }).text }
|
||||
} },
|
||||
store: storeApi(w).store,
|
||||
store: (storeApi(w) as unknown as { store: unknown }).store,
|
||||
ui: { log: () => undefined },
|
||||
}) as unknown as Api
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
// through unchanged: the mod may never break a tool call or a prompt.
|
||||
// It also recalls: registry entries on a qualifying prompt and a known-error
|
||||
// line on a Bash failure, both switchable with "recall": false.
|
||||
import type { EngineInterface, On, Register } from 'claude-code'
|
||||
import type {
|
||||
EngineInterface, On, Register, ToolCallResult,
|
||||
} from 'claude-code'
|
||||
|
||||
type Api = EngineInterface
|
||||
|
||||
@@ -1586,7 +1588,8 @@ function registerBash(on: On, st: State): void {
|
||||
await captureMilestones($, st, at, e, out as BashOut)
|
||||
const line = await knownContext($, st, at, e, f)
|
||||
if (line === '') return out
|
||||
return { ...out, context: [...(out.context ?? []), line] }
|
||||
return { ...out, context: [...(out.context ?? []), line] } as
|
||||
ToolCallResult<'Bash'>
|
||||
}).catch(($, e, next) => {
|
||||
warnOnce(st, $, 'Bash', next.error.kind)
|
||||
return next(e)
|
||||
|
||||
@@ -8,6 +8,12 @@ const SONNET = 'claude-sonnet-5-5'
|
||||
const HAIKU = 'claude-haiku-5-5'
|
||||
|
||||
type Rec = Record<string, unknown>
|
||||
|
||||
// the kit's type lib has neither the timers nor ES2024 strings: types only
|
||||
declare function setTimeout(fn: (...a: never[]) => void, ms: number): unknown
|
||||
declare global {
|
||||
interface String { isWellFormed(): boolean }
|
||||
}
|
||||
type Asked = { text: string; options: string[]; header: string }
|
||||
|
||||
const HOME = '/home/t'
|
||||
@@ -309,7 +315,7 @@ async function boot(
|
||||
// the probe of the model main runs on: every model answers unless a test says not
|
||||
on('model.complete', async (_$, e) => {
|
||||
world.completions.push(e.model)
|
||||
return { value: (await world.complete(e.model)) as string }
|
||||
return { value: (await world.complete(e.model)) as string } as never
|
||||
})
|
||||
installWorld(on, world)
|
||||
if (tokens !== null) usageOf(on, tokens)
|
||||
@@ -1198,6 +1204,7 @@ function recordLogs(on: On): string[] {
|
||||
} catch {
|
||||
// nothing implements ui.log below the recorder in the kit
|
||||
}
|
||||
return undefined as never
|
||||
})
|
||||
return lines
|
||||
}
|
||||
@@ -1380,7 +1387,7 @@ async function effortAfterSkill($: Engine, on: On, skill: string) {
|
||||
await $.agent.spawn(spawnOf('feater'))
|
||||
await loadSkill($, skill, 'a1')
|
||||
await runStep($, { ...highStep('a1'), model: SONNET })
|
||||
return rig.seen[rig.seen.length - 1].effort
|
||||
return rig.seen[rig.seen.length - 1]!.effort
|
||||
}
|
||||
|
||||
test('agent skill: an unrowed one leaves the loop effort', async ($, on) => {
|
||||
@@ -1595,7 +1602,7 @@ const queued = ($: Engine, kind: string, text: string) =>
|
||||
$.prompt.submit({
|
||||
text,
|
||||
wait: true,
|
||||
origin: { kind },
|
||||
origin: { kind } as never,
|
||||
turnId: 'u1',
|
||||
})
|
||||
|
||||
@@ -1614,7 +1621,7 @@ test('idle fallback: a mid-turn composer prompt promotes the allowance', async (
|
||||
await $.prompt.submit({
|
||||
text: 'hello',
|
||||
wait: false,
|
||||
origin: { kind: 'channel' },
|
||||
origin: { kind: 'channel' } as never,
|
||||
})
|
||||
await queued($, 'composer', 'hello')
|
||||
await endTurn($)
|
||||
@@ -1644,6 +1651,7 @@ function recordToasts(on: On): string[] {
|
||||
} catch {
|
||||
// nothing implements ui.toast below the recorder in the kit
|
||||
}
|
||||
return undefined as never
|
||||
})
|
||||
return lines
|
||||
}
|
||||
@@ -4595,7 +4603,7 @@ const skillWorld = (): World => newWorld({ edit: f => {
|
||||
|
||||
/** The name a line shows after `marker`, up to the closing char. */
|
||||
const nameAfter = (line: string, marker: string, end: string): string =>
|
||||
line.slice(line.indexOf(marker) + marker.length).split(end)[0]
|
||||
line.slice(line.indexOf(marker) + marker.length).split(end)[0]!
|
||||
|
||||
test('logs: a hostile skill name is cleaned in the main line', async (
|
||||
$, on) => {
|
||||
@@ -4668,6 +4676,7 @@ function recordStatus(on: On): string[] {
|
||||
} catch {
|
||||
// nothing implements ui.status below the recorder in the kit
|
||||
}
|
||||
return undefined as never
|
||||
})
|
||||
return lines
|
||||
}
|
||||
|
||||
@@ -4656,7 +4656,9 @@ function registerSpawn(on: On, st: State): void {
|
||||
const started = await next(wanted === undefined
|
||||
? e
|
||||
: { ...e, model: wanted })
|
||||
afterSpawn($, st, { e, started, route, wanted })
|
||||
if (started.deny === undefined) {
|
||||
afterSpawn($, st, { e, started, route, wanted })
|
||||
}
|
||||
return started
|
||||
} finally {
|
||||
st.spawning = Math.max(0, st.spawning - 1)
|
||||
|
||||
Reference in new issue
Block a user