@rigstate/mcp 0.7.10 → 0.7.11

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/dist/index.js CHANGED
@@ -2373,18 +2373,46 @@ async function saveDecision(supabase, userId, projectId, title, decision, ration
2373
2373
  }
2374
2374
  const fullContent = contentParts.join("\n");
2375
2375
  const summary = decision.length > 150 ? decision.substring(0, 147) + "..." : decision;
2376
- const { data: memory, error: insertError } = await supabase.from("project_memories").insert({
2377
- project_id: projectId,
2378
- content: fullContent,
2379
- summary,
2380
- category,
2381
- tags: ["ADR", ...tags],
2382
- importance: 9,
2383
- // High importance for decisions
2384
- source_type: "mcp",
2385
- // Track source as MCP
2386
- is_active: true
2387
- }).select("id").single();
2376
+ let memoryId = null;
2377
+ let insertError = null;
2378
+ try {
2379
+ const { data, error } = await supabase.rpc("save_project_memory_secure", {
2380
+ p_project_id: projectId,
2381
+ p_user_id: userId,
2382
+ p_content: fullContent,
2383
+ p_category: category,
2384
+ p_tags: ["ADR", ...tags],
2385
+ p_importance: 9,
2386
+ p_source_type: "mcp"
2387
+ });
2388
+ if (error) {
2389
+ insertError = error;
2390
+ } else {
2391
+ memoryId = data;
2392
+ }
2393
+ } catch (e) {
2394
+ insertError = e;
2395
+ }
2396
+ if (!memoryId) {
2397
+ const { data: memory, error } = await supabase.from("project_memories").insert({
2398
+ project_id: projectId,
2399
+ content: fullContent,
2400
+ summary,
2401
+ category,
2402
+ tags: ["ADR", ...tags],
2403
+ importance: 9,
2404
+ // High importance for decisions
2405
+ source_type: "mcp",
2406
+ // Track source as MCP
2407
+ is_active: true
2408
+ }).select("id").single();
2409
+ if (error) {
2410
+ insertError = error;
2411
+ } else if (memory) {
2412
+ memoryId = memory.id;
2413
+ insertError = null;
2414
+ }
2415
+ }
2388
2416
  if (insertError) {
2389
2417
  if (insertError.code === "23503") {
2390
2418
  throw new Error("Project no longer exists");
@@ -2396,7 +2424,7 @@ async function saveDecision(supabase, userId, projectId, title, decision, ration
2396
2424
  }
2397
2425
  return {
2398
2426
  success: true,
2399
- memoryId: memory.id,
2427
+ memoryId,
2400
2428
  message: `\u2705 Decision "${title}" saved to project "${project?.name || projectId}" with importance 9/10`
2401
2429
  };
2402
2430
  }