critiqs-react 0.0.0-stage → 0.3.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/AGENT_SETUP.md +190 -0
- package/LICENSE +21 -0
- package/README.md +341 -2
- package/bin/cli.d.mts +21 -0
- package/bin/cli.mjs +293 -0
- package/bin/critiqs.mjs +4 -0
- package/bin/env.d.mts +41 -0
- package/bin/env.mjs +384 -0
- package/bin/init.d.mts +126 -0
- package/bin/init.mjs +965 -0
- package/bin/mcp.d.mts +20 -0
- package/bin/mcp.mjs +314 -0
- package/bin/setup.d.mts +183 -0
- package/bin/setup.mjs +1054 -0
- package/dist/Critiqs.d.ts +9 -0
- package/dist/backend/convex/_generated/api.d.ts +95 -0
- package/dist/backend/convex/_generated/api.js +23 -0
- package/dist/backend/convex/_generated/dataModel.d.ts +60 -0
- package/dist/backend/convex/_generated/server.d.ts +162 -0
- package/dist/backend/convex/_generated/server.js +101 -0
- package/dist/backend/convex/ai.ts +93 -0
- package/dist/backend/convex/aiSettings.ts +43 -0
- package/dist/backend/convex/auth.config.ts +18 -0
- package/dist/backend/convex/captureHttp.ts +96 -0
- package/dist/backend/convex/captures.ts +167 -0
- package/dist/backend/convex/crons.ts +14 -0
- package/dist/backend/convex/deviceSignIn.ts +151 -0
- package/dist/backend/convex/grouping.ts +41 -0
- package/dist/backend/convex/http.ts +724 -0
- package/dist/backend/convex/lib/ai.ts +6 -0
- package/dist/backend/convex/lib/links.ts +12 -0
- package/dist/backend/convex/lib/pages.ts +207 -0
- package/dist/backend/convex/lib/r2.ts +75 -0
- package/dist/backend/convex/lib/store.ts +509 -0
- package/dist/backend/convex/lib/tokens.ts +101 -0
- package/dist/backend/convex/lib/validators.ts +73 -0
- package/dist/backend/convex/lib/vendor/aws4fetch.js +289 -0
- package/dist/backend/convex/lib/vendor/critiqs_ai.js +49081 -0
- package/dist/backend/convex/lib/vendor/critiqs_core.js +385 -0
- package/dist/backend/convex/lib/vendor/critiqs_server.js +3108 -0
- package/dist/backend/convex/notificationEmails.ts +61 -0
- package/dist/backend/convex/notifications.ts +182 -0
- package/dist/backend/convex/plans.ts +67 -0
- package/dist/backend/convex/projects.ts +46 -0
- package/dist/backend/convex/schema.ts +343 -0
- package/dist/backend/convex/search.ts +26 -0
- package/dist/backend/convex/signIn.ts +368 -0
- package/dist/backend/convex/tags.ts +68 -0
- package/dist/backend/convex/threads.ts +146 -0
- package/dist/backend/convex/users.ts +13 -0
- package/dist/constants.d.ts +4 -0
- package/dist/core/types.d.ts +72 -0
- package/dist/host.d.ts +66 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +8076 -0
- package/dist/server/chunks/driver-n9zpr0k3.js +21 -0
- package/dist/server/chunks/index-9bg7tmnq.js +522 -0
- package/dist/server/chunks/index-askcfn7t.js +148 -0
- package/dist/server/chunks/providers-rv184xvj.js +48444 -0
- package/dist/server/chunks/token-kzddms7r.js +63 -0
- package/dist/server/chunks/token-util-k8bee1wc.js +4 -0
- package/dist/server/index.d.ts +87 -0
- package/dist/server/index.js +4889 -0
- package/package.json +77 -4
package/AGENT_SETUP.md
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# Setting up Critiqs: instructions for coding agents
|
|
2
|
+
|
|
3
|
+
Critiqs lets reviewers comment directly on a running React prototype. It is one
|
|
4
|
+
component, `<Critiqs />`, from the `critiqs-react` package, and works in any
|
|
5
|
+
React 18 or 19 app: Vite, Create React App, Next.js (App Router or Pages
|
|
6
|
+
Router), server-rendered apps, and custom setups. The command line is enough;
|
|
7
|
+
the MCP server (step 5) is optional.
|
|
8
|
+
|
|
9
|
+
The setup CLI supports Node.js 20 or later. For the optional embedded SQLite
|
|
10
|
+
server use Node.js 22.13 or later, or Bun. Node.js 20 can build the browser
|
|
11
|
+
integration and run setup, but cannot run the built-in SQLite server.
|
|
12
|
+
|
|
13
|
+
Never ask the person to paste keys, tokens, or sign-in codes into the
|
|
14
|
+
conversation. Critiqs Cloud, the default, needs none. AI is optional: don't set
|
|
15
|
+
it up unless asked.
|
|
16
|
+
|
|
17
|
+
## 1. Install the package
|
|
18
|
+
|
|
19
|
+
Use the project's own package manager, as its lockfile shows:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm install critiqs-react # pnpm add / yarn add / bun add critiqs-react
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Run the commands below in the app's folder (the one with its `package.json`),
|
|
26
|
+
or pass `--dir <folder>`. Use `npx critiqs-react …` (or `pnpm exec`, `yarn`,
|
|
27
|
+
`bunx`); the command inside the package is named `critiqs`.
|
|
28
|
+
|
|
29
|
+
**Monorepos:** each app gets its own project. Run init once per app with
|
|
30
|
+
`--dir apps/<app>`; at the workspace root, init lists the apps with these exact
|
|
31
|
+
commands and changes nothing. Ask the person which apps should have Critiqs;
|
|
32
|
+
never connect two apps to one project unless they ask for that.
|
|
33
|
+
|
|
34
|
+
## 2. Add the component and create the project
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
npx critiqs-react init --json
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Init adds `<Critiqs />` and its import where the app renders: beside `<App />`
|
|
41
|
+
in a `createRoot(…).render(…)` or `ReactDOM.render(…)` call, inside `<body>` in
|
|
42
|
+
a Next.js `app/layout.tsx` (the layout stays a server component; the package
|
|
43
|
+
declares the client boundary), beside `<Component {...pageProps} />` in
|
|
44
|
+
`pages/_app.tsx`, or beside the element `hydrateRoot` receives. For other
|
|
45
|
+
structures, name the file and element:
|
|
46
|
+
`npx critiqs-react init --entry src/Shell.tsx --mount Outlet`. Preview with
|
|
47
|
+
`npx critiqs-react init <projectId> --dry-run` when the project already exists.
|
|
48
|
+
|
|
49
|
+
Then init signs the person in and creates the project:
|
|
50
|
+
|
|
51
|
+
- **Browser on this computer:** init opens a sign-in page. Tell the person to
|
|
52
|
+
sign in there with their email.
|
|
53
|
+
- **No browser here** (SSH, a container, a cloud agent): pass `--remote`, or
|
|
54
|
+
let init choose it. It prints an address and a code such as `BCDF-GHJK`. Give
|
|
55
|
+
both to the person exactly and ask them to open the address on any device,
|
|
56
|
+
enter the code, sign in, and choose Approve. The code expires after 10
|
|
57
|
+
minutes. Never ask them to send you the email code.
|
|
58
|
+
|
|
59
|
+
With `--json`, standard output is one JSON object; progress, including the
|
|
60
|
+
address and code, goes to standard error. The result's `stages` say where
|
|
61
|
+
setup stands: `Code`, `Project`, `Try it locally`, and `Reviewers elsewhere`,
|
|
62
|
+
each `pass`, `warn`, `fail`, or `next`. Report them to the person, including
|
|
63
|
+
any `warn` (such as a missing review address) and every `next` step they must
|
|
64
|
+
take themselves (run the dev server, deploy).
|
|
65
|
+
|
|
66
|
+
In a Vite or Next.js app, init makes the component read the app's public
|
|
67
|
+
variable, `<Critiqs projectId={import.meta.env.VITE_CRITIQS_PROJECT_ID} requireProjectId />`
|
|
68
|
+
(`process.env.NEXT_PUBLIC_CRITIQS_PROJECT_ID` in Next.js; workspace apps get a
|
|
69
|
+
name with the app's suffix, such as `VITE_CRITIQS_PROJECT_ID_ADMIN`), sets it
|
|
70
|
+
in the app's `.env.local`, and lists it empty in `.env.example`. The result's
|
|
71
|
+
`env` names the variable and file, and the `Deployments` stage says what to
|
|
72
|
+
do: commit the code change but not `.env.local`, and tell the person to set the
|
|
73
|
+
variable in the build settings of each deployment that should show Critiqs,
|
|
74
|
+
leaving it unset where Critiqs shouldn't appear. The value is built into the
|
|
75
|
+
app, so changing it needs a rebuild. Other builds get the ID written into the
|
|
76
|
+
component; commit it. The project ID is public configuration, not a secret.
|
|
77
|
+
|
|
78
|
+
Running init again is safe: it keeps the project the code names (a literal ID,
|
|
79
|
+
or the variable's value in `.env` files), and after an interrupted run it
|
|
80
|
+
reuses the person's project with the same name. Only pass `--new-project` when
|
|
81
|
+
the person wants another project. Init never edits code that computes the ID,
|
|
82
|
+
or a wrapper the person wrote; it prints what to set instead.
|
|
83
|
+
|
|
84
|
+
If the person already has a project ID, connect it instead:
|
|
85
|
+
`npx critiqs-react init <projectId>` (no sign-in needed). It sets the variable
|
|
86
|
+
when the component reads one.
|
|
87
|
+
|
|
88
|
+
## 3. Check the setup
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
npx critiqs-react doctor --json
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`ok` is false when any check `fail`s. Each check has a `stage` (`code`,
|
|
95
|
+
`service`, `project`, `reviewers`, `optional`) and a `basis`: `configuration`
|
|
96
|
+
means the settings are in place; `observed` means the backend has actually
|
|
97
|
+
done it (such as sending a mention email). Doctor never sends email, uploads a
|
|
98
|
+
screenshot, or posts a comment, so don't report those as proven; the first real
|
|
99
|
+
comment proves them. `info` (AI off) is not a problem. For an environment-backed
|
|
100
|
+
ID, doctor checks the value in this computer's `.env` files against the
|
|
101
|
+
backend; it can't see a deployment's build settings, and says so in the
|
|
102
|
+
`Deployments` check.
|
|
103
|
+
If setup used `--project-env-file`, pass the same file to doctor, for example
|
|
104
|
+
`npx critiqs-react doctor --project-env-file config/.env.local --json` (or `envFile`
|
|
105
|
+
on `critiqs_doctor`). If the environment directory cannot be determined,
|
|
106
|
+
doctor reports that uncertainty instead of saying the app is disabled.
|
|
107
|
+
|
|
108
|
+
Once the prototype is deployed, record its address so mention emails link to
|
|
109
|
+
it: `npx critiqs-react init --review-url https://<deployed address>`. Then ask
|
|
110
|
+
the person to open the deployed prototype and leave a comment.
|
|
111
|
+
|
|
112
|
+
## 4. When something fails
|
|
113
|
+
|
|
114
|
+
| Output | Do this |
|
|
115
|
+
| --- | --- |
|
|
116
|
+
| `Init didn't find where the app renders` | Find the file that renders the app's root and rerun with `--entry <file>` (and `--mount <Element>`), or add `<Critiqs />` there by hand and rerun init. |
|
|
117
|
+
| `Found several places the app could render Critiqs` | Ask which app this is; rerun with `--entry`, or in that app's folder. |
|
|
118
|
+
| `is a workspace with … apps` | Ask which apps should have Critiqs; run the printed `--dir` command for each. |
|
|
119
|
+
| `sets envDir in a way init can't follow` | Find the `.env.local` the app's Vite config loads and rerun with `--project-env-file <file>`, relative to the app. |
|
|
120
|
+
| `sets envPrefix` | Give `<Critiqs />` `projectId={import.meta.env.<name with the app's prefix>} requireProjectId`, then rerun init. |
|
|
121
|
+
| `Couldn't write .env.local` after the project was created | Add the printed `NAME=<project ID>` line to that file; the project and component already exist. |
|
|
122
|
+
| `uses Critiqs under another name` | Critiqs is already mounted there; set the printed properties on it by hand. |
|
|
123
|
+
| `sets projectId from code` | The code computes the ID (a wrapper or fallback); init leaves it alone. Put the printed ID where that code reads it, without making it secret. |
|
|
124
|
+
| `doesn't support approving setup from another device yet` | Run init where a browser can open, using the chosen backend, or create the project in the matching prototype's Critiqs sidebar and update its existing component's projectId while keeping its backend. |
|
|
125
|
+
| `Setup was denied` or `The setup code expired` | Run init again; nothing was created. |
|
|
126
|
+
| Source became unreadable or unwritable after approval | Keep the returned project ID and backend. Restore access, then apply the complete snippet at its indicated entry/mount, and the `.env` line it names. Update an existing component; do not use an ID-only command that would lose the selected backend. |
|
|
127
|
+
| `The code already uses project …` | Nothing changed. Use `--review-url` to set its address, or `--new-project` only if asked. |
|
|
128
|
+
| `Critiqs Cloud isn't ready for this version` | The hosted backend is older than the package; tell the person. Don't switch backends without asking. |
|
|
129
|
+
|
|
130
|
+
## 5. Optional: the MCP server
|
|
131
|
+
|
|
132
|
+
`critiqs mcp` offers the same steps as tools. Add it to the agent's MCP
|
|
133
|
+
configuration, with any keys in its environment rather than in tool calls:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"mcpServers": {
|
|
138
|
+
"critiqs": { "command": "npx", "args": ["critiqs-react", "mcp"] }
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
- `critiqs_setup_start` (`signIn`: `"auto"`, `"browser"`, or `"remote"`;
|
|
144
|
+
`entry`, `mount`, `name`, `reviewUrl`, `newProject`, `dir`, `envFile`; `target`:
|
|
145
|
+
`"cloud"` by default, `"own-convex"`, or an existing backend's URL). Returns
|
|
146
|
+
the address, and for remote approval the code, to give the person.
|
|
147
|
+
- `critiqs_setup_finish`: waits for sign-in or approval, then reuses or
|
|
148
|
+
creates the project and writes its ID. Call again while it reports waiting.
|
|
149
|
+
Its `structuredContent.stages` and `env` match init's.
|
|
150
|
+
- `critiqs_write_project_id` (`projectId`, `dir`, `entry`, `mount`, `envFile`, `dryRun`).
|
|
151
|
+
- `critiqs_doctor` (`dir`, `backend`, `envFile`); `structuredContent` matches
|
|
152
|
+
`doctor --json`.
|
|
153
|
+
|
|
154
|
+
## 6. Optional: more context, own backend, and AI
|
|
155
|
+
|
|
156
|
+
These are separate from basic setup; skip them unless the person asks.
|
|
157
|
+
|
|
158
|
+
- **Context:** `version`, `getContext`, and `restoreContext` properties record
|
|
159
|
+
and restore the prototype's view state; see the package README.
|
|
160
|
+
- **The team's own Convex deployment:** `npx critiqs-react init --own-convex`.
|
|
161
|
+
It needs `CONVEX_DEPLOY_KEY`, a production deploy key the person sets in the
|
|
162
|
+
environment themselves; `RESEND_API_KEY` and `CRITIQS_EMAIL_FROM` are
|
|
163
|
+
optional and turn on mention emails. It also writes
|
|
164
|
+
`backend="https://<deployment>.convex.cloud"`.
|
|
165
|
+
- **Inside the app's own Node or Bun server:** `critiqs-react/server` runs
|
|
166
|
+
Critiqs on SQLite; see the package README. Pass the mounted path as
|
|
167
|
+
`backend` (for example `backend="/critiqs"`), create the project in the
|
|
168
|
+
Critiqs sidebar, and write its ID with `npx critiqs-react init <projectId>`.
|
|
169
|
+
`npx critiqs-react doctor --backend http://localhost:<port>/critiqs` checks it.
|
|
170
|
+
- **AI:** works without any setup in the host app. On the team's own Convex
|
|
171
|
+
deployment, the person can set `CRITIQS_AI_ENCRYPTION_KEY` (32 or more random
|
|
172
|
+
characters, such as from `openssl rand -base64 32`) with `npx convex env set
|
|
173
|
+
CRITIQS_AI_ENCRYPTION_KEY`, typing the value at its prompt, so project owners
|
|
174
|
+
can connect a provider in the Critiqs sidebar. After upgrading a deployment
|
|
175
|
+
that already has feedback, run `npx convex run tags:backfill` once.
|
|
176
|
+
|
|
177
|
+
## What not to do
|
|
178
|
+
|
|
179
|
+
- Don't add a second `<Critiqs />`, or wrap the app in Critiqs providers or
|
|
180
|
+
`"use client"` boundaries; the package handles its own.
|
|
181
|
+
- Don't put keys in source files, tool arguments, the conversation, or the
|
|
182
|
+
prototype's browser code or build settings: AI and email keys belong on the
|
|
183
|
+
backend only.
|
|
184
|
+
- Don't identify projects by the prototype's URL. The project ID decides
|
|
185
|
+
which feedback a copy (local, preview, deployed) shows; a preview never
|
|
186
|
+
changes the project's review address unless someone runs `--review-url` for
|
|
187
|
+
it.
|
|
188
|
+
- Don't commit `.env.local`, copy one app's project ID into another app's
|
|
189
|
+
variable, or set one generic `VITE_CRITIQS_PROJECT_ID` for a build that
|
|
190
|
+
builds several apps.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Noah Jung
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,342 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Critiqs for React
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Reviewers comment directly on a running prototype, discuss feedback, and find
|
|
4
|
+
its original context as the prototype changes. Critiqs brings its own toolbar,
|
|
5
|
+
sidebar, sign-in, and styles. It works in any React 18 or 19 app: Vite, Create
|
|
6
|
+
React App, Next.js (App Router or Pages Router), Remix, or your own setup.
|
|
7
|
+
React and React DOM are peer dependencies; nothing else is required.
|
|
8
|
+
|
|
9
|
+
The browser package and setup CLI support Node.js 20 or later. The optional
|
|
10
|
+
`critiqs-react/server` SQLite server needs Node.js 22.13 or later, or Bun;
|
|
11
|
+
Node.js 20 does not include the built-in SQLite module.
|
|
12
|
+
|
|
13
|
+
## Set up in two commands
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install critiqs-react # or: pnpm add, yarn add, bun add
|
|
17
|
+
npx critiqs-react init
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`npx critiqs-react init` runs the package's `critiqs` command. It adds `<Critiqs />` where your app renders, signs you in through
|
|
21
|
+
your browser, creates a project on Critiqs Cloud, and connects the app to it.
|
|
22
|
+
Critiqs Cloud runs storage, sign-in, and email, so there are no keys to enter.
|
|
23
|
+
The project ID is public configuration, not a secret; reviewers never see or
|
|
24
|
+
enter it.
|
|
25
|
+
|
|
26
|
+
The result is one import and one component. In a Vite or Next.js app, the
|
|
27
|
+
component reads the project ID from the app's public environment variable, and
|
|
28
|
+
init sets that variable in `.env.local` on your computer:
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { Critiqs } from "critiqs-react";
|
|
32
|
+
|
|
33
|
+
<Critiqs projectId={import.meta.env.VITE_CRITIQS_PROJECT_ID} requireProjectId />
|
|
34
|
+
// Next.js: projectId={process.env.NEXT_PUBLIC_CRITIQS_PROJECT_ID}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
# .env.local (this computer only; init adds an empty entry to .env.example)
|
|
39
|
+
VITE_CRITIQS_PROJECT_ID=<project ID>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
With `requireProjectId`, Critiqs appears only where the variable holds a
|
|
43
|
+
valid project ID: a copy built without it adds nothing to the page and
|
|
44
|
+
contacts no backend. In other builds, init writes the ID into the component
|
|
45
|
+
instead (`<Critiqs projectId="<project ID>" />`), and every copy shares that
|
|
46
|
+
project.
|
|
47
|
+
|
|
48
|
+
Init finishes with where setup stands: the code, the project, trying it
|
|
49
|
+
locally, deployments, and what reviewers on other computers still need. Then:
|
|
50
|
+
|
|
51
|
+
1. Start (or restart) your dev server, open the prototype, and sign in from
|
|
52
|
+
the Critiqs toolbar to leave a comment.
|
|
53
|
+
2. Commit the code change (not `.env.local`). In each deployment that should
|
|
54
|
+
show Critiqs, set the variable in its build settings, and record the
|
|
55
|
+
deployed address so mention emails link to it:
|
|
56
|
+
`npx critiqs-react init --review-url https://<deployed address>`.
|
|
57
|
+
3. `npx critiqs-react doctor` checks the setup at any time.
|
|
58
|
+
|
|
59
|
+
### Each app and deployment chooses its project
|
|
60
|
+
|
|
61
|
+
The project ID is an environment setting, so the same commit can be deployed
|
|
62
|
+
from different branches or environments with different projects, or with
|
|
63
|
+
none:
|
|
64
|
+
|
|
65
|
+
| Deployment | Setting | Result |
|
|
66
|
+
| --- | --- | --- |
|
|
67
|
+
| Your computer | `.env.local`, written by init | Your project |
|
|
68
|
+
| A preview or staging deployment | `VITE_CRITIQS_PROJECT_ID=<staging project>` in its build settings | Its own feedback |
|
|
69
|
+
| Production for customers | unset | No Critiqs at all |
|
|
70
|
+
| Another deployment that shares feedback | the same ID | Shared feedback |
|
|
71
|
+
|
|
72
|
+
- **Built in, not read at run time.** Vite and Next.js copy `VITE_…` and
|
|
73
|
+
`NEXT_PUBLIC_…` values into the browser build when the app is built, so set
|
|
74
|
+
them in each deployment's build settings and rebuild after changing one.
|
|
75
|
+
Production-mode builds work the same way; Critiqs doesn't look at
|
|
76
|
+
`NODE_ENV`. If you build once and promote the same files through several
|
|
77
|
+
environments, read the ID from your own runtime configuration and pass it
|
|
78
|
+
to `projectId` yourself, keeping `requireProjectId`.
|
|
79
|
+
- **Wrong or unreachable settings stay out of sight.** A value that isn't a
|
|
80
|
+
project ID, a project the backend doesn't know, or a backend that can't be
|
|
81
|
+
reached shows visitors nothing; the browser console says what's wrong, and
|
|
82
|
+
`npx critiqs-react doctor` checks this computer's setting against the
|
|
83
|
+
backend. Doctor can't see a deployment's build settings.
|
|
84
|
+
- **Nothing is remembered in the browser.** With `requireProjectId`, Critiqs
|
|
85
|
+
never falls back to a project set up in the sidebar, so two apps on one site
|
|
86
|
+
(say `/` and `/admin/`) can't pick up each other's project.
|
|
87
|
+
- **Other builds.** Any React app can do the same by hand: pass its own public
|
|
88
|
+
setting as `projectId` and add `requireProjectId`. Without
|
|
89
|
+
`requireProjectId`, a component with no project ID shows project setup in its
|
|
90
|
+
sidebar, as before.
|
|
91
|
+
|
|
92
|
+
### Monorepos: one project per app
|
|
93
|
+
|
|
94
|
+
In a workspace (npm, Yarn, pnpm, or Bun), run init once for each app with
|
|
95
|
+
`--dir`. Each app gets its own project and its own variable, named after the
|
|
96
|
+
app (`VITE_CRITIQS_PROJECT_ID_ADMIN`, `NEXT_PUBLIC_CRITIQS_PROJECT_ID_WEB`),
|
|
97
|
+
so a value shared by the whole workspace, such as a root `.env` or one build
|
|
98
|
+
job that builds every app, can't connect them all to one project. Projects are
|
|
99
|
+
named after the workspace and the app (`acme/admin`), and an app whose package
|
|
100
|
+
name another workspace package shares is named by its path.
|
|
101
|
+
Names that become the same environment-variable name (such as `a-b` and
|
|
102
|
+
`a_b`) receive a stable suffix from the app's path, so shared environment
|
|
103
|
+
files keep separate project settings.
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
npx critiqs-react init --dir apps/admin
|
|
107
|
+
npx critiqs-react init --dir apps/web
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Run at the workspace root, init lists the apps and these commands and changes
|
|
111
|
+
nothing (at a terminal, it asks which app). Init writes only the chosen app's
|
|
112
|
+
files: its entry, and the `.env.local` and `.env.example` it loads. A Vite app
|
|
113
|
+
whose config sets `envDir` to a literal path or `resolve(__dirname, "…")`
|
|
114
|
+
gets its setting in that folder; for anything else, name the file with
|
|
115
|
+
`--project-env-file`, and pass the same option to `doctor` when checking it. Init adds
|
|
116
|
+
Critiqs to the app's entry, where it calls
|
|
117
|
+
`createRoot`, so another app that imports this app's components doesn't bring
|
|
118
|
+
its Critiqs along.
|
|
119
|
+
|
|
120
|
+
### Where init adds Critiqs
|
|
121
|
+
|
|
122
|
+
| App | Where | You can also add it yourself |
|
|
123
|
+
| --- | --- | --- |
|
|
124
|
+
| Vite, Create React App, and other single-page apps | beside `<App />` in the file that calls `createRoot(…).render(…)` or `ReactDOM.render(…)` | `root.render(<><App /><Critiqs /></>)` |
|
|
125
|
+
| Next.js App Router | inside `<body>` in `app/layout.tsx`. The layout stays a server component: the package marks `<Critiqs />` as a client component | `<body>{children}<Critiqs /></body>` |
|
|
126
|
+
| Next.js Pages Router | beside `<Component {...pageProps} />` in `pages/_app.tsx` | `<><Component {...pageProps} /><Critiqs /></>` |
|
|
127
|
+
| Server-rendered apps (`hydrateRoot`), Remix, and others | beside the element `hydrateRoot` receives, or the component every page renders | `<Critiqs />` renders nothing on the server, so hydration is unaffected |
|
|
128
|
+
| Anything else | name the file and element: `npx critiqs-react init --entry src/Shell.tsx --mount Outlet` | |
|
|
129
|
+
|
|
130
|
+
Init edits one source file, and only when it can tell exactly where: it
|
|
131
|
+
previews the change with `--dry-run`, and it refuses, changing nothing, when
|
|
132
|
+
there are several roots, when Critiqs is already used under another name, or
|
|
133
|
+
when the name `Critiqs` means something else there. It then prints the line to
|
|
134
|
+
add by hand. It checks the source and `.env` files can be written before you
|
|
135
|
+
sign in. Running init again keeps the project the code already names, through
|
|
136
|
+
a literal ID or the variable's value in your `.env` files; a missing or
|
|
137
|
+
malformed value doesn't count, so init connects one. It keeps your other
|
|
138
|
+
`.env` lines and values, a component's other properties, and wiring you wrote
|
|
139
|
+
yourself (`projectId={import.meta.env.VITE_MY_PROJECT}` is set as it is; other
|
|
140
|
+
code is left alone). A retry after an interrupted run reuses your project with
|
|
141
|
+
the same name rather than creating another. `--new-project` creates a new one.
|
|
142
|
+
|
|
143
|
+
### Signing in from another device
|
|
144
|
+
|
|
145
|
+
On a remote machine, in a container, or with a coding agent, there may be no
|
|
146
|
+
browser to open. `npx critiqs-react init --remote` (automatic over SSH or without a
|
|
147
|
+
desktop) prints an address and a short code instead:
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
Approve this setup from a browser on any device:
|
|
151
|
+
1. Open https://<sign-in service>/auth/device
|
|
152
|
+
2. Enter the code BCDF-GHJK
|
|
153
|
+
3. Sign in with your email and choose Approve.
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Setup waits while you approve on your phone or laptop. The code works for 10
|
|
157
|
+
minutes and once; setup receives a 15-minute access token, only to create or
|
|
158
|
+
connect the project, and no lasting session. If the sign-in service doesn't
|
|
159
|
+
offer this yet, init says so: run it where a browser can open, or create the
|
|
160
|
+
project in the matching prototype's Critiqs sidebar and set its public
|
|
161
|
+
`projectId` on the existing component, keeping its `backend` property.
|
|
162
|
+
|
|
163
|
+
### If something goes wrong
|
|
164
|
+
|
|
165
|
+
| Message | What to do |
|
|
166
|
+
| --- | --- |
|
|
167
|
+
| Init didn't find where the app renders | Run with `--entry <file>` (and `--mount <Element>`), or add `<Critiqs />` by hand and run `npx critiqs-react init` again. |
|
|
168
|
+
| Found several places the app could render Critiqs | Choose one with `--entry`; in a monorepo, run init in the app's folder or pass `--dir`. |
|
|
169
|
+
| … is a workspace with 2 apps | Run one of the printed `init --dir <app>` commands for each app. |
|
|
170
|
+
| Sets projectId from code | Init doesn't edit computed values. Set the printed ID where your code reads it. |
|
|
171
|
+
| Sets envDir in a way init can't follow | Pass `--project-env-file <the .env.local file Vite loads>`, relative to the app. |
|
|
172
|
+
| Sets envPrefix | Give `<Critiqs />` `projectId={import.meta.env.<a name with your prefix>} requireProjectId`, then run init again. |
|
|
173
|
+
| Couldn't write `.env.local` after the project was created | Add the printed `NAME=<project ID>` line to that file yourself; the project and component are already in place. |
|
|
174
|
+
| Sign-in took too long, or Setup was denied | Run init again; nothing was created. |
|
|
175
|
+
| Source became unreadable or unwritable during setup | The result keeps the created project ID and backend. Restore file access and apply the complete component snippet shown, at the indicated entry/mount, and the `.env` line it names. Preserve its backend and update an existing component rather than adding another. |
|
|
176
|
+
| The code already uses project … | Nothing was changed. Use `--new-project` to replace it, or `--review-url` to set its review address. |
|
|
177
|
+
| No review address, or one that only opens on this computer | Once deployed, run `npx critiqs-react init --review-url https://<deployed address>`. |
|
|
178
|
+
| Critiqs Cloud isn't ready for this version | The hosted service runs an older backend; wait for it, or use your own Convex deployment. |
|
|
179
|
+
|
|
180
|
+
`npx critiqs-react doctor` checks the component, the backend and its version,
|
|
181
|
+
sign-in, the project, its review address, and email. Each check says whether
|
|
182
|
+
it read configuration or something the backend has actually done; doctor never
|
|
183
|
+
sends an email, uploads a screenshot, or posts a comment, so the first real
|
|
184
|
+
comment is what proves those work. AI is optional and doctor reports it as
|
|
185
|
+
information. `--json` prints init's and doctor's results for scripts and coding
|
|
186
|
+
agents. Coding agents can follow [AGENT_SETUP.md](AGENT_SETUP.md); an optional
|
|
187
|
+
MCP server (`npx critiqs-react mcp`) offers the same steps.
|
|
188
|
+
|
|
189
|
+
### Keeping feedback on your own backend
|
|
190
|
+
|
|
191
|
+
Critiqs Cloud is the default. To keep feedback on your team's own Convex
|
|
192
|
+
deployment instead, run `npx critiqs-react init --own-convex`: it deploys
|
|
193
|
+
Critiqs's functions there and asks only for a production Convex deploy key
|
|
194
|
+
(`CONVEX_DEPLOY_KEY`), plus a Resend key if you want mention emails, then also
|
|
195
|
+
writes `backend="https://<deployment>.convex.cloud"`. `--backend <url>` uses a
|
|
196
|
+
Critiqs backend that is already deployed. To run Critiqs inside your own Node or
|
|
197
|
+
Bun server instead, see [self-hosting](#self-hosting-inside-your-apps-server).
|
|
198
|
+
|
|
199
|
+
## Optional: more context for feedback
|
|
200
|
+
|
|
201
|
+
Optional properties record the prototype version and let the host app report
|
|
202
|
+
and restore context: `version`, `getContext`, and `restoreContext`. The package
|
|
203
|
+
exports their TypeScript types: `CritiqsProps`, `HostContext`, `RestoreRequest`,
|
|
204
|
+
`Scope`, and `ViewState`. Elements marked `data-critiqs-mask` are covered in captures.
|
|
205
|
+
For canvas, video or iframe content, mark a containing element: directly marked
|
|
206
|
+
media fail automatic capture safely because the renderer replaces their nodes
|
|
207
|
+
without retaining the privacy marker. The comment still saves with the reason.
|
|
208
|
+
|
|
209
|
+
Opening a thread from the list or a link, or choosing **Show in prototype**,
|
|
210
|
+
shows its target in the screen and view state where it was left. Unless that
|
|
211
|
+
view is already shown, Critiqs calls `restoreContext`, then waits up to three
|
|
212
|
+
seconds for `getContext` to report the thread's screen and view state and for
|
|
213
|
+
the target to appear; a matching element in another view doesn't count. Return
|
|
214
|
+
a promise to wait for slower content first, or `false` to decline, for example
|
|
215
|
+
to keep unsaved work. Report each key whenever its part of the app is shown,
|
|
216
|
+
with null when nothing is open; once `restoreContext` has run, a key an older
|
|
217
|
+
thread lacks is left to it. Report only state that `restoreContext` can set again;
|
|
218
|
+
if it keeps the current record for shared feedback, keep that record's ID out
|
|
219
|
+
of the view state.
|
|
220
|
+
Captures leave out every mounted Critiqs, including its pins and windows.
|
|
221
|
+
|
|
222
|
+
## Tags, search, and AI
|
|
223
|
+
|
|
224
|
+
Reviewers tag threads with the project's tags or by writing hashtags such as
|
|
225
|
+
`#wording` in comments; typing `#` suggests the project's tags. The project's
|
|
226
|
+
owner gathers related tags into shared groups (the Tags and AI button in the
|
|
227
|
+
sidebar), which everyone can filter by. The sidebar's search field finds
|
|
228
|
+
threads by words and `#tags`.
|
|
229
|
+
|
|
230
|
+
With AI, new tags are grouped automatically, searches can be plain questions,
|
|
231
|
+
and results come with insights that cite their threads. A project uses
|
|
232
|
+
Critiqs-managed AI where the deployment offers it, or its owner connects the
|
|
233
|
+
project's own OpenAI, Anthropic, Google Gemini, Vercel AI Gateway, or
|
|
234
|
+
OpenAI-compatible provider in the same dialog. Keys go to the backend once,
|
|
235
|
+
are stored encrypted, and never return to browsers. AI is optional: without
|
|
236
|
+
it, commenting, replies, mentions, and tags work as usual, search is labeled
|
|
237
|
+
basic, and grouping is manual. Nobody installing the component is asked for an
|
|
238
|
+
AI key.
|
|
239
|
+
|
|
240
|
+
On your own Convex deployment, set `CRITIQS_AI_ENCRYPTION_KEY` (32 or more
|
|
241
|
+
random characters, such as from `openssl rand -base64 32`) so owners can save
|
|
242
|
+
keys, and optionally `CRITIQS_AI_PROVIDER`, `CRITIQS_AI_MODEL`, and
|
|
243
|
+
`CRITIQS_AI_API_KEY` for a provider every project uses by default.
|
|
244
|
+
`CRITIQS_AI_ALLOWED_ENDPOINTS` lists custom endpoint addresses owners may
|
|
245
|
+
enter. After upgrading an existing deployment, run
|
|
246
|
+
`npx convex run tags:backfill` once so earlier comments gain their hashtags.
|
|
247
|
+
|
|
248
|
+
Keyboard shortcuts: **C** Comment mode, **V** Browse mode, **Escape** close or
|
|
249
|
+
cancel, and **Ctrl or Cmd + `\`** hides or shows all of Critiqs.
|
|
250
|
+
|
|
251
|
+
### For a deployment's operator: Critiqs-managed AI
|
|
252
|
+
|
|
253
|
+
Critiqs-managed AI is configured once, on the backend, for every project; it
|
|
254
|
+
needs no change in host apps. On the Convex deployment, set these from your
|
|
255
|
+
own terminal, typing each value into the command's standard input rather than
|
|
256
|
+
on the command line, for example `npx convex env set CRITIQS_MANAGED_AI_API_KEY`:
|
|
257
|
+
|
|
258
|
+
| Setting | Value |
|
|
259
|
+
| --- | --- |
|
|
260
|
+
| `CRITIQS_MANAGED_AI` | `enabled` |
|
|
261
|
+
| `CRITIQS_MANAGED_AI_PROVIDER` | `openai`, `anthropic`, `google`, `gateway`, or `compatible` |
|
|
262
|
+
| `CRITIQS_MANAGED_AI_MODEL` | The provider's model name |
|
|
263
|
+
| `CRITIQS_MANAGED_AI_API_KEY` | The provider key (optional only for `compatible`) |
|
|
264
|
+
| `CRITIQS_MANAGED_AI_BASE_URL` | Optional: the endpoint for `compatible` |
|
|
265
|
+
|
|
266
|
+
Managed AI stays off until the provider, model, and key are all set. Check it
|
|
267
|
+
with `npx critiqs-react doctor` (or the backend's `/critiqs/health`, whose
|
|
268
|
+
`ai.managed` is `true`); like every health check, that reads configuration
|
|
269
|
+
without calling the model. A project owner's connection test in the Tags and
|
|
270
|
+
AI dialog makes one real request, which counts toward the plan's AI allowance.
|
|
271
|
+
|
|
272
|
+
## Screenshot storage on Convex
|
|
273
|
+
|
|
274
|
+
Convex deployments can store screenshots in a private Cloudflare R2 bucket,
|
|
275
|
+
keeping comments, image metadata, and access checks in Convex. Configure
|
|
276
|
+
`CRITIQS_CAPTURE_STORAGE=r2` and `CRITIQS_R2_ACCOUNT_ID`, `CRITIQS_R2_BUCKET`,
|
|
277
|
+
`CRITIQS_R2_ACCESS_KEY_ID`, and `CRITIQS_R2_SECRET_ACCESS_KEY` on the backend.
|
|
278
|
+
Deploy matching protocol-4 functions and package. Keep the bucket private and
|
|
279
|
+
restrict its API token to that bucket. The host app needs no R2 keys or code
|
|
280
|
+
changes. Existing Convex captures remain readable; incomplete R2 setup fails
|
|
281
|
+
explicitly. `critiqs doctor` checks configuration; a real upload verifies access.
|
|
282
|
+
|
|
283
|
+
## Self-hosting inside your app's server
|
|
284
|
+
|
|
285
|
+
If your prototype has its own long-running Node or Bun server with a disk that
|
|
286
|
+
survives restarts, Critiqs can run inside it and keep feedback in a SQLite file.
|
|
287
|
+
No Critiqs service is involved. Static hosts and serverless platforms such as
|
|
288
|
+
Vercel can't keep the file; use Critiqs Cloud or your own Convex there.
|
|
289
|
+
|
|
290
|
+
```ts
|
|
291
|
+
import { createCritiqsHandler, toNodeListener } from "critiqs-react/server";
|
|
292
|
+
|
|
293
|
+
const critiqs = await createCritiqsHandler({
|
|
294
|
+
database: "critiqs.sqlite",
|
|
295
|
+
email: { resendApiKey: process.env.RESEND_API_KEY!, from: "Critiqs <critiqs@example.com>" },
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
// Bun, or any server built on web requests:
|
|
299
|
+
Bun.serve({
|
|
300
|
+
fetch: (request, server) =>
|
|
301
|
+
new URL(request.url).pathname.startsWith("/critiqs")
|
|
302
|
+
? critiqs.fetch(request, { remoteAddress: server.requestIP(request)?.address })
|
|
303
|
+
: app(request),
|
|
304
|
+
});
|
|
305
|
+
// Node: http.createServer(toNodeListener(critiqs)) for requests under /critiqs.
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Then point the component at it: `<Critiqs backend="/critiqs" projectId="…" />`.
|
|
309
|
+
Reviewers sign in with an emailed code. To use your app's own sign-in instead,
|
|
310
|
+
pass `identify: (request) => ({ id, name, email })` for whoever the request's
|
|
311
|
+
session belongs to, or null. While developing without a Resend key,
|
|
312
|
+
`developmentSignIn: true` shows codes on screen, only for connections from this
|
|
313
|
+
computer (pass `remoteAddress` as above; the Node listener does it for you).
|
|
314
|
+
Captures must be PNG, JPEG, WebP, or GIF.
|
|
315
|
+
|
|
316
|
+
For AI, pass `ai`, read from your server's environment:
|
|
317
|
+
|
|
318
|
+
```ts
|
|
319
|
+
const critiqs = await createCritiqsHandler({
|
|
320
|
+
database: "critiqs.sqlite",
|
|
321
|
+
ai: {
|
|
322
|
+
// A provider for every project; omit for none. A local Ollama: provider "compatible", baseURL "http://localhost:11434/v1".
|
|
323
|
+
provider: "openai",
|
|
324
|
+
model: process.env.CRITIQS_AI_MODEL!,
|
|
325
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
326
|
+
// Lets project owners connect their own provider in Critiqs, with keys stored encrypted.
|
|
327
|
+
encryptionKey: process.env.CRITIQS_AI_ENCRYPTION_KEY,
|
|
328
|
+
allowedEndpoints: ["https://llm.example.com/v1"],
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
Model requests come from this server, so `localhost` means this server's
|
|
334
|
+
machine. Existing feedback gains its hashtags when the database upgrades on start.
|
|
335
|
+
Back up the database with SQLite's online backup
|
|
336
|
+
(`sqlite3 critiqs.sqlite ".backup backup.sqlite"`).
|
|
337
|
+
|
|
338
|
+
The first-release API and interaction choices remain provisional. See the
|
|
339
|
+
[project documentation](https://github.com/noahsjung/Critiqs/tree/main/docs)
|
|
340
|
+
for agreed behavior, proposed choices, and own-backend setup.
|
|
341
|
+
|
|
342
|
+
Critiqs is released under the [MIT license](LICENSE).
|
package/bin/cli.d.mts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const USAGE: string;
|
|
2
|
+
export interface CommandOptions {
|
|
3
|
+
command: "init" | "doctor" | "mcp" | null;
|
|
4
|
+
projectId: string | null;
|
|
5
|
+
dir: string;
|
|
6
|
+
dryRun: boolean;
|
|
7
|
+
/** "cloud", "own-convex", or a backend URL. */
|
|
8
|
+
target: string | null;
|
|
9
|
+
name: string | null;
|
|
10
|
+
reviewUrl: string | null;
|
|
11
|
+
help: boolean;
|
|
12
|
+
entry: string | null;
|
|
13
|
+
mount: string | null;
|
|
14
|
+
signIn: "remote" | "browser" | null;
|
|
15
|
+
newProject: boolean;
|
|
16
|
+
json: boolean;
|
|
17
|
+
/** The .env file to set an environment-backed project ID in, relative to `dir`. */
|
|
18
|
+
envFile: string | null;
|
|
19
|
+
}
|
|
20
|
+
export declare function parseCommand(argv: string[]): CommandOptions | { error: string };
|
|
21
|
+
export declare function runCli(argv: string[], options?: { cwd?: string; print?: (message: string) => void }): Promise<number>;
|