@lorekit/cli 1.48.0 → 1.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/mcp-server.mjs +24 -24
- package/src/store/remote.mjs +1 -1
package/package.json
CHANGED
package/src/mcp-server.mjs
CHANGED
|
@@ -419,7 +419,7 @@ const MEMORY_DISPATCH = {
|
|
|
419
419
|
// networkError, unusable }`. A tool that passed either through verbatim would
|
|
420
420
|
// hand the model two different contracts for one tool name depending on a
|
|
421
421
|
// config value it cannot see. What is left here is what only the MCP surface
|
|
422
|
-
// owns: the
|
|
422
|
+
// owns: the count-desc-then-scope-asc sort and the exit-clean degradation below.
|
|
423
423
|
//
|
|
424
424
|
// DEGRADATION IS EXIT-CLEAN, mirroring the `scopes` command, which reports an
|
|
425
425
|
// unreachable remote as a short note at exit 0 rather than failing the run. An
|
|
@@ -441,31 +441,31 @@ export async function listScopes(store) {
|
|
|
441
441
|
return ok ? { ok: true, scopes: sortScopes(scopes) } : { ok: true, scopes: [], note: reason };
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
-
// Sorted by scope
|
|
445
|
-
// tool catalog and `llms.txt` all state for `memory.scopes`. The HOSTED
|
|
446
|
-
// gets that ordering from `lorekit_memory_scopes` (`order by
|
|
447
|
-
// migration
|
|
448
|
-
// return their `Map` insertion order — a walk order, not an
|
|
449
|
-
// stdio server owns it here rather than the two surfaces
|
|
450
|
-
// Sorting BOTH shapes (not just the local one) makes the
|
|
451
|
-
// of this function instead of an assumption about the store
|
|
452
|
-
//
|
|
453
|
-
// depend on the HOST's locale.
|
|
444
|
+
// Sorted by count DESC then scope asc, which is the contract `docs/mcp-tools.md`,
|
|
445
|
+
// the tool catalog and `llms.txt` all state for `memory.scopes`. The HOSTED
|
|
446
|
+
// surface gets that ordering from `lorekit_memory_scopes` (`order by count(*)
|
|
447
|
+
// desc, m.scope asc`, migration 00065), but `LocalStore`/`TwoTierStore.
|
|
448
|
+
// listScopes()` both return their `Map` insertion order — a walk order, not an
|
|
449
|
+
// ordering — so the stdio server owns it here rather than the two surfaces
|
|
450
|
+
// answering differently. Sorting BOTH shapes (not just the local one) makes the
|
|
451
|
+
// guarantee a property of this function instead of an assumption about the store
|
|
452
|
+
// it was handed.
|
|
454
453
|
//
|
|
455
|
-
//
|
|
456
|
-
//
|
|
457
|
-
//
|
|
458
|
-
//
|
|
459
|
-
//
|
|
460
|
-
//
|
|
461
|
-
//
|
|
462
|
-
//
|
|
463
|
-
// order
|
|
464
|
-
//
|
|
465
|
-
//
|
|
466
|
-
// agreeing on the exact position of a punctuated neighbour.
|
|
454
|
+
// The primary key is `count` (a number), which orders identically on both
|
|
455
|
+
// surfaces. Only the scope-asc TIEBREAK between equal-count scopes carries the
|
|
456
|
+
// old caveat: it is a codepoint comparison here (deliberately not
|
|
457
|
+
// `localeCompare`, so the ordering never depends on the HOST's locale), while
|
|
458
|
+
// `order by m.scope asc` sorts under the DATABASE's collation (`en_US.UTF-8` on a
|
|
459
|
+
// default Supabase project), which does not order like codepoint around
|
|
460
|
+
// punctuation — and a scope string is mostly punctuation (`::`, `/`, `-`), so
|
|
461
|
+
// two equal-count scopes like `repo::a-b` and `repo::ab` can come out in the
|
|
462
|
+
// opposite relative order on the two surfaces. Case cannot differ (every scope
|
|
463
|
+
// segment is lowercased, see docs/scope-format.md). Nothing should depend on the
|
|
464
|
+
// two agreeing on the exact position of a punctuated equal-count neighbour.
|
|
467
465
|
function sortScopes(rows) {
|
|
468
|
-
return rows.sort(
|
|
466
|
+
return rows.sort(
|
|
467
|
+
(a, b) => b.count - a.count || (a.scope < b.scope ? -1 : a.scope > b.scope ? 1 : 0),
|
|
468
|
+
);
|
|
469
469
|
}
|
|
470
470
|
|
|
471
471
|
// Provenance for a tool call: the caller's explicit values win, the working
|
package/src/store/remote.mjs
CHANGED
|
@@ -257,7 +257,7 @@ class RemoteStore {
|
|
|
257
257
|
// The `scopes` array is the SAME `[{ scope, count }]` inventory shape
|
|
258
258
|
// `LocalStore.listScopes()` returns, so `scopes.mjs` feeds both through the
|
|
259
259
|
// same pure `filterScopeInventory`/`summarizeScopeInventory` helpers. Ordering
|
|
260
|
-
// is not relied upon (the server sorts by
|
|
260
|
+
// is not relied upon (the server sorts by count desc; the view re-sorts by
|
|
261
261
|
// scope type). Failures use this store's standard `{ ok:false, error,
|
|
262
262
|
// networkError }` envelope so the caller can degrade gracefully.
|
|
263
263
|
//
|