api-squash 0.1.0__tar.gz
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.
- api_squash-0.1.0/.github/workflows/ci.yml +38 -0
- api_squash-0.1.0/.github/workflows/publish.yml +22 -0
- api_squash-0.1.0/.gitignore +207 -0
- api_squash-0.1.0/AGENTS.md +27 -0
- api_squash-0.1.0/CONTRIBUTING.md +74 -0
- api_squash-0.1.0/PKG-INFO +6 -0
- api_squash-0.1.0/README.md +195 -0
- api_squash-0.1.0/docs/skills/api-squash-cli/README.md +23 -0
- api_squash-0.1.0/docs/skills/api-squash-cli/claude/SKILL.md +174 -0
- api_squash-0.1.0/docs/skills/api-squash-cli/copilot/SKILL.md +178 -0
- api_squash-0.1.0/docs/skills/python-code-context/README.md +24 -0
- api_squash-0.1.0/docs/skills/python-code-context/claude/SKILL.md +108 -0
- api_squash-0.1.0/docs/skills/python-code-context/copilot/SKILL.md +111 -0
- api_squash-0.1.0/docs/superpowers/plans/2026-04-09-api-squash-implementation.md +1528 -0
- api_squash-0.1.0/docs/superpowers/specs/2026-04-09-api-squash-design.md +215 -0
- api_squash-0.1.0/pyproject.toml +25 -0
- api_squash-0.1.0/src/api_squash/__init__.py +0 -0
- api_squash-0.1.0/src/api_squash/cli.py +80 -0
- api_squash-0.1.0/src/api_squash/extractor.py +109 -0
- api_squash-0.1.0/src/api_squash/models.py +24 -0
- api_squash-0.1.0/src/api_squash/renderer.py +104 -0
- api_squash-0.1.0/src/api_squash/scanner.py +66 -0
- api_squash-0.1.0/tests/__init__.py +0 -0
- api_squash-0.1.0/tests/test_cli.py +113 -0
- api_squash-0.1.0/tests/test_cross_platform.py +66 -0
- api_squash-0.1.0/tests/test_extractor.py +187 -0
- api_squash-0.1.0/tests/test_models.py +57 -0
- api_squash-0.1.0/tests/test_renderer.py +201 -0
- api_squash-0.1.0/tests/test_scanner.py +117 -0
- api_squash-0.1.0/uv.lock +335 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, develop]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main, develop]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v6
|
|
14
|
+
- uses: astral-sh/setup-uv@v7
|
|
15
|
+
with:
|
|
16
|
+
enable-cache: true
|
|
17
|
+
- run: uv run ruff check src/ tests/
|
|
18
|
+
- run: uv run ruff format --check src/ tests/
|
|
19
|
+
|
|
20
|
+
test:
|
|
21
|
+
runs-on: ${{ matrix.os }}
|
|
22
|
+
strategy:
|
|
23
|
+
fail-fast: false
|
|
24
|
+
matrix:
|
|
25
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
26
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v6
|
|
29
|
+
- uses: astral-sh/setup-uv@v7
|
|
30
|
+
with:
|
|
31
|
+
python-version: ${{ matrix.python-version }}
|
|
32
|
+
enable-cache: true
|
|
33
|
+
- run: uv sync --locked --dev
|
|
34
|
+
- run: uv run pytest -v --cov=api_squash --cov-report=xml
|
|
35
|
+
- if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13'
|
|
36
|
+
uses: codecov/codecov-action@v5
|
|
37
|
+
with:
|
|
38
|
+
files: coverage.xml
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
environment: pypi
|
|
11
|
+
permissions:
|
|
12
|
+
id-token: write
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v6
|
|
15
|
+
- uses: astral-sh/setup-uv@v7
|
|
16
|
+
- run: uv python install 3.13
|
|
17
|
+
- run: uv build
|
|
18
|
+
- name: Smoke test (wheel)
|
|
19
|
+
run: uv run --isolated --no-project --with dist/*.whl -- python -c "from api_squash.cli import cli; print('ok')"
|
|
20
|
+
- name: Smoke test (sdist)
|
|
21
|
+
run: uv run --isolated --no-project --with dist/*.tar.gz -- python -c "from api_squash.cli import cli; print('ok')"
|
|
22
|
+
- run: uv publish
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
## Build & Run
|
|
4
|
+
|
|
5
|
+
- **Package manager:** uv
|
|
6
|
+
- **Install deps:** `uv sync`
|
|
7
|
+
- **Run tests:** `uv run pytest -v`
|
|
8
|
+
- **Lint:** `uv run ruff check src/ tests/`
|
|
9
|
+
- **Format:** `uv run ruff format src/ tests/`
|
|
10
|
+
- **CLI:** `uv run api-squash --help`
|
|
11
|
+
|
|
12
|
+
> **Note:** Python is not directly on PATH in this environment. Always use `uv run` for all Python commands.
|
|
13
|
+
|
|
14
|
+
## Project Structure
|
|
15
|
+
|
|
16
|
+
- Source code: `src/api_squash/`
|
|
17
|
+
- Tests: `tests/`
|
|
18
|
+
- Specs: `docs/superpowers/specs/`
|
|
19
|
+
- Plans: `docs/superpowers/plans/`
|
|
20
|
+
|
|
21
|
+
## Conventions
|
|
22
|
+
|
|
23
|
+
- TDD: Write failing tests first, then implement
|
|
24
|
+
- Use `pathlib.Path` throughout, never raw string paths
|
|
25
|
+
- Output uses forward slashes in file path headers regardless of OS
|
|
26
|
+
- All file I/O uses `encoding="utf-8"` explicitly
|
|
27
|
+
- Frequent, atomic commits with conventional commit messages
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributing to api-squash
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing! This document describes the branching
|
|
4
|
+
strategy and workflow used in this project.
|
|
5
|
+
|
|
6
|
+
## Branching Strategy
|
|
7
|
+
|
|
8
|
+
We use a **gitflow-style** branching model:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
main ← production-ready, tagged releases only
|
|
12
|
+
└── develop ← integration branch, always ahead of or equal to main
|
|
13
|
+
├── feature/ ← new features
|
|
14
|
+
├── fix/ ← bug fixes
|
|
15
|
+
└── chore/ ← maintenance tasks
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- **`main`** — stable, release-only branch. Every commit on `main` is a
|
|
19
|
+
tagged release.
|
|
20
|
+
- **`develop`** — integration branch where feature and fix branches merge
|
|
21
|
+
into. This is the default branch.
|
|
22
|
+
|
|
23
|
+
## Development Workflow
|
|
24
|
+
|
|
25
|
+
### Feature / Fix / Chore
|
|
26
|
+
|
|
27
|
+
1. Branch from `develop`:
|
|
28
|
+
```bash
|
|
29
|
+
git checkout develop
|
|
30
|
+
git pull origin develop
|
|
31
|
+
git checkout -b feature/my-feature # or fix/, chore/
|
|
32
|
+
```
|
|
33
|
+
2. Make frequent, atomic commits using
|
|
34
|
+
[conventional commit](https://www.conventionalcommits.org/) messages
|
|
35
|
+
(e.g. `feat: add parser`, `fix: handle empty input`).
|
|
36
|
+
3. Open a pull request targeting **`develop`**.
|
|
37
|
+
4. After review, merge into `develop` (squash-merge or regular merge).
|
|
38
|
+
|
|
39
|
+
### Releases
|
|
40
|
+
|
|
41
|
+
1. When `develop` is ready for release, open a PR from `develop` → `main`.
|
|
42
|
+
2. Review and merge into `main`.
|
|
43
|
+
3. Tag the merge commit on `main` with a semver tag (e.g. `v0.2.0`).
|
|
44
|
+
4. Merge `main` back into `develop` to pick up the merge/tag commit.
|
|
45
|
+
|
|
46
|
+
### Hotfixes
|
|
47
|
+
|
|
48
|
+
1. Branch from `main` → `fix/<description>`.
|
|
49
|
+
2. Fix the issue, open a PR into `main`, and tag a patch release.
|
|
50
|
+
3. Merge `main` back into `develop` to keep branches in sync.
|
|
51
|
+
|
|
52
|
+
## Development Setup
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Requires Python >= 3.10 and uv (https://docs.astral.sh/uv/)
|
|
56
|
+
uv sync
|
|
57
|
+
|
|
58
|
+
# Run tests
|
|
59
|
+
uv run pytest -v
|
|
60
|
+
|
|
61
|
+
# Lint
|
|
62
|
+
uv run ruff check src/ tests/
|
|
63
|
+
|
|
64
|
+
# Format
|
|
65
|
+
uv run ruff format src/ tests/
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Code Conventions
|
|
69
|
+
|
|
70
|
+
- **TDD** — write failing tests first, then implement.
|
|
71
|
+
- Use `pathlib.Path` throughout; never use raw string paths.
|
|
72
|
+
- All file I/O uses `encoding="utf-8"` explicitly.
|
|
73
|
+
- Output uses forward slashes in file path headers regardless of OS.
|
|
74
|
+
- Use conventional commit messages (`feat:`, `fix:`, `chore:`, `docs:`, etc.).
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# api-squash
|
|
2
|
+
|
|
3
|
+
> Extract Python API surfaces in a compact, token-efficient format.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/b-j-karl/api-squash/actions/workflows/ci.yml)
|
|
6
|
+
[](https://codecov.io/gh/b-j-karl/api-squash)
|
|
7
|
+
[](https://www.python.org/downloads/)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Agentic AI workflows need to understand a codebase's API surface without
|
|
13
|
+
burning context on implementation details. Pasting entire source files into a
|
|
14
|
+
prompt wastes tokens on function bodies, comments, and boilerplate that the
|
|
15
|
+
agent doesn't need.
|
|
16
|
+
|
|
17
|
+
**api-squash** parses Python source files using the AST and produces concise
|
|
18
|
+
Markdown summaries containing only the public API surface — classes, functions,
|
|
19
|
+
and their signatures — so AI agents can ingest a full project's interface in a
|
|
20
|
+
fraction of the tokens.
|
|
21
|
+
|
|
22
|
+
Built for agentic AI workflows: code-generation agents, autonomous refactoring
|
|
23
|
+
pipelines, and any system where an LLM needs to reason about code structure
|
|
24
|
+
programmatically.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install api-squash
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
For development:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Requires the uv package manager (https://docs.astral.sh/uv/)
|
|
36
|
+
uv sync
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
Summarize a single file:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
api-squash file path/to/module.py
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Summarize an entire project:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
api-squash project path/to/project/
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Example
|
|
54
|
+
|
|
55
|
+
Given a file `example_api.py`:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
"""Client for the Acme API."""
|
|
59
|
+
|
|
60
|
+
from dataclasses import dataclass
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@dataclass
|
|
64
|
+
class Config:
|
|
65
|
+
"""Connection settings."""
|
|
66
|
+
host: str
|
|
67
|
+
port: int = 443
|
|
68
|
+
timeout: float = 30.0
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class AcmeClient:
|
|
72
|
+
"""High-level client for the Acme REST API."""
|
|
73
|
+
|
|
74
|
+
def __init__(self, config: Config) -> None:
|
|
75
|
+
self._config = config
|
|
76
|
+
|
|
77
|
+
async def get_user(self, user_id: int) -> dict:
|
|
78
|
+
"""Fetch a single user by ID."""
|
|
79
|
+
...
|
|
80
|
+
|
|
81
|
+
async def list_users(self, *, active: bool = True) -> list[dict]:
|
|
82
|
+
"""Return all users, optionally filtered."""
|
|
83
|
+
...
|
|
84
|
+
|
|
85
|
+
def _build_url(self, path: str) -> str:
|
|
86
|
+
...
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Running `api-squash file example_api.py` produces:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
# example_api.py
|
|
93
|
+
|
|
94
|
+
class Config:
|
|
95
|
+
Connection settings.
|
|
96
|
+
|
|
97
|
+
class AcmeClient:
|
|
98
|
+
High-level client for the Acme REST API.
|
|
99
|
+
def __init__(self, config: Config) -> None
|
|
100
|
+
async def get_user(self, user_id: int) -> dict
|
|
101
|
+
Fetch a single user by ID.
|
|
102
|
+
async def list_users(self, *, active: bool = True) -> list[dict]
|
|
103
|
+
Return all users, optionally filtered.
|
|
104
|
+
def _build_url(self, path: str) -> str
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
With `--no-docstrings --no-private`, the output shrinks further:
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
# example_api.py
|
|
111
|
+
|
|
112
|
+
class Config:
|
|
113
|
+
|
|
114
|
+
class AcmeClient:
|
|
115
|
+
def __init__(self, config: Config) -> None
|
|
116
|
+
async def get_user(self, user_id: int) -> dict
|
|
117
|
+
async def list_users(self, *, active: bool = True) -> list[dict]
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## CLI Reference
|
|
121
|
+
|
|
122
|
+
### `api-squash file`
|
|
123
|
+
|
|
124
|
+
Summarize a single Python file.
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
Usage: api-squash file [OPTIONS] PATH
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
| Option | Description |
|
|
131
|
+
|---|---|
|
|
132
|
+
| `--no-docstrings` | Strip all docstrings from the output |
|
|
133
|
+
| `--no-private` | Skip private methods (names starting with `_`), except `__init__` |
|
|
134
|
+
|
|
135
|
+
### `api-squash project`
|
|
136
|
+
|
|
137
|
+
Summarize all Python files in a directory.
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
Usage: api-squash project [OPTIONS] PATH
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
| Option | Description |
|
|
144
|
+
|---|---|
|
|
145
|
+
| `--max-depth INTEGER` | Limit directory recursion depth |
|
|
146
|
+
| `--exclude TEXT` | Glob patterns to exclude (can be repeated) |
|
|
147
|
+
| `--no-docstrings` | Strip all docstrings from the output |
|
|
148
|
+
| `--no-private` | Skip private methods (names starting with `_`), except `__init__` |
|
|
149
|
+
|
|
150
|
+
Common directories like `__pycache__`, `.venv`, `.git`, `node_modules`,
|
|
151
|
+
`build`, and `dist` are skipped automatically.
|
|
152
|
+
|
|
153
|
+
## Output Format
|
|
154
|
+
|
|
155
|
+
api-squash produces Markdown-style output designed for easy reading and
|
|
156
|
+
token-efficient LLM consumption:
|
|
157
|
+
|
|
158
|
+
- **File headers** — each module starts with `# path/to/file.py`
|
|
159
|
+
- **Classes** — rendered as `class Name(Base):` with docstrings indented below
|
|
160
|
+
- **Functions / methods** — rendered as `def name(signature) -> return_type`
|
|
161
|
+
with docstrings indented below
|
|
162
|
+
- **Separators** — in project mode, modules are separated by `---`
|
|
163
|
+
|
|
164
|
+
## Development
|
|
165
|
+
|
|
166
|
+
**Prerequisites:** Python ≥ 3.10, [uv](https://docs.astral.sh/uv/)
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Install dependencies
|
|
170
|
+
uv sync
|
|
171
|
+
|
|
172
|
+
# Run tests
|
|
173
|
+
uv run pytest -v
|
|
174
|
+
|
|
175
|
+
# Lint
|
|
176
|
+
uv run ruff check src/ tests/
|
|
177
|
+
|
|
178
|
+
# Format
|
|
179
|
+
uv run ruff format src/ tests/
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Project Structure
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
src/api_squash/
|
|
186
|
+
├── cli.py # Click CLI entry points
|
|
187
|
+
├── extractor.py # AST-based API extraction
|
|
188
|
+
├── models.py # Data models (ModuleSummary, ClassSummary, FunctionSummary)
|
|
189
|
+
├── renderer.py # Markdown output rendering
|
|
190
|
+
└── scanner.py # Directory scanning with exclusion patterns
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# api-squash-cli Skill
|
|
2
|
+
|
|
3
|
+
Pre-built skills for teaching AI coding agents how to use `api-squash`.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### Copilot CLI
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Copy the Copilot skill into your user skills directory
|
|
11
|
+
cp -r copilot ~/.copilot/skills/api-squash-cli
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### Claude Code
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Copy the Claude skill into your user skills directory
|
|
18
|
+
cp -r claude ~/.claude/skills/api-squash-cli
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
After installing, the skill will auto-trigger when you ask your agent to
|
|
22
|
+
summarise a Python API, understand codebase structure, or gather interface
|
|
23
|
+
context before code generation.
|