RG

remorses/goke

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

61 stars 质量 68 趋势 20

简单、类型安全、优雅的命令行框架。代理CLI框架

概览

goke 构建 CLI 就像构建 API 一样。类型安全,可链式,零依赖。 goke 是一个带有类似 Hono API 的 TypeScript CLI 框架。你用 .use() 连接中间件,.command() 连接路由——与应用到终端的 REST API 是相同的心理模型。 - — .use() 用于中间件,.command() 用于处理器。构建 CLI 就像设计 REST API 一样。- — 将 Zod 模式传递给 .option(),即可获得自动强制、TypeScript 推理和免费帮助文本。支持 Valibot、ArkType 或任何标准 Schema 库。- — @goke/mcp 连接 MCP 服务器,发现工具,并自动生成带类型 CLI 命令。- — 将整个 CLI 以 MCP 服务器的形式暴露,使用 createMcpAction({ cli }) 来自 @goke/mcp。每个命令都成为工具,准备好用于 Claude Desktop、Cursor、VS Code 及任何 MCP 客户端。- — cli.createJustBashCommand() 将你的 CLI 暴露为沙箱 JustBash 命令。相同的操作代码,无需更改。

概述(AI 翻译)

五乐 构建 CLI 就像构建 API 一样。类型安全、可链式、零依赖。

goke 是一个带有类似 Hono API 的 TypeScript CLI 框架。你用 .use() 连接中间件,.command() 连接路由——与应用到终端的 REST API 是相同的心理模型。

特色

  • 类 Hono 链式连接 — .use() 用于中间件,[.command() 用于处理器。构建 CLI 就像设计 REST API 一样。
  • Zod 类型安全 — 将 Zod 模式传递给 .option(),即可免费获得自动强制、TypeScript 推理和帮助文本。可支持 Valibot、ArkType 或任何标准模式库。
  • 来自任意MCP服务器的CLI — @goke/mcp连接MCP服务器,发现工具,并自动生成类型化的CLI命令。
  • MCP 服务器,仅为两行 — 将整个 CLI 暴露为 MCP 服务器,使用 createMcpAction({ cli }) 来自 @goke/mcp。每个命令都成为工具,准备支持 Claude Desktop、光标、VS Code 及任何 MCP 客户端。
  • JustBash 支持 — cli.createJustBashCommand() 将你的 CLI 暴露为沙箱化的 JustBash 命令。操作代码相同,无需更改。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

goke is a TypeScript CLI framework with a Hono-like API. You chain .use() for middleware and .command() for routes — the same mental model as a REST API, applied to the terminal.

import { goke } from 'goke'
import { z } from 'zod'

const cli = goke('deploy')

// middleware — runs before every command
cli
  .option('--env ', z.enum(['staging', 'production']).default('staging').describe('Target environment'))
  .use((options, { console }) => {
    console.log(`Environment: ${options.env}`)
  })

// commands — like route handlers
cli
  .command('up', 'Deploy the app')
  .option('--dry-run', 'Preview without deploying')
  .action((options, { console, process }) => {
    console.log(`Deploying from ${process.cwd}`)
  })

cli
  .command('logs ', 'Stream logs')
  .option('--lines ', z.number().default(100).describe('Lines to tail'))
  .action((id, options) => streamLogs(id, options.lines))

cli.help()
cli.completions()
cli.parse()

Features

  • Hono-like chaining — .use() for middleware, .command() for handlers. Build a CLI the same way you’d design a REST API.
  • Zod type safety — pass a Zod schema to .option() and get automatic coercion, TypeScript inference, and help text for free. Works with Valibot, ArkType, or any Standard Schema library.
  • CLI from any MCP server — @goke/mcp connects to an MCP server, discovers tools, and generates typed CLI commands automatically.
  • MCP server in 2 lines — expose your entire CLI as an MCP server with createMcpAction({ cli }) from @goke/mcp. Every command becomes a tool, ready for Claude Desktop, Cursor, VS Code, and any MCP client.
  • JustBash support — cli.createJustBashCommand() exposes your CLI as a sandboxed JustBash command. Same action code, no changes needed.
  • Space-separated subcommands — git remote add, mcp login, db migrate — multi-word commands work out of the box.
  • Injected { fs, console, process } — commands receive a portable runtime context. Swap it in tests, or let JustBash replace it with a sandbox. No global side effects.
  • Shell completions — cli.completions() adds Tab completion for zsh and bash. Install once with mycli completions install; completions stay up-to-date automatically because the shell calls the binary on every Tab press.
  • Zero runtime dependencies — install goke without pulling extra runtime packages into your CLI.
在 GitHub 查看完整 README

推荐工具

换一个关键词,或者移除筛选条件。

安装

npx skillfish add remorses/goke
新手?先看 mcpskill.org 教程 →