@hcmai/cli 0.4.25 → 0.4.27
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 +321 -45
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +7 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -66,6 +66,15 @@ async function ensureActiveAuth(args) {
|
|
|
66
66
|
envName
|
|
67
67
|
);
|
|
68
68
|
let idMeta = await loadIdentity3(identityName);
|
|
69
|
+
if (idMeta.env !== envName) {
|
|
70
|
+
throw new CliError5({
|
|
71
|
+
code: CliErrorCode4.IDENTITY_NOT_IN_ENV,
|
|
72
|
+
message: `identity '${identityName}' \u5C5E\u4E8E env '${idMeta.env}'\uFF0C\u4E0D\u662F\u5F53\u524D\u7684 '${envName}'\u3002\u7EE7\u7EED\u6267\u884C\u4F1A\u62FF\u7740 '${envName}' \u7684\u5730\u5740\u914D '${idMeta.env}' \u7684\u51ED\u636E\u53D1\u8BF7\u6C42\u3002`,
|
|
73
|
+
context: {
|
|
74
|
+
nextStep: `hcm identity list --env ${envName} \u770B\u8FD9\u4E2A\u73AF\u5883\u6709\u54EA\u4E9B\u8EAB\u4EFD\uFF1B\u6216 hcm login --env ${envName} \u91CD\u767B`
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
69
78
|
const slid = await ensureSessionFresh({
|
|
70
79
|
endpoint: envCfg.endpoint,
|
|
71
80
|
identity: identityName,
|
|
@@ -1972,7 +1981,6 @@ import {
|
|
|
1972
1981
|
loginPairing,
|
|
1973
1982
|
loginPat,
|
|
1974
1983
|
loginPassword,
|
|
1975
|
-
inferEnvName,
|
|
1976
1984
|
toOrigin,
|
|
1977
1985
|
changePassword,
|
|
1978
1986
|
detectPasswordChangeChallenge,
|
|
@@ -1980,8 +1988,12 @@ import {
|
|
|
1980
1988
|
saveEnv,
|
|
1981
1989
|
saveIdentity,
|
|
1982
1990
|
loadIdentity,
|
|
1991
|
+
listIdentities,
|
|
1992
|
+
deleteIdentity,
|
|
1983
1993
|
loadGlobalConfig,
|
|
1984
1994
|
saveGlobalConfig,
|
|
1995
|
+
TEMP_ENV_NAME,
|
|
1996
|
+
isTempEnv,
|
|
1985
1997
|
TokenStore,
|
|
1986
1998
|
isServerSlidingSession,
|
|
1987
1999
|
CliError as CliError2,
|
|
@@ -2134,6 +2146,50 @@ async function migrateProfileTokenToIdentity(envName, identityName) {
|
|
|
2134
2146
|
throw err;
|
|
2135
2147
|
}
|
|
2136
2148
|
}
|
|
2149
|
+
async function discardTempEnvSessions() {
|
|
2150
|
+
const ids = await listIdentities(TEMP_ENV_NAME).catch(() => []);
|
|
2151
|
+
for (const id of ids) {
|
|
2152
|
+
const store = TokenStore.forIdentity(id);
|
|
2153
|
+
const meta2 = await store.readMeta().catch(() => null);
|
|
2154
|
+
const hadServerSession = meta2 != null && isServerSlidingSession(meta2.scheme) && Boolean(meta2.accessTokenRef);
|
|
2155
|
+
const revoked = await revokeOnServer(store, TEMP_ENV_NAME).catch(() => false);
|
|
2156
|
+
if (hadServerSession && !revoked) {
|
|
2157
|
+
process.stderr.write(
|
|
2158
|
+
`[hcm] event=temp_session_revoke_unconfirmed identity=${id} hint="\u4E0A\u4E00\u6761\u4E34\u65F6\u4F1A\u8BDD\u53EF\u80FD\u4ECD\u7136\u6709\u6548\u76F4\u81F3\u81EA\u7136\u8FC7\u671F"
|
|
2159
|
+
`
|
|
2160
|
+
);
|
|
2161
|
+
}
|
|
2162
|
+
await store.clear().catch(() => void 0);
|
|
2163
|
+
await deleteIdentity(id).catch(() => void 0);
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
function assertPairingAddressBelongsToEnv(envName, cfg, pairingOrigin) {
|
|
2167
|
+
const originOf = (u) => {
|
|
2168
|
+
if (!u) return null;
|
|
2169
|
+
try {
|
|
2170
|
+
return new URL(u).origin;
|
|
2171
|
+
} catch {
|
|
2172
|
+
return null;
|
|
2173
|
+
}
|
|
2174
|
+
};
|
|
2175
|
+
const endpointOrigin = originOf(cfg.endpoint);
|
|
2176
|
+
const frontendOrigin = originOf(cfg.frontend);
|
|
2177
|
+
if (pairingOrigin === endpointOrigin || pairingOrigin === frontendOrigin) return;
|
|
2178
|
+
if (frontendOrigin) {
|
|
2179
|
+
throw new CliError2({
|
|
2180
|
+
code: CliErrorCode.INVALID_ARGUMENT,
|
|
2181
|
+
message: `env '${envName}' \u7684\u5730\u5740\u662F ${endpointOrigin} / ${frontendOrigin}\uFF0C\u4E0E\u4F60\u7C98\u8D34\u7684 ${pairingOrigin} \u90FD\u4E0D\u5339\u914D\u3002\u914D\u5BF9\u7801\u662F\u4E00\u6B21\u6027\u51ED\u636E\uFF0C\u4E0D\u80FD\u53D1\u5230\u4E00\u53F0\u8FD9\u4E2A env \u4E0D\u8BA4\u8BC6\u7684\u670D\u52A1\u5668\u4E0A\u3002`,
|
|
2182
|
+
context: {
|
|
2183
|
+
nextStep: `\u53BB\u6389 --env ${envName}\uFF08\u672C\u6B21\u4F1A\u843D\u5230\u4E34\u65F6\u73AF\u5883\uFF09\uFF0C\u6216\u6362\u6210\u5730\u5740\u5339\u914D\u7684\u90A3\u4E2A env`
|
|
2184
|
+
}
|
|
2185
|
+
});
|
|
2186
|
+
}
|
|
2187
|
+
process.stderr.write(
|
|
2188
|
+
`[hcm] \u914D\u5BF9\u7801\u5C06\u53D1\u5F80 ${endpointOrigin}\uFF08env '${envName}' \u7684 endpoint\uFF09\uFF0C\u800C\u4F60\u7C98\u8D34\u7684\u662F ${pairingOrigin}\u3002\u8BE5 env \u6CA1\u6709\u8BB0 frontend\uFF0C\u65E0\u6CD5\u6838\u5BF9\u4E24\u8005\u662F\u5426\u540C\u6E90\u3002
|
|
2189
|
+
[hcm] \u5982\u679C\u8FD9\u4E0D\u662F\u4F60\u8981\u7684\uFF0C\u73B0\u5728 Ctrl-C\uFF1B\u6838\u5BF9\u65E0\u8BEF\u53EF\u4EE5 hcm env edit frontend ${pairingOrigin} \u8BB0\u4E0B\u6765\uFF0C\u4EE5\u540E\u5C31\u80FD\u81EA\u52A8\u6838\u5BF9\u3002
|
|
2190
|
+
`
|
|
2191
|
+
);
|
|
2192
|
+
}
|
|
2137
2193
|
async function loginCommand(args) {
|
|
2138
2194
|
if (args.profile && args.env) {
|
|
2139
2195
|
process.stderr.write(
|
|
@@ -2147,18 +2203,20 @@ async function loginCommand(args) {
|
|
|
2147
2203
|
}
|
|
2148
2204
|
const g = await loadGlobalConfig();
|
|
2149
2205
|
const pairingOrigin = args.code ? toOrigin(args.endpointArg ?? args.endpoint ?? "") : null;
|
|
2150
|
-
const envName = args.env ?? (pairingOrigin ?
|
|
2206
|
+
const envName = args.env ?? (pairingOrigin ? TEMP_ENV_NAME : g.activeEnv);
|
|
2207
|
+
const usingTempEnv = Boolean(pairingOrigin) && isTempEnv(envName);
|
|
2208
|
+
const previousActiveEnv = g.activeEnv;
|
|
2151
2209
|
try {
|
|
2152
2210
|
let envCfg = await loadEnv(envName).catch(() => null);
|
|
2153
|
-
|
|
2154
|
-
|
|
2211
|
+
let tempEnvPending = false;
|
|
2212
|
+
if (pairingOrigin && usingTempEnv) {
|
|
2213
|
+
envCfg = { endpoint: pairingOrigin, frontend: pairingOrigin };
|
|
2214
|
+
tempEnvPending = true;
|
|
2215
|
+
} else if (pairingOrigin && !envCfg) {
|
|
2216
|
+
envCfg = { endpoint: pairingOrigin, frontend: pairingOrigin };
|
|
2155
2217
|
await saveEnv(envName, envCfg);
|
|
2156
|
-
}
|
|
2157
|
-
|
|
2158
|
-
throw new CliError2({
|
|
2159
|
-
code: CliErrorCode.INVALID_ARGUMENT,
|
|
2160
|
-
message: `env '${envName}' \u5DF2\u5B58\u5728\u4E14\u6307\u5411 ${envCfg.endpoint}\uFF0C\u4E0E\u672C\u6B21\u7684 ${pairingOrigin} \u4E0D\u540C\u3002\u7528 --env <name> \u663E\u5F0F\u6307\u5B9A\u4E00\u4E2A\u65B0\u540D\u5B57\u3002`
|
|
2161
|
-
});
|
|
2218
|
+
} else if (pairingOrigin && envCfg) {
|
|
2219
|
+
assertPairingAddressBelongsToEnv(envName, envCfg, pairingOrigin);
|
|
2162
2220
|
}
|
|
2163
2221
|
if (!envCfg) {
|
|
2164
2222
|
const endpoint2 = args.endpoint ?? await promptText("endpoint: ");
|
|
@@ -2194,6 +2252,10 @@ async function loginCommand(args) {
|
|
|
2194
2252
|
profile: envName,
|
|
2195
2253
|
httpClient: http
|
|
2196
2254
|
});
|
|
2255
|
+
if (tempEnvPending) {
|
|
2256
|
+
await discardTempEnvSessions();
|
|
2257
|
+
await saveEnv(envName, envCfg);
|
|
2258
|
+
}
|
|
2197
2259
|
scheme = "pairing";
|
|
2198
2260
|
scopes = record.scopes;
|
|
2199
2261
|
principal = p;
|
|
@@ -2277,17 +2339,24 @@ async function loginCommand(args) {
|
|
|
2277
2339
|
ttlSeconds: newMeta?.ttlSeconds
|
|
2278
2340
|
};
|
|
2279
2341
|
await saveIdentity(idName, identityMeta);
|
|
2280
|
-
if (principal?.tenantId
|
|
2281
|
-
|
|
2342
|
+
if (principal?.tenantId) {
|
|
2343
|
+
const actualTenant = String(principal.tenantId);
|
|
2344
|
+
const askedTenant = args.tenant ? String(args.tenant) : void 0;
|
|
2345
|
+
const recordedTenant = envCfg.tenantId ? String(envCfg.tenantId) : void 0;
|
|
2346
|
+
if (askedTenant && askedTenant !== actualTenant) {
|
|
2282
2347
|
process.stderr.write(
|
|
2283
|
-
`[hcm] WARNING: \u8BF7\u6C42\u7684\u79DF\u6237\u662F ${
|
|
2348
|
+
`[hcm] WARNING: \u8BF7\u6C42\u7684\u79DF\u6237\u662F ${askedTenant}\uFF0C\u4F46 token \u5B9E\u9645\u5F52\u5C5E\u79DF\u6237 ${actualTenant}\u3002\u540E\u7EED\u547D\u4EE4\u6309 ${actualTenant} \u6267\u884C\u3002
|
|
2284
2349
|
`
|
|
2285
2350
|
);
|
|
2286
|
-
} else {
|
|
2287
|
-
envCfg.tenantId =
|
|
2351
|
+
} else if (recordedTenant !== actualTenant) {
|
|
2352
|
+
envCfg.tenantId = actualTenant;
|
|
2288
2353
|
await saveEnv(envName, envCfg);
|
|
2289
|
-
|
|
2290
|
-
|
|
2354
|
+
if (recordedTenant !== void 0) {
|
|
2355
|
+
process.stderr.write(
|
|
2356
|
+
`[hcm] env ${envName} \u7684\u79DF\u6237\u5DF2\u4ECE ${recordedTenant} \u6539\u8BB0\u4E3A ${actualTenant}\uFF08token \u5F52\u5C5E\uFF09\u3002
|
|
2357
|
+
`
|
|
2358
|
+
);
|
|
2359
|
+
}
|
|
2291
2360
|
}
|
|
2292
2361
|
}
|
|
2293
2362
|
const shouldActivate = args.activate !== false;
|
|
@@ -2300,9 +2369,16 @@ async function loginCommand(args) {
|
|
|
2300
2369
|
gl.activeEnv = envName;
|
|
2301
2370
|
await saveGlobalConfig(gl);
|
|
2302
2371
|
}
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
);
|
|
2372
|
+
const envLabel = usingTempEnv ? "\u4E34\u65F6\u73AF\u5883(\u672A\u4FDD\u5B58)" : envName;
|
|
2373
|
+
const head = `\u2705 logged in (env=${envLabel}, identity=${idName}, scheme=${scheme}, ${describePrincipal(principal)}, scopes=${scopes.join(" ")})`;
|
|
2374
|
+
if (!usingTempEnv) return exitOk(head);
|
|
2375
|
+
const lines = [head, "", " \u8FD9\u662F\u4E34\u65F6\u73AF\u5883\uFF1A\u4E0B\u6B21 login --code \u4F1A\u76F4\u63A5\u8986\u76D6\u5B83\u3002"];
|
|
2376
|
+
const previousEnvExists = !isTempEnv(previousActiveEnv) && previousActiveEnv !== envName && await loadEnv(previousActiveEnv).catch(() => null) !== null;
|
|
2377
|
+
if (shouldActivate && previousEnvExists) {
|
|
2378
|
+
lines.push(` \u539F\u6765\u7684 activeEnv \u662F '${previousActiveEnv}'\uFF0C\u56DE\u53BB\u7528: hcm env use ${previousActiveEnv}`);
|
|
2379
|
+
}
|
|
2380
|
+
lines.push(" \u60F3\u7559\u7740\u5B83: hcm env save <name>");
|
|
2381
|
+
return exitOk(lines.join("\n"));
|
|
2306
2382
|
} catch (e) {
|
|
2307
2383
|
const err = e;
|
|
2308
2384
|
if (err.isAxiosError) {
|
|
@@ -2350,7 +2426,7 @@ async function revokeOnServer(store, envName) {
|
|
|
2350
2426
|
try {
|
|
2351
2427
|
const meta2 = await store.readMeta();
|
|
2352
2428
|
if (!meta2 || !isServerSlidingSession(meta2.scheme)) return false;
|
|
2353
|
-
const token = await store.
|
|
2429
|
+
const token = await store.getStoredAccessToken();
|
|
2354
2430
|
if (!token) return false;
|
|
2355
2431
|
const envCfg = await loadEnv(envName).catch(() => null);
|
|
2356
2432
|
if (!envCfg?.endpoint) return false;
|
|
@@ -2367,6 +2443,7 @@ async function revokeOnServer(store, envName) {
|
|
|
2367
2443
|
|
|
2368
2444
|
// src/commands/config.ts
|
|
2369
2445
|
import {
|
|
2446
|
+
CREDENTIAL_STORE_MODES,
|
|
2370
2447
|
loadGlobalConfig as loadGlobalConfig3,
|
|
2371
2448
|
saveGlobalConfig as saveGlobalConfig3,
|
|
2372
2449
|
CliError as CliError4,
|
|
@@ -2384,8 +2461,13 @@ import {
|
|
|
2384
2461
|
loadGlobalConfig as loadGlobalConfig2,
|
|
2385
2462
|
saveGlobalConfig as saveGlobalConfig2,
|
|
2386
2463
|
loadIdentity as loadIdentity2,
|
|
2387
|
-
|
|
2388
|
-
|
|
2464
|
+
saveIdentity as saveIdentity2,
|
|
2465
|
+
listIdentities as listIdentities2,
|
|
2466
|
+
deleteIdentity as deleteIdentity2,
|
|
2467
|
+
renameIdentity,
|
|
2468
|
+
assertNotReservedEnvName,
|
|
2469
|
+
TEMP_ENV_NAME as TEMP_ENV_NAME2,
|
|
2470
|
+
isTempEnv as isTempEnv2,
|
|
2389
2471
|
TokenStore as TokenStore2,
|
|
2390
2472
|
CliError as CliError3,
|
|
2391
2473
|
CliErrorCode as CliErrorCode2,
|
|
@@ -2419,7 +2501,9 @@ async function envList() {
|
|
|
2419
2501
|
const cfg = await loadEnv2(name);
|
|
2420
2502
|
return {
|
|
2421
2503
|
active: name === g.activeEnv ? "*" : " ",
|
|
2422
|
-
|
|
2504
|
+
// 临时槽位在列表里如实标出来:它不是使用者起的名字,也随时会被下一次
|
|
2505
|
+
// `login --code` 覆盖 —— 显示成一个普通 env 名会让人以为它是自己建的。
|
|
2506
|
+
name: isTempEnv2(name) ? `${name} (\u4E34\u65F6\xB7\u672A\u4FDD\u5B58)` : name,
|
|
2423
2507
|
endpoint: cfg.endpoint,
|
|
2424
2508
|
frontend: cfg.frontend ?? "(none)",
|
|
2425
2509
|
tenant: cfg.tenantId ?? "1",
|
|
@@ -2441,13 +2525,17 @@ async function envCurrent() {
|
|
|
2441
2525
|
}
|
|
2442
2526
|
const idName = cfg.defaultIdentity ?? "(none)";
|
|
2443
2527
|
const frontend = cfg.frontend ? ` frontend=${cfg.frontend}` : "";
|
|
2444
|
-
|
|
2528
|
+
const head = `\u2192 ${g.activeEnv} ${cfg.endpoint}${frontend} tenant=${cfg.tenantId ?? "1"} identity=${idName}`;
|
|
2529
|
+
if (!isTempEnv2(g.activeEnv)) return exitOk(head);
|
|
2530
|
+
return exitOk(`${head}
|
|
2531
|
+
\u4E34\u65F6\u73AF\u5883\xB7\u672A\u4FDD\u5B58\uFF08\u4E0B\u6B21 login --code \u4F1A\u8986\u76D6\uFF09\u3002\u7559\u7740\u5B83: hcm env save <name>`);
|
|
2445
2532
|
} catch (e) {
|
|
2446
2533
|
exitWithError(e);
|
|
2447
2534
|
}
|
|
2448
2535
|
}
|
|
2449
2536
|
async function envAdd(name, args) {
|
|
2450
2537
|
try {
|
|
2538
|
+
assertNotReservedEnvName(name);
|
|
2451
2539
|
if (!args.endpoint) {
|
|
2452
2540
|
throw new CliError3({
|
|
2453
2541
|
code: CliErrorCode2.ENV_ENDPOINT_REQUIRED,
|
|
@@ -2518,12 +2606,12 @@ async function envRemove(name, args) {
|
|
|
2518
2606
|
return exitOk("aborted");
|
|
2519
2607
|
}
|
|
2520
2608
|
}
|
|
2521
|
-
const ids = await
|
|
2609
|
+
const ids = await listIdentities2(name);
|
|
2522
2610
|
const failed2 = [];
|
|
2523
2611
|
for (const id of ids) {
|
|
2524
2612
|
try {
|
|
2525
2613
|
await TokenStore2.forIdentity(id).clear();
|
|
2526
|
-
await
|
|
2614
|
+
await deleteIdentity2(id);
|
|
2527
2615
|
} catch (err) {
|
|
2528
2616
|
failed2.push(id);
|
|
2529
2617
|
process.stderr.write(
|
|
@@ -2551,7 +2639,7 @@ async function envShow(args) {
|
|
|
2551
2639
|
const g = await loadGlobalConfig2();
|
|
2552
2640
|
const target = args.name ?? g.activeEnv;
|
|
2553
2641
|
const cfg = await loadEnv2(target);
|
|
2554
|
-
const ids = await
|
|
2642
|
+
const ids = await listIdentities2(target);
|
|
2555
2643
|
return exitOk(
|
|
2556
2644
|
toYaml({
|
|
2557
2645
|
name: target,
|
|
@@ -2586,6 +2674,84 @@ async function envEdit(field, value, args) {
|
|
|
2586
2674
|
exitWithError(e);
|
|
2587
2675
|
}
|
|
2588
2676
|
}
|
|
2677
|
+
async function findEquivalentEnvs(cfg, exclude) {
|
|
2678
|
+
const origin = (u) => {
|
|
2679
|
+
if (!u) return "";
|
|
2680
|
+
try {
|
|
2681
|
+
return new URL(u).origin;
|
|
2682
|
+
} catch {
|
|
2683
|
+
return "";
|
|
2684
|
+
}
|
|
2685
|
+
};
|
|
2686
|
+
const mine = new Set([origin(cfg.endpoint), origin(cfg.frontend)].filter(Boolean));
|
|
2687
|
+
const hits = [];
|
|
2688
|
+
for (const name of await listEnvs()) {
|
|
2689
|
+
if (name === exclude || isTempEnv2(name)) continue;
|
|
2690
|
+
const other = await loadEnv2(name).catch(() => null);
|
|
2691
|
+
if (!other) continue;
|
|
2692
|
+
const theirs = [origin(other.endpoint), origin(other.frontend)].filter(Boolean);
|
|
2693
|
+
const sameAddress = theirs.some((o) => mine.has(o));
|
|
2694
|
+
const tenantOf2 = (v) => String(v ?? "1");
|
|
2695
|
+
const sameTenant = tenantOf2(other.tenantId) === tenantOf2(cfg.tenantId);
|
|
2696
|
+
if (sameAddress && sameTenant) hits.push(name);
|
|
2697
|
+
}
|
|
2698
|
+
return hits;
|
|
2699
|
+
}
|
|
2700
|
+
async function envSave(name, args) {
|
|
2701
|
+
try {
|
|
2702
|
+
assertNotReservedEnvName(name);
|
|
2703
|
+
const g = await loadGlobalConfig2();
|
|
2704
|
+
if (!isTempEnv2(g.activeEnv)) {
|
|
2705
|
+
throw new CliError3({
|
|
2706
|
+
code: CliErrorCode2.INVALID_ARGUMENT,
|
|
2707
|
+
message: `\u5F53\u524D\u4E0D\u662F\u4E34\u65F6\u73AF\u5883\uFF08activeEnv='${g.activeEnv}'\uFF09\uFF0C\u6CA1\u6709\u8981\u4FDD\u5B58\u7684\u4E1C\u897F\u3002`,
|
|
2708
|
+
context: {
|
|
2709
|
+
nextStep: `\u4E34\u65F6\u73AF\u5883\u7531 'hcm login <url> --code <\u7801>' \u4EA7\u751F\uFF1B\u5DF2\u5177\u540D\u7684 env \u6539\u914D\u7F6E\u7528 'hcm env edit'`
|
|
2710
|
+
}
|
|
2711
|
+
});
|
|
2712
|
+
}
|
|
2713
|
+
const cfg = await loadEnv2(TEMP_ENV_NAME2);
|
|
2714
|
+
const existing = await loadEnv2(name).catch(() => null);
|
|
2715
|
+
if (existing && !args.force) {
|
|
2716
|
+
throw new CliError3({
|
|
2717
|
+
code: CliErrorCode2.ENV_ALREADY_EXISTS,
|
|
2718
|
+
message: `env '${name}' \u5DF2\u5B58\u5728\uFF08\u6307\u5411 ${existing.endpoint}\uFF09\u3002`,
|
|
2719
|
+
context: { nextStep: `\u6362\u4E2A\u540D\u5B57\uFF0C\u6216\u7528 --force \u8986\u76D6\u5B83\u7684\u914D\u7F6E` }
|
|
2720
|
+
});
|
|
2721
|
+
}
|
|
2722
|
+
const twins = await findEquivalentEnvs(cfg, name);
|
|
2723
|
+
if (twins.length > 0) {
|
|
2724
|
+
process.stderr.write(
|
|
2725
|
+
`[hcm] \u6CE8\u610F\uFF1A\u76F8\u540C\u5730\u5740\u4E0E\u79DF\u6237\u7684 env \u5DF2\u7ECF\u6709\u4E86\uFF1A${twins.join(", ")}\u3002\u5982\u679C\u662F\u540C\u4E00\u4E2A\u73AF\u5883\uFF0C\u8003\u8651\u76F4\u63A5\u7528\u5B83\u4EEC\uFF0C\u907F\u514D\u518D\u6512\u4E00\u4EFD\u91CD\u590D\u914D\u7F6E\u3002
|
|
2726
|
+
`
|
|
2727
|
+
);
|
|
2728
|
+
}
|
|
2729
|
+
await saveEnv2(name, cfg);
|
|
2730
|
+
const ids = await listIdentities2(TEMP_ENV_NAME2);
|
|
2731
|
+
const renamed = [];
|
|
2732
|
+
for (const id of ids) {
|
|
2733
|
+
const next = id.endsWith(`@${TEMP_ENV_NAME2}`) ? `${id.slice(0, -`@${TEMP_ENV_NAME2}`.length)}@${name}` : id;
|
|
2734
|
+
await renameIdentity(id, next);
|
|
2735
|
+
const meta2 = await loadIdentity2(next);
|
|
2736
|
+
await saveIdentity2(next, { ...meta2, env: name });
|
|
2737
|
+
renamed.push(next);
|
|
2738
|
+
if (cfg.defaultIdentity === id) {
|
|
2739
|
+
cfg.defaultIdentity = next;
|
|
2740
|
+
await saveEnv2(name, cfg);
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
g.activeEnv = name;
|
|
2744
|
+
await saveGlobalConfig2(g);
|
|
2745
|
+
await deleteEnv(TEMP_ENV_NAME2);
|
|
2746
|
+
const noun = renamed.length === 1 ? "identity" : "identities";
|
|
2747
|
+
const detail = renamed.length > 0 ? `\uFF1A${renamed.join(", ")}` : "";
|
|
2748
|
+
return exitOk(
|
|
2749
|
+
`\u2705 \u5DF2\u4FDD\u5B58\u4E3A env '${name}'\uFF08${renamed.length} ${noun} \u968F\u4E4B\u8FC1\u79FB${detail}\uFF09\uFF0C\u5E76\u8BBE\u4E3A\u5F53\u524D env\u3002`
|
|
2750
|
+
);
|
|
2751
|
+
} catch (e) {
|
|
2752
|
+
exitWithError(e);
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2589
2755
|
|
|
2590
2756
|
// src/commands/config.ts
|
|
2591
2757
|
init_exit();
|
|
@@ -2603,6 +2769,19 @@ async function configShowDeprecated() {
|
|
|
2603
2769
|
warnDeprecated("hcm config show", "hcm env current");
|
|
2604
2770
|
await envCurrent();
|
|
2605
2771
|
}
|
|
2772
|
+
function assertKnownDefault(sub, value) {
|
|
2773
|
+
const allowed = {
|
|
2774
|
+
credentialStore: CREDENTIAL_STORE_MODES,
|
|
2775
|
+
output: ["table", "json", "yaml"]
|
|
2776
|
+
};
|
|
2777
|
+
const options = allowed[sub];
|
|
2778
|
+
if (!options || options.includes(value)) return;
|
|
2779
|
+
throw new CliError4({
|
|
2780
|
+
code: CliErrorCode3.INVALID_ARGUMENT,
|
|
2781
|
+
message: `defaults.${sub} \u4E0D\u63A5\u53D7 '${value}'\u3002\u53EF\u9009\u503C\uFF1A${options.join(" / ")}`,
|
|
2782
|
+
context: sub === "credentialStore" ? { nextStep: `\u6CA1\u6709 keychain \u8FD9\u4E00\u6863\uFF1Aauto \u5C31\u662F\u300C\u4F18\u5148\u94A5\u5319\u4E32\u3001\u5199\u4E0D\u8FDB\u843D 0600 \u6587\u4EF6\u300D` } : void 0
|
|
2783
|
+
});
|
|
2784
|
+
}
|
|
2606
2785
|
async function configSetProfileDeprecated(name) {
|
|
2607
2786
|
warnDeprecated("hcm config set-profile", "hcm env use");
|
|
2608
2787
|
await envUse(name, { ping: false });
|
|
@@ -2620,6 +2799,7 @@ async function configSet(key2, value) {
|
|
|
2620
2799
|
});
|
|
2621
2800
|
}
|
|
2622
2801
|
const sub = key2.slice("defaults.".length);
|
|
2802
|
+
assertKnownDefault(sub, value);
|
|
2623
2803
|
const g = await loadGlobalConfig3();
|
|
2624
2804
|
g.defaults = g.defaults ?? {};
|
|
2625
2805
|
g.defaults[sub] = value;
|
|
@@ -8082,8 +8262,8 @@ import {
|
|
|
8082
8262
|
loadEnv as loadEnv8,
|
|
8083
8263
|
saveEnv as saveEnv3,
|
|
8084
8264
|
loadIdentity as loadIdentity4,
|
|
8085
|
-
listIdentities as
|
|
8086
|
-
deleteIdentity as
|
|
8265
|
+
listIdentities as listIdentities3,
|
|
8266
|
+
deleteIdentity as deleteIdentity3,
|
|
8087
8267
|
loadGlobalConfig as loadGlobalConfig8,
|
|
8088
8268
|
TokenStore as TokenStore3,
|
|
8089
8269
|
toPrincipal
|
|
@@ -8137,7 +8317,7 @@ async function identityList(args) {
|
|
|
8137
8317
|
try {
|
|
8138
8318
|
const g = await loadGlobalConfig8();
|
|
8139
8319
|
const filter = args.env === "all" ? void 0 : args.env ?? g.activeEnv;
|
|
8140
|
-
const names = await
|
|
8320
|
+
const names = await listIdentities3(filter);
|
|
8141
8321
|
if (names.length === 0) {
|
|
8142
8322
|
return exitOk("(no identities)");
|
|
8143
8323
|
}
|
|
@@ -8181,7 +8361,7 @@ async function identityRemove(name) {
|
|
|
8181
8361
|
`
|
|
8182
8362
|
);
|
|
8183
8363
|
}
|
|
8184
|
-
await
|
|
8364
|
+
await deleteIdentity3(name);
|
|
8185
8365
|
const env2 = await loadEnv8(meta2.env).catch(() => null);
|
|
8186
8366
|
if (env2?.defaultIdentity === name) {
|
|
8187
8367
|
env2.defaultIdentity = void 0;
|
|
@@ -8368,6 +8548,28 @@ function classify(argv, actionResolution) {
|
|
|
8368
8548
|
if (name === "delivery" && subcommand === "assess") {
|
|
8369
8549
|
return direct("R0", "local-discovery", "risk-assessment");
|
|
8370
8550
|
}
|
|
8551
|
+
if (name === "models") return direct("R0", "product-discovery", "model-discovery");
|
|
8552
|
+
if (name === "config") {
|
|
8553
|
+
if (["list", "show", "get"].includes(subcommand)) return direct("R0", "local-discovery", "config-read");
|
|
8554
|
+
return forbidden("identity-governance", "\u4FEE\u6539\u672C\u673A\u5168\u5C40\u914D\u7F6E\u4F1A\u6539\u53D8\u540E\u7EED\u6240\u6709\u547D\u4EE4\u7684\u73AF\u5883\u4E0E\u8EAB\u4EFD\uFF0C\u5C5E\u6CBB\u7406\u64CD\u4F5C\u3002");
|
|
8555
|
+
}
|
|
8556
|
+
if (name === "upgrade" || name === "self-update") {
|
|
8557
|
+
return direct("R1", "managed-local-write", "cli-self-upgrade");
|
|
8558
|
+
}
|
|
8559
|
+
if (name === "datapackage") {
|
|
8560
|
+
if (subcommand === "pack") return direct("R1", "local-validation", "datapackage-pack");
|
|
8561
|
+
if (subcommand === "status") return direct("R1", "remote-read", "datapackage-status");
|
|
8562
|
+
if (subcommand === "install") return guarded("tenant-data-write", "datapackage-install");
|
|
8563
|
+
return forbidden("unknown-command", "\u672A\u77E5 datapackage \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
|
|
8564
|
+
}
|
|
8565
|
+
if (name === "mini") {
|
|
8566
|
+
return forbidden("removed-command", "`hcm mini` \u5DF2\u79FB\u9664\uFF0C\u6539\u7528 `hcm workspace`\u3002");
|
|
8567
|
+
}
|
|
8568
|
+
if (name === "chiron") {
|
|
8569
|
+
if (subcommand === "doctor") return direct("R0", "local-discovery", "chiron-doctor");
|
|
8570
|
+
if (subcommand === "init") return direct("R1", "managed-local-write", "chiron-project-scaffold");
|
|
8571
|
+
return forbidden("unknown-command", "\u672A\u77E5 chiron \u5B50\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\u3002");
|
|
8572
|
+
}
|
|
8371
8573
|
if (name === "skills") {
|
|
8372
8574
|
if (subcommand === "list" || subcommand === "show") {
|
|
8373
8575
|
return direct("R0", "product-discovery", "skill-discovery");
|
|
@@ -9750,17 +9952,18 @@ import {
|
|
|
9750
9952
|
fetchReconIdentity as fetchReconIdentity2,
|
|
9751
9953
|
formatObject as formatObject24,
|
|
9752
9954
|
httpProbe as httpProbe2,
|
|
9753
|
-
|
|
9955
|
+
isTempEnv as isTempEnv3,
|
|
9956
|
+
listIdentities as listIdentities5,
|
|
9754
9957
|
loadEnv as loadEnv11,
|
|
9755
|
-
loadGlobalConfig as
|
|
9958
|
+
loadGlobalConfig as loadGlobalConfig11
|
|
9756
9959
|
} from "@hcmai/sdk";
|
|
9757
9960
|
|
|
9758
9961
|
// src/commands/chiron-project.ts
|
|
9759
9962
|
import { promises as fs9 } from "fs";
|
|
9760
9963
|
import os4 from "os";
|
|
9761
9964
|
import path9 from "path";
|
|
9762
|
-
import { spawnSync } from "child_process";
|
|
9763
|
-
import { hcmConfigDir, listEnvs as listEnvs3, loadEnv as loadEnv10 } from "@hcmai/sdk";
|
|
9965
|
+
import { execFileSync, spawnSync } from "child_process";
|
|
9966
|
+
import { hcmConfigDir, listEnvs as listEnvs3, listIdentities as listIdentities4, loadEnv as loadEnv10, loadGlobalConfig as loadGlobalConfig10 } from "@hcmai/sdk";
|
|
9764
9967
|
var ENV_FILE = "env.yaml";
|
|
9765
9968
|
var SKILLS_DIR = "hcm-skills";
|
|
9766
9969
|
var CASES_REPO_URL = "https://cnb.cool/hcm/chiron-cases.git";
|
|
@@ -9822,13 +10025,19 @@ function projectEnvFromConfig(cfg) {
|
|
|
9822
10025
|
tenant: cfg.tenantId ?? "1"
|
|
9823
10026
|
};
|
|
9824
10027
|
}
|
|
9825
|
-
async function findEnvByEndpoint(endpoint) {
|
|
10028
|
+
async function findEnvByEndpoint(endpoint, tenant2) {
|
|
9826
10029
|
const wanted = normalizeOrigin(endpoint);
|
|
10030
|
+
const matches = [];
|
|
9827
10031
|
for (const name of await listEnvs3().catch(() => [])) {
|
|
9828
10032
|
const config2 = await loadEnv10(name).catch(() => null);
|
|
9829
|
-
if (config2
|
|
10033
|
+
if (!config2 || normalizeOrigin(config2.endpoint) !== wanted) continue;
|
|
10034
|
+
matches.push({ name, config: config2, hasIdentity: (await listIdentities4(name).catch(() => [])).length > 0 });
|
|
9830
10035
|
}
|
|
9831
|
-
return null;
|
|
10036
|
+
if (matches.length === 0) return null;
|
|
10037
|
+
const active = (await loadGlobalConfig10().catch(() => null))?.activeEnv;
|
|
10038
|
+
const usable = matches.filter((m) => m.hasIdentity);
|
|
10039
|
+
const pick = usable.find((m) => m.name === active) ?? (tenant2 ? usable.find((m) => (m.config.tenantId ?? "1") === tenant2) : void 0) ?? usable[0] ?? matches.find((m) => m.name === active) ?? matches[0];
|
|
10040
|
+
return { name: pick.name, config: pick.config };
|
|
9832
10041
|
}
|
|
9833
10042
|
function renderChironAgentInstructions() {
|
|
9834
10043
|
return [
|
|
@@ -9973,6 +10182,60 @@ function firstLine(stderr, error) {
|
|
|
9973
10182
|
const line = stderr.split(/\r?\n/).map((l) => l.trim()).find(Boolean);
|
|
9974
10183
|
return line ?? "\uFF08\u65E0\u8F93\u51FA\uFF09";
|
|
9975
10184
|
}
|
|
10185
|
+
var JIRA_BASE = (process.env.JIRA_BASE || "https://jira.hcmcloud.cn").replace(/\/+$/, "");
|
|
10186
|
+
var JIRA_PROJECT = process.env.JIRA_PROJECT || "HCMNX";
|
|
10187
|
+
var JIRA_TOKEN_FILE = () => path9.join(os4.homedir(), ".config", "hcm", "jira-token");
|
|
10188
|
+
var JIRA_KEYCHAIN = "jira-hcmcloud";
|
|
10189
|
+
async function jiraTokenSource() {
|
|
10190
|
+
if (process.env.JIRA_TOKEN?.trim()) return { token: process.env.JIRA_TOKEN.trim(), from: "\u73AF\u5883\u53D8\u91CF JIRA_TOKEN" };
|
|
10191
|
+
const file = process.env.JIRA_TOKEN_FILE || JIRA_TOKEN_FILE();
|
|
10192
|
+
try {
|
|
10193
|
+
const value = (await fs9.readFile(file, "utf8")).trim();
|
|
10194
|
+
if (value) return { token: value, from: file };
|
|
10195
|
+
} catch {
|
|
10196
|
+
}
|
|
10197
|
+
try {
|
|
10198
|
+
const out = execFileSync("security", ["find-generic-password", "-s", JIRA_KEYCHAIN, "-w"], {
|
|
10199
|
+
encoding: "utf8",
|
|
10200
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
10201
|
+
}).trim();
|
|
10202
|
+
if (out) return { token: out, from: `\u94A5\u5319\u4E32 ${JIRA_KEYCHAIN}` };
|
|
10203
|
+
} catch {
|
|
10204
|
+
}
|
|
10205
|
+
return null;
|
|
10206
|
+
}
|
|
10207
|
+
async function inspectJira() {
|
|
10208
|
+
const src = await jiraTokenSource();
|
|
10209
|
+
if (!src) {
|
|
10210
|
+
return {
|
|
10211
|
+
ok: false,
|
|
10212
|
+
reason: `\u6CA1\u6709\u4EE4\u724C\u3002\u5728 ${JIRA_BASE} \u53F3\u4E0A\u89D2\u5934\u50CF \u2192 \u4E2A\u4EBA\u8BBE\u7F6E \u2192 Personal Access Tokens \u5EFA\u4E00\u4E2A\uFF0C\u7136\u540E\uFF1Amkdir -p ~/.config/hcm && read -rs pat && printf "%s" "$pat" > ~/.config/hcm/jira-token && chmod 600 ~/.config/hcm/jira-token && unset pat`
|
|
10213
|
+
};
|
|
10214
|
+
}
|
|
10215
|
+
const call = async (path_) => {
|
|
10216
|
+
const res = await fetch(`${JIRA_BASE}${path_}`, {
|
|
10217
|
+
headers: { Authorization: `Bearer ${src.token}`, Accept: "application/json" },
|
|
10218
|
+
signal: AbortSignal.timeout(15e3)
|
|
10219
|
+
});
|
|
10220
|
+
return res;
|
|
10221
|
+
};
|
|
10222
|
+
try {
|
|
10223
|
+
const me = await call("/rest/api/2/myself");
|
|
10224
|
+
if (me.status === 401) return { ok: false, from: src.from, reason: "\u4EE4\u724C\u65E0\u6548\u6216\u5DF2\u8FC7\u671F\uFF0C\u91CD\u5EFA PAT \u540E\u91CD\u65B0\u5B58\u4E00\u6B21" };
|
|
10225
|
+
if (!me.ok) return { ok: false, from: src.from, reason: `\u8FDE\u5F97\u4E0A\u4F46 /myself \u8FD4\u56DE ${me.status}` };
|
|
10226
|
+
const who = (await me.json()).displayName ?? "";
|
|
10227
|
+
const project = await call(`/rest/api/2/project/${JIRA_PROJECT}`);
|
|
10228
|
+
return {
|
|
10229
|
+
ok: project.ok,
|
|
10230
|
+
from: src.from,
|
|
10231
|
+
who,
|
|
10232
|
+
projectVisible: project.ok,
|
|
10233
|
+
reason: project.ok ? void 0 : `\u770B\u4E0D\u5230\u9879\u76EE ${JIRA_PROJECT}\uFF08${project.status}\uFF09\uFF0C\u627E Jira \u7BA1\u7406\u5458\u5F00\u6743\u9650`
|
|
10234
|
+
};
|
|
10235
|
+
} catch (e) {
|
|
10236
|
+
return { ok: false, from: src.from, reason: `\u8FDE\u4E0D\u4E0A ${JIRA_BASE}\uFF1A${e.message}` };
|
|
10237
|
+
}
|
|
10238
|
+
}
|
|
9976
10239
|
async function exists2(file) {
|
|
9977
10240
|
try {
|
|
9978
10241
|
await fs9.access(file);
|
|
@@ -10012,7 +10275,7 @@ var defaultChironInitDeps = {
|
|
|
10012
10275
|
caseLibrary: (envName) => ensureCaseLibrary(envName)
|
|
10013
10276
|
};
|
|
10014
10277
|
async function resolveLoggedInEnv() {
|
|
10015
|
-
const g = await
|
|
10278
|
+
const g = await loadGlobalConfig11();
|
|
10016
10279
|
const name = g.activeEnv;
|
|
10017
10280
|
const loginHint = "hcm login https://<\u4F60\u7684 HCM \u5730\u5740> --code <\u914D\u5BF9\u7801>";
|
|
10018
10281
|
if (!name) {
|
|
@@ -10028,7 +10291,7 @@ async function resolveLoggedInEnv() {
|
|
|
10028
10291
|
message: `\u5F53\u524D\u73AF\u5883 '${name}' \u6CA1\u6709 endpoint\u3002\u5148\u6267\u884C\uFF1A${loginHint}`
|
|
10029
10292
|
});
|
|
10030
10293
|
}
|
|
10031
|
-
const identities = await
|
|
10294
|
+
const identities = await listIdentities5(name).catch(() => []);
|
|
10032
10295
|
if (identities.length === 0) {
|
|
10033
10296
|
throw new CliError21({
|
|
10034
10297
|
code: CliErrorCode20.IDENTITY_NOT_FOUND,
|
|
@@ -10088,6 +10351,13 @@ async function scaffoldChironProject(root, env2, envName) {
|
|
|
10088
10351
|
async function runChironInit(args, deps = defaultChironInitDeps) {
|
|
10089
10352
|
const root = path10.resolve(args.project ?? ".");
|
|
10090
10353
|
const { name, env: env2, identity: identity2 } = await resolveLoggedInEnv();
|
|
10354
|
+
if (isTempEnv3(name)) {
|
|
10355
|
+
throw new CliError21({
|
|
10356
|
+
code: CliErrorCode20.INVALID_ARGUMENT,
|
|
10357
|
+
message: `\u5F53\u524D\u662F\u4E34\u65F6\u73AF\u5883\uFF08${env2.endpoint}\uFF09\uFF0C\u8FD8\u6CA1\u6709\u540D\u5B57\u3002\u9879\u76EE\u8981\u7ED1\u4E00\u4E2A\u7A33\u5B9A\u7684 env\uFF0C\u5426\u5219\u4E0B\u4E00\u6B21 hcm login --code \u8986\u76D6\u5B83\u4E4B\u540E\uFF0C\u9879\u76EE\u4ED3\u8BB0\u7684\u73AF\u5883\u5C31\u5BF9\u4E0D\u4E0A\u4E86\u3002`,
|
|
10358
|
+
context: { nextStep: `\u5148\u7ED9\u5B83\u8D77\u4E2A\u540D\u5B57\uFF1Ahcm env save <name>\uFF0C\u7136\u540E\u91CD\u8DD1 hcm chiron init` }
|
|
10359
|
+
});
|
|
10360
|
+
}
|
|
10091
10361
|
const say = (line) => process.stderr.write(`[chiron init] ${line}
|
|
10092
10362
|
`);
|
|
10093
10363
|
const actual = await deps.tokenTenant(name, env2.tenant);
|
|
@@ -10172,7 +10442,8 @@ var defaultDeps = {
|
|
|
10172
10442
|
fixCases: async (envName) => {
|
|
10173
10443
|
await ensureCaseLibrary(envName);
|
|
10174
10444
|
},
|
|
10175
|
-
inspectCases: () => inspectCaseLibrary()
|
|
10445
|
+
inspectCases: () => inspectCaseLibrary(),
|
|
10446
|
+
inspectJira: () => inspectJira()
|
|
10176
10447
|
};
|
|
10177
10448
|
async function runChironDoctor(args, deps = defaultDeps) {
|
|
10178
10449
|
const root = path11.resolve(args.project ?? ".");
|
|
@@ -10195,7 +10466,7 @@ async function runChironDoctor(args, deps = defaultDeps) {
|
|
|
10195
10466
|
return finish(report);
|
|
10196
10467
|
}
|
|
10197
10468
|
report.env = env2;
|
|
10198
|
-
const found = await findEnvByEndpoint(env2.endpoint);
|
|
10469
|
+
const found = await findEnvByEndpoint(env2.endpoint, env2.tenant);
|
|
10199
10470
|
const loginCmd = `hcm login ${env2.endpoint} --code <\u914D\u5BF9\u7801>`;
|
|
10200
10471
|
if (!found) {
|
|
10201
10472
|
report.lines.push({ item: "\u767B\u5F55", verdict: "fail", detail: `\u672C\u673A\u6CA1\u6709\u767B\u5F55\u8FC7 ${env2.endpoint}`, nextStep: loginCmd });
|
|
@@ -10256,6 +10527,10 @@ async function runChironDoctor(args, deps = defaultDeps) {
|
|
|
10256
10527
|
cases = await casesLine();
|
|
10257
10528
|
}
|
|
10258
10529
|
report.lines.push(cases);
|
|
10530
|
+
const jira = await deps.inspectJira();
|
|
10531
|
+
report.lines.push(
|
|
10532
|
+
jira.ok ? { item: "Jira", verdict: "ok", detail: `${jira.who || "\u5DF2\u8FDE\u63A5"} \xB7 \u770B\u5F97\u5230 ${JIRA_PROJECT}\uFF08\u4EE4\u724C\u6765\u81EA ${jira.from}\uFF09` } : { item: "Jira", verdict: "warn", detail: jira.reason ?? "\u4E0D\u53EF\u7528", nextStep: "\u73B0\u5728\u4E0D\u914D\u4E5F\u80FD\u4EA4\u4ED8\uFF1B\u649E\u5230\u300C\u4EA7\u54C1\u505A\u4E0D\u5230\u300D\u8981\u63D0\u5355\u65F6\u5FC5\u987B\u5148\u914D\u597D" }
|
|
10533
|
+
);
|
|
10259
10534
|
return finish(report);
|
|
10260
10535
|
}
|
|
10261
10536
|
function finish(report) {
|
|
@@ -12020,6 +12295,7 @@ env.command("list").description("\u5217\u51FA\u5168\u90E8 env").action(() => env
|
|
|
12020
12295
|
env.command("current").description("\u663E\u793A\u5F53\u524D\u6FC0\u6D3B\u7684 env").action(() => envCurrent());
|
|
12021
12296
|
env.command("add <name>").description("\u65B0\u589E env").option("--endpoint <url>", "HCM \u540E\u7AEF URL\uFF08\u5FC5\u586B\uFF09").option("--tenant <id>", "\u9ED8\u8BA4 tenant id", "1").option("--frontend <url>", "\u5BF9\u5E94\u524D\u7AEF URL\uFF0C\u4F8B\u5982 http://127.0.0.1:5176").option("--force", "\u8986\u76D6\u5DF2\u5B58\u5728\u7684\u540C\u540D env").action((name, opts) => envAdd(name, opts));
|
|
12022
12297
|
env.command("use <name>").description("\u5207\u5230\u6307\u5B9A env").option("--no-ping", "\u8DF3\u8FC7 endpoint \u5065\u5EB7\u68C0\u67E5").action((name, opts) => envUse(name, opts));
|
|
12298
|
+
env.command("save <name>").description("\u628A\u5F53\u524D\u4E34\u65F6\u73AF\u5883\uFF08login --code \u4EA7\u751F\u7684\uFF09\u5B58\u6210\u5177\u540D env").option("--force", "\u76EE\u6807 env \u5DF2\u5B58\u5728\u65F6\u8986\u76D6\u5B83\u7684\u914D\u7F6E").action((name, opts) => envSave(name, opts));
|
|
12023
12299
|
env.command("remove <name>").description("\u5220\u9664 env\uFF08\u7EA7\u8054\u6E05\u9664\u8BE5 env \u7684\u5168\u90E8 identity \u548C token\uFF09").option("--force", "\u8DF3\u8FC7\u786E\u8BA4\u63D0\u793A").action((name, opts) => envRemove(name, opts));
|
|
12024
12300
|
env.command("show [name]").description("\u663E\u793A env \u8BE6\u60C5\uFF08\u542B\u8BE5 env \u4E0B\u7684 identity \u5217\u8868\uFF09").action((name) => envShow({ name }));
|
|
12025
12301
|
env.command("edit <field> <value>").description("\u7F16\u8F91 env \u5B57\u6BB5\uFF08endpoint / frontend / tenantId / defaultIdentity / defaultAgent\uFF09").option("--env <name>", "\u76EE\u6807 env \u540D\uFF08\u9ED8\u8BA4\u5F53\u524D activeEnv\uFF09").action((field, value, opts) => envEdit(field, value, opts));
|
|
@@ -12030,9 +12306,9 @@ identity.command("use <name>").description("\u628A identity \u8BBE\u4E3A\u5176 e
|
|
|
12030
12306
|
identity.command("remove <name>").description("\u5220\u9664 identity\uFF08\u6E05 token + \u82E5\u662F env default \u5219\u6E05\u7A7A\uFF09").action((name) => identityRemove(name));
|
|
12031
12307
|
var user = program.command("user").description("\u7BA1\u7406\u79DF\u6237\u7528\u6237\u7684\u4E13\u7528\u51ED\u636E\u6D41\u7A0B");
|
|
12032
12308
|
user.command("reset-password").description("\u7531 admin.system \u5B89\u5168\u91CD\u7F6E\u7528\u6237\u5BC6\u7801\uFF0C\u5E76\u4F7F\u65E2\u6709\u4F1A\u8BDD\u5931\u6548").option("--id <uuid>", "\u76EE\u6807\u7528\u6237 ID\uFF08\u4E0E --username \u4E8C\u9009\u4E00\uFF09").option("--username <user>", "\u76EE\u6807\u7528\u6237\u540D\uFF08\u4E0E --id \u4E8C\u9009\u4E00\uFF09").option("--password-stdin", "\u4ECE\u6807\u51C6\u8F93\u5165\u8BFB\u53D6\u65B0\u5BC6\u7801\uFF08Agent/\u53D7\u63A7\u4EA4\u4ED8\u5FC5\u987B\u4F7F\u7528\uFF09").option("--no-force-change", "\u4E0B\u6B21\u767B\u5F55\u4E0D\u5F3A\u5236\u6539\u5BC6\uFF08\u4EC5\u9650\u5DF2\u6279\u51C6\u7684\u9694\u79BB\u6D4B\u8BD5\u73AF\u5883\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\u5FC5\u987B\u5177\u5907 admin.system\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => userResetPasswordCommand(opts));
|
|
12033
|
-
var chiron = program.command("chiron").description("\u777F\u620E\u987E\u95EE\u9879\u76EE\uFF1Ainit \u4E00\u6761\u547D\u4EE4\u521D\u59CB\u5316\u9879\u76EE\u4ED3\uFF0Cdoctor \
|
|
12309
|
+
var chiron = program.command("chiron").description("\u777F\u620E\u987E\u95EE\u9879\u76EE\uFF1Ainit \u4E00\u6761\u547D\u4EE4\u521D\u59CB\u5316\u9879\u76EE\u4ED3\uFF0Cdoctor \u56DB\u884C\u6838\u5BF9\u80FD\u4E0D\u80FD\u5F00\u5DE5");
|
|
12034
12310
|
chiron.command("init").description("\u521D\u59CB\u5316\u987E\u95EE\u9879\u76EE\u4ED3\uFF1A\u5199 env.yaml\uFF08\u7528\u521A hcm login \u7684\u73AF\u5883\uFF09\u3001\u5EFA\u76EE\u5F55\u3001\u88C5\u5168\u90E8\u6280\u80FD\u3001\u63A5\u6848\u4F8B\u5E93\uFF1B\u91CD\u8DD1\u5B89\u5168").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--skip-skills", "\u4E0D\u88C5\u6280\u80FD\uFF08\u79BB\u7EBF/\u6D4B\u8BD5\uFF09").option("--skip-cases", "\u4E0D\u63A5\u6848\u4F8B\u5E93").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => chironInitCommand(opts));
|
|
12035
|
-
chiron.command("doctor").description("\u6838\u5BF9\uFF1A\u672C\u673A\u767B\u5F55\u662F\u5426\u5BF9\u7740 env.yaml \u7684\u73AF\u5883\uFF08\u542B\u56DB\u6761\u951A\u70B9\uFF09/ \u6280\u80FD\u88C5\u6CA1\u88C5 / \u6848\u4F8B\u5E93\u63A5\u6CA1\u63A5").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--fix", "\u80FD\u81EA\u52A8\u8865\u7684\u8865\u4E0A\uFF08\u6280\u80FD / \u6848\u4F8B\u5E93\uFF09\u540E\u518D\u6838\u4E00\u904D").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => chironDoctorCommand(opts));
|
|
12311
|
+
chiron.command("doctor").description("\u6838\u5BF9\uFF1A\u672C\u673A\u767B\u5F55\u662F\u5426\u5BF9\u7740 env.yaml \u7684\u73AF\u5883\uFF08\u542B\u56DB\u6761\u951A\u70B9\uFF09/ \u6280\u80FD\u88C5\u6CA1\u88C5 / \u6848\u4F8B\u5E93\u63A5\u6CA1\u63A5 / Jira \u80FD\u4E0D\u80FD\u63D0\u5355").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--fix", "\u80FD\u81EA\u52A8\u8865\u7684\u8865\u4E0A\uFF08\u6280\u80FD / \u6848\u4F8B\u5E93\uFF09\u540E\u518D\u6838\u4E00\u904D").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => chironDoctorCommand(opts));
|
|
12036
12312
|
var delivery = program.command("delivery").description("\u987E\u95EE\u4EA4\u4ED8\uFF1A\u73B0\u573A\u63A2\u6D3B\u3001\u98CE\u9669\u8BC4\u4F30\u4E0E\u4E00\u6B21\u6027\u53D7\u63A7\u6267\u884C\u5408\u540C");
|
|
12037
12313
|
delivery.command("assess").description("\u8BC4\u4F30\u4E00\u6B21 HCM CLI argv\uFF1BAction \u98CE\u63A7\u58F0\u660E\u8BFB\u53D6\u81EA\u76EE\u6807 Core\uFF0C\u7528 -- \u5206\u9694\u88AB\u8BC4\u4F30\u547D\u4EE4").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").allowUnknownOption(true).argument("<command...>", "\u88AB\u8BC4\u4F30\u7684 HCM \u5B50\u547D\u4EE4\u4E0E\u53C2\u6570\uFF0C\u4E0D\u5305\u542B hcm \u672C\u8EAB").action((command, opts) => deliveryAssessCommand(command, opts));
|
|
12038
12314
|
delivery.command("doctor").description("\u56DB\u6761\u951A\u70B9\u63A2\u6D3B\uFF1A\u8FDE\u901A / \u6211\u662F\u8C01 / configAdmin / \u7AD9\u5728\u54EA\u4E00\u5C42").option("--env <name>", "\u76EE\u6807\u73AF\u5883\u522B\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--capabilities <s>", "\u722C\u53D6\u65F6\u58F0\u660E\u7684 capability \u4E32\uFF08\u4F1A\u968F\u56DB\u5143\u7EC4\u7559\u6863\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => deliveryDoctorCommand(opts));
|