From 3c56849cfa352d8f3f804faa347b749c182cfb16 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Mon, 9 Mar 2026 01:13:45 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=20@opencode-ai/plug?= =?UTF-8?q?in=20=E7=89=88=E6=9C=AC=E8=87=B3=201.2.21=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E8=B0=83=E6=95=B4=20commander=20=E6=A8=A1=E5=9D=97=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E7=B1=BB=E5=9E=8B=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++-- pnpm-lock.yaml | 18 +++++++++--------- src/commander.ts | 17 +++++++++-------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 853bf20..8954841 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/package", "name": "@kevisual/router", - "version": "0.0.88", + "version": "0.0.89", "description": "", "type": "module", "main": "./dist/router.js", @@ -29,7 +29,7 @@ "@kevisual/local-proxy": "^0.0.8", "@kevisual/query": "^0.0.53", "@kevisual/use-config": "^1.0.30", - "@opencode-ai/plugin": "^1.2.20", + "@opencode-ai/plugin": "^1.2.21", "@types/bun": "^1.3.10", "@types/node": "^25.3.5", "@types/send": "^1.2.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d9c79a0..47e344f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -34,8 +34,8 @@ importers: specifier: ^1.0.30 version: 1.0.30(dotenv@17.2.3) '@opencode-ai/plugin': - specifier: ^1.2.20 - version: 1.2.20 + specifier: ^1.2.21 + version: 1.2.21 '@types/bun': specifier: ^1.3.10 version: 1.3.10 @@ -169,11 +169,11 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} - '@opencode-ai/plugin@1.2.20': - resolution: {integrity: sha512-BE6TOXVxgF24g5QgtlogSY5B+/AmZJ3cYaVjHZhUVuAli9JEg4RblrbrK2rfgbyZBoZDpjBLGTYtIRTVmOccEA==} + '@opencode-ai/plugin@1.2.21': + resolution: {integrity: sha512-2/JhdD19bu9fxPIzZun2x57KA4Q4EsY/yRQZO54GTsVugZ+T0b5GZkFFYIyOVE6bU4PCoSYBK5MAU+VCEyxvEA==} - '@opencode-ai/sdk@1.2.20': - resolution: {integrity: sha512-U5ROpG21D8jg9rkc1IgKAk1g5dn6X/rkOBfveupd0peSDO9n6VM9aikYccVLaMObxVqdjtG08IeQOFTPVS8ySQ==} + '@opencode-ai/sdk@1.2.21': + resolution: {integrity: sha512-7XF7QlXDP5iAbGcAsxsrmKlIjRtSzKgbwuDHPPuZbILkhGOfCo05XwPidAZrVWucZ/re44oc/psw2zDECaZOpQ==} '@rollup/plugin-commonjs@29.0.0': resolution: {integrity: sha512-U2YHaxR2cU/yAiwKJtJRhnyLk7cifnQw0zUpISsocBDoHDJn+HTV74ABqnwr5bEgWUwFZC9oFL6wLe21lHu5eQ==} @@ -772,12 +772,12 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.20.1 - '@opencode-ai/plugin@1.2.20': + '@opencode-ai/plugin@1.2.21': dependencies: - '@opencode-ai/sdk': 1.2.20 + '@opencode-ai/sdk': 1.2.21 zod: 4.1.8 - '@opencode-ai/sdk@1.2.20': {} + '@opencode-ai/sdk@1.2.21': {} '@rollup/plugin-commonjs@29.0.0(rollup@4.57.1)': dependencies: diff --git a/src/commander.ts b/src/commander.ts index 0146436..04f7f76 100644 --- a/src/commander.ts +++ b/src/commander.ts @@ -1,4 +1,4 @@ -import { program } from 'commander'; +import { Command, program } from 'commander'; import { App, QueryRouterServer } from './app.ts'; export const groupByPath = (routes: App['routes']) => { @@ -62,7 +62,7 @@ export const parseDescription = (route: App['routes'][number]) => { } return desc; } -export const createCommand = (opts: { app: App, program: typeof program }) => { +export const createCommand = (opts: { app: App, program: Command }) => { const { app, program } = opts; const routes = app.routes; @@ -71,7 +71,7 @@ export const createCommand = (opts: { app: App, program: typeof program }) => { for (const path in groupRoutes) { const routeList = groupRoutes[path]; const keys = routeList.map(route => route.key).filter(Boolean); - const subProgram = program.command(path).description(`路由《${path}》 ${keys.length > 0 ? ': ' + keys.join(', ') : ''}`); + const subProgram = program.command(path).description(`路由[${path}] ${keys.length > 0 ? ': ' + keys.join(', ') : ''}`); routeList.forEach(route => { if (!route.key) return; const description = parseDescription(route); @@ -103,11 +103,12 @@ export const createCommand = (opts: { app: App, program: typeof program }) => { } } -export const parse = (opts: { app: QueryRouterServer, description?: string, parse?: boolean }) => { - const { app, description, parse = true } = opts; - program.description(description || 'Router 命令行工具'); - createCommand({ app: app as App, program }); +export const parse = (opts: { app: QueryRouterServer, description?: string, parse?: boolean, program?: Command }) => { + const { app, description, parse = true, } = opts; + const _program = opts.program || program; + _program.description(description || 'Router 命令行工具'); + createCommand({ app: app as App, program: _program }); if (parse) { - program.parse(process.argv); + _program.parse(process.argv); } } \ No newline at end of file