@devboy-tools/agent-usage 0.1.0

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.
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ const { spawn } = require("child_process");
6
+ const { getBinaryPath } = require("../index");
7
+
8
+ let binaryPath;
9
+ try {
10
+ binaryPath = getBinaryPath();
11
+ } catch (err) {
12
+ console.error(err.message);
13
+ process.exit(1);
14
+ }
15
+
16
+ const child = spawn(binaryPath, process.argv.slice(2), {
17
+ stdio: "inherit",
18
+ });
19
+
20
+ child.on("error", (err) => {
21
+ if (err.code === "ENOENT") {
22
+ console.error(
23
+ `devboy-agent-usage binary not found at: ${binaryPath}\n` +
24
+ "Run 'npm rebuild @devboy-tools/agent-usage' or set DEVBOY_AGENT_USAGE_BINARY_PATH.",
25
+ );
26
+ } else {
27
+ console.error(`Failed to start devboy-agent-usage: ${err.message}`);
28
+ }
29
+ process.exit(1);
30
+ });
31
+
32
+ child.on("exit", (code, signal) => {
33
+ if (signal) {
34
+ process.kill(process.pid, signal);
35
+ } else {
36
+ process.exit(code ?? 1);
37
+ }
38
+ });
39
+
40
+ // Forward signals to child process
41
+ for (const sig of ["SIGINT", "SIGTERM"]) {
42
+ process.on(sig, () => {
43
+ if (!child.killed) {
44
+ child.kill(sig);
45
+ }
46
+ });
47
+ }
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare function getBinaryPath(): string;
2
+ export declare const name: string;
3
+ export declare const version: string;
package/index.js ADDED
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ const path = require("path");
4
+ const fs = require("fs");
5
+
6
+ const pkg = require("./package.json");
7
+
8
+ exports.name = pkg.name;
9
+ exports.version = pkg.version;
10
+
11
+ /**
12
+ * Resolves the path to the devboy-agent-usage binary.
13
+ *
14
+ * Resolution order:
15
+ * 1. DEVBOY_AGENT_USAGE_BINARY_PATH environment variable
16
+ * 2. Platform-specific npm package
17
+ *
18
+ * @returns {string} Absolute path to the binary
19
+ * @throws {Error} If binary cannot be found
20
+ */
21
+ exports.getBinaryPath = function getBinaryPath() {
22
+ // 1. Check environment variable override
23
+ const envPath = process.env.DEVBOY_AGENT_USAGE_BINARY_PATH;
24
+ if (envPath) {
25
+ if (!fs.existsSync(envPath)) {
26
+ throw new Error(
27
+ `DEVBOY_AGENT_USAGE_BINARY_PATH is set to "${envPath}" but file does not exist.`,
28
+ );
29
+ }
30
+ return path.resolve(envPath);
31
+ }
32
+
33
+ // 2. Resolve from platform-specific package
34
+ const platformPkg = `@devboy-tools/agent-usage-${process.platform}-${process.arch}`;
35
+ const ext = process.platform === "win32" ? ".exe" : "";
36
+ const binaryName = `devboy-agent-usage${ext}`;
37
+
38
+ try {
39
+ const pkgJsonPath = require.resolve(`${platformPkg}/package.json`);
40
+ const binaryPath = path.join(path.dirname(pkgJsonPath), "bin", binaryName);
41
+ if (fs.existsSync(binaryPath)) {
42
+ return binaryPath;
43
+ }
44
+ } catch {
45
+ // Package not installed
46
+ }
47
+
48
+ throw new Error(
49
+ `devboy-agent-usage binary not found. No package ${platformPkg} installed.\n` +
50
+ "Your platform might not be supported. " +
51
+ "Set DEVBOY_AGENT_USAGE_BINARY_PATH to point to a binary, or install from source:\n" +
52
+ " cargo install --git https://github.com/meteora-pro/devboy-agent-usage.git",
53
+ );
54
+ };
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@devboy-tools/agent-usage",
3
+ "version": "0.1.0",
4
+ "description": "CLI tool for analyzing AI agent usage (Claude Code) — npm wrapper for Rust binary",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/meteora-pro/devboy-agent-usage.git"
9
+ },
10
+ "bin": {
11
+ "devboy-agent-usage": "bin/agent-usage.js"
12
+ },
13
+ "main": "index.js",
14
+ "types": "index.d.ts",
15
+ "files": [
16
+ "bin/agent-usage.js",
17
+ "index.js",
18
+ "index.d.ts"
19
+ ],
20
+ "engines": {
21
+ "node": ">=18"
22
+ },
23
+ "optionalDependencies": {
24
+ "@devboy-tools/agent-usage-darwin-arm64": "0.1.0",
25
+ "@devboy-tools/agent-usage-darwin-x64": "0.1.0",
26
+ "@devboy-tools/agent-usage-linux-arm64": "0.1.0",
27
+ "@devboy-tools/agent-usage-linux-x64": "0.1.0",
28
+ "@devboy-tools/agent-usage-win32-x64": "0.1.0"
29
+ }
30
+ }