@theglitchking/babel-fish 2.4.0 → 2.4.1
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.
- package/.claude/project-map/generate.py +19 -2
- package/.claude/project-map/grader.py +16 -2
- package/.claude/project-map/mine-sessions.py +16 -2
- package/.claude/project-map/test_generate.py +33 -0
- package/.claude/project-map/test_grader.py +16 -0
- package/.claude/project-map/test_mine_sessions.py +13 -0
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +30 -0
- package/package.json +1 -1
|
@@ -44,6 +44,24 @@ PROJECT_ROOT = MAP_DIR.parent.parent
|
|
|
44
44
|
|
|
45
45
|
SECTIONS_DIR.mkdir(parents=True, exist_ok=True)
|
|
46
46
|
|
|
47
|
+
|
|
48
|
+
def configure_paths(project_root: Path) -> None:
|
|
49
|
+
"""Point every output at <project_root>/.claude/project-map/.
|
|
50
|
+
|
|
51
|
+
--project-root previously moved only the READ root: the map was written back
|
|
52
|
+
into whichever directory the script itself lived in, so mapping another
|
|
53
|
+
project produced nothing for the target and destroyed the script repo's own
|
|
54
|
+
map. Writes follow the root now.
|
|
55
|
+
"""
|
|
56
|
+
global PROJECT_ROOT, MAP_DIR, SECTIONS_DIR, CHECKSUMS, LEARNED_VOC, GLOSSARY
|
|
57
|
+
PROJECT_ROOT = project_root
|
|
58
|
+
MAP_DIR = project_root / '.claude' / 'project-map'
|
|
59
|
+
SECTIONS_DIR = MAP_DIR / 'sections'
|
|
60
|
+
CHECKSUMS = MAP_DIR / 'checksums.json'
|
|
61
|
+
LEARNED_VOC = MAP_DIR / 'learned-vocabulary.json'
|
|
62
|
+
GLOSSARY = MAP_DIR / 'glossary.json'
|
|
63
|
+
SECTIONS_DIR.mkdir(parents=True, exist_ok=True)
|
|
64
|
+
|
|
47
65
|
# ── Secrets guard ────────────────────────────────────────────────────────────
|
|
48
66
|
SECRET_PATTERNS = re.compile(
|
|
49
67
|
r'(?i)(password|secret|token|api_key|apikey|private_key|auth_token|'
|
|
@@ -1612,9 +1630,8 @@ def main() -> None:
|
|
|
1612
1630
|
parser.add_argument('--stack-json', type=Path, default=None, help='Path to stack.json from detect-stack.sh')
|
|
1613
1631
|
args = parser.parse_args()
|
|
1614
1632
|
|
|
1615
|
-
global PROJECT_ROOT
|
|
1616
1633
|
if args.project_root:
|
|
1617
|
-
|
|
1634
|
+
configure_paths(args.project_root.resolve())
|
|
1618
1635
|
|
|
1619
1636
|
print(f"[generate] Project root: {PROJECT_ROOT}")
|
|
1620
1637
|
|
|
@@ -32,6 +32,21 @@ PROJECT_ROOT = MAP_DIR.parent.parent
|
|
|
32
32
|
|
|
33
33
|
REPORTS_DIR.mkdir(parents=True, exist_ok=True)
|
|
34
34
|
|
|
35
|
+
|
|
36
|
+
def configure_paths(project_root: Path) -> None:
|
|
37
|
+
"""Grade the map belonging to project_root, not the script's own.
|
|
38
|
+
|
|
39
|
+
Previously --project-root moved only the path-validation root, so the
|
|
40
|
+
script's own sections were graded against a different project's filesystem —
|
|
41
|
+
producing a confident but meaningless score (0% vocabulary accuracy).
|
|
42
|
+
"""
|
|
43
|
+
global PROJECT_ROOT, MAP_DIR, SECTIONS_DIR, REPORTS_DIR
|
|
44
|
+
PROJECT_ROOT = project_root
|
|
45
|
+
MAP_DIR = project_root / '.claude' / 'project-map'
|
|
46
|
+
SECTIONS_DIR = MAP_DIR / 'sections'
|
|
47
|
+
REPORTS_DIR = MAP_DIR / 'reports'
|
|
48
|
+
REPORTS_DIR.mkdir(parents=True, exist_ok=True)
|
|
49
|
+
|
|
35
50
|
PASS_THRESHOLD = 90.0
|
|
36
51
|
|
|
37
52
|
# ── Secret pattern (mirrors generate.py) ─────────────────────────────────────
|
|
@@ -597,9 +612,8 @@ def main() -> None:
|
|
|
597
612
|
help='Override report output path')
|
|
598
613
|
args = parser.parse_args()
|
|
599
614
|
|
|
600
|
-
global PROJECT_ROOT
|
|
601
615
|
if args.project_root:
|
|
602
|
-
|
|
616
|
+
configure_paths(args.project_root.resolve())
|
|
603
617
|
|
|
604
618
|
print(f"[grader] Grading iteration {args.iteration}/{args.total}...")
|
|
605
619
|
|
|
@@ -36,6 +36,21 @@ LEARNED_VOC = SCRIPT_DIR / "learned-vocabulary.json"
|
|
|
36
36
|
MINE_CURSOR = SCRIPT_DIR / ".mine-cursor.json"
|
|
37
37
|
PROJECT_ROOT = SCRIPT_DIR.parent.parent
|
|
38
38
|
|
|
39
|
+
|
|
40
|
+
def configure_paths(project_root: Path) -> None:
|
|
41
|
+
"""Write mined aliases into project_root's map, not the script's own.
|
|
42
|
+
|
|
43
|
+
Previously --project-root selected whose TRANSCRIPTS to mine but left the
|
|
44
|
+
output pointed at the script's directory, so mining another project wrote
|
|
45
|
+
its aliases into this one's learned vocabulary.
|
|
46
|
+
"""
|
|
47
|
+
global PROJECT_ROOT, LEARNED_VOC, MINE_CURSOR
|
|
48
|
+
PROJECT_ROOT = project_root
|
|
49
|
+
map_dir = project_root / '.claude' / 'project-map'
|
|
50
|
+
LEARNED_VOC = map_dir / 'learned-vocabulary.json'
|
|
51
|
+
MINE_CURSOR = map_dir / '.mine-cursor.json'
|
|
52
|
+
map_dir.mkdir(parents=True, exist_ok=True)
|
|
53
|
+
|
|
39
54
|
# ── Config ───────────────────────────────────────────────────────────────────
|
|
40
55
|
MIN_SCORE = 5.0 # Minimum score to include in vocabulary
|
|
41
56
|
RECENCY_WINDOWS = [ # (days_threshold, weight)
|
|
@@ -466,9 +481,8 @@ def main() -> None:
|
|
|
466
481
|
help='Ignore the incremental cursor and re-mine every transcript')
|
|
467
482
|
args = parser.parse_args()
|
|
468
483
|
|
|
469
|
-
global PROJECT_ROOT
|
|
470
484
|
if args.project_root:
|
|
471
|
-
|
|
485
|
+
configure_paths(args.project_root.resolve())
|
|
472
486
|
|
|
473
487
|
print(f"[mine-sessions] Project root: {PROJECT_ROOT}")
|
|
474
488
|
|
|
@@ -237,6 +237,39 @@ def test_glossary_survives_foreign_project_root(g):
|
|
|
237
237
|
assert data["source"].endswith("01-vocabulary.md"), data["source"]
|
|
238
238
|
|
|
239
239
|
|
|
240
|
+
# ── --project-root write path (#15) ──────────────────────────────────────────
|
|
241
|
+
|
|
242
|
+
def test_project_root_relocates_every_output(g):
|
|
243
|
+
"""--project-root used to move only the READ root: the map was written back
|
|
244
|
+
into the script's own directory, so the target got nothing and the script
|
|
245
|
+
repo's map was destroyed."""
|
|
246
|
+
target = g.PROJECT_ROOT / "elsewhere"
|
|
247
|
+
(target / "src").mkdir(parents=True)
|
|
248
|
+
(target / "src" / "app.py").write_text("# app\n")
|
|
249
|
+
|
|
250
|
+
script_owned = g.MAP_DIR
|
|
251
|
+
g.configure_paths(target)
|
|
252
|
+
|
|
253
|
+
assert g.PROJECT_ROOT == target
|
|
254
|
+
for name in ("MAP_DIR", "SECTIONS_DIR", "CHECKSUMS", "LEARNED_VOC", "GLOSSARY"):
|
|
255
|
+
p = getattr(g, name)
|
|
256
|
+
assert str(p).startswith(str(target)), f"{name} still outside the target: {p}"
|
|
257
|
+
assert not str(p).startswith(str(script_owned)), f"{name} still in the script dir: {p}"
|
|
258
|
+
assert g.SECTIONS_DIR.is_dir(), "sections dir not created under the target"
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def test_project_root_writes_land_in_the_target(g):
|
|
262
|
+
import json
|
|
263
|
+
target = g.PROJECT_ROOT / "elsewhere"
|
|
264
|
+
target.mkdir(parents=True)
|
|
265
|
+
g.configure_paths(target)
|
|
266
|
+
g.write_glossary([{"alias": "x", "type": "feature",
|
|
267
|
+
"location": "src/x.py", "notes": "n"}], g.load_stack())
|
|
268
|
+
written = target / ".claude" / "project-map" / "glossary.json"
|
|
269
|
+
assert written.exists(), "glossary.json was not written under the target"
|
|
270
|
+
assert json.loads(written.read_text())["entry_count"] == 1
|
|
271
|
+
|
|
272
|
+
|
|
240
273
|
def main() -> int:
|
|
241
274
|
tests = [v for k, v in sorted(globals().items()) if k.startswith("test_")]
|
|
242
275
|
failed = []
|
|
@@ -136,6 +136,22 @@ def test_generate_emits_prose_not_a_row_for_empty_vocab():
|
|
|
136
136
|
assert "No vocabulary generated yet" in out
|
|
137
137
|
|
|
138
138
|
|
|
139
|
+
def test_project_root_relocates_grader_paths(tmp):
|
|
140
|
+
"""The grader used to read its OWN sections while validating paths against
|
|
141
|
+
a different project — a confident but meaningless score."""
|
|
142
|
+
g = load_grader(tmp)
|
|
143
|
+
target = tmp / "elsewhere"
|
|
144
|
+
target.mkdir(parents=True)
|
|
145
|
+
script_owned = g.SECTIONS_DIR
|
|
146
|
+
g.configure_paths(target)
|
|
147
|
+
assert g.PROJECT_ROOT == target
|
|
148
|
+
for name in ("MAP_DIR", "SECTIONS_DIR", "REPORTS_DIR"):
|
|
149
|
+
p = getattr(g, name)
|
|
150
|
+
assert str(p).startswith(str(target)), f"{name} outside target: {p}"
|
|
151
|
+
assert p != script_owned, f"{name} still the script's: {p}"
|
|
152
|
+
assert g.REPORTS_DIR.is_dir()
|
|
153
|
+
|
|
154
|
+
|
|
139
155
|
def main() -> int:
|
|
140
156
|
import inspect
|
|
141
157
|
tests = [v for k, v in sorted(globals().items()) if k.startswith("test_")]
|
|
@@ -172,6 +172,19 @@ def test_junk_phrases_filtered(m, root):
|
|
|
172
172
|
assert not any("," in g or ":" in g for g in got), got
|
|
173
173
|
|
|
174
174
|
|
|
175
|
+
def test_project_root_relocates_miner_output(m, root):
|
|
176
|
+
"""Mining another project used to write its aliases into THIS project's
|
|
177
|
+
learned vocabulary."""
|
|
178
|
+
target = root / "elsewhere"
|
|
179
|
+
target.mkdir(parents=True)
|
|
180
|
+
m.configure_paths(target)
|
|
181
|
+
assert m.PROJECT_ROOT == target
|
|
182
|
+
for name in ("LEARNED_VOC", "MINE_CURSOR"):
|
|
183
|
+
p = getattr(m, name)
|
|
184
|
+
assert str(p).startswith(str(target)), f"{name} outside target: {p}"
|
|
185
|
+
assert m.LEARNED_VOC.parent.is_dir()
|
|
186
|
+
|
|
187
|
+
|
|
175
188
|
def main() -> int:
|
|
176
189
|
import inspect
|
|
177
190
|
tests = [v for k, v in sorted(globals().items()) if k.startswith("test_")]
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
},
|
|
7
7
|
"metadata": {
|
|
8
8
|
"description": "Official marketplace for babel-fish - Codebase introspection and vocabulary translation for AI coding assistants",
|
|
9
|
-
"version": "2.4.
|
|
9
|
+
"version": "2.4.1"
|
|
10
10
|
},
|
|
11
11
|
"plugins": [
|
|
12
12
|
{
|
|
13
13
|
"name": "babel-fish",
|
|
14
14
|
"description": "Auto-generates a project map, vocabulary translation layer, and developer skill for any codebase. Introspects routes, models, services, features, infrastructure, and session history to give Claude instant full-stack context. Self-updates via pre-commit hook.",
|
|
15
|
-
"version": "2.4.
|
|
15
|
+
"version": "2.4.1",
|
|
16
16
|
"author": {
|
|
17
17
|
"name": "TheGlitchKing"
|
|
18
18
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-fish",
|
|
3
3
|
"description": "Auto-generates a project map, vocabulary translation layer, and developer skill for any codebase. Introspects routes, models, services, features, infrastructure, and session history to give Claude instant full-stack context. Self-updates via pre-commit hook.",
|
|
4
|
-
"version": "2.4.
|
|
4
|
+
"version": "2.4.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TheGlitchKing",
|
|
7
7
|
"email": "theglitchking@users.noreply.github.com"
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [2.4.1] - 2026-09-04
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- **`--project-root` changed only the read root**
|
|
10
|
+
([#15](https://github.com/TheGlitchKing/babel-fish/issues/15)). All three
|
|
11
|
+
scripts kept writing to the directory the script itself lives in, so pointing
|
|
12
|
+
the flag at another project silently corrupted the script's own map instead of
|
|
13
|
+
mapping the target:
|
|
14
|
+
|
|
15
|
+
- `generate.py` wrote the map into its own directory — the target got nothing,
|
|
16
|
+
and the script repo's `sections/`, `glossary.json` and `checksums.json` were
|
|
17
|
+
overwritten, while the run reported success.
|
|
18
|
+
- `grader.py` graded its **own** sections while validating vocabulary paths
|
|
19
|
+
against the **target's** filesystem, producing a confident but meaningless
|
|
20
|
+
score (0% vocabulary accuracy, 77% FAIL). The nastiest of the three: it
|
|
21
|
+
neither crashed nor produced nothing.
|
|
22
|
+
- `mine-sessions.py` mined the target's transcripts and wrote the aliases into
|
|
23
|
+
its own `learned-vocabulary.json` and `.mine-cursor.json`.
|
|
24
|
+
|
|
25
|
+
Each script gained `configure_paths()`, called from `main()` after argument
|
|
26
|
+
parsing, which relocates every output under `<project-root>/.claude/project-map/`.
|
|
27
|
+
Module-level defaults are unchanged, so the common case and the test suites
|
|
28
|
+
are unaffected.
|
|
29
|
+
|
|
30
|
+
Not reachable during install: `.claude/install.sh` runs the copied scripts
|
|
31
|
+
inside the target, where `SCRIPT_DIR` and `--project-root` coincide. The
|
|
32
|
+
pre-commit hook and `babel-fish regen` / `grade` pass no `--project-root`.
|
|
33
|
+
Verified by a full install after the change.
|
|
34
|
+
|
|
5
35
|
## [2.4.0] - 2026-09-04
|
|
6
36
|
|
|
7
37
|
### Added
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theglitchking/babel-fish",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "Gives your AI coding assistant instant, accurate knowledge of every route, model, service, feature, and infrastructure element in your codebase.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|