Skip to main content

CLI tool for finding Python function definitions using ty's LSP server

Project description

ty-find

An LSP adapter for AI coding agents. Symbol name in, structured code intelligence out.

LSP servers are the gold standard for code navigation — but they require file positions (file.py:29:7). LLMs think in symbol names (MyClass). To use an LSP, an LLM first has to grep for the position, which is imprecise and adds a round-trip. tyf bridges this gap: one command gives you definition, signature, and references — by name, no file paths needed.

$ tyf show list_animals
# Definition (func)
main.py:14:1

# Signature
def list_animals(animals: list[Animal]) -> None

# Refs: 2 across 1 file(s)

$ tyf show list_animals --all    # add docs, refs, test refs

Built for: Claude Code, Codex, Cursor, Gemini CLI — and humans who want fast terminal-based navigation.

Why tyf?

vs grep/ripgrep:

  • grep matches text — tyf understands Python's type system
  • grep returns hits in comments, strings, and docstrings; tyf returns only real symbol references

vs raw LSP (in editors):

  • LSP requires file:line:col positions to answer queries
  • An LLM doesn't know positions without searching first
  • Searching with grep is imprecise — circular problem
  • tyf accepts symbol names directly, resolves positions internally

Usage with Claude Code

Add this to your project's CLAUDE.md to enable type-aware code navigation:

### Python Symbol Navigation — `tyf`

This project has `tyf` — a type-aware code search that gives LSP-quality
results by symbol name. Use `tyf` instead of grep/ripgrep for Python symbol lookups.

- `tyf show my_function` — definition + signature (add `-d` docs, `-r` refs, `-t` test refs, or `--all`)
- `tyf find MyClass` — find definition location
- `tyf refs my_function` — all usages (before refactoring)
- `tyf members TheirClass` — class public API
- `tyf list file.py` — file outline

All commands accept multiple symbols — batch to save tool calls.
Run `tyf <cmd> --help` for options.

Use grep for: string literals, config values, TODOs, non-Python files.

Installation

Prerequisite: ty type checker (uv add --dev ty)

Optional: ripgrep (rg) — speeds up lookups for non-existent symbols by quickly verifying whether a symbol appears in any .py file before retrying LSP queries. Without it, searches for non-existent symbols still work but may be slower.

# macOS
brew install ripgrep

# Ubuntu/Debian
sudo apt install ripgrep

# Or via cargo
cargo install ripgrep
uv add --dev ty-find

Note: On Windows, only tyf find --file is supported for now. All other commands require Unix domain sockets (Linux, macOS).

Usage

Show (Definition + Signature + References)

All-in-one command — searches the workspace by symbol name, no file needed. Add -d (docs), -r (references), -t (test refs), or --all for everything:

tyf show calculate_sum

# Multiple symbols at once
tyf show calculate_sum UserService Config

# Include docstring + refs + test refs
tyf show calculate_sum --all

# Narrow to a specific file
tyf show calculate_sum --file src/math.py

Find Symbol by Name

Searches the workspace for a symbol's definition. Supports multiple symbols in a single call. Use --fuzzy for partial/prefix matching with richer output (kind + container):

tyf find calculate_sum

# Find multiple symbols at once (results grouped by symbol)
tyf find calculate_sum multiply divide

# Narrow to a specific file (text-based search + goto_definition)
tyf find function_name --file myfile.py

# Fuzzy/prefix match (returns symbol kind + container info)
tyf find handle_ --fuzzy

Find References

# By position (exact, pipeable from list)
tyf refs -f myfile.py --line 10 --column 5

# By name
tyf refs my_function MyClass

# Mixed and piped
tyf refs file.py:10:5 my_func
... | tyf refs --stdin

Members (Class Public API)

tyf members MyClass

Document Outline

tyf list src/services/user.py

Daemon Management

The daemon starts automatically on first use. Run tyf daemon --help for manual control.

Output Formats

All commands support --format (placed before the subcommand): human (default), json, csv, paths.

tyf --format json show MyClass
tyf --format csv find User --fuzzy

Architecture

CLI Command → Daemon Client (auto-connects) → Unix Socket
→ Daemon Server (5min idle timeout) → LSP Client Pool → ty LSP Server

The daemon keeps LSP connections warm: first command takes 1-2s, subsequent commands 50-100ms. See How it works for details.

Development

cargo build --release
cargo test
cargo clippy
cargo fmt --check

# Verbose logging
RUST_LOG=ty_find=debug cargo run -- find hello_world

Testing / supported ty versions

tyf does not ship ty — it drives whatever ty LSP server you have installed. ty is 0.0.x and changes frequently, so the integration suite is run in CI against a curated set of pinned, exact ty versions on every push and PR (and on dependabot ty bumps).

The tested floor is 0.0.15 and the current latest tested is 0.0.49. This is a practical baseline, not a hard limit: the suite behaves identically (same output, same ~180ms cold start) across the whole modern range — genuine capability gaps only exist in ty ≤ 0.0.5, which don't return multi-file workspace symbols (0.0.1 has no Linux glibc wheel at all).

The exact list of tested versions is the single source of truth in ci/ty-versions.json; the methodology and per-version findings are in docs/dev/TY_VERSIONS.md.

Troubleshooting

# Check ty is installed
ty --version

# Debug daemon issues
tyf daemon status
RUST_LOG=ty_find=debug tyf daemon start

# Restart daemon
tyf daemon stop && tyf daemon start

Contributing

Contributions welcome! Please open an issue to discuss major changes.

License

MIT License - see LICENSE file for details.

Credits

Built with ty - Astral's Python type checker.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ty_find-0.4.1.tar.gz (999.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ty_find-0.4.1-py3-none-win_amd64.whl (809.8 kB view details)

Uploaded Python 3Windows x86-64

ty_find-0.4.1-py3-none-manylinux_2_28_x86_64.whl (1.2 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

ty_find-0.4.1-py3-none-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file ty_find-0.4.1.tar.gz.

File metadata

  • Download URL: ty_find-0.4.1.tar.gz
  • Upload date:
  • Size: 999.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ty_find-0.4.1.tar.gz
Algorithm Hash digest
SHA256 4f6a80331bc60ef299aa6e520d03765fb2e47aff4e7c296de2b922dca9499b3f
MD5 219a601baec681b389e49574dabab81f
BLAKE2b-256 fc22c1fd1a6602ef32e4e7904ffc11c9ecba65ceb388ed822ceed2cd87e5f90e

See more details on using hashes here.

Provenance

The following attestation bundles were made for ty_find-0.4.1.tar.gz:

Publisher: release.yml on mojzis/ty-find

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ty_find-0.4.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: ty_find-0.4.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 809.8 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ty_find-0.4.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 8a2cea2451f9a6d658afc7680f513abf38a731ede25b61eff71da49daa09cdd2
MD5 a033b2b1d56ec1e6667822475487309e
BLAKE2b-256 1fc0dfdcb7cac09d095f5b8cee35b905ffebee17d77d0044289a7e5f9792d17f

See more details on using hashes here.

Provenance

The following attestation bundles were made for ty_find-0.4.1-py3-none-win_amd64.whl:

Publisher: release.yml on mojzis/ty-find

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ty_find-0.4.1-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for ty_find-0.4.1-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1f384cd704a69a89e3c07eae4ecb5561ddf7acb5bed3923fdc8b2998c1c5ae91
MD5 ae521f9b0e37353c09383578f0a0855b
BLAKE2b-256 45368cc19f80c17c85b129aa7222c0a713ee2d996b0937dbbc7dfa77ffcc1459

See more details on using hashes here.

Provenance

The following attestation bundles were made for ty_find-0.4.1-py3-none-manylinux_2_28_x86_64.whl:

Publisher: release.yml on mojzis/ty-find

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ty_find-0.4.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ty_find-0.4.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5d5b1ee2b19523952f2e598cdc51a3f43f8db64858f8ad8a78de59fb64aa2710
MD5 49ec2f681c1abd962416c7f9d806f2b2
BLAKE2b-256 c2198fd6e6f97d469a5c8127c958a2850d06fb17b7598b0c3ad676b27d25d355

See more details on using hashes here.

Provenance

The following attestation bundles were made for ty_find-0.4.1-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on mojzis/ty-find

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page