Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ on:
branches: [main]

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 20
cache: npm
- run: npm ci
- run: npm run lint

typecheck:
name: Typecheck
runs-on: ubuntu-latest
Expand All @@ -29,12 +41,12 @@ jobs:
node-version: 20
cache: npm
- run: npm ci
- run: npm run test:run
- run: npx vitest run --coverage

build:
name: Build
runs-on: ubuntu-latest
needs: [typecheck, test]
needs: [lint, typecheck, test]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
Expand Down
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ npm run test:run # Run tests once and exit

All tests must pass before submitting a pull request.

## Linting

This project uses [Biome](https://biomejs.dev/) for linting and formatting:

```bash
npm run lint # Check for lint and formatting issues
npm run lint:fix # Auto-fix issues
```

CI enforces linting — run `npm run lint` before pushing.

## Building and Running

To build the TypeScript code:
Expand All @@ -58,6 +69,7 @@ npm start

- Use TypeScript for all code
- Follow ESM module conventions (this project uses `"type": "module"`)
- Run `npm run lint` to check formatting and lint rules ([Biome](https://biomejs.dev/) enforces style automatically)
- Keep code readable and maintainable
- Comments should explain the "why", not the "what"

Expand Down
24 changes: 24 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://biomejs.dev/schemas/2.4.4/schema.json",
"files": {
"includes": ["src/**/*.ts"]
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"trailingCommas": "all"
}
}
}
168 changes: 166 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"dev": "tsc --watch",
"start": "node dist/index.js",
"prepublishOnly": "npm run build",
"lint": "biome check src/",
"lint:fix": "biome check --write src/",
"test": "vitest",
"test:run": "vitest run"
},
Expand Down Expand Up @@ -47,6 +49,7 @@
"zod": "^4.3.6"
},
"devDependencies": {
"@biomejs/biome": "2.4.4",
"@types/node": "^25.3.0",
"@vitest/coverage-v8": "^4.0.18",
"typescript": "^5.9.3",
Expand Down
7 changes: 2 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import {
CallToolRequestSchema,
ListToolsRequestSchema,
} from "@modelcontextprotocol/sdk/types.js";
import { tools, executeTool } from "./tools.js";
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
import { getModels } from "./pricing.js";
import { executeTool, tools } from "./tools.js";

const server = new Server(
{
Expand Down
15 changes: 6 additions & 9 deletions src/pricing.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

// Mock fs so disk cache doesn't interfere
vi.mock("node:fs", () => ({
Expand Down Expand Up @@ -303,9 +303,7 @@ describe("pricing module", () => {
});

const { refreshPrices } = await loadPricing();
await expect(refreshPrices()).rejects.toThrow(
"Failed to fetch pricing data: 503",
);
await expect(refreshPrices()).rejects.toThrow("Failed to fetch pricing data: 503");
});
});

Expand Down Expand Up @@ -435,10 +433,9 @@ describe("pricing module", () => {
const { refreshPrices } = await loadPricing();
await refreshPrices();

expect(mkdirSync).toHaveBeenCalledWith(
expect.stringContaining(".cache"),
{ recursive: true },
);
expect(mkdirSync).toHaveBeenCalledWith(expect.stringContaining(".cache"), {
recursive: true,
});
});
});
});
Loading