Skip to content

API Reference parrot_tools.wiki.structural

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.wiki.structural

View source

Structural plane tools and toolkit (moved from parrot.knowledge.wiki.structural — FEAT-540 M3).

Class CodeStructuralToolkit

Query the codebase's structural symbol plane: lookup, outline, blast radius.

Tool prefix: "code" — methods are exposed as code_symbol_lookup, code_outline, code_blast_radius. All three delegate to one shared :class:StructuralService.

Example::

toolkit = CodeStructuralToolkit(root=Path("/path/to/repo"))
tools = toolkit.get_tools_sync()  # code_symbol_lookup, code_outline, code_blast_radius
Parameter Type Default Description
root Path | None None Wiki project root. Defaults to :func:find_project_root from the current working directory.
store BaseWikiStore | None None Pre-built retrieval plane. When omitted, one is built from config the same way wikitoolkit's CLI does.
config WikiProjectConfig | None None Effective project configuration. Defaults to :func:load_effective_config for root.
**kwargs Any {} Forwarded to :class:AbstractToolkit.

Attributes:

Attribute Type Description
tool_prefix str Set to "code" to namespace all tools.

Method CodeStructuralToolkit.symbol_lookup

Find a symbol (function/class/method) by name or qualname.

symbol_lookup(query: str, kind: str | None = None, language: str | None = None, path_prefix: str | None = None, limit: int = 20) -> dict[str, Any]

Parameter Type Default Description
query str Symbol name or qualname to look up.
kind str | None None Exact symbol kind filter (e.g. "function", "class").
language str | None None Exact scanner-name filter (e.g. "python").
path_prefix str | None None rel_path must start with this prefix.
limit int 20 Maximum results.

Returns: dict[str, Any] — The SymbolLookupOutput model, as a dict.

Method CodeStructuralToolkit.outline

Get the symbol outline of a file.

outline(target: str, depth: int = 2, include_source: bool = False) -> dict[str, Any]

Parameter Type Default Description
target str A file:, sym:#, or bare relative path.
depth int 2 Maximum symbol nesting depth included.
include_source bool False Include a capped source excerpt (sym: targets only).

Returns: dict[str, Any] — The CodeOutlineOutput model, as a dict.

Method CodeStructuralToolkit.blast_radius

Find every symbol that transitively depends on a given symbol.

blast_radius(symbol: str, relations: list[str] | None = None, depth: int = 2, include_inferred: bool = True, include_tests: bool = True) -> dict[str, Any]

Parameter Type Default Description
symbol str A sym: id or an exact qualname.
relations list[str] | None None Edge relations to follow (default: calls, extends, implements).
depth int 2 Maximum BFS depth.
include_inferred bool True Follow provenance='inferred' edges.
include_tests bool True Include symbols under a tests/ path.

Returns: dict[str, Any] — The BlastRadiusOutput model, as a dict.

Attribute ServiceFactory

Class WikiBlastRadiusTool

Find every symbol that transitively depends on (calls/extends/ implements) a given symbol — the "blast radius" of changing it. Use before editing a widely-used function or class.

Parameter Type Default Description
service_factory ServiceFactory

Class WikiCodeOutlineTool

Get the symbol outline of a file — every top-level (and nested, depth-bounded) class/function/method, with line ranges. Use before reading a whole file to see its shape first.

Parameter Type Default Description
service_factory ServiceFactory

Class WikiSymbolLookupTool

Find a symbol (function/class/method) by name or qualname across the codebase. Returns ranked hits with file/line locations. Use before grep when you know the symbol's name but not where it lives.

Parameter Type Default Description
service_factory ServiceFactory

Function create_structural_tools

Create the three structural tools, sharing one local StructuralService.

create_structural_tools(store: BaseWikiStore, root: Path, config: WikiProjectConfig, *, read_repair: bool = True) -> list[AbstractTool]

Parameter Type Default Description
store BaseWikiStore The (possibly federated) wiki retrieval-plane the tools resolve namespace against.
root Path Repository root the local plane describes — read-repair only ever reads/writes under this root.
config WikiProjectConfig Effective project configuration for the local plane.
read_repair bool True False runs every service rootless (no disk hashing, read-repair or source excerpts); foreign namespaces are always rootless.

Returns: list[AbstractTool] — [WikiSymbolLookupTool, WikiCodeOutlineTool, WikiBlastRadiusTool], all three sharing one service_factory.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally