Bringing a panel of experts in to review or refactor a code base is increasingly realistic.
Here’s what I asked Codex CLI (gpt-5-high
) on my AIPipe repo:
Which of these developers would I bring in to rewrite this repo and why them?
GitHub | Name | Style |
---|---|---|
mbostock | Mike Bostock | low-level primitives and explicit data>element bindings (d3); clean diffs; example-driven; notebook-native workflows. |
sindresorhus | Sindre Sorhus | “tiny, sharp utilities”. Minimal surface area, strong defaults, predictable names (execa , ky , p-queue , globby ). |
lukeed | Luke Edwards | “micro-libs, no fluff”. Single-purpose modules; native ESM; minimal deps; straight-line code. |
rich-harris | Rich Harris | “compiler-as-framework”. Write components; the compiler outputs minimal runtime. Emphasis on DX + shipping less JS. |
tannerlinsley | Tanner Linsley | “headless, type-safe primitives”. Framework-agnostic cores + typed adapters; declarative APIs (Query/Router/Table) with strong devtools. |
kentcdodds | Kent C. Dodds | “user-centric testing”. Avoid implementation details; integration-first tests; pragmatic full-stack co-location patterns. |
addyosmani | Addy Osmani | “performance patterns as first-class code”. Ship less JS; progressive bootstrapping; pattern catalogs (patterns.dev) usable across stacks. |
evanw | Evan Wallace | “tooling as leverage”. Single binary; clear CLI/JS APIs; fast defaults over heavy config. |
davidkpiano | David Khourshid | “formal, visual state”. Event-first, finite machines, visual tools; framework-agnostic. |
antfu | Anthony Fu | “unplugin-everything; DX-first”. Convention over config, on-demand utilities, editor-centric workflows. |
paulirish | Paul Irish | “performance-first, tooling-led frontend”. Begin with a best-practice baseline, then measure and iterate; progressive enhancement, diagnostics. |
sebmck | Sebastian McKenzie | “language-aware tooling”. Compiler-grade transforms; cohesive DX across parse/lint/format. |
jarred-sumner | Jarred Sumner | “integrated runtime thinking”. Batteries-included; prioritize startup/memory; pragmatic Node compat. |
mcollina | Matteo Collina | “measure first; zero-overhead Node”. Schema-driven, plugin-centric, perf-budgeted code; tight JSON/HTTP control. |
developit | Jason Miller | “small framework thinking”. 3kB-class frameworks, compile-free JSX (htm ), pragmatic trade-offs. |
ryansolid | Ryan Carniato | “fine-grained reactivity”. Minimal abstractions around signals; control over reactivity graph; JSX without VDOM. |
I’ll quickly scan the repo to understand its stack, goals, and pain points before recommending a fit.
Recommendation: Tanner Linsley
Why him
src/worker.js:1
, src/providers.js:1
, src/cost.js:1
) become thin wrappers around a stable core API that’s easy to extend and test.What the rewrite would look like
cloudflare-worker
(current), plus node
, bun
, deno
as optional packages.If your goals differ
Why not others (for a full rewrite)
Short answer: pick Tanner to turn AIPipe into a clean, typed, provider-agnostic core with adapters and great devtools, while keeping the runtime and UI minimal.
How would Luke Edwards rewrite this?
Here’s how Luke Edwards would likely tackle a rewrite: split into tiny, focused ESM modules with straight-line code, zero fluff, and minimal runtime branching. Keep the worker thin; push logic into micro-libs you can reuse in Node/Deno/Edge.
Principles
Package Layout
@aipipe/core
: routing, auth, provider dispatch, cost accounting.@aipipe/headers
: update(headers, skip, next)
, cors(req)
.@aipipe/sse
: zero-dep SSE passthrough with incremental JSON capture.@aipipe/auth-jwt
: tiny HS256 JWT sign/verify via WebCrypto or worktop/jwt.@aipipe/cost
: pure functions for token→$ calc; static price tables per provider.@aipipe/store
: storage interface + adapters: memory, CF DO, D1/SQLite.@aipipe/providers/*
: openrouter
, openai
, geminiv1beta
—each a 50–150 line module.@aipipe/adapter-cloudflare
: fetch(req, env)
that calls core.examples/*
: cloudflare-worker
, node-http
, deno
.Core APIs
createRouter({ providers, store, budget, salt })
returns { handle(req, env) }
.createProvider({ transform, parse, cost })
consistent shape for all providers.createStore(storeLike)
expects { add(email,c), sum(email, from,to), set(email,date,c), all() }
.auth.verify(token, secret, saltMap)
returns { email } | { error }
.Request Flow
regexparam
-style matching./proxy/*
, /token
, /usage
, /admin/*
.{limit,days}
inline from config.transform()
, forward fetch, stream passthrough, parse()
for usage hints.content-type
is JSON).@aipipe/sse
flush hook capturing last {model, usage}
.Storage
src/cost.js:1
, but the core never imports CF types.Providers
usage
exists.Auth
jose
with a tiny HS256 module over WebCrypto or worktop/jwt
for Workers.sign(payload, secret)
, verify(token, secret)
. Salt check is a single branch.SSE
data:
.model
and latest usage
; call onFlush({model,usage})
.Tooling & Tests
uvu
per package; memory store for unit, tiny in-process fetch for integration.c8
. Benchmarks optional, simple Node scripts.Example Entrypoint (Cloudflare)
@aipipe/adapter-cloudflare
:
export default { fetch: (req, env) => router.handle(req, env) }
env
scope.Mapping From Current Repo
src/worker.js:1
→ @aipipe/adapter-cloudflare
(fetch) + @aipipe/core
(handle).src/providers.js:1
→ @aipipe/providers/*
+ @aipipe/sse
+ @aipipe/cost
.src/cost.js:1
→ @aipipe/store/cf-do
adapter; interface lives in @aipipe/store
.src/utils.js:1
→ @aipipe/headers
+ @aipipe/auth-jwt
+ @aipipe/dates
(ymd).public/*
static and minimal; move logic out of pages into core/HTTP.Migration Steps
worker
.transform
, parse
, cost
) unchanged.store
interface and shim current Durable Object.This yields a tiny, fast, portable codebase: small files you can read in one screen, minimal deps, straight-line handlers, and adapters that make the same core run on Workers, Node, or Deno without ceremony.
Whose style would best align with the repo as-is?
Luke Edwards, with Sindre Sorhus as a close runner‑up.
Why Luke Edwards aligns best
jose
as a dep (package.json:1
), matching “micro-libs, no fluff.”src/worker.js:1
; helpers are tiny and single-purpose in src/utils.js:1
.transform/parse/cost
(src/providers.js:1
), SSE is a focused 60‑ish line transform, and the Durable Object is a concise store (src/cost.js:1
).Why Sindre Sorhus is runner-up
updateHeaders
, addCors
, ymd
(src/utils.js:1
) and predictable names across providers. The repo, though, is an app/proxy more than a utilities toolkit, so Luke’s micro‑lib, adapter mindset is a tighter fit.Why not others for “as-is” alignment
How would Luke Edwards rewrite this repo if we wanted fewer files and larger files were OK?
Here’s a Luke-Edwards-style rewrite with fewer, larger files: collapse to a single straight-line Worker (plus static assets), keep zero fluff, and minimize deps. It preserves current behavior, just tighter and flatter.
File Layout
src/worker.js
only: includes router, auth, CORS/headers, SSE, providers, pricing tables, and Durable Object.public/*
unchanged.src/pricing.json
if you prefer not to inline the tables; everything else merges.Single-File Structure (sections in order)
import pricing
.sign(payload, secret)
and verify(token, secret)
via WebCrypto. Keep jose
only for Google credential verification, but lazy-load it inside /token
path so it never hits the hot path.updateHeaders
, addCors
, ymd
inlined; pure and tiny.data:
JSON, keep first model
and last usage
, call onFlush
once, pass chunks through.openrouter
, openai
, geminiv1beta
, similarity
each as small inline objects with { transform, parse, cost }
. Keep OpenRouter model cache with a simple TTL local variable.class AIPipeCost
unchanged but in this file; same SQL schema and methods.fetch(request, env)
with early returns for OPTIONS
, /proxy/*
, /token
, /admin/*
, /usage
, else provider dispatch. Straight-line, minimal branches.Key Changes vs Current
src/providers.js
, src/cost.js
, src/utils.js
into src/worker.js:1
. The providers and SSE code from src/providers.js:1
lift verbatim with minor refactors for local references.AIPipeCost
class exactly as in src/cost.js:1
, just moved; wrangler.toml
already points class_name = "AIPipeCost"
, which can live in the main module.jose
for signing/verifying our HS256 JWT with a tiny WebCrypto helper; dynamically import('jose')
only inside /token
for Google JWKS verification. This preserves correctness with minimal cold-start cost.const budget
and const salt
near the top (you can still generate production tokens via /admin/token
).Tiny HS256 Auth (WebCrypto)
async function hmacKey(secret) { return crypto.subtle.importKey('raw', new TextEncoder().encode(secret), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign','verify']); }
async function signHS256(payload, secret) { /* base64url(header).base64url(payload).base64url(sig) */ }
async function verifyHS256(token, secret) { /* split/verify+JSON.parse */ }
Router Flow (straight-line)
OPTIONS
→ return CORS with Access-Control-Max-Age: 86400
.provider
from path; handle /proxy/*
, /token
, /usage
, /admin/*
early.verifyHS256
+ salt check.const { url, headers, error, ...params } = await providers[p].transform({ path, request, env })
fetch(url, { method, headers: updateHeaders(...), ...params })
await addCost(parsed)
. If SSE → pipe through sseTransform(provider, addCost)
.addCors(updateHeaders(...))
.Providers (inline)
openrouter
: lazy model list cache for pricing; compute cost when usage
present or derived.openai
: cost via token table; ensure chat stream sets stream_options.include_usage
.geminiv1beta
: rewrite to x-goog-api-key
, try :countTokens
when needed.similarity
: keep as-is; single POST handler that calls OpenAI embeddings then computes cosine sims.Migration Plan
AIPipeCost
from src/cost.js:1
into src/worker.js
unchanged.updateHeaders
, addCors
, ymd
, and createToken
into the top of src/worker.js
; replace createToken
to use the new HS256 signer.pricing
at the top; update provider cost lookups to reference local tables.sseTransform
and providers
into src/worker.js
.jose
usage for our JWT with the HS256 helpers; keep jose
dynamic import inside /token
only.src/*
files and update imports. wrangler.toml
remains the same.Trade-offs
Net: You get a single, direct, dependency-light Worker that mirrors Luke’s “micro-libs, no fluff” ethos—consolidated into one readable file with straight-line control flow and zero unnecessary abstractions.
Why use a generic coding agent when it can write in an expert’s style?