Automation

SovereignLink

A desktop command system that matches speed to complexity - instant cache lookups for known tasks, local LLM parsing for natural language, and multi-model research pipelines for anything harder.

Python Ollama SQLite Textual TUI Watchdog Windows Service

In Plain English

SovereignLink is a smart command launcher that lets you type what you want in plain English. Simple things like "open Discord" happen instantly from a cache (a stored memory of previous commands so it does not need to think twice). Anything more complex gets routed to a local language model (an AI running on your own computer, not in the cloud) that figures out what you meant and runs it. It also watches your Obsidian (a note-taking app) notes for special checkboxes and automatically carries out the tasks you write there.

Problem

There is a fundamental mismatch in every desktop command system: the tool is either fast and dumb, or smart and slow. Traditional app launchers like Flow Launcher give you sub-second response times, but they choke on anything beyond "open Notepad." You have to memorize exact application names, hunt through start menus, or maintain brittle keyboard shortcut muscle memory. The moment you want something that requires even basic reasoning - "set up my coding environment" or "find that PDF I downloaded last week" - you are on your own.

On the other end, AI assistants can understand natural language beautifully, but they pay for that understanding with latency. Sending "open Discord" to a language model and waiting two seconds for it to figure out you want to launch an application is absurd when a simple cache lookup would resolve it in 100 milliseconds. Every command pays the same overhead regardless of difficulty, which means you are perpetually waiting for the AI to do work it does not need to do.

SovereignLink solves this by refusing to pick a side. It implements a three-tier routing system that classifies each command by complexity before choosing how to handle it. Known commands hit a SQLite cache and execute in under 500 milliseconds with zero LLM involvement. Natural language requests get parsed by a fast 7B model in under two seconds. Complex research or multi-step tasks engage reasoning models that take up to ten seconds but deliver real depth. The system gets smarter over time: commands that prove reliable get promoted into the instant cache automatically, so the more you use it, the faster it gets.

Architecture

INPUT SOURCES Hotkey Daemon Win+Space global hotkey System tray integration TUI Popup Textual fuzzy-match input Vault Watcher /do /research /browse sovereign_service.py Auto-restart, event log BRAIN (Classification & Routing) Router classify_tier(command) pipeline Stats: tier hits, cache rate, timing 5-source classification waterfall Tier 1: Cached <500ms SQLite promotion cache lookup actions.json exact match No LLM, pure data retrieval Tier 2: Smart Parse <2s Rule-based intent matching (fast) LLM fallback: qwen2.5:7b parse Fuzzy action name resolution Tier 3: Research <10s Vision + chain-of-thought reasoning Multi-source web extraction Contradiction detection & synthesis Intent Parser 6 intent types Promoter 3+ uses, 80%+ EXECUTION LAYER Launcher Subprocess, Steam Batch files, aliases Timing & error track Chain Executor Multi-step workflows if/or/always logic 10 built-in chains Researcher Planning + extraction Cross-ref + synthesis Vision System Screenshot analysis UI element detection LOCAL LLMs (Ollama) Fast qwen:7b Reason deepseek Synth qwen:32b VL qwen-vl PERSISTENCE & CONFIG command_cache.db Usage counts, success rate, aliases workflows.json 10 chain defs actions.json App registry SQLite schema: commands, aliases, stats LEARNING LOOP Promotion Engine 3+ uses, >80% success Demotion Engine 3+ fails, <50% success Alias Learner User corrections Stale Cleanup 30+ days unused instant
Scroll to explore diagram

Commands flow from three input sources into a five-stage classification waterfall. The router checks the promotion cache, actions registry, keyword patterns, rule-based matching, and finally LLM parsing, dispatching to the cheapest tier that can handle the request. The learning loop tracks every execution outcome and gradually promotes reliable commands into the instant cache while demoting failures.

Features

3-Tier Speed System

500ms / 2s / 10s latency targets

The core insight is that most commands do not need AI at all. Tier 1 serves cached commands and exact action matches with no LLM call, resolving in under 500 milliseconds through pure SQLite lookup and subprocess launch. Tier 2 handles natural language through a two-stage approach: a rule-based matcher tries common patterns first, and only falls back to the fast 7B model when pattern confidence drops below 80%. Tier 3 engages reasoning models for research tasks, vision analysis, and multi-step planning where latency is an acceptable trade for depth. Each command is classified through a five-source waterfall before execution begins, ensuring the cheapest adequate path is always chosen.

Self-Learning Promoter

Auto-promote at 3+ uses, 80%+ success

The promoter maintains a SQLite database with a commands table tracking usage count, success count, failure count, last-used timestamp, and promotion timestamp for every command it has seen. When a command accumulates three or more uses with a success rate above 80%, it gets automatically promoted into the Tier 1 cache, meaning it executes instantly next time with zero LLM overhead. Commands with three or more failures and a success rate below 50% get demoted and removed. User corrections generate aliases stored in a separate table, so typing "dst" automatically resolves to "launch dst server." Entries unused for 30 or more days get cleaned up to keep the cache lean.

Multi-Step Workflows

10 built-in chains with conditional logic

Predefined workflow chains like "morning routine," "coding setup," and "gaming mode" execute multiple steps in sequence. Each step in a chain can carry an if, or, or always modifier that controls execution flow. The chain executor handles failures gracefully by checking step conditions before proceeding, so a failed optional step does not abort the entire workflow. Chains are defined declaratively in workflows.json, making it straightforward to add new multi-step routines without touching Python code. The executor tracks per-step timing and status for diagnostic output.

Obsidian Vault Integration

File watcher with auto-execute and result injection

A Watchdog-based file system watcher monitors the Obsidian vault for markdown checkboxes prefixed with /do, /research, or /browse. When a new task is detected, SovereignLink marks it as executing with a status indicator, runs it through the appropriate tier, and writes the result back into the note as a collapsible callout block. Research tasks support three depth levels - light (2 queries, 15s timeout), deep (6 queries, 60s), and thorough (10 queries, 120s with cross-referencing) - triggered by syntax variations in the checkbox text. A processing lock prevents duplicate execution, and a debounce delay waits for the file to settle before parsing.

How It Works

01

Command Input

The user presses Win+Space to summon a Textual TUI popup with fuzzy-matching search. As they type, the popup shows live results from the actions registry and command cache, ranked by match confidence and usage frequency. The TUI renders in a lightweight terminal overlay so it feels native rather than like a web browser pretending to be a desktop app. Alternatively, tasks can be written as markdown checkboxes in any Obsidian note, which the Watchdog file watcher picks up asynchronously without the user needing to switch context.

02

Five-Stage Tier Classification

The router classifies the command through a strict waterfall. First, it checks the SQLite promotion cache for a Tier 1 hit. Second, it checks the actions.json registry for an exact match. Third, it scans for vision or research keywords that would push the command straight to Tier 3. Fourth, a rule-based intent matcher tries to extract one of six intent types (LAUNCH, CLICK, TYPE, BROWSE, RESEARCH, CHAIN) from common patterns. Fifth, if nothing matched with sufficient confidence, the command goes to the LLM intent parser for natural language understanding. At every stage, the first confident match short-circuits the rest of the pipeline.

03

Intent Parsing and Resolution

For Tier 2 commands that reach the LLM, the intent parser sends the input to qwen2.5:7b via Ollama and receives a structured intent object containing the action type, target, and any parameters. Fuzzy matching then resolves approximate action names against the registry, so "open discrod" still finds Discord despite the typo. For Tier 3 research tasks, the system engages a full pipeline: a planning model (deepseek-r1) generates search queries, multiple sources are scraped and extracted, a synthesis model (qwen2.5:32b) combines findings, and a contradiction detector flags inconsistencies across sources.

04

Execution

The launcher handles the actual work. For run-type actions, it builds the appropriate command: plain subprocess for executables, "cmd /c start" for Steam protocol URLs, "cmd /c" prefix for batch files, and direct invocation for known system commands. Each execution is wrapped with timing instrumentation and error tracking via the ExecutionResult dataclass, which captures status, message, execution time in milliseconds, and any error details. The chain executor handles multi-step workflows by iterating through step definitions and evaluating conditional modifiers before each step.

05

Learning and Adaptation

After every execution, the promoter records the outcome against the command's entry in the SQLite database. The promotion engine checks if the command has crossed the three-use, 80%-success threshold for cache elevation. The demotion engine checks for repeated failures. The alias learner stores any user corrections ("I meant X when I said Y") as permanent shortcuts. And the stale cleanup process removes entries unused for over 30 days to prevent the cache from growing unbounded. Over days of use, the system converges toward near-instant execution for all of your habitual commands while keeping full natural language capability for anything new.

Tech Stack

Runtime

Python 3.11+ with async support, runs as a Windows service with automatic restart and event logging

Inference

Ollama with tiered model routing: qwen2.5:7b for fast parsing, deepseek-r1:32b for reasoning, qwen2.5:32b for synthesis, qwen2.5vl:7b for vision

Interface

Textual TUI for the command popup, pystray for the system tray icon, global hotkeys via the keyboard library

Cache & Persistence

SQLite database with commands and aliases tables for promotion tracking, usage statistics, and shortcut resolution

File Watching

Watchdog monitors the Obsidian vault for task checkboxes, with debounce delay and processing locks to prevent duplicates

Configuration

Declarative workflows.json for chain definitions, actions.json for the app registry, and sovereign_ctl.py CLI for management