Lines 12-52javascript
12// ~/.config/opencode/opencode.json
13// { "$schema": "https://opencode.ai/config.json",
14// "plugin": ["@postman-cse/opencode-cse-tools"] }
16// What it does on load:
17// 1. `config` hook -- injects the local `cse` remote MCP server
18// (http://127.0.0.1:9901/mcp) and allows the cse-* / prep skills, so the
19// daemon's tools are available regardless of the working directory.
20// No bearer headers: credentials stay in okta-aio + the daemon keychain.
21// 2. On first init -- syncs the bundled skill set into the global OpenCode
22// skills dir (~/.config/opencode/skills) so the native `skill` tool lists
23// them. Guarded by a version stamp so it only recopies on upgrade.
24// 3. On session.created -- provisions the signed cse-toold daemon
25// (LaunchAgent + auth-maintenance loop) via the bundled binary, the same
26// provisioning the Claude/Codex/Factory SessionStart hooks perform.
28import { createRequire } from "node:module"
29import { fileURLToPath } from "node:url"
30import fs from "node:fs"
31import os from "node:os"
32import path from "node:path"
33import { spawn } from "node:child_process"
35const require = createRequire(import.meta.url)
36const HERE = path.dirname(fileURLToPath(import.meta.url))
37const MCP_URL = "http://127.0.0.1:9901/mcp"
39function globalConfigDir() {
40 // Mirror OpenCode's own resolution: OPENCODE_CONFIG_DIR wins, else XDG, else
41 // ~/.config/opencode.
42 if (process.env.OPENCODE_CONFIG_DIR) return process.env.OPENCODE_CONFIG_DIR
43 const xdg = process.env.XDG_CONFIG_HOME
44 const base = xdg && xdg.trim() ? xdg : path.join(os.homedir(), ".config")
45 return path.join(base, "opencode")
48function pkgVersion() {
50 return require("./package.json").version || "0.0.0"