ceulen-dsh 0.2.11 → 0.2.13

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.
Files changed (44) hide show
  1. package/README.md +52 -13
  2. package/cordis.patch.yml +20 -1
  3. package/lib/core/upstream.d.ts.map +1 -1
  4. package/lib/core/upstream.js +26 -5
  5. package/lib/core/upstream.js.map +1 -1
  6. package/lib/modules/codemode/script.d.ts +30 -1
  7. package/lib/modules/codemode/script.d.ts.map +1 -1
  8. package/lib/modules/codemode/script.js +80 -8
  9. package/lib/modules/codemode/script.js.map +1 -1
  10. package/lib/modules/serena/index.d.ts +25 -0
  11. package/lib/modules/serena/index.d.ts.map +1 -1
  12. package/lib/modules/serena/index.js +113 -9
  13. package/lib/modules/serena/index.js.map +1 -1
  14. package/lib/modules/skills/index.js +1 -1
  15. package/lib/modules/status/index.d.ts.map +1 -1
  16. package/lib/modules/status/index.js +4 -2
  17. package/lib/modules/status/index.js.map +1 -1
  18. package/lib/modules/steering/bash-search.d.ts +7 -0
  19. package/lib/modules/steering/bash-search.d.ts.map +1 -1
  20. package/lib/modules/steering/bash-search.js +13 -0
  21. package/lib/modules/steering/bash-search.js.map +1 -1
  22. package/lib/modules/steering/index.d.ts.map +1 -1
  23. package/lib/modules/steering/index.js +20 -3
  24. package/lib/modules/steering/index.js.map +1 -1
  25. package/package.json +4 -2
  26. package/parity.json +15 -7
  27. package/scripts/ceulen-sync.mjs +4 -1
  28. package/scripts/check-bundle.mjs +23 -1
  29. package/scripts/check-pack.mjs +8 -21
  30. package/scripts/pack-contract.mjs +37 -0
  31. package/scripts/smoke-install.mjs +146 -0
  32. package/scripts/spill-page.mjs +64 -0
  33. package/scripts/steer-fixtures/fixtures.mjs +148 -0
  34. package/scripts/steer-fixtures/ws/fixtures/runbook.txt +7 -0
  35. package/scripts/steer-fixtures/ws/package.json +5 -0
  36. package/scripts/steer-fixtures/ws/src/cart.js +18 -0
  37. package/scripts/steer-fixtures/ws/src/format.js +6 -0
  38. package/scripts/steer-fixtures/ws/sum.js +4 -0
  39. package/scripts/steer-fixtures/ws/tools/stamp.js +4 -0
  40. package/scripts/steer-fixtures.mjs +180 -0
  41. package/scripts/tui-plan-patch.mjs +138 -1
  42. package/scripts/tui-question-fit-smoke.mjs +161 -0
  43. package/skills/dsh-update/SKILL.md +29 -4
  44. package/upstream.lock.json +4 -4
@@ -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})`)
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * dsh-tui plan-mode polish for the installed profile tree.
4
4
  *
5
- * Target: dsh-tui 0.19.0 (anchors unchanged since 0.18.0). Four behaviors the stock TUI cannot express, each
5
+ * Target: dsh-tui 0.20.2 (anchors unchanged since 0.18.0). Five behaviors the stock TUI cannot express, each
6
6
  * anchored on the exact 0.18.0 source text (a dsh-tui update reverts them
7
7
  * silently — re-run `apply` and check `/ceulen doctor`):
8
8
  *
@@ -24,6 +24,14 @@
24
24
  * the plan-review card, Esc used to cancel and drop what the user typed;
25
25
  * the model then heard only "the user cancelled". With text typed, Esc now
26
26
  * submits it like Enter. Empty Esc and Ctrl+C still cancel.
27
+ * 5. The plan-review card fits the screen. Stock sized the plan body as the
28
+ * terminal height minus a fixed twelve rows, so with the goal/todo band
29
+ * up (any later plan, e.g. an /orchestrator "Plan change") the stack ran
30
+ * past the screen: "Keep planning", the feedback row and the hint were
31
+ * cut off, and a short plan left a blank block. The card now measures
32
+ * its plan and its place on screen after layout and trims the body.
33
+ * The ask_user_question card had the same fixed budget for its option
34
+ * list; it measures the same way and windows the list instead.
27
35
  *
28
36
  * Usage: node scripts/tui-plan-patch.mjs [apply|revert|check] [--tui <dir>]
29
37
  * Restart the TUI after apply/revert.
@@ -37,6 +45,43 @@ const MODE = 'lib/types/dsh-adapter/channel/mode-actions.js'
37
45
  const PERMISSION_MODE = 'lib/types/dsh-adapter/channel/mode-permission-actions.js'
38
46
  const PLAN_REVIEW = 'lib/types/components/questions/PlanReviewPanel.js'
39
47
  const LAUNCHPAD = 'lib/types/screens/Launchpad.js'
48
+ const ASK_QUESTION = 'lib/types/components/questions/AskUserQuestionPanel.js'
49
+
50
+ /**
51
+ * Shared by both question cards: after layout, how many rows of the card's
52
+ * stack (the card plus what follows it in each enclosing column, such as the
53
+ * usage band) fall outside the screen. Expects `panel` and `terminalRows`;
54
+ * defines `over`.
55
+ */
56
+ const FIT_WALK = ` // Absolute top of the card (same walk as useTerminalViewport) plus
57
+ // what follows it in each enclosing column (the usage band).
58
+ let top = 0;
59
+ let below = 0;
60
+ let root = panel.yogaNode;
61
+ for (let node = panel; node; node = node.parentNode) {
62
+ const parent = node.parentNode;
63
+ if (node.yogaNode) {
64
+ top += node.yogaNode.getComputedTop();
65
+ root = node.yogaNode;
66
+ if (parent?.yogaNode && parent.style?.flexDirection === 'column') {
67
+ const end = node.yogaNode.getComputedTop() + node.yogaNode.getComputedHeight();
68
+ let last = end;
69
+ for (const sibling of parent.childNodes.slice(parent.childNodes.indexOf(node) + 1)) {
70
+ if (!sibling.yogaNode || sibling.style?.position === 'absolute')
71
+ continue;
72
+ last = Math.max(last, sibling.yogaNode.getComputedTop() + sibling.yogaNode.getComputedHeight());
73
+ }
74
+ below += last - end;
75
+ }
76
+ }
77
+ if (parent?.scrollTop)
78
+ top -= parent.scrollTop;
79
+ }
80
+ const screen = root.getComputedHeight();
81
+ const viewTop = screen > terminalRows ? screen - terminalRows + 1 : 0;
82
+ const bottom = top + panel.yogaNode.getComputedHeight() + below;
83
+ const over = Math.max(0, bottom - (viewTop + terminalRows), viewTop - top);
84
+ `
40
85
 
41
86
  const commandEdge = [
42
87
  {
@@ -127,6 +172,98 @@ const commandEdge = [
127
172
  return;
128
173
  }`,
129
174
  },
175
+ {
176
+ file: PLAN_REVIEW,
177
+ label: 'plan card fit: terminal width',
178
+ stock: ' const { rows: terminalRows } = useTerminalSize();',
179
+ patched: ' const { rows: terminalRows, columns: terminalColumns } = useTerminalSize();',
180
+ },
181
+ {
182
+ file: PLAN_REVIEW,
183
+ label: 'plan card fit: measure',
184
+ stock: ` const detailMax = Math.max(0, terminalRows - reservedRows);
185
+ const detailScrollRef = React.useRef(null);`,
186
+ patched: ` const detailMax = Math.max(0, terminalRows - reservedRows);
187
+ const detailScrollRef = React.useRef(null);
188
+ // ceulen-plan: fit the card to the screen it is given. The twelve rows
189
+ // above are a guess: Chat stacks the goal/todo band, the spinner and
190
+ // plugin status views over the card in the same unshrinkable column, so
191
+ // a second plan (board already up) pushed "Keep planning", the feedback
192
+ // row and the hint off the bottom. And the body kept its whole budget
193
+ // even for a short plan, leaving a blank block. After each layout the
194
+ // card measures its plan (body = content height, at most the budget)
195
+ // and where its stack really ends on screen; any rows past the screen
196
+ // come off the body. The limit only shrinks for a given terminal size,
197
+ // so the measuring settles in a frame or two and cannot oscillate.
198
+ const panelRef = React.useRef(null);
199
+ const detailContentRef = React.useRef(null);
200
+ const [fit, setFit] = React.useState(null);
201
+ const fitNow = fit !== null && fit.rows === terminalRows && fit.columns === terminalColumns && fit.detail === question.detail ? fit : null;
202
+ const detailRows = Math.max(0, Math.min(detailMax, fitNow?.content ?? detailMax, fitNow?.limit ?? detailMax));
203
+ React.useLayoutEffect(() => {
204
+ const panel = panelRef.current;
205
+ if (!panel?.yogaNode)
206
+ return;
207
+ // The plan's own height: ScrollBox's inner box grows to the
208
+ // viewport, so the markdown sits in a box of its natural height.
209
+ const body = question.detail !== undefined && detailRows > 0 ? detailContentRef.current : null;
210
+ // A body not laid out yet reads 0: keep the last reading, or the
211
+ // card would drop its plan and never measure it again.
212
+ const measured = body?.yogaNode?.getComputedHeight() ?? 0;
213
+ const content = measured > 0 ? measured : fitNow?.content;
214
+ ${FIT_WALK} const rendered = body === null ? 0 : detailRows;
215
+ const limit = over > 0 ? Math.min(fitNow?.limit ?? Infinity, Math.max(0, rendered - over)) : fitNow?.limit;
216
+ if (fitNow === null || content !== fitNow.content || limit !== fitNow.limit) {
217
+ setFit({ rows: terminalRows, columns: terminalColumns, detail: question.detail, content, limit });
218
+ }
219
+ });`,
220
+ },
221
+ {
222
+ file: PLAN_REVIEW,
223
+ label: 'plan card fit: body height',
224
+ stock: 'question.detail !== undefined && detailMax > 0 && (_jsx(Box, { flexDirection: "column", marginTop: 1, height: detailMax, flexShrink: 0, children: _jsx(ScrollBox, { ref: detailScrollRef, flexDirection: "column", flexGrow: 1, height: detailMax, children: _jsx(Markdown, { children: question.detail }) }) }))',
225
+ patched: 'question.detail !== undefined && detailRows > 0 && (_jsx(Box, { flexDirection: "column", marginTop: 1, height: detailRows, flexShrink: 0, children: _jsx(ScrollBox, { ref: detailScrollRef, flexDirection: "column", flexGrow: 1, height: detailRows, children: _jsx(Box, { ref: detailContentRef, flexDirection: "column", flexShrink: 0, children: _jsx(Markdown, { children: question.detail }) }) }) }))',
226
+ },
227
+ {
228
+ file: PLAN_REVIEW,
229
+ label: 'plan card fit: panel ref',
230
+ stock: 'return (_jsxs(Box, { flexDirection: "column", marginTop: 1, paddingLeft: 2, paddingRight: 2, width: "100%", children: [_jsx(Divider, { color: "permission"',
231
+ patched: 'return (_jsxs(Box, { ref: panelRef, flexDirection: "column", marginTop: 1, paddingLeft: 2, paddingRight: 2, width: "100%", children: [_jsx(Divider, { color: "permission"',
232
+ },
233
+ {
234
+ file: ASK_QUESTION,
235
+ label: 'question card fit: measure',
236
+ stock: ' const optionBudget = Math.max(terminalRows - reservedRows, 2);',
237
+ patched: ` // ceulen-plan: fit the question card to the screen it is given. The
238
+ // twelve rows above are a guess: Chat stacks the goal/todo band, the
239
+ // spinner and plugin status views over the card in the same unshrinkable
240
+ // column, so a long option list asked while a board is up pushed the
241
+ // answer row, the key hint and the usage band off the bottom. After each
242
+ // layout the card measures where its stack really ends on screen and
243
+ // takes the rows past it off the option budget (the list then windows).
244
+ // The limit only shrinks for a given terminal size and question, so the
245
+ // measuring settles in a frame or two and cannot oscillate.
246
+ const panelRef = React.useRef(null);
247
+ const [fit, setFit] = React.useState(null);
248
+ const fitNow = fit !== null && fit.rows === terminalRows && fit.columns === terminalColumns && fit.id === question.id && fit.question === question.question ? fit : null;
249
+ const optionBudget = Math.max(Math.min(terminalRows - reservedRows, fitNow?.limit ?? Infinity), 2);
250
+ React.useLayoutEffect(() => {
251
+ const panel = panelRef.current;
252
+ if (!panel?.yogaNode)
253
+ return;
254
+ ${FIT_WALK} const rendered = windowedOptions ? optionBudget : wrappedOptionRows;
255
+ const limit = over > 0 ? Math.max(2, Math.min(fitNow?.limit ?? Infinity, rendered - over)) : fitNow?.limit;
256
+ if (fitNow === null || limit !== fitNow.limit) {
257
+ setFit({ rows: terminalRows, columns: terminalColumns, id: question.id, question: question.question, limit });
258
+ }
259
+ });`,
260
+ },
261
+ {
262
+ file: ASK_QUESTION,
263
+ label: 'question card fit: panel ref',
264
+ stock: ' return (_jsxs(Box, { flexDirection: "column", marginTop: 1, paddingLeft: 2, paddingRight: 2, width: "100%", children: [_jsx(Box, { flexDirection: "column", onClick: onToggleFold',
265
+ patched: ' return (_jsxs(Box, { ref: panelRef, flexDirection: "column", marginTop: 1, paddingLeft: 2, paddingRight: 2, width: "100%", children: [_jsx(Box, { flexDirection: "column", onClick: onToggleFold',
266
+ },
130
267
  {
131
268
  file: MODE,
132
269
  label: 'footer plan indicator (base)',
@@ -0,0 +1,161 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Headless layout smoke for the two question cards (behaviour 5 of
4
+ * tui-plan-patch.mjs). `check` there only proves the anchors are in place;
5
+ * this renders the installed PlanReviewPanel and AskUserQuestionPanel inside a
6
+ * Chat-like fullscreen stack (a growing transcript, a band of rows standing in
7
+ * for the goal/todo panel, the card, then a usage band) into a headless
8
+ * terminal, and asserts that every control the user needs is on screen.
9
+ *
10
+ * A stock dsh-tui fails the band cases: "Keep planning", the feedback row and
11
+ * the hint fall off the bottom, and a short plan leaves a blank block.
12
+ *
13
+ * Usage: node scripts/tui-question-fit-smoke.mjs [--tui <dir>]
14
+ * Exit 0 when every case passes, 1 when one fails, 2 when it cannot run.
15
+ * The stack is a stand-in, not the real Chat screen: a live check after a
16
+ * restart is still the final word.
17
+ */
18
+ import { execFileSync } from 'node:child_process'
19
+ import { existsSync } from 'node:fs'
20
+ import { createRequire } from 'node:module'
21
+ import { homedir } from 'node:os'
22
+ import { join } from 'node:path'
23
+ import { PassThrough, Writable } from 'node:stream'
24
+ import { pathToFileURL } from 'node:url'
25
+
26
+ const args = process.argv.slice(2)
27
+ const tuiFlag = args.indexOf('--tui')
28
+ const home = process.env.DSH_HOME?.trim() || join(homedir(), '.dsh')
29
+ const root = tuiFlag >= 0 && args[tuiFlag + 1] !== undefined
30
+ ? args[tuiFlag + 1]
31
+ : join(home, 'profiles', 'tui', 'node_modules', '@deepseek-harness-tui', 'dsh-tui')
32
+ const types = join(root, 'lib', 'types')
33
+ if (!existsSync(join(types, 'components', 'questions', 'PlanReviewPanel.js'))) {
34
+ console.error(`dsh-tui not found at ${root}\nPass --tui <path-to-@deepseek-harness-tui/dsh-tui>.`)
35
+ process.exit(2)
36
+ }
37
+
38
+ // The headless terminal ships with the global dsh core.
39
+ let Terminal
40
+ try {
41
+ const globalRoot = execFileSync(process.platform === 'win32' ? 'npm.cmd' : 'npm', ['root', '-g'], { encoding: 'utf8' }).trim()
42
+ Terminal = createRequire(join(globalRoot, '@deepseek-ai', 'dsh', 'package.json'))('@xterm/headless').Terminal
43
+ } catch (error) {
44
+ console.error(`@xterm/headless not found next to the global @deepseek-ai/dsh: ${error instanceof Error ? error.message : error}`)
45
+ process.exit(2)
46
+ }
47
+
48
+ const requireTui = createRequire(join(types, 'ui.js'))
49
+ const { jsx, jsxs } = requireTui('react/jsx-runtime')
50
+ const load = rel => import(pathToFileURL(join(types, rel)).href)
51
+ const { Box, Text, ThemeProvider } = await load('ui.js')
52
+ const { renderSync } = await load('ink/root.js')
53
+ const { PlanReviewPanel } = await load('components/questions/PlanReviewPanel.js')
54
+ const { AskUserQuestionPanel } = await load('components/questions/AskUserQuestionPanel.js')
55
+
56
+ const COLUMNS = 160
57
+
58
+ /** Render one card under `band` filler rows on a `rows`-high screen; the visible lines. */
59
+ async function screen({ rows, band, card }) {
60
+ const term = new Terminal({ cols: COLUMNS, rows, allowProposedApi: true })
61
+ const stdout = new Writable({ write(chunk, _encoding, done) { term.write(chunk.toString(), done) } })
62
+ Object.assign(stdout, { columns: COLUMNS, rows, isTTY: true })
63
+ const stdin = new PassThrough()
64
+ Object.assign(stdin, { isTTY: true, setRawMode() {}, ref() {}, unref() {} })
65
+ const tree = jsx(ThemeProvider, {
66
+ children: jsxs(Box, {
67
+ flexDirection: 'column', height: rows, width: '100%', flexShrink: 0, children: [
68
+ jsx(Box, { flexDirection: 'column', flexGrow: 1, flexShrink: 1, overflow: 'hidden', children: jsx(Text, { children: 'transcript' }) }),
69
+ jsxs(Box, {
70
+ flexDirection: 'column', flexShrink: 0, children: [
71
+ ...Array.from({ length: band }, (_, index) => jsx(Text, { children: `band row ${index + 1}` }, `band${index}`)),
72
+ jsxs(Box, { flexDirection: 'column', flexShrink: 0, children: [card, jsx(Text, { children: 'USAGE-BAND' })] }),
73
+ ],
74
+ }),
75
+ ],
76
+ }),
77
+ })
78
+ const instance = renderSync(tree, { stdout, stdin, stderr: process.stderr, patchConsole: false, exitOnCtrlC: false, terminalImages: false })
79
+ // Layout effects measure, set state and lay out again: give it a few frames.
80
+ await new Promise(resolve => setTimeout(resolve, 600))
81
+ const buffer = term.buffer.active
82
+ const lines = []
83
+ for (let y = 0; y < rows; y++) lines.push(buffer.getLine(buffer.baseY + y)?.translateToString(true) ?? '')
84
+ // Unmount restores terminal modes with writeSync on a TTY stream's fd (1 for
85
+ // this fake one): keep those bytes out of the report.
86
+ stdout.isTTY = false
87
+ instance.unmount()
88
+ instance.cleanup?.()
89
+ return lines
90
+ }
91
+
92
+ const noop = () => {}
93
+ const planCard = planLines => jsx(PlanReviewPanel, {
94
+ question: {
95
+ id: 'plan-review',
96
+ header: 'Plan change',
97
+ question: 'The lead changed the plan you approved (adds T4). Approve the new plan?',
98
+ detail: Array.from({ length: planLines }, (_, index) => `- plan line ${index + 1}`).join('\n'),
99
+ options: [
100
+ { label: 'Approve', description: 'The lead dispatches the team on this plan.' },
101
+ { label: 'Keep planning', description: 'Nothing is dispatched; your feedback goes back to the lead.' },
102
+ ],
103
+ intent: { kind: 'plan-review', approve: 'Approve' },
104
+ },
105
+ onAnswer: noop,
106
+ onCancel: noop,
107
+ })
108
+ const askCard = count => jsx(AskUserQuestionPanel, {
109
+ question: {
110
+ id: 'pick',
111
+ header: 'Route',
112
+ question: 'Which route should the lead use for the follow-up task?',
113
+ detail: 'Pick one. The lead keeps the plan otherwise.',
114
+ options: Array.from({ length: count }, (_, index) => ({ label: `Option ${index + 1}`, description: `What option ${index + 1} means` })),
115
+ },
116
+ position: 0,
117
+ total: 1,
118
+ answered: [],
119
+ onAnswer: noop,
120
+ onCancel: noop,
121
+ fullscreen: true,
122
+ })
123
+
124
+ const has = (lines, pattern) => lines.some(line => pattern.test(line))
125
+ const index = (lines, pattern) => lines.findIndex(line => pattern.test(line))
126
+ const planChecks = planLines => lines => {
127
+ const failures = []
128
+ if (!has(lines, /2\. Keep planning/)) failures.push('"Keep planning" is off screen')
129
+ if (!has(lines, /✎/)) failures.push('the feedback row is off screen')
130
+ if (!has(lines, /Esc/)) failures.push('the key hint is off screen')
131
+ if (!has(lines, /USAGE-BAND/)) failures.push('the band under the card is off screen')
132
+ const last = index(lines, new RegExp(`plan line ${planLines}$`))
133
+ const approve = index(lines, /1\. Approve/)
134
+ if (last >= 0 && approve >= 0 && approve - last > 4) failures.push(`${approve - last - 1} rows between the plan and the options`)
135
+ return failures
136
+ }
137
+ const askChecks = count => lines => {
138
+ const failures = []
139
+ if (!has(lines, /✎/)) failures.push('the answer row is off screen')
140
+ if (!has(lines, /Esc/)) failures.push('the key hint is off screen')
141
+ if (!has(lines, /USAGE-BAND/)) failures.push('the band under the card is off screen')
142
+ if (count <= 3 && lines.filter(line => /Option \d+\s*$/.test(line)).length !== count) failures.push('a short option list lost an option')
143
+ return failures
144
+ }
145
+
146
+ const cases = [
147
+ { name: 'plan card, short plan, todo band up (the reported bug)', rows: 98, band: 10, card: planCard(56), check: planChecks(56) },
148
+ { name: 'plan card, short plan, no band (first plan)', rows: 98, band: 0, card: planCard(56), check: planChecks(56) },
149
+ { name: 'plan card, long plan scrolls, todo band up', rows: 60, band: 8, card: planCard(80), check: planChecks(80) },
150
+ { name: 'question card, 15 options, todo band up', rows: 40, band: 8, card: askCard(15), check: askChecks(15) },
151
+ { name: 'question card, 3 options, todo band up', rows: 40, band: 8, card: askCard(3), check: askChecks(3) },
152
+ ]
153
+
154
+ let failed = 0
155
+ for (const entry of cases) {
156
+ const failures = entry.check(await screen(entry))
157
+ if (failures.length > 0) failed += 1
158
+ console.log(`${failures.length === 0 ? 'ok ' : 'FAIL'} ${entry.name}${failures.length === 0 ? '' : `: ${failures.join('; ')}`}`)
159
+ }
160
+ console.log(failed === 0 ? 'question cards fit the screen.' : `${failed} case${failed === 1 ? '' : 's'} failed: run scripts/tui-plan-patch.mjs apply, or the anchors moved.`)
161
+ process.exit(failed === 0 ? 0 : 1)
@@ -105,10 +105,12 @@ node -p "require(process.env.HOME+'/.dsh/profiles/tui/node_modules/@deepseek-har
105
105
  # an add/remove/reinstall wipes every one of them.
106
106
  for p in advisor context toolname plan effort style panel; do node scripts/tui-$p-patch.mjs apply || exit 1; done
107
107
  for p in advisor context toolname plan effort style panel; do node scripts/tui-$p-patch.mjs check || exit 1; done
108
+ # `check` proves anchors, not behaviour: render the question cards headless.
109
+ node scripts/tui-question-fit-smoke.mjs || exit 1
108
110
  ```
109
111
 
110
112
  Repeat for every profile with an installed TUI, passing `--tui <resolved-dir>`
111
- to every patch script. Finish all profile package changes before applying
113
+ to every patch script and to the smoke. Finish all profile package changes before applying
112
114
  patches: another add/remove can rewrite the dependency tree again.
113
115
 
114
116
  Preserve the existing `~/.dsh-tui/effort-by-model.json` (resolved from the
@@ -142,8 +144,8 @@ not replace a literal old version that becomes a no-op after an upgrade.
142
144
  - Seven patches ride the installed dsh-tui tree, and a missed one breaks silently:
143
145
  `advisor` (reviewer notes in the transcript), `context` (`/context` opens the
144
146
  dashboard instead of the loaded-context text dump), `toolname` (grep tool
145
- renders as `fff`, not `Fff_grep`), `plan` (bare `/plan` toggles and the footer
146
- names plan mode), `effort` (per-model reasoning effort). `apply` fails loudly when an anchor moves; `check` exits 1
147
+ renders as `fff`, not `Fff_grep`), `plan` (bare `/plan` toggles, the footer
148
+ names plan mode, and both question cards fit the screen), `effort` (per-model reasoning effort). `apply` fails loudly when an anchor moves; `check` exits 1
147
149
  when not applied.
148
150
  - `style` adds live `/theme style dsh|pi|omp` layout selection without changing
149
151
  the color theme; `ui-style.json` shares the effort preference directory.
@@ -157,6 +159,23 @@ not replace a literal old version that becomes a no-op after an upgrade.
157
159
  anchors (the class `open(id)` head and its `request('open', …)` line, the
158
160
  bridge `request.kind === 'open'` branch and its `openPanel(…, { focus: true })`)
159
161
  before extending the gate.
162
+ - `plan` also patches `components/questions/PlanReviewPanel.js` and
163
+ `AskUserQuestionPanel.js`. Stock sizes the plan body and the option list
164
+ as the terminal height minus a fixed 12 rows, ignoring the goal/todo band,
165
+ spinner and status views stacked above. With a board up (e.g. the second
166
+ `/orchestrator` plan, a "Plan change" card) "Keep planning", the feedback/
167
+ answer row and the hint fell off the bottom, and a short plan left a blank
168
+ block (fixed 2026-11-25). The patch measures after layout (the card's yoga
169
+ position, the plan's natural height in a wrapper box) with a shrink-only
170
+ limit. Anchors: `detailMax`/`detailScrollRef`, the detail `ScrollBox` with its
171
+ `Markdown`, both panels' root `Box`, and the `optionBudget` line. If upstream
172
+ now sizes the cards from real layout, drop these edges instead of porting
173
+ them, and keep `scripts/tui-question-fit-smoke.mjs` as the proof. The smoke
174
+ must pass on the patched tree and fail on a reverted copy. It is a stand-in
175
+ stack (not the real Chat), so the live card check after restart stays.
176
+ Exit 1 is a card that does not fit (patch lost or anchors moved). Exit 2
177
+ means the smoke could not run: TUI not found, or `@xterm/headless` missing
178
+ from the global core. Fix the harness and do not count that as a patch result.
160
179
  - dsh-tui 0.19.0 dropped the context patch with no warning (2026-11-06):
161
180
  `/context` still answered, it just dumped the stock report again. That is why
162
181
  the loop now covers all seven, not the two this section used to list.
@@ -211,7 +230,8 @@ Run one read-only independent review of the compatibility delta, distinguishing
211
230
  pre-existing user edits; fix blockers and rerun affected checks before reporting.
212
231
 
213
232
  After review and any resulting fixes/package operations, run all seven patch
214
- `check` commands again for every installed TUI profile. This is the final gate,
233
+ `check` commands and `node scripts/tui-question-fit-smoke.mjs` again for every
234
+ installed TUI profile. This is the final gate,
215
235
  not just a step-4 check: bundle installs or reinstalls later in the task can
216
236
  replace patched files even when the TUI version is unchanged. If any check
217
237
  fails, reapply the compatible patches and recheck before declaring success.
@@ -252,6 +272,10 @@ Verify after restart:
252
272
  segment means that patch is missing — run its script and restart again.
253
273
  - `/context` renders the colour dashboard (that is `context-redirect applied`
254
274
  proving itself).
275
+ - With a todo/goal band up, a plan-review card (or `/orchestrator`'s "Plan
276
+ change") shows Approve, Keep planning, the ✎ feedback row and the key hint,
277
+ with no blank block under a short plan. Leave it pending if no plan is due;
278
+ do not start a paid run only to see it.
255
279
  - Switch model A → B → A using existing per-model preferences: reasoning must
256
280
  return to A's saved level, not the global `max`; the model picker must preview
257
281
  that level too. Do not overwrite user preferences to test this. Resumed
@@ -272,6 +296,7 @@ npm i -g --allow-scripts=@deepseek-ai/dsh-subprocess-local,koffi,node-pty,@googl
272
296
  dsh plugin --profile tui add @deepseek-harness-tui/dsh-tui@<exact-old-tui>
273
297
  for p in advisor context toolname plan effort style panel; do node scripts/tui-$p-patch.mjs apply || exit 1; done
274
298
  for p in advisor context toolname plan effort style panel; do node scripts/tui-$p-patch.mjs check || exit 1; done
299
+ node scripts/tui-question-fit-smoke.mjs || exit 1
275
300
  ```
276
301
 
277
302
  Restore only update-owned compatibility hunks (including `dshTui` and release
@@ -3,10 +3,10 @@
3
3
  "upstream": {
4
4
  "package": "ceulen",
5
5
  "repo": "ceulen-dev/ceulen",
6
- "version": "0.23.0",
7
- "commit": "ee0187ea923ee815615e984044788f2adb493e6e",
8
- "tarball": "https://registry.npmjs.org/ceulen/-/ceulen-0.23.0.tgz",
9
- "syncedAt": "2026-10-23T00:00:00.000Z"
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": {