Skip to content

Commit a132e62

Browse files
committed
simplify prettier setup.
1 parent aacee4a commit a132e62

14 files changed

+112
-90
lines changed

.github/workflows/ci.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ name: CI
33
on:
44
push:
55
branches:
6-
- "*"
6+
- '*'
77
pull_request:
88
branches:
99
- main
1010

1111
permissions:
1212
contents: read
1313

14+
env:
15+
pnpm-version: 10.2.1
16+
node-version: 23
17+
1418
jobs:
1519
ci:
1620
runs-on: ubuntu-latest
@@ -19,15 +23,15 @@ jobs:
1923

2024
- uses: pnpm/action-setup@v2
2125
with:
22-
version: 10.2.1
26+
version: ${{ env.pnpm-version }}
2327

2428
- uses: actions/setup-node@v3
2529
with:
26-
node-version: 23
30+
node-version: ${{ env.node-version }}
2731

2832
- name: Install dependencies
2933
run: pnpm install --frozen-lockfile
30-
34+
3135
- name: Build
3236
run: pnpm build:ci
3337

@@ -38,4 +42,4 @@ jobs:
3842
run: pnpm test
3943

4044
- name: Lint
41-
run: pnpm lint
45+
run: pnpm lint

.prettierignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
.DS_Store
3+
dist
4+
*.local
5+
node_modules/*
6+
dist
7+
coverage
8+
pnpm-lock.yaml

COMMIT_CONVENTION.md

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ docs: update README with new API documentation
4747
## Changelog Generation
4848

4949
Commit messages are used to:
50+
5051
1. Automatically determine the next version number
5152
2. Generate changelog entries
5253
3. Create GitHub releases

bin/cli.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env node
2-
import "../dist/index.js";
2+
import '../dist/index.js';

eslint.config.js

+50-50
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,78 @@
11
// eslint.config.js
2-
import js from "@eslint/js";
3-
import ts from "typescript-eslint";
4-
import prettierRecommended from "eslint-plugin-prettier/recommended";
5-
import importPlugin from "eslint-plugin-import";
6-
import unusedImports from "eslint-plugin-unused-imports";
7-
import pluginPromise from "eslint-plugin-promise";
2+
import js from '@eslint/js';
3+
import ts from 'typescript-eslint';
4+
import prettierRecommended from 'eslint-plugin-prettier/recommended';
5+
import importPlugin from 'eslint-plugin-import';
6+
import unusedImports from 'eslint-plugin-unused-imports';
7+
import pluginPromise from 'eslint-plugin-promise';
88

99
export default ts.config(
1010
js.configs.recommended,
1111
ts.configs.recommendedTypeChecked,
1212
prettierRecommended,
1313
importPlugin.flatConfigs.recommended,
14-
pluginPromise.configs["flat/recommended"],
14+
pluginPromise.configs['flat/recommended'],
1515
{
1616
languageOptions: {
1717
ecmaVersion: 2022,
18-
sourceType: "module",
18+
sourceType: 'module',
1919
parserOptions: {
20-
project: ["./tsconfig.eslint.json"],
20+
project: ['./tsconfig.eslint.json'],
2121
tsconfigRootDir: import.meta.dirname,
2222
},
2323
},
2424
plugins: {
25-
"unused-imports": unusedImports,
25+
'unused-imports': unusedImports,
2626
},
27-
files: ["{src,test}/**/*.{js,ts}"],
27+
files: ['{src,test}/**/*.{js,ts}'],
2828
rules: {
2929
// Basic code quality rules
30-
"no-console": "off",
31-
"prefer-const": "warn",
32-
"no-var": "warn",
33-
eqeqeq: ["warn", "always"],
30+
'no-console': 'off',
31+
'prefer-const': 'warn',
32+
'no-var': 'warn',
33+
eqeqeq: ['warn', 'always'],
3434

3535
// Light complexity rules
36-
complexity: ["warn", { max: 20 }],
37-
"max-depth": ["warn", { max: 4 }],
38-
"max-lines-per-function": ["warn", { max: 150 }],
36+
complexity: ['warn', { max: 20 }],
37+
'max-depth': ['warn', { max: 4 }],
38+
'max-lines-per-function': ['warn', { max: 150 }],
3939

40-
"@typescript-eslint/no-unsafe-assignment": "off",
41-
"@typescript-eslint/no-explicit-any": "off",
42-
"@typescript-eslint/no-unsafe-member-access": "off",
43-
"@typescript-eslint/no-unsafe-call": "off",
44-
"@typescript-eslint/no-unsafe-return": "off",
45-
"@typescript-eslint/no-unsafe-argument": "off",
46-
"@typescript-eslint/no-explicit-any": "off",
47-
"@typescript-eslint/no-unused-vars": [
48-
"error",
49-
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
40+
'@typescript-eslint/no-unsafe-assignment': 'off',
41+
'@typescript-eslint/no-explicit-any': 'off',
42+
'@typescript-eslint/no-unsafe-member-access': 'off',
43+
'@typescript-eslint/no-unsafe-call': 'off',
44+
'@typescript-eslint/no-unsafe-return': 'off',
45+
'@typescript-eslint/no-unsafe-argument': 'off',
46+
'@typescript-eslint/no-explicit-any': 'off',
47+
'@typescript-eslint/no-unused-vars': [
48+
'error',
49+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
5050
],
5151

52-
"import/no-unresolved": "off",
53-
"import/named": "off",
54-
"import/extensions": [
55-
"error",
56-
"ignorePackages",
57-
{ js: "always", ts: "never" },
52+
'import/no-unresolved': 'off',
53+
'import/named': 'off',
54+
'import/extensions': [
55+
'error',
56+
'ignorePackages',
57+
{ js: 'always', ts: 'never' },
5858
],
5959

60-
"no-unused-vars": "off", // or "@typescript-eslint/no-unused-vars": "off",
61-
"unused-imports/no-unused-imports": "error",
60+
'no-unused-vars': 'off', // or "@typescript-eslint/no-unused-vars": "off",
61+
'unused-imports/no-unused-imports': 'error',
6262

63-
"promise/always-return": "error",
64-
"promise/no-return-wrap": "error",
65-
"promise/param-names": "error",
66-
"promise/catch-or-return": "error",
67-
"promise/no-native": "off",
68-
"promise/no-nesting": "warn",
69-
"promise/no-promise-in-callback": "warn",
70-
"promise/no-callback-in-promise": "warn",
71-
"promise/avoid-new": "off",
72-
"promise/no-new-statics": "error",
73-
"promise/no-return-in-finally": "warn",
74-
"promise/valid-params": "warn",
75-
"promise/no-multiple-resolved": "error",
63+
'promise/always-return': 'error',
64+
'promise/no-return-wrap': 'error',
65+
'promise/param-names': 'error',
66+
'promise/catch-or-return': 'error',
67+
'promise/no-native': 'off',
68+
'promise/no-nesting': 'warn',
69+
'promise/no-promise-in-callback': 'warn',
70+
'promise/no-callback-in-promise': 'warn',
71+
'promise/avoid-new': 'off',
72+
'promise/no-new-statics': 'error',
73+
'promise/no-return-in-finally': 'warn',
74+
'promise/valid-params': 'warn',
75+
'promise/no-multiple-resolved': 'error',
7676
},
77-
}
77+
},
7878
);

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"clean": "rimraf dist",
2626
"clean:all": "rimraf dist node_modules",
2727
"lint": "eslint \"{src,test}/**/*.{js,ts}\" --fix",
28-
"format": "prettier --write \"src/**/*.*\"",
28+
"format": "prettier --write .",
2929
"test": "vitest run",
3030
"test:watch": "vitest",
3131
"test:ci": "vitest --run --coverage",

prettier.config.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// prettier.config.ts, .prettierrc.ts, prettier.config.mts, or .prettierrc.mts
22

3-
import { type Config } from "prettier";
3+
import { type Config } from 'prettier';
44

55
const config: Config = {
6-
trailingComma: "all",
6+
trailingComma: 'all',
77
tabWidth: 2,
88
semi: true,
99
singleQuote: true,
1010
};
1111

12-
export default config;
12+
export default config;

src/core/toolAgent.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,20 @@ async function executeTools(
123123
logger.verbose(`Executing ${toolCalls.length} tool calls`);
124124

125125
// Check for respawn tool call
126-
const respawnCall = toolCalls.find(call => call.name === 'respawn');
126+
const respawnCall = toolCalls.find((call) => call.name === 'respawn');
127127
if (respawnCall) {
128128
return {
129129
sequenceCompleted: false,
130-
toolResults: [{
131-
type: 'tool_result',
132-
tool_use_id: respawnCall.id,
133-
content: 'Respawn initiated',
134-
}],
130+
toolResults: [
131+
{
132+
type: 'tool_result',
133+
tool_use_id: respawnCall.id,
134+
content: 'Respawn initiated',
135+
},
136+
],
135137
respawn: {
136-
context: respawnCall.input.respawnContext
137-
}
138+
context: respawnCall.input.respawnContext,
139+
},
138140
};
139141
}
140142

src/tools/io/updateFile.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ export const updateFileTool: Tool<Parameters, ReturnType> = {
7474
},
7575
logParameters: (input, { logger }) => {
7676
const isFile = fs.existsSync(input.path);
77-
logger.info(`${isFile ? 'Modifying' : 'Creating' } "${input.path}", ${input.description}`);
77+
logger.info(
78+
`${isFile ? 'Modifying' : 'Creating'} "${input.path}", ${input.description}`,
79+
);
7880
},
7981
logReturns: () => {},
8082
};

src/tools/system/respawn.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export interface RespawnInput {
66

77
export const respawnTool: Tool = {
88
name: 'respawn',
9-
description: 'Resets the agent context to just the system prompt and provided context',
9+
description:
10+
'Resets the agent context to just the system prompt and provided context',
1011
parameters: {
1112
type: 'object',
1213
properties: {
@@ -22,7 +23,10 @@ export const respawnTool: Tool = {
2223
type: 'string',
2324
description: 'A message indicating that the respawn has been initiated',
2425
},
25-
execute: async (params: Record<string, any>, context: ToolContext): Promise<string> => {
26+
execute: async (
27+
params: Record<string, any>,
28+
context: ToolContext,
29+
): Promise<string> => {
2630
// This is a special case tool - the actual respawn logic is handled in toolAgent
2731
return 'Respawn initiated';
2832
},

src/tools/system/shellMessage.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ export const shellMessageTool: Tool<Parameters, ReturnType> = {
162162
},
163163

164164
logParameters: (input, { logger }) => {
165-
const processState = processStates.get(input.instanceId);
166-
logger.info(
167-
`Interacting with shell command "${processState ? processState.command : "<unknown instanceId>"}", ${input.description}`,
165+
const processState = processStates.get(input.instanceId);
166+
logger.info(
167+
`Interacting with shell command "${processState ? processState.command : '<unknown instanceId>'}", ${input.description}`,
168168
);
169169
},
170170
logReturns: () => {},

tests/cli.test.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { expect, test, describe } from "vitest";
2-
import { execSync } from "child_process";
3-
import { version } from "../package.json";
1+
import { expect, test, describe } from 'vitest';
2+
import { execSync } from 'child_process';
3+
import { version } from '../package.json';
44

5-
describe("CLI", () => {
6-
test("version command outputs correct version", () => {
7-
const output = execSync("npx mycoder --version").toString();
5+
describe('CLI', () => {
6+
test('version command outputs correct version', () => {
7+
const output = execSync('npx mycoder --version').toString();
88
expect(output.trim()).toContain(version);
9-
expect(output.trim()).not.toContain("AI-powered coding assistant");
9+
expect(output.trim()).not.toContain('AI-powered coding assistant');
1010
});
1111

12-
test("-h command outputs help", () => {
13-
const output = execSync("npx mycoder -h").toString();
14-
expect(output.trim()).toContain("Commands:");
15-
expect(output.trim()).toContain("Positionals:");
16-
expect(output.trim()).toContain("Options:");
12+
test('-h command outputs help', () => {
13+
const output = execSync('npx mycoder -h').toString();
14+
expect(output.trim()).toContain('Commands:');
15+
expect(output.trim()).toContain('Positionals:');
16+
expect(output.trim()).toContain('Options:');
1717
});
1818
});

tests/core/toolAgent.respawn.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ vi.mock('@anthropic-ai/sdk', () => {
88
return {
99
default: vi.fn().mockImplementation(() => ({
1010
messages: {
11-
create: vi.fn()
11+
create: vi
12+
.fn()
1213
.mockResolvedValueOnce({
1314
content: [
1415
{

vitest.config.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { defineConfig } from "vitest/config";
1+
import { defineConfig } from 'vitest/config';
22

33
export default defineConfig({
44
test: {
5-
include: ["src/**/*.test.ts", "tests/**/*.test.ts"],
6-
environment: "node",
5+
include: ['src/**/*.test.ts', 'tests/**/*.test.ts'],
6+
environment: 'node',
77
globals: true,
88
// Default timeout for all tests
99
testTimeout: 10000,

0 commit comments

Comments
 (0)