@skedulo/memory-hub-mcp 0.1.0 → 0.1.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 +47 -8
- package/assets/SKILL.md +13 -0
- package/assets/session-start.sh +266 -0
- package/assets/session-stop.sh +58 -0
- package/dist/cli.js +26 -0
- package/dist/index.js +21 -4
- package/dist/setup.js +292 -0
- package/package.json +8 -5
- package/skill-guide.md +303 -0
package/README.md
CHANGED
|
@@ -55,31 +55,70 @@ have no equivalent there. Two consequences, both permanent until Desktop grows h
|
|
|
55
55
|
`session-stop.sh` shells out to `claude -p --resume`, which is CLI-only. Anything worth
|
|
56
56
|
keeping must be saved with `memory_save` before the conversation ends.
|
|
57
57
|
|
|
58
|
+
### Install and set up
|
|
59
|
+
|
|
60
|
+
Two commands, no config file to edit. No GitHub access, no git clone, no build step, no npm
|
|
61
|
+
account:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
npm install -g @skedulo/memory-hub-mcp
|
|
65
|
+
memory-hub-mcp setup
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`setup` asks which host you use — Claude Code, Claude Desktop, or both (`--code` / `--desktop` /
|
|
69
|
+
`--both` skip the prompt) — then logs you in with the same browser OAuth `sked` itself uses and
|
|
70
|
+
mints a personal token from that session. For **Claude Code** it does everything
|
|
71
|
+
`scripts/setup-dev.sh` does for contributors: registers the MCP server in `~/.claude.json`, puts
|
|
72
|
+
the token in `~/.claude/settings.json`, installs the `SessionStart` hook into
|
|
73
|
+
`~/.claude/memory-hub-hook/` and registers it (appending, never stacking duplicates), and syncs
|
|
74
|
+
`SKILL.md` into `~/.claude/skills/se-ai-memory-hub/`. For **Claude Desktop** it writes
|
|
75
|
+
`claude_desktop_config.json` — no hook, because Desktop has none. Every file is merged, never
|
|
76
|
+
clobbered, and a `.bak` is left behind. Then it makes one real call to confirm the token works
|
|
77
|
+
before it says done.
|
|
78
|
+
|
|
79
|
+
If `sked` isn't installed it falls back to pasting a token you generated at Pulse Web → Settings →
|
|
80
|
+
Developer tools → API tokens. It never mints a token you didn't ask for.
|
|
81
|
+
|
|
82
|
+
Then restart Claude Code, or quit Claude Desktop completely and reopen it.
|
|
83
|
+
|
|
84
|
+
Installing the package is not the same as having access: every call is authorised by your personal
|
|
85
|
+
Skedulo API token, and the package is useless without one.
|
|
86
|
+
|
|
87
|
+
Re-run `memory-hub-mcp setup` anytime — it keeps a token that's already configured.
|
|
88
|
+
|
|
89
|
+
<details>
|
|
90
|
+
<summary>Configuring by hand instead</summary>
|
|
91
|
+
|
|
58
92
|
Add to `claude_desktop_config.json` (Settings → Developer → Edit Config):
|
|
59
93
|
|
|
60
94
|
```json
|
|
61
95
|
{
|
|
62
96
|
"mcpServers": {
|
|
63
97
|
"memory-hub": {
|
|
64
|
-
"command": "/absolute/path/to/
|
|
65
|
-
"args": ["/absolute/path/to/se-ai-memory-hub/memory-hub-mcp/dist/index.js"],
|
|
98
|
+
"command": "/absolute/path/to/memory-hub-mcp",
|
|
66
99
|
"env": { "MEMORY_HUB_MCP_TOKEN": "<your personal token>" }
|
|
67
100
|
}
|
|
68
101
|
}
|
|
69
102
|
}
|
|
70
103
|
```
|
|
71
104
|
|
|
72
|
-
|
|
73
|
-
source your shell profile, so a bare
|
|
74
|
-
|
|
75
|
-
|
|
105
|
+
The path must be absolute — `which memory-hub-mcp`. Desktop launches the server with a minimal
|
|
106
|
+
`PATH` and does not source your shell profile, so a bare command name fails under nvm or Homebrew.
|
|
107
|
+
For the same reason the token has to live in the `env` block; Desktop won't inherit it from your
|
|
108
|
+
shell.
|
|
109
|
+
|
|
110
|
+
</details>
|
|
111
|
+
|
|
112
|
+
Working on this repo instead of just using it? Follow [Setup](#setup) above and point the config
|
|
113
|
+
at `dist/cli.js`; the npm package is for consumers.
|
|
76
114
|
|
|
77
115
|
Desktop starts the server with no project directory, so repo detection returns nothing:
|
|
78
116
|
`memory_sessionContext` comes back with `repoScoped: false` and no repo-scoped facts, wiki or
|
|
79
117
|
skills, and `memory_save` defaults to **Private** visibility. That is a supported shape, not a
|
|
80
118
|
degraded one — it is the right default for work that isn't tied to a Skedulo repo (estimation,
|
|
81
|
-
design, discovery). `
|
|
82
|
-
|
|
119
|
+
design, discovery). `memory_checkRepoStatus` will not work from Desktop. `memory_linkRepoTeam`
|
|
120
|
+
does, but only if you name the repo — pass `repoName` explicitly, since there is nothing to
|
|
121
|
+
detect; `memory_listTeams` shows the team names to link it to.
|
|
83
122
|
|
|
84
123
|
## Tags
|
|
85
124
|
|
package/assets/SKILL.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: se-ai-memory-hub
|
|
3
|
+
description: Use when working in a repo where the memory-hub MCP tools (memory_recall, memory_save, memory_upsertPersona, memory_setVisibility, memory_bulkPromoteRepoScoped, memory_grantAccess, memory_checkRepoStatus, memory_linkRepoTeam, memory_moveResourceRepo, memory_listRepos, memory_getSkillGuide) are available, to recall prior context mid-session, save durable facts/skills/scenarios, update your persona, and share items with your team on explicit request
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SE AI Memory Hub
|
|
7
|
+
|
|
8
|
+
Call `memory_getSkillGuide` now — it returns the current, full usage guide
|
|
9
|
+
(when to recall, what to save where, sharing rules, repo linking). That
|
|
10
|
+
guide is served live from `memory-hub-mcp`, not copied here, so it can't go
|
|
11
|
+
stale on this machine the way this stub's own content once did. This file
|
|
12
|
+
stays intentionally thin: only what the harness needs to discover and
|
|
13
|
+
trigger the skill.
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# SessionStart hook: recalls this developer's + their team's memory-hub facts and
|
|
3
|
+
# skills, and injects them as additionalContext. Must never crash or block session
|
|
4
|
+
# start — every call degrades to "no content" on any failure.
|
|
5
|
+
set -u
|
|
6
|
+
|
|
7
|
+
# The team's one deployed memory-hub function. MEMORY_HUB_FUNCTION_URL only needs to
|
|
8
|
+
# be set to override this (e.g. pointing at a local `sked function dev` instance).
|
|
9
|
+
FUNCTION_URL="${MEMORY_HUB_FUNCTION_URL:-https://dev-api.test.skl.io/function/memory-hub/memory-hub}"
|
|
10
|
+
TOKEN="${MEMORY_HUB_MCP_TOKEN:-}"
|
|
11
|
+
|
|
12
|
+
if [ -z "$TOKEN" ]; then
|
|
13
|
+
exit 0
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
TMP_DIR=$(mktemp -d)
|
|
17
|
+
trap 'rm -rf "$TMP_DIR"' EXIT
|
|
18
|
+
|
|
19
|
+
call() {
|
|
20
|
+
local path="$1"
|
|
21
|
+
local body="$2"
|
|
22
|
+
local out_file="$3"
|
|
23
|
+
# Two sequential rounds of parallel calls (never more than one round waits on this
|
|
24
|
+
# any single call), against the outer hook's 15s harness timeout — 5s here leaves
|
|
25
|
+
# comfortable headroom even if both rounds hit the cap. Bumped from 2s/3s after live
|
|
26
|
+
# runs showed occasional silent drops (a call's own timeout, not a logic bug) under
|
|
27
|
+
# real tenant latency.
|
|
28
|
+
curl -sS --connect-timeout 3 --max-time 5 \
|
|
29
|
+
-X POST "${FUNCTION_URL}${path}" \
|
|
30
|
+
-H "Authorization: Bearer ${TOKEN}" \
|
|
31
|
+
-H "Content-Type: application/json" \
|
|
32
|
+
-d "$body" \
|
|
33
|
+
-o "$out_file" 2>/dev/null || true
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# Canonicalize a git remote URL to owner/name, per the repo/team grouping spec §3.
|
|
37
|
+
# Prints nothing (and returns 0) for anything unrecognized — never fails the hook.
|
|
38
|
+
#
|
|
39
|
+
# This logic is duplicated, on purpose, in memory-hub-mcp/src/git-remote.ts — a bash
|
|
40
|
+
# hook cannot import a TypeScript module. Change both together.
|
|
41
|
+
#
|
|
42
|
+
# NOTE: bash's =~ has no non-capturing groups, so the URL form's groups are numbered
|
|
43
|
+
# differently from the spec's regex: the canonical name is BASH_REMATCH[3], not [1].
|
|
44
|
+
canonicalize_remote_url() {
|
|
45
|
+
local url="${1:-}"
|
|
46
|
+
# A CRLF-terminated git config (e.g. a Windows checkout) can leave a trailing \r on
|
|
47
|
+
# the remote URL; strip it (and any other trailing whitespace) before matching, to
|
|
48
|
+
# stay in sync with the TypeScript canonicalizer on such input.
|
|
49
|
+
url=$(printf '%s' "$url" | sed -e 's/[[:space:]]*$//')
|
|
50
|
+
url="${url%.git}"
|
|
51
|
+
|
|
52
|
+
if [[ "$url" =~ ^git@[^:]+:(.+)$ ]]; then
|
|
53
|
+
printf '%s' "${BASH_REMATCH[1]}"
|
|
54
|
+
elif [[ "$url" =~ ^(https?|ssh)://([^@]+@)?[^/]+/(.+)$ ]]; then
|
|
55
|
+
printf '%s' "${BASH_REMATCH[3]}"
|
|
56
|
+
fi
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# The canonical owner/name of the repo this session is in, or nothing at all.
|
|
60
|
+
detect_repo_name() {
|
|
61
|
+
local url first
|
|
62
|
+
url=$(git remote get-url origin 2>/dev/null) || url=""
|
|
63
|
+
|
|
64
|
+
if [ -z "$url" ]; then
|
|
65
|
+
first=$(git remote 2>/dev/null | head -n 1) || first=""
|
|
66
|
+
if [ -n "$first" ]; then
|
|
67
|
+
url=$(git remote get-url "$first" 2>/dev/null) || url=""
|
|
68
|
+
fi
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
[ -n "$url" ] || return 0
|
|
72
|
+
canonicalize_remote_url "$url"
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
# The team-name hint from this session's skeduloPackage.json, or nothing. Never
|
|
76
|
+
# fails the hook — missing file, unparseable JSON, or a missing jq binary all
|
|
77
|
+
# degrade to printing nothing, same convention as detect_repo_name.
|
|
78
|
+
detect_team_name_hint() {
|
|
79
|
+
[ -f "skeduloPackage.json" ] || return 0
|
|
80
|
+
local description name
|
|
81
|
+
description=$(jq -r '.description // empty' skeduloPackage.json 2>/dev/null) || return 0
|
|
82
|
+
if [ -n "$description" ]; then
|
|
83
|
+
printf '%s' "$description"
|
|
84
|
+
return 0
|
|
85
|
+
fi
|
|
86
|
+
name=$(jq -r '.name // empty' skeduloPackage.json 2>/dev/null) || return 0
|
|
87
|
+
[ -n "$name" ] || return 0
|
|
88
|
+
printf '%s' "${name##*/}"
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# Turns a canonical "owner/repo" name into a humanized team-name guess
|
|
92
|
+
# (universal-group -> Universal Group) — used only when detect_team_name_hint
|
|
93
|
+
# finds no config file (e.g. a repo using the newer sked.pkg.json/
|
|
94
|
+
# sked.proj.json convention has nothing this reads at all). A repo's own
|
|
95
|
+
# name has been a decent signal for its client in every case seen so far
|
|
96
|
+
# (CX-Welbe_Transporation, cx-welbehealth, universal-group all self-name)
|
|
97
|
+
# — an imperfect guess beats offering no hint whatsoever. Written portably
|
|
98
|
+
# for macOS's stock bash 3.2 (no ${var^}) — see memory-hub-mcp/src/
|
|
99
|
+
# repo-context.ts's humanizeRepoSlug for the TypeScript twin; change both
|
|
100
|
+
# together.
|
|
101
|
+
humanize_repo_slug() {
|
|
102
|
+
local slug="${1##*/}"
|
|
103
|
+
slug="$(printf '%s' "$slug" | tr '_-' ' ')"
|
|
104
|
+
local word first result=""
|
|
105
|
+
for word in $slug; do
|
|
106
|
+
first=$(printf '%s' "${word:0:1}" | tr '[:lower:]' '[:upper:]')
|
|
107
|
+
result="${result}${first}${word:1} "
|
|
108
|
+
done
|
|
109
|
+
printf '%s' "${result% }"
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
REPO_NAME=$(detect_repo_name 2>/dev/null || true)
|
|
113
|
+
TEAM_NAME_HINT=$(detect_team_name_hint 2>/dev/null || true)
|
|
114
|
+
if [ -z "$TEAM_NAME_HINT" ] && [ -n "$REPO_NAME" ]; then
|
|
115
|
+
TEAM_NAME_HINT=$(humanize_repo_slug "$REPO_NAME" 2>/dev/null || true)
|
|
116
|
+
fi
|
|
117
|
+
|
|
118
|
+
call "/memory/recall" '{"scope":"self"}' "$TMP_DIR/facts_self.json" &
|
|
119
|
+
call "/memory/recall" '{"scope":"team"}' "$TMP_DIR/facts_team.json" &
|
|
120
|
+
call "/memory/list-skills" '{"scope":"self"}' "$TMP_DIR/skills_self.json" &
|
|
121
|
+
call "/memory/list-skills" '{"scope":"team"}' "$TMP_DIR/skills_team.json" &
|
|
122
|
+
if [ -n "$REPO_NAME" ]; then
|
|
123
|
+
REPO_NAME_JSON=$(printf '%s' "$REPO_NAME" | jq -Rs . 2>/dev/null || true)
|
|
124
|
+
if [ -n "$REPO_NAME_JSON" ]; then
|
|
125
|
+
if [ -n "$TEAM_NAME_HINT" ]; then
|
|
126
|
+
HINT_JSON=$(printf '%s' "$TEAM_NAME_HINT" | jq -Rs . 2>/dev/null || echo 'null')
|
|
127
|
+
call "/memory/resolve-repo" "{\"name\":${REPO_NAME_JSON},\"teamNameHint\":${HINT_JSON}}" "$TMP_DIR/repo.json" &
|
|
128
|
+
else
|
|
129
|
+
call "/memory/resolve-repo" "{\"name\":${REPO_NAME_JSON}}" "$TMP_DIR/repo.json" &
|
|
130
|
+
fi
|
|
131
|
+
fi
|
|
132
|
+
fi
|
|
133
|
+
wait
|
|
134
|
+
|
|
135
|
+
# The repo-scoped recall can only run once resolve-repo has returned a uid, so it's a
|
|
136
|
+
# second round rather than part of the batch above. Both calls carry the same 3s cap
|
|
137
|
+
# as everything else — worst case the hook takes two short rounds, never blocks.
|
|
138
|
+
REPO_UID=""
|
|
139
|
+
if [ -s "$TMP_DIR/repo.json" ]; then
|
|
140
|
+
REPO_UID=$(jq -r '.uid // empty' "$TMP_DIR/repo.json" 2>/dev/null || true)
|
|
141
|
+
fi
|
|
142
|
+
|
|
143
|
+
if [ -n "$REPO_UID" ]; then
|
|
144
|
+
REPO_BODY=$(printf '{"scope":"team","repo":%s}' "$(printf '%s' "$REPO_UID" | jq -Rs .)")
|
|
145
|
+
call "/memory/recall" "$REPO_BODY" "$TMP_DIR/facts_repo.json" &
|
|
146
|
+
call "/memory/list-skills" "$REPO_BODY" "$TMP_DIR/skills_repo.json" &
|
|
147
|
+
call "/memory/recall-wiki" "$REPO_BODY" "$TMP_DIR/wiki_repo.json" &
|
|
148
|
+
wait
|
|
149
|
+
fi
|
|
150
|
+
|
|
151
|
+
# Appends "(updated YYYY-MM-DD)" when lastModifiedDate is present, nothing otherwise —
|
|
152
|
+
# the panel shows the same signal as a relative "N days ago" label, but the raw date
|
|
153
|
+
# is cheaper to compute in jq and just as usable for the agent's own judgment (it can
|
|
154
|
+
# already see today's date in its own context).
|
|
155
|
+
extract_facts() {
|
|
156
|
+
jq -r '.facts[]? | "- " + .content + (if .lastModifiedDate then " (updated " + .lastModifiedDate[0:10] + ")" else "" end)' "$1" 2>/dev/null || true
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
extract_skills() {
|
|
160
|
+
jq -r '.skills[]? | "- " + .title + ": " + .content + (if .lastModifiedDate then " (updated " + .lastModifiedDate[0:10] + ")" else "" end)' "$1" 2>/dev/null || true
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
extract_wiki() {
|
|
164
|
+
jq -r '.pages[]? | "- " + .title + ": " + .content + (if .lastModifiedDate then " (updated " + .lastModifiedDate[0:10] + ")" else "" end)' "$1" 2>/dev/null || true
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
# Counts non-empty "- "-prefixed lines in a var (0 for an empty string, never 1) —
|
|
168
|
+
# used only for the diagnostic summary line below, not for any content shown above.
|
|
169
|
+
count_items() {
|
|
170
|
+
[ -z "$1" ] && { printf '0'; return 0; }
|
|
171
|
+
printf '%s\n' "$1" | grep -c '^-' 2>/dev/null || printf '0'
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
NL=$'\n'
|
|
175
|
+
CONTEXT=""
|
|
176
|
+
|
|
177
|
+
FACTS_SELF=$(extract_facts "$TMP_DIR/facts_self.json")
|
|
178
|
+
FACTS_TEAM=$(extract_facts "$TMP_DIR/facts_team.json")
|
|
179
|
+
SKILLS_SELF=$(extract_skills "$TMP_DIR/skills_self.json")
|
|
180
|
+
SKILLS_TEAM=$(extract_skills "$TMP_DIR/skills_team.json")
|
|
181
|
+
|
|
182
|
+
# The team-scope query matches DevAgentId == self OR Visibility == "Team", so
|
|
183
|
+
# self-owned items also come back in the team results. Drop anything already
|
|
184
|
+
# shown under "Your ..." so it isn't rendered twice.
|
|
185
|
+
FACTS_TEAM=$(comm -23 <(echo "$FACTS_TEAM" | sort) <(echo "$FACTS_SELF" | sort) 2>/dev/null || true)
|
|
186
|
+
SKILLS_TEAM=$(comm -23 <(echo "$SKILLS_TEAM" | sort) <(echo "$SKILLS_SELF" | sort) 2>/dev/null || true)
|
|
187
|
+
|
|
188
|
+
if [ -n "$FACTS_SELF" ]; then
|
|
189
|
+
CONTEXT="${CONTEXT}## Your memory-hub facts${NL}${FACTS_SELF}${NL}${NL}"
|
|
190
|
+
fi
|
|
191
|
+
if [ -n "$FACTS_TEAM" ]; then
|
|
192
|
+
CONTEXT="${CONTEXT}## Team memory-hub facts${NL}${FACTS_TEAM}${NL}${NL}"
|
|
193
|
+
fi
|
|
194
|
+
if [ -n "$SKILLS_SELF" ]; then
|
|
195
|
+
CONTEXT="${CONTEXT}## Your memory-hub skills${NL}${SKILLS_SELF}${NL}${NL}"
|
|
196
|
+
fi
|
|
197
|
+
if [ -n "$SKILLS_TEAM" ]; then
|
|
198
|
+
CONTEXT="${CONTEXT}## Team memory-hub skills${NL}${SKILLS_TEAM}${NL}${NL}"
|
|
199
|
+
fi
|
|
200
|
+
|
|
201
|
+
# Additive, never narrowing: this is an extra section on top of the four above, not a
|
|
202
|
+
# filter applied to them. It surfaces what the whole team knows about this specific
|
|
203
|
+
# repo — including from members whose work this developer has never seen.
|
|
204
|
+
if [ -n "$REPO_UID" ]; then
|
|
205
|
+
FACTS_REPO=$(extract_facts "$TMP_DIR/facts_repo.json")
|
|
206
|
+
SKILLS_REPO=$(extract_skills "$TMP_DIR/skills_repo.json")
|
|
207
|
+
# Wiki has no self/private-vs-team dedup concern the way facts/skills do — a wiki
|
|
208
|
+
# page is only ever fetched here, in this one repo-scoped round, so there's
|
|
209
|
+
# nothing to subtract it against.
|
|
210
|
+
WIKI_REPO=$(extract_wiki "$TMP_DIR/wiki_repo.json")
|
|
211
|
+
|
|
212
|
+
# The repo-scoped query ({"scope":"team","repo":...}) is a superset filter of what
|
|
213
|
+
# the team query already fetched, so dedup against both the self and team sections
|
|
214
|
+
# above (same pattern as the team-vs-self dedup) to avoid showing it all twice.
|
|
215
|
+
FACTS_REPO=$(comm -23 <(echo "$FACTS_REPO" | sort) <(echo "$FACTS_SELF" | sort) 2>/dev/null || true)
|
|
216
|
+
FACTS_REPO=$(comm -23 <(echo "$FACTS_REPO" | sort) <(echo "$FACTS_TEAM" | sort) 2>/dev/null || true)
|
|
217
|
+
SKILLS_REPO=$(comm -23 <(echo "$SKILLS_REPO" | sort) <(echo "$SKILLS_TEAM" | sort) 2>/dev/null || true)
|
|
218
|
+
SKILLS_REPO=$(comm -23 <(echo "$SKILLS_REPO" | sort) <(echo "$SKILLS_SELF" | sort) 2>/dev/null || true)
|
|
219
|
+
|
|
220
|
+
REPO_SECTION=""
|
|
221
|
+
if [ -n "$FACTS_REPO" ]; then
|
|
222
|
+
REPO_SECTION="${REPO_SECTION}${FACTS_REPO}${NL}"
|
|
223
|
+
fi
|
|
224
|
+
if [ -n "$SKILLS_REPO" ]; then
|
|
225
|
+
REPO_SECTION="${REPO_SECTION}${SKILLS_REPO}${NL}"
|
|
226
|
+
fi
|
|
227
|
+
if [ -n "$WIKI_REPO" ]; then
|
|
228
|
+
REPO_SECTION="${REPO_SECTION}${WIKI_REPO}${NL}"
|
|
229
|
+
fi
|
|
230
|
+
|
|
231
|
+
if [ -n "$REPO_SECTION" ]; then
|
|
232
|
+
CONTEXT="${CONTEXT}## Team knowledge for ${REPO_NAME}${NL}${REPO_SECTION}${NL}"
|
|
233
|
+
fi
|
|
234
|
+
fi
|
|
235
|
+
|
|
236
|
+
# A completed-but-empty run and a timed-out/killed run both look identical from the
|
|
237
|
+
# outside (no visible symptom either way) unless something says which one happened.
|
|
238
|
+
# This line always emits once the hook has actually run this far, so its absence
|
|
239
|
+
# means the run itself didn't finish (killed by the SessionStart timeout, or crashed
|
|
240
|
+
# before reaching here) rather than "ran fine, nothing to show."
|
|
241
|
+
DIAG="_memory-hub: self $(count_items "$FACTS_SELF") facts/$(count_items "$SKILLS_SELF") skills"
|
|
242
|
+
DIAG="${DIAG} · team $(count_items "$FACTS_TEAM") facts/$(count_items "$SKILLS_TEAM") skills"
|
|
243
|
+
if [ -n "$REPO_UID" ]; then
|
|
244
|
+
DIAG="${DIAG} · repo(${REPO_NAME}) $(count_items "$FACTS_REPO") facts/$(count_items "$SKILLS_REPO") skills/$(count_items "$WIKI_REPO") wiki"
|
|
245
|
+
else
|
|
246
|
+
DIAG="${DIAG} · repo: not linked"
|
|
247
|
+
fi
|
|
248
|
+
DIAG="${DIAG}_"
|
|
249
|
+
|
|
250
|
+
# Recall above is the hook's own automation — it never saves anything new, and an
|
|
251
|
+
# agent reading only the facts/skills sections has no reason to infer that a
|
|
252
|
+
# separate, non-automatic step exists for the other half (on-demand mid-session
|
|
253
|
+
# recall, and saving durable results once a task lands). State that explicitly and
|
|
254
|
+
# unconditionally (not gated behind having any facts to show) so an agent that
|
|
255
|
+
# finds nothing above still knows to check back in before finishing a task.
|
|
256
|
+
CONTEXT="${CONTEXT}## Reminder${NL}"
|
|
257
|
+
CONTEXT="${CONTEXT}The above is an automatic recall only - it never saves anything new.${NL}"
|
|
258
|
+
CONTEXT="${CONTEXT}Invoke the se-ai-memory-hub skill during this session: memory_recall before${NL}"
|
|
259
|
+
CONTEXT="${CONTEXT}investigating something that smells like prior context, and memory_save${NL}"
|
|
260
|
+
CONTEXT="${CONTEXT}(type \"Fact\" or \"Scenario\") once a task produces a durable decision, root${NL}"
|
|
261
|
+
CONTEXT="${CONTEXT}cause, or fix worth keeping for next time.${NL}${NL}"
|
|
262
|
+
|
|
263
|
+
CONTEXT="${CONTEXT}${DIAG}${NL}"
|
|
264
|
+
|
|
265
|
+
CONTEXT_JSON=$(printf '%s' "$CONTEXT" | jq -Rs .)
|
|
266
|
+
printf '{"hookSpecificOutput": {"hookEventName": "SessionStart", "additionalContext": %s}}\n' "$CONTEXT_JSON"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Stop hook: when a session ends, resumes it headlessly with a narrow tool
|
|
3
|
+
# allowlist and asks it to save anything durable it didn't already save. Closes
|
|
4
|
+
# the gap that session-start.sh's injected "## Reminder" only nudges at —
|
|
5
|
+
# nothing upstream of this actually saves memory on its own.
|
|
6
|
+
#
|
|
7
|
+
# Must never block session exit or crash: every failure path degrades to a
|
|
8
|
+
# silent no-op. Runs as an "async": true Stop hook (see ~/.claude/settings.json)
|
|
9
|
+
# so the harness doesn't wait on it either way.
|
|
10
|
+
set -u
|
|
11
|
+
|
|
12
|
+
# Recursion guard: the headless `claude -p --resume` call below is itself a
|
|
13
|
+
# Claude Code invocation, and this Stop hook is registered at the user level,
|
|
14
|
+
# so it would otherwise fire again when THAT session ends, forever. Set before
|
|
15
|
+
# spawning, checked first thing here.
|
|
16
|
+
if [ -n "${MEMORY_HUB_STOP_HOOK_ACTIVE:-}" ]; then
|
|
17
|
+
exit 0
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
TOKEN="${MEMORY_HUB_MCP_TOKEN:-}"
|
|
21
|
+
[ -n "$TOKEN" ] || exit 0
|
|
22
|
+
|
|
23
|
+
INPUT=$(cat)
|
|
24
|
+
SESSION_ID=$(printf '%s' "$INPUT" | jq -r '.session_id // empty' 2>/dev/null) || exit 0
|
|
25
|
+
[ -n "$SESSION_ID" ] || exit 0
|
|
26
|
+
|
|
27
|
+
# Cheap pre-filter before spawning a whole headless agent: a transcript this
|
|
28
|
+
# short is a trivial exchange (a one-off question, an aborted session) with
|
|
29
|
+
# nothing durable to extract. Line count, not a parsed field, on purpose — it
|
|
30
|
+
# doesn't depend on the transcript JSONL's exact schema, just its volume.
|
|
31
|
+
TRANSCRIPT_PATH=$(printf '%s' "$INPUT" | jq -r '.transcript_path // empty' 2>/dev/null) || TRANSCRIPT_PATH=""
|
|
32
|
+
if [ -n "$TRANSCRIPT_PATH" ] && [ -f "$TRANSCRIPT_PATH" ]; then
|
|
33
|
+
LINE_COUNT=$(wc -l < "$TRANSCRIPT_PATH" 2>/dev/null | tr -d ' ')
|
|
34
|
+
if [ -n "$LINE_COUNT" ] && [ "$LINE_COUNT" -lt 8 ] 2>/dev/null; then
|
|
35
|
+
exit 0
|
|
36
|
+
fi
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
PROMPT='This session is ending. Scan it for a decision, root cause, or fix that
|
|
40
|
+
would be worth knowing next time, in this repo or across the team — not
|
|
41
|
+
narration or exploration. If you already called memory_save with type
|
|
42
|
+
"Fact" or "Scenario" for it earlier in this same session, do not save it
|
|
43
|
+
again. If nothing in this session qualifies, do nothing and finish.
|
|
44
|
+
Otherwise, call memory_save now (type "Fact" or "Scenario") for exactly
|
|
45
|
+
the items that qualify.'
|
|
46
|
+
|
|
47
|
+
LOG_FILE="${TMPDIR:-/tmp}/memory-hub-stop-hook.log"
|
|
48
|
+
{
|
|
49
|
+
echo "---- $(date -u +%FT%TZ) session=$SESSION_ID ----"
|
|
50
|
+
MEMORY_HUB_STOP_HOOK_ACTIVE=1 claude -p --resume "$SESSION_ID" \
|
|
51
|
+
--allowedTools "mcp__memory-hub__memory_recall,mcp__memory-hub__memory_save" \
|
|
52
|
+
--permission-prompts none \
|
|
53
|
+
--model haiku \
|
|
54
|
+
--no-session-persistence \
|
|
55
|
+
"$PROMPT" </dev/null
|
|
56
|
+
} >>"$LOG_FILE" 2>&1 || true
|
|
57
|
+
|
|
58
|
+
exit 0
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
// Dispatch happens here rather than in index.ts because index.ts throws at module
|
|
4
|
+
// load when MEMORY_HUB_MCP_TOKEN is unset — which is exactly the state `setup` exists
|
|
5
|
+
// to fix, so it can never be reached from there.
|
|
6
|
+
const command = process.argv[2];
|
|
7
|
+
if (command === 'setup') {
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
9
|
+
const { runSetup } = require('./setup');
|
|
10
|
+
runSetup(process.argv.slice(3)).catch((error) => {
|
|
11
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
12
|
+
process.exit(1);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
else if (command === '--help' || command === '-h') {
|
|
16
|
+
console.log(`memory-hub-mcp — MCP server for the SE AI Memory Hub
|
|
17
|
+
|
|
18
|
+
memory-hub-mcp setup log in, then wire up Claude Code (MCP server + SessionStart
|
|
19
|
+
hook + skill) and/or Claude Desktop (MCP server), and verify
|
|
20
|
+
the token. Pass --code, --desktop or --both to skip the prompt.
|
|
21
|
+
memory-hub-mcp run the MCP server on stdio (how a host launches it)
|
|
22
|
+
`);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
require('./index');
|
|
26
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
"use strict";
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
const fs_1 = require("fs");
|
|
@@ -184,18 +183,36 @@ server.tool('memory_checkRepoStatus', "Check whether the current repo is linked
|
|
|
184
183
|
const status = await repoContext.checkRepoStatus();
|
|
185
184
|
return { content: [...(await joinNoticeBlocks()), { type: 'text', text: JSON.stringify(status) }] };
|
|
186
185
|
});
|
|
186
|
+
server.tool('memory_listTeams', "List the memory teams this developer belongs to, for choosing a teamName to pass to memory_linkRepoTeam.", {}, async () => {
|
|
187
|
+
const { teams } = await client.listTeams();
|
|
188
|
+
return { content: [{ type: 'text', text: JSON.stringify({ teams }) }] };
|
|
189
|
+
});
|
|
187
190
|
server.tool('memory_listRepos', "List repos across this developer's teams, with an optional substring query filter, for targeting memory_save or memory_moveResourceRepo at a repo other than the current directory.", {
|
|
188
191
|
query: zod_1.z.string().optional().describe('Case-insensitive substring filter on repo name.'),
|
|
189
192
|
}, async (input) => {
|
|
190
193
|
const repos = await (0, list_repos_1.listReposForTools)(client, input.query);
|
|
191
194
|
return { content: [{ type: 'text', text: JSON.stringify({ repos }) }] };
|
|
192
195
|
});
|
|
193
|
-
server.tool('memory_linkRepoTeam',
|
|
196
|
+
server.tool('memory_linkRepoTeam', "Link a repo to a team by name (existing or new) after the user has confirmed which team it belongs to. Defaults to the repo of the current directory; pass repoName to link a different one, or from a host with no repo at all (Claude Desktop). Use memory_listTeams to see the team names to choose from.", {
|
|
194
197
|
teamName: zod_1.z.string(),
|
|
198
|
+
repoName: zod_1.z
|
|
199
|
+
.string()
|
|
200
|
+
.min(1)
|
|
201
|
+
.optional()
|
|
202
|
+
.describe('Repo to link. Defaults to the current directory\'s repo; required when there is none.'),
|
|
195
203
|
}, async (input) => {
|
|
196
|
-
const repoName = (0, git_remote_1.detectRepoName)();
|
|
204
|
+
const repoName = input.repoName ?? (0, git_remote_1.detectRepoName)();
|
|
197
205
|
if (!repoName) {
|
|
198
|
-
return {
|
|
206
|
+
return {
|
|
207
|
+
content: [
|
|
208
|
+
{
|
|
209
|
+
type: 'text',
|
|
210
|
+
text: JSON.stringify({
|
|
211
|
+
error: 'No repo detected in this session. Pass repoName to say which repo to link.',
|
|
212
|
+
}),
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
};
|
|
199
216
|
}
|
|
200
217
|
const result = await client.linkRepoTeam({ repoName, teamName: input.teamName });
|
|
201
218
|
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
package/dist/setup.js
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runSetup = exports.registerSessionStartHook = exports.writeUserEnv = exports.writeDesktopConfig = exports.writeMcpServer = exports.functionUrl = exports.desktopConfigPath = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const os_1 = require("os");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const readline_1 = require("readline");
|
|
9
|
+
const DEFAULT_API_HOST = 'dev-api.test.skl.io';
|
|
10
|
+
const DEFAULT_TENANT = 'memory-hub';
|
|
11
|
+
const SKED_CONFIG = (0, path_1.join)((0, os_1.homedir)(), '.config', 'sked', 'config.json');
|
|
12
|
+
// Shipped in the package (see scripts/copy-assets.sh) so a teammate with no repo
|
|
13
|
+
// checkout still gets the hook and skill that scripts/setup-dev.sh installs.
|
|
14
|
+
const ASSETS = (0, path_1.join)(__dirname, '..', 'assets');
|
|
15
|
+
// Claude Desktop's config lives in the OS app-data dir, not the repo — a teammate
|
|
16
|
+
// installing from npm has no repo, so this is the only file setup touches for Desktop.
|
|
17
|
+
function desktopConfigPath() {
|
|
18
|
+
const home = (0, os_1.homedir)();
|
|
19
|
+
if ((0, os_1.platform)() === 'darwin') {
|
|
20
|
+
return (0, path_1.join)(home, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
|
|
21
|
+
}
|
|
22
|
+
if ((0, os_1.platform)() === 'win32') {
|
|
23
|
+
return (0, path_1.join)(process.env.APPDATA || (0, path_1.join)(home, 'AppData', 'Roaming'), 'Claude', 'claude_desktop_config.json');
|
|
24
|
+
}
|
|
25
|
+
return (0, path_1.join)(process.env.XDG_CONFIG_HOME || (0, path_1.join)(home, '.config'), 'Claude', 'claude_desktop_config.json');
|
|
26
|
+
}
|
|
27
|
+
exports.desktopConfigPath = desktopConfigPath;
|
|
28
|
+
function readJson(path) {
|
|
29
|
+
try {
|
|
30
|
+
return JSON.parse((0, fs_1.readFileSync)(path, 'utf8'));
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function writeJson(path, value) {
|
|
37
|
+
(0, fs_1.mkdirSync)((0, path_1.dirname)(path), { recursive: true });
|
|
38
|
+
if ((0, fs_1.existsSync)(path))
|
|
39
|
+
(0, fs_1.writeFileSync)(`${path}.bak`, (0, fs_1.readFileSync)(path));
|
|
40
|
+
(0, fs_1.writeFileSync)(path, `${JSON.stringify(value, null, 2)}\n`);
|
|
41
|
+
}
|
|
42
|
+
function ask(question) {
|
|
43
|
+
const rl = (0, readline_1.createInterface)({ input: process.stdin, output: process.stdout });
|
|
44
|
+
return new Promise((done) => rl.question(question, (answer) => { rl.close(); done(answer.trim()); }));
|
|
45
|
+
}
|
|
46
|
+
// A pasted API token is shown once by Pulse Web and never again; echoing it into
|
|
47
|
+
// the terminal leaves it in scrollback and shell logs.
|
|
48
|
+
function askHidden(question) {
|
|
49
|
+
return new Promise((done) => {
|
|
50
|
+
const rl = (0, readline_1.createInterface)({ input: process.stdin, output: process.stdout, terminal: true });
|
|
51
|
+
const output = rl.output;
|
|
52
|
+
let muted = false;
|
|
53
|
+
rl._writeToOutput = (chunk) => {
|
|
54
|
+
if (!muted)
|
|
55
|
+
output.write(chunk);
|
|
56
|
+
};
|
|
57
|
+
rl.question(question, (answer) => {
|
|
58
|
+
rl.close();
|
|
59
|
+
process.stdout.write('\n');
|
|
60
|
+
done(answer.trim());
|
|
61
|
+
});
|
|
62
|
+
muted = true;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
// Mirrors scripts/setup-dev.sh: never mint a token silently. `sked tenant login web`
|
|
66
|
+
// runs the same browser OAuth the CLI already uses, then writes the result into its
|
|
67
|
+
// own config. Which alias it lands under can't be assumed, so diff before/after and
|
|
68
|
+
// take whichever entry's token changed.
|
|
69
|
+
async function loginWithSked() {
|
|
70
|
+
const tenant = (await ask(` Tenant/team name for the sked login? (default: ${DEFAULT_TENANT}): `)) || DEFAULT_TENANT;
|
|
71
|
+
const env = (await ask(' Environment — test or production? (default: test): ')) || 'test';
|
|
72
|
+
const confirm = await ask(' Log in with sked now? [Y/n]: ');
|
|
73
|
+
if (confirm.toLowerCase() === 'n')
|
|
74
|
+
return undefined;
|
|
75
|
+
console.log(' Opening your browser...');
|
|
76
|
+
const before = readJson(SKED_CONFIG).users || {};
|
|
77
|
+
const result = (0, child_process_1.spawnSync)('sked', ['tenant', 'login', 'web', '-t', tenant, '-e', env, '-a', tenant, '-u', '-l', '0', '-o'], {
|
|
78
|
+
stdio: 'inherit',
|
|
79
|
+
});
|
|
80
|
+
if (result.status !== 0) {
|
|
81
|
+
console.log(" sked login didn't complete — falling back to manual paste.");
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
const after = readJson(SKED_CONFIG).users || {};
|
|
85
|
+
for (const [alias, user] of Object.entries(after)) {
|
|
86
|
+
if (before[alias]?.accessToken !== user?.accessToken && user?.accessToken) {
|
|
87
|
+
return { token: user.accessToken, apiBase: user.apiBasePath };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
console.log(" login succeeded but the token couldn't be found — falling back to manual paste.");
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
async function pasteToken() {
|
|
94
|
+
console.log(' Or generate one at Pulse Web -> your profile (top right) -> Settings ->');
|
|
95
|
+
console.log(' Developer tools -> API tokens -> Create. It is shown ONCE — Skedulo does');
|
|
96
|
+
console.log(' not store it, so copy it now.');
|
|
97
|
+
const host = (await ask(` Skedulo API host? (default: ${DEFAULT_API_HOST}): `)) || DEFAULT_API_HOST;
|
|
98
|
+
const token = await askHidden(' Paste your personal Skedulo API token (input hidden), or press Enter to skip: ');
|
|
99
|
+
if (!token)
|
|
100
|
+
return undefined;
|
|
101
|
+
return { token, apiBase: host };
|
|
102
|
+
}
|
|
103
|
+
function functionUrl(apiBase) {
|
|
104
|
+
const base = (apiBase || DEFAULT_API_HOST).replace(/\/+$/, '');
|
|
105
|
+
const withScheme = base.startsWith('http') ? base : `https://${base}`;
|
|
106
|
+
return `${withScheme}/function/memory-hub/memory-hub`;
|
|
107
|
+
}
|
|
108
|
+
exports.functionUrl = functionUrl;
|
|
109
|
+
// Merge, never replace: the file almost always holds other MCP servers, and a
|
|
110
|
+
// teammate may have deliberately pointed MEMORY_HUB_FUNCTION_URL somewhere else.
|
|
111
|
+
function writeMcpServer(path, command, env) {
|
|
112
|
+
const config = readJson(path);
|
|
113
|
+
const servers = (config.mcpServers ||= {});
|
|
114
|
+
const existing = servers['memory-hub'] || {};
|
|
115
|
+
servers['memory-hub'] = {
|
|
116
|
+
...existing,
|
|
117
|
+
command,
|
|
118
|
+
args: existing.args || [],
|
|
119
|
+
env: { ...(existing.env || {}), ...env },
|
|
120
|
+
};
|
|
121
|
+
writeJson(path, config);
|
|
122
|
+
}
|
|
123
|
+
exports.writeMcpServer = writeMcpServer;
|
|
124
|
+
/** @deprecated name kept for the 0.2.0 API; use writeMcpServer. */
|
|
125
|
+
exports.writeDesktopConfig = writeMcpServer;
|
|
126
|
+
// Claude Code reads the token from settings.json's env, not from the MCP server's
|
|
127
|
+
// env block: the SessionStart hook is a plain shell script and needs it too.
|
|
128
|
+
function writeUserEnv(path, env) {
|
|
129
|
+
const settings = readJson(path);
|
|
130
|
+
settings.env = { ...(settings.env || {}), ...env };
|
|
131
|
+
writeJson(path, settings);
|
|
132
|
+
}
|
|
133
|
+
exports.writeUserEnv = writeUserEnv;
|
|
134
|
+
// Appended, not replaced: a developer may have their own SessionStart hooks, and
|
|
135
|
+
// re-running setup must not stack duplicates of ours.
|
|
136
|
+
function registerSessionStartHook(path, hookPath) {
|
|
137
|
+
const settings = readJson(path);
|
|
138
|
+
const hooks = (settings.hooks ||= {});
|
|
139
|
+
const entries = (hooks.SessionStart ||= []);
|
|
140
|
+
const already = entries.some((entry) => (entry.hooks || []).some((h) => h.command === hookPath));
|
|
141
|
+
if (!already)
|
|
142
|
+
entries.push({ hooks: [{ type: 'command', command: hookPath }] });
|
|
143
|
+
writeJson(path, settings);
|
|
144
|
+
return already;
|
|
145
|
+
}
|
|
146
|
+
exports.registerSessionStartHook = registerSessionStartHook;
|
|
147
|
+
function installAssets() {
|
|
148
|
+
const hookDir = (0, path_1.join)((0, os_1.homedir)(), '.claude', 'memory-hub-hook');
|
|
149
|
+
const skillDir = (0, path_1.join)((0, os_1.homedir)(), '.claude', 'skills', 'se-ai-memory-hub');
|
|
150
|
+
(0, fs_1.mkdirSync)(hookDir, { recursive: true });
|
|
151
|
+
(0, fs_1.mkdirSync)(skillDir, { recursive: true });
|
|
152
|
+
for (const name of ['session-start.sh', 'session-stop.sh']) {
|
|
153
|
+
const dest = (0, path_1.join)(hookDir, name);
|
|
154
|
+
(0, fs_1.copyFileSync)((0, path_1.join)(ASSETS, name), dest);
|
|
155
|
+
(0, fs_1.chmodSync)(dest, 0o755);
|
|
156
|
+
}
|
|
157
|
+
(0, fs_1.copyFileSync)((0, path_1.join)(ASSETS, 'SKILL.md'), (0, path_1.join)(skillDir, 'SKILL.md'));
|
|
158
|
+
return { hookPath: (0, path_1.join)(hookDir, 'session-start.sh') };
|
|
159
|
+
}
|
|
160
|
+
// A wrong token does not make the server fail loudly — every recall degrades to
|
|
161
|
+
// empty — so the only honest confirmation is one real call before declaring done.
|
|
162
|
+
async function verify(url, token) {
|
|
163
|
+
try {
|
|
164
|
+
const response = await fetch(`${url}/memory/recall`, {
|
|
165
|
+
method: 'POST',
|
|
166
|
+
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
|
|
167
|
+
body: JSON.stringify({ scope: 'self' }),
|
|
168
|
+
signal: AbortSignal.timeout(10000),
|
|
169
|
+
});
|
|
170
|
+
if (response.ok) {
|
|
171
|
+
console.log(' token works — got a real response from the memory-hub function');
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
console.log(` got HTTP ${response.status} from the memory-hub function — token may be wrong or expired`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
console.log(` couldn't reach ${url} — check your network, not necessarily the token`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
async function chooseHosts() {
|
|
182
|
+
console.log(' Which host do you use?');
|
|
183
|
+
console.log(' 1) Claude Code (MCP server + startup hook + skill)');
|
|
184
|
+
console.log(' 2) Claude Desktop (MCP server only — Desktop has no hooks)');
|
|
185
|
+
console.log(' 3) both');
|
|
186
|
+
const answer = (await ask(' Choice? (default: 1): ')) || '1';
|
|
187
|
+
if (answer === '2')
|
|
188
|
+
return ['desktop'];
|
|
189
|
+
if (answer === '3')
|
|
190
|
+
return ['code', 'desktop'];
|
|
191
|
+
return ['code'];
|
|
192
|
+
}
|
|
193
|
+
function existingToken(hosts) {
|
|
194
|
+
if (hosts.includes('code')) {
|
|
195
|
+
const settings = readJson((0, path_1.join)((0, os_1.homedir)(), '.claude', 'settings.json'));
|
|
196
|
+
const token = settings.env?.MEMORY_HUB_MCP_TOKEN;
|
|
197
|
+
const url = readJson((0, path_1.join)((0, os_1.homedir)(), '.claude.json')).mcpServers?.['memory-hub']?.env?.MEMORY_HUB_FUNCTION_URL;
|
|
198
|
+
if (token)
|
|
199
|
+
return { token, url };
|
|
200
|
+
}
|
|
201
|
+
const env = readJson(desktopConfigPath()).mcpServers?.['memory-hub']?.env || {};
|
|
202
|
+
return { token: env.MEMORY_HUB_MCP_TOKEN, url: env.MEMORY_HUB_FUNCTION_URL };
|
|
203
|
+
}
|
|
204
|
+
async function runSetup(argv = []) {
|
|
205
|
+
console.log('==> Setting up the memory hub');
|
|
206
|
+
let hosts;
|
|
207
|
+
if (argv.includes('--code'))
|
|
208
|
+
hosts = ['code'];
|
|
209
|
+
else if (argv.includes('--desktop'))
|
|
210
|
+
hosts = ['desktop'];
|
|
211
|
+
else if (argv.includes('--both'))
|
|
212
|
+
hosts = ['code', 'desktop'];
|
|
213
|
+
else if (!process.stdin.isTTY) {
|
|
214
|
+
console.log(' Not an interactive terminal. Re-run from a terminal, or pass');
|
|
215
|
+
console.log(' --code, --desktop or --both.');
|
|
216
|
+
process.exitCode = 1;
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
else
|
|
220
|
+
hosts = await chooseHosts();
|
|
221
|
+
const prior = existingToken(hosts);
|
|
222
|
+
let credentials;
|
|
223
|
+
let token = prior.token;
|
|
224
|
+
console.log();
|
|
225
|
+
console.log('==> Checking MEMORY_HUB_MCP_TOKEN');
|
|
226
|
+
if (token) {
|
|
227
|
+
console.log(' already set — keeping it');
|
|
228
|
+
}
|
|
229
|
+
else if (!process.stdin.isTTY) {
|
|
230
|
+
console.log(' no token set, and this is not an interactive terminal.');
|
|
231
|
+
console.log(' Re-run `memory-hub-mcp setup` from a terminal.');
|
|
232
|
+
process.exitCode = 1;
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
if ((0, child_process_1.spawnSync)('which', ['sked']).status === 0) {
|
|
237
|
+
console.log(' Not set yet. Easiest way: log in once via sked (opens your browser).');
|
|
238
|
+
credentials = await loginWithSked();
|
|
239
|
+
}
|
|
240
|
+
if (!credentials)
|
|
241
|
+
credentials = await pasteToken();
|
|
242
|
+
if (!credentials) {
|
|
243
|
+
console.log(' No token provided — nothing written. Re-run when you have one.');
|
|
244
|
+
process.exitCode = 1;
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
token = credentials.token;
|
|
248
|
+
}
|
|
249
|
+
const url = credentials?.apiBase ? functionUrl(credentials.apiBase) : prior.url || functionUrl();
|
|
250
|
+
// The absolute path to this installed binary: neither host launches MCP servers
|
|
251
|
+
// from a login shell, so a bare command name on the user's PATH won't resolve.
|
|
252
|
+
const command = (0, path_1.resolve)(process.argv[1]);
|
|
253
|
+
const env = { MEMORY_HUB_MCP_TOKEN: token, MEMORY_HUB_FUNCTION_URL: url };
|
|
254
|
+
if (hosts.includes('code')) {
|
|
255
|
+
console.log();
|
|
256
|
+
console.log('==> Claude Code');
|
|
257
|
+
writeMcpServer((0, path_1.join)((0, os_1.homedir)(), '.claude.json'), command, env);
|
|
258
|
+
console.log(` MCP server -> ${command}`);
|
|
259
|
+
// The hook is a shell script, so it reads the token from the environment Claude
|
|
260
|
+
// Code gives it, not from the MCP server's env block.
|
|
261
|
+
writeUserEnv((0, path_1.join)((0, os_1.homedir)(), '.claude', 'settings.json'), env);
|
|
262
|
+
const { hookPath } = installAssets();
|
|
263
|
+
const already = registerSessionStartHook((0, path_1.join)((0, os_1.homedir)(), '.claude', 'settings.json'), hookPath);
|
|
264
|
+
console.log(` SessionStart hook -> ${hookPath}${already ? ' (already registered)' : ''}`);
|
|
265
|
+
console.log(' skill -> ~/.claude/skills/se-ai-memory-hub/SKILL.md');
|
|
266
|
+
for (const tool of ['curl', 'jq']) {
|
|
267
|
+
if ((0, child_process_1.spawnSync)('which', [tool]).status !== 0) {
|
|
268
|
+
console.log(` warning: ${tool} is not installed — the startup hook needs it`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (hosts.includes('desktop')) {
|
|
273
|
+
console.log();
|
|
274
|
+
console.log('==> Claude Desktop');
|
|
275
|
+
const path = desktopConfigPath();
|
|
276
|
+
writeMcpServer(path, command, env);
|
|
277
|
+
console.log(` MCP server -> ${command}`);
|
|
278
|
+
console.log(` config -> ${path}`);
|
|
279
|
+
console.log(' no hook: Desktop has no hook system, so startup injection and');
|
|
280
|
+
console.log(' end-of-session auto-save are Claude Code only.');
|
|
281
|
+
}
|
|
282
|
+
console.log();
|
|
283
|
+
console.log('==> Verifying');
|
|
284
|
+
console.log(` endpoint: ${url}`);
|
|
285
|
+
await verify(url, token);
|
|
286
|
+
console.log();
|
|
287
|
+
if (hosts.includes('code'))
|
|
288
|
+
console.log('Restart Claude Code to pick this up.');
|
|
289
|
+
if (hosts.includes('desktop'))
|
|
290
|
+
console.log('Quit Claude Desktop completely and reopen it to pick this up.');
|
|
291
|
+
}
|
|
292
|
+
exports.runSetup = runSetup;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skedulo/memory-hub-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "MCP server for the SE AI Memory Hub: recall and save developer memory from Claude Code and Claude Desktop.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -13,19 +13,22 @@
|
|
|
13
13
|
},
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"bin": {
|
|
16
|
-
"memory-hub-mcp": "dist/
|
|
16
|
+
"memory-hub-mcp": "dist/cli.js"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"dist/**/*.js",
|
|
20
|
-
"!dist/**/*.test.js"
|
|
20
|
+
"!dist/**/*.test.js",
|
|
21
|
+
"skill-guide.md",
|
|
22
|
+
"assets/**"
|
|
21
23
|
],
|
|
22
24
|
"publishConfig": {
|
|
23
|
-
"access": "
|
|
25
|
+
"access": "public"
|
|
24
26
|
},
|
|
25
27
|
"scripts": {
|
|
26
28
|
"build": "tsc",
|
|
27
29
|
"start": "node dist/index.js",
|
|
28
|
-
"test": "jest"
|
|
30
|
+
"test": "jest",
|
|
31
|
+
"prepack": "./scripts/copy-assets.sh"
|
|
29
32
|
},
|
|
30
33
|
"dependencies": {
|
|
31
34
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
package/skill-guide.md
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
# SE AI Memory Hub — usage guide
|
|
2
|
+
|
|
3
|
+
_Served live by memory_getSkillGuide — this is the single source of truth, edited here directly. Never hand-copy this content elsewhere._
|
|
4
|
+
|
|
5
|
+
If the session-start hook (see `memory-hub-hook/`) is registered, it already
|
|
6
|
+
injected your own and your team's recent facts and skills as context. This
|
|
7
|
+
skill covers what to do *during* the session, beyond that automatic
|
|
8
|
+
injection.
|
|
9
|
+
|
|
10
|
+
## Recall on demand
|
|
11
|
+
|
|
12
|
+
If you're about to work on something that might have prior context not
|
|
13
|
+
already surfaced at session start — a past decision on this specific repo,
|
|
14
|
+
a known gotcha, a previously-solved version of this exact problem — call
|
|
15
|
+
`memory_recall` with `scope: 'self'` or `scope: 'team'` and an optional
|
|
16
|
+
`query` string to narrow it. Don't call it reflexively for every task; call
|
|
17
|
+
it when the task smells like something that may have come up before.
|
|
18
|
+
|
|
19
|
+
Pass `type: 'Fact'`, `'Skill'`, `'Scenario'`, or `'Wiki'` to pick what kind of
|
|
20
|
+
content you're looking for — a past decision/gotcha, a reusable procedure, a
|
|
21
|
+
distilled multi-fact summary, or standing reference documentation,
|
|
22
|
+
respectively.
|
|
23
|
+
|
|
24
|
+
Pass `externalRef` instead of (or alongside) `query` when the task at hand is
|
|
25
|
+
"what do we already know about ticket X" (Fact and Scenario only) — it
|
|
26
|
+
filters to facts/scenarios linked to that ticket, and returns nothing (not
|
|
27
|
+
everything) if the ref was never used before.
|
|
28
|
+
|
|
29
|
+
## Save at the end of a task
|
|
30
|
+
|
|
31
|
+
When you finish a task that produced something durable and worth keeping
|
|
32
|
+
for next time:
|
|
33
|
+
|
|
34
|
+
Call `memory_save` with a `type` of `'Fact'`, `'Skill'`, `'Scenario'`, or
|
|
35
|
+
`'Wiki'` — which fields it needs depends on the type:
|
|
36
|
+
|
|
37
|
+
- **`type: 'Fact'`** — a distilled decision, constraint, or gotcha.
|
|
38
|
+
Pass `content` (the fact itself, written so it stands alone without the
|
|
39
|
+
conversation around it), and optionally `tags`, `externalRef` (the
|
|
40
|
+
Linear/Jira ticket this relates to, e.g. `"SOL-1234"` — pass it when the
|
|
41
|
+
user mentions a ticket; never guess one from a branch name or anything
|
|
42
|
+
else not explicitly said). The repo you're working in is detected from
|
|
43
|
+
its git remote and attached automatically — there is no `repo` argument
|
|
44
|
+
to pass unless you're targeting a different repo (see "Targeting a
|
|
45
|
+
different repo explicitly" below).
|
|
46
|
+
- **`type: 'Skill'`** — a reusable procedure or fix you'd want to reach
|
|
47
|
+
for again. Pass `title` and `content` (the actual steps/code), and
|
|
48
|
+
optionally `tags`. The repo is attached automatically, as above.
|
|
49
|
+
|
|
50
|
+
`tags` (on Fact/Skill/Wiki saves, and on `memory_recall`) is a fixed
|
|
51
|
+
picklist, not a free-form string — pick from `ConnectedFunction`,
|
|
52
|
+
`HorizonComponent`, `TriggeredAction`, `ObjectModel`, `MobileExtension`,
|
|
53
|
+
`Deployment`, `Auth`, `Testing`, `BreezeUI`, `PSS`, `PSF`, `Optimization`,
|
|
54
|
+
`Webhooks`, `Salesforce`, `Other`, `ArchitectureMap` (used for the
|
|
55
|
+
codebase-map skills described below, not for facts), `SOW` (a Statement of
|
|
56
|
+
Work), `TDD` (a Technical Design Doc) — `SOW`/`TDD` are most useful on wiki
|
|
57
|
+
pages, where a whole document usually lands (see below), but are valid on
|
|
58
|
+
Fact, Skill, or Wiki saves alike. The tool schema enforces this, so an invalid tag fails
|
|
59
|
+
with a clear validation error rather than reaching the backend — if this
|
|
60
|
+
list and the schema's actual error ever disagree, trust the error: this
|
|
61
|
+
list is prose, kept in sync by hand.
|
|
62
|
+
- **`type: 'Scenario'`** — when a task involved several related facts
|
|
63
|
+
worth grouping into one distilled summary. Pass `summary`, and optionally
|
|
64
|
+
`factIds` (UIDs of facts already saved this session that belong together)
|
|
65
|
+
and `externalRef` (the Linear/Jira ticket this relates to, e.g.
|
|
66
|
+
`"SOL-1234"` — pass it when the user mentions a ticket; never guess one
|
|
67
|
+
from a branch name or anything else not explicitly said).
|
|
68
|
+
- **`memory_upsertPersona`** — when something durable about how this
|
|
69
|
+
developer prefers to work emerged this session (a standing preference, a
|
|
70
|
+
recurring decision pattern). Pass only the field(s) that changed
|
|
71
|
+
(`preferences`, `decisions`, `patterns`) — **this replaces each field's
|
|
72
|
+
content entirely, it does not append.** There is currently no way to read
|
|
73
|
+
back the persona's existing content before overwriting it, so treat each
|
|
74
|
+
field you touch as a full replacement — don't assume you can merge with
|
|
75
|
+
what's already there.
|
|
76
|
+
- **`type: 'Wiki'`** — a standing reference, not a one-off decision:
|
|
77
|
+
"how the deploy pipeline works," "what each config variable does," "the
|
|
78
|
+
object model's relationships" — or a whole project document: an SOW, a
|
|
79
|
+
TDD, anything a Skedulo custom-project engagement produces that's meant
|
|
80
|
+
to stand on its own. Pass `title` and `content`, and optionally `tags`
|
|
81
|
+
and `externalRef` (the Linear/Jira ticket this page originated from, e.g.
|
|
82
|
+
`"SOL-1234"` — pass it when the user mentions a ticket; never guess one).
|
|
83
|
+
Reach for this instead of `type: 'Fact'` when what you learned will
|
|
84
|
+
still be true next month, not just relevant to the task at hand.
|
|
85
|
+
|
|
86
|
+
**Wiki pages can depend on each other** — pass `links` (an array of other
|
|
87
|
+
wiki page UIDs) on a `type: 'Wiki'` save to connect a page to the ones it
|
|
88
|
+
depends on, e.g. a TDD linking to the SOW it was scoped against, or an
|
|
89
|
+
implementation-notes page linking to the TDD it implements. These render as
|
|
90
|
+
a graph in the panel's Wiki tab. There's no separate "dependency" concept —
|
|
91
|
+
a link *is* the dependency edge, just without a label on it (plain
|
|
92
|
+
"linked," not "depends on" vs. "supersedes"). The link is directional (the page you're saving is the source, each UID in
|
|
93
|
+
`links` is a target) and computes backlinks automatically for the reverse
|
|
94
|
+
direction — but only the panel's Wiki tab currently shows either
|
|
95
|
+
direction. Neither `memory_recall` nor any other MCP tool returns a
|
|
96
|
+
page's links or backlinks today, so you can pass `links` when saving, but
|
|
97
|
+
can't currently query them back mid-session — check the panel, or the
|
|
98
|
+
page you already have the UID for, if you need to see them.
|
|
99
|
+
|
|
100
|
+
**If the user hands you a document (PDF, Word, PowerPoint, etc.) to turn
|
|
101
|
+
into a wiki page**, and a `convert_to_markdown` tool is available (from the
|
|
102
|
+
independent `markitdown-mcp` server, if the developer has it registered),
|
|
103
|
+
use it to extract the document's text first — pass it the file's `file://`
|
|
104
|
+
path or URL, not the raw binary. Then distill *that* into a `memory_save`
|
|
105
|
+
call with `type: 'Wiki'`, the same way you would any other source: never
|
|
106
|
+
paste the raw conversion output verbatim as the wiki content. A wiki page's
|
|
107
|
+
content is truncated at a fixed character budget on recall, so a 40-page
|
|
108
|
+
conversion pasted whole defeats the point — pull out what's actually
|
|
109
|
+
standing-reference-worthy, the same judgment call as any other wiki save.
|
|
110
|
+
|
|
111
|
+
New personas are always written `Private`. `memory_save` writes `Private`
|
|
112
|
+
too, unless the attached repo is already linked to a team, in which case it
|
|
113
|
+
writes `Team` — see "Repo-scoped saves default to Team automatically"
|
|
114
|
+
below.
|
|
115
|
+
Skip saving anything that's already obvious from the code, or that only
|
|
116
|
+
mattered to this one conversation.
|
|
117
|
+
|
|
118
|
+
**If a fact/skill makes a claim about code, cite the file it's true of.**
|
|
119
|
+
Nothing in this system re-verifies a saved item against the code it
|
|
120
|
+
describes — there's no watcher, no re-indexing, no expiry. A citation is
|
|
121
|
+
the cheapest possible staleness check available: a reader (human or you, on
|
|
122
|
+
a later recall) can `Read` the named file and confirm the claim still
|
|
123
|
+
holds, instead of having no way to tell a six-minute-old fact from a
|
|
124
|
+
six-month-old one. `LastModifiedDate` is surfaced alongside recalled
|
|
125
|
+
content specifically so this judgment call is possible — use it, and add
|
|
126
|
+
the citation habit on top of it, not instead of it.
|
|
127
|
+
|
|
128
|
+
**Don't wait for a hard stop to save.** "At the end of a task" describes
|
|
129
|
+
*when* the content is ready, not a license to defer the save call until
|
|
130
|
+
you're confident nothing else will happen first. If the session's context
|
|
131
|
+
is running low and compaction looks imminent before you reach a natural
|
|
132
|
+
stopping point, save what's already distilled now — compaction summarizes
|
|
133
|
+
lossily, and a fact that only exists in your reasoning does not survive
|
|
134
|
+
it. A save that happens is worth more than a better-timed one that doesn't.
|
|
135
|
+
|
|
136
|
+
## Mapping an unfamiliar codebase
|
|
137
|
+
|
|
138
|
+
When asked to get oriented in a repo or subsystem you haven't worked in
|
|
139
|
+
before — not on every task, the same "don't call it reflexively" discipline
|
|
140
|
+
as recall — explore it with Read/Grep/Glob as you normally would, then save
|
|
141
|
+
what you found as a skill tagged `ArchitectureMap`:
|
|
142
|
+
|
|
143
|
+
````
|
|
144
|
+
Title: <subsystem name> architecture
|
|
145
|
+
Tags: ['ArchitectureMap']
|
|
146
|
+
Content:
|
|
147
|
+
```codegraph
|
|
148
|
+
nodes: AuthModule, UserService, DbLayer
|
|
149
|
+
edges: AuthModule->UserService, UserService->DbLayer
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
<your actual findings in prose — what depends on what, and why, and
|
|
153
|
+
anything worth flagging before someone changes it>
|
|
154
|
+
````
|
|
155
|
+
|
|
156
|
+
Put the fence **first, before the prose** — recall truncates a skill's
|
|
157
|
+
content at a fixed character budget, and a long map's fence would otherwise
|
|
158
|
+
get cut off along with the "View graph" toggle it enables.
|
|
159
|
+
|
|
160
|
+
The fenced `codegraph` block is the only part a special UI renders (as a
|
|
161
|
+
graph, in the Skills tab) — everything else is free-form prose exactly like
|
|
162
|
+
any other skill. Keep `nodes`/`edges` to plain comma-separated identifiers
|
|
163
|
+
and `A->B` pairs; this is deliberately not a general graph format.
|
|
164
|
+
|
|
165
|
+
**For a client engagement spanning several repos** (a multi-package
|
|
166
|
+
monorepo, or several repos deployed together), prefix a node's identifier
|
|
167
|
+
with `repo:` when it lives in a different repo than the one this map is
|
|
168
|
+
saved against — e.g. `repo:ug-main-package/UniversalGroupFn` calling into
|
|
169
|
+
`repo:ug-sub-package/ResourceClashes`. No special syntax beyond the prefix;
|
|
170
|
+
it's a convention for a human or Claude reading the map later, not
|
|
171
|
+
something the parser treats differently.
|
|
172
|
+
|
|
173
|
+
This map is a snapshot, not a live index — nothing re-runs it
|
|
174
|
+
automatically. If you're working from one that looks old, re-explore and
|
|
175
|
+
save an updated version rather than trusting it blindly.
|
|
176
|
+
|
|
177
|
+
**When your work is something another developer's task depends on, this is
|
|
178
|
+
the format to write for them.** The memory hub has no concept of task
|
|
179
|
+
dependencies — no "blocks"/"blocked by," no notification when your work
|
|
180
|
+
lands (that's Linear's job, not this system's). What it can hold is the
|
|
181
|
+
thing a dependent teammate actually needs once the ticket-level dependency
|
|
182
|
+
clears: what you built exposes, in `ArchitectureMap` shape — nodes/edges
|
|
183
|
+
plus prose on what depends on what and what not to assume. Save it, then
|
|
184
|
+
**ask the human whether to promote it to `Team`** (never do this
|
|
185
|
+
unprompted — see "Sharing" below): a `Private` map is invisible to the
|
|
186
|
+
teammate blocked on it, which defeats the entire point of writing one.
|
|
187
|
+
|
|
188
|
+
## Repo-scoped saves default to Team automatically
|
|
189
|
+
|
|
190
|
+
**A save attached to a repo that's already linked to a team is written
|
|
191
|
+
`Team` visibility automatically — not `Private`.** A save with no repo
|
|
192
|
+
attached (no git remote detected, or the repo isn't linked to any team yet)
|
|
193
|
+
still defaults to `Private`, as before. This isn't a bug and isn't
|
|
194
|
+
optional per-save behavior; it's the platform default now.
|
|
195
|
+
|
|
196
|
+
Why the split: a repo-scoped item's audience is unambiguous — a Team-visible
|
|
197
|
+
item attached to a repo is scoped to that repo's own owning team, not to
|
|
198
|
+
every team you happen to belong to, so there's no reason to keep it hidden
|
|
199
|
+
by default once it's clearly that team's content. A repo-less item has no
|
|
200
|
+
such well-defined audience: `Team` visibility for a repo-less item falls
|
|
201
|
+
back to co-membership across *all* of your teams at once, which could leak
|
|
202
|
+
one client engagement's general notes to another client's team the moment
|
|
203
|
+
you're working both engagements concurrently — so it stays `Private` by
|
|
204
|
+
default instead. A repo that isn't linked to any team yet is treated the
|
|
205
|
+
same as repo-less (no defined audience) until someone links it with
|
|
206
|
+
`memory_linkRepoTeam`.
|
|
207
|
+
|
|
208
|
+
Two consequences worth knowing:
|
|
209
|
+
|
|
210
|
+
- **Older repo-scoped items saved before this default existed are still
|
|
211
|
+
`Private`.** `memory_bulkPromoteRepoScoped` (no arguments) is available to
|
|
212
|
+
catch them up — it promotes all of *your own* existing Private
|
|
213
|
+
Facts/Scenarios/Skills/Wiki pages whose repo is already linked to a team,
|
|
214
|
+
up to `Team` visibility. It doesn't touch repo-less items (nothing to
|
|
215
|
+
catch up there — they're correctly `Private`) or anyone else's items.
|
|
216
|
+
**Mention this tool exists if you notice old repo-scoped Private items,
|
|
217
|
+
but only run it when a human in the conversation explicitly asks you
|
|
218
|
+
to** — same rule as the sharing tools below. Running it more than once
|
|
219
|
+
will also re-promote anything demoted since the last run with
|
|
220
|
+
`memory_setVisibility`, so treat repeat runs as a fresh explicit request
|
|
221
|
+
too, not routine maintenance.
|
|
222
|
+
- **The automatic default can be wrong for a specific item** — something
|
|
223
|
+
repo-scoped that's nonetheless sensitive enough to stay `Private` for
|
|
224
|
+
now. Use `memory_setVisibility` to demote it back, the same way you'd use
|
|
225
|
+
it to promote something the other direction (see below).
|
|
226
|
+
|
|
227
|
+
## Sharing — only on explicit human request
|
|
228
|
+
|
|
229
|
+
- **`memory_setVisibility`** — changes a Fact/Scenario/Skill/Wiki page's
|
|
230
|
+
visibility in either direction: promote to `Team` or `Restricted`, or
|
|
231
|
+
demote back to `Private` (e.g. to undo an automatic Team default, or to
|
|
232
|
+
walk back an earlier promote/grant).
|
|
233
|
+
- **`memory_grantAccess`** — shares a specific item with one named teammate
|
|
234
|
+
(automatically promotes it to `Restricted` if needed).
|
|
235
|
+
|
|
236
|
+
**Call these two tools only when a human explicitly asks, in the current
|
|
237
|
+
conversation, to share, promote, un-share, or demote something** — e.g.
|
|
238
|
+
"share that fact with the team," "give Alice access to this skill," or
|
|
239
|
+
"actually make that one private again." Never call them autonomously based
|
|
240
|
+
on your own judgment that something seems worth sharing (or un-sharing);
|
|
241
|
+
that judgment belongs to the person who owns the item, not to you. This
|
|
242
|
+
rule applies the same way in both directions — a demote is not a safer
|
|
243
|
+
default action just because it narrows visibility.
|
|
244
|
+
|
|
245
|
+
## Targeting a different repo explicitly
|
|
246
|
+
|
|
247
|
+
The repo attached to a save is normally detected from the cwd's git remote,
|
|
248
|
+
automatically, with no argument to pass — see "Save at the end of a task"
|
|
249
|
+
above. Sometimes that's the wrong repo for the content: you're distilling
|
|
250
|
+
curated knowledge that semantically belongs to a *different* repo than the
|
|
251
|
+
one this session is running in (e.g. writing up what you learned about Repo
|
|
252
|
+
B's deploy pipeline while sitting in Repo A, which just happens to be where
|
|
253
|
+
the conversation started). For that case, call `memory_listRepos` (with an
|
|
254
|
+
optional `query` substring to narrow a long list) to find the target repo's
|
|
255
|
+
`uid`, then pass it as the `repo` argument on `memory_save` (any `type`) —
|
|
256
|
+
it overrides the cwd-detected repo for that one save.
|
|
257
|
+
|
|
258
|
+
If you get the repo wrong after the fact — or want to clear a save back to
|
|
259
|
+
repo-less — call `memory_moveResourceRepo` with `resourceType` (`Fact`,
|
|
260
|
+
`Skill`, `Scenario`, or `Wiki`), the item's `resourceId`, and the corrected
|
|
261
|
+
`repo` uid from `memory_listRepos`. Pass `repo: null` instead of a uid to
|
|
262
|
+
clear it back to unscoped rather than reassign it.
|
|
263
|
+
|
|
264
|
+
## Linking a repo to a team
|
|
265
|
+
|
|
266
|
+
A repo you're working in might not be linked to a memory team yet — this
|
|
267
|
+
matters because facts/skills you save only get repo-scoped once it is.
|
|
268
|
+
Call `memory_checkRepoStatus` (no arguments) once per session, the first
|
|
269
|
+
time it's relevant (e.g. before your first save, or if a recall/save
|
|
270
|
+
result looks unscoped when you expected repo context).
|
|
271
|
+
|
|
272
|
+
- If the result has no `needsTeamSelection`, nothing to do — the repo is
|
|
273
|
+
already linked (or none was detected at all).
|
|
274
|
+
- If it has `needsTeamSelection: true`, ask the user directly which team
|
|
275
|
+
this repo belongs to. Offer `agentTeams` as the likely options, and
|
|
276
|
+
mention `teamNameHint` as a guess if it's present — e.g. *"This repo
|
|
277
|
+
isn't linked to a memory team yet. You're on: Welbehealth, Catalyst.
|
|
278
|
+
Does '`<teamNameHint>`' sound right, or is this a different team?"*
|
|
279
|
+
Then call `memory_linkRepoTeam` with whatever they confirm — an
|
|
280
|
+
existing team name from `agentTeams`, or a new one to create.
|
|
281
|
+
- With no repo detected at all (Claude Desktop starts the server with no
|
|
282
|
+
project directory), `memory_linkRepoTeam` still works, but you have to
|
|
283
|
+
name the repo: pass `repoName` alongside `teamName`. `memory_listTeams`
|
|
284
|
+
lists the teams to choose from. Never guess the repo name — ask.
|
|
285
|
+
|
|
286
|
+
This only needs to happen once per repo per agent. Do this on explicit
|
|
287
|
+
user confirmation, not a guess of your own — an SE works several client
|
|
288
|
+
engagements, and guessing wrong silently mixes one client's memory into
|
|
289
|
+
another's.
|
|
290
|
+
|
|
291
|
+
**If the repo is *already* linked to a team you're not yet a member of,
|
|
292
|
+
you're joined to it automatically, no confirmation asked** — the first
|
|
293
|
+
`memory_save` or `memory_checkRepoStatus` call that resolves the repo this
|
|
294
|
+
session comes back with an extra plain-text note when this fires. **Relay
|
|
295
|
+
that note to the user
|
|
296
|
+
verbatim (or close to it) the one time it appears** — it's the only signal
|
|
297
|
+
they get that their saves are now shared with that team, and it won't
|
|
298
|
+
repeat later in the same session even though the join already happened.
|
|
299
|
+
|
|
300
|
+
## If the tools aren't available
|
|
301
|
+
|
|
302
|
+
The memory-hub MCP tools require `memory-hub-mcp` to be registered as an
|
|
303
|
+
MCP server for this session. See that package's own README for setup.
|