ziplex 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.
Files changed (91) hide show
  1. ziplex-0.1.0/LICENSE +21 -0
  2. ziplex-0.1.0/PKG-INFO +261 -0
  3. ziplex-0.1.0/README.md +200 -0
  4. ziplex-0.1.0/pyproject.toml +73 -0
  5. ziplex-0.1.0/setup.cfg +4 -0
  6. ziplex-0.1.0/src/ziplex/__init__.py +6 -0
  7. ziplex-0.1.0/src/ziplex/checkpoint.py +163 -0
  8. ziplex-0.1.0/src/ziplex/cli.py +430 -0
  9. ziplex-0.1.0/src/ziplex/confidence.py +131 -0
  10. ziplex-0.1.0/src/ziplex/config.py +111 -0
  11. ziplex-0.1.0/src/ziplex/corrector.py +192 -0
  12. ziplex-0.1.0/src/ziplex/edits.py +88 -0
  13. ziplex-0.1.0/src/ziplex/extract/__init__.py +0 -0
  14. ziplex-0.1.0/src/ziplex/extract/code/__init__.py +0 -0
  15. ziplex-0.1.0/src/ziplex/extract/code/compressor.py +99 -0
  16. ziplex-0.1.0/src/ziplex/extract/code/extractor.py +221 -0
  17. ziplex-0.1.0/src/ziplex/extract/code/languages.py +744 -0
  18. ziplex-0.1.0/src/ziplex/extract/code/parser.py +15 -0
  19. ziplex-0.1.0/src/ziplex/extract/text/__init__.py +0 -0
  20. ziplex-0.1.0/src/ziplex/extract/text/json.py +48 -0
  21. ziplex-0.1.0/src/ziplex/extract/text/markdown.py +201 -0
  22. ziplex-0.1.0/src/ziplex/extract/text/registry.py +23 -0
  23. ziplex-0.1.0/src/ziplex/extract/text/txt.py +62 -0
  24. ziplex-0.1.0/src/ziplex/file/__init__.py +0 -0
  25. ziplex-0.1.0/src/ziplex/file/collector.py +120 -0
  26. ziplex-0.1.0/src/ziplex/file/relationship.py +383 -0
  27. ziplex-0.1.0/src/ziplex/file/scanner.py +139 -0
  28. ziplex-0.1.0/src/ziplex/file/selector.py +92 -0
  29. ziplex-0.1.0/src/ziplex/file/textutil.py +32 -0
  30. ziplex-0.1.0/src/ziplex/freshness.py +157 -0
  31. ziplex-0.1.0/src/ziplex/gui/__init__.py +0 -0
  32. ziplex-0.1.0/src/ziplex/gui/gui_server.py +598 -0
  33. ziplex-0.1.0/src/ziplex/gui/index.html +28 -0
  34. ziplex-0.1.0/src/ziplex/gui/js/app.js +261 -0
  35. ziplex-0.1.0/src/ziplex/gui/js/graph.js +371 -0
  36. ziplex-0.1.0/src/ziplex/gui/js/i18n.js +327 -0
  37. ziplex-0.1.0/src/ziplex/gui/js/pack.js +337 -0
  38. ziplex-0.1.0/src/ziplex/gui/js/pages/files.js +105 -0
  39. ziplex-0.1.0/src/ziplex/gui/js/pages/landing.js +280 -0
  40. ziplex-0.1.0/src/ziplex/gui/js/pages/options.js +122 -0
  41. ziplex-0.1.0/src/ziplex/gui/js/pages/overview.js +43 -0
  42. ziplex-0.1.0/src/ziplex/gui/js/pages/relationships.js +87 -0
  43. ziplex-0.1.0/src/ziplex/gui/js/pages/search.js +55 -0
  44. ziplex-0.1.0/src/ziplex/gui/js/router.js +72 -0
  45. ziplex-0.1.0/src/ziplex/gui/pack_service.py +784 -0
  46. ziplex-0.1.0/src/ziplex/gui/style.css +475 -0
  47. ziplex-0.1.0/src/ziplex/gui/watcher.py +214 -0
  48. ziplex-0.1.0/src/ziplex/llm.py +321 -0
  49. ziplex-0.1.0/src/ziplex/mcp_server.py +52 -0
  50. ziplex-0.1.0/src/ziplex/packager.py +616 -0
  51. ziplex-0.1.0/src/ziplex/query_service.py +229 -0
  52. ziplex-0.1.0/src/ziplex/search.py +91 -0
  53. ziplex-0.1.0/src/ziplex/settings.py +125 -0
  54. ziplex-0.1.0/src/ziplex/skill_export.py +212 -0
  55. ziplex-0.1.0/src/ziplex/summarizer.py +191 -0
  56. ziplex-0.1.0/src/ziplex/tech_stack.py +315 -0
  57. ziplex-0.1.0/src/ziplex/text_references.py +98 -0
  58. ziplex-0.1.0/src/ziplex/tokenizer.py +148 -0
  59. ziplex-0.1.0/src/ziplex.egg-info/PKG-INFO +261 -0
  60. ziplex-0.1.0/src/ziplex.egg-info/SOURCES.txt +89 -0
  61. ziplex-0.1.0/src/ziplex.egg-info/dependency_links.txt +1 -0
  62. ziplex-0.1.0/src/ziplex.egg-info/entry_points.txt +4 -0
  63. ziplex-0.1.0/src/ziplex.egg-info/requires.txt +21 -0
  64. ziplex-0.1.0/src/ziplex.egg-info/top_level.txt +1 -0
  65. ziplex-0.1.0/tests/test_checkpoint.py +135 -0
  66. ziplex-0.1.0/tests/test_cli.py +112 -0
  67. ziplex-0.1.0/tests/test_code_compressor.py +234 -0
  68. ziplex-0.1.0/tests/test_collector.py +79 -0
  69. ziplex-0.1.0/tests/test_confidence.py +91 -0
  70. ziplex-0.1.0/tests/test_config.py +50 -0
  71. ziplex-0.1.0/tests/test_edits.py +96 -0
  72. ziplex-0.1.0/tests/test_extractor.py +575 -0
  73. ziplex-0.1.0/tests/test_freshness.py +160 -0
  74. ziplex-0.1.0/tests/test_gui_server.py +779 -0
  75. ziplex-0.1.0/tests/test_llm.py +146 -0
  76. ziplex-0.1.0/tests/test_mcp_server.py +227 -0
  77. ziplex-0.1.0/tests/test_pack_integration.py +988 -0
  78. ziplex-0.1.0/tests/test_pack_service.py +974 -0
  79. ziplex-0.1.0/tests/test_query_service.py +70 -0
  80. ziplex-0.1.0/tests/test_relationship.py +339 -0
  81. ziplex-0.1.0/tests/test_scanner.py +80 -0
  82. ziplex-0.1.0/tests/test_search.py +79 -0
  83. ziplex-0.1.0/tests/test_selector.py +48 -0
  84. ziplex-0.1.0/tests/test_settings.py +127 -0
  85. ziplex-0.1.0/tests/test_skill_export.py +184 -0
  86. ziplex-0.1.0/tests/test_summarizer.py +117 -0
  87. ziplex-0.1.0/tests/test_tech_stack.py +316 -0
  88. ziplex-0.1.0/tests/test_text_compressors.py +76 -0
  89. ziplex-0.1.0/tests/test_text_references.py +70 -0
  90. ziplex-0.1.0/tests/test_tokenizer.py +49 -0
  91. ziplex-0.1.0/tests/test_watcher.py +144 -0
ziplex-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 rim
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.
ziplex-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,261 @@
1
+ Metadata-Version: 2.4
2
+ Name: ziplex
3
+ Version: 0.1.0
4
+ Summary: Turn any local project into a token-reduced context file (aif.json) an AI can load instantly, instead of reading through hundreds of raw files.
5
+ Author: rim
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 rim
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/taerim0/Ziplex
29
+ Project-URL: Repository, https://github.com/taerim0/Ziplex
30
+ Classifier: Programming Language :: Python :: 3
31
+ Classifier: Programming Language :: Python :: 3.11
32
+ Classifier: License :: OSI Approved :: MIT License
33
+ Classifier: Operating System :: OS Independent
34
+ Classifier: Topic :: Software Development :: Documentation
35
+ Classifier: Topic :: Software Development :: Libraries
36
+ Classifier: Environment :: Console
37
+ Requires-Python: >=3.11
38
+ Description-Content-Type: text/markdown
39
+ License-File: LICENSE
40
+ Requires-Dist: tree-sitter
41
+ Requires-Dist: tree-sitter-python
42
+ Requires-Dist: tree-sitter-java
43
+ Requires-Dist: tree-sitter-typescript
44
+ Requires-Dist: tree-sitter-lua
45
+ Requires-Dist: tree-sitter-go
46
+ Requires-Dist: tree-sitter-cpp
47
+ Requires-Dist: tree-sitter-rust
48
+ Requires-Dist: tree-sitter-c-sharp
49
+ Requires-Dist: tree-sitter-language-pack
50
+ Requires-Dist: tiktoken
51
+ Requires-Dist: pathspec
52
+ Requires-Dist: python-dotenv
53
+ Requires-Dist: requests
54
+ Requires-Dist: mcp
55
+ Requires-Dist: flask
56
+ Requires-Dist: pywebview
57
+ Requires-Dist: watchdog
58
+ Provides-Extra: dev
59
+ Requires-Dist: pytest; extra == "dev"
60
+ Dynamic: license-file
61
+
62
+ # Ziplex
63
+
64
+ **English** | [한국어](README_ko.md)
65
+
66
+ **Turn any local project into a context file an AI can load instantly — instead of reading through hundreds of raw files.**
67
+
68
+ Ziplex walks a project, compresses and structures it with Tree-sitter, summarizes it with an LLM, and lets a human correct the result before it ships. The output is `aif.json`: a small, structured "AI context format" file.
69
+
70
+ > ⚠️ Under active development. Interfaces and output format may still change.
71
+
72
+ ---
73
+
74
+ ## How it works
75
+
76
+ Ziplex collects a project's files (skipping build artifacts and anything `.gitignore`d), security-scans them for secrets, and parses the safe ones with Tree-sitter to pull out signatures, imports, and API routes. Function bodies get compressed down to a single marker; an LLM then writes a one-line summary per file plus project-wide coding rules and an AI-facing guide. A human reviews and edits all of that — only low-confidence summaries get flagged, not every file — before the final `aif.json` (small, loaded up front) and its heavier sibling `detail.json` (full compressed body, fetched on demand) are saved.
77
+
78
+ ## Features
79
+
80
+ - **Multi-language, structure-aware compression** — Python, Java, TypeScript, JavaScript, Lua, GDScript, Go, C++, Rust, C# via Tree-sitter, plus dedicated JSON/Markdown/plain-text compressors, all preserving structure while cutting tokens. Works on any collection of local files with cross-file relationships, not just git repos — game mods and asset projects included.
81
+ - **Security scanning built in** — every file is checked for secrets (`secretlint`, regex fallback) before it ever enters the pipeline.
82
+ - **Human-in-the-loop, but it scales** — every LLM output (summaries, rules, project guide, dependency tree) is reviewable and editable, or skippable entirely with `--auto-correct`. Only low-confidence summaries get flagged for review — review time doesn't grow with project size.
83
+ - **Three ways to consume the result** — an [MCP server](#mcp-server) for Claude Code/Cursor/etc., a local [GUI](#gui) for packing and browsing without a terminal, or a [Claude Agent Skill export](#claude-agent-skill-export) that needs no server at all.
84
+ - **Cheap to keep current** — incremental re-pack only re-summarizes files that actually changed (content hash), retries with backoff on LLM flakiness, and checkpoints a failed run instead of restarting from scratch.
85
+ - **No API key required, if you want** — `pack --no-llm` skips every LLM call and still produces structural summaries, dependency graphs, and tech-stack detection. Scope any pack with `.ziplex.json`/`--include`/`--ignore`, and guard CI budgets with `--max-tokens`.
86
+
87
+ ## Quick start
88
+
89
+ ```bash
90
+ venv\Scripts\activate
91
+ pip install -e . # installs Ziplex + registers the ziplex/ziplex-gui/ziplex-mcp commands
92
+ ```
93
+
94
+ Add a `.env` with `GEMINI_API_KEY=...` (optionally `GEMINI_MODEL=...` too, if `gemini-flash-latest` is having a rough day — see [Tech stack](#tech-stack)), then:
95
+
96
+ ```bash
97
+ ziplex pack ./your-project/ # full pipeline, interactive
98
+ ziplex pack ./your-project/ --auto --auto-correct # fully non-interactive (CI, scripted runs)
99
+ ```
100
+
101
+ `--auto` (skip interactive file selection) and `--auto-correct` (skip interactive correction) are independent, so any combination of the two works. Re-running `pack` on a project you've packed before only re-summarizes files that actually changed (by content hash) — everything else reuses its previous summary instead of another LLM call.
102
+
103
+ <details>
104
+ <summary>Every <code>pack</code> flag</summary>
105
+
106
+ | Flag | Effect |
107
+ |---|---|
108
+ | `--auto` | Skip interactive file selection, include everything safe |
109
+ | `--auto-correct` | Skip interactive correction, auto-accept whatever the LLM produced |
110
+ | `-o, --output <path>` | Custom output path (writes `<path>` + sibling `.detail.json`/`.cache.json`) |
111
+ | `--no-cache` | Force-resummarize every file, ignoring any previous pack found on disk |
112
+ | `--include <patterns>` | Only pack files matching these comma-separated globs, on top of `.ziplex.json` (below) |
113
+ | `--ignore <patterns>` | Additionally exclude these comma-separated globs, on top of `.ziplex.json` |
114
+ | `--max-tokens N` (+ `--max-tokens-model M`) | CI guard: exit code 1 if the packed payload exceeds `N` tokens for model `M` (default GPT-4o) |
115
+ | `--no-llm` | No `GEMINI_API_KEY`/network at all — structural summaries only, `rules`/AI guide skipped |
116
+
117
+ </details>
118
+
119
+ ### Config file
120
+
121
+ `ziplex init ./your-project/` scaffolds `.ziplex.json` in the target project (not in Ziplex's own repo) so `include`/`ignore` glob patterns don't need retyping on every `pack`:
122
+
123
+ ```jsonc
124
+ // your-project/.ziplex.json
125
+ {
126
+ "include": ["src/**/*.py", "*.md"], // empty = everything not ignored (default)
127
+ "ignore": ["**/*.generated.*"] // extra patterns beyond DEFAULT_IGNORE/.gitignore
128
+ }
129
+ ```
130
+
131
+ `--include`/`--ignore` CLI flags add to this file's patterns rather than replacing them. Every subcommand that previews what `pack` would collect (`collect`, `tree`, `tokens`, `search`, `freshness`, `select`, `analyze`) reads the same file, so none of them drift out of sync with what a real `pack` on that project would actually see. Worth committing alongside the project the same way `aif.json`/`detail.json` already can (see Team use below) — it documents how that project gets packed.
132
+
133
+ <details>
134
+ <summary>Every command</summary>
135
+
136
+ | Command | Description |
137
+ |---|---|
138
+ | `pack <path>` | Full pipeline — the one most people want |
139
+ | `init <path>` | Scaffold `.ziplex.json` (`include`/`ignore` glob patterns) in the target project |
140
+ | `collect <path>` | File collection + security scan only |
141
+ | `tokens <path>` | Token count, before/after compression |
142
+ | `tree <path>` | Dependency tree only |
143
+ | `search <path> <pattern>` | Regex search across all safe files (`--context N`, `--ignore-case`) |
144
+ | `detail <name>.detail.json <file-key>` | Partial read of one file's compressed body (`--start`/`--end`) |
145
+ | `freshness <path> <name>.cache.json` | Hash-check `aif.json` against the files on disk — no LLM calls |
146
+ | `skill <name>.json` | Export as a Claude Agent Skill (`.claude/skills/<slug>/`) — no MCP server needed |
147
+ | `select <path>` | Interactive file selection only |
148
+ | `analyze <path>` | LLM analysis only |
149
+ | `signatures \| dependencies \| api \| compress \| debug <file>` | Run one extraction step on a single file |
150
+
151
+ </details>
152
+
153
+ ## Testing
154
+
155
+ ```bash
156
+ pip install -e ".[dev]" # adds pytest on top of the base install
157
+ pytest
158
+ ```
159
+
160
+ Covers the deterministic core — compressors, the Tree-sitter extractor, the collector's ignore/binary-file filtering, the dependency-graph operations (`build_tree`/`has_cycle`/`move_file`), and the pure `aif`-editing API — plus a full `pack()` run against a network-free `MockProvider` instead of Gemini, exercising checkpointing, parallel summaries, and token counting end to end without the cost or latency of a real LLM call.
161
+
162
+ Want to smoke-test `pack` against a real project without waiting on Gemini? `LLM_PROVIDER=mock ziplex pack <project> --auto --auto-correct` runs the whole pipeline network-free in under a second.
163
+
164
+ ## Output format
165
+
166
+ ```jsonc
167
+ // aif.json — small, loaded up front
168
+ {
169
+ "project": {
170
+ "name": "...", "prompt": "...",
171
+ "tech_stack": [{ "manifest": "package.json", "language": "JavaScript/TypeScript", "package_manager": "npm", "dependencies": ["react", "..."], "dependencies_truncated": false }]
172
+ },
173
+ "rules": ["..."],
174
+ "tokens": { "GPT-4o": { "original": 3100, "compressed": 749, "saved_pct": 75.8 } },
175
+ "files": { "src/App.tsx": { "summary": "...", "confidence": 0.83 } },
176
+ "relationships": { "src/App.tsx": { "internal": ["..."], "external": ["react"] } }
177
+ }
178
+ ```
179
+
180
+ ```jsonc
181
+ // out.detail.json — heavier, fetched only when a file actually needs a closer look
182
+ {
183
+ "src/App.tsx": { "compressed": "import React ...\n ⋮----\nexport default App" }
184
+ }
185
+ ```
186
+
187
+ ```jsonc
188
+ // out.cache.json — internal bookkeeping, not meant for an AI to read; a
189
+ // content-hash snapshot of what was packed, for check_freshness to diff
190
+ // against later
191
+ {
192
+ "src/App.tsx": "3b1c2e...(sha256)"
193
+ }
194
+ ```
195
+
196
+ ## MCP server
197
+
198
+ Query an already-packed project directly from Claude Code, Cursor, or any other MCP client — no copy-pasting `aif.json` into a prompt.
199
+
200
+ ```bash
201
+ ziplex-mcp # run directly (stdio transport)
202
+ claude mcp add ziplex -- ziplex-mcp # register with Claude Code
203
+ ```
204
+
205
+ | Tool | What it does |
206
+ |---|---|
207
+ | `get_overview(aif_path, project_path?)` | Project guide, coding rules, token stats — call this first |
208
+ | `list_files(aif_path, project_path?)` | Every file mapped to its summary + confidence score |
209
+ | `get_relationships(aif_path)` | The whole dependency graph at once — every file's internal/external edges |
210
+ | `get_dependents(aif_path, file)` | Files that directly depend on `file` |
211
+ | `get_blast_radius(aif_path, file)` | Every file transitively affected by a change to `file` |
212
+ | `get_detail(aif_path, file, start_line?, end_line?)` | A file's compressed source, in full or by line range |
213
+ | `check_freshness(project_path, aif_path)` | Hash-check the pack against the files on disk — no LLM calls |
214
+ | `search_project(project_path, pattern, ...)` | Regex search across the project's original files |
215
+
216
+ Read-only and deliberately so: every tool serves an `aif.json`/`detail.json` a human already reviewed via `correct_aif()` — none of them re-pack or re-correct a project on their own, since that would skip the human-in-the-loop step that's the point of Ziplex. `get_dependents`/`get_blast_radius` run on the same human-corrected `relationships` graph `pack` builds — not a fresh, uncorrected guess.
217
+
218
+ `aif.json`/`detail.json` are snapshots from the last `pack` run, so they can drift from an actively-changing project. Every tool above except `search_project` (which always reads files live) trusts that snapshot — call `check_freshness` first if you suspect it's gone stale, or just pass `project_path` to `get_overview`/`list_files` and let them check for you: a stale pack gets an extra `_stale` field in the result instead of silently being trusted. It won't fix anything, but it tells you whether a re-`pack` is warranted before you trust the rest.
219
+
220
+ ## GUI
221
+
222
+ A local, single-user GUI for two situations: packing a project without touching a terminal, and browsing an already-packed project somewhere Claude Code (or MCP generally) isn't available but a browser-based AI chat is.
223
+
224
+ ```bash
225
+ ziplex-gui # native window (pywebview)
226
+ ziplex-gui --aif out.json --project ./your-project/ # prefill the landing page
227
+ ziplex-gui --no-window # plain browser tab instead
228
+ ```
229
+
230
+ **Pack from the GUI** — pick a project folder with the native folder picker, check off which files to include (the same safe/dangerous split `collect`'s security scan produces), optionally check "no LLM" (`pack --no-llm`'s GUI equivalent), and watch the pack run in the background. Analysis pauses for review before anything is saved: edit the project name, guide, rules, and per-file summaries (only the low-confidence ones are flagged, same triage the CLI uses). The dependency graph opens as a collapsible whole-tree overview first — click a file's name once you've spotted one worth fixing to drop into an edit view for just that file, linking or unlinking individual edges (a file with more than one real parent keeps its other references intact).
231
+
232
+ **Browse an existing pack** — the same overview/files/relationships/detail/search views the MCP server exposes, as web pages instead of MCP tool calls. The Relationships page reuses the same whole-tree-then-edit-one-file flow packing uses, so a relationship noticed after the fact can be fixed without re-running the pipeline. Each page has a Copy button; the intended flow is looking around here and pasting what's useful into a separate AI chat by hand, not the GUI talking to that chat itself.
233
+
234
+ Binds to `127.0.0.1` only — no `--host` flag, no way to expose it to a network.
235
+
236
+ ## Claude Agent Skill export
237
+
238
+ A third way to reach a packed project, alongside the MCP server and the GUI — for when Claude Code is available but registering an MCP server isn't (or is more setup than the moment calls for):
239
+
240
+ ```bash
241
+ ziplex skill result/my-project.json # writes .claude/skills/my-project/
242
+ ziplex skill result/my-project.json -o some/dir # custom output directory
243
+ ```
244
+
245
+ Generates a [Claude Agent Skill](https://code.claude.com/docs/en/skills) — `SKILL.md` plus `references/overview.md`/`files.md`/`relationships.md`/`detail.json` — that Claude Code discovers and progressively loads on its own once it sits under `.claude/skills/`, no server process required. Unlike [repomix](https://repomix.com/guide/agent-skills-generation)'s equivalent `--skill-generate` feature, `references/files.md` never embeds full raw source — it stays to summaries and confidence scores, exactly what `aif.json` itself already restricts to; the *compressed* body only ships as `references/detail.json`. Committing the generated directory works the same way committing `aif.json`/`detail.json` does (see Team use below) — it's just files.
246
+
247
+ ## Team use
248
+
249
+ Ziplex packs one person's local snapshot — there's no shared server or live sync. That doesn't rule out team use, though: `aif.json`/`detail.json`/`cache.json` are just files, so a team can commit them to the project's own repo the same way any other generated-but-versioned artifact works.
250
+
251
+ - Whoever runs `pack` after a meaningful change commits the refreshed output alongside their code change.
252
+ - Everyone else's copy is only as current as the last commit that touched it — `check_freshness` (or `get_overview`/`list_files` with `project_path` passed, see above) tells them whether their working copy has drifted from what's committed, without re-`pack`ing just to find out.
253
+ - This is a convention, not a feature Ziplex enforces or coordinates: no merge/conflict resolution, and no defined "who wins" if two people repack independently before either commits.
254
+
255
+ ## Tech stack
256
+
257
+ Python 3.11 · [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) (Python/Java/TypeScript/JavaScript/Lua/GDScript/Go/C++/Rust/C# grammars, GDScript via `tree-sitter-language-pack`) · [tiktoken](https://github.com/openai/tiktoken) · Gemini API (`gemini-flash-latest` by default, overridable via `GEMINI_MODEL`; plain REST via `requests`) · [MCP](https://modelcontextprotocol.io/) · Flask · pywebview · `secretlint` · `pathspec`
258
+
259
+ ## License
260
+
261
+ [MIT](LICENSE)
ziplex-0.1.0/README.md ADDED
@@ -0,0 +1,200 @@
1
+ # Ziplex
2
+
3
+ **English** | [한국어](README_ko.md)
4
+
5
+ **Turn any local project into a context file an AI can load instantly — instead of reading through hundreds of raw files.**
6
+
7
+ Ziplex walks a project, compresses and structures it with Tree-sitter, summarizes it with an LLM, and lets a human correct the result before it ships. The output is `aif.json`: a small, structured "AI context format" file.
8
+
9
+ > ⚠️ Under active development. Interfaces and output format may still change.
10
+
11
+ ---
12
+
13
+ ## How it works
14
+
15
+ Ziplex collects a project's files (skipping build artifacts and anything `.gitignore`d), security-scans them for secrets, and parses the safe ones with Tree-sitter to pull out signatures, imports, and API routes. Function bodies get compressed down to a single marker; an LLM then writes a one-line summary per file plus project-wide coding rules and an AI-facing guide. A human reviews and edits all of that — only low-confidence summaries get flagged, not every file — before the final `aif.json` (small, loaded up front) and its heavier sibling `detail.json` (full compressed body, fetched on demand) are saved.
16
+
17
+ ## Features
18
+
19
+ - **Multi-language, structure-aware compression** — Python, Java, TypeScript, JavaScript, Lua, GDScript, Go, C++, Rust, C# via Tree-sitter, plus dedicated JSON/Markdown/plain-text compressors, all preserving structure while cutting tokens. Works on any collection of local files with cross-file relationships, not just git repos — game mods and asset projects included.
20
+ - **Security scanning built in** — every file is checked for secrets (`secretlint`, regex fallback) before it ever enters the pipeline.
21
+ - **Human-in-the-loop, but it scales** — every LLM output (summaries, rules, project guide, dependency tree) is reviewable and editable, or skippable entirely with `--auto-correct`. Only low-confidence summaries get flagged for review — review time doesn't grow with project size.
22
+ - **Three ways to consume the result** — an [MCP server](#mcp-server) for Claude Code/Cursor/etc., a local [GUI](#gui) for packing and browsing without a terminal, or a [Claude Agent Skill export](#claude-agent-skill-export) that needs no server at all.
23
+ - **Cheap to keep current** — incremental re-pack only re-summarizes files that actually changed (content hash), retries with backoff on LLM flakiness, and checkpoints a failed run instead of restarting from scratch.
24
+ - **No API key required, if you want** — `pack --no-llm` skips every LLM call and still produces structural summaries, dependency graphs, and tech-stack detection. Scope any pack with `.ziplex.json`/`--include`/`--ignore`, and guard CI budgets with `--max-tokens`.
25
+
26
+ ## Quick start
27
+
28
+ ```bash
29
+ venv\Scripts\activate
30
+ pip install -e . # installs Ziplex + registers the ziplex/ziplex-gui/ziplex-mcp commands
31
+ ```
32
+
33
+ Add a `.env` with `GEMINI_API_KEY=...` (optionally `GEMINI_MODEL=...` too, if `gemini-flash-latest` is having a rough day — see [Tech stack](#tech-stack)), then:
34
+
35
+ ```bash
36
+ ziplex pack ./your-project/ # full pipeline, interactive
37
+ ziplex pack ./your-project/ --auto --auto-correct # fully non-interactive (CI, scripted runs)
38
+ ```
39
+
40
+ `--auto` (skip interactive file selection) and `--auto-correct` (skip interactive correction) are independent, so any combination of the two works. Re-running `pack` on a project you've packed before only re-summarizes files that actually changed (by content hash) — everything else reuses its previous summary instead of another LLM call.
41
+
42
+ <details>
43
+ <summary>Every <code>pack</code> flag</summary>
44
+
45
+ | Flag | Effect |
46
+ |---|---|
47
+ | `--auto` | Skip interactive file selection, include everything safe |
48
+ | `--auto-correct` | Skip interactive correction, auto-accept whatever the LLM produced |
49
+ | `-o, --output <path>` | Custom output path (writes `<path>` + sibling `.detail.json`/`.cache.json`) |
50
+ | `--no-cache` | Force-resummarize every file, ignoring any previous pack found on disk |
51
+ | `--include <patterns>` | Only pack files matching these comma-separated globs, on top of `.ziplex.json` (below) |
52
+ | `--ignore <patterns>` | Additionally exclude these comma-separated globs, on top of `.ziplex.json` |
53
+ | `--max-tokens N` (+ `--max-tokens-model M`) | CI guard: exit code 1 if the packed payload exceeds `N` tokens for model `M` (default GPT-4o) |
54
+ | `--no-llm` | No `GEMINI_API_KEY`/network at all — structural summaries only, `rules`/AI guide skipped |
55
+
56
+ </details>
57
+
58
+ ### Config file
59
+
60
+ `ziplex init ./your-project/` scaffolds `.ziplex.json` in the target project (not in Ziplex's own repo) so `include`/`ignore` glob patterns don't need retyping on every `pack`:
61
+
62
+ ```jsonc
63
+ // your-project/.ziplex.json
64
+ {
65
+ "include": ["src/**/*.py", "*.md"], // empty = everything not ignored (default)
66
+ "ignore": ["**/*.generated.*"] // extra patterns beyond DEFAULT_IGNORE/.gitignore
67
+ }
68
+ ```
69
+
70
+ `--include`/`--ignore` CLI flags add to this file's patterns rather than replacing them. Every subcommand that previews what `pack` would collect (`collect`, `tree`, `tokens`, `search`, `freshness`, `select`, `analyze`) reads the same file, so none of them drift out of sync with what a real `pack` on that project would actually see. Worth committing alongside the project the same way `aif.json`/`detail.json` already can (see Team use below) — it documents how that project gets packed.
71
+
72
+ <details>
73
+ <summary>Every command</summary>
74
+
75
+ | Command | Description |
76
+ |---|---|
77
+ | `pack <path>` | Full pipeline — the one most people want |
78
+ | `init <path>` | Scaffold `.ziplex.json` (`include`/`ignore` glob patterns) in the target project |
79
+ | `collect <path>` | File collection + security scan only |
80
+ | `tokens <path>` | Token count, before/after compression |
81
+ | `tree <path>` | Dependency tree only |
82
+ | `search <path> <pattern>` | Regex search across all safe files (`--context N`, `--ignore-case`) |
83
+ | `detail <name>.detail.json <file-key>` | Partial read of one file's compressed body (`--start`/`--end`) |
84
+ | `freshness <path> <name>.cache.json` | Hash-check `aif.json` against the files on disk — no LLM calls |
85
+ | `skill <name>.json` | Export as a Claude Agent Skill (`.claude/skills/<slug>/`) — no MCP server needed |
86
+ | `select <path>` | Interactive file selection only |
87
+ | `analyze <path>` | LLM analysis only |
88
+ | `signatures \| dependencies \| api \| compress \| debug <file>` | Run one extraction step on a single file |
89
+
90
+ </details>
91
+
92
+ ## Testing
93
+
94
+ ```bash
95
+ pip install -e ".[dev]" # adds pytest on top of the base install
96
+ pytest
97
+ ```
98
+
99
+ Covers the deterministic core — compressors, the Tree-sitter extractor, the collector's ignore/binary-file filtering, the dependency-graph operations (`build_tree`/`has_cycle`/`move_file`), and the pure `aif`-editing API — plus a full `pack()` run against a network-free `MockProvider` instead of Gemini, exercising checkpointing, parallel summaries, and token counting end to end without the cost or latency of a real LLM call.
100
+
101
+ Want to smoke-test `pack` against a real project without waiting on Gemini? `LLM_PROVIDER=mock ziplex pack <project> --auto --auto-correct` runs the whole pipeline network-free in under a second.
102
+
103
+ ## Output format
104
+
105
+ ```jsonc
106
+ // aif.json — small, loaded up front
107
+ {
108
+ "project": {
109
+ "name": "...", "prompt": "...",
110
+ "tech_stack": [{ "manifest": "package.json", "language": "JavaScript/TypeScript", "package_manager": "npm", "dependencies": ["react", "..."], "dependencies_truncated": false }]
111
+ },
112
+ "rules": ["..."],
113
+ "tokens": { "GPT-4o": { "original": 3100, "compressed": 749, "saved_pct": 75.8 } },
114
+ "files": { "src/App.tsx": { "summary": "...", "confidence": 0.83 } },
115
+ "relationships": { "src/App.tsx": { "internal": ["..."], "external": ["react"] } }
116
+ }
117
+ ```
118
+
119
+ ```jsonc
120
+ // out.detail.json — heavier, fetched only when a file actually needs a closer look
121
+ {
122
+ "src/App.tsx": { "compressed": "import React ...\n ⋮----\nexport default App" }
123
+ }
124
+ ```
125
+
126
+ ```jsonc
127
+ // out.cache.json — internal bookkeeping, not meant for an AI to read; a
128
+ // content-hash snapshot of what was packed, for check_freshness to diff
129
+ // against later
130
+ {
131
+ "src/App.tsx": "3b1c2e...(sha256)"
132
+ }
133
+ ```
134
+
135
+ ## MCP server
136
+
137
+ Query an already-packed project directly from Claude Code, Cursor, or any other MCP client — no copy-pasting `aif.json` into a prompt.
138
+
139
+ ```bash
140
+ ziplex-mcp # run directly (stdio transport)
141
+ claude mcp add ziplex -- ziplex-mcp # register with Claude Code
142
+ ```
143
+
144
+ | Tool | What it does |
145
+ |---|---|
146
+ | `get_overview(aif_path, project_path?)` | Project guide, coding rules, token stats — call this first |
147
+ | `list_files(aif_path, project_path?)` | Every file mapped to its summary + confidence score |
148
+ | `get_relationships(aif_path)` | The whole dependency graph at once — every file's internal/external edges |
149
+ | `get_dependents(aif_path, file)` | Files that directly depend on `file` |
150
+ | `get_blast_radius(aif_path, file)` | Every file transitively affected by a change to `file` |
151
+ | `get_detail(aif_path, file, start_line?, end_line?)` | A file's compressed source, in full or by line range |
152
+ | `check_freshness(project_path, aif_path)` | Hash-check the pack against the files on disk — no LLM calls |
153
+ | `search_project(project_path, pattern, ...)` | Regex search across the project's original files |
154
+
155
+ Read-only and deliberately so: every tool serves an `aif.json`/`detail.json` a human already reviewed via `correct_aif()` — none of them re-pack or re-correct a project on their own, since that would skip the human-in-the-loop step that's the point of Ziplex. `get_dependents`/`get_blast_radius` run on the same human-corrected `relationships` graph `pack` builds — not a fresh, uncorrected guess.
156
+
157
+ `aif.json`/`detail.json` are snapshots from the last `pack` run, so they can drift from an actively-changing project. Every tool above except `search_project` (which always reads files live) trusts that snapshot — call `check_freshness` first if you suspect it's gone stale, or just pass `project_path` to `get_overview`/`list_files` and let them check for you: a stale pack gets an extra `_stale` field in the result instead of silently being trusted. It won't fix anything, but it tells you whether a re-`pack` is warranted before you trust the rest.
158
+
159
+ ## GUI
160
+
161
+ A local, single-user GUI for two situations: packing a project without touching a terminal, and browsing an already-packed project somewhere Claude Code (or MCP generally) isn't available but a browser-based AI chat is.
162
+
163
+ ```bash
164
+ ziplex-gui # native window (pywebview)
165
+ ziplex-gui --aif out.json --project ./your-project/ # prefill the landing page
166
+ ziplex-gui --no-window # plain browser tab instead
167
+ ```
168
+
169
+ **Pack from the GUI** — pick a project folder with the native folder picker, check off which files to include (the same safe/dangerous split `collect`'s security scan produces), optionally check "no LLM" (`pack --no-llm`'s GUI equivalent), and watch the pack run in the background. Analysis pauses for review before anything is saved: edit the project name, guide, rules, and per-file summaries (only the low-confidence ones are flagged, same triage the CLI uses). The dependency graph opens as a collapsible whole-tree overview first — click a file's name once you've spotted one worth fixing to drop into an edit view for just that file, linking or unlinking individual edges (a file with more than one real parent keeps its other references intact).
170
+
171
+ **Browse an existing pack** — the same overview/files/relationships/detail/search views the MCP server exposes, as web pages instead of MCP tool calls. The Relationships page reuses the same whole-tree-then-edit-one-file flow packing uses, so a relationship noticed after the fact can be fixed without re-running the pipeline. Each page has a Copy button; the intended flow is looking around here and pasting what's useful into a separate AI chat by hand, not the GUI talking to that chat itself.
172
+
173
+ Binds to `127.0.0.1` only — no `--host` flag, no way to expose it to a network.
174
+
175
+ ## Claude Agent Skill export
176
+
177
+ A third way to reach a packed project, alongside the MCP server and the GUI — for when Claude Code is available but registering an MCP server isn't (or is more setup than the moment calls for):
178
+
179
+ ```bash
180
+ ziplex skill result/my-project.json # writes .claude/skills/my-project/
181
+ ziplex skill result/my-project.json -o some/dir # custom output directory
182
+ ```
183
+
184
+ Generates a [Claude Agent Skill](https://code.claude.com/docs/en/skills) — `SKILL.md` plus `references/overview.md`/`files.md`/`relationships.md`/`detail.json` — that Claude Code discovers and progressively loads on its own once it sits under `.claude/skills/`, no server process required. Unlike [repomix](https://repomix.com/guide/agent-skills-generation)'s equivalent `--skill-generate` feature, `references/files.md` never embeds full raw source — it stays to summaries and confidence scores, exactly what `aif.json` itself already restricts to; the *compressed* body only ships as `references/detail.json`. Committing the generated directory works the same way committing `aif.json`/`detail.json` does (see Team use below) — it's just files.
185
+
186
+ ## Team use
187
+
188
+ Ziplex packs one person's local snapshot — there's no shared server or live sync. That doesn't rule out team use, though: `aif.json`/`detail.json`/`cache.json` are just files, so a team can commit them to the project's own repo the same way any other generated-but-versioned artifact works.
189
+
190
+ - Whoever runs `pack` after a meaningful change commits the refreshed output alongside their code change.
191
+ - Everyone else's copy is only as current as the last commit that touched it — `check_freshness` (or `get_overview`/`list_files` with `project_path` passed, see above) tells them whether their working copy has drifted from what's committed, without re-`pack`ing just to find out.
192
+ - This is a convention, not a feature Ziplex enforces or coordinates: no merge/conflict resolution, and no defined "who wins" if two people repack independently before either commits.
193
+
194
+ ## Tech stack
195
+
196
+ Python 3.11 · [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) (Python/Java/TypeScript/JavaScript/Lua/GDScript/Go/C++/Rust/C# grammars, GDScript via `tree-sitter-language-pack`) · [tiktoken](https://github.com/openai/tiktoken) · Gemini API (`gemini-flash-latest` by default, overridable via `GEMINI_MODEL`; plain REST via `requests`) · [MCP](https://modelcontextprotocol.io/) · Flask · pywebview · `secretlint` · `pathspec`
197
+
198
+ ## License
199
+
200
+ [MIT](LICENSE)
@@ -0,0 +1,73 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ziplex"
7
+ dynamic = ["version"]
8
+ description = "Turn any local project into a token-reduced context file (aif.json) an AI can load instantly, instead of reading through hundreds of raw files."
9
+ readme = "README.md"
10
+ license = { file = "LICENSE" }
11
+ authors = [{ name = "rim" }]
12
+ requires-python = ">=3.11"
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.11",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ "Topic :: Software Development :: Documentation",
19
+ "Topic :: Software Development :: Libraries",
20
+ "Environment :: Console",
21
+ ]
22
+ dependencies = [
23
+ "tree-sitter",
24
+ "tree-sitter-python",
25
+ "tree-sitter-java",
26
+ "tree-sitter-typescript",
27
+ "tree-sitter-lua",
28
+ "tree-sitter-go",
29
+ "tree-sitter-cpp",
30
+ "tree-sitter-rust",
31
+ "tree-sitter-c-sharp",
32
+ "tree-sitter-language-pack",
33
+ "tiktoken",
34
+ "pathspec",
35
+ "python-dotenv",
36
+ "requests",
37
+ "mcp",
38
+ "flask",
39
+ "pywebview",
40
+ "watchdog",
41
+ ]
42
+
43
+ [project.optional-dependencies]
44
+ dev = ["pytest"]
45
+
46
+ [project.urls]
47
+ Homepage = "https://github.com/taerim0/Ziplex"
48
+ Repository = "https://github.com/taerim0/Ziplex"
49
+
50
+ # `ziplex` covers pack/collect/tokens/tree/search/detail/freshness/skill/init
51
+ # (cli.py's own subcommands -- see the root CLAUDE.md's Commands section);
52
+ # ziplex-gui and ziplex-mcp are separate entry points, not `ziplex`
53
+ # subcommands, since each starts its own long-running process (a local
54
+ # server, a stdio MCP loop) instead of running once and exiting.
55
+ [project.scripts]
56
+ ziplex = "ziplex.cli:main"
57
+ ziplex-gui = "ziplex.gui.gui_server:main"
58
+ ziplex-mcp = "ziplex.mcp_server:main"
59
+
60
+ [tool.setuptools.dynamic]
61
+ version = { attr = "ziplex.__version__" }
62
+
63
+ [tool.setuptools.packages.find]
64
+ where = ["src"]
65
+
66
+ # The GUI's frontend (index.html/js/**/style.css) ships as package data --
67
+ # gui_server.py's Flask app serves these straight off disk next to itself
68
+ # (static_folder="."), so they need to actually be installed alongside the
69
+ # .py files, not left behind as source-only assets. CLAUDE.md files are
70
+ # Claude Code's own working notes for this repo, not runtime assets --
71
+ # deliberately excluded from the built package.
72
+ [tool.setuptools.package-data]
73
+ "ziplex.gui" = ["index.html", "style.css", "js/*.js", "js/pages/*.js"]
ziplex-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,6 @@
1
+ """Ziplex: local project -> aif.json, a token-reduced context format an AI
2
+ reads instead of raw files. See the repo root CLAUDE.md for the full
3
+ pipeline overview.
4
+ """
5
+
6
+ __version__ = "0.1.0"