monty-autonomous-fullstack-dev-multillm 1.0.0
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/LICENSE +81 -0
- package/README.md +608 -0
- package/bin/cli.js +448 -0
- package/dist/agents/coding.d.ts +15 -0
- package/dist/agents/coding.d.ts.map +1 -0
- package/dist/agents/coding.js +189 -0
- package/dist/agents/coding.js.map +1 -0
- package/dist/agents/initializer.d.ts +15 -0
- package/dist/agents/initializer.d.ts.map +1 -0
- package/dist/agents/initializer.js +87 -0
- package/dist/agents/initializer.js.map +1 -0
- package/dist/agents/prompts/arbitrator.md +143 -0
- package/dist/agents/prompts/coding.md +247 -0
- package/dist/agents/prompts/initializer.md +98 -0
- package/dist/config/agent-config.d.ts +103 -0
- package/dist/config/agent-config.d.ts.map +1 -0
- package/dist/config/agent-config.js +138 -0
- package/dist/config/agent-config.js.map +1 -0
- package/dist/config/auth-config.d.ts +152 -0
- package/dist/config/auth-config.d.ts.map +1 -0
- package/dist/config/auth-config.js +139 -0
- package/dist/config/auth-config.js.map +1 -0
- package/dist/config/mcp-config.d.ts +109 -0
- package/dist/config/mcp-config.d.ts.map +1 -0
- package/dist/config/mcp-config.js +234 -0
- package/dist/config/mcp-config.js.map +1 -0
- package/dist/config/provider-config.d.ts +139 -0
- package/dist/config/provider-config.d.ts.map +1 -0
- package/dist/config/provider-config.js +344 -0
- package/dist/config/provider-config.js.map +1 -0
- package/dist/config/subagents-config.d.ts +85 -0
- package/dist/config/subagents-config.d.ts.map +1 -0
- package/dist/config/subagents-config.js +430 -0
- package/dist/config/subagents-config.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +385 -0
- package/dist/index.js.map +1 -0
- package/dist/orchestrator/arbitrator.d.ts +93 -0
- package/dist/orchestrator/arbitrator.d.ts.map +1 -0
- package/dist/orchestrator/arbitrator.js +330 -0
- package/dist/orchestrator/arbitrator.js.map +1 -0
- package/dist/orchestrator/index.d.ts +113 -0
- package/dist/orchestrator/index.d.ts.map +1 -0
- package/dist/orchestrator/index.js +217 -0
- package/dist/orchestrator/index.js.map +1 -0
- package/dist/orchestrator/review-coordinator.d.ts +143 -0
- package/dist/orchestrator/review-coordinator.d.ts.map +1 -0
- package/dist/orchestrator/review-coordinator.js +401 -0
- package/dist/orchestrator/review-coordinator.js.map +1 -0
- package/dist/orchestrator/task-classifier.d.ts +87 -0
- package/dist/orchestrator/task-classifier.d.ts.map +1 -0
- package/dist/orchestrator/task-classifier.js +250 -0
- package/dist/orchestrator/task-classifier.js.map +1 -0
- package/dist/providers/anthropic-provider.d.ts +64 -0
- package/dist/providers/anthropic-provider.d.ts.map +1 -0
- package/dist/providers/anthropic-provider.js +264 -0
- package/dist/providers/anthropic-provider.js.map +1 -0
- package/dist/providers/base-provider.d.ts +219 -0
- package/dist/providers/base-provider.d.ts.map +1 -0
- package/dist/providers/base-provider.js +143 -0
- package/dist/providers/base-provider.js.map +1 -0
- package/dist/providers/cursor-provider.d.ts +82 -0
- package/dist/providers/cursor-provider.d.ts.map +1 -0
- package/dist/providers/cursor-provider.js +321 -0
- package/dist/providers/cursor-provider.js.map +1 -0
- package/dist/providers/google-provider.d.ts +75 -0
- package/dist/providers/google-provider.d.ts.map +1 -0
- package/dist/providers/google-provider.js +274 -0
- package/dist/providers/google-provider.js.map +1 -0
- package/dist/providers/index.d.ts +92 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +233 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/openai-provider.d.ts +83 -0
- package/dist/providers/openai-provider.d.ts.map +1 -0
- package/dist/providers/openai-provider.js +295 -0
- package/dist/providers/openai-provider.js.map +1 -0
- package/dist/templates/feature_list.template.json +66 -0
- package/dist/templates/progress.template.txt +51 -0
- package/dist/utils/auth-manager.d.ts +121 -0
- package/dist/utils/auth-manager.d.ts.map +1 -0
- package/dist/utils/auth-manager.js +560 -0
- package/dist/utils/auth-manager.js.map +1 -0
- package/dist/utils/budget-enforcer.d.ts +181 -0
- package/dist/utils/budget-enforcer.d.ts.map +1 -0
- package/dist/utils/budget-enforcer.js +386 -0
- package/dist/utils/budget-enforcer.js.map +1 -0
- package/dist/utils/chatgpt-detector.d.ts +51 -0
- package/dist/utils/chatgpt-detector.d.ts.map +1 -0
- package/dist/utils/chatgpt-detector.js +274 -0
- package/dist/utils/chatgpt-detector.js.map +1 -0
- package/dist/utils/claude-code-detector.d.ts +39 -0
- package/dist/utils/claude-code-detector.d.ts.map +1 -0
- package/dist/utils/claude-code-detector.js +153 -0
- package/dist/utils/claude-code-detector.js.map +1 -0
- package/dist/utils/code-quality.d.ts +58 -0
- package/dist/utils/code-quality.d.ts.map +1 -0
- package/dist/utils/code-quality.js +258 -0
- package/dist/utils/code-quality.js.map +1 -0
- package/dist/utils/context-primer.d.ts +50 -0
- package/dist/utils/context-primer.d.ts.map +1 -0
- package/dist/utils/context-primer.js +429 -0
- package/dist/utils/context-primer.js.map +1 -0
- package/dist/utils/dependency-management.d.ts +40 -0
- package/dist/utils/dependency-management.d.ts.map +1 -0
- package/dist/utils/dependency-management.js +123 -0
- package/dist/utils/dependency-management.js.map +1 -0
- package/dist/utils/environment-validation.d.ts +33 -0
- package/dist/utils/environment-validation.d.ts.map +1 -0
- package/dist/utils/environment-validation.js +136 -0
- package/dist/utils/environment-validation.js.map +1 -0
- package/dist/utils/error-recovery.d.ts +60 -0
- package/dist/utils/error-recovery.d.ts.map +1 -0
- package/dist/utils/error-recovery.js +183 -0
- package/dist/utils/error-recovery.js.map +1 -0
- package/dist/utils/feature-list.d.ts +102 -0
- package/dist/utils/feature-list.d.ts.map +1 -0
- package/dist/utils/feature-list.js +191 -0
- package/dist/utils/feature-list.js.map +1 -0
- package/dist/utils/gemini-detector.d.ts +65 -0
- package/dist/utils/gemini-detector.d.ts.map +1 -0
- package/dist/utils/gemini-detector.js +340 -0
- package/dist/utils/gemini-detector.js.map +1 -0
- package/dist/utils/git-utils.d.ts +48 -0
- package/dist/utils/git-utils.d.ts.map +1 -0
- package/dist/utils/git-utils.js +110 -0
- package/dist/utils/git-utils.js.map +1 -0
- package/dist/utils/health-check.d.ts +32 -0
- package/dist/utils/health-check.d.ts.map +1 -0
- package/dist/utils/health-check.js +152 -0
- package/dist/utils/health-check.js.map +1 -0
- package/dist/utils/hooks-manager.d.ts +154 -0
- package/dist/utils/hooks-manager.d.ts.map +1 -0
- package/dist/utils/hooks-manager.js +359 -0
- package/dist/utils/hooks-manager.js.map +1 -0
- package/dist/utils/multi-auth-manager.d.ts +144 -0
- package/dist/utils/multi-auth-manager.d.ts.map +1 -0
- package/dist/utils/multi-auth-manager.js +588 -0
- package/dist/utils/multi-auth-manager.js.map +1 -0
- package/dist/utils/progress.d.ts +49 -0
- package/dist/utils/progress.d.ts.map +1 -0
- package/dist/utils/progress.js +209 -0
- package/dist/utils/progress.js.map +1 -0
- package/dist/utils/project-detection.d.ts +40 -0
- package/dist/utils/project-detection.d.ts.map +1 -0
- package/dist/utils/project-detection.js +230 -0
- package/dist/utils/project-detection.js.map +1 -0
- package/dist/utils/session-manager.d.ts +119 -0
- package/dist/utils/session-manager.d.ts.map +1 -0
- package/dist/utils/session-manager.js +389 -0
- package/dist/utils/session-manager.js.map +1 -0
- package/dist/utils/skills-manager.d.ts +113 -0
- package/dist/utils/skills-manager.d.ts.map +1 -0
- package/dist/utils/skills-manager.js +332 -0
- package/dist/utils/skills-manager.js.map +1 -0
- package/dist/utils/structured-output.d.ts +117 -0
- package/dist/utils/structured-output.d.ts.map +1 -0
- package/dist/utils/structured-output.js +191 -0
- package/dist/utils/structured-output.js.map +1 -0
- package/dist/utils/subagent-manager.d.ts +143 -0
- package/dist/utils/subagent-manager.d.ts.map +1 -0
- package/dist/utils/subagent-manager.js +326 -0
- package/dist/utils/subagent-manager.js.map +1 -0
- package/dist/utils/supabase-setup.d.ts +50 -0
- package/dist/utils/supabase-setup.d.ts.map +1 -0
- package/dist/utils/supabase-setup.js +151 -0
- package/dist/utils/supabase-setup.js.map +1 -0
- package/dist/utils/token-refresh.d.ts +21 -0
- package/dist/utils/token-refresh.d.ts.map +1 -0
- package/dist/utils/token-refresh.js +77 -0
- package/dist/utils/token-refresh.js.map +1 -0
- package/dist/utils/tos-warning.d.ts +115 -0
- package/dist/utils/tos-warning.d.ts.map +1 -0
- package/dist/utils/tos-warning.js +304 -0
- package/dist/utils/tos-warning.js.map +1 -0
- package/dist/utils/usage-monitor.d.ts +156 -0
- package/dist/utils/usage-monitor.d.ts.map +1 -0
- package/dist/utils/usage-monitor.js +296 -0
- package/dist/utils/usage-monitor.js.map +1 -0
- package/package.json +105 -0
- package/scripts/init.ps1 +73 -0
- package/scripts/init.sh +86 -0
- package/scripts/test-auth.sh +90 -0
- package/templates/feature_list.template.json +66 -0
- package/templates/progress.template.txt +51 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subagent Manager
|
|
3
|
+
* Implements subagent spawning and coordination for the Claude Agent SDK.
|
|
4
|
+
* Subagents are specialized agent instances for focused tasks.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2025 Dobeu Tech Solutions LLC
|
|
7
|
+
* Licensed under CC BY-NC 4.0
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Subagent configuration
|
|
11
|
+
*/
|
|
12
|
+
export interface SubagentConfig {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
role: 'reviewer' | 'tester' | 'researcher' | 'documenter' | 'debugger' | 'custom';
|
|
16
|
+
tools: string[];
|
|
17
|
+
systemPrompt: string;
|
|
18
|
+
maxTurns?: number;
|
|
19
|
+
model?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Subagent execution result
|
|
23
|
+
*/
|
|
24
|
+
export interface SubagentResult {
|
|
25
|
+
subagentId: string;
|
|
26
|
+
name: string;
|
|
27
|
+
role: string;
|
|
28
|
+
success: boolean;
|
|
29
|
+
output: string;
|
|
30
|
+
artifacts?: Record<string, unknown>;
|
|
31
|
+
durationMs: number;
|
|
32
|
+
tokenUsage?: {
|
|
33
|
+
input: number;
|
|
34
|
+
output: number;
|
|
35
|
+
};
|
|
36
|
+
error?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Subagent task definition
|
|
40
|
+
*/
|
|
41
|
+
export interface SubagentTask {
|
|
42
|
+
type: 'review' | 'test' | 'research' | 'document' | 'debug' | 'custom';
|
|
43
|
+
description: string;
|
|
44
|
+
context?: string;
|
|
45
|
+
files?: string[];
|
|
46
|
+
constraints?: string[];
|
|
47
|
+
outputFormat?: 'text' | 'json' | 'markdown';
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Pre-defined subagent configurations
|
|
51
|
+
*/
|
|
52
|
+
export declare const PREDEFINED_SUBAGENTS: Record<string, SubagentConfig>;
|
|
53
|
+
/**
|
|
54
|
+
* Subagent Manager class
|
|
55
|
+
*/
|
|
56
|
+
export declare class SubagentManager {
|
|
57
|
+
private activeSubagents;
|
|
58
|
+
private results;
|
|
59
|
+
private enabled;
|
|
60
|
+
constructor();
|
|
61
|
+
/**
|
|
62
|
+
* Check if subagents are enabled
|
|
63
|
+
*/
|
|
64
|
+
isEnabled(): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Enable or disable subagents
|
|
67
|
+
*/
|
|
68
|
+
setEnabled(enabled: boolean): void;
|
|
69
|
+
/**
|
|
70
|
+
* Get a predefined subagent configuration
|
|
71
|
+
*/
|
|
72
|
+
getPredefined(name: keyof typeof PREDEFINED_SUBAGENTS): SubagentConfig | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* List all predefined subagent types
|
|
75
|
+
*/
|
|
76
|
+
listPredefined(): Array<{
|
|
77
|
+
name: string;
|
|
78
|
+
description: string;
|
|
79
|
+
role: string;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Create a custom subagent configuration
|
|
83
|
+
*/
|
|
84
|
+
createConfig(name: string, description: string, systemPrompt: string, options?: Partial<Omit<SubagentConfig, 'name' | 'description' | 'systemPrompt'>>): SubagentConfig;
|
|
85
|
+
/**
|
|
86
|
+
* Build prompt for subagent execution
|
|
87
|
+
*/
|
|
88
|
+
buildSubagentPrompt(config: SubagentConfig, task: SubagentTask): string;
|
|
89
|
+
/**
|
|
90
|
+
* Create a code review task
|
|
91
|
+
*/
|
|
92
|
+
createReviewTask(files: string[], context?: string): SubagentTask;
|
|
93
|
+
/**
|
|
94
|
+
* Create a test generation task
|
|
95
|
+
*/
|
|
96
|
+
createTestTask(files: string[], testType?: 'unit' | 'integration' | 'e2e'): SubagentTask;
|
|
97
|
+
/**
|
|
98
|
+
* Create a research task
|
|
99
|
+
*/
|
|
100
|
+
createResearchTask(topic: string, context?: string): SubagentTask;
|
|
101
|
+
/**
|
|
102
|
+
* Create a documentation task
|
|
103
|
+
*/
|
|
104
|
+
createDocumentTask(files: string[], docType?: 'readme' | 'api' | 'inline'): SubagentTask;
|
|
105
|
+
/**
|
|
106
|
+
* Create a debug task
|
|
107
|
+
*/
|
|
108
|
+
createDebugTask(errorDescription: string, stackTrace?: string, files?: string[]): SubagentTask;
|
|
109
|
+
/**
|
|
110
|
+
* Register a subagent as active
|
|
111
|
+
*/
|
|
112
|
+
registerActive(id: string, config: SubagentConfig): void;
|
|
113
|
+
/**
|
|
114
|
+
* Unregister an active subagent
|
|
115
|
+
*/
|
|
116
|
+
unregisterActive(id: string): void;
|
|
117
|
+
/**
|
|
118
|
+
* Get active subagent count
|
|
119
|
+
*/
|
|
120
|
+
getActiveCount(): number;
|
|
121
|
+
/**
|
|
122
|
+
* Record a subagent result
|
|
123
|
+
*/
|
|
124
|
+
recordResult(result: SubagentResult): void;
|
|
125
|
+
/**
|
|
126
|
+
* Get all results
|
|
127
|
+
*/
|
|
128
|
+
getResults(): SubagentResult[];
|
|
129
|
+
/**
|
|
130
|
+
* Get summary of subagent activity
|
|
131
|
+
*/
|
|
132
|
+
getSummary(): string;
|
|
133
|
+
/**
|
|
134
|
+
* Clear results
|
|
135
|
+
*/
|
|
136
|
+
clearResults(): void;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Create a subagent manager instance
|
|
140
|
+
*/
|
|
141
|
+
export declare function createSubagentManager(): SubagentManager;
|
|
142
|
+
export default SubagentManager;
|
|
143
|
+
//# sourceMappingURL=subagent-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subagent-manager.d.ts","sourceRoot":"","sources":["../../src/utils/subagent-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,UAAU,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,GAAG,UAAU,GAAG,QAAQ,CAAC;IAClF,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE;QACX,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU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AK,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,KAAK,GAAG,YAAY;IAcxF;;OAEG;IACH,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,YAAY;IAcjE;;OAEG;IACH,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,YAAY;IAcxF;;OAEG;IACH,eAAe,CACb,gBAAgB,EAAE,MAAM,EACxB,UAAU,CAAC,EAAE,MAAM,EACnB,KAAK,CAAC,EAAE,MAAM,EAAE,GACf,YAAY;IAef;;OAEG;IACH,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI;IAIxD;;OAEG;IACH,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAIlC;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IAK1C;;OAEG;IACH,UAAU,IAAI,cAAc,EAAE;IAI9B;;OAEG;IACH,UAAU,IAAI,MAAM;IAepB;;OAEG;IACH,YAAY,IAAI,IAAI;CAGrB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CAEvD;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subagent Manager
|
|
3
|
+
* Implements subagent spawning and coordination for the Claude Agent SDK.
|
|
4
|
+
* Subagents are specialized agent instances for focused tasks.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2025 Dobeu Tech Solutions LLC
|
|
7
|
+
* Licensed under CC BY-NC 4.0
|
|
8
|
+
*/
|
|
9
|
+
import { agentConfig } from '../config/agent-config.js';
|
|
10
|
+
/**
|
|
11
|
+
* Pre-defined subagent configurations
|
|
12
|
+
*/
|
|
13
|
+
export const PREDEFINED_SUBAGENTS = {
|
|
14
|
+
codeReviewer: {
|
|
15
|
+
name: 'Code Reviewer',
|
|
16
|
+
description: 'Reviews code for quality, security, and best practices',
|
|
17
|
+
role: 'reviewer',
|
|
18
|
+
tools: ['Read', 'Glob', 'Grep'],
|
|
19
|
+
systemPrompt: `You are a code reviewer specializing in finding issues and suggesting improvements.
|
|
20
|
+
|
|
21
|
+
Focus on:
|
|
22
|
+
- Security vulnerabilities
|
|
23
|
+
- Performance issues
|
|
24
|
+
- Code quality and maintainability
|
|
25
|
+
- Best practices adherence
|
|
26
|
+
- Potential bugs and edge cases
|
|
27
|
+
|
|
28
|
+
Provide specific, actionable feedback with file paths and line numbers when possible.`,
|
|
29
|
+
},
|
|
30
|
+
testGenerator: {
|
|
31
|
+
name: 'Test Generator',
|
|
32
|
+
description: 'Generates comprehensive test cases for code',
|
|
33
|
+
role: 'tester',
|
|
34
|
+
tools: ['Read', 'Glob', 'Grep'],
|
|
35
|
+
systemPrompt: `You are a test engineer specializing in creating comprehensive test suites.
|
|
36
|
+
|
|
37
|
+
Focus on:
|
|
38
|
+
- Unit tests for individual functions
|
|
39
|
+
- Integration tests for components
|
|
40
|
+
- Edge cases and error handling
|
|
41
|
+
- Test coverage optimization
|
|
42
|
+
- Clear test naming and documentation
|
|
43
|
+
|
|
44
|
+
Generate tests that are maintainable and follow testing best practices.`,
|
|
45
|
+
},
|
|
46
|
+
researcher: {
|
|
47
|
+
name: 'Research Assistant',
|
|
48
|
+
description: 'Researches documentation and best practices',
|
|
49
|
+
role: 'researcher',
|
|
50
|
+
tools: ['Read', 'Glob', 'Grep', 'WebSearch', 'WebFetch'],
|
|
51
|
+
systemPrompt: `You are a research assistant helping developers find relevant information.
|
|
52
|
+
|
|
53
|
+
Focus on:
|
|
54
|
+
- Official documentation and APIs
|
|
55
|
+
- Best practices and patterns
|
|
56
|
+
- Common issues and solutions
|
|
57
|
+
- Performance considerations
|
|
58
|
+
- Security recommendations
|
|
59
|
+
|
|
60
|
+
Provide well-sourced, accurate information with links where possible.`,
|
|
61
|
+
},
|
|
62
|
+
documenter: {
|
|
63
|
+
name: 'Documentation Writer',
|
|
64
|
+
description: 'Creates and improves documentation',
|
|
65
|
+
role: 'documenter',
|
|
66
|
+
tools: ['Read', 'Glob', 'Grep'],
|
|
67
|
+
systemPrompt: `You are a technical writer creating clear, comprehensive documentation.
|
|
68
|
+
|
|
69
|
+
Focus on:
|
|
70
|
+
- README files and getting started guides
|
|
71
|
+
- API documentation
|
|
72
|
+
- Code comments and docstrings
|
|
73
|
+
- Architecture documentation
|
|
74
|
+
- Usage examples
|
|
75
|
+
|
|
76
|
+
Write documentation that is clear, accurate, and helpful for developers.`,
|
|
77
|
+
},
|
|
78
|
+
debugger: {
|
|
79
|
+
name: 'Debug Assistant',
|
|
80
|
+
description: 'Helps diagnose and fix bugs',
|
|
81
|
+
role: 'debugger',
|
|
82
|
+
tools: ['Read', 'Glob', 'Grep', 'Bash'],
|
|
83
|
+
systemPrompt: `You are a debugging expert helping to identify and resolve issues.
|
|
84
|
+
|
|
85
|
+
Focus on:
|
|
86
|
+
- Root cause analysis
|
|
87
|
+
- Error message interpretation
|
|
88
|
+
- Stack trace analysis
|
|
89
|
+
- Reproduction steps
|
|
90
|
+
- Fix recommendations
|
|
91
|
+
|
|
92
|
+
Provide systematic debugging approaches and clear explanations.`,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Subagent Manager class
|
|
97
|
+
*/
|
|
98
|
+
export class SubagentManager {
|
|
99
|
+
activeSubagents = new Map();
|
|
100
|
+
results = [];
|
|
101
|
+
enabled;
|
|
102
|
+
constructor() {
|
|
103
|
+
this.enabled = agentConfig.features.enableSubagents;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Check if subagents are enabled
|
|
107
|
+
*/
|
|
108
|
+
isEnabled() {
|
|
109
|
+
return this.enabled;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Enable or disable subagents
|
|
113
|
+
*/
|
|
114
|
+
setEnabled(enabled) {
|
|
115
|
+
this.enabled = enabled;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get a predefined subagent configuration
|
|
119
|
+
*/
|
|
120
|
+
getPredefined(name) {
|
|
121
|
+
return PREDEFINED_SUBAGENTS[name];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* List all predefined subagent types
|
|
125
|
+
*/
|
|
126
|
+
listPredefined() {
|
|
127
|
+
return Object.entries(PREDEFINED_SUBAGENTS).map(([key, config]) => ({
|
|
128
|
+
name: key,
|
|
129
|
+
description: config.description,
|
|
130
|
+
role: config.role,
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Create a custom subagent configuration
|
|
135
|
+
*/
|
|
136
|
+
createConfig(name, description, systemPrompt, options) {
|
|
137
|
+
return {
|
|
138
|
+
name,
|
|
139
|
+
description,
|
|
140
|
+
systemPrompt,
|
|
141
|
+
role: options?.role || 'custom',
|
|
142
|
+
tools: options?.tools || ['Read', 'Glob', 'Grep'],
|
|
143
|
+
maxTurns: options?.maxTurns,
|
|
144
|
+
model: options?.model,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Build prompt for subagent execution
|
|
149
|
+
*/
|
|
150
|
+
buildSubagentPrompt(config, task) {
|
|
151
|
+
const sections = [];
|
|
152
|
+
// System context
|
|
153
|
+
sections.push(`# ${config.name}`);
|
|
154
|
+
sections.push(`Role: ${config.role}`);
|
|
155
|
+
sections.push('');
|
|
156
|
+
sections.push(config.systemPrompt);
|
|
157
|
+
sections.push('');
|
|
158
|
+
// Task description
|
|
159
|
+
sections.push('## Task');
|
|
160
|
+
sections.push(task.description);
|
|
161
|
+
sections.push('');
|
|
162
|
+
// Context if provided
|
|
163
|
+
if (task.context) {
|
|
164
|
+
sections.push('## Context');
|
|
165
|
+
sections.push(task.context);
|
|
166
|
+
sections.push('');
|
|
167
|
+
}
|
|
168
|
+
// Files to focus on
|
|
169
|
+
if (task.files && task.files.length > 0) {
|
|
170
|
+
sections.push('## Files to Review');
|
|
171
|
+
for (const file of task.files) {
|
|
172
|
+
sections.push(`- ${file}`);
|
|
173
|
+
}
|
|
174
|
+
sections.push('');
|
|
175
|
+
}
|
|
176
|
+
// Constraints
|
|
177
|
+
if (task.constraints && task.constraints.length > 0) {
|
|
178
|
+
sections.push('## Constraints');
|
|
179
|
+
for (const constraint of task.constraints) {
|
|
180
|
+
sections.push(`- ${constraint}`);
|
|
181
|
+
}
|
|
182
|
+
sections.push('');
|
|
183
|
+
}
|
|
184
|
+
// Output format
|
|
185
|
+
if (task.outputFormat) {
|
|
186
|
+
sections.push('## Output Format');
|
|
187
|
+
sections.push(`Please provide your response in ${task.outputFormat} format.`);
|
|
188
|
+
sections.push('');
|
|
189
|
+
}
|
|
190
|
+
return sections.join('\n');
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Create a code review task
|
|
194
|
+
*/
|
|
195
|
+
createReviewTask(files, context) {
|
|
196
|
+
return {
|
|
197
|
+
type: 'review',
|
|
198
|
+
description: 'Review the specified files for code quality, security, and best practices.',
|
|
199
|
+
context,
|
|
200
|
+
files,
|
|
201
|
+
outputFormat: 'markdown',
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Create a test generation task
|
|
206
|
+
*/
|
|
207
|
+
createTestTask(files, testType) {
|
|
208
|
+
return {
|
|
209
|
+
type: 'test',
|
|
210
|
+
description: `Generate ${testType || 'unit'} tests for the specified files.`,
|
|
211
|
+
files,
|
|
212
|
+
constraints: [
|
|
213
|
+
'Follow existing test patterns in the codebase',
|
|
214
|
+
'Include edge cases and error handling',
|
|
215
|
+
'Use descriptive test names',
|
|
216
|
+
],
|
|
217
|
+
outputFormat: 'markdown',
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Create a research task
|
|
222
|
+
*/
|
|
223
|
+
createResearchTask(topic, context) {
|
|
224
|
+
return {
|
|
225
|
+
type: 'research',
|
|
226
|
+
description: `Research: ${topic}`,
|
|
227
|
+
context,
|
|
228
|
+
constraints: [
|
|
229
|
+
'Cite sources when possible',
|
|
230
|
+
'Focus on official documentation',
|
|
231
|
+
'Provide practical examples',
|
|
232
|
+
],
|
|
233
|
+
outputFormat: 'markdown',
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Create a documentation task
|
|
238
|
+
*/
|
|
239
|
+
createDocumentTask(files, docType) {
|
|
240
|
+
return {
|
|
241
|
+
type: 'document',
|
|
242
|
+
description: `Create ${docType || 'documentation'} for the specified files.`,
|
|
243
|
+
files,
|
|
244
|
+
constraints: [
|
|
245
|
+
'Be clear and concise',
|
|
246
|
+
'Include code examples',
|
|
247
|
+
'Follow project documentation style',
|
|
248
|
+
],
|
|
249
|
+
outputFormat: 'markdown',
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Create a debug task
|
|
254
|
+
*/
|
|
255
|
+
createDebugTask(errorDescription, stackTrace, files) {
|
|
256
|
+
return {
|
|
257
|
+
type: 'debug',
|
|
258
|
+
description: `Debug issue: ${errorDescription}`,
|
|
259
|
+
context: stackTrace ? `Stack trace:\n\`\`\`\n${stackTrace}\n\`\`\`` : undefined,
|
|
260
|
+
files,
|
|
261
|
+
constraints: [
|
|
262
|
+
'Identify the root cause',
|
|
263
|
+
'Suggest specific fixes',
|
|
264
|
+
'Explain the reasoning',
|
|
265
|
+
],
|
|
266
|
+
outputFormat: 'markdown',
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Register a subagent as active
|
|
271
|
+
*/
|
|
272
|
+
registerActive(id, config) {
|
|
273
|
+
this.activeSubagents.set(id, config);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Unregister an active subagent
|
|
277
|
+
*/
|
|
278
|
+
unregisterActive(id) {
|
|
279
|
+
this.activeSubagents.delete(id);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Get active subagent count
|
|
283
|
+
*/
|
|
284
|
+
getActiveCount() {
|
|
285
|
+
return this.activeSubagents.size;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Record a subagent result
|
|
289
|
+
*/
|
|
290
|
+
recordResult(result) {
|
|
291
|
+
this.results.push(result);
|
|
292
|
+
this.unregisterActive(result.subagentId);
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Get all results
|
|
296
|
+
*/
|
|
297
|
+
getResults() {
|
|
298
|
+
return [...this.results];
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Get summary of subagent activity
|
|
302
|
+
*/
|
|
303
|
+
getSummary() {
|
|
304
|
+
if (this.results.length === 0) {
|
|
305
|
+
return 'No subagent activity';
|
|
306
|
+
}
|
|
307
|
+
const successCount = this.results.filter(r => r.success).length;
|
|
308
|
+
const totalTime = this.results.reduce((sum, r) => sum + r.durationMs, 0);
|
|
309
|
+
const totalTokens = this.results.reduce((sum, r) => sum + (r.tokenUsage?.input || 0) + (r.tokenUsage?.output || 0), 0);
|
|
310
|
+
return `Subagents: ${successCount}/${this.results.length} successful, ${Math.round(totalTime / 1000)}s total, ${totalTokens} tokens`;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Clear results
|
|
314
|
+
*/
|
|
315
|
+
clearResults() {
|
|
316
|
+
this.results = [];
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Create a subagent manager instance
|
|
321
|
+
*/
|
|
322
|
+
export function createSubagentManager() {
|
|
323
|
+
return new SubagentManager();
|
|
324
|
+
}
|
|
325
|
+
export default SubagentManager;
|
|
326
|
+
//# sourceMappingURL=subagent-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subagent-manager.js","sourceR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ChC,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;QAChE,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QACzE,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CACrC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,MAAM,IAAI,CAAC,CAAC,EAC1E,CAAC,CACF,CAAC;QAEF,OAAO,cAAc,YAAY,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,gBAAgB,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,WAAW,SAAS,CAAC;IACvI,CAAC;IAED;;OAEG;IACH,YAAY;QACV,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,IAAI,eAAe,EAAE,CAAC;AAC/B,CAAC;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supabase Setup Utilities
|
|
3
|
+
* Autonomous workflow for detecting and setting up Supabase backend infrastructure.
|
|
4
|
+
* Based on Anthropic's best practices for long-running agents.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Check if Supabase credentials are configured
|
|
8
|
+
*/
|
|
9
|
+
export interface SupabaseConfig {
|
|
10
|
+
url: string | null;
|
|
11
|
+
anonKey: string | null;
|
|
12
|
+
configured: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function checkSupabaseConfig(): SupabaseConfig;
|
|
15
|
+
/**
|
|
16
|
+
* Find migration files in the project
|
|
17
|
+
*/
|
|
18
|
+
export interface MigrationFile {
|
|
19
|
+
path: string;
|
|
20
|
+
name: string;
|
|
21
|
+
timestamp: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function findMigrationFiles(): MigrationFile[];
|
|
24
|
+
/**
|
|
25
|
+
* Check if Supabase CLI is available
|
|
26
|
+
*/
|
|
27
|
+
export declare function checkSupabaseCLI(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Generate a setup report
|
|
30
|
+
*/
|
|
31
|
+
export interface SetupReport {
|
|
32
|
+
config: SupabaseConfig;
|
|
33
|
+
migrations: MigrationFile[];
|
|
34
|
+
cliAvailable: boolean;
|
|
35
|
+
recommendations: string[];
|
|
36
|
+
}
|
|
37
|
+
export declare function generateSetupReport(): SetupReport;
|
|
38
|
+
/**
|
|
39
|
+
* Get a summary string for the agent prompt
|
|
40
|
+
*/
|
|
41
|
+
export declare function getSetupSummary(): string;
|
|
42
|
+
declare const _default: {
|
|
43
|
+
checkSupabaseConfig: typeof checkSupabaseConfig;
|
|
44
|
+
findMigrationFiles: typeof findMigrationFiles;
|
|
45
|
+
checkSupabaseCLI: typeof checkSupabaseCLI;
|
|
46
|
+
generateSetupReport: typeof generateSetupReport;
|
|
47
|
+
getSetupSummary: typeof getSetupSummary;
|
|
48
|
+
};
|
|
49
|
+
export default _default;
|
|
50
|
+
//# sourceMappingURL=supabase-setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supabase-setup.d.ts","sourceRoot":"","sources":["../../src/utils/supabase-setup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,mBAAmB,IAAI,cAAc,CAuCpD;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,kBAAkB,IAAI,aAAa,EAAE,CAsBpD;AAYD;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAI1C;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5B,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,wBAAgB,mBAAmB,IAAI,WAAW,CAyBjD;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAiCxC;;;;;;;;AAED,wBAME"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supabase Setup Utilities
|
|
3
|
+
* Autonomous workflow for detecting and setting up Supabase backend infrastructure.
|
|
4
|
+
* Based on Anthropic's best practices for long-running agents.
|
|
5
|
+
*/
|
|
6
|
+
import { readFileSync, existsSync, readdirSync } from "fs";
|
|
7
|
+
import { resolve, join, dirname } from "path";
|
|
8
|
+
import { fileURLToPath } from "url";
|
|
9
|
+
import { agentConfig } from "../config/agent-config.js";
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
+
const __dirname = dirname(__filename);
|
|
12
|
+
export function checkSupabaseConfig() {
|
|
13
|
+
// Check for .env file in project root
|
|
14
|
+
const projectRoot = agentConfig.paths.projectRoot;
|
|
15
|
+
const envPath = resolve(projectRoot, ".env");
|
|
16
|
+
let url = null;
|
|
17
|
+
let anonKey = null;
|
|
18
|
+
if (existsSync(envPath)) {
|
|
19
|
+
try {
|
|
20
|
+
const envContent = readFileSync(envPath, "utf-8");
|
|
21
|
+
const lines = envContent.split("\n");
|
|
22
|
+
for (const line of lines) {
|
|
23
|
+
const trimmed = line.trim();
|
|
24
|
+
if (trimmed && !trimmed.startsWith("#")) {
|
|
25
|
+
const eqIndex = trimmed.indexOf("=");
|
|
26
|
+
if (eqIndex > 0) {
|
|
27
|
+
const key = trimmed.substring(0, eqIndex).trim();
|
|
28
|
+
const value = trimmed.substring(eqIndex + 1).trim().replace(/^["']|["']$/g, "");
|
|
29
|
+
if (key === "VITE_SUPABASE_URL") {
|
|
30
|
+
url = value;
|
|
31
|
+
}
|
|
32
|
+
else if (key === "VITE_SUPABASE_ANON_KEY") {
|
|
33
|
+
anonKey = value;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
// Silently fail - env file might not be readable
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
url,
|
|
45
|
+
anonKey,
|
|
46
|
+
configured: !!(url && anonKey && url !== "https://placeholder.supabase.co" && anonKey !== "placeholder-anon-key"),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function findMigrationFiles() {
|
|
50
|
+
const projectRoot = agentConfig.paths.projectRoot;
|
|
51
|
+
const migrationsDir = resolve(projectRoot, "supabase", "migrations");
|
|
52
|
+
if (!existsSync(migrationsDir)) {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const files = readdirSync(migrationsDir)
|
|
57
|
+
.filter(f => f.endsWith(".sql"))
|
|
58
|
+
.map(f => ({
|
|
59
|
+
path: join(migrationsDir, f),
|
|
60
|
+
name: f,
|
|
61
|
+
timestamp: extractTimestamp(f),
|
|
62
|
+
}))
|
|
63
|
+
.sort((a, b) => a.timestamp.localeCompare(b.timestamp));
|
|
64
|
+
return files;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Extract timestamp from migration filename
|
|
72
|
+
* Formats: YYYYMMDDHHMMSS or YYYYMMDDHHMMSS_*
|
|
73
|
+
*/
|
|
74
|
+
function extractTimestamp(filename) {
|
|
75
|
+
// Match patterns like: 20251119020909_*.sql or 20251119020909.sql
|
|
76
|
+
const match = filename.match(/^(\d{14})/);
|
|
77
|
+
return match?.[1] ?? filename;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Check if Supabase CLI is available
|
|
81
|
+
*/
|
|
82
|
+
export function checkSupabaseCLI() {
|
|
83
|
+
// This would require running a command, so we'll return a hint
|
|
84
|
+
// The agent should check this by running: supabase --version
|
|
85
|
+
return false; // Placeholder - actual check happens via bash
|
|
86
|
+
}
|
|
87
|
+
export function generateSetupReport() {
|
|
88
|
+
const config = checkSupabaseConfig();
|
|
89
|
+
const migrations = findMigrationFiles();
|
|
90
|
+
const cliAvailable = checkSupabaseCLI();
|
|
91
|
+
const recommendations = [];
|
|
92
|
+
if (!config.configured) {
|
|
93
|
+
recommendations.push("Configure Supabase credentials in .env file (VITE_SUPABASE_URL, VITE_SUPABASE_ANON_KEY)");
|
|
94
|
+
}
|
|
95
|
+
else if (migrations.length > 0) {
|
|
96
|
+
recommendations.push(`Found ${migrations.length} migration files - check if they need to be applied`);
|
|
97
|
+
recommendations.push("Run: supabase db push (if Supabase CLI is installed)");
|
|
98
|
+
recommendations.push("Or apply migrations manually via Supabase dashboard SQL editor");
|
|
99
|
+
}
|
|
100
|
+
if (migrations.length === 0 && config.configured) {
|
|
101
|
+
recommendations.push("No migration files found - database may already be set up");
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
config,
|
|
105
|
+
migrations,
|
|
106
|
+
cliAvailable,
|
|
107
|
+
recommendations,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get a summary string for the agent prompt
|
|
112
|
+
*/
|
|
113
|
+
export function getSetupSummary() {
|
|
114
|
+
const report = generateSetupReport();
|
|
115
|
+
let summary = "\n## SUPABASE BACKEND STATUS\n\n";
|
|
116
|
+
if (report.config.configured) {
|
|
117
|
+
summary += "ā
Supabase credentials configured\n";
|
|
118
|
+
summary += ` URL: ${report.config.url}\n`;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
summary += "ā Supabase credentials not configured\n";
|
|
122
|
+
summary += " Missing: VITE_SUPABASE_URL and/or VITE_SUPABASE_ANON_KEY\n";
|
|
123
|
+
}
|
|
124
|
+
if (report.migrations.length > 0) {
|
|
125
|
+
summary += `\nš Found ${report.migrations.length} migration files:\n`;
|
|
126
|
+
report.migrations.slice(0, 5).forEach(m => {
|
|
127
|
+
summary += ` - ${m.name}\n`;
|
|
128
|
+
});
|
|
129
|
+
if (report.migrations.length > 5) {
|
|
130
|
+
summary += ` ... and ${report.migrations.length - 5} more\n`;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
summary += "\nš No migration files found\n";
|
|
135
|
+
}
|
|
136
|
+
if (report.recommendations.length > 0) {
|
|
137
|
+
summary += "\nš” Recommendations:\n";
|
|
138
|
+
report.recommendations.forEach(r => {
|
|
139
|
+
summary += ` - ${r}\n`;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return summary;
|
|
143
|
+
}
|
|
144
|
+
export default {
|
|
145
|
+
checkSupabaseConfig,
|
|
146
|
+
findMigrationFiles,
|
|
147
|
+
checkSupabaseCLI,
|
|
148
|
+
generateSetupReport,
|
|
149
|
+
getSetupSummary,
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=supabase-setup.js.map
|