MemFlow — AI Context & Token Analyzer (VS Code extension)AI Context & Token Analyzer by LamoonAGI. Analyze context waste and token costs before you pay for them. MemFlow analyzes the current file or selection and shows estimated token savings. Usage is attributed to your LamoonAGI workspace and appears on your dashboard.
Quickstart
To remove the key, run MemFlow: Clear API Key. To revoke it for good, use the API keys page on the website. Using
|
| Command | ID | Legacy alias |
|---|---|---|
| MemFlow: Set API Key | memflow.setApiKey |
lamoonagi.setApiKey |
| MemFlow: Clear API Key | memflow.clearApiKey |
lamoonagi.clearApiKey |
| MemFlow: Analyze Selection/File | memflow.analyze |
lamoonagi.analyze |
The legacy lamoonagi.* IDs still work, so existing keybindings and scripts keep running. A key saved by the earlier "LamoonAGI Context VMM" build is moved to the new SecretStorage entry the first time you run an analysis.
Settings
| Setting | Default | Notes |
|---|---|---|
memflow.apiBaseUrl |
https://api.lamoonagi.com |
Must be https://. Plain http:// is accepted only for localhost (local gateway on port 8100). |
lamoonagi.apiBaseUrl |
https://api.lamoonagi.com |
Deprecated. Read only when memflow.apiBaseUrl is not set. |
There are no other settings, and no secret is ever stored in settings.
What is sent
POST {apiBaseUrl}/v1/chat/completionswithAuthorization: Bearer lago_…. The body contains the selected text or the whole file, plus its relative file name and language ID. Content is capped at 400,000 characters.- The gateway runs the Context VMM optimizer and returns
x_cvmmmetadata (tokens before and after, estimated savings). It uses the server-side model key; your key is never forwarded upstream. - Savings shown in VS Code are estimates. Verified savings and USD values are shown separately on the dashboard.
Develop
pnpm --filter memflow install
pnpm --filter memflow test # vitest (pure client)
pnpm --filter memflow build # tsc → out/
pnpm --filter memflow package # vsce package → memflow-0.1.0.vsix
code --install-extension memflow-0.1.0.vsix
The Marketplace ID is lamoonagi.memflow. It matches the web dashboard's default "Install Extension" link (CONTEXT_VMM_EXTENSION_URL overrides it).
Design note: future OIDC Authorization Code + PKCE (not implemented)
Phase 1 uses pasted API keys to avoid delaying the launch (spec §19–20). The planned migration:
- Register a public authentik OIDC client,
lamoonagi-vscode, with no client secret. Use PKCE S256 (already supported by our authentik instance) and the redirect URIvscode://lamoonagi.memflow/auth-callback, plus a loopbackhttp://127.0.0.1:<port>/callbackas a fallback. - Implement
vscode.AuthenticationProvider(idlamoonagi):- generate
code_verifier,stateandnonce; - open the authorize URL with
vscode.env.openExternal; - receive the code with
window.registerUriHandler; - exchange it at the token endpoint.
- generate
- account-api gets an endpoint that exchanges a validated access token (issuer, signature via JWKS, audience
lamoonagi-vscode, expiry) for a short-lived, workspace-scopedlago_token or verifies it directly. That keeps the gateway's singlelago_verification path unchanged. - Store the refresh token in SecretStorage. Revoke it on sign-out.
- Keep Set API Key for CI and headless use. Nothing in the business tables changes: identity is still
auth_provider + auth_subject.