@hcmai/cli 0.14.4 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +378 -60
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +12 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4600,7 +4600,8 @@ import {
|
|
|
4600
4600
|
fetchConversationTimeline as fetchConversationTimeline2,
|
|
4601
4601
|
fetchConversationTimelineStrict,
|
|
4602
4602
|
fetchRecentConversations,
|
|
4603
|
-
|
|
4603
|
+
findLastAssistantTarget,
|
|
4604
|
+
SUPERSEDED_STATUS,
|
|
4604
4605
|
CliError as CliError16,
|
|
4605
4606
|
CliErrorCode as CliErrorCode15,
|
|
4606
4607
|
parseInteractionRequest as parseInteractionRequest2,
|
|
@@ -4719,21 +4720,39 @@ function eventScope(value) {
|
|
|
4719
4720
|
if (value.subLoop === false) return "root";
|
|
4720
4721
|
return "-";
|
|
4721
4722
|
}
|
|
4723
|
+
function toolState(tool) {
|
|
4724
|
+
return String(tool?.state ?? "").toLowerCase();
|
|
4725
|
+
}
|
|
4722
4726
|
function eventStatus(value) {
|
|
4723
|
-
if (typeof value.status === "string" && value.status.trim()) return oneLine(value.status,
|
|
4727
|
+
if (typeof value.status === "string" && value.status.trim()) return oneLine(value.status, 26);
|
|
4724
4728
|
if (value.live === true) return "live";
|
|
4725
4729
|
const tools = value.tools;
|
|
4726
4730
|
if (Array.isArray(tools) && tools.length) {
|
|
4727
|
-
if (tools.some((tool) =>
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
if (tools.some((tool) => String(tool.state ?? "").toLowerCase() === "running")) {
|
|
4731
|
-
return "running";
|
|
4732
|
-
}
|
|
4731
|
+
if (tools.some((tool) => toolState(tool) === "error")) return "failed";
|
|
4732
|
+
if (tools.some((tool) => toolState(tool) === "halted")) return "halted";
|
|
4733
|
+
if (tools.some((tool) => toolState(tool) === "running")) return "running";
|
|
4733
4734
|
return "done";
|
|
4734
4735
|
}
|
|
4735
4736
|
return "-";
|
|
4736
4737
|
}
|
|
4738
|
+
function asRecord(value) {
|
|
4739
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
4740
|
+
}
|
|
4741
|
+
function readSubToolStats(tool) {
|
|
4742
|
+
const t = asRecord(tool);
|
|
4743
|
+
if (!t) return void 0;
|
|
4744
|
+
const candidate = asRecord(t.subToolStats);
|
|
4745
|
+
if (!candidate) return void 0;
|
|
4746
|
+
const total = candidate.total;
|
|
4747
|
+
const failed2 = candidate.failed;
|
|
4748
|
+
if (typeof total !== "number" || typeof failed2 !== "number") return void 0;
|
|
4749
|
+
return { total, failed: failed2, errorCodes: candidate.errorCodes };
|
|
4750
|
+
}
|
|
4751
|
+
function formatSubToolStats(tool) {
|
|
4752
|
+
const stats = readSubToolStats(tool);
|
|
4753
|
+
if (!stats) return "";
|
|
4754
|
+
return `(sub ${stats.total} tool${stats.total === 1 ? "" : "s"} \xB7 ${stats.failed} failed)`;
|
|
4755
|
+
}
|
|
4737
4756
|
function stableJson(value) {
|
|
4738
4757
|
try {
|
|
4739
4758
|
return JSON.stringify(value);
|
|
@@ -4741,19 +4760,31 @@ function stableJson(value) {
|
|
|
4741
4760
|
return String(value ?? "");
|
|
4742
4761
|
}
|
|
4743
4762
|
}
|
|
4744
|
-
function
|
|
4763
|
+
function firstText(value) {
|
|
4745
4764
|
for (const key2 of ["text", "content", "summary", "question", "detail", "message"]) {
|
|
4746
|
-
|
|
4765
|
+
const v = value[key2];
|
|
4766
|
+
if (typeof v === "string" && v.trim()) return v;
|
|
4767
|
+
}
|
|
4768
|
+
return void 0;
|
|
4769
|
+
}
|
|
4770
|
+
function guardRedirectPreview(value) {
|
|
4771
|
+
const cause = typeof value.cause === "string" && value.cause.trim() ? value.cause : "";
|
|
4772
|
+
const body = firstText(value) ?? "";
|
|
4773
|
+
return oneLine(`\u27F2 \u6253\u56DE ${body}${cause ? ` \xB7 ${cause}` : ""}`, 86);
|
|
4774
|
+
}
|
|
4775
|
+
function eventPreview(value) {
|
|
4776
|
+
if (value.kind === "guard-redirect") return guardRedirectPreview(value);
|
|
4777
|
+
const text = firstText(value);
|
|
4778
|
+
if (text !== void 0) {
|
|
4779
|
+
const superseded = value.kind === "chat-text" && value.status === SUPERSEDED_STATUS;
|
|
4780
|
+
return superseded ? `\u2298 ${oneLine(text, 84)}` : oneLine(text, 86);
|
|
4747
4781
|
}
|
|
4748
4782
|
const tools = value.tools;
|
|
4749
4783
|
if (Array.isArray(tools) && tools.length) {
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
}).join(" \xB7 "),
|
|
4755
|
-
86
|
|
4756
|
-
);
|
|
4784
|
+
const list = tools;
|
|
4785
|
+
const prefix = list.map((t) => formatSubToolStats(t)).filter((s) => s !== "").join(" ");
|
|
4786
|
+
const body = list.map((t) => `${String(t.toolName ?? t.name ?? "-")}:${String(t.state ?? t.status ?? "-")}`).join(" \xB7 ");
|
|
4787
|
+
return oneLine(prefix ? `${prefix} ${body}` : body, 86);
|
|
4757
4788
|
}
|
|
4758
4789
|
const activityLog = value.activityLog;
|
|
4759
4790
|
if (Array.isArray(activityLog) && activityLog.length) {
|
|
@@ -4769,6 +4800,24 @@ function eventPreview(value) {
|
|
|
4769
4800
|
if (part && typeof part === "object") return oneLine(stableJson(part), 86);
|
|
4770
4801
|
return oneLine(stableJson(value), 86);
|
|
4771
4802
|
}
|
|
4803
|
+
function buildEventRows(items) {
|
|
4804
|
+
return items.map((item) => {
|
|
4805
|
+
const value = item;
|
|
4806
|
+
return {
|
|
4807
|
+
SEQ: value.seq ?? "-",
|
|
4808
|
+
KIND: oneLine(value.kind, 18),
|
|
4809
|
+
AGENT: eventAgent(value),
|
|
4810
|
+
SCOPE: eventScope(value),
|
|
4811
|
+
STATUS: eventStatus(value),
|
|
4812
|
+
EVENT: eventPreview(value)
|
|
4813
|
+
};
|
|
4814
|
+
});
|
|
4815
|
+
}
|
|
4816
|
+
function lastAssistantMissDetail(target) {
|
|
4817
|
+
const head = target.reason === "superseded-only" ? "\u672C\u8F6E\u7684\u7EC8\u7B54\u88AB\u5F15\u64CE\u5B88\u536B\u6253\u56DE\uFF08SUPERSEDED\uFF09\uFF0C\u4ECE\u672A\u4EA4\u4ED8\u7ED9\u7528\u6237" : target.reason === "no-answer-in-turn" ? "\u672C\u8F6E\u6CA1\u6709\u5DF2\u4EA4\u4ED8\u7684\u7EC8\u7B54\uFF08\u4E2D\u65AD\u6216\u4ECD\u5728\u8DD1\uFF09" : "\u8BE5\u4F1A\u8BDD\u7684 timeline \u6CA1\u6709\u53EF\u7528\u6761\u76EE";
|
|
4818
|
+
if (target.earlierSeq === void 0) return head;
|
|
4819
|
+
return `${head}\uFF1B\u8DE8\u8F6E\u56DE\u9000\u4F1A\u8FDE\u672C\u8F6E\u63D0\u95EE\u4E00\u8D77\u4F5C\u5E9F\uFF0C\u4E0D\u81EA\u52A8\u505A\u2014\u2014\u786E\u9700\u56DE\u9000\u5230\u4E0A\u4E00\u8F6E\u8BF7\u663E\u5F0F\u4F20 --regenerate-from ${target.earlierSeq}`;
|
|
4820
|
+
}
|
|
4772
4821
|
async function printConversationEvents(conversationId, args) {
|
|
4773
4822
|
const ctx = await getActiveAuthContextFromCli(args);
|
|
4774
4823
|
const client3 = HcmClient11.fromAuthContext(ctx);
|
|
@@ -4790,18 +4839,7 @@ async function printConversationEvents(conversationId, args) {
|
|
|
4790
4839
|
process.stdout.write("No timeline events.\n");
|
|
4791
4840
|
return;
|
|
4792
4841
|
}
|
|
4793
|
-
|
|
4794
|
-
const value = item;
|
|
4795
|
-
return {
|
|
4796
|
-
SEQ: value.seq ?? "-",
|
|
4797
|
-
KIND: oneLine(value.kind, 18),
|
|
4798
|
-
AGENT: eventAgent(value),
|
|
4799
|
-
SCOPE: eventScope(value),
|
|
4800
|
-
STATUS: eventStatus(value),
|
|
4801
|
-
EVENT: eventPreview(value)
|
|
4802
|
-
};
|
|
4803
|
-
});
|
|
4804
|
-
process.stdout.write(formatRows3(rows2, { format: "table" }) + "\n");
|
|
4842
|
+
process.stdout.write(formatRows3(buildEventRows(items), { format: "table" }) + "\n");
|
|
4805
4843
|
process.stdout.write(`Showing ${items.length} event${items.length === 1 ? "" : "s"}.
|
|
4806
4844
|
`);
|
|
4807
4845
|
process.stdout.write(`raw: hcm chat --events ${conversationId} --raw
|
|
@@ -4914,14 +4952,14 @@ async function chatCommand(prompt, args) {
|
|
|
4914
4952
|
}
|
|
4915
4953
|
if (regenerateFromLastAssistant) {
|
|
4916
4954
|
const items = await fetchConversationTimeline2(client3.raw(), resumeConversationId);
|
|
4917
|
-
const
|
|
4918
|
-
if (
|
|
4955
|
+
const target = findLastAssistantTarget(items);
|
|
4956
|
+
if (target.seq == null) {
|
|
4919
4957
|
throw new CliError16({
|
|
4920
4958
|
code: CliErrorCode15.BUSINESS_RULE_VIOLATION,
|
|
4921
|
-
message: `--regenerate-from last-assistant \u627E\u4E0D\u5230\u53EF\u91CD\u8DD1\u7684 chat-text seq: conversation=${resumeConversationId}`
|
|
4959
|
+
message: `--regenerate-from last-assistant \u627E\u4E0D\u5230\u53EF\u91CD\u8DD1\u7684 chat-text seq: conversation=${resumeConversationId}\uFF08${lastAssistantMissDetail(target)}\uFF09`
|
|
4922
4960
|
});
|
|
4923
4961
|
}
|
|
4924
|
-
regenerateFromSeq =
|
|
4962
|
+
regenerateFromSeq = target.seq;
|
|
4925
4963
|
}
|
|
4926
4964
|
const ws = new WsClient2({
|
|
4927
4965
|
endpoint: wsUrl,
|
|
@@ -5474,9 +5512,9 @@ function printLlmTraceTree(nodes) {
|
|
|
5474
5512
|
const root = nodes[0];
|
|
5475
5513
|
const childCount = nodes.length - 1;
|
|
5476
5514
|
if (!root.rows.length && childCount === 0) {
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5515
|
+
for (const line of describeLlmTraceEmpty(root.convId, root.envelope)) {
|
|
5516
|
+
process.stdout.write(line + "\n");
|
|
5517
|
+
}
|
|
5480
5518
|
return;
|
|
5481
5519
|
}
|
|
5482
5520
|
for (const node of nodes) {
|
|
@@ -5499,14 +5537,80 @@ ${" ".repeat(node.depth)}\u2514\u2500 \u59D4\u6D3E \u2192 ${node.label} \xB7 ${
|
|
|
5499
5537
|
if (table.length) {
|
|
5500
5538
|
process.stdout.write(formatRows4(table, { format: "table" }) + "\n");
|
|
5501
5539
|
} else {
|
|
5502
|
-
|
|
5540
|
+
const why = envelopeReason(node.envelope);
|
|
5541
|
+
process.stdout.write(`\uFF08\u65E0 LLM \u8C03\u7528${why ? ` \xB7 ${short(why, 60)}` : ""}\uFF09
|
|
5542
|
+
`);
|
|
5503
5543
|
}
|
|
5504
5544
|
}
|
|
5505
5545
|
process.stdout.write("\nnext: hcm trace --conv <convId> --raw\uFF08\u770B\u5B8C\u6574\u9010\u8C03\u7528 JSON\uFF09\n");
|
|
5506
5546
|
}
|
|
5547
|
+
function normalizeLlmTraceBody(body) {
|
|
5548
|
+
if (Array.isArray(body)) return { rows: body };
|
|
5549
|
+
if (body === null || body === void 0 || body === "") return { rows: [] };
|
|
5550
|
+
if (body && typeof body === "object") {
|
|
5551
|
+
const obj = body;
|
|
5552
|
+
if (Array.isArray(obj.rows)) {
|
|
5553
|
+
return { rows: obj.rows, envelope: obj };
|
|
5554
|
+
}
|
|
5555
|
+
}
|
|
5556
|
+
throw new Error("llm-trace \u54CD\u5E94\u65E2\u4E0D\u662F\u6570\u7EC4\u4E5F\u4E0D\u662F\u542B rows \u7684\u4FE1\u5C01\uFF0C\u65E0\u6CD5\u5224\u5B9A\u884C\u6570");
|
|
5557
|
+
}
|
|
5558
|
+
function asRecord2(value) {
|
|
5559
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
5560
|
+
}
|
|
5561
|
+
function asText(value) {
|
|
5562
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
5563
|
+
}
|
|
5564
|
+
function envelopeReason(envelope) {
|
|
5565
|
+
return envelope ? asText(envelope.reason) : void 0;
|
|
5566
|
+
}
|
|
5567
|
+
function unfold(text) {
|
|
5568
|
+
return text.replace(/\s+/g, " ").trim();
|
|
5569
|
+
}
|
|
5570
|
+
var WRITER_LOSS_KEYS = ["failed", "discardedNoTenant", "discardedQueueFull"];
|
|
5571
|
+
function writerCountsLine(envelope) {
|
|
5572
|
+
const writer = asRecord2(asRecord2(envelope.capture)?.writer);
|
|
5573
|
+
if (!writer) return void 0;
|
|
5574
|
+
const parts = Object.entries(writer).filter(([, v]) => typeof v === "number" || typeof v === "string").map(([k, v]) => `${k}=${v}`);
|
|
5575
|
+
if (!parts.length) return void 0;
|
|
5576
|
+
const lossy = WRITER_LOSS_KEYS.some((k) => typeof writer[k] === "number" && writer[k] > 0);
|
|
5577
|
+
if (!lossy && asText(envelope.code) !== "CAPTURE_MISSING_DESPITE_JOURNAL") return void 0;
|
|
5578
|
+
return `writer: ${parts.join(" ")}`;
|
|
5579
|
+
}
|
|
5580
|
+
function describeLlmTraceEmpty(convId, envelope) {
|
|
5581
|
+
const lines = [`No LLM calls for conversation ${convId}.`];
|
|
5582
|
+
if (!envelope) {
|
|
5583
|
+
lines.push("\u540E\u7AEF\u672A\u8FD4\u56DE\u81EA\u9648\uFF0C\u539F\u56E0\u65E0\u6CD5\u5224\u5B9A\u3002");
|
|
5584
|
+
lines.push(
|
|
5585
|
+
"next: \u5148\u6838\u5BF9 convId \u4E0E\u5F53\u524D\u767B\u5F55\u79DF\u6237/\u8EAB\u4EFD\uFF08--env/--as\uFF09\uFF1B\u82E5\u786E\u8BA4\u65E0\u8BEF\uFF0C\u5347\u7EA7\u540E\u7AEF\u81F3\u542B #2539 \u7684\u7248\u672C\u53EF\u62FF\u5230\u670D\u52A1\u7AEF\u81EA\u9648\u3002"
|
|
5586
|
+
);
|
|
5587
|
+
return lines;
|
|
5588
|
+
}
|
|
5589
|
+
const facts = [];
|
|
5590
|
+
const code = asText(envelope.code);
|
|
5591
|
+
const reason = envelopeReason(envelope);
|
|
5592
|
+
const nextStep = asText(envelope.nextStep);
|
|
5593
|
+
const tenantId = asText(asRecord2(envelope.scope)?.tenantId);
|
|
5594
|
+
const visible = asRecord2(envelope.conversation)?.visible;
|
|
5595
|
+
const retention = asText(asRecord2(envelope.capture)?.retention);
|
|
5596
|
+
const writerLine = writerCountsLine(envelope);
|
|
5597
|
+
if (code) lines.push(`code: ${code}`);
|
|
5598
|
+
if (reason) lines.push(`reason: ${unfold(reason)}`);
|
|
5599
|
+
if (tenantId) facts.push(`tenant ${tenantId}`);
|
|
5600
|
+
if (typeof visible === "boolean") facts.push(`conversation: ${visible ? "visible" : "not visible"}`);
|
|
5601
|
+
if (retention) facts.push(`retention ${retention}`);
|
|
5602
|
+
if (facts.length) lines.push(facts.join(" \xB7 "));
|
|
5603
|
+
if (writerLine) lines.push(writerLine);
|
|
5604
|
+
if (nextStep) lines.push(`next: ${unfold(nextStep)}`);
|
|
5605
|
+
if (lines.length === 1) lines.push("\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u4FE1\u5C01\u4F46\u6CA1\u7ED9\u539F\u56E0\uFF0C\u539F\u56E0\u65E0\u6CD5\u5224\u5B9A\u3002");
|
|
5606
|
+
return lines;
|
|
5607
|
+
}
|
|
5507
5608
|
async function fetchLlmTrace(http, convId) {
|
|
5508
|
-
const resp = await http.get(
|
|
5509
|
-
|
|
5609
|
+
const resp = await http.get(
|
|
5610
|
+
`/api/moirai/conversations/${encodeURIComponent(convId)}/llm-trace`,
|
|
5611
|
+
{ params: { envelope: "true" } }
|
|
5612
|
+
);
|
|
5613
|
+
return normalizeLlmTraceBody(resp.data);
|
|
5510
5614
|
}
|
|
5511
5615
|
function extractChildConvs(items) {
|
|
5512
5616
|
const out = [];
|
|
@@ -5546,7 +5650,8 @@ async function gatherLlmTraceTree(http, rootConvId, maxDepth = 3) {
|
|
|
5546
5650
|
async function walk(convId, depth, label) {
|
|
5547
5651
|
if (visited.has(convId) || depth > maxDepth) return;
|
|
5548
5652
|
visited.add(convId);
|
|
5549
|
-
|
|
5653
|
+
const body = await fetchLlmTrace(http, convId);
|
|
5654
|
+
nodes.push({ convId, depth, label, rows: body.rows, envelope: body.envelope });
|
|
5550
5655
|
if (depth === maxDepth) return;
|
|
5551
5656
|
for (const c of await fetchChildConvs(http, convId)) {
|
|
5552
5657
|
await walk(c.childConvId, depth + 1, c.label);
|
|
@@ -5562,9 +5667,14 @@ async function traceCommand(traceId, args) {
|
|
|
5562
5667
|
const convId = args.conv ?? (args.llmCalls ? traceId ?? void 0 : void 0);
|
|
5563
5668
|
if (convId) {
|
|
5564
5669
|
if (args.raw || args.output === "json" || args.output === "yaml") {
|
|
5565
|
-
const
|
|
5670
|
+
const body = await fetchLlmTrace(http, convId);
|
|
5566
5671
|
const fmt = args.raw ? "json" : args.output;
|
|
5567
|
-
process.stdout.write(formatObject10(
|
|
5672
|
+
process.stdout.write(formatObject10(body.rows, { format: fmt }) + "\n");
|
|
5673
|
+
if (!body.rows.length) {
|
|
5674
|
+
for (const line of describeLlmTraceEmpty(convId, body.envelope)) {
|
|
5675
|
+
process.stderr.write(line + "\n");
|
|
5676
|
+
}
|
|
5677
|
+
}
|
|
5568
5678
|
process.exitCode = 0;
|
|
5569
5679
|
return;
|
|
5570
5680
|
}
|
|
@@ -6117,7 +6227,7 @@ function classifyInstalledSource(id, record, catalog) {
|
|
|
6117
6227
|
return kind === "cli" ? "removed-in-cli" : "removed-upstream";
|
|
6118
6228
|
}
|
|
6119
6229
|
var SOURCE_STATUS_NOTE = {
|
|
6120
|
-
"removed-upstream": "\u4EA7\u54C1\u8FD9\u4E00\u7248\u7684\u6280\u80FD\u76EE\u5F55\u91CC\u5DF2\u7ECF\u6CA1\u6709\u5B83\u4E86
|
|
6230
|
+
"removed-upstream": "\u4EA7\u54C1\u8FD9\u4E00\u7248\u7684\u6280\u80FD\u76EE\u5F55\u91CC\u5DF2\u7ECF\u6CA1\u6709\u5B83\u4E86",
|
|
6121
6231
|
"removed-in-cli": "\u8FD9\u4E00\u7248 CLI \u4E0D\u518D\u81EA\u5E26\u5B83\uFF08\u591A\u534A\u662F\u88AB\u4EA7\u54C1\u6536\u7F16\u4E86\uFF0C\u8DD1 hcm skills list \u770B\u770B\uFF09",
|
|
6122
6232
|
"not-checked": "\u672C\u8F6E\u6CA1\u8FDE\u7F51\u6838\u5BF9\u5B83\u7684\u6765\u6E90\uFF08--source cli\uFF09\uFF0C\u5B83\u662F\u4E0D\u662F\u8FD8\u5728\u4EA7\u54C1\u76EE\u5F55\u91CC\u8FD9\u4E00\u8D9F\u4E0D\u77E5\u9053",
|
|
6123
6233
|
local: "\u672C\u5730\u6765\u6E90\uFF08install --from \u88C5\u7684\uFF09\uFF0Cupdate \u4E0D\u7BA1\u5B83\uFF1B\u8981\u66F4\u65B0\u5C31\u518D install --from \u4E00\u6B21"
|
|
@@ -7485,6 +7595,89 @@ async function readLocalSkills(localDir) {
|
|
|
7485
7595
|
}
|
|
7486
7596
|
return out;
|
|
7487
7597
|
}
|
|
7598
|
+
async function resolveSkillPath(layout, id) {
|
|
7599
|
+
assertSafeSkillId(id);
|
|
7600
|
+
const at = async (dir) => {
|
|
7601
|
+
const file = path8.join(dir, id, "SKILL.md");
|
|
7602
|
+
return await fsp2.stat(file).then(() => file).catch(() => void 0);
|
|
7603
|
+
};
|
|
7604
|
+
const inSync = await at(layout.baseDir);
|
|
7605
|
+
const inLocal = layout.localDir ? await at(layout.localDir) : void 0;
|
|
7606
|
+
if (inLocal) {
|
|
7607
|
+
return {
|
|
7608
|
+
id,
|
|
7609
|
+
file: inLocal,
|
|
7610
|
+
half: "local",
|
|
7611
|
+
references: path8.join(layout.localDir, id, "references"),
|
|
7612
|
+
...inSync ? { shadowed: inSync } : {}
|
|
7613
|
+
};
|
|
7614
|
+
}
|
|
7615
|
+
if (inSync) {
|
|
7616
|
+
return { id, file: inSync, half: "sync", references: path8.join(layout.baseDir, id, "references") };
|
|
7617
|
+
}
|
|
7618
|
+
const looked = [
|
|
7619
|
+
...layout.localDir ? [`${layout.localDir}/${id}/SKILL.md`] : [],
|
|
7620
|
+
`${layout.baseDir}/${id}/SKILL.md`
|
|
7621
|
+
];
|
|
7622
|
+
throw new CliError20({
|
|
7623
|
+
code: CliErrorCode19.INVALID_ARGUMENT,
|
|
7624
|
+
message: `\u8FD9\u4E2A\u9879\u76EE\u91CC\u6CA1\u6709\u6280\u80FD ${id}\u3002\u627E\u8FC7\uFF1A
|
|
7625
|
+
${looked.join("\n ")}
|
|
7626
|
+
\u770B\u6709\u54EA\u4E9B\uFF1Ahcm skills list --installed\uFF1B\u6CA1\u88C5\u5C31\u5148 hcm chiron skills sync\u3002`
|
|
7627
|
+
});
|
|
7628
|
+
}
|
|
7629
|
+
async function skillsPathCommand(id, args) {
|
|
7630
|
+
try {
|
|
7631
|
+
const layout = await resolveInstallLayout(args);
|
|
7632
|
+
const resolved = await resolveSkillPath(layout, id);
|
|
7633
|
+
const fmt = args.output ?? "table";
|
|
7634
|
+
if (fmt === "json" || fmt === "yaml") {
|
|
7635
|
+
process.stdout.write(formatObject17(resolved, { format: fmt }) + "\n");
|
|
7636
|
+
process.exitCode = 0;
|
|
7637
|
+
return;
|
|
7638
|
+
}
|
|
7639
|
+
process.stderr.write(
|
|
7640
|
+
resolved.half === "local" ? `\u2192 ${SKILLS_LOCAL_SUBDIR}/ \u90A3\u4E00\u534A\uFF08\u4F60\u6539\u8FC7\u7684\u7248\u672C\uFF09` + (resolved.shadowed ? `\uFF0C\u5B83\u906E\u4F4F\u4E86 ${resolved.shadowed}
|
|
7641
|
+
` : "\n") : `\u2192 ${SKILLS_SYNC_SUBDIR}/ \u90A3\u4E00\u534A\uFF08\u4EA7\u54C1\u7EF4\u62A4\uFF0C\u540C\u6B65\u4F1A\u66F4\u65B0\u5B83\uFF09
|
|
7642
|
+
`
|
|
7643
|
+
);
|
|
7644
|
+
process.stdout.write(`${args.refs ? resolved.references : resolved.file}
|
|
7645
|
+
`);
|
|
7646
|
+
process.exitCode = 0;
|
|
7647
|
+
} catch (e) {
|
|
7648
|
+
fail6(e, args);
|
|
7649
|
+
}
|
|
7650
|
+
}
|
|
7651
|
+
async function findShadowBypassingRefs(layout, shadowedIds) {
|
|
7652
|
+
if (shadowedIds.size === 0) return [];
|
|
7653
|
+
const hits = [];
|
|
7654
|
+
let ids;
|
|
7655
|
+
try {
|
|
7656
|
+
ids = (await fsp2.readdir(layout.baseDir, { withFileTypes: true })).filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => e.name);
|
|
7657
|
+
} catch {
|
|
7658
|
+
return [];
|
|
7659
|
+
}
|
|
7660
|
+
for (const from of ids.sort()) {
|
|
7661
|
+
const files = [path8.join(layout.baseDir, from, "SKILL.md")];
|
|
7662
|
+
const refDir = path8.join(layout.baseDir, from, "references");
|
|
7663
|
+
try {
|
|
7664
|
+
for (const e of await fsp2.readdir(refDir, { withFileTypes: true })) {
|
|
7665
|
+
if (e.isFile()) files.push(path8.join(refDir, e.name));
|
|
7666
|
+
}
|
|
7667
|
+
} catch {
|
|
7668
|
+
}
|
|
7669
|
+
for (const file of files) {
|
|
7670
|
+
const text = await fsp2.readFile(file, "utf8").catch(() => void 0);
|
|
7671
|
+
if (text === void 0) continue;
|
|
7672
|
+
for (const to of shadowedIds) {
|
|
7673
|
+
if (new RegExp(`\\.\\./(?:\\.\\./)*${to.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/`).test(text)) {
|
|
7674
|
+
hits.push({ from, to, file });
|
|
7675
|
+
}
|
|
7676
|
+
}
|
|
7677
|
+
}
|
|
7678
|
+
}
|
|
7679
|
+
return hits;
|
|
7680
|
+
}
|
|
7488
7681
|
async function syncAgentIndexes(layout, manifest2) {
|
|
7489
7682
|
if (!layout.agentsFile) return [];
|
|
7490
7683
|
const state = await readSkillsState(layout.baseDir);
|
|
@@ -7761,27 +7954,34 @@ async function planStaleReferences(state, documents, baseDir) {
|
|
|
7761
7954
|
const byKey = (a, b) => `${a.id}/${a.path}`.localeCompare(`${b.id}/${b.path}`);
|
|
7762
7955
|
return { remove: remove.sort(byKey), keptLocallyModified: keptLocallyModified.sort(byKey) };
|
|
7763
7956
|
}
|
|
7764
|
-
async function
|
|
7765
|
-
if (
|
|
7957
|
+
async function removeSkillDirs(baseDir, ids) {
|
|
7958
|
+
if (ids.length === 0) return [];
|
|
7766
7959
|
const kept = [];
|
|
7767
7960
|
const state = await readSkillsState(baseDir);
|
|
7768
|
-
for (const
|
|
7769
|
-
assertSafeSkillId(
|
|
7770
|
-
const dir = path8.join(baseDir,
|
|
7961
|
+
for (const id of ids) {
|
|
7962
|
+
assertSafeSkillId(id);
|
|
7963
|
+
const dir = path8.join(baseDir, id);
|
|
7771
7964
|
const resolved = path8.resolve(dir);
|
|
7772
|
-
if (resolved !== path8.join(path8.resolve(baseDir),
|
|
7965
|
+
if (resolved !== path8.join(path8.resolve(baseDir), id)) continue;
|
|
7773
7966
|
const hasSkillFile = await fsp2.stat(path8.join(dir, "SKILL.md")).then(() => true).catch(() => false);
|
|
7774
7967
|
const exists2 = await fsp2.stat(dir).then(() => true).catch(() => false);
|
|
7775
7968
|
if (exists2 && !hasSkillFile) {
|
|
7776
|
-
kept.push({
|
|
7777
|
-
|
|
7778
|
-
await fsp2.rm(dir, { recursive: true, force: true });
|
|
7969
|
+
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" });
|
|
7970
|
+
continue;
|
|
7779
7971
|
}
|
|
7780
|
-
if (
|
|
7972
|
+
if (exists2) await fsp2.rm(dir, { recursive: true, force: true });
|
|
7973
|
+
if (state?.skills[id] !== void 0) delete state.skills[id];
|
|
7781
7974
|
}
|
|
7782
7975
|
if (state) await writeSkillsState(baseDir, state);
|
|
7783
7976
|
return kept;
|
|
7784
7977
|
}
|
|
7978
|
+
async function removeRenamedSkills(baseDir, renamed) {
|
|
7979
|
+
const kept = await removeSkillDirs(baseDir, renamed.map((r) => r.from));
|
|
7980
|
+
return kept.map((k) => ({ from: k.id, kept: k.kept }));
|
|
7981
|
+
}
|
|
7982
|
+
async function removeOrphanSkills(baseDir, ids) {
|
|
7983
|
+
return await removeSkillDirs(baseDir, ids);
|
|
7984
|
+
}
|
|
7785
7985
|
async function writeSkillDocuments(documents, baseDir, removals = []) {
|
|
7786
7986
|
const staged = [];
|
|
7787
7987
|
const removed = [];
|
|
@@ -7848,9 +8048,69 @@ async function recordInstalled(baseDir, documents, meta2) {
|
|
|
7848
8048
|
await writeSkillsState(baseDir, state);
|
|
7849
8049
|
return state;
|
|
7850
8050
|
}
|
|
8051
|
+
function parsePruneMax(raw) {
|
|
8052
|
+
if (raw === void 0) return void 0;
|
|
8053
|
+
const text = typeof raw === "number" ? void 0 : raw.trim();
|
|
8054
|
+
const n = text === void 0 ? raw : text === "" ? Number.NaN : Number(text);
|
|
8055
|
+
if (!Number.isInteger(n) || n < 0) {
|
|
8056
|
+
throw new CliError20({
|
|
8057
|
+
code: CliErrorCode19.INVALID_ARGUMENT,
|
|
8058
|
+
message: `--prune-max \u8981\u4E00\u4E2A\u975E\u8D1F\u6574\u6570\uFF0C\u6536\u5230 ${JSON.stringify(raw)}\u30020 = \u8FD9\u4E00\u8D9F\u4E00\u4EFD\u90FD\u522B\u6E05\uFF1B\u4E0D\u7ED9\u8FD9\u4E2A\u53C2\u6570\u65F6\u4E0A\u9650\u662F\u300C${PRUNE_DEFAULT_MAX} \u4E0E\u5728\u518C\u4EFD\u6570\u4E00\u534A\u53D6\u5C0F\u300D\u3002`
|
|
8059
|
+
});
|
|
8060
|
+
}
|
|
8061
|
+
return n;
|
|
8062
|
+
}
|
|
7851
8063
|
function invalid(message) {
|
|
7852
8064
|
return new CliError20({ code: CliErrorCode19.INVALID_ARGUMENT, message });
|
|
7853
8065
|
}
|
|
8066
|
+
var PRUNE_DEFAULT_MAX = 5;
|
|
8067
|
+
var PRUNE_MAX_SHARE = 0.5;
|
|
8068
|
+
function orphanPruneLimit(trackedCount, explicitMax) {
|
|
8069
|
+
if (explicitMax !== void 0) return explicitMax;
|
|
8070
|
+
return Math.min(PRUNE_DEFAULT_MAX, Math.floor(trackedCount * PRUNE_MAX_SHARE));
|
|
8071
|
+
}
|
|
8072
|
+
var PRUNABLE_STATUS = /* @__PURE__ */ new Set(["removed-upstream", "removed-in-cli"]);
|
|
8073
|
+
async function planOrphanPrune(options) {
|
|
8074
|
+
const { entries, state, baseDir, liveMarkdown, trackedCount, max } = options;
|
|
8075
|
+
const remove = [];
|
|
8076
|
+
const kept = [];
|
|
8077
|
+
for (const entry of entries) {
|
|
8078
|
+
if (!PRUNABLE_STATUS.has(entry.status)) continue;
|
|
8079
|
+
const id = entry.id;
|
|
8080
|
+
const record = state.skills[id];
|
|
8081
|
+
const onDisk = await readInstalled(baseDir, id);
|
|
8082
|
+
if (onDisk !== void 0 && record !== void 0) {
|
|
8083
|
+
let edited = sha2562(onDisk) !== record.sha256;
|
|
8084
|
+
for (const [refPath, recordedSha] of Object.entries(record.references ?? {})) {
|
|
8085
|
+
const installed = await readInstalledReference(baseDir, id, refPath);
|
|
8086
|
+
if (installed !== void 0 && sha2562(installed) !== recordedSha) edited = true;
|
|
8087
|
+
}
|
|
8088
|
+
if (edited) {
|
|
8089
|
+
kept.push({
|
|
8090
|
+
id,
|
|
8091
|
+
why: `\u672C\u5730\u6539\u8FC7\uFF0C\u6CA1\u6709\u5220\u3002\u4E0A\u6E38\u5DF2\u7ECF\u4E0D\u53D1\u5B83\u4E86\u2014\u2014\u76D8\u4E0A\u8FD9\u4EFD\u5C31\u662F\u552F\u4E00\u4E00\u4EFD\uFF0C\u60F3\u957F\u671F\u7559\u4F4F\u5C31\u632A\u5230 ${SKILLS_LOCAL_SUBDIR}/${id}/\uFF08\u90A3\u4E00\u4FA7 CLI \u4ECE\u4E0D\u5199\uFF09`
|
|
8092
|
+
});
|
|
8093
|
+
continue;
|
|
8094
|
+
}
|
|
8095
|
+
}
|
|
8096
|
+
const referrers = [...liveMarkdown].filter(([otherId, markdown]) => otherId !== id && /* 相对引用与同级链接两种形态 */
|
|
8097
|
+
(markdown.includes(`../${id}/`) || markdown.includes(`](${id}/`))).map(([otherId]) => otherId);
|
|
8098
|
+
if (referrers.length > 0) {
|
|
8099
|
+
kept.push({
|
|
8100
|
+
id,
|
|
8101
|
+
why: `\u8FD8\u6709 ${referrers.length} \u4EFD\u6D3B\u7740\u7684\u6280\u80FD\u5728\u5F15\u7528\u5B83\uFF08${referrers.join("\u3001")}\uFF09\uFF0C\u5220\u4E86\u5C31\u662F\u628A\u94FE\u63A5\u6307\u5411\u7A7A\u6C14`
|
|
8102
|
+
});
|
|
8103
|
+
continue;
|
|
8104
|
+
}
|
|
8105
|
+
remove.push({ id, status: entry.status });
|
|
8106
|
+
}
|
|
8107
|
+
const limit = orphanPruneLimit(trackedCount, max);
|
|
8108
|
+
if (remove.length > limit) {
|
|
8109
|
+
const why = max !== void 0 ? `\u4E00\u8D9F\u8981\u6E05 ${remove.length} \u4EFD\uFF0C\u8D85\u8FC7\u4F60\u7ED9\u7684\u4E0A\u9650 ${limit} \u4EFD` : limit < PRUNE_DEFAULT_MAX ? `\u4E00\u8D9F\u8981\u6E05 ${remove.length} \u4EFD\uFF0C\u8D85\u8FC7\u5728\u518C ${trackedCount} \u4EFD\u7684\u4E00\u534A\uFF08\u4E0A\u9650 ${limit} \u4EFD\uFF09` : `\u4E00\u8D9F\u8981\u6E05 ${remove.length} \u4EFD\uFF0C\u8D85\u8FC7\u4E0A\u9650 ${limit} \u4EFD`;
|
|
8110
|
+
return { remove: [], kept, refused: { count: remove.length, limit, why } };
|
|
8111
|
+
}
|
|
8112
|
+
return { remove, kept };
|
|
8113
|
+
}
|
|
7854
8114
|
async function readInstalled(baseDir, id) {
|
|
7855
8115
|
try {
|
|
7856
8116
|
return await fsp2.readFile(path8.join(baseDir, id, "SKILL.md"), "utf8");
|
|
@@ -7995,7 +8255,21 @@ async function planSkillUpdate(options) {
|
|
|
7995
8255
|
});
|
|
7996
8256
|
}
|
|
7997
8257
|
entries.sort((a, b) => a.id.localeCompare(b.id));
|
|
7998
|
-
|
|
8258
|
+
const liveMarkdown = /* @__PURE__ */ new Map();
|
|
8259
|
+
for (const id of closure.keys()) {
|
|
8260
|
+
const pending = documents.find((d) => d.id === id);
|
|
8261
|
+
const markdown = pending?.markdown ?? await readInstalled(baseDir, id);
|
|
8262
|
+
if (markdown !== void 0) liveMarkdown.set(id, markdown);
|
|
8263
|
+
}
|
|
8264
|
+
const prune = await planOrphanPrune({
|
|
8265
|
+
entries,
|
|
8266
|
+
state,
|
|
8267
|
+
baseDir,
|
|
8268
|
+
liveMarkdown,
|
|
8269
|
+
trackedCount: Object.keys(state.skills).length,
|
|
8270
|
+
max: options.pruneMax
|
|
8271
|
+
});
|
|
8272
|
+
return { entries, documents, renamed: renamedPairs, prune };
|
|
7999
8273
|
}
|
|
8000
8274
|
var UPDATE_STATUS_LABEL = {
|
|
8001
8275
|
updated: "\u5DF2\u66F4\u65B0",
|
|
@@ -8048,6 +8322,7 @@ async function skillsUpdateCommand(args) {
|
|
|
8048
8322
|
baseDir: layout.baseDir,
|
|
8049
8323
|
force: Boolean(args.force),
|
|
8050
8324
|
all,
|
|
8325
|
+
pruneMax: parsePruneMax(args.pruneMax),
|
|
8051
8326
|
fetchDocument: (skill) => fetchSkillDocument(http, skill, endpoint, base)
|
|
8052
8327
|
});
|
|
8053
8328
|
const stale = await planStaleReferences(state, plan.documents, layout.baseDir);
|
|
@@ -8066,6 +8341,7 @@ async function skillsUpdateCommand(args) {
|
|
|
8066
8341
|
`);
|
|
8067
8342
|
}
|
|
8068
8343
|
}
|
|
8344
|
+
const pruneKept = !args.check && plan.prune.remove.length > 0 ? await removeOrphanSkills(layout.baseDir, plan.prune.remove.map((r) => r.id)) : [];
|
|
8069
8345
|
const agentIndexes = !args.check && layout.agentsFile ? await syncAgentIndexes(layout, manifest2) : [];
|
|
8070
8346
|
const changed = plan.entries.filter((e) => e.status === "updated" || e.status === "added");
|
|
8071
8347
|
const fmt = args.output ?? "table";
|
|
@@ -8083,6 +8359,11 @@ async function skillsUpdateCommand(args) {
|
|
|
8083
8359
|
},
|
|
8084
8360
|
cliVersion: CLI_VERSION,
|
|
8085
8361
|
staleReferences: stale,
|
|
8362
|
+
prune: {
|
|
8363
|
+
removed: plan.prune.remove.map((r) => r.id),
|
|
8364
|
+
kept: plan.prune.kept,
|
|
8365
|
+
refused: plan.prune.refused
|
|
8366
|
+
},
|
|
8086
8367
|
entries: plan.entries
|
|
8087
8368
|
}, { format: fmt }) + "\n");
|
|
8088
8369
|
process.exitCode = 0;
|
|
@@ -8105,8 +8386,10 @@ async function skillsUpdateCommand(args) {
|
|
|
8105
8386
|
const notChecked = plan.entries.filter((e) => e.status === "not-checked").length;
|
|
8106
8387
|
const tail = [
|
|
8107
8388
|
skipped > 0 ? `${skipped} \u4E2A\u672C\u5730\u6539\u8FC7\u88AB\u8DF3\u8FC7\uFF08--force \u8986\u76D6\uFF09` : "",
|
|
8108
|
-
removed > 0 ? `${removed} \u4E2A\u4EA7\u54C1\u5DF2\u79FB\u9664
|
|
8109
|
-
removedInCli > 0 ? `${removedInCli} \u4E2A\u8FD9\u4E00\u7248 CLI \u4E0D\u518D\u81EA\u5E26
|
|
8389
|
+
removed > 0 ? `${removed} \u4E2A\u4EA7\u54C1\u5DF2\u79FB\u9664` : "",
|
|
8390
|
+
removedInCli > 0 ? `${removedInCli} \u4E2A\u8FD9\u4E00\u7248 CLI \u4E0D\u518D\u81EA\u5E26` : "",
|
|
8391
|
+
plan.prune.remove.length > 0 ? `\u5176\u4E2D ${plan.prune.remove.length} \u4EFD${args.check ? "\u4F1A\u88AB" : "\u5DF2"}\u6E05\u6389` : "",
|
|
8392
|
+
plan.prune.kept.length + pruneKept.length > 0 ? `${plan.prune.kept.length + pruneKept.length} \u4EFD\u6CA1\u6E05\uFF08\u4E0A\u9762\u9010\u4E2A\u8BF4\u4E86\u4E3A\u4EC0\u4E48\uFF09` : "",
|
|
8110
8393
|
notChecked > 0 ? `${notChecked} \u4E2A\u672C\u8F6E\u672A\u6838\uFF08\u90A3\u4E00\u534A\u8FD9\u8D9F\u6CA1\u770B\uFF09` : ""
|
|
8111
8394
|
].filter(Boolean).join("\uFF0C");
|
|
8112
8395
|
const cliCount = plan.entries.filter(
|
|
@@ -8130,13 +8413,47 @@ async function skillsUpdateCommand(args) {
|
|
|
8130
8413
|
`
|
|
8131
8414
|
);
|
|
8132
8415
|
}
|
|
8416
|
+
if (plan.prune.remove.length > 0) {
|
|
8417
|
+
process.stdout.write(
|
|
8418
|
+
` ${args.check ? "\u4F1A\u6E05\u6389" : "\u5DF2\u6E05\u6389"} ${plan.prune.remove.length} \u4EFD\u4E0A\u6E38\u4E0D\u518D\u53D1\u7684\u6280\u80FD\uFF08${plan.prune.remove.map((r) => r.id).join("\u3001")}\uFF09
|
|
8419
|
+
`
|
|
8420
|
+
);
|
|
8421
|
+
}
|
|
8422
|
+
for (const k of plan.prune.kept) {
|
|
8423
|
+
process.stdout.write(` ! ${k.id} \u6CA1\u6E05\uFF1A${k.why}
|
|
8424
|
+
`);
|
|
8425
|
+
}
|
|
8426
|
+
for (const k of pruneKept) {
|
|
8427
|
+
process.stdout.write(` ! ${k.id} \u6CA1\u6E05\uFF1A${k.kept}
|
|
8428
|
+
`);
|
|
8429
|
+
}
|
|
8430
|
+
if (plan.prune.refused) {
|
|
8431
|
+
process.stdout.write(
|
|
8432
|
+
` \u26A0\uFE0F \u5B64\u513F\u6E05\u7406\u6574\u6279\u62D2\u7EDD\uFF1A${plan.prune.refused.why}\u3002\u8FD9\u4E0D\u50CF\u6280\u80FD\u9000\u5F79\uFF0C\u50CF\u76EE\u5F55\u53D6\u6B8B\u4E86\u2014\u2014
|
|
8433
|
+
\u5148\u8DD1 hcm skills list \u770B\u770B\u76EE\u5F55\u662F\u4E0D\u662F\u5168\u7684\uFF1B\u786E\u8BA4\u65E0\u8BEF\u518D\u8DD1 hcm chiron skills sync --prune-max ${plan.prune.refused.count}
|
|
8434
|
+
`
|
|
8435
|
+
);
|
|
8436
|
+
}
|
|
8437
|
+
{
|
|
8438
|
+
const shadowedIds = new Set(
|
|
8439
|
+
(await readLocalSkills(layout.localDir)).map((x) => x.id).filter((id) => state.skills[id] !== void 0)
|
|
8440
|
+
);
|
|
8441
|
+
const bypass = await findShadowBypassingRefs(layout, shadowedIds);
|
|
8442
|
+
for (const hit of bypass) {
|
|
8443
|
+
process.stdout.write(
|
|
8444
|
+
` \u26A0\uFE0F ${path8.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
|
|
8445
|
+
\u6B63\u6587\u6539\u6210\u6309 id \u53D6\u5740\u5C31\u4E0D\u4F1A\u518D\u9519\uFF1Ahcm chiron skills path ${hit.to}
|
|
8446
|
+
`
|
|
8447
|
+
);
|
|
8448
|
+
}
|
|
8449
|
+
}
|
|
8133
8450
|
if (stale.keptLocallyModified.length > 0) {
|
|
8134
8451
|
process.stdout.write(
|
|
8135
8452
|
` ${stale.keptLocallyModified.length} \u4E2A\u4EA7\u54C1\u5DF2\u64A4\u6389\u4F46\u672C\u5730\u6539\u8FC7\u7684\u53C2\u8003\u6587\u4EF6\u4FDD\u7559\u4E86\uFF08${stale.keptLocallyModified.map((r) => `${r.id}/references/${r.path}`).join("\u3001")}\uFF09
|
|
8136
8453
|
`
|
|
8137
8454
|
);
|
|
8138
8455
|
}
|
|
8139
|
-
if (changed.length === 0 && skipped === 0 && removed === 0) {
|
|
8456
|
+
if (changed.length === 0 && skipped === 0 && removed === 0 && removedInCli === 0 && plan.prune.remove.length === 0) {
|
|
8140
8457
|
process.stdout.write(args.check ? " \u5168\u90E8\u5DF2\u662F\u6700\u65B0\uFF08--check \u53EA\u770B\u4E0D\u52A8\uFF09\n" : " \u5168\u90E8\u5DF2\u662F\u6700\u65B0\uFF0C\u6CA1\u6709\u6539\u52A8\n");
|
|
8141
8458
|
} else {
|
|
8142
8459
|
const head = args.check ? changed.length > 0 ? `\u6709 ${changed.length} \u4E2A\u53EF\u4EE5\u66F4\u65B0\uFF0C\u53BB\u6389 --check \u5C31\u4F1A\u5199\u5165` : "\u6CA1\u6709\u53EF\u5199\u5165\u7684\u66F4\u65B0" : changed.length > 0 ? `\u5DF2\u66F4\u65B0 ${changed.length} \u4E2A` : "\u6CA1\u6709\u5199\u5165\u4EFB\u4F55\u6539\u52A8";
|
|
@@ -8877,7 +9194,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
|
|
|
8877
9194
|
workspaceKey: normalizedWorkspaceKey,
|
|
8878
9195
|
description: args.description ?? ""
|
|
8879
9196
|
});
|
|
8880
|
-
const created =
|
|
9197
|
+
const created = asRecord3(unwrapData(resp.data));
|
|
8881
9198
|
const id = stringOptional(created.id);
|
|
8882
9199
|
let activated = false;
|
|
8883
9200
|
if (args.activate) {
|
|
@@ -9878,7 +10195,7 @@ function stringRequired(value, field) {
|
|
|
9878
10195
|
function stringOptional(value) {
|
|
9879
10196
|
return typeof value === "string" && value.trim() ? value : void 0;
|
|
9880
10197
|
}
|
|
9881
|
-
function
|
|
10198
|
+
function asRecord3(value) {
|
|
9882
10199
|
return value && typeof value === "object" ? value : {};
|
|
9883
10200
|
}
|
|
9884
10201
|
function unwrapData(value) {
|
|
@@ -13584,7 +13901,8 @@ chiron.command("doctor").description(
|
|
|
13584
13901
|
"\u6838\u5BF9\uFF1A\u672C\u673A\u767B\u5F55\u662F\u5426\u5BF9\u7740 env.yaml \u7684\u73AF\u5883\uFF08\u542B\u56DB\u6761\u951A\u70B9\uFF09/ \u6280\u80FD\u88C5\u6CA1\u88C5 / \u6848\u4F8B\u5E93 clone \u4E86\u6CA1 / Jira \u80FD\u4E0D\u80FD\u63D0\u5355"
|
|
13585
13902
|
).option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u8986\u76D6\u8981\u6838\u7684\u73AF\u5883\u522B\u540D\uFF08\u9ED8\u8BA4\u53D6 env.yaml\uFF1B\u591A\u73AF\u5883\u9879\u76EE\u7528\u5B83\u6328\u4E2A\u63A2\uFF09").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\u63A2\u951A\u70B9").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => chironDoctorCommand(opts));
|
|
13586
13903
|
var chironSkills = chiron.command("skills").description("\u8FD9\u4E2A\u9879\u76EE\u4ED3\u7684\u6280\u80FD\uFF1A\u8DDF\u76EE\u6807\u73AF\u5883\u5BF9\u9F50");
|
|
13587
|
-
chironSkills.command("sync").description("\u8BA9\u8FD9\u4E2A\u4ED3\u7684\u6280\u80FD\u8DDF\u76EE\u6807\u73AF\u5883\u5BF9\u9F50\uFF1A\u7B2C\u4E00\u6B21\u5C31\u88C5\u9F50\uFF0C\u4E4B\u540E\u6309\u4EA7\u54C1\u5F53\u524D\u5168\u96C6\u5BF9\u8D26\u3002\u5E42\u7B49\uFF0C\u4EA7\u54C1\u5347\u7EA7\u540E\u8DD1\u5B83").option("--only <id...>", "\u53EA\u8981\u8FD9\u51E0\u4E2A\u6280\u80FD\uFF08\u8FDE\u540C requires \u524D\u7F6E\uFF09\uFF0C\u4E0D\u8BA2\u9605\u5168\u96C6\uFF1B\u8BAD\u7EC3\u573A blind \u6863\u7528").option("--check", "\u53EA\u770B\u4F1A\u53D8\u4EC0\u4E48\uFF0C\u4E0D\u5199\u76D8").option("--target <agent>", "claude\uFF08.claude/skills/\uFF09| codex\uFF08hcm-skills/ + Agent \u7D22\u5F15\uFF09| auto", "auto").option("--global", "\u540C\u6B65\u7528\u6237\u7EA7\u76EE\u5F55\u800C\u975E\u5F53\u524D\u9879\u76EE").option("--dir <path>", "\u540C\u6B65\u6307\u5B9A\u76EE\u5F55").option("--from <dir>", "\u4ECE\u672C\u5730\u76EE\u5F55\u53D6\uFF08\u73B0\u573A\u6539\u8FC7\u7684\u7248\u672C\uFF09\uFF0C\u4E0D\u8D70\u7F51\u7EDC").option("--force", "\u8FDE\u672C\u5730\u6539\u8FC7\u7684\u6280\u80FD\u4E00\u8D77\u8986\u76D6\u6210\u4EA7\u54C1\u8FD9\u4E00\u7248").option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u9879\u76EE\u73AF\u5883\u6216\u5B89\u88C5\u65F6\u8BB0\u5F55\u7684\u5730\u5740\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => skillsSyncCommand(opts));
|
|
13904
|
+
chironSkills.command("sync").description("\u8BA9\u8FD9\u4E2A\u4ED3\u7684\u6280\u80FD\u8DDF\u76EE\u6807\u73AF\u5883\u5BF9\u9F50\uFF1A\u7B2C\u4E00\u6B21\u5C31\u88C5\u9F50\uFF0C\u4E4B\u540E\u6309\u4EA7\u54C1\u5F53\u524D\u5168\u96C6\u5BF9\u8D26\u3002\u5E42\u7B49\uFF0C\u4EA7\u54C1\u5347\u7EA7\u540E\u8DD1\u5B83").option("--only <id...>", "\u53EA\u8981\u8FD9\u51E0\u4E2A\u6280\u80FD\uFF08\u8FDE\u540C requires \u524D\u7F6E\uFF09\uFF0C\u4E0D\u8BA2\u9605\u5168\u96C6\uFF1B\u8BAD\u7EC3\u573A blind \u6863\u7528").option("--check", "\u53EA\u770B\u4F1A\u53D8\u4EC0\u4E48\uFF0C\u4E0D\u5199\u76D8").option("--target <agent>", "claude\uFF08.claude/skills/\uFF09| codex\uFF08hcm-skills/ + Agent \u7D22\u5F15\uFF09| auto", "auto").option("--global", "\u540C\u6B65\u7528\u6237\u7EA7\u76EE\u5F55\u800C\u975E\u5F53\u524D\u9879\u76EE").option("--dir <path>", "\u540C\u6B65\u6307\u5B9A\u76EE\u5F55").option("--from <dir>", "\u4ECE\u672C\u5730\u76EE\u5F55\u53D6\uFF08\u73B0\u573A\u6539\u8FC7\u7684\u7248\u672C\uFF09\uFF0C\u4E0D\u8D70\u7F51\u7EDC").option("--force", "\u8FDE\u672C\u5730\u6539\u8FC7\u7684\u6280\u80FD\u4E00\u8D77\u8986\u76D6\u6210\u4EA7\u54C1\u8FD9\u4E00\u7248").option("--prune-max <n>", `\u4E00\u8D9F\u6700\u591A\u6E05\u51E0\u4EFD\u4E0A\u6E38\u4E0D\u518D\u53D1\u7684\u6280\u80FD\uFF0C\u8D85\u4E86\u6574\u6279\u62D2\u7EDD\uFF1B0 = \u4E00\u4EFD\u90FD\u522B\u6E05\uFF08\u7F3A\u7701 ${PRUNE_DEFAULT_MAX}\uFF09`).option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u9879\u76EE\u73AF\u5883\u6216\u5B89\u88C5\u65F6\u8BB0\u5F55\u7684\u5730\u5740\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => skillsSyncCommand(opts));
|
|
13905
|
+
chironSkills.command("path <id>").description("\u6253\u5370\u8FD9\u4E2A id \u5728\u672C\u9879\u76EE\u5B9E\u9645\u751F\u6548\u90A3\u4E00\u4EFD\u7684\u8DEF\u5F84\uFF08local/ \u906E\u853D sync/\uFF09\uFF0C\u4F9B\u6280\u80FD\u6B63\u6587\u5F15\u7528\uFF0C\u514D\u5F97\u6B63\u6587\u5199\u6B7B\u76EE\u5F55\u5C42\u6570").option("--refs", "\u8981 references/ \u7684\u843D\u70B9\uFF0C\u4E0D\u662F SKILL.md").option("--target <agent>", "claude | codex | auto", "auto").option("--global", "\u770B\u7528\u6237\u7EA7\u76EE\u5F55").option("--dir <path>", "\u770B\u6307\u5B9A\u76EE\u5F55").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((id, opts) => skillsPathCommand(id, opts));
|
|
13588
13906
|
var OUTPUT_OPT = ["--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table"];
|
|
13589
13907
|
var projectEnv = chiron.command("env").description("\u7EF4\u62A4\u672C\u9879\u76EE env.yaml\uFF1B\u672C\u673A\u69FD\u7531 hcm env \u7BA1\u7406");
|
|
13590
13908
|
projectEnv.command("list").description("\u5217\u51FA\u9879\u76EE\u73AF\u5883\u3001\u9ED8\u8BA4\u9879\u548C\u672C\u673A\u8EAB\u4EFD\u53EF\u7528\u6027\uFF08\u63A2\u4E0D\u5230\u65F6\u6807\u672A\u9A8C\u8BC1\uFF09").option("--project <dir>", "\u9879\u76EE\u76EE\u5F55\uFF08\u5411\u4E0A\u5BFB\u627E env.yaml\uFF09", ".").option(...OUTPUT_OPT).action((opts) => chironEnvCommand("list", opts));
|