Skip to content

Commit 00b11a2

Browse files
authored
Merge branch 'main' into ai-agents-docs-be09
2 parents 0b05e6b + ee2c4b4 commit 00b11a2

88 files changed

Lines changed: 2174 additions & 1336 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ jobs:
2121
go-version-file: go.mod
2222
cache: true
2323

24+
- name: Check for typos
25+
uses: crate-ci/typos@631208b7aac2daa8b707f55e7331f9112b0e062d # v1.44.0
26+
with:
27+
config: .github/workflows/typos.toml
28+
29+
- name: Lint
30+
run: make lint
31+
2432
- name: Run tests
2533
run: make test
2634

.github/workflows/typos.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[default]
2+
extend-ignore-re = ["(#|//)\\s*spellchecker:ignore-next-line\\n.*"]
3+
4+
[default.extend-words]
5+
trialer = "trialer"
6+
7+
[files]
8+
extend-exclude = [
9+
"go.sum",
10+
"go.mod",
11+
# Fixtures contain truncated streaming chunks that look like typos
12+
"fixtures/**",
13+
# Test files contain hashes and redacted values that look like typos
14+
"**/*_test.go",
15+
]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
# Project specific
77
example/aibridge.db
88
AGENTS.local.md
9+
build/

.golangci.yaml

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
# Based on the Coder repo lint profile, trimmed to the checks that make sense
2+
# for the standalone aibridge module.
3+
4+
linters-settings:
5+
dupl:
6+
threshold: 412
7+
8+
exhaustruct:
9+
include:
10+
- 'httpmw\.\w+'
11+
12+
gocognit:
13+
min-complexity: 300
14+
15+
goconst:
16+
min-len: 4
17+
min-occurrences: 3
18+
19+
gocritic:
20+
enabled-checks:
21+
- badLock
22+
- badRegexp
23+
- boolExprSimplify
24+
- builtinShadowDecl
25+
- commentedOutImport
26+
- deferUnlambda
27+
- dupImport
28+
- emptyFallthrough
29+
- hexLiteral
30+
- indexAlloc
31+
- initClause
32+
- methodExprCall
33+
- nilValReturn
34+
- regexpPattern
35+
- ruleguard
36+
- sortSlice
37+
- sprintfQuotedString
38+
- sqlQuery
39+
- truncateCmp
40+
- typeAssertChain
41+
- weakCond
42+
settings:
43+
ruleguard:
44+
failOn: all
45+
rules: "${configDir}/scripts/rules.go"
46+
47+
staticcheck:
48+
checks: ["all", "-SA1019"]
49+
50+
goimports:
51+
local-prefixes: coder.com,cdr.dev,go.coder.com,github.com/cdr,github.com/coder
52+
53+
importas:
54+
no-unaliased: true
55+
56+
misspell:
57+
locale: US
58+
ignore-words:
59+
- trialer
60+
61+
nestif:
62+
min-complexity: 20
63+
64+
revive:
65+
ignore-generated-header: true
66+
severity: warning
67+
rules:
68+
- name: atomic
69+
- name: bare-return
70+
- name: blank-imports
71+
- name: bool-literal-in-expr
72+
- name: call-to-gc
73+
- name: confusing-naming
74+
- name: confusing-results
75+
- name: constant-logical-expr
76+
- name: context-as-argument
77+
- name: context-keys-type
78+
- name: deep-exit
79+
- name: defer
80+
- name: dot-imports
81+
- name: duplicated-imports
82+
- name: early-return
83+
- name: empty-block
84+
- name: empty-lines
85+
- name: error-naming
86+
- name: error-return
87+
- name: error-strings
88+
- name: errorf
89+
- name: exported
90+
- name: flag-parameter
91+
- name: get-return
92+
- name: identical-branches
93+
- name: if-return
94+
- name: import-shadowing
95+
- name: increment-decrement
96+
- name: indent-error-flow
97+
- name: modifies-value-receiver
98+
- name: package-comments
99+
- name: range
100+
- name: receiver-naming
101+
- name: redefines-builtin-id
102+
- name: string-of-int
103+
- name: struct-tag
104+
- name: superfluous-else
105+
- name: time-naming
106+
- name: unconditional-recursion
107+
- name: unexported-naming
108+
- name: unexported-return
109+
- name: unhandled-error
110+
- name: unnecessary-stmt
111+
- name: unreachable-code
112+
- name: unused-parameter
113+
exclude: "**/*_test.go"
114+
- name: unused-receiver
115+
- name: var-declaration
116+
- name: var-naming
117+
- name: waitgroup-by-value
118+
119+
usetesting:
120+
os-setenv: true
121+
os-create-temp: false
122+
os-mkdir-temp: false
123+
os-temp-dir: false
124+
os-chdir: false
125+
context-background: false
126+
context-todo: false
127+
128+
govet:
129+
disable:
130+
- loopclosure
131+
132+
gosec:
133+
excludes:
134+
- G601
135+
136+
issues:
137+
fix: true
138+
139+
exclude-dirs:
140+
- .git
141+
142+
exclude-files:
143+
- scripts/rules.go
144+
145+
exclude-rules:
146+
- path: _test\.go
147+
linters:
148+
- errcheck
149+
- forcetypeassert
150+
- exhaustruct
151+
- path: scripts/*
152+
linters:
153+
- exhaustruct
154+
- path: scripts/rules.go
155+
linters:
156+
- ALL
157+
158+
max-issues-per-linter: 0
159+
max-same-issues: 0
160+
161+
run:
162+
timeout: 10m
163+
164+
linters:
165+
disable-all: true
166+
enable:
167+
- asciicheck
168+
- bidichk
169+
- bodyclose
170+
- dogsled
171+
- errcheck
172+
- errname
173+
- errorlint
174+
- exhaustruct
175+
- forcetypeassert
176+
- gocognit
177+
- gocritic
178+
- goimports
179+
- gomodguard
180+
- gosec
181+
- gosimple
182+
- govet
183+
- importas
184+
- ineffassign
185+
- makezero
186+
- misspell
187+
- nestif
188+
- nilnil
189+
- noctx
190+
- paralleltest
191+
- revive
192+
- staticcheck
193+
- testpackage
194+
- tparallel
195+
- typecheck
196+
- unconvert
197+
- unused
198+
- usetesting
199+
- dupl

Makefile

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Use a single bash shell for each job, and immediately exit on failure
2-
.SHELL := /usr/bin/env bash
2+
SHELL := bash
33
.SHELLFLAGS := -ceu
44
.ONESHELL:
55

@@ -13,6 +13,43 @@ ifndef VERBOSE
1313
.SILENT:
1414
endif
1515

16+
SHELL_SRC_FILES := $(shell find . -type f -name '*.sh' -not -path '*/.git/*')
17+
GOLANGCI_LINT_VERSION ?= 1.64.8
18+
PARALLELTESTCTX_VERSION ?= 0.0.1
19+
20+
lint: lint/shellcheck lint/go lint/typos
21+
.PHONY: lint
22+
23+
lint/go:
24+
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v$(GOLANGCI_LINT_VERSION) run
25+
go run github.com/coder/paralleltestctx/cmd/paralleltestctx@v$(PARALLELTESTCTX_VERSION) -custom-funcs="testutil.Context" ./...
26+
.PHONY: lint/go
27+
28+
TYPOS_VERSION := $(shell grep -oP 'crate-ci/typos@\S+\s+\#\s+v\K[0-9.]+' .github/workflows/ci.yml)
29+
TYPOS_ARCH := $(shell uname -m)
30+
ifeq ($(shell uname -s),Darwin)
31+
TYPOS_OS := apple-darwin
32+
else
33+
TYPOS_OS := unknown-linux-musl
34+
endif
35+
36+
build/typos-$(TYPOS_VERSION):
37+
mkdir -p build/
38+
curl -sSfL "https://github.com/crate-ci/typos/releases/download/v$(TYPOS_VERSION)/typos-v$(TYPOS_VERSION)-$(TYPOS_ARCH)-$(TYPOS_OS).tar.gz" \
39+
| tar -xzf - -C build/ ./typos
40+
mv build/typos "$@"
41+
42+
lint/typos: build/typos-$(TYPOS_VERSION)
43+
build/typos-$(TYPOS_VERSION) --config .github/workflows/typos.toml
44+
.PHONY: lint/typos
45+
46+
lint/shellcheck:
47+
if test -n "$(strip $(SHELL_SRC_FILES))"; then \
48+
echo "--- shellcheck"; \
49+
shellcheck --external-sources $(SHELL_SRC_FILES); \
50+
fi
51+
.PHONY: lint/shellcheck
52+
1653
test:
1754
go test -count=1 ./...
1855

@@ -48,4 +85,4 @@ endif
4885
.PHONY: fmt/go
4986

5087
mocks: mcp/api.go
51-
go generate ./mcpmock/
88+
go generate ./mcpmock/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ See [example/](example/) for a complete runnable example with SQLite persistence
118118
5. **Test with Claude Code**:
119119
Claude Code allows a base URL override via `ANTHROPIC_BASE_URL`.
120120

121-
![image with cloude code example](example/claude-code.png)
121+
![image with claude code example](example/claude-code.png)
122122

123123
## Supported Routes
124124

api.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ package aibridge
33
import (
44
"context"
55

6+
"github.com/prometheus/client_golang/prometheus"
7+
"go.opentelemetry.io/otel/trace"
8+
69
"cdr.dev/slog/v3"
710
"github.com/coder/aibridge/config"
811
aibcontext "github.com/coder/aibridge/context"
912
"github.com/coder/aibridge/metrics"
1013
"github.com/coder/aibridge/provider"
1114
"github.com/coder/aibridge/recorder"
12-
"github.com/prometheus/client_golang/prometheus"
13-
"go.opentelemetry.io/otel/trace"
1415
)
1516

1617
// Const + Type + function aliases for backwards compatibility.
@@ -61,5 +62,5 @@ func NewMetrics(reg prometheus.Registerer) *metrics.Metrics {
6162
}
6263

6364
func NewRecorder(logger slog.Logger, tracer trace.Tracer, clientFn func() (Recorder, error)) Recorder {
64-
return recorder.NewRecorder(logger, tracer, clientFn)
65+
return recorder.NewWrappedRecorder(logger, tracer, clientFn)
6566
}

0 commit comments

Comments
 (0)