weakincentives 0.1.0__py3-none-any.whl → 0.2.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.

Potentially problematic release.


This version of weakincentives might be problematic. Click here for more details.

@@ -0,0 +1,173 @@
1
+ Metadata-Version: 2.4
2
+ Name: weakincentives
3
+ Version: 0.2.0
4
+ Summary: Tools for developing and optimizing side effect free background agents
5
+ Project-URL: Homepage, https://weakincentives.com/
6
+ Project-URL: Documentation, https://github.com/weakincentives/weakincentives#readme
7
+ Project-URL: Repository, https://github.com/weakincentives/weakincentives
8
+ Project-URL: Issue Tracker, https://github.com/weakincentives/weakincentives/issues
9
+ Author-email: Andrei Savu <andrei@weakincentives.com>
10
+ License: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: agents,ai,background-agents,optimization,side-effect-free,weak-incentives
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.14
24
+ Provides-Extra: openai
25
+ Requires-Dist: openai>=2.6.1; extra == 'openai'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # Weak Incentives
29
+
30
+ Tools for developing and optimizing side effect free background agents. The library ships prompt composition primitives, structured tool metadata, and optional provider adapters so you can scaffold deterministic automation flows quickly. All commands below assume Astral's `uv` CLI.
31
+
32
+ ## For Library Users
33
+
34
+ ### Installation
35
+
36
+ - `uv add weakincentives`
37
+ - Add `uv add "weakincentives[openai]"` (or `uv sync --extra openai` when cloning the repo) to enable the OpenAI adapter helpers.
38
+
39
+ ### Key Features
40
+
41
+ - Fully typed prompt composition primitives (`Prompt`, `Section`, `TextSection`, `Tool`, `ToolResult`) for assembling deterministic Markdown prompts with attached tool metadata.
42
+ - Stdlib-only dataclass serde utilities (`parse`, `dump`, `clone`, `schema`) for Pydantic-like ergonomics without third-party dependencies.
43
+ - Optional OpenAI adapter that gates imports behind a friendly error and returns the SDK client when the extra is present.
44
+ - Quiet-by-default package with minimal runtime dependencies so background agents stay lean and predictable.
45
+
46
+ ### Quickstart
47
+
48
+ ````python
49
+ from dataclasses import dataclass
50
+
51
+ from weakincentives.prompts import (
52
+ Prompt,
53
+ TextSection,
54
+ Tool,
55
+ ToolResult,
56
+ parse_output,
57
+ )
58
+
59
+
60
+ @dataclass
61
+ class ResearchGuidance:
62
+ topic: str
63
+
64
+
65
+ @dataclass
66
+ class SourceLookup:
67
+ source_id: str
68
+
69
+
70
+ @dataclass
71
+ class SourceDetails:
72
+ source_id: str
73
+ title: str
74
+
75
+
76
+ @dataclass
77
+ class ResearchSummary:
78
+ summary: str
79
+ citations: list[str]
80
+
81
+
82
+ def lookup_source(params: SourceLookup) -> ToolResult[SourceDetails]:
83
+ details = SourceDetails(source_id=params.source_id, title="Ada Lovelace Archive")
84
+ return ToolResult(message=f"Loaded {details.title}", payload=details)
85
+
86
+
87
+ catalog_tool = Tool[SourceLookup, SourceDetails](
88
+ name="catalog_lookup",
89
+ description="Look up a primary source identifier and return structured details.",
90
+ handler=lookup_source,
91
+ )
92
+
93
+ research_section = TextSection[ResearchGuidance](
94
+ title="Task",
95
+ body=(
96
+ "Research ${topic}. Use the `catalog_lookup` tool for citations and return"
97
+ " a JSON summary with citations."
98
+ ),
99
+ tools=[catalog_tool],
100
+ )
101
+
102
+ prompt = Prompt[ResearchSummary](
103
+ name="research_run",
104
+ sections=[research_section],
105
+ )
106
+
107
+ rendered = prompt.render(ResearchGuidance(topic="Ada Lovelace"))
108
+ print(rendered.text)
109
+ print([tool.name for tool in rendered.tools])
110
+
111
+ reply = """```json
112
+ {
113
+ "summary": "Ada Lovelace pioneered computing...",
114
+ "citations": ["catalog_lookup:ada-archive"]
115
+ }
116
+ ```"""
117
+
118
+ parsed = parse_output(reply, rendered)
119
+ print(parsed.summary)
120
+ print(parsed.citations)
121
+ ````
122
+
123
+ ### Optional Extras
124
+
125
+ Use the OpenAI helpers once the extra is installed:
126
+
127
+ ```python
128
+ from weakincentives.adapters import OpenAIAdapter
129
+
130
+ adapter = OpenAIAdapter(model="gpt-4o-mini", client_kwargs={"api_key": "sk-..."})
131
+ ```
132
+
133
+ If the dependency is missing, the adapter raises a runtime error with installation guidance.
134
+
135
+ ## For Library Developers
136
+
137
+ ### Environment Setup
138
+
139
+ 1. Install Python 3.14 (pyenv users can run `pyenv install 3.14.0`).
140
+ 1. Install [`uv`](https://github.com/astral-sh/uv).
141
+ 1. Sync the virtualenv and optional git hooks:
142
+ ```bash
143
+ uv sync
144
+ ./install-hooks.sh # optional – wires git hooks that call make check
145
+ ```
146
+ 1. Use `uv run ...` when invoking ad-hoc scripts so everything stays inside the managed environment.
147
+
148
+ ### Development Workflow
149
+
150
+ - `make format` / `make format-check` — run Ruff formatters.
151
+ - `make lint` / `make lint-fix` — lint with Ruff.
152
+ - `make typecheck` — execute Ty with warnings promoted to errors.
153
+ - `make test` — run pytest via `build/run_pytest.py` with `--cov-fail-under=100`.
154
+ - `make bandit`, `make deptry`, `make pip-audit` — security, dependency, and vulnerability audits.
155
+ - `make check` — aggregate the quiet quality gate; run this before every commit (git hooks enforce it).
156
+
157
+ ### Project Layout
158
+
159
+ - `src/weakincentives/` — package root for the Python module.
160
+ - `src/weakincentives/prompts/` — prompt, section, and tool primitives.
161
+ - `src/weakincentives/adapters/` — optional provider integrations.
162
+ - `tests/` — pytest suites covering prompts, tools, and adapters.
163
+ - `specs/` — design docs; see `specs/PROMPTS.md` for prompt requirements.
164
+ - `build/` — thin wrappers that keep CLI tools quiet inside `uv`.
165
+ - `hooks/` — symlink-friendly git hooks (install via `./install-hooks.sh`).
166
+
167
+ ### Release Notes
168
+
169
+ Version numbers come from git tags named `vX.Y.Z`. Tag the repository manually before pushing a release.
170
+
171
+ ### More Documentation
172
+
173
+ `AGENTS.md` captures the full agent handbook, workflows, and TDD expectations. `ROADMAP.md` and `specs/` document upcoming work and prompt requirements.
@@ -0,0 +1,20 @@
1
+ weakincentives/__init__.py,sha256=2hDTwJS-d3T6LPBd2dNcZvv-OLLjb8RV5UzuqUg3S7c,615
2
+ weakincentives/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ weakincentives/adapters/__init__.py,sha256=i4zRQQvL21f1up1NFSe9kk3U6E4Nxj3hYMkGHSc4xbE,923
4
+ weakincentives/adapters/core.py,sha256=UDo-Em289TiBwj6dau0tbssoSecyDEaYWyI5POPECiM,2345
5
+ weakincentives/adapters/openai.py,sha256=fDmh-V1_FO3tvvw68VJh9ggh-OW5Vl9HycwB7oSC6_w,12240
6
+ weakincentives/prompts/__init__.py,sha256=SQWvYq1je_dH_H55Yo8SaOawKPoOtODkuAsbMwvrZOo,1273
7
+ weakincentives/prompts/_types.py,sha256=y9-bB9Pt_bG-C0258UJ93oGq1zt-ktoutjAKkEsjSSk,904
8
+ weakincentives/prompts/errors.py,sha256=DR3GN54oTnNARkto3mVbIuT6BwhijTP3onLpcB6jdq0,1664
9
+ weakincentives/prompts/prompt.py,sha256=k9D3O00vJb1YN-jKKB7vtKUPrOtj3ux6JpbHgjcNnX4,17152
10
+ weakincentives/prompts/response_format.py,sha256=1LyhgEy9pWrx0n0oiYDqPb69qPLeZY7W165C6DkjYrY,1723
11
+ weakincentives/prompts/section.py,sha256=kvbtsk7cWr3cSh9GxoPpsPItwI1cwV0ZgLzxUulbefw,4240
12
+ weakincentives/prompts/structured.py,sha256=sUyfMwYI7oHqbvISTf7OABUs4VFKKGBkl_7LD7qvcHo,4842
13
+ weakincentives/prompts/text.py,sha256=KRliScmPigC45zHV-SotD9UZ2RdIspkwPTiVCCp8kd4,3118
14
+ weakincentives/prompts/tool.py,sha256=uGOFW8F2cMs_RRODqsXl6BpVXXTI3rlfKeTG-AHW3YE,9051
15
+ weakincentives/serde/__init__.py,sha256=oGOvoKTF2txToLZJ2sRAH9SC5myO_-GFKi1X9YHdQ6w,1270
16
+ weakincentives/serde/dataclass_serde.py,sha256=g5fEq3ACq6xphB0yGxIB_gJAD2u4nUxhDEC9mOtOk1c,37886
17
+ weakincentives-0.2.0.dist-info/METADATA,sha256=w1xpKkylT9qfaMjR5YxE00ux1yEX4bdQMzicO_kvyJc,5936
18
+ weakincentives-0.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
19
+ weakincentives-0.2.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
20
+ weakincentives-0.2.0.dist-info/RECORD,,
@@ -1,21 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: weakincentives
3
- Version: 0.1.0
4
- Summary: Tools for developing and optimizing side effect free background agents
5
- Author-email: Andrei Savu <andrei@weakincentives.com>
6
- License-File: LICENSE
7
- Requires-Python: >=3.14
8
- Description-Content-Type: text/markdown
9
-
10
- # weakincentives
11
- Tools for developing and optimizing side effect free background agents
12
-
13
- ## Setup
14
-
15
- ```bash
16
- # Install dependencies
17
- uv sync
18
-
19
- # Install git hooks
20
- ./install-hooks.sh
21
- ```
@@ -1,6 +0,0 @@
1
- weakincentives/__init__.py,sha256=-KKie-6SsxmXheAK6zrI6G1Ij75q7794xcUDj-eFImk,60
2
- weakincentives/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- weakincentives-0.1.0.dist-info/METADATA,sha256=nGxxU8A0gNEmH8689RvMfePDqfHhq714eMyqZzVTU2g,461
4
- weakincentives-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
- weakincentives-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
6
- weakincentives-0.1.0.dist-info/RECORD,,