fathom-mcp 0.1.1 → 0.1.2
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/package.json +1 -1
- package/src/cli.js +0 -16
- package/scripts/fathom-context.sh +0 -65
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -166,7 +166,6 @@ async function runInit() {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
// 5. Hooks
|
|
169
|
-
const enableContextHook = await askYesNo(rl, " Enable SessionStart context injection hook?", true);
|
|
170
169
|
const enablePrecompactHook = await askYesNo(rl, " Enable PreCompact vault snapshot hook?", true);
|
|
171
170
|
|
|
172
171
|
rl.close();
|
|
@@ -182,7 +181,6 @@ async function runInit() {
|
|
|
182
181
|
server: serverUrl,
|
|
183
182
|
apiKey,
|
|
184
183
|
hooks: {
|
|
185
|
-
"context-inject": { enabled: enableContextHook },
|
|
186
184
|
"precompact-snapshot": { enabled: enablePrecompactHook },
|
|
187
185
|
},
|
|
188
186
|
};
|
|
@@ -226,20 +224,6 @@ async function runInit() {
|
|
|
226
224
|
// Claude Code hooks use matcher + hooks array format:
|
|
227
225
|
// { hooks: [{ type: "command", command: "...", timeout: N }] }
|
|
228
226
|
const hooks = {};
|
|
229
|
-
if (enableContextHook) {
|
|
230
|
-
hooks["UserPromptSubmit"] = [
|
|
231
|
-
...(claudeSettings.hooks?.["UserPromptSubmit"] || []),
|
|
232
|
-
];
|
|
233
|
-
const contextCmd = "bash .fathom/scripts/fathom-context.sh";
|
|
234
|
-
const hasFathomContext = hooks["UserPromptSubmit"].some((entry) =>
|
|
235
|
-
entry.hooks?.some((h) => h.command === contextCmd)
|
|
236
|
-
);
|
|
237
|
-
if (!hasFathomContext) {
|
|
238
|
-
hooks["UserPromptSubmit"].push({
|
|
239
|
-
hooks: [{ type: "command", command: contextCmd, timeout: 10000 }],
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
227
|
if (enablePrecompactHook) {
|
|
244
228
|
hooks["PreCompact"] = [
|
|
245
229
|
...(claudeSettings.hooks?.["PreCompact"] || []),
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Fathom SessionStart/UserPromptSubmit hook — injects vault context.
|
|
3
|
-
#
|
|
4
|
-
# Reads .fathom.json to find vault path and server URL.
|
|
5
|
-
# On SessionStart: injects recent heartbeat + active vault folders.
|
|
6
|
-
# On UserPromptSubmit: searches vault for relevant context.
|
|
7
|
-
|
|
8
|
-
set -euo pipefail
|
|
9
|
-
|
|
10
|
-
# Walk up to find .fathom.json
|
|
11
|
-
find_config() {
|
|
12
|
-
local dir="$PWD"
|
|
13
|
-
while [ "$dir" != "/" ]; do
|
|
14
|
-
if [ -f "$dir/.fathom.json" ]; then
|
|
15
|
-
echo "$dir/.fathom.json"
|
|
16
|
-
return 0
|
|
17
|
-
fi
|
|
18
|
-
dir="$(dirname "$dir")"
|
|
19
|
-
done
|
|
20
|
-
return 1
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
CONFIG_FILE=$(find_config 2>/dev/null) || exit 0
|
|
24
|
-
|
|
25
|
-
# Extract config values
|
|
26
|
-
WORKSPACE=$(python3 -c "import json; print(json.load(open('$CONFIG_FILE')).get('workspace',''))" 2>/dev/null || echo "")
|
|
27
|
-
SERVER=$(python3 -c "import json; print(json.load(open('$CONFIG_FILE')).get('server','http://localhost:4243'))" 2>/dev/null || echo "http://localhost:4243")
|
|
28
|
-
API_KEY=$(python3 -c "import json; print(json.load(open('$CONFIG_FILE')).get('apiKey',''))" 2>/dev/null || echo "")
|
|
29
|
-
HOOK_ENABLED=$(python3 -c "import json; c=json.load(open('$CONFIG_FILE')); print(c.get('hooks',{}).get('context-inject',{}).get('enabled','true'))" 2>/dev/null || echo "true")
|
|
30
|
-
|
|
31
|
-
if [ "$HOOK_ENABLED" != "True" ] && [ "$HOOK_ENABLED" != "true" ]; then
|
|
32
|
-
exit 0
|
|
33
|
-
fi
|
|
34
|
-
|
|
35
|
-
# Read user prompt from stdin (if UserPromptSubmit)
|
|
36
|
-
INPUT=$(cat)
|
|
37
|
-
|
|
38
|
-
# Build auth header
|
|
39
|
-
AUTH_HEADER=""
|
|
40
|
-
if [ -n "$API_KEY" ]; then
|
|
41
|
-
AUTH_HEADER="Authorization: Bearer $API_KEY"
|
|
42
|
-
fi
|
|
43
|
-
|
|
44
|
-
# Try to get recent vault activity from server
|
|
45
|
-
CONTEXT=""
|
|
46
|
-
if [ -n "$SERVER" ]; then
|
|
47
|
-
ACTIVITY=$(curl -sf -H "$AUTH_HEADER" \
|
|
48
|
-
"${SERVER}/api/vault/activity?workspace=${WORKSPACE}&limit=5" 2>/dev/null || echo "")
|
|
49
|
-
if [ -n "$ACTIVITY" ]; then
|
|
50
|
-
CONTEXT="Recent vault activity:\n$ACTIVITY"
|
|
51
|
-
fi
|
|
52
|
-
fi
|
|
53
|
-
|
|
54
|
-
if [ -n "$CONTEXT" ]; then
|
|
55
|
-
# Output as hook response
|
|
56
|
-
python3 -c "
|
|
57
|
-
import json, sys
|
|
58
|
-
result = {
|
|
59
|
-
'hookSpecificOutput': {
|
|
60
|
-
'additionalContext': '''$CONTEXT'''
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
json.dump(result, sys.stdout)
|
|
64
|
-
"
|
|
65
|
-
fi
|