optimize
This commit is contained in:
parent
13ea36f575
commit
f80bf7a423
2 changed files with 1 additions and 20 deletions
|
|
@ -21,7 +21,7 @@ import { fileURLToPath } from "url"
|
|||
import { writeHeapSnapshot } from "v8"
|
||||
|
||||
type RpcClient = ReturnType<typeof Rpc.client<typeof rpc>>
|
||||
const simulatedDirectory = "/"
|
||||
const simulatedDirectory = "/opencode"
|
||||
const simulatedCwdEnv = "OPENCODE_SIMULATION_CWD"
|
||||
|
||||
function fakeCwd(directory: string) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ export interface SimulationMcpHarness {
|
|||
readonly mockMouse: SimulationActions.MockMouse
|
||||
readonly renderOnce: () => Promise<void>
|
||||
readonly screen: () => string
|
||||
readonly spans: () => CapturedFrame
|
||||
}
|
||||
|
||||
export interface SimulationMcpOptions {
|
||||
|
|
@ -55,7 +54,6 @@ type RenderBuffer = {
|
|||
readonly width: number
|
||||
readonly height: number
|
||||
getRealCharBytes(includeAnsi?: boolean): Uint8Array
|
||||
getSpanLines(): CapturedFrame["lines"]
|
||||
}
|
||||
|
||||
const decoder = new TextDecoder()
|
||||
|
|
@ -159,16 +157,6 @@ export function harnessFromRenderer(renderer: CliRenderer): SimulationMcpHarness
|
|||
await renderer.idle()
|
||||
},
|
||||
screen: () => decoder.decode(currentBuffer(renderer).getRealCharBytes(true)),
|
||||
spans: () => {
|
||||
const buffer = currentBuffer(renderer)
|
||||
const cursor = renderer.getCursorState()
|
||||
return {
|
||||
cols: buffer.width,
|
||||
rows: buffer.height,
|
||||
cursor: [cursor.x, cursor.y] as [number, number],
|
||||
lines: buffer.getSpanLines(),
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -208,7 +196,6 @@ function snapshot(options: Options) {
|
|||
const running = current(options)
|
||||
return {
|
||||
screen: running.harness.screen(),
|
||||
spans: running.harness.spans(),
|
||||
ui: state(options),
|
||||
}
|
||||
}
|
||||
|
|
@ -238,9 +225,6 @@ function createServer(options: Options) {
|
|||
server.registerResource("screen", "simulation://screen", { mimeType: "text/plain" }, () => ({
|
||||
contents: [{ uri: "simulation://screen", mimeType: "text/plain", text: current(options).harness.screen() }],
|
||||
}))
|
||||
server.registerResource("spans", "simulation://spans", { mimeType: "application/json" }, () => ({
|
||||
contents: [{ uri: "simulation://spans", mimeType: "application/json", text: JSON.stringify(current(options).harness.spans()) }],
|
||||
}))
|
||||
server.registerResource("ui-state", "simulation://ui-state", { mimeType: "application/json" }, () => ({
|
||||
contents: [{ uri: "simulation://ui-state", mimeType: "application/json", text: JSON.stringify(state(options)) }],
|
||||
}))
|
||||
|
|
@ -269,9 +253,6 @@ function createServer(options: Options) {
|
|||
server.registerTool("simulation_screen_get", { description: "Get the current TUI screen buffer." }, () =>
|
||||
toolResult({ screen: current(options).harness.screen() }),
|
||||
)
|
||||
server.registerTool("simulation_spans_get", { description: "Get the current structured TUI spans." }, () =>
|
||||
toolResult(current(options).harness.spans()),
|
||||
)
|
||||
server.registerTool("simulation_ui_state_get", { description: "Get elements, focus state, and generated actions." }, () =>
|
||||
toolResult(state(options)),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue