src/tools/ exposes plugin tooling and runtime command hooks used by OpenCode.
ast-grep stack.smartfetch (webfetch tool).createCouncilTool (council.ts).task + task_status)/preset hook via createPresetManager (preset-manager.ts).It is the bridge between plugin runtime integration (src/index.ts) and the lower-level
implementations in feature folders.
src/tools/index.ts)ast_grep_search, ast_grep_replace from ./ast-grepcreateWebfetchTool, WEBFETCH_DESCRIPTION, and related types from ./smartfetchcreateCouncilTool
createPresetManager and PresetManager type
handleCommandExecuteBefore, handleEvent, registerCommand) rather than in tool
modules.createCouncilTool defines council_session.execute performs guarded invocation:
toolContext and sessionID,agent: 'council' (or missing agent for backward compatibility),CouncilManager.runCouncil(prompt, preset, parentSessionId).CouncilManager exposes deprecated field metadata.createPresetManager(ctx, config) returns:
registerCommand(opencodeConfig): injects /preset command definition if absent,handleCommandExecuteBefore(input, output): intercepts /preset command handling.active marker supported),client.config.update(...) with mapped agent overrides,AgentOverrideConfig) into runtime
SDK agent config (model, temperature, variant, options) and skips fields not
supported in runtime updates (prompt, orchestratorPrompt, skills, mcps,
displayName).activePreset supports immediate status display and updates after successful switches.createWebfetchTool owns fetch orchestration, permission prompts, cache checks,
llms.txt probing, binary/text branching, and optional secondary-model post-processing.smartfetch modules split work into:
network.ts),cache.ts),utils.ts),binary.ts),secondary-model.ts),webfetch is always registered from src/index.ts as a public tool.ast-grep is split into CLI/CLI-discovery and tool-definition concerns.ast_grep_search/ast_grep_replace execution calls into runSg, which handles
argument normalization, binary availability, timeout/error handling, and output truncation.src/tools/ast-grep/index.ts re-exports tool definitions and utility helpers for
discoverability (ensureCliAvailable, getAstGrepPath, downloader/runtime checks).src/index.tsTool registration:
council tools (only when config.council exists),webfetch,
AST tools.
presetManager is initialized in plugin init and:
registerCommand during config hook,command.execute.before./preset handling is explicitly user-facing (command hook), while webfetch and
council are tool-facing.