agent-tracker-vscode 0.0.0-stage → 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.
package/README.md CHANGED
@@ -1,3 +1,39 @@
1
- # Temporary Holding Version
1
+ # Agent Tracker for VS Code
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
+ Install the Agent Tracker extension to see Claude and Codex subscription quota
4
+ and local conversation usage in VS Code.
5
+
6
+ Requires Node.js 22.15+ and VS Code 1.101+ with the `code` command on PATH.
7
+
8
+ ```sh
9
+ npx agent-tracker-vscode@latest
10
+ ```
11
+
12
+ The installer includes the VSIX, installs it with the VS Code CLI, and verifies
13
+ the installed extension ID and version. Reload an open VS Code window with
14
+ **Developer: Reload Window**, then run **Agent Tracker: Open Dashboard**.
15
+
16
+ Run the same command with `@latest` to update. Install a specific version with
17
+ `npx agent-tracker-vscode@0.1.0`.
18
+
19
+ ```sh
20
+ npx agent-tracker-vscode --help
21
+ npx agent-tracker-vscode --profile "Work"
22
+ npx agent-tracker-vscode --code code-insiders
23
+ npx agent-tracker-vscode --code "/path/to/code"
24
+ ```
25
+
26
+ The default profile is used unless `--profile` is given. Create the named profile
27
+ in VS Code first; extension installation fails if it does not exist.
28
+ `--extensions-dir` and `--user-data-dir`
29
+ select separate VS Code directories when needed.
30
+
31
+ On macOS, use **Shell Command: Install 'code' command in PATH** in VS Code first.
32
+ On Windows, the official `code.cmd` launcher is supported, including installations
33
+ with versioned runtime directories.
34
+
35
+ Existing Claude/Codex CLI logins are used by the extension. The installer does
36
+ not log in to either provider. The optional workbench click-toggle patch is a
37
+ separate local setup step documented in the repository.
38
+
39
+ Source and full documentation: [Agent Tracker](https://github.com/lsc892/Agent-Tracker).
package/bin/cli.cjs ADDED
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ const { spawnSync } = require('node:child_process');
4
+ const { createHash } = require('node:crypto');
5
+ const { existsSync, readFileSync, statSync } = require('node:fs');
6
+ const { delimiter, dirname, extname, isAbsolute, join, resolve } = require('node:path');
7
+
8
+ function parseArguments(args) {
9
+ const options = { code: 'code' };
10
+ const values = new Map([
11
+ ['--code', 'code'], ['--profile', 'profile'],
12
+ ['--extensions-dir', 'extensionsDir'], ['--user-data-dir', 'userDataDir'],
13
+ ]);
14
+ for (let index = 0; index < args.length; index++) {
15
+ const argument = args[index];
16
+ if (argument === '--help' || argument === '-h') options.help = true;
17
+ else if (argument === '--version' || argument === '-v') options.version = true;
18
+ else if (values.has(argument)) {
19
+ const value = args[++index];
20
+ if (!value || value.startsWith('--') || value.includes('\0')) throw new Error(`Expected a value after ${argument}.`);
21
+ options[values.get(argument)] = value;
22
+ } else throw new Error(`Unknown argument: ${argument}. Use --help for usage.`);
23
+ }
24
+ return options;
25
+ }
26
+
27
+ function resolveCli(command, platform = process.platform, env = process.env) {
28
+ if (isAbsolute(command) || /[\\/]/.test(command)) {
29
+ const target = resolve(command);
30
+ if (existsSync(target) && statSync(target).isFile()) return target;
31
+ } else {
32
+ const pathValue = Object.entries(env).find(([key]) => platform === 'win32' ? key.toLowerCase() === 'path' : key === 'PATH')?.[1] ?? '';
33
+ const extensions = platform === 'win32' && !extname(command) ? ['.cmd', '.exe', '.bat', ''] : [''];
34
+ for (const directory of pathValue.split(platform === 'win32' ? ';' : delimiter).filter(Boolean)) {
35
+ for (const extension of extensions) {
36
+ const target = resolve(directory.replace(/^"|"$/g, ''), command + extension);
37
+ if (existsSync(target) && statSync(target).isFile()) return target;
38
+ }
39
+ }
40
+ }
41
+ throw new Error(`VS Code CLI "${command}" was not found. Install VS Code and add "code" to PATH, or pass --code <path>.`);
42
+ }
43
+
44
+ function cliInvocation(cli, platform = process.platform, env = process.env) {
45
+ if (platform !== 'win32' || !/\.(cmd|bat)$/i.test(cli)) return { file: cli, prefix: [], env };
46
+ // Run the bundled Electron CLI directly. Profile names and paths never enter cmd.exe.
47
+ // Read both paths from the launcher to support VS Code's versioned installation directories.
48
+ const launcher = readFileSync(cli, 'utf8');
49
+ const match = launcher.match(/"%~dp0([^"\r\n]+\.exe)"\s+"%~dp0([^"\r\n]+[\\/]out[\\/]cli\.js)"/i);
50
+ if (!match) throw new Error('Unsupported VS Code launcher. Pass --code with the official VS Code CLI path.');
51
+ const executable = resolve(dirname(cli), match[1].replaceAll('\\', '/'));
52
+ const script = resolve(dirname(cli), match[2].replaceAll('\\', '/'));
53
+ if (!existsSync(executable) || !existsSync(script)) throw new Error('The VS Code launcher points to missing runtime files. Reinstall VS Code.');
54
+ const childEnv = { ...env, ELECTRON_RUN_AS_NODE: '1' };
55
+ delete childEnv.VSCODE_DEV;
56
+ return { file: executable, prefix: [script], env: childEnv };
57
+ }
58
+
59
+ function minimumVersion(range) {
60
+ const match = /^(?:>=|\^)?(\d+)\.(\d+)\.(\d+)$/.exec(range);
61
+ if (!match) throw new Error(`Unsupported VS Code version range: ${range}.`);
62
+ return match.slice(1).map(Number);
63
+ }
64
+
65
+ function checkVersion(output, range) {
66
+ const match = /^(\d+)\.(\d+)\.(\d+)(?:-[\w.-]+)?\s*$/m.exec(output);
67
+ if (!match) throw new Error('Could not read the VS Code version.');
68
+ const actual = match.slice(1).map(Number);
69
+ const minimum = minimumVersion(range);
70
+ for (let index = 0; index < minimum.length; index++) {
71
+ if (actual[index] > minimum[index]) return;
72
+ if (actual[index] < minimum[index]) throw new Error(`VS Code ${minimum.join('.')} or newer is required; found ${actual.join('.')}.`);
73
+ }
74
+ }
75
+
76
+ function run(packageRoot, args, dependencies = {}) {
77
+ const spawn = dependencies.spawnSync ?? spawnSync;
78
+ const log = dependencies.log ?? console.log;
79
+ const platform = dependencies.platform ?? process.platform;
80
+ const env = dependencies.env ?? process.env;
81
+ const options = parseArguments(args);
82
+ const manifest = JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf8'));
83
+ if (options.help) {
84
+ log(`Usage: npx ${manifest.name} [options]
85
+
86
+ Install the bundled Agent Tracker VSIX into VS Code.
87
+
88
+ --code <command-or-path> VS Code CLI (default: code)
89
+ --profile <name> Install into a named VS Code profile
90
+ --extensions-dir <path> Use a separate extensions directory
91
+ --user-data-dir <path> Use a separate VS Code data directory
92
+ -h, --help Show this help
93
+ -v, --version Show the package version`);
94
+ return;
95
+ }
96
+ if (options.version) { log(manifest.version); return; }
97
+
98
+ const metadata = JSON.parse(readFileSync(join(packageRoot, 'extension.json'), 'utf8'));
99
+ if (metadata.id !== 'agent-tracker.agent-tracker' || metadata.version !== manifest.version) throw new Error('The bundled extension identity or version does not match the installer.');
100
+ const vsix = join(packageRoot, 'extension.vsix');
101
+ if (!existsSync(vsix)) throw new Error('The bundled extension.vsix is missing. Reinstall the npm package.');
102
+ if (createHash('sha256').update(readFileSync(vsix)).digest('hex') !== metadata.sha256) throw new Error('The bundled VSIX checksum does not match. Reinstall the npm package.');
103
+
104
+ const invocation = cliInvocation(resolveCli(options.code, platform, env), platform, env);
105
+ const selection = [];
106
+ for (const [key, flag] of [['profile', '--profile'], ['extensionsDir', '--extensions-dir'], ['userDataDir', '--user-data-dir']]) {
107
+ if (options[key]) selection.push(flag, options[key]);
108
+ }
109
+ const invoke = (commandArgs, inherit = false) => {
110
+ const result = spawn(invocation.file, [...invocation.prefix, ...commandArgs], {
111
+ env: invocation.env, windowsHide: true,
112
+ encoding: 'utf8', stdio: inherit ? 'inherit' : 'pipe',
113
+ });
114
+ if (result.error) throw result.error;
115
+ if (result.status !== 0) {
116
+ const error = new Error(`VS Code CLI failed${result.status === null ? ` (${result.signal ?? 'interrupted'})` : ` (exit ${result.status})`}.${result.stderr?.trim() ? `\n${result.stderr.trim()}` : ''}`);
117
+ error.exitCode = result.status || 1;
118
+ throw error;
119
+ }
120
+ return result.stdout ?? '';
121
+ };
122
+ checkVersion(invoke(['--version']), metadata.vscode);
123
+ log(`Installing ${metadata.id}@${metadata.version}...`);
124
+ invoke(['--install-extension', vsix, '--force', ...selection], true);
125
+ const expected = `${metadata.id}@${metadata.version}`;
126
+ const installed = invoke(['--list-extensions', '--show-versions', ...selection]);
127
+ if (!installed.split(/\r?\n/).some(line => line.trim().toLowerCase() === expected.toLowerCase())) throw new Error(`VS Code did not report the expected installed extension: ${expected}.`);
128
+ log(`Installed and verified: ${expected}`);
129
+ log('In VS Code, run Developer: Reload Window, then Agent Tracker: Open Dashboard.');
130
+ }
131
+
132
+ module.exports = { run, resolveCli, cliInvocation };
133
+ if (require.main === module) {
134
+ try { run(join(__dirname, '..'), process.argv.slice(2)); }
135
+ catch (error) { console.error(error.message); process.exitCode = error.exitCode || 1; }
136
+ }
package/extension.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "id": "agent-tracker.agent-tracker",
3
+ "version": "0.1.0",
4
+ "vscode": "^1.101.0",
5
+ "sha256": "1141a1be0f06d601e63ff1057f176833e0e72601fe272f708d3665b4f067bd02"
6
+ }
package/extension.vsix ADDED
Binary file
package/package.json CHANGED
@@ -1,6 +1,32 @@
1
1
  {
2
2
  "name": "agent-tracker-vscode",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "description": "Install the Agent Tracker VS Code extension for Claude and Codex usage tracking.",
4
+ "bin": {
5
+ "agent-tracker-vscode": "bin/cli.cjs"
6
+ },
7
+ "files": [
8
+ "bin/cli.cjs",
9
+ "extension.json",
10
+ "extension.vsix"
11
+ ],
12
+ "keywords": [
13
+ "vscode",
14
+ "claude",
15
+ "codex",
16
+ "quota",
17
+ "usage"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public",
21
+ "registry": "https://registry.npmjs.org/"
22
+ },
23
+ "version": "0.1.0",
24
+ "license": "UNLICENSED",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/lsc892/Agent-Tracker.git"
28
+ },
29
+ "engines": {
30
+ "node": ">=22.15.0"
31
+ }
32
+ }