fix(opencode): omit empty apply patch move path (#45329)
This commit is contained in:
parent
5c5c709fee
commit
f7da00f35e
2 changed files with 22 additions and 2 deletions
|
|
@ -198,7 +198,7 @@ export const ApplyPatchTool = Tool.define(
|
|||
patch: change.diff,
|
||||
additions: change.additions,
|
||||
deletions: change.deletions,
|
||||
movePath: change.movePath,
|
||||
...(change.movePath ? { movePath: change.movePath } : {}),
|
||||
}))
|
||||
|
||||
// Check permissions if needed
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import { describe, expect } from "bun:test"
|
||||
import path from "path"
|
||||
import * as fs from "fs/promises"
|
||||
import { PermissionV1 } from "@opencode-ai/core/v1/permission"
|
||||
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
|
||||
import { Cause, Effect, Exit, Layer } from "effect"
|
||||
import { Cause, Effect, Exit, Layer, Schema } from "effect"
|
||||
import { ApplyPatchTool } from "../../src/tool/apply_patch"
|
||||
import { LSP } from "@/lsp/lsp"
|
||||
import { FSUtil } from "@opencode-ai/core/fs-util"
|
||||
|
|
@ -107,6 +108,25 @@ describe("tool.apply_patch freeform", () => {
|
|||
}),
|
||||
)
|
||||
|
||||
it.instance(
|
||||
"produces JSON-encodable permission metadata",
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const { ctx, calls } = makeCtx()
|
||||
yield* execute({ patchText: "*** Begin Patch\n*** Add File: new.txt\n+created\n*** End Patch" }, ctx)
|
||||
|
||||
expect(() => {
|
||||
const request = Schema.encodeUnknownSync(PermissionV1.Request)({
|
||||
id: PermissionV1.ID.ascending(),
|
||||
sessionID: baseCtx.sessionID,
|
||||
...calls[0],
|
||||
})
|
||||
Schema.encodeUnknownSync(Schema.Json)(request)
|
||||
}).not.toThrow()
|
||||
}),
|
||||
{ git: true },
|
||||
)
|
||||
|
||||
it.instance(
|
||||
"applies add/update/delete in one patch",
|
||||
() =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue