Publish an IntentSpec JSON sample and round-trip test
ci / vet-and-test (pull_request) Successful in 18s
ci / docker-checkout-hostgateway (pull_request) Successful in 0s

Why: the intent library has to publish the shape it owns, without sharing a Go type with the other libraries.
Evidence: GOWORK=off go test -count=1 ./schema/ ./intent/ passed.
Impact: schema/ is new. Recognition behavior is unchanged.
Refs: D1
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-03 13:40:26 +00:00
co-authored by Cursor
parent 3bf228f4c0
commit 65aaebca1e
2 changed files with 35 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
{"id":"demo.write","domain":"demo","version":1,"matcher":{"includes_any":["写"]}}
+34
View File
@@ -0,0 +1,34 @@
package schema
import (
"encoding/json"
"os"
"testing"
"agent-intent/intent"
)
func TestIntentSpecRoundTrip(t *testing.T) {
raw, err := os.ReadFile("intentspec.sample.json")
if err != nil {
t.Fatal(err)
}
var spec intent.IntentSpec
if err := json.Unmarshal(raw, &spec); err != nil {
t.Fatal(err)
}
if spec.ID != "demo.write" || spec.Matcher.IncludesAny[0] != "写" {
t.Fatalf("%+v", spec)
}
back, err := json.Marshal(spec)
if err != nil {
t.Fatal(err)
}
var again intent.IntentSpec
if err := json.Unmarshal(back, &again); err != nil {
t.Fatal(err)
}
if again.ID != spec.ID || again.Version != 1 {
t.Fatalf("%+v", again)
}
}