Skip to content

Commit 54a8354

Browse files
prosdevclaude
andcommitted
fix(mcp): fix index check and remove dead metrics module
MCP install/start checked for a local `vectors` directory (LanceDB artifact) that no longer exists with Antfly. Switch to metadata.json. Remove the entire metrics module (MetricsStore, analytics, collector, schema, types, service) — it was write-only with no consumers after removing `dev stats` and the dashboard. Drops better-sqlite3 native dependency (-36 transitive packages, -2400 lines). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5db807f commit 54a8354

22 files changed

Lines changed: 24 additions & 2420 deletions

packages/cli/src/commands/index.ts

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import { join, resolve } from 'node:path';
1+
import { resolve } from 'node:path';
22
import {
3-
AsyncEventBus,
43
ensureStorageDirectory,
54
getStorageFilePaths,
65
getStoragePath,
7-
type IndexUpdatedEvent,
8-
MetricsStore,
96
RepositoryIndexer,
107
updateIndexedStats,
118
} from '@prosdevlab/dev-agent-core';
@@ -72,29 +69,13 @@ export const indexCommand = new Command('index')
7269
await ensureStorageDirectory(storagePath);
7370
const filePaths = getStorageFilePaths(storagePath);
7471

75-
// Create event bus for metrics
76-
const eventBus = new AsyncEventBus();
77-
const metricsDbPath = join(storagePath, 'metrics.db');
78-
const metricsStore = new MetricsStore(metricsDbPath);
79-
80-
eventBus.on<IndexUpdatedEvent>('index.updated', async (event) => {
81-
try {
82-
metricsStore.recordSnapshot(event.stats, event.isIncremental ? 'update' : 'index');
83-
} catch {
84-
// Metrics are non-critical — don't fail indexing
85-
}
72+
const indexer = new RepositoryIndexer({
73+
repositoryPath: resolvedRepoPath,
74+
vectorStorePath: filePaths.vectors,
75+
excludePatterns: config.repository?.excludePatterns || config.excludePatterns,
76+
languages: config.repository?.languages || config.languages,
8677
});
8778

88-
const indexer = new RepositoryIndexer(
89-
{
90-
repositoryPath: resolvedRepoPath,
91-
vectorStorePath: filePaths.vectors,
92-
excludePatterns: config.repository?.excludePatterns || config.excludePatterns,
93-
languages: config.repository?.languages || config.languages,
94-
},
95-
eventBus
96-
);
97-
9879
await indexer.initialize();
9980

10081
const indexLogger = createIndexLogger(options.verbose);
@@ -149,7 +130,6 @@ export const indexCommand = new Command('index')
149130

150131
// Finalize
151132
await indexer.close();
152-
metricsStore.close();
153133

154134
await updateIndexedStats(storagePath, {
155135
files: stats.filesScanned,

packages/cli/src/commands/mcp.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ Available Tools (6):
7070
try {
7171
// Check if repository is indexed
7272
const storagePath = await getStoragePath(repositoryPath);
73-
const { vectors, watcherSnapshot } = getStorageFilePaths(storagePath);
73+
const { vectors, metadata, watcherSnapshot } = getStorageFilePaths(storagePath);
7474

75-
const vectorsExist = await fs
76-
.access(vectors)
75+
const isIndexed = await fs
76+
.access(metadata)
7777
.then(() => true)
7878
.catch(() => false);
79-
if (!vectorsExist) {
79+
if (!isIndexed) {
8080
logger.error(`Repository not indexed. Run: ${chalk.yellow('dev index')}`);
8181
process.exit(1);
8282
}
@@ -205,15 +205,15 @@ Available Tools (6):
205205
const spinner = ora(`Installing dev-agent MCP server in ${targetIDE}...`).start();
206206

207207
try {
208-
// Check if repository is indexed
208+
// Check if repository is indexed (metadata.json is written at index time)
209209
const storagePath = await getStoragePath(repositoryPath);
210-
const { vectors } = getStorageFilePaths(storagePath);
210+
const { metadata } = getStorageFilePaths(storagePath);
211211

212-
const vectorsExist = await fs
213-
.access(vectors)
212+
const isIndexed = await fs
213+
.access(metadata)
214214
.then(() => true)
215215
.catch(() => false);
216-
if (!vectorsExist) {
216+
if (!isIndexed) {
217217
spinner.fail(`Repository not indexed. Run: ${chalk.yellow('dev index')}`);
218218
process.exit(1);
219219
}

packages/cli/src/commands/storage.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,9 @@ Storage Location:
9999
Each repository gets its own subdirectory based on path hash
100100
101101
What's Stored:
102-
• vectors.lance/ Vector embeddings for semantic search
103-
• indexer-state.json Repository indexing state
104-
• github-state.json GitHub issues/PRs state
105102
• metadata.json Repository metadata
106-
• metrics.db Historical metrics (SQLite)
103+
104+
Vector data is stored in Antfly (local search backend).
107105
`
108106
);
109107

packages/core/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"test:watch": "vitest"
3131
},
3232
"devDependencies": {
33-
"@types/better-sqlite3": "^7.6.13",
3433
"@types/mdast": "^4.0.4",
3534
"@types/node": "^24.10.1",
3635
"tree-sitter-wasms": "^0.1.13",
@@ -40,7 +39,6 @@
4039
"@antfly/sdk": "0.0.14",
4140
"@prosdevlab/dev-agent-types": "workspace:*",
4241
"@prosdevlab/kero": "workspace:*",
43-
"better-sqlite3": "^12.5.0",
4442
"globby": "^16.0.0",
4543
"remark": "^15.0.1",
4644
"remark-parse": "^11.0.0",

packages/core/src/events/types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
import type { DetailedIndexStats } from '../indexer/types.js';
9-
import type { CodeMetadata } from '../metrics/types.js';
109

1110
/**
1211
* Event handler function type
@@ -148,8 +147,6 @@ export interface IndexUpdatedEvent {
148147
stats: DetailedIndexStats;
149148
/** Whether this was an incremental update (vs full index) */
150149
isIncremental?: boolean;
151-
/** Per-file code metadata for metrics storage */
152-
codeMetadata?: CodeMetadata[];
153150
}
154151

155152
export interface IndexErrorEvent {

packages/core/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export * from './context';
55
export * from './events';
66
export * from './indexer';
77
export * from './map';
8-
export * from './metrics';
98
export * from './observability';
109
export * from './scanner';
1110
export * from './services';

0 commit comments

Comments
 (0)