ceulen-dsh 0.2.11 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -10
- package/cordis.patch.yml +20 -1
- package/lib/modules/codemode/script.d.ts +30 -1
- package/lib/modules/codemode/script.d.ts.map +1 -1
- package/lib/modules/codemode/script.js +80 -8
- package/lib/modules/codemode/script.js.map +1 -1
- package/lib/modules/serena/index.d.ts +25 -0
- package/lib/modules/serena/index.d.ts.map +1 -1
- package/lib/modules/serena/index.js +113 -9
- package/lib/modules/serena/index.js.map +1 -1
- package/lib/modules/skills/index.js +1 -1
- package/lib/modules/steering/bash-search.d.ts +7 -0
- package/lib/modules/steering/bash-search.d.ts.map +1 -1
- package/lib/modules/steering/bash-search.js +13 -0
- package/lib/modules/steering/bash-search.js.map +1 -1
- package/lib/modules/steering/index.d.ts.map +1 -1
- package/lib/modules/steering/index.js +20 -3
- package/lib/modules/steering/index.js.map +1 -1
- package/package.json +3 -1
- package/parity.json +15 -7
- package/scripts/ceulen-sync.mjs +4 -1
- package/scripts/check-bundle.mjs +23 -1
- package/scripts/check-pack.mjs +8 -21
- package/scripts/pack-contract.mjs +37 -0
- package/scripts/smoke-install.mjs +146 -0
- package/scripts/spill-page.mjs +64 -0
- package/scripts/steer-fixtures/fixtures.mjs +148 -0
- package/scripts/steer-fixtures/ws/fixtures/runbook.txt +7 -0
- package/scripts/steer-fixtures/ws/package.json +5 -0
- package/scripts/steer-fixtures/ws/src/cart.js +18 -0
- package/scripts/steer-fixtures/ws/src/format.js +6 -0
- package/scripts/steer-fixtures/ws/sum.js +4 -0
- package/scripts/steer-fixtures/ws/tools/stamp.js +4 -0
- package/scripts/steer-fixtures.mjs +180 -0
- package/upstream.lock.json +4 -4
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cold fixtures for steering changes: six one-shot tasks, each started in a
|
|
3
|
+
* fresh session, with a pass rule read from the run's own events.
|
|
4
|
+
*
|
|
5
|
+
* Why they exist: upstream Ceulen shipped a first-request bootstrap for
|
|
6
|
+
* DeepSeek flash in 0.28.2 and deleted it in 0.29.0 after exactly this kind of
|
|
7
|
+
* run showed 3/5 with it on against 5/5 with it off. Guidance that reads well
|
|
8
|
+
* can still make the model worse, and only a run on the model tells. Each
|
|
9
|
+
* fixture is one way steering has gone wrong, here or upstream:
|
|
10
|
+
*
|
|
11
|
+
* held-tool the user names a tool steering holds cold; it must still be called
|
|
12
|
+
* read-first "read X, then run its command": the read comes first
|
|
13
|
+
* run a plain run request goes straight to bash
|
|
14
|
+
* symbol a definition is found and cited with its line
|
|
15
|
+
* edit a one-line change touches one line
|
|
16
|
+
* verbatim a lookup command the user typed out runs as typed
|
|
17
|
+
*/
|
|
18
|
+
import { readFileSync } from 'node:fs'
|
|
19
|
+
import { join } from 'node:path'
|
|
20
|
+
|
|
21
|
+
/** Tool calls of a run, in order, each with the result that answered it. */
|
|
22
|
+
export function toolCalls(events) {
|
|
23
|
+
const results = new Map()
|
|
24
|
+
for (const event of events) if (event.type === 'tool_result') results.set(event.callId, event)
|
|
25
|
+
return events
|
|
26
|
+
.filter(event => event.type === 'tool_call')
|
|
27
|
+
.map((event, index) => {
|
|
28
|
+
const result = results.get(event.callId)
|
|
29
|
+
return { index, tool: event.tool, input: event.input ?? {}, status: result?.status, result: typeof result?.result === 'string' ? result.result : JSON.stringify(result?.result ?? '') }
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function finalText(events) {
|
|
34
|
+
const final = events.findLast(event => event.type === 'final')
|
|
35
|
+
return typeof final?.text === 'string' ? final.text : ''
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const text = call => JSON.stringify(call.input)
|
|
39
|
+
|
|
40
|
+
/** True when the call runs tool `name`: directly, through ceulen_tools, or inside a codemode script. */
|
|
41
|
+
export function reaches(call, name) {
|
|
42
|
+
if (call.tool === name) return true
|
|
43
|
+
if (call.tool === 'ceulen_tools') return call.input.action === 'call' && call.input.name === name
|
|
44
|
+
if (call.tool === 'codemode') return new RegExp(`tools\\.${name}\\b|["']${name}["']`).test(String(call.input.code ?? ''))
|
|
45
|
+
return false
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A shell command in the call: a direct bash call, or one inside a codemode script. */
|
|
49
|
+
function runs(call, fragment) {
|
|
50
|
+
return (call.tool === 'bash' || call.tool === 'codemode') && text(call).includes(fragment)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const ok = { pass: true, why: 'ok' }
|
|
54
|
+
const fail = why => ({ pass: false, why })
|
|
55
|
+
|
|
56
|
+
export const FIXTURES = [
|
|
57
|
+
{
|
|
58
|
+
id: 'held-tool',
|
|
59
|
+
prompt: 'Use the read_slice tool (not read) to show lines 3 to 5 of src/format.js. Reply with those three lines.',
|
|
60
|
+
check({ events }) {
|
|
61
|
+
const calls = toolCalls(events)
|
|
62
|
+
if (calls.length === 0) return fail('the turn ended without a tool call')
|
|
63
|
+
if (!calls.some(call => reaches(call, 'read_slice'))) return fail(`read_slice was never called (calls: ${calls.map(call => call.tool).join(', ')})`)
|
|
64
|
+
return finalText(events).includes('String(value)') ? ok : fail('the reply does not show the lines')
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: 'read-first',
|
|
69
|
+
prompt: 'Read fixtures/runbook.txt, then run its command and report the exact stdout.',
|
|
70
|
+
check({ events }) {
|
|
71
|
+
const calls = toolCalls(events)
|
|
72
|
+
const read = calls.find(call => text(call).includes('runbook.txt'))
|
|
73
|
+
const run = calls.find(call => runs(call, 'stamp.js'))
|
|
74
|
+
if (read === undefined) return fail('the runbook was never read')
|
|
75
|
+
if (run === undefined) return fail('the runbook command was never run')
|
|
76
|
+
if (run.index < read.index) return fail('the command ran before the runbook was read')
|
|
77
|
+
return finalText(events).includes('steer-fixture-42') ? ok : fail('the reply does not carry the stdout (steer-fixture-42)')
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'run',
|
|
82
|
+
prompt: 'Run `node sum.js` and tell me the number it prints.',
|
|
83
|
+
check({ events }) {
|
|
84
|
+
const calls = toolCalls(events)
|
|
85
|
+
if (calls.length === 0) return fail('the turn ended without a tool call')
|
|
86
|
+
if (!runs(calls[0], 'sum.js')) return fail(`the first call was ${calls[0].tool}, not the command`)
|
|
87
|
+
return finalText(events).includes('4950') ? ok : fail('the reply does not carry the number (4950)')
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: 'symbol',
|
|
92
|
+
prompt: 'Where is the function computeTotal defined? Answer as file:line.',
|
|
93
|
+
check({ events }) {
|
|
94
|
+
if (toolCalls(events).length === 0) return fail('the turn ended without a tool call')
|
|
95
|
+
return /cart\.js(?::|,? line )10\b/.test(finalText(events)) ? ok : fail('the reply does not say src/cart.js:10')
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: 'edit',
|
|
100
|
+
prompt: 'In src/cart.js change the value of TAX_RATE from 0.08 to 0.1. Change nothing else.',
|
|
101
|
+
check({ ws, template }) {
|
|
102
|
+
const want = readFileSync(join(template, 'src', 'cart.js'), 'utf8').replace('TAX_RATE = 0.08', 'TAX_RATE = 0.1')
|
|
103
|
+
const got = readFileSync(join(ws, 'src', 'cart.js'), 'utf8')
|
|
104
|
+
if (got === want) return ok
|
|
105
|
+
return got.includes('TAX_RATE = 0.1') ? fail('TAX_RATE changed, and so did something else') : fail('TAX_RATE was not changed')
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: 'verbatim',
|
|
110
|
+
// `grep -n` on purpose: a plain lookup, exactly what the steered redirect turns into the grep tool.
|
|
111
|
+
prompt: 'Run `grep -n TODO src/cart.js` and paste the exact output.',
|
|
112
|
+
check({ events }) {
|
|
113
|
+
const calls = toolCalls(events)
|
|
114
|
+
const typed = calls.filter(call => runs(call, 'grep -n TODO src/cart.js'))
|
|
115
|
+
if (typed.length === 0) return fail('the command the user typed was never sent')
|
|
116
|
+
if (!typed.some(call => call.status === 'completed' && !call.result.includes('Not run:'))) return fail('the command the user typed was refused')
|
|
117
|
+
const reply = finalText(events)
|
|
118
|
+
return ['load discounts', 'round per line item', 'more than one currency'].every(part => reply.includes(part)) ? ok : fail('the reply does not carry the three matching lines')
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
/** The three loadouts a steering change is judged across. Everything else is the same in all of them. */
|
|
124
|
+
export const CONFIGS = ['on', 'off', 'unloaded']
|
|
125
|
+
|
|
126
|
+
const QUIET = ['advisor', 'munin', 'agentmem', 'evo', 'cron', 'a2a', 'notebooklm', 'ux', 'usage', 'dashboard']
|
|
127
|
+
|
|
128
|
+
/** ceulen settings for one loadout. Memory, review and background modules are off in all three: a fixture must not write to a real memory store. */
|
|
129
|
+
export function settingsFor(config, model) {
|
|
130
|
+
const base = { schemaVersion: 1, upstream: { enabled: false } }
|
|
131
|
+
if (config === 'on') return { ...base, disabled: QUIET, steering: { models: [model], bashLookups: 'redirect', cold: ['read_slice'], coldModels: [] } }
|
|
132
|
+
const off = { models: [], bashLookups: 'off', cold: [], coldModels: [] }
|
|
133
|
+
if (config === 'off') return { ...base, disabled: QUIET, steering: off }
|
|
134
|
+
if (config === 'unloaded') return { ...base, disabled: [...QUIET, 'steering'], steering: off }
|
|
135
|
+
throw new Error(`unknown config "${config}" (${CONFIGS.join(', ')})`)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Steering must not make the model worse: with it on, the score is at least
|
|
140
|
+
* the best score without it. `results` is { config: { fixtureId: { pass } } }.
|
|
141
|
+
*/
|
|
142
|
+
export function verdict(results) {
|
|
143
|
+
const score = config => Object.values(results[config] ?? {}).filter(run => run.pass).length
|
|
144
|
+
const scores = Object.fromEntries(Object.keys(results).map(config => [config, score(config)]))
|
|
145
|
+
const baseline = Math.max(0, ...Object.keys(results).filter(config => config !== 'on').map(score))
|
|
146
|
+
const ok = results.on === undefined || scores.on >= baseline
|
|
147
|
+
return { ok, scores, baseline }
|
|
148
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Cart totals for the steer fixtures. Line numbers matter: the fixtures ask for them.
|
|
2
|
+
export const TAX_RATE = 0.08
|
|
3
|
+
|
|
4
|
+
// TODO: load discounts from the price list
|
|
5
|
+
export function applyDiscount(amount, percent) {
|
|
6
|
+
return amount - (amount * percent) / 100
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// TODO: round per line item, not per order
|
|
10
|
+
export function computeTotal(items) {
|
|
11
|
+
const subtotal = items.reduce((sum, item) => sum + item.price * item.qty, 0)
|
|
12
|
+
return subtotal + subtotal * TAX_RATE
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// TODO: support more than one currency
|
|
16
|
+
export function formatTotal(total) {
|
|
17
|
+
return `$${total.toFixed(2)}`
|
|
18
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Run the cold steering fixtures (scripts/steer-fixtures/fixtures.mjs) on a
|
|
4
|
+
* real model and say whether steering helps or hurts.
|
|
5
|
+
*
|
|
6
|
+
* Each fixture runs once per loadout — steering on, steering off, steering
|
|
7
|
+
* module unloaded — as a headless one-shot in its own copy of the fixture
|
|
8
|
+
* workspace, under its own DSH home, so nothing touches ~/.dsh, the user's
|
|
9
|
+
* settings or a real memory store. The bundle under test is this checkout
|
|
10
|
+
* (lib/ must be built). The provider row and the credential store are read
|
|
11
|
+
* from an existing profile.
|
|
12
|
+
*
|
|
13
|
+
* This spends real model calls (18 short runs by default). It is a release
|
|
14
|
+
* gate for changes to src/modules/steering, the playbook, steering.cold or the
|
|
15
|
+
* bash redirect, not part of `npm run check`.
|
|
16
|
+
*
|
|
17
|
+
* Usage: node scripts/steer-fixtures.mjs [--route provider/model] [--effort level]
|
|
18
|
+
* [--configs on,off,unloaded] [--only id,id] [--out dir]
|
|
19
|
+
* [--source-home dir] [--source-profile name] [--timeout seconds] [--list]
|
|
20
|
+
* Exit: 0 steering on scores at least the best loadout without it · 1 it scores
|
|
21
|
+
* lower, or a run could not start · 2 bad usage.
|
|
22
|
+
*/
|
|
23
|
+
import { spawn } from 'node:child_process'
|
|
24
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, symlinkSync, writeFileSync } from 'node:fs'
|
|
25
|
+
import { homedir, tmpdir } from 'node:os'
|
|
26
|
+
import { dirname, join, resolve } from 'node:path'
|
|
27
|
+
import { fileURLToPath } from 'node:url'
|
|
28
|
+
import { CONFIGS, FIXTURES, finalText, settingsFor, toolCalls, verdict } from './steer-fixtures/fixtures.mjs'
|
|
29
|
+
|
|
30
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
|
31
|
+
const template = join(root, 'scripts', 'steer-fixtures', 'ws')
|
|
32
|
+
|
|
33
|
+
function usage(message) {
|
|
34
|
+
console.error(`steer-fixtures: ${message}\nusage: steer-fixtures.mjs [--route provider/model] [--effort level] [--configs on,off,unloaded] [--only id,id] [--out dir] [--source-home dir] [--source-profile name] [--timeout seconds] [--list]`)
|
|
35
|
+
process.exit(2)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const options = { route: 'opencode-go/deepseek-v4.1-flash', effort: 'high', configs: CONFIGS, only: undefined, out: undefined, sourceHome: process.env.DSH_HOME?.trim() || join(homedir(), '.dsh'), sourceProfile: 'tui', timeout: 300, list: false }
|
|
39
|
+
const argv = process.argv.slice(2)
|
|
40
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
41
|
+
const token = argv[index]
|
|
42
|
+
const value = () => {
|
|
43
|
+
const next = argv[index + 1]
|
|
44
|
+
if (next === undefined || next.startsWith('--')) usage(`${token} needs a value`)
|
|
45
|
+
index += 1
|
|
46
|
+
return next
|
|
47
|
+
}
|
|
48
|
+
if (token === '--route') options.route = value()
|
|
49
|
+
else if (token === '--effort') options.effort = value()
|
|
50
|
+
else if (token === '--configs') options.configs = value().split(',').filter(Boolean)
|
|
51
|
+
else if (token === '--only') options.only = value().split(',').filter(Boolean)
|
|
52
|
+
else if (token === '--out') options.out = resolve(value())
|
|
53
|
+
else if (token === '--source-home') options.sourceHome = resolve(value())
|
|
54
|
+
else if (token === '--source-profile') options.sourceProfile = value()
|
|
55
|
+
else if (token === '--timeout') options.timeout = Number(value())
|
|
56
|
+
else if (token === '--list') options.list = true
|
|
57
|
+
else usage(`unknown option: ${token}`)
|
|
58
|
+
}
|
|
59
|
+
const slash = options.route.indexOf('/')
|
|
60
|
+
if (slash <= 0 || slash === options.route.length - 1) usage('--route must be provider/model')
|
|
61
|
+
const provider = options.route.slice(0, slash)
|
|
62
|
+
const model = options.route.slice(slash + 1)
|
|
63
|
+
for (const config of options.configs) if (!CONFIGS.includes(config)) usage(`unknown config "${config}" (${CONFIGS.join(', ')})`)
|
|
64
|
+
const fixtures = options.only === undefined ? FIXTURES : FIXTURES.filter(fixture => options.only.includes(fixture.id))
|
|
65
|
+
if (fixtures.length === 0) usage(`no fixture matches --only (${FIXTURES.map(fixture => fixture.id).join(', ')})`)
|
|
66
|
+
if (!Number.isFinite(options.timeout) || options.timeout <= 0) usage('--timeout must be a positive number of seconds')
|
|
67
|
+
|
|
68
|
+
if (options.list) {
|
|
69
|
+
for (const fixture of FIXTURES) console.log(`${fixture.id.padEnd(11)} ${fixture.prompt}`)
|
|
70
|
+
process.exit(0)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function die(message) {
|
|
74
|
+
console.error(`steer-fixtures: ${message}`)
|
|
75
|
+
process.exit(1)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!existsSync(join(root, 'lib', 'modules', 'subagent', 'herdr.js'))) die('lib/ is not built; run npm run build first')
|
|
79
|
+
const { overlayText } = await import(join(root, 'lib', 'modules', 'subagent', 'herdr.js'))
|
|
80
|
+
const profilePatch = join(options.sourceHome, 'profiles', options.sourceProfile, 'cordis.patch.yml')
|
|
81
|
+
if (!existsSync(profilePatch)) die(`no provider row to copy: ${profilePatch} does not exist (--source-home, --source-profile)`)
|
|
82
|
+
|
|
83
|
+
const stamp = new Date().toISOString().replace(/[-:]/g, '').replace(/\..*/, '').replace('T', '-')
|
|
84
|
+
// Outside the checkout by default: each loadout's home links the credential store and keeps session logs.
|
|
85
|
+
const out = options.out ?? join(tmpdir(), 'ceulen-steer-fixtures', stamp)
|
|
86
|
+
mkdirSync(out, { recursive: true })
|
|
87
|
+
const overlay = join(out, 'overlay.yml')
|
|
88
|
+
writeFileSync(overlay, overlayText(readFileSync(profilePatch, 'utf8'), { provider, model, effort: options.effort }), { mode: 0o600 })
|
|
89
|
+
|
|
90
|
+
/** One DSH home per loadout: the headless bundles plus this checkout, its own settings, the source credential store. */
|
|
91
|
+
function makeHome(config) {
|
|
92
|
+
const home = join(out, `home-${config}`)
|
|
93
|
+
const profile = join(home, 'profiles', 'fixture')
|
|
94
|
+
mkdirSync(join(profile, 'node_modules'), { recursive: true })
|
|
95
|
+
mkdirSync(join(home, 'ceulen'), { recursive: true })
|
|
96
|
+
writeFileSync(join(profile, 'package.json'), `${JSON.stringify({ name: 'dsh-profile-fixture', private: true, dependencies: { 'ceulen-dsh': `link:${root}` }, dsh: { profile: { bundles: ['@deepseek-ai/dsh-base', '@deepseek-ai/dsh-headless', 'ceulen-dsh'] } } }, null, 2)}\n`)
|
|
97
|
+
writeFileSync(join(profile, 'cordis.yml'), '[]\n')
|
|
98
|
+
writeFileSync(join(profile, 'cordis.patch.yml'), '[]\n')
|
|
99
|
+
symlinkSync(root, join(profile, 'node_modules', 'ceulen-dsh'))
|
|
100
|
+
writeFileSync(join(home, 'ceulen', 'settings.json'), `${JSON.stringify(settingsFor(config, model), null, 2)}\n`)
|
|
101
|
+
const credentials = join(options.sourceHome, '.credentials.yaml')
|
|
102
|
+
if (existsSync(credentials)) symlinkSync(credentials, join(home, '.credentials.yaml'))
|
|
103
|
+
return home
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function runOne(fixture, config, home) {
|
|
107
|
+
const ws = join(out, 'ws', `${config}-${fixture.id}`)
|
|
108
|
+
cpSync(template, ws, { recursive: true })
|
|
109
|
+
const eventsFile = join(out, `${config}-${fixture.id}.events.jsonl`)
|
|
110
|
+
const env = { ...process.env, DSH_HOME: home, CEULEN_HERDR: 'off' }
|
|
111
|
+
const started = Date.now()
|
|
112
|
+
return new Promise(done => {
|
|
113
|
+
const child = spawn('dsh', ['--profile', 'fixture', '--patch', overlay, '--permission-mode', 'workspace-write', '--approval-policy', 'never', '--json', '-'], { cwd: ws, env, stdio: ['pipe', 'pipe', 'pipe'] })
|
|
114
|
+
let stdout = ''
|
|
115
|
+
let stderr = ''
|
|
116
|
+
let timedOut = false
|
|
117
|
+
const timer = setTimeout(() => {
|
|
118
|
+
timedOut = true
|
|
119
|
+
child.kill('SIGKILL')
|
|
120
|
+
}, options.timeout * 1000)
|
|
121
|
+
child.stdout.on('data', chunk => { stdout += chunk })
|
|
122
|
+
child.stderr.on('data', chunk => { stderr += chunk })
|
|
123
|
+
child.on('error', error => {
|
|
124
|
+
clearTimeout(timer)
|
|
125
|
+
done({ fixture: fixture.id, config, pass: false, why: `could not start dsh: ${error.message}`, broken: true, calls: 0, seconds: 0, tokens: 0, first: '' })
|
|
126
|
+
})
|
|
127
|
+
child.on('close', code => {
|
|
128
|
+
clearTimeout(timer)
|
|
129
|
+
writeFileSync(eventsFile, stdout)
|
|
130
|
+
if (stderr.trim() !== '') writeFileSync(join(out, `${config}-${fixture.id}.stderr.log`), stderr)
|
|
131
|
+
const events = stdout.split('\n').flatMap(line => {
|
|
132
|
+
try {
|
|
133
|
+
return line.trim() === '' ? [] : [JSON.parse(line)]
|
|
134
|
+
} catch {
|
|
135
|
+
return []
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
const calls = toolCalls(events)
|
|
139
|
+
const error = events.find(event => event.type === 'error')
|
|
140
|
+
const tokens = events.reduce((sum, event) => sum + (event.type === 'status' ? (event.usage?.inputTokens ?? 0) + (event.usage?.outputTokens ?? 0) : 0), 0)
|
|
141
|
+
const base = { fixture: fixture.id, config, calls: calls.length, seconds: Math.round((Date.now() - started) / 1000), tokens, first: calls[0]?.tool ?? '' }
|
|
142
|
+
// A run that never reached the model says nothing about steering: report it apart from a failed fixture.
|
|
143
|
+
if (timedOut) return done({ ...base, pass: false, why: `timed out after ${options.timeout}s` })
|
|
144
|
+
if (events.length === 0 || (error !== undefined && calls.length === 0 && finalText(events) === '')) {
|
|
145
|
+
return done({ ...base, pass: false, broken: true, why: `run did not start (exit ${code}): ${String(error?.message ?? stderr).trim().split('\n').at(-1)?.slice(0, 200) ?? ''}` })
|
|
146
|
+
}
|
|
147
|
+
let result
|
|
148
|
+
try {
|
|
149
|
+
result = fixture.check({ events, ws, template })
|
|
150
|
+
} catch (thrown) {
|
|
151
|
+
result = { pass: false, why: `check threw: ${thrown instanceof Error ? thrown.message : String(thrown)}` }
|
|
152
|
+
}
|
|
153
|
+
done({ ...base, ...result })
|
|
154
|
+
})
|
|
155
|
+
child.stdin.end(fixture.prompt)
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
console.log(`steer-fixtures: ${fixtures.length} fixture(s) x ${options.configs.length} loadout(s) on ${options.route} (${options.effort}) -> ${out}`)
|
|
160
|
+
const homes = Object.fromEntries(options.configs.map(config => [config, makeHome(config)]))
|
|
161
|
+
const results = Object.fromEntries(options.configs.map(config => [config, {}]))
|
|
162
|
+
const rows = []
|
|
163
|
+
for (const fixture of fixtures) {
|
|
164
|
+
// One fixture at a time, its loadouts side by side: they share no workspace and no home.
|
|
165
|
+
const runs = await Promise.all(options.configs.map(config => runOne(fixture, config, homes[config])))
|
|
166
|
+
for (const run of runs) {
|
|
167
|
+
results[run.config][run.fixture] = run
|
|
168
|
+
rows.push(run)
|
|
169
|
+
console.log(`${run.pass ? 'pass' : 'FAIL'} ${run.fixture.padEnd(11)} ${run.config.padEnd(9)} ${String(run.calls).padStart(2)} call(s) ${String(run.seconds).padStart(3)}s ${String(run.tokens).padStart(6)} tok first: ${(run.first || '-').padEnd(12)} ${run.pass ? '' : run.why}`)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const outcome = verdict(results)
|
|
174
|
+
const broken = rows.filter(run => run.broken === true)
|
|
175
|
+
writeFileSync(join(out, 'summary.json'), `${JSON.stringify({ route: options.route, effort: options.effort, at: new Date().toISOString(), ...outcome, broken: broken.length, runs: rows }, null, 2)}\n`)
|
|
176
|
+
console.log('')
|
|
177
|
+
for (const config of options.configs) console.log(`${config.padEnd(9)} ${outcome.scores[config]}/${fixtures.length}`)
|
|
178
|
+
if (broken.length > 0) die(`${broken.length} run(s) did not start; the scores above are not a verdict. See ${out}`)
|
|
179
|
+
if (!outcome.ok) die(`steering on scores ${outcome.scores.on}/${fixtures.length}, below ${outcome.baseline}/${fixtures.length} without it. See ${out}`)
|
|
180
|
+
console.log(`steer-fixtures: steering on is not worse than without it (${out})`)
|
package/upstream.lock.json
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
"upstream": {
|
|
4
4
|
"package": "ceulen",
|
|
5
5
|
"repo": "ceulen-dev/ceulen",
|
|
6
|
-
"version": "0.
|
|
7
|
-
"commit": "
|
|
8
|
-
"tarball": "https://registry.npmjs.org/ceulen/-/ceulen-0.
|
|
9
|
-
"syncedAt": "2026-
|
|
6
|
+
"version": "0.31.0",
|
|
7
|
+
"commit": "28fe08a1465c1e2d4258974ccef96a77ab54fdca",
|
|
8
|
+
"tarball": "https://registry.npmjs.org/ceulen/-/ceulen-0.31.0.tgz",
|
|
9
|
+
"syncedAt": "2026-11-24T06:14:05.764Z"
|
|
10
10
|
},
|
|
11
11
|
"vendored": {
|
|
12
12
|
"src/vendor/ceulen/rules/rules.ts": {
|