refactor: 全面转向 CLI 驱动架构与底层 SDK,裁撤繁杂 MCP 工具并参考 seal-home 规范
This commit is contained in:
1 parent
3d549e2e2f
commit
e7aa8a86cc
19 files changed
+1228
-589
No files matched your search
@@ -0,0 +1,69 @@
|
||||
import { VERSION } from "../version.js";
|
||||
|
||||
export function printJson(data: unknown): string {
|
||||
return JSON.stringify(data, null, 2);
|
||||
}
|
||||
|
||||
export function printKeyValue(pairs: Record<string, unknown>): string {
|
||||
const lines: string[] = [];
|
||||
const maxKeyLen = Math.max(...Object.keys(pairs).map((k) => k.length), 0);
|
||||
|
||||
for (const [key, val] of Object.entries(pairs)) {
|
||||
const formattedVal = typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
|
||||
lines.push(` ${key.padEnd(maxKeyLen + 2)}: ${formattedVal}`);
|
||||
}
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
export function printTable(
|
||||
headers: string[],
|
||||
rows: Array<Array<string | number | boolean | null | undefined>>
|
||||
): string {
|
||||
if (rows.length === 0) return " (暂无数据)\n";
|
||||
|
||||
const strRows = rows.map((r) => r.map((c) => String(c ?? "")));
|
||||
const colWidths = headers.map((h, colIdx) => {
|
||||
const maxRowWidth = Math.max(...strRows.map((r) => (r[colIdx] || "").length), 0);
|
||||
return Math.max(h.length, maxRowWidth);
|
||||
});
|
||||
|
||||
const headerLine = headers.map((h, i) => h.padEnd(colWidths[i])).join(" ");
|
||||
const separatorLine = colWidths.map((w) => "-".repeat(w)).join(" ");
|
||||
const dataLines = strRows.map((r) =>
|
||||
r.map((c, i) => c.padEnd(colWidths[i])).join(" ")
|
||||
);
|
||||
|
||||
return [headerLine, separatorLine, ...dataLines].map((l) => ` ${l}`).join("\n");
|
||||
}
|
||||
|
||||
export function printHelp(): string {
|
||||
return `
|
||||
合思/易快报企业级 CLI 工具 (hose) v${VERSION}
|
||||
|
||||
用法:
|
||||
hose <命令域> <子命令> [参数] [选项]
|
||||
|
||||
核心命令域:
|
||||
auth 认证与凭证管理 (login, status, refresh, import, accounts)
|
||||
corps 多企业租户管理 (list, switch, current)
|
||||
workflow 工作流管理 (list, get, find, toggle)
|
||||
platform 自建应用管理 (list)
|
||||
probe 连通性诊断 (probe [corpId])
|
||||
mcp MCP Server 运行 (serve)
|
||||
version 查看版本信息
|
||||
|
||||
全局选项:
|
||||
--corp=<id> 临时指定操作的企业 ID (覆盖当前激活企业)
|
||||
--json, -j 以 JSON 结构化输出结果 (适合脚本/流水线集成)
|
||||
--help, -h 查看帮助信息
|
||||
|
||||
常用示例:
|
||||
hose auth login --phone=177... --password=... # 纯 API 账密自动登录
|
||||
hose auth status # 查看当前登录状态与活跃企业
|
||||
hose corps list # 列出名下所有企业
|
||||
hose corps switch uzU7pcWfScck00 # 切换工作企业
|
||||
hose workflow list # 汇总查看全部工作流
|
||||
hose workflow find --task=code-js2 # 搜索包含自定义脚本的工作流
|
||||
hose probe # 诊断当前企业鉴权连通性
|
||||
`.trim();
|
||||
}
|
||||
Reference in new issue
Block a user