refactor(acp): reduce bridge to automation protocol
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
import { structuredPatch } from 'diff'
|
||||
import type { FileDiff } from '@deepseek-ai/dsh-tools'
|
||||
|
||||
/** Context lines shown on each side of an applied hunk (matches claude-agent-acp). */
|
||||
/** Context lines shown on each side of an applied hunk. */
|
||||
export const DIFF_CONTEXT = 3
|
||||
|
||||
/**
|
||||
@@ -15,8 +15,7 @@ export const DIFF_CONTEXT = 3
|
||||
* contextual-diff hunks. Attached opaquely (as `unknown`) on the tool result and
|
||||
* persisted with the session log — it must be JSON-serializable (the session
|
||||
* validates this at `append`), so `presentResult` reproduces the diff card on
|
||||
* replay. The producing tool owns this shape; the bridge only sees the opaque
|
||||
* `meta` and the tool narrows it back via {@link diffsFromMeta}.
|
||||
* replay. The producing tool owns and narrows this opaque shape.
|
||||
*/
|
||||
export type FsDiffMeta = { diffs: FileDiff[] }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Derive the working directory a filesystem tool resolves relative paths against: the calling
|
||||
* agent's per-session workspace (`exec.agent.session.header.cwd`), so each ACP session's
|
||||
* agent's per-session workspace (`exec.agent.session.header.cwd`), so each session's
|
||||
* `read`/`write`/`edit` act on ITS workspace, not the server's launch dir — mirroring how
|
||||
* `dsh-tool-bash` defaults a bash `workdir` to the session cwd.
|
||||
* Non-agent calls return `undefined`, leaving the fallback in the provider rather than reading
|
||||
|
||||
@@ -125,9 +125,8 @@ export function applyWriteTool(ctx: Context, sandbox: FsSandboxSurface): void {
|
||||
after: outcome.after,
|
||||
}
|
||||
},
|
||||
// Pure display: a diff card (an editor renders write as a new-file / full- replace diff).
|
||||
// `oldText: null` — a call-time presenter has no access to the file's prior content, so
|
||||
// even an overwrite renders new-file style, matching claude-agent-acp.
|
||||
// Pure display: a diff card. A call-time presenter has no access to prior
|
||||
// file content, so `oldText: null` also represents an overwrite here.
|
||||
presentCall(args): DiffCallView {
|
||||
return {
|
||||
card: 'diff',
|
||||
@@ -136,10 +135,9 @@ export function applyWriteTool(ctx: Context, sandbox: FsSandboxSurface): void {
|
||||
locations: [{ path: args.file_path }],
|
||||
}
|
||||
},
|
||||
// Result-time display: a `diff` card so the completed `tool_call_update` re-installs the
|
||||
// diff rather than the model-facing result text (an ACP `tool_call_update.content` REPLACES
|
||||
// the call's content, so a text result would clobber the pending diff card). Overwrites use
|
||||
// applied metadata; creates and identical overwrites use the replay-safe args fallback.
|
||||
// Result-time display repeats the diff because completed views replace the
|
||||
// pending view. Overwrites use applied metadata; creates and identical
|
||||
// overwrites use the replay-safe args fallback.
|
||||
presentResult(args, result: ToolResult): DiffResultView | undefined {
|
||||
if (result.isError) return undefined
|
||||
const diffs = diffsFromMeta(result.meta)
|
||||
|
||||
Reference in New Issue
Block a user