@dibssoftware/dibs 0.0.180 → 0.0.195

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 (107) hide show
  1. package/CHANGELOG.md +111 -1
  2. package/README.md +10 -8
  3. package/bin/dibs.mjs +379 -74
  4. package/docs/agents.md +303 -0
  5. package/docs/council.md +88 -0
  6. package/docs/files.md +3 -3
  7. package/docs/guard.md +86 -11
  8. package/docs/json.md +211 -0
  9. package/docs/later.md +5 -5
  10. package/docs/machines.md +6 -6
  11. package/docs/questions.md +104 -3
  12. package/docs/reference.md +124 -30
  13. package/docs/relay.md +135 -11
  14. package/docs/releasing.md +7 -1
  15. package/docs/scheduling.md +28 -6
  16. package/docs/secrets.md +53 -0
  17. package/docs/simulators.md +3 -3
  18. package/docs/windows.md +3 -3
  19. package/package.json +1 -1
  20. package/skills/dibs/SKILL.md +79 -149
  21. package/src/about.mjs +341 -0
  22. package/src/acquire.mjs +113 -28
  23. package/src/after.mjs +127 -0
  24. package/src/agents.mjs +2 -1
  25. package/src/alerts.mjs +109 -48
  26. package/src/answers.mjs +2 -2
  27. package/src/board.mjs +21 -16
  28. package/src/broker.mjs +23 -7
  29. package/src/carry.mjs +287 -0
  30. package/src/codex.mjs +132 -0
  31. package/src/commands.mjs +254 -86
  32. package/src/config.mjs +85 -14
  33. package/src/connect.mjs +4 -2
  34. package/src/cool.mjs +28 -12
  35. package/src/council.mjs +482 -0
  36. package/src/cwd.mjs +9 -0
  37. package/src/decisions.mjs +250 -0
  38. package/src/declare.mjs +96 -0
  39. package/src/diskreport.mjs +306 -0
  40. package/src/diskuse.mjs +420 -0
  41. package/src/diskwarn.mjs +68 -13
  42. package/src/doctor.mjs +149 -0
  43. package/src/doors.mjs +547 -0
  44. package/src/durable.mjs +143 -0
  45. package/src/envs.mjs +372 -0
  46. package/src/events.mjs +7 -2
  47. package/src/files.mjs +121 -7
  48. package/src/guard.mjs +288 -105
  49. package/src/guardd.mjs +8 -1
  50. package/src/halt.mjs +63 -0
  51. package/src/handoffs.mjs +362 -0
  52. package/src/history.mjs +34 -4
  53. package/src/hogs.mjs +36 -8
  54. package/src/jobprogress.mjs +283 -0
  55. package/src/later.mjs +21 -10
  56. package/src/lock.mjs +51 -11
  57. package/src/measure.mjs +60 -14
  58. package/src/media.mjs +240 -0
  59. package/src/news.mjs +31 -0
  60. package/src/notes.mjs +49 -8
  61. package/src/notices.mjs +126 -43
  62. package/src/ondemand.mjs +25 -2
  63. package/src/outcome.mjs +163 -0
  64. package/src/overlap.mjs +2 -2
  65. package/src/override.mjs +149 -79
  66. package/src/owner.mjs +15 -2
  67. package/src/people.mjs +236 -0
  68. package/src/pickup.mjs +72 -0
  69. package/src/picture.mjs +321 -0
  70. package/src/plain.mjs +84 -18
  71. package/src/platform.mjs +29 -7
  72. package/src/preempt.mjs +123 -15
  73. package/src/primer.mjs +91 -20
  74. package/src/prints.mjs +99 -0
  75. package/src/proc.mjs +11 -1
  76. package/src/progress.mjs +49 -3
  77. package/src/proof.mjs +102 -0
  78. package/src/push.mjs +271 -0
  79. package/src/questions.mjs +328 -57
  80. package/src/quota.mjs +1 -1
  81. package/src/recap.mjs +205 -0
  82. package/src/relay.mjs +262 -26
  83. package/src/remote.mjs +23 -10
  84. package/src/reviewgate.mjs +268 -0
  85. package/src/reviews.mjs +377 -0
  86. package/src/route.mjs +263 -0
  87. package/src/rules.mjs +216 -0
  88. package/src/schedule.mjs +238 -44
  89. package/src/schema.mjs +62 -0
  90. package/src/scratch.mjs +2 -2
  91. package/src/serve.mjs +3 -2
  92. package/src/service.mjs +5 -1
  93. package/src/signed.mjs +97 -0
  94. package/src/simpool.mjs +46 -1
  95. package/src/spend.mjs +375 -0
  96. package/src/state.mjs +43 -17
  97. package/src/talk.mjs +1082 -134
  98. package/src/thin.sh +2 -0
  99. package/src/trail.mjs +290 -0
  100. package/src/trailnote.mjs +209 -0
  101. package/src/util.mjs +7 -0
  102. package/src/vault.mjs +435 -0
  103. package/src/vendors.mjs +327 -0
  104. package/src/version.mjs +1 -1
  105. package/src/web.mjs +354 -60
  106. package/src/work.mjs +487 -0
  107. package/src/worker.mjs +7 -1
@@ -0,0 +1,327 @@
1
+ // dibs guard for agent tools other than Claude Code. One set of rules (src/guard.mjs
2
+ // respond, src/files.mjs), read from each tool's hook input and answered in its format:
3
+ //
4
+ // Codex Claude Code's own format (hooks.json, PreToolUse, permission_mode), so
5
+ // src/guard.mjs answers it directly. Here: where its install goes, and its
6
+ // messages, which wait under its name since Claude Code doesn't know the session.
7
+ // Gemini CLI ~/.gemini/settings.json: BeforeTool answers { decision, reason } or changes
8
+ // tool_input; AfterTool and SessionStart add additionalContext.
9
+ // Cursor ~/.cursor/hooks.json: preToolUse answers { permission, agent_message,
10
+ // updated_input }; postToolUse and sessionStart add additional_context.
11
+ // OpenCode a plugin file (below) that hands each call to the hook in a small format of
12
+ // our own: { block }, { args } or { context }.
13
+ //
14
+ // The guard never rewrites a command (since 0.0.191): in every tool it turns a heavy one away
15
+ // with the exact dibs run line, and the tool's own approval sees the agent's retry.
16
+ //
17
+ // Loaded only for calls from these tools, and for dibs guard install and status.
18
+ import fs from 'node:fs';
19
+ import os from 'node:os';
20
+ import path from 'node:path';
21
+ import { fileURLToPath } from 'node:url';
22
+ import { respond, guardConfig, dibsConfig, dibsCommand, logError, installed, install, remove, isComplete, HOOK_COMMAND, split, DOOR_HINT } from './guard.mjs';
23
+
24
+ const DIBS_HOME = process.env.DIBS_HOME || path.join(os.homedir(), '.dibs');
25
+ const INBOX = path.join(DIBS_HOME, 'inbox.json');
26
+ const MESSAGES = path.join(DIBS_HOME, 'messages.json');
27
+ const HOOK_BIN = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'bin', 'dibs-guard.mjs');
28
+
29
+ // The tools whose hooks file dibs guard install writes, each with an env var that moves
30
+ // it (tests never touch the real ones). The edit tools are matched as well as the shell,
31
+ // for file leases; the after-tool hooks hand over messages.
32
+ const home = () => os.homedir();
33
+ export const TOOLS = {
34
+ codex: {
35
+ name: 'Codex',
36
+ file: () => process.env.DIBS_CODEX_HOOKS || path.join(process.env.CODEX_HOME || path.join(home(), '.codex'), 'hooks.json'),
37
+ // Edit and Write are Codex's names for apply_patch in a matcher; the call still says apply_patch.
38
+ entries: [['PreToolUse', 'Bash|apply_patch|Edit|Write'], ['SessionStart', null]],
39
+ handler: command => ({ type: 'command', command, timeout: 5 }),
40
+ note: 'Codex runs it once you trust it: open /hooks in a Codex session, and again after an update changes it',
41
+ },
42
+ gemini: {
43
+ name: 'Gemini CLI',
44
+ file: () => process.env.DIBS_GEMINI_SETTINGS || path.join(home(), '.gemini', 'settings.json'),
45
+ entries: [['BeforeTool', 'run_shell_command|write_file|replace'], ['AfterTool', 'run_shell_command|write_file|replace'], ['SessionStart', null]],
46
+ // Gemini CLI counts a hook's timeout in milliseconds.
47
+ handler: command => ({ name: 'dibs-guard', type: 'command', command, timeout: 5000 }),
48
+ },
49
+ cursor: {
50
+ name: 'Cursor',
51
+ file: () => process.env.DIBS_CURSOR_HOOKS || path.join(home(), '.cursor', 'hooks.json'),
52
+ flat: true,
53
+ top: { version: 1 },
54
+ entries: [['preToolUse', 'Shell|Write|Delete'], ['postToolUse', 'Shell|Write|Delete'], ['sessionStart', null]],
55
+ handler: command => ({ command, timeout: 5 }),
56
+ // cursor-agent talks only to Cursor's servers, so no scripted model could drive it here.
57
+ note: 'verified from shipped code, not run (cursor-agent 2026.11.22)',
58
+ },
59
+ opencode: {
60
+ name: 'OpenCode',
61
+ file: () => path.join(process.env.DIBS_OPENCODE_PLUGINS || path.join(process.env.XDG_CONFIG_HOME || path.join(home(), '.config'), 'opencode', 'plugins'), 'dibs.js'),
62
+ plugin: true,
63
+ },
64
+ };
65
+ export const NAMES = Object.keys(TOOLS);
66
+
67
+ // ----- answering a call -----
68
+
69
+ // What the guard says about one call in Claude Code's shape: { deny }, { command } or null.
70
+ // A command that can't be undone waits for the person's yes, when they turned dibs doors on (src/doors.mjs).
71
+ async function judge(call, vendor) {
72
+ let h = respond(call, guardConfig(), dibsCommand())?.hookSpecificOutput;
73
+ const cmd = call.tool_name === 'Bash' ? call.tool_input?.command || '' : '';
74
+ if (!h && cmd && DOOR_HINT.test(cmd) && dibsConfig().doors?.on === true) h = (await import('./doors.mjs')).gate(call, split, dibsConfig(), { vendor })?.hookSpecificOutput;
75
+ if (h?.permissionDecision === 'deny') return { deny: outside(h.permissionDecisionReason) };
76
+ if (typeof h?.updatedInput?.command === 'string') return { command: h.updatedInput.command };
77
+ return null;
78
+ }
79
+
80
+ const firstPath = ti => [ti?.file_path, ti?.filePath, ti?.path, ti?.target_file].find(p => typeof p === 'string' && p);
81
+ const write = (input, file, cwd) => (file ? { ...input, tool_name: 'Write', tool_input: { file_path: file }, cwd } : null);
82
+ const bash = (input, command, cwd) => (typeof command === 'string' ? { ...input, tool_name: 'Bash', tool_input: { command }, cwd } : null);
83
+ const under = (cwd, dir) => (typeof dir === 'string' && dir ? path.resolve(typeof cwd === 'string' ? cwd : process.cwd(), dir) : cwd);
84
+
85
+ // Each adapter: which kind of event a call is (tool, after, start), the call in Claude
86
+ // Code's shape, and its answers. quiet is what to print when the guard has nothing to say.
87
+ const ADAPTERS = {
88
+ gemini: {
89
+ kind: i => ({ BeforeTool: 'tool', AfterTool: 'after', SessionStart: 'start' })[i.hook_event_name],
90
+ call: i => {
91
+ const ti = i.tool_input || {};
92
+ if (i.tool_name === 'run_shell_command') return bash(i, ti.command, under(i.cwd, ti.dir_path));
93
+ if (i.tool_name === 'write_file' || i.tool_name === 'replace') return write(i, firstPath(ti), i.cwd);
94
+ return null;
95
+ },
96
+ tool: r => (r.deny ? { decision: 'deny', reason: r.deny }
97
+ : { hookSpecificOutput: { hookEventName: 'BeforeTool', tool_input: { command: r.command } }, systemMessage: `dibs guard ran this through dibs: ${r.command}` }),
98
+ context: (text, i) => ({ hookSpecificOutput: { hookEventName: i.hook_event_name, additionalContext: text } }),
99
+ // Gemini CLI reads stdout as JSON: an empty object says nothing.
100
+ quiet: () => ({}),
101
+ },
102
+ cursor: {
103
+ kind: i => ({ preToolUse: 'tool', postToolUse: 'after', sessionStart: 'start' })[i.hook_event_name],
104
+ call: i => {
105
+ const ti = i.tool_input || {};
106
+ // A Shell call's input is { command, cwd, timeout } (cursor-agent 2026.11.22, 9622.index.js createToolInput).
107
+ const cwd = ti.cwd || i.cwd || i.workspace_roots?.[0];
108
+ const call = { ...i, session_id: i.conversation_id };
109
+ if (i.tool_name === 'Shell') return bash(call, ti.command, cwd);
110
+ if (i.tool_name === 'Write' || i.tool_name === 'Delete') return write(call, firstPath(ti), cwd);
111
+ return null;
112
+ },
113
+ // On a deny cursor-agent hands the model user_message, not agent_message. updated_input is
114
+ // applied whatever permission says, so a rewrite needs no "allow".
115
+ tool: r => (r.deny ? { permission: 'deny', user_message: r.deny, agent_message: r.deny } : { updated_input: { command: r.command } }),
116
+ context: text => ({ additional_context: text }),
117
+ // An empty object is a valid answer that changes nothing. Never "allow": cursor-agent sends
118
+ // a hook's permission on to Cursor's servers, where what it does can't be read. No output
119
+ // at all would be logged as a failed hook.
120
+ quiet: () => ({}),
121
+ },
122
+ opencode: {
123
+ kind: i => ({ 'opencode.before': 'tool', 'opencode.after': 'after', 'opencode.start': 'start' })[i.hook_event_name],
124
+ call: i => {
125
+ const a = i.args || {};
126
+ const call = { hook_event_name: 'PreToolUse', session_id: i.sessionID, cwd: i.cwd };
127
+ // OpenCode 1 calls its shell bash, OpenCode 2 shell; both take command and workdir.
128
+ if (i.tool === 'bash' || i.tool === 'shell') return bash(call, a.command, under(i.cwd, a.workdir));
129
+ if (i.tool === 'apply_patch' || i.tool === 'patch') return { ...call, tool_name: 'apply_patch', tool_input: { command: a.patchText } };
130
+ if (['edit', 'write', 'multiedit'].includes(i.tool)) return write(call, firstPath(a), i.cwd);
131
+ return null;
132
+ },
133
+ tool: r => (r.deny ? { block: r.deny } : { args: { command: r.command } }),
134
+ context: text => ({ context: text }),
135
+ },
136
+ };
137
+
138
+ export async function decideFor(vendor, input) {
139
+ const a = ADAPTERS[vendor];
140
+ const kind = a.kind(input);
141
+ let out = null;
142
+ try {
143
+ if (kind === 'tool') {
144
+ const call = a.call(input);
145
+ const r = call && await judge(call, vendor);
146
+ if (r) out = a.tool(r, input);
147
+ } else if (kind === 'after') {
148
+ const text = await pending();
149
+ if (text) out = a.context(text, input);
150
+ } else if (kind === 'start') {
151
+ // Without dibs listen: only Claude Code keeps a background task running between turns.
152
+ out = a.context((await import('./primer.mjs')).primerText({ subagent: true, full: true }), input);
153
+ }
154
+ } catch (e) { logError(e, input); }
155
+ return out ?? a.quiet?.(kind) ?? null;
156
+ }
157
+
158
+ // Messages from the person and dibs's notices for an agent Claude Code doesn't know: they
159
+ // wait under its name ("@who" in inbox.json), and its next dibs command or tool call takes
160
+ // them. The name is the one its dibs commands go by, and any thread its session process
161
+ // started under another (a dibs command from a subfolder names it after that folder).
162
+ export async function pending() {
163
+ let box;
164
+ try { box = JSON.parse(fs.readFileSync(INBOX, 'utf8')); } catch { return ''; }
165
+ if (!Object.keys(box).some(k => k.startsWith('@'))) return '';
166
+ const { identity } = await import('./proc.mjs');
167
+ const id = identity();
168
+ const names = new Set([id.who]);
169
+ if (id.spid) {
170
+ try { for (const th of JSON.parse(fs.readFileSync(MESSAGES, 'utf8')).threads || []) if (th.spid === id.spid && !th.session) names.add(th.who); } catch {}
171
+ }
172
+ const waiting = [...names].filter(n => box[`@${n}`]);
173
+ if (!waiting.length) return '';
174
+ const { noticesFor } = await import('./talk.mjs');
175
+ return waiting.map(noticesFor).filter(Boolean).join('\n\n');
176
+ }
177
+
178
+ // Codex: Claude Code's answer, put in Codex's terms, with any messages waiting under its name.
179
+ export async function codexAnswer(input, out) {
180
+ const h = out?.hookSpecificOutput;
181
+ if (h && input.hook_event_name === 'SessionStart') {
182
+ return { ...out, hookSpecificOutput: { ...h, additionalContext: (await import('./primer.mjs')).primerText({ subagent: true, full: true }) } };
183
+ }
184
+ if (input.hook_event_name !== 'PreToolUse') return out;
185
+ if (h?.permissionDecision === 'deny') return { ...out, hookSpecificOutput: { ...h, permissionDecisionReason: outside(h.permissionDecisionReason) } };
186
+ const text = await pending();
187
+ const context = [h?.additionalContext && outside(h.additionalContext), text].filter(Boolean).join('\n\n');
188
+ if (!context) return out;
189
+ return { ...out, hookSpecificOutput: { hookEventName: 'PreToolUse', ...h, additionalContext: context } };
190
+ }
191
+
192
+ // The guard's words for Claude Code, said for an agent anywhere else: no SendMessage tool, and
193
+ // no moving a waiting call to the background (outside Claude Code dibs run gives up after a while).
194
+ const outside = text => String(text)
195
+ .replace(/Or SendMessage (.+?) and ask\./, 'Or ask them: dibs tell $1 "..."')
196
+ .replace(/If this call reaches its timeout while waiting in the queue, Claude Code moves it to the background and tells you when it ends: don't run it again\./,
197
+ 'If dibs run gives up waiting (exit 75 or 74), your command never ran: run it again.');
198
+
199
+ // ----- the OpenCode plugin -----
200
+
201
+ const MARK = '// dibs guard for OpenCode';
202
+
203
+ // The plugin, with this Node and this hook written in: OpenCode runs plugins in its own
204
+ // runtime, which may have no node on PATH. Both plugin APIs: OpenCode 1 calls server(),
205
+ // OpenCode 2 calls setup().
206
+ export function opencodePlugin(node = path.join(nodeDir(), process.platform === 'win32' ? 'node.exe' : 'node'), hook = HOOK_BIN) {
207
+ return `${MARK}, written by \`dibs guard install --for opencode\`. dibs guard remove --for opencode takes it out.
208
+ // Before each bash, edit, write or patch call it asks dibs's guard (${hook}): a heavy
209
+ // command outside dibs run is turned away with the exact dibs run line, and so is a write
210
+ // to a file another agent leased. Messages from the person come after the next such call,
211
+ // and every session starts with a few lines on how to use dibs. Anything that goes wrong
212
+ // here lets the call through.
213
+ import { spawnSync } from 'node:child_process';
214
+ import fs from 'node:fs';
215
+ import os from 'node:os';
216
+ import path from 'node:path';
217
+
218
+ const NODE = ${JSON.stringify(node)};
219
+ const HOOK = ${JSON.stringify(hook)};
220
+ const INBOX = path.join(process.env.DIBS_HOME || path.join(os.homedir(), '.dibs'), 'inbox.json');
221
+ // OpenCode 1's tools (bash, edit, write, patch) and OpenCode 2's (shell, edit, write).
222
+ const TOOLS = new Set(['bash', 'shell', 'edit', 'write', 'multiedit', 'patch', 'apply_patch']);
223
+
224
+ function ask(payload) {
225
+ try {
226
+ const r = spawnSync(NODE, [HOOK], { input: JSON.stringify(payload), encoding: 'utf8', timeout: 5000 });
227
+ return r.status === 0 && r.stdout.trim() ? JSON.parse(r.stdout) : null;
228
+ } catch { return null; }
229
+ }
230
+
231
+ function before(api, tool, args, sessionID, cwd) {
232
+ if (!TOOLS.has(tool) || !args || typeof args !== 'object') return;
233
+ const a = ask({ hook_event_name: 'opencode.before', api, tool, args, sessionID, cwd });
234
+ if (a?.block) throw new Error(a.block);
235
+ if (a?.args) Object.assign(args, a.args);
236
+ }
237
+
238
+ // Messages waiting for this agent. Asked for only when anything waits for anyone and the
239
+ // call's result has text to add them to: handing them over marks them read.
240
+ const after = (api, tool) => (TOOLS.has(tool) && fs.existsSync(INBOX) ? ask({ hook_event_name: 'opencode.after', api, tool })?.context || '' : '');
241
+
242
+ let primer = null;
243
+ const rules = () => (primer ??= ask({ hook_event_name: 'opencode.start' })?.context || '');
244
+
245
+ export default {
246
+ id: 'dibs',
247
+ // OpenCode 1: tool.execute.before(input, output) with output.args; after with output.output.
248
+ async server(ctx) {
249
+ return {
250
+ 'tool.execute.before': async (input, output) => before('v1', input.tool, output.args, input.sessionID, ctx.directory),
251
+ 'tool.execute.after': async (input, output) => {
252
+ if (typeof output?.output !== 'string') return;
253
+ const t = after('v1', input.tool);
254
+ if (t) output.output += \`\\n\\n\${t}\`;
255
+ },
256
+ 'experimental.chat.system.transform': async (input, output) => {
257
+ if (rules() && Array.isArray(output.system)) output.system.push(rules());
258
+ },
259
+ };
260
+ },
261
+ // OpenCode 2: one event per hook (packages/plugin/src/effect/tool.ts); a finished call's
262
+ // result.content is a string or a list of parts.
263
+ async setup(ctx) {
264
+ const dir = ctx.location?.directory;
265
+ await ctx.tool.hook('execute.before', async e => before('v2', e.tool, e.input, e.sessionID, dir));
266
+ await ctx.tool.hook('execute.after', async e => {
267
+ const c = e.status === 'completed' ? e.result?.content : undefined;
268
+ if (typeof c !== 'string' && !Array.isArray(c)) return;
269
+ const t = after('v2', e.tool);
270
+ if (t) e.result = { ...e.result, content: typeof c === 'string' ? \`\${c}\\n\\n\${t}\` : [...c, { type: 'text', text: t }] };
271
+ });
272
+ await ctx.session.hook('context', async e => {
273
+ if (rules() && Array.isArray(e.system)) e.system.push({ type: 'text', text: rules() });
274
+ });
275
+ },
276
+ };
277
+ `;
278
+ }
279
+
280
+ const ownPlugin = file => { try { return fs.readFileSync(file, 'utf8').startsWith(MARK) ? fs.readFileSync(file, 'utf8') : null; } catch { return null; } };
281
+
282
+ // ----- install, remove, status -----
283
+
284
+ // The folder node is found in on PATH (/opt/homebrew/bin, not the versioned folder it
285
+ // links to, which an upgrade removes), else this Node's own.
286
+ function nodeDir() {
287
+ const exe = process.platform === 'win32' ? 'node.exe' : 'node';
288
+ for (const dir of (process.env.PATH || '').split(path.delimiter)) if (dir && path.isAbsolute(dir) && fs.existsSync(path.join(dir, exe))) return dir;
289
+ return path.dirname(process.execPath);
290
+ }
291
+
292
+ // Every tool runs the same hook command as Claude Code's settings.json: the hook tells the
293
+ // tools apart by their input, and cursor-agent, which also runs the hooks in
294
+ // ~/.claude/settings.json, drops a Claude Code hook whose command matches one in its own file,
295
+ // so the hook runs once.
296
+ export function installFor(tool, file = TOOLS[tool].file(), command = HOOK_COMMAND) {
297
+ const t = TOOLS[tool];
298
+ if (!t.plugin) return install(file, command, t);
299
+ const text = opencodePlugin();
300
+ const old = ownPlugin(file);
301
+ if (old === text) return `already installed in ${file}`;
302
+ if (fs.existsSync(file) && old == null) throw new Error(`${file} is there and isn't dibs's; not touching it`);
303
+ fs.mkdirSync(path.dirname(file), { recursive: true });
304
+ fs.writeFileSync(`${file}.dibs-${process.pid}`, text);
305
+ fs.renameSync(`${file}.dibs-${process.pid}`, file);
306
+ return `${old ? 'updated' : 'installed'} in ${file}`;
307
+ }
308
+
309
+ export function removeFor(tool, file = TOOLS[tool].file()) {
310
+ if (!TOOLS[tool].plugin) return remove(file, TOOLS[tool]);
311
+ // Never delete a plugin dibs didn't write.
312
+ if (ownPlugin(file) == null) return null;
313
+ fs.rmSync(file);
314
+ return `removed ${file}`;
315
+ }
316
+
317
+ // { tool, name, installed, complete, file, note, viaClaude } for each tool, for dibs guard status.
318
+ // viaClaude: cursor-agent also runs the hooks in ~/.claude/settings.json, so dibs's Claude Code
319
+ // hook covers it with no file of its own (9622.index.js, the hooks loader's claude-user source).
320
+ export function statusFor(tool, file = TOOLS[tool].file()) {
321
+ const t = TOOLS[tool];
322
+ let on = false, whole = false, viaClaude = false;
323
+ if (t.plugin) { const text = ownPlugin(file); on = text != null; whole = text === opencodePlugin(); }
324
+ else { try { on = !!installed(file, t); whole = on && isComplete(file, t); } catch {} }
325
+ if (tool === 'cursor' && !on) { try { viaClaude = !!installed(); } catch {} }
326
+ return { tool, name: t.name, installed: on, complete: whole, file, ...(t.note && { note: t.note }), ...(viaClaude && { viaClaude }) };
327
+ }
package/src/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  // Bump with every release and add a matching section at the top of CHANGELOG.md.
2
- export const VERSION = '0.0.180';
2
+ export const VERSION = '0.0.195';