This commit is contained in:
2026-01-11 01:10:38 +08:00
commit 9830cbe735
10 changed files with 204 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
node_modules

3
AGENTS.md Normal file
View File

@@ -0,0 +1,3 @@
## 交互要求
需要中文回复

16
README.md Normal file
View File

@@ -0,0 +1,16 @@
## opencode基本配置
```sh
# clone 到根目录
git clone https://cnb.cool/kevisual/dev-opencode ~/.opencode
export OPENCODE_CONFIG=~/.opencode/opencode.json
```
模型配置
```sh
GLM-4.7
MiniMax-M2.1
```

46
opencode.json Normal file
View File

@@ -0,0 +1,46 @@
{
"$schema": "https://opencode.ai/config.json",
"autoshare": false,
"share": "disabled",
"autoupdate": true,
"permission": "allow",
"disabled_providers": [
"openai",
"gemini"
],
"watcher": {
"ignore": [
"node_modules/**",
"dist/**",
".git/**"
]
},
"provider": {
"custom-zhipu": {
"npm": "@ai-sdk/openai-compatible",
"name": "国内智谱AI",
"models": {
"GLM-4.7": {
"name": "GLM-4.7"
}
},
"options": {
"baseURL": "https://open.bigmodel.cn/api/coding/paas/v4",
"apiKey": "{env:ZHIPU_TOKEN}"
}
},
"custom-minimax": {
"npm": "@ai-sdk/anthropic",
"name": "国内MiniMax",
"models": {
"MiniMax-M2.1": {
"name": "MiniMax-M2.1"
}
},
"options": {
"baseURL": "https://api.minimaxi.com/anthropic/v1",
"apiKey": "{env:MINIMAX_TOKEN}"
}
}
}
}

6
package.json Normal file
View File

@@ -0,0 +1,6 @@
{
"dependencies": {
"@opencode-ai/plugin": "1.1.12",
"shescape": "^2.1.0"
}
}

21
plugin/example.ts Normal file
View File

@@ -0,0 +1,21 @@
import { tool, type Plugin } from "@opencode-ai/plugin"
// 列出工具列表便能获取到更多示例
export const MyPlugin: Plugin = async ({ project, client, $, directory, worktree }) => {
console.log("Plugin initialized!")
return {
// Hook implementations go here
tool: {
mytool: tool({
description: "获取foo的问候语",
args: {
foo: tool.schema.string(),
},
async execute(args, ctx) {
return `Hello ${args.foo}!`
},
}),
}
}
}

61
pnpm-lock.yaml generated Normal file
View File

@@ -0,0 +1,61 @@
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.:
dependencies:
'@opencode-ai/plugin':
specifier: 1.1.12
version: 1.1.12
shescape:
specifier: ^2.1.0
version: 2.1.7
packages:
'@opencode-ai/plugin@1.1.12':
resolution: {integrity: sha512-L+sh6mDU1teVgjRbpNnJdQIv3EYx9v8X2ZgjCAtC/eyjERR5s1smvBmvvBCpJ+p5APWKD4nuDS0xtiJiUBFZKQ==}
'@opencode-ai/sdk@1.1.12':
resolution: {integrity: sha512-M1c+525865g2C03iKaMdx3aUVC7oZSNbBGaTDjUN2UTIakdxqKHog0Hd8IA9WL8M0aU1QJ8+CnpvRT2Jt9kRNw==}
isexe@3.1.1:
resolution: {integrity: sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==}
engines: {node: '>=16'}
shescape@2.1.7:
resolution: {integrity: sha512-Y1syY0ggm3ow7mE1zrcK9YrOhAqv/IGbm3+J9S+MXLukwXf/M8yzL3hZp7ubVeSy250TT7M5SVKikTZkKyib6w==}
engines: {node: ^14.18.0 || ^16.13.0 || ^18 || ^19 || ^20 || ^22 || ^24}
which@6.0.0:
resolution: {integrity: sha512-f+gEpIKMR9faW/JgAgPK1D7mekkFoqbmiwvNzuhsHetni20QSgzg9Vhn0g2JSJkkfehQnqdUAx7/e15qS1lPxg==}
engines: {node: ^20.17.0 || >=22.9.0}
hasBin: true
zod@4.1.8:
resolution: {integrity: sha512-5R1P+WwQqmmMIEACyzSvo4JXHY5WiAFHRMg+zBZKgKS+Q1viRa0C1hmUKtHltoIFKtIdki3pRxkmpP74jnNYHQ==}
snapshots:
'@opencode-ai/plugin@1.1.12':
dependencies:
'@opencode-ai/sdk': 1.1.12
zod: 4.1.8
'@opencode-ai/sdk@1.1.12': {}
isexe@3.1.1: {}
shescape@2.1.7:
dependencies:
which: 6.0.0
which@6.0.0:
dependencies:
isexe: 3.1.1
zod@4.1.8: {}

View File

@@ -0,0 +1,14 @@
---
name: check-login
description: 检测ev是否已登录
---
# check-login
需要执行
```shell
# 检测ev是否已登录
ev me
```
如果返回信息有用户名,则表示已登录,否则未登录。

25
tool/math.ts Normal file
View File

@@ -0,0 +1,25 @@
import { tool } from "@opencode-ai/plugin"
export const add = tool({
description: "两个数字相加",
args: {
a: tool.schema.number().describe("第一个数字"),
b: tool.schema.number().describe("第二个数字"),
},
async execute(args) {
const end = args.a + args.b
return end + ""
},
})
export const multiply = tool({
description: "两个数字相乘",
args: {
a: tool.schema.number().describe("第一个数字"),
b: tool.schema.number().describe("第二个数字"),
},
async execute(args) {
const end = args.a * args.b
return end + ""
},
})

11
tool/project.ts Normal file
View File

@@ -0,0 +1,11 @@
import { tool } from "@opencode-ai/plugin"
export default tool({
description: "获取当前会话信息",
args: {},
async execute(args, context) {
// Access context information
const { agent, sessionID, messageID } = context
return `智能体: ${agent}, 会话ID: ${sessionID}, 消息ID: ${messageID}`
},
})