@devrouter/cli 0.0.25 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,18 +2,32 @@
2
2
 
3
3
  Local-first routing for macOS development with one shared Traefik router.
4
4
 
5
+ ## AI Agent Onboarding
6
+
7
+ If you are pair programming with an AI agent (such as Cursor, GitHub Copilot, Gemini, or Claude) to onboard or work on a repository, run the following command at the very start to generate a ready-to-copy, context-rich onboarding prompt for the agent:
8
+
9
+ ```bash
10
+ # Using npm/npx:
11
+ npx @devrouter/cli init --repo .
12
+
13
+ # Or using pnpm/pnpm dlx:
14
+ pnpm dlx @devrouter/cli init --repo .
15
+ ```
16
+
17
+ This prints a canonical prompt containing the full config schemas, best-practice workflows, docker dependency configurations, and verification commands required to configure the repo's devrouter setup.
18
+
5
19
  ## What it solves
6
20
 
7
21
  Run multiple repos concurrently without manual port juggling:
8
22
 
9
23
  - HTTP apps by hostname: `web.localhost`, `api.localhost`
10
- - PostgreSQL DBs by hostname on shared `:5432` via TLS/SNI: `db.localhost`
24
+ - Databases (Postgres, Redis, MariaDB, MySQL) by hostname on their standard shared ports via TLS/SNI: `db.localhost`, `redis.localhost`
11
25
 
12
26
  Traefik owns:
13
27
 
14
28
  - `:80` (HTTP)
15
29
  - `:443` (HTTPS)
16
- - `:5432` (Postgres TCP routing)
30
+ - Shared protocol ports for activated databases (e.g. `:5432`, `:6379`, `:3306`)
17
31
 
18
32
  ## Unified repo config
19
33
 
@@ -51,6 +65,12 @@ devrouter repo devcontainer verify --live --yes --json
51
65
 
52
66
  Why prefer it: the environment is reproducible and runs anywhere the devcontainer
53
67
  spec runs, while devrouter gives it stable local HTTPS and database hostnames.
68
+
69
+ We recommend **DevPod** to orchestrate the devcontainer lifecycle locally because:
70
+ - **IDE/Editor Independence**: DevPod manages the container lifecycle and code synchronization in the background, allowing developers to use any local editor (VS Code, JetBrains, vim) with the containerized toolchain.
71
+ - **No Vendor Lock-in**: It is a client-only, open-source runner that runs entirely locally on Docker without requiring Microsoft's proprietary VS Code extensions or cloud-based runners.
72
+ - **devrouter Integration**: DevPod spins up the devcontainer compose stack on the `devnet` network, and devrouter handles dynamic HTTPS domain routing (`*.localhost`), making manual port-forwarding management obsolete.
73
+
54
74
  Agents can add the scaffold with `devrouter repo inspect`, `devrouter repo devcontainer write`,
55
75
  and `devrouter repo devcontainer verify`, then include the JSON evidence in a PR. See
56
76
  [`docs/DEVCONTAINER.md`](./docs/DEVCONTAINER.md) for the full reference.
@@ -86,6 +106,7 @@ vars. Use it when you are not (yet) on a devcontainer. Fully supported.
86
106
  - `devrouter app rm <name> [--repo <path>]`
87
107
  - `devrouter logs [-f]`
88
108
  - `devrouter workspace up <branch> [--path <dir>] [--no-devpod] [--open] [--repo <path>]`
109
+ - `devrouter workspace ensure [path] [--open]`
89
110
  - `devrouter workspace ls [--repo <path>] [--json]`
90
111
  - `devrouter workspace down <workspace|branch> [--keep-worktree] [--keep-devpod] [--repo <path>]`
91
112
 
@@ -100,12 +121,12 @@ mutate local route state.
100
121
 
101
122
  A **workspace token** lets several git worktrees of the same repo run side-by-side without host or route collisions. The token is a single identity spanning three layers: the devpod workspace id, the routes devrouter registers, and the `${WORKSPACE}` placeholder in `.devrouter.yml` proxy upstreams and devcontainer compose network aliases.
102
123
 
103
- **Token resolution precedence** (highest to lowest):
104
-
105
- 1. `--workspace <slug>` CLI flag
106
- 2. `DEVROUTER_WORKSPACE` environment variable
107
- 3. Auto-derived from the linked git worktree's branch name (sanitized: lowercase, non-alphanumeric `-`, capped at 32 chars)
108
- 4. None the primary checkout uses no token and routes exactly as a plain repo (back-compatible)
124
+ Each linked worktree stores one stable identity in its Git metadata. Once stored,
125
+ that value is authoritative: an explicit flag or `DEVROUTER_WORKSPACE` may repeat
126
+ it but cannot silently rename the environment. On first use, devrouter reuses the
127
+ exact DevPod already bound to the worktree path or derives a sanitized identity
128
+ from the linked branch/path. Ambiguous identities and DevPods owned by another
129
+ worktree fail closed. The primary checkout keeps its plain, non-namespaced routes.
109
130
 
110
131
  **When a workspace token is active:**
111
132
 
@@ -122,6 +143,9 @@ A **workspace token** lets several git worktrees of the same repo run side-by-si
122
143
  # Bring up a feature branch as an isolated workspace
123
144
  devrouter workspace up feat/my-feature
124
145
 
146
+ # Reconcile an existing linked worktree (canonical agent startup command)
147
+ devrouter workspace ensure .
148
+
125
149
  # List git worktrees with workspace tokens and route counts
126
150
  devrouter workspace ls
127
151
 
@@ -129,7 +153,16 @@ devrouter workspace ls
129
153
  devrouter workspace down feat/my-feature
130
154
  ```
131
155
 
132
- **devcontainer integration:** the devcontainer compose service exposes a devnet network alias `${WORKSPACE}-app` (defaulting to the project name in `devcontainer.env`); the proxy app uses `upstream: ${WORKSPACE}-app:<port>`. Workspace `feat-a` alias `feat-a-app`, host `app.feat-a.localhost`.
156
+ New worktrees default to the repository's ignored `trees/<workspace>` directory; use `--path` only when a repository intentionally follows another layout.
157
+
158
+ **devcontainer integration:** the devcontainer compose service exposes a devnet network alias `${WORKSPACE}-app` (defaulting to the project name in `devcontainer.env`); the proxy app uses `upstream: ${WORKSPACE}-app:<port>`. `.devcontainer/docker-compose.devrouter.yml` passes `WORKSPACE` and `DEVROUTER_WORKSPACE` into the app and bind-mounts `${DEVROUTER_GIT_COMMON_DIR}` to the same absolute container path, so linked-worktree `.git` pointers remain valid. Workspace `feat-a` → alias `feat-a-app`, host `app.feat-a.localhost`.
159
+
160
+ `workspace ensure` is intentionally proof-driven: it verifies exact worktree
161
+ ownership, the compose overlay and Git mount, workspace env, devnet aliases,
162
+ container health, Git access, HTTP route reachability, and unique running TCP
163
+ upstream ownership (plus health when configured) before reporting ready. It
164
+ retries one stale DevPod with `--recreate`; failed proof does not leave new routes
165
+ behind.
133
166
 
134
167
  **Try it:** [`examples/workspace/`](examples/workspace/) is a runnable showcase — `./run.sh` brings up one app in two parallel worktrees (`wsdemo.localhost` and `wsdemo.feat-a.localhost`) served at once, then `./run.sh down` tears it down.
135
168
 
@@ -370,6 +403,18 @@ See details:
370
403
 
371
404
  `devrouter repo agents` writes a devrouter section into the repo's `AGENTS.md` and installs a skill file at `.agents/skills/devrouter/SKILL.md`. The skill content is embedded in the CLI bundle so it stays in sync across repos.
372
405
 
406
+ ## Development quality
407
+
408
+ `pnpm check` runs Biome formatting, lint, and import-order checks. `pnpm check:fix` applies safe fixes automatically. `pnpm knip` detects unused files, dependencies, and unresolved imports. `pnpm typecheck` runs TypeScript checks across the repo.
409
+
410
+ Pre-commit hooks run on every commit once installed:
411
+
412
+ ```sh
413
+ pre-commit install
414
+ ```
415
+
416
+ Hooks run Biome safe fixes, Knip, Gitleaks secret scanning, and basic file checks (trailing whitespace, merge conflict markers, large file guard).
417
+
373
418
  ## Known limitations (v1)
374
419
 
375
420
  - Host-runtime dependencies are not auto-started; only Docker dependencies are auto-started.