@hmharness/cli 0.14.7 → 0.14.10
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/dist/main.js +193 -8
- package/dist/tui.d.ts +127 -12
- package/dist/tui.js +1023 -54
- package/dist/web-daemon.d.ts +30 -13
- package/dist/web-daemon.js +45 -24
- package/package.json +5 -5
package/dist/main.js
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import readline from 'node:readline/promises';
|
|
25
25
|
import { stdin, stdout } from 'node:process';
|
|
26
|
+
import { readFile } from 'node:fs/promises';
|
|
26
27
|
import { join } from 'node:path';
|
|
27
28
|
import { stopWebDaemon, startWebDaemon, hmhWebUp, readWebPid } from "./web-daemon.js";
|
|
28
29
|
import { chat, homeDir, resolveProvider, initHome, latestSession, listProviders, listSessions, loadConfig, loadTranscript, mcpServerTools, Registry, runLoop, setChatRoute, setLocale, } from '@hmharness/kernel';
|
|
@@ -63,8 +64,12 @@ async function runTask(task, taskOpts = {}) {
|
|
|
63
64
|
registry: reg,
|
|
64
65
|
cfg,
|
|
65
66
|
yes: taskOpts.yes,
|
|
66
|
-
resumeMessages:
|
|
67
|
+
resumeMessages: [
|
|
68
|
+
...(taskOpts.plan ? [{ role: 'system', content: '[plan mode] Before ANY tool use, present a concrete plan (2-5 numbered steps). Then STOP and wait for the user to confirm before executing. Only execute after explicit confirmation.' }] : []),
|
|
69
|
+
...(taskOpts.resumeMessages ?? []),
|
|
70
|
+
],
|
|
67
71
|
sessionId: taskOpts.sessionId,
|
|
72
|
+
...(taskOpts.forkFrom ? { forkFrom: taskOpts.forkFrom } : {}),
|
|
68
73
|
events: {
|
|
69
74
|
onLine: (l) => stdout.write(DIM(` ${l}\n`)),
|
|
70
75
|
onDelta: (kind, chunk) => {
|
|
@@ -122,6 +127,11 @@ async function repl(yes, initialHistory, initialSessionId) {
|
|
|
122
127
|
// one rollout per conversation: the first task creates it, later lines and
|
|
123
128
|
// `hmh resume` sessions append to it (codex thread semantics)
|
|
124
129
|
let currentSessionId = initialSessionId;
|
|
130
|
+
// M4 B7: /fork queues a fork of the next task; /plan injects a
|
|
131
|
+
// plan-first directive (kernel forkFrom + system directive ride in runTask)
|
|
132
|
+
let pendingFork = false;
|
|
133
|
+
let forkAll = false;
|
|
134
|
+
let planMode = false;
|
|
125
135
|
try {
|
|
126
136
|
while (true) {
|
|
127
137
|
let line;
|
|
@@ -225,6 +235,70 @@ async function repl(yes, initialHistory, initialSessionId) {
|
|
|
225
235
|
stdout.write(DIM(t.cmdClearDone) + '\n');
|
|
226
236
|
continue;
|
|
227
237
|
}
|
|
238
|
+
if (line === '/new') {
|
|
239
|
+
// M4 B7: new-session alias of /clear (codex /new)
|
|
240
|
+
history = [];
|
|
241
|
+
currentSessionId = undefined;
|
|
242
|
+
stdout.write(DIM(t.cmdNewDone) + '\n');
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
if (line === '/compact') {
|
|
246
|
+
// M4 B7: compact the in-memory resume; report the delta
|
|
247
|
+
const { transcriptChars, compactMessages, adaptiveContextChars } = await import('@hmharness/kernel');
|
|
248
|
+
const before = transcriptChars(history);
|
|
249
|
+
const budget = adaptiveContextChars(cfg.provider);
|
|
250
|
+
history = compactMessages(history, budget);
|
|
251
|
+
const after = transcriptChars(history);
|
|
252
|
+
stdout.write(`context: ${before.toLocaleString()} → ${after.toLocaleString()} chars (freed ${(before - after).toLocaleString()}; budget ${budget.toLocaleString()})\n`);
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
if (line === '/usage') {
|
|
256
|
+
const { transcriptChars, adaptiveContextChars } = await import('@hmharness/kernel');
|
|
257
|
+
const chars = transcriptChars(history);
|
|
258
|
+
const budget = adaptiveContextChars(cfg.provider);
|
|
259
|
+
stdout.write(`context: ${chars.toLocaleString()} chars (~${Math.ceil(chars / 4).toLocaleString()} tok) of ${budget.toLocaleString()} budget (${Math.round((chars / budget) * 100)}%)\n`);
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
if (line === '/goal' || line.startsWith('/goal ')) {
|
|
263
|
+
const { getGoal, setGoal, clearGoal } = await import('@hmharness/kernel');
|
|
264
|
+
const arg = line.slice(6).trim();
|
|
265
|
+
const key = currentSessionId ?? 'web';
|
|
266
|
+
if (!arg) {
|
|
267
|
+
const g = await getGoal(home, key);
|
|
268
|
+
stdout.write((g ? `goal: ${g}` : '(no goal set — /goal <text> to set)') + '\n');
|
|
269
|
+
}
|
|
270
|
+
else if (arg === 'clear') {
|
|
271
|
+
await clearGoal(home, key);
|
|
272
|
+
stdout.write(DIM(t.cmdGoalCleared) + '\n');
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
await setGoal(home, key, arg);
|
|
276
|
+
stdout.write(GREEN('✓') + ` goal set (session ${key.slice(0, 8)}…)\n`);
|
|
277
|
+
}
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
if (line === '/fork') {
|
|
281
|
+
// M4 B7: the NEXT task forks a new session inheriting full context
|
|
282
|
+
// (kernel forkFrom provenance rides in runTask)
|
|
283
|
+
if (!currentSessionId && history.length === 0) {
|
|
284
|
+
stdout.write('nothing to fork yet\n');
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
pendingFork = true;
|
|
288
|
+
forkAll = true;
|
|
289
|
+
stdout.write(DIM('✂ next task runs as a NEW session (forked' + (currentSessionId ? ' from ' + currentSessionId : '') + ')\n'));
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
if (line === '/plan') {
|
|
293
|
+
planMode = !planMode;
|
|
294
|
+
stdout.write((planMode ? GREEN('🔥') + ' ' + t.cmdPlanOn : t.cmdPlanOff) + '\n');
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
if (line === '/review') {
|
|
298
|
+
// M4 B7: submit the review-worktree task template
|
|
299
|
+
line = 'Review the current worktree: run git status and inspect the diffs, then identify bugs, risks, regressions, and missing tests. Report findings ordered by severity with file:line references. Do NOT modify any files.';
|
|
300
|
+
// fall through to the task runner below
|
|
301
|
+
}
|
|
228
302
|
if (line === '/status') {
|
|
229
303
|
header();
|
|
230
304
|
continue;
|
|
@@ -258,18 +332,36 @@ async function repl(yes, initialHistory, initialSessionId) {
|
|
|
258
332
|
stdout.write(t.tuiEvolveDone(report.proposals.length, report.insightCount, report.noteCount) + '\n');
|
|
259
333
|
continue;
|
|
260
334
|
}
|
|
261
|
-
|
|
262
|
-
|
|
335
|
+
if (line === '/review') {
|
|
336
|
+
// M4 B7: submit the review-worktree task template — falls through
|
|
337
|
+
// to the task runner below; the else-branch fires only for lines
|
|
338
|
+
// no command consumed
|
|
339
|
+
line = 'Review the current worktree: run git status and inspect the diffs, then identify bugs, risks, regressions, and missing tests. Report findings ordered by severity with file:line references. Do NOT modify any files.';
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
stdout.write(YELLOW(t.unknownCommand(line) + '\n'));
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
263
345
|
}
|
|
264
346
|
try {
|
|
265
|
-
const r = await runTask(line, {
|
|
347
|
+
const r = await runTask(line, {
|
|
348
|
+
yes: autoApprove, sharedRl: rl, registry: reg, clients,
|
|
349
|
+
resumeMessages: history,
|
|
350
|
+
sessionId: pendingFork && !forkAll ? undefined : currentSessionId,
|
|
351
|
+
forkFrom: pendingFork ? currentSessionId : undefined,
|
|
352
|
+
plan: planMode,
|
|
353
|
+
});
|
|
266
354
|
// working transcript = [system, ...resumeMessages, user, ...new turns];
|
|
267
355
|
// only the NEW turns (past the replayed prefix) extend history.
|
|
268
|
-
|
|
356
|
+
pendingFork = false;
|
|
357
|
+
forkAll = false;
|
|
358
|
+
history = [...history, { role: 'user', content: line }, ...r.messages.slice((planMode ? 1 : 0) + history.length + 2)];
|
|
269
359
|
// one rollout per REPL conversation (codex thread semantics)
|
|
270
360
|
currentSessionId = r.sessionId;
|
|
271
361
|
}
|
|
272
362
|
catch (err) {
|
|
363
|
+
pendingFork = false;
|
|
364
|
+
forkAll = false;
|
|
273
365
|
stdout.write(`error: ${String(err)}\n`);
|
|
274
366
|
}
|
|
275
367
|
}
|
|
@@ -799,9 +891,10 @@ flags:
|
|
|
799
891
|
const up = await hmhWebUp(Number.isFinite(port) ? port : 7788);
|
|
800
892
|
stdout.write(up ? t.webRunning(readWebPid() || 0, port) + '\n' : t.webNotRunning + '\n');
|
|
801
893
|
// stale-daemon warning: the daemon is a code snapshot from spawn time;
|
|
802
|
-
// after an upgrade it keeps serving old code until restarted
|
|
894
|
+
// after an upgrade it keeps serving old code until restarted. The
|
|
895
|
+
// comparison uses the SERVED process's self-reported version.
|
|
803
896
|
const { webDaemonStale } = await import("./web-daemon.js");
|
|
804
|
-
const v = webDaemonStale();
|
|
897
|
+
const v = await webDaemonStale(Number.isFinite(port) ? port : 7788);
|
|
805
898
|
if (up && v.stale) {
|
|
806
899
|
stdout.write(YELLOW(`⚠ daemon is running v${v.daemon} but CLI is v${v.cli} — stale code (new features missing). Run: hmh web stop && hmh web start\n`));
|
|
807
900
|
}
|
|
@@ -822,7 +915,9 @@ flags:
|
|
|
822
915
|
}
|
|
823
916
|
// default: foreground server (handy for debugging)
|
|
824
917
|
const { startServer } = await import('@hmharness/web');
|
|
825
|
-
|
|
918
|
+
const { createRequire: cr } = await import('node:module');
|
|
919
|
+
const ver = cr(import.meta.url)('../package.json').version ?? '';
|
|
920
|
+
await startServer({ port: Number.isFinite(port) ? port : 7788, host: '127.0.0.1', version: ver });
|
|
826
921
|
return; // startServer keeps the process alive
|
|
827
922
|
}
|
|
828
923
|
if (cmd === 'pipeline') {
|
|
@@ -890,6 +985,96 @@ flags:
|
|
|
890
985
|
}
|
|
891
986
|
return;
|
|
892
987
|
}
|
|
988
|
+
if (cmd === 'reward') {
|
|
989
|
+
// V3 RL phase (ADR-0010): learned reward model over the human labels
|
|
990
|
+
await initHome();
|
|
991
|
+
const home = homeDir();
|
|
992
|
+
const E = await import('@hmharness/evolution');
|
|
993
|
+
const sub = rest[0] ?? 'report';
|
|
994
|
+
const readJsonl = async (f) => {
|
|
995
|
+
try {
|
|
996
|
+
return (await readFile(f, 'utf8')).trim().split('\n').filter(Boolean).map((l) => JSON.parse(l));
|
|
997
|
+
}
|
|
998
|
+
catch {
|
|
999
|
+
return [];
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
const labels = (await readJsonl(join(home, 'evolution', 'reward-human-labels.jsonl')));
|
|
1003
|
+
const insights = (await readJsonl(join(home, 'insights', 'insights.jsonl')));
|
|
1004
|
+
if (sub === 'fit') {
|
|
1005
|
+
if (labels.length < 10) {
|
|
1006
|
+
stdout.write('need >=10 human labels to fit (have ' + labels.length + ')\n');
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
const m = E.fitRewardModel(labels, insights);
|
|
1010
|
+
await E.saveRewardModel(home, m);
|
|
1011
|
+
stdout.write('reward model fitted on ' + m.nSamples + ' joined labels\n');
|
|
1012
|
+
stdout.write(' weights[outcome, failRate, turns, tools, bias] = ' + m.w.map((v) => v.toFixed(3)).join(', ') + '\n');
|
|
1013
|
+
stdout.write(' train RMSE ' + m.trainRmse + (m.holdoutRmse !== undefined ? ' · holdout RMSE ' + m.holdoutRmse : ' · (no holdout yet)') + '\n');
|
|
1014
|
+
stdout.write(' saved: ' + join(home, 'evolution', 'reward-model.json') + '\n');
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
if (sub === 'report') {
|
|
1018
|
+
const m = await E.loadRewardModel(home);
|
|
1019
|
+
if (!m) {
|
|
1020
|
+
stdout.write('no fitted reward model - run: hmh reward fit\n');
|
|
1021
|
+
return;
|
|
1022
|
+
}
|
|
1023
|
+
stdout.write('reward model @ ' + m.trainedAt + '\n');
|
|
1024
|
+
stdout.write(' samples ' + m.nSamples + ' · train RMSE ' + m.trainRmse + (m.holdoutRmse !== undefined ? ' · holdout RMSE ' + m.holdoutRmse : '') + '\n');
|
|
1025
|
+
stdout.write(' weights [outcome, failRate, turns, tools, bias] = ' + m.w.map((v) => v.toFixed(3)).join(', ') + '\n');
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
if (sub === 'export-dpo') {
|
|
1029
|
+
const { findSessionFile, readSessionHead, loadTranscript } = await import('@hmharness/kernel');
|
|
1030
|
+
const taskOf = async (session) => {
|
|
1031
|
+
try {
|
|
1032
|
+
const f = await findSessionFile(home, session);
|
|
1033
|
+
if (!f)
|
|
1034
|
+
return '';
|
|
1035
|
+
const h = await readSessionHead(f);
|
|
1036
|
+
return h?.firstUser ?? '';
|
|
1037
|
+
}
|
|
1038
|
+
catch {
|
|
1039
|
+
return '';
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
1042
|
+
const answerOf = async (session) => {
|
|
1043
|
+
try {
|
|
1044
|
+
const f = await findSessionFile(home, session);
|
|
1045
|
+
if (!f)
|
|
1046
|
+
return '';
|
|
1047
|
+
const tr = await loadTranscript(f);
|
|
1048
|
+
if (!tr)
|
|
1049
|
+
return '';
|
|
1050
|
+
for (let i = tr.messages.length - 1; i >= 0; i--) {
|
|
1051
|
+
const m = tr.messages[i];
|
|
1052
|
+
if (m.role === 'assistant' && typeof m.content === 'string' && m.content.trim())
|
|
1053
|
+
return m.content;
|
|
1054
|
+
}
|
|
1055
|
+
return '';
|
|
1056
|
+
}
|
|
1057
|
+
catch {
|
|
1058
|
+
return '';
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
const sessions = [...new Set(labels.map((l) => l.session))];
|
|
1062
|
+
const tasks = new Map();
|
|
1063
|
+
const answers = new Map();
|
|
1064
|
+
for (const s2 of sessions) {
|
|
1065
|
+
tasks.set(s2, await taskOf(s2));
|
|
1066
|
+
answers.set(s2, await answerOf(s2));
|
|
1067
|
+
}
|
|
1068
|
+
const pairs = E.exportDpoPairs(labels, insights, (x2) => tasks.get(x2) ?? '', (x2) => answers.get(x2) ?? '');
|
|
1069
|
+
const out = join(home, 'evolution', 'dpo-pairs.jsonl');
|
|
1070
|
+
const { writeFile: wf } = await import('node:fs/promises');
|
|
1071
|
+
await wf(out, pairs.map((p) => JSON.stringify(p)).join('\n') + (pairs.length ? '\n' : ''), 'utf8');
|
|
1072
|
+
stdout.write('DPO pairs: ' + pairs.length + ' -> ' + out + '\n');
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1075
|
+
stdout.write('usage: hmh reward fit | report | export-dpo\n');
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
893
1078
|
if (cmd === 'dataset') {
|
|
894
1079
|
// V2 M10: trajectory -> versioned dataset (filter/dedupe/reward/split)
|
|
895
1080
|
await initHome();
|
package/dist/tui.d.ts
CHANGED
|
@@ -12,11 +12,58 @@ export declare function matchCommands(input: string): Array<{
|
|
|
12
12
|
}>;
|
|
13
13
|
/** `/lang` target resolver: explicit zh/en wins, a bare `/lang` toggles. */
|
|
14
14
|
export declare function nextLocale(current: string, arg: string): 'zh' | 'en';
|
|
15
|
+
/** The trailing `@<query>` token of a task line, or null. Drives the @-file
|
|
16
|
+
* palette (codex/dsh @ reference): typing '@' opens it, the following
|
|
17
|
+
* path-ish chars extend the query, Enter inserts the picked path. */
|
|
18
|
+
export declare function atToken(input: string): string | null;
|
|
19
|
+
/** Substring history search (Ctrl+R): indices of entries containing the
|
|
20
|
+
* query (case-insensitive), NEWEST first, capped at 50. Empty query lists
|
|
21
|
+
* the most recent 50. */
|
|
22
|
+
export declare function histMatches(history: string[], query: string): number[];
|
|
23
|
+
/** `!` line prefix → the shell command to run (B3), or null. Empty `!` is
|
|
24
|
+
* not a command. */
|
|
25
|
+
export declare function shellBang(line: string): string | null;
|
|
26
|
+
/** Double-Esc fork-edit arming (B6): a bare Esc when idle+empty returns true
|
|
27
|
+
* only if the previous Esc was within `windowMs` and the arm is set. Pure
|
|
28
|
+
* timing decision; the runtime keeps escAt/armed state. */
|
|
29
|
+
export declare function forkArm(prevAt: number, now: number, armed: boolean, windowMs?: number): boolean;
|
|
30
|
+
/** Index of the LAST user-role message — the fork point (T13): a fork keeps
|
|
31
|
+
* everything BEFORE it as the new thread's resume and replaces it with the
|
|
32
|
+
* edited message. -1 when there is none. */
|
|
33
|
+
export declare function lastUserIdx(messages: Array<{
|
|
34
|
+
role: string;
|
|
35
|
+
}>): number;
|
|
36
|
+
/** /statusline (B11): render a configurable bottom-line template. Supported
|
|
37
|
+
* placeholders: {model} {cwd} {skills} {mode} {queue} {version} — unknown
|
|
38
|
+
* tokens stay literal so a typo is visible, never silently dropped. */
|
|
39
|
+
export declare function renderStatusline(template: string, ctx: {
|
|
40
|
+
model: string;
|
|
41
|
+
cwd: string;
|
|
42
|
+
skills: number;
|
|
43
|
+
mode: string;
|
|
44
|
+
queue: number;
|
|
45
|
+
version: string;
|
|
46
|
+
}): string;
|
|
47
|
+
/** /keymap (B14): parse a human key spec into the raw-mode byte string the
|
|
48
|
+
* TUI dispatches on. Returns null for unknown specs. */
|
|
49
|
+
export declare function parseKeySpec(spec: string): string | null;
|
|
50
|
+
/** The remappable M2/M4 actions and their defaults (B14). */
|
|
51
|
+
export declare const KEYMAP_DEFAULTS: Record<string, string>;
|
|
15
52
|
/**
|
|
16
53
|
* SGR mouse wheel decoding: '\x1b[<64;COL;ROWM' is wheel-up (-1), 65 is
|
|
17
54
|
* wheel-down (+1), anything else (clicks, drags, plain keys) is 0.
|
|
18
55
|
*/
|
|
19
56
|
export declare function parseWheel(data: string): number;
|
|
57
|
+
/**
|
|
58
|
+
* SGR reports can split across stdin chunks (fast wheel bursts fragment in
|
|
59
|
+
* some terminals). If the buffer ends inside a report - a trailing
|
|
60
|
+
* '\x1b[<...' with no terminating M/m yet - slice it off as `pending` for
|
|
61
|
+
* the next chunk and hand back only the complete part.
|
|
62
|
+
*/
|
|
63
|
+
export declare function splitMouseReport(data: string): {
|
|
64
|
+
data: string;
|
|
65
|
+
pending: string;
|
|
66
|
+
};
|
|
20
67
|
export declare class TuiRuntime {
|
|
21
68
|
private entries;
|
|
22
69
|
private dirty;
|
|
@@ -50,18 +97,41 @@ export declare class TuiRuntime {
|
|
|
50
97
|
private modeTag;
|
|
51
98
|
/** rows for the `/model ` picker (configured providers first, set by driver) */
|
|
52
99
|
private modelChoices;
|
|
53
|
-
/** Wheel/click handling:
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* selection
|
|
60
|
-
*
|
|
100
|
+
/** Wheel/click handling: SGR mouse reporting is ALWAYS on (enabled with
|
|
101
|
+
* ?1000h+?1006h at startup). Cross-terminal wheel support has to come
|
|
102
|
+
* from explicit reports: only some terminals translate the wheel to
|
|
103
|
+
* arrow keys on the alternate screen, so the wheel would silently do
|
|
104
|
+
* nothing on the others (conhost, several Linux terminals, the
|
|
105
|
+
* KaihongOS terminal). The wheel drives the transcript (or the open
|
|
106
|
+
* palette's selection); clicks only pick rows while a palette is open.
|
|
107
|
+
* Native select/copy stays available via Shift+click, the standard
|
|
108
|
+
* bypass in mainstream terminals. */
|
|
61
109
|
private mouseReported;
|
|
110
|
+
/** tail of an SGR mouse report split across stdin chunks (fast wheel
|
|
111
|
+
* bursts); prepended to the next chunk so parseWheel sees the sequence */
|
|
112
|
+
private mousePending;
|
|
62
113
|
/** screen row of each visible palette item (SGR click hit-testing); the
|
|
63
114
|
* render loop records row = frame.length (1-based) as it pushes rows */
|
|
64
115
|
private paletteClickRows;
|
|
116
|
+
/** Ctrl+R incremental history search: { query, matches (history indices), sel } */
|
|
117
|
+
private histSearch;
|
|
118
|
+
/** Ctrl+T full-transcript overlay (also the pager base for B9): title + lines + viewport top */
|
|
119
|
+
private overlay;
|
|
120
|
+
/** @-file palette (codex @ fuzzy reference): trailing @token query + ranked hits */
|
|
121
|
+
private atPal;
|
|
122
|
+
/** double-Esc fork-edit arming (T13): timestamp of the first bare Esc */
|
|
123
|
+
private escAt;
|
|
124
|
+
private forkArmed;
|
|
125
|
+
/** driver callbacks for the running-interaction trio (T9/T10) */
|
|
126
|
+
private interruptFn;
|
|
127
|
+
private injectFn;
|
|
128
|
+
private forkEditFn;
|
|
129
|
+
/** M5 B12: Ctrl+G hands the draft to an external editor ($EDITOR/notepad) */
|
|
130
|
+
private externalEditFn;
|
|
131
|
+
/** M5 B14: remappable key bindings (config.json tui.keymap) */
|
|
132
|
+
private keymap;
|
|
133
|
+
/** last user-submitted line, for Esc-Esc edit-and-fork (T13) */
|
|
134
|
+
private lastUserMsg;
|
|
65
135
|
constructor();
|
|
66
136
|
setModelChoices(list: Array<{
|
|
67
137
|
name: string;
|
|
@@ -87,6 +157,15 @@ export declare class TuiRuntime {
|
|
|
87
157
|
/** Full-frame picker layout (codex draw_picker): title / search+toolbar /
|
|
88
158
|
* list window / two hint lines / position footer. */
|
|
89
159
|
private renderResumePicker;
|
|
160
|
+
/** Ctrl+R history-search modal (B4): query line + matching entries,
|
|
161
|
+
* newest first; Enter adopts, Esc closes, ^P/^N or arrows move. */
|
|
162
|
+
private renderHistSearch;
|
|
163
|
+
/** Ctrl+T full-transcript overlay (B5): title + scrollable lines; also the
|
|
164
|
+
* pager base for long outputs (B9). q/Esc closes, ↑↓/PgUp/PgDn/g/G scroll. */
|
|
165
|
+
private renderOverlay;
|
|
166
|
+
/** @-file palette (B2): ranked workspace hits for the trailing @token.
|
|
167
|
+
* Enter inserts the path; Esc closes; arrows move. */
|
|
168
|
+
private renderAtPal;
|
|
90
169
|
/** Run the highlighted palette row (shared by Enter and palette clicks);
|
|
91
170
|
* with no palette open it just submits the typed input. */
|
|
92
171
|
private pickHighlighted;
|
|
@@ -106,10 +185,6 @@ export declare class TuiRuntime {
|
|
|
106
185
|
frameText: string;
|
|
107
186
|
};
|
|
108
187
|
setModeTag(tag: string): void;
|
|
109
|
-
/** Reporting is on ONLY while a palette is open. The palette is a modal:
|
|
110
|
-
* while it shows, clicks choose its rows and the wheel drives its
|
|
111
|
-
* selection; drag-select resumes the moment it closes. */
|
|
112
|
-
private syncMouseReporting;
|
|
113
188
|
/** The palette data source: `/model ` opens the model picker, otherwise
|
|
114
189
|
* slash commands. (/resume submits straight through to the driver, which
|
|
115
190
|
* opens the Codex-style full-frame picker - resume-picker.ts.) Rows are
|
|
@@ -134,7 +209,47 @@ export declare class TuiRuntime {
|
|
|
134
209
|
setQueued(n: number): void;
|
|
135
210
|
requestApproval(name: string, args: Record<string, unknown>): Promise<boolean>;
|
|
136
211
|
consumeInput(): string;
|
|
212
|
+
setInput(text: string): void;
|
|
213
|
+
setLastUserText(s: string): void;
|
|
214
|
+
/** Last user-submitted line (Esc-Esc edit-and-fork source, T13). */
|
|
215
|
+
getLastUserText(): string;
|
|
137
216
|
onSubmit(fn: () => void): void;
|
|
217
|
+
onInterrupt(fn: () => void): void;
|
|
218
|
+
onInject(fn: (text: string) => void): void;
|
|
219
|
+
onForkEdit(fn: () => void): void;
|
|
220
|
+
onExternalEdit(fn: (draft: string) => void): void;
|
|
221
|
+
/** M5 B14: apply remapped keys (config.json tui.keymap); unknown actions
|
|
222
|
+
* are ignored so a stale config degrades to defaults, never breaks keys */
|
|
223
|
+
setKeymap(map: Record<string, string>): void;
|
|
224
|
+
/** Close any open modal (Esc priority: panels close before anything else,
|
|
225
|
+
* T7/T9 order). Returns true when something was open. */
|
|
226
|
+
private closeModal;
|
|
227
|
+
/** Ctrl+R: incremental history search modal (B4). Enter adopts the match
|
|
228
|
+
* into the input; Esc closes; ^P/^N or arrows move. */
|
|
229
|
+
private openHistSearch;
|
|
230
|
+
private histKey;
|
|
231
|
+
/** Ctrl+T: full-transcript overlay (B5), also the pager base for long
|
|
232
|
+
* outputs (B9). ↑↓/PgUp/PgDn/g/G scroll, Esc/q closes. */
|
|
233
|
+
private overlaySource;
|
|
234
|
+
setOverlaySource(fn: () => string[]): void;
|
|
235
|
+
private openOverlay;
|
|
236
|
+
/** Public pager/overlay entry (M4 /diff, B9 auto-pager). */
|
|
237
|
+
showOverlay(title: string, lines: string[]): void;
|
|
238
|
+
private toolCells;
|
|
239
|
+
/** Tool call + result as a collapsible cell: one folded summary line by
|
|
240
|
+
* default (W1/T5 spirit); the `z` key (idle + empty input) expands the
|
|
241
|
+
* LAST cell to its full output. */
|
|
242
|
+
addToolCell(folded: string, full: string): void;
|
|
243
|
+
toggleLastCell(): boolean;
|
|
244
|
+
/** Light zero-dep markdown line color for STREAMED text: headings cyan,
|
|
245
|
+
* list markers dim, fences dim, blockquotes dim; everything else plain.
|
|
246
|
+
* Applied per completed line so already-stable rows never reflow. */
|
|
247
|
+
static mdColor(line: string): string;
|
|
248
|
+
private overlayKey;
|
|
249
|
+
/** @-file palette (B2): opens/refreshes from the input's trailing @token. */
|
|
250
|
+
private refreshAtPal;
|
|
251
|
+
private runAtSearch;
|
|
252
|
+
private atPalKey;
|
|
138
253
|
clearScreen(): void;
|
|
139
254
|
private totalLines;
|
|
140
255
|
private onKey;
|