diff options
| author | Shoubhit Dash <[email protected]> | 2026-04-16 17:30:14 +0530 |
|---|---|---|
| committer | Shoubhit Dash <[email protected]> | 2026-04-16 17:30:14 +0530 |
| commit | 2e18a603f0ea24154908e748493fd4bfaa74fc00 (patch) | |
| tree | b723e00af2821b213573b16fa199b64babd5f1f5 /packages/plugin/src/example-workspace.ts | |
| parent | 9819eb04614fd607cacb07d754052f1531a82331 (diff) | |
| parent | 7341718f9234b0cf3a8758c87e91d2006b71bff6 (diff) | |
| download | opencode-2e18a603f0ea24154908e748493fd4bfaa74fc00.tar.gz opencode-2e18a603f0ea24154908e748493fd4bfaa74fc00.zip | |
merge dev
Diffstat (limited to 'packages/plugin/src/example-workspace.ts')
| -rw-r--r-- | packages/plugin/src/example-workspace.ts | 34 |
1 files changed, 34 insertions, 0 deletions
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 |
