@hcmai/cli 0.31.0 → 0.31.2
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 +19 -0
- package/dist/index.js +427 -391
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -285,13 +285,13 @@ function prepareImpersonationExit(code2, brokenStderr = false) {
|
|
|
285
285
|
terminating ??= (async () => {
|
|
286
286
|
process.exitCode = code2 || process.exitCode || 0;
|
|
287
287
|
const errors = await cleanup();
|
|
288
|
-
await new Promise((
|
|
288
|
+
await new Promise((resolve8) => {
|
|
289
289
|
let remaining = 2;
|
|
290
|
-
const timer = setTimeout(
|
|
290
|
+
const timer = setTimeout(resolve8, 1e3);
|
|
291
291
|
const done = () => {
|
|
292
292
|
if (--remaining === 0) {
|
|
293
293
|
clearTimeout(timer);
|
|
294
|
-
|
|
294
|
+
resolve8();
|
|
295
295
|
}
|
|
296
296
|
};
|
|
297
297
|
for (const stream of [process.stdout, process.stderr]) {
|
|
@@ -658,7 +658,7 @@ __export(attachment_args_exports, {
|
|
|
658
658
|
});
|
|
659
659
|
import * as fs4 from "fs";
|
|
660
660
|
import * as os from "os";
|
|
661
|
-
import * as
|
|
661
|
+
import * as path5 from "path";
|
|
662
662
|
function extractAtFileTokens(text2) {
|
|
663
663
|
const paths = [];
|
|
664
664
|
const re = /@(?:"([^"]+)"|'([^']+)'|(\S+))/g;
|
|
@@ -694,7 +694,7 @@ function isBareFilePath(text2) {
|
|
|
694
694
|
return isExistingFile(abs) ? abs : null;
|
|
695
695
|
}
|
|
696
696
|
function expandHome(p) {
|
|
697
|
-
return p.startsWith("~") ?
|
|
697
|
+
return p.startsWith("~") ? path5.join(os.homedir(), p.slice(1)) : path5.resolve(p);
|
|
698
698
|
}
|
|
699
699
|
function isExistingFile(p) {
|
|
700
700
|
try {
|
|
@@ -1067,8 +1067,8 @@ var init_TerminalRenderer = __esm({
|
|
|
1067
1067
|
}
|
|
1068
1068
|
}
|
|
1069
1069
|
/** 来源行(仅子代理触发,agentPath ≥2 段时显示 `↑ 来自 a › b`,对齐 Web)。 */
|
|
1070
|
-
originLine(
|
|
1071
|
-
const segs =
|
|
1070
|
+
originLine(path26) {
|
|
1071
|
+
const segs = path26.split(".").filter(Boolean);
|
|
1072
1072
|
if (segs.length < 2) return "";
|
|
1073
1073
|
const names = segs.map((k) => agentDisplayName(k));
|
|
1074
1074
|
return chalk.gray(` \u2191 \u6765\u81EA ${names.join(" \u203A ")}`) + "\n";
|
|
@@ -2257,8 +2257,8 @@ function agentLabel(agentId) {
|
|
|
2257
2257
|
if (/^[0-9a-f]{8}-[0-9a-f-]{27}$/i.test(agentId)) return `agent \u2026${agentId.slice(-4)}`;
|
|
2258
2258
|
return agentDisplayName(agentId);
|
|
2259
2259
|
}
|
|
2260
|
-
function originLine(
|
|
2261
|
-
const segs = (
|
|
2260
|
+
function originLine(path26) {
|
|
2261
|
+
const segs = (path26 ?? "").split(".").filter(Boolean);
|
|
2262
2262
|
if (segs.length < 2) return null;
|
|
2263
2263
|
return `\u6765\u81EA ${segs.map((k) => agentDisplayName(k)).join(" \u203A ")}`;
|
|
2264
2264
|
}
|
|
@@ -2494,10 +2494,10 @@ __export(readline_exports, {
|
|
|
2494
2494
|
import * as readline2 from "readline";
|
|
2495
2495
|
function readLineFromStdin(prompt = "") {
|
|
2496
2496
|
const rl = readline2.createInterface({ input: process.stdin, output: process.stdout });
|
|
2497
|
-
return new Promise((
|
|
2497
|
+
return new Promise((resolve8) => {
|
|
2498
2498
|
rl.question(prompt, (answer) => {
|
|
2499
2499
|
rl.close();
|
|
2500
|
-
|
|
2500
|
+
resolve8(answer);
|
|
2501
2501
|
});
|
|
2502
2502
|
});
|
|
2503
2503
|
}
|
|
@@ -2847,7 +2847,7 @@ function requireTerminalForPrompt(message, nextStep) {
|
|
|
2847
2847
|
}
|
|
2848
2848
|
async function promptText(question, output = process.stdout) {
|
|
2849
2849
|
const rl = readline.createInterface({ input: process.stdin, output });
|
|
2850
|
-
return new Promise((
|
|
2850
|
+
return new Promise((resolve8, reject) => {
|
|
2851
2851
|
let answered = false;
|
|
2852
2852
|
rl.on("close", () => {
|
|
2853
2853
|
if (!answered) reject(new Error("\u8F93\u5165\u5DF2\u7ED3\u675F\uFF1B\u64CD\u4F5C\u5DF2\u53D6\u6D88\u3002"));
|
|
@@ -2855,12 +2855,12 @@ async function promptText(question, output = process.stdout) {
|
|
|
2855
2855
|
rl.question(question, (ans) => {
|
|
2856
2856
|
answered = true;
|
|
2857
2857
|
rl.close();
|
|
2858
|
-
|
|
2858
|
+
resolve8(ans.trim());
|
|
2859
2859
|
});
|
|
2860
2860
|
});
|
|
2861
2861
|
}
|
|
2862
2862
|
async function promptSecret(question, output = process.stdout) {
|
|
2863
|
-
return new Promise((
|
|
2863
|
+
return new Promise((resolve8, reject) => {
|
|
2864
2864
|
const stdin = process.stdin;
|
|
2865
2865
|
stdin.setRawMode?.(true);
|
|
2866
2866
|
let buf = "";
|
|
@@ -2880,7 +2880,7 @@ async function promptSecret(question, output = process.stdout) {
|
|
|
2880
2880
|
stdin.removeListener("data", onData);
|
|
2881
2881
|
stdin.removeListener("end", onEnd);
|
|
2882
2882
|
output.write("\n");
|
|
2883
|
-
|
|
2883
|
+
resolve8(buf);
|
|
2884
2884
|
return;
|
|
2885
2885
|
}
|
|
2886
2886
|
if (ch === "") {
|
|
@@ -2985,7 +2985,7 @@ function launchBrowser(url, platform = process.platform, onFailure) {
|
|
|
2985
2985
|
child.unref();
|
|
2986
2986
|
}
|
|
2987
2987
|
async function runOpen(target, args, deps) {
|
|
2988
|
-
const
|
|
2988
|
+
const path26 = normalizeTarget(target);
|
|
2989
2989
|
if (!deps.frontend?.trim()) {
|
|
2990
2990
|
throw new CliError6({
|
|
2991
2991
|
code: CliErrorCode4.INVALID_ARGUMENT,
|
|
@@ -2993,13 +2993,13 @@ async function runOpen(target, args, deps) {
|
|
|
2993
2993
|
});
|
|
2994
2994
|
}
|
|
2995
2995
|
const { ticket, expiresIn } = await deps.mintTicket();
|
|
2996
|
-
const url = buildBrowserLoginUrl(deps.frontend, ticket,
|
|
2996
|
+
const url = buildBrowserLoginUrl(deps.frontend, ticket, path26);
|
|
2997
2997
|
if (args.printUrl) {
|
|
2998
2998
|
deps.write(`${url}
|
|
2999
2999
|
`);
|
|
3000
3000
|
} else {
|
|
3001
3001
|
deps.launch(url);
|
|
3002
|
-
deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${
|
|
3002
|
+
deps.write(`\u5DF2\u7528\u5F53\u524D\u8EAB\u4EFD\u6253\u5F00 ${path26}\uFF08\u7968\u636E ${expiresIn ?? 60}s \u5185\u6709\u6548\uFF0C\u53EA\u80FD\u7528\u4E00\u6B21\uFF09
|
|
3003
3003
|
`);
|
|
3004
3004
|
}
|
|
3005
3005
|
return { url, expiresIn };
|
|
@@ -3196,10 +3196,10 @@ async function beginBrowserLogin(input) {
|
|
|
3196
3196
|
let closing;
|
|
3197
3197
|
let watch;
|
|
3198
3198
|
let stopCountdown = () => void 0;
|
|
3199
|
-
let
|
|
3199
|
+
let resolve8;
|
|
3200
3200
|
let reject;
|
|
3201
3201
|
const result = new Promise((yes, no) => {
|
|
3202
|
-
|
|
3202
|
+
resolve8 = yes;
|
|
3203
3203
|
reject = no;
|
|
3204
3204
|
});
|
|
3205
3205
|
void result.catch(() => void 0);
|
|
@@ -3252,7 +3252,7 @@ async function beginBrowserLogin(input) {
|
|
|
3252
3252
|
}).then((authorized) => {
|
|
3253
3253
|
verifier = "";
|
|
3254
3254
|
session = authorized;
|
|
3255
|
-
|
|
3255
|
+
resolve8({ session, close, complete: async () => {
|
|
3256
3256
|
if (cancel.controller.signal.aborted) throw cancel.error(new Error("\u767B\u5F55\u5DF2\u53D6\u6D88"));
|
|
3257
3257
|
session.complete();
|
|
3258
3258
|
reply(response, 200, "CLI \u767B\u5F55\u6210\u529F");
|
|
@@ -4915,6 +4915,7 @@ import {
|
|
|
4915
4915
|
|
|
4916
4916
|
// src/utils/json-input.ts
|
|
4917
4917
|
import * as fs2 from "fs/promises";
|
|
4918
|
+
import * as path3 from "path";
|
|
4918
4919
|
import { CliError as CliError13, CliErrorCode as CliErrorCode11 } from "@hcmai/sdk";
|
|
4919
4920
|
async function readJsonObjectInput(options) {
|
|
4920
4921
|
const { inline, file, inlineFlag, fileFlag, required: required2 = true } = options;
|
|
@@ -4933,10 +4934,14 @@ async function readJsonObjectInput(options) {
|
|
|
4933
4934
|
}
|
|
4934
4935
|
let raw;
|
|
4935
4936
|
let sourceFlag;
|
|
4937
|
+
let fileContext;
|
|
4936
4938
|
if (file) {
|
|
4937
4939
|
sourceFlag = fileFlag;
|
|
4938
4940
|
try {
|
|
4939
|
-
|
|
4941
|
+
const filePath2 = path3.resolve(file);
|
|
4942
|
+
const contents = await fs2.readFile(filePath2);
|
|
4943
|
+
raw = contents.toString("utf-8");
|
|
4944
|
+
fileContext = { filePath: filePath2, sizeBytes: contents.byteLength };
|
|
4940
4945
|
} catch (error) {
|
|
4941
4946
|
throw new CliError13({
|
|
4942
4947
|
code: CliErrorCode11.INVALID_ARGUMENT,
|
|
@@ -4947,19 +4952,26 @@ async function readJsonObjectInput(options) {
|
|
|
4947
4952
|
sourceFlag = inlineFlag;
|
|
4948
4953
|
raw = inline;
|
|
4949
4954
|
}
|
|
4955
|
+
const source = fileContext ? `${sourceFlag}: ${fileContext.filePath}\uFF08${fileContext.sizeBytes} \u5B57\u8282\uFF09` : sourceFlag;
|
|
4956
|
+
const context = {
|
|
4957
|
+
...fileContext,
|
|
4958
|
+
nextStep: `\u6821\u9A8C\u8F93\u5165\u4E3A\u5B8C\u6574\u7684 JSON \u5BF9\u8C61\u3002${fileContext ? "CLI \u53EA\u8BFB\u53D6\u8C03\u7528\u65B9\u63D0\u4F9B\u7684\u6587\u4EF6\uFF0C\u4E0D\u81EA\u5EFA\u53C2\u6570\u4E34\u65F6\u6587\u4EF6\uFF1B\u5E76\u53D1\u65F6\u6BCF\u4E2A\u4EFB\u52A1\u4F7F\u7528\u72EC\u7ACB\u6587\u4EF6\uFF0C\u7B49\u5F85\u5199\u5165\u5B8C\u6210\u540E\u518D\u8C03\u7528\u3002" : ""}` + (!required2 ? `\u82E5\u52A8\u4F5C\u65E0\u53C2\u6570\uFF0C\u53EF\u7701\u7565 ${inlineFlag}/${fileFlag}\uFF0C\u6216\u4F7F\u7528 ${inlineFlag} '{}'\u3002` : "")
|
|
4959
|
+
};
|
|
4950
4960
|
let parsed;
|
|
4951
4961
|
try {
|
|
4952
4962
|
parsed = JSON.parse(raw);
|
|
4953
|
-
} catch
|
|
4963
|
+
} catch {
|
|
4954
4964
|
throw new CliError13({
|
|
4955
4965
|
code: CliErrorCode11.INVALID_JSON,
|
|
4956
|
-
message: `${
|
|
4966
|
+
message: `${source}: ${raw.trim() ? "JSON \u8BED\u6CD5\u65E0\u6548\uFF0C\u53EF\u80FD\u672A\u5199\u5B8C\u6574\u6216\u5DF2\u622A\u65AD" : "\u8F93\u5165\u4E3A\u7A7A\u6216\u4EC5\u542B\u7A7A\u767D"}`,
|
|
4967
|
+
context
|
|
4957
4968
|
});
|
|
4958
4969
|
}
|
|
4959
4970
|
if (parsed === null || Array.isArray(parsed) || typeof parsed !== "object") {
|
|
4960
4971
|
throw new CliError13({
|
|
4961
4972
|
code: CliErrorCode11.INVALID_JSON,
|
|
4962
|
-
message: `${
|
|
4973
|
+
message: `${source}: \u9876\u5C42\u5FC5\u987B\u662F JSON \u5BF9\u8C61`,
|
|
4974
|
+
context
|
|
4963
4975
|
});
|
|
4964
4976
|
}
|
|
4965
4977
|
return parsed;
|
|
@@ -4969,7 +4981,7 @@ async function readJsonObjectInput(options) {
|
|
|
4969
4981
|
import { createHash as createHash2 } from "crypto";
|
|
4970
4982
|
import { CliError as CliError14, CliErrorCode as CliErrorCode12 } from "@hcmai/sdk";
|
|
4971
4983
|
import { promises as fs3 } from "fs";
|
|
4972
|
-
import
|
|
4984
|
+
import path4 from "path";
|
|
4973
4985
|
var MAX_ARTIFACT_BYTES = 10 * 1024 * 1024;
|
|
4974
4986
|
var ARTIFACT_ENCODING_BASE64 = "base64";
|
|
4975
4987
|
var SHA256_HEX = /^[0-9a-f]{64}$/;
|
|
@@ -5001,7 +5013,7 @@ function parseArtifactEnvelope(data) {
|
|
|
5001
5013
|
}
|
|
5002
5014
|
var fail = (message, nextStep) => new CliError14({ code: CliErrorCode12.INVALID_ARGUMENT, message, context: { nextStep } });
|
|
5003
5015
|
async function writeArtifact(artifact, target, opts = {}) {
|
|
5004
|
-
const abs =
|
|
5016
|
+
const abs = path4.resolve(target);
|
|
5005
5017
|
const stat = await fs3.lstat(abs).catch(() => null);
|
|
5006
5018
|
if (stat) {
|
|
5007
5019
|
if (stat.isSymbolicLink()) {
|
|
@@ -5030,9 +5042,9 @@ async function writeArtifact(artifact, target, opts = {}) {
|
|
|
5030
5042
|
if (digest !== artifact.sha256) {
|
|
5031
5043
|
throw fail(`SHA-256 \u5BF9\u4E0D\u4E0A\uFF1A\u4FE1\u5C01\u8BF4 ${artifact.sha256}\uFF0C\u5B9E\u9645 ${digest}`, "\u540C\u4E0A\uFF1A\u5185\u5BB9\u4E0E\u6458\u8981\u4E0D\u4E00\u81F4\uFF0C\u8FD9\u4EFD\u5236\u54C1\u4E0D\u53EF\u4FE1\uFF0C\u4E0D\u843D\u76D8\u3002");
|
|
5032
5044
|
}
|
|
5033
|
-
const dir =
|
|
5045
|
+
const dir = path4.dirname(abs);
|
|
5034
5046
|
await fs3.mkdir(dir, { recursive: true });
|
|
5035
|
-
const tmp =
|
|
5047
|
+
const tmp = path4.join(dir, `.tmp-artifact-${process.pid}-${Date.now()}`);
|
|
5036
5048
|
try {
|
|
5037
5049
|
await fs3.writeFile(tmp, bytes, { mode: 384, flag: "wx" });
|
|
5038
5050
|
await fs3.rename(tmp, abs);
|
|
@@ -5533,10 +5545,11 @@ import {
|
|
|
5533
5545
|
runImport,
|
|
5534
5546
|
importExitCode,
|
|
5535
5547
|
formatObject as formatObject9,
|
|
5536
|
-
fromAxiosError as fromAxiosError12
|
|
5548
|
+
fromAxiosError as fromAxiosError12,
|
|
5549
|
+
describeExcludedReason
|
|
5537
5550
|
} from "@hcmai/sdk";
|
|
5538
|
-
function collectYmlFiles(
|
|
5539
|
-
if (statSync(
|
|
5551
|
+
function collectYmlFiles(path26) {
|
|
5552
|
+
if (statSync(path26).isFile()) return [path26];
|
|
5540
5553
|
const out = [];
|
|
5541
5554
|
const walk = (dir) => {
|
|
5542
5555
|
for (const name of readdirSync(dir).sort()) {
|
|
@@ -5545,7 +5558,7 @@ function collectYmlFiles(path25) {
|
|
|
5545
5558
|
else if (full.endsWith(".yml") || full.endsWith(".yaml")) out.push(full);
|
|
5546
5559
|
}
|
|
5547
5560
|
};
|
|
5548
|
-
walk(
|
|
5561
|
+
walk(path26);
|
|
5549
5562
|
return out.sort();
|
|
5550
5563
|
}
|
|
5551
5564
|
var DRY_RUN_CLIENT = {
|
|
@@ -5554,9 +5567,9 @@ var DRY_RUN_CLIENT = {
|
|
|
5554
5567
|
update: async () => ({}),
|
|
5555
5568
|
fieldKeys: async () => []
|
|
5556
5569
|
};
|
|
5557
|
-
async function importCommand(
|
|
5570
|
+
async function importCommand(path26, args) {
|
|
5558
5571
|
try {
|
|
5559
|
-
const files = collectYmlFiles(
|
|
5572
|
+
const files = collectYmlFiles(path26);
|
|
5560
5573
|
const fixtures = files.map(
|
|
5561
5574
|
(f) => parseFixture(readFileSync3(f, "utf8"), relative2(process.cwd(), f))
|
|
5562
5575
|
);
|
|
@@ -5621,11 +5634,24 @@ var IMPORT_NEXT_STEP = {
|
|
|
5621
5634
|
};
|
|
5622
5635
|
var importNextStep = (reason) => (reason && IMPORT_NEXT_STEP[reason]) ?? `${reason ?? "\u670D\u52A1\u7AEF\u6CA1\u7ED9\u539F\u56E0\u7801"}\uFF1A\u6309 id \u624B\u5DE5\u6838\u5BF9\uFF0C\u4E0D\u8981\u91CD\u5BFC`;
|
|
5623
5636
|
var MAX_NAMED_ROWS = 20;
|
|
5637
|
+
function printExcluded(excluded) {
|
|
5638
|
+
if (!excluded.length) return;
|
|
5639
|
+
const byReason = /* @__PURE__ */ new Map();
|
|
5640
|
+
for (const e of excluded) byReason.set(e.reason, [...byReason.get(e.reason) ?? [], e]);
|
|
5641
|
+
process.stderr.write(" \u6CA1\u6BD4\u5BF9\u7684\u5B57\u6BB5\uFF08\u670D\u52A1\u7AEF\u6392\u9664\u6E05\u5355\uFF0C\u8FD9\u4E9B\u5217\u5199\u9519\u4E86\u4E5F\u7167\u6837\u6838\u9A8C\u901A\u8FC7\uFF09\uFF1A\n");
|
|
5642
|
+
for (const [reason, list] of byReason) {
|
|
5643
|
+
const why = reason === "UNSPECIFIED" ? "\u670D\u52A1\u7AEF\u6CA1\u7ED9\u539F\u56E0" : describeExcludedReason(reason) ?? "\u8FD9\u7248 CLI \u4E0D\u8BA4\u8BC6\u8FD9\u4E2A\u539F\u56E0\u7801\uFF0C\u539F\u6837\u7167\u767B";
|
|
5644
|
+
process.stderr.write(` \u2298 ${reason}\uFF08${why}\uFF09\uFF1A${list.map((e) => `${e.field}\xD7${e.rows}\u884C`).join("\u3001")}
|
|
5645
|
+
`);
|
|
5646
|
+
}
|
|
5647
|
+
process.stderr.write(" \u8981\u786E\u8BA4\u8FD9\u4E9B\u5217\uFF0C\u6309 id \u8BFB\u56DE\u90A3\u51E0\u884C\u6838\u5BF9\uFF1B\u9010\u884C\u89C1 --report \u6216 stdout \u7684 rows[].verification.excluded\n");
|
|
5648
|
+
}
|
|
5624
5649
|
function printVerification(result) {
|
|
5625
5650
|
const v = result.verification;
|
|
5626
5651
|
process.stderr.write(
|
|
5627
5652
|
`\u{1F50E} verify: \u6838\u9A8C\u901A\u8FC7=${v.verified} \u6838\u9A8C\u5931\u8D25=${v.mismatched} \u672A\u6838\u9A8C=${v.unverified}` + (v.skippedNotVerified ? `\uFF08\u53E6\u6709 ${v.skippedNotVerified} \u884C\u5DF2\u5B58\u5728\u3001\u88AB\u8DF3\u8FC7\uFF0C\u6CA1\u5199\u5165\u3001\u4E0D\u6838\u9A8C\uFF09` : "") + (result.failed ? `\uFF08\u53E6\u6709 ${result.failed} \u884C\u5199\u5165\u5931\u8D25\uFF0C\u6CA1\u6838\uFF09` : "") + "\n"
|
|
5628
5653
|
);
|
|
5654
|
+
printExcluded(v.excluded);
|
|
5629
5655
|
const label = (r) => `${r.model}:${r.key}`;
|
|
5630
5656
|
const one = (f) => {
|
|
5631
5657
|
const extra = [
|
|
@@ -6320,11 +6346,11 @@ async function chatCommand(prompt, args) {
|
|
|
6320
6346
|
lastConversationId: handle.conversationId,
|
|
6321
6347
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
6322
6348
|
});
|
|
6323
|
-
await new Promise((
|
|
6349
|
+
await new Promise((resolve8) => {
|
|
6324
6350
|
if (process.stdout.writableNeedDrain) {
|
|
6325
|
-
process.stdout.once("drain",
|
|
6351
|
+
process.stdout.once("drain", resolve8);
|
|
6326
6352
|
} else {
|
|
6327
|
-
|
|
6353
|
+
resolve8();
|
|
6328
6354
|
}
|
|
6329
6355
|
});
|
|
6330
6356
|
process.exitCode = 0;
|
|
@@ -6393,11 +6419,11 @@ async function chatCommand(prompt, args) {
|
|
|
6393
6419
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
6394
6420
|
});
|
|
6395
6421
|
process.removeListener("SIGINT", sigintHandler);
|
|
6396
|
-
await new Promise((
|
|
6422
|
+
await new Promise((resolve8) => {
|
|
6397
6423
|
if (process.stdout.writableNeedDrain) {
|
|
6398
|
-
process.stdout.once("drain",
|
|
6424
|
+
process.stdout.once("drain", resolve8);
|
|
6399
6425
|
} else {
|
|
6400
|
-
|
|
6426
|
+
resolve8();
|
|
6401
6427
|
}
|
|
6402
6428
|
});
|
|
6403
6429
|
process.exitCode = result.status === "interrupted" ? 130 : 0;
|
|
@@ -7661,7 +7687,7 @@ function emit3(payload, fmt) {
|
|
|
7661
7687
|
init_exit();
|
|
7662
7688
|
init_auth_guard();
|
|
7663
7689
|
import { promises as fs7 } from "fs";
|
|
7664
|
-
import * as
|
|
7690
|
+
import * as path6 from "path";
|
|
7665
7691
|
import yaml from "js-yaml";
|
|
7666
7692
|
import { HcmClient as HcmClient22, fromAxiosError as fromAxiosError21, CliError as CliError23, CliErrorCode as CliErrorCode23, stripDefinitionIds, columnSlotsToFlex, redactDescriptiveUuids, removeActionsUsingScripts, stripUnknownFieldKeysForPath } from "@hcmai/sdk";
|
|
7667
7693
|
|
|
@@ -7747,10 +7773,10 @@ function createLaneApi(http) {
|
|
|
7747
7773
|
}
|
|
7748
7774
|
return out.filter((x) => x.name);
|
|
7749
7775
|
},
|
|
7750
|
-
async tenantMetaGet(
|
|
7751
|
-
const resp = await http.get("/api/tenant-meta/meta", { params: { path:
|
|
7776
|
+
async tenantMetaGet(path26) {
|
|
7777
|
+
const resp = await http.get("/api/tenant-meta/meta", { params: { path: path26 } });
|
|
7752
7778
|
const d = resp.data?.data ?? resp.data;
|
|
7753
|
-
if (typeof d?.content !== "string") throw new Error(`\u8BFB\u53D6 ${
|
|
7779
|
+
if (typeof d?.content !== "string") throw new Error(`\u8BFB\u53D6 ${path26} \u672A\u8FD4\u56DE content`);
|
|
7754
7780
|
return { content: d.content, sourceKind: d.source?.kind };
|
|
7755
7781
|
}
|
|
7756
7782
|
};
|
|
@@ -8448,7 +8474,7 @@ async function resolvePackageIdentity(api2, opts) {
|
|
|
8448
8474
|
async function envExportConfigCommand(args) {
|
|
8449
8475
|
try {
|
|
8450
8476
|
if (!args.out) throw new CliError23({ code: CliErrorCode23.MISSING_FLAG, message: "\u7F3A --out <dir>", context: { nextStep: "hcm env export-config --out ./export-<\u73AF\u5883\u540D>" } });
|
|
8451
|
-
const outDir =
|
|
8477
|
+
const outDir = path6.resolve(args.out);
|
|
8452
8478
|
const columnSlots = args.columnSlots ?? "to-flex";
|
|
8453
8479
|
if (columnSlots !== "to-flex" && columnSlots !== "keep") {
|
|
8454
8480
|
throw new CliError23({
|
|
@@ -8472,12 +8498,12 @@ async function envExportConfigCommand(args) {
|
|
|
8472
8498
|
`)
|
|
8473
8499
|
});
|
|
8474
8500
|
if (args.force) {
|
|
8475
|
-
await fs7.rm(
|
|
8476
|
-
await fs7.rm(
|
|
8501
|
+
await fs7.rm(path6.join(outDir, "data"), { recursive: true, force: true });
|
|
8502
|
+
await fs7.rm(path6.join(outDir, "extensions"), { recursive: true, force: true });
|
|
8477
8503
|
}
|
|
8478
8504
|
for (const [rel, content] of result.files) {
|
|
8479
|
-
const abs =
|
|
8480
|
-
await fs7.mkdir(
|
|
8505
|
+
const abs = path6.join(outDir, rel);
|
|
8506
|
+
await fs7.mkdir(path6.dirname(abs), { recursive: true });
|
|
8481
8507
|
await fs7.writeFile(abs, content, "utf8");
|
|
8482
8508
|
}
|
|
8483
8509
|
const r = result.report;
|
|
@@ -8503,7 +8529,7 @@ async function envExportConfigCommand(args) {
|
|
|
8503
8529
|
}, null, 2) + "\n");
|
|
8504
8530
|
process.stderr.write(renderColumnSlots(r.columnSlots));
|
|
8505
8531
|
if (r.status === "DEGRADED") {
|
|
8506
|
-
process.stderr.write(`\u5BFC\u51FA\u4E0D\u5B8C\u6574\uFF08DEGRADED\uFF0C\u9000\u51FA\u7801 3\uFF09\uFF1A\u8BE6\u89C1 ${
|
|
8532
|
+
process.stderr.write(`\u5BFC\u51FA\u4E0D\u5B8C\u6574\uFF08DEGRADED\uFF0C\u9000\u51FA\u7801 3\uFF09\uFF1A\u8BE6\u89C1 ${path6.join(outDir, "export-report.json")} \u7684 degradedReasons / unresolvedReferences\u3002
|
|
8507
8533
|
`);
|
|
8508
8534
|
}
|
|
8509
8535
|
process.stderr.write(renderNextSteps(outDir, r));
|
|
@@ -8551,7 +8577,7 @@ function renderNextSteps(outDir, r) {
|
|
|
8551
8577
|
init_exit();
|
|
8552
8578
|
init_auth_guard();
|
|
8553
8579
|
import { promises as fs8 } from "fs";
|
|
8554
|
-
import * as
|
|
8580
|
+
import * as path7 from "path";
|
|
8555
8581
|
import yaml2 from "js-yaml";
|
|
8556
8582
|
import { HcmClient as HcmClient23, fromAxiosError as fromAxiosError22, CliError as CliError24, CliErrorCode as CliErrorCode24 } from "@hcmai/sdk";
|
|
8557
8583
|
var FINGERPRINT_MODELS = ["Employee", "OrgUnit", "Position", "Assignment"];
|
|
@@ -9221,7 +9247,7 @@ async function envFingerprintCommand(args) {
|
|
|
9221
9247
|
`) });
|
|
9222
9248
|
assertRedLine(fp, fieldMetas);
|
|
9223
9249
|
const text2 = yaml2.dump(fp, { lineWidth: -1, noRefs: true });
|
|
9224
|
-
const outFile =
|
|
9250
|
+
const outFile = path7.resolve(args.out);
|
|
9225
9251
|
await fs8.writeFile(outFile, text2, "utf8");
|
|
9226
9252
|
const summary = {
|
|
9227
9253
|
out: outFile,
|
|
@@ -9277,8 +9303,9 @@ async function envFingerprintCommand(args) {
|
|
|
9277
9303
|
init_exit();
|
|
9278
9304
|
import { promises as fsp2 } from "fs";
|
|
9279
9305
|
import os3 from "os";
|
|
9280
|
-
import
|
|
9306
|
+
import path12 from "path";
|
|
9281
9307
|
import { createHash as createHash4 } from "crypto";
|
|
9308
|
+
import axios4 from "axios";
|
|
9282
9309
|
import {
|
|
9283
9310
|
createHttpClient as createHttpClient2,
|
|
9284
9311
|
fetchSkillCatalog,
|
|
@@ -9498,7 +9525,7 @@ function boundaryFallbackLine(reason, notFetchedBy) {
|
|
|
9498
9525
|
|
|
9499
9526
|
// src/commands/chiron-project.ts
|
|
9500
9527
|
import { promises as fs10 } from "fs";
|
|
9501
|
-
import
|
|
9528
|
+
import path9 from "path";
|
|
9502
9529
|
|
|
9503
9530
|
// src/commands/chiron-case.ts
|
|
9504
9531
|
init_exit();
|
|
@@ -9506,10 +9533,10 @@ import { execFile } from "child_process";
|
|
|
9506
9533
|
import { promisify } from "util";
|
|
9507
9534
|
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync as readFileSync5, rmSync, statSync as statSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
9508
9535
|
import os2 from "os";
|
|
9509
|
-
import
|
|
9536
|
+
import path8 from "path";
|
|
9510
9537
|
import { CASES_REPO_SLUG, CASES_REPO_URL, CNB_ORIGIN, CliError as CliError26, CliErrorCode as CliErrorCode26, formatObject as formatObject19 } from "@hcmai/sdk";
|
|
9511
|
-
var casesCacheDir = () => process.env.HCM_CASES_CACHE?.trim() ||
|
|
9512
|
-
var INDEX_CACHE = () =>
|
|
9538
|
+
var casesCacheDir = () => process.env.HCM_CASES_CACHE?.trim() || path8.join(os2.homedir(), ".cache", "hcm", "chiron-cases");
|
|
9539
|
+
var INDEX_CACHE = () => path8.join(casesCacheDir(), "index.json");
|
|
9513
9540
|
var INDEX_TTL_MS = 60 * 60 * 1e3;
|
|
9514
9541
|
var fail5 = (message, nextStep, context = {}) => new CliError26({ code: CliErrorCode26.INVALID_ARGUMENT, message, context: { nextStep, ...context } });
|
|
9515
9542
|
var execFileAsync = promisify(execFile);
|
|
@@ -9521,7 +9548,7 @@ function stderrCause(stderr) {
|
|
|
9521
9548
|
}
|
|
9522
9549
|
var runCaseProcess = async (cmd, args, opts = {}) => {
|
|
9523
9550
|
const { timeoutMs, label: given, ...rest } = opts;
|
|
9524
|
-
const label = given ?? [
|
|
9551
|
+
const label = given ?? [path8.basename(cmd), args[0] && !args[0].startsWith("-") ? path8.basename(args[0]) : args[0] ?? ""].join(" ").trim();
|
|
9525
9552
|
try {
|
|
9526
9553
|
const pending = execFileAsync(cmd, args, { encoding: "utf8", maxBuffer: 1 << 26, timeout: timeoutMs ?? 0, ...rest });
|
|
9527
9554
|
pending.child.stdin?.end();
|
|
@@ -9547,8 +9574,8 @@ var CNB_NOT_FOUND = "\u627E\u4E0D\u5230 cnb \u53EF\u6267\u884C\u6587\u4EF6\uFF08
|
|
|
9547
9574
|
var CNB_NOT_FOUND_NEXT = "\u88C5 cnb\uFF1A`npm i -g @cnbcool/cnb-cli`\uFF0C\u518D `cnb login`\uFF1B\u88C5\u8FC7\u5C31\u68C0\u67E5 PATH\uFF08Windows \u4E0A `where cnb` \u5E94\u5217\u51FA cnb.exe \u6216\u5305\u7BA1\u7406\u5668\u751F\u6210\u7684 cnb.cmd\uFF0C\u7528 Volta \u7684\u8981\u6709 volta.exe\uFF1B\u81EA\u5DF1\u5199\u7684 .bat / .cmd \u5305\u88C5\u8BA4\u4E0D\u51FA\uFF09\uFF0C\u88C5\u574F\u4E86\u5C31\u91CD\u88C5\u3002\u53D6\u4E0D\u5230\u6848\u4F8B\u5E93\u4E0D\u62E6\u8DEF\uFF1A\u5148\u8DF3\u8FC7\u5B83\u6309\u6280\u80FD\u505A\uFF0C\u522B\u628A\u300C\u53D6\u4E0D\u5230\u300D\u5F53\u6210\u300C\u6CA1\u6709\u5148\u4F8B\u300D\u3002";
|
|
9548
9575
|
var CNB_NETWORK_CAUSE = /ECONN\w*|ENOTFOUND|EAI_AGAIN|ETIMEDOUT|fetch failed|socket|TLS/i;
|
|
9549
9576
|
var CNB_LOGIN_CAUSE = /未登录|登录凭证|登录失效|cnb login|unauthori[sz]ed/i;
|
|
9550
|
-
var windowsPathDirs = (pathVar, p =
|
|
9551
|
-
function shimTarget(dir, text2, p =
|
|
9577
|
+
var windowsPathDirs = (pathVar, p = path8) => pathVar.split(";").map((d) => d.trim().replace(/^"(.*)"$/, "$1")).filter((d) => p.isAbsolute(d));
|
|
9578
|
+
function shimTarget(dir, text2, p = path8) {
|
|
9552
9579
|
const rel = /"%~?dp0%?[\\/]([^"%]+\.[cm]?js)"/i.exec(text2)?.[1];
|
|
9553
9580
|
return rel ? p.join(dir, ...rel.split(/[\\/]/)) : /"([A-Za-z]:[\\/][^"%]+\.[cm]?js)"/.exec(text2)?.[1];
|
|
9554
9581
|
}
|
|
@@ -9566,9 +9593,9 @@ function resolveCnb() {
|
|
|
9566
9593
|
return r;
|
|
9567
9594
|
};
|
|
9568
9595
|
for (const dir of dirs) {
|
|
9569
|
-
const exe =
|
|
9596
|
+
const exe = path8.join(dir, "cnb.exe");
|
|
9570
9597
|
if (existsSync(exe)) return use({ cmd: exe, prefix: [] });
|
|
9571
|
-
for (const shim of ["cnb.cmd", "cnb.bat"].map((f) =>
|
|
9598
|
+
for (const shim of ["cnb.cmd", "cnb.bat"].map((f) => path8.join(dir, f)).filter((f) => existsSync(f))) {
|
|
9572
9599
|
let text2;
|
|
9573
9600
|
try {
|
|
9574
9601
|
text2 = readFileSync5(shim, "utf8");
|
|
@@ -9577,7 +9604,7 @@ function resolveCnb() {
|
|
|
9577
9604
|
continue;
|
|
9578
9605
|
}
|
|
9579
9606
|
if (/^\s*volta run %~n0 %\*\s*$/im.test(text2)) {
|
|
9580
|
-
const volta = dirs.map((d) =>
|
|
9607
|
+
const volta = dirs.map((d) => path8.join(d, "volta.exe")).find((f) => existsSync(f));
|
|
9581
9608
|
if (volta) return use({ cmd: volta, prefix: ["run", "cnb"] });
|
|
9582
9609
|
blocked ??= `\u627E\u5230\u4E86 Volta \u7684 ${shim}\uFF0C\u4F46 PATH \u91CC\u6CA1\u6709 volta.exe`;
|
|
9583
9610
|
continue;
|
|
@@ -9675,7 +9702,7 @@ async function loadIndex(opts = {}) {
|
|
|
9675
9702
|
const cases2 = JSON.parse(text2).cases;
|
|
9676
9703
|
const fetchedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
9677
9704
|
if (opts.writeCache !== false) {
|
|
9678
|
-
mkdirSync(
|
|
9705
|
+
mkdirSync(path8.dirname(file), { recursive: true });
|
|
9679
9706
|
writeFileSync2(file, text2);
|
|
9680
9707
|
}
|
|
9681
9708
|
return { cases: cases2, source: "live", fetchedAt };
|
|
@@ -9855,16 +9882,16 @@ async function caseMatchCommand(args) {
|
|
|
9855
9882
|
}
|
|
9856
9883
|
async function caseSubmitCommand(dir, args) {
|
|
9857
9884
|
await guard(async () => {
|
|
9858
|
-
const src =
|
|
9859
|
-
if (!existsSync(
|
|
9885
|
+
const src = path8.resolve(dir);
|
|
9886
|
+
if (!existsSync(path8.join(src, "case.yml"))) {
|
|
9860
9887
|
throw fail5(`${src} \u91CC\u6CA1\u6709 case.yml`, "\u6307\u5230\u9879\u76EE\u4ED3\u7684\u6848\u4F8B\u76EE\u5F55\uFF08\u5982 cases/CASE-20260902-xxx\uFF09\uFF0C\u90A3\u91CC\u5E94\u5F53\u6709 case.yml\u3002");
|
|
9861
9888
|
}
|
|
9862
|
-
const yamlText = readFileSync5(
|
|
9889
|
+
const yamlText = readFileSync5(path8.join(src, "case.yml"), "utf8");
|
|
9863
9890
|
const id = /^\s*(?:id|case_id):\s*(\S+)/m.exec(yamlText)?.[1];
|
|
9864
9891
|
if (!id) throw fail5("case.yml \u91CC\u6CA1\u6709 id", "case.yml \u9876\u5C42\u8981\u6709 `id: CASE-YYYYMMDD-xxx`\u3002");
|
|
9865
|
-
const work = mkdtempSync(
|
|
9892
|
+
const work = mkdtempSync(path8.join(os2.tmpdir(), "hcm-case-submit-"));
|
|
9866
9893
|
try {
|
|
9867
|
-
const repo =
|
|
9894
|
+
const repo = path8.join(work, "chiron-cases");
|
|
9868
9895
|
try {
|
|
9869
9896
|
await run("git", ["clone", "--depth", "1", "--filter=blob:none", "--quiet", CASES_REPO_URL, repo]);
|
|
9870
9897
|
} catch (e) {
|
|
@@ -9875,10 +9902,10 @@ async function caseSubmitCommand(dir, args) {
|
|
|
9875
9902
|
}
|
|
9876
9903
|
const branch = `case/${id}-submit`;
|
|
9877
9904
|
await run("git", ["-C", repo, "checkout", "-q", "-B", branch]);
|
|
9878
|
-
const dst =
|
|
9905
|
+
const dst = path8.join(repo, "cases", args.category, id);
|
|
9879
9906
|
cpSync(src, dst, { recursive: true, filter: (p) => !p.includes("node_modules") });
|
|
9880
|
-
mkdirSync(
|
|
9881
|
-
let doc = readFileSync5(
|
|
9907
|
+
mkdirSync(path8.join(dst, "evidence"), { recursive: true });
|
|
9908
|
+
let doc = readFileSync5(path8.join(dst, "case.yml"), "utf8");
|
|
9882
9909
|
doc = /^\s*tier:/m.test(doc) ? doc.replace(/^\s*tier:.*$/m, "tier: public") : `tier: public
|
|
9883
9910
|
${doc}`;
|
|
9884
9911
|
doc = /^\s*category:/m.test(doc) ? doc.replace(/^\s*category:.*$/m, `category: ${args.category}`) : `category: ${args.category}
|
|
@@ -9887,7 +9914,7 @@ ${doc}`;
|
|
|
9887
9914
|
${doc}`;
|
|
9888
9915
|
if (!/^\s*status:/m.test(doc)) doc = `status: approved
|
|
9889
9916
|
${doc}`;
|
|
9890
|
-
writeFileSync2(
|
|
9917
|
+
writeFileSync2(path8.join(dst, "case.yml"), doc);
|
|
9891
9918
|
await run("python3", ["scripts/render-readme.py", dst], { cwd: repo });
|
|
9892
9919
|
let lint;
|
|
9893
9920
|
try {
|
|
@@ -9943,10 +9970,10 @@ var SKILLS_DIR = "hcm-skills";
|
|
|
9943
9970
|
var SKILLS_SYNC_SUBDIR = "sync";
|
|
9944
9971
|
var SKILLS_LOCAL_SUBDIR = "local";
|
|
9945
9972
|
function skillsSyncDir(root) {
|
|
9946
|
-
return
|
|
9973
|
+
return path9.join(root, SKILLS_DIR, SKILLS_SYNC_SUBDIR);
|
|
9947
9974
|
}
|
|
9948
9975
|
function skillsLocalDir(root) {
|
|
9949
|
-
return
|
|
9976
|
+
return path9.join(root, SKILLS_DIR, SKILLS_LOCAL_SUBDIR);
|
|
9950
9977
|
}
|
|
9951
9978
|
var CHIRON_PROJECT_DIRECTORIES = [
|
|
9952
9979
|
"work",
|
|
@@ -10042,13 +10069,13 @@ async function inspectJira(opts = {}) {
|
|
|
10042
10069
|
|
|
10043
10070
|
// src/commands/skills-bundled.ts
|
|
10044
10071
|
import { existsSync as existsSync3, statSync as statSync5, promises as fsp } from "fs";
|
|
10045
|
-
import * as
|
|
10072
|
+
import * as path11 from "path";
|
|
10046
10073
|
import { CliError as CliError27, CliErrorCode as CliErrorCode27, assertSafeReferencePath, parseSkillRequirements } from "@hcmai/sdk";
|
|
10047
10074
|
|
|
10048
10075
|
// src/commands/skills-manifest.ts
|
|
10049
10076
|
import { readFileSync as readFileSync6, readdirSync as readdirSync2, statSync as statSync4, existsSync as existsSync2 } from "fs";
|
|
10050
10077
|
import { createHash as createHash3 } from "crypto";
|
|
10051
|
-
import * as
|
|
10078
|
+
import * as path10 from "path";
|
|
10052
10079
|
import { fileURLToPath } from "url";
|
|
10053
10080
|
import { formatObject as formatObject20, parseSkillFrontmatter } from "@hcmai/sdk";
|
|
10054
10081
|
function collectCommandSurface(root) {
|
|
@@ -10067,8 +10094,8 @@ function collectCommandSurface(root) {
|
|
|
10067
10094
|
return out.sort((a, b) => a.path.localeCompare(b.path));
|
|
10068
10095
|
}
|
|
10069
10096
|
function bundledSkillsDir() {
|
|
10070
|
-
const here =
|
|
10071
|
-
return
|
|
10097
|
+
const here = path10.dirname(fileURLToPath(import.meta.url));
|
|
10098
|
+
return path10.join(here, "skills");
|
|
10072
10099
|
}
|
|
10073
10100
|
function sha256(buf) {
|
|
10074
10101
|
return createHash3("sha256").update(buf).digest("hex");
|
|
@@ -10076,7 +10103,7 @@ function sha256(buf) {
|
|
|
10076
10103
|
function listFiles(dir, rel = "") {
|
|
10077
10104
|
const out = [];
|
|
10078
10105
|
for (const name of readdirSync2(dir)) {
|
|
10079
|
-
const p =
|
|
10106
|
+
const p = path10.join(dir, name);
|
|
10080
10107
|
const r = rel ? `${rel}/${name}` : name;
|
|
10081
10108
|
if (statSync4(p).isDirectory()) out.push(...listFiles(p, r));
|
|
10082
10109
|
else out.push(r);
|
|
@@ -10087,17 +10114,17 @@ function collectBundledSkills(dir = bundledSkillsDir()) {
|
|
|
10087
10114
|
if (!existsSync2(dir)) return [];
|
|
10088
10115
|
const out = [];
|
|
10089
10116
|
for (const id of readdirSync2(dir).sort()) {
|
|
10090
|
-
const skillDir =
|
|
10117
|
+
const skillDir = path10.join(dir, id);
|
|
10091
10118
|
if (!statSync4(skillDir).isDirectory()) continue;
|
|
10092
10119
|
const files = listFiles(skillDir).sort();
|
|
10093
10120
|
if (!files.includes("SKILL.md")) continue;
|
|
10094
10121
|
let bytes = 0;
|
|
10095
10122
|
const fileRows = files.map((rel) => {
|
|
10096
|
-
const buf = readFileSync6(
|
|
10123
|
+
const buf = readFileSync6(path10.join(skillDir, rel));
|
|
10097
10124
|
bytes += buf.byteLength;
|
|
10098
10125
|
return { path: rel, bytes: buf.byteLength, sha256: sha256(buf) };
|
|
10099
10126
|
});
|
|
10100
|
-
const body = readFileSync6(
|
|
10127
|
+
const body = readFileSync6(path10.join(skillDir, "SKILL.md"), "utf8");
|
|
10101
10128
|
const fm = parseSkillFrontmatter(body, id);
|
|
10102
10129
|
out.push({
|
|
10103
10130
|
id,
|
|
@@ -10159,7 +10186,7 @@ function unreachable(id, detail) {
|
|
|
10159
10186
|
});
|
|
10160
10187
|
}
|
|
10161
10188
|
async function readBundledReferences(skillDir) {
|
|
10162
|
-
const root =
|
|
10189
|
+
const root = path11.join(skillDir, "references");
|
|
10163
10190
|
const out = [];
|
|
10164
10191
|
const walk = async (dir, prefix) => {
|
|
10165
10192
|
let items;
|
|
@@ -10172,22 +10199,22 @@ async function readBundledReferences(skillDir) {
|
|
|
10172
10199
|
for (const item of items.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
10173
10200
|
const relative3 = prefix ? `${prefix}/${item.name}` : item.name;
|
|
10174
10201
|
if (item.isDirectory()) {
|
|
10175
|
-
await walk(
|
|
10202
|
+
await walk(path11.join(dir, item.name), relative3);
|
|
10176
10203
|
continue;
|
|
10177
10204
|
}
|
|
10178
10205
|
if (!item.isFile()) continue;
|
|
10179
10206
|
assertSafeReferencePath(relative3);
|
|
10180
|
-
out.push({ path: relative3, content: await fsp.readFile(
|
|
10207
|
+
out.push({ path: relative3, content: await fsp.readFile(path11.join(dir, item.name), "utf8") });
|
|
10181
10208
|
}
|
|
10182
10209
|
};
|
|
10183
10210
|
await walk(root, "");
|
|
10184
10211
|
return out;
|
|
10185
10212
|
}
|
|
10186
10213
|
async function readBundledSkillDocument(id, dir = bundledSkillsDir()) {
|
|
10187
|
-
const skillDir =
|
|
10214
|
+
const skillDir = path11.join(dir, id);
|
|
10188
10215
|
let markdown;
|
|
10189
10216
|
try {
|
|
10190
|
-
markdown = await fsp.readFile(
|
|
10217
|
+
markdown = await fsp.readFile(path11.join(skillDir, "SKILL.md"), "utf8");
|
|
10191
10218
|
} catch (cause) {
|
|
10192
10219
|
if (cause?.code === "ENOENT") throw unreachable(id, "SKILL.md \u4E0D\u5B58\u5728");
|
|
10193
10220
|
throw cause;
|
|
@@ -10339,9 +10366,9 @@ async function exists(target) {
|
|
|
10339
10366
|
}
|
|
10340
10367
|
}
|
|
10341
10368
|
async function detectTarget(cwd) {
|
|
10342
|
-
if (await exists(
|
|
10343
|
-
if (await exists(
|
|
10344
|
-
if (await exists(
|
|
10369
|
+
if (await exists(path12.join(cwd, ".claude"))) return "claude";
|
|
10370
|
+
if (await exists(path12.join(cwd, "AGENTS.md"))) return "codex";
|
|
10371
|
+
if (await exists(path12.join(cwd, ".codex"))) return "codex";
|
|
10345
10372
|
return void 0;
|
|
10346
10373
|
}
|
|
10347
10374
|
var DIR_ROOT_WRITE_TARGETS = ["AGENTS.md", "CLAUDE.md", SKILLS_STATE_FILE];
|
|
@@ -10354,15 +10381,15 @@ async function assertDirWriteTargetsConfined(dir) {
|
|
|
10354
10381
|
throw cause;
|
|
10355
10382
|
}
|
|
10356
10383
|
for (const name of DIR_ROOT_WRITE_TARGETS) {
|
|
10357
|
-
const file =
|
|
10384
|
+
const file = path12.join(root, name);
|
|
10358
10385
|
const stat = await fsp2.lstat(file).catch((cause) => {
|
|
10359
10386
|
if (cause.code === "ENOENT") return null;
|
|
10360
10387
|
throw cause;
|
|
10361
10388
|
});
|
|
10362
10389
|
if (!stat?.isSymbolicLink()) continue;
|
|
10363
10390
|
const destination = await fsp2.realpath(file).catch(() => null);
|
|
10364
|
-
const relative3 = destination === null ? null :
|
|
10365
|
-
if (relative3 === null || relative3 === ".." || relative3.startsWith(`..${
|
|
10391
|
+
const relative3 = destination === null ? null : path12.relative(root, destination);
|
|
10392
|
+
if (relative3 === null || relative3 === ".." || relative3.startsWith(`..${path12.sep}`) || path12.isAbsolute(relative3)) {
|
|
10366
10393
|
throw new CliError28({
|
|
10367
10394
|
code: CliErrorCode28.INVALID_ARGUMENT,
|
|
10368
10395
|
message: `--dir \u4E0B\u7684 ${name} \u662F\u7B26\u53F7\u94FE\u63A5\uFF0C\u6307\u5411${destination === null ? "\u4E00\u4E2A\u4E0D\u5B58\u5728\u7684\u76EE\u6807" : `\u76EE\u5F55\u5916\u7684 ${destination}`}\uFF1B\u672C\u547D\u4EE4\u4F1A\u6539\u5199\u5B83\uFF0C\u62D2\u7EDD\u7ECF\u94FE\u63A5\u5199\u5230 --dir \u4E4B\u5916\u3002\u672C\u6B21\u6CA1\u6709\u5199\u76D8\u3002`,
|
|
@@ -10374,22 +10401,22 @@ async function assertDirWriteTargetsConfined(dir) {
|
|
|
10374
10401
|
async function resolveInstallLayout(args, cwd = process.cwd(), forWrite = false) {
|
|
10375
10402
|
const requested = parseSkillTarget(args.target);
|
|
10376
10403
|
const target = requested ?? await detectTarget(cwd) ?? "claude";
|
|
10377
|
-
const explicitDir = args.dir ?
|
|
10404
|
+
const explicitDir = args.dir ? path12.resolve(args.dir) : void 0;
|
|
10378
10405
|
if (explicitDir && forWrite) await assertDirWriteTargetsConfined(explicitDir);
|
|
10379
10406
|
if (target === "codex") {
|
|
10380
|
-
const root = explicitDir ?? (args.global ?
|
|
10381
|
-
const claudeFile =
|
|
10407
|
+
const root = explicitDir ?? (args.global ? path12.join(os3.homedir(), ".codex") : cwd);
|
|
10408
|
+
const claudeFile = path12.join(root, "CLAUDE.md");
|
|
10382
10409
|
return {
|
|
10383
10410
|
target,
|
|
10384
10411
|
baseDir: explicitDir ?? skillsSyncDir(root),
|
|
10385
10412
|
localDir: explicitDir ? void 0 : skillsLocalDir(root),
|
|
10386
|
-
agentsFile:
|
|
10413
|
+
agentsFile: path12.join(root, "AGENTS.md"),
|
|
10387
10414
|
companionAgentFiles: (explicitDir || !args.global) && await exists(claudeFile) ? [claudeFile] : []
|
|
10388
10415
|
};
|
|
10389
10416
|
}
|
|
10390
10417
|
return {
|
|
10391
10418
|
target,
|
|
10392
|
-
baseDir: explicitDir ?? (args.global ?
|
|
10419
|
+
baseDir: explicitDir ?? (args.global ? path12.join(os3.homedir(), ".claude", "skills") : path12.join(cwd, ".claude", "skills"))
|
|
10393
10420
|
};
|
|
10394
10421
|
}
|
|
10395
10422
|
async function chironClient(args, options = {}) {
|
|
@@ -10428,7 +10455,16 @@ async function beforeAnyWrite(step2) {
|
|
|
10428
10455
|
function fail6(e, args) {
|
|
10429
10456
|
const err = e;
|
|
10430
10457
|
if (err?.response?.status === 404) {
|
|
10431
|
-
|
|
10458
|
+
let requestPath;
|
|
10459
|
+
try {
|
|
10460
|
+
if (err.config?.url) requestPath = new URL(axios4.getUri(err.config), "https://request-path.invalid").pathname;
|
|
10461
|
+
} catch {
|
|
10462
|
+
}
|
|
10463
|
+
const traceId = fromAxiosError23(err, args.env).traceId;
|
|
10464
|
+
exitWithError(new Error(
|
|
10465
|
+
`\u6280\u80FD\u8D44\u6E90\u8BF7\u6C42\u8FD4\u56DE HTTP 404${requestPath ? `\uFF1A${requestPath}` : "\uFF08\u8BF7\u6C42\u8DEF\u5F84\u672A\u77E5\uFF09"}${traceId ? ` [traceId: ${traceId}]` : ""}\u3002
|
|
10466
|
+
\u4E0B\u4E00\u6B65: \u8FD0\u884C hcm skills list \u6838\u5BF9\u5F53\u524D\u76EE\u5F55\uFF1B\u82E5\u76EE\u5F55\u4ECD\u58F0\u660E\u8BE5\u8D44\u6E90\uFF0C\u8BF7\u68C0\u67E5\u670D\u52A1\u7AEF\u8D44\u6E90\u548C\u5B9E\u4F8B\u7248\u672C\uFF0C\u518D\u91CD\u8BD5\u3002`
|
|
10467
|
+
));
|
|
10432
10468
|
}
|
|
10433
10469
|
if (err?.isAxiosError) exitWithError(fromAxiosError23(err, args.env));
|
|
10434
10470
|
exitWithError(e);
|
|
@@ -10588,7 +10624,7 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
|
|
|
10588
10624
|
process.exitCode = 0;
|
|
10589
10625
|
return;
|
|
10590
10626
|
}
|
|
10591
|
-
process.stdout.write(`${
|
|
10627
|
+
process.stdout.write(`${path12.join(layout.baseDir, SKILLS_STATE_FILE)} \u4E0D\u5B58\u5728\u6216\u4E3A\u7A7A \u2014\u2014 \u8FD9\u4E2A\u76EE\u5F55\u4E0B\u8FD8\u6CA1\u7528\u672C CLI \u88C5\u8FC7\u6280\u80FD\u3002
|
|
10592
10628
|
`);
|
|
10593
10629
|
process.stdout.write(" \u5168\u90E8\u88C5\u9F50\uFF1Ahcm chiron skills sync\n");
|
|
10594
10630
|
process.exitCode = 0;
|
|
@@ -10619,7 +10655,7 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
|
|
|
10619
10655
|
id: x.id,
|
|
10620
10656
|
title: x.title,
|
|
10621
10657
|
sourceKind: "local",
|
|
10622
|
-
sourceLocator:
|
|
10658
|
+
sourceLocator: path12.relative(path12.dirname(layout.baseDir), x.absolute).split(path12.sep).join("/"),
|
|
10623
10659
|
direct: true,
|
|
10624
10660
|
installedAt: void 0,
|
|
10625
10661
|
status: "installed"
|
|
@@ -10777,7 +10813,7 @@ async function skillsInstallCommand(id, args) {
|
|
|
10777
10813
|
let manifest2;
|
|
10778
10814
|
let conflictNote;
|
|
10779
10815
|
if (args.from) {
|
|
10780
|
-
const root =
|
|
10816
|
+
const root = path12.resolve(args.from);
|
|
10781
10817
|
requestedIds = all ? await listLocalSkillIds(root) : [id];
|
|
10782
10818
|
const seen = /* @__PURE__ */ new Set();
|
|
10783
10819
|
documents = [];
|
|
@@ -10927,7 +10963,7 @@ async function skillsInstallCommand(id, args) {
|
|
|
10927
10963
|
agentIndexes: agentIndexes2
|
|
10928
10964
|
}, { format: fmtCheck }) + "\n");
|
|
10929
10965
|
} else {
|
|
10930
|
-
process.stdout.write(installDir === layout.baseDir ? `\u8FD9\u4E2A\u76EE\u5F55\u8FD8\u6CA1\u88C5\u8FC7\u6280\u80FD\uFF08${
|
|
10966
|
+
process.stdout.write(installDir === layout.baseDir ? `\u8FD9\u4E2A\u76EE\u5F55\u8FD8\u6CA1\u88C5\u8FC7\u6280\u80FD\uFF08${path12.join(layout.baseDir, SKILLS_STATE_FILE)} \u4E0D\u5B58\u5728\uFF09\u3002
|
|
10931
10967
|
` : `--from \u53D6\u6765\u7684\u6280\u80FD\u843D ${SKILLS_LOCAL_SUBDIR}/\uFF08\u4F60\u81EA\u5DF1\u7684\u90A3\u4E00\u534A\uFF0C\u4E0D\u8FDB\u9501\u6587\u4EF6\uFF09\u3002
|
|
10932
10968
|
`);
|
|
10933
10969
|
process.stdout.write(`--check\uFF1A\u4F1A\u88C5 ${would.length} \u4E2A\u6280\u80FD\u5230 ${installDir}\uFF0C${agentIndexes2.length > 0 ? `\u5E76\u628A\u7D22\u5F15\u4E0E\u9879\u76EE\u8FB9\u754C\u5757\u5199\u8FDB ${agentIndexes2.map((index) => index.file).join("\u3001")}` : "Claude Code \u81EA\u52A8\u53D1\u73B0\u6280\u80FD\uFF0C\u65E0\u7D22\u5F15\u6587\u4EF6"}\u3002**\u672C\u6B21\u4E00\u4E2A\u5B57\u8282\u90FD\u6CA1\u5199\u3002**
|
|
@@ -10955,7 +10991,7 @@ async function skillsInstallCommand(id, args) {
|
|
|
10955
10991
|
if (fmt === "json" || fmt === "yaml") {
|
|
10956
10992
|
process.stdout.write(formatObject21({ ...result, all, target_agent: layout.target, agentsFile: layout.agentsFile, agents, agentIndexes, conflictCheck: conflictNote ? { checked: false, note: conflictNote } : { checked: true } }, { format: fmt }) + "\n");
|
|
10957
10993
|
} else {
|
|
10958
|
-
const headline = all ? `\u2705 \u5168\u90E8 ${requestedIds.length} \u4E2A\u6280\u80FD \u2192 ${result.baseDir}` : `\u2705 ${id} \u2192 ${
|
|
10994
|
+
const headline = all ? `\u2705 \u5168\u90E8 ${requestedIds.length} \u4E2A\u6280\u80FD \u2192 ${result.baseDir}` : `\u2705 ${id} \u2192 ${path12.join(result.baseDir, id, "SKILL.md")}`;
|
|
10959
10995
|
process.stdout.write(`${headline}
|
|
10960
10996
|
`);
|
|
10961
10997
|
if (result.installed.length > 0) {
|
|
@@ -10974,17 +11010,17 @@ async function skillsInstallCommand(id, args) {
|
|
|
10974
11010
|
`);
|
|
10975
11011
|
}
|
|
10976
11012
|
for (const index of agentIndexes) {
|
|
10977
|
-
const reader =
|
|
11013
|
+
const reader = path12.basename(index.file) === "CLAUDE.md" ? "Claude Code" : "Codex";
|
|
10978
11014
|
process.stdout.write(` \u5DF2${index.status === "created" ? "\u521B\u5EFA" : "\u66F4\u65B0"} ${index.file} \u91CC\u7684\u6280\u80FD\u7D22\u5F15\u4E0E\u9879\u76EE\u8FB9\u754C\u5757\uFF08${reader} \u8BFB\u8FD9\u91CC\uFF09
|
|
10979
11015
|
`);
|
|
10980
11016
|
}
|
|
10981
11017
|
const fallback = agentIndexes.find((i) => i.boundary === "cli-fallback");
|
|
10982
11018
|
if (fallback) {
|
|
10983
|
-
const by = args.from ? `--from ${
|
|
11019
|
+
const by = args.from ? `--from ${path12.resolve(args.from)}` : `--source ${args.source ?? "all"}`;
|
|
10984
11020
|
process.stdout.write(` ${boundaryFallbackLine(fallback.boundaryFallbackReason, by)}
|
|
10985
11021
|
`);
|
|
10986
11022
|
}
|
|
10987
|
-
process.stdout.write(` \u6765\u6E90 ${endpoint ?? (args.from ?
|
|
11023
|
+
process.stdout.write(` \u6765\u6E90 ${endpoint ?? (args.from ? path12.resolve(args.from) : `@hcmai/cli@${CLI_VERSION}`)}
|
|
10988
11024
|
`);
|
|
10989
11025
|
if (conflictNote) process.stdout.write(` \u26A0\uFE0F ${conflictNote}
|
|
10990
11026
|
`);
|
|
@@ -11021,7 +11057,7 @@ async function listLocalSkillIds(root) {
|
|
|
11021
11057
|
const ids = [];
|
|
11022
11058
|
for (const entry of entries) {
|
|
11023
11059
|
if (!entry.isDirectory()) continue;
|
|
11024
|
-
if (await exists(
|
|
11060
|
+
if (await exists(path12.join(root, entry.name, "SKILL.md"))) ids.push(entry.name);
|
|
11025
11061
|
}
|
|
11026
11062
|
if (ids.length === 0) throw invalid(`\u672C\u5730\u76EE\u5F55\u91CC\u6CA1\u6709\u4EFB\u4F55 <id>/SKILL.md\uFF1A${root}`);
|
|
11027
11063
|
return ids.sort();
|
|
@@ -11042,7 +11078,7 @@ async function fetchSkillDocument(http, skill, endpoint, base) {
|
|
|
11042
11078
|
}
|
|
11043
11079
|
async function ensureLocalSlot(localDir) {
|
|
11044
11080
|
if (!localDir) return;
|
|
11045
|
-
const keep =
|
|
11081
|
+
const keep = path12.join(localDir, ".gitkeep");
|
|
11046
11082
|
if (await fsp2.stat(localDir).then(() => true).catch(() => false)) return;
|
|
11047
11083
|
await fsp2.mkdir(localDir, { recursive: true });
|
|
11048
11084
|
await fsp2.writeFile(keep, "# \u4F60\u81EA\u5DF1\u5199\u7684\u6280\u80FD\u653E\u8FD9\u513F\u3002hcm chiron skills sync \u53EA\u7BA1\u9694\u58C1 sync/\uFF0C\u4E00\u4E2A\u5B57\u8282\u90FD\u4E0D\u78B0\u8FD9\u91CC\u3002\n", "utf8");
|
|
@@ -11051,7 +11087,7 @@ var isNotFound = (e) => ["ENOENT", "ENOTDIR"].includes(String(e?.code));
|
|
|
11051
11087
|
var SkillsDirUnreadable = class extends Error {
|
|
11052
11088
|
/** `claude`:`.claude/skills/` 那一半(产品版,双布局下与 local/ 对照遮蔽时才读,#399)。 */
|
|
11053
11089
|
constructor(side, dir, id, cause) {
|
|
11054
|
-
const where = id ?
|
|
11090
|
+
const where = id ? path12.join(dir, id, "SKILL.md") : dir, detail = cause instanceof Error ? cause.message : String(cause);
|
|
11055
11091
|
super(`${where}\uFF1A${detail}`);
|
|
11056
11092
|
this.side = side;
|
|
11057
11093
|
this.id = id;
|
|
@@ -11080,7 +11116,7 @@ function unreadableFix(code2, detail) {
|
|
|
11080
11116
|
if (code2 === "EACCES" || code2 === "EPERM") return "\u6CA1\u6709\u8BFB\u53D6\u6743\u9650\uFF0C\u4FEE\u597D\u6743\u9650";
|
|
11081
11117
|
return `\u8BFB\u53D6\u62A5 ${code2 ?? (detail || "\u672A\u77E5\u9519\u8BEF")}\uFF0C\u6309\u8FD9\u4E2A\u62A5\u9519\u4FEE\u597D`;
|
|
11082
11118
|
}
|
|
11083
|
-
var describeUnreadable = (list) => list.map((u) => `${u.id ??
|
|
11119
|
+
var describeUnreadable = (list) => list.map((u) => `${u.id ?? path12.basename(u.where)}\uFF08${unreadableFix(u.code, u.detail)}\uFF09`).join("\u3001");
|
|
11084
11120
|
async function readLocalSkills(localDir, { strict = false } = {}) {
|
|
11085
11121
|
if (!localDir) return [];
|
|
11086
11122
|
let names;
|
|
@@ -11092,7 +11128,7 @@ async function readLocalSkills(localDir, { strict = false } = {}) {
|
|
|
11092
11128
|
}
|
|
11093
11129
|
const out = [];
|
|
11094
11130
|
for (const id of names.sort()) {
|
|
11095
|
-
const absolute =
|
|
11131
|
+
const absolute = path12.join(localDir, id, "SKILL.md");
|
|
11096
11132
|
let markdown;
|
|
11097
11133
|
try {
|
|
11098
11134
|
markdown = await fsp2.readFile(absolute, "utf8");
|
|
@@ -11125,7 +11161,7 @@ async function listShadowedSkills(layout, productSide = "sync", tracked) {
|
|
|
11125
11161
|
const isProduct = async (id) => {
|
|
11126
11162
|
if (tracked && !tracked.has(id)) return false;
|
|
11127
11163
|
try {
|
|
11128
|
-
await fsp2.stat(
|
|
11164
|
+
await fsp2.stat(path12.join(layout.baseDir, id, "SKILL.md"));
|
|
11129
11165
|
return true;
|
|
11130
11166
|
} catch (e) {
|
|
11131
11167
|
if (!isNotFound(e)) throw new SkillsDirUnreadable(productSide, layout.baseDir, id, e);
|
|
@@ -11150,7 +11186,7 @@ async function listShadowedSkills(layout, productSide = "sync", tracked) {
|
|
|
11150
11186
|
}
|
|
11151
11187
|
const shadowed = [];
|
|
11152
11188
|
for (const s of locals) {
|
|
11153
|
-
if (await isProduct(s.id)) shadowed.push({ id: s.id, local: s.absolute, product:
|
|
11189
|
+
if (await isProduct(s.id)) shadowed.push({ id: s.id, local: s.absolute, product: path12.join(layout.baseDir, s.id, "SKILL.md"), note: s.firstLine });
|
|
11154
11190
|
}
|
|
11155
11191
|
return { local: locals.length, product, shadowed, unreadable };
|
|
11156
11192
|
}
|
|
@@ -11179,7 +11215,7 @@ var CLAUDE_SKILLS_DIR_LABEL = ".claude/skills/";
|
|
|
11179
11215
|
async function readClaudeLocalIndex(root) {
|
|
11180
11216
|
let text2;
|
|
11181
11217
|
try {
|
|
11182
|
-
text2 = await fsp2.readFile(
|
|
11218
|
+
text2 = await fsp2.readFile(path12.join(root, "CLAUDE.md"), "utf8");
|
|
11183
11219
|
} catch (e) {
|
|
11184
11220
|
if (isNotFound(e)) return { kind: "no-file" };
|
|
11185
11221
|
return { kind: "unreadable", detail: e instanceof Error ? e.message : String(e) };
|
|
@@ -11258,7 +11294,7 @@ async function reportClaudeShadows(claudeDir, root) {
|
|
|
11258
11294
|
async function resolveSkillPath(layout, id) {
|
|
11259
11295
|
assertSafeSkillId(id);
|
|
11260
11296
|
const at = async (dir) => {
|
|
11261
|
-
const file =
|
|
11297
|
+
const file = path12.join(dir, id, "SKILL.md");
|
|
11262
11298
|
return await fsp2.stat(file).then(() => file).catch(() => void 0);
|
|
11263
11299
|
};
|
|
11264
11300
|
const inSync = await at(layout.baseDir);
|
|
@@ -11268,12 +11304,12 @@ async function resolveSkillPath(layout, id) {
|
|
|
11268
11304
|
id,
|
|
11269
11305
|
file: inLocal,
|
|
11270
11306
|
half: "local",
|
|
11271
|
-
references:
|
|
11307
|
+
references: path12.join(layout.localDir, id, "references"),
|
|
11272
11308
|
...inSync ? { shadowed: inSync } : {}
|
|
11273
11309
|
};
|
|
11274
11310
|
}
|
|
11275
11311
|
if (inSync) {
|
|
11276
|
-
return { id, file: inSync, half: "sync", references:
|
|
11312
|
+
return { id, file: inSync, half: "sync", references: path12.join(layout.baseDir, id, "references") };
|
|
11277
11313
|
}
|
|
11278
11314
|
const looked = [
|
|
11279
11315
|
...layout.localDir ? [`${layout.localDir}/${id}/SKILL.md`] : [],
|
|
@@ -11318,11 +11354,11 @@ async function findShadowBypassingRefs(layout, shadowedIds) {
|
|
|
11318
11354
|
return [];
|
|
11319
11355
|
}
|
|
11320
11356
|
for (const from of ids.sort()) {
|
|
11321
|
-
const files = [
|
|
11322
|
-
const refDir =
|
|
11357
|
+
const files = [path12.join(layout.baseDir, from, "SKILL.md")];
|
|
11358
|
+
const refDir = path12.join(layout.baseDir, from, "references");
|
|
11323
11359
|
try {
|
|
11324
11360
|
for (const e of await fsp2.readdir(refDir, { withFileTypes: true })) {
|
|
11325
|
-
if (e.isFile()) files.push(
|
|
11361
|
+
if (e.isFile()) files.push(path12.join(refDir, e.name));
|
|
11326
11362
|
}
|
|
11327
11363
|
} catch {
|
|
11328
11364
|
}
|
|
@@ -11351,11 +11387,11 @@ async function syncAgentIndexes(layout, manifest2) {
|
|
|
11351
11387
|
const files = [layout.agentsFile, ...layout.companionAgentFiles ?? []];
|
|
11352
11388
|
const results = [];
|
|
11353
11389
|
for (const file of files) {
|
|
11354
|
-
const agentsDir =
|
|
11390
|
+
const agentsDir = path12.dirname(file);
|
|
11355
11391
|
const managed = await Promise.all(Object.keys(state?.skills ?? {}).sort().map(async (id) => {
|
|
11356
11392
|
const known = catalog.get(id);
|
|
11357
|
-
const absolute =
|
|
11358
|
-
let relative3 =
|
|
11393
|
+
const absolute = path12.join(layout.baseDir, id, "SKILL.md");
|
|
11394
|
+
let relative3 = path12.relative(agentsDir, absolute);
|
|
11359
11395
|
if (!relative3.startsWith(".")) relative3 = `./${relative3}`;
|
|
11360
11396
|
let title = known?.title;
|
|
11361
11397
|
let description = known?.description;
|
|
@@ -11378,19 +11414,19 @@ async function syncAgentIndexes(layout, manifest2) {
|
|
|
11378
11414
|
id,
|
|
11379
11415
|
title: title ?? id,
|
|
11380
11416
|
description: description ?? "",
|
|
11381
|
-
relativePath: relative3.split(
|
|
11417
|
+
relativePath: relative3.split(path12.sep).join("/")
|
|
11382
11418
|
};
|
|
11383
11419
|
}));
|
|
11384
11420
|
const shadowed = new Set(local.map((x) => x.id));
|
|
11385
11421
|
const localEntries = local.map((x) => {
|
|
11386
|
-
let relative3 =
|
|
11422
|
+
let relative3 = path12.relative(agentsDir, x.absolute);
|
|
11387
11423
|
if (!relative3.startsWith(".")) relative3 = `./${relative3}`;
|
|
11388
11424
|
const covers = managed.some((m) => m.id === x.id) ? `\uFF08\u4F60\u6539\u8FC7\u7684\u7248\u672C\uFF0C\u4EA7\u54C1\u90A3\u4E00\u4EFD\u5728 ${SKILLS_DIR}/${SKILLS_SYNC_SUBDIR}/${x.id}/\uFF0C\u540C\u6B65\u53EA\u66F4\u65B0\u90A3\u4E00\u4EFD\uFF09` : "";
|
|
11389
11425
|
return {
|
|
11390
11426
|
id: x.id,
|
|
11391
11427
|
title: x.title,
|
|
11392
11428
|
description: x.description ? `${x.description}${covers}` : covers,
|
|
11393
|
-
relativePath: relative3.split(
|
|
11429
|
+
relativePath: relative3.split(path12.sep).join("/")
|
|
11394
11430
|
};
|
|
11395
11431
|
});
|
|
11396
11432
|
const entries = [...managed.filter((m) => !shadowed.has(m.id)), ...localEntries].sort((a, b) => a.id.localeCompare(b.id));
|
|
@@ -11421,7 +11457,7 @@ async function resolveLocalSkillDocuments(sourceRoot, targetId, options = {}) {
|
|
|
11421
11457
|
throw invalid(`\u6280\u80FD\u4F9D\u8D56\u5B58\u5728\u73AF: ${[...pathStack.slice(Math.max(0, start)), id].join(" -> ")}`);
|
|
11422
11458
|
}
|
|
11423
11459
|
assertSafeSkillId(id);
|
|
11424
|
-
const local =
|
|
11460
|
+
const local = path12.join(sourceRoot, id, "SKILL.md");
|
|
11425
11461
|
let markdown;
|
|
11426
11462
|
try {
|
|
11427
11463
|
markdown = await fsp2.readFile(local, "utf8");
|
|
@@ -11431,7 +11467,7 @@ async function resolveLocalSkillDocuments(sourceRoot, targetId, options = {}) {
|
|
|
11431
11467
|
options.onSatisfiedElsewhere?.(id, requiredBy);
|
|
11432
11468
|
return;
|
|
11433
11469
|
}
|
|
11434
|
-
throw invalid(requiredBy ? `\u672C\u5730\u6280\u80FD ${requiredBy} \u4F9D\u8D56\u4E0D\u5B58\u5728: ${id}\uFF08${local}\uFF09\u2014\u2014\u628A ${id}/SKILL.md \u653E\u8FDB --from \u76EE\u5F55\u540E\u91CD\u8DD1\uFF0C\u6216\u5148\u4E0D\u5E26 --from \u8FDE\u7F51 sync \u88C5\u4E0A\u5B83` : `\u672C\u5730\u76EE\u5F55\u91CC\u6CA1\u6709 ${id}/SKILL.md\uFF1A${
|
|
11470
|
+
throw invalid(requiredBy ? `\u672C\u5730\u6280\u80FD ${requiredBy} \u4F9D\u8D56\u4E0D\u5B58\u5728: ${id}\uFF08${local}\uFF09\u2014\u2014\u628A ${id}/SKILL.md \u653E\u8FDB --from \u76EE\u5F55\u540E\u91CD\u8DD1\uFF0C\u6216\u5148\u4E0D\u5E26 --from \u8FDE\u7F51 sync \u88C5\u4E0A\u5B83` : `\u672C\u5730\u76EE\u5F55\u91CC\u6CA1\u6709 ${id}/SKILL.md\uFF1A${path12.join(sourceRoot, id)}`);
|
|
11435
11471
|
}
|
|
11436
11472
|
throw cause;
|
|
11437
11473
|
}
|
|
@@ -11443,7 +11479,7 @@ async function resolveLocalSkillDocuments(sourceRoot, targetId, options = {}) {
|
|
|
11443
11479
|
markdown,
|
|
11444
11480
|
source: local,
|
|
11445
11481
|
sourceKind: "local",
|
|
11446
|
-
references: await readLocalReferences(
|
|
11482
|
+
references: await readLocalReferences(path12.join(sourceRoot, id))
|
|
11447
11483
|
};
|
|
11448
11484
|
for (const required2 of parseSkillRequirements2(markdown, id)) {
|
|
11449
11485
|
await visit(required2, id);
|
|
@@ -11457,7 +11493,7 @@ async function resolveLocalSkillDocuments(sourceRoot, targetId, options = {}) {
|
|
|
11457
11493
|
}
|
|
11458
11494
|
async function readSkillsState(baseDir, options = {}) {
|
|
11459
11495
|
try {
|
|
11460
|
-
const raw = await fsp2.readFile(
|
|
11496
|
+
const raw = await fsp2.readFile(path12.join(baseDir, SKILLS_STATE_FILE), "utf8");
|
|
11461
11497
|
const parsed = JSON.parse(raw);
|
|
11462
11498
|
if (options.strict && (!parsed || typeof parsed !== "object" || !parsed.skills || typeof parsed.skills !== "object" || Array.isArray(parsed.skills)))
|
|
11463
11499
|
throw new Error("skills \u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
@@ -11470,7 +11506,7 @@ async function readSkillsState(baseDir, options = {}) {
|
|
|
11470
11506
|
}
|
|
11471
11507
|
async function writeSkillsState(baseDir, state) {
|
|
11472
11508
|
await fsp2.mkdir(baseDir, { recursive: true });
|
|
11473
|
-
const file =
|
|
11509
|
+
const file = path12.join(baseDir, SKILLS_STATE_FILE);
|
|
11474
11510
|
const temp = `${file}.${process.pid}.tmp`;
|
|
11475
11511
|
await fsp2.writeFile(temp, JSON.stringify(state, null, 2) + "\n", "utf8");
|
|
11476
11512
|
await fsp2.rename(temp, file);
|
|
@@ -11503,7 +11539,7 @@ async function upsertAgentsBlock(agentsFile, block) {
|
|
|
11503
11539
|
existing = await fsp2.readFile(agentsFile, "utf8");
|
|
11504
11540
|
} catch (cause) {
|
|
11505
11541
|
if (cause?.code !== "ENOENT") throw cause;
|
|
11506
|
-
await fsp2.mkdir(
|
|
11542
|
+
await fsp2.mkdir(path12.dirname(agentsFile), { recursive: true });
|
|
11507
11543
|
await fsp2.writeFile(agentsFile, block + "\n", "utf8");
|
|
11508
11544
|
return "created";
|
|
11509
11545
|
}
|
|
@@ -11529,7 +11565,7 @@ async function installSkillDocuments(documents, requestedIds, baseDir, force, me
|
|
|
11529
11565
|
if (!document2.markdown.trim()) throw invalid(`\u6280\u80FD ${document2.id} \u5185\u5BB9\u4E3A\u7A7A`);
|
|
11530
11566
|
return {
|
|
11531
11567
|
...document2,
|
|
11532
|
-
target:
|
|
11568
|
+
target: path12.join(baseDir, document2.id, "SKILL.md"),
|
|
11533
11569
|
bytes: Buffer.byteLength(document2.markdown)
|
|
11534
11570
|
};
|
|
11535
11571
|
});
|
|
@@ -11582,7 +11618,7 @@ async function sameOnDisk(baseDir, candidate) {
|
|
|
11582
11618
|
return true;
|
|
11583
11619
|
}
|
|
11584
11620
|
async function readLocalReferences(skillDir) {
|
|
11585
|
-
const root =
|
|
11621
|
+
const root = path12.join(skillDir, "references");
|
|
11586
11622
|
const out = [];
|
|
11587
11623
|
const walk = async (dir, prefix) => {
|
|
11588
11624
|
let items;
|
|
@@ -11595,12 +11631,12 @@ async function readLocalReferences(skillDir) {
|
|
|
11595
11631
|
for (const item of items.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
11596
11632
|
const relative3 = prefix ? `${prefix}/${item.name}` : item.name;
|
|
11597
11633
|
if (item.isDirectory()) {
|
|
11598
|
-
await walk(
|
|
11634
|
+
await walk(path12.join(dir, item.name), relative3);
|
|
11599
11635
|
continue;
|
|
11600
11636
|
}
|
|
11601
11637
|
if (!item.isFile()) continue;
|
|
11602
11638
|
assertSafeReferencePath2(relative3);
|
|
11603
|
-
out.push({ path: relative3, content: await fsp2.readFile(
|
|
11639
|
+
out.push({ path: relative3, content: await fsp2.readFile(path12.join(dir, item.name), "utf8") });
|
|
11604
11640
|
}
|
|
11605
11641
|
};
|
|
11606
11642
|
await walk(root, "");
|
|
@@ -11632,10 +11668,10 @@ async function removeSkillDirs(baseDir, ids) {
|
|
|
11632
11668
|
const state = await readSkillsState(baseDir);
|
|
11633
11669
|
for (const id of ids) {
|
|
11634
11670
|
assertSafeSkillId(id);
|
|
11635
|
-
const dir =
|
|
11636
|
-
const resolved =
|
|
11637
|
-
if (resolved !==
|
|
11638
|
-
const hasSkillFile = await fsp2.stat(
|
|
11671
|
+
const dir = path12.join(baseDir, id);
|
|
11672
|
+
const resolved = path12.resolve(dir);
|
|
11673
|
+
if (resolved !== path12.join(path12.resolve(baseDir), id)) continue;
|
|
11674
|
+
const hasSkillFile = await fsp2.stat(path12.join(dir, "SKILL.md")).then(() => true).catch(() => false);
|
|
11639
11675
|
const exists2 = await fsp2.stat(dir).then(() => true).catch(() => false);
|
|
11640
11676
|
if (exists2 && !hasSkillFile) {
|
|
11641
11677
|
kept.push({ id, kept: "\u76EE\u5F55\u91CC\u6CA1\u6709 SKILL.md\uFF0C\u50CF\u662F\u4F60\u81EA\u5DF1\u653E\u7684\u4E1C\u897F\uFF0C\u6CA1\u6709\u5220" });
|
|
@@ -11659,15 +11695,15 @@ async function writeSkillDocuments(documents, baseDir, removals = []) {
|
|
|
11659
11695
|
const removed = [];
|
|
11660
11696
|
try {
|
|
11661
11697
|
for (const document2 of documents) {
|
|
11662
|
-
const target =
|
|
11663
|
-
await fsp2.mkdir(
|
|
11664
|
-
const temp =
|
|
11698
|
+
const target = path12.join(baseDir, document2.id, "SKILL.md");
|
|
11699
|
+
await fsp2.mkdir(path12.dirname(target), { recursive: true });
|
|
11700
|
+
const temp = path12.join(path12.dirname(target), `.SKILL.md.${process.pid}.${Date.now()}.tmp`);
|
|
11665
11701
|
await fsp2.writeFile(temp, document2.markdown, "utf8");
|
|
11666
11702
|
staged.push({ temp, target });
|
|
11667
11703
|
for (const reference of document2.references ?? []) {
|
|
11668
11704
|
assertSafeReferencePath2(reference.path);
|
|
11669
|
-
const referenceTarget =
|
|
11670
|
-
await fsp2.mkdir(
|
|
11705
|
+
const referenceTarget = path12.join(baseDir, document2.id, "references", reference.path);
|
|
11706
|
+
await fsp2.mkdir(path12.dirname(referenceTarget), { recursive: true });
|
|
11671
11707
|
const referenceTemp = `${referenceTarget}.${process.pid}.${Date.now()}.tmp`;
|
|
11672
11708
|
await fsp2.writeFile(referenceTemp, reference.content, "utf8");
|
|
11673
11709
|
staged.push({ temp: referenceTemp, target: referenceTarget });
|
|
@@ -11675,7 +11711,7 @@ async function writeSkillDocuments(documents, baseDir, removals = []) {
|
|
|
11675
11711
|
}
|
|
11676
11712
|
for (const stale of removals) {
|
|
11677
11713
|
assertSafeReferencePath2(stale.path);
|
|
11678
|
-
const original =
|
|
11714
|
+
const original = path12.join(baseDir, stale.id, "references", stale.path);
|
|
11679
11715
|
const parked = `${original}.${process.pid}.${Date.now()}.removed`;
|
|
11680
11716
|
await fsp2.rename(original, parked);
|
|
11681
11717
|
removed.push({ parked, original });
|
|
@@ -11785,7 +11821,7 @@ async function planOrphanPrune(options) {
|
|
|
11785
11821
|
}
|
|
11786
11822
|
async function readInstalled(baseDir, id) {
|
|
11787
11823
|
try {
|
|
11788
|
-
return await fsp2.readFile(
|
|
11824
|
+
return await fsp2.readFile(path12.join(baseDir, id, "SKILL.md"), "utf8");
|
|
11789
11825
|
} catch (cause) {
|
|
11790
11826
|
if (cause?.code === "ENOENT") return void 0;
|
|
11791
11827
|
throw cause;
|
|
@@ -11793,7 +11829,7 @@ async function readInstalled(baseDir, id) {
|
|
|
11793
11829
|
}
|
|
11794
11830
|
async function readInstalledReference(baseDir, id, relative3) {
|
|
11795
11831
|
try {
|
|
11796
|
-
return await fsp2.readFile(
|
|
11832
|
+
return await fsp2.readFile(path12.join(baseDir, id, "references", relative3), "utf8");
|
|
11797
11833
|
} catch (cause) {
|
|
11798
11834
|
if (cause?.code === "ENOENT") return void 0;
|
|
11799
11835
|
throw cause;
|
|
@@ -11811,7 +11847,7 @@ function installConflictAdvice(where) {
|
|
|
11811
11847
|
if (where.half === "product") {
|
|
11812
11848
|
const product = displayDir(where.productDir);
|
|
11813
11849
|
const reach = where.target === "claude" ? CLAUDE_LOCAL_REACH : "\uFF08\u540C\u540D\u65F6\u5B83\u906E\u853D\u4EA7\u54C1\u90A3\u4EFD\uFF0C\u4EA7\u54C1\u90A3\u4EFD\u7EE7\u7EED\u8DDF\u7740\u66F4\u65B0\uFF09";
|
|
11814
|
-
return `${product}/ \u5F52\u4EA7\u54C1\uFF1A\u8981\u7559\u4F4F\u76D8\u4E0A\u8FD9\u4EFD\u6539\u52A8\uFF0C\u628A\u5B83\u632A\u5230 ${displayDir(
|
|
11850
|
+
return `${product}/ \u5F52\u4EA7\u54C1\uFF1A\u8981\u7559\u4F4F\u76D8\u4E0A\u8FD9\u4EFD\u6539\u52A8\uFF0C\u628A\u5B83\u632A\u5230 ${displayDir(path12.join(where.localDir, id))}/${reach}\uFF0C\u632A\u597D\u540E\u91CD\u8DD1\uFF1B\u786E\u8BA4\u653E\u5F03\u8FD9\u4EFD\u6539\u52A8\u624D\u52A0 --force\uFF08\u4F1A\u4E22\u6389\u76D8\u4E0A\u8FD9\u4EFD\uFF09\uFF0C\u8981\u88C5\u5230\u522B\u5904\u7528 --dir <path>`;
|
|
11815
11851
|
}
|
|
11816
11852
|
if (where.half === "local") {
|
|
11817
11853
|
return `${displayDir(where.localDir)}/ \u662F\u8FD9\u4E2A\u9879\u76EE\u81EA\u5DF1\u7684\u90A3\u4E00\u534A\uFF1A\u786E\u8BA4\u8981\u7528 --from \u8FD9\u4E00\u4EFD\u6362\u6389\u76D8\u4E0A\u90A3\u4EFD\u624D\u52A0 --force\uFF08\u4F1A\u4E22\u6389\u76D8\u4E0A\u8FD9\u4EFD\uFF09\uFF0C\u4E24\u4EFD\u90FD\u8981\u7559\u5C31\u7528 --dir <path> \u88C5\u5230\u522B\u5904`;
|
|
@@ -11832,8 +11868,8 @@ function reconcileAdvice(layout, args) {
|
|
|
11832
11868
|
return where.half === "product" && where.target === "claude" ? (id) => skillLocalModificationAdvice(id, "claude") : (id) => skillLocalModificationAdvice(id);
|
|
11833
11869
|
}
|
|
11834
11870
|
function displayDir(dir) {
|
|
11835
|
-
const relative3 =
|
|
11836
|
-
return relative3 && relative3 !== ".." && !relative3.startsWith(`..${
|
|
11871
|
+
const relative3 = path12.relative(process.cwd(), dir);
|
|
11872
|
+
return relative3 && relative3 !== ".." && !relative3.startsWith(`..${path12.sep}`) && !path12.isAbsolute(relative3) ? relative3.split(path12.sep).join("/") : dir;
|
|
11837
11873
|
}
|
|
11838
11874
|
async function compareInstalledWithSource(baseDir, id, record3, onDisk, source, force, advice = skillLocalModificationAdvice) {
|
|
11839
11875
|
let differsFromSource = source.markdown !== onDisk;
|
|
@@ -11884,11 +11920,11 @@ async function planLocalSkillUpdate(options) {
|
|
|
11884
11920
|
note: `\u672C\u8F6E\u6309 --from \u76EE\u5F55\u5BF9\u8D26\uFF0C${root} \u91CC\u6CA1\u6709\u5B83\uFF1A\u8FD9\u4E00\u8D9F\u6CA1\u6838\u5BF9\u5B83\uFF0C\u4E5F\u4E0D\u6E05\u5B83` + (by.length > 0 ? `\uFF1B${by.join("\u3001")} \u4F9D\u8D56\u5B83\uFF0C\u7528\u7684\u662F\u76D8\u4E0A\u5DF2\u88C5\u7684\u8FD9\u4EFD` : "")
|
|
11885
11921
|
});
|
|
11886
11922
|
}
|
|
11887
|
-
const advice = (id) => `\u672C\u5730\u6539\u8FC7\uFF0C\u6CA1\u6709\u8986\u76D6\u3002\u76D8\u4E0A\u8FD9\u4EFD\u4E0E\u9501\u91CC\u8BB0\u7684\u4E0D\u540C\uFF0C${
|
|
11923
|
+
const advice = (id) => `\u672C\u5730\u6539\u8FC7\uFF0C\u6CA1\u6709\u8986\u76D6\u3002\u76D8\u4E0A\u8FD9\u4EFD\u4E0E\u9501\u91CC\u8BB0\u7684\u4E0D\u540C\uFF0C${path12.join(root, id)}/ \u4E5F\u4E0E\u5B83\u4E0D\u540C\uFF1A\u628A\u76D8\u4E0A\u7684\u6539\u52A8\u5408\u8FDB ${path12.join(root, id)}/ \u540E\u91CD\u8DD1 sync --from\uFF1B\u786E\u8BA4\u653E\u5F03\u76D8\u4E0A\u6539\u52A8\u624D\u7528 --force`;
|
|
11888
11924
|
for (const [id, document2] of closure) {
|
|
11889
11925
|
const record3 = state.skills[id];
|
|
11890
11926
|
const onDisk = await readInstalled(baseDir, id);
|
|
11891
|
-
const withoutReferences = !await exists(
|
|
11927
|
+
const withoutReferences = !await exists(path12.join(root, id, "references"));
|
|
11892
11928
|
if (withoutReferences && record3 && Object.keys(record3.references ?? {}).length > 0) {
|
|
11893
11929
|
let onDiskCount = 0;
|
|
11894
11930
|
for (const relative3 of Object.keys(record3.references ?? {})) {
|
|
@@ -12146,7 +12182,7 @@ async function requireManagedState(layout) {
|
|
|
12146
12182
|
if (!state || Object.keys(state.skills).length === 0) {
|
|
12147
12183
|
throw new CliError28({
|
|
12148
12184
|
code: CliErrorCode28.INVALID_ARGUMENT,
|
|
12149
|
-
message: `${
|
|
12185
|
+
message: `${path12.join(layout.baseDir, SKILLS_STATE_FILE)} \u4E0D\u5B58\u5728\u6216\u4E3A\u7A7A \u2014\u2014 \u8FD9\u4E2A\u76EE\u5F55\u4E0B\u8FD8\u6CA1\u6709\u7528\u672C CLI \u88C5\u8FC7\u6280\u80FD\u3002\u5148\u8DD1 \`hcm chiron skills sync\`\uFF1B\u5982\u679C\u6280\u80FD\u662F\u624B\u5DE5\u62F7\u8FDB\u6765\u7684\uFF0C\u540C\u6B65\u4E00\u6B21\u5373\u53EF\u63A5\u7BA1\u5347\u7EA7\u3002`
|
|
12150
12186
|
});
|
|
12151
12187
|
}
|
|
12152
12188
|
return state;
|
|
@@ -12155,7 +12191,7 @@ async function skillsUpdateFromLocalCommand(args) {
|
|
|
12155
12191
|
try {
|
|
12156
12192
|
const layout = await resolveInstallLayout(args, process.cwd(), true);
|
|
12157
12193
|
const state = await requireManagedState(layout);
|
|
12158
|
-
const root =
|
|
12194
|
+
const root = path12.resolve(args.from);
|
|
12159
12195
|
const ignored = [args.endpoint ? "--endpoint" : "", args.env ? "--env" : "", args.pruneMax !== void 0 ? "--prune-max" : ""].filter(Boolean);
|
|
12160
12196
|
if (ignored.length > 0) {
|
|
12161
12197
|
process.stderr.write(`[hcm] --from \u5BF9\u8D26\u4E0D\u89E3\u6790 endpoint\u3001\u4E0D\u6E05\u5B64\u513F\uFF1A${ignored.join(" / ")} \u672C\u8D9F\u4E0D\u751F\u6548\uFF08\u53BB\u6389 --from \u624D\u8D70\u8FDE\u7F51\u5BF9\u8D26\uFF09
|
|
@@ -12231,7 +12267,7 @@ async function skillsUpdateFromLocalCommand(args) {
|
|
|
12231
12267
|
}
|
|
12232
12268
|
process.stdout.write("\n");
|
|
12233
12269
|
for (const index of agentIndexes) {
|
|
12234
|
-
const reader =
|
|
12270
|
+
const reader = path12.basename(index.file) === "CLAUDE.md" ? "Claude Code" : "Codex";
|
|
12235
12271
|
process.stdout.write(` \u5DF2${index.status === "created" ? "\u521B\u5EFA" : "\u66F4\u65B0"} ${index.file} \u91CC\u7684\u6280\u80FD\u7D22\u5F15\u4E0E\u9879\u76EE\u8FB9\u754C\u5757\uFF08${reader} \u8BFB\u8FD9\u91CC\uFF09
|
|
12236
12272
|
`);
|
|
12237
12273
|
}
|
|
@@ -12253,7 +12289,7 @@ async function skillsUpdateFromLocalCommand(args) {
|
|
|
12253
12289
|
);
|
|
12254
12290
|
}
|
|
12255
12291
|
for (const item of plan.referencesNotProvided) {
|
|
12256
|
-
process.stdout.write(` ${
|
|
12292
|
+
process.stdout.write(` ${path12.join(root, item.id)}/ \u6CA1\u6709 references/\uFF0C\u76D8\u4E0A ${item.onDisk} \u4E2A\u53C2\u8003\u6587\u4EF6\u4FDD\u7559\u672A\u6838` + (item.missing > 0 ? `\uFF08\u9501\u91CC\u8BB0\u7684\u53E6\u6709 ${item.missing} \u4E2A\u76D8\u4E0A\u6CA1\u6709\uFF0C\u8BB0\u5F55\u7167\u65E7\uFF09` : "") + "\n");
|
|
12257
12293
|
}
|
|
12258
12294
|
const tail = [
|
|
12259
12295
|
skipped > 0 ? `${skipped} \u4E2A\u672C\u5730\u6539\u8FC7\u88AB\u8DF3\u8FC7\uFF08--force \u8986\u76D6\uFF09` : "",
|
|
@@ -12417,7 +12453,7 @@ async function skillsUpdateCommand(args) {
|
|
|
12417
12453
|
if (conflictNote) process.stdout.write(` \u26A0\uFE0F ${conflictNote}
|
|
12418
12454
|
`);
|
|
12419
12455
|
for (const index of agentIndexes) {
|
|
12420
|
-
const reader =
|
|
12456
|
+
const reader = path12.basename(index.file) === "CLAUDE.md" ? "Claude Code" : "Codex";
|
|
12421
12457
|
process.stdout.write(` \u5DF2${index.status === "created" ? "\u521B\u5EFA" : "\u66F4\u65B0"} ${index.file} \u91CC\u7684\u6280\u80FD\u7D22\u5F15\u4E0E\u9879\u76EE\u8FB9\u754C\u5757\uFF08${reader} \u8BFB\u8FD9\u91CC\uFF09
|
|
12422
12458
|
`);
|
|
12423
12459
|
}
|
|
@@ -12460,7 +12496,7 @@ async function skillsUpdateCommand(args) {
|
|
|
12460
12496
|
const bypass = await findShadowBypassingRefs(layout, shadowedIds);
|
|
12461
12497
|
for (const hit of bypass) {
|
|
12462
12498
|
process.stdout.write(
|
|
12463
|
-
` \u26A0\uFE0F ${
|
|
12499
|
+
` \u26A0\uFE0F ${path12.relative(layout.baseDir, hit.file)} \u91CC\u7684 ../${hit.to}/ \u7ED5\u8FC7\u4E86\u906E\u853D\uFF1A\u4F60\u5728 ${SKILLS_LOCAL_SUBDIR}/${hit.to}/ \u6539\u8FC7\u5B83\uFF0C\u4F46\u987A\u7740\u8FD9\u6761\u76F8\u5BF9\u8DEF\u5F84\u8BFB\u5230\u7684\u662F ${SKILLS_SYNC_SUBDIR}/ \u91CC\u7684\u4EA7\u54C1\u539F\u7248
|
|
12464
12500
|
\u6B63\u6587\u6539\u6210\u6309 id \u53D6\u5740\u5C31\u4E0D\u4F1A\u518D\u9519\uFF1Ahcm chiron skills path ${hit.to}
|
|
12465
12501
|
`
|
|
12466
12502
|
);
|
|
@@ -12488,13 +12524,13 @@ async function skillsUpdateCommand(args) {
|
|
|
12488
12524
|
async function detectLegacyFlatLayout(layout) {
|
|
12489
12525
|
if (!layout.localDir) return void 0;
|
|
12490
12526
|
if (await readSkillsState(layout.baseDir)) return void 0;
|
|
12491
|
-
const legacyRoot =
|
|
12527
|
+
const legacyRoot = path12.dirname(layout.baseDir);
|
|
12492
12528
|
return await readSkillsState(legacyRoot) ? legacyRoot : void 0;
|
|
12493
12529
|
}
|
|
12494
12530
|
async function migrateFlatSkillsLayout(skillsRoot) {
|
|
12495
|
-
const legacyState =
|
|
12496
|
-
const syncDir =
|
|
12497
|
-
const localDir =
|
|
12531
|
+
const legacyState = path12.join(skillsRoot, SKILLS_STATE_FILE);
|
|
12532
|
+
const syncDir = path12.join(skillsRoot, SKILLS_SYNC_SUBDIR);
|
|
12533
|
+
const localDir = path12.join(skillsRoot, SKILLS_LOCAL_SUBDIR);
|
|
12498
12534
|
const hasLegacy = await fsp2.stat(legacyState).then(() => true).catch(() => false);
|
|
12499
12535
|
if (!hasLegacy) return { moved: [], migrated: false };
|
|
12500
12536
|
const state = await readSkillsState(skillsRoot);
|
|
@@ -12511,23 +12547,23 @@ async function migrateFlatSkillsLayout(skillsRoot) {
|
|
|
12511
12547
|
}
|
|
12512
12548
|
const moved = [];
|
|
12513
12549
|
for (const id of names) {
|
|
12514
|
-
const hasSkill = await fsp2.stat(
|
|
12550
|
+
const hasSkill = await fsp2.stat(path12.join(skillsRoot, id, "SKILL.md")).then(() => true).catch(() => false);
|
|
12515
12551
|
if (!hasSkill) continue;
|
|
12516
12552
|
const to = owned.has(id) ? "sync" : "local";
|
|
12517
|
-
const target =
|
|
12553
|
+
const target = path12.join(to === "sync" ? syncDir : localDir, id);
|
|
12518
12554
|
if (await fsp2.stat(target).then(() => true).catch(() => false)) {
|
|
12519
12555
|
throw invalid(`${target} \u5DF2\u7ECF\u5B58\u5728\uFF0C${id} \u642C\u4E0D\u8FC7\u53BB \u2014\u2014 \u5DF2\u7ECF\u642C\u597D\u7684\u90A3\u4E9B\u7559\u5728\u539F\u5730\uFF0C\u6CA1\u6709\u534A\u4EFD\u6587\u4EF6\u3002\u6253\u5F00\u8FD9\u4E24\u4E2A\u76EE\u5F55\u6BD4\u4E00\u6BD4\uFF0C\u7559\u4E00\u4EFD\u3001\u5220\u53E6\u4E00\u4EFD\uFF0C\u7136\u540E\u91CD\u8DD1 hcm chiron skills sync\u3002`);
|
|
12520
12556
|
}
|
|
12521
|
-
await fsp2.mkdir(
|
|
12557
|
+
await fsp2.mkdir(path12.dirname(target), { recursive: true });
|
|
12522
12558
|
try {
|
|
12523
|
-
await fsp2.rename(
|
|
12559
|
+
await fsp2.rename(path12.join(skillsRoot, id), target);
|
|
12524
12560
|
} catch (cause) {
|
|
12525
12561
|
throw invalid(`\u628A ${id} \u642C\u8FDB ${to}/ \u5931\u8D25\uFF1A${cause.message}\u3002\u5DF2\u7ECF\u642C\u597D\u7684 ${moved.length} \u4EFD\u5728\u65B0\u4F4D\u7F6E\uFF0C\u6CA1\u642C\u7684\u8FD8\u5728\u539F\u5730\uFF0C\u4E24\u8FB9\u90FD\u662F\u5B8C\u6574\u76EE\u5F55 \u2014\u2014 \u5904\u7406\u6389\u8FD9\u4E2A\u9519\u8BEF\u4E4B\u540E\u91CD\u8DD1 hcm chiron skills sync \u4F1A\u63A5\u7740\u642C\u5B8C\u3002`);
|
|
12526
12562
|
}
|
|
12527
12563
|
moved.push({ id, to });
|
|
12528
12564
|
}
|
|
12529
12565
|
await fsp2.mkdir(syncDir, { recursive: true });
|
|
12530
|
-
await fsp2.rename(legacyState,
|
|
12566
|
+
await fsp2.rename(legacyState, path12.join(syncDir, SKILLS_STATE_FILE));
|
|
12531
12567
|
return { moved, migrated: true };
|
|
12532
12568
|
}
|
|
12533
12569
|
function assertSyncArgs(args) {
|
|
@@ -12551,7 +12587,7 @@ var defaultSkillsSyncDeps = {
|
|
|
12551
12587
|
migrate: async (args) => {
|
|
12552
12588
|
const layout = await resolveInstallLayout(args).catch(() => null);
|
|
12553
12589
|
if (!layout || !layout.localDir) return { moved: [], migrated: false };
|
|
12554
|
-
return migrateFlatSkillsLayout(
|
|
12590
|
+
return migrateFlatSkillsLayout(path12.dirname(layout.baseDir));
|
|
12555
12591
|
}
|
|
12556
12592
|
};
|
|
12557
12593
|
async function skillsSyncCommand(args, deps = defaultSkillsSyncDeps) {
|
|
@@ -12865,19 +12901,19 @@ import {
|
|
|
12865
12901
|
CliErrorCode as CliErrorCode30,
|
|
12866
12902
|
fromAxiosError as fromAxiosError25
|
|
12867
12903
|
} from "@hcmai/sdk";
|
|
12868
|
-
import
|
|
12904
|
+
import axios5 from "axios";
|
|
12869
12905
|
init_exit();
|
|
12870
12906
|
async function bootstrapReport(http) {
|
|
12871
12907
|
const read = () => http.get("/api/system/health/report", { params: { only: "tenant.bootstrap" } });
|
|
12872
12908
|
try {
|
|
12873
12909
|
return (await read()).data;
|
|
12874
12910
|
} catch (error) {
|
|
12875
|
-
const wait =
|
|
12876
|
-
if (!
|
|
12911
|
+
const wait = axios5.isAxiosError(error) ? Number(error.response?.headers["retry-after"]) : NaN;
|
|
12912
|
+
if (!axios5.isAxiosError(error) || error.response?.status !== 429 || !Number.isFinite(wait) || wait < 0 || wait > 30) throw error;
|
|
12877
12913
|
const waitSeconds = Math.ceil(wait) + 1;
|
|
12878
12914
|
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
|
|
12879
12915
|
`);
|
|
12880
|
-
await new Promise((
|
|
12916
|
+
await new Promise((resolve8) => setTimeout(resolve8, waitSeconds * 1e3));
|
|
12881
12917
|
return (await read()).data;
|
|
12882
12918
|
}
|
|
12883
12919
|
}
|
|
@@ -12952,7 +12988,7 @@ async function tenantReconcileCommand(args) {
|
|
|
12952
12988
|
...!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" } : {}
|
|
12953
12989
|
};
|
|
12954
12990
|
} catch (error) {
|
|
12955
|
-
const translated =
|
|
12991
|
+
const translated = axios5.isAxiosError(error) ? fromAxiosError25(error, env2) : error;
|
|
12956
12992
|
verification = { status: "UNDETERMINED", reason: translated instanceof Error ? translated.message : "\u521D\u59CB\u5316\u590D\u9A8C\u5931\u8D25\uFF0C\u539F\u56E0\u672A\u77E5" };
|
|
12957
12993
|
}
|
|
12958
12994
|
}
|
|
@@ -12973,7 +13009,7 @@ async function tenantReconcileCommand(args) {
|
|
|
12973
13009
|
process.exitCode = verification.status === "PASS" ? 0 : 3;
|
|
12974
13010
|
} catch (error) {
|
|
12975
13011
|
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");
|
|
12976
|
-
exitWithError(
|
|
13012
|
+
exitWithError(axios5.isAxiosError(error) ? fromAxiosError25(error, args.env) : error);
|
|
12977
13013
|
}
|
|
12978
13014
|
}
|
|
12979
13015
|
|
|
@@ -13039,10 +13075,10 @@ async function metaListCommand(args) {
|
|
|
13039
13075
|
fail7(e, args, "read");
|
|
13040
13076
|
}
|
|
13041
13077
|
}
|
|
13042
|
-
async function metaGetCommand(
|
|
13078
|
+
async function metaGetCommand(path26, args) {
|
|
13043
13079
|
try {
|
|
13044
13080
|
const c2 = await client2(args);
|
|
13045
|
-
const content = await getTenantMeta(c2.raw(),
|
|
13081
|
+
const content = await getTenantMeta(c2.raw(), path26);
|
|
13046
13082
|
process.stdout.write(content.endsWith("\n") ? content : content + "\n");
|
|
13047
13083
|
process.exitCode = 0;
|
|
13048
13084
|
return;
|
|
@@ -13051,8 +13087,8 @@ async function metaGetCommand(path25, args) {
|
|
|
13051
13087
|
}
|
|
13052
13088
|
}
|
|
13053
13089
|
var PROBEABLE_META_TYPES = /* @__PURE__ */ new Set(["model", "list", "info", "view", "filter", "page", "wiz", "impexp"]);
|
|
13054
|
-
function parseMetaPath(
|
|
13055
|
-
const base =
|
|
13090
|
+
function parseMetaPath(path26) {
|
|
13091
|
+
const base = path26.split(/[\\/]/).pop() ?? path26;
|
|
13056
13092
|
if (!/\.(yml|yaml)$/i.test(base)) return {};
|
|
13057
13093
|
const parts = base.replace(/\.(yml|yaml)$/i, "").split(".");
|
|
13058
13094
|
return { model: parts[0] || void 0, kind: parts[1] ?? "model", state: parts[2] };
|
|
@@ -13069,10 +13105,10 @@ function unverifiableReason(e) {
|
|
|
13069
13105
|
if (st == null) return `\u8BF7\u6C42\u6CA1\u53D1\u51FA\u53BB\u6216\u6CA1\u56DE\u6765\uFF08${err.code ?? err.message ?? "\u672A\u77E5"}\uFF09`;
|
|
13070
13106
|
return void 0;
|
|
13071
13107
|
}
|
|
13072
|
-
async function verifyAfterWrite(c2,
|
|
13073
|
-
const { model, kind, state } = parseMetaPath(
|
|
13108
|
+
async function verifyAfterWrite(c2, path26) {
|
|
13109
|
+
const { model, kind, state } = parseMetaPath(path26);
|
|
13074
13110
|
if (!model || !kind) {
|
|
13075
|
-
return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${
|
|
13111
|
+
return { status: "unverified", where: "(\u672A\u63A2)", why: `\u4ECE\u8DEF\u5F84 ${path26} \u8BA4\u4E0D\u51FA\u6A21\u578B\u540D/\u5C42\u540D` };
|
|
13076
13112
|
}
|
|
13077
13113
|
try {
|
|
13078
13114
|
await clearMetaCache2(c2.raw(), model, {});
|
|
@@ -13117,7 +13153,7 @@ async function verifyAfterWrite(c2, path25) {
|
|
|
13117
13153
|
}
|
|
13118
13154
|
return { status: "ok" };
|
|
13119
13155
|
}
|
|
13120
|
-
async function metaSetCommand(
|
|
13156
|
+
async function metaSetCommand(path26, args) {
|
|
13121
13157
|
try {
|
|
13122
13158
|
if (!args.file) {
|
|
13123
13159
|
throw new CliError31({
|
|
@@ -13125,17 +13161,17 @@ async function metaSetCommand(path25, args) {
|
|
|
13125
13161
|
message: "--file <path> \u5FC5\u586B\uFF08\u4ECE\u6587\u4EF6\u8BFB\u53D6 meta \u539F\u6587\uFF1B\u7528 - \u8868\u793A stdin\uFF09"
|
|
13126
13162
|
});
|
|
13127
13163
|
}
|
|
13128
|
-
const content = args.file === "-" ? await new Promise((
|
|
13164
|
+
const content = args.file === "-" ? await new Promise((resolve8, reject) => {
|
|
13129
13165
|
let buf = "";
|
|
13130
13166
|
process.stdin.setEncoding("utf8");
|
|
13131
13167
|
process.stdin.on("data", (d) => buf += d);
|
|
13132
|
-
process.stdin.on("end", () =>
|
|
13168
|
+
process.stdin.on("end", () => resolve8(buf));
|
|
13133
13169
|
process.stdin.on("error", reject);
|
|
13134
13170
|
}) : await fsp3.readFile(args.file, "utf8");
|
|
13135
13171
|
if (!args.skipValidate) {
|
|
13136
|
-
const result2 = validateMetaContent(
|
|
13172
|
+
const result2 = validateMetaContent(path26, content);
|
|
13137
13173
|
if (result2.issues.length > 0) {
|
|
13138
|
-
process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${
|
|
13174
|
+
process.stderr.write(`\u{1F50E} \u5199\u524D\u6821\u9A8C ${path26}\uFF08schema \u7C7B\u578B\uFF1A${result2.kind ?? "\u672A\u8BC6\u522B"}\uFF09
|
|
13139
13175
|
`);
|
|
13140
13176
|
process.stderr.write(formatMetaIssues(result2, " ") + "\n");
|
|
13141
13177
|
}
|
|
@@ -13154,13 +13190,13 @@ async function metaSetCommand(path25, args) {
|
|
|
13154
13190
|
if (dryFmt === "json" || dryFmt === "yaml") {
|
|
13155
13191
|
process.stdout.write(
|
|
13156
13192
|
formatObject24(
|
|
13157
|
-
{ dryRun: true, path:
|
|
13193
|
+
{ dryRun: true, path: path26, bytes: Buffer.byteLength(content), content },
|
|
13158
13194
|
{ format: dryFmt }
|
|
13159
13195
|
) + "\n"
|
|
13160
13196
|
);
|
|
13161
13197
|
} else {
|
|
13162
13198
|
process.stdout.write(
|
|
13163
|
-
`[dry-run] \u5C06\u5199\u5165 ${
|
|
13199
|
+
`[dry-run] \u5C06\u5199\u5165 ${path26}\uFF08${Buffer.byteLength(content)} B\uFF09\u2014\u2014\u672A\u5B9E\u9645\u5199\u5165
|
|
13164
13200
|
---
|
|
13165
13201
|
${content}
|
|
13166
13202
|
`
|
|
@@ -13174,13 +13210,13 @@ ${content}
|
|
|
13174
13210
|
let backupState = "unknown";
|
|
13175
13211
|
let backupWhy;
|
|
13176
13212
|
try {
|
|
13177
|
-
const prev = await getTenantMeta(c2.raw(),
|
|
13213
|
+
const prev = await getTenantMeta(c2.raw(), path26);
|
|
13178
13214
|
if (!prev || prev.trim() === "") {
|
|
13179
13215
|
backupState = "absent";
|
|
13180
13216
|
} else {
|
|
13181
13217
|
backupFile = nodePath.join(
|
|
13182
13218
|
os4.tmpdir(),
|
|
13183
|
-
`hcm-meta-backup-${Date.now()}-${
|
|
13219
|
+
`hcm-meta-backup-${Date.now()}-${path26.replace(/[\\/]/g, "_")}`
|
|
13184
13220
|
);
|
|
13185
13221
|
await fsp3.writeFile(backupFile, prev, "utf8");
|
|
13186
13222
|
backupState = "saved";
|
|
@@ -13195,22 +13231,22 @@ ${content}
|
|
|
13195
13231
|
backupWhy = `HTTP ${st ?? "-"}${err.code ? ` ${err.code}` : ""}${err.message ? `\uFF1A${err.message}` : ""}`;
|
|
13196
13232
|
}
|
|
13197
13233
|
}
|
|
13198
|
-
const result = await saveTenantMeta(c2.raw(),
|
|
13234
|
+
const result = await saveTenantMeta(c2.raw(), path26, content);
|
|
13199
13235
|
const fmt = args.output ?? "json";
|
|
13200
|
-
if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${
|
|
13236
|
+
if (fmt !== "json") process.stdout.write(`\u2705 \u5DF2\u5199\u5165 ${path26}
|
|
13201
13237
|
`);
|
|
13202
13238
|
const restoreHint = backupState === "saved" && backupFile ? ` \u65E7\u5185\u5BB9\u5DF2\u5B58\uFF1A${backupFile}
|
|
13203
|
-
\u653E\u56DE\u53BB\uFF1Ahcm meta set ${
|
|
13204
|
-
` : 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 ${
|
|
13239
|
+
\u653E\u56DE\u53BB\uFF1Ahcm meta set ${path26} --file ${backupFile}${connFlags(args)}
|
|
13240
|
+
` : 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 ${path26}${connFlags(args)}
|
|
13205
13241
|
` : ` \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
|
|
13206
|
-
\u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${
|
|
13242
|
+
\u5148\u81EA\u5DF1\u8BFB\u4E00\u904D\u786E\u8BA4\uFF1Ahcm meta get ${path26}${connFlags(args)}
|
|
13207
13243
|
`;
|
|
13208
13244
|
if (args.verify === false) {
|
|
13209
13245
|
process.stderr.write(
|
|
13210
13246
|
"\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
|
|
13211
13247
|
);
|
|
13212
13248
|
} else {
|
|
13213
|
-
const outcome = await verifyAfterWrite(c2,
|
|
13249
|
+
const outcome = await verifyAfterWrite(c2, path26);
|
|
13214
13250
|
if (outcome.status === "broken") {
|
|
13215
13251
|
const human = explainJacksonError(outcome.raw);
|
|
13216
13252
|
process.stderr.write(
|
|
@@ -13244,23 +13280,23 @@ ${content}
|
|
|
13244
13280
|
fail7(e, args);
|
|
13245
13281
|
}
|
|
13246
13282
|
}
|
|
13247
|
-
async function metaDeleteCommand(
|
|
13283
|
+
async function metaDeleteCommand(path26, args) {
|
|
13248
13284
|
try {
|
|
13249
13285
|
if (!args.yes) {
|
|
13250
13286
|
requireTerminalForPrompt(
|
|
13251
|
-
`\u6807\u51C6\u8F93\u5165\u4E0D\u662F\u7EC8\u7AEF\uFF0C\u65E0\u6CD5\u786E\u8BA4\u5220\u9664\u5143\u6570\u636E ${
|
|
13252
|
-
`\u6838\u5BF9\u8DEF\u5F84\u4E0E\u5F71\u54CD\u540E\u52A0 --yes\uFF1Ahcm meta delete ${
|
|
13287
|
+
`\u6807\u51C6\u8F93\u5165\u4E0D\u662F\u7EC8\u7AEF\uFF0C\u65E0\u6CD5\u786E\u8BA4\u5220\u9664\u5143\u6570\u636E ${path26}\uFF1B\u672A\u5220\u9664\u3001\u672A\u53D1\u9001\u8BF7\u6C42\u3002`,
|
|
13288
|
+
`\u6838\u5BF9\u8DEF\u5F84\u4E0E\u5F71\u54CD\u540E\u52A0 --yes\uFF1Ahcm meta delete ${path26} --yes${connFlags(args)}`
|
|
13253
13289
|
);
|
|
13254
|
-
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${
|
|
13290
|
+
const ok = await promptConfirm(`\u5C06\u5220\u9664\u5143\u6570\u636E ${path26}\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u9006\u3002\u7EE7\u7EED\uFF1F`);
|
|
13255
13291
|
if (!ok) {
|
|
13256
13292
|
process.stderr.write("\u5DF2\u53D6\u6D88\n");
|
|
13257
13293
|
process.exit(1);
|
|
13258
13294
|
}
|
|
13259
13295
|
}
|
|
13260
13296
|
const c2 = await client2(args);
|
|
13261
|
-
const result = await deleteTenantMeta(c2.raw(),
|
|
13297
|
+
const result = await deleteTenantMeta(c2.raw(), path26);
|
|
13262
13298
|
const fmt = args.output ?? "json";
|
|
13263
|
-
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${
|
|
13299
|
+
if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path26}
|
|
13264
13300
|
`);
|
|
13265
13301
|
process.stdout.write(formatObject24(result, { format: fmt }) + "\n");
|
|
13266
13302
|
process.exitCode = 0;
|
|
@@ -13269,7 +13305,7 @@ async function metaDeleteCommand(path25, args) {
|
|
|
13269
13305
|
fail7(e, args);
|
|
13270
13306
|
}
|
|
13271
13307
|
}
|
|
13272
|
-
async function metaValidateCommand(
|
|
13308
|
+
async function metaValidateCommand(path26, args) {
|
|
13273
13309
|
try {
|
|
13274
13310
|
if (!args.file) {
|
|
13275
13311
|
throw new CliError31({
|
|
@@ -13277,20 +13313,20 @@ async function metaValidateCommand(path25, args) {
|
|
|
13277
13313
|
message: "--file <path> \u5FC5\u586B\uFF08\u8981\u9A8C\u7684\u90A3\u4EFD\u539F\u6587\uFF1B\u7528 - \u8868\u793A stdin\uFF09"
|
|
13278
13314
|
});
|
|
13279
13315
|
}
|
|
13280
|
-
const content = args.file === "-" ? await new Promise((
|
|
13316
|
+
const content = args.file === "-" ? await new Promise((resolve8, reject) => {
|
|
13281
13317
|
let buf = "";
|
|
13282
13318
|
process.stdin.setEncoding("utf8");
|
|
13283
13319
|
process.stdin.on("data", (d) => buf += d);
|
|
13284
|
-
process.stdin.on("end", () =>
|
|
13320
|
+
process.stdin.on("end", () => resolve8(buf));
|
|
13285
13321
|
process.stdin.on("error", reject);
|
|
13286
13322
|
}) : await fsp3.readFile(args.file, "utf8");
|
|
13287
|
-
const result = validateMetaContent(
|
|
13323
|
+
const result = validateMetaContent(path26, content);
|
|
13288
13324
|
const fmt = args.output ?? "table";
|
|
13289
13325
|
if (fmt === "json" || fmt === "yaml") {
|
|
13290
13326
|
process.stdout.write(
|
|
13291
13327
|
formatObject24(
|
|
13292
13328
|
{
|
|
13293
|
-
path:
|
|
13329
|
+
path: path26,
|
|
13294
13330
|
kind: result.kind,
|
|
13295
13331
|
schemaKnown: result.schemaKnown,
|
|
13296
13332
|
schemaSourceCommit: META_SCHEMA_SOURCE_COMMIT,
|
|
@@ -13302,7 +13338,7 @@ async function metaValidateCommand(path25, args) {
|
|
|
13302
13338
|
);
|
|
13303
13339
|
} else {
|
|
13304
13340
|
process.stdout.write(
|
|
13305
|
-
`\u{1F50E} ${
|
|
13341
|
+
`\u{1F50E} ${path26}\uFF08schema \u7C7B\u578B\uFF1A${result.kind ?? "\u672A\u8BC6\u522B"}\uFF0C\u6765\u6E90 ${META_SCHEMA_SOURCE_COMMIT.slice(0, 8)}\uFF09
|
|
13306
13342
|
`
|
|
13307
13343
|
);
|
|
13308
13344
|
process.stdout.write(
|
|
@@ -13574,7 +13610,7 @@ async function metaColumnSlotSqlCommand(model, field, args) {
|
|
|
13574
13610
|
init_exit();
|
|
13575
13611
|
import * as crypto from "crypto";
|
|
13576
13612
|
import * as fs12 from "fs/promises";
|
|
13577
|
-
import * as
|
|
13613
|
+
import * as path14 from "path";
|
|
13578
13614
|
import {
|
|
13579
13615
|
buildMiniPreviewTargets,
|
|
13580
13616
|
buildMiniVerifyAgentReport,
|
|
@@ -13738,7 +13774,7 @@ function boolValue(value) {
|
|
|
13738
13774
|
|
|
13739
13775
|
// src/commands/workspace-rebase.ts
|
|
13740
13776
|
import * as fs11 from "fs/promises";
|
|
13741
|
-
import * as
|
|
13777
|
+
import * as path13 from "path";
|
|
13742
13778
|
import { formatObject as formatObject26 } from "@hcmai/sdk";
|
|
13743
13779
|
async function runWorkspaceRebase(workspaceKey, args, connect2) {
|
|
13744
13780
|
const plan = args.plan && !args.dryRun ? readPlan(JSON.parse(await fs11.readFile(args.plan, "utf8"))) : void 0;
|
|
@@ -13783,8 +13819,8 @@ async function runWorkspaceRebase(workspaceKey, args, connect2) {
|
|
|
13783
13819
|
content: file.workspaceContent
|
|
13784
13820
|
}))
|
|
13785
13821
|
};
|
|
13786
|
-
await fs11.writeFile(
|
|
13787
|
-
process.stderr.write(`\u5DF2\u5199\u89E3\u51B3\u8349\u6848 ${
|
|
13822
|
+
await fs11.writeFile(path13.resolve(args.plan), JSON.stringify(draft, null, 2) + "\n", { flag: "wx", mode: 384 });
|
|
13823
|
+
process.stderr.write(`\u5DF2\u5199\u89E3\u51B3\u8349\u6848 ${path13.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
|
|
13788
13824
|
`);
|
|
13789
13825
|
} else {
|
|
13790
13826
|
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");
|
|
@@ -13868,7 +13904,7 @@ function nonnegativeInteger2(value) {
|
|
|
13868
13904
|
}
|
|
13869
13905
|
function filePath(value) {
|
|
13870
13906
|
const text2 = requiredText(value, "relativePath");
|
|
13871
|
-
if (
|
|
13907
|
+
if (path13.isAbsolute(text2) || text2.includes("\\") || text2.includes("\0") || /^[A-Za-z]:/.test(text2) || text2.split("/").some((part) => !part || part === "." || part === "..")) {
|
|
13872
13908
|
throw new Error(`relativePath \u5FC5\u987B\u662F\u5B89\u5168\u7684\u76F8\u5BF9\u6587\u4EF6\u8DEF\u5F84\uFF1A${text2}`);
|
|
13873
13909
|
}
|
|
13874
13910
|
return text2;
|
|
@@ -14004,8 +14040,8 @@ function releaseIssueNextStep(issue, deletedPaths) {
|
|
|
14004
14040
|
}
|
|
14005
14041
|
return "\u6309\u4E0A\u9762\u7684\u62A5\u9519\u6539\u597D\u540E\u91CD\u8DD1 hcm workspace verify";
|
|
14006
14042
|
}
|
|
14007
|
-
function appDirOf(
|
|
14008
|
-
const m =
|
|
14043
|
+
function appDirOf(path26) {
|
|
14044
|
+
const m = path26 ? /^(mini_apps|apps)\/([^/]+)\//.exec(path26) : null;
|
|
14009
14045
|
return m ? `${m[1]}/${m[2]}/` : void 0;
|
|
14010
14046
|
}
|
|
14011
14047
|
function formatCoverageDetail(coverage) {
|
|
@@ -14243,9 +14279,9 @@ async function workspacePullCommand(args) {
|
|
|
14243
14279
|
});
|
|
14244
14280
|
}
|
|
14245
14281
|
await fs12.mkdir(rootDir, { recursive: true });
|
|
14246
|
-
await fs12.mkdir(
|
|
14282
|
+
await fs12.mkdir(path14.join(rootDir, WORKSPACE_STATE_DIR), { recursive: true });
|
|
14247
14283
|
await fs12.writeFile(
|
|
14248
|
-
|
|
14284
|
+
path14.join(rootDir, WORKSPACE_STATE_DIR, WORKSPACE_PULL_INCOMPLETE_FILE),
|
|
14249
14285
|
JSON.stringify(context, null, 2) + "\n"
|
|
14250
14286
|
);
|
|
14251
14287
|
const pulledMiniApps = [];
|
|
@@ -14254,7 +14290,7 @@ async function workspacePullCommand(args) {
|
|
|
14254
14290
|
http: client4.raw(),
|
|
14255
14291
|
appCode,
|
|
14256
14292
|
workspaceKey,
|
|
14257
|
-
targetDir:
|
|
14293
|
+
targetDir: path14.join(rootDir, MINI_APPS_DIR, appCode),
|
|
14258
14294
|
tenantId: client4.tenantId,
|
|
14259
14295
|
endpoint: client4.endpoint,
|
|
14260
14296
|
profile: context.profile,
|
|
@@ -14279,7 +14315,7 @@ async function workspacePullCommand(args) {
|
|
|
14279
14315
|
}
|
|
14280
14316
|
});
|
|
14281
14317
|
}
|
|
14282
|
-
const target =
|
|
14318
|
+
const target = path14.join(rootDir, content.relativePath);
|
|
14283
14319
|
await writeTextFile(target, content.content, !!args.force);
|
|
14284
14320
|
pulledRawFiles.push(content.relativePath);
|
|
14285
14321
|
snapshots.push({
|
|
@@ -14293,7 +14329,7 @@ async function workspacePullCommand(args) {
|
|
|
14293
14329
|
}
|
|
14294
14330
|
await writeWorkspaceRawState(rootDir, context, snapshots);
|
|
14295
14331
|
await writeWorkspaceContext(rootDir, context);
|
|
14296
|
-
await fs12.unlink(
|
|
14332
|
+
await fs12.unlink(path14.join(rootDir, WORKSPACE_STATE_DIR, WORKSPACE_PULL_INCOMPLETE_FILE));
|
|
14297
14333
|
writeWorkspacePullResult(
|
|
14298
14334
|
{
|
|
14299
14335
|
workspaceKey,
|
|
@@ -14336,7 +14372,7 @@ async function workspaceAddMiniCommand(appCode, args) {
|
|
|
14336
14372
|
const result = await initMiniAppProject({
|
|
14337
14373
|
appCode,
|
|
14338
14374
|
workspaceKey: context.workspaceKey,
|
|
14339
|
-
targetDir:
|
|
14375
|
+
targetDir: path14.join(rootDir, MINI_APPS_DIR, appCode),
|
|
14340
14376
|
name: args.name,
|
|
14341
14377
|
runtimeSdkVersion: args.sdkVersion,
|
|
14342
14378
|
defaultSurface: parseSurface(args.surface),
|
|
@@ -14363,7 +14399,7 @@ async function workspaceRmCommand(relativePath, args) {
|
|
|
14363
14399
|
const rootDir = resolveRootDir(args.dir);
|
|
14364
14400
|
const context = await requireWorkspaceContext(rootDir);
|
|
14365
14401
|
const normalized = normalizeWorkspaceRmPath(relativePath);
|
|
14366
|
-
const absolutePath =
|
|
14402
|
+
const absolutePath = path14.join(rootDir, ...normalized.split("/"));
|
|
14367
14403
|
let stat;
|
|
14368
14404
|
try {
|
|
14369
14405
|
stat = await fs12.lstat(absolutePath);
|
|
@@ -14493,7 +14529,7 @@ async function workspaceValidateCommand(args) {
|
|
|
14493
14529
|
const rootDir = resolveRootDir(args.dir);
|
|
14494
14530
|
await requireWorkspaceContext(rootDir);
|
|
14495
14531
|
const miniApps = await discoverMiniApps(rootDir);
|
|
14496
|
-
const metaFiles = await readWorkspaceRawLocalFiles(
|
|
14532
|
+
const metaFiles = await readWorkspaceRawLocalFiles(path14.join(rootDir, "metas"));
|
|
14497
14533
|
const metaResults = metaFiles.filter((file) => /\.ya?ml$/i.test(file.localPath)).map((file) => {
|
|
14498
14534
|
const artifact = `meta:metas/${file.localPath}`;
|
|
14499
14535
|
const validation = validateMetaContent2(`metas/${file.localPath}`, file.content);
|
|
@@ -14746,7 +14782,7 @@ function removedMiniCommand() {
|
|
|
14746
14782
|
);
|
|
14747
14783
|
}
|
|
14748
14784
|
function resolveRootDir(dir) {
|
|
14749
|
-
return
|
|
14785
|
+
return path14.resolve(dir ?? ".");
|
|
14750
14786
|
}
|
|
14751
14787
|
async function workspacePathExists(file) {
|
|
14752
14788
|
try {
|
|
@@ -14763,11 +14799,11 @@ async function assertWorkspacePushRoot(rootDir) {
|
|
|
14763
14799
|
let insideMiniApp = false;
|
|
14764
14800
|
let dir = realRoot;
|
|
14765
14801
|
for (; ; ) {
|
|
14766
|
-
const parent =
|
|
14767
|
-
const appsDir =
|
|
14768
|
-
const miniDir = appsDir !== void 0 && (await workspacePathExists(
|
|
14802
|
+
const parent = path14.dirname(dir);
|
|
14803
|
+
const appsDir = path14.basename(dir) === MINI_APPS_DIR ? dir : path14.basename(parent) === MINI_APPS_DIR ? parent : void 0;
|
|
14804
|
+
const miniDir = appsDir !== void 0 && (await workspacePathExists(path14.join(path14.dirname(appsDir), WORKSPACE_CONTEXT_FILE)) || appsDir === parent && await workspacePathExists(path14.join(dir, "manifest.json"))) || await workspacePathExists(path14.join(dir, MINI_CONTEXT_FILE)) || await workspacePathExists(path14.join(dir, MINI_STATE_DIR, MINI_PULL_MANIFEST_FILE));
|
|
14769
14805
|
insideMiniApp ||= miniDir;
|
|
14770
|
-
if (!miniDir && await workspacePathExists(
|
|
14806
|
+
if (!miniDir && await workspacePathExists(path14.join(dir, WORKSPACE_CONTEXT_FILE))) {
|
|
14771
14807
|
workspaceRoot = dir;
|
|
14772
14808
|
break;
|
|
14773
14809
|
}
|
|
@@ -14798,7 +14834,7 @@ function buildWorkspaceContext(args) {
|
|
|
14798
14834
|
async function readWorkspaceContext(rootDir) {
|
|
14799
14835
|
try {
|
|
14800
14836
|
const parsed = JSON.parse(
|
|
14801
|
-
await fs12.readFile(
|
|
14837
|
+
await fs12.readFile(path14.join(rootDir, WORKSPACE_CONTEXT_FILE), "utf-8")
|
|
14802
14838
|
);
|
|
14803
14839
|
if (parsed.kind !== WORKSPACE_CONTEXT_KIND || parsed.version !== WORKSPACE_CONTEXT_VERSION) {
|
|
14804
14840
|
throw new Error(`${WORKSPACE_CONTEXT_FILE} is not an HCM workspace context`);
|
|
@@ -14828,7 +14864,7 @@ async function requireWorkspaceContext(rootDir) {
|
|
|
14828
14864
|
}
|
|
14829
14865
|
async function writeWorkspaceContext(rootDir, context) {
|
|
14830
14866
|
await fs12.writeFile(
|
|
14831
|
-
|
|
14867
|
+
path14.join(rootDir, WORKSPACE_CONTEXT_FILE),
|
|
14832
14868
|
JSON.stringify(context, null, 2) + "\n"
|
|
14833
14869
|
);
|
|
14834
14870
|
}
|
|
@@ -14839,13 +14875,13 @@ async function writeTextFile(file, content, force) {
|
|
|
14839
14875
|
} catch (e) {
|
|
14840
14876
|
if (e.code !== "ENOENT") throw e;
|
|
14841
14877
|
}
|
|
14842
|
-
await fs12.mkdir(
|
|
14878
|
+
await fs12.mkdir(path14.dirname(file), { recursive: true });
|
|
14843
14879
|
await fs12.writeFile(file, content);
|
|
14844
14880
|
}
|
|
14845
14881
|
async function readWorkspaceRawManifest(rootDir, context, forPull = false) {
|
|
14846
14882
|
if (!forPull) {
|
|
14847
14883
|
try {
|
|
14848
|
-
await fs12.access(
|
|
14884
|
+
await fs12.access(path14.join(rootDir, WORKSPACE_STATE_DIR, WORKSPACE_PULL_INCOMPLETE_FILE));
|
|
14849
14885
|
throw new CliError34({
|
|
14850
14886
|
code: CliErrorCode34.BUSINESS_RULE_VIOLATION,
|
|
14851
14887
|
message: "\u4E0A\u6B21 workspace pull \u672A\u5B8C\u6210\uFF0C\u672C\u5730\u53EF\u80FD\u6DF7\u6709\u4E0D\u540C\u76EE\u6807\u7684\u5185\u5BB9\uFF0C\u4E0D\u80FD\u7EE7\u7EED\u540C\u6B65\u3002",
|
|
@@ -14861,7 +14897,7 @@ async function readWorkspaceRawManifest(rootDir, context, forPull = false) {
|
|
|
14861
14897
|
try {
|
|
14862
14898
|
const parsed = JSON.parse(
|
|
14863
14899
|
await fs12.readFile(
|
|
14864
|
-
|
|
14900
|
+
path14.join(rootDir, WORKSPACE_STATE_DIR, WORKSPACE_PULL_MANIFEST_FILE),
|
|
14865
14901
|
"utf-8"
|
|
14866
14902
|
)
|
|
14867
14903
|
);
|
|
@@ -14899,9 +14935,9 @@ function workspaceRawBaselineByPath(manifest2) {
|
|
|
14899
14935
|
return new Map(manifest2.files.filter((file) => typeof file.fileId === "string" && file.fileId.trim().length > 0 && !isProtectedWorkspacePath(file.remotePath)).map((file) => [file.localPath, file]));
|
|
14900
14936
|
}
|
|
14901
14937
|
async function writeWorkspaceRawManifest(rootDir, manifest2) {
|
|
14902
|
-
const stateDir =
|
|
14938
|
+
const stateDir = path14.join(rootDir, WORKSPACE_STATE_DIR);
|
|
14903
14939
|
await fs12.mkdir(stateDir, { recursive: true });
|
|
14904
|
-
const target =
|
|
14940
|
+
const target = path14.join(stateDir, WORKSPACE_PULL_MANIFEST_FILE);
|
|
14905
14941
|
const temporary = `${target}.${crypto.randomUUID()}.tmp`;
|
|
14906
14942
|
try {
|
|
14907
14943
|
await fs12.writeFile(temporary, JSON.stringify(manifest2, null, 2) + "\n", { encoding: "utf8", flag: "wx" });
|
|
@@ -14917,7 +14953,7 @@ async function readWorkspaceRawLocalFiles(rootDir) {
|
|
|
14917
14953
|
return files;
|
|
14918
14954
|
}
|
|
14919
14955
|
async function walkWorkspaceRawFiles(rootDir, relativeDir, files) {
|
|
14920
|
-
const absoluteDir =
|
|
14956
|
+
const absoluteDir = path14.join(rootDir, relativeDir);
|
|
14921
14957
|
let entries;
|
|
14922
14958
|
try {
|
|
14923
14959
|
entries = await fs12.readdir(absoluteDir, { withFileTypes: true });
|
|
@@ -14929,8 +14965,8 @@ async function walkWorkspaceRawFiles(rootDir, relativeDir, files) {
|
|
|
14929
14965
|
if (entry.isDirectory() && RAW_WORKSPACE_EXCLUDED_DIRS.has(entry.name)) continue;
|
|
14930
14966
|
if (entry.isFile() && RAW_WORKSPACE_EXCLUDED_FILES.has(entry.name)) continue;
|
|
14931
14967
|
if (!relativeDir && isProtectedWorkspacePath(entry.name)) continue;
|
|
14932
|
-
const localPath = normalizeRelativePath(
|
|
14933
|
-
const absolutePath =
|
|
14968
|
+
const localPath = normalizeRelativePath(path14.posix.join(toPosix(relativeDir), entry.name));
|
|
14969
|
+
const absolutePath = path14.join(rootDir, localPath);
|
|
14934
14970
|
if (entry.isDirectory()) {
|
|
14935
14971
|
await walkWorkspaceRawFiles(rootDir, localPath, files);
|
|
14936
14972
|
continue;
|
|
@@ -15540,7 +15576,7 @@ function workspaceRawConflict(entry, reason) {
|
|
|
15540
15576
|
};
|
|
15541
15577
|
}
|
|
15542
15578
|
async function discoverMiniApps(rootDir) {
|
|
15543
|
-
const appsRoot =
|
|
15579
|
+
const appsRoot = path14.join(rootDir, MINI_APPS_DIR);
|
|
15544
15580
|
let entries;
|
|
15545
15581
|
try {
|
|
15546
15582
|
entries = await fs12.readdir(appsRoot, { withFileTypes: true });
|
|
@@ -15548,7 +15584,7 @@ async function discoverMiniApps(rootDir) {
|
|
|
15548
15584
|
if (e.code === "ENOENT") return [];
|
|
15549
15585
|
throw e;
|
|
15550
15586
|
}
|
|
15551
|
-
return entries.filter((entry) => entry.isDirectory()).map((entry) => ({ appCode: entry.name, dir:
|
|
15587
|
+
return entries.filter((entry) => entry.isDirectory()).map((entry) => ({ appCode: entry.name, dir: path14.join(appsRoot, entry.name) })).sort((a, b) => a.appCode.localeCompare(b.appCode));
|
|
15552
15588
|
}
|
|
15553
15589
|
function detectRemoteMiniApps(files) {
|
|
15554
15590
|
const appCodes = /* @__PURE__ */ new Set();
|
|
@@ -15733,7 +15769,7 @@ function normalizeWorkspaceKey(value) {
|
|
|
15733
15769
|
return key2;
|
|
15734
15770
|
}
|
|
15735
15771
|
function normalizeWorkspaceRmPath(value) {
|
|
15736
|
-
if (
|
|
15772
|
+
if (path14.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value)) {
|
|
15737
15773
|
throw new Error("workspace rm path must be relative to the bound workspace");
|
|
15738
15774
|
}
|
|
15739
15775
|
const normalized = normalizeRelativePath(value);
|
|
@@ -15755,7 +15791,7 @@ function normalizeRelativePath(value) {
|
|
|
15755
15791
|
return normalized;
|
|
15756
15792
|
}
|
|
15757
15793
|
function toPosix(value) {
|
|
15758
|
-
return value.split(
|
|
15794
|
+
return value.split(path14.sep).join("/");
|
|
15759
15795
|
}
|
|
15760
15796
|
function sha2563(content) {
|
|
15761
15797
|
return crypto.createHash("sha256").update(content, "utf-8").digest("hex");
|
|
@@ -16203,7 +16239,7 @@ async function workspaceDeactivateCommand(args) {
|
|
|
16203
16239
|
|
|
16204
16240
|
// src/commands/identity.ts
|
|
16205
16241
|
init_exit();
|
|
16206
|
-
import
|
|
16242
|
+
import axios6 from "axios";
|
|
16207
16243
|
import {
|
|
16208
16244
|
AUTH_INFO_PATH,
|
|
16209
16245
|
CliError as CliError35,
|
|
@@ -16223,7 +16259,7 @@ import {
|
|
|
16223
16259
|
toPrincipal
|
|
16224
16260
|
} from "@hcmai/sdk";
|
|
16225
16261
|
var fetchAuthInfo = async (endpoint, accessToken) => {
|
|
16226
|
-
const response = await
|
|
16262
|
+
const response = await axios6.get(`${endpoint.replace(/\/$/, "")}${AUTH_INFO_PATH}`, {
|
|
16227
16263
|
headers: { Authorization: `Bearer ${accessToken}` },
|
|
16228
16264
|
timeout: 3e4
|
|
16229
16265
|
});
|
|
@@ -16265,7 +16301,7 @@ async function identityShow(name, args) {
|
|
|
16265
16301
|
const details = await inspectIdentity(name);
|
|
16266
16302
|
return exitOk(formatObject28(details, { format: args.output ?? "json" }));
|
|
16267
16303
|
} catch (e) {
|
|
16268
|
-
exitWithError(
|
|
16304
|
+
exitWithError(axios6.isAxiosError(e) ? fromAxiosError30(e, name) : e);
|
|
16269
16305
|
}
|
|
16270
16306
|
}
|
|
16271
16307
|
async function identityList(args) {
|
|
@@ -16337,7 +16373,7 @@ async function identityRemove(name) {
|
|
|
16337
16373
|
init_auth_guard();
|
|
16338
16374
|
init_exit();
|
|
16339
16375
|
import { promises as fs13 } from "fs";
|
|
16340
|
-
import
|
|
16376
|
+
import path15 from "path";
|
|
16341
16377
|
import {
|
|
16342
16378
|
CliError as CliError36,
|
|
16343
16379
|
CliErrorCode as CliErrorCode36,
|
|
@@ -16398,7 +16434,7 @@ async function resolveInitEnv(root, args, deps) {
|
|
|
16398
16434
|
};
|
|
16399
16435
|
}
|
|
16400
16436
|
const existing = await discoverProjectEnv5(root);
|
|
16401
|
-
if (existing &&
|
|
16437
|
+
if (existing && path15.dirname(existing.path) === path15.resolve(root)) {
|
|
16402
16438
|
const name2 = args.env ?? existing.config.default;
|
|
16403
16439
|
const env2 = existing.config.environments[name2];
|
|
16404
16440
|
if (!env2) throw new CliError36({
|
|
@@ -16449,7 +16485,7 @@ ${explicitPaths}` }
|
|
|
16449
16485
|
}
|
|
16450
16486
|
async function scaffoldChironProject(root, env2, envName) {
|
|
16451
16487
|
const result = { created: [], updated: [], preserved: [] };
|
|
16452
|
-
const envFile =
|
|
16488
|
+
const envFile = path15.join(root, ENV_FILE);
|
|
16453
16489
|
const existing = await fs13.readFile(envFile, "utf8").catch(() => null);
|
|
16454
16490
|
if (existing !== null) {
|
|
16455
16491
|
const document2 = parseEnvYaml(existing);
|
|
@@ -16498,14 +16534,14 @@ async function scaffoldChironProject(root, env2, envName) {
|
|
|
16498
16534
|
result.created.push(ENV_FILE);
|
|
16499
16535
|
}
|
|
16500
16536
|
for (const directory of CHIRON_PROJECT_DIRECTORIES) {
|
|
16501
|
-
const absolute =
|
|
16537
|
+
const absolute = path15.join(root, directory);
|
|
16502
16538
|
await ensureDirectory(absolute);
|
|
16503
|
-
await writeIfAbsent(
|
|
16539
|
+
await writeIfAbsent(path15.join(absolute, ".gitkeep"), "", result, `${directory}/.gitkeep`);
|
|
16504
16540
|
}
|
|
16505
16541
|
return result;
|
|
16506
16542
|
}
|
|
16507
16543
|
async function runChironInit(args, deps = defaultChironInitDeps) {
|
|
16508
|
-
const root =
|
|
16544
|
+
const root = path15.resolve(args.project ?? ".");
|
|
16509
16545
|
const say = (line) => process.stderr.write(`[chiron init] ${line}
|
|
16510
16546
|
`);
|
|
16511
16547
|
const choice = await resolveInitEnv(root, args, deps);
|
|
@@ -18036,8 +18072,8 @@ async function gapVerifyCommand(ref, args, deps = defaultDeps) {
|
|
|
18036
18072
|
|
|
18037
18073
|
// src/commands/chiron-doctor.ts
|
|
18038
18074
|
import { promises as fs16 } from "fs";
|
|
18039
|
-
import
|
|
18040
|
-
import
|
|
18075
|
+
import path19 from "path";
|
|
18076
|
+
import axios11 from "axios";
|
|
18041
18077
|
import {
|
|
18042
18078
|
CliError as CliError44,
|
|
18043
18079
|
CliErrorCode as CliErrorCode44,
|
|
@@ -18060,7 +18096,7 @@ init_auth_guard();
|
|
|
18060
18096
|
// src/commands/chiron-env.ts
|
|
18061
18097
|
init_exit();
|
|
18062
18098
|
import { promises as fs14 } from "fs";
|
|
18063
|
-
import
|
|
18099
|
+
import path16 from "path";
|
|
18064
18100
|
import yaml3 from "js-yaml";
|
|
18065
18101
|
import {
|
|
18066
18102
|
AUTH_INFO_PATH as AUTH_INFO_PATH2,
|
|
@@ -18210,9 +18246,9 @@ async function runChironEnv(action, args = {}) {
|
|
|
18210
18246
|
if (args.output && !["table", "json", "yaml"].includes(args.output)) {
|
|
18211
18247
|
invalid2(`\u672A\u77E5\u8F93\u51FA\u683C\u5F0F '${args.output}'\uFF0C\u914D\u7F6E\u672A\u5199\u5165\u3002`, "\u4F7F\u7528 --output table\u3001json \u6216 yaml");
|
|
18212
18248
|
}
|
|
18213
|
-
const root =
|
|
18249
|
+
const root = path16.resolve(args.project ?? ".");
|
|
18214
18250
|
const discovered = await discoverProjectEnv6(root);
|
|
18215
|
-
const file = discovered?.path ??
|
|
18251
|
+
const file = discovered?.path ?? path16.join(root, ENV_FILE2);
|
|
18216
18252
|
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>");
|
|
18217
18253
|
const original = discovered ? await fs14.readFile(file, "utf8") : null;
|
|
18218
18254
|
const config2 = original ? parseEnvYaml2(original) : { default: "", environments: {} };
|
|
@@ -18310,7 +18346,7 @@ import { promisify as promisify2 } from "util";
|
|
|
18310
18346
|
import { createHash as createHash6 } from "crypto";
|
|
18311
18347
|
import { existsSync as existsSync4, promises as fsp4 } from "fs";
|
|
18312
18348
|
import os5 from "os";
|
|
18313
|
-
import
|
|
18349
|
+
import path17 from "path";
|
|
18314
18350
|
import yaml4 from "js-yaml";
|
|
18315
18351
|
import {
|
|
18316
18352
|
CliError as CliError40,
|
|
@@ -18483,7 +18519,7 @@ function latestVersionTag(tags) {
|
|
|
18483
18519
|
return [...tags.keys()].filter((t) => SEMVER_TAG.test(t)).sort(compareTags).pop();
|
|
18484
18520
|
}
|
|
18485
18521
|
async function listRemoteTags(deps) {
|
|
18486
|
-
const context = await fsp4.mkdtemp(
|
|
18522
|
+
const context = await fsp4.mkdtemp(path17.join(os5.tmpdir(), "hcm-method-tags-"));
|
|
18487
18523
|
try {
|
|
18488
18524
|
await deps.git(["init", "--quiet", context], { timeoutMs: 1e4 });
|
|
18489
18525
|
await deps.git(["remote", "add", "origin", deps.repoUrl], { cwd: context, timeoutMs: 1e4 });
|
|
@@ -18634,10 +18670,10 @@ function parsePackageManifest(text2) {
|
|
|
18634
18670
|
async function sha256File(file) {
|
|
18635
18671
|
return createHash6("sha256").update(await fsp4.readFile(file)).digest("hex");
|
|
18636
18672
|
}
|
|
18637
|
-
async function verifyDigests(entries,
|
|
18673
|
+
async function verifyDigests(entries, resolve8) {
|
|
18638
18674
|
const out = { files: entries.length, mismatched: [], missing: [] };
|
|
18639
18675
|
for (const f of entries) {
|
|
18640
|
-
const abs =
|
|
18676
|
+
const abs = resolve8(f.path);
|
|
18641
18677
|
if (!existsSync4(abs)) {
|
|
18642
18678
|
out.missing.push(f.path);
|
|
18643
18679
|
continue;
|
|
@@ -18651,7 +18687,7 @@ async function listFilesUnder(root, rel) {
|
|
|
18651
18687
|
const walk = async (dirRel) => {
|
|
18652
18688
|
let items;
|
|
18653
18689
|
try {
|
|
18654
|
-
items = await fsp4.readdir(
|
|
18690
|
+
items = await fsp4.readdir(path17.join(root, dirRel), { withFileTypes: true });
|
|
18655
18691
|
} catch {
|
|
18656
18692
|
return;
|
|
18657
18693
|
}
|
|
@@ -18672,9 +18708,9 @@ var BLOCK_LABEL = {
|
|
|
18672
18708
|
"online-catalog": "\u5728\u7EBF\u4EA7\u54C1\u76EE\u5F55"
|
|
18673
18709
|
};
|
|
18674
18710
|
var PROJECT_SKILL_STATE_FILES = [
|
|
18675
|
-
|
|
18676
|
-
|
|
18677
|
-
|
|
18711
|
+
path17.join(SKILLS_DIR, SKILLS_SYNC_SUBDIR, SKILLS_STATE_FILE),
|
|
18712
|
+
path17.join(SKILLS_DIR, SKILLS_STATE_FILE),
|
|
18713
|
+
path17.join(".claude", "skills", SKILLS_STATE_FILE)
|
|
18678
18714
|
];
|
|
18679
18715
|
async function onlineTargetFor(root) {
|
|
18680
18716
|
try {
|
|
@@ -18714,7 +18750,7 @@ async function checkMethodConflicts(methodIds, root, online, deps) {
|
|
|
18714
18750
|
const unreadable = [];
|
|
18715
18751
|
const owners = /* @__PURE__ */ new Map();
|
|
18716
18752
|
for (const rel of PROJECT_SKILL_STATE_FILES) {
|
|
18717
|
-
const file =
|
|
18753
|
+
const file = path17.join(root, rel);
|
|
18718
18754
|
if (!existsSync4(file)) continue;
|
|
18719
18755
|
found2.push(rel);
|
|
18720
18756
|
try {
|
|
@@ -18722,20 +18758,20 @@ async function checkMethodConflicts(methodIds, root, online, deps) {
|
|
|
18722
18758
|
for (const [id, rec] of Object.entries(state.skills ?? {})) {
|
|
18723
18759
|
if (!owners.has(id)) {
|
|
18724
18760
|
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"}`;
|
|
18725
|
-
owners.set(id, `\u672C\u9879\u76EE\u5DF2\u88C5\uFF08${rel.split(
|
|
18761
|
+
owners.set(id, `\u672C\u9879\u76EE\u5DF2\u88C5\uFF08${rel.split(path17.sep).join("/")}\uFF0C\u6765\u6E90 ${from}\uFF09`);
|
|
18726
18762
|
}
|
|
18727
18763
|
}
|
|
18728
18764
|
} catch (e) {
|
|
18729
|
-
unreadable.push(`${rel.split(
|
|
18765
|
+
unreadable.push(`${rel.split(path17.sep).join("/")}\uFF08${e.message.split("\n")[0]}\uFF09`);
|
|
18730
18766
|
}
|
|
18731
18767
|
}
|
|
18732
18768
|
if (found2.length === 0) {
|
|
18733
18769
|
b.note = "\u672C\u9879\u76EE\u8FD8\u6CA1\u88C5\u4EA7\u54C1\u6280\u80FD\uFF0C\u4EA7\u54C1\u4FA7\u672A\u6BD4\u5BF9";
|
|
18734
18770
|
} else if (owners.size === 0) {
|
|
18735
|
-
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(
|
|
18771
|
+
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(path17.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`;
|
|
18736
18772
|
} else {
|
|
18737
18773
|
b.checked = true;
|
|
18738
|
-
b.source = found2.map((f) => f.split(
|
|
18774
|
+
b.source = found2.map((f) => f.split(path17.sep).join("/")).join("\u3001");
|
|
18739
18775
|
b.compared = [...owners.keys()].sort();
|
|
18740
18776
|
b.conflicts = b.compared.filter((id) => wanted.has(id)).map((id) => ({ id, other: owners.get(id) }));
|
|
18741
18777
|
if (unreadable.length) b.note = `\u53E6\u6709\u6E05\u5355\u8BFB\u4E0D\u61C2\u3001\u6CA1\u7B97\u8FDB\u6765\uFF1A${unreadable.join("\uFF1B")}`;
|
|
@@ -18855,7 +18891,7 @@ function renderLock(lock) {
|
|
|
18855
18891
|
`;
|
|
18856
18892
|
}
|
|
18857
18893
|
async function readLock(root) {
|
|
18858
|
-
const file =
|
|
18894
|
+
const file = path17.join(root, METHOD_DIR, METHOD_LOCK_FILE);
|
|
18859
18895
|
let text2;
|
|
18860
18896
|
try {
|
|
18861
18897
|
text2 = await fsp4.readFile(file, "utf8");
|
|
@@ -18883,17 +18919,17 @@ async function readLock(root) {
|
|
|
18883
18919
|
}
|
|
18884
18920
|
async function readState(root) {
|
|
18885
18921
|
try {
|
|
18886
|
-
return JSON.parse(await fsp4.readFile(
|
|
18922
|
+
return JSON.parse(await fsp4.readFile(path17.join(root, METHOD_DIR, METHOD_STATE_FILE), "utf8"));
|
|
18887
18923
|
} catch {
|
|
18888
18924
|
return void 0;
|
|
18889
18925
|
}
|
|
18890
18926
|
}
|
|
18891
18927
|
async function resolveMethodRoot(project2, log) {
|
|
18892
|
-
if (project2 !== void 0) return { root:
|
|
18928
|
+
if (project2 !== void 0) return { root: path17.resolve(project2), rootSource: "--project" };
|
|
18893
18929
|
const cwd = process.cwd();
|
|
18894
18930
|
try {
|
|
18895
18931
|
const found2 = await discoverProjectEnv7(cwd);
|
|
18896
|
-
if (found2) return { root:
|
|
18932
|
+
if (found2) return { root: path17.dirname(found2.path), rootSource: "env.yaml" };
|
|
18897
18933
|
} catch (e) {
|
|
18898
18934
|
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}`);
|
|
18899
18935
|
return { root: cwd, rootSource: "cwd" };
|
|
@@ -18907,13 +18943,13 @@ async function resolveTarget(root, requested) {
|
|
|
18907
18943
|
return (await readState(root))?.target ?? await detectTarget(root) ?? "claude";
|
|
18908
18944
|
}
|
|
18909
18945
|
function skillFileSig(manifest2, skill) {
|
|
18910
|
-
const dir = `${
|
|
18946
|
+
const dir = `${path17.posix.dirname(skill.path)}/`;
|
|
18911
18947
|
return manifest2.files.filter((f) => f.path.startsWith(dir)).map((f) => `${f.path}:${f.sha256}`).sort().join("\n");
|
|
18912
18948
|
}
|
|
18913
18949
|
async function readCriteria(dir) {
|
|
18914
18950
|
let text2;
|
|
18915
18951
|
try {
|
|
18916
|
-
text2 = await fsp4.readFile(
|
|
18952
|
+
text2 = await fsp4.readFile(path17.join(dir, GATES_FILE), "utf8");
|
|
18917
18953
|
} catch {
|
|
18918
18954
|
return { reason: `\u6CA1\u6709 ${GATES_FILE}` };
|
|
18919
18955
|
}
|
|
@@ -18981,7 +19017,7 @@ async function step(deps, n, label, fn) {
|
|
|
18981
19017
|
}
|
|
18982
19018
|
async function readInstalledManifest(root) {
|
|
18983
19019
|
try {
|
|
18984
|
-
const text2 = await fsp4.readFile(
|
|
19020
|
+
const text2 = await fsp4.readFile(path17.join(root, METHOD_DIR, "package.yml"), "utf8");
|
|
18985
19021
|
return { text: text2, manifest: parsePackageManifest(text2) };
|
|
18986
19022
|
} catch {
|
|
18987
19023
|
return void 0;
|
|
@@ -18990,31 +19026,31 @@ async function readInstalledManifest(root) {
|
|
|
18990
19026
|
var sha256Text = (t) => createHash6("sha256").update(t, "utf8").digest("hex");
|
|
18991
19027
|
async function hasClaudeCopies(root) {
|
|
18992
19028
|
try {
|
|
18993
|
-
return (await fsp4.readdir(
|
|
19029
|
+
return (await fsp4.readdir(path17.join(root, ".claude", "skills"), { withFileTypes: true })).some((it) => it.isDirectory() && it.name.startsWith(METHOD_SKILL_PREFIX));
|
|
18994
19030
|
} catch {
|
|
18995
19031
|
return false;
|
|
18996
19032
|
}
|
|
18997
19033
|
}
|
|
18998
19034
|
function codexAgentFiles(root) {
|
|
18999
|
-
const files = [
|
|
19000
|
-
if (existsSync4(
|
|
19035
|
+
const files = [path17.join(root, "AGENTS.md")];
|
|
19036
|
+
if (existsSync4(path17.join(root, "CLAUDE.md"))) files.push(path17.join(root, "CLAUDE.md"));
|
|
19001
19037
|
return files;
|
|
19002
19038
|
}
|
|
19003
19039
|
async function installClaudeCopies(root, manifest2) {
|
|
19004
|
-
const skillsRoot =
|
|
19040
|
+
const skillsRoot = path17.join(root, ".claude", "skills");
|
|
19005
19041
|
await fsp4.mkdir(skillsRoot, { recursive: true });
|
|
19006
19042
|
const ids = new Set(manifest2.skills.map((s) => s.id));
|
|
19007
19043
|
const written = [];
|
|
19008
19044
|
for (const s of manifest2.skills) {
|
|
19009
|
-
const dst =
|
|
19045
|
+
const dst = path17.join(skillsRoot, s.id);
|
|
19010
19046
|
await fsp4.rm(dst, { recursive: true, force: true });
|
|
19011
|
-
await fsp4.cp(
|
|
19047
|
+
await fsp4.cp(path17.join(root, METHOD_DIR, path17.dirname(s.path)), dst, { recursive: true });
|
|
19012
19048
|
written.push(`.claude/skills/${s.id}/`);
|
|
19013
19049
|
}
|
|
19014
19050
|
const pruned = [];
|
|
19015
19051
|
for (const it of await fsp4.readdir(skillsRoot, { withFileTypes: true })) {
|
|
19016
19052
|
if (it.isDirectory() && it.name.startsWith(METHOD_SKILL_PREFIX) && !ids.has(it.name)) {
|
|
19017
|
-
await fsp4.rm(
|
|
19053
|
+
await fsp4.rm(path17.join(skillsRoot, it.name), { recursive: true, force: true });
|
|
19018
19054
|
pruned.push(`.claude/skills/${it.name}/`);
|
|
19019
19055
|
}
|
|
19020
19056
|
}
|
|
@@ -19023,14 +19059,14 @@ async function installClaudeCopies(root, manifest2) {
|
|
|
19023
19059
|
async function indexEntries(root, agentsDir, manifest2) {
|
|
19024
19060
|
const out = [];
|
|
19025
19061
|
for (const s of manifest2.skills) {
|
|
19026
|
-
const abs =
|
|
19062
|
+
const abs = path17.join(root, METHOD_DIR, s.path);
|
|
19027
19063
|
let description = "";
|
|
19028
19064
|
try {
|
|
19029
19065
|
const fm = parseSkillFrontmatter3(await fsp4.readFile(abs, "utf8"), s.id);
|
|
19030
19066
|
if (typeof fm.description === "string") description = fm.description.trim().replace(/\s+/g, " ");
|
|
19031
19067
|
} catch {
|
|
19032
19068
|
}
|
|
19033
|
-
let rel =
|
|
19069
|
+
let rel = path17.relative(agentsDir, abs).split(path17.sep).join("/");
|
|
19034
19070
|
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
19035
19071
|
out.push({ id: s.id, title: s.title, description, phases: s.phases, relativePath: rel });
|
|
19036
19072
|
}
|
|
@@ -19053,9 +19089,9 @@ async function runMethodPipeline(input, deps) {
|
|
|
19053
19089
|
deps.log(` ${r.ref} \u2192 ${r.commit.slice(0, 12)}`);
|
|
19054
19090
|
return r;
|
|
19055
19091
|
});
|
|
19056
|
-
const work = await fsp4.mkdtemp(
|
|
19092
|
+
const work = await fsp4.mkdtemp(path17.join(os5.tmpdir(), "hcm-method-"));
|
|
19057
19093
|
try {
|
|
19058
|
-
const checkout =
|
|
19094
|
+
const checkout = path17.join(work, "pkg");
|
|
19059
19095
|
const { manifest: manifest2, manifestText } = await step(deps, 2, "\u53D6\u5305\uFF08\u7A00\u758F\u6D45 clone\uFF09", async () => {
|
|
19060
19096
|
await deps.git(["clone", "--depth", "1", "--filter=blob:none", "--sparse", "--quiet", "--branch", resolved.ref, deps.repoUrl, checkout]);
|
|
19061
19097
|
const head = (await deps.git(["-C", checkout, "rev-parse", "HEAD"], { timeoutMs: 1e4 })).trim();
|
|
@@ -19068,7 +19104,7 @@ async function runMethodPipeline(input, deps) {
|
|
|
19068
19104
|
}
|
|
19069
19105
|
let text2;
|
|
19070
19106
|
try {
|
|
19071
|
-
text2 = await fsp4.readFile(
|
|
19107
|
+
text2 = await fsp4.readFile(path17.join(checkout, "package.yml"), "utf8");
|
|
19072
19108
|
} catch {
|
|
19073
19109
|
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`);
|
|
19074
19110
|
}
|
|
@@ -19079,11 +19115,11 @@ async function runMethodPipeline(input, deps) {
|
|
|
19079
19115
|
});
|
|
19080
19116
|
const unlisted = await step(deps, 3, "\u6821\u9A8C\u6E05\u5355\u4E0E\u6458\u8981", async () => {
|
|
19081
19117
|
for (const [i, entry] of manifest2.include.entries()) {
|
|
19082
|
-
if (!existsSync4(
|
|
19118
|
+
if (!existsSync4(path17.join(checkout, entry.replace(/\/$/, "")))) {
|
|
19083
19119
|
throw invalidPackage(`include[${i}]`, `include \u767B\u8BB0\u4E86 ${entry}\uFF0C\u4F46 ${resolved.ref} \u91CC\u6CA1\u6709\u5B83`);
|
|
19084
19120
|
}
|
|
19085
19121
|
}
|
|
19086
|
-
const check = await verifyDigests(manifest2.files, (p) =>
|
|
19122
|
+
const check = await verifyDigests(manifest2.files, (p) => path17.join(checkout, p));
|
|
19087
19123
|
if (check.missing.length) {
|
|
19088
19124
|
throw invalidPackage("files", `\u6E05\u5355\u767B\u8BB0\u4E86\u3001\u5305\u91CC\u5374\u6CA1\u6709\uFF1A${naming(check.missing)}`);
|
|
19089
19125
|
}
|
|
@@ -19104,7 +19140,7 @@ async function runMethodPipeline(input, deps) {
|
|
|
19104
19140
|
for (const l of renderConflictBlocks(blocks)) deps.log(l);
|
|
19105
19141
|
return blocks;
|
|
19106
19142
|
});
|
|
19107
|
-
const diff = input.mode === "update" ? await diffPackages(before ?
|
|
19143
|
+
const diff = input.mode === "update" ? await diffPackages(before ? path17.join(root, METHOD_DIR) : void 0, before?.manifest, checkout, manifest2) : void 0;
|
|
19108
19144
|
if (diff) for (const l of renderDiff(diff)) deps.log(` ${l}`);
|
|
19109
19145
|
const lock = {
|
|
19110
19146
|
lockVersion: 1,
|
|
@@ -19116,29 +19152,29 @@ async function runMethodPipeline(input, deps) {
|
|
|
19116
19152
|
skills: manifest2.skills.map((s) => s.id)
|
|
19117
19153
|
};
|
|
19118
19154
|
const nowIso = deps.now().toISOString();
|
|
19119
|
-
const gitignorePath =
|
|
19155
|
+
const gitignorePath = path17.join(root, ".gitignore");
|
|
19120
19156
|
const agentTargets = input.target === "codex" ? codexAgentFiles(root) : [];
|
|
19121
19157
|
const gitignore = await step(deps, 5, "\u9884\u68C0\u53D7\u7BA1\u5757\u5E76\u7EF4\u62A4 .gitignore", async () => {
|
|
19122
19158
|
await preflightManaged([
|
|
19123
19159
|
{ file: gitignorePath, begin: GITIGNORE_BEGIN, end: GITIGNORE_END, label: ".gitignore" },
|
|
19124
|
-
...agentTargets.map((file) => ({ file, begin: AGENTS_METHOD_BEGIN, end: AGENTS_METHOD_END, label:
|
|
19160
|
+
...agentTargets.map((file) => ({ file, begin: AGENTS_METHOD_BEGIN, end: AGENTS_METHOD_END, label: path17.basename(file) }))
|
|
19125
19161
|
]);
|
|
19126
19162
|
return writeManaged(gitignorePath, GITIGNORE_BEGIN, GITIGNORE_END, renderGitignoreBlock(), ".gitignore");
|
|
19127
19163
|
});
|
|
19128
19164
|
await step(deps, 6, `\u66FF\u6362 ${METHOD_DIR}/ \u5E76\u5199\u9501\u6587\u4EF6`, async () => {
|
|
19129
|
-
const targetDir =
|
|
19130
|
-
const staging =
|
|
19131
|
-
const old =
|
|
19165
|
+
const targetDir = path17.join(root, METHOD_DIR);
|
|
19166
|
+
const staging = path17.join(root, `.${METHOD_DIR}.staging-${process.pid}`);
|
|
19167
|
+
const old = path17.join(root, `.${METHOD_DIR}.old-${process.pid}`);
|
|
19132
19168
|
await fsp4.rm(staging, { recursive: true, force: true });
|
|
19133
19169
|
try {
|
|
19134
19170
|
await fsp4.mkdir(staging, { recursive: true });
|
|
19135
19171
|
for (const entry of manifest2.include) {
|
|
19136
19172
|
const rel = entry.replace(/\/$/, "");
|
|
19137
|
-
await fsp4.cp(
|
|
19173
|
+
await fsp4.cp(path17.join(checkout, rel), path17.join(staging, rel), { recursive: true });
|
|
19138
19174
|
}
|
|
19139
|
-
await fsp4.writeFile(
|
|
19175
|
+
await fsp4.writeFile(path17.join(staging, METHOD_LOCK_FILE), renderLock(lock), "utf8");
|
|
19140
19176
|
const state = { target: input.target, installedAt: nowIso, remoteCheckedAt: nowIso };
|
|
19141
|
-
await fsp4.writeFile(
|
|
19177
|
+
await fsp4.writeFile(path17.join(staging, METHOD_STATE_FILE), `${JSON.stringify(state, null, 2)}
|
|
19142
19178
|
`, "utf8");
|
|
19143
19179
|
const hadOld = existsSync4(targetDir);
|
|
19144
19180
|
if (hadOld) {
|
|
@@ -19162,8 +19198,8 @@ async function runMethodPipeline(input, deps) {
|
|
|
19162
19198
|
const refreshCopies = input.target === "claude" || await hasClaudeCopies(root);
|
|
19163
19199
|
if (refreshCopies) copies = await installClaudeCopies(root, manifest2);
|
|
19164
19200
|
for (const file of agentTargets) {
|
|
19165
|
-
const block = renderMethodAgentsBlock(lock, await indexEntries(root,
|
|
19166
|
-
files.push({ file:
|
|
19201
|
+
const block = renderMethodAgentsBlock(lock, await indexEntries(root, path17.dirname(file), manifest2));
|
|
19202
|
+
files.push({ file: path17.relative(root, file), status: await writeManaged(file, AGENTS_METHOD_BEGIN, AGENTS_METHOD_END, block, path17.basename(file)) });
|
|
19167
19203
|
}
|
|
19168
19204
|
return { files, copies };
|
|
19169
19205
|
});
|
|
@@ -19199,7 +19235,7 @@ async function runMethodPipeline(input, deps) {
|
|
|
19199
19235
|
function renderInstallReport(r) {
|
|
19200
19236
|
const out = [];
|
|
19201
19237
|
const verb = r.mode === "update" ? "\u5DF2\u66F4\u65B0\u5230" : "\u5DF2\u88C5";
|
|
19202
|
-
out.push(`${verb}\u65B9\u6CD5 ${r.package.version}\uFF08${r.ref} @ ${r.commit.slice(0, 12)}\uFF09\u2192 ${
|
|
19238
|
+
out.push(`${verb}\u65B9\u6CD5 ${r.package.version}\uFF08${r.ref} @ ${r.commit.slice(0, 12)}\uFF09\u2192 ${path17.join(r.root, METHOD_DIR)}/`);
|
|
19203
19239
|
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)}`);
|
|
19204
19240
|
out.push(` \u6280\u80FD ${r.skills.length} \u4EFD\uFF1A${naming(r.skills, 6)}`);
|
|
19205
19241
|
if (r.diff) for (const l of renderDiff(r.diff)) out.push(` ${l}`);
|
|
@@ -19247,7 +19283,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
19247
19283
|
report.lock = lock;
|
|
19248
19284
|
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` });
|
|
19249
19285
|
const state = await readState(root);
|
|
19250
|
-
const installed2 = await fsp4.readFile(
|
|
19286
|
+
const installed2 = await fsp4.readFile(path17.join(root, METHOD_DIR, "package.yml"), "utf8").catch(() => void 0);
|
|
19251
19287
|
if (installed2 === void 0) {
|
|
19252
19288
|
report.rows.push({
|
|
19253
19289
|
item: "\u5B89\u88C5",
|
|
@@ -19268,7 +19304,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
19268
19304
|
code: CliErrorCode41.METHOD_DIGEST_MISMATCH
|
|
19269
19305
|
});
|
|
19270
19306
|
} else {
|
|
19271
|
-
report.rows.push({ item: "\u5B89\u88C5", verdict: "ok", detail: `\u672C\u673A\u526F\u672C\u5C31\u662F\u9501\u5B9A\u7684\u90A3\u4E00\u7248\uFF08${
|
|
19307
|
+
report.rows.push({ item: "\u5B89\u88C5", verdict: "ok", detail: `\u672C\u673A\u526F\u672C\u5C31\u662F\u9501\u5B9A\u7684\u90A3\u4E00\u7248\uFF08${path17.join(root, METHOD_DIR)}/\uFF09` });
|
|
19272
19308
|
let manifest2;
|
|
19273
19309
|
try {
|
|
19274
19310
|
manifest2 = parsePackageManifest(installed2);
|
|
@@ -19276,17 +19312,17 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
19276
19312
|
report.digest.note = `\u672C\u673A package.yml \u8BFB\u4E0D\u61C2\uFF1A${e.message}`;
|
|
19277
19313
|
}
|
|
19278
19314
|
if (manifest2) {
|
|
19279
|
-
const main2 = await verifyDigests(manifest2.files, (p) =>
|
|
19315
|
+
const main2 = await verifyDigests(manifest2.files, (p) => path17.join(root, METHOD_DIR, p));
|
|
19280
19316
|
const copyEntries = [];
|
|
19281
19317
|
const copyMap = /* @__PURE__ */ new Map();
|
|
19282
19318
|
for (const s of manifest2.skills) {
|
|
19283
|
-
const copyDir =
|
|
19319
|
+
const copyDir = path17.join(root, ".claude", "skills", s.id);
|
|
19284
19320
|
if (!existsSync4(copyDir) && state?.target !== "claude") continue;
|
|
19285
|
-
const prefix = `${
|
|
19321
|
+
const prefix = `${path17.posix.dirname(s.path)}/`;
|
|
19286
19322
|
for (const f of manifest2.files.filter((x) => x.path.startsWith(prefix))) {
|
|
19287
19323
|
const shown = `.claude/skills/${s.id}/${f.path.slice(prefix.length)}`;
|
|
19288
19324
|
copyEntries.push({ ...f, path: shown });
|
|
19289
|
-
copyMap.set(shown,
|
|
19325
|
+
copyMap.set(shown, path17.join(root, shown));
|
|
19290
19326
|
}
|
|
19291
19327
|
}
|
|
19292
19328
|
const copies = await verifyDigests(copyEntries, (p) => copyMap.get(p));
|
|
@@ -19369,8 +19405,8 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
19369
19405
|
});
|
|
19370
19406
|
}
|
|
19371
19407
|
for (const id of lock.skills) {
|
|
19372
|
-
const by =
|
|
19373
|
-
if (existsSync4(
|
|
19408
|
+
const by = path17.join(SKILLS_DIR, SKILLS_LOCAL_SUBDIR, id);
|
|
19409
|
+
if (existsSync4(path17.join(root, by, "SKILL.md"))) report.shadowed.push({ id, by: `${by.split(path17.sep).join("/")}/` });
|
|
19374
19410
|
}
|
|
19375
19411
|
report.rows.push(report.shadowed.length ? {
|
|
19376
19412
|
item: "\u906E\u853D",
|
|
@@ -19390,7 +19426,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
19390
19426
|
}
|
|
19391
19427
|
function renderMethodStatus(r) {
|
|
19392
19428
|
const mark = { ok: "\u2705", warn: "\u26A0\uFE0F", fail: "\u274C" };
|
|
19393
|
-
const out = [`\u65B9\u6CD5\u5305\uFF1A${
|
|
19429
|
+
const out = [`\u65B9\u6CD5\u5305\uFF1A${path17.join(r.root, METHOD_DIR)}/`];
|
|
19394
19430
|
for (const row of r.rows) {
|
|
19395
19431
|
out.push(`${mark[row.verdict]} ${row.item} ${row.detail}`);
|
|
19396
19432
|
if (row.nextStep && row.verdict !== "ok") out.push(` \u2192 ${row.nextStep}`);
|
|
@@ -19489,8 +19525,8 @@ async function methodStatusCommand(args) {
|
|
|
19489
19525
|
|
|
19490
19526
|
// src/commands/doctor/local-checks.ts
|
|
19491
19527
|
import { promises as fs15 } from "fs";
|
|
19492
|
-
import
|
|
19493
|
-
import
|
|
19528
|
+
import path18 from "path";
|
|
19529
|
+
import axios7 from "axios";
|
|
19494
19530
|
import { CliError as CliError41, CliErrorCode as CliErrorCode42, fetchSkillCatalog as fetchSkillCatalog3, fetchSkillMarkdown as fetchSkillMarkdown2, fetchSkillReference as fetchSkillReference2, normalizeReferences as normalizeReferences2, normalizeOrigin as normalizeOrigin6, resolveChironBase as resolveChironBase3 } from "@hcmai/sdk";
|
|
19495
19531
|
|
|
19496
19532
|
// src/commands/doctor/result.ts
|
|
@@ -19606,13 +19642,13 @@ var version = async (ctx) => {
|
|
|
19606
19642
|
var installed = async (ctx) => {
|
|
19607
19643
|
let reading = "";
|
|
19608
19644
|
const read = (baseDir) => {
|
|
19609
|
-
reading =
|
|
19645
|
+
reading = path18.join(baseDir, SKILLS_STATE_FILE);
|
|
19610
19646
|
return readSkillsState(baseDir, { strict: true });
|
|
19611
19647
|
};
|
|
19612
19648
|
try {
|
|
19613
19649
|
const states = [];
|
|
19614
19650
|
for (const [target2, folder] of [["codex", "hcm-skills/sync"], ["claude", ".claude/skills"]]) {
|
|
19615
|
-
const baseDir =
|
|
19651
|
+
const baseDir = path18.join(ctx.root, folder);
|
|
19616
19652
|
const state = await read(baseDir);
|
|
19617
19653
|
if (state) states.push({ target: target2, baseDir, state });
|
|
19618
19654
|
}
|
|
@@ -19625,16 +19661,16 @@ var installed = async (ctx) => {
|
|
|
19625
19661
|
local = await readLocalSkills(localDir, { strict: true });
|
|
19626
19662
|
} catch (error) {
|
|
19627
19663
|
if (!(error instanceof SkillsDirUnreadable)) throw error;
|
|
19628
|
-
return unknown("SKILLS_LOCAL_UNREADABLE", `${
|
|
19664
|
+
return unknown("SKILLS_LOCAL_UNREADABLE", `${path18.relative(ctx.root, localDir)} \u8BFB\u4E0D\u4E86\uFF0C\u81EA\u5199\u6280\u80FD\u6570\u4E0D\u51FA\u6765\uFF1B${unreadableFix(error.code, error.detail)}\u540E\u91CD\u67E5`, {
|
|
19629
19665
|
note: `${error.where}\uFF1A${error.detail}`
|
|
19630
19666
|
});
|
|
19631
19667
|
}
|
|
19632
|
-
const localNote = local.length > 0 ? `\uFF1B${
|
|
19668
|
+
const localNote = local.length > 0 ? `\uFF1B${path18.relative(ctx.root, localDir)}/ \u53E6\u6709 ${local.length} \u4EFD\u81EA\u5199\u6280\u80FD\uFF08\u4E0D\u8FDB\u9501\u6587\u4EF6\uFF0Csync \u4E0D\u7BA1\u5B83\u4EEC\uFF09` : "";
|
|
19633
19669
|
const target = ctx.environments.find((e) => e.report.target);
|
|
19634
19670
|
if (states.some((s) => s.state.endpoint && normalizeOrigin6(s.state.endpoint) !== normalizeOrigin6(target.config.endpoint)))
|
|
19635
19671
|
return found("SKILLS_ENDPOINT_MISMATCH", void 0, { value: count });
|
|
19636
19672
|
if (count === 0) {
|
|
19637
|
-
const legacy = await read(
|
|
19673
|
+
const legacy = await read(path18.join(ctx.root, "hcm-skills"));
|
|
19638
19674
|
if (legacy && Object.keys(legacy.skills).length > 0) return found("SKILLS_LEGACY_LAYOUT", void 0, { value: count, evidence: "ABSENT" });
|
|
19639
19675
|
if (local.length > 0) {
|
|
19640
19676
|
return pass(
|
|
@@ -19647,7 +19683,7 @@ var installed = async (ctx) => {
|
|
|
19647
19683
|
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"))
|
|
19648
19684
|
return found("SKILLS_SPLIT_LAYOUT", void 0, { value: count });
|
|
19649
19685
|
return pass(
|
|
19650
|
-
`${count} \u4E2A\u4EA7\u54C1\u6280\u80FD\uFF08\u4E24\u4EFD\u9501\u6587\u4EF6 skills \u952E\u7684\u5E76\u96C6\uFF09\uFF1B${states.map((s) =>
|
|
19686
|
+
`${count} \u4E2A\u4EA7\u54C1\u6280\u80FD\uFF08\u4E24\u4EFD\u9501\u6587\u4EF6 skills \u952E\u7684\u5E76\u96C6\uFF09\uFF1B${states.map((s) => path18.relative(ctx.root, s.baseDir)).join("\u3001")}${localNote}`,
|
|
19651
19687
|
{ value: count + local.length }
|
|
19652
19688
|
);
|
|
19653
19689
|
} catch (error) {
|
|
@@ -19665,7 +19701,7 @@ function hasProductSkills(states) {
|
|
|
19665
19701
|
}
|
|
19666
19702
|
async function inspectSkillsFresh(states, endpoint, signal) {
|
|
19667
19703
|
if (!hasProductSkills(states)) return { level: "NOT_APPLICABLE", summary: NO_PRODUCT_SKILLS, note: "\u672A\u8BF7\u6C42\u6280\u80FD\u76EE\u5F55" };
|
|
19668
|
-
const http =
|
|
19704
|
+
const http = axios7.create({
|
|
19669
19705
|
baseURL: endpoint,
|
|
19670
19706
|
timeout: 5e3,
|
|
19671
19707
|
maxRedirects: 0,
|
|
@@ -19732,7 +19768,7 @@ var boundary = async (ctx) => {
|
|
|
19732
19768
|
for (const name of ["AGENTS.md", "CLAUDE.md"]) {
|
|
19733
19769
|
let text2;
|
|
19734
19770
|
try {
|
|
19735
|
-
text2 = await fs15.readFile(
|
|
19771
|
+
text2 = await fs15.readFile(path18.join(ctx.root, name), "utf8");
|
|
19736
19772
|
} catch (error) {
|
|
19737
19773
|
if (error.code === "ENOENT") continue;
|
|
19738
19774
|
throw error;
|
|
@@ -19808,7 +19844,7 @@ var shadow = async (ctx) => {
|
|
|
19808
19844
|
const localDir = skillsLocalDir(ctx.root);
|
|
19809
19845
|
const undetermined = (error) => {
|
|
19810
19846
|
const u = error instanceof SkillsDirUnreadable ? error : void 0;
|
|
19811
|
-
const where = u ?
|
|
19847
|
+
const where = u ? path18.relative(ctx.root, u.where) : path18.relative(ctx.root, localDir);
|
|
19812
19848
|
const detail = u ? safeError(new Error(u.detail)) : safeError(error);
|
|
19813
19849
|
return { summary: `${unreadableSideLabel(u?.side)}${u?.id ? ` \u91CC\u7684 ${u.id}` : ""} \u8BFB\u4E0D\u4E86`, note: `${where}\uFF1A${detail}`, fix: unreadableFix(u?.code, u?.detail ?? detail) };
|
|
19814
19850
|
};
|
|
@@ -19821,7 +19857,7 @@ var shadow = async (ctx) => {
|
|
|
19821
19857
|
}
|
|
19822
19858
|
let c2;
|
|
19823
19859
|
try {
|
|
19824
|
-
c2 = await listClaudeShadowedSkills(
|
|
19860
|
+
c2 = await listClaudeShadowedSkills(path18.join(ctx.root, ".claude", "skills"), localDir);
|
|
19825
19861
|
} catch (error) {
|
|
19826
19862
|
const x = undetermined(error);
|
|
19827
19863
|
if (!r.shadowed.length) return unknown("SKILLS_LOCAL_UNREADABLE", `${x.summary}\uFF0C\u6CA1\u6CD5\u5224\u6709\u6CA1\u6709\u906E\u853D\u4EA7\u54C1\u6280\u80FD\uFF1B${x.fix}\u540E\u91CD\u67E5`, { note: x.note });
|
|
@@ -19834,7 +19870,7 @@ var shadow = async (ctx) => {
|
|
|
19834
19870
|
const others = [[r, "sync/"], [c2, CLAUDE_SKILLS_DIR_LABEL]];
|
|
19835
19871
|
const othersText = others.filter(([x]) => x.unreadable.length).map(([x, label]) => `\uFF1B${label} \u53E6\u6709 ${x.unreadable.length} \u6761\u8BFB\u4E0D\u4E86\u3001\u6CA1\u7B97\u8FDB\u53BB\uFF1A${describeUnreadable(x.unreadable)}`).join("");
|
|
19836
19872
|
const unreadable = [...r.unreadable, ...c2.unreadable];
|
|
19837
|
-
const raw = unreadable.map((x) => `${
|
|
19873
|
+
const raw = unreadable.map((x) => `${path18.relative(ctx.root, x.where)}\uFF1A${safeError(new Error(x.detail))}`).join("\uFF1B");
|
|
19838
19874
|
if (r.shadowed.length || c2.shadowed.length) {
|
|
19839
19875
|
const parts = [];
|
|
19840
19876
|
if (r.shadowed.length) parts.push(`${SKILLS_DIR}/${SKILLS_LOCAL_SUBDIR}/ \u906E\u853D\u4E86 ${r.shadowed.length} \u4EFD\u4EA7\u54C1\u6280\u80FD\uFF1A${describeShadows(r.shadowed)}`);
|
|
@@ -19869,11 +19905,11 @@ var localChecks = { project, credential, version, installed, fresh, shadow, boun
|
|
|
19869
19905
|
|
|
19870
19906
|
// src/commands/doctor/connect-checks.ts
|
|
19871
19907
|
init_auth_guard();
|
|
19872
|
-
import
|
|
19908
|
+
import axios9 from "axios";
|
|
19873
19909
|
import { CliError as CliError42, IMPERSONATION_START_PATH, USER_LOOKUP_PATH, probeDoctorEndpoint, probeDoctorLayer, layerDetail, toPrincipal as toPrincipal3 } from "@hcmai/sdk";
|
|
19874
19910
|
|
|
19875
19911
|
// src/commands/doctor/server-report.ts
|
|
19876
|
-
import
|
|
19912
|
+
import axios8 from "axios";
|
|
19877
19913
|
import { classifyStatus } from "@hcmai/sdk";
|
|
19878
19914
|
var optionalText2 = (value) => value === void 0 || value === null || typeof value === "string";
|
|
19879
19915
|
var fullScope = { stage: null, only: [], skip: [], active: false };
|
|
@@ -19907,7 +19943,7 @@ var requestServerReport = async (endpoint, token, timeoutMs, budgetMs, signal, s
|
|
|
19907
19943
|
...scope.only.length ? { only: scope.only.join(",") } : {},
|
|
19908
19944
|
...scope.skip.length ? { skip: scope.skip.join(",") } : {}
|
|
19909
19945
|
};
|
|
19910
|
-
const res = scope.active ? await
|
|
19946
|
+
const res = scope.active ? await axios8.post("/api/system/health/report", { active: true, budgetMs, ...range }, options) : await axios8.get("/api/system/health/report", { ...options, params: { budgetMs, ...range } });
|
|
19911
19947
|
return {
|
|
19912
19948
|
status: res.status,
|
|
19913
19949
|
body: res.data,
|
|
@@ -19916,7 +19952,7 @@ var requestServerReport = async (endpoint, token, timeoutMs, budgetMs, signal, s
|
|
|
19916
19952
|
};
|
|
19917
19953
|
};
|
|
19918
19954
|
function stoppedWaiting(error, signal) {
|
|
19919
|
-
return signal.aborted ||
|
|
19955
|
+
return signal.aborted || axios8.isAxiosError(error) && error.code === "ECONNABORTED";
|
|
19920
19956
|
}
|
|
19921
19957
|
function httpNote(out) {
|
|
19922
19958
|
return `HTTP ${out.status < 0 ? "\u672A\u53D6\u5F97\u54CD\u5E94" : out.status}${out.headers["x-trace-id"] ? ` \xB7 traceId=${out.headers["x-trace-id"]}` : ""}`;
|
|
@@ -20257,11 +20293,11 @@ var identity = async (ctx, env2, execution) => {
|
|
|
20257
20293
|
const code3 = detail.mismatch === "tenant" ? "TENANT_MISMATCH" : "IDENTITY_USER_MISMATCH";
|
|
20258
20294
|
return found(code3, void 0, { note: `\u4EE3\u7406\u524D\u6838\u9A8C\u64CD\u4F5C\u8005\u65F6\u53D1\u73B0\u4E3B\u4F53\u4E0D\u7B26\uFF1A${safeError(error)}` });
|
|
20259
20295
|
}
|
|
20260
|
-
const status =
|
|
20261
|
-
const requestPath =
|
|
20296
|
+
const status = axios9.isAxiosError(error) ? error.response?.status : void 0;
|
|
20297
|
+
const requestPath = axios9.isAxiosError(error) ? error.config?.url ?? "" : "";
|
|
20262
20298
|
const proxyStart = requestPath.endsWith(IMPERSONATION_START_PATH);
|
|
20263
20299
|
const userLookup = requestPath.endsWith(USER_LOOKUP_PATH);
|
|
20264
|
-
const envelope =
|
|
20300
|
+
const envelope = axios9.isAxiosError(error) && obj(error.response?.data) && obj(error.response.data.error) ? error.response.data.error : void 0;
|
|
20265
20301
|
const targetMissing = status === 404 && proxyStart && envelope?.code === "NOT_FOUND";
|
|
20266
20302
|
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";
|
|
20267
20303
|
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";
|
|
@@ -20557,8 +20593,8 @@ async function executeChecks(ctx, options = {}) {
|
|
|
20557
20593
|
let timer;
|
|
20558
20594
|
let proxy = false;
|
|
20559
20595
|
let expire;
|
|
20560
|
-
const timeout = new Promise((
|
|
20561
|
-
expire =
|
|
20596
|
+
const timeout = new Promise((resolve8) => {
|
|
20597
|
+
expire = resolve8;
|
|
20562
20598
|
});
|
|
20563
20599
|
const arm = (ms) => {
|
|
20564
20600
|
clearTimeout(timer);
|
|
@@ -20867,7 +20903,7 @@ function renderChironDoctor(report) {
|
|
|
20867
20903
|
|
|
20868
20904
|
// src/commands/doctor/platform-ops.ts
|
|
20869
20905
|
import { createHash as createHash8 } from "crypto";
|
|
20870
|
-
import
|
|
20906
|
+
import axios10 from "axios";
|
|
20871
20907
|
import {
|
|
20872
20908
|
classifyStatus as classifyStatus2,
|
|
20873
20909
|
CliError as CliError43,
|
|
@@ -20937,7 +20973,7 @@ var placeholder = {
|
|
|
20937
20973
|
};
|
|
20938
20974
|
var OPS_DESCRIPTORS = [connectivity2, api, placeholder];
|
|
20939
20975
|
var requestOpsReport = async (endpoint, key2, timeoutMs, budgetMs, signal, scope) => {
|
|
20940
|
-
const res = await
|
|
20976
|
+
const res = await axios10.get(OPS_PATH, {
|
|
20941
20977
|
baseURL: endpoint,
|
|
20942
20978
|
timeout: timeoutMs,
|
|
20943
20979
|
signal,
|
|
@@ -21508,7 +21544,7 @@ var defaultServices = {
|
|
|
21508
21544
|
pendingVerify: async (signal) => gapPendingVerify({ client: await createJiraClient2({ timeoutMs: 8e3 }) }, { signal }),
|
|
21509
21545
|
skillsFresh: inspectSkillsFresh,
|
|
21510
21546
|
asAuth: (...args) => ensureAsAuth(...args),
|
|
21511
|
-
probe: (endpoint, token, signal) => httpProbe2(
|
|
21547
|
+
probe: (endpoint, token, signal) => httpProbe2(axios11.create({
|
|
21512
21548
|
baseURL: endpoint,
|
|
21513
21549
|
timeout: 5e3,
|
|
21514
21550
|
maxRedirects: 0,
|
|
@@ -21611,11 +21647,11 @@ async function readCredential(envFlag, root, as) {
|
|
|
21611
21647
|
return { resolved, identity: identity3, meta: meta2, token };
|
|
21612
21648
|
}
|
|
21613
21649
|
async function prepareContext(args, deps) {
|
|
21614
|
-
const startedAt = Date.now(), root =
|
|
21650
|
+
const startedAt = Date.now(), root = path19.resolve(args.project ?? ".");
|
|
21615
21651
|
let file;
|
|
21616
21652
|
let projectObservation = found("ENV_FILE_MISSING", void 0, { evidence: "ABSENT" });
|
|
21617
21653
|
try {
|
|
21618
|
-
const text2 = await fs16.readFile(
|
|
21654
|
+
const text2 = await fs16.readFile(path19.join(root, "env.yaml"), "utf8");
|
|
21619
21655
|
try {
|
|
21620
21656
|
file = parseEnvYaml3(text2);
|
|
21621
21657
|
projectObservation = pass("env.yaml \u53EF\u89E3\u6790");
|
|
@@ -21631,7 +21667,7 @@ async function prepareContext(args, deps) {
|
|
|
21631
21667
|
if (args.env && (!file || !Object.hasOwn(file.environments, args.env))) {
|
|
21632
21668
|
try {
|
|
21633
21669
|
const resolved = await resolveEnvContext9({ envFlag: args.env, cwd: root }, process.env, await loadGlobalConfig12());
|
|
21634
|
-
if (resolved.project?.path !==
|
|
21670
|
+
if (resolved.project?.path !== path19.join(root, "env.yaml")) throw new Error("\u672C\u673A\u69FD\u4E0D\u5C5E\u4E8E\u5F53\u524D\u9879\u76EE");
|
|
21635
21671
|
targetEnv = resolved.project.name;
|
|
21636
21672
|
explicitSlot = resolved.name;
|
|
21637
21673
|
} catch (error) {
|
|
@@ -21849,7 +21885,7 @@ import { spawnSync } from "child_process";
|
|
|
21849
21885
|
import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
|
|
21850
21886
|
import fs17 from "fs/promises";
|
|
21851
21887
|
import os6 from "os";
|
|
21852
|
-
import
|
|
21888
|
+
import path21 from "path";
|
|
21853
21889
|
import { CliError as CliError47, CliErrorCode as CliErrorCode47, formatObject as formatObject34, HcmClient as HcmClient30, loadEnv as loadEnv6 } from "@hcmai/sdk";
|
|
21854
21890
|
import { createRequire } from "module";
|
|
21855
21891
|
|
|
@@ -21916,8 +21952,8 @@ var CdpSession = class {
|
|
|
21916
21952
|
send(method3, params = {}) {
|
|
21917
21953
|
if (this.closed) return Promise.reject(new Error(`CDP socket \u5DF2\u5173\u95ED\uFF0C\u53D1\u4E0D\u4E86 ${method3}`));
|
|
21918
21954
|
const id = this.nextId++;
|
|
21919
|
-
return new Promise((
|
|
21920
|
-
this.pending.set(id, { resolve:
|
|
21955
|
+
return new Promise((resolve8, reject) => {
|
|
21956
|
+
this.pending.set(id, { resolve: resolve8, reject, method: method3 });
|
|
21921
21957
|
this.socket.send(JSON.stringify({ id, method: method3, params }));
|
|
21922
21958
|
});
|
|
21923
21959
|
}
|
|
@@ -21937,11 +21973,11 @@ var CdpSession = class {
|
|
|
21937
21973
|
}
|
|
21938
21974
|
/** 等一个事件,超时就 reject——「等 load 事件」不能无限等。无论哪种结束都摘掉监听器。 */
|
|
21939
21975
|
waitFor(event, timeoutMs) {
|
|
21940
|
-
return new Promise((
|
|
21976
|
+
return new Promise((resolve8, reject) => {
|
|
21941
21977
|
const off = this.on(event, (params) => {
|
|
21942
21978
|
clearTimeout(timer);
|
|
21943
21979
|
off();
|
|
21944
|
-
|
|
21980
|
+
resolve8(params);
|
|
21945
21981
|
});
|
|
21946
21982
|
const timer = setTimeout(() => {
|
|
21947
21983
|
off();
|
|
@@ -22055,7 +22091,7 @@ var defaultCdpIo = {
|
|
|
22055
22091
|
const text2 = await res.text();
|
|
22056
22092
|
return text2 ? JSON.parse(text2) : null;
|
|
22057
22093
|
},
|
|
22058
|
-
openSocket: (wsUrl) => new Promise((
|
|
22094
|
+
openSocket: (wsUrl) => new Promise((resolve8, reject) => {
|
|
22059
22095
|
const Ctor = globalThis.WebSocket;
|
|
22060
22096
|
if (!Ctor) {
|
|
22061
22097
|
reject(new CliError45({ code: CliErrorCode45.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" }));
|
|
@@ -22065,7 +22101,7 @@ var defaultCdpIo = {
|
|
|
22065
22101
|
const timer = setTimeout(() => reject(new Error(`\u8FDE ${wsUrl} \u8D85\u8FC7 ${CDP_IO_TIMEOUT_MS}ms \u6CA1\u63E1\u4E0A\u624B`)), CDP_IO_TIMEOUT_MS);
|
|
22066
22102
|
ws.addEventListener("open", () => {
|
|
22067
22103
|
clearTimeout(timer);
|
|
22068
|
-
|
|
22104
|
+
resolve8(ws);
|
|
22069
22105
|
});
|
|
22070
22106
|
ws.addEventListener("error", (ev) => {
|
|
22071
22107
|
clearTimeout(timer);
|
|
@@ -22080,17 +22116,17 @@ var defaultCdpIo = {
|
|
|
22080
22116
|
};
|
|
22081
22117
|
|
|
22082
22118
|
// src/commands/chiron-page-playwright.ts
|
|
22083
|
-
import
|
|
22119
|
+
import path20 from "path";
|
|
22084
22120
|
import { CliError as CliError46, CliErrorCode as CliErrorCode46 } from "@hcmai/sdk";
|
|
22085
22121
|
function playwrightCacheRoot(probe3) {
|
|
22086
22122
|
const override = probe3.env.PLAYWRIGHT_BROWSERS_PATH?.trim();
|
|
22087
|
-
if (override === "0" && probe3.packageRoot) return
|
|
22088
|
-
if (override && override !== "0") return
|
|
22089
|
-
if (probe3.platform === "darwin") return
|
|
22123
|
+
if (override === "0" && probe3.packageRoot) return path20.join(probe3.packageRoot, ".local-browsers");
|
|
22124
|
+
if (override && override !== "0") return path20.resolve(override);
|
|
22125
|
+
if (probe3.platform === "darwin") return path20.join(probe3.homedir(), "Library", "Caches", "ms-playwright");
|
|
22090
22126
|
if (probe3.platform === "win32") {
|
|
22091
|
-
return
|
|
22127
|
+
return path20.join(probe3.env.LOCALAPPDATA?.trim() || path20.join(probe3.homedir(), "AppData", "Local"), "ms-playwright");
|
|
22092
22128
|
}
|
|
22093
|
-
return
|
|
22129
|
+
return path20.join(probe3.env.XDG_CACHE_HOME?.trim() || path20.join(probe3.homedir(), ".cache"), "ms-playwright");
|
|
22094
22130
|
}
|
|
22095
22131
|
function playwrightPlatformTag(probe3) {
|
|
22096
22132
|
const arm = probe3.arch === "arm64";
|
|
@@ -22106,19 +22142,19 @@ function revisionOf(entry, prefix) {
|
|
|
22106
22142
|
function candidateBinaries(probe3, kind) {
|
|
22107
22143
|
const tag = playwrightPlatformTag(probe3);
|
|
22108
22144
|
if (kind === "headless-shell") {
|
|
22109
|
-
return [
|
|
22145
|
+
return [path20.join(`chrome-headless-shell-${tag}`, probe3.platform === "win32" ? "chrome-headless-shell.exe" : "chrome-headless-shell")];
|
|
22110
22146
|
}
|
|
22111
22147
|
if (probe3.platform === "darwin") {
|
|
22112
22148
|
return [
|
|
22113
22149
|
// Playwright ≥ 1.49:Chrome for Testing 的 .app
|
|
22114
|
-
|
|
22150
|
+
path20.join(`chrome-${tag}`, "Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing"),
|
|
22115
22151
|
// ≤ 1.48:Chromium.app,目录名不分架构
|
|
22116
|
-
|
|
22117
|
-
|
|
22152
|
+
path20.join("chrome-mac", "Chromium.app", "Contents", "MacOS", "Chromium"),
|
|
22153
|
+
path20.join(`chrome-${tag}`, "Chromium.app", "Contents", "MacOS", "Chromium")
|
|
22118
22154
|
];
|
|
22119
22155
|
}
|
|
22120
|
-
if (probe3.platform === "win32") return [
|
|
22121
|
-
return [
|
|
22156
|
+
if (probe3.platform === "win32") return [path20.join("chrome-win64", "chrome.exe"), path20.join("chrome-win", "chrome.exe")];
|
|
22157
|
+
return [path20.join(`chrome-${tag}`, "chrome"), path20.join("chrome-linux", "chrome")];
|
|
22122
22158
|
}
|
|
22123
22159
|
function discoverPlaywrightBrowser(probe3) {
|
|
22124
22160
|
const explicit = probe3.env.HCM_PLAYWRIGHT_EXECUTABLE?.trim();
|
|
@@ -22136,8 +22172,8 @@ function discoverPlaywrightBrowser(probe3) {
|
|
|
22136
22172
|
const revisions = entries.map((e) => ({ e, rev: revisionOf(e, prefix) })).filter((x) => x.rev !== null).sort((a, b) => b.rev - a.rev);
|
|
22137
22173
|
for (const { e } of revisions) {
|
|
22138
22174
|
for (const rel of candidateBinaries(probe3, kind)) {
|
|
22139
|
-
const candidate =
|
|
22140
|
-
if (probe3.executable(candidate)) return { executablePath: candidate, kind, from:
|
|
22175
|
+
const candidate = path20.join(root, e, rel);
|
|
22176
|
+
if (probe3.executable(candidate)) return { executablePath: candidate, kind, from: path20.join(root, e) };
|
|
22141
22177
|
}
|
|
22142
22178
|
}
|
|
22143
22179
|
return null;
|
|
@@ -22239,10 +22275,10 @@ function resolveEvidenceTarget(projectRoot, out) {
|
|
|
22239
22275
|
if (!out.endsWith(".png")) {
|
|
22240
22276
|
throw new CliError47({ code: CliErrorCode47.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
|
|
22241
22277
|
}
|
|
22242
|
-
const root =
|
|
22243
|
-
const evidenceRoot =
|
|
22244
|
-
const absolute =
|
|
22245
|
-
if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot +
|
|
22278
|
+
const root = path21.resolve(projectRoot);
|
|
22279
|
+
const evidenceRoot = path21.join(root, EVIDENCE_DIR);
|
|
22280
|
+
const absolute = path21.resolve(root, out);
|
|
22281
|
+
if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path21.sep)) {
|
|
22246
22282
|
throw new CliError47({
|
|
22247
22283
|
code: CliErrorCode47.INVALID_ARGUMENT,
|
|
22248
22284
|
message: `--out \u8981\u843D\u5728\u9879\u76EE\u7684 ${EVIDENCE_DIR}/ \u4E0B\uFF08${evidenceRoot}\uFF09\uFF0C\u6536\u5230\u7684\u662F ${absolute}`
|
|
@@ -22289,9 +22325,9 @@ function findChrome(probe3, override) {
|
|
|
22289
22325
|
}
|
|
22290
22326
|
async function assertInsideEvidence(deps, evidenceRoot, absolute) {
|
|
22291
22327
|
const canonicalRoot = await deps.realpath(evidenceRoot);
|
|
22292
|
-
const canonicalParent = await deps.realpath(
|
|
22328
|
+
const canonicalParent = await deps.realpath(path21.dirname(absolute));
|
|
22293
22329
|
if (canonicalRoot === null || canonicalParent === null) return;
|
|
22294
|
-
if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot +
|
|
22330
|
+
if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path21.sep)) {
|
|
22295
22331
|
throw new CliError47({
|
|
22296
22332
|
code: CliErrorCode47.INVALID_ARGUMENT,
|
|
22297
22333
|
message: `--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u8DD1\u51FA\u4E86 ${EVIDENCE_DIR}/\uFF1A${canonicalParent}`
|
|
@@ -22310,7 +22346,7 @@ async function runChironPage(target, args, deps) {
|
|
|
22310
22346
|
const reject = (args.rejectText ?? []).filter((t) => t.trim().length > 0);
|
|
22311
22347
|
const viewport = parseViewport(args.size ?? "1440x900");
|
|
22312
22348
|
const waitMs = parseWaitMs(args.waitMs);
|
|
22313
|
-
const root =
|
|
22349
|
+
const root = path21.resolve(args.project ?? ".");
|
|
22314
22350
|
const { evidenceRoot, absolute } = resolveEvidenceTarget(root, args.out);
|
|
22315
22351
|
if (await deps.present(absolute)) {
|
|
22316
22352
|
throw new CliError47({
|
|
@@ -22318,7 +22354,7 @@ async function runChironPage(target, args, deps) {
|
|
|
22318
22354
|
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`
|
|
22319
22355
|
});
|
|
22320
22356
|
}
|
|
22321
|
-
await deps.ensureDir(
|
|
22357
|
+
await deps.ensureDir(path21.dirname(absolute));
|
|
22322
22358
|
await assertInsideEvidence(deps, evidenceRoot, absolute);
|
|
22323
22359
|
const endpoint = normalizeCdpEndpoint(args.cdp ?? deps.env.HCM_CHROME_CDP);
|
|
22324
22360
|
const evalJs = args.eval?.trim() ? args.eval : void 0;
|
|
@@ -22436,7 +22472,7 @@ function safeStringify(value) {
|
|
|
22436
22472
|
}
|
|
22437
22473
|
function playwrightPackageRoot() {
|
|
22438
22474
|
try {
|
|
22439
|
-
return
|
|
22475
|
+
return path21.dirname(createRequire(import.meta.url).resolve("playwright-core/package.json"));
|
|
22440
22476
|
} catch {
|
|
22441
22477
|
return void 0;
|
|
22442
22478
|
}
|
|
@@ -22528,7 +22564,7 @@ init_exit();
|
|
|
22528
22564
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
22529
22565
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
22530
22566
|
import { promises as fs18 } from "fs";
|
|
22531
|
-
import
|
|
22567
|
+
import path22 from "path";
|
|
22532
22568
|
import yaml5 from "js-yaml";
|
|
22533
22569
|
import { formatObject as formatObject35 } from "@hcmai/sdk";
|
|
22534
22570
|
|
|
@@ -23511,7 +23547,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
|
|
|
23511
23547
|
continue;
|
|
23512
23548
|
}
|
|
23513
23549
|
if (c2.file) {
|
|
23514
|
-
const file =
|
|
23550
|
+
const file = path22.resolve(root, fill(c2.file));
|
|
23515
23551
|
const want = c2.expect ?? {};
|
|
23516
23552
|
const bad = [];
|
|
23517
23553
|
if (want.xlsx_header || want.xlsx_min_rows !== void 0) {
|
|
@@ -23533,7 +23569,7 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
|
|
|
23533
23569
|
results.push(bad.length ? { name: c2.name, verdict: "fail", detail: bad.join("\uFF1B") } : { name: c2.name, verdict: "pass", detail: "" });
|
|
23534
23570
|
continue;
|
|
23535
23571
|
}
|
|
23536
|
-
const out =
|
|
23572
|
+
const out = path22.join(
|
|
23537
23573
|
"evidence",
|
|
23538
23574
|
"test",
|
|
23539
23575
|
opts.evidenceRunId ?? "current",
|
|
@@ -23555,11 +23591,11 @@ async function runCase(spec, root, opts = {}, deps = defaultDeps2) {
|
|
|
23555
23591
|
}
|
|
23556
23592
|
async function loadCases(target) {
|
|
23557
23593
|
const stat = await fs18.stat(target);
|
|
23558
|
-
const files = stat.isDirectory() ? (await fs18.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) =>
|
|
23594
|
+
const files = stat.isDirectory() ? (await fs18.readdir(target)).filter((f) => /\.ya?ml$/.test(f)).sort().map((f) => path22.join(target, f)) : [target];
|
|
23559
23595
|
const out = [];
|
|
23560
23596
|
for (const f of files) {
|
|
23561
23597
|
const spec = yaml5.load(await fs18.readFile(f, "utf8"));
|
|
23562
|
-
assertUsableSpec(spec,
|
|
23598
|
+
assertUsableSpec(spec, path22.basename(f));
|
|
23563
23599
|
out.push({ file: f, spec });
|
|
23564
23600
|
}
|
|
23565
23601
|
if (out.length === 0) throw new Error(`${target} \u4E0B\u6CA1\u6709\u7528\u4F8B\uFF08*.yml\uFF09`);
|
|
@@ -23567,8 +23603,8 @@ async function loadCases(target) {
|
|
|
23567
23603
|
}
|
|
23568
23604
|
async function chironTestCommand(target, args, deps) {
|
|
23569
23605
|
try {
|
|
23570
|
-
const root =
|
|
23571
|
-
const where =
|
|
23606
|
+
const root = path22.resolve(args.project ?? ".");
|
|
23607
|
+
const where = path22.resolve(root, target ?? "tests");
|
|
23572
23608
|
const cases2 = await loadCases(where);
|
|
23573
23609
|
const report = [];
|
|
23574
23610
|
let failed2 = 0;
|
|
@@ -23580,7 +23616,7 @@ async function chironTestCommand(target, args, deps) {
|
|
|
23580
23616
|
deps
|
|
23581
23617
|
);
|
|
23582
23618
|
failed2 += results.filter((r) => r.verdict === "fail").length;
|
|
23583
|
-
report.push({ case: spec.name, file:
|
|
23619
|
+
report.push({ case: spec.name, file: path22.relative(root, file), results });
|
|
23584
23620
|
}
|
|
23585
23621
|
const fmt = args.output ?? "table";
|
|
23586
23622
|
if (fmt === "json" || fmt === "yaml") {
|
|
@@ -23721,7 +23757,7 @@ import {
|
|
|
23721
23757
|
writeRisk
|
|
23722
23758
|
} from "@hcmai/sdk";
|
|
23723
23759
|
import { existsSync as existsSync5 } from "fs";
|
|
23724
|
-
import * as
|
|
23760
|
+
import * as path23 from "path";
|
|
23725
23761
|
function premise(message, hint = "") {
|
|
23726
23762
|
process.stderr.write(message + (hint ? `
|
|
23727
23763
|
\u2192 ${hint}` : "") + "\n");
|
|
@@ -23748,13 +23784,13 @@ async function runSeedPlan(args, client4) {
|
|
|
23748
23784
|
const reconDir = candidates[0].reconDir;
|
|
23749
23785
|
if (candidates.length > 1) {
|
|
23750
23786
|
process.stderr.write(
|
|
23751
|
-
`\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${
|
|
23787
|
+
`\u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u6709 ${candidates.length} \u4EFD\u57FA\u7EBF\uFF0C\u672C\u8F6E\u8BFB\u7684\u662F \`${path23.basename(reconDir)}\`\uFF1A` + candidates.slice(1).map((c2) => `\`${path23.basename(c2.reconDir)}\``).join("\u3001") + " \u672A\u88AB\u8BFB\u53D6 \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n"
|
|
23752
23788
|
);
|
|
23753
23789
|
}
|
|
23754
23790
|
const round = inspectRound2(reconDir);
|
|
23755
23791
|
process.stderr.write(roundWarning(round));
|
|
23756
23792
|
const baseline = {
|
|
23757
|
-
path: `${
|
|
23793
|
+
path: `${path23.basename(path23.dirname(reconDir))}/${path23.basename(reconDir)}`,
|
|
23758
23794
|
roundId: round.roundId ?? null
|
|
23759
23795
|
};
|
|
23760
23796
|
let exemptions = null;
|
|
@@ -24016,7 +24052,7 @@ async function deliverySeedVerifyCommand(args) {
|
|
|
24016
24052
|
// src/commands/delivery-seed-find.ts
|
|
24017
24053
|
import { existsSync as existsSync6 } from "fs";
|
|
24018
24054
|
import { readFileSync as readFileSync9 } from "fs";
|
|
24019
|
-
import * as
|
|
24055
|
+
import * as path24 from "path";
|
|
24020
24056
|
import {
|
|
24021
24057
|
INIT_EXIT_CODES as INIT_EXIT_CODES2,
|
|
24022
24058
|
ValueHints,
|
|
@@ -24030,10 +24066,10 @@ import {
|
|
|
24030
24066
|
valuesRoundCaveat
|
|
24031
24067
|
} from "@hcmai/sdk";
|
|
24032
24068
|
function provenance(chosenReconDir, others) {
|
|
24033
|
-
let line = `> \u57FA\u7EBF\uFF1A\`${
|
|
24069
|
+
let line = `> \u57FA\u7EBF\uFF1A\`${path24.basename(chosenReconDir)}\`
|
|
24034
24070
|
`;
|
|
24035
24071
|
if (others.length > 0) {
|
|
24036
|
-
line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${
|
|
24072
|
+
line += `> \u26A0\uFE0F \u540C\u79DF\u6237\u4E0B\u53E6\u6709 ${others.length} \u4EFD\u57FA\u7EBF\u672A\u88AB\u8BFB\u53D6\uFF1A` + others.map((o) => `\`${path24.basename(o)}\``).join("\u3001") + " \u2014\u2014 \u4E0D\u540C sourceKey \u7684\u4EA7\u7269**\u4E0D\u53EF\u4E92\u6362**\u3002\n";
|
|
24037
24073
|
}
|
|
24038
24074
|
return `${line}
|
|
24039
24075
|
`;
|
|
@@ -24370,7 +24406,7 @@ import {
|
|
|
24370
24406
|
runTriageRound
|
|
24371
24407
|
} from "@hcmai/sdk";
|
|
24372
24408
|
import { mkdirSync as mkdirSync2, readFileSync as readFileSync11, writeFileSync as writeFileSync3 } from "fs";
|
|
24373
|
-
import * as
|
|
24409
|
+
import * as path25 from "path";
|
|
24374
24410
|
var DEFAULT_CAPABILITIES3 = "default";
|
|
24375
24411
|
function premise4(message, hint) {
|
|
24376
24412
|
process.stderr.write(`\u{1F534} \u524D\u63D0\u4E0D\u6210\u7ACB\uFF1A${message}
|
|
@@ -24406,8 +24442,8 @@ function renderProblems(rows2) {
|
|
|
24406
24442
|
`;
|
|
24407
24443
|
}
|
|
24408
24444
|
function writeTriageArtifact(outDir, body) {
|
|
24409
|
-
const out =
|
|
24410
|
-
mkdirSync2(
|
|
24445
|
+
const out = path25.join(outDir, "work", "triage.md");
|
|
24446
|
+
mkdirSync2(path25.dirname(out), { recursive: true });
|
|
24411
24447
|
writeFileSync3(out, body, "utf8");
|
|
24412
24448
|
return out;
|
|
24413
24449
|
}
|
|
@@ -24906,7 +24942,7 @@ program.command("update <Model>").description("\u66F4\u65B0\u4E00\u6761 Model \u
|
|
|
24906
24942
|
).action((model, opts) => updateCommand(model, opts));
|
|
24907
24943
|
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));
|
|
24908
24944
|
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));
|
|
24909
|
-
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((
|
|
24945
|
+
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((path26, opts) => openCommand(path26, opts));
|
|
24910
24946
|
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");
|
|
24911
24947
|
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));
|
|
24912
24948
|
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(
|