Skip to content

Commit 2e72ddc

Browse files
committed
chore: update dependencies and fix linting configuration
1 parent 8751476 commit 2e72ddc

File tree

23 files changed

+1364
-209
lines changed

23 files changed

+1364
-209
lines changed

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
"baseBranch": "main",
99
"updateInternalDependencies": "patch",
1010
"ignore": []
11-
}
11+
}

.husky/pre-commit

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
1-
# Get staged files
2-
files=$(git diff --cached --name-only --diff-filter=ACMR "*.ts" "*.tsx" "*.js" "*.jsx" | xargs)
3-
4-
if [ -n "$files" ]; then
5-
echo "Running Biome on staged files: $files"
6-
pnpm lint-staged $files
7-
git add $files
8-
fi
9-
10-
# Run TypeScript type check
1+
pnpm lint-staged
112
pnpm typecheck

biome.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.3.0/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
33
"assist": { "actions": { "source": { "organizeImports": "on" } } },
44
"linter": {
55
"enabled": true,
@@ -28,5 +28,10 @@
2828
"trailingCommas": "es5",
2929
"semicolons": "always"
3030
}
31+
},
32+
"vcs": {
33+
"enabled": true,
34+
"clientKind": "git",
35+
"useIgnoreFile": true
3136
}
3237
}

commitlint.config.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ module.exports = {
22
extends: ['@commitlint/config-conventional'],
33
rules: {
44
'body-max-line-length': [2, 'always', 100],
5-
'subject-case': [
6-
2,
7-
'never',
8-
['start-case', 'pascal-case', 'upper-case'],
9-
],
5+
'subject-case': [2, 'never', ['start-case', 'pascal-case', 'upper-case']],
106
},
11-
};
7+
};

package.json

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,18 @@
1515
"scripts": {
1616
"build": "pnpm -r build",
1717
"dev": "pnpm --filter @doc-agent/cli dev",
18-
"mcp": "pnpm --filter @doc-agent/cli mcp"
18+
"mcp": "pnpm --filter @doc-agent/cli mcp",
19+
"lint": "biome check .",
20+
"format": "biome format . --write",
21+
"lint-staged": "lint-staged",
22+
"check": "biome check .",
23+
"typecheck": "tsc --noEmit",
24+
"test": "vitest"
25+
},
26+
"lint-staged": {
27+
"*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}": [
28+
"biome check --write --no-errors-on-unmatched"
29+
]
1930
},
2031
"keywords": [
2132
"document",
@@ -32,7 +43,11 @@
3243
"packages/*"
3344
],
3445
"devDependencies": {
46+
"@biomejs/biome": "2.3.8",
3547
"@tsconfig/node-lts": "^24.0.0",
36-
"typescript": "^5.9.3"
48+
"@types/node": "^24.10.1",
49+
"lint-staged": "16.2.7",
50+
"typescript": "^5.9.3",
51+
"vitest": "^4.0.15"
3752
}
38-
}
53+
}

packages/cli/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
"@doc-agent/core": "workspace:*",
1919
"@doc-agent/extract": "workspace:*",
2020
"@doc-agent/vector-store": "workspace:*",
21-
"@modelcontextprotocol/sdk": "^1.0.4",
22-
"@google/generative-ai": "^0.21.0",
23-
"vectordb": "^0.9.0",
24-
"commander": "^12.1.0",
25-
"ora": "^8.1.1",
26-
"chalk": "^5.3.0"
21+
"@google/generative-ai": "^0.24.1",
22+
"@modelcontextprotocol/sdk": "^1.24.3",
23+
"chalk": "^5.6.2",
24+
"commander": "^14.0.2",
25+
"ora": "^9.0.0",
26+
"vectordb": "^0.21.2"
2727
},
2828
"devDependencies": {
29-
"@types/node": "^20.17.9",
30-
"typescript": "^5.7.2",
31-
"tsx": "^4.19.2"
29+
"@types/node": "^24.10.1",
30+
"tsx": "^4.21.0",
31+
"typescript": "^5.9.3"
3232
}
3333
}

packages/cli/src/cli.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env node
2-
import { Command } from 'commander';
3-
import ora from 'ora';
4-
import chalk from 'chalk';
5-
import { extractDocument } from '@doc-agent/extract';
6-
import type { Config } from '@doc-agent/core';
72
import { exec } from 'node:child_process';
83
import { promisify } from 'node:util';
4+
import type { Config } from '@doc-agent/core';
5+
import { extractDocument } from '@doc-agent/extract';
6+
import chalk from 'chalk';
7+
import { Command } from 'commander';
8+
import ora from 'ora';
99

1010
const execAsync = promisify(exec);
1111

@@ -24,8 +24,8 @@ async function ensureOllamaModel(model: string) {
2424
if (!response.ok) {
2525
throw new Error('Ollama is not running. Please start Ollama first.');
2626
}
27-
const data = await response.json() as { models: { name: string }[] };
28-
const modelExists = data.models.some(m => m.name.includes(model));
27+
const data = (await response.json()) as { models: { name: string }[] };
28+
const modelExists = data.models.some((m) => m.name.includes(model));
2929

3030
if (!modelExists) {
3131
spinner.text = `Pulling Ollama model: ${model} (this may take a while)...`;
@@ -46,31 +46,35 @@ program
4646
.command('extract <file>')
4747
.description('Extract structured data from a document')
4848
.option('-p, --provider <provider>', 'AI provider (gemini|openai|ollama)', 'ollama')
49-
.option('-m, --model <model>', 'Model to use (default: llama3.2-vision for ollama)', 'llama3.2-vision')
49+
.option(
50+
'-m, --model <model>',
51+
'Model to use (default: llama3.2-vision for ollama)',
52+
'llama3.2-vision'
53+
)
5054
.action(async (file: string, options) => {
5155
try {
5256
if (options.provider === 'ollama') {
5357
await ensureOllamaModel(options.model);
5458
}
5559

5660
const spinner = ora('Extracting document data...').start();
57-
61+
5862
const config: Config = {
5963
aiProvider: options.provider,
6064
geminiApiKey: process.env.GEMINI_API_KEY,
6165
openaiApiKey: process.env.OPENAI_API_KEY,
62-
ollamaModel: options.model
66+
ollamaModel: options.model,
6367
};
64-
68+
6569
const result = await extractDocument(file, config);
66-
70+
6771
spinner.succeed(chalk.green('Extraction complete!'));
6872
console.log(JSON.stringify(result, null, 2));
6973
} catch (error) {
7074
// Only fail the spinner if it's running (ensureOllamaModel might have failed already)
7175
if (ora().isSpinning) {
72-
// This check is tricky because ora() creates a new instance.
73-
// We'll just log the error.
76+
// This check is tricky because ora() creates a new instance.
77+
// We'll just log the error.
7478
}
7579
console.error(chalk.red('\nExtraction failed:'));
7680
console.error((error as Error).message);
@@ -95,7 +99,7 @@ program
9599
});
96100

97101
program
98-
.command('mcp')
102+
.command('mcp')
99103
.description('Start MCP server')
100104
.action(async () => {
101105
const { startMCPServer } = await import('./mcp/server.js');

packages/cli/src/mcp/server.ts

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1+
import type { Config } from '@doc-agent/core';
2+
import { extractDocument } from '@doc-agent/extract';
13
import { Server } from '@modelcontextprotocol/sdk/server';
24
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
35
import {
6+
type CallToolRequest,
47
CallToolRequestSchema,
58
ListToolsRequestSchema,
6-
CallToolRequest
79
} from '@modelcontextprotocol/sdk/types.js';
8-
import { extractDocument } from '@doc-agent/extract';
9-
import type { Config } from '@doc-agent/core';
1010

1111
const server = new Server(
1212
{
1313
name: 'doc-agent',
14-
version: '0.1.0'
14+
version: '0.1.0',
1515
},
1616
{
1717
capabilities: {
18-
tools: {}
19-
}
18+
tools: {},
19+
},
2020
}
2121
);
2222

@@ -32,17 +32,17 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
3232
properties: {
3333
filepath: {
3434
type: 'string',
35-
description: 'Path to the document file'
35+
description: 'Path to the document file',
3636
},
3737
provider: {
3838
type: 'string',
3939
enum: ['gemini', 'openai', 'ollama'],
4040
description: 'AI provider to use',
41-
default: 'gemini'
42-
}
41+
default: 'gemini',
42+
},
4343
},
44-
required: ['filepath']
45-
}
44+
required: ['filepath'],
45+
},
4646
},
4747
{
4848
name: 'search_documents',
@@ -52,18 +52,18 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
5252
properties: {
5353
query: {
5454
type: 'string',
55-
description: 'Search query in natural language'
55+
description: 'Search query in natural language',
5656
},
5757
limit: {
5858
type: 'number',
5959
description: 'Maximum number of results',
60-
default: 10
61-
}
60+
default: 10,
61+
},
6262
},
63-
required: ['query']
64-
}
65-
}
66-
]
63+
required: ['query'],
64+
},
65+
},
66+
],
6767
};
6868
});
6969

@@ -74,48 +74,48 @@ server.setRequestHandler(CallToolRequestSchema, async (request: CallToolRequest)
7474
filepath: string;
7575
provider?: string;
7676
};
77-
77+
7878
const config: Config = {
7979
aiProvider: provider as 'gemini' | 'openai' | 'ollama',
8080
geminiApiKey: process.env.GEMINI_API_KEY,
81-
openaiApiKey: process.env.OPENAI_API_KEY
81+
openaiApiKey: process.env.OPENAI_API_KEY,
8282
};
83-
83+
8484
try {
8585
const result = await extractDocument(filepath, config);
86-
86+
8787
return {
8888
content: [
8989
{
9090
type: 'text',
91-
text: JSON.stringify(result, null, 2)
92-
}
93-
]
91+
text: JSON.stringify(result, null, 2),
92+
},
93+
],
9494
};
9595
} catch (error) {
9696
return {
9797
content: [
9898
{
9999
type: 'text',
100-
text: `Error: ${(error as Error).message}`
101-
}
100+
text: `Error: ${(error as Error).message}`,
101+
},
102102
],
103-
isError: true
103+
isError: true,
104104
};
105105
}
106106
}
107-
107+
108108
if (request.params.name === 'search_documents') {
109109
return {
110110
content: [
111111
{
112112
type: 'text',
113-
text: 'Search functionality not yet implemented'
114-
}
115-
]
113+
text: 'Search functionality not yet implemented',
114+
},
115+
],
116116
};
117117
}
118-
118+
119119
throw new Error(`Unknown tool: ${request.params.name}`);
120120
});
121121

packages/cli/tsconfig.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,5 @@
66
},
77
"include": ["src/**/*"],
88
"exclude": ["node_modules", "dist"],
9-
"references": [
10-
{ "path": "../core" },
11-
{ "path": "../extract" },
12-
{ "path": "../vector-store" }
13-
]
9+
"references": [{ "path": "../core" }, { "path": "../extract" }, { "path": "../vector-store" }]
1410
}

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626
"devDependencies": {
2727
"typescript": "^5.9.3"
2828
}
29-
}
29+
}

0 commit comments

Comments
 (0)