@hcmai/cli 0.14.1 → 0.14.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 +77 -5
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6611,6 +6611,11 @@ function collectBundledSkills(dir = bundledSkillsDir()) {
|
|
|
6611
6611
|
stages: strArray(fm.stages),
|
|
6612
6612
|
actionSurface: str(fm.actionSurface),
|
|
6613
6613
|
requires: strArray(fm.requires),
|
|
6614
|
+
// 🔴 这一行原来是漏的:`BundledSkillEntry.renamedFrom` 的字段注释写着
|
|
6615
|
+
// 「`sync` 靠它清掉存量仓里的旧份」,而清单根本没读它 —— 于是**自带技能**改名时
|
|
6616
|
+
// 清理链路恒不触发(睿戎那一半读的是服务端目录,所以只有自带这一半是瞎的)。
|
|
6617
|
+
// 2026-09-09 独立核查逮到;同源于「解析了就要显示」,只是这里连解析都没做。
|
|
6618
|
+
renamedFrom: strArray(fm.renamedFrom),
|
|
6614
6619
|
bytes,
|
|
6615
6620
|
files: fileRows
|
|
6616
6621
|
});
|
|
@@ -6976,8 +6981,23 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
|
|
|
6976
6981
|
const fmt = args.output ?? "table";
|
|
6977
6982
|
const localSkills = await readLocalSkills(layout.localDir);
|
|
6978
6983
|
if ((!state || Object.keys(state.skills).length === 0) && localSkills.length === 0) {
|
|
6984
|
+
const legacy = await detectLegacyFlatLayout(layout);
|
|
6985
|
+
const legacyState = legacy ? await readSkillsState(legacy) : void 0;
|
|
6979
6986
|
if (fmt === "json" || fmt === "yaml") {
|
|
6980
|
-
process.stdout.write(formatObject17({
|
|
6987
|
+
process.stdout.write(formatObject17({
|
|
6988
|
+
baseDir: layout.baseDir,
|
|
6989
|
+
target: layout.target,
|
|
6990
|
+
all: false,
|
|
6991
|
+
skills: [],
|
|
6992
|
+
...legacy ? { legacyFlatLayout: { dir: legacy, skills: Object.keys(legacyState?.skills ?? {}).length } } : {}
|
|
6993
|
+
}, { format: fmt }) + "\n");
|
|
6994
|
+
process.exitCode = 0;
|
|
6995
|
+
return;
|
|
6996
|
+
}
|
|
6997
|
+
if (legacy) {
|
|
6998
|
+
process.stdout.write(`\u8FD9\u4E2A\u4ED3\u8FD8\u662F\u65E7\u7684\u6241\u5E73\u5E03\u5C40\uFF1A${Object.keys(legacyState?.skills ?? {}).length} \u4EFD\u6280\u80FD\u5728 ${legacy}/ \u4E0B\uFF0C\u800C 0.14.0 \u8D77\u4EA7\u54C1\u90A3\u4E00\u534A\u5E94\u8BE5\u5728 ${legacy}/${SKILLS_SYNC_SUBDIR}/\u3002
|
|
6999
|
+
`);
|
|
7000
|
+
process.stdout.write(" \u8DD1\u4E00\u6B21 hcm chiron skills sync \u5C31\u5730\u5206\u597D\uFF08\u5E42\u7B49\uFF0C\u4E0D\u4F1A\u91CD\u88C5\uFF09\u3002\n");
|
|
6981
7001
|
process.exitCode = 0;
|
|
6982
7002
|
return;
|
|
6983
7003
|
}
|
|
@@ -7225,6 +7245,27 @@ async function skillsInstallCommand(id, args) {
|
|
|
7225
7245
|
}
|
|
7226
7246
|
if (args.check) {
|
|
7227
7247
|
const fmtCheck = args.output ?? "table";
|
|
7248
|
+
const legacyForCheck = await detectLegacyFlatLayout(layout);
|
|
7249
|
+
if (legacyForCheck) {
|
|
7250
|
+
const legacyState = await readSkillsState(legacyForCheck);
|
|
7251
|
+
const count = Object.keys(legacyState?.skills ?? {}).length;
|
|
7252
|
+
if (fmtCheck === "json" || fmtCheck === "yaml") {
|
|
7253
|
+
process.stdout.write(formatObject17({
|
|
7254
|
+
dryRun: true,
|
|
7255
|
+
legacyFlatLayout: { dir: legacyForCheck, skills: count },
|
|
7256
|
+
wouldMigrate: true,
|
|
7257
|
+
baseDir: layout.baseDir
|
|
7258
|
+
}, { format: fmtCheck }) + "\n");
|
|
7259
|
+
} else {
|
|
7260
|
+
process.stdout.write(`\u8FD9\u4E2A\u4ED3\u8FD8\u662F\u65E7\u7684\u6241\u5E73\u5E03\u5C40\uFF1A${count} \u4EFD\u6280\u80FD\u5728 ${legacyForCheck}/ \u4E0B\u3002
|
|
7261
|
+
`);
|
|
7262
|
+
process.stdout.write(`--check\uFF1A\u771F\u8DD1\u4F1A\u5148\u628A\u5B83\u5C31\u5730\u5206\u6210 ${SKILLS_SYNC_SUBDIR}/\uFF08\u4EA7\u54C1\u7684\uFF09\u4E0E ${SKILLS_LOCAL_SUBDIR}/\uFF08\u4F60\u81EA\u5DF1\u7684\uFF09\u4E24\u534A\uFF0C**\u518D**\u6309\u4EA7\u54C1\u5F53\u524D\u5168\u96C6\u5BF9\u8D26\u2014\u2014\u4E0D\u662F\u91CD\u88C5\u3002**\u672C\u6B21\u4E00\u4E2A\u5B57\u8282\u90FD\u6CA1\u5199\u3002**
|
|
7263
|
+
`);
|
|
7264
|
+
process.stdout.write(" \u771F\u8DD1\uFF1A\u53BB\u6389 --check \u91CD\u8DD1\u3002\n");
|
|
7265
|
+
}
|
|
7266
|
+
process.exitCode = 0;
|
|
7267
|
+
return;
|
|
7268
|
+
}
|
|
7228
7269
|
const would = documents.map((d) => d.id).sort();
|
|
7229
7270
|
if (fmtCheck === "json" || fmtCheck === "yaml") {
|
|
7230
7271
|
process.stdout.write(formatObject17({
|
|
@@ -8047,6 +8088,12 @@ async function skillsUpdateCommand(args) {
|
|
|
8047
8088
|
fail6(e, args);
|
|
8048
8089
|
}
|
|
8049
8090
|
}
|
|
8091
|
+
async function detectLegacyFlatLayout(layout) {
|
|
8092
|
+
if (!layout.localDir) return void 0;
|
|
8093
|
+
if (await readSkillsState(layout.baseDir)) return void 0;
|
|
8094
|
+
const legacyRoot = path8.dirname(layout.baseDir);
|
|
8095
|
+
return await readSkillsState(legacyRoot) ? legacyRoot : void 0;
|
|
8096
|
+
}
|
|
8050
8097
|
async function migrateFlatSkillsLayout(skillsRoot) {
|
|
8051
8098
|
const legacyState = path8.join(skillsRoot, SKILLS_STATE_FILE);
|
|
8052
8099
|
const syncDir = path8.join(skillsRoot, SKILLS_SYNC_SUBDIR);
|
|
@@ -8061,14 +8108,25 @@ async function migrateFlatSkillsLayout(skillsRoot) {
|
|
|
8061
8108
|
} catch {
|
|
8062
8109
|
return { moved: [], migrated: false };
|
|
8063
8110
|
}
|
|
8111
|
+
for (const reserved of [SKILLS_SYNC_SUBDIR, SKILLS_LOCAL_SUBDIR]) {
|
|
8112
|
+
if (!owned.has(reserved)) continue;
|
|
8113
|
+
throw invalid(`\u6280\u80FD id \u649E\u4E0A\u76EE\u5F55\u540D ${reserved}\uFF1A${skillsRoot} \u5206\u4E0D\u6210\u4E24\u534A\u3002\u8FD9\u662F\u4EA7\u54C1\u4FA7\u7684 id \u51B2\u7A81\uFF0C\u62A5\u7ED9\u4EA7\u54C1\u65B9\u6539\u540D\uFF1B\u5728\u90A3\u4E4B\u524D\u7528 --dir \u6307\u5B9A\u4E00\u4E2A\u522B\u7684\u843D\u70B9\u3002`);
|
|
8114
|
+
}
|
|
8064
8115
|
const moved = [];
|
|
8065
8116
|
for (const id of names) {
|
|
8066
8117
|
const hasSkill = await fsp2.stat(path8.join(skillsRoot, id, "SKILL.md")).then(() => true).catch(() => false);
|
|
8067
8118
|
if (!hasSkill) continue;
|
|
8068
8119
|
const to = owned.has(id) ? "sync" : "local";
|
|
8069
8120
|
const target = path8.join(to === "sync" ? syncDir : localDir, id);
|
|
8121
|
+
if (await fsp2.stat(target).then(() => true).catch(() => false)) {
|
|
8122
|
+
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`);
|
|
8123
|
+
}
|
|
8070
8124
|
await fsp2.mkdir(path8.dirname(target), { recursive: true });
|
|
8071
|
-
|
|
8125
|
+
try {
|
|
8126
|
+
await fsp2.rename(path8.join(skillsRoot, id), target);
|
|
8127
|
+
} catch (cause) {
|
|
8128
|
+
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`);
|
|
8129
|
+
}
|
|
8072
8130
|
moved.push({ id, to });
|
|
8073
8131
|
}
|
|
8074
8132
|
await fsp2.mkdir(syncDir, { recursive: true });
|
|
@@ -8094,7 +8152,7 @@ var defaultSkillsSyncDeps = {
|
|
|
8094
8152
|
migrate: async (args) => {
|
|
8095
8153
|
const layout = await resolveInstallLayout(args).catch(() => null);
|
|
8096
8154
|
if (!layout || !layout.localDir) return { moved: [], migrated: false };
|
|
8097
|
-
return migrateFlatSkillsLayout(path8.dirname(layout.baseDir))
|
|
8155
|
+
return migrateFlatSkillsLayout(path8.dirname(layout.baseDir));
|
|
8098
8156
|
}
|
|
8099
8157
|
};
|
|
8100
8158
|
async function skillsSyncCommand(args, deps = defaultSkillsSyncDeps) {
|
|
@@ -8105,7 +8163,12 @@ async function skillsSyncCommand(args, deps = defaultSkillsSyncDeps) {
|
|
|
8105
8163
|
return exitWithError(e);
|
|
8106
8164
|
}
|
|
8107
8165
|
if (!args.check) {
|
|
8108
|
-
|
|
8166
|
+
let result;
|
|
8167
|
+
try {
|
|
8168
|
+
result = await deps.migrate(args);
|
|
8169
|
+
} catch (e) {
|
|
8170
|
+
return exitWithError(e);
|
|
8171
|
+
}
|
|
8109
8172
|
if (result.migrated) {
|
|
8110
8173
|
const toSync = result.moved.filter((m) => m.to === "sync");
|
|
8111
8174
|
const toLocal = result.moved.filter((m) => m.to === "local");
|
|
@@ -10463,7 +10526,7 @@ async function chironInitCommand(args, deps) {
|
|
|
10463
10526
|
`\u2705 \u9879\u76EE\u5DF2\u521D\u59CB\u5316\uFF1A${result.project}`,
|
|
10464
10527
|
` \u73AF\u5883 ${result.env} \xB7 ${result.endpoint} \xB7 \u79DF\u6237 ${result.tenant} \xB7 \u8EAB\u4EFD ${result.identity ?? "\uFF08\u672C\u673A\u672A\u767B\u5F55\uFF09"}\uFF08\u6765\u81EA ${result.envSource}\uFF09`,
|
|
10465
10528
|
` ${mark} \u79DF\u6237 ${result.tenantCheck.detail ?? result.tenantCheck.status}`,
|
|
10466
|
-
` \u6280\u80FD ${result.skills === "installed" ? `\u5DF2\u88C5\u5230 ${SKILLS_DIR}
|
|
10529
|
+
` \u6280\u80FD ${result.skills === "installed" ? `\u5DF2\u88C5\u5230 ${SKILLS_DIR}/sync/\uFF08\u4F60\u81EA\u5DF1\u5199\u7684\u653E ${SKILLS_DIR}/local/\uFF09` : "\u672A\u88C5\uFF08hcm chiron skills sync \u88C5\uFF09"}`,
|
|
10467
10530
|
` \u4E0B\u4E00\u6B65\uFF1A${result.nextStep}`
|
|
10468
10531
|
].join("\n") + "\n"
|
|
10469
10532
|
);
|
|
@@ -10925,6 +10988,15 @@ async function runChironDoctor(args, deps = defaultDeps2) {
|
|
|
10925
10988
|
const skillsLine = async () => {
|
|
10926
10989
|
const state = await readSkillsState(skillsSyncDir(root));
|
|
10927
10990
|
if (!state) {
|
|
10991
|
+
const legacy = await readSkillsState(path11.join(root, SKILLS_DIR));
|
|
10992
|
+
if (legacy) {
|
|
10993
|
+
return {
|
|
10994
|
+
item: "\u6280\u80FD",
|
|
10995
|
+
verdict: "warn",
|
|
10996
|
+
detail: `${Object.keys(legacy.skills).length} \u4E2A\uFF0C\u4F46\u8FD8\u662F 0.14.0 \u4E4B\u524D\u7684\u6241\u5E73\u5E03\u5C40\uFF08\u6E05\u5355\u5728 ${SKILLS_DIR}/\uFF0C\u4EA7\u54C1\u90A3\u4E00\u534A\u5E94\u8BE5\u5728 ${SKILLS_DIR}/${SKILLS_SYNC_SUBDIR}/\uFF09`,
|
|
10997
|
+
nextStep: "hcm chiron skills sync \u5C31\u5730\u5206\u6210\u4E24\u534A\uFF08\u5E42\u7B49\uFF0C\u4E0D\u4F1A\u91CD\u88C5\uFF09"
|
|
10998
|
+
};
|
|
10999
|
+
}
|
|
10928
11000
|
return {
|
|
10929
11001
|
item: "\u6280\u80FD",
|
|
10930
11002
|
verdict: "fail",
|