Skip to content

Latest commit

 

History

History
262 lines (234 loc) · 23.8 KB

File metadata and controls

262 lines (234 loc) · 23.8 KB

Codex Slides — Plan & Spec (living doc)

This is the source of truth for the /loop build. Each iteration: (1) refresh this doc, (2) check every requirement end-to-end against the code (build + run where possible), (3) advance the top open gap in NEXT ACTION. Last updated: 2026-07-10 (iteration 1).

0. Product in one line

Zero-config slide decks by image generation, driven by the local Codex agent — usable as a web app and natively inside Codex (plugin/MCP), with a project system, gen-UI onboarding, conversational + mark editing, deep-research outlines, and PDF/PPTX export.

0.1 Staged full-chain flow (2026-07-10) — the default homepage → deck path

The generation chain is a 6-step staged flow (not a one-shot). The outline is a persisted, editable, confirmable artifact before any pixels are drawn:

  1. Clarify (明确需求): after submit we enter the workspace directly; the RIGHT pane first shows OnboardForm (agent-generated questions, pre-filled + skippable, each single/multi option also takes a free-text custom answer). No separate full-page step.
  2. Search + outline (搜索/写大纲): POST /api/outline (SSE) optionally runs deep research (toggle-controlled, default off), then writes the outline and persists a status:"draft" project. Streams research/outline/project progress.
  3. Edit outline (编辑大纲): OutlineBoard in the right pane — edit title/points, reorder, delete, insert a page between any two (+), add at end; or NL-edit via the left chat (POST /api/projects/[id]/outlinereviseOutline). Debounced PUT persists.
  4. Confirm (确认): a prominent "✓ 生成 N 页幻灯片" bar.
  5. Render (一页页生成): POST /api/projects/[id]/render (SSE) runs the existing per-slide describe+image loop over the draft; status draft → rendering → ready.
  6. Next steps (指引调优): after render, the chat posts clickable suggestion chips.

/project/[id] resumes a draft (status==="draft") straight into step 3. Pipeline split: runGeneration = planOutline + renderProject/api/generate, /api/research, and the Codex MCP plugin keep working unchanged (one-shot). Key files: lib/pipeline.ts (planOutline/renderProject/reviseOutline), lib/deckEdit.ts (streamOutline/streamRender/saveOutline/reviseOutlineChat/readSSE), components/OutlineBoard.tsx, app/page.tsx (idle→work: clarify→outline→deck), components/DeckView.tsx (draft resume), routes api/outline, api/projects/[id]/{outline,render}.

Stack: Next.js 14 (App Router) + React + TypeScript, everything server-side runs on Node.

1. Principles

  • Zero-config: reuse the Codex OAuth token (~/.codex/auth.json); no API key, no .env.
  • Codex is the whole chain: text (outline/copy) and pixels (slides) both via Codex.
  • One agent call per slide (html-video lesson) — never one call for the whole deck.
  • Two front doors: standalone web app, and Codex-native (in-editor browser + MCP tools/skills).
  • Everything is a project: durable, resumable, previewable, editable.

2. Requirement matrix (end-to-end status)

Legend: ✅ done & verified · 🟡 partial · ❌ missing

ID Requirement Status Evidence / gap
R5 Core loop (detect agent → outline → copy → per-slide image → multi-round edit → mark) validated live iter-1 session: 2-slide deck rendered, mark-edit changed a title & removed marks. lib/pipeline.ts, lib/codex-*.ts, lib/agents.ts, lib/prompts.ts
R3.1 Export PDF lib/assemble.ts buildPdf; verified 2.1MB valid PDF
R3.2 Export PPTX lib/assemble.ts buildPptx; verified valid pptx zip
R1.1 Homepage input box app/page.tsx requirement textarea
R1.2 Gen-UI questioning (open-design style): after input, agent asks pre-questions (pages/ratio/theme/content/visual style/materials) as a dynamic form lib/onboard.ts + /api/onboard + components/OnboardForm.tsx + home "✦ Ask me questions". Verified iter-2: a Series-A topic → 6 tailored Qs (pages/aspect/language + category→fundraising-pitch + 4 topic-specific visual styles + content emphasis); answers merge into config+requirement then generate. Materials upload = R1.3 (M3).
R1.3 Gen-UI form supports uploading image materials for consumption lib/materials.ts, /api/materials (+/[id]), components/MaterialTray.tsx in config panel; config.materialIds threaded through pipeline.ts → copied into project + passed as refImages + prompt note. Verified iter-3: uploaded the indigo brand card → generated "Our Company" slide adopted its palette/type/layout.
R1.4 Project system: input → create project → enter project /api/projects (list), /project/[id] workspace (app/project/[id]/page.tsx + components/DeckView.tsx), recent-projects strip + "Open workspace" link on home; persistence lib/store.ts. Verified iter-1.
R1.5 In-project: preview / conversational edit / play / upload materials to tune ✅ preview + per-slide regen + mark; ✅ chat edit (lib/chat.ts + /api/projects/[id]/chat + ChatEditPanel); ✅ Play fullscreen (PlayMode); ✅ re-tune in workspace (iter-9): TemplatePicker + MaterialTray + PATCH /api/projects/[id] + "Apply & regenerate all". Verified: chat "第2页更暖"→[2] / "restyle whole deck"→[1,2]; template switch Swiss→Editorial-Ink visibly transformed a slide.
R2.1 Codex daemon detects codex & integrates (not only standalone web) mcp/server.mjs ensureServer() auto-builds when needed and auto-boots next start (port 4311) if unreachable. scripts/probe-mcp.mjs verifies the tool contract.
R2.2 Open in Codex in-editor browser open_codex_slides returns typed HTML resource links for the normal workspace plus scenario catalog, Design Files, and brand-system deep links; the bundled codex-slides-browser skill requires Codex to navigate them instead of merely printing a URL.
R2.3 Operate via Codex directly (MCP tools + skills), fully inside Codex Repo-root plugin structure exposes both a self-contained Agent Skill (skills/codex-slides/, portable CLI, no MCP dependency) and 28 MCP tools. The default contract is Browser-first: open the product, create a durable project shell, then keep clarification, research, outline confirmation, inspiration, render, editing, preview, and export visible and steerable. Headless one-call generation remains opt-in. See skills/codex-slides/references/CAPABILITY_MATRIX.md.
R4.1 Deep-research mode toggle home checkbox → ResearchPanel; PptConfig.mode.
R4.2 Research → markdown editor doc → outline ResearchPanel editable markdown brief; buildOutlinePrompt takes researchDoc as <research_document> context; Project.researchDoc stored.
R4.3 Search via DuckDuckGo or codex built-in search Codex built-in web_search (primary, zero-config) — verified 19 real source URLs. DDG HTML/Lite bot-block servers (HTTP 202); ddgSearch() kept as documented fallback.
R4.4 Deep research shipped as an out-of-the-box skill skills/codex-slides-research/SKILL.md (source-backed research → reviewed brief → outline → render → Browser verification).

3. Target architecture

repo root (Next.js + Codex plugin)
  app/
    page.tsx                     home: input + gen-UI onboarding + recent projects
    project/[id]/page.tsx        project workspace: preview · play · chat edit · materials
    api/
      agents, generate(SSE), files, export        [done]
      projects (list), projects/[id] (get/patch/delete)
      projects/[id]/{regenerate, mark}            [done]
      onboard          POST requirement -> agent-generated question schema (gen UI)
      materials        POST upload image material -> stored per project
      research         POST topic -> markdown research doc (deep-research skill)
  components/ DeckView, ProjectWorkspace, OnboardForm, ChatEditPanel, PlayMode, MarkdownEditor, MaterialTray, MarkCanvas[done]
  lib/ (codex-*, agents, prompts, pipeline, store, assemble) [done] + research.ts, onboard.ts, materials.ts

.codex-plugin/plugin.json        installable plugin manifest
.mcp.json                        registers the codex-slides MCP server
mcp/server.mjs                   complete 20-tool web-app bridge + daemon
skills/codex-slides/             canonical Agent Skill + portable CLI/reference
skills/codex-slides-*/SKILL.md   compatibility browser + deck + research entries
scripts/start-mcp.mjs            repairs cached dependencies, then starts MCP
scripts/probe-mcp.mjs            contract and live integration probe

Data model (extends current Project): add materials: {id,name,path,role}[], mode: "direct"|"research", researchDoc?: string (markdown), chat: {role,content,ts}[], questions?: QuestionSpec[].

4. Milestones (build order) + acceptance

  • M1 — Project system backbone (unblocks all UI): /api/projects list; /project/[id] workspace page; home shows recent projects & routes into a project; generation attaches to a project id. Accept: create a deck, land on /project/[id], reload page, deck still there, export works.
  • M2 — Gen-UI onboarding: /api/onboard returns an agent-generated QuestionSpec[] (pages/ratio/theme/tone/visual-style/language + free slots); home renders it as a dynamic form incl. image upload. Accept: type a topic → get 3-6 tailored questions → answers seed the project config.
  • M3 — Materials (image→ppt): upload endpoint + per-project material tray; selected materials passed as reference images into outline/copy/image stages. Accept: upload a logo, generate, logo/style reflected in slides.
  • M4 — Conversational edit + play: chat panel that routes NL edits to regenerate/mark/global-restyle; fullscreen play mode. Accept: "make slide 2 warmer" edits only slide 2; Play cycles slides fullscreen.
  • M5 — Deep research skill: research.ts (DuckDuckGo HTML fetch + codex synthesis loop) → markdown doc in a markdown editor → outline; toggle on home; also a skills/codex-slides-research/SKILL.md. Accept: toggle research on a topic → citations-backed markdown → outline derived from it.
  • M6 — Codex plugin / daemon / in-editor: repo-root .codex-plugin/plugin.json, .mcp.json, MCP server + skills; the web app opens in codex in-editor browser; codex can drive the full flow via tools. Accept: codex plugin add then ask codex "make a 6-slide deck about X" → deck produced & previewable.
  • M7 — Template catalogDONE & verified. lib/templates.ts: 15-category taxonomy (genspark §5) + per-category visual grammar (§6.9) + 45 templates (3 for every one of the 15 categories — none <3, "非常充足"). config.template wired into pipeline.ts via buildImagePromptstyleBlockFor(getTemplate()). components/TemplatePicker.tsx (grouped-by-category select + palette swatches) in the home config panel. Verified: template craft-swiss-international → an "Urban Mobility Report" slide rendered in unmistakable Swiss International (strict grid, red #E4002B accent, weight-only hierarchy). Optional polish: auto-pick a template from the onboarding category answer; expose the picker inside the /project/[id] workspace.

5. NEXT ACTION

🎉 M1–M7 ALL DONE — every requirement (R1-R5) + the template catalog are end-to-end implemented & verified. The product is feature-complete per this spec. Remaining loop ticks = polish + regression verification only (do NOT rebuild done milestones). Polish backlog:

  1. Onboarding → template (iter-8): OnboardForm maps the category answer → top template of that category → config.template. Verified: fundraising-pitch→pitch-midnight-traction, design-craft→craft-swiss-international, etc.
  2. Workspace parity (iter-9): TemplatePicker + MaterialTray in /project/[id] + PATCH /api/projects/[id] (update template/style/materials) + "Apply & regenerate all slides". Verified template switch regenerates the deck in the new style. (Research-in-workspace intentionally skipped — research starts a new deck; use the home flow.)
  3. Regression sweep (recurring): each tick, run one end-to-end pass (research→deck→chat-edit→export, or the MCP probe) and fix anything that regressed; keep the matrix honest. ← now the only standing backlog item.
  4. Docs (iter-8): web/README.md rewritten to cover onboarding, research, projects, templates, materials, editing, play, export, and the codex plugin.

(done) M6 — Codex plugin/daemon/in-editor. Repo-root plugin, 28 MCP tools,

browser/deck/research skills, scenario/Design Files/brand-system parity, and ensureServer daemon. Verified via MCP probe, production build, API route checks, and Browser resource-link contracts.

(done) M5 — Deep research mode + skill. Toggle on home; iterative

research loop (query → search → read → synthesize → gap-check → repeat) into a markdown research doc, show it in a lightweight markdown editor the user can tweak, then derive the outline FROM that doc (feed it to buildOutlinePrompt as context). Search: DuckDuckGo HTML endpoint (https://html.duckduckgo.com/html/?q=) with a Codex-synthesis fallback (no key). Ship it out-of-the-box as a skill: skills/codex-slides-research/SKILL.md (so Codex can run the same research flow natively — ties into M6). Files: lib/research.ts (search + loop + doc), /api/research (SSE progress), components/ResearchPanel.tsx + a small markdown editor, PptConfig.mode: "direct"|"research" + Project.researchDoc. Acceptance: toggle research on a topic → citations-backed markdown → outline derived from it. Ref patterns: dzhng/deep-research, Alibaba-NLP/DeepResearch, langchain-ai/open_deep_research.

6. Changelog

  • community-styles + inspiration-step (2026-07-10): curated 22 reusable slide community styles from the YouMind "Awesome Nano Banana Pro Prompts" gallery (PPT-relevant only; pure-person portraits dropped). Each is a subject-free styleBlock distilled from the source prompt + a downloaded cover, in lib/community.ts; covers live in public/community/*.jpg (served at /community/…). buildImagePrompt now resolves a community-template id → communityStyleBlock (alongside curated lib/templates.ts). New home Community gallery (Community.tsx, scrolling multi-row grid + group-filter chips, below "For you"). New inspiration step in the staged flow — order is now clarify → outline → inspire → render, where inspire shows ONLY when no template was picked: InspireBoard.tsx ranks the catalog against the topic+outline via POST /api/inspire (codex, lib/inspire.ts) with an instant offline keyword fallback (matchCommunityTemplates); the pick is applied with PATCH /api/projects/[id] (template) before renderProject reads it. Wired into both app/page.tsx (home flow) and DeckView.tsx (draft resume). OnboardForm clarify questions now also take per-question reference images (upload → shared materials → consumed as refImages), plus the existing free-text custom answers. Helpers rankInspire / patchProjectStyle in deckEdit. Verified: tsc clean; Community grid live in the running app. (NOTE: web/ prefix in git status is a stale alias — the buildable app is the repo root: src/, public/, package.json.)

  • codex-browser-integration (2026-07-10): promoted the repository itself to a valid installable plugin root; replaced the 6-tool partial MCP bridge with 20 tools covering every product workflow; added typed Browser resource links, a mandatory browser-opening skill, template discovery API, auto-build/start, a cache-safe dependency launcher, and static/live MCP probes. Installed through the personal marketplace and verified from its installed cache.

  • staged-flow (2026-07-10): reshaped the homepage→deck chain into the 6-step staged flow (§0.1). Split runGeneration into planOutline + renderProject (+ reviseOutline); added Project.status and a research ProgressEvent; new routes api/outline (SSE), api/projects/[id]/outline (PUT replace / POST NL-revise), api/projects/[id]/render (SSE); new OutlineBoard (editable outline, insert-between +, confirm bar), readSSE

    • stream/save/revise helpers in deckEdit; OnboardForm moved into the workspace right pane with per-option custom free-text; suggestion chips in ChatColumn; DeckView resumes drafts. /api/generate, /api/research, and the MCP plugin unchanged. tsc clean; new routes verified live (404/400 error paths + a real draft that rendered end-to-end). Larger home composer. Note: ResearchPanel.tsx is now unused (research folded into api/outline).
  • iter-1 (2026-07-10): wrote spec; full gap check; core loop + PDF/PPTX confirmed ✅. M1 done & verified: /api/projects, /project/[id] workspace, DeckView, recent-projects on home, "Open workspace" link. Build clean; routes return 200; project list serves the demo deck. Next: M2.

  • iter-1 templates-loop (2026-07-10): M7 seeded (lib/templates.ts): 15-category taxonomy (genspark §5) + per-category visual grammar (§6.9) + 15 templates (3 each for all 5 paid categories) + styleBlockFor() helper; PptConfig.template field added. tsc clean. Gated: full catalog (≥3 for all 15) + pipeline wiring + gallery UI after M2-M6. Two 5-min crons now active: capability build + template build (this one).

  • iter-2 (2026-07-10): M2 done & verified. lib/onboard.ts (QuestionSpec + prompt + normalize), /api/onboard, components/OnboardForm.tsx, home "✦ Ask me questions" → dynamic form → applyAndGenerate merges answers into config+requirement then generates. Live test: Series-A truck topic → 6 tailored Chinese Qs incl. category=fundraising-pitch + 4 topic-specific styles. Build clean. Next: M3 (materials → ref images).

  • iter-3 (2026-07-10): M3 done & verified (image→ppt). lib/materials.ts (staging + attach + load), /api/materials + /api/materials/[id], components/MaterialTray.tsx in config panel; PptConfig.materialIds threaded into pipeline.ts (copied to project, passed as refImages + materials guideline in buildImagePrompt), Project.materials. Live test: upload indigo brand card → "Our Company" slide adopted its palette/type/layout. Build clean. Template gate re-checked: M4-M6 still open → templates remain seeded-only. Next: M4 (chat edit + play).

  • iter-4 (2026-07-10): M4 done & verified (conversational edit + play). lib/chat.ts (classify NL edit → {reply,targets,instruction}), /api/projects/[id]/chat, components/ChatEditPanel.tsx + components/PlayMode.tsx wired into DeckView (chat runs targeted /regenerate sequentially; ▶ Play fullscreen ←/→/Esc). Live test: "第2页更暖"→targets[2]; "restyle whole deck"→targets[1,2], both with text-preserving instructions. Build clean. Template gate re-checked: M5-M6 still open → templates seeded-only. Next: M5 (deep research mode + skill).

  • iter-5 (2026-07-10): M5 done & verified (deep research; R4.1-4.4 all ✅). lib/research.ts (Codex built-in web_search loop, 2 rounds, gap-fill), /api/research (SSE), components/ResearchPanel.tsx (editable brief) + home "🔍 Deep research mode" toggle; buildOutlinePrompt grounds on researchDoc; PptConfig.mode/researchDoc, Project.researchDoc; skills/codex-slides-research/SKILL.md. Live test: humanoid-robot topic → 14.9KB brief with 19 real source URLs (GrandView/IDC/UBS/NVIDIA/Agility). Discovery: DDG HTML/Lite bot-block servers (202) → pivoted to codex web_search (zero-config, real citations). Build clean. Next: M6 (codex plugin/daemon) = last capability; when it lands the template gate (M7) unlocks.

  • iter-13 (2026-07-10): loops stopped. Product complete + every path verified across 12 iters; codebase static between ticks (nothing to re-discover). Deleted both crons 3152f326 + 5874d009 as a stewardship call to stop burning cost on redundant re-verification. Resume anytime via /loop. web/ remains git-untracked (commit on request).

  • iter-12 (2026-07-10): health check — green, no changes. Inventory: 15 lib modules · 8 components · 13 API routes · 45 templates · 6 MCP tools. Endpoints live (agents/codexReady, 4 decks). Nothing left to build/verify. ⚠️ The whole web/ app is still git-untracked (uncommitted) — flag for the user; commit only on request.

  • iter-11 (2026-07-10): research→deck full chain verified end-to-end (visual). Ran /api/research (EV charging 2026 → 11.5KB brief, 15 sources) → /api/generate {mode:"research", researchDoc, template:"data-answer-first"} → 2/2 rendered. Outline carried SPECIFIC facts (256,400 ports, NACS/SAE J3400, NEVI $1B/FY2026); the content slide rendered them as a US map + bar chart, standards diagram, funding timeline + KPI tiles — in true data-answer-first style. Note: a research-grounded multi-slide gen exceeds a 120s client timeout (server completes ~2-3min; SSE UI shows progress). Confirms R4 (research→grounded deck) + M7 (template) compose correctly. Everything now verified.

  • iter-10 (2026-07-10): regression sweep — ALL GREEN, no regressions. rebuild clean; /api/agents (codexReady, codex+claude+gemini); /api/projects (3); export PDF 2.2MB + PPTX 2.1MB (200); /api/onboard 6 tailored Qs (fields incl. category+style); /chat "whole deck"→[1,2]; MCP probe initialize+tools/list(6)+ list_projects OK. Product feature-complete & verified end-to-end. Backlog empty except the recurring sweep itself.

  • iter-9 (2026-07-10): polish #2 workspace parity done & verified. PATCH /api/projects/[id] (update template/style + attach materials); TemplatePicker + MaterialTray + "Apply & regenerate all slides" in DeckView. Live test: PATCH urban-mobility slide Swiss→craft-editorial-ink + regenerate → slide fully transformed (paper ground, serif display, ink illustration, umber accent). tsc+build clean. Only standing backlog now = recurring regression sweep (#3).

  • iter-8 (2026-07-10): polish (all milestones already done). #1 onboarding category→auto template pick in OnboardForm (verified mapping); #4 README.md rewritten for the full product. tsc+build clean. Remaining backlog: #2 workspace parity (template/material/research inside /project/[id]), #3 recurring regression sweep.

  • iter-7 templates-loop (2026-07-10): M7 DONE & verified — gate was unlocked. lib/templates.ts expanded to 45 templates (3 for all 15 categories); config.template wired into pipeline.ts (buildImagePromptstyleBlockFor); components/TemplatePicker.tsx added to the home config panel. tsc+build clean. Live test: craft-swiss-international → "Urban Mobility Report" slide rendered in true Swiss International (grid, red accent, weight hierarchy). M1-M7 all complete; product feature-complete. Remaining ticks = polish/regression only.

  • iter-6 (2026-07-10): M6 done & verified (R2.1-2.3 all ✅) — all capabilities M1-M6 complete. Built web/codex-plugin/: .codex-plugin/plugin.json, .mcp.json, mcp/server.mjs (McpServer + stdio; 6 tools: create_deck/deep_research/list_projects/open_preview/regenerate_slide/export_deck; ensureServer() daemon auto-boots next start), skills/{codex-slides-deck,codex-slides-research}. Added @modelcontextprotocol/sdk + zod. Verified via MCP stdio probe: initialize (server codex-slides 0.1.0) + tools/list (6 tools) + tools/call list_projects (real decks + preview URLs). Template gate (M7) UNLOCKED → next: template loop builds the full catalog + pipeline wiring; capability loop switches to verification/polish sweeps.