Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion packages/opencode/src/acp/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,33 @@ export namespace ACP {
} finally {
break
}

case "file.edited":
if (this.config.clientCapabilities?.fs?.writeTextFile) {
const filepath = event.properties.file
try {
const content = await Bun.file(filepath).text()
await this.connection.writeTextFile({
sessionId,
path: filepath,
content,
})
log.info("synced file edit to ACP client", { filepath, sessionId })
} catch (err) {
log.error("failed to sync file edit to ACP client", { error: err, filepath, sessionId })
}
}
break
}
}
})
}

async initialize(params: InitializeRequest): Promise<InitializeResponse> {
log.info("initialize", { protocolVersion: params.protocolVersion })
log.info("initialize", { protocolVersion: params.protocolVersion, clientCapabilities: params.clientCapabilities })

// Store client capabilities for use in session event handling
this.config.clientCapabilities = params.clientCapabilities

const authMethod: AuthMethod = {
description: "Run `opencode auth login` in the terminal",
Expand Down
3 changes: 2 additions & 1 deletion packages/opencode/src/acp/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { McpServer } from "@agentclientprotocol/sdk"
import type { ClientCapabilities, McpServer } from "@agentclientprotocol/sdk"
import type { OpencodeClient } from "@opencode-ai/sdk/v2"

export interface ACPSessionState {
Expand All @@ -19,4 +19,5 @@ export interface ACPConfig {
providerID: string
modelID: string
}
clientCapabilities?: ClientCapabilities
}