Files
pxpipe/package.json
T
teamchong f91c149d05 Port to TypeScript with dual Node + Cloudflare Workers targets
Runtime is pure Web Standard APIs (fetch, Request, Response, Uint8Array,
CompressionStream, crypto.subtle, btoa) — zero runtime dependencies.

Core (src/core/, runs identically on Node 18+ and Workers):
  - atlas.ts     auto-generated 9x15 JBM glyph atlas, base64-inlined (17KB)
  - png.ts       minimal grayscale PNG encoder via CompressionStream
  - render.ts    text → packed PNG, soft-wraps at 100 cols, ≤1568px tall
  - transform.ts request body rewriter (system + tool docs → image blocks)
  - proxy.ts     fetch-handler that transforms then forwards to Anthropic
  - types.ts     Anthropic Messages API types we touch

Adapters:
  - src/node.ts     node:http server + CLI flag parsing
  - src/worker.ts   export default { fetch } for wrangler dev/deploy

Build tooling:
  - scripts/gen-atlas.ts   @napi-rs/canvas → atlas.ts (build-time only)
  - scripts/build.mjs      esbuild Node bundle; wrangler handles Worker
  - tsconfig.json          strict, ES2022, Workers types

Tests (vitest): 8 passing — PNG signature, base64 round-trip, single +
multi-image renders, transform no-op + compress paths, billing-line strip,
tool fold + stub.

E2E smoke: 16K char system → 2 PNGs (36KB) → mock upstream, 34ms.

Next: replace docs, then verify byte-output parity against legacy/python.
2026-05-18 15:33:23 -04:00

64 lines
1.5 KiB
JSON

{
"name": "pixelpipe",
"version": "0.2.0",
"description": "Token-saving proxy for Claude Code: renders system prompt + tool definitions as images, achieving 65-73% token savings on Opus 4.7 while preserving 100% reasoning quality. Runs on Node and Cloudflare Workers.",
"type": "module",
"bin": {
"pixelpipe": "bin/cli.js"
},
"exports": {
".": {
"types": "./dist/core/proxy.d.ts",
"import": "./dist/core/proxy.js"
},
"./node": {
"types": "./dist/node.d.ts",
"import": "./dist/node.js"
},
"./worker": {
"types": "./dist/worker.d.ts",
"import": "./dist/worker.js"
}
},
"files": [
"bin/",
"dist/",
"README.md",
"LICENSE"
],
"scripts": {
"build": "node scripts/build.mjs",
"build:atlas": "tsx scripts/gen-atlas.ts",
"dev:node": "tsx watch src/node.ts",
"dev:worker": "wrangler dev",
"deploy:worker": "wrangler deploy",
"typecheck": "tsc --noEmit",
"test": "vitest run",
"test:watch": "vitest"
},
"keywords": [
"claude",
"claude-code",
"anthropic",
"proxy",
"token-optimization",
"prompt-cache",
"opus-4-7",
"cloudflare-workers"
],
"engines": {
"node": ">=18"
},
"license": "MIT",
"devDependencies": {
"@cloudflare/workers-types": "^4.20240512.0",
"@napi-rs/canvas": "^0.1.53",
"@types/node": "^20.12.0",
"esbuild": "^0.21.0",
"tsx": "^4.10.0",
"typescript": "^5.4.0",
"vitest": "^1.6.0",
"wrangler": "^3.60.0"
}
}