compact-code 0.2.0__tar.gz → 0.2.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.
- {compact_code-0.2.0 → compact_code-0.2.1}/PKG-INFO +1 -1
- {compact_code-0.2.0 → compact_code-0.2.1}/pyproject.toml +1 -1
- {compact_code-0.2.0 → compact_code-0.2.1}/src/compact_code/__init__.py +1 -1
- {compact_code-0.2.0 → compact_code-0.2.1}/src/compact_code/hooks.py +12 -2
- {compact_code-0.2.0 → compact_code-0.2.1}/tests/test_ledger.py +3 -2
- {compact_code-0.2.0 → compact_code-0.2.1}/uv.lock +1 -1
- {compact_code-0.2.0 → compact_code-0.2.1}/.gitignore +0 -0
- {compact_code-0.2.0 → compact_code-0.2.1}/LICENSE +0 -0
- {compact_code-0.2.0 → compact_code-0.2.1}/README.md +0 -0
- {compact_code-0.2.0 → compact_code-0.2.1}/src/compact_code/cli.py +0 -0
- {compact_code-0.2.0 → compact_code-0.2.1}/src/compact_code/compactor.py +0 -0
- {compact_code-0.2.0 → compact_code-0.2.1}/src/compact_code/expand.py +0 -0
- {compact_code-0.2.0 → compact_code-0.2.1}/src/compact_code/ledger.py +0 -0
- {compact_code-0.2.0 → compact_code-0.2.1}/src/compact_code/tokens.py +0 -0
- {compact_code-0.2.0 → compact_code-0.2.1}/tests/test_cli.py +0 -0
- {compact_code-0.2.0 → compact_code-0.2.1}/tests/test_compactor.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: compact-code
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Dense Python for AI agents, readable view for humans. Same logic, ~30-55% fewer tokens.
|
|
5
5
|
Project-URL: Homepage, https://github.com/EmmanuelFreund/compact-code
|
|
6
6
|
Project-URL: Repository, https://github.com/EmmanuelFreund/compact-code
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "compact-code"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.1"
|
|
8
8
|
description = "Dense Python for AI agents, readable view for humans. Same logic, ~30-55% fewer tokens."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -2,10 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
4
|
import os
|
|
5
|
+
import shutil
|
|
5
6
|
|
|
6
7
|
HOOK_COMMAND = "compact-code hook"
|
|
7
8
|
|
|
8
9
|
|
|
10
|
+
def _hook_command():
|
|
11
|
+
"""Absolute path to the executable: hooks run in shells whose PATH may differ."""
|
|
12
|
+
exe = shutil.which("compact-code")
|
|
13
|
+
if exe:
|
|
14
|
+
return f'"{exe.replace(os.sep, "/")}" hook'
|
|
15
|
+
return HOOK_COMMAND
|
|
16
|
+
|
|
17
|
+
|
|
9
18
|
def settings_path(project=False):
|
|
10
19
|
if project:
|
|
11
20
|
return os.path.join(".claude", "settings.json")
|
|
@@ -27,11 +36,12 @@ def install(project=False):
|
|
|
27
36
|
post = settings.setdefault("hooks", {}).setdefault("PostToolUse", [])
|
|
28
37
|
for matcher in post:
|
|
29
38
|
for hook in matcher.get("hooks", []):
|
|
30
|
-
|
|
39
|
+
cmd = hook.get("command", "")
|
|
40
|
+
if "compact-code" in cmd and cmd.endswith(" hook"):
|
|
31
41
|
return path, False
|
|
32
42
|
post.append({
|
|
33
43
|
"matcher": "Read",
|
|
34
|
-
"hooks": [{"type": "command", "command":
|
|
44
|
+
"hooks": [{"type": "command", "command": _hook_command()}],
|
|
35
45
|
})
|
|
36
46
|
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
37
47
|
with open(path, "w", encoding="utf-8", newline="\n") as f:
|
|
@@ -81,7 +81,7 @@ def test_install_hook_project(compacted, capsys):
|
|
|
81
81
|
(compacted / ".claude" / "settings.json").read_text(encoding="utf-8"))
|
|
82
82
|
cmds = [h["command"]
|
|
83
83
|
for m in settings["hooks"]["PostToolUse"] for h in m["hooks"]]
|
|
84
|
-
assert
|
|
84
|
+
assert any("compact-code" in c and c.endswith(" hook") for c in cmds)
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
def test_install_hook_idempotent_and_merging(compacted):
|
|
@@ -98,4 +98,5 @@ def test_install_hook_idempotent_and_merging(compacted):
|
|
|
98
98
|
post = settings["hooks"]["PostToolUse"]
|
|
99
99
|
assert len(post) == 2
|
|
100
100
|
cmds = [h["command"] for m in post for h in m["hooks"]]
|
|
101
|
-
|
|
101
|
+
ours = [c for c in cmds if "compact-code" in c and c.endswith(" hook")]
|
|
102
|
+
assert len(ours) == 1 and "echo hi" in cmds
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|