agentcassette 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.
- agentcassette-0.1.0/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- agentcassette-0.1.0/.github/ISSUE_TEMPLATE/feature_request.md +28 -0
- agentcassette-0.1.0/.github/dependabot.yml +30 -0
- agentcassette-0.1.0/.github/pull_request_template.md +23 -0
- agentcassette-0.1.0/.github/workflows/ci.yml +78 -0
- agentcassette-0.1.0/.github/workflows/publish.yml +136 -0
- agentcassette-0.1.0/.gitignore +50 -0
- agentcassette-0.1.0/CHANGELOG.md +26 -0
- agentcassette-0.1.0/CODE_OF_CONDUCT.md +31 -0
- agentcassette-0.1.0/CONTRIBUTING.md +70 -0
- agentcassette-0.1.0/LICENSE +21 -0
- agentcassette-0.1.0/PKG-INFO +290 -0
- agentcassette-0.1.0/README.md +258 -0
- agentcassette-0.1.0/SECURITY.md +31 -0
- agentcassette-0.1.0/pyproject.toml +53 -0
- agentcassette-0.1.0/src/agentcassette/__init__.py +83 -0
- agentcassette-0.1.0/src/agentcassette/_cassette.py +169 -0
- agentcassette-0.1.0/src/agentcassette/_diff.py +70 -0
- agentcassette-0.1.0/src/agentcassette/_errors.py +35 -0
- agentcassette-0.1.0/src/agentcassette/_session.py +249 -0
- agentcassette-0.1.0/src/agentcassette/_tokens.py +86 -0
- agentcassette-0.1.0/src/agentcassette/py.typed +0 -0
- agentcassette-0.1.0/tests/__init__.py +0 -0
- agentcassette-0.1.0/tests/test_async.py +94 -0
- agentcassette-0.1.0/tests/test_cassette.py +103 -0
- agentcassette-0.1.0/tests/test_diff.py +88 -0
- agentcassette-0.1.0/tests/test_divergence.py +60 -0
- agentcassette-0.1.0/tests/test_errors.py +76 -0
- agentcassette-0.1.0/tests/test_record_replay.py +100 -0
- agentcassette-0.1.0/tests/test_tokens.py +42 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Something isn't working correctly
|
|
4
|
+
labels: bug
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Description
|
|
8
|
+
|
|
9
|
+
A clear description of the bug.
|
|
10
|
+
|
|
11
|
+
## Reproduction
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
import agentcassette
|
|
15
|
+
from agentcassette import record, replay
|
|
16
|
+
|
|
17
|
+
call_model = agentcassette.intercept(call_model, kind="llm")
|
|
18
|
+
|
|
19
|
+
# What you did:
|
|
20
|
+
with record("cassette.json"):
|
|
21
|
+
...
|
|
22
|
+
|
|
23
|
+
# What you expected:
|
|
24
|
+
|
|
25
|
+
# What you got:
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Environment
|
|
29
|
+
|
|
30
|
+
- agentcassette version:
|
|
31
|
+
- Python version:
|
|
32
|
+
- OS:
|
|
33
|
+
|
|
34
|
+
## Traceback
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
Paste the full traceback here, if any.
|
|
38
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest a new capability or behavior
|
|
4
|
+
labels: enhancement
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## What problem does this solve?
|
|
8
|
+
|
|
9
|
+
Describe the use case, not the solution. What can't you do today?
|
|
10
|
+
|
|
11
|
+
## Proposed solution
|
|
12
|
+
|
|
13
|
+
If you have a concrete idea, describe it here. Include example code if helpful:
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
import agentcassette
|
|
17
|
+
|
|
18
|
+
# What the new behavior would look like:
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Alternatives considered
|
|
22
|
+
|
|
23
|
+
Any other approaches you've thought about?
|
|
24
|
+
|
|
25
|
+
## Notes
|
|
26
|
+
|
|
27
|
+
- Does this require a new dependency? (It shouldn't — agentcassette has zero dependencies by design.)
|
|
28
|
+
- Does it keep cassettes provider-agnostic and human-readable JSON?
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
# Keep GitHub Actions up to date
|
|
4
|
+
- package-ecosystem: "github-actions"
|
|
5
|
+
directory: "/"
|
|
6
|
+
schedule:
|
|
7
|
+
interval: "weekly"
|
|
8
|
+
day: "monday"
|
|
9
|
+
commit-message:
|
|
10
|
+
prefix: "ci"
|
|
11
|
+
labels:
|
|
12
|
+
- "dependencies"
|
|
13
|
+
- "ci"
|
|
14
|
+
|
|
15
|
+
# pip: only dev dependencies (agentcassette has no runtime dependencies)
|
|
16
|
+
- package-ecosystem: "pip"
|
|
17
|
+
directory: "/"
|
|
18
|
+
schedule:
|
|
19
|
+
interval: "weekly"
|
|
20
|
+
day: "monday"
|
|
21
|
+
commit-message:
|
|
22
|
+
prefix: "chore"
|
|
23
|
+
labels:
|
|
24
|
+
- "dependencies"
|
|
25
|
+
ignore:
|
|
26
|
+
# Only update patch versions for dev tools automatically
|
|
27
|
+
- dependency-name: "pytest"
|
|
28
|
+
update-types: ["version-update:semver-major"]
|
|
29
|
+
- dependency-name: "hatch"
|
|
30
|
+
update-types: ["version-update:semver-major"]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
## Summary
|
|
2
|
+
|
|
3
|
+
What does this PR do? Reference any related issues: `Fixes #123`
|
|
4
|
+
|
|
5
|
+
## Changes
|
|
6
|
+
|
|
7
|
+
-
|
|
8
|
+
-
|
|
9
|
+
|
|
10
|
+
## Testing
|
|
11
|
+
|
|
12
|
+
- [ ] New tests added (or existing tests updated) for all changed behavior
|
|
13
|
+
- [ ] `pytest tests/ -v` passes locally
|
|
14
|
+
- [ ] No third-party imports introduced (zero-dependency contract)
|
|
15
|
+
- [ ] Tested on Python 3.9 (lowest supported version)
|
|
16
|
+
|
|
17
|
+
## Cassette compatibility (if applicable)
|
|
18
|
+
|
|
19
|
+
If this PR changes the cassette format, describe the change and how existing cassettes are handled (bump `CASSETTE_VERSION` if the format is not backward compatible).
|
|
20
|
+
|
|
21
|
+
## Notes for reviewers
|
|
22
|
+
|
|
23
|
+
Anything that needs extra attention or context?
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
name: Python ${{ matrix.python-version }} / ${{ matrix.os }}
|
|
16
|
+
runs-on: ${{ matrix.os }}
|
|
17
|
+
strategy:
|
|
18
|
+
fail-fast: false
|
|
19
|
+
matrix:
|
|
20
|
+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
21
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
25
|
+
|
|
26
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
27
|
+
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
|
|
28
|
+
with:
|
|
29
|
+
python-version: ${{ matrix.python-version }}
|
|
30
|
+
|
|
31
|
+
- name: Install package (no dependencies to install)
|
|
32
|
+
run: pip install -e ".[dev]"
|
|
33
|
+
|
|
34
|
+
- name: Run tests
|
|
35
|
+
run: pytest tests/ -v --tb=short
|
|
36
|
+
|
|
37
|
+
- name: Verify zero runtime dependencies
|
|
38
|
+
shell: bash # heredoc below is bash syntax; Windows defaults to pwsh
|
|
39
|
+
run: |
|
|
40
|
+
# agentcassette must ship with zero dependencies.
|
|
41
|
+
# This step fails the build if any non-stdlib import is introduced.
|
|
42
|
+
python - <<'EOF'
|
|
43
|
+
import sys, pathlib, ast
|
|
44
|
+
|
|
45
|
+
# sys.stdlib_module_names is Python 3.10+. On 3.9 the rest of the
|
|
46
|
+
# matrix provides coverage, so skip this static check there.
|
|
47
|
+
if not hasattr(sys, "stdlib_module_names"):
|
|
48
|
+
print("Skipping static import check on Python < 3.10")
|
|
49
|
+
sys.exit(0)
|
|
50
|
+
|
|
51
|
+
src = pathlib.Path("src/agentcassette")
|
|
52
|
+
stdlib_modules = set(sys.stdlib_module_names)
|
|
53
|
+
|
|
54
|
+
third_party = []
|
|
55
|
+
for py_file in src.rglob("*.py"):
|
|
56
|
+
tree = ast.parse(py_file.read_text())
|
|
57
|
+
for node in ast.walk(tree):
|
|
58
|
+
if isinstance(node, ast.Import):
|
|
59
|
+
names = [alias.name for alias in node.names]
|
|
60
|
+
elif isinstance(node, ast.ImportFrom):
|
|
61
|
+
# Relative imports (level > 0) are always intra-package.
|
|
62
|
+
if node.level:
|
|
63
|
+
continue
|
|
64
|
+
names = [node.module or ""]
|
|
65
|
+
else:
|
|
66
|
+
continue
|
|
67
|
+
for name in names:
|
|
68
|
+
top = name.split(".")[0]
|
|
69
|
+
if top and top not in stdlib_modules and top != "agentcassette":
|
|
70
|
+
third_party.append(f"{py_file}: {top}")
|
|
71
|
+
|
|
72
|
+
if third_party:
|
|
73
|
+
print("FAIL: third-party imports detected:")
|
|
74
|
+
for item in third_party:
|
|
75
|
+
print(f" {item}")
|
|
76
|
+
sys.exit(1)
|
|
77
|
+
print("OK: zero third-party dependencies confirmed")
|
|
78
|
+
EOF
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
# Triggers on a pushed version tag: v0.1.0, v1.2.3, etc.
|
|
4
|
+
# Requires PyPI Trusted Publishing configured at:
|
|
5
|
+
# https://pypi.org/manage/project/agentcassette/settings/publishing/
|
|
6
|
+
# No API token or secret needed — OIDC handles authentication.
|
|
7
|
+
#
|
|
8
|
+
# Actions are pinned to full commit SHAs to satisfy the repo's
|
|
9
|
+
# "require actions to be pinned to a full-length commit SHA" policy.
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
push:
|
|
13
|
+
tags:
|
|
14
|
+
- "v[0-9]+.[0-9]+.[0-9]+"
|
|
15
|
+
- "v[0-9]+.[0-9]+.[0-9]+[ab][0-9]+" # alpha/beta: v1.0.0a1, v1.0.0b2
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
# ── 1. Run the full test suite before publishing ──────────────────────────
|
|
19
|
+
test:
|
|
20
|
+
name: Test before publish
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
24
|
+
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
|
|
25
|
+
with:
|
|
26
|
+
python-version: "3.12"
|
|
27
|
+
- run: pip install -e ".[dev]"
|
|
28
|
+
- run: pytest tests/ -v --tb=short
|
|
29
|
+
|
|
30
|
+
# ── 2. Build the distribution ─────────────────────────────────────────────
|
|
31
|
+
build:
|
|
32
|
+
name: Build distribution
|
|
33
|
+
needs: test
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
37
|
+
|
|
38
|
+
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
|
|
39
|
+
with:
|
|
40
|
+
python-version: "3.12"
|
|
41
|
+
|
|
42
|
+
- name: Install hatch
|
|
43
|
+
run: pip install hatch
|
|
44
|
+
|
|
45
|
+
- name: Verify version tag matches pyproject.toml
|
|
46
|
+
run: |
|
|
47
|
+
TAG="${GITHUB_REF#refs/tags/v}"
|
|
48
|
+
PKG=$(python -c "import tomllib; d=tomllib.load(open('pyproject.toml','rb')); print(d['project']['version'])")
|
|
49
|
+
if [ "$TAG" != "$PKG" ]; then
|
|
50
|
+
echo "Tag $TAG does not match package version $PKG"
|
|
51
|
+
exit 1
|
|
52
|
+
fi
|
|
53
|
+
echo "Version match confirmed: $TAG"
|
|
54
|
+
|
|
55
|
+
- name: Build sdist and wheel
|
|
56
|
+
run: hatch build
|
|
57
|
+
|
|
58
|
+
- name: Upload distribution artifacts
|
|
59
|
+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
60
|
+
with:
|
|
61
|
+
name: dist
|
|
62
|
+
path: dist/
|
|
63
|
+
|
|
64
|
+
# ── 3. Publish to PyPI via Trusted Publishing (OIDC) ─────────────────────
|
|
65
|
+
publish:
|
|
66
|
+
name: Publish to PyPI
|
|
67
|
+
needs: build
|
|
68
|
+
runs-on: ubuntu-latest
|
|
69
|
+
environment:
|
|
70
|
+
name: pypi
|
|
71
|
+
url: https://pypi.org/project/agentcassette/
|
|
72
|
+
permissions:
|
|
73
|
+
id-token: write # Required for OIDC trusted publishing
|
|
74
|
+
|
|
75
|
+
steps:
|
|
76
|
+
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
|
|
77
|
+
with:
|
|
78
|
+
python-version: "3.12"
|
|
79
|
+
|
|
80
|
+
- name: Download distribution artifacts
|
|
81
|
+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
82
|
+
with:
|
|
83
|
+
name: dist
|
|
84
|
+
path: dist/
|
|
85
|
+
|
|
86
|
+
# Trusted Publishing via OIDC, done manually with twine so no third-party
|
|
87
|
+
# GitHub Action is required (the org restricts which actions may run).
|
|
88
|
+
# Mirrors the official PyPI manual OIDC flow:
|
|
89
|
+
# https://docs.pypi.org/trusted-publishers/using-a-publisher/
|
|
90
|
+
- name: Publish to PyPI (OIDC trusted publishing)
|
|
91
|
+
run: |
|
|
92
|
+
set -euo pipefail
|
|
93
|
+
python -m pip install --upgrade twine
|
|
94
|
+
|
|
95
|
+
# 1. Obtain a GitHub OIDC token scoped to PyPI.
|
|
96
|
+
oidc_token=$(curl -sS \
|
|
97
|
+
-H "Authorization: bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" \
|
|
98
|
+
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=pypi" \
|
|
99
|
+
| python -c "import sys, json; print(json.load(sys.stdin)['value'])")
|
|
100
|
+
|
|
101
|
+
# 2. Exchange it for a short-lived PyPI API token.
|
|
102
|
+
api_token=$(curl -sS -X POST https://pypi.org/_/oidc/mint-token \
|
|
103
|
+
-d "{\"token\": \"${oidc_token}\"}" \
|
|
104
|
+
| python -c "import sys, json; print(json.load(sys.stdin)['token'])")
|
|
105
|
+
|
|
106
|
+
# 3. Upload the distributions (--skip-existing makes re-runs safe).
|
|
107
|
+
twine upload --skip-existing --username __token__ --password "${api_token}" dist/*
|
|
108
|
+
|
|
109
|
+
# ── 4. Create GitHub Release with changelog excerpt ───────────────────────
|
|
110
|
+
release:
|
|
111
|
+
name: Create GitHub Release
|
|
112
|
+
needs: publish
|
|
113
|
+
runs-on: ubuntu-latest
|
|
114
|
+
permissions:
|
|
115
|
+
contents: write
|
|
116
|
+
|
|
117
|
+
steps:
|
|
118
|
+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
119
|
+
|
|
120
|
+
- name: Download distribution artifacts
|
|
121
|
+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
122
|
+
with:
|
|
123
|
+
name: dist
|
|
124
|
+
path: dist/
|
|
125
|
+
|
|
126
|
+
- name: Create GitHub Release
|
|
127
|
+
env:
|
|
128
|
+
GH_TOKEN: ${{ github.token }}
|
|
129
|
+
run: |
|
|
130
|
+
TAG="${GITHUB_REF#refs/tags/}"
|
|
131
|
+
VERSION="${TAG#v}"
|
|
132
|
+
# Extract the changelog block for this version (between its header and the next)
|
|
133
|
+
awk "/^## \[$VERSION\]/{flag=1; next} /^## \[/{flag=0} flag" CHANGELOG.md > notes.md
|
|
134
|
+
# Create the release, or (re)attach assets if it already exists.
|
|
135
|
+
gh release create "$TAG" dist/* --title "$TAG" --notes-file notes.md \
|
|
136
|
+
|| gh release upload "$TAG" dist/* --clobber
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
*.egg
|
|
7
|
+
*.egg-info/
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
.eggs/
|
|
11
|
+
pip-wheel-metadata/
|
|
12
|
+
share/python-wheels/
|
|
13
|
+
|
|
14
|
+
# Virtual environments
|
|
15
|
+
.venv/
|
|
16
|
+
venv/
|
|
17
|
+
env/
|
|
18
|
+
ENV/
|
|
19
|
+
|
|
20
|
+
# Testing
|
|
21
|
+
.pytest_cache/
|
|
22
|
+
.coverage
|
|
23
|
+
.coverage.*
|
|
24
|
+
coverage.xml
|
|
25
|
+
htmlcov/
|
|
26
|
+
.tox/
|
|
27
|
+
.nox/
|
|
28
|
+
|
|
29
|
+
# Type checking
|
|
30
|
+
.mypy_cache/
|
|
31
|
+
.dmypy.json
|
|
32
|
+
.pytype/
|
|
33
|
+
.pyre/
|
|
34
|
+
|
|
35
|
+
# Build tools
|
|
36
|
+
.hatch/
|
|
37
|
+
*.tar.gz
|
|
38
|
+
*.whl
|
|
39
|
+
|
|
40
|
+
# Editors
|
|
41
|
+
.vscode/
|
|
42
|
+
.idea/
|
|
43
|
+
*.swp
|
|
44
|
+
*.swo
|
|
45
|
+
*~
|
|
46
|
+
.DS_Store
|
|
47
|
+
Thumbs.db
|
|
48
|
+
|
|
49
|
+
# Project-specific
|
|
50
|
+
*.log
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to agentcassette are documented here.
|
|
4
|
+
|
|
5
|
+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
6
|
+
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-06-30
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `intercept()` — wrap a callable so it can be recorded and replayed; transparent pass-through outside a session. Supports both sync functions and `async def` coroutine functions
|
|
14
|
+
- `record()` — context manager that tapes every intercepted call to a JSON cassette (written on clean exit only)
|
|
15
|
+
- `replay()` — context manager that serves recorded results without running the real functions
|
|
16
|
+
- Strict replay (`strict=True`) raising `DivergenceError` on any name/argument mismatch; best-effort mode collects divergences on the player
|
|
17
|
+
- `Cassette` — load/save, `num_steps`, `total_input_tokens`, `total_output_tokens`, `total_tokens`, `duration_ms`, and `redact()` for scrubbing secrets
|
|
18
|
+
- Record-time redaction via `record(..., redact=[...])`
|
|
19
|
+
- `diff_cassettes()` / `CassetteDiff` — `new_calls`, `dropped_calls`, `changed_calls`, token deltas, and `identical`
|
|
20
|
+
- Token accounting that prefers exact provider usage blocks (OpenAI/Anthropic) and falls back to a deterministic character heuristic
|
|
21
|
+
- Exception hierarchy under `AgentCassetteError`: `CassetteNotFound`, `ReplayExhausted`, `DivergenceError`
|
|
22
|
+
- Zero external dependencies — pure Python stdlib (3.9+)
|
|
23
|
+
- 44 unit tests covering sync/async record/replay, divergence, cassette inspection, diffing, token accounting, and error handling
|
|
24
|
+
|
|
25
|
+
[Unreleased]: https://github.com/aenealabs/agentcassette/compare/v0.1.0...HEAD
|
|
26
|
+
[0.1.0]: https://github.com/aenealabs/agentcassette/releases/tag/v0.1.0
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as contributors and maintainers pledge to make participation in agentcassette a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
## Our Standards
|
|
8
|
+
|
|
9
|
+
Examples of behavior that contributes to a positive environment:
|
|
10
|
+
|
|
11
|
+
- Using welcoming and inclusive language
|
|
12
|
+
- Being respectful of differing viewpoints and experiences
|
|
13
|
+
- Gracefully accepting constructive criticism
|
|
14
|
+
- Focusing on what is best for the community
|
|
15
|
+
- Showing empathy towards other community members
|
|
16
|
+
|
|
17
|
+
Examples of unacceptable behavior:
|
|
18
|
+
|
|
19
|
+
- The use of sexualized language or imagery
|
|
20
|
+
- Trolling, insulting/derogatory comments, and personal or political attacks
|
|
21
|
+
- Public or private harassment
|
|
22
|
+
- Publishing others' private information without explicit permission
|
|
23
|
+
- Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
24
|
+
|
|
25
|
+
## Enforcement
|
|
26
|
+
|
|
27
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening a GitHub issue or contacting the maintainers directly. All complaints will be reviewed and investigated and will result in a response deemed necessary and appropriate to the circumstances.
|
|
28
|
+
|
|
29
|
+
## Attribution
|
|
30
|
+
|
|
31
|
+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), version 2.1.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Contributing to agentcassette
|
|
2
|
+
|
|
3
|
+
Thank you for taking the time to contribute.
|
|
4
|
+
|
|
5
|
+
## Ground rules
|
|
6
|
+
|
|
7
|
+
- **Zero external dependencies.** agentcassette must remain pure Python stdlib. PRs that introduce any third-party import will not be merged.
|
|
8
|
+
- **Python 3.9+.** All code must run on Python 3.9 through the latest stable release.
|
|
9
|
+
- **Tests required.** Every new feature or bug fix must include a corresponding test. The CI matrix runs on 3 operating systems × 5 Python versions — please run tests locally before opening a PR.
|
|
10
|
+
- **Keep it focused.** agentcassette does one thing: record and replay agent runs deterministically. Feature requests outside that scope belong in a separate package.
|
|
11
|
+
|
|
12
|
+
## Setting up a development environment
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
git clone https://github.com/aenealabs/agentcassette
|
|
16
|
+
cd agentcassette
|
|
17
|
+
python -m venv .venv
|
|
18
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
19
|
+
pip install -e ".[dev]"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Running tests
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pytest tests/ -v
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
To run against a specific Python version, use `hatch`:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install hatch
|
|
32
|
+
hatch run test
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Architecture
|
|
36
|
+
|
|
37
|
+
agentcassette is small and layered — read the modules in this order:
|
|
38
|
+
|
|
39
|
+
1. `src/agentcassette/_errors.py` — the exception hierarchy.
|
|
40
|
+
2. `src/agentcassette/_tokens.py` — token accounting (exact usage blocks, else heuristic).
|
|
41
|
+
3. `src/agentcassette/_cassette.py` — the on-disk JSON format, load/save/redact, JSON coercion.
|
|
42
|
+
4. `src/agentcassette/_session.py` — the thread-local session, `intercept()` seam, `Recorder`, `Player`, and the `record`/`replay` context managers.
|
|
43
|
+
5. `src/agentcassette/_diff.py` — cassette comparison.
|
|
44
|
+
6. `src/agentcassette/__init__.py` — the public surface.
|
|
45
|
+
|
|
46
|
+
## Adding a feature
|
|
47
|
+
|
|
48
|
+
1. Implement it in the appropriate `_*.py` module.
|
|
49
|
+
2. Export it from `__init__.py` (and add to `__all__`) if it is public.
|
|
50
|
+
3. Add tests under `tests/` covering the new behavior, including edge cases.
|
|
51
|
+
4. Update `README.md` and `CHANGELOG.md`.
|
|
52
|
+
|
|
53
|
+
## Submitting a pull request
|
|
54
|
+
|
|
55
|
+
1. Fork the repository and create a branch: `git checkout -b fix/my-fix` or `feat/my-feature`.
|
|
56
|
+
2. Make your changes and add tests.
|
|
57
|
+
3. Run `pytest tests/ -v` — all tests must pass.
|
|
58
|
+
4. Open a pull request against `main` with a clear description of what changed and why.
|
|
59
|
+
|
|
60
|
+
## Reporting bugs
|
|
61
|
+
|
|
62
|
+
Open an issue using the **Bug report** template. Include the Python version, OS, a minimal agent/callable, and the full traceback.
|
|
63
|
+
|
|
64
|
+
## Suggesting features
|
|
65
|
+
|
|
66
|
+
Open an issue using the **Feature request** template. Explain the use case, not just the solution.
|
|
67
|
+
|
|
68
|
+
## Code style
|
|
69
|
+
|
|
70
|
+
agentcassette uses no formatter or linter by choice to keep contributor setup minimal. Please follow the style of the surrounding code: 4-space indentation, descriptive variable names, module-level docstrings on every file.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LaVon Rutledge
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|