@rigstate/mcp 0.4.2 → 0.4.3

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.
Files changed (57) hide show
  1. package/.agent/skills/client-side-notification-logger/SKILL.md +139 -0
  2. package/.agent/skills/react-state-counter/SKILL.md +73 -0
  3. package/.agent/skills/rigstate-evolutionary-refactor/SKILL.md +40 -0
  4. package/.agent/skills/rigstate-integrity-gate/SKILL.md +55 -0
  5. package/.agent/skills/rigstate-legacy-renovator/SKILL.md +12 -0
  6. package/.agent/skills/sec-auth-04/SKILL.md +22 -0
  7. package/.agent/skills/sec-key-01/SKILL.md +21 -0
  8. package/.agent/skills/sec-rls-01/SKILL.md +22 -0
  9. package/.agent/skills/sec-sql-01/SKILL.md +23 -0
  10. package/.agent/skills/sec-ui-01/SKILL.md +21 -0
  11. package/.cursor/rules/rigstate-database.mdc +89 -0
  12. package/.cursor/rules/rigstate-guardian.mdc +43 -0
  13. package/.cursor/rules/rigstate-identity.mdc +45 -0
  14. package/.cursor/rules/rigstate-roadmap.mdc +9 -0
  15. package/.cursor/rules/rigstate-workflow.mdc +323 -0
  16. package/.cursorrules +402 -0
  17. package/AGENTS.md +34 -0
  18. package/dist/index.js +2604 -3067
  19. package/dist/index.js.map +1 -1
  20. package/package.json +2 -2
  21. package/roadmap.json +815 -21
  22. package/src/index.ts +16 -1765
  23. package/src/lib/context-engine.ts +85 -0
  24. package/src/lib/curator/actions/fortress.ts +77 -0
  25. package/src/lib/curator/actions/query.ts +73 -0
  26. package/src/lib/curator/actions/stats.ts +70 -0
  27. package/src/lib/curator/actions/submit.ts +190 -0
  28. package/src/lib/curator/index.ts +10 -0
  29. package/src/lib/curator/schemas.ts +37 -0
  30. package/src/lib/schemas.ts +191 -0
  31. package/src/lib/types.ts +102 -261
  32. package/src/server/core.ts +40 -0
  33. package/src/server/factory.ts +78 -0
  34. package/src/server/telemetry.ts +122 -0
  35. package/src/server/types.ts +21 -0
  36. package/src/tools/analyze-database-performance.ts +157 -0
  37. package/src/tools/arch-tools.ts +16 -0
  38. package/src/tools/audit-integrity-gate.ts +166 -0
  39. package/src/tools/check-rules-sync.ts +20 -0
  40. package/src/tools/complete-roadmap-task.ts +88 -31
  41. package/src/tools/curator-tools.ts +74 -0
  42. package/src/tools/get-latest-decisions.ts +22 -0
  43. package/src/tools/get-next-roadmap-step.ts +21 -0
  44. package/src/tools/get-project-context.ts +35 -1
  45. package/src/tools/index.ts +7 -0
  46. package/src/tools/list-features.ts +4 -1
  47. package/src/tools/list-roadmap-tasks.ts +21 -0
  48. package/src/tools/planning-tools.ts +40 -0
  49. package/src/tools/query-brain.ts +25 -1
  50. package/src/tools/run-architecture-audit.ts +23 -0
  51. package/src/tools/save-decision.ts +26 -0
  52. package/src/tools/security-checks.ts +241 -0
  53. package/src/tools/security-tools.ts +88 -18
  54. package/src/tools/submit-idea.ts +25 -0
  55. package/src/tools/sync-ide-rules.ts +35 -3
  56. package/src/tools/teacher-mode.ts +92 -13
  57. package/src/tools/update-roadmap.ts +24 -0
@@ -0,0 +1,191 @@
1
+ import { z } from 'zod';
2
+
3
+ // =============================================================================
4
+ // ZOD SCHEMAS FOR TOOL INPUTS
5
+ // =============================================================================
6
+
7
+ export const QueryBrainInputSchema = z.object({
8
+ projectId: z.string().uuid('Invalid project ID'),
9
+ query: z.string().min(1, 'Query is required'),
10
+ limit: z.number().min(1).max(20).optional().default(8),
11
+ threshold: z.number().min(0).max(1).optional().default(0.5)
12
+ });
13
+
14
+ export const GetProjectContextInputSchema = z.object({
15
+ projectId: z.string().uuid('Invalid project ID')
16
+ });
17
+
18
+ export const GetLatestDecisionsInputSchema = z.object({
19
+ projectId: z.string().uuid('Invalid project ID'),
20
+ limit: z.number().min(1).max(10).optional().default(5)
21
+ });
22
+
23
+ export const SaveDecisionInputSchema = z.object({
24
+ projectId: z.string().uuid('Invalid project ID'),
25
+ title: z.string().min(1, 'Title is required').max(200, 'Title too long'),
26
+ decision: z.string().min(1, 'Decision content is required'),
27
+ rationale: z.string().optional(),
28
+ category: z.enum(['decision', 'architecture', 'constraint', 'tech_stack', 'design_rule']).optional().default('decision'),
29
+ tags: z.array(z.string()).optional().default([])
30
+ });
31
+
32
+ export const SubmitIdeaInputSchema = z.object({
33
+ projectId: z.string().uuid('Invalid project ID'),
34
+ title: z.string().min(1, 'Title is required').max(200, 'Title too long'),
35
+ description: z.string().min(1, 'Description is required'),
36
+ category: z.enum(['feature', 'improvement', 'experiment', 'pivot']).optional().default('feature'),
37
+ tags: z.array(z.string()).optional().default([])
38
+ });
39
+
40
+ export const UpdateRoadmapInputSchema = z.object({
41
+ projectId: z.string().uuid('Invalid project ID'),
42
+ chunkId: z.string().uuid('Invalid chunk ID').optional(),
43
+ title: z.string().optional(),
44
+ status: z.enum(['LOCKED', 'ACTIVE', 'COMPLETED'])
45
+ });
46
+
47
+ export const RunArchitectureAuditInputSchema = z.object({
48
+ projectId: z.string().uuid('Invalid project ID'),
49
+ filePath: z.string().min(1, 'File path is required'),
50
+ content: z.string().min(1, 'Content is required')
51
+ });
52
+
53
+ export const ListRoadmapTasksInputSchema = z.object({
54
+ projectId: z.string().uuid('Invalid project ID')
55
+ });
56
+
57
+ export const RefineLogicInputSchema = z.object({
58
+ projectId: z.string().uuid('Invalid project ID'),
59
+ originalReasoning: z.string().min(1, 'Original reasoning is required'),
60
+ userCorrection: z.string().min(1, 'User correction is required'),
61
+ scope: z.enum(['project', 'global']).optional().default('project')
62
+ });
63
+
64
+ export const GetLearnedInstructionsInputSchema = z.object({
65
+ projectId: z.string().uuid('Invalid project ID').optional()
66
+ });
67
+
68
+ export const CheckAgentBridgeInputSchema = z.object({
69
+ projectId: z.string().uuid('Invalid project ID'),
70
+ action: z.enum(['check', 'update', 'submit_for_review']).optional().default('check'),
71
+ bridgeId: z.string().uuid('Invalid bridge ID').optional(),
72
+ status: z.enum(['PENDING', 'NEEDS_REVIEW', 'AWAITING_APPROVAL', 'APPROVED', 'REJECTED', 'EXECUTING', 'COMPLETED', 'FAILED']).optional(),
73
+ summary: z.string().optional(),
74
+ execution_summary: z.string().optional(),
75
+ proposal: z.string().optional()
76
+ });
77
+
78
+ export const CheckRulesSyncInputSchema = z.object({
79
+ projectId: z.string().uuid('Invalid project ID'),
80
+ currentRulesContent: z.string().optional()
81
+ });
82
+
83
+ export const GetPendingTasksInputSchema = z.object({
84
+ projectId: z.string().uuid('Invalid project ID')
85
+ });
86
+
87
+ export const UpdateTaskStatusInputSchema = z.object({
88
+ projectId: z.string().uuid('Invalid project ID'),
89
+ taskId: z.string().uuid('Invalid task ID'),
90
+ status: z.enum(['EXECUTING', 'COMPLETED', 'FAILED']),
91
+ executionSummary: z.string().optional()
92
+ });
93
+
94
+ export const GetNextRoadmapStepInputSchema = z.object({
95
+ projectId: z.string().uuid('Invalid project ID'),
96
+ currentStepId: z.string().uuid('Invalid step ID').optional()
97
+ });
98
+
99
+ export const GenerateProfessionalPDFInputSchema = z.object({
100
+ projectId: z.string().uuid('Invalid project ID'),
101
+ reportType: z.enum(['SYSTEM_MANIFEST', 'INVESTOR_REPORT'])
102
+ });
103
+
104
+ export const ArchaeologicalScanInputSchema = z.object({
105
+ projectId: z.string().uuid('Invalid project ID'),
106
+ gitLog: z.string().describe('Git log output'),
107
+ fileTree: z.array(z.string()).describe('File paths')
108
+ });
109
+
110
+ export const ImportGhostFeaturesInputSchema = z.object({
111
+ projectId: z.string().uuid('Invalid project ID'),
112
+ features: z.array(z.any())
113
+ });
114
+
115
+ export const AnalyzeDependencyGraphInputSchema = z.object({
116
+ path: z.string().min(1).default('src')
117
+ });
118
+
119
+ export const AuditRlsStatusInputSchema = z.object({
120
+ projectId: z.string().uuid().optional()
121
+ });
122
+
123
+ export const AuditSecurityIntegrityInputSchema = z.object({
124
+ projectId: z.string().uuid(),
125
+ filePath: z.string().min(1),
126
+ content: z.string().min(1),
127
+ rules: z.array(z.string()).optional()
128
+ });
129
+
130
+ export const QueryProjectBrainInputSchema = QueryBrainInputSchema;
131
+
132
+ export const FetchPackageHealthInputSchema = z.object({
133
+ packageName: z.string().min(1)
134
+ });
135
+
136
+ export const SaveToProjectBrainInputSchema = z.object({
137
+ projectId: z.string().uuid(),
138
+ title: z.string().min(1),
139
+ content: z.string().min(1),
140
+ category: z.enum(['DECISION', 'ARCHITECTURE', 'NOTE', 'LESSON_LEARNED']).default('NOTE'),
141
+ tags: z.array(z.string()).optional().default([])
142
+ });
143
+
144
+ export const UpdateRoadmapStatusInputSchema = z.object({
145
+ projectId: z.string().uuid(),
146
+ chunkId: z.string().uuid(),
147
+ status: z.enum(['TODO', 'IN_PROGRESS', 'COMPLETED'])
148
+ });
149
+
150
+ export const AddRoadmapChunkInputSchema = z.object({
151
+ projectId: z.string().uuid(),
152
+ title: z.string().min(1),
153
+ description: z.string().optional(),
154
+ featureId: z.string().optional(),
155
+ priority: z.enum(['LOW', 'MEDIUM', 'HIGH']).default('MEDIUM')
156
+ });
157
+
158
+ export const AnalyzeUiComponentInputSchema = z.object({
159
+ filePath: z.string()
160
+ });
161
+
162
+ export const ApplyDesignSystemInputSchema = z.object({
163
+ filePath: z.string()
164
+ });
165
+
166
+ export const FetchUiLibraryDocsInputSchema = z.object({
167
+ componentName: z.string(),
168
+ library: z.enum(['shadcn', 'lucide']).default('shadcn')
169
+ });
170
+
171
+ export const GenerateCursorRulesInputSchema = z.object({
172
+ projectId: z.string().uuid()
173
+ });
174
+
175
+ export const AnalyzeDatabasePerformanceInputSchema = z.object({
176
+ projectId: z.string().uuid(),
177
+ filePaths: z.array(z.string())
178
+ });
179
+
180
+ export const AuditIntegrityGateInputSchema = z.object({
181
+ projectId: z.string().uuid(),
182
+ filePaths: z.array(z.string()).optional().default([])
183
+ });
184
+
185
+ export const CompleteRoadmapTaskInputSchema = z.object({
186
+ projectId: z.string().uuid(),
187
+ summary: z.string().min(1),
188
+ taskId: z.string().uuid().optional(),
189
+ gitDiff: z.string().optional(),
190
+ integrityGate: z.any().optional()
191
+ });
package/src/lib/types.ts CHANGED
@@ -1,10 +1,13 @@
1
1
  /**
2
2
  * Rigstate MCP Server - Types
3
- *
4
3
  * Shared type definitions for the MCP server tools.
5
4
  */
6
5
 
7
6
  import { z } from 'zod';
7
+ import * as schemas from './schemas.js';
8
+
9
+ // Re-export schemas for convenience
10
+ export * from './schemas.js';
8
11
 
9
12
  // =============================================================================
10
13
  // PROJECT CONTEXT TYPES
@@ -88,103 +91,42 @@ export interface DecisionsResponse {
88
91
  }
89
92
 
90
93
  // =============================================================================
91
- // ZOD SCHEMAS FOR TOOL INPUTS
92
- // =============================================================================
93
-
94
- export const QueryBrainInputSchema = z.object({
95
- projectId: z.string().uuid('Invalid project ID'),
96
- query: z.string().min(1, 'Query is required'),
97
- limit: z.number().min(1).max(20).optional().default(8),
98
- threshold: z.number().min(0).max(1).optional().default(0.5)
99
- });
100
-
101
- export const GetProjectContextInputSchema = z.object({
102
- projectId: z.string().uuid('Invalid project ID')
103
- });
104
-
105
- export const GetLatestDecisionsInputSchema = z.object({
106
- projectId: z.string().uuid('Invalid project ID'),
107
- limit: z.number().min(1).max(10).optional().default(5)
108
- });
109
-
110
- // =============================================================================
111
- // WRITE OPERATION SCHEMAS
94
+ // TYPE ALIASES (Inferred from Schemas)
112
95
  // =============================================================================
113
96
 
114
- export const SaveDecisionInputSchema = z.object({
115
- projectId: z.string().uuid('Invalid project ID'),
116
- title: z.string().min(1, 'Title is required').max(200, 'Title too long'),
117
- decision: z.string().min(1, 'Decision content is required'),
118
- rationale: z.string().optional(),
119
- category: z.enum(['decision', 'architecture', 'constraint', 'tech_stack', 'design_rule']).optional().default('decision'),
120
- tags: z.array(z.string()).optional().default([])
121
- });
122
-
123
- export const SubmitIdeaInputSchema = z.object({
124
- projectId: z.string().uuid('Invalid project ID'),
125
- title: z.string().min(1, 'Title is required').max(200, 'Title too long'),
126
- description: z.string().min(1, 'Description is required'),
127
- category: z.enum(['feature', 'improvement', 'experiment', 'pivot']).optional().default('feature'),
128
- tags: z.array(z.string()).optional().default([])
129
- });
130
-
131
- export const UpdateRoadmapInputSchema = z.object({
132
- projectId: z.string().uuid('Invalid project ID'),
133
- chunkId: z.string().uuid('Invalid chunk ID').optional(),
134
- title: z.string().optional(),
135
- status: z.enum(['LOCKED', 'ACTIVE', 'COMPLETED'])
136
- });
137
-
138
- export const RunArchitectureAuditInputSchema = z.object({
139
- projectId: z.string().uuid('Invalid project ID'),
140
- filePath: z.string().min(1, 'File path is required'),
141
- content: z.string().min(1, 'Content is required')
142
- });
143
-
144
- export const ListRoadmapTasksInputSchema = z.object({
145
- projectId: z.string().uuid('Invalid project ID')
146
- });
147
-
148
-
97
+ export type QueryBrainInput = z.infer<typeof schemas.QueryBrainInputSchema>;
98
+ export type GetProjectContextInput = z.infer<typeof schemas.GetProjectContextInputSchema>;
99
+ export type GetLatestDecisionsInput = z.infer<typeof schemas.GetLatestDecisionsInputSchema>;
100
+ export type SaveDecisionInput = z.infer<typeof schemas.SaveDecisionInputSchema>;
101
+ export type SubmitIdeaInput = z.infer<typeof schemas.SubmitIdeaInputSchema>;
102
+ export type UpdateRoadmapInput = z.infer<typeof schemas.UpdateRoadmapInputSchema>;
103
+ export type RunArchitectureAuditInput = z.infer<typeof schemas.RunArchitectureAuditInputSchema>;
104
+ export type ListRoadmapTasksInput = z.infer<typeof schemas.ListRoadmapTasksInputSchema>;
105
+ export type CheckAgentBridgeInput = z.infer<typeof schemas.CheckAgentBridgeInputSchema>;
106
+ export type GetPendingTasksInput = z.infer<typeof schemas.GetPendingTasksInputSchema>;
107
+ export type UpdateTaskStatusInput = z.infer<typeof schemas.UpdateTaskStatusInputSchema>;
108
+ export type AnalyzeDependencyGraphInput = z.infer<typeof schemas.AnalyzeDependencyGraphInputSchema>;
109
+ export type AuditRlsStatusInput = z.infer<typeof schemas.AuditRlsStatusInputSchema>;
110
+ export type AuditSecurityIntegrityInput = z.infer<typeof schemas.AuditSecurityIntegrityInputSchema>;
111
+ export type QueryProjectBrainInput = z.infer<typeof schemas.QueryProjectBrainInputSchema>;
112
+ export type FetchPackageHealthInput = z.infer<typeof schemas.FetchPackageHealthInputSchema>;
113
+ export type SaveToProjectBrainInput = z.infer<typeof schemas.SaveToProjectBrainInputSchema>;
114
+ export type UpdateRoadmapStatusInput = z.infer<typeof schemas.UpdateRoadmapStatusInputSchema>;
115
+ export type AddRoadmapChunkInput = z.infer<typeof schemas.AddRoadmapChunkInputSchema>;
116
+ export type AnalyzeUiComponentInput = z.infer<typeof schemas.AnalyzeUiComponentInputSchema>;
117
+ export type ApplyDesignSystemInput = z.infer<typeof schemas.ApplyDesignSystemInputSchema>;
118
+ export type FetchUiLibraryDocsInput = z.infer<typeof schemas.FetchUiLibraryDocsInputSchema>;
119
+ export type AnalyzeDatabasePerformanceInput = z.infer<typeof schemas.AnalyzeDatabasePerformanceInputSchema>;
120
+ export type AuditIntegrityGateInput = z.infer<typeof schemas.AuditIntegrityGateInputSchema>;
121
+ export type CompleteRoadmapTaskInput = z.infer<typeof schemas.CompleteRoadmapTaskInputSchema>;
149
122
 
150
123
  // =============================================================================
151
- // TEACHER MODE SCHEMAS
124
+ // RESPONSE INTERFACES
152
125
  // =============================================================================
153
126
 
154
- export const RefineLogicInputSchema = z.object({
155
- projectId: z.string().uuid('Invalid project ID'),
156
- originalReasoning: z.string().min(1, 'Original reasoning is required'),
157
- userCorrection: z.string().min(1, 'User correction is required'),
158
- scope: z.enum(['project', 'global']).optional().default('project')
159
- });
160
-
161
- export const GetLearnedInstructionsInputSchema = z.object({
162
- projectId: z.string().uuid('Invalid project ID').optional()
163
- });
164
-
165
- // =============================================================================
166
- // RESPONSE TYPES
167
- // =============================================================================
168
-
169
- export interface SaveDecisionResponse {
170
- success: boolean;
171
- memoryId: string;
172
- message: string;
173
- }
174
-
175
- export interface SubmitIdeaResponse {
176
- success: boolean;
177
- ideaId: string;
178
- message: string;
179
- }
180
-
181
- export interface UpdateRoadmapResponse {
182
- success: boolean;
183
- chunkId: string;
184
- previousStatus: string;
185
- newStatus: string;
186
- message: string;
187
- }
127
+ export interface SaveDecisionResponse { success: boolean; memoryId: string; message: string; }
128
+ export interface SubmitIdeaResponse { success: boolean; ideaId: string; message: string; }
129
+ export interface UpdateRoadmapResponse { success: boolean; chunkId: string; previousStatus: string; newStatus: string; message: string; }
188
130
 
189
131
  export interface AuditViolation {
190
132
  type: string;
@@ -202,54 +144,78 @@ export interface ArchitectureAuditResponse {
202
144
  summary: string;
203
145
  }
204
146
 
205
- export type QueryBrainInput = z.infer<typeof QueryBrainInputSchema>;
206
- export type GetProjectContextInput = z.infer<typeof GetProjectContextInputSchema>;
207
- export type GetLatestDecisionsInput = z.infer<typeof GetLatestDecisionsInputSchema>;
208
- export type SaveDecisionInput = z.infer<typeof SaveDecisionInputSchema>;
209
- export type SubmitIdeaInput = z.infer<typeof SubmitIdeaInputSchema>;
210
- export type UpdateRoadmapInput = z.infer<typeof UpdateRoadmapInputSchema>;
211
- export type RunArchitectureAuditInput = z.infer<typeof RunArchitectureAuditInputSchema>;
212
- export type ListRoadmapTasksInput = z.infer<typeof ListRoadmapTasksInputSchema>;
147
+ export interface IntegrityCheckResult {
148
+ check: 'PERFORMANCE' | 'SECURITY' | 'FORTRESS_MATRIX';
149
+ status: 'PASS' | 'FAIL' | 'WARN';
150
+ message: string;
151
+ details?: any;
152
+ }
213
153
 
154
+ export interface IntegrityGateResponse {
155
+ passed: boolean;
156
+ mode: 'OPEN' | 'SOFT_LOCK' | 'HARD_LOCK';
157
+ checks: IntegrityCheckResult[];
158
+ summary: string;
159
+ }
160
+
161
+ export interface SecurityIntegrityResponse {
162
+ passed: boolean;
163
+ score: number;
164
+ violations: Array<{
165
+ id: string;
166
+ type: string;
167
+ severity: 'LOW' | 'MEDIUM' | 'HIGH' | 'FATAL';
168
+ title: string;
169
+ description: string;
170
+ recommendation: string;
171
+ }>;
172
+ summary: string;
173
+ }
174
+
175
+ // =============================================================================
176
+ // ROADMAP & TASK TYPES
177
+ // =============================================================================
178
+
179
+ export interface RoadmapChunk {
180
+ id: string;
181
+ project_id: string;
182
+ feature_id: string | null;
183
+ title: string;
184
+ description: string | null;
185
+ status: string;
186
+ priority: string | null;
187
+ step_number: number;
188
+ prompt_content: string | null;
189
+ created_at: string;
190
+ completed_at: string | null;
191
+ }
214
192
 
215
193
  export interface ListRoadmapTasksResponse {
216
194
  tasks: Array<{
217
195
  id: string;
218
196
  title: string;
219
- priority: string;
197
+ priority: string | null;
220
198
  status: string;
221
- step_number?: number;
199
+ step_number: number;
200
+ prompt_content: string | null;
222
201
  }>;
223
202
  formatted: string;
224
203
  }
225
204
 
226
-
227
- export const CheckAgentBridgeInputSchema = z.object({
228
- projectId: z.string().uuid('Invalid project ID'),
229
- action: z.enum(['check', 'update', 'submit_for_review']).optional().default('check'),
230
- bridgeId: z.string().uuid('Invalid bridge ID').optional(),
231
- status: z.enum(['PENDING', 'NEEDS_REVIEW', 'AWAITING_APPROVAL', 'APPROVED', 'REJECTED', 'EXECUTING', 'COMPLETED', 'FAILED']).optional(),
232
- summary: z.string().optional(),
233
- execution_summary: z.string().optional(),
234
- proposal: z.string().optional()
235
- });
236
-
237
- export const CheckRulesSyncInputSchema = z.object({
238
- projectId: z.string().uuid('Invalid project ID'),
239
- currentRulesContent: z.string().optional() // Provide content to check, or tool tries to read file
240
- });
241
-
242
- export type CheckAgentBridgeInput = z.infer<typeof CheckAgentBridgeInputSchema>;
205
+ // =============================================================================
206
+ // AGENT BRIDGE & RULES TYPES
207
+ // =============================================================================
243
208
 
244
209
  export interface AgentBridgeTask {
245
210
  id: string;
246
211
  project_id: string;
247
- task_id: string;
212
+ task_id: string | null;
248
213
  status: string;
249
214
  summary: string | null;
250
215
  execution_summary: string | null;
251
216
  proposal: string | null;
252
217
  created_at: string;
218
+ updated_at?: string;
253
219
  completed_at: string | null;
254
220
  task_title?: string;
255
221
  task_description?: string;
@@ -258,8 +224,8 @@ export interface AgentBridgeTask {
258
224
 
259
225
  export interface CheckAgentBridgeResponse {
260
226
  success: boolean;
261
- task?: AgentBridgeTask;
262
227
  message: string;
228
+ task?: AgentBridgeTask;
263
229
  }
264
230
 
265
231
  export interface CheckRulesSyncResponse {
@@ -270,146 +236,21 @@ export interface CheckRulesSyncResponse {
270
236
  offlineMode?: boolean;
271
237
  }
272
238
 
273
- export interface RoadmapChunk {
274
- id: string;
275
- project_id: string;
276
- title: string;
277
- description: string | null;
278
- status: string;
279
- priority: string;
280
- step_number: number;
281
- prompt_content?: string;
282
- }
283
-
284
239
  // =============================================================================
285
- // PENDING TASKS SCHEMAS (get_pending_tasks & update_task_status)
240
+ // MISSION & RELEASE TYPES
286
241
  // =============================================================================
287
242
 
288
- export const GetPendingTasksInputSchema = z.object({
289
- projectId: z.string().uuid('Invalid project ID')
290
- });
291
-
292
- export const UpdateTaskStatusInputSchema = z.object({
293
- projectId: z.string().uuid('Invalid project ID'),
294
- taskId: z.string().uuid('Invalid task ID'),
295
- status: z.enum(['EXECUTING', 'COMPLETED', 'FAILED']),
296
- executionSummary: z.string().optional()
297
- });
298
-
299
- export type GetPendingTasksInput = z.infer<typeof GetPendingTasksInputSchema>;
300
- export type UpdateTaskStatusInput = z.infer<typeof UpdateTaskStatusInputSchema>;
301
-
302
- export const GetNextRoadmapStepInputSchema = z.object({
303
- projectId: z.string().uuid('Invalid project ID'),
304
- currentStepId: z.string().uuid('Invalid step ID').optional()
305
- });
306
-
307
- export const GenerateProfessionalPDFInputSchema = z.object({
308
- projectId: z.string().uuid('Invalid project ID'),
309
- reportType: z.enum(['SYSTEM_MANIFEST', 'INVESTOR_REPORT'])
310
- });
311
-
312
- export const ArchaeologicalScanInputSchema = z.object({
313
- projectId: z.string().uuid('Invalid project ID'),
314
- gitLog: z.string().describe('Git log output in format: hash:X\\ndate:X\\nauthor:X\\nmessage\\n---COMMIT---\\n...'),
315
- fileTree: z.array(z.string()).describe('Array of file/directory paths in the repository')
316
- });
317
-
318
- export const ImportGhostFeaturesInputSchema = z.object({
319
- projectId: z.string().uuid('Invalid project ID'),
320
- features: z.array(z.object({
321
- id: z.string(),
322
- title: z.string(),
323
- description: z.string(),
324
- status: z.literal('COMPLETED'),
325
- source: z.enum(['git', 'filesystem', 'combined']),
326
- evidence: z.array(z.string()),
327
- estimatedCompletionDate: z.string(),
328
- priority: z.number()
329
- }))
330
- });
331
-
332
- // =============================================================================
333
- // STRUCTURAL SHIELD (EINAR & SVEN)
334
- // =============================================================================
335
-
336
- export const AnalyzeDependencyGraphInputSchema = z.object({
337
- path: z.string().min(1, 'Path is required').default('src')
338
- });
339
-
340
- export const AuditRlsStatusInputSchema = z.object({
341
- projectId: z.string().uuid('Invalid project ID').optional()
342
- });
343
-
344
- export type AnalyzeDependencyGraphInput = z.infer<typeof AnalyzeDependencyGraphInputSchema>;
345
- export type AuditRlsStatusInput = z.infer<typeof AuditRlsStatusInputSchema>;
346
-
347
- // =============================================================================
348
- // INTELLIGENCE CORE (MAJA & ASTRID)
349
- // =============================================================================
350
-
351
- export const QueryProjectBrainInputSchema = QueryBrainInputSchema; // Reuse existing structure
352
-
353
- export const FetchPackageHealthInputSchema = z.object({
354
- packageName: z.string().min(1, 'Package name is required')
355
- });
356
-
357
- export type QueryProjectBrainInput = z.infer<typeof QueryProjectBrainInputSchema>;
358
- export type FetchPackageHealthInput = z.infer<typeof FetchPackageHealthInputSchema>;
359
-
360
- // =============================================================================
361
- // ACTIVE MEMORY & PLANNING (MAJA & KINE)
362
- // =============================================================================
363
-
364
- export const SaveToProjectBrainInputSchema = z.object({
365
- projectId: z.string().uuid('Invalid project ID'),
366
- title: z.string().min(1, 'Title is required'),
367
- content: z.string().min(1, 'Content is required'),
368
- category: z.enum(['DECISION', 'ARCHITECTURE', 'NOTE', 'LESSON_LEARNED']).default('NOTE'),
369
- tags: z.array(z.string()).optional().default([])
370
- });
371
-
372
- export const UpdateRoadmapStatusInputSchema = z.object({
373
- projectId: z.string().uuid('Invalid project ID'),
374
- chunkId: z.string().uuid('Invalid chunk ID'),
375
- status: z.enum(['TODO', 'IN_PROGRESS', 'COMPLETED'])
376
- });
377
-
378
- export const AddRoadmapChunkInputSchema = z.object({
379
- projectId: z.string().uuid('Invalid project ID'),
380
- title: z.string().min(1, 'Title is required'),
381
- description: z.string().optional(),
382
- featureId: z.string().optional(),
383
- priority: z.enum(['LOW', 'MEDIUM', 'HIGH']).default('MEDIUM')
384
- });
385
-
386
- export type SaveToProjectBrainInput = z.infer<typeof SaveToProjectBrainInputSchema>;
387
- export type UpdateRoadmapStatusInput = z.infer<typeof UpdateRoadmapStatusInputSchema>;
388
- export type AddRoadmapChunkInput = z.infer<typeof AddRoadmapChunkInputSchema>;
389
-
390
- // =============================================================================
391
- // UI/UX & RESEARCH (LINUS & ASTRID)
392
- // =============================================================================
393
-
394
- export const AnalyzeUiComponentInputSchema = z.object({
395
- filePath: z.string().describe('Absolute path to the component file (.tsx, .css)')
396
- });
397
-
398
- export const ApplyDesignSystemInputSchema = z.object({
399
- filePath: z.string().describe('Absolute path to the file to fix')
400
- });
401
-
402
- export const FetchUiLibraryDocsInputSchema = z.object({
403
- componentName: z.string().describe('Name of the component (e.g. "button", "card")'),
404
- library: z.enum(['shadcn', 'lucide']).default('shadcn')
405
- });
406
-
407
- export type AnalyzeUiComponentInput = z.infer<typeof AnalyzeUiComponentInputSchema>;
408
- export type ApplyDesignSystemInput = z.infer<typeof ApplyDesignSystemInputSchema>;
409
- export type FetchUiLibraryDocsInput = z.infer<typeof FetchUiLibraryDocsInputSchema>;
410
-
411
- export const GenerateCursorRulesInputSchema = z.object({
412
- projectId: z.string().uuid('Invalid project ID')
413
- });
414
-
415
- export type GenerateCursorRulesInput = z.infer<typeof GenerateCursorRulesInputSchema>;
243
+ export interface ReleaseManifest {
244
+ executive_summary: string;
245
+ security_certificate: {
246
+ status: 'PASSED' | 'FAILED' | 'WARNING';
247
+ message: string;
248
+ unsecured_tables: any[];
249
+ };
250
+ performance_report: {
251
+ status: 'PASSED' | 'FAILED' | 'WARNING';
252
+ message: string;
253
+ issues_found: number;
254
+ };
255
+ timestamp: string;
256
+ }
@@ -0,0 +1,40 @@
1
+ import { CallToolRequestSchema, McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
2
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
+ import { AuthContext } from './types.js';
4
+ import { registry } from '../lib/tool-registry.js';
5
+ import {
6
+ GetProjectContextInputSchema,
7
+ AuditSecurityIntegrityInputSchema
8
+ } from '../lib/types.js';
9
+ import { getProjectContext } from '../tools/get-project-context.js';
10
+ import { auditSecurityIntegrity } from '../tools/security-tools.js';
11
+ import { watcherState } from './telemetry.js';
12
+
13
+ export function setupToolHandlers(server: Server, authContext: AuthContext) {
14
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
15
+ const { name } = request.params;
16
+ const args = request.params.arguments as any;
17
+
18
+ // 1. Check Registry (Modern Tools)
19
+ try {
20
+ return await registry.callTool(name, args, {
21
+ supabase: authContext.supabase,
22
+ userId: authContext.userId
23
+ });
24
+ } catch (e: any) {
25
+ if (!e.message?.includes(`Tool '${name}' not found`)) {
26
+ throw new McpError(ErrorCode.InvalidParams, e.message);
27
+ }
28
+ }
29
+
30
+ // 2. Legacy Switch (Modularized)
31
+ switch (name) {
32
+ case 'get_agent_status': {
33
+ return { content: [{ type: 'text', text: JSON.stringify(watcherState, null, 2) }] };
34
+ }
35
+
36
+ default:
37
+ throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
38
+ }
39
+ });
40
+ }