Skip to content

MVP client-demo readiness: correctness fixes, SQLite drafts, HTTP API, web UI - #1

Open
denl95 wants to merge 20 commits into
mainfrom
mvp-client-demo
Open

MVP client-demo readiness: correctness fixes, SQLite drafts, HTTP API, web UI#1
denl95 wants to merge 20 commits into
mainfrom
mvp-client-demo

Conversation

@denl95

@denl95 denl95 commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

Implements the plan in docs/superpowers/plans/2026-07-15-mvp-client-demo.md (spec: docs/superpowers/specs/2026-07-15-mvp-client-demo-design.md) to make content-creator-agent demo-ready for prospective agency clients.

Correctness fixes

  • Aligned Lumen's brand identity (agents/tests described an accounting SaaS; corrected to the actual AI-agency corpus) across prompts, judge tests, and fixtures
  • Draft word count now computed from content instead of trusting the LLM's self-report
  • Writer/Editor now receive the brief's word_count/channel (previously missing, making the "±10%" rule unenforceable) and the Editor now judges tone against retrieved brand-style excerpts instead of blind
  • Hardened the CLI's human-approval gate (typos no longer silently approve) and added LLM call timeouts
  • Removed dead code (unused prompt builders, an unused tool)

New capabilities

  • Per-run token/cost tracking with a hard budget cap (CostTracker)
  • SQLite drafts database (src/db.ts, bun:sqlite) as the source of truth; Notion publishing is now optional/on-demand rather than the only record, and ./output/ files are opt-in via WRITE_OUTPUT_FILES
  • Per-thread web-search rate limiting (supports concurrent runs)
  • Hono HTTP API (src/server.ts, src/runManager.ts): run creation/status/resume, SSE progress streaming, drafts list/get/publish
  • Single-page web demo UI (public/index.html): brief form, live pipeline progress, plan-approval card, results, drafts library
  • GitHub Actions CI (typecheck + lint + unit tests), updated docs

Post-implementation hardening (found during final review and live end-to-end testing with real API keys, not just unit tests):

  • Fixed a millisecond-timestamp collision in the SSE replay-dedup logic that could silently drop the plan-approval or done event — replaced with a monotonic per-run sequence number
  • Escaped user/LLM-sourced text before innerHTML insertion
  • Added a bounded TTL sweep for in-memory run records and search-rate-limit counters
  • Fixed CostTracker never actually capturing tokens from live LLM calls — each graph node built a fresh RunnableConfig for its inner LLM invocation instead of merging the parent config, silently dropping the graph-level callback. Confirmed via a live run: cost_usd was 0 before the fix, a real non-zero value after.

Test plan

  • bun run typecheck — clean
  • bun run test:unit — 19/19 passing
  • bunx biome ci . — 0 errors
  • Live end-to-end run through the real HTTP API (real OpenAI/Tavily keys, Notion publish disabled): brief → plan approval → writer/editor revision loop → finalized draft persisted to SQLite, with real non-zero cost/token tracking confirmed
  • Manual review of the web UI in a browser (not done in this session — no browser available in the execution environment)

denl95 added 20 commits July 15, 2026 20:18
…oints

Wraps the compiled LangGraph pipeline in a Hono server: src/runManager.ts
drives runs in-memory and streams progress events; src/server.ts exposes
POST/GET /runs, GET /runs/:id/events (SSE), /drafts endpoints, and
POST /drafts/:id/publish. Also calls resetSearchCount(threadId) once a run
reaches a terminal state so the per-thread search-counter map in
src/tools/search.ts doesn't grow unbounded across the server's lifetime.
CostTracker (and any other graph-level callback) was silently dropped
because each node built a fresh RunnableConfig for its inner .invoke()
call instead of merging the config passed into the node. Verified via
a live end-to-end run: cost_usd was 0 before this fix, non-zero after.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant