@raidiant/notifai 0.1.0

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 (54) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +76 -0
  3. package/dist/client.d.ts +40 -0
  4. package/dist/client.js +118 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/commands.d.ts +225 -0
  7. package/dist/commands.js +1855 -0
  8. package/dist/commands.js.map +1 -0
  9. package/dist/config.d.ts +138 -0
  10. package/dist/config.js +224 -0
  11. package/dist/config.js.map +1 -0
  12. package/dist/credentials.d.ts +31 -0
  13. package/dist/credentials.js +94 -0
  14. package/dist/credentials.js.map +1 -0
  15. package/dist/hooks.d.ts +250 -0
  16. package/dist/hooks.js +792 -0
  17. package/dist/hooks.js.map +1 -0
  18. package/dist/idle.d.ts +16 -0
  19. package/dist/idle.js +44 -0
  20. package/dist/idle.js.map +1 -0
  21. package/dist/install-hooks.d.ts +194 -0
  22. package/dist/install-hooks.js +579 -0
  23. package/dist/install-hooks.js.map +1 -0
  24. package/dist/main.d.ts +2 -0
  25. package/dist/main.js +259 -0
  26. package/dist/main.js.map +1 -0
  27. package/dist/opencode-plugin.d.ts +65 -0
  28. package/dist/opencode-plugin.js +181 -0
  29. package/dist/opencode-plugin.js.map +1 -0
  30. package/dist/readiness.d.ts +87 -0
  31. package/dist/readiness.js +40 -0
  32. package/dist/readiness.js.map +1 -0
  33. package/dist/send.d.ts +86 -0
  34. package/dist/send.js +202 -0
  35. package/dist/send.js.map +1 -0
  36. package/package.json +56 -0
  37. package/src/client.test.ts +83 -0
  38. package/src/client.ts +183 -0
  39. package/src/commands.test.ts +1199 -0
  40. package/src/commands.ts +2201 -0
  41. package/src/config.test.ts +243 -0
  42. package/src/config.ts +347 -0
  43. package/src/credentials.ts +119 -0
  44. package/src/hooks.test.ts +1030 -0
  45. package/src/hooks.ts +1099 -0
  46. package/src/idle.test.ts +32 -0
  47. package/src/idle.ts +41 -0
  48. package/src/install-hooks.test.ts +500 -0
  49. package/src/install-hooks.ts +708 -0
  50. package/src/main.ts +315 -0
  51. package/src/opencode-plugin.ts +203 -0
  52. package/src/readiness.ts +88 -0
  53. package/src/send.ts +272 -0
  54. package/tsconfig.json +10 -0
@@ -0,0 +1,579 @@
1
+ import { closeSync, existsSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, statSync, renameSync, unlinkSync, writeFileSync, } from 'node:fs';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+ import { opencodePluginPath, opencodePluginTarget } from './opencode-plugin.js';
5
+ /**
6
+ * The three joints the OpenCode plugin hooks into, as (harness event, the
7
+ * `notifai hook` event it runs). The plugin is a module and has no settings
8
+ * entries to read, so `findInstallations` reconstructs its handlers from this.
9
+ */
10
+ const OPENCODE_EVENTS = [
11
+ ['UserPromptSubmit', 'user-prompt-submit'],
12
+ ['Stop', 'stop'],
13
+ ['SessionEnd', 'session-end'],
14
+ ];
15
+ /**
16
+ * Harness hook installation.
17
+ *
18
+ * Claude Code's `settings.json` and Codex's `hooks.json` use the same shape —
19
+ * `hooks` maps an event name to matcher groups, each holding command handlers
20
+ * with an optional timeout — so one generator serves both. Only the file
21
+ * location and the event set differ.
22
+ *
23
+ * Cursor's native format is flat and lower-camel-cased, while OpenCode's
24
+ * extension point is a JavaScript plugin module. Each therefore has a bounded
25
+ * adapter instead of being forced through this shared document shape.
26
+ */
27
+ export const HARNESSES = ['claude-code', 'codex', 'cursor', 'opencode'];
28
+ /**
29
+ * The command each hook runs. Uses the absolute interpreter and script path
30
+ * rather than the bare binary name: hooks inherit a login-ish environment, and
31
+ * a `notifai` that is only on an interactive shell's PATH fails silently.
32
+ */
33
+ export function hookCommand(execPath, scriptPath, event, harness) {
34
+ return (`${quote(execPath)} ${quote(scriptPath)} hook ${event} ${OWNER_MARKER}` +
35
+ (harness === 'cursor' ? ' --harness cursor' : ''));
36
+ }
37
+ /**
38
+ * Says "NotifAI installed this" without saying which checkout did.
39
+ *
40
+ * Ownership used to be matched on the absolute script path, so installing from
41
+ * a second checkout did not recognise the first one's handlers as ours. Both
42
+ * stayed, the harness ran both, and one question produced two notifications;
43
+ * uninstalling the second silently left the first running. A marker that every
44
+ * NotifAI build writes and no build's path appears in fixes that by making
45
+ * ownership a property of the handler rather than of the machine it was
46
+ * installed from.
47
+ *
48
+ * It is a real (ignored) CLI flag rather than a comment because not every
49
+ * harness runs the command through a shell.
50
+ */
51
+ export const OWNER_MARKER = '--owner notifai';
52
+ /**
53
+ * POSIX single-quoting. Double quotes were wrong: they still expand `$(...)`
54
+ * and backticks, so a checkout path containing shell syntax became command
55
+ * execution on every hook event. Single quotes suppress all expansion; the
56
+ * only escape needed is for a literal single quote.
57
+ */
58
+ function quote(value) {
59
+ return `'${value.replaceAll("'", `'\\''`)}'`;
60
+ }
61
+ /** Command-hook harnesses kill at 600s; generated adapters use the same safe ceiling. */
62
+ const HOOK_CEILING_SECONDS = 590;
63
+ /** Grace, reply wait, and teardown headroom for any blocking turn-end adapter. */
64
+ export function blockingHookTimeoutSeconds(graceSeconds, replyTimeoutSeconds) {
65
+ return Math.min(HOOK_CEILING_SECONDS, graceSeconds + replyTimeoutSeconds + 60);
66
+ }
67
+ export function buildHookConfig(options) {
68
+ const { execPath, scriptPath } = options;
69
+ // Stop can spend the grace window AND then the reply wait, so the declared
70
+ // timeout must cover both. Headroom on top so the harness never kills the
71
+ // hook first; a killed hook loses the answer the user already gave.
72
+ const blockingTimeout = blockingHookTimeoutSeconds(options.graceSeconds, options.replyTimeoutSeconds);
73
+ return {
74
+ UserPromptSubmit: [
75
+ {
76
+ hooks: [
77
+ {
78
+ type: 'command',
79
+ command: hookCommand(execPath, scriptPath, 'user-prompt-submit'),
80
+ // Claude Code caps UserPromptSubmit at 30s; stay well inside it so
81
+ // a slow network can never delay the user's own prompt.
82
+ timeout: 15,
83
+ },
84
+ ],
85
+ },
86
+ ],
87
+ Stop: [
88
+ {
89
+ hooks: [
90
+ {
91
+ type: 'command',
92
+ command: hookCommand(execPath, scriptPath, 'stop'),
93
+ timeout: blockingTimeout,
94
+ },
95
+ ],
96
+ },
97
+ ],
98
+ SessionEnd: [
99
+ {
100
+ hooks: [
101
+ {
102
+ type: 'command',
103
+ command: hookCommand(execPath, scriptPath, 'session-end'),
104
+ // Both harnesses give SessionEnd a ~1-3s budget, so this handler
105
+ // only touches local state.
106
+ timeout: 3,
107
+ },
108
+ ],
109
+ },
110
+ ],
111
+ };
112
+ }
113
+ /** Cursor's native schema is flat and uses lower-camel lifecycle event names. */
114
+ export function buildCursorHookConfig(options) {
115
+ const blockingTimeout = blockingHookTimeoutSeconds(options.graceSeconds, options.replyTimeoutSeconds);
116
+ return {
117
+ beforeSubmitPrompt: [
118
+ {
119
+ command: hookCommand(options.execPath, options.scriptPath, 'user-prompt-submit', 'cursor'),
120
+ timeout: 15,
121
+ },
122
+ ],
123
+ stop: [
124
+ {
125
+ command: hookCommand(options.execPath, options.scriptPath, 'stop', 'cursor'),
126
+ timeout: blockingTimeout,
127
+ // One companion-device answer produces one automatic follow-up turn. There is no
128
+ // useful reason for Cursor to repeat it, even if state cleanup fails.
129
+ loop_limit: 1,
130
+ },
131
+ ],
132
+ sessionEnd: [
133
+ {
134
+ command: hookCommand(options.execPath, options.scriptPath, 'session-end', 'cursor'),
135
+ timeout: 3,
136
+ },
137
+ ],
138
+ };
139
+ }
140
+ /**
141
+ * Where each harness reads hooks from. Project installs deliberately target the
142
+ * gitignored file where one exists: which devices a person wants their
143
+ * questions pushed to is not a property of the repository.
144
+ */
145
+ export function settingsFile(harness, global, cwd, env = process.env) {
146
+ // OpenCode has no settings document to merge into — its adapter is a
147
+ // generated plugin module, so it owns a whole file rather than a handler
148
+ // inside one. `opencodePluginPath` is its equivalent.
149
+ if (harness === 'opencode')
150
+ return opencodePluginPath(global, cwd, env);
151
+ if (harness === 'cursor') {
152
+ const home = env['HOME'] !== undefined && env['HOME'] !== '' ? env['HOME'] : os.homedir();
153
+ return global
154
+ ? path.join(home, '.cursor', 'hooks.json')
155
+ : path.join(cwd, '.cursor', 'hooks.json');
156
+ }
157
+ if (harness === 'claude-code') {
158
+ return global
159
+ ? path.join(configHome(env, 'CLAUDE_CONFIG_DIR', '.claude'), 'settings.json')
160
+ : path.join(cwd, '.claude', 'settings.local.json');
161
+ }
162
+ return global
163
+ ? path.join(configHome(env, 'CODEX_HOME', '.codex'), 'hooks.json')
164
+ : path.join(codexProjectRoot(cwd), '.codex', 'hooks.json');
165
+ }
166
+ /**
167
+ * Where Codex looks for a project's hooks — the **main** repository, not the
168
+ * working directory.
169
+ *
170
+ * Run from a linked git worktree, Codex reads `<main repo>/.codex/hooks.json`
171
+ * and never looks at the worktree's own. Proven 2026-08-03 in an isolated
172
+ * `CODEX_HOME`: with cwd set to a worktree, a handler at the main repo root
173
+ * fired and an identical one at the worktree root did not; removing the main
174
+ * one left nothing firing at all. Writing to cwd therefore produces a silent
175
+ * no-op for anyone whose agent runs in a worktree, which is the normal case
176
+ * under tooling like Orca.
177
+ *
178
+ * Claude Code does not share this behaviour — it reads the worktree's own
179
+ * `.claude/settings.local.json` — so this deliberately applies to Codex only.
180
+ */
181
+ export function codexProjectRoot(cwd) {
182
+ const entry = findGitEntry(cwd);
183
+ if (entry === null)
184
+ return cwd;
185
+ try {
186
+ if (statSync(entry).isDirectory())
187
+ return path.dirname(entry);
188
+ const linked = worktreeGitDir(entry);
189
+ return linked === null ? cwd : path.dirname(commonGitDir(linked));
190
+ }
191
+ catch {
192
+ // An unreadable or exotic checkout is not worth failing an install over;
193
+ // cwd is what we used to do and is right for every non-worktree case.
194
+ return cwd;
195
+ }
196
+ }
197
+ /**
198
+ * The `.codex` directory that has to exist for Codex to load project hooks at
199
+ * all, or null when nothing extra is needed.
200
+ *
201
+ * Codex splits the two halves of "which project am I in": it discovers the
202
+ * project layer by walking up from cwd for a `.codex` directory, but resolves
203
+ * `hooks.json` inside that layer against the main repository. In an ordinary
204
+ * checkout both land on the same directory and the split is invisible. In a
205
+ * worktree they diverge, and writing only the main repository's file leaves it
206
+ * unread — Codex never looks, because nothing at or above cwd told it there was
207
+ * a project layer to load. Proven 2026-08-03: with cwd in a worktree, an *empty*
208
+ * `.codex` directory there was the difference between the main repository's
209
+ * handler running and nothing running.
210
+ */
211
+ export function codexLayerDir(cwd) {
212
+ const entry = findGitEntry(cwd);
213
+ if (entry === null)
214
+ return null;
215
+ const worktreeRoot = path.dirname(entry);
216
+ if (path.resolve(worktreeRoot) === path.resolve(codexProjectRoot(cwd)))
217
+ return null;
218
+ return path.join(worktreeRoot, '.codex');
219
+ }
220
+ /** The nearest `.git` at or above `from`, or null outside a repository. */
221
+ function findGitEntry(from) {
222
+ let dir = path.resolve(from);
223
+ for (;;) {
224
+ const entry = path.join(dir, '.git');
225
+ if (existsSync(entry))
226
+ return entry;
227
+ const parent = path.dirname(dir);
228
+ if (parent === dir)
229
+ return null;
230
+ dir = parent;
231
+ }
232
+ }
233
+ /** `.git` in a linked worktree is a file naming that worktree's git directory. */
234
+ function worktreeGitDir(file) {
235
+ const match = /^gitdir:\s*(.+)$/m.exec(readFileSync(file, 'utf8'));
236
+ if (match === null)
237
+ return null;
238
+ return path.resolve(path.dirname(file), match[1].trim());
239
+ }
240
+ /**
241
+ * A worktree's git directory records the shared one in `commondir`; that shared
242
+ * directory is the main repository's `.git`, whose parent is its root.
243
+ */
244
+ function commonGitDir(gitDir) {
245
+ const marker = path.join(gitDir, 'commondir');
246
+ if (!existsSync(marker))
247
+ return gitDir;
248
+ return path.resolve(gitDir, readFileSync(marker, 'utf8').trim());
249
+ }
250
+ /**
251
+ * Both harnesses let an environment variable relocate their whole config
252
+ * directory, and tooling that manages sessions does exactly that — Orca points
253
+ * `CODEX_HOME` at a per-account home, so writing to `~/.codex` installs hooks
254
+ * into a file Codex never reads and the failure is silent. Observed 2026-08-02.
255
+ */
256
+ export function configHome(env, variable, fallback) {
257
+ const override = env[variable];
258
+ return override !== undefined && override !== '' ? override : path.join(os.homedir(), fallback);
259
+ }
260
+ /** Best-effort detection so `hooks install` usually needs no flags. */
261
+ export function detectHarness(cwd) {
262
+ const found = [];
263
+ if (existsSync(path.join(cwd, '.claude')) || existsSync(path.join(os.homedir(), '.claude'))) {
264
+ found.push('claude-code');
265
+ }
266
+ if (existsSync(path.join(cwd, '.codex')) || existsSync(path.join(os.homedir(), '.codex'))) {
267
+ found.push('codex');
268
+ }
269
+ if (existsSync(path.join(cwd, '.cursor')) || existsSync(path.join(os.homedir(), '.cursor'))) {
270
+ found.push('cursor');
271
+ }
272
+ if (existsSync(path.join(cwd, '.opencode')) ||
273
+ existsSync(path.join(os.homedir(), '.config', 'opencode'))) {
274
+ found.push('opencode');
275
+ }
276
+ return found.length === 1 ? found[0] : null;
277
+ }
278
+ function readCursorSettings(file) {
279
+ if (!existsSync(file))
280
+ return { version: 1 };
281
+ try {
282
+ const parsed = JSON.parse(readFileSync(file, 'utf8'));
283
+ return typeof parsed === 'object' && parsed !== null
284
+ ? parsed
285
+ : { version: 1 };
286
+ }
287
+ catch {
288
+ throw new Error(`Could not parse ${file}; fix or move it before installing hooks.`);
289
+ }
290
+ }
291
+ function isOurCommand(command, scriptPath) {
292
+ if (command.includes(OWNER_MARKER))
293
+ return true;
294
+ return (command.includes(`${scriptPath}' hook `) ||
295
+ command.includes(`${scriptPath}" hook `) ||
296
+ command.includes(`${scriptPath} hook `));
297
+ }
298
+ export function mergeCursorHooks(existing, incoming, scriptPath) {
299
+ const hooks = {};
300
+ const added = [];
301
+ const replaced = [];
302
+ const removed = [];
303
+ for (const [event, handlers] of Object.entries(existing.hooks ?? {})) {
304
+ const foreign = handlers.filter((handler) => !isOurCommand(handler.command, scriptPath));
305
+ if (foreign.length !== handlers.length) {
306
+ if (event in incoming)
307
+ replaced.push(event);
308
+ else
309
+ removed.push(event);
310
+ }
311
+ if (foreign.length > 0)
312
+ hooks[event] = foreign;
313
+ }
314
+ for (const [event, handlers] of Object.entries(incoming)) {
315
+ if (!replaced.includes(event))
316
+ added.push(event);
317
+ hooks[event] = [...(hooks[event] ?? []), ...handlers];
318
+ }
319
+ return { document: { ...existing, version: 1, hooks }, added, replaced, removed };
320
+ }
321
+ export function removeCursorHooks(existing, scriptPath) {
322
+ const hooks = {};
323
+ const replaced = [];
324
+ for (const [event, handlers] of Object.entries(existing.hooks ?? {})) {
325
+ const foreign = handlers.filter((handler) => !isOurCommand(handler.command, scriptPath));
326
+ if (foreign.length !== handlers.length)
327
+ replaced.push(event);
328
+ if (foreign.length > 0)
329
+ hooks[event] = foreign;
330
+ }
331
+ return { document: { ...existing, version: 1, hooks }, added: [], replaced, removed: [] };
332
+ }
333
+ function readSettings(file) {
334
+ if (!existsSync(file))
335
+ return {};
336
+ try {
337
+ const parsed = JSON.parse(readFileSync(file, 'utf8'));
338
+ return typeof parsed === 'object' && parsed !== null ? parsed : {};
339
+ }
340
+ catch {
341
+ throw new Error(`Could not parse ${file}; fix or move it before installing hooks.`);
342
+ }
343
+ }
344
+ /**
345
+ * True when a single handler is ours. Deliberately per-handler, not per-group:
346
+ * removing a whole group destroyed a user's own handler if they had added one
347
+ * beside ours inside the same matcher group.
348
+ */
349
+ function isOurHandler(handler, scriptPath) {
350
+ return isOurCommand(handler.command, scriptPath);
351
+ }
352
+ /** Drops only our handlers, keeping the group and anyone else's handlers. */
353
+ function withoutOurs(groups, scriptPath) {
354
+ let removed = false;
355
+ const kept = [];
356
+ for (const group of groups) {
357
+ const hooks = group.hooks.filter((handler) => {
358
+ const ours = isOurHandler(handler, scriptPath);
359
+ if (ours)
360
+ removed = true;
361
+ return !ours;
362
+ });
363
+ if (hooks.length > 0)
364
+ kept.push({ ...group, hooks });
365
+ }
366
+ return { groups: kept, removed };
367
+ }
368
+ /**
369
+ * Adds our handlers without disturbing anyone else's. Re-running replaces only
370
+ * the groups we previously wrote, so an upgrade that changes a timeout does not
371
+ * accumulate duplicate hooks.
372
+ *
373
+ * Handlers are stripped from EVERY event, not just the ones being installed.
374
+ * Only rewriting incoming events left a dropped event's handler in place for
375
+ * ever, and since the binary no longer implements it, it exited 2 with
376
+ * "Unknown hook event" every time the harness fired it — a permanent hook
377
+ * failure that reinstalling could not clear.
378
+ */
379
+ export function mergeHooks(existing, incoming, scriptPath) {
380
+ const hooks = {};
381
+ const added = [];
382
+ const replaced = [];
383
+ const removed = [];
384
+ for (const [event, groups] of Object.entries(existing.hooks ?? {})) {
385
+ const { groups: foreign, removed: hadOurs } = withoutOurs(groups, scriptPath);
386
+ if (hadOurs) {
387
+ if (event in incoming)
388
+ replaced.push(event);
389
+ else
390
+ removed.push(event);
391
+ }
392
+ if (foreign.length > 0)
393
+ hooks[event] = foreign;
394
+ }
395
+ for (const [event, groups] of Object.entries(incoming)) {
396
+ if (!replaced.includes(event))
397
+ added.push(event);
398
+ hooks[event] = [...(hooks[event] ?? []), ...groups];
399
+ }
400
+ return { document: { ...existing, hooks }, added, replaced, removed };
401
+ }
402
+ export function removeHooks(existing, scriptPath) {
403
+ const hooks = {};
404
+ const replaced = [];
405
+ for (const [event, groups] of Object.entries(existing.hooks ?? {})) {
406
+ const { groups: foreign, removed } = withoutOurs(groups, scriptPath);
407
+ if (removed)
408
+ replaced.push(event);
409
+ if (foreign.length > 0)
410
+ hooks[event] = foreign;
411
+ }
412
+ return { document: { ...existing, hooks }, added: [], replaced, removed: [] };
413
+ }
414
+ /**
415
+ * Writes the settings file the way a tool that does not own it should.
416
+ *
417
+ * Truncating in place lost the user's whole harness configuration if the write
418
+ * failed halfway, and clobbered a concurrent editor's changes; following a
419
+ * symlink wrote through to a target they never named. So: refuse
420
+ * anything that is not a regular file, write a sibling temp file, fsync it, and
421
+ * rename over the original — atomic within a directory on every platform we
422
+ * support.
423
+ */
424
+ export function applyPlan(file, document) {
425
+ mkdirSync(path.dirname(file), { recursive: true });
426
+ const mode = targetMode(file);
427
+ const temp = path.join(path.dirname(file), `.${path.basename(file)}.notifai-${process.pid}.tmp`);
428
+ const handle = openSync(temp, 'w', mode);
429
+ try {
430
+ writeFileSync(handle, `${JSON.stringify(document, null, 2)}\n`);
431
+ fsyncSync(handle);
432
+ }
433
+ finally {
434
+ closeSync(handle);
435
+ }
436
+ try {
437
+ renameSync(temp, file);
438
+ }
439
+ catch (err) {
440
+ // Leaving the temp behind would be a second, quieter mess on top of the
441
+ // failure the caller is about to hear about.
442
+ try {
443
+ unlinkSync(temp);
444
+ }
445
+ catch {
446
+ // Nothing useful to do; the rename error is the one that matters.
447
+ }
448
+ throw err;
449
+ }
450
+ }
451
+ /** Mode to preserve, or the mode for a new file. Refuses a non-regular target. */
452
+ function targetMode(file) {
453
+ let stat;
454
+ try {
455
+ stat = lstatSync(file);
456
+ }
457
+ catch (err) {
458
+ // A settings file can carry tokens, so a file we create is ours alone.
459
+ if (err.code === 'ENOENT')
460
+ return 0o600;
461
+ throw err;
462
+ }
463
+ if (stat.isSymbolicLink()) {
464
+ throw new Error(`${file} is a symlink; refusing to write through it. Replace it with a regular file, ` +
465
+ 'or install to a different location.');
466
+ }
467
+ if (!stat.isFile())
468
+ throw new Error(`${file} is not a regular file; refusing to replace it.`);
469
+ return stat.mode & 0o777;
470
+ }
471
+ export function loadSettings(file) {
472
+ return readSettings(file);
473
+ }
474
+ export function loadCursorSettings(file) {
475
+ return readCursorSettings(file);
476
+ }
477
+ /**
478
+ * Any NotifAI handler, whatever checkout wrote it.
479
+ *
480
+ * Deliberately looser than `isOurHandler`: this answers "has NotifAI been set
481
+ * up here at all", and a handler installed from a second checkout is still
482
+ * evidence that it has (and is itself worth reporting).
483
+ */
484
+ function isNotifaiCommand(command) {
485
+ return / hook (user-prompt-submit|stop|session-end)\b/.test(command);
486
+ }
487
+ function isNotifaiHandler(handler) {
488
+ return isNotifaiCommand(handler.command);
489
+ }
490
+ /** Every place either harness would read a NotifAI handler from. */
491
+ export function findInstallations(cwd, env = process.env) {
492
+ const found = [];
493
+ for (const harness of HARNESSES) {
494
+ for (const global of [false, true]) {
495
+ const file = settingsFile(harness, global, cwd, env);
496
+ if (!existsSync(file))
497
+ continue;
498
+ // OpenCode's adapter is a plugin module, not a settings document, so it
499
+ // is reported as one installation covering all three events rather than
500
+ // parsed for handlers.
501
+ if (harness === 'opencode') {
502
+ const target = opencodePluginTarget(readFileSync(file, 'utf8'));
503
+ if (target === null)
504
+ continue;
505
+ found.push({
506
+ harness,
507
+ file,
508
+ global,
509
+ ...(!target.current
510
+ ? { problems: ['obsolete OpenCode event wiring; rerun `notifai hooks install --harness opencode`'] }
511
+ : {}),
512
+ // Reported as the command line the plugin will actually run, not as
513
+ // the plugin's own path: every check downstream asks which build a
514
+ // handler invokes, and for a module that answer lives inside it.
515
+ handlers: OPENCODE_EVENTS.map(([event, hookEvent]) => ({
516
+ event,
517
+ groupIndex: 0,
518
+ handlerIndex: 0,
519
+ command: hookCommand(target.exec, target.script, hookEvent),
520
+ })),
521
+ });
522
+ continue;
523
+ }
524
+ if (harness === 'cursor') {
525
+ let document;
526
+ try {
527
+ document = readCursorSettings(file);
528
+ }
529
+ catch {
530
+ continue;
531
+ }
532
+ const handlers = locateCursorHandlers(document);
533
+ if (handlers.length > 0)
534
+ found.push({ harness, file, global, handlers });
535
+ continue;
536
+ }
537
+ let document;
538
+ try {
539
+ document = readSettings(file);
540
+ }
541
+ catch {
542
+ continue;
543
+ }
544
+ const handlers = locateHandlers(document);
545
+ if (handlers.length > 0)
546
+ found.push({ harness, file, global, handlers });
547
+ }
548
+ }
549
+ return found;
550
+ }
551
+ function locateCursorHandlers(document) {
552
+ const handlers = [];
553
+ for (const [event, eventHandlers] of Object.entries(document.hooks ?? {})) {
554
+ eventHandlers.forEach((handler, handlerIndex) => {
555
+ if (isNotifaiCommand(handler.command)) {
556
+ handlers.push({ event, groupIndex: 0, handlerIndex, command: handler.command });
557
+ }
558
+ });
559
+ }
560
+ return handlers;
561
+ }
562
+ function locateHandlers(document) {
563
+ const handlers = [];
564
+ for (const [event, groups] of Object.entries(document.hooks ?? {})) {
565
+ groups.forEach((group, groupIndex) => {
566
+ group.hooks?.forEach((handler, handlerIndex) => {
567
+ if (isNotifaiHandler(handler)) {
568
+ handlers.push({ event, groupIndex, handlerIndex, command: handler.command });
569
+ }
570
+ });
571
+ });
572
+ }
573
+ return handlers;
574
+ }
575
+ /** The hook event a handler's command actually invokes, e.g. `stop`. */
576
+ export function handlerEvent(command) {
577
+ return / hook ([a-z-]+)/.exec(command)?.[1] ?? null;
578
+ }
579
+ //# sourceMappingURL=install-hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-hooks.js","sourceRoot":"","sources":["../src/install-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAE/E;;;;GAIG;AACH,MAAM,eAAe,GAAG;IACtB,CAAC,kBAAkB,EAAE,oBAAoB,CAAC;IAC1C,CAAC,MAAM,EAAE,MAAM,CAAC;IAChB,CAAC,YAAY,EAAE,aAAa,CAAC;CACrB,CAAA;AAEV;;;;;;;;;;;GAWG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAU,CAAA;AAyBhF;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,QAAgB,EAChB,UAAkB,EAClB,KAAa,EACb,OAAkB;IAElB,OAAO,CACL,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,SAAS,KAAK,IAAI,YAAY,EAAE;QACvE,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAAC,CAClD,CAAA;AACH,CAAC;AAED;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