1. 架构对称性与声明式注册表抽取:
- 新增 src/cli/aipro-registry.ts,声明式定义 AIPRO_COMMAND_REGISTRY 及其别名映射与 mutating 突变检查
- 重构 src/aipro-cli.ts,移除过程式 switch-case 分发,改为查表式声明分发,与 hose-use 的 CLI_COMMAND_REGISTRY 保持 100% 对称
- 在 src/cli/registry.ts 统一重导出 aipro-registry,巩固其作为顶层声明注册表的单一事实源地位
- 增加 aipro-cli 测试用例,强制校验 COMMAND_METADATA["hose-aipro"] 与声明式注册表双向一致性
2. 双 Skill 独立打包与内嵌部署:
- 注册两个独立技能:skills/hose-use 与 skills/hose-aipro,互相关联引用
- src/packaging/embedded-skill.ts 增加双 Skill 编译期嵌入与 installSkillFiles 全量同步
- hose-use / hose-aipro 下的 skill status/dump/install 完全对齐
3. 守护服务交叉治理:
- src/cli/service.ts 支持 ServiceTargetName ("hose-use" | "hose-aipro"),默认端口 8888 与 8889
- 支持 hose-use aipro <start|stop|...> 与 hose-aipro hose-use <start|stop|...> 双向服务纳管
- 误触非本领域业务命令时提供友好互导拦截
4. 审批领域数据层防御加固:
- 迁移 004:approval_runs 增加 short_id 唯一约束
- 增加 allocateUniqueShortId 冲突重试,多步写操作纳入事务
5. 版本升级至 v0.9.0:
- package.json、README.md、specs、.zcode-plugin 及两套 Skill 同步更新至 0.9.0
- bump-version 脚本适配多 Skill 自动递增
114 lines
6.0 KiB
TypeScript
114 lines
6.0 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { mkdtempSync, rmSync, existsSync } from "node:fs";
|
|
import { homedir, tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import {
|
|
EMBEDDED_HOSE_USE_SKILL_FILES,
|
|
EMBEDDED_AIPRO_SKILL_FILES,
|
|
getDefaultGlobalSkillDir,
|
|
getDefaultAiProGlobalSkillDir,
|
|
getSkillContent,
|
|
getAiProSkillContent,
|
|
installSkillFiles,
|
|
installHoseUseSkillFiles,
|
|
installAiProSkillFiles,
|
|
} from "./embedded-skill.js";
|
|
|
|
describe("embedded-skill - 双 Skill 体系内嵌与分发 (hose-use 与 hose-aipro)", () => {
|
|
test("全局 Skill 目录分别固定为 ~/.agents/skills/hose-use 与 hose-aipro", () => {
|
|
expect(getDefaultGlobalSkillDir()).toBe(join(homedir(), ".agents", "skills", "hose-use"));
|
|
expect(getDefaultAiProGlobalSkillDir()).toBe(join(homedir(), ".agents", "skills", "hose-aipro"));
|
|
});
|
|
|
|
test("hose-use: 正确内嵌 SKILL.md、agents/openai.yaml 及各领域参考专卷", () => {
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["SKILL.md"]).toBeDefined();
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["SKILL.md"]).toContain("name: hose-use");
|
|
expect(getSkillContent()).toContain("name: hose-use");
|
|
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["agents/openai.yaml"]).toBeDefined();
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["agents/openai.yaml"]).toContain("hose_cli");
|
|
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["references/auth.md"]).toBeDefined();
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["references/auth.md"]).toContain("RSA");
|
|
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["references/bill.md"]).toBeDefined();
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["references/bill.md"]).toContain("bill get");
|
|
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["references/workflow.md"]).toBeDefined();
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["references/workflow.md"]).toContain("workflow find");
|
|
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["references/service.md"]).toBeDefined();
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["references/service.md"]).toContain("hose-use aipro");
|
|
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["references/contact.md"]).toBeDefined();
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["references/contact.md"]).toContain("contact search");
|
|
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["references/feetype.md"]).toBeDefined();
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["references/feetype.md"]).toContain("feetype");
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["references/store.md"]).toBeDefined();
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["references/store.md"]).toContain("hose-use keys");
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["references/assist-platform.md"]).toBeDefined();
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["references/assist-platform.md"]).toContain("assist-platform");
|
|
|
|
// 套件结构:根入口路由到 multi/ 下的子技能
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["SKILL.md"]).toContain("multi/ekuaibao-mvel/SKILL.md");
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["multi/ekuaibao-mvel/SKILL.md"]).toContain("name: ekuaibao-mvel");
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["multi/ekuaibao-mvel/agents/openai.yaml"]).toContain("ekuaibao-mvel");
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["multi/ekuaibao-nodes/SKILL.md"]).toContain("name: ekuaibao-nodes");
|
|
expect(EMBEDDED_HOSE_USE_SKILL_FILES["multi/ekuaibao-nodes/references/gray-nodes.md"]).toContain("灰度节点清单");
|
|
});
|
|
|
|
test("hose-aipro: 正确内嵌 SKILL.md、agents/openai.yaml、approval.md 与 service.md", () => {
|
|
expect(EMBEDDED_AIPRO_SKILL_FILES["SKILL.md"]).toBeDefined();
|
|
expect(EMBEDDED_AIPRO_SKILL_FILES["SKILL.md"]).toContain("name: hose-aipro");
|
|
expect(getAiProSkillContent()).toContain("name: hose-aipro");
|
|
|
|
expect(EMBEDDED_AIPRO_SKILL_FILES["agents/openai.yaml"]).toBeDefined();
|
|
expect(EMBEDDED_AIPRO_SKILL_FILES["agents/openai.yaml"]).toContain("command: \"hose-aipro\"");
|
|
|
|
expect(EMBEDDED_AIPRO_SKILL_FILES["references/approval.md"]).toBeDefined();
|
|
expect(EMBEDDED_AIPRO_SKILL_FILES["references/approval.md"]).toContain("hose-aipro decide");
|
|
|
|
expect(EMBEDDED_AIPRO_SKILL_FILES["references/service.md"]).toBeDefined();
|
|
expect(EMBEDDED_AIPRO_SKILL_FILES["references/service.md"]).toContain("8889");
|
|
});
|
|
|
|
test("installSkillFiles 显式路径安装保留层级结构", () => {
|
|
const tmp = mkdtempSync(join(tmpdir(), "hose-skill-test-"));
|
|
try {
|
|
const res = installHoseUseSkillFiles(tmp);
|
|
expect(res.targetDir).toBe(tmp);
|
|
expect(res.files.length).toBe(18);
|
|
expect(existsSync(join(tmp, "SKILL.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "agents", "openai.yaml"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "auth.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "bill.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "contact.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "feetype.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "role.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "workflow.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "service.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "store.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "multi", "ekuaibao-mvel", "SKILL.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "multi", "ekuaibao-nodes", "references", "gray-nodes.md"))).toBe(true);
|
|
} finally {
|
|
rmSync(tmp, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
test("installAiProSkillFiles 正确落盘 hose-aipro 专属技能文件", () => {
|
|
const tmp = mkdtempSync(join(tmpdir(), "aipro-skill-test-"));
|
|
try {
|
|
const res = installAiProSkillFiles(tmp);
|
|
expect(res.targetDir).toBe(tmp);
|
|
expect(res.files.length).toBe(5);
|
|
expect(existsSync(join(tmp, "SKILL.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "agents", "openai.yaml"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "approval.md"))).toBe(true);
|
|
expect(existsSync(join(tmp, "references", "service.md"))).toBe(true);
|
|
} finally {
|
|
rmSync(tmp, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|