@skedulo/memory-hub-mcp 0.2.20 → 0.2.22

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.
@@ -601,7 +601,8 @@ REMINDER="${REMINDER}${SAVE_LINE}${NL}"
601
601
  REMINDER="${REMINDER}Invoke the memory-hub skill during this session: memory_recall before${NL}"
602
602
  REMINDER="${REMINDER}investigating something that smells like prior context, and memory_save${NL}"
603
603
  REMINDER="${REMINDER}(type \"Fact\" or \"Scenario\") once a task produces a durable decision, root${NL}"
604
- REMINDER="${REMINDER}cause, or fix worth keeping for next time.${NL}${NL}"
604
+ REMINDER="${REMINDER}cause, or fix worth keeping for next time. On an error, memory_recall${NL}"
605
+ REMINDER="${REMINDER}scope=all with its text first: another project may have the fix.${NL}${NL}"
605
606
  REMINDER="${REMINDER}${STALE_MCP}${NUDGE}"
606
607
  NOTICES=$(collect_capture_notices "$STATE_DIR" "$((REMAINING - ${#REMINDER} - ${#DIAG}))" 2>/dev/null || true)
607
608
  [ -z "$NOTICES" ] || NOTICES="${NOTICES}${NL}${NL}"
@@ -14,9 +14,9 @@ a PR moved, and grows the hub when it did not know. It answers in the role the q
14
14
 
15
15
  - **Plain language.** The person may not be a developer. Short sentences, no jargon they did not
16
16
  use, and no tool names in the answer, unless the role's file says otherwise.
17
- - **Ask only for: joining a team, which repo when it is unclear, and which sources to read**
18
- (steps 3, 9 and 7). Everything else you decide. Joining is the person's choice, so never join
19
- without their yes.
17
+ - **Ask only for: which sources to read, which repo when it is unclear, and joining a team**
18
+ (steps 7 and 9; joining only when a save needs a team's repo). Everything else you decide.
19
+ Joining is the person's choice, so never join without their yes.
20
20
  - **Never paste SOW or Slack text.** Say what it means in your own words and name where it came from.
21
21
  - **Never reveal others' Private items.** The hub never returns them; never guess at them either.
22
22
  - **End every answer with one line** listing what you updated and saved, by uid, for example
@@ -77,23 +77,24 @@ steps 4 to 7 say what changes.
77
77
 
78
78
  ## 2. Search the hub
79
79
 
80
- 1. For each type picked, `memory_recall` with `scope=team`, using the question's key words. It
81
- also returns the person's own items, Private ones included.
80
+ 1. For each type picked, `memory_recall` with `scope=all`, using the question's key words. It
81
+ returns every project's shared items, from every team, plus the person's own, Private ones
82
+ included. Each item names its `repoName` and `teamName`.
82
83
  2. When a project is named, also list its pages, which works outside a repo too:
83
- `memory_list type=Wiki titlePrefix="<Project> ›"` (paginate with `offset` until you have
84
- `total`). Pick the pages the question needs.
85
- 3. Read with `memory_get` every item you will rely on whose text came back cut short.
86
- 4. When an item has `superseded: true`, prefer the newer memory that replaced it; look it up if it
84
+ `memory_list type=Wiki scope=all titlePrefix="<Project> ›"` (paginate with `offset` until you
85
+ have `total`). Pick the pages the question needs.
86
+ 3. When the question is about one project and an answer comes from another, say which project it
87
+ came from and treat it as precedent, not as that project's rule. Keep the other customer's
88
+ names, data and terms out of anything meant for this one.
89
+ 4. Read with `memory_get` every item you will rely on whose text came back cut short.
90
+ 5. When an item has `superseded: true`, prefer the newer memory that replaced it; look it up if it
87
91
  was not returned.
88
92
 
89
93
  ## 3. When a named project's pages are not found
90
94
 
91
- If the question names a project and step 2 found none of its pages, check `memory_listTeams` (the
92
- teams the person is on) before treating it as unrecorded. If none of their teams is the project's,
93
- say that its knowledge may be shared with its team only, and that saying "join the <team> team"
94
- shows it, using the project's name as the team name when you know no better. Call `memory_joinTeam`
95
- only after they say yes, since joining changes who reads what; then go back to step 2. If it says no
96
- such team exists, or they do not say yes, carry on to step 7 with what you have.
95
+ If the question names a project and step 2 found none of its pages, the hub has nothing shared for
96
+ it: `scope=all` already reads every team's Team and Org items, so joining its team would not show
97
+ more. Carry on to step 7 with what you have.
97
98
 
98
99
  ## 4. Check what you rely on
99
100
 
@@ -250,6 +251,9 @@ source.
250
251
 
251
252
  Decide the visibility by the guide's "What to share" section
252
253
  (`memory_getSkillGuide section="What to share"`), and state the choice and the reason in the answer.
254
+ A save on a project's repo needs the person on that project's team. When `memory_listTeams` shows
255
+ they are not, ask whether to join it, and call `memory_joinTeam` only after they say yes; then look
256
+ up the status snapshot again (step 6) before saving one. If they say no, save Private and say why.
253
257
 
254
258
  ## 10. Close
255
259
 
@@ -64,7 +64,12 @@ connector is not connected, stop and tell the developer.
64
64
  5. Read what the hub already knows about this ticket: `memory_recall type=Fact scope=team
65
65
  externalRef=<parent>` and `memory_recall type=Scenario scope=team externalRef=<parent>`. Read an
66
66
  existing plan Scenario in full with `memory_get`, because recall shortens items.
67
- 6. For each repo involved, read its architecture map: `memory_list type=Skill tags=["ArchitectureMap"]`,
67
+ 6. Ask whether another project already solved this: `memory_recall type=Fact scope=all`, then
68
+ `type=Skill` and `type=Wiki`, with the ticket's title and its problem in one sentence as the
69
+ `query`. An item whose `repoName` is not this project's is precedent: say in the plan's Decisions
70
+ which project it came from and check it against this code, and keep that customer's names, data
71
+ and settings out of the plan.
72
+ 7. For each repo involved, read its architecture map: `memory_list type=Skill tags=["ArchitectureMap"]`,
68
73
  then `memory_get type=Skill uid=<uid>` on the ones for those repos.
69
74
 
70
75
  Entry lines look like `- **LMB-R13** · core · verified — <rule> _Source: ..._`. `core` entries change
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: sweep-knowledge
3
- description: Use for the weekly knowledge sweep, run by hand or as a scheduled routine, e.g. "sweep the hub knowledge", "dry-run the knowledge sweep", "apply the weekly sweep for Skedulo/acme-delivery". It checks every hub memory sourced from your teams' repos against the latest code, stamps the ones still current, updates a capped number of changed ones, refreshes each project's non-code sources, and reports one digest. It never asks questions.
4
- argument-hint: "[dry-run|apply] [repo owner/name ...]"
3
+ description: Use for the weekly knowledge sweep, run by hand or as a scheduled routine, e.g. "sweep the hub knowledge", "dry-run the knowledge sweep", "apply the weekly sweep for Skedulo/acme-delivery". It checks every hub memory sourced from your teams' repos against the latest code, stamps the ones still current, updates a capped number of changed ones, refreshes each project's non-code sources, and reports one digest. It never asks questions. It can also schedule itself as a weekly cloud routine.
4
+ argument-hint: "[dry-run|apply|schedule [dry-run|apply]] [repo owner/name ...]"
5
5
  ---
6
6
 
7
7
  # Weekly knowledge sweep
@@ -15,7 +15,7 @@ ones, within fixed caps.
15
15
  would do. `apply` stamps, updates and refreshes. Start with dry runs; switch to `apply` once the
16
16
  digests look right.
17
17
  - **Repos.** The `owner/name` arguments, or else every repo found in step 2.
18
- - **Unattended.** Never ask a question. Anything that would need an answer is skipped and listed in
18
+ - **Unattended.** Never ask a question (schedule mode asks for one environment id, once). Anything that would need an answer is skipped and listed in
19
19
  the digest as waiting, with why. A problem that stops the whole run still ends with the digest.
20
20
  - **Never draft new knowledge.** The sweep saves no new memories, SkillDrift Facts included; it only
21
21
  stamps, updates, flags and reports.
@@ -39,9 +39,50 @@ The `sweep` command needs `MEMORY_HUB_MCP_TOKEN` in the environment. If it is mi
39
39
  in the digest how to provide it, as step 3 of the project-knowledge skill's `references/import.md`
40
40
  explains (`memory-hub:project-knowledge` when installed as a plugin).
41
41
 
42
+ ## Schedule mode
43
+
44
+ `schedule` sets up the weekly cloud routine `Memory hub weekly sweep` and stops. The rest of this
45
+ skill does not run. In order:
46
+
47
+ 1. If `MEMORY_HUB_MCP_TOKEN` is unset, stop and say how to provide it, as in the check above. Never
48
+ print the token.
49
+ 2. **Environment.** The token, the network access and the plugin live on a claude.ai cloud
50
+ environment, not on the routine. `RemoteTrigger list`, and if the existing routine has a
51
+ `job_config.ccr.environment_id`, reuse it. Otherwise ask for the id (`env_...`) of an environment
52
+ named `Memory hub`, giving these settings to create in claude.ai (Claude Code, environments).
53
+ This is the only question schedule mode asks.
54
+ - Network access: custom, keep the defaults, and add `*.skl.io`.
55
+ - Environment variable: `MEMORY_HUB_MCP_TOKEN=<your token>`. They paste it themselves from Pulse
56
+ Web or their local settings.
57
+ - If your local `MEMORY_HUB_FUNCTION_URL` differs from the default, set it on the environment too.
58
+ - Setup script:
59
+ ```
60
+ claude plugin marketplace add Skedulo/se-ai-memory-hub
61
+ claude plugin install memory-hub@memory-hub
62
+ ```
63
+ 3. **Repos.** `memory_listRepos`; keep every name matching the repo pattern in step 2 below. The
64
+ command drops repos without hub items.
65
+ 4. **Connectors.** From the `RemoteTrigger list` result, take the first `mcp_connections` entry named
66
+ `Linear`, `Atlassian`, `Google_Drive` or `Slack` across the developer's routines, and write them as
67
+ a JSON array to a temp file. If there are none, pass no file, and say the non-code refresh will
68
+ list sources as not refreshed until they add connectors on the routine page.
69
+ 5. **User.** `git config user.email`, else the email in the memory-hub persona
70
+ (`memory_sessionContext`). If neither exists, stop and say why.
71
+ 6. **Mode.** The argument after `schedule`, else the mode in the existing routine's prompt, else
72
+ `dry-run`.
73
+ 7. Run `npx -y @skedulo/memory-hub-mcp@latest routine --mode <mode> --user <email> --environment
74
+ <env id> --repos <owner/name,...> [--connections-file <file>]`. It prints the routine JSON. Exit
75
+ code 2: relay the command's message and stop (bad arguments, unreadable connections file, or no
76
+ repo with hub items). Exit code 1: the token is missing. Remove the temp connections file on
77
+ every stop.
78
+ 8. `RemoteTrigger create` with that JSON, or `update` the existing routine with the full body so
79
+ removed repos drop out. Remove the temp file.
80
+ 9. Reply with the routine link, the next run time, the mode and the repo count only. Never echo the
81
+ token or the body.
82
+
42
83
  ## 1. Settle the mode and the date
43
84
 
44
- Take the mode from the arguments (`dry-run` when none is given) and today's date, used as the reason
85
+ Take the mode from the arguments (`dry-run` when none is given; `schedule` goes to the section above) and today's date, used as the reason
45
86
  "weekly sweep <date>" in every change-log line this run writes.
46
87
 
47
88
  ## 2. Find the repos
@@ -61,7 +102,15 @@ Take the mode from the arguments (`dry-run` when none is given) and today's date
61
102
 
62
103
  For each swept repo, in turn:
63
104
 
64
- 1. Clone it fresh, without blobs, so only the files a diff needs are fetched:
105
+ 1. In a cloud routine the sources are already checked out, shallow, at `/home/user/<name>` (the
106
+ working directory or its parent). If one of them is `<owner/name>` (match `git remote get-url
107
+ origin`), use it as the clone; if `git rev-parse --is-shallow-repository` says `true`, run
108
+ `git fetch --unshallow`, and if that fails, list the repo as not swept, with the error. Then run
109
+ `git remote set-head origin --auto` (ignore a failure) and `git rev-parse --verify -q
110
+ origin/HEAD`; in `apply` mode, if that prints nothing, list the repo as not swept: no
111
+ `origin/HEAD` to stamp against. A repo with hub items that is not checked out in a cloud run is
112
+ not swept: list it as "not a source; re-run `schedule` to add it", not as a clone failure.
113
+ Otherwise clone it fresh, without blobs, so only the files a diff needs are fetched:
65
114
  `rm -rf "${TMPDIR:-/tmp}/memory-hub-sweep/<owner>/<name>"`, then
66
115
  `gh repo clone <owner/name> "${TMPDIR:-/tmp}/memory-hub-sweep/<owner>/<name>" -- --filter=blob:none`
67
116
  (or `git clone --filter=blob:none` with the repo URL when `gh` is not available). If the clone
@@ -92,7 +141,7 @@ Take the items in order. Before reading anything, skip and list:
92
141
  - `diffLines` over 300: flag it as too big to check here. For a project page, suggest "catch up the
93
142
  <Project> knowledge with the code".
94
143
  - `diffLines` of -1: the diff failed; flag it as not checked.
95
- - `editedByOtherWithin7Days`: someone else is working on it; report it, never rewrite it.
144
+ - `editedByOtherWithin7Days`: someone else is working on it; never rewrite it. Count it as "already swept by a teammate" in the digest, not as waiting.
96
145
  - `editable: false`: flag it (the "Stale memories" rule on edits you cannot make).
97
146
  - tagged `Superseded`: a newer memory replaced it; report it, do not update it.
98
147
 
@@ -137,7 +186,7 @@ In `apply` mode, for each project that has `<Project> › Sources` on a swept re
137
186
  (`memory_list type=Wiki repo=<repo uid> titlePrefix="<Project> › Sources"`), run the
138
187
  project-knowledge skill as "the weekly sweep runs this skill", so it picks the sources-only refresh:
139
188
  it reads the non-code sources, never repos, applies only non-core changes, and lists the core ones
140
- as waiting. Each refresh counts as one update against the cap; once the cap is reached, list the
189
+ as waiting. A source whose connector tools are missing is listed as not refreshed, not as an error. Each refresh counts as one update against the cap; once the cap is reached, list the
141
190
  remaining projects as not reached. In `dry-run` mode, list the projects it would refresh, counted
142
191
  the same way.
143
192
 
@@ -156,8 +205,9 @@ One digest for the whole run, headed with the mode and the date:
156
205
  1. Per repo: `target`, and the counts of unchanged, stamped, changed, updated, flagged, skipped,
157
206
  not reached, nothing cited, unknown commit, other repo and errors. Repos not swept, with why.
158
207
  2. Each update with its reason, by title (uid only when Private).
159
- 3. Flagged and skipped items with why: too big, diff failed, edited by someone else in the last 7 days, not
160
- editable, superseded, unclear after verifying, not reached.
208
+ 3. Flagged and skipped items with why: too big, diff failed, not editable,
209
+ superseded, unclear after verifying, not reached. Items edited by someone else in the last 7
210
+ days are counted as already swept by a teammate.
161
211
  4. Per project: what the targeted updates and sources-only refreshes changed, by page title and
162
212
  entry ID, the core changes waiting ("run project-knowledge on <Project> to decide them"), and
163
213
  anything "Worth a look", such as new modules.
@@ -167,4 +217,5 @@ One digest for the whole run, headed with the mode and the date:
167
217
 
168
218
  ## 8. Clean up
169
219
 
170
- Remove the clones, even after a failure: `rm -rf "${TMPDIR:-/tmp}/memory-hub-sweep"`.
220
+ Remove the clones, even after a failure: `rm -rf "${TMPDIR:-/tmp}/memory-hub-sweep"`. Never remove
221
+ a repo that was already checked out.
@@ -269,11 +269,15 @@ if [ "${#EMBED[@]}" -gt 0 ]; then
269
269
  fi
270
270
 
271
271
  QUERY=$(printf '%s' "$PROMPT" | head -c 300)
272
+ # Without a vector nothing can hold other projects to a closer match, so the word search stays on your teams.
272
273
  body() {
273
274
  jq -nc --arg q "$QUERY" --arg v "${VECTOR:-null}" --argjson cap "$((BUDGET / 2))" \
274
- --argjson min "$MIN_SIMILARITY" '
275
- {scope: "team", query: $q, diverse: true, maxCharsPerItem: 500, maxTotalChars: $cap}
276
- + (if $v == "null" then {} else {queryEmbedding: ($v | fromjson), minSimilarity: $min} end)'
275
+ --argjson min "$MIN_SIMILARITY" --arg repo "$REPO" --argjson other "$OTHER_REPO_MIN" --argjson band "$SIMILARITY_BAND" '
276
+ {query: $q, diverse: true, maxCharsPerItem: 500, maxTotalChars: $cap}
277
+ + (if $v == "null" then {scope: "team"}
278
+ else {scope: "all", queryEmbedding: ($v | fromjson), minSimilarity: $min}
279
+ + (if $repo == "" then {} else {homeRepo: $repo, otherRepoMinSimilarity: $other, similarityBand: $band} end)
280
+ end)'
277
281
  }
278
282
 
279
283
  call() {
@@ -298,20 +302,38 @@ call "/memory/recall-wiki" "$TMP_DIR/wiki.json" &
298
302
  call "/memory/recall-scenarios" "$TMP_DIR/scenarios.json" &
299
303
  wait
300
304
 
305
+ SCORED='[(.facts // [])[], (.skills // [])[], (.pages // [])[], (.scenarios // [])[]] | map(select(.similarity != null))'
306
+ SCORE='(.similarity + (.boost // 0))'
307
+ HOME_ITEM='($repo == "" or ((.repoName // "" | ascii_downcase) == ($repo | ascii_downcase)))'
308
+ higher() {
309
+ if [ -z "$1" ]; then printf '%s' "$2"
310
+ elif [ -z "$2" ] || [ "$(jq -n --argjson a "$1" --argjson b "$2" '$a > $b' 2>/dev/null)" = true ]; then printf '%s' "$1"
311
+ else printf '%s' "$2"; fi
312
+ }
313
+ floor_of() { if [ -n "$1" ]; then jq -n --argjson best "$1" --argjson band "$SIMILARITY_BAND" '$best - $band'; else echo -1; fi; }
301
314
  # Judged across every list: one list alone may have no strong match, and would keep its weak ones.
315
+ # This repo's items are judged against this repo's best, so a strong match elsewhere cannot push them out.
302
316
  BEST=""
317
+ BEST_HOME=""
303
318
  for kind in facts skills wiki scenarios; do
304
- top=$(jq -r '[(.facts // [])[], (.skills // [])[], (.pages // [])[], (.scenarios // [])[]] | map(select(.similarity != null) | .similarity + (.boost // 0)) | max // empty' "$TMP_DIR/$kind.json" 2>/dev/null)
305
- if [ -n "$top" ] && { [ -z "$BEST" ] || [ "$(jq -n --argjson a "$top" --argjson b "$BEST" '$a > $b' 2>/dev/null)" = true ]; }; then BEST="$top"; fi
319
+ top=$(jq -r "$SCORED | map($SCORE) | max // empty" "$TMP_DIR/$kind.json" 2>/dev/null)
320
+ top_home=$(jq -r --arg repo "$REPO" "$SCORED | map(select($HOME_ITEM) | $SCORE) | max // empty" "$TMP_DIR/$kind.json" 2>/dev/null)
321
+ BEST=$(higher "$top" "$BEST")
322
+ BEST_HOME=$(higher "$top_home" "$BEST_HOME")
306
323
  done
307
- FLOOR=-1
308
- [ -n "$BEST" ] && FLOOR=$(jq -n --argjson best "$BEST" --argjson band "$SIMILARITY_BAND" '$best - $band')
309
- KEEP='select(.similarity == null or ((.similarity + (.boost // 0)) >= $floor and ((.repoName // "" | ascii_downcase) == ($repo | ascii_downcase) or $repo == "" or (.similarity + (.boost // 0)) >= $other)))'
310
- KEEP_ARGS=(--argjson floor "$FLOOR" --arg repo "$REPO" --argjson other "$OTHER_REPO_MIN")
324
+ FLOOR=$(floor_of "$BEST")
325
+ HOME_FLOOR=$(floor_of "$BEST_HOME")
326
+ KEEP="select(.similarity == null or (if $HOME_ITEM then $SCORE >= \$home_floor else ($SCORE >= \$floor and $SCORE >= \$other) end))"
327
+ KEEP_ARGS=(--argjson floor "$FLOOR" --argjson home_floor "$HOME_FLOOR" --arg repo "$REPO" --argjson other "$OTHER_REPO_MIN")
328
+ ORIGIN_DEF='def origin:
329
+ if (.repoName | type) == "string" and .repoName != "" and (.repoName | ascii_downcase) != ($repo | ascii_downcase)
330
+ then " · from " + (.repoName | gsub("[[:cntrl:]]"; " ")) + (if (.teamName | type) == "string" and .teamName != "" then " (" + (.teamName | gsub("[[:cntrl:]]"; " ")) + ")" else "" end)
331
+ else "" end;'
311
332
 
312
333
  HEADING="## Memory relevant to this prompt"
313
334
  FOOTER="_Matched to your prompt, not newest-first. memory_recall with a query finds more; memory_get fetches a cut item._"
314
- room=$((BUDGET - ${#HEADING} - ${#FOOTER} - 4))
335
+ PRECEDENT_NOTE="_An item marked \"from\" another project is precedent: check it against this code, and keep that customer's names, data and terms out of this work._"
336
+ room=$((BUDGET - ${#HEADING} - ${#FOOTER} - ${#PRECEDENT_NOTE} - 5))
315
337
  BODY=""
316
338
  used=0
317
339
  # Whole items only: each item is one logical record, so it is shown entirely or not at all.
@@ -322,11 +344,14 @@ while IFS= read -r -d $'\x1e' item; do
322
344
  used=$((used + ${#item} + 1))
323
345
  fi
324
346
  done < <(
325
- jq -j "${KEEP_ARGS[@]}" "$EXTRAS_DEF [.facts[]? | $KEEP][:$FACTS_N][] | ((\"- \" + (.content | $ELIDE) + $(cut_pointer Fact) + $STAMP + extras(\"\"; .content)) | $CLOSE_FENCE | $INDENT), \"\\u001e\"" "$TMP_DIR/facts.json" 2>/dev/null
326
- jq -j "${KEEP_ARGS[@]}" "$EXTRAS_DEF [.skills[]? | $KEEP][:$SKILLS_N][] | ((\"- \" + .title + \": \" + (.content | $ELIDE) + $(cut_pointer Skill) + $STAMP + extras(\"\"; .content)) | $CLOSE_FENCE | $INDENT), \"\\u001e\"" "$TMP_DIR/skills.json" 2>/dev/null
327
- jq -j "${KEEP_ARGS[@]}" "$EXTRAS_DEF [.pages[]? | $KEEP][:$WIKI_N][] | ((\"- \" + .title + \": \" + (.content | $ELIDE) + $(cut_pointer Wiki) + $STAMP + extras(\"\"; .content)) | $CLOSE_FENCE | $INDENT), \"\\u001e\"" "$TMP_DIR/wiki.json" 2>/dev/null
328
- jq -j "${KEEP_ARGS[@]}" "$EXTRAS_DEF [.scenarios[]? | $KEEP][:$SCENARIOS_N][] | ((\"- \" + (.summary | $ELIDE) + $(cut_pointer Scenario summary) + $STAMP + extras(\"\"; .summary)) | $CLOSE_FENCE | $INDENT), \"\\u001e\"" "$TMP_DIR/scenarios.json" 2>/dev/null
347
+ jq -j "${KEEP_ARGS[@]}" "$EXTRAS_DEF $ORIGIN_DEF [.facts[]? | $KEEP][:$FACTS_N][] | ((\"- \" + (.content | $ELIDE) + $(cut_pointer Fact) + $STAMP + extras(\"\"; .content) + origin) | $CLOSE_FENCE | $INDENT), \"\\u001e\"" "$TMP_DIR/facts.json" 2>/dev/null
348
+ jq -j "${KEEP_ARGS[@]}" "$EXTRAS_DEF $ORIGIN_DEF [.skills[]? | $KEEP][:$SKILLS_N][] | ((\"- \" + .title + \": \" + (.content | $ELIDE) + $(cut_pointer Skill) + $STAMP + extras(\"\"; .content) + origin) | $CLOSE_FENCE | $INDENT), \"\\u001e\"" "$TMP_DIR/skills.json" 2>/dev/null
349
+ jq -j "${KEEP_ARGS[@]}" "$EXTRAS_DEF $ORIGIN_DEF [.pages[]? | $KEEP][:$WIKI_N][] | ((\"- \" + .title + \": \" + (.content | $ELIDE) + $(cut_pointer Wiki) + $STAMP + extras(\"\"; .content) + origin) | $CLOSE_FENCE | $INDENT), \"\\u001e\"" "$TMP_DIR/wiki.json" 2>/dev/null
350
+ jq -j "${KEEP_ARGS[@]}" "$EXTRAS_DEF $ORIGIN_DEF [.scenarios[]? | $KEEP][:$SCENARIOS_N][] | ((\"- \" + (.summary | $ELIDE) + $(cut_pointer Scenario summary) + $STAMP + extras(\"\"; .summary) + origin) | $CLOSE_FENCE | $INDENT), \"\\u001e\"" "$TMP_DIR/scenarios.json" 2>/dev/null
329
351
  )
330
352
  [ -n "$BODY" ] || finish_with_notices
353
+ case "$BODY" in
354
+ *" · from "*) FOOTER="${FOOTER}${NL}${PRECEDENT_NOTE}" ;;
355
+ esac
331
356
 
332
357
  emit "${NOTICES}${HEADING}${NL}${BODY}${NL}${FOOTER}${NL}"
@@ -8,8 +8,8 @@ const FALLBACK = [
8
8
  '',
9
9
  'Answer the question below from what the memory hub already knows, in plain language.',
10
10
  '',
11
- '1. Search with `memory_recall` scope=team, which includes your own items, for Facts, Skills, Scenarios and Wiki pages.',
12
- '2. When a project is named, list its pages with `memory_list type=Wiki titlePrefix="<Project> ›"`.',
11
+ "1. Search with `memory_recall` scope=all, which covers every project's shared items and your own, for Facts, Skills, Scenarios and Wiki pages. Say which project an answer came from, and keep another customer's names, data and terms out of anything meant for this one.",
12
+ '2. When a project is named, list its pages with `memory_list type=Wiki scope=all titlePrefix="<Project> ›"`.',
13
13
  '3. Read anything cut short with `memory_get`, and back each claim with the uid it came from.',
14
14
  "4. When the hub has nothing, say so and ask which sources to read; reading sources costs tokens. Searching everything for a project needs Claude Code in the project's repo.",
15
15
  '5. Never paste SOW or Slack text, and never save prices, rates, budgets, customer personal data or credentials.',
package/dist/cli.js CHANGED
@@ -72,6 +72,23 @@ else if (command === 'sweep') {
72
72
  process.exitCode = 1;
73
73
  });
74
74
  }
75
+ else if (command === 'routine') {
76
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
77
+ const { runRoutine } = require('./routine');
78
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
79
+ const { functionUrl } = require('./setup');
80
+ runRoutine(process.argv.slice(3), {
81
+ env: process.env,
82
+ log: (line) => console.log(line),
83
+ functionUrl,
84
+ timeZone: () => Intl.DateTimeFormat().resolvedOptions().timeZone,
85
+ }).then((code) => {
86
+ process.exitCode = code;
87
+ }, (error) => {
88
+ console.error(error instanceof Error ? error.message : String(error));
89
+ process.exitCode = 1;
90
+ });
91
+ }
75
92
  else if (command === 'migrate-plugin') {
76
93
  // eslint-disable-next-line @typescript-eslint/no-var-requires
77
94
  const { runMigratePlugin } = require('./migrate-plugin');
@@ -110,6 +127,10 @@ else if (command === '--help' || command === '-h') {
110
127
  they cite changed since their source commit, and print JSON.
111
128
  Compares against the checkout's origin/HEAD and never fetches.
112
129
  --stamp moves the source commit of unchanged items forward.
130
+ memory-hub-mcp routine --mode <dry-run|apply> --user <email> --environment <id> --repos <a/b,...>
131
+ print the JSON body of the weekly sweep cloud routine for those repos
132
+ (only repos with hub items), to create at claude.ai/code/routines.
133
+ [--connections-file <path>] adds connector entries.
113
134
  memory-hub-mcp embed print the embedding of the text on stdin (or the arguments) as JSON;
114
135
  used by the UserPromptSubmit hook. Exits non-zero if it cannot.
115
136
  memory-hub-mcp run the MCP server on stdio (how a host launches it)
package/dist/index.js CHANGED
@@ -111,9 +111,9 @@ server.tool('memory_getSkillGuide', 'Get the current Memory Hub usage guide —
111
111
  const registered = Object.keys(server._registeredTools ?? {});
112
112
  return { content: [{ type: 'text', text: (0, guide_check_1.staleBuildNotice)(guide, registered) + (section ? (0, guide_check_1.guideSection)(guide, section) : guide) }] };
113
113
  });
114
- server.tool('memory_recall', "Recall this developer's (or their team's) Facts, Skills, Scenarios, or Wiki pages. See memory_getSkillGuide for when to use each type. An item with a `staleness` field cites files that changed since it was verified; follow the skill guide's 'Stale memories' rules before relying on it.", {
114
+ server.tool('memory_recall', "Recall Facts, Skills, Scenarios, or Wiki pages. scope: self is your own Private items; team is yours plus what your teams share; all is yours plus every Team and Org item from every project, so use all to find whether another project already solved something. Each item carries repoName and teamName: one from another project is precedent to check against this code, and its customer's names, data and terms stay out of this project's work. See memory_getSkillGuide for when to use each type. An item with a `staleness` field cites files that changed since it was verified; follow the skill guide's 'Stale memories' rules before relying on it.", {
115
115
  type: zod_1.z.enum(['Fact', 'Skill', 'Scenario', 'Wiki']),
116
- scope: zod_1.z.enum(['self', 'team']),
116
+ scope: zod_1.z.enum(['self', 'team', 'all']),
117
117
  query: zod_1.z.string().optional(),
118
118
  tags: zod_1.z.array(zod_1.z.enum(tags_1.TAG_VALUES)).optional().describe('Fact only.'),
119
119
  externalRef: zod_1.z.string().optional().describe("Fact, Scenario only — filter to items linked to this Linear/Jira ticket ref, e.g. 'SOL-1234'. Does not create a task if the ref doesn't resolve to one — returns no results instead."),
@@ -123,7 +123,7 @@ server.tool('memory_recall', "Recall this developer's (or their team's) Facts, S
123
123
  const result = await (0, recall_1.performRecall)({ client, embed: embeddings_1.embed, staleness: currentStaleness() }, input);
124
124
  return { content: [...embeddingNoticeBlocks(), { type: 'text', text: JSON.stringify(result) }] };
125
125
  });
126
- server.tool('memory_get', "Fetch one Fact/Skill/Scenario/Wiki page in full by its uid (a Wiki page also returns its links and backlinks), with its lastModifiedDate to pass to memory_update as expectedLastModified. memory_recall truncates every item it lists (500 chars by default), so use this to read anything longer than a paragraph — take the uid from a memory_recall result. An item with a `staleness` field cites files that changed since it was verified; follow the skill guide's 'Stale memories' rules before relying on it.", {
126
+ server.tool('memory_get', "Fetch one Fact/Skill/Scenario/Wiki page in full by its uid (a Wiki page also returns its links and backlinks), with the repoName and teamName it belongs to and its lastModifiedDate to pass to memory_update as expectedLastModified. memory_recall truncates every item it lists (500 chars by default), so use this to read anything longer than a paragraph — take the uid from a memory_recall result. An item with a `staleness` field cites files that changed since it was verified; follow the skill guide's 'Stale memories' rules before relying on it.", {
127
127
  type: zod_1.z.enum(['Fact', 'Skill', 'Scenario', 'Wiki']),
128
128
  uid: zod_1.z.string().min(1).describe('The uid from a memory_recall result.'),
129
129
  }, async (input) => {
@@ -147,7 +147,7 @@ const saveShape = {
147
147
  tags: zod_1.z.array(zod_1.z.enum(tags_1.TAG_VALUES)).optional().describe('Fact, Skill, Wiki only.'),
148
148
  externalRef: zod_1.z.string().optional().describe("Fact, Scenario, Wiki only — the Linear/Jira ticket this relates to, e.g. 'SOL-1234' — pass it when the user mentions a ticket."),
149
149
  repo: zod_1.z.string().min(1).optional().describe('A DevRepos uid from memory_listRepos, or the owner/name of a repo memory_listRepos lists, overriding the current-directory auto-detected repo. A repo on a team you are not on is refused, never joined.'),
150
- visibility: zod_1.z.enum(['Private', 'Team', 'Org']).optional().describe('Choose it on every save ("What to share" in memory_getSkillGuide). Team: work knowledge about a project or customer (decisions, fixes, root causes, how-tos, gotchas, conventions), on that project\'s repo. Org (everyone in the tenant): knowledge about Skedulo\'s own platform, products, tools or practices with no customer names or data, project detail, commercial terms, credentials, unpatched security detail or anything about a person. Private only with a stated reason: personal, an unverified guess, about a person, or barred by the confidentiality rules. Unsure between Org and Team: Team. Team is refused on a repo no team owns yet. Omit it in capture mode, which saves Private.'),
150
+ visibility: zod_1.z.enum(['Private', 'Team', 'Org']).optional().describe('Choose it on every save ("What to share" in memory_getSkillGuide). Team: work knowledge about a project or customer (decisions, fixes, root causes, how-tos, gotchas, conventions), on that project\'s repo; every agent can find it with scope all, so keep customer specifics to what the lesson needs. Org (everyone in the tenant): knowledge about Skedulo\'s own platform, products, tools or practices with no customer names or data, project detail, commercial terms, credentials, unpatched security detail or anything about a person. Private only with a stated reason: personal, an unverified guess, about a person, or barred by the confidentiality rules. Unsure between Org and Team: Team. Team is refused on a repo no team owns yet. Omit it in capture mode, which saves Private.'),
151
151
  source: source_1.sourceSchema.optional().describe(source_1.SOURCE_DESCRIPTION),
152
152
  supersedes: zod_1.z.string().min(1).optional().describe('Fact, Skill, Wiki only — the uid of a memory of the same type that this one replaces. After saving, that memory is tagged Superseded if you may edit it (yours, or a Team item on your repo); otherwise the result says why it was not marked.'),
153
153
  };
@@ -192,6 +192,7 @@ server.tool('memory_saveBatch', 'Save up to 25 Facts/Skills/Scenarios/Wiki pages
192
192
  });
193
193
  server.tool('memory_list', "List memory items of one type that you can see, newest first, with a title, visibility, repo and whether each is yours — an inventory for choosing which items to share, move or review. Feed the uids to memory_setVisibility or memory_moveResourceRepo as resourceIds. Returns total (all matches) and one page of items; page with offset. Not a search: use memory_recall to find content by meaning.", {
194
194
  type: zod_1.z.enum(['Fact', 'Scenario', 'Skill', 'Wiki']),
195
+ scope: zod_1.z.enum(['team', 'all']).optional().describe("team (default): yours plus what your teams share. all: also every other team's Team and Org items."),
195
196
  repo: zod_1.z.string().min(1).nullable().optional().describe('A DevRepos uid from memory_listRepos. null lists only items with no repo; omit for any repo.'),
196
197
  visibility: zod_1.z.enum(['Private', 'Team', 'Restricted', 'Org']).optional(),
197
198
  titlePrefix: zod_1.z.string().min(1).optional().describe('Case-insensitive start of the title (Fact: content, Scenario: summary).'),
@@ -271,7 +272,7 @@ server.tool('memory_listTeamMembers', "List the members (uid and display name) o
271
272
  const result = await (0, teams_1.performListTeamMembers)({ client }, input);
272
273
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
273
274
  });
274
- server.tool('memory_whoCanRead', "Preview who can read one Fact/Scenario/Skill/Wiki page you can read, from its actual visibility: { visibility, audience }. audience.kind is author (Private), everyone (Org), team (the repo's owning team with memberCount), coMembers (Team with no repo: the author's teams, with memberCount and readerCount) or grants (Restricted: the granted agents by display name). Use it to check sharing instead of guessing from your own session.", {
275
+ server.tool('memory_whoCanRead', "Preview who can read one Fact/Scenario/Skill/Wiki page you can read, from its actual visibility: { visibility, audience }. audience is who sees it by default: author (Private), everyone (Org), team (the repo's owning team with memberCount), coMembers (Team with no repo: the author's teams, with memberCount and readerCount) or grants (Restricted: the granted agents by display name). searchableByEveryone is true for Team and Org: any agent's scope=all search and memory_get reach them. Use it to check sharing instead of guessing from your own session.", {
275
276
  type: zod_1.z.enum(['Fact', 'Scenario', 'Skill', 'Wiki']),
276
277
  uid: zod_1.z.string().min(1),
277
278
  }, async (input) => {
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runRoutine = exports.reposWithItems = exports.buildSweepRoutine = exports.sweepPrompt = exports.staggerMinute = exports.ROUTINE_USAGE = exports.ROUTINE_NAME = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const fs_1 = require("fs");
6
+ const client_1 = require("./client");
7
+ const sweep_1 = require("./sweep");
8
+ exports.ROUTINE_NAME = 'Memory hub weekly sweep';
9
+ exports.ROUTINE_USAGE = 'memory-hub-mcp routine --mode <dry-run|apply> --user <email> --environment <id> --repos <owner/name,...> [--connections-file <path>]';
10
+ const HUB_REPO = 'Skedulo/se-ai-memory-hub';
11
+ const TYPES = ['Fact', 'Skill', 'Scenario', 'Wiki'];
12
+ const ALLOWED_TOOLS = ['Bash', 'Read', 'Write', 'Edit', 'Glob', 'Grep', 'Skill'];
13
+ function staggerMinute(user) {
14
+ const digest = (0, crypto_1.createHash)('sha256').update(user.trim().toLowerCase()).digest();
15
+ return digest.readUInt32BE(0) % 60;
16
+ }
17
+ exports.staggerMinute = staggerMinute;
18
+ function sweepPrompt(mode, repos) {
19
+ const args = [mode, ...repos.map((repo) => repo.trim())].join(' ');
20
+ return `Run \`/memory-hub:sweep-knowledge ${args}\`. The repos to sweep are already checked out in the working directory. There is nobody to ask: never ask a question, and report anything that needs an answer in the digest.`;
21
+ }
22
+ exports.sweepPrompt = sweepPrompt;
23
+ function buildSweepRoutine(input) {
24
+ const seen = new Set();
25
+ const sources = [];
26
+ for (const repo of [HUB_REPO, ...input.repos]) {
27
+ const key = repo.trim().toLowerCase();
28
+ if (seen.has(key))
29
+ continue;
30
+ seen.add(key);
31
+ sources.push({ git_repository: { url: `https://github.com/${repo.trim()}` } });
32
+ }
33
+ const swept = input.repos.filter((repo, i) => input.repos.findIndex((r) => r.trim().toLowerCase() === repo.trim().toLowerCase()) === i);
34
+ return {
35
+ name: exports.ROUTINE_NAME,
36
+ cron_expression: `CRON_TZ=${input.timeZone} ${staggerMinute(input.user)} 7 * * 1`,
37
+ enabled: true,
38
+ mcp_connections: input.connections ?? [],
39
+ job_config: {
40
+ ccr: {
41
+ environment_id: input.environmentId,
42
+ session_context: { allowed_tools: ALLOWED_TOOLS, sources },
43
+ events: [
44
+ {
45
+ data: {
46
+ type: 'user',
47
+ uuid: (0, crypto_1.randomUUID)(),
48
+ session_id: '',
49
+ parent_tool_use_id: null,
50
+ message: { role: 'user', content: sweepPrompt(input.mode, swept) },
51
+ },
52
+ },
53
+ ],
54
+ },
55
+ },
56
+ };
57
+ }
58
+ exports.buildSweepRoutine = buildSweepRoutine;
59
+ async function reposWithItems(client, repos) {
60
+ const kept = [];
61
+ for (const repo of repos) {
62
+ for (const type of TYPES) {
63
+ const page = await client.listResources({ type, sourceRepo: repo, offset: 0, limit: 1 });
64
+ if (page.total > 0) {
65
+ kept.push(repo);
66
+ break;
67
+ }
68
+ }
69
+ }
70
+ return kept;
71
+ }
72
+ exports.reposWithItems = reposWithItems;
73
+ function option(argv, name) {
74
+ const index = argv.indexOf(`--${name}`);
75
+ const value = index >= 0 ? argv[index + 1] : undefined;
76
+ return value && !value.startsWith('--') ? value : undefined;
77
+ }
78
+ async function runRoutine(argv, deps) {
79
+ const mode = option(argv, 'mode');
80
+ const user = option(argv, 'user');
81
+ const environmentId = option(argv, 'environment');
82
+ const reposIndex = argv.indexOf('--repos');
83
+ const reposArg = reposIndex >= 0 ? (argv[reposIndex + 1] ?? '') : undefined;
84
+ if (mode !== 'dry-run' && mode !== 'apply') {
85
+ deps.log(`--mode must be dry-run or apply.\n${exports.ROUTINE_USAGE}`);
86
+ return 2;
87
+ }
88
+ if (!user || !environmentId || reposArg === undefined) {
89
+ deps.log(`--user, --environment and --repos are required.\n${exports.ROUTINE_USAGE}`);
90
+ return 2;
91
+ }
92
+ const repos = reposArg
93
+ .split(',')
94
+ .map((repo) => repo.trim())
95
+ .filter(Boolean);
96
+ if (repos.length === 0) {
97
+ deps.log(`--repos needs at least one owner/name.\n${exports.ROUTINE_USAGE}`);
98
+ return 2;
99
+ }
100
+ const bad = repos.find((repo) => !sweep_1.REPO_NAME.test(repo));
101
+ if (bad) {
102
+ deps.log(`--repos must be owner/name entries, got "${bad}".\n${exports.ROUTINE_USAGE}`);
103
+ return 2;
104
+ }
105
+ let connections;
106
+ const connectionsFile = option(argv, 'connections-file');
107
+ if (connectionsFile) {
108
+ try {
109
+ const parsed = JSON.parse((0, fs_1.readFileSync)(connectionsFile, 'utf8'));
110
+ if (!Array.isArray(parsed))
111
+ throw new Error('not a JSON array');
112
+ connections = parsed;
113
+ }
114
+ catch (error) {
115
+ deps.log(`Cannot read --connections-file ${connectionsFile}: ${error instanceof Error ? error.message : String(error)}`);
116
+ return 2;
117
+ }
118
+ }
119
+ const apiToken = deps.env.MEMORY_HUB_MCP_TOKEN;
120
+ if (!apiToken) {
121
+ deps.log('MEMORY_HUB_MCP_TOKEN is not set. Run `npx -y @skedulo/memory-hub-mcp setup` first.');
122
+ return 1;
123
+ }
124
+ const baseUrl = deps.env.MEMORY_HUB_FUNCTION_URL || deps.functionUrl();
125
+ const client = (deps.makeClient ?? ((config) => new client_1.MemoryHubClient(config)))({ baseUrl, apiToken });
126
+ const candidates = repos.filter((repo) => repo.toLowerCase() !== HUB_REPO.toLowerCase());
127
+ const withItems = await reposWithItems(client, candidates);
128
+ if (withItems.length === 0) {
129
+ deps.log('None of the repos has items in the hub, so there is nothing to sweep.');
130
+ return 2;
131
+ }
132
+ const body = buildSweepRoutine({ mode, timeZone: deps.timeZone() || 'UTC', user, repos: withItems, environmentId, connections });
133
+ deps.log(JSON.stringify(body, null, 2));
134
+ return 0;
135
+ }
136
+ exports.runRoutine = runRoutine;
@@ -13,7 +13,7 @@ function ownerLabel(match) {
13
13
  if (match.mine) {
14
14
  return ', yours';
15
15
  }
16
- return canEdit(match) ? ", a teammate's, editable" : ", a teammate's";
16
+ return canEdit(match) ? ", a teammate's, editable" : ", someone else's";
17
17
  }
18
18
  exports.ownerLabel = ownerLabel;
19
19
  const UPDATE_GUARD = "expectedLastModified=<its lastModifiedDate from memory_get>";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skedulo/memory-hub-mcp",
3
- "version": "0.2.20",
3
+ "version": "0.2.22",
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
@@ -18,9 +18,27 @@ for the one optional hook that does.
18
18
  If you're about to work on something that might have prior context not
19
19
  already surfaced at session start — a past decision on this specific repo,
20
20
  a known gotcha, a previously-solved version of this exact problem — call
21
- `memory_recall` with `scope: 'self'` or `scope: 'team'` and an optional
22
- `query` string to narrow it. Don't call it reflexively for every task; call
23
- it when the task smells like something that may have come up before.
21
+ `memory_recall` with an optional `query` string to narrow it. `scope: 'team'`
22
+ is your own items plus what your teams share; `scope: 'all'` adds every other
23
+ project's Team and Org items, so use `all` to find whether another project
24
+ already met this; `scope: 'self'` is your Private items only. Don't call it
25
+ reflexively for every task; call it when the task smells like something that
26
+ may have come up before.
27
+
28
+ **When you hit a problem, ask the whole hub first.** When an error, a failing
29
+ test or unexpected platform behaviour shows up and the cause is not obvious,
30
+ call `memory_recall` with `scope: 'all'` and the error text or a one-line
31
+ description as the `query`, before debugging. Every project runs on the same
32
+ platform, so the fix often exists already. The prompt hook searches only on
33
+ the first prompt of a session; a problem that appears later needs this call.
34
+
35
+ **Another project's item is precedent, not this project's rule.** Each
36
+ recalled or fetched item names its `repoName` and `teamName`, and the prompt hook marks
37
+ one from another repo `· from <repo> (<team>)`. Check it against this code
38
+ before applying it, and say which project it came from when you rely on it.
39
+ Keep that customer's names, data, configuration values and commercial terms
40
+ out of this project's code, documents and messages: carry the lesson, not the
41
+ details.
24
42
 
25
43
  Pass `type: 'Fact'`, `'Skill'`, `'Scenario'`, or `'Wiki'` to pick what kind of
26
44
  content you're looking for — a past decision/gotcha, a reusable procedure, a
@@ -197,6 +215,12 @@ project's sync job."). You make this choice yourself; nobody has to approve it.
197
215
  hub entirely.
198
216
  - **Unsure between Org and Team: Team.**
199
217
 
218
+ **Team items are searchable by everyone.** A Team item shows by default only
219
+ to the team that owns its repo, but every agent's `scope: 'all'` search and
220
+ `memory_get` reach it, from any project. Write it so the lesson reads on its
221
+ own, with the customer's specifics kept to what the lesson needs. Private is
222
+ the only way to keep an item to yourself.
223
+
200
224
  Auto-capture is the exception: its saves are `Private` (see "Automatic
201
225
  capture" below).
202
226
 
@@ -377,7 +401,8 @@ one client engagement's general notes to another client's team the moment
377
401
  you're working both engagements concurrently — so it stays `Private` by
378
402
  default instead. A repo that isn't linked to any team yet is treated the
379
403
  same as repo-less (no defined audience) until someone links it with
380
- `memory_linkRepoTeam`.
404
+ `memory_linkRepoTeam`. Either way, a Team item is also found by every agent's
405
+ `scope: 'all'` search; the team decides only who sees it by default.
381
406
 
382
407
  Two consequences worth knowing:
383
408
 
@@ -402,19 +427,22 @@ Two consequences worth knowing:
402
427
  ## Checking who can read an item
403
428
 
404
429
  - **`memory_whoCanRead`** — `type` and `uid` of an item you can read; returns
405
- `{ visibility, audience }` where `audience.kind` is `author`, `everyone`,
430
+ `{ visibility, audience, searchableByEveryone }`. `audience` is who sees it by
431
+ default, and its `kind` is `author`, `everyone`,
406
432
  `team` (the repo's team, with `memberCount`), `coMembers` (Team item with no
407
433
  repo: the author's teams plus `readerCount`) or `grants` (Restricted: display
408
- names of the granted agents). Use it to check who sees an item instead of
409
- guessing from the author's session. It only reads, so it needs no
410
- permission.
434
+ names of the granted agents). `searchableByEveryone` is true for Team and
435
+ Org: any agent's `scope: 'all'` search reaches them. Use it to check who sees
436
+ an item instead of guessing from the author's session. It only reads, so it
437
+ needs no permission.
411
438
 
412
439
  ## Sharing tools
413
440
 
414
441
  - **`memory_joinTeam`** — `teamName` of an existing team (never creates one).
415
442
  **`memory_addTeamMember`** — `teamName` you already belong to and `agent`
416
- (a uid or exact display name; idempotent). Both change who can read Team
417
- items, so call them only on a person's yes, never on your own judgment.
443
+ (a uid or exact display name; idempotent). Both change who sees Team items
444
+ by default and who can edit them, so call them only on a person's yes, never
445
+ on your own judgment.
418
446
  Membership is symmetric: adding someone shares their own repo-less Team
419
447
  items with every member of the team, and theirs with them, so tell the
420
448
  person being added first.
@@ -429,9 +457,10 @@ Two consequences worth knowing:
429
457
  - **`memory_grantAccess`** — shares a specific item with one named teammate
430
458
  (automatically promotes it to `Restricted` if needed).
431
459
 
432
- Visibility levels: `Private` is you only. `Team` is the team that owns the
433
- item's repo (or, for a repo-less item, every team you're in). `Org` is every
434
- agent in the tenant, whatever their team. Which one a save gets is the "What
460
+ Visibility levels: `Private` is you only. `Team` shows by default to the team
461
+ that owns the item's repo (or, for a repo-less item, every team you're in),
462
+ and every agent finds it with `scope: 'all'`. `Org` is every agent in the
463
+ tenant, whatever their team. Which one a save gets is the "What
435
464
  to share" rule above; when in doubt, `Team`. `Restricted`
436
465
  needs a named person, so only `memory_grantAccess` sets it, never a save.
437
466
 
@@ -564,7 +593,8 @@ Rules:
564
593
  developer and suggest "catch up the <Project> knowledge with the code".
565
594
  - Never attempt an edit you cannot make. Org items are author-only. A Team item you did not write
566
595
  can be edited only on one of your teams' repos and only with `expectedLastModified`. Private and
567
- Restricted items of others are never yours to edit. Flag these instead.
596
+ Restricted items of others are never yours to edit. Flag these instead; for an item from another
597
+ team's repo, name its repo and team so the developer can tell its owners.
568
598
  - Automatic capture never fixes or marks other items; it only updates its own Facts and Scenarios.
569
599
  - Never write stale text into content: no "may be out of date" notes. Staleness is worked out each
570
600
  time an item is read, never stored.
@@ -599,8 +629,8 @@ clear it back to unscoped rather than reassign it. To move many at once, pass
599
629
  `resourceIds` (up to 100 of one `resourceType`) instead of `resourceId`. List
600
630
  the set with `memory_list` and collect every page's uids before moving
601
631
  anything, since a move drops items out of a `repo` filter and shifts later
602
- pages. Moving Team-visible items into another team's repo changes who can read
603
- them.
632
+ pages. Moving Team-visible items into another team's repo changes who sees them
633
+ by default and who can edit them.
604
634
 
605
635
  ## Linking a repo to a team
606
636