@hcmai/cli 0.22.1 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/index.js +917 -631
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +22 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -33,13 +33,13 @@ function prepareImpersonationExit(code2, brokenStderr = false) {
|
|
|
33
33
|
terminating ??= (async () => {
|
|
34
34
|
process.exitCode = code2 || process.exitCode || 0;
|
|
35
35
|
const errors = await cleanup();
|
|
36
|
-
await new Promise((
|
|
36
|
+
await new Promise((resolve4) => {
|
|
37
37
|
let remaining = 2;
|
|
38
|
-
const timer = setTimeout(
|
|
38
|
+
const timer = setTimeout(resolve4, 1e3);
|
|
39
39
|
const done = () => {
|
|
40
40
|
if (--remaining === 0) {
|
|
41
41
|
clearTimeout(timer);
|
|
42
|
-
|
|
42
|
+
resolve4();
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
for (const stream of [process.stdout, process.stderr]) {
|
|
@@ -794,8 +794,8 @@ var init_TerminalRenderer = __esm({
|
|
|
794
794
|
}
|
|
795
795
|
}
|
|
796
796
|
/** 来源行(仅子代理触发,agentPath ≥2 段时显示 `↑ 来自 a › b`,对齐 Web)。 */
|
|
797
|
-
originLine(
|
|
798
|
-
const segs =
|
|
797
|
+
originLine(path22) {
|
|
798
|
+
const segs = path22.split(".").filter(Boolean);
|
|
799
799
|
if (segs.length < 2) return "";
|
|
800
800
|
const names = segs.map((k) => agentDisplayName(k));
|
|
801
801
|
return chalk.gray(` \u2191 \u6765\u81EA ${names.join(" \u203A ")}`) + "\n";
|
|
@@ -1760,12 +1760,12 @@ function ReplApp(props) {
|
|
|
1760
1760
|
setInteraction(null);
|
|
1761
1761
|
}
|
|
1762
1762
|
}, [appendBlock, updateStreaming, props]);
|
|
1763
|
-
const uploadOne = useCallback(async (
|
|
1763
|
+
const uploadOne = useCallback(async (filePath2) => {
|
|
1764
1764
|
try {
|
|
1765
|
-
const meta2 = await uploadDocument(props.client.raw(),
|
|
1765
|
+
const meta2 = await uploadDocument(props.client.raw(), filePath2);
|
|
1766
1766
|
return meta2;
|
|
1767
1767
|
} catch (e) {
|
|
1768
|
-
appendBlock({ kind: "banner", text: `\u{1F4CE} \u4E0A\u4F20\u5931\u8D25 ${
|
|
1768
|
+
appendBlock({ kind: "banner", text: `\u{1F4CE} \u4E0A\u4F20\u5931\u8D25 ${filePath2}: ${e.message}` });
|
|
1769
1769
|
return null;
|
|
1770
1770
|
}
|
|
1771
1771
|
}, [appendBlock, props.client]);
|
|
@@ -1984,8 +1984,8 @@ function agentLabel(agentId) {
|
|
|
1984
1984
|
if (/^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(agentId)) return `agent \u2026${agentId.slice(-4)}`;
|
|
1985
1985
|
return agentDisplayName(agentId);
|
|
1986
1986
|
}
|
|
1987
|
-
function originLine(
|
|
1988
|
-
const segs = (
|
|
1987
|
+
function originLine(path22) {
|
|
1988
|
+
const segs = (path22 ?? "").split(".").filter(Boolean);
|
|
1989
1989
|
if (segs.length < 2) return null;
|
|
1990
1990
|
return `\u6765\u81EA ${segs.map((k) => agentDisplayName(k)).join(" \u203A ")}`;
|
|
1991
1991
|
}
|
|
@@ -2221,10 +2221,10 @@ __export(readline_exports, {
|
|
|
2221
2221
|
import * as readline2 from "readline";
|
|
2222
2222
|
function readLineFromStdin(prompt = "") {
|
|
2223
2223
|
const rl = readline2.createInterface({ input: process.stdin, output: process.stdout });
|
|
2224
|
-
return new Promise((
|
|
2224
|
+
return new Promise((resolve4) => {
|
|
2225
2225
|
rl.question(prompt, (answer) => {
|
|
2226
2226
|
rl.close();
|
|
2227
|
-
|
|
2227
|
+
resolve4(answer);
|
|
2228
2228
|
});
|
|
2229
2229
|
});
|
|
2230
2230
|
}
|
|
@@ -2282,7 +2282,7 @@ import {
|
|
|
2282
2282
|
import * as readline from "readline";
|
|
2283
2283
|
async function promptText(question, output = process.stdout) {
|
|
2284
2284
|
const rl = readline.createInterface({ input: process.stdin, output });
|
|
2285
|
-
return new Promise((
|
|
2285
|
+
return new Promise((resolve4, reject) => {
|
|
2286
2286
|
let answered = false;
|
|
2287
2287
|
rl.on("close", () => {
|
|
2288
2288
|
if (!answered) reject(new Error("\u8F93\u5165\u5DF2\u7ED3\u675F\uFF1B\u64CD\u4F5C\u5DF2\u53D6\u6D88\u3002"));
|
|
@@ -2290,12 +2290,12 @@ async function promptText(question, output = process.stdout) {
|
|
|
2290
2290
|
rl.question(question, (ans) => {
|
|
2291
2291
|
answered = true;
|
|
2292
2292
|
rl.close();
|
|
2293
|
-
|
|
2293
|
+
resolve4(ans.trim());
|
|
2294
2294
|
});
|
|
2295
2295
|
});
|
|
2296
2296
|
}
|
|
2297
2297
|
async function promptSecret(question, output = process.stdout) {
|
|
2298
|
-
return new Promise((
|
|
2298
|
+
return new Promise((resolve4, reject) => {
|
|
2299
2299
|
const stdin = process.stdin;
|
|
2300
2300
|
stdin.setRawMode?.(true);
|
|
2301
2301
|
let buf = "";
|
|
@@ -2315,7 +2315,7 @@ async function promptSecret(question, output = process.stdout) {
|
|
|
2315
2315
|
stdin.removeListener("data", onData);
|
|
2316
2316
|
stdin.removeListener("end", onEnd);
|
|
2317
2317
|
output.write("\n");
|
|
2318
|
-
|
|
2318
|
+
resolve4(buf);
|
|
2319
2319
|
return;
|
|
2320
2320
|
}
|
|
2321
2321
|
if (ch === "") {
|
|
@@ -2410,7 +2410,7 @@ function launchBrowser(url, platform = process.platform, onFailure) {
|
|
|
2410
2410
|
child.unref();
|
|
2411
2411
|
}
|
|
2412
2412
|
async function runOpen(target, args, deps) {
|
|
2413
|
-
const
|
|
2413
|
+
const path22 = normalizeTarget(target);
|
|
2414
2414
|
if (!deps.frontend?.trim()) {
|
|
2415
2415
|
throw new CliError3({
|
|
2416
2416
|
code: CliErrorCode2.INVALID_ARGUMENT,
|
|
@@ -2418,13 +2418,13 @@ async function runOpen(target, args, deps) {
|
|
|
2418
2418
|
});
|
|
2419
2419
|
}
|
|
2420
2420
|
const { ticket, expiresIn } = await deps.mintTicket();
|
|
2421
|
-
const url = buildBrowserLoginUrl(deps.frontend, ticket,
|
|
2421
|
+
const url = buildBrowserLoginUrl(deps.frontend, ticket, path22);
|
|
2422
2422
|
if (args.printUrl) {
|
|
2423
2423
|
deps.write(`${url}
|
|
2424
2424
|
`);
|
|
2425
2425
|
} else {
|
|
2426
2426
|
deps.launch(url);
|
|
2427
|
-
deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${
|
|
2427
|
+
deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${path22}\uFF08\u7968\u636E ${expiresIn ?? 60}s \u5185\u6709\u6548\uFF0C\u53EA\u80FD\u7528\u4E00\u6B21\uFF09
|
|
2428
2428
|
`);
|
|
2429
2429
|
}
|
|
2430
2430
|
return { url, expiresIn };
|
|
@@ -2621,10 +2621,10 @@ async function beginBrowserLogin(input) {
|
|
|
2621
2621
|
let closing;
|
|
2622
2622
|
let watch;
|
|
2623
2623
|
let stopCountdown = () => void 0;
|
|
2624
|
-
let
|
|
2624
|
+
let resolve4;
|
|
2625
2625
|
let reject;
|
|
2626
2626
|
const result = new Promise((yes, no) => {
|
|
2627
|
-
|
|
2627
|
+
resolve4 = yes;
|
|
2628
2628
|
reject = no;
|
|
2629
2629
|
});
|
|
2630
2630
|
void result.catch(() => void 0);
|
|
@@ -2677,7 +2677,7 @@ async function beginBrowserLogin(input) {
|
|
|
2677
2677
|
}).then((authorized) => {
|
|
2678
2678
|
verifier = "";
|
|
2679
2679
|
session = authorized;
|
|
2680
|
-
|
|
2680
|
+
resolve4({ session, close, complete: async () => {
|
|
2681
2681
|
if (cancel.controller.signal.aborted) throw cancel.error(new Error("\u767B\u5F55\u5DF2\u53D6\u6D88"));
|
|
2682
2682
|
session.complete();
|
|
2683
2683
|
reply(response, 200, "CLI \u767B\u5F55\u6210\u529F");
|
|
@@ -2912,9 +2912,9 @@ async function migrateProfileTokenToIdentity(envName, identityName) {
|
|
|
2912
2912
|
const rawAccess = await oldStore.getAccessToken();
|
|
2913
2913
|
const rawRefresh = await oldStore.getRefreshToken();
|
|
2914
2914
|
const newStore = TokenStore2.forIdentity(identityName);
|
|
2915
|
-
const
|
|
2916
|
-
if (rawAccess)
|
|
2917
|
-
if (rawRefresh)
|
|
2915
|
+
const record2 = { ...oldMeta };
|
|
2916
|
+
if (rawAccess) record2.accessTokenRef = await newStore.setAccessToken(rawAccess);
|
|
2917
|
+
if (rawRefresh) record2.refreshTokenRef = await newStore.setRefreshToken(rawRefresh);
|
|
2918
2918
|
try {
|
|
2919
2919
|
await oldStore.clear();
|
|
2920
2920
|
} catch (err) {
|
|
@@ -2925,7 +2925,7 @@ async function migrateProfileTokenToIdentity(envName, identityName) {
|
|
|
2925
2925
|
`
|
|
2926
2926
|
);
|
|
2927
2927
|
}
|
|
2928
|
-
return
|
|
2928
|
+
return record2;
|
|
2929
2929
|
}
|
|
2930
2930
|
async function discardTempEnvSessions() {
|
|
2931
2931
|
const ids = await listIdentities2(TEMP_ENV_NAME).catch(() => []);
|
|
@@ -3154,7 +3154,7 @@ async function loginCommand(args) {
|
|
|
3154
3154
|
principal = session.principal;
|
|
3155
3155
|
username = principal.username;
|
|
3156
3156
|
} else if (args.code) {
|
|
3157
|
-
const { record, principal: p } = await loginPairing({
|
|
3157
|
+
const { record: record2, principal: p } = await loginPairing({
|
|
3158
3158
|
endpoint,
|
|
3159
3159
|
code: args.code,
|
|
3160
3160
|
profile: envName,
|
|
@@ -3166,11 +3166,11 @@ async function loginCommand(args) {
|
|
|
3166
3166
|
await saveEnv(envName, envCfg);
|
|
3167
3167
|
}
|
|
3168
3168
|
scheme = "pairing";
|
|
3169
|
-
scopes =
|
|
3169
|
+
scopes = record2.scopes;
|
|
3170
3170
|
principal = p;
|
|
3171
3171
|
username = p?.username;
|
|
3172
3172
|
} else if (pat) {
|
|
3173
|
-
const { record, principal: p } = await loginPat({
|
|
3173
|
+
const { record: record2, principal: p } = await loginPat({
|
|
3174
3174
|
endpoint,
|
|
3175
3175
|
tenantId,
|
|
3176
3176
|
pat,
|
|
@@ -3179,7 +3179,7 @@ async function loginCommand(args) {
|
|
|
3179
3179
|
httpClient: http
|
|
3180
3180
|
});
|
|
3181
3181
|
scheme = "pat";
|
|
3182
|
-
scopes =
|
|
3182
|
+
scopes = record2.scopes;
|
|
3183
3183
|
principal = p;
|
|
3184
3184
|
} else if (args.clientId || args.clientSecret) {
|
|
3185
3185
|
clientId = args.clientId ?? await promptText("client_id: ");
|
|
@@ -3190,7 +3190,7 @@ async function loginCommand(args) {
|
|
|
3190
3190
|
message: "client_id and client_secret required"
|
|
3191
3191
|
});
|
|
3192
3192
|
}
|
|
3193
|
-
const { record, principal: machinePrincipal } = await loginClientCredentials({
|
|
3193
|
+
const { record: record2, principal: machinePrincipal } = await loginClientCredentials({
|
|
3194
3194
|
endpoint,
|
|
3195
3195
|
tenantId,
|
|
3196
3196
|
clientId,
|
|
@@ -3201,7 +3201,7 @@ async function loginCommand(args) {
|
|
|
3201
3201
|
});
|
|
3202
3202
|
scheme = "client_credentials";
|
|
3203
3203
|
principal = machinePrincipal;
|
|
3204
|
-
scopes =
|
|
3204
|
+
scopes = record2.scopes;
|
|
3205
3205
|
} else {
|
|
3206
3206
|
username = args.username ?? await promptText("username: ", process.stderr);
|
|
3207
3207
|
await assertPasswordLoginAccount(username, envName);
|
|
@@ -3224,12 +3224,12 @@ async function loginCommand(args) {
|
|
|
3224
3224
|
message: "username and password required"
|
|
3225
3225
|
});
|
|
3226
3226
|
}
|
|
3227
|
-
const { record, principal: p } = await loginPasswordWithFirstLoginChange(
|
|
3227
|
+
const { record: record2, principal: p } = await loginPasswordWithFirstLoginChange(
|
|
3228
3228
|
{ endpoint, tenantId, username, password, profile: envName, expectedTenantId: project2?.environment.tenant, httpClient: http },
|
|
3229
3229
|
args
|
|
3230
3230
|
);
|
|
3231
3231
|
scheme = "password";
|
|
3232
|
-
scopes =
|
|
3232
|
+
scopes = record2.scopes;
|
|
3233
3233
|
principal = p;
|
|
3234
3234
|
}
|
|
3235
3235
|
if (projectEnvPending) {
|
|
@@ -3403,9 +3403,9 @@ async function loginCommand(args) {
|
|
|
3403
3403
|
}
|
|
3404
3404
|
const err = e;
|
|
3405
3405
|
if (err.isAxiosError) {
|
|
3406
|
-
const { fromAxiosError:
|
|
3406
|
+
const { fromAxiosError: fromAxiosError28 } = await import("@hcmai/sdk");
|
|
3407
3407
|
exitWithError(
|
|
3408
|
-
|
|
3408
|
+
fromAxiosError28(
|
|
3409
3409
|
e,
|
|
3410
3410
|
envName
|
|
3411
3411
|
)
|
|
@@ -4658,8 +4658,8 @@ import {
|
|
|
4658
4658
|
formatObject as formatObject7,
|
|
4659
4659
|
fromAxiosError as fromAxiosError9
|
|
4660
4660
|
} from "@hcmai/sdk";
|
|
4661
|
-
function collectYmlFiles(
|
|
4662
|
-
if (statSync(
|
|
4661
|
+
function collectYmlFiles(path22) {
|
|
4662
|
+
if (statSync(path22).isFile()) return [path22];
|
|
4663
4663
|
const out = [];
|
|
4664
4664
|
const walk = (dir) => {
|
|
4665
4665
|
for (const name of readdirSync(dir).sort()) {
|
|
@@ -4668,7 +4668,7 @@ function collectYmlFiles(path21) {
|
|
|
4668
4668
|
else if (full.endsWith(".yml") || full.endsWith(".yaml")) out.push(full);
|
|
4669
4669
|
}
|
|
4670
4670
|
};
|
|
4671
|
-
walk(
|
|
4671
|
+
walk(path22);
|
|
4672
4672
|
return out.sort();
|
|
4673
4673
|
}
|
|
4674
4674
|
var DRY_RUN_CLIENT = {
|
|
@@ -4677,9 +4677,9 @@ var DRY_RUN_CLIENT = {
|
|
|
4677
4677
|
update: async () => ({}),
|
|
4678
4678
|
fieldKeys: async () => []
|
|
4679
4679
|
};
|
|
4680
|
-
async function importCommand(
|
|
4680
|
+
async function importCommand(path22, args) {
|
|
4681
4681
|
try {
|
|
4682
|
-
const files = collectYmlFiles(
|
|
4682
|
+
const files = collectYmlFiles(path22);
|
|
4683
4683
|
const fixtures = files.map(
|
|
4684
4684
|
(f) => parseFixture(readFileSync2(f, "utf8"), relative(process.cwd(), f))
|
|
4685
4685
|
);
|
|
@@ -5352,11 +5352,11 @@ async function chatCommand(prompt, args) {
|
|
|
5352
5352
|
lastConversationId: handle.conversationId,
|
|
5353
5353
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5354
5354
|
});
|
|
5355
|
-
await new Promise((
|
|
5355
|
+
await new Promise((resolve4) => {
|
|
5356
5356
|
if (process.stdout.writableNeedDrain) {
|
|
5357
|
-
process.stdout.once("drain",
|
|
5357
|
+
process.stdout.once("drain", resolve4);
|
|
5358
5358
|
} else {
|
|
5359
|
-
|
|
5359
|
+
resolve4();
|
|
5360
5360
|
}
|
|
5361
5361
|
});
|
|
5362
5362
|
process.exitCode = 0;
|
|
@@ -5425,11 +5425,11 @@ async function chatCommand(prompt, args) {
|
|
|
5425
5425
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5426
5426
|
});
|
|
5427
5427
|
process.removeListener("SIGINT", sigintHandler);
|
|
5428
|
-
await new Promise((
|
|
5428
|
+
await new Promise((resolve4) => {
|
|
5429
5429
|
if (process.stdout.writableNeedDrain) {
|
|
5430
|
-
process.stdout.once("drain",
|
|
5430
|
+
process.stdout.once("drain", resolve4);
|
|
5431
5431
|
} else {
|
|
5432
|
-
|
|
5432
|
+
resolve4();
|
|
5433
5433
|
}
|
|
5434
5434
|
});
|
|
5435
5435
|
process.exitCode = result.status === "interrupted" ? 130 : 0;
|
|
@@ -6393,13 +6393,13 @@ import {
|
|
|
6393
6393
|
uploadDocument as uploadDocument2
|
|
6394
6394
|
} from "@hcmai/sdk";
|
|
6395
6395
|
var DEFAULT_UPLOAD_CATEGORY = "attachment";
|
|
6396
|
-
async function uploadCommand(
|
|
6396
|
+
async function uploadCommand(filePath2, args) {
|
|
6397
6397
|
try {
|
|
6398
6398
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
6399
6399
|
const client3 = HcmClient18.fromAuthContext(ctx);
|
|
6400
6400
|
const meta2 = await uploadDocument2(
|
|
6401
6401
|
client3.raw(),
|
|
6402
|
-
|
|
6402
|
+
filePath2,
|
|
6403
6403
|
args.category ?? DEFAULT_UPLOAD_CATEGORY,
|
|
6404
6404
|
args.model || args.originId || args.field ? { model: args.model ?? "", originId: args.originId ?? "", field: args.field ?? "", state: args.state } : void 0
|
|
6405
6405
|
);
|
|
@@ -6426,7 +6426,7 @@ async function uploadCommand(filePath, args) {
|
|
|
6426
6426
|
const err = e;
|
|
6427
6427
|
const status = err?.response?.status;
|
|
6428
6428
|
if (err?.code === "ENOENT") {
|
|
6429
|
-
exitWithError(new Error(`\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${
|
|
6429
|
+
exitWithError(new Error(`\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${filePath2}`));
|
|
6430
6430
|
} else if (status === 413) {
|
|
6431
6431
|
exitWithError(new Error("\u6587\u4EF6\u8D85\u51FA\u670D\u52A1\u7AEF\u5927\u5C0F\u4E0A\u9650\uFF08413\uFF09"));
|
|
6432
6432
|
} else if (err?.isAxiosError) {
|
|
@@ -6712,8 +6712,8 @@ function conflictMessage(ids, endpoint) {
|
|
|
6712
6712
|
function unconfirmedConflictNote(source) {
|
|
6713
6713
|
return `\u672C\u8D9F\u53EA\u770B\u4E86${source === "cli" ? "CLI \u81EA\u5E26" : "\u777F\u620E"}\u6765\u6E90\uFF0C\u672A\u505A\u8DE8\u6765\u6E90\u51B2\u7A81\u68C0\u67E5`;
|
|
6714
6714
|
}
|
|
6715
|
-
function classifyInstalledSource(id,
|
|
6716
|
-
const kind =
|
|
6715
|
+
function classifyInstalledSource(id, record2, catalog) {
|
|
6716
|
+
const kind = record2.sourceKind ?? "chiron";
|
|
6717
6717
|
if (kind === "local") return "local";
|
|
6718
6718
|
const half = kind === "cli" ? catalog.cli : catalog.chiron;
|
|
6719
6719
|
if (half.status !== "fetched") return "not-checked";
|
|
@@ -6792,7 +6792,7 @@ function upsertBlock(existing, begin, end, block) {
|
|
|
6792
6792
|
}
|
|
6793
6793
|
|
|
6794
6794
|
// src/commands/generated/agent-boundary.ts
|
|
6795
|
-
var BUILTIN_BOUNDARY = '# HCM \u987E\u95EE\u9879\u76EE\u8FB9\u754C\n\n- Next \u6280\u80FD\u53EA\u8BA4\u672C\u9879\u76EE\u7684\u4EA7\u54C1\u6280\u80FD\u4E0E\u65B9\u6CD5\u6280\u80FD\uFF1A\u4EA7\u54C1\u6280\u80FD\u5728 `hcm-skills/`\uFF0C\u8BB2\u300C\u8FD9\u7248\u4EA7\u54C1\u600E\u4E48\u64CD\u4F5C\u300D\uFF1B\u65B9\u6CD5\u6280\u80FD id \u4EE5 `method-` \u5F00\u5934\uFF0C\u6309 `hcm-methodology/methodology.lock.json` \u56FA\u5B9A\u7248\u672C\uFF0C\u8BB2\u300C\u5B9E\u65BD\u600E\u4E48\u7EC4\u7EC7\u300D\u3002\u4E24\u8FB9\u8BF4\u6CD5\u4E0D\u4E00\u81F4\u65F6\uFF0CNext \u4EA7\u54C1\u600E\u4E48\u64CD\u4F5C\u4EE5 `hcm-skills/` \u4E3A\u51C6\u3002Next \u547D\u4EE4\u53EA\u7528\u5DF2\u53D1\u5E03\u7684 `hcm` CLI\uFF1B\u4E0D\u8BFB\u53D6\u4EA7\u54C1\u6E90\u7801\uFF0C\u4E0D\u76F4\u8FDE\u6570\u636E\u5E93\uFF0C\u4E0D\u7528 `curl` \u7ED5\u8FC7\u5404\u7AEF\u6B63\u5F0F CLI\u3002\n- \u4EFB\u52A1\u660E\u786E\u6D89\u53CA\u65E7\u7248 HCM Cloud \u6E90\u7CFB\u7EDF\u65F6\uFF0C\u5148\u786E\u8BA4\u7CFB\u7EDF\u7C7B\u578B\uFF0C\u518D\u8BFB\u53D6\u539F\u4EA4\u4ED8\u5305\u7684 `hcmcloud-client`\u3001`hcmcloud-operator`\u3001`hcmcloud-configurator`\uFF0C\u4F7F\u7528 `hcmo` \u8BA4\u8BC1\u4E0E\u53EA\u8BFB\u6E90\u63A2\u67E5\u3002\u539F\u6280\u80FD\u672A\u5B89\u88C5\u6216\u6388\u6743\u51ED\u636E\u4E0D\u53EF\u7528\u65F6\u8BB0\u5F55\u771F\u5B9E\u963B\u585E\uFF0C\u6309\u539F\u4EA4\u4ED8\u6E20\u9053\u8865\u9F50\uFF1B\u4E0D\u4E34\u65F6\u91CD\u5199\u767B\u5F55\u3002\u6B64\u5165\u53E3\u4EC5\u9002\u7528\u4E8E\u65E7\u6E90\uFF0C\u4E0D\u66FF\u4EE3 Next \u76EE\u6807\u7684 `hcm`\uFF0C\u4E0D\u589E\u52A0\u6E90\u7AEF\u5199\u5165\u6216\u5B8C\u6574\u4E8B\u4EF6\u8FC1\u79FB\u6743\u9650\u3002\n- \u6280\u80FD\u76EE\u5F55\u5206\u4E24\u534A\uFF1A`hcm-skills/sync/` \u662F\u4EA7\u54C1\u7684\uFF08\u540C\u6B65\u7EF4\u62A4\uFF0C\u522B\u624B\u6539\uFF09\uFF0C`hcm-skills/local/` \u662F\u8FD9\u4E2A\u9879\u76EE\u81EA\u5DF1\u7684\uFF08\u540C\u6B65\u4E0D\u78B0\uFF09\u3002\u8981\u6539\u4E00\u4EFD\u4EA7\u54C1\u6280\u80FD\uFF0C\u590D\u5236\u5230 `local/` \u6539\u2014\u2014\u540C\u540D\u65F6\u5B83\u906E\u853D\u4EA7\u54C1\u90A3\u4EFD\uFF0C\u800C\u4EA7\u54C1\u90A3\u4EFD\u7EE7\u7EED\u8DDF\u7740\u66F4\u65B0\u3002\n- **\u63A5\u5230\u9700\u6C42\u5148\u505A\u4E00\u8F6E\u53EA\u8BFB\u6838\u5BF9**\uFF08\u8FB9\u754C\u3001\u6280\u80FD\u6E05\u5355\u3001CLI \u7248\u672C\u3001\u73AF\u5883\u4E0E\u8EAB\u4EFD\uFF09\uFF0C\u7ED9\u51FA READY / READY WITH RISKS / BLOCKED \u518D\u52A8\u624B\u3002\u987E\u95EE\u4E0D\u9700\u8981\u7C98\u4EFB\u4F55\u5F00\u573A\u767D\uFF0C\u8FD9\u6761\u5C31\u662F\u5F00\u573A\u767D\u3002\n- \u9700\u6C42\u8BF4\u5F97\u542B\u7CCA\u5C31\u8FFD\u95EE\uFF0C\u4E0D\u8981\u66FF\u5BA2\u6237\u731C\u53E3\u5F84\uFF1B\u53E3\u5F84\u4E0E\u8303\u56F4\u5199\u8FDB `requirements/`\uFF0C\u5BA2\u6237\u62CD\u677F\u7684\u5199\u8FDB `decisions/`\u3002\n- Next \u9879\u76EE\u5BF9\u7740\u7684\u73AF\u5883\u5728 `env.yaml`\uFF08default / environments\uFF0C\u5404\u73AF\u5883\u542B endpoint / frontend / tenant / roles\uFF09\uFF0C\u8EAB\u4EFD\u5728\u672C\u673A `hcm login`\u3002\u6BCF\u6B21\u5F00\u5DE5\u5BF9 Next \u7AEF\u8DD1 `hcm chiron doctor`\uFF1B\u65E7\u6E90\u6309\u539F\u6280\u80FD\u72EC\u7ACB\u914D\u7F6E\u3001\u8BA4\u8BC1\u4E0E\u6838\u5BF9\u6743\u9650\uFF0C\u4E0D\u8981\u6C42 Next identity\u3002\u73AF\u5883\u4E8B\u5B9E\u5FC5\u987B\u73B0\u67E5\uFF0C\u4E0D\u51ED\u8BB0\u5FC6\u586B\u5199\u3002\n- \u5199\u6388\u6743\u53EA\u8BA4\u9879\u76EE\u8D1F\u8D23\u4EBA\u5728**\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66**\u91CC\u7684\u660E\u786E\u6279\u51C6\uFF1B\u5BA2\u6237\u53E3\u5934\u8981\u6C42\u6216\u7FA4\u6D88\u606F\u4E0D\u662F\u6267\u884C\u6388\u6743\u3002\n- \u5199\u524D\u5FC5\u987B\u8BF4\u660E\u5BF9\u8C61\u3001\u8303\u56F4\u3001\u5F71\u54CD\u4E0E\u56DE\u9000\u5E76\u53D6\u5F97\u672C\u6B21\u660E\u786E\u786E\u8BA4\u3002\u975E\u4EA4\u4E92\u8FD0\u884C\u62FF\u4E0D\u5230\u786E\u8BA4\u65F6**\u505C\u5728\u8BA1\u5212\u3001\u4E0D\u8981\u5199**\uFF0C\u7ED3\u8BBA\u5FC5\u987B\u4E3A `BLOCKED` \u5E76\u9644\u8BA1\u5212\u3002\n- \u76EE\u5F55\u7EA6\u5B9A\uFF1A`requirements/` \u5BA2\u6237\u9700\u6C42 \xB7 `deliverables/` \u4EA4\u4ED8\u7269 \xB7 `evidence/` \u622A\u56FE\u4E0E\u6536\u636E \xB7 `cases/` \u6C89\u6DC0\u7684\u6848\u4F8B \xB7 `gaps/` \u4EA7\u54C1\u505A\u4E0D\u5230\u7684\u53F0\u8D26 \xB7 `decisions/` \u51B3\u7B56 \xB7 `customer-docs/` \u5BA2\u6237\u8D44\u6599 \xB7 `work/` \u53D8\u66F4\u4E0E\u56DE\u6EDA\u8BF4\u660E\u3002\n- \u649E\u5230\u4EA7\u54C1\u505A\u4E0D\u5230\uFF1A\u5148\u5199 `gaps/` \u53F0\u8D26\u5E76\u7B54\u6E05\u4E09\u95EE\uFF0C\u7528 `hcm chiron gap search` \u67E5\u91CD\uFF0C\u7ECF\u987E\u95EE\u786E\u8BA4\u540E `hcm chiron gap submit` \u63D0\u5230 Jira\uFF08\u4EA7\u54C1\u5BF9\u5916\u7684\u7EDF\u4E00\u9762\uFF09\uFF0C\u62A5\u544A\u5199 `BLOCKED \xB7 \u5DF2\u63D0 <\u5355\u53F7> \xB7 \u66FF\u4EE3\u6CD5`\uFF1B\u4E4B\u540E\u7528 `hcm chiron gap status` \u67E5\u8FDB\u5EA6\uFF0C\u8981\u770B\u90A3\u5355\u7684\u5168\u90E8\u8BC4\u8BBA\u7528 `hcm chiron gap comments`\u3002\u4FEE\u590D\u53D1\u5230\u4F60\u7684\u73AF\u5883\u5E76\u6309\u6280\u80FD\u590D\u9A8C\u540E\uFF0C\u7531\u63D0\u5355\u4EBA\u7528 `hcm chiron gap verify <\u5355\u53F7> --result pass|fail|partial --body <\u8BC1\u636E>` \u56DE\u5199\uFF1Apass \u5173\u5355\u3001fail \u9000\u56DE\u3001partial \u53EA\u8BB0\u5F55\u4E0D\u5173\u5355\uFF1B\u53EA\u9A8C `gaps/` \u53F0\u8D26\u91CC\u8BB0\u7740 `outcome=created`\u3001\u81EA\u5DF1\u63D0\u7684\u5355\uFF0C\u56DE\u5199\u524D\u8981\u9879\u76EE\u8D1F\u8D23\u4EBA\u672C\u6B21\u660E\u786E\u540C\u610F\u3002\n- Next \u9875\u9762\u9A8C\u6536\u7EDF\u4E00\u7528 `hcm chiron page </\u8DEF\u5F84> --expect-text <\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C> --out evidence/\u2026.png`\uFF1B\u53EA\u622A\u5230\u56FE\u4E0D\u7B97\u901A\u8FC7\u3002\u8981\u70B9\u6309\u94AE / \u8FFD\u95EE / \u5207\u8303\u56F4\u518D\u622A\uFF0C\u7528 `--eval "<\u51FD\u6570\u4F53\uFF0C\u53EF await>"`\uFF080.15.7 \u8D77\uFF0C\u6C99\u7BB1\u91CC\u4E5F\u80FD\u8DD1\uFF09\u3002\u65E7\u6E90 UI \u9075\u5FAA\u539F\u6280\u80FD\u7684\u6D4F\u89C8\u5668\u64CD\u4F5C\u94FE\u8DEF\u3002\n- \u4EFB\u4F55\u51ED\u636E\u3001\u914D\u5BF9\u7801\u3001\u4EE4\u724C\u3001\u5BA2\u6237\u5BC6\u7801\u90FD\u4E0D\u5F97\u5199\u5165\u4ED3\u5E93\u3001\u547D\u4EE4\u53C2\u6570\u6216\u4EA4\u4ED8\u6587\u6863\u3002';
|
|
6795
|
+
var BUILTIN_BOUNDARY = '# HCM \u987E\u95EE\u9879\u76EE\u8FB9\u754C\n\n- Next \u6280\u80FD\u53EA\u8BA4\u672C\u9879\u76EE\u7684\u4EA7\u54C1\u6280\u80FD\u4E0E\u65B9\u6CD5\u6280\u80FD\uFF1A\u4EA7\u54C1\u6280\u80FD\u5728 `hcm-skills/`\uFF0C\u8BB2\u300C\u8FD9\u7248\u4EA7\u54C1\u600E\u4E48\u64CD\u4F5C\u300D\uFF1B\u65B9\u6CD5\u6280\u80FD id \u4EE5 `method-` \u5F00\u5934\uFF0C\u6309 `hcm-methodology/methodology.lock.json` \u56FA\u5B9A\u7248\u672C\uFF0C\u8BB2\u300C\u5B9E\u65BD\u600E\u4E48\u7EC4\u7EC7\u300D\u3002\u4E24\u8FB9\u8BF4\u6CD5\u4E0D\u4E00\u81F4\u65F6\uFF0CNext \u4EA7\u54C1\u600E\u4E48\u64CD\u4F5C\u4EE5 `hcm-skills/` \u4E3A\u51C6\u3002Next \u547D\u4EE4\u53EA\u7528\u5DF2\u53D1\u5E03\u7684 `hcm` CLI\uFF1B\u4E0D\u8BFB\u53D6\u4EA7\u54C1\u6E90\u7801\uFF0C\u4E0D\u76F4\u8FDE\u6570\u636E\u5E93\uFF0C\u4E0D\u7528 `curl` \u7ED5\u8FC7\u5404\u7AEF\u6B63\u5F0F CLI\u3002\n- \u4EFB\u52A1\u660E\u786E\u6D89\u53CA\u65E7\u7248 HCM Cloud \u6E90\u7CFB\u7EDF\u65F6\uFF0C\u5148\u786E\u8BA4\u7CFB\u7EDF\u7C7B\u578B\uFF0C\u518D\u8BFB\u53D6\u539F\u4EA4\u4ED8\u5305\u7684 `hcmcloud-client`\u3001`hcmcloud-operator`\u3001`hcmcloud-configurator`\uFF0C\u4F7F\u7528 `hcmo` \u8BA4\u8BC1\u4E0E\u53EA\u8BFB\u6E90\u63A2\u67E5\u3002\u539F\u6280\u80FD\u672A\u5B89\u88C5\u6216\u6388\u6743\u51ED\u636E\u4E0D\u53EF\u7528\u65F6\u8BB0\u5F55\u771F\u5B9E\u963B\u585E\uFF0C\u6309\u539F\u4EA4\u4ED8\u6E20\u9053\u8865\u9F50\uFF1B\u4E0D\u4E34\u65F6\u91CD\u5199\u767B\u5F55\u3002\u6B64\u5165\u53E3\u4EC5\u9002\u7528\u4E8E\u65E7\u6E90\uFF0C\u4E0D\u66FF\u4EE3 Next \u76EE\u6807\u7684 `hcm`\uFF0C\u4E0D\u589E\u52A0\u6E90\u7AEF\u5199\u5165\u6216\u5B8C\u6574\u4E8B\u4EF6\u8FC1\u79FB\u6743\u9650\u3002\n- \u6280\u80FD\u76EE\u5F55\u5206\u4E24\u534A\uFF1A`hcm-skills/sync/` \u662F\u4EA7\u54C1\u7684\uFF08\u540C\u6B65\u7EF4\u62A4\uFF0C\u522B\u624B\u6539\uFF09\uFF0C`hcm-skills/local/` \u662F\u8FD9\u4E2A\u9879\u76EE\u81EA\u5DF1\u7684\uFF08\u540C\u6B65\u4E0D\u78B0\uFF09\u3002\u8981\u6539\u4E00\u4EFD\u4EA7\u54C1\u6280\u80FD\uFF0C\u590D\u5236\u5230 `local/` \u6539\u2014\u2014\u540C\u540D\u65F6\u5B83\u906E\u853D\u4EA7\u54C1\u90A3\u4EFD\uFF0C\u800C\u4EA7\u54C1\u90A3\u4EFD\u7EE7\u7EED\u8DDF\u7740\u66F4\u65B0\u3002\n- **\u63A5\u5230\u9700\u6C42\u5148\u505A\u4E00\u8F6E\u53EA\u8BFB\u6838\u5BF9**\uFF08\u8FB9\u754C\u3001\u6280\u80FD\u6E05\u5355\u3001CLI \u7248\u672C\u3001\u73AF\u5883\u4E0E\u8EAB\u4EFD\uFF09\uFF0C\u7ED9\u51FA READY / READY WITH RISKS / BLOCKED \u518D\u52A8\u624B\u3002\u987E\u95EE\u4E0D\u9700\u8981\u7C98\u4EFB\u4F55\u5F00\u573A\u767D\uFF0C\u8FD9\u6761\u5C31\u662F\u5F00\u573A\u767D\u3002\n- \u9700\u6C42\u8BF4\u5F97\u542B\u7CCA\u5C31\u8FFD\u95EE\uFF0C\u4E0D\u8981\u66FF\u5BA2\u6237\u731C\u53E3\u5F84\uFF1B\u53E3\u5F84\u4E0E\u8303\u56F4\u5199\u8FDB `requirements/`\uFF0C\u5BA2\u6237\u62CD\u677F\u7684\u5199\u8FDB `decisions/`\u3002\n- Next \u9879\u76EE\u5BF9\u7740\u7684\u73AF\u5883\u5728 `env.yaml`\uFF08default / environments\uFF0C\u5404\u73AF\u5883\u542B endpoint / frontend / tenant / roles\uFF09\uFF0C\u8EAB\u4EFD\u5728\u672C\u673A `hcm login`\u3002\u6BCF\u6B21\u5F00\u5DE5\u5BF9 Next \u7AEF\u8DD1 `hcm chiron doctor`\uFF1B\u65E7\u6E90\u6309\u539F\u6280\u80FD\u72EC\u7ACB\u914D\u7F6E\u3001\u8BA4\u8BC1\u4E0E\u6838\u5BF9\u6743\u9650\uFF0C\u4E0D\u8981\u6C42 Next identity\u3002\u73AF\u5883\u4E8B\u5B9E\u5FC5\u987B\u73B0\u67E5\uFF0C\u4E0D\u51ED\u8BB0\u5FC6\u586B\u5199\u3002\n- \u5199\u6388\u6743\u53EA\u8BA4\u9879\u76EE\u8D1F\u8D23\u4EBA\u5728**\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66**\u91CC\u7684\u660E\u786E\u6279\u51C6\uFF1B\u5BA2\u6237\u53E3\u5934\u8981\u6C42\u6216\u7FA4\u6D88\u606F\u4E0D\u662F\u6267\u884C\u6388\u6743\u3002\n- \u521D\u59CB\u5316\u68C0\u67E5\u62A5 `BOOTSTRAP_OUTDATED` / `BOOTSTRAP_STATE_MISSING` \u65F6\uFF0C\u6309 `tenant-onboarding` \u5148\u6838\u5BF9\u548C\u4FDD\u5B58\u57FA\u7EBF\uFF1BCLI 0.23.0 \u8D77\u5141\u8BB8\u5F53\u524D ACTIVE \u4E1A\u52A1\u79DF\u6237\u7684\u666E\u901A `admin.system` \u4F1A\u8BDD\u5728\u672C\u6B21\u660E\u786E\u6388\u6743\u540E\u6267\u884C `hcm tenant reconcile` \u5E76\u72EC\u7ACB\u590D\u9A8C\u3002\u8FD9\u662F\u79DF\u6237\u6CBB\u7406\u7684\u7A84\u4F8B\u5916\uFF0C\u4E0D\u5141\u8BB8\u5F00\u901A\u3001\u91CD\u7F6E\u3001\u8DE8\u79DF\u6237\u64CD\u4F5C\u3001\u6307\u5B9A\u7248\u672C\u3001API Token\u3001OAuth \u59D4\u6258\u6216\u4EE3\u7406\uFF1B\u5DF2\u6709\u540C\u8303\u56F4\u6388\u6743\u4E0D\u91CD\u590D\u786E\u8BA4\uFF0C\u672A\u77E5\u56DE\u6267\u4E0D\u81EA\u52A8\u91CD\u53D1\u3002\n- \u5199\u524D\u5FC5\u987B\u8BF4\u660E\u5BF9\u8C61\u3001\u8303\u56F4\u3001\u5F71\u54CD\u4E0E\u56DE\u9000\u5E76\u53D6\u5F97\u672C\u6B21\u660E\u786E\u786E\u8BA4\u3002\u975E\u4EA4\u4E92\u8FD0\u884C\u62FF\u4E0D\u5230\u786E\u8BA4\u65F6**\u505C\u5728\u8BA1\u5212\u3001\u4E0D\u8981\u5199**\uFF0C\u7ED3\u8BBA\u5FC5\u987B\u4E3A `BLOCKED` \u5E76\u9644\u8BA1\u5212\u3002\n- \u76EE\u5F55\u7EA6\u5B9A\uFF1A`requirements/` \u5BA2\u6237\u9700\u6C42 \xB7 `deliverables/` \u4EA4\u4ED8\u7269 \xB7 `evidence/` \u622A\u56FE\u4E0E\u6536\u636E \xB7 `cases/` \u6C89\u6DC0\u7684\u6848\u4F8B \xB7 `gaps/` \u4EA7\u54C1\u505A\u4E0D\u5230\u7684\u53F0\u8D26 \xB7 `decisions/` \u51B3\u7B56 \xB7 `customer-docs/` \u5BA2\u6237\u8D44\u6599 \xB7 `work/` \u53D8\u66F4\u4E0E\u56DE\u6EDA\u8BF4\u660E\u3002\n- \u649E\u5230\u4EA7\u54C1\u505A\u4E0D\u5230\uFF1A\u5148\u5199 `gaps/` \u53F0\u8D26\u5E76\u7B54\u6E05\u4E09\u95EE\uFF0C\u7528 `hcm chiron gap search` \u67E5\u91CD\uFF0C\u7ECF\u987E\u95EE\u786E\u8BA4\u540E `hcm chiron gap submit` \u63D0\u5230 Jira\uFF08\u4EA7\u54C1\u5BF9\u5916\u7684\u7EDF\u4E00\u9762\uFF09\uFF0C\u62A5\u544A\u5199 `BLOCKED \xB7 \u5DF2\u63D0 <\u5355\u53F7> \xB7 \u66FF\u4EE3\u6CD5`\uFF1B\u4E4B\u540E\u7528 `hcm chiron gap status` \u67E5\u8FDB\u5EA6\uFF0C\u8981\u770B\u90A3\u5355\u7684\u5168\u90E8\u8BC4\u8BBA\u7528 `hcm chiron gap comments`\u3002\u4FEE\u590D\u53D1\u5230\u4F60\u7684\u73AF\u5883\u5E76\u6309\u6280\u80FD\u590D\u9A8C\u540E\uFF0C\u7531\u63D0\u5355\u4EBA\u7528 `hcm chiron gap verify <\u5355\u53F7> --result pass|fail|partial --body <\u8BC1\u636E>` \u56DE\u5199\uFF1Apass \u5173\u5355\u3001fail \u9000\u56DE\u3001partial \u53EA\u8BB0\u5F55\u4E0D\u5173\u5355\uFF1B\u53EA\u9A8C `gaps/` \u53F0\u8D26\u91CC\u8BB0\u7740 `outcome=created`\u3001\u81EA\u5DF1\u63D0\u7684\u5355\uFF0C\u56DE\u5199\u524D\u8981\u9879\u76EE\u8D1F\u8D23\u4EBA\u672C\u6B21\u660E\u786E\u540C\u610F\u3002\n- Next \u9875\u9762\u9A8C\u6536\u7EDF\u4E00\u7528 `hcm chiron page </\u8DEF\u5F84> --expect-text <\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C> --out evidence/\u2026.png`\uFF1B\u53EA\u622A\u5230\u56FE\u4E0D\u7B97\u901A\u8FC7\u3002\u8981\u70B9\u6309\u94AE / \u8FFD\u95EE / \u5207\u8303\u56F4\u518D\u622A\uFF0C\u7528 `--eval "<\u51FD\u6570\u4F53\uFF0C\u53EF await>"`\uFF080.15.7 \u8D77\uFF0C\u6C99\u7BB1\u91CC\u4E5F\u80FD\u8DD1\uFF09\u3002\u65E7\u6E90 UI \u9075\u5FAA\u539F\u6280\u80FD\u7684\u6D4F\u89C8\u5668\u64CD\u4F5C\u94FE\u8DEF\u3002\n- \u4EFB\u4F55\u51ED\u636E\u3001\u914D\u5BF9\u7801\u3001\u4EE4\u724C\u3001\u5BA2\u6237\u5BC6\u7801\u90FD\u4E0D\u5F97\u5199\u5165\u4ED3\u5E93\u3001\u547D\u4EE4\u53C2\u6570\u6216\u4EA4\u4ED8\u6587\u6863\u3002';
|
|
6796
6796
|
|
|
6797
6797
|
// src/commands/chiron-agent-boundary.ts
|
|
6798
6798
|
var FALLBACK_NOTICE = "> \u26A0\uFE0F \u672C\u6BB5\u6765\u81EA CLI \u5185\u7F6E\u526F\u672C\uFF0C**\u672A\u4E0E\u4EA7\u54C1\u7248\u672C\u6838\u5BF9**\uFF08\u8FD9\u4E2A\u73AF\u5883\u7684 `/chiron.json` \u6CA1\u5E26 `agentBoundary`\uFF0C\u591A\u534A\u662F\u540E\u7AEF\u8FD8\u6CA1\u5347\u5230\u542B\u4F5C\u8005\u6E90\u7684\u7248\u672C\uFF09\u3002\u8054\u7F51\u5E76\u5347\u7EA7\u540E\u7AEF\u540E\u8DD1\u4E00\u6B21 `hcm chiron skills sync` \u5C31\u4F1A\u6362\u6210\u4EA7\u54C1\u90A3\u4E00\u7248\u3002";
|
|
@@ -7446,13 +7446,13 @@ function resolveRenamedId(id, half) {
|
|
|
7446
7446
|
}
|
|
7447
7447
|
function migrateSkillsState(state) {
|
|
7448
7448
|
const skills2 = {};
|
|
7449
|
-
for (const [id,
|
|
7450
|
-
if (
|
|
7451
|
-
skills2[id] =
|
|
7449
|
+
for (const [id, record2] of Object.entries(state.skills ?? {})) {
|
|
7450
|
+
if (record2.sourceKind) {
|
|
7451
|
+
skills2[id] = record2;
|
|
7452
7452
|
continue;
|
|
7453
7453
|
}
|
|
7454
|
-
const kind = /^https?:\/\//i.test(
|
|
7455
|
-
skills2[id] = { ...
|
|
7454
|
+
const kind = /^https?:\/\//i.test(record2.source ?? "") ? "chiron" : "local";
|
|
7455
|
+
skills2[id] = { ...record2, sourceKind: kind, sourceLocator: record2.source };
|
|
7456
7456
|
}
|
|
7457
7457
|
return { ...state, skills: skills2 };
|
|
7458
7458
|
}
|
|
@@ -7760,7 +7760,7 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
|
|
|
7760
7760
|
return;
|
|
7761
7761
|
}
|
|
7762
7762
|
const rows2 = [];
|
|
7763
|
-
for (const [id,
|
|
7763
|
+
for (const [id, record2] of Object.entries(state?.skills ?? {}).sort(([a], [b]) => a.localeCompare(b))) {
|
|
7764
7764
|
const markdown = await readInstalled(layout.baseDir, id);
|
|
7765
7765
|
let title = id;
|
|
7766
7766
|
if (markdown !== void 0) {
|
|
@@ -7771,12 +7771,12 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
|
|
|
7771
7771
|
id,
|
|
7772
7772
|
title,
|
|
7773
7773
|
// 迁移保证它必然有值;`?? 'chiron'` 只是让类型闭合,不是业务缺省。
|
|
7774
|
-
sourceKind:
|
|
7775
|
-
sourceLocator:
|
|
7776
|
-
direct:
|
|
7777
|
-
installedAt:
|
|
7774
|
+
sourceKind: record2.sourceKind ?? "chiron",
|
|
7775
|
+
sourceLocator: record2.sourceLocator ?? record2.source,
|
|
7776
|
+
direct: record2.direct,
|
|
7777
|
+
installedAt: record2.installedAt,
|
|
7778
7778
|
// 三种状态互斥:文件没了 / 本地改过 / 和装的时候一致
|
|
7779
|
-
status: markdown === void 0 ? "missing" : sha2562(markdown) !==
|
|
7779
|
+
status: markdown === void 0 ? "missing" : sha2562(markdown) !== record2.sha256 ? "locally-modified" : "installed"
|
|
7780
7780
|
});
|
|
7781
7781
|
}
|
|
7782
7782
|
const shadowed = new Set(localSkills.map((x) => x.id));
|
|
@@ -8666,11 +8666,11 @@ async function planOrphanPrune(options) {
|
|
|
8666
8666
|
for (const entry of entries) {
|
|
8667
8667
|
if (!PRUNABLE_STATUS.has(entry.status)) continue;
|
|
8668
8668
|
const id = entry.id;
|
|
8669
|
-
const
|
|
8669
|
+
const record2 = state.skills[id];
|
|
8670
8670
|
const onDisk = await readInstalled(baseDir, id);
|
|
8671
|
-
if (onDisk !== void 0 &&
|
|
8672
|
-
let edited = sha2562(onDisk) !==
|
|
8673
|
-
for (const [refPath, recordedSha] of Object.entries(
|
|
8671
|
+
if (onDisk !== void 0 && record2 !== void 0) {
|
|
8672
|
+
let edited = sha2562(onDisk) !== record2.sha256;
|
|
8673
|
+
for (const [refPath, recordedSha] of Object.entries(record2.references ?? {})) {
|
|
8674
8674
|
const installed2 = await readInstalledReference(baseDir, id, refPath);
|
|
8675
8675
|
if (installed2 !== void 0 && sha2562(installed2) !== recordedSha) edited = true;
|
|
8676
8676
|
}
|
|
@@ -8749,10 +8749,10 @@ async function planSkillUpdate(options) {
|
|
|
8749
8749
|
}
|
|
8750
8750
|
const liveIds = directIds.filter((id) => !renamedAway.has(id));
|
|
8751
8751
|
for (const id of liveIds.sort()) {
|
|
8752
|
-
const
|
|
8753
|
-
const status = classifyInstalledSource(id,
|
|
8752
|
+
const record2 = state.skills[id];
|
|
8753
|
+
const status = classifyInstalledSource(id, record2, catalog);
|
|
8754
8754
|
if (status === "present") {
|
|
8755
|
-
live.push({ id, kind: (
|
|
8755
|
+
live.push({ id, kind: (record2.sourceKind ?? "chiron") === "cli" ? "cli" : "chiron" });
|
|
8756
8756
|
continue;
|
|
8757
8757
|
}
|
|
8758
8758
|
entries.push({ id, status, note: SOURCE_STATUS_NOTE[status] });
|
|
@@ -8805,7 +8805,7 @@ async function planSkillUpdate(options) {
|
|
|
8805
8805
|
const documents = [];
|
|
8806
8806
|
const verified = [];
|
|
8807
8807
|
for (const [id, item] of closure) {
|
|
8808
|
-
const
|
|
8808
|
+
const record2 = state.skills[id];
|
|
8809
8809
|
const onDisk = await readInstalled(baseDir, id);
|
|
8810
8810
|
const fetch2 = async () => item.kind === "cli" ? await fetchBundled(id) : await fetchDocument(item.skill);
|
|
8811
8811
|
if (onDisk === void 0) {
|
|
@@ -8814,18 +8814,18 @@ async function planSkillUpdate(options) {
|
|
|
8814
8814
|
entries.push({
|
|
8815
8815
|
id,
|
|
8816
8816
|
status: "added",
|
|
8817
|
-
note: renamedFromId ? `${renamedFromId} \u6539\u540D\u540E\u7684\u65B0\u540D\uFF0C\u5185\u5BB9\u642C\u5230\u4E86\u8FD9\u91CC` :
|
|
8817
|
+
note: renamedFromId ? `${renamedFromId} \u6539\u540D\u540E\u7684\u65B0\u540D\uFF0C\u5185\u5BB9\u642C\u5230\u4E86\u8FD9\u91CC` : record2 ? "\u672C\u5730\u6587\u4EF6\u7F3A\u5931\uFF0C\u91CD\u65B0\u88C5\u56DE" : all ? "\u4EA7\u54C1\u8FD9\u4E00\u7248\u65B0\u589E\u7684\u6280\u80FD" : "\u4EA7\u54C1\u65B0\u589E\u7684\u524D\u7F6E\u6280\u80FD"
|
|
8818
8818
|
});
|
|
8819
8819
|
continue;
|
|
8820
8820
|
}
|
|
8821
8821
|
const remote = await fetch2();
|
|
8822
8822
|
const remoteReferences = remote.references ?? [];
|
|
8823
8823
|
let differsFromRemote = remote.markdown !== onDisk;
|
|
8824
|
-
let editedLocally =
|
|
8824
|
+
let editedLocally = record2 !== void 0 && sha2562(onDisk) !== record2.sha256;
|
|
8825
8825
|
for (const reference of remoteReferences) {
|
|
8826
8826
|
const installed2 = await readInstalledReference(baseDir, id, reference.path);
|
|
8827
8827
|
if (installed2 !== reference.content) differsFromRemote = true;
|
|
8828
|
-
const recordedSha =
|
|
8828
|
+
const recordedSha = record2?.references?.[reference.path];
|
|
8829
8829
|
if (installed2 !== void 0 && recordedSha && sha2562(installed2) !== recordedSha) editedLocally = true;
|
|
8830
8830
|
}
|
|
8831
8831
|
if (!differsFromRemote) {
|
|
@@ -8868,17 +8868,17 @@ async function planSkillUpdate(options) {
|
|
|
8868
8868
|
function planLockAlignment(state, plan, endpoint, options = {}) {
|
|
8869
8869
|
const repairs = [];
|
|
8870
8870
|
for (const doc of plan.verified) {
|
|
8871
|
-
const
|
|
8872
|
-
if (!
|
|
8871
|
+
const record2 = state.skills[doc.id];
|
|
8872
|
+
if (!record2) continue;
|
|
8873
8873
|
const measured = sha2562(doc.markdown);
|
|
8874
8874
|
const references = {};
|
|
8875
8875
|
for (const ref of doc.references ?? []) {
|
|
8876
|
-
const actual = sha2562(ref.content), previous =
|
|
8876
|
+
const actual = sha2562(ref.content), previous = record2.references?.[ref.path];
|
|
8877
8877
|
if (actual !== previous) references[ref.path] = { from: previous, to: actual };
|
|
8878
8878
|
}
|
|
8879
|
-
if (
|
|
8879
|
+
if (record2.sha256 !== measured || Object.keys(references).length) repairs.push({
|
|
8880
8880
|
id: doc.id,
|
|
8881
|
-
...
|
|
8881
|
+
...record2.sha256 !== measured ? { sha256: { from: record2.sha256, to: measured } } : {},
|
|
8882
8882
|
references
|
|
8883
8883
|
});
|
|
8884
8884
|
}
|
|
@@ -8897,9 +8897,9 @@ async function applyLockAlignment(baseDir, alignment, check) {
|
|
|
8897
8897
|
const state = await readSkillsState(baseDir);
|
|
8898
8898
|
if (!state) throw invalid("\u9501\u6587\u4EF6\u5728\u5BF9\u8D26\u540E\u6D88\u5931\uFF1B\u672A\u5199\u5165\u5BF9\u9F50\u7ED3\u679C");
|
|
8899
8899
|
for (const repair of alignment.repairs) {
|
|
8900
|
-
const
|
|
8901
|
-
if (repair.sha256)
|
|
8902
|
-
for (const [name, value] of Object.entries(repair.references)) (
|
|
8900
|
+
const record2 = state.skills[repair.id];
|
|
8901
|
+
if (repair.sha256) record2.sha256 = repair.sha256.to;
|
|
8902
|
+
for (const [name, value] of Object.entries(repair.references)) (record2.references ??= {})[name] = value.to;
|
|
8903
8903
|
}
|
|
8904
8904
|
if (alignment.endpoint) state.endpoint = alignment.endpoint.to;
|
|
8905
8905
|
state.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -9443,14 +9443,138 @@ async function tenantBootstrapCommand(args) {
|
|
|
9443
9443
|
}
|
|
9444
9444
|
}
|
|
9445
9445
|
|
|
9446
|
+
// src/commands/tenant-reconcile.ts
|
|
9447
|
+
init_auth_guard();
|
|
9448
|
+
import {
|
|
9449
|
+
HcmClient as HcmClient21,
|
|
9450
|
+
readSessionPrincipal as readSessionPrincipal3,
|
|
9451
|
+
reconcileTenant,
|
|
9452
|
+
assertDangerWrite as assertDangerWrite5,
|
|
9453
|
+
formatObject as formatObject21,
|
|
9454
|
+
CliError as CliError23,
|
|
9455
|
+
CliErrorCode as CliErrorCode24,
|
|
9456
|
+
fromAxiosError as fromAxiosError20
|
|
9457
|
+
} from "@hcmai/sdk";
|
|
9458
|
+
import axios4 from "axios";
|
|
9459
|
+
init_exit();
|
|
9460
|
+
async function bootstrapReport(http) {
|
|
9461
|
+
const read = () => http.get("/api/system/health/report", { params: { only: "tenant.bootstrap" } });
|
|
9462
|
+
try {
|
|
9463
|
+
return (await read()).data;
|
|
9464
|
+
} catch (error) {
|
|
9465
|
+
const wait = axios4.isAxiosError(error) ? Number(error.response?.headers["retry-after"]) : NaN;
|
|
9466
|
+
if (!axios4.isAxiosError(error) || error.response?.status !== 429 || !Number.isFinite(wait) || wait < 0 || wait > 30) throw error;
|
|
9467
|
+
const waitSeconds = Math.ceil(wait) + 1;
|
|
9468
|
+
process.stderr.write(`\u521D\u59CB\u5316\u590D\u9A8C\u88AB\u8282\u6D41\uFF0C\u6309 Retry-After \u52A0\u4E00\u79D2\u8FB9\u754C\u7B49\u5F85 ${waitSeconds} \u79D2\u540E\u53EA\u91CD\u8BD5\u4E00\u6B21\u53EA\u8BFB\u68C0\u67E5\u3002
|
|
9469
|
+
`);
|
|
9470
|
+
await new Promise((resolve4) => setTimeout(resolve4, waitSeconds * 1e3));
|
|
9471
|
+
return (await read()).data;
|
|
9472
|
+
}
|
|
9473
|
+
}
|
|
9474
|
+
async function tenantReconcileCommand(args) {
|
|
9475
|
+
let attempted = false;
|
|
9476
|
+
try {
|
|
9477
|
+
const format = args.output ?? "json";
|
|
9478
|
+
if (!["table", "json", "yaml"].includes(format)) throw new CliError23({
|
|
9479
|
+
code: CliErrorCode24.INVALID_ARGUMENT,
|
|
9480
|
+
message: "--output \u53D6\u503C table | json | yaml"
|
|
9481
|
+
});
|
|
9482
|
+
if (args.as !== void 0) throw new CliError23({
|
|
9483
|
+
code: CliErrorCode24.INVALID_ARGUMENT,
|
|
9484
|
+
message: "\u521D\u59CB\u5316\u8865\u8DD1\u4E0D\u652F\u6301 --as\uFF1B\u672A\u89E3\u6790\u6216\u7B7E\u53D1\u4EE3\u7406\u4F1A\u8BDD\u3002",
|
|
9485
|
+
context: { nextStep: "\u5148\u7528 hcm identity use \u9009\u62E9\u8BE5\u73AF\u5883\u5DF2\u6709\u7684\u666E\u901A\u7BA1\u7406\u5458\u767B\u5F55\u8EAB\u4EFD\uFF0C\u518D\u6267\u884C\u8865\u8DD1\u3002" }
|
|
9486
|
+
});
|
|
9487
|
+
const ctx = await getActiveAuthContextFromCli(args);
|
|
9488
|
+
if (ctx.impersonation) throw new CliError23({
|
|
9489
|
+
code: CliErrorCode24.SCOPE_FORBIDDEN,
|
|
9490
|
+
message: "\u521D\u59CB\u5316\u8865\u8DD1\u4E0D\u63A5\u53D7\u4EE3\u7406\u4F1A\u8BDD\uFF1B\u8BF7\u7531\u5F53\u524D\u79DF\u6237\u7BA1\u7406\u5458\u4F7F\u7528\u666E\u901A\u767B\u5F55\u4F1A\u8BDD\u64CD\u4F5C\u3002"
|
|
9491
|
+
});
|
|
9492
|
+
const { endpoint, tenantId, env: env2 } = ctx;
|
|
9493
|
+
const safety = ctx.environmentSafety ? { ...ctx.environmentSafety } : void 0;
|
|
9494
|
+
assertDangerWrite5(safety, "\u8865\u8DD1\u5F53\u524D\u79DF\u6237\u521D\u59CB\u5316");
|
|
9495
|
+
const accessToken = await HcmClient21.fromAuthContext(ctx).getAccessToken();
|
|
9496
|
+
if (!accessToken) throw new CliError23({
|
|
9497
|
+
code: CliErrorCode24.AUTH_FAILED,
|
|
9498
|
+
message: "\u5F53\u524D\u8EAB\u4EFD\u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u51ED\u636E\uFF0C\u672A\u53D1\u9001\u8865\u8DD1\u3002"
|
|
9499
|
+
});
|
|
9500
|
+
const client3 = new HcmClient21({ endpoint, tenantId, accessToken, profile: env2, environmentSafety: safety });
|
|
9501
|
+
client3.raw().defaults.maxRedirects = 0;
|
|
9502
|
+
client3.raw().defaults.__skipRetry = true;
|
|
9503
|
+
const principal = await readSessionPrincipal3(client3.raw());
|
|
9504
|
+
if (principal.tenantId !== tenantId || tenantId === "__SYSTEM__" || !principal.roles?.includes("admin.system") || principal.impersonated || principal.actSub != null) {
|
|
9505
|
+
throw new CliError23({
|
|
9506
|
+
code: CliErrorCode24.SCOPE_FORBIDDEN,
|
|
9507
|
+
message: "\u5B9E\u9645\u8EAB\u4EFD\u4E0D\u662F\u5F53\u524D\u4E1A\u52A1\u79DF\u6237\u7684\u76F4\u63A5 admin.system \u767B\u5F55\u8EAB\u4EFD\uFF0C\u672A\u53D1\u9001\u8865\u8DD1\u3002",
|
|
9508
|
+
context: { nextStep: "\u7531\u76EE\u6807\u79DF\u6237\u7BA1\u7406\u5458\u6838\u5BF9\u73AF\u5883\u3001\u79DF\u6237\u4E0E\u767B\u5F55\u4F1A\u8BDD\uFF1BAPI Token/OAuth \u59D4\u6258\u7531\u670D\u52A1\u7AEF\u62D2\u7EDD\u3002" }
|
|
9509
|
+
});
|
|
9510
|
+
}
|
|
9511
|
+
process.stderr.write(`\u2192 \u8865\u8DD1\u76EE\u6807 ${client3.endpoint} \xB7 \u73AF\u5883 ${env2} \xB7 \u79DF\u6237 ${tenantId} \xB7 \u7528\u6237 ${principal.username}
|
|
9512
|
+
\u5C06\u5F53\u524D\u79DF\u6237\u5404\u521D\u59CB\u5316\u7EC4\u4EF6\u5BF9\u9F50\u5230\u670D\u52A1\u7AEF\u6700\u65B0 catalog\uFF1B\u53EF\u80FD\u65B0\u589E\u9ED8\u8BA4\u8D44\u6E90\uFF0C\u4FDD\u7559\u89C4\u5219\u4EE5\u5404\u7EC4\u4EF6\u4E3A\u51C6\u3002\u6267\u884C\u524D\u5E94\u6309\u672C\u6B21\u6388\u6743\u4FDD\u5B58\u914D\u7F6E\u57FA\u7EBF\uFF1B\u4E0D\u91CD\u7F6E\u79DF\u6237\uFF0C\u4E0D\u63A5\u53D7\u6307\u5B9A\u79DF\u6237\u6216\u7248\u672C\u3002
|
|
9513
|
+
`);
|
|
9514
|
+
if (!args.yes) {
|
|
9515
|
+
if (!process.stdin.isTTY) throw new CliError23({
|
|
9516
|
+
code: CliErrorCode24.INVALID_ARGUMENT,
|
|
9517
|
+
message: "\u975E\u4EA4\u4E92\u8F93\u5165\u672A\u786E\u8BA4\uFF0C\u672A\u53D1\u9001\u521D\u59CB\u5316\u8865\u8DD1\u3002",
|
|
9518
|
+
context: { nextStep: "\u53D6\u5F97\u672C\u6B21\u76EE\u6807\u3001\u5F71\u54CD\u4E0E\u6062\u590D\u65B9\u6848\u7684\u660E\u786E\u6388\u6743\u540E\u52A0 --yes\uFF1B\u5371\u9669\u73AF\u5883\u8FD8\u9700 --allow-danger\u3002" }
|
|
9519
|
+
});
|
|
9520
|
+
const answer = await promptText("\u786E\u8BA4\u8865\u8DD1\u8FD9\u4E2A\u79DF\u6237\u7684\u521D\u59CB\u5316\uFF1F\u8F93\u5165 yes \u7EE7\u7EED\uFF1A", process.stderr);
|
|
9521
|
+
if (!/^y(es)?$/i.test(answer)) throw new CliError23({
|
|
9522
|
+
code: CliErrorCode24.INVALID_ARGUMENT,
|
|
9523
|
+
message: "\u5DF2\u53D6\u6D88\uFF0C\u672A\u53D1\u9001\u521D\u59CB\u5316\u8865\u8DD1\u3002"
|
|
9524
|
+
});
|
|
9525
|
+
}
|
|
9526
|
+
attempted = true;
|
|
9527
|
+
const reconcile = await reconcileTenant(client3.raw(), tenantId);
|
|
9528
|
+
let verification;
|
|
9529
|
+
if (!reconcile.success || reconcile.error != null || reconcile.results.some((r) => r.status !== "SUCCESS")) {
|
|
9530
|
+
verification = { status: "FAILED", reason: "\u670D\u52A1\u7AEF\u56DE\u6267\u5305\u542B\u672A\u6210\u529F\u7EC4\u4EF6\uFF1B\u672A\u5C06\u90E8\u5206\u6210\u529F\u5F53\u4F5C\u5B8C\u6210\u3002" };
|
|
9531
|
+
} else {
|
|
9532
|
+
try {
|
|
9533
|
+
const report = await bootstrapReport(client3.raw());
|
|
9534
|
+
const value = report;
|
|
9535
|
+
const checks = Array.isArray(value?.results) ? value.results.filter((r) => r?.checkId === "tenant.bootstrap") : [];
|
|
9536
|
+
const verdict = checks.length === 1 ? checks[0]?.verdict : void 0;
|
|
9537
|
+
const coverage = verdict?.coverage;
|
|
9538
|
+
const passed = value?.tenantId === tenantId && checks.length === 1 && verdict?.level === "PASS" && verdict.degraded === false && Array.isArray(verdict.hits) && verdict.hits.length === 0 && coverage?.expected === reconcile.results.length && coverage.evaluated === coverage.expected && coverage.missing === 0 && coverage.failed === 0;
|
|
9539
|
+
verification = {
|
|
9540
|
+
status: passed ? "PASS" : "UNDETERMINED",
|
|
9541
|
+
report,
|
|
9542
|
+
...!passed ? { reason: "\u521D\u59CB\u5316\u590D\u9A8C\u672A\u8BC1\u660E\u5F53\u524D\u79DF\u6237\u5168\u90E8\u7EC4\u4EF6\u901A\u8FC7\uFF1B\u8BF7\u8BFB\u53D6\u539F\u59CB report\uFF0C\u4E0D\u80FD\u5BA3\u79F0\u5B8C\u6210\u3002" } : {}
|
|
9543
|
+
};
|
|
9544
|
+
} catch (error) {
|
|
9545
|
+
const translated = axios4.isAxiosError(error) ? fromAxiosError20(error, env2) : error;
|
|
9546
|
+
verification = { status: "UNDETERMINED", reason: translated instanceof Error ? translated.message : "\u521D\u59CB\u5316\u590D\u9A8C\u5931\u8D25\uFF0C\u539F\u56E0\u672A\u77E5" };
|
|
9547
|
+
}
|
|
9548
|
+
}
|
|
9549
|
+
if (format === "table") {
|
|
9550
|
+
process.stdout.write(`\u79DF\u6237 ${reconcile.tenantId} \xB7 \u8865\u8DD1 success=${reconcile.success} \xB7 \u72EC\u7ACB\u590D\u9A8C ${verification.status}
|
|
9551
|
+
`);
|
|
9552
|
+
for (const r of reconcile.results) process.stdout.write(
|
|
9553
|
+
`${r.component} ${r.fromVersion} \u2192 ${r.toVersion} ${r.status} \u65B0\u589E=${r.created} \u66F4\u65B0=${r.updated} \u5F52\u6863=${r.archived} ${r.message}
|
|
9554
|
+
`
|
|
9555
|
+
);
|
|
9556
|
+
}
|
|
9557
|
+
process.stdout.write(formatObject21({ reconcile, verification }, { format }) + "\n");
|
|
9558
|
+
if (verification.status !== "PASS") process.stderr.write(`${verification.reason}
|
|
9559
|
+
`);
|
|
9560
|
+
const quote2 = (v) => "'" + v.replace(/'/g, "'\\''") + "'";
|
|
9561
|
+
process.stderr.write(`\u4E0B\u4E00\u6B65\uFF1Ahcm chiron doctor --env ${quote2(env2)} --only tenant.bootstrap --output json\uFF1B\u518D\u6838\u5BF9\u539F\u6709\u914D\u7F6E\u3001\u4E1A\u52A1\u6570\u636E\u4E0E\u91CD\u590D\u6267\u884C\u662F\u5426\u96F6\u589E\u6539\u3002\u672C\u6B21\u4E0D\u8BC1\u660E\u5B8C\u6574\u4E0A\u7EBF\u68C0\u67E5\u6216\u4E1A\u52A1\u53D1\u5E03\u901A\u8FC7\u3002
|
|
9562
|
+
`);
|
|
9563
|
+
process.exitCode = verification.status === "PASS" ? 0 : 3;
|
|
9564
|
+
} catch (error) {
|
|
9565
|
+
if (attempted) process.stderr.write("TENANT_RECONCILE_RESULT_UNKNOWN\uFF1A\u5DF2\u5C1D\u8BD5\u4E00\u6B21\u8865\u8DD1\uFF0C\u7ED3\u679C\u672A\u786E\u8BA4\uFF0C\u672A\u81EA\u52A8\u91CD\u53D1\uFF1B\u5148\u53EA\u8BFB\u68C0\u67E5 tenant.bootstrap \u4E0E\u670D\u52A1\u7AEF\u65E5\u5FD7\uFF0C\u4E0D\u8981\u76F2\u76EE\u91CD\u8DD1\u3002\n");
|
|
9566
|
+
exitWithError(axios4.isAxiosError(error) ? fromAxiosError20(error, args.env) : error);
|
|
9567
|
+
}
|
|
9568
|
+
}
|
|
9569
|
+
|
|
9446
9570
|
// src/commands/meta.ts
|
|
9447
9571
|
import { promises as fsp3 } from "fs";
|
|
9448
9572
|
import os4 from "os";
|
|
9449
9573
|
import nodePath from "path";
|
|
9450
9574
|
import {
|
|
9451
|
-
HcmClient as
|
|
9452
|
-
formatObject as
|
|
9453
|
-
fromAxiosError as
|
|
9575
|
+
HcmClient as HcmClient22,
|
|
9576
|
+
formatObject as formatObject22,
|
|
9577
|
+
fromAxiosError as fromAxiosError21,
|
|
9454
9578
|
listTenantMeta,
|
|
9455
9579
|
getTenantMeta,
|
|
9456
9580
|
saveTenantMeta,
|
|
@@ -9460,14 +9584,14 @@ import {
|
|
|
9460
9584
|
formatMetaIssues,
|
|
9461
9585
|
explainJacksonError,
|
|
9462
9586
|
META_SCHEMA_SOURCE_COMMIT,
|
|
9463
|
-
CliError as
|
|
9464
|
-
CliErrorCode as
|
|
9587
|
+
CliError as CliError24,
|
|
9588
|
+
CliErrorCode as CliErrorCode25
|
|
9465
9589
|
} from "@hcmai/sdk";
|
|
9466
9590
|
init_exit();
|
|
9467
9591
|
init_impersonation_lifecycle();
|
|
9468
9592
|
init_auth_guard();
|
|
9469
9593
|
async function client2(args) {
|
|
9470
|
-
return
|
|
9594
|
+
return HcmClient22.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
9471
9595
|
}
|
|
9472
9596
|
function formatMetaForbiddenMessage(mode = "write") {
|
|
9473
9597
|
if (mode === "read") {
|
|
@@ -9482,7 +9606,7 @@ function fail7(e, args, mode = "write") {
|
|
|
9482
9606
|
new Error(formatMetaForbiddenMessage(mode))
|
|
9483
9607
|
);
|
|
9484
9608
|
}
|
|
9485
|
-
if (err?.isAxiosError) exitWithError(
|
|
9609
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError21(err, args.env));
|
|
9486
9610
|
exitWithError(e);
|
|
9487
9611
|
process.exit(1);
|
|
9488
9612
|
}
|
|
@@ -9498,17 +9622,17 @@ async function metaListCommand(args) {
|
|
|
9498
9622
|
const fmt = args.output ?? "json";
|
|
9499
9623
|
if (fmt !== "json") process.stdout.write(`\u{1F4C4} ${items.length} \u4EFD${total ? ` / \u5171 ${total}` : ""}
|
|
9500
9624
|
`);
|
|
9501
|
-
process.stdout.write(
|
|
9625
|
+
process.stdout.write(formatObject22(items, { format: fmt }) + "\n");
|
|
9502
9626
|
process.exitCode = 0;
|
|
9503
9627
|
return;
|
|
9504
9628
|
} catch (e) {
|
|
9505
9629
|
fail7(e, args, "read");
|
|
9506
9630
|
}
|
|
9507
9631
|
}
|
|
9508
|
-
async function metaGetCommand(
|
|
9632
|
+
async function metaGetCommand(path22, args) {
|
|
9509
9633
|
try {
|
|
9510
9634
|
const c2 = await client2(args);
|
|
9511
|
-
const content = await getTenantMeta(c2.raw(),
|
|
9635
|
+
const content = await getTenantMeta(c2.raw(), path22);
|
|
9512
9636
|
process.stdout.write(content.endsWith("\n") ? content : content + "\n");
|
|
9513
9637
|
process.exitCode = 0;
|
|
9514
9638
|
return;
|
|
@@ -9517,8 +9641,8 @@ async function metaGetCommand(path21, args) {
|
|
|
9517
9641
|
}
|
|
9518
9642
|
}
|
|
9519
9643
|
var PROBEABLE_META_TYPES = /* @__PURE__ */ new Set(["model", "list", "info", "view", "filter", "page", "wiz", "impexp"]);
|
|
9520
|
-
function parseMetaPath(
|
|
9521
|
-
const base =
|
|
9644
|
+
function parseMetaPath(path22) {
|
|
9645
|
+
const base = path22.split(/[\\/]/).pop() ?? path22;
|
|
9522
9646
|
if (!/\.(yml|yaml)$/i.test(base)) return {};
|
|
9523
9647
|
const parts = base.replace(/\.(yml|yaml)$/i, "").split(".");
|
|
9524
9648
|
return { model: parts[0] || void 0, kind: parts[1] ?? "model", state: parts[2] };
|
|
@@ -9535,10 +9659,10 @@ function unverifiableReason(e) {
|
|
|
9535
9659
|
if (st == null) return `\u8BF7\u6C42\u6CA1\u53D1\u51FA\u53BB\u6216\u6CA1\u56DE\u6765\uFF08${err.code ?? err.message ?? "\u672A\u77E5"}\uFF09`;
|
|
9536
9660
|
return void 0;
|
|
9537
9661
|
}
|
|
9538
|
-
async function verifyAfterWrite(c2,
|
|
9539
|
-
const { model, kind, state } = parseMetaPath(
|
|
9662
|
+
async function verifyAfterWrite(c2, path22) {
|
|
9663
|
+
const { model, kind, state } = parseMetaPath(path22);
|
|
9540
9664
|
if (!model || !kind) {
|
|
9541
|
-
return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${
|
|
9665
|
+
return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path22} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
|
|
9542
9666
|
}
|
|
9543
9667
|
try {
|
|
9544
9668
|
await clearMetaCache2(c2.raw(), model, {});
|
|
@@ -9583,25 +9707,25 @@ async function verifyAfterWrite(c2, path21) {
|
|
|
9583
9707
|
}
|
|
9584
9708
|
return { status: "ok" };
|
|
9585
9709
|
}
|
|
9586
|
-
async function metaSetCommand(
|
|
9710
|
+
async function metaSetCommand(path22, args) {
|
|
9587
9711
|
try {
|
|
9588
9712
|
if (!args.file) {
|
|
9589
|
-
throw new
|
|
9590
|
-
code:
|
|
9713
|
+
throw new CliError24({
|
|
9714
|
+
code: CliErrorCode25.MISSING_FLAG,
|
|
9591
9715
|
message: "--file <path> \u5FC5\u586B\uFF08\u4ECE\u6587\u4EF6\u8BFB\u53D6 meta \u539F\u6587\uFF1B\u7528 - \u8868\u793A stdin\uFF09"
|
|
9592
9716
|
});
|
|
9593
9717
|
}
|
|
9594
|
-
const content = args.file === "-" ? await new Promise((
|
|
9718
|
+
const content = args.file === "-" ? await new Promise((resolve4, reject) => {
|
|
9595
9719
|
let buf = "";
|
|
9596
9720
|
process.stdin.setEncoding("utf8");
|
|
9597
9721
|
process.stdin.on("data", (d) => buf += d);
|
|
9598
|
-
process.stdin.on("end", () =>
|
|
9722
|
+
process.stdin.on("end", () => resolve4(buf));
|
|
9599
9723
|
process.stdin.on("error", reject);
|
|
9600
9724
|
}) : await fsp3.readFile(args.file, "utf8");
|
|
9601
9725
|
if (!args.skipValidate) {
|
|
9602
|
-
const result2 = validateMetaContent(
|
|
9726
|
+
const result2 = validateMetaContent(path22, content);
|
|
9603
9727
|
if (result2.issues.length > 0) {
|
|
9604
|
-
process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${
|
|
9728
|
+
process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path22}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
|
|
9605
9729
|
`);
|
|
9606
9730
|
process.stderr.write(formatMetaIssues(result2, " ") + "\n");
|
|
9607
9731
|
}
|
|
@@ -9619,14 +9743,14 @@ async function metaSetCommand(path21, args) {
|
|
|
9619
9743
|
const dryFmt = args.output;
|
|
9620
9744
|
if (dryFmt === "json" || dryFmt === "yaml") {
|
|
9621
9745
|
process.stdout.write(
|
|
9622
|
-
|
|
9623
|
-
{ dryRun: true, path:
|
|
9746
|
+
formatObject22(
|
|
9747
|
+
{ dryRun: true, path: path22, bytes: Buffer.byteLength(content), content },
|
|
9624
9748
|
{ format: dryFmt }
|
|
9625
9749
|
) + "\n"
|
|
9626
9750
|
);
|
|
9627
9751
|
} else {
|
|
9628
9752
|
process.stdout.write(
|
|
9629
|
-
`[dry-run] \u5C06\u5199\u5165 ${
|
|
9753
|
+
`[dry-run] \u5C06\u5199\u5165 ${path22}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
|
|
9630
9754
|
---
|
|
9631
9755
|
${content}
|
|
9632
9756
|
`
|
|
@@ -9640,13 +9764,13 @@ ${content}
|
|
|
9640
9764
|
let backupState = "unknown";
|
|
9641
9765
|
let backupWhy;
|
|
9642
9766
|
try {
|
|
9643
|
-
const prev = await getTenantMeta(c2.raw(),
|
|
9767
|
+
const prev = await getTenantMeta(c2.raw(), path22);
|
|
9644
9768
|
if (!prev || prev.trim() === "") {
|
|
9645
9769
|
backupState = "absent";
|
|
9646
9770
|
} else {
|
|
9647
9771
|
backupFile = nodePath.join(
|
|
9648
9772
|
os4.tmpdir(),
|
|
9649
|
-
`hcm-meta-backup-${Date.now()}-${
|
|
9773
|
+
`hcm-meta-backup-${Date.now()}-${path22.replace(/[\\/]/g, "_")}`
|
|
9650
9774
|
);
|
|
9651
9775
|
await fsp3.writeFile(backupFile, prev, "utf8");
|
|
9652
9776
|
backupState = "saved";
|
|
@@ -9661,22 +9785,22 @@ ${content}
|
|
|
9661
9785
|
backupWhy = `HTTP ${st ?? "-"}${err.code ? ` ${err.code}` : ""}${err.message ? `\uFF1A${err.message}` : ""}`;
|
|
9662
9786
|
}
|
|
9663
9787
|
}
|
|
9664
|
-
const result = await saveTenantMeta(c2.raw(),
|
|
9788
|
+
const result = await saveTenantMeta(c2.raw(), path22, content);
|
|
9665
9789
|
const fmt = args.output ?? "json";
|
|
9666
|
-
if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${
|
|
9790
|
+
if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path22}
|
|
9667
9791
|
`);
|
|
9668
9792
|
const restoreHint = backupState === "saved" && backupFile ? ` \u65E7\u5185\u5BB9\u5DF2\u5B58\uFF1A${backupFile}
|
|
9669
|
-
\u653E\u56DE\u53BB\uFF1Ahcm meta set ${
|
|
9670
|
-
` : 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 ${
|
|
9793
|
+
\u653E\u56DE\u53BB\uFF1Ahcm meta set ${path22} --file ${backupFile}${connFlags(args)}
|
|
9794
|
+
` : 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 ${path22}${connFlags(args)}
|
|
9671
9795
|
` : ` \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
|
|
9672
|
-
\u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${
|
|
9796
|
+
\u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path22}${connFlags(args)}
|
|
9673
9797
|
`;
|
|
9674
9798
|
if (args.verify === false) {
|
|
9675
9799
|
process.stderr.write(
|
|
9676
9800
|
"\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
|
|
9677
9801
|
);
|
|
9678
9802
|
} else {
|
|
9679
|
-
const outcome = await verifyAfterWrite(c2,
|
|
9803
|
+
const outcome = await verifyAfterWrite(c2, path22);
|
|
9680
9804
|
if (outcome.status === "broken") {
|
|
9681
9805
|
const human = explainJacksonError(outcome.raw);
|
|
9682
9806
|
process.stderr.write(
|
|
@@ -9702,7 +9826,7 @@ ${content}
|
|
|
9702
9826
|
process.stdout.write(" \u5DF2\u6E05\u5143\u6570\u636E\u7F13\u5B58\uFF0C\u5E76\u771F\u8BFB\u4E86\u4E00\u904D\uFF1A\u670D\u52A1\u7AEF\u8BFB\u5F97\u52A8 \u2714\n");
|
|
9703
9827
|
}
|
|
9704
9828
|
}
|
|
9705
|
-
process.stdout.write(
|
|
9829
|
+
process.stdout.write(formatObject22(result, { format: fmt }) + "\n");
|
|
9706
9830
|
process.exitCode = 0;
|
|
9707
9831
|
return;
|
|
9708
9832
|
} catch (e) {
|
|
@@ -9710,49 +9834,49 @@ ${content}
|
|
|
9710
9834
|
fail7(e, args);
|
|
9711
9835
|
}
|
|
9712
9836
|
}
|
|
9713
|
-
async function metaDeleteCommand(
|
|
9837
|
+
async function metaDeleteCommand(path22, args) {
|
|
9714
9838
|
try {
|
|
9715
9839
|
if (!args.yes) {
|
|
9716
|
-
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${
|
|
9840
|
+
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path22}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
|
|
9717
9841
|
if (!ok) {
|
|
9718
9842
|
process.stderr.write("\u5DF2\u53D6\u6D88\n");
|
|
9719
9843
|
process.exit(1);
|
|
9720
9844
|
}
|
|
9721
9845
|
}
|
|
9722
9846
|
const c2 = await client2(args);
|
|
9723
|
-
const result = await deleteTenantMeta(c2.raw(),
|
|
9847
|
+
const result = await deleteTenantMeta(c2.raw(), path22);
|
|
9724
9848
|
const fmt = args.output ?? "json";
|
|
9725
|
-
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${
|
|
9849
|
+
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path22}
|
|
9726
9850
|
`);
|
|
9727
|
-
process.stdout.write(
|
|
9851
|
+
process.stdout.write(formatObject22(result, { format: fmt }) + "\n");
|
|
9728
9852
|
process.exitCode = 0;
|
|
9729
9853
|
return;
|
|
9730
9854
|
} catch (e) {
|
|
9731
9855
|
fail7(e, args);
|
|
9732
9856
|
}
|
|
9733
9857
|
}
|
|
9734
|
-
async function metaValidateCommand(
|
|
9858
|
+
async function metaValidateCommand(path22, args) {
|
|
9735
9859
|
try {
|
|
9736
9860
|
if (!args.file) {
|
|
9737
|
-
throw new
|
|
9738
|
-
code:
|
|
9861
|
+
throw new CliError24({
|
|
9862
|
+
code: CliErrorCode25.MISSING_FLAG,
|
|
9739
9863
|
message: "--file <path> \u5FC5\u586B\uFF08\u8981\u9A8C\u7684\u90A3\u4EFD\u539F\u6587\uFF1B\u7528 - \u8868\u793A stdin\uFF09"
|
|
9740
9864
|
});
|
|
9741
9865
|
}
|
|
9742
|
-
const content = args.file === "-" ? await new Promise((
|
|
9866
|
+
const content = args.file === "-" ? await new Promise((resolve4, reject) => {
|
|
9743
9867
|
let buf = "";
|
|
9744
9868
|
process.stdin.setEncoding("utf8");
|
|
9745
9869
|
process.stdin.on("data", (d) => buf += d);
|
|
9746
|
-
process.stdin.on("end", () =>
|
|
9870
|
+
process.stdin.on("end", () => resolve4(buf));
|
|
9747
9871
|
process.stdin.on("error", reject);
|
|
9748
9872
|
}) : await fsp3.readFile(args.file, "utf8");
|
|
9749
|
-
const result = validateMetaContent(
|
|
9873
|
+
const result = validateMetaContent(path22, content);
|
|
9750
9874
|
const fmt = args.output ?? "table";
|
|
9751
9875
|
if (fmt === "json" || fmt === "yaml") {
|
|
9752
9876
|
process.stdout.write(
|
|
9753
|
-
|
|
9877
|
+
formatObject22(
|
|
9754
9878
|
{
|
|
9755
|
-
path:
|
|
9879
|
+
path: path22,
|
|
9756
9880
|
kind: result.kind,
|
|
9757
9881
|
schemaKnown: result.schemaKnown,
|
|
9758
9882
|
schemaSourceCommit: META_SCHEMA_SOURCE_COMMIT,
|
|
@@ -9764,7 +9888,7 @@ async function metaValidateCommand(path21, args) {
|
|
|
9764
9888
|
);
|
|
9765
9889
|
} else {
|
|
9766
9890
|
process.stdout.write(
|
|
9767
|
-
`\u{1F50E} ${
|
|
9891
|
+
`\u{1F50E} ${path22}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
|
|
9768
9892
|
`
|
|
9769
9893
|
);
|
|
9770
9894
|
process.stdout.write(
|
|
@@ -9782,8 +9906,8 @@ async function metaValidateCommand(path21, args) {
|
|
|
9782
9906
|
// src/commands/workspace.ts
|
|
9783
9907
|
init_exit();
|
|
9784
9908
|
import * as crypto from "crypto";
|
|
9785
|
-
import * as
|
|
9786
|
-
import * as
|
|
9909
|
+
import * as fs9 from "fs/promises";
|
|
9910
|
+
import * as path10 from "path";
|
|
9787
9911
|
import {
|
|
9788
9912
|
buildMiniPreviewTargets,
|
|
9789
9913
|
buildMiniVerifyAgentReport,
|
|
@@ -9791,10 +9915,10 @@ import {
|
|
|
9791
9915
|
createWorkspaceFile,
|
|
9792
9916
|
deleteWorkspaceFile,
|
|
9793
9917
|
formatMiniVerifyReport,
|
|
9794
|
-
formatObject as
|
|
9918
|
+
formatObject as formatObject24,
|
|
9795
9919
|
formatRows as formatRows6,
|
|
9796
9920
|
getMiniStatus,
|
|
9797
|
-
HcmClient as
|
|
9921
|
+
HcmClient as HcmClient23,
|
|
9798
9922
|
initMiniAppProject,
|
|
9799
9923
|
inferMiniWritableTemplateOptionsFromModel,
|
|
9800
9924
|
listWorkspaceFiles,
|
|
@@ -9809,14 +9933,14 @@ import {
|
|
|
9809
9933
|
validateMiniProject,
|
|
9810
9934
|
validateMetaContent as validateMetaContent2,
|
|
9811
9935
|
validateWorkspaceFiles,
|
|
9812
|
-
fromAxiosError as
|
|
9813
|
-
CliError as
|
|
9814
|
-
CliErrorCode as
|
|
9936
|
+
fromAxiosError as fromAxiosError23,
|
|
9937
|
+
CliError as CliError26,
|
|
9938
|
+
CliErrorCode as CliErrorCode27
|
|
9815
9939
|
} from "@hcmai/sdk";
|
|
9816
9940
|
|
|
9817
9941
|
// src/commands/workspace-push-progress.ts
|
|
9818
9942
|
import { isAxiosError } from "axios";
|
|
9819
|
-
import { CliError as
|
|
9943
|
+
import { CliError as CliError25, CliErrorCode as CliErrorCode26, fromAxiosError as fromAxiosError22 } from "@hcmai/sdk";
|
|
9820
9944
|
var PUSH_DEADLINE_MS = 3e5;
|
|
9821
9945
|
var HEARTBEAT_MS = 1e4;
|
|
9822
9946
|
async function withWorkspacePushProgress(run3, profile) {
|
|
@@ -9844,8 +9968,8 @@ async function withWorkspacePushProgress(run3, profile) {
|
|
|
9844
9968
|
let timer;
|
|
9845
9969
|
const deadline = new Promise((_, reject) => {
|
|
9846
9970
|
timer = setTimeout(() => {
|
|
9847
|
-
failure2 = new
|
|
9848
|
-
code:
|
|
9971
|
+
failure2 = new CliError25({
|
|
9972
|
+
code: CliErrorCode26.TIMEOUT,
|
|
9849
9973
|
message: `workspace push \u6574\u4F53\u671F\u9650\u5DF2\u5230\uFF08300 \u79D2\uFF09\uFF1B\u7B49\u5F85 ${requestLabel()}\u3002\u670D\u52A1\u7AEF\u63D0\u4EA4\u72B6\u6001\u672A\u77E5\u3002`,
|
|
9850
9974
|
traceId: traceId(),
|
|
9851
9975
|
profile,
|
|
@@ -9886,8 +10010,8 @@ async function withWorkspacePushProgress(run3, profile) {
|
|
|
9886
10010
|
return await Promise.race([operation, deadline]);
|
|
9887
10011
|
} catch (error) {
|
|
9888
10012
|
if (!isAxiosError(error)) throw error;
|
|
9889
|
-
const translated =
|
|
9890
|
-
throw new
|
|
10013
|
+
const translated = fromAxiosError22(error, profile);
|
|
10014
|
+
throw new CliError25({
|
|
9891
10015
|
code: translated.code,
|
|
9892
10016
|
message: translated.message,
|
|
9893
10017
|
traceId: translated.traceId,
|
|
@@ -9900,7 +10024,7 @@ async function withWorkspacePushProgress(run3, profile) {
|
|
|
9900
10024
|
} : {},
|
|
9901
10025
|
nextStep: [
|
|
9902
10026
|
translated.context?.nextStep,
|
|
9903
|
-
translated.code ===
|
|
10027
|
+
translated.code === CliErrorCode26.AUTH_FAILED ? `\u5148 hcm login --env ${profile ?? "<\u73AF\u5883>"} --username <\u771F\u5B9E\u767B\u5F55\u8D26\u53F7> --password-stdin\uFF0C\u518D hcm workspace active\uFF1B\u8BA4\u8BC1\u672A\u901A\u8FC7\u4E0D\u80FD\u636E\u6B64\u5224\u65AD\u5DE5\u4F5C\u533A\u5931\u6548\u3002` : void 0,
|
|
9904
10028
|
recovery2
|
|
9905
10029
|
].filter(Boolean).join(" ")
|
|
9906
10030
|
}
|
|
@@ -9941,6 +10065,147 @@ function boolValue(value) {
|
|
|
9941
10065
|
return value === true || value === "true";
|
|
9942
10066
|
}
|
|
9943
10067
|
|
|
10068
|
+
// src/commands/workspace-rebase.ts
|
|
10069
|
+
import * as fs8 from "fs/promises";
|
|
10070
|
+
import * as path9 from "path";
|
|
10071
|
+
import { formatObject as formatObject23 } from "@hcmai/sdk";
|
|
10072
|
+
async function runWorkspaceRebase(workspaceKey, args, connect) {
|
|
10073
|
+
const plan = args.plan && !args.dryRun ? readPlan(JSON.parse(await fs8.readFile(args.plan, "utf8"))) : void 0;
|
|
10074
|
+
const client3 = await connect();
|
|
10075
|
+
const workspaces = await client3.query("TenantExtensionWorkspace", {
|
|
10076
|
+
filter: { workspaceKey },
|
|
10077
|
+
fields: ["id", "workspaceKey"],
|
|
10078
|
+
limit: 2
|
|
10079
|
+
});
|
|
10080
|
+
if (workspaces.rows.length !== 1 || workspaces.rows[0]?.workspaceKey !== workspaceKey || workspaces.total !== void 0 && workspaces.total !== 1) {
|
|
10081
|
+
throw new Error(`workspace ${workspaceKey} \u5FC5\u987B\u5728\u5F53\u524D\u79DF\u6237\u67E5\u8BE2\u5230\u552F\u4E00\u7684\u5F00\u53D1\u7A7A\u95F4\uFF1B\u672A\u6267\u884C rebase\u3002`);
|
|
10082
|
+
}
|
|
10083
|
+
const id = requiredText(workspaces.rows[0].id, "workspace model id");
|
|
10084
|
+
const action = `/api/models/TenantExtensionWorkspace/${encodeURIComponent(id)}/action`;
|
|
10085
|
+
if (plan) {
|
|
10086
|
+
const response2 = await client3.raw().post(`${action}/resolve-conflicts`, { form: plan });
|
|
10087
|
+
const result = actionPayload(response2.data);
|
|
10088
|
+
const expected = new Set(plan.resolutions.map((item) => item.relativePath));
|
|
10089
|
+
if (result.workspaceKey !== workspaceKey || !Array.isArray(result.resolvedPaths) || result.resolvedPaths.length !== expected.size || new Set(result.resolvedPaths).size !== expected.size || result.resolvedPaths.some((item) => typeof item !== "string" || !expected.has(item)) || !nonnegativeInteger(result.remainingConflicts)) {
|
|
10090
|
+
throw new Error("resolve-conflicts \u56DE\u6267\u7F3A\u5931\u6216\u4E0E\u63D0\u4EA4\u8DEF\u5F84\u4E0D\u7B26\uFF1B\u4E0D\u80FD\u786E\u8BA4\u89E3\u51B3\u6210\u529F\uFF0C\u8BF7\u91CD\u65B0\u9884\u89C8\u540E\u6838\u5BF9\u3002");
|
|
10091
|
+
}
|
|
10092
|
+
requiredText(result.baselineHash, "resolve-conflicts baselineHash");
|
|
10093
|
+
writeResult(result, args.output, [
|
|
10094
|
+
`workspace rebase resolved: ${workspaceKey}`,
|
|
10095
|
+
`resolved paths: ${result.resolvedPaths.join(", ")}`,
|
|
10096
|
+
`baselineHash: ${result.baselineHash}`,
|
|
10097
|
+
`remainingConflicts: ${result.remainingConflicts}`,
|
|
10098
|
+
...result.degraded !== void 0 ? [`degraded: ${String(result.degraded)}`] : [],
|
|
10099
|
+
...result.reason !== void 0 ? [`reason: ${String(result.reason)}`] : []
|
|
10100
|
+
]);
|
|
10101
|
+
return;
|
|
10102
|
+
}
|
|
10103
|
+
const response = await client3.raw().get(`${action}/preview-rebase`);
|
|
10104
|
+
const preview = readPreview(actionPayload(response.data), workspaceKey);
|
|
10105
|
+
if (args.plan) {
|
|
10106
|
+
const draft = {
|
|
10107
|
+
planDigest: preview.planDigest,
|
|
10108
|
+
reason: "",
|
|
10109
|
+
resolutions: preview.files.filter((file) => file.conflict).map((file) => ({
|
|
10110
|
+
relativePath: file.relativePath,
|
|
10111
|
+
resolution: "UNRESOLVED",
|
|
10112
|
+
content: file.workspaceContent
|
|
10113
|
+
}))
|
|
10114
|
+
};
|
|
10115
|
+
await fs8.writeFile(path9.resolve(args.plan), JSON.stringify(draft, null, 2) + "\n", { flag: "wx", mode: 384 });
|
|
10116
|
+
process.stderr.write(`\u5DF2\u5199\u89E3\u51B3\u8349\u6848 ${path9.resolve(args.plan)}\u3002\u586B\u5199 reason\uFF0C\u5220\u9664\u6682\u4E0D\u5904\u7406\u7684\u8DEF\u5F84\u884C\uFF1B\u9010\u8DEF\u5F84\u628A UNRESOLVED \u6539\u4E3A TAKE_ACTIVE / MERGED / KEEP_WORKSPACE / DELETE\u3002MERGED \u5FC5\u987B\u586B\u5199 content\uFF08\u7A7A\u4E32\u5408\u6CD5\uFF09\uFF1B\u5176\u4ED6\u9009\u62E9\u4E0D\u4F1A\u63D0\u4EA4\u8349\u6848 content\u3002\u6838\u5BF9\u540E\u6267\u884C hcm workspace rebase --plan <\u6587\u4EF6>\uFF0C\u6CBF\u7528\u672C\u6B21 --workspace/--dir/--env/--as\u3002
|
|
10117
|
+
`);
|
|
10118
|
+
} else {
|
|
10119
|
+
process.stderr.write("\u53EA\u8BFB\u9884\u89C8\u5B8C\u6210\u3002\u53EF\u7528 hcm workspace rebase --dry-run --plan <\u65B0\u6587\u4EF6> \u751F\u6210\u89E3\u51B3\u8349\u6848\uFF1B\u6CBF\u7528\u672C\u6B21 --workspace/--dir/--env/--as\u3002pull \u4E0D\u4F1A\u66F4\u65B0\u670D\u52A1\u7AEF baseline\u3002\n");
|
|
10120
|
+
}
|
|
10121
|
+
writeResult(preview, args.output, [
|
|
10122
|
+
`workspace rebase preview: ${workspaceKey}`,
|
|
10123
|
+
`baselineHash: ${preview.baselineHash}`,
|
|
10124
|
+
`planDigest: ${preview.planDigest}`,
|
|
10125
|
+
`baseContentAvailable: false\uFF08\u57FA\u7EBF\u4EC5\u4FDD\u5B58\u6458\u8981\uFF0C\u672A\u63D0\u4F9B\u57FA\u7EBF\u6B63\u6587\uFF09`,
|
|
10126
|
+
`conflictCount: ${preview.conflictCount}`,
|
|
10127
|
+
...preview.files.map((file) => JSON.stringify(file))
|
|
10128
|
+
]);
|
|
10129
|
+
}
|
|
10130
|
+
function readPlan(value) {
|
|
10131
|
+
const data = record(value, "rebase plan");
|
|
10132
|
+
const planDigest = requiredText(data.planDigest, "planDigest");
|
|
10133
|
+
const reason = requiredText(data.reason, "reason");
|
|
10134
|
+
if (!Array.isArray(data.resolutions) || !data.resolutions.length) {
|
|
10135
|
+
throw new Error("resolutions \u5FC5\u987B\u5305\u542B\u81F3\u5C11\u4E00\u4E2A\u5DF2\u660E\u786E\u5904\u7406\u7684\u8DEF\u5F84\uFF1B\u5220\u9664\u6682\u4E0D\u5904\u7406\u7684\u884C\u3002");
|
|
10136
|
+
}
|
|
10137
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10138
|
+
const resolutions = data.resolutions.map((raw) => {
|
|
10139
|
+
const item = record(raw, "resolution");
|
|
10140
|
+
const relativePath = filePath(item.relativePath);
|
|
10141
|
+
if (seen.has(relativePath)) throw new Error(`resolution \u8DEF\u5F84\u91CD\u590D\uFF1A${relativePath}`);
|
|
10142
|
+
seen.add(relativePath);
|
|
10143
|
+
if (typeof item.resolution !== "string" || !["TAKE_ACTIVE", "MERGED", "KEEP_WORKSPACE", "DELETE"].includes(item.resolution)) {
|
|
10144
|
+
throw new Error(`${relativePath}: resolution \u5FC5\u987B\u660E\u786E\u9009\u62E9 TAKE_ACTIVE / MERGED / KEEP_WORKSPACE / DELETE\uFF1B\u4E0D\u80FD\u63D0\u4EA4 UNRESOLVED\u3002`);
|
|
10145
|
+
}
|
|
10146
|
+
if (item.content !== void 0 && item.content !== null && typeof item.content !== "string") {
|
|
10147
|
+
throw new Error(`${relativePath}: content \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u6216 null\u3002`);
|
|
10148
|
+
}
|
|
10149
|
+
const resolution = item.resolution;
|
|
10150
|
+
if (resolution === "MERGED" && typeof item.content !== "string") {
|
|
10151
|
+
throw new Error(`${relativePath}: MERGED \u5FC5\u987B\u586B\u5199\u5B57\u7B26\u4E32 content\uFF08\u7A7A\u4E32\u5408\u6CD5\uFF09\u3002`);
|
|
10152
|
+
}
|
|
10153
|
+
return { relativePath, resolution, ...resolution === "MERGED" ? { content: item.content } : {} };
|
|
10154
|
+
});
|
|
10155
|
+
return { planDigest, reason, resolutions };
|
|
10156
|
+
}
|
|
10157
|
+
function readPreview(data, workspaceKey) {
|
|
10158
|
+
if (data.workspaceKey !== workspaceKey || data.baseContentAvailable !== false || !Array.isArray(data.files) || !nonnegativeInteger(data.conflictCount)) throw new Error("preview-rebase \u8FD4\u56DE\u65E0\u6548\u7684\u5DE5\u4F5C\u533A\u3001\u57FA\u7EBF\u53EF\u7528\u6027\u6216\u51B2\u7A81\u6E05\u5355\u3002");
|
|
10159
|
+
requiredText(data.baselineHash, "preview-rebase baselineHash");
|
|
10160
|
+
requiredText(data.planDigest, "preview-rebase planDigest");
|
|
10161
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10162
|
+
for (const raw of data.files) {
|
|
10163
|
+
const file = record(raw, "preview-rebase file");
|
|
10164
|
+
const relativePath = filePath(file.relativePath);
|
|
10165
|
+
if (seen.has(relativePath)) throw new Error(`preview-rebase \u8DEF\u5F84\u91CD\u590D\uFF1A${relativePath}`);
|
|
10166
|
+
seen.add(relativePath);
|
|
10167
|
+
for (const key2 of ["baseHash", "activeHash", "workspaceHash"]) {
|
|
10168
|
+
if (file[key2] !== null) requiredText(file[key2], `${relativePath}: ${key2}`);
|
|
10169
|
+
}
|
|
10170
|
+
if (typeof file.workspaceDeleted !== "boolean" || typeof file.conflict !== "boolean" || !nullableText(file.activeContent) || !nullableText(file.workspaceContent)) {
|
|
10171
|
+
throw new Error(`${relativePath}: preview-rebase \u6587\u4EF6\u72B6\u6001\u6216\u6B63\u6587\u7F3A\u5931\u3002`);
|
|
10172
|
+
}
|
|
10173
|
+
}
|
|
10174
|
+
if (data.files.filter((file) => file.conflict).length !== data.conflictCount) {
|
|
10175
|
+
throw new Error("preview-rebase conflictCount \u4E0E\u6587\u4EF6\u6E05\u5355\u4E0D\u4E00\u81F4\uFF0C\u4E0D\u80FD\u751F\u6210\u89E3\u51B3\u8BA1\u5212\u3002");
|
|
10176
|
+
}
|
|
10177
|
+
return data;
|
|
10178
|
+
}
|
|
10179
|
+
function actionPayload(value) {
|
|
10180
|
+
const response = record(value, "workspace action response");
|
|
10181
|
+
if (response.success === false) throw new Error("workspace action \u8FD4\u56DE\u5931\u8D25\uFF1B\u8BF7\u68C0\u67E5\u670D\u52A1\u7AEF\u54CD\u5E94\u540E\u91CD\u8BD5\u3002");
|
|
10182
|
+
return record(response.data ?? response.result ?? response, "workspace action payload");
|
|
10183
|
+
}
|
|
10184
|
+
function record(value, label) {
|
|
10185
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${label} \u5FC5\u987B\u662F\u5BF9\u8C61\u3002`);
|
|
10186
|
+
return value;
|
|
10187
|
+
}
|
|
10188
|
+
function requiredText(value, label) {
|
|
10189
|
+
if (typeof value !== "string" || !value.trim()) throw new Error(`${label} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\u3002`);
|
|
10190
|
+
return value;
|
|
10191
|
+
}
|
|
10192
|
+
function nullableText(value) {
|
|
10193
|
+
return value === null || typeof value === "string";
|
|
10194
|
+
}
|
|
10195
|
+
function nonnegativeInteger(value) {
|
|
10196
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
10197
|
+
}
|
|
10198
|
+
function filePath(value) {
|
|
10199
|
+
const text = requiredText(value, "relativePath");
|
|
10200
|
+
if (path9.isAbsolute(text) || text.includes("\\") || text.includes("\0") || /^[A-Za-z]:/.test(text) || text.split("/").some((part) => !part || part === "." || part === "..")) {
|
|
10201
|
+
throw new Error(`relativePath \u5FC5\u987B\u662F\u5B89\u5168\u7684\u76F8\u5BF9\u6587\u4EF6\u8DEF\u5F84\uFF1A${text}`);
|
|
10202
|
+
}
|
|
10203
|
+
return text;
|
|
10204
|
+
}
|
|
10205
|
+
function writeResult(result, format = "table", lines) {
|
|
10206
|
+
process.stdout.write((format === "table" ? lines.join("\n") : formatObject23(result, { format })) + "\n");
|
|
10207
|
+
}
|
|
10208
|
+
|
|
9944
10209
|
// src/commands/workspace.ts
|
|
9945
10210
|
var DEFAULT_FRONTEND_URL = "http://127.0.0.1:5179";
|
|
9946
10211
|
var WORKSPACE_CONTEXT_FILE = "hcm.workspace.json";
|
|
@@ -9959,7 +10224,7 @@ var RAW_WORKSPACE_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
|
|
|
9959
10224
|
var RAW_WORKSPACE_EXCLUDED_FILES = /* @__PURE__ */ new Set([WORKSPACE_CONTEXT_FILE, ".DS_Store"]);
|
|
9960
10225
|
async function workspaceListCommand(args) {
|
|
9961
10226
|
try {
|
|
9962
|
-
const client3 =
|
|
10227
|
+
const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
9963
10228
|
const limit = parsePositiveInt3(args.limit, 50, "--limit");
|
|
9964
10229
|
const result = await client3.query("TenantExtensionWorkspace", {
|
|
9965
10230
|
keyword: args.keyword,
|
|
@@ -9992,7 +10257,7 @@ async function workspaceActiveCommand(args) {
|
|
|
9992
10257
|
const ctx = await getActiveAuthContextFromCli(args, {
|
|
9993
10258
|
fallbackEnv: localContext?.profile
|
|
9994
10259
|
});
|
|
9995
|
-
const client3 =
|
|
10260
|
+
const client3 = HcmClient23.fromAuthContext(ctx);
|
|
9996
10261
|
const binding = await readWorkspaceDevModeBinding(client3);
|
|
9997
10262
|
const activeWorkspaceKey = binding.enabled ? optionalText(binding.workspaceKey) : null;
|
|
9998
10263
|
const bindingUpdatedAt = typeof binding.updatedAt === "number" && Number.isFinite(binding.updatedAt) && binding.updatedAt > 0 && binding.updatedAt <= 864e13 ? binding.updatedAt : null;
|
|
@@ -10032,7 +10297,7 @@ async function workspaceBindCommand(workspaceKey, args) {
|
|
|
10032
10297
|
tenantId: args.tenant ?? client3?.tenantId,
|
|
10033
10298
|
endpoint: args.endpoint ?? client3?.endpoint
|
|
10034
10299
|
});
|
|
10035
|
-
await
|
|
10300
|
+
await fs9.mkdir(rootDir, { recursive: true });
|
|
10036
10301
|
await writeWorkspaceContext(rootDir, context);
|
|
10037
10302
|
writeWorkspaceBindResult(context, rootDir, args.output ?? "table");
|
|
10038
10303
|
process.exitCode = 0;
|
|
@@ -10050,7 +10315,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
|
|
|
10050
10315
|
`${WORKSPACE_CONTEXT_FILE} already binds workspace '${existing.workspaceKey}'; use --force to rebind`
|
|
10051
10316
|
);
|
|
10052
10317
|
}
|
|
10053
|
-
const client3 =
|
|
10318
|
+
const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
10054
10319
|
const normalizedWorkspaceKey = normalizeWorkspaceKey(workspaceKey);
|
|
10055
10320
|
const resp = await client3.raw().post("/api/models/TenantExtensionWorkspace", {
|
|
10056
10321
|
workspaceKey: normalizedWorkspaceKey,
|
|
@@ -10069,7 +10334,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
|
|
|
10069
10334
|
tenantId: client3.tenantId,
|
|
10070
10335
|
endpoint: client3.endpoint
|
|
10071
10336
|
});
|
|
10072
|
-
await
|
|
10337
|
+
await fs9.mkdir(rootDir, { recursive: true });
|
|
10073
10338
|
await writeWorkspaceContext(rootDir, context);
|
|
10074
10339
|
writeWorkspaceCreateResult(
|
|
10075
10340
|
{
|
|
@@ -10088,6 +10353,18 @@ async function workspaceCreateCommand(workspaceKey, args) {
|
|
|
10088
10353
|
exitWorkspaceError(e, args.env ?? args.profile);
|
|
10089
10354
|
}
|
|
10090
10355
|
}
|
|
10356
|
+
async function workspaceRebaseCommand(args) {
|
|
10357
|
+
try {
|
|
10358
|
+
const existing = await readWorkspaceContext(resolveRootDir(args.dir));
|
|
10359
|
+
const workspaceKey = normalizeWorkspaceKey(args.workspace ?? existing?.workspaceKey ?? "");
|
|
10360
|
+
await runWorkspaceRebase(workspaceKey, args, async () => HcmClient23.fromAuthContext(
|
|
10361
|
+
await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
|
|
10362
|
+
));
|
|
10363
|
+
process.exitCode = 0;
|
|
10364
|
+
} catch (e) {
|
|
10365
|
+
exitWorkspaceError(e, args.env ?? args.profile);
|
|
10366
|
+
}
|
|
10367
|
+
}
|
|
10091
10368
|
async function workspacePullCommand(args) {
|
|
10092
10369
|
try {
|
|
10093
10370
|
const rootDir = resolveRootDir(args.dir);
|
|
@@ -10098,7 +10375,7 @@ async function workspacePullCommand(args) {
|
|
|
10098
10375
|
`workspace key is required; pass --workspace <key> or run hcm workspace bind <key> first`
|
|
10099
10376
|
);
|
|
10100
10377
|
}
|
|
10101
|
-
const client3 =
|
|
10378
|
+
const client3 = HcmClient23.fromAuthContext(
|
|
10102
10379
|
await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
|
|
10103
10380
|
);
|
|
10104
10381
|
const context = buildWorkspaceContext({
|
|
@@ -10107,7 +10384,7 @@ async function workspacePullCommand(args) {
|
|
|
10107
10384
|
tenantId: client3.tenantId ?? existing?.tenantId,
|
|
10108
10385
|
endpoint: client3.endpoint ?? existing?.endpoint
|
|
10109
10386
|
});
|
|
10110
|
-
await
|
|
10387
|
+
await fs9.mkdir(rootDir, { recursive: true });
|
|
10111
10388
|
await writeWorkspaceContext(rootDir, context);
|
|
10112
10389
|
const files = await listWorkspaceFiles(client3.raw(), workspaceKey, { pageSize: 5e3 });
|
|
10113
10390
|
const miniApps = detectRemoteMiniApps(files.data);
|
|
@@ -10117,7 +10394,7 @@ async function workspacePullCommand(args) {
|
|
|
10117
10394
|
http: client3.raw(),
|
|
10118
10395
|
appCode,
|
|
10119
10396
|
workspaceKey,
|
|
10120
|
-
targetDir:
|
|
10397
|
+
targetDir: path10.join(rootDir, MINI_APPS_DIR, appCode),
|
|
10121
10398
|
tenantId: client3.tenantId,
|
|
10122
10399
|
endpoint: client3.endpoint,
|
|
10123
10400
|
profile: args.profile ?? client3.profile,
|
|
@@ -10132,7 +10409,7 @@ async function workspacePullCommand(args) {
|
|
|
10132
10409
|
const rawRemoteByLocalPath = /* @__PURE__ */ new Map();
|
|
10133
10410
|
for (const file of rawFiles) {
|
|
10134
10411
|
const content = await loadWorkspaceFileContent(client3.raw(), file.id);
|
|
10135
|
-
const target =
|
|
10412
|
+
const target = path10.join(rootDir, content.relativePath);
|
|
10136
10413
|
await writeTextFile(target, content.content, !!args.force);
|
|
10137
10414
|
pulledRawFiles.push(content.relativePath);
|
|
10138
10415
|
rawRemoteByLocalPath.set(content.relativePath, file);
|
|
@@ -10183,7 +10460,7 @@ async function workspaceAddMiniCommand(appCode, args) {
|
|
|
10183
10460
|
const result = await initMiniAppProject({
|
|
10184
10461
|
appCode,
|
|
10185
10462
|
workspaceKey: context.workspaceKey,
|
|
10186
|
-
targetDir:
|
|
10463
|
+
targetDir: path10.join(rootDir, MINI_APPS_DIR, appCode),
|
|
10187
10464
|
name: args.name,
|
|
10188
10465
|
runtimeSdkVersion: args.sdkVersion,
|
|
10189
10466
|
defaultSurface: parseSurface(args.surface),
|
|
@@ -10210,10 +10487,10 @@ async function workspaceRmCommand(relativePath, args) {
|
|
|
10210
10487
|
const rootDir = resolveRootDir(args.dir);
|
|
10211
10488
|
const context = await requireWorkspaceContext(rootDir);
|
|
10212
10489
|
const normalized = normalizeWorkspaceRmPath(relativePath);
|
|
10213
|
-
const absolutePath =
|
|
10490
|
+
const absolutePath = path10.join(rootDir, ...normalized.split("/"));
|
|
10214
10491
|
let stat;
|
|
10215
10492
|
try {
|
|
10216
|
-
stat = await
|
|
10493
|
+
stat = await fs9.lstat(absolutePath);
|
|
10217
10494
|
} catch (e) {
|
|
10218
10495
|
if (e.code !== "ENOENT") throw e;
|
|
10219
10496
|
stat = null;
|
|
@@ -10253,7 +10530,7 @@ async function workspaceRmCommand(relativePath, args) {
|
|
|
10253
10530
|
if (!stat) {
|
|
10254
10531
|
if (manifestEntry) {
|
|
10255
10532
|
process.stdout.write(
|
|
10256
|
-
|
|
10533
|
+
formatObject24(
|
|
10257
10534
|
{
|
|
10258
10535
|
workspaceKey: context.workspaceKey,
|
|
10259
10536
|
file: normalized,
|
|
@@ -10269,7 +10546,7 @@ async function workspaceRmCommand(relativePath, args) {
|
|
|
10269
10546
|
}
|
|
10270
10547
|
throw new Error(`workspace file not found locally or in the workspace: ${normalized}`);
|
|
10271
10548
|
}
|
|
10272
|
-
await
|
|
10549
|
+
await fs9.unlink(absolutePath);
|
|
10273
10550
|
const result = {
|
|
10274
10551
|
workspaceKey: context.workspaceKey,
|
|
10275
10552
|
file: normalized,
|
|
@@ -10278,7 +10555,7 @@ async function workspaceRmCommand(relativePath, args) {
|
|
|
10278
10555
|
next: `hcm workspace push --dir ${args.dir ?? "."}`
|
|
10279
10556
|
};
|
|
10280
10557
|
if (args.output === "json" || args.output === "yaml") {
|
|
10281
|
-
process.stdout.write(
|
|
10558
|
+
process.stdout.write(formatObject24(result, { format: args.output }) + "\n");
|
|
10282
10559
|
} else {
|
|
10283
10560
|
process.stdout.write(`workspace file staged for deletion: ${normalized}
|
|
10284
10561
|
`);
|
|
@@ -10325,7 +10602,7 @@ async function workspaceStatusCommand(args) {
|
|
|
10325
10602
|
}
|
|
10326
10603
|
if (args.output === "json" || args.output === "yaml") {
|
|
10327
10604
|
process.stdout.write(
|
|
10328
|
-
|
|
10605
|
+
formatObject24({ rootDir, miniApps: rows2 }, { format: args.output }) + "\n"
|
|
10329
10606
|
);
|
|
10330
10607
|
} else {
|
|
10331
10608
|
process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
|
|
@@ -10341,7 +10618,7 @@ async function workspaceValidateCommand(args) {
|
|
|
10341
10618
|
const rootDir = resolveRootDir(args.dir);
|
|
10342
10619
|
await requireWorkspaceContext(rootDir);
|
|
10343
10620
|
const miniApps = await discoverMiniApps(rootDir);
|
|
10344
|
-
const metaFiles = await readWorkspaceRawLocalFiles(
|
|
10621
|
+
const metaFiles = await readWorkspaceRawLocalFiles(path10.join(rootDir, "metas"));
|
|
10345
10622
|
const metaResults = metaFiles.filter((file) => /\.ya?ml$/i.test(file.localPath)).map((file) => {
|
|
10346
10623
|
const artifact = `meta:metas/${file.localPath}`;
|
|
10347
10624
|
const validation = validateMetaContent2(`metas/${file.localPath}`, file.content);
|
|
@@ -10386,13 +10663,13 @@ async function workspacePushCommand(args) {
|
|
|
10386
10663
|
for (const app of miniApps) {
|
|
10387
10664
|
const validation = await validateMiniProject(app.dir);
|
|
10388
10665
|
if (!validation.valid) {
|
|
10389
|
-
throw new
|
|
10390
|
-
code:
|
|
10666
|
+
throw new CliError26({
|
|
10667
|
+
code: CliErrorCode27.INVALID_ARGUMENT,
|
|
10391
10668
|
message: `mini app ${app.appCode} validation failed: ${validation.errors.join("; ")}`
|
|
10392
10669
|
});
|
|
10393
10670
|
}
|
|
10394
10671
|
}
|
|
10395
|
-
const client3 =
|
|
10672
|
+
const client3 = HcmClient23.fromAuthContext(
|
|
10396
10673
|
await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
|
|
10397
10674
|
);
|
|
10398
10675
|
profile = client3.profile ?? profile;
|
|
@@ -10435,8 +10712,8 @@ async function workspacePushCommand(args) {
|
|
|
10435
10712
|
return;
|
|
10436
10713
|
} catch (e) {
|
|
10437
10714
|
let failure2 = e;
|
|
10438
|
-
if (e instanceof
|
|
10439
|
-
failure2 = new
|
|
10715
|
+
if (e instanceof CliError26 && pushProgress && !e.context?.push) {
|
|
10716
|
+
failure2 = new CliError26({
|
|
10440
10717
|
code: e.code,
|
|
10441
10718
|
message: e.message,
|
|
10442
10719
|
traceId: e.traceId,
|
|
@@ -10473,7 +10750,7 @@ async function workspacePreviewCommand(args) {
|
|
|
10473
10750
|
);
|
|
10474
10751
|
}
|
|
10475
10752
|
if (args.output === "json" || args.output === "yaml") {
|
|
10476
|
-
process.stdout.write(
|
|
10753
|
+
process.stdout.write(formatObject24(rows2, { format: args.output }) + "\n");
|
|
10477
10754
|
} else {
|
|
10478
10755
|
process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
|
|
10479
10756
|
}
|
|
@@ -10591,11 +10868,11 @@ function removedMiniCommand() {
|
|
|
10591
10868
|
);
|
|
10592
10869
|
}
|
|
10593
10870
|
function resolveRootDir(dir) {
|
|
10594
|
-
return
|
|
10871
|
+
return path10.resolve(dir ?? ".");
|
|
10595
10872
|
}
|
|
10596
10873
|
async function workspacePathExists(file) {
|
|
10597
10874
|
try {
|
|
10598
|
-
await
|
|
10875
|
+
await fs9.access(file);
|
|
10599
10876
|
return true;
|
|
10600
10877
|
} catch (e) {
|
|
10601
10878
|
if (e.code === "ENOENT") return false;
|
|
@@ -10603,16 +10880,16 @@ async function workspacePathExists(file) {
|
|
|
10603
10880
|
}
|
|
10604
10881
|
}
|
|
10605
10882
|
async function assertWorkspacePushRoot(rootDir) {
|
|
10606
|
-
const realRoot = await
|
|
10883
|
+
const realRoot = await fs9.realpath(rootDir);
|
|
10607
10884
|
let workspaceRoot;
|
|
10608
10885
|
let insideMiniApp = false;
|
|
10609
10886
|
let dir = realRoot;
|
|
10610
10887
|
for (; ; ) {
|
|
10611
|
-
const parent =
|
|
10612
|
-
const appsDir =
|
|
10613
|
-
const miniDir = appsDir !== void 0 && (await workspacePathExists(
|
|
10888
|
+
const parent = path10.dirname(dir);
|
|
10889
|
+
const appsDir = path10.basename(dir) === MINI_APPS_DIR ? dir : path10.basename(parent) === MINI_APPS_DIR ? parent : void 0;
|
|
10890
|
+
const miniDir = appsDir !== void 0 && (await workspacePathExists(path10.join(path10.dirname(appsDir), WORKSPACE_CONTEXT_FILE)) || appsDir === parent && await workspacePathExists(path10.join(dir, "manifest.json"))) || await workspacePathExists(path10.join(dir, MINI_CONTEXT_FILE)) || await workspacePathExists(path10.join(dir, MINI_STATE_DIR, MINI_PULL_MANIFEST_FILE));
|
|
10614
10891
|
insideMiniApp ||= miniDir;
|
|
10615
|
-
if (!miniDir && await workspacePathExists(
|
|
10892
|
+
if (!miniDir && await workspacePathExists(path10.join(dir, WORKSPACE_CONTEXT_FILE))) {
|
|
10616
10893
|
workspaceRoot = dir;
|
|
10617
10894
|
break;
|
|
10618
10895
|
}
|
|
@@ -10621,8 +10898,8 @@ async function assertWorkspacePushRoot(rootDir) {
|
|
|
10621
10898
|
}
|
|
10622
10899
|
if (!insideMiniApp && (!workspaceRoot || workspaceRoot === realRoot)) return;
|
|
10623
10900
|
const target = workspaceRoot ? quoteWorkspaceArg(workspaceRoot) : "<workspace-root>";
|
|
10624
|
-
throw new
|
|
10625
|
-
code:
|
|
10901
|
+
throw new CliError26({
|
|
10902
|
+
code: CliErrorCode27.INVALID_ARGUMENT,
|
|
10626
10903
|
message: `workspace push \u5FC5\u987B\u4ECE workspace \u6839\u76EE\u5F55\u6267\u884C\uFF0C\u5F53\u524D\u76EE\u5F55 ${rootDir} \u662F${insideMiniApp ? "\u8F7B\u5E94\u7528\u76EE\u5F55\u6216\u5176\u5B50\u76EE\u5F55" : "\u5DE5\u4F5C\u533A\u5B50\u76EE\u5F55"}\uFF1B\u7EE7\u7EED\u4F1A\u8DF3\u8FC7\u8F7B\u5E94\u7528\u90E8\u7F72\u3002`,
|
|
10627
10904
|
context: {
|
|
10628
10905
|
nextStep: `${workspaceRoot ? `workspace \u6839\u76EE\u5F55\uFF1A${workspaceRoot}\u3002` : `\u672A\u627E\u5230\u4E0A\u5C42 ${WORKSPACE_CONTEXT_FILE}\uFF1B\u8BF7\u5148\u5B9A\u4F4D\u5305\u542B mini_apps/ \u7684 workspace \u6839\u76EE\u5F55\u3002`}\u6267\u884C hcm workspace push --dir ${target}\uFF0C\u4FDD\u7559\u539F\u6709 --env/--as \u7B49\u9009\u9879\u3002`
|
|
@@ -10643,7 +10920,7 @@ function buildWorkspaceContext(args) {
|
|
|
10643
10920
|
async function readWorkspaceContext(rootDir) {
|
|
10644
10921
|
try {
|
|
10645
10922
|
const parsed = JSON.parse(
|
|
10646
|
-
await
|
|
10923
|
+
await fs9.readFile(path10.join(rootDir, WORKSPACE_CONTEXT_FILE), "utf-8")
|
|
10647
10924
|
);
|
|
10648
10925
|
if (parsed.kind !== WORKSPACE_CONTEXT_KIND || parsed.version !== WORKSPACE_CONTEXT_VERSION) {
|
|
10649
10926
|
throw new Error(`${WORKSPACE_CONTEXT_FILE} is not an HCM workspace context`);
|
|
@@ -10672,26 +10949,26 @@ async function requireWorkspaceContext(rootDir) {
|
|
|
10672
10949
|
return context;
|
|
10673
10950
|
}
|
|
10674
10951
|
async function writeWorkspaceContext(rootDir, context) {
|
|
10675
|
-
await
|
|
10676
|
-
|
|
10952
|
+
await fs9.writeFile(
|
|
10953
|
+
path10.join(rootDir, WORKSPACE_CONTEXT_FILE),
|
|
10677
10954
|
JSON.stringify(context, null, 2) + "\n"
|
|
10678
10955
|
);
|
|
10679
10956
|
}
|
|
10680
10957
|
async function writeTextFile(file, content, force) {
|
|
10681
10958
|
try {
|
|
10682
|
-
await
|
|
10959
|
+
await fs9.access(file);
|
|
10683
10960
|
if (!force) throw new Error(`${file} already exists; use --force to overwrite`);
|
|
10684
10961
|
} catch (e) {
|
|
10685
10962
|
if (e.code !== "ENOENT") throw e;
|
|
10686
10963
|
}
|
|
10687
|
-
await
|
|
10688
|
-
await
|
|
10964
|
+
await fs9.mkdir(path10.dirname(file), { recursive: true });
|
|
10965
|
+
await fs9.writeFile(file, content);
|
|
10689
10966
|
}
|
|
10690
10967
|
async function readWorkspaceRawManifest(rootDir, context) {
|
|
10691
10968
|
try {
|
|
10692
10969
|
const parsed = JSON.parse(
|
|
10693
|
-
await
|
|
10694
|
-
|
|
10970
|
+
await fs9.readFile(
|
|
10971
|
+
path10.join(rootDir, WORKSPACE_STATE_DIR, WORKSPACE_PULL_MANIFEST_FILE),
|
|
10695
10972
|
"utf-8"
|
|
10696
10973
|
)
|
|
10697
10974
|
);
|
|
@@ -10713,8 +10990,8 @@ async function readWorkspaceRawManifest(rootDir, context) {
|
|
|
10713
10990
|
}
|
|
10714
10991
|
}
|
|
10715
10992
|
async function writeWorkspaceRawState(rootDir, context, files, remoteByLocalPath) {
|
|
10716
|
-
const stateDir =
|
|
10717
|
-
await
|
|
10993
|
+
const stateDir = path10.join(rootDir, WORKSPACE_STATE_DIR);
|
|
10994
|
+
await fs9.mkdir(stateDir, { recursive: true });
|
|
10718
10995
|
const snapshots = files.map(
|
|
10719
10996
|
(file) => ({
|
|
10720
10997
|
localPath: file.localPath,
|
|
@@ -10725,8 +11002,8 @@ async function writeWorkspaceRawState(rootDir, context, files, remoteByLocalPath
|
|
|
10725
11002
|
lastModified: remoteByLocalPath.get(file.localPath)?.lastModified
|
|
10726
11003
|
})
|
|
10727
11004
|
);
|
|
10728
|
-
await
|
|
10729
|
-
|
|
11005
|
+
await fs9.writeFile(
|
|
11006
|
+
path10.join(stateDir, WORKSPACE_PULL_MANIFEST_FILE),
|
|
10730
11007
|
JSON.stringify(
|
|
10731
11008
|
{
|
|
10732
11009
|
version: WORKSPACE_CONTEXT_VERSION,
|
|
@@ -10742,15 +11019,15 @@ async function writeWorkspaceRawState(rootDir, context, files, remoteByLocalPath
|
|
|
10742
11019
|
);
|
|
10743
11020
|
}
|
|
10744
11021
|
async function writeWorkspaceRawManifest(rootDir, manifest2) {
|
|
10745
|
-
const stateDir =
|
|
10746
|
-
await
|
|
10747
|
-
const target =
|
|
11022
|
+
const stateDir = path10.join(rootDir, WORKSPACE_STATE_DIR);
|
|
11023
|
+
await fs9.mkdir(stateDir, { recursive: true });
|
|
11024
|
+
const target = path10.join(stateDir, WORKSPACE_PULL_MANIFEST_FILE);
|
|
10748
11025
|
const temporary = `${target}.${crypto.randomUUID()}.tmp`;
|
|
10749
11026
|
try {
|
|
10750
|
-
await
|
|
10751
|
-
await
|
|
11027
|
+
await fs9.writeFile(temporary, JSON.stringify(manifest2, null, 2) + "\n", { encoding: "utf8", flag: "wx" });
|
|
11028
|
+
await fs9.rename(temporary, target);
|
|
10752
11029
|
} finally {
|
|
10753
|
-
await
|
|
11030
|
+
await fs9.rm(temporary, { force: true });
|
|
10754
11031
|
}
|
|
10755
11032
|
}
|
|
10756
11033
|
async function readWorkspaceRawLocalFiles(rootDir) {
|
|
@@ -10760,10 +11037,10 @@ async function readWorkspaceRawLocalFiles(rootDir) {
|
|
|
10760
11037
|
return files;
|
|
10761
11038
|
}
|
|
10762
11039
|
async function walkWorkspaceRawFiles(rootDir, relativeDir, files) {
|
|
10763
|
-
const absoluteDir =
|
|
11040
|
+
const absoluteDir = path10.join(rootDir, relativeDir);
|
|
10764
11041
|
let entries;
|
|
10765
11042
|
try {
|
|
10766
|
-
entries = await
|
|
11043
|
+
entries = await fs9.readdir(absoluteDir, { withFileTypes: true });
|
|
10767
11044
|
} catch (e) {
|
|
10768
11045
|
if (e.code === "ENOENT") return;
|
|
10769
11046
|
throw e;
|
|
@@ -10771,14 +11048,14 @@ async function walkWorkspaceRawFiles(rootDir, relativeDir, files) {
|
|
|
10771
11048
|
for (const entry of entries) {
|
|
10772
11049
|
if (entry.isDirectory() && RAW_WORKSPACE_EXCLUDED_DIRS.has(entry.name)) continue;
|
|
10773
11050
|
if (entry.isFile() && RAW_WORKSPACE_EXCLUDED_FILES.has(entry.name)) continue;
|
|
10774
|
-
const localPath = normalizeRelativePath(
|
|
10775
|
-
const absolutePath =
|
|
11051
|
+
const localPath = normalizeRelativePath(path10.posix.join(toPosix(relativeDir), entry.name));
|
|
11052
|
+
const absolutePath = path10.join(rootDir, localPath);
|
|
10776
11053
|
if (entry.isDirectory()) {
|
|
10777
11054
|
await walkWorkspaceRawFiles(rootDir, localPath, files);
|
|
10778
11055
|
continue;
|
|
10779
11056
|
}
|
|
10780
11057
|
if (!entry.isFile()) continue;
|
|
10781
|
-
const content = await
|
|
11058
|
+
const content = await fs9.readFile(absolutePath, "utf-8");
|
|
10782
11059
|
files.push({
|
|
10783
11060
|
localPath,
|
|
10784
11061
|
absolutePath,
|
|
@@ -10815,8 +11092,8 @@ async function pushWorkspaceRawFiles(args) {
|
|
|
10815
11092
|
);
|
|
10816
11093
|
if (args.dryRun) return result;
|
|
10817
11094
|
if (result.preflight.status === "failed") {
|
|
10818
|
-
throw new
|
|
10819
|
-
code:
|
|
11095
|
+
throw new CliError26({
|
|
11096
|
+
code: CliErrorCode27.INVALID_ARGUMENT,
|
|
10820
11097
|
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
11098
|
${formatPreflightIssues(result.preflight.issues, " ")}`,
|
|
10822
11099
|
profile: args.profile ?? args.context.profile,
|
|
@@ -10901,29 +11178,29 @@ ${formatPreflightIssues(result.preflight.issues, " ")}`,
|
|
|
10901
11178
|
checkpointSaved
|
|
10902
11179
|
});
|
|
10903
11180
|
} catch (error) {
|
|
10904
|
-
const translated = error?.isAxiosError ?
|
|
11181
|
+
const translated = error?.isAxiosError ? fromAxiosError23(error, args.profile ?? args.context.profile) : error;
|
|
10905
11182
|
const push = progress();
|
|
10906
11183
|
args.onProgress?.(push);
|
|
10907
|
-
throw new
|
|
10908
|
-
code: translated instanceof
|
|
11184
|
+
throw new CliError26({
|
|
11185
|
+
code: translated instanceof CliError26 ? translated.code : CliErrorCode27.INVALID_ARGUMENT,
|
|
10909
11186
|
message: translated instanceof Error ? translated.message : String(translated),
|
|
10910
|
-
traceId: translated instanceof
|
|
10911
|
-
profile: translated instanceof
|
|
11187
|
+
traceId: translated instanceof CliError26 ? translated.traceId : void 0,
|
|
11188
|
+
profile: translated instanceof CliError26 ? translated.profile : args.profile ?? args.context.profile,
|
|
10912
11189
|
cause: error,
|
|
10913
11190
|
context: {
|
|
10914
|
-
...translated instanceof
|
|
11191
|
+
...translated instanceof CliError26 ? translated.context : {},
|
|
10915
11192
|
workspaceKey: args.context.workspaceKey,
|
|
10916
11193
|
push,
|
|
10917
11194
|
details: {
|
|
10918
|
-
serverDetails: translated instanceof
|
|
11195
|
+
serverDetails: translated instanceof CliError26 ? translated.context?.details : void 0,
|
|
10919
11196
|
push
|
|
10920
11197
|
},
|
|
10921
11198
|
note: [
|
|
10922
|
-
translated instanceof
|
|
11199
|
+
translated instanceof CliError26 ? translated.context?.note : void 0,
|
|
10923
11200
|
"\u9010\u6587\u4EF6\u63A8\u9001\u53EF\u80FD\u5DF2\u90E8\u5206\u5199\u5165\uFF1Bcommitted \u662F\u5DF2\u6536\u5230\u6210\u529F\u56DE\u6267\u7684\u6587\u4EF6\uFF0CUNKNOWN \u4E0D\u80FD\u5F53\u4F5C\u672A\u5199\u5165\u3002"
|
|
10924
11201
|
].filter(Boolean).join(" "),
|
|
10925
11202
|
nextStep: [
|
|
10926
|
-
translated instanceof
|
|
11203
|
+
translated instanceof CliError26 ? translated.context?.nextStep : void 0,
|
|
10927
11204
|
"\u5DF2\u786E\u8BA4\u6587\u4EF6\u7684\u8FDB\u5EA6\u9010\u9879\u4FDD\u5B58\uFF1B\u4FEE\u6B63\u5931\u8D25\u6587\u4EF6\u540E\u5148 push --dry-run \u68C0\u67E5\uFF0C\u518D\u666E\u901A push \u7EED\u8DD1\u3002\u5F53\u524D\u5931\u8D25\u9879 checkpointSaved=false \u6216\u63D0\u4EA4\u72B6\u6001 UNKNOWN \u65F6\u987B\u56DE\u8BFB\u6838\u5BF9\uFF1B\u82E5\u6709\u771F\u5B9E\u8FDC\u7AEF\u51B2\u7A81\uFF0C\u5148 pull \u5230\u65B0\u7684\u7A7A\u76EE\u5F55\u6838\u5BF9\u5E76\u5408\u5E76\uFF0C\u7981\u6B62\u5F3A\u5236\u8986\u76D6\u3002"
|
|
10928
11205
|
].filter(Boolean).join(" ")
|
|
10929
11206
|
}
|
|
@@ -10974,7 +11251,7 @@ async function preflightWorkspacePlan(http, workspaceKey, operations, localFiles
|
|
|
10974
11251
|
return { status: "passed", sent, checked: verdict.checked, issues: [] };
|
|
10975
11252
|
} catch (error) {
|
|
10976
11253
|
const status = error?.response?.status;
|
|
10977
|
-
const translated = error?.isAxiosError ?
|
|
11254
|
+
const translated = error?.isAxiosError ? fromAxiosError23(error, profile) : error;
|
|
10978
11255
|
const detail = translated instanceof Error ? translated.message : String(translated);
|
|
10979
11256
|
return {
|
|
10980
11257
|
status: "unavailable",
|
|
@@ -11188,15 +11465,15 @@ function workspaceRawConflict(entry, reason) {
|
|
|
11188
11465
|
};
|
|
11189
11466
|
}
|
|
11190
11467
|
async function discoverMiniApps(rootDir) {
|
|
11191
|
-
const appsRoot =
|
|
11468
|
+
const appsRoot = path10.join(rootDir, MINI_APPS_DIR);
|
|
11192
11469
|
let entries;
|
|
11193
11470
|
try {
|
|
11194
|
-
entries = await
|
|
11471
|
+
entries = await fs9.readdir(appsRoot, { withFileTypes: true });
|
|
11195
11472
|
} catch (e) {
|
|
11196
11473
|
if (e.code === "ENOENT") return [];
|
|
11197
11474
|
throw e;
|
|
11198
11475
|
}
|
|
11199
|
-
return entries.filter((entry) => entry.isDirectory()).map((entry) => ({ appCode: entry.name, dir:
|
|
11476
|
+
return entries.filter((entry) => entry.isDirectory()).map((entry) => ({ appCode: entry.name, dir: path10.join(appsRoot, entry.name) })).sort((a, b) => a.appCode.localeCompare(b.appCode));
|
|
11200
11477
|
}
|
|
11201
11478
|
function detectRemoteMiniApps(files) {
|
|
11202
11479
|
const appCodes = /* @__PURE__ */ new Set();
|
|
@@ -11222,7 +11499,7 @@ async function readMiniStatusSafely(app) {
|
|
|
11222
11499
|
async function loadProfileClient(args) {
|
|
11223
11500
|
try {
|
|
11224
11501
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
11225
|
-
return
|
|
11502
|
+
return HcmClient23.fromAuthContext(ctx);
|
|
11226
11503
|
} catch (e) {
|
|
11227
11504
|
if (args.env || args.profile) throw e;
|
|
11228
11505
|
return null;
|
|
@@ -11339,7 +11616,7 @@ function normalizeWorkspaceKey(value) {
|
|
|
11339
11616
|
return key2;
|
|
11340
11617
|
}
|
|
11341
11618
|
function normalizeWorkspaceRmPath(value) {
|
|
11342
|
-
if (
|
|
11619
|
+
if (path10.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value)) {
|
|
11343
11620
|
throw new Error("workspace rm path must be relative to the bound workspace");
|
|
11344
11621
|
}
|
|
11345
11622
|
const normalized = normalizeRelativePath(value);
|
|
@@ -11361,7 +11638,7 @@ function normalizeRelativePath(value) {
|
|
|
11361
11638
|
return normalized;
|
|
11362
11639
|
}
|
|
11363
11640
|
function toPosix(value) {
|
|
11364
|
-
return value.split(
|
|
11641
|
+
return value.split(path10.sep).join("/");
|
|
11365
11642
|
}
|
|
11366
11643
|
function sha2563(content) {
|
|
11367
11644
|
return crypto.createHash("sha256").update(content, "utf-8").digest("hex");
|
|
@@ -11389,7 +11666,7 @@ function optionalText(value) {
|
|
|
11389
11666
|
}
|
|
11390
11667
|
function writeWorkspaceListResult(rows2, format, total) {
|
|
11391
11668
|
if (format !== "table") {
|
|
11392
|
-
process.stdout.write(
|
|
11669
|
+
process.stdout.write(formatObject24({ rows: rows2, total }, { format }) + "\n");
|
|
11393
11670
|
return;
|
|
11394
11671
|
}
|
|
11395
11672
|
process.stdout.write(formatRows6(toWorkspaceListRows(rows2), { format: "table" }) + "\n");
|
|
@@ -11400,7 +11677,7 @@ function writeWorkspaceListResult(rows2, format, total) {
|
|
|
11400
11677
|
}
|
|
11401
11678
|
function writeWorkspaceActiveResult(view, format) {
|
|
11402
11679
|
if (format !== "table") {
|
|
11403
|
-
process.stdout.write(
|
|
11680
|
+
process.stdout.write(formatObject24(view, { format }) + "\n");
|
|
11404
11681
|
return;
|
|
11405
11682
|
}
|
|
11406
11683
|
const rows2 = [
|
|
@@ -11425,7 +11702,7 @@ function writeWorkspaceActiveResult(view, format) {
|
|
|
11425
11702
|
}
|
|
11426
11703
|
function writeWorkspaceBindResult(context, rootDir, format) {
|
|
11427
11704
|
if (format !== "table") {
|
|
11428
|
-
process.stdout.write(
|
|
11705
|
+
process.stdout.write(formatObject24({ ...context, rootDir }, { format }) + "\n");
|
|
11429
11706
|
return;
|
|
11430
11707
|
}
|
|
11431
11708
|
process.stdout.write(
|
|
@@ -11439,7 +11716,7 @@ function writeWorkspaceBindResult(context, rootDir, format) {
|
|
|
11439
11716
|
}
|
|
11440
11717
|
function writeWorkspaceCreateResult(result, format) {
|
|
11441
11718
|
if (format !== "table") {
|
|
11442
|
-
process.stdout.write(
|
|
11719
|
+
process.stdout.write(formatObject24(result, { format }) + "\n");
|
|
11443
11720
|
return;
|
|
11444
11721
|
}
|
|
11445
11722
|
process.stdout.write(
|
|
@@ -11455,7 +11732,7 @@ function writeWorkspaceCreateResult(result, format) {
|
|
|
11455
11732
|
}
|
|
11456
11733
|
function writeWorkspacePullResult(result, format) {
|
|
11457
11734
|
if (format !== "table") {
|
|
11458
|
-
process.stdout.write(
|
|
11735
|
+
process.stdout.write(formatObject24(result, { format }) + "\n");
|
|
11459
11736
|
return;
|
|
11460
11737
|
}
|
|
11461
11738
|
const lines = [
|
|
@@ -11473,7 +11750,7 @@ function writeWorkspacePullResult(result, format) {
|
|
|
11473
11750
|
}
|
|
11474
11751
|
function writeWorkspaceAddMiniResult(result, rootDir, format) {
|
|
11475
11752
|
if (format !== "table") {
|
|
11476
|
-
process.stdout.write(
|
|
11753
|
+
process.stdout.write(formatObject24({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
|
|
11477
11754
|
return;
|
|
11478
11755
|
}
|
|
11479
11756
|
process.stdout.write(
|
|
@@ -11489,7 +11766,7 @@ function writeWorkspaceAddMiniResult(result, rootDir, format) {
|
|
|
11489
11766
|
function writeWorkspaceValidateResult(results, format) {
|
|
11490
11767
|
if (format !== "table") {
|
|
11491
11768
|
process.stdout.write(
|
|
11492
|
-
|
|
11769
|
+
formatObject24(
|
|
11493
11770
|
results.map((item) => ({ artifact: item.artifact, ...item.result })),
|
|
11494
11771
|
{ format }
|
|
11495
11772
|
) + "\n"
|
|
@@ -11517,7 +11794,7 @@ ${item.artifact}
|
|
|
11517
11794
|
function writeWorkspacePushResult(rawResult, results, format) {
|
|
11518
11795
|
if (format !== "table") {
|
|
11519
11796
|
process.stdout.write(
|
|
11520
|
-
|
|
11797
|
+
formatObject24(
|
|
11521
11798
|
{
|
|
11522
11799
|
// 预检覆盖整份计划(workspace 文件 + 轻应用文件),放在顶层。
|
|
11523
11800
|
preflight: rawResult.preflight ?? null,
|
|
@@ -11582,7 +11859,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
11582
11859
|
const preflight = raw.plan?.preflight ?? null;
|
|
11583
11860
|
if (format === "json") {
|
|
11584
11861
|
process.stdout.write(
|
|
11585
|
-
|
|
11862
|
+
formatObject24(
|
|
11586
11863
|
{
|
|
11587
11864
|
ok,
|
|
11588
11865
|
workspaceKey: context.workspaceKey,
|
|
@@ -11610,7 +11887,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
|
|
|
11610
11887
|
}
|
|
11611
11888
|
if (format !== "table") {
|
|
11612
11889
|
process.stdout.write(
|
|
11613
|
-
|
|
11890
|
+
formatObject24(
|
|
11614
11891
|
{
|
|
11615
11892
|
ok,
|
|
11616
11893
|
workspaceKey: context.workspaceKey,
|
|
@@ -11666,13 +11943,14 @@ function quoteWorkspaceArg(value) {
|
|
|
11666
11943
|
}
|
|
11667
11944
|
function exitWorkspaceError(err, profile, operation) {
|
|
11668
11945
|
const maybeAxios = err;
|
|
11669
|
-
const translated = maybeAxios?.isAxiosError ?
|
|
11670
|
-
if (translated instanceof
|
|
11946
|
+
const translated = maybeAxios?.isAxiosError ? fromAxiosError23(err, profile) : err;
|
|
11947
|
+
if (translated instanceof CliError26 && operation && translated.context?.status === 409 && ["WORKSPACE_REVISION_CONFLICT", "DEPLOY_IN_PROGRESS"].includes(String(translated.context.responseCode))) {
|
|
11671
11948
|
const scope = `${profile ? ` --env ${quoteWorkspaceArg(profile)}` : ""}${operation.as ? ` --as ${quoteWorkspaceArg(operation.as)}` : ""}`;
|
|
11672
11949
|
const active = "hcm workspace active" + scope + (operation.dir ? ` --dir ${quoteWorkspaceArg(operation.dir)}` : "");
|
|
11673
11950
|
const deployment = translated.context.responseCode === "DEPLOY_IN_PROGRESS" ? `\u6709\u53D1\u5E03\u67E5\u8BE2\u6743\u9650\u65F6\uFF0C\u6267\u884C hcm query TenantExtensionRelease --fields id,workspaceKey,deploymentStatus --limit 20${scope} \u67E5\u770B\u53EF\u89C1\u90E8\u7F72\u8BB0\u5F55\uFF1B\u7A7A\u7ED3\u679C\u4E0D\u80FD\u8BC1\u660E\u9501\u5DF2\u91CA\u653E\u3002` : void 0;
|
|
11951
|
+
const rebase = translated.context.responseCode === "WORKSPACE_REVISION_CONFLICT" ? `\u82E5\u670D\u52A1\u7AEF\u8BE6\u60C5\u786E\u8BA4 workspace \u4E0E active \u7684\u4FEE\u8BA2\u51B2\u7A81\uFF0C\u6267\u884C hcm workspace rebase --workspace ${quoteWorkspaceArg(operation.workspaceKey)} --dry-run${scope}\uFF0C\u518D\u7528 --dry-run --plan '<\u65B0\u8BA1\u5212\u6587\u4EF6>' \u751F\u6210\u9010\u8DEF\u5F84\u89E3\u51B3\u8349\u6848\u3002pull \u53EA\u6062\u590D\u672C\u5730\u5FEB\u7167\uFF0C\u4E0D\u66F4\u65B0\u670D\u52A1\u7AEF baseline\uFF1B\u4E0D\u8981\u5220\u9664\u91CD\u5EFA\u6587\u4EF6\u6216\u6574\u4E2A\u5F00\u53D1\u7A7A\u95F4\u6765\u5237\u65B0\u57FA\u7EBF\u3002` : void 0;
|
|
11674
11952
|
const retry = operation.command === "activate" ? `\u6309\u670D\u52A1\u7AEF\u8BE6\u60C5\u5B8C\u6210\u5904\u7406\u5E76\u786E\u8BA4\u76EE\u6807\u5DE5\u4F5C\u533A\u540E\uFF0C\u518D\u6267\u884C hcm workspace activate ${quoteWorkspaceArg(operation.workspaceKey)}${scope}\u3002` : `\u4FDD\u7559\u672C\u5730\u76EE\u5F55 ${operation.dir}\uFF1B\u6267\u884C hcm workspace pull --workspace ${quoteWorkspaceArg(operation.workspaceKey)} --dir '<\u65B0\u7684\u7A7A\u76EE\u5F55>'${scope}\uFF0C\u6BD4\u5BF9\u540E\u628A\u5F85\u4FDD\u7559\u4FEE\u6539\uFF08\u542B\u5220\u9664\u610F\u56FE\uFF09\u5408\u5E76\u5230\u65B0\u76EE\u5F55\uFF0C\u518D\u6267\u884C hcm workspace push --dir '<\u65B0\u7684\u7A7A\u76EE\u5F55>' --dry-run${scope}\uFF0C\u6838\u5BF9\u8BA1\u5212\u540E\u5728\u65B0\u76EE\u5F55\u53BB\u6389 --dry-run \u63A8\u9001\u3002\u539F\u76EE\u5F55\u4FDD\u7559\u5907\u4EFD\uFF0C\u4E0D\u8981\u8986\u76D6\u6216\u7EE7\u7EED\u4F7F\u7528\u65E7\u57FA\u7EBF\u63A8\u9001\u3002`;
|
|
11675
|
-
exitWithError(new
|
|
11953
|
+
exitWithError(new CliError26({
|
|
11676
11954
|
code: translated.code,
|
|
11677
11955
|
message: translated.message,
|
|
11678
11956
|
traceId: translated.traceId,
|
|
@@ -11681,12 +11959,12 @@ function exitWorkspaceError(err, profile, operation) {
|
|
|
11681
11959
|
context: {
|
|
11682
11960
|
...translated.context,
|
|
11683
11961
|
workspaceKey: operation.workspaceKey,
|
|
11684
|
-
nextStep: [translated.context.nextStep, `\u5148\u6267\u884C ${active} \u6838\u5BF9\u5F53\u524D\u8EAB\u4EFD\u7684\u5F00\u53D1\u6001\u7ED1\u5B9A\uFF08\u8BE5\u547D\u4EE4\u4E0D\u67E5\u8BE2\u90E8\u7F72\u8FDB\u5EA6\uFF09\u3002`, deployment, retry].filter(Boolean).join(" ")
|
|
11962
|
+
nextStep: [translated.context.nextStep, `\u5148\u6267\u884C ${active} \u6838\u5BF9\u5F53\u524D\u8EAB\u4EFD\u7684\u5F00\u53D1\u6001\u7ED1\u5B9A\uFF08\u8BE5\u547D\u4EE4\u4E0D\u67E5\u8BE2\u90E8\u7F72\u8FDB\u5EA6\uFF09\u3002`, deployment, rebase, retry].filter(Boolean).join(" ")
|
|
11685
11963
|
}
|
|
11686
11964
|
}));
|
|
11687
11965
|
}
|
|
11688
|
-
if (translated instanceof
|
|
11689
|
-
exitWithError(new
|
|
11966
|
+
if (translated instanceof CliError26 && translated.code === CliErrorCode27.AUTH_FAILED) {
|
|
11967
|
+
exitWithError(new CliError26({
|
|
11690
11968
|
code: translated.code,
|
|
11691
11969
|
message: translated.message,
|
|
11692
11970
|
traceId: translated.traceId,
|
|
@@ -11714,8 +11992,8 @@ async function probeActiveWorkspaceKey(client3) {
|
|
|
11714
11992
|
}
|
|
11715
11993
|
function requireWorkspaceActivation(activeKey, workspaceKey, afterPush = false) {
|
|
11716
11994
|
if (activeKey === workspaceKey) return;
|
|
11717
|
-
throw new
|
|
11718
|
-
code:
|
|
11995
|
+
throw new CliError26({
|
|
11996
|
+
code: CliErrorCode27.INVALID_ARGUMENT,
|
|
11719
11997
|
message: (afterPush ? "\u63A8\u9001\u540E\u7ED1\u5B9A\u5DF2\u53D8\u5316\uFF0C\u6587\u4EF6\u53EF\u80FD\u5DF2\u4FDD\u5B58\u4E3A\u8349\u7A3F\uFF1B" : "") + (activeKey ? `\u5F53\u524D\u8EAB\u4EFD\u6FC0\u6D3B\u7684\u662F "${activeKey}"\uFF0C\u4E0D\u662F\u672C\u7A7A\u95F4 "${workspaceKey}"\uFF1B\u672C\u7A7A\u95F4\u5185\u5BB9\u5C1A\u672A\u7528\u4E8E\u5F00\u53D1\u9884\u89C8\u3002` : `\u5F53\u524D\u8EAB\u4EFD\u672A\u6FC0\u6D3B\u5F00\u53D1\u7A7A\u95F4 "${workspaceKey}"\uFF1B\u672C\u7A7A\u95F4\u5185\u5BB9\u5C1A\u672A\u7528\u4E8E\u5F00\u53D1\u9884\u89C8\u3002`),
|
|
11720
11998
|
context: { workspaceKey, activeWorkspaceKey: activeKey, nextStep: `hcm workspace activate ${workspaceKey}` }
|
|
11721
11999
|
});
|
|
@@ -11752,7 +12030,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
11752
12030
|
let recovery2;
|
|
11753
12031
|
let profile = args.env ?? args.profile;
|
|
11754
12032
|
try {
|
|
11755
|
-
const client3 =
|
|
12033
|
+
const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
11756
12034
|
profile = client3.profile ?? profile;
|
|
11757
12035
|
const key2 = normalizeWorkspaceKey(workspaceKey);
|
|
11758
12036
|
recovery2 = { command: "activate", workspaceKey: key2, as: args.as };
|
|
@@ -11764,7 +12042,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
11764
12042
|
process.stdout.write("\u8BE5\u7A7A\u95F4\u7684 metas / scripts / menus / mini_apps \u73B0\u5DF2\u5728\u5F53\u524D\u79DF\u6237\u751F\u6548\u3002\n");
|
|
11765
12043
|
} else {
|
|
11766
12044
|
process.stdout.write(
|
|
11767
|
-
|
|
12045
|
+
formatObject24({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
|
|
11768
12046
|
);
|
|
11769
12047
|
}
|
|
11770
12048
|
process.exitCode = 0;
|
|
@@ -11775,7 +12053,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
|
|
|
11775
12053
|
}
|
|
11776
12054
|
async function workspaceDeactivateCommand(args) {
|
|
11777
12055
|
try {
|
|
11778
|
-
const client3 =
|
|
12056
|
+
const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
11779
12057
|
const binding = await requestWorkspaceDeactivation(client3);
|
|
11780
12058
|
const result = { ...binding, deactivated: true };
|
|
11781
12059
|
const fmt = args.output ?? "table";
|
|
@@ -11783,7 +12061,7 @@ async function workspaceDeactivateCommand(args) {
|
|
|
11783
12061
|
process.stdout.write("workspace deactivated\n");
|
|
11784
12062
|
process.stdout.write("\u5F53\u524D\u8EAB\u4EFD\u5DF2\u9000\u51FA\u5F00\u53D1\u8005\u6A21\u5F0F\uFF1B\u5F00\u53D1\u7A7A\u95F4\u3001\u672C\u5730\u6587\u4EF6\u4E0E\u5DF2\u53D1\u5E03\u8D44\u4EA7\u5747\u672A\u5220\u9664\u3002\n");
|
|
11785
12063
|
} else {
|
|
11786
|
-
process.stdout.write(
|
|
12064
|
+
process.stdout.write(formatObject24(result, { format: fmt }) + "\n");
|
|
11787
12065
|
}
|
|
11788
12066
|
process.exitCode = 0;
|
|
11789
12067
|
return;
|
|
@@ -11794,14 +12072,14 @@ async function workspaceDeactivateCommand(args) {
|
|
|
11794
12072
|
|
|
11795
12073
|
// src/commands/identity.ts
|
|
11796
12074
|
init_exit();
|
|
11797
|
-
import
|
|
12075
|
+
import axios5 from "axios";
|
|
11798
12076
|
import {
|
|
11799
12077
|
AUTH_INFO_PATH,
|
|
11800
|
-
CliError as
|
|
11801
|
-
CliErrorCode as
|
|
11802
|
-
formatObject as
|
|
12078
|
+
CliError as CliError27,
|
|
12079
|
+
CliErrorCode as CliErrorCode28,
|
|
12080
|
+
formatObject as formatObject25,
|
|
11803
12081
|
formatRows as formatRows7,
|
|
11804
|
-
fromAxiosError as
|
|
12082
|
+
fromAxiosError as fromAxiosError24,
|
|
11805
12083
|
loadEnv as loadEnv4,
|
|
11806
12084
|
saveEnv as saveEnv3,
|
|
11807
12085
|
loadIdentity as loadIdentity4,
|
|
@@ -11814,7 +12092,7 @@ import {
|
|
|
11814
12092
|
toPrincipal
|
|
11815
12093
|
} from "@hcmai/sdk";
|
|
11816
12094
|
var fetchAuthInfo = async (endpoint, accessToken) => {
|
|
11817
|
-
const response = await
|
|
12095
|
+
const response = await axios5.get(`${endpoint.replace(/\/$/, "")}${AUTH_INFO_PATH}`, {
|
|
11818
12096
|
headers: { Authorization: `Bearer ${accessToken}` },
|
|
11819
12097
|
timeout: 3e4
|
|
11820
12098
|
});
|
|
@@ -11825,8 +12103,8 @@ async function inspectIdentity(name, fetcher = fetchAuthInfo) {
|
|
|
11825
12103
|
const env2 = await loadEnv4(meta2.env);
|
|
11826
12104
|
const accessToken = await TokenStore4.forIdentity(name).getStoredAccessToken();
|
|
11827
12105
|
if (!accessToken) {
|
|
11828
|
-
throw new
|
|
11829
|
-
code:
|
|
12106
|
+
throw new CliError27({
|
|
12107
|
+
code: CliErrorCode28.AUTH_FAILED,
|
|
11830
12108
|
message: `identity '${name}' \u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u6301\u4E45\u5316 token`,
|
|
11831
12109
|
context: { nextStep: `\u91CD\u65B0\u767B\u5F55\u8BE5\u8EAB\u4EFD\uFF1Ahcm login --env ${meta2.env} --name ${name}` }
|
|
11832
12110
|
});
|
|
@@ -11854,9 +12132,9 @@ async function inspectIdentity(name, fetcher = fetchAuthInfo) {
|
|
|
11854
12132
|
async function identityShow(name, args) {
|
|
11855
12133
|
try {
|
|
11856
12134
|
const details = await inspectIdentity(name);
|
|
11857
|
-
return exitOk(
|
|
12135
|
+
return exitOk(formatObject25(details, { format: args.output ?? "json" }));
|
|
11858
12136
|
} catch (e) {
|
|
11859
|
-
exitWithError(
|
|
12137
|
+
exitWithError(axios5.isAxiosError(e) ? fromAxiosError24(e, name) : e);
|
|
11860
12138
|
}
|
|
11861
12139
|
}
|
|
11862
12140
|
async function identityList(args) {
|
|
@@ -11866,7 +12144,7 @@ async function identityList(args) {
|
|
|
11866
12144
|
const names = await listIdentities4(filter);
|
|
11867
12145
|
const fmt = args.output ?? "table";
|
|
11868
12146
|
if (names.length === 0) {
|
|
11869
|
-
return exitOk(fmt === "table" ? "(no identities)" :
|
|
12147
|
+
return exitOk(fmt === "table" ? "(no identities)" : formatObject25([], { format: fmt }));
|
|
11870
12148
|
}
|
|
11871
12149
|
const rows2 = [];
|
|
11872
12150
|
for (const n of names) {
|
|
@@ -11880,7 +12158,7 @@ async function identityList(args) {
|
|
|
11880
12158
|
isDefault: env2?.defaultIdentity === n
|
|
11881
12159
|
});
|
|
11882
12160
|
}
|
|
11883
|
-
return exitOk(fmt === "table" ? formatRows7(rows2, { format: fmt }) :
|
|
12161
|
+
return exitOk(fmt === "table" ? formatRows7(rows2, { format: fmt }) : formatObject25(rows2, { format: fmt }));
|
|
11884
12162
|
} catch (e) {
|
|
11885
12163
|
exitWithError(e);
|
|
11886
12164
|
}
|
|
@@ -11889,8 +12167,8 @@ async function identityUse(name) {
|
|
|
11889
12167
|
try {
|
|
11890
12168
|
const meta2 = await loadIdentity4(name);
|
|
11891
12169
|
const env2 = await loadEnv4(meta2.env).catch(() => {
|
|
11892
|
-
throw new
|
|
11893
|
-
code:
|
|
12170
|
+
throw new CliError27({
|
|
12171
|
+
code: CliErrorCode28.IDENTITY_NOT_IN_ENV,
|
|
11894
12172
|
message: `identity '${name}' references env '${meta2.env}' which no longer exists. Re-create the env, or remove this orphan: hcm identity remove ${name}`
|
|
11895
12173
|
});
|
|
11896
12174
|
});
|
|
@@ -11927,14 +12205,14 @@ async function identityRemove(name) {
|
|
|
11927
12205
|
// src/commands/chiron-init.ts
|
|
11928
12206
|
init_auth_guard();
|
|
11929
12207
|
init_exit();
|
|
11930
|
-
import { promises as
|
|
11931
|
-
import
|
|
12208
|
+
import { promises as fs10 } from "fs";
|
|
12209
|
+
import path11 from "path";
|
|
11932
12210
|
import {
|
|
11933
|
-
CliError as
|
|
11934
|
-
CliErrorCode as
|
|
11935
|
-
HcmClient as
|
|
12211
|
+
CliError as CliError28,
|
|
12212
|
+
CliErrorCode as CliErrorCode29,
|
|
12213
|
+
HcmClient as HcmClient24,
|
|
11936
12214
|
fetchReconIdentity,
|
|
11937
|
-
formatObject as
|
|
12215
|
+
formatObject as formatObject26,
|
|
11938
12216
|
httpProbe,
|
|
11939
12217
|
isTempEnv as isTempEnv3,
|
|
11940
12218
|
assertNotReservedEnvName as assertNotReservedEnvName2,
|
|
@@ -11947,7 +12225,7 @@ import {
|
|
|
11947
12225
|
} from "@hcmai/sdk";
|
|
11948
12226
|
async function probeTokenTenant(envName, requested) {
|
|
11949
12227
|
const ctx = await getActiveAuthContextFromCli({ env: envName });
|
|
11950
|
-
const client3 =
|
|
12228
|
+
const client3 = HcmClient24.fromAuthContext(ctx);
|
|
11951
12229
|
const identity3 = await fetchReconIdentity(httpProbe(client3.raw(), "default"), requested);
|
|
11952
12230
|
return identity3?.tenantId ? String(identity3.tenantId) : void 0;
|
|
11953
12231
|
}
|
|
@@ -11989,11 +12267,11 @@ async function resolveInitEnv(root, args, deps) {
|
|
|
11989
12267
|
};
|
|
11990
12268
|
}
|
|
11991
12269
|
const existing = await discoverProjectEnv5(root);
|
|
11992
|
-
if (existing &&
|
|
12270
|
+
if (existing && path11.dirname(existing.path) === path11.resolve(root)) {
|
|
11993
12271
|
const name2 = args.env ?? existing.config.default;
|
|
11994
12272
|
const env2 = existing.config.environments[name2];
|
|
11995
|
-
if (!env2) throw new
|
|
11996
|
-
code:
|
|
12273
|
+
if (!env2) throw new CliError28({
|
|
12274
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
11997
12275
|
message: `${existing.path} \u91CC\u6CA1\u6709\u73AF\u5883 '${name2}'\uFF0C\u53EA\u6709\uFF1A${Object.keys(existing.config.environments).join("\u3001")}`,
|
|
11998
12276
|
// env add 的 endpoint / frontend / tenant 都是必填,少一个照抄就是 required option 报错。
|
|
11999
12277
|
context: { nextStep: `hcm chiron env add ${name2} --endpoint <\u540E\u7AEF\u5730\u5740> --frontend <\u524D\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>` }
|
|
@@ -12003,8 +12281,8 @@ async function resolveInitEnv(root, args, deps) {
|
|
|
12003
12281
|
}
|
|
12004
12282
|
if (args.env) {
|
|
12005
12283
|
const config3 = await loadEnv5(args.env).catch(() => null);
|
|
12006
|
-
if (!config3?.endpoint) throw new
|
|
12007
|
-
code:
|
|
12284
|
+
if (!config3?.endpoint) throw new CliError28({
|
|
12285
|
+
code: CliErrorCode29.ENV_NOT_FOUND,
|
|
12008
12286
|
message: `\u672C\u673A\u6CA1\u6709\u540D\u53EB '${args.env}' \u7684\u73AF\u5883\u3002`,
|
|
12009
12287
|
context: { nextStep: "`hcm env list` \u770B\u6709\u54EA\u4E9B\uFF1B\u6216\u5B8C\u5168\u663E\u5F0F\u5730\u5EFA\uFF1A`hcm chiron init --endpoint <\u540E\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>`" }
|
|
12010
12288
|
});
|
|
@@ -12014,14 +12292,14 @@ async function resolveInitEnv(root, args, deps) {
|
|
|
12014
12292
|
const name = g.activeEnv;
|
|
12015
12293
|
const config2 = name ? await loadEnv5(name).catch(() => null) : null;
|
|
12016
12294
|
const explicitPaths = " hcm chiron init --env <\u672C\u673A\u73AF\u5883\u540D>\uFF08hcm env list \u770B\u6709\u54EA\u4E9B\uFF09\n hcm chiron init --endpoint <\u540E\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>\uFF08\u5B8C\u5168\u663E\u5F0F\uFF0C\u4E0D\u9700\u8981\u5148\u767B\u5F55\uFF09";
|
|
12017
|
-
if (!config2?.endpoint) throw new
|
|
12018
|
-
code:
|
|
12295
|
+
if (!config2?.endpoint) throw new CliError28({
|
|
12296
|
+
code: CliErrorCode29.ENV_NOT_FOUND,
|
|
12019
12297
|
message: "\u6CA1\u8BF4\u8FD9\u4E2A\u9879\u76EE\u5BF9\u7740\u54EA\u4E2A\u73AF\u5883\uFF0C\u672C\u673A\u4E5F\u6CA1\u6709\u53EF\u7528\u7684\u6D3B\u52A8\u73AF\u5883\u3002",
|
|
12020
12298
|
context: { nextStep: `\u4E8C\u9009\u4E00\uFF1A
|
|
12021
12299
|
${explicitPaths}` }
|
|
12022
12300
|
});
|
|
12023
|
-
if (isTempEnv3(name)) throw new
|
|
12024
|
-
code:
|
|
12301
|
+
if (isTempEnv3(name)) throw new CliError28({
|
|
12302
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12025
12303
|
message: `\u672C\u673A\u6D3B\u52A8\u73AF\u5883\u662F\u4E34\u65F6\u7684\uFF08${config2.endpoint}\uFF09\uFF0C\u8FD8\u6CA1\u6709\u540D\u5B57\u3002\u9879\u76EE\u8981\u7ED1\u4E00\u4E2A\u7A33\u5B9A\u7684\u73AF\u5883\uFF0C\u5426\u5219\u4E0B\u4E00\u6B21 hcm login --code \u8986\u76D6\u5B83\u4E4B\u540E\uFF0C\u4ED3\u91CC\u8BB0\u7684\u5C31\u5BF9\u4E0D\u4E0A\u4E86\u3002`,
|
|
12026
12304
|
context: { nextStep: `\u5148\u7ED9\u5B83\u8D77\u4E2A\u540D\u5B57\uFF1Ahcm env save <name>\uFF1B\u6216\u76F4\u63A5\u663E\u5F0F\u5EFA\uFF1A
|
|
12027
12305
|
${explicitPaths}` }
|
|
@@ -12029,8 +12307,8 @@ ${explicitPaths}` }
|
|
|
12029
12307
|
const summary = `${name} \xB7 ${config2.endpoint} \xB7 \u79DF\u6237 ${config2.tenantId ?? "1"}`;
|
|
12030
12308
|
if (!args.yes) {
|
|
12031
12309
|
const ok = deps.isTty() && deps.confirm ? await deps.confirm(`\u6CA1\u6307\u5B9A\u73AF\u5883\uFF0C\u7528\u672C\u673A\u5F53\u524D\u6D3B\u52A8\u7684 ${summary} \u5417\uFF1F[y/N] `) : false;
|
|
12032
|
-
if (!ok) throw new
|
|
12033
|
-
code:
|
|
12310
|
+
if (!ok) throw new CliError28({
|
|
12311
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12034
12312
|
message: `\u6CA1\u786E\u8BA4\u8981\u7528\u672C\u673A\u6D3B\u52A8\u73AF\u5883\uFF08${summary}\uFF09\u3002\u9879\u76EE\u73AF\u5883\u4F1A\u63D0\u4EA4\u8FDB\u4ED3\u3001\u5F71\u54CD\u6240\u6709\u534F\u4F5C\u8005\uFF0C\u4E0D\u9760\u4E0A\u4E00\u6761\u547D\u4EE4\u7684\u526F\u4F5C\u7528\u51B3\u5B9A\u3002`,
|
|
12035
12313
|
context: { nextStep: `\u786E\u8BA4\u5C31\u52A0 --yes\uFF1B\u6216\u660E\u8BF4\uFF1A
|
|
12036
12314
|
${explicitPaths}` }
|
|
@@ -12040,63 +12318,63 @@ ${explicitPaths}` }
|
|
|
12040
12318
|
}
|
|
12041
12319
|
async function scaffoldChironProject(root, env2, envName) {
|
|
12042
12320
|
const result = { created: [], updated: [], preserved: [] };
|
|
12043
|
-
const envFile =
|
|
12044
|
-
const existing = await
|
|
12321
|
+
const envFile = path11.join(root, ENV_FILE);
|
|
12322
|
+
const existing = await fs10.readFile(envFile, "utf8").catch(() => null);
|
|
12045
12323
|
if (existing !== null) {
|
|
12046
12324
|
const document2 = parseEnvYaml(existing);
|
|
12047
12325
|
const recorded = Object.values(document2.environments).find((candidate) => candidate.endpoint === env2.endpoint && candidate.tenant === env2.tenant) ?? document2.environments[document2.default];
|
|
12048
12326
|
if (recorded.endpoint !== env2.endpoint) {
|
|
12049
|
-
throw new
|
|
12050
|
-
code:
|
|
12327
|
+
throw new CliError28({
|
|
12328
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12051
12329
|
message: `${ENV_FILE} \u6307\u5411 ${recorded.endpoint}\uFF0C\u800C\u4F60\u5F53\u524D\u767B\u5F55\u7684\u662F ${env2.endpoint}\uFF08env '${envName}'\uFF09\u3002
|
|
12052
12330
|
\u8981\u7528\u8FD9\u4E2A\u9879\u76EE\u7684\u73AF\u5883\uFF1Ahcm login ${recorded.endpoint} --code <\u914D\u5BF9\u7801>\uFF0C\u518D\u91CD\u8DD1 hcm chiron init
|
|
12053
12331
|
\u8981\u628A\u9879\u76EE\u6539\u5230\u4F60\u767B\u5F55\u7684\u73AF\u5883\uFF1A\u5220\u6389 ${ENV_FILE} \u540E\u91CD\u8DD1\uFF08\u8FD9\u4F1A\u5F71\u54CD\u6240\u6709\u534F\u4F5C\u8005\uFF0C\u5148\u8DDF\u8D1F\u8D23\u4EBA\u786E\u8BA4\uFF09`
|
|
12054
12332
|
});
|
|
12055
12333
|
}
|
|
12056
12334
|
if (recorded.tenant !== env2.tenant) {
|
|
12057
|
-
throw new
|
|
12058
|
-
code:
|
|
12335
|
+
throw new CliError28({
|
|
12336
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12059
12337
|
message: `${ENV_FILE} \u662F\u79DF\u6237 ${recorded.tenant}\uFF0C\u800C\u4F60\u767B\u5F55\u7684\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${env2.tenant}\u3002
|
|
12060
12338
|
\u7528\u9879\u76EE\u79DF\u6237\u7684\u914D\u5BF9\u7801\u91CD\u65B0\u767B\u5F55\uFF1Ahcm login ${env2.endpoint} --code <\u914D\u5BF9\u7801>\uFF0C\u518D\u91CD\u8DD1 hcm chiron init`
|
|
12061
12339
|
});
|
|
12062
12340
|
}
|
|
12063
12341
|
result.preserved.push(ENV_FILE);
|
|
12064
12342
|
} else {
|
|
12065
|
-
if (!envName.trim() || envName.trim() !== envName) throw new
|
|
12066
|
-
code:
|
|
12343
|
+
if (!envName.trim() || envName.trim() !== envName) throw new CliError28({
|
|
12344
|
+
code: CliErrorCode29.INVALID_ARGUMENT,
|
|
12067
12345
|
message: `\u73AF\u5883\u540D '${envName}' \u4E0D\u80FD\u5199\u5165 ${ENV_FILE}\uFF1A\u73AF\u5883\u540D\u5FC5\u987B\u975E\u7A7A\u4E14\u4E0D\u80FD\u542B\u9996\u5C3E\u7A7A\u767D\u3002`,
|
|
12068
12346
|
context: { nextStep: "\u6362\u4E00\u4E2A\u6CA1\u6709\u9996\u5C3E\u7A7A\u767D\u7684\u73AF\u5883\u540D\uFF0C\u518D\u8FD0\u884C hcm chiron init --env <\u73AF\u5883\u540D>\uFF08\u6216 hcm chiron init --endpoint <\u540E\u7AEF\u5730\u5740> --env <\u73AF\u5883\u540D>\uFF09" }
|
|
12069
12347
|
});
|
|
12070
12348
|
assertNotReservedEnvName2(envName);
|
|
12071
|
-
await
|
|
12349
|
+
await fs10.writeFile(
|
|
12072
12350
|
envFile,
|
|
12073
12351
|
renderEnvYaml({ default: envName, environments: { [envName]: env2 } }),
|
|
12074
12352
|
{ encoding: "utf8", mode: 420, flag: "wx" }
|
|
12075
12353
|
);
|
|
12076
12354
|
try {
|
|
12077
|
-
const written = parseEnvYaml(await
|
|
12355
|
+
const written = parseEnvYaml(await fs10.readFile(envFile, "utf8"));
|
|
12078
12356
|
if (written.default !== envName || Object.keys(written.environments).length !== 1 || !Object.hasOwn(written.environments, envName)) {
|
|
12079
|
-
throw new
|
|
12080
|
-
code:
|
|
12357
|
+
throw new CliError28({
|
|
12358
|
+
code: CliErrorCode29.CONFIG_PARSE_ERROR,
|
|
12081
12359
|
message: `${ENV_FILE} \u5199\u5165\u540E\u73AF\u5883\u540D\u4E0E\u56DE\u6267 '${envName}' \u4E0D\u4E00\u81F4\u3002`,
|
|
12082
12360
|
context: { nextStep: `\u6838\u5BF9 ${ENV_FILE} \u7684 default \u4E0E environments \u952E\uFF0C\u518D\u91CD\u8DD1 hcm chiron init` }
|
|
12083
12361
|
});
|
|
12084
12362
|
}
|
|
12085
12363
|
} catch (error) {
|
|
12086
|
-
await
|
|
12364
|
+
await fs10.rm(envFile);
|
|
12087
12365
|
throw error;
|
|
12088
12366
|
}
|
|
12089
12367
|
result.created.push(ENV_FILE);
|
|
12090
12368
|
}
|
|
12091
12369
|
for (const directory of CHIRON_PROJECT_DIRECTORIES) {
|
|
12092
|
-
const absolute =
|
|
12370
|
+
const absolute = path11.join(root, directory);
|
|
12093
12371
|
await ensureDirectory(absolute);
|
|
12094
|
-
await writeIfAbsent(
|
|
12372
|
+
await writeIfAbsent(path11.join(absolute, ".gitkeep"), "", result, `${directory}/.gitkeep`);
|
|
12095
12373
|
}
|
|
12096
12374
|
return result;
|
|
12097
12375
|
}
|
|
12098
12376
|
async function runChironInit(args, deps = defaultChironInitDeps) {
|
|
12099
|
-
const root =
|
|
12377
|
+
const root = path11.resolve(args.project ?? ".");
|
|
12100
12378
|
const say = (line) => process.stderr.write(`[chiron init] ${line}
|
|
12101
12379
|
`);
|
|
12102
12380
|
const choice = await resolveInitEnv(root, args, deps);
|
|
@@ -12155,7 +12433,7 @@ async function chironInitCommand(args, deps) {
|
|
|
12155
12433
|
const result = await runChironInit(args, deps);
|
|
12156
12434
|
const fmt = args.output ?? "table";
|
|
12157
12435
|
if (fmt === "json" || fmt === "yaml") {
|
|
12158
|
-
process.stdout.write(
|
|
12436
|
+
process.stdout.write(formatObject26(result, { format: fmt }) + "\n");
|
|
12159
12437
|
} else {
|
|
12160
12438
|
const mark = { verified: "\u2705", mismatch: "\u274C", unreachable: "\u26A0\uFE0F", skipped: "\xB7" }[result.tenantCheck.status];
|
|
12161
12439
|
process.stdout.write(
|
|
@@ -12177,9 +12455,9 @@ async function chironInitCommand(args, deps) {
|
|
|
12177
12455
|
// src/commands/gap.ts
|
|
12178
12456
|
import { readFileSync as readFileSync6 } from "fs";
|
|
12179
12457
|
import {
|
|
12180
|
-
CliErrorCode as
|
|
12458
|
+
CliErrorCode as CliErrorCode31,
|
|
12181
12459
|
createHttpClient as createHttpClient4,
|
|
12182
|
-
formatObject as
|
|
12460
|
+
formatObject as formatObject27,
|
|
12183
12461
|
loadGlobalConfig as loadGlobalConfig10,
|
|
12184
12462
|
resolveEnvContext as resolveEnvContext7,
|
|
12185
12463
|
printResolvedEnvironment as printResolvedEnvironment7,
|
|
@@ -12579,8 +12857,8 @@ async function gapComments({ client: client3 }, ref, { limit } = {}, casesSlug =
|
|
|
12579
12857
|
// src/jira/gap-verify.ts
|
|
12580
12858
|
import {
|
|
12581
12859
|
CASES_REPO_SLUG as CASES_REPO_SLUG3,
|
|
12582
|
-
CliError as
|
|
12583
|
-
CliErrorCode as
|
|
12860
|
+
CliError as CliError29,
|
|
12861
|
+
CliErrorCode as CliErrorCode30,
|
|
12584
12862
|
JiraHttpError,
|
|
12585
12863
|
JiraNonBmpContentError,
|
|
12586
12864
|
NON_BMP_RULE_NOTE,
|
|
@@ -12601,14 +12879,14 @@ var VERIFY_PLAN = {
|
|
|
12601
12879
|
function parseVerifyResult(raw) {
|
|
12602
12880
|
const v = String(raw ?? "").trim().toLowerCase();
|
|
12603
12881
|
if (VERIFY_RESULTS.includes(v)) return v;
|
|
12604
|
-
throw new
|
|
12605
|
-
code: raw === void 0 ?
|
|
12882
|
+
throw new CliError29({
|
|
12883
|
+
code: raw === void 0 ? CliErrorCode30.MISSING_FLAG : CliErrorCode30.INVALID_ARGUMENT,
|
|
12606
12884
|
message: `--result \u53EA\u80FD\u662F pass / fail / partial\uFF0C\u7ED9\u7684\u662F\u300C${raw ?? "\uFF08\u6CA1\u7ED9\uFF09"}\u300D`,
|
|
12607
12885
|
context: { nextStep: "pass = \u539F\u6545\u969C\u5728\u76EE\u6807\u73AF\u5883\u4E0D\u518D\u51FA\u73B0\uFF1Bfail = \u4ECD\u7136\u590D\u73B0\u6216\u9A8C\u51FA\u6CA1\u901A\u8FC7\u7684\uFF1Bpartial = \u53EA\u9A8C\u4E86\u4E00\u90E8\u5206\u3001\u9A8C\u8FC7\u7684\u90FD\u901A\u8FC7\uFF08\u4E0D\u5173\u5355\uFF09\u3002" }
|
|
12608
12886
|
});
|
|
12609
12887
|
}
|
|
12610
12888
|
function verifyFailure(reasonCode, code2, written, message, nextStep, extra = {}, cause) {
|
|
12611
|
-
return new
|
|
12889
|
+
return new CliError29({ code: code2, message: `${message}${WRITTEN_TAG[written]}`, context: { reasonCode, written, nextStep, ...extra }, cause });
|
|
12612
12890
|
}
|
|
12613
12891
|
function who(u) {
|
|
12614
12892
|
if (!u) return "\uFF08\u5355\u4E0A\u6CA1\u6709\uFF09";
|
|
@@ -12696,7 +12974,7 @@ function writeFailure(e, key2, what) {
|
|
|
12696
12974
|
if (e instanceof JiraNonBmpContentError) {
|
|
12697
12975
|
return verifyFailure(
|
|
12698
12976
|
"non-bmp-content",
|
|
12699
|
-
|
|
12977
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12700
12978
|
"no",
|
|
12701
12979
|
`\u8FD9\u6B21${what}\u4E00\u4E2A\u5B57\u90FD\u6CA1\u53D1\u51FA\u53BB\uFF1A\u6B63\u6587\u91CC\u6709 ${e.hits.length} \u5904 Jira \u5B58\u4E0D\u4E0B\u7684\u5B57\u7B26`,
|
|
12702
12980
|
// 🔴 清单落 nextStep,不落 cause:CliError 渲染 cause 时 formatCause 截到 300 字,
|
|
@@ -12707,7 +12985,7 @@ ${nonBmpHitLines(e.hits)}`,
|
|
|
12707
12985
|
);
|
|
12708
12986
|
}
|
|
12709
12987
|
if (e instanceof JiraHttpError && e.status >= 400 && e.status < 500) {
|
|
12710
|
-
return verifyFailure("write-rejected",
|
|
12988
|
+
return verifyFailure("write-rejected", CliErrorCode30.BUSINESS_RULE_VIOLATION, "no", `Jira \u4EE5 ${e.status} \u62D2\u7EDD\u4E86\u8FD9\u6B21${what}`, rejectNextStep(e.status, key2), {
|
|
12711
12989
|
key: key2,
|
|
12712
12990
|
status: e.status,
|
|
12713
12991
|
details: e.message
|
|
@@ -12715,7 +12993,7 @@ ${nonBmpHitLines(e.hits)}`,
|
|
|
12715
12993
|
}
|
|
12716
12994
|
return verifyFailure(
|
|
12717
12995
|
"write-unconfirmed",
|
|
12718
|
-
|
|
12996
|
+
CliErrorCode30.NETWORK_ERROR,
|
|
12719
12997
|
"unknown",
|
|
12720
12998
|
`${what}\u8BF7\u6C42\u6CA1\u5F97\u5230\u786E\u8BA4\uFF08${unconfirmedWhy(e)}\uFF09`,
|
|
12721
12999
|
`\u5148\u7528 \`hcm chiron gap status ${key2}\` \u4E0E \`hcm chiron gap comments ${key2}\` \u6838\u5BF9\u5199\u8FDB\u53BB\u6CA1\u6709\uFF0C\u518D\u51B3\u5B9A\u8981\u4E0D\u8981\u91CD\u8DD1\u2014\u2014partial \u91CD\u8DD1\u4F1A\u591A\u4E00\u6761\u8BC4\u8BBA\u3002`,
|
|
@@ -12738,7 +13016,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12738
13016
|
if (!parsed || parsed.kind !== "jira") {
|
|
12739
13017
|
throw verifyFailure(
|
|
12740
13018
|
"not-jira-key",
|
|
12741
|
-
|
|
13019
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12742
13020
|
"no",
|
|
12743
13021
|
parsed && parsed.kind === "repo" ? `${parsed.repo}#${parsed.number} \u662F\u4EA7\u54C1\u4ED3\u7F16\u53F7\uFF0C\u9A8C\u6536\u8981\u843D\u5728 Jira \u5355\u4E0A` : `\u770B\u4E0D\u61C2 ${ref}`,
|
|
12744
13022
|
"\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12 \u6216\u88F8\u6570\u5B57 12\uFF09\u2014\u2014\u5C31\u662F `hcm chiron gap submit` \u56DE\u6267\u91CC\u7684\u90A3\u4E2A\u7F16\u53F7\u3002"
|
|
@@ -12748,7 +13026,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12748
13026
|
const inProject = (k) => k.startsWith(`${client3.project}-`);
|
|
12749
13027
|
const wrongProject = (k) => verifyFailure(
|
|
12750
13028
|
"wrong-project",
|
|
12751
|
-
|
|
13029
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12752
13030
|
"no",
|
|
12753
13031
|
`${k} \u4E0D\u5728 ${client3.project} \u9879\u76EE\u91CC\uFF0C\u9A8C\u6536\u53EA\u5199 ${client3.project} \u7684\u5355`,
|
|
12754
13032
|
`\u7ED9 ${client3.project} \u7684\u5355\u53F7\uFF08\`hcm chiron gap submit\` \u56DE\u6267\u91CC\u7684\u90A3\u4E2A\uFF09\u3002\u522B\u7684\u9879\u76EE\u7684\u5355\u8FD9\u6761\u547D\u4EE4\u4E0D\u78B0\u2014\u2014\u90A3\u91CC\u7684\u72B6\u6001\u540D\u4E0E\u6D41\u8F6C\u540D\u548C ${client3.project} \u540C\u5F62\uFF0C\u5199\u9519\u4E86\u4F1A\u628A\u522B\u5904\u7684\u5355\u5173\u6389\u3002`,
|
|
@@ -12759,7 +13037,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12759
13037
|
if (evidence.length < EVIDENCE_MIN) {
|
|
12760
13038
|
throw verifyFailure(
|
|
12761
13039
|
"evidence-too-short",
|
|
12762
|
-
|
|
13040
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12763
13041
|
"no",
|
|
12764
13042
|
`\u9A8C\u6536\u8BC1\u636E\u81F3\u5C11 ${EVIDENCE_MIN} \u4E2A\u5B57\uFF0C\u7ED9\u7684\u662F ${evidence.length} \u4E2A\u5B57`,
|
|
12765
13043
|
"\u5199\u6E05\uFF1A\u54EA\u4E2A\u73AF\u5883\u3001\u54EA\u4E2A\u7248\u672C\uFF08`hcm version`\uFF09\u3001\u6309\u6280\u80FD\u8DD1\u4E86\u4EC0\u4E48\u3001\u770B\u5230\u4E86\u4EC0\u4E48\uFF1B\u8BC1\u636E\u6587\u4EF6\u653E\u5728 evidence/ \u4E0B\u5E76\u5199\u4E0A\u8DEF\u5F84\u3002",
|
|
@@ -12785,7 +13063,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12785
13063
|
if (!sameUser(reporter, me)) {
|
|
12786
13064
|
throw verifyFailure(
|
|
12787
13065
|
"not-reporter",
|
|
12788
|
-
|
|
13066
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12789
13067
|
"no",
|
|
12790
13068
|
`\u53EA\u6709\u63D0\u5355\u4EBA\u80FD\u9A8C\u6536 ${key2}\uFF1A\u63D0\u5355\u4EBA\u662F ${who(reporter)}\uFF0C\u5F53\u524D\u8EAB\u4EFD\u662F ${who(me)}`,
|
|
12791
13069
|
"\u8BF7\u63D0\u5355\u4EBA\u590D\u9A8C\u540E\u81EA\u5DF1\u8DD1\u8FD9\u6761\u547D\u4EE4\u3002\u4F60\u624B\u4E0A\u7684\u65B0\u73B0\u573A\u7528 `hcm chiron gap submit` \u8FFD\u52A0\uFF1B\u7ECF\u529E\u4EBA\u3001\u641C\u7D22\u547D\u4E2D\u3001\u5728\u522B\u4EBA\u7684\u5355\u4E0B\u8FFD\u52A0\u8FC7\u73B0\u573A\u90FD\u4E0D\u6784\u6210\u9A8C\u6536\u8D44\u683C\u3002",
|
|
@@ -12799,7 +13077,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12799
13077
|
if (status !== FIXED_STATUS) {
|
|
12800
13078
|
throw verifyFailure(
|
|
12801
13079
|
"status-not-fixed",
|
|
12802
|
-
|
|
13080
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12803
13081
|
"no",
|
|
12804
13082
|
`${key2} \u7684\u72B6\u6001\u662F\u300C${status ?? "?"}\u300D\uFF0C\u9A8C\u6536\u53EA\u5728\u300C${FIXED_STATUS}\u300D\u4E0A\u505A`,
|
|
12805
13083
|
notFixedNextStep(key2, status, o.result),
|
|
@@ -12825,7 +13103,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12825
13103
|
} else if (o.fingerprint.revision < fixRevision) {
|
|
12826
13104
|
const environmentRevision = o.fingerprint.revision;
|
|
12827
13105
|
const message = `\u73AF\u5883\u5C1A\u672A\u5305\u542B\u4FEE\u590D\uFF08\u5F53\u524D r${environmentRevision} < \u4FEE\u590D r${fixRevision}\uFF09\uFF0C\u8BF7\u7B49\u90E8\u7F72\u540E\u590D\u9A8C\uFF1B\u81EA\u67E5 curl <env>/api/version/backend`;
|
|
12828
|
-
throw verifyFailure("env-behind-fix",
|
|
13106
|
+
throw verifyFailure("env-behind-fix", CliErrorCode30.BUSINESS_RULE_VIOLATION, "no", message, message, { key: key2, fixRevision, environmentRevision });
|
|
12829
13107
|
} else {
|
|
12830
13108
|
const environmentRevision = o.fingerprint.revision;
|
|
12831
13109
|
versionComparison = { status: "passed", text: `\u7248\u672C\u6BD4\u5BF9\uFF1A\u73AF\u5883 r${environmentRevision} \u2265 \u4FEE\u590D r${fixRevision}`, fixRevision, environmentRevision };
|
|
@@ -12843,7 +13121,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12843
13121
|
const available = list.map((t) => `${t.name}\u2192${t.to?.name ?? "?"}`);
|
|
12844
13122
|
throw verifyFailure(
|
|
12845
13123
|
"transition-unavailable",
|
|
12846
|
-
|
|
13124
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12847
13125
|
"no",
|
|
12848
13126
|
`${key2} \u4E0A\u670D\u52A1\u7AEF\u6B64\u523B\u4E0D\u7ED9\u300C${want.name}\u2192${want.to}\u300D\u8FD9\u6761\u6D41\u8F6C\uFF08\u53EF\u7528\uFF1A${available.join(" / ") || "\uFF08\u65E0\uFF09"}\uFF09`,
|
|
12849
13127
|
"\u591A\u534A\u662F\u5DE5\u4F5C\u6D41\u88AB\u6539\u8FC7\uFF0C\u6216\u4F60\u7684\u8D26\u53F7\u5728\u8FD9\u4E2A\u9879\u76EE\u4E0A\u6CA1\u6709\u8FD9\u6761\u6D41\u8F6C\u7684\u6743\u9650\u3002\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\uFF1B\u522B\u81EA\u5DF1\u62FC HTTP\uFF0C\u4E5F\u522B\u6539\u95EE\u9898\u7C7B\u578B\u7ED5\u8FC7\u3002",
|
|
@@ -12855,7 +13133,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12855
13133
|
else if (req.missing.length) {
|
|
12856
13134
|
throw verifyFailure(
|
|
12857
13135
|
"required-fields-missing",
|
|
12858
|
-
|
|
13136
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12859
13137
|
"no",
|
|
12860
13138
|
`\u300C${transition.name}\u300D\u8981\u6C42\u8FD9\u4E9B\u5B57\u6BB5\u6709\u503C\uFF0C${key2} \u4E0A\u662F\u7A7A\u7684\uFF1A${req.missing.join("\u3001")}`,
|
|
12861
13139
|
"\u8FD9\u4E9B\u5B57\u6BB5\u7531\u4EA7\u54C1\u4FA7\u7EF4\u62A4\uFF0C\u8BF7\u5206\u8BCA\u4EBA\u8865\u9F50\u540E\u518D\u8DD1\uFF1BCLI \u4E0D\u4EE3\u586B\uFF0C\u4E5F\u522B\u628A\u7ECF\u529E\u4EBA\u6216\u4FEE\u590D\u4EBA\u731C\u6210 Bug\u5F15\u5165\u4EBA\u3002",
|
|
@@ -12897,7 +13175,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12897
13175
|
} catch (e) {
|
|
12898
13176
|
throw verifyFailure(
|
|
12899
13177
|
"readback-failed",
|
|
12900
|
-
|
|
13178
|
+
CliErrorCode30.NETWORK_ERROR,
|
|
12901
13179
|
"yes",
|
|
12902
13180
|
`${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u5931\u8D25\uFF0C\u843D\u5230\u4EC0\u4E48\u72B6\u6001\u6CA1\u786E\u8BA4`,
|
|
12903
13181
|
`\u7528 \`hcm chiron gap status ${key2}\` \u770B\u7ED3\u679C\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF08\u4F1A\u518D\u5199\u4E00\u6761\u8BC4\u8BBA\uFF09\u3002`,
|
|
@@ -12911,7 +13189,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12911
13189
|
const did = plan.outcome === "closed" ? "\u5173\u5355" : "\u9000\u56DE";
|
|
12912
13190
|
throw verifyFailure(
|
|
12913
13191
|
"readback-mismatch",
|
|
12914
|
-
|
|
13192
|
+
CliErrorCode30.SERVER_ERROR,
|
|
12915
13193
|
"yes",
|
|
12916
13194
|
after2.status !== expected ? `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u72B6\u6001\u662F\u300C${after2.status ?? "?"}\u300D\uFF0C\u9884\u671F\u300C${expected}\u300D` : `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C${key2} \u56DE\u5230\u4E86\u300C${expected}\u300D\uFF0C\u4F46 resolution \u8FD8\u662F\u300C${after2.resolution}\u300D\u2014\u2014\u5B83\u4F1A\u4ECE\u300C\u672A\u89E3\u51B3\u300D\u7684\u67E5\u8BE2\u91CC\u6D88\u5931`,
|
|
12917
13195
|
after2.status !== expected ? `\u4EE5 \`hcm chiron gap status ${key2}\` \u4E3A\u51C6\uFF0C\u522B\u5F53\u6210\u5DF2\u7ECF${did}\uFF1B\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u3002` : "\u8BF7\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u6E05\u6389\u8FD9\u5355\u7684 resolution\uFF08\u300C\u672A\u89E3\u51B3\u300D\u8FD9\u6761\u6D41\u8F6C\u672C\u6765\u4F1A\u6E05\uFF0C\u6CA1\u6E05\u8BF4\u660E\u5DE5\u4F5C\u6D41\u88AB\u6539\u8FC7\uFF09\uFF1B\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4ED6\u3002",
|
|
@@ -12943,7 +13221,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12943
13221
|
} catch (e) {
|
|
12944
13222
|
throw verifyFailure(
|
|
12945
13223
|
"readback-failed",
|
|
12946
|
-
|
|
13224
|
+
CliErrorCode30.NETWORK_ERROR,
|
|
12947
13225
|
"yes",
|
|
12948
13226
|
`\u8BC4\u8BBA\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u5931\u8D25\uFF0C\u6CA1\u786E\u8BA4\u5B83\u5728`,
|
|
12949
13227
|
`\u7528 \`hcm chiron gap comments ${key2}\` \u770B\u5B83\u5728\u4E0D\u5728\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF08\u4F1A\u518D\u5199\u4E00\u6761\uFF09\u3002`,
|
|
@@ -12957,7 +13235,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
|
|
|
12957
13235
|
} else if (!listed.some((c2) => c2.id === written.id)) {
|
|
12958
13236
|
throw verifyFailure(
|
|
12959
13237
|
"readback-mismatch",
|
|
12960
|
-
|
|
13238
|
+
CliErrorCode30.SERVER_ERROR,
|
|
12961
13239
|
"yes",
|
|
12962
13240
|
`Jira \u56DE\u4E86\u8BC4\u8BBA ${written.id}\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u91CC\u6CA1\u6709\u5B83`,
|
|
12963
13241
|
`\u7528 \`hcm chiron gap comments ${key2}\` \u6838\u5BF9\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF0C\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u3002`,
|
|
@@ -12994,7 +13272,7 @@ async function gapDeps(deps) {
|
|
|
12994
13272
|
return { client: await deps.client() };
|
|
12995
13273
|
}
|
|
12996
13274
|
function emit5(fmt, data, text) {
|
|
12997
|
-
if (fmt === "json" || fmt === "yaml") process.stdout.write(
|
|
13275
|
+
if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject27(data, { format: fmt }) + "\n");
|
|
12998
13276
|
else process.stdout.write(text() + "\n");
|
|
12999
13277
|
}
|
|
13000
13278
|
async function run2(fn) {
|
|
@@ -13099,7 +13377,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
|
|
|
13099
13377
|
if (opts.file !== void 0 && opts.body !== void 0) {
|
|
13100
13378
|
throw verifyFailure(
|
|
13101
13379
|
"evidence-ambiguous",
|
|
13102
|
-
|
|
13380
|
+
CliErrorCode31.INVALID_ARGUMENT,
|
|
13103
13381
|
"no",
|
|
13104
13382
|
"--body \u4E0E --file \u540C\u65F6\u7ED9\u4E86\uFF0C\u4E0D\u77E5\u9053\u8BE5\u7528\u54EA\u4EFD\u505A\u9A8C\u6536\u8BC1\u636E",
|
|
13105
13383
|
"\u53EA\u7559\u4E00\u4E2A\uFF1A\u77ED\u8BC1\u636E\u7528 --body\uFF0C\u957F\u8BC1\u636E\u5199\u8FDB\u6587\u4EF6\u7528 --file\u3002"
|
|
@@ -13111,7 +13389,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
|
|
|
13111
13389
|
} catch (e) {
|
|
13112
13390
|
throw verifyFailure(
|
|
13113
13391
|
"evidence-unreadable",
|
|
13114
|
-
|
|
13392
|
+
CliErrorCode31.INVALID_ARGUMENT,
|
|
13115
13393
|
"no",
|
|
13116
13394
|
`\u8BFB\u4E0D\u5230\u8BC1\u636E\u6587\u4EF6 ${opts.file}`,
|
|
13117
13395
|
"\u6838\u5BF9\u8DEF\u5F84\u4E0E\u6743\u9650\uFF1B\u8BC1\u636E\u6587\u4EF6\u4E00\u822C\u653E\u5728\u9879\u76EE\u4ED3\u7684 evidence/ \u4E0B\u3002",
|
|
@@ -13124,7 +13402,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
|
|
|
13124
13402
|
if (stdinIsTTY) {
|
|
13125
13403
|
throw verifyFailure(
|
|
13126
13404
|
"evidence-missing",
|
|
13127
|
-
|
|
13405
|
+
CliErrorCode31.INVALID_ARGUMENT,
|
|
13128
13406
|
"no",
|
|
13129
13407
|
"\u6CA1\u7ED9\u9A8C\u6536\u8BC1\u636E",
|
|
13130
13408
|
"\u7528 --body <\u6587\u672C> \u6216 --file <\u6587\u4EF6> \u7ED9\u51FA\uFF1A\u54EA\u4E2A\u73AF\u5883\u3001\u54EA\u4E2A\u7248\u672C\u3001\u6309\u6280\u80FD\u8DD1\u4E86\u4EC0\u4E48\u3001\u770B\u5230\u4E86\u4EC0\u4E48\u3002"
|
|
@@ -13179,13 +13457,13 @@ async function gapVerifyCommand(ref, args, deps = defaultDeps) {
|
|
|
13179
13457
|
|
|
13180
13458
|
// src/commands/chiron-doctor.ts
|
|
13181
13459
|
init_auth_guard();
|
|
13182
|
-
import { promises as
|
|
13183
|
-
import
|
|
13184
|
-
import
|
|
13460
|
+
import { promises as fs13 } from "fs";
|
|
13461
|
+
import path15 from "path";
|
|
13462
|
+
import axios10 from "axios";
|
|
13185
13463
|
import {
|
|
13186
|
-
CliError as
|
|
13187
|
-
CliErrorCode as
|
|
13188
|
-
formatObject as
|
|
13464
|
+
CliError as CliError34,
|
|
13465
|
+
CliErrorCode as CliErrorCode35,
|
|
13466
|
+
formatObject as formatObject30,
|
|
13189
13467
|
httpProbe as httpProbe2,
|
|
13190
13468
|
listEnvs as listEnvs2,
|
|
13191
13469
|
loadGlobalConfig as loadGlobalConfig12,
|
|
@@ -13201,18 +13479,18 @@ import {
|
|
|
13201
13479
|
|
|
13202
13480
|
// src/commands/chiron-env.ts
|
|
13203
13481
|
init_exit();
|
|
13204
|
-
import { promises as
|
|
13205
|
-
import
|
|
13482
|
+
import { promises as fs11 } from "fs";
|
|
13483
|
+
import path12 from "path";
|
|
13206
13484
|
import yaml from "js-yaml";
|
|
13207
13485
|
import {
|
|
13208
13486
|
AUTH_INFO_PATH as AUTH_INFO_PATH2,
|
|
13209
13487
|
assertNotReservedEnvName as assertNotReservedEnvName3,
|
|
13210
|
-
CliError as
|
|
13211
|
-
CliErrorCode as
|
|
13488
|
+
CliError as CliError30,
|
|
13489
|
+
CliErrorCode as CliErrorCode32,
|
|
13212
13490
|
discoverProjectEnv as discoverProjectEnv6,
|
|
13213
13491
|
ENV_FILE as ENV_FILE2,
|
|
13214
13492
|
findEnvByEndpoint as findEnvByEndpoint5,
|
|
13215
|
-
formatObject as
|
|
13493
|
+
formatObject as formatObject28,
|
|
13216
13494
|
listIdentities as listIdentities6,
|
|
13217
13495
|
parseEnvYaml as parseEnvYaml2,
|
|
13218
13496
|
renderEnvYaml as renderEnvYaml2,
|
|
@@ -13231,7 +13509,7 @@ function summarizeReasons(reasons) {
|
|
|
13231
13509
|
return reasons.length === 1 ? reasons[0] : `${reasons[0]} \u7B49 ${reasons.length} \u6761\uFF08--output json \u770B\u5168\u90E8\uFF09`;
|
|
13232
13510
|
}
|
|
13233
13511
|
function invalid2(message, nextStep) {
|
|
13234
|
-
throw new
|
|
13512
|
+
throw new CliError30({ code: CliErrorCode32.INVALID_ARGUMENT, message, context: { nextStep } });
|
|
13235
13513
|
}
|
|
13236
13514
|
function required(value, label) {
|
|
13237
13515
|
if (!value?.trim()) invalid2(`${label} \u4E0D\u80FD\u4E3A\u7A7A\uFF1B\u914D\u7F6E\u672A\u5199\u5165\u3002`, `\u8BF7\u63D0\u4F9B\u975E\u7A7A\u7684 ${label}`);
|
|
@@ -13352,11 +13630,11 @@ async function runChironEnv(action, args = {}) {
|
|
|
13352
13630
|
if (args.output && !["table", "json", "yaml"].includes(args.output)) {
|
|
13353
13631
|
invalid2(`\u672A\u77E5\u8F93\u51FA\u683C\u5F0F '${args.output}'\uFF0C\u914D\u7F6E\u672A\u5199\u5165\u3002`, "\u4F7F\u7528 --output table\u3001json \u6216 yaml");
|
|
13354
13632
|
}
|
|
13355
|
-
const root =
|
|
13633
|
+
const root = path12.resolve(args.project ?? ".");
|
|
13356
13634
|
const discovered = await discoverProjectEnv6(root);
|
|
13357
|
-
const file = discovered?.path ??
|
|
13635
|
+
const file = discovered?.path ?? path12.join(root, ENV_FILE2);
|
|
13358
13636
|
if (!discovered && action !== "add") invalid2(`\u6CA1\u6709\u627E\u5230 ${file}\u3002`, "\u8FDB\u5165\u987E\u95EE\u9879\u76EE\uFF0C\u6216\u8FD0\u884C hcm chiron env add <\u540D\u5B57> --endpoint <URL> --frontend <URL> --tenant <\u79DF\u6237>");
|
|
13359
|
-
const original = discovered ? await
|
|
13637
|
+
const original = discovered ? await fs11.readFile(file, "utf8") : null;
|
|
13360
13638
|
const config2 = original ? parseEnvYaml2(original) : { default: "", environments: {} };
|
|
13361
13639
|
const warnings = [];
|
|
13362
13640
|
const report = { action, path: file, config: config2, environments: [], warnings };
|
|
@@ -13411,14 +13689,14 @@ async function runChironEnv(action, args = {}) {
|
|
|
13411
13689
|
const legacy = original !== null && Object.hasOwn(yaml.load(original), "endpoint");
|
|
13412
13690
|
const rendered = legacy && action === "edit" ? yaml.dump(config2.environments.default, { noRefs: true, lineWidth: -1 }) : renderEnvYaml2(config2);
|
|
13413
13691
|
parseEnvYaml2(rendered);
|
|
13414
|
-
if (original !== null && await
|
|
13415
|
-
await
|
|
13416
|
-
report.config = parseEnvYaml2(await
|
|
13692
|
+
if (original !== null && await fs11.readFile(file, "utf8") !== original) invalid2(`${file} \u5728\u6838\u9A8C\u671F\u95F4\u88AB\u4FEE\u6539\uFF0C\u914D\u7F6E\u672A\u5199\u5165\u3002`, "\u91CD\u65B0\u8FD0\u884C\u547D\u4EE4\uFF0C\u57FA\u4E8E\u6700\u65B0\u914D\u7F6E\u7F16\u8F91");
|
|
13693
|
+
await fs11.writeFile(file, rendered, { encoding: "utf8", flag: original === null ? "wx" : "w" });
|
|
13694
|
+
report.config = parseEnvYaml2(await fs11.readFile(file, "utf8"));
|
|
13417
13695
|
report.environments = await rows(report.config, warnings);
|
|
13418
13696
|
return report;
|
|
13419
13697
|
}
|
|
13420
13698
|
function formatChironEnvReport(report, output = "table") {
|
|
13421
|
-
if (output !== "table") return
|
|
13699
|
+
if (output !== "table") return formatObject28(report, { format: output });
|
|
13422
13700
|
const lines = [
|
|
13423
13701
|
report.action === "list" ? `\u9879\u76EE\u73AF\u5883\uFF1A${report.path}` : `\u5DF2\u5199\u5165\uFF1A${report.path}`,
|
|
13424
13702
|
formatTable(report.environments.map((env2) => ({
|
|
@@ -13452,11 +13730,11 @@ import { promisify as promisify2 } from "util";
|
|
|
13452
13730
|
import { createHash as createHash6 } from "crypto";
|
|
13453
13731
|
import { existsSync as existsSync3, promises as fsp4 } from "fs";
|
|
13454
13732
|
import os5 from "os";
|
|
13455
|
-
import
|
|
13733
|
+
import path13 from "path";
|
|
13456
13734
|
import yaml2 from "js-yaml";
|
|
13457
13735
|
import {
|
|
13458
|
-
CliError as
|
|
13459
|
-
CliErrorCode as
|
|
13736
|
+
CliError as CliError31,
|
|
13737
|
+
CliErrorCode as CliErrorCode33,
|
|
13460
13738
|
METHOD_REPO_DISPLAY,
|
|
13461
13739
|
METHOD_REPO_URL,
|
|
13462
13740
|
assertSafeSkillId as assertSafeSkillId2,
|
|
@@ -13464,7 +13742,7 @@ import {
|
|
|
13464
13742
|
discoverProjectEnv as discoverProjectEnv7,
|
|
13465
13743
|
fetchSkillCatalog as fetchSkillCatalog2,
|
|
13466
13744
|
flattenSkills as flattenSkills2,
|
|
13467
|
-
formatObject as
|
|
13745
|
+
formatObject as formatObject29,
|
|
13468
13746
|
parseSkillFrontmatter as parseSkillFrontmatter3,
|
|
13469
13747
|
resolveChironBase as resolveChironBase2
|
|
13470
13748
|
} from "@hcmai/sdk";
|
|
@@ -13497,8 +13775,8 @@ function gitErrorText(e) {
|
|
|
13497
13775
|
function classifyGitFailure(e, repoDisplay) {
|
|
13498
13776
|
const err = e;
|
|
13499
13777
|
if (err.code === "ENOENT") {
|
|
13500
|
-
return new
|
|
13501
|
-
code:
|
|
13778
|
+
return new CliError31({
|
|
13779
|
+
code: CliErrorCode33.METHOD_GIT_UNAVAILABLE,
|
|
13502
13780
|
message: "\u672C\u673A\u627E\u4E0D\u5230 git\uFF0C\u53D6\u65B9\u6CD5\u5305\u9760\u5B83",
|
|
13503
13781
|
context: { nextStep: "\u88C5\u4E0A git\uFF08`git --version` \u80FD\u8DD1\u901A\uFF09\uFF0C\u518D\u91CD\u8DD1\u8FD9\u6761\u547D\u4EE4" }
|
|
13504
13782
|
});
|
|
@@ -13506,15 +13784,15 @@ function classifyGitFailure(e, repoDisplay) {
|
|
|
13506
13784
|
const text = gitErrorText(e);
|
|
13507
13785
|
const head = text.split("\n").filter(Boolean).slice(-3).join(" / ").slice(0, 400);
|
|
13508
13786
|
if (err.code === "ETIMEDOUT" || err.signal === "SIGTERM") {
|
|
13509
|
-
return new
|
|
13510
|
-
code:
|
|
13787
|
+
return new CliError31({
|
|
13788
|
+
code: CliErrorCode33.METHOD_SOURCE_NETWORK,
|
|
13511
13789
|
message: `git \u5728\u65F6\u9650\u5185\u6CA1\u6709\u8FD4\u56DE\uFF08${repoDisplay}\uFF09`,
|
|
13512
13790
|
context: { nextStep: "\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u540E\u91CD\u8DD1\uFF1B\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\u79BB\u7EBF\u53EF\u8BFB\uFF0C`hcm chiron method status` \u7167\u5E38\u80FD\u7528" }
|
|
13513
13791
|
});
|
|
13514
13792
|
}
|
|
13515
13793
|
if (/could not read Username|Authentication failed|terminal prompts disabled|returned error: 401|HTTP Basic: Access denied|invalid credentials|Permission denied \(publickey/i.test(text)) {
|
|
13516
|
-
return new
|
|
13517
|
-
code:
|
|
13794
|
+
return new CliError31({
|
|
13795
|
+
code: CliErrorCode33.METHOD_SOURCE_AUTH_REQUIRED,
|
|
13518
13796
|
message: `\u65B9\u6CD5\u8BBA\u4ED3\u8981\u8BA4\u8BC1\uFF0C\u672C\u673A\u6CA1\u6709\u53EF\u7528\u7684 git \u51ED\u636E\uFF08${repoDisplay}\uFF09\uFF1A${head}`,
|
|
13519
13797
|
context: { nextStep: "`cnb login` \u4E4B\u540E\u91CD\u8DD1\u3002\u65B9\u6CD5\u5305\u8D70\u7684\u662F git \u51ED\u636E\uFF0C\u4E0D\u662F `hcm login`" }
|
|
13520
13798
|
});
|
|
@@ -13522,8 +13800,8 @@ function classifyGitFailure(e, repoDisplay) {
|
|
|
13522
13800
|
const notFound = /returned error: 404|Repository not found|repository '.*' not found|does not appear to be a git repository/i.test(text);
|
|
13523
13801
|
if (/returned error: 403|403 Forbidden|access denied|not authorized/i.test(text) || notFound) {
|
|
13524
13802
|
const overridden = Boolean(process.env.HCM_METHOD_REPO?.trim() || process.env.HCM_METHOD_REPO_URL?.trim());
|
|
13525
|
-
return new
|
|
13526
|
-
code:
|
|
13803
|
+
return new CliError31({
|
|
13804
|
+
code: CliErrorCode33.METHOD_SOURCE_FORBIDDEN,
|
|
13527
13805
|
message: `\u51ED\u636E\u6709\u6548\u4F46\u8BFB\u4E0D\u5230\u65B9\u6CD5\u8BBA\u4ED3 ${repoDisplay}\uFF1A${head}` + (notFound ? "\uFF08\u8FDC\u7AEF\u5BF9\u65E0\u6743\u8BBF\u95EE\u7684\u79C1\u6709\u4ED3\u4E5F\u53EF\u80FD\u56DE 404\uFF0C\u6240\u4EE5\u8FD9\u91CC\u4E0D\u628A\u5B83\u5224\u6210\u300C\u4ED3\u4E0D\u5B58\u5728\u300D\uFF09" : ""),
|
|
13528
13806
|
context: {
|
|
13529
13807
|
nextStep: "\u627E\u77E5\u8BC6\u7EC4\u7EC7\u7BA1\u7406\u5458\u628A\u4F60\u52A0\u8FDB\u65B9\u6CD5\u8BBA\u4ED3\uFF08\u8981\u4EE3\u7801\u8BFB\u6743\u9650\uFF09" + (overridden ? "\uFF1B\u4F60\u8BBE\u4E86 HCM_METHOD_REPO / HCM_METHOD_REPO_URL\uFF0C\u5148\u6838\u5BF9\u62FC\u5199" : "")
|
|
@@ -13531,14 +13809,14 @@ function classifyGitFailure(e, repoDisplay) {
|
|
|
13531
13809
|
});
|
|
13532
13810
|
}
|
|
13533
13811
|
if (/Could not resolve host|Failed to connect|Connection refused|Connection timed out|Operation timed out|Network is unreachable|Could not connect|SSL|TLS|timed out/i.test(text)) {
|
|
13534
|
-
return new
|
|
13535
|
-
code:
|
|
13812
|
+
return new CliError31({
|
|
13813
|
+
code: CliErrorCode33.METHOD_SOURCE_NETWORK,
|
|
13536
13814
|
message: `\u8FDE\u4E0D\u4E0A\u65B9\u6CD5\u8BBA\u4ED3\uFF08${repoDisplay}\uFF09\uFF1A${head}`,
|
|
13537
13815
|
context: { nextStep: "\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u540E\u91CD\u8DD1\uFF1B\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\u79BB\u7EBF\u53EF\u8BFB\uFF0C`hcm chiron method status` \u7167\u5E38\u80FD\u7528" }
|
|
13538
13816
|
});
|
|
13539
13817
|
}
|
|
13540
|
-
return new
|
|
13541
|
-
code:
|
|
13818
|
+
return new CliError31({
|
|
13819
|
+
code: CliErrorCode33.METHOD_SOURCE_GIT_FAILED,
|
|
13542
13820
|
message: `git \u5931\u8D25\u4E86\uFF0C\u539F\u56E0\u4E0D\u5728\u8BA4\u8BC1 / \u6743\u9650 / \u7F51\u7EDC\u4E09\u7C7B\u91CC\uFF08${repoDisplay}\uFF09\uFF1A${head}`,
|
|
13543
13821
|
context: { nextStep: `\u81EA\u5DF1\u8DD1\u4E00\u6B21 \`git ls-remote --tags <\u65B9\u6CD5\u8BBA\u4ED3\u5730\u5740>\` \u770B\u539F\u8BDD\uFF1B\u628A\u4E0A\u9762\u8FD9\u6BB5\u8FDE\u540C \`git --version\` \u62A5\u7ED9 CLI \u7EF4\u62A4\u8005` }
|
|
13544
13822
|
});
|
|
@@ -13614,8 +13892,8 @@ function resolveRef(tags, ref, deps) {
|
|
|
13614
13892
|
if (ref === void 0) {
|
|
13615
13893
|
const latest = versions[0];
|
|
13616
13894
|
if (!latest) {
|
|
13617
|
-
throw new
|
|
13618
|
-
code:
|
|
13895
|
+
throw new CliError31({
|
|
13896
|
+
code: CliErrorCode33.METHOD_REF_NOT_FOUND,
|
|
13619
13897
|
message: `\u65B9\u6CD5\u8BBA\u4ED3 ${deps.repoDisplay} \u91CC\u4E00\u4E2A vX.Y.Z \u5F62\u5F0F\u7684\u7248\u672C tag \u90FD\u6CA1\u6709`,
|
|
13620
13898
|
context: { nextStep: tags.size ? `\u4ED3\u91CC\u6709\u8FD9\u4E9B tag\uFF1A${[...tags.keys()].slice(0, 10).join("\u3001")}\uFF0C\u7528 --ref \u6307\u5B9A\u4E00\u4E2A` : "\u65B9\u6CD5\u8BBA\u4ED3\u8FD8\u6CA1\u53D1\u8FC7\u7248\uFF0C\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4" }
|
|
13621
13899
|
});
|
|
@@ -13624,8 +13902,8 @@ function resolveRef(tags, ref, deps) {
|
|
|
13624
13902
|
}
|
|
13625
13903
|
const name = tags.has(ref) ? ref : tags.has(`v${ref}`) ? `v${ref}` : void 0;
|
|
13626
13904
|
if (!name) {
|
|
13627
|
-
throw new
|
|
13628
|
-
code:
|
|
13905
|
+
throw new CliError31({
|
|
13906
|
+
code: CliErrorCode33.METHOD_REF_NOT_FOUND,
|
|
13629
13907
|
message: `\u65B9\u6CD5\u8BBA\u4ED3 ${deps.repoDisplay} \u91CC\u6CA1\u6709 tag ${ref}`,
|
|
13630
13908
|
context: { nextStep: versions.length ? `\u53EF\u7528\u7684\u7248\u672C tag\uFF1A${versions.slice(0, 10).join("\u3001")}` : "\u65B9\u6CD5\u8BBA\u4ED3\u8FD8\u6CA1\u53D1\u8FC7\u7248\uFF0C\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4" }
|
|
13631
13909
|
});
|
|
@@ -13633,8 +13911,8 @@ function resolveRef(tags, ref, deps) {
|
|
|
13633
13911
|
return { ref: name, commit: tags.get(name) };
|
|
13634
13912
|
}
|
|
13635
13913
|
function invalidPackage(field, message) {
|
|
13636
|
-
return new
|
|
13637
|
-
code:
|
|
13914
|
+
return new CliError31({
|
|
13915
|
+
code: CliErrorCode33.METHOD_PACKAGE_INVALID,
|
|
13638
13916
|
message: `\u65B9\u6CD5\u5305\u6E05\u5355 package.yml \u4E0D\u5408\u683C\uFF1A${message}`,
|
|
13639
13917
|
context: { field, nextStep: "\u8FD9\u662F\u65B9\u6CD5\u5305\u7684\u7F3A\u9677\uFF0C\u4E0D\u662F\u672C\u673A\u95EE\u9898\uFF1A\u628A\u8FD9\u6BB5\u62A5\u7ED9\u65B9\u6CD5\u8BBA\u4ED3\u8D1F\u8D23\u4EBA\u3002\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\uFF08\u5982\u6709\uFF09\u4FDD\u6301\u539F\u6837\uFF0C\u6CA1\u52A8" }
|
|
13640
13918
|
});
|
|
@@ -13658,8 +13936,8 @@ function parsePackageManifest(text) {
|
|
|
13658
13936
|
throw invalidPackage("schemaVersion", "\u7F3A schemaVersion\uFF08\u6574\u6570\uFF09");
|
|
13659
13937
|
}
|
|
13660
13938
|
if (!KNOWN_PACKAGE_SCHEMA_VERSIONS.includes(m.schemaVersion)) {
|
|
13661
|
-
throw new
|
|
13662
|
-
code:
|
|
13939
|
+
throw new CliError31({
|
|
13940
|
+
code: CliErrorCode33.METHOD_PACKAGE_SCHEMA_UNSUPPORTED,
|
|
13663
13941
|
message: `\u65B9\u6CD5\u5305\u6E05\u5355\u7684\u683C\u5F0F\u7248\u672C schemaVersion=${m.schemaVersion}\uFF0C\u8FD9\u7248 CLI\uFF08${CLI_VERSION}\uFF09\u53EA\u8BA4\u8BC6 ${KNOWN_PACKAGE_SCHEMA_VERSIONS.join(" / ")}`,
|
|
13664
13942
|
context: { nextStep: "\u5347\u7EA7 CLI\uFF1A`npm install --global @hcmai/cli@latest`\uFF08\u6216 `hcm upgrade`\uFF09\uFF0C\u518D\u91CD\u8DD1\u3002\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\uFF08\u5982\u6709\uFF09\u4FDD\u6301\u539F\u6837\uFF0C\u6CA1\u52A8" }
|
|
13665
13943
|
});
|
|
@@ -13748,10 +14026,10 @@ function parsePackageManifest(text) {
|
|
|
13748
14026
|
async function sha256File(file) {
|
|
13749
14027
|
return createHash6("sha256").update(await fsp4.readFile(file)).digest("hex");
|
|
13750
14028
|
}
|
|
13751
|
-
async function verifyDigests(entries,
|
|
14029
|
+
async function verifyDigests(entries, resolve4) {
|
|
13752
14030
|
const out = { files: entries.length, mismatched: [], missing: [] };
|
|
13753
14031
|
for (const f of entries) {
|
|
13754
|
-
const abs =
|
|
14032
|
+
const abs = resolve4(f.path);
|
|
13755
14033
|
if (!existsSync3(abs)) {
|
|
13756
14034
|
out.missing.push(f.path);
|
|
13757
14035
|
continue;
|
|
@@ -13765,7 +14043,7 @@ async function listFilesUnder(root, rel) {
|
|
|
13765
14043
|
const walk = async (dirRel) => {
|
|
13766
14044
|
let items;
|
|
13767
14045
|
try {
|
|
13768
|
-
items = await fsp4.readdir(
|
|
14046
|
+
items = await fsp4.readdir(path13.join(root, dirRel), { withFileTypes: true });
|
|
13769
14047
|
} catch {
|
|
13770
14048
|
return;
|
|
13771
14049
|
}
|
|
@@ -13786,9 +14064,9 @@ var BLOCK_LABEL = {
|
|
|
13786
14064
|
"online-catalog": "\u5728\u7EBF\u4EA7\u54C1\u76EE\u5F55"
|
|
13787
14065
|
};
|
|
13788
14066
|
var PROJECT_SKILL_STATE_FILES = [
|
|
13789
|
-
|
|
13790
|
-
|
|
13791
|
-
|
|
14067
|
+
path13.join(SKILLS_DIR, SKILLS_SYNC_SUBDIR, SKILLS_STATE_FILE),
|
|
14068
|
+
path13.join(SKILLS_DIR, SKILLS_STATE_FILE),
|
|
14069
|
+
path13.join(".claude", "skills", SKILLS_STATE_FILE)
|
|
13792
14070
|
];
|
|
13793
14071
|
async function onlineTargetFor(root) {
|
|
13794
14072
|
try {
|
|
@@ -13828,7 +14106,7 @@ async function checkMethodConflicts(methodIds, root, online, deps) {
|
|
|
13828
14106
|
const unreadable = [];
|
|
13829
14107
|
const owners = /* @__PURE__ */ new Map();
|
|
13830
14108
|
for (const rel of PROJECT_SKILL_STATE_FILES) {
|
|
13831
|
-
const file =
|
|
14109
|
+
const file = path13.join(root, rel);
|
|
13832
14110
|
if (!existsSync3(file)) continue;
|
|
13833
14111
|
found2.push(rel);
|
|
13834
14112
|
try {
|
|
@@ -13836,20 +14114,20 @@ async function checkMethodConflicts(methodIds, root, online, deps) {
|
|
|
13836
14114
|
for (const [id, rec] of Object.entries(state.skills ?? {})) {
|
|
13837
14115
|
if (!owners.has(id)) {
|
|
13838
14116
|
const from = rec?.sourceKind === "cli" ? "CLI \u81EA\u5E26" : rec?.sourceKind === "local" ? "\u672C\u5730\u76EE\u5F55" : `\u4EA7\u54C1 ${state.endpoint ?? "\uFF08\u672A\u8BB0\u73AF\u5883\uFF09"}`;
|
|
13839
|
-
owners.set(id, `\u672C\u9879\u76EE\u5DF2\u88C5\uFF08${rel.split(
|
|
14117
|
+
owners.set(id, `\u672C\u9879\u76EE\u5DF2\u88C5\uFF08${rel.split(path13.sep).join("/")}\uFF0C\u6765\u6E90 ${from}\uFF09`);
|
|
13840
14118
|
}
|
|
13841
14119
|
}
|
|
13842
14120
|
} catch (e) {
|
|
13843
|
-
unreadable.push(`${rel.split(
|
|
14121
|
+
unreadable.push(`${rel.split(path13.sep).join("/")}\uFF08${e.message.split("\n")[0]}\uFF09`);
|
|
13844
14122
|
}
|
|
13845
14123
|
}
|
|
13846
14124
|
if (found2.length === 0) {
|
|
13847
14125
|
b.note = "\u672C\u9879\u76EE\u8FD8\u6CA1\u88C5\u4EA7\u54C1\u6280\u80FD\uFF0C\u4EA7\u54C1\u4FA7\u672A\u6BD4\u5BF9";
|
|
13848
14126
|
} else if (owners.size === 0) {
|
|
13849
|
-
b.note = unreadable.length ? `\u5B89\u88C5\u6E05\u5355\u8BFB\u4E0D\u61C2\uFF1A${unreadable.join("\uFF1B")}\uFF0C\u4EA7\u54C1\u4FA7\u672A\u6BD4\u5BF9` : `\u5B89\u88C5\u6E05\u5355\u5728\uFF08${found2.map((f) => f.split(
|
|
14127
|
+
b.note = unreadable.length ? `\u5B89\u88C5\u6E05\u5355\u8BFB\u4E0D\u61C2\uFF1A${unreadable.join("\uFF1B")}\uFF0C\u4EA7\u54C1\u4FA7\u672A\u6BD4\u5BF9` : `\u5B89\u88C5\u6E05\u5355\u5728\uFF08${found2.map((f) => f.split(path13.sep).join("/")).join("\u3001")}\uFF09\uFF0C\u4F46\u4E00\u6761\u8BB0\u5F55\u90FD\u6CA1\u6709\uFF0C\u7A7A\u96C6\u5408\u4E0A\u6BD4\u4E0D\u51FA\u300C\u65E0\u540C\u540D\u300D\uFF0C\u4EA7\u54C1\u4FA7\u672A\u6BD4\u5BF9`;
|
|
13850
14128
|
} else {
|
|
13851
14129
|
b.checked = true;
|
|
13852
|
-
b.source = found2.map((f) => f.split(
|
|
14130
|
+
b.source = found2.map((f) => f.split(path13.sep).join("/")).join("\u3001");
|
|
13853
14131
|
b.compared = [...owners.keys()].sort();
|
|
13854
14132
|
b.conflicts = b.compared.filter((id) => wanted.has(id)).map((id) => ({ id, other: owners.get(id) }));
|
|
13855
14133
|
if (unreadable.length) b.note = `\u53E6\u6709\u6E05\u5355\u8BFB\u4E0D\u61C2\u3001\u6CA1\u7B97\u8FDB\u6765\uFF1A${unreadable.join("\uFF1B")}`;
|
|
@@ -13895,8 +14173,8 @@ function renderConflictBlocks(blocks) {
|
|
|
13895
14173
|
}
|
|
13896
14174
|
function conflictError(blocks, pkg, commit) {
|
|
13897
14175
|
const hits = blocks.flatMap((b) => b.conflicts);
|
|
13898
|
-
return new
|
|
13899
|
-
code:
|
|
14176
|
+
return new CliError31({
|
|
14177
|
+
code: CliErrorCode33.SKILL_ID_CONFLICT,
|
|
13900
14178
|
message: "\u65B9\u6CD5\u5305\u91CC\u7684\u6280\u80FD id \u4E0E\u5DF2\u6709\u6765\u6E90\u540C\u540D\uFF0C\u62D2\u88C5\uFF1A\n" + hits.map((c2) => ` \xB7 \`${c2.id}\`\uFF1A\u65B9\u6CD5 ${pkg.version} @${commit.slice(0, 12)} \u2194 ${c2.other}`).join("\n") + "\n\u672C\u8D9F\u51B2\u7A81\u68C0\u67E5\uFF1A\n" + renderConflictBlocks(blocks).join("\n"),
|
|
13901
14179
|
context: {
|
|
13902
14180
|
nextStep: `\u62A5\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u6539\u540D\u3002\`${METHOD_SKILL_PREFIX}\` \u524D\u7F00\u53EA\u7ED9\u65B9\u6CD5\u6765\u6E90\uFF0C\u7EA6\u5B9A\u751F\u6548\u65F6\u4E0D\u8BE5\u649E\u540D\uFF1B\u649E\u4E86\u8BF4\u660E\u6709\u4E00\u8FB9\u8FDD\u53CD\u4E86\u524D\u7F00\u7EA6\u5B9A\u3002\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\uFF08\u5982\u6709\uFF09\u4FDD\u6301\u539F\u6837\uFF0C\u6CA1\u52A8`,
|
|
@@ -13911,8 +14189,8 @@ function upsertManagedBlock(existing, begin, end, block, label) {
|
|
|
13911
14189
|
const finish = existing.indexOf(end);
|
|
13912
14190
|
const malformed = start < 0 !== finish < 0 || start >= 0 && (finish < start || existing.lastIndexOf(begin) !== start || existing.lastIndexOf(end) !== finish);
|
|
13913
14191
|
if (malformed) {
|
|
13914
|
-
throw new
|
|
13915
|
-
code:
|
|
14192
|
+
throw new CliError31({
|
|
14193
|
+
code: CliErrorCode33.METHOD_MANAGED_BLOCK_CORRUPT,
|
|
13916
14194
|
message: `${label} \u91CC\u65B9\u6CD5\u53D7\u7BA1\u5757\u7684\u6807\u8BB0\u635F\u574F\u6216\u91CD\u590D\uFF08${begin} \u2026 ${end}\uFF09\uFF0C\u62D2\u7EDD\u8986\u76D6`,
|
|
13917
14195
|
context: { nextStep: `\u624B\u5DE5\u628A ${label} \u91CC\u8FD9\u4E24\u884C\u6807\u8BB0\u4FEE\u6210\u5404\u51FA\u73B0\u4E00\u6B21\u3001begin \u5728\u524D\uFF08\u6216\u8FDE\u540C\u4E2D\u95F4\u5185\u5BB9\u6574\u6BB5\u5220\u6389\uFF09\uFF0C\u518D\u91CD\u8DD1` }
|
|
13918
14196
|
});
|
|
@@ -13968,7 +14246,7 @@ function renderLock(lock) {
|
|
|
13968
14246
|
`;
|
|
13969
14247
|
}
|
|
13970
14248
|
async function readLock(root) {
|
|
13971
|
-
const file =
|
|
14249
|
+
const file = path13.join(root, METHOD_DIR, METHOD_LOCK_FILE);
|
|
13972
14250
|
let text;
|
|
13973
14251
|
try {
|
|
13974
14252
|
text = await fsp4.readFile(file, "utf8");
|
|
@@ -13976,8 +14254,8 @@ async function readLock(root) {
|
|
|
13976
14254
|
if (e.code === "ENOENT") return void 0;
|
|
13977
14255
|
throw e;
|
|
13978
14256
|
}
|
|
13979
|
-
const bad = (why) => new
|
|
13980
|
-
code:
|
|
14257
|
+
const bad = (why) => new CliError31({
|
|
14258
|
+
code: CliErrorCode33.METHOD_LOCK_INVALID,
|
|
13981
14259
|
message: `\u9501\u6587\u4EF6 ${METHOD_DIR}/${METHOD_LOCK_FILE} \u8BFB\u4E0D\u61C2\uFF1A${why}`,
|
|
13982
14260
|
context: { nextStep: "\u591A\u534A\u662F\u5408\u5E76\u51B2\u7A81\u7559\u4E0B\u7684\u6807\u8BB0\uFF1A\u6309\u9879\u76EE PR \u91CC\u60F3\u8981\u7684\u90A3\u4E00\u7248\u89E3\u51B3\u51B2\u7A81\uFF08\u6216 `git checkout` \u56DE\u4E0A\u4E00\u7248\uFF09\uFF0C\u518D\u8DD1 `hcm chiron method status`" }
|
|
13983
14261
|
});
|
|
@@ -13996,17 +14274,17 @@ async function readLock(root) {
|
|
|
13996
14274
|
}
|
|
13997
14275
|
async function readState(root) {
|
|
13998
14276
|
try {
|
|
13999
|
-
return JSON.parse(await fsp4.readFile(
|
|
14277
|
+
return JSON.parse(await fsp4.readFile(path13.join(root, METHOD_DIR, METHOD_STATE_FILE), "utf8"));
|
|
14000
14278
|
} catch {
|
|
14001
14279
|
return void 0;
|
|
14002
14280
|
}
|
|
14003
14281
|
}
|
|
14004
14282
|
async function resolveMethodRoot(project2, log) {
|
|
14005
|
-
if (project2 !== void 0) return { root:
|
|
14283
|
+
if (project2 !== void 0) return { root: path13.resolve(project2), rootSource: "--project" };
|
|
14006
14284
|
const cwd = process.cwd();
|
|
14007
14285
|
try {
|
|
14008
14286
|
const found2 = await discoverProjectEnv7(cwd);
|
|
14009
|
-
if (found2) return { root:
|
|
14287
|
+
if (found2) return { root: path13.dirname(found2.path), rootSource: "env.yaml" };
|
|
14010
14288
|
} catch (e) {
|
|
14011
14289
|
log(`env.yaml \u8BFB\u4E0D\u61C2\uFF08${e.message.split("\n")[0]}\uFF09\uFF0C\u4EE5\u5F53\u524D\u76EE\u5F55\u4E3A\u9879\u76EE\u6839\uFF1A${cwd}`);
|
|
14012
14290
|
return { root: cwd, rootSource: "cwd" };
|
|
@@ -14017,18 +14295,18 @@ async function resolveMethodRoot(project2, log) {
|
|
|
14017
14295
|
async function resolveTarget(root, requested) {
|
|
14018
14296
|
if (requested === "claude" || requested === "codex") return requested;
|
|
14019
14297
|
if (requested !== void 0 && requested !== "auto") {
|
|
14020
|
-
throw new
|
|
14298
|
+
throw new CliError31({ code: CliErrorCode33.INVALID_ARGUMENT, message: `--target \u53EA\u8BA4 claude / codex / auto\uFF0C\u6536\u5230 ${requested}` });
|
|
14021
14299
|
}
|
|
14022
14300
|
return (await readState(root))?.target ?? await detectTarget(root) ?? "claude";
|
|
14023
14301
|
}
|
|
14024
14302
|
function skillFileSig(manifest2, skill) {
|
|
14025
|
-
const dir = `${
|
|
14303
|
+
const dir = `${path13.posix.dirname(skill.path)}/`;
|
|
14026
14304
|
return manifest2.files.filter((f) => f.path.startsWith(dir)).map((f) => `${f.path}:${f.sha256}`).sort().join("\n");
|
|
14027
14305
|
}
|
|
14028
14306
|
async function readCriteria(dir) {
|
|
14029
14307
|
let text;
|
|
14030
14308
|
try {
|
|
14031
|
-
text = await fsp4.readFile(
|
|
14309
|
+
text = await fsp4.readFile(path13.join(dir, GATES_FILE), "utf8");
|
|
14032
14310
|
} catch {
|
|
14033
14311
|
return { reason: `\u6CA1\u6709 ${GATES_FILE}` };
|
|
14034
14312
|
}
|
|
@@ -14096,7 +14374,7 @@ async function step(deps, n, label, fn) {
|
|
|
14096
14374
|
}
|
|
14097
14375
|
async function readInstalledManifest(root) {
|
|
14098
14376
|
try {
|
|
14099
|
-
const text = await fsp4.readFile(
|
|
14377
|
+
const text = await fsp4.readFile(path13.join(root, METHOD_DIR, "package.yml"), "utf8");
|
|
14100
14378
|
return { text, manifest: parsePackageManifest(text) };
|
|
14101
14379
|
} catch {
|
|
14102
14380
|
return void 0;
|
|
@@ -14105,31 +14383,31 @@ async function readInstalledManifest(root) {
|
|
|
14105
14383
|
var sha256Text = (t) => createHash6("sha256").update(t, "utf8").digest("hex");
|
|
14106
14384
|
async function hasClaudeCopies(root) {
|
|
14107
14385
|
try {
|
|
14108
|
-
return (await fsp4.readdir(
|
|
14386
|
+
return (await fsp4.readdir(path13.join(root, ".claude", "skills"), { withFileTypes: true })).some((it) => it.isDirectory() && it.name.startsWith(METHOD_SKILL_PREFIX));
|
|
14109
14387
|
} catch {
|
|
14110
14388
|
return false;
|
|
14111
14389
|
}
|
|
14112
14390
|
}
|
|
14113
14391
|
function codexAgentFiles(root) {
|
|
14114
|
-
const files = [
|
|
14115
|
-
if (existsSync3(
|
|
14392
|
+
const files = [path13.join(root, "AGENTS.md")];
|
|
14393
|
+
if (existsSync3(path13.join(root, "CLAUDE.md"))) files.push(path13.join(root, "CLAUDE.md"));
|
|
14116
14394
|
return files;
|
|
14117
14395
|
}
|
|
14118
14396
|
async function installClaudeCopies(root, manifest2) {
|
|
14119
|
-
const skillsRoot =
|
|
14397
|
+
const skillsRoot = path13.join(root, ".claude", "skills");
|
|
14120
14398
|
await fsp4.mkdir(skillsRoot, { recursive: true });
|
|
14121
14399
|
const ids = new Set(manifest2.skills.map((s) => s.id));
|
|
14122
14400
|
const written = [];
|
|
14123
14401
|
for (const s of manifest2.skills) {
|
|
14124
|
-
const dst =
|
|
14402
|
+
const dst = path13.join(skillsRoot, s.id);
|
|
14125
14403
|
await fsp4.rm(dst, { recursive: true, force: true });
|
|
14126
|
-
await fsp4.cp(
|
|
14404
|
+
await fsp4.cp(path13.join(root, METHOD_DIR, path13.dirname(s.path)), dst, { recursive: true });
|
|
14127
14405
|
written.push(`.claude/skills/${s.id}/`);
|
|
14128
14406
|
}
|
|
14129
14407
|
const pruned = [];
|
|
14130
14408
|
for (const it of await fsp4.readdir(skillsRoot, { withFileTypes: true })) {
|
|
14131
14409
|
if (it.isDirectory() && it.name.startsWith(METHOD_SKILL_PREFIX) && !ids.has(it.name)) {
|
|
14132
|
-
await fsp4.rm(
|
|
14410
|
+
await fsp4.rm(path13.join(skillsRoot, it.name), { recursive: true, force: true });
|
|
14133
14411
|
pruned.push(`.claude/skills/${it.name}/`);
|
|
14134
14412
|
}
|
|
14135
14413
|
}
|
|
@@ -14138,14 +14416,14 @@ async function installClaudeCopies(root, manifest2) {
|
|
|
14138
14416
|
async function indexEntries(root, agentsDir, manifest2) {
|
|
14139
14417
|
const out = [];
|
|
14140
14418
|
for (const s of manifest2.skills) {
|
|
14141
|
-
const abs =
|
|
14419
|
+
const abs = path13.join(root, METHOD_DIR, s.path);
|
|
14142
14420
|
let description = "";
|
|
14143
14421
|
try {
|
|
14144
14422
|
const fm = parseSkillFrontmatter3(await fsp4.readFile(abs, "utf8"), s.id);
|
|
14145
14423
|
if (typeof fm.description === "string") description = fm.description.trim().replace(/\s+/g, " ");
|
|
14146
14424
|
} catch {
|
|
14147
14425
|
}
|
|
14148
|
-
let rel =
|
|
14426
|
+
let rel = path13.relative(agentsDir, abs).split(path13.sep).join("/");
|
|
14149
14427
|
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
14150
14428
|
out.push({ id: s.id, title: s.title, description, phases: s.phases, relativePath: rel });
|
|
14151
14429
|
}
|
|
@@ -14159,8 +14437,8 @@ async function runMethodPipeline(input, deps) {
|
|
|
14159
14437
|
const tags = await listRemoteTags(deps);
|
|
14160
14438
|
const r = resolveRef(tags, input.ref, deps);
|
|
14161
14439
|
if (input.expectCommit && r.commit !== input.expectCommit) {
|
|
14162
|
-
throw new
|
|
14163
|
-
code:
|
|
14440
|
+
throw new CliError31({
|
|
14441
|
+
code: CliErrorCode33.METHOD_TAG_MOVED,
|
|
14164
14442
|
message: `\u9501\u6587\u4EF6\u9501\u5B9A ${r.ref} @ ${input.expectCommit}\uFF0C\u800C\u8FD9\u4E2A tag \u73B0\u5728\u6307\u5411 ${r.commit}\uFF08tag \u88AB\u79FB\u52A8\u8FC7\uFF09`,
|
|
14165
14443
|
context: { nextStep: "\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4\u8FD9\u4E2A tag \u4E3A\u4EC0\u4E48\u88AB\u79FB\u52A8\u3002\u786E\u8BA4\u8981\u8DDF\u65B0\u5185\u5BB9\u5C31 `hcm chiron method update --ref <tag>`\uFF08\u9501\u6587\u4EF6\u7684\u53D8\u66F4\u8D70\u9879\u76EE PR \u8BC4\u5BA1\uFF09" }
|
|
14166
14444
|
});
|
|
@@ -14168,22 +14446,22 @@ async function runMethodPipeline(input, deps) {
|
|
|
14168
14446
|
deps.log(` ${r.ref} \u2192 ${r.commit.slice(0, 12)}`);
|
|
14169
14447
|
return r;
|
|
14170
14448
|
});
|
|
14171
|
-
const work = await fsp4.mkdtemp(
|
|
14449
|
+
const work = await fsp4.mkdtemp(path13.join(os5.tmpdir(), "hcm-method-"));
|
|
14172
14450
|
try {
|
|
14173
|
-
const checkout =
|
|
14451
|
+
const checkout = path13.join(work, "pkg");
|
|
14174
14452
|
const { manifest: manifest2, manifestText } = await step(deps, 2, "\u53D6\u5305\uFF08\u7A00\u758F\u6D45 clone\uFF09", async () => {
|
|
14175
14453
|
await deps.git(["clone", "--depth", "1", "--filter=blob:none", "--sparse", "--quiet", "--branch", resolved.ref, deps.repoUrl, checkout]);
|
|
14176
14454
|
const head = (await deps.git(["-C", checkout, "rev-parse", "HEAD"], { timeoutMs: 1e4 })).trim();
|
|
14177
14455
|
if (head !== resolved.commit) {
|
|
14178
|
-
throw new
|
|
14179
|
-
code:
|
|
14456
|
+
throw new CliError31({
|
|
14457
|
+
code: CliErrorCode33.METHOD_TAG_MOVED,
|
|
14180
14458
|
message: `\u89E3\u6790\u65F6 ${resolved.ref} \u6307\u5411 ${resolved.commit}\uFF0C\u53D6\u4E0B\u6765\u7684\u5374\u662F ${head}\uFF08tag \u5728\u8FD9\u51E0\u79D2\u91CC\u88AB\u79FB\u52A8\u4E86\uFF09`,
|
|
14181
14459
|
context: { nextStep: "\u91CD\u8DD1\u4E00\u6B21\uFF1B\u518D\u51FA\u73B0\u5C31\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4\u8FD9\u4E2A tag \u4E3A\u4EC0\u4E48\u5728\u52A8" }
|
|
14182
14460
|
});
|
|
14183
14461
|
}
|
|
14184
14462
|
let text;
|
|
14185
14463
|
try {
|
|
14186
|
-
text = await fsp4.readFile(
|
|
14464
|
+
text = await fsp4.readFile(path13.join(checkout, "package.yml"), "utf8");
|
|
14187
14465
|
} catch {
|
|
14188
14466
|
throw invalidPackage("package.yml", `${resolved.ref} \u7684\u6839\u76EE\u5F55\u6CA1\u6709 package.yml\uFF08\u8FD9\u4E2A tag \u4E0D\u662F\u6309\u65B9\u6CD5\u5305\u6253\u7684\uFF09`);
|
|
14189
14467
|
}
|
|
@@ -14194,11 +14472,11 @@ async function runMethodPipeline(input, deps) {
|
|
|
14194
14472
|
});
|
|
14195
14473
|
const unlisted = await step(deps, 3, "\u6821\u9A8C\u6E05\u5355\u4E0E\u6458\u8981", async () => {
|
|
14196
14474
|
for (const [i, entry] of manifest2.include.entries()) {
|
|
14197
|
-
if (!existsSync3(
|
|
14475
|
+
if (!existsSync3(path13.join(checkout, entry.replace(/\/$/, "")))) {
|
|
14198
14476
|
throw invalidPackage(`include[${i}]`, `include \u767B\u8BB0\u4E86 ${entry}\uFF0C\u4F46 ${resolved.ref} \u91CC\u6CA1\u6709\u5B83`);
|
|
14199
14477
|
}
|
|
14200
14478
|
}
|
|
14201
|
-
const check = await verifyDigests(manifest2.files, (p) =>
|
|
14479
|
+
const check = await verifyDigests(manifest2.files, (p) => path13.join(checkout, p));
|
|
14202
14480
|
if (check.missing.length) {
|
|
14203
14481
|
throw invalidPackage("files", `\u6E05\u5355\u767B\u8BB0\u4E86\u3001\u5305\u91CC\u5374\u6CA1\u6709\uFF1A${naming(check.missing)}`);
|
|
14204
14482
|
}
|
|
@@ -14219,7 +14497,7 @@ async function runMethodPipeline(input, deps) {
|
|
|
14219
14497
|
for (const l of renderConflictBlocks(blocks)) deps.log(l);
|
|
14220
14498
|
return blocks;
|
|
14221
14499
|
});
|
|
14222
|
-
const diff = input.mode === "update" ? await diffPackages(before ?
|
|
14500
|
+
const diff = input.mode === "update" ? await diffPackages(before ? path13.join(root, METHOD_DIR) : void 0, before?.manifest, checkout, manifest2) : void 0;
|
|
14223
14501
|
if (diff) for (const l of renderDiff(diff)) deps.log(` ${l}`);
|
|
14224
14502
|
const lock = {
|
|
14225
14503
|
lockVersion: 1,
|
|
@@ -14231,29 +14509,29 @@ async function runMethodPipeline(input, deps) {
|
|
|
14231
14509
|
skills: manifest2.skills.map((s) => s.id)
|
|
14232
14510
|
};
|
|
14233
14511
|
const nowIso = deps.now().toISOString();
|
|
14234
|
-
const gitignorePath =
|
|
14512
|
+
const gitignorePath = path13.join(root, ".gitignore");
|
|
14235
14513
|
const agentTargets = input.target === "codex" ? codexAgentFiles(root) : [];
|
|
14236
14514
|
const gitignore = await step(deps, 5, "\u9884\u68C0\u53D7\u7BA1\u5757\u5E76\u7EF4\u62A4 .gitignore", async () => {
|
|
14237
14515
|
await preflightManaged([
|
|
14238
14516
|
{ file: gitignorePath, begin: GITIGNORE_BEGIN, end: GITIGNORE_END, label: ".gitignore" },
|
|
14239
|
-
...agentTargets.map((file) => ({ file, begin: AGENTS_METHOD_BEGIN, end: AGENTS_METHOD_END, label:
|
|
14517
|
+
...agentTargets.map((file) => ({ file, begin: AGENTS_METHOD_BEGIN, end: AGENTS_METHOD_END, label: path13.basename(file) }))
|
|
14240
14518
|
]);
|
|
14241
14519
|
return writeManaged(gitignorePath, GITIGNORE_BEGIN, GITIGNORE_END, renderGitignoreBlock(), ".gitignore");
|
|
14242
14520
|
});
|
|
14243
14521
|
await step(deps, 6, `\u66FF\u6362 ${METHOD_DIR}/ \u5E76\u5199\u9501\u6587\u4EF6`, async () => {
|
|
14244
|
-
const targetDir =
|
|
14245
|
-
const staging =
|
|
14246
|
-
const old =
|
|
14522
|
+
const targetDir = path13.join(root, METHOD_DIR);
|
|
14523
|
+
const staging = path13.join(root, `.${METHOD_DIR}.staging-${process.pid}`);
|
|
14524
|
+
const old = path13.join(root, `.${METHOD_DIR}.old-${process.pid}`);
|
|
14247
14525
|
await fsp4.rm(staging, { recursive: true, force: true });
|
|
14248
14526
|
try {
|
|
14249
14527
|
await fsp4.mkdir(staging, { recursive: true });
|
|
14250
14528
|
for (const entry of manifest2.include) {
|
|
14251
14529
|
const rel = entry.replace(/\/$/, "");
|
|
14252
|
-
await fsp4.cp(
|
|
14530
|
+
await fsp4.cp(path13.join(checkout, rel), path13.join(staging, rel), { recursive: true });
|
|
14253
14531
|
}
|
|
14254
|
-
await fsp4.writeFile(
|
|
14532
|
+
await fsp4.writeFile(path13.join(staging, METHOD_LOCK_FILE), renderLock(lock), "utf8");
|
|
14255
14533
|
const state = { target: input.target, installedAt: nowIso, remoteCheckedAt: nowIso };
|
|
14256
|
-
await fsp4.writeFile(
|
|
14534
|
+
await fsp4.writeFile(path13.join(staging, METHOD_STATE_FILE), `${JSON.stringify(state, null, 2)}
|
|
14257
14535
|
`, "utf8");
|
|
14258
14536
|
const hadOld = existsSync3(targetDir);
|
|
14259
14537
|
if (hadOld) {
|
|
@@ -14277,8 +14555,8 @@ async function runMethodPipeline(input, deps) {
|
|
|
14277
14555
|
const refreshCopies = input.target === "claude" || await hasClaudeCopies(root);
|
|
14278
14556
|
if (refreshCopies) copies = await installClaudeCopies(root, manifest2);
|
|
14279
14557
|
for (const file of agentTargets) {
|
|
14280
|
-
const block = renderMethodAgentsBlock(lock, await indexEntries(root,
|
|
14281
|
-
files.push({ file:
|
|
14558
|
+
const block = renderMethodAgentsBlock(lock, await indexEntries(root, path13.dirname(file), manifest2));
|
|
14559
|
+
files.push({ file: path13.relative(root, file), status: await writeManaged(file, AGENTS_METHOD_BEGIN, AGENTS_METHOD_END, block, path13.basename(file)) });
|
|
14282
14560
|
}
|
|
14283
14561
|
return { files, copies };
|
|
14284
14562
|
});
|
|
@@ -14314,7 +14592,7 @@ async function runMethodPipeline(input, deps) {
|
|
|
14314
14592
|
function renderInstallReport(r) {
|
|
14315
14593
|
const out = [];
|
|
14316
14594
|
const verb = r.mode === "update" ? "\u5DF2\u66F4\u65B0\u5230" : "\u5DF2\u88C5";
|
|
14317
|
-
out.push(`${verb}\u65B9\u6CD5 ${r.package.version}\uFF08${r.ref} @ ${r.commit.slice(0, 12)}\uFF09\u2192 ${
|
|
14595
|
+
out.push(`${verb}\u65B9\u6CD5 ${r.package.version}\uFF08${r.ref} @ ${r.commit.slice(0, 12)}\uFF09\u2192 ${path13.join(r.root, METHOD_DIR)}/`);
|
|
14318
14596
|
if (r.previous && r.previous.commit !== r.commit) out.push(` \u9501\u6587\u4EF6\uFF1A${r.previous.ref} @ ${r.previous.commit.slice(0, 12)} \u2192 ${r.ref} @ ${r.commit.slice(0, 12)}`);
|
|
14319
14597
|
out.push(` \u6280\u80FD ${r.skills.length} \u4EFD\uFF1A${naming(r.skills, 6)}`);
|
|
14320
14598
|
if (r.diff) for (const l of renderDiff(r.diff)) out.push(` ${l}`);
|
|
@@ -14355,21 +14633,21 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14355
14633
|
verdict: "fail",
|
|
14356
14634
|
detail: `\u6CA1\u6709 ${METHOD_DIR}/${METHOD_LOCK_FILE}\uFF1A\u8FD9\u4E2A\u9879\u76EE\u8FD8\u6CA1\u88C5\u65B9\u6CD5\u5305`,
|
|
14357
14635
|
nextStep: "\u6709\u77E5\u8BC6\u7EC4\u7EC7\u6388\u6743\u5C31\u8DD1 `hcm chiron method install`\uFF1B\u6CA1\u6709\u6388\u6743\u53EF\u4EE5\u8DF3\u8FC7\uFF0C\u4E0D\u5F71\u54CD\u4EA7\u54C1\u64CD\u4F5C",
|
|
14358
|
-
code:
|
|
14636
|
+
code: CliErrorCode33.METHOD_NOT_INSTALLED
|
|
14359
14637
|
});
|
|
14360
14638
|
return done();
|
|
14361
14639
|
}
|
|
14362
14640
|
report.lock = lock;
|
|
14363
14641
|
report.rows.push({ item: "\u9501\u5B9A", verdict: "ok", detail: `\u65B9\u6CD5 ${lock.package.version} \xB7 ${lock.ref} @ ${lock.commit.slice(0, 12)}\uFF08${lock.skills.length} \u4EFD\u6280\u80FD\uFF09` });
|
|
14364
14642
|
const state = await readState(root);
|
|
14365
|
-
const installed2 = await fsp4.readFile(
|
|
14643
|
+
const installed2 = await fsp4.readFile(path13.join(root, METHOD_DIR, "package.yml"), "utf8").catch(() => void 0);
|
|
14366
14644
|
if (installed2 === void 0) {
|
|
14367
14645
|
report.rows.push({
|
|
14368
14646
|
item: "\u5B89\u88C5",
|
|
14369
14647
|
verdict: "fail",
|
|
14370
14648
|
detail: "\u9501\u6587\u4EF6\u5728\uFF0C\u4F46\u672C\u673A\u6CA1\u6709\u65B9\u6CD5\u5305\u526F\u672C\uFF08\u521A clone \u4E0B\u6765\u7684\u9879\u76EE\u4ED3\u5C31\u662F\u8FD9\u6837\uFF09",
|
|
14371
14649
|
nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684\u7248\u672C\u88C5\uFF09",
|
|
14372
|
-
code:
|
|
14650
|
+
code: CliErrorCode33.METHOD_NOT_INSTALLED
|
|
14373
14651
|
});
|
|
14374
14652
|
} else {
|
|
14375
14653
|
report.installed.present = true;
|
|
@@ -14380,10 +14658,10 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14380
14658
|
verdict: "fail",
|
|
14381
14659
|
detail: "\u672C\u673A\u526F\u672C\u7684 package.yml \u4E0E\u9501\u6587\u4EF6\u8BB0\u7684\u6458\u8981\u4E0D\u4E00\u81F4\uFF1A\u88C5\u7684\u4E0D\u662F\u9501\u5B9A\u7684\u90A3\u4E00\u7248",
|
|
14382
14660
|
nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684 commit \u91CD\u88C5\uFF09",
|
|
14383
|
-
code:
|
|
14661
|
+
code: CliErrorCode33.METHOD_DIGEST_MISMATCH
|
|
14384
14662
|
});
|
|
14385
14663
|
} else {
|
|
14386
|
-
report.rows.push({ item: "\u5B89\u88C5", verdict: "ok", detail: `\u672C\u673A\u526F\u672C\u5C31\u662F\u9501\u5B9A\u7684\u90A3\u4E00\u7248\uFF08${
|
|
14664
|
+
report.rows.push({ item: "\u5B89\u88C5", verdict: "ok", detail: `\u672C\u673A\u526F\u672C\u5C31\u662F\u9501\u5B9A\u7684\u90A3\u4E00\u7248\uFF08${path13.join(root, METHOD_DIR)}/\uFF09` });
|
|
14387
14665
|
let manifest2;
|
|
14388
14666
|
try {
|
|
14389
14667
|
manifest2 = parsePackageManifest(installed2);
|
|
@@ -14391,17 +14669,17 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14391
14669
|
report.digest.note = `\u672C\u673A package.yml \u8BFB\u4E0D\u61C2\uFF1A${e.message}`;
|
|
14392
14670
|
}
|
|
14393
14671
|
if (manifest2) {
|
|
14394
|
-
const main2 = await verifyDigests(manifest2.files, (p) =>
|
|
14672
|
+
const main2 = await verifyDigests(manifest2.files, (p) => path13.join(root, METHOD_DIR, p));
|
|
14395
14673
|
const copyEntries = [];
|
|
14396
14674
|
const copyMap = /* @__PURE__ */ new Map();
|
|
14397
14675
|
for (const s of manifest2.skills) {
|
|
14398
|
-
const copyDir =
|
|
14676
|
+
const copyDir = path13.join(root, ".claude", "skills", s.id);
|
|
14399
14677
|
if (!existsSync3(copyDir) && state?.target !== "claude") continue;
|
|
14400
|
-
const prefix = `${
|
|
14678
|
+
const prefix = `${path13.posix.dirname(s.path)}/`;
|
|
14401
14679
|
for (const f of manifest2.files.filter((x) => x.path.startsWith(prefix))) {
|
|
14402
14680
|
const shown = `.claude/skills/${s.id}/${f.path.slice(prefix.length)}`;
|
|
14403
14681
|
copyEntries.push({ ...f, path: shown });
|
|
14404
|
-
copyMap.set(shown,
|
|
14682
|
+
copyMap.set(shown, path13.join(root, shown));
|
|
14405
14683
|
}
|
|
14406
14684
|
}
|
|
14407
14685
|
const copies = await verifyDigests(copyEntries, (p) => copyMap.get(p));
|
|
@@ -14424,13 +14702,13 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14424
14702
|
verdict: "fail",
|
|
14425
14703
|
detail: `${bad.length} \u4EFD .claude/skills \u65B9\u6CD5\u526F\u672C\u4E0E\u9501\u5B9A\u7248\u672C\u4E0D\u7B26\uFF08\u8FD9\u53F0\u673A\u5668\u73B0\u5728\u7684 target \u662F ${state.target}\uFF0C\u8FD9\u4E9B\u526F\u672C\u662F\u4E4B\u524D\u7528 claude \u76EE\u6807\u88C5\u65F6\u7559\u4E0B\u7684\uFF09\uFF1A${listing}`,
|
|
14426
14704
|
nextStep: "`hcm chiron method install`\uFF08\u4F1A\u4E00\u5E76\u5237\u65B0 .claude/skills \u4E0B\u5DF2\u6709\u7684\u65B9\u6CD5\u526F\u672C\uFF09\uFF1B\u4E0D\u518D\u7528 Claude Code \u5C31\u5220\u6389 `.claude/skills/method-*/`",
|
|
14427
|
-
code:
|
|
14705
|
+
code: CliErrorCode33.METHOD_DIGEST_MISMATCH
|
|
14428
14706
|
} : {
|
|
14429
14707
|
item: "\u6458\u8981",
|
|
14430
14708
|
verdict: "fail",
|
|
14431
14709
|
detail: `${bad.length} \u4EFD\u6587\u4EF6\u4E0E\u6E05\u5355\u4E0D\u7B26\uFF1A${listing}`,
|
|
14432
14710
|
nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684 commit \u91CD\u88C5\uFF0C\u672C\u673A\u6539\u52A8\u4F1A\u88AB\u8986\u76D6\uFF1B\u8981\u6539\u65B9\u6CD5\u5C31\u53BB\u65B9\u6CD5\u8BBA\u4ED3\u63D0\uFF09",
|
|
14433
|
-
code:
|
|
14711
|
+
code: CliErrorCode33.METHOD_DIGEST_MISMATCH
|
|
14434
14712
|
});
|
|
14435
14713
|
} else {
|
|
14436
14714
|
report.rows.push({
|
|
@@ -14453,7 +14731,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14453
14731
|
verdict: "warn",
|
|
14454
14732
|
detail: `tag ${lock.ref} \u73B0\u5728\u6307\u5411 ${report.remote.lockedTagCommit.slice(0, 12)}\uFF0C\u9501\u5B9A\u7684\u662F ${lock.commit.slice(0, 12)}\uFF08tag \u88AB\u79FB\u52A8\u8FC7\uFF1B\u672C\u673A\u526F\u672C\u4EE5\u9501\u5B9A\u7684 commit \u4E3A\u51C6\uFF09`,
|
|
14455
14733
|
nextStep: "\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4 tag \u4E3A\u4EC0\u4E48\u88AB\u79FB\u52A8\uFF1B\u8981\u8DDF\u65B0\u5185\u5BB9\u5C31 `hcm chiron method update --ref <tag>`",
|
|
14456
|
-
code:
|
|
14734
|
+
code: CliErrorCode33.METHOD_TAG_MOVED
|
|
14457
14735
|
});
|
|
14458
14736
|
} else if (!SEMVER_TAG.test(lock.ref) || !report.remote.latestTag) {
|
|
14459
14737
|
report.remote.undetermined = !SEMVER_TAG.test(lock.ref) ? `\u9501\u5B9A\u7684 ref ${lock.ref} \u4E0D\u662F vX.Y.Z \u7248\u672C tag\uFF0C\u65E0\u6CD5\u5224\u65AD\u662F\u5426\u843D\u540E\uFF08\u8FDC\u7AEF\u6700\u65B0\u7248\u672C tag\uFF1A${report.remote.latestTag ?? "\u65E0"}\uFF09` : "\u8FDC\u7AEF\u4E00\u4E2A vX.Y.Z \u7248\u672C tag \u90FD\u6CA1\u6709\uFF0C\u65E0\u6CD5\u5224\u65AD\u662F\u5426\u843D\u540E";
|
|
@@ -14484,8 +14762,8 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14484
14762
|
});
|
|
14485
14763
|
}
|
|
14486
14764
|
for (const id of lock.skills) {
|
|
14487
|
-
const by =
|
|
14488
|
-
if (existsSync3(
|
|
14765
|
+
const by = path13.join(SKILLS_DIR, SKILLS_LOCAL_SUBDIR, id);
|
|
14766
|
+
if (existsSync3(path13.join(root, by, "SKILL.md"))) report.shadowed.push({ id, by: `${by.split(path13.sep).join("/")}/` });
|
|
14489
14767
|
}
|
|
14490
14768
|
report.rows.push(report.shadowed.length ? {
|
|
14491
14769
|
item: "\u906E\u853D",
|
|
@@ -14498,14 +14776,14 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14498
14776
|
const hits = report.conflictCheck.flatMap((b) => b.conflicts);
|
|
14499
14777
|
const unchecked = report.conflictCheck.filter((b) => !b.checked);
|
|
14500
14778
|
const summary = report.conflictCheck.map((b) => b.checked ? `${b.label}\uFF1A\u5DF2\u6BD4\u5BF9 ${b.compared.length} \u4E2A${b.conflicts.length ? `\uFF0C\u540C\u540D ${b.conflicts.map((c2) => c2.id).join("\u3001")}` : "\uFF0C\u65E0\u540C\u540D"}` : `${b.label}\uFF1A\u672A\u6BD4\u5BF9\uFF08${b.note}\uFF09`).join("\uFF1B");
|
|
14501
|
-
report.rows.push(hits.length ? { item: "\u51B2\u7A81", verdict: "fail", detail: summary, nextStep: "\u62A5\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u6539\u540D\uFF08method- \u524D\u7F00\u53EA\u7ED9\u65B9\u6CD5\u6765\u6E90\uFF09", code:
|
|
14779
|
+
report.rows.push(hits.length ? { item: "\u51B2\u7A81", verdict: "fail", detail: summary, nextStep: "\u62A5\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u6539\u540D\uFF08method- \u524D\u7F00\u53EA\u7ED9\u65B9\u6CD5\u6765\u6E90\uFF09", code: CliErrorCode33.SKILL_ID_CONFLICT } : unchecked.length ? { item: "\u51B2\u7A81", verdict: "warn", detail: `${summary}\u2014\u2014\u6CA1\u6BD4\u5BF9\u7684\u5757\u4E0A\u4E0D\u80FD\u8BF4\u300C\u65E0\u51B2\u7A81\u300D` } : { item: "\u51B2\u7A81", verdict: "ok", detail: summary });
|
|
14502
14780
|
}
|
|
14503
14781
|
report.rows.push(report.remote.checked ? { item: "\u6765\u6E90", verdict: "ok", detail: `\u5728\u7EBF\uFF1Agit \u51ED\u636E\u8BA4\u8BC1\u53D6 tag\uFF0Ccommit \u56FA\u5B9A\uFF08${lock.repo}\uFF09` } : { item: "\u6765\u6E90", verdict: "warn", detail: "\u79BB\u7EBF\uFF1A\u53EA\u6838\u4E86\u672C\u673A\u526F\u672C\u7684\u6458\u8981\uFF0C\u6CA1\u4E0E\u8FDC\u7AEF\u6838\u5BF9 tag" });
|
|
14504
14782
|
return done();
|
|
14505
14783
|
}
|
|
14506
14784
|
function renderMethodStatus(r) {
|
|
14507
14785
|
const mark = { ok: "\u2705", warn: "\u26A0\uFE0F", fail: "\u274C" };
|
|
14508
|
-
const out = [`\u65B9\u6CD5\u5305\uFF1A${
|
|
14786
|
+
const out = [`\u65B9\u6CD5\u5305\uFF1A${path13.join(r.root, METHOD_DIR)}/`];
|
|
14509
14787
|
for (const row of r.rows) {
|
|
14510
14788
|
out.push(`${mark[row.verdict]} ${row.item} ${row.detail}`);
|
|
14511
14789
|
if (row.nextStep && row.verdict !== "ok") out.push(` \u2192 ${row.nextStep}`);
|
|
@@ -14517,10 +14795,10 @@ async function inspectMethodForDoctor(root, deps = quietDeps()) {
|
|
|
14517
14795
|
const row = (item) => s.rows.find((r) => r.item === item);
|
|
14518
14796
|
const lockRow = row("\u9501\u5B9A");
|
|
14519
14797
|
if (!s.lock) {
|
|
14520
|
-
return lockRow.code ===
|
|
14798
|
+
return lockRow.code === CliErrorCode33.METHOD_NOT_INSTALLED ? { verdict: "warn", detail: "\u672A\u5B89\u88C5\uFF08\u9879\u76EE\u91CC\u6CA1\u6709\u65B9\u6CD5\u5305\u9501\u6587\u4EF6\uFF09", nextStep: "\u6709\u77E5\u8BC6\u7EC4\u7EC7\u6388\u6743\u5C31\u8DD1 `hcm chiron method install`\uFF1B\u6CA1\u6709\u6388\u6743\u53EF\u4EE5\u8DF3\u8FC7\uFF0C\u4E0D\u5F71\u54CD\u4EA7\u54C1\u64CD\u4F5C" } : { verdict: "warn", detail: `\u65E0\u6CD5\u5224\u65AD\uFF1A${lockRow.detail}`, nextStep: lockRow.nextStep };
|
|
14521
14799
|
}
|
|
14522
14800
|
const install = row("\u5B89\u88C5");
|
|
14523
|
-
if (install?.code ===
|
|
14801
|
+
if (install?.code === CliErrorCode33.METHOD_NOT_INSTALLED) {
|
|
14524
14802
|
return { verdict: "warn", detail: `\u672A\u5B89\u88C5\uFF08\u9501\u6587\u4EF6\u9501\u5B9A\u65B9\u6CD5 ${s.lock.package.version} \xB7 ${s.lock.ref}\uFF0C\u672C\u673A\u8FD8\u6CA1\u6709\u65B9\u6CD5\u5305\u526F\u672C\uFF09`, nextStep: "\u6709\u77E5\u8BC6\u7EC4\u7EC7\u6388\u6743\u5C31\u8DD1 `hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684\u7248\u672C\u88C5\uFF09\uFF1B\u6CA1\u6709\u6388\u6743\u53EF\u4EE5\u8DF3\u8FC7\uFF0C\u4E0D\u5F71\u54CD\u4EA7\u54C1\u64CD\u4F5C" };
|
|
14525
14803
|
}
|
|
14526
14804
|
const local = [install, row("\u6458\u8981")].find((r) => r && r.verdict === "fail");
|
|
@@ -14537,7 +14815,7 @@ function quietDeps() {
|
|
|
14537
14815
|
} };
|
|
14538
14816
|
}
|
|
14539
14817
|
function emit6(output, data, text) {
|
|
14540
|
-
if (output === "json" || output === "yaml") process.stdout.write(
|
|
14818
|
+
if (output === "json" || output === "yaml") process.stdout.write(formatObject29(data, { format: output }) + "\n");
|
|
14541
14819
|
else process.stdout.write(text() + "\n");
|
|
14542
14820
|
}
|
|
14543
14821
|
async function runMethodInstall(args, deps = defaultMethodDeps()) {
|
|
@@ -14553,8 +14831,8 @@ async function runMethodUpdate(args, deps = defaultMethodDeps()) {
|
|
|
14553
14831
|
const { root, rootSource } = await resolveMethodRoot(args.project, deps.log);
|
|
14554
14832
|
const lock = await readLock(root);
|
|
14555
14833
|
if (!lock) {
|
|
14556
|
-
throw new
|
|
14557
|
-
code:
|
|
14834
|
+
throw new CliError31({
|
|
14835
|
+
code: CliErrorCode33.METHOD_NOT_INSTALLED,
|
|
14558
14836
|
message: `${root} \u91CC\u6CA1\u6709 ${METHOD_DIR}/${METHOD_LOCK_FILE}\uFF1A\u8FD9\u4E2A\u9879\u76EE\u8FD8\u6CA1\u88C5\u65B9\u6CD5\u5305\uFF0C\u6CA1\u6709\u53EF\u4EE5\u66F4\u65B0\u7684\u8D77\u70B9`,
|
|
14559
14837
|
context: { nextStep: "`hcm chiron method install`\uFF08\u88C5\u6700\u65B0\u7684\u7248\u672C tag\uFF09" }
|
|
14560
14838
|
});
|
|
@@ -14601,9 +14879,9 @@ async function methodStatusCommand(args) {
|
|
|
14601
14879
|
}
|
|
14602
14880
|
|
|
14603
14881
|
// src/commands/doctor/local-checks.ts
|
|
14604
|
-
import { promises as
|
|
14605
|
-
import
|
|
14606
|
-
import
|
|
14882
|
+
import { promises as fs12 } from "fs";
|
|
14883
|
+
import path14 from "path";
|
|
14884
|
+
import axios6 from "axios";
|
|
14607
14885
|
import { fetchSkillCatalog as fetchSkillCatalog3, fetchSkillMarkdown as fetchSkillMarkdown2, fetchSkillReference as fetchSkillReference2, normalizeReferences as normalizeReferences2, normalizeOrigin as normalizeOrigin6, resolveChironBase as resolveChironBase3 } from "@hcmai/sdk";
|
|
14608
14886
|
|
|
14609
14887
|
// src/commands/doctor/result.ts
|
|
@@ -14704,13 +14982,13 @@ var version = async (ctx) => {
|
|
|
14704
14982
|
var installed = async (ctx) => {
|
|
14705
14983
|
let reading = "";
|
|
14706
14984
|
const read = (baseDir) => {
|
|
14707
|
-
reading =
|
|
14985
|
+
reading = path14.join(baseDir, SKILLS_STATE_FILE);
|
|
14708
14986
|
return readSkillsState(baseDir, { strict: true });
|
|
14709
14987
|
};
|
|
14710
14988
|
try {
|
|
14711
14989
|
const states = [];
|
|
14712
14990
|
for (const [target2, folder] of [["codex", "hcm-skills/sync"], ["claude", ".claude/skills"]]) {
|
|
14713
|
-
const baseDir =
|
|
14991
|
+
const baseDir = path14.join(ctx.root, folder);
|
|
14714
14992
|
const state = await read(baseDir);
|
|
14715
14993
|
if (state) states.push({ target: target2, baseDir, state });
|
|
14716
14994
|
}
|
|
@@ -14721,12 +14999,12 @@ var installed = async (ctx) => {
|
|
|
14721
14999
|
if (states.some((s) => s.state.endpoint && normalizeOrigin6(s.state.endpoint) !== normalizeOrigin6(target.config.endpoint)))
|
|
14722
15000
|
return found("SKILLS_ENDPOINT_MISMATCH", void 0, { value: count });
|
|
14723
15001
|
if (count === 0) {
|
|
14724
|
-
const legacy = await read(
|
|
15002
|
+
const legacy = await read(path14.join(ctx.root, "hcm-skills"));
|
|
14725
15003
|
return found(legacy && Object.keys(legacy.skills).length > 0 ? "SKILLS_LEGACY_LAYOUT" : "SKILLS_EMPTY", void 0, { value: count, evidence: "ABSENT" });
|
|
14726
15004
|
}
|
|
14727
15005
|
if (states.length === 2 && keys(states[0]).length > 0 && keys(states[1]).length > 0 && keys(states[0]).sort().join("\0") !== keys(states[1]).sort().join("\0"))
|
|
14728
15006
|
return found("SKILLS_SPLIT_LAYOUT", void 0, { value: count });
|
|
14729
|
-
return pass(`${count} \u4E2A\u6280\u80FD\uFF08\u4E24\u4EFD\u9501\u6587\u4EF6 skills \u952E\u7684\u5E76\u96C6\uFF09\uFF1B${states.map((s) =>
|
|
15007
|
+
return pass(`${count} \u4E2A\u6280\u80FD\uFF08\u4E24\u4EFD\u9501\u6587\u4EF6 skills \u952E\u7684\u5E76\u96C6\uFF09\uFF1B${states.map((s) => path14.relative(ctx.root, s.baseDir)).join("\u3001")}`, { value: count });
|
|
14730
15008
|
} catch (error) {
|
|
14731
15009
|
return unknown("SKILLS_STATE_UNREADABLE", void 0, {
|
|
14732
15010
|
note: `${reading}\uFF1A${safeError(error)}\uFF1B\u5148\u4FEE\u590D\u9501\u6587\u4EF6 JSON \u6216\u8BFB\u53D6\u6743\u9650\uFF08\u53EF\u4ECE\u5907\u4EFD\u6062\u590D\uFF09\uFF0C\u518D\u6309\u4E0B\u4E00\u6B65\u540C\u6B65\u5E76\u91CD\u8DD1\u4F53\u68C0`
|
|
@@ -14742,7 +15020,7 @@ function hasProductSkills(states) {
|
|
|
14742
15020
|
}
|
|
14743
15021
|
async function inspectSkillsFresh(states, endpoint, signal) {
|
|
14744
15022
|
if (!hasProductSkills(states)) return { level: "NOT_APPLICABLE", summary: NO_PRODUCT_SKILLS, note: "\u672A\u8BF7\u6C42\u6280\u80FD\u76EE\u5F55" };
|
|
14745
|
-
const http =
|
|
15023
|
+
const http = axios6.create({
|
|
14746
15024
|
baseURL: endpoint,
|
|
14747
15025
|
timeout: 5e3,
|
|
14748
15026
|
maxRedirects: 0,
|
|
@@ -14792,7 +15070,7 @@ var boundary = async (ctx) => {
|
|
|
14792
15070
|
for (const name of ["AGENTS.md", "CLAUDE.md"]) {
|
|
14793
15071
|
let text;
|
|
14794
15072
|
try {
|
|
14795
|
-
text = await
|
|
15073
|
+
text = await fs12.readFile(path14.join(ctx.root, name), "utf8");
|
|
14796
15074
|
} catch (error) {
|
|
14797
15075
|
if (error.code === "ENOENT") continue;
|
|
14798
15076
|
throw error;
|
|
@@ -14840,11 +15118,11 @@ var localChecks = { project, credential, version, installed, fresh, boundary, me
|
|
|
14840
15118
|
|
|
14841
15119
|
// src/commands/doctor/connect-checks.ts
|
|
14842
15120
|
init_auth_guard();
|
|
14843
|
-
import
|
|
14844
|
-
import { CliError as
|
|
15121
|
+
import axios8 from "axios";
|
|
15122
|
+
import { CliError as CliError32, IMPERSONATION_START_PATH, USER_LOOKUP_PATH, probeDoctorEndpoint, probeDoctorLayer, layerDetail, toPrincipal as toPrincipal3 } from "@hcmai/sdk";
|
|
14845
15123
|
|
|
14846
15124
|
// src/commands/doctor/server-report.ts
|
|
14847
|
-
import
|
|
15125
|
+
import axios7 from "axios";
|
|
14848
15126
|
import { classifyStatus } from "@hcmai/sdk";
|
|
14849
15127
|
var optionalText2 = (value) => value === void 0 || value === null || typeof value === "string";
|
|
14850
15128
|
var fullScope = { stage: null, only: [], skip: [], active: false };
|
|
@@ -14878,7 +15156,7 @@ var requestServerReport = async (endpoint, token, timeoutMs, budgetMs, signal, s
|
|
|
14878
15156
|
...scope.only.length ? { only: scope.only.join(",") } : {},
|
|
14879
15157
|
...scope.skip.length ? { skip: scope.skip.join(",") } : {}
|
|
14880
15158
|
};
|
|
14881
|
-
const res = scope.active ? await
|
|
15159
|
+
const res = scope.active ? await axios7.post("/api/system/health/report", { active: true, budgetMs, ...range }, options) : await axios7.get("/api/system/health/report", { ...options, params: { budgetMs, ...range } });
|
|
14882
15160
|
return {
|
|
14883
15161
|
status: res.status,
|
|
14884
15162
|
body: res.data,
|
|
@@ -14887,7 +15165,7 @@ var requestServerReport = async (endpoint, token, timeoutMs, budgetMs, signal, s
|
|
|
14887
15165
|
};
|
|
14888
15166
|
};
|
|
14889
15167
|
function stoppedWaiting(error, signal) {
|
|
14890
|
-
return signal.aborted ||
|
|
15168
|
+
return signal.aborted || axios7.isAxiosError(error) && error.code === "ECONNABORTED";
|
|
14891
15169
|
}
|
|
14892
15170
|
function httpNote(out) {
|
|
14893
15171
|
return `HTTP ${out.status < 0 ? "\u672A\u53D6\u5F97\u54CD\u5E94" : out.status}${out.headers["x-trace-id"] ? ` \xB7 traceId=${out.headers["x-trace-id"]}` : ""}`;
|
|
@@ -15194,8 +15472,8 @@ var identity = async (ctx, env2, execution) => {
|
|
|
15194
15472
|
if (execution.signal.aborted) await e.close?.();
|
|
15195
15473
|
return observation;
|
|
15196
15474
|
} catch (error) {
|
|
15197
|
-
const detail = error instanceof
|
|
15198
|
-
const errorCode = error instanceof
|
|
15475
|
+
const detail = error instanceof CliError32 ? error.context : void 0;
|
|
15476
|
+
const errorCode = error instanceof CliError32 ? error.code : void 0;
|
|
15199
15477
|
const actorStep = error !== null && typeof error === "object" ? error[AS_ACTOR_STEP] : void 0;
|
|
15200
15478
|
if (actorStep) {
|
|
15201
15479
|
const actorCode = actorStep === "meta" || actorStep === "env" ? "IDENTITY_META_INVALID" : actorStep === "resolve" && errorCode === "IDENTITY_NOT_FOUND" ? "IDENTITY_NOT_LOGGED_IN" : "IDENTITY_UNVERIFIED";
|
|
@@ -15205,11 +15483,11 @@ var identity = async (ctx, env2, execution) => {
|
|
|
15205
15483
|
const code3 = detail.mismatch === "tenant" ? "TENANT_MISMATCH" : "IDENTITY_USER_MISMATCH";
|
|
15206
15484
|
return found(code3, void 0, { note: `\u4EE3\u7406\u524D\u6838\u9A8C\u64CD\u4F5C\u8005\u65F6\u53D1\u73B0\u4E3B\u4F53\u4E0D\u7B26\uFF1A${safeError(error)}` });
|
|
15207
15485
|
}
|
|
15208
|
-
const status =
|
|
15209
|
-
const requestPath =
|
|
15486
|
+
const status = axios8.isAxiosError(error) ? error.response?.status : void 0;
|
|
15487
|
+
const requestPath = axios8.isAxiosError(error) ? error.config?.url ?? "" : "";
|
|
15210
15488
|
const proxyStart = requestPath.endsWith(IMPERSONATION_START_PATH);
|
|
15211
15489
|
const userLookup = requestPath.endsWith(USER_LOOKUP_PATH);
|
|
15212
|
-
const envelope =
|
|
15490
|
+
const envelope = axios8.isAxiosError(error) && obj(error.response?.data) && obj(error.response.data.error) ? error.response.data.error : void 0;
|
|
15213
15491
|
const targetMissing = status === 404 && proxyStart && envelope?.code === "NOT_FOUND";
|
|
15214
15492
|
const targetAdvice = envelope?.details === "\u76EE\u6807\u7528\u6237\u4E0D\u5B58\u5728" ? "\u670D\u52A1\u7AEF\uFF1A\u76EE\u6807\u7528\u6237\u4E0D\u5B58\u5728\uFF1B\u6838\u5BF9\u5F53\u524D\u79DF\u6237\u4E0E\u76EE\u6807\u7528\u6237 UUID" : "\u670D\u52A1\u7AEF\u56DE 404 NOT_FOUND\uFF0C\u672A\u6307\u660E\u76EE\u6807\u7528\u6237\u4E0D\u5B58\u5728\uFF08\u4E5F\u53EF\u80FD\u662F\u540E\u7AEF\u6CA1\u6709\u4EE3\u7406\u63A5\u53E3\uFF09\uFF1B\u6838\u5BF9\u5F53\u524D\u79DF\u6237\u4E0E\u76EE\u6807\u7528\u6237 UUID\uFF0C\u5E76\u6838\u540E\u7AEF\u7248\u672C";
|
|
15215
15493
|
const code2 = status === 403 || targetMissing || errorCode && ["SCOPE_FORBIDDEN", "IDENTITY_NOT_FOUND", "INVALID_ARGUMENT", "IDENTITY_NOT_IN_ENV", "IDENTITY_META_INCOMPLETE"].includes(errorCode) ? "AS_PROXY_DENIED" : errorCode === "AUTH_FAILED" ? "IDENTITY_NOT_LOGGED_IN" : status === 401 ? "TOKEN_REJECTED" : "IDENTITY_UNVERIFIED";
|
|
@@ -15485,8 +15763,8 @@ async function executeChecks(ctx, options = {}) {
|
|
|
15485
15763
|
let timer;
|
|
15486
15764
|
let proxy = false;
|
|
15487
15765
|
let expire;
|
|
15488
|
-
const timeout = new Promise((
|
|
15489
|
-
expire =
|
|
15766
|
+
const timeout = new Promise((resolve4) => {
|
|
15767
|
+
expire = resolve4;
|
|
15490
15768
|
});
|
|
15491
15769
|
const arm = (ms) => {
|
|
15492
15770
|
clearTimeout(timer);
|
|
@@ -15773,11 +16051,11 @@ function renderChironDoctor(report) {
|
|
|
15773
16051
|
|
|
15774
16052
|
// src/commands/doctor/platform-ops.ts
|
|
15775
16053
|
import { createHash as createHash8 } from "crypto";
|
|
15776
|
-
import
|
|
16054
|
+
import axios9 from "axios";
|
|
15777
16055
|
import {
|
|
15778
16056
|
classifyStatus as classifyStatus2,
|
|
15779
|
-
CliError as
|
|
15780
|
-
CliErrorCode as
|
|
16057
|
+
CliError as CliError33,
|
|
16058
|
+
CliErrorCode as CliErrorCode34,
|
|
15781
16059
|
loadGlobalConfig as loadGlobalConfig11,
|
|
15782
16060
|
printResolvedEnvironment as printResolvedEnvironment8,
|
|
15783
16061
|
resolveEnvContext as resolveEnvContext8
|
|
@@ -15843,7 +16121,7 @@ var placeholder = {
|
|
|
15843
16121
|
};
|
|
15844
16122
|
var OPS_DESCRIPTORS = [connectivity2, api, placeholder];
|
|
15845
16123
|
var requestOpsReport = async (endpoint, key2, timeoutMs, budgetMs, signal, scope) => {
|
|
15846
|
-
const res = await
|
|
16124
|
+
const res = await axios9.get(OPS_PATH, {
|
|
15847
16125
|
baseURL: endpoint,
|
|
15848
16126
|
timeout: timeoutMs,
|
|
15849
16127
|
signal,
|
|
@@ -15885,11 +16163,11 @@ async function readPlatformOpsKey(args, io = {
|
|
|
15885
16163
|
} else if (io.isTTY) {
|
|
15886
16164
|
source = "tty";
|
|
15887
16165
|
key2 = await io.prompt();
|
|
15888
|
-
} else throw new
|
|
16166
|
+
} else throw new CliError33({ code: CliErrorCode34.INVALID_ARGUMENT, message: blank ? "HCM_PLATFORM_OPS_KEY \u5DF2\u8BBE\u7F6E\u4F46\u5168\u662F\u7A7A\u767D\uFF0C\u5DF2\u5FFD\u7565\uFF1A\u628A\u5BC6\u94A5\u5199\u8FDB\u8BE5\u53D8\u91CF\u3001\u4F7F\u7528 --platform-ops-key-stdin\uFF0C\u6216\u5728 TTY \u4EA4\u4E92\u8F93\u5165" : "\u7F3A\u5C11\u8FD0\u7EF4\u5BC6\u94A5\uFF1A\u8BBE\u7F6E HCM_PLATFORM_OPS_KEY\u3001\u4F7F\u7528 --platform-ops-key-stdin\uFF0C\u6216\u5728 TTY \u4EA4\u4E92\u8F93\u5165" });
|
|
15889
16167
|
if (blank) io.stderr(`HCM_PLATFORM_OPS_KEY \u5168\u662F\u7A7A\u767D\uFF0C\u5DF2\u5FFD\u7565\uFF1B\u6539\u4ECE ${source} \u8BFB\u53D6
|
|
15890
16168
|
`);
|
|
15891
16169
|
key2 = key2.trim();
|
|
15892
|
-
if (!key2) throw new
|
|
16170
|
+
if (!key2) throw new CliError33({ code: CliErrorCode34.INVALID_ARGUMENT, message: "\u8FD0\u7EF4\u5BC6\u94A5\u4E3A\u7A7A" });
|
|
15893
16171
|
io.stderr(`\u8FD0\u7EF4\u5BC6\u94A5\u6765\u6E90\uFF1A${source} \xB7 \u6307\u7EB9 ${opsKeyFingerprint(key2)}
|
|
15894
16172
|
`);
|
|
15895
16173
|
return { key: key2, source };
|
|
@@ -15898,12 +16176,12 @@ var split = (value) => (Array.isArray(value) ? value : value ? [value] : []).fla
|
|
|
15898
16176
|
function scopeFor(args) {
|
|
15899
16177
|
const only = split(args.only), skip = split(args.skip);
|
|
15900
16178
|
for (const token of [...only, ...skip]) if (!("platform.".startsWith(token) || token.startsWith("platform.")))
|
|
15901
|
-
throw new
|
|
15902
|
-
code:
|
|
16179
|
+
throw new CliError33({
|
|
16180
|
+
code: CliErrorCode34.INVALID_ARGUMENT,
|
|
15903
16181
|
message: `\u8FD0\u7EF4\u89C6\u56FE\u53EA\u770B\u5E73\u53F0\u5C42\uFF1A--only / --skip \u53EA\u63A5\u53D7 platform \u524D\u7F00\uFF0C\u6536\u5230 ${token}`
|
|
15904
16182
|
});
|
|
15905
|
-
if (skip.some((token) => "platform.".startsWith(token))) throw new
|
|
15906
|
-
code:
|
|
16183
|
+
if (skip.some((token) => "platform.".startsWith(token))) throw new CliError33({
|
|
16184
|
+
code: CliErrorCode34.INVALID_ARGUMENT,
|
|
15907
16185
|
message: "\u6392\u9664\u4E86\u5E73\u53F0\u5C42\uFF0C\u8FD0\u7EF4\u89C6\u56FE\u6CA1\u6709\u53EF\u770B\u7684\u68C0\u67E5"
|
|
15908
16186
|
});
|
|
15909
16187
|
return {
|
|
@@ -16059,7 +16337,7 @@ function failure(ctx, env2, health, key2) {
|
|
|
16059
16337
|
}
|
|
16060
16338
|
var ENV_HINT = "hcm env list \u67E5\u770B\u53EF\u9009\u73AF\u5883\uFF1Bhcm env add <\u540D> --endpoint <url> \u767B\u8BB0";
|
|
16061
16339
|
function resolverMessage(error) {
|
|
16062
|
-
if (error instanceof
|
|
16340
|
+
if (error instanceof CliError33 && error.code === CliErrorCode34.NO_ACTIVE_ENV) return "\u672A\u9009\u5B9A\u73AF\u5883\uFF1A\u7528 --env <\u540D> \u6307\u5B9A";
|
|
16063
16341
|
return (error instanceof Error ? error.message : safeError(error)).replace(/\s*(&&\s*)?hcm\s+login\b[^;;\n]*/gi, "");
|
|
16064
16342
|
}
|
|
16065
16343
|
async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onReport) {
|
|
@@ -16068,10 +16346,10 @@ async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onRe
|
|
|
16068
16346
|
try {
|
|
16069
16347
|
resolved = await resolveEnvContext8({ envFlag: args.env }, process.env, await loadGlobalConfig11());
|
|
16070
16348
|
} catch (error2) {
|
|
16071
|
-
throw new
|
|
16349
|
+
throw new CliError33({ code: CliErrorCode34.INVALID_ARGUMENT, message: `${resolverMessage(error2)}\uFF1B${ENV_HINT}` });
|
|
16072
16350
|
}
|
|
16073
|
-
if (!resolved.config.endpoint) throw new
|
|
16074
|
-
code:
|
|
16351
|
+
if (!resolved.config.endpoint) throw new CliError33({
|
|
16352
|
+
code: CliErrorCode34.INVALID_ARGUMENT,
|
|
16075
16353
|
message: `\u672A\u89E3\u6790\u5230 endpoint\uFF1B${ENV_HINT}`
|
|
16076
16354
|
});
|
|
16077
16355
|
printResolvedEnvironment8(resolved);
|
|
@@ -16117,8 +16395,8 @@ async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onRe
|
|
|
16117
16395
|
const error = out && object(out.body) && object(out.body.error) ? out.body.error : void 0;
|
|
16118
16396
|
if (out?.status === 400 && error?.code === "HEALTH_REPORT_INVALID_PARAM") {
|
|
16119
16397
|
const trace = out.headers["x-trace-id"];
|
|
16120
|
-
throw new
|
|
16121
|
-
code:
|
|
16398
|
+
throw new CliError33({
|
|
16399
|
+
code: CliErrorCode34.INVALID_ARGUMENT,
|
|
16122
16400
|
message: `${typeof error.message === "string" ? redact(error.message, key2) : "\u8FD0\u7EF4\u68C0\u67E5\u8303\u56F4\u65E0\u6548"}${scope.only.length || scope.skip.length ? "\uFF1B\u53BB\u6389 --only / --skip \u91CD\u8DD1 hcm chiron doctor --platform-ops \u53EF\u770B\u5230\u5168\u90E8\u5E73\u53F0\u68C0\u67E5" : `\uFF1B\u672C\u6B21\u6CA1\u6709\u5E26 --only / --skip\uFF0C\u53C2\u6570\u4ECD\u88AB\u5224\u65E0\u6548\uFF0C\u5C5E\u670D\u52A1\u7AEF\u7F3A\u9677\uFF1A\u9644 traceId ${trace || "\uFF08\u54CD\u5E94\u672A\u5E26\uFF0C\u9644\u672C\u6B21\u65F6\u95F4\u4E0E\u73AF\u5883\u540D\uFF09"} \u8054\u7CFB\u7814\u53D1`}`
|
|
16123
16401
|
});
|
|
16124
16402
|
}
|
|
@@ -16410,7 +16688,7 @@ var defaultServices = {
|
|
|
16410
16688
|
latestVersion: fetchLatestVersion,
|
|
16411
16689
|
skillsFresh: inspectSkillsFresh,
|
|
16412
16690
|
asAuth: (...args) => ensureAsAuth(...args),
|
|
16413
|
-
probe: (endpoint, token, signal) => httpProbe2(
|
|
16691
|
+
probe: (endpoint, token, signal) => httpProbe2(axios10.create({
|
|
16414
16692
|
baseURL: endpoint,
|
|
16415
16693
|
timeout: 5e3,
|
|
16416
16694
|
maxRedirects: 0,
|
|
@@ -16421,13 +16699,13 @@ var defaultServices = {
|
|
|
16421
16699
|
};
|
|
16422
16700
|
function validate(args) {
|
|
16423
16701
|
for (const [key2, value, choices] of [["output", args.output, ["table", "json", "yaml"]], ["fail-on", args.failOn, ["blocked", "risks"]]])
|
|
16424
|
-
if (value !== void 0 && !choices.includes(value)) throw new
|
|
16425
|
-
code:
|
|
16702
|
+
if (value !== void 0 && !choices.includes(value)) throw new CliError34({
|
|
16703
|
+
code: CliErrorCode35.INVALID_ARGUMENT,
|
|
16426
16704
|
message: `--${key2} \u53EA\u63A5\u53D7 ${choices.join(" / ")}\uFF0C\u6536\u5230 ${value}`
|
|
16427
16705
|
});
|
|
16428
16706
|
const stages = ["handover", "baseline", "configure", "migrate", "integrate", "golive", "operate"];
|
|
16429
|
-
if (args.stage !== void 0 && !stages.includes(args.stage.toLowerCase())) throw new
|
|
16430
|
-
code:
|
|
16707
|
+
if (args.stage !== void 0 && !stages.includes(args.stage.toLowerCase())) throw new CliError34({
|
|
16708
|
+
code: CliErrorCode35.INVALID_ARGUMENT,
|
|
16431
16709
|
message: `--stage \u53EA\u63A5\u53D7 ${stages.join(" / ")}\uFF0C\u6536\u5230 ${args.stage}`
|
|
16432
16710
|
});
|
|
16433
16711
|
if (args.platformOpsKeyStdin && !args.platformOps) invalidScope("--platform-ops-key-stdin \u53EA\u80FD\u4E0E --platform-ops \u540C\u7528");
|
|
@@ -16448,7 +16726,7 @@ var tokens = (value) => (Array.isArray(value) ? value : value ? [value] : []).fl
|
|
|
16448
16726
|
var matches = (id, only, skip) => (!only.length || only.some((t) => id.startsWith(t))) && !skip.some((t) => id.startsWith(t));
|
|
16449
16727
|
var serverCandidate = (t) => ["platform.", "tenant."].some((prefix) => prefix.startsWith(t) || t.startsWith(prefix));
|
|
16450
16728
|
function invalidScope(message) {
|
|
16451
|
-
throw new
|
|
16729
|
+
throw new CliError34({ code: CliErrorCode35.INVALID_ARGUMENT, message });
|
|
16452
16730
|
}
|
|
16453
16731
|
function scopeFor2(args, catalog) {
|
|
16454
16732
|
const only = tokens(args.only), skip = tokens(args.skip), stage = args.stage?.toLowerCase() ?? null;
|
|
@@ -16483,7 +16761,7 @@ async function readCredential(envFlag, root, as) {
|
|
|
16483
16761
|
try {
|
|
16484
16762
|
resolved = await resolveEnvContext9({ envFlag, cwd: root }, process.env, await loadGlobalConfig12());
|
|
16485
16763
|
} catch (error) {
|
|
16486
|
-
if (error instanceof
|
|
16764
|
+
if (error instanceof CliError34 && error.code === CliErrorCode35.ENV_NOT_FOUND) return { resolved: null };
|
|
16487
16765
|
throw error;
|
|
16488
16766
|
}
|
|
16489
16767
|
if (as) return { resolved };
|
|
@@ -16492,14 +16770,14 @@ async function readCredential(envFlag, root, as) {
|
|
|
16492
16770
|
try {
|
|
16493
16771
|
identity3 = await resolveActiveIdentity2({}, process.env, resolved.name);
|
|
16494
16772
|
} catch (error) {
|
|
16495
|
-
if (error instanceof
|
|
16773
|
+
if (error instanceof CliError34 && error.code === CliErrorCode35.IDENTITY_NOT_FOUND) return { resolved, error: found("IDENTITY_NOT_LOGGED_IN") };
|
|
16496
16774
|
throw error;
|
|
16497
16775
|
}
|
|
16498
16776
|
let meta2;
|
|
16499
16777
|
try {
|
|
16500
16778
|
meta2 = await loadIdentity5(identity3);
|
|
16501
16779
|
} catch (error) {
|
|
16502
|
-
if (error instanceof
|
|
16780
|
+
if (error instanceof CliError34 && error.code === CliErrorCode35.IDENTITY_NOT_FOUND) return { resolved, identity: identity3, error: found("IDENTITY_META_INVALID", `\u8EAB\u4EFD ${identity3} \u7684\u5143\u6570\u636E\u4E0D\u5B58\u5728\uFF1B\u91CD\u65B0\u767B\u5F55\u4FEE\u590D`) };
|
|
16503
16781
|
throw error;
|
|
16504
16782
|
}
|
|
16505
16783
|
if (!meta2.env || meta2.env !== resolved.name) return {
|
|
@@ -16513,11 +16791,11 @@ async function readCredential(envFlag, root, as) {
|
|
|
16513
16791
|
return { resolved, identity: identity3, meta: meta2, token };
|
|
16514
16792
|
}
|
|
16515
16793
|
async function prepareContext(args, deps) {
|
|
16516
|
-
const startedAt = Date.now(), root =
|
|
16794
|
+
const startedAt = Date.now(), root = path15.resolve(args.project ?? ".");
|
|
16517
16795
|
let file;
|
|
16518
16796
|
let projectObservation = found("ENV_FILE_MISSING", void 0, { evidence: "ABSENT" });
|
|
16519
16797
|
try {
|
|
16520
|
-
const text = await
|
|
16798
|
+
const text = await fs13.readFile(path15.join(root, "env.yaml"), "utf8");
|
|
16521
16799
|
try {
|
|
16522
16800
|
file = parseEnvYaml3(text);
|
|
16523
16801
|
projectObservation = pass("env.yaml \u53EF\u89E3\u6790");
|
|
@@ -16533,7 +16811,7 @@ async function prepareContext(args, deps) {
|
|
|
16533
16811
|
if (args.env && (!file || !Object.hasOwn(file.environments, args.env))) {
|
|
16534
16812
|
try {
|
|
16535
16813
|
const resolved = await resolveEnvContext9({ envFlag: args.env, cwd: root }, process.env, await loadGlobalConfig12());
|
|
16536
|
-
if (resolved.project?.path !==
|
|
16814
|
+
if (resolved.project?.path !== path15.join(root, "env.yaml")) throw new Error("\u672C\u673A\u69FD\u4E0D\u5C5E\u4E8E\u5F53\u524D\u9879\u76EE");
|
|
16537
16815
|
targetEnv = resolved.project.name;
|
|
16538
16816
|
explicitSlot = resolved.name;
|
|
16539
16817
|
} catch (error) {
|
|
@@ -16541,7 +16819,7 @@ async function prepareContext(args, deps) {
|
|
|
16541
16819
|
const detail = `${safeError(error)}\uFF1B\u53EF\u9009\u73AF\u5883\uFF1A${available.join(", ") || "\uFF08\u65E0\uFF09"}`;
|
|
16542
16820
|
projectObservation = found("ENV_NOT_RESOLVED", detail);
|
|
16543
16821
|
targetEnv = null;
|
|
16544
|
-
const slotMissing = error instanceof
|
|
16822
|
+
const slotMissing = error instanceof CliError34 && error.code === CliErrorCode35.ENV_NOT_FOUND;
|
|
16545
16823
|
const project2 = args.project !== void 0 ? ` --project ${quote(root)}` : "";
|
|
16546
16824
|
const step2 = file ? `hcm chiron env add ${quote(args.env)} --endpoint <\u540E\u7AEF\u5730\u5740> --frontend <\u524D\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>${project2}` : slotMissing ? `hcm chiron init --env ${quote(args.env)} --endpoint <\u540E\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>${project2}` : `hcm chiron init --env ${quote(args.env)}${project2}`;
|
|
16547
16825
|
if (slotMissing || error instanceof Error && error.message === "\u672C\u673A\u69FD\u4E0D\u5C5E\u4E8E\u5F53\u524D\u9879\u76EE")
|
|
@@ -16709,12 +16987,12 @@ async function chironDoctorCommand(args, deps) {
|
|
|
16709
16987
|
}
|
|
16710
16988
|
}
|
|
16711
16989
|
const data = explainOpsCatalog(args.explain, descriptorReport);
|
|
16712
|
-
process.stdout.write((args.output === "json" || args.output === "yaml" ?
|
|
16990
|
+
process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject30(data, { format: args.output }) : renderCatalogExplanation(data)) + "\n");
|
|
16713
16991
|
process.exitCode = 0;
|
|
16714
16992
|
return;
|
|
16715
16993
|
}
|
|
16716
16994
|
const report2 = await runPlatformOps(args, { ...defaultServices, ...deps });
|
|
16717
|
-
process.stdout.write((args.output === "json" || args.output === "yaml" ?
|
|
16995
|
+
process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject30(report2, { format: args.output }) : renderChironDoctor(report2)) + "\n");
|
|
16718
16996
|
process.exitCode = conclude(report2.results, { total: report2.coverage.total, failOn: args.failOn ?? "blocked" }).exitCode;
|
|
16719
16997
|
return;
|
|
16720
16998
|
}
|
|
@@ -16726,12 +17004,12 @@ async function chironDoctorCommand(args, deps) {
|
|
|
16726
17004
|
if (!listing.server.known) process.stderr.write(`\u670D\u52A1\u7AEF\u76EE\u5F55${"partial" in listing.server ? "\u4E0D\u5168" : "\u672A\u53D6\u5230"}\uFF1A${listing.server.reason}
|
|
16727
17005
|
`);
|
|
16728
17006
|
}
|
|
16729
|
-
process.stdout.write((args.output === "json" || args.output === "yaml" ?
|
|
17007
|
+
process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject30(data, { format: args.output }) : args.list ? renderCatalogList(data) : renderCatalogExplanation(data)) + "\n");
|
|
16730
17008
|
process.exitCode = 0;
|
|
16731
17009
|
return;
|
|
16732
17010
|
}
|
|
16733
17011
|
const report = await runChironDoctor(args, deps);
|
|
16734
|
-
process.stdout.write((args.output === "json" || args.output === "yaml" ?
|
|
17012
|
+
process.stdout.write((args.output === "json" || args.output === "yaml" ? formatObject30(report, { format: args.output }) : renderChironDoctor(report)) + "\n");
|
|
16735
17013
|
process.exitCode = conclude(report.results, {
|
|
16736
17014
|
total: report.coverage.total,
|
|
16737
17015
|
failOn: args.failOn ?? "blocked",
|
|
@@ -16749,14 +17027,14 @@ init_auth_guard();
|
|
|
16749
17027
|
init_exit();
|
|
16750
17028
|
import { spawnSync } from "child_process";
|
|
16751
17029
|
import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
|
|
16752
|
-
import
|
|
17030
|
+
import fs14 from "fs/promises";
|
|
16753
17031
|
import os6 from "os";
|
|
16754
|
-
import
|
|
16755
|
-
import { CliError as
|
|
17032
|
+
import path17 from "path";
|
|
17033
|
+
import { CliError as CliError37, CliErrorCode as CliErrorCode38, formatObject as formatObject31, HcmClient as HcmClient25, loadEnv as loadEnv6 } from "@hcmai/sdk";
|
|
16756
17034
|
import { createRequire } from "module";
|
|
16757
17035
|
|
|
16758
17036
|
// src/commands/chiron-page-cdp.ts
|
|
16759
|
-
import { CliError as
|
|
17037
|
+
import { CliError as CliError35, CliErrorCode as CliErrorCode36 } from "@hcmai/sdk";
|
|
16760
17038
|
|
|
16761
17039
|
// src/commands/chiron-page-shared.ts
|
|
16762
17040
|
function redactTicket(text) {
|
|
@@ -16792,14 +17070,14 @@ function normalizeCdpEndpoint(raw) {
|
|
|
16792
17070
|
try {
|
|
16793
17071
|
url = new URL(candidate);
|
|
16794
17072
|
} catch {
|
|
16795
|
-
throw new
|
|
17073
|
+
throw new CliError35({ code: CliErrorCode36.INVALID_ARGUMENT, message: `--cdp \u8981\u5199\u6210 http://\u4E3B\u673A:\u7AEF\u53E3\uFF08Chrome \u7684 --remote-debugging-port\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
|
|
16796
17074
|
}
|
|
16797
17075
|
const protocol = url.protocol === "wss:" ? "https:" : url.protocol === "ws:" ? "http:" : url.protocol;
|
|
16798
17076
|
if (protocol !== "http:" && protocol !== "https:") {
|
|
16799
|
-
throw new
|
|
17077
|
+
throw new CliError35({ code: CliErrorCode36.INVALID_ARGUMENT, message: `--cdp \u53EA\u8BA4 http(s) \u6216 ws(s) \u7AEF\u70B9\uFF0C\u6536\u5230\u7684\u662F ${text}` });
|
|
16800
17078
|
}
|
|
16801
17079
|
if (!url.port) {
|
|
16802
|
-
throw new
|
|
17080
|
+
throw new CliError35({ code: CliErrorCode36.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}` });
|
|
16803
17081
|
}
|
|
16804
17082
|
return `${protocol}//${url.hostname}:${url.port}`;
|
|
16805
17083
|
}
|
|
@@ -16818,8 +17096,8 @@ var CdpSession = class {
|
|
|
16818
17096
|
send(method3, params = {}) {
|
|
16819
17097
|
if (this.closed) return Promise.reject(new Error(`CDP socket \u5DF2\u5173\u95ED\uFF0C\u53D1\u4E0D\u4E86 ${method3}`));
|
|
16820
17098
|
const id = this.nextId++;
|
|
16821
|
-
return new Promise((
|
|
16822
|
-
this.pending.set(id, { resolve:
|
|
17099
|
+
return new Promise((resolve4, reject) => {
|
|
17100
|
+
this.pending.set(id, { resolve: resolve4, reject, method: method3 });
|
|
16823
17101
|
this.socket.send(JSON.stringify({ id, method: method3, params }));
|
|
16824
17102
|
});
|
|
16825
17103
|
}
|
|
@@ -16839,11 +17117,11 @@ var CdpSession = class {
|
|
|
16839
17117
|
}
|
|
16840
17118
|
/** 等一个事件,超时就 reject——「等 load 事件」不能无限等。无论哪种结束都摘掉监听器。 */
|
|
16841
17119
|
waitFor(event, timeoutMs) {
|
|
16842
|
-
return new Promise((
|
|
17120
|
+
return new Promise((resolve4, reject) => {
|
|
16843
17121
|
const off = this.on(event, (params) => {
|
|
16844
17122
|
clearTimeout(timer);
|
|
16845
17123
|
off();
|
|
16846
|
-
|
|
17124
|
+
resolve4(params);
|
|
16847
17125
|
});
|
|
16848
17126
|
const timer = setTimeout(() => {
|
|
16849
17127
|
off();
|
|
@@ -16896,8 +17174,8 @@ async function captureViaCdp(input, io) {
|
|
|
16896
17174
|
const browser = version2?.Browser ? String(version2.Browser) : `attached ${input.endpoint}`;
|
|
16897
17175
|
const target = await io.fetchJson(`${input.endpoint}/json/new?about:blank`, "PUT");
|
|
16898
17176
|
if (!target?.id || !target.webSocketDebuggerUrl) {
|
|
16899
|
-
throw new
|
|
16900
|
-
code:
|
|
17177
|
+
throw new CliError35({
|
|
17178
|
+
code: CliErrorCode36.SERVER_ERROR,
|
|
16901
17179
|
message: `${input.endpoint}/json/new \u6CA1\u6709\u7ED9\u51FA\u6807\u7B7E\u9875\uFF08id / webSocketDebuggerUrl \u7F3A\u5931\uFF09`,
|
|
16902
17180
|
context: { nextStep: "\u786E\u8BA4 Chrome \u662F\u5E26 --remote-debugging-port \u8D77\u7684\uFF0C\u4E14 --cdp \u6307\u5230\u7684\u662F\u5B83" }
|
|
16903
17181
|
});
|
|
@@ -16927,7 +17205,7 @@ async function captureViaCdp(input, io) {
|
|
|
16927
17205
|
});
|
|
16928
17206
|
if (r.exceptionDetails) {
|
|
16929
17207
|
const why = r.exceptionDetails.exception?.description ?? r.exceptionDetails.text ?? "unknown";
|
|
16930
|
-
throw new
|
|
17208
|
+
throw new CliError35({ code: CliErrorCode36.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why.split("\n")[0] ?? why)}` });
|
|
16931
17209
|
}
|
|
16932
17210
|
evalResult = r.result && "value" in r.result ? toPlainJson(r.result.value) : toPlainJson(r.result?.description);
|
|
16933
17211
|
}
|
|
@@ -16938,7 +17216,7 @@ async function captureViaCdp(input, io) {
|
|
|
16938
17216
|
const dom = typeof domReply.result?.value === "string" ? domReply.result.value : "";
|
|
16939
17217
|
const shot = await session.send("Page.captureScreenshot", { format: "png" });
|
|
16940
17218
|
if (!shot.data) {
|
|
16941
|
-
throw new
|
|
17219
|
+
throw new CliError35({ code: CliErrorCode36.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
|
|
16942
17220
|
}
|
|
16943
17221
|
await io.writeFile(input.screenshot, Buffer.from(shot.data, "base64"));
|
|
16944
17222
|
return { dom, browser, evalResult, navigated, minted };
|
|
@@ -16957,17 +17235,17 @@ var defaultCdpIo = {
|
|
|
16957
17235
|
const text = await res.text();
|
|
16958
17236
|
return text ? JSON.parse(text) : null;
|
|
16959
17237
|
},
|
|
16960
|
-
openSocket: (wsUrl) => new Promise((
|
|
17238
|
+
openSocket: (wsUrl) => new Promise((resolve4, reject) => {
|
|
16961
17239
|
const Ctor = globalThis.WebSocket;
|
|
16962
17240
|
if (!Ctor) {
|
|
16963
|
-
reject(new
|
|
17241
|
+
reject(new CliError35({ code: CliErrorCode36.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" }));
|
|
16964
17242
|
return;
|
|
16965
17243
|
}
|
|
16966
17244
|
const ws = new Ctor(wsUrl);
|
|
16967
17245
|
const timer = setTimeout(() => reject(new Error(`\u8FDE ${wsUrl} \u8D85\u8FC7 ${CDP_IO_TIMEOUT_MS}ms \u6CA1\u63E1\u4E0A\u624B`)), CDP_IO_TIMEOUT_MS);
|
|
16968
17246
|
ws.addEventListener("open", () => {
|
|
16969
17247
|
clearTimeout(timer);
|
|
16970
|
-
|
|
17248
|
+
resolve4(ws);
|
|
16971
17249
|
});
|
|
16972
17250
|
ws.addEventListener("error", (ev) => {
|
|
16973
17251
|
clearTimeout(timer);
|
|
@@ -16975,24 +17253,24 @@ var defaultCdpIo = {
|
|
|
16975
17253
|
});
|
|
16976
17254
|
}),
|
|
16977
17255
|
writeFile: async (file, bytes) => {
|
|
16978
|
-
const
|
|
16979
|
-
await
|
|
17256
|
+
const fs16 = await import("fs/promises");
|
|
17257
|
+
await fs16.writeFile(file, bytes);
|
|
16980
17258
|
},
|
|
16981
17259
|
sleep: (ms) => new Promise((r) => setTimeout(r, ms))
|
|
16982
17260
|
};
|
|
16983
17261
|
|
|
16984
17262
|
// src/commands/chiron-page-playwright.ts
|
|
16985
|
-
import
|
|
16986
|
-
import { CliError as
|
|
17263
|
+
import path16 from "path";
|
|
17264
|
+
import { CliError as CliError36, CliErrorCode as CliErrorCode37 } from "@hcmai/sdk";
|
|
16987
17265
|
function playwrightCacheRoot(probe2) {
|
|
16988
17266
|
const override = probe2.env.PLAYWRIGHT_BROWSERS_PATH?.trim();
|
|
16989
|
-
if (override === "0" && probe2.packageRoot) return
|
|
16990
|
-
if (override && override !== "0") return
|
|
16991
|
-
if (probe2.platform === "darwin") return
|
|
17267
|
+
if (override === "0" && probe2.packageRoot) return path16.join(probe2.packageRoot, ".local-browsers");
|
|
17268
|
+
if (override && override !== "0") return path16.resolve(override);
|
|
17269
|
+
if (probe2.platform === "darwin") return path16.join(probe2.homedir(), "Library", "Caches", "ms-playwright");
|
|
16992
17270
|
if (probe2.platform === "win32") {
|
|
16993
|
-
return
|
|
17271
|
+
return path16.join(probe2.env.LOCALAPPDATA?.trim() || path16.join(probe2.homedir(), "AppData", "Local"), "ms-playwright");
|
|
16994
17272
|
}
|
|
16995
|
-
return
|
|
17273
|
+
return path16.join(probe2.env.XDG_CACHE_HOME?.trim() || path16.join(probe2.homedir(), ".cache"), "ms-playwright");
|
|
16996
17274
|
}
|
|
16997
17275
|
function playwrightPlatformTag(probe2) {
|
|
16998
17276
|
const arm = probe2.arch === "arm64";
|
|
@@ -17008,26 +17286,26 @@ function revisionOf(entry, prefix) {
|
|
|
17008
17286
|
function candidateBinaries(probe2, kind) {
|
|
17009
17287
|
const tag = playwrightPlatformTag(probe2);
|
|
17010
17288
|
if (kind === "headless-shell") {
|
|
17011
|
-
return [
|
|
17289
|
+
return [path16.join(`chrome-headless-shell-${tag}`, probe2.platform === "win32" ? "chrome-headless-shell.exe" : "chrome-headless-shell")];
|
|
17012
17290
|
}
|
|
17013
17291
|
if (probe2.platform === "darwin") {
|
|
17014
17292
|
return [
|
|
17015
17293
|
// Playwright ≥ 1.49:Chrome for Testing 的 .app
|
|
17016
|
-
|
|
17294
|
+
path16.join(`chrome-${tag}`, "Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing"),
|
|
17017
17295
|
// ≤ 1.48:Chromium.app,目录名不分架构
|
|
17018
|
-
|
|
17019
|
-
|
|
17296
|
+
path16.join("chrome-mac", "Chromium.app", "Contents", "MacOS", "Chromium"),
|
|
17297
|
+
path16.join(`chrome-${tag}`, "Chromium.app", "Contents", "MacOS", "Chromium")
|
|
17020
17298
|
];
|
|
17021
17299
|
}
|
|
17022
|
-
if (probe2.platform === "win32") return [
|
|
17023
|
-
return [
|
|
17300
|
+
if (probe2.platform === "win32") return [path16.join("chrome-win64", "chrome.exe"), path16.join("chrome-win", "chrome.exe")];
|
|
17301
|
+
return [path16.join(`chrome-${tag}`, "chrome"), path16.join("chrome-linux", "chrome")];
|
|
17024
17302
|
}
|
|
17025
17303
|
function discoverPlaywrightBrowser(probe2) {
|
|
17026
17304
|
const explicit = probe2.env.HCM_PLAYWRIGHT_EXECUTABLE?.trim();
|
|
17027
17305
|
if (explicit) {
|
|
17028
17306
|
if (probe2.executable(explicit)) return { executablePath: explicit, kind: "explicit", from: "HCM_PLAYWRIGHT_EXECUTABLE" };
|
|
17029
|
-
throw new
|
|
17030
|
-
code:
|
|
17307
|
+
throw new CliError36({
|
|
17308
|
+
code: CliErrorCode37.INVALID_ARGUMENT,
|
|
17031
17309
|
message: `HCM_PLAYWRIGHT_EXECUTABLE \u6307\u7684\u6587\u4EF6\u4E0D\u53EF\u6267\u884C\uFF1A${explicit}`,
|
|
17032
17310
|
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" }
|
|
17033
17311
|
});
|
|
@@ -17038,8 +17316,8 @@ function discoverPlaywrightBrowser(probe2) {
|
|
|
17038
17316
|
const revisions = entries.map((e) => ({ e, rev: revisionOf(e, prefix) })).filter((x) => x.rev !== null).sort((a, b) => b.rev - a.rev);
|
|
17039
17317
|
for (const { e } of revisions) {
|
|
17040
17318
|
for (const rel of candidateBinaries(probe2, kind)) {
|
|
17041
|
-
const candidate =
|
|
17042
|
-
if (probe2.executable(candidate)) return { executablePath: candidate, kind, from:
|
|
17319
|
+
const candidate = path16.join(root, e, rel);
|
|
17320
|
+
if (probe2.executable(candidate)) return { executablePath: candidate, kind, from: path16.join(root, e) };
|
|
17043
17321
|
}
|
|
17044
17322
|
}
|
|
17045
17323
|
return null;
|
|
@@ -17069,8 +17347,8 @@ async function captureViaPlaywright(input) {
|
|
|
17069
17347
|
}
|
|
17070
17348
|
}
|
|
17071
17349
|
if (!browser) {
|
|
17072
|
-
throw new
|
|
17073
|
-
code:
|
|
17350
|
+
throw new CliError36({
|
|
17351
|
+
code: CliErrorCode37.SERVER_ERROR,
|
|
17074
17352
|
message: `Playwright \u8D77\u4E0D\u4E86\u6D4F\u89C8\u5668\uFF1A${failures.join("\uFF1B")}`,
|
|
17075
17353
|
context: {
|
|
17076
17354
|
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"
|
|
@@ -17090,7 +17368,7 @@ async function captureViaPlaywright(input) {
|
|
|
17090
17368
|
evalResult = toPlainJson(await page.evaluate(wrapEvalBody(input.evalJs)));
|
|
17091
17369
|
} catch (e) {
|
|
17092
17370
|
const why = (e instanceof Error ? e.message : String(e)).split("\n")[0] ?? "";
|
|
17093
|
-
throw new
|
|
17371
|
+
throw new CliError36({ code: CliErrorCode37.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
|
|
17094
17372
|
}
|
|
17095
17373
|
}
|
|
17096
17374
|
const dom = await page.content();
|
|
@@ -17114,13 +17392,13 @@ function judgePageContent(input) {
|
|
|
17114
17392
|
function parseViewport(size) {
|
|
17115
17393
|
const m = /^(\d+)x(\d+)$/.exec(size.trim());
|
|
17116
17394
|
if (!m) {
|
|
17117
|
-
throw new
|
|
17395
|
+
throw new CliError37({ code: CliErrorCode38.INVALID_ARGUMENT, message: `--size \u8981\u5199\u6210 <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900\uFF0C\u6536\u5230\u7684\u662F ${size}` });
|
|
17118
17396
|
}
|
|
17119
17397
|
const width = Number(m[1]);
|
|
17120
17398
|
const height = Number(m[2]);
|
|
17121
17399
|
if (width < VIEWPORT_MIN.width || width > VIEWPORT_MAX.width || height < VIEWPORT_MIN.height || height > VIEWPORT_MAX.height) {
|
|
17122
|
-
throw new
|
|
17123
|
-
code:
|
|
17400
|
+
throw new CliError37({
|
|
17401
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17124
17402
|
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}`
|
|
17125
17403
|
});
|
|
17126
17404
|
}
|
|
@@ -17130,23 +17408,23 @@ function parseWaitMs(raw) {
|
|
|
17130
17408
|
if (raw === void 0) return 1e4;
|
|
17131
17409
|
const value = typeof raw === "number" ? raw : Number(raw);
|
|
17132
17410
|
if (!Number.isInteger(value) || value < 0 || value > WAIT_MS_MAX) {
|
|
17133
|
-
throw new
|
|
17411
|
+
throw new CliError37({ code: CliErrorCode38.INVALID_ARGUMENT, message: `--wait-ms \u8981\u662F 0..${WAIT_MS_MAX} \u7684\u6574\u6570\uFF0C\u6536\u5230\u7684\u662F ${raw}` });
|
|
17134
17412
|
}
|
|
17135
17413
|
return value;
|
|
17136
17414
|
}
|
|
17137
17415
|
function resolveEvidenceTarget(projectRoot, out) {
|
|
17138
17416
|
if (!out?.trim()) {
|
|
17139
|
-
throw new
|
|
17417
|
+
throw new CliError37({ code: CliErrorCode38.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` });
|
|
17140
17418
|
}
|
|
17141
17419
|
if (!out.endsWith(".png")) {
|
|
17142
|
-
throw new
|
|
17420
|
+
throw new CliError37({ code: CliErrorCode38.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
|
|
17143
17421
|
}
|
|
17144
|
-
const root =
|
|
17145
|
-
const evidenceRoot =
|
|
17146
|
-
const absolute =
|
|
17147
|
-
if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot +
|
|
17148
|
-
throw new
|
|
17149
|
-
code:
|
|
17422
|
+
const root = path17.resolve(projectRoot);
|
|
17423
|
+
const evidenceRoot = path17.join(root, EVIDENCE_DIR);
|
|
17424
|
+
const absolute = path17.resolve(root, out);
|
|
17425
|
+
if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path17.sep)) {
|
|
17426
|
+
throw new CliError37({
|
|
17427
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17150
17428
|
message: `--out \u8981\u843D\u5728\u9879\u76EE\u7684 ${EVIDENCE_DIR}/ \u4E0B\uFF08${evidenceRoot}\uFF09\uFF0C\u6536\u5230\u7684\u662F ${absolute}`
|
|
17151
17429
|
});
|
|
17152
17430
|
}
|
|
@@ -17191,11 +17469,11 @@ function findChrome(probe2, override) {
|
|
|
17191
17469
|
}
|
|
17192
17470
|
async function assertInsideEvidence(deps, evidenceRoot, absolute) {
|
|
17193
17471
|
const canonicalRoot = await deps.realpath(evidenceRoot);
|
|
17194
|
-
const canonicalParent = await deps.realpath(
|
|
17472
|
+
const canonicalParent = await deps.realpath(path17.dirname(absolute));
|
|
17195
17473
|
if (canonicalRoot === null || canonicalParent === null) return;
|
|
17196
|
-
if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot +
|
|
17197
|
-
throw new
|
|
17198
|
-
code:
|
|
17474
|
+
if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path17.sep)) {
|
|
17475
|
+
throw new CliError37({
|
|
17476
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17199
17477
|
message: `--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u8DD1\u51FA\u4E86 ${EVIDENCE_DIR}/\uFF1A${canonicalParent}`
|
|
17200
17478
|
});
|
|
17201
17479
|
}
|
|
@@ -17204,23 +17482,23 @@ async function runChironPage(target, args, deps) {
|
|
|
17204
17482
|
const sitePath = normalizeTarget(target);
|
|
17205
17483
|
const expect = (args.expectText ?? []).filter((t) => t.trim().length > 0);
|
|
17206
17484
|
if (expect.length === 0) {
|
|
17207
|
-
throw new
|
|
17208
|
-
code:
|
|
17485
|
+
throw new CliError37({
|
|
17486
|
+
code: CliErrorCode38.MISSING_FLAG,
|
|
17209
17487
|
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"
|
|
17210
17488
|
});
|
|
17211
17489
|
}
|
|
17212
17490
|
const reject = (args.rejectText ?? []).filter((t) => t.trim().length > 0);
|
|
17213
17491
|
const viewport = parseViewport(args.size ?? "1440x900");
|
|
17214
17492
|
const waitMs = parseWaitMs(args.waitMs);
|
|
17215
|
-
const root =
|
|
17493
|
+
const root = path17.resolve(args.project ?? ".");
|
|
17216
17494
|
const { evidenceRoot, absolute } = resolveEvidenceTarget(root, args.out);
|
|
17217
17495
|
if (await deps.present(absolute)) {
|
|
17218
|
-
throw new
|
|
17219
|
-
code:
|
|
17496
|
+
throw new CliError37({
|
|
17497
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17220
17498
|
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`
|
|
17221
17499
|
});
|
|
17222
17500
|
}
|
|
17223
|
-
await deps.ensureDir(
|
|
17501
|
+
await deps.ensureDir(path17.dirname(absolute));
|
|
17224
17502
|
await assertInsideEvidence(deps, evidenceRoot, absolute);
|
|
17225
17503
|
const endpoint = normalizeCdpEndpoint(args.cdp ?? deps.env.HCM_CHROME_CDP);
|
|
17226
17504
|
const evalJs = args.eval?.trim() ? args.eval : void 0;
|
|
@@ -17228,8 +17506,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17228
17506
|
const playwrightBrowser = endpoint || forceSpawn ? null : deps.findPlaywrightBrowser();
|
|
17229
17507
|
const usePlaywright = !endpoint && !forceSpawn && (playwrightBrowser !== null || evalJs !== void 0);
|
|
17230
17508
|
if (evalJs && !endpoint && !usePlaywright) {
|
|
17231
|
-
throw new
|
|
17232
|
-
code:
|
|
17509
|
+
throw new CliError37({
|
|
17510
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17233
17511
|
message: "--eval \u9700\u8981 Playwright \u6216 --cdp\uFF1A\u8001\u7684 spawn \u8DEF\u5F84\u53EA\u4F1A --dump-dom\uFF0C\u585E\u4E0D\u8FDB\u811A\u672C\u3002",
|
|
17234
17512
|
context: { nextStep: "npx playwright install chromium-headless-shell\uFF0C\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
|
|
17235
17513
|
});
|
|
@@ -17247,10 +17525,10 @@ async function runChironPage(target, args, deps) {
|
|
|
17247
17525
|
try {
|
|
17248
17526
|
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 });
|
|
17249
17527
|
} catch (e) {
|
|
17250
|
-
if (e instanceof
|
|
17528
|
+
if (e instanceof CliError37) throw new CliError37({ code: e.code, message: redactTicket(e.message), context: e.context });
|
|
17251
17529
|
const where = endpoint ? `\u8FDE\u5230 ${endpoint} \u7684 Chrome` : "Playwright \u8D77\u7684\u6D4F\u89C8\u5668";
|
|
17252
|
-
throw new
|
|
17253
|
-
code:
|
|
17530
|
+
throw new CliError37({
|
|
17531
|
+
code: CliErrorCode38.SERVER_ERROR,
|
|
17254
17532
|
message: `${where}\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(e instanceof Error ? e.message : String(e))}`,
|
|
17255
17533
|
context: {
|
|
17256
17534
|
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"
|
|
@@ -17266,8 +17544,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17266
17544
|
mode = "spawn";
|
|
17267
17545
|
const browser = deps.findBrowser();
|
|
17268
17546
|
if (!browser) {
|
|
17269
|
-
throw new
|
|
17270
|
-
code:
|
|
17547
|
+
throw new CliError37({
|
|
17548
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17271
17549
|
message: "\u672C\u673A\u627E\u4E0D\u5230 Playwright \u7684 Chromium\uFF0C\u4E5F\u627E\u4E0D\u5230 Chrome/Chromium\uFF0C\u622A\u4E0D\u4E86\u56FE\u3002",
|
|
17272
17550
|
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" }
|
|
17273
17551
|
});
|
|
@@ -17275,8 +17553,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17275
17553
|
minted = await mint();
|
|
17276
17554
|
const result = deps.capture({ browser, argv: chromeArgv({ viewport, waitMs, screenshot: absolute, url: minted.url, isRoot: process.getuid?.() === 0 }) });
|
|
17277
17555
|
if (!result.ok) {
|
|
17278
|
-
throw new
|
|
17279
|
-
code:
|
|
17556
|
+
throw new CliError37({
|
|
17557
|
+
code: CliErrorCode38.SERVER_ERROR,
|
|
17280
17558
|
message: `\u6D4F\u89C8\u5668\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(result.stderr.trim().split("\n").slice(-1)[0] ?? "\u65E0\u8F93\u51FA")}`,
|
|
17281
17559
|
context: { nextStep: spawnFailureNextStep(browser, result, deps.platform) }
|
|
17282
17560
|
});
|
|
@@ -17286,7 +17564,7 @@ async function runChironPage(target, args, deps) {
|
|
|
17286
17564
|
}
|
|
17287
17565
|
const bytes = await deps.present(absolute) ? await deps.sizeOf(absolute) : 0;
|
|
17288
17566
|
if (bytes === 0) {
|
|
17289
|
-
throw new
|
|
17567
|
+
throw new CliError37({ code: CliErrorCode38.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
|
|
17290
17568
|
}
|
|
17291
17569
|
const verdict = judgePageContent({ dom, expect, reject });
|
|
17292
17570
|
return {
|
|
@@ -17338,7 +17616,7 @@ function safeStringify(value) {
|
|
|
17338
17616
|
}
|
|
17339
17617
|
function playwrightPackageRoot() {
|
|
17340
17618
|
try {
|
|
17341
|
-
return
|
|
17619
|
+
return path17.dirname(createRequire(import.meta.url).resolve("playwright-core/package.json"));
|
|
17342
17620
|
} catch {
|
|
17343
17621
|
return void 0;
|
|
17344
17622
|
}
|
|
@@ -17349,13 +17627,13 @@ var defaultChironPageDeps = {
|
|
|
17349
17627
|
const envCfg = await loadEnv6(ctx.env);
|
|
17350
17628
|
const frontend = ctx.frontend ?? envCfg.frontend;
|
|
17351
17629
|
if (!frontend?.trim()) {
|
|
17352
|
-
throw new
|
|
17353
|
-
code:
|
|
17630
|
+
throw new CliError37({
|
|
17631
|
+
code: CliErrorCode38.INVALID_ARGUMENT,
|
|
17354
17632
|
message: `env '${ctx.env}' \u6CA1\u914D\u524D\u7AEF\u5730\u5740\uFF0C\u5F00\u4E0D\u4E86\u9875\u9762\u3002`,
|
|
17355
17633
|
context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
|
|
17356
17634
|
});
|
|
17357
17635
|
}
|
|
17358
|
-
const client3 =
|
|
17636
|
+
const client3 = HcmClient25.fromAuthContext(ctx);
|
|
17359
17637
|
const { ticket } = await mintBrowserTicket(client3, ctx.env)();
|
|
17360
17638
|
return { url: buildBrowserLoginUrl(frontend, ticket, sitePath), environment: ctx.env, identity: ctx.identity ?? null };
|
|
17361
17639
|
},
|
|
@@ -17408,16 +17686,16 @@ var defaultChironPageDeps = {
|
|
|
17408
17686
|
capturePlaywright: (input) => captureViaPlaywright(input),
|
|
17409
17687
|
platform: process.platform,
|
|
17410
17688
|
browserVersion: (browser) => (spawnSync(browser, ["--version"], { encoding: "utf8" }).stdout ?? "").trim().split("\n")[0] ?? "",
|
|
17411
|
-
ensureDir: (dir) =>
|
|
17412
|
-
present: (file) =>
|
|
17413
|
-
sizeOf: (file) =>
|
|
17414
|
-
realpath: (file) =>
|
|
17689
|
+
ensureDir: (dir) => fs14.mkdir(dir, { recursive: true }).then(() => void 0),
|
|
17690
|
+
present: (file) => fs14.lstat(file).then(() => true).catch(() => false),
|
|
17691
|
+
sizeOf: (file) => fs14.stat(file).then((s) => s.size),
|
|
17692
|
+
realpath: (file) => fs14.realpath(file).catch(() => null)
|
|
17415
17693
|
};
|
|
17416
17694
|
async function chironPageCommand(target, args, deps = defaultChironPageDeps) {
|
|
17417
17695
|
try {
|
|
17418
17696
|
const receipt = await runChironPage(target, args, deps);
|
|
17419
17697
|
const fmt = args.output ?? "table";
|
|
17420
|
-
if (fmt === "json" || fmt === "yaml") process.stdout.write(
|
|
17698
|
+
if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject31(receipt, { format: fmt }) + "\n");
|
|
17421
17699
|
else process.stdout.write(renderChironPage(receipt) + "\n");
|
|
17422
17700
|
process.exitCode = receipt.ok ? 0 : 3;
|
|
17423
17701
|
} catch (e) {
|
|
@@ -17429,14 +17707,14 @@ async function chironPageCommand(target, args, deps = defaultChironPageDeps) {
|
|
|
17429
17707
|
init_exit();
|
|
17430
17708
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
17431
17709
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
17432
|
-
import { promises as
|
|
17433
|
-
import
|
|
17710
|
+
import { promises as fs15 } from "fs";
|
|
17711
|
+
import path18 from "path";
|
|
17434
17712
|
import yaml3 from "js-yaml";
|
|
17435
|
-
import { formatObject as
|
|
17713
|
+
import { formatObject as formatObject32 } from "@hcmai/sdk";
|
|
17436
17714
|
|
|
17437
17715
|
// src/commands/delivery-action-policy.ts
|
|
17438
17716
|
init_auth_guard();
|
|
17439
|
-
import { HcmClient as
|
|
17717
|
+
import { HcmClient as HcmClient26, classifyEffect } from "@hcmai/sdk";
|
|
17440
17718
|
|
|
17441
17719
|
// src/commands/delivery.ts
|
|
17442
17720
|
import { createHash as createHash9 } from "crypto";
|
|
@@ -17482,6 +17760,7 @@ var GUARDED_EXECUTOR_REASON_CODES = /* @__PURE__ */ new Set([
|
|
|
17482
17760
|
// 被「该 R2 命令不在首批受控执行器支持面」拦死,远端只多了一个空 workspace。
|
|
17483
17761
|
"metadata-write",
|
|
17484
17762
|
"workspace-push",
|
|
17763
|
+
"workspace-rebase",
|
|
17485
17764
|
// 载荷是**位置参数**(`hcm import <路径>`),既不走 --file 也不走 --dir,
|
|
17486
17765
|
// 所以上一刀把文件与目录开关收进来时它仍留在外面(0.4.9 CHANGELOG 逐字记了这一条)。
|
|
17487
17766
|
//
|
|
@@ -17497,7 +17776,8 @@ var GUARDED_EXECUTOR_REASON_CODES = /* @__PURE__ */ new Set([
|
|
|
17497
17776
|
// 报表 / 套打模板回传要先 upload 拿 documentId,再挂到业务对象。文件路径是
|
|
17498
17777
|
// 固定位置参数,prepare 会钉住项目内普通文件的摘要,execute 前重算后才单次执行。
|
|
17499
17778
|
// 2026-09-02 弹性报表顾问仿真已证实这条交付链会在缺受控执行器时中断。
|
|
17500
|
-
"document-upload"
|
|
17779
|
+
"document-upload",
|
|
17780
|
+
"tenant-bootstrap-reconcile"
|
|
17501
17781
|
]);
|
|
17502
17782
|
function normalizeAssessedArgv(inputArgv) {
|
|
17503
17783
|
let rest = inputArgv;
|
|
@@ -17584,7 +17864,7 @@ function classify(argv, actionResolution) {
|
|
|
17584
17864
|
`\u88AB\u8BC4\u4F30\u7684\u547D\u4EE4\u540D\u89E3\u6790\u6210\u4E86 ${name} \u2014\u2014 \u90A3\u662F\u4E00\u4E2A\u9009\u9879\uFF0C\u4E0D\u662F\u547D\u4EE4\u3002next_step=\u4ECE\u547D\u4EE4\u540D\u5F00\u5934\u5199\u6574\u6761\u547D\u4EE4\uFF0C\u628A ${name} \u632A\u5230\u547D\u4EE4\u540D\u540E\u9762\uFF0C\u4F8B\u5982 \`hcm meta set <Model> --env <env>\``
|
|
17585
17865
|
);
|
|
17586
17866
|
}
|
|
17587
|
-
if (argv.some((arg) => APPROVAL_BYPASS_FLAGS.has(flagName(arg)))) {
|
|
17867
|
+
if (argv.some((arg) => APPROVAL_BYPASS_FLAGS.has(flagName(arg)) && !(name === "tenant" && subcommand === "reconcile" && ["-y", "--yes"].includes(flagName(arg))))) {
|
|
17588
17868
|
return forbidden("approval-bypass", "\u547D\u4EE4\u5305\u542B\u8DF3\u8FC7\u786E\u8BA4\u7684\u65D7\u6807\uFF0C\u987E\u95EE\u4EA4\u4ED8\u9762\u4E0D\u6267\u884C\u3002");
|
|
17589
17869
|
}
|
|
17590
17870
|
if (name === "user" && subcommand === "reset-password") {
|
|
@@ -17750,6 +18030,9 @@ function classify(argv, actionResolution) {
|
|
|
17750
18030
|
}
|
|
17751
18031
|
}
|
|
17752
18032
|
if (name === "workspace") {
|
|
18033
|
+
if (subcommand === "rebase") {
|
|
18034
|
+
return hasFlag(argv, "--dry-run") || !hasFlag(argv, "--plan") ? direct("R1", "remote-read", "workspace-rebase-preview") : guarded("tenant-write", "workspace-rebase");
|
|
18035
|
+
}
|
|
17753
18036
|
if (subcommand === "push" && hasFlag(argv, "--dry-run")) {
|
|
17754
18037
|
return direct("R1", "remote-read", "workspace-push-dry-run");
|
|
17755
18038
|
}
|
|
@@ -17807,6 +18090,7 @@ function classify(argv, actionResolution) {
|
|
|
17807
18090
|
return forbidden("destructive", "\u5220\u9664\u64CD\u4F5C\u4E0D\u8FDB\u5165\u987E\u95EE\u63D2\u4EF6\u6267\u884C\u9762\u3002");
|
|
17808
18091
|
}
|
|
17809
18092
|
if (name === "tenant") {
|
|
18093
|
+
if (subcommand === "reconcile") return guarded("tenant-config-write", "tenant-bootstrap-reconcile");
|
|
17810
18094
|
return forbidden("tenant-governance", "\u79DF\u6237\u5F00\u901A\u6216\u6CBB\u7406\u5FC5\u987B\u5347\u7EA7\u6CBB\u7406\u4EBA\u5458\u3002");
|
|
17811
18095
|
}
|
|
17812
18096
|
if (name === "login" || name === "logout") {
|
|
@@ -18025,7 +18309,7 @@ async function resolveCoreAction(request) {
|
|
|
18025
18309
|
as: request.identity,
|
|
18026
18310
|
profile: request.profile
|
|
18027
18311
|
});
|
|
18028
|
-
const description = await
|
|
18312
|
+
const description = await HcmClient26.fromAuthContext(auth).describe(request.model);
|
|
18029
18313
|
const named = description.actions.filter((action) => action.name === request.action);
|
|
18030
18314
|
if (named.length === 0) {
|
|
18031
18315
|
const degraded = description.effectiveActionsAvailable ? "" : `\u26A0\uFE0F \u672C\u6B21\u6BD4\u5BF9\u4E0D\u542B\u811A\u672C Action\u2014\u2014${description.effectiveActionsNote ?? "\u539F\u56E0\u672A\u77E5"}\u3002`;
|
|
@@ -18329,7 +18613,7 @@ var defaultDeps2 = {
|
|
|
18329
18613
|
return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
|
|
18330
18614
|
},
|
|
18331
18615
|
readXlsx: (file) => xlsxRows(file),
|
|
18332
|
-
readText: (file) =>
|
|
18616
|
+
readText: (file) => fs15.readFile(file, "utf8")
|
|
18333
18617
|
};
|
|
18334
18618
|
async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
|
|
18335
18619
|
const results = [];
|
|
@@ -18394,7 +18678,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
|
|
|
18394
18678
|
continue;
|
|
18395
18679
|
}
|
|
18396
18680
|
if (c2.file) {
|
|
18397
|
-
const file =
|
|
18681
|
+
const file = path18.resolve(root, fill(c2.file));
|
|
18398
18682
|
const want = c2.expect ?? {};
|
|
18399
18683
|
const bad = [];
|
|
18400
18684
|
if (want.xlsx_header || want.xlsx_min_rows !== void 0) {
|
|
@@ -18416,7 +18700,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
|
|
|
18416
18700
|
results.push(bad.length ? { name: c2.name, verdict: "fail", detail: bad.join("\uFF1B") } : { name: c2.name, verdict: "pass", detail: "" });
|
|
18417
18701
|
continue;
|
|
18418
18702
|
}
|
|
18419
|
-
const out =
|
|
18703
|
+
const out = path18.join(
|
|
18420
18704
|
"evidence",
|
|
18421
18705
|
"test",
|
|
18422
18706
|
opts.evidenceRunId ?? "current",
|
|
@@ -18437,12 +18721,12 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
|
|
|
18437
18721
|
return results;
|
|
18438
18722
|
}
|
|
18439
18723
|
async function loadCases(target) {
|
|
18440
|
-
const stat = await
|
|
18441
|
-
const files = stat.isDirectory() ? (await
|
|
18724
|
+
const stat = await fs15.stat(target);
|
|
18725
|
+
const files = stat.isDirectory() ? (await fs15.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) => path18.join(target, f)) : [target];
|
|
18442
18726
|
const out = [];
|
|
18443
18727
|
for (const f of files) {
|
|
18444
|
-
const spec = yaml3.load(await
|
|
18445
|
-
assertUsableSpec(spec,
|
|
18728
|
+
const spec = yaml3.load(await fs15.readFile(f, "utf8"));
|
|
18729
|
+
assertUsableSpec(spec, path18.basename(f));
|
|
18446
18730
|
out.push({ file: f, spec });
|
|
18447
18731
|
}
|
|
18448
18732
|
if (out.length === 0) throw new Error(`${target} \u4E0B\u6CA1\u6709\u7528\u4F8B\uFF08*.yml\uFF09`);
|
|
@@ -18450,8 +18734,8 @@ async function loadCases(target) {
|
|
|
18450
18734
|
}
|
|
18451
18735
|
async function chironTestCommand(target, args, deps) {
|
|
18452
18736
|
try {
|
|
18453
|
-
const root =
|
|
18454
|
-
const where =
|
|
18737
|
+
const root = path18.resolve(args.project ?? ".");
|
|
18738
|
+
const where = path18.resolve(root, target ?? "tests");
|
|
18455
18739
|
const cases2 = await loadCases(where);
|
|
18456
18740
|
const report = [];
|
|
18457
18741
|
let failed2 = 0;
|
|
@@ -18463,11 +18747,11 @@ async function chironTestCommand(target, args, deps) {
|
|
|
18463
18747
|
deps
|
|
18464
18748
|
);
|
|
18465
18749
|
failed2 += results.filter((r) => r.verdict === "fail").length;
|
|
18466
|
-
report.push({ case: spec.name, file:
|
|
18750
|
+
report.push({ case: spec.name, file: path18.relative(root, file), results });
|
|
18467
18751
|
}
|
|
18468
18752
|
const fmt = args.output ?? "table";
|
|
18469
18753
|
if (fmt === "json" || fmt === "yaml") {
|
|
18470
|
-
process.stdout.write(
|
|
18754
|
+
process.stdout.write(formatObject32({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
|
|
18471
18755
|
} else {
|
|
18472
18756
|
for (const c2 of report) {
|
|
18473
18757
|
process.stdout.write(`
|
|
@@ -18496,12 +18780,12 @@ ${failed2} \u6761\u6CA1\u8FC7\u2014\u2014\u4E0A\u9762\u6BCF\u6761\u90FD\u5199\u4
|
|
|
18496
18780
|
init_auth_guard();
|
|
18497
18781
|
init_exit();
|
|
18498
18782
|
import {
|
|
18499
|
-
HcmClient as
|
|
18783
|
+
HcmClient as HcmClient27,
|
|
18500
18784
|
ReconLayout,
|
|
18501
18785
|
ROUND_EXIT_CODES,
|
|
18502
18786
|
computeReconSourceKey,
|
|
18503
|
-
formatObject as
|
|
18504
|
-
fromAxiosError as
|
|
18787
|
+
formatObject as formatObject33,
|
|
18788
|
+
fromAxiosError as fromAxiosError25,
|
|
18505
18789
|
httpProbe as httpProbe3,
|
|
18506
18790
|
inspectRound,
|
|
18507
18791
|
renderRound,
|
|
@@ -18511,7 +18795,7 @@ var DEFAULT_CAPABILITIES = "default";
|
|
|
18511
18795
|
async function deliveryReconCommand(args) {
|
|
18512
18796
|
try {
|
|
18513
18797
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
18514
|
-
const client3 =
|
|
18798
|
+
const client3 = HcmClient27.fromAuthContext(ctx);
|
|
18515
18799
|
const probe2 = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
|
|
18516
18800
|
const sourceKey = await computeReconSourceKey(probe2);
|
|
18517
18801
|
const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
|
|
@@ -18520,10 +18804,10 @@ async function deliveryReconCommand(args) {
|
|
|
18520
18804
|
onlyModel: args.model ?? null,
|
|
18521
18805
|
identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
|
|
18522
18806
|
});
|
|
18523
|
-
process.stdout.write(
|
|
18807
|
+
process.stdout.write(formatObject33(summary, { format: args.output ?? "json" }) + "\n");
|
|
18524
18808
|
} catch (e) {
|
|
18525
18809
|
const err = e;
|
|
18526
|
-
if (err?.isAxiosError) exitWithError(
|
|
18810
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError25(err, args.env));
|
|
18527
18811
|
exitWithError(e);
|
|
18528
18812
|
process.exit(1);
|
|
18529
18813
|
}
|
|
@@ -18534,7 +18818,7 @@ async function deliveryReconRoundCommand(args) {
|
|
|
18534
18818
|
const result = inspectRound(args.dir ?? ".");
|
|
18535
18819
|
const fmt = args.output ?? "json";
|
|
18536
18820
|
if (fmt !== "json") process.stdout.write(renderRound(result));
|
|
18537
|
-
process.stdout.write(
|
|
18821
|
+
process.stdout.write(formatObject33(result, { format: fmt }) + "\n");
|
|
18538
18822
|
code2 = ROUND_EXIT_CODES[result.state];
|
|
18539
18823
|
} catch (e) {
|
|
18540
18824
|
exitWithError(e);
|
|
@@ -18554,7 +18838,7 @@ import {
|
|
|
18554
18838
|
DRY_RUN_TAIL,
|
|
18555
18839
|
DriftDetected,
|
|
18556
18840
|
FORCE_STALE_FLAG,
|
|
18557
|
-
HcmClient as
|
|
18841
|
+
HcmClient as HcmClient28,
|
|
18558
18842
|
fetchReconIdentity as fetchReconIdentity2,
|
|
18559
18843
|
INIT_EXIT_CODES,
|
|
18560
18844
|
JOURNAL_STOP_KINDS,
|
|
@@ -18604,7 +18888,7 @@ import {
|
|
|
18604
18888
|
writeRisk
|
|
18605
18889
|
} from "@hcmai/sdk";
|
|
18606
18890
|
import { existsSync as existsSync4 } from "fs";
|
|
18607
|
-
import * as
|
|
18891
|
+
import * as path19 from "path";
|
|
18608
18892
|
function premise(message, hint = "") {
|
|
18609
18893
|
process.stderr.write(message + (hint ? `
|
|
18610
18894
|
\u2192 ${hint}` : "") + "\n");
|
|
@@ -18631,13 +18915,13 @@ async function runSeedPlan(args, client3) {
|
|
|
18631
18915
|
const reconDir = candidates[0].reconDir;
|
|
18632
18916
|
if (candidates.length > 1) {
|
|
18633
18917
|
process.stderr.write(
|
|
18634
|
-
`\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${
|
|
18918
|
+
`\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${path19.basename(reconDir)}\`\uFF1A` + candidates.slice(1).map((c2) => `\`${path19.basename(c2.reconDir)}\``).join("\u3001") + " \u672A\u88AB\u8BFB\u53D6 \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n"
|
|
18635
18919
|
);
|
|
18636
18920
|
}
|
|
18637
18921
|
const round = inspectRound2(reconDir);
|
|
18638
18922
|
process.stderr.write(roundWarning(round));
|
|
18639
18923
|
const baseline = {
|
|
18640
|
-
path: `${
|
|
18924
|
+
path: `${path19.basename(path19.dirname(reconDir))}/${path19.basename(reconDir)}`,
|
|
18641
18925
|
roundId: round.roundId ?? null
|
|
18642
18926
|
};
|
|
18643
18927
|
let exemptions = null;
|
|
@@ -18694,7 +18978,7 @@ async function authOrSignpost(args, cmd) {
|
|
|
18694
18978
|
}
|
|
18695
18979
|
async function deliverySeedPlanCommand(args) {
|
|
18696
18980
|
const ctx = await authOrSignpost(args, "plan");
|
|
18697
|
-
const client3 =
|
|
18981
|
+
const client3 = HcmClient28.fromAuthContext(ctx);
|
|
18698
18982
|
process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
|
|
18699
18983
|
}
|
|
18700
18984
|
function seedClient(client3, ctx) {
|
|
@@ -18868,7 +19152,7 @@ async function runSeedApply(args, client3) {
|
|
|
18868
19152
|
}
|
|
18869
19153
|
async function deliverySeedApplyCommand(args) {
|
|
18870
19154
|
const ctx = await authOrSignpost(args, "apply");
|
|
18871
|
-
const client3 =
|
|
19155
|
+
const client3 = HcmClient28.fromAuthContext(ctx);
|
|
18872
19156
|
process.exitCode = await runSeedApply(args, seedClient(client3, ctx));
|
|
18873
19157
|
}
|
|
18874
19158
|
async function runSeedVerify(args, client3) {
|
|
@@ -18892,14 +19176,14 @@ async function deliverySeedVerifyCommand(args) {
|
|
|
18892
19176
|
return;
|
|
18893
19177
|
}
|
|
18894
19178
|
const ctx = await authOrSignpost(args, "verify");
|
|
18895
|
-
const client3 =
|
|
19179
|
+
const client3 = HcmClient28.fromAuthContext(ctx);
|
|
18896
19180
|
process.exitCode = await runSeedVerify(args, await seedVerifyClient(client3, ctx));
|
|
18897
19181
|
}
|
|
18898
19182
|
|
|
18899
19183
|
// src/commands/delivery-seed-find.ts
|
|
18900
19184
|
import { existsSync as existsSync5 } from "fs";
|
|
18901
19185
|
import { readFileSync as readFileSync8 } from "fs";
|
|
18902
|
-
import * as
|
|
19186
|
+
import * as path20 from "path";
|
|
18903
19187
|
import {
|
|
18904
19188
|
INIT_EXIT_CODES as INIT_EXIT_CODES2,
|
|
18905
19189
|
ValueHints,
|
|
@@ -18913,10 +19197,10 @@ import {
|
|
|
18913
19197
|
valuesRoundCaveat
|
|
18914
19198
|
} from "@hcmai/sdk";
|
|
18915
19199
|
function provenance(chosenReconDir, others) {
|
|
18916
|
-
let line = `> \u57FA\u7EBF\uFF1A\`${
|
|
19200
|
+
let line = `> \u57FA\u7EBF\uFF1A\`${path20.basename(chosenReconDir)}\`
|
|
18917
19201
|
`;
|
|
18918
19202
|
if (others.length > 0) {
|
|
18919
|
-
line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${
|
|
19203
|
+
line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${path20.basename(o)}\``).join("\u3001") + " \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n";
|
|
18920
19204
|
}
|
|
18921
19205
|
return `${line}
|
|
18922
19206
|
`;
|
|
@@ -19007,7 +19291,7 @@ import {
|
|
|
19007
19291
|
CHANGE_STATES,
|
|
19008
19292
|
CHANGE_UNKNOWN,
|
|
19009
19293
|
CODE_WORDS,
|
|
19010
|
-
HcmClient as
|
|
19294
|
+
HcmClient as HcmClient29,
|
|
19011
19295
|
INIT_EXIT_CODES as INIT_EXIT_CODES3,
|
|
19012
19296
|
META_WRITE_STEPS,
|
|
19013
19297
|
META_VERIFY_STEPS,
|
|
@@ -19235,7 +19519,7 @@ function lowerCaseHeaders2(headers) {
|
|
|
19235
19519
|
}
|
|
19236
19520
|
async function deliveryMetaCommand(args) {
|
|
19237
19521
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
19238
|
-
const client3 =
|
|
19522
|
+
const client3 = HcmClient29.fromAuthContext(ctx);
|
|
19239
19523
|
process.exitCode = await runDeliveryMeta(
|
|
19240
19524
|
{ ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
|
|
19241
19525
|
metaClient(client3, ctx)
|
|
@@ -19247,13 +19531,13 @@ init_auth_guard();
|
|
|
19247
19531
|
init_exit();
|
|
19248
19532
|
import {
|
|
19249
19533
|
computeReconSourceKey as computeReconSourceKey2,
|
|
19250
|
-
HcmClient as
|
|
19534
|
+
HcmClient as HcmClient30,
|
|
19251
19535
|
httpProbe as httpProbe4,
|
|
19252
19536
|
ReconLayout as ReconLayout2,
|
|
19253
19537
|
runTriageRound
|
|
19254
19538
|
} from "@hcmai/sdk";
|
|
19255
19539
|
import { mkdirSync as mkdirSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync3 } from "fs";
|
|
19256
|
-
import * as
|
|
19540
|
+
import * as path21 from "path";
|
|
19257
19541
|
var DEFAULT_CAPABILITIES3 = "default";
|
|
19258
19542
|
function premise4(message, hint) {
|
|
19259
19543
|
process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
|
|
@@ -19289,8 +19573,8 @@ function renderProblems(rows2) {
|
|
|
19289
19573
|
`;
|
|
19290
19574
|
}
|
|
19291
19575
|
function writeTriageArtifact(outDir, body) {
|
|
19292
|
-
const out =
|
|
19293
|
-
mkdirSync2(
|
|
19576
|
+
const out = path21.join(outDir, "work", "triage.md");
|
|
19577
|
+
mkdirSync2(path21.dirname(out), { recursive: true });
|
|
19294
19578
|
writeFileSync3(out, body, "utf8");
|
|
19295
19579
|
return out;
|
|
19296
19580
|
}
|
|
@@ -19303,7 +19587,7 @@ async function runTriage(args) {
|
|
|
19303
19587
|
return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
|
|
19304
19588
|
}
|
|
19305
19589
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
19306
|
-
const client3 =
|
|
19590
|
+
const client3 = HcmClient30.fromAuthContext(ctx);
|
|
19307
19591
|
const probe2 = httpProbe4(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES3);
|
|
19308
19592
|
const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe2)).dir;
|
|
19309
19593
|
const result = await runTriageRound(probe2, artifactsDir, entriesIn);
|
|
@@ -19332,25 +19616,25 @@ async function deliveryTriageCommand(args) {
|
|
|
19332
19616
|
init_auth_guard();
|
|
19333
19617
|
init_exit();
|
|
19334
19618
|
import {
|
|
19335
|
-
HcmClient as
|
|
19619
|
+
HcmClient as HcmClient31,
|
|
19336
19620
|
adminResetPassword,
|
|
19337
|
-
formatObject as
|
|
19338
|
-
fromAxiosError as
|
|
19339
|
-
CliError as
|
|
19340
|
-
CliErrorCode as
|
|
19621
|
+
formatObject as formatObject34,
|
|
19622
|
+
fromAxiosError as fromAxiosError26,
|
|
19623
|
+
CliError as CliError38,
|
|
19624
|
+
CliErrorCode as CliErrorCode39
|
|
19341
19625
|
} from "@hcmai/sdk";
|
|
19342
19626
|
function buildAdminResetPasswordRequest(args, password) {
|
|
19343
19627
|
const hasId = Boolean(args.id);
|
|
19344
19628
|
const hasUsername = Boolean(args.username);
|
|
19345
19629
|
if (hasId === hasUsername) {
|
|
19346
|
-
throw new
|
|
19347
|
-
code:
|
|
19630
|
+
throw new CliError38({
|
|
19631
|
+
code: CliErrorCode39.INVALID_ARGUMENT,
|
|
19348
19632
|
message: "--id <uuid> \u4E0E --username <user> \u5FC5\u987B\u4E14\u53EA\u80FD\u63D0\u4F9B\u4E00\u4E2A"
|
|
19349
19633
|
});
|
|
19350
19634
|
}
|
|
19351
19635
|
if (!password) {
|
|
19352
|
-
throw new
|
|
19353
|
-
code:
|
|
19636
|
+
throw new CliError38({
|
|
19637
|
+
code: CliErrorCode39.INVALID_ARGUMENT,
|
|
19354
19638
|
message: "\u65B0\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
|
|
19355
19639
|
});
|
|
19356
19640
|
}
|
|
@@ -19366,12 +19650,12 @@ async function userResetPasswordCommand(args) {
|
|
|
19366
19650
|
try {
|
|
19367
19651
|
const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
|
|
19368
19652
|
const request = buildAdminResetPasswordRequest(args, password);
|
|
19369
|
-
const client3 =
|
|
19653
|
+
const client3 = HcmClient31.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
19370
19654
|
const result = await adminResetPassword(client3.raw(), request);
|
|
19371
|
-
process.stdout.write(
|
|
19655
|
+
process.stdout.write(formatObject34(result, { format: args.output ?? "json" }) + "\n");
|
|
19372
19656
|
} catch (cause) {
|
|
19373
19657
|
const err = cause;
|
|
19374
|
-
if (err?.isAxiosError) exitWithError(
|
|
19658
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError26(err, args.env));
|
|
19375
19659
|
exitWithError(cause);
|
|
19376
19660
|
}
|
|
19377
19661
|
}
|
|
@@ -19379,8 +19663,8 @@ async function promptPasswordTwice() {
|
|
|
19379
19663
|
const password = await promptSecret("\u65B0\u5BC6\u7801: ");
|
|
19380
19664
|
const confirmation = await promptSecret("\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ");
|
|
19381
19665
|
if (password !== confirmation) {
|
|
19382
|
-
throw new
|
|
19383
|
-
code:
|
|
19666
|
+
throw new CliError38({
|
|
19667
|
+
code: CliErrorCode39.INVALID_ARGUMENT,
|
|
19384
19668
|
message: "\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4"
|
|
19385
19669
|
});
|
|
19386
19670
|
}
|
|
@@ -19391,19 +19675,19 @@ async function promptPasswordTwice() {
|
|
|
19391
19675
|
init_exit();
|
|
19392
19676
|
init_auth_guard();
|
|
19393
19677
|
import {
|
|
19394
|
-
HcmClient as
|
|
19395
|
-
formatObject as
|
|
19396
|
-
fromAxiosError as
|
|
19678
|
+
HcmClient as HcmClient32,
|
|
19679
|
+
formatObject as formatObject35,
|
|
19680
|
+
fromAxiosError as fromAxiosError27
|
|
19397
19681
|
} from "@hcmai/sdk";
|
|
19398
19682
|
async function modelsCommand(keyword, args) {
|
|
19399
19683
|
try {
|
|
19400
|
-
const client3 =
|
|
19684
|
+
const client3 = HcmClient32.fromAuthContext(await getActiveAuthContextFromCli(args));
|
|
19401
19685
|
const all = await client3.listModels();
|
|
19402
19686
|
const needle = keyword?.trim().toLowerCase();
|
|
19403
19687
|
const rows2 = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
|
|
19404
19688
|
const fmt = args.output ?? "table";
|
|
19405
19689
|
if (fmt !== "table") {
|
|
19406
|
-
process.stdout.write(
|
|
19690
|
+
process.stdout.write(formatObject35({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
|
|
19407
19691
|
process.exitCode = 0;
|
|
19408
19692
|
return;
|
|
19409
19693
|
}
|
|
@@ -19430,7 +19714,7 @@ async function modelsCommand(keyword, args) {
|
|
|
19430
19714
|
return;
|
|
19431
19715
|
} catch (e) {
|
|
19432
19716
|
const err = e;
|
|
19433
|
-
if (err?.isAxiosError) exitWithError(
|
|
19717
|
+
if (err?.isAxiosError) exitWithError(fromAxiosError27(err, args.profile));
|
|
19434
19718
|
exitWithError(e);
|
|
19435
19719
|
}
|
|
19436
19720
|
}
|
|
@@ -19676,6 +19960,7 @@ workspace.command("deactivate").description("\u8BA9\u5F53\u524D\u8EAB\u4EFD\u900
|
|
|
19676
19960
|
workspace.command("bind <workspaceKey>").description("\u628A\u5F53\u524D\u76EE\u5F55\u7ED1\u5B9A\u5230\u4E00\u4E2A\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("--tenant <tenantId>", "\u79DF\u6237 ID\uFF08\u9ED8\u8BA4\u4F7F\u7528 env \u914D\u7F6E\uFF09").option("--endpoint <url>", "HCM \u540E\u7AEF\u5730\u5740\uFF08\u9ED8\u8BA4\u4F7F\u7528 env \u914D\u7F6E\uFF09").option("--force", "\u5F3A\u5236\u8986\u76D6\u5DF2\u6709\u7ED1\u5B9A").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((workspaceKey, opts) => workspaceBindCommand(workspaceKey, opts));
|
|
19677
19961
|
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));
|
|
19678
19962
|
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));
|
|
19963
|
+
workspace.command("rebase").description("\u9884\u89C8 workspace \u4E0E active \u7684\u4FEE\u8BA2\u5DEE\u5F02\uFF1B\u6309\u660E\u786E\u7684\u9010\u8DEF\u5F84\u89E3\u51B3\u8BA1\u5212\u66F4\u65B0\u5F00\u53D1\u7A7A\u95F4\u57FA\u7EBF").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("--dry-run", "\u53EA\u8BFB\u9884\u89C8\uFF1B\u914D\u5408 --plan \u5199\u4E00\u4E2A\u4E0D\u8986\u76D6\u5DF2\u6709\u6587\u4EF6\u7684\u89E3\u51B3\u8349\u6848").option("--plan <path>", "\u89E3\u51B3\u8BA1\u5212 JSON\uFF1B\u4E0D\u5E26 --dry-run \u65F6\u6821\u9A8C\u5E76\u6267\u884C\u8BE5\u8BA1\u5212\uFF0C\u672A\u63D0\u4F9B\u65F6\u53EA\u9884\u89C8").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => workspaceRebaseCommand(opts));
|
|
19679
19964
|
var workspaceAdd = workspace.command("add").description("\u5411\u5DF2\u7ED1\u5B9A\u5F00\u53D1\u7A7A\u95F4\u6DFB\u52A0 artifact");
|
|
19680
19965
|
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(
|
|
19681
19966
|
"--surface <surface>",
|
|
@@ -19713,6 +19998,7 @@ datapackage.command("pack <packageDir>").description("\u628A\u5305\u76EE\u5F55\u
|
|
|
19713
19998
|
datapackage.command("install <artifact>").description("\u4E0A\u4F20 .hcmpkg \u5236\u54C1\u5E76\u7ECF\u670D\u52A1\u7AEF\u5F02\u6B65\u5B89\u88C5\u5668\u5B89\u88C5\uFF0C\u5B9E\u65F6\u663E\u793A\u8FDB\u5EA6\uFF08admin.system\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("--category <name>", "\u5236\u54C1\u4E0A\u4F20\u7684\u5B58\u50A8\u5206\u7C7B\uFF08\u670D\u52A1\u7AEF\u6570\u636E\u975E\u679A\u4E3E\uFF09", "attachment").option("--no-wait", "\u53EA\u53D7\u7406\u4E0D\u7B49\u5F85\uFF0C\u7ACB\u523B\u8FD4\u56DE runId").option("--timeout <sec>", "\u7B49\u5F85\u4E0A\u9650\uFF08\u79D2\uFF09\uFF1B\u7B49\u4E0D\u5230\u4E0D\u662F\u5931\u8D25\uFF0C\u88C5\u8F7D\u5728\u670D\u52A1\u7AEF\u7EE7\u7EED", "900").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((artifact, opts) => datapackageInstallCommand(artifact, opts));
|
|
19714
19999
|
datapackage.command("status <runId>").description("\u67E5\u770B\u88C5\u8F7D\u6D41\u6C34\u8FDB\u5EA6/\u7EC8\u6001\uFF08\u914D\u5408 install --no-wait \u6216\u7B49\u5F85\u8D85\u65F6\u540E\u4F7F\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").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((runId, opts) => datapackageStatusCommand(runId, opts));
|
|
19715
20000
|
var tenant = program.command("tenant").description("\u79DF\u6237\u5F00\u901A\u4E0E\u751F\u547D\u5468\u671F");
|
|
20001
|
+
tenant.command("reconcile").description("\u4EE5\u5F53\u524D\u79DF\u6237\u7BA1\u7406\u5458\u666E\u901A\u4F1A\u8BDD\u8865\u8DD1\u521D\u59CB\u5316\u5230\u6700\u65B0 catalog\uFF0C\u5E76\u72EC\u7ACB\u590D\u9A8C\uFF1B\u4E0D\u91CD\u7F6E\u3001\u4E0D\u8DE8\u79DF\u6237").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("-y, --yes", "\u5DF2\u53D6\u5F97\u672C\u6B21\u8865\u8DD1\u6388\u6743\uFF0C\u8DF3\u8FC7\u4EA4\u4E92\u786E\u8BA4").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => tenantReconcileCommand(opts));
|
|
19716
20002
|
tenant.command("reset").description("\u4EE5\u5F53\u524D\u79DF\u6237\u5185\u7F6E admin \u91CD\u7F6E PostgreSQL \u5230\u51FA\u5382\u57FA\u7EBF\uFF1B\u4E0D\u53EF\u9006\uFF0C\u975E PG \u672A\u5904\u7406\u672A\u6838\u9A8C").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4F7F\u7528\u8BE5\u73AF\u5883\u7684\u76F4\u63A5\u767B\u5F55\u8EAB\u4EFD\uFF0C\u4E0D\u63A5\u53D7\u4EE3\u7406").option("-y, --yes", "\u786E\u8BA4\u91CD\u7F6E\u5DF2\u6838\u9A8C\u7684\u5F53\u524D\u79DF\u6237\uFF0C\u8DF3\u8FC7\u4EA4\u4E92").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => tenantResetCommand(opts));
|
|
19717
20003
|
tenant.command("bootstrap").description("\u5F00\u901A\u65B0\u79DF\u6237\uFF08\u5EFA\u79DF\u6237 + admin \u7528\u6237 + \u7ED3\u6784 reconcile\uFF09\u2014\u2014\u4E0D\u53EF\u9006\uFF0C\u9ED8\u8BA4\u8FC7\u786E\u8BA4\u95F8").requiredOption("--tenant-id <id>", "\u79DF\u6237 ID").option("--admin-username <user>", "\u7BA1\u7406\u5458\u7528\u6237\u540D\uFF08\u670D\u52A1\u7AEF\u4EC5\u63A5\u53D7 admin\uFF09", "admin").option(
|
|
19718
20004
|
"--admin-password <pwd>",
|
|
@@ -19741,7 +20027,7 @@ program.command("update <Model>").description("\u66F4\u65B0\u4E00\u6761 Model \u
|
|
|
19741
20027
|
).action((model, opts) => updateCommand(model, opts));
|
|
19742
20028
|
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));
|
|
19743
20029
|
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));
|
|
19744
|
-
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((
|
|
20030
|
+
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((path22, opts) => openCommand(path22, opts));
|
|
19745
20031
|
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");
|
|
19746
20032
|
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));
|
|
19747
20033
|
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(
|