diff --git a/agent/command.ts b/agent/command.ts new file mode 100644 index 0000000..d51294f --- /dev/null +++ b/agent/command.ts @@ -0,0 +1,4 @@ +import { app } from './index.ts'; +import { parse } from '@kevisual/router/src/commander.ts'; + +parse({ app: app as any, description: 'CNB控制台命令行工具', parse: true }) \ No newline at end of file diff --git a/agent/routes/index.ts b/agent/routes/index.ts index 30a2016..3001ef6 100644 --- a/agent/routes/index.ts +++ b/agent/routes/index.ts @@ -7,7 +7,7 @@ import './cnb-env/index.ts' import './knowledge/index.ts' import './issues/index.ts' import './cnb-board/index.ts'; - +import './share/index.ts'; /** * 验证上下文中的 App ID 是否与指定的 App ID 匹配 * @param {any} ctx - 上下文对象,可能包含 appId 属性 diff --git a/agent/routes/share/index.ts b/agent/routes/share/index.ts new file mode 100644 index 0000000..d948fe2 --- /dev/null +++ b/agent/routes/share/index.ts @@ -0,0 +1,48 @@ +import { useKey } from '@kevisual/context'; +import { app, cnb } from '../../app.ts'; +import z from 'zod'; + +app.route({ + path: 'cnb', + key: 'get-assistant-url', + description: '获取cnb工作空间中部署的各个助手的访问地址', + middleware: ['auth'], + metadata: { + args: { + more: z.boolean().describe('需要更多信息') + } + } +}).define(async (ctx) => { + const uri = useKey('CNB_VSCODE_PROXY_URI') as string || ''; + const base = { + base: uri, + link: uri.replace('{{port}}', '51515'), + kevisual: uri.replace('{{port}}', '51515'), + openclaw: uri.replace('{{port}}', '80'), + opencode: uri.replace('{{port}}', '100'), + openwebui: uri.replace('{{port}}', '200'), + note: uri.replace('{{port}}', '3000'), + uptime: uri.replace('{{port}}', '3001'), + immich: uri.replace('{{port}}', '2283'), + nocodb: uri.replace('{{port}}', '4000'), + openlist: uri.replace('{{port}}', '5244'), + xiaoyao: uri.replace('{{port}}', '5678'), + meilisearch: uri.replace('{{port}}', '7700'), + bark: uri.replace('{{port}}', '9111'), + vaultwarden: uri.replace('{{port}}', '8180'), + music: uri.replace('{{port}}', '8096'), + jellyfin: uri.replace('{{port}}', '8096'), + homeassistant: uri.replace('{{port}}', '8123'), + cloudreve: uri.replace('{{port}}', '5212'), + filebrowser: uri.replace('{{port}}', '8081'), + // newapi: uri.replace('{{port}}', '8080'), + vscode: useKey('CNB_VSCODE_PROXY_URI') as string || '', + codeServer: uri.replace('{{port}}', '10000'), + gitea: uri.replace('{{port}}', '3000'), + calibre: uri.replace('{{port}}', '8083'), + searXNG: uri.replace('{{port}}', '8888'), + } + ctx.body = { + ...base, + } +}).addTo(app); diff --git a/bin/index.js b/bin/index.js new file mode 100755 index 0000000..b9c9276 --- /dev/null +++ b/bin/index.js @@ -0,0 +1,2 @@ +#!/usr/bin/env bun +import '../dist/cli.js'; \ No newline at end of file diff --git a/bun.config.ts b/bun.config.ts index 595836e..aeed142 100644 --- a/bun.config.ts +++ b/bun.config.ts @@ -1,4 +1,6 @@ import { buildWithBun } from '@kevisual/code-builder' await buildWithBun({ naming: 'opencode', entry: 'agent/opencode.ts', dts: true }); await buildWithBun({ naming: 'keep', entry: 'src/keep.ts', dts: true, target: 'node' }); -await buildWithBun({ naming: 'routes', entry: 'agent/index.ts', dts: true }); \ No newline at end of file +await buildWithBun({ naming: 'routes', entry: 'agent/index.ts', dts: true }); + +await buildWithBun({ naming: 'cli', entry: 'agent/command.ts', dts: true, target: 'node' }); \ No newline at end of file diff --git a/package.json b/package.json index afd04d2..2e1baae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kevisual/cnb", - "version": "0.0.35", + "version": "0.0.36", "description": "", "main": "index.js", "scripts": { @@ -8,6 +8,9 @@ "flow": "ev npm patch && pnpm build && ev npm publish npm -p" }, "keywords": [], + "bin": { + "cnb": "./bin/index.js" + }, "files": [ "dist", "src", @@ -21,13 +24,14 @@ "devDependencies": { "@kevisual/ai": "^0.0.26", "@kevisual/code-builder": "^0.0.6", - "@kevisual/dts": "^0.0.4", "@kevisual/context": "^0.0.8", + "@kevisual/dts": "^0.0.4", "@kevisual/types": "^0.0.12", - "@opencode-ai/plugin": "^1.2.16", + "@opencode-ai/plugin": "^1.2.20", "@types/bun": "^1.3.10", - "@types/node": "^25.3.3", + "@types/node": "^25.3.5", "@types/ws": "^8.18.1", + "commander": "^14.0.3", "dayjs": "^1.11.19", "dotenv": "^17.3.1" }, @@ -38,8 +42,8 @@ "zod": "^4.3.6" }, "dependencies": { - "@kevisual/query": "^0.0.52", - "@kevisual/router": "^0.0.85", + "@kevisual/query": "^0.0.53", + "@kevisual/router": "^0.0.88", "@kevisual/use-config": "^1.0.30", "es-toolkit": "^1.45.1", "nanoid": "^5.1.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4203d39..2363f34 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,11 +12,11 @@ importers: .: dependencies: '@kevisual/query': - specifier: ^0.0.52 - version: 0.0.52 + specifier: ^0.0.53 + version: 0.0.53 '@kevisual/router': - specifier: ^0.0.85 - version: 0.0.85 + specifier: ^0.0.88 + version: 0.0.88 '@kevisual/use-config': specifier: ^1.0.30 version: 1.0.30(dotenv@17.3.1) @@ -52,17 +52,20 @@ importers: specifier: ^0.0.12 version: 0.0.12 '@opencode-ai/plugin': - specifier: ^1.2.16 - version: 1.2.16 + specifier: ^1.2.20 + version: 1.2.20 '@types/bun': specifier: ^1.3.10 version: 1.3.10 '@types/node': - specifier: ^25.3.3 - version: 25.3.3 + specifier: ^25.3.5 + version: 25.3.5 '@types/ws': specifier: ^8.18.1 version: 8.18.1 + commander: + specifier: ^14.0.3 + version: 14.0.3 dayjs: specifier: ^1.11.19 version: 1.11.19 @@ -109,8 +112,11 @@ packages: '@kevisual/query@0.0.52': resolution: {integrity: sha512-m1UbyDTIxtfAQXM+EqhXA4ytE2V8rV8mXTZVBwzfW9O6+gtvAcRY7K1YYxfewTSXLVh9nwvfHe0KQ8MDL5ukyw==} - '@kevisual/router@0.0.85': - resolution: {integrity: sha512-ihSzPXHOMSOnZD/+Eso4yZMt4MoUXyLdfRHhXJGg90+sJBr/BjsmgAokit4pI9gWU+Rs/3JqQ2/aqA43FHtGoA==} + '@kevisual/query@0.0.53': + resolution: {integrity: sha512-PAhpCLBr0emz0lGNlTVHMbJiC5wrtGLbInPddRzgKE35fiyNt+SWSsUWABiD0DeNrLN/OxWyAFobt880Z/e5MQ==} + + '@kevisual/router@0.0.88': + resolution: {integrity: sha512-T8kEbxyTGxZpbxAKDplDjZMIY+HCnXOeEdjwQ11AQetrLuqLFDZS5PnaWdVAHnONUDLhYoftkNj7bGWLtyQDlg==} '@kevisual/types@0.0.12': resolution: {integrity: sha512-zJXH2dosir3jVrQ6QG4i0+iLQeT9gJ3H+cKXs8ReWboxBSYzUZO78XssVeVrFPsJ33iaAqo4q3DWbSS1dWGn7Q==} @@ -124,11 +130,11 @@ packages: resolution: {integrity: sha512-jLsL80wBBKkrJZrfk3SQpJ9JA/zREdlUROj7eCkmzqduAWKSI0wVcXuCKf+mLFCHB0Q0Tkh2rgzjSlurt3JQgw==} engines: {node: '>=10.0.0'} - '@opencode-ai/plugin@1.2.16': - resolution: {integrity: sha512-9Kb7BQIC2P3oKCvI8K3thP5YP0vE7yLvcmBmgyACUIqc3e5UL6U+4umLpTvgQa2eQdjxtOXznuGTNwgcGMHUHg==} + '@opencode-ai/plugin@1.2.20': + resolution: {integrity: sha512-BE6TOXVxgF24g5QgtlogSY5B+/AmZJ3cYaVjHZhUVuAli9JEg4RblrbrK2rfgbyZBoZDpjBLGTYtIRTVmOccEA==} - '@opencode-ai/sdk@1.2.16': - resolution: {integrity: sha512-y9ae9VnCcuog0GaI4DveX1HB6DBoZgGN3EuJVlRFbBCPwhzkls6fCfHSb5+VnTS6Fy0OWFUL28VBCmixL/D+/Q==} + '@opencode-ai/sdk@1.2.20': + resolution: {integrity: sha512-U5ROpG21D8jg9rkc1IgKAk1g5dn6X/rkOBfveupd0peSDO9n6VM9aikYccVLaMObxVqdjtG08IeQOFTPVS8ySQ==} '@rollup/plugin-commonjs@29.0.0': resolution: {integrity: sha512-U2YHaxR2cU/yAiwKJtJRhnyLk7cifnQw0zUpISsocBDoHDJn+HTV74ABqnwr5bEgWUwFZC9oFL6wLe21lHu5eQ==} @@ -314,8 +320,8 @@ packages: '@types/estree@1.0.8': resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==} - '@types/node@25.3.3': - resolution: {integrity: sha512-DpzbrH7wIcBaJibpKo9nnSQL0MTRdnWttGyE5haGwK86xgMOkFLp7vEyfQPGLOJh5wNYiJ3V9PmUMDhV9u8kkQ==} + '@types/node@25.3.5': + resolution: {integrity: sha512-oX8xrhvpiyRCQkG1MFchB09f+cXftgIXb3a7UUa4Y3wpmZPw5tyZGTLWhlESOLq1Rq6oDlc8npVU2/9xiCuXMA==} '@types/resolve@1.20.2': resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} @@ -334,6 +340,10 @@ packages: resolution: {integrity: sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==} engines: {node: '>= 20.19.0'} + commander@14.0.3: + resolution: {integrity: sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==} + engines: {node: '>=20'} + commondir@1.0.1: resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} @@ -603,7 +613,9 @@ snapshots: '@kevisual/query@0.0.52': {} - '@kevisual/router@0.0.85': + '@kevisual/query@0.0.53': {} + + '@kevisual/router@0.0.88': dependencies: es-toolkit: 1.45.1 @@ -616,12 +628,12 @@ snapshots: '@kevisual/ws@8.19.0': {} - '@opencode-ai/plugin@1.2.16': + '@opencode-ai/plugin@1.2.20': dependencies: - '@opencode-ai/sdk': 1.2.16 + '@opencode-ai/sdk': 1.2.20 zod: 4.3.6 - '@opencode-ai/sdk@1.2.16': {} + '@opencode-ai/sdk@1.2.20': {} '@rollup/plugin-commonjs@29.0.0(rollup@4.57.1)': dependencies: @@ -743,7 +755,7 @@ snapshots: '@types/estree@1.0.8': {} - '@types/node@25.3.3': + '@types/node@25.3.5': dependencies: undici-types: 7.18.2 @@ -751,7 +763,7 @@ snapshots: '@types/ws@8.18.1': dependencies: - '@types/node': 25.3.3 + '@types/node': 25.3.5 anymatch@3.1.3: dependencies: @@ -760,12 +772,14 @@ snapshots: bun-types@1.3.10: dependencies: - '@types/node': 25.3.3 + '@types/node': 25.3.5 chokidar@5.0.0: dependencies: readdirp: 5.0.0 + commander@14.0.3: {} + commondir@1.0.1: {} cookie-es@1.2.2: {}