@hcmai/cli 0.4.16 → 0.4.18
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/index.js +522 -191
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +19 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1839,7 +1839,7 @@ __export(run_exports, {
|
|
|
1839
1839
|
});
|
|
1840
1840
|
import React3 from "react";
|
|
1841
1841
|
import { render } from "ink";
|
|
1842
|
-
import { HcmClient as
|
|
1842
|
+
import { HcmClient as HcmClient10, WsClient, DEFAULT_AGENT_ID as DEFAULT_AGENT_ID2 } from "@hcmai/sdk";
|
|
1843
1843
|
async function runInkRepl(args) {
|
|
1844
1844
|
if (process.stdout.isTTY) {
|
|
1845
1845
|
process.stdout.write("\x1B[>4;1m");
|
|
@@ -1847,7 +1847,7 @@ async function runInkRepl(args) {
|
|
|
1847
1847
|
}
|
|
1848
1848
|
try {
|
|
1849
1849
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
1850
|
-
const client3 =
|
|
1850
|
+
const client3 = HcmClient10.fromAuthContext(ctx);
|
|
1851
1851
|
const ws = new WsClient({
|
|
1852
1852
|
endpoint: ctx.endpoint.replace(/^http/, "ws") + "/ws/conversation",
|
|
1853
1853
|
getAccessToken: () => client3.getAccessToken(),
|
|
@@ -2286,9 +2286,9 @@ async function loginCommand(args) {
|
|
|
2286
2286
|
} catch (e) {
|
|
2287
2287
|
const err = e;
|
|
2288
2288
|
if (err.isAxiosError) {
|
|
2289
|
-
const { fromAxiosError:
|
|
2289
|
+
const { fromAxiosError: fromAxiosError24 } = await import("@hcmai/sdk");
|
|
2290
2290
|
exitWithError(
|
|
2291
|
-
|
|
2291
|
+
fromAxiosError24(
|
|
2292
2292
|
e,
|
|
2293
2293
|
envName
|
|
2294
2294
|
)
|
|
@@ -3104,22 +3104,124 @@ async function upgradeCommand(args) {
|
|
|
3104
3104
|
process.exit(args.check && latest !== null && latest !== CLI_VERSION ? 1 : 0);
|
|
3105
3105
|
}
|
|
3106
3106
|
|
|
3107
|
+
// src/commands/open.ts
|
|
3108
|
+
init_auth_guard();
|
|
3109
|
+
init_exit();
|
|
3110
|
+
import { spawn } from "child_process";
|
|
3111
|
+
import { CliError as CliError12, CliErrorCode as CliErrorCode11, fromAxiosError as fromAxiosError7, HcmClient as HcmClient6, loadEnv as loadEnv5 } from "@hcmai/sdk";
|
|
3112
|
+
var BROWSER_TICKET_PATH = "/api/auth/browser-ticket";
|
|
3113
|
+
var SSO_CALLBACK_PATH = "/sso/callback";
|
|
3114
|
+
function normalizeTarget(target) {
|
|
3115
|
+
const raw = (target ?? "").trim();
|
|
3116
|
+
if (!raw) return "/";
|
|
3117
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(raw)) {
|
|
3118
|
+
throw new CliError12({
|
|
3119
|
+
code: CliErrorCode11.INVALID_ARGUMENT,
|
|
3120
|
+
message: `\u53EA\u6536\u7AD9\u5185\u8DEF\u5F84\uFF08\u5982 /dashboard/<id>\uFF09\uFF0C\u4E0D\u6536\u5B8C\u6574 URL\uFF1A${raw}`
|
|
3121
|
+
});
|
|
3122
|
+
}
|
|
3123
|
+
return raw.startsWith("/") ? raw : `/${raw}`;
|
|
3124
|
+
}
|
|
3125
|
+
function buildBrowserLoginUrl(frontend, ticket, target) {
|
|
3126
|
+
const base = frontend.trim().replace(/\/+$/, "");
|
|
3127
|
+
const query = new URLSearchParams({ ticket, redirect: normalizeTarget(target) });
|
|
3128
|
+
return `${base}${SSO_CALLBACK_PATH}?${query.toString()}`;
|
|
3129
|
+
}
|
|
3130
|
+
function launcherFor(platform, url) {
|
|
3131
|
+
if (platform === "darwin") return { cmd: "open", args: [url] };
|
|
3132
|
+
if (platform === "win32") return { cmd: "cmd", args: ["/c", "start", "", url] };
|
|
3133
|
+
return { cmd: "xdg-open", args: [url] };
|
|
3134
|
+
}
|
|
3135
|
+
function launchBrowser(url, platform = process.platform) {
|
|
3136
|
+
const { cmd, args } = launcherFor(platform, url);
|
|
3137
|
+
const child = spawn(cmd, args, { detached: true, stdio: "ignore" });
|
|
3138
|
+
child.on("error", () => {
|
|
3139
|
+
});
|
|
3140
|
+
child.unref();
|
|
3141
|
+
}
|
|
3142
|
+
async function runOpen(target, args, deps) {
|
|
3143
|
+
const path12 = normalizeTarget(target);
|
|
3144
|
+
if (!deps.frontend?.trim()) {
|
|
3145
|
+
throw new CliError12({
|
|
3146
|
+
code: CliErrorCode11.INVALID_ARGUMENT,
|
|
3147
|
+
message: `env '${args.envName}' \u6CA1\u914D\u524D\u7AEF\u5730\u5740\uFF0C\u5F00\u4E0D\u4E86\u9875\u9762\u3002\u5148\u8DD1\uFF1Ahcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${args.envName}`
|
|
3148
|
+
});
|
|
3149
|
+
}
|
|
3150
|
+
const { ticket, expiresIn } = await deps.mintTicket();
|
|
3151
|
+
const url = buildBrowserLoginUrl(deps.frontend, ticket, path12);
|
|
3152
|
+
if (args.printUrl) {
|
|
3153
|
+
deps.write(`${url}
|
|
3154
|
+
`);
|
|
3155
|
+
} else {
|
|
3156
|
+
deps.launch(url);
|
|
3157
|
+
deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${path12}\uFF08\u7968\u636E ${expiresIn ?? 60}s \u5185\u6709\u6548\uFF0C\u53EA\u80FD\u7528\u4E00\u6B21\uFF09
|
|
3158
|
+
`);
|
|
3159
|
+
}
|
|
3160
|
+
return { url, expiresIn };
|
|
3161
|
+
}
|
|
3162
|
+
async function openCommand(target, args) {
|
|
3163
|
+
try {
|
|
3164
|
+
const ctx = await getActiveAuthContextFromCli(args);
|
|
3165
|
+
const envCfg = await loadEnv5(ctx.env);
|
|
3166
|
+
const client3 = HcmClient6.fromAuthContext(ctx);
|
|
3167
|
+
await runOpen(
|
|
3168
|
+
target,
|
|
3169
|
+
{ printUrl: args.printUrl, envName: ctx.env },
|
|
3170
|
+
{
|
|
3171
|
+
frontend: envCfg.frontend,
|
|
3172
|
+
mintTicket: async () => {
|
|
3173
|
+
let data;
|
|
3174
|
+
try {
|
|
3175
|
+
const resp = await client3.raw().post(BROWSER_TICKET_PATH, {});
|
|
3176
|
+
data = resp.data?.data ?? resp.data ?? {};
|
|
3177
|
+
} catch (e) {
|
|
3178
|
+
const err = e;
|
|
3179
|
+
if (err?.isAxiosError && err.response?.status === 404) {
|
|
3180
|
+
throw new CliError12({
|
|
3181
|
+
code: CliErrorCode11.INVALID_ARGUMENT,
|
|
3182
|
+
message: `\u540E\u7AEF\u6CA1\u6709 ${BROWSER_TICKET_PATH}\uFF08\u9700\u8981\u542B\u6D4F\u89C8\u5668\u4F1A\u8BDD\u7968\u636E\u7684\u540E\u7AEF\u7248\u672C\uFF09\uFF0C\u5347\u7EA7\u540E\u7AEF\u540E\u518D\u8BD5\u3002\u672C\u547D\u4EE4\u4E0D\u4F1A\u628A\u4F1A\u8BDD token \u62FC\u8FDB URL \u515C\u5E95\u3002`
|
|
3183
|
+
});
|
|
3184
|
+
}
|
|
3185
|
+
if (err?.isAxiosError) throw fromAxiosError7(err, ctx.env);
|
|
3186
|
+
throw e;
|
|
3187
|
+
}
|
|
3188
|
+
if (typeof data.ticket !== "string" || !data.ticket) {
|
|
3189
|
+
throw new CliError12({
|
|
3190
|
+
code: CliErrorCode11.INVALID_ARGUMENT,
|
|
3191
|
+
message: "\u94F8\u7968\u54CD\u5E94\u91CC\u6CA1\u6709 ticket \u2014\u2014 \u540E\u7AEF\u7248\u672C\u4E0E\u672C CLI \u7684\u5951\u7EA6\u5BF9\u4E0D\u4E0A"
|
|
3192
|
+
});
|
|
3193
|
+
}
|
|
3194
|
+
return {
|
|
3195
|
+
ticket: data.ticket,
|
|
3196
|
+
expiresIn: typeof data.expiresIn === "number" ? data.expiresIn : void 0
|
|
3197
|
+
};
|
|
3198
|
+
},
|
|
3199
|
+
launch: launchBrowser,
|
|
3200
|
+
write: (line) => process.stdout.write(line)
|
|
3201
|
+
}
|
|
3202
|
+
);
|
|
3203
|
+
process.exit(0);
|
|
3204
|
+
} catch (e) {
|
|
3205
|
+
exitWithError(e);
|
|
3206
|
+
}
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3107
3209
|
// src/commands/delete.ts
|
|
3108
3210
|
init_auth_guard();
|
|
3109
3211
|
init_exit();
|
|
3110
3212
|
import {
|
|
3111
|
-
HcmClient as
|
|
3213
|
+
HcmClient as HcmClient7,
|
|
3112
3214
|
formatObject as formatObject6,
|
|
3113
|
-
fromAxiosError as
|
|
3114
|
-
CliError as
|
|
3115
|
-
CliErrorCode as
|
|
3215
|
+
fromAxiosError as fromAxiosError8,
|
|
3216
|
+
CliError as CliError13,
|
|
3217
|
+
CliErrorCode as CliErrorCode12
|
|
3116
3218
|
} from "@hcmai/sdk";
|
|
3117
3219
|
async function deleteCommand(model, args) {
|
|
3118
3220
|
try {
|
|
3119
3221
|
if (!args.id) {
|
|
3120
|
-
throw new
|
|
3222
|
+
throw new CliError13({ code: CliErrorCode12.MISSING_FLAG, message: "--id <id> \u5FC5\u586B" });
|
|
3121
3223
|
}
|
|
3122
|
-
const client3 =
|
|
3224
|
+
const client3 = HcmClient7.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
3123
3225
|
const res = await client3.remove(model, args.id);
|
|
3124
3226
|
const fmt = args.output ?? "json";
|
|
3125
3227
|
if (fmt !== "json") process.stdout.write("\u2705 deleted\n");
|
|
@@ -3127,7 +3229,7 @@ async function deleteCommand(model, args) {
|
|
|
3127
3229
|
process.exit(0);
|
|
3128
3230
|
} catch (e) {
|
|
3129
3231
|
const err = e;
|
|
3130
|
-
if (err?.isAxiosError) exitWithError(
|
|
3232
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError8(err, args.profile));
|
|
3131
3233
|
exitWithError(e);
|
|
3132
3234
|
}
|
|
3133
3235
|
}
|
|
@@ -3138,11 +3240,11 @@ init_auth_guard();
|
|
|
3138
3240
|
import { readFileSync as readFileSync2, readdirSync, statSync, writeFileSync } from "fs";
|
|
3139
3241
|
import { join, relative } from "path";
|
|
3140
3242
|
import {
|
|
3141
|
-
HcmClient as
|
|
3243
|
+
HcmClient as HcmClient8,
|
|
3142
3244
|
parseFixture,
|
|
3143
3245
|
runImport,
|
|
3144
3246
|
formatObject as formatObject7,
|
|
3145
|
-
fromAxiosError as
|
|
3247
|
+
fromAxiosError as fromAxiosError9
|
|
3146
3248
|
} from "@hcmai/sdk";
|
|
3147
3249
|
function collectYmlFiles(path12) {
|
|
3148
3250
|
if (statSync(path12).isFile()) return [path12];
|
|
@@ -3173,7 +3275,7 @@ async function importCommand(path12, args) {
|
|
|
3173
3275
|
updateOnly: !!args.updateOnly,
|
|
3174
3276
|
onError: args.onError === "stop" ? "stop" : "continue"
|
|
3175
3277
|
};
|
|
3176
|
-
const client3 = opts.dryRun ? DRY_RUN_CLIENT :
|
|
3278
|
+
const client3 = opts.dryRun ? DRY_RUN_CLIENT : HcmClient8.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
3177
3279
|
const result = await runImport(client3, fixtures, opts);
|
|
3178
3280
|
if (args.report) writeFileSync(args.report, JSON.stringify(result, null, 2));
|
|
3179
3281
|
const fmt = args.output ?? "json";
|
|
@@ -3186,7 +3288,7 @@ async function importCommand(path12, args) {
|
|
|
3186
3288
|
process.exit(result.failed > 0 ? 3 : 0);
|
|
3187
3289
|
} catch (e) {
|
|
3188
3290
|
const err = e;
|
|
3189
|
-
if (err?.isAxiosError) exitWithError(
|
|
3291
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError9(err, args.profile));
|
|
3190
3292
|
exitWithError(e);
|
|
3191
3293
|
}
|
|
3192
3294
|
}
|
|
@@ -3195,13 +3297,13 @@ async function importCommand(path12, args) {
|
|
|
3195
3297
|
init_exit();
|
|
3196
3298
|
init_auth_guard();
|
|
3197
3299
|
import {
|
|
3198
|
-
HcmClient as
|
|
3300
|
+
HcmClient as HcmClient9,
|
|
3199
3301
|
formatObject as formatObject8,
|
|
3200
|
-
fromAxiosError as
|
|
3302
|
+
fromAxiosError as fromAxiosError10
|
|
3201
3303
|
} from "@hcmai/sdk";
|
|
3202
3304
|
async function describeCommand(model, args) {
|
|
3203
3305
|
try {
|
|
3204
|
-
const client3 =
|
|
3306
|
+
const client3 = HcmClient9.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
3205
3307
|
const desc = await client3.describe(model, { verbose: !!args.verbose });
|
|
3206
3308
|
const fmt = args.output ?? "table";
|
|
3207
3309
|
if (fmt !== "table") {
|
|
@@ -3213,7 +3315,7 @@ async function describeCommand(model, args) {
|
|
|
3213
3315
|
} catch (e) {
|
|
3214
3316
|
const err = e;
|
|
3215
3317
|
if (err?.isAxiosError) {
|
|
3216
|
-
exitWithError(
|
|
3318
|
+
exitWithError(fromAxiosError10(err, args.profile));
|
|
3217
3319
|
}
|
|
3218
3320
|
exitWithError(e);
|
|
3219
3321
|
}
|
|
@@ -3253,7 +3355,7 @@ function formatDescriptionTable(desc, verbose = false) {
|
|
|
3253
3355
|
init_exit();
|
|
3254
3356
|
init_auth_guard();
|
|
3255
3357
|
import {
|
|
3256
|
-
HcmClient as
|
|
3358
|
+
HcmClient as HcmClient11,
|
|
3257
3359
|
WsClient as WsClient2,
|
|
3258
3360
|
oneShot,
|
|
3259
3361
|
sendMessageAndStream as sendMessageAndStream2,
|
|
@@ -3266,8 +3368,8 @@ import {
|
|
|
3266
3368
|
fetchConversationTimelineStrict,
|
|
3267
3369
|
fetchRecentConversations,
|
|
3268
3370
|
findLastAssistantSeq,
|
|
3269
|
-
CliError as
|
|
3270
|
-
CliErrorCode as
|
|
3371
|
+
CliError as CliError14,
|
|
3372
|
+
CliErrorCode as CliErrorCode13,
|
|
3271
3373
|
parseInteractionRequest as parseInteractionRequest2,
|
|
3272
3374
|
parseInteractionResolved as parseInteractionResolved2,
|
|
3273
3375
|
buildConfirm as buildConfirm2,
|
|
@@ -3280,8 +3382,8 @@ import chalk2 from "chalk";
|
|
|
3280
3382
|
import * as fs4 from "fs/promises";
|
|
3281
3383
|
function parseInjectOn(s) {
|
|
3282
3384
|
const fail6 = (detail) => {
|
|
3283
|
-
throw new
|
|
3284
|
-
code:
|
|
3385
|
+
throw new CliError14({
|
|
3386
|
+
code: CliErrorCode13.INVALID_ARGUMENT,
|
|
3285
3387
|
message: `--inject-on \u683C\u5F0F <eventType>:<action>[:<arg>]\uFF0Caction \u2208 {interrupt, steer}\uFF08steer \u5FC5\u987B\u5E26 content\uFF09\uFF1B${detail}\uFF0C\u6536\u5230 "${s}"`
|
|
3286
3388
|
});
|
|
3287
3389
|
};
|
|
@@ -3307,21 +3409,21 @@ function parseOnConfirm(s) {
|
|
|
3307
3409
|
if (s === "approve") return { decision: "approve" };
|
|
3308
3410
|
if (s === "reject") return { decision: "reject" };
|
|
3309
3411
|
if (s.startsWith("reject:")) return { decision: "reject", reason: s.slice("reject:".length) };
|
|
3310
|
-
throw new
|
|
3311
|
-
code:
|
|
3412
|
+
throw new CliError14({
|
|
3413
|
+
code: CliErrorCode13.INVALID_ARGUMENT,
|
|
3312
3414
|
message: `--on-confirm \u53D6\u503C approve | reject | reject:<reason>\uFF0C\u6536\u5230 "${s}"`
|
|
3313
3415
|
});
|
|
3314
3416
|
}
|
|
3315
3417
|
function resolveResumeConversation(args) {
|
|
3316
3418
|
if (args.resume && args.conversation) {
|
|
3317
|
-
throw new
|
|
3318
|
-
code:
|
|
3419
|
+
throw new CliError14({
|
|
3420
|
+
code: CliErrorCode13.INVALID_ARGUMENT,
|
|
3319
3421
|
message: "--resume \u548C --conversation \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528\uFF1B\u65B0\u547D\u4EE4\u8BF7\u7528 --resume <conversationId>"
|
|
3320
3422
|
});
|
|
3321
3423
|
}
|
|
3322
3424
|
if (args.resume === "NEW") {
|
|
3323
|
-
throw new
|
|
3324
|
-
code:
|
|
3425
|
+
throw new CliError14({
|
|
3426
|
+
code: CliErrorCode13.INVALID_ARGUMENT,
|
|
3325
3427
|
message: "--resume \u9700\u8981\u65E2\u5B58 conversationId\uFF1B\u65B0\u4F1A\u8BDD\u8BF7\u76F4\u63A5\u7701\u7565 --resume"
|
|
3326
3428
|
});
|
|
3327
3429
|
}
|
|
@@ -3332,8 +3434,8 @@ function resolveResumeConversation(args) {
|
|
|
3332
3434
|
function parsePositiveInt(value, fallback, flag) {
|
|
3333
3435
|
const n = Number(value ?? fallback);
|
|
3334
3436
|
if (!Number.isInteger(n) || n <= 0) {
|
|
3335
|
-
throw new
|
|
3336
|
-
code:
|
|
3437
|
+
throw new CliError14({
|
|
3438
|
+
code: CliErrorCode13.INVALID_ARGUMENT,
|
|
3337
3439
|
message: `${flag} \u9700\u8981\u6B63\u6574\u6570\uFF0C\u6536\u5230 "${value}"`
|
|
3338
3440
|
});
|
|
3339
3441
|
}
|
|
@@ -3356,21 +3458,21 @@ function resolveEventsConversation(args) {
|
|
|
3356
3458
|
const resumeConversationId = resolveResumeConversation(args);
|
|
3357
3459
|
const eventConversationId = typeof args.events === "string" ? args.events.trim() : void 0;
|
|
3358
3460
|
if (eventConversationId === "NEW") {
|
|
3359
|
-
throw new
|
|
3360
|
-
code:
|
|
3461
|
+
throw new CliError14({
|
|
3462
|
+
code: CliErrorCode13.INVALID_ARGUMENT,
|
|
3361
3463
|
message: "--events \u9700\u8981\u65E2\u5B58 conversationId\uFF1B\u65B0\u4F1A\u8BDD\u6CA1\u6709\u53EF\u67E5\u8BE2\u7684\u4E8B\u4EF6\u6D41"
|
|
3362
3464
|
});
|
|
3363
3465
|
}
|
|
3364
3466
|
if (eventConversationId && resumeConversationId && eventConversationId !== resumeConversationId) {
|
|
3365
|
-
throw new
|
|
3366
|
-
code:
|
|
3467
|
+
throw new CliError14({
|
|
3468
|
+
code: CliErrorCode13.INVALID_ARGUMENT,
|
|
3367
3469
|
message: "--events <conversationId> \u4E0E --resume/--conversation \u6307\u5411\u4E0D\u540C\u4F1A\u8BDD\uFF1B\u8BF7\u53EA\u4FDD\u7559\u4E00\u4E2A id"
|
|
3368
3470
|
});
|
|
3369
3471
|
}
|
|
3370
3472
|
const id = eventConversationId || resumeConversationId;
|
|
3371
3473
|
if (!id) {
|
|
3372
|
-
throw new
|
|
3373
|
-
code:
|
|
3474
|
+
throw new CliError14({
|
|
3475
|
+
code: CliErrorCode13.INVALID_ARGUMENT,
|
|
3374
3476
|
message: "\u67E5\u8BE2\u4E8B\u4EF6\u6D41\u8BF7\u4F20 `hcm chat --events <conversationId>`\uFF0C\u6216 `hcm chat --resume <conversationId> --events`"
|
|
3375
3477
|
});
|
|
3376
3478
|
}
|
|
@@ -3436,7 +3538,7 @@ function eventPreview(value) {
|
|
|
3436
3538
|
}
|
|
3437
3539
|
async function printConversationEvents(conversationId, args) {
|
|
3438
3540
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
3439
|
-
const client3 =
|
|
3541
|
+
const client3 = HcmClient11.fromAuthContext(ctx);
|
|
3440
3542
|
const items = await fetchConversationTimelineStrict(client3.raw(), conversationId);
|
|
3441
3543
|
const fmt = args.output ?? "text";
|
|
3442
3544
|
if (args.raw) {
|
|
@@ -3474,13 +3576,13 @@ async function printConversationEvents(conversationId, args) {
|
|
|
3474
3576
|
}
|
|
3475
3577
|
async function printConversationList(args) {
|
|
3476
3578
|
if (args.events || args.resume || args.conversation || args.regenerateFrom || args.promptFile) {
|
|
3477
|
-
throw new
|
|
3478
|
-
code:
|
|
3579
|
+
throw new CliError14({
|
|
3580
|
+
code: CliErrorCode13.INVALID_ARGUMENT,
|
|
3479
3581
|
message: "--list \u53EA\u7528\u4E8E\u5217\u4F1A\u8BDD\uFF1B\u4E0D\u8981\u540C\u65F6\u4F20 --events/--resume/--conversation/--regenerate-from/--prompt-file"
|
|
3480
3582
|
});
|
|
3481
3583
|
}
|
|
3482
3584
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
3483
|
-
const client3 =
|
|
3585
|
+
const client3 = HcmClient11.fromAuthContext(ctx);
|
|
3484
3586
|
const limit = parsePositiveInt(args.limit, 10, "--limit");
|
|
3485
3587
|
const result = await fetchRecentConversations(client3.raw(), limit);
|
|
3486
3588
|
const fmt = args.output ?? "text";
|
|
@@ -3505,8 +3607,8 @@ async function chatCommand(prompt, args) {
|
|
|
3505
3607
|
try {
|
|
3506
3608
|
if (args.list) {
|
|
3507
3609
|
if (prompt) {
|
|
3508
|
-
throw new
|
|
3509
|
-
code:
|
|
3610
|
+
throw new CliError14({
|
|
3611
|
+
code: CliErrorCode13.INVALID_ARGUMENT,
|
|
3510
3612
|
message: "--list \u4E0D\u63A5\u53D7 prompt\uFF1B\u7528 `hcm chat --list` \u67E5\u770B\u6700\u8FD1\u4F1A\u8BDD"
|
|
3511
3613
|
});
|
|
3512
3614
|
}
|
|
@@ -3516,8 +3618,8 @@ async function chatCommand(prompt, args) {
|
|
|
3516
3618
|
const eventsConversationId = resolveEventsConversation(args);
|
|
3517
3619
|
if (eventsConversationId) {
|
|
3518
3620
|
if (prompt || args.promptFile || args.regenerateFrom || args.attach?.length) {
|
|
3519
|
-
throw new
|
|
3520
|
-
code:
|
|
3621
|
+
throw new CliError14({
|
|
3622
|
+
code: CliErrorCode13.INVALID_ARGUMENT,
|
|
3521
3623
|
message: "--events \u662F\u53EA\u8BFB\u67E5\u8BE2\uFF1B\u4E0D\u8981\u540C\u65F6\u4F20 prompt/--prompt-file/--regenerate-from/--attach"
|
|
3522
3624
|
});
|
|
3523
3625
|
}
|
|
@@ -3534,15 +3636,15 @@ async function chatCommand(prompt, args) {
|
|
|
3534
3636
|
} else {
|
|
3535
3637
|
regenerateFromSeq = Number(args.regenerateFrom);
|
|
3536
3638
|
if (!Number.isInteger(regenerateFromSeq) || regenerateFromSeq <= 0) {
|
|
3537
|
-
throw new
|
|
3538
|
-
code:
|
|
3639
|
+
throw new CliError14({
|
|
3640
|
+
code: CliErrorCode13.INVALID_ARGUMENT,
|
|
3539
3641
|
message: `--regenerate-from \u9700\u8981\u6B63\u6574\u6570 journal seq \u6216 last-assistant\uFF0C\u6536\u5230 "${args.regenerateFrom}"`
|
|
3540
3642
|
});
|
|
3541
3643
|
}
|
|
3542
3644
|
}
|
|
3543
3645
|
if (!requestedConversationId) {
|
|
3544
|
-
throw new
|
|
3545
|
-
code:
|
|
3646
|
+
throw new CliError14({
|
|
3647
|
+
code: CliErrorCode13.INVALID_ARGUMENT,
|
|
3546
3648
|
message: "--regenerate-from \u5FC5\u987B\u914D\u5408 --resume <\u65E2\u5B58\u4F1A\u8BDD id>\uFF08\u91CD\u8DD1\u65E2\u5B58\u6BB5\uFF0C\u65E0\u65B0 prompt\uFF09"
|
|
3547
3649
|
});
|
|
3548
3650
|
}
|
|
@@ -3556,8 +3658,8 @@ async function chatCommand(prompt, args) {
|
|
|
3556
3658
|
prompt = await fs4.readFile(args.promptFile, "utf-8");
|
|
3557
3659
|
}
|
|
3558
3660
|
if (prompt === void 0 || !prompt && !regenerateMode) {
|
|
3559
|
-
throw new
|
|
3560
|
-
code:
|
|
3661
|
+
throw new CliError14({
|
|
3662
|
+
code: CliErrorCode13.INVALID_ARGUMENT,
|
|
3561
3663
|
message: "prompt is required (positional or --prompt-file)"
|
|
3562
3664
|
});
|
|
3563
3665
|
}
|
|
@@ -3565,7 +3667,7 @@ async function chatCommand(prompt, args) {
|
|
|
3565
3667
|
const injectOn = args.injectOn ? parseInjectOn(args.injectOn) : void 0;
|
|
3566
3668
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
3567
3669
|
const wsUrl = ctx.endpoint.replace(/^http/, "ws") + "/ws/conversation";
|
|
3568
|
-
const client3 =
|
|
3670
|
+
const client3 = HcmClient11.fromAuthContext(ctx);
|
|
3569
3671
|
const stateKey = ctx.env;
|
|
3570
3672
|
const agentId = args.agent ?? DEFAULT_AGENT_ID3;
|
|
3571
3673
|
let resumeConversationId = requestedConversationId;
|
|
@@ -3578,8 +3680,8 @@ async function chatCommand(prompt, args) {
|
|
|
3578
3680
|
const items = await fetchConversationTimeline2(client3.raw(), resumeConversationId);
|
|
3579
3681
|
const lastSeq = findLastAssistantSeq(items);
|
|
3580
3682
|
if (lastSeq == null) {
|
|
3581
|
-
throw new
|
|
3582
|
-
code:
|
|
3683
|
+
throw new CliError14({
|
|
3684
|
+
code: CliErrorCode13.BUSINESS_RULE_VIOLATION,
|
|
3583
3685
|
message: `--regenerate-from last-assistant \u627E\u4E0D\u5230\u53EF\u91CD\u8DD1\u7684 chat-text seq: conversation=${resumeConversationId}`
|
|
3584
3686
|
});
|
|
3585
3687
|
}
|
|
@@ -3797,8 +3899,8 @@ async function chatCommand(prompt, args) {
|
|
|
3797
3899
|
} catch (e) {
|
|
3798
3900
|
process.removeListener("SIGINT", sigintHandler);
|
|
3799
3901
|
await ws.close();
|
|
3800
|
-
throw new
|
|
3801
|
-
code: e.code ??
|
|
3902
|
+
throw new CliError14({
|
|
3903
|
+
code: e.code ?? CliErrorCode13.BUSINESS_RULE_VIOLATION,
|
|
3802
3904
|
message: e.message,
|
|
3803
3905
|
traceId: e.traceId ?? void 0
|
|
3804
3906
|
});
|
|
@@ -3863,11 +3965,11 @@ async function chatCommand(prompt, args) {
|
|
|
3863
3965
|
init_auth_guard();
|
|
3864
3966
|
init_exit();
|
|
3865
3967
|
import { downloadDocument } from "@hcmai/sdk";
|
|
3866
|
-
import { HcmClient as
|
|
3968
|
+
import { HcmClient as HcmClient12 } from "@hcmai/sdk";
|
|
3867
3969
|
async function downloadCommand(documentId, args) {
|
|
3868
3970
|
try {
|
|
3869
3971
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
3870
|
-
const client3 =
|
|
3972
|
+
const client3 = HcmClient12.fromAuthContext(ctx);
|
|
3871
3973
|
const saved = await downloadDocument(client3.raw(), { documentId }, args.output);
|
|
3872
3974
|
process.stdout.write(saved + "\n");
|
|
3873
3975
|
process.exit(0);
|
|
@@ -3886,7 +3988,7 @@ async function downloadCommand(documentId, args) {
|
|
|
3886
3988
|
// src/commands/trace.ts
|
|
3887
3989
|
init_exit();
|
|
3888
3990
|
init_auth_guard();
|
|
3889
|
-
import { HcmClient as
|
|
3991
|
+
import { HcmClient as HcmClient13, formatObject as formatObject10, formatRows as formatRows4, fromAxiosError as fromAxiosError11 } from "@hcmai/sdk";
|
|
3890
3992
|
function parsePositiveInt2(value, fallback, flag) {
|
|
3891
3993
|
const n = Number(value ?? fallback);
|
|
3892
3994
|
if (!Number.isInteger(n) || n <= 0) {
|
|
@@ -4214,7 +4316,7 @@ async function gatherLlmTraceTree(http, rootConvId, maxDepth = 3) {
|
|
|
4214
4316
|
}
|
|
4215
4317
|
async function traceCommand(traceId, args) {
|
|
4216
4318
|
try {
|
|
4217
|
-
const client3 =
|
|
4319
|
+
const client3 = HcmClient13.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
4218
4320
|
const http = client3.raw();
|
|
4219
4321
|
const convId = args.conv ?? (args.llmCalls ? traceId ?? void 0 : void 0);
|
|
4220
4322
|
if (convId) {
|
|
@@ -4264,7 +4366,7 @@ async function traceCommand(traceId, args) {
|
|
|
4264
4366
|
} catch (e) {
|
|
4265
4367
|
const err = e;
|
|
4266
4368
|
if (err?.isAxiosError) {
|
|
4267
|
-
exitWithError(
|
|
4369
|
+
exitWithError(fromAxiosError11(err, args.profile));
|
|
4268
4370
|
}
|
|
4269
4371
|
exitWithError(e);
|
|
4270
4372
|
}
|
|
@@ -4274,15 +4376,15 @@ async function traceCommand(traceId, args) {
|
|
|
4274
4376
|
init_exit();
|
|
4275
4377
|
init_auth_guard();
|
|
4276
4378
|
import {
|
|
4277
|
-
HcmClient as
|
|
4379
|
+
HcmClient as HcmClient14,
|
|
4278
4380
|
formatObject as formatObject11,
|
|
4279
|
-
fromAxiosError as
|
|
4381
|
+
fromAxiosError as fromAxiosError12,
|
|
4280
4382
|
getCacheStats,
|
|
4281
4383
|
clearModelCache,
|
|
4282
4384
|
clearMetaCache
|
|
4283
4385
|
} from "@hcmai/sdk";
|
|
4284
4386
|
async function withClient(args, fn) {
|
|
4285
|
-
const client3 =
|
|
4387
|
+
const client3 = HcmClient14.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
4286
4388
|
return fn(client3);
|
|
4287
4389
|
}
|
|
4288
4390
|
function emit(result, args, human) {
|
|
@@ -4293,7 +4395,7 @@ function emit(result, args, human) {
|
|
|
4293
4395
|
}
|
|
4294
4396
|
function fail2(e, args) {
|
|
4295
4397
|
const err = e;
|
|
4296
|
-
if (err?.isAxiosError) exitWithError(
|
|
4398
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError12(err, args.env));
|
|
4297
4399
|
exitWithError(e);
|
|
4298
4400
|
process.exit(1);
|
|
4299
4401
|
}
|
|
@@ -4331,16 +4433,16 @@ init_exit();
|
|
|
4331
4433
|
init_auth_guard();
|
|
4332
4434
|
import { readFileSync as readFileSync3 } from "fs";
|
|
4333
4435
|
import {
|
|
4334
|
-
HcmClient as
|
|
4436
|
+
HcmClient as HcmClient15,
|
|
4335
4437
|
formatObject as formatObject12,
|
|
4336
|
-
fromAxiosError as
|
|
4438
|
+
fromAxiosError as fromAxiosError13,
|
|
4337
4439
|
scriptDryRun,
|
|
4338
4440
|
validateScriptManifest,
|
|
4339
4441
|
queryScriptLogs,
|
|
4340
4442
|
getScriptTask
|
|
4341
4443
|
} from "@hcmai/sdk";
|
|
4342
4444
|
async function withClient2(args, fn) {
|
|
4343
|
-
const client3 =
|
|
4445
|
+
const client3 = HcmClient15.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
4344
4446
|
return fn(client3);
|
|
4345
4447
|
}
|
|
4346
4448
|
function emit2(result, args, human) {
|
|
@@ -4351,7 +4453,7 @@ function emit2(result, args, human) {
|
|
|
4351
4453
|
}
|
|
4352
4454
|
function fail3(e, args) {
|
|
4353
4455
|
const err = e;
|
|
4354
|
-
if (err?.isAxiosError) exitWithError(
|
|
4456
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError13(err, args.env));
|
|
4355
4457
|
exitWithError(e);
|
|
4356
4458
|
process.exit(1);
|
|
4357
4459
|
}
|
|
@@ -4441,16 +4543,16 @@ async function scriptTaskCommand(taskId, args) {
|
|
|
4441
4543
|
init_exit();
|
|
4442
4544
|
init_auth_guard();
|
|
4443
4545
|
import {
|
|
4444
|
-
HcmClient as
|
|
4546
|
+
HcmClient as HcmClient16,
|
|
4445
4547
|
formatObject as formatObject13,
|
|
4446
|
-
fromAxiosError as
|
|
4548
|
+
fromAxiosError as fromAxiosError14,
|
|
4447
4549
|
uploadDocument as uploadDocument2
|
|
4448
4550
|
} from "@hcmai/sdk";
|
|
4449
4551
|
var DEFAULT_UPLOAD_CATEGORY = "attachment";
|
|
4450
4552
|
async function uploadCommand(filePath, args) {
|
|
4451
4553
|
try {
|
|
4452
4554
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
4453
|
-
const client3 =
|
|
4555
|
+
const client3 = HcmClient16.fromAuthContext(ctx);
|
|
4454
4556
|
const meta2 = await uploadDocument2(
|
|
4455
4557
|
client3.raw(),
|
|
4456
4558
|
filePath,
|
|
@@ -4473,7 +4575,7 @@ async function uploadCommand(filePath, args) {
|
|
|
4473
4575
|
} else if (status === 413) {
|
|
4474
4576
|
exitWithError(new Error("\u6587\u4EF6\u8D85\u51FA\u670D\u52A1\u7AEF\u5927\u5C0F\u4E0A\u9650\uFF08413\uFF09"));
|
|
4475
4577
|
} else if (err?.isAxiosError) {
|
|
4476
|
-
exitWithError(
|
|
4578
|
+
exitWithError(fromAxiosError14(err, args.env));
|
|
4477
4579
|
} else {
|
|
4478
4580
|
exitWithError(e);
|
|
4479
4581
|
}
|
|
@@ -4484,9 +4586,9 @@ async function uploadCommand(filePath, args) {
|
|
|
4484
4586
|
init_exit();
|
|
4485
4587
|
init_auth_guard();
|
|
4486
4588
|
import {
|
|
4487
|
-
HcmClient as
|
|
4589
|
+
HcmClient as HcmClient17,
|
|
4488
4590
|
formatObject as formatObject14,
|
|
4489
|
-
fromAxiosError as
|
|
4591
|
+
fromAxiosError as fromAxiosError15,
|
|
4490
4592
|
packDataPackage,
|
|
4491
4593
|
installDataPackageArtifact,
|
|
4492
4594
|
DEFAULT_ARTIFACT_CATEGORY
|
|
@@ -4510,7 +4612,7 @@ async function datapackagePackCommand(packageDir, args) {
|
|
|
4510
4612
|
async function datapackageInstallCommand(artifactPath, args) {
|
|
4511
4613
|
try {
|
|
4512
4614
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
4513
|
-
const client3 =
|
|
4615
|
+
const client3 = HcmClient17.fromAuthContext(ctx);
|
|
4514
4616
|
const { documentId, view } = await installDataPackageArtifact(client3, artifactPath, {
|
|
4515
4617
|
category: args.category ?? DEFAULT_ARTIFACT_CATEGORY
|
|
4516
4618
|
});
|
|
@@ -4532,7 +4634,7 @@ async function datapackageInstallCommand(artifactPath, args) {
|
|
|
4532
4634
|
if (err?.code === "ENOENT") {
|
|
4533
4635
|
exitWithError(new Error(`\u5236\u54C1\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${artifactPath}`));
|
|
4534
4636
|
} else if (err?.isAxiosError) {
|
|
4535
|
-
exitWithError(
|
|
4637
|
+
exitWithError(fromAxiosError15(err, args.env));
|
|
4536
4638
|
} else {
|
|
4537
4639
|
exitWithError(e);
|
|
4538
4640
|
}
|
|
@@ -4561,16 +4663,16 @@ import {
|
|
|
4561
4663
|
matchSkills,
|
|
4562
4664
|
filterByStage,
|
|
4563
4665
|
formatObject as formatObject16,
|
|
4564
|
-
fromAxiosError as
|
|
4565
|
-
loadEnv as
|
|
4666
|
+
fromAxiosError as fromAxiosError16,
|
|
4667
|
+
loadEnv as loadEnv6,
|
|
4566
4668
|
loadGlobalConfig as loadGlobalConfig6,
|
|
4567
4669
|
resolveActiveEnv as resolveActiveEnv3,
|
|
4568
|
-
CliError as
|
|
4569
|
-
CliErrorCode as
|
|
4670
|
+
CliError as CliError17,
|
|
4671
|
+
CliErrorCode as CliErrorCode16
|
|
4570
4672
|
} from "@hcmai/sdk";
|
|
4571
4673
|
|
|
4572
4674
|
// src/commands/skills-catalog.ts
|
|
4573
|
-
import { flattenSkills, CliError as
|
|
4675
|
+
import { flattenSkills, CliError as CliError15, CliErrorCode as CliErrorCode14 } from "@hcmai/sdk";
|
|
4574
4676
|
var CLI_CATEGORY_KEY = "cli-operations";
|
|
4575
4677
|
var CLI_CATEGORY_NAME = "CLI \u64CD\u4F5C";
|
|
4576
4678
|
function chironEntry(skill) {
|
|
@@ -4613,8 +4715,8 @@ var SOURCE_FILTERS = ["cli", "chiron", "all"];
|
|
|
4613
4715
|
function parseSourceFilter(raw) {
|
|
4614
4716
|
if (raw === void 0) return "all";
|
|
4615
4717
|
if (SOURCE_FILTERS.includes(raw)) return raw;
|
|
4616
|
-
throw new
|
|
4617
|
-
code:
|
|
4718
|
+
throw new CliError15({
|
|
4719
|
+
code: CliErrorCode14.INVALID_ARGUMENT,
|
|
4618
4720
|
message: `--source \u53EA\u8BA4 ${SOURCE_FILTERS.join(" / ")}\uFF0C\u6536\u5230 "${raw}"\u3002\uFF08\`local\` \u4E0D\u662F\u53D6\u503C\uFF1A\u6CA1\u6709\u54EA\u4E00\u8D9F\u4F1A\u53BB\u300C\u626B local \u6765\u6E90\u300D\uFF0Cinstall --from \u88C5\u7684\u90A3\u4E9B\u5728\u4EFB\u4F55 --source \u4E0B\u90FD\u5355\u5217\u3001\u90FD\u4E0D\u53C2\u4E0E\u5347\u7EA7\u3002\uFF09`
|
|
4619
4721
|
});
|
|
4620
4722
|
}
|
|
@@ -4685,7 +4787,7 @@ function checkCrossSourceRequires(catalog) {
|
|
|
4685
4787
|
// src/commands/skills-bundled.ts
|
|
4686
4788
|
import { promises as fsp } from "fs";
|
|
4687
4789
|
import * as path3 from "path";
|
|
4688
|
-
import { CliError as
|
|
4790
|
+
import { CliError as CliError16, CliErrorCode as CliErrorCode15, assertSafeReferencePath, parseSkillRequirements } from "@hcmai/sdk";
|
|
4689
4791
|
|
|
4690
4792
|
// src/commands/skills-manifest.ts
|
|
4691
4793
|
import { readFileSync as readFileSync4, readdirSync as readdirSync2, statSync as statSync3, existsSync } from "fs";
|
|
@@ -4777,8 +4879,8 @@ function listBundledSkills(dir = bundledSkillsDir()) {
|
|
|
4777
4879
|
return collectBundledSkills(dir);
|
|
4778
4880
|
}
|
|
4779
4881
|
function unreachable(id, detail) {
|
|
4780
|
-
return new
|
|
4781
|
-
code:
|
|
4882
|
+
return new CliError16({
|
|
4883
|
+
code: CliErrorCode15.SKILL_SOURCE_UNREACHABLE,
|
|
4782
4884
|
message: `\u88C5\u5728\u8FD9\u4EFD CLI \u91CC\u7684\u6280\u80FD\u8D44\u6E90\u8BFB\u4E0D\u5230\uFF08${detail}\uFF09\uFF0C\u91CD\u88C5 @hcmai/cli\u3002
|
|
4783
4885
|
\u6280\u80FD id\uFF1A${id}\uFF1B\u627E\u7684\u4F4D\u7F6E\uFF1A${bundledSkillsDir()}`
|
|
4784
4886
|
});
|
|
@@ -4835,8 +4937,8 @@ async function resolveBundledClosure(targetId, dir = bundledSkillsDir()) {
|
|
|
4835
4937
|
const visit = async (id) => {
|
|
4836
4938
|
if (state.get(id) === "done") return;
|
|
4837
4939
|
if (state.get(id) === "visiting") {
|
|
4838
|
-
throw new
|
|
4839
|
-
code:
|
|
4940
|
+
throw new CliError16({
|
|
4941
|
+
code: CliErrorCode15.INVALID_ARGUMENT,
|
|
4840
4942
|
message: `\u81EA\u5E26\u6280\u80FD\u4F9D\u8D56\u6210\u73AF\uFF1A${[...stack, id].join(" \u2192 ")}`
|
|
4841
4943
|
});
|
|
4842
4944
|
}
|
|
@@ -4876,10 +4978,10 @@ async function resolveEndpoint(args) {
|
|
|
4876
4978
|
if (args.endpoint) return args.endpoint.replace(/\/+$/, "");
|
|
4877
4979
|
const g = await loadGlobalConfig6();
|
|
4878
4980
|
const envName = resolveActiveEnv3({ envFlag: args.env }, process.env, g);
|
|
4879
|
-
const env2 = await
|
|
4981
|
+
const env2 = await loadEnv6(envName).catch(() => null);
|
|
4880
4982
|
if (!env2?.endpoint) {
|
|
4881
|
-
throw new
|
|
4882
|
-
code:
|
|
4983
|
+
throw new CliError17({
|
|
4984
|
+
code: CliErrorCode16.MISSING_FLAG,
|
|
4883
4985
|
message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`\u3002\uFF08\u6280\u80FD\u5E93\u514D\u8BA4\u8BC1\uFF0C\u4E0D\u9700\u8981\u5148 login\uFF09"
|
|
4884
4986
|
});
|
|
4885
4987
|
}
|
|
@@ -4898,8 +5000,8 @@ function decideTrackedEndpoint(options) {
|
|
|
4898
5000
|
}
|
|
4899
5001
|
if (!recorded) {
|
|
4900
5002
|
if (!current) {
|
|
4901
|
-
throw new
|
|
4902
|
-
code:
|
|
5003
|
+
throw new CliError17({
|
|
5004
|
+
code: CliErrorCode16.MISSING_FLAG,
|
|
4903
5005
|
message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`\u3002\uFF08\u6280\u80FD\u5E93\u514D\u8BA4\u8BC1\uFF0C\u4E0D\u9700\u8981\u5148 login\uFF09"
|
|
4904
5006
|
});
|
|
4905
5007
|
}
|
|
@@ -4959,7 +5061,7 @@ function fail4(e, args) {
|
|
|
4959
5061
|
if (err?.response?.status === 404) {
|
|
4960
5062
|
exitWithError(new Error("\u8BE5\u73AF\u5883\u6CA1\u6709\u8FD9\u4E2A\u6280\u80FD \u2014\u2014 \u8DD1 `hcm skills list` \u770B\u76EE\u5F55\uFF08\u6280\u80FD\u968F\u4EA7\u54C1\u7248\u672C\u8D70\uFF09"));
|
|
4961
5063
|
}
|
|
4962
|
-
if (err?.isAxiosError) exitWithError(
|
|
5064
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError16(err, args.env));
|
|
4963
5065
|
exitWithError(e);
|
|
4964
5066
|
process.exit(1);
|
|
4965
5067
|
}
|
|
@@ -4978,8 +5080,8 @@ async function skillsListCommand(keyword, args) {
|
|
|
4978
5080
|
const catalog = buildUnifiedCatalog({ source, chironManifest: manifest2, bundled, cliVersion: CLI_VERSION });
|
|
4979
5081
|
const conflicts = detectIdConflicts(catalog);
|
|
4980
5082
|
if (conflicts.ids.length > 0) {
|
|
4981
|
-
throw new
|
|
4982
|
-
code:
|
|
5083
|
+
throw new CliError17({
|
|
5084
|
+
code: CliErrorCode16.SKILL_ID_CONFLICT,
|
|
4983
5085
|
message: conflictMessage(conflicts.ids, endpoint ?? "(\u672A\u77E5\u73AF\u5883)")
|
|
4984
5086
|
});
|
|
4985
5087
|
}
|
|
@@ -5241,8 +5343,8 @@ async function skillsInstallCommand(id, args) {
|
|
|
5241
5343
|
const catalog = buildUnifiedCatalog({ source, chironManifest: manifest2, bundled, cliVersion: CLI_VERSION });
|
|
5242
5344
|
const conflicts = detectIdConflicts(catalog);
|
|
5243
5345
|
if (conflicts.ids.length > 0) {
|
|
5244
|
-
throw new
|
|
5245
|
-
code:
|
|
5346
|
+
throw new CliError17({
|
|
5347
|
+
code: CliErrorCode16.SKILL_ID_CONFLICT,
|
|
5246
5348
|
message: conflictMessage(conflicts.ids, endpoint ?? "(\u672A\u77E5\u73AF\u5883)")
|
|
5247
5349
|
});
|
|
5248
5350
|
}
|
|
@@ -5697,7 +5799,7 @@ async function recordInstalled(baseDir, documents, meta2) {
|
|
|
5697
5799
|
return state;
|
|
5698
5800
|
}
|
|
5699
5801
|
function invalid(message) {
|
|
5700
|
-
return new
|
|
5802
|
+
return new CliError17({ code: CliErrorCode16.INVALID_ARGUMENT, message });
|
|
5701
5803
|
}
|
|
5702
5804
|
async function readInstalled(baseDir, id) {
|
|
5703
5805
|
try {
|
|
@@ -5841,8 +5943,8 @@ async function skillsUpdateCommand(args) {
|
|
|
5841
5943
|
const layout = await resolveInstallLayout(args);
|
|
5842
5944
|
const state = await readSkillsState(layout.baseDir);
|
|
5843
5945
|
if (!state || Object.keys(state.skills).length === 0) {
|
|
5844
|
-
throw new
|
|
5845
|
-
code:
|
|
5946
|
+
throw new CliError17({
|
|
5947
|
+
code: CliErrorCode16.INVALID_ARGUMENT,
|
|
5846
5948
|
message: `${path4.join(layout.baseDir, SKILLS_STATE_FILE)} \u4E0D\u5B58\u5728\u6216\u4E3A\u7A7A \u2014\u2014 \u8FD9\u4E2A\u76EE\u5F55\u4E0B\u8FD8\u6CA1\u6709\u7528\u672C CLI \u88C5\u8FC7\u6280\u80FD\u3002\u5148 \`hcm skills install <id>\`\uFF1B\u5982\u679C\u6280\u80FD\u662F\u624B\u5DE5\u62F7\u8FDB\u6765\u7684\uFF0C\u91CD\u88C5\u4E00\u6B21\u5373\u53EF\u63A5\u7BA1\u5347\u7EA7\u3002`
|
|
5847
5949
|
});
|
|
5848
5950
|
}
|
|
@@ -5969,12 +6071,12 @@ import {
|
|
|
5969
6071
|
bootstrapTenant,
|
|
5970
6072
|
createHttpClient as createHttpClient3,
|
|
5971
6073
|
formatObject as formatObject17,
|
|
5972
|
-
fromAxiosError as
|
|
5973
|
-
loadEnv as
|
|
6074
|
+
fromAxiosError as fromAxiosError17,
|
|
6075
|
+
loadEnv as loadEnv7,
|
|
5974
6076
|
loadGlobalConfig as loadGlobalConfig7,
|
|
5975
6077
|
resolveActiveEnv as resolveActiveEnv4,
|
|
5976
|
-
CliError as
|
|
5977
|
-
CliErrorCode as
|
|
6078
|
+
CliError as CliError18,
|
|
6079
|
+
CliErrorCode as CliErrorCode17
|
|
5978
6080
|
} from "@hcmai/sdk";
|
|
5979
6081
|
init_exit();
|
|
5980
6082
|
async function resolveBootstrapKey(args, stdinTaken) {
|
|
@@ -5982,8 +6084,8 @@ async function resolveBootstrapKey(args, stdinTaken) {
|
|
|
5982
6084
|
if (fromEnv) return fromEnv;
|
|
5983
6085
|
if (args.bootstrapKeyStdin) {
|
|
5984
6086
|
if (stdinTaken) {
|
|
5985
|
-
throw new
|
|
5986
|
-
code:
|
|
6087
|
+
throw new CliError18({
|
|
6088
|
+
code: CliErrorCode17.INVALID_ARGUMENT,
|
|
5987
6089
|
message: "--bootstrap-key-stdin \u4E0E --admin-password-stdin \u4E0D\u80FD\u540C\u65F6\u7528\uFF08stdin \u53EA\u6709\u4E00\u8DEF\uFF09\uFF1B\u628A\u5176\u4E2D\u4E00\u4E2A\u6539\u8D70 HCM_BOOTSTRAP_KEY \u73AF\u5883\u53D8\u91CF\u6216\u4EA4\u4E92\u8F93\u5165"
|
|
5988
6090
|
});
|
|
5989
6091
|
}
|
|
@@ -6011,10 +6113,10 @@ async function resolveEndpoint2(args) {
|
|
|
6011
6113
|
if (args.endpoint) return args.endpoint;
|
|
6012
6114
|
const g = await loadGlobalConfig7();
|
|
6013
6115
|
const envName = resolveActiveEnv4({ envFlag: args.env }, process.env, g);
|
|
6014
|
-
const env2 = await
|
|
6116
|
+
const env2 = await loadEnv7(envName).catch(() => null);
|
|
6015
6117
|
if (!env2?.endpoint) {
|
|
6016
|
-
throw new
|
|
6017
|
-
code:
|
|
6118
|
+
throw new CliError18({
|
|
6119
|
+
code: CliErrorCode17.MISSING_FLAG,
|
|
6018
6120
|
message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`"
|
|
6019
6121
|
});
|
|
6020
6122
|
}
|
|
@@ -6023,8 +6125,8 @@ async function resolveEndpoint2(args) {
|
|
|
6023
6125
|
async function tenantBootstrapCommand(args) {
|
|
6024
6126
|
try {
|
|
6025
6127
|
if (!args.tenantId || !args.adminUsername) {
|
|
6026
|
-
throw new
|
|
6027
|
-
code:
|
|
6128
|
+
throw new CliError18({
|
|
6129
|
+
code: CliErrorCode17.MISSING_FLAG,
|
|
6028
6130
|
message: "--tenant-id \u4E0E --admin-username \u5FC5\u586B"
|
|
6029
6131
|
});
|
|
6030
6132
|
}
|
|
@@ -6067,7 +6169,7 @@ async function tenantBootstrapCommand(args) {
|
|
|
6067
6169
|
if (err?.response?.status === 403) {
|
|
6068
6170
|
exitWithError(new Error("bootstrap key \u65E0\u6548\uFF08403\uFF09\u2014\u2014 \u6838\u5BF9\u90E8\u7F72\u65B9\u63D0\u4F9B\u7684 key\uFF0C\u52FF\u590D\u7528\u5176\u4ED6\u73AF\u5883\u7684"));
|
|
6069
6171
|
} else if (err?.isAxiosError) {
|
|
6070
|
-
exitWithError(
|
|
6172
|
+
exitWithError(fromAxiosError17(err, args.env));
|
|
6071
6173
|
} else {
|
|
6072
6174
|
exitWithError(e);
|
|
6073
6175
|
}
|
|
@@ -6076,21 +6178,28 @@ async function tenantBootstrapCommand(args) {
|
|
|
6076
6178
|
|
|
6077
6179
|
// src/commands/meta.ts
|
|
6078
6180
|
import { promises as fsp3 } from "fs";
|
|
6181
|
+
import os3 from "os";
|
|
6182
|
+
import nodePath from "path";
|
|
6079
6183
|
import {
|
|
6080
|
-
HcmClient as
|
|
6184
|
+
HcmClient as HcmClient18,
|
|
6081
6185
|
formatObject as formatObject18,
|
|
6082
|
-
fromAxiosError as
|
|
6186
|
+
fromAxiosError as fromAxiosError18,
|
|
6083
6187
|
listTenantMeta,
|
|
6084
6188
|
getTenantMeta,
|
|
6085
6189
|
saveTenantMeta,
|
|
6086
6190
|
deleteTenantMeta,
|
|
6087
|
-
|
|
6088
|
-
|
|
6191
|
+
clearMetaCache as clearMetaCache2,
|
|
6192
|
+
validateMetaContent,
|
|
6193
|
+
formatMetaIssues,
|
|
6194
|
+
explainJacksonError,
|
|
6195
|
+
META_SCHEMA_SOURCE_COMMIT,
|
|
6196
|
+
CliError as CliError19,
|
|
6197
|
+
CliErrorCode as CliErrorCode18
|
|
6089
6198
|
} from "@hcmai/sdk";
|
|
6090
6199
|
init_exit();
|
|
6091
6200
|
init_auth_guard();
|
|
6092
6201
|
async function client2(args) {
|
|
6093
|
-
return
|
|
6202
|
+
return HcmClient18.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
6094
6203
|
}
|
|
6095
6204
|
function fail5(e, args) {
|
|
6096
6205
|
const err = e;
|
|
@@ -6099,7 +6208,7 @@ function fail5(e, args) {
|
|
|
6099
6208
|
new Error("\u5143\u6570\u636E\u5199\u5165\u88AB\u62D2\uFF08403\uFF09\u2014\u2014 \u9700 config-admin \u8EAB\u4EFD\u4E14\u5F53\u524D source \u53EF\u5199\uFF1B\u82E5\u5728\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4\u5916\uFF0C\u5148 `hcm workspace bind <key>`")
|
|
6100
6209
|
);
|
|
6101
6210
|
}
|
|
6102
|
-
if (err?.isAxiosError) exitWithError(
|
|
6211
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError18(err, args.env));
|
|
6103
6212
|
exitWithError(e);
|
|
6104
6213
|
process.exit(1);
|
|
6105
6214
|
}
|
|
@@ -6131,11 +6240,78 @@ async function metaGetCommand(path12, args) {
|
|
|
6131
6240
|
fail5(e, args);
|
|
6132
6241
|
}
|
|
6133
6242
|
}
|
|
6243
|
+
var PROBEABLE_META_TYPES = /* @__PURE__ */ new Set(["model", "list", "info", "view", "filter", "page", "wiz", "impexp"]);
|
|
6244
|
+
function parseMetaPath(path12) {
|
|
6245
|
+
const base = path12.split(/[\\/]/).pop() ?? path12;
|
|
6246
|
+
if (!/\.(yml|yaml)$/i.test(base)) return {};
|
|
6247
|
+
const parts = base.replace(/\.(yml|yaml)$/i, "").split(".");
|
|
6248
|
+
return { model: parts[0] || void 0, kind: parts[1] ?? "model", state: parts[2] };
|
|
6249
|
+
}
|
|
6250
|
+
function connFlags(args) {
|
|
6251
|
+
return (args.env ? ` --env ${args.env}` : "") + (args.as ? ` --as ${args.as}` : "");
|
|
6252
|
+
}
|
|
6253
|
+
function unverifiableReason(e) {
|
|
6254
|
+
const err = e;
|
|
6255
|
+
const st = err.response?.status;
|
|
6256
|
+
if (st === 401 || st === 403) return `\u6743\u9650\u4E0D\u8DB3\uFF08HTTP ${st}\uFF09`;
|
|
6257
|
+
if (st === 404) return "\u63A5\u53E3 404\uFF08\u6A21\u578B\u540D\u5BF9\u4E0D\u4E0A\uFF1F\uFF09";
|
|
6258
|
+
if (st === 429 || st != null && st >= 502) return `\u670D\u52A1\u7AEF\u6682\u65F6\u4E0D\u53EF\u7528\uFF08HTTP ${st}\uFF09`;
|
|
6259
|
+
if (st == null) return `\u8BF7\u6C42\u6CA1\u53D1\u51FA\u53BB\u6216\u6CA1\u56DE\u6765\uFF08${err.code ?? err.message ?? "\u672A\u77E5"}\uFF09`;
|
|
6260
|
+
return void 0;
|
|
6261
|
+
}
|
|
6262
|
+
async function verifyAfterWrite(c, path12) {
|
|
6263
|
+
const { model, kind, state } = parseMetaPath(path12);
|
|
6264
|
+
if (!model || !kind) {
|
|
6265
|
+
return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path12} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
|
|
6266
|
+
}
|
|
6267
|
+
try {
|
|
6268
|
+
await clearMetaCache2(c.raw(), model, {});
|
|
6269
|
+
} catch (e) {
|
|
6270
|
+
const err = e;
|
|
6271
|
+
return {
|
|
6272
|
+
status: "unverified",
|
|
6273
|
+
where: `DELETE /api/models/${model}/meta/cache`,
|
|
6274
|
+
why: `\u6E05\u5143\u6570\u636E\u7F13\u5B58\u5931\u8D25\uFF08${err.response?.status ?? err.message ?? "\u672A\u77E5"}\uFF09\uFF1B\u540E\u9762\u90A3\u4E00\u8BFB\u4F1A\u547D\u4E2D\u65E7\u7F13\u5B58\uFF0C\u9A8C\u4E0D\u51FA\u8FD9\u4EFD\u65B0\u7684\u771F\u5047`
|
|
6275
|
+
};
|
|
6276
|
+
}
|
|
6277
|
+
const probes = [];
|
|
6278
|
+
if (PROBEABLE_META_TYPES.has(kind)) {
|
|
6279
|
+
const params = { type: kind };
|
|
6280
|
+
if (state) params.state = state;
|
|
6281
|
+
probes.push({
|
|
6282
|
+
where: `GET /api/models/${model}/meta?type=${kind}${state ? `&state=${state}` : ""}`,
|
|
6283
|
+
run: () => c.raw().get(`/api/models/${model}/meta`, { params })
|
|
6284
|
+
});
|
|
6285
|
+
}
|
|
6286
|
+
probes.push({
|
|
6287
|
+
where: `GET /api/models/${model}/meta`,
|
|
6288
|
+
run: () => c.raw().get(`/api/models/${model}/meta`)
|
|
6289
|
+
});
|
|
6290
|
+
if (kind === "list") {
|
|
6291
|
+
probes.push({
|
|
6292
|
+
where: `GET /api/models/${model}?state=${state ?? "default"}`,
|
|
6293
|
+
run: () => c.raw().get(`/api/models/${model}`, { params: { state: state ?? "default", size: 1 } })
|
|
6294
|
+
});
|
|
6295
|
+
}
|
|
6296
|
+
for (const probe of probes) {
|
|
6297
|
+
try {
|
|
6298
|
+
await probe.run();
|
|
6299
|
+
} catch (e) {
|
|
6300
|
+
const why = unverifiableReason(e);
|
|
6301
|
+
if (why) return { status: "unverified", where: probe.where, why };
|
|
6302
|
+
const err = e;
|
|
6303
|
+
const body = err.response?.data;
|
|
6304
|
+
const raw = typeof body === "string" ? body : JSON.stringify(body ?? err.message ?? String(e));
|
|
6305
|
+
return { status: "broken", where: probe.where, raw };
|
|
6306
|
+
}
|
|
6307
|
+
}
|
|
6308
|
+
return { status: "ok" };
|
|
6309
|
+
}
|
|
6134
6310
|
async function metaSetCommand(path12, args) {
|
|
6135
6311
|
try {
|
|
6136
6312
|
if (!args.file) {
|
|
6137
|
-
throw new
|
|
6138
|
-
code:
|
|
6313
|
+
throw new CliError19({
|
|
6314
|
+
code: CliErrorCode18.MISSING_FLAG,
|
|
6139
6315
|
message: "--file <path> \u5FC5\u586B\uFF08\u4ECE\u6587\u4EF6\u8BFB\u53D6 meta \u539F\u6587\uFF1B\u7528 - \u8868\u793A stdin\uFF09"
|
|
6140
6316
|
});
|
|
6141
6317
|
}
|
|
@@ -6146,27 +6322,112 @@ async function metaSetCommand(path12, args) {
|
|
|
6146
6322
|
process.stdin.on("end", () => resolve4(buf));
|
|
6147
6323
|
process.stdin.on("error", reject);
|
|
6148
6324
|
}) : await fsp3.readFile(args.file, "utf8");
|
|
6325
|
+
if (!args.skipValidate) {
|
|
6326
|
+
const result2 = validateMetaContent(path12, content);
|
|
6327
|
+
if (result2.issues.length > 0) {
|
|
6328
|
+
process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path12}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
|
|
6329
|
+
`);
|
|
6330
|
+
process.stderr.write(formatMetaIssues(result2, " ") + "\n");
|
|
6331
|
+
}
|
|
6332
|
+
if (result2.errors.length > 0) {
|
|
6333
|
+
process.stderr.write(
|
|
6334
|
+
`
|
|
6335
|
+
\u274C \u4E0A\u9762 ${result2.errors.length} \u5904\u7C7B\u578B\u4E0D\u7B26\uFF0C\u5199\u4E0B\u53BB\u670D\u52A1\u7AEF\u4F1A**\u6536\u4E0B\u5E76\u8FD4 200**\uFF0C\u7136\u540E\u5728\u771F\u5B9E\u7528\u6237\u6253\u5F00\u9875\u9762\u65F6\u624D\u70B8\u3002\u5DF2\u62E6\u5728\u5199\u4E4B\u524D\u3002
|
|
6336
|
+
\u786E\u4FE1 schema \u526F\u672C\u65E7\u4E86\uFF08core \u6539\u8FC7\u5951\u7EA6\uFF09\u21D2 \u52A0 --skip-validate \u5F3A\u5199\u3002
|
|
6337
|
+
`
|
|
6338
|
+
);
|
|
6339
|
+
process.exit(1);
|
|
6340
|
+
}
|
|
6341
|
+
}
|
|
6149
6342
|
if (args.dryRun) {
|
|
6150
|
-
|
|
6151
|
-
|
|
6343
|
+
const dryFmt = args.output;
|
|
6344
|
+
if (dryFmt === "json" || dryFmt === "yaml") {
|
|
6345
|
+
process.stdout.write(
|
|
6346
|
+
formatObject18(
|
|
6347
|
+
{ dryRun: true, path: path12, bytes: Buffer.byteLength(content), content },
|
|
6348
|
+
{ format: dryFmt }
|
|
6349
|
+
) + "\n"
|
|
6350
|
+
);
|
|
6351
|
+
} else {
|
|
6352
|
+
process.stdout.write(
|
|
6353
|
+
`[dry-run] \u5C06\u5199\u5165 ${path12}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
|
|
6152
6354
|
---
|
|
6153
6355
|
${content}
|
|
6154
6356
|
`
|
|
6155
|
-
|
|
6357
|
+
);
|
|
6358
|
+
}
|
|
6156
6359
|
process.exit(0);
|
|
6157
6360
|
}
|
|
6158
6361
|
const c = await client2(args);
|
|
6362
|
+
let backupFile;
|
|
6363
|
+
let backupState = "unknown";
|
|
6364
|
+
let backupWhy;
|
|
6365
|
+
try {
|
|
6366
|
+
const prev = await getTenantMeta(c.raw(), path12);
|
|
6367
|
+
if (!prev || prev.trim() === "") {
|
|
6368
|
+
backupState = "absent";
|
|
6369
|
+
} else {
|
|
6370
|
+
backupFile = nodePath.join(
|
|
6371
|
+
os3.tmpdir(),
|
|
6372
|
+
`hcm-meta-backup-${Date.now()}-${path12.replace(/[\\/]/g, "_")}`
|
|
6373
|
+
);
|
|
6374
|
+
await fsp3.writeFile(backupFile, prev, "utf8");
|
|
6375
|
+
backupState = "saved";
|
|
6376
|
+
}
|
|
6377
|
+
} catch (e) {
|
|
6378
|
+
const err = e;
|
|
6379
|
+
const st = err.response?.status;
|
|
6380
|
+
if (st === 404) {
|
|
6381
|
+
backupState = "absent";
|
|
6382
|
+
} else {
|
|
6383
|
+
backupState = "unknown";
|
|
6384
|
+
backupWhy = `HTTP ${st ?? "-"}${err.code ? ` ${err.code}` : ""}${err.message ? `\uFF1A${err.message}` : ""}`;
|
|
6385
|
+
}
|
|
6386
|
+
}
|
|
6159
6387
|
const result = await saveTenantMeta(c.raw(), path12, content);
|
|
6160
6388
|
const fmt = args.output ?? "json";
|
|
6161
|
-
if (fmt !== "json") {
|
|
6162
|
-
process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path12}
|
|
6163
|
-
\u8BB0\u5F97\u6E05\u7F13\u5B58\uFF1Ahcm cache clear-meta <Model>
|
|
6389
|
+
if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path12}
|
|
6164
6390
|
`);
|
|
6391
|
+
const restoreHint = backupState === "saved" && backupFile ? ` \u65E7\u5185\u5BB9\u5DF2\u5B58\uFF1A${backupFile}
|
|
6392
|
+
\u653E\u56DE\u53BB\uFF1Ahcm meta set ${path12} --file ${backupFile}${connFlags(args)}
|
|
6393
|
+
` : backupState === "absent" ? ` \u8FD9\u4E00\u5C42\u6B64\u524D\u6CA1\u6709\u8986\u76D6\uFF08\u5DF2\u8BC1\u5B9E\uFF09\uFF0C\u6062\u590D\u5373\u5220\u9664\uFF1Ahcm meta delete ${path12}${connFlags(args)}
|
|
6394
|
+
` : ` \u26A0\uFE0F \u65E7\u5185\u5BB9**\u6CA1\u5907\u4EFD\u6210**\uFF08${backupWhy ?? "\u539F\u56E0\u672A\u77E5"}\uFF09\u2014\u2014\u65E2\u4E0D\u77E5\u9053\u6B64\u524D\u6709\u6CA1\u6709\u8986\u76D6\uFF0C\u4E5F\u5C31\u7ED9\u4E0D\u51FA\u6062\u590D\u547D\u4EE4\u3002
|
|
6395
|
+
\u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path12}${connFlags(args)}
|
|
6396
|
+
`;
|
|
6397
|
+
if (args.verify === false) {
|
|
6398
|
+
process.stderr.write(
|
|
6399
|
+
"\u26A0\uFE0F --no-verify\uFF1A**\u6CA1\u6709**\u9A8C\u8FC7\u670D\u52A1\u7AEF\u8BFB\u4E0D\u8BFB\u5F97\u52A8\u8FD9\u4EFD meta\u3002\u300C\u5199\u5165\u6210\u529F\u300D\u53EA\u8BF4\u660E\u5B57\u8282\u6536\u4E0B\u4E86\u3002\n \u81EA\u5DF1\u8865\uFF1Ahcm cache clear-meta <Model> \u540E\u6253\u5F00\u9875\u9762\u770B\u4E00\u773C\u3002\n" + restoreHint
|
|
6400
|
+
);
|
|
6401
|
+
} else {
|
|
6402
|
+
const outcome = await verifyAfterWrite(c, path12);
|
|
6403
|
+
if (outcome.status === "broken") {
|
|
6404
|
+
const human = explainJacksonError(outcome.raw);
|
|
6405
|
+
process.stderr.write(
|
|
6406
|
+
`
|
|
6407
|
+
\u{1F534} \u5199\u8FDB\u53BB\u4E86\uFF0C\u4F46**\u670D\u52A1\u7AEF\u8BFB\u4E0D\u52A8** \u2014\u2014 \u9875\u9762\u73B0\u5728\u662F\u574F\u7684\u3002
|
|
6408
|
+
\u63A2\u9488\uFF1A${outcome.where}
|
|
6409
|
+
` + (human ? `${human.split("\n").map((l) => " " + l).join("\n")}
|
|
6410
|
+
` : "") + ` \u670D\u52A1\u7AEF\u539F\u8BDD\uFF1A${outcome.raw.slice(0, 600)}
|
|
6411
|
+
` + restoreHint
|
|
6412
|
+
);
|
|
6413
|
+
process.exit(1);
|
|
6414
|
+
}
|
|
6415
|
+
if (outcome.status === "unverified") {
|
|
6416
|
+
process.stderr.write(
|
|
6417
|
+
`
|
|
6418
|
+
\u26A0\uFE0F \u5199\u8FDB\u53BB\u4E86\uFF0C\u4F46**\u6CA1\u9A8C\u6210**\uFF1A${outcome.why}
|
|
6419
|
+
\u63A2\u9488\uFF1A${outcome.where}
|
|
6420
|
+
\u4E5F\u5C31\u662F\u8BF4\uFF0C\u670D\u52A1\u7AEF\u8BFB\u4E0D\u8BFB\u5F97\u52A8\u8FD9\u4EFD meta\uFF0C\u672C\u6B21\u547D\u4EE4**\u4E0D\u77E5\u9053**\u3002
|
|
6421
|
+
` + restoreHint
|
|
6422
|
+
);
|
|
6423
|
+
} else if (fmt !== "json") {
|
|
6424
|
+
process.stdout.write(" \u5DF2\u6E05\u5143\u6570\u636E\u7F13\u5B58\uFF0C\u5E76\u771F\u8BFB\u4E86\u4E00\u904D\uFF1A\u670D\u52A1\u7AEF\u8BFB\u5F97\u52A8 \u2714\n");
|
|
6425
|
+
}
|
|
6165
6426
|
}
|
|
6166
6427
|
process.stdout.write(formatObject18(result, { format: fmt }) + "\n");
|
|
6167
6428
|
process.exit(0);
|
|
6168
6429
|
} catch (e) {
|
|
6169
|
-
if (e
|
|
6430
|
+
if (e.code === "ENOENT") exitWithError(new Error(`\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${args.file}`));
|
|
6170
6431
|
fail5(e, args);
|
|
6171
6432
|
}
|
|
6172
6433
|
}
|
|
@@ -6190,6 +6451,52 @@ async function metaDeleteCommand(path12, args) {
|
|
|
6190
6451
|
fail5(e, args);
|
|
6191
6452
|
}
|
|
6192
6453
|
}
|
|
6454
|
+
async function metaValidateCommand(path12, args) {
|
|
6455
|
+
try {
|
|
6456
|
+
if (!args.file) {
|
|
6457
|
+
throw new CliError19({
|
|
6458
|
+
code: CliErrorCode18.MISSING_FLAG,
|
|
6459
|
+
message: "--file <path> \u5FC5\u586B\uFF08\u8981\u9A8C\u7684\u90A3\u4EFD\u539F\u6587\uFF1B\u7528 - \u8868\u793A stdin\uFF09"
|
|
6460
|
+
});
|
|
6461
|
+
}
|
|
6462
|
+
const content = args.file === "-" ? await new Promise((resolve4, reject) => {
|
|
6463
|
+
let buf = "";
|
|
6464
|
+
process.stdin.setEncoding("utf8");
|
|
6465
|
+
process.stdin.on("data", (d) => buf += d);
|
|
6466
|
+
process.stdin.on("end", () => resolve4(buf));
|
|
6467
|
+
process.stdin.on("error", reject);
|
|
6468
|
+
}) : await fsp3.readFile(args.file, "utf8");
|
|
6469
|
+
const result = validateMetaContent(path12, content);
|
|
6470
|
+
const fmt = args.output ?? "table";
|
|
6471
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
6472
|
+
process.stdout.write(
|
|
6473
|
+
formatObject18(
|
|
6474
|
+
{
|
|
6475
|
+
path: path12,
|
|
6476
|
+
kind: result.kind,
|
|
6477
|
+
schemaKnown: result.schemaKnown,
|
|
6478
|
+
schemaSourceCommit: META_SCHEMA_SOURCE_COMMIT,
|
|
6479
|
+
errorCount: result.errors.length,
|
|
6480
|
+
issues: result.issues
|
|
6481
|
+
},
|
|
6482
|
+
{ format: fmt }
|
|
6483
|
+
) + "\n"
|
|
6484
|
+
);
|
|
6485
|
+
} else {
|
|
6486
|
+
process.stdout.write(
|
|
6487
|
+
`\u{1F50E} ${path12}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
|
|
6488
|
+
`
|
|
6489
|
+
);
|
|
6490
|
+
process.stdout.write(
|
|
6491
|
+
result.issues.length === 0 ? " \u6CA1\u6709\u53D1\u73B0\u95EE\u9898\u3002\n" : formatMetaIssues(result, " ") + "\n"
|
|
6492
|
+
);
|
|
6493
|
+
}
|
|
6494
|
+
process.exit(result.errors.length > 0 ? 1 : 0);
|
|
6495
|
+
} catch (e) {
|
|
6496
|
+
if (e.code === "ENOENT") exitWithError(new Error(`\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${args.file}`));
|
|
6497
|
+
fail5(e, args);
|
|
6498
|
+
}
|
|
6499
|
+
}
|
|
6193
6500
|
|
|
6194
6501
|
// src/commands/workspace.ts
|
|
6195
6502
|
init_exit();
|
|
@@ -6206,7 +6513,7 @@ import {
|
|
|
6206
6513
|
formatObject as formatObject19,
|
|
6207
6514
|
formatRows as formatRows5,
|
|
6208
6515
|
getMiniStatus,
|
|
6209
|
-
HcmClient as
|
|
6516
|
+
HcmClient as HcmClient19,
|
|
6210
6517
|
initMiniAppProject,
|
|
6211
6518
|
inferMiniWritableTemplateOptionsFromModel,
|
|
6212
6519
|
listWorkspaceFiles,
|
|
@@ -6216,7 +6523,7 @@ import {
|
|
|
6216
6523
|
runMiniSmokeChecks,
|
|
6217
6524
|
saveWorkspaceFileContent,
|
|
6218
6525
|
validateMiniProject,
|
|
6219
|
-
fromAxiosError as
|
|
6526
|
+
fromAxiosError as fromAxiosError19
|
|
6220
6527
|
} from "@hcmai/sdk";
|
|
6221
6528
|
|
|
6222
6529
|
// src/commands/workspace-format.ts
|
|
@@ -6263,7 +6570,7 @@ var RAW_WORKSPACE_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
|
|
|
6263
6570
|
var RAW_WORKSPACE_EXCLUDED_FILES = /* @__PURE__ */ new Set([WORKSPACE_CONTEXT_FILE, ".DS_Store"]);
|
|
6264
6571
|
async function workspaceListCommand(args) {
|
|
6265
6572
|
try {
|
|
6266
|
-
const client3 =
|
|
6573
|
+
const client3 = HcmClient19.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
6267
6574
|
const limit = parsePositiveInt3(args.limit, 50, "--limit");
|
|
6268
6575
|
const result = await client3.query("TenantExtensionWorkspace", {
|
|
6269
6576
|
keyword: args.keyword,
|
|
@@ -6292,7 +6599,7 @@ async function workspaceActiveCommand(args) {
|
|
|
6292
6599
|
const ctx = await getActiveAuthContextFromCli(args, {
|
|
6293
6600
|
fallbackEnv: localContext?.profile
|
|
6294
6601
|
});
|
|
6295
|
-
const client3 =
|
|
6602
|
+
const client3 = HcmClient19.fromAuthContext(ctx);
|
|
6296
6603
|
const result = await client3.query("TenantExtensionWorkspace", {
|
|
6297
6604
|
filter: { devModeEnabled: true },
|
|
6298
6605
|
fields: ["workspaceKey", "devModeEnabled"],
|
|
@@ -6347,7 +6654,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
|
|
|
6347
6654
|
`${WORKSPACE_CONTEXT_FILE} already binds workspace '${existing.workspaceKey}'; use --force to rebind`
|
|
6348
6655
|
);
|
|
6349
6656
|
}
|
|
6350
|
-
const client3 =
|
|
6657
|
+
const client3 = HcmClient19.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
6351
6658
|
const normalizedWorkspaceKey = normalizeWorkspaceKey(workspaceKey);
|
|
6352
6659
|
const resp = await client3.raw().post("/api/models/TenantExtensionWorkspace", {
|
|
6353
6660
|
workspaceKey: normalizedWorkspaceKey,
|
|
@@ -6394,7 +6701,7 @@ async function workspacePullCommand(args) {
|
|
|
6394
6701
|
`workspace key is required; pass --workspace <key> or run hcm workspace bind <key> first`
|
|
6395
6702
|
);
|
|
6396
6703
|
}
|
|
6397
|
-
const client3 =
|
|
6704
|
+
const client3 = HcmClient19.fromAuthContext(
|
|
6398
6705
|
await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
|
|
6399
6706
|
);
|
|
6400
6707
|
const context = buildWorkspaceContext({
|
|
@@ -6564,7 +6871,7 @@ async function workspacePushCommand(args) {
|
|
|
6564
6871
|
const rootDir = resolveRootDir(args.dir);
|
|
6565
6872
|
const context = await requireWorkspaceContext(rootDir);
|
|
6566
6873
|
const miniApps = await discoverMiniApps(rootDir);
|
|
6567
|
-
const client3 =
|
|
6874
|
+
const client3 = HcmClient19.fromAuthContext(
|
|
6568
6875
|
await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
|
|
6569
6876
|
);
|
|
6570
6877
|
const activeWorkspaceKey = args.dryRun ? null : await probeActiveWorkspaceKey(client3);
|
|
@@ -7087,7 +7394,7 @@ async function readMiniStatusSafely(app) {
|
|
|
7087
7394
|
async function loadProfileClient(args) {
|
|
7088
7395
|
try {
|
|
7089
7396
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
7090
|
-
return
|
|
7397
|
+
return HcmClient19.fromAuthContext(ctx);
|
|
7091
7398
|
} catch (e) {
|
|
7092
7399
|
if (args.env || args.profile) throw e;
|
|
7093
7400
|
return null;
|
|
@@ -7498,7 +7805,7 @@ function formatStatusSummary(summary) {
|
|
|
7498
7805
|
function exitWorkspaceError(err, profile) {
|
|
7499
7806
|
const maybeAxios = err;
|
|
7500
7807
|
if (maybeAxios?.isAxiosError) {
|
|
7501
|
-
exitWithError(
|
|
7808
|
+
exitWithError(fromAxiosError19(err, profile));
|
|
7502
7809
|
}
|
|
7503
7810
|
exitWithError(err);
|
|
7504
7811
|
}
|
|
@@ -7533,7 +7840,7 @@ async function setDevModeBinding(client3, workspaceKey) {
|
|
|
7533
7840
|
}
|
|
7534
7841
|
async function workspaceActivateCommand(workspaceKey, args) {
|
|
7535
7842
|
try {
|
|
7536
|
-
const client3 =
|
|
7843
|
+
const client3 = HcmClient19.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
7537
7844
|
const key2 = normalizeWorkspaceKey(workspaceKey);
|
|
7538
7845
|
await setDevModeBinding(client3, key2);
|
|
7539
7846
|
const fmt = args.output ?? "table";
|
|
@@ -7555,15 +7862,15 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
7555
7862
|
// src/commands/identity.ts
|
|
7556
7863
|
init_exit();
|
|
7557
7864
|
import {
|
|
7558
|
-
loadEnv as
|
|
7865
|
+
loadEnv as loadEnv8,
|
|
7559
7866
|
saveEnv as saveEnv3,
|
|
7560
7867
|
loadIdentity as loadIdentity4,
|
|
7561
7868
|
listIdentities as listIdentities2,
|
|
7562
7869
|
deleteIdentity as deleteIdentity2,
|
|
7563
7870
|
loadGlobalConfig as loadGlobalConfig8,
|
|
7564
7871
|
TokenStore as TokenStore3,
|
|
7565
|
-
CliError as
|
|
7566
|
-
CliErrorCode as
|
|
7872
|
+
CliError as CliError20,
|
|
7873
|
+
CliErrorCode as CliErrorCode19
|
|
7567
7874
|
} from "@hcmai/sdk";
|
|
7568
7875
|
async function identityList(args) {
|
|
7569
7876
|
try {
|
|
@@ -7577,7 +7884,7 @@ async function identityList(args) {
|
|
|
7577
7884
|
const lines = [];
|
|
7578
7885
|
for (const n of names) {
|
|
7579
7886
|
const meta2 = await loadIdentity4(n);
|
|
7580
|
-
const env2 = await
|
|
7887
|
+
const env2 = await loadEnv8(meta2.env).catch(() => null);
|
|
7581
7888
|
const isDefault = env2?.defaultIdentity === n ? "*" : " ";
|
|
7582
7889
|
const expired = meta2.expiresAt && new Date(meta2.expiresAt) < /* @__PURE__ */ new Date() ? " (expired)" : "";
|
|
7583
7890
|
lines.push(`${isDefault} ${n} scheme=${meta2.scheme} env=${meta2.env}${expired}`);
|
|
@@ -7590,9 +7897,9 @@ async function identityList(args) {
|
|
|
7590
7897
|
async function identityUse(name) {
|
|
7591
7898
|
try {
|
|
7592
7899
|
const meta2 = await loadIdentity4(name);
|
|
7593
|
-
const env2 = await
|
|
7594
|
-
throw new
|
|
7595
|
-
code:
|
|
7900
|
+
const env2 = await loadEnv8(meta2.env).catch(() => {
|
|
7901
|
+
throw new CliError20({
|
|
7902
|
+
code: CliErrorCode19.IDENTITY_NOT_IN_ENV,
|
|
7596
7903
|
message: `identity '${name}' references env '${meta2.env}' which no longer exists. Re-create the env, or remove this orphan: hcm identity remove ${name}`
|
|
7597
7904
|
});
|
|
7598
7905
|
});
|
|
@@ -7615,7 +7922,7 @@ async function identityRemove(name) {
|
|
|
7615
7922
|
);
|
|
7616
7923
|
}
|
|
7617
7924
|
await deleteIdentity2(name);
|
|
7618
|
-
const env2 = await
|
|
7925
|
+
const env2 = await loadEnv8(meta2.env).catch(() => null);
|
|
7619
7926
|
if (env2?.defaultIdentity === name) {
|
|
7620
7927
|
env2.defaultIdentity = void 0;
|
|
7621
7928
|
await saveEnv3(meta2.env, env2);
|
|
@@ -7631,7 +7938,7 @@ init_auth_guard();
|
|
|
7631
7938
|
import { existsSync as existsSync2, readFileSync as readFileSync5 } from "fs";
|
|
7632
7939
|
import { join as pathJoin } from "path";
|
|
7633
7940
|
import {
|
|
7634
|
-
HcmClient as
|
|
7941
|
+
HcmClient as HcmClient20,
|
|
7635
7942
|
formatObject as formatObject20
|
|
7636
7943
|
} from "@hcmai/sdk";
|
|
7637
7944
|
|
|
@@ -7682,8 +7989,31 @@ var GUARDED_EXECUTOR_REASON_CODES = /* @__PURE__ */ new Set([
|
|
|
7682
7989
|
// 「该 R2 命令不在首批受控执行器支持面」拦死,一个写请求都没发出去。
|
|
7683
7990
|
"import-write"
|
|
7684
7991
|
]);
|
|
7992
|
+
function normalizeAssessedArgv(inputArgv) {
|
|
7993
|
+
let rest = inputArgv;
|
|
7994
|
+
const dropSeparators = () => {
|
|
7995
|
+
let start = 0;
|
|
7996
|
+
while (rest[start] === "--") start += 1;
|
|
7997
|
+
rest = start > 0 ? rest.slice(start) : rest;
|
|
7998
|
+
};
|
|
7999
|
+
dropSeparators();
|
|
8000
|
+
if (PACKAGE_RUNNERS.has(rest[0] ?? "") && isCliLauncher(rest[1])) {
|
|
8001
|
+
rest = rest.slice(2);
|
|
8002
|
+
} else if (isCliLauncher(rest[0])) {
|
|
8003
|
+
rest = rest.slice(1);
|
|
8004
|
+
}
|
|
8005
|
+
dropSeparators();
|
|
8006
|
+
return rest === inputArgv ? [...inputArgv] : rest;
|
|
8007
|
+
}
|
|
8008
|
+
var PACKAGE_RUNNERS = /* @__PURE__ */ new Set(["npx", "bunx", "pnpx"]);
|
|
8009
|
+
function isCliLauncher(token) {
|
|
8010
|
+
if (!token || token.startsWith("-")) return false;
|
|
8011
|
+
if (token === "@hcmai/cli") return true;
|
|
8012
|
+
const base = token.split(/[\\/]/).pop() ?? token;
|
|
8013
|
+
return base === "hcm" || base === "hcm.js" || base === "hcmai";
|
|
8014
|
+
}
|
|
7685
8015
|
function assessDeliveryCommand(inputArgv, options = {}) {
|
|
7686
|
-
const argv = inputArgv
|
|
8016
|
+
const argv = normalizeAssessedArgv(inputArgv);
|
|
7687
8017
|
const commandSha256 = sha2564(JSON.stringify(argv));
|
|
7688
8018
|
const name = argv[0] ?? "";
|
|
7689
8019
|
const subcommand = argv[1] && !argv[1].startsWith("-") ? argv[1] : void 0;
|
|
@@ -7764,6 +8094,7 @@ function classify(argv, actionResolution) {
|
|
|
7764
8094
|
return forbidden("credential-governance", "\u547D\u4EE4\u643A\u5E26\u8EAB\u4EFD\u51ED\u636E\u53C2\u6570\uFF0C\u5FC5\u987B\u8F6C\u4EA4\u8EAB\u4EFD\u6CBB\u7406\u6D41\u7A0B\u3002");
|
|
7765
8095
|
}
|
|
7766
8096
|
if (name === "version") return direct("R0", "product-discovery", "product-discovery");
|
|
8097
|
+
if (name === "open") return direct("R1", "remote-read", "browser-session-open");
|
|
7767
8098
|
if (name === "delivery" && subcommand === "assess") {
|
|
7768
8099
|
return direct("R0", "local-discovery", "risk-assessment");
|
|
7769
8100
|
}
|
|
@@ -8076,7 +8407,7 @@ async function resolveCoreAction(request) {
|
|
|
8076
8407
|
as: request.identity,
|
|
8077
8408
|
profile: request.profile
|
|
8078
8409
|
});
|
|
8079
|
-
const description = await
|
|
8410
|
+
const description = await HcmClient20.fromAuthContext(auth).describe(request.model);
|
|
8080
8411
|
const named = description.actions.filter((action2) => action2.name === request.action);
|
|
8081
8412
|
if (named.length === 0) {
|
|
8082
8413
|
const degraded = description.effectiveActionsAvailable ? "" : `\u26A0\uFE0F \u672C\u6B21\u6BD4\u5BF9\u4E0D\u542B\u811A\u672C Action\u2014\u2014${description.effectiveActionsNote ?? "\u539F\u56E0\u672A\u77E5"}\u3002`;
|
|
@@ -8303,10 +8634,10 @@ async function deliveryModeCommand(args) {
|
|
|
8303
8634
|
init_auth_guard();
|
|
8304
8635
|
init_exit();
|
|
8305
8636
|
import {
|
|
8306
|
-
HcmClient as
|
|
8637
|
+
HcmClient as HcmClient21,
|
|
8307
8638
|
fetchReconIdentity,
|
|
8308
8639
|
formatObject as formatObject22,
|
|
8309
|
-
fromAxiosError as
|
|
8640
|
+
fromAxiosError as fromAxiosError20,
|
|
8310
8641
|
httpProbe,
|
|
8311
8642
|
runDoctor
|
|
8312
8643
|
} from "@hcmai/sdk";
|
|
@@ -8325,7 +8656,7 @@ function render2(report) {
|
|
|
8325
8656
|
async function deliveryDoctorCommand(args) {
|
|
8326
8657
|
try {
|
|
8327
8658
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
8328
|
-
const client3 =
|
|
8659
|
+
const client3 = HcmClient21.fromAuthContext(ctx);
|
|
8329
8660
|
const probe = httpProbe(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
|
|
8330
8661
|
const identity2 = await fetchReconIdentity(probe, ctx.tenantId);
|
|
8331
8662
|
const report = await runDoctor(probe, identity2);
|
|
@@ -8335,7 +8666,7 @@ async function deliveryDoctorCommand(args) {
|
|
|
8335
8666
|
process.exit(report.ok ? 0 : 1);
|
|
8336
8667
|
} catch (e) {
|
|
8337
8668
|
const err = e;
|
|
8338
|
-
if (err?.isAxiosError) exitWithError(
|
|
8669
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError20(err, args.env));
|
|
8339
8670
|
exitWithError(e);
|
|
8340
8671
|
process.exit(1);
|
|
8341
8672
|
}
|
|
@@ -8345,12 +8676,12 @@ async function deliveryDoctorCommand(args) {
|
|
|
8345
8676
|
init_auth_guard();
|
|
8346
8677
|
init_exit();
|
|
8347
8678
|
import {
|
|
8348
|
-
HcmClient as
|
|
8679
|
+
HcmClient as HcmClient22,
|
|
8349
8680
|
ReconLayout,
|
|
8350
8681
|
ROUND_EXIT_CODES,
|
|
8351
8682
|
computeReconSourceKey,
|
|
8352
8683
|
formatObject as formatObject23,
|
|
8353
|
-
fromAxiosError as
|
|
8684
|
+
fromAxiosError as fromAxiosError21,
|
|
8354
8685
|
httpProbe as httpProbe2,
|
|
8355
8686
|
inspectRound,
|
|
8356
8687
|
renderRound,
|
|
@@ -8360,7 +8691,7 @@ var DEFAULT_CAPABILITIES2 = "default";
|
|
|
8360
8691
|
async function deliveryReconCommand(args) {
|
|
8361
8692
|
try {
|
|
8362
8693
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
8363
|
-
const client3 =
|
|
8694
|
+
const client3 = HcmClient22.fromAuthContext(ctx);
|
|
8364
8695
|
const probe = httpProbe2(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES2);
|
|
8365
8696
|
const sourceKey = await computeReconSourceKey(probe);
|
|
8366
8697
|
const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
|
|
@@ -8372,7 +8703,7 @@ async function deliveryReconCommand(args) {
|
|
|
8372
8703
|
process.stdout.write(formatObject23(summary, { format: args.output ?? "json" }) + "\n");
|
|
8373
8704
|
} catch (e) {
|
|
8374
8705
|
const err = e;
|
|
8375
|
-
if (err?.isAxiosError) exitWithError(
|
|
8706
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError21(err, args.env));
|
|
8376
8707
|
exitWithError(e);
|
|
8377
8708
|
process.exit(1);
|
|
8378
8709
|
}
|
|
@@ -8470,7 +8801,7 @@ import {
|
|
|
8470
8801
|
DRY_RUN_TAIL,
|
|
8471
8802
|
DriftDetected,
|
|
8472
8803
|
FORCE_STALE_FLAG,
|
|
8473
|
-
HcmClient as
|
|
8804
|
+
HcmClient as HcmClient23,
|
|
8474
8805
|
fetchReconIdentity as fetchReconIdentity2,
|
|
8475
8806
|
INIT_EXIT_CODES,
|
|
8476
8807
|
JOURNAL_STOP_KINDS,
|
|
@@ -8610,7 +8941,7 @@ async function authOrSignpost(args, cmd) {
|
|
|
8610
8941
|
}
|
|
8611
8942
|
async function deliverySeedPlanCommand(args) {
|
|
8612
8943
|
const ctx = await authOrSignpost(args, "plan");
|
|
8613
|
-
const client3 =
|
|
8944
|
+
const client3 = HcmClient23.fromAuthContext(ctx);
|
|
8614
8945
|
process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
|
|
8615
8946
|
}
|
|
8616
8947
|
function seedClient(client3, ctx) {
|
|
@@ -8784,7 +9115,7 @@ async function runSeedApply(args, client3) {
|
|
|
8784
9115
|
}
|
|
8785
9116
|
async function deliverySeedApplyCommand(args) {
|
|
8786
9117
|
const ctx = await authOrSignpost(args, "apply");
|
|
8787
|
-
const client3 =
|
|
9118
|
+
const client3 = HcmClient23.fromAuthContext(ctx);
|
|
8788
9119
|
process.exitCode = await runSeedApply(args, seedClient(client3, ctx));
|
|
8789
9120
|
}
|
|
8790
9121
|
async function runSeedVerify(args, client3) {
|
|
@@ -8808,7 +9139,7 @@ async function deliverySeedVerifyCommand(args) {
|
|
|
8808
9139
|
return;
|
|
8809
9140
|
}
|
|
8810
9141
|
const ctx = await authOrSignpost(args, "verify");
|
|
8811
|
-
const client3 =
|
|
9142
|
+
const client3 = HcmClient23.fromAuthContext(ctx);
|
|
8812
9143
|
process.exitCode = await runSeedVerify(args, await seedVerifyClient(client3, ctx));
|
|
8813
9144
|
}
|
|
8814
9145
|
|
|
@@ -8923,7 +9254,7 @@ import {
|
|
|
8923
9254
|
CHANGE_STATES,
|
|
8924
9255
|
CHANGE_UNKNOWN,
|
|
8925
9256
|
CODE_WORDS,
|
|
8926
|
-
HcmClient as
|
|
9257
|
+
HcmClient as HcmClient24,
|
|
8927
9258
|
INIT_EXIT_CODES as INIT_EXIT_CODES3,
|
|
8928
9259
|
META_WRITE_STEPS,
|
|
8929
9260
|
META_VERIFY_STEPS,
|
|
@@ -9151,7 +9482,7 @@ function lowerCaseHeaders2(headers) {
|
|
|
9151
9482
|
}
|
|
9152
9483
|
async function deliveryMetaCommand(args) {
|
|
9153
9484
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
9154
|
-
const client3 =
|
|
9485
|
+
const client3 = HcmClient24.fromAuthContext(ctx);
|
|
9155
9486
|
process.exitCode = await runDeliveryMeta(
|
|
9156
9487
|
{ ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
|
|
9157
9488
|
metaClient(client3, ctx)
|
|
@@ -9163,7 +9494,7 @@ init_auth_guard();
|
|
|
9163
9494
|
init_exit();
|
|
9164
9495
|
import {
|
|
9165
9496
|
computeReconSourceKey as computeReconSourceKey2,
|
|
9166
|
-
HcmClient as
|
|
9497
|
+
HcmClient as HcmClient25,
|
|
9167
9498
|
httpProbe as httpProbe3,
|
|
9168
9499
|
ReconLayout as ReconLayout2,
|
|
9169
9500
|
runTriageRound
|
|
@@ -9219,7 +9550,7 @@ async function runTriage(args) {
|
|
|
9219
9550
|
return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
|
|
9220
9551
|
}
|
|
9221
9552
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
9222
|
-
const client3 =
|
|
9553
|
+
const client3 = HcmClient25.fromAuthContext(ctx);
|
|
9223
9554
|
const probe = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES4);
|
|
9224
9555
|
const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe)).dir;
|
|
9225
9556
|
const result = await runTriageRound(probe, artifactsDir, entriesIn);
|
|
@@ -9245,10 +9576,10 @@ async function deliveryTriageCommand(args) {
|
|
|
9245
9576
|
|
|
9246
9577
|
// src/commands/delivery-execution.ts
|
|
9247
9578
|
import { createHash as createHash5, randomBytes as secureRandomBytes } from "crypto";
|
|
9248
|
-
import { spawn } from "child_process";
|
|
9579
|
+
import { spawn as spawn2 } from "child_process";
|
|
9249
9580
|
import { createReadStream, promises as fs7 } from "fs";
|
|
9250
9581
|
import path11 from "path";
|
|
9251
|
-
import { CliError as
|
|
9582
|
+
import { CliError as CliError21, CliErrorCode as CliErrorCode20, formatObject as formatObject25 } from "@hcmai/sdk";
|
|
9252
9583
|
init_exit();
|
|
9253
9584
|
var EXECUTION_CONTRACT_VERSION = "2026-08-29.controlled-v3";
|
|
9254
9585
|
var DEFAULT_TTL_SECONDS = 15 * 60;
|
|
@@ -9626,9 +9957,7 @@ var IMPLICIT_DIR_COMMANDS = { "workspace push": "." };
|
|
|
9626
9957
|
var TOOLING_DIRS = [".git", "node_modules", ".hcm-delivery", "evidence"];
|
|
9627
9958
|
var POSITIONAL_PAYLOAD_COMMANDS = { import: 1 };
|
|
9628
9959
|
function normalizeCommandArgv(argv) {
|
|
9629
|
-
|
|
9630
|
-
while (argv[start] === "--") start += 1;
|
|
9631
|
-
return argv.slice(start);
|
|
9960
|
+
return normalizeAssessedArgv(argv);
|
|
9632
9961
|
}
|
|
9633
9962
|
async function bindPayloadFiles(project, argv) {
|
|
9634
9963
|
const bound = [];
|
|
@@ -9751,7 +10080,7 @@ async function runCurrentCliCommand(argv, cwd, streams) {
|
|
|
9751
10080
|
const entry = process.argv[1];
|
|
9752
10081
|
if (!entry) throw invalid2("\u65E0\u6CD5\u89E3\u6790\u5F53\u524D CLI entry");
|
|
9753
10082
|
return new Promise((resolve4, reject) => {
|
|
9754
|
-
const child =
|
|
10083
|
+
const child = spawn2(process.execPath, [entry, ...argv], {
|
|
9755
10084
|
cwd,
|
|
9756
10085
|
env: process.env,
|
|
9757
10086
|
shell: false,
|
|
@@ -9894,7 +10223,7 @@ async function sha256File(file) {
|
|
|
9894
10223
|
return hash.digest("hex");
|
|
9895
10224
|
}
|
|
9896
10225
|
function invalid2(message, cause) {
|
|
9897
|
-
return new
|
|
10226
|
+
return new CliError21({ code: CliErrorCode20.INVALID_ARGUMENT, message, cause });
|
|
9898
10227
|
}
|
|
9899
10228
|
function nextCommandHint(planId, project, argv) {
|
|
9900
10229
|
const quoted = argv.map((a) => /[\s"'$`\\]/.test(a) ? `'${a.replace(/'/g, `'\\''`)}'` : a);
|
|
@@ -9906,25 +10235,25 @@ function nextCommandHint(planId, project, argv) {
|
|
|
9906
10235
|
init_auth_guard();
|
|
9907
10236
|
init_exit();
|
|
9908
10237
|
import {
|
|
9909
|
-
HcmClient as
|
|
10238
|
+
HcmClient as HcmClient26,
|
|
9910
10239
|
adminResetPassword,
|
|
9911
10240
|
formatObject as formatObject26,
|
|
9912
|
-
fromAxiosError as
|
|
9913
|
-
CliError as
|
|
9914
|
-
CliErrorCode as
|
|
10241
|
+
fromAxiosError as fromAxiosError22,
|
|
10242
|
+
CliError as CliError22,
|
|
10243
|
+
CliErrorCode as CliErrorCode21
|
|
9915
10244
|
} from "@hcmai/sdk";
|
|
9916
10245
|
function buildAdminResetPasswordRequest(args, password) {
|
|
9917
10246
|
const hasId = Boolean(args.id);
|
|
9918
10247
|
const hasUsername = Boolean(args.username);
|
|
9919
10248
|
if (hasId === hasUsername) {
|
|
9920
|
-
throw new
|
|
9921
|
-
code:
|
|
10249
|
+
throw new CliError22({
|
|
10250
|
+
code: CliErrorCode21.INVALID_ARGUMENT,
|
|
9922
10251
|
message: "--id <uuid> \u4E0E --username <user> \u5FC5\u987B\u4E14\u53EA\u80FD\u63D0\u4F9B\u4E00\u4E2A"
|
|
9923
10252
|
});
|
|
9924
10253
|
}
|
|
9925
10254
|
if (!password) {
|
|
9926
|
-
throw new
|
|
9927
|
-
code:
|
|
10255
|
+
throw new CliError22({
|
|
10256
|
+
code: CliErrorCode21.INVALID_ARGUMENT,
|
|
9928
10257
|
message: "\u65B0\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
|
|
9929
10258
|
});
|
|
9930
10259
|
}
|
|
@@ -9940,12 +10269,12 @@ async function userResetPasswordCommand(args) {
|
|
|
9940
10269
|
try {
|
|
9941
10270
|
const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
|
|
9942
10271
|
const request = buildAdminResetPasswordRequest(args, password);
|
|
9943
|
-
const client3 =
|
|
10272
|
+
const client3 = HcmClient26.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
9944
10273
|
const result = await adminResetPassword(client3.raw(), request);
|
|
9945
10274
|
process.stdout.write(formatObject26(result, { format: args.output ?? "json" }) + "\n");
|
|
9946
10275
|
} catch (cause) {
|
|
9947
10276
|
const err = cause;
|
|
9948
|
-
if (err?.isAxiosError) exitWithError(
|
|
10277
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError22(err, args.env));
|
|
9949
10278
|
exitWithError(cause);
|
|
9950
10279
|
}
|
|
9951
10280
|
}
|
|
@@ -9953,8 +10282,8 @@ async function promptPasswordTwice() {
|
|
|
9953
10282
|
const password = await promptSecret("\u65B0\u5BC6\u7801: ");
|
|
9954
10283
|
const confirmation = await promptSecret("\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ");
|
|
9955
10284
|
if (password !== confirmation) {
|
|
9956
|
-
throw new
|
|
9957
|
-
code:
|
|
10285
|
+
throw new CliError22({
|
|
10286
|
+
code: CliErrorCode21.INVALID_ARGUMENT,
|
|
9958
10287
|
message: "\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4"
|
|
9959
10288
|
});
|
|
9960
10289
|
}
|
|
@@ -9965,13 +10294,13 @@ async function promptPasswordTwice() {
|
|
|
9965
10294
|
init_exit();
|
|
9966
10295
|
init_auth_guard();
|
|
9967
10296
|
import {
|
|
9968
|
-
HcmClient as
|
|
10297
|
+
HcmClient as HcmClient27,
|
|
9969
10298
|
formatObject as formatObject27,
|
|
9970
|
-
fromAxiosError as
|
|
10299
|
+
fromAxiosError as fromAxiosError23
|
|
9971
10300
|
} from "@hcmai/sdk";
|
|
9972
10301
|
async function modelsCommand(keyword, args) {
|
|
9973
10302
|
try {
|
|
9974
|
-
const client3 =
|
|
10303
|
+
const client3 = HcmClient27.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
9975
10304
|
const all = await client3.listModels();
|
|
9976
10305
|
const needle = keyword?.trim().toLowerCase();
|
|
9977
10306
|
const rows = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
|
|
@@ -10001,7 +10330,7 @@ async function modelsCommand(keyword, args) {
|
|
|
10001
10330
|
process.exit(0);
|
|
10002
10331
|
} catch (e) {
|
|
10003
10332
|
const err = e;
|
|
10004
|
-
if (err?.isAxiosError) exitWithError(
|
|
10333
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError23(err, args.profile));
|
|
10005
10334
|
exitWithError(e);
|
|
10006
10335
|
}
|
|
10007
10336
|
}
|
|
@@ -10184,7 +10513,8 @@ tenant.command("bootstrap").description("\u5F00\u901A\u65B0\u79DF\u6237\uFF08\u5
|
|
|
10184
10513
|
var meta = program.command("meta").description("\u79DF\u6237\u5143\u6570\u636E\u8BFB\u5199\uFF08\u9875\u9762/\u5B57\u6BB5/\u5217\u8868\u914D\u7F6E\uFF09");
|
|
10185
10514
|
meta.command("list").description("\u5217\u51FA\u79DF\u6237\u5143\u6570\u636E\u6587\u4EF6").option("--keyword <kw>", "\u641C\u7D22\u5173\u952E\u8BCD").option("--type <type>", "\u7C7B\u578B\uFF1Ayml | properties | all", "all").option("--page <n>", "\u9875\u7801\uFF08\u4ECE 0 \u5F00\u59CB\uFF09").option("--page-size <n>", "\u6BCF\u9875\u6761\u6570").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => metaListCommand(opts));
|
|
10186
10515
|
meta.command("get <path>").description("\u6253\u5370 meta \u539F\u6587\uFF08\u5982 metas/Employee.list.yml\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").action((p, opts) => metaGetCommand(p, opts));
|
|
10187
|
-
meta.command("set <path>").description("\u5199\u5165 meta \u539F\u6587\
|
|
10516
|
+
meta.command("set <path>").description("\u5199\u5165 meta \u539F\u6587\uFF1A\u5199\u524D\u6309 schema \u9A8C\u7C7B\u578B \u2192 \u5199\u5165 \u2192 \u6E05\u7F13\u5B58\u540E\u771F\u8BFB\u4E00\u904D\uFF08\u8BFB\u4E0D\u52A8\u5C31\u62A5\u5E76\u7ED9\u6062\u590D\u547D\u4EE4\uFF09").requiredOption("--file <file>", "\u4ECE\u6587\u4EF6\u8BFB\u53D6\u539F\u6587\uFF08- \u8868\u793A stdin\uFF09").option("--dry-run", "\u53EA\u663E\u793A\u5C06\u5199\u5165\u7684\u5185\u5BB9\uFF0C\u4E0D\u5B9E\u9645\u5199\u5165").option("--skip-validate", "\u8DF3\u8FC7\u5199\u524D schema \u7C7B\u578B\u6821\u9A8C\uFF08schema \u526F\u672C\u65E7\u4E86\u65F6\u7684\u9003\u751F\u95E8\uFF09").option("--no-verify", "\u4E0D\u505A\u5199\u540E\u81EA\u8BC1\u3002\u26A0\uFE0F \u300C\u5199\u5165\u6210\u529F\u300D\u53EA\u8BF4\u660E\u5B57\u8282\u6536\u4E0B\u4E86\uFF0C\u4E0D\u8BF4\u660E\u670D\u52A1\u7AEF\u8BFB\u5F97\u52A8").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((p, opts) => metaSetCommand(p, opts));
|
|
10517
|
+
meta.command("validate <path>").description("\u96F6\u7F51\u7EDC\uFF1A\u6309 core \u4ED3\u7684 JSON Schema \u9A8C\u4E00\u4EFD meta \u539F\u6587\uFF08path \u53EA\u7528\u6765\u6311 schema\uFF0C\u4E0D\u53D1\u8BF7\u6C42\uFF09").requiredOption("--file <file>", "\u8981\u9A8C\u7684\u539F\u6587\uFF08- \u8868\u793A stdin\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((p, opts) => metaValidateCommand(p, opts));
|
|
10188
10518
|
meta.command("delete <path>").description("\u5220\u9664 meta\uFF08\u4E0D\u53EF\u9006\uFF0C\u9ED8\u8BA4\u8FC7\u786E\u8BA4\u95F8\uFF09").option("-y, --yes", "\u8DF3\u8FC7\u786E\u8BA4").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((p, opts) => metaDeleteCommand(p, opts));
|
|
10189
10519
|
var skills = program.command("skills").description("\u4EA4\u4ED8\u6280\u80FD\uFF1A\u777F\u620E Chiron \u6280\u80FD\u5E93 + CLI \u81EA\u5E26\u6280\u80FD\uFF08\u514D\u8BA4\u8BC1\uFF0C\u65E0\u9700\u5148 login\uFF09");
|
|
10190
10520
|
skills.command("list [keyword]").description("\u5217\u51FA\u76EE\u6807\u73AF\u5883\u8FD9\u4E00\u7248\u7684\u4EA4\u4ED8\u6280\u80FD\uFF1B--installed \u6539\u770B\u672C\u5730\u88C5\u4E86\u54EA\u4E9B\uFF08\u4E0D\u8FDE\u7F51\uFF09").option("--installed", "\u53EA\u770B\u672C\u5730\u5DF2\u88C5\u7684\u6280\u80FD\uFF08\u8BFB .hcm-skills.json\uFF0C\u4E0D\u8FDE\u7F51\uFF09").option("--target <agent>", "\u914D\u5408 --installed\uFF1Aclaude | codex | auto", "auto").option("--global", "\u914D\u5408 --installed\uFF1A\u770B\u7528\u6237\u7EA7\u76EE\u5F55").option("--dir <path>", "\u914D\u5408 --installed\uFF1A\u770B\u6307\u5B9A\u76EE\u5F55").option("--category <key>", "\u53EA\u770B\u67D0\u4E2A\u5206\u7C7B").option("--stage <key>", "\u53EA\u770B\u67D0\u4E2A\u4EA4\u4ED8\u9636\u6BB5\uFF1Ahandover | baseline | configure | migrate | integrate | golive | operate").option("--by-stage", "\u6309\u4EA4\u4ED8\u751F\u547D\u5468\u671F\u5206\u7EC4\u5C55\u793A\uFF08\u9ED8\u8BA4\u6309\u529F\u80FD\u5206\u7C7B\uFF09").option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6 activeEnv \u7684 endpoint\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((kw, opts) => skillsListCommand(kw, opts));
|
|
@@ -10195,6 +10525,7 @@ skills.command("update").description("\u628A\u88C5\u8FC7\u7684\u6280\u80FD\u5347
|
|
|
10195
10525
|
program.command("update <Model>").description("\u66F4\u65B0\u4E00\u6761 Model \u8BB0\u5F55\uFF08\u8D70\u540E\u7AEF\u5B8C\u6574\u6821\u9A8C\uFF09\u3002\u5347\u7EA7 CLI \u8BF7\u7528 `hcm upgrade`").requiredOption("--id <id>", "\u8BB0\u5F55 ID").option("--data <JSON>", `\u8981\u66F4\u65B0\u7684\u5B57\u6BB5 JSON\uFF0C\u4F8B\u5982 '{"name":"\u65B0\u540D\u79F0"}'`).option("--data-file <path>", "\u4ECE UTF-8 JSON \u6587\u4EF6\u8BFB\u53D6\u66F4\u65B0\u5B57\u6BB5\uFF08\u4E0E --data \u4E92\u65A5\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").option("--i18n", "\u591A\u8BED\u8A00\u5B57\u6BB5\u6309 Map \u5B8C\u6574\u66FF\u6362\uFF08\u952E\u7528 zh-CN / en-US \u8FDE\u5B57\u7B26\u5F62\uFF09\uFF1B\u4E0D\u4F20\u5219\u6309\u5B57\u7B26\u4E32\u53EA\u6539\u5F53\u524D\u8BED\u8A00").action((model, opts) => updateCommand(model, opts));
|
|
10196
10526
|
program.command("version").description("\u67E5 CLI \u4E0E\u540E\u7AEF\u4E24\u4E2A\u7248\u672C\uFF08commit / tag / \u6784\u5EFA\u65F6\u95F4\uFF09\u2014\u2014\u514D\u8BA4\u8BC1\uFF0C\u65E0\u9700\u5148 login").option("--endpoint <url>", "\u540E\u7AEF\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6 activeEnv \u7684 endpoint\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => versionCommand(opts));
|
|
10197
10527
|
program.command("upgrade").alias("self-update").description("\u5347\u7EA7 CLI \u81EA\u5DF1\uFF08\u6CE8\u610F\uFF1A`hcm update` \u662F\u66F4\u65B0\u4E1A\u52A1\u8BB0\u5F55\uFF0C\u4E0D\u662F\u5347\u7EA7\uFF09").option("--check", "\u53EA\u68C0\u67E5\uFF1B\u6709\u65B0\u7248\u672C\u65F6\u4EE5\u9000\u51FA\u7801 1 \u7ED3\u675F\uFF0C\u4FBF\u4E8E\u811A\u672C\u5224\u65AD").action((opts) => upgradeCommand(opts));
|
|
10528
|
+
program.command("open [path]").description("\u7528\u5F53\u524D CLI \u8EAB\u4EFD\u6253\u5F00\u524D\u7AEF\u9875\u9762\uFF1A\u94F8\u4E00\u5F20 60s \u4E00\u6B21\u6027\u7968\u636E\u4EA4\u7ED9\u6D4F\u89C8\u5668\uFF0C\u4F1A\u8BDD token \u4E0D\u8FDB URL").option("--print-url", "\u53EA\u6253\u5370\u767B\u5F55 URL\uFF0C\u4E0D\u5F00\u6D4F\u89C8\u5668\uFF08\u7ED9 agent \u6D4F\u89C8\u5668 navigate \u7528\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").action((path12, opts) => openCommand(path12, opts));
|
|
10198
10529
|
var setting = program.command("setting").description("\u79DF\u6237\u7CFB\u7EDF\u53C2\u6570\uFF08\u767B\u5F55\u7B56\u7565 / \u5BC6\u7801\u7B56\u7565 / \u529F\u80FD\u5F00\u5173 / \u96C6\u6210\u53C2\u6570\uFF09");
|
|
10199
10530
|
setting.command("get <domain>").description("\u8BFB\u67D0\u57DF\u53C2\u6570\uFF08\u5B9A\u4E49 + \u79DF\u6237\u8986\u76D6\u503C\u5408\u5E76\uFF0C\u7F3A\u5931\u56DE\u843D\u9ED8\u8BA4\u503C\uFF09").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((d, opts) => settingGetCommand(d, opts));
|
|
10200
10531
|
setting.command("set <domain>").description("\u6539\u53C2\u6570\uFF0C\u53EF\u91CD\u590D --set\uFF1B\u8D70\u53D7\u63A7\u6821\u9A8C\u8DEF\u5F84\u800C\u975E\u6807\u51C6 CRUD").option("--set <assignment...>", "namespace.key=value\uFF0C\u4F8B\u5982 security.password.passwordPolicy=complex").option("--dry-run", "\u53EA\u663E\u793A\u5C06\u5199\u5165\u4EC0\u4E48\uFF0C\u4E0D\u5B9E\u9645\u5199\u5165").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((d, opts) => settingSetCommand(d, opts));
|