virtualcode 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/install.js +39 -0
  2. package/package.json +5 -4
package/install.js ADDED
@@ -0,0 +1,39 @@
1
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs"
2
+ import { join, dirname } from "node:path"
3
+
4
+ function findOpencodeConfig(start) {
5
+ let dir = start
6
+ for (let i = 0; i < 10; i++) {
7
+ const candidate = join(dir, ".opencode", "opencode.json")
8
+ if (existsSync(candidate)) return candidate
9
+ const parent = dirname(dir)
10
+ if (parent === dir) break
11
+ dir = parent
12
+ }
13
+ return null
14
+ }
15
+
16
+ function setup() {
17
+ const cwd = process.cwd()
18
+ const configPath = findOpencodeConfig(cwd) || join(cwd, ".opencode", "opencode.json")
19
+
20
+ let config = { plugins: [] }
21
+ if (existsSync(configPath)) {
22
+ try {
23
+ config = JSON.parse(readFileSync(configPath, "utf-8"))
24
+ } catch {
25
+ config = { plugins: [] }
26
+ }
27
+ }
28
+
29
+ if (!Array.isArray(config.plugins)) config.plugins = []
30
+ if (config.plugins.includes("virtualcode")) return
31
+
32
+ config.plugins.push("virtualcode")
33
+
34
+ mkdirSync(dirname(configPath), { recursive: true })
35
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n")
36
+ console.log("[virtualcode] Added to .opencode/opencode.json")
37
+ }
38
+
39
+ setup()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "virtualcode",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "OpenCode plugin that bridges your terminal sessions with Telegram",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -17,10 +17,12 @@
17
17
  }
18
18
  },
19
19
  "files": [
20
- "dist"
20
+ "dist",
21
+ "install.js"
21
22
  ],
22
23
  "scripts": {
23
24
  "build": "tsc",
25
+ "postinstall": "node ./install.js",
24
26
  "prepublishOnly": "npm run build",
25
27
  "typecheck": "tsc --noEmit"
26
28
  },
@@ -36,8 +38,7 @@
36
38
  ],
37
39
  "dependencies": {
38
40
  "@opencode-ai/plugin": "^1.17.8",
39
- "telegraf": "^4.16.3",
40
- "virtualcode-telegram": "^1.0.0"
41
+ "telegraf": "^4.16.3"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@types/node": "^22.0.0",