ai-consultation-mcp 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.
Files changed (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +193 -0
  3. package/dist/api/index.d.ts +27 -0
  4. package/dist/api/index.js +213 -0
  5. package/dist/api/index.js.map +1 -0
  6. package/dist/api/middleware/security.d.ts +6 -0
  7. package/dist/api/middleware/security.js +28 -0
  8. package/dist/api/middleware/security.js.map +1 -0
  9. package/dist/api/routes/chat.d.ts +2 -0
  10. package/dist/api/routes/chat.js +78 -0
  11. package/dist/api/routes/chat.js.map +1 -0
  12. package/dist/api/routes/config.d.ts +2 -0
  13. package/dist/api/routes/config.js +81 -0
  14. package/dist/api/routes/config.js.map +1 -0
  15. package/dist/api/routes/providers.d.ts +2 -0
  16. package/dist/api/routes/providers.js +225 -0
  17. package/dist/api/routes/providers.js.map +1 -0
  18. package/dist/api/standalone-server.d.ts +12 -0
  19. package/dist/api/standalone-server.js +117 -0
  20. package/dist/api/standalone-server.js.map +1 -0
  21. package/dist/config/defaults.d.ts +17 -0
  22. package/dist/config/defaults.js +30 -0
  23. package/dist/config/defaults.js.map +1 -0
  24. package/dist/config/encryption.d.ts +12 -0
  25. package/dist/config/encryption.js +85 -0
  26. package/dist/config/encryption.js.map +1 -0
  27. package/dist/config/index.d.ts +5 -0
  28. package/dist/config/index.js +6 -0
  29. package/dist/config/index.js.map +1 -0
  30. package/dist/config/manager.d.ts +62 -0
  31. package/dist/config/manager.js +210 -0
  32. package/dist/config/manager.js.map +1 -0
  33. package/dist/config/prompts.d.ts +10 -0
  34. package/dist/config/prompts.js +168 -0
  35. package/dist/config/prompts.js.map +1 -0
  36. package/dist/config/schema.d.ts +141 -0
  37. package/dist/config/schema.js +54 -0
  38. package/dist/config/schema.js.map +1 -0
  39. package/dist/index.d.ts +2 -0
  40. package/dist/index.js +260 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/installer/detector.d.ts +48 -0
  43. package/dist/installer/detector.js +164 -0
  44. package/dist/installer/detector.js.map +1 -0
  45. package/dist/installer/index.d.ts +7 -0
  46. package/dist/installer/index.js +10 -0
  47. package/dist/installer/index.js.map +1 -0
  48. package/dist/installer/installer.d.ts +16 -0
  49. package/dist/installer/installer.js +262 -0
  50. package/dist/installer/installer.js.map +1 -0
  51. package/dist/installer/tools.d.ts +16 -0
  52. package/dist/installer/tools.js +327 -0
  53. package/dist/installer/tools.js.map +1 -0
  54. package/dist/installer/types.d.ts +68 -0
  55. package/dist/installer/types.js +5 -0
  56. package/dist/installer/types.js.map +1 -0
  57. package/dist/providers/base.d.ts +44 -0
  58. package/dist/providers/base.js +84 -0
  59. package/dist/providers/base.js.map +1 -0
  60. package/dist/providers/deepseek.d.ts +30 -0
  61. package/dist/providers/deepseek.js +148 -0
  62. package/dist/providers/deepseek.js.map +1 -0
  63. package/dist/providers/index.d.ts +5 -0
  64. package/dist/providers/index.js +8 -0
  65. package/dist/providers/index.js.map +1 -0
  66. package/dist/providers/openai.d.ts +30 -0
  67. package/dist/providers/openai.js +123 -0
  68. package/dist/providers/openai.js.map +1 -0
  69. package/dist/providers/registry.d.ts +37 -0
  70. package/dist/providers/registry.js +65 -0
  71. package/dist/providers/registry.js.map +1 -0
  72. package/dist/providers/types.d.ts +71 -0
  73. package/dist/providers/types.js +2 -0
  74. package/dist/providers/types.js.map +1 -0
  75. package/dist/server/conversation.d.ts +105 -0
  76. package/dist/server/conversation.js +279 -0
  77. package/dist/server/conversation.js.map +1 -0
  78. package/dist/server/index.d.ts +2 -0
  79. package/dist/server/index.js +3 -0
  80. package/dist/server/index.js.map +1 -0
  81. package/dist/server/tools/consult.d.ts +15 -0
  82. package/dist/server/tools/consult.js +164 -0
  83. package/dist/server/tools/consult.js.map +1 -0
  84. package/dist/server/tools/index.d.ts +1 -0
  85. package/dist/server/tools/index.js +2 -0
  86. package/dist/server/tools/index.js.map +1 -0
  87. package/dist/types/config.d.ts +20 -0
  88. package/dist/types/config.js +2 -0
  89. package/dist/types/config.js.map +1 -0
  90. package/dist/types/index.d.ts +3 -0
  91. package/dist/types/index.js +4 -0
  92. package/dist/types/index.js.map +1 -0
  93. package/dist/types/messages.d.ts +48 -0
  94. package/dist/types/messages.js +2 -0
  95. package/dist/types/messages.js.map +1 -0
  96. package/dist/types/models.d.ts +39 -0
  97. package/dist/types/models.js +66 -0
  98. package/dist/types/models.js.map +1 -0
  99. package/dist/ui/index.html +1244 -0
  100. package/dist/utils/errors.d.ts +32 -0
  101. package/dist/utils/errors.js +53 -0
  102. package/dist/utils/errors.js.map +1 -0
  103. package/dist/utils/index.d.ts +2 -0
  104. package/dist/utils/index.js +3 -0
  105. package/dist/utils/index.js.map +1 -0
  106. package/dist/utils/logger.d.ts +13 -0
  107. package/dist/utils/logger.js +73 -0
  108. package/dist/utils/logger.js.map +1 -0
  109. package/package.json +65 -0
@@ -0,0 +1,62 @@
1
+ import type { Config } from '../types/index.js';
2
+ /**
3
+ * Configuration file manager
4
+ * Handles loading, saving, and encrypting configuration
5
+ */
6
+ export declare class ConfigManager {
7
+ private config;
8
+ private configPath;
9
+ constructor(configPath?: string);
10
+ /**
11
+ * Initialize the config manager and load configuration
12
+ */
13
+ init(): Promise<void>;
14
+ /**
15
+ * Load configuration from file
16
+ */
17
+ load(): Promise<Config>;
18
+ /**
19
+ * Save configuration to file
20
+ */
21
+ save(): Promise<void>;
22
+ /**
23
+ * Get current configuration (with decrypted keys)
24
+ */
25
+ getConfig(): Config;
26
+ /**
27
+ * Get configuration without API keys (safe for display)
28
+ */
29
+ getSafeConfig(): Config;
30
+ /**
31
+ * Update configuration
32
+ */
33
+ update(updates: Partial<Config>): Promise<void>;
34
+ /**
35
+ * Set provider API key
36
+ */
37
+ setProviderKey(provider: keyof Config['providers'], apiKey: string): Promise<void>;
38
+ /**
39
+ * Remove provider API key
40
+ */
41
+ removeProviderKey(provider: keyof Config['providers']): Promise<void>;
42
+ /**
43
+ * Check if a provider is configured
44
+ */
45
+ isProviderConfigured(provider: keyof Config['providers']): boolean;
46
+ /**
47
+ * Get API key for a provider (decrypted)
48
+ */
49
+ getProviderKey(provider: keyof Config['providers']): string | undefined;
50
+ /**
51
+ * Encrypt API keys in config object
52
+ */
53
+ private encryptApiKeys;
54
+ /**
55
+ * Decrypt API keys in config object
56
+ */
57
+ private decryptApiKeys;
58
+ }
59
+ /**
60
+ * Get the config manager instance
61
+ */
62
+ export declare function getConfigManager(configPath?: string): ConfigManager;
@@ -0,0 +1,210 @@
1
+ import fs from 'node:fs/promises';
2
+ import fsSync from 'node:fs';
3
+ import path from 'node:path';
4
+ import os from 'node:os';
5
+ import { ConfigError } from '../utils/index.js';
6
+ import { logger } from '../utils/index.js';
7
+ import { DEFAULT_CONFIG } from './defaults.js';
8
+ import { encrypt, decrypt, isEncrypted } from './encryption.js';
9
+ import { configSchema } from './schema.js';
10
+ /**
11
+ * Get the config directory path (in user's home directory)
12
+ */
13
+ function getConfigDir() {
14
+ return path.join(os.homedir(), '.ai-consultation-mcp');
15
+ }
16
+ /**
17
+ * Get the config file path
18
+ */
19
+ function getConfigPath() {
20
+ return path.join(getConfigDir(), 'config.json');
21
+ }
22
+ /**
23
+ * Ensure config directory exists
24
+ */
25
+ function ensureConfigDir() {
26
+ const configDir = getConfigDir();
27
+ if (!fsSync.existsSync(configDir)) {
28
+ fsSync.mkdirSync(configDir, { recursive: true });
29
+ }
30
+ }
31
+ /**
32
+ * Configuration file manager
33
+ * Handles loading, saving, and encrypting configuration
34
+ */
35
+ export class ConfigManager {
36
+ config;
37
+ configPath;
38
+ constructor(configPath) {
39
+ this.config = { ...DEFAULT_CONFIG };
40
+ // Always use home directory for config (consistent across all invocations)
41
+ this.configPath = configPath || getConfigPath();
42
+ ensureConfigDir();
43
+ }
44
+ /**
45
+ * Initialize the config manager and load configuration
46
+ */
47
+ async init() {
48
+ try {
49
+ await this.load();
50
+ logger.info('Configuration loaded successfully');
51
+ }
52
+ catch (error) {
53
+ if (error.code === 'ENOENT') {
54
+ logger.info('No config file found, using defaults');
55
+ await this.save();
56
+ }
57
+ else {
58
+ throw error;
59
+ }
60
+ }
61
+ }
62
+ /**
63
+ * Load configuration from file
64
+ */
65
+ async load() {
66
+ const data = await fs.readFile(this.configPath, 'utf-8');
67
+ const rawConfig = JSON.parse(data);
68
+ // Decrypt API keys
69
+ const decryptedConfig = this.decryptApiKeys(rawConfig);
70
+ // Validate configuration
71
+ const result = configSchema.safeParse(decryptedConfig);
72
+ if (!result.success) {
73
+ throw new ConfigError(`Invalid configuration: ${result.error.message}`);
74
+ }
75
+ this.config = result.data;
76
+ return this.config;
77
+ }
78
+ /**
79
+ * Save configuration to file
80
+ */
81
+ async save() {
82
+ // Ensure config directory exists
83
+ const configDir = path.dirname(this.configPath);
84
+ await fs.mkdir(configDir, { recursive: true });
85
+ // Encrypt API keys before saving
86
+ const encryptedConfig = this.encryptApiKeys(this.config);
87
+ await fs.writeFile(this.configPath, JSON.stringify(encryptedConfig, null, 2), 'utf-8');
88
+ logger.info('Configuration saved');
89
+ }
90
+ /**
91
+ * Get current configuration (with decrypted keys)
92
+ */
93
+ getConfig() {
94
+ return { ...this.config };
95
+ }
96
+ /**
97
+ * Get configuration without API keys (safe for display)
98
+ */
99
+ getSafeConfig() {
100
+ const safe = { ...this.config };
101
+ for (const provider of Object.keys(safe.providers)) {
102
+ if (safe.providers[provider].apiKey) {
103
+ safe.providers[provider] = {
104
+ ...safe.providers[provider],
105
+ apiKey: '***configured***',
106
+ };
107
+ }
108
+ }
109
+ return safe;
110
+ }
111
+ /**
112
+ * Update configuration
113
+ */
114
+ async update(updates) {
115
+ this.config = {
116
+ ...this.config,
117
+ ...updates,
118
+ providers: {
119
+ ...this.config.providers,
120
+ ...updates.providers,
121
+ },
122
+ };
123
+ // Validate after update
124
+ const result = configSchema.safeParse(this.config);
125
+ if (!result.success) {
126
+ throw new ConfigError(`Invalid configuration update: ${result.error.message}`);
127
+ }
128
+ await this.save();
129
+ }
130
+ /**
131
+ * Set provider API key
132
+ */
133
+ async setProviderKey(provider, apiKey) {
134
+ this.config.providers[provider] = {
135
+ ...this.config.providers[provider],
136
+ enabled: true,
137
+ apiKey,
138
+ };
139
+ await this.save();
140
+ logger.info(`API key set for provider: ${provider}`);
141
+ }
142
+ /**
143
+ * Remove provider API key
144
+ */
145
+ async removeProviderKey(provider) {
146
+ this.config.providers[provider] = {
147
+ enabled: false,
148
+ apiKey: undefined,
149
+ };
150
+ await this.save();
151
+ logger.info(`API key removed for provider: ${provider}`);
152
+ }
153
+ /**
154
+ * Check if a provider is configured
155
+ */
156
+ isProviderConfigured(provider) {
157
+ const providerConfig = this.config.providers[provider];
158
+ return providerConfig.enabled && !!providerConfig.apiKey;
159
+ }
160
+ /**
161
+ * Get API key for a provider (decrypted)
162
+ */
163
+ getProviderKey(provider) {
164
+ return this.config.providers[provider].apiKey;
165
+ }
166
+ /**
167
+ * Encrypt API keys in config object
168
+ */
169
+ encryptApiKeys(config) {
170
+ const encrypted = { ...config, providers: { ...config.providers } };
171
+ for (const provider of Object.keys(encrypted.providers)) {
172
+ const providerConfig = encrypted.providers[provider];
173
+ if (providerConfig.apiKey && !isEncrypted(providerConfig.apiKey)) {
174
+ encrypted.providers[provider] = {
175
+ ...providerConfig,
176
+ apiKey: encrypt(providerConfig.apiKey),
177
+ };
178
+ }
179
+ }
180
+ return encrypted;
181
+ }
182
+ /**
183
+ * Decrypt API keys in config object
184
+ */
185
+ decryptApiKeys(config) {
186
+ const decrypted = { ...config, providers: { ...config.providers } };
187
+ for (const provider of Object.keys(decrypted.providers)) {
188
+ const providerConfig = decrypted.providers[provider];
189
+ if (providerConfig.apiKey && isEncrypted(providerConfig.apiKey)) {
190
+ decrypted.providers[provider] = {
191
+ ...providerConfig,
192
+ apiKey: decrypt(providerConfig.apiKey),
193
+ };
194
+ }
195
+ }
196
+ return decrypted;
197
+ }
198
+ }
199
+ // Singleton instance
200
+ let configManagerInstance = null;
201
+ /**
202
+ * Get the config manager instance
203
+ */
204
+ export function getConfigManager(configPath) {
205
+ if (!configManagerInstance) {
206
+ configManagerInstance = new ConfigManager(configPath);
207
+ }
208
+ return configManagerInstance;
209
+ }
210
+ //# sourceMappingURL=manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/config/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C;;GAEG;AACH,SAAS,YAAY;IACnB,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,sBAAsB,CAAC,CAAC;AACzD,CAAC;AAED;;GAEG;AACH,SAAS,aAAa;IACpB,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,aAAa,CAAC,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,SAAS,eAAe;IACtB,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAClC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,aAAa;IAChB,MAAM,CAAS;IACf,UAAU,CAAS;IAE3B,YAAY,UAAmB;QAC7B,IAAI,CAA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IAAI,qBAAqB,GAAyB,IAAI,CAAC;AAEvD;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAmB;IAClD,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC3B,qBAAqB,GAAG,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,qBAAqB,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ConsultationMode } from './schema.js';
2
+ /**
3
+ * Specialized system prompts for different consultation modes
4
+ * These are optimized for DeepSeek Reasoner's reasoning capabilities
5
+ */
6
+ export declare const SYSTEM_PROMPTS: Record<ConsultationMode, string>;
7
+ /**
8
+ * Get the system prompt for a given mode
9
+ */
10
+ export declare function getSystemPromptForMode(mode: ConsultationMode): string;
@@ -0,0 +1,168 @@
1
+ /**
2
+ * Base context that explains the consultation purpose
3
+ * This ensures the AI understands its role as a "second opinion" provider
4
+ */
5
+ const CONSULTATION_CONTEXT = `You are being consulted by another AI agent (like Claude Code) to provide a SECOND OPINION.
6
+
7
+ Your role is to ENRICH PERSPECTIVES by:
8
+ - Challenging assumptions and identifying blind spots
9
+ - Offering alternative approaches the other agent might have missed
10
+ - Providing constructive criticism, not just validation
11
+ - Thinking independently rather than agreeing by default
12
+ - Highlighting potential risks or edge cases overlooked
13
+
14
+ Remember: You are a CRITICAL REVIEWER, not a yes-man. The agent consulting you values honest, rigorous analysis over polite agreement. If you see a flaw, say it directly. If you have a different approach, propose it confidently.
15
+
16
+ `;
17
+ /**
18
+ * Specialized system prompts for different consultation modes
19
+ * These are optimized for DeepSeek Reasoner's reasoning capabilities
20
+ */
21
+ export const SYSTEM_PROMPTS = {
22
+ debug: CONSULTATION_CONTEXT + `You are an expert debugger using systematic reasoning.
23
+
24
+ ANALYZE the problem using this framework:
25
+ 1. **OBSERVE**: What are the symptoms? What error messages exist?
26
+ 2. **HYPOTHESIZE**: What could cause this? List 3-5 possibilities.
27
+ 3. **TEST**: How would you verify each hypothesis?
28
+ 4. **CONCLUDE**: What is the most likely root cause?
29
+ 5. **FIX**: Provide the solution with code.
30
+
31
+ Show your reasoning process explicitly. Think step by step.
32
+
33
+ Format your response as:
34
+ ## Thinking Process
35
+ [Your detailed reasoning]
36
+
37
+ ## Root Cause
38
+ [The identified issue]
39
+
40
+ ## Solution
41
+ [Code fix with explanation]
42
+
43
+ ## Prevention
44
+ [How to avoid this in future]`,
45
+ analyzeCode: CONSULTATION_CONTEXT + `You are a senior code reviewer with expertise in security, performance, and best practices.
46
+
47
+ REVIEW the code systematically:
48
+ 1. **CORRECTNESS**: Does it do what it's supposed to?
49
+ 2. **SECURITY**: Any vulnerabilities? (injection, XSS, auth issues)
50
+ 3. **PERFORMANCE**: Any bottlenecks? N+1 queries? Memory leaks?
51
+ 4. **MAINTAINABILITY**: Is it readable? Well-structured?
52
+ 5. **EDGE CASES**: What could go wrong?
53
+
54
+ Show your analysis process. Be specific with line references.
55
+
56
+ Format your response as:
57
+ ## Analysis Process
58
+ [Your systematic review]
59
+
60
+ ## Issues Found
61
+ [Prioritized list: Critical → Minor]
62
+
63
+ ## Recommendations
64
+ [Specific improvements with code examples]`,
65
+ reviewArchitecture: CONSULTATION_CONTEXT + `You are a software architect helping with system design decisions.
66
+
67
+ ANALYZE the architecture problem:
68
+ 1. **REQUIREMENTS**: What are the functional and non-functional requirements?
69
+ 2. **CONSTRAINTS**: What limitations exist? (budget, team, timeline, tech stack)
70
+ 3. **OPTIONS**: What are the possible approaches? (minimum 3)
71
+ 4. **TRADE-OFFS**: Compare options on scalability, cost, complexity, maintainability
72
+ 5. **RECOMMENDATION**: Which approach and why?
73
+
74
+ Think through each option thoroughly before recommending.
75
+
76
+ Format your response as:
77
+ ## Understanding
78
+ [Problem restatement and requirements]
79
+
80
+ ## Options Analysis
81
+ [Each option with pros/cons]
82
+
83
+ ## Recommendation
84
+ [Your choice with detailed justification]
85
+
86
+ ## Implementation Roadmap
87
+ [High-level steps]`,
88
+ validatePlan: CONSULTATION_CONTEXT + `You are a technical lead reviewing an implementation plan.
89
+
90
+ EVALUATE the plan:
91
+ 1. **COMPLETENESS**: Are all necessary steps included?
92
+ 2. **ORDERING**: Is the sequence logical? Dependencies correct?
93
+ 3. **RISKS**: What could go wrong? What's missing?
94
+ 4. **EFFORT**: Is the estimation realistic?
95
+ 5. **ALTERNATIVES**: Are there better approaches?
96
+
97
+ Be constructive but thorough. Identify gaps.
98
+
99
+ Format your response as:
100
+ ## Plan Assessment
101
+ [Overall evaluation]
102
+
103
+ ## Strengths
104
+ [What's good about the plan]
105
+
106
+ ## Concerns
107
+ [Issues and risks identified]
108
+
109
+ ## Suggestions
110
+ [Specific improvements]`,
111
+ explainConcept: CONSULTATION_CONTEXT + `You are a patient teacher explaining technical concepts.
112
+
113
+ EXPLAIN using this approach:
114
+ 1. **SIMPLE ANALOGY**: Start with a real-world comparison
115
+ 2. **CORE CONCEPT**: Explain the fundamental idea
116
+ 3. **EXAMPLE**: Show a practical code example
117
+ 4. **DEEP DIVE**: Explain the details and nuances
118
+ 5. **COMMON MISTAKES**: What do beginners get wrong?
119
+ 6. **PRACTICE**: Suggest exercises to solidify understanding
120
+
121
+ Assume the learner wants to deeply understand, not just get a quick answer.
122
+
123
+ Format your response as:
124
+ ## In Simple Terms
125
+ [Analogy and basic explanation]
126
+
127
+ ## How It Works
128
+ [Technical explanation with examples]
129
+
130
+ ## Key Points
131
+ [Important things to remember]
132
+
133
+ ## Common Pitfalls
134
+ [Mistakes to avoid]
135
+
136
+ ## Next Steps
137
+ [How to practice and learn more]`,
138
+ general: CONSULTATION_CONTEXT + `Provide thoughtful, well-reasoned responses that offer a fresh perspective.
139
+
140
+ Your approach:
141
+ 1. **Challenge First**: Question the assumptions before accepting them
142
+ 2. **Alternative View**: What would a skeptic say? What's the counterargument?
143
+ 3. **Blind Spots**: What might the consulting agent be missing?
144
+ 4. **Fresh Perspective**: Offer insights they might not have considered
145
+ 5. **Honest Assessment**: Be direct about weaknesses in their approach
146
+
147
+ Structure your response:
148
+ ## My Take
149
+ [Your independent assessment - agree or disagree with reasoning]
150
+
151
+ ## What You Might Be Missing
152
+ [Blind spots, risks, or overlooked aspects]
153
+
154
+ ## Alternative Approach
155
+ [If you'd do it differently, explain how and why]
156
+
157
+ ## Recommendation
158
+ [Your final advice with clear reasoning]
159
+
160
+ Remember: Polite disagreement is more valuable than hollow agreement.`,
161
+ };
162
+ /**
163
+ * Get the system prompt for a given mode
164
+ */
165
+ export function getSystemPromptForMode(mode) {
166
+ return SYSTEM_PROMPTS[mode];
167
+ }
168
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/config/prompts.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,oBAAoB,GAAG;;;;;;;;;;;CAW5B,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAqC;IAC9D,KAAK,EAAE,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;8BAsBF;IAE5B,WAAW,EAAE,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;2CAmBK;IAEzC,kBAAkB,EAAE,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;mBAsB1B;IAEjB,YAAY,EAAE,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;wBAsBf;IAEtB,cAAc,EAAE,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;iCA0BR;IAE/B,OAAO,EAAE,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;sEAsBoC;CACrE,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAsB;IAC3D,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,141 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Provider configuration schema
4
+ */
5
+ export declare const providerConfigSchema: z.ZodObject<{
6
+ enabled: z.ZodBoolean;
7
+ apiKey: z.ZodOptional<z.ZodString>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ enabled: boolean;
10
+ apiKey?: string | undefined;
11
+ }, {
12
+ enabled: boolean;
13
+ apiKey?: string | undefined;
14
+ }>;
15
+ /**
16
+ * Full configuration schema
17
+ */
18
+ export declare const configSchema: z.ZodObject<{
19
+ defaultModel: z.ZodEnum<["deepseek-chat", "deepseek-reasoner", "gpt-5.2", "gpt-5.2-pro"]>;
20
+ maxMessages: z.ZodNumber;
21
+ providers: z.ZodObject<{
22
+ deepseek: z.ZodObject<{
23
+ enabled: z.ZodBoolean;
24
+ apiKey: z.ZodOptional<z.ZodString>;
25
+ }, "strip", z.ZodTypeAny, {
26
+ enabled: boolean;
27
+ apiKey?: string | undefined;
28
+ }, {
29
+ enabled: boolean;
30
+ apiKey?: string | undefined;
31
+ }>;
32
+ openai: z.ZodObject<{
33
+ enabled: z.ZodBoolean;
34
+ apiKey: z.ZodOptional<z.ZodString>;
35
+ }, "strip", z.ZodTypeAny, {
36
+ enabled: boolean;
37
+ apiKey?: string | undefined;
38
+ }, {
39
+ enabled: boolean;
40
+ apiKey?: string | undefined;
41
+ }>;
42
+ }, "strip", z.ZodTypeAny, {
43
+ deepseek: {
44
+ enabled: boolean;
45
+ apiKey?: string | undefined;
46
+ };
47
+ openai: {
48
+ enabled: boolean;
49
+ apiKey?: string | undefined;
50
+ };
51
+ }, {
52
+ deepseek: {
53
+ enabled: boolean;
54
+ apiKey?: string | undefined;
55
+ };
56
+ openai: {
57
+ enabled: boolean;
58
+ apiKey?: string | undefined;
59
+ };
60
+ }>;
61
+ }, "strip", z.ZodTypeAny, {
62
+ defaultModel: "deepseek-chat" | "deepseek-reasoner" | "gpt-5.2" | "gpt-5.2-pro";
63
+ maxMessages: number;
64
+ providers: {
65
+ deepseek: {
66
+ enabled: boolean;
67
+ apiKey?: string | undefined;
68
+ };
69
+ openai: {
70
+ enabled: boolean;
71
+ apiKey?: string | undefined;
72
+ };
73
+ };
74
+ }, {
75
+ defaultModel: "deepseek-chat" | "deepseek-reasoner" | "gpt-5.2" | "gpt-5.2-pro";
76
+ maxMessages: number;
77
+ providers: {
78
+ deepseek: {
79
+ enabled: boolean;
80
+ apiKey?: string | undefined;
81
+ };
82
+ openai: {
83
+ enabled: boolean;
84
+ apiKey?: string | undefined;
85
+ };
86
+ };
87
+ }>;
88
+ /**
89
+ * Consultation modes for specialized system prompts
90
+ */
91
+ export declare const CONSULTATION_MODES: readonly ["debug", "analyzeCode", "reviewArchitecture", "validatePlan", "explainConcept", "general"];
92
+ export type ConsultationMode = (typeof CONSULTATION_MODES)[number];
93
+ /**
94
+ * Consult request schema (for tool input validation)
95
+ */
96
+ export declare const consultRequestSchema: z.ZodObject<{
97
+ question: z.ZodString;
98
+ model: z.ZodOptional<z.ZodEnum<["deepseek-chat", "deepseek-reasoner", "gpt-5.2", "gpt-5.2-pro"]>>;
99
+ mode: z.ZodOptional<z.ZodEnum<["debug", "analyzeCode", "reviewArchitecture", "validatePlan", "explainConcept", "general"]>>;
100
+ context: z.ZodOptional<z.ZodString>;
101
+ }, "strip", z.ZodTypeAny, {
102
+ question: string;
103
+ model?: "deepseek-chat" | "deepseek-reasoner" | "gpt-5.2" | "gpt-5.2-pro" | undefined;
104
+ mode?: "debug" | "analyzeCode" | "reviewArchitecture" | "validatePlan" | "explainConcept" | "general" | undefined;
105
+ context?: string | undefined;
106
+ }, {
107
+ question: string;
108
+ model?: "deepseek-chat" | "deepseek-reasoner" | "gpt-5.2" | "gpt-5.2-pro" | undefined;
109
+ mode?: "debug" | "analyzeCode" | "reviewArchitecture" | "validatePlan" | "explainConcept" | "general" | undefined;
110
+ context?: string | undefined;
111
+ }>;
112
+ /**
113
+ * Continue conversation request schema
114
+ */
115
+ export declare const continueRequestSchema: z.ZodObject<{
116
+ conversationId: z.ZodString;
117
+ message: z.ZodString;
118
+ }, "strip", z.ZodTypeAny, {
119
+ conversationId: string;
120
+ message: string;
121
+ }, {
122
+ conversationId: string;
123
+ message: string;
124
+ }>;
125
+ /**
126
+ * End conversation request schema
127
+ */
128
+ export declare const endRequestSchema: z.ZodObject<{
129
+ conversationId: z.ZodString;
130
+ }, "strip", z.ZodTypeAny, {
131
+ conversationId: string;
132
+ }, {
133
+ conversationId: string;
134
+ }>;
135
+ /**
136
+ * Type exports from schemas
137
+ */
138
+ export type ValidatedConfig = z.infer<typeof configSchema>;
139
+ export type ValidatedConsultRequest = z.infer<typeof consultRequestSchema>;
140
+ export type ValidatedContinueRequest = z.infer<typeof continueRequestSchema>;
141
+ export type ValidatedEndRequest = z.infer<typeof endRequestSchema>;
@@ -0,0 +1,54 @@
1
+ import { z } from 'zod';
2
+ import { MODEL_TYPES } from '../types/index.js';
3
+ /**
4
+ * Provider configuration schema
5
+ */
6
+ export const providerConfigSchema = z.object({
7
+ enabled: z.boolean(),
8
+ apiKey: z.string().optional(),
9
+ });
10
+ /**
11
+ * Full configuration schema
12
+ */
13
+ export const configSchema = z.object({
14
+ defaultModel: z.enum(MODEL_TYPES),
15
+ maxMessages: z.number().int().min(1).max(10),
16
+ providers: z.object({
17
+ deepseek: providerConfigSchema,
18
+ openai: providerConfigSchema,
19
+ }),
20
+ });
21
+ /**
22
+ * Consultation modes for specialized system prompts
23
+ */
24
+ export const CONSULTATION_MODES = [
25
+ 'debug',
26
+ 'analyzeCode',
27
+ 'reviewArchitecture',
28
+ 'validatePlan',
29
+ 'explainConcept',
30
+ 'general',
31
+ ];
32
+ /**
33
+ * Consult request schema (for tool input validation)
34
+ */
35
+ export const consultRequestSchema = z.object({
36
+ question: z.string().min(1, 'Question is required'),
37
+ model: z.enum(MODEL_TYPES).optional(),
38
+ mode: z.enum(CONSULTATION_MODES).optional(),
39
+ context: z.string().optional(),
40
+ });
41
+ /**
42
+ * Continue conversation request schema
43
+ */
44
+ export const continueRequestSchema = z.object({
45
+ conversationId: z.string().uuid('Invalid conversation ID'),
46
+ message: z.string().min(1, 'Message is required'),
47
+ });
48
+ /**
49
+ * End conversation request schema
50
+ */
51
+ export const endRequestSchema = z.object({
52
+ conversationId: z.string().uuid('Invalid conversation ID'),
53
+ });
54
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;IACjC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IAC5C,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC;QAClB,QAAQ,EAAE,oBAAoB;QAC9B,MAAM,EAAE,oBAAoB;KAC7B,CAAC;CACH,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO;IACP,aAAa;IACb,oBAAoB;IACpB,cAAc;IACd,gBAAgB;IAChB,SAAS;CACD,CAAC;AAIX;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,sBAAsB,CAAC;IACnD,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE;IACrC,IAAI,EA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