Skip to content

Commit df19423

Browse files
committed
refactor(services): resolve circular deps with shared types package
- Create @lytics/dev-agent-types for GitHub types - Refactor GitHubService to use dependency injection - Update all adapters and tests to use new service patterns - Fix tsconfigs to exclude tests from dist builds - Clean stale build artifacts - Define GitHubIndexerInstance interface for type safety - Fix findRelated to return GitHubSearchResult[] with real scores - Add comprehensive tests for related action Changes: - GitHubService.findRelated() returns GitHubSearchResult[] (not GitHubDocument[]) - All mocks properly typed as GitHubIndexerInstance - Added adapter tests for 'related' action with score validation - Fixed search method to pass options directly Tests: All 1927 passing Build: All 9 packages clean Lint: All clean Net: -141 lines
1 parent 46e7a10 commit df19423

39 files changed

Lines changed: 1606 additions & 1152 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,4 @@ packages/benchmark/
7070

7171
# Benchmark studies and session logs
7272
studies/
73+
.test-vectors/

packages/cli/src/commands/mcp.ts

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ import { spawn } from 'node:child_process';
77
import * as fs from 'node:fs/promises';
88
import * as path from 'node:path';
99
import {
10+
CoordinatorService,
11+
type GitHubIndexerFactory,
12+
GitHubService,
1013
GitIndexer,
1114
getStorageFilePaths,
1215
getStoragePath,
1316
LocalGitExtractor,
1417
RepositoryIndexer,
18+
SearchService,
19+
StatsService,
1520
VectorStorage,
1621
} from '@lytics/dev-agent-core';
1722
import {
@@ -26,12 +31,7 @@ import {
2631
SearchAdapter,
2732
StatusAdapter,
2833
} from '@lytics/dev-agent-mcp';
29-
import {
30-
ExplorerAgent,
31-
PlannerAgent,
32-
PrAgent,
33-
SubagentCoordinator,
34-
} from '@lytics/dev-agent-subagents';
34+
import type { SubagentCoordinator } from '@lytics/dev-agent-subagents';
3535
import chalk from 'chalk';
3636
import { Command } from 'commander';
3737
import ora from 'ora';
@@ -83,30 +83,40 @@ export const mcpCommand = new Command('mcp')
8383

8484
await indexer.initialize();
8585

86-
// Create and configure the subagent coordinator
87-
const coordinator = new SubagentCoordinator({
86+
// Create and configure the subagent coordinator using CoordinatorService
87+
const coordinatorService = new CoordinatorService({
88+
repositoryPath,
8889
maxConcurrentTasks: 5,
8990
defaultMessageTimeout: 30000,
9091
logLevel: logLevel as 'debug' | 'info' | 'warn' | 'error',
9192
});
93+
// Type assertion: CoordinatorService returns a minimal interface
94+
const coordinator = (await coordinatorService.createCoordinator(
95+
indexer
96+
)) as SubagentCoordinator;
9297

93-
// Set up context manager with indexer
94-
coordinator.getContextManager().setIndexer(indexer);
95-
96-
// Register subagents
97-
await coordinator.registerAgent(new ExplorerAgent());
98-
await coordinator.registerAgent(new PlannerAgent());
99-
await coordinator.registerAgent(new PrAgent());
98+
// Create services
99+
const searchService = new SearchService({ repositoryPath });
100100

101101
// Create all adapters
102102
const searchAdapter = new SearchAdapter({
103-
repositoryIndexer: indexer,
103+
searchService,
104104
defaultFormat: 'compact',
105105
defaultLimit: 10,
106106
});
107107

108+
const statsService = new StatsService({ repositoryPath });
109+
const createGitHubIndexer: GitHubIndexerFactory = async (config) => {
110+
const { GitHubIndexer } = await import('@lytics/dev-agent-subagents');
111+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic import requires type coercion
112+
return new GitHubIndexer(config) as any;
113+
};
114+
115+
const githubService = new GitHubService({ repositoryPath }, createGitHubIndexer);
116+
108117
const statusAdapter = new StatusAdapter({
109-
repositoryIndexer: indexer,
118+
statsService,
119+
githubService,
110120
repositoryPath,
111121
vectorStorePath: vectors,
112122
defaultSection: 'summary',
@@ -122,8 +132,7 @@ export const mcpCommand = new Command('mcp')
122132

123133
const githubAdapter = new GitHubAdapter({
124134
repositoryPath,
125-
vectorStorePath: `${vectors}-github`,
126-
statePath: getStorageFilePaths(storagePath).githubState,
135+
githubService,
127136
defaultLimit: 10,
128137
defaultFormat: 'compact',
129138
});
@@ -205,9 +214,7 @@ export const mcpCommand = new Command('mcp')
205214
await server.stop();
206215
await indexer.close();
207216
await gitVectorStorage.close();
208-
if (githubAdapter.githubIndexer) {
209-
await githubAdapter.githubIndexer.close();
210-
}
217+
await githubService.shutdown();
211218
process.exit(0);
212219
};
213220

packages/cli/tsconfig.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"outDir": "./dist",
55
"rootDir": "./src",
66
"composite": true,
7+
"declaration": true,
8+
"declarationMap": true,
79
"types": ["node", "vitest/globals"]
810
},
911
"references": [
@@ -13,5 +15,11 @@
1315
{ "path": "../logger" }
1416
],
1517
"include": ["src/**/*"],
16-
"exclude": ["node_modules", "dist"]
18+
"exclude": [
19+
"node_modules",
20+
"dist",
21+
"**/*.test.ts",
22+
"**/*.spec.ts",
23+
"**/__tests__/**"
24+
]
1725
}

packages/core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
},
3939
"dependencies": {
4040
"@lancedb/lancedb": "^0.22.3",
41+
"@lytics/dev-agent-types": "workspace:*",
4142
"@lytics/kero": "workspace:*",
4243
"@xenova/transformers": "^2.17.2",
4344
"better-sqlite3": "^12.5.0",

0 commit comments

Comments
 (0)