@hmharness/cli 0.18.0 → 0.18.2
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 +35 -38
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -36,16 +36,10 @@ const CYAN = (s) => `\x1b[36m${s}\x1b[0m`;
|
|
|
36
36
|
const YELLOW = (s) => `\x1b[33m${s}\x1b[0m`;
|
|
37
37
|
const GREEN = (s) => `\x1b[32m${s}\x1b[0m`;
|
|
38
38
|
const RED = (s) => `\x1b[31m${s}\x1b[0m`;
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
for (const p of Object.values(cfg.providers ?? {})) {
|
|
44
|
-
if (p.baseUrl?.includes('bigmodel.cn') && p.apiKey)
|
|
45
|
-
return { apiKey: p.apiKey, baseUrl: p.baseUrl, model: p.model };
|
|
46
|
-
}
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
39
|
+
/** Fine-tuning is provider-agnostic (helper deleted 2026-09-25): the
|
|
40
|
+
* auto-finetune command resolves the backend from the user's configured
|
|
41
|
+
* providers via CF.resolveFineTuneBackend - chat route first. Zhipu is one
|
|
42
|
+
* supported dialect, not a design target. */
|
|
49
43
|
async function uiStrings() {
|
|
50
44
|
const cfg = await loadConfig();
|
|
51
45
|
return strings((cfg.locale ?? 'zh'));
|
|
@@ -1025,25 +1019,28 @@ flags:
|
|
|
1025
1019
|
return;
|
|
1026
1020
|
}
|
|
1027
1021
|
if (cmd === 'auto-finetune') {
|
|
1028
|
-
// 2026-09-25: the cloud fine-tuning loop is CLOSED
|
|
1029
|
-
// the accumulated DPO pairs, converts them to the
|
|
1030
|
-
// format and uploads train/validation files (free)
|
|
1031
|
-
// staged for one-command submission. Job creation
|
|
1032
|
-
// --submit. The user never
|
|
1022
|
+
// 2026-09-25: the cloud fine-tuning loop is CLOSED and PROVIDER-AGNOSTIC.
|
|
1023
|
+
// Default run exports the accumulated DPO pairs, converts them to the
|
|
1024
|
+
// matched backend's row format and uploads train/validation files (free)
|
|
1025
|
+
// - everything is then staged for one-command submission. Job creation
|
|
1026
|
+
// is PAID, so it needs --submit. The user never picks a provider, model
|
|
1027
|
+
// or local GPU stack: the chat-route provider is matched against the
|
|
1028
|
+
// backend registry automatically (Zhipu is one dialect, not the design).
|
|
1033
1029
|
await initHome();
|
|
1034
1030
|
const home = homeDir();
|
|
1035
1031
|
const CF = await import('@hmharness/evolution');
|
|
1036
1032
|
const flag = (name) => (rest.find((a) => a.startsWith(`--${name}=`)) ?? '').split('=').slice(1).join('=');
|
|
1033
|
+
const supportedList = CF.FINE_TUNE_BACKENDS.map((b) => b.label).join('、');
|
|
1034
|
+
const cfgFT = await loadConfig();
|
|
1035
|
+
const ft = CF.resolveFineTuneBackend(cfgFT.providers, cfgFT.routing?.chat);
|
|
1037
1036
|
if (rest.includes('--status')) {
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
if (!zp) {
|
|
1041
|
-
stdout.write(RED('未找到智谱 provider(config.json providers 中需有 baseUrl 含 bigmodel.cn 的条目,如 glm)\n'));
|
|
1037
|
+
if (!ft) {
|
|
1038
|
+
stdout.write('云端微调:你当前配置的模型供应商暂不支持微调(已支持:' + supportedList + ')。其余功能不受影响。\n');
|
|
1042
1039
|
return;
|
|
1043
1040
|
}
|
|
1044
|
-
const jobs = await CF.listFineTuneJobs({ apiKey:
|
|
1041
|
+
const jobs = await CF.listFineTuneJobs({ backend: ft.backend, apiKey: ft.apiKey, baseUrl: ft.baseUrl, limit: 10 });
|
|
1045
1042
|
const local = await CF.readLocalFineTuneJobs(home);
|
|
1046
|
-
stdout.write('
|
|
1043
|
+
stdout.write('云端微调任务(' + ft.backend.label + ',最近 ' + jobs.length + ' 条):\n');
|
|
1047
1044
|
for (const j of jobs)
|
|
1048
1045
|
stdout.write(' ' + (j.id ?? '?').padEnd(38) + ' ' + String(j.status ?? '?').padEnd(12) + ' ' + String(j.model ?? '') + (j.fine_tuned_model ? ' → ' + j.fine_tuned_model : '') + '\n');
|
|
1049
1046
|
if (local.length) {
|
|
@@ -1055,13 +1052,13 @@ flags:
|
|
|
1055
1052
|
stdout.write('(还没有任何微调任务)\n');
|
|
1056
1053
|
return;
|
|
1057
1054
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
stdout.write(RED('未找到智谱 provider:请在 config.json 的 providers 里配置 glm(baseUrl 含 bigmodel.cn)。只需这一个密钥。\n'));
|
|
1055
|
+
if (!ft) {
|
|
1056
|
+
// a clean STATUS, never an error: unsupported provider is normal life
|
|
1057
|
+
stdout.write('云端微调暂未对你当前配置的模型供应商开放(已支持:' + supportedList + ')。\n');
|
|
1058
|
+
stdout.write(DIM('继续正常使用即可——评审、进化等其他能力照常工作;后续版本会接入更多微调后端。\n'));
|
|
1063
1059
|
return;
|
|
1064
1060
|
}
|
|
1061
|
+
stdout.write('微调后端:' + ft.backend.label + '(provider ' + ft.providerName + ')\n');
|
|
1065
1062
|
// unattended safety rails (2026-09-25 "configure one key, forget it"):
|
|
1066
1063
|
// kill-switch finetune.auto=false, at most one active cloud job, and a
|
|
1067
1064
|
// cooldown between submissions - the daemon calls this same command, so
|
|
@@ -1083,7 +1080,7 @@ flags:
|
|
|
1083
1080
|
return;
|
|
1084
1081
|
}
|
|
1085
1082
|
try {
|
|
1086
|
-
const running = (await CF.listFineTuneJobs({ apiKey:
|
|
1083
|
+
const running = (await CF.listFineTuneJobs({ backend: ft.backend, apiKey: ft.apiKey, baseUrl: ft.baseUrl, limit: 20 }))
|
|
1087
1084
|
.some((j) => ['queued', 'running', 'pending', 'training'].includes(String(j.status ?? '').toLowerCase()));
|
|
1088
1085
|
if (running) {
|
|
1089
1086
|
stdout.write(DIM('云端已有进行中的微调任务——本次跳过\n'));
|
|
@@ -1093,8 +1090,8 @@ flags:
|
|
|
1093
1090
|
catch { /* status check failed - fail open to the gates below */ }
|
|
1094
1091
|
}
|
|
1095
1092
|
// 2026-09-25 user call: novices never pick a fine-tune base. Try the
|
|
1096
|
-
// user's MAIN model first (glm-5.3
|
|
1097
|
-
// silently fall down the
|
|
1093
|
+
// user's MAIN model first (on this account glm-5.3 answers 微调功能未开放),
|
|
1094
|
+
// then silently fall down the backend's ladder. --model= stays as override.
|
|
1098
1095
|
const forced = flag('model');
|
|
1099
1096
|
let model;
|
|
1100
1097
|
if (forced) {
|
|
@@ -1103,10 +1100,10 @@ flags:
|
|
|
1103
1100
|
}
|
|
1104
1101
|
else {
|
|
1105
1102
|
model = await CF.pickFineTuneModel({
|
|
1106
|
-
apiKey:
|
|
1103
|
+
backend: ft.backend, apiKey: ft.apiKey, baseUrl: ft.baseUrl, mainModel: ft.model,
|
|
1107
1104
|
log: (l) => stdout.write(DIM(l + '\n')),
|
|
1108
1105
|
});
|
|
1109
|
-
stdout.write('云端微调模型:' + model + (model !==
|
|
1106
|
+
stdout.write('云端微调模型:' + model + (model !== ft.model ? DIM('(主模型 ' + ft.model + ' 暂不可微调,已自动改用)') : '') + '\n');
|
|
1110
1107
|
}
|
|
1111
1108
|
// labels gate (same as before)
|
|
1112
1109
|
const judgeLabels = await CF.readJudgeLabels(home);
|
|
@@ -1137,20 +1134,20 @@ flags:
|
|
|
1137
1134
|
return;
|
|
1138
1135
|
}
|
|
1139
1136
|
const trainRows = rows.filter((r) => r.split !== 'eval').slice(0, maxPairs);
|
|
1140
|
-
const evalRows = rows.filter((r) => r.split === 'eval');
|
|
1141
|
-
stdout.write('偏好对:' + rows.length + (trainRows.length < rows.filter((r) => r.split !== 'eval').length ? DIM('(本次训练用前 ' + maxPairs + ' 条控制成本)') : '') + '(train ' + trainRows.length + ' / eval ' + evalRows.length + ')\n');
|
|
1142
|
-
const trainJsonl =
|
|
1143
|
-
const evalJsonl =
|
|
1137
|
+
const evalRows = rows.filter((r) => r.split === 'eval').slice(0, 1000); // validation loss needs a sample, not the whole set
|
|
1138
|
+
stdout.write('偏好对:' + rows.length + (trainRows.length < rows.filter((r) => r.split !== 'eval').length ? DIM('(本次训练用前 ' + maxPairs + ' 条控制成本)') : '') + '(train ' + trainRows.length + ' / eval ' + evalRows.length + (evalRows.length < rows.filter((r) => r.split === 'eval').length ? DIM('(抽样 1000)') : '') + ')\n');
|
|
1139
|
+
const trainJsonl = ft.backend.dpoJsonl(trainRows);
|
|
1140
|
+
const evalJsonl = ft.backend.dpoJsonl(evalRows);
|
|
1144
1141
|
stdout.write('本地预估 token:train ~' + CF.estimateTokens(trainJsonl).toLocaleString() + ' / eval ~' + CF.estimateTokens(evalJsonl).toLocaleString() + DIM('(上传后以官方分词统计为准)') + '\n');
|
|
1145
1142
|
// upload (free) - provider token stats come back exact
|
|
1146
1143
|
const stamp = new Date().toISOString().slice(0, 10).replaceAll('-', '');
|
|
1147
1144
|
let upTrain;
|
|
1148
1145
|
let upEval = null;
|
|
1149
1146
|
try {
|
|
1150
|
-
upTrain = await CF.uploadFineTuneFile({ apiKey:
|
|
1147
|
+
upTrain = await CF.uploadFineTuneFile({ backend: ft.backend, apiKey: ft.apiKey, baseUrl: ft.baseUrl, filename: `hmh-dpo-train-${stamp}.jsonl`, jsonl: trainJsonl });
|
|
1151
1148
|
stdout.write(GREEN('✓') + ' 训练文件已上传:' + upTrain.id + '(' + upTrain.samples + ' 样本,官方统计 ' + upTrain.tokens.toLocaleString() + ' tokens)\n');
|
|
1152
1149
|
if (evalRows.length) {
|
|
1153
|
-
upEval = await CF.uploadFineTuneFile({ apiKey:
|
|
1150
|
+
upEval = await CF.uploadFineTuneFile({ backend: ft.backend, apiKey: ft.apiKey, baseUrl: ft.baseUrl, filename: `hmh-dpo-eval-${stamp}.jsonl`, jsonl: evalJsonl });
|
|
1154
1151
|
stdout.write(GREEN('✓') + ' 验证文件已上传:' + upEval.id + '(' + upEval.samples + ' 样本)\n');
|
|
1155
1152
|
}
|
|
1156
1153
|
}
|
|
@@ -1168,7 +1165,7 @@ flags:
|
|
|
1168
1165
|
// PAID step - explicit --submit only
|
|
1169
1166
|
try {
|
|
1170
1167
|
const job = await CF.createFineTuneJob({
|
|
1171
|
-
apiKey:
|
|
1168
|
+
backend: ft.backend, apiKey: ft.apiKey, baseUrl: ft.baseUrl, model,
|
|
1172
1169
|
trainingFile: upTrain.id, validationFile: upEval?.id, suffix: 'hmh',
|
|
1173
1170
|
});
|
|
1174
1171
|
await CF.recordFineTuneJob(home, job, { model, trainFile: upTrain.id, evalFile: upEval?.id, pairs: rows.length });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmharness/cli",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.2",
|
|
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",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@hmharness/kernel": "0.9.6",
|
|
47
47
|
"@hmharness/observability": "0.7.4",
|
|
48
|
-
"@hmharness/evolution": "0.14.
|
|
48
|
+
"@hmharness/evolution": "0.14.25",
|
|
49
49
|
"@hmharness/domain-harmony": "0.13.8",
|
|
50
50
|
"@hmharness/domain-ops": "0.8.3",
|
|
51
51
|
"@hmharness/agent": "0.14.18",
|