@opencode-ai/sdk
Advanced tools
@@ -1001,5 +1001,24 @@ export type Project = { | ||
| path: string; | ||
| absolute: string; | ||
| type: "file" | "directory"; | ||
| ignored: boolean; | ||
| }; | ||
| export type FileContent = { | ||
| content: string; | ||
| diff?: string; | ||
| patch?: { | ||
| oldFileName: string; | ||
| newFileName: string; | ||
| oldHeader?: string; | ||
| newHeader?: string; | ||
| hunks: Array<{ | ||
| oldStart: number; | ||
| oldLines: number; | ||
| newStart: number; | ||
| newLines: number; | ||
| lines: Array<string>; | ||
| }>; | ||
| index?: string; | ||
| }; | ||
| }; | ||
| export type File = { | ||
@@ -1670,6 +1689,3 @@ path: string; | ||
| */ | ||
| 200: { | ||
| type: "raw" | "patch"; | ||
| content: string; | ||
| }; | ||
| 200: FileContent; | ||
| }; | ||
@@ -1676,0 +1692,0 @@ export type FileReadResponse = FileReadResponses[keyof FileReadResponses]; |
+11
-0
@@ -9,2 +9,10 @@ import { type Config } from "./gen/types.gen.js"; | ||
| }; | ||
| export type TuiOptions = { | ||
| project?: string; | ||
| model?: string; | ||
| session?: string; | ||
| agent?: string; | ||
| signal?: AbortSignal; | ||
| config?: Config; | ||
| }; | ||
| export declare function createOpencodeServer(options?: ServerOptions): Promise<{ | ||
@@ -14,1 +22,4 @@ url: string; | ||
| }>; | ||
| export declare function createOpencodeTui(options?: TuiOptions): { | ||
| close(): void; | ||
| }; |
+28
-0
@@ -64,1 +64,29 @@ import { spawn } from "node:child_process"; | ||
| } | ||
| export function createOpencodeTui(options) { | ||
| const args = []; | ||
| if (options?.project) { | ||
| args.push(`--project=${options.project}`); | ||
| } | ||
| if (options?.model) { | ||
| args.push(`--model=${options.model}`); | ||
| } | ||
| if (options?.session) { | ||
| args.push(`--session=${options.session}`); | ||
| } | ||
| if (options?.agent) { | ||
| args.push(`--agent=${options.agent}`); | ||
| } | ||
| const proc = spawn(`opencode`, args, { | ||
| signal: options?.signal, | ||
| stdio: 'inherit', | ||
| env: { | ||
| ...process.env, | ||
| OPENCODE_CONFIG_CONTENT: JSON.stringify(options?.config ?? {}), | ||
| }, | ||
| }); | ||
| return { | ||
| close() { | ||
| proc.kill(); | ||
| }, | ||
| }; | ||
| } |
+1
-1
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "name": "@opencode-ai/sdk", | ||
| "version": "0.6.4", | ||
| "version": "0.6.5", | ||
| "type": "module", | ||
@@ -6,0 +6,0 @@ "scripts": { |
123922
1.1%4093
1.36%4
33.33%