// Package toolref renders references to Gortex MCP tools for guidance text so // every hook, adapter, and CLI message names a tool the SAME way — and never // mints the invalid bare `gortex ` shell shape that led agents astray // (an agent that sees a bare tool name in a shell context invents // `gortex read_file `, which is not a real verb). MCP-directed guidance // says "call the `` MCP tool"; a shell fallback renders the real // `gortex call --arg k=v` invocation, which is the ONE correct way to // reach a tool that has no dedicated CLI verb. package toolref import "strings" // exampleArg maps a Gortex MCP tool to a realistic `--arg` for its shell // fallback, so the rendered hint reads `gortex call read_file --arg path=` // rather than a shapeless `key=value`. A tool absent here falls back to the // generic `key=value`, which is still a valid invocation shape. // // Symbol-ID placeholders render both forms — `::` — so // an agent targeting a method knows the ID carries the receiver // (`pkg/s.go::Server.Handle`), not the bare method name; the bare form only // resolves functions and types. var exampleArg = map[string]string{ "read_file": "path=", "get_symbol_source": "symbol=::", "get_editing_context": "path=", "get_file_summary": "path=", "get_symbol": "id=::", "search_symbols": "query=", "search_text": "query=", "find_usages": "symbol=::", "get_callers": "symbol=::", "smart_context": "task=", "explore": "task=", "get_repo_outline": "path_prefix=/", "edit_file": "path=", "edit_symbol": "id=::", "index_repository": "path=", "reindex_repository": "path=", } // MCPRef renders an MCP-directed reference to a tool: "call the `read_file` MCP // tool". Use wherever guidance assumes the agent has the Gortex MCP server // mounted and can call the tool directly. func MCPRef(tool string) string { return "call the `" + tool + "` MCP tool" } // CLIFallback renders the shell-fallback invocation for one tool: // `gortex call read_file --arg path=`. This is the single place a tool // name becomes a shell command — nothing else should hand-assemble a // `gortex …` shape, so the bare-verb mistake can never be re-minted piecemeal. func CLIFallback(tool string) string { arg := exampleArg[tool] if arg == "" { arg = "key=value" } return "gortex call " + tool + " --arg " + arg } // FallbackLine is the standard one-line advisory appended to graph-tool // guidance. It teaches the `gortex call --arg …` shape (with a realistic // example for the primary tool) so an agent in a shell context — MCP unmounted // or degraded, or one that chose Bash — never invents the invalid // `gortex ` verb. primary names the most relevant tool for the worked // example; pass "" to emit only the generic form. The returned string ends in a // newline so it drops straight into a bulleted guidance block. func FallbackLine(primary string) string { var b strings.Builder b.WriteString(" - Shell only (no MCP tools)? Reach any tool above with `gortex call --arg k=v`") if primary != "" { b.WriteString(" — e.g. `" + CLIFallback(primary) + "`") } b.WriteString(". There is no bare `gortex ` verb.\n") return b.String() }