diff --git a/packages/coding-agent/examples/hooks/plan-mode.ts b/packages/coding-agent/examples/hooks/plan-mode.ts index e1d5961f..b05a8646 100644 --- a/packages/coding-agent/examples/hooks/plan-mode.ts +++ b/packages/coding-agent/examples/hooks/plan-mode.ts @@ -147,7 +147,10 @@ function cleanStepText(text: string): string { // Remove markdown code .replace(/`([^`]+)`/g, "$1") // Remove leading action words that are redundant - .replace(/^(Use|Run|Execute|Create|Write|Read|Check|Verify|Update|Modify|Add|Remove|Delete|Install)\s+(the\s+)?/i, "") + .replace( + /^(Use|Run|Execute|Create|Write|Read|Check|Verify|Update|Modify|Add|Remove|Delete|Install)\s+(the\s+)?/i, + "", + ) // Clean up extra whitespace .replace(/\s+/g, " ") .trim(); @@ -159,7 +162,7 @@ function cleanStepText(text: string): string { // Truncate if too long if (cleaned.length > 50) { - cleaned = cleaned.slice(0, 47) + "..."; + cleaned = `${cleaned.slice(0, 47)}...`; } return cleaned; @@ -203,8 +206,6 @@ function extractTodoItems(message: string): TodoItem[] { return items; } - - export default function planModeHook(pi: HookAPI) { let planModeEnabled = false; let toolsCalledThisTurn = false; @@ -329,19 +330,16 @@ export default function planModeHook(pi: HookAPI) { // Filter out stale plan mode context messages from LLM context // This ensures the agent only sees the CURRENT state (plan mode on/off) pi.on("context", async (event) => { - // Only filter when NOT in plan mode (i.e., when executing) if (planModeEnabled) { return; } // Remove any previous plan-mode-context messages - const beforeCount = event.messages.length; + const _beforeCount = event.messages.length; const filtered = event.messages.filter((m) => { if (m.role === "user" && Array.isArray(m.content)) { - const hasOldContext = m.content.some( - (c) => c.type === "text" && c.text.includes("[PLAN MODE ACTIVE]"), - ); + const hasOldContext = m.content.some((c) => c.type === "text" && c.text.includes("[PLAN MODE ACTIVE]")); if (hasOldContext) { return false; } diff --git a/packages/coding-agent/src/core/hooks/loader.ts b/packages/coding-agent/src/core/hooks/loader.ts index 4411021a..6e66b47c 100644 --- a/packages/coding-agent/src/core/hooks/loader.ts +++ b/packages/coding-agent/src/core/hooks/loader.ts @@ -12,7 +12,14 @@ import { getAgentDir } from "../../config.js"; import type { HookMessage } from "../messages.js"; import type { SessionManager } from "../session-manager.js"; import { execCommand } from "./runner.js"; -import type { ExecOptions, HookAPI, HookContext, HookFactory, HookMessageRenderer, RegisteredCommand } from "./types.js"; +import type { + ExecOptions, + HookAPI, + HookContext, + HookFactory, + HookMessageRenderer, + RegisteredCommand, +} from "./types.js"; // Create require function to resolve module paths at runtime const require = createRequire(import.meta.url); diff --git a/packages/coding-agent/src/core/hooks/types.ts b/packages/coding-agent/src/core/hooks/types.ts index 6305872f..0b59ce67 100644 --- a/packages/coding-agent/src/core/hooks/types.ts +++ b/packages/coding-agent/src/core/hooks/types.ts @@ -6,7 +6,7 @@ */ import type { AgentMessage } from "@mariozechner/pi-agent-core"; -import type { ImageContent, Message, Model, TextContent, ToolResultMessage } from "@mariozechner/pi-ai"; +import type { ImageContent, Model, TextContent, ToolResultMessage } from "@mariozechner/pi-ai"; import type { Component, TUI } from "@mariozechner/pi-tui"; import type { Theme } from "../../modes/interactive/theme/theme.js"; import type { CompactionPreparation, CompactionResult } from "../compaction/index.js";