xonecas.io
62159
Sy

symb / commit b3356e0

feat: local cache for web tools, redundant query protection

xonecas2026-02-13 b3356e0d326c795fb1f3bb39d51c21d15444450d parent 56193e3

10 files changed

This diff is too big to show in full. The first 1000 lines are below, and every file is listed with its counts.

README.md+24−1
@@ -23,6 +23,8 @@ Symb pairs you with an LLM, providing an agentic UI with tools the LLM can use t
2323 - **Clean aesthetic**: Dark grayscale with minimal distractions
2424 - **ELM architecture**: Built with BubbleTea for solid state management
2525 - **LLM integration**: Ollama local + Opencode Zen support
26+- **Hashline-assisted edits**: LLM edit operations use line hashes for precise, conflict-free file modifications
27+- **Web search**: Exa AI integration with configurable SQLite cache and content-aware redundant search prevention
2628
2729 ## Quick Start
2830
@@ -39,7 +41,28 @@ make dev
3941
4042 ## Configuration
4143
42-Edit `config.toml` to configure LLM provider, editor settings, and UI preferences.
44+Edit `config.toml` to configure LLM providers, UI preferences, and cache settings:
45+
46+```toml
47+[providers.ollama-qwen]
48+endpoint = "http://localhost:11434"
49+model = "qwen3:8b"
50+temperature = 0.3
51+
52+[cache]
53+ttl_hours = 24 # how long web search/fetch results are cached
54+```
55+
56+API keys are stored separately in `~/.config/symb/credentials.json`:
57+
58+```json
59+{
60+ "providers": {
61+ "opencode_zen": { "api_key": "your-key" },
62+ "exa_ai": { "api_key": "your-exa-key" }
63+ }
64+}
65+```
4366
4467 ## Development
4568
cmd/symb/main.go+18−2
@@ -5,6 +5,7 @@ import (
55 "fmt"
66 "os"
77 "path/filepath"
8+ "time"
89
910 tea "github.com/charmbracelet/bubbletea"
1011 "github.com/rs/zerolog"
@@ -13,6 +14,7 @@ import (
1314 "github.com/xonecas/symb/internal/mcp"
1415 "github.com/xonecas/symb/internal/mcp_tools"
1516 "github.com/xonecas/symb/internal/provider"
17+ "github.com/xonecas/symb/internal/store"
1618 "github.com/xonecas/symb/internal/tui"
1719 )
1820
@@ -105,9 +107,23 @@ func main() {
105107 editHandler := mcp_tools.NewEditHandler(fileTracker)
106108 proxy.RegisterTool(editTool, editHandler.Handle)
107109
108- // Register web tools (shared cache for fetch + search)
109- webCache := mcp_tools.NewWebCache()
110+ // Open web cache (SQLite-backed, persisted across sessions).
111+ // If data dir or db open fails, webCache stays nil — handlers degrade gracefully.
112+ var webCache *store.Cache
113+ if cacheDir, err := config.EnsureDataDir(); err != nil {
114+ fmt.Printf("Warning: cache dir failed: %v\n", err)
115+ } else {
116+ cacheTTL := time.Duration(cfg.Cache.CacheTTLOrDefault()) * time.Hour
117+ webCache, err = store.Open(filepath.Join(cacheDir, "cache.db"), cacheTTL)
118+ if err != nil {
119+ fmt.Printf("Warning: cache open failed: %v\n", err)
120+ }
121+ }
122+ if webCache != nil {
123+ defer webCache.Close()
124+ }
110125
126+ // Register web tools
111127 webFetchTool := mcp_tools.NewWebFetchTool()
112128 webFetchHandler := mcp_tools.MakeWebFetchHandler(webCache)
113129 proxy.RegisterTool(webFetchTool, webFetchHandler)
config.toml+3−0
@@ -51,5 +51,8 @@ theme = "molokai"
5151 split_ratio = 0.5
5252 syntax_theme = "monokai"
5353
54+[cache]
55+ttl_hours = 24
56+
5457 [git]
5558 enable_sandbox = false
go.mod+9−0
@@ -14,6 +14,7 @@ require (
1414 github.com/rs/zerolog v1.34.0
1515 github.com/sashabaranov/go-openai v1.41.2
1616 golang.org/x/net v0.50.0
17+ modernc.org/sqlite v1.45.0
1718 )
1819
1920 require (
@@ -26,7 +27,9 @@ require (
2627 github.com/clipperhouse/stringish v0.1.1 // indirect
2728 github.com/clipperhouse/uax29/v2 v2.5.0 // indirect
2829 github.com/dlclark/regexp2 v1.11.5 // indirect
30+ github.com/dustin/go-humanize v1.0.1 // indirect
2931 github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
32+ github.com/google/uuid v1.6.0 // indirect
3033 github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
3134 github.com/mattn/go-colorable v0.1.13 // indirect
3235 github.com/mattn/go-isatty v0.0.20 // indirect
@@ -35,8 +38,14 @@ require (
3538 github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
3639 github.com/muesli/cancelreader v0.2.2 // indirect
3740 github.com/muesli/termenv v0.16.0 // indirect
41+ github.com/ncruces/go-strftime v1.0.0 // indirect
42+ github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
3843 github.com/rivo/uniseg v0.4.7 // indirect
3944 github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
45+ golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect
4046 golang.org/x/sys v0.41.0 // indirect
4147 golang.org/x/text v0.34.0 // indirect
48+ modernc.org/libc v1.67.6 // indirect
49+ modernc.org/mathutil v1.7.1 // indirect
50+ modernc.org/memory v1.11.0 // indirect
4251 )
go.sum+48−2
@@ -37,9 +37,17 @@ github.com/clipperhouse/uax29/v2 v2.5.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsV
3737 github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
3838 github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ=
3939 github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
40+github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
41+github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
4042 github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
4143 github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
4244 github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
45+github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
46+github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
47+github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
48+github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
49+github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
50+github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
4351 github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
4452 github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
4553 github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag=
@@ -60,7 +68,11 @@ github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELU
6068 github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
6169 github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
6270 github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
71+github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
72+github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
6373 github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
74+github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
75+github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
6476 github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
6577 github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
6678 github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
@@ -70,10 +82,14 @@ github.com/sashabaranov/go-openai v1.41.2 h1:vfPRBZNMpnqu8ELsclWcAvF19lDNgh1t6TV
7082 github.com/sashabaranov/go-openai v1.41.2/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
7183 github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
7284 github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
73-golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
74-golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
85+golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2wtOnGAHZWCHUM4KGzY=
86+golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
87+golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c=
88+golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU=
7589 golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=
7690 golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM=
91+golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
92+golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
7793 golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
7894 golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
7995 golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -82,3 +98,33 @@ golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
8298 golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
8399 golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=
84100 golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
101+golang.org/x/tools v0.41.0 h1:a9b8iMweWG+S0OBnlU36rzLp20z1Rp10w+IY2czHTQc=
102+golang.org/x/tools v0.41.0/go.mod h1:XSY6eDqxVNiYgezAVqqCeihT4j1U2CCsqvH3WhQpnlg=
103+modernc.org/cc/v4 v4.27.1 h1:9W30zRlYrefrDV2JE2O8VDtJ1yPGownxciz5rrbQZis=
104+modernc.org/cc/v4 v4.27.1/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
105+modernc.org/ccgo/v4 v4.30.1 h1:4r4U1J6Fhj98NKfSjnPUN7Ze2c6MnAdL0hWw6+LrJpc=
106+modernc.org/ccgo/v4 v4.30.1/go.mod h1:bIOeI1JL54Utlxn+LwrFyjCx2n2RDiYEaJVSrgdrRfM=
107+modernc.org/fileutil v1.3.40 h1:ZGMswMNc9JOCrcrakF1HrvmergNLAmxOPjizirpfqBA=
108+modernc.org/fileutil v1.3.40/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc=
109+modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
110+modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
111+modernc.org/gc/v3 v3.1.1 h1:k8T3gkXWY9sEiytKhcgyiZ2L0DTyCQ/nvX+LoCljoRE=
112+modernc.org/gc/v3 v3.1.1/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
113+modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
114+modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
115+modernc.org/libc v1.67.6 h1:eVOQvpModVLKOdT+LvBPjdQqfrZq+pC39BygcT+E7OI=
116+modernc.org/libc v1.67.6/go.mod h1:JAhxUVlolfYDErnwiqaLvUqc8nfb2r6S6slAgZOnaiE=
117+modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
118+modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
119+modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
120+modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
121+modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
122+modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
123+modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
124+modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
125+modernc.org/sqlite v1.45.0 h1:r51cSGzKpbptxnby+EIIz5fop4VuE4qFoVEjNvWoObs=
126+modernc.org/sqlite v1.45.0/go.mod h1:CzbrU2lSB1DKUusvwGz7rqEKIq+NUd8GWuBBZDs9/nA=
127+modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
128+modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
129+modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
130+modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
internal/config/config.go+14−0
@@ -16,6 +16,20 @@ type Config struct {
1616 DefaultProvider string `toml:"default_provider"`
1717 Providers map[string]ProviderConfig `toml:"providers"`
1818 MCP MCPConfig `toml:"mcp"`
19+ Cache CacheConfig `toml:"cache"`
20+}
21+
22+// CacheConfig holds web cache settings.
23+type CacheConfig struct {
24+ TTLHours int `toml:"ttl_hours"`
25+}
26+
27+// CacheTTLOrDefault returns the configured TTL or 24 hours if unset.
28+func (c CacheConfig) CacheTTLOrDefault() int {
29+ if c.TTLHours <= 0 {
30+ return 24
31+ }
32+ return c.TTLHours
1933 }
2034
2135 // ProviderConfig holds LLM provider settings.
internal/mcp_tools/web.go+25−62
@@ -8,59 +8,17 @@ import (
88 "io"
99 "net/http"
1010 "strings"
11- "sync"
1211 "time"
1312
1413 "github.com/rs/zerolog/log"
1514 "github.com/xonecas/symb/internal/mcp"
15+ "github.com/xonecas/symb/internal/store"
1616 "golang.org/x/net/html"
1717 )
1818
19-// cacheTTL is how long cached entries remain fresh.
20-const cacheTTL = 24 * time.Hour
21-
22-// cacheEntry stores a cached result with its timestamp.
23-type cacheEntry struct {
24- result string
25- createdAt time.Time
26-}
27-
2819 // noSearchResults is the message returned when no search results are found.
2920 const noSearchResults = "No results found."
3021
31-// WebCache is a shared in-memory cache for WebFetch and WebSearch results.
32-type WebCache struct {
33- mu sync.RWMutex
34- entries map[string]cacheEntry
35-}
36-
37-func newWebCache() *WebCache {
38- return &WebCache{entries: make(map[string]cacheEntry)}
39-}
40-
41-// get returns the cached value and true if it exists and is fresh.
42-func (c *WebCache) get(key string) (string, bool) {
43- c.mu.RLock()
44- defer c.mu.RUnlock()
45-
46- entry, ok := c.entries[key]
47- if !ok {
48- return "", false
49- }
50- if time.Since(entry.createdAt) > cacheTTL {
51- return "", false
52- }
53- return entry.result, true
54-}
55-
56-// set stores a value in the cache.
57-func (c *WebCache) set(key, result string) {
58- c.mu.Lock()
59- defer c.mu.Unlock()
60-
61- c.entries[key] = cacheEntry{result: result, createdAt: time.Now()}
62-}
63-
6422 // --- WebFetch ---
6523
6624 // WebFetchArgs represents arguments for the WebFetch tool.
@@ -90,13 +48,13 @@ func NewWebFetchTool() mcp.Tool {
9048
9149 return mcp.Tool{
9250 Name: "WebFetch",
93- Description: "Fetch a URL and return its content as cleaned text (HTML tags, scripts, and styles stripped). Cached for 24 hours.",
51+ Description: "Fetch a URL and return its content as cleaned text (HTML tags, scripts, and styles stripped). Results are cached.",
9452 InputSchema: schemaJSON,
9553 }
9654 }
9755
9856 // MakeWebFetchHandler creates a handler for the WebFetch tool.
99-func MakeWebFetchHandler(cache *WebCache) mcp.ToolHandler {
57+func MakeWebFetchHandler(cache *store.Cache) mcp.ToolHandler {
10058 client := &http.Client{Timeout: 15 * time.Second}
10159
10260 return func(ctx context.Context, arguments json.RawMessage) (*mcp.ToolResult, error) {
@@ -112,8 +70,8 @@ func MakeWebFetchHandler(cache *WebCache) mcp.ToolHandler {
11270 args.MaxChars = 10000
11371 }
11472
115- // Check cache (keyed by raw URL).
116- if cached, ok := cache.get(args.URL); ok {
73+ // Check cache (keyed by URL).
74+ if cached, ok := cache.GetFetch(args.URL); ok {
11775 log.Debug().Str("url", args.URL).Msg("WebFetch cache hit")
11876 return toolText(truncate(cached, args.MaxChars)), nil
11977 }
@@ -149,7 +107,7 @@ func MakeWebFetchHandler(cache *WebCache) mcp.ToolHandler {
149107 text = string(body)
150108 }
151109
152- cache.set(args.URL, text)
110+ cache.SetFetch(args.URL, text)
153111 return toolText(truncate(text, args.MaxChars)), nil
154112 }
155113 }
@@ -224,7 +182,7 @@ func NewWebSearchTool() mcp.Tool {
224182
225183 return mcp.Tool{
226184 Name: "WebSearch",
227- Description: "Search the web using Exa AI. Use this to look up documentation, APIs, libraries, or current information. Cached for 24 hours.",
185+ Description: "Search the web using Exa AI. Use this to look up documentation, APIs, libraries, or current information. Results are cached.",
228186 InputSchema: schemaJSON,
229187 }
230188 }
@@ -233,7 +191,7 @@ const exaDefaultEndpoint = "https://api.exa.ai/search"
233191
234192 // MakeWebSearchHandler creates a handler for the WebSearch tool.
235193 // endpoint is the Exa API URL; pass "" to use the default (https://api.exa.ai/search).
236-func MakeWebSearchHandler(cache *WebCache, apiKey, endpoint string) mcp.ToolHandler {
194+func MakeWebSearchHandler(cache *store.Cache, apiKey, endpoint string) mcp.ToolHandler {
237195 if endpoint == "" {
238196 endpoint = exaDefaultEndpoint
239197 }
@@ -258,12 +216,22 @@ func MakeWebSearchHandler(cache *WebCache, apiKey, endpoint string) mcp.ToolHand
258216 args.Type = "auto"
259217 }
260218
261- // Check cache (keyed by normalized query + params).
262- cacheKey := fmt.Sprintf("search:%s:n=%d:t=%s:d=%s",
263- strings.ToLower(strings.TrimSpace(args.Query)),
264- args.NumResults, args.Type, strings.Join(args.IncludeDomains, ","))
265- if cached, ok := cache.get(cacheKey); ok {
266- log.Debug().Str("query", args.Query).Msg("WebSearch cache hit")
219+ // Build exact cache key including params so different num_results/type
220+ // don't return wrong cached results.
221+ exactKey := fmt.Sprintf("%s|n=%d|t=%s|d=%s",
222+ args.Query, args.NumResults, args.Type,
223+ strings.Join(args.IncludeDomains, ","))
224+
225+ // Check exact cache hit first (query + params).
226+ if cached, ok := cache.GetSearch(exactKey); ok {
227+ log.Debug().Str("query", args.Query).Msg("WebSearch exact cache hit")
228+ return toolText(cached), nil
229+ }
230+
231+ // Search cached result content for query keywords — avoids API call
232+ // if the answer already exists in a previously cached result.
233+ if cached, ok := cache.SearchCachedContent(args.Query); ok {
234+ log.Debug().Str("query", args.Query).Msg("WebSearch content cache hit")
267235 return toolText(cached), nil
268236 }
269237
@@ -310,16 +278,11 @@ func MakeWebSearchHandler(cache *WebCache, apiKey, endpoint string) mcp.ToolHand
310278 }
311279
312280 result := formatSearchResults(exaResp.Results)
313- cache.set(cacheKey, result)
281+ cache.SetSearch(exactKey, result)
314282 return toolText(result), nil
315283 }
316284 }
317285
318-// NewWebCache creates a shared cache for web tools.
319-func NewWebCache() *WebCache {
320- return newWebCache()
321-}
322-
323286 // --- Helpers ---
324287
325288 // formatSearchResults formats Exa results into readable text.
internal/mcp_tools/web_test.go+19−40
@@ -5,40 +5,22 @@ import (
55 "encoding/json"
66 "net/http"
77 "net/http/httptest"
8+ "path/filepath"
89 "testing"
910 "time"
10-)
11-
12-func TestWebCache_GetSet(t *testing.T) {
13- c := NewWebCache()
14-
15- // Miss on empty cache.
16- if _, ok := c.get("key"); ok {
17- t.Fatal("expected cache miss")
18- }
19-
20- // Set and hit.
21- c.set("key", "value")
22- v, ok := c.get("key")
23- if !ok || v != "value" {
24- t.Fatalf("expected cache hit with 'value', got %q ok=%v", v, ok)
25- }
26-}
27-
28-func TestWebCache_Expiry(t *testing.T) {
29- c := NewWebCache()
30- c.set("key", "value")
3111
32- // Manually backdate the entry.
33- c.mu.Lock()
34- e := c.entries["key"]
35- e.createdAt = time.Now().Add(-25 * time.Hour)
36- c.entries["key"] = e
37- c.mu.Unlock()
12+ "github.com/xonecas/symb/internal/store"
13+)
3814
39- if _, ok := c.get("key"); ok {
40- t.Fatal("expected cache miss for stale entry")
15+func testCache(t *testing.T) *store.Cache {
16+ t.Helper()
17+ dbPath := filepath.Join(t.TempDir(), "test.db")
18+ c, err := store.Open(dbPath, 24*time.Hour)
19+ if err != nil {
20+ t.Fatalf("failed to open test cache: %v", err)
4121 }
22+ t.Cleanup(func() { c.Close() })
23+ return c
4224 }
4325
4426 func TestExtractText(t *testing.T) {
@@ -62,7 +44,6 @@ func TestExtractText(t *testing.T) {
6244 }
6345
6446 func TestExtractText_PlainText(t *testing.T) {
65- // No HTML at all — should pass through.
6647 text := extractText([]byte("just plain text"))
6748 if text != "just plain text" {
6849 t.Errorf("expected plain passthrough, got %q", text)
@@ -95,7 +76,7 @@ func TestWebFetchHandler_HTML(t *testing.T) {
9576 }))
9677 defer srv.Close()
9778
98- cache := NewWebCache()
79+ cache := testCache(t)
9980 handler := MakeWebFetchHandler(cache)
10081
10182 args, _ := json.Marshal(WebFetchArgs{URL: srv.URL})
@@ -124,7 +105,7 @@ func TestWebFetchHandler_PlainText(t *testing.T) {
124105 }))
125106 defer srv.Close()
126107
127- cache := NewWebCache()
108+ cache := testCache(t)
128109 handler := MakeWebFetchHandler(cache)
129110
130111 args, _ := json.Marshal(WebFetchArgs{URL: srv.URL})
@@ -143,7 +124,7 @@ func TestWebFetchHandler_Error(t *testing.T) {
143124 }))
144125 defer srv.Close()
145126
146- cache := NewWebCache()
127+ cache := testCache(t)
147128 handler := MakeWebFetchHandler(cache)
148129
149130 args, _ := json.Marshal(WebFetchArgs{URL: srv.URL})
@@ -154,7 +135,7 @@ func TestWebFetchHandler_Error(t *testing.T) {
154135 }
155136
156137 func TestWebFetchHandler_MissingURL(t *testing.T) {
157- cache := NewWebCache()
138+ cache := testCache(t)
158139 handler := MakeWebFetchHandler(cache)
159140
160141 args, _ := json.Marshal(WebFetchArgs{})
@@ -165,7 +146,7 @@ func TestWebFetchHandler_MissingURL(t *testing.T) {
165146 }
166147
167148 func TestWebSearchHandler_MissingKey(t *testing.T) {
168- cache := NewWebCache()
149+ cache := testCache(t)
169150 handler := MakeWebSearchHandler(cache, "", "")
170151
171152 args, _ := json.Marshal(WebSearchArgs{Query: "test"})
@@ -179,7 +160,7 @@ func TestWebSearchHandler_MissingKey(t *testing.T) {
179160 }
180161
181162 func TestWebSearchHandler_MissingQuery(t *testing.T) {
182- cache := NewWebCache()
163+ cache := testCache(t)
183164 handler := MakeWebSearchHandler(cache, "fake-key", "")
184165
185166 args, _ := json.Marshal(WebSearchArgs{})
@@ -191,13 +172,11 @@ func TestWebSearchHandler_MissingQuery(t *testing.T) {
191172
192173 func TestWebSearchHandler_Success(t *testing.T) {
193174 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
194- // Verify auth header.
195175 if r.Header.Get("x-api-key") != "test-key" {
196176 w.WriteHeader(http.StatusUnauthorized)
197177 return
198178 }
199179
200- // Verify request body.
201180 var req exaSearchRequest
202181 if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
203182 w.WriteHeader(http.StatusBadRequest)
@@ -215,7 +194,7 @@ func TestWebSearchHandler_Success(t *testing.T) {
215194 defer srv.Close()
216195
217196 t.Run("integration", func(t *testing.T) {
218- cache := NewWebCache()
197+ cache := testCache(t)
219198 handler := MakeWebSearchHandler(cache, "test-key", srv.URL)
220199
221200 args, _ := json.Marshal(WebSearchArgs{Query: "test query", NumResults: 2})
@@ -241,7 +220,7 @@ func TestWebSearchHandler_Success(t *testing.T) {
241220 })
242221
243222 t.Run("bad_auth", func(t *testing.T) {
244- cache := NewWebCache()
223+ cache := testCache(t)
245224 handler := MakeWebSearchHandler(cache, "wrong-key", srv.URL)
246225
247226 args, _ := json.Marshal(WebSearchArgs{Query: "test"})
internal/store/store.go+313−0
@@ -0,0 +1,313 @@
1+// Package store provides a SQLite-backed cache for web fetch and search results.
2+package store
3+
4+import (
5+ "database/sql"
6+ "fmt"
7+ "strings"
8+ "sync"
9+ "time"
10+
11+ "github.com/rs/zerolog/log"
12+ _ "modernc.org/sqlite" // register sqlite driver
13+)
14+
15+const schema = `
16+CREATE TABLE IF NOT EXISTS fetch_cache (
17+ url TEXT PRIMARY KEY,
18+ result TEXT NOT NULL,
19+ created INTEGER NOT NULL
20+);
21+
22+CREATE TABLE IF NOT EXISTS search_cache (
23+ query TEXT PRIMARY KEY,
24+ result TEXT NOT NULL,
25+ created INTEGER NOT NULL
26+);
27+
28+CREATE INDEX IF NOT EXISTS idx_fetch_created ON fetch_cache(created);
29+CREATE INDEX IF NOT EXISTS idx_search_created ON search_cache(created);
30+`
31+
32+// Cache is a SQLite-backed cache for web results.
33+type Cache struct {
34+ mu sync.Mutex
35+ db *sql.DB
36+ ttl time.Duration
37+}
38+
39+// Open creates or opens a cache database at the given path.
40+// ttl controls how long entries remain fresh.
41+func Open(dbPath string, ttl time.Duration) (*Cache, error) {
42+ db, err := sql.Open("sqlite", dbPath)
43+ if err != nil {
44+ return nil, fmt.Errorf("open cache db: %w", err)
45+ }
46+
47+ // SQLite pragmas for performance.
48+ for _, pragma := range []string{
49+ "PRAGMA journal_mode = WAL",
50+ "PRAGMA synchronous = NORMAL",
51+ "PRAGMA busy_timeout = 5000",
52+ } {
53+ if _, err := db.Exec(pragma); err != nil {
54+ db.Close()
55+ return nil, fmt.Errorf("pragma %q: %w", pragma, err)
56+ }
57+ }
58+
59+ // Migrate: drop old search_cache with keywords column and recreate.
60+ // This is a cache, so losing data is acceptable.
61+ if hasColumn(db, "search_cache", "keywords") {
62+ db.Exec("DROP TABLE search_cache") //nolint:errcheck // best-effort migration
63+ }
64+
65+ if _, err := db.Exec(schema); err != nil {
66+ db.Close()
67+ return nil, fmt.Errorf("create schema: %w", err)
68+ }
69+
70+ c := &Cache{db: db, ttl: ttl}
71+ c.purgeStale()
72+ return c, nil
73+}
74+
75+// Close closes the database.
76+func (c *Cache) Close() error {
77+ if c == nil {
78+ return nil
79+ }
80+ return c.db.Close()
81+}
82+
83+// --- Fetch cache ---
84+
85+// GetFetch returns a cached fetch result for the given URL, or "" if miss/stale.
86+// Safe to call on a nil receiver (returns miss).
87+func (c *Cache) GetFetch(url string) (string, bool) {
88+ if c == nil {
89+ return "", false
90+ }
91+ c.mu.Lock()
92+ defer c.mu.Unlock()
93+
94+ cutoff := time.Now().Add(-c.ttl).Unix()
95+ var result string
96+ err := c.db.QueryRow(
97+ "SELECT result FROM fetch_cache WHERE url = ? AND created > ?",
98+ url, cutoff,
99+ ).Scan(&result)
100+ if err != nil {
101+ return "", false
102+ }
103+ return result, true
104+}
105+
106+// SetFetch stores a fetch result. No-op on nil receiver.
107+func (c *Cache) SetFetch(url, result string) {
108+ if c == nil {
109+ return
110+ }
111+ c.mu.Lock()
112+ defer c.mu.Unlock()
113+
114+ _, err := c.db.Exec(
115+ "INSERT OR REPLACE INTO fetch_cache (url, result, created) VALUES (?, ?, ?)",
116+ url, result, time.Now().Unix(),
117+ )
118+ if err != nil {
119+ log.Warn().Err(err).Str("url", url).Msg("failed to cache fetch result")
120+ }
121+}
122+
123+// --- Search cache ---
124+
125+// GetSearch returns a cached search result for the exact query, or "" if miss/stale.
126+// Safe to call on a nil receiver (returns miss).
127+func (c *Cache) GetSearch(query string) (string, bool) {
128+ if c == nil {
129+ return "", false
130+ }
131+ c.mu.Lock()
132+ defer c.mu.Unlock()
133+
134+ normalized := normalizeQuery(query)
135+ cutoff := time.Now().Add(-c.ttl).Unix()
136+ var result string
137+ err := c.db.QueryRow(
138+ "SELECT result FROM search_cache WHERE query = ? AND created > ?",
139+ normalized, cutoff,
140+ ).Scan(&result)
141+ if err != nil {
142+ return "", false
143+ }
144+ return result, true
145+}
146+
147+// SearchCachedContent looks for a cached result whose text content contains
148+// enough of the query keywords. This searches the actual cached results, not
149+// the original queries — so if the answer already exists in any cached result,
150+// we return it instead of making a new API call.
151+func (c *Cache) SearchCachedContent(query string) (string, bool) {
152+ if c == nil {
153+ return "", false
154+ }
155+ c.mu.Lock()
156+ defer c.mu.Unlock()
157+
158+ queryKw := tokenize(query)
159+ if len(queryKw) < 2 {
160+ return "", false
161+ }
162+
163+ cutoff := time.Now().Add(-c.ttl).Unix()
164+ rows, err := c.db.Query(
165+ "SELECT result FROM search_cache WHERE created > ?",
166+ cutoff,
167+ )
168+ if err != nil {
169+ return "", false
170+ }
171+ defer rows.Close()
172+
173+ var bestResult string
174+ var bestScore float64
175+ var bestHits int
176+
177+ for rows.Next() {
178+ var result string
179+ if err := rows.Scan(&result); err != nil {
180+ continue
181+ }
182+ resultLower := strings.ToLower(result)
183+ score, hits := contentOverlap(queryKw, resultLower)
184+ if score > bestScore {
185+ bestScore = score
186+ bestHits = hits
187+ bestResult = result
188+ }
189+ }
190+
191+ // Require at least 75% of query keywords found in content AND at least 3 hits.
192+ if bestScore >= 0.75 && bestHits >= 3 {
193+ return bestResult, true
194+ }
195+ return "", false
196+}
197+
198+// SetSearch stores a search result. No-op on nil receiver.
199+func (c *Cache) SetSearch(query, result string) {
200+ if c == nil {
201+ return
202+ }
203+ c.mu.Lock()
204+ defer c.mu.Unlock()
205+
206+ normalized := normalizeQuery(query)
207+ _, err := c.db.Exec(
208+ "INSERT OR REPLACE INTO search_cache (query, result, created) VALUES (?, ?, ?)",
209+ normalized, result, time.Now().Unix(),
210+ )
211+ if err != nil {
212+ log.Warn().Err(err).Str("query", query).Msg("failed to cache search result")
213+ }
214+}
215+
216+// hasColumn checks if a table has a specific column.
217+func hasColumn(db *sql.DB, table, column string) bool {
218+ rows, err := db.Query(fmt.Sprintf("PRAGMA table_info(%s)", table)) //nolint:gosec // table name is hardcoded by caller
219+ if err != nil {
220+ return false
221+ }
222+ defer rows.Close()
223+ for rows.Next() {
224+ var cid int
225+ var name, typ string
226+ var notNull, pk int
227+ var dflt sql.NullString
228+ if err := rows.Scan(&cid, &name, &typ, &notNull, &dflt, &pk); err != nil {
229+ continue
230+ }
231+ if name == column {
232+ return true
233+ }
234+ }
235+ return false
236+}
237+
238+// --- Helpers ---
239+
240+// purgeStale removes entries older than the TTL.
241+func (c *Cache) purgeStale() {
242+ cutoff := time.Now().Add(-c.ttl).Unix()
243+ for _, table := range []string{"fetch_cache", "search_cache"} {
244+ res, err := c.db.Exec(
245+ fmt.Sprintf("DELETE FROM %s WHERE created <= ?", table), //nolint:gosec // table name is hardcoded
246+ cutoff,
247+ )
248+ if err != nil {
249+ log.Warn().Err(err).Str("table", table).Msg("failed to purge stale cache")
250+ continue
251+ }
252+ if n, _ := res.RowsAffected(); n > 0 {
253+ log.Info().Int64("deleted", n).Str("table", table).Msg("purged stale cache entries")
254+ }
255+ }
256+}
257+
258+// normalizeQuery lowercases and trims a query string.
259+func normalizeQuery(q string) string {
260+ return strings.ToLower(strings.TrimSpace(q))
261+}
262+
263+// stopWords are common words filtered out during tokenization.
264+var stopWords = map[string]bool{
265+ "a": true, "an": true, "the": true, "is": true, "are": true,
266+ "was": true, "were": true, "be": true, "been": true, "being": true,
267+ "have": true, "has": true, "had": true, "do": true, "does": true,
268+ "did": true, "will": true, "would": true, "could": true, "should": true,
269+ "may": true, "might": true, "shall": true, "can": true,
270+ "for": true, "and": true, "but": true, "or": true, "nor": true,
271+ "not": true, "so": true, "yet": true, "to": true, "of": true,
272+ "in": true, "on": true, "at": true, "by": true, "with": true,
273+ "from": true, "as": true, "into": true, "about": true, "between": true,
274+ "through": true, "during": true, "before": true, "after": true,
275+ "above": true, "below": true, "up": true, "down": true, "out": true,
276+ "off": true, "over": true, "under": true, "again": true, "then": true,
277+ "once": true, "here": true, "there": true, "when": true, "where": true,
278+ "why": true, "how": true, "what": true, "which": true, "who": true,
279+ "whom": true, "this": true, "that": true, "these": true, "those": true,
280+ "i": true, "me": true, "my": true, "we": true, "our": true,
281+ "you": true, "your": true, "he": true, "him": true, "his": true,
282+ "she": true, "her": true, "it": true, "its": true, "they": true,
283+ "them": true, "their": true,
284+}
285+
286+// tokenize splits a query into lowercase keywords, filtering stop words and short tokens.
287+func tokenize(query string) []string {
288+ words := strings.Fields(strings.ToLower(strings.TrimSpace(query)))
289+ var out []string
290+ for _, w := range words {
291+ w = strings.Trim(w, ".,;:!?\"'()-[]{}") // strip punctuation
292+ if len(w) < 2 || stopWords[w] {
293+ continue
294+ }
295+ out = append(out, w)
296+ }
297+ return out
298+}
299+
300+// contentOverlap checks how many of the query keywords appear anywhere in the
301+// lowercased result text. Returns fraction and count.
302+func contentOverlap(queryKw []string, resultLower string) (float64, int) {
303+ if len(queryKw) == 0 {
304+ return 0, 0
305+ }
306+ hits := 0
307+ for _, kw := range queryKw {
308+ if strings.Contains(resultLower, kw) {
309+ hits++
310+ }
311+ }
312+ return float64(hits) / float64(len(queryKw)), hits
313+}
internal/store/store_test.go+231−0
@@ -0,0 +1,231 @@
1+package store
2+
3+import (
4+ "path/filepath"
5+ "testing"
6+ "time"
7+)
8+
9+func openTestCache(t *testing.T, ttl time.Duration) *Cache {
10+ t.Helper()
11+ dbPath := filepath.Join(t.TempDir(), "test.db")
12+ c, err := Open(dbPath, ttl)
13+ if err != nil {
14+ t.Fatalf("Open: %v", err)
15+ }
16+ t.Cleanup(func() { c.Close() })
17+ return c
18+}
19+
20+func TestFetchCache_SetGet(t *testing.T) {
21+ c := openTestCache(t, 24*time.Hour)
22+
23+ // Miss on empty.
24+ if _, ok := c.GetFetch("https://example.com"); ok {
25+ t.Fatal("expected miss")
26+ }
27+
28+ c.SetFetch("https://example.com", "page content")
29+
30+ got, ok := c.GetFetch("https://example.com")
31+ if !ok {
32+ t.Fatal("expected hit")
33+ }
34+ if got != "page content" {
35+ t.Errorf("got %q, want %q", got, "page content")
36+ }
37+}
38+
39+func TestFetchCache_Expiry(t *testing.T) {
40+ c := openTestCache(t, 1*time.Second)
41+ c.SetFetch("https://example.com", "content")
42+
43+ // Backdate the entry.
44+ c.db.Exec("UPDATE fetch_cache SET created = ? WHERE url = ?",
45+ time.Now().Add(-2*time.Second).Unix(), "https://example.com")
46+
47+ if _, ok := c.GetFetch("https://example.com"); ok {
48+ t.Fatal("expected stale miss")
49+ }
50+}
51+
52+func TestSearchCache_SetGet(t *testing.T) {
53+ c := openTestCache(t, 24*time.Hour)
54+
55+ if _, ok := c.GetSearch("golang context"); ok {
56+ t.Fatal("expected miss")
57+ }
58+
59+ c.SetSearch("Golang Context", "results about context")
60+
61+ // Exact match (case-insensitive via normalization).
62+ got, ok := c.GetSearch("golang context")
63+ if !ok {
64+ t.Fatal("expected hit")
65+ }
66+ if got != "results about context" {
67+ t.Errorf("got %q", got)
68+ }
69+}
70+
71+func TestSearchCache_Expiry(t *testing.T) {
72+ c := openTestCache(t, 1*time.Second)
73+ c.SetSearch("golang context", "results")
74+
75+ c.db.Exec("UPDATE search_cache SET created = ? WHERE query = ?",
76+ time.Now().Add(-2*time.Second).Unix(), "golang context")
77+
78+ if _, ok := c.GetSearch("golang context"); ok {
79+ t.Fatal("expected stale miss")
80+ }
81+}
82+
83+func TestSearchCachedContent(t *testing.T) {
84+ c := openTestCache(t, 24*time.Hour)
85+
86+ // Seed cache with a result that contains content about Charm TUI tools.
87+ c.SetSearch("charm coding assistant tui", `Found 3 result(s):
88+
89+--- 1. Crush - Charmbracelet coding assistant ---
90+URL: https://github.com/charmbracelet/crush
91+A terminal-based AI coding agent built with Bubbletea.
92+
93+--- 2. Charm blog ---
94+URL: https://charm.sh/blog
95+Charm builds tools for the terminal including Bubbletea TUI framework.
96+
97+--- 3. Z.AI docs ---
98+URL: https://z.ai/docs
99+AI agent for terminal workflows.
100+`)
101+
102+ tests := []struct {
103+ name string
104+ query string
105+ want bool
106+ }{
107+ // These keywords appear in the cached result text:
108+ {"same topic different words", "charmbracelet terminal agent", true},
109+ {"synonym match", "charm bubbletea framework", true},
110+ {"partial content match", "coding agent terminal", true},
111+ // These don't appear enough in the cached content:
112+ {"unrelated", "python flask deployment", false},
113+ {"single keyword too few", "charm performance", false}, // only 1 hit < min 3
114+ {"below threshold", "react native mobile flutter", false},
115+ }
116+
117+ for _, tt := range tests {
118+ t.Run(tt.name, func(t *testing.T) {
119+ _, ok := c.SearchCachedContent(tt.query)
120+ if ok != tt.want {
121+ t.Errorf("SearchCachedContent(%q) = _, %v; want %v", tt.query, ok, tt.want)
122+ }
123+ })
124+ }
125+}
126+
127+func TestSearchCachedContent_Empty(t *testing.T) {
128+ c := openTestCache(t, 24*time.Hour)
129+
130+ if _, ok := c.SearchCachedContent("anything here"); ok {
131+ t.Fatal("expected miss on empty cache")
132+ }
133+}
134+
135+func TestSearchCachedContent_StaleIgnored(t *testing.T) {
136+ c := openTestCache(t, 1*time.Second)
137+ c.SetSearch("golang context package", "golang context cancellation patterns")
138+
139+ c.db.Exec("UPDATE search_cache SET created = ? WHERE query = ?",
140+ time.Now().Add(-2*time.Second).Unix(), "golang context package")
141+
142+ if _, ok := c.SearchCachedContent("golang context patterns"); ok {
143+ t.Fatal("expected stale entries to be ignored")
144+ }
145+}
146+
147+func TestTokenize(t *testing.T) {
148+ tests := []struct {
149+ input string
150+ want []string
151+ }{
152+ {"Go context package", []string{"go", "context", "package"}},
Cut short: this commit's diff is over 1000 lines.