fix: 显式标注 multicall 入口身份并补齐目录文档
- CliRuntime 新增 app?: "hose-use" | "hose-aipro",由 runCli 与 runAiProCli 各自标注;skill.ts 优先用它判断调用方,修复 hose-aipro skill dump 误输出 hose-use Skill 的既有 bug——根因是 multicall 二进制的 argv0 不会进入 parsed.raw。保留 raw 里的历史 aipro 标记作为兼容。 - 新增 skill.test.ts 覆盖两个入口与历史兼容三条路径。 - 补齐 4 份目录 README(scripts/build、cli/commands/aipro、web、 web/src):web/ 文件在 #177 合入后由 untracked 转为 tracked, 才被 check:readme 纳入扫描,暴露出 4 个目录缺文档。 校验:bun test 1111 pass / 0 fail,bun run check 通过, check:readme 36/36 通过;编译产物实测 hose-aipro skill dump 返回 AI PRO Skill、hose-use 返回平台 Skill。
This commit is contained in:
1 parent
50362c2937
commit
55573de6a8
9 files changed
+99
No files matched your search
@@ -0,0 +1,18 @@
|
||||
# AI PRO 命令层
|
||||
|
||||
`hose-aipro` 专属命令的 handler,由 `src/cli/aipro-registry.ts` 注册,经 `src/aipro-cli.ts` 的统一凭证门禁后分发。只读自省命令(`status` / `version` / `help` 等)豁免门禁,其余一律要求有效离线凭证。
|
||||
|
||||
| 文件 | 职责 |
|
||||
|---|---|
|
||||
| `status.ts` | 网关运行上下文、企业信息与帮助页 |
|
||||
| `rules.ts` | 规约场景、审核要点、核验清单 |
|
||||
| `bind.ts` | 单据挂载与会话初始化 |
|
||||
| `review.ts` | 事实证据核验打标(PASS / FAIL / SKIP) |
|
||||
| `decide.ts` | 确定性仲裁与流转 |
|
||||
| `logs.ts` | 审计流水查询 |
|
||||
| `service.ts` | 常驻服务控制 |
|
||||
| `report.ts` | `report --json` 聚合数据源,供本地 Web 控制台一次拉取场景 / 规则 / 会话 / 要点 / 流水 / 授权状态 |
|
||||
|
||||
`types.ts` 定义 `AiProExecutionContext` 与命令结果类型;`index.ts` 汇总导出。新增命令照常注册即可自动受门禁管辖,不需要改授权代码。
|
||||
|
||||
**边界**:凭证只作用于 `hose-aipro`;`hose-use` 是免费功能,不受任何激活门禁约束。
|
||||
@@ -0,0 +1,37 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { handleSkillCommand } from "./skill.js";
|
||||
import { getAiProSkillContent, getSkillContent } from "../../packaging/embedded-skill.js";
|
||||
|
||||
const parsed = {
|
||||
area: "skill",
|
||||
action: "dump",
|
||||
args: [],
|
||||
options: {},
|
||||
raw: ["skill", "dump"],
|
||||
};
|
||||
|
||||
const baseRuntime = {
|
||||
selectedCorp: null,
|
||||
corpContext: {},
|
||||
jsonMode: false,
|
||||
};
|
||||
|
||||
describe("skill dump 的 multicall 入口识别", () => {
|
||||
test("hose-aipro 入口返回 AI PRO Skill(不依赖 argv0 猜测)", async () => {
|
||||
const result = await handleSkillCommand(parsed as never,{ ...baseRuntime, app: "hose-aipro" } as never);
|
||||
expect(result.stdout).toBe(`${getAiProSkillContent()}\n`);
|
||||
expect(result.stdout).toContain("hose-aipro (v");
|
||||
});
|
||||
|
||||
test("hose-use 入口返回平台 Skill", async () => {
|
||||
const result = await handleSkillCommand(parsed as never,{ ...baseRuntime, app: "hose-use" } as never);
|
||||
expect(result.stdout).toBe(`${getSkillContent()}\n`);
|
||||
expect(result.stdout).toContain("hose-use (v");
|
||||
});
|
||||
|
||||
test("兼容历史:未标注 app 时仍按 parsed.raw 里的 aipro 标记识别", async () => {
|
||||
const legacyParsed = { ...parsed, raw: ["skill", "dump", "aipro"] };
|
||||
const result = await handleSkillCommand(legacyParsed as never, baseRuntime as never);
|
||||
expect(result.stdout).toBe(`${getAiProSkillContent()}\n`);
|
||||
});
|
||||
});
|
||||
@@ -22,6 +22,7 @@ export async function handleSkillCommand(
|
||||
): Promise<CliResult> {
|
||||
const action = parsed.action || "status";
|
||||
const isAiProCaller =
|
||||
runtime.app === "hose-aipro" ||
|
||||
parsed.area === "hose-aipro" ||
|
||||
parsed.raw.some((arg) => arg.includes("hose-aipro") || arg === "aipro");
|
||||
|
||||
|
||||
@@ -162,6 +162,7 @@ async function dispatchParsedCli(
|
||||
launcher: options.launcher,
|
||||
});
|
||||
runtime.writeStdout = options.writeStdout;
|
||||
runtime.app = "hose-use";
|
||||
|
||||
try {
|
||||
if (!parsed.area) {
|
||||
|
||||
@@ -44,6 +44,8 @@ export interface CliRuntime {
|
||||
outputOptions?: OutputOptions;
|
||||
appRoot?: string;
|
||||
entryFile?: string;
|
||||
/** 入口身份,由 runCli / runAiProCli 显式标注,供命令层区分 multicall 调用方。 */
|
||||
app?: "hose-use" | "hose-aipro";
|
||||
launcher?: {
|
||||
command: string;
|
||||
args?: string[];
|
||||
|
||||
Reference in new issue
Block a user