chat-recall 0.7.20 → 0.7.21
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 +37 -10
- package/dist/board-hooks.d.ts +37 -27
- package/dist/board-hooks.d.ts.map +1 -1
- package/dist/board-hooks.js +50 -80
- package/dist/board-hooks.js.map +1 -1
- package/dist/cli.js +9001 -8996
- package/dist/cli.js.map +1 -1
- package/dist/install-hooks.d.ts +95 -0
- package/dist/install-hooks.d.ts.map +1 -0
- package/dist/install-hooks.js +352 -0
- package/dist/install-hooks.js.map +1 -0
- package/dist/mcp-relay.js +1 -1
- package/dist/mcp.js +1960 -924
- package/dist/mcp.js.map +1 -1
- package/dist/message-hook-core.d.ts +67 -0
- package/dist/message-hook-core.d.ts.map +1 -0
- package/dist/message-hook-core.js +77 -0
- package/dist/message-hook-core.js.map +1 -0
- package/dist/message-hook.d.ts +2 -0
- package/dist/message-hook.d.ts.map +1 -0
- package/dist/message-hook.js +423 -0
- package/dist/message-hook.js.map +1 -0
- package/dist/scan-worker.js +32 -24
- package/dist/service-installer.d.ts.map +1 -1
- package/dist/service-installer.js +7 -0
- package/dist/service-installer.js.map +1 -1
- package/dist/watch.js +500 -483
- package/package.json +1 -1
- package/skills/chat-recall/SKILL.md +6 -1
- package/skills/chat-recall-sessions/SKILL.md +155 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/** Which hooks to install. Every one is on unless the user turned it off. */
|
|
2
|
+
export interface HookSelection {
|
|
3
|
+
save: boolean;
|
|
4
|
+
resume: boolean;
|
|
5
|
+
escalate: boolean;
|
|
6
|
+
wakeup: boolean;
|
|
7
|
+
guard: boolean;
|
|
8
|
+
taskBoard: boolean;
|
|
9
|
+
messages: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const ALL_HOOKS: HookSelection;
|
|
12
|
+
/** The shell scripts, by the selection key that installs each one. */
|
|
13
|
+
declare const SCRIPTS: {
|
|
14
|
+
readonly save: "chat_recall_save_hook.sh";
|
|
15
|
+
readonly resume: "chat_recall_resume_hook.sh";
|
|
16
|
+
readonly escalate: "chat_recall_escalate_hook.sh";
|
|
17
|
+
readonly wakeup: "chat_recall_wakeup_hook.sh";
|
|
18
|
+
readonly guard: "chat_recall_guard_hook.sh";
|
|
19
|
+
};
|
|
20
|
+
type ScriptKey = keyof typeof SCRIPTS;
|
|
21
|
+
/** Every event an entry of ours can sit on. Uninstall and reinstall walk all of them. */
|
|
22
|
+
export declare const HOOK_EVENTS: string[];
|
|
23
|
+
type Entry = {
|
|
24
|
+
matcher: string;
|
|
25
|
+
hooks: Array<Record<string, unknown>>;
|
|
26
|
+
};
|
|
27
|
+
type Config = {
|
|
28
|
+
hooks?: Record<string, unknown[]>;
|
|
29
|
+
[k: string]: unknown;
|
|
30
|
+
};
|
|
31
|
+
/** True for every hook entry chat-recall writes, in any version. */
|
|
32
|
+
export declare function isOurEntry(entry: unknown): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Every Claude profile's `settings.json`, deduped by real path.
|
|
35
|
+
*
|
|
36
|
+
* `CLAUDE_CONFIG_DIR=~/.claude-work` makes that directory the whole config root
|
|
37
|
+
* for a session, so each profile needs its own registration. Only profiles that
|
|
38
|
+
* are real installs (they have `projects/`) are returned.
|
|
39
|
+
*/
|
|
40
|
+
export declare function claudeSettingsFiles(): string[];
|
|
41
|
+
/** The `[event, entry]` pairs for a selection. */
|
|
42
|
+
export declare function hookEntries(sel: HookSelection, paths: {
|
|
43
|
+
scripts: Partial<Record<ScriptKey, string>>;
|
|
44
|
+
execPath: string;
|
|
45
|
+
cliEntry: string;
|
|
46
|
+
messageHookEntry: string;
|
|
47
|
+
}): Array<[string, Entry]>;
|
|
48
|
+
/** Replace our entries in one parsed settings object; entries of other tools stay. */
|
|
49
|
+
export declare function mergeOurEntries(config: Config, entries: Array<[string, Entry]>): void;
|
|
50
|
+
/** Remove our entries from one parsed config; returns how many. */
|
|
51
|
+
export declare function removeOurEntries(config: Config): number;
|
|
52
|
+
export interface InstallReport {
|
|
53
|
+
/** settings.json files written. */
|
|
54
|
+
written: string[];
|
|
55
|
+
/** settings.json files left alone because they do not parse. */
|
|
56
|
+
skipped: string[];
|
|
57
|
+
/** Old entries removed from hooks.json files. */
|
|
58
|
+
migrated: number;
|
|
59
|
+
/** Shell hooks left out because this platform cannot run them. */
|
|
60
|
+
shellSkipped: boolean;
|
|
61
|
+
scriptsDir: string;
|
|
62
|
+
selection: HookSelection;
|
|
63
|
+
guardTargets: Array<{
|
|
64
|
+
label: string;
|
|
65
|
+
configPath: string;
|
|
66
|
+
note?: string;
|
|
67
|
+
}>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Install the selected hooks in every profile. Idempotent: a second run
|
|
71
|
+
* replaces our entries and adds no duplicate.
|
|
72
|
+
*
|
|
73
|
+
* On Windows the five shell hooks are left out: Claude Code runs a hook
|
|
74
|
+
* command through cmd.exe, which cannot run a `.sh`. The board and message
|
|
75
|
+
* hooks are node plus a bundle path, and install everywhere.
|
|
76
|
+
*/
|
|
77
|
+
export declare function installHooks(distDir: string, sel?: HookSelection): Promise<InstallReport>;
|
|
78
|
+
export interface UninstallReport {
|
|
79
|
+
removed: number;
|
|
80
|
+
files: string[];
|
|
81
|
+
guardRemoved: Array<{
|
|
82
|
+
label: string;
|
|
83
|
+
configPath: string;
|
|
84
|
+
}>;
|
|
85
|
+
}
|
|
86
|
+
/** Remove every chat-recall hook, and record the choice so the MCP server does not put them back. */
|
|
87
|
+
export declare function uninstallHooks(): Promise<UninstallReport>;
|
|
88
|
+
/**
|
|
89
|
+
* Install the hooks when this version has not installed them, or when a
|
|
90
|
+
* profile is missing them. The MCP server calls this at every start.
|
|
91
|
+
* Returns null when nothing was needed, or when the user uninstalled them.
|
|
92
|
+
*/
|
|
93
|
+
export declare function ensureHooks(distDir: string): Promise<InstallReport | null>;
|
|
94
|
+
export {};
|
|
95
|
+
//# sourceMappingURL=install-hooks.d.ts.map
|
|
@@ -0,0 +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CAAC,CAOhF"}
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Install the chat-recall hooks into every Claude profile, and the decision
|
|
3
|
+
* guard into the other AI tools.
|
|
4
|
+
*
|
|
5
|
+
* Claude Code reads hooks from `settings.json`. This module wrote them to
|
|
6
|
+
* `<profile>/hooks.json`, which Claude Code does not read outside a plugin, so
|
|
7
|
+
* no hook it registered ever ran: the save hook creates
|
|
8
|
+
* `~/.claude/chat-recall-memory` on every Stop, and that directory did not
|
|
9
|
+
* exist on a machine where the Stop hook had been registered for months.
|
|
10
|
+
* Registration is in `settings.json` now, and our entries are removed from
|
|
11
|
+
* `hooks.json`.
|
|
12
|
+
*
|
|
13
|
+
* Three callers: `init` (every user runs it), `install-hooks` (the explicit
|
|
14
|
+
* command and its opt-outs), and the MCP server at start, which repairs a
|
|
15
|
+
* profile that is missing hooks. The last one is what reaches a user who added
|
|
16
|
+
* only the MCP server, from a marketplace button or a hand-written config.
|
|
17
|
+
* `install-hooks --uninstall` records the choice, and the MCP server then
|
|
18
|
+
* leaves the hooks out.
|
|
19
|
+
*/
|
|
20
|
+
import { chmodSync, copyFileSync, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
21
|
+
import { dirname, join } from 'node:path';
|
|
22
|
+
import { getHooksDir } from '@chat-recall/engine/core/paths.js';
|
|
23
|
+
import { claudeBackend } from '@chat-recall/engine/core/backends/claude.js';
|
|
24
|
+
import { claudeHomeDirs } from '@chat-recall/engine/core/tool-paths.js';
|
|
25
|
+
import { boardHookEntries, isBoardHookEntry, messageHookEntries, isMessageHookEntry, isMessageWaiterEntry, resolveCliEntry, resolveMessageHookEntry, } from './board-hooks.js';
|
|
26
|
+
import { cliVersion } from './http.js';
|
|
27
|
+
export const ALL_HOOKS = {
|
|
28
|
+
save: true, resume: true, escalate: true, wakeup: true, guard: true, taskBoard: true, messages: true,
|
|
29
|
+
};
|
|
30
|
+
/** The shell scripts, by the selection key that installs each one. */
|
|
31
|
+
const SCRIPTS = {
|
|
32
|
+
save: 'chat_recall_save_hook.sh',
|
|
33
|
+
resume: 'chat_recall_resume_hook.sh',
|
|
34
|
+
escalate: 'chat_recall_escalate_hook.sh',
|
|
35
|
+
wakeup: 'chat_recall_wakeup_hook.sh',
|
|
36
|
+
guard: 'chat_recall_guard_hook.sh',
|
|
37
|
+
};
|
|
38
|
+
/** Every event an entry of ours can sit on. Uninstall and reinstall walk all of them. */
|
|
39
|
+
export const HOOK_EVENTS = ['Stop', 'PreCompact', 'UserPromptSubmit', 'SessionEnd', 'SessionStart', 'PreToolUse', 'PostToolUse'];
|
|
40
|
+
/** True for every hook entry chat-recall writes, in any version. */
|
|
41
|
+
export function isOurEntry(entry) {
|
|
42
|
+
const cmd = entry?.hooks?.[0]?.command;
|
|
43
|
+
if (typeof cmd !== 'string')
|
|
44
|
+
return false;
|
|
45
|
+
return Object.values(SCRIPTS).some((s) => cmd.includes(s)) || isBoardHookEntry(entry) || isMessageHookEntry(entry);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Every Claude profile's `settings.json`, deduped by real path.
|
|
49
|
+
*
|
|
50
|
+
* `CLAUDE_CONFIG_DIR=~/.claude-work` makes that directory the whole config root
|
|
51
|
+
* for a session, so each profile needs its own registration. Only profiles that
|
|
52
|
+
* are real installs (they have `projects/`) are returned.
|
|
53
|
+
*/
|
|
54
|
+
export function claudeSettingsFiles() {
|
|
55
|
+
const out = [];
|
|
56
|
+
const seen = new Set();
|
|
57
|
+
for (const home of claudeHomeDirs()) {
|
|
58
|
+
if (!existsSync(join(home, 'projects')))
|
|
59
|
+
continue;
|
|
60
|
+
// Keyed by the file, so profiles that share one settings.json through a
|
|
61
|
+
// symlink are written once.
|
|
62
|
+
const file = join(home, 'settings.json');
|
|
63
|
+
let key;
|
|
64
|
+
try {
|
|
65
|
+
key = realpathSync(file);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
key = file;
|
|
69
|
+
}
|
|
70
|
+
if (seen.has(key))
|
|
71
|
+
continue;
|
|
72
|
+
seen.add(key);
|
|
73
|
+
out.push(file);
|
|
74
|
+
}
|
|
75
|
+
if (out.length === 0)
|
|
76
|
+
out.push(claudeBackend.settingsFile());
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
/** Find a bundled hook script: the package's hooks/ in a release, the repo's in a checkout. */
|
|
80
|
+
function findScript(distDir, name) {
|
|
81
|
+
return [
|
|
82
|
+
join(distDir, '..', 'hooks', name),
|
|
83
|
+
join(distDir, '..', '..', 'hooks', name),
|
|
84
|
+
join(distDir, '..', '..', '..', 'hooks', name),
|
|
85
|
+
].find((p) => existsSync(p));
|
|
86
|
+
}
|
|
87
|
+
/** The `[event, entry]` pairs for a selection. */
|
|
88
|
+
export function hookEntries(sel, paths) {
|
|
89
|
+
const cmd = (command, extra = {}) => [{ type: 'command', command, ...extra }];
|
|
90
|
+
const q = (p) => `"${p}"`;
|
|
91
|
+
const out = [];
|
|
92
|
+
const s = paths.scripts;
|
|
93
|
+
if (sel.save && s.save) {
|
|
94
|
+
out.push(['Stop', { matcher: '', hooks: cmd(q(s.save)) }]);
|
|
95
|
+
out.push(['PreCompact', { matcher: '', hooks: cmd(`${q(s.save)} --precompact`) }]);
|
|
96
|
+
}
|
|
97
|
+
if (sel.resume && s.resume)
|
|
98
|
+
out.push(['UserPromptSubmit', { matcher: '', hooks: cmd(q(s.resume)) }]);
|
|
99
|
+
// The escalation detaches its own background work, so session end is never delayed.
|
|
100
|
+
if (sel.escalate && s.escalate)
|
|
101
|
+
out.push(['SessionEnd', { matcher: '', hooks: cmd(q(s.escalate)) }]);
|
|
102
|
+
// `startup|clear` only: a resumed session already carries its context.
|
|
103
|
+
if (sel.wakeup && s.wakeup)
|
|
104
|
+
out.push(['SessionStart', { matcher: 'startup|clear', hooks: cmd(q(s.wakeup)) }]);
|
|
105
|
+
// Only the tools that can introduce a dependency; matching everything would
|
|
106
|
+
// start a process on every Read for a check that can never fire.
|
|
107
|
+
if (sel.guard && s.guard)
|
|
108
|
+
out.push(['PreToolUse', { matcher: 'Bash|Edit|Write|MultiEdit|NotebookEdit', hooks: cmd(q(s.guard)) }]);
|
|
109
|
+
if (sel.taskBoard)
|
|
110
|
+
out.push(...boardHookEntries(paths.execPath, paths.cliEntry));
|
|
111
|
+
if (sel.messages)
|
|
112
|
+
out.push(...messageHookEntries(paths.execPath, paths.messageHookEntry));
|
|
113
|
+
return out;
|
|
114
|
+
}
|
|
115
|
+
/** Replace our entries in one parsed settings object; entries of other tools stay. */
|
|
116
|
+
export function mergeOurEntries(config, entries) {
|
|
117
|
+
if (!config.hooks || typeof config.hooks !== 'object')
|
|
118
|
+
config.hooks = {};
|
|
119
|
+
const hooks = config.hooks;
|
|
120
|
+
for (const event of HOOK_EVENTS) {
|
|
121
|
+
const kept = (Array.isArray(hooks[event]) ? hooks[event] : []).filter((h) => !isOurEntry(h));
|
|
122
|
+
for (const [ev, entry] of entries)
|
|
123
|
+
if (ev === event)
|
|
124
|
+
kept.push(entry);
|
|
125
|
+
if (kept.length)
|
|
126
|
+
hooks[event] = kept;
|
|
127
|
+
else
|
|
128
|
+
delete hooks[event];
|
|
129
|
+
}
|
|
130
|
+
if (!Object.keys(hooks).length)
|
|
131
|
+
delete config.hooks;
|
|
132
|
+
}
|
|
133
|
+
/** Remove our entries from one parsed config; returns how many. */
|
|
134
|
+
export function removeOurEntries(config) {
|
|
135
|
+
if (!config.hooks || typeof config.hooks !== 'object')
|
|
136
|
+
return 0;
|
|
137
|
+
let removed = 0;
|
|
138
|
+
for (const event of Object.keys(config.hooks)) {
|
|
139
|
+
const current = Array.isArray(config.hooks[event]) ? config.hooks[event] : [];
|
|
140
|
+
const kept = current.filter((h) => !isOurEntry(h));
|
|
141
|
+
removed += current.length - kept.length;
|
|
142
|
+
if (kept.length)
|
|
143
|
+
config.hooks[event] = kept;
|
|
144
|
+
else
|
|
145
|
+
delete config.hooks[event];
|
|
146
|
+
}
|
|
147
|
+
if (!Object.keys(config.hooks).length)
|
|
148
|
+
delete config.hooks;
|
|
149
|
+
return removed;
|
|
150
|
+
}
|
|
151
|
+
/** Read a JSON config. Absent → {}; unparseable → null, and the caller leaves the file alone. */
|
|
152
|
+
function readJson(file) {
|
|
153
|
+
if (!existsSync(file))
|
|
154
|
+
return {};
|
|
155
|
+
try {
|
|
156
|
+
const v = JSON.parse(readFileSync(file, 'utf-8'));
|
|
157
|
+
return v && typeof v === 'object' && !Array.isArray(v) ? v : null;
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Write through a temp file and a rename. Claude Code watches settings.json
|
|
165
|
+
* and reloads it while a session runs, so it must never read a half-written file.
|
|
166
|
+
* The rename goes to the symlink's target: renaming onto the link itself would
|
|
167
|
+
* replace a shared settings.json with a copy that stops being shared.
|
|
168
|
+
*/
|
|
169
|
+
function writeJsonAtomic(file, value) {
|
|
170
|
+
let target = file;
|
|
171
|
+
try {
|
|
172
|
+
target = realpathSync(file);
|
|
173
|
+
}
|
|
174
|
+
catch { /* a new file */ }
|
|
175
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
176
|
+
const tmp = `${target}.chat-recall-${process.pid}.tmp`;
|
|
177
|
+
writeFileSync(tmp, JSON.stringify(value, null, 2) + '\n');
|
|
178
|
+
renameSync(tmp, target);
|
|
179
|
+
}
|
|
180
|
+
function statePath() { return join(getHooksDir(), 'install.json'); }
|
|
181
|
+
function readState() {
|
|
182
|
+
try {
|
|
183
|
+
return JSON.parse(readFileSync(statePath(), 'utf-8'));
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Install the selected hooks in every profile. Idempotent: a second run
|
|
191
|
+
* replaces our entries and adds no duplicate.
|
|
192
|
+
*
|
|
193
|
+
* On Windows the five shell hooks are left out: Claude Code runs a hook
|
|
194
|
+
* command through cmd.exe, which cannot run a `.sh`. The board and message
|
|
195
|
+
* hooks are node plus a bundle path, and install everywhere.
|
|
196
|
+
*/
|
|
197
|
+
export async function installHooks(distDir, sel = ALL_HOOKS) {
|
|
198
|
+
const shellSkipped = process.platform === 'win32';
|
|
199
|
+
const scriptsDir = getHooksDir();
|
|
200
|
+
const scripts = {};
|
|
201
|
+
if (!shellSkipped) {
|
|
202
|
+
for (const key of Object.keys(SCRIPTS)) {
|
|
203
|
+
if (!sel[key])
|
|
204
|
+
continue;
|
|
205
|
+
const source = findScript(distDir, SCRIPTS[key]);
|
|
206
|
+
if (!source)
|
|
207
|
+
continue;
|
|
208
|
+
const target = join(scriptsDir, SCRIPTS[key]);
|
|
209
|
+
copyFileSync(source, target);
|
|
210
|
+
chmodSync(target, 0o755);
|
|
211
|
+
scripts[key] = target;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const entries = hookEntries(sel, {
|
|
215
|
+
scripts, execPath: process.execPath,
|
|
216
|
+
cliEntry: resolveCliEntry(distDir), messageHookEntry: resolveMessageHookEntry(distDir),
|
|
217
|
+
});
|
|
218
|
+
const report = { written: [], skipped: [], migrated: 0, shellSkipped, scriptsDir, selection: sel, guardTargets: [] };
|
|
219
|
+
for (const settingsFile of claudeSettingsFiles()) {
|
|
220
|
+
const config = readJson(settingsFile);
|
|
221
|
+
if (!config) {
|
|
222
|
+
report.skipped.push(settingsFile);
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
mergeOurEntries(config, entries);
|
|
226
|
+
writeJsonAtomic(settingsFile, config);
|
|
227
|
+
report.written.push(settingsFile);
|
|
228
|
+
report.migrated += migrateHooksJson(join(dirname(settingsFile), 'hooks.json'));
|
|
229
|
+
}
|
|
230
|
+
if (sel.guard && scripts.guard)
|
|
231
|
+
report.guardTargets = await addGuardToOtherTools(scriptsDir, scripts.guard);
|
|
232
|
+
writeJsonAtomic(statePath(), { version: cliVersion(), selection: sel });
|
|
233
|
+
return report;
|
|
234
|
+
}
|
|
235
|
+
/** Remove our entries from a profile's hooks.json, where earlier versions put them. */
|
|
236
|
+
function migrateHooksJson(file) {
|
|
237
|
+
if (!existsSync(file))
|
|
238
|
+
return 0;
|
|
239
|
+
const config = readJson(file);
|
|
240
|
+
if (!config)
|
|
241
|
+
return 0;
|
|
242
|
+
const removed = removeOurEntries(config);
|
|
243
|
+
if (removed === 0)
|
|
244
|
+
return 0;
|
|
245
|
+
// A hooks.json that held only our entries is removed, not left as `{}`.
|
|
246
|
+
if (!Object.keys(config).length)
|
|
247
|
+
unlinkSync(file);
|
|
248
|
+
else
|
|
249
|
+
writeJsonAtomic(file, config);
|
|
250
|
+
return removed;
|
|
251
|
+
}
|
|
252
|
+
/** Remove every chat-recall hook, and record the choice so the MCP server does not put them back. */
|
|
253
|
+
export async function uninstallHooks() {
|
|
254
|
+
const report = { removed: 0, files: [], guardRemoved: [] };
|
|
255
|
+
for (const settingsFile of claudeSettingsFiles()) {
|
|
256
|
+
for (const file of [settingsFile, join(dirname(settingsFile), 'hooks.json')]) {
|
|
257
|
+
if (!existsSync(file))
|
|
258
|
+
continue;
|
|
259
|
+
const config = readJson(file);
|
|
260
|
+
if (!config)
|
|
261
|
+
continue;
|
|
262
|
+
const removed = removeOurEntries(config);
|
|
263
|
+
if (!removed)
|
|
264
|
+
continue;
|
|
265
|
+
writeJsonAtomic(file, config);
|
|
266
|
+
report.removed += removed;
|
|
267
|
+
report.files.push(file);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
report.guardRemoved = await removeGuardFromOtherTools();
|
|
271
|
+
writeJsonAtomic(statePath(), { version: cliVersion(), selection: ALL_HOOKS, uninstalled: true });
|
|
272
|
+
return report;
|
|
273
|
+
}
|
|
274
|
+
/** The selection a profile is missing, judged by the message hook on SessionStart and PostToolUse. */
|
|
275
|
+
function profileMissingHooks(settingsFile, sel) {
|
|
276
|
+
const config = readJson(settingsFile);
|
|
277
|
+
if (!config)
|
|
278
|
+
return false; // unparseable: not ours to repair
|
|
279
|
+
const has = (event, test) => (Array.isArray(config.hooks?.[event]) ? config.hooks[event] : []).some(test);
|
|
280
|
+
if (sel.messages && !(has('Stop', isMessageWaiterEntry) && has('SessionStart', isMessageHookEntry)))
|
|
281
|
+
return true;
|
|
282
|
+
if (sel.taskBoard && !has('UserPromptSubmit', isBoardHookEntry))
|
|
283
|
+
return true;
|
|
284
|
+
if (process.platform !== 'win32' && sel.save && !has('Stop', (e) => isOurEntry(e) && !isMessageHookEntry(e)))
|
|
285
|
+
return true;
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Install the hooks when this version has not installed them, or when a
|
|
290
|
+
* profile is missing them. The MCP server calls this at every start.
|
|
291
|
+
* Returns null when nothing was needed, or when the user uninstalled them.
|
|
292
|
+
*/
|
|
293
|
+
export async function ensureHooks(distDir) {
|
|
294
|
+
const state = readState();
|
|
295
|
+
if (state?.uninstalled)
|
|
296
|
+
return null;
|
|
297
|
+
const sel = { ...ALL_HOOKS, ...(state?.selection ?? {}) };
|
|
298
|
+
const stale = !state || state.version !== cliVersion();
|
|
299
|
+
if (!stale && !claudeSettingsFiles().some((f) => profileMissingHooks(f, sel)))
|
|
300
|
+
return null;
|
|
301
|
+
return installHooks(distDir, sel);
|
|
302
|
+
}
|
|
303
|
+
// ── The decision guard in the AI tools that are not Claude Code ──────────────
|
|
304
|
+
//
|
|
305
|
+
// `chat-recall guard` speaks all five harnesses; each of the other four keeps
|
|
306
|
+
// its pre-execution hook in its own file, in its own shape. A tool whose home
|
|
307
|
+
// directory is absent is skipped, so installing never leaves config behind for
|
|
308
|
+
// a tool nobody has.
|
|
309
|
+
async function addGuardToOtherTools(scriptsDir, guardScript) {
|
|
310
|
+
const reg = await import('@chat-recall/engine/core/guard-registration.js');
|
|
311
|
+
const out = [];
|
|
312
|
+
for (const target of reg.guardTargets()) {
|
|
313
|
+
if (!existsSync(target.homeDir))
|
|
314
|
+
continue;
|
|
315
|
+
const wrapper = join(scriptsDir, reg.guardWrapperName(target.tool));
|
|
316
|
+
writeFileSync(wrapper, reg.guardWrapperSource(target.tool, guardScript));
|
|
317
|
+
chmodSync(wrapper, 0o755);
|
|
318
|
+
mkdirSync(dirname(target.configPath), { recursive: true });
|
|
319
|
+
if (target.tool === 'opencode') {
|
|
320
|
+
writeFileSync(target.configPath, reg.opencodePluginSource(wrapper));
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
const merged = reg.registerGuard(target.tool, readJson(target.configPath) ?? {}, reg.guardCommand(wrapper));
|
|
324
|
+
writeJsonAtomic(target.configPath, merged);
|
|
325
|
+
}
|
|
326
|
+
out.push({ label: target.label, configPath: target.configPath, note: target.note });
|
|
327
|
+
}
|
|
328
|
+
return out;
|
|
329
|
+
}
|
|
330
|
+
async function removeGuardFromOtherTools() {
|
|
331
|
+
const reg = await import('@chat-recall/engine/core/guard-registration.js');
|
|
332
|
+
const out = [];
|
|
333
|
+
for (const target of reg.guardTargets()) {
|
|
334
|
+
if (!existsSync(target.configPath))
|
|
335
|
+
continue;
|
|
336
|
+
if (target.tool === 'opencode') {
|
|
337
|
+
// Only ours: install writes this marker on the first line.
|
|
338
|
+
if (!readFileSync(target.configPath, 'utf-8').includes('chat-recall install-hooks'))
|
|
339
|
+
continue;
|
|
340
|
+
unlinkSync(target.configPath);
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
const r = reg.unregisterGuard(target.tool, readJson(target.configPath) ?? {});
|
|
344
|
+
if (r.removed === 0)
|
|
345
|
+
continue;
|
|
346
|
+
writeJsonAtomic(target.configPath, r.config);
|
|
347
|
+
}
|
|
348
|
+
out.push({ label: target.label, configPath: target.configPath });
|
|
349
|
+
}
|
|
350
|
+
return out;
|
|
351
|
+
}
|
|
352
|
+
//# sourceMappingURL=install-hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-hooks.js","sourceRoot":"","sources":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7C,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC/B,2DAA2D;YAC3D,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,2BAA2B,CAAC;gBAAE,SAAS;YAC9F,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;YAC9E,IAAI,CAAC,CAAC,OAAO,KAAK,CAAC;gBAAE,SAAS;YAC9B,eAAe,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;QAC/C,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/mcp-relay.js
CHANGED
|
@@ -299,7 +299,7 @@ function resilientBridge(input, output, first, reconnect, exit, opts = {}) {
|
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
// src/mcp-relay.ts
|
|
302
|
-
var VERSION = true ? "0.7.
|
|
302
|
+
var VERSION = true ? "0.7.21" : "0.0.0";
|
|
303
303
|
var SERVER_URL = new URL("./mcp.js", import.meta.url);
|
|
304
304
|
var SERVER_PATH = fileURLToPath(SERVER_URL);
|
|
305
305
|
var START_TIMEOUT_MS = 15e3;
|