mirror of
https://github.com/wassname/pi-lgtm.git
synced 2026-06-27 17:01:35 +08:00
linter fixes
This commit is contained in:
+7
-7
@@ -14,15 +14,15 @@
|
||||
* /tasks — Interactive task management menu
|
||||
*/
|
||||
|
||||
import type { ExtensionAPI, ExtensionContext, ExtensionCommandContext } from "@mariozechner/pi-coding-agent";
|
||||
import { Type } from "@sinclair/typebox";
|
||||
import { TaskStore } from "./task-store.js";
|
||||
import { ProcessTracker } from "./process-tracker.js";
|
||||
import { TaskWidget, type UICtx } from "./ui/task-widget.js";
|
||||
import { loadTasksConfig } from "./tasks-config.js";
|
||||
import { openSettingsMenu } from "./ui/settings-menu.js";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { join, resolve } from "node:path";
|
||||
import type { ExtensionAPI, ExtensionCommandContext, ExtensionContext } from "@mariozechner/pi-coding-agent";
|
||||
import { Type } from "@sinclair/typebox";
|
||||
import { ProcessTracker } from "./process-tracker.js";
|
||||
import { TaskStore } from "./task-store.js";
|
||||
import { loadTasksConfig } from "./tasks-config.js";
|
||||
import { openSettingsMenu } from "./ui/settings-menu.js";
|
||||
import { TaskWidget, type UICtx } from "./ui/task-widget.js";
|
||||
|
||||
// ---- Debug ----
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ export class ProcessTracker {
|
||||
});
|
||||
|
||||
// Handle process exit
|
||||
proc.on("close", (code, signal) => {
|
||||
proc.on("close", (code, _signal) => {
|
||||
if (bp.status === "running") {
|
||||
bp.status = code === 0 ? "completed" : "error";
|
||||
}
|
||||
|
||||
+2
-2
@@ -5,9 +5,9 @@
|
||||
* Shared (PI_TASK_LIST_ID set): ~/.pi/tasks/<listId>.json with file locking.
|
||||
*/
|
||||
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync, renameSync } from "node:fs";
|
||||
import { join, dirname, isAbsolute } from "node:path";
|
||||
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { dirname, isAbsolute, join } from "node:path";
|
||||
import type { Task, TaskStatus, TaskStoreData } from "./types.js";
|
||||
|
||||
const TASKS_DIR = join(homedir(), ".pi", "tasks");
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
// <cwd>/.pi/tasks-config.json — persists extension settings across sessions
|
||||
|
||||
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
||||
import { join, dirname } from "node:path";
|
||||
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { dirname, join } from "node:path";
|
||||
|
||||
export interface TasksConfig {
|
||||
taskScope?: "memory" | "session" | "project"; // default: "session"
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
* own settings panel style.
|
||||
*/
|
||||
|
||||
import { SettingsList, Container, Text, Spacer, type SettingItem } from "@mariozechner/pi-tui";
|
||||
import { getSettingsListTheme } from "@mariozechner/pi-coding-agent";
|
||||
import { Container, type SettingItem, SettingsList, Spacer, Text } from "@mariozechner/pi-tui";
|
||||
import { saveTasksConfig, type TasksConfig } from "../tasks-config.js";
|
||||
|
||||
// ── Types ───────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, beforeEach } from "vitest";
|
||||
import { ProcessTracker } from "../src/process-tracker.js";
|
||||
import { spawn } from "node:child_process";
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import { ProcessTracker } from "../src/process-tracker.js";
|
||||
|
||||
describe("ProcessTracker", () => {
|
||||
let tracker: ProcessTracker;
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
* auto-cascade, and widget agent ID display.
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
||||
import { TaskStore } from "../src/task-store.js";
|
||||
import { TaskWidget, type UICtx, type Theme } from "../src/ui/task-widget.js";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import initExtension from "../src/index.js";
|
||||
import { TaskStore } from "../src/task-store.js";
|
||||
import { TaskWidget, type Theme, type UICtx } from "../src/ui/task-widget.js";
|
||||
|
||||
// Force in-memory task store for all integration tests — prevents file-backed
|
||||
// store from loading stale tasks across test instances.
|
||||
@@ -15,6 +15,11 @@ afterEach(() => { delete process.env.PI_TASKS; });
|
||||
|
||||
// ---- Mock pi ----
|
||||
|
||||
type MockEventBus = {
|
||||
on: (channel: string, handler: (data: unknown) => void) => () => void;
|
||||
emit: (channel: string, data: unknown) => void;
|
||||
};
|
||||
|
||||
/** Minimal mock of ExtensionAPI with events, tool capture, and event hooks. */
|
||||
function mockPi() {
|
||||
const tools = new Map<string, any>();
|
||||
@@ -84,7 +89,7 @@ function mockCtx() {
|
||||
// ---- Mock subagents extension (RPC responders) ----
|
||||
|
||||
/** Simulates the @tintinweb/pi-subagents extension: responds to ping + spawn RPCs and emits ready. */
|
||||
function installSubagentsMock(pi: { events: { on: Function; emit: Function } }, opts?: { spawnError?: string }) {
|
||||
function installSubagentsMock(pi: { events: MockEventBus }, opts?: { spawnError?: string }) {
|
||||
let idCounter = 0;
|
||||
const spawned: Array<{ id: string; type: string; prompt: string; options: any }> = [];
|
||||
const stopped: string[] = [];
|
||||
@@ -712,7 +717,7 @@ describe("RPC protocol correctness", () => {
|
||||
});
|
||||
|
||||
/** Install a ping-only mock with a specific protocol version (or no version for v1). */
|
||||
function installVersionedMock(pi: { events: { on: Function; emit: Function } }, version?: number) {
|
||||
function installVersionedMock(pi: { events: MockEventBus }, version?: number) {
|
||||
const unsubPing = pi.events.on("subagents:rpc:ping", (data: unknown) => {
|
||||
const { requestId } = data as { requestId: string };
|
||||
if (version !== undefined) {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
||||
import { TaskStore } from "../src/task-store.js";
|
||||
import { existsSync, rmSync, mkdirSync, readFileSync } from "node:fs";
|
||||
import { readFileSync, rmSync } from "node:fs";
|
||||
import { homedir, tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { homedir } from "node:os";
|
||||
import { tmpdir } from "node:os";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { TaskStore } from "../src/task-store.js";
|
||||
|
||||
describe("TaskStore (in-memory)", () => {
|
||||
let store: TaskStore;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
||||
import { TaskWidget, type UICtx, type Theme, type TaskMetrics } from "../src/ui/task-widget.js";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { TaskStore } from "../src/task-store.js";
|
||||
import { TaskWidget, type Theme, type UICtx } from "../src/ui/task-widget.js";
|
||||
|
||||
/** Create a mock theme that returns raw text (no ANSI escapes). */
|
||||
function mockTheme(): Theme {
|
||||
|
||||
Reference in New Issue
Block a user