agentic-comments 0.6.1 → 0.7.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 CHANGED
@@ -321,12 +321,42 @@ try {
321
321
  - The client never follows a redirect and never retries. A write that you abort after the client sends it can still apply:
322
322
  read the thread before you try again.
323
323
 
324
+ ## React panel
325
+
326
+ `agentic-comments/ui` is a threaded comments panel for a React page. It shows the thread list, the quote each thread
327
+ points at, a reply box, resolve and reopen, and an author mark on every message. A person shows a name. An agent
328
+ shows the `AgentBadge` of `agentic-design`, with the words "Comment by an agent". Each suggestion has Accept and
329
+ Reject buttons. React 19 and `react-dom` are peer dependencies. The package depends on `agentic-design`.
330
+
331
+ ```tsx
332
+ import { CommentsPanel, createClient } from "agentic-comments/ui";
333
+ import "agentic-design/styles.css";
334
+ import "agentic-comments/ui.css";
335
+
336
+ const client = createClient({ baseUrl: "https://comments.example.com", token });
337
+ <CommentsPanel client={client} docId="report-q3" />;
338
+ ```
339
+
340
+ `client` is any object with the methods of `PanelClient`, so a host can pass its own. The panel reads who is signed
341
+ in from `client.me()`. It follows the product rule for suggestions: an agent never gets Accept or Reject for its own
342
+ suggestion. Through the Worker, an agent needs the `comments:admin` scope to decide any suggestion. With a client of your own, the `comments:accept` right is enough too. A person who holds
343
+ `comments:write` decides any suggestion. `mayDecide(me, suggestion)` is exported, so a host can use the same rule.
344
+ A hidden button is a help and not a lock: the Worker checks every call. The panel shows an error with its code, and
345
+ it never retries a call with other input. It needs a document whose text holds the quote, because a new thread
346
+ points at a quote. It meets WCAG 2.2 AA (axe runs on light, dark, and 390px) and its classes all start with `agd-`.
347
+
348
+ The demo page in `ui/` runs the panel with no token on in-memory data, with a switch for the signed-in principal. Open
349
+ `/#token=<bearer>&doc=<id>` on a Worker that serves it, and it talks to that Worker. `npm run test:ui` drives it in
350
+ Chromium against `wrangler dev`.
351
+
352
+ ![The panel in the light theme](docs/screenshots/panel-light.png)
353
+
324
354
  ## Live demo
325
355
 
326
356
  A demo Worker runs at <https://agentic-comments-demo.hello-fd1.workers.dev>. It is a staging site. Check it with
327
357
  `GET /health`. Every `/api/v1` route needs a bearer token, and the demo does not publish one, so a call
328
358
  with no token gets `401`. The data lives in a D1 database in the EU (`weur`), and the Worker sets the
329
- region to `eu`.
359
+ region to `eu`. The panel demo page is at the root of the demo Worker.
330
360
 
331
361
  To deploy your own copy, log in with `wrangler login` or set `CLOUDFLARE_API_TOKEN`, then:
332
362
 
@@ -436,13 +466,29 @@ const stop = notifications.subscribe(async (event) => {
436
466
  - Mentions are stored in lowercase, with no leading `@`. A handle holds up to 64 letters, digits, marks,
437
467
  and `. _ -`. A longer handle in a body is refused.
438
468
 
469
+ ## Run locally
470
+
471
+ ```sh
472
+ git clone https://github.com/pooriaarab/agentic-comments
473
+ cd agentic-comments
474
+ npm install && npm run dev
475
+ ```
476
+
477
+ You can also use `bun install && bun run dev`. The `dev` script calls npm, so npm must be installed. The scripts need macOS, Linux, or WSL. The `dev` script builds the package, then starts `wrangler dev` on <http://localhost:8794>. Wrangler keeps a local D1 database. The `dev` script turns off Wrangler telemetry. Set `WRANGLER_SEND_METRICS=false` when you run other wrangler commands.
478
+
479
+ ```sh
480
+ curl -i http://localhost:8794/health # 200
481
+ ```
482
+
483
+ `npm run dev:smoke` runs the same check by itself. It starts the dev server. It waits for `/health` to answer 200. It stops the server. CI runs it as the "dev smoke" step. To use another port, change `8794` in the `dev` and `dev:smoke` scripts.
484
+
439
485
  ## Develop
440
486
 
441
487
  ```sh
442
488
  git clone https://github.com/pooriaarab/agentic-comments
443
489
  cd agentic-comments
444
490
  npm ci
445
- npm run ci:local
491
+ npm run ci:local # build, typecheck, unit tests, then the browser tests (npx playwright install chromium once)
446
492
  ```
447
493
 
448
494
  ## License
package/SKILL.md CHANGED
@@ -32,6 +32,11 @@ anyone's with that scope). Check `unread` in an export.
32
32
  Over MCP, call `list_threads`, `add_comment`, `reply_to_thread`, `resolve_thread`, `suggest_change`,
33
33
  `accept_suggestion`, `reject_suggestion`, and the tools above. You never pass an author or a scope.
34
34
 
35
+ ## Show threads in a React page
36
+
37
+ `import { CommentsPanel, createClient } from "agentic-comments/ui"` and load `agentic-design/styles.css` and `agentic-comments/ui.css`.
38
+ `<CommentsPanel client={createClient({ baseUrl, token })} docId="..." />`. The panel never offers an agent Accept or Reject for its own suggestion.
39
+
35
40
  ## Rules
36
41
 
37
42
  - The host stamps the author. Never call `stamp()` yourself, and never pass an author in an input.