Skip to content

Commit b0eb5c4

Browse files
authored
Merge pull request #25 from GrayCodeAI/chore/sync-quality-hardening-and-codegen
chore(sync): quality-hardening + SDK codegen tools, resolution logic, deps and tests
2 parents 15d0e89 + 9dd572a commit b0eb5c4

15 files changed

Lines changed: 599 additions & 28 deletions

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ GOLANGCI := $(GOBIN_DIR)/golangci-lint
2323
GOFUMPT := $(GOBIN_DIR)/gofumpt
2424
GOIMPORTS := $(GOBIN_DIR)/goimports
2525
GOVULNCHECK := $(GOBIN_DIR)/govulncheck
26+
OAPICODEGEN := $(GOBIN_DIR)/oapi-codegen
2627

2728
# ---------------------------------------------------------------------------
2829
# Phony declarations (alphabetical).
2930
# ---------------------------------------------------------------------------
30-
.PHONY: all bench boundary-guard build ci clean cover fmt help lint lint-fix \
31+
.PHONY: all bench boundary-guard build ci clean cover fmt gen help lint lint-fix \
3132
security test test-10x test-race tidy version vet
3233

3334
# ---------------------------------------------------------------------------
@@ -96,7 +97,7 @@ tidy: ## Tidy go.mod / go.sum.
9697
# ---------------------------------------------------------------------------
9798
# Composite gate used by CI and pre-push.
9899
# ---------------------------------------------------------------------------
99-
ci: tidy fmt vet boundary-guard lint test-race security ## Run everything CI runs.
100+
ci: tidy gen fmt vet boundary-guard lint test-race security ## Run everything CI runs.
100101
@echo "All CI checks passed."
101102

102103
# ---------------------------------------------------------------------------
@@ -107,6 +108,10 @@ version: ## Print the version that will be embedded.
107108
@echo "Commit: $(COMMIT)"
108109
@echo "Date: $(DATE)"
109110

111+
gen: ## Generate code from the OpenAPI spec (requires oapi-codegen).
112+
go generate ./internal/spec/
113+
@echo "Code generation complete."
114+
110115
clean: ## Remove build artefacts.
111116
rm -rf coverage.out coverage.html
112117
go clean -testcache

agent_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func TestAgent_ChatWithTools(t *testing.T) {
5555
json.NewEncoder(w).Encode(ChatWithToolsResponse{
5656
ChatResponse: ChatResponse{SessionID: "s-tools"},
5757
ToolCalls: []ToolCall{
58-
{ID: "tc-1", Name: "greet", Arguments: `{"name":"world"}`},
58+
{ID: "tc-1", Name: "greet", Arguments: map[string]interface{}{"name": "world"}},
5959
},
6060
})
6161
} else {
@@ -80,9 +80,10 @@ func TestAgent_ChatWithTools(t *testing.T) {
8080
Description: "Greets someone",
8181
Parameters: json.RawMessage(`{"type":"object","properties":{"name":{"type":"string"}}}`),
8282
},
83-
Run: func(ctx context.Context, args string) (string, error) {
83+
Run: func(ctx context.Context, args map[string]interface{}) (string, error) {
8484
var p struct{ Name string }
85-
json.Unmarshal([]byte(args), &p)
85+
b, _ := json.Marshal(args)
86+
json.Unmarshal(b, &p)
8687
return "Hello, " + p.Name + "!", nil
8788
},
8889
},

benchmark_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func BenchmarkChatWithTools(b *testing.B) {
258258
if round%2 == 1 {
259259
json.NewEncoder(w).Encode(ChatWithToolsResponse{
260260
ChatResponse: ChatResponse{SessionID: "s-1", Response: ""},
261-
ToolCalls: []ToolCall{{ID: "tc-1", Name: "echo", Arguments: `{"msg":"hi"}`}},
261+
ToolCalls: []ToolCall{{ID: "tc-1", Name: "echo", Arguments: map[string]interface{}{"msg": "hi"}}},
262262
FinishReason: "tool_calls",
263263
})
264264
} else {
@@ -274,7 +274,7 @@ func BenchmarkChatWithTools(b *testing.B) {
274274
tools := []Tool{
275275
{
276276
Schema: ToolSchema{Name: "echo", Description: "echo", Parameters: json.RawMessage(`{"type":"object"}`)},
277-
Run: func(_ context.Context, args string) (string, error) { return "echoed", nil },
277+
Run: func(_ context.Context, args map[string]interface{}) (string, error) { return "echoed", nil },
278278
},
279279
}
280280
ctx := context.Background()

codegen_tools.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//go:build tools
2+
3+
package hawksdk
4+
5+
import (
6+
_ "github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen"
7+
)

go.mod

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)