@hcmai/cli 0.21.13 → 0.22.0
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 +215 -38
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2236,7 +2236,7 @@ var init_readline = __esm({
|
|
|
2236
2236
|
|
|
2237
2237
|
// src/index.ts
|
|
2238
2238
|
import { Command } from "commander";
|
|
2239
|
-
import { LEDGER_ONLY_FLAG as LEDGER_ONLY_FLAG2, migrateLegacyProfiles } from "@hcmai/sdk";
|
|
2239
|
+
import { DATA_PACKAGE_FIXTURE_SCHEMA_V1, LEDGER_ONLY_FLAG as LEDGER_ONLY_FLAG2, migrateLegacyProfiles } from "@hcmai/sdk";
|
|
2240
2240
|
|
|
2241
2241
|
// src/package-version.ts
|
|
2242
2242
|
import { readFileSync } from "fs";
|
|
@@ -4690,6 +4690,8 @@ async function importCommand(path21, args) {
|
|
|
4690
4690
|
};
|
|
4691
4691
|
const client3 = opts.dryRun ? DRY_RUN_CLIENT : HcmClient8.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
4692
4692
|
const result = await runImport(client3, fixtures, opts);
|
|
4693
|
+
for (const warning of result.warnings ?? []) process.stderr.write(`\u26A0 ${warning}
|
|
4694
|
+
`);
|
|
4693
4695
|
if (args.report) writeFileSync(args.report, JSON.stringify(result, null, 2));
|
|
4694
4696
|
const fmt = args.output ?? "json";
|
|
4695
4697
|
const tag = opts.dryRun ? "\u{1F50D} dry-run" : "\u{1F4E6} import";
|
|
@@ -9785,6 +9787,7 @@ import * as path9 from "path";
|
|
|
9785
9787
|
import {
|
|
9786
9788
|
buildMiniPreviewTargets,
|
|
9787
9789
|
buildMiniVerifyAgentReport,
|
|
9790
|
+
collectMiniPushWrites,
|
|
9788
9791
|
createWorkspaceFile,
|
|
9789
9792
|
deleteWorkspaceFile,
|
|
9790
9793
|
formatMiniVerifyReport,
|
|
@@ -9805,6 +9808,7 @@ import {
|
|
|
9805
9808
|
saveWorkspaceFileContent,
|
|
9806
9809
|
validateMiniProject,
|
|
9807
9810
|
validateMetaContent as validateMetaContent2,
|
|
9811
|
+
validateWorkspaceFiles,
|
|
9808
9812
|
fromAxiosError as fromAxiosError22,
|
|
9809
9813
|
CliError as CliError25,
|
|
9810
9814
|
CliErrorCode as CliErrorCode26
|
|
@@ -10395,22 +10399,27 @@ async function workspacePushCommand(args) {
|
|
|
10395
10399
|
if (!args.dryRun) {
|
|
10396
10400
|
requireWorkspaceActivation(await probeActiveWorkspaceKey(client3), context.workspaceKey);
|
|
10397
10401
|
}
|
|
10402
|
+
const miniPlans = [];
|
|
10403
|
+
for (const app of miniApps) {
|
|
10404
|
+
miniPlans.push({ app, plan: await pushMiniAppProject({ http: client3.raw(), rootDir: app.dir, dryRun: true }) });
|
|
10405
|
+
}
|
|
10398
10406
|
const rawResult = await pushWorkspaceRawFiles({
|
|
10399
10407
|
http: client3.raw(),
|
|
10400
10408
|
rootDir,
|
|
10401
10409
|
context,
|
|
10402
10410
|
dryRun: !!args.dryRun,
|
|
10403
10411
|
profile,
|
|
10412
|
+
extraPreflight: await collectMiniPreflightCandidates(miniPlans),
|
|
10404
10413
|
onProgress: (progress) => {
|
|
10405
10414
|
pushProgress = progress;
|
|
10406
10415
|
}
|
|
10407
10416
|
});
|
|
10408
10417
|
const results = [];
|
|
10409
|
-
for (const app of
|
|
10410
|
-
const result = await pushMiniAppProject({
|
|
10418
|
+
for (const { app, plan } of miniPlans) {
|
|
10419
|
+
const result = args.dryRun ? plan : await pushMiniAppProject({
|
|
10411
10420
|
http: client3.raw(),
|
|
10412
10421
|
rootDir: app.dir,
|
|
10413
|
-
dryRun:
|
|
10422
|
+
dryRun: false
|
|
10414
10423
|
});
|
|
10415
10424
|
results.push({ app, result });
|
|
10416
10425
|
}
|
|
@@ -10419,7 +10428,8 @@ async function workspacePushCommand(args) {
|
|
|
10419
10428
|
if (!args.dryRun) {
|
|
10420
10429
|
requireWorkspaceActivation(await probeActiveWorkspaceKey(client3), context.workspaceKey, true);
|
|
10421
10430
|
}
|
|
10422
|
-
|
|
10431
|
+
const preflightBlocks = !!args.dryRun && !!rawResult.preflight && (rawResult.preflight.status === "failed" || rawResult.preflight.status === "unavailable");
|
|
10432
|
+
process.exitCode = rawResult.conflicts.length || preflightBlocks || results.some((item) => item.result.conflicts.length) ? 3 : 0;
|
|
10423
10433
|
}, args.env ?? args.profile);
|
|
10424
10434
|
return;
|
|
10425
10435
|
} catch (e) {
|
|
@@ -10485,6 +10495,27 @@ async function workspaceVerifyCommand(args) {
|
|
|
10485
10495
|
const client3 = await loadProfileClient(authArgs);
|
|
10486
10496
|
const smokeAccessToken = args.smoke ? await loadSmokeAccessToken(client3, authArgs) : null;
|
|
10487
10497
|
const rawStatus = await getWorkspaceRawStatus(rootDir, context);
|
|
10498
|
+
const miniPlans = [];
|
|
10499
|
+
for (const app of miniApps) {
|
|
10500
|
+
const validation = await validateMiniProject(app.dir);
|
|
10501
|
+
let plan = null;
|
|
10502
|
+
let planSkipped;
|
|
10503
|
+
if (!validation.valid) {
|
|
10504
|
+
planSkipped = "validation failed";
|
|
10505
|
+
} else if (!client3) {
|
|
10506
|
+
planSkipped = "profile not configured";
|
|
10507
|
+
} else {
|
|
10508
|
+
try {
|
|
10509
|
+
plan = await pushMiniAppProject({ http: client3.raw(), rootDir: app.dir, dryRun: true });
|
|
10510
|
+
} catch (planErr) {
|
|
10511
|
+
planSkipped = planErr.message ?? "push dry-run failed";
|
|
10512
|
+
}
|
|
10513
|
+
}
|
|
10514
|
+
miniPlans.push({ app, validation, plan, planSkipped });
|
|
10515
|
+
}
|
|
10516
|
+
const miniCandidates = await collectMiniPreflightCandidates(
|
|
10517
|
+
miniPlans.flatMap(({ app, plan }) => plan ? [{ app, plan }] : [])
|
|
10518
|
+
);
|
|
10488
10519
|
let rawPlan = null;
|
|
10489
10520
|
let rawPlanSkipped;
|
|
10490
10521
|
if (!client3) {
|
|
@@ -10495,34 +10526,17 @@ async function workspaceVerifyCommand(args) {
|
|
|
10495
10526
|
http: client3.raw(),
|
|
10496
10527
|
rootDir,
|
|
10497
10528
|
context,
|
|
10498
|
-
dryRun: true
|
|
10529
|
+
dryRun: true,
|
|
10530
|
+
extraPreflight: miniCandidates
|
|
10499
10531
|
});
|
|
10500
10532
|
} catch (planErr) {
|
|
10501
10533
|
rawPlanSkipped = planErr.message ?? "workspace raw dry-run failed";
|
|
10502
10534
|
}
|
|
10503
10535
|
}
|
|
10504
10536
|
const reports = [];
|
|
10505
|
-
for (const app of
|
|
10506
|
-
const validation = await validateMiniProject(app.dir);
|
|
10537
|
+
for (const { app, validation, plan: pushResult, planSkipped } of miniPlans) {
|
|
10507
10538
|
const status = await readMiniStatusSafely(app);
|
|
10508
|
-
|
|
10509
|
-
let planSkipped;
|
|
10510
|
-
if (!validation.valid) {
|
|
10511
|
-
planSkipped = "validation failed";
|
|
10512
|
-
} else if (!client3) {
|
|
10513
|
-
planSkipped = "profile not configured";
|
|
10514
|
-
} else {
|
|
10515
|
-
try {
|
|
10516
|
-
const pushResult = await pushMiniAppProject({
|
|
10517
|
-
http: client3.raw(),
|
|
10518
|
-
rootDir: app.dir,
|
|
10519
|
-
dryRun: true
|
|
10520
|
-
});
|
|
10521
|
-
plan = { operations: pushResult.operations, conflicts: pushResult.conflicts };
|
|
10522
|
-
} catch (planErr) {
|
|
10523
|
-
planSkipped = planErr.message ?? "push dry-run failed";
|
|
10524
|
-
}
|
|
10525
|
-
}
|
|
10539
|
+
const plan = pushResult ? { operations: pushResult.operations, conflicts: pushResult.conflicts } : null;
|
|
10526
10540
|
const previewTargets = await buildMiniPreviewTargets(app.dir, frontend).catch(
|
|
10527
10541
|
() => []
|
|
10528
10542
|
);
|
|
@@ -10533,7 +10547,8 @@ async function workspaceVerifyCommand(args) {
|
|
|
10533
10547
|
previewTargets: preview,
|
|
10534
10548
|
accessToken: smokeAccessToken
|
|
10535
10549
|
}) : null;
|
|
10536
|
-
const
|
|
10550
|
+
const preflight = miniAppPreflight(rawPlan?.preflight, validation.appCode ?? app.appCode, miniCandidates);
|
|
10551
|
+
const ok = validation.valid && !!plan && plan.conflicts.length === 0 && (!smoke || smoke.ok) && preflight?.status !== "failed";
|
|
10537
10552
|
const report = {
|
|
10538
10553
|
ok,
|
|
10539
10554
|
validate: validation,
|
|
@@ -10541,7 +10556,8 @@ async function workspaceVerifyCommand(args) {
|
|
|
10541
10556
|
plan,
|
|
10542
10557
|
planSkipped,
|
|
10543
10558
|
preview,
|
|
10544
|
-
smoke
|
|
10559
|
+
smoke,
|
|
10560
|
+
preflight
|
|
10545
10561
|
};
|
|
10546
10562
|
reports.push({
|
|
10547
10563
|
appCode: app.appCode,
|
|
@@ -10557,8 +10573,7 @@ async function workspaceVerifyCommand(args) {
|
|
|
10557
10573
|
reports,
|
|
10558
10574
|
args.output ?? "table"
|
|
10559
10575
|
);
|
|
10560
|
-
|
|
10561
|
-
process.exitCode = rawOk && reports.every((item) => item.report.ok) ? 0 : 1;
|
|
10576
|
+
process.exitCode = workspaceVerifyOk(rawPlan, reports) ? 0 : rawPlan?.preflight?.status === "unavailable" && workspaceRawPlanOk(rawPlan) && reports.every((item) => item.report.ok) ? 3 : 1;
|
|
10562
10577
|
return;
|
|
10563
10578
|
} catch (e) {
|
|
10564
10579
|
exitWorkspaceError(e, args.env ?? args.profile);
|
|
@@ -10787,7 +10802,36 @@ async function pushWorkspaceRawFiles(args) {
|
|
|
10787
10802
|
operations: plan.operations,
|
|
10788
10803
|
conflicts: plan.conflicts
|
|
10789
10804
|
};
|
|
10790
|
-
|
|
10805
|
+
const extra = args.extraPreflight ?? { files: [], deletedPaths: [] };
|
|
10806
|
+
if (plan.conflicts.length && !extra.files.length && !extra.deletedPaths.length) return result;
|
|
10807
|
+
result.preflight = await preflightWorkspacePlan(
|
|
10808
|
+
args.http,
|
|
10809
|
+
args.context.workspaceKey,
|
|
10810
|
+
plan.conflicts.length ? [] : plan.operations,
|
|
10811
|
+
localFiles,
|
|
10812
|
+
extra,
|
|
10813
|
+
args.profile ?? args.context.profile
|
|
10814
|
+
);
|
|
10815
|
+
if (args.dryRun) return result;
|
|
10816
|
+
if (result.preflight.status === "failed") {
|
|
10817
|
+
throw new CliError25({
|
|
10818
|
+
code: CliErrorCode26.INVALID_ARGUMENT,
|
|
10819
|
+
message: `\u670D\u52A1\u7AEF\u9884\u68C0\u672A\u901A\u8FC7\uFF0C\u672C\u6B21\u6CA1\u6709\u5199\u5165\u4EFB\u4F55\u6587\u4EF6\uFF1A${result.preflight.issues.length} \u5904\u95EE\u9898
|
|
10820
|
+
${formatPreflightIssues(result.preflight.issues, " ")}`,
|
|
10821
|
+
profile: args.profile ?? args.context.profile,
|
|
10822
|
+
context: {
|
|
10823
|
+
reason: "WORKSPACE_PREFLIGHT_FAILED",
|
|
10824
|
+
workspaceKey: args.context.workspaceKey,
|
|
10825
|
+
details: { preflight: result.preflight },
|
|
10826
|
+
nextStep: result.preflight.nextStep
|
|
10827
|
+
}
|
|
10828
|
+
});
|
|
10829
|
+
}
|
|
10830
|
+
if (result.preflight.status === "unavailable") {
|
|
10831
|
+
process.stderr.write(`\u26A0 \u670D\u52A1\u7AEF\u9884\u68C0\u4E0D\u53EF\u7528\uFF08${result.preflight.reason}\uFF09\uFF0C\u6309\u9010\u6587\u4EF6\u5199\u5165\u7EE7\u7EED\uFF1B\u4E2D\u9014\u88AB\u62D2\u65F6\u524D\u9762\u7684\u6587\u4EF6\u5DF2\u7ECF\u5199\u5165\u3002
|
|
10832
|
+
`);
|
|
10833
|
+
}
|
|
10834
|
+
if (plan.conflicts.length) return result;
|
|
10791
10835
|
const localByPath = new Map(localFiles.map((file) => [file.localPath, file]));
|
|
10792
10836
|
const snapshots = new Map(manifest2.files.map((file) => [file.localPath, file]));
|
|
10793
10837
|
const committed = [];
|
|
@@ -10887,6 +10931,125 @@ async function pushWorkspaceRawFiles(args) {
|
|
|
10887
10931
|
}
|
|
10888
10932
|
return result;
|
|
10889
10933
|
}
|
|
10934
|
+
async function preflightWorkspacePlan(http, workspaceKey, operations, localFiles, extra, profile) {
|
|
10935
|
+
const localByPath = new Map(localFiles.map((file) => [file.localPath, file]));
|
|
10936
|
+
const files = [];
|
|
10937
|
+
const deletedPaths = [];
|
|
10938
|
+
for (const operation of operations) {
|
|
10939
|
+
if (operation.operation === "create" || operation.operation === "update") {
|
|
10940
|
+
const localFile = localByPath.get(operation.localPath);
|
|
10941
|
+
if (localFile) files.push({ relativePath: operation.remotePath, content: localFile.content });
|
|
10942
|
+
} else if (operation.operation === "delete") {
|
|
10943
|
+
deletedPaths.push(operation.remotePath);
|
|
10944
|
+
}
|
|
10945
|
+
}
|
|
10946
|
+
files.push(...extra.files);
|
|
10947
|
+
deletedPaths.push(...extra.deletedPaths);
|
|
10948
|
+
const sent = files.length + deletedPaths.length;
|
|
10949
|
+
if (sent === 0) {
|
|
10950
|
+
return { status: "nothing-to-check", sent, checked: 0, issues: [], reason: "\u8BA1\u5212\u91CC\u6CA1\u6709\u8981\u5199\u5165\u6216\u5220\u9664\u7684\u6587\u4EF6" };
|
|
10951
|
+
}
|
|
10952
|
+
try {
|
|
10953
|
+
const verdict = await validateWorkspaceFiles(http, workspaceKey, files, deletedPaths);
|
|
10954
|
+
if (!verdict.ok) {
|
|
10955
|
+
return {
|
|
10956
|
+
status: "failed",
|
|
10957
|
+
sent,
|
|
10958
|
+
checked: verdict.checked,
|
|
10959
|
+
issues: verdict.issues,
|
|
10960
|
+
nextStep: preflightFailureNextStep(verdict.issues)
|
|
10961
|
+
};
|
|
10962
|
+
}
|
|
10963
|
+
if (verdict.checked !== sent) {
|
|
10964
|
+
return {
|
|
10965
|
+
status: "unavailable",
|
|
10966
|
+
sent,
|
|
10967
|
+
checked: verdict.checked,
|
|
10968
|
+
issues: [],
|
|
10969
|
+
reason: `\u670D\u52A1\u7AEF\u53EA\u68C0\u67E5\u4E86 ${verdict.checked}/${sent} \u4E2A\u6587\u4EF6\uFF0C\u7ED3\u8BBA\u4E0D\u8986\u76D6\u6574\u4EFD\u8BA1\u5212`,
|
|
10970
|
+
nextStep: "\u628A\u8FD9\u6761\u8F93\u51FA\u8FDE\u540C\u670D\u52A1\u7AEF\u7248\u672C\uFF08hcm version\uFF09\u62A5\u7ED9\u4EA7\u54C1\u4FA7\uFF1B\u5728\u6B64\u4E4B\u524D\u4EE5\u771F\u5B9E push \u7684\u7ED3\u679C\u4E3A\u51C6\u3002"
|
|
10971
|
+
};
|
|
10972
|
+
}
|
|
10973
|
+
return { status: "passed", sent, checked: verdict.checked, issues: [] };
|
|
10974
|
+
} catch (error) {
|
|
10975
|
+
const status = error?.response?.status;
|
|
10976
|
+
const translated = error?.isAxiosError ? fromAxiosError22(error, profile) : error;
|
|
10977
|
+
const detail = translated instanceof Error ? translated.message : String(translated);
|
|
10978
|
+
return {
|
|
10979
|
+
status: "unavailable",
|
|
10980
|
+
sent,
|
|
10981
|
+
checked: 0,
|
|
10982
|
+
issues: [],
|
|
10983
|
+
reason: status === 404 ? "\u670D\u52A1\u7AEF\u6CA1\u6709 validate-files \u9884\u68C0\uFF08\u670D\u52A1\u7AEF\u7248\u672C\u65E9\u4E8E HCMNX-328\uFF09" : `\u9884\u68C0\u8C03\u7528\u5931\u8D25\uFF1A${detail}`,
|
|
10984
|
+
nextStep: status === 404 ? "\u670D\u52A1\u7AEF\u5347\u7EA7\u524D\uFF0Cverify / push --dry-run \u53EA\u80FD\u7ED9\u51FA\u672C\u5730\u540C\u6B65\u8BA1\u5212\uFF1B\u4EE5\u771F\u5B9E push \u7684\u7ED3\u679C\u4E3A\u51C6\u3002" : "\u786E\u8BA4\u767B\u5F55\u4E0E\u7F51\u7EDC\u540E\u91CD\u8DD1 hcm workspace verify\u3002"
|
|
10985
|
+
};
|
|
10986
|
+
}
|
|
10987
|
+
}
|
|
10988
|
+
async function collectMiniPreflightCandidates(plans) {
|
|
10989
|
+
const candidates = { files: [], deletedPaths: [] };
|
|
10990
|
+
for (const { app, plan } of plans) {
|
|
10991
|
+
if (plan.conflicts.length) continue;
|
|
10992
|
+
const writes = await collectMiniPushWrites(app.dir, plan.operations);
|
|
10993
|
+
candidates.files.push(...writes.files);
|
|
10994
|
+
candidates.deletedPaths.push(...writes.deletedPaths);
|
|
10995
|
+
}
|
|
10996
|
+
return candidates;
|
|
10997
|
+
}
|
|
10998
|
+
function miniAppPreflight(preflight, appCode, candidates) {
|
|
10999
|
+
if (!preflight) return void 0;
|
|
11000
|
+
const prefix = `mini_apps/${appCode}/`;
|
|
11001
|
+
const sent = [...candidates.files.map((file) => file.relativePath), ...candidates.deletedPaths].filter((relativePath) => relativePath.startsWith(prefix)).length;
|
|
11002
|
+
const issues = preflight.issues.filter((issue) => issue.path === null || issue.path.startsWith(prefix)).map((issue) => ({ path: issue.path, errCode: issue.errCode, message: issue.message }));
|
|
11003
|
+
if (issues.length) return { status: "failed", sent, issues };
|
|
11004
|
+
if (!sent) return { status: "nothing-to-check", sent, issues };
|
|
11005
|
+
return { status: preflight.status === "failed" ? "passed" : preflight.status, sent, issues };
|
|
11006
|
+
}
|
|
11007
|
+
function formatPreflightIssues(issues, indent2 = "") {
|
|
11008
|
+
return issues.map((issue) => {
|
|
11009
|
+
const lines = [`${indent2}\u2717 ${issue.path ?? "(\u6574\u6279)"} [${issue.errCode ?? "ERROR"}] ${issue.message}`];
|
|
11010
|
+
if (issue.description) lines.push(`${indent2} \u21B3 ${issue.description}`);
|
|
11011
|
+
const holder = conflictHolder(issue);
|
|
11012
|
+
if (holder) lines.push(`${indent2} \u21B3 \u5360\u7528\u65B9\uFF1A\u5F00\u53D1\u7A7A\u95F4 ${holder}`);
|
|
11013
|
+
return lines.join("\n");
|
|
11014
|
+
}).join("\n");
|
|
11015
|
+
}
|
|
11016
|
+
function conflictHolder(issue) {
|
|
11017
|
+
const data = issue.data;
|
|
11018
|
+
if (typeof data?.conflictingWorkspaceKey !== "string" || !data.conflictingWorkspaceKey) return void 0;
|
|
11019
|
+
const owner = typeof data.conflictingOwnerUserName === "string" && data.conflictingOwnerUserName ? `\uFF08${data.conflictingOwnerUserName}\uFF09` : "";
|
|
11020
|
+
return `${data.conflictingWorkspaceKey}${owner}`;
|
|
11021
|
+
}
|
|
11022
|
+
function preflightFailureNextStep(issues) {
|
|
11023
|
+
const steps = [];
|
|
11024
|
+
if (issues.some((issue) => !conflictHolder(issue))) {
|
|
11025
|
+
steps.push("\u6309\u6BCF\u6761\u95EE\u9898\u6539\u597D\u672C\u5730\u6587\u4EF6\uFF0C\u5148\u8DD1 hcm workspace verify\uFF08\u6216 push --dry-run\uFF09\u786E\u8BA4\u9884\u68C0\u901A\u8FC7\uFF0C\u518D push\u3002");
|
|
11026
|
+
}
|
|
11027
|
+
if (issues.some((issue) => conflictHolder(issue))) {
|
|
11028
|
+
steps.push("\u6807\u4E86\u300C\u5360\u7528\u65B9\u300D\u7684\u6587\u4EF6\u4E0D\u662F\u5199\u9519\u4E86\uFF1A\u540C\u4E00 artifact \u6B63\u88AB\u90A3\u4E2A\u5F00\u53D1\u7A7A\u95F4\u6539\u7740\uFF0C\u7B49\u5BF9\u65B9\u53D1\u5E03\uFF08release\uFF09\u6216\u64A4\u56DE\u5B83\u7684\u6539\u52A8\u540E\u518D push\uFF0C\u6216\u8005\u5148\u628A\u8FD9\u4E9B\u6587\u4EF6\u79FB\u51FA\u672C\u6B21 push\u3002");
|
|
11029
|
+
}
|
|
11030
|
+
return steps.join(" ");
|
|
11031
|
+
}
|
|
11032
|
+
function workspaceRawPlanOk(plan) {
|
|
11033
|
+
return !!plan && !plan.conflicts.length;
|
|
11034
|
+
}
|
|
11035
|
+
function workspacePreflightOk(preflight) {
|
|
11036
|
+
return preflight?.status === "passed" || preflight?.status === "nothing-to-check";
|
|
11037
|
+
}
|
|
11038
|
+
function workspaceVerifyOk(plan, reports) {
|
|
11039
|
+
return workspaceRawPlanOk(plan) && workspacePreflightOk(plan?.preflight) && reports.every((item) => item.report.ok);
|
|
11040
|
+
}
|
|
11041
|
+
function withoutPreflight(result) {
|
|
11042
|
+
const rest = { ...result };
|
|
11043
|
+
delete rest.preflight;
|
|
11044
|
+
return rest;
|
|
11045
|
+
}
|
|
11046
|
+
function formatPreflightSummary(preflight, indent2 = "") {
|
|
11047
|
+
const head = preflight.status === "passed" ? `server preflight: OK (${preflight.checked}/${preflight.sent} checked)` : preflight.status === "failed" ? `server preflight: FAIL (${preflight.issues.length} issues in ${preflight.checked}/${preflight.sent} checked)` : preflight.status === "unavailable" ? `server preflight: UNAVAILABLE \u2014 ${preflight.reason}\uFF08\u4E0D\u662F\u901A\u8FC7\uFF09` : `server preflight: nothing to check (${preflight.reason})`;
|
|
11048
|
+
const lines = [`${indent2}${head}`];
|
|
11049
|
+
if (preflight.issues.length) lines.push(formatPreflightIssues(preflight.issues, `${indent2} `));
|
|
11050
|
+
if (preflight.nextStep) lines.push(`${indent2} next: ${preflight.nextStep}`);
|
|
11051
|
+
return lines.join("\n");
|
|
11052
|
+
}
|
|
10890
11053
|
async function loadWorkspaceRawRemoteFiles(http, workspaceKey) {
|
|
10891
11054
|
const list = await listWorkspaceFiles(http, workspaceKey, { pageSize: 5e3 });
|
|
10892
11055
|
const result = [];
|
|
@@ -11355,7 +11518,9 @@ function writeWorkspacePushResult(rawResult, results, format) {
|
|
|
11355
11518
|
process.stdout.write(
|
|
11356
11519
|
formatObject22(
|
|
11357
11520
|
{
|
|
11358
|
-
|
|
11521
|
+
// 预检覆盖整份计划(workspace 文件 + 轻应用文件),放在顶层。
|
|
11522
|
+
preflight: rawResult.preflight ?? null,
|
|
11523
|
+
workspaceFiles: { artifact: "workspace", ...withoutPreflight(rawResult) },
|
|
11359
11524
|
miniApps: results.map((item) => ({
|
|
11360
11525
|
artifact: `mini:${item.app.appCode}`,
|
|
11361
11526
|
...item.result
|
|
@@ -11381,6 +11546,9 @@ function writeWorkspacePushResult(rawResult, results, format) {
|
|
|
11381
11546
|
}))
|
|
11382
11547
|
);
|
|
11383
11548
|
const conflicts = [...rawConflicts, ...miniConflicts];
|
|
11549
|
+
if (rawResult.preflight) {
|
|
11550
|
+
process.stdout.write(formatPreflightSummary(rawResult.preflight) + "\n");
|
|
11551
|
+
}
|
|
11384
11552
|
if (conflicts.length) {
|
|
11385
11553
|
process.stdout.write("conflicts:\n" + formatRows6(conflicts, { format: "table" }) + "\n");
|
|
11386
11554
|
return;
|
|
@@ -11408,8 +11576,9 @@ function writeWorkspacePushResult(rawResult, results, format) {
|
|
|
11408
11576
|
}
|
|
11409
11577
|
}
|
|
11410
11578
|
function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
11411
|
-
const rawOk =
|
|
11412
|
-
const ok =
|
|
11579
|
+
const rawOk = workspaceRawPlanOk(raw.plan);
|
|
11580
|
+
const ok = workspaceVerifyOk(raw.plan, reports);
|
|
11581
|
+
const preflight = raw.plan?.preflight ?? null;
|
|
11413
11582
|
if (format === "json") {
|
|
11414
11583
|
process.stdout.write(
|
|
11415
11584
|
formatObject22(
|
|
@@ -11417,6 +11586,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
11417
11586
|
ok,
|
|
11418
11587
|
workspaceKey: context.workspaceKey,
|
|
11419
11588
|
rootDir,
|
|
11589
|
+
preflight,
|
|
11420
11590
|
workspaceFiles: {
|
|
11421
11591
|
ok: rawOk,
|
|
11422
11592
|
status: summarizeStatus(raw.status),
|
|
@@ -11444,7 +11614,8 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
11444
11614
|
ok,
|
|
11445
11615
|
workspaceKey: context.workspaceKey,
|
|
11446
11616
|
rootDir,
|
|
11447
|
-
|
|
11617
|
+
preflight,
|
|
11618
|
+
workspaceFiles: { ...raw, plan: raw.plan ? withoutPreflight(raw.plan) : null },
|
|
11448
11619
|
miniApps: reports
|
|
11449
11620
|
},
|
|
11450
11621
|
{ format }
|
|
@@ -11459,6 +11630,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
11459
11630
|
`workspace files: ${raw.status.length}`,
|
|
11460
11631
|
`mini apps: ${reports.length}`
|
|
11461
11632
|
];
|
|
11633
|
+
if (preflight) lines.push("", formatPreflightSummary(preflight));
|
|
11462
11634
|
lines.push("", "workspace files");
|
|
11463
11635
|
if (raw.planSkipped) {
|
|
11464
11636
|
lines.push(` dry-run skipped: ${raw.planSkipped}`);
|
|
@@ -19445,7 +19617,12 @@ program.command("create <Model>").description("\u521B\u5EFA\u4E00\u6761 Model \u
|
|
|
19445
19617
|
"\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"
|
|
19446
19618
|
).action((m, opts) => createCommand(m, opts));
|
|
19447
19619
|
program.command("delete <Model>").description("\u5220\u9664\u4E00\u6761 Model \u8BB0\u5F55\uFF08\u8D70\u540E\u7AEF\u5B8C\u6574\u6821\u9A8C\uFF1B\u90E8\u5206 Model \u4F1A\u6267\u884C\u4E1A\u52A1\u64A4\u9500\uFF09").option("--id <id>", "\u76EE\u6807\u5B9E\u4F53 ID\uFF08\u5FC5\u586B\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").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").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((m, opts) => deleteCommand(m, opts));
|
|
19448
|
-
program.command("import <path>").description("\u6CE8\u5165 DataPackage
|
|
19620
|
+
program.command("import <path>").description("\u6CE8\u5165 DataPackage fixture v1\uFF08\u76EE\u5F55\u6216\u5355\u6587\u4EF6\uFF0C\u5355\u4E00\u4E1A\u52A1\u952E\uFF09").option("--dry-run", "\u53EA\u8DD1\u5BA2\u6237\u7AEF\u9759\u6001\u6821\u9A8C\uFF0C\u4E0D\u843D\u5E93\uFF08\u89C1 spec \xA78 \u9650\u5236\uFF09").option("--update-only", "\u5DF2\u5B58\u5728\uFF08\u6309 key_field\uFF09\u5219 PUT \u66F4\u65B0\uFF0C\u5426\u5219 create").option("--on-error <mode>", "stop | continue\uFF08\u9ED8\u8BA4 continue\uFF09", "continue").option("--report <path>", "\u5199 JSON \u6CE8\u5165\u62A5\u544A\uFF08\u9010\u884C\u7ED3\u679C + key\u2192id \u6620\u5C04\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").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").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").addHelpText("after", `
|
|
19621
|
+
\u516C\u5171 schema\uFF1A${DATA_PACKAGE_FIXTURE_SCHEMA_V1.$id}
|
|
19622
|
+
${DATA_PACKAGE_FIXTURE_SCHEMA_V1.properties.key_field.description}
|
|
19623
|
+
${DATA_PACKAGE_FIXTURE_SCHEMA_V1.properties.key.description}
|
|
19624
|
+
\u5B8C\u6574 DataPackage manifest \u7684 models[].keys \u7531 hcm datapackage install \u5904\u7406\u3002
|
|
19625
|
+
`).action((p, opts) => importCommand(p, opts));
|
|
19449
19626
|
program.command("models [keyword]").description("\u5217\u51FA\u76EE\u6807\u73AF\u5883\u6709\u54EA\u4E9B Model\uFF08describe \u7684\u4E0A\u4E00\u6B65\uFF09\uFF1B\u53EF\u5E26\u5173\u952E\u5B57\u8FC7\u6EE4").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").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", "table").action((keyword, opts) => modelsCommand(keyword, opts));
|
|
19450
19627
|
program.command("describe <Model>").description("\u67E5\u770B Model \u5143\u6570\u636E\uFF08\u5B57\u6BB5\u3001\u5173\u7CFB\u3001Action \u5217\u8868\uFF09").option("-v, --verbose", "\u663E\u793A enum \u53D6\u503C\u57DF\uFF0C\u4EE5\u53CA\u81EA\u5B9A\u4E49\u5B57\u6BB5\u7684\u63CF\u8FF0").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").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").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((m, opts) => describeCommand(m, opts));
|
|
19451
19628
|
var interactions = program.command("interactions").description("\u770B\u89C1\u5E76\u5904\u7406\u4F1A\u8BDD\u91CC\u672A\u51B3\u7684\u6682\u505C\uFF08\u786E\u8BA4 / \u8FFD\u95EE\uFF09\u2014\u2014\u4E0D\u53D1\u65B0\u6D88\u606F\uFF0C\u76F4\u63A5\u56DE\u5230\u90A3\u4E00\u6761");
|
|
@@ -19507,10 +19684,10 @@ workspaceAdd.command("mini <appCode>").description("\u65B0\u589E\u8F7B\u5E94\u75
|
|
|
19507
19684
|
workspace.command("status").description("\u67E5\u770B\u5F00\u53D1\u7A7A\u95F4\u672C\u5730 artifact \u4E0E\u4E0A\u6B21 pull/push \u7684\u5DEE\u5F02").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspaceStatusCommand(opts));
|
|
19508
19685
|
workspace.command("rm <relativePath>").description("\u6682\u5B58\u5220\u9664\u4E00\u4E2A raw workspace \u6587\u4EF6\uFF1B\u968F\u540E\u7528 push \u6267\u884C\u8FDC\u7AEF\u5220\u9664").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").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").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((relativePath, opts) => workspaceRmCommand(relativePath, opts));
|
|
19509
19686
|
workspace.command("validate").description("\u6821\u9A8C\u5F00\u53D1\u7A7A\u95F4\u672C\u5730 artifact\uFF08push \u524D\u5FC5\u8DD1\uFF09").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspaceValidateCommand(opts));
|
|
19510
|
-
workspace.command("push").description("\u628A\u672C\u5730\u5F00\u53D1\u7A7A\u95F4 artifact \u63A8\u9001\u56DE\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").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").option("--dry-run", "\u53EA\u8BA1\u7B97\u5F85\u6267\u884C\u7684\u64CD\u4F5C\uFF0C\u4E0D\
|
|
19687
|
+
workspace.command("push").description("\u628A\u672C\u5730\u5F00\u53D1\u7A7A\u95F4 artifact \u63A8\u9001\u56DE\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4\uFF1B\u5199\u5165\u524D\u5148\u8BA9\u670D\u52A1\u7AEF\u6309\u771F\u5B9E\u5199\u5165\u94FE\u9884\u68C0\u6574\u4EFD\u8BA1\u5212\uFF08\u542B mini_apps\uFF09\uFF0C\u6709\u95EE\u9898\u4E00\u4E2A\u6587\u4EF6\u90FD\u4E0D\u5199\uFF1B\u9884\u68C0\u62FF\u4E0D\u5230\u7ED3\u8BBA\uFF08\u8001\u670D\u52A1\u7AEF / \u8C03\u7528\u5931\u8D25\uFF09\u65F6\u5728 stderr \u8B66\u544A\u540E\u7167\u5E38\u9010\u6587\u4EF6\u5199\u5165").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").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").option("--dry-run", "\u53EA\u8BA1\u7B97\u5F85\u6267\u884C\u7684\u64CD\u4F5C\u5E76\u505A\u670D\u52A1\u7AEF\u53EA\u8BFB\u9884\u68C0\uFF0C\u4E0D\u5199\u8FDC\u7AEF\u6587\u4EF6\uFF1B\u9884\u68C0\u6709\u95EE\u9898\u6216\u62FF\u4E0D\u5230\u7ED3\u8BBA\u65F6\u9000\u51FA\u7801 3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspacePushCommand(opts));
|
|
19511
19688
|
workspace.command("preview").description("\u6253\u5370\u5F00\u53D1\u7A7A\u95F4\u4E2D\u8F7B\u5E94\u7528 artifact \u7684\u9884\u89C8 URL").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--frontend <url>", "\u524D\u7AEF\u5730\u5740", "http://127.0.0.1:5179").option("--surface <surface>", "\u5C55\u793A\u54EA\u79CD\u5F62\u6001\uFF1Aall | bare | standalone | embedded", "all").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspacePreviewCommand(opts));
|
|
19512
19689
|
workspace.command("verify").description(
|
|
19513
|
-
"\u4E00\u952E\u9A8C\u6536\uFF1A\u4E32\u8054 validate + status + push --dry-run
|
|
19690
|
+
"\u4E00\u952E\u9A8C\u6536\uFF1A\u4E32\u8054 validate + status + push --dry-run\uFF08\u542B\u670D\u52A1\u7AEF\u53EA\u8BFB\u9884\u68C0\uFF09+ preview\uFF0C\u5168\u7A0B\u4E0D\u5199\u8FDC\u7AEF\uFF0Cpush \u524D\u5FC5\u8DD1\uFF1B\u9000\u51FA\u7801 0 \u901A\u8FC7 / 1 \u53D1\u73B0\u95EE\u9898 / 3 \u670D\u52A1\u7AEF\u9884\u68C0\u62FF\u4E0D\u5230\u7ED3\u8BBA\uFF08\u4E0D\u662F\u901A\u8FC7\uFF09"
|
|
19514
19691
|
).option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--env <name>", "\u4E34\u65F6\u5207\u73AF\u5883\uFF08\u8986\u76D6 activeEnv\uFF0Cdry-run \u9636\u6BB5\u9700\u8981\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").option("--frontend <url>", "\u524D\u7AEF\u5730\u5740", "http://127.0.0.1:5179").option("--surface <surface>", "\u9884\u89C8\u5F62\u6001\uFF1Aall | bare | standalone | embedded", "all").option("--smoke", "\u5BF9\u9884\u89C8\u5165\u53E3\u4E0E\u57FA\u7840\u8D44\u6E90\u6267\u884C\u53EA\u8BFB HTTP GET \u53EF\u8FBE\u68C0\u67E5").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspaceVerifyCommand(opts));
|
|
19515
19692
|
program.command("trace [traceId]").description("\u67E5\u770B trace\uFF1A\u4E0D\u4F20 traceId \u5217\u6700\u8FD1\u8BB0\u5F55\uFF0C\u4F20 traceId \u663E\u793A\u4EBA\u7C7B\u53EF\u8BFB\u8BE6\u60C5").option("--conv <convId>", "\u67E5\u4F1A\u8BDD\u7684 LLM \u9010\u8C03\u7528 trace\uFF08PG llm_call_trace\uFF0CADR-134 D2\uFF09").option("--llm-calls", "\u628A\u4F4D\u7F6E\u53C2\u5F53 convId \u67E5 LLM \u9010\u8C03\u7528\uFF08\u7B49\u4EF7 --conv <convId>\uFF09").option("--span <N>", "\u67E5\u770B\u7B2C N \u4E2A span \u7684\u8BE6\u60C5").option("-n, --limit <N>", "\u5217\u8868\u6A21\u5F0F\u663E\u793A\u6761\u6570", "10").option("--events", "\u6309\u4E8B\u4EF6\u65F6\u95F4\u7EBF\u5C55\u793A spans/logs/LLM \u5185\u5BB9\u6458\u8981").option("--raw", "\u8F93\u51FA\u539F\u59CB trace \u805A\u5408 JSON\uFF08\u534F\u8BAE/P0 \u8C03\u8BD5\u7528\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").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").option("--output <fmt>", "\u517C\u5BB9\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml\uFF1B\u8C03\u8BD5\u539F\u6587\u4F18\u5148\u7528 --raw", "table").action((traceId, opts) => traceCommand(traceId ?? null, opts));
|
|
19516
19693
|
program.command("mini").description("\u5DF2\u79FB\u9664\uFF1A\u8BF7\u6539\u7528 hcm workspace").allowUnknownOption(true).allowExcessArguments(true).argument("[args...]").action(() => removedMiniCommand());
|