Skip to content

Commit 12cc771

Browse files
fix: install the tree-sitter semantic analyzer explicitly
core v0.3.3 (#315/#316) moved tree-sitter into core/code/semantic and made the analyzer opt-in so Go agents can build CGO-free. This agent forwards a semantic index through Tooling, so without an installed analyzer those calls now fail with UNSUPPORTED_OPERATION. It already releases with CGO_ENABLED=1, so install the analyzer explicitly via code.WithSemanticAnalyzer. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 1e568af commit 12cc771

3 files changed

Lines changed: 58 additions & 2 deletions

File tree

‎go.mod‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ require (
3030
github.com/codefly-dev/gortk v0.2.0 // indirect
3131
github.com/cyphar/filepath-securejoin v0.7.0 // indirect
3232
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
33+
github.com/dekobon/tree-sitter-groovy v0.2.2 // indirect
3334
github.com/emirpasic/gods v1.18.1 // indirect
3435
github.com/fatih/color v1.19.0 // indirect
3536
github.com/fsnotify/fsnotify v1.10.1 // indirect
@@ -75,6 +76,7 @@ require (
7576
github.com/lufia/plan9stats v0.0.0-20260802145828-341c2f0c90b5 // indirect
7677
github.com/mattn/go-colorable v0.1.15 // indirect
7778
github.com/mattn/go-isatty v0.0.24 // indirect
79+
github.com/mattn/go-pointer v0.0.1 // indirect
7880
github.com/mattn/go-runewidth v0.0.28 // indirect
7981
github.com/mitchellh/mapstructure v1.5.0 // indirect
8082
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
@@ -90,6 +92,15 @@ require (
9092
github.com/skeema/knownhosts v1.3.2 // indirect
9193
github.com/tklauser/go-sysconf v0.4.0 // indirect
9294
github.com/tklauser/numcpus v0.12.0 // indirect
95+
github.com/tree-sitter-grammars/tree-sitter-kotlin v1.1.0 // indirect
96+
github.com/tree-sitter/go-tree-sitter v0.25.0 // indirect
97+
github.com/tree-sitter/tree-sitter-c-sharp v0.23.5 // indirect
98+
github.com/tree-sitter/tree-sitter-go v0.25.0 // indirect
99+
github.com/tree-sitter/tree-sitter-java v0.23.5 // indirect
100+
github.com/tree-sitter/tree-sitter-javascript v0.25.0 // indirect
101+
github.com/tree-sitter/tree-sitter-python v0.25.0 // indirect
102+
github.com/tree-sitter/tree-sitter-rust v0.24.2 // indirect
103+
github.com/tree-sitter/tree-sitter-typescript v0.23.2 // indirect
93104
github.com/xanzy/ssh-agent v0.3.3 // indirect
94105
github.com/xlab/treeprint v1.2.0 // indirect
95106
github.com/yoheimuta/go-protoparser/v4 v4.14.2 // indirect

‎go.sum‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
4747
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4848
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
4949
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
50+
github.com/dekobon/tree-sitter-groovy v0.2.2 h1:ppghxHjtcQQakgjVStZN6lTFjjh5kluT1Y1dUQKfn4w=
51+
github.com/dekobon/tree-sitter-groovy v0.2.2/go.mod h1:zmwPJRzx9mn9Ca9qEa20FKgg9NukaZF0hUL4gF6zCbg=
5052
github.com/dlclark/regexp2 v1.12.0 h1:0j4c5qQmnC6XOWNjP3PIXURXN2gWx76rd3KvgdPkCz8=
5153
github.com/dlclark/regexp2 v1.12.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
5254
github.com/elazarl/goproxy v1.7.2 h1:Y2o6urb7Eule09PjlhQRGNsqRfPmYI3KKQLFpCAV3+o=
@@ -166,6 +168,8 @@ github.com/mattn/go-colorable v0.1.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy
166168
github.com/mattn/go-colorable v0.1.15/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
167169
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
168170
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
171+
github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0=
172+
github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc=
169173
github.com/mattn/go-runewidth v0.0.28 h1:rPyg2ybwEKPebvpzVWe1gKBkH8EQFkxO4Y0hjBeLaBU=
170174
github.com/mattn/go-runewidth v0.0.28/go.mod h1:3qAiGCV4Koz/yuveO58qUefmUTRm8r0IGEXZ9jeHp/8=
171175
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
@@ -219,6 +223,38 @@ github.com/tklauser/go-sysconf v0.4.0 h1:7H0uAN+7RkwWRaxhYXDLqa5V3LPrJeV8wmD9dRU
219223
github.com/tklauser/go-sysconf v0.4.0/go.mod h1:8mTNWyog7H+MpKijp4VmKJAd2bbYQ2zuUwkYRbUArPI=
220224
github.com/tklauser/numcpus v0.12.0 h1:NR85qdvHA9pFse3x3weVZ0r0ST8R6l5RHbZrlRaqob4=
221225
github.com/tklauser/numcpus v0.12.0/go.mod h1:ABHeXzJnr/qqwguhClkZKT1/8VABcYrsyUiUGobwWJg=
226+
github.com/tree-sitter-grammars/tree-sitter-kotlin v1.1.0 h1:SWIUDASa+WPhDDem1U5IJpYwQEezkqXrUI61OcnORzM=
227+
github.com/tree-sitter-grammars/tree-sitter-kotlin v1.1.0/go.mod h1:eH+flFf3QOa9c9BY9g3Bz02F7zTq30kGIG3cgB0lSlI=
228+
github.com/tree-sitter/go-tree-sitter v0.25.0 h1:sx6kcg8raRFCvc9BnXglke6axya12krCJF5xJ2sftRU=
229+
github.com/tree-sitter/go-tree-sitter v0.25.0/go.mod h1:r77ig7BikoZhHrrsjAnv8RqGti5rtSyvDHPzgTPsUuU=
230+
github.com/tree-sitter/tree-sitter-c v0.23.4 h1:nBPH3FV07DzAD7p0GfNvXM+Y7pNIoPenQWBpvM++t4c=
231+
github.com/tree-sitter/tree-sitter-c v0.23.4/go.mod h1:MkI5dOiIpeN94LNjeCp8ljXN/953JCwAby4bClMr6bw=
232+
github.com/tree-sitter/tree-sitter-c-sharp v0.23.5 h1:EeUc2WJE5G1pD6YEqera2yVHYeroeR+/MakKX2a+0xQ=
233+
github.com/tree-sitter/tree-sitter-c-sharp v0.23.5/go.mod h1:H7/aFm5vR1A8Yn5VIOfLWPdlKuJsMgZ5eDmaJdv8bY0=
234+
github.com/tree-sitter/tree-sitter-cpp v0.23.4 h1:LaWZsiqQKvR65yHgKmnaqA+uz6tlDJTJFCyFIeZU/8w=
235+
github.com/tree-sitter/tree-sitter-cpp v0.23.4/go.mod h1:doqNW64BriC7WBCQ1klf0KmJpdEvfxyXtoEybnBo6v8=
236+
github.com/tree-sitter/tree-sitter-embedded-template v0.23.2 h1:nFkkH6Sbe56EXLmZBqHHcamTpmz3TId97I16EnGy4rg=
237+
github.com/tree-sitter/tree-sitter-embedded-template v0.23.2/go.mod h1:HNPOhN0qF3hWluYLdxWs5WbzP/iE4aaRVPMsdxuzIaQ=
238+
github.com/tree-sitter/tree-sitter-go v0.25.0 h1:cEB0Q3LHgZtS+ECHx9wcP7AwzoOddJFQCVmytX42cVU=
239+
github.com/tree-sitter/tree-sitter-go v0.25.0/go.mod h1:Jrx8QqYN0v7npv1fJRH1AznddllYiCMUChtVjxPK040=
240+
github.com/tree-sitter/tree-sitter-html v0.23.2 h1:1UYDV+Yd05GGRhVnTcbP58GkKLSHHZwVaN+lBZV11Lc=
241+
github.com/tree-sitter/tree-sitter-html v0.23.2/go.mod h1:gpUv/dG3Xl/eebqgeYeFMt+JLOY9cgFinb/Nw08a9og=
242+
github.com/tree-sitter/tree-sitter-java v0.23.5 h1:J9YeMGMwXYlKSP3K4Us8CitC6hjtMjqpeOf2GGo6tig=
243+
github.com/tree-sitter/tree-sitter-java v0.23.5/go.mod h1:NRKlI8+EznxA7t1Yt3xtraPk1Wzqh3GAIC46wxvc320=
244+
github.com/tree-sitter/tree-sitter-javascript v0.25.0 h1:ZkWETb66/w8cc13yhfnNuHOLDQWl3BnKlH6f9AdR88c=
245+
github.com/tree-sitter/tree-sitter-javascript v0.25.0/go.mod h1:lmGD1EJdCA+v0S1u2fFgepMg/opzSg/4pgFym2FPGAs=
246+
github.com/tree-sitter/tree-sitter-json v0.24.8 h1:tV5rMkihgtiOe14a9LHfDY5kzTl5GNUYe6carZBn0fQ=
247+
github.com/tree-sitter/tree-sitter-json v0.24.8/go.mod h1:F351KK0KGvCaYbZ5zxwx/gWWvZhIDl0eMtn+1r+gQbo=
248+
github.com/tree-sitter/tree-sitter-php v0.23.11 h1:iHewsLNDmznh8kgGyfWfujsZxIz1YGbSd2ZTEM0ZiP8=
249+
github.com/tree-sitter/tree-sitter-php v0.23.11/go.mod h1:T/kbfi+UcCywQfUNAJnGTN/fMSUjnwPXA8k4yoIks74=
250+
github.com/tree-sitter/tree-sitter-python v0.25.0 h1:O6XD9v8U1LOcRc3cNj9nM7XufrtEBezE6VrpRrHZDf0=
251+
github.com/tree-sitter/tree-sitter-python v0.25.0/go.mod h1:cpdthSy/Yoa28aJFBscFHlGiU+cnSiSh1kuDVtI8YeM=
252+
github.com/tree-sitter/tree-sitter-ruby v0.23.1 h1:T/NKHUA+iVbHM440hFx+lzVOzS4dV6z8Qw8ai+72bYo=
253+
github.com/tree-sitter/tree-sitter-ruby v0.23.1/go.mod h1:kUS4kCCQloFcdX6sdpr8p6r2rogbM6ZjTox5ZOQy8cA=
254+
github.com/tree-sitter/tree-sitter-rust v0.24.2 h1:NL4nF67ib21RMzzfvkmXlVwe45vvhW10DVyO+D0z/W0=
255+
github.com/tree-sitter/tree-sitter-rust v0.24.2/go.mod h1:hfeGWic9BAfgTrc7Xf6FaOAguCFJRo3RBbs7QJ6D7MI=
256+
github.com/tree-sitter/tree-sitter-typescript v0.23.2 h1:/Odvphn18PniVixb9e97X0DbNVsU6Qocv9mfkyzdXwU=
257+
github.com/tree-sitter/tree-sitter-typescript v0.23.2/go.mod h1:zjzMXT/Ulffel2xfOcAkQQkiAkmgnbtPGlFQw/5X4xA=
222258
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
223259
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
224260
github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=

‎pkg/code/code.go‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"strings"
1212

1313
corecode "github.com/codefly-dev/core/code"
14+
"github.com/codefly-dev/core/code/semantic"
1415
basev0 "github.com/codefly-dev/core/generated/go/codefly/base/v0"
1516
codev0 "github.com/codefly-dev/core/generated/go/codefly/services/code/v0"
1617
runners "github.com/codefly-dev/core/runners/base"
@@ -37,7 +38,7 @@ type Code struct {
3738
func New(svc *pythonservice.Service) *Code {
3839
c := &Code{
3940
Service: svc,
40-
PythonCodeServer: corecode.NewPythonCodeServer(".", nil),
41+
PythonCodeServer: corecode.NewPythonCodeServer(".", semanticOpts()),
4142
}
4243
return c
4344
}
@@ -59,7 +60,7 @@ func (c *Code) SourceDir() string {
5960
// calling embedded RPC methods can share the same guard.
6061
func (c *Code) EnsureInit() {
6162
if !c.initialized {
62-
c.PythonCodeServer = corecode.NewPythonCodeServer(c.SourceDir(), nil)
63+
c.PythonCodeServer = corecode.NewPythonCodeServer(c.SourceDir(), semanticOpts())
6364
c.SetSourceFixer(c.fixPython)
6465
c.initialized = true
6566
}
@@ -125,3 +126,11 @@ func (c *Code) runnerEnvironment(ctx context.Context) runners.RunnerEnvironment
125126
}
126127
return runners.ResolveStandaloneEnvironment(ctx, c.SourceDir(), runtimeContext)
127128
}
129+
130+
// semanticOpts installs the tree-sitter source analyzer that core omits by
131+
// default (so Go agents can build CGO-free). This agent forwards a semantic
132+
// index through its Tooling and already releases with CGO_ENABLED=1, so it
133+
// opts back in explicitly. See core/code.WithSemanticAnalyzer.
134+
func semanticOpts() []corecode.ServerOption {
135+
return []corecode.ServerOption{corecode.WithSemanticAnalyzer(semantic.New())}
136+
}

0 commit comments

Comments
 (0)