From df24d51276a72ef0123ae83bf55066da382f0972 Mon Sep 17 00:00:00 2001 From: JonathanLab Date: Tue, 30 Sep 2025 14:09:13 +0200 Subject: [PATCH] chore: config housekeeping --- mprocs.yaml | 6 ++-- package.json | 8 ++--- src/api/posthogClient.ts | 14 ++++---- src/main/index.ts | 2 +- src/main/preload.ts | 2 +- src/main/services/agent.ts | 4 +-- src/main/services/os.ts | 2 +- src/main/services/posthog.ts | 2 +- tailwind.config.js | 2 +- tsconfig.json | 54 +++++++++++++++++++++++++------ tsconfig.node.json | 23 +++++++++++++ tsconfig.preload.json | 17 ---------- tsconfig.renderer.json | 39 ---------------------- tsconfig.web.json | 26 +++++++++++++++ vite.config.ts => vite.config.mts | 3 ++ 15 files changed, 117 insertions(+), 87 deletions(-) create mode 100644 tsconfig.node.json delete mode 100644 tsconfig.preload.json delete mode 100644 tsconfig.renderer.json create mode 100644 tsconfig.web.json rename vite.config.ts => vite.config.mts (85%) diff --git a/mprocs.yaml b/mprocs.yaml index 73f7ee6a..e0c0c9c7 100644 --- a/mprocs.yaml +++ b/mprocs.yaml @@ -4,8 +4,8 @@ procs: cwd: . color: blue - main: - cmd: ["pnpm", "run", "dev:main"] + node: + cmd: ["pnpm", "run", "dev:node"] cwd: . color: green @@ -15,4 +15,4 @@ procs: color: yellow depends_on: - vite - - main \ No newline at end of file + - node \ No newline at end of file diff --git a/package.json b/package.json index 14b584ac..9f2f5599 100644 --- a/package.json +++ b/package.json @@ -11,14 +11,14 @@ "scripts": { "dev": "mprocs", "dev:vite": "vite", - "dev:main": "tsc -p tsconfig.json --watch & tsc -p tsconfig.preload.json --watch", + "dev:node": "tsc -p tsconfig.node.json --watch", "dev:electron": "wait-on tcp:5173 && wait-on dist/main/index.js && electron . --dev", - "build": "pnpm run build:main && pnpm run build:vite && pnpm run build:electron", - "build:main": "tsc -p tsconfig.json && tsc -p tsconfig.preload.json && echo '{\"type\":\"module\"}' > dist/main/package.json", + "build": "pnpm run build:node && pnpm run build:vite && pnpm run build:electron", + "build:node": "tsc -p tsconfig.node.json", "build:vite": "vite build", "build:electron": "electron-builder", "preview": "vite preview", - "typecheck": "tsc --noEmit", + "typecheck": "tsc -p tsconfig.node.json --noEmit && tsc -p tsconfig.web.json --noEmit", "lint": "eslint src --ext .ts,.tsx", "generate-client": "tsx scripts/update-openapi-client.ts" }, diff --git a/src/api/posthogClient.ts b/src/api/posthogClient.ts index a31c9e5d..164c59c8 100644 --- a/src/api/posthogClient.ts +++ b/src/api/posthogClient.ts @@ -6,7 +6,7 @@ export class PostHogAPIClient { private api: ReturnType; private _teamId: number | null = null; - constructor(private apiKey: string, private apiHost: string) { + constructor(apiKey: string, apiHost: string) { const baseUrl = apiHost.endsWith('/') ? apiHost.slice(0, -1) : apiHost; this.api = createApiClient( buildApiFetcher({ apiToken: apiKey }), @@ -64,24 +64,24 @@ export class PostHogAPIClient { } async createTask( - title: string, + title: string, description: string, repositoryConfig?: { organization: string; repository: string } ) { const teamId = await this.getTeamId(); - + const payload = { title, description, - origin_product: 'user_created', + origin_product: 'user_created' as const, ...(repositoryConfig && { repository_config: repositoryConfig }), }; - + const data = await this.api.post(`/api/projects/{project_id}/tasks/`, { path: {project_id: teamId.toString()}, - body: payload + body: payload as Schemas.Task }); - + return data; } diff --git a/src/main/index.ts b/src/main/index.ts index 451424d3..c9c923ba 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -1,4 +1,4 @@ -import { app, BrowserWindow, Menu, MenuItemConstructorOptions } from 'electron'; +import { app, BrowserWindow, Menu, type MenuItemConstructorOptions } from 'electron'; import path from 'path'; import { fileURLToPath } from 'url'; import { registerPosthogIpc } from './services/posthog.js'; diff --git a/src/main/preload.ts b/src/main/preload.ts index c1744a1a..79cb56fc 100644 --- a/src/main/preload.ts +++ b/src/main/preload.ts @@ -1,4 +1,4 @@ -import { contextBridge, ipcRenderer, IpcRendererEvent } from 'electron'; +import { contextBridge, ipcRenderer, type IpcRendererEvent } from 'electron'; interface MessageBoxOptions { type?: 'info' | 'error' | 'warning' | 'question'; diff --git a/src/main/services/agent.ts b/src/main/services/agent.ts index c73d1871..68cb737f 100644 --- a/src/main/services/agent.ts +++ b/src/main/services/agent.ts @@ -1,4 +1,4 @@ -import { ipcMain, BrowserWindow, IpcMainInvokeEvent } from 'electron'; +import { ipcMain, BrowserWindow, type IpcMainInvokeEvent } from 'electron'; import { getCurrentBranch } from './git.js'; import { createAgent, ClaudeCodeAgent } from '@posthog/code-agent'; @@ -15,7 +15,7 @@ interface TaskController { } export function registerAgentIpc(taskControllers: Map, getMainWindow: () => BrowserWindow | null): void { - ipcMain.handle('agent-start', async (_event: IpcMainInvokeEvent, { prompt, repoPath, model }: AgentStartParams): Promise<{ taskId: string; channel: string }> => { + ipcMain.handle('agent-start', async (_event: IpcMainInvokeEvent, { prompt, repoPath }: AgentStartParams): Promise<{ taskId: string; channel: string }> => { if (!prompt || !repoPath) { throw new Error('prompt and repoPath are required'); } diff --git a/src/main/services/os.ts b/src/main/services/os.ts index 7ae82fb0..c67cefb7 100644 --- a/src/main/services/os.ts +++ b/src/main/services/os.ts @@ -1,4 +1,4 @@ -import { ipcMain, dialog, BrowserWindow, IpcMainInvokeEvent } from 'electron'; +import { ipcMain, dialog, BrowserWindow, type IpcMainInvokeEvent } from 'electron'; import path from 'path'; import fs from 'fs'; import { promisify } from 'util'; diff --git a/src/main/services/posthog.ts b/src/main/services/posthog.ts index 1b035055..fc587e2f 100644 --- a/src/main/services/posthog.ts +++ b/src/main/services/posthog.ts @@ -1,4 +1,4 @@ -import { ipcMain, safeStorage, IpcMainInvokeEvent } from 'electron'; +import { ipcMain, safeStorage, type IpcMainInvokeEvent } from 'electron'; export function registerPosthogIpc(): void { // IPC handlers for secure storage diff --git a/tailwind.config.js b/tailwind.config.js index 7ed169fd..6a6cadcd 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,4 +1,4 @@ -const { radixThemePreset } = require('radix-themes-tw'); +import { radixThemePreset } from 'radix-themes-tw'; /** @type {import('tailwindcss').Config} */ module.exports = { diff --git a/tsconfig.json b/tsconfig.json index a644baee..68e0b407 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,17 +1,51 @@ { + "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { - "target": "ES2020", - "module": "ESNext", - "lib": ["ES2020"], - "moduleResolution": "node", + "allowJs": true, + "baseUrl": "./src", + "declaration": true, + "declarationMap": true, "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "inlineSources": true, + "isolatedModules": true, + "jsx": "preserve", + "module": "esnext", + "moduleResolution": "bundler", + "noEmit": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "paths": { + "@/*": [ + "./*" + ], + "@api/*": [ + "api/*" + ], + "@main/*": [ + "main/*" + ], + "@renderer/*": [ + "renderer/*" + ], + "@shared/*": [ + "shared/*" + ] + }, + "resolveJsonModule": true, "skipLibCheck": true, + "sourceMap": true, "strict": true, - "resolveJsonModule": true, - "outDir": "dist/main", - "rootDir": "src/main", - "types": ["node"] + "target": "esnext" }, - "include": ["src/main/**/*"], - "exclude": ["node_modules", "src/main/preload.ts"] + "exclude": [ + "node_modules", + "dist", + "release" + ], + "include": [ + "src/**/*" + ] } \ No newline at end of file diff --git a/tsconfig.node.json b/tsconfig.node.json new file mode 100644 index 00000000..2d0b3063 --- /dev/null +++ b/tsconfig.node.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src", + "noEmit": false, + "module": "ES2022", + "moduleResolution": "node", + "verbatimModuleSyntax": true, + "types": [ + "node" + ] + }, + "exclude": [ + "src/renderer/**/*" + ], + "extends": "./tsconfig.json", + "include": [ + "src/main/**/*", + "src/shared/**/*", + "src/api/**/*" + ] +} \ No newline at end of file diff --git a/tsconfig.preload.json b/tsconfig.preload.json deleted file mode 100644 index a44aeaad..00000000 --- a/tsconfig.preload.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2020", - "module": "CommonJS", - "lib": ["ES2020"], - "moduleResolution": "node", - "esModuleInterop": true, - "skipLibCheck": true, - "strict": true, - "resolveJsonModule": true, - "outDir": "dist/main", - "rootDir": "src/main", - "types": ["node"] - }, - "include": ["src/main/preload.ts"], - "exclude": ["node_modules"] -} \ No newline at end of file diff --git a/tsconfig.renderer.json b/tsconfig.renderer.json deleted file mode 100644 index bce8a2a3..00000000 --- a/tsconfig.renderer.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2022", - "lib": ["ES2022", "DOM", "DOM.Iterable"], - "module": "ESNext", - "jsx": "react-jsx", - "moduleResolution": "node", - "resolveJsonModule": true, - "allowJs": true, - "strict": true, - "esModuleInterop": true, - "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, - "declaration": true, - "declarationMap": true, - "sourceMap": true, - "inlineSources": true, - "allowSyntheticDefaultImports": true, - "outDir": "./dist/renderer", - "baseUrl": "./src", - "paths": { - "@/*": ["./*"], - "@renderer/*": ["renderer/*"], - "@shared/*": ["shared/*"], - "@api/*": ["api/*"] - }, - "types": ["vite/client"] - }, - "include": [ - "src/renderer/**/*", - "src/shared/**/*" - ], - "exclude": [ - "node_modules", - "dist", - "release", - "src/main/**/*" - ] -} \ No newline at end of file diff --git a/tsconfig.web.json b/tsconfig.web.json new file mode 100644 index 00000000..4b9431f8 --- /dev/null +++ b/tsconfig.web.json @@ -0,0 +1,26 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "compilerOptions": { + "jsx": "react-jsx", + "lib": [ + "ESNext", + "DOM", + "DOM.Iterable" + ], + "outDir": "./dist/renderer", + "target": "ESNext", + "types": [ + "vite/client" + ] + }, + "exclude": [ + "src/main/**/*", + "src/api/repoDetector.ts" + ], + "extends": "./tsconfig.json", + "include": [ + "src/renderer/**/*", + "src/shared/**/*", + "src/api/**/*" + ] +} \ No newline at end of file diff --git a/vite.config.ts b/vite.config.mts similarity index 85% rename from vite.config.ts rename to vite.config.mts index 5bd0f561..85f7c153 100644 --- a/vite.config.ts +++ b/vite.config.mts @@ -1,6 +1,9 @@ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import path from 'path'; +import { fileURLToPath } from 'url'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); export default defineConfig({ plugins: [react()],