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 自动递增
142 lines
6.4 KiB
TypeScript
142 lines
6.4 KiB
TypeScript
import { mkdirSync, writeFileSync } from "node:fs";
|
|
import { homedir } from "node:os";
|
|
import { dirname, join } from "node:path";
|
|
|
|
// ── hose-use Skill 文件 ────────────────────────────────────────────────────────
|
|
import skillMain from "../../skills/hose-use/SKILL.md" with { type: "text" };
|
|
import agentOpenAi from "../../skills/hose-use/agents/openai.yaml" with { type: "text" };
|
|
import refAuth from "../../skills/hose-use/references/auth.md" with { type: "text" };
|
|
import refBill from "../../skills/hose-use/references/bill.md" with { type: "text" };
|
|
import refWorkflow from "../../skills/hose-use/references/workflow.md" with { type: "text" };
|
|
import refService from "../../skills/hose-use/references/service.md" with { type: "text" };
|
|
import refContact from "../../skills/hose-use/references/contact.md" with { type: "text" };
|
|
import refTask from "../../skills/hose-use/references/task.md" with { type: "text" };
|
|
import refMessage from "../../skills/hose-use/references/message.md" with { type: "text" };
|
|
import refDimension from "../../skills/hose-use/references/dimension.md" with { type: "text" };
|
|
import refRole from "../../skills/hose-use/references/role.md" with { type: "text" };
|
|
import refFeeType from "../../skills/hose-use/references/feetype.md" with { type: "text" };
|
|
import refStore from "../../skills/hose-use/references/store.md" with { type: "text" };
|
|
import refAssistPlatform from "../../skills/hose-use/references/assist-platform.md" with { type: "text" };
|
|
import multiMvel from "../../skills/hose-use/multi/ekuaibao-mvel/SKILL.md" with { type: "text" };
|
|
import multiMvelAgent from "../../skills/hose-use/multi/ekuaibao-mvel/agents/openai.yaml" with { type: "text" };
|
|
import multiNodes from "../../skills/hose-use/multi/ekuaibao-nodes/SKILL.md" with { type: "text" };
|
|
import multiNodesGray from "../../skills/hose-use/multi/ekuaibao-nodes/references/gray-nodes.md" with { type: "text" };
|
|
|
|
// ── hose-aipro Skill 文件 ──────────────────────────────────────────────────────
|
|
import aiproSkillMain from "../../skills/hose-aipro/SKILL.md" with { type: "text" };
|
|
import aiproAgentOpenAi from "../../skills/hose-aipro/agents/openai.yaml" with { type: "text" };
|
|
import aiproRefApproval from "../../skills/hose-aipro/references/approval.md" with { type: "text" };
|
|
import aiproRefService from "../../skills/hose-aipro/references/service.md" with { type: "text" };
|
|
import aiproRefReadme from "../../skills/hose-aipro/references/README.references.md" with { type: "text" };
|
|
|
|
export const EMBEDDED_HOSE_USE_SKILL_FILES: Record<string, string> = {
|
|
"SKILL.md": skillMain,
|
|
"agents/openai.yaml": agentOpenAi,
|
|
"references/auth.md": refAuth,
|
|
"references/bill.md": refBill,
|
|
"references/feetype.md": refFeeType,
|
|
"references/contact.md": refContact,
|
|
"references/task.md": refTask,
|
|
"references/message.md": refMessage,
|
|
"references/dimension.md": refDimension,
|
|
"references/role.md": refRole,
|
|
"references/workflow.md": refWorkflow,
|
|
"references/service.md": refService,
|
|
"references/store.md": refStore,
|
|
"references/assist-platform.md": refAssistPlatform,
|
|
"multi/ekuaibao-mvel/SKILL.md": multiMvel,
|
|
"multi/ekuaibao-mvel/agents/openai.yaml": multiMvelAgent,
|
|
"multi/ekuaibao-nodes/SKILL.md": multiNodes,
|
|
"multi/ekuaibao-nodes/references/gray-nodes.md": multiNodesGray,
|
|
};
|
|
|
|
export const EMBEDDED_AIPRO_SKILL_FILES: Record<string, string> = {
|
|
"SKILL.md": aiproSkillMain,
|
|
"agents/openai.yaml": aiproAgentOpenAi,
|
|
"references/approval.md": aiproRefApproval,
|
|
"references/service.md": aiproRefService,
|
|
"references/README.references.md": aiproRefReadme,
|
|
};
|
|
|
|
// 保持模块级向后兼容
|
|
export const EMBEDDED_SKILL_FILES: Record<string, string> = EMBEDDED_HOSE_USE_SKILL_FILES;
|
|
|
|
export function getSkillContent(): string {
|
|
return EMBEDDED_HOSE_USE_SKILL_FILES["SKILL.md"] || "";
|
|
}
|
|
|
|
export function getAiProSkillContent(): string {
|
|
return EMBEDDED_AIPRO_SKILL_FILES["SKILL.md"] || "";
|
|
}
|
|
|
|
export function getDefaultGlobalSkillDir(): string {
|
|
return join(homedir(), ".agents", "skills", "hose-use");
|
|
}
|
|
|
|
export function getDefaultAiProGlobalSkillDir(): string {
|
|
return join(homedir(), ".agents", "skills", "hose-aipro");
|
|
}
|
|
|
|
export function installHoseUseSkillFiles(targetDir: string = getDefaultGlobalSkillDir()): {
|
|
targetDir: string;
|
|
files: string[];
|
|
} {
|
|
mkdirSync(targetDir, { recursive: true });
|
|
const installed: string[] = [];
|
|
|
|
for (const [relPath, content] of Object.entries(EMBEDDED_HOSE_USE_SKILL_FILES)) {
|
|
const fullPath = join(targetDir, relPath);
|
|
mkdirSync(dirname(fullPath), { recursive: true });
|
|
writeFileSync(fullPath, content, "utf8");
|
|
installed.push(relPath);
|
|
}
|
|
|
|
return { targetDir, files: installed };
|
|
}
|
|
|
|
export function installAiProSkillFiles(targetDir: string = getDefaultAiProGlobalSkillDir()): {
|
|
targetDir: string;
|
|
files: string[];
|
|
} {
|
|
mkdirSync(targetDir, { recursive: true });
|
|
const installed: string[] = [];
|
|
|
|
for (const [relPath, content] of Object.entries(EMBEDDED_AIPRO_SKILL_FILES)) {
|
|
const fullPath = join(targetDir, relPath);
|
|
mkdirSync(dirname(fullPath), { recursive: true });
|
|
writeFileSync(fullPath, content, "utf8");
|
|
installed.push(relPath);
|
|
}
|
|
|
|
return { targetDir, files: installed };
|
|
}
|
|
|
|
export function installSkillFiles(targetDir: string = getDefaultGlobalSkillDir()): {
|
|
targetDir: string;
|
|
files: string[];
|
|
skills?: string[];
|
|
} {
|
|
const defaultGlobalDir = getDefaultGlobalSkillDir();
|
|
// 当为全局默认目录时,自动同时安装两个 Skill
|
|
if (targetDir === defaultGlobalDir) {
|
|
const hoseRes = installHoseUseSkillFiles(defaultGlobalDir);
|
|
const aiproRes = installAiProSkillFiles(getDefaultAiProGlobalSkillDir());
|
|
return {
|
|
targetDir,
|
|
files: [...hoseRes.files, ...aiproRes.files.map((f) => `hose-aipro/${f}`)],
|
|
skills: ["hose-use", "hose-aipro"],
|
|
};
|
|
}
|
|
|
|
// 显式指定自定义目录时,在该目录下安装 hose-use 文件
|
|
return installHoseUseSkillFiles(targetDir);
|
|
}
|
|
|
|
export function syncGlobalSkillIfPresent(): { synced: boolean; targetDir?: string; targetDirs: string[] } {
|
|
const hoseDir = getDefaultGlobalSkillDir();
|
|
const aiproDir = getDefaultAiProGlobalSkillDir();
|
|
installHoseUseSkillFiles(hoseDir);
|
|
installAiProSkillFiles(aiproDir);
|
|
return { synced: true, targetDir: hoseDir, targetDirs: [hoseDir, aiproDir] };
|
|
}
|