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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: compact-code
3
- Version: 0.2.0
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.0"
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"
@@ -3,5 +3,5 @@
3
3
  from .compactor import compact_source, verify_equivalence
4
4
  from .expand import expand_source
5
5
 
6
- __version__ = "0.2.0"
6
+ __version__ = "0.2.1"
7
7
  __all__ = ["compact_source", "verify_equivalence", "expand_source", "__version__"]
@@ -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
- if HOOK_COMMAND in hook.get("command", ""):
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": HOOK_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 hooks.HOOK_COMMAND in cmds
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
- assert cmds.count(hooks.HOOK_COMMAND) == 1 and "echo hi" in cmds
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
@@ -138,7 +138,7 @@ wheels = [
138
138
 
139
139
  [[package]]
140
140
  name = "compact-code"
141
- version = "0.1.0"
141
+ version = "0.2.1"
142
142
  source = { editable = "." }
143
143
 
144
144
  [package.optional-dependencies]
File without changes
File without changes
File without changes