Skip to content

Commit 7af0dd5

Browse files
committed
Add VSIX packaging and install docs
1 parent 4716565 commit 7af0dd5

File tree

6 files changed

+143
-3
lines changed

6 files changed

+143
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
22
.vscode-test/
3+
*.vsix

.vscodeignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.gitignore
2+
.sisyphus/
3+
.vscode/
4+
node_modules/
5+
scripts/
6+
test/
7+
*.vsix
8+
package-lock.json

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 DongHyunnn
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,67 @@ A VS Code/Cursor extension that combines two sources of truth:
2020

2121
## Installation
2222

23-
- Install the extension in VS Code or Cursor by opening this folder and launching the Extension Development Host.
24-
- For a packaged install, build a VSIX with the standard VS Code extension workflow and install that VSIX in VS Code or Cursor.
23+
- Install from the marketplace when it is published there, or install a GitHub release VSIX directly.
24+
- For local development, open this folder in VS Code or Cursor and launch the Extension Development Host.
2525
- Local history works immediately as long as `sqlite3` is available on `PATH`.
2626
- To install the companion token-tracking plugin, run `OpenCode Token Usage: Install Tracking Plugin` from the command palette or the dashboard title actions.
2727
- The command copies `opencode-token-usage-tracker.js` into `~/.config/opencode/plugins/`.
2828
- Restart OpenCode after installation so the tracker plugin is loaded.
2929

30+
### GitHub / VSIX install
31+
32+
Build a VSIX locally:
33+
34+
```bash
35+
npm install
36+
npm run package:vsix
37+
```
38+
39+
Install the generated VSIX in VS Code:
40+
41+
```bash
42+
code --install-extension ./opencode-token-usage-extension-2.0.0.vsix
43+
```
44+
45+
If the `cursor` shell command is available on your machine, you can use the same VSIX from Cursor:
46+
47+
```bash
48+
cursor --install-extension ./opencode-token-usage-extension-2.0.0.vsix
49+
```
50+
51+
Convenience scripts are included:
52+
53+
```bash
54+
npm run install:vsix:vscode:dry-run
55+
npm run install:vsix:cursor:dry-run
56+
```
57+
58+
Then run the real install command after packaging:
59+
60+
```bash
61+
npm run install:vsix:vscode
62+
```
63+
64+
or
65+
66+
```bash
67+
npm run install:vsix:cursor
68+
```
69+
70+
### Marketplace install
71+
72+
Once the extension is published, install it from the VS Code extensions view by searching for `OpenCode Token Usage`, or from the CLI with:
73+
74+
```bash
75+
code --install-extension donghyunnn.opencode-token-usage-extension
76+
```
77+
78+
Cursor officially supports extension installation from the Extensions UI. If the `cursor` shell command is available and the same extension id is resolvable there, the equivalent command is:
79+
80+
```bash
81+
cursor --install-extension donghyunnn.opencode-token-usage-extension
82+
```
83+
3084
## How it works
3185

3286
- OpenCode history is read from the local SQLite `message` table, which already stores provider, model, token, cost, and timestamp metadata.

package.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
"version": "2.0.0",
66
"publisher": "donghyunnn",
77
"license": "MIT",
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/DongHyunnn/opencode-plugin-token-usage.git"
11+
},
12+
"homepage": "https://github.com/DongHyunnn/opencode-plugin-token-usage",
13+
"bugs": {
14+
"url": "https://github.com/DongHyunnn/opencode-plugin-token-usage/issues"
15+
},
816
"engines": {
917
"vscode": "^1.96.0"
1018
},
@@ -134,6 +142,11 @@
134142
},
135143
"scripts": {
136144
"dev": "node ./scripts/dev.js",
137-
"test": "node --test"
145+
"test": "node --test",
146+
"package:vsix": "npx @vscode/vsce package",
147+
"install:vsix:vscode": "node ./scripts/install-vsix.js code",
148+
"install:vsix:cursor": "node ./scripts/install-vsix.js cursor",
149+
"install:vsix:vscode:dry-run": "node ./scripts/install-vsix.js code --dry-run",
150+
"install:vsix:cursor:dry-run": "node ./scripts/install-vsix.js cursor --dry-run"
138151
}
139152
}

scripts/install-vsix.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const fs = require("node:fs");
2+
const path = require("node:path");
3+
const { spawnSync } = require("node:child_process");
4+
5+
function main() {
6+
const editor = process.argv[2];
7+
const dryRun = process.argv.includes("--dry-run");
8+
9+
if (!editor || !["code", "cursor"].includes(editor)) {
10+
throw new Error("Usage: node scripts/install-vsix.js <code|cursor> [--dry-run]");
11+
}
12+
13+
const root = path.resolve(__dirname, "..");
14+
const manifest = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
15+
const vsixName = `${manifest.name}-${manifest.version}.vsix`;
16+
const vsixPath = path.join(root, vsixName);
17+
18+
if (!fs.existsSync(vsixPath)) {
19+
throw new Error(`VSIX not found: ${vsixPath}. Run npm run package:vsix first.`);
20+
}
21+
22+
const command = [editor, "--install-extension", vsixPath];
23+
if (dryRun) {
24+
console.log(command.join(" "));
25+
return;
26+
}
27+
28+
const result = spawnSync(editor, ["--install-extension", vsixPath], {
29+
cwd: root,
30+
stdio: "inherit",
31+
});
32+
33+
if (result.status !== 0) {
34+
throw new Error(`${editor} --install-extension failed with exit code ${result.status}`);
35+
}
36+
}
37+
38+
try {
39+
main();
40+
} catch (error) {
41+
console.error(error instanceof Error ? error.message : String(error));
42+
process.exit(1);
43+
}

0 commit comments

Comments
 (0)