<?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: VANSH ARORA</title>
    <description>The latest articles on DEV Community by VANSH ARORA (@vansharora21).</description>
    <link>https://dev.to/vansharora21</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%2F3977293%2Fc5c372d4-6394-447c-b24e-985f05573fc4.png</url>
      <title>DEV Community: VANSH ARORA</title>
      <link>https://dev.to/vansharora21</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vansharora21"/>
    <language>en</language>
    <item>
      <title>A Redaction Bug in TokenCap's Companion Bridge, and the Fail-Closed Fix</title>
      <dc:creator>VANSH ARORA</dc:creator>
      <pubDate>Thu, 03 Dec 2026 16:00:42 +0000</pubDate>
      <link>https://dev.to/vansharora21/a-redaction-bug-in-tokencaps-companion-bridge-and-the-fail-closed-fix-3gkb</link>
      <guid>https://dev.to/vansharora21/a-redaction-bug-in-tokencaps-companion-bridge-and-the-fail-closed-fix-3gkb</guid>
      <description>&lt;p&gt;TokenCap is local-first: it builds context packs from your repository and never uploads them. The one place repository text does leave the tool on its way to a third party is the Chrome companion, where you choose to inject a pack into a browser chat. That path has to be redacted every time. For a while it was not always redacted, and this post explains why and what changed.&lt;/p&gt;

&lt;h3&gt;
  
  
  How the companion gets context
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;tokencap serve&lt;/code&gt; starts a loopback HTTP bridge on &lt;code&gt;127.0.0.1&lt;/code&gt; (port 4545 by default). The companion calls it with a pairing token in the &lt;code&gt;X-TokenCap-Token&lt;/code&gt; header, from an allowlisted origin. For a task, it posts to &lt;code&gt;/generate&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tokencap serve --token my-token

curl -s -X POST http://127.0.0.1:4545/generate \
  -H &lt;span class="s2"&gt;"X-TokenCap-Token: my-token"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"projectPath": "/home/me/app", "query": "cookie fallback"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The bridge builds the task pack in memory, then puts three parts together: a project primer (from the README, the &lt;code&gt;package.json&lt;/code&gt; description and &lt;code&gt;.tokencap/agent/agent.json&lt;/code&gt;), a short focus brief, and the task code. A final redaction pass runs over the joined text before it is returned. The file contents in the pack were already redacted when they were read. The final pass is what covers the primer and anything else assembled around them.&lt;/p&gt;

&lt;h3&gt;
  
  
  The bug
&lt;/h3&gt;

&lt;p&gt;The final pass used to look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;redact&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contextPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;audit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* keep text */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Browser packs are built with &lt;code&gt;write: false&lt;/code&gt;, so no context file is written and &lt;code&gt;result.contextPath&lt;/code&gt; is &lt;code&gt;undefined&lt;/code&gt;. Inside &lt;code&gt;redact()&lt;/code&gt;, the path is made relative to the project root with &lt;code&gt;path.relative(root, filepath)&lt;/code&gt;. Node throws on an undefined argument:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TypeError [ERR_INVALID_ARG_TYPE]: The "to" argument must be of type string. Received undefined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;catch&lt;/code&gt; kept the text. So in task mode the final pass threw on every request and the text went out unredacted. A secret in the README overview, or any other part of the primer, could reach a browser chat.&lt;/p&gt;

&lt;p&gt;Quick mode, which sends only the primer, passed a fixed label and was not hit by the path error. But its &lt;code&gt;catch&lt;/code&gt; also kept the text on any other failure.&lt;/p&gt;

&lt;h3&gt;
  
  
  The fix
&lt;/h3&gt;

&lt;p&gt;Two changes in &lt;code&gt;src/bridge/generate.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;First, the final pass gets a fixed label, &lt;code&gt;"bridge-task"&lt;/code&gt;, instead of a path that may not exist. The primer in quick mode keeps its &lt;code&gt;"primer"&lt;/code&gt; label.&lt;/p&gt;

&lt;p&gt;Second, both passes now fail closed. If &lt;code&gt;redact()&lt;/code&gt; throws for any reason, the bridge returns an error and no context:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;500 {"error": "redaction_failed", "detail": "Secret redaction failed; context withheld."}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No context is a worse experience than a context pack, and a much better one than an unredacted pack in a chat log. Both cases have regression tests in &lt;code&gt;test/fix-bridge-capture.test.js&lt;/code&gt;: one that checks primer secrets are redacted in a task-mode pack, and one that checks a redaction failure withholds the context in both task and quick mode.&lt;/p&gt;

&lt;p&gt;A related fix: &lt;code&gt;agent.json&lt;/code&gt; and &lt;code&gt;tech-stack.md&lt;/code&gt; no longer contain raw &lt;code&gt;.env&lt;/code&gt; values. External services are listed by public URL or by variable name.&lt;/p&gt;

&lt;h3&gt;
  
  
  Honest errors for build failures
&lt;/h3&gt;

&lt;p&gt;The same function had a smaller problem. Any exception while building the pack was answered with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;409 {"error": "project_not_indexed", ...}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The companion then told you to run &lt;code&gt;tokencap make&lt;/code&gt;. If the project was already indexed and the build failed for another reason, running &lt;code&gt;make&lt;/code&gt; again changed nothing and hid the real error.&lt;/p&gt;

&lt;p&gt;The bridge now checks whether the project is indexed before choosing the answer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;409 {"error": "project_not_indexed", "detail": "Run 'tokencap make' in this project first."}

500 {"error": "context_build_failed", "detail": "&amp;lt;the error message&amp;gt;",
     "hint": "Run 'tokencap make --rebuild'; if it persists, report this error."}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 409 is also returned up front when a request names a relative &lt;code&gt;projectPath&lt;/code&gt; or a project that is not indexed. Bridge endpoints act only on indexed projects named by absolute path, so they no longer create &lt;code&gt;.tokencap&lt;/code&gt; state in arbitrary directories.&lt;/p&gt;

&lt;h3&gt;
  
  
  What to do if you used the companion before this fix
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Update TokenCap with &lt;code&gt;tokencap update&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Look at what your primer is built from: the README overview, the &lt;code&gt;package.json&lt;/code&gt; description, and &lt;code&gt;.tokencap/agent/agent.json&lt;/code&gt;. If any of them held a secret, treat it as exposed to the chats you injected into and rotate it.&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;tokencap analyze security scan&lt;/code&gt; to check the generated files under &lt;code&gt;.tokencap/&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Limits
&lt;/h3&gt;

&lt;p&gt;Redaction is pattern-based. Failing closed means a crash in the redactor can no longer leak text, but a secret in a format no pattern knows is still passed through, as it would be anywhere else in TokenCap. A request can also turn redaction off on purpose with &lt;code&gt;"redactSecrets": false&lt;/code&gt;; the default is on. And the pairing token and origin allowlist stop a random web page from reading your projects over the port. They are not a defence against malware already running as your user.&lt;/p&gt;

&lt;p&gt;More: tokencap.vansharora.app&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devtools</category>
      <category>vscode</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Import Edges Beyond JavaScript: Python, Go, Rust and Java in TokenCap</title>
      <dc:creator>VANSH ARORA</dc:creator>
      <pubDate>Wed, 02 Dec 2026 11:56:36 +0000</pubDate>
      <link>https://dev.to/vansharora21/import-edges-beyond-javascript-python-go-rust-and-java-in-tokencap-5h0l</link>
      <guid>https://dev.to/vansharora21/import-edges-beyond-javascript-python-go-rust-and-java-in-tokencap-5h0l</guid>
      <description>&lt;p&gt;TokenCap builds a file graph of your repository: one node per source file, one edge per import that resolves to another file in the repository. Task packs, risk labels and the MCP dependency tool all read that graph. It used to be much smaller than most repositories.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the graph used to leave out
&lt;/h3&gt;

&lt;p&gt;Two limits, both in &lt;code&gt;src/graph/&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The scanner only added &lt;code&gt;.ts&lt;/code&gt;, &lt;code&gt;.tsx&lt;/code&gt;, &lt;code&gt;.js&lt;/code&gt;, &lt;code&gt;.jsx&lt;/code&gt;, &lt;code&gt;.mjs&lt;/code&gt; and &lt;code&gt;.cjs&lt;/code&gt; source files (plus some infrastructure files) to the graph. Python, Go, Rust, Java, Vue and Svelte files were not nodes, so no task pack could select them.&lt;/li&gt;
&lt;li&gt;The import parser only returned specifiers that started with &lt;code&gt;./&lt;/code&gt; or &lt;code&gt;../&lt;/code&gt;. The resolver already understood tsconfig &lt;code&gt;paths&lt;/code&gt; and &lt;code&gt;baseUrl&lt;/code&gt;, but an import like &lt;code&gt;@/lib/auth&lt;/code&gt; was discarded before it got there.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now those languages are graph nodes, and their imports become edges.&lt;/p&gt;

&lt;h3&gt;
  
  
  How each language resolves
&lt;/h3&gt;

&lt;p&gt;The specifiers are read with line-based patterns per language, then resolved against the list of files in the repository. Anything that does not resolve to a repository file is dropped, which is how standard library and third-party imports stay out.&lt;/p&gt;

&lt;p&gt;I ran the parser and resolver from &lt;code&gt;src/graph/&lt;/code&gt; on a small set of paths to show real output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;backend/app/api/routes.py
  py:app.core.config  -&amp;gt; backend/app/core/config.py
  ..db                -&amp;gt; backend/app/db.py
  py:os               -&amp;gt; null
  py:requests         -&amp;gt; null

cmd/server/main.go
  fmt                             -&amp;gt; null
  example.com/svc/internal/store  -&amp;gt; internal/store/store.go

src/main.rs
  rs:mod::walk             -&amp;gt; src/walk.rs
  rs:mod::flags            -&amp;gt; src/flags/mod.rs
  rs:crate::walk::Walker   -&amp;gt; src/walk.rs
  rs:crate::flags::parse   -&amp;gt; src/flags/parse.rs

src/main/java/com/example/App.java
  java:com.example.Foo     -&amp;gt; src/main/java/com/example/Foo.java
  java:java.util.List      -&amp;gt; null

src/components/Login.vue
  @/lib/auth               -&amp;gt; src/lib/auth.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rules behind those lines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Python.&lt;/strong&gt; Relative imports count leading dots as levels up and resolve to &lt;code&gt;mod.py&lt;/code&gt; or &lt;code&gt;mod/__init__.py&lt;/code&gt;. Absolute imports are tried against import roots: the directory above the importer's top-level package, the repository root, &lt;code&gt;src/&lt;/code&gt;, and any directory that holds a top-level package. That covers layouts like &lt;code&gt;backend/app/...&lt;/code&gt;. &lt;code&gt;from pkg import mod&lt;/code&gt; is also tried as a submodule.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Go.&lt;/strong&gt; Module paths come from &lt;code&gt;go.mod&lt;/code&gt; at the repository root and in workspace package directories. An import names a package directory, so it resolves to one non-test &lt;code&gt;.go&lt;/code&gt; file in that directory, preferring &lt;code&gt;&amp;lt;dir&amp;gt;.go&lt;/code&gt;, then &lt;code&gt;doc.go&lt;/code&gt;. A nested sub-package is never picked.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rust.&lt;/strong&gt; &lt;code&gt;mod x;&lt;/code&gt; declarations and &lt;code&gt;use&lt;/code&gt; paths that start with &lt;code&gt;crate::&lt;/code&gt;, &lt;code&gt;super::&lt;/code&gt; or &lt;code&gt;self::&lt;/code&gt; resolve to &lt;code&gt;x.rs&lt;/code&gt; or &lt;code&gt;x/mod.rs&lt;/code&gt;. Use trees like &lt;code&gt;crate::{a, b::{self, c}}&lt;/code&gt; are expanded. External crates are not followed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Java.&lt;/strong&gt; &lt;code&gt;import com.example.Foo;&lt;/code&gt; and static imports resolve to the file whose path ends in &lt;code&gt;com/example/Foo.java&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vue and Svelte.&lt;/strong&gt; The JS import patterns run over the file, so &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; imports become edges, including imports of other &lt;code&gt;.vue&lt;/code&gt; and &lt;code&gt;.svelte&lt;/code&gt; files.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JS/TS.&lt;/strong&gt; Every string specifier is kept now, not only relative ones. Bare specifiers go through tsconfig/jsconfig &lt;code&gt;paths&lt;/code&gt; and &lt;code&gt;baseUrl&lt;/code&gt;, &lt;code&gt;package.json&lt;/code&gt; &lt;code&gt;imports&lt;/code&gt; (&lt;code&gt;#internal/*&lt;/code&gt;), and workspace package names. Dynamic &lt;code&gt;import("./x")&lt;/code&gt; is matched too.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why the graph matters for a task pack
&lt;/h3&gt;

&lt;p&gt;Retrieval scores files by the words and identifiers in the task. The graph adds two things on top.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Proximity.&lt;/strong&gt; The 25 best-scoring files each lend 15% of their score to the files they import and the files that import them. A neighbour never outranks the file it came from. In practice this pulls in the module a matched function calls into, or the route that uses a matched service, even when that file shares no words with the task. Each file in the pack records why it was chosen, and for these files the reason names the file that imports it or that it imports. &lt;code&gt;tokencap ask "&amp;lt;task&amp;gt;" --json&lt;/code&gt; carries the full explanation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Risk and impact.&lt;/strong&gt; A file's importer count feeds its importance and risk level. Five or more importers make a file HIGH risk; a database file with five or more importers is CRITICAL. Those labels show up in the pack's Risk Areas section and act as small multipliers on files that already match the task. Without edges, a Python service imported by thirty modules looked exactly like a script nobody used.&lt;/p&gt;

&lt;h3&gt;
  
  
  Seeing the edges
&lt;/h3&gt;

&lt;p&gt;To build the graph and open it in a browser:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tokencap make --open-graph
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From an agent, the MCP tool &lt;code&gt;tokencap_dependencies&lt;/code&gt; walks the same graph from a file: what it imports, what imports it, up to five hops. It is available once your host runs &lt;code&gt;tokencap serve --mcp&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Limits
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Import parsing uses line-based patterns, not the Tree-sitter parser. An import built at runtime from a string is invisible.&lt;/li&gt;
&lt;li&gt;Java wildcard imports (&lt;code&gt;import com.example.util.*;&lt;/code&gt;) are not followed.&lt;/li&gt;
&lt;li&gt;A one-word Python import like &lt;code&gt;import config&lt;/code&gt; that is not found under an import root is not matched to a same-named file elsewhere in the repository. It is far more likely to be the standard library or a third-party package. Dotted imports still fall back to a path match.&lt;/li&gt;
&lt;li&gt;A Go import becomes one edge to one file of the package, not to every file in it.&lt;/li&gt;
&lt;li&gt;Edges are file to file. Call-level resolution is a separate graph, used by &lt;code&gt;tokencap ask impact&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On the &lt;code&gt;benchmarks/fair/&lt;/code&gt; set (100 real commits across JavaScript, TypeScript, Vue, Python, Go, Rust and Java), the task pack shows 89% of the needed files as code and holds 74% of the edited lines, at a median 18.4x fewer tokens than a keyword grep. That figure covers the whole retrieval and packing pipeline; the benchmark does not isolate import edges.&lt;/p&gt;

&lt;p&gt;More: tokencap.vansharora.app&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devtools</category>
      <category>vscode</category>
      <category>productivity</category>
    </item>
    <item>
      <title>How TokenCap Picks Files for a Task: Rare Words, Four Fields, Exact Identifiers</title>
      <dc:creator>VANSH ARORA</dc:creator>
      <pubDate>Tue, 01 Dec 2026 21:39:34 +0000</pubDate>
      <link>https://dev.to/vansharora21/how-tokencap-picks-files-for-a-task-rare-words-four-fields-exact-identifiers-1o7o</link>
      <guid>https://dev.to/vansharora21/how-tokencap-picks-files-for-a-task-rare-words-four-fields-exact-identifiers-1o7o</guid>
      <description>&lt;p&gt;A TokenCap task pack starts with a ranking. &lt;code&gt;tokencap ask "&amp;lt;task&amp;gt;"&lt;/code&gt; scores every file in the repository's graph, and only the top of that list competes for the token budget. If the ranking is wrong, the packer can only fill the budget with the wrong files.&lt;/p&gt;

&lt;p&gt;That ranking was rewritten. The code is in &lt;code&gt;src/retrieve/rank.js&lt;/code&gt; and &lt;code&gt;src/context/retrieveFiles.js&lt;/code&gt;. This post covers how it works now and what it still cannot do.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the old ranking did
&lt;/h3&gt;

&lt;p&gt;The old score was a sum of bonuses. A query keyword anywhere in the path added 5. A matching cluster added 3. Risk added up to 2, a recent change 1.5, high impact 1. A BM25 score over the path and the file's identifiers was added on top, with every query word counted the same.&lt;/p&gt;

&lt;p&gt;Two things followed from that. Path matching was a substring test, so the keyword "is" matched &lt;code&gt;registry&lt;/code&gt;. And a file with no connection to the task could still rank, because risk and recent-change bonuses did not depend on the task.&lt;/p&gt;

&lt;p&gt;I checked both rankings on a five-file toy repository: a shortcodes registry, its renderer, a database connector, a parser, and an auth session file marked as changed, high-impact and CRITICAL. For the task "allShortcodes includes drafts", the old ranking returned one file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;4.5  src/auth/session.js   recently-changed, high-impact, risk:CRITICAL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rewritten ranking returned the files the task is about (scores from when it was written):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10   src/shortcodes/registry.js  matches:allshortcodes+shortcod+draft, direct-dependency
8.4  src/shortcodes/render.js    matches:allshortcodes+shortcod, direct-dependency
1.3  src/util/parse.js           direct-dependency
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A toy proves nothing about real repositories. It does show the two failure modes clearly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rare words count more
&lt;/h3&gt;

&lt;p&gt;Each query term gets an inverse document frequency weight:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;idf(term) = log(1 + (files - matching + 0.5) / (matching + 0.5))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A word that appears in most files of the repository adds little. A word that appears in three adds a lot. The final score is also scaled by how much of the task's rare-word weight a file covers, from 0.4 for almost none to 1.0 for all of it. A file that matches one of three rare words is scored down.&lt;/p&gt;

&lt;h3&gt;
  
  
  Four fields per file
&lt;/h3&gt;

&lt;p&gt;Each term is checked against four fields:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Weight&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;File name&lt;/td&gt;
&lt;td&gt;3.0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Declared symbols (functions, classes, consts, defs)&lt;/td&gt;
&lt;td&gt;1.5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Directory&lt;/td&gt;
&lt;td&gt;1.0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Full text, BM25-saturated&lt;/td&gt;
&lt;td&gt;1.0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A term that appears 40 times in a file does not count 40 times more than a term that appears once; BM25 saturation flattens repeat counts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stemming, variants and a few synonyms
&lt;/h3&gt;

&lt;p&gt;A small suffix stemmer runs on both the query and the files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cookie, cookies         -&amp;gt; cooki
validate, validating    -&amp;gt; validat
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Words where one extends the other, like "config" and "configuration", match at 0.6 weight. Five fixed synonym groups match at 0.5: auth/login/session/token, user/account/profile, payment/billing/checkout, database/db/storage, and test/spec/e2e.&lt;/p&gt;

&lt;h3&gt;
  
  
  Identifiers, paths and stack frames are matched exactly
&lt;/h3&gt;

&lt;p&gt;When a task names an identifier, that is the most precise signal it carries. TokenCap pulls out every token with two or more parts and builds the spellings it may take in source:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;allShortcodes -&amp;gt; allshortcodes, all_shortcodes, all-shortcodes
DATABASE_URL  -&amp;gt; databaseurl, database_url, database-url
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each file whose text or path contains one of those spellings gets an extra 4.0 times that identifier's rarity. Plain words are not treated as identifiers.&lt;/p&gt;

&lt;p&gt;A file path in the task is looked up directly and outweighs every other field. A stack frame is looked up the same way, and its line is shown first. A name declared in only a few files points straight at those files.&lt;/p&gt;

&lt;h3&gt;
  
  
  Signals that only adjust
&lt;/h3&gt;

&lt;p&gt;Risk, impact and recent change are still useful for ordering files that are already relevant. They are multipliers that apply only when a file's task score is above zero:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;recently changed   x1.15
cluster match      x1.10
memory match       x1.05
high impact        x1.05
HIGH/CRITICAL risk x1.05
test files         x0.60 (unless the task is about tests)
generated, lockfiles x0.30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How files without a matching word get in
&lt;/h3&gt;

&lt;p&gt;Three routes are tied to the task's best matches. Graph proximity: the 25 best matches pass 15% of their score to the files they import and the files that import them, and a neighbour never outranks the match it came from. Co-change: files that git history shows changing together with the best matches can join. Commit history: files of past commits whose messages match the task can join too.&lt;/p&gt;

&lt;h3&gt;
  
  
  One retrieval everywhere, with reasons
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;tokencap ask "&amp;lt;task&amp;gt;"&lt;/code&gt;, the companion bridge and &lt;code&gt;--adaptive&lt;/code&gt; build the same pack through one pipeline, and the MCP tool &lt;code&gt;tokencap_files&lt;/code&gt; uses the same ranking. The CLI and your agent agree on file order.&lt;/p&gt;

&lt;p&gt;Each file in a pack records how it was included (whole, span, outline, summary or reference), what it cost, and why it was chosen. &lt;code&gt;tokencap ask&lt;/code&gt; prints the files shown as code and up to five left-out files with the reason: out of budget, over the file cap, or below relevance. For the full explanation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tokencap ask &lt;span class="s2"&gt;"allShortcodes includes drafts"&lt;/span&gt; --json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What the benchmark shows, and the limits
&lt;/h3&gt;

&lt;p&gt;On &lt;code&gt;benchmarks/fair/&lt;/code&gt;, 100 real commits from nine repositories, the task pack shows 89% of the needed files as code, holds 74% of the lines each commit edited, and uses a median 18.4x fewer tokens than a keyword grep. On the held-out tasks: 88.9%, 74.5% and 18.0x. Before this ranking, the first three repositories in that benchmark scored 25%. The benchmark calls no model, so it measures retrieval and packing, not answers.&lt;/p&gt;

&lt;p&gt;Limits worth knowing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reading every matching file still finds more: 96%.&lt;/li&gt;
&lt;li&gt;Files over 300,000 bytes are ranked by path and symbols only, and repositories with more than 6,000 graph files skip full-text matching, which also limits identifier matching to paths.&lt;/li&gt;
&lt;li&gt;The stemmer strips suffixes. It does not know that "ran" is "run".&lt;/li&gt;
&lt;li&gt;The synonym list is five groups, not a thesaurus.&lt;/li&gt;
&lt;li&gt;Benchmark tasks are commit subjects, which are terser than what people usually type.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More: tokencap.vansharora.app&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devtools</category>
      <category>vscode</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Moving an Older TokenCap Setup Over: Three Commands and an Alias Table</title>
      <dc:creator>VANSH ARORA</dc:creator>
      <pubDate>Thu, 26 Nov 2026 17:10:58 +0000</pubDate>
      <link>https://dev.to/vansharora21/moving-an-older-tokencap-setup-over-three-commands-and-an-alias-table-2nk4</link>
      <guid>https://dev.to/vansharora21/moving-an-older-tokencap-setup-over-three-commands-and-an-alias-table-2nk4</guid>
      <description>&lt;p&gt;TokenCap's CLI is organised around seven commands, and the generated artifacts follow published JSON schemas. If a repository was set up with an older TokenCap, this is the whole move.&lt;/p&gt;

&lt;h3&gt;
  
  
  The three commands
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm install -g tokencap
tokencap make --migrate
tokencap make
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The install gets the latest TokenCap, which carries the fixes covered in recent posts: stricter redaction that leaves code references intact, every language parsing on Node 18 and 20, and an MCP server that no longer times out on a first run.&lt;/p&gt;

&lt;p&gt;Check the install:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tokencap version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, in each repository, run the other two commands.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;tokencap make --migrate&lt;/code&gt; upgrades &lt;code&gt;.tokencap/config.json&lt;/code&gt; to the current format, publishes JSON schemas in &lt;code&gt;.tokencap/schemas/&lt;/code&gt;, and writes &lt;code&gt;.tokencap/migration.json&lt;/code&gt;. It prints the three paths and ends by telling you to run &lt;code&gt;tokencap make&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The following &lt;code&gt;tokencap make&lt;/code&gt; regenerates the artifact manifest and writes a build record, &lt;code&gt;.tokencap/build.json&lt;/code&gt;, with the commit, time and the layers that built. Migration is a &lt;code&gt;make&lt;/code&gt; flag on purpose, so the CLI stays at seven commands: &lt;code&gt;make&lt;/code&gt;, &lt;code&gt;ask&lt;/code&gt;, &lt;code&gt;analyze&lt;/code&gt;, &lt;code&gt;serve&lt;/code&gt;, &lt;code&gt;update&lt;/code&gt;, &lt;code&gt;help&lt;/code&gt;, &lt;code&gt;version&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  The alias table
&lt;/h3&gt;

&lt;p&gt;The old compatibility aliases are gone. The ones you are most likely to have in scripts:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Old command&lt;/th&gt;
&lt;th&gt;Current command&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tokencap impact &amp;lt;file&amp;gt;:&amp;lt;sym&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tokencap ask impact &amp;lt;file&amp;gt;:&amp;lt;sym&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tokencap health&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tokencap analyze health&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tokencap rebuild&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tokencap make --rebuild&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tokencap remember&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tokencap serve session save&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tokencap memory&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tokencap serve session list&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tokencap handoff&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tokencap serve session handoff&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tokencap migrate&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tokencap make --migrate&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tokencap compress &amp;lt;file&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tokencap analyze compress &amp;lt;file&amp;gt; --write&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tokencap stats&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tokencap analyze stats&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tokencap debt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tokencap analyze debt&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tokencap risk&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tokencap analyze risk&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tokencap refactor&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tokencap analyze refactor&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tokencap verify&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tokencap analyze verify&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tokencap security scan&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;tokencap analyze security scan&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Removed commands tell you where they went
&lt;/h3&gt;

&lt;p&gt;You do not have to grep your scripts first. A removed command prints a one-line error that says it was removed and names its replacement, then exits 1. &lt;code&gt;tokencap rebuild&lt;/code&gt; points you to &lt;code&gt;tokencap make --rebuild&lt;/code&gt;, and &lt;code&gt;tokencap remember&lt;/code&gt; to &lt;code&gt;tokencap serve session save&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It does not guess and run the new command for you. A CI job that calls an old name fails loudly, with the fix in the log line.&lt;/p&gt;

&lt;h3&gt;
  
  
  MCP setups keep working
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;tokencap mcp&lt;/code&gt; is the one exception to the removals. It still starts the MCP server, so host configs written for the old CLI keep working without edits. New configs written by &lt;code&gt;tokencap serve --mcp --init&lt;/code&gt; launch &lt;code&gt;tokencap serve --mcp&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The MCP tool contract is stable: tools are not renamed and documented fields keep their meaning. &lt;code&gt;tokencap_mcp_status&lt;/code&gt; reports the contract the server speaks.&lt;/p&gt;

&lt;p&gt;One thing to check if you use Claude Code: older builds wrote the config to &lt;code&gt;.claude/mcp.json&lt;/code&gt;, which Claude Code does not read. TokenCap now writes &lt;code&gt;.mcp.json&lt;/code&gt; at the project root:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tokencap serve --mcp --init --client claude-code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An existing &lt;code&gt;tokencap&lt;/code&gt; entry is kept unless you pass &lt;code&gt;--force&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Behaviour changes to check after the move
&lt;/h3&gt;

&lt;p&gt;Coming from an older setup also brings a few behaviour changes. The ones most likely to touch you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Constitution rule IDs are content-derived&lt;/strong&gt; (&lt;code&gt;CONST-API-F5BF63&lt;/code&gt;). Every ID changes once. A manual override that reuses an old positional ID like &lt;code&gt;CONST-API-001&lt;/code&gt; becomes an extra rule; copy the new ID from &lt;code&gt;.tokencap/constitution/constitution.yaml&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A hand-written &lt;code&gt;AGENTS.md&lt;/code&gt; is no longer overwritten.&lt;/strong&gt; &lt;code&gt;make&lt;/code&gt; only refreshes it while it still holds a TokenCap template.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Redaction keeps the original separator and quotes&lt;/strong&gt;: &lt;code&gt;OPENAI_API_KEY = '[REDACTED:KEY]'&lt;/code&gt; instead of &lt;code&gt;OPENAI_API_KEY=[REDACTED:KEY]&lt;/code&gt;. Update anything that matches the old form.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flag parsing.&lt;/strong&gt; An unknown flag prints a warning on stderr, and &lt;code&gt;--flag=value&lt;/code&gt; is parsed, so &lt;code&gt;make --root=X&lt;/code&gt; now builds into X.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After this, &lt;code&gt;tokencap update&lt;/code&gt; keeps you current. It is the only command that uses the network. &lt;code&gt;make&lt;/code&gt;, &lt;code&gt;ask&lt;/code&gt;, &lt;code&gt;analyze health&lt;/code&gt;, &lt;code&gt;diff&lt;/code&gt; and &lt;code&gt;update&lt;/code&gt; each end with one &lt;code&gt;Next:&lt;/code&gt; line, and when the index is behind your commits that line tells you to rebuild first.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where the evidence stands
&lt;/h3&gt;

&lt;p&gt;The open work is evidence, and it is listed in &lt;code&gt;HONEST-NUMBERS.md&lt;/code&gt;. The model-in-the-loop harness, &lt;code&gt;benchmarks/fair/answer-eval.js&lt;/code&gt;, exists but has not been run, so there is no published answer-quality result yet. The current benchmark measures whether the task pack holds the files a real commit changed, on 100 tasks: 89% of the needed files are shown as code, 74% of the edited lines are in the pack, at a median 18.4x fewer tokens than a keyword grep. On the held-out tasks: 88.9%, 74.5% and 18.0x. Grepping everything still finds more files (96%), and that limit is written down next to the number.&lt;/p&gt;

&lt;p&gt;What would help most:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If a migration step failed or printed something confusing, tell me the command and the output.&lt;/li&gt;
&lt;li&gt;If an old command you rely on has no obvious home in the new CLI, say which.&lt;/li&gt;
&lt;li&gt;Tell me which host and language you use. That decides what gets tested next.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Migration notes, docs and the changelog are at tokencap.vansharora.app&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devtools</category>
      <category>vscode</category>
      <category>productivity</category>
    </item>
    <item>
      <title>What the TokenCap MCP Server Gives Your Agent</title>
      <dc:creator>VANSH ARORA</dc:creator>
      <pubDate>Wed, 25 Nov 2026 17:29:19 +0000</pubDate>
      <link>https://dev.to/vansharora21/what-the-tokencap-mcp-server-gives-your-agent-14ca</link>
      <guid>https://dev.to/vansharora21/what-the-tokencap-mcp-server-gives-your-agent-14ca</guid>
      <description>&lt;p&gt;TokenCap runs as a local MCP server over stdio. Your editor or agent host starts &lt;code&gt;tokencap serve --mcp&lt;/code&gt;, and the agent can ask for ranked files, dependencies, impact and repository rules instead of rediscovering the codebase every session. Nothing leaves the machine: no upload, no LLM call, no API key.&lt;/p&gt;

&lt;p&gt;This post covers how that flow behaves on first contact and in daily use, including the parts that used to break.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. &lt;code&gt;initialize&lt;/code&gt; is answered at once
&lt;/h3&gt;

&lt;p&gt;The server used to build repository intelligence before it answered the host. On a large repository that took longer than the host was willing to wait, and the first run looked like a dead server.&lt;/p&gt;

&lt;p&gt;Now the server answers &lt;code&gt;initialize&lt;/code&gt; immediately and runs the build in the background, then starts its file watcher. Until the build finishes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;tools that need intelligence return &lt;code&gt;status: "building"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;results served from earlier intelligence carry &lt;code&gt;stale: true&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The build runs detached and logs to &lt;code&gt;.tokencap/mcp/initial-build.log&lt;/code&gt;, so it completes even if the host stops the server. A failed initial build is not fatal: the server keeps serving whatever intelligence exists, and the file watcher still starts.&lt;/p&gt;

&lt;p&gt;No separate &lt;code&gt;tokencap make&lt;/code&gt; step is needed before using MCP.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Responses say how fresh the index is
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;tokencap make&lt;/code&gt; writes a build record (&lt;code&gt;.tokencap/build.json&lt;/code&gt;: commit, time, layers built or failed, files indexed and skipped). One classifier reads it and reports the index as fresh, behind, dirty, incomplete or missing.&lt;/p&gt;

&lt;p&gt;When the index is anything other than fresh, the MCP response carries an &lt;code&gt;index&lt;/code&gt; field with the state, a short detail and the command that fixes it. &lt;code&gt;tokencap_mcp_status&lt;/code&gt; and the overview report the same state. The server picks up new builds on its own, so there is no "restart the server" step after a &lt;code&gt;make&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Two servers, one repository
&lt;/h3&gt;

&lt;p&gt;Open the same repository in two windows and you get two MCP servers. The second one used to exit when it found the build lock taken.&lt;/p&gt;

&lt;p&gt;Now it waits for the running build and keeps serving. The same applies when you run &lt;code&gt;tokencap make&lt;/code&gt; by hand while the server is up. A lock held for more than 10 minutes fails with the holder's pid and the lock path, so a stuck build is something you can find and kill.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. &lt;code&gt;tokencap_files&lt;/code&gt; ranks like &lt;code&gt;tokencap ask&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;tokencap_files&lt;/code&gt; takes a query and returns ranked task-relevant files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"query"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"login redirect bug"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It uses the same retrieval as task packs. &lt;code&gt;tokencap ask "login redirect bug"&lt;/code&gt; in a terminal and &lt;code&gt;tokencap_files&lt;/code&gt; from the agent agree on file order and scores. The first call in a session builds the graph from the working tree.&lt;/p&gt;

&lt;p&gt;Tool responses are capped at about 15k tokens. A larger one is shortened, and the full copy is saved under &lt;code&gt;.tokencap/mcp/cut/&lt;/code&gt; and named in &lt;code&gt;restore.path&lt;/code&gt;, so the agent can read the rest if it needs it.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. &lt;code&gt;--init&lt;/code&gt; writes where the host reads
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tokencap serve --mcp --init                       &lt;span class="c"&gt;# detect the host&lt;/span&gt;
tokencap serve --mcp --init --client claude-code  &lt;span class="c"&gt;# or pick one&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✓ claude-code config written to .mcp.json
  Start the server: tokencap serve --mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Host&lt;/th&gt;
&lt;th&gt;File written&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Claude Code&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;.mcp.json&lt;/code&gt; (project root)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cursor&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.cursor/mcp.json&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;VS Code&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.vscode/mcp.json&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Codex&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.codex/config.toml&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claude Desktop&lt;/td&gt;
&lt;td&gt;per-user &lt;code&gt;claude_desktop_config.json&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Windsurf&lt;/td&gt;
&lt;td&gt;per-user &lt;code&gt;~/.codeium/windsurf/mcp_config.json&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The Claude Code row was a fix. An older build wrote &lt;code&gt;.claude/mcp.json&lt;/code&gt;, which Claude Code does not read. Claude Desktop and Windsurf only read per-user files shared by every project, so their entry adds &lt;code&gt;--root &amp;lt;repo&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Running &lt;code&gt;--init&lt;/code&gt; again does not clobber your setup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✓ claude-code config .mcp.json already has a tokencap server; kept it (--force replaces it)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An existing &lt;code&gt;tokencap&lt;/code&gt; entry is kept as it is, including a custom command, &lt;code&gt;--root&lt;/code&gt; or &lt;code&gt;env&lt;/code&gt;. Other servers in the file are kept too.&lt;/p&gt;

&lt;p&gt;It also reads real-world config files. A VS Code &lt;code&gt;mcp.json&lt;/code&gt; that starts with a byte-order mark and has &lt;code&gt;// comments&lt;/code&gt; and trailing commas gets the &lt;code&gt;tokencap&lt;/code&gt; entry added, and the comments stay. Invalid JSON is refused rather than replaced. The command exits 1 when no host is detected, &lt;code&gt;--client&lt;/code&gt; is unknown, or the write fails, so scripts can tell.&lt;/p&gt;

&lt;p&gt;Codex only loads workspace MCP configuration for a trusted workspace. Trust it and reload Codex after &lt;code&gt;--init&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Smaller fixes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;tokencap_review&lt;/code&gt; refuses base refs that look like git options and reports an unknown base ref as an error instead of "No changes detected".&lt;/li&gt;
&lt;li&gt;The final redaction pass keeps the JSON envelope intact and catches escaped secrets.&lt;/li&gt;
&lt;li&gt;Error hints name commands that exist.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Check it
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tokencap serve --mcp --tools    &lt;span class="c"&gt;# list endpoints&lt;/span&gt;
tokencap serve --mcp --test     &lt;span class="c"&gt;# exercise every endpoint&lt;/span&gt;
tokencap serve --mcp --health   &lt;span class="c"&gt;# one-shot health check&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From inside the host, &lt;code&gt;tokencap_mcp_status&lt;/code&gt; reports uptime, cache hit rate, per-endpoint call counts, the log location and the index state.&lt;/p&gt;

&lt;p&gt;The MCP guide and tool contract are at tokencap.vansharora.app&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devtools</category>
      <category>vscode</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Project Memory for AI Coding Agents: Decisions Linked to the Code They Cover</title>
      <dc:creator>VANSH ARORA</dc:creator>
      <pubDate>Tue, 24 Nov 2026 23:13:09 +0000</pubDate>
      <link>https://dev.to/vansharora21/project-memory-for-ai-coding-agents-decisions-linked-to-the-code-they-cover-58m5</link>
      <guid>https://dev.to/vansharora21/project-memory-for-ai-coding-agents-decisions-linked-to-the-code-they-cover-58m5</guid>
      <description>&lt;p&gt;Every repository has rules that live in someone's head. "Totals are rounded in one place only." "Don't call the payment client from a request handler." An AI coding agent never sees them unless someone pastes them into the chat again, every session.&lt;/p&gt;

&lt;p&gt;TokenCap now stores these as project memory records and hands them to the agent with the code they apply to.&lt;/p&gt;

&lt;h3&gt;
  
  
  What a record is
&lt;/h3&gt;

&lt;p&gt;A record has a kind (decision, constraint, gotcha or convention), a title, some text, and anchors: the files, or file and function, it applies to.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tokencap analyze memory add --kind decision \
  --title &lt;span class="s2"&gt;"Totals are rounded to cents"&lt;/span&gt; \
  --text &lt;span class="s2"&gt;"round() in src/money.js is the only rounding rule."&lt;/span&gt; \
  --anchor src/invoice.js --anchor src/money.js:round
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Records are stored in &lt;code&gt;.tokencap/memory/records.json&lt;/code&gt;, inside your repository. Nothing is sent anywhere.&lt;/p&gt;

&lt;h3&gt;
  
  
  How the agent gets them
&lt;/h3&gt;

&lt;p&gt;When you run &lt;code&gt;tokencap ask "&amp;lt;task&amp;gt;"&lt;/code&gt;, the task pack picks the files for the task as before. Then it adds the accepted records anchored to those files, at most 8 records and about 300 tokens, so memory can't crowd out code. A project with no records gets no memory section at all.&lt;/p&gt;

&lt;p&gt;The same records reach agents through the MCP server (&lt;code&gt;tokencap_manage_adr&lt;/code&gt; lists, adds, edits and supersedes them). Existing ADRs keep their own store and show up as &lt;code&gt;adr-&amp;lt;n&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  How records stay true
&lt;/h3&gt;

&lt;p&gt;A rule that no longer matches the code is worse than no rule. So when the code a record is anchored to changes, the record is flagged stale.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tokencap analyze memory stale              &lt;span class="c"&gt;# records whose anchored code changed&lt;/span&gt;
tokencap analyze memory confirm --id 1     &lt;span class="c"&gt;# still true&lt;/span&gt;
tokencap analyze memory supersede --id 1 --title &lt;span class="s2"&gt;"..."&lt;/span&gt;   &lt;span class="c"&gt;# replaced by a newer rule&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Session capture feeds the same store, with a person in the loop. Approving a captured session proposes its decisions as records. They are never accepted automatically: you review them with &lt;code&gt;tokencap analyze memory list --proposed&lt;/code&gt; and approve the ones that are right. The session handoff lists the proposals next to the records for the files the session changed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Two smaller changes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Next step everywhere. &lt;code&gt;make&lt;/code&gt;, &lt;code&gt;ask&lt;/code&gt;, &lt;code&gt;analyze review&lt;/code&gt;, &lt;code&gt;diff&lt;/code&gt;, &lt;code&gt;health&lt;/code&gt; and &lt;code&gt;update&lt;/code&gt; end with one &lt;code&gt;Next:&lt;/code&gt; line. If the index is stale, that comes first.&lt;/li&gt;
&lt;li&gt;Test guidance. Change review lists the tests to run, and where a missing test would go under your repository's own naming convention.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What did not change
&lt;/h3&gt;

&lt;p&gt;File selection. I ran the full benchmark (235 tasks across four splits) after these changes, and recall, edit-site coverage and the median token ratio are identical to before, task by task. The 91% recall and 80% edit-site targets are still open, and I'll report on them when they move.&lt;/p&gt;

&lt;p&gt;Install or update:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm install -g tokencap
tokencap make
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ai</category>
      <category>devtools</category>
      <category>vscode</category>
      <category>productivity</category>
    </item>
    <item>
      <title>The Bug Where Node 20 Could Only Parse Rust</title>
      <dc:creator>VANSH ARORA</dc:creator>
      <pubDate>Tue, 24 Nov 2026 14:01:21 +0000</pubDate>
      <link>https://dev.to/vansharora21/the-bug-where-node-20-could-only-parse-rust-41gp</link>
      <guid>https://dev.to/vansharora21/the-bug-where-node-20-could-only-parse-rust-41gp</guid>
      <description>&lt;p&gt;TokenCap uses Tree-sitter, compiled to WASM, to find real function boundaries in your code. When a large file has to be shown in part, the parser tells it where a function starts and ends, so a matching function is shown whole instead of cut in the middle.&lt;/p&gt;

&lt;p&gt;For a while, on Node 20, that only worked for Rust.&lt;/p&gt;

&lt;h3&gt;
  
  
  What it looked like
&lt;/h3&gt;

&lt;p&gt;Nothing. That was the problem.&lt;/p&gt;

&lt;p&gt;The parse layer is built to degrade gracefully. If a grammar is missing or fails, &lt;code&gt;parse()&lt;/code&gt; returns &lt;code&gt;null&lt;/code&gt; and the caller falls back to text heuristics. It never throws. The error is only printed when &lt;code&gt;TOKENCAP_DEBUG&lt;/code&gt; is set.&lt;/p&gt;

&lt;p&gt;So on Node 20, JavaScript, TypeScript, Python, Go and Java files all went through the heuristic path for function boundaries, spans and outlines. Builds succeeded. Packs were produced. They were just less precise, and nothing said so.&lt;/p&gt;

&lt;h3&gt;
  
  
  The cause
&lt;/h3&gt;

&lt;p&gt;TokenCap pins &lt;code&gt;web-tree-sitter&lt;/code&gt; 0.24 and vendors its grammars under &lt;code&gt;src/parse/grammars/&lt;/code&gt;. A warm-up step loaded all of them in parallel.&lt;/p&gt;

&lt;p&gt;On Node 20, that runtime linked the symbols of grammars loaded concurrently into each other. Loading JavaScript would fail with an error naming a Python symbol:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bad export type for 'tree_sitter_python_external_scanner_create'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One grammar survived the race. Every other language fell back. Node 24 happened to tolerate the same parallel load, so on Node 24 everything looked fine.&lt;/p&gt;

&lt;h3&gt;
  
  
  The fix
&lt;/h3&gt;

&lt;p&gt;Load grammars one at a time. The warm-up can still ask for every grammar at once with &lt;code&gt;Promise.all&lt;/code&gt;, but each actual load waits on the previous one through a promise queue (trimmed from &lt;code&gt;src/parse/engine.js&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;loadQueue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;loadLanguageFromPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wasmPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;langId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;load&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;loadQueue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Language&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wasmPath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;loadQueue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The real function also wraps a failure in a message that names the grammar and the likely cause, a grammar that does not match the runtime it is loaded into. Concurrent callers asking for the same language share one in-flight load, so the queue does not load a grammar twice.&lt;/p&gt;

&lt;p&gt;After the fix, packs are identical across Node 18 and 20.&lt;/p&gt;

&lt;h3&gt;
  
  
  The test that would have caught it
&lt;/h3&gt;

&lt;p&gt;A test that only checks that parsing does not crash passes the whole time this bug exists. The new test checks the good path (trimmed; &lt;code&gt;samples&lt;/code&gt; holds one small snippet per language):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"warming every grammar at once loads all of them (Node 20 linking race)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;disposeEngine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;warmGrammars&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;parserCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;vendoredLanguages&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;lang&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nf"&gt;vendoredLanguages&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;tree&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parseSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;samples&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;lang&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lang&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sb"&gt;`${lang} parses after warmGrammars on ${process.version}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rootNode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hasError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;deleteTree&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CI now runs the suite on Node 20 on Ubuntu and Windows, and on Node 24 on Ubuntu, with a comment in the workflow saying why: behaviour has differed by Node version before.&lt;/p&gt;

&lt;h3&gt;
  
  
  A second quiet failure: WASM memory
&lt;/h3&gt;

&lt;p&gt;A second bug had the same shape. Every tree the parser returns lives on the WASM heap until it is freed with &lt;code&gt;deleteTree()&lt;/code&gt;. In a long-lived process, like the MCP server or the bridge, the heap could run out. When it does, the runtime aborts with &lt;code&gt;WebAssembly.RuntimeError: Aborted()&lt;/code&gt; and stays unusable. Every later parse failed, and fell back, silently.&lt;/p&gt;

&lt;p&gt;Now &lt;code&gt;parse()&lt;/code&gt; recognises the abort, drops the dead runtime, loads a fresh one and retries once. Long sessions keep parsing.&lt;/p&gt;

&lt;h3&gt;
  
  
  The lesson
&lt;/h3&gt;

&lt;p&gt;Graceful degradation is the right default for a tool that has to work on any repository. But every fallback branch is a place where a bug can live without a symptom.&lt;/p&gt;

&lt;p&gt;Three takeaways:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;For every fallback, write a test that asserts the primary path ran, not just that some output exists.&lt;/li&gt;
&lt;li&gt;Run CI on more than one runtime version when the code depends on a native or WASM layer.&lt;/li&gt;
&lt;li&gt;Make fallbacks visible. A fallback rate that jumps from zero to most of your files should show up somewhere other than a debug flag. TokenCap went part of the way here: &lt;code&gt;tokencap make&lt;/code&gt; now writes a build record (&lt;code&gt;.tokencap/build.json&lt;/code&gt;) listing the layers that built or failed, and &lt;code&gt;ask&lt;/code&gt;, &lt;code&gt;analyze health&lt;/code&gt; and the MCP status report whether the index is fresh, behind, incomplete or missing, with the command that fixes it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Install and docs: tokencap.vansharora.app&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devtools</category>
      <category>vscode</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Redacting Secrets Without Breaking the Code Your AI Agent Reads</title>
      <dc:creator>VANSH ARORA</dc:creator>
      <pubDate>Thu, 19 Nov 2026 15:56:50 +0000</pubDate>
      <link>https://dev.to/vansharora21/redacting-secrets-without-breaking-the-code-your-ai-agent-reads-54hb</link>
      <guid>https://dev.to/vansharora21/redacting-secrets-without-breaking-the-code-your-ai-agent-reads-54hb</guid>
      <description>&lt;p&gt;TokenCap builds context packs from your repository for AI coding agents. Every file read, git diff and snippet passes through one redaction function before it is written anywhere. In v3.1 that function got stricter about secrets and more careful about code.&lt;/p&gt;

&lt;p&gt;Both directions matter. A missed secret is a leak. A false positive is quieter but still costly: if &lt;code&gt;const secret = process.env.SECRET&lt;/code&gt; gets rewritten, the agent loses the one line that tells it where the value comes from.&lt;/p&gt;

&lt;h3&gt;
  
  
  More secrets caught
&lt;/h3&gt;

&lt;p&gt;Here is a &lt;code&gt;config/production.env&lt;/code&gt; file and what ends up in the pack:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# input&lt;/span&gt;
&lt;span class="nv"&gt;DB_PASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;hunter2hunter2
&lt;span class="nv"&gt;GITHUB_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ghp_EXAMPLE_NOT_A_REAL_TOKEN
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;SECRET_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;changeme-changeme
&lt;span class="nv"&gt;DB_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;postgres://app:hunter2hunter2@db.internal:5432/app

&lt;span class="c"&gt;# output&lt;/span&gt;
&lt;span class="nv"&gt;DB_PASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;REDACTED:SECRET&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="nv"&gt;GITHUB_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;REDACTED:SECRET&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="kd"&gt;export&lt;/span&gt; &lt;span class="nv"&gt;SECRET_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;REDACTED:SECRET&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="nv"&gt;DB_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;postgres://app:&lt;span class="o"&gt;[&lt;/span&gt;REDACTED:SECRET&lt;span class="o"&gt;]&lt;/span&gt;@db.internal:5432/app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Prefixed keys (&lt;code&gt;DB_PASSWORD&lt;/code&gt;, &lt;code&gt;GITHUB_TOKEN&lt;/code&gt;) and shell &lt;code&gt;export KEY=value&lt;/code&gt; lines are matched, including hex and UUID values. In a connection string only the password goes. The user name and host stay, because "which database" is useful context and not a secret.&lt;/p&gt;

&lt;p&gt;Quoted keys in JSON and YAML are covered too:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"admin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"password"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"[REDACTED:SECRET]"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So are HTTP Basic auth and &lt;code&gt;curl -u&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -u deploy:&lt;span class="o"&gt;[&lt;/span&gt;REDACTED:SECRET&lt;span class="o"&gt;]&lt;/span&gt; https://ci.example.com/api
-H &lt;span class="s2"&gt;"Authorization: Basic [REDACTED:SECRET]"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Two bypasses closed
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;UTF-16 files.&lt;/strong&gt; PowerShell 5.1 writes UTF-16 by default. Those files used to slip past redaction. They no longer do.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;*.env&lt;/code&gt; and &lt;code&gt;*.env.*&lt;/code&gt; files.&lt;/strong&gt; A name like &lt;code&gt;production.env&lt;/code&gt; is now treated as an env file. JS/TS modules such as &lt;code&gt;app.env.ts&lt;/code&gt; are still treated as code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The high-entropy check also stopped skipping secrets on long lines that only look minified, and known key prefixes (&lt;code&gt;ghp_&lt;/code&gt;, &lt;code&gt;sk-&lt;/code&gt;, &lt;code&gt;AKIA&lt;/code&gt;) are never exempt.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code references stay intact
&lt;/h3&gt;

&lt;p&gt;This is the part that changes what agents see. In a source file, a value that is a reference, a type or a call is left as it is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/auth.ts, after redaction&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;secret&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SECRET&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;login&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;OPENAI_API_KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'[REDACTED:KEY]'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"postgres://app:[REDACTED:SECRET]@db.internal:5432/app"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# app/config.py, after redaction&lt;/span&gt;
&lt;span class="n"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;PASSWORD&lt;/span&gt;
&lt;span class="n"&gt;secret_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"[REDACTED:SECRET]"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rule is simple to state. A quoted literal or an opaque value is redacted. An identifier, member access, type or call is not, because it is not the secret. It is where the secret comes from. Outside source files, everything is redacted as before.&lt;/p&gt;

&lt;p&gt;Redaction also keeps the original separator and quotes now. 3.0 wrote &lt;code&gt;OPENAI_API_KEY=[REDACTED:KEY]&lt;/code&gt;. 3.1 writes &lt;code&gt;OPENAI_API_KEY = '[REDACTED:KEY]'&lt;/code&gt;, so redacted JSON and YAML stay valid. If you match the old form anywhere, update it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fail closed
&lt;/h3&gt;

&lt;p&gt;The Chrome companion gets its context from a loopback bridge on &lt;code&gt;127.0.0.1&lt;/code&gt;. Before v3.1, if redaction threw, the bridge could still send the context, and a secret in the project primer could reach a browser chat.&lt;/p&gt;

&lt;p&gt;Now the bridge stops:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;500 {"error": "redaction_failed", "detail": "Secret redaction failed; context withheld."}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No context is better than unredacted context. That is the rule for every path that leaves the repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  Custom rules apply everywhere
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;tokencap.security.yaml&lt;/code&gt; now applies to task packs, review packs and constitution artifacts as well. One invalid &lt;code&gt;customRules&lt;/code&gt; entry no longer discards the whole file, and an inline &lt;code&gt;# comment&lt;/code&gt; no longer switches a setting off.&lt;/p&gt;

&lt;p&gt;To check your own generated output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tokencap analyze security scan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It no longer reports &lt;code&gt;[REDACTED:*]&lt;/code&gt; markers as leaks, and it never writes secret prefixes into its report.&lt;/p&gt;

&lt;p&gt;The full list of redaction fixes is in the v3.1 changelog. Docs and install: tokencap.vansharora.app&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devtools</category>
      <category>vscode</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Budget-Exact Context Packing: Render First, Then Charge</title>
      <dc:creator>VANSH ARORA</dc:creator>
      <pubDate>Wed, 18 Nov 2026 15:53:12 +0000</pubDate>
      <link>https://dev.to/vansharora21/budget-exact-context-packing-render-first-then-charge-png</link>
      <guid>https://dev.to/vansharora21/budget-exact-context-packing-render-first-then-charge-png</guid>
      <description>&lt;p&gt;A task pack has a token budget. TokenCap's v3.1 packer is built around one rule: a file costs what it renders, not what we estimated it would cost. This post walks through how that works in &lt;code&gt;src/pack/fitSections.js&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  The problem with estimates
&lt;/h3&gt;

&lt;p&gt;The older allocator assigned each file a compression level before any content existed. A file reserved as "whole" but later demoted, or spanned down to 10% of its size, left its reservation unused. Budget was lost to bookkeeping.&lt;/p&gt;

&lt;p&gt;The new packer renders files in rank order and subtracts the real token count of each rendered section from the remaining budget.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pass 1: code, with a per-file allowance
&lt;/h3&gt;

&lt;p&gt;Each file gets an allowance that scales with its relevance score. The best match may take up to 18% of the budget. Weaker matches get proportionally less, with a floor of 500 tokens. This stops one large file from taking the budget that five medium ones needed.&lt;/p&gt;

&lt;p&gt;If the whole file fits its allowance, it ships whole. If not, it ships spans.&lt;/p&gt;

&lt;h3&gt;
  
  
  Spans around the rarest terms
&lt;/h3&gt;

&lt;p&gt;Every line that contains a query term gets a score. The score is not how many query terms it contains. It is how rare those terms are inside this file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rarity(term) = log(1 + totalLines / linesContainingTerm)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A term on every other line of a file is noise for that file. A term on one line is a signal. Lines are taken best-first until the allowance is used.&lt;/p&gt;

&lt;p&gt;Around each chosen line, the packer shows a window of 6 lines before and 10 after. The file's import header is kept, up to a quarter of the line allowance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Whole-function spans
&lt;/h3&gt;

&lt;p&gt;Windows cut functions in half, and a half function is hard to edit correctly. So when the matching line is inside a function of 60 lines or fewer, the whole function is shown instead of the window.&lt;/p&gt;

&lt;p&gt;Function boundaries come from the Tree-sitter parser when the grammar is loaded, with a pattern-based fallback otherwise. A function longer than 60 lines gets its signature line kept, so the window still shows which function it belongs to.&lt;/p&gt;

&lt;p&gt;v3.1 also fixed grammar loading on Node 20. Grammars were loaded all at once, and that left only Rust parseable. JavaScript, TypeScript, Python, Go and Java silently fell back to text heuristics for boundaries. They now load one at a time, and packs are identical across Node 18 and 20.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pass 2 and pass 3
&lt;/h3&gt;

&lt;p&gt;Whatever budget is left after pass 1 is spent showing spanned files whole, best match first.&lt;/p&gt;

&lt;p&gt;Files that did not fit as code get, in order of preference, a structural outline, a summary, or a single reference line. You still know they exist and can ask for them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reference-only files
&lt;/h3&gt;

&lt;p&gt;Files that score under 15% of the best match skip code entirely. They go straight to a reference line under "Referenced Files": path, score and size. A file that weakly matches is context, not an answer, and showing its code costs budget the strong matches need.&lt;/p&gt;

&lt;h3&gt;
  
  
  Protected task budget
&lt;/h3&gt;

&lt;p&gt;The Chrome companion's task packs carry two extra sections: a project primer for a cold chat, and a focus brief listing the selected files and why they were chosen. Both are bounded separately. The primer gets at most 1,400 tokens or 20% of the budget, the focus brief at most 600 tokens or 16%, and source code gets the rest. On small model budgets, orientation text cannot displace the code you asked about.&lt;/p&gt;

&lt;h3&gt;
  
  
  Running it
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tokencap ask &lt;span class="s2"&gt;"cookie fallback"&lt;/span&gt; --budget 8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The default budget is 12,000 tokens. Spanned files are labeled in their header, for example &lt;code&gt;span: 48/612 lines&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the benchmark shows
&lt;/h3&gt;

&lt;p&gt;On the &lt;code&gt;benchmarks/fair/&lt;/code&gt; set of 100 real commits across nine repositories, the task pack held the needed files as code 87% of the time, at a median 18.9x fewer tokens than reading every matching file. Reading every matching file finds more, 96%. Spans also miss edits: on average 73% of the lines a commit changed were in the pack, and 56-58% on the repositories with very large files. No model is called in this benchmark, so it measures retrieval and packing, not answer quality. The full limits are in &lt;code&gt;docs/HONEST-NUMBERS.md&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;More: tokencap.vansharora.app&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devtools</category>
      <category>vscode</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Re-Ranking Context with Explicit Feedback, Without Letting It Take Over</title>
      <dc:creator>VANSH ARORA</dc:creator>
      <pubDate>Tue, 17 Nov 2026 12:09:16 +0000</pubDate>
      <link>https://dev.to/vansharora21/re-ranking-context-with-explicit-feedback-without-letting-it-take-over-3np6</link>
      <guid>https://dev.to/vansharora21/re-ranking-context-with-explicit-feedback-without-letting-it-take-over-3np6</guid>
      <description>&lt;p&gt;The previous post covered TokenCap's local learning ledger: a file of explicit judgments about context packs. This one covers what reads it. &lt;code&gt;tokencap ask "&amp;lt;task&amp;gt;" --adaptive&lt;/code&gt; uses that evidence to re-rank the files retrieval found. It is opt-in, it is bounded, and it explains itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  Running it
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tokencap ask &lt;span class="s2"&gt;"invoice rounding"&lt;/span&gt; --adaptive
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before the usual task-context summary, the CLI prints one extra line. It says whether matching evidence was found and how many events were used, and it confirms that all baseline candidates were preserved. With no matching feedback, it says "no matching explicit evidence" and no file is boosted.&lt;/p&gt;

&lt;h3&gt;
  
  
  Which feedback counts
&lt;/h3&gt;

&lt;p&gt;The ranking code lives in &lt;code&gt;src/learning/adaptiveRank.js&lt;/code&gt;. A ledger event is considered only if its task has the same subject as the current task.&lt;/p&gt;

&lt;p&gt;Both task labels are stemmed and stripped of function words and generic task words: &lt;code&gt;fix&lt;/code&gt;, &lt;code&gt;bug&lt;/code&gt;, &lt;code&gt;add&lt;/code&gt;, &lt;code&gt;update&lt;/code&gt;, &lt;code&gt;refactor&lt;/code&gt;, &lt;code&gt;review&lt;/code&gt;, &lt;code&gt;implement&lt;/code&gt;, &lt;code&gt;workflow&lt;/code&gt; and similar. What remains is the subject. Two tasks match when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;one subject is contained in the other ("auth" and "auth flow"), or&lt;/li&gt;
&lt;li&gt;at least half of their combined subject terms are shared.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A single shared word between two longer tasks is not enough. So "fix the login bug" does not pull in evidence from "fix the payment bug", and "invoice rounding" does match "rounding in invoice totals".&lt;/p&gt;

&lt;h3&gt;
  
  
  What gets boosted
&lt;/h3&gt;

&lt;p&gt;Two kinds of evidence produce a boost:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;files selected in a pack you marked &lt;code&gt;helped&lt;/code&gt; (+0.75 per matching event)&lt;/li&gt;
&lt;li&gt;files you reported missed, whatever the outcome (+0.5 per matching event)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Files of neutral or harmful packs are never boosted. The total boost per file is capped at 2. A file with many helpful reports still cannot outrun a much stronger retrieval match by feedback alone.&lt;/p&gt;

&lt;h3&gt;
  
  
  What it never does
&lt;/h3&gt;

&lt;p&gt;It never adds a file. The boost applies only to files already in the baseline candidate list. A missed file that retrieval did not find at all is not inserted. Feedback is not a back door into the pack.&lt;/p&gt;

&lt;p&gt;It never removes one either. Every baseline candidate is still in the result, and the output includes &lt;code&gt;candidatesPreserved&lt;/code&gt;. Each re-ranked result also keeps its &lt;code&gt;baselineRank&lt;/code&gt; and &lt;code&gt;baselineRelevanceScore&lt;/code&gt;, plus an &lt;code&gt;explicit-feedback&lt;/code&gt; match reason when a boost applied. Run with &lt;code&gt;--json&lt;/code&gt; and you can see exactly what moved and why.&lt;/p&gt;

&lt;h3&gt;
  
  
  Inspecting the evidence
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tokencap analyze --learning
tokencap analyze --patterns
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;--learning&lt;/code&gt; lists recent events and outcome counts. &lt;code&gt;--patterns&lt;/code&gt; reports file pairs that appeared together in two or more packs you judged helpful or harmful. Neutral records are left out, including Missed reports from the companion. A pattern is advisory. It is not a dependency edge and not a rule, and nothing acts on it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Quality gates
&lt;/h3&gt;

&lt;p&gt;Two npm scripts test the feature itself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run eval:adaptive
npm run eval:ledger
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;eval:adaptive&lt;/code&gt; runs a versioned, controlled corpus. For each case it compares baseline and adaptive recall within the top-K window, and the tokens needed to cover every expected file. It fails if adaptive recall drops below baseline on any case, if candidates are not preserved, or if the average token saving is below the corpus minimum.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;eval:ledger&lt;/code&gt; runs a held-out check on your own repository's feedback, to see whether the boosts hold up on records they were not tuned on. It needs 20 or more records.&lt;/p&gt;

&lt;p&gt;The controlled corpus is a regression gate, not a benchmark claim. It tells us the re-ranker did not break recall. It does not tell you how much better your packs will get.&lt;/p&gt;

&lt;p&gt;More: tokencap.vansharora.app&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devtools</category>
      <category>vscode</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Designing a Local Learning Ledger with No Transcripts and No Telemetry</title>
      <dc:creator>VANSH ARORA</dc:creator>
      <pubDate>Thu, 12 Nov 2026 15:29:16 +0000</pubDate>
      <link>https://dev.to/vansharora21/designing-a-local-learning-ledger-with-no-transcripts-and-no-telemetry-43k6</link>
      <guid>https://dev.to/vansharora21/designing-a-local-learning-ledger-with-no-transcripts-and-no-telemetry-43k6</guid>
      <description>&lt;p&gt;TokenCap builds task-scoped context packs for AI coding agents. Retrieval is good but not perfect, so v3.1 adds a way to tell it when a pack was right or wrong. The constraint we kept throughout: the ledger records only explicit, bounded evidence, and it records it locally.&lt;/p&gt;

&lt;h3&gt;
  
  
  Recording a judgment
&lt;/h3&gt;

&lt;p&gt;After reviewing a pack, record what happened:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tokencap analyze --learning --outcome helped \
  --task &lt;span class="s2"&gt;"invoice rounding"&lt;/span&gt; \
  --files src/billing/invoice.js,src/billing/round.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the pack left something out:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tokencap analyze --learning --outcome neutral \
  --task &lt;span class="s2"&gt;"invoice rounding"&lt;/span&gt; \
  --missing src/billing/currency.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CLI confirms what it did and what it did not do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Recorded explicit focus-feedback (helped). Local only; no automatic behavior changed.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;--outcome&lt;/code&gt; accepts &lt;code&gt;helped&lt;/code&gt;, &lt;code&gt;neutral&lt;/code&gt; or &lt;code&gt;hurt&lt;/code&gt;. Anything else is rejected.&lt;/p&gt;

&lt;h3&gt;
  
  
  What a record contains
&lt;/h3&gt;

&lt;p&gt;Each event in &lt;code&gt;.tokencap/learning/ledger.json&lt;/code&gt; has an ID, a timestamp, a kind, a source (&lt;code&gt;cli&lt;/code&gt; or &lt;code&gt;companion&lt;/code&gt;), an outcome, a task label, and two file lists: selected and missing. That is the full schema.&lt;/p&gt;

&lt;p&gt;The bounds are enforced in &lt;code&gt;src/learning/ledger.js&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Task labels are capped at 300 characters, with newlines and tabs collapsed.&lt;/li&gt;
&lt;li&gt;Each file list keeps at most 30 entries, deduplicated.&lt;/li&gt;
&lt;li&gt;Only workspace-relative paths are accepted. Absolute paths, drive letters, UNC paths, &lt;code&gt;~&lt;/code&gt; paths, URL schemes and anything containing &lt;code&gt;..&lt;/code&gt; are dropped.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Redacting the task label
&lt;/h3&gt;

&lt;p&gt;A task label is free text, so it can contain things that should not be stored. Two passes run before it is written:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Paths are scrubbed. A path inside the workspace is rewritten as workspace-relative. A path outside it becomes &lt;code&gt;[path]&lt;/code&gt;. POSIX paths are only matched under system roots such as &lt;code&gt;/Users&lt;/code&gt; or &lt;code&gt;/home&lt;/code&gt;, so an API route like &lt;code&gt;/users/:id&lt;/code&gt; stays readable.&lt;/li&gt;
&lt;li&gt;The label goes through TokenCap's central redaction engine, the same one that redacts packs.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If redaction throws, the label is dropped rather than stored unredacted.&lt;/p&gt;

&lt;h3&gt;
  
  
  What it never does
&lt;/h3&gt;

&lt;p&gt;There is no transcript capture. The ledger does not accept chat history and does not infer outcomes from what an agent did. There is no telemetry; the file stays on disk and nothing reads it over the network. And there are no automatic changes. Recording feedback does not edit rules, the Constitution, or default ranking.&lt;/p&gt;

&lt;p&gt;The ledger is also not shared. Team rules in &lt;code&gt;.tokencap/team/&lt;/code&gt; are meant to be committed. The learning ledger stays ignored with the rest of &lt;code&gt;.tokencap/&lt;/code&gt;, so one developer's judgments do not end up in everyone's history.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reading it back
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tokencap analyze --learning
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prints a count of helpful, neutral and harmful focus events, rule feedback events, and the ten most recent records with their files. Add &lt;code&gt;--json&lt;/code&gt; to get the full report, which states &lt;code&gt;local: true&lt;/code&gt; and &lt;code&gt;automaticChanges: false&lt;/code&gt; in the output itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  The companion signal
&lt;/h3&gt;

&lt;p&gt;The Chrome companion can mark a file Useful or Missed for the current task. It sends that to the local loopback bridge's &lt;code&gt;/feedback&lt;/code&gt; endpoint, which writes the same kind of event with &lt;code&gt;source: "companion"&lt;/code&gt;. The bridge only accepts feedback for a project that has been indexed, named by absolute path.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where the evidence is used
&lt;/h3&gt;

&lt;p&gt;The ledger is input for two opt-in features: &lt;code&gt;tokencap ask "&amp;lt;task&amp;gt;" --adaptive&lt;/code&gt;, which can re-rank candidates using matching feedback, and &lt;code&gt;tokencap analyze --patterns&lt;/code&gt;, which reports file pairs that keep appearing together. Both are covered in the next post. Neither runs unless you ask for it.&lt;/p&gt;

&lt;p&gt;Docs: tokencap.vansharora.app&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devtools</category>
      <category>vscode</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Team Rules for AI Agents, Stored as Append-Only Files in Git</title>
      <dc:creator>VANSH ARORA</dc:creator>
      <pubDate>Wed, 11 Nov 2026 14:37:19 +0000</pubDate>
      <link>https://dev.to/vansharora21/team-rules-for-ai-agents-stored-as-append-only-files-in-git-3cjb</link>
      <guid>https://dev.to/vansharora21/team-rules-for-ai-agents-stored-as-append-only-files-in-git-3cjb</guid>
      <description>&lt;p&gt;Shared project knowledge usually needs a shared place to live. For TokenCap v3.0 we wanted that place to be the repository itself, with no server, no account and no sync service. The result is &lt;code&gt;tokencap analyze team&lt;/code&gt;, and its storage format is the interesting part.&lt;/p&gt;

&lt;h3&gt;
  
  
  The layout
&lt;/h3&gt;

&lt;p&gt;Everything lives under &lt;code&gt;.tokencap/team/&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.tokencap/team/
  team.json
  rules/rule-&amp;lt;id&amp;gt;.json
  decisions/decision-&amp;lt;id&amp;gt;.json
  approvals/approval-&amp;lt;id&amp;gt;.json
  profiles/&amp;lt;hash&amp;gt;.json
  adrs/adr-&amp;lt;hash&amp;gt;.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;team.json&lt;/code&gt; holds the team name and a schema version. Every rule, decision and approval is its own file, named by a random UUID. A record holds its text, author and creation time. Nothing else is stored.&lt;/p&gt;

&lt;h3&gt;
  
  
  The commands
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tokencap analyze team init --name &lt;span class="s2"&gt;"Platform"&lt;/span&gt;
tokencap analyze team rule --author &lt;span class="s2"&gt;"Ava"&lt;/span&gt; --text &lt;span class="s2"&gt;"Changes to auth require review."&lt;/span&gt;
tokencap analyze team approve-rule --id &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;rule-id&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; --author &lt;span class="s2"&gt;"Ben"&lt;/span&gt;
tokencap analyze team decision --author &lt;span class="s2"&gt;"Ava"&lt;/span&gt; --text &lt;span class="s2"&gt;"Use local Git records."&lt;/span&gt;
tokencap analyze team profile --author &lt;span class="s2"&gt;"Ava"&lt;/span&gt; --text &lt;span class="s2"&gt;"Owns authentication."&lt;/span&gt;
tokencap analyze team sync-adrs
tokencap analyze team status --json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each write prints the same reminder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Team intelligence: rule complete. Commit .tokencap/team/ to share it through Git.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;TokenCap never runs that commit for you. You do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add .tokencap/team .gitignore
git commit -m &lt;span class="s2"&gt;"chore: share TokenCap team intelligence"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why one file per record
&lt;/h3&gt;

&lt;p&gt;The obvious design is a single &lt;code&gt;rules.json&lt;/code&gt; with an array in it. It works until two people add a rule on two branches. Both edit the same lines of the same file, and the merge stops for a human.&lt;/p&gt;

&lt;p&gt;With one file per record, Ava's rule and Carol's rule are different files with different names. Git merges both branches cleanly because neither branch touched a file the other changed.&lt;/p&gt;

&lt;p&gt;Approvals follow the same idea. &lt;code&gt;approve-rule&lt;/code&gt; does not edit the rule. It writes a new &lt;code&gt;approval-&amp;lt;id&amp;gt;.json&lt;/code&gt; that points at the rule's ID. &lt;code&gt;status&lt;/code&gt; reads every approval and reports each rule as &lt;code&gt;proposed&lt;/code&gt; or &lt;code&gt;accepted&lt;/code&gt;, with the list of approvers. A rule with two approvals has two approval files, and the Git log shows when each one arrived.&lt;/p&gt;

&lt;p&gt;Records are never rewritten after creation. The one exception is profiles: each contributor has one profile file, and &lt;code&gt;profile&lt;/code&gt; replaces it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting Git to see the directory
&lt;/h3&gt;

&lt;p&gt;Many repositories ignore &lt;code&gt;.tokencap/&lt;/code&gt; entirely, since most of it is generated. &lt;code&gt;analyze team init&lt;/code&gt; and &lt;code&gt;analyze team status&lt;/code&gt; add a managed block to &lt;code&gt;.gitignore&lt;/code&gt; that re-includes only &lt;code&gt;.tokencap/team/&lt;/code&gt;. In v3.0 the block re-included more than that, so &lt;code&gt;git add&lt;/code&gt; could pick up generated artifacts. v3.1 narrowed it, and running &lt;code&gt;init&lt;/code&gt; or &lt;code&gt;status&lt;/code&gt; rewrites an old block in place.&lt;/p&gt;

&lt;h3&gt;
  
  
  What it does not do
&lt;/h3&gt;

&lt;p&gt;TokenCap records evidence. It does not block a commit when a rule is unapproved, and it does not resolve a disagreement between two people. If two engineers propose contradicting rules, both files exist until the team decides what to do about them. That decision is a conversation, and then a commit.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sync-adrs&lt;/code&gt; copies your existing architecture decision records into &lt;code&gt;adrs/&lt;/code&gt;, one file per ADR, keyed by a hash of its content. Running it twice adds nothing new.&lt;/p&gt;

&lt;p&gt;The whole feature is files plus Git. Review it in a pull request like any other change.&lt;/p&gt;

&lt;p&gt;Docs and install: tokencap.vansharora.app&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devtools</category>
      <category>vscode</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
