From 269b7e8f0f3598729841dc135b895555ee326ad6 Mon Sep 17 00:00:00 2001 From: yunyingk Date: Sat, 5 Sep 2026 22:16:56 +0800 Subject: [PATCH 1/2] fix(cli): support case-insensitive version and help flags and subcommands --- src/cli/parser.ts | 16 ++++++++++----- src/cli/runner.test.ts | 16 +++++++++++++++ src/cli/runner.ts | 46 ++++++++++++++++++++++++++---------------- 3 files changed, 56 insertions(+), 22 deletions(-) diff --git a/src/cli/parser.ts b/src/cli/parser.ts index e6f0e11..0d29864 100644 --- a/src/cli/parser.ts +++ b/src/cli/parser.ts @@ -49,8 +49,10 @@ export function parseArgs(rawArgs: string[]): CliParsedArgs { options[key] = val; } else { 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; + if (key !== keyLower) options[keyLower] = true; } else { const next = rawArgs[i + 1]; if (next && !next.startsWith("-")) { @@ -66,10 +68,14 @@ export function parseArgs(rawArgs: string[]): CliParsedArgs { if (arg.startsWith("-") && arg.length > 1) { const flag = arg.slice(1); - if (flag === "h") options.help = true; - else if (flag === "j") options.json = true; - else if (flag === "v" || flag === "V") options.version = true; - else if (flag === "o") { + const flagLower = flag.toLowerCase(); + if (flagLower === "h" || flag === "?") { + options.help = true; + } else if (flagLower === "j") { + options.json = true; + } else if (flagLower === "v") { + options.version = true; + } else if (flag === "o") { const next = rawArgs[i + 1]; if (next && !next.startsWith("-")) { options.outputFile = next; diff --git a/src/cli/runner.test.ts b/src/cli/runner.test.ts index 85c3d16..532b4c2 100644 --- a/src/cli/runner.test.ts +++ b/src/cli/runner.test.ts @@ -5,11 +5,19 @@ 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) { @@ -24,9 +32,17 @@ describe("CLI runner - version and help aliases", () => { const helpVariants = [ [], ["help"], + ["HeLp"], + ["HELP"], ["h"], + ["H"], ["-h"], + ["-H"], ["--help"], + ["--HeLp"], + ["--HELP"], + ["?"], + ["-?"], ]; for (const args of helpVariants) { diff --git a/src/cli/runner.ts b/src/cli/runner.ts index 6db9d26..324735f 100644 --- a/src/cli/runner.ts +++ b/src/cli/runner.ts @@ -21,7 +21,7 @@ import { handleMessageCommand } from "./commands/message.js"; import { handleDimensionCommand } from "./commands/dimension.js"; import { handleRoleCommand } from "./commands/role.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"]); @@ -82,31 +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( rawArgs: string[], options: CliRunOptions = {} ): Promise { const parsed = parseArgs(rawArgs); - if ( - booleanOption(parsed.options, ["help", "h"]) || - parsed.area === "help" || - parsed.area === "h" || - parsed.area === "-h" || - parsed.area === "--help" - ) { + if (isHelpRequested(parsed)) { return { stdout: printHelp() + "\n", stderr: "", exitCode: 0 }; } - if ( - booleanOption(parsed.options, ["version", "v", "V"]) || - parsed.area === "version" || - parsed.area === "v" || - parsed.area === "V" || - parsed.area === "-v" || - parsed.area === "-V" || - parsed.area === "--version" - ) { + if (isVersionRequested(parsed)) { return { stdout: `hose-use v${VERSION}\n`, stderr: "", exitCode: 0 }; } From 535404871c6551fbcd35cdeed4b98589bcee4f96 Mon Sep 17 00:00:00 2001 From: yunyingk Date: Sat, 5 Sep 2026 22:17:32 +0800 Subject: [PATCH 2/2] chore(release): bump version to v0.6.1 --- .zcode-plugin/plugin.json | 2 +- README.md | 2 +- dist/openapi.json | 2 +- openapi/openapi.yaml | 2 +- package.json | 2 +- skills/hose-use/SKILL.md | 2 +- src/version.ts | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.zcode-plugin/plugin.json b/.zcode-plugin/plugin.json index 1c3f3bf..4484c39 100644 --- a/.zcode-plugin/plugin.json +++ b/.zcode-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "hose-use", - "version": "0.6.0", + "version": "0.6.1", "description": "合思/易快报 (ekuaibao) 企业级 SaaS CLI 与底层 SDK:多账号登录、企业租户切换、单据明细检索、工作流管理、内置 HTTP 服务与常驻守护进程。", "author": { "name": "yingqing" diff --git a/README.md b/README.md index 368bdf3..a350395 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# hose-use (v0.6.0) +# hose-use (v0.6.1) 合思/易快报(ekuaibao)企业级 CLI 命令行工具与底层 SDK。 diff --git a/dist/openapi.json b/dist/openapi.json index 13d0f18..d164045 100644 --- a/dist/openapi.json +++ b/dist/openapi.json @@ -2,7 +2,7 @@ "openapi": "3.1.0", "info": { "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." }, "servers": [ diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 7ad0de9..72e3ec5 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: 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. servers: diff --git a/package.json b/package.json index c45eeb3..67e9c47 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hose-use", - "version": "0.6.0", + "version": "0.6.1", "module": "src/server.ts", "type": "module", "bin": { diff --git a/skills/hose-use/SKILL.md b/skills/hose-use/SKILL.md index 8a9cff2..2144aee 100644 --- a/skills/hose-use/SKILL.md +++ b/skills/hose-use/SKILL.md @@ -6,7 +6,7 @@ metadata: 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` 命令行。 本 Skill 是智能体的路由分发层:保持主文档简明,遇到复杂业务时深入查阅对应的专属参考文档(`references/*.md`)。 diff --git a/src/version.ts b/src/version.ts index ed952a2..72a3111 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = "0.6.0"; +export const VERSION = "0.6.1";