---
name: dev-start
description: Launch SmartStack dev environment (backend + frontend + admin credentials)
argument-hint: "[--stop] [--restart] [--clean] [--reset] [--backend-only] [--frontend-only]"
model: sonnet
allowed-tools: Bash, BashOutput, PowerShell
disable-model-invocation: true
---

`/dev-start` is a thin wrapper over the **deterministic `ss dev up` orchestrator**.
`ss dev up` runs the WHOLE workflow in ONE process — detect → (self-repair) →
ensure deps → (restart: stop + build) → launch detached → wait for readiness →
render the cartouche — driven by a tested state machine, NOT by you. You do **not**
chain `detect`/`start`/`wait`/`summary` by hand any more: you run one command and
relay its result.

## THE RULE — always output the cartouche, never a summary
**In every case where `ss dev up` returns a `cartouche`, that field IS your entire reply — output it VERBATIM, and nothing else before or instead of it.** It is forbidden to replace it with a hand-written status sentence ("Serveurs prêts", "servers ready", "c'est lancé", "à toi de tester"…). The user reads the GROUND TRUTH only from the box: per-side `✓ up` / `✗ DOWN`, `Health`, and every `⚠` CORS / port / FrontendUrl warning. A summary HIDES a DOWN side or a broken-CORS warning and makes the user think the app works when it does not — that is exactly the bug this rule exists to kill. Relay the rendered string as-is; never re-type, paraphrase, or pre-empt it.

## Important
- **Bash runs Git Bash (POSIX)** on Windows. Use `ss dev …` only — never `run_in_background`, never raw `dotnet run`/`npm run`. The CLI launches each server as a hidden, fully-detached process tree (WMI, outside the harness Job Object) that survives the session.
- Run `ss dev up <flags> --json` plain — do **not** pipe it through `jq`/`head`/etc. You parse the single JSON line yourself and then output its `cartouche` field verbatim.

## Routing — run ONE Bash command
Parse `$ARGUMENTS`:
- Contains `--stop` → `ss dev stop [--backend-only|--frontend-only] --json` → relay the JSON → DONE.
- Otherwise → `ss dev up <flags> --json`, passing through any of `--restart --clean --reset --backend-only --frontend-only` **verbatim**.

## Handle the result — read the JSON `status`
- **`"ok"`** → output the `cartouche` field **VERBATIM as your whole reply** (THE RULE above) — it carries URLs · database · admin login + real password · health · ⚠ warnings. DONE. A non-zero exit just means a side is DOWN — the box already shows it; **never restart/rebuild/loop because of it**, and never paper over it with "prêts".
- **`"error"`** → there is no cartouche (nothing launched). Print `message`; if `phase == "build"` also print `compiler_output` (the compiler tail). DONE.
- **`"needs_input"`** → a real config problem needs a human decision. Ask **ONE** `AskUserQuestion`, then re-enter:
  1. Show `message` + the proposed free ports (`proposed_ports.api` / `.web`), header "Ports":
     - **[1] Use proposed** · **[2] Custom** — the user types 2 ports (accept a pattern like `21xx` → 2100/2101; if you can, verify free + distinct) · **[3] Manual edit** — print the file list ONCE and STOP (do **not** write the files yourself).
  2. If `needs_sql == true` (a first setup only) also ask: auth mode (Windows **or** SQL login) + SQL server + database (default `sql_defaults.database`) [+ login/password if SQL].
  3. Write the config with ONE Bash, filling the placeholders in `reentry`:
     - ports-only (`mismatch` / `occupied`, existing config) → `reentry.configure_ports_only`.
     - first setup (`needs_setup`) → `reentry.configure_first_setup` (add `"sqlLogin"`/`"sqlPassword"` for SQL auth).
     Parse `{ success }`; on `success:false` print `error` and STOP.
  4. Run `reentry.then` (`ss dev up … --json`) and handle THAT result (terminal: `ok`/`error`). **Re-enter at most ONCE** — a second non-`ok` is final.

## Notes
- **Idempotent / never-halt.** If our own servers are already up and the cache is fresh, `ss dev up` returns the cartouche in one shot. A foreign process squatting our port is rendered **DOWN, never ✓ up** (strong-identity check on the launched child PID), so it never silently reuses a stranger.
- **`--restart`** = stop → incremental `dotnet build` (fail-fast: a compile error returns `status:"error", phase:"build"` and nothing is launched) → relaunch → wait → cartouche. **`--clean`** = full `dotnet clean && build` + clears the Vite cache. `--frontend-only` skips the build/wait; `--backend-only` skips deps/Vite.
- **`appsettings.Local.json`** holds the SQL password + JWT — `ss dev configure` creates it gitignored and sweeps a port change through every URL in it. You **never** hand-edit config files; `configure` writes them.
- Dev is **HTTP-only** (two ports, no https) — never propose an `httpsPort`.
