@hcmai/cli 0.21.14 → 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 +206 -36
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -9787,6 +9787,7 @@ import * as path9 from "path";
|
|
|
9787
9787
|
import {
|
|
9788
9788
|
buildMiniPreviewTargets,
|
|
9789
9789
|
buildMiniVerifyAgentReport,
|
|
9790
|
+
collectMiniPushWrites,
|
|
9790
9791
|
createWorkspaceFile,
|
|
9791
9792
|
deleteWorkspaceFile,
|
|
9792
9793
|
formatMiniVerifyReport,
|
|
@@ -9807,6 +9808,7 @@ import {
|
|
|
9807
9808
|
saveWorkspaceFileContent,
|
|
9808
9809
|
validateMiniProject,
|
|
9809
9810
|
validateMetaContent as validateMetaContent2,
|
|
9811
|
+
validateWorkspaceFiles,
|
|
9810
9812
|
fromAxiosError as fromAxiosError22,
|
|
9811
9813
|
CliError as CliError25,
|
|
9812
9814
|
CliErrorCode as CliErrorCode26
|
|
@@ -10397,22 +10399,27 @@ async function workspacePushCommand(args) {
|
|
|
10397
10399
|
if (!args.dryRun) {
|
|
10398
10400
|
requireWorkspaceActivation(await probeActiveWorkspaceKey(client3), context.workspaceKey);
|
|
10399
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
|
+
}
|
|
10400
10406
|
const rawResult = await pushWorkspaceRawFiles({
|
|
10401
10407
|
http: client3.raw(),
|
|
10402
10408
|
rootDir,
|
|
10403
10409
|
context,
|
|
10404
10410
|
dryRun: !!args.dryRun,
|
|
10405
10411
|
profile,
|
|
10412
|
+
extraPreflight: await collectMiniPreflightCandidates(miniPlans),
|
|
10406
10413
|
onProgress: (progress) => {
|
|
10407
10414
|
pushProgress = progress;
|
|
10408
10415
|
}
|
|
10409
10416
|
});
|
|
10410
10417
|
const results = [];
|
|
10411
|
-
for (const app of
|
|
10412
|
-
const result = await pushMiniAppProject({
|
|
10418
|
+
for (const { app, plan } of miniPlans) {
|
|
10419
|
+
const result = args.dryRun ? plan : await pushMiniAppProject({
|
|
10413
10420
|
http: client3.raw(),
|
|
10414
10421
|
rootDir: app.dir,
|
|
10415
|
-
dryRun:
|
|
10422
|
+
dryRun: false
|
|
10416
10423
|
});
|
|
10417
10424
|
results.push({ app, result });
|
|
10418
10425
|
}
|
|
@@ -10421,7 +10428,8 @@ async function workspacePushCommand(args) {
|
|
|
10421
10428
|
if (!args.dryRun) {
|
|
10422
10429
|
requireWorkspaceActivation(await probeActiveWorkspaceKey(client3), context.workspaceKey, true);
|
|
10423
10430
|
}
|
|
10424
|
-
|
|
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;
|
|
10425
10433
|
}, args.env ?? args.profile);
|
|
10426
10434
|
return;
|
|
10427
10435
|
} catch (e) {
|
|
@@ -10487,6 +10495,27 @@ async function workspaceVerifyCommand(args) {
|
|
|
10487
10495
|
const client3 = await loadProfileClient(authArgs);
|
|
10488
10496
|
const smokeAccessToken = args.smoke ? await loadSmokeAccessToken(client3, authArgs) : null;
|
|
10489
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
|
+
);
|
|
10490
10519
|
let rawPlan = null;
|
|
10491
10520
|
let rawPlanSkipped;
|
|
10492
10521
|
if (!client3) {
|
|
@@ -10497,34 +10526,17 @@ async function workspaceVerifyCommand(args) {
|
|
|
10497
10526
|
http: client3.raw(),
|
|
10498
10527
|
rootDir,
|
|
10499
10528
|
context,
|
|
10500
|
-
dryRun: true
|
|
10529
|
+
dryRun: true,
|
|
10530
|
+
extraPreflight: miniCandidates
|
|
10501
10531
|
});
|
|
10502
10532
|
} catch (planErr) {
|
|
10503
10533
|
rawPlanSkipped = planErr.message ?? "workspace raw dry-run failed";
|
|
10504
10534
|
}
|
|
10505
10535
|
}
|
|
10506
10536
|
const reports = [];
|
|
10507
|
-
for (const app of
|
|
10508
|
-
const validation = await validateMiniProject(app.dir);
|
|
10537
|
+
for (const { app, validation, plan: pushResult, planSkipped } of miniPlans) {
|
|
10509
10538
|
const status = await readMiniStatusSafely(app);
|
|
10510
|
-
|
|
10511
|
-
let planSkipped;
|
|
10512
|
-
if (!validation.valid) {
|
|
10513
|
-
planSkipped = "validation failed";
|
|
10514
|
-
} else if (!client3) {
|
|
10515
|
-
planSkipped = "profile not configured";
|
|
10516
|
-
} else {
|
|
10517
|
-
try {
|
|
10518
|
-
const pushResult = await pushMiniAppProject({
|
|
10519
|
-
http: client3.raw(),
|
|
10520
|
-
rootDir: app.dir,
|
|
10521
|
-
dryRun: true
|
|
10522
|
-
});
|
|
10523
|
-
plan = { operations: pushResult.operations, conflicts: pushResult.conflicts };
|
|
10524
|
-
} catch (planErr) {
|
|
10525
|
-
planSkipped = planErr.message ?? "push dry-run failed";
|
|
10526
|
-
}
|
|
10527
|
-
}
|
|
10539
|
+
const plan = pushResult ? { operations: pushResult.operations, conflicts: pushResult.conflicts } : null;
|
|
10528
10540
|
const previewTargets = await buildMiniPreviewTargets(app.dir, frontend).catch(
|
|
10529
10541
|
() => []
|
|
10530
10542
|
);
|
|
@@ -10535,7 +10547,8 @@ async function workspaceVerifyCommand(args) {
|
|
|
10535
10547
|
previewTargets: preview,
|
|
10536
10548
|
accessToken: smokeAccessToken
|
|
10537
10549
|
}) : null;
|
|
10538
|
-
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";
|
|
10539
10552
|
const report = {
|
|
10540
10553
|
ok,
|
|
10541
10554
|
validate: validation,
|
|
@@ -10543,7 +10556,8 @@ async function workspaceVerifyCommand(args) {
|
|
|
10543
10556
|
plan,
|
|
10544
10557
|
planSkipped,
|
|
10545
10558
|
preview,
|
|
10546
|
-
smoke
|
|
10559
|
+
smoke,
|
|
10560
|
+
preflight
|
|
10547
10561
|
};
|
|
10548
10562
|
reports.push({
|
|
10549
10563
|
appCode: app.appCode,
|
|
@@ -10559,8 +10573,7 @@ async function workspaceVerifyCommand(args) {
|
|
|
10559
10573
|
reports,
|
|
10560
10574
|
args.output ?? "table"
|
|
10561
10575
|
);
|
|
10562
|
-
|
|
10563
|
-
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;
|
|
10564
10577
|
return;
|
|
10565
10578
|
} catch (e) {
|
|
10566
10579
|
exitWorkspaceError(e, args.env ?? args.profile);
|
|
@@ -10789,7 +10802,36 @@ async function pushWorkspaceRawFiles(args) {
|
|
|
10789
10802
|
operations: plan.operations,
|
|
10790
10803
|
conflicts: plan.conflicts
|
|
10791
10804
|
};
|
|
10792
|
-
|
|
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;
|
|
10793
10835
|
const localByPath = new Map(localFiles.map((file) => [file.localPath, file]));
|
|
10794
10836
|
const snapshots = new Map(manifest2.files.map((file) => [file.localPath, file]));
|
|
10795
10837
|
const committed = [];
|
|
@@ -10889,6 +10931,125 @@ async function pushWorkspaceRawFiles(args) {
|
|
|
10889
10931
|
}
|
|
10890
10932
|
return result;
|
|
10891
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
|
+
}
|
|
10892
11053
|
async function loadWorkspaceRawRemoteFiles(http, workspaceKey) {
|
|
10893
11054
|
const list = await listWorkspaceFiles(http, workspaceKey, { pageSize: 5e3 });
|
|
10894
11055
|
const result = [];
|
|
@@ -11357,7 +11518,9 @@ function writeWorkspacePushResult(rawResult, results, format) {
|
|
|
11357
11518
|
process.stdout.write(
|
|
11358
11519
|
formatObject22(
|
|
11359
11520
|
{
|
|
11360
|
-
|
|
11521
|
+
// 预检覆盖整份计划(workspace 文件 + 轻应用文件),放在顶层。
|
|
11522
|
+
preflight: rawResult.preflight ?? null,
|
|
11523
|
+
workspaceFiles: { artifact: "workspace", ...withoutPreflight(rawResult) },
|
|
11361
11524
|
miniApps: results.map((item) => ({
|
|
11362
11525
|
artifact: `mini:${item.app.appCode}`,
|
|
11363
11526
|
...item.result
|
|
@@ -11383,6 +11546,9 @@ function writeWorkspacePushResult(rawResult, results, format) {
|
|
|
11383
11546
|
}))
|
|
11384
11547
|
);
|
|
11385
11548
|
const conflicts = [...rawConflicts, ...miniConflicts];
|
|
11549
|
+
if (rawResult.preflight) {
|
|
11550
|
+
process.stdout.write(formatPreflightSummary(rawResult.preflight) + "\n");
|
|
11551
|
+
}
|
|
11386
11552
|
if (conflicts.length) {
|
|
11387
11553
|
process.stdout.write("conflicts:\n" + formatRows6(conflicts, { format: "table" }) + "\n");
|
|
11388
11554
|
return;
|
|
@@ -11410,8 +11576,9 @@ function writeWorkspacePushResult(rawResult, results, format) {
|
|
|
11410
11576
|
}
|
|
11411
11577
|
}
|
|
11412
11578
|
function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
11413
|
-
const rawOk =
|
|
11414
|
-
const ok =
|
|
11579
|
+
const rawOk = workspaceRawPlanOk(raw.plan);
|
|
11580
|
+
const ok = workspaceVerifyOk(raw.plan, reports);
|
|
11581
|
+
const preflight = raw.plan?.preflight ?? null;
|
|
11415
11582
|
if (format === "json") {
|
|
11416
11583
|
process.stdout.write(
|
|
11417
11584
|
formatObject22(
|
|
@@ -11419,6 +11586,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
11419
11586
|
ok,
|
|
11420
11587
|
workspaceKey: context.workspaceKey,
|
|
11421
11588
|
rootDir,
|
|
11589
|
+
preflight,
|
|
11422
11590
|
workspaceFiles: {
|
|
11423
11591
|
ok: rawOk,
|
|
11424
11592
|
status: summarizeStatus(raw.status),
|
|
@@ -11446,7 +11614,8 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
11446
11614
|
ok,
|
|
11447
11615
|
workspaceKey: context.workspaceKey,
|
|
11448
11616
|
rootDir,
|
|
11449
|
-
|
|
11617
|
+
preflight,
|
|
11618
|
+
workspaceFiles: { ...raw, plan: raw.plan ? withoutPreflight(raw.plan) : null },
|
|
11450
11619
|
miniApps: reports
|
|
11451
11620
|
},
|
|
11452
11621
|
{ format }
|
|
@@ -11461,6 +11630,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
11461
11630
|
`workspace files: ${raw.status.length}`,
|
|
11462
11631
|
`mini apps: ${reports.length}`
|
|
11463
11632
|
];
|
|
11633
|
+
if (preflight) lines.push("", formatPreflightSummary(preflight));
|
|
11464
11634
|
lines.push("", "workspace files");
|
|
11465
11635
|
if (raw.planSkipped) {
|
|
11466
11636
|
lines.push(` dry-run skipped: ${raw.planSkipped}`);
|
|
@@ -19514,10 +19684,10 @@ workspaceAdd.command("mini <appCode>").description("\u65B0\u589E\u8F7B\u5E94\u75
|
|
|
19514
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));
|
|
19515
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));
|
|
19516
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));
|
|
19517
|
-
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));
|
|
19518
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));
|
|
19519
19689
|
workspace.command("verify").description(
|
|
19520
|
-
"\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"
|
|
19521
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));
|
|
19522
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));
|
|
19523
19693
|
program.command("mini").description("\u5DF2\u79FB\u9664\uFF1A\u8BF7\u6539\u7528 hcm workspace").allowUnknownOption(true).allowExcessArguments(true).argument("[args...]").action(() => removedMiniCommand());
|