From 605061a60e4a5d4cc79444cb97e9fe32d9fca795 Mon Sep 17 00:00:00 2001 From: xiongxiao Date: Wed, 28 Jan 2026 00:02:21 +0800 Subject: [PATCH] feat: enhance plugin integration with hooks and context management - Updated the `createRouterAgentPluginFn` to accept an optional `hooks` parameter for better plugin customization. - Introduced `usePluginInput` for accessing plugin input context. - Refactored `AgentPlugin` to utilize hooks and context, improving flexibility and functionality. - Cleaned up commented-out code for clarity. --- package.json | 18 +-- pnpm-lock.yaml | 378 +++++++++++++++++++++++++++--------------------- src/opencode.ts | 30 ++-- 3 files changed, 245 insertions(+), 181 deletions(-) diff --git a/package.json b/package.json index 21e75a7..9506635 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,13 @@ { "$schema": "https://json.schemastore.org/package", "name": "@kevisual/router", - "version": "0.0.62", + "version": "0.0.63", "description": "", "type": "module", "main": "./dist/router.js", "types": "./dist/router.d.ts", "scripts": { "build": "npm run clean && rollup -c", - "postbuild": "bun run bun.config.ts", "watch": "rollup -c -w", "clean": "rm -rf dist" }, @@ -22,20 +21,20 @@ "keywords": [], "author": "abearxiong", "license": "MIT", - "packageManager": "pnpm@10.28.1", + "packageManager": "pnpm@10.28.2", "devDependencies": { "@kevisual/context": "^0.0.4", "@kevisual/js-filter": "^0.0.5", "@kevisual/local-proxy": "^0.0.8", - "@kevisual/query": "^0.0.35", + "@kevisual/query": "^0.0.38", "@kevisual/use-config": "^1.0.28", - "@opencode-ai/plugin": "^1.1.27", + "@opencode-ai/plugin": "^1.1.36", "@rollup/plugin-alias": "^6.0.0", "@rollup/plugin-commonjs": "29.0.0", "@rollup/plugin-node-resolve": "^16.0.3", "@rollup/plugin-typescript": "^12.3.0", "@types/bun": "^1.3.6", - "@types/node": "^25.0.9", + "@types/node": "^25.0.10", "@types/send": "^1.2.1", "@types/ws": "^8.18.1", "@types/xml2js": "^0.4.14", @@ -43,7 +42,7 @@ "fast-glob": "^3.3.3", "nanoid": "^5.1.6", "path-to-regexp": "^8.3.0", - "rollup": "^4.55.2", + "rollup": "^4.57.0", "rollup-plugin-dts": "^6.3.0", "send": "^1.2.1", "ts-loader": "^9.5.4", @@ -53,14 +52,15 @@ "typescript": "^5.9.3", "ws": "npm:@kevisual/ws", "xml2js": "^0.6.2", - "zod": "^4.3.5" + "zod": "^4.3.6" }, "repository": { "type": "git", "url": "git+https://github.com/abearxiong/kevisual-router.git" }, "dependencies": { - "hono": "^4.11.4" + "@kevisual/dts": "^0.0.3", + "hono": "^4.11.7" }, "publishConfig": { "access": "public" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d7cacc2..542e075 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,12 @@ importers: .: dependencies: + '@kevisual/dts': + specifier: ^0.0.3 + version: 0.0.3(typescript@5.9.3) hono: - specifier: ^4.11.4 - version: 4.11.4 + specifier: ^4.11.7 + version: 4.11.7 devDependencies: '@kevisual/context': specifier: ^0.0.4 @@ -22,32 +25,32 @@ importers: specifier: ^0.0.8 version: 0.0.8 '@kevisual/query': - specifier: ^0.0.35 - version: 0.0.35 + specifier: ^0.0.38 + version: 0.0.38 '@kevisual/use-config': specifier: ^1.0.28 version: 1.0.28(dotenv@17.2.3) '@opencode-ai/plugin': - specifier: ^1.1.27 - version: 1.1.27 + specifier: ^1.1.36 + version: 1.1.36 '@rollup/plugin-alias': specifier: ^6.0.0 - version: 6.0.0(rollup@4.55.2) + version: 6.0.0(rollup@4.57.0) '@rollup/plugin-commonjs': specifier: 29.0.0 - version: 29.0.0(rollup@4.55.2) + version: 29.0.0(rollup@4.57.0) '@rollup/plugin-node-resolve': specifier: ^16.0.3 - version: 16.0.3(rollup@4.55.2) + version: 16.0.3(rollup@4.57.0) '@rollup/plugin-typescript': specifier: ^12.3.0 - version: 12.3.0(rollup@4.55.2)(tslib@2.8.1)(typescript@5.9.3) + version: 12.3.0(rollup@4.57.0)(tslib@2.8.1)(typescript@5.9.3) '@types/bun': specifier: ^1.3.6 version: 1.3.6 '@types/node': - specifier: ^25.0.9 - version: 25.0.9 + specifier: ^25.0.10 + version: 25.0.10 '@types/send': specifier: ^1.2.1 version: 1.2.1 @@ -70,11 +73,11 @@ importers: specifier: ^8.3.0 version: 8.3.0 rollup: - specifier: ^4.55.2 - version: 4.55.2 + specifier: ^4.57.0 + version: 4.57.0 rollup-plugin-dts: specifier: ^6.3.0 - version: 6.3.0(rollup@4.55.2)(typescript@5.9.3) + version: 6.3.0(rollup@4.57.0)(typescript@5.9.3) send: specifier: ^1.2.1 version: 1.2.1 @@ -83,7 +86,7 @@ importers: version: 9.5.4(typescript@5.9.3)(webpack@5.104.1) ts-node: specifier: ^10.9.2 - version: 10.9.2(@types/node@25.0.9)(typescript@5.9.3) + version: 10.9.2(@types/node@25.0.10)(typescript@5.9.3) tslib: specifier: ^2.8.1 version: 2.8.1 @@ -100,8 +103,8 @@ importers: specifier: ^0.6.2 version: 0.6.2 zod: - specifier: ^4.3.5 - version: 4.3.5 + specifier: ^4.3.6 + version: 4.3.6 demo/simple: dependencies: @@ -114,7 +117,7 @@ importers: version: 1.1.1 ts-node: specifier: ^10.9.2 - version: 10.9.2(@types/node@25.0.9)(typescript@5.9.3) + version: 10.9.2(@types/node@25.0.10)(typescript@5.9.3) typescript: specifier: ^5.5.4 version: 5.9.3 @@ -311,6 +314,10 @@ packages: '@kevisual/context@0.0.4': resolution: {integrity: sha512-HJeLeZQLU+7tCluSfOyvkgKLs0HjCZrdJlZgEgKRSa8XTwZfMAUt6J7qZTbrZAHBlPtX68EPu/PI8JMCeu3WAQ==} + '@kevisual/dts@0.0.3': + resolution: {integrity: sha512-4T/m2LqhtwWEW+lWmg7jLxKFW7VtIAftsWFDDZvh10bZunqFf8iXxChHcVSQWikghJb4cq1IkWzPkvc2l+Asdw==} + hasBin: true + '@kevisual/js-filter@0.0.5': resolution: {integrity: sha512-+S+Sf3K/aP6XtZI2s7TgKOr35UuvUvtpJ9YDW30a+mY0/N8gRuzyKhieBzQN7Ykayzz70uoMavBXut2rUlLgzw==} @@ -320,8 +327,8 @@ packages: '@kevisual/local-proxy@0.0.8': resolution: {integrity: sha512-VX/P+6/Cc8ruqp34ag6gVX073BchUmf5VNZcTV/6MJtjrNE76G8V6TLpBE8bywLnrqyRtFLIspk4QlH8up9B5Q==} - '@kevisual/query@0.0.35': - resolution: {integrity: sha512-80dyy2LMCmEC72g+X4QWUKlZErhawQPgnGSBNR4yhrBcFgHIJQ14LR1Z+bS5S1I7db+1PDNpaxBTjIaoYoXunw==} + '@kevisual/query@0.0.38': + resolution: {integrity: sha512-bfvbSodsZyMfwY+1T2SvDeOCKsT/AaIxlVe0+B1R/fNhlg2MDq2CP0L9HKiFkEm+OXrvXcYDMKPUituVUM5J6Q==} '@kevisual/use-config@1.0.28': resolution: {integrity: sha512-ngF+LDbjxpXWrZNmnShIKF/jPpAa+ezV+DcgoZIIzHlRnIjE+rr9sLkN/B7WJbiH9C/j1tQXOILY8ujBqILrow==} @@ -344,11 +351,11 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} - '@opencode-ai/plugin@1.1.27': - resolution: {integrity: sha512-EevLVaEhQ1jTLNRbQJj18tFZaVNJcZZcVqvZEbDSe17CfmVRv3FQNKRAjD/QHwb+Kym7sn+LAZxD7aYIPPelvQ==} + '@opencode-ai/plugin@1.1.36': + resolution: {integrity: sha512-b2XWeFZN7UzgwkkzTIi6qSntkpEA9En2zvpqakQzZAGQm6QBdGAlv6r1u5hEnmF12Gzyj5umTMWr5GzVbP/oAA==} - '@opencode-ai/sdk@1.1.27': - resolution: {integrity: sha512-ssRZpET3zUNdk1GuF6HwFkNHhCXSTG0lhuPmw9HjifTwv1EVrn8gz7jAuME2OCvUSBvRTesH6Lb0Xt78Qbhzww==} + '@opencode-ai/sdk@1.1.36': + resolution: {integrity: sha512-feNHWnbxhg03TI2QrWnw3Chc0eYrWSDSmHIy/ejpSVfcKlfXREw1Tpg0L4EjrpeSc4jB1eM673dh+WM/Ko2SFQ==} '@rollup/plugin-alias@6.0.0': resolution: {integrity: sha512-tPCzJOtS7uuVZd+xPhoy5W4vThe6KWXNmsFCNktaAh5RTqcLiSfT4huPQIXkgJ6YCOjJHvecOAzQxLFhPxKr+g==} @@ -359,6 +366,15 @@ packages: rollup: optional: true + '@rollup/plugin-commonjs@28.0.9': + resolution: {integrity: sha512-PIR4/OHZ79romx0BVVll/PkwWpJ7e5lsqFa3gFfcrFPWwLXLV39JVUzQV9RKjWerE7B845Hqjj9VYlQeieZ2dA==} + engines: {node: '>=16.0.0 || 14 >= 14.17'} + peerDependencies: + rollup: ^2.68.0||^3.0.0||^4.0.0 + peerDependenciesMeta: + rollup: + optional: true + '@rollup/plugin-commonjs@29.0.0': resolution: {integrity: sha512-U2YHaxR2cU/yAiwKJtJRhnyLk7cifnQw0zUpISsocBDoHDJn+HTV74ABqnwr5bEgWUwFZC9oFL6wLe21lHu5eQ==} engines: {node: '>=16.0.0 || 14 >= 14.17'} @@ -399,128 +415,141 @@ packages: rollup: optional: true - '@rollup/rollup-android-arm-eabi@4.55.2': - resolution: {integrity: sha512-21J6xzayjy3O6NdnlO6aXi/urvSRjm6nCI6+nF6ra2YofKruGixN9kfT+dt55HVNwfDmpDHJcaS3JuP/boNnlA==} + '@rollup/rollup-android-arm-eabi@4.57.0': + resolution: {integrity: sha512-tPgXB6cDTndIe1ah7u6amCI1T0SsnlOuKgg10Xh3uizJk4e5M1JGaUMk7J4ciuAUcFpbOiNhm2XIjP9ON0dUqA==} cpu: [arm] os: [android] - '@rollup/rollup-android-arm64@4.55.2': - resolution: {integrity: sha512-eXBg7ibkNUZ+sTwbFiDKou0BAckeV6kIigK7y5Ko4mB/5A1KLhuzEKovsmfvsL8mQorkoincMFGnQuIT92SKqA==} + '@rollup/rollup-android-arm64@4.57.0': + resolution: {integrity: sha512-sa4LyseLLXr1onr97StkU1Nb7fWcg6niokTwEVNOO7awaKaoRObQ54+V/hrF/BP1noMEaaAW6Fg2d/CfLiq3Mg==} cpu: [arm64] os: [android] - '@rollup/rollup-darwin-arm64@4.55.2': - resolution: {integrity: sha512-UCbaTklREjrc5U47ypLulAgg4njaqfOVLU18VrCrI+6E5MQjuG0lSWaqLlAJwsD7NpFV249XgB0Bi37Zh5Sz4g==} + '@rollup/rollup-darwin-arm64@4.57.0': + resolution: {integrity: sha512-/NNIj9A7yLjKdmkx5dC2XQ9DmjIECpGpwHoGmA5E1AhU0fuICSqSWScPhN1yLCkEdkCwJIDu2xIeLPs60MNIVg==} cpu: [arm64] os: [darwin] - '@rollup/rollup-darwin-x64@4.55.2': - resolution: {integrity: sha512-dP67MA0cCMHFT2g5XyjtpVOtp7y4UyUxN3dhLdt11at5cPKnSm4lY+EhwNvDXIMzAMIo2KU+mc9wxaAQJTn7sQ==} + '@rollup/rollup-darwin-x64@4.57.0': + resolution: {integrity: sha512-xoh8abqgPrPYPr7pTYipqnUi1V3em56JzE/HgDgitTqZBZ3yKCWI+7KUkceM6tNweyUKYru1UMi7FC060RyKwA==} cpu: [x64] os: [darwin] - '@rollup/rollup-freebsd-arm64@4.55.2': - resolution: {integrity: sha512-WDUPLUwfYV9G1yxNRJdXcvISW15mpvod1Wv3ok+Ws93w1HjIVmCIFxsG2DquO+3usMNCpJQ0wqO+3GhFdl6Fow==} + '@rollup/rollup-freebsd-arm64@4.57.0': + resolution: {integrity: sha512-PCkMh7fNahWSbA0OTUQ2OpYHpjZZr0hPr8lId8twD7a7SeWrvT3xJVyza+dQwXSSq4yEQTMoXgNOfMCsn8584g==} cpu: [arm64] os: [freebsd] - '@rollup/rollup-freebsd-x64@4.55.2': - resolution: {integrity: sha512-Ng95wtHVEulRwn7R0tMrlUuiLVL/HXA8Lt/MYVpy88+s5ikpntzZba1qEulTuPnPIZuOPcW9wNEiqvZxZmgmqQ==} + '@rollup/rollup-freebsd-x64@4.57.0': + resolution: {integrity: sha512-1j3stGx+qbhXql4OCDZhnK7b01s6rBKNybfsX+TNrEe9JNq4DLi1yGiR1xW+nL+FNVvI4D02PUnl6gJ/2y6WJA==} cpu: [x64] os: [freebsd] - '@rollup/rollup-linux-arm-gnueabihf@4.55.2': - resolution: {integrity: sha512-AEXMESUDWWGqD6LwO/HkqCZgUE1VCJ1OhbvYGsfqX2Y6w5quSXuyoy/Fg3nRqiwro+cJYFxiw5v4kB2ZDLhxrw==} + '@rollup/rollup-linux-arm-gnueabihf@4.57.0': + resolution: {integrity: sha512-eyrr5W08Ms9uM0mLcKfM/Uzx7hjhz2bcjv8P2uynfj0yU8GGPdz8iYrBPhiLOZqahoAMB8ZiolRZPbbU2MAi6Q==} cpu: [arm] os: [linux] + libc: [glibc] - '@rollup/rollup-linux-arm-musleabihf@4.55.2': - resolution: {integrity: sha512-ZV7EljjBDwBBBSv570VWj0hiNTdHt9uGznDtznBB4Caj3ch5rgD4I2K1GQrtbvJ/QiB+663lLgOdcADMNVC29Q==} + '@rollup/rollup-linux-arm-musleabihf@4.57.0': + resolution: {integrity: sha512-Xds90ITXJCNyX9pDhqf85MKWUI4lqjiPAipJ8OLp8xqI2Ehk+TCVhF9rvOoN8xTbcafow3QOThkNnrM33uCFQA==} cpu: [arm] os: [linux] + libc: [musl] - '@rollup/rollup-linux-arm64-gnu@4.55.2': - resolution: {integrity: sha512-uvjwc8NtQVPAJtq4Tt7Q49FOodjfbf6NpqXyW/rjXoV+iZ3EJAHLNAnKT5UJBc6ffQVgmXTUL2ifYiLABlGFqA==} + '@rollup/rollup-linux-arm64-gnu@4.57.0': + resolution: {integrity: sha512-Xws2KA4CLvZmXjy46SQaXSejuKPhwVdaNinldoYfqruZBaJHqVo6hnRa8SDo9z7PBW5x84SH64+izmldCgbezw==} cpu: [arm64] os: [linux] + libc: [glibc] - '@rollup/rollup-linux-arm64-musl@4.55.2': - resolution: {integrity: sha512-s3KoWVNnye9mm/2WpOZ3JeUiediUVw6AvY/H7jNA6qgKA2V2aM25lMkVarTDfiicn/DLq3O0a81jncXszoyCFA==} + '@rollup/rollup-linux-arm64-musl@4.57.0': + resolution: {integrity: sha512-hrKXKbX5FdaRJj7lTMusmvKbhMJSGWJ+w++4KmjiDhpTgNlhYobMvKfDoIWecy4O60K6yA4SnztGuNTQF+Lplw==} cpu: [arm64] os: [linux] + libc: [musl] - '@rollup/rollup-linux-loong64-gnu@4.55.2': - resolution: {integrity: sha512-gi21faacK+J8aVSyAUptML9VQN26JRxe484IbF+h3hpG+sNVoMXPduhREz2CcYr5my0NE3MjVvQ5bMKX71pfVA==} + '@rollup/rollup-linux-loong64-gnu@4.57.0': + resolution: {integrity: sha512-6A+nccfSDGKsPm00d3xKcrsBcbqzCTAukjwWK6rbuAnB2bHaL3r9720HBVZ/no7+FhZLz/U3GwwZZEh6tOSI8Q==} cpu: [loong64] os: [linux] + libc: [glibc] - '@rollup/rollup-linux-loong64-musl@4.55.2': - resolution: {integrity: sha512-qSlWiXnVaS/ceqXNfnoFZh4IiCA0EwvCivivTGbEu1qv2o+WTHpn1zNmCTAoOG5QaVr2/yhCoLScQtc/7RxshA==} + '@rollup/rollup-linux-loong64-musl@4.57.0': + resolution: {integrity: sha512-4P1VyYUe6XAJtQH1Hh99THxr0GKMMwIXsRNOceLrJnaHTDgk1FTcTimDgneRJPvB3LqDQxUmroBclQ1S0cIJwQ==} cpu: [loong64] os: [linux] + libc: [musl] - '@rollup/rollup-linux-ppc64-gnu@4.55.2': - resolution: {integrity: sha512-rPyuLFNoF1B0+wolH277E780NUKf+KoEDb3OyoLbAO18BbeKi++YN6gC/zuJoPPDlQRL3fIxHxCxVEWiem2yXw==} + '@rollup/rollup-linux-ppc64-gnu@4.57.0': + resolution: {integrity: sha512-8Vv6pLuIZCMcgXre6c3nOPhE0gjz1+nZP6T+hwWjr7sVH8k0jRkH+XnfjjOTglyMBdSKBPPz54/y1gToSKwrSQ==} cpu: [ppc64] os: [linux] + libc: [glibc] - '@rollup/rollup-linux-ppc64-musl@4.55.2': - resolution: {integrity: sha512-g+0ZLMook31iWV4PvqKU0i9E78gaZgYpSrYPed/4Bu+nGTgfOPtfs1h11tSSRPXSjC5EzLTjV/1A7L2Vr8pJoQ==} + '@rollup/rollup-linux-ppc64-musl@4.57.0': + resolution: {integrity: sha512-r1te1M0Sm2TBVD/RxBPC6RZVwNqUTwJTA7w+C/IW5v9Ssu6xmxWEi+iJQlpBhtUiT1raJ5b48pI8tBvEjEFnFA==} cpu: [ppc64] os: [linux] + libc: [musl] - '@rollup/rollup-linux-riscv64-gnu@4.55.2': - resolution: {integrity: sha512-i+sGeRGsjKZcQRh3BRfpLsM3LX3bi4AoEVqmGDyc50L6KfYsN45wVCSz70iQMwPWr3E5opSiLOwsC9WB4/1pqg==} + '@rollup/rollup-linux-riscv64-gnu@4.57.0': + resolution: {integrity: sha512-say0uMU/RaPm3CDQLxUUTF2oNWL8ysvHkAjcCzV2znxBr23kFfaxocS9qJm+NdkRhF8wtdEEAJuYcLPhSPbjuQ==} cpu: [riscv64] os: [linux] + libc: [glibc] - '@rollup/rollup-linux-riscv64-musl@4.55.2': - resolution: {integrity: sha512-C1vLcKc4MfFV6I0aWsC7B2Y9QcsiEcvKkfxprwkPfLaN8hQf0/fKHwSF2lcYzA9g4imqnhic729VB9Fo70HO3Q==} + '@rollup/rollup-linux-riscv64-musl@4.57.0': + resolution: {integrity: sha512-/MU7/HizQGsnBREtRpcSbSV1zfkoxSTR7wLsRmBPQ8FwUj5sykrP1MyJTvsxP5KBq9SyE6kH8UQQQwa0ASeoQQ==} cpu: [riscv64] os: [linux] + libc: [musl] - '@rollup/rollup-linux-s390x-gnu@4.55.2': - resolution: {integrity: sha512-68gHUK/howpQjh7g7hlD9DvTTt4sNLp1Bb+Yzw2Ki0xvscm2cOdCLZNJNhd2jW8lsTPrHAHuF751BygifW4bkQ==} + '@rollup/rollup-linux-s390x-gnu@4.57.0': + resolution: {integrity: sha512-Q9eh+gUGILIHEaJf66aF6a414jQbDnn29zeu0eX3dHMuysnhTvsUvZTCAyZ6tJhUjnvzBKE4FtuaYxutxRZpOg==} cpu: [s390x] os: [linux] + libc: [glibc] - '@rollup/rollup-linux-x64-gnu@4.55.2': - resolution: {integrity: sha512-1e30XAuaBP1MAizaOBApsgeGZge2/Byd6wV4a8oa6jPdHELbRHBiw7wvo4dp7Ie2PE8TZT4pj9RLGZv9N4qwlw==} + '@rollup/rollup-linux-x64-gnu@4.57.0': + resolution: {integrity: sha512-OR5p5yG5OKSxHReWmwvM0P+VTPMwoBS45PXTMYaskKQqybkS3Kmugq1W+YbNWArF8/s7jQScgzXUhArzEQ7x0A==} cpu: [x64] os: [linux] + libc: [glibc] - '@rollup/rollup-linux-x64-musl@4.55.2': - resolution: {integrity: sha512-4BJucJBGbuGnH6q7kpPqGJGzZnYrpAzRd60HQSt3OpX/6/YVgSsJnNzR8Ot74io50SeVT4CtCWe/RYIAymFPwA==} + '@rollup/rollup-linux-x64-musl@4.57.0': + resolution: {integrity: sha512-XeatKzo4lHDsVEbm1XDHZlhYZZSQYym6dg2X/Ko0kSFgio+KXLsxwJQprnR48GvdIKDOpqWqssC3iBCjoMcMpw==} cpu: [x64] os: [linux] + libc: [musl] - '@rollup/rollup-openbsd-x64@4.55.2': - resolution: {integrity: sha512-cT2MmXySMo58ENv8p6/O6wI/h/gLnD3D6JoajwXFZH6X9jz4hARqUhWpGuQhOgLNXscfZYRQMJvZDtWNzMAIDw==} + '@rollup/rollup-openbsd-x64@4.57.0': + resolution: {integrity: sha512-Lu71y78F5qOfYmubYLHPcJm74GZLU6UJ4THkf/a1K7Tz2ycwC2VUbsqbJAXaR6Bx70SRdlVrt2+n5l7F0agTUw==} cpu: [x64] os: [openbsd] - '@rollup/rollup-openharmony-arm64@4.55.2': - resolution: {integrity: sha512-sZnyUgGkuzIXaK3jNMPmUIyJrxu/PjmATQrocpGA1WbCPX8H5tfGgRSuYtqBYAvLuIGp8SPRb1O4d1Fkb5fXaQ==} + '@rollup/rollup-openharmony-arm64@4.57.0': + resolution: {integrity: sha512-v5xwKDWcu7qhAEcsUubiav7r+48Uk/ENWdr82MBZZRIm7zThSxCIVDfb3ZeRRq9yqk+oIzMdDo6fCcA5DHfMyA==} cpu: [arm64] os: [openharmony] - '@rollup/rollup-win32-arm64-msvc@4.55.2': - resolution: {integrity: sha512-sDpFbenhmWjNcEbBcoTV0PWvW5rPJFvu+P7XoTY0YLGRupgLbFY0XPfwIbJOObzO7QgkRDANh65RjhPmgSaAjQ==} + '@rollup/rollup-win32-arm64-msvc@4.57.0': + resolution: {integrity: sha512-XnaaaSMGSI6Wk8F4KK3QP7GfuuhjGchElsVerCplUuxRIzdvZ7hRBpLR0omCmw+kI2RFJB80nenhOoGXlJ5TfQ==} cpu: [arm64] os: [win32] - '@rollup/rollup-win32-ia32-msvc@4.55.2': - resolution: {integrity: sha512-GvJ03TqqaweWCigtKQVBErw2bEhu1tyfNQbarwr94wCGnczA9HF8wqEe3U/Lfu6EdeNP0p6R+APeHVwEqVxpUQ==} + '@rollup/rollup-win32-ia32-msvc@4.57.0': + resolution: {integrity: sha512-3K1lP+3BXY4t4VihLw5MEg6IZD3ojSYzqzBG571W3kNQe4G4CcFpSUQVgurYgib5d+YaCjeFow8QivWp8vuSvA==} cpu: [ia32] os: [win32] - '@rollup/rollup-win32-x64-gnu@4.55.2': - resolution: {integrity: sha512-KvXsBvp13oZz9JGe5NYS7FNizLe99Ny+W8ETsuCyjXiKdiGrcz2/J/N8qxZ/RSwivqjQguug07NLHqrIHrqfYw==} + '@rollup/rollup-win32-x64-gnu@4.57.0': + resolution: {integrity: sha512-MDk610P/vJGc5L5ImE4k5s+GZT3en0KoK1MKPXCRgzmksAMk79j4h3k1IerxTNqwDLxsGxStEZVBqG0gIqZqoA==} cpu: [x64] os: [win32] - '@rollup/rollup-win32-x64-msvc@4.55.2': - resolution: {integrity: sha512-xNO+fksQhsAckRtDSPWaMeT1uIM+JrDRXlerpnWNXhn1TdB3YZ6uKBMBTKP0eX9XtYEP978hHk1f8332i2AW8Q==} + '@rollup/rollup-win32-x64-msvc@4.57.0': + resolution: {integrity: sha512-Zv7v6q6aV+VslnpwzqKAmrk5JdVkLUzok2208ZXGipjb+msxBr/fJPZyeEXiFgH7k62Ak0SLIfxQRZQvTuf7rQ==} cpu: [x64] os: [win32] @@ -551,8 +580,8 @@ packages: '@types/json-schema@7.0.15': resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} - '@types/node@25.0.9': - resolution: {integrity: sha512-/rpCXHlCWeqClNBwUhDcusJxXYDjZTyE8v5oTO7WbL8eij2nKhUeU89/6xgjU7N4/Vh3He0BtyhJdQbDyhiXAw==} + '@types/node@25.0.10': + resolution: {integrity: sha512-zWW5KPngR/yvakJgGOmZ5vTBemDoSqF3AcV/LrO5u5wTWyEAVVh+IT39G4gtyAkh3CtTZs8aX/yRM82OfzHJRg==} '@types/resolve@1.20.2': resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} @@ -848,8 +877,8 @@ packages: resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} engines: {node: '>= 0.4'} - hono@4.11.4: - resolution: {integrity: sha512-U7tt8JsyrxSRKspfhtLET79pU8K+tInj5QZXs1jSugO1Vq5dFj3kmZsRldo29mTBfcjDRVRXrEZ6LS63Cog9ZA==} + hono@4.11.7: + resolution: {integrity: sha512-l7qMiNee7t82bH3SeyUCt9UF15EVmaBvsppY2zQtrbIhl/yzBTny+YUxsVjSjQ6gaqaeVtZmGocom8TzBlA4Yw==} engines: {node: '>=16.9.0'} http-errors@2.0.1: @@ -999,8 +1028,8 @@ packages: rollup: ^3.29.4 || ^4 typescript: ^4.5 || ^5.0 - rollup@4.55.2: - resolution: {integrity: sha512-PggGy4dhwx5qaW+CKBilA/98Ql9keyfnb7lh4SR6shQ91QQQi1ORJ1v4UinkdP2i87OBs9AQFooQylcrrRfIcg==} + rollup@4.57.0: + resolution: {integrity: sha512-e5lPJi/aui4TO1LpAXIRLySmwXSE8k3b9zoGfd42p67wzxog4WHjiZF3M2uheQih4DGyc25QEV4yRBbpueNiUA==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true @@ -1171,8 +1200,8 @@ packages: zod@4.1.8: resolution: {integrity: sha512-5R1P+WwQqmmMIEACyzSvo4JXHY5WiAFHRMg+zBZKgKS+Q1viRa0C1hmUKtHltoIFKtIdki3pRxkmpP74jnNYHQ==} - zod@4.3.5: - resolution: {integrity: sha512-k7Nwx6vuWx1IJ9Bjuf4Zt1PEllcwe7cls3VNzm4CQ1/hgtFUK2bRNG3rvnpPUhFjmqJKAKtjV576KnUkHocg/g==} + zod@4.3.6: + resolution: {integrity: sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==} snapshots: @@ -1294,6 +1323,17 @@ snapshots: '@kevisual/context@0.0.4': {} + '@kevisual/dts@0.0.3(typescript@5.9.3)': + dependencies: + '@rollup/plugin-commonjs': 28.0.9(rollup@4.57.0) + '@rollup/plugin-node-resolve': 16.0.3(rollup@4.57.0) + '@rollup/plugin-typescript': 12.3.0(rollup@4.57.0)(tslib@2.8.1)(typescript@5.9.3) + rollup: 4.57.0 + rollup-plugin-dts: 6.3.0(rollup@4.57.0)(typescript@5.9.3) + tslib: 2.8.1 + transitivePeerDependencies: + - typescript + '@kevisual/js-filter@0.0.5': {} '@kevisual/load@0.0.6': @@ -1302,7 +1342,7 @@ snapshots: '@kevisual/local-proxy@0.0.8': {} - '@kevisual/query@0.0.35': + '@kevisual/query@0.0.38': dependencies: tslib: 2.8.1 @@ -1325,20 +1365,20 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.20.1 - '@opencode-ai/plugin@1.1.27': + '@opencode-ai/plugin@1.1.36': dependencies: - '@opencode-ai/sdk': 1.1.27 + '@opencode-ai/sdk': 1.1.36 zod: 4.1.8 - '@opencode-ai/sdk@1.1.27': {} + '@opencode-ai/sdk@1.1.36': {} - '@rollup/plugin-alias@6.0.0(rollup@4.55.2)': + '@rollup/plugin-alias@6.0.0(rollup@4.57.0)': optionalDependencies: - rollup: 4.55.2 + rollup: 4.57.0 - '@rollup/plugin-commonjs@29.0.0(rollup@4.55.2)': + '@rollup/plugin-commonjs@28.0.9(rollup@4.57.0)': dependencies: - '@rollup/pluginutils': 5.3.0(rollup@4.55.2) + '@rollup/pluginutils': 5.3.0(rollup@4.57.0) commondir: 1.0.1 estree-walker: 2.0.2 fdir: 6.5.0(picomatch@4.0.3) @@ -1346,108 +1386,120 @@ snapshots: magic-string: 0.30.21 picomatch: 4.0.3 optionalDependencies: - rollup: 4.55.2 + rollup: 4.57.0 - '@rollup/plugin-node-resolve@16.0.3(rollup@4.55.2)': + '@rollup/plugin-commonjs@29.0.0(rollup@4.57.0)': dependencies: - '@rollup/pluginutils': 5.3.0(rollup@4.55.2) + '@rollup/pluginutils': 5.3.0(rollup@4.57.0) + commondir: 1.0.1 + estree-walker: 2.0.2 + fdir: 6.5.0(picomatch@4.0.3) + is-reference: 1.2.1 + magic-string: 0.30.21 + picomatch: 4.0.3 + optionalDependencies: + rollup: 4.57.0 + + '@rollup/plugin-node-resolve@16.0.3(rollup@4.57.0)': + dependencies: + '@rollup/pluginutils': 5.3.0(rollup@4.57.0) '@types/resolve': 1.20.2 deepmerge: 4.3.1 is-module: 1.0.0 resolve: 1.22.11 optionalDependencies: - rollup: 4.55.2 + rollup: 4.57.0 - '@rollup/plugin-typescript@12.3.0(rollup@4.55.2)(tslib@2.8.1)(typescript@5.9.3)': + '@rollup/plugin-typescript@12.3.0(rollup@4.57.0)(tslib@2.8.1)(typescript@5.9.3)': dependencies: - '@rollup/pluginutils': 5.3.0(rollup@4.55.2) + '@rollup/pluginutils': 5.3.0(rollup@4.57.0) resolve: 1.22.11 typescript: 5.9.3 optionalDependencies: - rollup: 4.55.2 + rollup: 4.57.0 tslib: 2.8.1 - '@rollup/pluginutils@5.3.0(rollup@4.55.2)': + '@rollup/pluginutils@5.3.0(rollup@4.57.0)': dependencies: '@types/estree': 1.0.8 estree-walker: 2.0.2 picomatch: 4.0.3 optionalDependencies: - rollup: 4.55.2 + rollup: 4.57.0 - '@rollup/rollup-android-arm-eabi@4.55.2': + '@rollup/rollup-android-arm-eabi@4.57.0': optional: true - '@rollup/rollup-android-arm64@4.55.2': + '@rollup/rollup-android-arm64@4.57.0': optional: true - '@rollup/rollup-darwin-arm64@4.55.2': + '@rollup/rollup-darwin-arm64@4.57.0': optional: true - '@rollup/rollup-darwin-x64@4.55.2': + '@rollup/rollup-darwin-x64@4.57.0': optional: true - '@rollup/rollup-freebsd-arm64@4.55.2': + '@rollup/rollup-freebsd-arm64@4.57.0': optional: true - '@rollup/rollup-freebsd-x64@4.55.2': + '@rollup/rollup-freebsd-x64@4.57.0': optional: true - '@rollup/rollup-linux-arm-gnueabihf@4.55.2': + '@rollup/rollup-linux-arm-gnueabihf@4.57.0': optional: true - '@rollup/rollup-linux-arm-musleabihf@4.55.2': + '@rollup/rollup-linux-arm-musleabihf@4.57.0': optional: true - '@rollup/rollup-linux-arm64-gnu@4.55.2': + '@rollup/rollup-linux-arm64-gnu@4.57.0': optional: true - '@rollup/rollup-linux-arm64-musl@4.55.2': + '@rollup/rollup-linux-arm64-musl@4.57.0': optional: true - '@rollup/rollup-linux-loong64-gnu@4.55.2': + '@rollup/rollup-linux-loong64-gnu@4.57.0': optional: true - '@rollup/rollup-linux-loong64-musl@4.55.2': + '@rollup/rollup-linux-loong64-musl@4.57.0': optional: true - '@rollup/rollup-linux-ppc64-gnu@4.55.2': + '@rollup/rollup-linux-ppc64-gnu@4.57.0': optional: true - '@rollup/rollup-linux-ppc64-musl@4.55.2': + '@rollup/rollup-linux-ppc64-musl@4.57.0': optional: true - '@rollup/rollup-linux-riscv64-gnu@4.55.2': + '@rollup/rollup-linux-riscv64-gnu@4.57.0': optional: true - '@rollup/rollup-linux-riscv64-musl@4.55.2': + '@rollup/rollup-linux-riscv64-musl@4.57.0': optional: true - '@rollup/rollup-linux-s390x-gnu@4.55.2': + '@rollup/rollup-linux-s390x-gnu@4.57.0': optional: true - '@rollup/rollup-linux-x64-gnu@4.55.2': + '@rollup/rollup-linux-x64-gnu@4.57.0': optional: true - '@rollup/rollup-linux-x64-musl@4.55.2': + '@rollup/rollup-linux-x64-musl@4.57.0': optional: true - '@rollup/rollup-openbsd-x64@4.55.2': + '@rollup/rollup-openbsd-x64@4.57.0': optional: true - '@rollup/rollup-openharmony-arm64@4.55.2': + '@rollup/rollup-openharmony-arm64@4.57.0': optional: true - '@rollup/rollup-win32-arm64-msvc@4.55.2': + '@rollup/rollup-win32-arm64-msvc@4.57.0': optional: true - '@rollup/rollup-win32-ia32-msvc@4.55.2': + '@rollup/rollup-win32-ia32-msvc@4.57.0': optional: true - '@rollup/rollup-win32-x64-gnu@4.55.2': + '@rollup/rollup-win32-x64-gnu@4.57.0': optional: true - '@rollup/rollup-win32-x64-msvc@4.55.2': + '@rollup/rollup-win32-x64-msvc@4.57.0': optional: true '@tsconfig/node10@1.0.12': {} @@ -1476,7 +1528,7 @@ snapshots: '@types/json-schema@7.0.15': {} - '@types/node@25.0.9': + '@types/node@25.0.10': dependencies: undici-types: 7.16.0 @@ -1484,15 +1536,15 @@ snapshots: '@types/send@1.2.1': dependencies: - '@types/node': 25.0.9 + '@types/node': 25.0.10 '@types/ws@8.18.1': dependencies: - '@types/node': 25.0.9 + '@types/node': 25.0.10 '@types/xml2js@0.4.14': dependencies: - '@types/node': 25.0.9 + '@types/node': 25.0.10 '@webassemblyjs/ast@1.14.1': dependencies: @@ -1624,7 +1676,7 @@ snapshots: bun-types@1.3.6: dependencies: - '@types/node': 25.0.9 + '@types/node': 25.0.10 caniuse-lite@1.0.30001761: {} @@ -1777,7 +1829,7 @@ snapshots: dependencies: function-bind: 1.1.2 - hono@4.11.4: {} + hono@4.11.7: {} http-errors@2.0.1: dependencies: @@ -1809,7 +1861,7 @@ snapshots: jest-worker@27.5.1: dependencies: - '@types/node': 25.0.9 + '@types/node': 25.0.10 merge-stream: 2.0.0 supports-color: 8.1.1 @@ -1891,43 +1943,43 @@ snapshots: reusify@1.1.0: {} - rollup-plugin-dts@6.3.0(rollup@4.55.2)(typescript@5.9.3): + rollup-plugin-dts@6.3.0(rollup@4.57.0)(typescript@5.9.3): dependencies: magic-string: 0.30.21 - rollup: 4.55.2 + rollup: 4.57.0 typescript: 5.9.3 optionalDependencies: '@babel/code-frame': 7.27.1 - rollup@4.55.2: + rollup@4.57.0: dependencies: '@types/estree': 1.0.8 optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.55.2 - '@rollup/rollup-android-arm64': 4.55.2 - '@rollup/rollup-darwin-arm64': 4.55.2 - '@rollup/rollup-darwin-x64': 4.55.2 - '@rollup/rollup-freebsd-arm64': 4.55.2 - '@rollup/rollup-freebsd-x64': 4.55.2 - '@rollup/rollup-linux-arm-gnueabihf': 4.55.2 - '@rollup/rollup-linux-arm-musleabihf': 4.55.2 - '@rollup/rollup-linux-arm64-gnu': 4.55.2 - '@rollup/rollup-linux-arm64-musl': 4.55.2 - '@rollup/rollup-linux-loong64-gnu': 4.55.2 - '@rollup/rollup-linux-loong64-musl': 4.55.2 - '@rollup/rollup-linux-ppc64-gnu': 4.55.2 - '@rollup/rollup-linux-ppc64-musl': 4.55.2 - '@rollup/rollup-linux-riscv64-gnu': 4.55.2 - '@rollup/rollup-linux-riscv64-musl': 4.55.2 - '@rollup/rollup-linux-s390x-gnu': 4.55.2 - '@rollup/rollup-linux-x64-gnu': 4.55.2 - '@rollup/rollup-linux-x64-musl': 4.55.2 - '@rollup/rollup-openbsd-x64': 4.55.2 - '@rollup/rollup-openharmony-arm64': 4.55.2 - '@rollup/rollup-win32-arm64-msvc': 4.55.2 - '@rollup/rollup-win32-ia32-msvc': 4.55.2 - '@rollup/rollup-win32-x64-gnu': 4.55.2 - '@rollup/rollup-win32-x64-msvc': 4.55.2 + '@rollup/rollup-android-arm-eabi': 4.57.0 + '@rollup/rollup-android-arm64': 4.57.0 + '@rollup/rollup-darwin-arm64': 4.57.0 + '@rollup/rollup-darwin-x64': 4.57.0 + '@rollup/rollup-freebsd-arm64': 4.57.0 + '@rollup/rollup-freebsd-x64': 4.57.0 + '@rollup/rollup-linux-arm-gnueabihf': 4.57.0 + '@rollup/rollup-linux-arm-musleabihf': 4.57.0 + '@rollup/rollup-linux-arm64-gnu': 4.57.0 + '@rollup/rollup-linux-arm64-musl': 4.57.0 + '@rollup/rollup-linux-loong64-gnu': 4.57.0 + '@rollup/rollup-linux-loong64-musl': 4.57.0 + '@rollup/rollup-linux-ppc64-gnu': 4.57.0 + '@rollup/rollup-linux-ppc64-musl': 4.57.0 + '@rollup/rollup-linux-riscv64-gnu': 4.57.0 + '@rollup/rollup-linux-riscv64-musl': 4.57.0 + '@rollup/rollup-linux-s390x-gnu': 4.57.0 + '@rollup/rollup-linux-x64-gnu': 4.57.0 + '@rollup/rollup-linux-x64-musl': 4.57.0 + '@rollup/rollup-openbsd-x64': 4.57.0 + '@rollup/rollup-openharmony-arm64': 4.57.0 + '@rollup/rollup-win32-arm64-msvc': 4.57.0 + '@rollup/rollup-win32-ia32-msvc': 4.57.0 + '@rollup/rollup-win32-x64-gnu': 4.57.0 + '@rollup/rollup-win32-x64-msvc': 4.57.0 fsevents: 2.3.3 run-parallel@1.2.0: @@ -2024,14 +2076,14 @@ snapshots: typescript: 5.9.3 webpack: 5.104.1 - ts-node@10.9.2(@types/node@25.0.9)(typescript@5.9.3): + ts-node@10.9.2(@types/node@25.0.10)(typescript@5.9.3): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.12 '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 25.0.9 + '@types/node': 25.0.10 acorn: 8.15.0 acorn-walk: 8.3.4 arg: 4.1.3 @@ -2113,4 +2165,4 @@ snapshots: zod@4.1.8: {} - zod@4.3.5: {} + zod@4.3.6: {} diff --git a/src/opencode.ts b/src/opencode.ts index f060211..3b10a4b 100644 --- a/src/opencode.ts +++ b/src/opencode.ts @@ -1,9 +1,10 @@ import { useContextKey } from '@kevisual/context' import { createSkill, type QueryRouterServer, tool, type QueryRouter, type Skill } from './route.ts' import { type App } from './app.ts' -import { type Plugin } from "@opencode-ai/plugin" +import { PluginInput, type Plugin, Hooks } from "@opencode-ai/plugin" import { filter } from '@kevisual/js-filter'; + export const addCallFn = (app: App) => { app.route({ path: 'call', @@ -34,10 +35,12 @@ export const addCallFn = (app: App) => { ctx.forward(res); }).addTo(app) } + export const createRouterAgentPluginFn = (opts?: { router?: App | QueryRouterServer, //** 过滤比如,WHERE metadata.tags includes 'opencode' */ - query?: string + query?: string, + hooks?: (plugin: PluginInput) => Promise }) => { let router = opts?.router if (!router) { @@ -60,10 +63,14 @@ export const createRouterAgentPluginFn = (opts?: { return !!metadata.skill } return false - }) + }); + // opencode run "查看系统信息" - const AgentPlugin: Plugin = async ({ project, client, $, directory, worktree }) => { + const AgentPlugin: Plugin = async (pluginInput) => { + useContextKey('plugin-input', () => pluginInput, true) + const hooks = opts?.hooks ? await opts.hooks(pluginInput) : {} return { + ...hooks, 'tool': { ...routes.reduce((acc, route) => { const metadata = route.metadata as Skill @@ -96,13 +103,18 @@ export const createRouterAgentPluginFn = (opts?: { } } return acc; - }, {} as Record) + }, {} as Record), + ...hooks?.tool }, - 'tool.execute.before': async (opts) => { - // console.log('CnbPlugin: tool.execute.before', opts.tool); - // delete toolSkills['cnb-login-verify'] - } + // 'tool.execute.before': async (opts) => { + // // console.log('CnbPlugin: tool.execute.before', opts.tool); + // // delete toolSkills['cnb-login-verify'] + // }, } } return AgentPlugin } + +export const usePluginInput = (): PluginInput => { + return useContextKey('plugin-input') +} \ No newline at end of file