@skedulo/memory-hub-mcp 0.2.18 → 0.2.20

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 CHANGED
@@ -60,6 +60,7 @@ have no equivalent there, and nothing is saved unless Claude calls `memory_save`
60
60
  For Claude Code, `setup` installs the `memory-hub` plugin from the repo's marketplace when the
61
61
  `claude` CLI and your GitHub access allow it, and turns its auto-update on; otherwise, or with
62
62
  `--no-plugin`, it installs the hooks and skill directly as described below.
63
+ Older installs (`memory-hub@se-ai-memory-hub`) move to the `memory-hub@memory-hub` ID by themselves at the end of a session, except ones with a pasted token, which keep working and move when you run `setup`.
63
64
 
64
65
  Two commands, no config file to edit. No GitHub access, no git clone, no build step, no npm
65
66
  account:
@@ -11,10 +11,14 @@ set -u
11
11
  FUNCTION_URL="${MEMORY_HUB_FUNCTION_URL:-https://dev-api.test.skl.io/function/memory-hub/memory-hub}"
12
12
  TOKEN="${MEMORY_HUB_MCP_TOKEN:-${CLAUDE_PLUGIN_OPTION_TOKEN:-}}"
13
13
 
14
+ PLUGIN_ID=memory-hub@memory-hub
15
+ OLD_ID_ROOT=false
16
+ case "${CLAUDE_PLUGIN_ROOT:-}" in */se-ai-memory-hub/*) PLUGIN_ID=memory-hub@se-ai-memory-hub; OLD_ID_ROOT=true ;; esac
17
+
14
18
  if [ -z "$TOKEN" ]; then
15
19
  # A plugin install has no setup step of its own, so it says how to add the token.
16
20
  if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ]; then
17
- printf '%s\n' '{"hookSpecificOutput": {"hookEventName": "SessionStart", "additionalContext": "memory-hub plugin: MEMORY_HUB_MCP_TOKEN is not set, so memory is off this session. Tell the user to run `npx -y @skedulo/memory-hub-mcp setup --code` in a terminal (it logs in with sked and stores a token), or to paste a Skedulo API token with /plugin configure memory-hub@se-ai-memory-hub. Then restart Claude Code."}}'
21
+ printf '{"hookSpecificOutput": {"hookEventName": "SessionStart", "additionalContext": "memory-hub plugin: MEMORY_HUB_MCP_TOKEN is not set, so memory is off this session. Tell the user to run `npx -y @skedulo/memory-hub-mcp setup --code` in a terminal (it logs in with sked and stores a token), or to paste a Skedulo API token with /plugin configure %s. Then restart Claude Code."}}\n' "$PLUGIN_ID"
18
22
  fi
19
23
  exit 0
20
24
  fi
@@ -410,6 +414,10 @@ if [ -n "$REPO_UID" ]; then
410
414
  else
411
415
  DIAG="${DIAG} · repo: not linked"
412
416
  fi
417
+ if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ]; then
418
+ PLUGIN_VERSION=$(jq -r '.version // empty' "$CLAUDE_PLUGIN_ROOT/.claude-plugin/plugin.json" 2>/dev/null || true)
419
+ [ -n "$PLUGIN_VERSION" ] && DIAG="${DIAG} · plugin ${PLUGIN_VERSION}"
420
+ fi
413
421
  DIAG="${DIAG}_"
414
422
 
415
423
  # Unconditional, not gated behind having any facts to show, so an agent that finds nothing below still knows to check back in before finishing a task.
@@ -568,10 +576,25 @@ share_nudge() {
568
576
  printf '%d of your private notes on team repos look shareable; say "share them" to review and share.' "$n"
569
577
  }
570
578
 
579
+ plugin_move_nudge() {
580
+ $OLD_ID_ROOT || return 0
581
+ local stamp="$STATE_DIR/plugin-move-nudge.stamp" now last
582
+ # The log also holds stderr, so the result is the last line shaped like one.
583
+ grep -E '^[0-9T:.Z-]+ (moved|skipped|failed) ' "$STATE_DIR/plugin-move.log" 2>/dev/null | tail -n1 | grep -qF 'pasted token' || return 0
584
+ now=$(date +%s)
585
+ last=$(cat "$stamp" 2>/dev/null)
586
+ case "$last" in ''|*[!0-9]*) last=0 ;; esac
587
+ [ $((now - last)) -ge 604800 ] || return 0
588
+ printf '%s\n' "$now" > "$stamp" 2>/dev/null || return 0
589
+ printf '%s' 'memory-hub has a new plugin name. Tell the user they can move to it by running `npx -y @skedulo/memory-hub-mcp@latest setup` in a terminal; their current install keeps working.'
590
+ }
591
+
571
592
  NUDGE=$(catch_up_nudge 2>/dev/null || true)
572
593
  [ -z "$NUDGE" ] || NUDGE="${NUDGE}${NL}${NL}"
573
594
  SHARE_NUDGE=$(share_nudge 2>/dev/null || true)
574
595
  [ -z "$SHARE_NUDGE" ] || NUDGE="${NUDGE}${SHARE_NUDGE}${NL}${NL}"
596
+ MOVE_NUDGE=$(plugin_move_nudge 2>/dev/null || true)
597
+ [ -z "$MOVE_NUDGE" ] || NUDGE="${NUDGE}${MOVE_NUDGE}${NL}${NL}"
575
598
 
576
599
  REMINDER="## Reminder${NL}"
577
600
  REMINDER="${REMINDER}${SAVE_LINE}${NL}"
@@ -7,11 +7,57 @@ if [ -n "${MEMORY_HUB_STOP_HOOK_ACTIVE:-}" ]; then
7
7
  exit 0
8
8
  fi
9
9
 
10
+ start_plugin_move() {
11
+ [ "$EVENT" = SessionEnd ] || return 0
12
+ case "${CLAUDE_PLUGIN_ROOT:-}" in */se-ai-memory-hub/*) ;; *) return 0 ;; esac
13
+ local cli stamp="$STATE_DIR/plugin-move.stamp" lock="$STATE_DIR/plugin-move.lock" today
14
+ today=$(date +%F)
15
+ [ "$(cat "$stamp" 2>/dev/null)" != "$today" ] || return 0
16
+ cli=$(head -n1 "$HOME/.claude/memory-hub-hook/cli-path" 2>/dev/null)
17
+ # An older npm build would start the MCP server instead of failing on the unknown command.
18
+ [ -n "$cli" ] && grep -qF migrate-plugin "$cli" 2>/dev/null || return 0
19
+ if [ -n "${MEMORY_HUB_MIGRATE_CMD:-}" ]; then
20
+ set -- sh -c "$MEMORY_HUB_MIGRATE_CMD"
21
+ else
22
+ command -v node >/dev/null 2>&1 || return 0
23
+ set -- node "$cli" migrate-plugin
24
+ fi
25
+ mkdir -p "$STATE_DIR" 2>/dev/null || return 0
26
+ [ -z "$(find "$lock" -maxdepth 0 -mmin +60 2>/dev/null)" ] || rmdir "$lock" 2>/dev/null
27
+ mkdir "$lock" 2>/dev/null || return 0
28
+ # A session that ended just before may have finished and released the lock after our stamp check.
29
+ if [ "$(cat "$stamp" 2>/dev/null)" = "$today" ]; then
30
+ rmdir "$lock" 2>/dev/null
31
+ return 0
32
+ fi
33
+ if ! printf '%s\n' "$today" > "$stamp" 2>/dev/null; then
34
+ rmdir "$lock" 2>/dev/null
35
+ return 0
36
+ fi
37
+ # HUP is ignored from the fork on and the wrapper leaves the session's process group, so the lock release survives a signal to that group.
38
+ set -- sh -c 'lock=$1 log=$2; shift 2; trap "" HUP; "$@" >>"$log" 2>&1 </dev/null; rmdir "$lock" 2>/dev/null' sh "$lock" "$STATE_DIR/plugin-move.log" "$@"
39
+ if command -v perl >/dev/null 2>&1; then
40
+ set -- perl -e '$SIG{HUP} = "IGNORE"; setpgrp(0, 0); exec @ARGV' "$@"
41
+ fi
42
+ trap '' HUP
43
+ "$@" >/dev/null 2>&1 </dev/null &
44
+ trap - HUP
45
+ }
46
+
10
47
  opted_in() {
11
48
  case "$(printf '%s' "${MEMORY_HUB_AUTO_CAPTURE:-}" | tr '[:upper:]' '[:lower:]')" in 1|true|yes|on) return 0 ;; esac
12
49
  [ "${CLAUDE_PLUGIN_OPTION_CAPTURE:-}" = true ]
13
50
  }
14
51
 
52
+ command -v jq >/dev/null 2>&1 || exit 0
53
+
54
+ INPUT=$(cat)
55
+ EVENT=$(printf '%s' "$INPUT" | jq -r '.hook_event_name // empty' 2>/dev/null)
56
+
57
+ umask 077
58
+ STATE_DIR="${MEMORY_HUB_STATE_DIR:-$HOME/.claude/memory-hub-hook/state}"
59
+ start_plugin_move
60
+
15
61
  # The plugin registers this hook for everyone, so there it waits for an opt-in; a hand registration is the opt-in.
16
62
  if [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && ! opted_in; then
17
63
  exit 0
@@ -19,7 +65,6 @@ fi
19
65
 
20
66
  TOKEN="${MEMORY_HUB_MCP_TOKEN:-${CLAUDE_PLUGIN_OPTION_TOKEN:-}}"
21
67
  [ -n "$TOKEN" ] || exit 0
22
- command -v jq >/dev/null 2>&1 || exit 0
23
68
 
24
69
  # Same default as session-start.sh; change both together.
25
70
  FUNCTION_URL="${MEMORY_HUB_FUNCTION_URL:-https://dev-api.test.skl.io/function/memory-hub/memory-hub}"
@@ -30,16 +75,12 @@ SESSION_END_MIN_LINES=8
30
75
  case "$INTERVAL_MIN" in ''|*[!0-9]*) INTERVAL_MIN=30 ;; esac
31
76
  case "$MIN_NEW_LINES" in ''|*[!0-9]*) MIN_NEW_LINES=40 ;; esac
32
77
 
33
- INPUT=$(cat)
34
- EVENT=$(printf '%s' "$INPUT" | jq -r '.hook_event_name // empty' 2>/dev/null)
35
78
  case "$EVENT" in Stop|SessionEnd) ;; *) exit 0 ;; esac
36
79
  SESSION_ID=$(printf '%s' "$INPUT" | jq -r '.session_id // empty' 2>/dev/null | tr -cd 'A-Za-z0-9_-')
37
80
  [ -n "$SESSION_ID" ] || exit 0
38
81
  TRANSCRIPT_PATH=$(printf '%s' "$INPUT" | jq -r '.transcript_path // empty' 2>/dev/null)
39
82
  INPUT_CWD=$(printf '%s' "$INPUT" | jq -r '.cwd // empty' 2>/dev/null)
40
83
 
41
- umask 077
42
- STATE_DIR="${MEMORY_HUB_STATE_DIR:-$HOME/.claude/memory-hub-hook/state}"
43
84
  mkdir -p "$STATE_DIR/logs" 2>/dev/null || exit 0
44
85
  STATE_FILE="$STATE_DIR/capture-$SESSION_ID.json"
45
86
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ask
3
- description: Use when someone asks what the team, a project or the hub knows, e.g. "what do we know about the Welbehealth rostering rules?", "ask the hub how job allocation works", "why did we stop syncing contacts for Acme?", "has anyone solved the token refresh problem?". It answers from hub knowledge in plain language, inside or outside a project folder, fixes what it relies on when the code or a cited document moved, and saves what it learns when the hub did not know.
3
+ description: Use when someone asks what the team, a project or the hub knows, e.g. "what do we know about the Welbehealth rostering rules?", "ask the hub how job allocation works", "why did we stop syncing contacts for Acme?", "has anyone solved the token refresh problem?", "where is the Acme release at?", "which test cases cover manual entry?", "is bulk cancel in scope for Acme?". It answers as a delivery lead, developer, QA or consultant, picked from the question, from hub knowledge, inside or outside a project folder, fixes what it relies on when the code, a cited document, a ticket or a PR moved, and saves what it learns when the hub did not know.
4
4
  argument-hint: "<question>"
5
5
  ---
6
6
 
@@ -8,13 +8,14 @@ argument-hint: "<question>"
8
8
 
9
9
  Answer a question from what the hub already knows, for anyone: a developer in a repo, or someone in
10
10
  Claude Desktop with no project folder open. Keeping knowledge current is one of the hub's core
11
- principles, so this skill also fixes what it relies on when the code or a cited document moved, and grows the hub when
12
- it did not know.
11
+ principles, so this skill also fixes what it relies on when the code, a cited document, a ticket or
12
+ a PR moved, and grows the hub when it did not know. It answers in the role the question needs
13
+ (delivery lead, developer, QA or consultant), which changes what it reads and how it answers.
13
14
 
14
15
  - **Plain language.** The person may not be a developer. Short sentences, no jargon they did not
15
- use, and no tool names in the answer.
16
+ use, and no tool names in the answer, unless the role's file says otherwise.
16
17
  - **Ask only for: joining a team, which repo when it is unclear, and which sources to read**
17
- (steps 3, 8 and 6). Everything else you decide. Joining is the person's choice, so never join
18
+ (steps 3, 9 and 7). Everything else you decide. Joining is the person's choice, so never join
18
19
  without their yes.
19
20
  - **Never paste SOW or Slack text.** Say what it means in your own words and name where it came from.
20
21
  - **Never reveal others' Private items.** The hub never returns them; never guess at them either.
@@ -36,7 +37,33 @@ server is older than this release. Stop, do nothing else, and say it must be upd
36
37
 
37
38
  ## 1. Read the question
38
39
 
39
- Note the project or customer it names, if any, and pick the types to search:
40
+ Note the project or customer it names, if any. A link names it too: a Linear project or ticket, a
41
+ GitHub PR, or a Confluence or Drive document is the question's subject. Find the project's repos
42
+ with `memory_listRepos`, called without a query, by keeping those whose team is the project or
43
+ customer: a repo's own name often does not include it.
44
+
45
+ Then pick the role to answer as, and read its file in this skill's folder before step 2 (as a
46
+ prompt, the role files follow this skill):
47
+
48
+ - **delivery** (`references/delivery.md`): progress, dates, milestones, risks, releases, what is
49
+ blocked or left;
50
+ - **developer** (`references/developer.md`): how the code works, where something lives, how to
51
+ change or fix it;
52
+ - **qa** (`references/qa.md`): test cases, UAT, defects, what to test or what is untested;
53
+ - **consultant** (`references/consultant.md`): rules, scope, what the customer asked for or
54
+ agreed, what not to build, bug or change.
55
+
56
+ The person's own words decide first ("as a PM", "as a dev", "as QA", "as a BA"), then the question.
57
+ When the question fits none clearly, use the default in the persona's `preferences` (a line
58
+ "ask role: <role>", from `memory_sessionContext`); with none, answer without a role file. A question
59
+ that plainly spans two roles uses both files, never more. When you inferred the role, name it in
60
+ the answer's first line so the person can redirect it.
61
+
62
+ When the person asks to make a role their default, take the persona's `preferences` from
63
+ `memory_sessionContext`, add or replace its "ask role: <role>" line, and pass the whole text back
64
+ with `memory_upsertPersona`, which replaces the field.
65
+
66
+ Pick the types to search, starting with those the role's file names:
40
67
 
41
68
  - **Facts and Scenarios** for decisions, history and "why did we…";
42
69
  - **Skills** for how-tos and architecture maps ("how does X work", "how do I…");
@@ -46,7 +73,7 @@ When unsure, search all four.
46
73
 
47
74
  Note too whether you have a checkout of the project's repo and the project-knowledge skill
48
75
  (`memory-hub:project-knowledge` when installed as a plugin). In Claude Desktop you have neither, and
49
- steps 4 to 6 say what changes.
76
+ steps 4 to 7 say what changes.
50
77
 
51
78
  ## 2. Search the hub
52
79
 
@@ -66,7 +93,7 @@ teams the person is on) before treating it as unrecorded. If none of their teams
66
93
  say that its knowledge may be shared with its team only, and that saying "join the <team> team"
67
94
  shows it, using the project's name as the team name when you know no better. Call `memory_joinTeam`
68
95
  only after they say yes, since joining changes who reads what; then go back to step 2. If it says no
69
- such team exists, or they do not say yes, carry on to step 6 with what you have.
96
+ such team exists, or they do not say yes, carry on to step 7 with what you have.
70
97
 
71
98
  ## 4. Check what you rely on
72
99
 
@@ -100,7 +127,7 @@ answer that the hub's memory was behind it. Then:
100
127
  - **Project page:** it is never edited here. Without a checkout of the project's repo or the
101
128
  project-knowledge skill (for example in Claude Desktop), never hand off: answer from the reread
102
129
  document, save a Fact on the page's repo that names the page and entry ID and says what the
103
- document now says (step 8), and tell the person a developer can update the project page with
130
+ document now says (step 9), and tell the person a developer can update the project page with
104
131
  "update the <Project> knowledge". With both, hand the change to project-knowledge's targeted
105
132
  update, which owns the page and its Sources line. Hand over what you took from the reread document as the change list. Add the document's
106
133
  new version (Confluence `version.number`, or Drive `modifiedTime`) only when you read the whole
@@ -118,7 +145,74 @@ text: say what it means in your own words and name the document.
118
145
 
119
146
  Keep each fix (uid and what changed) for the closing line.
120
147
 
121
- ## 6. When the hub has nothing
148
+ ## 6. Check the live state of work
149
+
150
+ A memory about work in progress is a snapshot. Tickets move and PRs merge or close after it was
151
+ saved, and work that never went through a hub session (a teammate's, a QA move, a PR closed by hand)
152
+ is not in the hub at all. Do this step:
153
+
154
+ - always for the delivery and QA roles;
155
+ - for any role, when the question is about progress, status, or what is open, done or released;
156
+ - for any role, when the answer rests on an item that states a ticket or PR status ("Status as
157
+ of…", "PR #n open", "In QA").
158
+
159
+ The role's file says what else to list.
160
+
161
+ 1. **List recent work.** Pick the window: the last 14 days, or since the oldest status date among
162
+ the items you rely on when that is earlier, never more than 30 days. Pick the repos: those of
163
+ the items you rely on and, for a progress or status question that names a project, its team's
164
+ repos from `memory_listRepos`. In each, list the PRs opened, merged or closed in the window:
165
+ `gh pr list -R <owner/name> --state all --limit 100 --search "updated:>=<date>" --json
166
+ number,title,state,author,mergedAt,closedAt,updatedAt,headRefName`, and drop those whose author
167
+ is a bot (`author.is_bot`, or a login ending in `[bot]`). For a status question that names a
168
+ project, also list the tickets updated in the window, at most 100 in all: those in the Linear
169
+ projects, or under the parent tickets, of the tickets the memories cite (a name search misses
170
+ stories whose titles do not name the customer), plus a search by the project or customer name.
171
+ 2. **Check what the memories cite.** Match each ticket and PR an item you rely on names against
172
+ those lists, and look up only the ones they missed: at most 20 calls in all, and flag the rest
173
+ as not checked.
174
+ - A ticket (its `externalRef`, or a ticket ID in its text): one Linear or Jira call for its
175
+ status, assignee and last update.
176
+ - A PR written as `<owner/name>#<n>` or as a link: `gh pr view <n> -R <owner/name> --json
177
+ state,mergedAt,closedAt,title,headRefName`.
178
+ - A bare `#<n>` may be in any of the project's repos. Take a PR as the one cited only when its
179
+ title or branch names a ticket the item cites; otherwise say in the answer that you could not
180
+ tell which PR it is.
181
+ 3. **Read more only where it matters.** Read the comments of at most five tickets: those whose status
182
+ changed since the hub's note, those whose PR was closed without merging, and those waiting on a
183
+ decision. Read nothing else.
184
+
185
+ Then:
186
+
187
+ - **Which state wins.** A merged PR or a recorded release beats any ticket status. A ticket beats
188
+ the memory only when the ticket's last update is later than the memory's status date (its "as of"
189
+ date, else its `lastModifiedDate`). Never move a memory backward on a ticket alone, for example
190
+ from shipped to "Ready for Prod": tickets are often left behind. When a ticket disagrees and does
191
+ not win, say in the answer that the ticket may be behind, and change nothing.
192
+ - **A memory whose status is now wrong:** add a status note to it under the guide's "Stale
193
+ memories" rules: one `memory_update` that adds a dated line at the top saying where the work now
194
+ stands and where that was seen ("UPDATE <date> (GitHub): PR #123 closed without merging"), and
195
+ keeps the rest. Say what is true now; never write that the rest is out of date. Flag, instead of
196
+ editing, an item those rules say you cannot edit. A project page is never edited here: handle it
197
+ as step 5 handles a project page that is behind its document. Status notes are not among step
198
+ 4's three fixes. At most five status notes per question; flag the rest in the answer.
199
+ - **What the hub had no memory of** goes into step 9 as the project's status snapshot: one Fact on
200
+ the project's repo that starts "<Project> status snapshot, <date>", with ticket statuses, PR
201
+ states, open decisions and newly seen tickets, and `externalRef` set to the main ticket when
202
+ there is one. Find the last snapshot first (`memory_recall type=Fact scope=team` for
203
+ "<Project> status snapshot") and pass its uid as `supersedes`, so the hub keeps one.
204
+ - **In the answer,** say which live sources you checked and when. Anything you did not check keeps
205
+ the date the hub gave it.
206
+
207
+ Without a shell (for example in Claude Desktop), check PRs through a GitHub connector if one is
208
+ attached. If Linear, Jira or GitHub cannot be reached, say in the answer what was not checked and
209
+ use the memories as they are. Never paste ticket comments: say what they mean and name the ticket.
210
+
211
+ Keep each correction (uid and what changed) for the closing line.
212
+
213
+ ## 7. When the hub has nothing
214
+
215
+ If step 6 found the answer, skip this step: answer (step 8) and save it (step 9).
122
216
 
123
217
  If nothing found answers the question, say so plainly, then ask which sources to read:
124
218
  links or names of documents, tickets, Slack channels or repos. In the
@@ -130,23 +224,23 @@ team when it is about a project.
130
224
  - Read only the sources they give.
131
225
  - If they say "search everything" after that warning, and you have a checkout of the project's
132
226
  repo and the project-knowledge skill, run it for that project, then answer from the pages it
133
- saved. It saves those pages itself: step 8 saves nothing more. Without them (for example in
227
+ saved. It saves those pages itself: step 9 saves nothing more. Without them (for example in
134
228
  Claude Desktop), explain that searching everything needs Claude Code opened in the project's
135
229
  repo, and offer to read the sources they name instead.
136
- - If they give no sources, answer that the hub does not know, and end with "Nothing changed."
230
+ - If they give no sources, answer that the hub does not know, and close as step 10 says.
137
231
 
138
- Then answer (step 7), and save what you found (step 8) without asking again.
232
+ Then answer (step 8), and save what you found (step 9) without asking again.
139
233
 
140
- ## 7. Answer
234
+ ## 8. Answer
141
235
 
142
- Answer briefly, in plain language. Back each claim with the item it came from: its uid, its title
236
+ Answer briefly, shaped as the role's file says, in plain language unless it says otherwise. Back each claim with the item it came from: its uid, its title
143
237
  and, when it has one, its source as `<owner/name>@<short commit>`. Say plainly what the hub does not
144
- know. Mention anything flagged in steps 4 and 5.
238
+ know. Mention anything flagged in steps 4 to 6.
145
239
 
146
- ## 8. Save what was learned
240
+ ## 9. Save what was learned
147
241
 
148
- Save only what came from the sources read in steps 5 and 6, not what the hub already had;
149
- corrections found in steps 4 and 5 are already made by their `memory_update`. One `memory_save` per
242
+ Save only what came from the sources read in steps 5 to 7, not what the hub already had;
243
+ corrections found in steps 4 to 6 are already made by their `memory_update`. One `memory_save` per
150
244
  durable point: a Fact for a decision or finding, a Skill for a how-to. Pass `supersedes` with the old
151
245
  uid when it replaces an existing memory, and a `source` when it came from code.
152
246
 
@@ -157,7 +251,7 @@ source.
157
251
  Decide the visibility by the guide's "What to share" section
158
252
  (`memory_getSkillGuide section="What to share"`), and state the choice and the reason in the answer.
159
253
 
160
- ## 9. Close
254
+ ## 10. Close
161
255
 
162
256
  End with the one line of what changed: each update and save by uid, with the visibility of each
163
257
  save, or "Nothing changed."
@@ -0,0 +1,27 @@
1
+ # Answering as a consultant or BA
2
+
3
+ For business rules, scope, what the customer asked for or agreed, what not to build, and whether a
4
+ request is a bug or a change.
5
+
6
+ ## Search first
7
+
8
+ - The project's Rules pages (rules with IDs and tiers), its Don't build page, and its Reference
9
+ pages (overview, glossary, workflows).
10
+ - Facts on decisions and on the customer's answers to questions.
11
+ - `<Project> › Sources`, for the documents behind each rule.
12
+
13
+ ## Live sources
14
+
15
+ - The documents the rules cite (SOW, TDD, design pages), through step 5. Step 5's checks matter
16
+ most for this role: a changed SOW or TDD changes the scope.
17
+ - Tickets only for a decision recorded in their comments: at most five tickets' comments.
18
+
19
+ ## Answer
20
+
21
+ - Answer with the rule IDs that decide it, and say what each means in your own words.
22
+ - In or out of scope: name the rule, the Don't build entry, or the document behind it. When nothing
23
+ covers it, say so: it is a new requirement, which needs a change request.
24
+ - Bug or change: a bug breaks an agreed rule or acceptance criterion; anything else the customer
25
+ now wants is a change. Name what it was measured against.
26
+
27
+ Never paste SOW text, and never name commercial terms (prices, rates, budgets).
@@ -0,0 +1,47 @@
1
+ # Answering as a delivery lead
2
+
3
+ For progress, dates, milestones, risks, releases, and what is blocked or left. Step 6 always runs
4
+ for this role.
5
+
6
+ ## Search first
7
+
8
+ - Facts and Scenarios on the project's repos: the latest "<Project> status snapshot", release
9
+ Facts, and plan Scenarios.
10
+ - The project's Reference pages only when the answer needs its scope.
11
+
12
+ ## Live sources (in step 6)
13
+
14
+ Find the Linear project: the one the question links, else the project of the tickets the memories
15
+ cite (at most three projects, the most cited first).
16
+
17
+ 1. Get the project with its milestones (name, target date, progress), its status, target date and
18
+ lead.
19
+ 2. Read its latest project update: health, date and what it says. Never paste it.
20
+ 3. List its issues: every open one whatever its last update, since stalled work is what a status
21
+ answer most needs, and those completed or canceled in step 6's window. They count toward step
22
+ 6's 100 tickets.
23
+ 4. Release and deploy tickets done in the window say what reached which environment.
24
+
25
+ Then check PRs as step 6 says.
26
+
27
+ ## When Linear itself is behind
28
+
29
+ Project status, milestone progress and target dates are set by hand and are often left behind.
30
+ Flag these in the answer as "Linear may be behind", and never correct the hub from them:
31
+
32
+ - a milestone whose target date has passed with progress under 100%;
33
+ - a project status that does not match its issues, for example Backlog while stories are in UAT;
34
+ - a latest project update older than 14 days.
35
+
36
+ ## Answer
37
+
38
+ 1. One line on where the project stands against its next milestone date (on track, at risk or
39
+ behind) and why.
40
+ 2. Milestones: the last one passed and the next two, each with its target date and progress.
41
+ 3. Work by state: done or released (with the environment and version when the hub knows them), in
42
+ UAT or QA, in progress, waiting (and on whom: the customer, or another team's ticket), not
43
+ started.
44
+ 4. Risks and decisions waiting, each naming its ticket.
45
+ 5. What was not checked, and each "Linear may be behind" flag.
46
+
47
+ Ticket IDs are fine in the answer; tool names are not.
@@ -0,0 +1,27 @@
1
+ # Answering as a developer
2
+
3
+ For how the code works, where something lives, why it behaves as it does, and how to change or fix
4
+ it.
5
+
6
+ ## Search first
7
+
8
+ - Skills (architecture maps and how-tos) and Facts with a `source`, on the project's repos.
9
+ - The project's Rules pages only when a rule constrains the change; cite the rule's ID.
10
+
11
+ ## Live sources
12
+
13
+ - The code. With a checkout, confirm the answer in the files the items you rely on cite, read at
14
+ `origin/<default>` (`git show origin/<default>:<path>`), never the working tree. Read at most
15
+ five other files to fill a gap. Step 4's staleness check matters most for this role.
16
+ - Without a checkout, say the answer was not checked against the code, and give each item's
17
+ "verified <n> days ago".
18
+ - PRs only when the question is about a change in flight, through step 6.
19
+
20
+ ## Answer
21
+
22
+ - Lead with the answer, then where it lives: `<owner/name>@<short commit>:<path>` for each place,
23
+ and the uid of each memory used.
24
+ - Name the gotchas the memories record, with their uids.
25
+ - File paths, function names, commands and tool names are fine for this role. Use no jargon the
26
+ code and the question do not use.
27
+ - When the code contradicts a memory, the code wins: say so, and fix the memory under step 4.
@@ -0,0 +1,33 @@
1
+ # Answering as QA
2
+
3
+ For test cases, UAT, defects, regressions, and what to test or what is untested. Step 6 runs for
4
+ this role, for the stories the question is about.
5
+
6
+ ## Search first
7
+
8
+ - The project's Rules pages for the feature: the expected behaviour, with rule IDs. These are what
9
+ a test checks.
10
+ - Facts and Scenarios on known issues, defects and UAT findings.
11
+
12
+ ## Live sources (in step 6)
13
+
14
+ For each story the question is about (named by ID or title, or the feature's stories in its Linear
15
+ project), at most 15 stories:
16
+
17
+ - its status and its acceptance criteria (the ticket's description: read it, never paste it);
18
+ - its sub-tickets, above all its test-case tickets (titles like "Create test cases - …"), and their
19
+ state;
20
+ - defects: bug tickets linked to it, or in its project naming the feature, and their state.
21
+
22
+ Take these from one listing of the project's issues, which gives each sub-ticket's parent, rather
23
+ than a call per story. Read comments only on stories that failed QA or UAT or were sent back, within
24
+ step 6's five.
25
+
26
+ ## Answer
27
+
28
+ - For each story: its state, its test cases (done, canceled or missing) and its open defects.
29
+ - Gaps: stories in QA or UAT with no done test-case ticket, rules no story or test covers, and
30
+ known issues the hub records that have no ticket.
31
+ - What to test next, riskiest first, each tied to a rule ID or an acceptance criterion.
32
+
33
+ Never paste test steps or ticket text: say what they mean and name the ticket.
@@ -26,7 +26,8 @@ function skillPaths(assetsDir) {
26
26
  function readSkillBody(assetsDir) {
27
27
  for (const path of skillPaths(assetsDir)) {
28
28
  try {
29
- return (0, fs_1.readFileSync)(path, 'utf-8').replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/, '').trim();
29
+ const body = (0, fs_1.readFileSync)(path, 'utf-8').replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/, '').trim();
30
+ return [body, ...roleFiles((0, path_1.dirname)(path))].join('\n\n');
30
31
  }
31
32
  catch {
32
33
  continue;
@@ -34,6 +35,18 @@ function readSkillBody(assetsDir) {
34
35
  }
35
36
  return undefined;
36
37
  }
38
+ // A prompt has no skill folder to read from, so the role files ride along.
39
+ function roleFiles(skillDir) {
40
+ const folder = (0, path_1.join)(skillDir, 'references');
41
+ let names;
42
+ try {
43
+ names = (0, fs_1.readdirSync)(folder).filter((name) => name.endsWith('.md')).sort();
44
+ }
45
+ catch {
46
+ return [];
47
+ }
48
+ return names.map((name) => `## references/${name}\n\n${(0, fs_1.readFileSync)((0, path_1.join)(folder, name), 'utf-8').trim()}`);
49
+ }
37
50
  function askPromptText(question, assetsDir) {
38
51
  const body = readSkillBody(assetsDir) || FALLBACK;
39
52
  return `${body}\n\n## The question\n\n${question.trim()}\n`;
package/dist/cli.js CHANGED
@@ -4,7 +4,12 @@
4
4
  // load when MEMORY_HUB_MCP_TOKEN is unset — which is exactly the state `setup` exists
5
5
  // to fix, so it can never be reached from there.
6
6
  const command = process.argv[2];
7
- if (command === 'setup') {
7
+ if (command === '--version' || command === '-v') {
8
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
9
+ const { packageVersion } = require('./version');
10
+ console.log(packageVersion());
11
+ }
12
+ else if (command === 'setup') {
8
13
  // eslint-disable-next-line @typescript-eslint/no-var-requires
9
14
  const { runSetup } = require('./setup');
10
15
  runSetup(process.argv.slice(3)).catch((error) => {
@@ -67,6 +72,16 @@ else if (command === 'sweep') {
67
72
  process.exitCode = 1;
68
73
  });
69
74
  }
75
+ else if (command === 'migrate-plugin') {
76
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
77
+ const { runMigratePlugin } = require('./migrate-plugin');
78
+ runMigratePlugin(process.argv.slice(3)).then((code) => {
79
+ process.exitCode = code;
80
+ }, (error) => {
81
+ console.error(error instanceof Error ? error.message : String(error));
82
+ process.exitCode = 1;
83
+ });
84
+ }
70
85
  else if (command === '--help' || command === '-h') {
71
86
  console.log(`memory-hub-mcp — MCP server for the Memory Hub
72
87
 
package/dist/index.js CHANGED
@@ -22,6 +22,7 @@ const guide_check_1 = require("./guide-check");
22
22
  const revise_1 = require("./revise");
23
23
  const similar_notice_1 = require("./similar-notice");
24
24
  const session_context_1 = require("./session-context");
25
+ const version_1 = require("./version");
25
26
  const asset_sync_1 = require("./asset-sync");
26
27
  const tags_1 = require("./tags");
27
28
  const ask_prompt_1 = require("./ask-prompt");
@@ -55,7 +56,7 @@ const INSTRUCTIONS = [
55
56
  'knowledge about Skedulo\'s platform, products, tools or practices; Private only with a',
56
57
  'stated reason. Unsure between Org and Team: Team. Say the choice and the reason.',
57
58
  ].join(' ');
58
- const server = new mcp_js_1.McpServer({ name: 'memory-hub-mcp', version: '0.1.0' }, { instructions: INSTRUCTIONS });
59
+ const server = new mcp_js_1.McpServer({ name: 'memory-hub-mcp', version: (0, version_1.packageVersion)() }, { instructions: INSTRUCTIONS });
59
60
  // Detected from this process's own working directory, not from anything the model
60
61
  // types. Resolved lazily on the first save so startup never blocks on git or the
61
62
  // network, and degrades to undefined (an unscoped save) on any failure.
@@ -340,7 +341,12 @@ server.tool('memory_checkSources', "Find memories that may be stale against a re
340
341
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
341
342
  });
342
343
  server.tool('memory_sessionContext', "Load this developer's saved memory-hub context: their persona profile, facts, skills, and — when the session has a repo — its wiki pages. Call once at the start of a conversation. If the result has persona.configured false, offer once to set up their persona with memory_upsertPersona, then drop it for the rest of the conversation. On Claude Code the SessionStart hook already covers facts and skills; call this there for the persona, or if that context is missing.", {}, async () => {
343
- const context = await (0, session_context_1.buildSessionContext)({ client, currentRepoUid: repoContext.currentRepoUid, staleness: currentStaleness() });
344
+ const context = await (0, session_context_1.buildSessionContext)({
345
+ client,
346
+ currentRepoUid: repoContext.currentRepoUid,
347
+ staleness: currentStaleness(),
348
+ serverVersion: (0, version_1.packageVersion)(),
349
+ });
344
350
  return { content: [...embeddingNoticeBlocks(), { type: 'text', text: JSON.stringify(context) }] };
345
351
  });
346
352
  (0, asset_sync_1.refreshInstalledAssets)();
@@ -0,0 +1,219 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runMigratePlugin = exports.migratePlugin = void 0;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ const setup_1 = require("./setup");
7
+ const has = (value, key) => typeof value === 'object' && value !== null && Object.prototype.hasOwnProperty.call(value, key);
8
+ const message = (error) => (error instanceof Error ? error.message : String(error));
9
+ function parseObject(output) {
10
+ const start = output.indexOf('{');
11
+ const end = output.lastIndexOf('}');
12
+ if (start < 0 || end < start)
13
+ return undefined;
14
+ try {
15
+ return JSON.parse(output.slice(start, end + 1));
16
+ }
17
+ catch {
18
+ return undefined;
19
+ }
20
+ }
21
+ // readJson reads a torn or hand-broken file as {}, and writing that back would wipe the user's settings.
22
+ function readStrict(path) {
23
+ if (!(0, fs_1.existsSync)(path))
24
+ return {};
25
+ try {
26
+ const value = JSON.parse((0, fs_1.readFileSync)(path, 'utf8'));
27
+ return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : undefined;
28
+ }
29
+ catch {
30
+ return undefined;
31
+ }
32
+ }
33
+ function updateSettings(path, change) {
34
+ const settings = readStrict(path);
35
+ if (!settings)
36
+ return false;
37
+ change(settings);
38
+ (0, setup_1.writeJson)(path, settings);
39
+ return true;
40
+ }
41
+ function pick(source, keys) {
42
+ return Object.fromEntries(keys.filter((key) => has(source, key)).map((key) => [key, JSON.parse(JSON.stringify(source[key]))]));
43
+ }
44
+ function putBack(settings, field, keys, before) {
45
+ for (const key of keys) {
46
+ if (has(before, key))
47
+ (settings[field] ||= {})[key] = before[key];
48
+ else if (has(settings[field], key))
49
+ delete settings[field][key];
50
+ }
51
+ }
52
+ function logLine(status, reason) {
53
+ return `${new Date().toISOString()} ${status} ${reason.replace(/\s+/g, ' ')}`;
54
+ }
55
+ function migratePlugin(deps) {
56
+ const { run, configDir } = deps;
57
+ const finish = (status, reason) => {
58
+ deps.log(logLine(status, reason));
59
+ return { status, reason };
60
+ };
61
+ const settingsPath = (0, path_1.join)(configDir, 'settings.json');
62
+ const installedPath = (0, path_1.join)(configDir, 'plugins', 'installed_plugins.json');
63
+ const knownPath = (0, path_1.join)(configDir, 'plugins', 'known_marketplaces.json');
64
+ const retireOld = (notes) => {
65
+ let left;
66
+ try {
67
+ if (readStrict(settingsPath)?.enabledPlugins?.[setup_1.LEGACY_PLUGIN_ID] === true) {
68
+ const disabled = run(['plugin', 'disable', setup_1.LEGACY_PLUGIN_ID]);
69
+ if (disabled.status !== 0)
70
+ left = `disable failed (${(0, setup_1.lastLine)(disabled.output)})`;
71
+ }
72
+ if (left === undefined) {
73
+ const removed = run(['plugin', 'marketplace', 'remove', setup_1.LEGACY_MARKETPLACE_NAME]);
74
+ if (removed.status !== 0)
75
+ left = (0, setup_1.lastLine)(removed.output);
76
+ }
77
+ }
78
+ catch (error) {
79
+ left = message(error);
80
+ }
81
+ if (left === undefined)
82
+ return;
83
+ notes.push(`old marketplace not removed: ${left}`);
84
+ try {
85
+ const turnedOff = updateSettings(settingsPath, (current) => {
86
+ if (current.enabledPlugins?.[setup_1.LEGACY_PLUGIN_ID] === true)
87
+ current.enabledPlugins[setup_1.LEGACY_PLUGIN_ID] = false;
88
+ });
89
+ if (!turnedOff)
90
+ notes.push(`${setup_1.LEGACY_PLUGIN_ID} still enabled, settings unreadable`);
91
+ }
92
+ catch (error) {
93
+ notes.push(`${setup_1.LEGACY_PLUGIN_ID} still enabled (${message(error)})`);
94
+ }
95
+ };
96
+ const withNotes = (reason, notes) => (notes.length > 0 ? `${reason} (${notes.join('; ')})` : reason);
97
+ const plugins = (0, setup_1.readJson)(installedPath).plugins || {};
98
+ if (!has(plugins, setup_1.LEGACY_PLUGIN_ID))
99
+ return finish('skipped', has(plugins, setup_1.PLUGIN_ID) ? 'already moved' : 'not installed');
100
+ const settings = readStrict(settingsPath);
101
+ if (!settings)
102
+ return finish('skipped', 'settings unreadable');
103
+ const records = Array.isArray(plugins[setup_1.LEGACY_PLUGIN_ID]) ? plugins[setup_1.LEGACY_PLUGIN_ID] : [];
104
+ const userScopeOnly = records.length > 0 && records.every((record) => record?.scope === 'user');
105
+ if (has(plugins, setup_1.PLUGIN_ID)) {
106
+ if (!userScopeOnly)
107
+ return finish('skipped', 'not user scope');
108
+ // A move cut off after the new install leaves both IDs loaded until the old marketplace goes.
109
+ const known = readStrict(knownPath);
110
+ if (!known)
111
+ return finish('skipped', 'marketplaces unreadable');
112
+ if (!has(known, setup_1.LEGACY_MARKETPLACE_NAME) || !(0, setup_1.isHubSource)(known[setup_1.MARKETPLACE_NAME]?.source))
113
+ return finish('skipped', 'already moved');
114
+ const newRecords = Array.isArray(plugins[setup_1.PLUGIN_ID]) ? plugins[setup_1.PLUGIN_ID] : [];
115
+ const newActive = newRecords.some((record) => record?.scope === 'user') && settings.enabledPlugins?.[setup_1.PLUGIN_ID] === true;
116
+ if (!newActive)
117
+ return finish('skipped', 'new install not active');
118
+ const notes = [];
119
+ retireOld(notes);
120
+ return finish('moved', withNotes('retired the old install', notes));
121
+ }
122
+ if (settings.enabledPlugins?.[setup_1.LEGACY_PLUGIN_ID] !== true)
123
+ return finish('skipped', 'disabled');
124
+ if (!userScopeOnly)
125
+ return finish('skipped', 'not user scope');
126
+ const repoCopy = (0, path_1.join)(configDir, 'plugins', 'marketplaces', setup_1.LEGACY_MARKETPLACE_NAME, '.claude-plugin', 'marketplace.json');
127
+ if ((0, setup_1.readJson)(repoCopy).name !== setup_1.MARKETPLACE_NAME)
128
+ return finish('skipped', 'not released yet');
129
+ const declared = settings.extraKnownMarketplaces?.[setup_1.LEGACY_MARKETPLACE_NAME];
130
+ if (!(0, setup_1.isHubSource)(declared?.source))
131
+ return finish('skipped', 'old marketplace not in settings');
132
+ const configured = run(['plugin', 'configure', '--json', setup_1.LEGACY_PLUGIN_ID]);
133
+ const options = configured.status === 0 ? parseObject(configured.output) : undefined;
134
+ if (!options || !Array.isArray(options.configured))
135
+ return finish('failed', 'could not read the plugin options, nothing changed');
136
+ const settingsToken = settings.env?.MEMORY_HUB_MCP_TOKEN;
137
+ const hasSettingsToken = typeof settingsToken === 'string' && settingsToken.trim() !== '';
138
+ if (options.configured.includes('token') && !hasSettingsToken)
139
+ return finish('skipped', 'pasted token');
140
+ if (run(['plugin', 'marketplace', 'update', setup_1.LEGACY_MARKETPLACE_NAME]).status !== 0)
141
+ return finish('skipped', 'cannot reach the marketplace');
142
+ const knownAtStart = readStrict(knownPath);
143
+ if (!knownAtStart || !has(knownAtStart, setup_1.LEGACY_MARKETPLACE_NAME))
144
+ return finish('skipped', 'marketplaces unreadable');
145
+ const capture = options.inputs?.capture === true ? ['--config', 'capture=true'] : [];
146
+ const ref = declared.source.ref || setup_1.MARKETPLACE_REF;
147
+ const knownBefore = new Set(Object.keys(knownAtStart));
148
+ const marketplacesBefore = pick(settings.extraKnownMarketplaces, [setup_1.MARKETPLACE_NAME]);
149
+ const enabledBefore = pick(settings.enabledPlugins, [setup_1.PLUGIN_ID]);
150
+ const addAndInstall = () => {
151
+ const added = run(['plugin', 'marketplace', 'add', `${setup_1.MARKETPLACE_GIT_URL}#${ref}`]);
152
+ if (added.status !== 0)
153
+ return `add failed (${(0, setup_1.lastLine)(added.output)})`;
154
+ if (!(0, setup_1.isHubSource)((0, setup_1.readJson)(knownPath)[setup_1.MARKETPLACE_NAME]?.source))
155
+ return `add failed (the repo did not register as ${setup_1.MARKETPLACE_NAME})`;
156
+ const installed = run(['plugin', 'install', setup_1.PLUGIN_ID, ...capture]);
157
+ if (installed.status !== 0)
158
+ return `install failed (${(0, setup_1.lastLine)(installed.output)})`;
159
+ if ((0, setup_1.installedPluginId)(installedPath) !== setup_1.PLUGIN_ID)
160
+ return `install failed (claude did not list ${setup_1.PLUGIN_ID})`;
161
+ return undefined;
162
+ };
163
+ const undoNew = () => {
164
+ const known = (0, setup_1.readJson)(knownPath);
165
+ for (const name of Object.keys(known)) {
166
+ if (name !== setup_1.LEGACY_MARKETPLACE_NAME && !knownBefore.has(name) && (0, setup_1.isHubSource)(known[name]?.source))
167
+ run(['plugin', 'marketplace', 'remove', name]);
168
+ }
169
+ const restored = updateSettings(settingsPath, (current) => {
170
+ putBack(current, 'extraKnownMarketplaces', [setup_1.MARKETPLACE_NAME], marketplacesBefore);
171
+ putBack(current, 'enabledPlugins', [setup_1.PLUGIN_ID], enabledBefore);
172
+ });
173
+ return restored ? `${setup_1.LEGACY_PLUGIN_ID} untouched` : `${setup_1.LEGACY_PLUGIN_ID} untouched, settings unreadable and left as they are`;
174
+ };
175
+ let failure;
176
+ try {
177
+ failure = addAndInstall();
178
+ }
179
+ catch (error) {
180
+ failure = `add or install failed (${message(error)})`;
181
+ }
182
+ if (failure !== undefined) {
183
+ let outcome;
184
+ try {
185
+ outcome = undoNew();
186
+ }
187
+ catch (error) {
188
+ outcome = `undoing the new marketplace failed (${message(error)})`;
189
+ }
190
+ return finish('failed', `${failure}; ${outcome}`);
191
+ }
192
+ const notes = [];
193
+ retireOld(notes);
194
+ if (declared.autoUpdate === true) {
195
+ try {
196
+ const set = updateSettings(settingsPath, (current) => {
197
+ const known = (current.extraKnownMarketplaces ||= {});
198
+ known[setup_1.MARKETPLACE_NAME] = { source: { source: 'git', url: setup_1.MARKETPLACE_GIT_URL, ref }, ...known[setup_1.MARKETPLACE_NAME], autoUpdate: true };
199
+ });
200
+ if (!set)
201
+ notes.push('auto-update not carried over, settings unreadable');
202
+ }
203
+ catch (error) {
204
+ notes.push(`auto-update not carried over (${message(error)})`);
205
+ }
206
+ }
207
+ return finish('moved', withNotes(`${setup_1.LEGACY_PLUGIN_ID} to ${setup_1.PLUGIN_ID}, loads at the next session`, notes));
208
+ }
209
+ exports.migratePlugin = migratePlugin;
210
+ async function runMigratePlugin(_argv) {
211
+ const log = (line) => console.log(line);
212
+ const run = (0, setup_1.claudeRunner)();
213
+ if (!run) {
214
+ log(logLine('skipped', 'claude CLI not on PATH'));
215
+ return 0;
216
+ }
217
+ return migratePlugin({ run, configDir: (0, setup_1.claudeConfigDir)(), log }).status === 'failed' ? 1 : 0;
218
+ }
219
+ exports.runMigratePlugin = runMigratePlugin;
@@ -59,6 +59,7 @@ async function buildSessionContext(deps) {
59
59
  ? await soft(Promise.all(groups.map((raws) => toItems(raws, staleness))), plain, soft_1.STALENESS_TIMEOUT_MS)
60
60
  : plain;
61
61
  return {
62
+ serverVersion: deps.serverVersion,
62
63
  persona,
63
64
  facts: { self: factsS, team: factsT, repo: factsR },
64
65
  skills: { self: skillsS, team: skillsT, repo: skillsR },
package/dist/setup.js CHANGED
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runSetup = exports.runCapture = exports.registerPromptHook = exports.registerSessionStartHook = exports.removeMcpServer = exports.removeCopiedAssets = exports.setCapture = exports.captureOn = exports.CAPTURE_FLAG = exports.unregisterHooks = exports.installPlugin = exports.enableMarketplaceAutoUpdate = exports.removeUserEnv = exports.writeUserEnv = exports.writeDesktopConfig = exports.writeMcpServer = exports.functionUrl = exports.desktopConfigPath = exports.mcpLaunch = exports.pluginInstalled = exports.PLUGIN_ID = exports.MARKETPLACE_REF = exports.MARKETPLACE_REPO = exports.MARKETPLACE_NAME = exports.launchPath = exports.PACKAGE_SPEC = void 0;
3
+ exports.runSetup = exports.runCapture = exports.registerPromptHook = exports.registerSessionStartHook = exports.removeMcpServer = exports.removeCopiedAssets = exports.setCapture = exports.captureOn = exports.CAPTURE_FLAG = exports.unregisterHooks = exports.claudeRunner = exports.installPlugin = exports.enableMarketplaceAutoUpdate = exports.removeUserEnv = exports.writeUserEnv = exports.writeDesktopConfig = exports.writeMcpServer = exports.functionUrl = exports.writeJson = exports.readJson = exports.desktopConfigPath = exports.mcpLaunch = exports.lastLine = exports.isHubSource = exports.pluginInstalled = exports.installedPluginId = exports.installedPluginIds = exports.claudeConfigDir = exports.LEGACY_PLUGIN_ID = exports.PLUGIN_ID = exports.MARKETPLACE_REF = exports.MARKETPLACE_GIT_URL = exports.MARKETPLACE_REPO = exports.LEGACY_MARKETPLACE_NAME = exports.MARKETPLACE_NAME = exports.launchPath = exports.PACKAGE_SPEC = void 0;
4
4
  const child_process_1 = require("child_process");
5
5
  const fs_1 = require("fs");
6
6
  const os_1 = require("os");
7
7
  const path_1 = require("path");
8
8
  const readline_1 = require("readline");
9
9
  const asset_sync_1 = require("./asset-sync");
10
+ const migrate_plugin_1 = require("./migrate-plugin");
10
11
  const DEFAULT_API_HOST = 'dev-api.test.skl.io';
11
12
  const DEFAULT_TENANT = 'memory-hub';
12
13
  const SKED_CONFIG = (0, path_1.join)((0, os_1.homedir)(), '.config', 'sked', 'config.json');
@@ -19,15 +20,48 @@ function launchPath(execPath, currentPath = process.env.PATH || '', sep = path_1
19
20
  return [...new Set([(0, path_1.dirname)(execPath), ...currentPath.split(sep).filter(Boolean)])].join(sep);
20
21
  }
21
22
  exports.launchPath = launchPath;
22
- exports.MARKETPLACE_NAME = 'se-ai-memory-hub';
23
+ exports.MARKETPLACE_NAME = 'memory-hub';
24
+ exports.LEGACY_MARKETPLACE_NAME = 'se-ai-memory-hub';
23
25
  exports.MARKETPLACE_REPO = 'Skedulo/se-ai-memory-hub';
26
+ // While the old entry holds the repo by its github shorthand, adding the shorthand again is a no-op; the git URL registers alongside it.
27
+ exports.MARKETPLACE_GIT_URL = `https://github.com/${exports.MARKETPLACE_REPO}.git`;
24
28
  // main only moves when a release is merged into it, so installs and updates both get released hooks.
25
29
  exports.MARKETPLACE_REF = 'main';
26
30
  exports.PLUGIN_ID = `memory-hub@${exports.MARKETPLACE_NAME}`;
27
- function pluginInstalled(path = (0, path_1.join)((0, os_1.homedir)(), '.claude', 'plugins', 'installed_plugins.json')) {
28
- return Object.prototype.hasOwnProperty.call(readJson(path).plugins || {}, exports.PLUGIN_ID);
31
+ exports.LEGACY_PLUGIN_ID = `memory-hub@${exports.LEGACY_MARKETPLACE_NAME}`;
32
+ // `||`, not `??`: Claude Code treats an empty CLAUDE_CONFIG_DIR as the current directory.
33
+ function claudeConfigDir(env = process.env, home = (0, os_1.homedir)()) {
34
+ return env.CLAUDE_CONFIG_DIR || (0, path_1.join)(home, '.claude');
35
+ }
36
+ exports.claudeConfigDir = claudeConfigDir;
37
+ function installedPluginIds(path = (0, path_1.join)(claudeConfigDir(), 'plugins', 'installed_plugins.json')) {
38
+ const plugins = readJson(path).plugins || {};
39
+ return [exports.PLUGIN_ID, exports.LEGACY_PLUGIN_ID].filter((id) => Object.prototype.hasOwnProperty.call(plugins, id));
40
+ }
41
+ exports.installedPluginIds = installedPluginIds;
42
+ function installedPluginId(path) {
43
+ return installedPluginIds(path)[0];
44
+ }
45
+ exports.installedPluginId = installedPluginId;
46
+ function pluginInstalled(path) {
47
+ return installedPluginId(path) !== undefined;
29
48
  }
30
49
  exports.pluginInstalled = pluginInstalled;
50
+ function isHubSource(source) {
51
+ const s = (source || {});
52
+ const repo = exports.MARKETPLACE_REPO.toLowerCase();
53
+ if (typeof s.repo === 'string')
54
+ return s.repo.toLowerCase() === repo;
55
+ if (typeof s.url !== 'string')
56
+ return false;
57
+ const url = s.url.toLowerCase().replace(/\.git$/, '');
58
+ return url.endsWith(`/${repo}`) || url.endsWith(`:${repo}`);
59
+ }
60
+ exports.isHubSource = isHubSource;
61
+ function lastLine(output) {
62
+ return output.trim().split('\n').pop() || 'no output';
63
+ }
64
+ exports.lastLine = lastLine;
31
65
  // Hosts don't launch MCP servers from a login shell, so the command must be an absolute path.
32
66
  function mcpLaunch(options) {
33
67
  if (!options.autoUpdate)
@@ -58,12 +92,14 @@ function readJson(path) {
58
92
  return {};
59
93
  }
60
94
  }
95
+ exports.readJson = readJson;
61
96
  function writeJson(path, value) {
62
97
  (0, fs_1.mkdirSync)((0, path_1.dirname)(path), { recursive: true });
63
98
  if ((0, fs_1.existsSync)(path))
64
99
  (0, fs_1.writeFileSync)(`${path}.bak`, (0, fs_1.readFileSync)(path));
65
100
  (0, fs_1.writeFileSync)(path, `${JSON.stringify(value, null, 2)}\n`);
66
101
  }
102
+ exports.writeJson = writeJson;
67
103
  function ask(question) {
68
104
  const rl = (0, readline_1.createInterface)({ input: process.stdin, output: process.stdout });
69
105
  return new Promise((done) => rl.question(question, (answer) => { rl.close(); done(answer.trim()); }));
@@ -186,11 +222,11 @@ function registerHook(path, event, hookPath, script, timeout, extra = {}) {
186
222
  return { already, replaced: already ? 0 : ours.length };
187
223
  }
188
224
  // Third-party marketplaces don't auto-update unless this documented settings key says so.
189
- function enableMarketplaceAutoUpdate(path) {
225
+ function enableMarketplaceAutoUpdate(path, name = exports.MARKETPLACE_NAME) {
190
226
  const settings = readJson(path);
191
227
  const known = (settings.extraKnownMarketplaces ||= {});
192
- const entry = known[exports.MARKETPLACE_NAME] || {};
193
- known[exports.MARKETPLACE_NAME] = {
228
+ const entry = known[name] || {};
229
+ known[name] = {
194
230
  ...entry,
195
231
  source: entry.source || { source: 'github', repo: exports.MARKETPLACE_REPO, ref: exports.MARKETPLACE_REF },
196
232
  autoUpdate: true,
@@ -198,16 +234,23 @@ function enableMarketplaceAutoUpdate(path) {
198
234
  writeJson(path, settings);
199
235
  }
200
236
  exports.enableMarketplaceAutoUpdate = enableMarketplaceAutoUpdate;
201
- function installPlugin(run, settingsPath, installedPath) {
202
- const lastLine = (output) => output.trim().split('\n').pop() || 'no output';
237
+ // The repo's marketplace.json decides the name `marketplace add` registers, and main may still carry the old one.
238
+ function registeredMarketplace(knownPath) {
239
+ const known = readJson(knownPath);
240
+ const names = Object.keys(known).filter((name) => isHubSource(known[name]?.source));
241
+ return names.includes(exports.MARKETPLACE_NAME) ? exports.MARKETPLACE_NAME : names[0] || exports.MARKETPLACE_NAME;
242
+ }
243
+ function installPlugin(run, settingsPath, installedPath = (0, path_1.join)(claudeConfigDir(), 'plugins', 'installed_plugins.json'), knownPath = (0, path_1.join)((0, path_1.dirname)(installedPath), 'known_marketplaces.json')) {
203
244
  const added = run(['plugin', 'marketplace', 'add', `${exports.MARKETPLACE_REPO}#${exports.MARKETPLACE_REF}`]);
204
245
  if (added.status !== 0)
205
246
  return { ok: false, reason: lastLine(added.output) };
206
- enableMarketplaceAutoUpdate(settingsPath);
207
- const installed = run(['plugin', 'install', exports.PLUGIN_ID]);
247
+ const name = registeredMarketplace(knownPath);
248
+ enableMarketplaceAutoUpdate(settingsPath, name);
249
+ const id = `memory-hub@${name}`;
250
+ const installed = run(['plugin', 'install', id]);
208
251
  if (installed.status !== 0)
209
252
  return { ok: false, reason: lastLine(installed.output) };
210
- return pluginInstalled(installedPath) ? { ok: true } : { ok: false, reason: 'claude reported success but did not list the plugin' };
253
+ return installedPluginId(installedPath) === id ? { ok: true } : { ok: false, reason: 'claude reported success but did not list the plugin' };
211
254
  }
212
255
  exports.installPlugin = installPlugin;
213
256
  // Without repo access git would otherwise wait on a password prompt or an SSH host-key question.
@@ -227,6 +270,7 @@ function claudeRunner() {
227
270
  return { status: result.status, output: `${result.stdout || ''}${result.stderr || ''}` };
228
271
  };
229
272
  }
273
+ exports.claudeRunner = claudeRunner;
230
274
  // The plugin brings its own hooks, so setup's copies would run every hook twice.
231
275
  // Empty event lists are dropped too: left behind, they read as "the hooks are missing".
232
276
  function removeHookCommands(settings, event, matches) {
@@ -394,7 +438,7 @@ async function chooseHosts() {
394
438
  }
395
439
  function existingToken(hosts) {
396
440
  if (hosts.includes('code')) {
397
- const settings = readJson((0, path_1.join)((0, os_1.homedir)(), '.claude', 'settings.json'));
441
+ const settings = readJson((0, path_1.join)(claudeConfigDir(), 'settings.json'));
398
442
  const token = settings.env?.MEMORY_HUB_MCP_TOKEN;
399
443
  const url = readJson((0, path_1.join)((0, os_1.homedir)(), '.claude.json')).mcpServers?.['memory-hub']?.env?.MEMORY_HUB_FUNCTION_URL;
400
444
  if (token)
@@ -425,13 +469,13 @@ async function askCapture(current) {
425
469
  return answer.startsWith('y');
426
470
  }
427
471
  async function runCapture(argv = []) {
428
- const settingsPath = (0, path_1.join)((0, os_1.homedir)(), '.claude', 'settings.json');
472
+ const settingsPath = (0, path_1.join)(claudeConfigDir(), 'settings.json');
429
473
  const plugin = pluginInstalled();
430
474
  const hookPath = (0, path_1.join)((0, asset_sync_1.installDirs)().hookDir, 'session-stop.sh');
431
475
  const choice = argv[0];
432
476
  const pluginNote = "If you turned on the plugin's Auto-capture option in /plugin configure, that keeps it on too.";
433
477
  if (choice !== 'on' && choice !== 'off') {
434
- console.log(`auto-capture is ${captureOn(settingsPath) ? 'on' : 'off'} in ~/.claude/settings.json.`);
478
+ console.log(`auto-capture is ${captureOn(settingsPath) ? 'on' : 'off'} in ${settingsPath}.`);
435
479
  if (plugin)
436
480
  console.log(pluginNote);
437
481
  console.log('Usage: memory-hub-mcp capture on|off');
@@ -447,7 +491,7 @@ async function runCapture(argv = []) {
447
491
  console.log('auto-capture is on: after long stretches and at session end, a background Claude run, using your Claude usage, saves what the session learned. New memories are Private; updates keep their visibility.');
448
492
  }
449
493
  else if (captureOn(settingsPath)) {
450
- console.log('auto-capture is still on: a session-stop.sh entry under Stop or SessionEnd in ~/.claude/settings.json keeps it running. Remove that entry by hand to stop it.');
494
+ console.log(`auto-capture is still on: a session-stop.sh entry under Stop or SessionEnd in ${settingsPath} keeps it running. Remove that entry by hand to stop it.`);
451
495
  }
452
496
  else {
453
497
  console.log('auto-capture is off.');
@@ -457,6 +501,60 @@ async function runCapture(argv = []) {
457
501
  console.log('Restart Claude Code to pick this up.');
458
502
  }
459
503
  exports.runCapture = runCapture;
504
+ const QUIET_SKIPS = ['not installed', 'already moved', 'not released yet'];
505
+ const MOVE_LOCK_STALE_MS = 60 * 60 * 1000;
506
+ // The same lock the SessionEnd hook takes, so setup and a background move never overlap.
507
+ function withMoveLock(fn) {
508
+ const stateDir = process.env.MEMORY_HUB_STATE_DIR || (0, path_1.join)((0, os_1.homedir)(), '.claude', 'memory-hub-hook', 'state');
509
+ const lock = (0, path_1.join)(stateDir, 'plugin-move.lock');
510
+ try {
511
+ (0, fs_1.mkdirSync)(stateDir, { recursive: true });
512
+ if ((0, fs_1.existsSync)(lock) && Date.now() - (0, fs_1.statSync)(lock).mtimeMs > MOVE_LOCK_STALE_MS)
513
+ (0, fs_1.rmdirSync)(lock);
514
+ (0, fs_1.mkdirSync)(lock);
515
+ }
516
+ catch {
517
+ return false;
518
+ }
519
+ try {
520
+ fn();
521
+ }
522
+ finally {
523
+ try {
524
+ (0, fs_1.rmdirSync)(lock);
525
+ }
526
+ catch { }
527
+ }
528
+ return true;
529
+ }
530
+ function moveLegacyPlugin() {
531
+ const say = (line) => {
532
+ console.log();
533
+ console.log('==> Claude Code plugin');
534
+ console.log(line);
535
+ };
536
+ const run = claudeRunner();
537
+ if (!run) {
538
+ say(` kept ${exports.LEGACY_PLUGIN_ID}: the claude CLI is not on PATH to move it to ${exports.PLUGIN_ID}.`);
539
+ return;
540
+ }
541
+ let result;
542
+ const locked = withMoveLock(() => {
543
+ result = (0, migrate_plugin_1.migratePlugin)({ run, configDir: claudeConfigDir(), log: () => { } });
544
+ });
545
+ if (!locked || !result) {
546
+ say(` a move of ${exports.LEGACY_PLUGIN_ID} to ${exports.PLUGIN_ID} is already running; re-run setup in a minute if it is still listed.`);
547
+ return;
548
+ }
549
+ if (result.status === 'moved' && result.reason.startsWith('retired'))
550
+ say(` removed the old ${exports.LEGACY_PLUGIN_ID} install; ${exports.PLUGIN_ID} stays.`);
551
+ else if (result.status === 'moved')
552
+ say(` moved ${exports.LEGACY_PLUGIN_ID} to its new ID ${exports.PLUGIN_ID}; it loads at the next session.`);
553
+ else if (result.status === 'failed')
554
+ say(` couldn't move ${exports.LEGACY_PLUGIN_ID} to ${exports.PLUGIN_ID}: ${result.reason}.`);
555
+ else if (!QUIET_SKIPS.includes(result.reason))
556
+ say(` kept ${exports.LEGACY_PLUGIN_ID} (${result.reason}).`);
557
+ }
460
558
  async function runSetup(argv = []) {
461
559
  console.log('==> Setting up the memory hub');
462
560
  let hosts;
@@ -522,7 +620,7 @@ async function runSetup(argv = []) {
522
620
  else {
523
621
  console.log(' pinned to this install. Update with `npm i -g @skedulo/memory-hub-mcp` and re-run setup.');
524
622
  }
525
- const settingsPath = (0, path_1.join)((0, os_1.homedir)(), '.claude', 'settings.json');
623
+ const settingsPath = (0, path_1.join)(claudeConfigDir(), 'settings.json');
526
624
  let plugin = hosts.includes('code') && pluginInstalled();
527
625
  if (hosts.includes('code') && !plugin && !argv.includes('--no-plugin')) {
528
626
  console.log();
@@ -540,13 +638,22 @@ async function runSetup(argv = []) {
540
638
  : ` couldn't install it (${result.reason}), so the hooks and skill are installed directly instead.`);
541
639
  }
542
640
  }
641
+ if (plugin && installedPluginIds().includes(exports.LEGACY_PLUGIN_ID)) {
642
+ // Before the move: a settings token is what lets an install with a pasted token move.
643
+ writeUserEnv(settingsPath, env);
644
+ moveLegacyPlugin();
645
+ plugin = pluginInstalled();
646
+ if (!plugin)
647
+ console.log(' no memory-hub plugin is installed now, so the hooks and skill are installed directly instead.');
648
+ }
543
649
  if (plugin) {
544
650
  console.log();
545
651
  console.log('==> Claude Code');
546
- console.log(` the ${exports.PLUGIN_ID} plugin brings the MCP server, hooks and skill, so setup only`);
547
- console.log(' stores your token for them, and keeps the plugin on auto-update.');
548
- enableMarketplaceAutoUpdate(settingsPath);
549
652
  writeUserEnv(settingsPath, env);
653
+ const pluginId = installedPluginId() ?? exports.PLUGIN_ID;
654
+ console.log(` the ${pluginId} plugin brings the MCP server, hooks and skill, so setup only`);
655
+ console.log(' stores your token for them, and keeps the plugin on auto-update.');
656
+ enableMarketplaceAutoUpdate(settingsPath, pluginId === exports.LEGACY_PLUGIN_ID ? exports.LEGACY_MARKETPLACE_NAME : exports.MARKETPLACE_NAME);
550
657
  const hooks = unregisterHooks(settingsPath);
551
658
  const server = removeMcpServer((0, path_1.join)((0, os_1.homedir)(), '.claude.json'));
552
659
  const copies = removeCopiedAssets(settingsPath);
@@ -565,16 +672,16 @@ async function runSetup(argv = []) {
565
672
  console.log(` MCP server -> ${shown}`);
566
673
  // The hook is a shell script, so it reads the token from the environment Claude
567
674
  // Code gives it, not from the MCP server's env block.
568
- writeUserEnv((0, path_1.join)((0, os_1.homedir)(), '.claude', 'settings.json'), env);
675
+ writeUserEnv(settingsPath, env);
569
676
  const { hookPath, promptHookPath } = installAssets();
570
- const { already, replaced } = registerSessionStartHook((0, path_1.join)((0, os_1.homedir)(), '.claude', 'settings.json'), hookPath);
677
+ const { already, replaced } = registerSessionStartHook(settingsPath, hookPath);
571
678
  const note = already
572
679
  ? ' (already registered)'
573
680
  : replaced > 0
574
681
  ? ` (replaced ${replaced} earlier registration${replaced > 1 ? 's' : ''})`
575
682
  : '';
576
683
  console.log(` SessionStart hook -> ${hookPath}${note}`);
577
- const prompt = registerPromptHook((0, path_1.join)((0, os_1.homedir)(), '.claude', 'settings.json'), promptHookPath);
684
+ const prompt = registerPromptHook(settingsPath, promptHookPath);
578
685
  console.log(` UserPromptSubmit hook -> ${promptHookPath}${prompt.already ? ' (already registered)' : ''}`);
579
686
  console.log(` skills -> ~/.claude/skills/ (${(0, asset_sync_1.packagedSkills)(ASSETS).join(', ')})`);
580
687
  }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.packageVersion = void 0;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ // Same relative path from src (ts-jest) and from dist.
7
+ function packageVersion(dir = __dirname) {
8
+ try {
9
+ return JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(dir, '..', 'package.json'), 'utf8')).version ?? 'unknown';
10
+ }
11
+ catch {
12
+ return 'unknown';
13
+ }
14
+ }
15
+ exports.packageVersion = packageVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skedulo/memory-hub-mcp",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "description": "MCP server for the Memory Hub: recall and save developer memory from Claude Code and Claude Desktop.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
package/skill-guide.md CHANGED
@@ -95,10 +95,9 @@ list is prose, kept in sync by hand.
95
95
  developer prefers to work emerged this session (a standing preference, a
96
96
  recurring decision pattern). Pass only the field(s) that changed
97
97
  (`preferences`, `decisions`, `patterns`) — **this replaces each field's
98
- content entirely, it does not append.** There is currently no way to read
99
- back the persona's existing content before overwriting it, so treat each
100
- field you touch as a full replacement — don't assume you can merge with
101
- what's already there.
98
+ content entirely, it does not append.** To add to a field, read its
99
+ current text from `memory_sessionContext`'s `persona` and pass back the
100
+ whole text with your change.
102
101
  - **`type: 'Wiki'`** — a standing reference, not a one-off decision:
103
102
  "how the deploy pipeline works," "what each config variable does," "the
104
103
  object model's relationships" — or a whole project document: an SOW, a
@@ -551,6 +550,10 @@ Before relying on a stale item, verify, then flag, then fix:
551
550
  Rules:
552
551
 
553
552
  - At most three fixes per task. Flag the rest to the developer.
553
+ - A status note is not a fix: one dated line added at the top of a memory that says where a ticket
554
+ or PR now stands and where that was seen (`UPDATE <date> (GitHub): PR #123 closed without
555
+ merging`), the rest left as it is. At most five status notes per task, under the same rules on
556
+ who may edit what. Flag the rest.
554
557
  - `source.commit` only moves forward: only when `git merge-base --is-ancestor <old> <new>` passes,
555
558
  and never onto an unmerged commit. When `target` is `HEAD` (no `origin/<default>` to compare
556
559
  with), never move `source`; flag it instead.