@whisperr/wizard 0.1.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.
- package/README.md +151 -0
- package/dist/index.js +1149 -0
- package/dist/index.js.map +1 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Whisperr Wizard
|
|
2
|
+
|
|
3
|
+
> One command to integrate Whisperr into any app. The user pastes a command,
|
|
4
|
+
> authenticates with their onboarded account, and an AI coding agent wires up
|
|
5
|
+
> `identify()` and the exact business events Whisperr needs — then they push and
|
|
6
|
+
> deploy. Inspired by the PostHog wizard, but onboarding-aware.
|
|
7
|
+
|
|
8
|
+
Run it in your project root. No install, no setup — `npx` fetches the wizard and
|
|
9
|
+
its dependencies (including the coding-agent runtime) and runs it from the
|
|
10
|
+
current directory. The only thing you do is authenticate.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
cd your-app
|
|
14
|
+
npx @whisperr/wizard
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## What it does (the flow)
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
detect stack ─▶ authenticate (browser) ─▶ load manifest ─▶ git checkpoint ─▶ agent edits ─▶ verify first event
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
1. **Detect** the repo's language/framework (Flutter, Web/JS, Next.js, React
|
|
24
|
+
Native, Swift…).
|
|
25
|
+
2. **Authenticate** via an OAuth device flow — the browser opens, the user (who
|
|
26
|
+
is already logged in from onboarding) approves, and the CLI gets a short-lived
|
|
27
|
+
session token bound to their app.
|
|
28
|
+
3. **Load the integration manifest** from whisperr-go: the ingestion API key, the
|
|
29
|
+
specific snake_case events to instrument, the interventions each event drives,
|
|
30
|
+
and `identify()` guidance — all derived from the user's onboarding.
|
|
31
|
+
4. **Checkpoint** with git so the auto-applied edits are reversible.
|
|
32
|
+
5. **Run the coding agent** (Claude Agent SDK) inside the repo: add the SDK
|
|
33
|
+
dependency, initialize it, wire `identify()`, and place `track()` calls at the
|
|
34
|
+
correct call sites for each manifest event.
|
|
35
|
+
6. **Verify** by polling for the first event — the "Whisperr is receiving
|
|
36
|
+
events ✓" moment, which also lights up the dashboard.
|
|
37
|
+
|
|
38
|
+
## Why it's better than a generic wizard
|
|
39
|
+
|
|
40
|
+
Whisperr already knows **what the app needs to track** (from onboarding), so the
|
|
41
|
+
agent doesn't just install a snippet — it instruments the *specific named events*
|
|
42
|
+
that drive this customer's churn interventions, at the right places in their code.
|
|
43
|
+
|
|
44
|
+
## Architecture (SDK-agnostic)
|
|
45
|
+
|
|
46
|
+
The core is dumb about any specific SDK. All SDK knowledge lives in **playbooks**
|
|
47
|
+
(`src/core/playbooks/`). Each playbook carries:
|
|
48
|
+
|
|
49
|
+
- a `detect()` function (how to recognize the stack),
|
|
50
|
+
- the package reference,
|
|
51
|
+
- an SDK-specific **system prompt** (the best-practice integration guide), and
|
|
52
|
+
- an optional verify command.
|
|
53
|
+
|
|
54
|
+
**Adding a new SDK = adding one playbook file** and registering it in
|
|
55
|
+
`playbooks/index.ts`. Nothing else changes.
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
src/
|
|
59
|
+
index.ts CLI entry + arg parsing
|
|
60
|
+
cli.ts orchestration + terminal UX (@clack/prompts)
|
|
61
|
+
types.ts shared contracts
|
|
62
|
+
ui/ theme + banner (signal-blue, tasteful)
|
|
63
|
+
core/
|
|
64
|
+
config.ts env/flag resolution
|
|
65
|
+
detect.ts runs all playbook detectors
|
|
66
|
+
auth.ts device-authorization flow (+ offline stub)
|
|
67
|
+
manifest.ts fetch integration manifest (+ mock)
|
|
68
|
+
agent.ts Claude Agent SDK runner (file edits)
|
|
69
|
+
git.ts checkpoint + diff + revert hint
|
|
70
|
+
verify.ts first-event activation poll
|
|
71
|
+
playbooks/ ← the only SDK-aware code
|
|
72
|
+
shared-prompt.ts base wizard prompt + manifest renderer
|
|
73
|
+
flutter.ts (available)
|
|
74
|
+
web.ts (planned)
|
|
75
|
+
nextjs.ts (planned)
|
|
76
|
+
react-native.ts (planned)
|
|
77
|
+
swift.ts (planned)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Model & auth
|
|
81
|
+
|
|
82
|
+
The agent runs on Claude via the **Claude Agent SDK**. The CLI **never ships an
|
|
83
|
+
Anthropic key**:
|
|
84
|
+
|
|
85
|
+
- **Production:** the SDK is pointed at Whisperr's Anthropic-compatible gateway
|
|
86
|
+
via `ANTHROPIC_BASE_URL`, with the wizard session token as
|
|
87
|
+
`ANTHROPIC_AUTH_TOKEN`. The gateway injects the real key server-side and meters
|
|
88
|
+
usage per app.
|
|
89
|
+
- **Local dev:** set `WHISPERR_WIZARD_DIRECT_ANTHROPIC_KEY` (or `ANTHROPIC_API_KEY`)
|
|
90
|
+
and run `--offline` to exercise the whole flow against a real model + a mock
|
|
91
|
+
manifest, with no backend.
|
|
92
|
+
|
|
93
|
+
Default model: `claude-opus-4-8` (override with `WHISPERR_WIZARD_MODEL`, e.g.
|
|
94
|
+
`claude-sonnet-4-6`).
|
|
95
|
+
|
|
96
|
+
## Contributing / local dev
|
|
97
|
+
|
|
98
|
+
Only needed if you're working **on** the wizard (not using it). End users just
|
|
99
|
+
run `npx @whisperr/wizard`.
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npm install
|
|
103
|
+
export ANTHROPIC_API_KEY=sk-ant-... # local dev only
|
|
104
|
+
npm run dev:local -- --offline ../some-flutter-app
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`--offline` uses a demo manifest (trial_started, feature_activated,
|
|
108
|
+
payment_failed, subscription_cancelled) so you can watch the agent integrate a
|
|
109
|
+
real repo end-to-end without the backend.
|
|
110
|
+
|
|
111
|
+
To publish: `npm publish` (the package is scoped `@whisperr` with restricted
|
|
112
|
+
access; `prepublishOnly` runs the build). Once published, `npx @whisperr/wizard`
|
|
113
|
+
works for anyone with access.
|
|
114
|
+
|
|
115
|
+
## Backend (whisperr-go — IMPLEMENTED)
|
|
116
|
+
|
|
117
|
+
The wizard talks to these endpoints on the runtime API (default
|
|
118
|
+
`https://api.whisperr.net`), all implemented in `whisperr-go/internal/wizard/`:
|
|
119
|
+
|
|
120
|
+
| Endpoint | Auth | Purpose |
|
|
121
|
+
|---|---|---|
|
|
122
|
+
| `POST /wizard/device/authorize` | public | Start device flow → `device_code`, `user_code`, `verification_uri` |
|
|
123
|
+
| `POST /wizard/device/token` | public (polled) | → `{ token, app_id, expires_at }` once approved (`428` while pending) |
|
|
124
|
+
| `POST /dashboard/wizard/approve` | Supabase JWT | The whisperr-watch approval page binds a `user_code` to the user's app |
|
|
125
|
+
| `GET /wizard/manifest` | wizard session | → `IntegrationManifest`: **mints the ingestion key** + events + interventions + identify |
|
|
126
|
+
| `GET /wizard/first-event` | wizard session | → `{ received, event_type? }` for the activation poll |
|
|
127
|
+
| `POST /wizard/llm/*` | wizard session | Anthropic-compatible gateway: injects Whisperr's real key, streams the response |
|
|
128
|
+
|
|
129
|
+
whisperr-go env to set:
|
|
130
|
+
- `WHISPERR_WIZARD_ANTHROPIC_API_KEY` (or `ANTHROPIC_API_KEY`) — the gateway's real key
|
|
131
|
+
- `WHISPERR_WIZARD_ACTIVATE_URL` — the watch approval page (default `https://app.whisperr.net/wizard/activate`)
|
|
132
|
+
- `WHISPERR_PUBLIC_API_BASE_URL` — base URL surfaced in the manifest for the SDK (default `https://api.whisperr.net`)
|
|
133
|
+
- `WHISPERR_WIZARD_LLM_UPSTREAM` — Anthropic base (default `https://api.anthropic.com`)
|
|
134
|
+
|
|
135
|
+
Run migration `0010_wizard_device_authorizations.sql` (`whisperr migrate up`).
|
|
136
|
+
|
|
137
|
+
## Still to build
|
|
138
|
+
|
|
139
|
+
- The `/wizard/activate` page in **whisperr-watch** (reuse existing Supabase
|
|
140
|
+
login; show the `user_code`, let the user pick an app, POST to
|
|
141
|
+
`/dashboard/wizard/approve`).
|
|
142
|
+
- The `@whisperr/web` SDK (then flip the web/nextjs playbooks to `available`).
|
|
143
|
+
|
|
144
|
+
## Status
|
|
145
|
+
|
|
146
|
+
- ✅ CLI: detection, playbook registry, terminal UX, agent runner, git
|
|
147
|
+
checkpoint, offline demo manifest. Typechecks + builds; npx-standalone.
|
|
148
|
+
- ✅ whisperr-go backend: device auth, manifest (with key minting), first-event,
|
|
149
|
+
LLM gateway, migration. Builds + vets clean.
|
|
150
|
+
- ⏳ whisperr-watch activate page.
|
|
151
|
+
- ⏳ `@whisperr/web` SDK (Flutter is the first live target — SDK on pub.dev).
|