@hcmai/cli 0.21.14 → 0.22.1
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 +208 -37
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +2 -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
|
|
@@ -10183,6 +10185,7 @@ async function workspaceAddMiniCommand(appCode, args) {
|
|
|
10183
10185
|
workspaceKey: context.workspaceKey,
|
|
10184
10186
|
targetDir: path9.join(rootDir, MINI_APPS_DIR, appCode),
|
|
10185
10187
|
name: args.name,
|
|
10188
|
+
runtimeSdkVersion: args.sdkVersion,
|
|
10186
10189
|
defaultSurface: parseSurface(args.surface),
|
|
10187
10190
|
templateKind,
|
|
10188
10191
|
writableModel: model,
|
|
@@ -10397,22 +10400,27 @@ async function workspacePushCommand(args) {
|
|
|
10397
10400
|
if (!args.dryRun) {
|
|
10398
10401
|
requireWorkspaceActivation(await probeActiveWorkspaceKey(client3), context.workspaceKey);
|
|
10399
10402
|
}
|
|
10403
|
+
const miniPlans = [];
|
|
10404
|
+
for (const app of miniApps) {
|
|
10405
|
+
miniPlans.push({ app, plan: await pushMiniAppProject({ http: client3.raw(), rootDir: app.dir, dryRun: true }) });
|
|
10406
|
+
}
|
|
10400
10407
|
const rawResult = await pushWorkspaceRawFiles({
|
|
10401
10408
|
http: client3.raw(),
|
|
10402
10409
|
rootDir,
|
|
10403
10410
|
context,
|
|
10404
10411
|
dryRun: !!args.dryRun,
|
|
10405
10412
|
profile,
|
|
10413
|
+
extraPreflight: await collectMiniPreflightCandidates(miniPlans),
|
|
10406
10414
|
onProgress: (progress) => {
|
|
10407
10415
|
pushProgress = progress;
|
|
10408
10416
|
}
|
|
10409
10417
|
});
|
|
10410
10418
|
const results = [];
|
|
10411
|
-
for (const app of
|
|
10412
|
-
const result = await pushMiniAppProject({
|
|
10419
|
+
for (const { app, plan } of miniPlans) {
|
|
10420
|
+
const result = args.dryRun ? plan : await pushMiniAppProject({
|
|
10413
10421
|
http: client3.raw(),
|
|
10414
10422
|
rootDir: app.dir,
|
|
10415
|
-
dryRun:
|
|
10423
|
+
dryRun: false
|
|
10416
10424
|
});
|
|
10417
10425
|
results.push({ app, result });
|
|
10418
10426
|
}
|
|
@@ -10421,7 +10429,8 @@ async function workspacePushCommand(args) {
|
|
|
10421
10429
|
if (!args.dryRun) {
|
|
10422
10430
|
requireWorkspaceActivation(await probeActiveWorkspaceKey(client3), context.workspaceKey, true);
|
|
10423
10431
|
}
|
|
10424
|
-
|
|
10432
|
+
const preflightBlocks = !!args.dryRun && !!rawResult.preflight && (rawResult.preflight.status === "failed" || rawResult.preflight.status === "unavailable");
|
|
10433
|
+
process.exitCode = rawResult.conflicts.length || preflightBlocks || results.some((item) => item.result.conflicts.length) ? 3 : 0;
|
|
10425
10434
|
}, args.env ?? args.profile);
|
|
10426
10435
|
return;
|
|
10427
10436
|
} catch (e) {
|
|
@@ -10487,6 +10496,27 @@ async function workspaceVerifyCommand(args) {
|
|
|
10487
10496
|
const client3 = await loadProfileClient(authArgs);
|
|
10488
10497
|
const smokeAccessToken = args.smoke ? await loadSmokeAccessToken(client3, authArgs) : null;
|
|
10489
10498
|
const rawStatus = await getWorkspaceRawStatus(rootDir, context);
|
|
10499
|
+
const miniPlans = [];
|
|
10500
|
+
for (const app of miniApps) {
|
|
10501
|
+
const validation = await validateMiniProject(app.dir);
|
|
10502
|
+
let plan = null;
|
|
10503
|
+
let planSkipped;
|
|
10504
|
+
if (!validation.valid) {
|
|
10505
|
+
planSkipped = "validation failed";
|
|
10506
|
+
} else if (!client3) {
|
|
10507
|
+
planSkipped = "profile not configured";
|
|
10508
|
+
} else {
|
|
10509
|
+
try {
|
|
10510
|
+
plan = await pushMiniAppProject({ http: client3.raw(), rootDir: app.dir, dryRun: true });
|
|
10511
|
+
} catch (planErr) {
|
|
10512
|
+
planSkipped = planErr.message ?? "push dry-run failed";
|
|
10513
|
+
}
|
|
10514
|
+
}
|
|
10515
|
+
miniPlans.push({ app, validation, plan, planSkipped });
|
|
10516
|
+
}
|
|
10517
|
+
const miniCandidates = await collectMiniPreflightCandidates(
|
|
10518
|
+
miniPlans.flatMap(({ app, plan }) => plan ? [{ app, plan }] : [])
|
|
10519
|
+
);
|
|
10490
10520
|
let rawPlan = null;
|
|
10491
10521
|
let rawPlanSkipped;
|
|
10492
10522
|
if (!client3) {
|
|
@@ -10497,34 +10527,17 @@ async function workspaceVerifyCommand(args) {
|
|
|
10497
10527
|
http: client3.raw(),
|
|
10498
10528
|
rootDir,
|
|
10499
10529
|
context,
|
|
10500
|
-
dryRun: true
|
|
10530
|
+
dryRun: true,
|
|
10531
|
+
extraPreflight: miniCandidates
|
|
10501
10532
|
});
|
|
10502
10533
|
} catch (planErr) {
|
|
10503
10534
|
rawPlanSkipped = planErr.message ?? "workspace raw dry-run failed";
|
|
10504
10535
|
}
|
|
10505
10536
|
}
|
|
10506
10537
|
const reports = [];
|
|
10507
|
-
for (const app of
|
|
10508
|
-
const validation = await validateMiniProject(app.dir);
|
|
10538
|
+
for (const { app, validation, plan: pushResult, planSkipped } of miniPlans) {
|
|
10509
10539
|
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
|
-
}
|
|
10540
|
+
const plan = pushResult ? { operations: pushResult.operations, conflicts: pushResult.conflicts } : null;
|
|
10528
10541
|
const previewTargets = await buildMiniPreviewTargets(app.dir, frontend).catch(
|
|
10529
10542
|
() => []
|
|
10530
10543
|
);
|
|
@@ -10535,7 +10548,8 @@ async function workspaceVerifyCommand(args) {
|
|
|
10535
10548
|
previewTargets: preview,
|
|
10536
10549
|
accessToken: smokeAccessToken
|
|
10537
10550
|
}) : null;
|
|
10538
|
-
const
|
|
10551
|
+
const preflight = miniAppPreflight(rawPlan?.preflight, validation.appCode ?? app.appCode, miniCandidates);
|
|
10552
|
+
const ok = validation.valid && !!plan && plan.conflicts.length === 0 && (!smoke || smoke.ok) && preflight?.status !== "failed";
|
|
10539
10553
|
const report = {
|
|
10540
10554
|
ok,
|
|
10541
10555
|
validate: validation,
|
|
@@ -10543,7 +10557,8 @@ async function workspaceVerifyCommand(args) {
|
|
|
10543
10557
|
plan,
|
|
10544
10558
|
planSkipped,
|
|
10545
10559
|
preview,
|
|
10546
|
-
smoke
|
|
10560
|
+
smoke,
|
|
10561
|
+
preflight
|
|
10547
10562
|
};
|
|
10548
10563
|
reports.push({
|
|
10549
10564
|
appCode: app.appCode,
|
|
@@ -10559,8 +10574,7 @@ async function workspaceVerifyCommand(args) {
|
|
|
10559
10574
|
reports,
|
|
10560
10575
|
args.output ?? "table"
|
|
10561
10576
|
);
|
|
10562
|
-
|
|
10563
|
-
process.exitCode = rawOk && reports.every((item) => item.report.ok) ? 0 : 1;
|
|
10577
|
+
process.exitCode = workspaceVerifyOk(rawPlan, reports) ? 0 : rawPlan?.preflight?.status === "unavailable" && workspaceRawPlanOk(rawPlan) && reports.every((item) => item.report.ok) ? 3 : 1;
|
|
10564
10578
|
return;
|
|
10565
10579
|
} catch (e) {
|
|
10566
10580
|
exitWorkspaceError(e, args.env ?? args.profile);
|
|
@@ -10789,7 +10803,36 @@ async function pushWorkspaceRawFiles(args) {
|
|
|
10789
10803
|
operations: plan.operations,
|
|
10790
10804
|
conflicts: plan.conflicts
|
|
10791
10805
|
};
|
|
10792
|
-
|
|
10806
|
+
const extra = args.extraPreflight ?? { files: [], deletedPaths: [] };
|
|
10807
|
+
if (plan.conflicts.length && !extra.files.length && !extra.deletedPaths.length) return result;
|
|
10808
|
+
result.preflight = await preflightWorkspacePlan(
|
|
10809
|
+
args.http,
|
|
10810
|
+
args.context.workspaceKey,
|
|
10811
|
+
plan.conflicts.length ? [] : plan.operations,
|
|
10812
|
+
localFiles,
|
|
10813
|
+
extra,
|
|
10814
|
+
args.profile ?? args.context.profile
|
|
10815
|
+
);
|
|
10816
|
+
if (args.dryRun) return result;
|
|
10817
|
+
if (result.preflight.status === "failed") {
|
|
10818
|
+
throw new CliError25({
|
|
10819
|
+
code: CliErrorCode26.INVALID_ARGUMENT,
|
|
10820
|
+
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
|
|
10821
|
+
${formatPreflightIssues(result.preflight.issues, " ")}`,
|
|
10822
|
+
profile: args.profile ?? args.context.profile,
|
|
10823
|
+
context: {
|
|
10824
|
+
reason: "WORKSPACE_PREFLIGHT_FAILED",
|
|
10825
|
+
workspaceKey: args.context.workspaceKey,
|
|
10826
|
+
details: { preflight: result.preflight },
|
|
10827
|
+
nextStep: result.preflight.nextStep
|
|
10828
|
+
}
|
|
10829
|
+
});
|
|
10830
|
+
}
|
|
10831
|
+
if (result.preflight.status === "unavailable") {
|
|
10832
|
+
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
|
|
10833
|
+
`);
|
|
10834
|
+
}
|
|
10835
|
+
if (plan.conflicts.length) return result;
|
|
10793
10836
|
const localByPath = new Map(localFiles.map((file) => [file.localPath, file]));
|
|
10794
10837
|
const snapshots = new Map(manifest2.files.map((file) => [file.localPath, file]));
|
|
10795
10838
|
const committed = [];
|
|
@@ -10889,6 +10932,125 @@ async function pushWorkspaceRawFiles(args) {
|
|
|
10889
10932
|
}
|
|
10890
10933
|
return result;
|
|
10891
10934
|
}
|
|
10935
|
+
async function preflightWorkspacePlan(http, workspaceKey, operations, localFiles, extra, profile) {
|
|
10936
|
+
const localByPath = new Map(localFiles.map((file) => [file.localPath, file]));
|
|
10937
|
+
const files = [];
|
|
10938
|
+
const deletedPaths = [];
|
|
10939
|
+
for (const operation of operations) {
|
|
10940
|
+
if (operation.operation === "create" || operation.operation === "update") {
|
|
10941
|
+
const localFile = localByPath.get(operation.localPath);
|
|
10942
|
+
if (localFile) files.push({ relativePath: operation.remotePath, content: localFile.content });
|
|
10943
|
+
} else if (operation.operation === "delete") {
|
|
10944
|
+
deletedPaths.push(operation.remotePath);
|
|
10945
|
+
}
|
|
10946
|
+
}
|
|
10947
|
+
files.push(...extra.files);
|
|
10948
|
+
deletedPaths.push(...extra.deletedPaths);
|
|
10949
|
+
const sent = files.length + deletedPaths.length;
|
|
10950
|
+
if (sent === 0) {
|
|
10951
|
+
return { status: "nothing-to-check", sent, checked: 0, issues: [], reason: "\u8BA1\u5212\u91CC\u6CA1\u6709\u8981\u5199\u5165\u6216\u5220\u9664\u7684\u6587\u4EF6" };
|
|
10952
|
+
}
|
|
10953
|
+
try {
|
|
10954
|
+
const verdict = await validateWorkspaceFiles(http, workspaceKey, files, deletedPaths);
|
|
10955
|
+
if (!verdict.ok) {
|
|
10956
|
+
return {
|
|
10957
|
+
status: "failed",
|
|
10958
|
+
sent,
|
|
10959
|
+
checked: verdict.checked,
|
|
10960
|
+
issues: verdict.issues,
|
|
10961
|
+
nextStep: preflightFailureNextStep(verdict.issues)
|
|
10962
|
+
};
|
|
10963
|
+
}
|
|
10964
|
+
if (verdict.checked !== sent) {
|
|
10965
|
+
return {
|
|
10966
|
+
status: "unavailable",
|
|
10967
|
+
sent,
|
|
10968
|
+
checked: verdict.checked,
|
|
10969
|
+
issues: [],
|
|
10970
|
+
reason: `\u670D\u52A1\u7AEF\u53EA\u68C0\u67E5\u4E86 ${verdict.checked}/${sent} \u4E2A\u6587\u4EF6\uFF0C\u7ED3\u8BBA\u4E0D\u8986\u76D6\u6574\u4EFD\u8BA1\u5212`,
|
|
10971
|
+
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"
|
|
10972
|
+
};
|
|
10973
|
+
}
|
|
10974
|
+
return { status: "passed", sent, checked: verdict.checked, issues: [] };
|
|
10975
|
+
} catch (error) {
|
|
10976
|
+
const status = error?.response?.status;
|
|
10977
|
+
const translated = error?.isAxiosError ? fromAxiosError22(error, profile) : error;
|
|
10978
|
+
const detail = translated instanceof Error ? translated.message : String(translated);
|
|
10979
|
+
return {
|
|
10980
|
+
status: "unavailable",
|
|
10981
|
+
sent,
|
|
10982
|
+
checked: 0,
|
|
10983
|
+
issues: [],
|
|
10984
|
+
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}`,
|
|
10985
|
+
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"
|
|
10986
|
+
};
|
|
10987
|
+
}
|
|
10988
|
+
}
|
|
10989
|
+
async function collectMiniPreflightCandidates(plans) {
|
|
10990
|
+
const candidates = { files: [], deletedPaths: [] };
|
|
10991
|
+
for (const { app, plan } of plans) {
|
|
10992
|
+
if (plan.conflicts.length) continue;
|
|
10993
|
+
const writes = await collectMiniPushWrites(app.dir, plan.operations);
|
|
10994
|
+
candidates.files.push(...writes.files);
|
|
10995
|
+
candidates.deletedPaths.push(...writes.deletedPaths);
|
|
10996
|
+
}
|
|
10997
|
+
return candidates;
|
|
10998
|
+
}
|
|
10999
|
+
function miniAppPreflight(preflight, appCode, candidates) {
|
|
11000
|
+
if (!preflight) return void 0;
|
|
11001
|
+
const prefix = `mini_apps/${appCode}/`;
|
|
11002
|
+
const sent = [...candidates.files.map((file) => file.relativePath), ...candidates.deletedPaths].filter((relativePath) => relativePath.startsWith(prefix)).length;
|
|
11003
|
+
const issues = preflight.issues.filter((issue) => issue.path === null || issue.path.startsWith(prefix)).map((issue) => ({ path: issue.path, errCode: issue.errCode, message: issue.message }));
|
|
11004
|
+
if (issues.length) return { status: "failed", sent, issues };
|
|
11005
|
+
if (!sent) return { status: "nothing-to-check", sent, issues };
|
|
11006
|
+
return { status: preflight.status === "failed" ? "passed" : preflight.status, sent, issues };
|
|
11007
|
+
}
|
|
11008
|
+
function formatPreflightIssues(issues, indent2 = "") {
|
|
11009
|
+
return issues.map((issue) => {
|
|
11010
|
+
const lines = [`${indent2}\u2717 ${issue.path ?? "(\u6574\u6279)"} [${issue.errCode ?? "ERROR"}] ${issue.message}`];
|
|
11011
|
+
if (issue.description) lines.push(`${indent2} \u21B3 ${issue.description}`);
|
|
11012
|
+
const holder = conflictHolder(issue);
|
|
11013
|
+
if (holder) lines.push(`${indent2} \u21B3 \u5360\u7528\u65B9\uFF1A\u5F00\u53D1\u7A7A\u95F4 ${holder}`);
|
|
11014
|
+
return lines.join("\n");
|
|
11015
|
+
}).join("\n");
|
|
11016
|
+
}
|
|
11017
|
+
function conflictHolder(issue) {
|
|
11018
|
+
const data = issue.data;
|
|
11019
|
+
if (typeof data?.conflictingWorkspaceKey !== "string" || !data.conflictingWorkspaceKey) return void 0;
|
|
11020
|
+
const owner = typeof data.conflictingOwnerUserName === "string" && data.conflictingOwnerUserName ? `\uFF08${data.conflictingOwnerUserName}\uFF09` : "";
|
|
11021
|
+
return `${data.conflictingWorkspaceKey}${owner}`;
|
|
11022
|
+
}
|
|
11023
|
+
function preflightFailureNextStep(issues) {
|
|
11024
|
+
const steps = [];
|
|
11025
|
+
if (issues.some((issue) => !conflictHolder(issue))) {
|
|
11026
|
+
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");
|
|
11027
|
+
}
|
|
11028
|
+
if (issues.some((issue) => conflictHolder(issue))) {
|
|
11029
|
+
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");
|
|
11030
|
+
}
|
|
11031
|
+
return steps.join(" ");
|
|
11032
|
+
}
|
|
11033
|
+
function workspaceRawPlanOk(plan) {
|
|
11034
|
+
return !!plan && !plan.conflicts.length;
|
|
11035
|
+
}
|
|
11036
|
+
function workspacePreflightOk(preflight) {
|
|
11037
|
+
return preflight?.status === "passed" || preflight?.status === "nothing-to-check";
|
|
11038
|
+
}
|
|
11039
|
+
function workspaceVerifyOk(plan, reports) {
|
|
11040
|
+
return workspaceRawPlanOk(plan) && workspacePreflightOk(plan?.preflight) && reports.every((item) => item.report.ok);
|
|
11041
|
+
}
|
|
11042
|
+
function withoutPreflight(result) {
|
|
11043
|
+
const rest = { ...result };
|
|
11044
|
+
delete rest.preflight;
|
|
11045
|
+
return rest;
|
|
11046
|
+
}
|
|
11047
|
+
function formatPreflightSummary(preflight, indent2 = "") {
|
|
11048
|
+
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})`;
|
|
11049
|
+
const lines = [`${indent2}${head}`];
|
|
11050
|
+
if (preflight.issues.length) lines.push(formatPreflightIssues(preflight.issues, `${indent2} `));
|
|
11051
|
+
if (preflight.nextStep) lines.push(`${indent2} next: ${preflight.nextStep}`);
|
|
11052
|
+
return lines.join("\n");
|
|
11053
|
+
}
|
|
10892
11054
|
async function loadWorkspaceRawRemoteFiles(http, workspaceKey) {
|
|
10893
11055
|
const list = await listWorkspaceFiles(http, workspaceKey, { pageSize: 5e3 });
|
|
10894
11056
|
const result = [];
|
|
@@ -11357,7 +11519,9 @@ function writeWorkspacePushResult(rawResult, results, format) {
|
|
|
11357
11519
|
process.stdout.write(
|
|
11358
11520
|
formatObject22(
|
|
11359
11521
|
{
|
|
11360
|
-
|
|
11522
|
+
// 预检覆盖整份计划(workspace 文件 + 轻应用文件),放在顶层。
|
|
11523
|
+
preflight: rawResult.preflight ?? null,
|
|
11524
|
+
workspaceFiles: { artifact: "workspace", ...withoutPreflight(rawResult) },
|
|
11361
11525
|
miniApps: results.map((item) => ({
|
|
11362
11526
|
artifact: `mini:${item.app.appCode}`,
|
|
11363
11527
|
...item.result
|
|
@@ -11383,6 +11547,9 @@ function writeWorkspacePushResult(rawResult, results, format) {
|
|
|
11383
11547
|
}))
|
|
11384
11548
|
);
|
|
11385
11549
|
const conflicts = [...rawConflicts, ...miniConflicts];
|
|
11550
|
+
if (rawResult.preflight) {
|
|
11551
|
+
process.stdout.write(formatPreflightSummary(rawResult.preflight) + "\n");
|
|
11552
|
+
}
|
|
11386
11553
|
if (conflicts.length) {
|
|
11387
11554
|
process.stdout.write("conflicts:\n" + formatRows6(conflicts, { format: "table" }) + "\n");
|
|
11388
11555
|
return;
|
|
@@ -11410,8 +11577,9 @@ function writeWorkspacePushResult(rawResult, results, format) {
|
|
|
11410
11577
|
}
|
|
11411
11578
|
}
|
|
11412
11579
|
function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
11413
|
-
const rawOk =
|
|
11414
|
-
const ok =
|
|
11580
|
+
const rawOk = workspaceRawPlanOk(raw.plan);
|
|
11581
|
+
const ok = workspaceVerifyOk(raw.plan, reports);
|
|
11582
|
+
const preflight = raw.plan?.preflight ?? null;
|
|
11415
11583
|
if (format === "json") {
|
|
11416
11584
|
process.stdout.write(
|
|
11417
11585
|
formatObject22(
|
|
@@ -11419,6 +11587,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
11419
11587
|
ok,
|
|
11420
11588
|
workspaceKey: context.workspaceKey,
|
|
11421
11589
|
rootDir,
|
|
11590
|
+
preflight,
|
|
11422
11591
|
workspaceFiles: {
|
|
11423
11592
|
ok: rawOk,
|
|
11424
11593
|
status: summarizeStatus(raw.status),
|
|
@@ -11446,7 +11615,8 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
11446
11615
|
ok,
|
|
11447
11616
|
workspaceKey: context.workspaceKey,
|
|
11448
11617
|
rootDir,
|
|
11449
|
-
|
|
11618
|
+
preflight,
|
|
11619
|
+
workspaceFiles: { ...raw, plan: raw.plan ? withoutPreflight(raw.plan) : null },
|
|
11450
11620
|
miniApps: reports
|
|
11451
11621
|
},
|
|
11452
11622
|
{ format }
|
|
@@ -11461,6 +11631,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
11461
11631
|
`workspace files: ${raw.status.length}`,
|
|
11462
11632
|
`mini apps: ${reports.length}`
|
|
11463
11633
|
];
|
|
11634
|
+
if (preflight) lines.push("", formatPreflightSummary(preflight));
|
|
11464
11635
|
lines.push("", "workspace files");
|
|
11465
11636
|
if (raw.planSkipped) {
|
|
11466
11637
|
lines.push(` dry-run skipped: ${raw.planSkipped}`);
|
|
@@ -19506,7 +19677,7 @@ workspace.command("bind <workspaceKey>").description("\u628A\u5F53\u524D\u76EE\u
|
|
|
19506
19677
|
workspace.command("create <workspaceKey>").description("\u65B0\u5EFA\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4\uFF0C\u5E76\u5728\u672C\u5730\u76EE\u5F55\u5199\u5165 workspace \u7ED1\u5B9A").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--description <text>", "\u5F00\u53D1\u7A7A\u95F4\u8BF4\u660E").option("--activate", "\u521B\u5EFA\u540E\u7ED1\u5B9A\u4E3A\u5F53\u524D\u5F00\u53D1\u7A7A\u95F4").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("--force", "\u672C\u5730\u76EE\u5F55\u5DF2\u6709\u4E0D\u540C workspace \u7ED1\u5B9A\u65F6\u5F3A\u5236\u8986\u76D6").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((workspaceKey, opts) => workspaceCreateCommand(workspaceKey, opts));
|
|
19507
19678
|
workspace.command("pull").description("\u4ECE\u5F00\u53D1\u7A7A\u95F4\u62C9\u53D6\u6587\u4EF6\u5305\u5230\u672C\u5730\uFF1Bmini_apps \u4F1A\u751F\u6210\u53EF\u9A8C\u8BC1\u7684 artifact \u4E0A\u4E0B\u6587").option("--workspace <key>", "\u79DF\u6237\u5F00\u53D1\u7A7A\u95F4 key\uFF1B\u672A\u63D0\u4F9B\u65F6\u8BFB\u53D6\u672C\u5730\u7ED1\u5B9A").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("--force", "\u5F3A\u5236\u8986\u76D6\u5DF2\u6709\u7684\u672C\u5730\u6587\u4EF6").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspacePullCommand(opts));
|
|
19508
19679
|
var workspaceAdd = workspace.command("add").description("\u5411\u5DF2\u7ED1\u5B9A\u5F00\u53D1\u7A7A\u95F4\u6DFB\u52A0 artifact");
|
|
19509
|
-
workspaceAdd.command("mini <appCode>").description("\u65B0\u589E\u8F7B\u5E94\u7528 artifact\uFF08\u5199\u5165 mini_apps/<appCode>/\uFF09").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--name <name>", "\u8F7B\u5E94\u7528\u5C55\u793A\u540D").option("--template <kind>", "\u6A21\u677F\uFF1Adashboard | multi-page | writable-workbench", "dashboard").option("--model <Model>", "\u53EF\u5199\u5DE5\u4F5C\u53F0\u7ED1\u5B9A\u7684 Model\uFF0C\u4F8B\u5982 OrgUnit").option("--fields <csv|auto>", "\u53EF\u5199\u5DE5\u4F5C\u53F0\u8868\u5355\u5B57\u6BB5\u5217\u8868\uFF1B\u4F20 auto \u65F6\u6839\u636E Model \u5143\u6570\u636E\u63A8\u65AD").option("--defaults <JSON|auto>", "\u53EF\u5199\u5DE5\u4F5C\u53F0\u521B\u5EFA\u9ED8\u8BA4\u503C\uFF1B\u4F20 auto \u65F6\u6839\u636E Model \u5143\u6570\u636E\u63A8\u65AD").option(
|
|
19680
|
+
workspaceAdd.command("mini <appCode>").description("\u65B0\u589E\u8F7B\u5E94\u7528 artifact\uFF08\u5199\u5165 mini_apps/<appCode>/\uFF09").option("--dir <path>", "\u5DE5\u4F5C\u7A7A\u95F4\u672C\u5730\u76EE\u5F55", ".").option("--name <name>", "\u8F7B\u5E94\u7528\u5C55\u793A\u540D").option("--template <kind>", "\u6A21\u677F\uFF1Adashboard | multi-page | writable-workbench", "dashboard").option("--sdk-version <semver>", "\u76EE\u6807 Core \u7684\u8F7B\u5E94\u7528\u8FD0\u884C\u65F6 ABI\uFF08\u9ED8\u8BA4 0.1.0\uFF0C\u72EC\u7ACB\u4E8E CLI \u5305\u7248\u672C\uFF1B\u4E0D\u63A2\u6D4B\u7EBF\u4E0A\u7248\u672C\uFF09").option("--model <Model>", "\u53EF\u5199\u5DE5\u4F5C\u53F0\u7ED1\u5B9A\u7684 Model\uFF0C\u4F8B\u5982 OrgUnit").option("--fields <csv|auto>", "\u53EF\u5199\u5DE5\u4F5C\u53F0\u8868\u5355\u5B57\u6BB5\u5217\u8868\uFF1B\u4F20 auto \u65F6\u6839\u636E Model \u5143\u6570\u636E\u63A8\u65AD").option("--defaults <JSON|auto>", "\u53EF\u5199\u5DE5\u4F5C\u53F0\u521B\u5EFA\u9ED8\u8BA4\u503C\uFF1B\u4F20 auto \u65F6\u6839\u636E Model \u5143\u6570\u636E\u63A8\u65AD").option(
|
|
19510
19681
|
"--surface <surface>",
|
|
19511
19682
|
"\u8FD0\u884C\u5F62\u6001\uFF1Aembedded\uFF08\u5D4C\u5165\u4E1A\u52A1\u9875\uFF09| standalone\uFF08\u72EC\u7ACB\u9875\uFF09",
|
|
19512
19683
|
"embedded"
|
|
@@ -19514,10 +19685,10 @@ workspaceAdd.command("mini <appCode>").description("\u65B0\u589E\u8F7B\u5E94\u75
|
|
|
19514
19685
|
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
19686
|
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
19687
|
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\
|
|
19688
|
+
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
19689
|
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
19690
|
workspace.command("verify").description(
|
|
19520
|
-
"\u4E00\u952E\u9A8C\u6536\uFF1A\u4E32\u8054 validate + status + push --dry-run
|
|
19691
|
+
"\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
19692
|
).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
19693
|
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
19694
|
program.command("mini").description("\u5DF2\u79FB\u9664\uFF1A\u8BF7\u6539\u7528 hcm workspace").allowUnknownOption(true).allowExcessArguments(true).argument("[args...]").action(() => removedMiniCommand());
|