@userreason/wizard 0.1.0 → 0.2.1

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
@@ -1,51 +1,139 @@
1
- # @userreason/wizard
1
+ # UserReason installation wizard
2
2
 
3
- Authenticated installation for UserReason. It shares the CLI client and credentials, uses the same onboarding endpoints, and generates integrations for React, Next.js, Vue and plain browser applications. This package is prepared for publication; no npm publication occurs during its build.
3
+ Add UserReason feedback to your application with a guided setup for **React,
4
+ Next.js, Vue and browser JavaScript**. The wizard installs the SDK and project
5
+ CLI, connects your workspace and previews the integration before applying it.
4
6
 
5
- Build the local CLI first, then the wizard:
7
+ [Quickstart](https://docs.userreason.com/get-started/quickstart/) ·
8
+ [SDK documentation](https://docs.userreason.com/sdk/initialization/) ·
9
+ [Dashboard](https://dash.userreason.com)
10
+
11
+ ## Requirements
12
+
13
+ - Node.js **22.12 or later** and npm, pnpm or Yarn.
14
+ - Your application's source directory and permission to install dependencies.
15
+ - A browser to sign in to UserReason and approve the installation.
16
+
17
+ ## Install
18
+
19
+ Run this command from your application directory:
6
20
 
7
21
  ```sh
8
- cd ../ur-cli && npm ci && npm run build
9
- cd ../ur-wizard && npm ci && npm run typecheck && npm test
10
- node dist/bin.js --help
22
+ npx -y @userreason/wizard@latest
11
23
  ```
12
24
 
13
- The wizard bundles the CLI client at build time. Its published runtime does not depend on the private `ur-types` package or a local file reference; its only runtime dependency is the OS credential-store binding.
25
+ The wizard will:
14
26
 
15
- After publication:
27
+ 1. Detect your framework, package manager and any existing UserReason setup.
28
+ 2. Open the browser so you can sign in and approve installation access.
29
+ 3. Let you choose or create a workspace and site.
30
+ 4. Show the proposed application change and optional setup steps for review.
31
+ 5. Install `@userreason/js` and the project-local `@userreason/cli`, apply the
32
+ approved integration and check that the site's configuration is available.
33
+
34
+ Start your application afterward and follow the next steps shown in the
35
+ terminal. The [first survey guide](https://docs.userreason.com/get-started/first-prompt/)
36
+ walks through creating and publishing a survey. Installing the SDK does not
37
+ publish a survey.
38
+
39
+ For a different application directory:
16
40
 
17
41
  ```sh
18
- npx -y @userreason/wizard@latest
42
+ npx -y @userreason/wizard@latest --directory ./my-app
43
+ ```
44
+
45
+ ## What changes in your application
46
+
47
+ The SDK is added to `dependencies`, and the CLI to `devDependencies`. For a
48
+ supported entry point, the integration initializes UserReason with your public
49
+ site ID:
50
+
51
+ ```js
52
+ import UserReason from '@userreason/js';
53
+
54
+ UserReason.init({ siteId: 'YOUR_SITE_ID' });
55
+ ```
56
+
57
+ React, Vue and browser applications initialize before the app mounts. Modern
58
+ Next.js applications use client instrumentation; older supported versions use a
59
+ small client component. If your entry point needs a custom integration, the
60
+ wizard provides manual instructions.
61
+
62
+ Existing initialization is detected on reruns. The wizard previews source edits
63
+ and preserves existing integrations and customized agent guidance. Only public
64
+ SDK configuration belongs in application source; sign-in credentials are stored
65
+ separately.
66
+
67
+ ## Optional setup
68
+
69
+ The setup review can also include:
70
+
71
+ - **Project agent guidance:** a short note in an existing `AGENTS.md` or
72
+ `CLAUDE.md`, plus a UserReason feedback skill for compatible agents.
73
+ - **Ongoing CLI access:** a separate account connection for reading feedback and
74
+ managing surveys, subject to the permissions you approve.
75
+ - **Global CLI:** make `userreason` available outside this project through npm's
76
+ configured global installation location.
77
+
78
+ The project-local CLI works without a global installation:
79
+
80
+ ```sh
81
+ npx --no-install userreason whoami
82
+ npx --no-install userreason prompt list
83
+ npx --no-install userreason docs search "survey targeting"
19
84
  ```
20
85
 
21
- It discovers the public WorkOS client ID from the configured API, reads the selected project's `package.json`, detects its framework/package manager, reuses an existing OS-stored login or starts public WorkOS device authentication, and selects or creates a workspace and site. `--client-id` remains available for explicit configuration. Only when the operation lacks an effective grant does it ask the human to approve installation permissions. A previously approved client can continue unattended until its grant expires or is revoked. Fresh clients may choose an existing workspace in the browser approval screen even before they have permission to list its name.
86
+ Use `pnpm exec userreason` or `yarn exec userreason` in those projects. Teammates
87
+ install the project's dependencies and connect their own account with
88
+ `userreason login --open`; they do not need to create another site.
89
+
90
+ ## Update an existing installation
22
91
 
23
92
  ```sh
24
- npx -y @userreason/wizard@latest \
25
- --directory ./app \
26
- --workspace WORKSPACE_UUID \
27
- --site SITE_UUID \
28
- --origin https://app.example.com \
29
- --install \
30
- --yes \
31
- --json
93
+ npx -y @userreason/wizard@latest --refresh
32
94
  ```
33
95
 
34
- For new resources, use `--workspace-name` and `--site-name` instead of their UUID flags. `--dev` selects the development API, development WorkOS client configuration and default site environment. `--environment` can select the site's environment independently of the API deployment. Production sites require HTTPS origins.
96
+ Refresh updates the SDK and project CLI without repeating onboarding or
97
+ rewriting the application's initialization. Restart or reload your application
98
+ to use the updated SDK. Use `--install` to force package installation.
99
+
100
+ ## Preview and scripted setup
35
101
 
36
- `--install` installs `@userreason/js@^0.2.0` with the detected package manager and dependency scripts disabled. This requires that the remote-compatible SDK has been published first. `--skip-install` prepares the integration without changing dependencies; ensure your existing SDK supports `init({workspaceId, siteId, apiBaseUrl})`. SDK 0.1.x's local-survey API cannot connect to the Worker's remote campaign protocol.
102
+ Inspect a plan without signing in, installing packages or changing files:
37
103
 
38
- Generated files:
104
+ ```sh
105
+ npx -y @userreason/wizard@latest --dry-run
106
+ ```
107
+
108
+ For a scripted installation with an existing workspace and site:
109
+
110
+ ```sh
111
+ npx -y @userreason/wizard@latest \
112
+ --workspace WORKSPACE_UUID \
113
+ --site SITE_UUID \
114
+ --yes --integrate --json
115
+ ```
39
116
 
40
- - `userreason.config.json`: public workspace/site/API configuration and required SDK version.
41
- - `src/userreason.generated.tsx` for React/Next.js, or `src/userreason.generated.ts` for Vue/vanilla; written at the project root when there is no `src` directory.
117
+ Browser approval is still required. `--yes` accepts the main installation plan;
118
+ optional global installation, ongoing CLI access and agent guidance require
119
+ explicit flags in scripted use. Run `--help` for all options. `--no-open` prints
120
+ the sign-in link for use in another browser.
42
121
 
43
- The generated React/Next component, Vue composable or vanilla initializer must be mounted/called once at the application root. The wizard prints the framework-specific instruction and includes lifecycle cleanup. It leaves existing application source unchanged so the integration can be reviewed. Files are reused if identical; changed files require `--force`, which creates a backup before replacement. Symlinked source directories are refused.
122
+ ## Environments and access
44
123
 
45
- React/Next initialization uses a browser layout effect with an SSR-safe fallback, so ordinary descendant `useEffect` calls can report their first event after initialization. Cleanup and reinitialization also run correctly during React Strict Mode's development remount. Descendant layout effects can run earlier: move their event reports to a passive effect or initialize UserReason through a controlled browser entry before rendering that tree. Vue initializes in the root `onBeforeMount`, ahead of descendant mount hooks; call the composable in the root setup before creating descendants. Neither framework starts the SDK during server rendering. Remote configuration still loads asynchronously: await `UserReason.ready()` when an event must wait for its targeting configuration. See [React layout effects](https://react.dev/reference/react/useLayoutEffect) and [Vue lifecycle hooks](https://vuejs.org/api/composition-api-lifecycle.html#onbeforemount).
124
+ The wizard uses the production UserReason API by default. For a customer site
125
+ used in local development or previews, choose `--environment development`.
126
+ This setting describes your site; it does not select a different UserReason API.
46
127
 
47
- The wizard checks the public SDK configuration endpoint using the exact allowed host origin. Its result explicitly reports `hostConnectionVerified:false`: configuration availability is not proof of a real browser connection. Start the host application, mount the generated integration, and verify its config/session flow from that origin. No campaign is published merely by installing the SDK.
128
+ New sites allow any origin by default. Add `--origin https://app.example.com` to
129
+ restrict a new site to an exact origin, or manage restrictions in the dashboard.
130
+ Existing site restrictions are preserved.
48
131
 
49
- Only public SDK configuration is written into the project. Login tokens remain in macOS Keychain, Windows Credential Manager or Linux Secret Service. WorkOS API keys and UserReason signing keys are never required by the wizard.
132
+ Installation access is short-lived and cannot publish surveys. Ongoing CLI
133
+ access is a separate approval that you can review or revoke in the dashboard.
134
+ Per-user credentials use file storage by default; `--credential-store keychain`
135
+ selects the available OS credential store. Your application source is parsed
136
+ locally and is not uploaded to an AI service.
50
137
 
51
- Local tests use temporary projects and HTTP fixtures. Live login, grant approval, npm installation and host-origin operation require the configured WorkOS environment, migrations and deployed onboarding Worker.
138
+ See [troubleshooting](https://docs.userreason.com/get-started/troubleshooting/)
139
+ for help with installation, sign-in, permissions and browser verification.