Skip to content

feat(cli): add a Lovable handoff target to plan and impl - #871

Merged
coderdan merged 3 commits into
mainfrom
feat/lovable-handoff-target
Aug 10, 2026
Merged

feat(cli): add a Lovable handoff target to plan and impl#871
coderdan merged 3 commits into
mainfrom
feat/lovable-handoff-target

Conversation

@coderdan

@coderdan coderdan commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Closes #873.

Why

A customer hit a wall setting up CipherStash in Lovable. Lovable's agent — with no repo-local guidance available — answered from stale training data: it claimed CipherStash needs a Postgres extension (EQL) plus ZeroKMS "installed on the managed database", concluded a real setup was impossible, and built a hand-rolled AES-GCM + deterministic-HMAC scheme instead. Every claim is wrong today: EQL v3 is plain SQL, installs as a non-superuser on Supabase (Lovable's backend), and ZeroKMS is hosted — nothing installs in the database.

Nothing in stash init targeted Lovable, so there was no way to get correct guidance in front of its agent.

image

What

Adds a lovable handoff target to stash plan / stash impl (--target lovable plus a new agent-target picker entry).

  • Reuses the editor-agent inline path: writes AGENTS.md with the doctrine plus the per-integration skills inlined, and the usual .cipherstash/context.json + .cipherstash/setup-prompt.md.
  • Lovable-specific next steps in the handoff note: Lovable only sees the repo through its GitHub sync, and does not auto-load AGENTS.md the way Cursor/Windsurf do — so the guidance is to commit and push, then add a Knowledge note in the Lovable project settings pointing the agent at AGENTS.md and .cipherstash/setup-prompt.md.
  • plan's non-TTY outro now derives its target list from HANDOFF_CHOICES instead of a hard-coded string.
  • Registry help text, skills/stash-cli/SKILL.md, and tests updated; stash minor changeset included.

Verification

  • pnpm --filter stash test — 1207 passed
  • pnpm --filter stash test:e2e — 100 passed
  • pnpm run code:check — no errors
  • stash manifest --json resolves the new --target value (skills doc checked against it)

Summary by CodeRabbit

New Features

  • Added Lovable as a supported handoff target for planning and implementation.
  • Added Lovable-specific setup guidance, generated files, skills, and follow-up instructions.
  • Added guidance for syncing project files through GitHub and configuring Lovable Knowledge.

Bug Fixes

  • Improved messaging when setup files or skills cannot be written, including clear recovery instructions.

Documentation

  • Updated command help and workflow documentation to include Lovable support.

Summary by CodeRabbit

  • New Features
    • Added Lovable as a handoff target for plan and impl commands.
    • Lovable handoffs now generate project guidance and setup instructions, including GitHub synchronization and Knowledge configuration.
    • Added Lovable to interactive target selection and command help.
  • Bug Fixes
    • Improved messaging when guidance files cannot be written, with clearer recovery instructions.
    • Updated fallback messages to accurately reflect which setup content is available.
  • Tests
    • Added coverage for Lovable handoffs, target selection, and file-write failure scenarios.

Lovable's agent runs in Lovable's cloud and only sees the repo through
GitHub sync, so without repo-local guidance it answers CipherStash
questions from stale training data (the pre-EQL-v3 "needs a Postgres
extension and superuser" story) and talks users out of a supported
Supabase setup.

The new --target lovable (and picker entry) writes the same AGENTS.md
as the editor-agent handoff — doctrine plus the per-integration skills
inlined — with Lovable-specific next steps: commit and push the
generated files, then add a Knowledge note in the Lovable project
settings pointing the agent at AGENTS.md and
.cipherstash/setup-prompt.md, since Lovable does not auto-load
AGENTS.md the way Cursor or Windsurf do.
@coderdan
coderdan requested a review from a team as a code owner August 10, 2026 01:21
@changeset-bot

changeset-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 52104d7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
stash Minor
@cipherstash/basic-example Patch
@cipherstash/e2e Patch
@cipherstash/stack Minor
@cipherstash/stack-drizzle Minor
@cipherstash/stack-supabase Minor
@cipherstash/stack-prisma Minor
@cipherstash/wizard Minor
@cipherstash/bench Patch
@cipherstash/test-kit Patch
@cipherstash/prisma-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds lovable as a stash plan and stash impl handoff target. The CLI routes Lovable handoffs to artifact generation, updates setup guidance, and documents GitHub synchronization and Lovable Knowledge configuration.

Changes

Lovable handoff

Layer / File(s) Summary
Target contract and routing
packages/cli/src/commands/init/types.ts, packages/cli/src/commands/impl/steps/how-to-proceed.ts, packages/cli/src/cli/registry.ts, packages/cli/src/commands/plan/index.ts, packages/cli/src/commands/impl/__tests__/how-to-proceed.test.ts, packages/cli/src/commands/impl/steps/__tests__/how-to-proceed-dispatch.test.ts, packages/cli/tests/e2e/impl-non-tty.e2e.test.ts
The CLI accepts lovable, shows it in target choices and help text, routes it to the Lovable handoff, and tests interactive and non-interactive dispatch.
Lovable artifact generation
packages/cli/src/commands/impl/steps/handoff-lovable.ts, packages/cli/src/commands/init/lib/setup-prompt.ts, packages/cli/src/commands/impl/steps/handoff-agents-md.ts, packages/cli/src/commands/impl/steps/__tests__/handoff-lovable.test.ts, packages/cli/src/commands/impl/steps/__tests__/handoff-agents-md.test.ts, packages/cli/src/commands/init/lib/__tests__/setup-prompt.test.ts
The Lovable handoff writes guidance artifacts, records skill installation outcomes, and updates success and failure messaging for AGENTS.md.
Documentation and release notes
.changeset/lovable-handoff-target.md, skills/stash-cli/SKILL.md
The changeset and CLI skill documentation describe the Lovable target, GitHub sync, and Lovable Knowledge setup.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant StashCLI
  participant ProjectFiles
  participant Lovable
  User->>StashCLI: Run plan or impl with --target lovable
  StashCLI->>ProjectFiles: Write AGENTS.md and setup-prompt artifacts
  StashCLI->>User: Show GitHub sync and Knowledge instructions
  User->>Lovable: Configure project Knowledge
  Lovable->>ProjectFiles: Reference AGENTS.md and setup-prompt guidance
Loading

Possibly related PRs

Suggested reviewers: freshtonic, auxesis, calvinbrewer

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR addresses issue #873 by adding Lovable guidance, generated artifacts, and setup instructions for CipherStash projects.
Out of Scope Changes check ✅ Passed The changes support the Lovable handoff objective and include related documentation, tests, help text, and a changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a Lovable handoff target to the CLI plan and impl commands.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/lovable-handoff-target

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/src/commands/impl/steps/handoff-lovable.ts`:
- Around line 42-64: Preserve the writeAgentsMd() result when generating the
Lovable handoff and setup prompt. In
packages/cli/src/commands/impl/steps/handoff-lovable.ts lines 42-64, pass an
explicit AGENTS.md write-status value and show recovery guidance instead of
instructing users to commit AGENTS.md when writing fails. In
packages/cli/src/commands/init/lib/setup-prompt.ts lines 254-276, update
skillsLoadedLines() to claim durable rules are in AGENTS.md only when artifact
generation succeeded. Add a regression test covering failed AGENTS.md writing.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f0fd1209-0848-4fe7-a9b3-d7586324238f

📥 Commits

Reviewing files that changed from the base of the PR and between f90b0db and eb61d9b.

📒 Files selected for processing (10)
  • .changeset/lovable-handoff-target.md
  • packages/cli/src/cli/registry.ts
  • packages/cli/src/commands/impl/__tests__/how-to-proceed.test.ts
  • packages/cli/src/commands/impl/steps/handoff-lovable.ts
  • packages/cli/src/commands/impl/steps/how-to-proceed.ts
  • packages/cli/src/commands/init/lib/setup-prompt.ts
  • packages/cli/src/commands/init/types.ts
  • packages/cli/src/commands/plan/index.ts
  • packages/cli/tests/e2e/impl-non-tty.e2e.test.ts
  • skills/stash-cli/SKILL.md

Comment thread packages/cli/src/commands/impl/steps/handoff-lovable.ts
Review follow-up on the Lovable handoff. When writeAgentsMd() fails,
the handoff note now shows recovery guidance instead of telling the
user to commit a file that was never written — in both the Lovable and
editor-agent (agents-md) steps, which shared the flaw.

skillsLoadedLines() keyed its 'durable rules are in AGENTS.md' claim on
any AGENTS.md-writing handoff, but for agents-md and lovable the skills
are inlined into AGENTS.md itself — all skills failing means the file
was not written. Only codex writes its doctrine separately, so only
codex keeps that pointer on the all-failed path.
@coderdan
coderdan requested a review from freshtonic August 10, 2026 02:14

@freshtonic freshtonic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full diff plus the surrounding code on the branch (target validation, the setup-prompt renderer, write-context.ts, and the plan/impl outro paths). Approving — this is a clean, well-scoped addition.

What holds up well:

  • --target lovable needs no bespoke validation: plan and impl both validate against HANDOFF_CHOICES, and the non-TTY hints in init/plan/impl all derive from it too — the plan outro's switch from a hard-coded string to HANDOFF_CHOICES.join('|') closes the last one. The e2e assertion pins the rendered list.
  • The deferred-handoff behaviour falls out correctly for free: handoffLovableStep never sets agentLaunched, so plan takes the "No plan drafted yet, exit 0" path exactly as documented in the updated skills/stash-cli/SKILL.md.
  • The honesty fixes are the strongest part. skillsLoadedLines narrowing the all-failed AGENTS.md pointer to handoff === 'codex' is a genuine bug fix for the pre-existing agents-md path (all-failed there means writeAgentsMd itself failed, so the old prompt pointed at a nonexistent file), and both handoff notes now branch on written. The new tests cover exactly these branches, including the codex contrast case.
  • Repo hygiene is all in order: stash minor changeset, SKILL.md updated against the manifest, registry help text, and the test updates match.

One doc nit (fine as a fast-follow):

  • packages/cli/README.md:27 still says --target <claude-code|codex|agents-md|wizard> — the same stale list this PR fixes in the registry and SKILL.md. (The CHANGELOG hit is historical and correctly left alone.)

Observed but not worth acting on:

  • The stripped-build + unwritable-AGENTS.md combination (installed/inlined/failed all empty with written === false) would still claim "the durable rules are in AGENTS.md" for agents-md/lovable — but that requires two independent failures at once and predates this PR.
  • The success/failure note duplication between handoff-agents-md.ts and handoff-lovable.ts is acceptable; the cross-referencing comments make the pairing discoverable.

@cipherstash-bot cipherstash-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict

Solid PR — most of the Lovable handoff target is well covered (setup-prompt cases per mode, five-target ordering in how-to-proceed.test.ts, non-TTY e2e --target string, agents-md honesty branch source). The gaps are all test coverage, not correctness: the new execution path (handoffLovableStep.run) and one changed help surface (plan --help) are unverified. No crypto/security concerns — pure CLI handoff wiring.

Review stats

Source Model Raw Survived
claude claude-opus-4-8 [test-gap] 2 2
codex gpt-5.5 [test-gap] 3 3

After de-dup: 4 distinct findings kept (the lovable-step gap was raised by both). Cross-model overlap: 1 kept finding corroborated by 2+ models.

Comment thread packages/cli/src/commands/impl/steps/handoff-lovable.ts
Comment thread packages/cli/src/commands/impl/steps/how-to-proceed.ts
Comment thread packages/cli/src/cli/registry.ts
Comment thread packages/cli/src/commands/impl/steps/handoff-agents-md.ts
…TS.md honesty branch

Coverage-bot follow-up on the Lovable handoff. Four gaps, all in new or
changed code that CI would have shipped green:

- handoff-lovable.test.ts — neither arm of the writeAgentsMd success/
  failure split was exercised, so a regression could record skills as
  inlined after the write failed, or tell the user to commit a file
  that was never written.
- handoff-agents-md.test.ts — the step had no test at all, and this
  branch gained the same honesty ternary.
- how-to-proceed-dispatch.test.ts — buildOptions ordering was covered
  but not the dispatch arms. Table-driven off HANDOFF_CHOICES so a
  target that reaches the picker without a dispatch arm fails here.
- The --help e2e now loops over impl and plan; each carries its own
  --target descriptor, so asserting only impl let a dropped target
  ship silently from plan.

Mutation-checked: rerouting the lovable dispatch arm and forcing the
note ternary true each fail the new tests.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/cli/src/commands/impl/steps/__tests__/handoff-lovable.test.ts (1)

28-28: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Replace the repeated type-erasing InitState fixtures.

Both tests force partial objects through as unknown as InitState. This bypasses the InitState contract and duplicates the exception. Use a typed shared test fixture, or document one intentional coercion at a helper boundary.

  • packages/cli/src/commands/impl/steps/__tests__/handoff-lovable.test.ts#L28-L28: replace the local type-erasing fixture.
  • packages/cli/src/commands/impl/steps/__tests__/handoff-agents-md.test.ts#L27-L27: reuse the typed fixture.

As per coding guidelines, source type-erasing assertions must use narrowing, a specific assertion, or a deliberate suppression with a reason. Based on learnings, minimize type-erasing assertions in __tests__ and centralize them when practical.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/commands/impl/steps/__tests__/handoff-lovable.test.ts` at
line 28, Replace the repeated type-erasing InitState fixtures with one shared,
properly typed test fixture or helper, centralizing any necessary coercion with
an explicit reason. Update
packages/cli/src/commands/impl/steps/__tests__/handoff-lovable.test.ts#L28-L28
to use it, and update
packages/cli/src/commands/impl/steps/__tests__/handoff-agents-md.test.ts#L27-L27
to reuse the same fixture; preserve each test’s existing integration value.

Sources: Coding guidelines, Learnings

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/cli/src/commands/impl/steps/__tests__/handoff-lovable.test.ts`:
- Line 28: Replace the repeated type-erasing InitState fixtures with one shared,
properly typed test fixture or helper, centralizing any necessary coercion with
an explicit reason. Update
packages/cli/src/commands/impl/steps/__tests__/handoff-lovable.test.ts#L28-L28
to use it, and update
packages/cli/src/commands/impl/steps/__tests__/handoff-agents-md.test.ts#L27-L27
to reuse the same fixture; preserve each test’s existing integration value.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 914840e8-cfe3-4c01-a4c2-8e4c24af5d55

📥 Commits

Reviewing files that changed from the base of the PR and between 1269b5e and 52104d7.

📒 Files selected for processing (4)
  • packages/cli/src/commands/impl/steps/__tests__/handoff-agents-md.test.ts
  • packages/cli/src/commands/impl/steps/__tests__/handoff-lovable.test.ts
  • packages/cli/src/commands/impl/steps/__tests__/how-to-proceed-dispatch.test.ts
  • packages/cli/tests/e2e/impl-non-tty.e2e.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/cli/tests/e2e/impl-non-tty.e2e.test.ts

@coderdan
coderdan merged commit 7785643 into main Aug 10, 2026
10 checks passed
@coderdan
coderdan deleted the feat/lovable-handoff-target branch August 10, 2026 05:48
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.

Lovable's agent talks users out of a supported CipherStash setup — no way to get correct guidance into a Lovable project

3 participants