recount-sdk 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.
- recount_sdk-0.1.0/.gitignore +42 -0
- recount_sdk-0.1.0/LICENSE +21 -0
- recount_sdk-0.1.0/PKG-INFO +100 -0
- recount_sdk-0.1.0/README.md +77 -0
- recount_sdk-0.1.0/llms.md +474 -0
- recount_sdk-0.1.0/pyproject.toml +50 -0
- recount_sdk-0.1.0/recount/__init__.py +258 -0
- recount_sdk-0.1.0/recount/_chart.py +83 -0
- recount_sdk-0.1.0/recount/_client.py +145 -0
- recount_sdk-0.1.0/recount/_context.py +36 -0
- recount_sdk-0.1.0/recount/_http.py +102 -0
- recount_sdk-0.1.0/recount/_redact.py +44 -0
- recount_sdk-0.1.0/recount/_table.py +333 -0
- recount_sdk-0.1.0/recount/_trace.py +322 -0
- recount_sdk-0.1.0/recount/_types.py +137 -0
- recount_sdk-0.1.0/recount/integrations/__init__.py +0 -0
- recount_sdk-0.1.0/recount/integrations/anthropic.py +141 -0
- recount_sdk-0.1.0/recount/integrations/openai.py +152 -0
- recount_sdk-0.1.0/recount/integrations/pymongo.py +266 -0
- recount_sdk-0.1.0/recount-instrument/SKILL.md +213 -0
- recount_sdk-0.1.0/tests/__init__.py +0 -0
- recount_sdk-0.1.0/tests/conftest.py +11 -0
- recount_sdk-0.1.0/tests/integrations/__init__.py +0 -0
- recount_sdk-0.1.0/tests/integrations/test_anthropic.py +142 -0
- recount_sdk-0.1.0/tests/integrations/test_openai.py +122 -0
- recount_sdk-0.1.0/tests/integrations/test_pymongo.py +581 -0
- recount_sdk-0.1.0/tests/test_chart.py +72 -0
- recount_sdk-0.1.0/tests/test_client.py +265 -0
- recount_sdk-0.1.0/tests/test_http.py +202 -0
- recount_sdk-0.1.0/tests/test_recount.py +387 -0
- recount_sdk-0.1.0/tests/test_redact.py +113 -0
- recount_sdk-0.1.0/tests/test_table.py +251 -0
- recount_sdk-0.1.0/tests/test_trace.py +665 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.pyo
|
|
5
|
+
*.pyd
|
|
6
|
+
*.so
|
|
7
|
+
*.egg
|
|
8
|
+
*.egg-info/
|
|
9
|
+
dist/
|
|
10
|
+
build/
|
|
11
|
+
.eggs/
|
|
12
|
+
.ruff_cache/
|
|
13
|
+
|
|
14
|
+
# Venv
|
|
15
|
+
.venv/
|
|
16
|
+
venv/
|
|
17
|
+
env/
|
|
18
|
+
|
|
19
|
+
# Pytest / coverage
|
|
20
|
+
.pytest_cache/
|
|
21
|
+
.coverage
|
|
22
|
+
htmlcov/
|
|
23
|
+
.tox/
|
|
24
|
+
|
|
25
|
+
# Type checking
|
|
26
|
+
.mypy_cache/
|
|
27
|
+
.pyright/
|
|
28
|
+
|
|
29
|
+
# Editor
|
|
30
|
+
.vscode/
|
|
31
|
+
.idea/
|
|
32
|
+
*.swp
|
|
33
|
+
*.swo
|
|
34
|
+
|
|
35
|
+
# OS
|
|
36
|
+
.DS_Store
|
|
37
|
+
Thumbs.db
|
|
38
|
+
|
|
39
|
+
# Env files
|
|
40
|
+
.env
|
|
41
|
+
.env.*
|
|
42
|
+
!.env.example
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Refactor Labs Pty Ltd
|
|
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.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: recount-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for Recount
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Requires-Dist: httpx>=0.25.0
|
|
9
|
+
Provides-Extra: anthropic
|
|
10
|
+
Requires-Dist: anthropic>=0.20.0; extra == 'anthropic'
|
|
11
|
+
Provides-Extra: dev
|
|
12
|
+
Requires-Dist: httpx>=0.25.0; extra == 'dev'
|
|
13
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
14
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
15
|
+
Requires-Dist: python-dotenv[cli]>=1.0; extra == 'dev'
|
|
16
|
+
Requires-Dist: respx>=0.20; extra == 'dev'
|
|
17
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
18
|
+
Provides-Extra: openai
|
|
19
|
+
Requires-Dist: openai>=1.0.0; extra == 'openai'
|
|
20
|
+
Provides-Extra: pymongo
|
|
21
|
+
Requires-Dist: pymongo>=4.0; extra == 'pymongo'
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# recount-sdk
|
|
25
|
+
|
|
26
|
+
Application explainability for modern software. Recount captures the reasoning behind your application's decisions and presents it as an interactive timeline, making it easy for engineers, support teams, product managers, and business stakeholders to understand what happened - and why.
|
|
27
|
+
|
|
28
|
+
This is the Python SDK for [Recount](https://recount.refactor.gg).
|
|
29
|
+
|
|
30
|
+
**[Documentation](https://recount.refactor.gg/docs)**
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
pip install recount-sdk
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Quick start
|
|
39
|
+
|
|
40
|
+
Wrap the function that makes a decision in `start_trace`, then add a span per step. No `RECOUNT_API_KEY`? All calls silently no-op, so it's safe to wire up before you have one.
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
import asyncio
|
|
44
|
+
import recount
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
async def check_discount_eligibility():
|
|
48
|
+
recount.add_span("table", "Discount rules", {
|
|
49
|
+
"output": recount.table()
|
|
50
|
+
.from_records([
|
|
51
|
+
{"rule": "Loyalty tier", "value": "Gold", "result": "Pass"},
|
|
52
|
+
{"rule": "Order total >= $50", "value": "$84.00", "result": "Pass"},
|
|
53
|
+
{"rule": "No active disputes", "value": "0", "result": "Pass"},
|
|
54
|
+
])
|
|
55
|
+
.highlight_rows(lambda row: "success" if row["result"] == "Pass" else "danger")
|
|
56
|
+
.build(),
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
recount.add_span("json", "Result", {
|
|
60
|
+
"output": {"decision": "approved", "discount": "15%"},
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
asyncio.run(recount.start_trace("Discount eligibility - ORDER-4471", check_discount_eligibility))
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
That trace shows up in the [Recount dashboard](https://recount.refactor.gg) as a readable timeline - not a log dump - that a support agent or auditor can open and see exactly why the discount was approved.
|
|
68
|
+
|
|
69
|
+
## Integrations
|
|
70
|
+
|
|
71
|
+
Wrap a client once and every call through it is traced automatically - don't hand-write spans for these:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from recount.integrations.anthropic import wrap_anthropic
|
|
75
|
+
from recount.integrations.openai import wrap_openai
|
|
76
|
+
from recount.integrations.pymongo import wrap_collection
|
|
77
|
+
|
|
78
|
+
anthropic = wrap_anthropic(AsyncAnthropic())
|
|
79
|
+
openai = wrap_openai(AsyncOpenAI())
|
|
80
|
+
users = wrap_collection(db["users"]) # find_one, find, update_one, aggregate, ...
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
See the [full docs](https://recount.refactor.gg/docs) for span types, the `table()`/`chart()` builders, redaction, alerts, and `add_group` for bounded lists.
|
|
84
|
+
|
|
85
|
+
## Claude Code skill
|
|
86
|
+
|
|
87
|
+
This package ships a [Claude Code](https://claude.com/claude-code) Skill that finds decision logic
|
|
88
|
+
in your codebase (pricing, billing, discounts, access control, LLM calls) and instruments it with
|
|
89
|
+
Recount automatically. To use it in your project:
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
mkdir -p .claude/skills/recount-instrument
|
|
93
|
+
cp "$(python -c "import recount, os; print(os.path.join(os.path.dirname(recount.__file__), 'recount-instrument', 'SKILL.md'))")" .claude/skills/recount-instrument/
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Then in Claude Code, ask it to "add recount tracing to this" or "instrument this with recount".
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
MIT
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# recount-sdk
|
|
2
|
+
|
|
3
|
+
Application explainability for modern software. Recount captures the reasoning behind your application's decisions and presents it as an interactive timeline, making it easy for engineers, support teams, product managers, and business stakeholders to understand what happened - and why.
|
|
4
|
+
|
|
5
|
+
This is the Python SDK for [Recount](https://recount.refactor.gg).
|
|
6
|
+
|
|
7
|
+
**[Documentation](https://recount.refactor.gg/docs)**
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pip install recount-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
Wrap the function that makes a decision in `start_trace`, then add a span per step. No `RECOUNT_API_KEY`? All calls silently no-op, so it's safe to wire up before you have one.
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
import asyncio
|
|
21
|
+
import recount
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
async def check_discount_eligibility():
|
|
25
|
+
recount.add_span("table", "Discount rules", {
|
|
26
|
+
"output": recount.table()
|
|
27
|
+
.from_records([
|
|
28
|
+
{"rule": "Loyalty tier", "value": "Gold", "result": "Pass"},
|
|
29
|
+
{"rule": "Order total >= $50", "value": "$84.00", "result": "Pass"},
|
|
30
|
+
{"rule": "No active disputes", "value": "0", "result": "Pass"},
|
|
31
|
+
])
|
|
32
|
+
.highlight_rows(lambda row: "success" if row["result"] == "Pass" else "danger")
|
|
33
|
+
.build(),
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
recount.add_span("json", "Result", {
|
|
37
|
+
"output": {"decision": "approved", "discount": "15%"},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
asyncio.run(recount.start_trace("Discount eligibility - ORDER-4471", check_discount_eligibility))
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
That trace shows up in the [Recount dashboard](https://recount.refactor.gg) as a readable timeline - not a log dump - that a support agent or auditor can open and see exactly why the discount was approved.
|
|
45
|
+
|
|
46
|
+
## Integrations
|
|
47
|
+
|
|
48
|
+
Wrap a client once and every call through it is traced automatically - don't hand-write spans for these:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from recount.integrations.anthropic import wrap_anthropic
|
|
52
|
+
from recount.integrations.openai import wrap_openai
|
|
53
|
+
from recount.integrations.pymongo import wrap_collection
|
|
54
|
+
|
|
55
|
+
anthropic = wrap_anthropic(AsyncAnthropic())
|
|
56
|
+
openai = wrap_openai(AsyncOpenAI())
|
|
57
|
+
users = wrap_collection(db["users"]) # find_one, find, update_one, aggregate, ...
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
See the [full docs](https://recount.refactor.gg/docs) for span types, the `table()`/`chart()` builders, redaction, alerts, and `add_group` for bounded lists.
|
|
61
|
+
|
|
62
|
+
## Claude Code skill
|
|
63
|
+
|
|
64
|
+
This package ships a [Claude Code](https://claude.com/claude-code) Skill that finds decision logic
|
|
65
|
+
in your codebase (pricing, billing, discounts, access control, LLM calls) and instruments it with
|
|
66
|
+
Recount automatically. To use it in your project:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
mkdir -p .claude/skills/recount-instrument
|
|
70
|
+
cp "$(python -c "import recount, os; print(os.path.join(os.path.dirname(recount.__file__), 'recount-instrument', 'SKILL.md'))")" .claude/skills/recount-instrument/
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Then in Claude Code, ask it to "add recount tracing to this" or "instrument this with recount".
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT
|