Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf5d12b0a5 | ||
|
|
535404871c | ||
|
|
269b7e8f0f | ||
|
|
c99c5d98ec | ||
|
|
4fbd737402 |
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hose-use",
|
"name": "hose-use",
|
||||||
"version": "0.6.0",
|
"version": "0.6.1",
|
||||||
"description": "合思/易快报 (ekuaibao) 企业级 SaaS CLI 与底层 SDK:多账号登录、企业租户切换、单据明细检索、工作流管理、内置 HTTP 服务与常驻守护进程。",
|
"description": "合思/易快报 (ekuaibao) 企业级 SaaS CLI 与底层 SDK:多账号登录、企业租户切换、单据明细检索、工作流管理、内置 HTTP 服务与常驻守护进程。",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "yingqing"
|
"name": "yingqing"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# hose-use (v0.6.0)
|
# hose-use (v0.6.1)
|
||||||
|
|
||||||
合思/易快报(ekuaibao)企业级 CLI 命令行工具与底层 SDK。
|
合思/易快报(ekuaibao)企业级 CLI 命令行工具与底层 SDK。
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
"openapi": "3.1.0",
|
"openapi": "3.1.0",
|
||||||
"info": {
|
"info": {
|
||||||
"title": "hose-use API & MCP Tools Specification",
|
"title": "hose-use API & MCP Tools Specification",
|
||||||
"version": "0.6.0",
|
"version": "0.6.1",
|
||||||
"description": "Unified Enterprise SaaS API, CLI, and MCP Specification for Ekuaibao (合思/易快报), EASO, and Piper Workflows."
|
"description": "Unified Enterprise SaaS API, CLI, and MCP Specification for Ekuaibao (合思/易快报), EASO, and Piper Workflows."
|
||||||
},
|
},
|
||||||
"servers": [
|
"servers": [
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
openapi: 3.1.0
|
openapi: 3.1.0
|
||||||
info:
|
info:
|
||||||
title: hose-use API & MCP Tools Specification
|
title: hose-use API & MCP Tools Specification
|
||||||
version: 0.6.0
|
version: 0.6.1
|
||||||
description: >-
|
description: >-
|
||||||
Unified Enterprise SaaS API, CLI, and MCP Specification for Ekuaibao (合思/易快报), EASO, and Piper Workflows.
|
Unified Enterprise SaaS API, CLI, and MCP Specification for Ekuaibao (合思/易快报), EASO, and Piper Workflows.
|
||||||
servers:
|
servers:
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hose-use",
|
"name": "hose-use",
|
||||||
"version": "0.6.0",
|
"version": "0.6.1",
|
||||||
"module": "src/server.ts",
|
"module": "src/server.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ metadata:
|
|||||||
short-description: 合思/易快报企业级 CLI 工具与底层 SDK (v0.6.0)
|
short-description: 合思/易快报企业级 CLI 工具与底层 SDK (v0.6.0)
|
||||||
---
|
---
|
||||||
|
|
||||||
# hose-use (v0.6.0)
|
# hose-use (v0.6.1)
|
||||||
|
|
||||||
在具备 MCP 的 AI 智能体环境中,**优先使用 `hose_cli` 单工具网关**,传入 `command: string` 执行;在终端或自动化脚本中,直接调用全局 `hose` 或 `hose-use` 命令行。
|
在具备 MCP 的 AI 智能体环境中,**优先使用 `hose_cli` 单工具网关**,传入 `command: string` 执行;在终端或自动化脚本中,直接调用全局 `hose` 或 `hose-use` 命令行。
|
||||||
本 Skill 是智能体的路由分发层:保持主文档简明,遇到复杂业务时深入查阅对应的专属参考文档(`references/*.md`)。
|
本 Skill 是智能体的路由分发层:保持主文档简明,遇到复杂业务时深入查阅对应的专属参考文档(`references/*.md`)。
|
||||||
|
|||||||
+12
-5
@@ -8,6 +8,7 @@ const KNOWN_BOOLEAN_FLAGS = new Set([
|
|||||||
"h",
|
"h",
|
||||||
"version",
|
"version",
|
||||||
"v",
|
"v",
|
||||||
|
"V",
|
||||||
"force",
|
"force",
|
||||||
"f",
|
"f",
|
||||||
"stateless",
|
"stateless",
|
||||||
@@ -48,8 +49,10 @@ export function parseArgs(rawArgs: string[]): CliParsedArgs {
|
|||||||
options[key] = val;
|
options[key] = val;
|
||||||
} else {
|
} else {
|
||||||
const key = arg.slice(2);
|
const key = arg.slice(2);
|
||||||
if (KNOWN_BOOLEAN_FLAGS.has(key)) {
|
const keyLower = key.toLowerCase();
|
||||||
|
if (KNOWN_BOOLEAN_FLAGS.has(key) || KNOWN_BOOLEAN_FLAGS.has(keyLower)) {
|
||||||
options[key] = true;
|
options[key] = true;
|
||||||
|
if (key !== keyLower) options[keyLower] = true;
|
||||||
} else {
|
} else {
|
||||||
const next = rawArgs[i + 1];
|
const next = rawArgs[i + 1];
|
||||||
if (next && !next.startsWith("-")) {
|
if (next && !next.startsWith("-")) {
|
||||||
@@ -65,10 +68,14 @@ export function parseArgs(rawArgs: string[]): CliParsedArgs {
|
|||||||
|
|
||||||
if (arg.startsWith("-") && arg.length > 1) {
|
if (arg.startsWith("-") && arg.length > 1) {
|
||||||
const flag = arg.slice(1);
|
const flag = arg.slice(1);
|
||||||
if (flag === "h") options.help = true;
|
const flagLower = flag.toLowerCase();
|
||||||
else if (flag === "j") options.json = true;
|
if (flagLower === "h" || flag === "?") {
|
||||||
else if (flag === "v") options.version = true;
|
options.help = true;
|
||||||
else if (flag === "o") {
|
} else if (flagLower === "j") {
|
||||||
|
options.json = true;
|
||||||
|
} else if (flagLower === "v") {
|
||||||
|
options.version = true;
|
||||||
|
} else if (flag === "o") {
|
||||||
const next = rawArgs[i + 1];
|
const next = rawArgs[i + 1];
|
||||||
if (next && !next.startsWith("-")) {
|
if (next && !next.startsWith("-")) {
|
||||||
options.outputFile = next;
|
options.outputFile = next;
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
import { describe, expect, it } from "bun:test";
|
||||||
|
import { runCli } from "./runner.js";
|
||||||
|
import { VERSION } from "../version.js";
|
||||||
|
|
||||||
|
describe("CLI runner - version and help aliases", () => {
|
||||||
|
const versionVariants = [
|
||||||
|
["version"],
|
||||||
|
["verSion"],
|
||||||
|
["versioN"],
|
||||||
|
["VERSION"],
|
||||||
|
["Version"],
|
||||||
|
["v"],
|
||||||
|
["V"],
|
||||||
|
["-v"],
|
||||||
|
["-V"],
|
||||||
|
["--version"],
|
||||||
|
["--verSion"],
|
||||||
|
["--VERSION"],
|
||||||
|
["--v"],
|
||||||
|
["--V"],
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const args of versionVariants) {
|
||||||
|
it(`correctly outputs version for "${args.join(" ")}"`, async () => {
|
||||||
|
const result = await runCli(args);
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.stderr).toBe("");
|
||||||
|
expect(result.stdout).toBe(`hose-use v${VERSION}\n`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const helpVariants = [
|
||||||
|
[],
|
||||||
|
["help"],
|
||||||
|
["HeLp"],
|
||||||
|
["HELP"],
|
||||||
|
["h"],
|
||||||
|
["H"],
|
||||||
|
["-h"],
|
||||||
|
["-H"],
|
||||||
|
["--help"],
|
||||||
|
["--HeLp"],
|
||||||
|
["--HELP"],
|
||||||
|
["?"],
|
||||||
|
["-?"],
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const args of helpVariants) {
|
||||||
|
it(`correctly outputs help for "${args.join(" ") || "<empty>"}"`, async () => {
|
||||||
|
const result = await runCli(args);
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.stderr).toBe("");
|
||||||
|
expect(result.stdout).toContain(`合思/易快报企业级 CLI 工具 (hose-use) v${VERSION}`);
|
||||||
|
expect(result.stdout).toContain("用法:");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
it("handles unknown commands gracefully", async () => {
|
||||||
|
const result = await runCli(["unknown-command-xyz"]);
|
||||||
|
expect(result.exitCode).toBe(1);
|
||||||
|
expect(result.stderr).toContain("未知命令域: unknown-command-xyz");
|
||||||
|
});
|
||||||
|
});
|
||||||
+29
-3
@@ -21,7 +21,7 @@ import { handleMessageCommand } from "./commands/message.js";
|
|||||||
import { handleDimensionCommand } from "./commands/dimension.js";
|
import { handleDimensionCommand } from "./commands/dimension.js";
|
||||||
import { handleRoleCommand } from "./commands/role.js";
|
import { handleRoleCommand } from "./commands/role.js";
|
||||||
import { handlePermissionCommand } from "./commands/permission.js";
|
import { handlePermissionCommand } from "./commands/permission.js";
|
||||||
import type { CliResult, CliRunOptions } from "./types.js";
|
import type { CliParsedArgs, CliResult, CliRunOptions } from "./types.js";
|
||||||
|
|
||||||
const STANDING_COMMANDS = new Set(["http", "server", "web", "mcp"]);
|
const STANDING_COMMANDS = new Set(["http", "server", "web", "mcp"]);
|
||||||
|
|
||||||
@@ -82,17 +82,43 @@ async function runCliOnce(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isHelpRequested(parsed: CliParsedArgs): boolean {
|
||||||
|
const normArea = (parsed.area || "").replace(/^-+/, "").toLowerCase();
|
||||||
|
if (normArea === "help" || normArea === "h" || normArea === "?") return true;
|
||||||
|
|
||||||
|
for (const [key, val] of Object.entries(parsed.options)) {
|
||||||
|
const normKey = key.replace(/^-+/, "").toLowerCase();
|
||||||
|
if (normKey === "help" || normKey === "h" || normKey === "?") {
|
||||||
|
if (val === true || val === "true" || val === "") return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isVersionRequested(parsed: CliParsedArgs): boolean {
|
||||||
|
const normArea = (parsed.area || "").replace(/^-+/, "").toLowerCase();
|
||||||
|
if (normArea === "version" || normArea === "v") return true;
|
||||||
|
|
||||||
|
for (const [key, val] of Object.entries(parsed.options)) {
|
||||||
|
const normKey = key.replace(/^-+/, "").toLowerCase();
|
||||||
|
if (normKey === "version" || normKey === "v") {
|
||||||
|
if (val === true || val === "true" || val === "") return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
async function dispatchCli(
|
async function dispatchCli(
|
||||||
rawArgs: string[],
|
rawArgs: string[],
|
||||||
options: CliRunOptions = {}
|
options: CliRunOptions = {}
|
||||||
): Promise<CliResult> {
|
): Promise<CliResult> {
|
||||||
const parsed = parseArgs(rawArgs);
|
const parsed = parseArgs(rawArgs);
|
||||||
|
|
||||||
if (booleanOption(parsed.options, ["help", "h"]) || parsed.area === "help") {
|
if (isHelpRequested(parsed)) {
|
||||||
return { stdout: printHelp() + "\n", stderr: "", exitCode: 0 };
|
return { stdout: printHelp() + "\n", stderr: "", exitCode: 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (booleanOption(parsed.options, ["version", "v"]) || parsed.area === "version") {
|
if (isVersionRequested(parsed)) {
|
||||||
return { stdout: `hose-use v${VERSION}\n`, stderr: "", exitCode: 0 };
|
return { stdout: `hose-use v${VERSION}\n`, stderr: "", exitCode: 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
export const VERSION = "0.6.0";
|
export const VERSION = "0.6.1";
|
||||||
Reference in new issue
Block a user