ast-outline-cli 2.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,117 @@
1
+ """ast-outline CLI installer — downloads the Rust binary on first run."""
2
+
3
+ import os
4
+ import sys
5
+ import stat
6
+ import platform
7
+ import subprocess
8
+ from pathlib import Path
9
+
10
+ import httpx
11
+
12
+ VERSION = "2.1.0"
13
+ GITHUB_REPO = "aeroxy/ast-outline"
14
+ BINARY_NAME = "ast-outline"
15
+
16
+
17
+ def get_cache_dir() -> Path:
18
+ if sys.platform == "darwin":
19
+ return Path.home() / "Library" / "Caches" / "ast-outline"
20
+ elif sys.platform == "linux":
21
+ return Path.home() / ".cache" / "ast-outline"
22
+ else:
23
+ return Path.home() / ".cache" / "ast-outline"
24
+
25
+
26
+ def get_platform() -> tuple[str, str]:
27
+ """Return (os, arch) for download URL."""
28
+ system = platform.system().lower()
29
+ machine = platform.machine().lower()
30
+
31
+ os_map = {"darwin": "macos", "linux": "linux", "windows": "windows"}
32
+ arch_map = {"arm64": "arm64", "aarch64": "arm64", "x86_64": "x86_64", "amd64": "x86_64"}
33
+
34
+ os_name = os_map.get(system)
35
+ arch = arch_map.get(machine)
36
+
37
+ if not os_name or not arch:
38
+ raise RuntimeError(
39
+ f"No pre-built binary for {system}/{machine}. "
40
+ f"Build from source: cargo install ast-outline"
41
+ )
42
+
43
+ # Check if pre-built binary exists (only macos-arm64 for now)
44
+ available = {("macos", "arm64")}
45
+ if (os_name, arch) not in available:
46
+ raise RuntimeError(
47
+ f"No pre-built binary for {os_name}-{arch} yet (available: macos-arm64). "
48
+ f"Build from source: cargo install ast-outline"
49
+ )
50
+
51
+ return os_name, arch
52
+
53
+
54
+ def download_binary() -> Path:
55
+ """Download the ast-outline binary to cache dir."""
56
+ cache_dir = get_cache_dir()
57
+ cache_dir.mkdir(parents=True, exist_ok=True)
58
+
59
+ os_name, arch = get_platform()
60
+ ext = ".zip" if os_name == "windows" else ".tar.gz"
61
+ binary_ext = ".exe" if os_name == "windows" else ""
62
+ binary_path = cache_dir / f"{BINARY_NAME}{binary_ext}"
63
+
64
+ # Check if already downloaded
65
+ if binary_path.exists():
66
+ return binary_path
67
+
68
+ url = f"https://github.com/{GITHUB_REPO}/releases/download/{VERSION}/{BINARY_NAME}-{os_name}-{arch}{ext}"
69
+ print(f"Downloading ast-outline {VERSION} for {os_name}-{arch}...")
70
+ print(f" {url}")
71
+
72
+ archive_path = cache_dir / f"archive{ext}"
73
+
74
+ with httpx.Client(follow_redirects=True) as client:
75
+ resp = client.get(url)
76
+ resp.raise_for_status()
77
+ archive_path.write_bytes(resp.content)
78
+
79
+ # Extract
80
+ import tarfile
81
+ import zipfile
82
+
83
+ if ext == ".tar.gz":
84
+ with tarfile.open(archive_path, "r:gz") as tar:
85
+ tar.extractall(path=cache_dir)
86
+ else:
87
+ with zipfile.ZipFile(archive_path) as zf:
88
+ zf.extractall(path=cache_dir)
89
+
90
+ archive_path.unlink()
91
+
92
+ # Make executable
93
+ if sys.platform != "windows":
94
+ binary_path.chmod(binary_path.stat().st_mode | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)
95
+
96
+ print(f"Installed ast-outline to {binary_path}")
97
+ return binary_path
98
+
99
+
100
+ def get_binary_path() -> Path:
101
+ """Get path to the ast-outline binary, downloading if needed."""
102
+ cache_dir = get_cache_dir()
103
+ os_name, _ = get_platform()
104
+ ext = ".exe" if os_name == "windows" else ""
105
+ binary_path = cache_dir / f"{BINARY_NAME}{ext}"
106
+
107
+ if not binary_path.exists():
108
+ return download_binary()
109
+ return binary_path
110
+
111
+
112
+ def main():
113
+ """CLI entry point — forwards to the Rust binary."""
114
+ binary = get_binary_path()
115
+ args = sys.argv[1:]
116
+ result = subprocess.run([str(binary)] + args, cwd=os.getcwd())
117
+ sys.exit(result.returncode)
@@ -0,0 +1,3 @@
1
+ from ast_outline_cli import main
2
+
3
+ main()
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: ast-outline-cli
3
+ Version: 2.1.0
4
+ Summary: Fast, AST-based code-navigation toolkit — downloads the Rust binary on install
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/aeroxy/ast-outline
7
+ Project-URL: Repository, https://github.com/aeroxy/ast-outline
8
+ Project-URL: Documentation, https://github.com/aeroxy/ast-outline#readme
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: httpx>=0.24.0
12
+
13
+ # ast-outline-cli
14
+
15
+ [![PyPI](https://img.shields.io/pypi/v/ast-outline-cli)](https://pypi.org/project/ast-outline-cli/)
16
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/aeroxy/ast-outline/blob/main/LICENSE)
17
+
18
+ CLI installer for [ast-outline](https://github.com/aeroxy/ast-outline) — a fast, AST-based code-navigation toolkit for source files. Downloads the pre-built Rust binary on first run.
19
+
20
+ ## Install
21
+
22
+ ```bash
23
+ pip install ast-outline-cli
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ```bash
29
+ # Map the structure of a file (signatures + line ranges, no bodies)
30
+ ast-outline map src/player.rs
31
+
32
+ # Show the exact source of a specific method
33
+ ast-outline show Player.cs TakeDamage
34
+
35
+ # Compact digest of a whole module
36
+ ast-outline digest src/services/
37
+
38
+ # True public API (resolves pub use / __all__ re-exports)
39
+ ast-outline surface .
40
+
41
+ # Find all implementations of a type
42
+ ast-outline implements IDamageable src/
43
+
44
+ # Dependency graph
45
+ ast-outline deps src/auth.rs --depth 2
46
+ ast-outline reverse-deps src/auth.rs
47
+ ast-outline cycles
48
+
49
+ # Call graph (AST-accurate)
50
+ ast-outline callers TakeDamage
51
+ ast-outline callees Player.TakeDamage
52
+
53
+ # Hybrid BM25 + dense semantic search
54
+ ast-outline search "how does login work"
55
+
56
+ # Find semantically similar code
57
+ ast-outline find-related src/auth/login.rs:42
58
+ ```
59
+
60
+ On first run, the CLI downloads the pre-built binary for your platform from [GitHub releases](https://github.com/aeroxy/ast-outline/releases) and caches it locally.
61
+
62
+ | Platform | Cache directory |
63
+ |---|---|
64
+ | macOS | `~/Library/Caches/ast-outline/` |
65
+ | Linux | `~/.cache/ast-outline/` |
66
+
67
+ ## Supported Platforms
68
+
69
+ | Platform | Status |
70
+ |---|---|
71
+ | macOS ARM64 | Pre-built binary available |
72
+ | Other platforms | Build from source (see below) |
73
+
74
+ For unsupported platforms, build from source:
75
+
76
+ ```bash
77
+ cargo install ast-outline
78
+ ```
79
+
80
+ ## What is ast-outline?
81
+
82
+ [ast-outline](https://github.com/aeroxy/ast-outline) is a fast, AST-based code-navigation toolkit built for LLM coding agents and humans. It uses [tree-sitter](https://github.com/tree-sitter/tree-sitter) via [ast-grep](https://github.com/ast-grep/ast-grep) to parse source files and provide:
83
+
84
+ - **File shape** — `map` / `digest` / `show` for signatures with line ranges (95% token savings vs reading full files)
85
+ - **True public API** — `surface` resolves re-export graphs across Rust, Python, TypeScript, and more
86
+ - **Dependency graph** — `deps` / `reverse-deps` / `cycles` / `graph` for import analysis
87
+ - **Call graph** — `callers` / `callees` with AST accuracy across 14 languages
88
+ - **Semantic search** — hybrid BM25 + dense embeddings via `search` and `find-related`
89
+ - **MCP server** — every command exposed as an MCP tool for LLM agents
90
+
91
+ Supports Rust, Python, TypeScript, JavaScript, Java, C#, Kotlin, Scala, Go, PHP, Ruby, SQL, and Markdown.
92
+
93
+ ## Links
94
+
95
+ - [ast-outline source code](https://github.com/aeroxy/ast-outline)
96
+ - [npm package](https://www.npmjs.com/package/@ast-outline/cli) (Node.js installer)
97
+ - [crates.io](https://crates.io/crates/ast-outline) (Rust library)
98
+
99
+ ## License
100
+
101
+ [MIT](https://github.com/aeroxy/ast-outline/blob/main/LICENSE)
@@ -0,0 +1,7 @@
1
+ ast_outline_cli/__init__.py,sha256=F00ZgOwO6iAdwes2suMhZ9SrKejWK9pBQySITEwaJAM,3507
2
+ ast_outline_cli/__main__.py,sha256=9AxeJX7Z2wuYiWJZXeI4MuP1RMpoduTjhhtGtOCJFSk,41
3
+ ast_outline_cli-2.1.0.dist-info/METADATA,sha256=8HJ51ZdSkpa6OC8KiOndwcqu6NmrHDjQi974gXZTM6U,3574
4
+ ast_outline_cli-2.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
5
+ ast_outline_cli-2.1.0.dist-info/entry_points.txt,sha256=FyEnLtu8pfQDJkatbViREiVxH3-l6MbDdtmmCADeo8g,53
6
+ ast_outline_cli-2.1.0.dist-info/top_level.txt,sha256=dBmBeo178aLD2igGWw-0yZIfctOGEta3UcJuPFC00zs,16
7
+ ast_outline_cli-2.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ast-outline = ast_outline_cli:main
@@ -0,0 +1 @@
1
+ ast_outline_cli