From 9830cbe735bab189f6577280ef364b613e584ebf Mon Sep 17 00:00:00 2001 From: abearxiong Date: Sun, 11 Jan 2026 01:10:38 +0800 Subject: [PATCH] update --- .gitignore | 1 + AGENTS.md | 3 ++ README.md | 16 ++++++++++ opencode.json | 46 ++++++++++++++++++++++++++++ package.json | 6 ++++ plugin/example.ts | 21 +++++++++++++ pnpm-lock.yaml | 61 +++++++++++++++++++++++++++++++++++++ skills/check-login/SKILL.md | 14 +++++++++ tool/math.ts | 25 +++++++++++++++ tool/project.ts | 11 +++++++ 10 files changed, 204 insertions(+) create mode 100644 .gitignore create mode 100644 AGENTS.md create mode 100644 README.md create mode 100644 opencode.json create mode 100644 package.json create mode 100644 plugin/example.ts create mode 100644 pnpm-lock.yaml create mode 100644 skills/check-login/SKILL.md create mode 100644 tool/math.ts create mode 100644 tool/project.ts diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..a7c9adb --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,3 @@ +## 交互要求 + +需要中文回复 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..465f8aa --- /dev/null +++ b/README.md @@ -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 +``` \ No newline at end of file diff --git a/opencode.json b/opencode.json new file mode 100644 index 0000000..3f184a3 --- /dev/null +++ b/opencode.json @@ -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}" + } + } + } +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..93644de --- /dev/null +++ b/package.json @@ -0,0 +1,6 @@ +{ + "dependencies": { + "@opencode-ai/plugin": "1.1.12", + "shescape": "^2.1.0" + } +} \ No newline at end of file diff --git a/plugin/example.ts b/plugin/example.ts new file mode 100644 index 0000000..ee38004 --- /dev/null +++ b/plugin/example.ts @@ -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}!` + }, + }), + } + } +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..936dad4 --- /dev/null +++ b/pnpm-lock.yaml @@ -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: {} diff --git a/skills/check-login/SKILL.md b/skills/check-login/SKILL.md new file mode 100644 index 0000000..fbe2aad --- /dev/null +++ b/skills/check-login/SKILL.md @@ -0,0 +1,14 @@ +--- +name: check-login +description: 检测ev是否已登录 +--- + +# check-login + +需要执行 + +```shell +# 检测ev是否已登录 +ev me +``` +如果返回信息有用户名,则表示已登录,否则未登录。 \ No newline at end of file diff --git a/tool/math.ts b/tool/math.ts new file mode 100644 index 0000000..d1c77a2 --- /dev/null +++ b/tool/math.ts @@ -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 + "" + }, +}) \ No newline at end of file diff --git a/tool/project.ts b/tool/project.ts new file mode 100644 index 0000000..2a62437 --- /dev/null +++ b/tool/project.ts @@ -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}` + }, +}) \ No newline at end of file