<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Доктор к</title>
    <description>The latest articles on DEV Community by Доктор к (@doctorgth).</description>
    <link>https://dev.to/doctorgth</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4265913%2F94ba4edb-2f7d-40b1-a4a3-f6fb58e6f421.png</url>
      <title>DEV Community: Доктор к</title>
      <link>https://dev.to/doctorgth</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/doctorgth"/>
    <language>en</language>
    <item>
      <title>Stop Burning API Tokens: Turn Browser &amp; Local LLMs into a Safe Coding Agent with FS-XML</title>
      <dc:creator>Доктор к</dc:creator>
      <pubDate>Thu, 26 Nov 2026 07:50:46 +0000</pubDate>
      <link>https://dev.to/doctorgth/stop-burning-api-tokens-turn-browser-local-llms-into-a-safe-coding-agent-with-fs-xml-2kmg</link>
      <guid>https://dev.to/doctorgth/stop-burning-api-tokens-turn-browser-local-llms-into-a-safe-coding-agent-with-fs-xml-2kmg</guid>
      <description>&lt;p&gt;Most developers already use LLMs in a regular browser every day: Gemini (via Google AI Studio), Claude, ChatGPT, DeepSeek, or Qwen. They offer massive context windows that are often free or billed by message count rather than per-token input/output. The only catch? &lt;strong&gt;Browser chats can't touch your local disk.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On the flip side, if you switch to autonomous IDE agents (Cursor, Cline, Aider, etc.), three other headaches quickly pop up:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Skyrocketing API Token Bills.&lt;/strong&gt; The agent decides what to read, re-reads half the repo on every step, and enters retry loops when a patch fails. One heavy refactoring evening can burn a noticeable budget.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blind Edits.&lt;/strong&gt; An agent can go off for 25 iterations, burn a million tokens, and head in the completely wrong direction—or fix a single button while silently rewriting a neighboring module.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IDE Lock-in.&lt;/strong&gt; If you’ve spent years mastering PyCharm, JetBrains tools, or Neovim, you shouldn't have to abandon your workflow for a VS Code fork just to get an AI assistant.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To solve this for my own workflow, I built &lt;strong&gt;FS-XML Interpreter&lt;/strong&gt;—a lightweight, open-source desktop orchestrator that turns any &lt;strong&gt;browser chat&lt;/strong&gt; (or local LLM) into a safe, semi-autonomous agent &lt;em&gt;with a human in the loop&lt;/em&gt;, running smoothly right alongside your favorite IDE.&lt;/p&gt;

&lt;h3&gt;
  
  
  What FS-XML Is (and What It Isn't)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It is &lt;strong&gt;not&lt;/strong&gt; an API proxy, an autonomous bash/shell agent, or a replacement for heavy agentic IDEs when you want full 40-step autonomy.&lt;/li&gt;
&lt;li&gt;It &lt;strong&gt;is&lt;/strong&gt; a local bridge between an LLM chat and your disk: you explicitly define &lt;code&gt;Writable&lt;/code&gt; / &lt;code&gt;Read-Only&lt;/code&gt; / &lt;code&gt;Unmarked&lt;/code&gt; file permissions, generate a clean context dump, and apply XML patches from the model's response in 1 click through a sandbox with rollbacks and snapshots.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ Your Project ] ──&amp;gt; (W / RO Permissions) ──&amp;gt; [ context_dump.txt ]
                                                       │
                                                       ▼
[ Browser / Local LLM ] ──&amp;gt; dump + task ──&amp;gt; [ Model XML Response ]
                                                       │
                                                       ▼
(Apply in 1 Click) ──────────────────────&amp;gt; [ Human Verification ]
      │
      ├──&amp;gt; Broke something? ──&amp;gt; [ File Rollback / Snapshot ]
      └──&amp;gt; Patch failed?    ──&amp;gt; [ 1-Click Copy Error + Actual File ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fffiay2wg7lou48rwfle6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fffiay2wg7lou48rwfle6.png" alt="UI Screenshot" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Why Custom FS-XML Tags Instead of &lt;code&gt;unified diff&lt;/code&gt; or JSON?
&lt;/h3&gt;

&lt;p&gt;Every engineer asks the same fair question: &lt;em&gt;Why invent custom XML tags when &lt;code&gt;unified diff&lt;/code&gt; and &lt;code&gt;git apply&lt;/code&gt; already exist?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The answer comes down to a well-known LLM quirk: &lt;strong&gt;models are terrible at counting line numbers.&lt;/strong&gt; (This is heavily documented by teams like Aider and Cline). When a model makes three edits in a single file via &lt;code&gt;@@ -42,7 +42,9 @@&lt;/code&gt;, the second and third hunks suffer from &lt;em&gt;line-number drift&lt;/em&gt;, and &lt;code&gt;git apply&lt;/code&gt; simply fails.&lt;/p&gt;

&lt;p&gt;Compare a broken classic diff:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;--- a/src/auth/session.py&lt;/span&gt;
&lt;span class="gi"&gt;+++ b/src/auth/session.py&lt;/span&gt;
&lt;span class="gu"&gt;@@ -18,4 +18,4 @@ # &amp;lt;- model missed by 3 lines, patch rejected&lt;/span&gt;
 def is_expired(ts: int) -&amp;gt; bool:
&lt;span class="gd"&gt;-    return time.time() &amp;gt; ts&lt;/span&gt;
&lt;span class="gi"&gt;+    return time.time() &amp;gt;= ts&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the content-addressed &lt;strong&gt;FS-XML&lt;/strong&gt; format:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;fs_edit&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"src/auth/session.py"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;fs_search&amp;gt;&lt;/span&gt;
def is_expired(ts: int) -&amp;gt; bool:
    return time.time() &amp;gt; ts
&lt;span class="nt"&gt;&amp;lt;/fs_search&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;fs_replace&amp;gt;&lt;/span&gt;
def is_expired(ts: int) -&amp;gt; bool:
    return time.time() &amp;gt;= ts
&lt;span class="nt"&gt;&amp;lt;/fs_replace&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/fs_edit&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why not JSON tool calls?&lt;/strong&gt; Browser chats don't run your local tool-calling runtime—they output Markdown text. JSON inside Markdown breaks constantly due to &lt;code&gt;\n&lt;/code&gt; escaping, nested quotes in code, and conversational fluff around the block. XML tags are human-readable in chat and trivial for a dedicated parser to extract.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Won't the XML parser break on HTML / Vue / JSX?&lt;/strong&gt; FS-XML's own frontend is built in Vue 3. The &lt;code&gt;fs_&lt;/code&gt; prefix (&lt;code&gt;&amp;lt;fs_create&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;fs_edit&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;fs_search&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;fs_replace&amp;gt;&lt;/code&gt;) is unique and doesn't collide with standard markup.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Money, Modularity, and Local Models
&lt;/h3&gt;

&lt;p&gt;Even if you already pay $20/mo for Claude Pro or ChatGPT Plus, flat-rate web chats count messages rather than megabytes of re-read context. And if you run &lt;strong&gt;local models&lt;/strong&gt; (via Ollama, vLLM, or LM Studio) or free tiers like Google AI Studio, context hygiene is critical: smaller models hallucinate drastically less when fed 3 relevant files instead of an entire repository.&lt;/p&gt;

&lt;p&gt;By using the &lt;strong&gt;Black-Box Principle&lt;/strong&gt;, once a module is finished and tested, you mark its implementation as &lt;code&gt;Unmarked&lt;/code&gt; and keep only its interface/contract file as &lt;code&gt;Read-Only&lt;/code&gt;. The model can build new features around it without wasting context or physically having permission to break working code.&lt;/p&gt;




&lt;h3&gt;
  
  
  Under the Hood: Architecture &amp;amp; 5 Engineering Pitfalls
&lt;/h3&gt;

&lt;p&gt;The app is split into three clean layers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;core/&lt;/code&gt;&lt;/strong&gt; — Autonomous engine (&lt;code&gt;CoreEngine&lt;/code&gt; parser, &lt;code&gt;CommandRegistry&lt;/code&gt;, &lt;code&gt;Sandbox&lt;/code&gt;, and handlers).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;server/&lt;/code&gt;&lt;/strong&gt; — FastAPI + SQLite in WAL mode (projects, profiles, file permissions, execution history, and snapshots).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;frontend/&lt;/code&gt; + &lt;code&gt;desktop_app.py&lt;/code&gt;&lt;/strong&gt; — Vue 3 + TypeScript + TailwindCSS rendered in a native PyWebView window (plus a lightweight C# launcher &lt;code&gt;FS-XML.exe&lt;/code&gt; for Windows).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are 5 real-world edge cases I had to solve in production:&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Parser Collisions: When the Code Contains &lt;code&gt;&amp;lt;/fs_edit&amp;gt;&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;When I started using FS-XML to develop FS-XML itself, a Python file literally contained &lt;code&gt;closing = "&amp;lt;/fs_edit&amp;gt;"&lt;/code&gt;. A naive regex parser happily terminated the command right in the middle of the file.&lt;br&gt;
In &lt;code&gt;core/engine.py&lt;/code&gt;, this is handled with three layers of protection: skipping narrative mentions without a &lt;code&gt;path&lt;/code&gt; attribute, ignoring tags wrapped in string literal quotes (&lt;code&gt;"..."&lt;/code&gt; or &lt;code&gt;'...'&lt;/code&gt;), and a two-pass depth-aware scanner.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nd"&gt;@staticmethod&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_is_quoted_literal_tag&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw_text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw_text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;prev_ch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;raw_text&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;next_ch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;raw_text&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;prev_ch&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'"'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"'"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;next_ch&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;prev_ch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. Trailing Whitespace, Empty Search Blocks, and CRLF/LF Pain
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Whitespace &amp;amp; &lt;code&gt;\v&lt;/code&gt; / &lt;code&gt;\f&lt;/code&gt;:&lt;/strong&gt; If an exact match fails, a second pass strips trailing spaces per line—splitting strictly via &lt;code&gt;split("\n")&lt;/code&gt; rather than &lt;code&gt;splitlines()&lt;/code&gt; so vertical tabs inside string literals aren't broken.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Empty &lt;code&gt;&amp;lt;fs_search&amp;gt;&lt;/code&gt;:&lt;/strong&gt; In Python, &lt;code&gt;"".replace("", new, 1)&lt;/code&gt; silently prepends code to the top of the file. Empty searches are explicitly rejected (full file overwrites use a dedicated marker).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Windows Line Endings:&lt;/strong&gt; &lt;code&gt;has_crlf = "\r\n" in original_content&lt;/code&gt; is captured before editing and preserved upon write to prevent &lt;code&gt;\r\r\n&lt;/code&gt; corruption.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  3. Intentional Threat Model (No Shell Access)
&lt;/h4&gt;

&lt;p&gt;The lack of terminal execution is a deliberate security choice: the orchestrator physically cannot run &lt;code&gt;rm -rf&lt;/code&gt; or exfiltrate &lt;code&gt;.env&lt;/code&gt; variables via &lt;code&gt;curl&lt;/code&gt;. &lt;code&gt;Sandbox.resolve_safe_path&lt;/code&gt; blocks absolute paths and &lt;code&gt;../&lt;/code&gt; traversal, while &lt;code&gt;assert_write_permitted&lt;/code&gt; denies writes to &lt;code&gt;READONLY&lt;/code&gt; or &lt;code&gt;UNMARKED&lt;/code&gt; files.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Context Hygiene (&lt;code&gt;.fsignore&lt;/code&gt; &amp;amp; Test Exclusion)
&lt;/h4&gt;

&lt;p&gt;Supports a two-level ignore system (global + local &lt;code&gt;.fsignore&lt;/code&gt; using &lt;code&gt;.gitignore&lt;/code&gt; syntax), automatic binary exclusion, optional test-file stubbing (&lt;code&gt;# [TEST FILE EXCLUDED - EXISTS ON DISK]&lt;/code&gt;), and an optional &lt;code&gt;UNMARKED PROJECT STRUCTURE&lt;/code&gt; tree so the LLM knows paths without wasting tokens on contents.&lt;/p&gt;

&lt;h4&gt;
  
  
  5. Manual Edit Detection &amp;amp; 1-Click Error Recovery
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Safe Rollbacks:&lt;/strong&gt; Before rolling back a patch, the server checks if the file on disk matches &lt;code&gt;new_snapshot&lt;/code&gt; in SQLite. If you edited the file manually in your IDE after applying the AI patch, rollback pauses and warns you instead of silently overwriting your code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;1-Click Error Context:&lt;/strong&gt; If a &lt;code&gt;&amp;lt;fs_search&amp;gt;&lt;/code&gt; block misses, clicking the failed log copies both the failed patch attempt and the actual file from disk straight to your clipboard so the chat can immediately issue a corrected patch.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Check It Out
&lt;/h3&gt;

&lt;p&gt;FS-XML Interpreter is completely free, open-source under &lt;strong&gt;Apache 2.0&lt;/strong&gt;, covered by backend and frontend tests (&lt;code&gt;pytest&lt;/code&gt; + &lt;code&gt;vitest&lt;/code&gt;), and comes with a pre-compiled &lt;code&gt;FS-XML.exe&lt;/code&gt; in the releases for Windows users who don't want to set up Python or Node.js.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Repository &amp;amp; Releases:&lt;/strong&gt; &lt;a href="https://github.com/Doctorgth/FS-XML" rel="noopener noreferrer"&gt;github.com/Doctorgth/FS-XML&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;(And if you prefer running strictly locally via API keys / Ollama without browser copy-pasting, check out my companion project &lt;a href="https://github.com/Doctorgth/live-context-ai-chat" rel="noopener noreferrer"&gt;Live-Context AI Chat&lt;/a&gt; which includes built-in FS-XML support).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;How do you manage context and prevent your AI coding agents from going rogue? Let's discuss in the comments!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>python</category>
      <category>llm</category>
    </item>
  </channel>
</rss>
