{"modulePath":"github.com/memcode-ai/memcode","version":"v0.56.16","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package tools\n\nAdmin toolset — the \\`memcode admin\\` session's ONLY tools (plus ask\\_user). Deterministic, typed operations over the gateway configuration and state: the model converses, these tools read and write. No shell, no file editor, and secrets are structurally out of reach (nothing here touches the .env).\n\nPackage tools declares the typed tool registry exposed to the model. The definitions (names + JSON schemas) live here; the runtime owns execution so that permission gating, event capture and post-command diff detection stay in one place. v0 registry: read\\_file, ripgrep, bash, git\\_diff, edit\\_file.\n\nToolsets are the named groups an agent's tool policy speaks in (agents.\\\u003cname\u003e.toolsets / disabled\\_toolsets in gateway.yaml) — the same mechanism Hermes uses. A policy entry may name a toolset or an individual tool; deny always wins over allow. These names are the public contract, documented at memcode.ai/docs/agents/tools — rename one only with the docs.\n\n## Constants\n\n```go\nconst (\n\tGwOverview = \"gw_overview\" // full current state: channels, projects, agents, schedules, pending pairings\n\tGwChannel  = \"gw_channel\"  // per-channel settings: allow list, agent, tier, pairing, voice, group behavior\n\tGwPairing  = \"gw_pairing\"  // approve/deny a pending pairing code\n\tGwProject  = \"gw_project\"  // register/remove working directories\n\tGwAgent    = \"gw_agent\"    // create/remove agents; objective, autonomy, browser, pause\n\tGwSchedule = \"gw_schedule\" // recurring tasks (cron)\n\tGwService  = \"gw_service\"  // the background daemon: status, install, uninstall\n\n\t// Autonomy tools — these apply to an agent allowed to run unattended\n\t// (gw_agent action=autonomous). They are ordinary admin tools, not a\n\t// separate species of agent: an autonomous agent is an agent with an\n\t// objective, an approved policy, and permission to act on its own.\n\tGwPolicy  = \"gw_policy\"  // stage/show/approve the delegation policy (the authority ceremony)\n\tGwGrant   = \"gw_grant\"   // grant/list/revoke resources (filesystem paths, mcp tools, ...)\n\tGwWake    = \"gw_wake\"    // run one bounded wake now\n\tGwInbox   = \"gw_inbox\"   // questions an agent is suspended on\n\tGwAnswer  = \"gw_answer\"  // answer one, resuming the suspended run\n\tGwJournal = \"gw_journal\" // recent runs + the consequential-action journal\n\tGwDoctor  = \"gw_doctor\"  // health check an agent's home, objective, policy, wakes\n\tGwBrowser = \"gw_browser\" // check/connect the user's existing Chrome for browser work\n)\n```\n\n```go\nconst (\n\tReadFile         = \"read_file\"\n\tListDir          = \"list_dir\"\n\tGlob             = \"glob\" // recursive file discovery by name pattern (repofiles-backed; excludes hidden/ignored)\n\tRipgrep          = \"ripgrep\"\n\tCodeQuery        = \"code_query\" // deterministic \"where does X live\" — ranked evidence in one call (no model loop)\n\tBash             = \"bash\"\n\tMCPCodeExec      = \"mcp_code_exec\" // orchestrate the connected MCP servers from a Python script (\"code execution with MCP\"); only the printed result returns\n\tGitDiff          = \"git_diff\"\n\tEditFile         = \"edit_file\"\n\tApplyPatch       = \"apply_patch\"       // multi-file, all-or-nothing edits (coherent refactor lands whole or rolls back)\n\tMCP              = \"mcp\"               // the MCP meta-tool: search/schema/call over connected servers (schemas disclosed on demand, never inlined)\n\tMCPResource      = \"mcp_resource\"      // list/read MCP resources (external context: docs, schemas, runbooks)\n\tMCPPrompt        = \"mcp_prompt\"        // list/get MCP prompt templates\n\tGitHub           = \"github\"            // typed PR/issue/CI surface over gh (structured, not shell-string fiddling)\n\tRunTests         = \"run_tests\"         // run the repo's tests and return a STRUCTURED pass/fail summary (not raw log)\n\tDiagnostics      = \"diagnostics\"       // type/compile diagnostics for a file or the repo (gopls/go build, tsc) — see errors without guessing\n\tCodeNav          = \"code_nav\"          // semantic navigation via LSP: go-to-definition, find-references, hover-for-type\n\tRepoMap          = \"repo_map\"          // ranked, token-budgeted symbol map (personalized PageRank over the reference graph)\n\tMemcode          = \"memcode\"           // dispatcher into memcode's own intelligence (read-only)\n\tTodo             = \"todo\"              // dispatcher for the agent's own work-tracker checklist\n\tExplore          = \"explore\"           // spawn a read-only sub-agent to investigate one facet (map/reduce)\n\tAskUser          = \"ask_user\"          // human-in-the-loop: ask the user a clarifying question on a critical fork\n\tWebSearch        = \"web_search\"        // search the web for a query\n\tFetch            = \"fetch\"             // fetch a specific URL and return its text\n\tSkill            = \"skill\"             // recruit an installed skill's expert guidance on demand (gated)\n\tTask             = \"task\"              // turn recurring work into a durable autonomous task (gated; asks when underspecified)\n\tScript           = \"script\"            // save/find/run/delete a reusable multi-step command sequence (each gated ONCE at the script level, not per inner command)\n\tArtifact         = \"artifact\"          // publish/update/list/delete a self-contained HTML page hosted at memcode.ai (publish gated)\n\tWebsites         = \"websites\"          // make memcode websites locally (git-like: create/develop, then push/publish to memcode.ai) and manage hosted ones\n\tKnowledge        = \"knowledge\"         // consult memcode's baseline facts/idioms for a stack (ungated reference)\n\tTrace            = \"trace\"             // trace an artifact across pipeline stages to locate where data is lost (alias: wiretap)\n\tEnterPlan        = \"enter_plan\"        // switch into research-and-approve plan mode (offered in normal chat only)\n\tCancelPlan       = \"cancel_plan\"       // CANCEL/ABANDON plan mode on the user's behalf (plan mode only; never executes, never presents). Renamed from exit_plan: models carry a Claude Code prior where \"exit plan mode\" means \"present the plan\" — that name got plans silently abandoned.\n\tExecutePlan      = \"execute_plan\"      // APPROVE+execute the plan when the user says so (plan mode only) → apply phase\n\tDispatch         = \"dispatch\"          // offload a discrete block of work to a hands-off background sub-agent\n\tAgent            = \"agent\"             // first-class sub-agent: run a task on a chosen tier (fast/strong), report the result back\n\tRecallPlan       = \"recall_plan\"       // list / retrieve a previously saved plan from the user-level plans store\n\tReasoning        = \"reasoning\"         // adaptive reasoning: inspect/adjust OWN thinking depth mid-turn, or delegate a hard sub-problem to the strong reasoning model\n\tPreferenceSignal = \"preference_signal\" // capture a durable user taste/constraint to remember (LLM-captured, reducer-promoted)\n\tUserPolicy       = \"policy\"            // read/set the user's behavior policy (which model does what, plan review/advisor mode, ...) — only on explicit instruction\n\n\t// Browser tools — only advertised when --chrome is set (gated in toolDefs).\n\tBrowserNavigate   = \"browser_navigate\"   // load a URL in the current Chrome tab\n\tBrowserClick      = \"browser_click\"      // click an element by CSS selector\n\tBrowserType       = \"browser_type\"       // type text into an element by CSS selector\n\tBrowserScreenshot = \"browser_screenshot\" // capture the current page as an image (vision)\n\tBrowserEval       = \"browser_eval\"       // run JavaScript in the page and return the result\n\tBrowserText       = \"browser_text\"       // get the visible text content of the current page\n\tBrowserScroll     = \"browser_scroll\"     // scroll the page by x/y pixel deltas\n\tBrowserPressKey   = \"browser_press_key\"  // send a keyboard event (Enter, Escape, Tab, arrows)\n\tBrowserHover      = \"browser_hover\"      // hover over an element (trigger hover states/menus)\n\tBrowserSelect     = \"browser_select\"     // pick an option in a \u003cselect\u003e dropdown\n\tBrowserBack       = \"browser_back\"       // navigate to the previous page in history\n\tBrowserForward    = \"browser_forward\"    // navigate to the next page in history\n\tBrowserConsole    = \"browser_console\"    // read captured console.log/error messages\n\tBrowserNewTab     = \"browser_new_tab\"    // open a new tab and switch to it\n\tBrowserSwitchTab  = \"browser_switch_tab\" // switch focus to a different tab\n\tBrowserCloseTab   = \"browser_close_tab\"  // close a tab\n\tBrowserListTabs   = \"browser_list_tabs\"  // list all open tabs\n\tBrowserWait       = \"browser_wait\"       // wait for a selector to become visible/hidden/ready (settles SPA navigation)\n\tBrowserUpload     = \"browser_upload\"     // set a file input's file (project files only, symlink-safe)\n\tBrowserResize     = \"browser_resize\"     // set the viewport dimensions (responsive testing)\n)\n```\nTool names (stable identifiers shared by the model and the runtime).\n\n```go\nconst CapabilityTool = \"capability\"\n```\nCapability tool name: the tiny always-on tool that enables a deferred one.\n\n```go\nconst Site = \"site\"\n```\nSite is the website worker's own tool: it SEES pages (look, inspect), adds packages through the dependency policy, and runs the production-build check. Advertised only to a website worker, never to an ordinary session.\n\n## Variables\n\n```go\nvar Capabilities = []Capability{\n\t{Tool: Websites,\n\t\tSummary:  \"memcode websites, a separate product: sites made in ~/.memcode/websites and hosted at {slug}.memcode.app (create, change, push, publish, manage). \\\"Make me a website\\\" usually is NOT this: it is ordinary development in the user's project with the file tools. Use this only when the user names memcode websites or memcode.app, is working on one they already have, or says so when asked; if the conversation doesn't settle which they mean, ask before assuming. Changing a memcode website or judging how it looks is always websites develop (its worker sees pages in a browser; you can't). For public sites elsewhere use fetch/web_search\",\n\t\tTriggers: []string{\"memcode.app\"},\n\t\tGuide: \"Every change to a memcode website, and every question about how one looks (\\\"make it like ode.com\\\", \\\"does it match?\\\", \\\"pick up where we left off\\\"), goes through websites develop. \" +\n\t\t\t\"Its worker opens the site and any reference in a real browser, measures and compares them, edits, and checks the production build. \" +\n\t\t\t\"You can't see pages, so never judge a site's look yourself, and never read, edit, serve or install packages in a site's folder with your own tools. \" +\n\t\t\t\"Pass the user's whole brief as prompt and any reference sites as references.\"},\n\t{Tool: Task,\n\t\tSummary: \"work memcode should do LATER or REPEATEDLY on its own, without the user (\\\"every morning…\\\", \\\"each Monday…\\\", \\\"nightly…\\\"): scheduled automations to create, list, pause, delete. A request to do it once, now, is not this\",\n\t},\n\t{Tool: Script,\n\t\tSummary: \"command sequences the user SAVED earlier and wants replayed (\\\"the deploy recipe I saved\\\", \\\"run my check script\\\"), or a new one to save: save, find, run, delete. Not for writing a script file in the repo\",\n\t},\n\t{Tool: Artifact,\n\t\tSummary:  \"publish a local self-contained HTML file as a shareable memcode.ai page (publish, update, list, delete)\",\n\t\tTriggers: []string{\"memcode.ai/code/artifact\"}},\n}\n```\nCapabilities is the catalog, in index order.\n\nSummary is the model's ROUTER line: what the capability is for and what it is not. The main model reading this index is the classifier; the summaries are where the understanding of what users mean belongs.\n\nTriggers are a latency shortcut for MACHINE identifiers only (a product hostname, a product URL), never natural language: approximating intent with a growing list of words and phrases misroutes ordinary requests, and a false trigger puts an irrelevant schema in front of the model. A capability with no identifier has no triggers and is reached through the index.\n\n```go\nvar MemcodeCommands = []string{\n\t\"overview\", \"map\", \"context\", \"why\", \"recall\", \"next\", \"recap\", \"memories\", \"claims\", \"sources\", \"session\", \"acceptance\", \"doctor\", \"jobs\", \"preferences\",\n}\n```\nMemcodeCommands are the introspection subcommands the \\`memcode\\` tool dispatches to. One tool, one schema — cheap context, structured calls (no shell strings).\n\n```go\nvar PolicyAliases = map[string][]string{\n\n\t\"exec\": {Bash}, \"process\": {\"shell\"}, \"terminal\": {\"shell\"},\n\t\"read\": {ReadFile}, \"write\": {EditFile}, \"edit\": {EditFile},\n\t\"web_fetch\": {Fetch},\n\t\"group:fs\":  {\"files\"}, \"group:runtime\": {\"shell\"}, \"group:web\": {\"web\"},\n\t\"group:session\": {\"delegation\"}, \"group:memory\": {\"memory\"},\n\n\t\"file\": {\"files\"}, \"search\": {WebSearch}, \"clarify\": {AskUser},\n\t\"code_execution\": {\"shell\"},\n\t\"debugging\":      {\"shell\", \"web\", \"files\"},\n}\n```\nPolicyAliases accepts the names OpenClaw and Hermes users already know, so a pasted or migrated policy just works. Canonical names stay memcode's own (the wire-advertised tool names + toolset names); aliases only ever expand to them.\n\n```go\nvar PreferenceAxes = []string{\"workflow\", \"gating\", \"verbosity\", \"style\", \"tooling\"}\n```\nPreferenceAxes is the vocabulary for preference\\_signal's \\`axis\\` field. The axis drives clustering in the reducer — same-axis signals are candidates to merge.\n\n```go\nvar TodoActions = []string{\"create\", \"add\", \"start\", \"done\", \"block\", \"skip\", \"update\", \"show\"}\n```\nTodoActions are the actions the \\`todo\\` tool dispatches to.\n\n## Functions\n\n```go\nfunc AdminDefs() []wire.ToolDef\n```\nAdminDefs returns the admin session's tool registry.\n\n```go\nfunc BrowserDefs() []wire.ToolDef\n```\nBrowserDefs returns the browser tool schemas, advertised only when --chrome is set. They drive a real Chrome instance (via CDP) so the agent can fully interact with web pages as a user would: navigate, click, type, scroll, hover, keyboard, dropdowns, history, tabs, screenshots, console logs, and JS. Screenshots come back as image blocks (vision) through the tool\\_result content union. Actions that change page state (navigate/click/type/scroll/hover/press/ select/back/forward/new\\_tab/close\\_tab) are Medium (they act on the world); screenshot/eval/text/console/list\\_tabs are Safe (read-only).\n\n```go\nfunc CapabilityDef(ids []string) wire.ToolDef\n```\nCapabilityDef is the always-on tool that turns a deferred capability on. ids are the capabilities this session may enable (account gating and modes already applied), so the enum never names a tool the session can't use.\n\n```go\nfunc Defs() []wire.ToolDef\n```\nDefs returns the tool schemas advertised to the model.\n\n```go\nfunc IsDeferred(name string) bool\n```\nIsDeferred reports whether name is a deferred capability's tool.\n\n```go\nfunc SiteDef() wire.ToolDef\n```\nSiteDef is the site tool's schema.\n\n```go\nfunc ToolsetNames() []string\n```\nToolsetNames returns the toolset names in display order.\n\n```go\nfunc ValidPolicyEntry(name string) bool\n```\nValidPolicyEntry reports whether a policy list entry names a toolset, a tool, an accepted alias, or a wildcard matching at least one tool.\n\n## Types\n\n```go\ntype AgentInput struct {\n\tTask       string `json:\"task\"`                 // the self-contained instruction for the sub-agent\n\tContext    string `json:\"context,omitempty\"`    // optional background the sub-agent needs (it starts fresh)\n\tReadOnly   bool   `json:\"readonly,omitempty\"`   // true = investigate/generate only (no edits); false = a full mutating agent\n\tBackground bool   `json:\"background,omitempty\"` // true = run detached and report the result back when done (don't block this turn)\n}\n```\nAgentInput drives the first-class agent tool: run a self-contained task on a chosen tier, read-only or mutating, and get the result back.\n\n```go\ntype ApplyPatchInput struct {\n\tEdits []EditFileInput `json:\"edits\"`\n}\n```\nApplyPatchInput is a set of edits applied ATOMICALLY: validate all, apply all, or roll back all. For a coherent multi-file change (rename + all call sites) that must not half-land. Each edit is the same shape as edit\\_file.\n\n```go\ntype ArtifactInput struct {\n\tAction string `json:\"action\"`          // publish | update | list | delete\n\tPath   string `json:\"path,omitempty\"`  // repo-relative path to the HTML file (publish/update)\n\tTitle  string `json:\"title,omitempty\"` // display title (publish; optional on update)\n\tID     string `json:\"id,omitempty\"`    // artifact id from a prior publish (update/delete)\n}\n```\nArtifactInput drives the artifact tool: publish a LOCAL self-contained HTML file as a shareable page at memcode.ai/code/artifact/\\\u003cid\u003e.\n\n```go\ntype AskOption struct {\n\tLabel       string `json:\"label\"`\n\tDescription string `json:\"description,omitempty\"`\n}\n```\nAskOption is one candidate answer: a concise Label (the choice the user picks) and an optional Description (a muted clarifying line shown beneath it, à la a Claude-Code selector). It decodes tolerantly from EITHER a plain JSON string (→ Label, no description) or an object {label, description}, because models are inconsistent about which they emit — see UnmarshalJSON.\n\n```go\nfunc (o *AskOption) UnmarshalJSON(b []byte) error\n```\nUnmarshalJSON accepts an ask option as EITHER a plain string (a bare label) or an object {label, description}. Models are inconsistent about which they emit, so we tolerate both rather than dropping options that arrived as strings.\n\n```go\ntype AskUserInput struct {\n\tQuestion string      `json:\"question\"`\n\tOptions  []AskOption `json:\"options,omitempty\"` // 2-4 choices; the user may also type their own\n}\n```\nAskUserInput poses a clarifying question to the user (human-in-the-loop).\n\n```go\ntype BashInput struct {\n\tCommand     string `json:\"command\"`\n\tCwd         string `json:\"cwd,omitempty\"`\n\tContext     string `json:\"context,omitempty\"`     // e.g. \"scratchpad\" for isolated analytical experiments\n\tDescription string `json:\"description,omitempty\"` // short human-readable summary for the TUI marker\n\tBackground  bool   `json:\"background,omitempty\"`  // long-running (dev server/watcher): run detached, don't block\n\t// OutsideSandbox runs the command without memcode's OS sandbox, for a tool\n\t// that starts its own sandbox (those can't nest). Always asks the user.\n\tOutsideSandbox bool `json:\"outside_sandbox,omitempty\"`\n}\n```\nInput payloads, one per tool.\n\n```go\ntype BrowserClickInput struct {\n\tSelector string `json:\"selector\"`\n}\n```\nBrowserClickInput clicks an element by CSS selector.\n\n```go\ntype BrowserCloseTabInput struct {\n\tIndex int `json:\"index\"` // 1-based tab number\n}\n```\nBrowserCloseTabInput closes a tab by 1-based index.\n\n```go\ntype BrowserConsoleInput struct {\n\tLevel string `json:\"level,omitempty\"` // filter by level: log, error, warn, info, debug, exception\n}\n```\nBrowserConsoleInput reads captured console messages.\n\n```go\ntype BrowserEvalInput struct {\n\tScript string `json:\"script\"`\n}\n```\nBrowserEvalInput runs a JavaScript expression in the page and returns the result.\n\n```go\ntype BrowserHoverInput struct {\n\tSelector string `json:\"selector\"`\n}\n```\nBrowserHoverInput hovers over an element by CSS selector.\n\n```go\ntype BrowserNavigateInput struct {\n\tURL string `json:\"url\"`\n}\n```\nBrowserNavigateInput loads a URL in the Chrome tab.\n\n```go\ntype BrowserPressKeyInput struct {\n\tKey string `json:\"key\"` // \"Enter\", \"Escape\", \"Tab\", \"Backspace\", \"Space\", \"ArrowUp/Down/Left/Right\", or a single char\n}\n```\nBrowserPressKeyInput sends a keyboard event to the page.\n\n```go\ntype BrowserResizeInput struct {\n\tWidth  int `json:\"width\"`\n\tHeight int `json:\"height\"`\n}\n```\nBrowserResizeInput sets the viewport size.\n\n```go\ntype BrowserScreenshotInput struct {\n\tFullPage bool `json:\"full_page,omitempty\"`\n}\n```\nBrowserScreenshotInput captures the current page as a PNG image (vision). Default is the viewport; full\\_page captures the entire scrollable page (larger — more tokens).\n\n```go\ntype BrowserScrollInput struct {\n\tDX int `json:\"dx,omitempty\"` // horizontal pixels (positive = right)\n\tDY int `json:\"dy,omitempty\"` // vertical pixels (positive = down)\n}\n```\nBrowserScrollInput scrolls the page by pixel deltas.\n\n```go\ntype BrowserSelectInput struct {\n\tSelector string `json:\"selector\"`\n\tValue    string `json:\"value\"`\n}\n```\nBrowserSelectInput picks an option in a \\\u003cselect\u003e by value.\n\n```go\ntype BrowserSwitchTabInput struct {\n\tIndex int `json:\"index\"` // 1-based tab number\n}\n```\nBrowserSwitchTabInput switches to a tab by 1-based index.\n\n```go\ntype BrowserTypeInput struct {\n\tSelector string `json:\"selector\"`\n\tText     string `json:\"text\"`\n\t// Append keeps the field's existing value; default clears it first.\n\tAppend bool `json:\"append,omitempty\"`\n}\n```\nBrowserTypeInput types text into an element by CSS selector.\n\n```go\ntype BrowserUploadInput struct {\n\tSelector string `json:\"selector\"`\n\tPath     string `json:\"path\"` // inside the project root (resolved through symlinks)\n}\n```\nBrowserUploadInput sets a file input's file.\n\n```go\ntype BrowserWaitInput struct {\n\tSelector       string `json:\"selector\"`\n\tState          string `json:\"state,omitempty\"`           // visible (default) | hidden | ready\n\tTimeoutSeconds int    `json:\"timeout_seconds,omitempty\"` // default 30, max 60\n}\n```\nBrowserWaitInput waits for an element to reach a state.\n\n```go\ntype Capability struct {\n\t// Tool is the typed tool this capability turns on; also its ID.\n\tTool string\n\t// Summary is the index line: what it does, in the user's words.\n\tSummary string\n\t// Triggers are machine identifiers (a hostname, a URL) whose presence in a\n\t// request turns the tool on before the model is called, saving a turn.\n\t// Natural language is never a trigger; see the catalog note below.\n\tTriggers []string\n\t// Guide is told to the model the moment the capability turns on: how to\n\t// use it well, at no cost to the requests that never need it.\n\tGuide string\n}\n```\nCapability is one deferred tool.\n\n```go\ntype CodeNavInput struct {\n\tAction string `json:\"action\"`\n\tPath   string `json:\"path\"`\n\tLine   int    `json:\"line\"`\n\tCol    int    `json:\"col\"`\n\tDepth  int    `json:\"depth,omitempty\"`\n}\n```\nCodeNavInput drives the code\\_nav tool: a semantic query at a 1-based line/col in a file. action = definition | references | hover | impact. depth applies to impact.\n\n```go\ntype CodeQueryInput struct {\n\tQuery string `json:\"query\"`\n\tScope string `json:\"scope,omitempty\"` // optional path prefix to focus on\n}\n```\nCodeQueryInput locates code by a natural-language question, deterministically.\n\n```go\ntype DiagnosticsInput struct {\n\tPath string `json:\"path,omitempty\"`\n}\n```\nDiagnosticsInput drives the diagnostics tool: optional path (a file or dir) to scope the check. Empty = the whole repo.\n\n```go\ntype DispatchInput struct {\n\tTask string `json:\"task\"`\n\tMode string `json:\"mode,omitempty\"` // \"auto\" (default) | \"allow-all\"\n}\n```\nDispatchInput offloads a discrete block of work to a hands-off background sub-agent. The sub-agent runs the full mutating agent loop (edits, bash, tests) with NO prompts or clarifying questions — 100% autonomous. It reports back a summary when done.\n\n```go\ntype EditFileInput struct {\n\tPath       string `json:\"path\"`\n\tOldString  string `json:\"old_string,omitempty\"`\n\tNewString  string `json:\"new_string\"`\n\tReplaceAll bool   `json:\"replace_all,omitempty\"`\n}\n```\nInput payloads, one per tool.\n\n```go\ntype EnterPlanInput struct {\n\tYolo bool `json:\"yolo,omitempty\"`\n}\n```\nEnterPlanInput optionally requests yolo planning (auto-resolve questions + auto-execute on approval). cancel\\_plan takes no input — it's cancel-only.\n\n```go\ntype ExploreInput struct {\n\tQuestion string `json:\"question\"`\n\tScope    string `json:\"scope,omitempty\"` // optional subsystem/path to focus on\n\tFocus    string `json:\"focus,omitempty\"` // optional angle (e.g. \"entrypoints, schema, tests\")\n}\n```\nExploreInput dispatches a read-only sub-agent investigation of one facet.\n\n```go\ntype FetchInput struct {\n\tURL string `json:\"url\"`\n}\n```\nFetchInput fetches a specific URL and returns its (text) content.\n\n```go\ntype GitDiffInput struct {\n\tPath string `json:\"path,omitempty\"`\n}\n```\nInput payloads, one per tool.\n\n```go\ntype GitHubInput struct {\n\tAction string `json:\"action\"`           // pr_view | pr_list | issue_view | issue_list | checks | pr_create | comment\n\tNumber int    `json:\"number,omitempty\"` // PR/issue number (pr_view/issue_view/comment; checks uses current branch if 0)\n\tTitle  string `json:\"title,omitempty\"`  // pr_create\n\tBody   string `json:\"body,omitempty\"`   // pr_create / comment\n\tBase   string `json:\"base,omitempty\"`   // pr_create base branch (default the repo default)\n}\n```\nGitHubInput drives the github tool — a typed surface over \\`gh\\`. Read actions (pr\\_view/pr\\_list/issue\\_view/issue\\_list/checks) run directly; write actions (pr\\_create/comment) go through the permission gate.\n\n```go\ntype GlobInput struct {\n\tPattern       string `json:\"pattern\"`\n\tIncludeHidden bool   `json:\"include_hidden,omitempty\"`\n\tMaxResults    int    `json:\"max_results,omitempty\"`\n}\n```\nInput payloads, one per tool.\n\n```go\ntype KnowledgeInput struct {\n\tFind  string `json:\"find,omitempty\"`  // search query → matching pack names\n\tTopic string `json:\"topic,omitempty\"` // exact pack name → its full Facts + Idioms (ungated)\n}\n```\nKnowledgeInput drives the knowledge tool: FIND packs by topic, or get one by name/topic.\n\n```go\ntype ListDirInput struct {\n\tPath string `json:\"path,omitempty\"`\n}\n```\nInput payloads, one per tool.\n\n```go\ntype MCPCodeExecInput struct {\n\tScript               string `json:\"script\"`\n\tSaveSkill            string `json:\"save_skill,omitempty\"`             // slug (lowercase-hyphen) to save the script as a skill\n\tSaveSkillDescription string `json:\"save_skill_description,omitempty\"` // one-line description for the saved skill\n}\n```\nMCPMCPCodeExecInput drives the mcp\\_code\\_exec tool: a Python 3 script that calls a whitelisted set of read-only memcode tools as functions and prints ONLY the distilled answer. save\\_skill (+ description) optionally persists the script as a reusable skill under .memcode/skills/ — only when the user asked for it.\n\n```go\ntype MCPInput struct {\n\tAction string          `json:\"action\"`          // search | schema | call\n\tQuery  string          `json:\"query,omitempty\"` // search filter (empty = list all)\n\tTool   string          `json:\"tool,omitempty\"`  // required for schema/call\n\tArgs   json.RawMessage `json:\"args,omitempty\"`  // call arguments per the tool's schema\n}\n```\nMCPInput drives the mcp meta-tool: action \"search\" (find tools by query), \"schema\" (one tool's input schema on demand), or \"call\" (invoke — gated per call).\n\n```go\ntype MCPPromptInput struct {\n\tAction string            `json:\"action\"`         // list | get\n\tName   string            `json:\"name,omitempty\"` // required for get (namespaced)\n\tArgs   map[string]string `json:\"args,omitempty\"` // template arguments for get\n}\n```\nMCPPromptInput drives the mcp\\_prompt tool: action \"list\" (catalog) or \"get\" (render a template with args).\n\n```go\ntype MCPResourceInput struct {\n\tAction string `json:\"action\"`        // list | read\n\tURI    string `json:\"uri,omitempty\"` // required for read\n}\n```\nMCPResourceInput drives the mcp\\_resource tool: action \"list\" (catalog) or \"read\" (fetch a resource's contents by uri).\n\n```go\ntype MemcodeInput struct {\n\tCommand string `json:\"command\"`\n\tTarget  string `json:\"target,omitempty\"` // path/subsystem for context/why\n\tQuery   string `json:\"query,omitempty\"`  // question for recall\n\tLimit   int    `json:\"limit,omitempty\"`\n}\n```\nInput payloads, one per tool.\n\n```go\ntype Policy struct {\n\t// contains filtered or unexported fields\n}\n```\nPolicy is a compiled tool policy: allow (empty = everything) minus deny. Entries may be toolset names or individual tool names; deny wins.\n\n```go\nfunc NewPolicy(allow, deny []string) (Policy, []string)\n```\nNewPolicy compiles allow/deny lists into a Policy. Unknown entries are returned so callers can surface them instead of silently ignoring them.\n\n```go\nfunc (p Policy) Allows(name string) bool\n```\nAllows reports whether the policy permits a tool. Tools outside the canonical registry (dynamic surfaces) follow the toolset of their family when named, else the allow-list default.\n\n```go\nfunc (p Policy) Empty() bool\n```\nEmpty reports whether the policy restricts nothing.\n\n```go\ntype PolicyInput struct {\n\tAction string         `json:\"action\"`\n\tTarget string         `json:\"target,omitempty\"`\n\tFields map[string]any `json:\"fields,omitempty\"`\n\tScope  string         `json:\"scope,omitempty\"`\n}\n```\nPolicyInput drives the policy tool: read or change the user's behavior settings. It records a choice the user stated; it never makes one.\n\n```go\ntype PreferenceSignalInput struct {\n\tText  string `json:\"text\"`\n\tAxis  string `json:\"axis\"`\n\tScope string `json:\"scope,omitempty\"`\n}\n```\nPreferenceSignalInput captures a durable user taste/constraint the model wants memcode to remember. The reducer clusters these by axis + lexical similarity and promotes a cluster to a standing preference once it crosses the evidence bar (≥3 signals, ≥2 sessions, weighted score ≥ 2.0). Call this when the user states a FORCEFUL, REPEATED directive (\"always X\", \"never Y\", \"stop doing Z\") — NOT for one-off tasks, explorations, or ordinary preferences.\n\n```go\ntype ReadFileInput struct {\n\tPath string `json:\"path\"`\n\t// Optional 1-based inclusive line range — a re-verification read fetches\n\t// the region it needs instead of re-paying the whole file. 0 = unset.\n\tStartLine int `json:\"start_line,omitempty\"`\n\tEndLine   int `json:\"end_line,omitempty\"`\n\t// Attach (PDFs only): send the file ITSELF to the model as a native\n\t// document instead of locally extracted text — for layout/charts/scans.\n\t// Costs far more tokens (per-page image billing), so it's opt-in.\n\tAttach bool `json:\"attach,omitempty\"`\n}\n```\nInput payloads, one per tool.\n\n```go\ntype ReasoningInput struct {\n\tTask    string `json:\"task,omitempty\"`\n\tContext string `json:\"context,omitempty\"`\n\tEffort  string `json:\"effort,omitempty\"` // off | medium | high | auto\n}\n```\nReasoningInput drives the adaptive-reasoning tool: bare effort = self-adjust (or report when everything is empty); task (+context, +effort) = delegate to the strong reasoning model.\n\n```go\ntype RecallPlanInput struct {\n\tSlug string `json:\"slug,omitempty\"`\n}\n```\nRecallPlanInput retrieves a saved plan. Empty slug → the most recent plan (plus a list of older ones); a slug → that specific plan's markdown.\n\n```go\ntype RepoMapInput struct {\n\tFocus        string `json:\"focus,omitempty\"`\n\tBudgetTokens int    `json:\"budget_tokens,omitempty\"`\n}\n```\nRepoMapInput drives the repo\\_map tool: optional focus terms (paths or symbol names, space-separated) to center the map on, and a token budget.\n\n```go\ntype RipgrepInput struct {\n\tQuery string `json:\"query\"`\n\tPath  string `json:\"path,omitempty\"`\n}\n```\nInput payloads, one per tool.\n\n```go\ntype RunTestsInput struct {\n\tPath string `json:\"path,omitempty\"` // package/dir to scope the run (default: whole repo)\n\tRun  string `json:\"run,omitempty\"`  // test-name pattern to filter (go -run / pytest -k / jest -t)\n}\n```\nRunTestsInput drives the run\\_tests tool: optional path (a package/dir to scope to) and run (a name pattern to filter). Empty = the whole repo's tests.\n\n```go\ntype ScriptInput struct {\n\tSave        string `json:\"save,omitempty\"`        // slug (lowercase-hyphen) to save/update — pairs with description + command (gated)\n\tDescription string `json:\"description,omitempty\"` // one-line description for `save`\n\tCommand     string `json:\"command,omitempty\"`     // the command body for `save`\n\tRun         string `json:\"run,omitempty\"`         // exact saved slug to execute (gated once, at the script level — its contents are NOT re-classified)\n\tBackground  bool   `json:\"background,omitempty\"`  // `run`: start detached instead of blocking (long-running scripts)\n\tList        bool   `json:\"list,omitempty\"`        // list every saved script (read-only)\n\tFind        string `json:\"find,omitempty\"`        // search saved scripts by topic (read-only)\n\tDelete      string `json:\"delete,omitempty\"`      // exact saved slug to remove — soft-deleted to .trash (gated)\n}\n```\nScriptInput drives the script tool: SAVE/DELETE/RUN each get exactly ONE coarse permission decision (never a deep look inside the script — its commands were already approved, per-command, the moment they first ran live); LIST/FIND are read-only.\n\n```go\ntype SiteInput struct {\n\tAction   string `json:\"action\"`             // look | inspect | add_package | check | plan\n\tURL      string `json:\"url,omitempty\"`      // look/inspect: a reference page (http/https)\n\tPath     string `json:\"path,omitempty\"`     // look/inspect: a route of the site being built (\"/\", \"/about\")\n\tViewport string `json:\"viewport,omitempty\"` // desktop (default) | laptop | tablet | mobile\n\tFrom     int    `json:\"from,omitempty\"`     // look: page offset in px to start at\n\tScreens  int    `json:\"screens,omitempty\"`  // look: how many viewport-high screens (default 4, max 8)\n\tPackage  string `json:\"package,omitempty\"`  // add_package: npm name, optionally name@version\n\tPlan     string `json:\"plan,omitempty\"`     // plan: the full design plan (replaces the saved one)\n}\n```\nSiteInput drives the site tool.\n\n```go\ntype SkillInput struct {\n\tFind     string `json:\"find,omitempty\"`     // search INSTALLED skills (local) → matching names\n\tLoad     string `json:\"load,omitempty\"`     // exact installed skill name → pull its guidance in (gated)\n\tDiscover string `json:\"discover,omitempty\"` // search the skills.sh CATALOG (remote, no install) → packages\n\tInstall  string `json:\"install,omitempty\"`  // install \"owner/repo@skill\" from the catalog (gated) → then loadable\n}\n```\nSkillInput drives the skill tool: FIND/LOAD work on already-installed skills; DISCOVER/INSTALL reach the skills.sh catalog (search any agent's published skills, then install one on demand).\n\n```go\ntype TodoInput struct {\n\tAction  string         `json:\"action\"`\n\tItems   []TodoItemWire `json:\"items,omitempty\"`\n\tIndex   int            `json:\"index,omitempty\"`\n\tIndices []int          `json:\"indices,omitempty\"` // done/skip several at once (one sweep → one call)\n}\n```\nTodoInput drives the work-tracker. \\`items\\` carries the (re)written list for create/update; \\`index\\` (1-based) targets a single item for done/block.\n\n```go\ntype TodoItemWire struct {\n\tTitle  string `json:\"title\"`\n\tDetail string `json:\"detail,omitempty\"`\n\tStatus string `json:\"status,omitempty\"`\n}\n```\nInput payloads, one per tool.\n\n```go\ntype TraceInput struct {\n\tTarget string `json:\"target\"` // a URL (traces the fetch pipeline) or a file path\n}\n```\nTraceInput traces an artifact across pipeline stages to locate data loss.\n\n```go\ntype WebSearchInput struct {\n\tQuery string `json:\"query\"`\n}\n```\nWebSearchInput searches the web for a query.\n\n```go\ntype WebsitesEditWire struct {\n\tFind    string `json:\"find\"`\n\tReplace string `json:\"replace\"`\n}\n```\nWebsitesEditWire is one verbatim find/replace for the edit action.\n\n```go\ntype WebsitesInput struct {\n\tAction    string             `json:\"action\"`               // list | get | create | develop | push | zip | share | build | edit | builds | preview | publish | unpublish | delete | update | assets_list | assets_upload | assets_delete\n\tSlug      string             `json:\"slug,omitempty\"`       // required for everything but list/create\n\tName      string             `json:\"name,omitempty\"`       // create (display name) / update (rename)\n\tPrompt    string             `json:\"prompt,omitempty\"`     // create / build: describes the site/change to build\n\tModel     string             `json:\"model,omitempty\"`      // create / build / update: chat model id (default: catalog default / the site's pin)\n\tEdits     []WebsitesEditWire `json:\"edits,omitempty\"`      // edit: verbatim find/replace pairs applied without the agent\n\tAssetPath string             `json:\"asset_path,omitempty\"` // assets_upload: repo-relative path of the file to upload\n\tAssetName string             `json:\"asset_name,omitempty\"` // assets_upload (optional override name) / assets_delete (required)\n\tReveal    bool               `json:\"reveal,omitempty\"`     // preview: return the link itself (only when the user asks for it)\n\tRemote    bool               `json:\"remote,omitempty\"`     // create: on memcode.ai with a hosted build, not on this machine\n\t// create/develop: sites the user wants it to look like; the site\n\t// worker opens, measures and screenshots each before designing.\n\tReferences []string `json:\"references,omitempty\"`\n}\n```\nWebsitesInput drives the websites tool — the remote/API-backed surface over memcode.ai's Websites feature. Local workflows that need real files (pull/dev/push, or editing inside a pulled checkout) stay on the \\`memcode websites\\` CLI; this tool covers everything addressable by slug alone. Mutating actions (create, build, edit, publish, unpublish, delete, update, assets\\_upload, assets\\_delete) are gated; list/get/builds/preview/ assets\\_list are read-only.\n\n","path":"github.com/memcode-ai/memcode/internal/agent/tools","name":"tools","synopsis":"Admin toolset — the `memcode admin` session's ONLY tools (plus ask_user).","isRedistributable":true}
