@hcmai/cli 0.37.2 → 0.37.5
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/README.md +2 -1
- package/dist/index.js +66 -29
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -125,7 +125,8 @@ files or the whole workspace to refresh the baseline.
|
|
|
125
125
|
A project `env.yaml` can declare `default` and named `environments`, each with
|
|
126
126
|
`endpoint`, `frontend`, `tenant`, optional `roles`, and `danger`. Legacy three-line
|
|
127
127
|
files remain supported. `--env` first matches a project name, then a local slot.
|
|
128
|
-
Connection provenance is printed to stderr
|
|
128
|
+
Connection provenance is printed to stderr (skipped when `--output json|yaml` or
|
|
129
|
+
`--raw` is given explicitly; check the target with `hcm env current`); writes to `danger: true` environments
|
|
129
130
|
require `--allow-danger`. Credentials stay in the local identity store.
|
|
130
131
|
|
|
131
132
|
## Delivery projects
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
loadIdentity,
|
|
18
18
|
resolveEnvContext,
|
|
19
19
|
printResolvedEnvironment,
|
|
20
|
+
writeEnvironmentBanner,
|
|
20
21
|
resolveActiveIdentity,
|
|
21
22
|
identityMetaFile,
|
|
22
23
|
listIdentities,
|
|
@@ -39,7 +40,7 @@ async function ensureActiveAuth(args) {
|
|
|
39
40
|
if (args.asFlag) {
|
|
40
41
|
const roles = resolved.project?.environment.roles;
|
|
41
42
|
const target = roles && Object.hasOwn(roles, args.asFlag) ? roles[args.asFlag] : args.asFlag;
|
|
42
|
-
if (target !== args.asFlag)
|
|
43
|
+
if (target !== args.asFlag) writeEnvironmentBanner(`\u2192 \u9879\u76EE\u89D2\u8272 ${args.asFlag} \u2192 ${target}\uFF08\u6765\u81EA ${resolved.project.path}\uFF09
|
|
43
44
|
`);
|
|
44
45
|
const ctx = await ensureAsAuth(envName, envCfg.endpoint, envCfg.tenantId, target, resolved.project?.environment.tenant);
|
|
45
46
|
return finishContext(ctx, resolved, args.allowDanger);
|
|
@@ -5476,7 +5477,7 @@ function uniquePaths(value, name, allowEmpty = false) {
|
|
|
5476
5477
|
// src/index.ts
|
|
5477
5478
|
init_package_version();
|
|
5478
5479
|
import { Command } from "commander";
|
|
5479
|
-
import { COLUMN_SLOT_SQL_KEYS as COLUMN_SLOT_SQL_KEYS2, DATA_PACKAGE_FIXTURE_SCHEMA_V1, LEDGER_ONLY_FLAG as LEDGER_ONLY_FLAG2, migrateLegacyProfiles } from "@hcmai/sdk";
|
|
5480
|
+
import { COLUMN_SLOT_SQL_KEYS as COLUMN_SLOT_SQL_KEYS2, DATA_PACKAGE_FIXTURE_SCHEMA_V1, LEDGER_ONLY_FLAG as LEDGER_ONLY_FLAG2, migrateLegacyProfiles, setMachineReadableOutput } from "@hcmai/sdk";
|
|
5480
5481
|
|
|
5481
5482
|
// src/commands/login.ts
|
|
5482
5483
|
import axios2 from "axios";
|
|
@@ -8737,13 +8738,14 @@ import {
|
|
|
8737
8738
|
loadGlobalConfig as loadGlobalConfig5,
|
|
8738
8739
|
resolveEnvContext as resolveEnvContext4,
|
|
8739
8740
|
printResolvedEnvironment as printResolvedEnvironment3,
|
|
8741
|
+
writeEnvironmentBanner as writeEnvironmentBanner2,
|
|
8740
8742
|
CliError as CliError20,
|
|
8741
8743
|
CliErrorCode as CliErrorCode18
|
|
8742
8744
|
} from "@hcmai/sdk";
|
|
8743
8745
|
async function versionCommand(args) {
|
|
8744
8746
|
try {
|
|
8745
8747
|
let endpoint = args.endpoint;
|
|
8746
|
-
if (endpoint)
|
|
8748
|
+
if (endpoint) writeEnvironmentBanner2(`\u2192 ${endpoint} \xB7 \u8EAB\u4EFD \u672A\u8BA4\u8BC1\uFF08\u6765\u81EA --endpoint\uFF09
|
|
8747
8749
|
`);
|
|
8748
8750
|
if (!endpoint) {
|
|
8749
8751
|
const g = await loadGlobalConfig5();
|
|
@@ -13291,6 +13293,7 @@ import {
|
|
|
13291
13293
|
discoverProjectEnv as discoverProjectEnv3,
|
|
13292
13294
|
resolveEnvContext as resolveEnvContext5,
|
|
13293
13295
|
printResolvedEnvironment as printResolvedEnvironment4,
|
|
13296
|
+
writeEnvironmentBanner as writeEnvironmentBanner3,
|
|
13294
13297
|
CliError as CliError33,
|
|
13295
13298
|
CliErrorCode as CliErrorCode33
|
|
13296
13299
|
} from "@hcmai/sdk";
|
|
@@ -13981,7 +13984,7 @@ function sha2562(text2) {
|
|
|
13981
13984
|
}
|
|
13982
13985
|
async function resolveEndpoint(args) {
|
|
13983
13986
|
if (args.endpoint) {
|
|
13984
|
-
|
|
13987
|
+
writeEnvironmentBanner3(`\u2192 ${args.endpoint}\uFF08\u6765\u81EA --endpoint\uFF09
|
|
13985
13988
|
`);
|
|
13986
13989
|
return args.endpoint.replace(/\/+$/, "");
|
|
13987
13990
|
}
|
|
@@ -15837,6 +15840,10 @@ async function planSkillUpdate(options) {
|
|
|
15837
15840
|
}
|
|
15838
15841
|
}
|
|
15839
15842
|
}
|
|
15843
|
+
if (options.prefetchDocuments) {
|
|
15844
|
+
const remoteSkills = [...closure.values()].flatMap(({ skill }) => skill ? [skill] : []);
|
|
15845
|
+
await options.prefetchDocuments(remoteSkills);
|
|
15846
|
+
}
|
|
15840
15847
|
const documents = [];
|
|
15841
15848
|
const verified = [];
|
|
15842
15849
|
for (const [id, item] of closure) {
|
|
@@ -16419,6 +16426,7 @@ import {
|
|
|
16419
16426
|
loadGlobalConfig as loadGlobalConfig7,
|
|
16420
16427
|
resolveEnvContext as resolveEnvContext6,
|
|
16421
16428
|
printResolvedEnvironment as printResolvedEnvironment5,
|
|
16429
|
+
writeEnvironmentBanner as writeEnvironmentBanner4,
|
|
16422
16430
|
CliError as CliError34,
|
|
16423
16431
|
CliErrorCode as CliErrorCode34
|
|
16424
16432
|
} from "@hcmai/sdk";
|
|
@@ -16618,7 +16626,7 @@ async function tenantBootstrapCommand(args) {
|
|
|
16618
16626
|
const protectedNames = project2 ? Object.entries(project2.config.environments).filter(([, candidate]) => candidate.danger && candidate.endpoint === normalizeOrigin4(endpoint)).map(([name]) => name) : [];
|
|
16619
16627
|
assertDangerWrite4({ name: protectedNames.join(", "), danger: protectedNames.length > 0, allowDanger: args.allowDanger }, "\u5F00\u901A\u79DF\u6237");
|
|
16620
16628
|
const endpointDisplay = bootstrapDisplayUrl(endpoint, "\u670D\u52A1\u5730\u5740\uFF08endpoint\uFF09");
|
|
16621
|
-
if (args.endpoint)
|
|
16629
|
+
if (args.endpoint) writeEnvironmentBanner4(`\u2192 ${endpointDisplay} \xB7 \u79DF\u6237 ${args.tenantId} \xB7 \u8EAB\u4EFD bootstrap key\uFF08\u6765\u81EA --endpoint\uFF09
|
|
16622
16630
|
`);
|
|
16623
16631
|
const { pwd, stdinTaken } = await resolveAdminPassword(args);
|
|
16624
16632
|
const key2 = await resolveBootstrapKey(args, stdinTaken);
|
|
@@ -22245,14 +22253,18 @@ var NO_PRODUCT_SKILLS = "\u6CA1\u6709\u4EA7\u54C1\u6280\u80FD\u8981\u548C\u76EE\
|
|
|
22245
22253
|
function hasProductSkills(states) {
|
|
22246
22254
|
return states.some(({ state }) => Boolean(state.all) || Object.values(state.skills).some((r) => (r.sourceKind ?? "chiron") !== "local"));
|
|
22247
22255
|
}
|
|
22256
|
+
var SKILL_REQUEST_TIMEOUT_MS = 15e3;
|
|
22257
|
+
var SKILL_DOWNLOAD_CONCURRENCY = 6;
|
|
22248
22258
|
async function inspectSkillsFresh(states, endpoint, signal, token) {
|
|
22249
22259
|
if (!hasProductSkills(states)) return { level: "NOT_APPLICABLE", summary: NO_PRODUCT_SKILLS, note: "\u672A\u8BF7\u6C42\u6280\u80FD\u76EE\u5F55" };
|
|
22260
|
+
const downloads = new AbortController();
|
|
22261
|
+
const requestSignal = AbortSignal.any([signal, downloads.signal]);
|
|
22250
22262
|
const http2 = axios7.create({
|
|
22251
22263
|
baseURL: endpoint,
|
|
22252
|
-
timeout:
|
|
22264
|
+
timeout: SKILL_REQUEST_TIMEOUT_MS,
|
|
22253
22265
|
maxRedirects: 0,
|
|
22254
22266
|
headers: token ? { Authorization: `Bearer ${token}` } : void 0,
|
|
22255
|
-
signal:
|
|
22267
|
+
signal: requestSignal
|
|
22256
22268
|
});
|
|
22257
22269
|
try {
|
|
22258
22270
|
const base = await resolveChironBase3(http2);
|
|
@@ -22267,27 +22279,40 @@ async function inspectSkillsFresh(states, endpoint, signal, token) {
|
|
|
22267
22279
|
);
|
|
22268
22280
|
}
|
|
22269
22281
|
const documents = /* @__PURE__ */ new Map();
|
|
22270
|
-
const
|
|
22271
|
-
|
|
22272
|
-
|
|
22273
|
-
|
|
22274
|
-
|
|
22275
|
-
|
|
22276
|
-
|
|
22277
|
-
|
|
22278
|
-
|
|
22279
|
-
|
|
22280
|
-
|
|
22281
|
-
|
|
22282
|
+
const prefetchDocuments = async (skills2) => {
|
|
22283
|
+
const pending = skills2.filter((skill) => !documents.has(skill.id));
|
|
22284
|
+
const queue = pending.values();
|
|
22285
|
+
await Promise.all(Array.from({ length: Math.min(SKILL_DOWNLOAD_CONCURRENCY, pending.length) }, async () => {
|
|
22286
|
+
for (const skill of queue) {
|
|
22287
|
+
requestSignal.throwIfAborted();
|
|
22288
|
+
const markdown = await fetchSkillMarkdown2(http2, skill.id, base);
|
|
22289
|
+
const references = [];
|
|
22290
|
+
for (const relative3 of normalizeReferences2(skill.references, skill.id)) {
|
|
22291
|
+
references.push({ path: relative3, content: await fetchSkillReference2(http2, skill.id, relative3, base) });
|
|
22292
|
+
}
|
|
22293
|
+
documents.set(skill.id, { id: skill.id, markdown, source: `${endpoint}${base}/${skill.id}.md`, sourceKind: "chiron", references });
|
|
22294
|
+
}
|
|
22295
|
+
}));
|
|
22282
22296
|
};
|
|
22283
|
-
const
|
|
22284
|
-
|
|
22285
|
-
|
|
22286
|
-
|
|
22287
|
-
|
|
22288
|
-
|
|
22289
|
-
|
|
22297
|
+
const entries = [];
|
|
22298
|
+
const mismatched = [];
|
|
22299
|
+
for (const { state, baseDir } of states) {
|
|
22300
|
+
const plan = await planSkillUpdate({
|
|
22301
|
+
state,
|
|
22302
|
+
baseDir,
|
|
22303
|
+
manifest: manifest2,
|
|
22304
|
+
catalog,
|
|
22305
|
+
force: false,
|
|
22306
|
+
prefetchDocuments,
|
|
22307
|
+
fetchDocument: async (skill) => documents.get(skill.id)
|
|
22308
|
+
});
|
|
22309
|
+
entries.push(...plan.entries);
|
|
22310
|
+
mismatched.push(...planLockAlignment(state, plan).repairs.map((r) => r.id));
|
|
22311
|
+
}
|
|
22312
|
+
requestSignal.throwIfAborted();
|
|
22313
|
+
return classifySkillFreshness(states.length, entries, mismatched);
|
|
22290
22314
|
} catch (error) {
|
|
22315
|
+
downloads.abort();
|
|
22291
22316
|
if (error instanceof CliError48 && error.code === CliErrorCode48.SKILL_CATALOG_UNAVAILABLE) {
|
|
22292
22317
|
const reason = typeof error.context?.reason === "string" ? `\uFF1A${error.context.reason}` : "";
|
|
22293
22318
|
const next2 = typeof error.context?.nextStep === "string" ? error.context.nextStep : void 0;
|
|
@@ -23093,7 +23118,7 @@ var CHECKS = [
|
|
|
23093
23118
|
descriptor("local.credential", "\u672C\u673A\u51ED\u636E\u69FD", ["local.project.env"], ["CREDENTIAL_MISSING"], 5e3, localChecks.credential),
|
|
23094
23119
|
descriptor("local.cli.version", "CLI \u7248\u672C", [], ["CLI_OUTDATED", "CLI_LATEST_UNKNOWN", "CLI_VERSION_UNPARSEABLE"], 1e4, localChecks.version),
|
|
23095
23120
|
descriptor("local.skills.installed", "\u6280\u80FD", ["local.project.env"], ["SKILLS_STATE_UNREADABLE", "SKILLS_EMPTY", "SKILLS_LEGACY_LAYOUT", "SKILLS_SPLIT_LAYOUT", "SKILLS_ENDPOINT_MISMATCH", "SKILLS_LOCAL_UNREADABLE"], 5e3, localChecks.installed),
|
|
23096
|
-
descriptor("local.skills.fresh", "\u6280\u80FD\u65B0\u9C9C\u5EA6", ["local.skills.installed"], ["SKILLS_STALE", "SKILLS_LOCALLY_MODIFIED", "SKILLS_CATALOG_UNCHECKED", "SKILLS_CATALOG_UNAVAILABLE", "SKILLS_BUNDLED_UNREACHABLE", "SKILLS_ID_CONFLICT"],
|
|
23121
|
+
descriptor("local.skills.fresh", "\u6280\u80FD\u65B0\u9C9C\u5EA6", ["local.skills.installed"], ["SKILLS_STALE", "SKILLS_LOCALLY_MODIFIED", "SKILLS_CATALOG_UNCHECKED", "SKILLS_CATALOG_UNAVAILABLE", "SKILLS_BUNDLED_UNREACHABLE", "SKILLS_ID_CONFLICT"], 12e4, localChecks.fresh),
|
|
23097
23122
|
descriptor("local.skills.shadow", "\u672C\u5730\u906E\u853D", [], ["SKILLS_LOCAL_SHADOW", "SKILLS_LOCAL_UNREADABLE"], 5e3, localChecks.shadow),
|
|
23098
23123
|
descriptor("local.boundary", "\u9879\u76EE\u8FB9\u754C", [], ["BOUNDARY_MISSING", "BOUNDARY_FALLBACK", "BOUNDARY_FALLBACK_UNSYNCED", "BOUNDARY_FILE_UNWRITABLE"], 5e3, localChecks.boundary),
|
|
23099
23124
|
descriptor("local.method", "\u65B9\u6CD5\u5305", [], ["METHOD_NOT_INSTALLED", "METHOD_UNCHECKED", "METHOD_COPY_MISMATCH", "METHOD_OUTDATED"], 35e3, localChecks.method, true),
|
|
@@ -24127,6 +24152,8 @@ function renderCatalogExplanation(item) {
|
|
|
24127
24152
|
}
|
|
24128
24153
|
|
|
24129
24154
|
// src/commands/chiron-doctor.ts
|
|
24155
|
+
var DOCTOR_BUDGET_MS = 45e3;
|
|
24156
|
+
var DOCTOR_WITH_SKILLS_FRESH_BUDGET_MS = 18e4;
|
|
24130
24157
|
var defaultServices = {
|
|
24131
24158
|
reportRequest: requestServerReport,
|
|
24132
24159
|
opsReportRequest: requestOpsReport,
|
|
@@ -24320,7 +24347,7 @@ async function runChironDoctor(args, deps = {}) {
|
|
|
24320
24347
|
checks: CHECKS.filter((d) => ["connect.connectivity", "connect.identity", "connect.health-api"].includes(d.id)),
|
|
24321
24348
|
fetchReport: false,
|
|
24322
24349
|
onlyTarget: true,
|
|
24323
|
-
budgetMs: Math.max(0,
|
|
24350
|
+
budgetMs: Math.max(0, DOCTOR_BUDGET_MS - (Date.now() - startedAt))
|
|
24324
24351
|
}) : [];
|
|
24325
24352
|
const targetBefore = ctx.environments.find((e) => e.report.target);
|
|
24326
24353
|
const scope2 = scopeFor2(args, targetBefore?.catalog);
|
|
@@ -24334,9 +24361,10 @@ async function runChironDoctor(args, deps = {}) {
|
|
|
24334
24361
|
if (scope2.serverLayers.size) scope2.addedPrerequisites = ["connect.connectivity", "connect.identity", "connect.health-api"].filter((id) => !selectedConnect.some((d) => d.id === id));
|
|
24335
24362
|
ctx.scope = scope2;
|
|
24336
24363
|
const reused = /* @__PURE__ */ new Set([...selectedConnect.map((d) => d.id), ...scope2.addedPrerequisites]);
|
|
24364
|
+
const budget = selectedLocal.some((d) => d.id === "local.skills.fresh") ? DOCTOR_WITH_SKILLS_FRESH_BUDGET_MS : DOCTOR_BUDGET_MS;
|
|
24337
24365
|
results = await executeChecks(ctx, {
|
|
24338
24366
|
precomputed: preflight.filter((row) => reused.has(row.checkId)),
|
|
24339
|
-
budgetMs: Math.max(0,
|
|
24367
|
+
budgetMs: Math.max(0, budget - (Date.now() - startedAt))
|
|
24340
24368
|
});
|
|
24341
24369
|
} finally {
|
|
24342
24370
|
await Promise.all(ctx.environments.map(async (env2) => {
|
|
@@ -27833,6 +27861,14 @@ init_impersonation_lifecycle();
|
|
|
27833
27861
|
init_exit();
|
|
27834
27862
|
init_error_output();
|
|
27835
27863
|
|
|
27864
|
+
// src/utils/output-mode.ts
|
|
27865
|
+
function explicitMachineReadableOutput(cmd) {
|
|
27866
|
+
const opts = cmd.opts();
|
|
27867
|
+
const format = cmd.options.find((o) => o.long === "--output");
|
|
27868
|
+
if (format?.flags.includes("<fmt>") && cmd.getOptionValueSource("output") === "cli" && (opts.output === "json" || opts.output === "yaml")) return true;
|
|
27869
|
+
return cmd.options.some((o) => o.long === "--raw") && opts.raw === true;
|
|
27870
|
+
}
|
|
27871
|
+
|
|
27836
27872
|
// src/commands/offline/guard.ts
|
|
27837
27873
|
init_state();
|
|
27838
27874
|
import { CliError as CliError60, CliErrorCode as CliErrorCode59 } from "@hcmai/sdk";
|
|
@@ -31323,6 +31359,7 @@ program.name("hcm").description("HCM \u547D\u4EE4\u884C\u5DE5\u5177 \u2014 \u64C
|
|
|
31323
31359
|
if (lang) process.env.HCM_LANG = lang;
|
|
31324
31360
|
const outputOption = actionCommand2.options.find((o) => o.long === "--output");
|
|
31325
31361
|
setErrorOutputFormat(outputOption?.flags.includes("<fmt>") ? actionCommand2.opts().output : void 0);
|
|
31362
|
+
setMachineReadableOutput(explicitMachineReadableOutput(actionCommand2));
|
|
31326
31363
|
try {
|
|
31327
31364
|
assertOnlineAllowed(commandPath(actionCommand2));
|
|
31328
31365
|
} catch (e) {
|