-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpostinstall.cjs
More file actions
44 lines (41 loc) · 1.66 KB
/
Copy pathpostinstall.cjs
File metadata and controls
44 lines (41 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const fs = require("fs")
const path = require("path")
const os = require("os")
const CMD = `---
description: Toggle, inspect, and benchmark the triage skill router
---
Run npx -y opencode-triage $ARGUMENTS and show the output verbatim.
If output contains "Restart opencode", tell the user to restart.
`
const isGlobal = process.env.npm_config_global === "true"
if (isGlobal) {
const dir = path.join(os.homedir(), ".config", "opencode", "commands")
const file = path.join(dir, "triage.md")
// Always write (fixes edge case #12: previously only created if missing,
// so template updates in new versions were never applied to existing installs)
fs.mkdirSync(dir, { recursive: true })
fs.writeFileSync(file, CMD, "utf-8")
console.log()
console.log(" opencode-triage installed globally")
console.log()
console.log(" 1. Restart OpenCode")
console.log(" 2. Type /triage on to activate")
console.log(" 3. Will rename SKILL.md in:")
console.log(" ~/.config/opencode/skills/ ~/.claude/skills/ ~/.agent/skills/")
console.log()
} else {
const projectRoot = process.env.INIT_CWD || process.cwd()
const dir = path.join(projectRoot, ".opencode", "commands")
const file = path.join(dir, "triage.md")
// Always write (fixes edge case #12: see global section above)
fs.mkdirSync(dir, { recursive: true })
fs.writeFileSync(file, CMD, "utf-8")
console.log()
console.log(" opencode-triage installed locally")
console.log()
console.log(" 1. Restart OpenCode")
console.log(" 2. Type /triage on --local to activate")
console.log(" 3. Will rename SKILL.md in:")
console.log(" .opencode/skills/ .claude/skills/ .agent/skills/")
console.log()
}