Skip to content

samuelncui/godoccli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

godoccli

godoccli is a Go library plus a set of command-line entrypoints for fetching and formatting Go documentation and source code.

It supports:

  • local package lookups from your current Go environment
  • remote package fetches through a Go module proxy
  • standard library version pinning such as fmt@go1.22.1
  • third-party module version pinning such as github.com/gorilla/mux@v1.8.0

This makes it useful for CI jobs, editor tooling, AI agents, remote debugging systems, and any environment where you want reproducible Go docs and source reads.

CLI (godoccli)

godoccli is the direct command-line interface for the repo's core capabilities. It is the recommended entrypoint for scripts and skills that want to inspect Go docs or source code without running MCP.

Install

go install github.com/samuelncui/godoccli/cmd/godoccli@latest

Commands

Show package documentation:

godoccli show -path fmt

Show a symbol:

godoccli show -path net/http -symbol ListenAndServe

Show an unexported symbol:

godoccli show -path net/http@go1.22.1 -symbol isNotToken -show-unexported

Read source:

godoccli read-src -path github.com/gorilla/mux@v1.8.0/mux.go

Read a source slice with line numbers:

godoccli read-src \
  -path github.com/gorilla/mux@v1.8.0/mux.go \
  -offset 24 \
  -limit 20 \
  -show-line-number

List package files:

godoccli list-src -path github.com/gorilla/mux@v1.8.0

List package files as JSON:

godoccli list-src -path github.com/gorilla/mux@v1.8.0 -json

Shared Flags

All subcommands support these flags:

  • -proxy: override the Go proxy URL, default https://proxy.golang.org
  • -remote-only: skip local package lookup and force proxy-backed reads
  • -verbose: print diagnostic logs to stderr

Agent Skill

This repo ships a reusable skill under .agents/skills/godoccli, not under any Trae-specific directory.

The skill uses the godoccli binary directly and does not rely on MCP.

Quick Install

From the root of the workspace where you want to add the skill:

curl -fsSL https://raw.githubusercontent.com/samuelncui/godoccli/main/scripts/install-skill.sh | bash

To install into a different workspace path:

curl -fsSL https://raw.githubusercontent.com/samuelncui/godoccli/main/scripts/install-skill.sh | \
  bash -s -- /path/to/workspace

The installer will:

  • download .agents/skills/godoccli/SKILL.md
  • create the target .agents/skills/godoccli directory if needed
  • run go install github.com/samuelncui/godoccli/cmd/godoccli@latest

Installed Files

After installation, your workspace will contain:

.agents/
  skills/
    godoccli/
      SKILL.md

MCP Server (godocmcp)

godocmcp is still available when you specifically want to expose the same functionality through an MCP server.

Install

go install github.com/samuelncui/godoccli/cmd/godocmcp@latest

Run

godocmcp -verbose

The MCP server exposes three tools:

  • show: retrieve package or symbol documentation
  • read_src: read a specific source file with line slicing
  • list_src: list files in a package directory

As a Library

You can also use godoccli directly in your Go applications.

Install

go get github.com/samuelncui/godoccli

Usage

package main

import (
	"fmt"
	"log"

	"github.com/samuelncui/godoccli"
)

func main() {
	client, err := godoccli.NewCli(
		godoccli.WithGoProxyURL("https://proxy.golang.org"),
		godoccli.WithRemoteOnly(true),
	)
	if err != nil {
		log.Fatalf("Failed to create Cli client: %v", err)
	}
	defer client.Close()

	showResp, err := client.Show(&godoccli.ShowReq{
		Path:   "net/http",
		Symbol: "ListenAndServe",
	})
	if err != nil {
		log.Printf("Show failed: %v", err)
		return
	}

	fmt.Println(showResp.Doc)
}

API Overview

The godoccli client exposes three primary methods:

  • Show(*ShowReq) (*ShowResp, error): retrieves documentation for a package or symbol
  • ReadSrc(*ReadSrcReq) (*ReadSrcResp, error): retrieves source code for a file
  • ListSrc(*ListSrcReq) (*ListSrcResp, error): lists files in a package directory

License

This project is licensed under the MIT License. See LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors