@rigstate/mcp 0.4.2
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/.env.example +8 -0
- package/README.md +352 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3445 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
- package/roadmap.json +531 -0
- package/src/agents/the-scribe.ts +122 -0
- package/src/index.ts +1792 -0
- package/src/lib/supabase.ts +120 -0
- package/src/lib/tool-registry.ts +134 -0
- package/src/lib/types.ts +415 -0
- package/src/lib/utils.ts +10 -0
- package/src/resources/project-morals.ts +92 -0
- package/src/tools/arch-tools.ts +166 -0
- package/src/tools/archaeological-scan.ts +335 -0
- package/src/tools/check-agent-bridge.ts +169 -0
- package/src/tools/check-rules-sync.ts +85 -0
- package/src/tools/complete-roadmap-task.ts +96 -0
- package/src/tools/generate-professional-pdf.ts +232 -0
- package/src/tools/get-latest-decisions.ts +130 -0
- package/src/tools/get-next-roadmap-step.ts +76 -0
- package/src/tools/get-project-context.ts +163 -0
- package/src/tools/index.ts +17 -0
- package/src/tools/list-features.ts +67 -0
- package/src/tools/list-roadmap-tasks.ts +61 -0
- package/src/tools/pending-tasks.ts +228 -0
- package/src/tools/planning-tools.ts +123 -0
- package/src/tools/query-brain.ts +125 -0
- package/src/tools/research-tools.ts +149 -0
- package/src/tools/run-architecture-audit.ts +203 -0
- package/src/tools/save-decision.ts +77 -0
- package/src/tools/security-tools.ts +82 -0
- package/src/tools/submit-idea.ts +66 -0
- package/src/tools/sync-ide-rules.ts +76 -0
- package/src/tools/teacher-mode.ts +171 -0
- package/src/tools/ui-tools.ts +191 -0
- package/src/tools/update-roadmap.ts +105 -0
- package/tsconfig.json +29 -0
- package/tsup.config.ts +16 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
|
|
2
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The Scribe's core adapter for fetching its own persona from Prompt CMS.
|
|
6
|
+
*/
|
|
7
|
+
export async function getScribePersona(supabase: SupabaseClient) {
|
|
8
|
+
const { data: persona, error } = await supabase
|
|
9
|
+
.from('agent_personas')
|
|
10
|
+
.select('*')
|
|
11
|
+
.eq('slug', 'the-scribe')
|
|
12
|
+
.single();
|
|
13
|
+
|
|
14
|
+
if (error || !persona) {
|
|
15
|
+
return {
|
|
16
|
+
display_name: 'The Scribe',
|
|
17
|
+
job_title: 'Technical Documentation Lead',
|
|
18
|
+
content: 'You are The Scribe, an expert in technical manifest generation and investor-ready reporting.'
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return persona;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Calculates real-world metrics for the Scribe to report on.
|
|
27
|
+
* Focuses on Velocity, Quality, and Risk.
|
|
28
|
+
* IMPORTANT: Excludes is_legacy=true items from velocity calculations
|
|
29
|
+
* to prevent historical imports from skewing development metrics.
|
|
30
|
+
*/
|
|
31
|
+
export async function calculateScribeMetrics(supabase: SupabaseClient, projectId: string) {
|
|
32
|
+
// A: Velocity - Average time for agent_bridge tasks in the last 7 days
|
|
33
|
+
const { data: recentTasks } = await supabase
|
|
34
|
+
.from('agent_bridge')
|
|
35
|
+
.select('created_at, updated_at')
|
|
36
|
+
.eq('project_id', projectId)
|
|
37
|
+
.eq('status', 'COMPLETED')
|
|
38
|
+
.gte('created_at', new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString());
|
|
39
|
+
|
|
40
|
+
let avgTimeMs = 0;
|
|
41
|
+
if (recentTasks && recentTasks.length > 0) {
|
|
42
|
+
const deltas = recentTasks.map(t =>
|
|
43
|
+
new Date(t.updated_at).getTime() - new Date(t.created_at).getTime()
|
|
44
|
+
);
|
|
45
|
+
avgTimeMs = deltas.reduce((a, b) => a + b, 0) / deltas.length;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const velocityStr = avgTimeMs > 0
|
|
49
|
+
? `${(avgTimeMs / 1000).toFixed(1)}s avg execution time`
|
|
50
|
+
: "No execution history";
|
|
51
|
+
|
|
52
|
+
// B: Active Tasks Completed (EXCLUDES legacy items)
|
|
53
|
+
const { count: activeTasksCompleted } = await supabase
|
|
54
|
+
.from('roadmap_chunks')
|
|
55
|
+
.select('*', { count: 'exact', head: true })
|
|
56
|
+
.eq('project_id', projectId)
|
|
57
|
+
.eq('status', 'COMPLETED')
|
|
58
|
+
.or('is_legacy.is.null,is_legacy.eq.false');
|
|
59
|
+
|
|
60
|
+
// C: Legacy Foundations Count (for separate reporting)
|
|
61
|
+
const { count: legacyCount } = await supabase
|
|
62
|
+
.from('roadmap_chunks')
|
|
63
|
+
.select('*', { count: 'exact', head: true })
|
|
64
|
+
.eq('project_id', projectId)
|
|
65
|
+
.eq('is_legacy', true);
|
|
66
|
+
|
|
67
|
+
// D: Quality - Fetch from intelligence_trends
|
|
68
|
+
const { data: trends } = await supabase
|
|
69
|
+
.from('intelligence_trends')
|
|
70
|
+
.select('correction_count')
|
|
71
|
+
.order('week_start', { ascending: false })
|
|
72
|
+
.limit(2);
|
|
73
|
+
|
|
74
|
+
let trendDir = 'stable';
|
|
75
|
+
if (trends && trends.length === 2) {
|
|
76
|
+
const latest = trends[0].correction_count;
|
|
77
|
+
const prev = trends[1].correction_count;
|
|
78
|
+
if (latest < prev) trendDir = 'improving';
|
|
79
|
+
else if (latest > prev) trendDir = 'declining';
|
|
80
|
+
}
|
|
81
|
+
const qualityStr = `Quality trend is ${trendDir}` +
|
|
82
|
+
(legacyCount && legacyCount > 0 ? `. Built on ${legacyCount} established foundations.` : '');
|
|
83
|
+
|
|
84
|
+
// E: Risk - Count PING/CHECK rows
|
|
85
|
+
const { count: riskCount } = await supabase
|
|
86
|
+
.from('agent_bridge')
|
|
87
|
+
.select('*', { count: 'exact', head: true })
|
|
88
|
+
.eq('project_id', projectId)
|
|
89
|
+
.or('proposal.ilike.%PING%,proposal.ilike.%CHECK%,summary.ilike.%PING%,summary.ilike.%CHECK%');
|
|
90
|
+
|
|
91
|
+
// F: Enhanced Risk - Check for RLS
|
|
92
|
+
const { count: rlsCount } = await supabase.from('pg_policies').select('*', { count: 'exact', head: true }).eq('schemaname', 'public');
|
|
93
|
+
|
|
94
|
+
const riskMitigation = (riskCount || 0) > 0 || (rlsCount || 0) > 0
|
|
95
|
+
? `Security posture reinforced by ${rlsCount || 0} RLS policies and ${riskCount || 0} active guardian pings. All access is audited.`
|
|
96
|
+
: "Security controls inactive. Immediate RLS audit recommended.";
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
velocity: velocityStr,
|
|
100
|
+
qualityTrend: qualityStr,
|
|
101
|
+
riskScore: riskCount || 0,
|
|
102
|
+
riskMitigation,
|
|
103
|
+
activeTasksCompleted: activeTasksCompleted || 0,
|
|
104
|
+
legacyFoundations: legacyCount || 0
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Interpolates common variables into the Scribe's prompt.
|
|
111
|
+
*/
|
|
112
|
+
export function interpolateScribePrompt(
|
|
113
|
+
basePrompt: string,
|
|
114
|
+
vars: { projectName: string; velocity?: string; quality?: string; riskMitigation?: string }
|
|
115
|
+
): string {
|
|
116
|
+
let result = basePrompt;
|
|
117
|
+
result = result.replace(/{{project_name}}/g, vars.projectName);
|
|
118
|
+
if (vars.velocity) result = result.replace(/{{velocity}}/g, vars.velocity);
|
|
119
|
+
if (vars.quality) result = result.replace(/{{quality}}/g, vars.quality);
|
|
120
|
+
if (vars.riskMitigation) result = result.replace(/{{risk_mitigation}}/g, vars.riskMitigation);
|
|
121
|
+
return result;
|
|
122
|
+
}
|