### Install ABCoder CLI Source: https://github.com/cloudwego/abcoder/blob/main/README.md Install the ABCoder command-line interface using go install. Ensure your Go environment is set up correctly. ```bash go install github.com/cloudwego/abcoder@latest ``` -------------------------------- ### ABCoder Agent Interaction Example Source: https://github.com/cloudwego/abcoder/blob/main/README.md An example of interacting with the ABCoder agent. This shows setting environment variables, starting the agent, asking a question about a repository, and receiving an analysis. ```bash $ API_TYPE='ark' API_KEY='xxx' MODEL_NAME='zzz' abcoder agent ./testdata/asts Hello! I'm ABCoder, your coding assistant. What can I do for you today? $ What does the repo 'localsession' do? The `localsession` repository appears to be a Go module (`github.com/cloudwego/localsession`) that provides functionality related to managing local sessions. Here's a breakdown of its structure and purpose: ... If you'd like to explore specific functionalities or code details, let me know, and I can dive deeper into the relevant files or nodes. For example: - What does `session.go` or `manager.go` implement? - How is the backup functionality used? $ exit ``` -------------------------------- ### Installation Instructions Source: https://github.com/cloudwego/abcoder/blob/main/docs/claude-code-spec.md Provides steps for installing the AST-Driven Coder configuration, including copying the .claude directory, verifying hook paths in settings.json, and ensuring template directory existence. ```text 1. Copy the `.claude/` directory to the project root or user home directory 2. Ensure the hook paths in `settings.json` are correct 3. Ensure the `~/.claude/tmpls/` directory exists and contains the template files ``` -------------------------------- ### Parse Go Repository Example Source: https://github.com/cloudwego/abcoder/blob/main/README.md Example of parsing a Go repository ('localsession') into a JSON AST file. This demonstrates the 'abcoder parse' command with specific language and path arguments. ```bash git clone https://github.com/cloudwego/localsession.git localsession abcoder parse go localsession -o /abcoder-asts/localsession.json ``` -------------------------------- ### Install and Initialize ABCoder for Claude Code Source: https://github.com/cloudwego/abcoder/blob/main/README.md Install ABCoder using go install and then run the init-spec command in your project directory to automatically configure Claude Code integration. This command sets up necessary directories and configuration files. ```bash go install github.com/cloudwego/abcoder@latest cd /path/to/your/project abcoder init-spec ``` -------------------------------- ### Install Python LSP Server Source: https://github.com/cloudwego/abcoder/blob/main/docs/lsp-installation-en.md Clones the modified python-lsp-server repository, installs it using pip, adds its bin directory to the PATH, and verifies the installation. ```bash $ git clone https://github.com/Hoblovski/python-lsp-server.git -b abc $ cd python-lsp-server $ pip install . $ export PATH=$(realpath ./bin):$PATH $ pylsp --version ``` -------------------------------- ### Install ABCoder CLI Source: https://context7.com/cloudwego/abcoder/llms.txt Install the abcoder binary using Go modules. Requires Go 1.23+. ```bash # Requires Go 1.23+ go install github.com/cloudwego/abcoder@latest # Verify installation abcoder version # Output: v0.x.y-build ``` -------------------------------- ### Install Rust Analyzer Source: https://github.com/cloudwego/abcoder/blob/main/docs/lsp-installation-en.md Installs the Rust language server component using rustup and verifies the installation. ```bash $ rustup component add rust-analyzer $ rust-analyzer --version # Verify successful installation ``` -------------------------------- ### Go Example Skeleton for Swift LanguageSpec Source: https://context7.com/cloudwego/abcoder/llms.txt Provides a skeleton implementation in Go for a hypothetical `SwiftSpec` struct, demonstrating how to start implementing the `LanguageSpec` interface methods for a new language. ```go // Register the new language in lang/parse.go → checkLSP() and checkRepoPath() // Example skeleton for a hypothetical "Swift" language: type SwiftSpec struct{} func (s SwiftSpec) WorkSpace(root string) (map[string]string, error) { // Walk Package.swift files, return module name → directory return map[string]string{"MySwiftModule": root}, nil } func (s SwiftSpec) NameSpace(path string) (string, string, error) { // Derive module and package from file path mod := "MySwiftModule" pkg := filepath.Dir(path) return mod, pkg, nil } // ... implement remaining methods ... ``` -------------------------------- ### ABCoder Agent Example Session Source: https://context7.com/cloudwego/abcoder/llms.txt Demonstrates an interactive session with the `abcoder agent`, showing how to ask questions about the repository and how the agent internally uses commands to provide answers. ```bash $ What does the repo 'localsession' do? # → The agent calls list_repos, get_repo_structure, get_ast_node internally and explains. $ exit ``` -------------------------------- ### Install Clangd on Ubuntu Source: https://github.com/cloudwego/abcoder/blob/main/docs/lsp-installation-en.md Installs the clangd-18 language server directly using the apt package manager on Ubuntu 24.04 or later. ```bash $ sudo apt install clangd-18 ``` -------------------------------- ### AST-Driven Coding Workflow Source: https://github.com/cloudwego/abcoder/blob/main/docs/claude-code-spec.md Illustrates the step-by-step workflow for AST-Driven Coding, starting from user requirements through scheduling, task creation, rechecking, and finally execution. ```mermaid graph TD User Requirements --> /abcoder:schedule subgraph ABCoder Analysis /abcoder:schedule --> Design Plan end Design Plan --> /abcoder:task /abcoder:task --> CODE_TASK subgraph ABCoder Verification CODE_TASK --> /abcoder:recheck /abcoder:recheck --> Plan Review end Plan Review --> coding-executor coding-executor --> Execute Implementation ``` -------------------------------- ### Start MCP Server Command Source: https://github.com/cloudwego/abcoder/blob/main/docs/system_architecture.md Launches the MCP server to load UniAST JSON files and serve them via an HTTP API. Provide the directory containing the AST files. ```bash abcoder mcp {ast-directory-path} ``` -------------------------------- ### Launch ABCoder Agent with Step and History Limits Source: https://context7.com/cloudwego/abcoder/llms.txt Configure the `abcoder agent` with specific limits for maximum steps and histories to control its autonomous execution. This example uses OpenAI. ```bash API_TYPE=openai API_KEY=sk-xxx MODEL_NAME=gpt-4o \ abcoder agent ~/.asts/ --agent-max-steps 100 --agent-max-histories 20 ``` -------------------------------- ### Launch ABCoder Agent with Local Ollama Model Source: https://context7.com/cloudwego/abcoder/llms.txt Start the `abcoder agent` with a local Ollama model. Specify `API_TYPE`, `MODEL_NAME`, and `BASE_URL` to connect to your Ollama instance. ```bash API_TYPE=ollama API_KEY=ollama MODEL_NAME=llama3 BASE_URL=http://localhost:11434 \ abcoder agent ~/.asts/ ``` -------------------------------- ### Start MCP Server Source: https://context7.com/cloudwego/abcoder/llms.txt Launch a Model Context Protocol server to serve UniAST JSON files. Clients can query code structure via structured tools. Supports verbose mode and hot-reloading of AST files. ```bash # Start MCP server pointing at an AST directory abcoder mcp /tmp/asts/ # Verbose mode (logs every tool call) abcoder mcp /tmp/asts/ -v ``` ```json { "mcpServers": { "abcoder": { "command": "abcoder", "args": ["mcp", "/tmp/asts/"] } } } ``` -------------------------------- ### AST Node Unique Identification Example Source: https://github.com/cloudwego/abcoder/blob/main/docs/uniast-en.md Demonstrates the JSON format for globally unique identification of AST Nodes using ModPath, PkgPath, and Name. ```json { "ModPath": "github.com/cloudwego/localsession", "PkgPath": "github.com/cloudwego/localsession/backup", "Name": "RecoverCtxOnDemands" } ``` -------------------------------- ### Launch ABCoder Agent with OpenAI Source: https://context7.com/cloudwego/abcoder/llms.txt Configure and launch the `abcoder agent` for autonomous coding by setting environment variables for API type, key, and model name. This example uses OpenAI. ```bash export API_TYPE=openai export API_KEY=sk-xxx export MODEL_NAME=gpt-4o abcoder agent ~/.asts/ ``` -------------------------------- ### Get Repository Structure with MCP Tool Source: https://context7.com/cloudwego/abcoder/llms.txt Retrieves the module, package, and file hierarchy for a given repository. Use the output's `mod_path` and `pkg_path` for subsequent calls. ```json // Request { "repo_name": "github.com/cloudwego/localsession" } // Response { "modules": [ { "mod_path": "github.com/cloudwego/localsession", "packages": [ { "pkg_path": "github.com/cloudwego/localsession", "files": [ { "file_path": "manager.go" }, { "file_path": "session.go" } ] }, { "pkg_path": "github.com/cloudwego/localsession/backup", "files": [ { "file_path": "backup/backup.go" } ] } ] } ] } ``` -------------------------------- ### UniAST Node Identity Format Examples Source: https://context7.com/cloudwego/abcoder/llms.txt Illustrates the canonical string formats for globally identifying AST nodes using module path, package path, and name. Includes full and display formats. ```string Full format: ModPath?PkgPath#Name Display format: PkgPath#Name Examples: github.com/cloudwego/localsession?github.com/cloudwego/localsession#SessionManager.BindSession github.com/cloudwego/localsession#Session github.com/bytedance/gopkg@v0.1.3?github.com/bytedance/gopkg/cloud/metainfo#CountPersistentValues ``` -------------------------------- ### Get Package Structure with MCP Tool Source: https://context7.com/cloudwego/abcoder/llms.txt Returns all files within a specified package, including node IDs, types, and function signatures. Requires repository and module paths as input. ```json // Request { "repo_name": "github.com/cloudwego/localsession", "mod_path": "github.com/cloudwego/localsession", "package_path": "github.com/cloudwego/localsession" } // Response { "files": [ { "file_path": "manager.go", "nodes": [ { "name": "SessionManager.BindSession", "type": "FUNC", "signature": "func (self *SessionManager) BindSession(Identity SessionIdentity, s Session)", "line": 134 }, { "name": "SessionManager", "type": "TYPE", "signature": "type SessionManager struct", "line": 60 } ] } ] } ``` -------------------------------- ### TypeScript Module/Package Structure Example Source: https://github.com/cloudwego/abcoder/blob/main/ts-parser/src/types/typescript-mapping.md Illustrates the hierarchical relationship between a repository, npm modules (packages), and individual TypeScript files (packages) within the UNIAST context. Shows how package.json defines a module and how files like index.ts, utils.ts, and test files are mapped to package properties. ```text Repository (root) ├── Module (npm package) │ ├── package.json │ ├── src/ │ │ ├── index.ts (Package: PkgPath="src/index.ts", IsMain=true) │ │ ├── utils.ts (Package: PkgPath="src/utils.ts") │ │ └── models/ │ │ └── user.ts (Package: PkgPath="src/models/user.ts") │ └── test/ │ └── index.test.ts (Package: PkgPath="test/index.test.ts", IsTest=true) └── node_modules/ ├── lodash (Module - external) │ └── ... └── react (Module - external) └── ... ``` -------------------------------- ### UniAST JSON Schema Example Source: https://context7.com/cloudwego/abcoder/llms.txt This is an example of the UniAST JSON structure generated by `abcoder parse`. It represents the Abstract Syntax Tree (AST) of a Go project, detailing modules, packages, functions, types, and dependencies. ```json { "id": "github.com/cloudwego/localsession", "ASTVersion": "0.1.5", "ToolVersion": "v0.x.y", "Path": "/abs/path/to/localsession", "Modules": { "github.com/cloudwego/localsession": { "Name": "github.com/cloudwego/localsession", "Language": "go", "Dir": ".", "Packages": { "github.com/cloudwego/localsession": { "PkgPath": "github.com/cloudwego/localsession", "IsMain": false, "IsTest": false, "Functions": { "SessionManager.BindSession": { "ModPath": "github.com/cloudwego/localsession", "PkgPath": "github.com/cloudwego/localsession", "Name": "SessionManager.BindSession", "Exported": true, "IsMethod": true, "File": "manager.go", "Line": 134, "StartOffset": 3290, "EndOffset": 3573, "Signature": "func (self *SessionManager) BindSession(Identity SessionIdentity, s Session)", "Content": "func (self *SessionManager) BindSession(...) { ... }", "FunctionCalls": [ { "ModPath": "...", "PkgPath": "...", "Name": "transmitSessionIdentity" } ] } }, "Types": { "Session": { "TypeKind": "interface", "Exported": true, "Methods": { "Get": { "Name": "Session.Get" } } } }, "Vars": { "defaultShardCap": { "IsConst": false, "IsExported": false, "Content": "var defaultShardCap int = 10" } } } }, "Dependencies": { "github.com/bytedance/gopkg": "github.com/bytedance/gopkg@v0.1.3" } } }, "Graph": { "github.com/cloudwego/localsession?github.com/cloudwego/localsession#SessionManager.BindSession": { "Type": "FUNC", "Dependencies": [ { "Kind": "Dependency", "Name": "transmitSessionIdentity", "Line": 6 } ], "References": [ { "Kind": "Reference", "Name": "InitDefaultManager", "Line": 3 } ] } } } ``` -------------------------------- ### Get File Structure with MCP Tool Source: https://context7.com/cloudwego/abcoder/llms.txt Retrieves all Abstract Syntax Tree (AST) nodes within a specific file, along with their signatures, types, and line numbers. Requires repository and file paths. ```json // Request { "repo_name": "github.com/cloudwego/localsession", "file_path": "session.go" } // Response { "file_path": "session.go", "imports": [ { "Path": "context" } ], "nodes": [ { "mod_path": "github.com/cloudwego/localsession", "pkg_path": "github.com/cloudwego/localsession", "name": "Session", "type": "TYPE", "signature": "type Session interface", "line": 25 } ] } ``` -------------------------------- ### Parse Repository to UniAST (JSON) Source: https://github.com/cloudwego/abcoder/blob/main/README.md Use the 'abcoder parse' command to convert a code repository into a UniAST JSON format. ABCoder attempts to auto-install dependencies; refer to LSP installation docs for customization. ```bash abcoder parse {language} {repo-path} -o xxx.json ``` -------------------------------- ### abcoder init-spec Source: https://context7.com/cloudwego/abcoder/llms.txt Bootstraps a full ABCoder + Claude Code integration within a project directory by copying configuration files, slash commands, hooks, and setting up the MCP server. ```APIDOC ## `abcoder init-spec` ### Description Bootstraps a full ABCoder + Claude Code integration in a project directory: copies `.claude/` config files, slash commands, hooks, and wires up the MCP server in `~/.claude.json`. ### Usage Run this command inside the project directory you want to instrument. ```bash # Run inside the project you want to instrument cd /path/to/your/project abcoder init-spec # Or pass the path explicitly abcoder init-spec /path/to/your/project ``` ### Expected Output (The documentation does not specify the exact output format, but it indicates that the integration setup will be performed.) ``` -------------------------------- ### Initialize ABCoder + Claude Code Integration Source: https://context7.com/cloudwego/abcoder/llms.txt Bootstraps a full ABCoder and Claude Code integration within a project. This command copies configuration files, slash commands, hooks, and sets up the MCP server. ```bash # Run inside the project you want to instrument cd /path/to/your/project abcoder init-spec # Or pass the path explicitly abcoder init-spec /path/to/your/project # Expected output: ``` -------------------------------- ### Parse Go Project with ABCoder Source: https://github.com/cloudwego/abcoder/blob/main/docs/uniast-en.md Command to clone a Go project and parse it using abcoder. ```bash git clone https://github.com/cloudwego/localsession.git && abcoder parse go ./localsession ``` -------------------------------- ### ABCoder Command-Line Arguments Source: https://github.com/cloudwego/abcoder/blob/main/docs/system_architecture.md Key configuration items are specified as command-line arguments when executing ABCoder. Use these for parsing code, processing Abstract Syntax Trees (AST), or running the agent. ```bash abcoder parse {language} {repo-path} -o {output.json} ``` ```bash abcoder mcp {ast-directory-path} ``` ```bash abcoder agent {ast-directory-path} ``` -------------------------------- ### AST-Driven Coding Workflow Layers Source: https://github.com/cloudwego/abcoder/blob/main/README.md The AST-Driven Coding workflow utilizes a 4-layer analysis chain, starting from repository listing down to AST node details. This structure helps in progressively refining code analysis. ```text list_repos → get_repo_structure → get_package_structure → get_file_structure → get_ast_node │ │ │ │ │ └── repo_name └── mod/pkg list └── file list └── node list └── dependencies/references ``` -------------------------------- ### Get AST Node Details with MCP Tool Source: https://context7.com/cloudwego/abcoder/llms.txt Performs deep analysis to retrieve full source code, dependencies, reverse references, interface implementations, and inheritance for specified nodes. Supports batch requests. ```json // Request — batch multiple nodes in one call { "repo_name": "github.com/cloudwego/localsession", "node_ids": [ { "mod_path": "github.com/cloudwego/localsession", "pkg_path": "github.com/cloudwego/localsession", "name": "SessionManager.BindSession" }, { "mod_path": "github.com/cloudwego/localsession", "pkg_path": "github.com/cloudwego/localsession", "name": "Session" } ] } // Response { "nodes": [ { "mod_path": "github.com/cloudwego/localsession", "pkg_path": "github.com/cloudwego/localsession", "name": "SessionManager.BindSession", "type": "FUNC", "file": "manager.go", "line": 134, "codes": "func (self *SessionManager) BindSession(Identity SessionIdentity, s Session) {\n\tshard := self.shards[...}\n\tshard.Store(Identity, s)\n}", "dependencies": [ { "mod_path": "github.com/cloudwego/localsession", "pkg_path": "github.com/cloudwego/localsession", "name": "transmitSessionIdentity" } ], "references": [ { "mod_path": "github.com/cloudwego/localsession", "pkg_path": "github.com/cloudwego/localsession", "name": "InitDefaultManager" } ] } ] } ``` -------------------------------- ### Run Tests with Verbose Output Source: https://github.com/cloudwego/abcoder/blob/main/ts-parser/src/parser/test/README.md Execute tests and display detailed output for each test. ```bash npm run test:verbose ``` -------------------------------- ### Run Tests with Coverage Source: https://github.com/cloudwego/abcoder/blob/main/ts-parser/src/parser/test/README.md Execute tests and generate a code coverage report. ```bash npm run test:coverage ``` -------------------------------- ### Run ABCoder as Agent Source: https://github.com/cloudwego/abcoder/blob/main/README.md Execute ABCoder as a command-line agent. Set the API_TYPE, API_KEY, and MODEL_NAME environment variables before running the 'abcoder agent' command. ```bash export API_TYPE='{openai|ollama|ark|claude}' export API_KEY='{your-api-key}' export MODEL_NAME='{model-endpoint}' abcoder agent {the-AST-directory} ``` -------------------------------- ### Run All Tests Source: https://github.com/cloudwego/abcoder/blob/main/ts-parser/src/parser/test/README.md Execute all unit tests for the parser modules. ```bash npm test ``` -------------------------------- ### Parse Code Repository Command Source: https://github.com/cloudwego/abcoder/blob/main/docs/system_architecture.md Initiates the process of converting a code repository into a UniAST JSON file. Specify the language and the path to the repository. ```bash abcoder parse {language} {repo-path} ``` -------------------------------- ### ABCoder Workflow with Claude Code Source: https://github.com/cloudwego/abcoder/blob/main/README.md This diagram illustrates the workflow when using ABCoder with Claude Code, from user request to implementation, involving scheduling, task creation, and verification steps. ```text User Request │ ▼ /abcoder:schedule ──────────→ Design Solution (ABCoder Analysis) │ │ ▼ ▼ /abcoder:task ─────────→ CODE_TASK (with Technical Specs, including accurate `get_ast_node` call args) │ │ ▼ ▼ /abcoder:recheck ────→ Verify Solution (ABCoder Validation. After `/abcoder:task` Claude Code will tell you what the external dependencies CODE_TASK contains, use `/abcoder:recheck` to analyze external ast_node and technical detail with ABCoder) │ │ ▼ ▼ Start coding(sub-agent) ─────────→ Execute Implementation ``` -------------------------------- ### Configure ABCoder MCP Server Source: https://github.com/cloudwego/abcoder/blob/main/README.md Integrate ABCoder's MCP tools into your AI agent by configuring the 'mcpServers' in your settings. This JSON snippet shows how to define the abcoder command and its arguments. ```json { "mcpServers": { "abcoder": { "command": "abcoder", "args": [ "mcp", "{the-AST-directory}" ] } } } ``` -------------------------------- ### Reconstruct Source Code with Go Library API Source: https://context7.com/cloudwego/abcoder/llms.txt Use `lang.Write` to reconstruct source code files from a `uniast.Repository` object. Specify an output directory for the regenerated files. ```go package main import ( "context" "encoding/json" "os" "github.com/cloudwego/abcoder/lang" "github.com/cloudwego/abcoder/lang/uniast" ) func main() { // Load existing UniAST JSON data, _ := os.ReadFile("/tmp/asts/localsession.json") var repo uniast.Repository json.Unmarshal(data, &repo) // Optionally modify the AST here (e.g., rename a function, insert a field) // Write back to source files err := lang.Write(context.Background(), &repo, lang.WriteOptions{ OutputDir: "/tmp/reconstructed/localsession", }) if err != nil { panic(err) } // /tmp/reconstructed/localsession now contains re-generated .go files } ``` -------------------------------- ### File Information (JSON) Source: https://github.com/cloudwego/abcoder/blob/main/docs/uniast-en.md Represents a file within a module, including its path, imports, and associated package. ```json { "Path": "manager.go", "Imports": [], "Package": "github.com/cloudwego/localsession" } ``` -------------------------------- ### lang.Write Source: https://context7.com/cloudwego/abcoder/llms.txt Reconstructs source code from a UniAST Repository object back to disk. ```APIDOC ## Go Library API: `lang.Write` Reconstructs source code from a (potentially modified) `uniast.Repository` object back to disk. ### Description Writes the UniAST Repository object back to source files in the specified output directory. ### Method Signature `func Write(ctx context.Context, repo *uniast.Repository, opts WriteOptions) error` ### Parameters #### Path Parameters - `ctx` (context.Context) - The context for the operation. #### Request Body - `repo` (*uniast.Repository) - A pointer to the UniAST Repository object to write. - `opts` (lang.WriteOptions): - `OutputDir` (string) - The directory where the reconstructed source files will be written. ### Response #### Success Response (nil) - Returns nil on successful write. #### Error Response - Returns an error if writing fails. ``` -------------------------------- ### Parse UniAST Identity String in Go Source: https://context7.com/cloudwego/abcoder/llms.txt Demonstrates how to parse a UniAST identity string in Go using `uniast.NewIdentityFromString` and access its components like ModPath, PkgPath, and Name. ```go // Parse an identity string in Go id := uniast.NewIdentityFromString( "github.com/cloudwego/localsession?github.com/cloudwego/localsession#SessionManager.BindSession", ) fmt.Println(id.ModPath) // github.com/cloudwego/localsession fmt.Println(id.PkgPath) // github.com/cloudwego/localsession fmt.Println(id.Name) // SessionManager.BindSession fmt.Println(id.Full()) // full string round-trip fmt.Println(id.String()) // PkgPath#Name (LLM-friendly display) ``` -------------------------------- ### Package Structure (JSON) Source: https://github.com/cloudwego/abcoder/blob/main/docs/uniast-en.md Describes a code package, including its path, whether it's a main or test package, and its contained functions, types, and variables. ```json { "IsMain": false, "IsTest": false, "PkgPath": "github.com/cloudwego/localsession/backup", "PkgPath": "github.com/cloudwego/localsession/backup", "Functions": { "BackupCtx": {} }, "Types": {}, "Vars": {} } ``` -------------------------------- ### Hook System Configuration Source: https://github.com/cloudwego/abcoder/blob/main/docs/claude-code-spec.md Describes the hooks available in the system, their associated events, matching tools, and their primary functions, such as AST generation or workflow display. ```markdown | Hook | Event | Matching Tool | |---|---|---| | parse.sh | PreToolUse | get_repo_structure, get_file_structure, get_package_structure, get_ast_node | | prompt.sh | PostToolUse | list_repos | | reminder.sh | PostToolUse | get_repo_structure, get_package_structure, get_file_structure | ``` ```markdown | Function | Auto-detect language and generate AST to `~/.asts/` directory | | Display ABCoder workflow SOP | | Remind recursive call to get_ast_node | ``` -------------------------------- ### LLM Credentials via Environment Variables Source: https://github.com/cloudwego/abcoder/blob/main/docs/system_architecture.md When using the 'agent' mode, configure LLM credentials using environment variables. Ensure API_TYPE, API_KEY, and MODEL_NAME are set correctly for the chosen LLM service. ```bash export API_TYPE=openai ``` ```bash export API_KEY=your_api_key ``` ```bash export MODEL_NAME=gpt-4 ``` -------------------------------- ### Dependency Graph Representation Source: https://github.com/cloudwego/abcoder/blob/main/docs/uniast-en.md Illustrates the dependency topology graph of AST nodes. Keys are Identity strings, and values map to node details. ```json { "github.com/cloudwego/localsession?github.com/cloudwego/localsession#checkEnvOptions": {}, "github.com/bytedance/gopkg@v0.0.0-20230728082804-614d0af6619b?github.com/bytedance/gopkg/cloud/metainfo#CountPersistentValues": {} } ``` -------------------------------- ### lang.Parse Source: https://context7.com/cloudwego/abcoder/llms.txt Programmatic Go API for parsing a repository without using the CLI. It takes a context, repository path, and parse options to generate UniAST JSON. ```APIDOC ## Go Library API: `lang.Parse` Programmatic Go API for parsing a repository without using the CLI. ### Description Parses a given repository path and returns its Abstract Syntax Tree (AST) in UniAST JSON format. ### Method Signature `func Parse(ctx context.Context, repoPath string, opts ParseOptions) ([]byte, error)` ### Parameters #### Path Parameters - `ctx` (context.Context) - The context for the operation. - `repoPath` (string) - The path to the repository to parse. #### Request Body - `opts` (lang.ParseOptions) - Options for parsing: - `CollectOption` (lang.CollectOption): - `Language` (uniast.Language) - The programming language of the repository. - `LoadExternalSymbol` (bool) - Whether to include third-party dependencies. - `NoNeedComment` (bool) - Whether to keep doc comments. - `NotNeedTest` (bool) - Whether to skip `_test.go` files. - `RepoID` (string) - The identifier for the repository. ### Response #### Success Response ([]byte) - Returns a byte slice representing the UniAST JSON of the repository. #### Error Response - Returns an error if parsing fails. ``` -------------------------------- ### Parse Repository with ABCoder Source: https://context7.com/cloudwego/abcoder/llms.txt Use `abcoder parse` to analyze your project's code and store the Abstract Syntax Tree (AST) for Claude Code. Specify the language and output file path. ```bash abcoder parse go /path/to/your/project -o ~/.asts/myproject.json ``` -------------------------------- ### Custom output path Source: https://github.com/cloudwego/abcoder/blob/main/ts-parser/README.md Specify a custom file path for the output JSON when parsing a project. ```bash node dist/index.js parse ./my-project -o ./output/result.json ``` -------------------------------- ### Parse Rust Project with ABCoder Source: https://github.com/cloudwego/abcoder/blob/main/docs/uniast-en.md Command to clone a Rust project and parse it using abcoder, loading external symbols. ```bash git clone https://github.com/cloudwego/metainfo.git && abcoder parse rust ./metainfo -load-external-symbol ``` -------------------------------- ### MCP Tool: list_repos Request/Response Source: https://context7.com/cloudwego/abcoder/llms.txt The `list_repos` MCP tool is used for repository discovery. It returns a list of repository names loaded by the MCP server. This is typically the first call in an analysis workflow. ```json // Request (no parameters) {} // Response { "repo_names": [ "github.com/cloudwego/localsession", "github.com/cloudwego/hertz" ] } ``` -------------------------------- ### Parse monorepo with separate package outputs Source: https://github.com/cloudwego/abcoder/blob/main/ts-parser/README.md Parse a monorepo and output results for each package separately. ```bash node dist/index.js parse ./my-monorepo --monorepo-mode separate ``` -------------------------------- ### Reconstruct Source Code from UniAST Source: https://context7.com/cloudwego/abcoder/llms.txt Reconstruct source code from a UniAST JSON file back to disk. Useful for applying AI-generated structural changes. Can specify an output directory and enable verbose logging. ```bash # Reconstruct Go source from a UniAST JSON into ./localsession/ abcoder write /tmp/asts/localsession.json ``` ```bash # Specify output directory explicitly abcoder write /tmp/asts/localsession.json -o /tmp/reconstructed/localsession ``` ```bash # With verbose output to trace file writes abcoder write /tmp/asts/localsession.json -o /tmp/out -v ``` -------------------------------- ### Parse Repository with Go Library API Source: https://context7.com/cloudwego/abcoder/llms.txt Use `lang.Parse` to programmatically parse a code repository into a UniAST JSON byte slice. Configure parsing options like language, external symbol collection, and test file exclusion. ```go package main import ( "context" "encoding/json" "fmt" "os" "github.com/cloudwego/abcoder/lang" "github.com/cloudwego/abcoder/lang/uniast" ) func main() { ctx := context.Background() out, err := lang.Parse(ctx, "/path/to/localsession", lang.ParseOptions{ CollectOption: lang.CollectOption{ Language: uniast.Golang, LoadExternalSymbol: true, // include third-party deps NoNeedComment: false, // keep doc comments NotNeedTest: true, // skip _test.go files }, RepoID: "localsession", }) if err != nil { fmt.Fprintf(os.Stderr, "parse error: %v\n", err) os.Exit(1) } // out is []byte of the UniAST JSON var repo uniast.Repository if err := json.Unmarshal(out, &repo); err != nil { panic(err) } fmt.Printf("Repo: %s\n", repo.Name) fmt.Printf("Modules: %d\n", len(repo.Modules)) // Look up a specific function id := uniast.NewIdentity( "github.com/cloudwego/localsession", "github.com/cloudwego/localsession", "SessionManager.BindSession", ) fn := repo.GetFunction(id) if fn != nil { fmt.Printf("Function signature: %s\n", fn.Signature) fmt.Printf("Called by %d callers\n", len(repo.Graph[id.Full()].References)) } } ``` -------------------------------- ### Parse monorepo (combined output) Source: https://github.com/cloudwego/abcoder/blob/main/ts-parser/README.md Parse a monorepo and generate a combined output for the entire repository. ```bash node dist/index.js parse ./my-monorepo ``` -------------------------------- ### Repository Structure (JSON) Source: https://github.com/cloudwego/abcoder/blob/main/docs/uniast-en.md Represents the overall structure of a parsed repository, including its ID, AST version, tool version, path, modules, and dependency graph. ```json { "id": "/Users/bytedance/golang/work/abcoder/tmp/localsession", "ASTVersion": "xx", "ToolVersion": "yy", "Path": "/a/b/localsession", "Modules": { "github.com/bytedance/gopkg@v0.0.0-20230728082804-614d0af6619b": {}, "github.com/cloudwego/localsession": {} }, "Graph": {} } ``` -------------------------------- ### Launch ABCoder Agent with Anthropic Claude via Ark Source: https://context7.com/cloudwego/abcoder/llms.txt Run the `abcoder agent` using Anthropic Claude through the Ark (Volcano Engine) provider. Set the `API_TYPE`, `API_KEY`, and `MODEL_NAME` accordingly. ```bash API_TYPE=ark API_KEY=xxx MODEL_NAME=my-endpoint abcoder agent ~/.asts/ ``` -------------------------------- ### Parse a single TypeScript project Source: https://github.com/cloudwego/abcoder/blob/main/ts-parser/README.md Use this command to parse a single TypeScript project directory. ```bash node dist/index.js parse ./my-project ``` -------------------------------- ### Slash Command: /abcoder:schedule Source: https://github.com/cloudwego/abcoder/blob/main/docs/claude-code-spec.md Defines the '/abcoder:schedule' slash command for designing implementation plans using mcp__abcoder. Includes guardrails to maximize reuse, minimize changes, and prohibit code writing or agent usage. ```text /abcoder:schedule Use mcp__abcoder to design implementation plan Guardrails: - Maximize reuse of existing features - Prioritize minimal changes - Prohibit writing code, prohibit using agents ``` -------------------------------- ### Parse Repository to UniAST JSON Source: https://context7.com/cloudwego/abcoder/llms.txt Parse a source repository into UniAST JSON format. Supports multiple languages. Use flags to customize parsing behavior, such as excluding test files or including external symbols. ```bash # Parse a Go repository, write output to a file git clone https://github.com/cloudwego/localsession.git localsession abcoder parse go localsession -o /tmp/asts/localsession.json ``` ```bash # Parse with extra options: exclude test files, load external symbols abcoder parse go ./myproject \ --no-need-test \ --load-external-symbol \ --exclude vendor \ --repo-id myproject \ -o /tmp/asts/myproject.json ``` ```bash # Parse a Rust project (rust-analyzer must be available) abcoder parse rust ./my-rust-crate -o /tmp/asts/my-rust-crate.json ``` ```bash # Parse a Java project (requires JDK and eclipse.jdt.ls) abcoder parse java ./my-java-project \ --java-home /usr/lib/jvm/java-17 \ -o /tmp/asts/my-java-project.json ``` ```bash # Parse a TypeScript project (installs abcoder-ts-parser via npm automatically) abcoder parse ts ./my-ts-project \ --tsconfig ./tsconfig.json \ -o /tmp/asts/my-ts-project.json ``` ```bash # Output to stdout (pipe to jq for inspection) abcoder parse go ./localsession | jq '.Modules | keys' ```