fix(config): Improve config-manager.js for MCP server integration

- Fixed MCP server initialization warnings by refactoring config-manager.js to handle missing project roots silently during startup

- Added project root tracking (loadedConfigRoot) to improve config caching and prevent unnecessary reloads

- Modified _loadAndValidateConfig to return defaults without warnings when no explicitRoot provided

- Improved getConfig to only update cache when loading config with a specific project root

- Ensured warning messages still appear when explicitly specified roots have missing/invalid configs

- Prevented console output during MCP startup that was causing JSON parsing errors

- Verified parse_prd and other MCP tools still work correctly with the new config loading approach.

- Replaces test perplexity api key in mcp.json and rolls it. It's invalid now.
This commit is contained in:
Eyal Toledano
2025-04-24 13:34:51 -04:00
parent be3f68e777
commit 205a11e82c
6 changed files with 86 additions and 125 deletions

View File

@@ -162,7 +162,7 @@ describe('Unified AI Services', () => {
expect(mockLog).toHaveBeenNthCalledWith(
2,
'info',
'Attempting service call with role: main'
'New AI service call with role: main'
);
expect(mockLog).toHaveBeenNthCalledWith(
3,
@@ -229,7 +229,7 @@ describe('Unified AI Services', () => {
);
expect(mockLog).toHaveBeenCalledWith(
'info',
'Attempting service call with role: main'
'New AI service call with role: main'
);
expect(mockLog).toHaveBeenCalledWith('info', 'Retrieved AI client', {
provider: mockClient.provider,
@@ -277,7 +277,7 @@ describe('Unified AI Services', () => {
// Check subsequent fallback attempts (which also fail)
expect(mockLog).toHaveBeenCalledWith(
'info',
'Attempting service call with role: fallback'
'New AI service call with role: fallback'
);
expect(mockLog).toHaveBeenCalledWith(
'error',
@@ -285,7 +285,7 @@ describe('Unified AI Services', () => {
);
expect(mockLog).toHaveBeenCalledWith(
'info',
'Attempting service call with role: research'
'New AI service call with role: research'
);
expect(mockLog).toHaveBeenCalledWith(
'error',
@@ -349,7 +349,7 @@ describe('Unified AI Services', () => {
);
expect(mockLog).toHaveBeenCalledWith(
'info',
'Attempting service call with role: fallback'
'New AI service call with role: fallback'
);
expect(mockLog).toHaveBeenCalledWith(
'info',
@@ -431,7 +431,7 @@ describe('Unified AI Services', () => {
);
expect(mockLog).toHaveBeenCalledWith(
'info',
'Attempting service call with role: research'
'New AI service call with role: research'
);
expect(mockLog).toHaveBeenCalledWith(
'info',
@@ -509,7 +509,7 @@ describe('Unified AI Services', () => {
);
expect(mockLog).toHaveBeenCalledWith(
'info',
'Attempting service call with role: research'
'New AI service call with role: research'
);
expect(mockLog).toHaveBeenCalledWith(
'info',
@@ -554,7 +554,7 @@ describe('Unified AI Services', () => {
// Check logs for sequence
expect(mockLog).toHaveBeenCalledWith(
'info',
'Attempting service call with role: fallback'
'New AI service call with role: fallback'
);
expect(mockLog).toHaveBeenCalledWith(
'error',
@@ -568,7 +568,7 @@ describe('Unified AI Services', () => {
);
expect(mockLog).toHaveBeenCalledWith(
'info',
'Attempting service call with role: research'
'New AI service call with role: research'
);
expect(mockLog).toHaveBeenCalledWith(
'info',
@@ -613,7 +613,7 @@ describe('Unified AI Services', () => {
// Check logs for sequence
expect(mockLog).toHaveBeenCalledWith(
'info',
'Attempting service call with role: research'
'New AI service call with role: research'
);
expect(mockLog).toHaveBeenCalledWith(
'error',
@@ -627,7 +627,7 @@ describe('Unified AI Services', () => {
);
expect(mockLog).toHaveBeenCalledWith(
'info',
'Attempting service call with role: fallback'
'New AI service call with role: fallback'
);
expect(mockLog).toHaveBeenCalledWith(
'info',