feat: release v0.5.2 with protected contact domain and bill web link
🚀 Release / 🚀 Build & Publish Multi-Platform Binaries (push) Has been cancelled

This commit is contained in:
gitea committed 2026-09-03 15:58:20 +08:00
1 parent 188a0fb5dc
commit 68d570022d
19 files changed
+679 -146

No files matched your search

+62 -1
View File
@@ -195,7 +195,68 @@ export async function handleBillCommand(
};
}
case "link":
case "url": {
const target = parsed.args[0] || stringOption(parsed.options, ["code", "id", "c"]);
if (!target) {
return {
stdout: "",
stderr: "用法: hose bill link <单号或ID>",
exitCode: 1,
};
}
const items = await getBillByCodeOrId(client, corpId, target);
if (!items || items.length === 0) {
return {
stdout: "",
stderr: `未找到单据: ${target}`,
exitCode: 1,
};
}
const item = items[0];
const billId = item.billId;
const billCode = item.billCode || target;
const baseUrl = (corp.baseUrl || "https://app.ekuaibao.com").replace(/\/+$/, "");
const webUrl = `${baseUrl}/#/invoice/detail?id=${encodeURIComponent(billId)}&corporationId=${encodeURIComponent(corpId)}`;
if (runtime.jsonMode) {
return {
stdout: printJson(
{
code: billCode,
id: billId,
corpId,
corpName: corp.name,
url: webUrl,
},
runtime.outputOptions
),
stderr: "",
exitCode: 0,
};
}
const text = [
`====== 合思单据 Web 直达链接 ======`,
` 单据编号: ${billCode}`,
` 单据 ID : ${billId}`,
` 所属企业: ${corp.name} (${corpId})`,
` 直达链接:`,
` ${webUrl}`,
``,
`Markdown 链接: [查看单据 ${billCode}](${webUrl})`,
].join("\n");
return {
stdout: text + "\n",
stderr: "",
exitCode: 0,
};
}
default:
throw new Error(`未知 bill 子命令: ${action}。支持: list, get <单号>, schema`);
throw new Error(`未知 bill 子命令: ${action}。支持: list, get <单号>, schema, link <单号>`);
}
}
+155
View File
@@ -0,0 +1,155 @@
import { numberOption, stringOption } from "../parser.js";
import { printJson, printKeyValue, printTable } from "../printer.js";
import type { CliParsedArgs, CliResult, CliRuntime } from "../types.js";
import {
getStaffById,
listStaffsProtected,
searchStaffs,
DEFAULT_STAFF_LIST_LIMIT,
} from "../../domains/contact/tools.js";
export async function handleContactCommand(
parsed: CliParsedArgs,
runtime: CliRuntime
): Promise<CliResult> {
const corp = runtime.selectedCorp;
if (!corp) {
return {
stdout: "",
stderr: "未指定或未找到有效企业配置。请运行 'hose corps list' 或指定 '--corp=<id>'",
exitCode: 1,
};
}
const action = parsed.action || parsed.args[0] || "list";
const limit = numberOption(parsed.options, ["limit", "l"]);
// 1. 搜索: hose contact search <keyword> 或 hose 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 <关键词 (姓名/邮箱/工号)>",
exitCode: 1,
};
}
const results = await searchStaffs(corp, { keyword, limit });
if (runtime.jsonMode) {
return {
stdout: printJson({ count: results.length, keyword, staffs: results }, runtime.outputOptions),
stderr: "",
exitCode: 0,
};
}
if (results.length === 0) {
return {
stdout: `未找到匹配关键词 "${keyword}" 的员工。\n`,
stderr: "",
exitCode: 0,
};
}
const headers = ["姓名", "工号 / staffId", "邮箱", "手机号"];
const rows = results.map((s) => [
s.name || "-",
s.id,
s.email || "-",
s.cellphone || "-",
]);
return {
stdout: `====== 员工搜索结果 (关键词: "${keyword}", 找到 ${results.length} 人) ======\n${printTable(headers, rows)}\n`,
stderr: "",
exitCode: 0,
};
}
// 2. 详情: hose 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>",
exitCode: 1,
};
}
const staff = await getStaffById(corp, staffId);
if (!staff) {
return {
stdout: "",
stderr: `未找到员工档案: ${staffId}`,
exitCode: 1,
};
}
if (runtime.jsonMode) {
return {
stdout: printJson(staff, runtime.outputOptions),
stderr: "",
exitCode: 0,
};
}
const pairs: Record<string, unknown> = {
"员工姓名": staff.name,
"工号/staffId": staff.id,
"电子邮箱": staff.email || "-",
"联系手机": staff.cellphone || "-",
"所属部门": staff.department || "-",
};
return {
stdout: `====== 员工详细档案 ======\n${printKeyValue(pairs)}\n`,
stderr: "",
exitCode: 0,
};
}
// 3. 列表采样: hose contact list (默认限流截断防爆)
if (action === "list") {
const isFull = runtime.outputOptions?.allowFull === true;
const result = await listStaffsProtected(corp, {
limit: limit ?? (isFull ? undefined : DEFAULT_STAFF_LIST_LIMIT),
allowFull: isFull,
});
if (runtime.jsonMode) {
return {
stdout: printJson(result, runtime.outputOptions),
stderr: "",
exitCode: 0,
};
}
const headers = ["姓名", "工号 / staffId", "邮箱", "手机号"];
const rows = result.staffs.map((s) => [
s.name || "-",
s.id,
s.email || "-",
s.cellphone || "-",
]);
let output = `====== 企业通讯录采样 (共 ${result.total} 人,当前显示 ${result.staffs.length} 条) ======\n`;
output += printTable(headers, rows) + "\n";
if (result.hint) {
output += `\n💡 提示: ${result.hint}\n`;
}
return {
stdout: output,
stderr: "",
exitCode: 0,
};
}
return {
stdout: "",
stderr: `未知通讯录子命令: ${action}。支持的子命令: list, search <关键词>, get <staffId>`,
exitCode: 1,
};
}
+6 -2
View File
@@ -119,7 +119,8 @@ export function printHelp(): string {
corps 多企业租户管理 (list, switch, current)
config 全局运行模式与路径诊断 (show, paths, mode <stateful|stateless>, set)
workflow 工作流管理 (list, get, find, toggle)
bill 单据与费用明细检索 (list, get <单号|ID>, schema)
bill 单据与费用明细检索 (list, get <单号|ID>, schema, link <单号|ID>)
contact 企业通讯录与人员检索 (list, search <关键词>, get <staffId>)
platform 自建应用管理 (list)
skill Agent Skill 管理 (install, status, dump)
probe 连通性诊断 (probe [corpId])
@@ -145,10 +146,13 @@ export function printHelp(): string {
hose-use config paths # 查看多级企业配置目录链
hose-use config mode stateless # 切换为无状态模式 (防止 Agent 误操作)
hose-use corps list # 列出名下所有企业
hose-use corps switch uzU7pcWfScck00 # 切换工作企业
hose-use corps switch ID01MCcOgJl1td # 切换工作企业
hose-use contact search 张三 # 模糊搜索员工工号、邮箱与电话
hose-use contact list --limit=20 # 采样查看企业通讯录(带防爆截断保护)
hose-use workflow list # 汇总查看全部工作流
hose-use workflow find --task=code-js2 # 搜索包含自定义脚本的工作流
hose-use bill list # 查看当前企业单据与报销列表
hose-use bill link CL20260901001 # 获取单据 Web 详情直达免密跳转链接
hose-use bill list --json -o /tmp/bills.json # 导出单据报文到本地磁盘并防爆
hose-use bill get n0GMIM0dkQmKbS # 根据单号精准查询单据结构化详情
hose-use http --port=8888 # 启动本地 HTTP 服务与可视化交互文档
+6
View File
@@ -13,6 +13,7 @@ import { handleMcpCommand } from "./commands/mcp.js";
import { handleUpdateCommand } from "./commands/update.js";
import { handleOpenApiCommand } from "./commands/openapi.js";
import { handleBillCommand } from "./commands/bill.js";
import { handleContactCommand } from "./commands/contact.js";
import { handleServiceCommand } from "./commands/service.js";
import { handleHttpCommand } from "./commands/http.js";
import type { CliResult, CliRunOptions } from "./types.js";
@@ -129,6 +130,11 @@ async function dispatchCli(
case "invoice":
case "invoices":
return await handleBillCommand(parsed, runtime);
case "contact":
case "contacts":
case "staff":
case "staffs":
return await handleContactCommand(parsed, runtime);
case "platform":
case "platforms":
case "app":