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 -1
View File
@@ -107,7 +107,7 @@ hose-use mcp # 启动 MCP Server (默认暴露
### 模块化 Agent Skill 与 IDE 插件规范
- **多文件 Skill 模块体系**:知识体系划分至 `references/auth.md`、`references/bill.md`、`references/workflow.md`、`references/service.md`,执行 `hose-use skill install` 自动递归安装并支持环境自愈;
- **多文件 Skill 模块体系**:知识体系划分至 `references/auth.md`、`references/bill.md`、`references/workflow.md`、`references/service.md`,执行 `hose-use skill install` 自动递归安装到统一的 `~/.agents/skills/hose-use`;如需安装到其他位置,必须显式使用 `--dir`;
- **原生 IDE 插件规范支持**:内嵌 `.zcode-plugin/plugin.json` 与 `.mcp.json` 清单,支持标准 IDE 插件市场/本地插件直接载入,并在设置界面支持可视化切换 MCP 开关;
- **MCP 单文件产物**:支持通过 `bun run build:plugin` 快速编译 Node.js 兼容的轻量单文件 `dist/mcp/server.js`。
+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) {
+6 -2
View File
@@ -1,10 +1,14 @@
import { describe, expect, test } from "bun:test";
import { mkdtempSync, rmSync, existsSync } from "node:fs";
import { tmpdir } from "node:os";
import { homedir, tmpdir } from "node:os";
import { join } from "node:path";
import { EMBEDDED_SKILL_FILES, getSkillContent, installSkillFiles } from "./embedded-skill.js";
import { EMBEDDED_SKILL_FILES, getDefaultGlobalSkillDir, getSkillContent, installSkillFiles } from "./embedded-skill.js";
describe("embedded-skill - 多文件内嵌 Skill 体系", () => {
test("全局 Skill 目录固定为 ~/.agents/skills/hose-use", () => {
expect(getDefaultGlobalSkillDir()).toBe(join(homedir(), ".agents", "skills", "hose-use"));
});
test("正确内嵌 SKILL.md、agents/openai.yaml 及各领域参考专卷", () => {
expect(EMBEDDED_SKILL_FILES["SKILL.md"]).toBeDefined();
expect(EMBEDDED_SKILL_FILES["SKILL.md"]).toContain("name: hose-use");
-8
View File
@@ -42,14 +42,6 @@ export function getDefaultGlobalSkillDir(): string {
return join(homedir(), ".agents", "skills", "hose-use");
}
export function getAgentSkillCandidates(): string[] {
return [
join(homedir(), ".agents", "skills", "hose-use"),
join(homedir(), ".gemini", "antigravity", "skills", "hose-use"),
join(homedir(), ".codex", "skills", "hose-use"),
];
}
export function installSkillFiles(targetDir: string = getDefaultGlobalSkillDir()): {
targetDir: string;
files: string[];