@klarlabs-studio/tokenops 0.0.0-stage → 0.101.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/README.md CHANGED
@@ -1,3 +1,24 @@
1
- # Temporary Holding Version
1
+ # @klarlabs-studio/tokenops
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ What your coding agents cost, where they leak, and every plan's limits —
4
+ read on your machine. Your prompts and your code never leave it.
5
+
6
+ ```bash
7
+ npx @klarlabs-studio/tokenops checkup
8
+ ```
9
+
10
+ reads the last week of Claude Code, Codex, Gemini CLI and opencode work,
11
+ with no setup: tokens and their value at API prices per harness and model,
12
+ how the sessions went, and each leak with the one command that fixes it.
13
+
14
+ This package is a launcher for the prebuilt `tokenops` binary for your
15
+ platform (macOS and Linux, x64 and arm64), installed as an optional
16
+ dependency. For the daemon, the coach and the menu bar app, install it
17
+ with Homebrew:
18
+
19
+ ```bash
20
+ brew install --cask klarlabs-studio/tap/tokenops
21
+ tokenops init
22
+ ```
23
+
24
+ Docs: https://github.com/klarlabs-studio/tokenops · Apache-2.0
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+ // Pure launcher: locate the prebuilt tokenops binary for this platform (shipped
3
+ // as an optionalDependency npm resolved for us) and exec it, forwarding args,
4
+ // stdio, and the exit code. All tokenops logic lives in the Go binary; this file
5
+ // carries none of it.
6
+ "use strict";
7
+
8
+ const { spawnSync } = require("node:child_process");
9
+
10
+ function binaryPath() {
11
+ const pkg = `@klarlabs-studio/tokenops-${process.platform}-${process.arch}`;
12
+ const exe = process.platform === "win32" ? "tokenops.exe" : "tokenops";
13
+ try {
14
+ // npm installed only the platform package matching this os/cpu.
15
+ return require.resolve(`${pkg}/bin/${exe}`);
16
+ } catch {
17
+ return null;
18
+ }
19
+ }
20
+
21
+ // Whether tokenops PUBLISHES a binary for this platform, which is a different
22
+ // question from whether one is installed. The wrapper's own
23
+ // optionalDependencies list every platform package built for this release, so
24
+ // it answers the first question without a network call.
25
+ function isPublishedPlatform(pkg) {
26
+ try {
27
+ const own = require("../package.json");
28
+ return Object.prototype.hasOwnProperty.call(own.optionalDependencies || {}, pkg);
29
+ } catch {
30
+ // Cannot tell. Say the weaker thing rather than guess.
31
+ return false;
32
+ }
33
+ }
34
+
35
+ const bin = binaryPath();
36
+ if (!bin) {
37
+ // These two failures look identical here and have opposite fixes, so they
38
+ // must not share a message. Telling someone their platform is unsupported
39
+ // when the real problem is a missing install sends them to build from source
40
+ // to solve something a reinstall fixes.
41
+ const pkg = `@klarlabs-studio/tokenops-${process.platform}-${process.arch}`;
42
+ if (isPublishedPlatform(pkg)) {
43
+ console.error(
44
+ `tokenops: ${pkg} is published for this release but is not installed here.\n` +
45
+ `This is an install problem, not an unsupported platform. Common causes:\n` +
46
+ ` - installed with --no-optional or --omit=optional, which skips it\n` +
47
+ ` - the release published minutes ago and the registry has not caught up\n` +
48
+ ` - a partial or interrupted install\n` +
49
+ `Try: npm install ${pkg}\n` +
50
+ `Binaries: https://github.com/klarlabs-studio/tokenops/releases`,
51
+ );
52
+ } else {
53
+ console.error(
54
+ `tokenops: no prebuilt binary for ${process.platform}-${process.arch}.\n` +
55
+ `Install another way: https://github.com/klarlabs-studio/tokenops/releases ` +
56
+ `or 'brew install --cask klarlabs-studio/tap/tokenops'.`,
57
+ );
58
+ }
59
+ process.exit(1);
60
+ }
61
+
62
+ const res = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
63
+ if (res.error) {
64
+ console.error(res.error.message);
65
+ process.exit(1);
66
+ }
67
+ process.exit(res.status === null ? 1 : res.status);
package/package.json CHANGED
@@ -1,6 +1,38 @@
1
1
  {
2
2
  "name": "@klarlabs-studio/tokenops",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "_version_comment": "Set at publish time by npm/scripts/build-packages.mjs from the git tag; the literal below is never published. optionalDependencies are rewritten the same way.",
4
+ "version": "0.101.1",
5
+ "description": "What your coding agents cost, where they leak, and every plan's limits — local-first. `npx @klarlabs-studio/tokenops checkup` reads a week of Claude Code, Codex, Gemini CLI and opencode work with no setup.",
6
+ "bin": {
7
+ "tokenops": "bin/tokenops.cjs"
8
+ },
9
+ "files": [
10
+ "bin/tokenops.cjs",
11
+ "README.md"
12
+ ],
13
+ "optionalDependencies": {
14
+ "@klarlabs-studio/tokenops-linux-x64": "0.101.1",
15
+ "@klarlabs-studio/tokenops-linux-arm64": "0.101.1",
16
+ "@klarlabs-studio/tokenops-darwin-x64": "0.101.1",
17
+ "@klarlabs-studio/tokenops-darwin-arm64": "0.101.1"
18
+ },
19
+ "keywords": [
20
+ "claude-code",
21
+ "codex",
22
+ "ai",
23
+ "tokens",
24
+ "usage",
25
+ "cost",
26
+ "rate-limits",
27
+ "coding-agents"
28
+ ],
29
+ "license": "Apache-2.0",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/klarlabs-studio/tokenops.git"
33
+ },
34
+ "homepage": "https://github.com/klarlabs-studio/tokenops",
35
+ "engines": {
36
+ "node": ">=16"
37
+ }
38
+ }