AI Code Sherlock
Documentation

AI Code Sherlock is a free, open-source desktop IDE assistant for automated code analysis, surgical patching, and autonomous AI workflow execution. This guide covers everything from installation to building complex multi-agent pipelines.

⬇ Installation

Requirements

🐍 Python
Python 3.11 or newer required. Install from python.org.
🖼 PyQt6
UI framework. Installed automatically via requirements.txt.
🌐 aiohttp
Async HTTP for AI API calls. Required for cloud models.
🦙 Ollama (optional)
For offline/local AI models. Install from ollama.ai.

Install Steps

git clone https://github.com/signupss/ai-code-sherlock.git cd ai-code-sherlock pip install -r requirements.txt python main.py
💡 Tip: For Ollama offline use, install it first and pull a model: ollama pull deepseek-coder-v2. No API key needed.

▶ First Run

📝 Code Editor

The code editor is the center panel. It supports syntax highlighting for 15+ languages, line numbers, and scroll-linked context compression for large files.

🤖 AI Chat

The right-center chat panel is your main interface to the AI. It has three tabs: Chat, Logs, and Context.

Chat Tab

Type a message and press Enter or click Send. The AI sees your open file and any context files you have added. You can ask it to fix bugs, explain code, generate new functions, or write tests.

Context Tab

Add extra files as read-only context — the AI sees them but never modifies them. Useful for config files, documentation, or reference code.

Consensus Mode

Enable Consensus in the toolbar to query multiple AI models simultaneously. The best patch is selected based on agreement between models. Ideal for critical fixes.

Sherlock Mode: Click the 🔍 button to run automated root-cause analysis. Sherlock reads error logs, traces the bug to its source, and generates a targeted patch — without you writing a single prompt.

🩹 Patches & SEARCH/REPLACE

Sherlock never rewrites entire files. It generates surgical SEARCH/REPLACE patches — only the exact blocks that need changing. The right panel shows pending patches with a diff view.

✅ Apply
Apply the patch to the file. Original is backed up in .sherlock_versions/.
❌ Reject
Discard the patch without changing the file.
👁 Preview
Open a full diff viewer showing exactly what changes.
⏮ Restore
Roll back to any previous version from the version history panel.

⚙️ Auto-Improve Pipeline

The pipeline runs a loop: generate patch → apply → run tests → if failed, analyze and re-patch. It continues until tests pass or the max iteration limit is reached.

8 Built-in Strategies

Each strategy tells the AI how to approach improvement:

🔄 Iterative Fix
Patch incrementally based on test output each round.
🏗 Architecture
Restructure the codebase before fixing bugs.
🧪 Test-First
Write tests first, then make them pass.
🤝 Consensus
Query multiple models and merge the best response.
🩹 Minimal Patch
Change as few lines as possible each iteration.
🗺 Trace
Follow error tracebacks to root cause before patching.
⚠ Infinite Loop Guard: If the pipeline detects the same error repeating, it automatically stops, rolls back the last patch, and re-analyzes from a clean state.

▶️ Script Runner

Run scripts in 15+ languages directly from the IDE. Output streams live to the Logs tab.

Supported Languages

🐍 Python 🟨 JavaScript 📘 TypeScript 💎 Ruby 🐘 PHP 🐹 Go 🌙 Lua 🔩 Perl 📊 R 🔬 Julia 🖥 Shell 📋 Batch 🔵 PowerShell

Interactive stdin

The script runner supports live stdin input. While a script is running, type into the stdin input box and press Enter to send input — no race conditions, no closed-pipe errors. Queue-based pumping ensures all input is delivered in order.

🧩 Visual Workflow Editor — Introduction

The Agent Constructor is a separate module that lets you build AI automation workflows visually. Connect nodes on an infinite canvas to create pipelines that combine AI agents, code execution, browser automation, and control flow logic.

Open it from the main toolbar or Ctrl+Shift+W. It opens as a new window alongside the IDE.

💡 Concept: A workflow is a graph of nodes (actions) connected by edges (transitions). Execution starts at the Project Start node and follows edges until a Good End or Bad End node.

🖼 Canvas & Navigation

Moving Around

ActionHow
Zoom in/outCtrl + scroll wheel
Pan horizontallyShift + scroll wheel
Pan freelyHold middle mouse button + drag
Select multiple nodesClick + drag rubber-band on empty canvas
Select single nodeLeft-click the node
Move node(s)Drag selected node(s)
Auto-scroll while draggingMove node near canvas edge — canvas scrolls automatically

Minimap

The minimap (bottom-right corner) shows a bird's-eye view of the entire workflow. Click anywhere on the minimap to jump to that location. The highlighted rectangle represents the current viewport.

📦 Node Types

Nodes are divided into three categories:

🧠 AI Agent Nodes

These nodes call an AI model to perform a task. Each has configurable model, system prompt, temperature, max tokens, retry count, and skills.

💻 Code Writer 🔍 Code Reviewer 🧪 Tester 🏗️ Planner 🎨 Image Gen 👁️ Image Analyst 📁 File Manager ▶️ Script Runner ✅ Verifier 🎯 Orchestrator 🩹 Patcher 🤖 Custom

⚙️ Snippet / Logic Nodes

These nodes execute deterministic logic without AI — control flow, data manipulation, I/O.

❓ If Condition
Branches flow based on a Python expression. Access variables via context["var"].
🔁 Loop
Repeats a set of nodes N times or until a condition is met.
🔀 Switch
Multi-branch based on a variable's value (like a switch/case).
📝 Variable Set
Write a value to the shared execution context.
🌐 HTTP Request
Make GET/POST/PUT/DELETE requests. Result stored in context.
⏳ Delay
Pause execution for N seconds.
📜 Code Snippet
Execute arbitrary Python code inline.
🟨 JS Snippet
Execute JavaScript via Node.js.
📄 File Operation
Read, write, copy, move, or delete files.
📁 Dir Operation
Create, list, copy, move, or delete directories.
✂️ Text Processing
Regex replace, split, trim, encode, spintax.
🔣 JSON/XML
Parse, query (JsonPath/XPath), and transform JSON or XML.

📌 Note Nodes

Notes and Project Start markers. Notes are visual-only and never executed. Project Start marks the workflow entry point.

🔗 Connections (Edges)

Connect two nodes by hovering over the source node's output port and dragging to the target node's input port. A bezier curve appears.

Edge Conditions

ConditionDescription
ALWAYSFollow this edge every time (default).
ON_SUCCESSFollow only if the previous node succeeded.
ON_FAILUREFollow only if the previous node failed — use for fallback/recovery paths.
ON_CONDITIONFollow if a custom Python expression evaluates to True.
Priority: When multiple edges leave the same node, higher-priority edges are evaluated first. Set priority in the edge properties panel.

Routing Modes

Each AI node has an Orchestration Mode setting:

⚙️ Node Settings

Double-click any node (or right-click → Properties) to open the settings panel. Key settings for AI nodes:

🧠 Model
Primary model. Optionally set separate vision, reasoning, and fast models — the engine picks the right one per task automatically.
📝 System Prompt
Custom system prompt merged with any assigned skills.
🔁 Retry Count
Number of retries on failure. Supports exponential backoff.
✅ Verification
Verify output via self-check, a second model, or a dedicated verifier agent before proceeding.
🔧 Auto-Improve
On failure, the engine rewrites the system prompt based on the error and retries.
🔴 Breakpoint
Pause execution at this node when running in debug mode.

🔧 Skills & Skill Registry

Skills are reusable capability definitions that inject instructions into an agent's system prompt. Assign multiple skills to one node — they are merged automatically.

Built-in Skills

💻 Code Generation 🔍 Code Review 🔧 Patching 🧪 Testing 🏗️ Architecture 🐛 Debugging 📝 Documentation 👁️ Image Analysis 📁 File Operations 📊 Data Analysis

Creating Custom Skills

Auto-Load Skills

Enable Auto-Load Skills on a node to have the engine use an AI model to automatically select the most relevant skills from the registry for that node's task description at runtime.

🌐 Browser Automation Nodes

The browser suite lets you control a web browser as part of a workflow — click, type, screenshot, and more.

🌐 Browser Launch
Start a browser instance. Configure profile, headless mode, proxy, and viewport size.
🖱 Browser Action
Perform an action: click, type text, navigate to URL, scroll, wait for element, extract text.
📸 Screenshot
Capture the current page. The image is stored in context for later use by Image Analyst nodes.
🖼 Click by Image
Find a UI element by template image matching and click it. Useful for complex or dynamic pages.
🌐🧠 Browser Agent
AI-powered browser agent that understands DOM structure. Given a task, it autonomously navigates and interacts with pages.
🪪 Profile Operation
Create, switch, import, or export browser profiles (cookies, localStorage, extensions).
🔴 Browser Close
Cleanly close the browser instance and release resources.
Planner Preprocessing: The Browser Agent node supports Planner Mode. When enabled, a Planner AI first breaks down the task into numbered subtasks, then the browser agent executes them one by one — reducing errors on complex workflows.

🚀 Running Workflows

🐛 Step-by-Step Debugger

The debugger lets you execute workflows one node at a time for testing and inspection.

📁 Projects

Each project consists of a workflow (.json) and a root folder. Projects can be saved, loaded, duplicated, and exported.

⚡ Multi-Threaded Execution

The Project Execution Manager lets you run multiple workflow projects simultaneously in separate threads.

🔢 Thread Modes
One Thread, Multi-Thread, or Thread-Per-Project. Configure in project settings.
🛑 Stop Conditions
Stop after N iterations, on first success, on first failure, or on manual stop.
⏱ Cooldown
Set a cooldown delay between iterations to avoid rate limits.
📊 Live Status
Project Dashboard shows each project's current state, iteration count, and last result.

📊 Project Dashboard

The dashboard displays all registered projects in a card grid. Each card shows:

⌨️ Keyboard Shortcuts

Global

ShortcutAction
Ctrl+ZUndo
Ctrl+Shift+Z / Ctrl+YRedo
Ctrl+SSave
Ctrl+CCopy selected node(s)
Ctrl+XCut selected node(s)
Ctrl+VPaste node(s)
DeleteDelete selected node(s) / edge
Ctrl+ASelect all nodes
EscapeDeselect / cancel current action

Canvas Navigation

ShortcutAction
Ctrl + scrollZoom in / out
Shift + scrollScroll horizontally
Middle mouse button + dragPan canvas freely
Ctrl+0Reset zoom to 100%
Ctrl+Shift+FFit all nodes in view

Execution

ShortcutAction
F5Run workflow
F6Debug (step mode)
F10Step one node (in debug mode)
F9Toggle breakpoint on selected node
Shift+F5Stop execution

🧠 AI Model Configuration

Add models in Settings → Models. Each model definition includes:

💡 Multi-model tip: In Agent Constructor node settings, you can set different models for different task types. The engine automatically picks the right model — vision tasks use the vision model, complex reasoning uses the reasoning model, simple tasks use the fast model.

❓ FAQ

Does it work offline?

Yes. Install Ollama and pull a local model. Set the base URL to http://localhost:11434 in Settings → Models. No internet or API key required.

Can I use multiple AI providers simultaneously?

Yes. Define multiple model entries in Settings. Assign different models to different nodes in the Agent Constructor. Use Consensus Mode in the IDE to query several models at once.

Where are my patches and backups stored?

All versions are stored in .sherlock_versions/ inside your project folder. Access them via History → Version History.

How do I add a model that uses OpenAI-compatible API?

In Settings → Models, select source type "OpenAI Compatible", enter the base URL (e.g. https://api.groq.com/openai/v1), and your API key. Enter the model name as provided by the API.

The AI keeps making the same mistake. What do I do?

Open Error Map (Tools → Error Map). Add the error pattern and the correct fix. The AI will reference the Error Map on future runs and avoid repeating confirmed mistakes.

My workflow has a cycle — is that supported?

Yes. Intentional cycles (e.g. ScriptRunner → Patcher → ScriptRunner) are supported and useful for self-healing loops. The runtime engine does not block cycles — only the Infinite Loop Guard in the pipeline will catch unintentional infinite loops.

How do I share a workflow with someone?

Save the workflow (Ctrl+S) and share the resulting .json file. The recipient opens it in their Agent Constructor via File → Open Workflow.