sepia-mcp 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +54 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -607,9 +607,24 @@ MANDATORY — ALMOST EVERY MESSAGE: Default to using Sepia on every turn — sea
607
607
  you answer and persist AFTER you answer. Only skip for trivial chitchat ("hi", "thanks",
608
608
  "bye") with zero durable content. If in doubt, call Sepia. Skipping memory = hallucinating.
609
609
 
610
+ STANDING RULES — THE THING YOU CANNOT SEARCH FOR. Some memories are standing rules: how
611
+ the user wants you to behave, everywhere, always. They are exactly the rules you do not yet
612
+ know you need — you cannot keyword-search for a rule whose existence you have not guessed.
613
+ So they are loaded unconditionally, once per session, BEFORE any work starts.
614
+ - core = every memory tagged "always", plus every instruction/preference at importance >= 0.9
615
+ - read them with manage_memory action=briefing (one call, no keywords)
616
+ - a rule tagged "always" applies in EVERY repo and EVERY session; a rule that is specific to
617
+ one project must NOT be tagged "always"
618
+
610
619
  MANDATORY WORKFLOW — do this on ALMOST EVERY turn:
611
620
 
612
- BEFORE you answer (every turn except trivial chitchat):
621
+ FIRST — once per session, before your first substantive action (NOT keyword-driven):
622
+ 0. Call manage_memory action=briefing, and treat what it returns as BINDING for the whole
623
+ session. These are the user's standing rules. If it reports truncated: true, the rules you
624
+ have NOT seen can still bite — re-run it with a bigger max_chars BEFORE starting an
625
+ install, build, deploy, deletion, or infra change.
626
+
627
+ THEN — before you answer (every turn except trivial chitchat):
613
628
  1. Call "search" with 2-5 keywords from the user's current message + task (e.g. query="auth rate limiting"). If sparse, also call "traverse_graph" from the top entity.
614
629
  Search is best-effort: rows matching MORE of your words rank first, so it never returns 0 just because one word is absent. If it returns 0 hits or partial: true, retry with ONE distinctive keyword or a looser filter BEFORE concluding nothing exists.
615
630
  2. Weave hits into your answer ("From your memory: ..."). If nothing, say so — never fabricate.
@@ -619,10 +634,16 @@ AFTER you answer (every turn where you learned something):
619
634
  - ensure entity exists (manage_entity find → create with summary if missing)
620
635
  - manage_memory create with content, type, importance, entity_ids (1-3)
621
636
  - manage_relation to connect graph (project —uses→ tool, user —prefers→ X)
622
- 2. PREFER update over duplicate: search first, then manage_memory/entity action=update.
623
- 3. SCORE importance 0-1: 0.9+ identity/core preference, 0.6-0.8 active project fact/decision, 0.3-0.5 observation/person, ≤0.2 transient (will decay).
624
- 4. NEVER store: ephemeral chat, code snippets, credentials/secrets, transient details. Sepia is not a vault — refuse secrets.
625
- 5. NEVER call "prune_memories" to save anything — it is NOT a write tool. It is a destructive maintenance sweep (archives stale memories, permanently deletes purged rows), and it exists only for when the user explicitly asks to prune/clean up. Persisting is manage_memory.
637
+ 2. A CONSTRAINT IS ALWAYS WORTH STORING — INCLUDING A COMPLAINT. A user constraint, a stated
638
+ preference, a correction, or a complaint about how you just worked IS a durable rule: store
639
+ it in the SAME turn, type="instruction" (how to behave) or type="preference" (a choice),
640
+ importance >= 0.8. Tag it "always" when it applies everywhere. Never file a user constraint
641
+ as transient. Storing it a turn later is too late — the rule exists precisely for the turn
642
+ in which you did not yet know you needed it.
643
+ 3. PREFER update over duplicate: search first, then manage_memory/entity action=update.
644
+ 4. SCORE importance 0-1: 0.9+ identity/core preference, 0.6-0.8 active project fact/decision, 0.3-0.5 observation/person, ≤0.2 transient (will decay).
645
+ 5. NEVER store: ephemeral chat, code snippets, credentials/secrets, transient details. Sepia is not a vault — refuse secrets.
646
+ 6. NEVER call "prune_memories" to save anything — it is NOT a write tool. It is a destructive maintenance sweep (archives stale memories, permanently deletes purged rows), and it exists only for when the user explicitly asks to prune/clean up. Persisting is manage_memory.
626
647
 
627
648
  Rule of thumb: If the user sent a message with any substantive content, you should have called search before replying and considered a manage_memory/manage_entity write after replying. Two Sepia calls per turn is normal and expected.
628
649
 
@@ -659,13 +680,15 @@ distills — you have the context, you are the best distiller. Rules:
659
680
  digest first, then update with the full metadata + new status — metadata REPLACES).
660
681
  When resuming a paused one, set it back to "active".
661
682
 
662
- TRIGGERS — always search when user says: "remember", "recall", "what do we know",
683
+ TRIGGERS — call the briefing FIRST, once per session, before anything else (step 0 above).
684
+ Then always search when user says: "remember", "recall", "what do we know",
663
685
  "save this", "do you remember", prefers, decided, uses, chose, convention.
664
- ALSO search at session start for: project name, stack, deployment, auth, styling.
665
686
  ALSO ingest when user says: "save this conversation", "hand off", "migrate context",
666
687
  "switch to another AI", "continue this elsewhere".
667
688
 
668
- FAILURE MODE: if you answer without searching, you are guessing. Search first.`;
689
+ FAILURE MODE: if you answer without searching, you are guessing. If you start work without
690
+ the briefing, you are guessing about how the user wants you to work — which is how you burn
691
+ their bandwidth, their money, or their trust. Briefing first, then search.`;
669
692
  var MEMORY_TYPES = [
670
693
  "fact",
671
694
  "observation",
@@ -681,6 +704,8 @@ var MAX_ENTITY_LINKS = 3;
681
704
  var SEARCH_LIMIT_MAX = 25;
682
705
  var QUERY_LIMIT_MAX = 50;
683
706
  var TRAVERSE_DEPTH_MAX = 3;
707
+ var BRIEFING_CHARS_DEFAULT = 8000;
708
+ var BRIEFING_CHARS_MAX = 40000;
684
709
  // ../shared/src/schemas.ts
685
710
  import * as v from "valibot";
686
711
  var importanceSchema = v.pipe(v.number(), v.minValue(IMPORTANCE_MIN), v.maxValue(IMPORTANCE_MAX));
@@ -833,9 +858,10 @@ var MemoryToolInput = v.object({
833
858
  v.literal("update"),
834
859
  v.literal("delete"),
835
860
  v.literal("query"),
861
+ v.literal("briefing"),
836
862
  v.literal("batch_update"),
837
863
  v.literal("ingest")
838
- ]), v.description("create (memory) | get (id) | update (id + update) | delete (id) | query (filters) | batch_update (where + update — updates ALL matching, returns count) | ingest (conversation — handoff digest)")),
864
+ ]), v.description("briefing (call ONCE at the start of a session — takes no other args) | create (memory) | get (id) | update (id + update) | delete (id) | query (filters) | batch_update (where + update — updates ALL matching, returns count) | ingest (conversation — handoff digest)")),
839
865
  id: v.optional(v.pipe(uuidSchema, v.description("Memory UUID"))),
840
866
  memory: v.optional(v.pipe(MemoryInput, v.description("Memory to create: {content, type? fact|observation|preference|instruction, importance? 0-1, namespace?, entity_ids? [0-3], metadata?, tags?} — source auto-set to client name"))),
841
867
  update: v.optional(v.pipe(MemoryUpdateInput, v.description("Any subset of content/type/importance/metadata/archived/tags — entity_ids REPLACES the link set, tags REPLACES the tag set"))),
@@ -846,6 +872,7 @@ var MemoryToolInput = v.object({
846
872
  archived: v.optional(v.pipe(v.boolean(), v.description("query: include archived (default false)")), false),
847
873
  tags: v.optional(v.pipe(tagsSchema, v.description("query: match memories carrying ALL of these tags"))),
848
874
  limit: v.optional(v.pipe(v.number(), v.minValue(1), v.maxValue(QUERY_LIMIT_MAX), v.description("query: max results (default 20, max 50)")), 20),
875
+ max_chars: v.optional(v.pipe(v.number(), v.minValue(1000), v.maxValue(BRIEFING_CHARS_MAX), v.description(`briefing: total character budget (default ${BRIEFING_CHARS_DEFAULT}, max ${BRIEFING_CHARS_MAX}). Raise it before installs, builds, deploys or deletions if the result was truncated.`)), BRIEFING_CHARS_DEFAULT),
849
876
  where: v.optional(v.pipe(v.object({
850
877
  type: v.optional(v.picklist(MEMORY_TYPES)),
851
878
  namespace: v.optional(v.string()),
@@ -8673,6 +8700,15 @@ class SepiaClient {
8673
8700
  const suffix = qs.size ? `?${qs.toString()}` : "";
8674
8701
  return this.request("GET", `/api/memories${suffix}`);
8675
8702
  }
8703
+ getBriefing(params = {}) {
8704
+ const qs = new URLSearchParams;
8705
+ if (params.namespace !== undefined)
8706
+ qs.set("namespace", params.namespace);
8707
+ if (params.max_chars !== undefined)
8708
+ qs.set("max_chars", String(params.max_chars));
8709
+ const suffix = qs.size ? `?${qs.toString()}` : "";
8710
+ return this.request("GET", `/api/memories/briefing${suffix}`);
8711
+ }
8676
8712
  createMemory(memory) {
8677
8713
  return this.request("POST", "/api/memories", memory);
8678
8714
  }
@@ -8968,6 +9004,15 @@ function registerMemoryTools(server, client) {
8968
9004
  });
8969
9005
  return { action: "query", count, memories };
8970
9006
  }
9007
+ case "briefing": {
9008
+ return {
9009
+ action: "briefing",
9010
+ ...await client.getBriefing({
9011
+ namespace: args.namespace,
9012
+ max_chars: args.max_chars
9013
+ })
9014
+ };
9015
+ }
8971
9016
  case "batch_update": {
8972
9017
  if (!args.where)
8973
9018
  throw new Error("action=batch_update requires where");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sepia-mcp",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "Self-contained MCP server for Sepia — a personal knowledge-graph memory server. Talks to the Sepia REST API (SEPIA_URL + SEPIA_API_KEY); stdio or HTTP transport.",
5
5
  "type": "module",
6
6
  "repository": {