virtualcode 1.0.0 → 1.0.2

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 +45 -0
  2. package/package.json +5 -4
package/install.js ADDED
@@ -0,0 +1,45 @@
1
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs"
2
+ import { join, dirname } from "node:path"
3
+ import { homedir } from "node:os"
4
+
5
+ const XDG_CONFIG = join(homedir(), ".config", "opencode")
6
+
7
+ function findConfig(start) {
8
+ const candidates = [
9
+ join(start, ".opencode", "opencode.jsonc"),
10
+ join(start, ".opencode", "opencode.json"),
11
+ join(start, "opencode.jsonc"),
12
+ join(start, "opencode.json"),
13
+ ]
14
+ for (const p of candidates) {
15
+ if (existsSync(p)) return p
16
+ }
17
+
18
+ const parent = dirname(start)
19
+ if (parent !== start) return findConfig(parent)
20
+ return null
21
+ }
22
+
23
+ function setup() {
24
+ const configPath = findConfig(process.cwd()) || join(XDG_CONFIG, "opencode.jsonc")
25
+
26
+ let config = { plugins: [] }
27
+ if (existsSync(configPath)) {
28
+ try {
29
+ config = JSON.parse(readFileSync(configPath, "utf-8"))
30
+ } catch {
31
+ config = { plugins: [] }
32
+ }
33
+ }
34
+
35
+ if (!Array.isArray(config.plugins)) config.plugins = []
36
+ if (config.plugins.includes("virtualcode")) return
37
+
38
+ config.plugins.push("virtualcode")
39
+
40
+ mkdirSync(dirname(configPath), { recursive: true })
41
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n")
42
+ console.log("[virtualcode] Added to " + configPath)
43
+ }
44
+
45
+ setup()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "virtualcode",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
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",