Skip to content

Commit 5656263

Browse files
committed
fix(cli): add better-sqlite3 dependency and graceful error handling
- Add better-sqlite3 as direct dependency to fix native binding errors - Add consistent error messages across dev activity, owners, map, stats - Provide clear re-index instructions when data is missing - Better UX for users upgrading to v0.8.0
1 parent 280e60e commit 5656263

File tree

7 files changed

+66
-6
lines changed

7 files changed

+66
-6
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
"@lytics/dev-agent": patch
3+
"@lytics/dev-agent-cli": patch
4+
---
5+
6+
## Bug Fix & UX Improvements
7+
8+
### Fixed Native Bindings Error
9+
10+
Added `better-sqlite3` as a direct dependency to fix "Could not locate the bindings file" error in globally installed package.
11+
12+
### Improved Error Messages
13+
14+
Added consistent, user-friendly error messages across all commands when indexed data is missing. Commands now provide clear re-index instructions instead of cryptic errors.
15+
16+
Affected commands: `dev activity`, `dev owners`, `dev map`, `dev stats`
17+

packages/cli/src/commands/activity.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,16 @@ export const activityCommand = new Command('activity')
131131
store.close();
132132

133133
if (files.length === 0) {
134-
logger.warn('No file metrics available.');
134+
logger.warn('No activity metrics found.');
135+
console.log('');
136+
console.log(chalk.yellow('📌 This feature requires re-indexing your repository:'));
137+
console.log('');
138+
console.log(chalk.white(' dev index .'));
139+
console.log('');
140+
console.log(
141+
chalk.dim(' This is a one-time operation. Future updates will maintain activity data.')
142+
);
143+
console.log('');
135144
process.exit(0);
136145
}
137146

packages/cli/src/commands/map.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
RepositoryIndexer,
1616
} from '@lytics/dev-agent-core';
1717
import { createLogger } from '@lytics/kero';
18+
import chalk from 'chalk';
1819
import { Command } from 'commander';
1920
import ora from 'ora';
2021
import { loadConfig } from '../utils/config.js';
@@ -100,9 +101,16 @@ Use Case:
100101
const stats = await indexer.getBasicStats();
101102
if (!stats || stats.filesScanned === 0) {
102103
spinner.fail('Repository not indexed');
103-
logger.error('Run "dev index" first to index your repository');
104104
await indexer.close();
105-
process.exit(1);
105+
logger.warn('No indexed data found.');
106+
console.log('');
107+
console.log(chalk.yellow('📌 This command requires indexing your repository:'));
108+
console.log('');
109+
console.log(chalk.white(' dev index .'));
110+
console.log('');
111+
console.log(chalk.dim(' This is a one-time operation. Run in your repository root.'));
112+
console.log('');
113+
process.exit(0);
106114
}
107115

108116
mapLogger.info(

packages/cli/src/commands/owners.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,23 @@ export const ownersCommand = new Command('owners')
251251
const allFiles = store.getCodeMetadata({ snapshotId: latestSnapshot.id, limit: 10000 });
252252
const totalFiles = allFiles.length;
253253

254+
// Check if file_authors data exists
255+
const fileAuthors = store.getFileAuthors(latestSnapshot.id);
256+
if (fileAuthors.size === 0) {
257+
store.close();
258+
logger.warn('No author contribution data found.');
259+
console.log('');
260+
console.log(chalk.yellow('📌 This feature requires re-indexing your repository:'));
261+
console.log('');
262+
console.log(chalk.white(' dev index .'));
263+
console.log('');
264+
console.log(
265+
chalk.dim(' This is a one-time operation. Future updates will maintain author data.')
266+
);
267+
console.log('');
268+
process.exit(0);
269+
}
270+
254271
const developers = calculateDeveloperOwnership(store, latestSnapshot.id, repositoryPath);
255272
store.close();
256273

packages/cli/src/commands/stats.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,14 @@ What You'll See:
158158
spinner.stop();
159159

160160
if (!stats) {
161-
output.warn('No indexing statistics available');
162-
output.log(`Run ${chalk.cyan('dev index')} to index your repository first`);
163-
output.log('');
161+
output.warn('No indexed data found.');
162+
console.log('');
163+
console.log(chalk.yellow('📌 This command requires indexing your repository:'));
164+
console.log('');
165+
console.log(chalk.white(' dev index .'));
166+
console.log('');
167+
console.log(chalk.dim(' This is a one-time operation. Run in your repository root.'));
168+
console.log('');
164169
return;
165170
}
166171

packages/dev-agent/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"dependencies": {
4646
"@lancedb/lancedb": "^0.22.3",
4747
"@xenova/transformers": "^2.17.2",
48+
"better-sqlite3": "^12.5.0",
4849
"ts-morph": "^27.0.2",
4950
"web-tree-sitter": "^0.25.10"
5051
},

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)