zzm-agent 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.
- zzm_agent-0.1.0/PKG-INFO +12 -0
- zzm_agent-0.1.0/README.md +268 -0
- zzm_agent-0.1.0/pyproject.toml +24 -0
- zzm_agent-0.1.0/setup.cfg +4 -0
- zzm_agent-0.1.0/tests/test_agent_loop.py +1347 -0
- zzm_agent-0.1.0/tests/test_agent_replay.py +178 -0
- zzm_agent-0.1.0/tests/test_cli.py +1581 -0
- zzm_agent-0.1.0/tests/test_config_manager.py +128 -0
- zzm_agent-0.1.0/tests/test_constants.py +41 -0
- zzm_agent-0.1.0/tests/test_eval_runner.py +36 -0
- zzm_agent-0.1.0/tests/test_evolution.py +162 -0
- zzm_agent-0.1.0/tests/test_language_policy.py +39 -0
- zzm_agent-0.1.0/tests/test_memory_store.py +629 -0
- zzm_agent-0.1.0/tests/test_p1_acceptance.py +125 -0
- zzm_agent-0.1.0/tests/test_plugin_safety.py +82 -0
- zzm_agent-0.1.0/tests/test_plugins.py +396 -0
- zzm_agent-0.1.0/tests/test_progress_monitor.py +116 -0
- zzm_agent-0.1.0/tests/test_prompt_manager.py +106 -0
- zzm_agent-0.1.0/tests/test_query_engine_streaming.py +240 -0
- zzm_agent-0.1.0/tests/test_runtime_messages.py +76 -0
- zzm_agent-0.1.0/tests/test_runtime_records.py +115 -0
- zzm_agent-0.1.0/tests/test_runtime_state.py +837 -0
- zzm_agent-0.1.0/tests/test_state_lifecycle.py +82 -0
- zzm_agent-0.1.0/tests/test_state_serialization.py +206 -0
- zzm_agent-0.1.0/tests/test_tool_error_recovery.py +141 -0
- zzm_agent-0.1.0/tests/test_tool_registry.py +256 -0
- zzm_agent-0.1.0/tests/test_tool_results.py +95 -0
- zzm_agent-0.1.0/zzm_agent/__init__.py +3 -0
- zzm_agent-0.1.0/zzm_agent/cli_support/__init__.py +1 -0
- zzm_agent-0.1.0/zzm_agent/cli_support/commands.py +1269 -0
- zzm_agent-0.1.0/zzm_agent/cli_support/observability.py +485 -0
- zzm_agent-0.1.0/zzm_agent/cli_support/rendering.py +1148 -0
- zzm_agent-0.1.0/zzm_agent/cli_support/runtime.py +956 -0
- zzm_agent-0.1.0/zzm_agent/constants.py +56 -0
- zzm_agent-0.1.0/zzm_agent/core/__init__.py +3 -0
- zzm_agent-0.1.0/zzm_agent/core/agent_loop.py +1615 -0
- zzm_agent-0.1.0/zzm_agent/core/config.py +299 -0
- zzm_agent-0.1.0/zzm_agent/core/errors.py +175 -0
- zzm_agent-0.1.0/zzm_agent/core/hooks.py +200 -0
- zzm_agent-0.1.0/zzm_agent/core/language_policy.py +155 -0
- zzm_agent-0.1.0/zzm_agent/core/model_adapter.py +203 -0
- zzm_agent-0.1.0/zzm_agent/core/model_metadata.py +95 -0
- zzm_agent-0.1.0/zzm_agent/core/model_stream.py +104 -0
- zzm_agent-0.1.0/zzm_agent/core/observability.py +369 -0
- zzm_agent-0.1.0/zzm_agent/core/plugin.py +38 -0
- zzm_agent-0.1.0/zzm_agent/core/progress_monitor.py +158 -0
- zzm_agent-0.1.0/zzm_agent/core/query_engine.py +153 -0
- zzm_agent-0.1.0/zzm_agent/core/runtime_messages.py +88 -0
- zzm_agent-0.1.0/zzm_agent/core/runtime_records.py +492 -0
- zzm_agent-0.1.0/zzm_agent/core/runtime_state.py +1818 -0
- zzm_agent-0.1.0/zzm_agent/core/state_lifecycle.py +232 -0
- zzm_agent-0.1.0/zzm_agent/core/state_serialization.py +321 -0
- zzm_agent-0.1.0/zzm_agent/core/tool_registry.py +490 -0
- zzm_agent-0.1.0/zzm_agent/core/tool_results.py +372 -0
- zzm_agent-0.1.0/zzm_agent/eval/replay.py +202 -0
- zzm_agent-0.1.0/zzm_agent/eval/runner.py +339 -0
- zzm_agent-0.1.0/zzm_agent/evolution/__init__.py +1 -0
- zzm_agent-0.1.0/zzm_agent/evolution/optimizer.py +491 -0
- zzm_agent-0.1.0/zzm_agent/memory/__init__.py +4 -0
- zzm_agent-0.1.0/zzm_agent/memory/episodic_store.py +83 -0
- zzm_agent-0.1.0/zzm_agent/memory/history_store.py +33 -0
- zzm_agent-0.1.0/zzm_agent/memory/instructions.py +91 -0
- zzm_agent-0.1.0/zzm_agent/memory/io.py +166 -0
- zzm_agent-0.1.0/zzm_agent/memory/pinned_context.py +115 -0
- zzm_agent-0.1.0/zzm_agent/memory/retriever.py +115 -0
- zzm_agent-0.1.0/zzm_agent/memory/semantic_store.py +107 -0
- zzm_agent-0.1.0/zzm_agent/memory/session_store.py +288 -0
- zzm_agent-0.1.0/zzm_agent/memory/store.py +646 -0
- zzm_agent-0.1.0/zzm_agent/memory/token_counter.py +101 -0
- zzm_agent-0.1.0/zzm_agent/plugins/__init__.py +1 -0
- zzm_agent-0.1.0/zzm_agent/plugins/file_ops.py +472 -0
- zzm_agent-0.1.0/zzm_agent/plugins/search.py +309 -0
- zzm_agent-0.1.0/zzm_agent/plugins/shell.py +141 -0
- zzm_agent-0.1.0/zzm_agent/prompt/__init__.py +5 -0
- zzm_agent-0.1.0/zzm_agent/prompt/context_builder.py +103 -0
- zzm_agent-0.1.0/zzm_agent/prompt/manager.py +105 -0
- zzm_agent-0.1.0/zzm_agent/prompt/output_protocol.py +54 -0
- zzm_agent-0.1.0/zzm_agent/prompt/templates.py +55 -0
- zzm_agent-0.1.0/zzm_agent.egg-info/PKG-INFO +12 -0
- zzm_agent-0.1.0/zzm_agent.egg-info/SOURCES.txt +82 -0
- zzm_agent-0.1.0/zzm_agent.egg-info/dependency_links.txt +1 -0
- zzm_agent-0.1.0/zzm_agent.egg-info/entry_points.txt +2 -0
- zzm_agent-0.1.0/zzm_agent.egg-info/requires.txt +10 -0
- zzm_agent-0.1.0/zzm_agent.egg-info/top_level.txt +1 -0
zzm_agent-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: zzm-agent
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Requires-Python: >=3.11
|
|
5
|
+
Requires-Dist: openai>=1.30
|
|
6
|
+
Requires-Dist: pyyaml>=6.0
|
|
7
|
+
Requires-Dist: rich>=13.0
|
|
8
|
+
Provides-Extra: dev
|
|
9
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
10
|
+
Requires-Dist: pytest-mock>=3.14; extra == "dev"
|
|
11
|
+
Provides-Extra: context
|
|
12
|
+
Requires-Dist: tiktoken>=0.7.0; extra == "context"
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# zzm-agent
|
|
4
|
+
|
|
5
|
+
**A local-first personal coding agent and REPL for OpenAI-compatible chat models.**
|
|
6
|
+
|
|
7
|
+
[](https://www.python.org/)
|
|
8
|
+
[](https://platform.openai.com/docs/api-reference)
|
|
9
|
+
[](#usage)
|
|
10
|
+
[](#memory-and-sessions)
|
|
11
|
+
|
|
12
|
+
[English](README.md) · [简体中文](README.zh-CN.md)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
`zzm-agent` is built for hands-on project work: talk to a model, let it inspect and edit your workspace through tools, keep useful memories across sessions, and inspect the exact prompt payload sent to the model when debugging.
|
|
19
|
+
|
|
20
|
+
## At A Glance
|
|
21
|
+
|
|
22
|
+
| You get | Why it matters |
|
|
23
|
+
| --- | --- |
|
|
24
|
+
| Interactive REPL | Work with the agent continuously instead of sending one-off prompts. |
|
|
25
|
+
| OpenAI-compatible runtime | Use OpenAI, OpenRouter, DashScope-compatible endpoints, or local gateways. |
|
|
26
|
+
| Persistent sessions | Keep each conversation's history under its own session directory. |
|
|
27
|
+
| Semantic and episodic memory | Store explicit facts and recall summaries from previous sessions. |
|
|
28
|
+
| Tool plugins | Add file, search, shell, or custom tools with generated schemas. |
|
|
29
|
+
| Prompt snapshots | Inspect `latest_context.json` to see the exact latest model request. |
|
|
30
|
+
|
|
31
|
+
## Contents
|
|
32
|
+
|
|
33
|
+
- [Quick Start](#quick-start)
|
|
34
|
+
- [Configuration](#configuration)
|
|
35
|
+
- [Usage](#usage)
|
|
36
|
+
- [REPL Commands](#repl-commands)
|
|
37
|
+
- [Memory and Sessions](#memory-and-sessions)
|
|
38
|
+
- [Prompt Snapshots](#prompt-snapshots)
|
|
39
|
+
- [Tools and Plugins](#tools-and-plugins)
|
|
40
|
+
- [Development](#development)
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
git clone <your-repo-url>
|
|
46
|
+
cd zzm-agent
|
|
47
|
+
python -m venv .venv
|
|
48
|
+
.\.venv\Scripts\activate
|
|
49
|
+
pip install -e .
|
|
50
|
+
pip install -r requirements.txt
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Create `.env`:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
LLM_BASE_URL=https://api.openai.com/v1
|
|
57
|
+
LLM_API_KEY=your_api_key_here
|
|
58
|
+
LLM_MODEL_NAME=gpt-4o-mini
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Start the REPL:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
zzm-agent
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Configuration
|
|
68
|
+
|
|
69
|
+
`zzm-agent` loads `config.yaml` by default. You can override it with `--config` or `ZZM_AGENT_CONFIG`.
|
|
70
|
+
|
|
71
|
+
| Priority | Source |
|
|
72
|
+
| --- | --- |
|
|
73
|
+
| 1 | `--config <path>` |
|
|
74
|
+
| 2 | `ZZM_AGENT_CONFIG` |
|
|
75
|
+
| 3 | `./config.yaml` |
|
|
76
|
+
| 4 | Repository default `config.yaml` |
|
|
77
|
+
|
|
78
|
+
Minimal config:
|
|
79
|
+
|
|
80
|
+
```yaml
|
|
81
|
+
model:
|
|
82
|
+
base_url: "${LLM_BASE_URL}"
|
|
83
|
+
api_key: "${LLM_API_KEY}"
|
|
84
|
+
model_name: "${LLM_MODEL_NAME}"
|
|
85
|
+
temperature: 0.7
|
|
86
|
+
max_tokens: 4096
|
|
87
|
+
|
|
88
|
+
agent:
|
|
89
|
+
system_prompt: "You are zzm-agent, a concise and efficient personal assistant."
|
|
90
|
+
auto_approve: false
|
|
91
|
+
stream: true
|
|
92
|
+
tool_choice: "auto"
|
|
93
|
+
plugin_dirs:
|
|
94
|
+
- "zzm_agent/plugins"
|
|
95
|
+
|
|
96
|
+
memory:
|
|
97
|
+
path: ".zzm_agent/memory.json"
|
|
98
|
+
max_history: 50
|
|
99
|
+
retrieval_top_k: 3
|
|
100
|
+
max_context_tokens: 32000
|
|
101
|
+
compression_keep_recent: 10
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Usage
|
|
105
|
+
|
|
106
|
+
| Task | Command |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| Start the default REPL | `zzm-agent` |
|
|
109
|
+
| Start explicitly | `zzm-agent repl` |
|
|
110
|
+
| Resume or create a session | `zzm-agent repl --session my-session` |
|
|
111
|
+
| Use a custom config | `zzm-agent repl --config path/to/config.yaml` |
|
|
112
|
+
| Run replay eval | `zzm-agent eval --suite replay` |
|
|
113
|
+
| Run smoke eval with real LLM | `zzm-agent eval --suite smoke --llm` |
|
|
114
|
+
| Run full eval with real LLM | `zzm-agent eval --suite full --llm` |
|
|
115
|
+
|
|
116
|
+
## REPL Commands
|
|
117
|
+
|
|
118
|
+
| Command | Description |
|
|
119
|
+
| --- | --- |
|
|
120
|
+
| `/help` | Show command help. |
|
|
121
|
+
| `/tools` | List registered tools. |
|
|
122
|
+
| `/reload` | Reload plugin tools from disk. |
|
|
123
|
+
| `/models [filter]` | List models from the configured base URL. |
|
|
124
|
+
| `/model [id]` | Show or switch the active model. |
|
|
125
|
+
| `/stream [on, off, toggle, status]` | Show or change streaming output for this REPL session. |
|
|
126
|
+
| `/memory` | Show recent history and compression state. |
|
|
127
|
+
| `/sessions` | List known conversation sessions. |
|
|
128
|
+
| `/session <id>` | Switch to a specific session. |
|
|
129
|
+
| `/new` | Start a clean session. |
|
|
130
|
+
| `/remember <fact>` | Add a long-term semantic memory fact. |
|
|
131
|
+
| `/forget <keyword>` | Remove semantic memories matching a keyword. |
|
|
132
|
+
| `/search <keyword>` | Search semantic and episodic memories. |
|
|
133
|
+
| `/semantic` | List all semantic memory facts. |
|
|
134
|
+
| `/evolve run` | Generate a prompt candidate from current history. |
|
|
135
|
+
| `/evolve status` | Show the latest prompt evaluation status. |
|
|
136
|
+
| `/evolve diff [id]` | Show a prompt candidate diff. |
|
|
137
|
+
| `/evolve apply [id]` | Apply a prompt candidate. |
|
|
138
|
+
| `/evolve rollback` | Roll back prompt changes. |
|
|
139
|
+
| `/exit`, `/quit` | Exit the REPL. |
|
|
140
|
+
|
|
141
|
+
## Streaming
|
|
142
|
+
|
|
143
|
+
Streaming is enabled by default:
|
|
144
|
+
|
|
145
|
+
```yaml
|
|
146
|
+
agent:
|
|
147
|
+
stream: true
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Runtime changes apply only to the current REPL session:
|
|
151
|
+
|
|
152
|
+
```text
|
|
153
|
+
/stream status
|
|
154
|
+
/stream off
|
|
155
|
+
/stream on
|
|
156
|
+
/stream toggle
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Memory and Sessions
|
|
160
|
+
|
|
161
|
+
Memory is stored under the directory that contains `memory.path`.
|
|
162
|
+
|
|
163
|
+
```text
|
|
164
|
+
.zzm_agent/
|
|
165
|
+
|-- semantic.json
|
|
166
|
+
`-- sessions/
|
|
167
|
+
|-- index.json
|
|
168
|
+
|-- last_session.txt
|
|
169
|
+
`-- <session-id>/
|
|
170
|
+
|-- meta.json
|
|
171
|
+
|-- history.json
|
|
172
|
+
|-- episodic.json
|
|
173
|
+
`-- latest_context.json
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
| File | Purpose |
|
|
177
|
+
| --- | --- |
|
|
178
|
+
| `history.json` | Raw transcript for the active session. |
|
|
179
|
+
| `episodic.json` | Lightweight session summary for cross-session recall. |
|
|
180
|
+
| `semantic.json` | Explicit long-term facts added with `/remember`. |
|
|
181
|
+
| `latest_context.json` | Latest full model prompt snapshot saved before each model call. |
|
|
182
|
+
|
|
183
|
+
Context is assembled in this order:
|
|
184
|
+
|
|
185
|
+
1. System prompt
|
|
186
|
+
2. Retrieved semantic memory
|
|
187
|
+
3. Retrieved episodic memory
|
|
188
|
+
4. Pinned context inferred from the current turn
|
|
189
|
+
5. Current session history, compressed if needed
|
|
190
|
+
6. Current user input
|
|
191
|
+
|
|
192
|
+
## Prompt Snapshots
|
|
193
|
+
|
|
194
|
+
Before every model request, the active session receives:
|
|
195
|
+
|
|
196
|
+
```text
|
|
197
|
+
sessions/<session-id>/latest_context.json
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
The snapshot includes the latest request metadata and payload:
|
|
201
|
+
|
|
202
|
+
| Field | Meaning |
|
|
203
|
+
| --- | --- |
|
|
204
|
+
| `created_at` | Snapshot creation time. |
|
|
205
|
+
| `session_id` | Active session id. |
|
|
206
|
+
| `model` | Active model name. |
|
|
207
|
+
| `latest_user_input` | Current user input. |
|
|
208
|
+
| `stream` | Whether the request used streaming. |
|
|
209
|
+
| `tool_iteration` | Tool-loop iteration number. |
|
|
210
|
+
| `context_window` | Token and compression metadata. |
|
|
211
|
+
| `request.messages` | Full message payload sent to the model. |
|
|
212
|
+
| `request.tools` | Tool schemas included in the request. |
|
|
213
|
+
|
|
214
|
+
If a turn includes tool calls, the file is overwritten before each follow-up model call. It always represents the latest request.
|
|
215
|
+
|
|
216
|
+
## Tools and Plugins
|
|
217
|
+
|
|
218
|
+
Tools are registered through `ToolRegistry` and exposed as OpenAI-compatible function schemas.
|
|
219
|
+
|
|
220
|
+
| Module | Purpose |
|
|
221
|
+
| --- | --- |
|
|
222
|
+
| `file_ops` | Read, write, and edit files inside the workspace. |
|
|
223
|
+
| `search` | Search files and file contents inside the workspace. |
|
|
224
|
+
| `shell` | Run shell commands inside the workspace. |
|
|
225
|
+
|
|
226
|
+
Configure plugin directories in `config.yaml`:
|
|
227
|
+
|
|
228
|
+
```yaml
|
|
229
|
+
agent:
|
|
230
|
+
plugin_dirs:
|
|
231
|
+
- "zzm_agent/plugins"
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
| Risk level | Meaning |
|
|
235
|
+
| --- | --- |
|
|
236
|
+
| `low` | Usually safe inspection or read-only work. |
|
|
237
|
+
| `medium` | Actions that may modify files or state. |
|
|
238
|
+
| `high` | Actions such as shell execution that require stronger confirmation. |
|
|
239
|
+
|
|
240
|
+
Medium and high risk tools require confirmation unless explicitly auto-approved.
|
|
241
|
+
|
|
242
|
+
## Development
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
pytest tests -q
|
|
246
|
+
pytest tests/test_agent_loop.py -q
|
|
247
|
+
python -B -m compileall -q zzm_agent tests
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## Project Structure
|
|
251
|
+
|
|
252
|
+
```text
|
|
253
|
+
zzm_agent/
|
|
254
|
+
|-- cli_support/ # CLI runtime, rendering, and slash commands
|
|
255
|
+
|-- core/ # Agent loop, tool registry, errors, observability
|
|
256
|
+
|-- eval/ # Replay and evaluation runner
|
|
257
|
+
|-- evolution/ # Prompt optimization and candidate management
|
|
258
|
+
|-- memory/ # Sessions, history, semantic and episodic memory
|
|
259
|
+
`-- plugins/ # Built-in tools
|
|
260
|
+
|
|
261
|
+
tests/ # Pytest suite
|
|
262
|
+
docs/ # Design notes and change records
|
|
263
|
+
config.yaml # Default configuration
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## License
|
|
267
|
+
|
|
268
|
+
No license file is currently included. Add one before publishing or distributing the project.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "zzm-agent"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
requires-python = ">=3.11"
|
|
9
|
+
dependencies = [
|
|
10
|
+
"openai>=1.30",
|
|
11
|
+
"pyyaml>=6.0",
|
|
12
|
+
"rich>=13.0",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[project.optional-dependencies]
|
|
16
|
+
dev = ["pytest>=8.0", "pytest-mock>=3.14"]
|
|
17
|
+
context = ["tiktoken>=0.7.0"]
|
|
18
|
+
|
|
19
|
+
[project.scripts]
|
|
20
|
+
zzm-agent = "zzm_agent.cli_support.runtime:main"
|
|
21
|
+
|
|
22
|
+
[tool.setuptools.packages.find]
|
|
23
|
+
where = ["."]
|
|
24
|
+
include = ["zzm_agent*"]
|