fix: install skill only in canonical global directory

This commit is contained in:
gitea committed 2026-09-12 23:02:25 +08:00
1 parent f26eae7b08
commit 33db72f863
4 files changed
+8 -30

No files matched your search

+1 -19
View File
@@ -3,7 +3,6 @@ import { join } from "node:path";
import {
EMBEDDED_SKILL_FILES,
getDefaultGlobalSkillDir,
getAgentSkillCandidates,
getSkillContent,
installSkillFiles,
} from "../../core/embedded-skill.js";
@@ -47,25 +46,13 @@ export async function handleSkillCommand(
return mutationPreview(parsed, runtime, "安装 Agent Skill 文件", targetDir, {
fileCount: Object.keys(EMBEDDED_SKILL_FILES).length,
local: isLocal,
syncCandidates: !customDir,
targetPolicy: customDir ? "explicit" : isLocal ? "workspace" : "global-canonical",
});
}
requireMutationConfirmation(parsed, runtime, "安装 Agent Skill 文件", `hose-use skill install${customDir ? ` --dir=${customDir}` : ""} --yes`);
const result = installSkillFiles(targetDir);
// 也同时尝试安装到其它检测到的候选目录
const candidates = getAgentSkillCandidates();
for (const dir of candidates) {
if (dir !== targetDir) {
try {
installSkillFiles(dir);
} catch {
// ignore
}
}
}
if (runtime.jsonMode) {
return {
stdout: printJson({
@@ -90,7 +77,6 @@ export async function handleSkillCommand(
case "get": {
const globalDir = getDefaultGlobalSkillDir();
const localDir = join(process.cwd(), ".agents", "skills", "hose-use");
const candidates = getAgentSkillCandidates();
const statusObj = {
global: {
@@ -101,10 +87,6 @@ export async function handleSkillCommand(
dir: localDir,
installed: existsSync(join(localDir, "SKILL.md")),
},
candidates: candidates.map((dir) => ({
dir,
installed: existsSync(join(dir, "SKILL.md")),
})),
};
if (runtime.jsonMode) {