Pi-native TypeScript port – just a heads-up!#8
Open
eSaadster wants to merge 1 commit into
Open
Conversation
Collaborator
|
Genius! |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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.
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
typer→commander,asyncio→async/await, andpytest→vitest. 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
esbuildbundle, the pi integration is a native TS extension instead of a subprocess hop, and the config usessmol-toml/better-sqlite3instead of Python stdlib equivalents. SameTOKEN_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.