summaryrefslogtreecommitdiffhomepage
path: root/packages/plugin
diff options
context:
space:
mode:
authorShoubhit Dash <[email protected]>2026-04-16 17:30:14 +0530
committerShoubhit Dash <[email protected]>2026-04-16 17:30:14 +0530
commit2e18a603f0ea24154908e748493fd4bfaa74fc00 (patch)
treeb723e00af2821b213573b16fa199b64babd5f1f5 /packages/plugin
parent9819eb04614fd607cacb07d754052f1531a82331 (diff)
parent7341718f9234b0cf3a8758c87e91d2006b71bff6 (diff)
downloadopencode-2e18a603f0ea24154908e748493fd4bfaa74fc00.tar.gz
opencode-2e18a603f0ea24154908e748493fd4bfaa74fc00.zip
merge dev
Diffstat (limited to 'packages/plugin')
-rw-r--r--packages/plugin/package.json11
-rw-r--r--packages/plugin/src/example-workspace.ts34
-rw-r--r--packages/plugin/src/example.ts2
-rw-r--r--packages/plugin/src/index.ts51
-rw-r--r--packages/plugin/src/tool.ts3
-rw-r--r--packages/plugin/src/tui.ts5
-rw-r--r--packages/plugin/tsconfig.json1
7 files changed, 95 insertions, 12 deletions
diff --git a/packages/plugin/package.json b/packages/plugin/package.json
index ced1523da..76fe2e862 100644
--- a/packages/plugin/package.json
+++ b/packages/plugin/package.json
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@opencode-ai/plugin",
- "version": "1.4.3",
+ "version": "1.4.6",
"type": "module",
"license": "MIT",
"scripts": {
@@ -18,11 +18,12 @@
],
"dependencies": {
"@opencode-ai/sdk": "workspace:*",
+ "effect": "catalog:",
"zod": "catalog:"
},
"peerDependencies": {
- "@opentui/core": ">=0.1.97",
- "@opentui/solid": ">=0.1.97"
+ "@opentui/core": ">=0.1.99",
+ "@opentui/solid": ">=0.1.99"
},
"peerDependenciesMeta": {
"@opentui/core": {
@@ -33,8 +34,8 @@
}
},
"devDependencies": {
- "@opentui/core": "0.1.97",
- "@opentui/solid": "0.1.97",
+ "@opentui/core": "0.1.99",
+ "@opentui/solid": "0.1.99",
"@tsconfig/node22": "catalog:",
"@types/node": "catalog:",
"typescript": "catalog:",
diff --git a/packages/plugin/src/example-workspace.ts b/packages/plugin/src/example-workspace.ts
new file mode 100644
index 000000000..925328450
--- /dev/null
+++ b/packages/plugin/src/example-workspace.ts
@@ -0,0 +1,34 @@
+import type { Plugin } from "@opencode-ai/plugin"
+import { mkdir, rm } from "node:fs/promises"
+
+export const FolderWorkspacePlugin: Plugin = async ({ experimental_workspace }) => {
+ experimental_workspace.register("folder", {
+ name: "Folder",
+ description: "Create a blank folder",
+ configure(config) {
+ const rand = "" + Math.random()
+
+ return {
+ ...config,
+ directory: `/tmp/folder/folder-${rand}`,
+ }
+ },
+ async create(config) {
+ if (!config.directory) return
+ await mkdir(config.directory, { recursive: true })
+ },
+ async remove(config) {
+ await rm(config.directory!, { recursive: true, force: true })
+ },
+ target(config) {
+ return {
+ type: "local",
+ directory: config.directory!,
+ }
+ },
+ })
+
+ return {}
+}
+
+export default FolderWorkspacePlugin
diff --git a/packages/plugin/src/example.ts b/packages/plugin/src/example.ts
index 1cf042fe9..9d7e178a9 100644
--- a/packages/plugin/src/example.ts
+++ b/packages/plugin/src/example.ts
@@ -1,7 +1,7 @@
import { Plugin } from "./index.js"
import { tool } from "./tool.js"
-export const ExamplePlugin: Plugin = async (ctx) => {
+export const ExamplePlugin: Plugin = async (_ctx) => {
return {
tool: {
mytool: tool({
diff --git a/packages/plugin/src/index.ts b/packages/plugin/src/index.ts
index 1afb55daa..d53c23a89 100644
--- a/packages/plugin/src/index.ts
+++ b/packages/plugin/src/index.ts
@@ -24,11 +24,44 @@ export type ProviderContext = {
options: Record<string, any>
}
+export type WorkspaceInfo = {
+ id: string
+ type: string
+ name: string
+ branch: string | null
+ directory: string | null
+ extra: unknown | null
+ projectID: string
+}
+
+export type WorkspaceTarget =
+ | {
+ type: "local"
+ directory: string
+ }
+ | {
+ type: "remote"
+ url: string | URL
+ headers?: HeadersInit
+ }
+
+export type WorkspaceAdaptor = {
+ name: string
+ description: string
+ configure(config: WorkspaceInfo): WorkspaceInfo | Promise<WorkspaceInfo>
+ create(config: WorkspaceInfo, from?: WorkspaceInfo): Promise<void>
+ remove(config: WorkspaceInfo): Promise<void>
+ target(config: WorkspaceInfo): WorkspaceTarget | Promise<WorkspaceTarget>
+}
+
export type PluginInput = {
client: ReturnType<typeof createOpencodeClient>
project: Project
directory: string
worktree: string
+ experimental_workspace: {
+ register(type: string, adaptor: WorkspaceAdaptor): void
+ }
serverUrl: URL
$: BunShell
}
@@ -271,6 +304,24 @@ export interface Hooks {
input: { sessionID: string },
output: { context: string[]; prompt?: string },
) => Promise<void>
+ /**
+ * Called after compaction succeeds and before a synthetic user
+ * auto-continue message is added.
+ *
+ * - `enabled`: Defaults to `true`. Set to `false` to skip the synthetic
+ * user "continue" turn.
+ */
+ "experimental.compaction.autocontinue"?: (
+ input: {
+ sessionID: string
+ agent: string
+ model: Model
+ provider: ProviderContext
+ message: UserMessage
+ overflow: boolean
+ },
+ output: { enabled: boolean },
+ ) => Promise<void>
"experimental.text.complete"?: (
input: { sessionID: string; messageID: string; partID: string },
output: { text: string },
diff --git a/packages/plugin/src/tool.ts b/packages/plugin/src/tool.ts
index 23aa512d9..b568d0371 100644
--- a/packages/plugin/src/tool.ts
+++ b/packages/plugin/src/tool.ts
@@ -1,4 +1,5 @@
import { z } from "zod"
+import { Effect } from "effect"
export type ToolContext = {
sessionID: string
@@ -16,7 +17,7 @@ export type ToolContext = {
worktree: string
abort: AbortSignal
metadata(input: { title?: string; metadata?: { [key: string]: any } }): void
- ask(input: AskInput): Promise<void>
+ ask(input: AskInput): Effect.Effect<void>
}
type AskInput = {
diff --git a/packages/plugin/src/tui.ts b/packages/plugin/src/tui.ts
index 8f8439fab..099cf2758 100644
--- a/packages/plugin/src/tui.ts
+++ b/packages/plugin/src/tui.ts
@@ -13,7 +13,6 @@ import type {
QuestionRequest,
SessionStatus,
TextPart,
- Workspace,
Config as SdkConfig,
} from "@opencode-ai/sdk/v2"
import type { CliRenderer, ParsedKey, RGBA, SlotMode } from "@opentui/core"
@@ -272,10 +271,6 @@ export type TuiState = {
directory: string
}
readonly vcs: { branch?: string } | undefined
- readonly workspace: {
- list: () => ReadonlyArray<Workspace>
- get: (workspaceID: string) => Workspace | undefined
- }
session: {
count: () => number
diff: (sessionID: string) => ReadonlyArray<TuiSidebarFileItem>
diff --git a/packages/plugin/tsconfig.json b/packages/plugin/tsconfig.json
index 117381878..f8e9370d8 100644
--- a/packages/plugin/tsconfig.json
+++ b/packages/plugin/tsconfig.json
@@ -2,6 +2,7 @@
"$schema": "https://json.schemastore.org/tsconfig.json",
"extends": "@tsconfig/node22/tsconfig.json",
"compilerOptions": {
+ "rootDir": "src",
"outDir": "dist",
"module": "nodenext",
"declaration": true,