Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix: add cli eslint

Gus49e3196691d5
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index f344f26d8..5a2690ee9 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -22,10 +22,11 @@ jobs:
node-version: 20
cache: pnpm
- run: pnpm install --frozen-lockfile
- - run: pnpm tsc --noEmit -p src/web/tsconfig.json
- run: pnpm tsc -b src/shared
+ - run: pnpm tsc --noEmit -p src/web/tsconfig.json
- run: pnpm tsc --noEmit -p src/cli/tsconfig.json
- run: cd src/web && pnpm eslint
+ - run: cd src/cli && pnpm eslint
test:
name: Tests
diff --git a/Makefile b/Makefile
index 36e9aa1c4..49a40f81a 100644
--- a/Makefile
+++ b/Makefile
@@ -28,8 +28,11 @@ test-unit: ## Run unit tests only (no DB required)
test: test-unit test-integration ## Run all tests
typecheck: ## TypeScript type check
+ pnpm tsc -b src/shared
pnpm tsc --noEmit -p src/web/tsconfig.json
pnpm tsc --noEmit -p src/cli/tsconfig.json
+ cd src/web && pnpm eslint
+ cd src/cli && pnpm eslint
test-integration: ## Run integration tests (requires PostgreSQL)
bash scripts/setup-test-db.sh
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index c11ce50d9..232ccc9b7 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -30,6 +30,9 @@ importers:
specifier: ^16.0.0
version: 16.6.1
devDependencies:
+ eslint:
+ specifier: ^9.0.0
+ version: 9.39.4([email protected])
tsup:
specifier: ^8.0.0
@@ -39,6 +42,9 @@ importers:
typescript:
specifier: ^5.0.0
version: 5.9.3
+ typescript-eslint:
+ specifier: ^8.0.0
src/shared:
dependencies:
@@ -129,7 +135,7 @@ importers:
version: 9.39.4([email protected])
eslint-config-next:
specifier: 16.2.2
tailwindcss:
specifier: ^4
version: 4.2.2
@@ -7218,13 +7224,13 @@ snapshots:
dependencies:
'@next/eslint-plugin-next': 16.2.2
eslint: 9.39.4([email protected])
eslint-import-resolver-node: 0.3.10
eslint-plugin-jsx-a11y: 6.10.2([email protected]([email protected]))
eslint-plugin-react: 7.37.5([email protected]([email protected]))
eslint-plugin-react-hooks: 7.0.1([email protected]([email protected]))
@@ -7246,7 +7252,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@nolyfill/is-core-module': 1.0.39
debug: 4.4.3
@@ -7257,22 +7263,21 @@ snapshots:
tinyglobby: 0.2.16
unrs-resolver: 1.11.1
optionalDependencies:
transitivePeerDependencies:
- supports-color
dependencies:
debug: 3.2.7
optionalDependencies:
- '@typescript-eslint/parser': 8.58.1([email protected]([email protected]))([email protected])
eslint: 9.39.4([email protected])
eslint-import-resolver-node: 0.3.10
transitivePeerDependencies:
- supports-color
dependencies:
'@rtsao/scc': 1.1.0
array-includes: 3.1.9
@@ -7283,7 +7288,7 @@ snapshots:
doctrine: 2.1.0
eslint: 9.39.4([email protected])
eslint-import-resolver-node: 0.3.10
hasown: 2.0.2
is-core-module: 2.16.1
is-glob: 4.0.3
@@ -7294,8 +7299,6 @@ snapshots:
semver: 6.3.1
string.prototype.trimend: 1.0.9
tsconfig-paths: 3.15.0
- optionalDependencies:
- '@typescript-eslint/parser': 8.58.1([email protected]([email protected]))([email protected])
transitivePeerDependencies:
- eslint-import-resolver-typescript
- eslint-import-resolver-webpack
diff --git a/src/cli/commands/register.ts b/src/cli/commands/register.ts
index fca6b1d45..5c0c22e13 100644
--- a/src/cli/commands/register.ts
+++ b/src/cli/commands/register.ts
@@ -1,9 +1,6 @@
import { Command } from "commander";
import { APIClient } from "../lib/client.js";
-import {
- loadCLIConfigForProfile,
- saveCLIConfigForProfile,
-} from "../lib/config.js";
+import { saveCLIConfigForProfile } from "../lib/config.js";
interface MeResponse {
id: string;
diff --git a/src/cli/daemon/daemon.ts b/src/cli/daemon/daemon.ts
index 554a0478f..76404c0ad 100644
--- a/src/cli/daemon/daemon.ts
+++ b/src/cli/daemon/daemon.ts
@@ -3,7 +3,7 @@ import { type DaemonConfig, loadDaemonConfig } from "./config.js";
import { createHealthServer } from "./health.js";
import { buildPrompt } from "./prompt.js";
import { createBackend, detectVersion } from "./agent/index.js";
-import { type Task, type TaskResult, type AgentMessage, fromApiTask } from "./types.js";
+import { type Task, type TaskResult, fromApiTask } from "./types.js";
import { loadCLIConfigForProfile } from "../lib/config.js";
import { log } from "../lib/logger.js";
import { mkdirSync } from "fs";
@@ -111,36 +111,6 @@ export async function startDaemon(
`Daemon started — ${allRuntimeIds.length} runtime(s) across ${workspaces.length} workspace(s)`,
);
- let heartbeatTimer: NodeJS.Timeout;
- let pollTimer: NodeJS.Timeout;
-
- const shutdown = async () => {
- log.info("Shutting down...");
- clearInterval(heartbeatTimer);
- clearInterval(pollTimer);
- const timeout = setTimeout(() => process.exit(1), 5000);
- try {
- await client.deregister(allRuntimeIds);
- } catch {
- // best-effort deregister
- }
- clearTimeout(timeout);
- health.server.close();
- process.exit(0);
- };
- process.on("SIGTERM", shutdown);
- process.on("SIGINT", shutdown);
-
- heartbeatTimer = setInterval(async () => {
- for (const rid of allRuntimeIds) {
- try {
- await client.heartbeat(rid);
- } catch (e) {
- log.debug("Heartbeat failed", e);
- }
- }
- }, config.heartbeatInterval);
-
const activeTasks = new Set<string>();
const poll = async () => {
@@ -164,7 +134,33 @@ export async function startDaemon(
}
};
- pollTimer = setInterval(poll, config.pollInterval);
+ const heartbeatTimer = setInterval(async () => {
+ for (const rid of allRuntimeIds) {
+ try {
+ await client.heartbeat(rid);
+ } catch (e) {
+ log.debug("Heartbeat failed", e);
+ }
+ }
+ }, config.heartbeatInterval);
+ const pollTimer = setInterval(poll, config.pollInterval);
+
+ const shutdown = async () => {
+ log.info("Shutting down...");
+ clearInterval(heartbeatTimer);
+ clearInterval(pollTimer);
+ const timeout = setTimeout(() => process.exit(1), 5000);
+ try {
+ await client.deregister(allRuntimeIds);
+ } catch {
+ // best-effort deregister
+ }
+ clearTimeout(timeout);
+ health.server.close();
+ process.exit(0);
+ };
+ process.on("SIGTERM", shutdown);
+ process.on("SIGINT", shutdown);
await poll();
}
diff --git a/src/cli/daemon/health.ts b/src/cli/daemon/health.ts
index 3a2c40bc6..0926b506a 100644
--- a/src/cli/daemon/health.ts
+++ b/src/cli/daemon/health.ts
@@ -2,7 +2,7 @@ import { createServer, type Server, type IncomingMessage, type ServerResponse }
export function startHealthServer(port: number = 19514): Server {
const startTime = Date.now();
- let runtimeCount = 0;
+ const runtimeCount = 0;
const server = createServer((req: IncomingMessage, res: ServerResponse) => {
if (req.url === "/health") {
diff --git a/src/cli/eslint.config.mjs b/src/cli/eslint.config.mjs
new file mode 100644
index 000000000..8d67ca6ff
--- /dev/null
+++ b/src/cli/eslint.config.mjs
@@ -0,0 +1,16 @@
+import { defineConfig, globalIgnores } from "eslint/config";
+import tseslint from "typescript-eslint";
+
+const eslintConfig = defineConfig([
+ ...tseslint.configs.recommended,
+ globalIgnores(["dist/**"]),
+ {
+ files: ["**/*.test.ts"],
+ rules: {
+ "@typescript-eslint/no-explicit-any": "off",
+ "@typescript-eslint/no-unused-vars": "off",
+ },
+ },
+]);
+
+export default eslintConfig;
diff --git a/src/cli/lib/logger.test.ts b/src/cli/lib/logger.test.ts
index 2322bb159..542dffa31 100644
--- a/src/cli/lib/logger.test.ts
+++ b/src/cli/lib/logger.test.ts
@@ -1,9 +1,7 @@
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import { Logger } from "./logger.js";
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
let stdoutSpy: any;
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
let stderrSpy: any;
beforeEach(() => {
diff --git a/src/cli/package.json b/src/cli/package.json
index 8b920219b..a9d775233 100644
--- a/src/cli/package.json
+++ b/src/cli/package.json
@@ -6,7 +6,8 @@
"bin": { "alook": "./dist/index.js" },
"scripts": {
"build": "tsup src/index.ts --format esm --dts",
- "dev": "tsx src/index.ts"
+ "dev": "tsx src/index.ts",
+ "lint": "eslint"
},
"dependencies": {
"@alook/shared": "workspace:*",
@@ -14,8 +15,10 @@
"dotenv": "^16.0.0"
},
"devDependencies": {
+ "eslint": "^9.0.0",
"tsup": "^8.0.0",
"tsx": "^4.0.0",
- "typescript": "^5.0.0"
+ "typescript": "^5.0.0",
+ "typescript-eslint": "^8.0.0"
}
}