tokenjam 0.5.3

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 (3) hide show
  1. package/README.md +40 -0
  2. package/bin/tj.js +72 -0
  3. package/package.json +24 -0
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # `tokenjam` — zero-install TokenJam launcher (command: `tj`)
2
+
3
+ ```bash
4
+ npx tokenjam
5
+ ```
6
+
7
+ That one command reads your `~/.claude/projects/*.jsonl` session logs
8
+ and shows you **where your
9
+ Claude Code quota actually goes** — quota composition (re-reading context vs.
10
+ net-new work) plus a session timeline. No pip env, no daemon, no onboarding.
11
+
12
+ This npm package is a **thin launcher** for the real CLI, which is the Python
13
+ package [`tokenjam`](https://pypi.org/project/tokenjam/) (command: `tj`). `npx tokenjam`
14
+ shells out to the first available Python runner:
15
+
16
+ 1. `uvx --from tokenjam tj …`
17
+ 2. `pipx run --spec tokenjam tj …`
18
+ 3. an already-installed `tj` on your `PATH`
19
+
20
+ All arguments pass straight through, so `npx tokenjam quickstart --since 7d`,
21
+ `npx tokenjam context`, `npx tokenjam optimize`, etc. all work.
22
+
23
+ ## Go deeper
24
+
25
+ `npx tokenjam` is the no-setup front door. When you want live capture, the local
26
+ dashboard, and the MCP server for Claude Code, install the full CLI and onboard:
27
+
28
+ ```bash
29
+ pipx install tokenjam
30
+ tj onboard
31
+ ```
32
+
33
+ See the [TokenJam README](https://github.com/Metabuilder-Labs/tokenjam) for the
34
+ full feature set.
35
+
36
+ ## Requirements
37
+
38
+ A Python runner — [`uv`](https://docs.astral.sh/uv/) (recommended) or
39
+ [`pipx`](https://pipx.pypa.io/). If neither is present, `npx tokenjam` prints install
40
+ guidance.
package/bin/tj.js ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ * Zero-install launcher for TokenJam (`npx tokenjam`), issue #6.
4
+ *
5
+ * TokenJam's CLI is a Python package (`tokenjam`, command `tj`). This thin npm
6
+ * wrapper exists for one reason: the Claude Code / ccusage crowd reaches for
7
+ * `npx <tool>` first. `npx tokenjam` here resolves a Python launcher with NO pip env,
8
+ * NO daemon, NO onboarding — it shells out to the Python CLI via the first
9
+ * available runner and hands every argument straight through. Bare `npx tokenjam`
10
+ * (no subcommand) routes to `tj quickstart`: where your Claude Code quota goes,
11
+ * from the same ~/.claude/projects/*.jsonl files ccusage reads, in one command.
12
+ *
13
+ * Runner preference (first that exists wins):
14
+ * 1. `uvx --from tokenjam tj …` — fully ephemeral, downloads nothing global
15
+ * 2. `pipx run --spec tokenjam tj …`
16
+ * 3. `tj …` — an already-installed CLI on PATH
17
+ *
18
+ * If none are present we print actionable install guidance and exit non-zero.
19
+ */
20
+ "use strict";
21
+
22
+ const { spawnSync } = require("child_process");
23
+
24
+ // PyPI package name vs. command name differ (`tokenjam` ships the `tj` script),
25
+ // so ephemeral runners must be told the source package explicitly.
26
+ const PACKAGE = "tokenjam";
27
+ const COMMAND = "tj";
28
+
29
+ function has(bin) {
30
+ // `<bin> --version` is a cheap, side-effect-free presence probe.
31
+ const probe = spawnSync(bin, ["--version"], { stdio: "ignore" });
32
+ return probe.status === 0 || probe.status === 1; // 1 = exists but no --version
33
+ }
34
+
35
+ function runners() {
36
+ return [
37
+ { bin: "uvx", prefix: ["--from", PACKAGE, COMMAND] },
38
+ { bin: "pipx", prefix: ["run", "--spec", PACKAGE, COMMAND] },
39
+ { bin: COMMAND, prefix: [] }, // already installed on PATH
40
+ ];
41
+ }
42
+
43
+ function main() {
44
+ // Bare `npx tokenjam` IS the zero-install first run — route it to
45
+ // `tj quickstart` (the quota report the docs promise). The branded home
46
+ // screen that bare LOCAL `tj` prints assumes an installed CLI and would
47
+ // dead-end an npx user ("You're set up", suggesting commands they don't
48
+ // have). Any explicit args pass through untouched.
49
+ const argv = process.argv.slice(2);
50
+ const passthrough = argv.length ? argv : ["quickstart"];
51
+
52
+ for (const { bin, prefix } of runners()) {
53
+ if (!has(bin)) continue;
54
+ const result = spawnSync(bin, [...prefix, ...passthrough], {
55
+ stdio: "inherit",
56
+ });
57
+ if (result.error) continue; // try the next runner on spawn failure
58
+ process.exit(result.status === null ? 1 : result.status);
59
+ }
60
+
61
+ process.stderr.write(
62
+ "\n" +
63
+ "tj (TokenJam) needs a Python runner to launch its CLI.\n" +
64
+ "Install one of these, then re-run `npx tokenjam`:\n" +
65
+ " • uv → https://docs.astral.sh/uv/ (then `uvx --from tokenjam tj`)\n" +
66
+ " • pipx → `brew install pipx` / `apt install pipx`\n" +
67
+ "Or install TokenJam directly: pipx install tokenjam\n\n"
68
+ );
69
+ process.exit(1);
70
+ }
71
+
72
+ main();
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "tokenjam",
3
+ "version": "0.5.3",
4
+ "description": "Zero-install launcher for TokenJam (tj) — `npx tokenjam` runs the Python CLI via uvx/pipx and prints where your Claude Code quota actually goes, no setup.",
5
+ "keywords": ["claude-code", "ccusage", "tokens", "cost", "llm", "agents", "observability", "tokenjam"],
6
+ "homepage": "https://tokenjam.dev",
7
+ "bugs": "https://github.com/Metabuilder-Labs/tokenjam/issues",
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/Metabuilder-Labs/tokenjam.git",
12
+ "directory": "npm-wrapper"
13
+ },
14
+ "bin": {
15
+ "tj": "bin/tj.js"
16
+ },
17
+ "files": [
18
+ "bin/tj.js",
19
+ "README.md"
20
+ ],
21
+ "engines": {
22
+ "node": ">=16"
23
+ }
24
+ }