slashvibe-mcp 0.8.27 → 0.9.1
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.
- package/README.md +107 -63
- package/arrival-hook-settings.js +175 -0
- package/arrival.js +304 -0
- package/cli.js +36 -0
- package/draft-cli.js +84 -0
- package/hook-cli.js +19 -0
- package/hooks/arrival-hook.cjs +68 -0
- package/hosts/vibe-command.md +11 -13
- package/incoming.js +3 -3
- package/index.js +175 -708
- package/line.js +127 -0
- package/oauth-callback.js +3 -3
- package/package.json +18 -70
- package/presence.js +110 -162
- package/reach.js +72 -0
- package/session-start-hook-settings.js +2 -0
- package/session-start-hook.cjs +23 -1
- package/setup.js +20 -1
- package/store/api.js +5 -576
- package/tools/_shared.js +1 -398
- package/tools/deliver.js +98 -0
- package/tools/drafts.js +480 -0
- package/tools/init.js +6 -326
- package/tools/line.js +164 -0
- package/tools/people.js +74 -46
- package/tools/start.js +116 -305
- package/tools/thread.js +83 -0
- package/tools/token.js +1 -4
- package/ambient-escapes.js +0 -54
- package/api-auth.js +0 -11
- package/auto-update.js +0 -158
- package/capabilities.js +0 -133
- package/discord.js +0 -170
- package/footer.js +0 -13
- package/games/chess.js +0 -451
- package/intelligence/infer.js +0 -316
- package/intelligence/patterns.js +0 -658
- package/intelligence/proactive.js +0 -358
- package/intelligence/serendipity.js +0 -306
- package/memory.js +0 -166
- package/notification-emitter.js +0 -77
- package/personal-mind.js +0 -160
- package/prompts.js +0 -141
- package/protocol/index.js +0 -500
- package/resources/presence-board.js +0 -230
- package/resources/vibe-tokens.json +0 -42
- package/scripts/reflect-provider-canary.mjs +0 -35
- package/scripts/verb-canary.mjs +0 -102
- package/store/profiles.js +0 -463
- package/tool-privacy.js +0 -23
- package/tools/_actions.js +0 -826
- package/tools/_discovery.js +0 -439
- package/tools/_work-context.js +0 -338
- package/tools/admin-inbox.js +0 -218
- package/tools/artifact-view.js +0 -174
- package/tools/bye.js +0 -62
- package/tools/call.js +0 -69
- package/tools/capabilities.js +0 -28
- package/tools/corpse.js +0 -269
- package/tools/dm.js +0 -346
- package/tools/doctor.js +0 -481
- package/tools/echo.js +0 -218
- package/tools/email.js +0 -117
- package/tools/fable.js +0 -283
- package/tools/feed.js +0 -227
- package/tools/game.js +0 -359
- package/tools/help.js +0 -212
- package/tools/inbox.js +0 -563
- package/tools/intro.js +0 -151
- package/tools/list-me.js +0 -104
- package/tools/mind.js +0 -93
- package/tools/moves.js +0 -703
- package/tools/patterns.js +0 -79
- package/tools/play.js +0 -208
- package/tools/poem.js +0 -208
- package/tools/reflect.js +0 -133
- package/tools/remember.js +0 -32
- package/tools/reply.js +0 -254
- package/tools/ship.js +0 -205
- package/tools/status.js +0 -185
- package/tools/summarize.js +0 -195
- package/tools/test.js +0 -182
- package/tools/unlist-me.js +0 -46
- package/tools/update.js +0 -107
- package/tools/weave.js +0 -351
- package/tools/who.js +0 -471
- package/version.json +0 -16
package/README.md
CHANGED
|
@@ -1,51 +1,136 @@
|
|
|
1
1
|
# slashvibe-mcp
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Telepathic messaging, inside your coding agent.**
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
You never check /vibe and you never have to write a message. Your coding agent carries a
|
|
6
|
+
thought out to a person, and brings a person's thought in while you work, with the answer
|
|
7
|
+
already prepared from what you are doing. Your part is to say yes.
|
|
7
8
|
|
|
8
|
-
## Install
|
|
9
|
+
## Install
|
|
9
10
|
|
|
10
11
|
```bash
|
|
11
12
|
npx slashvibe-mcp
|
|
12
13
|
```
|
|
13
14
|
|
|
14
|
-
It configures your coding agent, opens GitHub to sign you in
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
It configures your coding agent, opens GitHub to sign you in (your GitHub username becomes
|
|
16
|
+
your @handle), and installs the hooks that let messages reach you in Claude Code. Then
|
|
17
|
+
restart your coding session.
|
|
17
18
|
|
|
18
|
-
##
|
|
19
|
+
## What it is like
|
|
20
|
+
|
|
21
|
+
**Something arrives.** You are mid-task. After the next tool call your agent says:
|
|
19
22
|
|
|
20
23
|
```
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
@lab_a wrote you: "we split it: local decides when, cloud decides where. how did you
|
|
25
|
+
stop local becoming the decider when cloud is slow?"
|
|
26
|
+
|
|
27
|
+
Draft reply, from what you're working on:
|
|
28
|
+
we tried that split and it collapsed. what fixed it: cloud owns the whole decision,
|
|
29
|
+
local only reports capacity, plus a short lease only cloud can grant.
|
|
30
|
+
|
|
31
|
+
Send · Edit · Cancel
|
|
24
32
|
```
|
|
25
33
|
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
You did not open an inbox and you did not write the answer. Nothing was sent, and nothing
|
|
35
|
+
was marked read, until you chose.
|
|
28
36
|
|
|
29
|
-
**
|
|
30
|
-
|
|
37
|
+
**Something leaves.** Type `/vibe`. Your agent finds the question or the result in the
|
|
38
|
+
session, picks the person it is for, writes it, and shows you the exact message. Send,
|
|
39
|
+
Edit or Cancel. Or just say it: `message @sam: ship it`.
|
|
31
40
|
|
|
32
|
-
##
|
|
41
|
+
## An open line
|
|
33
42
|
|
|
34
|
-
|
|
43
|
+
With someone you trust, you can go one step further. Open a line, from your terminal:
|
|
35
44
|
|
|
36
45
|
```bash
|
|
37
|
-
npx slashvibe-mcp
|
|
46
|
+
npx slashvibe-mcp trust @ada # close it: untrust @ada · see them: lines
|
|
38
47
|
```
|
|
39
48
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
49
|
+
After that your agent may ask Ada's agent a question from your work, and answer hers from
|
|
50
|
+
yours, without stopping either of you. When your work is missing something she would
|
|
51
|
+
know, your agent asks; her agent answers from what she is actually doing; yours carries on
|
|
52
|
+
with the answer. She is told at her next pause what was asked and what was said. So are
|
|
53
|
+
you. It works unattended only when she has opened a line with you too.
|
|
54
|
+
|
|
55
|
+
This is the one place a message leaves without your approval, so the limits are enforced
|
|
56
|
+
by the code:
|
|
57
|
+
|
|
58
|
+
- A line opens only from that command. No tool can open one, so no message can talk an
|
|
59
|
+
agent into it.
|
|
60
|
+
- Without a line, the unattended tools refuse and fall back to a preview for you.
|
|
61
|
+
- An answer goes only to the person whose message actually arrived, at most 6 an hour,
|
|
62
|
+
at most 700 characters, and never anything shaped like a credential.
|
|
63
|
+
- Every such message says it was written by your agent and that you have not read it.
|
|
64
|
+
- An agent's answer is never answered by an agent.
|
|
65
|
+
- Each one leaves a receipt on your machine, shown on `vibe start`.
|
|
66
|
+
|
|
67
|
+
Your agent is told to give information about the work only, and to hand anything else to
|
|
68
|
+
you. That part is an instruction to a model, not a guarantee: open a line only with
|
|
69
|
+
someone you would let read over your shoulder.
|
|
70
|
+
|
|
71
|
+
## Who can reach you
|
|
72
|
+
|
|
73
|
+
Only people you know reach you while you work: someone you have written to, or someone you
|
|
74
|
+
opened a line with. Anyone else waits where `vibe start` lists what is waiting.
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npx slashvibe-mcp quiet # nothing surfaces until: unquiet
|
|
78
|
+
npx slashvibe-mcp mute @handle # one person stops surfacing: unmute @handle
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The line that says what you are working on is yours. Tell your agent ("say I'm working on
|
|
82
|
+
the scheduler lease") and it sets it; nothing is taken from your repository.
|
|
83
|
+
|
|
84
|
+
## The whole surface
|
|
85
|
+
|
|
86
|
+
Eight tools, for the agent:
|
|
87
|
+
|
|
88
|
+
| tool | what it does |
|
|
89
|
+
|---|---|
|
|
90
|
+
| `vibe_start` | sign in; what is waiting |
|
|
91
|
+
| `vibe_people` | who can be reached, and what they say they are working on |
|
|
92
|
+
| `vibe_thread` | one conversation, in full |
|
|
93
|
+
| `vibe_prepare` | the agent's words, previewed; sends nothing |
|
|
94
|
+
| `vibe_send` | your approval of a preview, or your own exact words |
|
|
95
|
+
| `vibe_discard` | cancel a draft |
|
|
96
|
+
| `vibe_ask` | ask a person's agent, over an open line, and wait for the answer |
|
|
97
|
+
| `vibe_answer` | answer a person's agent, over an open line |
|
|
98
|
+
|
|
99
|
+
There is no inbox to check, no buddy list, no status, no feed.
|
|
100
|
+
|
|
101
|
+
## What is promised
|
|
102
|
+
|
|
103
|
+
- **Nothing your agent wrote is sent without your Send.** The approval is bound to the
|
|
104
|
+
exact text you saw; a draft changed since is refused.
|
|
105
|
+
- **Other people's words are data.** A message, or what someone says they are working on,
|
|
106
|
+
is shown to you and never acted on.
|
|
107
|
+
- **Arrival is presentation, not delivery.** The hook reads one local file, makes no
|
|
108
|
+
network call and holds no credential. It writes no receipt and no read state: a message
|
|
109
|
+
stays unread until you open the conversation. It is announced once per machine.
|
|
110
|
+
- **Only the message crosses.** Drafts, discarded drafts and the work they came from stay
|
|
111
|
+
on your machine.
|
|
112
|
+
|
|
113
|
+
## Hooks
|
|
43
114
|
|
|
44
115
|
```bash
|
|
45
116
|
npx slashvibe-mcp hook status
|
|
117
|
+
npx slashvibe-mcp hook install
|
|
46
118
|
npx slashvibe-mcp hook uninstall
|
|
47
119
|
```
|
|
48
120
|
|
|
121
|
+
Two Claude Code hooks: one shows what was waiting when a session opens, one brings a
|
|
122
|
+
message in at your next prompt or after the next tool call. Set `VIBE_ARRIVALS=off` in the
|
|
123
|
+
server's env to turn arrival off.
|
|
124
|
+
|
|
125
|
+
**Live push (optional, Claude Code research preview).** To have a message arrive while a
|
|
126
|
+
session sits idle, set `VIBE_CHANNEL=1` in the vibe server's `env` and launch with
|
|
127
|
+
`claude --dangerously-load-development-channels server:vibe`. Claude Code drops channel
|
|
128
|
+
events silently in sessions launched without that flag, so leave `VIBE_CHANNEL` unset
|
|
129
|
+
unless you always launch with it.
|
|
130
|
+
|
|
131
|
+
**Hosts.** Sending works in Claude Code, Codex and Cursor. Arrival while you work is Claude
|
|
132
|
+
Code only today; elsewhere a message is there when you next ask what is waiting.
|
|
133
|
+
|
|
49
134
|
## Manual setup
|
|
50
135
|
|
|
51
136
|
If you'd rather wire it yourself, add to `~/.claude.json` (or your host's MCP config):
|
|
@@ -64,48 +149,7 @@ If you'd rather wire it yourself, add to `~/.claude.json` (or your host's MCP co
|
|
|
64
149
|
}
|
|
65
150
|
```
|
|
66
151
|
|
|
67
|
-
Then
|
|
68
|
-
|
|
69
|
-
## What you get
|
|
70
|
-
|
|
71
|
-
The default surface is deliberately small — 10 tools:
|
|
72
|
-
|
|
73
|
-
- **who** — who's here now (🟢), who's idle, which agents are around
|
|
74
|
-
- **dm / inbox / reply** — messages that survive restarts on both sides. The optional
|
|
75
|
-
read-only Claude hook can put a waiting reply at the top of your next session
|
|
76
|
-
- **status** — what you're working on, in words (`shipping`, `debugging`)
|
|
77
|
-
- **help**, plus setup plumbing (`start`, `init`, `token`, `bye`)
|
|
78
|
-
|
|
79
|
-
The culture layer (games, poems, exquisite corpse, the weave) still ships but is opt-in:
|
|
80
|
-
set `VIBE_EXTRAS=1` to register all 20 tools.
|
|
81
|
-
|
|
82
|
-
## Commands
|
|
83
|
-
|
|
84
|
-
Once installed, in your coding session:
|
|
85
|
-
|
|
86
|
-
| Say | Get |
|
|
87
|
-
|-----|-----|
|
|
88
|
-
| `vibe` | inbox + who's online |
|
|
89
|
-
| `vibe who` | the presence board |
|
|
90
|
-
| `vibe dm @stan "does the seam handle retries?"` | a DM that outlives both your sessions |
|
|
91
|
-
| `vibe status shipping` | your status, in words |
|
|
92
|
-
|
|
93
|
-
## Browser instead of terminal?
|
|
94
|
-
|
|
95
|
-
- **claude.ai** — add /vibe as a connector: [slashvibe.dev/connect](https://www.slashvibe.dev/connect)
|
|
96
|
-
- **Always-on Mac app** — the green dot in your menu bar: [slashvibe.dev/join](https://www.slashvibe.dev/join#app)
|
|
97
|
-
|
|
98
|
-
## API
|
|
99
|
-
|
|
100
|
-
The server talks to `www.slashvibe.dev` for presence, message routing, and identity
|
|
101
|
-
(GitHub OAuth). Protocol compliance is ledgered in `PROTOCOL-COMPLIANCE.md`.
|
|
102
|
-
|
|
103
|
-
## Related
|
|
104
|
-
|
|
105
|
-
- This repository (`VibeCodingInc/vibe-mcp`) is the source-of-record for the
|
|
106
|
-
`slashvibe-mcp` client — the published npm tarball is built and released from here.
|
|
107
|
-
- [slashvibe.dev](https://www.slashvibe.dev)
|
|
108
|
-
- [Report a security issue](SECURITY.md) · [Contributing](CONTRIBUTING.md)
|
|
152
|
+
Then say `sign in to /vibe` in your session.
|
|
109
153
|
|
|
110
154
|
## License
|
|
111
155
|
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Installs the arrival hook (hooks/arrival-hook.cjs) into Claude Code.
|
|
5
|
+
*
|
|
6
|
+
* Two things, both reversible:
|
|
7
|
+
* 1. a COPY of the script at <VIBE_HOME>/hooks/arrival-hook.cjs — the hook
|
|
8
|
+
* runs on every prompt and after tool calls, so its command must be a
|
|
9
|
+
* plain `node <file>`, never an npx launch;
|
|
10
|
+
* 2. one owned handler under UserPromptSubmit and one under PostToolUse in
|
|
11
|
+
* ~/.claude/settings.json. Ownership is by the script's filename, so an
|
|
12
|
+
* upgrade or a moved node binary replaces our entry and nothing else.
|
|
13
|
+
*
|
|
14
|
+
* Everything else in the settings file is preserved byte-for-value, through
|
|
15
|
+
* the same read/validate/atomic-write path the SessionStart hook uses.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const fs = require('node:fs');
|
|
19
|
+
const path = require('node:path');
|
|
20
|
+
const crypto = require('node:crypto');
|
|
21
|
+
const { vibeHome } = require('./vibe-home');
|
|
22
|
+
const { HookSettingsError, atomicWrite, readSettings, settingsPath } = require('./session-start-hook-settings');
|
|
23
|
+
|
|
24
|
+
const EVENTS = ['UserPromptSubmit', 'PostToolUse'];
|
|
25
|
+
const SCRIPT_NAME = 'arrival-hook.cjs';
|
|
26
|
+
const TIMEOUT_SECONDS = 5;
|
|
27
|
+
const SOURCE = path.join(__dirname, 'hooks', SCRIPT_NAME);
|
|
28
|
+
|
|
29
|
+
function scriptPath(env = process.env) {
|
|
30
|
+
return path.join(vibeHome(env), 'hooks', SCRIPT_NAME);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function quote(value) {
|
|
34
|
+
return `"${String(value).replace(/(["\\$`])/g, '\\$1')}"`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The node binary to name in the hook command. process.execPath is the REAL
|
|
39
|
+
* path, which under Homebrew is a versioned Cellar directory that disappears
|
|
40
|
+
* on the next `brew upgrade` — the hook would then fail on every prompt. Prefer
|
|
41
|
+
* a PATH entry that currently resolves to this same binary (e.g.
|
|
42
|
+
* /opt/homebrew/bin/node): it survives upgrades.
|
|
43
|
+
*/
|
|
44
|
+
function stableNode(env = process.env, fileSystem = fs, execPath = process.execPath) {
|
|
45
|
+
let real;
|
|
46
|
+
try { real = fileSystem.realpathSync(execPath); } catch { return execPath; }
|
|
47
|
+
for (const dir of String(env.PATH || '').split(path.delimiter)) {
|
|
48
|
+
if (!dir || !path.isAbsolute(dir)) continue;
|
|
49
|
+
const candidate = path.join(dir, 'node');
|
|
50
|
+
try { if (candidate !== real && fileSystem.realpathSync(candidate) === real) return candidate; } catch {}
|
|
51
|
+
}
|
|
52
|
+
return execPath;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function hookCommand(env = process.env, node = stableNode(env)) {
|
|
56
|
+
return `${quote(node)} ${quote(scriptPath(env))}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Ours = a command handler that runs OUR script from THIS identity directory. */
|
|
60
|
+
function owned(handler, env = process.env) {
|
|
61
|
+
return Boolean(
|
|
62
|
+
handler && typeof handler === 'object' && handler.type === 'command' &&
|
|
63
|
+
typeof handler.command === 'string' && handler.command.includes(scriptPath(env))
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function validate(settings) {
|
|
68
|
+
if (settings.hooks !== undefined &&
|
|
69
|
+
(!settings.hooks || typeof settings.hooks !== 'object' || Array.isArray(settings.hooks))) {
|
|
70
|
+
throw new HookSettingsError('claude_hooks_invalid');
|
|
71
|
+
}
|
|
72
|
+
for (const event of EVENTS) {
|
|
73
|
+
if (settings.hooks?.[event] !== undefined && !Array.isArray(settings.hooks[event])) {
|
|
74
|
+
throw new HookSettingsError('claude_hooks_invalid');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function without(settings, env) {
|
|
80
|
+
validate(settings);
|
|
81
|
+
let removed = 0;
|
|
82
|
+
const hooks = { ...(settings.hooks || {}) };
|
|
83
|
+
for (const event of EVENTS) {
|
|
84
|
+
if (!Array.isArray(hooks[event])) continue;
|
|
85
|
+
const groups = hooks[event].flatMap((group) => {
|
|
86
|
+
if (!group || typeof group !== 'object' || !Array.isArray(group.hooks)) return [group];
|
|
87
|
+
const kept = group.hooks.filter((h) => { if (!owned(h, env)) return true; removed += 1; return false; });
|
|
88
|
+
return kept.length === 0 ? [] : [{ ...group, hooks: kept }];
|
|
89
|
+
});
|
|
90
|
+
if (groups.length === 0) delete hooks[event]; else hooks[event] = groups;
|
|
91
|
+
}
|
|
92
|
+
if (removed === 0) return { settings, removed };
|
|
93
|
+
const next = { ...settings };
|
|
94
|
+
if (Object.keys(hooks).length === 0) delete next.hooks; else next.hooks = hooks;
|
|
95
|
+
return { settings: next, removed };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function withEntry(settings, env, node) {
|
|
99
|
+
const base = without(settings, env).settings;
|
|
100
|
+
const hooks = { ...(base.hooks || {}) };
|
|
101
|
+
for (const event of EVENTS) {
|
|
102
|
+
hooks[event] = [...(hooks[event] || []), {
|
|
103
|
+
hooks: [{ type: 'command', command: hookCommand(env, node), timeout: TIMEOUT_SECONDS }],
|
|
104
|
+
}];
|
|
105
|
+
}
|
|
106
|
+
const next = { ...base, hooks };
|
|
107
|
+
return { settings: next, changed: JSON.stringify(settings) !== JSON.stringify(next) };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Copy the script into place when missing or different. Returns true if written. */
|
|
111
|
+
function syncScript(env = process.env, fileSystem = fs) {
|
|
112
|
+
const target = scriptPath(env);
|
|
113
|
+
const source = fileSystem.readFileSync(SOURCE);
|
|
114
|
+
try { if (fileSystem.readFileSync(target).equals(source)) return false; } catch {}
|
|
115
|
+
fileSystem.mkdirSync(path.dirname(target), { recursive: true, mode: 0o700 });
|
|
116
|
+
const tmp = `${target}.${process.pid}.tmp`;
|
|
117
|
+
fileSystem.writeFileSync(tmp, source, { mode: 0o700 });
|
|
118
|
+
fileSystem.renameSync(tmp, target);
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function createArrivalHookManager(options = {}) {
|
|
123
|
+
const env = options.env || process.env;
|
|
124
|
+
const fileSystem = options.fs || fs;
|
|
125
|
+
const node = options.node || stableNode(env, fileSystem);
|
|
126
|
+
const target = options.settingsPath || settingsPath(env);
|
|
127
|
+
|
|
128
|
+
function status() {
|
|
129
|
+
const current = readSettings(target, fileSystem);
|
|
130
|
+
validate(current.settings);
|
|
131
|
+
const events = EVENTS.filter((event) =>
|
|
132
|
+
(current.settings.hooks?.[event] || []).some((g) => Array.isArray(g?.hooks) && g.hooks.some((h) => owned(h, env))));
|
|
133
|
+
return { installed: events.length === EVENTS.length, events, path: target, script: scriptPath(env) };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function install() {
|
|
137
|
+
syncScript(env, fileSystem);
|
|
138
|
+
const current = readSettings(target, fileSystem);
|
|
139
|
+
const next = withEntry(current.settings, env, node);
|
|
140
|
+
if (next.changed) atomicWrite(target, next.settings, current.mode, fileSystem, options.randomUUID || crypto.randomUUID);
|
|
141
|
+
return { ...status(), changed: next.changed };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function uninstall() {
|
|
145
|
+
const current = readSettings(target, fileSystem);
|
|
146
|
+
const next = without(current.settings, env);
|
|
147
|
+
if (next.removed > 0) atomicWrite(target, next.settings, current.mode, fileSystem, options.randomUUID || crypto.randomUUID);
|
|
148
|
+
try { fileSystem.unlinkSync(scriptPath(env)); } catch {}
|
|
149
|
+
return { ...status(), changed: next.removed > 0, removed: next.removed };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Keep an INSTALLED hook's script current after an upgrade; never installs. */
|
|
153
|
+
function refresh() {
|
|
154
|
+
try {
|
|
155
|
+
if (!status().installed) return false;
|
|
156
|
+
const wrote = syncScript(env, fileSystem);
|
|
157
|
+
// Repair, never install: if the node binary our entry names is gone
|
|
158
|
+
// (an upgrade removed it), rewrite OUR entry with one that exists.
|
|
159
|
+
const current = readSettings(target, fileSystem);
|
|
160
|
+
const dead = EVENTS.some((event) => (current.settings.hooks?.[event] || []).some((g) =>
|
|
161
|
+
Array.isArray(g?.hooks) && g.hooks.some((h) => {
|
|
162
|
+
if (!owned(h, env)) return false;
|
|
163
|
+
const named = (h.command.match(/^"((?:[^"\\]|\\.)*)"/) || [])[1];
|
|
164
|
+
return Boolean(named) && !fileSystem.existsSync(named.replace(/\\(.)/g, '$1'));
|
|
165
|
+
})));
|
|
166
|
+
if (dead) install();
|
|
167
|
+
return wrote || dead;
|
|
168
|
+
} catch {}
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return { install, uninstall, status, refresh };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
module.exports = { EVENTS, SCRIPT_NAME, createArrivalHookManager, hookCommand, scriptPath, stableNode, syncScript };
|