Skip to content

Commit

Permalink
move interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmacarthy committed Dec 16, 2024
1 parent 1a1b0b7 commit 20ef43b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 37 deletions.
35 changes: 35 additions & 0 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,38 @@ export interface Tool {
status?: string
error?: string
}

export interface CreateFileArgs {
path: string
content: string
openAfterCreate?: boolean
createIntermediateDirs?: boolean
fileTemplate?: string
permissions?: string
}

export interface RunCommandArgs {
command: string
cwd?: string
env?: Record<string, string>
shell?: string
timeout?: number
captureOutput?: boolean
runInBackground?: boolean
}

export interface OpenFileArgs {
path: string
preview?: boolean
viewColumn?: "beside" | "active" | "new"
encoding?: string
revealIfOpen?: boolean
}

export interface EditFileArgs {
path: string
edit: string
createIfNotExists?: boolean
backupBeforeEdit?: boolean
}

2 changes: 1 addition & 1 deletion src/extension/review-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export class GithubService extends ConversationHistory {

try {
const data = getResponseData(streamResponse)
this._completion = this._completion + data
this._completion = this._completion + data.content
this.webView.postMessage({
type: EVENT_NAME.twinnyOnCompletion,
data: {
Expand Down
36 changes: 1 addition & 35 deletions src/extension/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,10 @@ import { TextEncoder } from "util"
import * as vscode from "vscode"

import { EVENT_NAME, TOOL_EVENT_NAME } from "../common/constants"
import { ClientMessage, Message, ServerMessage, Tool } from "../common/types"
import { ClientMessage, CreateFileArgs, EditFileArgs, Message, OpenFileArgs, RunCommandArgs, ServerMessage, Tool } from "../common/types"

import { Base } from "./base"

interface CreateFileArgs {
path: string
content: string
openAfterCreate?: boolean
createIntermediateDirs?: boolean
fileTemplate?: string
permissions?: string
}

interface RunCommandArgs {
command: string
cwd?: string
env?: Record<string, string>
shell?: string
timeout?: number
captureOutput?: boolean
runInBackground?: boolean
}

interface OpenFileArgs {
path: string
preview?: boolean
viewColumn?: "beside" | "active" | "new"
encoding?: string
revealIfOpen?: boolean
}

interface EditFileArgs {
path: string
edit: string
createIfNotExists?: boolean
backupBeforeEdit?: boolean
}

export class Tools extends Base {
private _workspaceRoot: string | undefined
private webView: vscode.Webview
Expand Down
2 changes: 1 addition & 1 deletion src/extension/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ export const getResponseData = (data: StreamResponse) => {
type: "content" as const,
content:
data?.choices?.[0]?.delta?.content ||
data.choices[0].message.content ||
data.choices[0].message?.content ||
""
}
}
Expand Down

0 comments on commit 20ef43b

Please sign in to comment.