@hcmai/cli 0.15.6 → 0.15.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/dist/index.js +561 -115
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +3 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -769,8 +769,8 @@ var init_TerminalRenderer = __esm({
|
|
|
769
769
|
}
|
|
770
770
|
}
|
|
771
771
|
/** 来源行(仅子代理触发,agentPath ≥2 段时显示 `↑ 来自 a › b`,对齐 Web)。 */
|
|
772
|
-
originLine(
|
|
773
|
-
const segs =
|
|
772
|
+
originLine(path19) {
|
|
773
|
+
const segs = path19.split(".").filter(Boolean);
|
|
774
774
|
if (segs.length < 2) return "";
|
|
775
775
|
const names = segs.map((k) => agentDisplayName(k));
|
|
776
776
|
return chalk.gray(` \u2191 \u6765\u81EA ${names.join(" \u203A ")}`) + "\n";
|
|
@@ -1952,8 +1952,8 @@ function agentLabel(agentId) {
|
|
|
1952
1952
|
if (/^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(agentId)) return `agent \u2026${agentId.slice(-4)}`;
|
|
1953
1953
|
return agentDisplayName(agentId);
|
|
1954
1954
|
}
|
|
1955
|
-
function originLine(
|
|
1956
|
-
const segs = (
|
|
1955
|
+
function originLine(path19) {
|
|
1956
|
+
const segs = (path19 ?? "").split(".").filter(Boolean);
|
|
1957
1957
|
if (segs.length < 2) return null;
|
|
1958
1958
|
return `\u6765\u81EA ${segs.map((k) => agentDisplayName(k)).join(" \u203A ")}`;
|
|
1959
1959
|
}
|
|
@@ -2376,7 +2376,7 @@ function launchBrowser(url, platform = process.platform, onFailure) {
|
|
|
2376
2376
|
child.unref();
|
|
2377
2377
|
}
|
|
2378
2378
|
async function runOpen(target, args, deps) {
|
|
2379
|
-
const
|
|
2379
|
+
const path19 = normalizeTarget(target);
|
|
2380
2380
|
if (!deps.frontend?.trim()) {
|
|
2381
2381
|
throw new CliError3({
|
|
2382
2382
|
code: CliErrorCode2.INVALID_ARGUMENT,
|
|
@@ -2384,13 +2384,13 @@ async function runOpen(target, args, deps) {
|
|
|
2384
2384
|
});
|
|
2385
2385
|
}
|
|
2386
2386
|
const { ticket, expiresIn } = await deps.mintTicket();
|
|
2387
|
-
const url = buildBrowserLoginUrl(deps.frontend, ticket,
|
|
2387
|
+
const url = buildBrowserLoginUrl(deps.frontend, ticket, path19);
|
|
2388
2388
|
if (args.printUrl) {
|
|
2389
2389
|
deps.write(`${url}
|
|
2390
2390
|
`);
|
|
2391
2391
|
} else {
|
|
2392
2392
|
deps.launch(url);
|
|
2393
|
-
deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${
|
|
2393
|
+
deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${path19}\uFF08\u7968\u636E ${expiresIn ?? 60}s \u5185\u6709\u6548\uFF0C\u53EA\u80FD\u7528\u4E00\u6B21\uFF09
|
|
2394
2394
|
`);
|
|
2395
2395
|
}
|
|
2396
2396
|
return { url, expiresIn };
|
|
@@ -4468,8 +4468,8 @@ import {
|
|
|
4468
4468
|
formatObject as formatObject7,
|
|
4469
4469
|
fromAxiosError as fromAxiosError9
|
|
4470
4470
|
} from "@hcmai/sdk";
|
|
4471
|
-
function collectYmlFiles(
|
|
4472
|
-
if (statSync(
|
|
4471
|
+
function collectYmlFiles(path19) {
|
|
4472
|
+
if (statSync(path19).isFile()) return [path19];
|
|
4473
4473
|
const out = [];
|
|
4474
4474
|
const walk = (dir) => {
|
|
4475
4475
|
for (const name of readdirSync(dir).sort()) {
|
|
@@ -4478,7 +4478,7 @@ function collectYmlFiles(path18) {
|
|
|
4478
4478
|
else if (full.endsWith(".yml") || full.endsWith(".yaml")) out.push(full);
|
|
4479
4479
|
}
|
|
4480
4480
|
};
|
|
4481
|
-
walk(
|
|
4481
|
+
walk(path19);
|
|
4482
4482
|
return out.sort();
|
|
4483
4483
|
}
|
|
4484
4484
|
var DRY_RUN_CLIENT = {
|
|
@@ -4486,9 +4486,9 @@ var DRY_RUN_CLIENT = {
|
|
|
4486
4486
|
create: async () => ({ id: "" }),
|
|
4487
4487
|
update: async () => ({})
|
|
4488
4488
|
};
|
|
4489
|
-
async function importCommand(
|
|
4489
|
+
async function importCommand(path19, args) {
|
|
4490
4490
|
try {
|
|
4491
|
-
const files = collectYmlFiles(
|
|
4491
|
+
const files = collectYmlFiles(path19);
|
|
4492
4492
|
const fixtures = files.map(
|
|
4493
4493
|
(f) => parseFixture(readFileSync2(f, "utf8"), relative(process.cwd(), f))
|
|
4494
4494
|
);
|
|
@@ -8780,10 +8780,10 @@ async function metaListCommand(args) {
|
|
|
8780
8780
|
fail7(e, args, "read");
|
|
8781
8781
|
}
|
|
8782
8782
|
}
|
|
8783
|
-
async function metaGetCommand(
|
|
8783
|
+
async function metaGetCommand(path19, args) {
|
|
8784
8784
|
try {
|
|
8785
8785
|
const c = await client2(args);
|
|
8786
|
-
const content = await getTenantMeta(c.raw(),
|
|
8786
|
+
const content = await getTenantMeta(c.raw(), path19);
|
|
8787
8787
|
process.stdout.write(content.endsWith("\n") ? content : content + "\n");
|
|
8788
8788
|
process.exitCode = 0;
|
|
8789
8789
|
return;
|
|
@@ -8792,8 +8792,8 @@ async function metaGetCommand(path18, args) {
|
|
|
8792
8792
|
}
|
|
8793
8793
|
}
|
|
8794
8794
|
var PROBEABLE_META_TYPES = /* @__PURE__ */ new Set(["model", "list", "info", "view", "filter", "page", "wiz", "impexp"]);
|
|
8795
|
-
function parseMetaPath(
|
|
8796
|
-
const base =
|
|
8795
|
+
function parseMetaPath(path19) {
|
|
8796
|
+
const base = path19.split(/[\\/]/).pop() ?? path19;
|
|
8797
8797
|
if (!/\.(yml|yaml)$/i.test(base)) return {};
|
|
8798
8798
|
const parts = base.replace(/\.(yml|yaml)$/i, "").split(".");
|
|
8799
8799
|
return { model: parts[0] || void 0, kind: parts[1] ?? "model", state: parts[2] };
|
|
@@ -8810,10 +8810,10 @@ function unverifiableReason(e) {
|
|
|
8810
8810
|
if (st == null) return `\u8BF7\u6C42\u6CA1\u53D1\u51FA\u53BB\u6216\u6CA1\u56DE\u6765\uFF08${err.code ?? err.message ?? "\u672A\u77E5"}\uFF09`;
|
|
8811
8811
|
return void 0;
|
|
8812
8812
|
}
|
|
8813
|
-
async function verifyAfterWrite(c,
|
|
8814
|
-
const { model, kind, state } = parseMetaPath(
|
|
8813
|
+
async function verifyAfterWrite(c, path19) {
|
|
8814
|
+
const { model, kind, state } = parseMetaPath(path19);
|
|
8815
8815
|
if (!model || !kind) {
|
|
8816
|
-
return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${
|
|
8816
|
+
return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path19} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
|
|
8817
8817
|
}
|
|
8818
8818
|
try {
|
|
8819
8819
|
await clearMetaCache2(c.raw(), model, {});
|
|
@@ -8858,7 +8858,7 @@ async function verifyAfterWrite(c, path18) {
|
|
|
8858
8858
|
}
|
|
8859
8859
|
return { status: "ok" };
|
|
8860
8860
|
}
|
|
8861
|
-
async function metaSetCommand(
|
|
8861
|
+
async function metaSetCommand(path19, args) {
|
|
8862
8862
|
try {
|
|
8863
8863
|
if (!args.file) {
|
|
8864
8864
|
throw new CliError22({
|
|
@@ -8874,9 +8874,9 @@ async function metaSetCommand(path18, args) {
|
|
|
8874
8874
|
process.stdin.on("error", reject);
|
|
8875
8875
|
}) : await fsp3.readFile(args.file, "utf8");
|
|
8876
8876
|
if (!args.skipValidate) {
|
|
8877
|
-
const result2 = validateMetaContent(
|
|
8877
|
+
const result2 = validateMetaContent(path19, content);
|
|
8878
8878
|
if (result2.issues.length > 0) {
|
|
8879
|
-
process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${
|
|
8879
|
+
process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path19}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
|
|
8880
8880
|
`);
|
|
8881
8881
|
process.stderr.write(formatMetaIssues(result2, " ") + "\n");
|
|
8882
8882
|
}
|
|
@@ -8895,13 +8895,13 @@ async function metaSetCommand(path18, args) {
|
|
|
8895
8895
|
if (dryFmt === "json" || dryFmt === "yaml") {
|
|
8896
8896
|
process.stdout.write(
|
|
8897
8897
|
formatObject20(
|
|
8898
|
-
{ dryRun: true, path:
|
|
8898
|
+
{ dryRun: true, path: path19, bytes: Buffer.byteLength(content), content },
|
|
8899
8899
|
{ format: dryFmt }
|
|
8900
8900
|
) + "\n"
|
|
8901
8901
|
);
|
|
8902
8902
|
} else {
|
|
8903
8903
|
process.stdout.write(
|
|
8904
|
-
`[dry-run] \u5C06\u5199\u5165 ${
|
|
8904
|
+
`[dry-run] \u5C06\u5199\u5165 ${path19}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
|
|
8905
8905
|
---
|
|
8906
8906
|
${content}
|
|
8907
8907
|
`
|
|
@@ -8915,13 +8915,13 @@ ${content}
|
|
|
8915
8915
|
let backupState = "unknown";
|
|
8916
8916
|
let backupWhy;
|
|
8917
8917
|
try {
|
|
8918
|
-
const prev = await getTenantMeta(c.raw(),
|
|
8918
|
+
const prev = await getTenantMeta(c.raw(), path19);
|
|
8919
8919
|
if (!prev || prev.trim() === "") {
|
|
8920
8920
|
backupState = "absent";
|
|
8921
8921
|
} else {
|
|
8922
8922
|
backupFile = nodePath.join(
|
|
8923
8923
|
os4.tmpdir(),
|
|
8924
|
-
`hcm-meta-backup-${Date.now()}-${
|
|
8924
|
+
`hcm-meta-backup-${Date.now()}-${path19.replace(/[\\/]/g, "_")}`
|
|
8925
8925
|
);
|
|
8926
8926
|
await fsp3.writeFile(backupFile, prev, "utf8");
|
|
8927
8927
|
backupState = "saved";
|
|
@@ -8936,22 +8936,22 @@ ${content}
|
|
|
8936
8936
|
backupWhy = `HTTP ${st ?? "-"}${err.code ? ` ${err.code}` : ""}${err.message ? `\uFF1A${err.message}` : ""}`;
|
|
8937
8937
|
}
|
|
8938
8938
|
}
|
|
8939
|
-
const result = await saveTenantMeta(c.raw(),
|
|
8939
|
+
const result = await saveTenantMeta(c.raw(), path19, content);
|
|
8940
8940
|
const fmt = args.output ?? "json";
|
|
8941
|
-
if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${
|
|
8941
|
+
if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path19}
|
|
8942
8942
|
`);
|
|
8943
8943
|
const restoreHint = backupState === "saved" && backupFile ? ` \u65E7\u5185\u5BB9\u5DF2\u5B58\uFF1A${backupFile}
|
|
8944
|
-
\u653E\u56DE\u53BB\uFF1Ahcm meta set ${
|
|
8945
|
-
` : backupState === "absent" ? ` \u8FD9\u4E00\u5C42\u6B64\u524D\u6CA1\u6709\u8986\u76D6\uFF08\u5DF2\u8BC1\u5B9E\uFF09\uFF0C\u6062\u590D\u5373\u5220\u9664\uFF1Ahcm meta delete ${
|
|
8944
|
+
\u653E\u56DE\u53BB\uFF1Ahcm meta set ${path19} --file ${backupFile}${connFlags(args)}
|
|
8945
|
+
` : backupState === "absent" ? ` \u8FD9\u4E00\u5C42\u6B64\u524D\u6CA1\u6709\u8986\u76D6\uFF08\u5DF2\u8BC1\u5B9E\uFF09\uFF0C\u6062\u590D\u5373\u5220\u9664\uFF1Ahcm meta delete ${path19}${connFlags(args)}
|
|
8946
8946
|
` : ` \u26A0\uFE0F \u65E7\u5185\u5BB9**\u6CA1\u5907\u4EFD\u6210**\uFF08${backupWhy ?? "\u539F\u56E0\u672A\u77E5"}\uFF09\u2014\u2014\u65E2\u4E0D\u77E5\u9053\u6B64\u524D\u6709\u6CA1\u6709\u8986\u76D6\uFF0C\u4E5F\u5C31\u7ED9\u4E0D\u51FA\u6062\u590D\u547D\u4EE4\u3002
|
|
8947
|
-
\u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${
|
|
8947
|
+
\u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path19}${connFlags(args)}
|
|
8948
8948
|
`;
|
|
8949
8949
|
if (args.verify === false) {
|
|
8950
8950
|
process.stderr.write(
|
|
8951
8951
|
"\u26A0\uFE0F --no-verify\uFF1A**\u6CA1\u6709**\u9A8C\u8FC7\u670D\u52A1\u7AEF\u8BFB\u4E0D\u8BFB\u5F97\u52A8\u8FD9\u4EFD meta\u3002\u300C\u5199\u5165\u6210\u529F\u300D\u53EA\u8BF4\u660E\u5B57\u8282\u6536\u4E0B\u4E86\u3002\n \u81EA\u5DF1\u8865\uFF1Ahcm cache clear-meta <Model> \u540E\u6253\u5F00\u9875\u9762\u770B\u4E00\u773C\u3002\n" + restoreHint
|
|
8952
8952
|
);
|
|
8953
8953
|
} else {
|
|
8954
|
-
const outcome = await verifyAfterWrite(c,
|
|
8954
|
+
const outcome = await verifyAfterWrite(c, path19);
|
|
8955
8955
|
if (outcome.status === "broken") {
|
|
8956
8956
|
const human = explainJacksonError(outcome.raw);
|
|
8957
8957
|
process.stderr.write(
|
|
@@ -8985,19 +8985,19 @@ ${content}
|
|
|
8985
8985
|
fail7(e, args);
|
|
8986
8986
|
}
|
|
8987
8987
|
}
|
|
8988
|
-
async function metaDeleteCommand(
|
|
8988
|
+
async function metaDeleteCommand(path19, args) {
|
|
8989
8989
|
try {
|
|
8990
8990
|
if (!args.yes) {
|
|
8991
|
-
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${
|
|
8991
|
+
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path19}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
|
|
8992
8992
|
if (!ok) {
|
|
8993
8993
|
process.stderr.write("\u5DF2\u53D6\u6D88\n");
|
|
8994
8994
|
process.exit(1);
|
|
8995
8995
|
}
|
|
8996
8996
|
}
|
|
8997
8997
|
const c = await client2(args);
|
|
8998
|
-
const result = await deleteTenantMeta(c.raw(),
|
|
8998
|
+
const result = await deleteTenantMeta(c.raw(), path19);
|
|
8999
8999
|
const fmt = args.output ?? "json";
|
|
9000
|
-
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${
|
|
9000
|
+
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path19}
|
|
9001
9001
|
`);
|
|
9002
9002
|
process.stdout.write(formatObject20(result, { format: fmt }) + "\n");
|
|
9003
9003
|
process.exitCode = 0;
|
|
@@ -9006,7 +9006,7 @@ async function metaDeleteCommand(path18, args) {
|
|
|
9006
9006
|
fail7(e, args);
|
|
9007
9007
|
}
|
|
9008
9008
|
}
|
|
9009
|
-
async function metaValidateCommand(
|
|
9009
|
+
async function metaValidateCommand(path19, args) {
|
|
9010
9010
|
try {
|
|
9011
9011
|
if (!args.file) {
|
|
9012
9012
|
throw new CliError22({
|
|
@@ -9021,13 +9021,13 @@ async function metaValidateCommand(path18, args) {
|
|
|
9021
9021
|
process.stdin.on("end", () => resolve3(buf));
|
|
9022
9022
|
process.stdin.on("error", reject);
|
|
9023
9023
|
}) : await fsp3.readFile(args.file, "utf8");
|
|
9024
|
-
const result = validateMetaContent(
|
|
9024
|
+
const result = validateMetaContent(path19, content);
|
|
9025
9025
|
const fmt = args.output ?? "table";
|
|
9026
9026
|
if (fmt === "json" || fmt === "yaml") {
|
|
9027
9027
|
process.stdout.write(
|
|
9028
9028
|
formatObject20(
|
|
9029
9029
|
{
|
|
9030
|
-
path:
|
|
9030
|
+
path: path19,
|
|
9031
9031
|
kind: result.kind,
|
|
9032
9032
|
schemaKnown: result.schemaKnown,
|
|
9033
9033
|
schemaSourceCommit: META_SCHEMA_SOURCE_COMMIT,
|
|
@@ -9039,7 +9039,7 @@ async function metaValidateCommand(path18, args) {
|
|
|
9039
9039
|
);
|
|
9040
9040
|
} else {
|
|
9041
9041
|
process.stdout.write(
|
|
9042
|
-
`\u{1F50E} ${
|
|
9042
|
+
`\u{1F50E} ${path19}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
|
|
9043
9043
|
`
|
|
9044
9044
|
);
|
|
9045
9045
|
process.stdout.write(
|
|
@@ -12319,10 +12319,360 @@ async function chironEnvCommand(action, args) {
|
|
|
12319
12319
|
init_auth_guard();
|
|
12320
12320
|
init_exit();
|
|
12321
12321
|
import { spawnSync } from "child_process";
|
|
12322
|
-
import { accessSync, constants } from "fs";
|
|
12322
|
+
import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
|
|
12323
12323
|
import fs12 from "fs/promises";
|
|
12324
|
+
import os5 from "os";
|
|
12325
|
+
import path14 from "path";
|
|
12326
|
+
import { CliError as CliError30, CliErrorCode as CliErrorCode29, formatObject as formatObject27, HcmClient as HcmClient23, loadEnv as loadEnv6 } from "@hcmai/sdk";
|
|
12327
|
+
import { createRequire } from "module";
|
|
12328
|
+
|
|
12329
|
+
// src/commands/chiron-page-cdp.ts
|
|
12330
|
+
import { CliError as CliError28, CliErrorCode as CliErrorCode27 } from "@hcmai/sdk";
|
|
12331
|
+
|
|
12332
|
+
// src/commands/chiron-page-shared.ts
|
|
12333
|
+
function redactTicket(text) {
|
|
12334
|
+
return text.replace(/(ticket=)[^&\s"']+/g, "$1<redacted>");
|
|
12335
|
+
}
|
|
12336
|
+
function toPlainJson(value) {
|
|
12337
|
+
if (value === void 0) return void 0;
|
|
12338
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
12339
|
+
const text = JSON.stringify(value, (_k, v) => {
|
|
12340
|
+
if (typeof v === "bigint") return v.toString();
|
|
12341
|
+
if (v && typeof v === "object") {
|
|
12342
|
+
if (seen.has(v)) return "[Circular]";
|
|
12343
|
+
seen.add(v);
|
|
12344
|
+
}
|
|
12345
|
+
return v;
|
|
12346
|
+
});
|
|
12347
|
+
if (text === void 0) return void 0;
|
|
12348
|
+
return JSON.parse(redactTicket(text));
|
|
12349
|
+
}
|
|
12350
|
+
function wrapEvalBody(body) {
|
|
12351
|
+
return `(async () => {
|
|
12352
|
+
${body}
|
|
12353
|
+
})()`;
|
|
12354
|
+
}
|
|
12355
|
+
|
|
12356
|
+
// src/commands/chiron-page-cdp.ts
|
|
12357
|
+
function normalizeCdpEndpoint(raw) {
|
|
12358
|
+
const text = raw?.trim();
|
|
12359
|
+
if (!text) return null;
|
|
12360
|
+
let candidate = text;
|
|
12361
|
+
if (!/^[a-z]+:\/\//i.test(candidate)) candidate = `http://${candidate}`;
|
|
12362
|
+
let url;
|
|
12363
|
+
try {
|
|
12364
|
+
url = new URL(candidate);
|
|
12365
|
+
} catch {
|
|
12366
|
+
throw new CliError28({ code: CliErrorCode27.INVALID_ARGUMENT, message: `--cdp \u8981\u5199\u6210 http://\u4E3B\u673A:\u7AEF\u53E3\uFF08Chrome \u7684 --remote-debugging-port\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
|
|
12367
|
+
}
|
|
12368
|
+
const protocol = url.protocol === "wss:" ? "https:" : url.protocol === "ws:" ? "http:" : url.protocol;
|
|
12369
|
+
if (protocol !== "http:" && protocol !== "https:") {
|
|
12370
|
+
throw new CliError28({ code: CliErrorCode27.INVALID_ARGUMENT, message: `--cdp \u53EA\u8BA4 http(s) \u6216 ws(s) \u7AEF\u70B9\uFF0C\u6536\u5230\u7684\u662F ${text}` });
|
|
12371
|
+
}
|
|
12372
|
+
if (!url.port) {
|
|
12373
|
+
throw new CliError28({ code: CliErrorCode27.INVALID_ARGUMENT, message: `--cdp \u8981\u5E26\u7AEF\u53E3\uFF08Chrome \u542F\u52A8\u65F6 --remote-debugging-port=<\u7AEF\u53E3> \u7684\u90A3\u4E2A\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
|
|
12374
|
+
}
|
|
12375
|
+
return `${protocol}//${url.hostname}:${url.port}`;
|
|
12376
|
+
}
|
|
12377
|
+
var CdpSession = class {
|
|
12378
|
+
constructor(socket) {
|
|
12379
|
+
this.socket = socket;
|
|
12380
|
+
socket.addEventListener("message", (ev) => this.onMessage(typeof ev.data === "string" ? ev.data : String(ev.data)));
|
|
12381
|
+
socket.addEventListener("close", () => this.failAll(new Error("CDP socket \u5DF2\u5173\u95ED")));
|
|
12382
|
+
socket.addEventListener("error", (ev) => this.failAll(new Error(`CDP socket \u51FA\u9519\uFF1A${describe(ev)}`)));
|
|
12383
|
+
}
|
|
12384
|
+
socket;
|
|
12385
|
+
nextId = 1;
|
|
12386
|
+
pending = /* @__PURE__ */ new Map();
|
|
12387
|
+
listeners = /* @__PURE__ */ new Map();
|
|
12388
|
+
closed = false;
|
|
12389
|
+
send(method, params = {}) {
|
|
12390
|
+
if (this.closed) return Promise.reject(new Error(`CDP socket \u5DF2\u5173\u95ED\uFF0C\u53D1\u4E0D\u4E86 ${method}`));
|
|
12391
|
+
const id = this.nextId++;
|
|
12392
|
+
return new Promise((resolve3, reject) => {
|
|
12393
|
+
this.pending.set(id, { resolve: resolve3, reject, method });
|
|
12394
|
+
this.socket.send(JSON.stringify({ id, method, params }));
|
|
12395
|
+
});
|
|
12396
|
+
}
|
|
12397
|
+
on(event, listener) {
|
|
12398
|
+
const list = this.listeners.get(event) ?? [];
|
|
12399
|
+
list.push(listener);
|
|
12400
|
+
this.listeners.set(event, list);
|
|
12401
|
+
return () => {
|
|
12402
|
+
const cur = this.listeners.get(event) ?? [];
|
|
12403
|
+
const i = cur.indexOf(listener);
|
|
12404
|
+
if (i >= 0) cur.splice(i, 1);
|
|
12405
|
+
};
|
|
12406
|
+
}
|
|
12407
|
+
/** 事件监听器数(测试用:确认 waitFor 结束后不留监听器)。 */
|
|
12408
|
+
listenerCount(event) {
|
|
12409
|
+
return (this.listeners.get(event) ?? []).length;
|
|
12410
|
+
}
|
|
12411
|
+
/** 等一个事件,超时就 reject——「等 load 事件」不能无限等。无论哪种结束都摘掉监听器。 */
|
|
12412
|
+
waitFor(event, timeoutMs) {
|
|
12413
|
+
return new Promise((resolve3, reject) => {
|
|
12414
|
+
const off = this.on(event, (params) => {
|
|
12415
|
+
clearTimeout(timer);
|
|
12416
|
+
off();
|
|
12417
|
+
resolve3(params);
|
|
12418
|
+
});
|
|
12419
|
+
const timer = setTimeout(() => {
|
|
12420
|
+
off();
|
|
12421
|
+
reject(new Error(`\u7B49 ${event} \u8D85\u8FC7 ${timeoutMs}ms`));
|
|
12422
|
+
}, timeoutMs);
|
|
12423
|
+
});
|
|
12424
|
+
}
|
|
12425
|
+
close() {
|
|
12426
|
+
this.closed = true;
|
|
12427
|
+
try {
|
|
12428
|
+
this.socket.close();
|
|
12429
|
+
} catch {
|
|
12430
|
+
}
|
|
12431
|
+
this.failAll(new Error("CDP socket \u5DF2\u5173\u95ED"));
|
|
12432
|
+
}
|
|
12433
|
+
onMessage(raw) {
|
|
12434
|
+
let msg;
|
|
12435
|
+
try {
|
|
12436
|
+
msg = JSON.parse(raw);
|
|
12437
|
+
} catch {
|
|
12438
|
+
return;
|
|
12439
|
+
}
|
|
12440
|
+
if (typeof msg.id === "number") {
|
|
12441
|
+
const p = this.pending.get(msg.id);
|
|
12442
|
+
if (!p) return;
|
|
12443
|
+
this.pending.delete(msg.id);
|
|
12444
|
+
if (msg.error) p.reject(new Error(`${p.method} \u88AB Chrome \u62D2\u7EDD\uFF1A${msg.error.message ?? JSON.stringify(msg.error)}`));
|
|
12445
|
+
else p.resolve(msg.result);
|
|
12446
|
+
return;
|
|
12447
|
+
}
|
|
12448
|
+
if (msg.method) {
|
|
12449
|
+
for (const l of [...this.listeners.get(msg.method) ?? []]) l(msg.params);
|
|
12450
|
+
}
|
|
12451
|
+
}
|
|
12452
|
+
failAll(err) {
|
|
12453
|
+
for (const [id, p] of this.pending) {
|
|
12454
|
+
this.pending.delete(id);
|
|
12455
|
+
p.reject(err);
|
|
12456
|
+
}
|
|
12457
|
+
}
|
|
12458
|
+
};
|
|
12459
|
+
function describe(ev) {
|
|
12460
|
+
if (ev && typeof ev === "object" && "message" in ev) return String(ev.message);
|
|
12461
|
+
return String(ev);
|
|
12462
|
+
}
|
|
12463
|
+
var LOAD_WAIT_MS = 15e3;
|
|
12464
|
+
var CDP_IO_TIMEOUT_MS = 1e4;
|
|
12465
|
+
async function captureViaCdp(input, io) {
|
|
12466
|
+
const version = await io.fetchJson(`${input.endpoint}/json/version`, "GET");
|
|
12467
|
+
const browser = version?.Browser ? String(version.Browser) : `attached ${input.endpoint}`;
|
|
12468
|
+
const target = await io.fetchJson(`${input.endpoint}/json/new?about:blank`, "PUT");
|
|
12469
|
+
if (!target?.id || !target.webSocketDebuggerUrl) {
|
|
12470
|
+
throw new CliError28({
|
|
12471
|
+
code: CliErrorCode27.SERVER_ERROR,
|
|
12472
|
+
message: `${input.endpoint}/json/new \u6CA1\u6709\u7ED9\u51FA\u6807\u7B7E\u9875\uFF08id / webSocketDebuggerUrl \u7F3A\u5931\uFF09`,
|
|
12473
|
+
context: { nextStep: "\u786E\u8BA4 Chrome \u662F\u5E26 --remote-debugging-port \u8D77\u7684\uFF0C\u4E14 --cdp \u6307\u5230\u7684\u662F\u5B83" }
|
|
12474
|
+
});
|
|
12475
|
+
}
|
|
12476
|
+
let session = null;
|
|
12477
|
+
try {
|
|
12478
|
+
session = new CdpSession(await io.openSocket(target.webSocketDebuggerUrl));
|
|
12479
|
+
await session.send("Emulation.setDeviceMetricsOverride", {
|
|
12480
|
+
width: input.viewport.width,
|
|
12481
|
+
height: input.viewport.height,
|
|
12482
|
+
deviceScaleFactor: 1,
|
|
12483
|
+
mobile: false
|
|
12484
|
+
});
|
|
12485
|
+
await session.send("Page.enable");
|
|
12486
|
+
await session.send("Runtime.enable");
|
|
12487
|
+
const minted = await input.mintUrl();
|
|
12488
|
+
const loaded = session.waitFor("Page.loadEventFired", LOAD_WAIT_MS).then(() => true, () => false);
|
|
12489
|
+
await session.send("Page.navigate", { url: minted.url });
|
|
12490
|
+
const navigated = await loaded;
|
|
12491
|
+
if (input.waitMs > 0) await io.sleep(input.waitMs);
|
|
12492
|
+
let evalResult;
|
|
12493
|
+
if (input.evalJs?.trim()) {
|
|
12494
|
+
const r = await session.send("Runtime.evaluate", {
|
|
12495
|
+
expression: wrapEvalBody(input.evalJs),
|
|
12496
|
+
awaitPromise: true,
|
|
12497
|
+
returnByValue: true
|
|
12498
|
+
});
|
|
12499
|
+
if (r.exceptionDetails) {
|
|
12500
|
+
const why = r.exceptionDetails.exception?.description ?? r.exceptionDetails.text ?? "unknown";
|
|
12501
|
+
throw new CliError28({ code: CliErrorCode27.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why.split("\n")[0] ?? why)}` });
|
|
12502
|
+
}
|
|
12503
|
+
evalResult = r.result && "value" in r.result ? toPlainJson(r.result.value) : toPlainJson(r.result?.description);
|
|
12504
|
+
}
|
|
12505
|
+
const domReply = await session.send("Runtime.evaluate", {
|
|
12506
|
+
expression: "document.documentElement.outerHTML",
|
|
12507
|
+
returnByValue: true
|
|
12508
|
+
});
|
|
12509
|
+
const dom = typeof domReply.result?.value === "string" ? domReply.result.value : "";
|
|
12510
|
+
const shot = await session.send("Page.captureScreenshot", { format: "png" });
|
|
12511
|
+
if (!shot.data) {
|
|
12512
|
+
throw new CliError28({ code: CliErrorCode27.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
|
|
12513
|
+
}
|
|
12514
|
+
await io.writeFile(input.screenshot, Buffer.from(shot.data, "base64"));
|
|
12515
|
+
return { dom, browser, evalResult, navigated, minted };
|
|
12516
|
+
} finally {
|
|
12517
|
+
session?.close();
|
|
12518
|
+
try {
|
|
12519
|
+
await io.fetchJson(`${input.endpoint}/json/close/${target.id}`, "GET");
|
|
12520
|
+
} catch {
|
|
12521
|
+
}
|
|
12522
|
+
}
|
|
12523
|
+
}
|
|
12524
|
+
var defaultCdpIo = {
|
|
12525
|
+
fetchJson: async (url, method) => {
|
|
12526
|
+
const res = await fetch(url, { method, signal: AbortSignal.timeout(CDP_IO_TIMEOUT_MS) });
|
|
12527
|
+
if (!res.ok) throw new Error(`${method} ${url} \u2192 HTTP ${res.status}`);
|
|
12528
|
+
const text = await res.text();
|
|
12529
|
+
return text ? JSON.parse(text) : null;
|
|
12530
|
+
},
|
|
12531
|
+
openSocket: (wsUrl) => new Promise((resolve3, reject) => {
|
|
12532
|
+
const Ctor = globalThis.WebSocket;
|
|
12533
|
+
if (!Ctor) {
|
|
12534
|
+
reject(new CliError28({ code: CliErrorCode27.SERVER_ERROR, message: "\u8FD9\u4E2A Node \u6CA1\u6709\u5168\u5C40 WebSocket\uFF08\u9700\u8981 Node \u2265 22.4\uFF1B22.0\u201322.3 \u8981\u52A0 --experimental-websocket\uFF09" }));
|
|
12535
|
+
return;
|
|
12536
|
+
}
|
|
12537
|
+
const ws = new Ctor(wsUrl);
|
|
12538
|
+
const timer = setTimeout(() => reject(new Error(`\u8FDE ${wsUrl} \u8D85\u8FC7 ${CDP_IO_TIMEOUT_MS}ms \u6CA1\u63E1\u4E0A\u624B`)), CDP_IO_TIMEOUT_MS);
|
|
12539
|
+
ws.addEventListener("open", () => {
|
|
12540
|
+
clearTimeout(timer);
|
|
12541
|
+
resolve3(ws);
|
|
12542
|
+
});
|
|
12543
|
+
ws.addEventListener("error", (ev) => {
|
|
12544
|
+
clearTimeout(timer);
|
|
12545
|
+
reject(new Error(`\u8FDE\u4E0D\u4E0A ${wsUrl}\uFF1A${describe(ev)}`));
|
|
12546
|
+
});
|
|
12547
|
+
}),
|
|
12548
|
+
writeFile: async (file, bytes) => {
|
|
12549
|
+
const fs14 = await import("fs/promises");
|
|
12550
|
+
await fs14.writeFile(file, bytes);
|
|
12551
|
+
},
|
|
12552
|
+
sleep: (ms) => new Promise((r) => setTimeout(r, ms))
|
|
12553
|
+
};
|
|
12554
|
+
|
|
12555
|
+
// src/commands/chiron-page-playwright.ts
|
|
12324
12556
|
import path13 from "path";
|
|
12325
|
-
import { CliError as
|
|
12557
|
+
import { CliError as CliError29, CliErrorCode as CliErrorCode28 } from "@hcmai/sdk";
|
|
12558
|
+
function playwrightCacheRoot(probe) {
|
|
12559
|
+
const override = probe.env.PLAYWRIGHT_BROWSERS_PATH?.trim();
|
|
12560
|
+
if (override === "0" && probe.packageRoot) return path13.join(probe.packageRoot, ".local-browsers");
|
|
12561
|
+
if (override && override !== "0") return path13.resolve(override);
|
|
12562
|
+
if (probe.platform === "darwin") return path13.join(probe.homedir(), "Library", "Caches", "ms-playwright");
|
|
12563
|
+
if (probe.platform === "win32") {
|
|
12564
|
+
return path13.join(probe.env.LOCALAPPDATA?.trim() || path13.join(probe.homedir(), "AppData", "Local"), "ms-playwright");
|
|
12565
|
+
}
|
|
12566
|
+
return path13.join(probe.env.XDG_CACHE_HOME?.trim() || path13.join(probe.homedir(), ".cache"), "ms-playwright");
|
|
12567
|
+
}
|
|
12568
|
+
function playwrightPlatformTag(probe) {
|
|
12569
|
+
const arm = probe.arch === "arm64";
|
|
12570
|
+
if (probe.platform === "darwin") return arm ? "mac-arm64" : "mac-x64";
|
|
12571
|
+
if (probe.platform === "win32") return "win64";
|
|
12572
|
+
return arm ? "linux-arm64" : "linux64";
|
|
12573
|
+
}
|
|
12574
|
+
function revisionOf(entry, prefix) {
|
|
12575
|
+
if (!entry.startsWith(prefix)) return null;
|
|
12576
|
+
const rev = Number(entry.slice(prefix.length));
|
|
12577
|
+
return Number.isInteger(rev) ? rev : null;
|
|
12578
|
+
}
|
|
12579
|
+
function candidateBinaries(probe, kind) {
|
|
12580
|
+
const tag = playwrightPlatformTag(probe);
|
|
12581
|
+
if (kind === "headless-shell") {
|
|
12582
|
+
return [path13.join(`chrome-headless-shell-${tag}`, probe.platform === "win32" ? "chrome-headless-shell.exe" : "chrome-headless-shell")];
|
|
12583
|
+
}
|
|
12584
|
+
if (probe.platform === "darwin") {
|
|
12585
|
+
return [
|
|
12586
|
+
// Playwright ≥ 1.49:Chrome for Testing 的 .app
|
|
12587
|
+
path13.join(`chrome-${tag}`, "Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing"),
|
|
12588
|
+
// ≤ 1.48:Chromium.app,目录名不分架构
|
|
12589
|
+
path13.join("chrome-mac", "Chromium.app", "Contents", "MacOS", "Chromium"),
|
|
12590
|
+
path13.join(`chrome-${tag}`, "Chromium.app", "Contents", "MacOS", "Chromium")
|
|
12591
|
+
];
|
|
12592
|
+
}
|
|
12593
|
+
if (probe.platform === "win32") return [path13.join("chrome-win64", "chrome.exe"), path13.join("chrome-win", "chrome.exe")];
|
|
12594
|
+
return [path13.join(`chrome-${tag}`, "chrome"), path13.join("chrome-linux", "chrome")];
|
|
12595
|
+
}
|
|
12596
|
+
function discoverPlaywrightBrowser(probe) {
|
|
12597
|
+
const explicit = probe.env.HCM_PLAYWRIGHT_EXECUTABLE?.trim();
|
|
12598
|
+
if (explicit) {
|
|
12599
|
+
if (probe.executable(explicit)) return { executablePath: explicit, kind: "explicit", from: "HCM_PLAYWRIGHT_EXECUTABLE" };
|
|
12600
|
+
throw new CliError29({
|
|
12601
|
+
code: CliErrorCode28.INVALID_ARGUMENT,
|
|
12602
|
+
message: `HCM_PLAYWRIGHT_EXECUTABLE \u6307\u7684\u6587\u4EF6\u4E0D\u53EF\u6267\u884C\uFF1A${explicit}`,
|
|
12603
|
+
context: { nextStep: "\u6307\u5230 Playwright \u88C5\u7684 chrome-headless-shell / chrome \u4E8C\u8FDB\u5236\uFF0C\u6216\u53BB\u6389\u8FD9\u4E2A\u53D8\u91CF\u8BA9 CLI \u81EA\u5DF1\u627E" }
|
|
12604
|
+
});
|
|
12605
|
+
}
|
|
12606
|
+
const root = playwrightCacheRoot(probe);
|
|
12607
|
+
const entries = probe.readdir(root);
|
|
12608
|
+
const pick2 = (prefix, kind) => {
|
|
12609
|
+
const revisions = entries.map((e) => ({ e, rev: revisionOf(e, prefix) })).filter((x) => x.rev !== null).sort((a, b) => b.rev - a.rev);
|
|
12610
|
+
for (const { e } of revisions) {
|
|
12611
|
+
for (const rel of candidateBinaries(probe, kind)) {
|
|
12612
|
+
const candidate = path13.join(root, e, rel);
|
|
12613
|
+
if (probe.executable(candidate)) return { executablePath: candidate, kind, from: path13.join(root, e) };
|
|
12614
|
+
}
|
|
12615
|
+
}
|
|
12616
|
+
return null;
|
|
12617
|
+
};
|
|
12618
|
+
return pick2("chromium_headless_shell-", "headless-shell") ?? pick2("chromium-", "chromium");
|
|
12619
|
+
}
|
|
12620
|
+
var PW_LOAD_WAIT_MS = 15e3;
|
|
12621
|
+
async function loadPlaywright() {
|
|
12622
|
+
return import("playwright-core");
|
|
12623
|
+
}
|
|
12624
|
+
async function captureViaPlaywright(input) {
|
|
12625
|
+
const pw = await loadPlaywright();
|
|
12626
|
+
const attempts = [];
|
|
12627
|
+
if (input.browser) attempts.push({ label: `${input.browser.kind} @ ${input.browser.from}`, options: { headless: true, executablePath: input.browser.executablePath } });
|
|
12628
|
+
attempts.push({ label: "playwright default", options: { headless: true } });
|
|
12629
|
+
attempts.push({ label: "channel=chrome", options: { headless: true, channel: "chrome" } });
|
|
12630
|
+
const failures = [];
|
|
12631
|
+
let browser = null;
|
|
12632
|
+
let used = "";
|
|
12633
|
+
for (const a of attempts) {
|
|
12634
|
+
try {
|
|
12635
|
+
browser = await pw.chromium.launch({ ...a.options, args: ["--disable-gpu", "--disable-dev-shm-usage", "--hide-scrollbars"] });
|
|
12636
|
+
used = a.label;
|
|
12637
|
+
break;
|
|
12638
|
+
} catch (e) {
|
|
12639
|
+
failures.push(`${a.label}: ${(e instanceof Error ? e.message : String(e)).split("\n")[0]}`);
|
|
12640
|
+
}
|
|
12641
|
+
}
|
|
12642
|
+
if (!browser) {
|
|
12643
|
+
throw new CliError29({
|
|
12644
|
+
code: CliErrorCode28.SERVER_ERROR,
|
|
12645
|
+
message: `Playwright \u8D77\u4E0D\u4E86\u6D4F\u89C8\u5668\uFF1A${failures.join("\uFF1B")}`,
|
|
12646
|
+
context: {
|
|
12647
|
+
nextStep: "\u88C5\u4E00\u4EFD Playwright \u7684 Chromium\uFF1Anpx playwright install chromium-headless-shell\uFF08\u6216 chromium\uFF09\uFF1B\u5DF2\u7ECF\u88C5\u4E86\u4F46\u4E0D\u5728\u7F3A\u7701\u7F13\u5B58\u76EE\u5F55\u5C31 export PLAYWRIGHT_BROWSERS_PATH=<\u76EE\u5F55> \u6216 HCM_PLAYWRIGHT_EXECUTABLE=<\u4E8C\u8FDB\u5236>\uFF1B\u6C99\u7BB1\u8FDE headless shell \u90FD\u8D77\u4E0D\u4E86\u65F6\uFF0C\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u5E76\u7528 --cdp \u8FDE"
|
|
12648
|
+
}
|
|
12649
|
+
});
|
|
12650
|
+
}
|
|
12651
|
+
const browserLabel = `${browser.version()} via playwright (${used})`;
|
|
12652
|
+
try {
|
|
12653
|
+
const context = await browser.newContext({ viewport: input.viewport, deviceScaleFactor: 1 });
|
|
12654
|
+
const page = await context.newPage();
|
|
12655
|
+
const minted = await input.mintUrl();
|
|
12656
|
+
const navigated = await page.goto(minted.url, { waitUntil: "load", timeout: PW_LOAD_WAIT_MS }).then(() => true, () => false);
|
|
12657
|
+
if (input.waitMs > 0) await page.waitForTimeout(input.waitMs);
|
|
12658
|
+
let evalResult;
|
|
12659
|
+
if (input.evalJs?.trim()) {
|
|
12660
|
+
try {
|
|
12661
|
+
evalResult = toPlainJson(await page.evaluate(wrapEvalBody(input.evalJs)));
|
|
12662
|
+
} catch (e) {
|
|
12663
|
+
const why = (e instanceof Error ? e.message : String(e)).split("\n")[0] ?? "";
|
|
12664
|
+
throw new CliError29({ code: CliErrorCode28.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
|
|
12665
|
+
}
|
|
12666
|
+
}
|
|
12667
|
+
const dom = await page.content();
|
|
12668
|
+
await page.screenshot({ path: input.screenshot, fullPage: false });
|
|
12669
|
+
return { dom, browser: browserLabel, evalResult, navigated, minted };
|
|
12670
|
+
} finally {
|
|
12671
|
+
await browser.close().catch(() => void 0);
|
|
12672
|
+
}
|
|
12673
|
+
}
|
|
12674
|
+
|
|
12675
|
+
// src/commands/chiron-page.ts
|
|
12326
12676
|
var EVIDENCE_DIR = "evidence";
|
|
12327
12677
|
var WAIT_MS_MAX = 6e4;
|
|
12328
12678
|
var VIEWPORT_MIN = { width: 320, height: 240 };
|
|
@@ -12335,13 +12685,13 @@ function judgePageContent(input) {
|
|
|
12335
12685
|
function parseViewport(size) {
|
|
12336
12686
|
const m = /^(\d+)x(\d+)$/.exec(size.trim());
|
|
12337
12687
|
if (!m) {
|
|
12338
|
-
throw new
|
|
12688
|
+
throw new CliError30({ code: CliErrorCode29.INVALID_ARGUMENT, message: `--size \u8981\u5199\u6210 <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900\uFF0C\u6536\u5230\u7684\u662F ${size}` });
|
|
12339
12689
|
}
|
|
12340
12690
|
const width = Number(m[1]);
|
|
12341
12691
|
const height = Number(m[2]);
|
|
12342
12692
|
if (width < VIEWPORT_MIN.width || width > VIEWPORT_MAX.width || height < VIEWPORT_MIN.height || height > VIEWPORT_MAX.height) {
|
|
12343
|
-
throw new
|
|
12344
|
-
code:
|
|
12693
|
+
throw new CliError30({
|
|
12694
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12345
12695
|
message: `--size \u8D85\u51FA\u8303\u56F4\uFF1A\u5BBD ${VIEWPORT_MIN.width}..${VIEWPORT_MAX.width}\u3001\u9AD8 ${VIEWPORT_MIN.height}..${VIEWPORT_MAX.height}\uFF0C\u6536\u5230\u7684\u662F ${size}`
|
|
12346
12696
|
});
|
|
12347
12697
|
}
|
|
@@ -12351,23 +12701,23 @@ function parseWaitMs(raw) {
|
|
|
12351
12701
|
if (raw === void 0) return 1e4;
|
|
12352
12702
|
const value = typeof raw === "number" ? raw : Number(raw);
|
|
12353
12703
|
if (!Number.isInteger(value) || value < 0 || value > WAIT_MS_MAX) {
|
|
12354
|
-
throw new
|
|
12704
|
+
throw new CliError30({ code: CliErrorCode29.INVALID_ARGUMENT, message: `--wait-ms \u8981\u662F 0..${WAIT_MS_MAX} \u7684\u6574\u6570\uFF0C\u6536\u5230\u7684\u662F ${raw}` });
|
|
12355
12705
|
}
|
|
12356
12706
|
return value;
|
|
12357
12707
|
}
|
|
12358
12708
|
function resolveEvidenceTarget(projectRoot, out) {
|
|
12359
12709
|
if (!out?.trim()) {
|
|
12360
|
-
throw new
|
|
12710
|
+
throw new CliError30({ code: CliErrorCode29.MISSING_FLAG, message: `\u8981\u4F20 --out <${EVIDENCE_DIR}/\u2026/\u622A\u56FE.png>\uFF1A\u622A\u56FE\u843D\u5728\u54EA\u513F\u5FC5\u987B\u662F\u4F60\u5B9A\u7684\uFF0C\u4E0D\u7531\u547D\u4EE4\u731C` });
|
|
12361
12711
|
}
|
|
12362
12712
|
if (!out.endsWith(".png")) {
|
|
12363
|
-
throw new
|
|
12364
|
-
}
|
|
12365
|
-
const root =
|
|
12366
|
-
const evidenceRoot =
|
|
12367
|
-
const absolute =
|
|
12368
|
-
if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot +
|
|
12369
|
-
throw new
|
|
12370
|
-
code:
|
|
12713
|
+
throw new CliError30({ code: CliErrorCode29.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
|
|
12714
|
+
}
|
|
12715
|
+
const root = path14.resolve(projectRoot);
|
|
12716
|
+
const evidenceRoot = path14.join(root, EVIDENCE_DIR);
|
|
12717
|
+
const absolute = path14.resolve(root, out);
|
|
12718
|
+
if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path14.sep)) {
|
|
12719
|
+
throw new CliError30({
|
|
12720
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12371
12721
|
message: `--out \u8981\u843D\u5728\u9879\u76EE\u7684 ${EVIDENCE_DIR}/ \u4E0B\uFF08${evidenceRoot}\uFF09\uFF0C\u6536\u5230\u7684\u662F ${absolute}`
|
|
12372
12722
|
});
|
|
12373
12723
|
}
|
|
@@ -12412,11 +12762,11 @@ function findChrome(probe, override) {
|
|
|
12412
12762
|
}
|
|
12413
12763
|
async function assertInsideEvidence(deps, evidenceRoot, absolute) {
|
|
12414
12764
|
const canonicalRoot = await deps.realpath(evidenceRoot);
|
|
12415
|
-
const canonicalParent = await deps.realpath(
|
|
12765
|
+
const canonicalParent = await deps.realpath(path14.dirname(absolute));
|
|
12416
12766
|
if (canonicalRoot === null || canonicalParent === null) return;
|
|
12417
|
-
if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot +
|
|
12418
|
-
throw new
|
|
12419
|
-
code:
|
|
12767
|
+
if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path14.sep)) {
|
|
12768
|
+
throw new CliError30({
|
|
12769
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12420
12770
|
message: `--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u8DD1\u51FA\u4E86 ${EVIDENCE_DIR}/\uFF1A${canonicalParent}`
|
|
12421
12771
|
});
|
|
12422
12772
|
}
|
|
@@ -12425,46 +12775,91 @@ async function runChironPage(target, args, deps) {
|
|
|
12425
12775
|
const sitePath = normalizeTarget(target);
|
|
12426
12776
|
const expect = (args.expectText ?? []).filter((t) => t.trim().length > 0);
|
|
12427
12777
|
if (expect.length === 0) {
|
|
12428
|
-
throw new
|
|
12429
|
-
code:
|
|
12778
|
+
throw new CliError30({
|
|
12779
|
+
code: CliErrorCode29.MISSING_FLAG,
|
|
12430
12780
|
message: "\u81F3\u5C11\u8981\u4F20\u4E00\u6761 --expect-text\uFF08\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C\uFF09\u3002\u53EA\u5224\u300C\u622A\u51FA\u56FE\u4E86\u300D\u4E0D\u7B97\u9A8C\u6536\uFF1A\u767B\u5F55\u9875\u3001\u62A5\u9519\u9875\u3001\u767D\u5C4F\u90FD\u80FD\u622A\u51FA\u56FE\u3002"
|
|
12431
12781
|
});
|
|
12432
12782
|
}
|
|
12433
12783
|
const reject = (args.rejectText ?? []).filter((t) => t.trim().length > 0);
|
|
12434
12784
|
const viewport = parseViewport(args.size ?? "1440x900");
|
|
12435
12785
|
const waitMs = parseWaitMs(args.waitMs);
|
|
12436
|
-
const root =
|
|
12786
|
+
const root = path14.resolve(args.project ?? ".");
|
|
12437
12787
|
const { evidenceRoot, absolute } = resolveEvidenceTarget(root, args.out);
|
|
12438
12788
|
if (await deps.present(absolute)) {
|
|
12439
|
-
throw new
|
|
12440
|
-
code:
|
|
12789
|
+
throw new CliError30({
|
|
12790
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12441
12791
|
message: `\u622A\u56FE\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8986\u76D6\uFF1A${absolute}\u3002\u6362\u4E2A --out\uFF0C\u6216\u5148\u628A\u65E7\u8BC1\u636E\u632A\u8D70\u3002`
|
|
12442
12792
|
});
|
|
12443
12793
|
}
|
|
12444
|
-
await deps.ensureDir(
|
|
12794
|
+
await deps.ensureDir(path14.dirname(absolute));
|
|
12445
12795
|
await assertInsideEvidence(deps, evidenceRoot, absolute);
|
|
12446
|
-
const
|
|
12447
|
-
|
|
12448
|
-
|
|
12449
|
-
|
|
12450
|
-
|
|
12451
|
-
|
|
12796
|
+
const endpoint = normalizeCdpEndpoint(args.cdp ?? deps.env.HCM_CHROME_CDP);
|
|
12797
|
+
const evalJs = args.eval?.trim() ? args.eval : void 0;
|
|
12798
|
+
const forceSpawn = (deps.env.HCM_CHIRON_PAGE_DRIVER ?? "").trim() === "spawn";
|
|
12799
|
+
const playwrightBrowser = endpoint || forceSpawn ? null : deps.findPlaywrightBrowser();
|
|
12800
|
+
const usePlaywright = !endpoint && !forceSpawn && (playwrightBrowser !== null || evalJs !== void 0);
|
|
12801
|
+
if (evalJs && !endpoint && !usePlaywright) {
|
|
12802
|
+
throw new CliError30({
|
|
12803
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12804
|
+
message: "--eval \u9700\u8981 Playwright \u6216 --cdp\uFF1A\u8001\u7684 spawn \u8DEF\u5F84\u53EA\u4F1A --dump-dom\uFF0C\u585E\u4E0D\u8FDB\u811A\u672C\u3002",
|
|
12805
|
+
context: { nextStep: "npx playwright install chromium-headless-shell\uFF0C\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
|
|
12452
12806
|
});
|
|
12453
12807
|
}
|
|
12454
|
-
|
|
12455
|
-
|
|
12456
|
-
|
|
12457
|
-
|
|
12458
|
-
|
|
12459
|
-
|
|
12460
|
-
|
|
12461
|
-
|
|
12808
|
+
let dom;
|
|
12809
|
+
let browserLabel;
|
|
12810
|
+
let evalResult;
|
|
12811
|
+
let navigated;
|
|
12812
|
+
let minted;
|
|
12813
|
+
let mode;
|
|
12814
|
+
const mint = () => deps.mintUrl({ path: sitePath, args });
|
|
12815
|
+
if (endpoint || usePlaywright) {
|
|
12816
|
+
mode = endpoint ? "attach" : "playwright";
|
|
12817
|
+
let captured;
|
|
12818
|
+
try {
|
|
12819
|
+
captured = endpoint ? await deps.captureAttached({ endpoint, viewport, waitMs, evalJs, screenshot: absolute, mintUrl: mint }) : await deps.capturePlaywright({ viewport, waitMs, evalJs, screenshot: absolute, browser: playwrightBrowser, mintUrl: mint });
|
|
12820
|
+
} catch (e) {
|
|
12821
|
+
if (e instanceof CliError30) throw new CliError30({ code: e.code, message: redactTicket(e.message), context: e.context });
|
|
12822
|
+
const where = endpoint ? `\u8FDE\u5230 ${endpoint} \u7684 Chrome` : "Playwright \u8D77\u7684\u6D4F\u89C8\u5668";
|
|
12823
|
+
throw new CliError30({
|
|
12824
|
+
code: CliErrorCode29.SERVER_ERROR,
|
|
12825
|
+
message: `${where}\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(e instanceof Error ? e.message : String(e))}`,
|
|
12826
|
+
context: {
|
|
12827
|
+
nextStep: endpoint ? `\u6838\u4E00\u773C ${endpoint}/json/version \u80FD\u4E0D\u80FD\u6253\u5F00\uFF1BChrome \u8981\u5E26 --remote-debugging-port \u8D77\uFF0C\u4E14\u6C99\u7BB1\u653E\u884C\u4E86\u8FD9\u4E2A\u7AEF\u53E3` : "npx playwright install chromium-headless-shell \u540E\u91CD\u8DD1\uFF1B\u6216 HCM_CHIRON_PAGE_DRIVER=spawn \u8D70\u8001\u8DEF\u5F84\u5BF9\u7167"
|
|
12828
|
+
}
|
|
12829
|
+
});
|
|
12830
|
+
}
|
|
12831
|
+
dom = captured.dom;
|
|
12832
|
+
browserLabel = captured.browser;
|
|
12833
|
+
evalResult = captured.evalResult;
|
|
12834
|
+
navigated = captured.navigated;
|
|
12835
|
+
minted = captured.minted;
|
|
12836
|
+
} else {
|
|
12837
|
+
mode = "spawn";
|
|
12838
|
+
const browser = deps.findBrowser();
|
|
12839
|
+
if (!browser) {
|
|
12840
|
+
throw new CliError30({
|
|
12841
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12842
|
+
message: "\u672C\u673A\u627E\u4E0D\u5230 Playwright \u7684 Chromium\uFF0C\u4E5F\u627E\u4E0D\u5230 Chrome/Chromium\uFF0C\u622A\u4E0D\u4E86\u56FE\u3002",
|
|
12843
|
+
context: { nextStep: "npx playwright install chromium-headless-shell\uFF08\u6C99\u7BB1\u91CC\u4E5F\u80FD\u8DD1\uFF09\uFF1B\u6216\u88C5\u4E00\u4E2A Chrome / HCM_CHROME_BIN=/\u7EDD\u5BF9\u8DEF\u5F84\uFF1B\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
|
|
12844
|
+
});
|
|
12845
|
+
}
|
|
12846
|
+
minted = await mint();
|
|
12847
|
+
const result = deps.capture({ browser, argv: chromeArgv({ viewport, waitMs, screenshot: absolute, url: minted.url, isRoot: process.getuid?.() === 0 }) });
|
|
12848
|
+
if (!result.ok) {
|
|
12849
|
+
throw new CliError30({
|
|
12850
|
+
code: CliErrorCode29.SERVER_ERROR,
|
|
12851
|
+
message: `\u6D4F\u89C8\u5668\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(result.stderr.trim().split("\n").slice(-1)[0] ?? "\u65E0\u8F93\u51FA")}`,
|
|
12852
|
+
context: { nextStep: spawnFailureNextStep(browser, result, deps.platform) }
|
|
12853
|
+
});
|
|
12854
|
+
}
|
|
12855
|
+
dom = result.dom;
|
|
12856
|
+
browserLabel = deps.browserVersion(browser);
|
|
12462
12857
|
}
|
|
12463
12858
|
const bytes = await deps.present(absolute) ? await deps.sizeOf(absolute) : 0;
|
|
12464
12859
|
if (bytes === 0) {
|
|
12465
|
-
throw new
|
|
12860
|
+
throw new CliError30({ code: CliErrorCode29.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
|
|
12466
12861
|
}
|
|
12467
|
-
const verdict = judgePageContent({ dom
|
|
12862
|
+
const verdict = judgePageContent({ dom, expect, reject });
|
|
12468
12863
|
return {
|
|
12469
12864
|
ok: verdict.ok,
|
|
12470
12865
|
path: sitePath,
|
|
@@ -12474,25 +12869,50 @@ async function runChironPage(target, args, deps) {
|
|
|
12474
12869
|
identity: minted.identity,
|
|
12475
12870
|
viewport: `${viewport.width}x${viewport.height}`,
|
|
12476
12871
|
waitMs,
|
|
12477
|
-
browser:
|
|
12872
|
+
browser: browserLabel,
|
|
12873
|
+
mode,
|
|
12874
|
+
...endpoint ? { attach: endpoint } : {},
|
|
12875
|
+
...evalResult !== void 0 ? { evalResult } : {},
|
|
12876
|
+
...navigated !== void 0 ? { navigated } : {},
|
|
12478
12877
|
expected: expect,
|
|
12479
12878
|
rejected: reject,
|
|
12480
12879
|
missing: verdict.missing,
|
|
12481
12880
|
forbidden: verdict.forbidden
|
|
12482
12881
|
};
|
|
12483
12882
|
}
|
|
12883
|
+
function spawnFailureNextStep(browser, result, platform) {
|
|
12884
|
+
const sandboxed = result.signal === "SIGABRT" || /SIGABRT|abort trap|Trace\/BPT trap|sandbox/i.test(result.stderr);
|
|
12885
|
+
if (sandboxed) {
|
|
12886
|
+
return `Chrome \u5728\u8FD9\u4E2A\u8FDB\u7A0B\u91CC\u8D77\u4E0D\u6765\uFF08${result.signal ?? "\u88AB\u4FE1\u53F7\u7EC8\u6B62"}\uFF09\u2014\u2014\u6C99\u7BB1\u91CC\u5E38\u89C1\u3002\u6539\u8D70 attach\uFF1A\u5728\u6C99\u7BB1\u5916\u8D77 "${browser}" --headless=new --remote-debugging-port=9222 --user-data-dir=<\u4E34\u65F6\u76EE\u5F55>\uFF0C\u518D\u7ED9\u672C\u547D\u4EE4\u52A0 --cdp http://127.0.0.1:9222\uFF08\u6216 export HCM_CHROME_CDP=\u2026\uFF09` + (platform === "darwin" ? "\uFF1BmacOS \u7684 Seatbelt \u5C31\u662F\u8FD9\u79CD\u60C5\u51B5" : "");
|
|
12887
|
+
}
|
|
12888
|
+
return `\u624B\u5DE5\u6838\u4E00\u773C\uFF1A${browser} --headless=new --screenshot \u8DD1\u5F97\u8D77\u6765\u5417\uFF1B\u8D77\u4E0D\u6765\u5C31\u5728\u6C99\u7BB1\u5916\u8D77\u597D Chrome \u7528 --cdp \u8FDE`;
|
|
12889
|
+
}
|
|
12484
12890
|
function renderChironPage(receipt) {
|
|
12485
12891
|
const out = [];
|
|
12486
12892
|
out.push(`${receipt.ok ? "\u2705" : "\u274C"} ${receipt.path} \xB7 ${receipt.environment}${receipt.identity ? ` \xB7 ${receipt.identity}` : ""}`);
|
|
12487
|
-
out.push(` \u622A\u56FE ${receipt.screenshot}\uFF08${receipt.bytes} \u5B57\u8282\uFF0C${receipt.viewport}\uFF0C\u7B49 ${receipt.waitMs}ms\uFF09`);
|
|
12893
|
+
out.push(` \u622A\u56FE ${receipt.screenshot}\uFF08${receipt.bytes} \u5B57\u8282\uFF0C${receipt.viewport}\uFF0C\u7B49 ${receipt.waitMs}ms\uFF0C${receipt.mode === "attach" ? `\u8FDE\u7684 ${receipt.attach}` : receipt.mode}\uFF09`);
|
|
12894
|
+
out.push(` \u6D4F\u89C8\u5668 ${receipt.browser}`);
|
|
12895
|
+
if (receipt.navigated === false) out.push(" \u26A0\uFE0F \u5BFC\u822A\u6CA1\u8D70\u5230 load \u4E8B\u4EF6\uFF08\u8FDE\u63A5\u88AB\u62D2 / \u8BC1\u4E66 / \u7968\u636E\u9875\u8DF3\u8F6C\u5931\u8D25\uFF09\u2014\u2014\u4E0B\u9762\u7684\u5224\u636E\u662F\u5BF9\u9519\u8BEF\u9875\u6216\u7A7A\u58F3\u5224\u7684");
|
|
12896
|
+
if (receipt.evalResult !== void 0) out.push(` --eval \u8FD4\u56DE ${typeof receipt.evalResult === "string" ? receipt.evalResult : safeStringify(receipt.evalResult)}`);
|
|
12488
12897
|
out.push(` \u6838\u8FC7 ${receipt.expected.map((t) => `\u300C${t}\u300D`).join("\u3001")}${receipt.rejected.length ? ` \xB7 \u4E0D\u8BB8\u51FA\u73B0 ${receipt.rejected.map((t) => `\u300C${t}\u300D`).join("\u3001")}` : ""}`);
|
|
12489
12898
|
for (const t of receipt.missing) out.push(` \u274C \u9875\u9762\u4E0A\u6CA1\u6709\u300C${t}\u300D`);
|
|
12490
12899
|
for (const t of receipt.forbidden) out.push(` \u274C \u9875\u9762\u4E0A\u51FA\u73B0\u4E86\u4E0D\u8BE5\u6709\u7684\u300C${t}\u300D`);
|
|
12491
12900
|
if (!receipt.ok) out.push(" \u622A\u56FE\u4FDD\u7559\u7740\uFF0C\u6253\u5F00\u770B\u4E00\u773C\u662F\u767B\u5F55\u9875\u3001\u62A5\u9519\u9875\uFF0C\u8FD8\u662F\u9875\u9762\u771F\u7684\u5C11\u4E86\u4E1C\u897F\u3002");
|
|
12492
12901
|
return out.join("\n");
|
|
12493
12902
|
}
|
|
12494
|
-
function
|
|
12495
|
-
|
|
12903
|
+
function safeStringify(value) {
|
|
12904
|
+
try {
|
|
12905
|
+
return JSON.stringify(value);
|
|
12906
|
+
} catch {
|
|
12907
|
+
return String(value);
|
|
12908
|
+
}
|
|
12909
|
+
}
|
|
12910
|
+
function playwrightPackageRoot() {
|
|
12911
|
+
try {
|
|
12912
|
+
return path14.dirname(createRequire(import.meta.url).resolve("playwright-core/package.json"));
|
|
12913
|
+
} catch {
|
|
12914
|
+
return void 0;
|
|
12915
|
+
}
|
|
12496
12916
|
}
|
|
12497
12917
|
var defaultChironPageDeps = {
|
|
12498
12918
|
mintUrl: async ({ path: sitePath, args }) => {
|
|
@@ -12500,8 +12920,8 @@ var defaultChironPageDeps = {
|
|
|
12500
12920
|
const envCfg = await loadEnv6(ctx.env);
|
|
12501
12921
|
const frontend = ctx.frontend ?? envCfg.frontend;
|
|
12502
12922
|
if (!frontend?.trim()) {
|
|
12503
|
-
throw new
|
|
12504
|
-
code:
|
|
12923
|
+
throw new CliError30({
|
|
12924
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12505
12925
|
message: `env '${ctx.env}' \u6CA1\u914D\u524D\u7AEF\u5730\u5740\uFF0C\u5F00\u4E0D\u4E86\u9875\u9762\u3002`,
|
|
12506
12926
|
context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
|
|
12507
12927
|
});
|
|
@@ -12530,8 +12950,34 @@ var defaultChironPageDeps = {
|
|
|
12530
12950
|
),
|
|
12531
12951
|
capture: ({ browser, argv }) => {
|
|
12532
12952
|
const r = spawnSync(browser, argv, { encoding: "utf8", maxBuffer: 1 << 26, timeout: 3e5 });
|
|
12533
|
-
return { ok: r.status === 0, dom: r.stdout ?? "", stderr: redactTicket(r.stderr ?? "") };
|
|
12953
|
+
return { ok: r.status === 0, dom: r.stdout ?? "", stderr: redactTicket(r.stderr ?? ""), signal: r.signal ?? null };
|
|
12534
12954
|
},
|
|
12955
|
+
captureAttached: (input) => captureViaCdp(input, defaultCdpIo),
|
|
12956
|
+
env: process.env,
|
|
12957
|
+
findPlaywrightBrowser: () => discoverPlaywrightBrowser({
|
|
12958
|
+
platform: process.platform,
|
|
12959
|
+
arch: process.arch,
|
|
12960
|
+
env: process.env,
|
|
12961
|
+
packageRoot: playwrightPackageRoot(),
|
|
12962
|
+
homedir: () => os5.homedir(),
|
|
12963
|
+
readdir: (dir) => {
|
|
12964
|
+
try {
|
|
12965
|
+
return readdirSync3(dir);
|
|
12966
|
+
} catch {
|
|
12967
|
+
return [];
|
|
12968
|
+
}
|
|
12969
|
+
},
|
|
12970
|
+
executable: (file) => {
|
|
12971
|
+
try {
|
|
12972
|
+
accessSync(file, constants.X_OK);
|
|
12973
|
+
return true;
|
|
12974
|
+
} catch {
|
|
12975
|
+
return false;
|
|
12976
|
+
}
|
|
12977
|
+
}
|
|
12978
|
+
}),
|
|
12979
|
+
capturePlaywright: (input) => captureViaPlaywright(input),
|
|
12980
|
+
platform: process.platform,
|
|
12535
12981
|
browserVersion: (browser) => (spawnSync(browser, ["--version"], { encoding: "utf8" }).stdout ?? "").trim().split("\n")[0] ?? "",
|
|
12536
12982
|
ensureDir: (dir) => fs12.mkdir(dir, { recursive: true }).then(() => void 0),
|
|
12537
12983
|
present: (file) => fs12.lstat(file).then(() => true).catch(() => false),
|
|
@@ -12555,7 +13001,7 @@ init_exit();
|
|
|
12555
13001
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
12556
13002
|
import { randomUUID } from "crypto";
|
|
12557
13003
|
import { promises as fs13 } from "fs";
|
|
12558
|
-
import
|
|
13004
|
+
import path15 from "path";
|
|
12559
13005
|
import yaml2 from "js-yaml";
|
|
12560
13006
|
import { formatObject as formatObject28 } from "@hcmai/sdk";
|
|
12561
13007
|
|
|
@@ -13445,7 +13891,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps3) {
|
|
|
13445
13891
|
continue;
|
|
13446
13892
|
}
|
|
13447
13893
|
if (c.file) {
|
|
13448
|
-
const file =
|
|
13894
|
+
const file = path15.resolve(root, fill(c.file));
|
|
13449
13895
|
const want = c.expect ?? {};
|
|
13450
13896
|
const bad = [];
|
|
13451
13897
|
if (want.xlsx_header || want.xlsx_min_rows !== void 0) {
|
|
@@ -13467,7 +13913,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps3) {
|
|
|
13467
13913
|
results.push(bad.length ? { name: c.name, verdict: "fail", detail: bad.join("\uFF1B") } : { name: c.name, verdict: "pass", detail: "" });
|
|
13468
13914
|
continue;
|
|
13469
13915
|
}
|
|
13470
|
-
const out =
|
|
13916
|
+
const out = path15.join(
|
|
13471
13917
|
"evidence",
|
|
13472
13918
|
"test",
|
|
13473
13919
|
opts.evidenceRunId ?? "current",
|
|
@@ -13489,11 +13935,11 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps3) {
|
|
|
13489
13935
|
}
|
|
13490
13936
|
async function loadCases(target) {
|
|
13491
13937
|
const stat = await fs13.stat(target);
|
|
13492
|
-
const files = stat.isDirectory() ? (await fs13.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) =>
|
|
13938
|
+
const files = stat.isDirectory() ? (await fs13.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) => path15.join(target, f)) : [target];
|
|
13493
13939
|
const out = [];
|
|
13494
13940
|
for (const f of files) {
|
|
13495
13941
|
const spec = yaml2.load(await fs13.readFile(f, "utf8"));
|
|
13496
|
-
assertUsableSpec(spec,
|
|
13942
|
+
assertUsableSpec(spec, path15.basename(f));
|
|
13497
13943
|
out.push({ file: f, spec });
|
|
13498
13944
|
}
|
|
13499
13945
|
if (out.length === 0) throw new Error(`${target} \u4E0B\u6CA1\u6709\u7528\u4F8B\uFF08*.yml\uFF09`);
|
|
@@ -13501,8 +13947,8 @@ async function loadCases(target) {
|
|
|
13501
13947
|
}
|
|
13502
13948
|
async function chironTestCommand(target, args, deps) {
|
|
13503
13949
|
try {
|
|
13504
|
-
const root =
|
|
13505
|
-
const where =
|
|
13950
|
+
const root = path15.resolve(args.project ?? ".");
|
|
13951
|
+
const where = path15.resolve(root, target ?? "tests");
|
|
13506
13952
|
const cases = await loadCases(where);
|
|
13507
13953
|
const report = [];
|
|
13508
13954
|
let failed2 = 0;
|
|
@@ -13514,7 +13960,7 @@ async function chironTestCommand(target, args, deps) {
|
|
|
13514
13960
|
deps
|
|
13515
13961
|
);
|
|
13516
13962
|
failed2 += results.filter((r) => r.verdict === "fail").length;
|
|
13517
|
-
report.push({ case: spec.name, file:
|
|
13963
|
+
report.push({ case: spec.name, file: path15.relative(root, file), results });
|
|
13518
13964
|
}
|
|
13519
13965
|
const fmt = args.output ?? "table";
|
|
13520
13966
|
if (fmt === "json" || fmt === "yaml") {
|
|
@@ -13655,7 +14101,7 @@ import {
|
|
|
13655
14101
|
writeRisk
|
|
13656
14102
|
} from "@hcmai/sdk";
|
|
13657
14103
|
import { existsSync as existsSync3 } from "fs";
|
|
13658
|
-
import * as
|
|
14104
|
+
import * as path16 from "path";
|
|
13659
14105
|
function premise(message, hint = "") {
|
|
13660
14106
|
process.stderr.write(message + (hint ? `
|
|
13661
14107
|
\u2192 ${hint}` : "") + "\n");
|
|
@@ -13682,13 +14128,13 @@ async function runSeedPlan(args, client3) {
|
|
|
13682
14128
|
const reconDir = candidates[0].reconDir;
|
|
13683
14129
|
if (candidates.length > 1) {
|
|
13684
14130
|
process.stderr.write(
|
|
13685
|
-
`\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${
|
|
14131
|
+
`\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${path16.basename(reconDir)}\`\uFF1A` + candidates.slice(1).map((c) => `\`${path16.basename(c.reconDir)}\``).join("\u3001") + " \u672A\u88AB\u8BFB\u53D6 \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n"
|
|
13686
14132
|
);
|
|
13687
14133
|
}
|
|
13688
14134
|
const round = inspectRound2(reconDir);
|
|
13689
14135
|
process.stderr.write(roundWarning(round));
|
|
13690
14136
|
const baseline = {
|
|
13691
|
-
path: `${
|
|
14137
|
+
path: `${path16.basename(path16.dirname(reconDir))}/${path16.basename(reconDir)}`,
|
|
13692
14138
|
roundId: round.roundId ?? null
|
|
13693
14139
|
};
|
|
13694
14140
|
let exemptions = null;
|
|
@@ -13950,7 +14396,7 @@ async function deliverySeedVerifyCommand(args) {
|
|
|
13950
14396
|
// src/commands/delivery-seed-find.ts
|
|
13951
14397
|
import { existsSync as existsSync4 } from "fs";
|
|
13952
14398
|
import { readFileSync as readFileSync8 } from "fs";
|
|
13953
|
-
import * as
|
|
14399
|
+
import * as path17 from "path";
|
|
13954
14400
|
import {
|
|
13955
14401
|
INIT_EXIT_CODES as INIT_EXIT_CODES2,
|
|
13956
14402
|
ValueHints,
|
|
@@ -13964,10 +14410,10 @@ import {
|
|
|
13964
14410
|
valuesRoundCaveat
|
|
13965
14411
|
} from "@hcmai/sdk";
|
|
13966
14412
|
function provenance(chosenReconDir, others) {
|
|
13967
|
-
let line = `> \u57FA\u7EBF\uFF1A\`${
|
|
14413
|
+
let line = `> \u57FA\u7EBF\uFF1A\`${path17.basename(chosenReconDir)}\`
|
|
13968
14414
|
`;
|
|
13969
14415
|
if (others.length > 0) {
|
|
13970
|
-
line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${
|
|
14416
|
+
line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${path17.basename(o)}\``).join("\u3001") + " \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n";
|
|
13971
14417
|
}
|
|
13972
14418
|
return `${line}
|
|
13973
14419
|
`;
|
|
@@ -14304,7 +14750,7 @@ import {
|
|
|
14304
14750
|
runTriageRound
|
|
14305
14751
|
} from "@hcmai/sdk";
|
|
14306
14752
|
import { mkdirSync as mkdirSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync3 } from "fs";
|
|
14307
|
-
import * as
|
|
14753
|
+
import * as path18 from "path";
|
|
14308
14754
|
var DEFAULT_CAPABILITIES3 = "default";
|
|
14309
14755
|
function premise4(message, hint) {
|
|
14310
14756
|
process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
|
|
@@ -14340,8 +14786,8 @@ function renderProblems(rows2) {
|
|
|
14340
14786
|
`;
|
|
14341
14787
|
}
|
|
14342
14788
|
function writeTriageArtifact(outDir, body) {
|
|
14343
|
-
const out =
|
|
14344
|
-
mkdirSync2(
|
|
14789
|
+
const out = path18.join(outDir, "work", "triage.md");
|
|
14790
|
+
mkdirSync2(path18.dirname(out), { recursive: true });
|
|
14345
14791
|
writeFileSync3(out, body, "utf8");
|
|
14346
14792
|
return out;
|
|
14347
14793
|
}
|
|
@@ -14387,21 +14833,21 @@ import {
|
|
|
14387
14833
|
adminResetPassword,
|
|
14388
14834
|
formatObject as formatObject30,
|
|
14389
14835
|
fromAxiosError as fromAxiosError23,
|
|
14390
|
-
CliError as
|
|
14391
|
-
CliErrorCode as
|
|
14836
|
+
CliError as CliError31,
|
|
14837
|
+
CliErrorCode as CliErrorCode30
|
|
14392
14838
|
} from "@hcmai/sdk";
|
|
14393
14839
|
function buildAdminResetPasswordRequest(args, password) {
|
|
14394
14840
|
const hasId = Boolean(args.id);
|
|
14395
14841
|
const hasUsername = Boolean(args.username);
|
|
14396
14842
|
if (hasId === hasUsername) {
|
|
14397
|
-
throw new
|
|
14398
|
-
code:
|
|
14843
|
+
throw new CliError31({
|
|
14844
|
+
code: CliErrorCode30.INVALID_ARGUMENT,
|
|
14399
14845
|
message: "--id <uuid> \u4E0E --username <user> \u5FC5\u987B\u4E14\u53EA\u80FD\u63D0\u4F9B\u4E00\u4E2A"
|
|
14400
14846
|
});
|
|
14401
14847
|
}
|
|
14402
14848
|
if (!password) {
|
|
14403
|
-
throw new
|
|
14404
|
-
code:
|
|
14849
|
+
throw new CliError31({
|
|
14850
|
+
code: CliErrorCode30.INVALID_ARGUMENT,
|
|
14405
14851
|
message: "\u65B0\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
|
|
14406
14852
|
});
|
|
14407
14853
|
}
|
|
@@ -14430,8 +14876,8 @@ async function promptPasswordTwice() {
|
|
|
14430
14876
|
const password = await promptSecret("\u65B0\u5BC6\u7801: ");
|
|
14431
14877
|
const confirmation = await promptSecret("\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ");
|
|
14432
14878
|
if (password !== confirmation) {
|
|
14433
|
-
throw new
|
|
14434
|
-
code:
|
|
14879
|
+
throw new CliError31({
|
|
14880
|
+
code: CliErrorCode30.INVALID_ARGUMENT,
|
|
14435
14881
|
message: "\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4"
|
|
14436
14882
|
});
|
|
14437
14883
|
}
|
|
@@ -14562,7 +15008,7 @@ var chiron = program.command("chiron").description(
|
|
|
14562
15008
|
);
|
|
14563
15009
|
chiron.command("init").description("\u5EFA\u987E\u95EE\u9879\u76EE\u4ED3\uFF1A\u5199 env.yaml\u3001\u5EFA\u76EE\u5F55\u3001\u5199 AGENTS/CLAUDE \u8FB9\u754C\u5757\u3002\u7EAF\u672C\u5730\uFF0C\u65AD\u7F51\u4E5F\u80FD\u5EFA\uFF1B\u91CD\u8DD1\u5B89\u5168").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u7ED1\u5230\u672C\u673A\u54EA\u4E2A\u73AF\u5883\uFF08\u6216\u5DF2\u6709 env.yaml \u91CC\u7684\u73AF\u5883\u540D\uFF09").option("--endpoint <url>", "\u5B8C\u5168\u663E\u5F0F\u5730\u58F0\u660E\u540E\u7AEF\u5730\u5740\uFF08\u4E0D\u9700\u8981\u5148\u767B\u5F55\uFF0C\u4E5F\u4E0D\u53D1\u4EFB\u4F55\u8BF7\u6C42\uFF09").option("--frontend <url>", "\u524D\u7AEF\u5730\u5740\uFF08\u914D\u5408 --endpoint\uFF1B\u9ED8\u8BA4\u4E0E\u540E\u7AEF\u540C\u5740\uFF09").option("--tenant <id>", "\u79DF\u6237\u53F7\uFF08\u914D\u5408 --endpoint\uFF1B\u9ED8\u8BA4 1\uFF09").option("--with-skills", "\u987A\u624B\u628A\u6280\u80FD\u4E5F\u88C5\u4E0A\uFF08\u9ED8\u8BA4\u4E0D\u88C5\uFF0C\u7528 hcm chiron skills sync\uFF09").option("--yes", "\u975E\u4EA4\u4E92\u5730\u786E\u8BA4\u300C\u5C31\u7528\u672C\u673A\u5F53\u524D\u6D3B\u52A8\u73AF\u5883\u300D").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => chironInitCommand(opts));
|
|
14564
15010
|
chiron.command("test").description("\u6309\u7528\u4F8B\u8DD1\u4E00\u904D\u5E76\u628A\u95EE\u9898\u627E\u51FA\u6765\uFF1A\u7528\u4F8B\u5728\u9879\u76EE\u4ED3 tests/\uFF0C\u5224\u636E\u5FC5\u987B\u770B\u5185\u5BB9\uFF08\u53EA\u5224\u9000\u51FA\u7801\u7684\u7528\u4F8B\u4F1A\u88AB\u62D2\u7EDD\u52A0\u8F7D\uFF09").argument("[target]", "\u7528\u4F8B\u6587\u4EF6\u6216\u76EE\u5F55\uFF08\u9ED8\u8BA4 tests/\uFF09").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u76EE\u6807\u73AF\u5883\uFF1B\u7528\u4F8B\u91CC\u6CA1\u5199 --env \u65F6\u8865\u4E0A").option("--as <identity>", "\u8EAB\u4EFD\uFF1B\u7528\u4F8B\u91CC\u6CA1\u5199 --as \u65F6\u8865\u4E0A").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((target, opts) => chironTestCommand(target, opts));
|
|
14565
|
-
chiron.command("page").description("\u6253\u5F00\u9875\u9762\u622A\u56FE\u5E76\u5BF9\u7740\u9875\u9762\u5185\u5BB9\u5224\u4E00\u6B21\uFF1A\u81F3\u5C11\u8981\u7ED9\u4E00\u6761 --expect-text\uFF0C\u53EA\u622A\u56FE\u4E0D\u7B97\u9A8C\u6536").argument("<\u8DEF\u5F84>", "\u7AD9\u5185\u8DEF\u5F84\uFF0C\u5982 /dashboard/xxx").requiredOption("--out <file>", "\u622A\u56FE\u843D\u70B9\uFF0C\u5FC5\u987B\u5728\u9879\u76EE\u7684 evidence/ \u4E0B\u4E14\u4EE5 .png \u7ED3\u5C3E").option("--expect-text <text...>", "\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C\uFF08\u81F3\u5C11\u4E00\u6761\uFF09").option("--reject-text <text...>", "\u9875\u9762\u4E0A\u4E0D\u5F97\u51FA\u73B0\u7684\u6587\u672C").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--wait-ms <ms>", "\u9875\u9762\u6E32\u67D3\u9884\u7B97\u6BEB\u79D2\u6570", "10000").option("--size <WxH>", "\u89C6\u53E3\u5C3A\u5BF8", "1440x900").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((target, opts) => chironPageCommand(target, opts));
|
|
15011
|
+
chiron.command("page").description("\u6253\u5F00\u9875\u9762\u622A\u56FE\u5E76\u5BF9\u7740\u9875\u9762\u5185\u5BB9\u5224\u4E00\u6B21\uFF1A\u81F3\u5C11\u8981\u7ED9\u4E00\u6761 --expect-text\uFF0C\u53EA\u622A\u56FE\u4E0D\u7B97\u9A8C\u6536").argument("<\u8DEF\u5F84>", "\u7AD9\u5185\u8DEF\u5F84\uFF0C\u5982 /dashboard/xxx").requiredOption("--out <file>", "\u622A\u56FE\u843D\u70B9\uFF0C\u5FC5\u987B\u5728\u9879\u76EE\u7684 evidence/ \u4E0B\u4E14\u4EE5 .png \u7ED3\u5C3E").option("--expect-text <text...>", "\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C\uFF08\u81F3\u5C11\u4E00\u6761\uFF09").option("--reject-text <text...>", "\u9875\u9762\u4E0A\u4E0D\u5F97\u51FA\u73B0\u7684\u6587\u672C").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--wait-ms <ms>", "\u9875\u9762\u6E32\u67D3\u9884\u7B97\u6BEB\u79D2\u6570", "10000").option("--size <WxH>", "\u89C6\u53E3\u5C3A\u5BF8", "1440x900").option("--cdp <endpoint>", "\u4E0D\u81EA\u5DF1\u8D77 Chrome\uFF0C\u8FDE\u5230\u5DF2\u5728\u8DD1\u7684 Chrome\uFF08--remote-debugging-port\uFF09\uFF1A\u6C99\u7BB1\u91CC\u8D77\u4E0D\u4E86 Chrome \u65F6\u7528\uFF1B\u4E5F\u8BFB HCM_CHROME_CDP").option("--eval <js>", "\u622A\u56FE\u524D\u5728\u9875\u9762\u91CC\u8DD1\u7684 JS\uFF08\u51FD\u6570\u4F53\uFF0C\u53EF await\uFF0C\u8FD4\u56DE\u503C\u8FDB\u56DE\u6267\uFF09\uFF1A\u70B9\u6309\u94AE\u3001\u586B\u8868\u3001\u8FFD\u95EE\u90FD\u9760\u5B83\uFF1B\u9700\u8981 Playwright \u6216 --cdp").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((target, opts) => chironPageCommand(target, opts));
|
|
14566
15012
|
chiron.command("doctor").description(
|
|
14567
15013
|
"\u6838\u5BF9\uFF1A\u672C\u673A\u767B\u5F55\u662F\u5426\u5BF9\u7740 env.yaml \u7684\u73AF\u5883\uFF08\u542B\u4E94\u6761\u951A\u70B9\u4E0E\u5BF9\u8BDD\u63E1\u624B\uFF09/ \u6280\u80FD\u88C5\u6CA1\u88C5 / \u6848\u4F8B\u5E93\u8BFB\u4E0D\u8BFB\u5F97\u5230 / Jira \u80FD\u4E0D\u80FD\u63D0\u5355"
|
|
14568
15014
|
).option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u8986\u76D6\u8981\u6838\u7684\u73AF\u5883\u522B\u540D\uFF08\u9ED8\u8BA4\u53D6 env.yaml\uFF1B\u591A\u73AF\u5883\u9879\u76EE\u7528\u5B83\u6328\u4E2A\u63A2\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\u63A2\u951A\u70B9").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => chironDoctorCommand(opts));
|
|
@@ -14765,7 +15211,7 @@ program.command("update <Model>").description("\u66F4\u65B0\u4E00\u6761 Model \u
|
|
|
14765
15211
|
).action((model, opts) => updateCommand(model, opts));
|
|
14766
15212
|
program.command("version").description("\u67E5 CLI \u4E0E\u540E\u7AEF\u4E24\u4E2A\u7248\u672C\uFF08commit / tag / \u6784\u5EFA\u65F6\u95F4\uFF09\u2014\u2014\u514D\u8BA4\u8BC1\uFF0C\u65E0\u9700\u5148 login").option("--endpoint <url>", "\u540E\u7AEF\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u9879\u76EE\u73AF\u5883\u6216 activeEnv \u7684 endpoint\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => versionCommand(opts));
|
|
14767
15213
|
program.command("upgrade").alias("self-update").description("\u5347\u7EA7 CLI \u81EA\u5DF1\uFF08\u6CE8\u610F\uFF1A`hcm update` \u662F\u66F4\u65B0\u4E1A\u52A1\u8BB0\u5F55\uFF0C\u4E0D\u662F\u5347\u7EA7\uFF09").option("--check", "\u53EA\u68C0\u67E5\uFF1B\u6709\u65B0\u7248\u672C\u65F6\u4EE5\u9000\u51FA\u7801 1 \u7ED3\u675F\uFF0C\u4FBF\u4E8E\u811A\u672C\u5224\u65AD").action((opts) => upgradeCommand(opts));
|
|
14768
|
-
program.command("open [path]").description("\u7528\u5F53\u524D CLI \u8EAB\u4EFD\u6253\u5F00\u524D\u7AEF\u9875\u9762\uFF1A\u94F8\u4E00\u5F20 60s \u4E00\u6B21\u6027\u7968\u636E\u4EA4\u7ED9\u6D4F\u89C8\u5668\uFF0C\u4F1A\u8BDD token \u4E0D\u8FDB URL").option("--print-url", "\u53EA\u6253\u5370\u767B\u5F55 URL\uFF0C\u4E0D\u5F00\u6D4F\u89C8\u5668\uFF08\u7ED9 agent \u6D4F\u89C8\u5668 navigate \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").action((
|
|
15214
|
+
program.command("open [path]").description("\u7528\u5F53\u524D CLI \u8EAB\u4EFD\u6253\u5F00\u524D\u7AEF\u9875\u9762\uFF1A\u94F8\u4E00\u5F20 60s \u4E00\u6B21\u6027\u7968\u636E\u4EA4\u7ED9\u6D4F\u89C8\u5668\uFF0C\u4F1A\u8BDD token \u4E0D\u8FDB URL").option("--print-url", "\u53EA\u6253\u5370\u767B\u5F55 URL\uFF0C\u4E0D\u5F00\u6D4F\u89C8\u5668\uFF08\u7ED9 agent \u6D4F\u89C8\u5668 navigate \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").action((path19, opts) => openCommand(path19, opts));
|
|
14769
15215
|
var setting = program.command("setting").description("\u79DF\u6237\u7CFB\u7EDF\u53C2\u6570\uFF08\u767B\u5F55\u7B56\u7565 / \u5BC6\u7801\u7B56\u7565 / \u529F\u80FD\u5F00\u5173 / \u96C6\u6210\u53C2\u6570\uFF09");
|
|
14770
15216
|
setting.command("get <domain>").description("\u8BFB\u67D0\u57DF\u53C2\u6570\uFF08\u5B9A\u4E49 + \u79DF\u6237\u8986\u76D6\u503C\u5408\u5E76\uFF0C\u7F3A\u5931\u56DE\u843D\u9ED8\u8BA4\u503C\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").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((d, opts) => settingGetCommand(d, opts));
|
|
14771
15217
|
setting.command("set <domain>").description("\u6539\u53C2\u6570\uFF0C\u53EF\u91CD\u590D --set\uFF1B\u8D70\u53D7\u63A7\u6821\u9A8C\u8DEF\u5F84\u800C\u975E\u6807\u51C6 CRUD").option(
|