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
+31
-82
@@ -9,21 +9,12 @@ import {
|
||||
ApprovalRepository,
|
||||
ApprovalGatewayBlockedError,
|
||||
} from "./domains/approval/index.js";
|
||||
import { formatVersionLabel, getVersionInfo } from "./version.js";
|
||||
import { handleAiProHelp, handleAiProLogs, handleAiProStatus } from "./cli/commands/aipro/status.js";
|
||||
import {
|
||||
handleAiProChecklist,
|
||||
handleAiProPoints,
|
||||
handleAiProRules,
|
||||
handleAiProScopes,
|
||||
} from "./cli/commands/aipro/rules.js";
|
||||
import {
|
||||
handleAiProBind,
|
||||
handleAiProDecide,
|
||||
handleAiProInit,
|
||||
handleAiProReview,
|
||||
handleAiProTranslate,
|
||||
} from "./cli/commands/aipro/session.js";
|
||||
findAiProCommand,
|
||||
isSaasPlatformCommand,
|
||||
handleSaasPlatformRedirect,
|
||||
} from "./cli/aipro-registry.js";
|
||||
import { handleAiProHelp } from "./cli/commands/aipro/status.js";
|
||||
import type { AiProExecutionContext } from "./cli/commands/aipro/types.js";
|
||||
|
||||
export async function runAiProCli(
|
||||
@@ -51,10 +42,21 @@ async function runAiProCliOnce(rawArgs: string[]): Promise<{ stdout: string; std
|
||||
const corp = runtime.selectedCorp;
|
||||
const previewPositional = parsed.positional || [];
|
||||
const previewCommand = (previewPositional[0] || "help").toLowerCase();
|
||||
const mutating = ["init", "start", "bind", "mount", "review", "eval", "evaluate", "decide", "approve", "reject"].includes(previewCommand) || (["points", "clauses"].includes(previewCommand) && previewPositional.length >= 3);
|
||||
if (mutating && isDryRun(parsed, runtime)) {
|
||||
return mutationPreview({ ...parsed, raw: ["aipro", ...rawArgs] }, runtime, "预览 AI PRO 审批操作", stringOption(parsed.options, ["run", "r", "code", "sn", "id", "target"]) || previewPositional[1] || "未指定", { action: previewCommand, corpId: corp?.corpId || corp?.id, apply: booleanOption(parsed.options, ["apply", "execute", "run", "do"]) });
|
||||
const previewDef = findAiProCommand(previewCommand);
|
||||
const isMutating = typeof previewDef?.mutating === "function"
|
||||
? previewDef.mutating(parsed, previewPositional)
|
||||
: Boolean(previewDef?.mutating);
|
||||
|
||||
if (isMutating && isDryRun(parsed, runtime)) {
|
||||
return mutationPreview(
|
||||
{ ...parsed, raw: ["hose-aipro", ...rawArgs] },
|
||||
runtime,
|
||||
"预览 AI PRO 审批操作",
|
||||
stringOption(parsed.options, ["run", "r", "code", "sn", "id", "target"]) || previewPositional[1] || "未指定",
|
||||
{ action: previewCommand, corpId: corp?.corpId || corp?.id, apply: booleanOption(parsed.options, ["apply", "execute", "run", "do"]) }
|
||||
);
|
||||
}
|
||||
|
||||
const repo = new ApprovalRepository();
|
||||
const service = new ApprovalService(repo);
|
||||
let cachedSession: Awaited<ReturnType<typeof getSessionClientForRuntime>> | undefined;
|
||||
@@ -95,74 +97,21 @@ async function runAiProCliOnce(rawArgs: string[]): Promise<{ stdout: string; std
|
||||
};
|
||||
|
||||
try {
|
||||
if (command === "version" || command === "v" || booleanOption(parsed.options, ["version", "v"])) {
|
||||
return {
|
||||
stdout: jsonMode
|
||||
? printJson(getVersionInfo("hose-aipro")) + "\n"
|
||||
: `${formatVersionLabel("hose-aipro")}\n`,
|
||||
stderr: "",
|
||||
exitCode: 0,
|
||||
};
|
||||
if (booleanOption(parsed.options, ["version", "v"])) {
|
||||
const versionDef = findAiProCommand("version");
|
||||
if (versionDef) return await versionDef.handler(ctx);
|
||||
}
|
||||
|
||||
switch (command) {
|
||||
case "status":
|
||||
case "whoami":
|
||||
case "context":
|
||||
case "info":
|
||||
return await handleAiProStatus(ctx);
|
||||
|
||||
case "init":
|
||||
case "start":
|
||||
return await handleAiProInit(ctx);
|
||||
|
||||
case "scopes":
|
||||
case "index":
|
||||
case "indexes":
|
||||
return await handleAiProScopes(ctx);
|
||||
|
||||
case "translate":
|
||||
case "doc":
|
||||
case "markdown":
|
||||
case "render":
|
||||
return await handleAiProTranslate(ctx);
|
||||
|
||||
case "rules":
|
||||
case "rule":
|
||||
return await handleAiProRules(ctx);
|
||||
|
||||
case "bind":
|
||||
case "mount":
|
||||
return await handleAiProBind(ctx);
|
||||
|
||||
case "points":
|
||||
case "clauses":
|
||||
return await handleAiProPoints(ctx);
|
||||
|
||||
case "checklist":
|
||||
case "list":
|
||||
return await handleAiProChecklist(ctx);
|
||||
|
||||
case "review":
|
||||
case "eval":
|
||||
case "evaluate":
|
||||
return await handleAiProReview(ctx);
|
||||
|
||||
case "decide":
|
||||
case "approve":
|
||||
case "reject":
|
||||
return await handleAiProDecide(ctx);
|
||||
|
||||
case "logs":
|
||||
case "log":
|
||||
case "history":
|
||||
case "trail":
|
||||
return await handleAiProLogs(ctx);
|
||||
|
||||
case "help":
|
||||
default:
|
||||
return handleAiProHelp(ctx);
|
||||
const commandDef = findAiProCommand(command);
|
||||
if (commandDef) {
|
||||
return await commandDef.handler(ctx);
|
||||
}
|
||||
|
||||
if (isSaasPlatformCommand(command)) {
|
||||
return handleSaasPlatformRedirect(command, positional);
|
||||
}
|
||||
|
||||
return await handleAiProHelp(ctx);
|
||||
} catch (err: any) {
|
||||
if (err instanceof ApprovalGatewayBlockedError) {
|
||||
repo.logAiProAction({
|
||||
|
||||
Reference in new issue
Block a user