wrencode 0.2.0__tar.gz → 0.3.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: wrencode
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: A minimal agent harness for coding, in a single Python file
|
|
5
5
|
Project-URL: Homepage, https://github.com/almostly/wrencode
|
|
6
6
|
Project-URL: Repository, https://github.com/almostly/wrencode
|
|
@@ -14,6 +14,8 @@ Classifier: Intended Audience :: Developers
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
15
|
Classifier: Topic :: Software Development :: Code Generators
|
|
16
16
|
Requires-Python: >=3.9
|
|
17
|
+
Provides-Extra: agent-sdk
|
|
18
|
+
Requires-Dist: claude-agent-sdk; (python_version >= '3.10') and extra == 'agent-sdk'
|
|
17
19
|
Provides-Extra: mlx
|
|
18
20
|
Requires-Dist: mlx-lm; extra == 'mlx'
|
|
19
21
|
Provides-Extra: transformers
|
|
@@ -45,6 +47,7 @@ saved choice, e.g. for CI.
|
|
|
45
47
|
|Backend |Description |Availability |
|
|
46
48
|
|--------------|----------------------------------------|----------------------|
|
|
47
49
|
|`anthropic` |Claude via Anthropic API |binary + source |
|
|
50
|
+
|`claude-agent-sdk`|Claude Code's agent loop and tools via the Claude Agent SDK|source install, Python 3.10+|
|
|
48
51
|
|`openai` |GPT models via OpenAI API |binary + source |
|
|
49
52
|
|`openrouter` |Any model via OpenRouter |binary + source |
|
|
50
53
|
|`nanogpt` |Any model via NanoGPT |binary + source |
|
|
@@ -63,6 +66,29 @@ The default local models are
|
|
|
63
66
|
[`deburky/gpt-oss-claude-mlx`](https://huggingface.co/deburky/gpt-oss-claude-mlx)
|
|
64
67
|
(MLX) — override either with `MODEL=...`.
|
|
65
68
|
|
|
69
|
+
### Claude Agent SDK
|
|
70
|
+
|
|
71
|
+
The `claude-agent-sdk` backend hands each prompt to the
|
|
72
|
+
[Claude Agent SDK](https://code.claude.com/docs/en/agent-sdk/overview), which
|
|
73
|
+
runs Claude Code's own agent loop, tools and subagents. WrenCode shows the
|
|
74
|
+
stream, asks before edits and commands, and prints the cost of each turn.
|
|
75
|
+
Install the extra, then pick the backend in `/configure`:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install 'wrencode[agent-sdk]' # or: pip install claude-agent-sdk
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
It always authenticates with `ANTHROPIC_API_KEY`, so usage bills to your
|
|
82
|
+
Console credits, including the monthly API credits that come with Max and Team
|
|
83
|
+
plans. Subscription logins are never used. Multi-workspace keys need
|
|
84
|
+
`ANTHROPIC_WORKSPACE_ID`. The conversation resumes per project across restarts;
|
|
85
|
+
`/clear` starts a new one. Your `~/.claude` hooks, plugins and MCP servers are
|
|
86
|
+
not loaded; project instructions come from `AGENTS.md` / `CLAUDE.md`.
|
|
87
|
+
|
|
88
|
+
To run several prompts in parallel, each as its own agent with a fresh
|
|
89
|
+
context, see `examples/agent_sdk_swarm.py`. It prints every answer and the
|
|
90
|
+
total cost.
|
|
91
|
+
|
|
66
92
|
### OpenAI-compatible servers
|
|
67
93
|
|
|
68
94
|
`openai-compatible` talks to any server that implements OpenAI chat completions,
|
|
@@ -105,7 +131,15 @@ All file operations are sandboxed to the workspace root by default.
|
|
|
105
131
|
|
|
106
132
|
The `task` tool runs a nested agent loop on a fresh message history, so the
|
|
107
133
|
parent's context only grows by the returned summary — useful for context-heavy
|
|
108
|
-
subtasks.
|
|
134
|
+
subtasks.
|
|
135
|
+
|
|
136
|
+
Task calls made in the same reply run in parallel, up to
|
|
137
|
+
`WRENCODE_MAX_PARALLEL_SUBAGENTS` at a time (default 4), on every backend
|
|
138
|
+
except the in-process `mlx` and `transformers` ones. Ask for it in the prompt,
|
|
139
|
+
for example "analyze each file in docs/ with its own subagent, in parallel".
|
|
140
|
+
Each subagent's output is tagged `[1]`, `[2]`, and so on; approval prompts
|
|
141
|
+
take turns and pause the other agents' output until you answer. Escape stops
|
|
142
|
+
the whole batch. Recursion is capped by `WRENCODE_MAX_SUBAGENT_DEPTH` (default 2), and
|
|
109
143
|
each subagent round is bounded. For autonomous subagent runs, enable
|
|
110
144
|
`--yes` / `WRENCODE_AUTO_APPROVE` so sub-tool calls don't block on confirmation.
|
|
111
145
|
|
|
@@ -291,10 +325,12 @@ wrencode --configure
|
|
|
291
325
|
# Or from source — also prompts on first run
|
|
292
326
|
python3 wrencode.py
|
|
293
327
|
|
|
294
|
-
# Anthropic Claude
|
|
328
|
+
# Anthropic Claude (model list is fetched live from the API during /configure)
|
|
295
329
|
BACKEND=anthropic python3 wrencode.py
|
|
330
|
+
# Multi-workspace Anthropic keys also need a workspace id:
|
|
331
|
+
# ANTHROPIC_WORKSPACE_ID=wrkspc_... BACKEND=anthropic python3 wrencode.py
|
|
296
332
|
|
|
297
|
-
# OpenAI
|
|
333
|
+
# OpenAI (model list fetched live from the API during /configure)
|
|
298
334
|
BACKEND=openai MODEL=gpt-4o python3 wrencode.py
|
|
299
335
|
|
|
300
336
|
# OpenRouter
|
|
@@ -339,9 +375,13 @@ This publishes release assets:
|
|
|
339
375
|
|Command |Description |
|
|
340
376
|
|--------------|----------------------------------------------|
|
|
341
377
|
|`/help` |Show available commands |
|
|
342
|
-
|`/
|
|
378
|
+
|`/model` |Switch model, or `/model <id>` to set it directly|
|
|
379
|
+
|`/backend`, `/configure`|Switch backend, model and API key |
|
|
380
|
+
|`/clear` or `/c`|Clear conversation history |
|
|
343
381
|
|`/compact` |Summarize history to reduce context |
|
|
344
|
-
|`/q` or
|
|
382
|
+
|`/quit`, `/q` or `/exit`|Quit |
|
|
383
|
+
|
|
384
|
+
Type `/` to see matching commands: ↑↓ pick, Tab completes, Enter runs.
|
|
345
385
|
|
|
346
386
|
## Environment Variables
|
|
347
387
|
|
|
@@ -355,9 +395,11 @@ This publishes release assets:
|
|
|
355
395
|
|`WRENCODE_UNRESTRICTED_PATHS`|`0` |Allow paths outside workspace |
|
|
356
396
|
|`WRENCODE_AUTO_APPROVE` |`0` |Skip y/N confirmation for writes/commands (headless; also `--yes`)|
|
|
357
397
|
|`WRENCODE_MAX_SUBAGENT_DEPTH`|`2` |Max nested subagent recursion depth (`task` tool)|
|
|
358
|
-
|`
|
|
398
|
+
|`WRENCODE_MAX_PARALLEL_SUBAGENTS`|`4` |Subagents run at once from one reply; `1` runs them in order|
|
|
399
|
+
|`MAX_TOKENS` |`8192`, `16000` for Claude|Max tokens per response |
|
|
400
|
+
|`WRENCODE_EFFORT` |- |Claude reasoning effort: `low`, `medium`, `high`, `xhigh`, `max`|
|
|
359
401
|
|`WRENCODE_HTTP_TIMEOUT` |`600` |Seconds to wait for a model response|
|
|
360
|
-
|`WRENCODE_HTTP_RETRIES` |`2` |Retries on HTTP 429/5xx, with backoff|
|
|
402
|
+
|`WRENCODE_HTTP_RETRIES` |`2` |Retries on HTTP 429/5xx and network errors, with backoff|
|
|
361
403
|
|`WRENCODE_CONTEXT_TOKENS` |`128000` |Model context window, for auto-compaction|
|
|
362
404
|
|`WRENCODE_COMPACT_AT` |`0.75` |Compact at this fraction of the window (`0` disables)|
|
|
363
405
|
|`MAX_READ_BYTES` |`4MB` |Max file size to read |
|
|
@@ -370,6 +412,7 @@ This publishes release assets:
|
|
|
370
412
|
|`NANOGPT_API_KEY` |- |NanoGPT API key |
|
|
371
413
|
|`OPENAI_API_KEY` |- |OpenAI API key |
|
|
372
414
|
|`ANTHROPIC_API_KEY` |- |Anthropic API key |
|
|
415
|
+
|`ANTHROPIC_WORKSPACE_ID` |- |Anthropic workspace id (`wrkspc_…`); required for multi-workspace keys|
|
|
373
416
|
|`LOCAL_API_KEY` |`local` |Local proxy API key |
|
|
374
417
|
|`LOCAL_PORT` |`8082` |Local proxy port |
|
|
375
418
|
|`OLLAMA_HOST` |`http://localhost:11434`|Ollama server base URL |
|
|
@@ -22,6 +22,7 @@ saved choice, e.g. for CI.
|
|
|
22
22
|
|Backend |Description |Availability |
|
|
23
23
|
|--------------|----------------------------------------|----------------------|
|
|
24
24
|
|`anthropic` |Claude via Anthropic API |binary + source |
|
|
25
|
+
|`claude-agent-sdk`|Claude Code's agent loop and tools via the Claude Agent SDK|source install, Python 3.10+|
|
|
25
26
|
|`openai` |GPT models via OpenAI API |binary + source |
|
|
26
27
|
|`openrouter` |Any model via OpenRouter |binary + source |
|
|
27
28
|
|`nanogpt` |Any model via NanoGPT |binary + source |
|
|
@@ -40,6 +41,29 @@ The default local models are
|
|
|
40
41
|
[`deburky/gpt-oss-claude-mlx`](https://huggingface.co/deburky/gpt-oss-claude-mlx)
|
|
41
42
|
(MLX) — override either with `MODEL=...`.
|
|
42
43
|
|
|
44
|
+
### Claude Agent SDK
|
|
45
|
+
|
|
46
|
+
The `claude-agent-sdk` backend hands each prompt to the
|
|
47
|
+
[Claude Agent SDK](https://code.claude.com/docs/en/agent-sdk/overview), which
|
|
48
|
+
runs Claude Code's own agent loop, tools and subagents. WrenCode shows the
|
|
49
|
+
stream, asks before edits and commands, and prints the cost of each turn.
|
|
50
|
+
Install the extra, then pick the backend in `/configure`:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install 'wrencode[agent-sdk]' # or: pip install claude-agent-sdk
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
It always authenticates with `ANTHROPIC_API_KEY`, so usage bills to your
|
|
57
|
+
Console credits, including the monthly API credits that come with Max and Team
|
|
58
|
+
plans. Subscription logins are never used. Multi-workspace keys need
|
|
59
|
+
`ANTHROPIC_WORKSPACE_ID`. The conversation resumes per project across restarts;
|
|
60
|
+
`/clear` starts a new one. Your `~/.claude` hooks, plugins and MCP servers are
|
|
61
|
+
not loaded; project instructions come from `AGENTS.md` / `CLAUDE.md`.
|
|
62
|
+
|
|
63
|
+
To run several prompts in parallel, each as its own agent with a fresh
|
|
64
|
+
context, see `examples/agent_sdk_swarm.py`. It prints every answer and the
|
|
65
|
+
total cost.
|
|
66
|
+
|
|
43
67
|
### OpenAI-compatible servers
|
|
44
68
|
|
|
45
69
|
`openai-compatible` talks to any server that implements OpenAI chat completions,
|
|
@@ -82,7 +106,15 @@ All file operations are sandboxed to the workspace root by default.
|
|
|
82
106
|
|
|
83
107
|
The `task` tool runs a nested agent loop on a fresh message history, so the
|
|
84
108
|
parent's context only grows by the returned summary — useful for context-heavy
|
|
85
|
-
subtasks.
|
|
109
|
+
subtasks.
|
|
110
|
+
|
|
111
|
+
Task calls made in the same reply run in parallel, up to
|
|
112
|
+
`WRENCODE_MAX_PARALLEL_SUBAGENTS` at a time (default 4), on every backend
|
|
113
|
+
except the in-process `mlx` and `transformers` ones. Ask for it in the prompt,
|
|
114
|
+
for example "analyze each file in docs/ with its own subagent, in parallel".
|
|
115
|
+
Each subagent's output is tagged `[1]`, `[2]`, and so on; approval prompts
|
|
116
|
+
take turns and pause the other agents' output until you answer. Escape stops
|
|
117
|
+
the whole batch. Recursion is capped by `WRENCODE_MAX_SUBAGENT_DEPTH` (default 2), and
|
|
86
118
|
each subagent round is bounded. For autonomous subagent runs, enable
|
|
87
119
|
`--yes` / `WRENCODE_AUTO_APPROVE` so sub-tool calls don't block on confirmation.
|
|
88
120
|
|
|
@@ -268,10 +300,12 @@ wrencode --configure
|
|
|
268
300
|
# Or from source — also prompts on first run
|
|
269
301
|
python3 wrencode.py
|
|
270
302
|
|
|
271
|
-
# Anthropic Claude
|
|
303
|
+
# Anthropic Claude (model list is fetched live from the API during /configure)
|
|
272
304
|
BACKEND=anthropic python3 wrencode.py
|
|
305
|
+
# Multi-workspace Anthropic keys also need a workspace id:
|
|
306
|
+
# ANTHROPIC_WORKSPACE_ID=wrkspc_... BACKEND=anthropic python3 wrencode.py
|
|
273
307
|
|
|
274
|
-
# OpenAI
|
|
308
|
+
# OpenAI (model list fetched live from the API during /configure)
|
|
275
309
|
BACKEND=openai MODEL=gpt-4o python3 wrencode.py
|
|
276
310
|
|
|
277
311
|
# OpenRouter
|
|
@@ -316,9 +350,13 @@ This publishes release assets:
|
|
|
316
350
|
|Command |Description |
|
|
317
351
|
|--------------|----------------------------------------------|
|
|
318
352
|
|`/help` |Show available commands |
|
|
319
|
-
|`/
|
|
353
|
+
|`/model` |Switch model, or `/model <id>` to set it directly|
|
|
354
|
+
|`/backend`, `/configure`|Switch backend, model and API key |
|
|
355
|
+
|`/clear` or `/c`|Clear conversation history |
|
|
320
356
|
|`/compact` |Summarize history to reduce context |
|
|
321
|
-
|`/q` or
|
|
357
|
+
|`/quit`, `/q` or `/exit`|Quit |
|
|
358
|
+
|
|
359
|
+
Type `/` to see matching commands: ↑↓ pick, Tab completes, Enter runs.
|
|
322
360
|
|
|
323
361
|
## Environment Variables
|
|
324
362
|
|
|
@@ -332,9 +370,11 @@ This publishes release assets:
|
|
|
332
370
|
|`WRENCODE_UNRESTRICTED_PATHS`|`0` |Allow paths outside workspace |
|
|
333
371
|
|`WRENCODE_AUTO_APPROVE` |`0` |Skip y/N confirmation for writes/commands (headless; also `--yes`)|
|
|
334
372
|
|`WRENCODE_MAX_SUBAGENT_DEPTH`|`2` |Max nested subagent recursion depth (`task` tool)|
|
|
335
|
-
|`
|
|
373
|
+
|`WRENCODE_MAX_PARALLEL_SUBAGENTS`|`4` |Subagents run at once from one reply; `1` runs them in order|
|
|
374
|
+
|`MAX_TOKENS` |`8192`, `16000` for Claude|Max tokens per response |
|
|
375
|
+
|`WRENCODE_EFFORT` |- |Claude reasoning effort: `low`, `medium`, `high`, `xhigh`, `max`|
|
|
336
376
|
|`WRENCODE_HTTP_TIMEOUT` |`600` |Seconds to wait for a model response|
|
|
337
|
-
|`WRENCODE_HTTP_RETRIES` |`2` |Retries on HTTP 429/5xx, with backoff|
|
|
377
|
+
|`WRENCODE_HTTP_RETRIES` |`2` |Retries on HTTP 429/5xx and network errors, with backoff|
|
|
338
378
|
|`WRENCODE_CONTEXT_TOKENS` |`128000` |Model context window, for auto-compaction|
|
|
339
379
|
|`WRENCODE_COMPACT_AT` |`0.75` |Compact at this fraction of the window (`0` disables)|
|
|
340
380
|
|`MAX_READ_BYTES` |`4MB` |Max file size to read |
|
|
@@ -347,6 +387,7 @@ This publishes release assets:
|
|
|
347
387
|
|`NANOGPT_API_KEY` |- |NanoGPT API key |
|
|
348
388
|
|`OPENAI_API_KEY` |- |OpenAI API key |
|
|
349
389
|
|`ANTHROPIC_API_KEY` |- |Anthropic API key |
|
|
390
|
+
|`ANTHROPIC_WORKSPACE_ID` |- |Anthropic workspace id (`wrkspc_…`); required for multi-workspace keys|
|
|
350
391
|
|`LOCAL_API_KEY` |`local` |Local proxy API key |
|
|
351
392
|
|`LOCAL_PORT` |`8082` |Local proxy port |
|
|
352
393
|
|`OLLAMA_HOST` |`http://localhost:11434`|Ollama server base URL |
|
|
@@ -34,6 +34,8 @@ dependencies = []
|
|
|
34
34
|
[project.optional-dependencies]
|
|
35
35
|
mlx = ["mlx-lm"]
|
|
36
36
|
transformers = ["transformers", "torch"]
|
|
37
|
+
# Claude Code's agent loop as a backend; the SDK needs Python 3.10+.
|
|
38
|
+
agent-sdk = ["claude-agent-sdk; python_version >= '3.10'"]
|
|
37
39
|
|
|
38
40
|
[project.scripts]
|
|
39
41
|
wrencode = "wrencode:main"
|
|
@@ -55,7 +57,7 @@ include = ["wrencode.py", "README.md"]
|
|
|
55
57
|
|
|
56
58
|
[tool.commitizen]
|
|
57
59
|
name = "cz_conventional_commits"
|
|
58
|
-
version = "0.
|
|
60
|
+
version = "0.3.0"
|
|
59
61
|
version_scheme = "pep440"
|
|
60
62
|
tag_format = "$version"
|
|
61
63
|
legacy_tag_formats = ["v$version"]
|
|
@@ -64,3 +66,19 @@ update_changelog_on_bump = true
|
|
|
64
66
|
changelog_incremental = true
|
|
65
67
|
# Pre-commitizen four-part tags (0.1.4.x); their history is in CHANGELOG.md.
|
|
66
68
|
ignored_tag_formats = ["$major.$minor.$patch.*"]
|
|
69
|
+
|
|
70
|
+
[tool.ty.analysis]
|
|
71
|
+
# Optional at runtime, so not installed in the dev environment: certifi is
|
|
72
|
+
# soft-imported for the frozen binary's CA bundle, mlx-lm and transformers/torch
|
|
73
|
+
# are the [mlx]/[transformers] extras, claude_agent_sdk is the [agent-sdk]
|
|
74
|
+
# extra, and modal is only for examples/modal_vllm.py.
|
|
75
|
+
allowed-unresolved-imports = [
|
|
76
|
+
"certifi",
|
|
77
|
+
"mlx_lm",
|
|
78
|
+
"mlx_lm.*",
|
|
79
|
+
"torch",
|
|
80
|
+
"transformers",
|
|
81
|
+
"modal",
|
|
82
|
+
"claude_agent_sdk",
|
|
83
|
+
"claude_agent_sdk.*",
|
|
84
|
+
]
|