Skip to content

Describe a pipeline in words (AI builder, off until switched on) - #109

Open
Murraylr wants to merge 1 commit into
mainfrom
claude/ai-generate
Open

Murraylr wants to merge 1 commit into
mainfrom
claude/ai-generate

Conversation

@Murraylr

Copy link
Copy Markdown
Collaborator

What and why

Visitors can describe a pipeline in words and get suggested steps from Claude (REQ-027, NFR-007). The feature is built to keep the AI bill bounded, and it stays off in production until the switch-on step (TASK-015) is done.

Worker: POST /api/generate (TASK-013)

  • Replies 503 ai_off unless AI_GENERATE=on and the ANTHROPIC_API_KEY and AI_IP_SALT secrets are set.
  • Spend is capped by a daily dollar budget (AI_DAILY_BUDGET_USD, default 5) and a per-IP daily limit (AI_IP_DAILY_LIMIT, default 10). Both counters live in D1 (migrations/0002_ai_generate.sql). The IP is stored only as a keyed daily hash.
  • Replies are cached by a hash of the description. Every step is checked against the utility catalog before it is returned, and code-running utilities are never suggested.
  • Adds @anthropic-ai/sdk as a dependency (used only by the Worker).

App: describe dialog (TASK-014)

  • A "Describe it" button beside the step list and a "Describe a pipeline (AI)" palette command open a lazy-loaded dialog.
  • The dialog sends only the description. The visitor's input, output and pipeline never leave the browser.
  • The app checks the returned steps again (registry, sanitizeSteps, code utilities removed), because the Worker and an open tab can be different versions.
  • "Replace pipeline" or "Add to the end" loads the steps as one undoable change. An empty pipeline gets a single "Use these steps" button.
  • Each failure has its own message. All but a too-long description link utility search and the MCP server.
  • The privacy policy gets an "AI pipeline builder" item: what is sent, to Anthropic, and what is kept for how long.

Reviewer notes

  • The button goes live when this merges. Until TASK-015 every click shows "not switched on" with the search and MCP links. TASK-015 covers the secrets, the Anthropic Console spend limit, applying the D1 migration and setting AI_GENERATE=on.
  • Undo after "Replace pipeline" restores the steps but not a saved pipeline's library name and link. Loading a preset behaves the same way.
  • The privacy text is legal wording. Please give it a human read before switch-on.
  • No release label is set. This is a new feature, so release:minor may be the right one.

How it was tested

  • 30 targeted test files (347 tests) pass: src/app/generate/*, tool, commands, SitePage, i18n and worker/generate, ai-budget, ai-catalog. The Worker tests use a fake model and an in-memory D1; no real API call was made.
  • npm run typecheck, the worker tsc and npm run lint pass.
  • npm run build (295 pages) and npm run check:bundle pass, and the dialog is its own chunk. The build was not re-run after the last one-line change (fallback links on upstream failures).
  • npx wrangler deploy --dry-run builds the Worker.
  • By hand, in the dev server with a faked route: Add to the end then Undo, and Replace then Undo, each in one step. Only { description } was sent, and there were no console errors.
  • Not run: the full npm test and Playwright E2E (CI runs both).

Checklist

  • npm test, npm run typecheck and npm run lint pass (typecheck and lint pass; only targeted tests were run locally)
  • New utilities have index.test.ts, guide.md and regenerated _generated/ files (no new utilities)
  • User-visible changes are noted under ## [Unreleased] in CHANGELOG.md (not yet)
  • Labelled release:minor or release:major if a patch release isn't right
  • If the change affects what data leaves the browser, the privacy policy is updated

🤖 Generated with Claude Code

Worker (TASK-013): POST /api/generate turns a short description into
pipeline steps with Claude. It stays off (503 ai_off) until AI_GENERATE=on
and the ANTHROPIC_API_KEY and AI_IP_SALT secrets are set. A daily dollar
budget and a per-IP daily limit, both kept in D1
(migrations/0002_ai_generate.sql), cap spend. Replies are cached by a hash
of the description, and every step is checked against the catalog before
it is returned.

App (TASK-014): a "Describe it" button beside the step list and a
"Describe a pipeline (AI)" palette command open a lazy-loaded dialog. It
sends only the description, checks the returned steps again, and loads
them with Replace or Add to the end as one undoable change. Every failure
except a too-long description links utility search and the MCP server.
The privacy policy describes what is sent, to whom and what is kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Murraylr
Murraylr requested a review from a team November 27, 2026 19:02

This branch has not been deployed

No deployments
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