refactor(cli): purge short hose alias and standardize on hose-use across docs, scripts, and prompts

This commit is contained in:
gitea committed 2026-09-06 22:26:04 +08:00
1 parent 304a8c0d98
commit 2f8bcb90c9
31 files changed
+190 -191

No files matched your search

+2 -2
View File
@@ -309,7 +309,7 @@ async function handleAccounts(parsed: CliParsedArgs, runtime: CliRuntime): Promi
}
if (accounts.length === 0) {
return { stdout: "暂无保存的账号,请使用 hose auth login 登录\n", stderr: "", exitCode: 0 };
return { stdout: "暂无保存的账号,请使用 hose-use auth login 登录\n", stderr: "", exitCode: 0 };
}
const rows = accounts.map((acc, i) => [
@@ -327,7 +327,7 @@ async function handleAccounts(parsed: CliParsedArgs, runtime: CliRuntime): Promi
async function handleSwitchAccount(parsed: CliParsedArgs, runtime: CliRuntime): Promise<CliResult> {
const target = parsed.args[0] || stringOption(parsed.options, ["account", "a"]);
if (!target) {
return { stdout: "", stderr: "用法: hose auth switch-account <accountId>\n", exitCode: 1 };
return { stdout: "", stderr: "用法: hose-use auth switch-account <accountId>\n", exitCode: 1 };
}
const success = setActiveAccount(target);
+14 -14
View File
@@ -27,7 +27,7 @@ export async function handleBillCommand(
const corp = runtime.selectedCorp;
if (!corp) {
throw new Error(
"未指定或未找到有效企业。请通过 --corp=<id> 指定企业,或运行 hose auth login 登录。"
"未指定或未找到有效企业。请通过 --corp=<id> 指定企业,或运行 hose-use auth login 登录。"
);
}
@@ -75,7 +75,7 @@ export async function handleBillCommand(
case "agree": {
await requireWriteConfirmation();
const target = actionTarget();
if (!target) throw new Error("请提供审批任务、单号或单据 ID: hose bill approve <单号|ID> --yes");
if (!target) throw new Error("请提供审批任务、单号或单据 ID: hose-use bill approve <单号|ID> --yes");
const result = await approveBill(client, corpId, target, actionOptions());
if (runtime.jsonMode) return { stdout: printJson(result, runtime.outputOptions), stderr: "", exitCode: 0 };
return { stdout: `审批同意成功\n单号: ${result.billCode || target}\n任务 ID: ${result.backlogId}\n`, stderr: "", exitCode: 0 };
@@ -85,7 +85,7 @@ export async function handleBillCommand(
case "deny": {
await requireWriteConfirmation();
const target = actionTarget();
if (!target) throw new Error("请提供审批任务、单号或单据 ID: hose bill reject <单号|ID> --comment <原因> --yes");
if (!target) throw new Error("请提供审批任务、单号或单据 ID: hose-use bill reject <单号|ID> --comment <原因> --yes");
const options = actionOptions();
if (!options.comment?.trim()) throw new Error("驳回原因不能为空,请通过 --comment 提供原因");
const result = await rejectBill(client, corpId, target, options);
@@ -97,7 +97,7 @@ export async function handleBillCommand(
case "shift": {
await requireWriteConfirmation();
const target = actionTarget();
if (!target) throw new Error("请提供审批任务、单号或单据 ID: hose bill transfer <单号|ID> --approver-id <员工ID> --yes");
if (!target) throw new Error("请提供审批任务、单号或单据 ID: hose-use bill transfer <单号|ID> --approver-id <员工ID> --yes");
const options = { ...actionOptions(), approverIds: await resolveApproverIds(actionOptions().approverIds) };
const result = await transferBill(client, corpId, target, options);
if (runtime.jsonMode) return { stdout: printJson(result, runtime.outputOptions), stderr: "", exitCode: 0 };
@@ -110,7 +110,7 @@ export async function handleBillCommand(
case "counter-sign": {
await requireWriteConfirmation();
const target = actionTarget();
if (!target) throw new Error("请提供审批任务、单号或单据 ID: hose bill add-node <单号|ID> --approver-id <员工ID> --yes");
if (!target) throw new Error("请提供审批任务、单号或单据 ID: hose-use bill add-node <单号|ID> --approver-id <员工ID> --yes");
const options = { ...actionOptions(), approverIds: await resolveApproverIds(actionOptions().approverIds) };
const result = await addNodeBill(client, corpId, target, options);
if (runtime.jsonMode) return { stdout: printJson(result, runtime.outputOptions), stderr: "", exitCode: 0 };
@@ -121,7 +121,7 @@ export async function handleBillCommand(
case "remark": {
await requireWriteConfirmation();
const target = actionTarget();
if (!target) throw new Error("请提供单号或单据 ID: hose bill comment <单号|ID> --comment <内容> --yes");
if (!target) throw new Error("请提供单号或单据 ID: hose-use bill comment <单号|ID> --comment <内容> --yes");
const result = await commentBill(client, corpId, target, actionOptions());
if (runtime.jsonMode) return { stdout: printJson(result, runtime.outputOptions), stderr: "", exitCode: 0 };
return { stdout: `单据评论成功\n单号: ${result.billCode || target}\n流程 ID: ${result.flowId}\n`, stderr: "", exitCode: 0 };
@@ -326,7 +326,7 @@ export async function handleBillCommand(
case "records":
case "timeline": {
const target = parsed.args[0] || stringOption(parsed.options, ["code", "id"]);
if (!target) throw new Error("请提供要查询流程的单号或单据 ID: hose bill flow <单号|ID>");
if (!target) throw new Error("请提供要查询流程的单号或单据 ID: hose-use bill flow <单号|ID>");
const flow = await getBillFlow(client, corpId, target);
if (!flow) {
if (runtime.jsonMode) return { stdout: printJson({ found: false, target }, runtime.outputOptions), stderr: "", exitCode: 1 };
@@ -368,7 +368,7 @@ export async function handleBillCommand(
case "review":
case "warnings": {
const target = parsed.args[0] || stringOption(parsed.options, ["code", "id"]);
if (!target) throw new Error("请提供要查询风控结果的单号或单据 ID: hose bill risk <单号|ID>");
if (!target) throw new Error("请提供要查询风控结果的单号或单据 ID: hose-use bill risk <单号|ID>");
const report = await getBillRisk(client, corpId, target);
if (!report) {
if (runtime.jsonMode) return { stdout: printJson({ found: false, target }, runtime.outputOptions), stderr: "", exitCode: 1 };
@@ -398,7 +398,7 @@ export async function handleBillCommand(
case "budget":
case "budgets": {
const target = parsed.args[0] || stringOption(parsed.options, ["code", "id"]);
if (!target) throw new Error("请提供要查询预算状态的单号或单据 ID: hose bill budget <单号|ID>");
if (!target) throw new Error("请提供要查询预算状态的单号或单据 ID: hose-use bill budget <单号|ID>");
const report = await getBillRisk(client, corpId, target);
if (!report) {
if (runtime.jsonMode) return { stdout: printJson({ found: false, target }, runtime.outputOptions), stderr: "", exitCode: 1 };
@@ -424,7 +424,7 @@ export async function handleBillCommand(
case "references":
case "resolve": {
const target = parsed.args[0] || stringOption(parsed.options, ["code", "id"]);
if (!target) throw new Error("请提供要解析引用的单号或单据 ID: hose bill refs <单号|ID>");
if (!target) throw new Error("请提供要解析引用的单号或单据 ID: hose-use bill refs <单号|ID>");
const report = await getBillReferences(client, corpId, target);
if (!report) {
if (runtime.jsonMode) return { stdout: printJson({ found: false, target }, runtime.outputOptions), stderr: "", exitCode: 1 };
@@ -453,7 +453,7 @@ export async function handleBillCommand(
case "relation":
case "links": {
const target = parsed.args[0] || stringOption(parsed.options, ["code", "id"]);
if (!target) throw new Error("请提供要查询关联关系的单号或单据 ID: hose bill relations <单号|ID>");
if (!target) throw new Error("请提供要查询关联关系的单号或单据 ID: hose-use bill relations <单号|ID>");
const report = await getBillRelations(client, corpId, target);
if (!report) {
if (runtime.jsonMode) return { stdout: printJson({ found: false, target }, runtime.outputOptions), stderr: "", exitCode: 1 };
@@ -486,7 +486,7 @@ export async function handleBillCommand(
case "attachment":
case "files": {
const target = parsed.args[0] || stringOption(parsed.options, ["code", "id"]);
if (!target) throw new Error("请提供要查询附件的单号或单据 ID: hose bill attachments <单号|ID>");
if (!target) throw new Error("请提供要查询附件的单号或单据 ID: hose-use bill attachments <单号|ID>");
const report = await getBillAttachments(client, corpId, target);
if (!report) {
if (runtime.jsonMode) return { stdout: printJson({ found: false, target }, runtime.outputOptions), stderr: "", exitCode: 1 };
@@ -507,7 +507,7 @@ export async function handleBillCommand(
case "download":
case "file-download": {
const target = parsed.args[0] || stringOption(parsed.options, ["code", "id"]);
if (!target) throw new Error("请提供要下载附件的单号或单据 ID: hose bill download <单号|ID>");
if (!target) throw new Error("请提供要下载附件的单号或单据 ID: hose-use bill download <单号|ID>");
const outputDir = stringOption(parsed.options, ["output-dir", "dir"]) || `${process.cwd()}/downloads`;
const fileId = stringOption(parsed.options, ["file-id", "file"]);
const result = await downloadBillAttachments(client, corpId, target, outputDir, fileId);
@@ -540,7 +540,7 @@ export async function handleBillCommand(
if (!target) {
return {
stdout: "",
stderr: "用法: hose bill link <单号或ID>",
stderr: "用法: hose-use bill link <单号或ID>",
exitCode: 1,
};
}
+3 -3
View File
@@ -67,7 +67,7 @@ async function handleShow(parsed: CliParsedArgs, runtime: CliRuntime): Promise<C
});
return {
stdout: `====== 全局运行配置 ======\n${output}\n\n提示:\n 切换模式: hose config mode <stateful|stateless>\n 指定企业: hose corps switch <corpId>\n 更新源设置: hose config set updateSource <auto|github|gitea>\n`,
stdout: `====== 全局运行配置 ======\n${output}\n\n提示:\n 切换模式: hose-use config mode <stateful|stateless>\n 指定企业: hose-use corps switch <corpId>\n 更新源设置: hose-use config set updateSource <auto|github|gitea>\n`,
stderr: "",
exitCode: 0,
};
@@ -79,7 +79,7 @@ async function handleMode(parsed: CliParsedArgs, runtime: CliRuntime): Promise<C
if (!targetMode || (targetMode !== "stateful" && targetMode !== "stateless")) {
return {
stdout: "",
stderr: "用法: hose config mode <stateful|stateless>\n",
stderr: "用法: hose-use config mode <stateful|stateless>\n",
exitCode: 1,
};
}
@@ -105,7 +105,7 @@ async function handleSet(parsed: CliParsedArgs, runtime: CliRuntime): Promise<Cl
if (!rawKey || val === undefined) {
return {
stdout: "",
stderr: "用法: hose config set <key> <val> (如 hose config set defaultCorpId uzU7pcWfScck00)\n",
stderr: "用法: hose-use config set <key> <val> (如 hose-use config set defaultCorpId uzU7pcWfScck00)\n",
exitCode: 1,
};
}
+6 -6
View File
@@ -16,7 +16,7 @@ export async function handleContactCommand(
if (!corp) {
return {
stdout: "",
stderr: "未指定或未找到有效企业配置。请运行 'hose corps list' 或指定 '--corp=<id>'",
stderr: "未指定或未找到有效企业配置。请运行 'hose-use corps list' 或指定 '--corp=<id>'",
exitCode: 1,
};
}
@@ -24,13 +24,13 @@ export async function handleContactCommand(
const action = parsed.action || parsed.args[0] || "list";
const limit = numberOption(parsed.options, ["limit", "l"]);
// 1. 搜索: hose contact search <keyword> 或 hose contact find <keyword>
// 1. 搜索: hose-use contact search <keyword> 或 hose-use contact find <keyword>
if (action === "search" || action === "find") {
const keyword = parsed.args[0] || stringOption(parsed.options, ["keyword", "query", "k"]) || "";
if (!keyword.trim()) {
return {
stdout: "",
stderr: "用法: hose contact search <关键词 (姓名/邮箱/工号)>",
stderr: "用法: hose-use contact search <关键词 (姓名/邮箱/工号)>",
exitCode: 1,
};
}
@@ -67,13 +67,13 @@ export async function handleContactCommand(
};
}
// 2. 详情: hose contact get <staffId>
// 2. 详情: hose-use contact get <staffId>
if (action === "get") {
const staffId = parsed.args[0] || stringOption(parsed.options, ["id", "staff-id"]);
if (!staffId) {
return {
stdout: "",
stderr: "用法: hose contact get <staffId>",
stderr: "用法: hose-use contact get <staffId>",
exitCode: 1,
};
}
@@ -110,7 +110,7 @@ export async function handleContactCommand(
};
}
// 3. 列表采样: hose contact list (默认限流截断防爆)
// 3. 列表采样: hose-use contact list (默认限流截断防爆)
if (action === "list") {
const isFull = runtime.outputOptions?.allowFull === true;
const result = await listStaffsProtected(corp, {
+4 -4
View File
@@ -42,7 +42,7 @@ async function handleList(parsed: CliParsedArgs, runtime: CliRuntime): Promise<C
}
if (corps.length === 0) {
return { stdout: "未找到任何企业配置,请先运行 hose auth login\n", stderr: "", exitCode: 0 };
return { stdout: "未找到任何企业配置,请先运行 hose-use auth login\n", stderr: "", exitCode: 0 };
}
const rows = corps.map((c, i) => [
@@ -61,7 +61,7 @@ async function handleList(parsed: CliParsedArgs, runtime: CliRuntime): Promise<C
);
return {
stdout: `====== 已配置企业列表 (${corps.length} 家) ======\n${table}\n\n提示: 使用 hose corps switch <企业ID> 切换工作企业\n`,
stdout: `====== 已配置企业列表 (${corps.length} 家) ======\n${table}\n\n提示: 使用 hose-use corps switch <企业ID> 切换工作企业\n`,
stderr: "",
exitCode: 0,
};
@@ -70,14 +70,14 @@ async function handleList(parsed: CliParsedArgs, runtime: CliRuntime): Promise<C
async function handleSwitch(parsed: CliParsedArgs, runtime: CliRuntime): Promise<CliResult> {
const corpId = parsed.args[0];
if (!corpId) {
return { stdout: "", stderr: "用法: hose corps switch <企业ID>\n", exitCode: 1 };
return { stdout: "", stderr: "用法: hose-use corps switch <企业ID>\n", exitCode: 1 };
}
const success = runtime.corpContext.switchCorp(corpId);
if (!success) {
return {
stdout: "",
stderr: `企业 ${corpId} 不存在或未配置。可运行 hose corps list 查看可用列表。\n`,
stderr: `企业 ${corpId} 不存在或未配置。可运行 hose-use corps list 查看可用列表。\n`,
exitCode: 1,
};
}
+2 -2
View File
@@ -6,7 +6,7 @@ import { searchDimensions, resolveDimension } from "../../domains/dimension/tool
export async function handleDimensionCommand(parsed: CliParsedArgs, runtime: CliRuntime): Promise<CliResult> {
const corp = runtime.selectedCorp;
if (!corp) throw new Error("未指定或未找到有效企业。请通过 --corp=<id> 指定企业,或运行 hose auth login 登录。");
if (!corp) throw new Error("未指定或未找到有效企业。请通过 --corp=<id> 指定企业,或运行 hose-use auth login 登录。");
const client = await createEkbClient(corp);
const corpId = corp.corpId || corp.id;
const action = parsed.action?.toLowerCase() || "list";
@@ -19,7 +19,7 @@ export async function handleDimensionCommand(parsed: CliParsedArgs, runtime: Cli
}
if (["items", "get", "show"].includes(action)) {
const target = parsed.args[0] || stringOption(parsed.options, ["dimension", "id", "code", "name"]);
if (!target) throw new Error("请提供档案维度 ID、编码或名称: hose dimension items <维度>");
if (!target) throw new Error("请提供档案维度 ID、编码或名称: hose-use dimension items <维度>");
const result = await resolveDimension(client, corpId, target);
if (!result) {
if (runtime.jsonMode) return { stdout: printJson({ found: false, target }, runtime.outputOptions), stderr: "", exitCode: 1 };
+2 -2
View File
@@ -24,7 +24,7 @@ function renderItems(items: MessageItem[]): string {
export async function handleMessageCommand(parsed: CliParsedArgs, runtime: CliRuntime): Promise<CliResult> {
const corp = runtime.selectedCorp;
if (!corp) throw new Error("未指定或未找到有效企业。请运行 hose corps list 或指定 --corp=<id>");
if (!corp) throw new Error("未指定或未找到有效企业。请运行 hose-use corps list 或指定 --corp=<id>");
const action = parsed.action || parsed.args[0] || "list";
const client = await createEkbClient(corp);
const corpId = corp.corpId || corp.id;
@@ -37,7 +37,7 @@ export async function handleMessageCommand(parsed: CliParsedArgs, runtime: CliRu
if (action === "read" || action === "mark-read") {
const messageId = parsed.args[0] || stringOption(parsed.options, ["id", "message-id"]);
if (!messageId) return { stdout: "", stderr: "用法: hose message read <messageId>\n", exitCode: 1 };
if (!messageId) return { stdout: "", stderr: "用法: hose-use message read <messageId>\n", exitCode: 1 };
await readMessage(client, corpId, messageId);
if (runtime.jsonMode) return { stdout: printJson({ corpId, id: messageId, read: true }, runtime.outputOptions), stderr: "", exitCode: 0 };
return { stdout: `已标记消息为已读: ${messageId}\n`, stderr: "", exitCode: 0 };
+1 -1
View File
@@ -5,7 +5,7 @@ import { getPermissions } from "../../domains/permission/tools.js";
export async function handlePermissionCommand(parsed: CliParsedArgs, runtime: CliRuntime): Promise<CliResult> {
const corp = runtime.selectedCorp;
if (!corp) throw new Error("未指定或未找到有效企业。请通过 --corp=<id> 指定企业,或运行 hose auth login 登录。");
if (!corp) throw new Error("未指定或未找到有效企业。请通过 --corp=<id> 指定企业,或运行 hose-use auth login 登录。");
const action = parsed.action?.toLowerCase() || "get";
if (!["get", "list", "show"].includes(action)) throw new Error(`未知 permission 子命令: ${action}。支持: get`);
const client = await createEkbClient(corp);
+1 -1
View File
@@ -11,7 +11,7 @@ export async function handlePlatformCommand(
if (!currentCorp) {
return {
stdout: "",
stderr: "未选中企业,请先通过 hose corps switch 或 --corp 指定企业\n",
stderr: "未选中企业,请先通过 hose-use corps switch 或 --corp 指定企业\n",
exitCode: 1,
};
}
+1 -1
View File
@@ -11,7 +11,7 @@ export async function handleProbeCommand(
if (!currentCorp) {
return {
stdout: "",
stderr: "未配置任何企业,请先运行 hose auth login 或使用 --corp 指定\n",
stderr: "未配置任何企业,请先运行 hose-use auth login 或使用 --corp 指定\n",
exitCode: 1,
};
}
+2 -2
View File
@@ -6,7 +6,7 @@ import { getRoleGroups, getRoleMembers, searchRoles } from "../../domains/role/t
export async function handleRoleCommand(parsed: CliParsedArgs, runtime: CliRuntime): Promise<CliResult> {
const corp = runtime.selectedCorp;
if (!corp) throw new Error("未指定或未找到有效企业。请通过 --corp=<id> 指定企业,或运行 hose auth login 登录。");
if (!corp) throw new Error("未指定或未找到有效企业。请通过 --corp=<id> 指定企业,或运行 hose-use auth login 登录。");
const client = await createEkbClient(corp), corpId = corp.corpId || corp.id;
const action = parsed.action?.toLowerCase() || "list";
if (["list", "search"].includes(action)) {
@@ -26,7 +26,7 @@ export async function handleRoleCommand(parsed: CliParsedArgs, runtime: CliRunti
}
if (["members", "member", "staffs", "staff"].includes(action)) {
const target = parsed.args[0] || stringOption(parsed.options, ["role", "id", "code", "name"]);
if (!target) throw new Error("请提供角色 ID、编码或名称: hose role members <角色>");
if (!target) throw new Error("请提供角色 ID、编码或名称: hose-use role members <角色>");
const report = await getRoleMembers(client, corpId, target);
if (!report) {
if (runtime.jsonMode) return { stdout: printJson({ found: false, target }, runtime.outputOptions), stderr: "", exitCode: 1 };
+1 -1
View File
@@ -15,7 +15,7 @@ function dateOption(value: string | undefined): number | undefined {
export async function handleTaskCommand(parsed: CliParsedArgs, runtime: CliRuntime): Promise<CliResult> {
const corp = runtime.selectedCorp;
if (!corp) throw new Error("未指定或未找到有效企业。请运行 hose corps list 或指定 --corp=<id>");
if (!corp) throw new Error("未指定或未找到有效企业。请运行 hose-use corps list 或指定 --corp=<id>");
const action = parsed.action || parsed.args[0] || "todo";
const view: TaskView | undefined = action === "todo" || action === "pending"
? "todo"
+5 -5
View File
@@ -17,7 +17,7 @@ export async function handleWorkflowCommand(
if (!currentCorp) {
return {
stdout: "",
stderr: "未选中企业,请先通过 hose corps switch 或 --corp 指定企业\n",
stderr: "未选中企业,请先通过 hose-use corps switch 或 --corp 指定企业\n",
exitCode: 1,
};
}
@@ -52,7 +52,7 @@ export async function handleWorkflowCommand(
async function handleAnalyze(parsed: CliParsedArgs, runtime: CliRuntime): Promise<CliResult> {
const pipelineId = parsed.args[0] || stringOption(parsed.options, ["id", "pipelineId"]);
if (!pipelineId) return { stdout: "", stderr: "用法: hose workflow analyze <pipelineId>\n", exitCode: 1 };
if (!pipelineId) return { stdout: "", stderr: "用法: hose-use workflow analyze <pipelineId>\n", exitCode: 1 };
const clients = await createClientsForCorp(runtime.selectedCorp!);
const detail = await api.getWorkflowDetail(clients.easoClient, pipelineId);
const result = analyzeWorkflow(detail);
@@ -110,7 +110,7 @@ async function handleList(parsed: CliParsedArgs, runtime: CliRuntime): Promise<C
async function handleGet(parsed: CliParsedArgs, runtime: CliRuntime): Promise<CliResult> {
const pipelineId = parsed.args[0] || stringOption(parsed.options, ["id", "pipelineId"]);
if (!pipelineId) {
return { stdout: "", stderr: "用法: hose workflow get <pipelineId>\n", exitCode: 1 };
return { stdout: "", stderr: "用法: hose-use workflow get <pipelineId>\n", exitCode: 1 };
}
const clients = await createClientsForCorp(runtime.selectedCorp!);
@@ -152,7 +152,7 @@ async function handleFind(parsed: CliParsedArgs, runtime: CliRuntime): Promise<C
if (!taskType) {
return {
stdout: "",
stderr: "用法: hose workflow find --task=<节点类型> (如 code-js2, http, condition)\n",
stderr: "用法: hose-use workflow find --task=<节点类型> (如 code-js2, http, condition)\n",
exitCode: 1,
};
}
@@ -207,7 +207,7 @@ async function handleToggle(parsed: CliParsedArgs, runtime: CliRuntime): Promise
if (!pipelineId || stateArg === undefined) {
return {
stdout: "",
stderr: "用法: hose workflow toggle <pipelineId> --state=<1|0> (1启用, 0停用)\n",
stderr: "用法: hose-use workflow toggle <pipelineId> --state=<1|0> (1启用, 0停用)\n",
exitCode: 1,
};
}
+1 -1
View File
@@ -229,7 +229,7 @@ async function dispatchCli(
default:
return {
stdout: "",
stderr: `未知命令域: ${parsed.area}。运行 hose --help 查看帮助\n`,
stderr: `未知命令域: ${parsed.area}。运行 hose-use --help 查看帮助\n`,
exitCode: 1,
};
}
+1 -1
View File
@@ -39,7 +39,7 @@ export async function runServiceCommand(
case undefined:
return serviceStatus(config);
default:
throw new Error("用法: hose service <start|stop|restart|status|logs|poll>");
throw new Error("用法: hose-use service <start|stop|restart|status|logs|poll>");
}
}