update
This commit is contained in:
1
.cnb.yml
1
.cnb.yml
@@ -8,7 +8,6 @@ include:
|
|||||||
TO_URL: git.xiongxiao.me
|
TO_URL: git.xiongxiao.me
|
||||||
imports:
|
imports:
|
||||||
- https://cnb.cool/kevisual/env/-/blob/main/.env.development
|
- https://cnb.cool/kevisual/env/-/blob/main/.env.development
|
||||||
- https://cnb.cool/kevisual/env/-/blob/main/.env.test
|
|
||||||
|
|
||||||
$:
|
$:
|
||||||
vscode:
|
vscode:
|
||||||
|
|||||||
@@ -104,6 +104,7 @@
|
|||||||
else
|
else
|
||||||
echo "文件不存在"
|
echo "文件不存在"
|
||||||
fi
|
fi
|
||||||
|
printenv > ~/.env
|
||||||
init_stages:
|
init_stages:
|
||||||
- name: '安装依赖'
|
- name: '安装依赖'
|
||||||
script: |
|
script: |
|
||||||
|
|||||||
@@ -1,10 +1,48 @@
|
|||||||
import { tool } from "@opencode-ai/plugin/tool"
|
import { tool } from "@opencode-ai/plugin/tool"
|
||||||
import { type Plugin } from "@opencode-ai/plugin"
|
import { type Plugin } from "@opencode-ai/plugin"
|
||||||
import { app, cnb, appId } from './index.ts';
|
import { app, cnb, appId } from './index.ts';
|
||||||
|
import { } from 'es-toolkit'
|
||||||
|
import { Skill } from "@kevisual/router";
|
||||||
|
const routes = app.routes.filter(r => {
|
||||||
|
const metadata = r.metadata as Skill
|
||||||
|
if (metadata && metadata.tags && metadata.tags.includes('opencode')) {
|
||||||
|
return !!metadata.skill
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
const toolSkills = routes.reduce((acc, route) => {
|
||||||
|
const metadata = route.metadata as Skill
|
||||||
|
acc[metadata.skill!] = {
|
||||||
|
name: metadata.title || metadata.skill,
|
||||||
|
description: metadata.summary || '',
|
||||||
|
args: metadata.args || {},
|
||||||
|
async execute(args: Record<string, any>) {
|
||||||
|
const res = await app.run({
|
||||||
|
path: route.path,
|
||||||
|
key: route.key,
|
||||||
|
payload: args
|
||||||
|
}, { appId });
|
||||||
|
return res.data?.content || res.data || res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {} as Record<string, any>);
|
||||||
|
console.log('CnbPlugin loaded skills:', Object.keys(toolSkills));
|
||||||
|
|
||||||
// opencode run "请使用 cnb-login-verify 工具验证登录信信息,检查cookie"
|
// opencode run "请使用 cnb-login-verify 工具验证登录信信息,检查cookie"
|
||||||
export const CnbPlugin: Plugin = async ({ project, client, $, directory, worktree }) => {
|
export const CnbPlugin: Plugin = async ({ project, client, $, directory, worktree }) => {
|
||||||
return {
|
return {
|
||||||
|
'tool': {
|
||||||
|
...toolSkills
|
||||||
|
},
|
||||||
|
'tool.execute.before': async (opts) => {
|
||||||
|
// console.log('CnbPlugin: tool.execute.before', opts.tool);
|
||||||
|
// delete toolSkills['cnb-login-verify']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const demo = {
|
||||||
'tool': {
|
'tool': {
|
||||||
"cnb-login-verify": {
|
"cnb-login-verify": {
|
||||||
name: "CNB 登录验证信息",
|
name: "CNB 登录验证信息",
|
||||||
@@ -27,9 +65,5 @@ export const CnbPlugin: Plugin = async ({ project, client, $, directory, worktre
|
|||||||
return '无法获取登录状态,请检查配置。';
|
return '无法获取登录状态,请检查配置。';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
'tool.execute.before': async (opts) => {
|
|
||||||
// console.log('CnbPlugin: tool.execute.before', opts.tool);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
import { app, appId } from '../app.ts';
|
import { app, appId } from '../app.ts';
|
||||||
import './user/check.ts'
|
import './user/check.ts'
|
||||||
|
import './repo/index.ts'
|
||||||
|
import './workspace/index.ts'
|
||||||
import { isEqual } from 'es-toolkit'
|
import { isEqual } from 'es-toolkit'
|
||||||
/**
|
/**
|
||||||
* 验证上下文中的 App ID 是否与指定的 App ID 匹配
|
* 验证上下文中的 App ID 是否与指定的 App ID 匹配
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import { createSkill } from '@kevisual/router';
|
||||||
import { app, cnb } from '../../app.ts';
|
import { app, cnb } from '../../app.ts';
|
||||||
|
import { tool } from '@opencode-ai/plugin/tool';
|
||||||
|
|
||||||
|
|
||||||
app.route({
|
app.route({
|
||||||
@@ -7,27 +9,36 @@ app.route({
|
|||||||
description: '检查用户登录状态,参数checkToken,default true; checkCookie, default false',
|
description: '检查用户登录状态,参数checkToken,default true; checkCookie, default false',
|
||||||
middleware: ['auth'],
|
middleware: ['auth'],
|
||||||
metadata: {
|
metadata: {
|
||||||
tags: ['opencode']
|
tags: ['opencode'],
|
||||||
|
...createSkill({
|
||||||
|
skill: 'cnb-login-verify',
|
||||||
|
title: 'CNB 登录验证信息',
|
||||||
|
summary: '验证 CNB 登录信息是否有效',
|
||||||
|
args: {
|
||||||
|
checkToken: tool.schema.boolean().describe('是否检查 Token 的有效性').default(true),
|
||||||
|
checkCookie: tool.schema.boolean().describe('是否检查 Cookie 的有效性').default(false),
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}).define(async (ctx) => {
|
}).define(async (ctx) => {
|
||||||
const checkToken = ctx.query?.checkToken ?? true;
|
const checkToken = ctx.query?.checkToken ?? true;
|
||||||
const checkCookie = ctx.query?.checkCookie ?? false;
|
const checkCookie = ctx.query?.checkCookie ?? false;
|
||||||
let output = '';
|
let content = '';
|
||||||
if (checkToken) {
|
if (checkToken) {
|
||||||
const res = await cnb.user.getUser();
|
const res = await cnb.user.getUser();
|
||||||
if (res?.code !== 200) {
|
if (res?.code !== 200) {
|
||||||
output += `Token 无效,请检查 CNB_TOKEN 配置。\n`;
|
content += `Token 无效,请检查 CNB_TOKEN 配置。\n`;
|
||||||
} else {
|
} else {
|
||||||
output += `Token 有效,Token用户昵称:${res.data?.nickname}\n`;
|
content += `Token 有效,Token用户昵称:${res.data?.nickname}\n`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (checkCookie) {
|
if (checkCookie) {
|
||||||
const res = await cnb.user.getCurrentUser();
|
const res = await cnb.user.getCurrentUser();
|
||||||
if (res?.code !== 200) {
|
if (res?.code !== 200) {
|
||||||
output += `Cookie 无效,请检查 CNB_COOKIE 配置。\n`;
|
content += `Cookie 无效,请检查 CNB_COOKIE 配置。\n`;
|
||||||
} else {
|
} else {
|
||||||
output += `Cookie 有效,当前Cookie用户:${res.data?.nickname}\n`;
|
content += `Cookie 有效,当前Cookie用户:${res.data?.nickname}\n`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.body = { output };
|
ctx.body = { content };
|
||||||
}).addTo(app);
|
}).addTo(app);
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
"@kevisual/types": "^0.0.11",
|
"@kevisual/types": "^0.0.11",
|
||||||
"@opencode-ai/plugin": "^1.1.21",
|
"@opencode-ai/plugin": "^1.1.21",
|
||||||
"@types/bun": "^1.3.6",
|
"@types/bun": "^1.3.6",
|
||||||
"@types/node": "^25.0.8",
|
"@types/node": "^25.0.9",
|
||||||
"dotenv": "^17.2.3"
|
"dotenv": "^17.2.3"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
|||||||
12
pnpm-lock.yaml
generated
12
pnpm-lock.yaml
generated
@@ -40,8 +40,8 @@ importers:
|
|||||||
specifier: ^1.3.6
|
specifier: ^1.3.6
|
||||||
version: 1.3.6
|
version: 1.3.6
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^25.0.8
|
specifier: ^25.0.9
|
||||||
version: 25.0.8
|
version: 25.0.9
|
||||||
dotenv:
|
dotenv:
|
||||||
specifier: ^17.2.3
|
specifier: ^17.2.3
|
||||||
version: 17.2.3
|
version: 17.2.3
|
||||||
@@ -77,8 +77,8 @@ packages:
|
|||||||
'@types/bun@1.3.6':
|
'@types/bun@1.3.6':
|
||||||
resolution: {integrity: sha512-uWCv6FO/8LcpREhenN1d1b6fcspAB+cefwD7uti8C8VffIv0Um08TKMn98FynpTiU38+y2dUO55T11NgDt8VAA==}
|
resolution: {integrity: sha512-uWCv6FO/8LcpREhenN1d1b6fcspAB+cefwD7uti8C8VffIv0Um08TKMn98FynpTiU38+y2dUO55T11NgDt8VAA==}
|
||||||
|
|
||||||
'@types/node@25.0.8':
|
'@types/node@25.0.9':
|
||||||
resolution: {integrity: sha512-powIePYMmC3ibL0UJ2i2s0WIbq6cg6UyVFQxSCpaPxxzAaziRfimGivjdF943sSGV6RADVbk0Nvlm5P/FB44Zg==}
|
resolution: {integrity: sha512-/rpCXHlCWeqClNBwUhDcusJxXYDjZTyE8v5oTO7WbL8eij2nKhUeU89/6xgjU7N4/Vh3He0BtyhJdQbDyhiXAw==}
|
||||||
|
|
||||||
bun-types@1.3.6:
|
bun-types@1.3.6:
|
||||||
resolution: {integrity: sha512-OlFwHcnNV99r//9v5IIOgQ9Uk37gZqrNMCcqEaExdkVq3Avwqok1bJFmvGMCkCE0FqzdY8VMOZpfpR3lwI+CsQ==}
|
resolution: {integrity: sha512-OlFwHcnNV99r//9v5IIOgQ9Uk37gZqrNMCcqEaExdkVq3Avwqok1bJFmvGMCkCE0FqzdY8VMOZpfpR3lwI+CsQ==}
|
||||||
@@ -142,13 +142,13 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
bun-types: 1.3.6
|
bun-types: 1.3.6
|
||||||
|
|
||||||
'@types/node@25.0.8':
|
'@types/node@25.0.9':
|
||||||
dependencies:
|
dependencies:
|
||||||
undici-types: 7.16.0
|
undici-types: 7.16.0
|
||||||
|
|
||||||
bun-types@1.3.6:
|
bun-types@1.3.6:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 25.0.8
|
'@types/node': 25.0.9
|
||||||
|
|
||||||
dotenv@17.2.3: {}
|
dotenv@17.2.3: {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user