Skip to content

feat(domain): integrate coasts dev server with feature flag and coastfile auto-generation#437

Open
arielshad wants to merge 27 commits intomainfrom
feat/coasts-dev-server
Open

feat(domain): integrate coasts dev server with feature flag and coastfile auto-generation#437
arielshad wants to merge 27 commits intomainfrom
feat/coasts-dev-server

Conversation

@arielshad
Copy link
Contributor

Summary

  • Add coastsDevServer feature flag across the full stack: TypeSpec model, SQLite migration, settings mapper, feature flags state, web UI toggle, and context defaults
  • Implement ICoastsService output port interface with methods for prerequisite checks, build/run/stop lifecycle, coast instance lookup, and Coastfile auto-generation via AI agent system
  • Implement CoastsService infrastructure service wrapping the coast CLI binary via child_process.spawn with proper error handling, timeouts, and subprocess safety
  • Add dev-server branching logic: when the flag is enabled, check prerequisites, auto-generate Coastfile if missing, and start Next.js via coast run instead of bare next()
  • Add coasts-dev-server.ts module with startCoastsDevServer() and shutdownCoasts() for clean separation of Coasts-mode startup/shutdown
  • Add dev:coasts convenience script to package.json
  • Register CoastsService in the DI container
  • Comprehensive test coverage: 30 unit tests for CoastsService, 16 tests for coasts dev-server module, 12 integration tests for dev-server branching logic

What This Enables

When users enable the coastsDevServer feature flag, the Shep dev server uses Coasts for containerized runtime isolation per worktree. Each worktree gets its own isolated dev server instance with dedicated ports, volumes, and services — enabling true parallel feature development without port conflicts or shared state.

If a target repo lacks a Coastfile, Shep auto-generates one by running coast installation-prompt to obtain the official generation prompt, then passing it to the AI agent system to produce a tailored Coastfile based on the repo's actual structure.

Architecture

  • Clean Architecture: ICoastsService interface in application layer, CoastsService implementation in infrastructure layer
  • Feature flag pattern: follows established pattern with TypeSpec, SQLite migration, settings mapper, flag context, and UI toggle
  • Agent resolution: Coastfile generation flows through IAgentExecutorProvider per mandatory agent resolution rule
  • DI registration: CoastsService registered as ICoastsService token in the DI container

Evidence

Evidence Description
Settings toggle Coasts Dev Server toggle in Feature Flags settings
Full settings page Full settings page with integrated flag
CoastsService unit tests 30 tests passing — prerequisite checks, build, run, stop, checkout, lookup, isRunning, hasCoastfile, getInstallationPrompt, generateCoastfile
Coasts dev-server module tests 16 tests passing — full flow, prerequisite failures, Coastfile generation, log prefix, error handling
Dev-server branching integration tests 12 tests passing — prerequisite ordering, failure handling, build/run sequencing, Coastfile detection
Full test suite 382 test files, 5080 tests (4559 unit + 521 integration), ALL passing

Test plan

  • Build compiles without errors (pnpm build)
  • All 4559 unit tests pass (pnpm test:unit)
  • All 521 integration tests pass (pnpm test:int)
  • Lint passes with zero warnings (pnpm lint:fix)
  • Feature flag defaults to false (no behavior change for existing users)
  • CI passes on all workflow runs

🤖 Generated with Claude Code

arielshad and others added 18 commits March 20, 2026 22:28
Fix relatedLinks in spec.yaml to use structured { title, url } objects
matching the TypeSpec RelatedLink model. Add scaffold plan, research,
tasks, and feature YAML artifacts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address rejection feedback: Shep manages any repo, not just itself.
Removed Coastfile auto-generation (repos own their Coastfiles).
Added Coastfile-exists prerequisite check, multi-worktree concurrency
requirement, and workDir-scoped CoastsService operations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update requirements to use `coast installation-prompt` CLI command to
obtain the official Coastfile generation prompt, then pass it to the AI
agent system for intelligent per-repo Coastfile generation. Removes the
previous requirement that repos must have a pre-existing Coastfile.

Key changes:
- New FR-8: Coastfile auto-generation flow using agent system
- New FR-13: Installation prompt caching
- Updated ICoastsService with generateCoastfile, getInstallationPrompt,
  and hasCoastfile methods
- Updated dev-server branching logic to generate Coastfile when missing
- Added NFR-12 for generated Coastfile quality validation
- Resolved open question 6 in favor of auto-generation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…sts dev server

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… dev server

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Wire coastsDevServer boolean feature flag through all 8 layers:
TypeSpec model, SQLite migration 042, settings mapper, settings
repository, feature-flags resolution with env var fallback, React
context defaults, and web UI toggle in feature flags settings section.
Update all tests and stories to include the new flag field.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Define the ICoastsService application-layer output port with 10 methods
(checkPrerequisites, build, run, stop, lookup, isRunning, checkout,
getInstallationPrompt, generateCoastfile, hasCoastfile) plus supporting
types PrerequisiteCheckResult and CoastInstance. Add barrel export and
type-level tests validating all method signatures and type shapes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…di registration

Implement CoastsService wrapping the coast CLI binary via injected
ExecFunction for containerized runtime isolation. Includes parallel
prerequisite checks (coast binary, Docker, coastd daemon), coast CLI
operations (build, run, stop, checkout, lookup), installation prompt
caching, and AI-powered Coastfile generation via IStructuredAgentCaller.
Register ICoastsService in the DI container with factory-based injection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…erver

Add coastsDevServer feature flag branching in dev-server.ts after DI
initialization. When enabled: checks prerequisites, generates Coastfile
if missing, builds and runs via coast CLI. When disabled (default), bare
Next.js path is completely unchanged (NFR-1 zero regression).

Extracted startCoastsDevServer and shutdownCoasts into coasts-dev-server.ts
for testability. Shutdown handler detects Coasts mode via null check and
calls coastsService.stop() with error handling. Added dev:coasts convenience
script to package.json.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ogic

Tests startCoastsDevServer and shutdownCoasts with mocked ICoastsService
covering all branching scenarios: flag enabled with prerequisites met,
missing prerequisites, coastfile generation, build/run failures, and
graceful shutdown in both coasts and bare modes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The coastsDevServer feature flag was defined in FLAG_KEYS and
FLAG_LABELS but missing from the manually rendered SwitchRow
list in settings-page-client.tsx, causing the toggle to not
appear in the actual settings page.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Evidence includes:
- App screenshot showing Coasts Dev Server toggle in settings
- Full settings page screenshot
- CoastsService unit tests (30 passing)
- Coasts dev-server module tests (16 passing)
- Dev-server branching integration tests (12 passing)
- Full test suite results (5080 tests, zero regressions)
- Build output (clean compilation)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…rmalize yaml

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@arielshad arielshad force-pushed the feat/coasts-dev-server branch from 5b0c90c to 576f0c7 Compare March 20, 2026 20:32
Pass isWindows=false explicitly in test beforeEach to prevent
auto-detection short-circuiting on Windows CI. Replace path
assertion with path.join for cross-platform compatibility.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link

Dev Release Published

Artifact Version Install
npm 1.135.2-pr437.64c56e0 npm install -g @shepai/cli@1.135.2-pr437.64c56e0

Published from commit d7232e2 | View CI

arielshad and others added 8 commits March 20, 2026 23:26
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tion

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tfile generation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link

Dev Release Published

Artifact Version Install
npm 1.136.0-pr437.9f802f1 npm install -g @shepai/cli@1.136.0-pr437.9f802f1

Published from commit ad3b11a | View CI

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