Compare commits
22
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a47b0ed90 | ||
|
|
722904fe4f | ||
|
|
93cef701c0 | ||
|
|
0c3ff84f44 | ||
|
|
ba2e3c16b2 | ||
|
|
4712c18a58 | ||
|
|
9e156ea168 | ||
|
|
68f4aa220e | ||
|
|
3a0e00dd7f | ||
|
|
66b4e5e020 | ||
|
|
8b8d4fa066 | ||
|
|
6253ef0c27 | ||
|
|
c6ebc7ff7c | ||
|
|
985663620f | ||
|
|
c796b9a19e | ||
|
|
6ea108a03b | ||
|
|
280eb16e77 | ||
|
|
930e94a3ea | ||
|
|
629e866ff0 | ||
|
|
c08fa5675f | ||
|
|
cc50b778eb | ||
|
|
00fa68b3a7 |
@@ -75,6 +75,7 @@ jobs:
|
|||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: unit-${{ matrix.settings.name }}-${{ github.run_attempt }}
|
name: unit-${{ matrix.settings.name }}-${{ github.run_attempt }}
|
||||||
|
include-hidden-files: true
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
retention-days: 7
|
retention-days: 7
|
||||||
path: packages/*/.artifacts/unit/junit.xml
|
path: packages/*/.artifacts/unit/junit.xml
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
},
|
},
|
||||||
"packages/app": {
|
"packages/app": {
|
||||||
"name": "@opencode-ai/app",
|
"name": "@opencode-ai/app",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@kobalte/core": "catalog:",
|
"@kobalte/core": "catalog:",
|
||||||
"@opencode-ai/sdk": "workspace:*",
|
"@opencode-ai/sdk": "workspace:*",
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
},
|
},
|
||||||
"packages/console/app": {
|
"packages/console/app": {
|
||||||
"name": "@opencode-ai/console-app",
|
"name": "@opencode-ai/console-app",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cloudflare/vite-plugin": "1.15.2",
|
"@cloudflare/vite-plugin": "1.15.2",
|
||||||
"@ibm/plex": "6.4.1",
|
"@ibm/plex": "6.4.1",
|
||||||
@@ -114,7 +114,7 @@
|
|||||||
},
|
},
|
||||||
"packages/console/core": {
|
"packages/console/core": {
|
||||||
"name": "@opencode-ai/console-core",
|
"name": "@opencode-ai/console-core",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-sts": "3.782.0",
|
"@aws-sdk/client-sts": "3.782.0",
|
||||||
"@jsx-email/render": "1.1.1",
|
"@jsx-email/render": "1.1.1",
|
||||||
@@ -141,7 +141,7 @@
|
|||||||
},
|
},
|
||||||
"packages/console/function": {
|
"packages/console/function": {
|
||||||
"name": "@opencode-ai/console-function",
|
"name": "@opencode-ai/console-function",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ai-sdk/anthropic": "3.0.64",
|
"@ai-sdk/anthropic": "3.0.64",
|
||||||
"@ai-sdk/openai": "3.0.48",
|
"@ai-sdk/openai": "3.0.48",
|
||||||
@@ -165,7 +165,7 @@
|
|||||||
},
|
},
|
||||||
"packages/console/mail": {
|
"packages/console/mail": {
|
||||||
"name": "@opencode-ai/console-mail",
|
"name": "@opencode-ai/console-mail",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jsx-email/all": "2.2.3",
|
"@jsx-email/all": "2.2.3",
|
||||||
"@jsx-email/cli": "1.4.3",
|
"@jsx-email/cli": "1.4.3",
|
||||||
@@ -189,7 +189,7 @@
|
|||||||
},
|
},
|
||||||
"packages/desktop": {
|
"packages/desktop": {
|
||||||
"name": "@opencode-ai/desktop",
|
"name": "@opencode-ai/desktop",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@opencode-ai/app": "workspace:*",
|
"@opencode-ai/app": "workspace:*",
|
||||||
"@opencode-ai/ui": "workspace:*",
|
"@opencode-ai/ui": "workspace:*",
|
||||||
@@ -222,7 +222,7 @@
|
|||||||
},
|
},
|
||||||
"packages/desktop-electron": {
|
"packages/desktop-electron": {
|
||||||
"name": "@opencode-ai/desktop-electron",
|
"name": "@opencode-ai/desktop-electron",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@opencode-ai/app": "workspace:*",
|
"@opencode-ai/app": "workspace:*",
|
||||||
"@opencode-ai/ui": "workspace:*",
|
"@opencode-ai/ui": "workspace:*",
|
||||||
@@ -254,7 +254,7 @@
|
|||||||
},
|
},
|
||||||
"packages/enterprise": {
|
"packages/enterprise": {
|
||||||
"name": "@opencode-ai/enterprise",
|
"name": "@opencode-ai/enterprise",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@opencode-ai/ui": "workspace:*",
|
"@opencode-ai/ui": "workspace:*",
|
||||||
"@opencode-ai/util": "workspace:*",
|
"@opencode-ai/util": "workspace:*",
|
||||||
@@ -283,7 +283,7 @@
|
|||||||
},
|
},
|
||||||
"packages/function": {
|
"packages/function": {
|
||||||
"name": "@opencode-ai/function",
|
"name": "@opencode-ai/function",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@octokit/auth-app": "8.0.1",
|
"@octokit/auth-app": "8.0.1",
|
||||||
"@octokit/rest": "catalog:",
|
"@octokit/rest": "catalog:",
|
||||||
@@ -299,7 +299,7 @@
|
|||||||
},
|
},
|
||||||
"packages/opencode": {
|
"packages/opencode": {
|
||||||
"name": "opencode",
|
"name": "opencode",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"bin": {
|
"bin": {
|
||||||
"opencode": "./bin/opencode",
|
"opencode": "./bin/opencode",
|
||||||
},
|
},
|
||||||
@@ -371,6 +371,7 @@
|
|||||||
"jsonc-parser": "3.3.1",
|
"jsonc-parser": "3.3.1",
|
||||||
"mime-types": "3.0.2",
|
"mime-types": "3.0.2",
|
||||||
"minimatch": "10.0.3",
|
"minimatch": "10.0.3",
|
||||||
|
"npm-package-arg": "13.0.2",
|
||||||
"open": "10.1.2",
|
"open": "10.1.2",
|
||||||
"opencode-gitlab-auth": "2.0.1",
|
"opencode-gitlab-auth": "2.0.1",
|
||||||
"opencode-poe-auth": "0.0.1",
|
"opencode-poe-auth": "0.0.1",
|
||||||
@@ -412,6 +413,7 @@
|
|||||||
"@types/bun": "catalog:",
|
"@types/bun": "catalog:",
|
||||||
"@types/cross-spawn": "catalog:",
|
"@types/cross-spawn": "catalog:",
|
||||||
"@types/mime-types": "3.0.1",
|
"@types/mime-types": "3.0.1",
|
||||||
|
"@types/npm-package-arg": "6.1.4",
|
||||||
"@types/npmcli__arborist": "6.3.3",
|
"@types/npmcli__arborist": "6.3.3",
|
||||||
"@types/semver": "^7.5.8",
|
"@types/semver": "^7.5.8",
|
||||||
"@types/turndown": "5.0.5",
|
"@types/turndown": "5.0.5",
|
||||||
@@ -428,7 +430,7 @@
|
|||||||
},
|
},
|
||||||
"packages/plugin": {
|
"packages/plugin": {
|
||||||
"name": "@opencode-ai/plugin",
|
"name": "@opencode-ai/plugin",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@opencode-ai/sdk": "workspace:*",
|
"@opencode-ai/sdk": "workspace:*",
|
||||||
"zod": "catalog:",
|
"zod": "catalog:",
|
||||||
@@ -462,7 +464,7 @@
|
|||||||
},
|
},
|
||||||
"packages/sdk/js": {
|
"packages/sdk/js": {
|
||||||
"name": "@opencode-ai/sdk",
|
"name": "@opencode-ai/sdk",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cross-spawn": "catalog:",
|
"cross-spawn": "catalog:",
|
||||||
},
|
},
|
||||||
@@ -477,7 +479,7 @@
|
|||||||
},
|
},
|
||||||
"packages/slack": {
|
"packages/slack": {
|
||||||
"name": "@opencode-ai/slack",
|
"name": "@opencode-ai/slack",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@opencode-ai/sdk": "workspace:*",
|
"@opencode-ai/sdk": "workspace:*",
|
||||||
"@slack/bolt": "^3.17.1",
|
"@slack/bolt": "^3.17.1",
|
||||||
@@ -512,7 +514,7 @@
|
|||||||
},
|
},
|
||||||
"packages/ui": {
|
"packages/ui": {
|
||||||
"name": "@opencode-ai/ui",
|
"name": "@opencode-ai/ui",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@kobalte/core": "catalog:",
|
"@kobalte/core": "catalog:",
|
||||||
"@opencode-ai/sdk": "workspace:*",
|
"@opencode-ai/sdk": "workspace:*",
|
||||||
@@ -560,7 +562,7 @@
|
|||||||
},
|
},
|
||||||
"packages/util": {
|
"packages/util": {
|
||||||
"name": "@opencode-ai/util",
|
"name": "@opencode-ai/util",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"zod": "catalog:",
|
"zod": "catalog:",
|
||||||
},
|
},
|
||||||
@@ -571,7 +573,7 @@
|
|||||||
},
|
},
|
||||||
"packages/web": {
|
"packages/web": {
|
||||||
"name": "@opencode-ai/web",
|
"name": "@opencode-ai/web",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/cloudflare": "12.6.3",
|
"@astrojs/cloudflare": "12.6.3",
|
||||||
"@astrojs/markdown-remark": "6.3.1",
|
"@astrojs/markdown-remark": "6.3.1",
|
||||||
|
|||||||
+4
-4
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"nodeModules": {
|
"nodeModules": {
|
||||||
"x86_64-linux": "sha256-0jwPCu2Lod433GPQLHN8eEkhfpPviDFfkFJmuvkRdlE=",
|
"x86_64-linux": "sha256-LRhPPrOKCGUSCEWTpAxPdWKTKVNkg82WrvD25cP3jts=",
|
||||||
"aarch64-linux": "sha256-Qi0IkGkaIBKZsPLTO8kaTbCVL0cEfVOm/Y/6VUVI9TY=",
|
"aarch64-linux": "sha256-sbNxkil47n+B7v6ds5EYFybLytXUyRlu0Cpka0ZmDx4=",
|
||||||
"aarch64-darwin": "sha256-1eZBBLgYVkjg5RYN/etR1Mb5UjU3VelElBB5ug5hQdc=",
|
"aarch64-darwin": "sha256-5+99gtpIHGygMW3VBAexNhmaORgI8LCxPk/Gf1fW/ds=",
|
||||||
"x86_64-darwin": "sha256-jdXgA+kZb/foFHR40UiPif6rsA2GDVCCVHnJR3jBUGI="
|
"x86_64-darwin": "sha256-LqnvZGGnQaRxIoowOr5gf6lFgDhbgQhVPiAcRTtU6fE="
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@opencode-ai/app",
|
"name": "@opencode-ai/app",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"description": "",
|
"description": "",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"serve": "vite preview",
|
"serve": "vite preview",
|
||||||
"test": "bun run test:unit",
|
"test": "bun run test:unit",
|
||||||
"test:ci": "bun test --preload ./happydom.ts ./src --reporter=junit --reporter-outfile=.artifacts/unit/junit.xml",
|
"test:ci": "mkdir -p .artifacts/unit && bun test --preload ./happydom.ts ./src --reporter=junit --reporter-outfile=.artifacts/unit/junit.xml",
|
||||||
"test:unit": "bun test --preload ./happydom.ts ./src",
|
"test:unit": "bun test --preload ./happydom.ts ./src",
|
||||||
"test:unit:watch": "bun test --watch --preload ./happydom.ts ./src",
|
"test:unit:watch": "bun test --watch --preload ./happydom.ts ./src",
|
||||||
"test:e2e": "playwright test",
|
"test:e2e": "playwright test",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@opencode-ai/console-app",
|
"name": "@opencode-ai/console-app",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json.schemastore.org/package.json",
|
"$schema": "https://json.schemastore.org/package.json",
|
||||||
"name": "@opencode-ai/console-core",
|
"name": "@opencode-ai/console-core",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@opencode-ai/console-function",
|
"name": "@opencode-ai/console-function",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"$schema": "https://json.schemastore.org/package.json",
|
"$schema": "https://json.schemastore.org/package.json",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@opencode-ai/console-mail",
|
"name": "@opencode-ai/console-mail",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jsx-email/all": "2.2.3",
|
"@jsx-email/all": "2.2.3",
|
||||||
"@jsx-email/cli": "1.4.3",
|
"@jsx-email/cli": "1.4.3",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@opencode-ai/desktop-electron",
|
"name": "@opencode-ai/desktop-electron",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "https://opencode.ai",
|
"homepage": "https://opencode.ai",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@opencode-ai/desktop",
|
"name": "@opencode-ai/desktop",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@opencode-ai/enterprise",
|
"name": "@opencode-ai/enterprise",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
id = "opencode"
|
id = "opencode"
|
||||||
name = "OpenCode"
|
name = "OpenCode"
|
||||||
description = "The open source coding agent."
|
description = "The open source coding agent."
|
||||||
version = "1.3.13"
|
version = "1.3.15"
|
||||||
schema_version = 1
|
schema_version = 1
|
||||||
authors = ["Anomaly"]
|
authors = ["Anomaly"]
|
||||||
repository = "https://github.com/anomalyco/opencode"
|
repository = "https://github.com/anomalyco/opencode"
|
||||||
@@ -11,26 +11,26 @@ name = "OpenCode"
|
|||||||
icon = "./icons/opencode.svg"
|
icon = "./icons/opencode.svg"
|
||||||
|
|
||||||
[agent_servers.opencode.targets.darwin-aarch64]
|
[agent_servers.opencode.targets.darwin-aarch64]
|
||||||
archive = "https://github.com/anomalyco/opencode/releases/download/v1.3.13/opencode-darwin-arm64.zip"
|
archive = "https://github.com/anomalyco/opencode/releases/download/v1.3.15/opencode-darwin-arm64.zip"
|
||||||
cmd = "./opencode"
|
cmd = "./opencode"
|
||||||
args = ["acp"]
|
args = ["acp"]
|
||||||
|
|
||||||
[agent_servers.opencode.targets.darwin-x86_64]
|
[agent_servers.opencode.targets.darwin-x86_64]
|
||||||
archive = "https://github.com/anomalyco/opencode/releases/download/v1.3.13/opencode-darwin-x64.zip"
|
archive = "https://github.com/anomalyco/opencode/releases/download/v1.3.15/opencode-darwin-x64.zip"
|
||||||
cmd = "./opencode"
|
cmd = "./opencode"
|
||||||
args = ["acp"]
|
args = ["acp"]
|
||||||
|
|
||||||
[agent_servers.opencode.targets.linux-aarch64]
|
[agent_servers.opencode.targets.linux-aarch64]
|
||||||
archive = "https://github.com/anomalyco/opencode/releases/download/v1.3.13/opencode-linux-arm64.tar.gz"
|
archive = "https://github.com/anomalyco/opencode/releases/download/v1.3.15/opencode-linux-arm64.tar.gz"
|
||||||
cmd = "./opencode"
|
cmd = "./opencode"
|
||||||
args = ["acp"]
|
args = ["acp"]
|
||||||
|
|
||||||
[agent_servers.opencode.targets.linux-x86_64]
|
[agent_servers.opencode.targets.linux-x86_64]
|
||||||
archive = "https://github.com/anomalyco/opencode/releases/download/v1.3.13/opencode-linux-x64.tar.gz"
|
archive = "https://github.com/anomalyco/opencode/releases/download/v1.3.15/opencode-linux-x64.tar.gz"
|
||||||
cmd = "./opencode"
|
cmd = "./opencode"
|
||||||
args = ["acp"]
|
args = ["acp"]
|
||||||
|
|
||||||
[agent_servers.opencode.targets.windows-x86_64]
|
[agent_servers.opencode.targets.windows-x86_64]
|
||||||
archive = "https://github.com/anomalyco/opencode/releases/download/v1.3.13/opencode-windows-x64.zip"
|
archive = "https://github.com/anomalyco/opencode/releases/download/v1.3.15/opencode-windows-x64.zip"
|
||||||
cmd = "./opencode.exe"
|
cmd = "./opencode.exe"
|
||||||
args = ["acp"]
|
args = ["acp"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@opencode-ai/function",
|
"name": "@opencode-ai/function",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"$schema": "https://json.schemastore.org/package.json",
|
"$schema": "https://json.schemastore.org/package.json",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json.schemastore.org/package.json",
|
"$schema": "https://json.schemastore.org/package.json",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"name": "opencode",
|
"name": "opencode",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
"prepare": "effect-language-service patch || true",
|
"prepare": "effect-language-service patch || true",
|
||||||
"typecheck": "tsgo --noEmit",
|
"typecheck": "tsgo --noEmit",
|
||||||
"test": "bun test --timeout 30000",
|
"test": "bun test --timeout 30000",
|
||||||
"test:ci": "bun test --timeout 30000 --reporter=junit --reporter-outfile=.artifacts/unit/junit.xml",
|
"test:ci": "mkdir -p .artifacts/unit && bun test --timeout 30000 --reporter=junit --reporter-outfile=.artifacts/unit/junit.xml",
|
||||||
"build": "bun run script/build.ts",
|
"build": "bun run script/build.ts",
|
||||||
"upgrade-opentui": "bun run script/upgrade-opentui.ts",
|
"upgrade-opentui": "bun run script/upgrade-opentui.ts",
|
||||||
"dev": "bun run --conditions=browser ./src/index.ts",
|
"dev": "bun run --conditions=browser ./src/index.ts",
|
||||||
@@ -54,6 +54,7 @@
|
|||||||
"@types/bun": "catalog:",
|
"@types/bun": "catalog:",
|
||||||
"@types/cross-spawn": "catalog:",
|
"@types/cross-spawn": "catalog:",
|
||||||
"@types/mime-types": "3.0.1",
|
"@types/mime-types": "3.0.1",
|
||||||
|
"@types/npm-package-arg": "6.1.4",
|
||||||
"@types/npmcli__arborist": "6.3.3",
|
"@types/npmcli__arborist": "6.3.3",
|
||||||
"@types/semver": "^7.5.8",
|
"@types/semver": "^7.5.8",
|
||||||
"@types/turndown": "5.0.5",
|
"@types/turndown": "5.0.5",
|
||||||
@@ -135,6 +136,7 @@
|
|||||||
"jsonc-parser": "3.3.1",
|
"jsonc-parser": "3.3.1",
|
||||||
"mime-types": "3.0.2",
|
"mime-types": "3.0.2",
|
||||||
"minimatch": "10.0.3",
|
"minimatch": "10.0.3",
|
||||||
|
"npm-package-arg": "13.0.2",
|
||||||
"open": "10.1.2",
|
"open": "10.1.2",
|
||||||
"opencode-gitlab-auth": "2.0.1",
|
"opencode-gitlab-auth": "2.0.1",
|
||||||
"opencode-poe-auth": "0.0.1",
|
"opencode-poe-auth": "0.0.1",
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ for (const item of targets) {
|
|||||||
conditions: ["browser"],
|
conditions: ["browser"],
|
||||||
tsconfig: "./tsconfig.json",
|
tsconfig: "./tsconfig.json",
|
||||||
plugins: [plugin],
|
plugins: [plugin],
|
||||||
|
external: ["node-gyp"],
|
||||||
compile: {
|
compile: {
|
||||||
autoloadBunfig: false,
|
autoloadBunfig: false,
|
||||||
autoloadDotenv: false,
|
autoloadDotenv: false,
|
||||||
|
|||||||
@@ -235,11 +235,27 @@ Once individual tools are effectified, change `Tool.Info` (`tool/tool.ts`) so `i
|
|||||||
2. Update `Tool.define()` factory to work with Effects
|
2. Update `Tool.define()` factory to work with Effects
|
||||||
3. Update `SessionPrompt` to `yield*` tool results instead of `await`ing
|
3. Update `SessionPrompt` to `yield*` tool results instead of `await`ing
|
||||||
|
|
||||||
|
### Tool migration details
|
||||||
|
|
||||||
|
Until the tool interface itself returns `Effect`, use this transitional pattern for migrated tools:
|
||||||
|
|
||||||
|
- `Tool.defineEffect(...)` should `yield*` the services the tool depends on and close over them in the returned tool definition.
|
||||||
|
- Keep the bridge at the Promise boundary only. Prefer a single `Effect.runPromise(...)` in the temporary `async execute(...)` implementation, and move the inner logic into `Effect.fn(...)` helpers instead of scattering `runPromise` islands through the tool body.
|
||||||
|
- If a tool starts requiring new services, wire them into `ToolRegistry.defaultLayer` so production callers resolve the same dependencies as tests.
|
||||||
|
|
||||||
|
Tool tests should use the existing Effect helpers in `packages/opencode/test/lib/effect.ts`:
|
||||||
|
|
||||||
|
- Use `testEffect(...)` / `it.live(...)` instead of creating fake local wrappers around effectful tools.
|
||||||
|
- Yield the real tool export, then initialize it: `const info = yield* ReadTool`, `const tool = yield* Effect.promise(() => info.init())`.
|
||||||
|
- Run tests inside a real instance with `provideTmpdirInstance(...)` or `provideInstance(tmpdirScoped(...))` so instance-scoped services resolve exactly as they do in production.
|
||||||
|
|
||||||
|
This keeps migrated tool tests aligned with the production service graph today, and makes the eventual `Tool.Info` → `Effect` cleanup mostly mechanical later.
|
||||||
|
|
||||||
Individual tools, ordered by value:
|
Individual tools, ordered by value:
|
||||||
|
|
||||||
- [ ] `apply_patch.ts` — HIGH: multi-step orchestration, error accumulation, Bus events
|
- [ ] `apply_patch.ts` — HIGH: multi-step orchestration, error accumulation, Bus events
|
||||||
- [ ] `bash.ts` — HIGH: shell orchestration, quoting, timeout handling, output capture
|
- [ ] `bash.ts` — HIGH: shell orchestration, quoting, timeout handling, output capture
|
||||||
- [ ] `read.ts` — HIGH: streaming I/O, readline, binary detection → FileSystem + Stream
|
- [x] `read.ts` — HIGH: streaming I/O, readline, binary detection → FileSystem + Stream
|
||||||
- [ ] `edit.ts` — HIGH: multi-step diff/format/publish pipeline, FileWatcher lock
|
- [ ] `edit.ts` — HIGH: multi-step diff/format/publish pipeline, FileWatcher lock
|
||||||
- [ ] `grep.ts` — MEDIUM: spawns ripgrep → ChildProcessSpawner, timeout handling
|
- [ ] `grep.ts` — MEDIUM: spawns ripgrep → ChildProcessSpawner, timeout handling
|
||||||
- [ ] `write.ts` — MEDIUM: permission checks, diagnostics polling, Bus events
|
- [ ] `write.ts` — MEDIUM: permission checks, diagnostics polling, Bus events
|
||||||
|
|||||||
@@ -52,6 +52,11 @@ export type AccountOrgs = {
|
|||||||
orgs: readonly Org[]
|
orgs: readonly Org[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ActiveOrg = {
|
||||||
|
account: Info
|
||||||
|
org: Org
|
||||||
|
}
|
||||||
|
|
||||||
class RemoteConfig extends Schema.Class<RemoteConfig>("RemoteConfig")({
|
class RemoteConfig extends Schema.Class<RemoteConfig>("RemoteConfig")({
|
||||||
config: Schema.Record(Schema.String, Schema.Json),
|
config: Schema.Record(Schema.String, Schema.Json),
|
||||||
}) {}
|
}) {}
|
||||||
@@ -137,6 +142,7 @@ const mapAccountServiceError =
|
|||||||
export namespace Account {
|
export namespace Account {
|
||||||
export interface Interface {
|
export interface Interface {
|
||||||
readonly active: () => Effect.Effect<Option.Option<Info>, AccountError>
|
readonly active: () => Effect.Effect<Option.Option<Info>, AccountError>
|
||||||
|
readonly activeOrg: () => Effect.Effect<Option.Option<ActiveOrg>, AccountError>
|
||||||
readonly list: () => Effect.Effect<Info[], AccountError>
|
readonly list: () => Effect.Effect<Info[], AccountError>
|
||||||
readonly orgsByAccount: () => Effect.Effect<readonly AccountOrgs[], AccountError>
|
readonly orgsByAccount: () => Effect.Effect<readonly AccountOrgs[], AccountError>
|
||||||
readonly remove: (accountID: AccountID) => Effect.Effect<void, AccountError>
|
readonly remove: (accountID: AccountID) => Effect.Effect<void, AccountError>
|
||||||
@@ -279,19 +285,31 @@ export namespace Account {
|
|||||||
resolveAccess(accountID).pipe(Effect.map(Option.map((r) => r.accessToken))),
|
resolveAccess(accountID).pipe(Effect.map(Option.map((r) => r.accessToken))),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const activeOrg = Effect.fn("Account.activeOrg")(function* () {
|
||||||
|
const activeAccount = yield* repo.active()
|
||||||
|
if (Option.isNone(activeAccount)) return Option.none<ActiveOrg>()
|
||||||
|
|
||||||
|
const account = activeAccount.value
|
||||||
|
if (!account.active_org_id) return Option.none<ActiveOrg>()
|
||||||
|
|
||||||
|
const accountOrgs = yield* orgs(account.id)
|
||||||
|
const org = accountOrgs.find((item) => item.id === account.active_org_id)
|
||||||
|
if (!org) return Option.none<ActiveOrg>()
|
||||||
|
|
||||||
|
return Option.some({ account, org })
|
||||||
|
})
|
||||||
|
|
||||||
const orgsByAccount = Effect.fn("Account.orgsByAccount")(function* () {
|
const orgsByAccount = Effect.fn("Account.orgsByAccount")(function* () {
|
||||||
const accounts = yield* repo.list()
|
const accounts = yield* repo.list()
|
||||||
const [errors, results] = yield* Effect.partition(
|
return yield* Effect.forEach(
|
||||||
accounts,
|
accounts,
|
||||||
(account) => orgs(account.id).pipe(Effect.map((orgs) => ({ account, orgs }))),
|
(account) =>
|
||||||
|
orgs(account.id).pipe(
|
||||||
|
Effect.catch(() => Effect.succeed([] as readonly Org[])),
|
||||||
|
Effect.map((orgs) => ({ account, orgs })),
|
||||||
|
),
|
||||||
{ concurrency: 3 },
|
{ concurrency: 3 },
|
||||||
)
|
)
|
||||||
for (const error of errors) {
|
|
||||||
yield* Effect.logWarning("failed to fetch orgs for account").pipe(
|
|
||||||
Effect.annotateLogs({ error: String(error) }),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return results
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const orgs = Effect.fn("Account.orgs")(function* (accountID: AccountID) {
|
const orgs = Effect.fn("Account.orgs")(function* (accountID: AccountID) {
|
||||||
@@ -396,6 +414,7 @@ export namespace Account {
|
|||||||
|
|
||||||
return Service.of({
|
return Service.of({
|
||||||
active: repo.active,
|
active: repo.active,
|
||||||
|
activeOrg,
|
||||||
list: repo.list,
|
list: repo.list,
|
||||||
orgsByAccount,
|
orgsByAccount,
|
||||||
remove: repo.remove,
|
remove: repo.remove,
|
||||||
@@ -417,6 +436,26 @@ export namespace Account {
|
|||||||
return Option.getOrUndefined(await runPromise((service) => service.active()))
|
return Option.getOrUndefined(await runPromise((service) => service.active()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function list(): Promise<Info[]> {
|
||||||
|
return runPromise((service) => service.list())
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function activeOrg(): Promise<ActiveOrg | undefined> {
|
||||||
|
return Option.getOrUndefined(await runPromise((service) => service.activeOrg()))
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function orgsByAccount(): Promise<readonly AccountOrgs[]> {
|
||||||
|
return runPromise((service) => service.orgsByAccount())
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function orgs(accountID: AccountID): Promise<readonly Org[]> {
|
||||||
|
return runPromise((service) => service.orgs(accountID))
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function switchOrg(accountID: AccountID, orgID: OrgID) {
|
||||||
|
return runPromise((service) => service.use(accountID, Option.some(orgID)))
|
||||||
|
}
|
||||||
|
|
||||||
export async function token(accountID: AccountID): Promise<AccessToken | undefined> {
|
export async function token(accountID: AccountID): Promise<AccessToken | undefined> {
|
||||||
const t = await runPromise((service) => service.token(accountID))
|
const t = await runPromise((service) => service.token(accountID))
|
||||||
return Option.getOrUndefined(t)
|
return Option.getOrUndefined(t)
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import { CommandProvider, useCommandDialog } from "@tui/component/dialog-command
|
|||||||
import { DialogAgent } from "@tui/component/dialog-agent"
|
import { DialogAgent } from "@tui/component/dialog-agent"
|
||||||
import { DialogSessionList } from "@tui/component/dialog-session-list"
|
import { DialogSessionList } from "@tui/component/dialog-session-list"
|
||||||
import { DialogWorkspaceList } from "@tui/component/dialog-workspace-list"
|
import { DialogWorkspaceList } from "@tui/component/dialog-workspace-list"
|
||||||
|
import { DialogConsoleOrg } from "@tui/component/dialog-console-org"
|
||||||
import { KeybindProvider, useKeybind } from "@tui/context/keybind"
|
import { KeybindProvider, useKeybind } from "@tui/context/keybind"
|
||||||
import { ThemeProvider, useTheme } from "@tui/context/theme"
|
import { ThemeProvider, useTheme } from "@tui/context/theme"
|
||||||
import { Home } from "@tui/routes/home"
|
import { Home } from "@tui/routes/home"
|
||||||
@@ -124,14 +125,16 @@ import type { EventSource } from "./context/sdk"
|
|||||||
import { DialogVariant } from "./component/dialog-variant"
|
import { DialogVariant } from "./component/dialog-variant"
|
||||||
|
|
||||||
function rendererConfig(_config: TuiConfig.Info): CliRendererConfig {
|
function rendererConfig(_config: TuiConfig.Info): CliRendererConfig {
|
||||||
|
const mouseEnabled = !Flag.OPENCODE_DISABLE_MOUSE && (_config.mouse ?? true)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
externalOutputMode: "passthrough",
|
|
||||||
targetFps: 60,
|
targetFps: 60,
|
||||||
gatherStats: false,
|
gatherStats: false,
|
||||||
exitOnCtrlC: false,
|
exitOnCtrlC: false,
|
||||||
useKittyKeyboard: { events: process.platform === "win32" },
|
useKittyKeyboard: { events: process.platform === "win32" },
|
||||||
autoFocus: false,
|
autoFocus: false,
|
||||||
openConsoleOnError: false,
|
openConsoleOnError: false,
|
||||||
|
useMouse: mouseEnabled,
|
||||||
consoleOptions: {
|
consoleOptions: {
|
||||||
keyBindings: [{ name: "y", ctrl: true, action: "copy-selection" }],
|
keyBindings: [{ name: "y", ctrl: true, action: "copy-selection" }],
|
||||||
onCopySelection: (text) => {
|
onCopySelection: (text) => {
|
||||||
@@ -629,6 +632,23 @@ function App(props: { onSnapshot?: () => Promise<string[]> }) {
|
|||||||
},
|
},
|
||||||
category: "Provider",
|
category: "Provider",
|
||||||
},
|
},
|
||||||
|
...(sync.data.console_state.switchableOrgCount > 1
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
title: "Switch org",
|
||||||
|
value: "console.org.switch",
|
||||||
|
suggested: Boolean(sync.data.console_state.activeOrgName),
|
||||||
|
slash: {
|
||||||
|
name: "org",
|
||||||
|
aliases: ["orgs", "switch-org"],
|
||||||
|
},
|
||||||
|
onSelect: () => {
|
||||||
|
dialog.replace(() => <DialogConsoleOrg />)
|
||||||
|
},
|
||||||
|
category: "Provider",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
{
|
{
|
||||||
title: "View status",
|
title: "View status",
|
||||||
keybind: "status_view",
|
keybind: "status_view",
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
import { createResource, createMemo } from "solid-js"
|
||||||
|
import { DialogSelect } from "@tui/ui/dialog-select"
|
||||||
|
import { useSDK } from "@tui/context/sdk"
|
||||||
|
import { useDialog } from "@tui/ui/dialog"
|
||||||
|
import { useToast } from "@tui/ui/toast"
|
||||||
|
import { useTheme } from "@tui/context/theme"
|
||||||
|
import type { ExperimentalConsoleListOrgsResponse } from "@opencode-ai/sdk/v2"
|
||||||
|
|
||||||
|
type OrgOption = ExperimentalConsoleListOrgsResponse["orgs"][number]
|
||||||
|
|
||||||
|
const accountHost = (url: string) => {
|
||||||
|
try {
|
||||||
|
return new URL(url).host
|
||||||
|
} catch {
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const accountLabel = (item: Pick<OrgOption, "accountEmail" | "accountUrl">) =>
|
||||||
|
`${item.accountEmail} ${accountHost(item.accountUrl)}`
|
||||||
|
|
||||||
|
export function DialogConsoleOrg() {
|
||||||
|
const sdk = useSDK()
|
||||||
|
const dialog = useDialog()
|
||||||
|
const toast = useToast()
|
||||||
|
const { theme } = useTheme()
|
||||||
|
|
||||||
|
const [orgs] = createResource(async () => {
|
||||||
|
const result = await sdk.client.experimental.console.listOrgs({}, { throwOnError: true })
|
||||||
|
return result.data?.orgs ?? []
|
||||||
|
})
|
||||||
|
|
||||||
|
const current = createMemo(() => orgs()?.find((item) => item.active))
|
||||||
|
|
||||||
|
const options = createMemo(() => {
|
||||||
|
const listed = orgs()
|
||||||
|
if (listed === undefined) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
title: "Loading orgs...",
|
||||||
|
value: "loading",
|
||||||
|
onSelect: () => {},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listed.length === 0) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
title: "No orgs found",
|
||||||
|
value: "empty",
|
||||||
|
onSelect: () => {},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
return listed
|
||||||
|
.toSorted((a, b) => {
|
||||||
|
const activeAccountA = a.active ? 0 : 1
|
||||||
|
const activeAccountB = b.active ? 0 : 1
|
||||||
|
if (activeAccountA !== activeAccountB) return activeAccountA - activeAccountB
|
||||||
|
|
||||||
|
const accountCompare = accountLabel(a).localeCompare(accountLabel(b))
|
||||||
|
if (accountCompare !== 0) return accountCompare
|
||||||
|
|
||||||
|
return a.orgName.localeCompare(b.orgName)
|
||||||
|
})
|
||||||
|
.map((item) => ({
|
||||||
|
title: item.orgName,
|
||||||
|
value: item,
|
||||||
|
category: accountLabel(item),
|
||||||
|
categoryView: (
|
||||||
|
<box flexDirection="row" gap={2}>
|
||||||
|
<text fg={theme.accent}>{item.accountEmail}</text>
|
||||||
|
<text fg={theme.textMuted}>{accountHost(item.accountUrl)}</text>
|
||||||
|
</box>
|
||||||
|
),
|
||||||
|
onSelect: async () => {
|
||||||
|
if (item.active) {
|
||||||
|
dialog.clear()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
await sdk.client.experimental.console.switchOrg(
|
||||||
|
{
|
||||||
|
accountID: item.accountID,
|
||||||
|
orgID: item.orgID,
|
||||||
|
},
|
||||||
|
{ throwOnError: true },
|
||||||
|
)
|
||||||
|
|
||||||
|
await sdk.client.instance.dispose()
|
||||||
|
toast.show({
|
||||||
|
message: `Switched to ${item.orgName}`,
|
||||||
|
variant: "info",
|
||||||
|
})
|
||||||
|
dialog.clear()
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
|
return <DialogSelect<string | OrgOption> title="Switch org" options={options()} current={current()} />
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ import { createDialogProviderOptions, DialogProvider } from "./dialog-provider"
|
|||||||
import { DialogVariant } from "./dialog-variant"
|
import { DialogVariant } from "./dialog-variant"
|
||||||
import { useKeybind } from "../context/keybind"
|
import { useKeybind } from "../context/keybind"
|
||||||
import * as fuzzysort from "fuzzysort"
|
import * as fuzzysort from "fuzzysort"
|
||||||
|
import { consoleManagedProviderLabel } from "@tui/util/provider-origin"
|
||||||
|
|
||||||
export function useConnected() {
|
export function useConnected() {
|
||||||
const sync = useSync()
|
const sync = useSync()
|
||||||
@@ -46,7 +47,11 @@ export function DialogModel(props: { providerID?: string }) {
|
|||||||
key: item,
|
key: item,
|
||||||
value: { providerID: provider.id, modelID: model.id },
|
value: { providerID: provider.id, modelID: model.id },
|
||||||
title: model.name ?? item.modelID,
|
title: model.name ?? item.modelID,
|
||||||
description: provider.name,
|
description: consoleManagedProviderLabel(
|
||||||
|
sync.data.console_state.consoleManagedProviders,
|
||||||
|
provider.id,
|
||||||
|
provider.name,
|
||||||
|
),
|
||||||
category,
|
category,
|
||||||
disabled: provider.id === "opencode" && model.id.includes("-nano"),
|
disabled: provider.id === "opencode" && model.id.includes("-nano"),
|
||||||
footer: model.cost?.input === 0 && provider.id === "opencode" ? "Free" : undefined,
|
footer: model.cost?.input === 0 && provider.id === "opencode" ? "Free" : undefined,
|
||||||
@@ -84,7 +89,9 @@ export function DialogModel(props: { providerID?: string }) {
|
|||||||
description: favorites.some((item) => item.providerID === provider.id && item.modelID === model)
|
description: favorites.some((item) => item.providerID === provider.id && item.modelID === model)
|
||||||
? "(Favorite)"
|
? "(Favorite)"
|
||||||
: undefined,
|
: undefined,
|
||||||
category: connected() ? provider.name : undefined,
|
category: connected()
|
||||||
|
? consoleManagedProviderLabel(sync.data.console_state.consoleManagedProviders, provider.id, provider.name)
|
||||||
|
: undefined,
|
||||||
disabled: provider.id === "opencode" && model.includes("-nano"),
|
disabled: provider.id === "opencode" && model.includes("-nano"),
|
||||||
footer: info.cost?.input === 0 && provider.id === "opencode" ? "Free" : undefined,
|
footer: info.cost?.input === 0 && provider.id === "opencode" ? "Free" : undefined,
|
||||||
onSelect() {
|
onSelect() {
|
||||||
@@ -132,7 +139,11 @@ export function DialogModel(props: { providerID?: string }) {
|
|||||||
props.providerID ? sync.data.provider.find((x) => x.id === props.providerID) : null,
|
props.providerID ? sync.data.provider.find((x) => x.id === props.providerID) : null,
|
||||||
)
|
)
|
||||||
|
|
||||||
const title = createMemo(() => provider()?.name ?? "Select model")
|
const title = createMemo(() => {
|
||||||
|
const value = provider()
|
||||||
|
if (!value) return "Select model"
|
||||||
|
return consoleManagedProviderLabel(sync.data.console_state.consoleManagedProviders, value.id, value.name)
|
||||||
|
})
|
||||||
|
|
||||||
function onSelect(providerID: string, modelID: string) {
|
function onSelect(providerID: string, modelID: string) {
|
||||||
local.model.set({ providerID, modelID }, { recent: true })
|
local.model.set({ providerID, modelID }, { recent: true })
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { DialogModel } from "./dialog-model"
|
|||||||
import { useKeyboard } from "@opentui/solid"
|
import { useKeyboard } from "@opentui/solid"
|
||||||
import { Clipboard } from "@tui/util/clipboard"
|
import { Clipboard } from "@tui/util/clipboard"
|
||||||
import { useToast } from "../ui/toast"
|
import { useToast } from "../ui/toast"
|
||||||
|
import { CONSOLE_MANAGED_ICON, isConsoleManagedProvider } from "@tui/util/provider-origin"
|
||||||
|
|
||||||
const PROVIDER_PRIORITY: Record<string, number> = {
|
const PROVIDER_PRIORITY: Record<string, number> = {
|
||||||
opencode: 0,
|
opencode: 0,
|
||||||
@@ -28,11 +29,16 @@ export function createDialogProviderOptions() {
|
|||||||
const dialog = useDialog()
|
const dialog = useDialog()
|
||||||
const sdk = useSDK()
|
const sdk = useSDK()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
const { theme } = useTheme()
|
||||||
const options = createMemo(() => {
|
const options = createMemo(() => {
|
||||||
return pipe(
|
return pipe(
|
||||||
sync.data.provider_next.all,
|
sync.data.provider_next.all,
|
||||||
sortBy((x) => PROVIDER_PRIORITY[x.id] ?? 99),
|
sortBy((x) => PROVIDER_PRIORITY[x.id] ?? 99),
|
||||||
map((provider) => ({
|
map((provider) => {
|
||||||
|
const consoleManaged = isConsoleManagedProvider(sync.data.console_state.consoleManagedProviders, provider.id)
|
||||||
|
const connected = sync.data.provider_next.connected.includes(provider.id)
|
||||||
|
|
||||||
|
return {
|
||||||
title: provider.name,
|
title: provider.name,
|
||||||
value: provider.id,
|
value: provider.id,
|
||||||
description: {
|
description: {
|
||||||
@@ -41,8 +47,16 @@ export function createDialogProviderOptions() {
|
|||||||
openai: "(ChatGPT Plus/Pro or API key)",
|
openai: "(ChatGPT Plus/Pro or API key)",
|
||||||
"opencode-go": "Low cost subscription for everyone",
|
"opencode-go": "Low cost subscription for everyone",
|
||||||
}[provider.id],
|
}[provider.id],
|
||||||
|
footer: consoleManaged ? sync.data.console_state.activeOrgName : undefined,
|
||||||
category: provider.id in PROVIDER_PRIORITY ? "Popular" : "Other",
|
category: provider.id in PROVIDER_PRIORITY ? "Popular" : "Other",
|
||||||
|
gutter: consoleManaged ? (
|
||||||
|
<text fg={theme.textMuted}>{CONSOLE_MANAGED_ICON}</text>
|
||||||
|
) : connected ? (
|
||||||
|
<text fg={theme.success}>✓</text>
|
||||||
|
) : undefined,
|
||||||
async onSelect() {
|
async onSelect() {
|
||||||
|
if (consoleManaged) return
|
||||||
|
|
||||||
const methods = sync.data.provider_auth[provider.id] ?? [
|
const methods = sync.data.provider_auth[provider.id] ?? [
|
||||||
{
|
{
|
||||||
type: "api",
|
type: "api",
|
||||||
@@ -95,12 +109,22 @@ export function createDialogProviderOptions() {
|
|||||||
}
|
}
|
||||||
if (result.data?.method === "code") {
|
if (result.data?.method === "code") {
|
||||||
dialog.replace(() => (
|
dialog.replace(() => (
|
||||||
<CodeMethod providerID={provider.id} title={method.label} index={index} authorization={result.data!} />
|
<CodeMethod
|
||||||
|
providerID={provider.id}
|
||||||
|
title={method.label}
|
||||||
|
index={index}
|
||||||
|
authorization={result.data!}
|
||||||
|
/>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
if (result.data?.method === "auto") {
|
if (result.data?.method === "auto") {
|
||||||
dialog.replace(() => (
|
dialog.replace(() => (
|
||||||
<AutoMethod providerID={provider.id} title={method.label} index={index} authorization={result.data!} />
|
<AutoMethod
|
||||||
|
providerID={provider.id}
|
||||||
|
title={method.label}
|
||||||
|
index={index}
|
||||||
|
authorization={result.data!}
|
||||||
|
/>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +132,8 @@ export function createDialogProviderOptions() {
|
|||||||
return dialog.replace(() => <ApiMethod providerID={provider.id} title={method.label} />)
|
return dialog.replace(() => <ApiMethod providerID={provider.id} title={method.label} />)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})),
|
}
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
return options
|
return options
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import { useToast } from "../../ui/toast"
|
|||||||
import { useKV } from "../../context/kv"
|
import { useKV } from "../../context/kv"
|
||||||
import { useTextareaKeybindings } from "../textarea-keybindings"
|
import { useTextareaKeybindings } from "../textarea-keybindings"
|
||||||
import { DialogSkill } from "../dialog-skill"
|
import { DialogSkill } from "../dialog-skill"
|
||||||
|
import { CONSOLE_MANAGED_ICON, consoleManagedProviderLabel } from "@tui/util/provider-origin"
|
||||||
|
|
||||||
export type PromptProps = {
|
export type PromptProps = {
|
||||||
sessionID?: string
|
sessionID?: string
|
||||||
@@ -94,6 +95,15 @@ export function Prompt(props: PromptProps) {
|
|||||||
const list = createMemo(() => props.placeholders?.normal ?? [])
|
const list = createMemo(() => props.placeholders?.normal ?? [])
|
||||||
const shell = createMemo(() => props.placeholders?.shell ?? [])
|
const shell = createMemo(() => props.placeholders?.shell ?? [])
|
||||||
const [auto, setAuto] = createSignal<AutocompleteRef>()
|
const [auto, setAuto] = createSignal<AutocompleteRef>()
|
||||||
|
const activeOrgName = createMemo(() => sync.data.console_state.activeOrgName)
|
||||||
|
const canSwitchOrgs = createMemo(() => sync.data.console_state.switchableOrgCount > 1)
|
||||||
|
const currentProviderLabel = createMemo(() => {
|
||||||
|
const current = local.model.current()
|
||||||
|
const provider = local.model.parsed().provider
|
||||||
|
if (!current) return provider
|
||||||
|
return consoleManagedProviderLabel(sync.data.console_state.consoleManagedProviders, current.providerID, provider)
|
||||||
|
})
|
||||||
|
const hasRightContent = createMemo(() => Boolean(props.right || activeOrgName()))
|
||||||
|
|
||||||
function promptModelWarning() {
|
function promptModelWarning() {
|
||||||
toast.show({
|
toast.show({
|
||||||
@@ -831,8 +841,20 @@ export function Prompt(props: PromptProps) {
|
|||||||
return !!current
|
return !!current
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const suggestion = createMemo(() => {
|
||||||
|
if (!props.sessionID) return
|
||||||
|
if (store.mode !== "normal") return
|
||||||
|
if (store.prompt.input) return
|
||||||
|
const current = status()
|
||||||
|
if (current.type !== "idle") return
|
||||||
|
const value = current.suggestion?.trim()
|
||||||
|
if (!value) return
|
||||||
|
return value
|
||||||
|
})
|
||||||
|
|
||||||
const placeholderText = createMemo(() => {
|
const placeholderText = createMemo(() => {
|
||||||
if (props.showPlaceholder === false) return undefined
|
if (props.showPlaceholder === false) return undefined
|
||||||
|
if (suggestion()) return suggestion()
|
||||||
if (store.mode === "shell") {
|
if (store.mode === "shell") {
|
||||||
if (!shell().length) return undefined
|
if (!shell().length) return undefined
|
||||||
const example = shell()[store.placeholder % shell().length]
|
const example = shell()[store.placeholder % shell().length]
|
||||||
@@ -923,6 +945,16 @@ export function Prompt(props: PromptProps) {
|
|||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (!store.prompt.input && e.name === "right" && !e.ctrl && !e.meta && !e.shift && !e.super) {
|
||||||
|
const value = suggestion()
|
||||||
|
if (value) {
|
||||||
|
input.setText(value)
|
||||||
|
setStore("prompt", "input", value)
|
||||||
|
input.gotoBufferEnd()
|
||||||
|
e.preventDefault()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
// Check clipboard for images before terminal-handled paste runs.
|
// Check clipboard for images before terminal-handled paste runs.
|
||||||
// This helps terminals that forward Ctrl+V to the app; Windows
|
// This helps terminals that forward Ctrl+V to the app; Windows
|
||||||
// Terminal 1.25+ usually handles Ctrl+V before this path.
|
// Terminal 1.25+ usually handles Ctrl+V before this path.
|
||||||
@@ -1095,7 +1127,7 @@ export function Prompt(props: PromptProps) {
|
|||||||
<text flexShrink={0} fg={keybind.leader ? theme.textMuted : theme.text}>
|
<text flexShrink={0} fg={keybind.leader ? theme.textMuted : theme.text}>
|
||||||
{local.model.parsed().model}
|
{local.model.parsed().model}
|
||||||
</text>
|
</text>
|
||||||
<text fg={theme.textMuted}>{local.model.parsed().provider}</text>
|
<text fg={theme.textMuted}>{currentProviderLabel()}</text>
|
||||||
<Show when={showVariant()}>
|
<Show when={showVariant()}>
|
||||||
<text fg={theme.textMuted}>·</text>
|
<text fg={theme.textMuted}>·</text>
|
||||||
<text>
|
<text>
|
||||||
@@ -1105,7 +1137,22 @@ export function Prompt(props: PromptProps) {
|
|||||||
</box>
|
</box>
|
||||||
</Show>
|
</Show>
|
||||||
</box>
|
</box>
|
||||||
|
<Show when={hasRightContent()}>
|
||||||
|
<box flexDirection="row" gap={1} alignItems="center">
|
||||||
{props.right}
|
{props.right}
|
||||||
|
<Show when={activeOrgName()}>
|
||||||
|
<text
|
||||||
|
fg={theme.textMuted}
|
||||||
|
onMouseUp={() => {
|
||||||
|
if (!canSwitchOrgs()) return
|
||||||
|
command.trigger("console.org.switch")
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{`${CONSOLE_MANAGED_ICON} ${activeOrgName()}`}
|
||||||
|
</text>
|
||||||
|
</Show>
|
||||||
|
</box>
|
||||||
|
</Show>
|
||||||
</box>
|
</box>
|
||||||
</box>
|
</box>
|
||||||
</box>
|
</box>
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import { batch, onMount } from "solid-js"
|
|||||||
import { Log } from "@/util/log"
|
import { Log } from "@/util/log"
|
||||||
import type { Path } from "@opencode-ai/sdk"
|
import type { Path } from "@opencode-ai/sdk"
|
||||||
import type { Workspace } from "@opencode-ai/sdk/v2"
|
import type { Workspace } from "@opencode-ai/sdk/v2"
|
||||||
|
import { ConsoleState, emptyConsoleState, type ConsoleState as ConsoleStateType } from "@/config/console-state"
|
||||||
|
|
||||||
export const { use: useSync, provider: SyncProvider } = createSimpleContext({
|
export const { use: useSync, provider: SyncProvider } = createSimpleContext({
|
||||||
name: "Sync",
|
name: "Sync",
|
||||||
@@ -38,6 +39,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
|
|||||||
provider: Provider[]
|
provider: Provider[]
|
||||||
provider_default: Record<string, string>
|
provider_default: Record<string, string>
|
||||||
provider_next: ProviderListResponse
|
provider_next: ProviderListResponse
|
||||||
|
console_state: ConsoleStateType
|
||||||
provider_auth: Record<string, ProviderAuthMethod[]>
|
provider_auth: Record<string, ProviderAuthMethod[]>
|
||||||
agent: Agent[]
|
agent: Agent[]
|
||||||
command: Command[]
|
command: Command[]
|
||||||
@@ -81,6 +83,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
|
|||||||
default: {},
|
default: {},
|
||||||
connected: [],
|
connected: [],
|
||||||
},
|
},
|
||||||
|
console_state: emptyConsoleState,
|
||||||
provider_auth: {},
|
provider_auth: {},
|
||||||
config: {},
|
config: {},
|
||||||
status: "loading",
|
status: "loading",
|
||||||
@@ -230,7 +233,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "session.status": {
|
case "session.status": {
|
||||||
setStore("session_status", event.properties.sessionID, event.properties.status)
|
setStore("session_status", event.properties.sessionID, reconcile(event.properties.status))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,6 +368,10 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
|
|||||||
// blocking - include session.list when continuing a session
|
// blocking - include session.list when continuing a session
|
||||||
const providersPromise = sdk.client.config.providers({}, { throwOnError: true })
|
const providersPromise = sdk.client.config.providers({}, { throwOnError: true })
|
||||||
const providerListPromise = sdk.client.provider.list({}, { throwOnError: true })
|
const providerListPromise = sdk.client.provider.list({}, { throwOnError: true })
|
||||||
|
const consoleStatePromise = sdk.client.experimental.console
|
||||||
|
.get({}, { throwOnError: true })
|
||||||
|
.then((x) => ConsoleState.parse(x.data))
|
||||||
|
.catch(() => emptyConsoleState)
|
||||||
const agentsPromise = sdk.client.app.agents({}, { throwOnError: true })
|
const agentsPromise = sdk.client.app.agents({}, { throwOnError: true })
|
||||||
const configPromise = sdk.client.config.get({}, { throwOnError: true })
|
const configPromise = sdk.client.config.get({}, { throwOnError: true })
|
||||||
const blockingRequests: Promise<unknown>[] = [
|
const blockingRequests: Promise<unknown>[] = [
|
||||||
@@ -379,6 +386,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
const providersResponse = providersPromise.then((x) => x.data!)
|
const providersResponse = providersPromise.then((x) => x.data!)
|
||||||
const providerListResponse = providerListPromise.then((x) => x.data!)
|
const providerListResponse = providerListPromise.then((x) => x.data!)
|
||||||
|
const consoleStateResponse = consoleStatePromise
|
||||||
const agentsResponse = agentsPromise.then((x) => x.data ?? [])
|
const agentsResponse = agentsPromise.then((x) => x.data ?? [])
|
||||||
const configResponse = configPromise.then((x) => x.data!)
|
const configResponse = configPromise.then((x) => x.data!)
|
||||||
const sessionListResponse = args.continue ? sessionListPromise : undefined
|
const sessionListResponse = args.continue ? sessionListPromise : undefined
|
||||||
@@ -386,20 +394,23 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
|
|||||||
return Promise.all([
|
return Promise.all([
|
||||||
providersResponse,
|
providersResponse,
|
||||||
providerListResponse,
|
providerListResponse,
|
||||||
|
consoleStateResponse,
|
||||||
agentsResponse,
|
agentsResponse,
|
||||||
configResponse,
|
configResponse,
|
||||||
...(sessionListResponse ? [sessionListResponse] : []),
|
...(sessionListResponse ? [sessionListResponse] : []),
|
||||||
]).then((responses) => {
|
]).then((responses) => {
|
||||||
const providers = responses[0]
|
const providers = responses[0]
|
||||||
const providerList = responses[1]
|
const providerList = responses[1]
|
||||||
const agents = responses[2]
|
const consoleState = responses[2]
|
||||||
const config = responses[3]
|
const agents = responses[3]
|
||||||
const sessions = responses[4]
|
const config = responses[4]
|
||||||
|
const sessions = responses[5]
|
||||||
|
|
||||||
batch(() => {
|
batch(() => {
|
||||||
setStore("provider", reconcile(providers.providers))
|
setStore("provider", reconcile(providers.providers))
|
||||||
setStore("provider_default", reconcile(providers.default))
|
setStore("provider_default", reconcile(providers.default))
|
||||||
setStore("provider_next", reconcile(providerList))
|
setStore("provider_next", reconcile(providerList))
|
||||||
|
setStore("console_state", reconcile(consoleState))
|
||||||
setStore("agent", reconcile(agents))
|
setStore("agent", reconcile(agents))
|
||||||
setStore("config", reconcile(config))
|
setStore("config", reconcile(config))
|
||||||
if (sessions !== undefined) setStore("session", reconcile(sessions))
|
if (sessions !== undefined) setStore("session", reconcile(sessions))
|
||||||
@@ -411,6 +422,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
|
|||||||
// non-blocking
|
// non-blocking
|
||||||
Promise.all([
|
Promise.all([
|
||||||
...(args.continue ? [] : [sessionListPromise.then((sessions) => setStore("session", reconcile(sessions)))]),
|
...(args.continue ? [] : [sessionListPromise.then((sessions) => setStore("session", reconcile(sessions)))]),
|
||||||
|
consoleStatePromise.then((consoleState) => setStore("console_state", reconcile(consoleState))),
|
||||||
sdk.client.command.list().then((x) => setStore("command", reconcile(x.data ?? []))),
|
sdk.client.command.list().then((x) => setStore("command", reconcile(x.data ?? []))),
|
||||||
sdk.client.lsp.status().then((x) => setStore("lsp", reconcile(x.data!))),
|
sdk.client.lsp.status().then((x) => setStore("lsp", reconcile(x.data!))),
|
||||||
sdk.client.mcp.status().then((x) => setStore("mcp", reconcile(x.data!))),
|
sdk.client.mcp.status().then((x) => setStore("mcp", reconcile(x.data!))),
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export interface DialogSelectOption<T = any> {
|
|||||||
description?: string
|
description?: string
|
||||||
footer?: JSX.Element | string
|
footer?: JSX.Element | string
|
||||||
category?: string
|
category?: string
|
||||||
|
categoryView?: JSX.Element
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
bg?: RGBA
|
bg?: RGBA
|
||||||
gutter?: JSX.Element
|
gutter?: JSX.Element
|
||||||
@@ -291,9 +292,16 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
|
|||||||
<>
|
<>
|
||||||
<Show when={category}>
|
<Show when={category}>
|
||||||
<box paddingTop={index() > 0 ? 1 : 0} paddingLeft={3}>
|
<box paddingTop={index() > 0 ? 1 : 0} paddingLeft={3}>
|
||||||
|
<Show
|
||||||
|
when={options[0]?.categoryView}
|
||||||
|
fallback={
|
||||||
<text fg={theme.accent} attributes={TextAttributes.BOLD}>
|
<text fg={theme.accent} attributes={TextAttributes.BOLD}>
|
||||||
{category}
|
{category}
|
||||||
</text>
|
</text>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{options[0]?.categoryView}
|
||||||
|
</Show>
|
||||||
</box>
|
</box>
|
||||||
</Show>
|
</Show>
|
||||||
<For each={options}>
|
<For each={options}>
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
export const CONSOLE_MANAGED_ICON = "⌂"
|
||||||
|
|
||||||
|
const contains = (consoleManagedProviders: string[] | ReadonlySet<string>, providerID: string) =>
|
||||||
|
Array.isArray(consoleManagedProviders)
|
||||||
|
? consoleManagedProviders.includes(providerID)
|
||||||
|
: consoleManagedProviders.has(providerID)
|
||||||
|
|
||||||
|
export const isConsoleManagedProvider = (consoleManagedProviders: string[] | ReadonlySet<string>, providerID: string) =>
|
||||||
|
contains(consoleManagedProviders, providerID)
|
||||||
|
|
||||||
|
export const consoleManagedProviderSuffix = (
|
||||||
|
consoleManagedProviders: string[] | ReadonlySet<string>,
|
||||||
|
providerID: string,
|
||||||
|
) => (contains(consoleManagedProviders, providerID) ? ` ${CONSOLE_MANAGED_ICON}` : "")
|
||||||
|
|
||||||
|
export const consoleManagedProviderLabel = (
|
||||||
|
consoleManagedProviders: string[] | ReadonlySet<string>,
|
||||||
|
providerID: string,
|
||||||
|
providerName: string,
|
||||||
|
) => `${providerName}${consoleManagedProviderSuffix(consoleManagedProviders, providerID)}`
|
||||||
@@ -33,6 +33,7 @@ import { Account } from "@/account"
|
|||||||
import { isRecord } from "@/util/record"
|
import { isRecord } from "@/util/record"
|
||||||
import { ConfigPaths } from "./paths"
|
import { ConfigPaths } from "./paths"
|
||||||
import { Filesystem } from "@/util/filesystem"
|
import { Filesystem } from "@/util/filesystem"
|
||||||
|
import type { ConsoleState } from "./console-state"
|
||||||
import { AppFileSystem } from "@/filesystem"
|
import { AppFileSystem } from "@/filesystem"
|
||||||
import { InstanceState } from "@/effect/instance-state"
|
import { InstanceState } from "@/effect/instance-state"
|
||||||
import { makeRuntime } from "@/effect/run-service"
|
import { makeRuntime } from "@/effect/run-service"
|
||||||
@@ -1050,11 +1051,13 @@ export namespace Config {
|
|||||||
config: Info
|
config: Info
|
||||||
directories: string[]
|
directories: string[]
|
||||||
deps: Promise<void>[]
|
deps: Promise<void>[]
|
||||||
|
consoleState: ConsoleState
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Interface {
|
export interface Interface {
|
||||||
readonly get: () => Effect.Effect<Info>
|
readonly get: () => Effect.Effect<Info>
|
||||||
readonly getGlobal: () => Effect.Effect<Info>
|
readonly getGlobal: () => Effect.Effect<Info>
|
||||||
|
readonly getConsoleState: () => Effect.Effect<ConsoleState>
|
||||||
readonly update: (config: Info) => Effect.Effect<void>
|
readonly update: (config: Info) => Effect.Effect<void>
|
||||||
readonly updateGlobal: (config: Info) => Effect.Effect<Info>
|
readonly updateGlobal: (config: Info) => Effect.Effect<Info>
|
||||||
readonly invalidate: (wait?: boolean) => Effect.Effect<void>
|
readonly invalidate: (wait?: boolean) => Effect.Effect<void>
|
||||||
@@ -1260,6 +1263,8 @@ export namespace Config {
|
|||||||
const auth = yield* authSvc.all().pipe(Effect.orDie)
|
const auth = yield* authSvc.all().pipe(Effect.orDie)
|
||||||
|
|
||||||
let result: Info = {}
|
let result: Info = {}
|
||||||
|
const consoleManagedProviders = new Set<string>()
|
||||||
|
let activeOrgName: string | undefined
|
||||||
|
|
||||||
const scope = (source: string): PluginScope => {
|
const scope = (source: string): PluginScope => {
|
||||||
if (source.startsWith("http://") || source.startsWith("https://")) return "global"
|
if (source.startsWith("http://") || source.startsWith("https://")) return "global"
|
||||||
@@ -1371,26 +1376,31 @@ export namespace Config {
|
|||||||
log.debug("loaded custom config from OPENCODE_CONFIG_CONTENT")
|
log.debug("loaded custom config from OPENCODE_CONFIG_CONTENT")
|
||||||
}
|
}
|
||||||
|
|
||||||
const active = Option.getOrUndefined(yield* accountSvc.active().pipe(Effect.orDie))
|
const activeOrg = Option.getOrUndefined(
|
||||||
if (active?.active_org_id) {
|
yield* accountSvc.activeOrg().pipe(Effect.catch(() => Effect.succeed(Option.none()))),
|
||||||
|
)
|
||||||
|
if (activeOrg) {
|
||||||
yield* Effect.gen(function* () {
|
yield* Effect.gen(function* () {
|
||||||
const [configOpt, tokenOpt] = yield* Effect.all(
|
const [configOpt, tokenOpt] = yield* Effect.all(
|
||||||
[accountSvc.config(active.id, active.active_org_id!), accountSvc.token(active.id)],
|
[accountSvc.config(activeOrg.account.id, activeOrg.org.id), accountSvc.token(activeOrg.account.id)],
|
||||||
{ concurrency: 2 },
|
{ concurrency: 2 },
|
||||||
)
|
)
|
||||||
const token = Option.getOrUndefined(tokenOpt)
|
if (Option.isSome(tokenOpt)) {
|
||||||
if (token) {
|
process.env["OPENCODE_CONSOLE_TOKEN"] = tokenOpt.value
|
||||||
process.env["OPENCODE_CONSOLE_TOKEN"] = token
|
Env.set("OPENCODE_CONSOLE_TOKEN", tokenOpt.value)
|
||||||
Env.set("OPENCODE_CONSOLE_TOKEN", token)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = Option.getOrUndefined(configOpt)
|
activeOrgName = activeOrg.org.name
|
||||||
if (config) {
|
|
||||||
const source = `${active.url}/api/config`
|
if (Option.isSome(configOpt)) {
|
||||||
const next = yield* loadConfig(JSON.stringify(config), {
|
const source = `${activeOrg.account.url}/api/config`
|
||||||
|
const next = yield* loadConfig(JSON.stringify(configOpt.value), {
|
||||||
dir: path.dirname(source),
|
dir: path.dirname(source),
|
||||||
source,
|
source,
|
||||||
})
|
})
|
||||||
|
for (const providerID of Object.keys(next.provider ?? {})) {
|
||||||
|
consoleManagedProviders.add(providerID)
|
||||||
|
}
|
||||||
merge(source, next, "global")
|
merge(source, next, "global")
|
||||||
}
|
}
|
||||||
}).pipe(
|
}).pipe(
|
||||||
@@ -1456,6 +1466,11 @@ export namespace Config {
|
|||||||
config: result,
|
config: result,
|
||||||
directories,
|
directories,
|
||||||
deps,
|
deps,
|
||||||
|
consoleState: {
|
||||||
|
consoleManagedProviders: Array.from(consoleManagedProviders),
|
||||||
|
activeOrgName,
|
||||||
|
switchableOrgCount: 0,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -1473,6 +1488,10 @@ export namespace Config {
|
|||||||
return yield* InstanceState.use(state, (s) => s.directories)
|
return yield* InstanceState.use(state, (s) => s.directories)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const getConsoleState = Effect.fn("Config.getConsoleState")(function* () {
|
||||||
|
return yield* InstanceState.use(state, (s) => s.consoleState)
|
||||||
|
})
|
||||||
|
|
||||||
const waitForDependencies = Effect.fn("Config.waitForDependencies")(function* () {
|
const waitForDependencies = Effect.fn("Config.waitForDependencies")(function* () {
|
||||||
yield* InstanceState.useEffect(state, (s) => Effect.promise(() => Promise.all(s.deps).then(() => undefined)))
|
yield* InstanceState.useEffect(state, (s) => Effect.promise(() => Promise.all(s.deps).then(() => undefined)))
|
||||||
})
|
})
|
||||||
@@ -1528,6 +1547,7 @@ export namespace Config {
|
|||||||
return Service.of({
|
return Service.of({
|
||||||
get,
|
get,
|
||||||
getGlobal,
|
getGlobal,
|
||||||
|
getConsoleState,
|
||||||
update,
|
update,
|
||||||
updateGlobal,
|
updateGlobal,
|
||||||
invalidate,
|
invalidate,
|
||||||
@@ -1553,6 +1573,10 @@ export namespace Config {
|
|||||||
return runPromise((svc) => svc.getGlobal())
|
return runPromise((svc) => svc.getGlobal())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getConsoleState() {
|
||||||
|
return runPromise((svc) => svc.getConsoleState())
|
||||||
|
}
|
||||||
|
|
||||||
export async function update(config: Info) {
|
export async function update(config: Info) {
|
||||||
return runPromise((svc) => svc.update(config))
|
return runPromise((svc) => svc.update(config))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import z from "zod"
|
||||||
|
|
||||||
|
export const ConsoleState = z.object({
|
||||||
|
consoleManagedProviders: z.array(z.string()),
|
||||||
|
activeOrgName: z.string().optional(),
|
||||||
|
switchableOrgCount: z.number().int().nonnegative(),
|
||||||
|
})
|
||||||
|
|
||||||
|
export type ConsoleState = z.infer<typeof ConsoleState>
|
||||||
|
|
||||||
|
export const emptyConsoleState: ConsoleState = {
|
||||||
|
consoleManagedProviders: [],
|
||||||
|
activeOrgName: undefined,
|
||||||
|
switchableOrgCount: 0,
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ export const TuiOptions = z.object({
|
|||||||
.enum(["auto", "stacked"])
|
.enum(["auto", "stacked"])
|
||||||
.optional()
|
.optional()
|
||||||
.describe("Control diff rendering style: 'auto' adapts to terminal width, 'stacked' always shows single column"),
|
.describe("Control diff rendering style: 'auto' adapts to terminal width, 'stacked' always shows single column"),
|
||||||
|
mouse: z.boolean().optional().describe("Enable or disable mouse capture (default: true)"),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const TuiInfo = z
|
export const TuiInfo = z
|
||||||
|
|||||||
@@ -188,13 +188,23 @@ export namespace AppFileSystem {
|
|||||||
|
|
||||||
export function normalizePath(p: string): string {
|
export function normalizePath(p: string): string {
|
||||||
if (process.platform !== "win32") return p
|
if (process.platform !== "win32") return p
|
||||||
|
const resolved = pathResolve(windowsPath(p))
|
||||||
try {
|
try {
|
||||||
return realpathSync.native(p)
|
return realpathSync.native(resolved)
|
||||||
} catch {
|
} catch {
|
||||||
return p
|
return resolved
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function normalizePathPattern(p: string): string {
|
||||||
|
if (process.platform !== "win32") return p
|
||||||
|
if (p === "*") return p
|
||||||
|
const match = p.match(/^(.*)[\\/]\*$/)
|
||||||
|
if (!match) return normalizePath(p)
|
||||||
|
const dir = /^[A-Za-z]:$/.test(match[1]) ? match[1] + "\\" : match[1]
|
||||||
|
return join(normalizePath(dir), "*")
|
||||||
|
}
|
||||||
|
|
||||||
export function resolve(p: string): string {
|
export function resolve(p: string): string {
|
||||||
const resolved = pathResolve(windowsPath(p))
|
const resolved = pathResolve(windowsPath(p))
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ export namespace Flag {
|
|||||||
export const OPENCODE_ENABLE_EXPERIMENTAL_MODELS = truthy("OPENCODE_ENABLE_EXPERIMENTAL_MODELS")
|
export const OPENCODE_ENABLE_EXPERIMENTAL_MODELS = truthy("OPENCODE_ENABLE_EXPERIMENTAL_MODELS")
|
||||||
export const OPENCODE_DISABLE_AUTOCOMPACT = truthy("OPENCODE_DISABLE_AUTOCOMPACT")
|
export const OPENCODE_DISABLE_AUTOCOMPACT = truthy("OPENCODE_DISABLE_AUTOCOMPACT")
|
||||||
export const OPENCODE_DISABLE_MODELS_FETCH = truthy("OPENCODE_DISABLE_MODELS_FETCH")
|
export const OPENCODE_DISABLE_MODELS_FETCH = truthy("OPENCODE_DISABLE_MODELS_FETCH")
|
||||||
|
export const OPENCODE_DISABLE_MOUSE = truthy("OPENCODE_DISABLE_MOUSE")
|
||||||
export const OPENCODE_DISABLE_CLAUDE_CODE = truthy("OPENCODE_DISABLE_CLAUDE_CODE")
|
export const OPENCODE_DISABLE_CLAUDE_CODE = truthy("OPENCODE_DISABLE_CLAUDE_CODE")
|
||||||
export const OPENCODE_DISABLE_CLAUDE_CODE_PROMPT =
|
export const OPENCODE_DISABLE_CLAUDE_CODE_PROMPT =
|
||||||
OPENCODE_DISABLE_CLAUDE_CODE || truthy("OPENCODE_DISABLE_CLAUDE_CODE_PROMPT")
|
OPENCODE_DISABLE_CLAUDE_CODE || truthy("OPENCODE_DISABLE_CLAUDE_CODE_PROMPT")
|
||||||
@@ -72,6 +73,7 @@ export namespace Flag {
|
|||||||
export const OPENCODE_EXPERIMENTAL_PLAN_MODE = OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_PLAN_MODE")
|
export const OPENCODE_EXPERIMENTAL_PLAN_MODE = OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_PLAN_MODE")
|
||||||
export const OPENCODE_EXPERIMENTAL_WORKSPACES = OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_WORKSPACES")
|
export const OPENCODE_EXPERIMENTAL_WORKSPACES = OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_WORKSPACES")
|
||||||
export const OPENCODE_EXPERIMENTAL_MARKDOWN = !falsy("OPENCODE_EXPERIMENTAL_MARKDOWN")
|
export const OPENCODE_EXPERIMENTAL_MARKDOWN = !falsy("OPENCODE_EXPERIMENTAL_MARKDOWN")
|
||||||
|
export const OPENCODE_EXPERIMENTAL_NEXT_PROMPT = truthy("OPENCODE_EXPERIMENTAL_NEXT_PROMPT")
|
||||||
export const OPENCODE_MODELS_URL = process.env["OPENCODE_MODELS_URL"]
|
export const OPENCODE_MODELS_URL = process.env["OPENCODE_MODELS_URL"]
|
||||||
export const OPENCODE_MODELS_PATH = process.env["OPENCODE_MODELS_PATH"]
|
export const OPENCODE_MODELS_PATH = process.env["OPENCODE_MODELS_PATH"]
|
||||||
export const OPENCODE_DISABLE_EMBEDDED_WEB_UI = truthy("OPENCODE_DISABLE_EMBEDDED_WEB_UI")
|
export const OPENCODE_DISABLE_EMBEDDED_WEB_UI = truthy("OPENCODE_DISABLE_EMBEDDED_WEB_UI")
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { Arborist } from "@npmcli/arborist"
|
|||||||
|
|
||||||
export namespace Npm {
|
export namespace Npm {
|
||||||
const log = Log.create({ service: "npm" })
|
const log = Log.create({ service: "npm" })
|
||||||
|
const illegal = process.platform === "win32" ? new Set(["<", ">", ":", '"', "|", "?", "*"]) : undefined
|
||||||
|
|
||||||
export const InstallFailedError = NamedError.create(
|
export const InstallFailedError = NamedError.create(
|
||||||
"NpmInstallFailedError",
|
"NpmInstallFailedError",
|
||||||
@@ -19,8 +20,13 @@ export namespace Npm {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
export function sanitize(pkg: string) {
|
||||||
|
if (!illegal) return pkg
|
||||||
|
return Array.from(pkg, (char) => (illegal.has(char) || char.charCodeAt(0) < 32 ? "_" : char)).join("")
|
||||||
|
}
|
||||||
|
|
||||||
function directory(pkg: string) {
|
function directory(pkg: string) {
|
||||||
return path.join(Global.Path.cache, "packages", pkg)
|
return path.join(Global.Path.cache, "packages", sanitize(pkg))
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveEntryPoint(name: string, dir: string) {
|
function resolveEntryPoint(name: string, dir: string) {
|
||||||
@@ -67,6 +73,7 @@ export namespace Npm {
|
|||||||
binLinks: true,
|
binLinks: true,
|
||||||
progress: false,
|
progress: false,
|
||||||
savePrefix: "",
|
savePrefix: "",
|
||||||
|
ignoreScripts: true,
|
||||||
})
|
})
|
||||||
const tree = await arborist.loadVirtual().catch(() => {})
|
const tree = await arborist.loadVirtual().catch(() => {})
|
||||||
if (tree) {
|
if (tree) {
|
||||||
@@ -106,6 +113,7 @@ export namespace Npm {
|
|||||||
binLinks: true,
|
binLinks: true,
|
||||||
progress: false,
|
progress: false,
|
||||||
savePrefix: "",
|
savePrefix: "",
|
||||||
|
ignoreScripts: true,
|
||||||
})
|
})
|
||||||
await arb.reify().catch(() => {})
|
await arb.reify().catch(() => {})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import path from "path"
|
import path from "path"
|
||||||
import { fileURLToPath, pathToFileURL } from "url"
|
import { fileURLToPath, pathToFileURL } from "url"
|
||||||
|
import npa from "npm-package-arg"
|
||||||
import semver from "semver"
|
import semver from "semver"
|
||||||
import { Npm } from "@/npm"
|
import { Npm } from "@/npm"
|
||||||
import { Filesystem } from "@/util/filesystem"
|
import { Filesystem } from "@/util/filesystem"
|
||||||
@@ -12,11 +13,24 @@ export function isDeprecatedPlugin(spec: string) {
|
|||||||
return DEPRECATED_PLUGIN_PACKAGES.some((pkg) => spec.includes(pkg))
|
return DEPRECATED_PLUGIN_PACKAGES.some((pkg) => spec.includes(pkg))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parse(spec: string) {
|
||||||
|
try {
|
||||||
|
return npa(spec)
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
export function parsePluginSpecifier(spec: string) {
|
export function parsePluginSpecifier(spec: string) {
|
||||||
const lastAt = spec.lastIndexOf("@")
|
const hit = parse(spec)
|
||||||
const pkg = lastAt > 0 ? spec.substring(0, lastAt) : spec
|
if (hit?.type === "alias" && !hit.name) {
|
||||||
const version = lastAt > 0 ? spec.substring(lastAt + 1) : "latest"
|
const sub = (hit as npa.AliasResult).subSpec
|
||||||
return { pkg, version }
|
if (sub?.name) {
|
||||||
|
const version = !sub.rawSpec || sub.rawSpec === "*" ? "latest" : sub.rawSpec
|
||||||
|
return { pkg: sub.name, version }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hit?.name) return { pkg: spec, version: "" }
|
||||||
|
if (hit.raw === hit.name) return { pkg: hit.name, version: "latest" }
|
||||||
|
return { pkg: hit.name, version: hit.rawSpec }
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PluginSource = "file" | "npm"
|
export type PluginSource = "file" | "npm"
|
||||||
@@ -190,9 +204,11 @@ export async function checkPluginCompatibility(target: string, opencodeVersion:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function resolvePluginTarget(spec: string, parsed = parsePluginSpecifier(spec)) {
|
export async function resolvePluginTarget(spec: string) {
|
||||||
if (isPathPluginSpec(spec)) return resolvePathPluginTarget(spec)
|
if (isPathPluginSpec(spec)) return resolvePathPluginTarget(spec)
|
||||||
const result = await Npm.add(parsed.pkg + "@" + parsed.version)
|
const hit = parse(spec)
|
||||||
|
const pkg = hit?.name && hit.raw === hit.name ? `${hit.name}@latest` : spec
|
||||||
|
const result = await Npm.add(pkg)
|
||||||
return result.directory
|
return result.directory
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,116 @@ import { Instance } from "../../project/instance"
|
|||||||
import { Project } from "../../project/project"
|
import { Project } from "../../project/project"
|
||||||
import { MCP } from "../../mcp"
|
import { MCP } from "../../mcp"
|
||||||
import { Session } from "../../session"
|
import { Session } from "../../session"
|
||||||
|
import { Config } from "../../config/config"
|
||||||
|
import { ConsoleState } from "../../config/console-state"
|
||||||
|
import { Account, AccountID, OrgID } from "../../account"
|
||||||
import { zodToJsonSchema } from "zod-to-json-schema"
|
import { zodToJsonSchema } from "zod-to-json-schema"
|
||||||
import { errors } from "../error"
|
import { errors } from "../error"
|
||||||
import { lazy } from "../../util/lazy"
|
import { lazy } from "../../util/lazy"
|
||||||
import { WorkspaceRoutes } from "./workspace"
|
import { WorkspaceRoutes } from "./workspace"
|
||||||
|
|
||||||
|
const ConsoleOrgOption = z.object({
|
||||||
|
accountID: z.string(),
|
||||||
|
accountEmail: z.string(),
|
||||||
|
accountUrl: z.string(),
|
||||||
|
orgID: z.string(),
|
||||||
|
orgName: z.string(),
|
||||||
|
active: z.boolean(),
|
||||||
|
})
|
||||||
|
|
||||||
|
const ConsoleOrgList = z.object({
|
||||||
|
orgs: z.array(ConsoleOrgOption),
|
||||||
|
})
|
||||||
|
|
||||||
|
const ConsoleSwitchBody = z.object({
|
||||||
|
accountID: z.string(),
|
||||||
|
orgID: z.string(),
|
||||||
|
})
|
||||||
|
|
||||||
export const ExperimentalRoutes = lazy(() =>
|
export const ExperimentalRoutes = lazy(() =>
|
||||||
new Hono()
|
new Hono()
|
||||||
|
.get(
|
||||||
|
"/console",
|
||||||
|
describeRoute({
|
||||||
|
summary: "Get active Console provider metadata",
|
||||||
|
description: "Get the active Console org name and the set of provider IDs managed by that Console org.",
|
||||||
|
operationId: "experimental.console.get",
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "Active Console provider metadata",
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: resolver(ConsoleState),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
async (c) => {
|
||||||
|
const [consoleState, groups] = await Promise.all([Config.getConsoleState(), Account.orgsByAccount()])
|
||||||
|
return c.json({
|
||||||
|
...consoleState,
|
||||||
|
switchableOrgCount: groups.reduce((count, group) => count + group.orgs.length, 0),
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.get(
|
||||||
|
"/console/orgs",
|
||||||
|
describeRoute({
|
||||||
|
summary: "List switchable Console orgs",
|
||||||
|
description: "Get the available Console orgs across logged-in accounts, including the current active org.",
|
||||||
|
operationId: "experimental.console.listOrgs",
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "Switchable Console orgs",
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: resolver(ConsoleOrgList),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
async (c) => {
|
||||||
|
const [groups, active] = await Promise.all([Account.orgsByAccount(), Account.active()])
|
||||||
|
|
||||||
|
const orgs = groups.flatMap((group) =>
|
||||||
|
group.orgs.map((org) => ({
|
||||||
|
accountID: group.account.id,
|
||||||
|
accountEmail: group.account.email,
|
||||||
|
accountUrl: group.account.url,
|
||||||
|
orgID: org.id,
|
||||||
|
orgName: org.name,
|
||||||
|
active: !!active && active.id === group.account.id && active.active_org_id === org.id,
|
||||||
|
})),
|
||||||
|
)
|
||||||
|
return c.json({ orgs })
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.post(
|
||||||
|
"/console/switch",
|
||||||
|
describeRoute({
|
||||||
|
summary: "Switch active Console org",
|
||||||
|
description: "Persist a new active Console account/org selection for the current local OpenCode state.",
|
||||||
|
operationId: "experimental.console.switchOrg",
|
||||||
|
responses: {
|
||||||
|
200: {
|
||||||
|
description: "Switch success",
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: resolver(z.boolean()),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
validator("json", ConsoleSwitchBody),
|
||||||
|
async (c) => {
|
||||||
|
const body = c.req.valid("json")
|
||||||
|
await Account.switchOrg(AccountID.make(body.accountID), OrgID.make(body.orgID))
|
||||||
|
return c.json(true)
|
||||||
|
},
|
||||||
|
)
|
||||||
.get(
|
.get(
|
||||||
"/tool/ids",
|
"/tool/ids",
|
||||||
describeRoute({
|
describeRoute({
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ export namespace Session {
|
|||||||
const tokens = {
|
const tokens = {
|
||||||
total,
|
total,
|
||||||
input: adjustedInputTokens,
|
input: adjustedInputTokens,
|
||||||
output: outputTokens,
|
output: outputTokens - reasoningTokens,
|
||||||
reasoning: reasoningTokens,
|
reasoning: reasoningTokens,
|
||||||
cache: {
|
cache: {
|
||||||
write: cacheWriteInputTokens,
|
write: cacheWriteInputTokens,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { Plugin } from "../plugin"
|
|||||||
import PROMPT_PLAN from "../session/prompt/plan.txt"
|
import PROMPT_PLAN from "../session/prompt/plan.txt"
|
||||||
import BUILD_SWITCH from "../session/prompt/build-switch.txt"
|
import BUILD_SWITCH from "../session/prompt/build-switch.txt"
|
||||||
import MAX_STEPS from "../session/prompt/max-steps.txt"
|
import MAX_STEPS from "../session/prompt/max-steps.txt"
|
||||||
|
import PROMPT_SUGGEST_NEXT from "../session/prompt/suggest-next.txt"
|
||||||
import { ToolRegistry } from "../tool/registry"
|
import { ToolRegistry } from "../tool/registry"
|
||||||
import { Runner } from "@/effect/runner"
|
import { Runner } from "@/effect/runner"
|
||||||
import { MCP } from "../mcp"
|
import { MCP } from "../mcp"
|
||||||
@@ -249,6 +250,80 @@ export namespace SessionPrompt {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const suggest = Effect.fn("SessionPrompt.suggest")(function* (input: {
|
||||||
|
session: Session.Info
|
||||||
|
sessionID: SessionID
|
||||||
|
message: MessageV2.WithParts
|
||||||
|
}) {
|
||||||
|
if (input.session.parentID) return
|
||||||
|
const message = input.message.info
|
||||||
|
if (message.role !== "assistant") return
|
||||||
|
if (message.error) return
|
||||||
|
if (!message.finish) return
|
||||||
|
if (["tool-calls", "unknown"].includes(message.finish)) return
|
||||||
|
if ((yield* status.get(input.sessionID)).type !== "idle") return
|
||||||
|
|
||||||
|
// Use the same model for prompt-cache hit on the conversation prefix
|
||||||
|
const model = yield* Effect.promise(async () =>
|
||||||
|
Provider.getModel(message.providerID, message.modelID).catch(() => undefined),
|
||||||
|
)
|
||||||
|
if (!model) return
|
||||||
|
|
||||||
|
const ag = yield* agents.get(message.agent ?? "code")
|
||||||
|
if (!ag) return
|
||||||
|
|
||||||
|
// Full message history so the cached KV from the main conversation is reused
|
||||||
|
const msgs = yield* MessageV2.filterCompactedEffect(input.sessionID)
|
||||||
|
const real = (item: MessageV2.WithParts) =>
|
||||||
|
item.info.role === "user" && !item.parts.every((part) => "synthetic" in part && part.synthetic)
|
||||||
|
const parent = msgs.find((item) => item.info.id === message.parentID)
|
||||||
|
const user = parent && real(parent) ? parent.info : msgs.findLast((item) => real(item))?.info
|
||||||
|
if (!user || user.role !== "user") return
|
||||||
|
|
||||||
|
// Rebuild system prompt identical to the main loop for cache hit
|
||||||
|
const skills = yield* Effect.promise(() => SystemPrompt.skills(ag))
|
||||||
|
const env = yield* Effect.promise(() => SystemPrompt.environment(model))
|
||||||
|
const instructions = yield* instruction.system().pipe(Effect.orDie)
|
||||||
|
const modelMsgs = yield* Effect.promise(() => MessageV2.toModelMessages(msgs, model))
|
||||||
|
const system = [...env, ...(skills ? [skills] : []), ...instructions]
|
||||||
|
|
||||||
|
const text = yield* Effect.promise(async (signal) => {
|
||||||
|
const result = await LLM.stream({
|
||||||
|
agent: ag,
|
||||||
|
user,
|
||||||
|
system,
|
||||||
|
small: false,
|
||||||
|
tools: {},
|
||||||
|
model,
|
||||||
|
abort: signal,
|
||||||
|
sessionID: input.sessionID,
|
||||||
|
retries: 1,
|
||||||
|
toolChoice: "none",
|
||||||
|
// Append suggestion instruction after the full conversation
|
||||||
|
messages: [...modelMsgs, { role: "user" as const, content: PROMPT_SUGGEST_NEXT }],
|
||||||
|
})
|
||||||
|
return result.text
|
||||||
|
})
|
||||||
|
|
||||||
|
const line = text
|
||||||
|
.replace(/<think>[\s\S]*?<\/think>\s*/g, "")
|
||||||
|
.split("\n")
|
||||||
|
.map((item) => item.trim())
|
||||||
|
.find((item) => item.length > 0)
|
||||||
|
?.replace(/^["'`]+|["'`]+$/g, "")
|
||||||
|
if (!line) return
|
||||||
|
|
||||||
|
const tag = line
|
||||||
|
.toUpperCase()
|
||||||
|
.replace(/[\s-]+/g, "_")
|
||||||
|
.replace(/[^A-Z_]/g, "")
|
||||||
|
if (tag === "NO_SUGGESTION") return
|
||||||
|
|
||||||
|
const suggestion = line.length > 110 ? line.slice(0, 107) + "..." : line
|
||||||
|
if ((yield* status.get(input.sessionID)).type !== "idle") return
|
||||||
|
yield* status.suggest(input.sessionID, suggestion)
|
||||||
|
})
|
||||||
|
|
||||||
const insertReminders = Effect.fn("SessionPrompt.insertReminders")(function* (input: {
|
const insertReminders = Effect.fn("SessionPrompt.insertReminders")(function* (input: {
|
||||||
messages: MessageV2.WithParts[]
|
messages: MessageV2.WithParts[]
|
||||||
agent: Agent.Info
|
agent: Agent.Info
|
||||||
@@ -1319,7 +1394,13 @@ NOTE: At any point in time through this workflow you should feel free to ask the
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (input.noReply === true) return message
|
if (input.noReply === true) return message
|
||||||
return yield* loop({ sessionID: input.sessionID })
|
const result = yield* loop({ sessionID: input.sessionID })
|
||||||
|
yield* suggest({
|
||||||
|
session,
|
||||||
|
sessionID: input.sessionID,
|
||||||
|
message: result,
|
||||||
|
}).pipe(Effect.ignore, Effect.forkIn(scope))
|
||||||
|
return result
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -82,25 +82,6 @@ If the `AGENTS.md` is empty or insufficient, you may check `README`/`README.md`
|
|||||||
|
|
||||||
If you modified any files/styles/structures/configurations/workflows/... mentioned in `AGENTS.md` files, you MUST update the corresponding `AGENTS.md` files to keep them up-to-date.
|
If you modified any files/styles/structures/configurations/workflows/... mentioned in `AGENTS.md` files, you MUST update the corresponding `AGENTS.md` files to keep them up-to-date.
|
||||||
|
|
||||||
# Skills
|
|
||||||
|
|
||||||
Skills are reusable, composable capabilities that enhance your abilities. Each skill is a self-contained directory with a `SKILL.md` file that contains instructions, examples, and/or reference material.
|
|
||||||
|
|
||||||
## What are skills?
|
|
||||||
|
|
||||||
Skills are modular extensions that provide:
|
|
||||||
|
|
||||||
- Specialized knowledge: Domain-specific expertise (e.g., PDF processing, data analysis)
|
|
||||||
- Workflow patterns: Best practices for common tasks
|
|
||||||
- Tool integrations: Pre-configured tool chains for specific operations
|
|
||||||
- Reference material: Documentation, templates, and examples
|
|
||||||
|
|
||||||
## How to use skills
|
|
||||||
|
|
||||||
Identify the skills that are likely to be useful for the tasks you are currently working on, use the `skill` tool to load a skill for detailed instructions, guidelines, scripts and more.
|
|
||||||
|
|
||||||
Only load skill details when needed to conserve the context window.
|
|
||||||
|
|
||||||
# Ultimate Reminders
|
# Ultimate Reminders
|
||||||
|
|
||||||
At any time, you should be HELPFUL, CONCISE, and ACCURATE. Be thorough in your actions — test what you build, verify what you change — not in your explanations.
|
At any time, you should be HELPFUL, CONCISE, and ACCURATE. Be thorough in your actions — test what you build, verify what you change — not in your explanations.
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
You are generating a suggested next user message for the current conversation.
|
||||||
|
|
||||||
|
Goal:
|
||||||
|
- Suggest a useful next step that keeps momentum.
|
||||||
|
|
||||||
|
Rules:
|
||||||
|
- Output exactly one line, 110 characters max. Be concise.
|
||||||
|
- Write as the user speaking to the assistant (for example: "Can you...", "Help me...", "Let's...").
|
||||||
|
- Match the user's tone and language; keep it natural and human.
|
||||||
|
- Prefer a concrete action over a broad question.
|
||||||
|
- If the conversation is vague or small-talk, steer toward a practical starter request.
|
||||||
|
- If there is no meaningful or appropriate next step to suggest, output exactly: NO_SUGGESTION
|
||||||
|
- Avoid corporate or robotic phrasing.
|
||||||
|
- Avoid asking multiple discovery questions in one sentence.
|
||||||
|
- Do not include quotes, labels, markdown, or explanations.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
- Greeting context -> "Can you scan this repo and suggest the best first task to tackle?"
|
||||||
|
- Bug-fix context -> "Can you reproduce this bug and propose the smallest safe fix?"
|
||||||
|
- Feature context -> "Let's implement this incrementally; start with the MVP version first."
|
||||||
|
- Conversation is complete -> "NO_SUGGESTION"
|
||||||
@@ -11,6 +11,7 @@ export namespace SessionStatus {
|
|||||||
.union([
|
.union([
|
||||||
z.object({
|
z.object({
|
||||||
type: z.literal("idle"),
|
type: z.literal("idle"),
|
||||||
|
suggestion: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
type: z.literal("retry"),
|
type: z.literal("retry"),
|
||||||
@@ -48,6 +49,7 @@ export namespace SessionStatus {
|
|||||||
readonly get: (sessionID: SessionID) => Effect.Effect<Info>
|
readonly get: (sessionID: SessionID) => Effect.Effect<Info>
|
||||||
readonly list: () => Effect.Effect<Map<SessionID, Info>>
|
readonly list: () => Effect.Effect<Map<SessionID, Info>>
|
||||||
readonly set: (sessionID: SessionID, status: Info) => Effect.Effect<void>
|
readonly set: (sessionID: SessionID, status: Info) => Effect.Effect<void>
|
||||||
|
readonly suggest: (sessionID: SessionID, suggestion: string) => Effect.Effect<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Service extends ServiceMap.Service<Service, Interface>()("@opencode/SessionStatus") {}
|
export class Service extends ServiceMap.Service<Service, Interface>()("@opencode/SessionStatus") {}
|
||||||
@@ -81,7 +83,17 @@ export namespace SessionStatus {
|
|||||||
data.set(sessionID, status)
|
data.set(sessionID, status)
|
||||||
})
|
})
|
||||||
|
|
||||||
return Service.of({ get, list, set })
|
const suggest = Effect.fn("SessionStatus.suggest")(function* (sessionID: SessionID, suggestion: string) {
|
||||||
|
const data = yield* InstanceState.get(state)
|
||||||
|
const current = data.get(sessionID)
|
||||||
|
if (current && current.type !== "idle") return
|
||||||
|
const status: Info = { type: "idle", suggestion }
|
||||||
|
// only publish Status so the TUI sees the suggestion;
|
||||||
|
// skip Event.Idle to avoid spurious plugin notifications
|
||||||
|
yield* bus.publish(Event.Status, { sessionID, status })
|
||||||
|
})
|
||||||
|
|
||||||
|
return Service.of({ get, list, set, suggest })
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -99,4 +111,8 @@ export namespace SessionStatus {
|
|||||||
export async function set(sessionID: SessionID, status: Info) {
|
export async function set(sessionID: SessionID, status: Info) {
|
||||||
return runPromise((svc) => svc.set(sessionID, status))
|
return runPromise((svc) => svc.set(sessionID, status))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function suggest(sessionID: SessionID, suggestion: string) {
|
||||||
|
return runPromise((svc) => svc.suggest(sessionID, suggestion))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import path from "path"
|
import path from "path"
|
||||||
|
import { Effect } from "effect"
|
||||||
import type { Tool } from "./tool"
|
import type { Tool } from "./tool"
|
||||||
import { Instance } from "../project/instance"
|
import { Instance } from "../project/instance"
|
||||||
import { Filesystem } from "@/util/filesystem"
|
import { AppFileSystem } from "../filesystem"
|
||||||
|
|
||||||
type Kind = "file" | "directory"
|
type Kind = "file" | "directory"
|
||||||
|
|
||||||
@@ -15,14 +16,14 @@ export async function assertExternalDirectory(ctx: Tool.Context, target?: string
|
|||||||
|
|
||||||
if (options?.bypass) return
|
if (options?.bypass) return
|
||||||
|
|
||||||
const full = process.platform === "win32" ? Filesystem.normalizePath(target) : target
|
const full = process.platform === "win32" ? AppFileSystem.normalizePath(target) : target
|
||||||
if (Instance.containsPath(full)) return
|
if (Instance.containsPath(full)) return
|
||||||
|
|
||||||
const kind = options?.kind ?? "file"
|
const kind = options?.kind ?? "file"
|
||||||
const dir = kind === "directory" ? full : path.dirname(full)
|
const dir = kind === "directory" ? full : path.dirname(full)
|
||||||
const glob =
|
const glob =
|
||||||
process.platform === "win32"
|
process.platform === "win32"
|
||||||
? Filesystem.normalizePathPattern(path.join(dir, "*"))
|
? AppFileSystem.normalizePathPattern(path.join(dir, "*"))
|
||||||
: path.join(dir, "*").replaceAll("\\", "/")
|
: path.join(dir, "*").replaceAll("\\", "/")
|
||||||
|
|
||||||
await ctx.ask({
|
await ctx.ask({
|
||||||
@@ -35,3 +36,11 @@ export async function assertExternalDirectory(ctx: Tool.Context, target?: string
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const assertExternalDirectoryEffect = Effect.fn("Tool.assertExternalDirectory")(function* (
|
||||||
|
ctx: Tool.Context,
|
||||||
|
target?: string,
|
||||||
|
options?: Options,
|
||||||
|
) {
|
||||||
|
yield* Effect.promise(() => assertExternalDirectory(ctx, target, options))
|
||||||
|
})
|
||||||
|
|||||||
+163
-127
@@ -1,16 +1,17 @@
|
|||||||
import z from "zod"
|
import z from "zod"
|
||||||
|
import { Effect, Scope } from "effect"
|
||||||
import { createReadStream } from "fs"
|
import { createReadStream } from "fs"
|
||||||
import * as fs from "fs/promises"
|
import { open } from "fs/promises"
|
||||||
import * as path from "path"
|
import * as path from "path"
|
||||||
import { createInterface } from "readline"
|
import { createInterface } from "readline"
|
||||||
import { Tool } from "./tool"
|
import { Tool } from "./tool"
|
||||||
|
import { AppFileSystem } from "../filesystem"
|
||||||
import { LSP } from "../lsp"
|
import { LSP } from "../lsp"
|
||||||
import { FileTime } from "../file/time"
|
import { FileTime } from "../file/time"
|
||||||
import DESCRIPTION from "./read.txt"
|
import DESCRIPTION from "./read.txt"
|
||||||
import { Instance } from "../project/instance"
|
import { Instance } from "../project/instance"
|
||||||
import { assertExternalDirectory } from "./external-directory"
|
import { assertExternalDirectoryEffect } from "./external-directory"
|
||||||
import { Instruction } from "../session/instruction"
|
import { Instruction } from "../session/instruction"
|
||||||
import { Filesystem } from "../util/filesystem"
|
|
||||||
|
|
||||||
const DEFAULT_READ_LIMIT = 2000
|
const DEFAULT_READ_LIMIT = 2000
|
||||||
const MAX_LINE_LENGTH = 2000
|
const MAX_LINE_LENGTH = 2000
|
||||||
@@ -18,98 +19,126 @@ const MAX_LINE_SUFFIX = `... (line truncated to ${MAX_LINE_LENGTH} chars)`
|
|||||||
const MAX_BYTES = 50 * 1024
|
const MAX_BYTES = 50 * 1024
|
||||||
const MAX_BYTES_LABEL = `${MAX_BYTES / 1024} KB`
|
const MAX_BYTES_LABEL = `${MAX_BYTES / 1024} KB`
|
||||||
|
|
||||||
export const ReadTool = Tool.define("read", {
|
const parameters = z.object({
|
||||||
description: DESCRIPTION,
|
|
||||||
parameters: z.object({
|
|
||||||
filePath: z.string().describe("The absolute path to the file or directory to read"),
|
filePath: z.string().describe("The absolute path to the file or directory to read"),
|
||||||
offset: z.coerce.number().describe("The line number to start reading from (1-indexed)").optional(),
|
offset: z.coerce.number().describe("The line number to start reading from (1-indexed)").optional(),
|
||||||
limit: z.coerce.number().describe("The maximum number of lines to read (defaults to 2000)").optional(),
|
limit: z.coerce.number().describe("The maximum number of lines to read (defaults to 2000)").optional(),
|
||||||
}),
|
})
|
||||||
async execute(params, ctx) {
|
|
||||||
if (params.offset !== undefined && params.offset < 1) {
|
export const ReadTool = Tool.defineEffect(
|
||||||
throw new Error("offset must be greater than or equal to 1")
|
"read",
|
||||||
|
Effect.gen(function* () {
|
||||||
|
const fs = yield* AppFileSystem.Service
|
||||||
|
const instruction = yield* Instruction.Service
|
||||||
|
const lsp = yield* LSP.Service
|
||||||
|
const time = yield* FileTime.Service
|
||||||
|
const scope = yield* Scope.Scope
|
||||||
|
|
||||||
|
const miss = Effect.fn("ReadTool.miss")(function* (filepath: string) {
|
||||||
|
const dir = path.dirname(filepath)
|
||||||
|
const base = path.basename(filepath)
|
||||||
|
const items = yield* fs.readDirectory(dir).pipe(
|
||||||
|
Effect.map((items) =>
|
||||||
|
items
|
||||||
|
.filter(
|
||||||
|
(item) =>
|
||||||
|
item.toLowerCase().includes(base.toLowerCase()) || base.toLowerCase().includes(item.toLowerCase()),
|
||||||
|
)
|
||||||
|
.map((item) => path.join(dir, item))
|
||||||
|
.slice(0, 3),
|
||||||
|
),
|
||||||
|
Effect.catch(() => Effect.succeed([] as string[])),
|
||||||
|
)
|
||||||
|
|
||||||
|
if (items.length > 0) {
|
||||||
|
return yield* Effect.fail(
|
||||||
|
new Error(`File not found: ${filepath}\n\nDid you mean one of these?\n${items.join("\n")}`),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return yield* Effect.fail(new Error(`File not found: ${filepath}`))
|
||||||
|
})
|
||||||
|
|
||||||
|
const list = Effect.fn("ReadTool.list")(function* (filepath: string) {
|
||||||
|
const items = yield* fs.readDirectoryEntries(filepath)
|
||||||
|
return yield* Effect.forEach(
|
||||||
|
items,
|
||||||
|
Effect.fnUntraced(function* (item) {
|
||||||
|
if (item.type === "directory") return item.name + "/"
|
||||||
|
if (item.type !== "symlink") return item.name
|
||||||
|
|
||||||
|
const target = yield* fs
|
||||||
|
.stat(path.join(filepath, item.name))
|
||||||
|
.pipe(Effect.catch(() => Effect.succeed(undefined)))
|
||||||
|
if (target?.type === "Directory") return item.name + "/"
|
||||||
|
return item.name
|
||||||
|
}),
|
||||||
|
{ concurrency: "unbounded" },
|
||||||
|
).pipe(Effect.map((items: string[]) => items.sort((a, b) => a.localeCompare(b))))
|
||||||
|
})
|
||||||
|
|
||||||
|
const warm = Effect.fn("ReadTool.warm")(function* (filepath: string, sessionID: Tool.Context["sessionID"]) {
|
||||||
|
yield* lsp.touchFile(filepath, false).pipe(Effect.ignore, Effect.forkIn(scope))
|
||||||
|
yield* time.read(sessionID, filepath)
|
||||||
|
})
|
||||||
|
|
||||||
|
const run = Effect.fn("ReadTool.execute")(function* (params: z.infer<typeof parameters>, ctx: Tool.Context) {
|
||||||
|
if (params.offset !== undefined && params.offset < 1) {
|
||||||
|
return yield* Effect.fail(new Error("offset must be greater than or equal to 1"))
|
||||||
|
}
|
||||||
|
|
||||||
let filepath = params.filePath
|
let filepath = params.filePath
|
||||||
if (!path.isAbsolute(filepath)) {
|
if (!path.isAbsolute(filepath)) {
|
||||||
filepath = path.resolve(Instance.directory, filepath)
|
filepath = path.resolve(Instance.directory, filepath)
|
||||||
}
|
}
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
filepath = Filesystem.normalizePath(filepath)
|
filepath = AppFileSystem.normalizePath(filepath)
|
||||||
}
|
}
|
||||||
const title = path.relative(Instance.worktree, filepath)
|
const title = path.relative(Instance.worktree, filepath)
|
||||||
|
|
||||||
const stat = Filesystem.stat(filepath)
|
const stat = yield* fs.stat(filepath).pipe(
|
||||||
|
Effect.catchIf(
|
||||||
|
(err) => "reason" in err && err.reason._tag === "NotFound",
|
||||||
|
() => Effect.succeed(undefined),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
await assertExternalDirectory(ctx, filepath, {
|
yield* assertExternalDirectoryEffect(ctx, filepath, {
|
||||||
bypass: Boolean(ctx.extra?.["bypassCwdCheck"]),
|
bypass: Boolean(ctx.extra?.["bypassCwdCheck"]),
|
||||||
kind: stat?.isDirectory() ? "directory" : "file",
|
kind: stat?.type === "Directory" ? "directory" : "file",
|
||||||
})
|
})
|
||||||
|
|
||||||
await ctx.ask({
|
yield* Effect.promise(() =>
|
||||||
|
ctx.ask({
|
||||||
permission: "read",
|
permission: "read",
|
||||||
patterns: [filepath],
|
patterns: [filepath],
|
||||||
always: ["*"],
|
always: ["*"],
|
||||||
metadata: {},
|
metadata: {},
|
||||||
})
|
|
||||||
|
|
||||||
if (!stat) {
|
|
||||||
const dir = path.dirname(filepath)
|
|
||||||
const base = path.basename(filepath)
|
|
||||||
|
|
||||||
const suggestions = await fs
|
|
||||||
.readdir(dir)
|
|
||||||
.then((entries) =>
|
|
||||||
entries
|
|
||||||
.filter(
|
|
||||||
(entry) =>
|
|
||||||
entry.toLowerCase().includes(base.toLowerCase()) || base.toLowerCase().includes(entry.toLowerCase()),
|
|
||||||
)
|
|
||||||
.map((entry) => path.join(dir, entry))
|
|
||||||
.slice(0, 3),
|
|
||||||
)
|
|
||||||
.catch(() => [])
|
|
||||||
|
|
||||||
if (suggestions.length > 0) {
|
|
||||||
throw new Error(`File not found: ${filepath}\n\nDid you mean one of these?\n${suggestions.join("\n")}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error(`File not found: ${filepath}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stat.isDirectory()) {
|
|
||||||
const dirents = await fs.readdir(filepath, { withFileTypes: true })
|
|
||||||
const entries = await Promise.all(
|
|
||||||
dirents.map(async (dirent) => {
|
|
||||||
if (dirent.isDirectory()) return dirent.name + "/"
|
|
||||||
if (dirent.isSymbolicLink()) {
|
|
||||||
const target = await fs.stat(path.join(filepath, dirent.name)).catch(() => undefined)
|
|
||||||
if (target?.isDirectory()) return dirent.name + "/"
|
|
||||||
}
|
|
||||||
return dirent.name
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
entries.sort((a, b) => a.localeCompare(b))
|
|
||||||
|
|
||||||
|
if (!stat) return yield* miss(filepath)
|
||||||
|
|
||||||
|
if (stat.type === "Directory") {
|
||||||
|
const items = yield* list(filepath)
|
||||||
const limit = params.limit ?? DEFAULT_READ_LIMIT
|
const limit = params.limit ?? DEFAULT_READ_LIMIT
|
||||||
const offset = params.offset ?? 1
|
const offset = params.offset ?? 1
|
||||||
const start = offset - 1
|
const start = offset - 1
|
||||||
const sliced = entries.slice(start, start + limit)
|
const sliced = items.slice(start, start + limit)
|
||||||
const truncated = start + sliced.length < entries.length
|
const truncated = start + sliced.length < items.length
|
||||||
|
|
||||||
const output = [
|
return {
|
||||||
|
title,
|
||||||
|
output: [
|
||||||
`<path>${filepath}</path>`,
|
`<path>${filepath}</path>`,
|
||||||
`<type>directory</type>`,
|
`<type>directory</type>`,
|
||||||
`<entries>`,
|
`<entries>`,
|
||||||
sliced.join("\n"),
|
sliced.join("\n"),
|
||||||
truncated
|
truncated
|
||||||
? `\n(Showing ${sliced.length} of ${entries.length} entries. Use 'offset' parameter to read beyond entry ${offset + sliced.length})`
|
? `\n(Showing ${sliced.length} of ${items.length} entries. Use 'offset' parameter to read beyond entry ${offset + sliced.length})`
|
||||||
: `\n(${entries.length} entries)`,
|
: `\n(${items.length} entries)`,
|
||||||
`</entries>`,
|
`</entries>`,
|
||||||
].join("\n")
|
].join("\n"),
|
||||||
|
|
||||||
return {
|
|
||||||
title,
|
|
||||||
output,
|
|
||||||
metadata: {
|
metadata: {
|
||||||
preview: sliced.slice(0, 20).join("\n"),
|
preview: sliced.slice(0, 20).join("\n"),
|
||||||
truncated,
|
truncated,
|
||||||
@@ -118,10 +147,9 @@ export const ReadTool = Tool.define("read", {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const instructions = await Instruction.resolve(ctx.messages, filepath, ctx.messageID)
|
const loaded = yield* instruction.resolve(ctx.messages, filepath, ctx.messageID)
|
||||||
|
|
||||||
// Exclude SVG (XML-based) and vnd.fastbidsheet (.fbs extension, commonly FlatBuffers schema files)
|
const mime = AppFileSystem.mimeType(filepath)
|
||||||
const mime = Filesystem.mimeType(filepath)
|
|
||||||
const isImage = mime.startsWith("image/") && mime !== "image/svg+xml" && mime !== "image/vnd.fastbidsheet"
|
const isImage = mime.startsWith("image/") && mime !== "image/svg+xml" && mime !== "image/vnd.fastbidsheet"
|
||||||
const isPdf = mime === "application/pdf"
|
const isPdf = mime === "application/pdf"
|
||||||
if (isImage || isPdf) {
|
if (isImage || isPdf) {
|
||||||
@@ -132,21 +160,74 @@ export const ReadTool = Tool.define("read", {
|
|||||||
metadata: {
|
metadata: {
|
||||||
preview: msg,
|
preview: msg,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
loaded: instructions.map((i) => i.filepath),
|
loaded: loaded.map((item) => item.filepath),
|
||||||
},
|
},
|
||||||
attachments: [
|
attachments: [
|
||||||
{
|
{
|
||||||
type: "file",
|
type: "file" as const,
|
||||||
mime,
|
mime,
|
||||||
url: `data:${mime};base64,${Buffer.from(await Filesystem.readBytes(filepath)).toString("base64")}`,
|
url: `data:${mime};base64,${Buffer.from(yield* fs.readFile(filepath)).toString("base64")}`,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const isBinary = await isBinaryFile(filepath, Number(stat.size))
|
if (yield* Effect.promise(() => isBinaryFile(filepath, Number(stat.size)))) {
|
||||||
if (isBinary) throw new Error(`Cannot read binary file: ${filepath}`)
|
return yield* Effect.fail(new Error(`Cannot read binary file: ${filepath}`))
|
||||||
|
}
|
||||||
|
|
||||||
|
const file = yield* Effect.promise(() =>
|
||||||
|
lines(filepath, { limit: params.limit ?? DEFAULT_READ_LIMIT, offset: params.offset ?? 1 }),
|
||||||
|
)
|
||||||
|
if (file.count < file.offset && !(file.count === 0 && file.offset === 1)) {
|
||||||
|
return yield* Effect.fail(
|
||||||
|
new Error(`Offset ${file.offset} is out of range for this file (${file.count} lines)`),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
let output = [`<path>${filepath}</path>`, `<type>file</type>`, "<content>" + "\n"].join("\n")
|
||||||
|
output += file.raw.map((line, i) => `${i + file.offset}: ${line}`).join("\n")
|
||||||
|
|
||||||
|
const last = file.offset + file.raw.length - 1
|
||||||
|
const next = last + 1
|
||||||
|
const truncated = file.more || file.cut
|
||||||
|
if (file.cut) {
|
||||||
|
output += `\n\n(Output capped at ${MAX_BYTES_LABEL}. Showing lines ${file.offset}-${last}. Use offset=${next} to continue.)`
|
||||||
|
} else if (file.more) {
|
||||||
|
output += `\n\n(Showing lines ${file.offset}-${last} of ${file.count}. Use offset=${next} to continue.)`
|
||||||
|
} else {
|
||||||
|
output += `\n\n(End of file - total ${file.count} lines)`
|
||||||
|
}
|
||||||
|
output += "\n</content>"
|
||||||
|
|
||||||
|
yield* warm(filepath, ctx.sessionID)
|
||||||
|
|
||||||
|
if (loaded.length > 0) {
|
||||||
|
output += `\n\n<system-reminder>\n${loaded.map((item) => item.content).join("\n\n")}\n</system-reminder>`
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
title,
|
||||||
|
output,
|
||||||
|
metadata: {
|
||||||
|
preview: file.raw.slice(0, 20).join("\n"),
|
||||||
|
truncated,
|
||||||
|
loaded: loaded.map((item) => item.filepath),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
description: DESCRIPTION,
|
||||||
|
parameters,
|
||||||
|
async execute(params: z.infer<typeof parameters>, ctx) {
|
||||||
|
return Effect.runPromise(run(params, ctx).pipe(Effect.orDie))
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
async function lines(filepath: string, opts: { limit: number; offset: number }) {
|
||||||
const stream = createReadStream(filepath, { encoding: "utf8" })
|
const stream = createReadStream(filepath, { encoding: "utf8" })
|
||||||
const rl = createInterface({
|
const rl = createInterface({
|
||||||
input: stream,
|
input: stream,
|
||||||
@@ -155,29 +236,27 @@ export const ReadTool = Tool.define("read", {
|
|||||||
crlfDelay: Infinity,
|
crlfDelay: Infinity,
|
||||||
})
|
})
|
||||||
|
|
||||||
const limit = params.limit ?? DEFAULT_READ_LIMIT
|
const start = opts.offset - 1
|
||||||
const offset = params.offset ?? 1
|
|
||||||
const start = offset - 1
|
|
||||||
const raw: string[] = []
|
const raw: string[] = []
|
||||||
let bytes = 0
|
let bytes = 0
|
||||||
let lines = 0
|
let count = 0
|
||||||
let truncatedByBytes = false
|
let cut = false
|
||||||
let hasMoreLines = false
|
let more = false
|
||||||
try {
|
try {
|
||||||
for await (const text of rl) {
|
for await (const text of rl) {
|
||||||
lines += 1
|
count += 1
|
||||||
if (lines <= start) continue
|
if (count <= start) continue
|
||||||
|
|
||||||
if (raw.length >= limit) {
|
if (raw.length >= opts.limit) {
|
||||||
hasMoreLines = true
|
more = true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
const line = text.length > MAX_LINE_LENGTH ? text.substring(0, MAX_LINE_LENGTH) + MAX_LINE_SUFFIX : text
|
const line = text.length > MAX_LINE_LENGTH ? text.substring(0, MAX_LINE_LENGTH) + MAX_LINE_SUFFIX : text
|
||||||
const size = Buffer.byteLength(line, "utf-8") + (raw.length > 0 ? 1 : 0)
|
const size = Buffer.byteLength(line, "utf-8") + (raw.length > 0 ? 1 : 0)
|
||||||
if (bytes + size > MAX_BYTES) {
|
if (bytes + size > MAX_BYTES) {
|
||||||
truncatedByBytes = true
|
cut = true
|
||||||
hasMoreLines = true
|
more = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,52 +268,9 @@ export const ReadTool = Tool.define("read", {
|
|||||||
stream.destroy()
|
stream.destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lines < offset && !(lines === 0 && offset === 1)) {
|
return { raw, count, cut, more, offset: opts.offset }
|
||||||
throw new Error(`Offset ${offset} is out of range for this file (${lines} lines)`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const content = raw.map((line, index) => {
|
|
||||||
return `${index + offset}: ${line}`
|
|
||||||
})
|
|
||||||
const preview = raw.slice(0, 20).join("\n")
|
|
||||||
|
|
||||||
let output = [`<path>${filepath}</path>`, `<type>file</type>`, "<content>"].join("\n")
|
|
||||||
output += content.join("\n")
|
|
||||||
|
|
||||||
const totalLines = lines
|
|
||||||
const lastReadLine = offset + raw.length - 1
|
|
||||||
const nextOffset = lastReadLine + 1
|
|
||||||
const truncated = hasMoreLines || truncatedByBytes
|
|
||||||
|
|
||||||
if (truncatedByBytes) {
|
|
||||||
output += `\n\n(Output capped at ${MAX_BYTES_LABEL}. Showing lines ${offset}-${lastReadLine}. Use offset=${nextOffset} to continue.)`
|
|
||||||
} else if (hasMoreLines) {
|
|
||||||
output += `\n\n(Showing lines ${offset}-${lastReadLine} of ${totalLines}. Use offset=${nextOffset} to continue.)`
|
|
||||||
} else {
|
|
||||||
output += `\n\n(End of file - total ${totalLines} lines)`
|
|
||||||
}
|
|
||||||
output += "\n</content>"
|
|
||||||
|
|
||||||
// just warms the lsp client
|
|
||||||
LSP.touchFile(filepath, false)
|
|
||||||
await FileTime.read(ctx.sessionID, filepath)
|
|
||||||
|
|
||||||
if (instructions.length > 0) {
|
|
||||||
output += `\n\n<system-reminder>\n${instructions.map((i) => i.content).join("\n\n")}\n</system-reminder>`
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
title,
|
|
||||||
output,
|
|
||||||
metadata: {
|
|
||||||
preview,
|
|
||||||
truncated,
|
|
||||||
loaded: instructions.map((i) => i.filepath),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
async function isBinaryFile(filepath: string, fileSize: number): Promise<boolean> {
|
async function isBinaryFile(filepath: string, fileSize: number): Promise<boolean> {
|
||||||
const ext = path.extname(filepath).toLowerCase()
|
const ext = path.extname(filepath).toLowerCase()
|
||||||
// binary check for common non-text extensions
|
// binary check for common non-text extensions
|
||||||
@@ -274,7 +310,7 @@ async function isBinaryFile(filepath: string, fileSize: number): Promise<boolean
|
|||||||
|
|
||||||
if (fileSize === 0) return false
|
if (fileSize === 0) return false
|
||||||
|
|
||||||
const fh = await fs.open(filepath, "r")
|
const fh = await open(filepath, "r")
|
||||||
try {
|
try {
|
||||||
const sampleSize = Math.min(4096, fileSize)
|
const sampleSize = Math.min(4096, fileSize)
|
||||||
const bytes = Buffer.alloc(sampleSize)
|
const bytes = Buffer.alloc(sampleSize)
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ import { makeRuntime } from "@/effect/run-service"
|
|||||||
import { Env } from "../env"
|
import { Env } from "../env"
|
||||||
import { Question } from "../question"
|
import { Question } from "../question"
|
||||||
import { Todo } from "../session/todo"
|
import { Todo } from "../session/todo"
|
||||||
|
import { LSP } from "../lsp"
|
||||||
|
import { FileTime } from "../file/time"
|
||||||
|
import { Instruction } from "../session/instruction"
|
||||||
|
import { AppFileSystem } from "../filesystem"
|
||||||
|
|
||||||
export namespace ToolRegistry {
|
export namespace ToolRegistry {
|
||||||
const log = Log.create({ service: "tool.registry" })
|
const log = Log.create({ service: "tool.registry" })
|
||||||
@@ -57,8 +61,18 @@ export namespace ToolRegistry {
|
|||||||
|
|
||||||
export class Service extends ServiceMap.Service<Service, Interface>()("@opencode/ToolRegistry") {}
|
export class Service extends ServiceMap.Service<Service, Interface>()("@opencode/ToolRegistry") {}
|
||||||
|
|
||||||
export const layer: Layer.Layer<Service, never, Config.Service | Plugin.Service | Question.Service | Todo.Service> =
|
export const layer: Layer.Layer<
|
||||||
Layer.effect(
|
Service,
|
||||||
|
never,
|
||||||
|
| Config.Service
|
||||||
|
| Plugin.Service
|
||||||
|
| Question.Service
|
||||||
|
| Todo.Service
|
||||||
|
| LSP.Service
|
||||||
|
| FileTime.Service
|
||||||
|
| Instruction.Service
|
||||||
|
| AppFileSystem.Service
|
||||||
|
> = Layer.effect(
|
||||||
Service,
|
Service,
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
const config = yield* Config.Service
|
const config = yield* Config.Service
|
||||||
@@ -142,8 +156,7 @@ export namespace ToolRegistry {
|
|||||||
|
|
||||||
const all = Effect.fn("ToolRegistry.all")(function* (custom: Tool.Info[]) {
|
const all = Effect.fn("ToolRegistry.all")(function* (custom: Tool.Info[]) {
|
||||||
const cfg = yield* config.get()
|
const cfg = yield* config.get()
|
||||||
const question =
|
const question = ["app", "cli", "desktop"].includes(Flag.OPENCODE_CLIENT) || Flag.OPENCODE_ENABLE_QUESTION_TOOL
|
||||||
["app", "cli", "desktop"].includes(Flag.OPENCODE_CLIENT) || Flag.OPENCODE_ENABLE_QUESTION_TOOL
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
invalid,
|
invalid,
|
||||||
@@ -226,6 +239,10 @@ export namespace ToolRegistry {
|
|||||||
Layer.provide(Plugin.defaultLayer),
|
Layer.provide(Plugin.defaultLayer),
|
||||||
Layer.provide(Question.defaultLayer),
|
Layer.provide(Question.defaultLayer),
|
||||||
Layer.provide(Todo.defaultLayer),
|
Layer.provide(Todo.defaultLayer),
|
||||||
|
Layer.provide(LSP.defaultLayer),
|
||||||
|
Layer.provide(FileTime.defaultLayer),
|
||||||
|
Layer.provide(Instruction.defaultLayer),
|
||||||
|
Layer.provide(AppFileSystem.defaultLayer),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import { Npm } from "../../src/npm"
|
|||||||
|
|
||||||
const emptyAccount = Layer.mock(Account.Service)({
|
const emptyAccount = Layer.mock(Account.Service)({
|
||||||
active: () => Effect.succeed(Option.none()),
|
active: () => Effect.succeed(Option.none()),
|
||||||
|
activeOrg: () => Effect.succeed(Option.none()),
|
||||||
})
|
})
|
||||||
|
|
||||||
const emptyAuth = Layer.mock(Auth.Service)({
|
const emptyAuth = Layer.mock(Auth.Service)({
|
||||||
@@ -282,6 +283,21 @@ test("resolves env templates in account config with account token", async () =>
|
|||||||
active_org_id: OrgID.make("org-1"),
|
active_org_id: OrgID.make("org-1"),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
activeOrg: () =>
|
||||||
|
Effect.succeed(
|
||||||
|
Option.some({
|
||||||
|
account: {
|
||||||
|
id: AccountID.make("account-1"),
|
||||||
|
email: "user@example.com",
|
||||||
|
url: "https://control.example.com",
|
||||||
|
active_org_id: OrgID.make("org-1"),
|
||||||
|
},
|
||||||
|
org: {
|
||||||
|
id: OrgID.make("org-1"),
|
||||||
|
name: "Example Org",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
),
|
||||||
config: () =>
|
config: () =>
|
||||||
Effect.succeed(
|
Effect.succeed(
|
||||||
Option.some({
|
Option.some({
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { describe, expect, test } from "bun:test"
|
||||||
|
import { Npm } from "../src/npm"
|
||||||
|
|
||||||
|
const win = process.platform === "win32"
|
||||||
|
|
||||||
|
describe("Npm.sanitize", () => {
|
||||||
|
test("keeps normal scoped package specs unchanged", () => {
|
||||||
|
expect(Npm.sanitize("@opencode/acme")).toBe("@opencode/acme")
|
||||||
|
expect(Npm.sanitize("@opencode/acme@1.0.0")).toBe("@opencode/acme@1.0.0")
|
||||||
|
expect(Npm.sanitize("prettier")).toBe("prettier")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("handles git https specs", () => {
|
||||||
|
const spec = "acme@git+https://github.com/opencode/acme.git"
|
||||||
|
const expected = win ? "acme@git+https_//github.com/opencode/acme.git" : spec
|
||||||
|
expect(Npm.sanitize(spec)).toBe(expected)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
import { describe, expect, test } from "bun:test"
|
||||||
|
import { parsePluginSpecifier } from "../../src/plugin/shared"
|
||||||
|
|
||||||
|
describe("parsePluginSpecifier", () => {
|
||||||
|
test("parses standard npm package without version", () => {
|
||||||
|
expect(parsePluginSpecifier("acme")).toEqual({
|
||||||
|
pkg: "acme",
|
||||||
|
version: "latest",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("parses standard npm package with version", () => {
|
||||||
|
expect(parsePluginSpecifier("acme@1.0.0")).toEqual({
|
||||||
|
pkg: "acme",
|
||||||
|
version: "1.0.0",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("parses scoped npm package without version", () => {
|
||||||
|
expect(parsePluginSpecifier("@opencode/acme")).toEqual({
|
||||||
|
pkg: "@opencode/acme",
|
||||||
|
version: "latest",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("parses scoped npm package with version", () => {
|
||||||
|
expect(parsePluginSpecifier("@opencode/acme@1.0.0")).toEqual({
|
||||||
|
pkg: "@opencode/acme",
|
||||||
|
version: "1.0.0",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("parses package with git+https url", () => {
|
||||||
|
expect(parsePluginSpecifier("acme@git+https://github.com/opencode/acme.git")).toEqual({
|
||||||
|
pkg: "acme",
|
||||||
|
version: "git+https://github.com/opencode/acme.git",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("parses scoped package with git+https url", () => {
|
||||||
|
expect(parsePluginSpecifier("@opencode/acme@git+https://github.com/opencode/acme.git")).toEqual({
|
||||||
|
pkg: "@opencode/acme",
|
||||||
|
version: "git+https://github.com/opencode/acme.git",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("parses package with git+ssh url containing another @", () => {
|
||||||
|
expect(parsePluginSpecifier("acme@git+ssh://git@github.com/opencode/acme.git")).toEqual({
|
||||||
|
pkg: "acme",
|
||||||
|
version: "git+ssh://git@github.com/opencode/acme.git",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("parses scoped package with git+ssh url containing another @", () => {
|
||||||
|
expect(parsePluginSpecifier("@opencode/acme@git+ssh://git@github.com/opencode/acme.git")).toEqual({
|
||||||
|
pkg: "@opencode/acme",
|
||||||
|
version: "git+ssh://git@github.com/opencode/acme.git",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("parses unaliased git+ssh url", () => {
|
||||||
|
expect(parsePluginSpecifier("git+ssh://git@github.com/opencode/acme.git")).toEqual({
|
||||||
|
pkg: "git+ssh://git@github.com/opencode/acme.git",
|
||||||
|
version: "",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("parses npm alias using the alias name", () => {
|
||||||
|
expect(parsePluginSpecifier("acme@npm:@opencode/acme@1.0.0")).toEqual({
|
||||||
|
pkg: "acme",
|
||||||
|
version: "npm:@opencode/acme@1.0.0",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("parses bare npm protocol specifier using the target package", () => {
|
||||||
|
expect(parsePluginSpecifier("npm:@opencode/acme@1.0.0")).toEqual({
|
||||||
|
pkg: "@opencode/acme",
|
||||||
|
version: "1.0.0",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
test("parses unversioned npm protocol specifier", () => {
|
||||||
|
expect(parsePluginSpecifier("npm:@opencode/acme")).toEqual({
|
||||||
|
pkg: "@opencode/acme",
|
||||||
|
version: "latest",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -1080,7 +1080,7 @@ describe("session.getUsage", () => {
|
|||||||
expect(result.tokens.cache.read).toBe(200)
|
expect(result.tokens.cache.read).toBe(200)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("handles reasoning tokens", () => {
|
test("separates reasoning tokens from output tokens", () => {
|
||||||
const model = createModel({ context: 100_000, output: 32_000 })
|
const model = createModel({ context: 100_000, output: 32_000 })
|
||||||
const result = Session.getUsage({
|
const result = Session.getUsage({
|
||||||
model,
|
model,
|
||||||
@@ -1092,7 +1092,35 @@ describe("session.getUsage", () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
expect(result.tokens.input).toBe(1000)
|
||||||
|
expect(result.tokens.output).toBe(400)
|
||||||
expect(result.tokens.reasoning).toBe(100)
|
expect(result.tokens.reasoning).toBe(100)
|
||||||
|
expect(result.tokens.total).toBe(1500)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("does not double count reasoning tokens in cost", () => {
|
||||||
|
const model = createModel({
|
||||||
|
context: 100_000,
|
||||||
|
output: 32_000,
|
||||||
|
cost: {
|
||||||
|
input: 0,
|
||||||
|
output: 15,
|
||||||
|
cache: { read: 0, write: 0 },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const result = Session.getUsage({
|
||||||
|
model,
|
||||||
|
usage: {
|
||||||
|
inputTokens: 0,
|
||||||
|
outputTokens: 1_000_000,
|
||||||
|
totalTokens: 1_000_000,
|
||||||
|
reasoningTokens: 250_000,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(result.tokens.output).toBe(750_000)
|
||||||
|
expect(result.tokens.reasoning).toBe(250_000)
|
||||||
|
expect(result.cost).toBe(15)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("handles undefined optional values gracefully", () => {
|
test("handles undefined optional values gracefully", () => {
|
||||||
|
|||||||
@@ -1,12 +1,20 @@
|
|||||||
import { afterEach, describe, expect, test } from "bun:test"
|
import { afterEach, describe, expect } from "bun:test"
|
||||||
|
import { Cause, Effect, Exit, Layer } from "effect"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { ReadTool } from "../../src/tool/read"
|
|
||||||
import { Instance } from "../../src/project/instance"
|
|
||||||
import { Filesystem } from "../../src/util/filesystem"
|
|
||||||
import { tmpdir } from "../fixture/fixture"
|
|
||||||
import { Permission } from "../../src/permission"
|
|
||||||
import { Agent } from "../../src/agent/agent"
|
import { Agent } from "../../src/agent/agent"
|
||||||
|
import * as CrossSpawnSpawner from "../../src/effect/cross-spawn-spawner"
|
||||||
|
import { AppFileSystem } from "../../src/filesystem"
|
||||||
|
import { FileTime } from "../../src/file/time"
|
||||||
|
import { LSP } from "../../src/lsp"
|
||||||
|
import { Permission } from "../../src/permission"
|
||||||
|
import { Instance } from "../../src/project/instance"
|
||||||
import { SessionID, MessageID } from "../../src/session/schema"
|
import { SessionID, MessageID } from "../../src/session/schema"
|
||||||
|
import { Instruction } from "../../src/session/instruction"
|
||||||
|
import { ReadTool } from "../../src/tool/read"
|
||||||
|
import { Tool } from "../../src/tool/tool"
|
||||||
|
import { Filesystem } from "../../src/util/filesystem"
|
||||||
|
import { provideInstance, tmpdirScoped } from "../fixture/fixture"
|
||||||
|
import { testEffect } from "../lib/effect"
|
||||||
|
|
||||||
const FIXTURES_DIR = path.join(import.meta.dir, "fixtures")
|
const FIXTURES_DIR = path.join(import.meta.dir, "fixtures")
|
||||||
|
|
||||||
@@ -25,173 +33,171 @@ const ctx = {
|
|||||||
ask: async () => {},
|
ask: async () => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const it = testEffect(
|
||||||
|
Layer.mergeAll(
|
||||||
|
Agent.defaultLayer,
|
||||||
|
AppFileSystem.defaultLayer,
|
||||||
|
CrossSpawnSpawner.defaultLayer,
|
||||||
|
FileTime.defaultLayer,
|
||||||
|
Instruction.defaultLayer,
|
||||||
|
LSP.defaultLayer,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
const init = Effect.fn("ReadToolTest.init")(function* () {
|
||||||
|
const info = yield* ReadTool
|
||||||
|
return yield* Effect.promise(() => info.init())
|
||||||
|
})
|
||||||
|
|
||||||
|
const run = Effect.fn("ReadToolTest.run")(function* (
|
||||||
|
args: Tool.InferParameters<typeof ReadTool>,
|
||||||
|
next: Tool.Context = ctx,
|
||||||
|
) {
|
||||||
|
const tool = yield* init()
|
||||||
|
return yield* Effect.promise(() => tool.execute(args, next))
|
||||||
|
})
|
||||||
|
|
||||||
|
const exec = Effect.fn("ReadToolTest.exec")(function* (
|
||||||
|
dir: string,
|
||||||
|
args: Tool.InferParameters<typeof ReadTool>,
|
||||||
|
next: Tool.Context = ctx,
|
||||||
|
) {
|
||||||
|
return yield* provideInstance(dir)(run(args, next))
|
||||||
|
})
|
||||||
|
|
||||||
|
const fail = Effect.fn("ReadToolTest.fail")(function* (
|
||||||
|
dir: string,
|
||||||
|
args: Tool.InferParameters<typeof ReadTool>,
|
||||||
|
next: Tool.Context = ctx,
|
||||||
|
) {
|
||||||
|
const exit = yield* exec(dir, args, next).pipe(Effect.exit)
|
||||||
|
if (Exit.isFailure(exit)) {
|
||||||
|
const err = Cause.squash(exit.cause)
|
||||||
|
return err instanceof Error ? err : new Error(String(err))
|
||||||
|
}
|
||||||
|
throw new Error("expected read to fail")
|
||||||
|
})
|
||||||
|
|
||||||
const full = (p: string) => (process.platform === "win32" ? Filesystem.normalizePath(p) : p)
|
const full = (p: string) => (process.platform === "win32" ? Filesystem.normalizePath(p) : p)
|
||||||
const glob = (p: string) =>
|
const glob = (p: string) =>
|
||||||
process.platform === "win32" ? Filesystem.normalizePathPattern(p) : p.replaceAll("\\", "/")
|
process.platform === "win32" ? Filesystem.normalizePathPattern(p) : p.replaceAll("\\", "/")
|
||||||
|
const put = Effect.fn("ReadToolTest.put")(function* (p: string, content: string | Buffer | Uint8Array) {
|
||||||
|
const fs = yield* AppFileSystem.Service
|
||||||
|
yield* fs.writeWithDirs(p, content)
|
||||||
|
})
|
||||||
|
const load = Effect.fn("ReadToolTest.load")(function* (p: string) {
|
||||||
|
const fs = yield* AppFileSystem.Service
|
||||||
|
return yield* fs.readFileString(p)
|
||||||
|
})
|
||||||
|
const asks = () => {
|
||||||
|
const items: Array<Omit<Permission.Request, "id" | "sessionID" | "tool">> = []
|
||||||
|
return {
|
||||||
|
items,
|
||||||
|
next: {
|
||||||
|
...ctx,
|
||||||
|
ask: async (req: Omit<Permission.Request, "id" | "sessionID" | "tool">) => {
|
||||||
|
items.push(req)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
describe("tool.read external_directory permission", () => {
|
describe("tool.read external_directory permission", () => {
|
||||||
test("allows reading absolute path inside project directory", async () => {
|
it.live("allows reading absolute path inside project directory", () =>
|
||||||
await using tmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const dir = yield* tmpdirScoped()
|
||||||
await Bun.write(path.join(dir, "test.txt"), "hello world")
|
yield* put(path.join(dir, "test.txt"), "hello world")
|
||||||
},
|
|
||||||
})
|
const result = yield* exec(dir, { filePath: path.join(dir, "test.txt") })
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
const result = await read.execute({ filePath: path.join(tmp.path, "test.txt") }, ctx)
|
|
||||||
expect(result.output).toContain("hello world")
|
expect(result.output).toContain("hello world")
|
||||||
},
|
}),
|
||||||
})
|
)
|
||||||
})
|
|
||||||
|
|
||||||
test("allows reading file in subdirectory inside project directory", async () => {
|
it.live("allows reading file in subdirectory inside project directory", () =>
|
||||||
await using tmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const dir = yield* tmpdirScoped()
|
||||||
await Bun.write(path.join(dir, "subdir", "test.txt"), "nested content")
|
yield* put(path.join(dir, "subdir", "test.txt"), "nested content")
|
||||||
},
|
|
||||||
})
|
const result = yield* exec(dir, { filePath: path.join(dir, "subdir", "test.txt") })
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
const result = await read.execute({ filePath: path.join(tmp.path, "subdir", "test.txt") }, ctx)
|
|
||||||
expect(result.output).toContain("nested content")
|
expect(result.output).toContain("nested content")
|
||||||
},
|
}),
|
||||||
})
|
)
|
||||||
})
|
|
||||||
|
|
||||||
test("asks for external_directory permission when reading absolute path outside project", async () => {
|
it.live("asks for external_directory permission when reading absolute path outside project", () =>
|
||||||
await using outerTmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const outer = yield* tmpdirScoped()
|
||||||
await Bun.write(path.join(dir, "secret.txt"), "secret data")
|
const dir = yield* tmpdirScoped({ git: true })
|
||||||
},
|
yield* put(path.join(outer, "secret.txt"), "secret data")
|
||||||
})
|
|
||||||
await using tmp = await tmpdir({ git: true })
|
const { items, next } = asks()
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
yield* exec(dir, { filePath: path.join(outer, "secret.txt") }, next)
|
||||||
fn: async () => {
|
const ext = items.find((item) => item.permission === "external_directory")
|
||||||
const read = await ReadTool.init()
|
expect(ext).toBeDefined()
|
||||||
const requests: Array<Omit<Permission.Request, "id" | "sessionID" | "tool">> = []
|
expect(ext!.patterns).toContain(glob(path.join(outer, "*")))
|
||||||
const testCtx = {
|
}),
|
||||||
...ctx,
|
)
|
||||||
ask: async (req: Omit<Permission.Request, "id" | "sessionID" | "tool">) => {
|
|
||||||
requests.push(req)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
await read.execute({ filePath: path.join(outerTmp.path, "secret.txt") }, testCtx)
|
|
||||||
const extDirReq = requests.find((r) => r.permission === "external_directory")
|
|
||||||
expect(extDirReq).toBeDefined()
|
|
||||||
expect(extDirReq!.patterns).toContain(glob(path.join(outerTmp.path, "*")))
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
test("normalizes read permission paths on Windows", async () => {
|
it.live("normalizes read permission paths on Windows", () =>
|
||||||
await using tmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
git: true,
|
const dir = yield* tmpdirScoped({ git: true })
|
||||||
init: async (dir) => {
|
yield* put(path.join(dir, "test.txt"), "hello world")
|
||||||
await Bun.write(path.join(dir, "test.txt"), "hello world")
|
|
||||||
},
|
const { items, next } = asks()
|
||||||
})
|
const target = path.join(dir, "test.txt")
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
const requests: Array<Omit<Permission.Request, "id" | "sessionID" | "tool">> = []
|
|
||||||
const testCtx = {
|
|
||||||
...ctx,
|
|
||||||
ask: async (req: Omit<Permission.Request, "id" | "sessionID" | "tool">) => {
|
|
||||||
requests.push(req)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
const target = path.join(tmp.path, "test.txt")
|
|
||||||
const alt = target
|
const alt = target
|
||||||
.replace(/^[A-Za-z]:/, "")
|
.replace(/^[A-Za-z]:/, "")
|
||||||
.replaceAll("\\", "/")
|
.replaceAll("\\", "/")
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
await read.execute({ filePath: alt }, testCtx)
|
|
||||||
const readReq = requests.find((r) => r.permission === "read")
|
yield* exec(dir, { filePath: alt }, next)
|
||||||
expect(readReq).toBeDefined()
|
const read = items.find((item) => item.permission === "read")
|
||||||
expect(readReq!.patterns).toEqual([full(target)])
|
expect(read).toBeDefined()
|
||||||
},
|
expect(read!.patterns).toEqual([full(target)])
|
||||||
})
|
}),
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
test("asks for directory-scoped external_directory permission when reading external directory", async () => {
|
it.live("asks for directory-scoped external_directory permission when reading external directory", () =>
|
||||||
await using outerTmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const outer = yield* tmpdirScoped()
|
||||||
await Bun.write(path.join(dir, "external", "a.txt"), "a")
|
const dir = yield* tmpdirScoped({ git: true })
|
||||||
},
|
yield* put(path.join(outer, "external", "a.txt"), "a")
|
||||||
})
|
|
||||||
await using tmp = await tmpdir({ git: true })
|
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
const requests: Array<Omit<Permission.Request, "id" | "sessionID" | "tool">> = []
|
|
||||||
const testCtx = {
|
|
||||||
...ctx,
|
|
||||||
ask: async (req: Omit<Permission.Request, "id" | "sessionID" | "tool">) => {
|
|
||||||
requests.push(req)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
await read.execute({ filePath: path.join(outerTmp.path, "external") }, testCtx)
|
|
||||||
const extDirReq = requests.find((r) => r.permission === "external_directory")
|
|
||||||
expect(extDirReq).toBeDefined()
|
|
||||||
expect(extDirReq!.patterns).toContain(glob(path.join(outerTmp.path, "external", "*")))
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("asks for external_directory permission when reading relative path outside project", async () => {
|
const { items, next } = asks()
|
||||||
await using tmp = await tmpdir({ git: true })
|
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
const requests: Array<Omit<Permission.Request, "id" | "sessionID" | "tool">> = []
|
|
||||||
const testCtx = {
|
|
||||||
...ctx,
|
|
||||||
ask: async (req: Omit<Permission.Request, "id" | "sessionID" | "tool">) => {
|
|
||||||
requests.push(req)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
// This will fail because file doesn't exist, but we can check if permission was asked
|
|
||||||
await read.execute({ filePath: "../outside.txt" }, testCtx).catch(() => {})
|
|
||||||
const extDirReq = requests.find((r) => r.permission === "external_directory")
|
|
||||||
expect(extDirReq).toBeDefined()
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("does not ask for external_directory permission when reading inside project", async () => {
|
yield* exec(dir, { filePath: path.join(outer, "external") }, next)
|
||||||
await using tmp = await tmpdir({
|
const ext = items.find((item) => item.permission === "external_directory")
|
||||||
git: true,
|
expect(ext).toBeDefined()
|
||||||
init: async (dir) => {
|
expect(ext!.patterns).toContain(glob(path.join(outer, "external", "*")))
|
||||||
await Bun.write(path.join(dir, "internal.txt"), "internal content")
|
}),
|
||||||
},
|
)
|
||||||
})
|
|
||||||
await Instance.provide({
|
it.live("asks for external_directory permission when reading relative path outside project", () =>
|
||||||
directory: tmp.path,
|
Effect.gen(function* () {
|
||||||
fn: async () => {
|
const dir = yield* tmpdirScoped({ git: true })
|
||||||
const read = await ReadTool.init()
|
|
||||||
const requests: Array<Omit<Permission.Request, "id" | "sessionID" | "tool">> = []
|
const { items, next } = asks()
|
||||||
const testCtx = {
|
|
||||||
...ctx,
|
yield* fail(dir, { filePath: "../outside.txt" }, next)
|
||||||
ask: async (req: Omit<Permission.Request, "id" | "sessionID" | "tool">) => {
|
const ext = items.find((item) => item.permission === "external_directory")
|
||||||
requests.push(req)
|
expect(ext).toBeDefined()
|
||||||
},
|
}),
|
||||||
}
|
)
|
||||||
await read.execute({ filePath: path.join(tmp.path, "internal.txt") }, testCtx)
|
|
||||||
const extDirReq = requests.find((r) => r.permission === "external_directory")
|
it.live("does not ask for external_directory permission when reading inside project", () =>
|
||||||
expect(extDirReq).toBeUndefined()
|
Effect.gen(function* () {
|
||||||
},
|
const dir = yield* tmpdirScoped({ git: true })
|
||||||
})
|
yield* put(path.join(dir, "internal.txt"), "internal content")
|
||||||
})
|
|
||||||
|
const { items, next } = asks()
|
||||||
|
|
||||||
|
yield* exec(dir, { filePath: path.join(dir, "internal.txt") }, next)
|
||||||
|
const ext = items.find((item) => item.permission === "external_directory")
|
||||||
|
expect(ext).toBeUndefined()
|
||||||
|
}),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("tool.read env file permissions", () => {
|
describe("tool.read env file permissions", () => {
|
||||||
@@ -205,112 +211,97 @@ describe("tool.read env file permissions", () => {
|
|||||||
["environment.ts", false],
|
["environment.ts", false],
|
||||||
]
|
]
|
||||||
|
|
||||||
describe.each(["build", "plan"])("agent=%s", (agentName) => {
|
for (const agentName of ["build", "plan"] as const) {
|
||||||
test.each(cases)("%s asks=%s", async (filename, shouldAsk) => {
|
describe(`agent=${agentName}`, () => {
|
||||||
await using tmp = await tmpdir({
|
for (const [filename, shouldAsk] of cases) {
|
||||||
init: (dir) => Bun.write(path.join(dir, filename), "content"),
|
it.live(`${filename} asks=${shouldAsk}`, () =>
|
||||||
})
|
Effect.gen(function* () {
|
||||||
await Instance.provide({
|
const dir = yield* tmpdirScoped()
|
||||||
directory: tmp.path,
|
yield* put(path.join(dir, filename), "content")
|
||||||
fn: async () => {
|
|
||||||
const agent = await Agent.get(agentName)
|
const asked = yield* provideInstance(dir)(
|
||||||
let askedForEnv = false
|
Effect.gen(function* () {
|
||||||
const ctxWithPermissions = {
|
const agent = yield* Agent.Service
|
||||||
|
const info = yield* agent.get(agentName)
|
||||||
|
let asked = false
|
||||||
|
const next = {
|
||||||
...ctx,
|
...ctx,
|
||||||
ask: async (req: Omit<Permission.Request, "id" | "sessionID" | "tool">) => {
|
ask: async (req: Omit<Permission.Request, "id" | "sessionID" | "tool">) => {
|
||||||
for (const pattern of req.patterns) {
|
for (const pattern of req.patterns) {
|
||||||
const rule = Permission.evaluate(req.permission, pattern, agent.permission)
|
const rule = Permission.evaluate(req.permission, pattern, info.permission)
|
||||||
if (rule.action === "ask" && req.permission === "read") {
|
if (rule.action === "ask" && req.permission === "read") {
|
||||||
askedForEnv = true
|
asked = true
|
||||||
}
|
}
|
||||||
if (rule.action === "deny") {
|
if (rule.action === "deny") {
|
||||||
throw new Permission.DeniedError({ ruleset: agent.permission })
|
throw new Permission.DeniedError({ ruleset: info.permission })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
const read = await ReadTool.init()
|
|
||||||
await read.execute({ filePath: path.join(tmp.path, filename) }, ctxWithPermissions)
|
yield* run({ filePath: path.join(dir, filename) }, next)
|
||||||
expect(askedForEnv).toBe(shouldAsk)
|
return asked
|
||||||
},
|
}),
|
||||||
})
|
)
|
||||||
})
|
|
||||||
|
expect(asked).toBe(shouldAsk)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("tool.read truncation", () => {
|
describe("tool.read truncation", () => {
|
||||||
test("truncates large file by bytes and sets truncated metadata", async () => {
|
it.live("truncates large file by bytes and sets truncated metadata", () =>
|
||||||
await using tmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const dir = yield* tmpdirScoped()
|
||||||
const base = await Filesystem.readText(path.join(FIXTURES_DIR, "models-api.json"))
|
const base = yield* load(path.join(FIXTURES_DIR, "models-api.json"))
|
||||||
const target = 60 * 1024
|
const target = 60 * 1024
|
||||||
const content = base.length >= target ? base : base.repeat(Math.ceil(target / base.length))
|
const content = base.length >= target ? base : base.repeat(Math.ceil(target / base.length))
|
||||||
await Filesystem.write(path.join(dir, "large.json"), content)
|
yield* put(path.join(dir, "large.json"), content)
|
||||||
},
|
|
||||||
})
|
const result = yield* exec(dir, { filePath: path.join(dir, "large.json") })
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
const result = await read.execute({ filePath: path.join(tmp.path, "large.json") }, ctx)
|
|
||||||
expect(result.metadata.truncated).toBe(true)
|
expect(result.metadata.truncated).toBe(true)
|
||||||
expect(result.output).toContain("Output capped at")
|
expect(result.output).toContain("Output capped at")
|
||||||
expect(result.output).toContain("Use offset=")
|
expect(result.output).toContain("Use offset=")
|
||||||
},
|
}),
|
||||||
})
|
)
|
||||||
})
|
|
||||||
|
|
||||||
test("truncates by line count when limit is specified", async () => {
|
it.live("truncates by line count when limit is specified", () =>
|
||||||
await using tmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const dir = yield* tmpdirScoped()
|
||||||
const lines = Array.from({ length: 100 }, (_, i) => `line${i}`).join("\n")
|
const lines = Array.from({ length: 100 }, (_, i) => `line${i}`).join("\n")
|
||||||
await Bun.write(path.join(dir, "many-lines.txt"), lines)
|
yield* put(path.join(dir, "many-lines.txt"), lines)
|
||||||
},
|
|
||||||
})
|
const result = yield* exec(dir, { filePath: path.join(dir, "many-lines.txt"), limit: 10 })
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
const result = await read.execute({ filePath: path.join(tmp.path, "many-lines.txt"), limit: 10 }, ctx)
|
|
||||||
expect(result.metadata.truncated).toBe(true)
|
expect(result.metadata.truncated).toBe(true)
|
||||||
expect(result.output).toContain("Showing lines 1-10 of 100")
|
expect(result.output).toContain("Showing lines 1-10 of 100")
|
||||||
expect(result.output).toContain("Use offset=11")
|
expect(result.output).toContain("Use offset=11")
|
||||||
expect(result.output).toContain("line0")
|
expect(result.output).toContain("line0")
|
||||||
expect(result.output).toContain("line9")
|
expect(result.output).toContain("line9")
|
||||||
expect(result.output).not.toContain("line10")
|
expect(result.output).not.toContain("line10")
|
||||||
},
|
}),
|
||||||
})
|
)
|
||||||
})
|
|
||||||
|
|
||||||
test("does not truncate small file", async () => {
|
it.live("does not truncate small file", () =>
|
||||||
await using tmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const dir = yield* tmpdirScoped()
|
||||||
await Bun.write(path.join(dir, "small.txt"), "hello world")
|
yield* put(path.join(dir, "small.txt"), "hello world")
|
||||||
},
|
|
||||||
})
|
const result = yield* exec(dir, { filePath: path.join(dir, "small.txt") })
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
const result = await read.execute({ filePath: path.join(tmp.path, "small.txt") }, ctx)
|
|
||||||
expect(result.metadata.truncated).toBe(false)
|
expect(result.metadata.truncated).toBe(false)
|
||||||
expect(result.output).toContain("End of file")
|
expect(result.output).toContain("End of file")
|
||||||
},
|
}),
|
||||||
})
|
)
|
||||||
})
|
|
||||||
|
|
||||||
test("respects offset parameter", async () => {
|
it.live("respects offset parameter", () =>
|
||||||
await using tmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const dir = yield* tmpdirScoped()
|
||||||
const lines = Array.from({ length: 20 }, (_, i) => `line${i + 1}`).join("\n")
|
const lines = Array.from({ length: 20 }, (_, i) => `line${i + 1}`).join("\n")
|
||||||
await Bun.write(path.join(dir, "offset.txt"), lines)
|
yield* put(path.join(dir, "offset.txt"), lines)
|
||||||
},
|
|
||||||
})
|
const result = yield* exec(dir, { filePath: path.join(dir, "offset.txt"), offset: 10, limit: 5 })
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
const result = await read.execute({ filePath: path.join(tmp.path, "offset.txt"), offset: 10, limit: 5 }, ctx)
|
|
||||||
expect(result.output).toContain("10: line10")
|
expect(result.output).toContain("10: line10")
|
||||||
expect(result.output).toContain("14: line14")
|
expect(result.output).toContain("14: line14")
|
||||||
expect(result.output).not.toContain("9: line10")
|
expect(result.output).not.toContain("9: line10")
|
||||||
@@ -319,131 +310,91 @@ describe("tool.read truncation", () => {
|
|||||||
expect(result.output).toContain("line14")
|
expect(result.output).toContain("line14")
|
||||||
expect(result.output).not.toContain("line0")
|
expect(result.output).not.toContain("line0")
|
||||||
expect(result.output).not.toContain("line15")
|
expect(result.output).not.toContain("line15")
|
||||||
},
|
}),
|
||||||
})
|
)
|
||||||
})
|
|
||||||
|
|
||||||
test("throws when offset is beyond end of file", async () => {
|
it.live("throws when offset is beyond end of file", () =>
|
||||||
await using tmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const dir = yield* tmpdirScoped()
|
||||||
const lines = Array.from({ length: 3 }, (_, i) => `line${i + 1}`).join("\n")
|
const lines = Array.from({ length: 3 }, (_, i) => `line${i + 1}`).join("\n")
|
||||||
await Bun.write(path.join(dir, "short.txt"), lines)
|
yield* put(path.join(dir, "short.txt"), lines)
|
||||||
},
|
|
||||||
})
|
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
await expect(
|
|
||||||
read.execute({ filePath: path.join(tmp.path, "short.txt"), offset: 4, limit: 5 }, ctx),
|
|
||||||
).rejects.toThrow("Offset 4 is out of range for this file (3 lines)")
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("allows reading empty file at default offset", async () => {
|
const err = yield* fail(dir, { filePath: path.join(dir, "short.txt"), offset: 4, limit: 5 })
|
||||||
await using tmp = await tmpdir({
|
expect(err.message).toContain("Offset 4 is out of range for this file (3 lines)")
|
||||||
init: async (dir) => {
|
}),
|
||||||
await Bun.write(path.join(dir, "empty.txt"), "")
|
)
|
||||||
},
|
|
||||||
})
|
it.live("allows reading empty file at default offset", () =>
|
||||||
await Instance.provide({
|
Effect.gen(function* () {
|
||||||
directory: tmp.path,
|
const dir = yield* tmpdirScoped()
|
||||||
fn: async () => {
|
yield* put(path.join(dir, "empty.txt"), "")
|
||||||
const read = await ReadTool.init()
|
|
||||||
const result = await read.execute({ filePath: path.join(tmp.path, "empty.txt") }, ctx)
|
const result = yield* exec(dir, { filePath: path.join(dir, "empty.txt") })
|
||||||
expect(result.metadata.truncated).toBe(false)
|
expect(result.metadata.truncated).toBe(false)
|
||||||
expect(result.output).toContain("End of file - total 0 lines")
|
expect(result.output).toContain("End of file - total 0 lines")
|
||||||
},
|
}),
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("throws when offset > 1 for empty file", async () => {
|
|
||||||
await using tmp = await tmpdir({
|
|
||||||
init: async (dir) => {
|
|
||||||
await Bun.write(path.join(dir, "empty.txt"), "")
|
|
||||||
},
|
|
||||||
})
|
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
await expect(read.execute({ filePath: path.join(tmp.path, "empty.txt"), offset: 2 }, ctx)).rejects.toThrow(
|
|
||||||
"Offset 2 is out of range for this file (0 lines)",
|
|
||||||
)
|
)
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("does not mark final directory page as truncated", async () => {
|
it.live("throws when offset > 1 for empty file", () =>
|
||||||
await using tmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const dir = yield* tmpdirScoped()
|
||||||
await Promise.all(
|
yield* put(path.join(dir, "empty.txt"), "")
|
||||||
Array.from({ length: 10 }, (_, i) => Bun.write(path.join(dir, "dir", `file-${i + 1}.txt`), `line${i}`)),
|
|
||||||
|
const err = yield* fail(dir, { filePath: path.join(dir, "empty.txt"), offset: 2 })
|
||||||
|
expect(err.message).toContain("Offset 2 is out of range for this file (0 lines)")
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
it.live("does not mark final directory page as truncated", () =>
|
||||||
|
Effect.gen(function* () {
|
||||||
|
const dir = yield* tmpdirScoped()
|
||||||
|
yield* Effect.forEach(
|
||||||
|
Array.from({ length: 10 }, (_, i) => i),
|
||||||
|
(i) => put(path.join(dir, "dir", `file-${i + 1}.txt`), `line${i}`),
|
||||||
|
{
|
||||||
|
concurrency: "unbounded",
|
||||||
},
|
},
|
||||||
})
|
)
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
const result = yield* exec(dir, { filePath: path.join(dir, "dir"), offset: 6, limit: 5 })
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
const result = await read.execute({ filePath: path.join(tmp.path, "dir"), offset: 6, limit: 5 }, ctx)
|
|
||||||
expect(result.metadata.truncated).toBe(false)
|
expect(result.metadata.truncated).toBe(false)
|
||||||
expect(result.output).not.toContain("Showing 5 of 10 entries")
|
expect(result.output).not.toContain("Showing 5 of 10 entries")
|
||||||
},
|
}),
|
||||||
})
|
)
|
||||||
})
|
|
||||||
|
|
||||||
test("truncates long lines", async () => {
|
it.live("truncates long lines", () =>
|
||||||
await using tmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const dir = yield* tmpdirScoped()
|
||||||
const longLine = "x".repeat(3000)
|
yield* put(path.join(dir, "long-line.txt"), "x".repeat(3000))
|
||||||
await Bun.write(path.join(dir, "long-line.txt"), longLine)
|
|
||||||
},
|
const result = yield* exec(dir, { filePath: path.join(dir, "long-line.txt") })
|
||||||
})
|
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
const result = await read.execute({ filePath: path.join(tmp.path, "long-line.txt") }, ctx)
|
|
||||||
expect(result.output).toContain("(line truncated to 2000 chars)")
|
expect(result.output).toContain("(line truncated to 2000 chars)")
|
||||||
expect(result.output.length).toBeLessThan(3000)
|
expect(result.output.length).toBeLessThan(3000)
|
||||||
},
|
}),
|
||||||
})
|
)
|
||||||
})
|
|
||||||
|
|
||||||
test("image files set truncated to false", async () => {
|
it.live("image files set truncated to false", () =>
|
||||||
await using tmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const dir = yield* tmpdirScoped()
|
||||||
// 1x1 red PNG
|
|
||||||
const png = Buffer.from(
|
const png = Buffer.from(
|
||||||
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg==",
|
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg==",
|
||||||
"base64",
|
"base64",
|
||||||
)
|
)
|
||||||
await Bun.write(path.join(dir, "image.png"), png)
|
yield* put(path.join(dir, "image.png"), png)
|
||||||
},
|
|
||||||
})
|
const result = yield* exec(dir, { filePath: path.join(dir, "image.png") })
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
const result = await read.execute({ filePath: path.join(tmp.path, "image.png") }, ctx)
|
|
||||||
expect(result.metadata.truncated).toBe(false)
|
expect(result.metadata.truncated).toBe(false)
|
||||||
expect(result.attachments).toBeDefined()
|
expect(result.attachments).toBeDefined()
|
||||||
expect(result.attachments?.length).toBe(1)
|
expect(result.attachments?.length).toBe(1)
|
||||||
expect(result.attachments?.[0]).not.toHaveProperty("id")
|
expect(result.attachments?.[0]).not.toHaveProperty("id")
|
||||||
expect(result.attachments?.[0]).not.toHaveProperty("sessionID")
|
expect(result.attachments?.[0]).not.toHaveProperty("sessionID")
|
||||||
expect(result.attachments?.[0]).not.toHaveProperty("messageID")
|
expect(result.attachments?.[0]).not.toHaveProperty("messageID")
|
||||||
},
|
}),
|
||||||
})
|
)
|
||||||
})
|
|
||||||
|
|
||||||
test("large image files are properly attached without error", async () => {
|
it.live("large image files are properly attached without error", () =>
|
||||||
await Instance.provide({
|
Effect.gen(function* () {
|
||||||
directory: FIXTURES_DIR,
|
const result = yield* exec(FIXTURES_DIR, { filePath: path.join(FIXTURES_DIR, "large-image.png") })
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
const result = await read.execute({ filePath: path.join(FIXTURES_DIR, "large-image.png") }, ctx)
|
|
||||||
expect(result.metadata.truncated).toBe(false)
|
expect(result.metadata.truncated).toBe(false)
|
||||||
expect(result.attachments).toBeDefined()
|
expect(result.attachments).toBeDefined()
|
||||||
expect(result.attachments?.length).toBe(1)
|
expect(result.attachments?.length).toBe(1)
|
||||||
@@ -451,15 +402,13 @@ describe("tool.read truncation", () => {
|
|||||||
expect(result.attachments?.[0]).not.toHaveProperty("id")
|
expect(result.attachments?.[0]).not.toHaveProperty("id")
|
||||||
expect(result.attachments?.[0]).not.toHaveProperty("sessionID")
|
expect(result.attachments?.[0]).not.toHaveProperty("sessionID")
|
||||||
expect(result.attachments?.[0]).not.toHaveProperty("messageID")
|
expect(result.attachments?.[0]).not.toHaveProperty("messageID")
|
||||||
},
|
}),
|
||||||
})
|
)
|
||||||
})
|
|
||||||
|
|
||||||
test(".fbs files (FlatBuffers schema) are read as text, not images", async () => {
|
it.live(".fbs files (FlatBuffers schema) are read as text, not images", () =>
|
||||||
await using tmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const dir = yield* tmpdirScoped()
|
||||||
// FlatBuffers schema content
|
const fbs = `namespace MyGame;
|
||||||
const fbsContent = `namespace MyGame;
|
|
||||||
|
|
||||||
table Monster {
|
table Monster {
|
||||||
pos:Vec3;
|
pos:Vec3;
|
||||||
@@ -468,79 +417,52 @@ table Monster {
|
|||||||
}
|
}
|
||||||
|
|
||||||
root_type Monster;`
|
root_type Monster;`
|
||||||
await Bun.write(path.join(dir, "schema.fbs"), fbsContent)
|
yield* put(path.join(dir, "schema.fbs"), fbs)
|
||||||
},
|
|
||||||
})
|
const result = yield* exec(dir, { filePath: path.join(dir, "schema.fbs") })
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
const result = await read.execute({ filePath: path.join(tmp.path, "schema.fbs") }, ctx)
|
|
||||||
// Should be read as text, not as image
|
|
||||||
expect(result.attachments).toBeUndefined()
|
expect(result.attachments).toBeUndefined()
|
||||||
expect(result.output).toContain("namespace MyGame")
|
expect(result.output).toContain("namespace MyGame")
|
||||||
expect(result.output).toContain("table Monster")
|
expect(result.output).toContain("table Monster")
|
||||||
},
|
}),
|
||||||
})
|
)
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("tool.read loaded instructions", () => {
|
describe("tool.read loaded instructions", () => {
|
||||||
test("loads AGENTS.md from parent directory and includes in metadata", async () => {
|
it.live("loads AGENTS.md from parent directory and includes in metadata", () =>
|
||||||
await using tmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const dir = yield* tmpdirScoped()
|
||||||
await Bun.write(path.join(dir, "subdir", "AGENTS.md"), "# Test Instructions\nDo something special.")
|
yield* put(path.join(dir, "subdir", "AGENTS.md"), "# Test Instructions\nDo something special.")
|
||||||
await Bun.write(path.join(dir, "subdir", "nested", "test.txt"), "test content")
|
yield* put(path.join(dir, "subdir", "nested", "test.txt"), "test content")
|
||||||
},
|
|
||||||
})
|
const result = yield* exec(dir, { filePath: path.join(dir, "subdir", "nested", "test.txt") })
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
const result = await read.execute({ filePath: path.join(tmp.path, "subdir", "nested", "test.txt") }, ctx)
|
|
||||||
expect(result.output).toContain("test content")
|
expect(result.output).toContain("test content")
|
||||||
expect(result.output).toContain("system-reminder")
|
expect(result.output).toContain("system-reminder")
|
||||||
expect(result.output).toContain("Test Instructions")
|
expect(result.output).toContain("Test Instructions")
|
||||||
expect(result.metadata.loaded).toBeDefined()
|
expect(result.metadata.loaded).toBeDefined()
|
||||||
expect(result.metadata.loaded).toContain(path.join(tmp.path, "subdir", "AGENTS.md"))
|
expect(result.metadata.loaded).toContain(path.join(dir, "subdir", "AGENTS.md"))
|
||||||
},
|
}),
|
||||||
})
|
)
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("tool.read binary detection", () => {
|
describe("tool.read binary detection", () => {
|
||||||
test("rejects text extension files with null bytes", async () => {
|
it.live("rejects text extension files with null bytes", () =>
|
||||||
await using tmp = await tmpdir({
|
Effect.gen(function* () {
|
||||||
init: async (dir) => {
|
const dir = yield* tmpdirScoped()
|
||||||
const bytes = Buffer.from([0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00, 0x77, 0x6f, 0x72, 0x6c, 0x64])
|
const bytes = Buffer.from([0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00, 0x77, 0x6f, 0x72, 0x6c, 0x64])
|
||||||
await Bun.write(path.join(dir, "null-byte.txt"), bytes)
|
yield* put(path.join(dir, "null-byte.txt"), bytes)
|
||||||
},
|
|
||||||
})
|
|
||||||
await Instance.provide({
|
|
||||||
directory: tmp.path,
|
|
||||||
fn: async () => {
|
|
||||||
const read = await ReadTool.init()
|
|
||||||
await expect(read.execute({ filePath: path.join(tmp.path, "null-byte.txt") }, ctx)).rejects.toThrow(
|
|
||||||
"Cannot read binary file",
|
|
||||||
)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test("rejects known binary extensions", async () => {
|
const err = yield* fail(dir, { filePath: path.join(dir, "null-byte.txt") })
|
||||||
await using tmp = await tmpdir({
|
expect(err.message).toContain("Cannot read binary file")
|
||||||
init: async (dir) => {
|
}),
|
||||||
await Bun.write(path.join(dir, "module.wasm"), "not really wasm")
|
)
|
||||||
},
|
|
||||||
})
|
it.live("rejects known binary extensions", () =>
|
||||||
await Instance.provide({
|
Effect.gen(function* () {
|
||||||
directory: tmp.path,
|
const dir = yield* tmpdirScoped()
|
||||||
fn: async () => {
|
yield* put(path.join(dir, "module.wasm"), "not really wasm")
|
||||||
const read = await ReadTool.init()
|
|
||||||
await expect(read.execute({ filePath: path.join(tmp.path, "module.wasm") }, ctx)).rejects.toThrow(
|
const err = yield* fail(dir, { filePath: path.join(dir, "module.wasm") })
|
||||||
"Cannot read binary file",
|
expect(err.message).toContain("Cannot read binary file")
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json.schemastore.org/package.json",
|
"$schema": "https://json.schemastore.org/package.json",
|
||||||
"name": "@opencode-ai/plugin",
|
"name": "@opencode-ai/plugin",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json.schemastore.org/package.json",
|
"$schema": "https://json.schemastore.org/package.json",
|
||||||
"name": "@opencode-ai/sdk",
|
"name": "@opencode-ai/sdk",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ import type {
|
|||||||
EventTuiPromptAppend,
|
EventTuiPromptAppend,
|
||||||
EventTuiSessionSelect,
|
EventTuiSessionSelect,
|
||||||
EventTuiToastShow,
|
EventTuiToastShow,
|
||||||
|
ExperimentalConsoleGetResponses,
|
||||||
|
ExperimentalConsoleListOrgsResponses,
|
||||||
|
ExperimentalConsoleSwitchOrgResponses,
|
||||||
ExperimentalResourceListResponses,
|
ExperimentalResourceListResponses,
|
||||||
ExperimentalSessionListResponses,
|
ExperimentalSessionListResponses,
|
||||||
ExperimentalWorkspaceCreateErrors,
|
ExperimentalWorkspaceCreateErrors,
|
||||||
@@ -981,13 +984,13 @@ export class Config2 extends HeyApiClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Tool extends HeyApiClient {
|
export class Console extends HeyApiClient {
|
||||||
/**
|
/**
|
||||||
* List tool IDs
|
* Get active Console provider metadata
|
||||||
*
|
*
|
||||||
* Get a list of all available tool IDs, including both built-in tools and dynamically registered tools.
|
* Get the active Console org name and the set of provider IDs managed by that Console org.
|
||||||
*/
|
*/
|
||||||
public ids<ThrowOnError extends boolean = false>(
|
public get<ThrowOnError extends boolean = false>(
|
||||||
parameters?: {
|
parameters?: {
|
||||||
directory?: string
|
directory?: string
|
||||||
workspace?: string
|
workspace?: string
|
||||||
@@ -1005,24 +1008,22 @@ export class Tool extends HeyApiClient {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
return (options?.client ?? this.client).get<ToolIdsResponses, ToolIdsErrors, ThrowOnError>({
|
return (options?.client ?? this.client).get<ExperimentalConsoleGetResponses, unknown, ThrowOnError>({
|
||||||
url: "/experimental/tool/ids",
|
url: "/experimental/console",
|
||||||
...options,
|
...options,
|
||||||
...params,
|
...params,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List tools
|
* List switchable Console orgs
|
||||||
*
|
*
|
||||||
* Get a list of available tools with their JSON schema parameters for a specific provider and model combination.
|
* Get the available Console orgs across logged-in accounts, including the current active org.
|
||||||
*/
|
*/
|
||||||
public list<ThrowOnError extends boolean = false>(
|
public listOrgs<ThrowOnError extends boolean = false>(
|
||||||
parameters: {
|
parameters?: {
|
||||||
directory?: string
|
directory?: string
|
||||||
workspace?: string
|
workspace?: string
|
||||||
provider: string
|
|
||||||
model: string
|
|
||||||
},
|
},
|
||||||
options?: Options<never, ThrowOnError>,
|
options?: Options<never, ThrowOnError>,
|
||||||
) {
|
) {
|
||||||
@@ -1033,18 +1034,55 @@ export class Tool extends HeyApiClient {
|
|||||||
args: [
|
args: [
|
||||||
{ in: "query", key: "directory" },
|
{ in: "query", key: "directory" },
|
||||||
{ in: "query", key: "workspace" },
|
{ in: "query", key: "workspace" },
|
||||||
{ in: "query", key: "provider" },
|
|
||||||
{ in: "query", key: "model" },
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
return (options?.client ?? this.client).get<ToolListResponses, ToolListErrors, ThrowOnError>({
|
return (options?.client ?? this.client).get<ExperimentalConsoleListOrgsResponses, unknown, ThrowOnError>({
|
||||||
url: "/experimental/tool",
|
url: "/experimental/console/orgs",
|
||||||
...options,
|
...options,
|
||||||
...params,
|
...params,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Switch active Console org
|
||||||
|
*
|
||||||
|
* Persist a new active Console account/org selection for the current local OpenCode state.
|
||||||
|
*/
|
||||||
|
public switchOrg<ThrowOnError extends boolean = false>(
|
||||||
|
parameters?: {
|
||||||
|
directory?: string
|
||||||
|
workspace?: string
|
||||||
|
accountID?: string
|
||||||
|
orgID?: string
|
||||||
|
},
|
||||||
|
options?: Options<never, ThrowOnError>,
|
||||||
|
) {
|
||||||
|
const params = buildClientParams(
|
||||||
|
[parameters],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
args: [
|
||||||
|
{ in: "query", key: "directory" },
|
||||||
|
{ in: "query", key: "workspace" },
|
||||||
|
{ in: "body", key: "accountID" },
|
||||||
|
{ in: "body", key: "orgID" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
)
|
||||||
|
return (options?.client ?? this.client).post<ExperimentalConsoleSwitchOrgResponses, unknown, ThrowOnError>({
|
||||||
|
url: "/experimental/console/switch",
|
||||||
|
...options,
|
||||||
|
...params,
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
...options?.headers,
|
||||||
|
...params.headers,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Workspace extends HeyApiClient {
|
export class Workspace extends HeyApiClient {
|
||||||
@@ -1239,6 +1277,11 @@ export class Resource extends HeyApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Experimental extends HeyApiClient {
|
export class Experimental extends HeyApiClient {
|
||||||
|
private _console?: Console
|
||||||
|
get console(): Console {
|
||||||
|
return (this._console ??= new Console({ client: this.client }))
|
||||||
|
}
|
||||||
|
|
||||||
private _workspace?: Workspace
|
private _workspace?: Workspace
|
||||||
get workspace(): Workspace {
|
get workspace(): Workspace {
|
||||||
return (this._workspace ??= new Workspace({ client: this.client }))
|
return (this._workspace ??= new Workspace({ client: this.client }))
|
||||||
@@ -1255,6 +1298,72 @@ export class Experimental extends HeyApiClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class Tool extends HeyApiClient {
|
||||||
|
/**
|
||||||
|
* List tool IDs
|
||||||
|
*
|
||||||
|
* Get a list of all available tool IDs, including both built-in tools and dynamically registered tools.
|
||||||
|
*/
|
||||||
|
public ids<ThrowOnError extends boolean = false>(
|
||||||
|
parameters?: {
|
||||||
|
directory?: string
|
||||||
|
workspace?: string
|
||||||
|
},
|
||||||
|
options?: Options<never, ThrowOnError>,
|
||||||
|
) {
|
||||||
|
const params = buildClientParams(
|
||||||
|
[parameters],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
args: [
|
||||||
|
{ in: "query", key: "directory" },
|
||||||
|
{ in: "query", key: "workspace" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
)
|
||||||
|
return (options?.client ?? this.client).get<ToolIdsResponses, ToolIdsErrors, ThrowOnError>({
|
||||||
|
url: "/experimental/tool/ids",
|
||||||
|
...options,
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List tools
|
||||||
|
*
|
||||||
|
* Get a list of available tools with their JSON schema parameters for a specific provider and model combination.
|
||||||
|
*/
|
||||||
|
public list<ThrowOnError extends boolean = false>(
|
||||||
|
parameters: {
|
||||||
|
directory?: string
|
||||||
|
workspace?: string
|
||||||
|
provider: string
|
||||||
|
model: string
|
||||||
|
},
|
||||||
|
options?: Options<never, ThrowOnError>,
|
||||||
|
) {
|
||||||
|
const params = buildClientParams(
|
||||||
|
[parameters],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
args: [
|
||||||
|
{ in: "query", key: "directory" },
|
||||||
|
{ in: "query", key: "workspace" },
|
||||||
|
{ in: "query", key: "provider" },
|
||||||
|
{ in: "query", key: "model" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
)
|
||||||
|
return (options?.client ?? this.client).get<ToolListResponses, ToolListErrors, ThrowOnError>({
|
||||||
|
url: "/experimental/tool",
|
||||||
|
...options,
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class Worktree extends HeyApiClient {
|
export class Worktree extends HeyApiClient {
|
||||||
/**
|
/**
|
||||||
* Remove worktree
|
* Remove worktree
|
||||||
@@ -4017,16 +4126,16 @@ export class OpencodeClient extends HeyApiClient {
|
|||||||
return (this._config ??= new Config2({ client: this.client }))
|
return (this._config ??= new Config2({ client: this.client }))
|
||||||
}
|
}
|
||||||
|
|
||||||
private _tool?: Tool
|
|
||||||
get tool(): Tool {
|
|
||||||
return (this._tool ??= new Tool({ client: this.client }))
|
|
||||||
}
|
|
||||||
|
|
||||||
private _experimental?: Experimental
|
private _experimental?: Experimental
|
||||||
get experimental(): Experimental {
|
get experimental(): Experimental {
|
||||||
return (this._experimental ??= new Experimental({ client: this.client }))
|
return (this._experimental ??= new Experimental({ client: this.client }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _tool?: Tool
|
||||||
|
get tool(): Tool {
|
||||||
|
return (this._tool ??= new Tool({ client: this.client }))
|
||||||
|
}
|
||||||
|
|
||||||
private _worktree?: Worktree
|
private _worktree?: Worktree
|
||||||
get worktree(): Worktree {
|
get worktree(): Worktree {
|
||||||
return (this._worktree ??= new Worktree({ client: this.client }))
|
return (this._worktree ??= new Worktree({ client: this.client }))
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ export type EventPermissionReplied = {
|
|||||||
export type SessionStatus =
|
export type SessionStatus =
|
||||||
| {
|
| {
|
||||||
type: "idle"
|
type: "idle"
|
||||||
|
suggestion?: string
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: "retry"
|
type: "retry"
|
||||||
@@ -2653,6 +2654,81 @@ export type ConfigProvidersResponses = {
|
|||||||
|
|
||||||
export type ConfigProvidersResponse = ConfigProvidersResponses[keyof ConfigProvidersResponses]
|
export type ConfigProvidersResponse = ConfigProvidersResponses[keyof ConfigProvidersResponses]
|
||||||
|
|
||||||
|
export type ExperimentalConsoleGetData = {
|
||||||
|
body?: never
|
||||||
|
path?: never
|
||||||
|
query?: {
|
||||||
|
directory?: string
|
||||||
|
workspace?: string
|
||||||
|
}
|
||||||
|
url: "/experimental/console"
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ExperimentalConsoleGetResponses = {
|
||||||
|
/**
|
||||||
|
* Active Console provider metadata
|
||||||
|
*/
|
||||||
|
200: {
|
||||||
|
consoleManagedProviders: Array<string>
|
||||||
|
activeOrgName?: string
|
||||||
|
switchableOrgCount: number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ExperimentalConsoleGetResponse = ExperimentalConsoleGetResponses[keyof ExperimentalConsoleGetResponses]
|
||||||
|
|
||||||
|
export type ExperimentalConsoleListOrgsData = {
|
||||||
|
body?: never
|
||||||
|
path?: never
|
||||||
|
query?: {
|
||||||
|
directory?: string
|
||||||
|
workspace?: string
|
||||||
|
}
|
||||||
|
url: "/experimental/console/orgs"
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ExperimentalConsoleListOrgsResponses = {
|
||||||
|
/**
|
||||||
|
* Switchable Console orgs
|
||||||
|
*/
|
||||||
|
200: {
|
||||||
|
orgs: Array<{
|
||||||
|
accountID: string
|
||||||
|
accountEmail: string
|
||||||
|
accountUrl: string
|
||||||
|
orgID: string
|
||||||
|
orgName: string
|
||||||
|
active: boolean
|
||||||
|
}>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ExperimentalConsoleListOrgsResponse =
|
||||||
|
ExperimentalConsoleListOrgsResponses[keyof ExperimentalConsoleListOrgsResponses]
|
||||||
|
|
||||||
|
export type ExperimentalConsoleSwitchOrgData = {
|
||||||
|
body?: {
|
||||||
|
accountID: string
|
||||||
|
orgID: string
|
||||||
|
}
|
||||||
|
path?: never
|
||||||
|
query?: {
|
||||||
|
directory?: string
|
||||||
|
workspace?: string
|
||||||
|
}
|
||||||
|
url: "/experimental/console/switch"
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ExperimentalConsoleSwitchOrgResponses = {
|
||||||
|
/**
|
||||||
|
* Switch success
|
||||||
|
*/
|
||||||
|
200: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ExperimentalConsoleSwitchOrgResponse =
|
||||||
|
ExperimentalConsoleSwitchOrgResponses[keyof ExperimentalConsoleSwitchOrgResponses]
|
||||||
|
|
||||||
export type ToolIdsData = {
|
export type ToolIdsData = {
|
||||||
body?: never
|
body?: never
|
||||||
path?: never
|
path?: never
|
||||||
|
|||||||
@@ -1220,6 +1220,194 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/experimental/console": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "experimental.console.get",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "directory",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "workspace",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"summary": "Get active Console provider metadata",
|
||||||
|
"description": "Get the active Console org name and the set of provider IDs managed by that Console org.",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Active Console provider metadata",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"consoleManagedProviders": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"activeOrgName": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"switchableOrgCount": {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 0,
|
||||||
|
"maximum": 9007199254740991
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["consoleManagedProviders", "switchableOrgCount"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-codeSamples": [
|
||||||
|
{
|
||||||
|
"lang": "js",
|
||||||
|
"source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.console.get({\n ...\n})"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/experimental/console/orgs": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "experimental.console.listOrgs",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "directory",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "workspace",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"summary": "List switchable Console orgs",
|
||||||
|
"description": "Get the available Console orgs across logged-in accounts, including the current active org.",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Switchable Console orgs",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"orgs": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"accountID": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"accountEmail": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"accountUrl": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"orgID": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"orgName": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"active": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["accountID", "accountEmail", "accountUrl", "orgID", "orgName", "active"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["orgs"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-codeSamples": [
|
||||||
|
{
|
||||||
|
"lang": "js",
|
||||||
|
"source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.console.listOrgs({\n ...\n})"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/experimental/console/switch": {
|
||||||
|
"post": {
|
||||||
|
"operationId": "experimental.console.switchOrg",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "directory",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "workspace",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"summary": "Switch active Console org",
|
||||||
|
"description": "Persist a new active Console account/org selection for the current local OpenCode state.",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Switch success",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"requestBody": {
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"accountID": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"orgID": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["accountID", "orgID"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-codeSamples": [
|
||||||
|
{
|
||||||
|
"lang": "js",
|
||||||
|
"source": "import { createOpencodeClient } from \"@opencode-ai/sdk\n\nconst client = createOpencodeClient()\nawait client.experimental.console.switchOrg({\n ...\n})"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"/experimental/tool/ids": {
|
"/experimental/tool/ids": {
|
||||||
"get": {
|
"get": {
|
||||||
"operationId": "tool.ids",
|
"operationId": "tool.ids",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@opencode-ai/slack",
|
"name": "@opencode-ai/slack",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@opencode-ai/ui",
|
"name": "@opencode-ai/ui",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@opencode-ai/util",
|
"name": "@opencode-ai/util",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "@opencode-ai/web",
|
"name": "@opencode-ai/web",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "astro dev",
|
"dev": "astro dev",
|
||||||
"dev:remote": "VITE_API_URL=https://api.opencode.ai astro dev",
|
"dev:remote": "VITE_API_URL=https://api.opencode.ai astro dev",
|
||||||
|
|||||||
@@ -573,6 +573,7 @@ OpenCode can be configured using environment variables.
|
|||||||
| `OPENCODE_DISABLE_CLAUDE_CODE_PROMPT` | boolean | Disable reading `~/.claude/CLAUDE.md` |
|
| `OPENCODE_DISABLE_CLAUDE_CODE_PROMPT` | boolean | Disable reading `~/.claude/CLAUDE.md` |
|
||||||
| `OPENCODE_DISABLE_CLAUDE_CODE_SKILLS` | boolean | Disable loading `.claude/skills` |
|
| `OPENCODE_DISABLE_CLAUDE_CODE_SKILLS` | boolean | Disable loading `.claude/skills` |
|
||||||
| `OPENCODE_DISABLE_MODELS_FETCH` | boolean | Disable fetching models from remote sources |
|
| `OPENCODE_DISABLE_MODELS_FETCH` | boolean | Disable fetching models from remote sources |
|
||||||
|
| `OPENCODE_DISABLE_MOUSE` | boolean | Disable mouse capture in the TUI |
|
||||||
| `OPENCODE_FAKE_VCS` | string | Fake VCS provider for testing purposes |
|
| `OPENCODE_FAKE_VCS` | string | Fake VCS provider for testing purposes |
|
||||||
| `OPENCODE_DISABLE_FILETIME_CHECK` | boolean | Disable file time checking for optimization |
|
| `OPENCODE_DISABLE_FILETIME_CHECK` | boolean | Disable file time checking for optimization |
|
||||||
| `OPENCODE_CLIENT` | string | Client identifier (defaults to `cli`) |
|
| `OPENCODE_CLIENT` | string | Client identifier (defaults to `cli`) |
|
||||||
|
|||||||
@@ -272,7 +272,8 @@ Use a dedicated `tui.json` (or `tui.jsonc`) file for TUI-specific settings.
|
|||||||
"scroll_acceleration": {
|
"scroll_acceleration": {
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
"diff_style": "auto"
|
"diff_style": "auto",
|
||||||
|
"mouse": true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -280,8 +281,6 @@ Use `OPENCODE_TUI_CONFIG` to point to a custom TUI config file.
|
|||||||
|
|
||||||
Legacy `theme`, `keybinds`, and `tui` keys in `opencode.json` are deprecated and automatically migrated when possible.
|
Legacy `theme`, `keybinds`, and `tui` keys in `opencode.json` are deprecated and automatically migrated when possible.
|
||||||
|
|
||||||
[Learn more about TUI configuration here](/docs/tui#configure).
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Server
|
### Server
|
||||||
|
|||||||
@@ -368,7 +368,8 @@ You can customize TUI behavior through `tui.json` (or `tui.jsonc`).
|
|||||||
"scroll_acceleration": {
|
"scroll_acceleration": {
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
"diff_style": "auto"
|
"diff_style": "auto",
|
||||||
|
"mouse": true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -381,6 +382,7 @@ This is separate from `opencode.json`, which configures server/runtime behavior.
|
|||||||
- `scroll_acceleration.enabled` - Enable macOS-style scroll acceleration for smooth, natural scrolling. When enabled, scroll speed increases with rapid scrolling gestures and stays precise for slower movements. **This setting takes precedence over `scroll_speed` and overrides it when enabled.**
|
- `scroll_acceleration.enabled` - Enable macOS-style scroll acceleration for smooth, natural scrolling. When enabled, scroll speed increases with rapid scrolling gestures and stays precise for slower movements. **This setting takes precedence over `scroll_speed` and overrides it when enabled.**
|
||||||
- `scroll_speed` - Controls how fast the TUI scrolls when using scroll commands (minimum: `0.001`, supports decimal values). Defaults to `3`. **Note: This is ignored if `scroll_acceleration.enabled` is set to `true`.**
|
- `scroll_speed` - Controls how fast the TUI scrolls when using scroll commands (minimum: `0.001`, supports decimal values). Defaults to `3`. **Note: This is ignored if `scroll_acceleration.enabled` is set to `true`.**
|
||||||
- `diff_style` - Controls diff rendering. `"auto"` adapts to terminal width, `"stacked"` always shows a single-column layout.
|
- `diff_style` - Controls diff rendering. `"auto"` adapts to terminal width, `"stacked"` always shows a single-column layout.
|
||||||
|
- `mouse` - Enable or disable mouse capture in the TUI (default: `true`). When disabled, the terminal's native mouse selection/scrolling behavior is preserved.
|
||||||
|
|
||||||
Use `OPENCODE_TUI_CONFIG` to load a custom TUI config path.
|
Use `OPENCODE_TUI_CONFIG` to load a custom TUI config path.
|
||||||
|
|
||||||
|
|||||||
@@ -94,8 +94,6 @@ You can also access our models through the following API endpoints.
|
|||||||
| GLM 5 | glm-5 | `https://opencode.ai/zen/v1/chat/completions` | `@ai-sdk/openai-compatible` |
|
| GLM 5 | glm-5 | `https://opencode.ai/zen/v1/chat/completions` | `@ai-sdk/openai-compatible` |
|
||||||
| Kimi K2.5 | kimi-k2.5 | `https://opencode.ai/zen/v1/chat/completions` | `@ai-sdk/openai-compatible` |
|
| Kimi K2.5 | kimi-k2.5 | `https://opencode.ai/zen/v1/chat/completions` | `@ai-sdk/openai-compatible` |
|
||||||
| Big Pickle | big-pickle | `https://opencode.ai/zen/v1/chat/completions` | `@ai-sdk/openai-compatible` |
|
| Big Pickle | big-pickle | `https://opencode.ai/zen/v1/chat/completions` | `@ai-sdk/openai-compatible` |
|
||||||
| MiMo V2 Pro Free | mimo-v2-pro-free | `https://opencode.ai/zen/v1/chat/completions` | `@ai-sdk/openai-compatible` |
|
|
||||||
| MiMo V2 Omni Free | mimo-v2-omni-free | `https://opencode.ai/zen/v1/chat/completions` | `@ai-sdk/openai-compatible` |
|
|
||||||
| Qwen3.6 Plus Free | qwen3.6-plus-free | `https://opencode.ai/zen/v1/chat/completions` | `@ai-sdk/openai-compatible` |
|
| Qwen3.6 Plus Free | qwen3.6-plus-free | `https://opencode.ai/zen/v1/chat/completions` | `@ai-sdk/openai-compatible` |
|
||||||
| Nemotron 3 Super Free | nemotron-3-super-free | `https://opencode.ai/zen/v1/chat/completions` | `@ai-sdk/openai-compatible` |
|
| Nemotron 3 Super Free | nemotron-3-super-free | `https://opencode.ai/zen/v1/chat/completions` | `@ai-sdk/openai-compatible` |
|
||||||
|
|
||||||
@@ -122,8 +120,6 @@ We support a pay-as-you-go model. Below are the prices **per 1M tokens**.
|
|||||||
| Model | Input | Output | Cached Read | Cached Write |
|
| Model | Input | Output | Cached Read | Cached Write |
|
||||||
| --------------------------------- | ------ | ------- | ----------- | ------------ |
|
| --------------------------------- | ------ | ------- | ----------- | ------------ |
|
||||||
| Big Pickle | Free | Free | Free | - |
|
| Big Pickle | Free | Free | Free | - |
|
||||||
| MiMo V2 Pro Free | Free | Free | Free | - |
|
|
||||||
| MiMo V2 Omni Free | Free | Free | Free | - |
|
|
||||||
| Qwen3.6 Plus Free | Free | Free | Free | - |
|
| Qwen3.6 Plus Free | Free | Free | Free | - |
|
||||||
| Nemotron 3 Super Free | Free | Free | Free | - |
|
| Nemotron 3 Super Free | Free | Free | Free | - |
|
||||||
| MiniMax M2.5 Free | Free | Free | Free | - |
|
| MiniMax M2.5 Free | Free | Free | Free | - |
|
||||||
@@ -169,8 +165,6 @@ Credit card fees are passed along at cost (4.4% + $0.30 per transaction); we don
|
|||||||
The free models:
|
The free models:
|
||||||
|
|
||||||
- MiniMax M2.5 Free is available on OpenCode for a limited time. The team is using this time to collect feedback and improve the model.
|
- MiniMax M2.5 Free is available on OpenCode for a limited time. The team is using this time to collect feedback and improve the model.
|
||||||
- MiMo V2 Pro Free is available on OpenCode for a limited time. The team is using this time to collect feedback and improve the model.
|
|
||||||
- MiMo V2 Omni Free is available on OpenCode for a limited time. The team is using this time to collect feedback and improve the model.
|
|
||||||
- Qwen3.6 Plus Free is available on OpenCode for a limited time. The team is using this time to collect feedback and improve the model.
|
- Qwen3.6 Plus Free is available on OpenCode for a limited time. The team is using this time to collect feedback and improve the model.
|
||||||
- Nemotron 3 Super Free is available on OpenCode for a limited time. The team is using this time to collect feedback and improve the model.
|
- Nemotron 3 Super Free is available on OpenCode for a limited time. The team is using this time to collect feedback and improve the model.
|
||||||
- Big Pickle is a stealth model that's free on OpenCode for a limited time. The team is using this time to collect feedback and improve the model.
|
- Big Pickle is a stealth model that's free on OpenCode for a limited time. The team is using this time to collect feedback and improve the model.
|
||||||
@@ -218,8 +212,6 @@ All our models are hosted in the US. Our providers follow a zero-retention polic
|
|||||||
|
|
||||||
- Big Pickle: During its free period, collected data may be used to improve the model.
|
- Big Pickle: During its free period, collected data may be used to improve the model.
|
||||||
- MiniMax M2.5 Free: During its free period, collected data may be used to improve the model.
|
- MiniMax M2.5 Free: During its free period, collected data may be used to improve the model.
|
||||||
- MiMo V2 Pro Free: During its free period, collected data may be used to improve the model.
|
|
||||||
- MiMo V2 Omni Free: During its free period, collected data may be used to improve the model.
|
|
||||||
- Qwen3.6 Plus Free: During its free period, collected data may be used to improve the model.
|
- Qwen3.6 Plus Free: During its free period, collected data may be used to improve the model.
|
||||||
- Nemotron 3 Super Free: During its free period, collected data may be used to improve the model.
|
- Nemotron 3 Super Free: During its free period, collected data may be used to improve the model.
|
||||||
- OpenAI APIs: Requests are retained for 30 days in accordance with [OpenAI's Data Policies](https://platform.openai.com/docs/guides/your-data).
|
- OpenAI APIs: Requests are retained for 30 days in accordance with [OpenAI's Data Policies](https://platform.openai.com/docs/guides/your-data).
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "opencode",
|
"name": "opencode",
|
||||||
"displayName": "opencode",
|
"displayName": "opencode",
|
||||||
"description": "opencode for VS Code",
|
"description": "opencode for VS Code",
|
||||||
"version": "1.3.13",
|
"version": "1.3.15",
|
||||||
"publisher": "sst-dev",
|
"publisher": "sst-dev",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
Reference in New Issue
Block a user