@rigstate/mcp 0.7.3 → 0.7.5

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
@@ -1192,10 +1192,13 @@ import { z as z2 } from "zod";
1192
1192
  var QueryGlobalAntidotesSchema = z2.object({
1193
1193
  categories: z2.array(z2.string()).optional().describe("Filter by categories (SECURITY, ARCHITECTURE, UX, PERFORMANCE, ACCESSIBILITY, MAINTAINABILITY)"),
1194
1194
  severities: z2.array(z2.string()).optional().describe("Filter by severity (CRITICAL, HIGH, MEDIUM, LOW)"),
1195
- framework_tags: z2.array(z2.string()).optional().describe('Filter by framework tags (e.g., ["nextjs", "react", "supabase"])'),
1196
- min_trust_score: z2.number().optional().describe("Minimum trust score (0-100)"),
1195
+ framework_tags: z2.preprocess(
1196
+ (val) => typeof val === "string" ? JSON.parse(val) : val,
1197
+ z2.array(z2.string())
1198
+ ).optional().describe('Filter by framework tags (e.g., ["nextjs", "react", "supabase"])'),
1199
+ min_trust_score: z2.coerce.number().optional().describe("Minimum trust score (0-100)"),
1197
1200
  search_text: z2.string().optional().describe("Search in title and instruction"),
1198
- limit: z2.number().optional().describe("Max results (default: 20)")
1201
+ limit: z2.coerce.number().optional().describe("Max results (default: 20)")
1199
1202
  });
1200
1203
  var SubmitSignalSchema = z2.object({
1201
1204
  projectId: z2.string().describe("The UUID of the Rigstate project"),
@@ -1205,7 +1208,10 @@ var SubmitSignalSchema = z2.object({
1205
1208
  severity: z2.enum(["CRITICAL", "HIGH", "MEDIUM", "LOW"]).describe("Severity level"),
1206
1209
  example: z2.string().optional().describe("Good example demonstrating the instruction"),
1207
1210
  anti_example: z2.string().optional().describe("Bad example showing what NOT to do"),
1208
- framework_tags: z2.array(z2.string()).optional().describe("Relevant framework tags"),
1211
+ framework_tags: z2.preprocess(
1212
+ (val) => typeof val === "string" ? [val] : val,
1213
+ z2.array(z2.string())
1214
+ ).optional().describe("Relevant framework tags"),
1209
1215
  reasoning: z2.string().optional().describe("Why this signal should be added"),
1210
1216
  source_type: z2.string().optional().describe("Internal source type override (e.g. TEACHER_MODE)")
1211
1217
  });
@@ -1739,15 +1745,15 @@ import { z as z4 } from "zod";
1739
1745
  var QueryBrainInputSchema = z4.object({
1740
1746
  projectId: z4.string().uuid("Invalid project ID"),
1741
1747
  query: z4.string().min(1, "Query is required"),
1742
- limit: z4.number().min(1).max(20).optional().default(8),
1743
- threshold: z4.number().min(0).max(1).optional().default(0.1)
1748
+ limit: z4.coerce.number().min(1).max(20).optional().default(8),
1749
+ threshold: z4.coerce.number().min(0).max(1).optional().default(0.1)
1744
1750
  });
1745
1751
  var GetProjectContextInputSchema = z4.object({
1746
1752
  projectId: z4.string().uuid("Invalid project ID")
1747
1753
  });
1748
1754
  var GetLatestDecisionsInputSchema = z4.object({
1749
1755
  projectId: z4.string().uuid("Invalid project ID"),
1750
- limit: z4.number().min(1).max(10).optional().default(5)
1756
+ limit: z4.coerce.number().min(1).max(10).optional().default(5)
1751
1757
  });
1752
1758
  var SaveDecisionInputSchema = z4.object({
1753
1759
  projectId: z4.string().uuid("Invalid project ID"),
@@ -1755,14 +1761,14 @@ var SaveDecisionInputSchema = z4.object({
1755
1761
  decision: z4.string().min(1, "Decision content is required"),
1756
1762
  rationale: z4.string().optional(),
1757
1763
  category: z4.enum(["decision", "architecture", "constraint", "tech_stack", "design_rule"]).optional().default("decision"),
1758
- tags: z4.array(z4.string()).optional().default([])
1764
+ tags: z4.preprocess((val) => typeof val === "string" ? [val] : val, z4.array(z4.string())).optional().default([])
1759
1765
  });
1760
1766
  var SubmitIdeaInputSchema = z4.object({
1761
1767
  projectId: z4.string().uuid("Invalid project ID"),
1762
1768
  title: z4.string().min(1, "Title is required").max(200, "Title too long"),
1763
1769
  description: z4.string().min(1, "Description is required"),
1764
1770
  category: z4.enum(["feature", "improvement", "experiment", "pivot"]).optional().default("feature"),
1765
- tags: z4.array(z4.string()).optional().default([])
1771
+ tags: z4.preprocess((val) => typeof val === "string" ? [val] : val, z4.array(z4.string())).optional().default([])
1766
1772
  });
1767
1773
  var UpdateRoadmapInputSchema = z4.object({
1768
1774
  projectId: z4.string().uuid("Invalid project ID"),
@@ -1820,7 +1826,7 @@ var GenerateProfessionalPDFInputSchema = z4.object({
1820
1826
  var ArchaeologicalScanInputSchema = z4.object({
1821
1827
  projectId: z4.string().uuid("Invalid project ID"),
1822
1828
  gitLog: z4.string().describe("Git log output"),
1823
- fileTree: z4.array(z4.string()).describe("File paths")
1829
+ fileTree: z4.preprocess((val) => typeof val === "string" ? [val] : val, z4.array(z4.string())).describe("File paths")
1824
1830
  });
1825
1831
  var ImportGhostFeaturesInputSchema = z4.object({
1826
1832
  projectId: z4.string().uuid("Invalid project ID"),
@@ -1836,7 +1842,7 @@ var AuditSecurityIntegrityInputSchema = z4.object({
1836
1842
  projectId: z4.string().uuid(),
1837
1843
  filePath: z4.string().min(1),
1838
1844
  content: z4.string().min(1),
1839
- rules: z4.array(z4.string()).optional()
1845
+ rules: z4.preprocess((val) => typeof val === "string" ? [val] : val, z4.array(z4.string())).optional()
1840
1846
  });
1841
1847
  var FetchPackageHealthInputSchema = z4.object({
1842
1848
  packageName: z4.string().min(1)
@@ -1846,7 +1852,7 @@ var SaveToProjectBrainInputSchema = z4.object({
1846
1852
  title: z4.string().min(1),
1847
1853
  content: z4.string().min(1),
1848
1854
  category: z4.enum(["DECISION", "ARCHITECTURE", "NOTE", "LESSON_LEARNED"]).default("NOTE"),
1849
- tags: z4.array(z4.string()).optional().default([])
1855
+ tags: z4.preprocess((val) => typeof val === "string" ? [val] : val, z4.array(z4.string())).optional().default([])
1850
1856
  });
1851
1857
  var UpdateRoadmapStatusInputSchema = z4.object({
1852
1858
  projectId: z4.string().uuid(),
@@ -1875,11 +1881,11 @@ var GenerateCursorRulesInputSchema = z4.object({
1875
1881
  });
1876
1882
  var AnalyzeDatabasePerformanceInputSchema = z4.object({
1877
1883
  projectId: z4.string().uuid(),
1878
- filePaths: z4.array(z4.string())
1884
+ filePaths: z4.preprocess((val) => typeof val === "string" ? [val] : val, z4.array(z4.string()))
1879
1885
  });
1880
1886
  var AuditIntegrityGateInputSchema = z4.object({
1881
1887
  projectId: z4.string().uuid(),
1882
- filePaths: z4.array(z4.string()).optional().default([])
1888
+ filePaths: z4.preprocess((val) => typeof val === "string" ? [val] : val, z4.array(z4.string())).optional().default([])
1883
1889
  });
1884
1890
  var CompleteRoadmapTaskInputSchema = z4.object({
1885
1891
  projectId: z4.string().uuid(),
@@ -1937,14 +1943,19 @@ async function getProjectContext(supabase, userId, projectId) {
1937
1943
  repository_tree: projectRow.repository_tree
1938
1944
  };
1939
1945
  const stackDef = projectRow.architectural_dna?.stack_definition;
1940
- const [activeTaskResult, nextTaskResult] = await Promise.all([
1941
- supabase.from("roadmap_chunks").select("id, title, step_number, role, instruction_set").eq("project_id", projectId).in("status", ["IN_PROGRESS", "ACTIVE"]).limit(1).maybeSingle(),
1942
- supabase.from("roadmap_chunks").select("id, title, step_number, role").eq("project_id", projectId).in("status", ["PENDING", "LOCKED"]).order("step_number", { ascending: true }).limit(1).maybeSingle()
1943
- ]);
1944
- const activeTask = activeTaskResult.data;
1945
- const nextTask = nextTaskResult.data;
1946
- const { data: agentTasks } = await supabase.from("agent_bridge").select("id, roadmap_chunks(title), execution_summary, completed_at").eq("project_id", projectId).eq("status", "COMPLETED").order("completed_at", { ascending: false }).limit(2);
1947
- const { data: roadmapItems } = await supabase.from("roadmap_chunks").select("title, status, updated_at").eq("project_id", projectId).order("updated_at", { ascending: false }).limit(2);
1946
+ const { data: allChunks, error: chunksError } = await supabase.rpc("get_roadmap_chunks_secure", {
1947
+ p_project_id: projectId,
1948
+ p_user_id: userId
1949
+ });
1950
+ const tasks = allChunks || [];
1951
+ const activeTask = tasks.find((t) => ["IN_PROGRESS", "ACTIVE"].includes(t.status));
1952
+ const nextTask = tasks.filter((t) => ["PENDING", "LOCKED"].includes(t.status)).sort((a, b) => a.step_number - b.step_number)[0];
1953
+ const { data: agentTasks } = await supabase.rpc("get_agent_bridge_secure", {
1954
+ p_project_id: projectId,
1955
+ p_user_id: userId,
1956
+ p_limit: 2
1957
+ });
1958
+ const roadmapItems = tasks.sort((a, b) => new Date(b.updated_at || b.created_at).getTime() - new Date(a.updated_at || a.created_at).getTime()).slice(0, 2);
1948
1959
  const techStack = {
1949
1960
  framework: null,
1950
1961
  orm: null,
@@ -2027,7 +2038,7 @@ Description: ${project.description}`);
2027
2038
  summaryParts.push("\nLatest AI Executions:");
2028
2039
  agentTasks.forEach((t) => {
2029
2040
  const time = t.completed_at ? new Date(t.completed_at).toLocaleString() : "Recently";
2030
- summaryParts.push(`- [${time}] ${t.roadmap_chunks?.title || "Task"}: ${t.execution_summary || "Completed"}`);
2041
+ summaryParts.push(`- [${time}] ${t.roadmap_title || "Task"}: ${t.execution_summary || "Completed"}`);
2031
2042
  });
2032
2043
  }
2033
2044
  if (roadmapItems && roadmapItems.length > 0) {
@@ -2770,25 +2781,30 @@ Shows active and locked steps with their step numbers.`,
2770
2781
  }
2771
2782
  });
2772
2783
  async function listRoadmapTasks(supabase, userId, projectId) {
2773
- const { data: hasAccess, error: accessError } = await supabase.rpc("check_project_access_secure", {
2784
+ const { data: tasks, error } = await supabase.rpc("get_roadmap_chunks_secure", {
2774
2785
  p_project_id: projectId,
2775
2786
  p_user_id: userId
2776
2787
  });
2777
- if (accessError || !hasAccess) {
2778
- throw new Error("Project not found or access denied");
2779
- }
2780
- const { data: tasks, error } = await supabase.from("roadmap_chunks").select("id, title, priority, status, step_number, prompt_content").eq("project_id", projectId).neq("status", "COMPLETED").order("priority", { ascending: false }).order("step_number", { ascending: true });
2781
2788
  if (error) {
2789
+ if (error.message.includes("Access Denied")) {
2790
+ throw new Error("Project not found or access denied");
2791
+ }
2782
2792
  console.error("Failed to fetch roadmap tasks:", error);
2783
2793
  throw new Error("Failed to fetch roadmap tasks");
2784
2794
  }
2785
- const formatted = (tasks || []).length > 0 ? (tasks || []).map((t) => {
2795
+ const activeTasks = (tasks || []).filter((t) => t.status !== "COMPLETED").sort((a, b) => {
2796
+ if (a.priority !== b.priority) {
2797
+ const priorityOrder = { "CRITICAL": 3, "HIGH": 2, "MEDIUM": 1, "LOW": 0 };
2798
+ return (priorityOrder[b.priority] || 0) - (priorityOrder[a.priority] || 0);
2799
+ }
2800
+ return a.step_number - b.step_number;
2801
+ });
2802
+ const formatted = activeTasks.length > 0 ? activeTasks.map((t) => {
2786
2803
  const statusEmoji = t.status === "ACTIVE" ? "\u{1F535}" : "\u{1F512}";
2787
- const priorityStr = t.priority ? `[${t.priority}]` : "";
2788
2804
  return `${statusEmoji} Step ${t.step_number}: ${t.title} (ID: ${t.id})`;
2789
2805
  }).join("\n") : "No active or locked tasks found in the roadmap.";
2790
2806
  return {
2791
- tasks: (tasks || []).map((t) => ({
2807
+ tasks: activeTasks.map((t) => ({
2792
2808
  id: t.id,
2793
2809
  title: t.title,
2794
2810
  priority: t.priority,
@@ -2810,29 +2826,38 @@ Useful for transitioning between tasks.`,
2810
2826
  handler: async (args, context) => {
2811
2827
  const result = await getNextRoadmapStep(
2812
2828
  context.supabase,
2829
+ context.userId,
2813
2830
  args.projectId,
2814
2831
  args.currentStepId
2815
2832
  );
2816
2833
  return { content: [{ type: "text", text: result.message }] };
2817
2834
  }
2818
2835
  });
2819
- async function getNextRoadmapStep(supabase, projectId, currentStepId) {
2836
+ async function getNextRoadmapStep(supabase, userId, projectId, currentStepId) {
2837
+ const { data: allTasks, error: fetchError } = await supabase.rpc("get_roadmap_chunks_secure", {
2838
+ p_project_id: projectId,
2839
+ p_user_id: userId
2840
+ });
2841
+ if (fetchError) {
2842
+ throw new Error(`Failed to fetch roadmap data: ${fetchError.message}`);
2843
+ }
2844
+ const tasks = allTasks || [];
2820
2845
  let currentStepNumber = 0;
2821
2846
  if (currentStepId) {
2822
- const { data: current } = await supabase.from("roadmap_chunks").select("step_number").eq("id", currentStepId).single();
2847
+ const current = tasks.find((t) => t.id === currentStepId);
2823
2848
  if (current) {
2824
2849
  currentStepNumber = current.step_number;
2825
2850
  }
2826
2851
  } else {
2827
- const { data: active } = await supabase.from("roadmap_chunks").select("step_number").eq("project_id", projectId).in("status", ["ACTIVE", "IN_PROGRESS"]).order("step_number", { ascending: true }).limit(1).single();
2852
+ const active = tasks.filter((t) => ["ACTIVE", "IN_PROGRESS"].includes(t.status)).sort((a, b) => a.step_number - b.step_number)[0];
2828
2853
  if (active) {
2829
- currentStepNumber = active.step_number;
2854
+ return {
2855
+ nextStep: active,
2856
+ message: `Current active step: [Step ${active.step_number}] ${active.title}`
2857
+ };
2830
2858
  }
2831
2859
  }
2832
- const { data: nextStep, error } = await supabase.from("roadmap_chunks").select("*").eq("project_id", projectId).gt("step_number", currentStepNumber).neq("status", "COMPLETED").order("step_number", { ascending: true }).limit(1).single();
2833
- if (error && error.code !== "PGRST116") {
2834
- throw new Error(`Failed to fetch next roadmap step: ${error.message}`);
2835
- }
2860
+ const nextStep = tasks.filter((t) => t.step_number > currentStepNumber && t.status !== "COMPLETED").sort((a, b) => a.step_number - b.step_number)[0];
2836
2861
  if (!nextStep) {
2837
2862
  return {
2838
2863
  nextStep: null,