Skip to content

Commit 64f3bbc

Browse files
committed
docs: contributor experience overhaul
Makefile - make check (lint + typecheck + tests) — the one command before every PR - make test, make lint, make typecheck, make bench, make fix, make clean CONTRIBUTING.md (rewritten from scratch) - Quick start with make install + make check - Architecture in 30 seconds (ASCII flow + file map) - The Three Rules (never raise, never mutate, zero deps) - Gotchas section (callable module trick, _serialize vs _minimize, __future__ annotations, precompiled regexes, pragma preservation, thread safety) - Full minimizer template with step-by-step checklist - Testing philosophy (feature tests vs adversarial tests) - PR etiquette GitHub templates - PR template with checklist (make check, tests, no new deps, docs) - Bug report issue form (reproduction, traceback, versions) - Feature request issue form (problem, proposal, example, scope) Pre-commit config (ruff + mypy) Fixes - pyproject.toml URLs pointed to ptk-ai/ptk, now amahi2001/python-token-killer - Added Issues + Changelog URLs to project.urls - Added ruff, mypy, pre-commit to dev dependencies - Ran ruff format across all source files - AGENTS.md updated to reference Makefile commands
1 parent 9a06324 commit 64f3bbc

File tree

19 files changed

+588
-116
lines changed

19 files changed

+588
-116
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Bug Report
2+
description: Something isn't working as expected
3+
labels: ["bug"]
4+
body:
5+
- type: textarea
6+
id: what-happened
7+
attributes:
8+
label: What happened?
9+
description: What did you expect vs what actually happened?
10+
validations:
11+
required: true
12+
13+
- type: textarea
14+
id: reproduce
15+
attributes:
16+
label: Minimal reproduction
17+
description: The smallest code snippet that triggers the bug.
18+
render: python
19+
placeholder: |
20+
import ptk
21+
result = ptk.minimize(...) # expected X, got Y
22+
validations:
23+
required: true
24+
25+
- type: textarea
26+
id: traceback
27+
attributes:
28+
label: Traceback (if applicable)
29+
description: Full error traceback.
30+
render: text
31+
32+
- type: input
33+
id: ptk-version
34+
attributes:
35+
label: ptk version
36+
placeholder: "0.1.0"
37+
validations:
38+
required: true
39+
40+
- type: input
41+
id: python-version
42+
attributes:
43+
label: Python version
44+
placeholder: "3.12"
45+
validations:
46+
required: true
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Feature Request
2+
description: Suggest a new minimizer, compression strategy, or API improvement
3+
labels: ["enhancement"]
4+
body:
5+
- type: textarea
6+
id: problem
7+
attributes:
8+
label: What problem does this solve?
9+
description: What are you trying to minimize, and why doesn't ptk handle it well today?
10+
placeholder: "I have [type of data] that ptk currently treats as text, but it could save more tokens by..."
11+
validations:
12+
required: true
13+
14+
- type: textarea
15+
id: proposal
16+
attributes:
17+
label: Proposed solution
18+
description: How should ptk handle this? New minimizer? Improvement to an existing one? New API option?
19+
validations:
20+
required: true
21+
22+
- type: textarea
23+
id: example
24+
attributes:
25+
label: Example input/output
26+
description: Show a before (original) and after (what the minimized output should look like).
27+
render: python
28+
29+
- type: dropdown
30+
id: scope
31+
attributes:
32+
label: Scope
33+
options:
34+
- New minimizer
35+
- Improvement to existing minimizer
36+
- New output format
37+
- API change
38+
- Detection improvement
39+
- Other
40+
validations:
41+
required: true

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## What
2+
3+
<!-- One sentence: what does this PR do? -->
4+
5+
## Why
6+
7+
<!-- What problem does it solve? Link to issue if applicable. -->
8+
9+
## Type of Change
10+
11+
- [ ] Bug fix
12+
- [ ] New minimizer
13+
- [ ] Improvement to existing minimizer
14+
- [ ] Documentation
15+
- [ ] Tests
16+
- [ ] Other: <!-- describe -->
17+
18+
## Checklist
19+
20+
- [ ] `make check` passes (lint + typecheck + tests)
21+
- [ ] New code has tests in `test_ptk.py` (feature) and/or `test_adversarial.py` (edge cases)
22+
- [ ] No new required dependencies added (optional extras are fine)
23+
- [ ] Docstrings on new public classes/methods
24+
- [ ] CHANGELOG.md updated under `[Unreleased]` if user-facing
25+
26+
## For New Minimizers Only
27+
28+
- [ ] Detection heuristic added to `_types.py`
29+
- [ ] Registered in `_ROUTER` in `__init__.py`
30+
- [ ] Exported from `minimizers/__init__.py`
31+
- [ ] Sample input added to `TestAPIContracts.SAMPLE_INPUTS`
32+
- [ ] Content type mismatch test added
33+
- [ ] Benchmark data included in PR description

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.15.0
4+
hooks:
5+
- id: ruff
6+
args: [--fix]
7+
- id: ruff-format
8+
9+
- repo: https://github.com/pre-commit/mirrors-mypy
10+
rev: v1.20.0
11+
hooks:
12+
- id: mypy
13+
args: [--strict]
14+
additional_dependencies: []
15+
files: ^src/ptk/

AGENTS.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,12 @@ ptk.minimize(obj) → _types.detect(obj) → _ROUTER[type].run(obj) → MinResul
3434
## Commands
3535

3636
```bash
37-
# run tests (322 tests, <0.5s)
38-
PYTHONPATH=src python -m pytest tests/ -v
39-
40-
# run benchmarks (requires tiktoken)
41-
python benchmarks/bench.py
42-
43-
# type check
44-
mypy --strict src/ptk/
45-
46-
# lint
47-
ruff check src/ tests/
37+
make check # lint + typecheck + tests — run before every commit
38+
make test # tests only (322 tests, <0.5s)
39+
make lint # ruff check + format check
40+
make typecheck # mypy --strict
41+
make bench # benchmarks with tiktoken
42+
make fix # auto-fix lint/formatting
4843
```
4944

5045
## Test Structure

0 commit comments

Comments
 (0)