screw-bugs 0.1.5 → 0.1.6
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 +20 -3
- package/dist/build-info.json +3 -3
- package/dist/cli/commands.js +44 -19
- package/dist/cli/mcp.d.ts +13 -7
- package/dist/cli/mcp.js +55 -12
- package/dist/cli/operations.d.ts +12 -2
- package/dist/cli/operations.js +20 -2
- package/dist/report/html.d.ts +1 -1
- package/dist/report/html.js +29 -11
- package/dist/report/player.d.ts +18 -2
- package/dist/report/player.js +54 -5
- package/dist/report/pr-summary.d.ts +1 -1
- package/dist/report/pr-summary.js +13 -4
- package/dist/report/sign-in.d.ts +1 -1
- package/dist/report/sign-in.js +37 -8
- package/dist/report/styles.js +8 -0
- package/dist/report/view.d.ts +9 -0
- package/dist/report/view.js +16 -6
- package/dist/report/walkthrough.d.ts +3 -2
- package/dist/report/walkthrough.js +25 -9
- package/dist/schema/findings.d.ts +2 -0
- package/dist/schema/findings.js +8 -2
- package/dist/schema/ledger.d.ts +30 -0
- package/dist/schema/ledger.js +24 -0
- package/package.json +1 -1
package/dist/report/view.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DateTime, Duration, Option } from 'effect';
|
|
2
2
|
import { clipBox, drawableAction, drawableShot, MISMATCH_ALLOWED, withStartPage, } from '../core/index.js';
|
|
3
|
-
import { casesOf, framesOf, baseName, customTimeoutOf, uploadFileOf, } from '../schema/index.js';
|
|
3
|
+
import { casesOf, framesOf, agentFailures, baseName, judgedCase, judgedLedger, customTimeoutOf, uploadFileOf, } from '../schema/index.js';
|
|
4
4
|
/* What both reports show, worked out once. Plain data: escaping is each format's job. */
|
|
5
5
|
export const statuses = ['passed', 'failed', 'blocked', 'not_verified'];
|
|
6
6
|
export const statusLabel = {
|
|
@@ -9,6 +9,11 @@ export const statusLabel = {
|
|
|
9
9
|
blocked: 'Blocked',
|
|
10
10
|
not_verified: 'Not verified',
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* The code's result, shown under the agent's verdict on a case its findings mark failed:
|
|
14
|
+
* `Checks passed`, `Checks: blocked`.
|
|
15
|
+
*/
|
|
16
|
+
export const checksNote = (status) => status === 'passed' ? 'Checks passed' : `Checks: ${statusLabel[status].toLowerCase()}`;
|
|
12
17
|
export const countsOf = (cases) => {
|
|
13
18
|
const counts = { passed: 0, failed: 0, blocked: 0, not_verified: 0 };
|
|
14
19
|
for (const c of cases)
|
|
@@ -202,8 +207,11 @@ const drawableEntry = (entry, device) => ({
|
|
|
202
207
|
export const caseViews = (bundle) => {
|
|
203
208
|
const specs = new Map(casesOf(bundle.spec).map((spec) => [spec.id, spec]));
|
|
204
209
|
const written = new Map((bundle.findings?.cases ?? []).map((c) => [c.id, c]));
|
|
210
|
+
const failures = agentFailures(bundle.findings);
|
|
205
211
|
return bundle.ledger.cases.map((recorded) => {
|
|
206
|
-
|
|
212
|
+
// Steps and screenshots are as the code ran them; the status is the one results show.
|
|
213
|
+
const checked = drawableEntry(recorded, bundle.device.kind);
|
|
214
|
+
const { checkStatus, agentFailed, ...entry } = judgedCase(checked, failures);
|
|
207
215
|
const spec = specs.get(entry.id);
|
|
208
216
|
const steps = spec ? withStartPage(spec, bundle.spec.url) : [];
|
|
209
217
|
const offset = spec ? steps.length - spec.steps.length : 0;
|
|
@@ -218,7 +226,7 @@ export const caseViews = (bundle) => {
|
|
|
218
226
|
elements: (shot && bundle.elements?.[shot.id]) ?? [],
|
|
219
227
|
};
|
|
220
228
|
});
|
|
221
|
-
const failurePath = entry.evidence.findLast((path) => records.get(path)?.kind === 'failure' || isFailureShot(
|
|
229
|
+
const failurePath = entry.evidence.findLast((path) => records.get(path)?.kind === 'failure' || isFailureShot(checked, path));
|
|
222
230
|
return {
|
|
223
231
|
entry,
|
|
224
232
|
spec,
|
|
@@ -226,12 +234,14 @@ export const caseViews = (bundle) => {
|
|
|
226
234
|
index: i + 1 - offset,
|
|
227
235
|
step,
|
|
228
236
|
implicit: i < offset,
|
|
229
|
-
state: stateOf(
|
|
237
|
+
state: stateOf(checked, i + 1 - offset),
|
|
230
238
|
timing: timings.get(i + 1 - offset),
|
|
231
239
|
})),
|
|
232
240
|
failureShot: shots.find((s) => s.path === failurePath),
|
|
233
241
|
otherShots: shots.filter((s) => s.path !== failurePath),
|
|
234
242
|
findings: written.get(entry.id),
|
|
243
|
+
checkStatus,
|
|
244
|
+
agentFailed,
|
|
235
245
|
video: videoOf(bundle, entry),
|
|
236
246
|
};
|
|
237
247
|
});
|
|
@@ -614,7 +624,7 @@ export const reportHeading = (bundle) => {
|
|
|
614
624
|
* `7 of 7 cases passed · 3 areas not tested`, never that all passed.
|
|
615
625
|
*/
|
|
616
626
|
export const verdictOf = (bundle) => {
|
|
617
|
-
const { cases, state } = bundle.ledger;
|
|
627
|
+
const { cases, state } = judgedLedger(bundle.ledger, bundle.findings);
|
|
618
628
|
const passed = cases.filter((c) => c.status === 'passed').length;
|
|
619
629
|
if (state !== 'finished' && state !== 'errored')
|
|
620
630
|
return `In progress: ${passed} of ${cases.length} passed so far`;
|
|
@@ -626,7 +636,7 @@ export const verdictOf = (bundle) => {
|
|
|
626
636
|
/** `2 failed`, `1 not verified`: a count of cases with a status, as the filters say it. */
|
|
627
637
|
export const countWords = (status, n) => `${n} ${statusLabel[status].toLowerCase()}`;
|
|
628
638
|
export const evaluationOf = (bundle) => {
|
|
629
|
-
const counts = countsOf(bundle.ledger.cases);
|
|
639
|
+
const counts = countsOf(judgedLedger(bundle.ledger, bundle.findings).cases);
|
|
630
640
|
const line = statuses
|
|
631
641
|
.filter((s) => s !== 'passed' && counts[s] > 0)
|
|
632
642
|
.map((s) => countWords(s, counts[s]))
|
|
@@ -40,7 +40,7 @@ export declare const GLIDE_S = 0.6;
|
|
|
40
40
|
* and there is no ripple. A "Cursor" switch turns it off, remembered like the theme. Nothing is
|
|
41
41
|
* added to the page under test or to the video.
|
|
42
42
|
*/
|
|
43
|
-
export declare const WALKTHROUGH_SCRIPT = "(()=>{const d=document,r=d.documentElement,K='screw-bugs-theme';\nconst still=()=>matchMedia('(prefers-reduced-motion: reduce)').matches;\nconst topEdge=()=>{const b=d.querySelector('.menubar');return b?Math.max(0,b.getBoundingClientRect().bottom):0};\nconst pad=n=>String(n).padStart(2,'0');\nconst clock=s=>{s=Math.max(0,Math.floor(s||0));const h=Math.floor(s/3600),m=Math.floor(s%3600/60);return(h?h+':'+pad(m):String(m))+':'+pad(s%60)};\nlet theme='system';try{theme=localStorage.getItem(K)||theme}catch(e){}r.dataset.theme=theme;\nconst themeCycle=(b,key)=>{\n const r=document.documentElement,T=['light','dark','system'],N={light:'Light theme',dark:'Dark theme',system:'Theme from system'};\n const at=()=>{const i=T.indexOf(r.dataset.theme);return i<0?2:i};\n const show=()=>{const i=at(),f=document.getElementById('favicon'),h=f&&f.dataset[T[i]];if(h)f.href=h;b.setAttribute('aria-label',N[T[i]]+'. Switch to '+N[T[(i+1)%3]].toLowerCase());b.title=N[T[i]]};\n show();\n b.addEventListener('click',()=>{const m=T[(at()+1)%3];r.dataset.theme=m;if(key)try{localStorage.setItem(key,m)}catch(e){}show()});\n};\nconst chrome=()=>{\n d.querySelectorAll('.menubar .theme').forEach(b=>{themeCycle(b,K);b.hidden=false});\n if(location.protocol==='http:'&&(location.hostname==='127.0.0.1'||location.hostname==='localhost'))d.querySelectorAll('a.share-btn').forEach(a=>{a.hidden=false});\n d.querySelectorAll('time.when[datetime]').forEach(e=>{\n const t=new Date(e.getAttribute('datetime'));if(isNaN(t.getTime()))return;const p={};\n try{new Intl.DateTimeFormat('en-US',{month:'short',day:'numeric',year:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).forEach(x=>{p[x.type]=x.value});\n const y=d.createElement('span');y.className='year';y.textContent=', '+p.year;\n e.replaceChildren(p.month+' '+p.day,y,' '+String.fromCharCode(183)+' '+p.hour+':'+p.minute);\n e.title=new Intl.DateTimeFormat('en-US',{dateStyle:'full',timeStyle:'long'}).format(t)}catch(x){}\n });\n d.querySelectorAll('.prompt').forEach(p=>{\n const t=p.querySelector('.prompt-text'),b=p.querySelector('.prompt-more');if(!t||!b)return;\n const fits=()=>{if(!p.classList.contains('open'))b.hidden=t.scrollHeight<=t.clientHeight+1};\n fits();if(window.ResizeObserver)new ResizeObserver(fits).observe(t);if(d.fonts&&d.fonts.ready)d.fonts.ready.then(fits);\n b.addEventListener('click',()=>{const o=p.classList.toggle('open');b.textContent=o?'Show less':'Show full prompt';b.setAttribute('aria-expanded',String(o));fits()});\n });\n};\nconst bare=u=>{const i=u.indexOf('://');return i<0?u:u.slice(i+3)};\nconst player=(p,o)=>{\n const v=d.getElementById(p+'-video'),fig=v.closest('.player'),note=d.getElementById(p+'-unloaded'),c=d.getElementById(p+'-controls'),url=d.getElementById(p+'-url');\n const srcs=new Map([...fig.querySelectorAll('[data-session-src]')].map(e=>[e.dataset.session,e.dataset.sessionSrc]));\n const order=[...srcs.keys()];\n const urls=[...fig.querySelectorAll('[data-url]')].map(e=>({s:e.dataset.s,t:Number(e.dataset.at),u:e.dataset.url}));\n const dead=new Set(),empty=d.getElementById(p+'-none');let cur=v.dataset.session,down=null,held=false,ask=0,auto=false,rate=1,raf=0,drag=false;\n const play=c.querySelector('.play'),now=c.querySelector('.now'),total=c.querySelector('.total'),bar=c.querySelector('.scrub'),head=c.querySelector('.head'),tracks=[...c.querySelectorAll('.track')];\n v.removeAttribute('controls');c.hidden=false;\n const big=d.getElementById(p+'-start');\n if(big){big.hidden=false;big.addEventListener('click',()=>{grow();v.play().catch(()=>{})});v.addEventListener('play',()=>big.remove(),{once:true})}\n const track=()=>tracks.find(t=>t.dataset.s===cur);\n const len=()=>{const t=track(),n=t?Number(t.dataset.total):0;return n>0?n:(isFinite(v.duration)?v.duration:0)};\n const paint=()=>{\n const L=len(),t=v.currentTime,f=L?Math.min(1,t/L):0,k=track();\n tracks.forEach(x=>{x.hidden=x!==k});head.style.left=(f*100)+'%';\n const done=k&&k.querySelector('.done');if(done)done.style.width=(f*100)+'%';\n now.textContent=clock(t);total.textContent=clock(L);\n bar.setAttribute('aria-valuemax',String(Math.round(L)));bar.setAttribute('aria-valuenow',String(Math.round(t)));bar.setAttribute('aria-valuetext',clock(t)+' of '+clock(L));\n play.classList.toggle('playing',!v.paused);play.setAttribute('aria-label',v.paused?'Play':'Pause');\n if(url){let u='';if(down!=='')for(const x of urls){if(x.s===cur&&x.t<=t+0.02)u=x.u}url.textContent=bare(u);url.parentElement.title=u}\n };\n const update=()=>{paint();if(o.tick)o.tick(v.currentTime)};\n const frame=()=>{update();raf=v.paused?0:requestAnimationFrame(frame)};\n const show=s=>{if(down===null)held=!v.paused;down=s;v.pause();fig.classList.add('broken');c.hidden=true;if(empty)empty.hidden=true;if(note){note.hidden=false;const a=note.querySelector('a');if(a){a.href=srcs.get(s);a.textContent=srcs.get(s)}}if(o.broken)o.broken()};\n const fine=()=>{if(down===null)return;down=null;fig.classList.remove('broken');c.hidden=false;if(note)note.hidden=true;if(empty)empty.hidden=true;if(o.fine)o.fine()};\n const none=()=>{if(down===null)held=!v.paused;++ask;auto=false;down='';v.pause();fig.classList.add('broken');c.hidden=true;if(note)note.hidden=true;if(empty)empty.hidden=false;paint();if(o.broken)o.broken()};\n const playing=()=>down===null?!v.paused:held;\n const next=s=>order.slice(order.indexOf(s)+1).find(n=>!dead.has(n));\n const load=(s,t,go,a)=>{\n const my=++ask;auto=!!a;if(dead.has(s))return show(s);\n if(s!==cur||!v.currentSrc||v.error){cur=s;v.dataset.session=s;v.src=srcs.get(s);v.load()}\n const done=()=>{if(my!==ask)return;auto=false;fine();v.playbackRate=rate;v.currentTime=t;update();if(go)v.play().catch(()=>{})};\n if(v.readyState>0)done();else v.addEventListener('loadedmetadata',done,{once:true});\n };\n const bad=()=>{if(!v.error)return;dead.add(cur);if(down==='')return;const n=auto?next(cur):undefined;if(n!==undefined)return load(n,0,true,true);auto=false;show(cur)};\n ['timeupdate','seeked','loadedmetadata','pause','play','durationchange'].forEach(n=>v.addEventListener(n,update));\n v.addEventListener('play',()=>{if(!raf)raf=requestAnimationFrame(frame)});\n addEventListener('resize',update);\n v.addEventListener('error',bad);if(v.error)queueMicrotask(bad);\n v.addEventListener('ended',()=>{if(o.ended&&o.ended())return;const n=next(cur);if(n!==undefined)load(n,0,true,true)});\n play.addEventListener('click',()=>{if(v.paused)v.play().catch(()=>{});else v.pause()});\n v.addEventListener('click',()=>{if(down!==null)return;if(grow())v.play().catch(()=>{});else play.click()});\n c.querySelectorAll('[data-rate]').forEach(b=>b.addEventListener('click',()=>{rate=Number(b.dataset.rate);v.playbackRate=rate;v.defaultPlaybackRate=rate;c.querySelectorAll('[data-rate]').forEach(x=>x.setAttribute('aria-pressed',String(x===b)))}));\n const seek=t=>{const L=len();t=Math.max(0,L?Math.min(L,t):t);v.currentTime=t;if(o.seek)o.seek(t);update()};\n const at=e=>{const b=bar.getBoundingClientRect();return Math.max(0,Math.min(1,(e.clientX-b.left)/b.width))*len()};\n bar.addEventListener('pointerdown',e=>{if(e.button>0||down!==null)return;drag=true;bar.setPointerCapture(e.pointerId);seek(at(e))});\n bar.addEventListener('pointermove',e=>{if(drag)seek(at(e))});\n ['pointerup','pointercancel'].forEach(n=>bar.addEventListener(n,()=>{drag=false}));\n bar.addEventListener('keydown',e=>{\n const k=e.key,t=v.currentTime,by={ArrowLeft:-1,ArrowDown:-1,ArrowRight:1,ArrowUp:1,PageDown:-10,PageUp:10}[k];\n const to=by!==undefined?t+by:k==='Home'?0:k==='End'?len():null;if(to===null)return;e.preventDefault();seek(to);\n });\n const full=c.querySelector('.full'),screen=o.full||fig.querySelector('.screen');\n const api=!!(d.fullscreenEnabled&&screen.requestFullscreen),inPage=()=>!!o.inPage&&(o.inPage()||!api);\n const mark=()=>{const f=d.fullscreenElement===screen||screen.classList.contains('focus');full.classList.toggle('out',f);full.setAttribute('aria-label',f?'Exit fullscreen':'Fullscreen');update()};\n let back=0;const focus=on=>{if(on)back=scrollY;screen.classList.toggle('focus',on);scrollTo({top:on?0:back,behavior:'auto'});mark()};\n const grow=()=>{if(!o.expand||!o.inPage||!o.inPage()||d.fullscreenElement||screen.classList.contains('focus'))return false;focus(true);return true};\n if(!api&&!o.inPage)full.hidden=true;\n else{full.addEventListener('click',()=>{const f=screen.classList.contains('focus');if(d.fullscreenElement){d.exitFullscreen().catch(()=>{});if(f)focus(false)}else if(f)focus(false);else if(inPage())focus(true);else screen.requestFullscreen().catch(()=>{})});\n d.addEventListener('fullscreenchange',mark);\n d.addEventListener('keydown',e=>{if(e.key==='Escape'&&!e.defaultPrevented&&screen.classList.contains('focus')&&!d.querySelector('dialog[open]')){e.preventDefault();focus(false)}})}\n d.addEventListener('keydown',e=>{if(e.key!==' '||down!==null||e.defaultPrevented||d.querySelector('dialog[open]')||e.target.closest('button,a,input,textarea,select,summary,[role=slider]'))return;e.preventDefault();play.click()});\n return {v,load,none,playing,update,len,cur:()=>cur,down:()=>down,has:s=>srcs.has(s)};\n};\n\nd.addEventListener('DOMContentLoaded',()=>{\n chrome();\n const stg=d.querySelector('.wt-stage');let fr=0;\n const fit=()=>{fr=0;if(!stg)return;const t=stg.getBoundingClientRect().top;stg.style.setProperty('--wt-top',Math.round(t)+'px');stg.style.setProperty('--wt-y',Math.round(t+scrollY)+'px')};\n const refit=()=>{if(!fr)fr=requestAnimationFrame(fit)};\n fit();addEventListener('resize',refit);addEventListener('load',refit);addEventListener('scroll',refit,{passive:true});d.addEventListener('fullscreenchange',refit);\n if(window.ResizeObserver)new ResizeObserver(refit).observe(d.body);\n const v=d.getElementById('wt-video');if(!v)return;\n const w=d.querySelector('.wt'),panel=d.getElementById('wt-script'),box=d.getElementById('wt-box'),cap=d.getElementById('wt-cap');\n const say=a=>{const x=a&&a.querySelector('.wt-text');cap.replaceChildren(...(x?[...x.childNodes].filter(n=>!(n instanceof Element&&n.classList.contains('wt-state'))).map(n=>n.cloneNode(true)):[]));cap.hidden=!x};\n const steps=[...d.querySelectorAll('.wt-step[data-t]')];\n const idle=[...d.querySelectorAll('.idle[data-a]')].map(e=>({s:e.closest('.track').dataset.s,a:Number(e.dataset.a),b:Number(e.dataset.b)}));\n const skipB=d.getElementById('wt-skip'),expB=d.getElementById('wt-expand');\n let on=null,skip=!!skipB&&skipB.getAttribute('aria-pressed')==='true',P=null;\n w.classList.add('live');\n const hide=()=>{box.hidden=true};\n const geo=()=>{const vw=v.videoWidth,vh=v.videoHeight,cw=v.clientWidth,ch=v.clientHeight;if(!vw||!vh||!cw||!ch)return null;const s=Math.min(cw/vw,ch/vh);return{x:v.offsetLeft+(cw-vw*s)/2,y:v.offsetTop+(ch-vh*s)/2,w:vw*s,h:vh*s}};\n const put=(e,x,y,bw,bh)=>{e.style.left=x+'px';e.style.top=y+'px';if(bw!==undefined){e.style.width=bw+'px';e.style.height=bh+'px'}};\n const draw=(t,g)=>{if(P.down()!==null||!g||!on||!on.dataset.box||t<Number(on.dataset.b0)||t>Number(on.dataset.b1))return hide();const b=on.dataset.box.split(' ').map(Number);put(box,g.x+b[0]*g.w,g.y+b[1]*g.h,b[2]*g.w,b[3]*g.h);box.querySelector('span').textContent=on.dataset.label||'';box.hidden=false};\n const C=d.getElementById('wt-cursor'),R=d.getElementById('wt-ripple'),G=d.getElementById('wt-ring'),L=d.getElementById('wt-act'),T=d.getElementById('wt-cursor-on'),ck='screw-bugs-cursor';\n const nums=x=>x?x.split(' ').map(Number):null;\n const acts=[...d.querySelectorAll('.wt-step[data-act][data-s]')].map(e=>({s:e.dataset.s,at:e.dataset.at?Number(e.dataset.at):NaN,t0:Number(e.dataset.t),t1:Number(e.dataset.a1),b0:Number(e.dataset.b0),b1:Number(e.dataset.b1),k:e.dataset.act,p:nums(e.dataset.pt),b:nums(e.dataset.tb),l:e.dataset.al||''})).sort((a,b)=>(a.at>=0?a.at:a.t0)-(b.at>=0?b.at:b.t0));\n let fon=true;try{fon=localStorage.getItem(ck)!=='off'}catch(e){}\n const fx=(t,g)=>{\n C.hidden=R.hidden=G.hidden=L.hidden=true;box.querySelector('span').hidden=false;\n if(!fon||P.down()!==null||!g)return;\n const m=still(),mine=acts.filter(a=>a.s===P.cur()),ptr=mine.filter(a=>a.p),xy=p=>[g.x+p[0]*g.w,g.y+p[1]*g.h];\n let i=-1;ptr.forEach((a,j)=>{if(a.at<=t)i=j});\n const a=ptr[i],n=ptr[i+1];let c=a?a.p:null;\n if(n&&a){const gw=Math.min(0.6,n.at-a.at),q=gw>0?(t-n.at+gw)/gw:1;if(q>=0){const e=q<.5?4*q*q*q:1-Math.pow(2-2*q,3)/2;c=!m&&q<1?[a.p[0]+(n.p[0]-a.p[0])*e,a.p[1]+(n.p[1]-a.p[1])*e]:n.p}}\n if(c){const xy0=xy(c);put(C,xy0[0]-3,xy0[1]-2);C.hidden=false}\n if(a&&!m&&t-a.at<.6){const q=(t-a.at)/.6,xy1=xy(a.p);put(R,xy1[0],xy1[1]);R.style.transform='translate(-50%,-50%) scale('+(.35+q*1.3)+')';R.style.opacity=String(1-q);R.hidden=false}\n let f=null,l=null,u=null;\n for(const x of mine){if(x.k==='fill'&&x.b&&t>=x.b0&&t<=x.b1)f=x;if(x.k==='fill'||!(x.at>=0)?t>=x.t0&&t<=x.t1:t>=x.at&&t<=x.at+1.5)l=x;else if(!u&&x.p&&x.at>t&&x.at-t<=0.6)u=x}\n l=l||u;\n if(f){const xy2=xy(f.b);put(G,xy2[0],xy2[1],f.b[2]*g.w,f.b[3]*g.h);G.hidden=false;box.hidden=true}\n if(l&&l.l){L.textContent=l.l;L.hidden=false;let x=g.x+10,y=g.y+10;if(l.p){const q=xy(l.p);x=q[0]+14;y=q[1]+20}else if(l.b){const q=xy(l.b);x=q[0];y=q[1]+l.b[3]*g.h+10}if(y+L.offsetHeight>g.y+g.h-4)y=l.b?g.y+l.b[1]*g.h-L.offsetHeight-10:g.y+g.h-L.offsetHeight-4;put(L,Math.max(g.x+4,Math.min(x,g.x+g.w-L.offsetWidth-4)),Math.max(g.y+4,y))}\n box.querySelector('span').hidden=!L.hidden;\n };\n const stage=d.querySelector('.wt-stage');\n const cover=()=>{let y=topEdge();if(stage&&getComputedStyle(stage).position==='sticky')y=Math.max(y,stage.getBoundingClientRect().bottom+16);return y};\n const anchor=a=>{const hid=Math.max(0,cover()-panel.getBoundingClientRect().top);panel.scrollTo({top:Math.max(0,a.offsetTop-6-hid),behavior:still()?'auto':'smooth'})};\n const tick=t=>{\n const cur=P.cur();\n if(skip&&!v.paused&&!v.seeking){const gap=idle.find(x=>x.s===cur&&t>=x.a&&t<x.b-0.05);if(gap){v.currentTime=gap.b;return}}\n let a=null;for(const s of steps){if(s.dataset.s===cur&&Number(s.dataset.t)<=t+0.02)a=s}\n if(a!==on){if(on){on.classList.remove('on');on.removeAttribute('aria-current');on.closest('.wt-case').classList.remove('on')}on=a;say(a);if(a){a.classList.add('on');a.setAttribute('aria-current','step');a.closest('.wt-case').classList.add('on');anchor(a)}}\n const g=geo();draw(t,g);fx(t,g);\n };\n P=player('wt',{tick,full:w,expand:true,inPage:()=>matchMedia('(min-width: 901px)').matches,broken:()=>{hide();fx(0,null);w.classList.remove('live')},fine:()=>{w.classList.add('live')}});\n if(T&&acts.length){T.checked=fon;T.closest('label').hidden=false;T.addEventListener('change',()=>{fon=T.checked;try{localStorage.setItem(ck,fon?'on':'off')}catch(e){}P.update()})}\n if(skipB)skipB.addEventListener('click',()=>{skip=!skip;skipB.setAttribute('aria-pressed',String(skip))});\n if(expB)expB.addEventListener('click',()=>{const x=w.classList.toggle('expanded');expB.setAttribute('aria-expanded',String(x));expB.querySelector('span').textContent=x?'Collapse':'Expand';P.update();if(on)anchor(on)});\n d.addEventListener('click',e=>{\n const t=e.target;if(!(t instanceof Element))return;\n const a=t.closest('a[data-t][data-s],.wt-step[data-t][data-s]');if(!a||!P.has(a.dataset.s))return;\n e.preventDefault();const fig=v.closest('.player');\n if(fig.getBoundingClientRect().bottom<topEdge())fig.scrollIntoView({block:'start',behavior:still()?'auto':'smooth'});\n P.load(a.dataset.s,Number(a.dataset.t),P.playing());\n });\n P.update();\n});\n})();";
|
|
43
|
+
export declare const WALKTHROUGH_SCRIPT = "(()=>{const d=document,r=d.documentElement,K='screw-bugs-theme';\nconst still=()=>matchMedia('(prefers-reduced-motion: reduce)').matches;\nconst topEdge=()=>{const b=d.querySelector('.menubar');return b?Math.max(0,b.getBoundingClientRect().bottom):0};\nconst pad=n=>String(n).padStart(2,'0');\nconst clock=s=>{s=Math.max(0,Math.floor(s||0));const h=Math.floor(s/3600),m=Math.floor(s%3600/60);return(h?h+':'+pad(m):String(m))+':'+pad(s%60)};\nlet theme='system';try{theme=localStorage.getItem(K)||theme}catch(e){}r.dataset.theme=theme;\nconst themeCycle=(b,key)=>{\n const r=document.documentElement,T=['light','dark','system'],N={light:'Light theme',dark:'Dark theme',system:'Theme from system'};\n const at=()=>{const i=T.indexOf(r.dataset.theme);return i<0?2:i};\n const show=()=>{const i=at(),f=document.getElementById('favicon'),h=f&&f.dataset[T[i]];if(h)f.href=h;b.setAttribute('aria-label',N[T[i]]+'. Switch to '+N[T[(i+1)%3]].toLowerCase());b.title=N[T[i]]};\n show();\n b.addEventListener('click',()=>{const m=T[(at()+1)%3];r.dataset.theme=m;if(key)try{localStorage.setItem(key,m)}catch(e){}show()});\n};\nconst chrome=()=>{\n d.querySelectorAll('.menubar .theme').forEach(b=>{themeCycle(b,K);b.hidden=false});\n if(location.protocol==='http:'&&(location.hostname==='127.0.0.1'||location.hostname==='localhost'))d.querySelectorAll('a.share-btn').forEach(a=>{a.hidden=false});\n d.querySelectorAll('time.when[datetime]').forEach(e=>{\n const t=new Date(e.getAttribute('datetime'));if(isNaN(t.getTime()))return;const p={};\n try{new Intl.DateTimeFormat('en-US',{month:'short',day:'numeric',year:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).forEach(x=>{p[x.type]=x.value});\n const y=d.createElement('span');y.className='year';y.textContent=', '+p.year;\n e.replaceChildren(p.month+' '+p.day,y,' '+String.fromCharCode(183)+' '+p.hour+':'+p.minute);\n e.title=new Intl.DateTimeFormat('en-US',{dateStyle:'full',timeStyle:'long'}).format(t)}catch(x){}\n });\n d.querySelectorAll('.prompt').forEach(p=>{\n const t=p.querySelector('.prompt-text'),b=p.querySelector('.prompt-more');if(!t||!b)return;\n const fits=()=>{if(!p.classList.contains('open'))b.hidden=t.scrollHeight<=t.clientHeight+1};\n fits();if(window.ResizeObserver)new ResizeObserver(fits).observe(t);if(d.fonts&&d.fonts.ready)d.fonts.ready.then(fits);\n b.addEventListener('click',()=>{const o=p.classList.toggle('open');b.textContent=o?'Show less':'Show full prompt';b.setAttribute('aria-expanded',String(o));fits()});\n });\n};\nconst bare=u=>{const i=u.indexOf('://');return i<0?u:u.slice(i+3)};\nconst player=(p,o)=>{\n const v=d.getElementById(p+'-video'),fig=v.closest('.player'),note=d.getElementById(p+'-unloaded'),c=d.getElementById(p+'-controls'),url=d.getElementById(p+'-url');\n const srcs=new Map([...fig.querySelectorAll('[data-session-src]')].map(e=>[e.dataset.session,e.dataset.sessionSrc]));\n const order=[...srcs.keys()];\n const urls=[...fig.querySelectorAll('[data-url]')].map(e=>({s:e.dataset.s,t:Number(e.dataset.at),u:e.dataset.url}));\n const dead=new Set(),errs=new Map(),empty=d.getElementById(p+'-none');let shown=0,cur=v.dataset.session,down=null,held=false,ask=0,auto=false,rate=1,raf=0,drag=false;\n const play=c.querySelector('.play'),now=c.querySelector('.now'),total=c.querySelector('.total'),bar=c.querySelector('.scrub'),head=c.querySelector('.head'),tracks=[...c.querySelectorAll('.track')];\n v.removeAttribute('controls');c.hidden=false;\n const big=d.getElementById(p+'-start');\n if(big){big.hidden=false;big.addEventListener('click',()=>{grow();v.play().catch(()=>{})});v.addEventListener('play',()=>big.remove(),{once:true})}\n const track=()=>tracks.find(t=>t.dataset.s===cur);\n const len=()=>{const t=track(),n=t?Number(t.dataset.total):0;return n>0?n:(isFinite(v.duration)?v.duration:0)};\n const paint=()=>{\n const L=len(),t=v.currentTime,f=L?Math.min(1,t/L):0,k=track();\n tracks.forEach(x=>{x.hidden=x!==k});head.style.left=(f*100)+'%';\n const done=k&&k.querySelector('.done');if(done)done.style.width=(f*100)+'%';\n now.textContent=clock(t);total.textContent=clock(L);\n bar.setAttribute('aria-valuemax',String(Math.round(L)));bar.setAttribute('aria-valuenow',String(Math.round(t)));bar.setAttribute('aria-valuetext',clock(t)+' of '+clock(L));\n play.classList.toggle('playing',!v.paused);play.setAttribute('aria-label',v.paused?'Play':'Pause');\n if(url){let u='';if(down!=='')for(const x of urls){if(x.s===cur&&x.t<=t+0.02)u=x.u}url.textContent=bare(u);url.parentElement.title=u}\n };\n const update=()=>{paint();if(o.tick)o.tick(v.currentTime)};\n const frame=()=>{update();raf=v.paused?0:requestAnimationFrame(frame)};\n const show=s=>{if(down===null)held=!v.paused;down=s;v.pause();fig.classList.add('broken');c.hidden=true;if(empty)empty.hidden=true;if(note){++shown;note.hidden=false;const a=note.querySelector('a');if(a){a.href=srcs.get(s);a.textContent=srcs.get(s)}const ft=note.querySelector('.fix-text'),fd=note.querySelector('.fix-done');if(ft){ft.hidden=true;ft.value=''}if(fd)fd.textContent=''}if(o.broken)o.broken()};\n const fine=()=>{if(down===null)return;down=null;fig.classList.remove('broken');c.hidden=false;if(note)note.hidden=true;if(empty)empty.hidden=true;if(o.fine)o.fine()};\n const none=()=>{if(down===null)held=!v.paused;++ask;auto=false;down='';v.pause();fig.classList.add('broken');c.hidden=true;if(note)note.hidden=true;if(empty)empty.hidden=false;paint();if(o.broken)o.broken()};\n const playing=()=>down===null?!v.paused:held;\n const next=s=>order.slice(order.indexOf(s)+1).find(n=>!dead.has(n));\n const load=(s,t,go,a)=>{\n const my=++ask;auto=!!a;if(dead.has(s))return show(s);\n if(s!==cur||!v.currentSrc||v.error){cur=s;v.dataset.session=s;v.src=srcs.get(s);v.load()}\n const done=()=>{if(my!==ask)return;auto=false;fine();v.playbackRate=rate;v.currentTime=t;update();if(go)v.play().catch(()=>{})};\n if(v.readyState>0)done();else v.addEventListener('loadedmetadata',done,{once:true});\n };\n const bad=()=>{const e=v.error;if(!e)return;dead.add(cur);errs.set(cur,'error code '+e.code+(e.message?': '+e.message:''));if(down==='')return;const n=auto?next(cur):undefined;if(n!==undefined)return load(n,0,true,true);auto=false;show(cur)};\n ['timeupdate','seeked','loadedmetadata','pause','play','durationchange'].forEach(n=>v.addEventListener(n,update));\n v.addEventListener('play',()=>{if(!raf)raf=requestAnimationFrame(frame)});\n addEventListener('resize',update);\n v.addEventListener('error',bad);if(v.error)queueMicrotask(bad);\n const fix=d.getElementById(p+'-fix');\n if(fix){const box=fix.parentElement,ta=box.querySelector('.fix-text'),said=box.querySelector('.fix-done');\n fix.addEventListener('click',()=>{\n let t=ta.dataset.template||'';\n [['video',down?srcs.get(down)||'':''],['page',location.href],['browser',navigator.userAgent],['error',errs.get(down)||'nothing']].forEach(([k,x])=>{t=t.split('{'+k+'}').join(x)});\n const g=shown;ta.value=t;const ok=()=>{if(g!==shown)return;said.textContent='Copied. Paste it into your coding agent.'};\n const by=()=>{if(g!==shown)return;ta.hidden=false;ta.focus();ta.setSelectionRange(0,t.length);ta.scrollTop=0;let c=false;try{c=d.execCommand('copy')}catch(x){}if(c)ok();else said.textContent='Copy the prompt below.'};\n if(navigator.clipboard&&window.isSecureContext)navigator.clipboard.writeText(t).then(ok,by);else by();\n })}\n v.addEventListener('ended',()=>{if(o.ended&&o.ended())return;const n=next(cur);if(n!==undefined)load(n,0,true,true)});\n play.addEventListener('click',()=>{if(v.paused)v.play().catch(()=>{});else v.pause()});\n v.addEventListener('click',()=>{if(down!==null)return;if(grow())v.play().catch(()=>{});else play.click()});\n c.querySelectorAll('[data-rate]').forEach(b=>b.addEventListener('click',()=>{rate=Number(b.dataset.rate);v.playbackRate=rate;v.defaultPlaybackRate=rate;c.querySelectorAll('[data-rate]').forEach(x=>x.setAttribute('aria-pressed',String(x===b)))}));\n const seek=t=>{const L=len();t=Math.max(0,L?Math.min(L,t):t);v.currentTime=t;if(o.seek)o.seek(t);update()};\n const at=e=>{const b=bar.getBoundingClientRect();return Math.max(0,Math.min(1,(e.clientX-b.left)/b.width))*len()};\n bar.addEventListener('pointerdown',e=>{if(e.button>0||down!==null)return;drag=true;bar.setPointerCapture(e.pointerId);seek(at(e))});\n bar.addEventListener('pointermove',e=>{if(drag)seek(at(e))});\n ['pointerup','pointercancel'].forEach(n=>bar.addEventListener(n,()=>{drag=false}));\n bar.addEventListener('keydown',e=>{\n const k=e.key,t=v.currentTime,by={ArrowLeft:-1,ArrowDown:-1,ArrowRight:1,ArrowUp:1,PageDown:-10,PageUp:10}[k];\n const to=by!==undefined?t+by:k==='Home'?0:k==='End'?len():null;if(to===null)return;e.preventDefault();seek(to);\n });\n const full=c.querySelector('.full'),screen=o.full||fig.querySelector('.screen');\n const api=!!(d.fullscreenEnabled&&screen.requestFullscreen),inPage=()=>!!o.inPage&&(o.inPage()||!api);\n const mark=()=>{const f=d.fullscreenElement===screen||screen.classList.contains('focus');full.classList.toggle('out',f);full.setAttribute('aria-label',f?'Exit fullscreen':'Fullscreen');update()};\n let back=0;const focus=on=>{if(on)back=scrollY;screen.classList.toggle('focus',on);scrollTo({top:on?0:back,behavior:'auto'});mark()};\n const grow=()=>{if(!o.expand||!o.inPage||!o.inPage()||d.fullscreenElement||screen.classList.contains('focus'))return false;focus(true);return true};\n if(!api&&!o.inPage)full.hidden=true;\n else{full.addEventListener('click',()=>{const f=screen.classList.contains('focus');if(d.fullscreenElement){d.exitFullscreen().catch(()=>{});if(f)focus(false)}else if(f)focus(false);else if(inPage())focus(true);else screen.requestFullscreen().catch(()=>{})});\n d.addEventListener('fullscreenchange',mark);\n d.addEventListener('keydown',e=>{if(e.key==='Escape'&&!e.defaultPrevented&&screen.classList.contains('focus')&&!d.querySelector('dialog[open]')){e.preventDefault();focus(false)}})}\n d.addEventListener('keydown',e=>{if(e.key!==' '||down!==null||e.defaultPrevented||d.querySelector('dialog[open]')||e.target.closest('button,a,input,textarea,select,summary,[role=slider]'))return;e.preventDefault();play.click()});\n return {v,load,none,playing,update,len,cur:()=>cur,down:()=>down,has:s=>srcs.has(s)};\n};\n\nd.addEventListener('DOMContentLoaded',()=>{\n chrome();\n const stg=d.querySelector('.wt-stage');let fr=0;\n const fit=()=>{fr=0;if(!stg)return;const t=stg.getBoundingClientRect().top;stg.style.setProperty('--wt-top',Math.round(t)+'px');stg.style.setProperty('--wt-y',Math.round(t+scrollY)+'px')};\n const refit=()=>{if(!fr)fr=requestAnimationFrame(fit)};\n fit();addEventListener('resize',refit);addEventListener('load',refit);addEventListener('scroll',refit,{passive:true});d.addEventListener('fullscreenchange',refit);\n if(window.ResizeObserver)new ResizeObserver(refit).observe(d.body);\n const v=d.getElementById('wt-video');if(!v)return;\n const w=d.querySelector('.wt'),panel=d.getElementById('wt-script'),box=d.getElementById('wt-box'),cap=d.getElementById('wt-cap');\n const say=a=>{const x=a&&a.querySelector('.wt-text');cap.replaceChildren(...(x?[...x.childNodes].filter(n=>!(n instanceof Element&&n.classList.contains('wt-state'))).map(n=>n.cloneNode(true)):[]));cap.hidden=!x};\n const steps=[...d.querySelectorAll('.wt-step[data-t]')];\n const idle=[...d.querySelectorAll('.idle[data-a]')].map(e=>({s:e.closest('.track').dataset.s,a:Number(e.dataset.a),b:Number(e.dataset.b)}));\n const skipB=d.getElementById('wt-skip'),expB=d.getElementById('wt-expand');\n let on=null,skip=!!skipB&&skipB.getAttribute('aria-pressed')==='true',P=null;\n w.classList.add('live');\n const hide=()=>{box.hidden=true};\n const geo=()=>{const vw=v.videoWidth,vh=v.videoHeight,cw=v.clientWidth,ch=v.clientHeight;if(!vw||!vh||!cw||!ch)return null;const s=Math.min(cw/vw,ch/vh);return{x:v.offsetLeft+(cw-vw*s)/2,y:v.offsetTop+(ch-vh*s)/2,w:vw*s,h:vh*s}};\n const put=(e,x,y,bw,bh)=>{e.style.left=x+'px';e.style.top=y+'px';if(bw!==undefined){e.style.width=bw+'px';e.style.height=bh+'px'}};\n const draw=(t,g)=>{if(P.down()!==null||!g||!on||!on.dataset.box||t<Number(on.dataset.b0)||t>Number(on.dataset.b1))return hide();const b=on.dataset.box.split(' ').map(Number);put(box,g.x+b[0]*g.w,g.y+b[1]*g.h,b[2]*g.w,b[3]*g.h);box.querySelector('span').textContent=on.dataset.label||'';box.hidden=false};\n const C=d.getElementById('wt-cursor'),R=d.getElementById('wt-ripple'),G=d.getElementById('wt-ring'),L=d.getElementById('wt-act'),T=d.getElementById('wt-cursor-on'),ck='screw-bugs-cursor';\n const nums=x=>x?x.split(' ').map(Number):null;\n const acts=[...d.querySelectorAll('.wt-step[data-act][data-s]')].map(e=>({s:e.dataset.s,at:e.dataset.at?Number(e.dataset.at):NaN,t0:Number(e.dataset.t),t1:Number(e.dataset.a1),b0:Number(e.dataset.b0),b1:Number(e.dataset.b1),k:e.dataset.act,p:nums(e.dataset.pt),b:nums(e.dataset.tb),l:e.dataset.al||''})).sort((a,b)=>(a.at>=0?a.at:a.t0)-(b.at>=0?b.at:b.t0));\n let fon=true;try{fon=localStorage.getItem(ck)!=='off'}catch(e){}\n const fx=(t,g)=>{\n C.hidden=R.hidden=G.hidden=L.hidden=true;box.querySelector('span').hidden=false;\n if(!fon||P.down()!==null||!g)return;\n const m=still(),mine=acts.filter(a=>a.s===P.cur()),ptr=mine.filter(a=>a.p),xy=p=>[g.x+p[0]*g.w,g.y+p[1]*g.h];\n let i=-1;ptr.forEach((a,j)=>{if(a.at<=t)i=j});\n const a=ptr[i],n=ptr[i+1];let c=a?a.p:null;\n if(n&&a){const gw=Math.min(0.6,n.at-a.at),q=gw>0?(t-n.at+gw)/gw:1;if(q>=0){const e=q<.5?4*q*q*q:1-Math.pow(2-2*q,3)/2;c=!m&&q<1?[a.p[0]+(n.p[0]-a.p[0])*e,a.p[1]+(n.p[1]-a.p[1])*e]:n.p}}\n if(c){const xy0=xy(c);put(C,xy0[0]-3,xy0[1]-2);C.hidden=false}\n if(a&&!m&&t-a.at<.6){const q=(t-a.at)/.6,xy1=xy(a.p);put(R,xy1[0],xy1[1]);R.style.transform='translate(-50%,-50%) scale('+(.35+q*1.3)+')';R.style.opacity=String(1-q);R.hidden=false}\n let f=null,l=null,u=null;\n for(const x of mine){if(x.k==='fill'&&x.b&&t>=x.b0&&t<=x.b1)f=x;if(x.k==='fill'||!(x.at>=0)?t>=x.t0&&t<=x.t1:t>=x.at&&t<=x.at+1.5)l=x;else if(!u&&x.p&&x.at>t&&x.at-t<=0.6)u=x}\n l=l||u;\n if(f){const xy2=xy(f.b);put(G,xy2[0],xy2[1],f.b[2]*g.w,f.b[3]*g.h);G.hidden=false;box.hidden=true}\n if(l&&l.l){L.textContent=l.l;L.hidden=false;let x=g.x+10,y=g.y+10;if(l.p){const q=xy(l.p);x=q[0]+14;y=q[1]+20}else if(l.b){const q=xy(l.b);x=q[0];y=q[1]+l.b[3]*g.h+10}if(y+L.offsetHeight>g.y+g.h-4)y=l.b?g.y+l.b[1]*g.h-L.offsetHeight-10:g.y+g.h-L.offsetHeight-4;put(L,Math.max(g.x+4,Math.min(x,g.x+g.w-L.offsetWidth-4)),Math.max(g.y+4,y))}\n box.querySelector('span').hidden=!L.hidden;\n };\n const stage=d.querySelector('.wt-stage');\n const cover=()=>{let y=topEdge();if(stage&&getComputedStyle(stage).position==='sticky')y=Math.max(y,stage.getBoundingClientRect().bottom+16);return y};\n const anchor=a=>{const hid=Math.max(0,cover()-panel.getBoundingClientRect().top);panel.scrollTo({top:Math.max(0,a.offsetTop-6-hid),behavior:still()?'auto':'smooth'})};\n const tick=t=>{\n const cur=P.cur();\n if(skip&&!v.paused&&!v.seeking){const gap=idle.find(x=>x.s===cur&&t>=x.a&&t<x.b-0.05);if(gap){v.currentTime=gap.b;return}}\n let a=null;for(const s of steps){if(s.dataset.s===cur&&Number(s.dataset.t)<=t+0.02)a=s}\n if(a!==on){if(on){on.classList.remove('on');on.removeAttribute('aria-current');on.closest('.wt-case').classList.remove('on')}on=a;say(a);if(a){a.classList.add('on');a.setAttribute('aria-current','step');a.closest('.wt-case').classList.add('on');anchor(a)}}\n const g=geo();draw(t,g);fx(t,g);\n };\n P=player('wt',{tick,full:w,expand:true,inPage:()=>matchMedia('(min-width: 901px)').matches,broken:()=>{hide();fx(0,null);w.classList.remove('live')},fine:()=>{w.classList.add('live')}});\n if(T&&acts.length){T.checked=fon;T.closest('label').hidden=false;T.addEventListener('change',()=>{fon=T.checked;try{localStorage.setItem(ck,fon?'on':'off')}catch(e){}P.update()})}\n if(skipB)skipB.addEventListener('click',()=>{skip=!skip;skipB.setAttribute('aria-pressed',String(skip))});\n if(expB)expB.addEventListener('click',()=>{const x=w.classList.toggle('expanded');expB.setAttribute('aria-expanded',String(x));expB.querySelector('span').textContent=x?'Collapse':'Expand';P.update();if(on)anchor(on)});\n d.addEventListener('click',e=>{\n const t=e.target;if(!(t instanceof Element))return;\n const a=t.closest('a[data-t][data-s],.wt-step[data-t][data-s]');if(!a||!P.has(a.dataset.s))return;\n e.preventDefault();const fig=v.closest('.player');\n if(fig.getBoundingClientRect().bottom<topEdge())fig.scrollIntoView({block:'start',behavior:still()?'auto':'smooth'});\n P.load(a.dataset.s,Number(a.dataset.t),P.playing());\n });\n P.update();\n});\n})();";
|
|
44
44
|
/**
|
|
45
45
|
* As the report's: the video by relative path, one script by hash, and from the network only
|
|
46
46
|
* Google Fonts' stylesheet and its fonts.
|
|
@@ -83,6 +83,7 @@ export declare const stepAction: (action: StepAction | undefined) => {
|
|
|
83
83
|
* one inline script, and from the network only Geist and Geist Mono from Google Fonts (system
|
|
84
84
|
* fonts offline). The video loads by relative path, or under `options.assetBaseUrl` (see
|
|
85
85
|
* `RenderOptions`); with no options the page is exactly the local one. Code decides everything
|
|
86
|
-
* on it
|
|
86
|
+
* on it, except that a case the agent's findings mark failed shows as failed, with the agent's
|
|
87
|
+
* verdict labelled as its own; nothing else from the write-up is shown. Every piece of text from the job or the page is escaped.
|
|
87
88
|
*/
|
|
88
89
|
export declare const renderWalkthrough: (bundle: ReportBundle, options?: RenderOptions) => string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { clampBox } from '../core/index.js';
|
|
2
2
|
import { runFiles, } from '../schema/index.js';
|
|
3
3
|
import { favicon, generatorMeta, html, icon, Markup, promptBlock, safeRelative, statusIcon, statusTag, textParts, webFonts, } from './markup.js';
|
|
4
|
-
import { controlsBlock, PLAYER_JS, playableSessions, playerWindow, shapeStyle, share, toggleButton, } from './player.js';
|
|
4
|
+
import { controlsBlock, PLAYER_JS, playableSessions, playerWindow, shapeStyle, share, toggleButton, videoFixPrompt, } from './player.js';
|
|
5
5
|
import { assetsOf, contentPolicy } from './assets.js';
|
|
6
6
|
import { topBar } from './menu-bar.js';
|
|
7
7
|
import { cspHash } from './sha256.js';
|
|
8
8
|
import { styles } from './styles.js';
|
|
9
|
-
import { caseViews, formatTimecode, fragmentSeconds, idleStretches, stepParts, stepText, statusLabel, urlAt, urlTimeline, } from './view.js';
|
|
9
|
+
import { caseViews, checksNote, formatTimecode, fragmentSeconds, idleStretches, stepParts, stepText, statusLabel, urlAt, urlTimeline, } from './view.js';
|
|
10
10
|
/*
|
|
11
11
|
* The walkthrough: one player for the run's video, and under it (beside it, for a run on a phone)
|
|
12
12
|
* the script: every step of every case in run order with its timecode. The step playing now is the
|
|
@@ -431,8 +431,16 @@ export const stepAction = (action) => {
|
|
|
431
431
|
};
|
|
432
432
|
const stepLabel = (step) => (step.index === 0 ? 'Opening page' : `Step ${step.index}`);
|
|
433
433
|
const notRun = { 'not-run': 'not run', unknown: '', done: '', decided: '' };
|
|
434
|
-
|
|
435
|
-
|
|
434
|
+
/** Why the code gave a case its status (`status`: the code's, not one the agent gave). */
|
|
435
|
+
const why = (entry, status, extraClass = '') => html `<p class="${`wt-why s-${status}${extraClass}`}">
|
|
436
|
+
${statusTag(status)}<span>${entry.reason}</span>
|
|
437
|
+
</p>`;
|
|
438
|
+
/** The agent's verdict on a case its findings mark failed, beside the code's result. */
|
|
439
|
+
const agentWhy = (view) => html `<p class="wt-why s-failed wt-case-why">
|
|
440
|
+
${statusTag('failed')}<span
|
|
441
|
+
>Agent's verdict: ${view.agentFailed ?? ''}
|
|
442
|
+
<span class="wt-checked">(${checksNote(view.checkStatus)})</span></span
|
|
443
|
+
>
|
|
436
444
|
</p>`;
|
|
437
445
|
/**
|
|
438
446
|
* The input a step gives the page, as an icon by its words in the fullscreen caption: a left
|
|
@@ -461,7 +469,7 @@ const stepRow = (view, step, sessions) => {
|
|
|
461
469
|
const decided = step.state === 'decided';
|
|
462
470
|
const kind = stepIcon[step.step.action];
|
|
463
471
|
return html `<li
|
|
464
|
-
class="wt-step st-${step.state}${decided ? ` s-${
|
|
472
|
+
class="wt-step st-${step.state}${decided ? ` s-${view.checkStatus}` : ''}"
|
|
465
473
|
id="${`wt-${entry.id}-${step.index}`}"
|
|
466
474
|
${timed ? html ` data-s="${String(session)}" data-t="${fragmentSeconds(ms)}"` : ''}
|
|
467
475
|
${box
|
|
@@ -480,7 +488,7 @@ const stepRow = (view, step, sessions) => {
|
|
|
480
488
|
? html ` <span class="wt-state">(added: every case starts at the job URL)</span>`
|
|
481
489
|
: ''}${notRun[step.state] ? html ` <span class="wt-state">(${notRun[step.state]})</span>` : ''}</span
|
|
482
490
|
>
|
|
483
|
-
${decided && entry.reason ? why(entry) : ''}
|
|
491
|
+
${decided && entry.reason ? why(entry, view.checkStatus) : ''}
|
|
484
492
|
</li>`;
|
|
485
493
|
};
|
|
486
494
|
/** Steps that only check the page, left out of the walkthrough's script, even one that decided its case. */
|
|
@@ -514,7 +522,7 @@ const caseBlock = (view, position, sessions) => {
|
|
|
514
522
|
>${statusLabel[entry.status]}</span
|
|
515
523
|
>
|
|
516
524
|
</div>
|
|
517
|
-
${timedButNoVideo}${entry.reason && !decidedShown ? why(entry, ' wt-case-why') : ''}
|
|
525
|
+
${timedButNoVideo}${view.agentFailed !== undefined ? agentWhy(view) : ''}${entry.reason && !decidedShown ? why(entry, view.checkStatus, ' wt-case-why') : ''}
|
|
518
526
|
${steps.length > 0
|
|
519
527
|
? html `<ol class="wt-steps">
|
|
520
528
|
${steps.map((step) => stepRow(view, step, sessions))}
|
|
@@ -541,7 +549,11 @@ const problemsBlock = (views, sessions) => {
|
|
|
541
549
|
>`;
|
|
542
550
|
return html `<li class="s-${entry.status}">
|
|
543
551
|
${at}${statusTag(entry.status)}<span class="why"
|
|
544
|
-
><a href="${`#wt-${entry.id}`}">${entry.title}</a>${
|
|
552
|
+
><a href="${`#wt-${entry.id}`}">${entry.title}</a>${view.agentFailed !== undefined
|
|
553
|
+
? html `: agent's verdict: ${view.agentFailed} (${checksNote(view.checkStatus)})`
|
|
554
|
+
: entry.reason
|
|
555
|
+
? html `: ${entry.reason}`
|
|
556
|
+
: ''}</span
|
|
545
557
|
>
|
|
546
558
|
</li>`;
|
|
547
559
|
})}
|
|
@@ -555,7 +567,8 @@ const expandIcon = html `${icon('chevrons-up-down', { size: 13, className: 'i-ex
|
|
|
555
567
|
* one inline script, and from the network only Geist and Geist Mono from Google Fonts (system
|
|
556
568
|
* fonts offline). The video loads by relative path, or under `options.assetBaseUrl` (see
|
|
557
569
|
* `RenderOptions`); with no options the page is exactly the local one. Code decides everything
|
|
558
|
-
* on it
|
|
570
|
+
* on it, except that a case the agent's findings mark failed shows as failed, with the agent's
|
|
571
|
+
* verdict labelled as its own; nothing else from the write-up is shown. Every piece of text from the job or the page is escaped.
|
|
559
572
|
*/
|
|
560
573
|
export const renderWalkthrough = (bundle, options) => {
|
|
561
574
|
const { spec, ledger } = bundle;
|
|
@@ -606,6 +619,9 @@ export const renderWalkthrough = (bundle, options) => {
|
|
|
606
619
|
overlay,
|
|
607
620
|
below: caption,
|
|
608
621
|
extraClass: 'wt-player',
|
|
622
|
+
...(options?.assetBaseUrl === undefined
|
|
623
|
+
? { fixPrompt: videoFixPrompt(bundle.jobId) }
|
|
624
|
+
: {}),
|
|
609
625
|
})}
|
|
610
626
|
${controlsBlock({
|
|
611
627
|
prefix: 'wt',
|
|
@@ -56,6 +56,7 @@ export declare const CaseFindings: Schema.Struct<{
|
|
|
56
56
|
readonly did: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
57
57
|
readonly worked: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
58
58
|
readonly didnt: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
59
|
+
readonly failed: Schema.optionalKey<Schema.String>;
|
|
59
60
|
readonly highlights: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
60
61
|
readonly shot: Schema.NonEmptyString;
|
|
61
62
|
readonly target: Schema.Struct<{
|
|
@@ -114,6 +115,7 @@ export declare const Findings: Schema.Struct<{
|
|
|
114
115
|
readonly did: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
115
116
|
readonly worked: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
116
117
|
readonly didnt: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
118
|
+
readonly failed: Schema.optionalKey<Schema.String>;
|
|
117
119
|
readonly highlights: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
118
120
|
readonly shot: Schema.NonEmptyString;
|
|
119
121
|
readonly target: Schema.Struct<{
|
package/dist/schema/findings.js
CHANGED
|
@@ -2,8 +2,9 @@ import { Schema } from 'effect';
|
|
|
2
2
|
import { ShortLine as Line, Target } from './job.js';
|
|
3
3
|
/*
|
|
4
4
|
* The agent's write-up of an ended run: fixed, structured slots that the report lays out. Every
|
|
5
|
-
* text is short and plain
|
|
6
|
-
*
|
|
5
|
+
* text is short and plain. The run's code sets each case's status; the only status the write-up
|
|
6
|
+
* can give is `failed`, through a case's `failed` (see `judgedLedger`), never a pass. IDs (cases,
|
|
7
|
+
* screenshots, timecodes) are checked against the run by `checkFindings` in core.
|
|
7
8
|
*/
|
|
8
9
|
/** A list of at most `max` short lines. */
|
|
9
10
|
const Lines = (max, length, description) => Schema.Array(Line(length))
|
|
@@ -43,6 +44,11 @@ export const CaseFindings = Schema.Struct({
|
|
|
43
44
|
did: Schema.optionalKey(Lines(8, 160, 'What the case did, as a user would say it.')),
|
|
44
45
|
worked: Schema.optionalKey(Lines(8, 160, 'What worked.')),
|
|
45
46
|
didnt: Schema.optionalKey(Lines(8, 160, "What didn't work.")),
|
|
47
|
+
failed: Schema.optionalKey(Line(160, 'Set when your own evidence (the database, logs, the screenshots, the video) shows the ' +
|
|
48
|
+
'case did not do what its success says, even if every check passed: what is wrong, in ' +
|
|
49
|
+
'one line. The case then counts as failed by your review everywhere results are shown. ' +
|
|
50
|
+
'Leave it out when the case did what it should; minor issues go in didnt. It can never ' +
|
|
51
|
+
'make a case pass.').check(Schema.makeFilter((text) => /[\r\n]/.test(text) ? 'Use one line, with no line breaks' : undefined))),
|
|
46
52
|
highlights: Schema.optionalKey(Schema.Array(Highlight)
|
|
47
53
|
.check(Schema.isMaxLength(6, { message: 'Use at most 6 highlights per case' }))
|
|
48
54
|
.annotate({ description: 'Elements to mark on this case’s screenshots. At most 6.' })),
|
package/dist/schema/ledger.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
|
+
import { Findings } from './findings.js';
|
|
2
3
|
import { type JobRecord } from './job.js';
|
|
4
|
+
import { CaseStatus } from './status.js';
|
|
3
5
|
/**
|
|
4
6
|
* `run_status` cuts each listed reason to this many characters. A reason with a hint about where
|
|
5
7
|
* else its text or element is (see `withHint` in core) is kept within it, so the hint shows.
|
|
@@ -889,6 +891,7 @@ export declare const ReportBundle: Schema.Struct<{
|
|
|
889
891
|
readonly did: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
890
892
|
readonly worked: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
891
893
|
readonly didnt: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
894
|
+
readonly failed: Schema.optionalKey<Schema.String>;
|
|
892
895
|
readonly highlights: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
893
896
|
readonly shot: Schema.NonEmptyString;
|
|
894
897
|
readonly target: Schema.Struct<{
|
|
@@ -1020,3 +1023,30 @@ export declare const findingsRevision: (text: string) => string;
|
|
|
1020
1023
|
* the screw-bugs version building it (`generator`); undefined leaves that out.
|
|
1021
1024
|
*/
|
|
1022
1025
|
export declare const reportBundleOf: (job: JobRecord, ledger: CaseLedger, writeUp?: Pick<ReportBundle, 'findings' | 'marks' | 'annotated' | 'elements' | 'urls'>, version?: string) => ReportBundle;
|
|
1026
|
+
/**
|
|
1027
|
+
* The cases the agent's findings mark failed (`CaseFindings.failed`), by case ID, with what is
|
|
1028
|
+
* wrong. Empty without findings.
|
|
1029
|
+
*/
|
|
1030
|
+
export declare const agentFailures: (findings: Findings | undefined) => ReadonlyMap<string, string>;
|
|
1031
|
+
/** A case as results show it: its status there, and what the run's code decided. */
|
|
1032
|
+
export type JudgedCase = CaseEntry & {
|
|
1033
|
+
/** The status the run's code gave it, as `ledger.json` keeps it. */
|
|
1034
|
+
readonly checkStatus: CaseStatus;
|
|
1035
|
+
/** What is wrong, when the agent's findings mark it failed (then `status` is `failed`). */
|
|
1036
|
+
readonly agentFailed?: string;
|
|
1037
|
+
};
|
|
1038
|
+
/**
|
|
1039
|
+
* A case's status as results show it: `failed` when the agent's findings mark it failed, else the
|
|
1040
|
+
* code's. Findings can only turn a case into a failure, never make one pass.
|
|
1041
|
+
*/
|
|
1042
|
+
export declare const judgedCase: (entry: CaseEntry, failures: ReadonlyMap<string, string>) => JudgedCase;
|
|
1043
|
+
/** A ledger whose cases have their statuses as results show them (see `judgedLedger`). */
|
|
1044
|
+
export type JudgedLedger = Omit<CaseLedger, 'cases'> & {
|
|
1045
|
+
readonly cases: ReadonlyArray<JudgedCase>;
|
|
1046
|
+
};
|
|
1047
|
+
/**
|
|
1048
|
+
* The ledger as everything that shows results reads it (reports, replies, the CLI): each case's
|
|
1049
|
+
* status after the agent's findings (`judgedCase`). `ledger.json` and `evidence.json` keep the
|
|
1050
|
+
* code's statuses.
|
|
1051
|
+
*/
|
|
1052
|
+
export declare const judgedLedger: (ledger: CaseLedger, findings: Findings | undefined) => JudgedLedger;
|
package/dist/schema/ledger.js
CHANGED
|
@@ -223,3 +223,27 @@ export const reportBundleOf = (job, ledger, writeUp = {}, version) => ({
|
|
|
223
223
|
...(ledger.browser !== undefined ? { browser: ledger.browser } : {}),
|
|
224
224
|
files: { ledger: runFiles.ledger, html: runFiles.html, evidenceDir: runFiles.evidenceDir },
|
|
225
225
|
});
|
|
226
|
+
/**
|
|
227
|
+
* The cases the agent's findings mark failed (`CaseFindings.failed`), by case ID, with what is
|
|
228
|
+
* wrong. Empty without findings.
|
|
229
|
+
*/
|
|
230
|
+
export const agentFailures = (findings) => new Map((findings?.cases ?? []).flatMap((c) => c.failed !== undefined && c.failed.trim() !== '' ? [[c.id, c.failed.trim()]] : []));
|
|
231
|
+
/**
|
|
232
|
+
* A case's status as results show it: `failed` when the agent's findings mark it failed, else the
|
|
233
|
+
* code's. Findings can only turn a case into a failure, never make one pass.
|
|
234
|
+
*/
|
|
235
|
+
export const judgedCase = (entry, failures) => {
|
|
236
|
+
const agentFailed = failures.get(entry.id);
|
|
237
|
+
return agentFailed === undefined
|
|
238
|
+
? { ...entry, checkStatus: entry.status }
|
|
239
|
+
: { ...entry, status: 'failed', checkStatus: entry.status, agentFailed };
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* The ledger as everything that shows results reads it (reports, replies, the CLI): each case's
|
|
243
|
+
* status after the agent's findings (`judgedCase`). `ledger.json` and `evidence.json` keep the
|
|
244
|
+
* code's statuses.
|
|
245
|
+
*/
|
|
246
|
+
export const judgedLedger = (ledger, findings) => {
|
|
247
|
+
const failures = agentFailures(findings);
|
|
248
|
+
return { ...ledger, cases: ledger.cases.map((entry) => judgedCase(entry, failures)) };
|
|
249
|
+
};
|