@@ -80,7 +80,10 @@ func NewRootCmd() *cobra.Command {
8080 cmd := & cobra.Command {
8181 Use : "abcoder" ,
8282 Short : "Universal AST parser and writer for multi-language" ,
83- Long : Usage ,
83+ Long : `ABCoder is a universal code analysis tool that converts source code to UniAST format.
84+
85+ It supports multiple programming languages and provides various subcommands for parsing,
86+ writing, and analyzing code structures.` ,
8487 }
8588
8689 // Global flags
@@ -100,7 +103,10 @@ func NewRootCmd() *cobra.Command {
100103func newVersionCmd () * cobra.Command {
101104 return & cobra.Command {
102105 Use : "version" ,
103- Short : "print the version of abcoder" ,
106+ Short : "Print abcoder version information" ,
107+ Long : `Output the version number and build metadata in the format: vX.X.Y-BUILD.
108+
109+ Use this command to verify installation or when reporting issues.` ,
104110 Run : func (cmd * cobra.Command , args []string ) {
105111 fmt .Fprintf (os .Stdout , "%s\n " , version .Version )
106112 },
@@ -117,7 +123,20 @@ func newParseCmd() *cobra.Command {
117123
118124 cmd := & cobra.Command {
119125 Use : "parse <language> <path>" ,
120- Short : "parse the specific repo and write its UniAST (to stdout by default)" ,
126+ Short : "Parse repository and export to UniAST JSON format" ,
127+ Long : `Parse the specified repository and generate its Universal AST representation.
128+
129+ By default, outputs to stdout. Use --output to write to a file.
130+
131+ Language Support:
132+ go - Go projects
133+ rust - Rust projects
134+ cxx - C/C++ projects
135+ python - Python projects
136+ ts - TypeScript projects
137+ js - JavaScript projects
138+ java - Java projects` ,
139+ Example : `abcoder parse go ./my-project -o ast.json` ,
121140 Args : cobra .ExactArgs (2 ),
122141 PreRunE : func (cmd * cobra.Command , args []string ) error {
123142 // Validate language
@@ -176,17 +195,17 @@ func newParseCmd() *cobra.Command {
176195 }
177196
178197 // Flags
179- cmd .Flags ().StringVarP (& flagOutput , "output" , "o" , "" , "Output path." )
180- cmd .Flags ().StringVar (& flagLsp , "lsp" , "" , "Specify the language server path ." )
181- cmd .Flags ().StringVar (& javaHome , "java-home" , "" , "java home " )
182- cmd .Flags ().BoolVar (& opts .LoadExternalSymbol , "load-external-symbol" , false , "load external symbols into results" )
183- cmd .Flags ().BoolVar (& opts .NoNeedComment , "no-need-comment" , false , "not need comment (only works for Go now) " )
184- cmd .Flags ().BoolVar (& opts .NotNeedTest , "no-need-test" , false , "not need parse test files (only works for Go now) " )
185- cmd .Flags ().BoolVar (& opts .LoadByPackages , "load-by-packages" , false , "load by packages (only works for Go now) " )
186- cmd .Flags ().StringSliceVar (& opts .Excludes , "exclude" , []string {}, "exclude files or directories, support multiple values " )
187- cmd .Flags ().StringVar (& opts .RepoID , "repo-id" , "" , "specify the repo id " )
188- cmd .Flags ().StringVar (& opts .TSConfig , "tsconfig" , "" , "tsconfig path (only works for TS now) " )
189- cmd .Flags ().StringSliceVar (& opts .TSSrcDir , "ts-src-dir" , []string {}, "src-dir path (only works for TS now) " )
198+ cmd .Flags ().StringVarP (& flagOutput , "output" , "o" , "" , "Output path for UniAST JSON (default: stdout) ." )
199+ cmd .Flags ().StringVar (& flagLsp , "lsp" , "" , "Path to Language Server Protocol executable. Required for languages with LSP support (e.g., Java) ." )
200+ cmd .Flags ().StringVar (& javaHome , "java-home" , "" , "Java installation directory (JAVA_HOME). Required when using LSP for Java. " )
201+ cmd .Flags ().BoolVar (& opts .LoadExternalSymbol , "load-external-symbol" , false , "Load external symbol references into AST results (slower but more complete). " )
202+ cmd .Flags ().BoolVar (& opts .NoNeedComment , "no-need-comment" , false , "Skip parsing code comments (only works for Go). " )
203+ cmd .Flags ().BoolVar (& opts .NotNeedTest , "no-need-test" , false , "Skip test files during parsing (only works for Go). " )
204+ cmd .Flags ().BoolVar (& opts .LoadByPackages , "load-by-packages" , false , "Load packages one by one instead of all at once (only works for Go, uses more memory). " )
205+ cmd .Flags ().StringSliceVar (& opts .Excludes , "exclude" , []string {}, "Files or directories to exclude from parsing (can be specified multiple times). " )
206+ cmd .Flags ().StringVar (& opts .RepoID , "repo-id" , "" , "Custom identifier for this repository (useful for multi- repo scenarios). " )
207+ cmd .Flags ().StringVar (& opts .TSConfig , "tsconfig" , "" , "Path to tsconfig.json file for TypeScript project configuration. " )
208+ cmd .Flags ().StringSliceVar (& opts .TSSrcDir , "ts-src-dir" , []string {}, "Additional TypeScript source directories (can be specified multiple times). " )
190209
191210 return cmd
192211}
@@ -236,16 +255,22 @@ func newWriteCmd() *cobra.Command {
236255 },
237256 }
238257
239- cmd .Flags ().StringVarP (& flagOutput , "output" , "o" , "" , "Output path ." )
240- cmd .Flags ().StringVar (& wopts .Compiler , "compiler" , "" , "destination compiler path ." )
258+ cmd .Flags ().StringVarP (& flagOutput , "output" , "o" , "" , "Output directory for generated code files (default: <basename of input file>) ." )
259+ cmd .Flags ().StringVar (& wopts .Compiler , "compiler" , "" , "Path to compiler executable (language-specific) ." )
241260
242261 return cmd
243262}
244263
245264func newMcpCmd () * cobra.Command {
246265 return & cobra.Command {
247- Use : "mcp <path>" ,
248- Short : "run as a MCP server for all repo ASTs (*.json) in the specific directory" ,
266+ Use : "mcp <directory>" ,
267+ Short : "Start MCP server for AST files" ,
268+ Long : `Start a Model Context Protocol (MCP) server that provides AST reading tools.
269+
270+ The server communicates via stdio and can be integrated with Claude Code or other MCP clients.
271+
272+ It serves all *.json AST files in the specified directory.` ,
273+ Example : `abcoder mcp ./asts/` ,
249274 Args : cobra .ExactArgs (1 ),
250275 PreRunE : func (cmd * cobra.Command , args []string ) error {
251276 if args [0 ] == "" {
@@ -278,8 +303,18 @@ func newMcpCmd() *cobra.Command {
278303
279304func newInitSpecCmd () * cobra.Command {
280305 return & cobra.Command {
281- Use : "init-spec [path]" ,
282- Short : "initialize ABCoder integration for Claude Code (copies .claude directory and configures MCP servers)" ,
306+ Use : "init-spec [project-path]" ,
307+ Short : "Initialize ABCoder integration for Claude Code" ,
308+ Long : `Initialize ABCoder integration by copying .claude directory and configuring MCP servers.
309+
310+ This sets up Claude Code to use ABCoder for code analysis.
311+
312+ The path defaults to the current directory if not specified.
313+
314+ The command will:
315+ 1. Copy the .claude configuration directory
316+ 2. Configure MCP server settings in Claude's config.json` ,
317+ Example : `abcoder init-spec /path/to/project` ,
283318 Args : cobra .MaximumNArgs (1 ),
284319 RunE : func (cmd * cobra.Command , args []string ) error {
285320 verbose , _ := cmd .Flags ().GetBool ("verbose" )
@@ -308,8 +343,27 @@ func newAgentCmd() *cobra.Command {
308343 )
309344
310345 cmd := & cobra.Command {
311- Use : "agent <path>" ,
312- Short : "run as an Agent for all repo ASTs (*.json) in the specific directory. WIP: only support code-analyzing at present." ,
346+ Use : "agent <directory>" ,
347+ Short : "Run AI agent with code analysis capabilities" ,
348+ Long : `Start an autonomous AI agent that can perform code analysis tasks using LLM.
349+
350+ The agent reads AST files from the specified directory and can perform various
351+ code analysis operations.
352+
353+ Required Environment Variables:
354+ API_TYPE LLM provider type (e.g., openai, anthropic)
355+ API_KEY LLM API authentication key
356+ MODEL_NAME Model identifier (e.g., gpt-4, claude-3-opus-20240229)
357+ BASE_URL (Optional) Custom API base URL
358+
359+ Examples:
360+ # Basic usage with OpenAI
361+ API_TYPE=openai API_KEY=sk-xxx MODEL_NAME=gpt-4 \
362+ abcoder agent ./asts/
363+
364+ # With custom API endpoint and step limit
365+ API_TYPE=custom API_KEY=xxx MODEL_NAME=my-model BASE_URL=https://api.example.com \
366+ abcoder agent ./asts/ --agent-max-steps 100` ,
313367 Args : cobra .ExactArgs (1 ),
314368 PreRunE : func (cmd * cobra.Command , args []string ) error {
315369 if args [0 ] == "" {
@@ -350,8 +404,8 @@ func newAgentCmd() *cobra.Command {
350404 },
351405 }
352406
353- cmd .Flags ().IntVar (& aopts .MaxSteps , "agent-max-steps" , 50 , "specify the max steps that the agent can run for each time " )
354- cmd .Flags ().IntVar (& aopts .MaxHistories , "agent-max-histories" , 10 , "specify the max histories that the agent can use " )
407+ cmd .Flags ().IntVar (& aopts .MaxSteps , "agent-max-steps" , 50 , "Maximum number of agent reasoning steps per task (default: 50). Higher values allow more complex tasks but increase cost. " )
408+ cmd .Flags ().IntVar (& aopts .MaxHistories , "agent-max-histories" , 10 , "Maximum number of conversation histories to maintain for context (default: 10). " )
355409
356410 return cmd
357411}
0 commit comments