@hmharness/cli 0.14.23 → 0.14.24
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 +32 -1
- package/dist/tui.js +16 -2
- package/dist/update-check.d.ts +20 -0
- package/dist/update-check.js +38 -0
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -1155,7 +1155,38 @@ flags:
|
|
|
1155
1155
|
stdout.write('manifest: ' + mf + '\n');
|
|
1156
1156
|
return;
|
|
1157
1157
|
}
|
|
1158
|
-
|
|
1158
|
+
if (sub === 'train-prep') {
|
|
1159
|
+
// RL next step: materialize the exported pairs into a trainer-ready
|
|
1160
|
+
// directory (LLaMA-Factory layout): split files + dataset_info.json -
|
|
1161
|
+
// fine-tuning stays an EXTERNAL step (GPU trainer), this is the feed
|
|
1162
|
+
const pairsFile = join(home, 'evolution', 'dpo-pairs.jsonl');
|
|
1163
|
+
let rows = [];
|
|
1164
|
+
try {
|
|
1165
|
+
rows = (await readFile(pairsFile, 'utf8')).trim().split('\n').filter(Boolean).map((l) => JSON.parse(l));
|
|
1166
|
+
}
|
|
1167
|
+
catch {
|
|
1168
|
+
stdout.write('no dpo-pairs.jsonl - run: hmh reward export-dpo\n');
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1171
|
+
const outDir = rest[1] ? require('node:path').resolve(rest[1]) : join(home, 'evolution', 'dpo-export');
|
|
1172
|
+
const { mkdir, writeFile: wf2 } = await import('node:fs/promises');
|
|
1173
|
+
await mkdir(outDir, { recursive: true });
|
|
1174
|
+
const train = rows.filter((r) => r.split !== 'eval');
|
|
1175
|
+
const evalR = rows.filter((r) => r.split === 'eval');
|
|
1176
|
+
const slim = (r) => JSON.stringify({ prompt: r.prompt, chosen: r.chosen, rejected: r.rejected });
|
|
1177
|
+
await wf2(join(outDir, 'dpo-train.jsonl'), train.map(slim).join('\n') + (train.length ? '\n' : ''), 'utf8');
|
|
1178
|
+
await wf2(join(outDir, 'dpo-eval.jsonl'), evalR.map(slim).join('\n') + (evalR.length ? '\n' : ''), 'utf8');
|
|
1179
|
+
const info = {
|
|
1180
|
+
'hmh-dpo-train': { file_name: 'dpo-train.jsonl', ranking: true, columns: { prompt: 'prompt', chosen: 'chosen', rejected: 'rejected' } },
|
|
1181
|
+
'hmh-dpo-eval': { file_name: 'dpo-eval.jsonl', ranking: true, columns: { prompt: 'prompt', chosen: 'chosen', rejected: 'rejected' } },
|
|
1182
|
+
};
|
|
1183
|
+
await wf2(join(outDir, 'dataset_info.json'), JSON.stringify(info, null, 2) + '\n', 'utf8');
|
|
1184
|
+
stdout.write('trainer-ready export:\n');
|
|
1185
|
+
stdout.write(' ' + outDir + '\n');
|
|
1186
|
+
stdout.write(' train ' + train.length + ' · eval ' + evalR.length + ' (prompt-grouped split; see docs/rl-training.md)\n');
|
|
1187
|
+
return;
|
|
1188
|
+
}
|
|
1189
|
+
stdout.write('usage: hmh reward fit | report | export-dpo | train-prep [dir]\n');
|
|
1159
1190
|
return;
|
|
1160
1191
|
}
|
|
1161
1192
|
if (cmd === 'dataset') {
|
package/dist/tui.js
CHANGED
|
@@ -1785,10 +1785,24 @@ export async function tui(yes, noWeb = false, opts = {}) {
|
|
|
1785
1785
|
// update reminder: cached (1/day) registry check, resolved async into the
|
|
1786
1786
|
// transcript via addText (frame-safe); offline stays silent
|
|
1787
1787
|
{
|
|
1788
|
-
|
|
1788
|
+
// 2026-09-21 user direction: updates are ZERO-ACTION - a newer version
|
|
1789
|
+
// installs itself in the background (detached npm, next launch picks it
|
|
1790
|
+
// up; never swaps files under the running process) and we only SAY so.
|
|
1791
|
+
// Opt out with config.json tui.autoUpdate=false (falls back to the hint).
|
|
1792
|
+
const { notifyUpdate, autoUpdate } = await import("./update-check.js");
|
|
1789
1793
|
const { createRequire } = await import('node:module');
|
|
1790
1794
|
const current = createRequire(import.meta.url)('../package.json').version;
|
|
1791
|
-
|
|
1795
|
+
if (cfg.tui?.autoUpdate === false) {
|
|
1796
|
+
void notifyUpdate(home, current, (latest) => rt.addText(`↑ ${t.updateHint(latest)}`, 'dim'));
|
|
1797
|
+
}
|
|
1798
|
+
else {
|
|
1799
|
+
void autoUpdate({
|
|
1800
|
+
home,
|
|
1801
|
+
current,
|
|
1802
|
+
say: (latest) => rt.addText(t.tuiAutoUpdating(latest), 'dim'),
|
|
1803
|
+
sayFail: (why) => rt.addText(t.tuiAutoUpdateFailed(why), 'dim'),
|
|
1804
|
+
});
|
|
1805
|
+
}
|
|
1792
1806
|
}
|
|
1793
1807
|
let history = [];
|
|
1794
1808
|
// Codex thread semantics: one rollout file per conversation. The first task
|
package/dist/update-check.d.ts
CHANGED
|
@@ -17,3 +17,23 @@ export declare function checkForUpdate(opts: {
|
|
|
17
17
|
/** Fire-and-forget wrapper for interactive frontends: resolve-and-say, or
|
|
18
18
|
* say nothing at all. Never rejects. */
|
|
19
19
|
export declare function notifyUpdate(home: string, current: string, say: (line: string) => void): Promise<void>;
|
|
20
|
+
/** Background self-update (user direction 2026-09-21: zero-action updates,
|
|
21
|
+
* notify only). NEVER swaps files under the running process - npm runs
|
|
22
|
+
* detached and the new version is picked up on the NEXT launch, so a
|
|
23
|
+
* mid-session install cannot corrupt the live TUI (Windows also locks
|
|
24
|
+
* files in use, and this machine EPERMs on locked writes). A lock file
|
|
25
|
+
* keeps concurrent hmh instances from racing one npm install. */
|
|
26
|
+
export declare function autoUpdate(opts: {
|
|
27
|
+
home: string;
|
|
28
|
+
current: string;
|
|
29
|
+
say: (line: string) => void;
|
|
30
|
+
sayFail?: (line: string) => void;
|
|
31
|
+
spawnImpl?: (cmd: string, args: string[], o: {
|
|
32
|
+
detached: boolean;
|
|
33
|
+
stdio: unknown;
|
|
34
|
+
cwd: string;
|
|
35
|
+
}) => {
|
|
36
|
+
unref: () => void;
|
|
37
|
+
};
|
|
38
|
+
now?: number;
|
|
39
|
+
}): Promise<void>;
|
package/dist/update-check.js
CHANGED
|
@@ -65,3 +65,41 @@ export async function notifyUpdate(home, current, say) {
|
|
|
65
65
|
}
|
|
66
66
|
catch { /* never surface update-check failures */ }
|
|
67
67
|
}
|
|
68
|
+
/** Background self-update (user direction 2026-09-21: zero-action updates,
|
|
69
|
+
* notify only). NEVER swaps files under the running process - npm runs
|
|
70
|
+
* detached and the new version is picked up on the NEXT launch, so a
|
|
71
|
+
* mid-session install cannot corrupt the live TUI (Windows also locks
|
|
72
|
+
* files in use, and this machine EPERMs on locked writes). A lock file
|
|
73
|
+
* keeps concurrent hmh instances from racing one npm install. */
|
|
74
|
+
export async function autoUpdate(opts) {
|
|
75
|
+
try {
|
|
76
|
+
const info = await checkForUpdate({ home: opts.home, current: opts.current, now: opts.now });
|
|
77
|
+
if (!info)
|
|
78
|
+
return;
|
|
79
|
+
const { open } = await import('node:fs/promises');
|
|
80
|
+
const lockFile = join(opts.home, 'updating.lck');
|
|
81
|
+
const now = opts.now ?? Date.now();
|
|
82
|
+
try {
|
|
83
|
+
const prev = JSON.parse(await readFile(lockFile, 'utf8'));
|
|
84
|
+
if (now - prev.time < 10 * 60_000) {
|
|
85
|
+
opts.say?.(info.latest + ' (another hmh is already updating)');
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch { /* no lock */ }
|
|
90
|
+
await mkdir(opts.home, { recursive: true });
|
|
91
|
+
const log = await open(join(opts.home, 'update.log'), 'a');
|
|
92
|
+
const spawnFn = opts.spawnImpl ?? ((await import('node:child_process')).spawn);
|
|
93
|
+
const child = spawnFn('npm', ['install', '-g', '@hmharness/cli@' + info.latest, '--registry=https://registry.npmjs.org/', '--no-fund', '--no-audit'], {
|
|
94
|
+
detached: true,
|
|
95
|
+
stdio: ['ignore', log.fd, log.fd],
|
|
96
|
+
cwd: opts.home,
|
|
97
|
+
});
|
|
98
|
+
child.unref();
|
|
99
|
+
await writeFile(lockFile, JSON.stringify({ time: now, to: info.latest }), 'utf8');
|
|
100
|
+
opts.say(info.latest);
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
opts.sayFail?.(String(err).slice(0, 80));
|
|
104
|
+
}
|
|
105
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cli",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.24",
|
|
4
4
|
"description": "hmharness command line: one-shot tasks, an interactive REPL, a fullscreen TUI, the web frontend, and direct tool invocation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@hmharness/evolution": "0.14.15",
|
|
49
49
|
"@hmharness/domain-harmony": "0.13.6",
|
|
50
50
|
"@hmharness/domain-ops": "0.8.1",
|
|
51
|
-
"@hmharness/agent": "0.14.
|
|
51
|
+
"@hmharness/agent": "0.14.14",
|
|
52
52
|
"@hmharness/evaluation": "0.8.0",
|
|
53
53
|
"@hmharness/web": "0.9.2"
|
|
54
54
|
}
|