Skip to content

Pi-native TypeScript port – just a heads-up!#8

Open
eSaadster wants to merge 1 commit into
DFKHelper:mainfrom
eSaadster:ts-port-note
Open

Pi-native TypeScript port – just a heads-up!#8
eSaadster wants to merge 1 commit into
DFKHelper:mainfrom
eSaadster:ts-port-note

Conversation

@eSaadster

Copy link
Copy Markdown
Contributor

Hey! 👋

I forked token-goat into my own repo (pi-token-goat) and have been working on a TypeScript/Node.js port over the past week. Wanted to share what I did in case it is interesting.

Two reasons I did this:

  1. I use pi (a TypeScript-native coding agent). pi is all Node.js under the hood, so every time token-goat needed to fire I was forking a Python subprocess. I figured embedding the whole thing directly into the JS runtime would be snappier — and it gave me an excuse to finally build something non-trivial in TypeScript.

  2. I wanted to see if I could take a substantial real-world tool and port it to a language / framework I am still learning. I am really more of a Python + bash person by trade, and TypeScript + Node was outside my comfort zone. This started as "how hard could it be?" and turned into a couple weeks of reading source, chasing edge cases, and figuring out how to map things like typercommander, asyncioasync/await, and pytestvitest. It was humbling and I learned a ton.

What works: All 80+ CLI commands, bash output compression (130+ filters), code/session/skill compaction, image shrinking, read optimization, the hook system — all ported line-by-line. ~280 tests so far (nowhere near your coverage, but it is a start).

What is different: It runs as a single esbuild bundle, the pi integration is a native TS extension instead of a subprocess hop, and the config uses smol-toml / better-sqlite3 instead of Python stdlib equivalents. Same TOKEN_GOAT_* env vars, same TOML config shape, same defaults.

This is absolutely not meant to replace or compete with the Python original — just a personal port for my own stack and a massive learning experience. I figured I would open a PR so it is on your radar in case anyone ever asks about a Node/TS path, and so I can say I finally sent a PR to something real 😅

Thanks for building token-goat — it has saved me a ridiculous amount of tokens.

@Zelys-DFKH

Zelys-DFKH commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Genius!
I've been working on something that touches a little bit of that. Let me see if I can bring us closer so you can also benefit from the new optimizations I'm pushing out.
I'm actually TS/JS native myself, and was going Python for the same reason as you!

@Zelys-DFKH

Copy link
Copy Markdown
Collaborator

On the latest version, if you use bash at all, you will probably see another 70% context savings on top of what you were seeing before.

I've started to migrate from my TS branch and will incorporate your ideas. Consider contributing here in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants