Retro comic UI + Cloudflare-native, agentic graphic-comic generation workflow.
just devThis runs:
bun run buildbun run db:init:localwrangler pages dev dist --ip 127.0.0.1 --port 8788 -b TEST_SECRET=local-secret -b AUTO_GENERATE_ON_READ=1 -b ALLOW_LOCAL_BOOTSTRAP=1
For local real Workers AI image generation, use:
just dev-aijust dev-uiKeep just dev running, then:
just test-workflow-dryFor a real generation run:
just test-workflowwrangler.toml contains:
- Pages build output config (
dist) - D1 binding:
DB - R2 binding:
COMICS_BUCKET - Workers AI binding in production env:
env.production.ai - default production model vars (
SCRIPT_MODEL_A,SCRIPT_MODEL_B,TOPIC_MODEL)
wrangler.cron.toml contains:
- Worker entrypoint (
functions/_worker.js) - cron trigger (
0 9 * * *) - the same D1/R2/KV/AI bindings used by scheduled generation
See .env.example for full list.
Core values:
TEST_SECRETfor/api/test-generateAUTO_GENERATE_ON_READ(1to auto-create today's comic when/api/todayis empty)ALLOW_LOCAL_BOOTSTRAP(1to create local SVG fallback comic ifenv.AIis unavailable)ENABLE_PUSH_NOTIFICATIONS(1to enable real VAPID push delivery)VAPID_PRIVATE_KEY(JWK JSON string generated bynpx @pushforge/builder vapid)VAPID_SUBJECT(mailto:orhttps:contact string for VAPID)SCRIPT_MODEL_A(default@cf/deepseek-ai/deepseek-r1-distill-qwen-32b)SCRIPT_MODEL_B(default@cf/meta/llama-3.3-70b-instruct-fp8-fast)TOPIC_MODEL(default@cf/qwen/qwen3-30b-a3b-fp8)
Main implementation:
functions/lib/agentic-comic-workflow.ts
Workflow:
- Random panel count (
1..4) - Random cast size + cast selection from
cast/characters.json - Three topic suggestions
- Standardized comic-script prompt generation
- Two Workers AI writing variants (head-to-head), rendered server-side to SVG
- Artifact retention in R2
- Metadata retention in D1 (
workflow_runs)
Cast assets:
- Descriptions:
cast/characters.json - Reference samples:
public/cast/samples/*.svg
GET /api/todayGET /api/day?day=YYYY-MM-DDGET /api/archive?page=1&limit=20GET /api/workflow?day=YYYY-MM-DD&include_artifacts=1POST /api/test-generateSupportsreset=1andrebuild=1for day-level admin repair.POST /api/votePOST /api/subscribeDELETE /api/subscribe
The cron handler is exported in:
functions/_worker.js
Important: a top-level export async function scheduled(...) is present so Cron Triggers are handled correctly.
To test scheduled events locally:
just dev-cronIn another terminal:
just test-cronIf AI binding is not configured locally, cron trigger will run and fail with an explicit Workers AI binding error (expected).
For production deployment:
- Deploy Pages with
bun run deploy:pages - Deploy the scheduled Worker with
bun run deploy:cron
Real image generation requires an AI binding (env.AI).
For local real-generation testing:
- set
CLOUDFLARE_API_TOKEN - run:
just dev-aiIf no AI binding is present, dry_run=1 still works for prompt workflow testing.
A hardened skill spec for delegated analysis/orchestration now lives at:
skills/principal-cognitive-systems-architect/SKILL.mdskills/principal-cognitive-systems-architect/references/*skills/principal-cognitive-systems-architect/scripts/*
Useful commands:
just architect-init "stabilize comic publish and voting flow"
just architect-summary .agent-runs/run-YYYYMMDDTHHMMSSZThis project uses the MIT License.
See LICENSE.