tools

package module
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

README

tools

tools provides ready-to-assemble executable tools: shell, filesystem, HTTP, web fetch, web search, and Agent Skills. Each one is a plain core/tool.Tool, so a chat client, an Agent, or an MCP server consumes them through the same contract.

The tool protocol itself, typed functions, and the registry live in core/tool; schemas are derived by core/jsonschema. This module only implements capability.

Install

go get github.com/Tangerg/scope/tools

Packages

Package Capability
shell Run a command and capture its output
fs Read, write, edit, glob, and grep inside a fixed path authority
textread Read text with line numbering and limits
httpreq Issue an HTTP request against an explicit allowlist
web Neutral Searcher and Fetcher SPIs plus the search and fetch tools
web/brave, web/exa, web/firecrawl, web/jina, web/perplexity, web/serper, web/tavily Provider implementations of those SPIs
skills Expose an Agent Skills repository as a callable tool

Assembling a toolset

There is no global registry. A caller registers exactly what it wants:

registry, err := tool.NewRegistry(
    fs.NewReadTool(fs.NewLocalExecutor(root)),
    fs.NewGlobTool(fs.NewLocalExecutor(root)),
    shell.NewTool(nil),
)
if err != nil {
    return err
}

New(nil) means "use the local backend" for capabilities that have one (shell, fs). For capabilities that must be configured (web, httpreq) it returns an error instead — there is no safe local fallback for a network call.

Two tiers

Every capability is split in two:

  • The Tool tier faces the model: JSON in, JSON out, schema validation.
  • The Backend Port tier does the work and holds all the domain logic — line numbering, binary detection, write locks, path authority.

That split is what lets a remote or sandboxed backend answer a glob or grep in one round trip instead of listing and reading through the Tool tier.

Concurrency

A tool may declare, per call, whether it can overlap others and what it conflicts on. Reads declare no conflict and run in parallel; an edit or write keys on its target path, so the loop parallelizes different files and serializes the same file.

Web search and fetch

Every provider returns the same web.SearchResponse and web.FetchResponse, so the model never adapts to a vendor API. A provider needs a key:

searcher, err := tavily.NewSearcher(tavily.Config{APIKey: key})
if err != nil {
    return err
}
searchTool, err := web.NewSearchTool(searcher)

The neutral Recency filter (hour, day, week, month, year) is translated into each provider's native freshness syntax.

Limits

Output over a limit is truncated and marked, never turned into an error, so the model can decide what to do next.

See ARCHITECTURE.md for the boundaries these rules rest on.

Documentation

Overview

Package tools is the module overview for Scope's ready-to-assemble tools. It declares no API of its own; every capability lives in a subpackage.

This module implements executable capability only. The tool protocol, typed functions, and the registry belong to core/tool; schemas are derived by core/jsonschema. Every capability here is an ordinary core/tool.Tool, so a chat client, an Agent, or an MCP server consumes them through one contract.

Capabilities

  • shell: run a command and capture its output.
  • fs: read, write, edit, glob, and grep inside a fixed path authority.
  • textread: read text with line numbering and limits.
  • httpreq: issue an HTTP request against an explicit allowlist.
  • web: the neutral Searcher and Fetcher SPIs plus the search and fetch tools, with one provider package per vendor.
  • skills: expose an Agent Skills repository as a callable tool.

Two tiers

Every capability is split in two. The Tool tier faces the model: JSON in, JSON out, schema validation. The Backend Port tier does the work and holds all the domain logic — line numbering, binary detection, write locks, path authority. That split is what lets a remote or sandboxed backend answer a glob or grep in one round trip instead of listing and reading through the Tool tier.

Assembly

There is no global registry: a caller registers exactly the tools it wants. New(nil) means "use the local backend" for a capability that has one, such as shell and fs. For a capability that must be configured, such as web and httpreq, New(nil) returns an error, because there is no safe local fallback for a network call.

Concurrency and limits

A tool may declare, per call, whether it can overlap others and what it conflicts on. Reads declare no conflict; an edit or write keys on its target path, so the loop parallelizes different files and serializes the same file. Output over a limit is truncated and marked, never turned into an error, so the model can decide what to do next.

See README.md for usage and ARCHITECTURE.md for the invariants these boundaries rest on.

Directories

Path Synopsis
Package fs exposes LLM-callable filesystem tools (read, write, edit, glob, grep) on top of minimal per-operation ports.
Package fs exposes LLM-callable filesystem tools (read, write, edit, glob, grep) on top of minimal per-operation ports.
Package httpreq exposes a single model-callable HTTP-request tool.
Package httpreq exposes a single model-callable HTTP-request tool.
Package shell exposes a single LLM-callable shell tool plus a small Executor SPI.
Package shell exposes a single LLM-callable shell tool plus a small Executor SPI.
Package skills exposes three LLM-callable tools that surface Agent Skills to a chat model through progressive disclosure.
Package skills exposes three LLM-callable tools that surface Agent Skills to a chat model through progressive disclosure.
Package textread provides bounded UTF-8 line scanning for filesystem adapters with different consumer result policies.
Package textread provides bounded UTF-8 line scanning for filesystem adapters with different consumer result policies.
web
Package web defines provider-neutral web search and page-fetching tools.
Package web defines provider-neutral web search and page-fetching tools.
brave
Package brave wires Brave's Web Search API into web.Searcher.
Package brave wires Brave's Web Search API into web.Searcher.
exa
Package exa integrates Exa's Search and Contents APIs with the provider-neutral web contracts.
Package exa integrates Exa's Search and Contents APIs with the provider-neutral web contracts.
firecrawl
Package firecrawl integrates Firecrawl's Search and Scrape APIs with the provider-neutral web contracts.
Package firecrawl integrates Firecrawl's Search and Scrape APIs with the provider-neutral web contracts.
jina
Package jina integrates Jina Search and Jina Reader with the provider-neutral web contracts.
Package jina integrates Jina Search and Jina Reader with the provider-neutral web contracts.
perplexity
Package perplexity wires Perplexity's Search API into web.Searcher.
Package perplexity wires Perplexity's Search API into web.Searcher.
serper
Package serper wires Serper's Google Search API into web.Searcher.
Package serper wires Serper's Google Search API into web.Searcher.
tavily
Package tavily integrates Tavily Search and Extract with the provider-neutral web contracts.
Package tavily integrates Tavily Search and Extract with the provider-neutral web contracts.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL