toolnames

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package toolnames defines the registry of available tools for the godoctor server. It serves as a centralized catalog containing metadata (Name, Title, Description, Instructions) for each tool, which is used to advertise capabilities to the MCP client and guide the LLM.

Index

Constants

This section is empty.

Variables

View Source
var Registry = map[string]ToolDef{

	"file_create": {
		Name:        "file_create",
		Title:       "Create File",
		Description: "Initializes a new source file, automatically creating parent directories and applying standard Go formatting. Ensures new files are immediately compliant with project style guides.",
		Instruction: "*   **`file_create`**: Initialize a new source file.\n    *   **Usage:** `file_create(filename=\"cmd/main.go\", content=\"package main\n...\")`\n    *   **Outcome:** A correctly formatted, directory-synced file is created.",
	},
	"smart_edit": {
		Name:        "smart_edit",
		Title:       "Smart Edit",
		Description: "An intelligent file editor providing robust block matching and safety guarantees. Automatically handles formatting (gofmt), import optimization, and syntax verification to ensure edits do not break the build.",
		Instruction: "*   **`smart_edit`**: The primary tool for safe code modification.\n    *   **Capabilities:** Validates syntax and auto-formats (gofmt/goimports) *before* committing changes to disk.\n    *   **Robustness:** Uses fuzzy matching to locate target blocks despite minor whitespace or indentation variances.\n    *   **Usage:** `smart_edit(filename=\"...\", old_content=\"...\", new_content=\"...\")`.\n    *   **Append Mode:** Leave `old_content` empty to append to the end of the file.\n    *   **Outcome:** A syntactically valid, properly formatted file update.",
	},
	"smart_read": {
		Name:        "smart_read",
		Title:       "Read File",
		Description: "A structure-aware file reader that optimizes for context density. Supports returning full content, structural outlines (signatures only), or specific line ranges to minimize token consumption.",
		Instruction: "*   **`smart_read`**: Inspect file content and structure.\n    *   **Read All:** `smart_read(filename=\"pkg/utils.go\")`\n    *   **Outline:** `smart_read(filename=\"pkg/utils.go\", outline=true)` (Retrieve types and function signatures only).\n    *   **Snippet:** `smart_read(filename=\"pkg/utils.go\", start_line=10, end_line=50)` (Targeted range reading).\n    *   **Outcome:** Targeted source content or structural map.",
	},
	"list_files": {
		Name:        "list_files",
		Title:       "List Files",
		Description: "Recursively lists files and directories while filtering out build artifacts and version control data (e.g., .git, node_modules). Provides an accurate view of the source code hierarchy.",
		Instruction: "*   **`list_files`**: Explore the project structure.\n    *   **Usage:** `list_files(path=\".\", depth=2)`\n    *   **Outcome:** A hierarchical list of source files and directories.",
	},

	"read_docs": {
		Name:        "read_docs",
		Title:       "Get Documentation",
		Description: "Retrieves authoritative Go documentation for any package or symbol. Streamlines development by providing API signatures and usage examples directly within the workflow.",
		Instruction: "*   **`read_docs`**: Access API documentation.\n    *   **Usage:** `read_docs(import_path=\"net/http\")`\n    *   **Outcome:** API reference and usage guidance.",
	},

	"smart_build": {
		Name:        "smart_build",
		Title:       "Smart Build",
		Description: "The primary build tool. Enforces a quality gate pipeline: Tidy -> Format -> Build -> Test -> Lint. Ensures code is production-ready.",
		Instruction: "*   **`smart_build`**: Compile and verify code.\n    *   **Usage:** `smart_build(packages=\"./...\", auto_fix=true)`\n    *   **Outcome:** A comprehensive report on build status, test results, and lint issues.",
	},
	"add_dependency": {
		Name:        "add_dependency",
		Title:       "Add Dependency",
		Description: "Manages Go module installation and manifest updates. Consolidates the workflow by immediately returning the public API documentation for the installed packages.",
		Instruction: "*   **`add_dependency`**: Install dependencies and fetch documentation.\n    *   **Usage:** `add_dependency(packages=[\"github.com/gin-gonic/gin@latest\"])`\n    *   **Outcome:** Dependency added to go.mod and API documentation returned.",
	},
	"project_init": {
		Name:        "project_init",
		Title:       "Initialize Project",
		Description: "Bootstraps a new Go project by creating the directory, initializing the Go module, and installing essential dependencies. Reduces boilerplate and ensures a standard project structure.",
		Instruction: "*   **`project_init`**: Bootstrap a new Go project.\n    *   **Usage:** `project_init(path=\"my-app\", module_path=\"github.com/user/my-app\", dependencies=[\"github.com/go-chi/chi/v5\"])`\n    *   **Outcome:** A valid Go module with requested dependencies and a skeleton structure.",
	},
	"modernize_code": {
		Name:        "modernize_code",
		Title:       "Modernize Code",
		Description: "Analyzes the codebase for outdated Go patterns and automatically refactors them to modern standards. Improves maintainability and performance by applying idiomatic upgrades.",
		Instruction: "*   **`modernize_code`**: Automatically upgrade legacy patterns.\n    *   **Usage:** `modernize_code(dir=\".\", fix=true)`\n    *   **Outcome:** Source code refactored to modern Go standards.",
	},

	"mutation_test": {
		Name:        "mutation_test",
		Title:       "Mutation Test",
		Description: "Runs mutation testing using Selene. Introduces small code mutations (flipped conditions, swapped operators) and checks if existing tests catch them, objectively measuring test suite quality.",
		Instruction: "*   **`mutation_test`**: Verify test quality with mutation testing.\n    *   **Usage:** `mutation_test(dir=\".\")`\n    *   **Outcome:** A report showing which mutations survived (tests missed) and the mutation score.",
	},
	"test_query": {
		Name:        "test_query",
		Title:       "Test Query",
		Description: "Queries Go test results and coverage data using SQL via testquery (tq). Uses a persistent SQLite database (testquery.db) to avoid re-running tests on every query. Set rebuild=true after code changes to refresh the database. Available tables: all_tests (package, test, action, elapsed, output), all_coverage (file, function_name, start_line, end_line, count, stmt_num), test_coverage (test_name, file, start_line, end_line, count), all_code (file, line_number, content).",
		Instruction: "*   **`test_query`**: Query test results with SQL.\n    *   **Usage:** `test_query(query=\"SELECT * FROM all_coverage WHERE count = 0\")`\n    *   **Caching:** Uses a persistent `testquery.db` file. First call builds it automatically. Set `rebuild=true` after code changes.\n    *   **Outcome:** Tabular results from the SQL query over test and coverage data.",
	},

	"code_review": {
		Name:        "code_review",
		Title:       "Code Review",
		Description: "Provides an automated architectural and idiomatic review of source code. Identifies potential defects in concurrency, error handling, and performance before code is committed.",
		Instruction: "*   **`code_review`**: Perform an automated expert review.\n    *   **Usage:** `code_review(file_content=\"...\")`\n    *   **Outcome:** A structured critique identifying potential bugs and optimization opportunities.",
	},
}

Registry holds all tool definitions, keyed by Name.

Functions

This section is empty.

Types

type ToolDef

type ToolDef struct {
	Name        string // The canonical name (e.g. "file_create")
	Title       string // Human-readable title
	Description string // Description passed to the LLM via MCP
	Instruction string // Guidance for the system prompt
}

ToolDef defines the textual representation of a tool.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL