@staff0rd/assist 0.930.0 → 0.932.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
@@ -47,7 +47,7 @@ The user guide is an [Astro Starlight](https://starlight.astro.build/) site in i
47
47
  - **Session status glyphs** — write `:status[running]` (or `verifying`, `waiting`, `done`, `error`, `stopped`) to show a session card's status glyph in the dashboard's colours, and `:badge[clone]` (or `harness`, `serving`, `node`) for a card badge.
48
48
  - **Icons** — write `:icon[OpenInFull]` to show the icon a dashboard button uses. Add a new icon to the registry in `src/docs/starlight/renderIcon.ts`.
49
49
  - **Coverage report** — `npx tsx src/docs/docsCoverage.ts --report` lists the commands, skills, config keys and routes no page covers, by kind. `verify:docs-coverage` fails when any item is covered by no page, so a new command, skill, config key or route needs docs before verify passes.
50
- - **Screenshots** — each entry in the frontmatter's `screenshots` declares a `file`, `alt` and `route`, and optionally `viewport` (default 1280×800), `theme`, `waitFor` and `crop` selectors, a `scene` (a named list of setup steps in `docs/capture/scenes.json`), `setup` steps run after the scene, and `actions` (`click: <selector>`, `press: <key>`, `type: <text>`, `drag: { from: <selector>, to: <selector> }`) performed on the page before capture, and `highlight` (a list of selectors; every match is outlined in the capture to point the reader at it). Setup steps: `assist: [args]` runs an assist command in the sandbox, `run: <name>` starts a run session from `docs/capture/assist.yml`, and `session: { repo, prompt, title?, reply?, status? }` starts an agent session in the `sandbox`, `api` or `website` repo and sets its status (`running`, `waiting` or `done`). `openPr: { repo, number, title, author? }` gives the repo an open pull request: the capture also puts a fake `gh` (`docs/capture/bin/gh`) on the `PATH`, which answers `gh pr list` and `gh pr view` with it and fails every other call. `gh: { match, json }` makes that fake `gh` print `json` for any call whose arguments contain every string in `match`, with each `"{{ago:<n><m|h|d>}}"` in it replaced by the ISO time that long ago. `sql: <statements>` runs SQL against the capture database, and `newsFeed: { name, title, items }` serves an RSS feed of `{ title, hoursAgo, excerpt? }` items locally and adds it with `assist news add`. Between states the capture also restores `~/.assist.yml` and empties the backlog, backups and usage tables. Preview steps open a preview pane on the session started with the step's `session` prompt and hold it open until the state changes: `preview: { session, kind: ask|show, title, body }`, `pr: { session, title, what, why, how?, resolves?, prNumber?, draft? }`, `proposal: { session, item }` (an `assist backlog propose` payload) and `highLevelReview: { session, prNumber, title, headRef, body, linkedIssues?, criticalPaths?, uiPaths?, files }`, where each file is `{ path, status, content?, patch? }` and an added file's patch is built from its `content`. The capture puts a fake `claude` (`docs/capture/bin/claude`) on the `PATH`, which prints the step's `reply` lines as its transcript and answers title generation with its `title`, so no real harness runs. Screenshots sharing a scene and setup are captured together, and the sessions are drained before the next state is set up. Without a `theme`, it is captured as `<file>` (light) and `<file>-dark.png`, and the site shows the one matching the theme the reader picked. A `::screenshot{file="<file>"}` line in the page places it; a declared screenshot with no such line, or a line naming an undeclared one, fails the build.
50
+ - **Screenshots** — each entry in the frontmatter's `screenshots` declares a `file`, `alt` and either a `route` on the capture web server or a `url` on `https://github.com/` (a live page, logged out, with the browser extension's `content.js` injected and its `browser.*` APIs stubbed; a `script: <name>` action runs `docs/capture/github/<name>.js` in the page to stand in for what a logged-out page lacks), and optionally `viewport` (default 1280×800), `theme`, `waitFor` and `crop` selectors, a `scene` (a named list of setup steps in `docs/capture/scenes.json`), `setup` steps run after the scene, and `actions` (`click: <selector>`, `press: <key>`, `type: <text>`, `drag: { from: <selector>, to: <selector> }`) performed on the page before capture, and `highlight` (a list of selectors; every match is outlined in the capture to point the reader at it). Setup steps: `assist: [args]` runs an assist command in the sandbox, `run: <name>` starts a run session from `docs/capture/assist.yml`, and `session: { repo, prompt, title?, reply?, status? }` starts an agent session in the `sandbox`, `api` or `website` repo and sets its status (`running`, `waiting` or `done`). `openPr: { repo, number, title, author? }` gives the repo an open pull request: the capture also puts a fake `gh` (`docs/capture/bin/gh`) on the `PATH`, which answers `gh pr list` and `gh pr view` with it and fails every other call. `gh: { match, json }` makes that fake `gh` print `json` for any call whose arguments contain every string in `match`, with each `"{{ago:<n><m|h|d>}}"` in it replaced by the ISO time that long ago. `sql: <statements>` runs SQL against the capture database, and `newsFeed: { name, title, items }` serves an RSS feed of `{ title, hoursAgo, excerpt? }` items locally and adds it with `assist news add`. Between states the capture also restores `~/.assist.yml` and empties the backlog, backups and usage tables. Preview steps open a preview pane on the session started with the step's `session` prompt and hold it open until the state changes: `preview: { session, kind: ask|show, title, body }`, `pr: { session, title, what, why, how?, resolves?, prNumber?, draft? }`, `proposal: { session, item }` (an `assist backlog propose` payload) and `highLevelReview: { session, prNumber, title, headRef, body, linkedIssues?, criticalPaths?, uiPaths?, files }`, where each file is `{ path, status, content?, patch? }` and an added file's patch is built from its `content`. The capture puts a fake `claude` (`docs/capture/bin/claude`) on the `PATH`, which prints the step's `reply` lines as its transcript and answers title generation with its `title`, so no real harness runs. Screenshots sharing a scene and setup are captured together, and the sessions are drained before the next state is set up. Without a `theme`, it is captured as `<file>` (light) and `<file>-dark.png`, and the site shows the one matching the theme the reader picked. A `::screenshot{file="<file>"}` line in the page places it; a declared screenshot with no such line, or a line naming an undeclared one, fails the build.
51
51
  - **Recapture** — `npm run docs:capture [-- <file.png>...] [--skip-build] [--keep-home]` builds assist, starts a throwaway Postgres container (Docker required), clones `staff0rd/sandbox` (plus local `api` and `website` repos) into a temporary `HOME`, runs the real daemon and web server there on a free port, captures the screenshots with Playwright (`npx playwright install chromium` once) and tears everything down. Commit the changed PNGs.
52
52
  - **Preview** — `npm run docs:build` builds the site into `docs/dist/`, and `npm run docs:preview` runs the Astro dev server on port 4173, replacing any dev server already running for the checkout, which reloads open tabs as pages change; a tab with a feedback popover open reloads once the popover closes. Set `DOCS_BASE_PATH=<path>` to build for a site hosted under a sub-path. The server restarts itself when a page is added or removed, a page's `group` or `order` changes, a screenshot PNG is added or removed, or code under `src/docs/` or `docs/capture/scenes.json` changes. A page whose frontmatter fails validation shows the error in the browser instead of its last valid copy.
53
53
  - **Feedback** — start the `docs` run entry (a `server: docs` run of `docs:preview` on port 4173) from the dashboard and open the preview in Firefox with the [assist browser extension](#docs-feedback) installed. Select text on a page with the mouse, and a prompt popover opens at the end of the selection with its textbox focused; type a prompt and press **Enter**: it arrives as a user prompt naming the page id, section heading and source `.md` file, with the selected text quoted, in the live Claude session that shares the docs server's directory — the one the run is grouped under on the dashboard. With several such sessions, the one that most recently wrote that page (else the newest) gets it; with none, the live session that most recently wrote the page or anything under `docs/src/`.
@@ -346,6 +346,8 @@ Rules are `- **<code>** — **<title>** — <text>` bullets, the title optional,
346
346
  - `assist netcap extract-linkedin-posts [file]` - Parse a netcap capture into structured LinkedIn posts
347
347
  - `assist extension [--sign] [--url]` - Locate the [assist browser extension](#assist-browser-extension) to load unpacked; `--sign` signs it for a permanent Firefox install; `--url` prints the latest signed build's download URL
348
348
  - `assist browser status [--url <substring>] [--server <url>]` - Through the [browser link](#browser-link), print the connected extension's version, the target tab's URL and whether the assist content script runs there; `--url` targets the most recently active tab whose URL contains the substring instead of the focused window's active tab; `--server` is the web server the extension connects to (default `http://localhost:3100`)
349
+ - `assist browser snapshot [--url <substring>] [--server <url>]` - Write the target tab's DOM (`outerHTML`) to `~/.assist/browser/<host>-<timestamp>.html` and print the tab's URL and the file's path
350
+ - `assist browser inspect [selector] [--text <text>] [--url <substring>] [--server <url>]` - For each element matching the CSS selector, or whose own text contains `--text` (skipping `script`/`style`), print its rendered size, text (first 80 characters) and ancestor chain from `html` down, one `tag#id.class.class` per line; prints the first 20 matches with the total, or that nothing matched
349
351
  - `assist screenshot <process>` - Capture a screenshot of a running application window (`screenshot.outputDir`, default `./screenshots`)
350
352
  - `assist mermaid export [file.md]` - Render each fenced mermaid block to SVG via [Kroki](https://kroki.io) (`--out`, `--index`, `mermaid.krokiUrl`)
351
353
  - `assist prompts` - Show the most frequently denied tool calls
package/allowed.cli-reads CHANGED
@@ -27,6 +27,8 @@ assist backlog list
27
27
  assist backlog show
28
28
  assist backlog view
29
29
  assist backup schedule status
30
+ assist browser inspect
31
+ assist browser snapshot
30
32
  assist browser status
31
33
  assist cli-hook
32
34
  assist complexity
@@ -27,6 +27,8 @@ assist backlog list
27
27
  assist backlog show
28
28
  assist backlog view
29
29
  assist backup schedule status
30
+ assist browser inspect
31
+ assist browser snapshot
30
32
  assist browser status
31
33
  assist cli-hook
32
34
  assist complexity
@@ -1 +1 @@
1
- "use strict";(()=>{function m(){return globalThis.browser?.storage?.local}function w(s){let e;try{e=new URL(s.trim())}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return e.origin}var _="http://localhost:3100",c="serverUrl";async function u(){let e=(await m()?.get(c).catch(()=>{}))?.[c];return typeof e=="string"&&w(e)||_}function d(){let s=globalThis.browser;return s?.runtime&&s.tabs?s:void 0}var O=new Set(["localhost","127.0.0.1"]);function b(s){if(!s)return!1;let e;try{e=new URL(s)}catch{return!1}let{protocol:r,hostname:t}=e;return r==="http:"?O.has(t):r!=="https:"?!1:t==="github.com"||t==="dev.azure.com"||t.endsWith(".visualstudio.com")}function y(s){return s.reduce((e,r)=>!e||(r.lastAccessed??0)>(e.lastAccessed??0)?r:e,void 0)}function k(s,e,r){if(r)return y(s.filter(n=>n.url?.includes(r)));let t=s.filter(n=>n.active);return t.find(n=>n.windowId===e)??y(t)}var R="assist-browser-probe",S="/ws/browser";var U="github.com, dev.azure.com, *.visualstudio.com, localhost, 127.0.0.1";async function A(s){let e=d();if(!e)return{ok:!1,error:"browser tabs API unavailable"};let[r,t]=await Promise.all([e.tabs.query({}),e.windows?.getLastFocused().catch(()=>{})]),n=k(r,t?.id,s.url);if(!n||n.id===void 0)return{ok:!1,error:s.url?`no open tab has a URL containing "${s.url}"`:"no active tab found"};let o=n.url;if(!o||!b(o))return{ok:!1,tabUrl:o,error:`the target tab is not on an assist host (${U})`};let f=await e.tabs.sendMessage(n.id,{type:R,op:s.op}).then(a=>a?.running===!0).catch(()=>!1);return{ok:!0,result:{tabUrl:o,contentScript:f}}}var h="assist-browser-link",F=5e3,i,l;function v(){let s=d();s&&(s.alarms?.create(h,{periodInMinutes:.5}),s.alarms?.onAlarm.addListener(e=>{e.name===h&&g()}),s.storage?.onChanged.addListener(e=>{c in e&&i?.close()}),g())}function g(){l||i&&i.readyState<=WebSocket.OPEN||(l=D().finally(()=>{l=void 0}))}async function D(){let s=await u(),e=new WebSocket(`${s.replace(/^http/,"ws")}${S}`);i=e,e.addEventListener("open",()=>B(e,{type:"hello",version:d()?.runtime.getManifest().version??"unknown"})),e.addEventListener("message",r=>{q(e,r.data)}),e.addEventListener("close",()=>{i===e&&(i=void 0,setTimeout(g,F))})}async function q(s,e){let r;try{r=JSON.parse(String(e))}catch{return}if(r.type!=="request")return;let t=await A(r).catch(n=>({ok:!1,error:n instanceof Error?n.message:String(n)}));B(s,{...t,type:"response",id:r.id})}function B(s,e){s.readyState===WebSocket.OPEN&&s.send(JSON.stringify(e))}function x(s){let{type:e,pageId:r,prompt:t}=s??{};return e==="assist-docs-feedback"&&typeof r=="string"&&typeof t=="string"}async function p(s,e,r){let t;try{t=await fetch(`${s}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}catch{return{ok:!1,message:`assist web server unreachable at ${s}`}}let n=await t.json().catch(()=>({}));return t.ok?{ok:!0,data:n}:{ok:!1,message:n.error??`assist web server returned ${t.status}`}}async function M(s,{type:e,...r}){let t=await p(s,"/api/sessions/docs-feedback",r);return t.ok?{ok:!0,message:t.data.message??"Sent to the docs session"}:t}var W={draft:["draft","--once"],bug:["bug","--once"]};function T(s){return typeof s=="string"&&Object.hasOwn(W,s)}function E(s){let{type:e,url:r,args:t,mode:n}=s??{};return e==="assist-send"&&typeof r=="string"&&(t===void 0||Array.isArray(t)&&t.every(o=>typeof o=="string"))&&(n===void 0||T(n))}function L(){return globalThis.browser?.runtime}async function P(s,{url:e,instructions:r,args:t,mode:n}){let[o,f]=t?["review-from-github",{url:e,args:t}]:["from-github",{url:e,instructions:r,mode:n}],a=await p(s,`/api/sessions/${o}`,f);return a.ok?{ok:!0,message:`assist session started in ${a.data.cwd}`}:a}function I(){L()?.onMessage.addListener(s=>{if(E(s))return u().then(e=>P(e,s));if(x(s))return u().then(e=>M(e,s))})}I();v();})();
1
+ "use strict";(()=>{function m(){return globalThis.browser?.storage?.local}function w(s){let e;try{e=new URL(s.trim())}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return e.origin}var _="http://localhost:3100",d="serverUrl";async function u(){let e=(await m()?.get(d).catch(()=>{}))?.[d];return typeof e=="string"&&w(e)||_}function p(){let s=globalThis.browser;return s?.runtime&&s.tabs?s:void 0}var I=new Set(["localhost","127.0.0.1"]);function b(s){if(!s)return!1;let e;try{e=new URL(s)}catch{return!1}let{protocol:t,hostname:r}=e;return t==="http:"?I.has(r):t!=="https:"?!1:r==="github.com"||r==="dev.azure.com"||r.endsWith(".visualstudio.com")}function y(s){return s.reduce((e,t)=>!e||(t.lastAccessed??0)>(e.lastAccessed??0)?t:e,void 0)}function R(s,e,t){if(t)return y(s.filter(n=>n.url?.includes(t)));let r=s.filter(n=>n.active);return r.find(n=>n.windowId===e)??y(r)}function k(s,e,t){let r=t?.running===!0;return s==="status"?{ok:!0,result:{tabUrl:e,contentScript:r}}:r?t.error||!t.result?{ok:!1,tabUrl:e,error:t.error??"empty probe reply"}:{ok:!0,result:{tabUrl:e,...t.result}}:{ok:!1,tabUrl:e,error:"the assist content script is not running on the target tab (reload the tab, or update the extension)"}}var h="assist-browser-probe",A="/ws/browser";var F="github.com, dev.azure.com, *.visualstudio.com, localhost, 127.0.0.1";async function S(s){let e=p();if(!e)return{ok:!1,error:"browser tabs API unavailable"};let[t,r]=await Promise.all([e.tabs.query({}),e.windows?.getLastFocused().catch(()=>{})]),n=R(t,r?.id,s.url);if(!n||n.id===void 0)return{ok:!1,error:s.url?`no open tab has a URL containing "${s.url}"`:"no active tab found"};let o=n.url;if(!o||!b(o))return{ok:!1,tabUrl:o,error:`the target tab is not on an assist host (${F})`};let l=await e.tabs.sendMessage(n.id,{...s,type:h}).then(a=>a).catch(()=>{});return k(s.op,o,l)}var x="assist-browser-link",U=5e3,i,f;function B(){let s=p();s&&(s.alarms?.create(x,{periodInMinutes:.5}),s.alarms?.onAlarm.addListener(e=>{e.name===x&&g()}),s.storage?.onChanged.addListener(e=>{d in e&&i?.close()}),g())}function g(){f||i&&i.readyState<=WebSocket.OPEN||(f=D().finally(()=>{f=void 0}))}async function D(){let s=await u(),e=new WebSocket(`${s.replace(/^http/,"ws")}${A}`);i=e,e.addEventListener("open",()=>v(e,{type:"hello",version:p()?.runtime.getManifest().version??"unknown"})),e.addEventListener("message",t=>{q(e,t.data)}),e.addEventListener("close",()=>{i===e&&(i=void 0,setTimeout(g,U))})}async function q(s,e){let t;try{t=JSON.parse(String(e))}catch{return}if(t.type!=="request")return;let r=await S(t).catch(n=>({ok:!1,error:n instanceof Error?n.message:String(n)}));v(s,{...r,type:"response",id:t.id})}function v(s,e){s.readyState===WebSocket.OPEN&&s.send(JSON.stringify(e))}function M(s){let{type:e,pageId:t,prompt:r}=s??{};return e==="assist-docs-feedback"&&typeof t=="string"&&typeof r=="string"}async function c(s,e,t){let r;try{r=await fetch(`${s}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{return{ok:!1,message:`assist web server unreachable at ${s}`}}let n=await r.json().catch(()=>({}));return r.ok?{ok:!0,data:n}:{ok:!1,message:n.error??`assist web server returned ${r.status}`}}async function P(s,{type:e,...t}){let r=await c(s,"/api/sessions/docs-feedback",t);return r.ok?{ok:!0,message:r.data.message??"Sent to the docs session"}:r}var W={draft:["draft","--once"],bug:["bug","--once"]};function T(s){return typeof s=="string"&&Object.hasOwn(W,s)}function E(s){let{type:e,url:t,args:r,mode:n}=s??{};return e==="assist-send"&&typeof t=="string"&&(r===void 0||Array.isArray(r)&&r.every(o=>typeof o=="string"))&&(n===void 0||T(n))}function L(){return globalThis.browser?.runtime}async function O(s,{url:e,instructions:t,args:r,mode:n}){let[o,l]=r?["review-from-github",{url:e,args:r}]:["from-github",{url:e,instructions:t,mode:n}],a=await c(s,`/api/sessions/${o}`,l);return a.ok?{ok:!0,message:`assist session started in ${a.data.cwd}`}:a}function G(){L()?.onMessage.addListener(s=>{if(E(s))return u().then(e=>O(e,s));if(M(s))return u().then(e=>P(e,s))})}G();B();})();