@hmharness/cli 0.14.16 → 0.14.17

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 (2) hide show
  1. package/dist/main.js +38 -3
  2. package/package.json +3 -3
package/dist/main.js CHANGED
@@ -1006,6 +1006,30 @@ flags:
1006
1006
  }
1007
1007
  return;
1008
1008
  }
1009
+ if (cmd === 'judge') {
1010
+ // J1: LLM-as-judge session scoring - the scaling replacement for human
1011
+ // star labeling (humans cannot audit 20-turn agent sessions; the judge
1012
+ // route should be a different model family than the actor)
1013
+ await initHome();
1014
+ const home = homeDir();
1015
+ const limit = Math.max(1, Math.min(50, Number(rest[0] ?? 5) || 5));
1016
+ const cfgJ = await loadConfig();
1017
+ const provider = resolveProvider(cfgJ, 'judge');
1018
+ stdout.write('judge model: ' + provider.model + ' @ ' + provider.baseUrl + ' · next ' + limit + ' unlabeled session(s), degraded first\n');
1019
+ const EJ = await import('@hmharness/evolution');
1020
+ const r = await EJ.runJudgeBatch({ home, limit, provider, log: (l) => stdout.write(DIM(l + '\n')) });
1021
+ const by = {};
1022
+ for (const sc of r.scores)
1023
+ by[sc] = (by[sc] || 0) + 1;
1024
+ stdout.write('judged ' + r.labeled + ' (failed/skipped ' + r.failed + ') · score spread ' + JSON.stringify(by) + '\n');
1025
+ if (r.scores.length) {
1026
+ const insightsRows = (await readFile(join(home, 'insights', 'insights.jsonl'), 'utf8').catch(() => '')).trim().split('\n').filter(Boolean).map((l) => JSON.parse(l));
1027
+ const means = EJ.judgeBucketMeans(await EJ.readJudgeLabels(home), insightsRows);
1028
+ stdout.write('sanity: mean score ok-bucket=' + means.ok + ' vs degraded-bucket=' + means.degraded + (means.ok !== null && means.degraded !== null && (means.ok - means.degraded) < 0.3 ? ' ⚠ judge barely separates buckets' : ' ✓ buckets separated') + '\n');
1029
+ }
1030
+ stdout.write(DIM('next: hmh reward export-dpo\n'));
1031
+ return;
1032
+ }
1009
1033
  if (cmd === 'reward') {
1010
1034
  // V3 RL phase (ADR-0010): learned reward model over the human labels
1011
1035
  await initHome();
@@ -1079,18 +1103,29 @@ flags:
1079
1103
  return '';
1080
1104
  }
1081
1105
  };
1082
- const sessions = [...new Set(labels.map((l) => l.session))];
1106
+ const judgeLabels = (await readJsonl(join(home, 'evolution', 'judge-labels.jsonl')));
1107
+ const sources = new Map();
1108
+ for (const l of judgeLabels)
1109
+ if (!sources.has(l.session))
1110
+ sources.set(l.session, 'judge');
1111
+ for (const l of labels)
1112
+ sources.set(l.session, 'human'); // human wins on double-labeled
1113
+ const merged = [...labels, ...judgeLabels.filter((j) => !labels.some((l) => l.session === j.session))];
1114
+ const sessions = [...new Set(merged.map((l) => l.session))];
1083
1115
  const tasks = new Map();
1084
1116
  const answers = new Map();
1085
1117
  for (const s2 of sessions) {
1086
1118
  tasks.set(s2, await taskOf(s2));
1087
1119
  answers.set(s2, await answerOf(s2));
1088
1120
  }
1089
- const pairs = E.exportDpoPairs(labels, insights, (x2) => tasks.get(x2) ?? '', (x2) => answers.get(x2) ?? '');
1121
+ const pairs = E.exportDpoPairs(merged, insights, (x2) => tasks.get(x2) ?? '', (x2) => answers.get(x2) ?? '', { sources });
1090
1122
  const out = join(home, 'evolution', 'dpo-pairs.jsonl');
1091
1123
  const { writeFile: wf } = await import('node:fs/promises');
1092
1124
  await wf(out, pairs.map((p) => JSON.stringify(p)).join('\n') + (pairs.length ? '\n' : ''), 'utf8');
1093
- stdout.write('DPO pairs: ' + pairs.length + ' -> ' + out + '\n');
1125
+ const bySrc = {};
1126
+ for (const p of pairs)
1127
+ bySrc[p.source ?? 'unmarked'] = (bySrc[p.source ?? 'unmarked'] || 0) + 1;
1128
+ stdout.write('DPO pairs: ' + pairs.length + ' ' + JSON.stringify(bySrc) + ' -> ' + out + '\n');
1094
1129
  return;
1095
1130
  }
1096
1131
  stdout.write('usage: hmh reward fit | report | export-dpo\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/cli",
3
- "version": "0.14.16",
3
+ "version": "0.14.17",
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",
@@ -43,9 +43,9 @@
43
43
  "build": "tsc -p tsconfig.build.json"
44
44
  },
45
45
  "dependencies": {
46
- "@hmharness/kernel": "0.9.1",
46
+ "@hmharness/kernel": "0.9.2",
47
47
  "@hmharness/observability": "0.7.0",
48
- "@hmharness/evolution": "0.14.10",
48
+ "@hmharness/evolution": "0.14.11",
49
49
  "@hmharness/domain-harmony": "0.13.5",
50
50
  "@hmharness/domain-ops": "0.8.1",
51
51
  "@hmharness/agent": "0.14.11",