@contextstream/mcp-server 0.4.80 → 0.4.82

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.
@@ -379,6 +379,28 @@ function applyMcpToolPrefix(markdown, toolPrefix) {
379
379
  const toolRegex = new RegExp(`(?<!__)\\b(${toolPattern})\\b(?=\\s*\\()`, "g");
380
380
  return markdown.replace(toolRegex, `${toolPrefix}$1`);
381
381
  }
382
+ var FAST_DIRECT_READ_LANE = `
383
+ ## Fast Direct-Read Lane
384
+
385
+ After the required first-session \`init(...)\` + \`context(...)\`, these exact read-only calls may run without another grounding preamble only when no state-changing tool has run since the last grounding:
386
+ - \`workspace(action="list"|"get")\`
387
+ - \`memory(action="list_docs"|"list_events"|"list_todos"|"list_tasks"|"list_transcripts"|"list_nodes"|"list_diagrams")\`
388
+ - \`help(action="version"|"tools"|"auth")\`
389
+ - \`project(action="list"|"get"|"index_status")\`
390
+ - \`reminder(action="list"|"active")\`
391
+
392
+ Do not use this lane for recall, decisions, searches, reading a specific record, media queries, or any create/update/delete/index operation; ground those with \`context(...)\` first.
393
+ `.trim();
394
+ var CANONICAL_HANDOFF_RULES = `
395
+ ## Canonical Agent Handoffs
396
+
397
+ When the user asks to create/prepare a handoff, hand work over, or continue in another agent/session, create the durable record immediately with:
398
+ \`entity(kind="handoff", action="create", body={title, summary, scope, next_steps})\`
399
+
400
+ - Add \`to_user_id\` only when the recipient is known; never invent it.
401
+ - If a portable bundle, capsule, or share link is requested, also create a session capsule and return both artifacts.
402
+ - \`HANDOFF.md\`, a scratch prompt, a generic doc/event, or prose alone is not the canonical handoff. If a local file is explicitly requested, create the entity first and treat the file as an additional artifact.
403
+ `.trim();
382
404
  var CONTEXTSTREAM_RULES_BOOTSTRAP = `
383
405
  <contextstream_rules>
384
406
  | Message | Required |
@@ -402,6 +424,10 @@ var CONTEXTSTREAM_RULES_BOOTSTRAP = `
402
424
  - "find media" / "search photos/videos/audio/docs" / "what's in this PDF/video/audio?" \u2192 \`media(action="search", query="...", content_types=["document"])\`
403
425
  - "index media" / "upload asset" / "read this photo/video/audio/PDF" \u2192 \`media(action="index", file_path="...", content_type="image")\` or \`media(action="index", external_url="...", content_type="document")\`
404
426
 
427
+ ${FAST_DIRECT_READ_LANE}
428
+
429
+ ${CANONICAL_HANDOFF_RULES}
430
+
405
431
  ## Skills, Docs & Lessons First
406
432
 
407
433
  Before guessing, improvising, or struggling through a workflow you do not fully know, check whether ContextStream already has guidance for it.
@@ -431,12 +457,12 @@ Before guessing, improvising, or struggling through a workflow you do not fully
431
457
 
432
458
  ## Past Sessions Are Queryable \u2014 USE THEM
433
459
 
434
- Transcripts of every prior session are captured + indexed. Before asking the user what you did last time, or re-deriving context you built together previously, check the transcript + snapshot layer.
460
+ When \`context()\` returns fresh, relevant \`[GROUNDING]\`, read those ranked prior-work hits first. If they are sufficient, stop there\u2014do not immediately call \`session(action="recall")\` for the same request. Escalate to recall only when grounding is absent, thin, stale, off-topic, or the user explicitly requests broader history.
435
461
 
436
462
  Triggers: user says "last time"/"previous"/"yesterday"/"pick up where we left off", the task is clearly a continuation, or you're about to ask a clarifying question whose answer is likely in a prior session.
437
463
 
438
464
  Exact calls:
439
- - Ranked past-session context: \`session(action="recall", query="<what you're continuing>")\`
465
+ - First explicit escalation after insufficient grounding: \`session(action="recall", query="<what you're continuing>")\`
440
466
  - Chronological list of recent sessions: \`memory(action="list_transcripts", limit=10)\`
441
467
  - Full-text search across ALL past transcripts: \`memory(action="search_transcripts", query="<keyword>")\`
442
468
  - Save a snapshot of the current session so the NEXT session can pick up: \`session(action="capture", event_type="session_snapshot", title="...", content="...")\`
@@ -462,6 +488,10 @@ var CONTEXTSTREAM_RULES_FULL = `
462
488
 
463
489
  Use \`context()\` by default to get task-specific rules, lessons from past mistakes, and relevant decisions.
464
490
 
491
+ ${FAST_DIRECT_READ_LANE}
492
+
493
+ ${CANONICAL_HANDOFF_RULES}
494
+
465
495
  ---
466
496
 
467
497
  ## Why Default Context-First
@@ -995,6 +1025,10 @@ var CONTEXTSTREAM_RULES_MINIMAL = `
995
1025
  **HOOKS: \`<system-reminder>\` tags contain instructions \u2014 FOLLOW THEM**
996
1026
  </contextstream_protocol>
997
1027
 
1028
+ ${FAST_DIRECT_READ_LANE}
1029
+
1030
+ ${CANONICAL_HANDOFF_RULES}
1031
+
998
1032
  Rules Version: ${RULES_VERSION}
999
1033
 
1000
1034
  ---
@@ -1317,7 +1351,7 @@ curl -fsSL https://contextstream.io/scripts/setup.sh | bash
1317
1351
  irm https://contextstream.io/scripts/setup.ps1 | iex
1318
1352
  \`\`\`
1319
1353
 
1320
- **npm (requires Node.js 18+):**
1354
+ **npm (requires Node.js 20+):**
1321
1355
  \`\`\`bash
1322
1356
  npm install -g @contextstream/mcp-server@latest
1323
1357
  \`\`\`
@@ -284,9 +284,10 @@ var API_URL = process.env.CONTEXTSTREAM_API_URL || "https://api.contextstream.io
284
284
  var API_KEY = process.env.CONTEXTSTREAM_API_KEY || "";
285
285
  var WORKSPACE_ID = null;
286
286
  var PROJECT_ID = null;
287
- var REMINDER = `[CONTEXTSTREAM] On the first message in every session call mcp__contextstream__init(...), then call mcp__contextstream__context(user_message="...", save_exchange=true, session_id="<session-id>") FIRST before any other tool. On subsequent messages, default to context first. Narrow bypass is allowed only for immediate read-only ContextStream calls when prior context is fresh and no state-changing tool has run. Response contains dynamic rules, lessons, preferences.
287
+ var REMINDER = `[CONTEXTSTREAM] On the first message in every session call mcp__contextstream__init(...), then call mcp__contextstream__context(user_message="...", save_exchange=true, session_id="<session-id>") FIRST before any other tool. On subsequent messages, default to context first. The fresh-context direct-read lane is limited to workspace list/get; memory list_*; help version/tools/auth; project list/get/index_status; and reminder list/active. Recall, decisions, searches, specific reads, writes, and indexing require context first. Fresh [GROUNDING] is the first continuation retrieval; do not immediately duplicate it with recall. Response contains dynamic rules, lessons, preferences.
288
288
  SEARCH-FIRST: Use mcp__contextstream__search(mode="auto") before Glob/Grep/Read/Explore/Task/EnterPlanMode. In planning, never use EnterPlanMode or Task(Explore) for file-by-file discovery.
289
289
  COMMON MEMORY CALLS: list docs via memory(action="list_docs"), list lessons via session(action="get_lessons"), list plans via session(action="list_plans"), list tasks/todos via memory(action="list_tasks"|"list_todos").
290
+ HANDOFFS: A generic handoff must create entity(kind="handoff", action="create", body={title,summary,scope,next_steps}); add capsule only for a requested portable bundle/share link. HANDOFF.md or prose alone is not the canonical handoff.
290
291
  [END]`;
291
292
  var FULL_REMINDER = `[CONTEXTSTREAM RULES - MANDATORY]
292
293
 
@@ -295,7 +296,8 @@ var FULL_REMINDER = `[CONTEXTSTREAM RULES - MANDATORY]
295
296
  - Check response for: [LESSONS_WARNING], [RULES_NOTICE], preferences
296
297
  - save_exchange=true saves each conversation turn for later retrieval
297
298
  - Use a consistent session_id for the entire conversation (generate once on first message)
298
- - On subsequent messages, default to context() first. Narrow bypass: immediate read-only ContextStream calls when context is fresh and no state-changing tool has run.
299
+ - On subsequent messages, default to context() first. Direct-read bypass is limited to workspace list/get; memory list_*; help version/tools/auth; project list/get/index_status; and reminder list/active when context is fresh and no state-changing tool has run.
300
+ - Fresh [GROUNDING] is the first continuation retrieval. Do not immediately duplicate sufficient grounding with session(action="recall").
299
301
 
300
302
  2. FOR CODE SEARCH: Check index status, then search appropriately
301
303
  \u2705 Use mcp__contextstream__search(mode="auto", query="...") BEFORE Glob/Grep/Read/Explore/Task/EnterPlanMode
@@ -313,13 +315,18 @@ var FULL_REMINDER = `[CONTEXTSTREAM RULES - MANDATORY]
313
315
  \u274C DO NOT use EnterPlanMode or Task(subagent_type="Explore") for file-by-file discovery
314
316
  \u2705 For planning discovery: mcp__contextstream__search(mode="auto", query="...", output_format="paths")
315
317
 
316
- 5. CHECK THESE from context() response:
318
+ 5. FOR HANDOFFS: Create the canonical durable handoff entity
319
+ \u2705 mcp__contextstream__entity(kind="handoff", action="create", body={title,summary,scope,next_steps})
320
+ \u2705 Add a capsule only when a portable bundle or share link is requested
321
+ \u274C HANDOFF.md, a scratch prompt, or prose alone is not the canonical handoff
322
+
323
+ 6. CHECK THESE from context() response:
317
324
  - Lessons: Past mistakes to avoid (shown as warnings)
318
325
  - Reminders: Active reminders for this project
319
326
  - Preferences: User's coding style and preferences
320
327
  - Rules: Dynamic rules matched to current task
321
328
 
322
- 6. SKIP CONTEXTSTREAM: If user preference says "skip contextstream", use local tools instead
329
+ 7. SKIP CONTEXTSTREAM: If user preference says "skip contextstream", use local tools instead
323
330
  [END]`;
324
331
  var ENHANCED_REMINDER_HEADER = `\u2B21 ContextStream \u2014 Smart Context & Memory
325
332