Neural Inverse is Open Source →
GuidesPower Mode
GuidesOpen Source ContributingPower Mode

Power Mode

Power Mode is an autonomous coding agent that opens in its own window (Cmd+Alt+P). It plans, edits files, runs terminal commands, and iterates until the task is done.


How It Works

Power Mode uses native tool calling (MCP protocol) with the LLM. The agent loop:

  1. User gives an instruction
  2. LLM reasons about the task
  3. LLM calls tools (read files, edit code, run commands, search, etc.)
  4. Results return to the LLM
  5. LLM decides: done, or call more tools
  6. Repeat until task is complete

The key principle: action, not words — the agent executes immediately rather than explaining what it would do.


Built-in Tools

CategoryToolsWhat they do
Filesystembash, read, write, editRun commands, read/write/edit files
Searchglob, grep, listFind files by pattern, search content, list directories
Sub-agentsworkflow toolsSpawn child agents for parallel tasks
Modernisationmigration toolsAccess active modernisation session data
Knowledge BaseKB toolsQuery the modernisation knowledge base
Autonomyexecution toolsControl autonomous execution flow

Tools are registered via IVoidInternalToolService and shared across Power Mode and sidebar chat.


System Prompt

The system prompt (powerMode/browser/session/systemPrompt.ts) dynamically includes:

  • Current working directory and git status
  • Platform info (OS, shell)
  • Active modernisation session context (if running)
  • Active firmware session context (if running)
  • Custom instructions from AGENTS.md in the workspace root
  • BYOLLM attribution rules for git commits

Agent Configuration

Users can configure agent behavior via .neuralinverseagent JSON file at workspace root:

{
  "maxIterations": 50,
  "autoApproval": {
    "fileEdits": true,
    "terminalCommands": ["npm test", "npm run build"]
  },
  "blockedCommands": ["rm -rf", "git push --force"],
  "subAgents": {
    "maxConcurrent": 3
  }
}

Sub-Agents

Power Mode can spawn sub-agents for parallel work:

RoleCapabilitiesUse case
ExplorerRead-only filesystem accessResearch, find files, understand code
EditorScoped file editsMake changes to specific files
VerifierRun tests and lintValidate changes before completing

Sub-agents run concurrently (up to maxConcurrentSubAgents) with their own chat threads and scoped tool whitelists.


Session Compaction

Power Mode supports 200-step sessions. To keep within context limits, the compaction engine runs automatically when token count exceeds 100K.

How Compaction Works

4 progressive levels (cheapest first, stop when under target):

Level 1: Truncate tool outputs

  • Tool outputs > 8K tokens → first 200 + last 100 tokens kept
  • Inserts [...N tokens truncated...] marker
  • Skips messages in the preserved recent window

Level 2: Drop reasoning parts

  • Removes internal chain-of-thought from old messages
  • Preserves all tool calls and results

Level 3: Collapse redundant sequences

  • 3+ consecutive read/list calls to same directory → one-line summary
  • Zero-result grep calls → collapsed to "Searched for X — no results"

Level 4: LLM summarization

  • Groups messages into step ranges (step-start to step-finish boundaries)
  • LLM generates structured summary: goal, decisions, file changes, errors
  • Heuristic fallback if LLM unavailable
  • Summary injects as single message replacing compacted range

Preservation Rules

Always kept verbatim:

  • First user message (original goal)
  • Last 6 messages (recent context)
  • Messages with unresolved errors
  • Messages referencing currently active files

Implementation

FilePurpose
compaction/tokenEstimator.tsBrowser-safe token counting (prose/code/JSON detection)
compaction/compactionStrategy.tsDecides when/what/how to compact
compaction/conversationSummarizer.tsLLM + heuristic summarization
compaction/compactionService.tsOrchestrates estimation + strategy + summarization
powerModeProcessor.tsPre-step budget check, triggers compaction

Compaction is non-fatal — failures never crash the agent loop. Sessions continue with full history if compaction fails.


UI

Power Mode opens as a dedicated auxiliary window with:

  • Dark theme terminal-style interface
  • > prompt for input
  • Tool call rendering (amber #e0a84e for tool names)
  • Streaming output with real-time progress
  • Abort button to stop execution mid-flow

Contributing

Key files:

  • powerMode/browser/powerModePart.ts — window UI
  • powerMode/browser/tools/allTools.ts — tool registry
  • powerMode/browser/session/systemPrompt.ts — prompt construction
  • powerMode/browser/powerBusService.ts — real-time communication bus
  • powerMode/browser/session/compaction/ — session compaction engine

Was this page helpful?