Skip to content

Commit b6f1aaf

Browse files
committed
readme
1 parent ba36b55 commit b6f1aaf

4 files changed

Lines changed: 76 additions & 95 deletions

File tree

README.md

Lines changed: 33 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -18,109 +18,57 @@
1818

1919
![ABCoder](images/ABCoder.png)
2020

21-
ABCoder, an AI-powered tool, streamlines coding by keeping real-time status updates, providing lossless code compression, and giving development guidance. It enhances testing by identifying quality, generating reports, and auto-creating test cases. It also offers guidance for refactoring, including language stack switches.
22-
23-
# Table of Contents
24-
25-
- [ABCoder: AI-Based Coder(AKA: A Brand-new Coder)](#abcoder-ai-based-coderaka-a-brand-new-coder)
26-
- [Table of Contents](#table-of-contents)
27-
- [Overview](#overview)
28-
- [Quick Start](#quick-start)
29-
- [Prerequisites](#prerequisites)
30-
- [Running through Coze OpenAPI](#running-through-coze-openapi)
31-
- [Status Update](#status-update)
32-
- [Lossless Compression](#lossless-compression)
33-
- [Development Guide](#development-guide)
34-
- [Testing Enhancements](#testing-enhancements)
35-
- [Refactor/Rewrite Guide](#refactorrewrite-guide)
36-
- [Getting Involved](#getting-involved)
37-
38-
# Overview
39-
40-
ABCoder is a comprehensive open-source software development tool that aims to utilize artificial intelligence to enhance
41-
the process of coding. This project focuses on various aspects of software development ranging from repository analysis,
42-
issue and pull request tracking, to automated code compression, development guidance, testing enhancement, and
43-
refactoring guidance.
44-
45-
# Quick Start
46-
47-
## Prerequisites
48-
- install git and set your access token for github on cmd-line
49-
- install [rust-toolchain](https://www.rust-lang.org/tools/install) (stable)
50-
- (optional) install [ollama](https://github.com/ollama/ollama) and run your LLM
51-
- (optional) create a [Coze](https://www.coze.com/docs/developer_guides/coze_api_overview?_lang=en) agent and set its OpenAPI key
52-
53-
## Running through Coze OpenAPI
54-
1. Set .env file for configuration on ABCoder's working directory. Taking Coze as an example:
55-
```
56-
# cache for repo,AST and so on
57-
WORK_DIR=tmp_abcoder
21+
ABCoder, an AI-oriented code handling tool, is designed to enhance coding-context for Large-Language-Model (LLM).
5822

59-
# exclude dirs for repo parsing, separated by comma
60-
EXCLUDE_DIRS=target,gen-codes
6123

62-
# LLM's api type
63-
API_TYPE=coze # coze|ollama
24+
## Features
6425

65-
# LLM's output language
66-
LANGUAGE=zh
26+
- Universal Abstract Syntax Tree (UniAST), an language-independent and AI-friendly coding-context, provides ample and recursive code information for AI or programs.
27+
28+
- Universal Parser, parses abitary languages to UniAST.
6729

68-
# Coze options
69-
COZE_API_TOKEN="{YOUR_COZE_API_TOKEN}"
70-
COZE_BOT_ID={YOUR_COZE_BOT_ID}
71-
```
30+
- Univeral Writer, transforms UniAST back to codes.
7231

73-
2. compile the parsers
74-
```
75-
./script/make_parser.sh
76-
```
32+
- (WIP) Code Understanding and Semantic Querying, which can be used to retrieve codes with natural language for either human or AI.
33+
34+
Based on these features, ABCoder can help developers to easily implement or enhance many AI-assisted coding applications, such as code reviewer, IDE copilot and so on.
7735

78-
3. compile and run ABCoder
79-
```
80-
cargo run --bin cmd compress https://xxx.git
81-
```
36+
## Getting Started
8237

83-
4. Once triggered, ABCoder will take three steps:
84-
1. Download the repository in {REPO_DIR}
85-
2. Parse the repository and store the AST in {CACHE_DIR}
86-
3. Call the LLM to compress the repository codes, and refresh the AST for each call.
87-
You can stop the process at anytime after step 2. You can restart the compressing by running the same command.
88-
89-
5. Export the compressed results
38+
1. Install ABCoder:
39+
```bash
40+
go install github.com/cloudwego/abcoder@latest
9041
```
91-
cargo run --bin cmd export https://xxx.git --out-dir {OUTPUT_DIR}
42+
2. Use ABCoder to parse a repository to UniAST (JSON)
43+
```bash
44+
abcoder parse <language> <repo-path> > <AST-path>
45+
```
46+
3. Use ABCoder as a writer
47+
```bash
48+
abcoder write <AST-path>
9249
```
9350

94-
# Status Update
95-
96-
The system is designed to automatically fetch the latest data from Github upon triggering relevant tasks, ensuring the
97-
repository status is always up-to-date. It can answer queries related to function, defects based on issue and PR
98-
information. For more details, check out our Issues and Pull Requests sections on Github.
99-
100-
# Lossless Compression
101-
102-
The system also offers a lossless compression feature for repository code. The specific implementation methods are being
103-
optimized, and more details will be available soon.
51+
## Universal-Abstract-Syntax-Tree Specification
10452

105-
# Development Guide
53+
see [UniAST Specification](docs/uniast-zh.md)
10654

107-
We welcome all developers wishing to contribute to ABCoder. Our system provides detailed guidance for manual development
108-
and also supports auto-generation of instructions. Check out our Contribution Guide for more information.
10955

110-
# Testing Enhancements
56+
## Supported Languages
11157

112-
The system is designed to analyze existing functions and corresponding tests, identify the overall quality of testing,
113-
produce reports, and automatically generate test cases for weakly covered items. Our goal is to help repositories
114-
enhance and perfect their test cases.
58+
ABCoder currently supports the following languages:
11559

116-
# Refactor/Rewrite Guide
60+
| Language | Parser | Writer |
61+
| -------- | ------ | ------ |
62+
| Go |||
63+
| Rust || WIP |
64+
| C | WIP ||
11765

118-
We offer guidance for both small-scale feature iterations and large-scale rewrites, including language stack switches.
119-
Our system provides a detailed guide for manual development and also supports automated guidance generation.
12066

121-
# Getting Involved
67+
## Getting Involved
12268

12369
We encourage developers to contribute and make this tool more powerful. If you are interested in contributing to ABCoder
124-
project, kindly check out our Getting Involved Guide.
70+
project, kindly check out our Getting Involved Guide:
71+
- [Parser Extension](docs/parser_extension-zh.md)
72+
- [Writer Extension](docs/writer_extension-zh.md)
12573

12674
> Note: This is a dynamic README and is subject to changes as the project evolves.

docs/uniast-zh.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!--
2+
Copyright 2025 ByteDance Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+

lang/uniast/ast.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,15 @@ func NewLanguage(lang string) (l Language) {
4747
}
4848
}
4949

50+
// Node ID (string) => Node
51+
// Node ID comes from Identity.Full()
52+
type NodeGraph map[string]*Node
53+
5054
// Repository
5155
type Repository struct {
5256
Name string `json:"id"` // module name
53-
Modules map[string]*Module // module name => Library
54-
Graph map[string]*Node
57+
Modules map[string]*Module // module name => module
58+
Graph NodeGraph // node id => node
5559
}
5660

5761
func (r Repository) ID() string {
@@ -223,12 +227,16 @@ func ModPathName(mod ModPath) string {
223227
return mod
224228
}
225229

226-
// Identity holds identity information about a third party declaration
230+
// Identity is the universal-unique for an ast node.
227231
type Identity struct {
228-
ModPath `json:"ModPath" jsonschema:"description=the compiling module of the ast node, the format is {ModName} or {ModName}@{Version}"` // ModPath is the module which the package belongs to
229-
PkgPath `json:"PkgPath" jsonschema:"description=the namespace of the ast node"` // Import Path of the third party package
232+
// module id, must be unique within a repo
233+
ModPath `json:"ModPath" jsonschema:"description=the compiling module of the ast node, the format is {ModName} or {ModName}@{Version}"`
234+
235+
// path id, must be unique within a module
236+
PkgPath `json:"PkgPath" jsonschema:"description=the namespace of the ast node"`
230237

231-
Name string `json:"Name" jsonschema:"description=unique name of the ast node, the format is one of {FunctionName}, {TypeName}.{MethodName}, {InterfaceName}<{TypeName}>.{MethodName}, {TypeName}"` // Unique Name of declaration (FunctionName, TypeName.MethodName, InterfaceName<TypeName>.MethodName, or TypeName)
238+
// symbol id , must be unique within a package
239+
Name string `json:"Name" jsonschema:"description=unique name of the ast node, the format is one of {FunctionName}, {TypeName}.{MethodName}, {InterfaceName}<{TypeName}>.{MethodName}, {TypeName}"`
232240
}
233241

234242
func NewIdentity(mod, pkg, name string) Identity {

lang/uniast/node.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,16 @@ type Relation struct {
201201
// return json.Marshal(rr)
202202
// }
203203

204-
// Node 类型
204+
// Node Type
205205
type NodeType int
206206

207207
const (
208208
UNKNOWN NodeType = iota
209+
// top Function、 methods
209210
FUNC
211+
// Struct、TypeAlias、Enum...
210212
TYPE
213+
// Global Varable or Global Const
211214
VAR
212215
)
213216

@@ -251,12 +254,18 @@ func NewNodeType(typ string) NodeType {
251254
}
252255
}
253256

257+
// an Entity in a language
254258
type Node struct {
259+
// unique identity of the node
255260
Identity
256-
Type NodeType
261+
// Node Type, must be one of FUNC, TYPE, VAR
262+
Type NodeType
263+
// other nodes that depends on this node
257264
Dependencies []Relation
258-
References []Relation
259-
Repo *Repository `json:"-"`
265+
// other nodes that reference this node
266+
References []Relation
267+
// the repo that this node belongs to
268+
Repo *Repository `json:"-"`
260269
}
261270

262271
func (n Node) GetDependency(id Identity) *Relation {

0 commit comments

Comments
 (0)