Why: native must compile without agent-intent, and the two execution packages were the same contract under two names. Evidence: GOWORK=off go test -count=1 ./... passed, including schema.TestRequestAndResultRoundTrip and the native adapter tests after Options was split into embedded sub-structs. Impact: adapters/intentgate is gone, go.mod no longer requires agent-intent, and the nested gitlink stays for the release task. Callers of Options composite literals name the sub-struct. Refs: D1 Co-authored-by: Cursor <cursoragent@cursor.com>
56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
package schema
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"agent-native/exec"
|
|
)
|
|
|
|
func TestRequestAndResultRoundTrip(t *testing.T) {
|
|
reqRaw, err := os.ReadFile(filepath.Join("request.sample.json"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var req exec.Request
|
|
if err := json.Unmarshal(reqRaw, &req); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if req.Prompt != "写一份说明" || req.ToolProfile != exec.ToolProfileWorkspace {
|
|
t.Fatalf("%+v", req)
|
|
}
|
|
back, err := json.Marshal(req)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var again exec.Request
|
|
if err := json.Unmarshal(back, &again); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if again.Prompt != req.Prompt || len(again.Targets) != 1 {
|
|
t.Fatalf("%+v", again)
|
|
}
|
|
|
|
resRaw, err := os.ReadFile("result.sample.json")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var res exec.Result
|
|
if err := json.Unmarshal(resRaw, &res); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !res.Success || string(res.Patches["output.md"]) != "demo" {
|
|
t.Fatalf("%+v", res)
|
|
}
|
|
out, err := json.Marshal(res)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !bytes.Contains(out, []byte(`"success":true`)) {
|
|
t.Fatalf("%s", out)
|
|
}
|
|
}
|