@capagents/forgeqe 2.5.1 → 2.6.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.
Files changed (48) hide show
  1. package/HOW_TO_USE.md +91 -2
  2. package/dist/docs-site/docs/index.html +89 -3
  3. package/dist/docs-site/docs/search.js +1 -1
  4. package/dist/docs-site/docs/web-app/index.html +8 -4
  5. package/dist/forgeqe.js +1093 -1074
  6. package/dist/web/assets/{Agent-BMqCDZeZ.js → Agent-u7Ey8Slc.js} +1 -1
  7. package/dist/web/assets/ApiTests-D_PZKUXw.js +10 -0
  8. package/dist/web/assets/Chat-BCwImb3U.js +3 -0
  9. package/dist/web/assets/{Data-BPtl_mUy.js → Data-x_yeOrL3.js} +4 -4
  10. package/dist/web/assets/{Features-DwHyOoJu.js → Features-BQr8SMEU.js} +1 -1
  11. package/dist/web/assets/Jobs-KYn7S4yx.js +3 -0
  12. package/dist/web/assets/Quality-BY4sCSwU.js +1 -0
  13. package/dist/web/assets/Record-yZT93LmM.js +2 -0
  14. package/dist/web/assets/Regression-BMzfuhsG.js +5 -0
  15. package/dist/web/assets/{Reports-Bapldq1A.js → Reports-D_L3pa9R.js} +2 -2
  16. package/dist/web/assets/Response-DeCMeFqw.js +4 -0
  17. package/dist/web/assets/Runs-ShLZeGq3.js +2 -0
  18. package/dist/web/assets/Shell-B8HJCZ4f.js +3 -0
  19. package/dist/web/assets/arrow-down-B8XP1MaD.js +1 -0
  20. package/dist/web/assets/capgemini-white-ByjwPW8N.svg +21 -0
  21. package/dist/web/assets/{circle-dashed-C84s5T0C.js → circle-dashed-ByDXyh2H.js} +1 -1
  22. package/dist/web/assets/index-Ct2Md_DL.js +26 -0
  23. package/dist/web/assets/index-DtP9ditr.css +2 -0
  24. package/dist/web/assets/{markdown-BtqKvAEi.js → markdown-BQVf95TM.js} +7 -7
  25. package/dist/web/assets/{sticky-note-C_NJNONZ.js → sticky-note-Cx1bYZ3E.js} +1 -1
  26. package/dist/web/assets/thread-CIhAcfY-.js +5 -0
  27. package/dist/web/assets/{trending-up-DK1wDqic.js → trending-up-Dg2FfbKu.js} +1 -1
  28. package/dist/web/assets/usePageChat-PSLtKusy.js +1 -0
  29. package/dist/web/index.html +3 -3
  30. package/docs/WEB_APP.md +9 -4
  31. package/docs/user-guide.html +89 -3
  32. package/package.json +1 -1
  33. package/py/forgeqe_engine/cli.py +16 -0
  34. package/py/forgeqe_engine/recordsession.py +180 -7
  35. package/py/forgeqe_engine/suggest.py +79 -0
  36. package/py/forgeqe_engine/webrecord.py +19 -0
  37. package/py/forgeqe_engine/webrecord_page.py +11 -3
  38. package/dist/web/assets/ApiTests-CkxIx6sI.js +0 -2
  39. package/dist/web/assets/Chat-BT6yGqKW.js +0 -3
  40. package/dist/web/assets/Jobs-DW2uXMkv.js +0 -3
  41. package/dist/web/assets/Quality-BeuhtzZi.js +0 -1
  42. package/dist/web/assets/Record-EHgUTspl.js +0 -1
  43. package/dist/web/assets/Regression-BDq3BUP_.js +0 -2
  44. package/dist/web/assets/Response-Dh_kxnCt.js +0 -8
  45. package/dist/web/assets/Runs-BOi2fP0o.js +0 -2
  46. package/dist/web/assets/frame-z3iL_6aL.js +0 -3
  47. package/dist/web/assets/index-BVw2ygO2.js +0 -26
  48. package/dist/web/assets/index-CBa29-yG.css +0 -2
@@ -1 +1 @@
1
- import{ar as e}from"./frame-z3iL_6aL.js";var t={name:`sticky-note`,size:24,node:[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]};t.node;var n=e(t);export{n as t};
1
+ import{ar as e}from"./Shell-B8HJCZ4f.js";var t={name:`sticky-note`,size:24,node:[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]};t.node;var n=e(t);export{n as t};
@@ -0,0 +1,5 @@
1
+ import{ht as e}from"./Shell-B8HJCZ4f.js";var t=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:{},n=e=>typeof e==`string`?e:e==null?``:String(e),r=(e,t=400)=>e.length>t?`${e.slice(0,t-1)}…`:e,i=e=>typeof e==`number`?` in ${Math.round(e/1e3)}s`:``;function a(e,t=400){return r(e.replace(/\s+/g,` `).trim(),t).replace(/([\\`*_[\]<>#|~!])/g,`\\$1`)}function o(e){let t=e.replace(/\s+/g,` `).trim();if(!t)return``;let n=t.includes("`")?"``":"`";return`${n}${n==="``"?` `:``}${t}${n==="``"?` `:``}${n}`}function s(e,t){return/^https?:\/\/[^\s)]+$/i.test(t)?`[${a(e||t,120)}](${t})`:a(e)}var c=e=>[o(n(t(e).id)),a(n(t(e).title),200)].filter(Boolean).join(` `);function l(e){return e.replace(/<!--[\s\S]*?(?:-->|$)/g,``).trim()}function u(e){return e.replace(/\[((?:\\.|[^\]\\])*)\]\(https?:\/\/[^\s)]+\)/g,`$1`).replace(/\\(.)/g,`$1`).replace(/[*`]/g,``)}var d=(e,t)=>({tone:e,kind:`item`,md:t}),f=(e,t)=>({tone:e,kind:`sub`,md:t});function p(e,r=``){let i=r||(e.agent&&e.agent!==`forgeqe`?`**${a(n(e.agent))}:** `:``);switch(e.kind){case`info`:return d(`info`,`${i}${a(n(e.text))}`);case`start`:return d(`dim`,`${i}→ ${o(n(e.tool))}${e.text&&e.text!==e.tool?` ${a(n(e.text),200)}`:``}`);case`tool`:{let r=t(e.file);return d(e.ok===!1?`warn`:`dim`,`${i}${e.ok===!1?`⚠`:`✓`} ${a(n(e.text)||n(e.tool),240)}${r.path?` (${a(n(r.action))} ${o(n(r.path))})`:``}`)}case`say`:{let t=l(n(e.text));return t?d(`say`,`${i}*${a(t)}*`):null}case`test`:return Number(e.attempt)>0?d(e.ok?`ok`:`fail`,`${i}${e.ok?`✓`:`✗`} **Test, attempt ${a(n(e.attempt))}:** ${a(n(e.text),240)}`):d(e.ok?`ok`:`fail`,`${i}${e.ok?`✓`:`✗`} ${a(n(e.text),240)}`);case`plan`:{let r=Array.isArray(e.items)?e.items.map(t):[],o=r.find(e=>e.status===`in_progress`);return d(`info`,`${i}**Plan:** ${r.filter(e=>e.status===`completed`).length} of ${r.length} done${o?`; now: ${a(n(o.text))}`:``}`)}case`review`:return d(e.approved?`ok`:`warn`,`${i}**Review, attempt ${a(n(e.attempt))}:** ${e.approved?`approved`:`changes asked`}. ${a(n(e.summary),240)}`);case`attempt`:return d(`warn`,`${i}**Attempt ${a(n(e.attempt))} of ${a(n(e.max))}:** ${a(n(e.why),240)}`);case`answer`:return d(`dim`,`${i}Attempt ${a(n(e.attempt))}: ${a(n(e.notes)||`changed ${(Array.isArray(e.changed)?e.changed:[]).map(n).join(`, `)}`,240)}`);case`context`:return e.compacted?d(`info`,`${i}Context compacted: the conversation was summarised to make room.`):null;default:return null}}function m(e,r=``){switch(e.type){case`log`:return d(e.level===`error`?`fail`:e.level===`warn`?`warn`:`dim`,`${r}${e.level===`warn`||e.level===`error`?`⚠ `:``}${a(n(e.text))}`);case`step`:return d(`dim`,`${r}**Step ${a(n(e.step))}** · ${e.source===`memory`?`from memory`:a(n(e.category))} · ${s(n(e.title)||`untitled`,n(e.url))}`);case`memory`:return d(`info`,`${r}↻ ${a(n(e.text))}`);case`thought`:return f(`think`,`*${a(n(e.text))}*`);case`outcome`:return f(e.ok?`ok`:`fail`,`${e.ok?`✓`:`✗`} ${a(n(e.text),300)}`);case`done`:{let i=t(e.result);return d(i.status===`complete`?`ok`:`fail`,`${r}**${a(n(i.status))}:** ${a(n(i.summary))}`)}case`code`:return p(e,r);default:return null}}function h(e){switch(e.type){case`run-start`:return{tone:`info`,kind:`head`,md:`Browser run: ${a(n(e.goal),200)}${e.url?` · ${s(n(e.url).replace(/^https?:\/\//,``),n(e.url))}`:``}`};case`run-event`:return m(t(e.event));case`run-done`:{let r=t(e.result),s=!e.error&&(r.outcome===`passed`||!r.outcome&&r.status===`complete`);return d(s?`ok`:`fail`,`${s?`✓`:`✗`} **Run ${s?`passed`:`failed`}**${i(e.ms)}: ${a(n(e.error)||n(r.summary))}${e.runDir?` · ${o(n(e.runDir))}`:``}`)}case`suite-start`:return{tone:`info`,kind:`head`,md:`Suite: ${(Array.isArray(e.cases)?e.cases:[]).length} cases, ${a(n(e.parallel))} at once`};case`suite-event`:{let r=t(e.event);if(r.type===`case-start`)return d(`info`,`**Case ${Number(r.index)+1} of ${a(n(r.total))}:** ${c(r.case)}`);if(r.type===`case-event`)return m(t(r.event),`${o(n(t(r.case).id))} `);if(r.type===`case-done`){let e=t(r.result);return d(e.status===`passed`?`ok`:`fail`,`${e.status===`passed`?`✓`:`✗`} ${c(e.case)}: **${a(n(e.status))}**${i(e.ms)}${e.summary?`. ${a(n(e.summary),240)}`:``}`)}return r.type===`code-start`?d(`info`,`${o(n(t(r.case).id))} writing its test`):r.type===`writeback`?d(`dim`,`Posted the result back: ${a(JSON.stringify(r.item),240)}`):null}case`suite-done`:{let n=(Array.isArray(t(e.suite).results)?t(e.suite).results:[]).map(t),r=n.filter(e=>e.status===`passed`).length;return d(r===n.length?`ok`:`fail`,`**Suite: ${r} of ${n.length} passed**${i(t(e.suite).ms)}`)}case`info`:return d(e.ok===!1?`fail`:e.ok===!0?`ok`:`info`,a(n(e.text)));case`agent`:return p(t(t(e.event)),`**Coding agent:** `);case`code-start`:return{tone:`info`,kind:`head`,md:`Writing a test: ${a(n(e.goal),200)}`};case`code-done`:return d(e.error?`fail`:`ok`,`${e.error?`✗`:`✓`} **Test ${e.error?`not written`:`written`}**${i(e.ms)}${e.error?`: ${a(n(e.error),240)}`:``}`);case`card`:{let r=t(e.card),i=(Array.isArray(r.body)?r.body:[]).map(n).filter(Boolean);return d(r.status===`ok`?`ok`:r.status===`fail`?`fail`:`info`,`**${a(n(r.title))}**${r.stats?` · ${a(n(r.stats))}`:``}${i.length?`: ${a(i.join(`; `),300)}`:``}`)}case`report`:return d(`ok`,`✓ Report saved: ${a(n(e.title))}`);case`call-start`:return d(`dim`,`→ ${a(n(e.text),240)}`);case`call`:return d(e.ok===!1?`warn`:`dim`,`${e.ok===!1?`⚠`:`✓`} ${a(n(e.text),240)}`);default:return null}}function g(e){let r=n(e.at)||n(e.t),i=null;switch(e.type){case`user`:i=d(`you`,`**You:** ${a(n(e.text),240)}`);break;case`agent`:i=p(t(e.event));break;case`tool`:i=h(t(e.event));break;case`ask`:i=d(`you`,`**Asked:** ${a(n(t(e.question).title))}`);break;case`wait`:i=d(`you`,`**Waiting for you:** ${a(n(e.prompt))}`);break;case`answered`:i=d(`you`,`**You:** ${e.label===void 0?e.ok?`done, continue`:`cancel`:a(n(e.label))}`);break;case`turn_done`:i=d(e.outcome===`done`?`ok`:e.outcome===`stopped`?`warn`:`fail`,`**${e.outcome===`done`?`Done`:e.outcome===`stopped`?`Stopped`:e.outcome===`needs_input`?`Needs your input`:`Failed`}**${e.error?`: ${a(n(e.error),300)}`:``}`);break;case`settings`:i=d(`you`,`**Settings:** browser ${e.headed?`shown`:`headless`}, ${e.writeTests?`passed runs become tests`:`no tests written`}`);break;case`stderr`:i={tone:`dim`,kind:`out`,md:n(e.text)};break;case`error`:i=d(`warn`,`⚠ ${a(n(e.message))}`);break;case`fatal`:i=d(`fail`,`✗ **ForgeQE cannot go on:** ${a(n(e.message))}`);break;case`exit`:i=d(e.code===0?`dim`:`fail`,`ForgeQE stopped${e.code!==null&&e.code!==void 0?` (exit ${a(n(e.code))})`:``}${e.message?`: ${a(n(e.message))}`:``}`)}return i?{at:r,...i,plain:i.kind===`out`?i.md:u(i.md)}:null}function _(e,t){let n=e?Math.max(0,Math.round((Date.parse(t)-Date.parse(e))/1e3)):0;return Number.isFinite(n)?`+${Math.floor(n/60)}:${String(n%60).padStart(2,`0`)}`:``}function v(e,t,n){let r=n?[`## ${a(n,200)}`,``]:[],i=[],o=()=>{if(!i.length)return;let e=Math.max(2,...i.map(e=>Math.max(0,...(e.match(/`+/g)||[]).map(e=>e.length)))),t="`".repeat(e+1);r.push(``,`${t}text`,...i,t,``),i=[]};for(let n of e){let e=`\`${_(t,n.at)}\``;n.kind===`out`?i.push(`${_(t,n.at)} ${n.md}`):(o(),n.kind===`head`?r.push(``,`#### ${n.md} ${e}`,``):n.kind===`sub`?r.push(` - ${n.md}`):r.push(`- ${e} ${n.md}`))}return o(),r.join(`
2
+ `).replace(/\n{3,}/g,`
3
+
4
+ `).trim()+`
5
+ `}var y=e=>{let t=b(e);return typeof t.input==`number`&&typeof t.output==`number`?{input:t.input,output:t.output,cached:typeof t.cached==`number`?t.cached:void 0}:void 0},b=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:{},x=e=>typeof e==`string`?e:e==null?``:String(e),S=[[/find_test_cases|story_test_cases|check_test_cases|list_sprints/,`Finding test cases`,`searching`],[/environment|logins/,`Preparing the environment`,`handing`],[/run_test_cases|browser_run|suite|run_goal|run_direct/,`Running in the browser`,`browsing`],[/comment_on_pr/,`Commenting on the pull request`,`working`],[/write_back|post_result|post_results|file_bugs|create_bugs/,`Posting the result`,`working`],[/write_test|heal/,`Writing the test`,`writing`],[/run_tests|bash|shell/,`Running the tests`,`working`],[/read_confluence|read|grep|glob|list|webfetch/,`Reading`,`reading`],[/edit|write|patch/,`Changing the code`,`writing`],[/task/,`Handing work to another agent`,`handing`]],C=/run_test_cases|browser_run|run_suite|write_test/,w=[[/find_test_cases|story_test_cases|check_test_cases/,`forgeqe-find`],[/run_test_cases|browser_run|run_goal|run_direct|suite|explore_run/,`engine`],[/write_test/,`forgeqe-test`],[/heal/,`forgeqe-heal`],[/review_pr|pr_review/,`forgeqe-pr-review`],[/api_plan/,`forgeqe-api-plan`],[/write_api|api_test/,`forgeqe-api`],[/explore_plan|plan_charters/,`forgeqe-explore-plan`],[/defect_rca|root_cause/,`forgeqe-defect-rca`],[/insights|forgeqe_bi|defect_intelligence/,`forgeqe-bi`],[/refine/,`forgeqe-refine`]];function T(e){let t=e.toLowerCase();if(!O(t))return w.find(([e])=>e.test(t))?.[1]}var E=[[/^(azure_devops|ado|azuredevops)_/,`Azure DevOps`],[/^(jira|atlassian)_/,`Jira`],[/^confluence_/,`Confluence`],[/^github_/,`GitHub`],[/^xray_/,`Xray`],[/^testrail_/,`TestRail`],[/^zephyr_/,`Zephyr Scale`],[/^qtest_/,`qTest`]],D=/(^|_)(create|update|add|delete|remove|post|comment|link|unlink|upload|set|assign|transition|edit|merge|close|reopen|queue|trigger|run|push|move|copy|import|write|publish|approve|vote|lock|unlock)(_|$)/;function O(e){let t=e.toLowerCase();if(!t.startsWith(`forgeqe_`))return E.find(([e])=>e.test(t))?.[1]}var k=e=>{let t=b(e);return typeof t.diff==`string`&&t.diff?{diff:t.diff,added:Number(t.added)||0,removed:Number(t.removed)||0}:void 0},A=e=>Array.isArray(e)?e.map(x).filter(Boolean):[];function j(e,t,n){let r=x(e.status)||(t?`failed`:``);return{status:r,ok:!t&&/^(passed|pass|written|ok|known_defect)$/i.test(r),...x(e.testFile)?{testFile:x(e.testFile)}:{},...x(e.testName)?{testName:x(e.testName)}:{},...x(e.command)?{command:x(e.command)}:{},...typeof e.attempts==`number`?{attempts:e.attempts}:{},...typeof e.maxAttempts==`number`?{maxAttempts:e.maxAttempts}:{},changed:A(e.changed),reused:A(e.reused),...n?{runDir:n}:{},...t?{error:t}:{},...x(e.notes)?{notes:x(e.notes)}:{}}}function M(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=b(n),r=(typeof n==`string`?n:x(e.label)||x(e.request)).replace(/\s+/g,` `).trim(),i=(typeof n==`string`?n:x(e.request)||x(e.label)).trim();r&&i&&!t.some(e=>e.label.toLowerCase()===r.toLowerCase())&&t.push({label:r.length>60?`${r.slice(0,59)}…`:r,request:i})}return t.slice(0,4)}function N(e){let t=e.toLowerCase(),n=O(t);if(n)return D.test(t.replace(/^[a-z]+_/,``))?{label:`Updating ${n}`,orb:`working`}:{label:`Reading ${n}`,orb:`reading`};for(let[e,n,r]of S)if(e.test(t))return{label:n,orb:r};let r=t.replace(/^forgeqe_/,``).replace(/[_-]+/g,` `).trim();return{label:r?r[0].toUpperCase()+r.slice(1):`Working`,orb:`working`}}function P(e,t){return{id:e,user:t,steps:[],parts:[],next:[],asks:[],waits:[],log:[],plan:[],changes:[],tests:[],reports:[]}}function F(e){let t=b(e);return[x(t.id),x(t.title)].filter(Boolean).join(`: `)}function I(t){let n={turns:[],notes:[]},r=new Map,i=e=>(typeof e==`string`?r.get(e):void 0)??n.turns.at(-1),a=(e,t)=>{let n=e=>{for(let r of e){if(r.key===t)return r;let e=r.children&&n(r.children);if(e)return e}};return n(e.steps)},o=(e,t,n)=>{let r={lines:[],...t};if(n)n.push(r);else{let t=e.plan.find(e=>e.status===`active`)??e.plan.find(e=>e.status===`pending`)??e.plan.at(-1);t&&(r.phase=t.text),e.steps.push(r)}return r},s=(t,n,r)=>{let i=n.parent?a(t,`c:${x(n.parent)}`):void 0;if(i)return i.children??=[];let s=x(n.agent);if(!r||!s||s===`forgeqe`)return;let c=[...t.steps].reverse().find(e=>e.status===`running`);return c||=o(t,{key:`ag:${s}:${t.steps.length}`,label:e(s).name,status:`running`,orb:`handing`,agent:s}),c.agent??=s,c.children??=[]},c=(t,r,i)=>{let c=x(r.kind),l=x(r.id);if((c===`start`||c===`tool`)&&C.test(x(r.tool))&&!O(x(r.tool)))return;let u=s(t,r,i),d=b(r.delegate),f=x(d.agent)?{agent:x(d.agent),task:x(d.task)}:void 0;if(c===`start`){if(f)o(t,{key:`c:${l}`,label:`Hands off to the ${e(f.agent).name}`,arg:f.task||void 0,status:`running`,orb:`handing`,agent:f.agent,handoff:f,children:[]},u);else{let{label:e,orb:n}=N(x(r.tool)||x(r.text)),i=u?void 0:T(x(r.tool));o(t,{key:`c:${l}`,label:e,arg:x(r.text)&&x(r.text)!==x(r.tool)?x(r.text):void 0,status:`running`,orb:n,...i?{agent:i}:{}},u)}}else if(c===`tool`){let n=l?a(t,`c:${l}`):void 0,i=b(r.file),s=k(r.change);if(s&&x(i.path)){let e=t.changes.find(e=>e.path===x(i.path));e?Object.assign(e,{diff:`${e.diff}\n${s.diff}`,added:e.added+s.added,removed:e.removed+s.removed}):t.changes.push({path:x(i.path),...s,...x(r.agent)?{agent:x(r.agent)}:{}})}if(n)n.status=r.ok===!1?`fail`:`ok`,n.handoff&&x(d.result)&&(n.handoff.result=x(d.result));else if(f)o(t,{key:`c:${l||t.steps.length}`,label:`Hands off to the ${e(f.agent).name}`,arg:f.task||void 0,status:r.ok===!1?`fail`:`ok`,orb:`handing`,agent:f.agent,handoff:{...f,...x(d.result)?{result:x(d.result)}:{}},children:[]},u);else{let{label:e,orb:n}=N(x(r.tool)||x(r.text)),a=u?void 0:T(x(r.tool));o(t,{key:`c:${l||t.steps.length}`,label:e,arg:x(i.path)||x(r.text)||void 0,status:r.ok===!1?`fail`:`ok`,orb:n,...a?{agent:a}:{},...s?{change:s}:{}},u)}n&&s&&(n.change=s)}else if(c===`stream`||c===`say`){if(i)return;let e=t.parts.find(e=>e.id===l);e?e.text=c===`say`?x(r.text):e.text+x(r.text):t.parts.push({id:l||`p${t.parts.length}`,text:x(r.text)})}else if(c===`plan`){if(u||r.agent&&r.agent!==`forgeqe`)return;let e=Array.isArray(r.items)?r.items.map(b):[],n=e=>e===`completed`?`done`:e===`in_progress`?`active`:e===`cancelled`?`skipped`:`pending`;t.plan=e.map(e=>({text:x(e.text),status:n(e.status)})).filter(e=>e.text)}else if(c===`test`){let e=Number(r.attempt)||0;if(e>0)o(t,{key:`t:${t.steps.length}`,label:`Test, attempt ${e}`,arg:x(r.text),status:r.ok?`ok`:`fail`,orb:`retrying`},u);else if(r.ok&&/\bconnected$/i.test(x(r.text)))return;else o(t,{key:`t:${t.steps.length}`,label:x(r.text)||(r.ok?`Checked`:`Check failed`),status:r.ok?`ok`:`fail`,orb:/connect|mcp/i.test(x(r.text))?`waiting`:`working`},u)}else if(c===`review`)o(t,{key:`r:${t.steps.length}`,label:r.approved?`Review approved`:`Review asked for changes`,status:r.approved?`ok`:`info`,orb:`thinking`,agent:`forgeqe-review`,lines:[{text:x(r.summary)}]});else if((c===`context`||c===`usage`)&&!i)c===`context`&&typeof r.tokens==`number`&&typeof r.limit==`number`&&(n.context={tokens:r.tokens,limit:r.limit,compactsAt:typeof r.compactsAt==`number`?r.compactsAt:void 0}),c===`usage`&&(n.usage=y(r.usage)??n.usage);else if(c===`info`){let e=(u??t.steps).at(-1);e&&e.lines.push({text:x(r.text)})}},l,u=(e,t)=>{let n=x(t.type);if(n===`run-start`)o(e,{key:`run:${e.steps.length}`,label:`Running in the browser`,arg:x(t.goal),status:`running`,orb:`browsing`,agent:`engine`});else if(n===`run-event`){let n=[...e.steps].reverse().find(e=>e.key.startsWith(`run:`)),r=b(t.event);if(!n)return;r.type===`outcome`?n.lines.push({text:`Step ${x(r.step)}: ${x(r.action)||x(r.text)}`,ok:r.ok===!0||r.ok!==!1&&void 0}):r.type===`log`&&(r.level!==`info`||r.progress)&&n.lines.push({text:x(r.text),ok:r.level!==`error`&&void 0})}else if(n===`run-done`){let n=[...e.steps].reverse().find(e=>e.key.startsWith(`run:`)&&e.status===`running`),r=b(t.result),i=!t.error&&(r.outcome===`passed`||!r.outcome&&r.status===`complete`);if(n){n.status=i?`ok`:`fail`;let e=x(t.error)||x(r.summary);e&&n.lines.push({text:e,ok:!!i})}x(t.runDir)&&e.reports.push({label:i?`Browser run report`:`Browser run report (failed)`,path:x(t.runDir)})}else if(n===`suite-start`){let n=Array.isArray(t.cases)?t.cases:[];o(e,{key:`suite:${e.steps.length}`,label:`Running ${n.length} test case${n.length===1?``:`s`}`,status:`running`,orb:`working`,agent:`engine`})}else if(n===`suite-event`){let n=[...e.steps].reverse().find(e=>e.key.startsWith(`suite:`)),r=b(t.event);if(n&&r.type===`case-done`){let e=b(r.result);n.lines.push({text:`${F(e.case)}: ${x(e.status)}`,ok:e.status===`passed`})}}else if(n===`suite-done`){let n=[...e.steps].reverse().find(e=>e.key.startsWith(`suite:`)),r=Array.isArray(b(t.suite).results)?b(t.suite).results.map(b):[];if(n){let e=r.filter(e=>e.status!==`passed`).length;n.status=e?`fail`:`ok`,n.arg=`${r.length-e} of ${r.length} passed`}}else if(n===`card`){let n=b(t.card);o(e,{key:`card:${e.steps.length}`,label:x(n.title),arg:x(n.stats)||void 0,status:n.status===`ok`?`ok`:n.status===`fail`?`fail`:`info`,orb:`working`,lines:(Array.isArray(n.body)?n.body:[]).map(e=>({text:x(e)}))})}else if(n===`call-start`&&!t.quiet)o(e,{key:`call:${x(t.id)}`,label:x(t.text),status:`running`,orb:`working`});else if(n===`call`&&!t.quiet){let n=t.id?a(e,`call:${x(t.id)}`):void 0;n?n.status=t.ok===!1?`fail`:`ok`:o(e,{key:`call:${e.steps.length}`,label:x(t.text),status:t.ok===!1?`fail`:`ok`,orb:`working`})}else if(n===`code-start`)l=x(t.runDir)||void 0,o(e,{key:`code:${e.steps.length}`,label:`Writing the test`,arg:x(t.goal),status:`running`,orb:`writing`,agent:`forgeqe-test`});else if(n===`code-done`){let n=[...e.steps].reverse().find(e=>e.key.startsWith(`code:`)&&e.status===`running`);n&&(n.status=t.error?`fail`:`ok`,t.error&&n.lines.push({text:x(t.error),ok:!1})),e.tests.push(j(b(t.result),x(t.error),l)),l=void 0}else if(n===`agent`)c(e,b(t.event),!0);else if(n===`info`){let n=e.steps.at(-1);n?n.lines.push({text:x(t.text),ok:t.ok===!0||t.ok!==!1&&void 0}):o(e,{key:`info:${e.steps.length}`,label:x(t.text),status:t.ok===!1?`fail`:`info`,orb:`working`})}else n===`report`&&(o(e,{key:`report:${e.steps.length}`,label:`Report saved`,arg:x(t.title),status:`ok`,orb:`working`}),x(t.html)&&e.reports.push({label:x(t.title)||`Report`,path:x(t.html)}))};for(let e of t){d(e);let t=g(e);t&&(typeof e.id==`string`&&r.get(e.id)||typeof e.turn==`string`&&r.get(e.turn)||n.turns.at(-1))?.log.push(t)}return n;function d(e){switch(e.type){case`user`:{let t=P(x(e.id),x(e.text));n.turns.push(t),r.set(t.id,t);break}case`ready`:{let t=b(e.profile);t.name&&(n.model={name:x(t.name),provider:x(t.provider)}),n.writeTests=e.writeTests!==!1,n.headed=e.headed===!0;break}case`settings`:typeof e.writeTests==`boolean`&&(n.writeTests=e.writeTests),typeof e.headed==`boolean`&&(n.headed=e.headed);break;case`turn_start`:{let t=i(e.id);t&&(t.started=x(e.t)||x(e.at));break}case`agent`:{let t=i(e.id);t&&c(t,b(e.event),!1);break}case`tool`:{let t=i(e.id);t&&u(t,b(e.event));break}case`ask`:{let t=i(e.turn),n=b(e.question);t?.asks.push({id:x(e.id),title:x(n.title),detail:x(n.detail)||void 0,lines:Array.isArray(n.lines)?n.lines.map(x):[],options:(Array.isArray(n.options)?n.options:[]).map(e=>({id:x(b(e).id),label:x(b(e).label)}))});break}case`wait`:i(e.turn)?.waits.push({id:x(e.id),prompt:x(e.prompt)});break;case`answered`:for(let t of n.turns){let n=t.asks.find(t=>t.id===e.ask);n&&(n.answer=x(e.label));let r=t.waits.find(t=>t.id===e.ask);r&&(r.answer=e.ok===!0)}break;case`turn_done`:{let t=i(e.id);if(!t)break;t.outcome=e.outcome,t.reply=x(e.reply),t.next=M(e.next),t.error=x(e.error)||void 0,t.ended=x(e.t)||x(e.at),n.usage=y(e.usage)??n.usage;let r=e=>{for(let n of e)n.status===`running`&&(n.status=t.outcome===`done`?`ok`:`info`),n.children&&r(n.children)};if(r(t.steps),t.outcome===`done`)for(let e of t.plan)e.status===`active`&&(e.status=`done`);break}case`error`:e.code!==`busy`&&n.notes.push(x(e.message));break;case`fatal`:n.fatal=x(e.message);break;case`exit`:n.ended={code:typeof e.code==`number`?e.code:null,stderr:Array.isArray(e.stderr)?e.stderr.map(x):void 0,message:x(e.message)||void 0}}}}function L(e){let t=e.asks.find(e=>e.answer===void 0),n=e.waits.find(e=>e.answer===void 0);if(t||n)return{text:`Waiting for you…`,orb:`waiting`};let r=[...e.steps].reverse().find(e=>e.status===`running`);return r?{text:`${r.label}…`,orb:r.orb}:e.parts.some(e=>e.text.trim())&&e.steps.length?{text:`Writing a reply…`,orb:`writing`}:{text:`Thinking…`,orb:`thinking`}}function R(e){if(!e.started||!e.ended)return`Done`;let t=Math.max(1,Math.round((Date.parse(e.ended)-Date.parse(e.started))/1e3)),n=e.outcome===`stopped`?`Stopped after`:`Worked for`;return t<60?`${n} ${t} second${t===1?``:`s`}`:`${n} ${Math.floor(t/60)} min ${t%60} s`}var z={running:`active`,ok:`done`,fail:`failed`,info:`note`};function B(e,t){let n=e=>e===`active`&&!t?`done`:e;if(!e.plan.length)return e.steps.map(e=>({key:e.key,label:e.label,status:n(z[e.status]),steps:[],step:e}));let r=new Set(e.plan.map(e=>e.text)),i=new Map,a=``;for(let t of e.steps)t.phase&&r.has(t.phase)&&(a=t.phase),i.set(a,[...i.get(a)||[],t]);let o=e=>e.some(e=>e.status===`running`),s=[],c=i.get(``)||[];c.length&&s.push({key:`plan:start`,label:`Getting started`,status:n(o(c)?`active`:`done`),steps:c});let l=e.plan.map((e,n)=>{let r=i.get(e.text)||[],a=e.status===`done`?`done`:e.status===`skipped`?`skipped`:e.status===`active`||o(r)?`active`:`pending`;return{key:`plan:${n}`,label:e.text,status:a===`active`&&!t?`pending`:a,steps:r}});return[...s,...V(l)]}function V(e){let t=e.findIndex(e=>e.status===`active`);return t<0?e:e.map((e,n)=>e.status===`skipped`||e.status===`failed`||n===t?e:{...e,status:n<t?`done`:`pending`})}export{g as a,R as i,I as n,v as o,B as r,l as s,L as t};
@@ -1 +1 @@
1
- import{ar as e}from"./frame-z3iL_6aL.js";var t={name:`trending-down`,size:24,node:[[`path`,{d:`M16 17h6v-6`,key:`t6n2it`}],[`path`,{d:`m22 17-8.5-8.5-5 5L2 7`,key:`x473p`}]]};t.node;var n=e(t),r={name:`trending-up`,size:24,node:[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]};r.node;var i=e(r);export{n,i as t};
1
+ import{ar as e}from"./Shell-B8HJCZ4f.js";var t={name:`trending-down`,size:24,node:[[`path`,{d:`M16 17h6v-6`,key:`t6n2it`}],[`path`,{d:`m22 17-8.5-8.5-5 5L2 7`,key:`x473p`}]]};t.node;var n=e(t),r={name:`trending-up`,size:24,node:[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]};r.node;var i=e(r);export{n,i as t};
@@ -0,0 +1 @@
1
+ import{Fr as e,Mr as t,ar as n,fr as r}from"./Shell-B8HJCZ4f.js";import{n as i}from"./thread-CIhAcfY-.js";var a={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};a.node;var o=n(a),s={name:`message-square-plus`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]};s.node;var c=n(s),l={name:`save`,size:24,node:[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]};l.node;var u=n(l),d=e(t(),1),f=/^<!--[\s\S]*?-->\s*/,p=e=>e&&/^No model in llms\.json/.test(e)?`No model is set up for the agent yet: add one in Settings, Models (or sign in to GitHub Copilot there), then send this again.`:e;function m(e){let t=()=>{try{return localStorage.getItem(e)}catch{return null}},n=t=>{try{t?localStorage.setItem(e,t):localStorage.removeItem(e)}catch{}},[a,o]=(0,d.useState)(t),[s,c]=(0,d.useState)([]),[l,u]=(0,d.useState)(null);(0,d.useEffect)(()=>{if(!a){c([]),u(null);return}let e=!1,t=0;return c([]),(async()=>{for(;!e;)try{let n=await r.events(a,t,t>0);if(e||(u(n.state),n.events.length&&(t=n.events.at(-1).n,c(e=>[...e,...n.events])),(n.state===`closed`||n.state===`failed`)&&!n.events.length))return}catch(t){if(e)return;if(t.status===404){n(null),o(null);return}await new Promise(e=>setTimeout(e,2e3))}})(),()=>{e=!0}},[a]);let f=(0,d.useMemo)(()=>i(s),[s]),p=f.turns.at(-1),m=l===`closed`||l===`failed`;return{chat:a,thread:f,last:p,busy:l===`busy`||l===`starting`||!!p&&!p.outcome&&!m,ended:m,send:async(e,t)=>{if(a&&!m)await r.send(a,e);else{let{id:i}=await r.start(`${t}\n${e}`,{});n(i),o(i)}},reset:()=>{n(null),o(null)}}}export{c as a,u as i,p as n,o,m as r,f as t};
@@ -5,9 +5,9 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <meta name="referrer" content="no-referrer" />
7
7
  <title>ForgeQE</title>
8
- <script type="module" crossorigin src="/assets/index-BVw2ygO2.js"></script>
9
- <link rel="modulepreload" crossorigin href="/assets/frame-z3iL_6aL.js">
10
- <link rel="stylesheet" crossorigin href="/assets/index-CBa29-yG.css">
8
+ <script type="module" crossorigin src="/assets/index-Ct2Md_DL.js"></script>
9
+ <link rel="modulepreload" crossorigin href="/assets/Shell-B8HJCZ4f.js">
10
+ <link rel="stylesheet" crossorigin href="/assets/index-DtP9ditr.css">
11
11
  </head>
12
12
  <body>
13
13
  <div id="root"></div>
package/docs/WEB_APP.md CHANGED
@@ -39,6 +39,11 @@ Settings are locked.
39
39
  4. **A model.** At least one model with its key or sign-in, under **Models**. For a GitHub Copilot seat, sign in here
40
40
  or in Models (below).
41
41
 
42
+ **Dark mode.** Each person chooses for their own browser: **System mode** in the sidebar's footer moves through
43
+ System (as the computer is set), Light and Dark, and Settings › Appearance › **Colour mode** has all three. In dark mode
44
+ the page and the default sidebar go dark, links and the accent are lightened so they read, code is coloured for a dark
45
+ page, and logos drawn in black turn white. A project's own sidebar colour (Appearance) stays the brand's.
46
+
42
47
  **Signing in to GitHub Copilot** (Set up, and Settings › Models › Sign-ins) does what `forgeqe auth login copilot`
43
48
  does. **Sign in with GitHub** runs GitHub's own Copilot CLI sign-in (downloaded the first time): the page shows
44
49
  GitHub's link with **Open GitHub** and the one-time code with **Copy**, and waits while you approve on GitHub; the
@@ -125,10 +130,10 @@ and Ended as filters, a search, and 50 at a time.
125
130
 
126
131
  | Page | What it is for |
127
132
  |---|---|
128
- | **Record** | Do a test's steps yourself in a browser or a Windows app ForgeQE opens; each click, entry and check is recorded. A web recording becomes a test through a chat; a desktop one replays with no model. The recordings, searched and paged. |
129
- | **Regression** | Regression packs for a release: built from test cases, run, and healed, with their results. |
130
- | **API tests** | Contract sets from an API description or the calls a browser run saw; scenarios that chain calls. Run them (calls that change data only after you agree), see each call's result, write them as tests. |
131
- | **Quality** | What each browser run measured: accessibility (WCAG), Core Web Vitals, and visual changes against approved baselines, with **Approve as the new baseline**; and each page's trend. |
133
+ | **Record** | Do a test's steps yourself in a browser or a Windows app ForgeQE opens; each click, entry and choice is recorded, with nothing to describe first: no panel in the page, only a small badge, with Pause, Undo and Stop on the Record page. A web recording is then reviewed with clicks: its name (written from what you did), steps to drop or add (in your words, a page to open, go back), notes on steps, instructions for the Coding agent, checks suggested from what each step brought to the page or picked on its picture (a text, a field's value, the page it leads to, or in your words), and where each typed value comes from (as typed, test data, new on each run, or a secret read from the environment, its typed text removed from the recording). Every change is a version to go back to. Steps used in many tests are kept as a **block**, put into another recording, or played first when one starts (**Start from a block**). **Record more from here** plays the steps up to one and records what comes next. Checks of the page's own server calls, and **Suggest with the model** (one call). ForgeQE makes the usual choices first, and finds saved blocks in the steps. **Try it** replays the steps with Playwright, on another environment or with other test data if you like. **Write the test** tries the steps first, then the Coding agent writes it in the review, asking nothing: the plan and where the test goes follow the repository, and a block becomes one helper. A desktop recording replays with no model. The recordings, searched and paged, each with **Review**. |
134
+ | **Regression** | Regression packs for a release, in two tabs. **Agent**: a conversation where the agent reads the connected sources, says what is missing, asks for the details it needs (ticked off above the message box), and builds the pack. **Packs**: a table of the packs; a row opens the pack's page, with its numbers in one strip, the plan as a table (automated, manual, new automation, exploratory; filters, search, 50 rows a page, each row's evidence) and the release's changes, risk areas, runs and triage, history and a comparison beside it; save it, run it now or schedule it, refresh it, reuse it for the next release. |
135
+ | **API tests** | Two tabs. **Agent**: a conversation where you paste links, cURL or details (or attach a Postman collection or an API description) and the agent makes the API's calls in folders, sends them and says what it found, each API as a card to open. **Workbench**: like Postman, with an agent: APIs (from a description, a Postman collection, or the calls a recorded run saw) with their calls in folders and flows on the left, exported as a Postman collection; a call open to edit and **Send**, its answer, and what it must answer; an environment from env.yaml and one **Run**. Calls that change data ask first (once, or always on a test environment). Sign in once per API, the value kept as a secret. Flows built from the API's calls, passing values on. **Ask the agent** writes the tests or explains a failure, on the page. |
136
+ | **Quality** | What each browser run measured, as a table of runs (rules failed, critical and serious violations, slow pages, visual changes, budgets exceeded), with Trends beside it. A row opens the run's page: its numbers in one strip and three tabs, **Accessibility** (every failed WCAG rule with its criterion, level, elements and pages, each opening on the elements and how to fix it; the rules that passed), **Performance** (every page's Core Web Vitals, requests and size against the thresholds and budgets) and **Visual** (every page against its baseline, with the baseline, this run and the difference, and **Approve as the new baseline**). |
132
137
  | **Data** | Databases (read-only queries; test data only with a writable database and your confirmation), test data, and data flows. |
133
138
  | **Runs** | Every ForgeQE session in the project, from here, a schedule or the terminal: 25 to a page with filters. A run shows its summary, the conversation, its activity, and its details. |
134
139
  | **Reports** | Every report ForgeQE wrote, each opening as its HTML report in a new tab; and the project report: every run together, with pass rate by day, what fails most, flaky cases and defects. |
@@ -1158,6 +1158,46 @@ change. <code>--no-plan</code> (or <code>--yes</code>) skips the plan. Later: <c
1158
1158
  <p>The recorder runs in an isolated world in each page, so the page's own scripts can neither see it nor add steps, and it
1159
1159
  records only real input: clicks and keys a script fakes are ignored. The panel's own clicks and keys never reach the page
1160
1160
  and are never recorded, and it stays above the page's dialogs. Recording uses local Chrome or Chromium.</p>
1161
+ <p><strong>From the web app (Record page).</strong> You only do the steps, with nothing to describe first: the browser shows the site
1162
+ with no panel in it, only a small &quot;Recording&quot; badge that takes no click. <strong>Pause</strong>, <strong>Undo</strong> and <strong>Stop</strong> are on the
1163
+ Record page (and on the keys: Ctrl+Shift+Space, then P, Z or S). After each step the recorder keeps a picture of the
1164
+ page and what it showed (<code>steps/NNN.jpg</code> and <code>.json</code> in the run folder; the badge is left out of the picture, and an
1165
+ address keeps no query, where a form sent by GET puts what was typed), and the calls the page made to its own site
1166
+ that change data or fail (method, path and status only). When you stop, you review the recording with clicks.</p>
1167
+ <p>The review starts with the steps and <strong>Write the test</strong>; everything else is under <strong>More</strong>. ForgeQE has already made
1168
+ the choices most recordings need, as one version you can undo: an email typed where an account is made is new on each
1169
+ run, and the last step has the check its page suggests first. When steps of the recording are a saved block, it says
1170
+ so: <strong>Use the block</strong> marks them as the block.</p>
1171
+ <div class="tbl"><table>
1172
+ <thead>
1173
+ <tr><th>In the review</th><th>What it does</th></tr>
1174
+ </thead>
1175
+ <tbody>
1176
+ <tr><td>Name</td><td>Written from what you did (&quot;shop.test: Sign in → Email → Password → Log in …&quot;); change it if you like</td></tr>
1177
+ <tr><td>Check that … under a step</td><td>One click adds a check of what the step brought to the page: a new title, a message or heading. Digits are checked by their shape (<code>Order placed: #\d+</code>)</td></tr>
1178
+ <tr><td>A call under a step</td><td>One click checks the page's own call to its server, such as <code>POST /api/orders answers 201</code>: the test waits for it and checks its status</td></tr>
1179
+ <tr><td>Suggest with the model</td><td>One model call reads the pages after each step and suggests checks and test data; each is kept only when it is what the recording holds. <strong>Add</strong> one, or <strong>Add all</strong></td></tr>
1180
+ <tr><td>The picture of a step</td><td>Click a text on it to check that it shows, or a field to check its value</td></tr>
1181
+ <tr><td>Add, then Check</td><td>The page the step leads to, or a check in your words, which the coding agent finds on the page</td></tr>
1182
+ <tr><td>Add, then Step</td><td><strong>Record more from here</strong>: the browser opens and does the steps up to there, and you record what comes next; it goes in after that step. Or a step in your words (&quot;choose the cheapest delivery&quot;), which the coding agent finds on the page and does there; open a page; or go back</td></tr>
1183
+ <tr><td>Add, then Note</td><td>A note on the step for whoever writes the test (&quot;this is the cart page object&quot;)</td></tr>
1184
+ <tr><td>Drop (bin)</td><td>Removes the step</td></tr>
1185
+ <tr><td>Instructions for the Coding agent</td><td>Anything else about the test, in your words: where it goes, the page objects to use, its tags. The coding agent follows them, as long as they keep to the steps and checks</td></tr>
1186
+ <tr><td>Test data</td><td>Each typed value: as typed, test data, new on each run (<code>ann+{{$unique}}@shop.test</code>), or a secret read from the environment, its typed text removed from the recording, its pictures and every kept version</td></tr>
1187
+ <tr><td>Blocks</td><td>Keep steps you do in many tests (Sign in) as a block, <code>.forgeqe/blocks/&lt;name&gt;.yaml</code>; put a block in after a step. Blocks go into the repository, so the team shares them (the review says when <code>.gitignore</code> leaves them out). A block holds only steps done by hand: a block file with a step that runs JavaScript, calls an API or uploads a file is ignored</td></tr>
1188
+ <tr><td>History</td><td>Every change is a version: go back to any of them, or to the recording as recorded</td></tr>
1189
+ <tr><td>Try it</td><td>Plays the steps with Playwright in a new browser, as the test will: where it was recorded or on another environment of <code>env.yaml</code> (the same web app's address there), with the test data as recorded or other values</td></tr>
1190
+ </tbody>
1191
+ </table></div>
1192
+ <p><strong>Start from a block</strong> (More options on the Record page): the recording opens the block's first page and does its
1193
+ steps for you in the same tab, the recorder paused meanwhile; then you record the rest. A step that cannot be done (a
1194
+ secret not set) ends the block there, and you do the rest by hand. <strong>Write the test</strong> hands the recording to the coding
1195
+ agent, which asks nothing: the plan and where the test goes follow the repository, and each block becomes one helper
1196
+ that every test using it calls. A past recording is run again the same way: <strong>Review</strong> in the list, then <strong>Try it</strong>.</p>
1197
+ <p><strong>Write the test</strong> first plays the steps with Playwright, as the test will. When a step does not work, it says so
1198
+ before any code is written: <strong>Record step N again</strong> (the browser does the steps before it, and what you record takes
1199
+ its place), drop it, or write the test anyway. Then the Coding agent writes the test, and its work shows in the review:
1200
+ what it is doing, the files it changed, and its answer (or why it stopped).</p>
1161
1201
  </div>
1162
1202
  </section>
1163
1203
  </div>
@@ -4174,7 +4214,7 @@ forgeqe report setup # a report after every Playw
4174
4214
  <div class="facts">
4175
4215
  <div class="fact"><span class="mono">Ask it</span><ul class="asks"><li>Build a regression pack for sprint 12 and run it on TestMu</li><li>Which tests should we run for the PRs merged this week?</li></ul></div>
4176
4216
  <div class="fact"><span class="mono">What it needs</span><ul class="needs"><li><span class="need input">You give</span><span>a repository with tests</span></li><li><span class="need opt">Optional</span><span>Azure DevOps or Jira, to read a sprint's or release's work items: set up under sources: in forgeqe.yaml, or sign in with /auth</span></li></ul></div>
4177
- <div class="fact"><span class="mono">Tools</span><p class="tools"><code>build_regression_pack</code> <code>run_regression_pack</code> <code>list_regression_packs</code></p></div>
4217
+ <div class="fact"><span class="mono">Tools</span><p class="tools"><code>build_regression_pack</code> <code>run_regression_pack</code> <code>list_regression_packs</code> <code>regression_sources</code> <code>edit_regression_pack</code></p></div>
4178
4218
  </div>
4179
4219
  <div class="detail"><span class="mono">In detail</span>
4180
4220
  <section class="doc" id="doc-how_to_use-regression-packs-for-a-release">
@@ -4205,6 +4245,27 @@ Build a pack for Jira fix version 2.4 and the commits since release/2.3 in ../sh
4205
4245
  </tbody>
4206
4246
  </table></div>
4207
4247
  <p><strong>Gaps.</strong> Changes no test is in for are listed as <em>not covered</em>, each with the closest existing test and what it lacks, so you can extend that test rather than write a new one.</p>
4248
+ <p><strong>The plan: what the release needs.</strong> Besides the tests to run, a pack is a plan in four groups, so what is ready is never mixed up with what someone still has to do:</p>
4249
+ <div class="tbl"><table>
4250
+ <thead>
4251
+ <tr><th>Group</th><th>What it is</th><th>Its script</th></tr>
4252
+ </thead>
4253
+ <tbody>
4254
+ <tr><td>A Automated</td><td>tests of the repository the pack found (the reasons above)</td><td><em>checked</em> only while its file is in the repository and still names the test; otherwise <em>missing</em> (moved, renamed or deleted since)</td></tr>
4255
+ <tr><td>B Manual</td><td>test cases linked to a changed work item that no automated test runs</td><td>run by a person</td></tr>
4256
+ <tr><td>C New automation</td><td>changes no test covers: a test to write, or the closest one to extend</td><td>to write</td></tr>
4257
+ <tr><td>D Exploratory</td><td>the risk areas the release touches</td><td>a session for a person</td></tr>
4258
+ </tbody>
4259
+ </table></div>
4260
+ <p>Each entry has a priority, says where it came from (<em>found</em> in the sources and the code, or <em>suggested</em> by ForgeQE or its agent) and keeps its evidence (the work item, pull request or defect history, with links). Change it in your words (&quot;take out the flaky ones&quot;, &quot;add a manual check of the invoice PDF&quot;, &quot;why is this in?&quot;) or on the page: priority, take out and put back, move between B, C and D, add an entry. An automated test is added only when its file is in the test repository (no hidden file) and names the test, so the pack never claims a script it has not found. Every change is kept in the pack's history, with who made it.</p>
4261
+ <p>A pack starts as a <strong>draft</strong>; save it (a name, the release) when it is right, then run it now or on a schedule (a job that runs <code>forgeqe pack run</code>). Reuse it:</p>
4262
+ <ul>
4263
+ <li><strong>Refresh</strong>: the same changes read again (<code>forgeqe pack build --refresh release-22</code>); your edits and its runs stay.</li>
4264
+ <li><strong>The next release</strong>: a new pack from new changes that keeps the edits of an earlier one (<code>--based-on release-22</code>).</li>
4265
+ <li><strong>Compare</strong> two releases: what each has ready, manual, to automate and exploratory, the tests and changes one has and the other not, and their last runs.</li>
4266
+ </ul>
4267
+ <p><code>--release &quot;Release 22&quot;</code> names the release a pack is for.</p>
4268
+ <p><strong>On the Regression page</strong> there are two tabs. On <strong>Agent</strong> you ask for a pack in a sentence (&quot;Create a regression pack for Release 22&quot;). The agent reads which sources the project is connected to (the test and product repositories, Azure DevOps, Jira, GitHub, test management, docs, a pipeline: the line at the top says which), says what a missing one would add and offers to connect it, and asks for the details it still needs, one or two at a time: the release, where its changes are, what to leave out, then whether to save it and run it now or on a schedule. Above the message box, <em>The pack needs</em> ticks off each detail as it is given (sources, release, changes, plan, saved, run); click a missing one to start your answer to it. The tab looks and works like the API page's Agent tab. None of the sources is required, and nothing runs until you say so. On <strong>Packs</strong> the packs are a table, newest first: each with how many entries are ready to run, scripts missing, manual, to automate and exploratory, and its last run. A row opens the pack's page: one strip of numbers (ready to run, script missing, the four groups, high priority, coverage of the release's changes, the last run; click one to show those entries), the plan as a table (all or one group, high priority, script missing, flaky or taken out, a search over tests, files and features, 50 rows a page with the highest priority first; a row opens its evidence), and beside it the release's changes, risk areas, runs and triage, history and a comparison with another release. Without a model set up, <em>Choose the changes</em> picks the sprint, commits or pull requests yourself.</p>
4208
4269
  <p><strong>Running it.</strong> ForgeQE asks before it runs anything.</p>
4209
4270
  <ul>
4210
4271
  <li><em>This machine</em>: ForgeQE builds one command for exactly the pack's tests, the way the repository already runs a test (for .NET, a <code>--filter</code> with each test, the settings an earlier job used, TRX results), runs it, and reads each result. A failed test runs once more; one that then passes is flaky.</li>
@@ -4344,10 +4405,10 @@ forgeqe pr-tests 42 --run --post # and post the results on p
4344
4405
  <div class="hd"><span class="mono">API</span><h3>API and contract testing</h3></div>
4345
4406
  <p class="ds">Builds API contracts (status, schema, key fields) from the calls a browser run saw or from an API description (OpenAPI, Swagger, WSDL, GraphQL, .proto, gRPC reflection), and end-to-end API scenarios from runs, descriptions, test cases, or plain English. Runs them straight against the API without a browser, or writes them as tests in the repository. REST, GraphQL, SOAP, and gRPC.</p>
4346
4407
  <div class="facts">
4347
- <div class="fact"><span class="mono">Ask it</span><ul class="asks"><li>Turn the last run's API calls into tests</li><li>Test the API in openapi.yaml</li><li>Write API scenario tests for the order lifecycle</li></ul></div>
4408
+ <div class="fact"><span class="mono">Ask it</span><ul class="asks"><li>Turn the last run's API calls into tests</li><li>Test the API in openapi.yaml</li><li>Write API scenario tests for the order lifecycle</li><li>Import our Postman collection and send its calls</li><li>Add these cURL calls to the shop API</li></ul></div>
4348
4409
  <div class="fact"><span class="mono">What it needs</span><ul class="needs"><li><span class="need opt">Optional</span><span>The coding agent, Scribe: a live model profile (or code.model) and the agent runtime, which forgeqe setup installs</span></li></ul></div>
4349
4410
  <div class="fact"><span class="mono">Limits</span><ul class="plainlist"><li>Functional API testing, not load or stress testing.</li></ul></div>
4350
- <div class="fact"><span class="mono">Tools</span><p class="tools"><code>api_contracts</code> <code>run_api_contracts</code> <code>api_scenarios</code> <code>run_api_scenarios</code> <code>write_api_tests</code></p></div>
4411
+ <div class="fact"><span class="mono">Tools</span><p class="tools"><code>api_contracts</code> <code>run_api_contracts</code> <code>api_scenarios</code> <code>run_api_scenarios</code> <code>write_api_tests</code> <code>api_new_set</code> <code>api_add_calls</code> <code>api_import_collection</code></p></div>
4351
4412
  </div>
4352
4413
  <div class="detail"><span class="mono">In detail</span>
4353
4414
  <section class="doc" id="doc-how_to_use-api-and-contract-tests">
@@ -4378,6 +4439,31 @@ forgeqe api contracts --run # the latest browser run's API c
4378
4439
  forgeqe api run --base-url https://qa.shop.example # exit 1 when a contract fails: a CI gate
4379
4440
  forgeqe api tests --repo ../app # Scribe writes them as tests
4380
4441
  </code></pre>
4442
+ <p><strong>The Agent tab</strong> of the API tests page is a conversation: paste a link (an API description, a Postman collection,
4443
+ the docs), cURL commands, or tell it about the API in your words, and attach a file (a Postman collection is imported
4444
+ at once; an API description is kept in <code>.forgeqe/specs/</code> for the agent to read). The agent makes the API and its
4445
+ calls in folders, as Postman would (<code>api_new_set</code>, <code>api_add_calls</code>, <code>api_import_collection</code>, <code>api_contracts</code>), sends
4446
+ them, and says what it found; each API it made shows as a card to open on the Workbench tab. It never puts a
4447
+ credential in a call: you set the API's sign-in on the Workbench.</p>
4448
+ <p><strong>Postman collections</strong> (v2.0 and v2.1) come in from <strong>Add an API</strong> or the Agent tab, and go out with <strong>Export as a
4449
+ Postman collection</strong>: requests become calls in their folders, a saved example's status what each call must answer;
4450
+ only requests to the collection's own address are kept, and credentials (headers, secret variables, auth values)
4451
+ never are. An exported collection has a test of what each call must answer and <code>{{variables}}</code> where credentials go.</p>
4452
+ <p><strong>On the API tests page's Workbench tab</strong> (<code>forgeqe web</code>), it works like Postman, with an agent beside it. The APIs are on the left,
4453
+ each with its <strong>calls</strong> (contracts) and <strong>flows</strong> (scenarios). Open a call to see and change its request (method,
4454
+ path, params, headers, a JSON body), <strong>Send</strong> it and see what came back (body, headers, the checks that passed or
4455
+ failed), <strong>Save</strong> it, and set <strong>what it must answer</strong> (the status, the statuses that also pass, fields with their
4456
+ type or value), or take it from a right answer with <strong>Use as what it must answer</strong>. Pick the <strong>environment</strong> from
4457
+ <code>env.yaml</code> at the top: calls go to its API app's address, and <strong>Run</strong> runs every call and then every flow there
4458
+ (<code>forgeqe api run-all</code>). A call that changes data asks first: <strong>Send it once</strong>, or <strong>Always on</strong> that environment
4459
+ (remembered for the API, never for an environment named like production). <strong>Sign in</strong> once per API: a bearer token,
4460
+ an API key in a header, or a user name and password; the value you type goes to the credential store under a variable
4461
+ name, and only the name is kept with the API. Credential headers cannot be typed into a call's headers, and answers
4462
+ come back with credentials masked. Build a <strong>flow</strong> step by step from the API's calls: a step keeps a value from its
4463
+ answer by a name (<code>id</code> as <code>itemId</code>), and later steps use it as <code>{{itemId}}</code> in their path or body; <code>{{$unique}}</code> is
4464
+ new on each run. <strong>Ask the agent</strong> writes the tests, says why a call fails, or what is not tested yet, and its work
4465
+ shows on the page. Adding an API runs its calls that only read at once. Each run keeps the start of every answer (secrets
4466
+ masked), and each call shows how its last runs went.</p>
4381
4467
  </div>
4382
4468
  </section>
4383
4469
  <section class="doc" id="doc-how_to_use-end-to-end-api-scenarios">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capagents/forgeqe",
3
- "version": "2.5.1",
3
+ "version": "2.6.0",
4
4
  "description": "ForgeQE: a browser agent CLI that runs goals and test cases in local Chrome or Chromium, or BrowserStack and TestMu AI/LambdaTest when configured, and turns passing runs into tests in your repo",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -238,6 +238,20 @@ def _probe(out: TextIO) -> int:
238
238
  return 0 if result.get("ok") else 1
239
239
 
240
240
 
241
+ def _suggest(out: TextIO) -> int:
242
+ """stdin: {llm, steps}. Prints {ok, picks, ms, usage} or {ok: false, error}: one model call over a reviewed recording."""
243
+ from .suggest import suggest
244
+
245
+ line = sys.stdin.readline()
246
+ payload = json.loads(line) if line.strip() else {}
247
+ try:
248
+ result = asyncio.run(suggest(payload))
249
+ except Exception as e:
250
+ result = {"ok": False, "error": f"{type(e).__name__}: {e}"[:500]}
251
+ out.write(json.dumps(result, ensure_ascii=False) + "\n")
252
+ return 0 if result.get("ok") else 1
253
+
254
+
241
255
  def _utf8_stdio() -> None:
242
256
  """The CLI speaks UTF-8 on every pipe; on Windows a pipe defaults to the ANSI code page, which turns a curly quote into a lone surrogate."""
243
257
  for stream in (sys.stdin, sys.stderr):
@@ -265,6 +279,8 @@ def main(argv: list[str] | None = None) -> int:
265
279
  return _token(out)
266
280
  if cmd == "probe":
267
281
  return _probe(out)
282
+ if cmd == "suggest":
283
+ return _suggest(out)
268
284
  if cmd == "copilot-gateway":
269
285
  from .copilot_gateway import main as copilot_gateway
270
286
 
@@ -32,7 +32,7 @@ from typing import Any, Callable, Dict, List, Optional
32
32
  from .capture import capture_element, locate_check
33
33
  from .memory import BASE, KEPT_ATTRS, candidate_locators, confidence, looks_generated
34
34
  from . import dynamic
35
- from .webrecord import Target, WebRecorder, describe, upload_path
35
+ from .webrecord import Target, WebRecorder, auto_name, describe, upload_path
36
36
  from .webrecord_page import recorder_js
37
37
 
38
38
  logger = logging.getLogger("forgeqe_engine.record")
@@ -40,6 +40,39 @@ logger = logging.getLogger("forgeqe_engine.record")
40
40
  Emit = Callable[[Dict[str, Any]], None]
41
41
 
42
42
  CDP_TIMEOUT = 5.0
43
+ # A step's picture of the page: taken this long after the step, once the page has answered it; at most this many.
44
+ SHOT_SETTLE = 0.7
45
+ MAX_SHOTS = 400
46
+ SHOT_QUALITY = 55
47
+
48
+ # What the page shows after a step, for the review to suggest checks from and to pick an element on the screenshot:
49
+ # the address and title, the visible text (a leaf's own words, with its box) and the fields with their values, in the
50
+ # viewport's coordinates. A password field's value is never read; the Recorder panel (forgeqe-recorder) is left out.
51
+ SNAPSHOT_JS = r"""(() => {
52
+ const vw = innerWidth, vh = innerHeight, out = { url: location.origin + location.pathname, title: document.title, w: vw, h: vh, texts: [], fields: [] };
53
+ const seen = (el) => { const r = el.getBoundingClientRect(); if (r.width < 2 || r.height < 2 || r.bottom < 0 || r.right < 0 || r.top > vh || r.left > vw) return null;
54
+ const cs = getComputedStyle(el); if (cs.visibility === 'hidden' || cs.display === 'none' || +cs.opacity === 0) return null;
55
+ return { x: Math.round(r.left), y: Math.round(r.top), w: Math.round(r.width), h: Math.round(r.height) }; };
56
+ const own = (el) => [...el.childNodes].filter((n) => n.nodeType === 3).map((n) => n.textContent).join(' ').replace(/\s+/g, ' ').trim();
57
+ const skip = (el) => el.closest('forgeqe-recorder,script,style,noscript,svg,template');
58
+ for (const el of document.body ? document.body.querySelectorAll('*') : []) {
59
+ if (out.texts.length >= 200) break;
60
+ if (skip(el) || /^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(el.tagName)) continue;
61
+ const t = own(el); if (t.length < 2 || t.length > 160) continue;
62
+ const box = seen(el); if (!box) continue;
63
+ out.texts.push({ t, tag: el.tagName.toLowerCase(), role: el.getAttribute('role') || '', ...box });
64
+ }
65
+ for (const el of document.querySelectorAll('input,textarea,select')) {
66
+ if (out.fields.length >= 60 || skip(el)) continue;
67
+ const type = (el.getAttribute('type') || el.tagName).toLowerCase();
68
+ if (/^(hidden|submit|button|image|reset|file)$/.test(type)) continue;
69
+ const box = seen(el); if (!box) continue;
70
+ const label = (el.getAttribute('aria-label') || (el.labels && el.labels[0] && el.labels[0].innerText) || el.getAttribute('placeholder') || el.name || '').replace(/\s+/g, ' ').trim().slice(0, 80);
71
+ const value = type === 'password' ? '' : (type === 'checkbox' || type === 'radio') ? (el.checked ? 'checked' : 'not checked') : el.tagName === 'SELECT' ? (el.selectedOptions[0] ? el.selectedOptions[0].text : '') : String(el.value || '');
72
+ out.fields.push({ label, value: value.slice(0, 120), type, ...box });
73
+ }
74
+ return out;
75
+ })()"""
43
76
  MAX_SECONDS = 4 * 3600
44
77
  DEFAULT_LEADER = {"code": "Space", "ctrl": True, "shift": True, "alt": False, "meta": False}
45
78
  MAX_PAGE_TEXT = 8000
@@ -97,6 +130,15 @@ class RecordSession:
97
130
  ]
98
131
  # A stop with expected results not checked yet warns once; the next stop stops.
99
132
  self.gaps_warned = False
133
+ # Each step's screenshot and page snapshot (steps/NNN.jpg, .json), taken once the page has answered it.
134
+ self.shots = 0
135
+ self._shot_task: Optional[asyncio.Task] = None
136
+ # The latest picture of each step, by its place: a step the recorder replaces in place (a click into a field that
137
+ # becomes the typing) keeps the place's newest picture. Put on the steps when the run folder is written.
138
+ self.shot_at: Dict[int, str] = {}
139
+ # The page's own API calls after each step (method, path, status), for checks of them in the review.
140
+ self.calls: Dict[int, List[Dict[str, Any]]] = {}
141
+ self._requests: Dict[str, str] = {}
100
142
 
101
143
  # -- the browser ----------------------------------------------------------------------------------------------
102
144
 
@@ -145,6 +187,8 @@ class RecordSession:
145
187
  reg.Page.frameNavigated(self._queue("navigated"))
146
188
  reg.Page.navigatedWithinDocument(self._queue("navigated_same"))
147
189
  reg.Page.frameRequestedNavigation(self._queue("requested"))
190
+ reg.Network.requestWillBeSent(self._queue("request"))
191
+ reg.Network.responseReceived(self._queue("response"))
148
192
  await self.send("Target.setAutoAttach", {"autoAttach": True, "waitForDebuggerOnStart": True, "flatten": True})
149
193
  if self.llm is None and self.payload.get("llm") and (self.payload["llm"].get("provider") or "") != "mock":
150
194
  try:
@@ -153,7 +197,9 @@ class RecordSession:
153
197
  self.llm = _build_llm(self.payload["llm"])
154
198
  _time_llm_calls(self.llm, [], lambda c: self._on_call(c))
155
199
  except Exception as ex:
156
- self.log(f"Checks described in words are kept as written: no model ({ex})", "warn")
200
+ # Without a panel (the web app), no check is described in words while recording: nothing to warn about.
201
+ if self.payload.get("panel") != "badge":
202
+ self.log(f"Checks described in words are kept as written: no model ({ex})", "warn")
157
203
 
158
204
  def _on_call(self, call: Dict[str, Any]) -> None:
159
205
  for k in ("input", "output"):
@@ -171,6 +217,11 @@ class RecordSession:
171
217
  self.active = main
172
218
  self.pages[main]["initial"] = True
173
219
  await self.send("Page.navigate", {"url": self.start_url}, main)
220
+ # The start page's picture, once it has loaded.
221
+ self._schedule_shot(2.0)
222
+ # Where ForgeQE reaches this browser (on this computer only), to play a block of steps first: never shown.
223
+ if str(getattr(self.browser, "cdp_url", "") or "").startswith(("http://127.0.0.1:", "ws://127.0.0.1:", "http://localhost:", "ws://localhost:")):
224
+ self.emit({"type": "browser", "cdp": self.browser.cdp_url})
174
225
 
175
226
  async def close(self) -> None:
176
227
  from .browser import _shutdown_browser_instance
@@ -207,6 +258,10 @@ class RecordSession:
207
258
  stopping = self.stop_reason
208
259
  await self._drain(0.6, stopping=True)
209
260
  self.stop_reason = stopping
261
+ # The last step's picture, now rather than after its pause.
262
+ if self._shot_task and not self._shot_task.done():
263
+ self._shot_task.cancel()
264
+ await self.shoot()
210
265
 
211
266
  async def _drain(self, seconds: float, stopping: bool = False) -> None:
212
267
  end = time.monotonic() + seconds
@@ -236,12 +291,33 @@ class RecordSession:
236
291
  self.pages[sid]["renderer"] = True
237
292
  elif kind in ("navigated", "navigated_same"):
238
293
  await self._navigated(event, sid, same=kind == "navigated_same")
294
+ elif kind == "request":
295
+ if event.get("type") in ("XHR", "Fetch") and event.get("requestId"):
296
+ if len(self._requests) > 2000:
297
+ self._requests.clear()
298
+ self._requests[str(event["requestId"])] = str((event.get("request") or {}).get("method") or "GET")
299
+ elif kind == "response":
300
+ self._response(event, sid)
239
301
  elif kind == "cmd":
240
302
  await self.command(event)
241
303
  except Exception as ex:
242
304
  logger.warning("record: %s not handled: %s", kind, ex)
243
305
  logger.debug("record: details", exc_info=True)
244
306
 
307
+ def _response(self, event: Dict[str, Any], sid: Optional[str]) -> None:
308
+ method = self._requests.pop(str(event.get("requestId") or ""), None)
309
+ rec = self.rec
310
+ if not method or rec is None or not rec.steps or self.paused or event.get("type") not in ("XHR", "Fetch"):
311
+ return
312
+ res = event.get("response") or {}
313
+ page = str((self.pages.get(sid or "") or {}).get("url") or rec.url or self.start_url)
314
+ call = api_call(method, str(res.get("url") or ""), int(res.get("status") or 0), page)
315
+ if not call:
316
+ return
317
+ at = self.calls.setdefault(len(rec.steps) - 1, [])
318
+ if call not in at and len(at) < MAX_CALLS:
319
+ at.append(call)
320
+
245
321
  # -- pages ----------------------------------------------------------------------------------------------------
246
322
 
247
323
  async def _attached(self, event: Dict[str, Any]) -> None:
@@ -256,7 +332,9 @@ class RecordSession:
256
332
  # Binding calls are Runtime events: the domain must be on for them to arrive.
257
333
  await self.send("Runtime.enable", None, sid)
258
334
  await self.send("Runtime.addBinding", {"name": self.binding, "executionContextName": self.world}, sid)
259
- js = recorder_js(self.binding, KEPT_ATTRS, leader=self.leader)
335
+ # The page's own calls to its server, kept by step (only method, path and status: never a query or a body).
336
+ await self.send("Network.enable", None, sid)
337
+ js = recorder_js(self.binding, KEPT_ATTRS, leader=self.leader, badge=self.payload.get("panel") == "badge")
260
338
  await self.send("Page.addScriptToEvaluateOnNewDocument", {"source": js, "worldName": self.world}, sid)
261
339
  tree = await self.send("Page.getFrameTree", None, sid)
262
340
  frame = ((tree.get("frameTree") or {}).get("frame") or {}).get("id")
@@ -740,6 +818,7 @@ class RecordSession:
740
818
  def _changed(self, msg: str) -> None:
741
819
  rec = self.rec
742
820
  assert rec is not None
821
+ self._schedule_shot()
743
822
  self.emit({"type": "steps", "steps": rec.view(), "summary": rec.summary(), "text": msg})
744
823
  level = "warn" if msg.startswith("not recorded") else "info"
745
824
  self.emit({"type": "log", "level": level, "text": msg})
@@ -772,6 +851,62 @@ class RecordSession:
772
851
  except Exception:
773
852
  pass
774
853
 
854
+ # -- each step's picture of the page ---------------------------------------------------------------------------------
855
+
856
+ def _schedule_shot(self, settle: float = SHOT_SETTLE) -> None:
857
+ """A picture of the page after the latest step, once it has settled; a newer step replaces one not yet taken."""
858
+ if self._shot_task and not self._shot_task.done():
859
+ self._shot_task.cancel()
860
+
861
+ async def later() -> None:
862
+ await asyncio.sleep(settle)
863
+ await self.shoot()
864
+
865
+ try:
866
+ self._shot_task = asyncio.ensure_future(later())
867
+ except RuntimeError:
868
+ self._shot_task = None
869
+
870
+ async def shoot(self) -> Optional[str]:
871
+ """
872
+ The page as the latest step left it: steps/NNN.jpg (a screenshot of the viewport) and steps/NNN.json (SNAPSHOT_JS),
873
+ and the step's place gets it (``shot: NNN`` in workflow.yaml). Paused or stopped by then, or a page that cannot answer: no picture, never an error.
874
+ """
875
+ rec, sid = self.rec, self.active
876
+ if rec is None or not rec.steps or not sid or self.paused or self.shots >= MAX_SHOTS:
877
+ return None
878
+ ctx = (self.pages.get(sid) or {}).get("ctx")
879
+ async def panel(hidden: bool) -> None:
880
+ # The Recorder panel is not part of the page: out of the picture while it is taken.
881
+ if ctx:
882
+ await self.send("Runtime.evaluate", {"expression": f"globalThis.__fqeRec && __fqeRec.hide && __fqeRec.hide({'true' if hidden else 'false'})", "contextId": ctx}, sid)
883
+
884
+ try:
885
+ await panel(True)
886
+ try:
887
+ pic = await self.send("Page.captureScreenshot", {"format": "jpeg", "quality": SHOT_QUALITY}, sid)
888
+ finally:
889
+ await panel(False)
890
+ snap: Dict[str, Any] = {}
891
+ if ctx:
892
+ res = await self.send("Runtime.evaluate", {"expression": SNAPSHOT_JS, "contextId": ctx, "returnByValue": True}, sid)
893
+ snap = ((res.get("result") or {}).get("value")) or {}
894
+ except Exception as ex:
895
+ logger.debug("record: no picture of the page: %s", ex)
896
+ return None
897
+ if not pic.get("data"):
898
+ return None
899
+ import base64
900
+
901
+ self.shots += 1
902
+ name = f"{self.shots:03d}"
903
+ folder = self.out_dir / "steps"
904
+ folder.mkdir(parents=True, exist_ok=True)
905
+ (folder / f"{name}.jpg").write_bytes(base64.b64decode(pic["data"]))
906
+ (folder / f"{name}.json").write_text(json.dumps(snap, ensure_ascii=False), encoding="utf-8")
907
+ self.shot_at[len(rec.steps) - 1] = name
908
+ return name
909
+
775
910
  # -- the run folder -------------------------------------------------------------------------------------------------
776
911
 
777
912
  async def finish(self) -> Dict[str, Any]:
@@ -782,10 +917,13 @@ class RecordSession:
782
917
  assert rec is not None
783
918
  self.out_dir.mkdir(parents=True, exist_ok=True)
784
919
  # The recorder's own working fields (an element's facts) stay out of the run.
785
- steps = [{k: v for k, v in s.items() if not k.startswith("_")} for s in rec.steps]
920
+ steps = [
921
+ {**{k: v for k, v in s.items() if not k.startswith("_")}, **({"shot": self.shot_at[i]} if i in self.shot_at else {}), **({"calls": self.calls[i]} if self.calls.get(i) else {})}
922
+ for i, s in enumerate(rec.steps)
923
+ ]
786
924
  recorded = len(steps) - 1
787
925
  ok = recorded > 0
788
- goal = self.name or f"Recorded: {_path_of(self.start_url, host=True)}"
926
+ goal = self.name or auto_name(steps, self.start_url)
789
927
  summary = f"Recorded by hand: {rec.summary()}" if ok else "Nothing was recorded after opening the start page."
790
928
  try:
791
929
  profile = await browser_profile(self.browser, self.launch)
@@ -802,7 +940,8 @@ class RecordSession:
802
940
  "summary": summary,
803
941
  "goal": goal,
804
942
  "start_url": self.start_url,
805
- "final_url": rec.url,
943
+ # Without its query: a form sent by GET puts what was typed there, a password too.
944
+ "final_url": _no_query(rec.url),
806
945
  "driver": "engine",
807
946
  "source": "recorded",
808
947
  "run_id": self.out_dir.name,
@@ -876,6 +1015,37 @@ def fallback_target(url: str, facts: Dict[str, Any], counted: Optional[Dict[str,
876
1015
  return Target(url, f, locs)
877
1016
 
878
1017
 
1018
+ MAX_CALLS = 5
1019
+ STATIC = re.compile(r"\.(?:js|mjs|css|png|jpe?g|gif|svg|webp|ico|woff2?|ttf|map)$", re.I)
1020
+
1021
+
1022
+ def api_call(method: str, url: str, status: int, page_url: str) -> Optional[Dict[str, Any]]:
1023
+ """
1024
+ A call the page made to its own site, worth a check: one that changes data (not GET), or one that failed. Kept as
1025
+ method, path and status only: never a query, a body, or a call to another site (analytics, ads).
1026
+ """
1027
+ from urllib.parse import urlparse
1028
+
1029
+ u, p = urlparse(url or ""), urlparse(page_url or "")
1030
+ if u.scheme not in ("http", "https") or not u.hostname or not p.hostname or not status:
1031
+ return None
1032
+ site = lambda h: ".".join(h.split(".")[-2:]) # noqa: E731
1033
+ if site(u.hostname) != site(p.hostname) or STATIC.search(u.path or ""):
1034
+ return None
1035
+ m = (method or "GET").upper()
1036
+ if m in ("GET", "HEAD", "OPTIONS") and status < 400:
1037
+ return None
1038
+ return {"method": m, "path": (u.path or "/")[:200], "status": int(status)}
1039
+
1040
+
1041
+ def _no_query(url: str) -> str:
1042
+ """An address without its query and fragment."""
1043
+ from urllib.parse import urlparse
1044
+
1045
+ p = urlparse(url or "")
1046
+ return f"{p.scheme}://{p.netloc}{p.path}" if p.scheme and p.netloc else (url or "").split("?")[0].split("#")[0]
1047
+
1048
+
879
1049
  def _path_of(url: str, host: bool = False) -> str:
880
1050
  from urllib.parse import urlparse
881
1051
 
@@ -898,7 +1068,10 @@ async def record_web(payload: Dict[str, Any], emit: Emit, commands: asyncio.Queu
898
1068
  try:
899
1069
  await s.start()
900
1070
  await s.open()
901
- s.log(f"Recording in the browser. Do the steps; the Recorder panel is in the page. {leader_label(s.leader)} then a letter adds a check, a variable, a note (S stops).")
1071
+ if s.payload.get("panel") == "badge":
1072
+ s.log(f"Recording in the browser. Do the steps; you choose the checks and the test data when you stop. In the page, {leader_label(s.leader)} then P pauses, Z undoes, S stops.")
1073
+ else:
1074
+ s.log(f"Recording in the browser. Do the steps; the Recorder panel is in the page. {leader_label(s.leader)} then a letter adds a check, a variable, a note (S stops).")
902
1075
  await s.run(float(payload.get("max_seconds") or MAX_SECONDS))
903
1076
  await s.review_values()
904
1077
  s._render()