feat(cli): 分离 hose-aipro 独立命令体系并升级至 v0.9.0
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 自动递增
This commit is contained in:
1 parent
c3e39fe77a
commit
362acfba58
38 files changed
+1380
-690
No files matched your search
+97
-29
@@ -1,10 +1,15 @@
|
||||
import { existsSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import {
|
||||
EMBEDDED_SKILL_FILES,
|
||||
EMBEDDED_HOSE_USE_SKILL_FILES,
|
||||
EMBEDDED_AIPRO_SKILL_FILES,
|
||||
getDefaultGlobalSkillDir,
|
||||
getDefaultAiProGlobalSkillDir,
|
||||
getSkillContent,
|
||||
getAiProSkillContent,
|
||||
installSkillFiles,
|
||||
installHoseUseSkillFiles,
|
||||
installAiProSkillFiles,
|
||||
} from "../../packaging/embedded-skill.js";
|
||||
import { booleanOption, stringOption } from "../parser.js";
|
||||
import { printJson, printKeyValue } from "../printer.js";
|
||||
@@ -16,13 +21,16 @@ export async function handleSkillCommand(
|
||||
runtime: CliRuntime
|
||||
): Promise<CliResult> {
|
||||
const action = parsed.action || "status";
|
||||
const isAiProCaller =
|
||||
parsed.area === "hose-aipro" ||
|
||||
parsed.raw.some((arg) => arg.includes("hose-aipro") || arg === "aipro");
|
||||
|
||||
switch (action) {
|
||||
case "dump":
|
||||
case "cat":
|
||||
case "show":
|
||||
return {
|
||||
stdout: `${getSkillContent()}\n`,
|
||||
stdout: `${isAiProCaller ? getAiProSkillContent() : getSkillContent()}\n`,
|
||||
stderr: "",
|
||||
exitCode: 0,
|
||||
};
|
||||
@@ -36,30 +44,71 @@ export async function handleSkillCommand(
|
||||
const customDir =
|
||||
stringOption(parsed.options, ["dir", "target"]) || parsed.args[0];
|
||||
|
||||
const targetDir = customDir
|
||||
? customDir
|
||||
: isLocal
|
||||
? join(process.cwd(), ".agents", "skills", "hose-use")
|
||||
: getDefaultGlobalSkillDir();
|
||||
const globalHoseDir = getDefaultGlobalSkillDir();
|
||||
const globalAiProDir = getDefaultAiProGlobalSkillDir();
|
||||
const localHoseDir = join(process.cwd(), ".agents", "skills", "hose-use");
|
||||
const localAiProDir = join(process.cwd(), ".agents", "skills", "hose-aipro");
|
||||
|
||||
const targetPolicy = customDir ? "explicit" : isLocal ? "workspace" : "global-canonical";
|
||||
const totalFiles =
|
||||
Object.keys(EMBEDDED_HOSE_USE_SKILL_FILES).length +
|
||||
Object.keys(EMBEDDED_AIPRO_SKILL_FILES).length;
|
||||
|
||||
if (isDryRun(parsed, runtime)) {
|
||||
return mutationPreview(parsed, runtime, "安装 Agent Skill 文件", targetDir, {
|
||||
fileCount: Object.keys(EMBEDDED_SKILL_FILES).length,
|
||||
local: isLocal,
|
||||
targetPolicy: customDir ? "explicit" : isLocal ? "workspace" : "global-canonical",
|
||||
});
|
||||
return mutationPreview(
|
||||
parsed,
|
||||
runtime,
|
||||
"安装 Agent Skill 文件 (hose-use 与 hose-aipro)",
|
||||
customDir || (isLocal ? `${localHoseDir} & ${localAiProDir}` : `${globalHoseDir} & ${globalAiProDir}`),
|
||||
{
|
||||
fileCount: totalFiles,
|
||||
local: isLocal,
|
||||
targetPolicy,
|
||||
skills: ["hose-use", "hose-aipro"],
|
||||
}
|
||||
);
|
||||
}
|
||||
requireMutationConfirmation(parsed, runtime, "安装 Agent Skill 文件", `hose-use skill install${customDir ? ` --dir=${customDir}` : ""} --yes`);
|
||||
requireMutationConfirmation(
|
||||
parsed,
|
||||
runtime,
|
||||
"安装 Agent Skill 文件",
|
||||
`${isAiProCaller ? "hose-aipro" : "hose-use"} skill install${customDir ? ` --dir=${customDir}` : ""} --yes`
|
||||
);
|
||||
|
||||
const result = installSkillFiles(targetDir);
|
||||
let installedReport: { targetDirs: string[]; filesCount: number; skills: string[] };
|
||||
|
||||
if (customDir) {
|
||||
const res = installSkillFiles(customDir);
|
||||
installedReport = {
|
||||
targetDirs: [res.targetDir],
|
||||
filesCount: res.files.length,
|
||||
skills: ["hose-use"],
|
||||
};
|
||||
} else if (isLocal) {
|
||||
const hoseRes = installHoseUseSkillFiles(localHoseDir);
|
||||
const aiproRes = installAiProSkillFiles(localAiProDir);
|
||||
installedReport = {
|
||||
targetDirs: [hoseRes.targetDir, aiproRes.targetDir],
|
||||
filesCount: hoseRes.files.length + aiproRes.files.length,
|
||||
skills: ["hose-use", "hose-aipro"],
|
||||
};
|
||||
} else {
|
||||
const hoseRes = installHoseUseSkillFiles(globalHoseDir);
|
||||
const aiproRes = installAiProSkillFiles(globalAiProDir);
|
||||
installedReport = {
|
||||
targetDirs: [hoseRes.targetDir, aiproRes.targetDir],
|
||||
filesCount: hoseRes.files.length + aiproRes.files.length,
|
||||
skills: ["hose-use", "hose-aipro"],
|
||||
};
|
||||
}
|
||||
|
||||
if (runtime.jsonMode) {
|
||||
return {
|
||||
stdout: printJson({
|
||||
installed: true,
|
||||
targetDir: result.targetDir,
|
||||
fileCount: result.files.length,
|
||||
files: result.files,
|
||||
targetDirs: installedReport.targetDirs,
|
||||
fileCount: installedReport.filesCount,
|
||||
skills: installedReport.skills,
|
||||
}),
|
||||
stderr: "",
|
||||
exitCode: 0,
|
||||
@@ -67,7 +116,10 @@ export async function handleSkillCommand(
|
||||
}
|
||||
|
||||
return {
|
||||
stdout: `[SUCCESS] hose-use 技能已成功安装至: ${result.targetDir}\n包含文件: ${result.files.join(", ")}\n`,
|
||||
stdout:
|
||||
`[SUCCESS] Agent 技能已成功安装:\n` +
|
||||
installedReport.targetDirs.map((d) => ` • ${d}`).join("\n") +
|
||||
`\n共 ${installedReport.filesCount} 个文件。\n`,
|
||||
stderr: "",
|
||||
exitCode: 0,
|
||||
};
|
||||
@@ -75,17 +127,31 @@ export async function handleSkillCommand(
|
||||
|
||||
case "status":
|
||||
case "get": {
|
||||
const globalDir = getDefaultGlobalSkillDir();
|
||||
const localDir = join(process.cwd(), ".agents", "skills", "hose-use");
|
||||
const globalHoseDir = getDefaultGlobalSkillDir();
|
||||
const globalAiProDir = getDefaultAiProGlobalSkillDir();
|
||||
const localHoseDir = join(process.cwd(), ".agents", "skills", "hose-use");
|
||||
const localAiProDir = join(process.cwd(), ".agents", "skills", "hose-aipro");
|
||||
|
||||
const statusObj = {
|
||||
global: {
|
||||
dir: globalDir,
|
||||
installed: existsSync(join(globalDir, "SKILL.md")),
|
||||
"hose-use": {
|
||||
global: {
|
||||
dir: globalHoseDir,
|
||||
installed: existsSync(join(globalHoseDir, "SKILL.md")),
|
||||
},
|
||||
local: {
|
||||
dir: localHoseDir,
|
||||
installed: existsSync(join(localHoseDir, "SKILL.md")),
|
||||
},
|
||||
},
|
||||
local: {
|
||||
dir: localDir,
|
||||
installed: existsSync(join(localDir, "SKILL.md")),
|
||||
"hose-aipro": {
|
||||
global: {
|
||||
dir: globalAiProDir,
|
||||
installed: existsSync(join(globalAiProDir, "SKILL.md")),
|
||||
},
|
||||
local: {
|
||||
dir: localAiProDir,
|
||||
installed: existsSync(join(localAiProDir, "SKILL.md")),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -94,12 +160,14 @@ export async function handleSkillCommand(
|
||||
}
|
||||
|
||||
const output = printKeyValue({
|
||||
"全局 Skill 目录": `${globalDir} [${statusObj.global.installed ? "已安装 ✅" : "未安装 ❌"}]`,
|
||||
"本地 Skill 目录": `${localDir} [${statusObj.local.installed ? "已安装 ✅" : "未安装 ❌"}]`,
|
||||
"hose-use (全局)": `${globalHoseDir} [${statusObj["hose-use"].global.installed ? "已安装 ✅" : "未安装 ❌"}]`,
|
||||
"hose-aipro (全局)": `${globalAiProDir} [${statusObj["hose-aipro"].global.installed ? "已安装 ✅" : "未安装 ❌"}]`,
|
||||
"hose-use (本地)": `${localHoseDir} [${statusObj["hose-use"].local.installed ? "已安装 ✅" : "未安装 ❌"}]`,
|
||||
"hose-aipro (本地)": `${localAiProDir} [${statusObj["hose-aipro"].local.installed ? "已安装 ✅" : "未安装 ❌"}]`,
|
||||
});
|
||||
|
||||
return {
|
||||
stdout: `====== Agent Skill 状态 ======\n${output}\n\n提示: 运行 hose-use skill install --yes 进行全局安装\n`,
|
||||
stdout: `====== Agent Skill 状态 ======\n${output}\n\n提示: 运行 ${isAiProCaller ? "hose-aipro" : "hose-use"} skill install --yes 进行全局安装\n`,
|
||||
stderr: "",
|
||||
exitCode: 0,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user