feat: Implement Endless Mode Token Economics Calculator

- Added a new script to simulate token savings from Endless Mode using real observation data.
- Introduced functions to calculate token costs with and without Endless Mode, showcasing the differences in context handling.
- Enhanced output to display detailed token usage statistics and potential savings at scale.
- Integrated assumptions for user activity to estimate weekly and annual token savings.
- Updated worker-utils to automatically start the worker using PM2 if not running, improving service reliability.
This commit is contained in:
Alex Newman
2025-11-17 14:04:47 -05:00
parent 95edf31c14
commit 812de2940d
8 changed files with 407 additions and 88 deletions
+5 -5
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env node
import{execSync as u}from"child_process";import{join as r}from"path";import{homedir as s}from"os";import{existsSync as l}from"fs";import i from"path";import{homedir as a}from"os";import{existsSync as c,readFileSync as p}from"fs";function n(){try{let e=i.join(a(),".claude-mem","settings.json");if(c(e)){let t=JSON.parse(p(e,"utf-8")),o=parseInt(t.env?.CLAUDE_MEM_WORKER_PORT,10);if(!isNaN(o))return o}}catch{}return parseInt(process.env.CLAUDE_MEM_WORKER_PORT||"37777",10)}var m=r(s(),".claude","plugins","marketplaces","thedotmack"),d=r(m,"node_modules");l(d)||(console.error(`
import{execSync as p}from"child_process";import{join as r}from"path";import{homedir as i}from"os";import{existsSync as d}from"fs";import n from"path";import{homedir as a}from"os";import{existsSync as c,readFileSync as m}from"fs";import{fileURLToPath as l}from"url";var u=l(import.meta.url),w=n.dirname(u);function s(){try{let t=n.join(a(),".claude-mem","settings.json");if(c(t)){let o=JSON.parse(m(t,"utf-8")),e=parseInt(o.env?.CLAUDE_MEM_WORKER_PORT,10);if(!isNaN(e))return e}}catch{}return parseInt(process.env.CLAUDE_MEM_WORKER_PORT||"37777",10)}var f=r(i(),".claude","plugins","marketplaces","thedotmack"),h=r(f,"node_modules");d(h)||(console.error(`
---
\u{1F389} Note: This appears under Plugin Hook Error, but it's not an error. That's the only option for
user messages in Claude Code UI until a better method is provided.
@@ -17,15 +17,15 @@ Dependencies have been installed in the background. This only happens once.
Thank you for installing Claude-Mem!
This message was not added to your startup context, so you can continue working as normal.
`),process.exit(3));try{let e=r(s(),".claude","plugins","marketplaces","thedotmack","plugin","scripts","context-hook.js"),t=u(`node "${e}" --colors`,{encoding:"utf8"}),o=n();console.error(`
`),process.exit(3));try{let t=r(i(),".claude","plugins","marketplaces","thedotmack","plugin","scripts","context-hook.js"),o=p(`node "${t}" --colors`,{encoding:"utf8"}),e=s();console.error(`
\u{1F4DD} Claude-Mem Context Loaded
\u2139\uFE0F Note: This appears as stderr but is informational only
`+t+`
`+o+`
\u{1F4AC} Feedback & Support
https://github.com/thedotmack/claude-mem/discussions/110
\u{1F4FA} Watch live in browser http://localhost:${o}/
`)}catch(e){console.error(`\u274C Failed to load context display: ${e}`)}process.exit(3);
\u{1F4FA} Watch live in browser http://localhost:${e}/
`)}catch(t){console.error(`\u274C Failed to load context display: ${t}`)}process.exit(3);