Skip to content

API Reference parrot.tools.repo.toolkit

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

parrot.tools.repo.toolkit

View source

ReadOnlyRepoToolkit — cwd-confined, write-free repository access.

See sdd/specs/readonly-repo-toolkit.spec.md (FEAT-484) §2/§3 Module 1. This module currently implements the static grounding axis (read_file, list_files); later tasks add grep_files, the local git history tools, graph-backed search, and the opt-in web_search to this same class.

Read-only by construction: this class defines no mutating method, so AbstractToolkit._generate_tools() (tools/toolkit.py:537) — which turns every public async def into an LLM-callable tool — has nothing to expose. There is no flag that adds write capability.

Alias AbstractToolkit

Re-exported from parrot.tools.toolkit.AbstractToolkit.

Alias GitBlameInput

Re-exported from parrot.tools.repo.schemas.GitBlameInput.

Alias GitLogInput

Re-exported from parrot.tools.repo.schemas.GitLogInput.

Alias GitShowInput

Re-exported from parrot.tools.repo.schemas.GitShowInput.

Alias GrepFilesInput

Re-exported from parrot.tools.repo.schemas.GrepFilesInput.

Alias InvalidRefError

Re-exported from parrot.tools.repo.git_tools.InvalidRefError.

Alias LOG_FORMAT

Re-exported from parrot.tools.repo.git_tools.LOG_FORMAT.

Alias ListFilesInput

Re-exported from parrot.tools.repo.schemas.ListFilesInput.

Alias PathOutsideRootError

Re-exported from parrot.tools.repo.confinement.PathOutsideRootError.

Alias ReadFileInput

Re-exported from parrot.tools.repo.schemas.ReadFileInput.

Class ReadOnlyRepoToolkit

Cwd-confined, write-free repository access for any AbstractClient.

Parameter Type Default Description
repo_root Path The repository checkout this toolkit is confined to.
wiki_store object | None None An already-open wiki store, or None to resolve one lazily (consumed by the graph-backed search tools).
wiki_name str 'parrot' The wiki plane name to query.
enable_web_search bool False When True, exposes the web_search tool. When False, the method is not exposed as a tool at all.
default_search_mode Literal['lexical', 'vector', 'combined'] 'lexical' The default search_code mode.
deny_secret_files bool True When True (default), the secret deny-list (spec §8 Q1) applies to read_file / grep_files / list_files. Never affects path containment.
max_result_bytes int 64000 Byte bound applied to any single tool result.
max_search_hits int 12 Maximum number of hits returned by search tools.
search_budget_tokens int 4000 Token budget for search_code results.
command_timeout float 20.0 Timeout, in seconds, for any subprocess.
**kwargs Any {} Forwarded to AbstractToolkit.__init__.

Method ReadOnlyRepoToolkit.read_file

Read a text file from the repository, optionally a line range.

Use this after search_code has told you which file to open. Paths are relative to the repository root; paths outside it are refused, as are secret files such as .env or private keys. Large files are truncated — pass start/end to page through one instead.

read_file(path: str, start: int = 1, end: int = 0) -> RepoReadResult | RepoToolError

Parameter Type Default Description
path str Repository-relative path, e.g. "pkg/sub/mod.py".
start int 1 1-based first line to return. Defaults to the file start.
end int 0 1-based last line, inclusive. 0 (the default) means end of file.

Returns: RepoReadResult | RepoToolError — RepoReadResult with the content, or RepoToolError if refused.

Method ReadOnlyRepoToolkit.list_files

List files and directories under a repository path.

Use this to explore repository structure before reading a file. Skips VCS/build/cache directories and any secret files. Results are bounded — increase depth sparingly on large trees.

list_files(path: str = '.', depth: int = 1) -> dict[str, Any]

Parameter Type Default Description
path str '.' Repository-relative directory to list. Defaults to root.
depth int 1 How many directory levels to recurse. 1 means immediate children only.

Returns: dict[str, Any] — A dict with path, files (repo-relative paths) and truncated, or a RepoToolError-shaped dict if path is refused.

Method ReadOnlyRepoToolkit.grep_files

Search the repository for a literal string.

Prefer search_code for conceptual or symbol lookups — it is ranked and ignores build artifacts. Use grep_files for exact strings, config values, or anything not indexed by the code graph. The pattern is matched literally (not as a regex). Secret files (e.g. .env, private keys) are never included in results.

grep_files(pattern: str, glob: str = '') -> RepoSearchResult | RepoToolError

Parameter Type Default Description
pattern str The literal string to search for.
glob str '' Optional glob restricting which files are searched.

Returns: RepoSearchResult | RepoToolError — A RepoSearchResult with matching hits (never an error result for zero matches — that is a normal, empty result).

Method ReadOnlyRepoToolkit.git_log

List recent commits, optionally only those touching one path.

Use this to understand why code looks the way it does, or to find when a behaviour changed. Paths are relative to the repository root.

git_log(path: str = '', limit: int = 20) -> dict[str, Any] | RepoToolError

Parameter Type Default Description
path str '' Repository-relative path to filter by. Empty = whole repo.
limit int 20 Maximum commits to return (clamped to 200).

Returns: dict[str, Any] | RepoToolError — Mapping with a commits list of {sha, author, date, subject}, or RepoToolError when the path is refused or git is unavailable.

Method ReadOnlyRepoToolkit.git_show

Show a commit's message and change summary.

Use this to see what a specific commit changed and why. ref may be a sha, branch, tag, or a relative ref such as HEAD~3.

git_show(ref: str) -> dict[str, Any] | RepoToolError

Parameter Type Default Description
ref str A commit sha, branch, tag, or ref such as "HEAD~3".

Returns: dict[str, Any] | RepoToolError — Mapping with commit_info (sha/author/date/subject) and stat (the diffstat text, bounded and possibly truncated), or a RepoToolError when the ref is unsafe or git fails.

Method ReadOnlyRepoToolkit.git_blame

Show per-line commit attribution for a file.

Use this to find who last changed a specific line and in which commit. Secret files are refused, since blame output includes the file's content.

git_blame(path: str, start: int = 1, end: int = 0) -> dict[str, Any] | RepoToolError

Parameter Type Default Description
path str Repository-relative path to blame.
start int 1 1-based first line to blame.
end int 0 1-based last line, inclusive. 0 (the default) means EOF.

Returns: dict[str, Any] | RepoToolError — Mapping with a lines list of {line, sha, author, summary, content}, or a RepoToolError when the path is refused or git fails.

Method ReadOnlyRepoToolkit.search_code

Search the codebase's structural index for relevant files and modules.

PREFER THIS over grep_files for any question about where something lives or how modules relate: it returns ranked, deduplicated results with summaries and skips build artifacts, where grep returns raw unranked line matches. Use grep_files only for exact strings, regexes, or config values this index does not cover.

search_code(query: str, top_k: int = 12, mode: Literal['lexical', 'vector', 'combined'] | None = None) -> RepoSearchResult

Parameter Type Default Description
query str What you are looking for — name the symbol, module or subsystem, not your theory about where it might be.
top_k int 12 Maximum results to return.
mode Literal['lexical', 'vector', 'combined'] | None None "lexical" (default) matches names and text — best for symbols and modules. "combined" also considers semantic similarity where available. "vector" is semantic only. When semantic search is not configured, these fall back to lexical and the result is marked degraded.

Returns: RepoSearchResult — RepoSearchResult. Check degraded: when True, the structural index was unavailable (or returned nothing usable) and these are weaker grep-based results, or the mode itself degraded.

Method ReadOnlyRepoToolkit.related_code

Find pages related to a page returned by search_code.

Use this to explore what a file/module contains or connects to (e.g. a directory's files, an import relationship) via the code graph's typed edges.

related_code(page_id: str) -> RepoSearchResult

Parameter Type Default Description
page_id str A page id previously returned by search_code.

Returns: RepoSearchResult — RepoSearchResult with neighbouring pages as hits, or a degraded result when the structural index is unavailable.

Method ReadOnlyRepoToolkit.web_search

Search the public web.

Use only for information outside this repository — library documentation, error messages, upstream changes. For anything about this codebase, use search_code instead.

web_search(query: str, max_results: int = 5) -> dict[str, Any]

Parameter Type Default Description
query str What to search the web for.
max_results int 5 Maximum results to return.

Returns: dict[str, Any] — Mapping with a results list, or an error key when web search is unavailable.

Alias RelatedCodeInput

Re-exported from parrot.tools.repo.schemas.RelatedCodeInput.

Alias RepoReadResult

Re-exported from parrot.tools.repo.models.RepoReadResult.

Alias RepoSearchHit

Re-exported from parrot.tools.repo.models.RepoSearchHit.

Alias RepoSearchResult

Re-exported from parrot.tools.repo.models.RepoSearchResult.

Alias RepoToolError

Re-exported from parrot.tools.repo.models.RepoToolError.

Alias SHOW_FORMAT

Re-exported from parrot.tools.repo.git_tools.SHOW_FORMAT.

Alias SearchCodeInput

Re-exported from parrot.tools.repo.schemas.SearchCodeInput.

Alias SecretFileError

Re-exported from parrot.tools.repo.confinement.SecretFileError.

Alias WebSearchInput

Re-exported from parrot.tools.repo.schemas.WebSearchInput.

Alias is_secret_path

Re-exported from parrot.tools.repo.confinement.is_secret_path.

Alias map_neighbor_hit

Re-exported from parrot.tools.repo.graph_search.map_neighbor_hit.

Alias map_search_hit

Re-exported from parrot.tools.repo.graph_search.map_search_hit.

Alias open_plane

Re-exported from parrot.tools.repo.graph_search.open_plane.

Alias pack_results

Re-exported from parrot.knowledge.wiki.context.pack_results.

Alias parse_blame

Re-exported from parrot.tools.repo.git_tools.parse_blame.

Alias parse_log

Re-exported from parrot.tools.repo.git_tools.parse_log.

Alias resolve_readable_path

Re-exported from parrot.tools.repo.confinement.resolve_readable_path.

Alias resolve_within_root

Re-exported from parrot.tools.repo.confinement.resolve_within_root.

Alias split_show_output

Re-exported from parrot.tools.repo.git_tools.split_show_output.

Alias tool_schema

Re-exported from parrot.tools.decorators.tool_schema.

Alias validate_ref

Re-exported from parrot.tools.repo.git_tools.validate_ref.

Alias wiki_search_module

Re-exported from parrot.knowledge.wiki.search.

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