ods-pages

ADR-0003 — In-app AI Build Helper (BYO API key)

Status: draft Date: 2026-04-27 Tracked in: TODO.mdAI Build Helper (BYO API key)


1. Context

ODS Pages has had an AI workflow since day one, but it lives entirely outside the framework: builders copy a system prompt and their current spec into ChatGPT or Claude, work back and forth, and paste the result back. The asset bundle ships as Specification/build-helper-prompt.txt with provider-specific variants under BuildHelpers/Claude/ and BuildHelpers/ChatGPT/, and the React framework wraps the copy/paste UX as a 3-step screen (EditWithAiScreen.tsx). Flutter has no AI surface at all today.

This split has accumulated friction now that more builders have their own API keys:

1.1 Same dance whether you have a key or not

A user with an Anthropic key still has to: open the AI screen, copy the system prompt, switch to claude.ai, paste, switch back to ODS, copy the spec, switch back to claude.ai, paste, wait, copy the result, switch back to ODS, paste, save. That’s 8+ context switches for a one-line change. Having a key buys nothing.

1.2 Iteration starts fresh every time

Each “Edit with AI” round-trip is a brand-new conversation. “Now make the priority field default to medium” requires re-pasting the prompt, the spec (which may have been updated since the last round), and the new instruction. There’s no continuity for non-trivial edits.

1.3 No safety net

Today the user pastes the AI’s output back into a textarea and hits Save. If the AI hallucinated an OdsBrandng field or dropped a matchField, the validator catches it on load — but the user has already lost their previous spec and has to undo by hand. There’s no diff-review step where they can see what changed before committing.

1.4 Flutter parity gap

The whole “Edit with AI” surface is React-only. Flutter Quick Build exists, but nothing equivalent to “edit an existing app via AI.”

1.5 Provider asymmetry would creep in

We currently maintain two prompt files (Claude and ChatGPT) but the framework only wires the prompt asset for one path. If the in-app integration locks to a single provider, builders on the other side become second-class.

2. Decision

Add an in-app AI Build Helper that activates when the builder has provided an API key. Two interaction modes share one provider layer:

One-shot edit. User types “add a priority field with low/med/high options”; framework sends current spec + instruction + system prompt to the configured provider; receives a proposed new spec; renders a side-by-side diff; user accepts or discards. Same as today’s copy/paste loop, just collapsed into one button + one diff.

Multi-turn chat. User opens a chat panel, has an ongoing conversation. Each AI message that proposes a spec change renders as a diff card with its own Apply / Discard buttons. Conversation history (in-memory for v1) gives the AI context for “now make the default ‘medium’” without re-pasting the spec.

Both modes go through one AiProvider abstraction with Anthropic and OpenAI implementations from day one. The builder picks a provider + model in the framework settings; key is stored in SettingsStore (Flutter) / localStorage (React) for v1, with OS-keychain integration noted as a follow-up.

The existing 3-step copy/paste flow stays as the no-key fallback: clicking “Edit with AI” without a configured key still works as it does today, plus a one-liner “have an API key? Set it once in Settings → AI to skip the copy/paste.”

3. Consequences

Good:

Bad:

Neutral:

4. Alternatives considered

5. Open questions

6. Implementation sketch

Phased so the provider layer + settings land first (small, well-tested), then the UI surfaces in order of impact.

Phase 1 — Provider layer (React + Flutter, in parallel)

Phase 2 — Framework AI Settings (React + Flutter)

Phase 3 — One-shot edit mode (React first)

Phase 4 — Multi-turn chat panel (React first)

Phase 5 — Conformance + tests

Phase 6 — Flutter mirror

Out of scope for v1


Phasing summary

Phase Lands Surface Frameworks
1 Provider layer + tests none (engine) React + Flutter parallel
2 AI Settings panel Settings React + Flutter
3 One-shot edit EditWithAi screen React
4 Multi-turn chat EditWithAi panel React
5 Conformance + mutation tests both
6 Flutter mirror EditWithAi screen Flutter

Estimated 4–6 sessions across both frameworks, similar to ADR-0002.