@hcmai/cli 0.13.0 → 0.13.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/dist/index.js +69 -9
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6370,6 +6370,14 @@ async function resolveBundledClosure(targetId, dir = bundledSkillsDir()) {
|
|
|
6370
6370
|
|
|
6371
6371
|
// src/commands/skills.ts
|
|
6372
6372
|
var SKILLS_STATE_FILE = ".hcm-skills.json";
|
|
6373
|
+
function resolveRenamedId(id, half) {
|
|
6374
|
+
if (half.entries.has(id)) return id;
|
|
6375
|
+
if (half.status !== "fetched") return id;
|
|
6376
|
+
for (const [current, entry] of half.entries) {
|
|
6377
|
+
if ((entry.meta.renamedFrom ?? []).includes(id)) return current;
|
|
6378
|
+
}
|
|
6379
|
+
return id;
|
|
6380
|
+
}
|
|
6373
6381
|
function migrateSkillsState(state) {
|
|
6374
6382
|
const skills2 = {};
|
|
6375
6383
|
for (const [id, record] of Object.entries(state.skills ?? {})) {
|
|
@@ -6796,14 +6804,15 @@ async function skillsInstallCommand(id, args) {
|
|
|
6796
6804
|
};
|
|
6797
6805
|
const installBundled = async (one) => {
|
|
6798
6806
|
const { documents: local, external } = await resolveBundledClosure(one);
|
|
6799
|
-
for (const
|
|
6807
|
+
for (const rawNeed of external) {
|
|
6808
|
+
const need = resolveRenamedId(rawNeed, catalog.chiron);
|
|
6800
6809
|
if (catalog.chiron.status !== "fetched") {
|
|
6801
6810
|
throw invalid(
|
|
6802
6811
|
`\u81EA\u5E26\u6280\u80FD ${one} \u4F9D\u8D56\u777F\u620E\u6280\u80FD ${need}\uFF0C\u4F46\u8FD9\u4E00\u8D9F\u6CA1\u8FDE\u7F51\u53D6\u777F\u620E\u76EE\u5F55\uFF08--source ${source}\uFF09\u3002\u8054\u7F51\u540E\u91CD\u8DD1\uFF0C\u6216\u5148\u5355\u72EC\u88C5\u4E0A\u5B83\u3002`
|
|
6803
6812
|
);
|
|
6804
6813
|
}
|
|
6805
6814
|
if (!catalog.chiron.entries.has(need)) {
|
|
6806
|
-
throw invalid(`\u81EA\u5E26\u6280\u80FD ${one} \u4F9D\u8D56 ${need}\uFF0C\u4F46 ${endpoint} \u7684\u6280\u80FD\u76EE\u5F55\u91CC\u6CA1\u6709\u5B83`);
|
|
6815
|
+
throw invalid(`\u81EA\u5E26\u6280\u80FD ${one} \u4F9D\u8D56 ${rawNeed}${need !== rawNeed ? `\uFF08\u73B0\u540D ${need}\uFF09` : ""}\uFF0C\u4F46 ${endpoint} \u7684\u6280\u80FD\u76EE\u5F55\u91CC\u6CA1\u6709\u5B83`);
|
|
6807
6816
|
}
|
|
6808
6817
|
pushAll(
|
|
6809
6818
|
await mapWithConcurrency(
|
|
@@ -6849,6 +6858,34 @@ async function skillsInstallCommand(id, args) {
|
|
|
6849
6858
|
);
|
|
6850
6859
|
}
|
|
6851
6860
|
}
|
|
6861
|
+
if (args.check) {
|
|
6862
|
+
const fmtCheck = args.output ?? "table";
|
|
6863
|
+
const would = documents.map((d) => d.id).sort();
|
|
6864
|
+
if (fmtCheck === "json" || fmtCheck === "yaml") {
|
|
6865
|
+
process.stdout.write(formatObject16({
|
|
6866
|
+
dryRun: true,
|
|
6867
|
+
baseDir: layout.baseDir,
|
|
6868
|
+
target: layout.target,
|
|
6869
|
+
all,
|
|
6870
|
+
managed: false,
|
|
6871
|
+
wouldInstall: would,
|
|
6872
|
+
endpoint,
|
|
6873
|
+
base
|
|
6874
|
+
}, { format: fmtCheck }) + "\n");
|
|
6875
|
+
} else {
|
|
6876
|
+
process.stdout.write(`\u8FD9\u4E2A\u76EE\u5F55\u8FD8\u6CA1\u88C5\u8FC7\u6280\u80FD\uFF08${path6.join(layout.baseDir, SKILLS_STATE_FILE)} \u4E0D\u5B58\u5728\uFF09\u3002
|
|
6877
|
+
`);
|
|
6878
|
+
process.stdout.write(`--check\uFF1A\u4F1A\u88C5 ${would.length} \u4E2A\u6280\u80FD\u5230 ${layout.baseDir}\uFF0C\u5E76\u628A\u7D22\u5F15\u4E0E\u9879\u76EE\u8FB9\u754C\u5757\u5199\u8FDB ${layout.agentsFile ?? "AGENTS.md"}\u3002**\u672C\u6B21\u4E00\u4E2A\u5B57\u8282\u90FD\u6CA1\u5199\u3002**
|
|
6879
|
+
`);
|
|
6880
|
+
if (would.length > 0) {
|
|
6881
|
+
process.stdout.write(` ${would.slice(0, 8).join("\u3001")}${would.length > 8 ? ` \u7B49 ${would.length} \u4E2A` : ""}
|
|
6882
|
+
`);
|
|
6883
|
+
}
|
|
6884
|
+
process.stdout.write(" \u771F\u88C5\uFF1A\u53BB\u6389 --check \u91CD\u8DD1\u3002\n");
|
|
6885
|
+
}
|
|
6886
|
+
process.exitCode = 0;
|
|
6887
|
+
return;
|
|
6888
|
+
}
|
|
6852
6889
|
const result = await installSkillDocuments(documents, requestedIds, layout.baseDir, Boolean(args.force), {
|
|
6853
6890
|
endpoint,
|
|
6854
6891
|
base,
|
|
@@ -6954,18 +6991,35 @@ async function syncAgentIndexes(layout, manifest2) {
|
|
|
6954
6991
|
const results = [];
|
|
6955
6992
|
for (const file of files) {
|
|
6956
6993
|
const agentsDir = path6.dirname(file);
|
|
6957
|
-
const entries = Object.keys(state.skills).sort().map((id) => {
|
|
6994
|
+
const entries = await Promise.all(Object.keys(state.skills).sort().map(async (id) => {
|
|
6958
6995
|
const known = catalog.get(id);
|
|
6959
6996
|
const absolute = path6.join(layout.baseDir, id, "SKILL.md");
|
|
6960
6997
|
let relative2 = path6.relative(agentsDir, absolute);
|
|
6961
6998
|
if (!relative2.startsWith(".")) relative2 = `./${relative2}`;
|
|
6999
|
+
let title = known?.title;
|
|
7000
|
+
let description = known?.description;
|
|
7001
|
+
if (title === void 0 || description === void 0) {
|
|
7002
|
+
const markdown = await readInstalled(layout.baseDir, id);
|
|
7003
|
+
if (markdown !== void 0) {
|
|
7004
|
+
try {
|
|
7005
|
+
const frontmatter = parseSkillFrontmatter2(markdown, id);
|
|
7006
|
+
const localTitle = frontmatter.title;
|
|
7007
|
+
const localDescription = frontmatter.description;
|
|
7008
|
+
if (title === void 0 && typeof localTitle === "string" && localTitle.trim()) title = localTitle.trim();
|
|
7009
|
+
if (description === void 0 && typeof localDescription === "string" && localDescription.trim()) {
|
|
7010
|
+
description = localDescription.trim();
|
|
7011
|
+
}
|
|
7012
|
+
} catch {
|
|
7013
|
+
}
|
|
7014
|
+
}
|
|
7015
|
+
}
|
|
6962
7016
|
return {
|
|
6963
7017
|
id,
|
|
6964
|
-
title:
|
|
6965
|
-
description:
|
|
7018
|
+
title: title ?? id,
|
|
7019
|
+
description: description ?? "",
|
|
6966
7020
|
relativePath: relative2.split(path6.sep).join("/")
|
|
6967
7021
|
};
|
|
6968
|
-
});
|
|
7022
|
+
}));
|
|
6969
7023
|
const status = await upsertAgentsBlock(file, renderAgentsBlock(entries));
|
|
6970
7024
|
const before = await fsp2.readFile(file, "utf8").catch(() => "");
|
|
6971
7025
|
const merged = mergeBoundaryBlock(before, manifest2?.agentBoundary);
|
|
@@ -7048,7 +7102,11 @@ function renderAgentsBlock(entries) {
|
|
|
7048
7102
|
];
|
|
7049
7103
|
for (const e of entries) {
|
|
7050
7104
|
lines.push(`- \`${e.relativePath}\` \u2014 **${e.title}**`);
|
|
7051
|
-
if (e.description)
|
|
7105
|
+
if (e.description) {
|
|
7106
|
+
lines.push(` ${e.description}`);
|
|
7107
|
+
} else {
|
|
7108
|
+
lines.push(" \uFF08\u67E5\u4E0D\u5230\u63CF\u8FF0\uFF1A\u4EA7\u54C1\u76EE\u5F55\u91CC\u6CA1\u6709\u5B83\uFF0C\u76D8\u4E0A\u90A3\u4EFD SKILL.md \u7684 frontmatter \u4E5F\u6CA1\u7ED9\u3002\u8981\u7528\u5B83\u5C31\u5148\u6253\u5F00\u8BFB\u4E00\u773C\u3002\uFF09");
|
|
7109
|
+
}
|
|
7052
7110
|
}
|
|
7053
7111
|
lines.push("", AGENTS_BLOCK_END);
|
|
7054
7112
|
return lines.join("\n");
|
|
@@ -7356,8 +7414,9 @@ async function planSkillUpdate(options) {
|
|
|
7356
7414
|
}
|
|
7357
7415
|
chironNeeded.add(item.id);
|
|
7358
7416
|
}
|
|
7359
|
-
for (const
|
|
7417
|
+
for (const rawId of chironNeeded) {
|
|
7360
7418
|
if (!manifest2) continue;
|
|
7419
|
+
const id = resolveRenamedId(rawId, catalog.chiron);
|
|
7361
7420
|
try {
|
|
7362
7421
|
for (const skill of resolveSkillInstallOrder(manifest2, id)) {
|
|
7363
7422
|
if (!closure.has(skill.id)) closure.set(skill.id, { kind: "chiron", skill });
|
|
@@ -7375,10 +7434,11 @@ async function planSkillUpdate(options) {
|
|
|
7375
7434
|
const fetch2 = async () => item.kind === "cli" ? await fetchBundled(id) : await fetchDocument(item.skill);
|
|
7376
7435
|
if (onDisk === void 0) {
|
|
7377
7436
|
documents.push(await fetch2());
|
|
7437
|
+
const renamedFromId = renamedPairs.find((pair) => pair.to === id)?.from;
|
|
7378
7438
|
entries.push({
|
|
7379
7439
|
id,
|
|
7380
7440
|
status: "added",
|
|
7381
|
-
note: record ? "\u672C\u5730\u6587\u4EF6\u7F3A\u5931\uFF0C\u91CD\u65B0\u88C5\u56DE" : all ? "\u4EA7\u54C1\u8FD9\u4E00\u7248\u65B0\u589E\u7684\u6280\u80FD" : "\u4EA7\u54C1\u65B0\u589E\u7684\u524D\u7F6E\u6280\u80FD"
|
|
7441
|
+
note: renamedFromId ? `${renamedFromId} \u6539\u540D\u540E\u7684\u65B0\u540D\uFF0C\u5185\u5BB9\u642C\u5230\u4E86\u8FD9\u91CC` : record ? "\u672C\u5730\u6587\u4EF6\u7F3A\u5931\uFF0C\u91CD\u65B0\u88C5\u56DE" : all ? "\u4EA7\u54C1\u8FD9\u4E00\u7248\u65B0\u589E\u7684\u6280\u80FD" : "\u4EA7\u54C1\u65B0\u589E\u7684\u524D\u7F6E\u6280\u80FD"
|
|
7382
7442
|
});
|
|
7383
7443
|
continue;
|
|
7384
7444
|
}
|