@tokmizer/plugin 0.5.4
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-plugin/plugin.json +10 -0
- package/README.md +81 -0
- package/codex-plugin/plugin.json +21 -0
- package/commands/tkr-compression.md +26 -0
- package/commands/tkr-gain.md +16 -0
- package/commands/tkr-link.md +20 -0
- package/commands/tkr-reducer.md +27 -0
- package/commands/tkr-status.md +15 -0
- package/commands/tkr-telemetry.md +19 -0
- package/commands/tkr-unlink.md +13 -0
- package/commands/tkr-update.md +22 -0
- package/commands/tkr.md +42 -0
- package/dist/bin/tkr-codex-hook.js +13 -0
- package/dist/bin/tkr-daemon.js +16 -0
- package/dist/bin/tkr-exec.js +21 -0
- package/dist/bin/tkr-shim.js +13 -0
- package/dist/bin/tkr.js +139 -0
- package/dist/hooks-host/post-tool-use.js +10 -0
- package/dist/hooks-host/pre-tool-use.js +6 -0
- package/dist/hooks-host/reducer-prompt-submit.js +3 -0
- package/dist/hooks-host/reducer-session-start.js +3 -0
- package/dist/hooks-host/reducer-stop.js +5 -0
- package/dist/index.js +11 -0
- package/dist/prod-public-key.js +5 -0
- package/hooks/hooks.json +69 -0
- package/hooks/on-session-start.mjs +102 -0
- package/package.json +59 -0
- package/scripts/README-INSTALL.md +37 -0
- package/scripts/install-mac-linux.sh +69 -0
- package/scripts/install-windows.ps1 +69 -0
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tokmizer/plugin",
|
|
3
|
+
"version": "0.5.4",
|
|
4
|
+
"description": "Tokmizer reduces token consumption for AI coding tools (Claude Code, Codex, Cursor, Aider, Gemini CLI, Cline, Windsurf, Copilot). Cross-OS.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"tkr": "dist/bin/tkr.js",
|
|
9
|
+
"tkr-exec": "dist/bin/tkr-exec.js",
|
|
10
|
+
"tkr-shim": "dist/bin/tkr-shim.js",
|
|
11
|
+
"tkr-codex-hook": "dist/bin/tkr-codex-hook.js",
|
|
12
|
+
"tkr-daemon": "dist/bin/tkr-daemon.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"codex-plugin",
|
|
17
|
+
".claude-plugin",
|
|
18
|
+
"hooks",
|
|
19
|
+
"commands",
|
|
20
|
+
"scripts/install-mac-linux.sh",
|
|
21
|
+
"scripts/install-windows.ps1",
|
|
22
|
+
"scripts/README-INSTALL.md",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"lint": "tsc --noEmit",
|
|
27
|
+
"build": "tsc -p tsconfig.json --noEmit && rm -rf dist && node scripts/bundle.mjs && chmod +x dist/bin/tkr.js dist/bin/tkr-exec.js dist/bin/tkr-shim.js dist/bin/tkr-codex-hook.js dist/bin/tkr-daemon.js",
|
|
28
|
+
"prepublishOnly": "npm run build && node scripts/check-prod-key.mjs && node scripts/check-version.mjs && node scripts/check-dist-clean.mjs && node scripts/check-pack-clean.mjs && node dist/bin/tkr-exec.js echo dist-smoke-ok && node dist/bin/tkr.js help > /dev/null"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@tokmizer/shared": "0.1.0",
|
|
32
|
+
"esbuild": "^0.28.0",
|
|
33
|
+
"smol-toml": "^1.3.0",
|
|
34
|
+
"zod": "^3.23.8"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/Impulse-Creation/Tokmizer"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://tokmizer.com",
|
|
44
|
+
"keywords": [
|
|
45
|
+
"claude-code",
|
|
46
|
+
"codex",
|
|
47
|
+
"cursor",
|
|
48
|
+
"aider",
|
|
49
|
+
"gemini-cli",
|
|
50
|
+
"cline",
|
|
51
|
+
"windsurf",
|
|
52
|
+
"copilot",
|
|
53
|
+
"tokmizer",
|
|
54
|
+
"plugin",
|
|
55
|
+
"tokens",
|
|
56
|
+
"token-optimizer"
|
|
57
|
+
],
|
|
58
|
+
"license": "SEE LICENSE IN LICENSE"
|
|
59
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Installing Tokmizer on any AI coding tool
|
|
2
|
+
|
|
3
|
+
Tokmizer works with **Claude Code, OpenAI Codex, Cursor, Cline, Aider, Gemini CLI, Windsurf, and GitHub Copilot** — on **macOS, Linux, and Windows**.
|
|
4
|
+
|
|
5
|
+
For Claude Code and Codex, Tokmizer uses native hook APIs. For every other tool, it uses a universal **shell-shim**: a thin wrapper on common commands (`git`, `npm`, `docker`, etc.) that compresses output before it reaches the model. Because the shim sits on PATH, it works regardless of which IDE or CLI invokes the command.
|
|
6
|
+
|
|
7
|
+
## macOS / Linux
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
curl -fsSL https://tokmizer.com/install.sh | bash
|
|
11
|
+
# or
|
|
12
|
+
bash scripts/install-mac-linux.sh
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Windows (PowerShell)
|
|
16
|
+
|
|
17
|
+
```powershell
|
|
18
|
+
iwr -useb https://tokmizer.com/install.ps1 | iex
|
|
19
|
+
# or
|
|
20
|
+
PowerShell -ExecutionPolicy Bypass -File scripts\install-windows.ps1
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Per-tool notes
|
|
24
|
+
|
|
25
|
+
| Tool | Adapter | Setup |
|
|
26
|
+
|---------------|-----------------|----------------------------------------------------------------|
|
|
27
|
+
| Claude Code | Native hooks | `/plugin marketplace add Impulse-Creation/Tokmizer` then `/plugin install tokmizer@tokmizer` |
|
|
28
|
+
| Codex CLI | Native hook | `curl -fsSL https://tokmizer.com/install.sh \| bash` |
|
|
29
|
+
| Cursor | Shell-shim | Open a new terminal after install. |
|
|
30
|
+
| Cline | Shell-shim | Open a new terminal after install. |
|
|
31
|
+
| Aider | Shell-shim | Open a new terminal after install. |
|
|
32
|
+
| Gemini CLI | Shell-shim | Open a new terminal after install. |
|
|
33
|
+
| Windsurf | Shell-shim | Open a new terminal after install. |
|
|
34
|
+
| GitHub Copilot| Shell-shim | Open a new terminal after install. |
|
|
35
|
+
| Plain shell | Shell-shim | Works out of the box. |
|
|
36
|
+
|
|
37
|
+
After install, optimization starts automatically. Run `tkr link` to connect a paid account.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# tokmizer universal install — macOS + Linux
|
|
6
|
+
# Installs shell shims under ~/.tokmizer/shims and adds it to PATH.
|
|
7
|
+
# Works under any AI CLI/IDE that invokes shell (Cursor, Cline, Aider,
|
|
8
|
+
# Gemini CLI, Windsurf, Copilot, plain shell). Native hooks are preferred
|
|
9
|
+
# for Claude Code and Codex (see those plugin manifests separately).
|
|
10
|
+
#
|
|
11
|
+
|
|
12
|
+
TOKMIZER_HOME="${TOKMIZER_HOME:-$HOME/.tokmizer}"
|
|
13
|
+
SHIMS_DIR="$TOKMIZER_HOME/shims"
|
|
14
|
+
|
|
15
|
+
err() { printf 'tkr install: %s\n' "$*" >&2; exit 1; }
|
|
16
|
+
log() { printf 'tkr: %s\n' "$*"; }
|
|
17
|
+
|
|
18
|
+
command -v node >/dev/null 2>&1 || err "Node.js 20+ is required."
|
|
19
|
+
command -v npm >/dev/null 2>&1 || err "npm is required."
|
|
20
|
+
|
|
21
|
+
NODE_MAJOR="$(node -p 'process.versions.node.split(".")[0]')"
|
|
22
|
+
[ "$NODE_MAJOR" -ge 20 ] || err "Node.js 20+ required (found v$NODE_MAJOR)."
|
|
23
|
+
|
|
24
|
+
log "Installing @tokmizer/plugin from npm..."
|
|
25
|
+
npm install -g @tokmizer/plugin >/dev/null
|
|
26
|
+
|
|
27
|
+
mkdir -p "$SHIMS_DIR"
|
|
28
|
+
|
|
29
|
+
SHIM_ENTRY="$(command -v tkr-shim || true)"
|
|
30
|
+
[ -n "$SHIM_ENTRY" ] || err "tkr-shim not found on PATH after install."
|
|
31
|
+
|
|
32
|
+
log "Installing shims into $SHIMS_DIR..."
|
|
33
|
+
tkr link --shim --shim-runner "$SHIM_ENTRY" </dev/null || true
|
|
34
|
+
|
|
35
|
+
# Fallback: directly symlink commands if the wizard didn't.
|
|
36
|
+
COMMANDS="git npm yarn pnpm docker kubectl terraform tofu cargo go mvn gradle rg grep find ls cat tail head ps lsof ssh scp rsync curl wget jq yq make"
|
|
37
|
+
for cmd in $COMMANDS; do
|
|
38
|
+
target="$SHIMS_DIR/$cmd"
|
|
39
|
+
if [ ! -e "$target" ]; then
|
|
40
|
+
ln -sf "$SHIM_ENTRY" "$target"
|
|
41
|
+
chmod +x "$target" || true
|
|
42
|
+
fi
|
|
43
|
+
done
|
|
44
|
+
|
|
45
|
+
# Detect the user's interactive shell rc file.
|
|
46
|
+
RC=""
|
|
47
|
+
case "${SHELL:-}" in
|
|
48
|
+
*/zsh) RC="$HOME/.zshrc" ;;
|
|
49
|
+
*/bash) RC="$HOME/.bashrc" ;;
|
|
50
|
+
*/fish) RC="$HOME/.config/fish/config.fish" ;;
|
|
51
|
+
*) RC="$HOME/.profile" ;;
|
|
52
|
+
esac
|
|
53
|
+
|
|
54
|
+
MARKER="# tokmizer-shim PATH (managed by tokmizer)"
|
|
55
|
+
if [ -f "$RC" ] && ! grep -Fq "$MARKER" "$RC"; then
|
|
56
|
+
{
|
|
57
|
+
printf '\n%s\n' "$MARKER"
|
|
58
|
+
if [[ "$RC" == *fish* ]]; then
|
|
59
|
+
printf 'set -gx PATH %s $PATH\n' "$SHIMS_DIR"
|
|
60
|
+
else
|
|
61
|
+
printf 'export PATH="%s:$PATH"\n' "$SHIMS_DIR"
|
|
62
|
+
fi
|
|
63
|
+
} >> "$RC"
|
|
64
|
+
log "Added shim PATH to $RC"
|
|
65
|
+
else
|
|
66
|
+
log "Shim PATH already present (or rc file missing): $RC"
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
log "Done. Open a new terminal — optimization starts automatically. Run 'tkr link' to connect a paid account."
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<#
|
|
2
|
+
.SYNOPSIS
|
|
3
|
+
Tokmizer universal install — Windows (PowerShell 5.1+ / PowerShell 7+)
|
|
4
|
+
.DESCRIPTION
|
|
5
|
+
Installs shell shims under $env:USERPROFILE\.tokmizer\shims and prepends
|
|
6
|
+
that directory to the user PATH. Works under any AI CLI/IDE that invokes
|
|
7
|
+
shell (Cursor, Cline, Aider, Gemini CLI, Windsurf, Copilot, cmd, pwsh).
|
|
8
|
+
#>
|
|
9
|
+
|
|
10
|
+
$ErrorActionPreference = "Stop"
|
|
11
|
+
|
|
12
|
+
function Write-Log([string]$msg) { Write-Host "tkr: $msg" }
|
|
13
|
+
function Fail([string]$msg) { Write-Error "tkr install: $msg"; exit 1 }
|
|
14
|
+
|
|
15
|
+
# Check Node.js 20+
|
|
16
|
+
try {
|
|
17
|
+
$nodeMajor = (node -p "process.versions.node.split('.')[0]" 2>$null)
|
|
18
|
+
} catch { Fail "Node.js 20+ is required (not found)." }
|
|
19
|
+
if ([int]$nodeMajor -lt 20) { Fail "Node.js 20+ required (found v$nodeMajor)." }
|
|
20
|
+
|
|
21
|
+
Write-Log "Installing @tokmizer/plugin from npm..."
|
|
22
|
+
npm install -g @tokmizer/plugin | Out-Null
|
|
23
|
+
|
|
24
|
+
$home = $env:USERPROFILE
|
|
25
|
+
$tokmizerHome = if ($env:TOKMIZER_HOME) { $env:TOKMIZER_HOME } else { Join-Path $home ".tokmizer" }
|
|
26
|
+
$shimsDir = Join-Path $tokmizerHome "shims"
|
|
27
|
+
New-Item -ItemType Directory -Force -Path $shimsDir | Out-Null
|
|
28
|
+
|
|
29
|
+
$shimEntry = (Get-Command tkr-shim -ErrorAction SilentlyContinue).Source
|
|
30
|
+
if (-not $shimEntry) { Fail "tkr-shim not found on PATH after install." }
|
|
31
|
+
|
|
32
|
+
Write-Log "Installing shims into $shimsDir..."
|
|
33
|
+
$commands = @(
|
|
34
|
+
"git","npm","yarn","pnpm","docker","kubectl","terraform","tofu",
|
|
35
|
+
"cargo","go","mvn","gradle","rg","grep","find","ls","cat","tail",
|
|
36
|
+
"head","ps","lsof","ssh","scp","rsync","curl","wget","jq","yq","make"
|
|
37
|
+
)
|
|
38
|
+
foreach ($cmd in $commands) {
|
|
39
|
+
$target = Join-Path $shimsDir "$cmd.cmd"
|
|
40
|
+
# Each per-command wrapper hard-codes `--as <cmd>` so the shim runner
|
|
41
|
+
# knows exactly which binary to spawn instead of falling back to the
|
|
42
|
+
# first user arg (which would let attackers plant arbitrary names).
|
|
43
|
+
$content = "@echo off`r`nnode `"$shimEntry`" --as `"$cmd`" %*"
|
|
44
|
+
$content | Set-Content -Encoding ASCII -Path $target -Force
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
# Prepend shims dir to user PATH.
|
|
48
|
+
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
|
49
|
+
if ($userPath -notmatch [Regex]::Escape($shimsDir)) {
|
|
50
|
+
$newPath = "$shimsDir;$userPath"
|
|
51
|
+
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
|
|
52
|
+
Write-Log "Added $shimsDir to user PATH."
|
|
53
|
+
} else {
|
|
54
|
+
Write-Log "Shim PATH already present in user PATH."
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
# PowerShell profile — update for current session and future sessions.
|
|
58
|
+
$profilePath = $PROFILE.CurrentUserAllHosts
|
|
59
|
+
$marker = "# tokmizer-shim PATH (managed by tokmizer)"
|
|
60
|
+
if (-not (Test-Path $profilePath)) {
|
|
61
|
+
New-Item -ItemType File -Force -Path $profilePath | Out-Null
|
|
62
|
+
}
|
|
63
|
+
$profileContent = Get-Content -Raw -Path $profilePath -ErrorAction SilentlyContinue
|
|
64
|
+
if ($null -eq $profileContent -or -not $profileContent.Contains($marker)) {
|
|
65
|
+
Add-Content -Path $profilePath -Value "`r`n$marker`r`n`$env:Path = `"$shimsDir;`" + `$env:Path"
|
|
66
|
+
Write-Log "Added shim line to PowerShell profile: $profilePath"
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
Write-Log "Done. Open a new terminal — optimization starts automatically. Run 'tkr link' to connect a paid account."
|