@rigstate/mcp 0.7.6 → 0.7.7
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 +67 -62
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/project-context-utils.ts +32 -23
- package/src/tools/get-project-context.ts +2 -2
- package/src/tools/list-features.ts +18 -32
- package/src/tools/planning-tools.ts +10 -14
- package/src/tools/query-brain.ts +29 -41
package/dist/index.js
CHANGED
|
@@ -1903,10 +1903,10 @@ var CompleteRoadmapTaskInputSchema = z4.object({
|
|
|
1903
1903
|
|
|
1904
1904
|
// src/lib/project-context-utils.ts
|
|
1905
1905
|
init_esm_shims();
|
|
1906
|
-
async function buildProjectSummary(project, techStack, activeTask, nextTask, agentTasks, roadmapItems, stackDef, supabase) {
|
|
1906
|
+
async function buildProjectSummary(project, techStack, activeTask, nextTask, agentTasks, roadmapItems, stackDef, supabase, userId) {
|
|
1907
1907
|
const summaryParts = [];
|
|
1908
1908
|
summaryParts.push(`Project Type: ${project.project_type?.toUpperCase() || "UNKNOWN"}`);
|
|
1909
|
-
if (stackDef) {
|
|
1909
|
+
if (stackDef || activeTask || nextTask) {
|
|
1910
1910
|
summaryParts.push("\n=== ACTIVE MISSION PARAMETERS ===");
|
|
1911
1911
|
if (activeTask) {
|
|
1912
1912
|
summaryParts.push(`\u26A0\uFE0F CURRENT OBJECTIVE: T-${activeTask.step_number}: ${activeTask.title}`);
|
|
@@ -1937,11 +1937,19 @@ async function buildProjectSummary(project, techStack, activeTask, nextTask, age
|
|
|
1937
1937
|
summaryParts.push(` Tags: ${activeTask.tags.join(", ")}`);
|
|
1938
1938
|
}
|
|
1939
1939
|
if (activeTask.feature_id) {
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1940
|
+
try {
|
|
1941
|
+
const { data: dbFeatures } = await supabase.rpc("get_project_features_secure", {
|
|
1942
|
+
p_project_id: project.id,
|
|
1943
|
+
p_user_id: userId
|
|
1944
|
+
});
|
|
1945
|
+
const feature = dbFeatures?.find((f) => f.id === activeTask.feature_id);
|
|
1946
|
+
if (feature) {
|
|
1947
|
+
summaryParts.push(`
|
|
1943
1948
|
Parent Feature: ${feature.name}`);
|
|
1944
|
-
|
|
1949
|
+
summaryParts.push(` Feature Vision: ${feature.description}`);
|
|
1950
|
+
}
|
|
1951
|
+
} catch (e) {
|
|
1952
|
+
console.warn("Feature context fetch failed", e);
|
|
1945
1953
|
}
|
|
1946
1954
|
}
|
|
1947
1955
|
summaryParts.push("\n ACTION: Focus ALL coding efforts on completing this task.");
|
|
@@ -1964,13 +1972,15 @@ async function buildProjectSummary(project, techStack, activeTask, nextTask, age
|
|
|
1964
1972
|
summaryParts.push(`2. PROACTIVE: Instead of asking "How can I help?", ask "Shall we start on T-${nextTask.step_number}?"`);
|
|
1965
1973
|
}
|
|
1966
1974
|
summaryParts.push("\n=== CURRENT STACK ===");
|
|
1967
|
-
if (stackDef
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1975
|
+
if (stackDef) {
|
|
1976
|
+
if (stackDef.frontend) summaryParts.push(`Frontend: ${stackDef.frontend.framework} (${stackDef.frontend.language})`);
|
|
1977
|
+
if (stackDef.backend) summaryParts.push(`Backend: ${stackDef.backend.service} (${stackDef.backend.database})`);
|
|
1978
|
+
if (stackDef.styling) summaryParts.push(`Styling: ${stackDef.styling.framework} ${stackDef.styling.library || ""}`);
|
|
1979
|
+
if (stackDef.hosting) summaryParts.push(`Infrastructure: ${stackDef.hosting.provider}`);
|
|
1980
|
+
} else {
|
|
1981
|
+
if (techStack.framework) summaryParts.push(`Framework: ${techStack.framework}`);
|
|
1982
|
+
if (techStack.orm) summaryParts.push(`ORM: ${techStack.orm}`);
|
|
1983
|
+
}
|
|
1974
1984
|
}
|
|
1975
1985
|
if (project.description) {
|
|
1976
1986
|
summaryParts.push(`
|
|
@@ -1984,8 +1994,8 @@ Description: ${project.description}`);
|
|
|
1984
1994
|
if (spec.coreProblem) summaryParts.push(`Core Problem: ${spec.coreProblem}`);
|
|
1985
1995
|
if (spec.featureList && Array.isArray(spec.featureList)) {
|
|
1986
1996
|
summaryParts.push("\nKey Features & Nuances:");
|
|
1987
|
-
spec.featureList.filter((f) => f.priority === "MVP").forEach((f) => {
|
|
1988
|
-
summaryParts.push(`- ${f.name}: ${f.description}`);
|
|
1997
|
+
spec.featureList.filter((f) => f.priority === "MVP" || f.priority === "HIGH").slice(0, 10).forEach((f) => {
|
|
1998
|
+
summaryParts.push(`- ${f.name}: ${f.description?.substring(0, 200)}`);
|
|
1989
1999
|
});
|
|
1990
2000
|
}
|
|
1991
2001
|
}
|
|
@@ -2002,7 +2012,7 @@ Description: ${project.description}`);
|
|
|
2002
2012
|
summaryParts.push("\nLatest AI Executions:");
|
|
2003
2013
|
agentTasks.forEach((t) => {
|
|
2004
2014
|
const time = t.completed_at ? new Date(t.completed_at).toLocaleString() : "Recently";
|
|
2005
|
-
summaryParts.push(`- [${time}] ${t.roadmap_title || "Task"}: ${t.execution_summary || "Completed"}`);
|
|
2015
|
+
summaryParts.push(`- [${time}] ${t.roadmap_title || "Task"}: ${t.execution_summary?.substring(0, 100) || "Completed"}`);
|
|
2006
2016
|
});
|
|
2007
2017
|
}
|
|
2008
2018
|
if (roadmapItems && roadmapItems.length > 0) {
|
|
@@ -2114,7 +2124,8 @@ async function getProjectContext(supabase, userId, projectId) {
|
|
|
2114
2124
|
agentTasks || [],
|
|
2115
2125
|
roadmapItems || [],
|
|
2116
2126
|
stackDef,
|
|
2117
|
-
supabase
|
|
2127
|
+
supabase,
|
|
2128
|
+
userId
|
|
2118
2129
|
);
|
|
2119
2130
|
const response = {
|
|
2120
2131
|
project: {
|
|
@@ -2204,26 +2215,16 @@ async function queryBrain(supabase, userId, projectId, query, limit = 8, thresho
|
|
|
2204
2215
|
}
|
|
2205
2216
|
const embedding = await generateQueryEmbedding(query);
|
|
2206
2217
|
let memories = [];
|
|
2207
|
-
const { data: searchResults, error: searchError } = await supabase.rpc("
|
|
2218
|
+
const { data: searchResults, error: searchError } = await supabase.rpc("query_project_brain_secure", {
|
|
2208
2219
|
p_project_id: projectId,
|
|
2220
|
+
p_user_id: userId,
|
|
2209
2221
|
p_query: query,
|
|
2210
|
-
|
|
2211
|
-
p_limit: limit,
|
|
2212
|
-
p_similarity_threshold: threshold || 0.1
|
|
2222
|
+
p_limit: limit
|
|
2213
2223
|
});
|
|
2214
|
-
if (searchError) {
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
id: m.id,
|
|
2219
|
-
content: m.content,
|
|
2220
|
-
category: m.category || "general",
|
|
2221
|
-
tags: m.tags || [],
|
|
2222
|
-
netVotes: m.importance || 0,
|
|
2223
|
-
createdAt: m.created_at
|
|
2224
|
-
}));
|
|
2225
|
-
}
|
|
2226
|
-
} else if (searchResults) {
|
|
2224
|
+
if (searchError || !searchResults) {
|
|
2225
|
+
console.error("Brain query failed:", searchError);
|
|
2226
|
+
memories = [];
|
|
2227
|
+
} else {
|
|
2227
2228
|
memories = searchResults.map((m) => ({
|
|
2228
2229
|
id: m.id,
|
|
2229
2230
|
content: m.content,
|
|
@@ -2235,8 +2236,15 @@ async function queryBrain(supabase, userId, projectId, query, limit = 8, thresho
|
|
|
2235
2236
|
}
|
|
2236
2237
|
let relevantFeatures = [];
|
|
2237
2238
|
try {
|
|
2238
|
-
const { data:
|
|
2239
|
-
|
|
2239
|
+
const { data: projectRow } = await supabase.rpc("get_project_context_secure", {
|
|
2240
|
+
p_project_id: projectId,
|
|
2241
|
+
p_user_id: userId
|
|
2242
|
+
}).single();
|
|
2243
|
+
if (projectRow?.functional_spec) {
|
|
2244
|
+
const spec = typeof projectRow.functional_spec === "string" ? JSON.parse(projectRow.functional_spec) : projectRow.functional_spec;
|
|
2245
|
+
const features = spec.featureList || spec.features || [];
|
|
2246
|
+
relevantFeatures = features.filter((f) => (f.name || f.title)?.toLowerCase().includes(query.toLowerCase())).slice(0, 3);
|
|
2247
|
+
}
|
|
2240
2248
|
} catch (e) {
|
|
2241
2249
|
console.warn("Feature fetch failed in brain query", e);
|
|
2242
2250
|
}
|
|
@@ -2246,7 +2254,7 @@ async function queryBrain(supabase, userId, projectId, query, limit = 8, thresho
|
|
|
2246
2254
|
const category = m.category ? m.category.toUpperCase() : "GENERAL";
|
|
2247
2255
|
return `- [${category}]${tagStr}${voteIndicator}: ${m.content}`;
|
|
2248
2256
|
});
|
|
2249
|
-
const searchType = embedding ? "TRIPLE-HYBRID (Vector + FTS + Fuzzy)" : "
|
|
2257
|
+
const searchType = embedding ? "TRIPLE-HYBRID (Vector + FTS + Fuzzy)" : "SECURE-GATEWAY (Fuzzy)";
|
|
2250
2258
|
let formatted = `=== PROJECT BRAIN: RELEVANT MEMORIES ===
|
|
2251
2259
|
Search Mode: ${searchType}
|
|
2252
2260
|
Query: "${query}"`;
|
|
@@ -2254,7 +2262,7 @@ Query: "${query}"`;
|
|
|
2254
2262
|
formatted += `
|
|
2255
2263
|
|
|
2256
2264
|
=== RELATED FEATURES ===
|
|
2257
|
-
` + relevantFeatures.map((f) => `- ${f.name} [${f.status}]`).join("\n");
|
|
2265
|
+
` + relevantFeatures.map((f) => `- ${f.name || f.title} [${f.status || "Active"}]`).join("\n");
|
|
2258
2266
|
}
|
|
2259
2267
|
formatted += `
|
|
2260
2268
|
|
|
@@ -2818,32 +2826,30 @@ var listFeaturesTool = {
|
|
|
2818
2826
|
Useful for understanding the strategic context and major milestones.`,
|
|
2819
2827
|
schema: InputSchema,
|
|
2820
2828
|
handler: async ({ projectId }, { supabase, userId }) => {
|
|
2821
|
-
const { data:
|
|
2829
|
+
const { data: projectRow, error: projectError } = await supabase.rpc("get_project_context_secure", {
|
|
2822
2830
|
p_project_id: projectId,
|
|
2823
2831
|
p_user_id: userId
|
|
2824
|
-
});
|
|
2825
|
-
if (
|
|
2826
|
-
throw new Error("Project not found or access denied");
|
|
2827
|
-
}
|
|
2828
|
-
const { data: project, error: projectError } = await supabase.from("projects").select("id, functional_spec").eq("id", projectId).single();
|
|
2829
|
-
if (projectError || !project) {
|
|
2830
|
-
throw new Error("Project details not found");
|
|
2832
|
+
}).single();
|
|
2833
|
+
if (projectError || !projectRow) {
|
|
2834
|
+
throw new Error("Project details not found or access denied");
|
|
2831
2835
|
}
|
|
2832
|
-
const { data: dbFeatures, error: dbError } = await supabase.
|
|
2836
|
+
const { data: dbFeatures, error: dbError } = await supabase.rpc("get_project_features_secure", {
|
|
2837
|
+
p_project_id: projectId,
|
|
2838
|
+
p_user_id: userId
|
|
2839
|
+
});
|
|
2833
2840
|
let featuresList = [];
|
|
2834
2841
|
let source = "DB";
|
|
2835
2842
|
if (!dbError && dbFeatures && dbFeatures.length > 0) {
|
|
2836
2843
|
featuresList = dbFeatures.map((f) => ({
|
|
2837
2844
|
...f,
|
|
2838
2845
|
title: f.name
|
|
2839
|
-
// Map back to title specifically for uniform handling below
|
|
2840
2846
|
}));
|
|
2841
2847
|
} else {
|
|
2842
2848
|
source = "FALLBACK_SPEC";
|
|
2843
|
-
|
|
2844
|
-
const
|
|
2845
|
-
if (
|
|
2846
|
-
featuresList =
|
|
2849
|
+
const spec = projectRow.functional_spec;
|
|
2850
|
+
const features = spec?.featureList || spec?.features;
|
|
2851
|
+
if (Array.isArray(features)) {
|
|
2852
|
+
featuresList = features.map((f) => ({
|
|
2847
2853
|
id: "legacy",
|
|
2848
2854
|
title: f.name || f.title,
|
|
2849
2855
|
description: f.description,
|
|
@@ -3807,19 +3813,18 @@ async function saveToProjectBrain(supabase, userId, input) {
|
|
|
3807
3813
|
const fullContent = `# ${title}
|
|
3808
3814
|
|
|
3809
3815
|
${content}`;
|
|
3810
|
-
const { data, error } = await supabase.
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
}).select("id").single();
|
|
3816
|
+
const { data: memoryId, error } = await supabase.rpc("save_project_memory_secure", {
|
|
3817
|
+
p_project_id: projectId,
|
|
3818
|
+
p_user_id: userId,
|
|
3819
|
+
p_content: fullContent,
|
|
3820
|
+
p_category: category.toLowerCase(),
|
|
3821
|
+
p_tags: tags || [],
|
|
3822
|
+
p_importance: category === "DECISION" || category === "ARCHITECTURE" ? 9 : 5
|
|
3823
|
+
});
|
|
3819
3824
|
if (error) throw new Error(`Failed to save memory: ${error.message}`);
|
|
3820
3825
|
return {
|
|
3821
3826
|
success: true,
|
|
3822
|
-
memoryId
|
|
3827
|
+
memoryId,
|
|
3823
3828
|
message: `\u2705 Saved [${category}] "${title}" to Project Brain.`
|
|
3824
3829
|
};
|
|
3825
3830
|
}
|