Skip to content

feat(cli): fail closed on direct adds without the official foundation (#547 phase C) - #644

Merged
LudoLoops merged 2 commits into
mainfrom
547-phase-c-direct-add
Oct 23, 2026
Merged

LudoLoops merged 2 commits into
mainfrom
547-phase-c-direct-add

Conversation

@LudoLoops

Copy link
Copy Markdown
Contributor

Phase C — direct sv add fails closed with the supported sequence

Phases A (#642) and B (#643) made SVForge extend the official Paraglide / Drizzle / Better Auth output. Phase C closes the direct-add path.

What changed

  • Preflight before any write (official-integrations.ts): a direct sv add <svforge-addon>=template:<base|dashboard> now verifies the official foundation exists — project.inlang/settings.json, src/hooks.server.ts (with the Paraglide middleware; and the Better Auth handler for the dashboard), src/hooks.ts, plus auth.ts/db/index.ts/env.ts for the dashboard. Missing pieces → the add-on cancels before writing any file or dependency.
  • Actionable message: exact, package-manager-aware official commands (bunx/pnpm dlx/npx --yes) then "re-run the SVForge add", plus the supported one-command alternative npx svforge create <dir> --template ….
  • Why not automatic: the published sv@1.1.1 still cannot express conditional add-on dependencies with options (setup() does not receive the add-on options; upstream feat(addons): pass setup defaults to dependencies sveltejs/cli#1419 is open). The manual sequence is documented rather than faked.
  • Docs/guidance: generated AGENTS.md, the Better Auth runbook and the ownership matrix describe the ordering; svforge create (official add-ons first) remains the one-command path.
  • Tests: preflight unit coverage (empty/partial/full foundation, hooks without official handles, PM-aware message) + a zero-write cancellation test; the real-CLI test (vite-config-modern-scaffold) runs the official add-ons first, and add-on-run tests seed the official foundation.

Verification

  • Real CLI on a fresh project: direct SVForge add is cancelled with the three exact commands and no file is written (AGENTS.md, svforge-check.mjs, components absent).
  • Running the printed sequence then the SVForge add succeeds: hooks.server.ts = sequence(handleParaglide, handleBetterAuth, handleSvforgePolicy), auth.ts carries svforgeAuthPolicy + disableSignUp.
  • bun run test, bun run lint, bun run typecheck, node scripts/check-generated.mjs — pass.
  • test-scaffold.sh base, dashboard (46 tests, schema/runtime gate, auth HTTP smoke) and create-cli (all 13 modules, 58 tests) with real PostgreSQL — pass.

Remaining (upstream)

Automatic dependency installation for direct sv add requires the upstream conditional-dependency API (sveltejs/cli#1419). When a published sv exposes setup({ options, dependsOn }), SVForge can declare the official add-ons instead of the documented manual sequence — no template or extension changes expected.

Refs #547 — phase C; nothing else implemented.

LudoLoops added 2 commits October 24, 2026 01:05
…#547 phase C)

A direct `sv add <svforge-addon>=template:<base|dashboard>` can no longer run
without the official Paraglide/Drizzle/Better Auth output: SVForge only
extends that foundation since phases A/B.

- new `official-integrations.ts` preflights the workspace BEFORE any write
  (official files, plus the Paraglide/Better Auth handles in hooks.server.ts)
  and cancels with the exact supported manual sequence and the
  `svforge create` alternative. Fail-closed: no file, no dependency change.
- the published `sv` (1.1.1) still cannot express conditional add-on
  dependencies with options (upstream sveltejs/cli#1419 open), so the direct
  path is documented as a manual sequence rather than faked.
- generated AGENTS.md guidance, the Better Auth runbook and the ownership
  matrix document the ordering; the scaffold matrix keeps validating the
  supported sequence (official add-ons, then SVForge).
- tests: preflight unit coverage (missing artifacts, hooks without official
  handles, PM-aware message) and a zero-write cancellation test; the real-CLI
  smoke (`vite-config-modern-scaffold`) and addon-run tests now seed/request
  the official add-ons first.

Validated: full repo suite, lint, typecheck; direct add on a fresh project
cancels with the exact commands and writes nothing; the manual sequence then
produces the composed hooks/policy; `test-scaffold.sh base`, `dashboard`
(46 tests) and `create-cli` (58 tests) pass with real PostgreSQL.

Refs #547 (phase C).
The OSV audit flags three new advisories against undici 8.10.2, resolved
through jsdom (dev-only). A scoped override keeps every resolution on
8.12.3 without adding a direct dependency; `bun run audit` is clean again.
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