@nebulr-group/bridge-cli 0.1.4 → 0.4.0-beta.0

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.
Files changed (43) hide show
  1. package/README.md +26 -4
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +4 -0
  4. package/dist/cli.js.map +1 -1
  5. package/dist/commands/app.command.d.ts.map +1 -1
  6. package/dist/commands/app.command.js +2 -0
  7. package/dist/commands/app.command.js.map +1 -1
  8. package/dist/commands/flag-init.command.d.ts +13 -0
  9. package/dist/commands/flag-init.command.d.ts.map +1 -0
  10. package/dist/commands/flag-init.command.js +353 -0
  11. package/dist/commands/flag-init.command.js.map +1 -0
  12. package/dist/commands/flag.command.d.ts +92 -0
  13. package/dist/commands/flag.command.d.ts.map +1 -1
  14. package/dist/commands/flag.command.js +784 -25
  15. package/dist/commands/flag.command.js.map +1 -1
  16. package/dist/commands/guide.command.d.ts +21 -0
  17. package/dist/commands/guide.command.d.ts.map +1 -1
  18. package/dist/commands/guide.command.js +297 -21
  19. package/dist/commands/guide.command.js.map +1 -1
  20. package/dist/commands/integrate.command.js +3 -3
  21. package/dist/commands/integrate.command.js.map +1 -1
  22. package/dist/commands/ops.command.d.ts +17 -0
  23. package/dist/commands/ops.command.d.ts.map +1 -0
  24. package/dist/commands/ops.command.js +129 -0
  25. package/dist/commands/ops.command.js.map +1 -0
  26. package/dist/commands/plan.command.d.ts +31 -0
  27. package/dist/commands/plan.command.d.ts.map +1 -1
  28. package/dist/commands/plan.command.js +182 -1
  29. package/dist/commands/plan.command.js.map +1 -1
  30. package/dist/commands/stripe.command.d.ts +3 -0
  31. package/dist/commands/stripe.command.d.ts.map +1 -0
  32. package/dist/commands/stripe.command.js +43 -0
  33. package/dist/commands/stripe.command.js.map +1 -0
  34. package/dist/output.d.ts +8 -0
  35. package/dist/output.d.ts.map +1 -1
  36. package/dist/output.js +10 -0
  37. package/dist/output.js.map +1 -1
  38. package/dist/prompts/architecture.md +560 -0
  39. package/dist/prompts/auth-master-integration-prompt.md +251 -0
  40. package/dist/prompts/billing/master.md +269 -0
  41. package/dist/prompts/flags/master.md +215 -0
  42. package/dist/prompts/integration-success.md +107 -0
  43. package/package.json +4 -3
@@ -0,0 +1,215 @@
1
+ # Bridge Feature Flags — Master Integration Prompt
2
+
3
+ You are integrating **Bridge Feature Flags** into a user's application — the flags-only path. No auth scaffolding, no billing components. If the user also wants auth or billing, run `bridge guide` (auth master) or `bridge guide billing` afterwards.
4
+
5
+ This master prompt orchestrates discovery, confirmation, and verification. The **actual install commands, provider shapes, and runnable code snippets live in the per-framework prompts** that ship in each plugin repo's `mcp/` folder. This master does the planning; the per-framework prompts do the wiring.
6
+
7
+ ## Where per-framework prompts live
8
+
9
+ Each plugin repo owns its own framework-specific prompt under `mcp/feature-flags-prompt.md`. The CLI fetches them on demand:
10
+
11
+ | Framework | Plugin repo | Fetched by |
12
+ |-----------|-------------|------------|
13
+ | SvelteKit | `bridge-svelte/mcp/feature-flags-prompt.md` | `bridge guide flags --framework svelte` |
14
+ | React | `bridge-react/mcp/feature-flags-prompt.md` | `bridge guide flags --framework react` |
15
+ | Next.js | `bridge-nextjs/mcp/feature-flags-prompt.md` | `bridge guide flags --framework nextjs` |
16
+ | Angular | `bridge-angular/mcp/feature-flags-prompt.md` | `bridge guide flags --framework angular` |
17
+ | NestJS | `bridge-nestjs/mcp/feature-flags-prompt.md` | `bridge guide flags --framework nestjs` |
18
+ | Express | `bridge-express/mcp/feature-flags-prompt.md` | `bridge guide flags --framework express` |
19
+
20
+ `bridge guide <framework> flags` is an equivalent route — both call the same plugin-repo prompt.
21
+
22
+ If the CLI returns `HTTP 404 — file may not exist yet in the plugin repo`, the plugin hasn't published its Flags guide yet. Tell the user that's the blocker and fall back to `@nebulr-group/bridge-auth-core` directly (it's framework-agnostic and stable). Do NOT improvise an inline integration in this master prompt — the plugin guide is the canonical handover.
23
+
24
+ ## Step 0 — Authenticate
25
+
26
+ Run `bridge auth login` and wait for it to print "Logged in as <email>".
27
+
28
+ If the user is using flags **without Bridge Auth** (bring-your-own identity), they still need to be logged into the CLI to fetch app config and manage flags. Login is not the same as runtime identity.
29
+
30
+ ---
31
+
32
+ **At the end of this integration you will output a success message:**
33
+
34
+ ```
35
+ ██████╗ ██████╗ ██╗██████╗ ██████╗ ███████╗
36
+ ██╔══██╗██╔══██╗██║██╔══██╗██╔════╝ ██╔════╝
37
+ ██████╔╝██████╔╝██║██║ ██║██║ ███╗█████╗
38
+ ██╔══██╗██╔══██╗██║██║ ██║██║ ██║██╔══╝
39
+ ██████╔╝██║ ██║██║██████╔╝╚██████╔╝███████╗
40
+ ╚═════╝ ╚═╝ ╚═╝╚═╝╚═════╝ ╚═════╝ ╚══════╝
41
+
42
+ ──────────────────────────────────────────────
43
+ Feature flags are live in [project-name].
44
+
45
+ ✅ Flags read from the bulk-evaluate endpoint at boot
46
+ ✅ Eval context wired: [identity-source]
47
+ ✅ Telemetry batching enabled
48
+ ✅ Realtime updates enabled (optional)
49
+ ──────────────────────────────────────────────
50
+ Here is what I actually did:
51
+ [what-i-actually-did]
52
+
53
+ And here is what I changed:
54
+ [what-i-changed]
55
+ ──────────────────────────────────────────────
56
+ ```
57
+
58
+ Track as you work:
59
+ - **`[project-name]`** — folder name and/or `package.json` name for each project
60
+ - **`[identity-source]`** — how `identity` flows in (Bridge Auth `user.id`, your own session, anonymous bucket ID, etc.)
61
+ - **`[what-i-actually-did]`** — high-level outcomes
62
+ - **`[what-i-changed]`** — every package installed, file modified, env var set
63
+
64
+ ## Mental model (1-minute version)
65
+
66
+ A flag in has:
67
+
68
+ | Field | Possible values |
69
+ |---|---|
70
+ | `state` | `off` · `on` · `on-with-rule` |
71
+ | `valueType` | `boolean` · `string` · `number` · `json` |
72
+ | `offValue` | typed per `valueType` (returned when state=off) |
73
+ | `onValue` | typed per `valueType` (returned when state=on) |
74
+ | `rule` | branches[] + otherwiseValue + rolloutPct (only when state=on-with-rule) |
75
+
76
+ Branches are first-match-wins; conditions within a branch AND together; `rolloutPct` is rule-level (0-100) and requires `identity` on the eval context.
77
+
78
+ The SDK call is the same everywhere — `bridge.flag(key, defaultValue)`. The return type is inferred from `defaultValue`, so no casts.
79
+
80
+ ## Step 1 — Discover projects
81
+
82
+ Scan the current directory and its immediate subdirectories for `package.json` files. For each one:
83
+
84
+ 1. **Package manager** — detect from lock file:
85
+ - `bun.lock` / `bun.lockb` → `bun`
86
+ - `pnpm-lock.yaml` → `pnpm`
87
+ - `yarn.lock` → `yarn`
88
+ - `package-lock.json` or none → `npm`
89
+
90
+ 2. **Framework** (from `dependencies` + `devDependencies`):
91
+ - `svelte` or `@sveltejs/kit` → **SvelteKit**
92
+ - `react` + `next` → **Next.js**
93
+ - `react` (without next) → **React**
94
+ - `@angular/core` → **Angular**
95
+ - `@nestjs/core` → **NestJS** (backend)
96
+ - `express` (without `@nestjs/core`) → **Express** (backend)
97
+
98
+ 3. **Existing Bridge plugin?** Check for `@nebulr-group/bridge-<framework>` — if present, the project may already have auth or other Bridge surfaces. Flags can co-exist with auth in the same plugin; the per-framework guide will tell you whether the unified `useBridge()` is already in place.
99
+
100
+ 4. **Existing flag system?** Look for `launchdarkly-*`, `@unleash/*`, `posthog-js`, `growthbook-*` — warn the user that Bridge flags will run in parallel unless they migrate.
101
+
102
+ 5. **Record** for each project: path, type (frontend/backend), framework, package manager, existing flag system (if any).
103
+
104
+ ## Step 2 — Present findings and confirm
105
+
106
+ ```
107
+ I detected the following projects:
108
+
109
+ 1. ./my-app-ui — SvelteKit 5 (frontend, bun)
110
+ Existing flags: none
111
+
112
+ 2. ./my-app-api — NestJS 11 (backend, bun)
113
+ Existing flags: none
114
+
115
+ Which projects should I wire flags into? (all / select by number)
116
+ ```
117
+
118
+ Wait for confirmation. If specific projects are selected, only integrate those.
119
+
120
+ **Identity source (frontend + backend both).** Ask:
121
+
122
+ ```
123
+ How should flags identify users?
124
+
125
+ - Bridge Auth (default if already integrated) — uses the authenticated user's id
126
+ - Your own user model — you pass identity yourself per call / per request
127
+ - Anonymous — every visitor gets a stable random bucket id (no targeting beyond rolloutPct)
128
+ ```
129
+
130
+ Note the answer — Step 4 wires the eval context based on it.
131
+
132
+ ## Step 3 — Get Bridge app context
133
+
134
+ Run:
135
+
136
+ ```bash
137
+ bridge app get
138
+ bridge info flags
139
+ ```
140
+
141
+ Extract and note:
142
+ - `appId` — needed by every project
143
+ - Existing flags in the app (if any) — useful to show the user what they can already read
144
+
145
+ If `bridge` CLI is not available or not configured, ask the user for the `appId` directly.
146
+
147
+ ## Step 4 — Fetch the per-framework prompt and follow it
148
+
149
+ For each confirmed project, fetch the framework-specific flags prompt and follow it verbatim:
150
+
151
+ ```bash
152
+ bridge guide flags --framework <name>
153
+ ```
154
+
155
+ Where `<name>` is one of: `svelte`, `react`, `nextjs`, `angular`, `nestjs`, `express`.
156
+
157
+ | Framework | Command |
158
+ |-----------|---------|
159
+ | SvelteKit | `bridge guide flags --framework svelte` |
160
+ | React | `bridge guide flags --framework react` |
161
+ | Next.js | `bridge guide flags --framework nextjs` |
162
+ | Angular | `bridge guide flags --framework angular` |
163
+ | NestJS | `bridge guide flags --framework nestjs` |
164
+ | Express | `bridge guide flags --framework express` |
165
+
166
+ `bridge guide <framework> flags` is an equivalent route — both call the same plugin-repo prompt.
167
+
168
+ **Every per-framework guide covers this contract:**
169
+
170
+ - **Install** — the right package + version + import path (`/flags` entry point so auth code isn't pulled in unnecessarily)
171
+ - **Bootstrap** — provider / module / factory setup, `appId` + `baseUrl` + `mode` config
172
+ - **Eval context** — idiomatic placement for `identity` and `attributes`, including how to wire the `identitySource` chosen in Step 2
173
+ - **Reading a flag** — the framework wrapper (`useFlag`, `FeatureFlag`, `signal`, decorator) and the synchronous `evaluateFlag` for non-reactive contexts
174
+ - **Advanced attribute wiring** — the unified `bridge.attributes` write surface and realtime event subscription via `bridge.events.handle`
175
+ - **Telemetry + realtime** — both on by default; how to disable
176
+ - **Troubleshooting** — the most common first-time failures
177
+
178
+ **Pass these values from this master to the per-framework prompt:**
179
+ - `appId` — from Step 3
180
+ - `baseUrl` — `https://api.thebridge.dev` (default; only override for self-hosted)
181
+ - `packageManager` — from Step 1
182
+ - `mode` — `frontend` (browser projects) or `backend` (NestJS, Express, Next.js server)
183
+ - `identitySource` — from Step 2
184
+
185
+ **Order:** Frontend first, then backend.
186
+
187
+ If the CLI returns `HTTP 404`, the plugin hasn't published its Flags guide yet. Tell the user that's the blocker and fall back to `@nebulr-group/bridge-auth-core` directly — `new BridgeFlags({ appId, baseUrl, mode })` + `bridge.setContext({...})` + `bridge.flag(...)`. The SDK shape is identical across frameworks; only the bindings differ.
188
+
189
+ ## Step 5 — Verify
190
+
191
+ For each integrated project:
192
+
193
+ 1. **Build check** — run the project's build command (from `package.json` scripts)
194
+ 2. **Eval check** — read one flag (existing or freshly created) and confirm it returns the expected value
195
+ 3. **Context check** — confirm `identity` is set when the project uses any rolled-out rule
196
+
197
+ If anything fails, diagnose and fix before moving on.
198
+
199
+ ## Step 6 — Tell the developer what they just got
200
+
201
+ Output the success message at the top of this prompt, personalised for what you actually did. Same rules as the auth master:
202
+
203
+ - Fill every `[placeholder]` with real values
204
+ - Strip any agent-only notes
205
+ - Group by project if both frontend and backend were integrated
206
+ - **Do not** write any text before the banner — start with the `█` character
207
+ - If a build is broken or flag reads return defaults forever, prepend a single "Heads up:" line before the banner
208
+
209
+ After delivering the message, the flags integration is complete.
210
+
211
+ ## Reference notes
212
+
213
+ **Frontend vs backend:** The frontend SDK evaluates flags from a local cache hydrated at boot. The backend SDK (`mode: 'backend'`) evaluates per-request and requires an explicit `identity` for any rule using `rolloutPct < 100` — no anonymous bucketing.
214
+
215
+ **Flags without Bridge Auth:** Flags work standalone. Pass your own `identity` and `attributes` when `identitySource` is "your own user model". If Bridge Auth is already installed, `role` and `plan` merge into the eval context automatically via the auth attribute provider wired by the per-framework guide.
@@ -0,0 +1,107 @@
1
+ ██████╗ ██████╗ ██╗██████╗ ██████╗ ███████╗
2
+ ██╔══██╗██╔══██╗██║██╔══██╗██╔════╝ ██╔════╝
3
+ ██████╔╝██████╔╝██║██║ ██║██║ ███╗█████╗
4
+ ██╔══██╗██╔══██╗██║██║ ██║██║ ██║██╔══╝
5
+ ██████╔╝██║ ██║██║██████╔╝╚██████╔╝███████╗
6
+ ╚═════╝ ╚═╝ ╚═╝╚═╝╚═════╝ ╚═════╝ ╚══════╝
7
+
8
+ ──────────────────────────────────────────────
9
+ Congratulations — [project-name] now has superpowers.
10
+
11
+ ✅ Authentication
12
+ UI for users to signup and login. Enable more
13
+ alternatives from the control center.
14
+
15
+ ✅ Locked by default
16
+ Every route protected. Unauth'd users
17
+ bounce to login automatically.
18
+
19
+ ✅ Multi-tenant ready
20
+ Teams · Orgs · Workspaces · RBAC
21
+ Tenant context flows through every request.
22
+
23
+ ✅ You know who's calling
24
+ [token-description]
25
+ One token. Every auth alternative covered.
26
+
27
+ ──────────────────────────────────────────────
28
+ The control center gives you even more powers.
29
+
30
+ › Billing Stripe plans & subscriptions → bridge guide [framework] payments
31
+ › Feature flags Per-user, per-plan toggles → bridge guide flags
32
+ › Team management Invites, roles, orgs → bridge guide [framework] team
33
+
34
+ Run any of those when you're ready.
35
+
36
+ Go build the thing that actually matters.
37
+
38
+ ──────────────────────────────────────────────
39
+ Here is what I actually did:
40
+
41
+ [what-i-actually-did]
42
+
43
+ And here is what I changed:
44
+
45
+ [what-i-changed]
46
+ ──────────────────────────────────────────────
47
+
48
+ ---
49
+ AGENT SUBSTITUTION GUIDE (strip this section before outputting)
50
+
51
+ PLACEHOLDER: project-name
52
+ Pick the most human-readable name available. Prefer in this order:
53
+ 1. The folder name (e.g. "my-saas-app") — often more meaningful than the package name
54
+ 2. The `name` field in package.json if it's descriptive
55
+ If both frontend and backend were integrated, combine them:
56
+ "my-saas-app + my-saas-api" or just the shared root folder name if obvious.
57
+
58
+ PLACEHOLDER: framework
59
+ In the "control center" next-steps lines, replace `[framework]` with the
60
+ framework slug used by `bridge guide` (`svelte`, `react`, `nextjs`, `angular`,
61
+ `nestjs`, `express`). Use the frontend framework when both frontend and
62
+ backend were integrated. Leave `bridge guide flags` unchanged — that command
63
+ auto-detects the framework from `package.json`.
64
+
65
+ PLACEHOLDER: token-description
66
+ One short line — the key identifiers the developer uses to access the
67
+ authenticated user in their specific framework. No explanation.
68
+ Examples:
69
+ Svelte: profileStore · isAuthenticated · tokenStore
70
+ React: useProfile() · useIsAuthenticated() · useToken()
71
+ NestJS: @CurrentUser() on any endpoint
72
+ Express: req.user on any protected route
73
+ If both frontend and backend were integrated, combine on one line:
74
+ profileStore (frontend) · @CurrentUser() (backend)
75
+
76
+ PLACEHOLDER: what-i-actually-did
77
+ 3–5 bullet lines drawn from what actually happened in this session.
78
+ High-level outcomes in plain English — not file names.
79
+ If both frontend and backend were integrated, group under headings:
80
+
81
+ Frontend (my-saas-app):
82
+ ✅ Auth UI live — signup, login, password reset
83
+ ✅ All routes protected by default
84
+
85
+ Backend (my-saas-api):
86
+ ✅ All endpoints require a verified JWT
87
+ ✅ Authenticated user available on every request
88
+
89
+ PLACEHOLDER: what-i-changed
90
+ The nitty-gritty. One line per actual change, drawn from what you did in this
91
+ session. Real package names, real file paths, real URLs, real values. Omit
92
+ anything that was skipped.
93
+ If both frontend and backend were integrated, group under headings:
94
+
95
+ Frontend (my-saas-app):
96
+ ✅ @nebulr-group/bridge-svelte installed
97
+ ✅ src/routes/+layout.ts wired with bridgeBootstrap()
98
+ ✅ src/routes/+layout.svelte rendering <BridgeBootstrap>
99
+ ✅ OAuth callback route at /auth/oauth-callback
100
+ ✅ .env configured with VITE_BRIDGE_APP_ID=abc123
101
+ ✅ Bridge app configured for http://localhost:5175
102
+
103
+ Backend (my-saas-api):
104
+ ✅ @nebulr-group/bridge-nestjs installed
105
+ ✅ BridgeModule registered in AppModule
106
+ ✅ Global JWT guard applied
107
+ ✅ .env configured with BRIDGE_APP_ID=abc123
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nebulr-group/bridge-cli",
3
- "version": "0.1.4",
3
+ "version": "0.4.0-beta.0",
4
4
  "description": "Bridge platform CLI for AI coding agents and developers",
5
5
  "author": "Nebulr Group",
6
6
  "license": "MIT",
@@ -16,14 +16,15 @@
16
16
  "LICENSE"
17
17
  ],
18
18
  "scripts": {
19
- "build": "tsc",
19
+ "build": "tsc && npm run copy:prompts",
20
+ "copy:prompts": "node -e \"const fs=require('fs'),path=require('path');function cp(s,d){if(fs.statSync(s).isDirectory()){fs.mkdirSync(d,{recursive:true});for(const f of fs.readdirSync(s))cp(path.join(s,f),path.join(d,f));}else fs.copyFileSync(s,d);}fs.rmSync('dist/prompts',{recursive:true,force:true});cp('prompts','dist/prompts');console.log('Copied prompts/ -> dist/prompts/');\"",
20
21
  "prepublishOnly": "npm run build",
21
22
  "test": "jest --passWithNoTests",
22
23
  "test:coverage": "jest --coverage",
23
24
  "publish:local": "npm run build && node -e \"const fs=require('fs'),p=JSON.parse(fs.readFileSync('package.json','utf8')),v=p.version.match(/^(\\d+\\.\\d+\\.\\d+)-alpha\\.(\\d+)$/);if(v){p.version=v[1]+'-alpha.'+(+v[2]+1);}else{p.version=p.version+'-alpha.0';}fs.writeFileSync('package.json',JSON.stringify(p,null,' ')+'\\n');console.log('Version bumped to '+p.version);\" && npm publish --registry http://host.docker.internal:4873 --no-git-checks --ignore-scripts && npm dist-tag add @nebulr-group/bridge-cli@$(node -p \"require('./package.json').version\") alpha --registry http://host.docker.internal:4873"
24
25
  },
25
26
  "dependencies": {
26
- "@nebulr-group/bridge-auth-core": "^0.1.0",
27
+ "@nebulr-group/bridge-auth-core": "0.4.0-beta.0",
27
28
  "commander": "^12.0.0"
28
29
  },
29
30
  "devDependencies": {