Skip to content

Commit c31a097

Browse files
committed
feat: add tool version to UniAST
1 parent 683a2f7 commit c31a097

5 files changed

Lines changed: 25 additions & 15 deletions

File tree

lang/parse.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"github.com/cloudwego/abcoder/lang/register"
3636
"github.com/cloudwego/abcoder/lang/rust"
3737
"github.com/cloudwego/abcoder/lang/uniast"
38+
"github.com/cloudwego/abcoder/version"
3839
)
3940

4041
// ParseOptions is the options for parsing the repo.
@@ -104,7 +105,8 @@ func Parse(ctx context.Context, uri string, args ParseOptions) ([]byte, error) {
104105
repo.Name = args.RepoID
105106
}
106107

107-
repo.ASTVersion = uniast.Version
108+
repo.ASTVersion = uniast.ABCoderSpecificationVersion
109+
repo.ABCoderToolVersion = version.ABCoderToolVersion
108110

109111
out, err := json.Marshal(repo)
110112
if err != nil {

lang/uniast/ast.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"path/filepath"
2323
"strconv"
2424
"strings"
25+
26+
"github.com/cloudwego/abcoder/version"
2527
)
2628

2729
type Language string
@@ -83,11 +85,14 @@ type NodeGraph map[string]*Node
8385

8486
// Repository
8587
type Repository struct {
88+
// ASTVersion is 'ABCoder Specification Version'
8689
ASTVersion string
87-
Name string `json:"id"` // module name
88-
Path string // repo path
89-
Modules map[string]*Module // module name => module
90-
Graph NodeGraph // node id => node
90+
// ABCoderToolVersion is 'ABCoder Tool Version'
91+
ABCoderToolVersion string
92+
Name string `json:"id"` // module name
93+
Path string // repo path
94+
Modules map[string]*Module // module name => module
95+
Graph NodeGraph // node id => node
9196
}
9297

9398
func (r Repository) ID() string {
@@ -107,11 +112,12 @@ func (r Repository) InternalModules() []*Module {
107112
// NOTICE: Repository.Path is set as name by default, if th name isn't a path, set path somewhere
108113
func NewRepository(name string) Repository {
109114
ret := Repository{
110-
Name: name,
111-
Path: name,
112-
Modules: map[string]*Module{},
113-
Graph: map[string]*Node{},
114-
ASTVersion: Version,
115+
Name: name,
116+
Path: name,
117+
Modules: map[string]*Module{},
118+
Graph: map[string]*Node{},
119+
ASTVersion: ABCoderSpecificationVersion,
120+
ABCoderToolVersion: version.ABCoderToolVersion,
115121
}
116122
return ret
117123
}

lang/uniast/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616

1717
package uniast
1818

19-
const Version = "v0.1.3"
19+
const ABCoderSpecificationVersion = "v0.1.3"

main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import (
4747
"github.com/cloudwego/abcoder/llm/agent"
4848
"github.com/cloudwego/abcoder/llm/mcp"
4949
"github.com/cloudwego/abcoder/llm/tool"
50+
"github.com/cloudwego/abcoder/version"
5051
)
5152

5253
const Usage = `abcoder <Action> [Language] <Path> [Flags]
@@ -106,7 +107,8 @@ func main() {
106107

107108
switch action {
108109
case "version":
109-
fmt.Fprintf(os.Stdout, "%s\n", Version)
110+
fmt.Fprintf(os.Stdout, "ABCoder Tool Version: %s\n", version.ABCoderToolVersion)
111+
fmt.Fprintf(os.Stdout, "ABCoder Universal Abstract-Syntax-Tree Specification Version: %s\n", uniast.ABCoderSpecificationVersion)
110112

111113
case "parse":
112114
language, uri := parseArgsAndFlags(flags, true, flagHelp, flagVerbose)
@@ -183,7 +185,7 @@ func main() {
183185

184186
svr := mcp.NewServer(mcp.ServerOptions{
185187
ServerName: "abcoder",
186-
ServerVersion: Version,
188+
ServerVersion: version.ABCoderToolVersion,
187189
Verbose: *flagVerbose,
188190
ASTReadToolsOptions: tool.ASTReadToolsOptions{
189191
RepoASTsDir: uri,

version.go renamed to version/version.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
package main
17+
package version
1818

1919
const (
20-
Version = "0.2.1"
20+
ABCoderToolVersion = "0.2.1"
2121
)

0 commit comments

Comments
 (0)