GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: add opencode local plugin and resources · feelsodev/louder@a577509

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .gitignore
  • opencode-plugin
    • louder.js
  • resources
    • louder_image.png
  • tsup.plugin.config.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.gitignore‎

Copy file name to clipboardExpand all lines: .gitignore
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ bun.lockb
3737
.claude/
3838
.omc/
3939
opencode.json
40+
dist-plugin/
Collapse file

‎opencode-plugin/louder.js‎

Copy file name to clipboard
+133Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/**
2+
* Louder - OpenCode Plugin
3+
* Sound + Haptic feedback when AI tasks complete
4+
*
5+
* Haptic requires: macOS + Force Touch trackpad + native binary
6+
* Build native binary: cd native && ./build.sh
7+
*/
8+
import { spawn } from "child_process"
9+
import { existsSync } from "fs"
10+
import { dirname, join } from "path"
11+
import { fileURLToPath } from "url"
12+
import { homedir } from "os"
13+
14+
const SOUND_MAP = {
15+
success: "/System/Library/Sounds/Glass.aiff",
16+
error: "/System/Library/Sounds/Basso.aiff",
17+
info: "/System/Library/Sounds/Blow.aiff",
18+
warning: "/System/Library/Sounds/Sosumi.aiff",
19+
progress: "/System/Library/Sounds/Tink.aiff",
20+
reminder: "/System/Library/Sounds/Ping.aiff",
21+
}
22+
23+
function findHapticBinary() {
24+
const locations = [
25+
join(homedir(), ".config/opencode/native/HapticEngine"),
26+
join(homedir(), ".local/share/louder/HapticEngine"),
27+
join(dirname(fileURLToPath(import.meta.url)), "native/HapticEngine"),
28+
]
29+
30+
for (const loc of locations) {
31+
if (existsSync(loc)) return loc
32+
}
33+
return null
34+
}
35+
36+
let hapticEngine = null
37+
let hapticBinaryPath = null
38+
39+
function getHapticEngine() {
40+
if (hapticEngine) return Promise.resolve(hapticEngine)
41+
42+
return new Promise((resolve) => {
43+
if (!hapticBinaryPath) {
44+
hapticBinaryPath = findHapticBinary()
45+
}
46+
47+
if (!hapticBinaryPath) {
48+
resolve(null)
49+
return
50+
}
51+
52+
const proc = spawn(hapticBinaryPath, [], {
53+
stdio: ["pipe", "ignore", "ignore"],
54+
})
55+
56+
proc.once("spawn", () => {
57+
hapticEngine = {
58+
write: (cmd) => {
59+
try {
60+
proc.stdin.write(cmd + "\n")
61+
return true
62+
} catch {
63+
return false
64+
}
65+
}
66+
}
67+
resolve(hapticEngine)
68+
})
69+
70+
proc.once("error", () => resolve(null))
71+
proc.once("exit", () => {
72+
hapticEngine = null
73+
})
74+
})
75+
}
76+
77+
async function playSound(type = "success") {
78+
const soundPath = SOUND_MAP[type] || SOUND_MAP.success
79+
if (existsSync(soundPath)) {
80+
spawn("afplay", [soundPath], { stdio: "ignore" })
81+
}
82+
}
83+
84+
async function playHaptic(intensity = 2.0) {
85+
const engine = await getHapticEngine()
86+
if (engine) {
87+
engine.write(`15,${intensity}`)
88+
}
89+
}
90+
91+
async function notify(soundType = "success", hapticIntensity = 2.0) {
92+
await Promise.all([
93+
playSound(soundType),
94+
playHaptic(hapticIntensity)
95+
])
96+
}
97+
98+
const notifiedSessions = new Set()
99+
const MAX_SESSIONS = 100
100+
101+
function trackSession(sessionID) {
102+
notifiedSessions.add(sessionID)
103+
if (notifiedSessions.size > MAX_SESSIONS) {
104+
const oldest = notifiedSessions.values().next().value
105+
if (oldest) notifiedSessions.delete(oldest)
106+
}
107+
}
108+
109+
export const louderPlugin = async (ctx) => {
110+
return {
111+
event: async ({ event }) => {
112+
const props = event.properties
113+
const sessionID = props?.info?.id || props?.sessionID
114+
115+
if (event.type === "session.updated" || event.type === "message.updated") {
116+
if (sessionID) notifiedSessions.delete(sessionID)
117+
return
118+
}
119+
120+
if (event.type === "session.idle") {
121+
if (!sessionID || notifiedSessions.has(sessionID)) return
122+
trackSession(sessionID)
123+
await notify("success", 2.0)
124+
}
125+
126+
if (event.type === "session.error") {
127+
if (!sessionID || notifiedSessions.has(sessionID)) return
128+
trackSession(sessionID)
129+
await notify("error", 1.5)
130+
}
131+
}
132+
}
133+
}
Collapse file

‎resources/louder_image.png‎

Copy file name to clipboard
6.61 MB
  • Display the source diff
  • Display the rich diff
Loading
Collapse file

‎tsup.plugin.config.ts‎

Copy file name to clipboard
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineConfig } from "tsup"
2+
3+
export default defineConfig({
4+
entry: { "louder-opencode": "src/opencode/index.ts" },
5+
format: ["esm"],
6+
target: "node18",
7+
outDir: "dist-plugin",
8+
noExternal: [/.*/],
9+
bundle: true,
10+
splitting: false,
11+
clean: true,
12+
})

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.