zoku 0.1.1__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.
- zoku-0.1.1/LICENSE +21 -0
- zoku-0.1.1/PKG-INFO +232 -0
- zoku-0.1.1/README.md +215 -0
- zoku-0.1.1/pyproject.toml +33 -0
- zoku-0.1.1/setup.cfg +4 -0
- zoku-0.1.1/tests/test_zoku.py +462 -0
- zoku-0.1.1/zoku/__init__.py +11 -0
- zoku-0.1.1/zoku/__main__.py +6 -0
- zoku-0.1.1/zoku/cli.py +276 -0
- zoku-0.1.1/zoku/detector.py +238 -0
- zoku-0.1.1/zoku/hooks.py +156 -0
- zoku-0.1.1/zoku/installer.py +202 -0
- zoku-0.1.1/zoku/recorder.py +201 -0
- zoku-0.1.1/zoku.egg-info/PKG-INFO +232 -0
- zoku-0.1.1/zoku.egg-info/SOURCES.txt +16 -0
- zoku-0.1.1/zoku.egg-info/dependency_links.txt +1 -0
- zoku-0.1.1/zoku.egg-info/entry_points.txt +2 -0
- zoku-0.1.1/zoku.egg-info/top_level.txt +1 -0
zoku-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Zoku Contributors
|
|
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.
|
zoku-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: zoku
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Invisible automation layer for Claude Code. Watches your sessions, discovers repeated workflows, suggests automating them.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/kasparovabi/deja
|
|
7
|
+
Project-URL: Repository, https://github.com/kasparovabi/deja
|
|
8
|
+
Project-URL: Issues, https://github.com/kasparovabi/deja/issues
|
|
9
|
+
Keywords: claude-code,automation,workflow,hooks,patterns
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# Zoku
|
|
19
|
+
|
|
20
|
+
[](https://github.com/kasparovabi/deja/actions/workflows/ci.yml)
|
|
21
|
+
[](https://python.org)
|
|
22
|
+
[](LICENSE)
|
|
23
|
+
[](#technical-details)
|
|
24
|
+
|
|
25
|
+
**The invisible automation layer for Claude Code.**
|
|
26
|
+
|
|
27
|
+
<p align="center">
|
|
28
|
+
<img src="assets/demo.svg" alt="Zoku Demo" width="700">
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
Zoku is an open source Claude Code hook that runs silently in the background while you work. It watches every action you take across sessions, discovers repeated patterns in your workflow, and tells you about them so you can automate the boring parts.
|
|
32
|
+
|
|
33
|
+
You don't configure anything. You don't change how you work. You just install it once and forget about it. Zoku does the rest.
|
|
34
|
+
|
|
35
|
+
## The Problem
|
|
36
|
+
|
|
37
|
+
Every developer has habits they don't notice. You grep for something, open the file, edit it, run the tests, then fix the lint errors. You do this ten times a day without thinking about it. Multiply that across weeks and you're spending hours on sequences that could be a single command.
|
|
38
|
+
|
|
39
|
+
The issue is that nobody sits down and audits their own workflow. It's tedious, it's invisible, and honestly most people don't even realize they're repeating themselves.
|
|
40
|
+
|
|
41
|
+
## What Zoku Does
|
|
42
|
+
|
|
43
|
+
Zoku hooks into Claude Code's event system and records every tool action: file reads, edits, searches, bash commands, everything. It stores these as session traces. When a session ends, Zoku runs a pattern detection algorithm across all your recorded sessions. It looks for contiguous subsequences of tool usage that appear in two or more sessions.
|
|
44
|
+
|
|
45
|
+
When you start a new session, Zoku loads the patterns it found and injects them into Claude's context. Claude now knows "hey, this user frequently does Grep then Read then Edit then Bash then Bash" and can proactively suggest or execute that workflow.
|
|
46
|
+
|
|
47
|
+
### How the Detection Works
|
|
48
|
+
|
|
49
|
+
1. Every `PostToolUse` event is recorded as an `Action` with the tool name, a short input summary, timestamp, and session ID
|
|
50
|
+
2. Actions within a session form a `SessionTrace`, which is essentially an ordered list of tool names
|
|
51
|
+
3. The detector extracts all contiguous subsequences of length 3 to 15 from each session
|
|
52
|
+
4. It counts how many *distinct* sessions each subsequence appears in
|
|
53
|
+
5. Subsequences that appear in 2+ sessions become candidate patterns
|
|
54
|
+
6. Strict subsets of longer patterns are removed (if "A B C" is always part of "A B C D", only the longer one survives)
|
|
55
|
+
7. Results are sorted by frequency first, then by length
|
|
56
|
+
|
|
57
|
+
No machine learning, no cloud calls, no external dependencies. Pure algorithmic analysis using Python's standard library.
|
|
58
|
+
|
|
59
|
+
### What Gets Stored
|
|
60
|
+
|
|
61
|
+
All data lives in a `.zoku/` directory (local or global depending on your install):
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
.zoku/
|
|
65
|
+
traces/
|
|
66
|
+
2026-04-01_session123.jsonl # one JSONL file per session
|
|
67
|
+
2026-04-02_session456.jsonl
|
|
68
|
+
patterns.json # discovered workflow patterns
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Each line in a trace file is a JSON object:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{"tool": "Grep", "input_summary": "grep:TODO", "timestamp": "2026-04-01T14:30:00+00:00", "session_id": "abc123", "success": true}
|
|
75
|
+
{"tool": "Read", "input_summary": "/src/main.py", "timestamp": "2026-04-01T14:30:05+00:00", "session_id": "abc123", "success": true}
|
|
76
|
+
{"tool": "Edit", "input_summary": "edit:/src/main.py", "timestamp": "2026-04-01T14:30:15+00:00", "session_id": "abc123", "success": true}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Nothing sensitive is stored. Input summaries are truncated to 200 characters and only contain file paths or command previews, never file contents.
|
|
80
|
+
|
|
81
|
+
## Installation
|
|
82
|
+
|
|
83
|
+
### Quick Install (Recommended)
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install zoku && zoku setup
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
That's it. Two commands, zero configuration. Zoku installs globally and works in every project.
|
|
90
|
+
|
|
91
|
+
### Install from Claude Code
|
|
92
|
+
|
|
93
|
+
Already inside a Claude Code session? Just ask Claude:
|
|
94
|
+
|
|
95
|
+
> Install zoku for me: `pip install zoku && zoku setup`
|
|
96
|
+
|
|
97
|
+
Claude will run it and Zoku starts working immediately — in that session and every future one.
|
|
98
|
+
|
|
99
|
+
### Install from GitHub (latest development version)
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
pip install git+https://github.com/kasparovabi/deja.git && zoku setup
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Per-Project Install
|
|
106
|
+
|
|
107
|
+
If you only want Zoku active in a specific project:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
pip install zoku
|
|
111
|
+
cd your-project
|
|
112
|
+
zoku install
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
This writes to `your-project/.claude/settings.json` and creates `your-project/.zoku/`.
|
|
116
|
+
|
|
117
|
+
### Windows
|
|
118
|
+
|
|
119
|
+
Zoku automatically detects Windows and uses the correct Python path in hook commands. No manual configuration needed.
|
|
120
|
+
|
|
121
|
+
### Uninstalling
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
zoku uninstall --global # remove global hooks
|
|
125
|
+
zoku uninstall # remove project hooks
|
|
126
|
+
zoku clear # delete all recorded data
|
|
127
|
+
pip uninstall zoku # remove the package
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Usage
|
|
131
|
+
|
|
132
|
+
There is no usage. That's the point.
|
|
133
|
+
|
|
134
|
+
Install it and use Claude Code exactly as you always do. Zoku is completely invisible during your sessions. It only surfaces information when:
|
|
135
|
+
|
|
136
|
+
1. A session **ends** and new patterns are found (logged silently)
|
|
137
|
+
2. A session **starts** and previously discovered patterns exist (injected as context for Claude)
|
|
138
|
+
|
|
139
|
+
### CLI Commands
|
|
140
|
+
|
|
141
|
+
To inspect what Zoku has learned:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
zoku status # installation status, session count, pattern count
|
|
145
|
+
zoku patterns # list all discovered workflow patterns with details
|
|
146
|
+
zoku traces # show recorded sessions and their tool sequences
|
|
147
|
+
zoku analyse # force pattern analysis right now (normally happens on session end)
|
|
148
|
+
zoku clear # wipe all traces and patterns
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Example Output
|
|
152
|
+
|
|
153
|
+
After a few sessions, `zoku patterns` might show:
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
Discovered 3 workflow pattern(s):
|
|
157
|
+
|
|
158
|
+
Pattern 1: Grep > Read > Edit > Bash > Bash
|
|
159
|
+
Steps: Grep -> Read -> Edit -> Bash -> Bash
|
|
160
|
+
Seen in: 4 sessions
|
|
161
|
+
Example:
|
|
162
|
+
1. [Grep] grep:handleSubmit
|
|
163
|
+
2. [Read] /src/components/Form.tsx
|
|
164
|
+
3. [Edit] edit:/src/components/Form.tsx
|
|
165
|
+
4. [Bash] npm test
|
|
166
|
+
5. [Bash] npm run lint
|
|
167
|
+
|
|
168
|
+
Pattern 2: Read > Edit > Read > Edit
|
|
169
|
+
Steps: Read -> Edit -> Read -> Edit
|
|
170
|
+
Seen in: 3 sessions
|
|
171
|
+
|
|
172
|
+
Pattern 3: Glob > Read > Edit > Bash
|
|
173
|
+
Steps: Glob -> Read -> Edit -> Bash
|
|
174
|
+
Seen in: 2 sessions
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Architecture
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
zoku/
|
|
181
|
+
__init__.py # package metadata (version 0.1.0)
|
|
182
|
+
__main__.py # entry point: zoku
|
|
183
|
+
cli.py # 8 CLI commands (setup, install, uninstall, patterns, traces, status, analyse, clear)
|
|
184
|
+
recorder.py # Action/SessionTrace dataclasses, JSONL storage, summarise_input()
|
|
185
|
+
detector.py # Pattern detection: subsequence extraction, frequency counting, subset pruning
|
|
186
|
+
hooks.py # Claude Code hook handlers (PostToolUse, Stop, SessionStart)
|
|
187
|
+
installer.py # Hook registration into .claude/settings.json (local + global)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Hook Integration
|
|
191
|
+
|
|
192
|
+
Zoku registers three hooks in Claude Code's settings:
|
|
193
|
+
|
|
194
|
+
| Event | What Zoku Does | Timeout |
|
|
195
|
+
|-------|---------------|--------|
|
|
196
|
+
| `PostToolUse` | Records the action to the session's JSONL trace file | 5s |
|
|
197
|
+
| `Stop` | Loads all traces, runs pattern detection, saves new patterns | 15s |
|
|
198
|
+
| `SessionStart` | Loads saved patterns and injects them as context for Claude | 5s |
|
|
199
|
+
|
|
200
|
+
Hooks communicate via stdin/stdout JSON, following Claude Code's hook protocol. Exit code 0 means success (parse the JSON output), exit code 2 means blocking error.
|
|
201
|
+
|
|
202
|
+
## Technical Details
|
|
203
|
+
|
|
204
|
+
**Python Version**: 3.10+
|
|
205
|
+
|
|
206
|
+
**External Dependencies**: None. Everything uses Python's standard library (json, pathlib, dataclasses, argparse, datetime, shutil).
|
|
207
|
+
|
|
208
|
+
**Test Suite**: 49 tests covering all Zoku functionality. Run with:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
python -m pytest tests/ -v
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Data Safety**: Zoku never modifies your code, never sends data anywhere, and never interferes with Claude Code's normal operation. It only *reads* hook events and *writes* to its own `.zoku/` directory.
|
|
215
|
+
|
|
216
|
+
## Roadmap
|
|
217
|
+
|
|
218
|
+
This project is part of a larger vision for AI coding tool infrastructure:
|
|
219
|
+
|
|
220
|
+
**Zoku v2**: Workflow replay (not just detection, but execution), cross project pattern aggregation, pattern sharing between team members
|
|
221
|
+
|
|
222
|
+
**AgentBlackBox**: SaaS audit trail for AI agent sessions. Full token cost tracking, decision tree visualization, compliance reporting for enterprises that need to prove what their AI agents did and why.
|
|
223
|
+
|
|
224
|
+
**MirrorMode**: Cross agent workflow translation. Record a workflow in Claude Code, replay it in Cursor or Aider. Universal session format that works across all AI coding tools.
|
|
225
|
+
|
|
226
|
+
## Contributing
|
|
227
|
+
|
|
228
|
+
This project is in active development. If you're interested in contributing, the codebase is intentionally simple and well tested. Every module is under 200 lines and uses no external dependencies.
|
|
229
|
+
|
|
230
|
+
## License
|
|
231
|
+
|
|
232
|
+
MIT
|
zoku-0.1.1/README.md
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# Zoku
|
|
2
|
+
|
|
3
|
+
[](https://github.com/kasparovabi/deja/actions/workflows/ci.yml)
|
|
4
|
+
[](https://python.org)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](#technical-details)
|
|
7
|
+
|
|
8
|
+
**The invisible automation layer for Claude Code.**
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<img src="assets/demo.svg" alt="Zoku Demo" width="700">
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
Zoku is an open source Claude Code hook that runs silently in the background while you work. It watches every action you take across sessions, discovers repeated patterns in your workflow, and tells you about them so you can automate the boring parts.
|
|
15
|
+
|
|
16
|
+
You don't configure anything. You don't change how you work. You just install it once and forget about it. Zoku does the rest.
|
|
17
|
+
|
|
18
|
+
## The Problem
|
|
19
|
+
|
|
20
|
+
Every developer has habits they don't notice. You grep for something, open the file, edit it, run the tests, then fix the lint errors. You do this ten times a day without thinking about it. Multiply that across weeks and you're spending hours on sequences that could be a single command.
|
|
21
|
+
|
|
22
|
+
The issue is that nobody sits down and audits their own workflow. It's tedious, it's invisible, and honestly most people don't even realize they're repeating themselves.
|
|
23
|
+
|
|
24
|
+
## What Zoku Does
|
|
25
|
+
|
|
26
|
+
Zoku hooks into Claude Code's event system and records every tool action: file reads, edits, searches, bash commands, everything. It stores these as session traces. When a session ends, Zoku runs a pattern detection algorithm across all your recorded sessions. It looks for contiguous subsequences of tool usage that appear in two or more sessions.
|
|
27
|
+
|
|
28
|
+
When you start a new session, Zoku loads the patterns it found and injects them into Claude's context. Claude now knows "hey, this user frequently does Grep then Read then Edit then Bash then Bash" and can proactively suggest or execute that workflow.
|
|
29
|
+
|
|
30
|
+
### How the Detection Works
|
|
31
|
+
|
|
32
|
+
1. Every `PostToolUse` event is recorded as an `Action` with the tool name, a short input summary, timestamp, and session ID
|
|
33
|
+
2. Actions within a session form a `SessionTrace`, which is essentially an ordered list of tool names
|
|
34
|
+
3. The detector extracts all contiguous subsequences of length 3 to 15 from each session
|
|
35
|
+
4. It counts how many *distinct* sessions each subsequence appears in
|
|
36
|
+
5. Subsequences that appear in 2+ sessions become candidate patterns
|
|
37
|
+
6. Strict subsets of longer patterns are removed (if "A B C" is always part of "A B C D", only the longer one survives)
|
|
38
|
+
7. Results are sorted by frequency first, then by length
|
|
39
|
+
|
|
40
|
+
No machine learning, no cloud calls, no external dependencies. Pure algorithmic analysis using Python's standard library.
|
|
41
|
+
|
|
42
|
+
### What Gets Stored
|
|
43
|
+
|
|
44
|
+
All data lives in a `.zoku/` directory (local or global depending on your install):
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
.zoku/
|
|
48
|
+
traces/
|
|
49
|
+
2026-04-01_session123.jsonl # one JSONL file per session
|
|
50
|
+
2026-04-02_session456.jsonl
|
|
51
|
+
patterns.json # discovered workflow patterns
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Each line in a trace file is a JSON object:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{"tool": "Grep", "input_summary": "grep:TODO", "timestamp": "2026-04-01T14:30:00+00:00", "session_id": "abc123", "success": true}
|
|
58
|
+
{"tool": "Read", "input_summary": "/src/main.py", "timestamp": "2026-04-01T14:30:05+00:00", "session_id": "abc123", "success": true}
|
|
59
|
+
{"tool": "Edit", "input_summary": "edit:/src/main.py", "timestamp": "2026-04-01T14:30:15+00:00", "session_id": "abc123", "success": true}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Nothing sensitive is stored. Input summaries are truncated to 200 characters and only contain file paths or command previews, never file contents.
|
|
63
|
+
|
|
64
|
+
## Installation
|
|
65
|
+
|
|
66
|
+
### Quick Install (Recommended)
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install zoku && zoku setup
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
That's it. Two commands, zero configuration. Zoku installs globally and works in every project.
|
|
73
|
+
|
|
74
|
+
### Install from Claude Code
|
|
75
|
+
|
|
76
|
+
Already inside a Claude Code session? Just ask Claude:
|
|
77
|
+
|
|
78
|
+
> Install zoku for me: `pip install zoku && zoku setup`
|
|
79
|
+
|
|
80
|
+
Claude will run it and Zoku starts working immediately — in that session and every future one.
|
|
81
|
+
|
|
82
|
+
### Install from GitHub (latest development version)
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pip install git+https://github.com/kasparovabi/deja.git && zoku setup
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Per-Project Install
|
|
89
|
+
|
|
90
|
+
If you only want Zoku active in a specific project:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
pip install zoku
|
|
94
|
+
cd your-project
|
|
95
|
+
zoku install
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
This writes to `your-project/.claude/settings.json` and creates `your-project/.zoku/`.
|
|
99
|
+
|
|
100
|
+
### Windows
|
|
101
|
+
|
|
102
|
+
Zoku automatically detects Windows and uses the correct Python path in hook commands. No manual configuration needed.
|
|
103
|
+
|
|
104
|
+
### Uninstalling
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
zoku uninstall --global # remove global hooks
|
|
108
|
+
zoku uninstall # remove project hooks
|
|
109
|
+
zoku clear # delete all recorded data
|
|
110
|
+
pip uninstall zoku # remove the package
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Usage
|
|
114
|
+
|
|
115
|
+
There is no usage. That's the point.
|
|
116
|
+
|
|
117
|
+
Install it and use Claude Code exactly as you always do. Zoku is completely invisible during your sessions. It only surfaces information when:
|
|
118
|
+
|
|
119
|
+
1. A session **ends** and new patterns are found (logged silently)
|
|
120
|
+
2. A session **starts** and previously discovered patterns exist (injected as context for Claude)
|
|
121
|
+
|
|
122
|
+
### CLI Commands
|
|
123
|
+
|
|
124
|
+
To inspect what Zoku has learned:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
zoku status # installation status, session count, pattern count
|
|
128
|
+
zoku patterns # list all discovered workflow patterns with details
|
|
129
|
+
zoku traces # show recorded sessions and their tool sequences
|
|
130
|
+
zoku analyse # force pattern analysis right now (normally happens on session end)
|
|
131
|
+
zoku clear # wipe all traces and patterns
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Example Output
|
|
135
|
+
|
|
136
|
+
After a few sessions, `zoku patterns` might show:
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
Discovered 3 workflow pattern(s):
|
|
140
|
+
|
|
141
|
+
Pattern 1: Grep > Read > Edit > Bash > Bash
|
|
142
|
+
Steps: Grep -> Read -> Edit -> Bash -> Bash
|
|
143
|
+
Seen in: 4 sessions
|
|
144
|
+
Example:
|
|
145
|
+
1. [Grep] grep:handleSubmit
|
|
146
|
+
2. [Read] /src/components/Form.tsx
|
|
147
|
+
3. [Edit] edit:/src/components/Form.tsx
|
|
148
|
+
4. [Bash] npm test
|
|
149
|
+
5. [Bash] npm run lint
|
|
150
|
+
|
|
151
|
+
Pattern 2: Read > Edit > Read > Edit
|
|
152
|
+
Steps: Read -> Edit -> Read -> Edit
|
|
153
|
+
Seen in: 3 sessions
|
|
154
|
+
|
|
155
|
+
Pattern 3: Glob > Read > Edit > Bash
|
|
156
|
+
Steps: Glob -> Read -> Edit -> Bash
|
|
157
|
+
Seen in: 2 sessions
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Architecture
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
zoku/
|
|
164
|
+
__init__.py # package metadata (version 0.1.0)
|
|
165
|
+
__main__.py # entry point: zoku
|
|
166
|
+
cli.py # 8 CLI commands (setup, install, uninstall, patterns, traces, status, analyse, clear)
|
|
167
|
+
recorder.py # Action/SessionTrace dataclasses, JSONL storage, summarise_input()
|
|
168
|
+
detector.py # Pattern detection: subsequence extraction, frequency counting, subset pruning
|
|
169
|
+
hooks.py # Claude Code hook handlers (PostToolUse, Stop, SessionStart)
|
|
170
|
+
installer.py # Hook registration into .claude/settings.json (local + global)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Hook Integration
|
|
174
|
+
|
|
175
|
+
Zoku registers three hooks in Claude Code's settings:
|
|
176
|
+
|
|
177
|
+
| Event | What Zoku Does | Timeout |
|
|
178
|
+
|-------|---------------|--------|
|
|
179
|
+
| `PostToolUse` | Records the action to the session's JSONL trace file | 5s |
|
|
180
|
+
| `Stop` | Loads all traces, runs pattern detection, saves new patterns | 15s |
|
|
181
|
+
| `SessionStart` | Loads saved patterns and injects them as context for Claude | 5s |
|
|
182
|
+
|
|
183
|
+
Hooks communicate via stdin/stdout JSON, following Claude Code's hook protocol. Exit code 0 means success (parse the JSON output), exit code 2 means blocking error.
|
|
184
|
+
|
|
185
|
+
## Technical Details
|
|
186
|
+
|
|
187
|
+
**Python Version**: 3.10+
|
|
188
|
+
|
|
189
|
+
**External Dependencies**: None. Everything uses Python's standard library (json, pathlib, dataclasses, argparse, datetime, shutil).
|
|
190
|
+
|
|
191
|
+
**Test Suite**: 49 tests covering all Zoku functionality. Run with:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
python -m pytest tests/ -v
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Data Safety**: Zoku never modifies your code, never sends data anywhere, and never interferes with Claude Code's normal operation. It only *reads* hook events and *writes* to its own `.zoku/` directory.
|
|
198
|
+
|
|
199
|
+
## Roadmap
|
|
200
|
+
|
|
201
|
+
This project is part of a larger vision for AI coding tool infrastructure:
|
|
202
|
+
|
|
203
|
+
**Zoku v2**: Workflow replay (not just detection, but execution), cross project pattern aggregation, pattern sharing between team members
|
|
204
|
+
|
|
205
|
+
**AgentBlackBox**: SaaS audit trail for AI agent sessions. Full token cost tracking, decision tree visualization, compliance reporting for enterprises that need to prove what their AI agents did and why.
|
|
206
|
+
|
|
207
|
+
**MirrorMode**: Cross agent workflow translation. Record a workflow in Claude Code, replay it in Cursor or Aider. Universal session format that works across all AI coding tools.
|
|
208
|
+
|
|
209
|
+
## Contributing
|
|
210
|
+
|
|
211
|
+
This project is in active development. If you're interested in contributing, the codebase is intentionally simple and well tested. Every module is under 200 lines and uses no external dependencies.
|
|
212
|
+
|
|
213
|
+
## License
|
|
214
|
+
|
|
215
|
+
MIT
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "zoku"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "Invisible automation layer for Claude Code. Watches your sessions, discovers repeated workflows, suggests automating them."
|
|
9
|
+
requires-python = ">=3.10"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
authors = []
|
|
12
|
+
keywords = ["claude-code", "automation", "workflow", "hooks", "patterns"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
17
|
+
]
|
|
18
|
+
dependencies = []
|
|
19
|
+
readme = "README.md"
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/kasparovabi/deja"
|
|
23
|
+
Repository = "https://github.com/kasparovabi/deja"
|
|
24
|
+
Issues = "https://github.com/kasparovabi/deja/issues"
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
zoku = "zoku.cli:main"
|
|
28
|
+
|
|
29
|
+
[tool.setuptools.packages.find]
|
|
30
|
+
include = ["zoku*"]
|
|
31
|
+
|
|
32
|
+
[tool.pytest.ini_options]
|
|
33
|
+
testpaths = ["tests"]
|
zoku-0.1.1/setup.cfg
ADDED