cf-memory-mcp 3.39.0 → 3.41.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.
@@ -2487,7 +2487,16 @@ class CFMemoryMCP {
2487
2487
  * detection fails.
2488
2488
  */
2489
2489
  getRepoMetadata() {
2490
- if (this._repoMetaCache) return this._repoMetaCache;
2490
+ // 60s TTL: long enough to amortize git invocations across a flurry
2491
+ // of tool calls, short enough that a branch switch mid-session
2492
+ // gets picked up within a minute. Without the TTL, the bridge
2493
+ // would keep reporting the original branch for the whole process
2494
+ // lifetime even after `git checkout other-branch`.
2495
+ const TTL_MS = 60_000;
2496
+ if (this._repoMetaCache && this._repoMetaCacheTime &&
2497
+ (Date.now() - this._repoMetaCacheTime) < TTL_MS) {
2498
+ return this._repoMetaCache;
2499
+ }
2491
2500
  const result = {};
2492
2501
  try {
2493
2502
  const root = process.env.CF_MEMORY_WATCH_PATH || process.cwd();
@@ -2509,6 +2518,7 @@ class CFMemoryMCP {
2509
2518
  if (branch) result.branch = branch;
2510
2519
  } catch (_) { /* not a git repo, detached HEAD, or no branch — leave undefined */ }
2511
2520
  this._repoMetaCache = result;
2521
+ this._repoMetaCacheTime = Date.now();
2512
2522
  _mcpTrace('REPO_META', `repo_path=${result.repo_path||'?'} branch=${result.branch||'?'}`);
2513
2523
  return result;
2514
2524
  }
@@ -3914,6 +3924,8 @@ function parseCliArgs(rest) {
3914
3924
  flags.chain = true;
3915
3925
  } else if (a === '--validate') {
3916
3926
  flags.validate = true;
3927
+ } else if (a === '--raw') {
3928
+ flags.raw = true;
3917
3929
  } else if (a === '--older-than') {
3918
3930
  // Accept "7d" / "30d" / "12h" / raw number (days).
3919
3931
  const raw = rest[++i] || '';
@@ -4067,6 +4079,15 @@ async function runResumeCli() {
4067
4079
  process.exit(0);
4068
4080
  }
4069
4081
 
4082
+ // --raw: print the bare handoff JSON (no envelope metadata).
4083
+ // Useful for migrations, direct inspection, or piping to jq.
4084
+ if (flags.raw) {
4085
+ const handoff = payload.resume_handoff?.handoff;
4086
+ if (!handoff) process.exit(3);
4087
+ process.stdout.write(JSON.stringify(handoff, null, 2) + '\n');
4088
+ process.exit(0);
4089
+ }
4090
+
4070
4091
  // --chain: walk parent_session_id back through the thread history.
4071
4092
  // Bounded at 20 iterations to avoid an infinite loop on malformed
4072
4093
  // data. Prints each handoff as "<id> [age] status — goal".
@@ -4299,7 +4320,8 @@ async function runListCli() {
4299
4320
  const status = (h.status || 'unknown').padEnd(11);
4300
4321
  const branch = h.branch ? `[${h.branch}] ` : '';
4301
4322
  const goal = (h.goal || '(no goal)').slice(0, 80);
4302
- process.stdout.write(` ${shortId} ${status} ${age.padStart(4)} ago ${branch}${goal}\n`);
4323
+ const q = typeof h.quality_score === 'number' ? ` q=${h.quality_score.toFixed(2)}` : '';
4324
+ process.stdout.write(` ${shortId} ${status} ${age.padStart(4)} ago${q} ${branch}${goal}\n`);
4303
4325
  if (h.next_step) process.stdout.write(` next: ${h.next_step.slice(0, 80)}\n`);
4304
4326
  }
4305
4327
  process.stdout.write(`\n(Run "npx cf-memory-mcp resume <id>" to see a specific handoff)\n`);
@@ -4611,6 +4633,26 @@ _cf_memory_mcp() {
4611
4633
  fi
4612
4634
  }
4613
4635
  _cf_memory_mcp "\$@"
4636
+ `);
4637
+ } else if (shell === 'powershell' || shell === 'pwsh') {
4638
+ process.stdout.write(`# cf-memory-mcp PowerShell completion
4639
+ # Install: cf-memory-mcp completion powershell | Out-String | Invoke-Expression
4640
+ # To persist: add the above to your $PROFILE
4641
+ Register-ArgumentCompleter -Native -CommandName cf-memory-mcp,cfm -ScriptBlock {
4642
+ param($wordToComplete, $commandAst, $cursorPosition)
4643
+ $commands = @('${commands.join("','")}')
4644
+ $flags = @('${flags.filter(f => f.startsWith('--')).join("','")}')
4645
+ $tokens = $commandAst.CommandElements | ForEach-Object { $_.Extent.Text }
4646
+ if ($tokens.Count -le 2) {
4647
+ $commands | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
4648
+ [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
4649
+ }
4650
+ } elseif ($wordToComplete.StartsWith('--')) {
4651
+ $flags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
4652
+ [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterName', $_)
4653
+ }
4654
+ }
4655
+ }
4614
4656
  `);
4615
4657
  } else if (shell === 'fish') {
4616
4658
  process.stdout.write(`# cf-memory-mcp fish completion
@@ -4625,7 +4667,7 @@ complete -c cf-memory-mcp -l help -s h -d 'Show help'
4625
4667
  complete -c cf-memory-mcp -l version -s v -d 'Show version'
4626
4668
  `);
4627
4669
  } else {
4628
- process.stderr.write(`Unknown shell "${shell}". Supported: bash, zsh, fish.\n`);
4670
+ process.stderr.write(`Unknown shell "${shell}". Supported: bash, zsh, fish, powershell.\n`);
4629
4671
  process.exit(1);
4630
4672
  }
4631
4673
  process.exit(0);
@@ -4646,6 +4688,7 @@ const PER_COMMAND_HELP = {
4646
4688
  --blockers-only open blockers, one per line.
4647
4689
  --chain Walk parent_session_id back; show the thread history.
4648
4690
  --validate Check that files_touched + code_anchors still exist locally.
4691
+ --raw Print just the raw handoff JSON (no envelope metadata).
4649
4692
  --json, -j Full bootstrap payload as JSON.
4650
4693
  Exit codes: 0 = found, 3 = no handoff / no data, 4 = --validate found missing files.`,
4651
4694
  list: `cf-memory-mcp list [--status S] [--since ISO] [--repo PATH] [--limit N] [--json]
@@ -4687,7 +4730,7 @@ const PER_COMMAND_HELP = {
4687
4730
  cache writability, worker reachability, project indexing, resume
4688
4731
  availability. Exit nonzero if any check fails.
4689
4732
  --json, -j Emit a JSON list of checks.`,
4690
- completion: `cf-memory-mcp completion [bash|zsh|fish]
4733
+ completion: `cf-memory-mcp completion [bash|zsh|fish|powershell]
4691
4734
  Output shell completion script. Pipe to your shell's completion dir.`,
4692
4735
  delete: `cf-memory-mcp delete <session-id-or-prefix> [--json]
4693
4736
  cf-memory-mcp delete [--status STATUS] [--older-than 30d] [--repo PATH] --yes [--json]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cf-memory-mcp",
3
- "version": "3.39.0",
3
+ "version": "3.41.0",
4
4
  "description": "Cloudflare-hosted MCP server for code indexing, retrieval, and assistant memory with a direct remote MCP endpoint and local stdio bridge.",
5
5
  "main": "bin/cf-memory-mcp.js",
6
6
  "bin": {