@testmuai/kane-cli 0.6.10 → 0.6.11
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/dist/ChatSurface-TZ554O4U.js +8 -0
- package/dist/{ChromeProfilePicker-IDKFTIHW.js → ChromeProfilePicker-54CAJDUF.js} +1 -1
- package/dist/{CliFeedbackPrompt-SZOU5FGZ.js → CliFeedbackPrompt-TCAH4AHL.js} +1 -1
- package/dist/{CliUploadProgress-W2FC33Q4.js → CliUploadProgress-UURZ63VQ.js} +1 -1
- package/dist/{ConfigView-JB2NSZ2N.js → ConfigView-5QGB7MUS.js} +1 -1
- package/dist/{EvidenceViewOffer-5YST67KY.js → EvidenceViewOffer-SSAM4RRP.js} +1 -1
- package/dist/{FolderPicker-SPNZESAR.js → FolderPicker-Y5MAYFIJ.js} +1 -1
- package/dist/{HelpView-XBDXXHFB.js → HelpView-S3GJGSCE.js} +1 -1
- package/dist/{InfoBox-2T7GYSFT.js → InfoBox-LYTNNMVJ.js} +1 -1
- package/dist/{LinksBox-2NNZZDQT.js → LinksBox-5MSEKNSV.js} +1 -1
- package/dist/{ProfilesView-KJZVGU5B.js → ProfilesView-LTHE5UIO.js} +1 -1
- package/dist/{ProjectPicker-AUTZNEPE.js → ProjectPicker-XMXIGHSE.js} +1 -1
- package/dist/{SaveSessionPrompt-LHLSJQSQ.js → SaveSessionPrompt-VQDEA4WA.js} +1 -1
- package/dist/SingleShotApp-A6PCNPLM.js +2 -0
- package/dist/{SummaryBox-5G7WULUN.js → SummaryBox-WWF3G263.js} +1 -1
- package/dist/TestMdRunView-MQ7ZPFN2.js +2 -0
- package/dist/{WhoamiView-XNWBDMQR.js → WhoamiView-PDURYP7E.js} +1 -1
- package/dist/auth-I4RB4KO3.js +2 -0
- package/dist/{bind-FEOGBJ2O.js → bind-QJT726NE.js} +2 -2
- package/dist/{bootstrap-T6DSUI34.js → bootstrap-566PPFCC.js} +1 -1
- package/dist/{bridge-WMGH3O3B.js → bridge-QCMEOQDD.js} +1 -1
- package/dist/{changelog-AGFDNTTW.js → changelog-OKYH4F7I.js} +1 -1
- package/dist/{chat-committer-4ENYH3RC.js → chat-committer-OS7ULZMH.js} +1 -1
- package/dist/chat-controller-QLORQWJZ.js +2 -0
- package/dist/{chunk-FYDBD7Q4.js → chunk-2WKX3RMA.js} +1 -1
- package/dist/{chunk-6JTEWZ75.js → chunk-3AZTXJY4.js} +1 -1
- package/dist/{chunk-SKRZN25J.js → chunk-3RZ63RBO.js} +1 -1
- package/dist/{chunk-5F7PU5AJ.js → chunk-4CJ55EUY.js} +1 -1
- package/dist/{chunk-5Z7GAIPP.js → chunk-54IB6CXK.js} +2 -2
- package/dist/{chunk-JHPZXF77.js → chunk-54VQ46U2.js} +2 -2
- package/dist/{chunk-KK7DYHK6.js → chunk-55Y65VPA.js} +1 -1
- package/dist/{chunk-L4JIMNKW.js → chunk-6HYW5RFX.js} +1 -1
- package/dist/{chunk-A46NBRAP.js → chunk-6W6AIDLJ.js} +1 -1
- package/dist/{chunk-XY5KWIRF.js → chunk-73OQDAXF.js} +1 -1
- package/dist/{chunk-SDRFTIRU.js → chunk-7E24OCGX.js} +1 -1
- package/dist/{chunk-W54W762O.js → chunk-7MRBMDZ5.js} +1 -1
- package/dist/{chunk-76I6NJBX.js → chunk-7NLQ3QQD.js} +1 -1
- package/dist/chunk-7YPK6EDR.js +4 -0
- package/dist/{chunk-WSZ7IENQ.js → chunk-DSOA6L73.js} +3 -3
- package/dist/{chunk-6CGNLFSN.js → chunk-EAUUULJQ.js} +1 -1
- package/dist/{chunk-QPT4ERGK.js → chunk-F7WKDMX7.js} +1 -1
- package/dist/{chunk-7Z64BL5D.js → chunk-FCHTL74E.js} +1 -1
- package/dist/{chunk-OSALXGD4.js → chunk-FMR2KPSK.js} +1 -1
- package/dist/{chunk-RGDQMKNJ.js → chunk-FRBYGSGJ.js} +1 -1
- package/dist/{chunk-LPBAQQ7E.js → chunk-FSB3FTIQ.js} +1 -1
- package/dist/{chunk-AYDUHTPA.js → chunk-GIMTSDNC.js} +1 -1
- package/dist/{chunk-SACSQY3Q.js → chunk-GLA6QL3T.js} +1 -1
- package/dist/{chunk-TLL7KFLY.js → chunk-H2W2UNTN.js} +1 -1
- package/dist/{chunk-WV42KKEU.js → chunk-HLRLP6TQ.js} +1 -1
- package/dist/{chunk-6ZJ7ZFEX.js → chunk-HMM5FJJO.js} +1 -1
- package/dist/{chunk-GWJ76BLF.js → chunk-HOQEMPMQ.js} +2 -2
- package/dist/{chunk-2H3XNXL3.js → chunk-ICGHBZFZ.js} +1 -1
- package/dist/{chunk-7C6G4V43.js → chunk-IQODWB32.js} +1 -1
- package/dist/{chunk-MBXWXBDM.js → chunk-J2KSZUOO.js} +1 -1
- package/dist/{chunk-OESHJ4J2.js → chunk-JXKRO2ZJ.js} +2 -2
- package/dist/{chunk-RH4GCEFX.js → chunk-KHJXOFDM.js} +1 -1
- package/dist/chunk-KHQHVSZ6.js +5 -0
- package/dist/{chunk-ECFOND7B.js → chunk-KSZ72BSC.js} +1 -1
- package/dist/{chunk-TW3K2DKB.js → chunk-KXUSG5ZI.js} +1 -1
- package/dist/{chunk-YJIESLN6.js → chunk-LHDNJJGE.js} +1 -1
- package/dist/{chunk-Z25FKS3Y.js → chunk-M5PJQ5Y3.js} +1 -1
- package/dist/{chunk-VYQMCLKG.js → chunk-MFOH7EYR.js} +1 -1
- package/dist/{chunk-QGBLC4ZJ.js → chunk-MJBCBQC2.js} +1 -1
- package/dist/{chunk-2KS2YRIS.js → chunk-MMPFU2YC.js} +1 -1
- package/dist/{chunk-ZFFRHV5U.js → chunk-MR7CX5VT.js} +1 -1
- package/dist/{chunk-J4WS2SXT.js → chunk-MRP54NCJ.js} +1 -1
- package/dist/{chunk-JTCW76YG.js → chunk-MTNUZEO7.js} +1 -1
- package/dist/{chunk-XZW3TBOV.js → chunk-NJAHRITS.js} +1 -1
- package/dist/{chunk-FEF75YKV.js → chunk-NTGYFYBP.js} +1 -1
- package/dist/{chunk-DHF3VO2R.js → chunk-NTNAHN25.js} +1 -1
- package/dist/{chunk-KA7Q5IIC.js → chunk-NUQ423YE.js} +1 -1
- package/dist/{chunk-RLZA4VJT.js → chunk-OGWC3J3C.js} +1 -1
- package/dist/{chunk-5LTUYXMP.js → chunk-POYZ6SAI.js} +1 -1
- package/dist/{chunk-6NWPK2MS.js → chunk-QJIJC3KC.js} +1 -1
- package/dist/{chunk-YOFKDRY4.js → chunk-RFJAYURU.js} +1 -1
- package/dist/chunk-RGJIRS3B.js +2 -0
- package/dist/{chunk-4OSW2WEN.js → chunk-RZJVQUBA.js} +3 -3
- package/dist/{chunk-7LWXIRI3.js → chunk-SURF5Z7Y.js} +1 -1
- package/dist/chunk-TDPWFYTJ.js +2 -0
- package/dist/chunk-V3UE6RJP.js +2 -0
- package/dist/{chunk-MSK7AC4E.js → chunk-XSKLH2MC.js} +2 -2
- package/dist/{chunk-C3OGWCII.js → chunk-XWSAKVEY.js} +2 -2
- package/dist/{chunk-YVXC46DY.js → chunk-XXMNUJX4.js} +1 -1
- package/dist/{chunk-6MTVGARW.js → chunk-XZRIQ3GF.js} +1 -1
- package/dist/chunk-YSSTGJ7O.js +7 -0
- package/dist/chunk-Z2JSEL3I.js +4 -0
- package/dist/{chunk-7APDXIKI.js → chunk-ZNHXIRCM.js} +9 -9
- package/dist/{chunk-MJF3USZF.js → chunk-ZP4S5WGW.js} +1 -1
- package/dist/{chunk-3KN2UW37.js → chunk-ZPCU6546.js} +1 -1
- package/dist/{config-7WI6TBDV.js → config-QISRENF5.js} +1 -1
- package/dist/{cover-cmd-J2ZJUL6P.js → cover-cmd-SV3I23UM.js} +1 -1
- package/dist/{credentials-MX5ABDPF.js → credentials-OGLK7MPV.js} +1 -1
- package/dist/docx-convert-ZBVQO2LG.js +2 -0
- package/dist/{dossier-UVTGCL7T.js → dossier-KJSJPWOW.js} +1 -1
- package/dist/{evidence-TZYIOSPG.js → evidence-HDD7T7DX.js} +1 -1
- package/dist/{evolve-cmd-IDS5ZIUY.js → evolve-cmd-UE2BIMXK.js} +1 -1
- package/dist/{explain-VTRHEVUQ.js → explain-EBVIUS2X.js} +1 -1
- package/dist/{explain-cmd-NPKN63XL.js → explain-cmd-DBUTPZHA.js} +1 -1
- package/dist/{explain-cmd-R3WCNR2A.js → explain-cmd-NWIYH5MI.js} +1 -1
- package/dist/{extract-bind-CISTQFI3.js → extract-bind-6MQYKN3G.js} +3 -3
- package/dist/{extract-cmd-HG3DHHSL.js → extract-cmd-2RUIWFZG.js} +1 -1
- package/dist/{gaps-cmd-XLVUFSTY.js → gaps-cmd-CKCHH3HQ.js} +1 -1
- package/dist/{generate-headless-4VJMAHCU.js → generate-headless-TUA3HGRX.js} +2 -2
- package/dist/index.js +13 -13
- package/dist/ingest-FIIO67ZN.js +2 -0
- package/dist/ingest-cmd-CRMY46YC.js +7 -0
- package/dist/{interactive-bind-IXFRXBBL.js → interactive-bind-53FCRK34.js} +3 -3
- package/dist/{lifecycle-cmd-VTFZ3TF2.js → lifecycle-cmd-32LG364Q.js} +1 -1
- package/dist/{list-cmd-KXL4WQII.js → list-cmd-UTZ2PQUK.js} +1 -1
- package/dist/{list-commands-BJYJ34HT.js → list-commands-F53ZNYOZ.js} +1 -1
- package/dist/{logical-ids-LMBNMENR.js → logical-ids-I7B3VJEH.js} +1 -1
- package/dist/login-flow-D7KBR7XR.js +2 -0
- package/dist/{maintenance-cmd-UJG4LPWD.js → maintenance-cmd-BZAGSYGI.js} +1 -1
- package/dist/{persist-recorded-session-QR7RVAXR.js → persist-recorded-session-5ZFS5SMZ.js} +1 -1
- package/dist/pipeline-MX3ZR5B3.js +2 -0
- package/dist/readmodel-S5RAQH3F.js +2 -0
- package/dist/{reconcile-cmd-E2MMQM7Z.js → reconcile-cmd-4377PWF5.js} +1 -1
- package/dist/{recording-banner-QAIKLV6E.js → recording-banner-ZZUF2MGT.js} +1 -1
- package/dist/{require-project-folder-OANMHOVE.js → require-project-folder-NQBZFUPF.js} +1 -1
- package/dist/{revert-FRXNIP5R.js → revert-RQJE56HF.js} +1 -1
- package/dist/{review-cmd-2FCGP55U.js → review-cmd-7LXGYHHQ.js} +1 -1
- package/dist/run-2AIQUJ55.js +2 -0
- package/dist/run-YH5SCBYD.js +2 -0
- package/dist/{run-test-md-5E53A5DT.js → run-test-md-XOSCYVSS.js} +2 -2
- package/dist/{skill-installer-LGEIIQ4Q.js → skill-installer-VYIIWAK7.js} +1 -1
- package/dist/{spawner-6FHAXNOA.js → spawner-7KXVKAD5.js} +1 -1
- package/dist/tcg-generate-U6OCCS2E.js +2 -0
- package/dist/{testmd-actions-2OFH5GRJ.js → testmd-actions-RPALXRZK.js} +1 -1
- package/dist/token-refresh-S7CYBZTE.js +2 -0
- package/dist/{validate-basic-Z46MAH2G.js → validate-basic-LP3S5PK7.js} +1 -1
- package/dist/{version-check-64M5JQQ7.js → version-check-XP62HWLJ.js} +1 -1
- package/dist/{view-cmd-PG66UQK7.js → view-cmd-GQBFCPDL.js} +1 -1
- package/dist/{walk-session-7PM2RXEF.js → walk-session-YIKHE6PT.js} +1 -1
- package/package.json +6 -6
- package/dist/ChatSurface-PLXUGRBV.js +0 -8
- package/dist/SingleShotApp-Z2HGSZXG.js +0 -2
- package/dist/TestMdRunView-B4IZHRDT.js +0 -2
- package/dist/chat-controller-M4QYRH7Y.js +0 -2
- package/dist/chunk-26H3PDVN.js +0 -4
- package/dist/chunk-2OQLMW3F.js +0 -7
- package/dist/chunk-GLS46X7N.js +0 -5
- package/dist/chunk-JHHMXU76.js +0 -2
- package/dist/chunk-KFUZYEHX.js +0 -2
- package/dist/chunk-ZPENY2Q3.js +0 -4
- package/dist/docx-convert-IAX54REO.js +0 -2
- package/dist/ingest-UAIKHOB4.js +0 -2
- package/dist/ingest-cmd-7HJLRLMG.js +0 -4
- package/dist/login-flow-KW5T7WRJ.js +0 -2
- package/dist/pipeline-L6V24KGN.js +0 -2
- package/dist/readmodel-AGAPK2AI.js +0 -2
- package/dist/run-FYJZCWYS.js +0 -2
- package/dist/run-IOBBB7GN.js +0 -2
- package/dist/tcg-generate-CEDA6DZJ.js +0 -2
- package/dist/token-refresh-R75DGT4X.js +0 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as B,b as V,c as se}from"./chunk-
|
|
2
|
+
import{a as B,b as V,c as se}from"./chunk-HOQEMPMQ.js";import{a as j,b as N}from"./chunk-NJAHRITS.js";import{a as ne,b as oe}from"./chunk-2YQ6TW77.js";import{a as C,b as Y,e as M,f as te,m as re}from"./chunk-RKWJG3WW.js";import{a as L}from"./chunk-3AZTXJY4.js";import{a as ee}from"./chunk-WAOCHXJ5.js";import{a as Z}from"./chunk-GIMTSDNC.js";import{a as A}from"./chunk-RZ4F3BHX.js";import{a as H}from"./chunk-KHJXOFDM.js";import{a as O}from"./chunk-LHDNJJGE.js";import{y as h}from"./chunk-MMPFU2YC.js";import{a as F}from"./chunk-HCBYKLMW.js";import{a as k,b as g,i as Q}from"./chunk-C44QQJR4.js";import{a as X}from"./chunk-6YGTRKDT.js";import{e as v}from"./chunk-UR6MHSHU.js";var D=v(X(),1);import{existsSync as P,readFileSync as Je,rmSync as pe,unlinkSync as Ke}from"fs";import{resolve as G}from"path";import{promises as ie,realpathSync as ke}from"fs";import{homedir as be}from"os";import{join as q,parse as Te,relative as ae,resolve as ce}from"path";var le=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),R=class extends Error{constructor(s){super(`refusing to scan '${s}'. Run from your project root, or pass --root <dir>.`);this.cwd=s;this.name="HomeRefusedError"}};function ue(e){try{return ke(ce(e))}catch{return ce(e)}}function Ee(e){let r=ue(e),s=ue(be()),n=Te(r).root;if(process.platform==="win32"){let o=t=>t.toLowerCase();return o(r)===o(s)||o(r)===o(n)}return r===s||r===n}async function U(e){if(Ee(e.root))throw new R(e.root);let r=e.maxEntries??5e4,s=e.maxResults??5e3,n=new Set(e.ignore??[]),o=[],t=0,i=0,c=!1,f,l=[e.root];for(;l.length>0&&!c;){let a=l.shift(),m;try{m=await ie.readdir(a,{withFileTypes:!0})}catch{continue}i++;for(let b of m){if(t++,t>r){c=!0,f="max_entries";break}let w=b.name,E=q(a,w);if(b.isDirectory()){if(le.has(w)||w.startsWith(".")||w.startsWith("output-")||n.has(w))continue;l.push(E)}else if(b.isFile()&&w.endsWith("_test.md")&&(o.push({path:E,relPath:ae(e.root,E),source:"cwd"}),o.length>=s)){c=!0,f="max_results";break}}e.onProgress?.(i,o.length)}if(!c){let m=[{dir:q(e.root,".testmuai","tests"),depth:0}];for(;m.length>0&&!c;){let{dir:b,depth:w}=m.shift(),E;try{E=await ie.readdir(b,{withFileTypes:!0})}catch{continue}i++;for(let u of E){if(t++,t>r){c=!0,f="max_entries";break}let x=u.name,y=q(b,x);if(u.isDirectory()){if(w>=20||x.startsWith(".")||x.startsWith("output-")||le.has(x))continue;m.push({dir:y,depth:w+1})}else if(u.isFile()&&x.endsWith("_test.md")&&(o.push({path:y,relPath:ae(e.root,y),source:"tests-dir"}),o.length>=s)){c=!0,f="max_results";break}}}}return{results:o,aborted:c,abortReason:f,dirsScanned:i}}import{readFileSync as Se}from"fs";function W(e){try{return re(e,Se(e,"utf8")).global.tags??[]}catch{return[]}}import{mkdirSync as ve,writeFileSync as Re}from"fs";import{join as Pe}from"path";function de(e,r){return`Basic ${Buffer.from(`${e}:${r}`).toString("base64")}`}async function Me(e){let r=ne({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId,codeExport:{enabled:!0,language:e.language,skipValidation:e.skipValidation}}),s=await A(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:de(e.auth.username,e.auth.access_key)},body:JSON.stringify(r.body)});if(!s.ok)throw new Error(`code-export trigger failed: ${s.status} ${await s.text()}`);e.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:e.testcaseId})}async function De(e){let r=oe({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId}),s=e.pollIntervalMs??5e3,n=e.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let t=await A(r,{headers:{authorization:de(e.auth.username,e.auth.access_key),accept:"application/json"}});if(!t.ok){await new Promise(l=>setTimeout(l,s));continue}let c=(await t.json()).data?.find(l=>l.code_name==="kane-cli-trigger");if(!c){await new Promise(l=>setTimeout(l,s));continue}let f=(c.status??"").toLowerCase();if(f==="in progress"||f==="in_progress"||f==="pending"){await new Promise(l=>setTimeout(l,s));continue}if(!c.url||c.url.length===0)throw new Error(`code-export status=${c.status} but no files returned`);ve(e.outDir,{recursive:!0});for(let l of c.url){let a=Pe(e.outDir,l.file_name),m=await A(l.file_url);if(!m.ok){e.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:l.file_name,status:m.status});continue}let b=await m.text();Re(a,b,"utf-8")}return e.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:e.outDir,file_count:c.url.length}),e.outDir}throw new Error("code-export polling timed out")}async function fe(e){return await Me(e),await De(e)}var T=v(X(),1);import{existsSync as $e,readFileSync as Ce}from"fs";var p=v(F(),1);function Ie(e){B(e);let r=M(e);if(!$e(r))return null;try{return JSON.parse(Ce(r,"utf8"))}catch{return{}}}function Fe(e){return e===null?"never_run":e.testcase_id?"synced":"local_only"}function Oe(e){return e==="synced"?"\u2601":e==="local_only"?"\u25A3":"\u25CB"}function Ae(e){return e==="tests-dir"?"\u2726":" "}function Le(e,r){return r==="all"?!0:r==="synced"?e.status==="synced":r==="local"?e.status==="local_only":r==="never_run"?e.status==="never_run":r==="cli"?e.source==="tests-dir":r==="hand"?e.source==="cwd":!0}var z=["all","synced","local","never_run","cli","hand"];function Be(e){let r=z.indexOf(e);return z[(r+1)%z.length]}function me({root:e,currentOrgId:r,onSelect:s,onCancel:n}){let[o,t]=(0,T.useState)([]),[i,c]=(0,T.useState)(null),[f,l]=(0,T.useState)(!0),[a,m]=(0,T.useState)("all");(0,T.useEffect)(()=>{(async()=>{try{let u=await U({root:e}),x=[];for(let y of u.results){let K=Ie(y.path);K?.org_id!==void 0&&K.org_id!==r||x.push({path:y.path,relPath:y.relPath,name:C(y.path),status:Fe(K),source:y.source,tags:W(y.path)})}t(x),l(!1)}catch(u){u instanceof R,c(u.message),l(!1)}})()},[e,r]);let b=(0,T.useMemo)(()=>o.filter(u=>Le(u,a)).map(u=>({id:u.path,label:`${Oe(u.status)} ${Ae(u.source)} ${u.relPath}${u.tags.length>0?` [${u.tags.join(", ")}]`:""}`})),[o,a]),w=(0,T.useMemo)(()=>Ne(a,o),[a,o]);if(i)return(0,p.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.red,paddingX:2,paddingY:1,children:[(0,p.jsx)(g,{color:h.red,bold:!0,children:"testmd"}),(0,p.jsx)(k,{marginTop:1,children:(0,p.jsx)(g,{color:h.red,children:i})})]});let E=a==="all"?"all":je(a);return(0,p.jsx)(Z,{title:`testmd \xB7 filter: ${E}`,items:b,loading:f,itemNoun:"tests",onSelect:u=>{let x=o.find(y=>y.path===u.id);x&&s(x)},onCancel:n,onTab:()=>m(u=>Be(u)),extraHint:"cycle filter",footer:w})}function je(e){return e==="synced"?"synced (\u2601)":e==="local"?"local (\u25A3)":e==="never_run"?"never run (\u25CB)":e==="cli"?"cli-generated (\u2726)":e==="hand"?"hand-written":"all"}function Ne(e,r){let s={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?h.orange:h.dim;return(0,p.jsxs)(k,{flexDirection:"column",children:[(0,p.jsx)(g,{color:h.dim,children:"legend:"}),(0,p.jsxs)(k,{children:[(0,p.jsx)(g,{color:n(e==="synced"),children:` \u2601 synced (${s.synced}) `}),(0,p.jsx)(g,{color:n(e==="local"),children:`\u25A3 local (${s.local}) `}),(0,p.jsx)(g,{color:n(e==="never_run"),children:`\u25CB never run (${s.never})`})]}),(0,p.jsxs)(k,{children:[(0,p.jsx)(g,{color:n(e==="cli"),children:` \u2726 cli-generated (${s.cli}) `}),(0,p.jsx)(g,{color:n(e==="hand"),children:` hand-written (${s.hand})`})]})]})}var I=v(X(),1);import{existsSync as Ue,readFileSync as We}from"fs";var d=v(F(),1);function ge({path:e,relPath:r,onAction:s,onBack:n,onView:o}){let[t,i]=(0,I.useState)(null),[c,f]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let a=M(e);if(Ue(a))try{i(JSON.parse(We(a,"utf8")))}catch{i(null)}},[e]),Q((a,m)=>{if(m.escape){if(c){f(!1);return}n();return}if(c){a==="y"||a==="Y"?(f(!1),s("delete")):(a==="n"||a==="N")&&f(!1);return}a==="r"&&s("run"),a==="e"&&t?.testcase_id&&s("export"),a==="d"&&f(!0),a==="v"&&o&&o()});let l=({k:a,v:m})=>m?(0,d.jsxs)(g,{children:[(0,d.jsx)(g,{color:h.dim,children:a.padEnd(14)}),m]}):null;return(0,d.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.orange,paddingX:2,paddingY:1,children:[(0,d.jsx)(g,{color:h.orange,bold:!0,children:r}),(0,d.jsx)(k,{marginTop:1,flexDirection:"column",children:t?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l,{k:"test_id",v:t.test_id}),(0,d.jsx)(l,{k:"testcase_id",v:t.testcase_id}),(0,d.jsx)(l,{k:"project_id",v:t.project_id}),(0,d.jsx)(l,{k:"folder_id",v:t.folder_id}),(0,d.jsx)(l,{k:"org_id",v:t.org_id}),(0,d.jsx)(l,{k:"session_name",v:t.session_name}),(0,d.jsx)(l,{k:"commit_id",v:t.commit_id})]}):(0,d.jsx)(g,{color:h.dim,children:"(never run \u2014 no meta.json)"})}),c?(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(g,{color:h.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(g,{color:h.dim,children:["[r] run [e] export",t?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function $(e){B(e);let r=M(e);if(!P(r))return null;try{return JSON.parse(Je(r,"utf8"))}catch{return null}}function he(e,r){return!e||e.org_id===void 0?!0:e.org_id===r}function J(e,r){return he(e,r)?null:(process.stderr.write(`error: this test belongs to org ${e.org_id}; you are logged in as org ${r}.
|
|
3
3
|
Switch profiles with \`kane-cli profiles switch\` to act on it.
|
|
4
4
|
`),2)}async function Ut(e={}){let r=!!process.stdin.isTTY&&!e.json,s=new O,n=new L;await V({isInteractive:r,creds:s,config:n});let o=s.getDefaultEnv()??"prod";try{let t=await N({creds:s,env:o,log:()=>{}});return t.resolvedCreds?.org_id===void 0?(process.stderr.write("error: TMS did not return an org_id. Run `kane-cli login` again.\n"),{ok:!1,code:2}):{ok:!0,orgId:String(t.resolvedCreds.org_id)}}catch(t){if(t instanceof j)return process.stderr.write("error: not authenticated. Run `kane-cli login` first.\n"),{ok:!1,code:2};throw t}}async function Wt(e,r){if(process.stdin.isTTY&&!e.json)return await Ye(r,e.root);let s=e.root??process.cwd(),n;try{n=await U({root:s,ignore:e.ignore})}catch(o){if(o instanceof R)return process.stderr.write(`error: ${o.message}
|
|
5
5
|
`),2;throw o}for(let o of n.results){let t=$(o.path);if(!he(t,r))continue;let i={path:o.relPath.startsWith(".")?o.relPath:`./${o.relPath}`,name:C(o.path),has_meta:t!==null,source:o.source,synced:!!t?.testcase_id,tags:W(o.path)};t&&(t.test_id&&(i.test_id=t.test_id),t.testcase_id&&(i.testcase_id=t.testcase_id),t.org_id&&(i.org_id=t.org_id),t.project_id&&(i.project_id=t.project_id),t.folder_id&&(i.folder_id=t.folder_id)),process.stdout.write(JSON.stringify(i)+`
|
|
6
6
|
`)}return n.aborted&&process.stderr.write(`warn: walk aborted (${n.abortReason}). Pass --root or --ignore to narrow.
|
|
7
|
-
`),0}var _e=-1001,ye=-1002,we=-1003,_={action:null,path:null};function Xe(e,r){return _.action=e,_.path=r,e==="run"?_e:e==="export"?ye:we}function He({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(me,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(ge,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Xe(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function Ye(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:c}=n(D.default.createElement(He,{root:s,currentOrgId:e,onComplete:f=>{i(),t(f)}}),{stdout:process.stderr,exitOnCtrlC:!0});c().then(()=>t(0)).catch(()=>t(0))});if(o===_e&&_.path){let{runTestMdFile:t}=await import("./run-test-md-
|
|
7
|
+
`),0}var _e=-1001,ye=-1002,we=-1003,_={action:null,path:null};function Xe(e,r){return _.action=e,_.path=r,e==="run"?_e:e==="export"?ye:we}function He({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(me,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(ge,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Xe(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function Ye(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:c}=n(D.default.createElement(He,{root:s,currentOrgId:e,onComplete:f=>{i(),t(f)}}),{stdout:process.stderr,exitOnCtrlC:!0});c().then(()=>t(0)).catch(()=>t(0))});if(o===_e&&_.path){let{runTestMdFile:t}=await import("./run-test-md-XOSCYVSS.js"),i=await t(_.path,{});return _.action=null,_.path=null,i}if(o===ye&&_.path){let t=await qe(_.path,{},e);return _.action=null,_.path=null,t}if(o===we&&_.path){let t=await Ve(_.path,!0,e);return _.action=null,_.path=null,t}return o}async function Jt(e,r){let s=G(e);if(!P(s))return process.stderr.write(`error: file not found: ${s}
|
|
8
8
|
`),2;let n=$(s),o=J(n,r);if(o!==null)return o;let t={path:s,name:C(s),has_meta:n!==null};return n&&(n.commit_id&&(t.commit_id=n.commit_id),n.test_id&&(t.test_id=n.test_id),n.testcase_id&&(t.testcase_id=n.testcase_id),n.project_id&&(t.project_id=n.project_id),n.folder_id&&(t.folder_id=n.folder_id),n.org_id&&(t.org_id=n.org_id),n.session_name&&(t.session_name=n.session_name)),process.stdout.write(JSON.stringify(t)+`
|
|
9
9
|
`),0}async function Ve(e,r,s){let n=G(e);if(!P(n))return process.stderr.write(`error: file not found: ${n}
|
|
10
10
|
`),2;let o=$(n),t=J(o,s);if(t!==null)return t;if(!r)return process.stderr.write(`error: refusing to delete without --yes.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-5Y2G4NC7.js";import{y as o}from"./chunk-
|
|
2
|
+
import{a}from"./chunk-5Y2G4NC7.js";import{y as o}from"./chunk-MMPFU2YC.js";import{a as n}from"./chunk-HCBYKLMW.js";import{b as t}from"./chunk-C44QQJR4.js";import{a as s}from"./chunk-6YGTRKDT.js";import{e as r}from"./chunk-UR6MHSHU.js";var l=r(s(),1);var m=r(n(),1),i=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function b({active:e=!0}){let[p,c]=(0,l.useState)(0);return a(()=>{c(f=>(f+1)%i.length)},e?80:null),(0,m.jsx)(t,{color:o.orange,children:e?i[p]:"\u25CF"})}export{b as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as t}from"./chunk-
|
|
2
|
+
import{a as t}from"./chunk-4CJ55EUY.js";async function l(e){let o=e.credentials.expires_at,i=e.thresholdSeconds??300;if(o-Date.now()/1e3>=i)return null;let r=e.creds.loadClient(e.profile,e.env);if(!r)return null;let n=await new t(e.env).refreshToken(e.credentials.refresh_token,r.client_id),s=Math.floor(Date.now()/1e3)+n.expires_in;return e.creds.saveCredentials(e.profile,e.env,{access_token:n.access_token,refresh_token:n.refresh_token,expires_at:s,scope:n.scope}),{accessToken:n.access_token,refreshToken:n.refresh_token,expiresAt:s,scope:n.scope}}export{l as a};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as O}from"./chunk-TDPWFYTJ.js";import{a as b}from"./chunk-3AZTXJY4.js";import{a as N}from"./chunk-KHJXOFDM.js";import{e as A,j as w}from"./chunk-MMPFU2YC.js";import{spawn as U,execSync as B}from"child_process";import{appendFileSync as L,existsSync as E,mkdirSync as K}from"fs";import{homedir as G}from"os";import{join as D,resolve as t,dirname as C}from"path";import{fileURLToPath as W}from"url";import{createInterface as P}from"readline";async function*T(e){let n=P({input:e,crlfDelay:1/0});for await(let l of n){let r=l.trim();if(r)try{let a=JSON.parse(r);a&&typeof a.type=="string"&&(yield a)}catch{}}}function h(e){return e==="action"?{set:{V16_AGENT_ENABLE_ALL_BLOCKERS:"true",V16_BIFURCATION_PHASES:"1"},unset:["V16_NETWORK_WS","V16_NETWORK_SSE"]}:{set:{V16_BIFURCATION_PHASES:"1"},unset:["V16_AGENT_ENABLE_ALL_BLOCKERS","V16_NETWORK_WS","V16_NETWORK_SSE"]}}function M(e){return e?{set:{},unset:["V16_AGENT_SKIP_CP_FINAL"]}:{set:{V16_AGENT_SKIP_CP_FINAL:"true"},unset:[]}}function I(e){return e==="dom"?{set:{V16_AGENT_ENABLE_TEXTUAL_VISUAL:"true"},unset:[]}:{set:{},unset:["V16_AGENT_ENABLE_TEXTUAL_VISUAL"]}}var o=C(W(import.meta.url));function j(){for(let e of["python3","python"])try{return B(`${e} --version`,{stdio:"ignore"}),e}catch{}return null}function $(){let n=process.platform==="win32"?"v16-runner.exe":"v16-runner",l={"darwin-arm64":["@testmuai/kane-cli-darwin-arm64","@lambdatestincprivate/kane-cli-darwin-arm64"],"darwin-x64":["@testmuai/kane-cli-darwin-x64","@lambdatestincprivate/kane-cli-darwin-x64"],"linux-x64":["@testmuai/kane-cli-linux-x64","@lambdatestincprivate/kane-cli-linux-x64"],"linux-arm64":["@testmuai/kane-cli-linux-arm64","@lambdatestincprivate/kane-cli-linux-arm64"],"win32-x64":["@testmuai/kane-cli-win-x64","@lambdatestincprivate/kane-cli-win-x64"]},r=`${process.platform}-${process.arch}`,a=l[r];if(a)for(let s of a){let m=[t(o,"..","node_modules",s,"bin",n),t(o,"..","..","node_modules",s,"bin",n),t(o,"..","..","..","node_modules",s,"bin",n),t(o,"..","..","..","..","node_modules",s,"bin",n)];for(let u of m)if(E(u))return{cmd:u,args:[]}}let _=[t(o,"bin",n),t(o,"..","bin",n),t(o,"..","..","..","..","v16-runner","dist",n),t(o,"..","..","..","v16-runner","dist",n),t(o,"..","..","v16-runner","dist",n),t(process.cwd(),"v16-runner","dist",n),t(process.cwd(),"..","v16-runner","dist",n)];for(let s of _)if(E(s))return{cmd:s,args:[]};let v=[t(o,"..","..","v16-runner"),t(o,"..","..","..","..","v16-runner"),t(o,"..","..","..","v16-runner"),t(process.cwd(),"v16-runner"),t(process.cwd(),"..","v16-runner")];for(let s of v)if(E(t(s,"main.py"))){for(let u of[t(s,".venv","bin","python"),t(s,"..",".venv","bin","python"),t(s,"..","browser-agent",".venv","bin","python")])if(E(u))return{cmd:u,args:["main.py"],cwd:s};let m=j();if(m)return{cmd:m,args:["main.py"],cwd:s}}return null}function ie(e,n){let l=$();if(!l)throw new Error("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available.");process.env.KANE_SPAWN_DEBUG&&process.stderr.write(`[spawn-debug] ${JSON.stringify(l)}
|
|
3
|
+
`);let r={...process.env};n?.environment&&(r.TESTMUAI_ENV=n.environment),r.TESTMUAI_SOURCE="kane-cli",process.platform==="win32"&&(r.PYTHONIOENCODING="utf-8");let a=N(n?.environment);r.V16_SERVER_API_HOST=a.v16ServerHost,r.ATMS_URL=a.tmsBaseUrl.replace(/\/api\/?$/,""),e.username&&e.access_key&&(r.LT_USERNAME=e.username,r.LT_ACCESS_KEY=e.access_key),e.session_id&&(r.TESTMUAI_SESSION_ID=e.session_id);let _=h(n?.mode??"testing");Object.assign(r,_.set);for(let i of _.unset)delete r[i];let v=new b().load(),s=I(n?.assertionMode??(v.assertion_mode==="visual"?"visual":"dom"));Object.assign(r,s.set);for(let i of s.unset)delete r[i];let m=n?.finalValidation??v.final_validation,u=M(m);Object.assign(r,u.set);for(let i of u.unset)delete r[i];let g=O();g!==void 0&&e.ap_mode===void 0&&(e.ap_mode=g),e.telemetry_proxy_url===void 0&&process.env.KANE_TELEMETRY!=="0"&&(e.telemetry_proxy_url=w),e.media_upload===void 0&&e.org_id&&e.username&&e.access_key&&(e.media_upload={url:a.shareApiBaseUrl.replace(/\/$/,"")+"/mfs/v1.0/media/upload",artefacts_host:a.mediaArtefactsHost,org_id:e.org_id,media_dir:A});let d=U(l.cmd,l.args,{stdio:["pipe","pipe","pipe"],env:r,cwd:l.cwd});d.stdin.on("error",()=>{}),d.stdin.write(JSON.stringify(e)+`
|
|
4
|
+
`);let p=e.session_id?D(G(),".testmuai","kaneai","sessions",e.session_id,"runner-stderr.log"):null;if(p)try{K(C(p),{recursive:!0}),L(p,`--- runner spawn ${new Date().toISOString()} run_index=${e.run_index} ---
|
|
5
|
+
`)}catch{}let S=1e5,f="";d.stderr.on("data",i=>{if(f+=i.toString(),f.length>S&&(f=f.slice(-S)),p)try{L(p,i)}catch{}}),d.on("error",i=>{n?.log?.("error","RUNNER_SPAWN_ERROR","Runner spawn error",{error:i.message})});let R=null,y=null,k=new Promise(i=>{d.on("close",(c,x)=>{R=c,y=x?String(x):null,n?.log?.("info","RUNNER_EXIT","Runner exited",{code:c,signal:y??"none"}),i({code:c,signal:y})})}),V=T(d.stdout);return{child:d,events:V,sendUserResponse(i){let c=JSON.stringify({type:"user_response",answer:i});try{d.stdin.write(c+`
|
|
6
|
+
`)}catch{}},sendCancel(i){let c=JSON.stringify({type:"cancel",reason:i});try{d.stdin.write(c+`
|
|
7
|
+
`)}catch{}},cancel(){d.kill("SIGTERM")},get stderr(){return f},get exitCode(){return R},get exitSignal(){return y},exited:k}}export{$ as a,ie as b};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{b as B,d as F}from"./chunk-V3UE6RJP.js";import{b as M}from"./chunk-DNNZ353O.js";import{a as k}from"./chunk-Q2F5QB2W.js";import{b as w,c as p}from"./chunk-NVGBE2DR.js";import{a as A}from"./chunk-7E24OCGX.js";import{a as N,c as L}from"./chunk-6HYW5RFX.js";import{e as R}from"./chunk-J2KSZUOO.js";import{a as O,d as C,f as $}from"./chunk-5YPBPZUR.js";import{existsSync as V,mkdirSync as H,readFileSync as K,writeFileSync as Z}from"fs";import{basename as X,extname as U,join as Y}from"path";var T=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function z(e){return typeof e=="string"&&e!=="."&&e!==".."&&T.test(e)}function S(e){if(!z(e))throw new Error(`unsafe logical_id: ${JSON.stringify(e)} \u2014 must match ${String(T)} (no path separators)`)}function q(e,r,t){return k({source_id:e,source_cid:"sha256:".padEnd(71,"0"),doc_kind:r,numbered_text:M(t)})}var P=2e3;function Q(e){let t=X(e,U(e)).toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^[^a-z0-9]+/,"");return S(t),t}function me(e){let r=/^(.*?)[-_.]?v?\d+$/.exec(e);if(!r)return null;let t=(r[1]??"").replace(/[-_.]+$/,"");return t.length>0&&t!==e?t:null}function j(e){let r=Y(e,"meta.json");V(r)||(H(e,{recursive:!0}),Z(r,JSON.stringify({schema:O,canonicalizer:"v1"},null,2)+`
|
|
3
|
+
`))}async function fe(e){let{contextDir:r,filePath:t,asId:o,confirmSameSource:f,converters:b}=e;j(r);let n=K(t),s=F(t);if(!s.ok)throw new Error(`UNSUPPORTED_MEDIA: ${U(t)} \u2014 supported: ${s.allowlist.join(" ")}`);if(n.byteLength>s.media.maxBytes)throw new Error(`FILE_TOO_LARGE: ${n.byteLength} bytes > ${s.media.maxBytes} cap for ${s.media.media_type}`);if(s.media.sniff&&!s.media.sniff(n)){let c=s.media.sniffFail?.(n);throw new Error(c??`MEDIA_SNIFF_MISMATCH: ${t} does not look like ${s.media.media_type}`)}let d;return o!==void 0?(S(o),d=o):d=Q(t),W({contextDir:r,bytes:n,media:s.media,sourceId:d,label:t,confirmSameSource:f,converters:b})}async function W(e){let{contextDir:r,bytes:t,media:o,confirmSameSource:f,converters:b}=e,n=e.sourceId,s=e.label??n;if(j(r),t.byteLength>o.maxBytes)throw new Error(`FILE_TOO_LARGE: ${t.byteLength} bytes > ${o.maxBytes} cap for ${o.media_type}`);let d=[],c=B[o.kind];if(o.cite==="verbatim"&&!c){try{new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch{throw new Error(`ENCODING_UNSUPPORTED: ${s} is not valid UTF-8 \u2014 re-save it as UTF-8 and re-ingest`)}t.toString("utf8").split(`
|
|
4
|
+
`).some(a=>a.length>P)&&d.push(`long line detected (> ${P} chars) \u2014 anchors lose granularity; consider pretty-printing before ingest`)}let l=w(t),g=A(r),u=g.heads.get(n),G=u!=null?g.getNode(u)?.content:void 0;if(u!=null&&G?.blob===l)return{status:"unchanged",source_id:n,cid:u,blob:l};if(u==null){for(let[a,i]of g.heads.entries())if(!(a===n||i==null)&&g.getNode(i)?.content.blob===l){if(f&&await f(a))return{status:"unchanged",source_id:a,cid:i,blob:l};break}}let I={},y,m=null,h=null;if(c){let a=b?.[c];if(!a)throw new Error(`${c.toUpperCase()}_CONVERTER_MISSING: ${c} ingestion requires the converter \u2014 the command layer wires it`);let i=await a(t);m=Buffer.from(i.projection,"utf8");let x=q(n,o.kind,m);if(x>4e5)throw new Error(`PROJECTION_TOO_LARGE: serialized source payload ${x} bytes > ${4e5} \u2014 split the document and re-ingest`);I={text_blob:w(m),...i.inventory.length>0?{images:i.inventory}:{},converter:i.converter},h=i.blobs,y={kind:o.kind,...i.pages!==void 0?{pages:i.pages}:{},delivered:i.delivered.length,omitted:i.inventory.length-i.delivered.length}}if(p(r,t),m!==null&&p(r,m),h!==null)for(let[,a]of h)p(r,a);let _=L(n,l),v=$("source",_);if(v.length>0)throw new Error(`source node fails ${v[0].code}: ${v[0].detail}`);let E=N("source",_);return R(r,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:E,label:C.SOURCE,content:_}],edges:[],review:[],supersessions:[],media:{[n]:{format:o.kind,media_type:o.media_type,anchors_supported:c?["L-L","img#ref"]:o.cite==="verbatim"?["L-L"]:[],...I}},source_head_moves:{[n]:E}}),{status:u!=null?"versioned":"created",source_id:n,cid:E,blob:l,...d.length?{warnings:d}:{},...y?{composite:y}:{}}}export{S as a,q as b,Q as c,me as d,fe as e,W as f};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as m}from"./chunk-L5LI2JF4.js";import{c as
|
|
3
|
-
`)}function
|
|
4
|
-
\u26A0 Failed to create ${
|
|
2
|
+
import{a as _}from"./chunk-TDPWFYTJ.js";import{b as m}from"./chunk-L5LI2JF4.js";import{c as h}from"./chunk-MMPFU2YC.js";import{randomUUID as F}from"crypto";import{mkdirSync as A,writeFileSync as v,appendFileSync as O,existsSync as b}from"fs";import{join as u}from"path";import{writeFileSync as x,mkdirSync as I,existsSync as j}from"fs";import{join as p,relative as L}from"path";function f(n){let t=Object.keys(n.frontmatter).length>0?m(n.frontmatter).trimEnd():"",s=["---"];return t&&s.push(t),s.push("---",""),s.push(`# ${n.heading}`,""),n.steps.forEach((i,r)=>{s.push(`## Step ${r+1}`,i,"")}),s.join(`
|
|
3
|
+
`)}function T(n,e){let t={},s={},i=e;for(let[r,l]of Object.entries(n)){if(r.startsWith("global.")||r.startsWith("secrets.user.")||r.startsWith("environment.")){let o=r.startsWith("secrets.user.");t[r]={value:l.value,secret:o,syntax:`{{${r}}}`,type:o?"secret":r.startsWith("environment.")?"environment":"global"},s[r]=r;continue}if(l.secret){let o=`secrets.user.${r}`;t[o]={value:l.value,secret:!0,syntax:`{{secrets.user.${r}}}`,type:"secret"},s[r]=o,i=i.replaceAll(`{{${r}}}`,`{{secrets.user.${r}}}`)}else{let o=`global.${r}`;t[o]={value:l.value,secret:!1,syntax:`{{global.${r}}}`,type:"global"},s[r]=o,i=i.replaceAll(`{{${r}}}`,`{{global.${r}}}`)}}return{variables:t,objective:i,keyMap:s}}var w=/\{\{\s*(?:global|secrets\.user|environment)\.([^{}]+?)\s*\}\}/g;function c(n){return typeof n!="string"||!n.includes("{{")?n:n.replace(w,"{{$1}}")}function d(n){if(typeof n=="string")return c(n);if(Array.isArray(n))return n.map(e=>d(e));if(n&&typeof n=="object"){let e={};for(let[t,s]of Object.entries(n))e[t]=d(s);return e}return n}var N=new Set(["username","access_key","oauth","profile","project_id","folder_id"]),$=new Set(["model","env"]),g=class{constructor(e){this.opts=e}objectives=[];flushed=!1;lastWrittenPath=null;lastCollisionSuffixed=!1;appendObjective(e){this.objectives.push(e)}flush(){if(this.flushed||(this.flushed=!0,this.objectives.length===0))return;let e=this.opts.getName();if(!e)return;let t=p(this.opts.cwd,".testmuai","tests");try{I(t,{recursive:!0})}catch(a){process.stderr.write(`
|
|
4
|
+
\u26A0 Failed to create ${L(this.opts.cwd,t)}/
|
|
5
5
|
${a.message}
|
|
6
6
|
Your test recording was NOT saved.
|
|
7
7
|
|
|
8
|
-
`);return}let s=
|
|
8
|
+
`);return}let s=p(t,`${e}_test.md`),i=2,r=!1;for(;j(s);)s=p(t,`${e}-${i}_test.md`),i++,r=!0;let l=d(E(this.opts.getResolvedGlobal())),o=f({frontmatter:l,heading:`Session: ${e}`,steps:this.objectives.map(c)});try{x(s,o,"utf8")}catch(a){process.stderr.write(`
|
|
9
9
|
\u26A0 Failed to save your test recording.
|
|
10
10
|
${a.message}
|
|
11
11
|
Path: ${s}
|
|
12
12
|
|
|
13
|
-
`);return}this.lastWrittenPath=s,this.lastCollisionSuffixed=r}};function
|
|
14
|
-
`)}}start(e){if(!this._started){this._started=!0,this._model=e.model,this._environment=e.environment,this._profile=e.profile,this._startedAt=new Date().toISOString();try{
|
|
15
|
-
`)}catch{}this._log(`SESSION START session_id=${this.sessionId}`),this._log(`CONFIG model=${e.model} env=${e.environment} profile=${e.profile}`),this._earlyLogBuffer.push({level:"info",event:"SESSION_START",message:"Session started",context:{session_id:this.sessionId}},{level:"info",event:"CONFIG",message:"Session config",context:{model:e.model,environment:e.environment,profile:e.profile}})}}setPlan(e){this._plan=e;let t={level:"info",event:"SESSION_INFO",message:"Session info",context:{session_id:this.sessionId,plan:e??null}};this._remoteLogger?this._remoteLogger.log(t.level,t.event,t.message,t.context):this._earlyLogBuffer.push(t)}get plan(){return this._plan}setRemoteLogger(e){this._remoteLogger=e;for(let t of this._earlyLogBuffer)e.log(t.level,t.event,t.message,t.context);this._earlyLogBuffer=[]}get hasRemoteLogger(){return this._remoteLogger!==null}setAuteurVariables(e){Object.assign(this._auteurVariables,e)}get auteurVariables(){return this._auteurVariables}setScreenshotSas(e){this._screenshotSas=e}get screenshotSas(){return this._screenshotSas}get screenshotBaseUrl(){return this._screenshotSas?`${this._screenshotSas.base_url}/${this._screenshotSas.container}`:""}get startedAt(){return this._startedAt||new Date().toISOString()}log(e,t,s,i){if(t===void 0){this._log(e);let o=e.indexOf(" "),a=o>0?e.slice(0,o):e,
|
|
16
|
-
`),this.flushRecorder(),this._recorder=null}nextRunIndex(){return this._nextIndex}addRunResult(e,t){this.runs.push(e),this._nextIndex+=t??1,this._recordingEnabled&&this._recorder?.appendObjective(e.objective)}getContext(){return{prior_runs:this.runs.map(e=>({index:e.index,objective:e.objective,summary:e.summary,status:e.status,memory:e.context.memory,variables:e.context.variables,pointer:e.context.pointer}))}}addFlow(e){let t={...e,index:this._flows.length+1};return this._flows.push(t),t}getFlows(){return[...this._flows]}getFlow(e){return this._flows.find(t=>t.index===e)}clearFlows(){this._flows=[]}recordStepRun(e){this._stepRunRecords.push(e)}getStepRunRecords(){return[...this._stepRunRecords]}getRunsAsStepRecords(){return this.runs.map((e,t)=>({testmdStepIndex:t+1,runIndex:e.index,totalRunDirs:e.run_dirs?.length??1}))}snapshot(){return{runsLen:this.runs.length,nextRunIndex:this._nextIndex,stepRunRecordsLen:this._stepRunRecords.length}}rollback(e){this.runs.length=e.runsLen,this._nextIndex=e.nextRunIndex,this._stepRunRecords.length=e.stepRunRecordsLen}setTestId(e){this._testId=e}get testId(){return this._testId}setTestcaseId(e){this._testcaseId=e}get testcaseId(){return this._testcaseId}setProjectId(e){this._projectId=e}setOrgId(e){this._orgId=e}get orgId(){return this._orgId}setUserIdentity(e,t){e&&(this._userName=e),t&&(this._userEmail=t)}get userName(){return this._userName}get userEmail(){return this._userEmail}setFirstRun(e,t){this._firstObjective||(this._firstObjective=e,this._firstUrl=t)}get firstObjective(){return this._firstObjective}get firstUrl(){return this._firstUrl}getRunDirs(){let e=[];for(let t of this.runs)t.run_dirs&&t.run_dirs.length>0?e.push(...t.run_dirs):t.run_dir&&e.push(t.run_dir);return e}getRunObjectives(){let e=[];for(let t of this.runs)t.flow_objectives&&t.flow_objectives.length>0?e.push(...t.flow_objectives):e.push(t.objective);return e}getRunMetadata(){let e=[];for(let t of this.runs)if(t.perFlowMetadata&&t.perFlowMetadata.length>0)e.push(...t.perFlowMetadata);else{let s={resultCode:t.resultCode,reasonCode:t.reasonCode,errorMessage:t.status==="failed"?t.summary??null:null,summary:t.summary,oneLiner:t.oneLiner},i=t.run_dirs?.length??1;for(let r=0;r<i;r++)e.push(s)}return e}setUploadStatus(e,t){this._uploadStatus=e,this._uploadAttempts+=1,this._uploadError=t??null}_log(e,t){if(!(!this._started||!
|
|
17
|
-
`)}catch{}}};export{
|
|
13
|
+
`);return}this.lastWrittenPath=s,this.lastCollisionSuffixed=r}};function E(n){let e={};for(let[t,s]of Object.entries(n))N.has(t)||$.has(t)||(e[t]=s);return e}var D=u(h,"sessions"),R=class{sessionId;sessionDir;runs=[];_flows=[];_nextIndex=0;_started=!1;_testId=null;_testcaseId=null;_projectId=null;_orgId=null;_userName=null;_userEmail=null;_uploadStatus="pending";_uploadAttempts=0;_uploadError=null;_firstObjective=null;_firstUrl=null;_auteurVariables={};_screenshotSas=null;_model="";_environment="";_profile=null;_plan=null;_startedAt="";_remoteLogger=null;_earlyLogBuffer=[];_recorder=null;_resolvedGlobal={};_sessionName=null;_recordingEnabled=!0;_stepRunRecords=[];constructor(e){this.sessionId=F();let t=e?.baseDir?u(e.baseDir,"sessions"):D;this.sessionDir=u(t,this.sessionId)}setResolvedGlobal(e){this._resolvedGlobal={...this._resolvedGlobal,...e}}setSessionName(e){this._sessionName=e}get sessionName(){return this._sessionName}setRecordingEnabled(e){this._recordingEnabled=e}get recorder(){return this._recorder}flushRecorder(){try{this._recorder?.flush()}catch(e){process.stderr.write(`[recorder] flush failed: ${e.message}
|
|
14
|
+
`)}}start(e){if(!this._started){this._started=!0,this._model=e.model,this._environment=e.environment,this._profile=e.profile,this._startedAt=new Date().toISOString();try{A(this.sessionDir,{recursive:!0}),this._recorder=new g({cwd:process.cwd(),getResolvedGlobal:()=>this._resolvedGlobal,getName:()=>this._sessionName});let t={session_id:this.sessionId,started_at:this._startedAt,model:e.model,environment:e.environment,profile:e.profile,plan:this._plan,objectives:[],runs:[],status:"in_progress"};v(u(this.sessionDir,"session.json"),JSON.stringify(t,null,2)+`
|
|
15
|
+
`)}catch{}this._log(`SESSION START session_id=${this.sessionId}`),this._log(`CONFIG model=${e.model} env=${e.environment} profile=${e.profile}`),this._earlyLogBuffer.push({level:"info",event:"SESSION_START",message:"Session started",context:{session_id:this.sessionId}},{level:"info",event:"CONFIG",message:"Session config",context:{model:e.model,environment:e.environment,profile:e.profile}})}}setPlan(e){this._plan=e;let t={level:"info",event:"SESSION_INFO",message:"Session info",context:{session_id:this.sessionId,plan:e??null}};this._remoteLogger?this._remoteLogger.log(t.level,t.event,t.message,t.context):this._earlyLogBuffer.push(t)}get plan(){return this._plan}get apMode(){return _()}setRemoteLogger(e){this._remoteLogger=e;for(let t of this._earlyLogBuffer)e.log(t.level,t.event,t.message,t.context);this._earlyLogBuffer=[]}get hasRemoteLogger(){return this._remoteLogger!==null}setAuteurVariables(e){Object.assign(this._auteurVariables,e)}get auteurVariables(){return this._auteurVariables}setScreenshotSas(e){this._screenshotSas=e}get screenshotSas(){return this._screenshotSas}get screenshotBaseUrl(){return this._screenshotSas?`${this._screenshotSas.base_url}/${this._screenshotSas.container}`:""}get startedAt(){return this._startedAt||new Date().toISOString()}log(e,t,s,i){if(t===void 0){this._log(e);let o=e.indexOf(" "),a=o>0?e.slice(0,o):e,S=o>0?e.slice(o+1):"",y=/fail|error/i.test(e)?"error":"info";this._remoteLogger?.log(y,a,S||e);return}let r=e,l=s;this._log(`${t} ${l}`,i),this._remoteLogger?.log(r,t,l,i)}logStep(e,t,s){this._log(`${e} ${t}`,s);let i=this._nextIndex>0?this._nextIndex-1:0;this._remoteLogger?.logStep(i,e,t,s)}logCommand(e){this._log(`COMMAND ${e}`)}logRunStart(e,t,s){this._log(`RUN ${e} START objective="${t.slice(0,100)}" url=${s}`),this._remoteLogger?.setRunIndex(e),this._remoteLogger?.log("info","RUN_START",`Run ${e} started`,{run_index:e,objective:t,url:s})}logRunEnd(e,t,s,i,r){let l=(s??0).toFixed(1),o=(i??"").slice(0,100),a=r==null||r===""||Number.isNaN(Number(r))?null:Number(r);this._log(`RUN ${e} END status=${t} duration=${l}s summary="${o}"`,a!=null?{result_code:a}:void 0),this._remoteLogger?.log("info","RUN_END",`Run ${e} ended`,{run_index:e,status:t,duration:s??0,summary:i??"",result_code:a}),t!=="failed"&&t!=="error"&&this._remoteLogger?.discardSteps(e)}escalateRun(e){this._remoteLogger?.escalate(e)}logChromeLaunch(e,t){this._log(`CHROME LAUNCH port=${e} endpoint=${t}`),this._remoteLogger?.log("info","CHROME_LAUNCH","Chrome launched",{port:e,cdp_endpoint:t})}async finish(e="complete"){this._log(`SESSION END status=${e} total_runs=${this.runs.length}`),this._remoteLogger?.log("info","SESSION_END","Session ended",{status:e,total_runs:this.runs.length}),await this._remoteLogger?.shutdown();let t={session_id:this.sessionId,started_at:this._startedAt,ended_at:new Date().toISOString(),model:this._model,environment:this._environment,profile:this._profile,plan:this._plan,status:e,total_runs:this.runs.length,test_id:this._testId,testcase_id:this._testcaseId,commit_id:this.sessionId,project_id:this._projectId,upload_status:this._uploadStatus,upload_attempts:this._uploadAttempts,last_upload_attempt:this._uploadAttempts>0?new Date().toISOString():null,upload_error:this._uploadError,runs:this.runs.map(s=>({index:s.index,objective:s.objective,status:s.status,summary:s.summary,run_dir:s.run_dir}))};b(this.sessionDir)&&v(u(this.sessionDir,"session.json"),JSON.stringify(t,null,2)+`
|
|
16
|
+
`),this.flushRecorder(),this._recorder=null}nextRunIndex(){return this._nextIndex}addRunResult(e,t){this.runs.push(e),this._nextIndex+=t??1,this._recordingEnabled&&this._recorder?.appendObjective(e.objective)}getContext(){return{prior_runs:this.runs.map(e=>({index:e.index,objective:e.objective,summary:e.summary,status:e.status,memory:e.context.memory,variables:e.context.variables,pointer:e.context.pointer}))}}addFlow(e){let t={...e,index:this._flows.length+1};return this._flows.push(t),t}getFlows(){return[...this._flows]}getFlow(e){return this._flows.find(t=>t.index===e)}clearFlows(){this._flows=[]}recordStepRun(e){this._stepRunRecords.push(e)}getStepRunRecords(){return[...this._stepRunRecords]}getRunsAsStepRecords(){return this.runs.map((e,t)=>({testmdStepIndex:t+1,runIndex:e.index,totalRunDirs:e.run_dirs?.length??1}))}snapshot(){return{runsLen:this.runs.length,nextRunIndex:this._nextIndex,stepRunRecordsLen:this._stepRunRecords.length}}rollback(e){this.runs.length=e.runsLen,this._nextIndex=e.nextRunIndex,this._stepRunRecords.length=e.stepRunRecordsLen}setTestId(e){this._testId=e}get testId(){return this._testId}setTestcaseId(e){this._testcaseId=e}get testcaseId(){return this._testcaseId}setProjectId(e){this._projectId=e}setOrgId(e){this._orgId=e}get orgId(){return this._orgId}setUserIdentity(e,t){e&&(this._userName=e),t&&(this._userEmail=t)}get userName(){return this._userName}get userEmail(){return this._userEmail}setFirstRun(e,t){this._firstObjective||(this._firstObjective=e,this._firstUrl=t)}get firstObjective(){return this._firstObjective}get firstUrl(){return this._firstUrl}getRunDirs(){let e=[];for(let t of this.runs)t.run_dirs&&t.run_dirs.length>0?e.push(...t.run_dirs):t.run_dir&&e.push(t.run_dir);return e}getRunObjectives(){let e=[];for(let t of this.runs)t.flow_objectives&&t.flow_objectives.length>0?e.push(...t.flow_objectives):e.push(t.objective);return e}getRunMetadata(){let e=[];for(let t of this.runs)if(t.perFlowMetadata&&t.perFlowMetadata.length>0)e.push(...t.perFlowMetadata);else{let s={resultCode:t.resultCode,reasonCode:t.reasonCode,errorMessage:t.status==="failed"?t.summary??null:null,summary:t.summary,oneLiner:t.oneLiner},i=t.run_dirs?.length??1;for(let r=0;r<i;r++)e.push(s)}return e}setUploadStatus(e,t){this._uploadStatus=e,this._uploadAttempts+=1,this._uploadError=t??null}_log(e,t){if(!(!this._started||!b(this.sessionDir)))try{let s=new Date().toISOString().slice(0,19).replace("T"," "),i=u(this.sessionDir,"tui.log"),r=t&&Object.keys(t).length>0?` ${JSON.stringify(t)}`:"";O(i,`[${s}] ${e}${r}
|
|
17
|
+
`)}catch{}}};export{f as a,T as b,R as c};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as $}from"./chunk-
|
|
2
|
+
import{a as $}from"./chunk-ZNHXIRCM.js";import{b as D}from"./chunk-YSSTGJ7O.js";import{a as E}from"./chunk-NLCCBXXV.js";function U(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function je(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function q(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function Re(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function Ce(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function P(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function H(e,t){let n=[],i=e.type??"",d=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let r=e.data??{},o=se(r.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:r.message??"",tookMs:o});break}case"progress":{let r=e.data??{};typeof r.progress=="number"&&n.push({type:"progress",pct:r.progress});break}case"clarification":{let r=e.data??{};typeof r.message=="string"&&n.push({type:"clarification",text:r.message});break}case"chatting_stopped":{let r=e.data??{};typeof r.message=="string"&&r.message.length>0&&n.push({type:"chat",text:r.message});break}case"limit_update":{let r=e.data??{},o=r.test_cases_limit??e.test_cases_limit,p=r.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:o,perScenarioLimit:p});break}case"error":{let r=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:r});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:d,headline:e.headline,scenarios:e.scenarios}}),d&&U(d)){let r=d.trim().toLowerCase();n.push({type:"done",status:r})}return n}function se(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var v=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},I=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function x(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new v(n):e===403?t?.key==="insufficient_credits"?new I(n):new M(n):new k(n)}async function*J(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,d=e.connectTimeoutMs??1e4,r=0,o=!1;for(;;){if(e.signal.aborted)return;let p=new AbortController,a=()=>p.abort();e.signal.addEventListener("abort",a,{once:!0});let c=setTimeout(()=>p.abort(),d),g;try{g=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:p.signal})}catch(w){if(clearTimeout(c),e.signal.removeEventListener("abort",a),e.signal.aborted)return;if(++r>n)throw new k("SSE connect failed",w);await O(F(r,i));continue}if(clearTimeout(c),!g.ok){e.signal.removeEventListener("abort",a);let w=await oe(g);if(g.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(g.status,w)}if(!g.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let m=g.body.getReader(),h=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await m.cancel().catch(()=>{});return}let{done:w,value:s}=await m.read();if(w)break;b+=h.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
|
|
3
3
|
|
|
4
4
|
`))>=0;){let u=b.slice(0,f);b=b.slice(f+2);let l=ie(u);l&&(yield l)}}}catch(w){if(e.signal.aborted)return;if(++r>n)throw new k("SSE stream dropped",w);await O(F(r,i));continue}finally{e.signal.removeEventListener("abort",a)}return}}function ie(e){let t="message",n="";for(let i of e.split(`
|
|
5
5
|
`))i.startsWith("event:")?t=i.slice(6).trim():i.startsWith("data:")&&(n+=i.slice(5).trim());if(t!=="message"||!n)return null;try{let i=Buffer.from(n,"base64").toString("utf-8");return JSON.parse(i)}catch{return null}}function F(e,t){return Math.min(t,1e3*2**(e-1))}function O(e){return new Promise(t=>setTimeout(t,e))}async function oe(e){try{return await e.clone().json()}catch{return}}function W(e,t){t?.length&&(e.append("files",t.map(n=>n.fileKey).join(",")),e.append("gemini_metadata",JSON.stringify(t.map(n=>({fileData:{fileUri:n.geminiUri,mimeType:n.mimeType}})))))}function Ue(e,t={}){let n=t.fetchImpl??fetch,i=new Map,d=!0;async function r(){let s=await e.authResolver.resolve();if(!s)throw new v("unauthorized; run `kane-cli login`");return E(s.username,s.access_key)}function o(s){return`${e.baseUrl}${s}`}async function p(s){if(!s.ok){let f;try{f=await s.clone().json()}catch{f=void 0}throw x(s.status,f)}return s.json()}function a(s){let f=s?.data??s;return{request_id:f.request_id??f.id,status:f.status??""}}function c(s,f,u,l){let y=q({requestId:s,objective:f});l&&(y=P(y,{type:"snapshot",data:l}),l.status==="cleaned_up"&&(y={...y,error:"session was reaped (cleaned_up) \u2014 continuing will destructively regenerate"}));let S=new AbortController;u&&(u.aborted?S.abort():u.addEventListener("abort",()=>S.abort(),{once:!0})),i.set(s,S);let A={requestId:s,state:y,events:void 0};return A.events=(async function*(){try{let C=J({url:o(`/requests/${s}/sse`),authHeader:r,signal:S.signal,log:e.log,fetchImpl:n});for await(let L of C)for(let z of H(L,s))A.state=P(A.state,z),yield z}finally{i.delete(s)}})(),A}async function g(s,f){let u=new FormData;u.append("prompt",s.prompt),d=s.memoryEnhancement??!0,u.append("memory_enhancement",String(d)),s.scenarioLimit!==void 0&&u.append("test_scenario_limit",String(s.scenarioLimit)),s.perScenarioLimit!==void 0&&u.append("per_scenario_test_cases_limit",String(s.perScenarioLimit));let l=s.projectId??e.projectId,y=s.folderId??e.folderId;l&&u.append("project_id",l),y&&u.append("folder_id",y),W(u,s.attachments);let S=await n(o("/requests"),{method:"POST",headers:{Authorization:await r()},body:u}),A=await p(S),{request_id:C}=a(A),L=String(C);return c(L,s.prompt,f)}async function m(s,f){let u=await n(o(`/requests/${s}`),{method:"GET",headers:{Authorization:await r()}}),l=await p(u),y=l?.data??l,S={requestId:s,status:y.status??"",headline:y.headline,scenarios:Array.isArray(y.scenarios)?y.scenarios:[]};return c(s,"",f,S)}async function h(s,f,u){let l=new FormData;l.append("prompt",f),l.append("chat_enabled","true"),l.append("memory_enhancement",String(d)),u?.mappings&&l.append("mappings",JSON.stringify(u.mappings)),W(l,u?.attachments);let y=await n(o(`/requests/${s}`),{method:"PUT",headers:{Authorization:await r()},body:l});if(!y.ok){let S;try{S=await y.clone().json()}catch{}throw x(y.status,S)}}async function b(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/stop`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}async function w(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/end`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}return{start:g,attach:m,chat:h,cancel:b,end:w}}import{statSync as ae,realpathSync as G,existsSync as ce}from"fs";import{extname as ue,resolve as j,isAbsolute as pe}from"path";import{homedir as V}from"os";var de=new Set([".txt",".md",".json",".xml",".jpg",".jpeg",".png",".gif",".bmp",".webp",".pdf",".docx",".csv",".xlsx",".mp3",".wav",".m4a",".webm",".mpeg",".mpga",".mp4",".mov"]),le=50*1024*1024,X=10;function fe(e){return e==="~"?V():e.startsWith("~/")?j(V(),e.slice(2)):e}function Ge(e,t){let n=[],i=[],d=new Set,r=[],o=(()=>{try{return G(j(t))}catch{return j(t)}})(),p=o.endsWith("/")?o:o+"/";for(let a of e){let c=fe(a),g=pe(c)?c:j(t,c);if(!ce(g)){n.push(`Not found: ${a}`);continue}let m;try{m=G(g)}catch{n.push(`Cannot resolve: ${a}`);continue}if(d.has(m))continue;let h;try{h=ae(m)}catch{n.push(`Cannot read: ${a}`);continue}if(!h.isFile()){n.push(`Not a file: ${a}`);continue}if(h.size===0){n.push(`Empty file: ${a}`);continue}let b=ue(m).toLowerCase();if(!de.has(b)){n.push(`Unsupported type ${b||"(none)"}: ${a}`);continue}if(h.size>le){n.push(`Too large (>50MB): ${a}`);continue}m!==o&&!m.startsWith(p)&&i.push(`Outside working dir: ${a}`),d.add(m),r.push(m)}return r.length>X&&n.push(`Too many files: ${r.length} (max ${X})`),{ok:n.length?[]:r,errors:n,warnings:i}}var B=class extends Error{constructor(n){super(n.join("; "));this.errors=n;this.name="AttachmentValidationError"}};async function Xe(e){let{promptText:t,filePaths:n,cwd:i,scenarios:d,isRefine:r,conn:o,deps:p}=e,{ok:a,errors:c,warnings:g}=p.validate(n,i);if(c.length)throw new B(c);e.onValidated?.();let m=a.length?await p.upload(o,a,p.onUpload):[],h=r?p.buildMappings(t,d):void 0;return{promptText:t,mappings:h,attachments:m,warnings:g}}import{readFile as me}from"fs/promises";import{basename as K}from"path";async function ge(e){let t=await e.authResolver.resolve();if(!t)throw new v("unauthorized; run `kane-cli login`");return E(t.username,t.access_key)}async function he(e,t,n={}){let i=n.fetchImpl??fetch,d=await me(t),r=K(t),o=new FormData;o.append("file",new Blob([d]),r),o.append("source","omniBox"),o.append("geminiFileUpload","true");let p=await i(`${e.tmsBaseUrl}/v1/attachment`,{method:"POST",headers:{Authorization:await ge(e)},body:o,signal:n.signal});if(!p.ok){let h;try{h=await p.clone().json()}catch{}throw x(p.status,h)}let a=await p.json(),c=a?.data??a,g=c?.gemini_response?.uri,m=c?.gemini_response?.mimeType;if(!c?.file_key||!g){let h=c&&typeof c=="object"?Object.keys(c).join(","):typeof c,b=(()=>{try{return JSON.stringify(c).slice(0,500)}catch{return"<unserializable>"}})();throw new Error(`attachment upload for ${r} returned no file_key/gemini uri \u2014 status ${p.status}, body keys: [${h}], raw: ${b}`)}return{fileName:c.file_name??r,fileKey:c.file_key,geminiUri:g,mimeType:m??"application/octet-stream"}}async function tt(e,t,n,i={}){let d=[];for(let r=0;r<t.length;r++){if(i.signal?.aborted)throw Object.assign(new Error("upload aborted"),{name:"AbortError"});let o=K(t[r]);n?.({file:o,index:r+1,total:t.length,status:"uploading"});try{d.push(await he(e,t[r],i)),n?.({file:o,index:r+1,total:t.length,status:"done"})}catch(p){throw n?.({file:o,index:r+1,total:t.length,status:"failed"}),p}}return d}var ye=/@([sS])(\d+)\.([cC])(\d+)/g,be=/@([sS])(\d+)(?!\d)(?!\.[cC]\d)/g;function rt(e,t){let n={},i={};for(let d of e.matchAll(ye)){let r=Number(d[2]),o=Number(d[4]),p=t[r-1];if(!p)continue;n[`s${r}`]=String(p.id);let a=p.test_cases??[];if(a[o-1])for(let c=0;c<o;c++){let g=a[c];g&&(i[`s${r}.c${c+1}`]=String(g.id))}}for(let d of e.matchAll(be)){let r=Number(d[2]),o=t[r-1];o&&(n[`s${r}`]=String(o.id))}if(!(Object.keys(n).length===0&&Object.keys(i).length===0))return{scenario:n,testcase:i}}function R(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(n==null||typeof n!="object")return[];let i=n;if(typeof i.step!="string")return[];let d=typeof i.expected_result=="string"?i.expected_result:typeof i.outcome=="string"?i.outcome:"";t.push({step:i.step,expected:d})}return t}var we=30,Se=300;function Z(){return{mode:"testing",max_steps:we,timeout:Se,variables:{}}}function Q(e){return e.title??`Test case ${e.id}`}function ct(e,t){return $({frontmatter:Z(),heading:Q(t),steps:e.sub_objectives.map(n=>n.objective)})}function Y(e){let t=R(e.manual_steps).map(n=>n.step);return $({frontmatter:Z(),heading:Q(e),steps:t})}import{mkdtempSync as xe,mkdirSync as N,writeFileSync as ee,rmSync as te,renameSync as _e,existsSync as ne,readFileSync as ve}from"fs";import{join as _,resolve as ke}from"path";async function ft(e,t,n,i=Y){(n.redirectBareCwd??!0)&&ke(t)===process.cwd()&&(t=_(t,".testmuai","tests"));let d=T(e.objective)??e.headline,r=T(n.suiteName)??`${T(re(d,4))??"tcg"}-${e.requestId}`,o=r,p=_(t,r);ne(p)&&!Te(p,e.requestId)&&(o=`${r}-${e.requestId}`);let a=_(t,o),c=[],g=new Map;for(let h of e.scenarios){let b=(h.test_cases??[]).filter(Ae);if(b.length===0)continue;let w=T(Ee(h.scode))??T(h.sid)??`s${h.id}`,s=g.get(w)??new Set;g.set(w,s);for(let f of b){let u=T(re(f.title,5))??"case",l=`${u}_test.md`;for(let y=2;s.has(l);y++)l=`${u}-${y}_test.md`;s.add(l),c.push({dir:w,file:l,tc:f})}}if(c.length===0)return{suiteDir:a,paths:[],warning:"no functional test cases generated"};N(t,{recursive:!0});let m=xe(_(t,".tcg-tmp-"));try{N(_(m,"helpers"),{recursive:!0}),ee(_(m,".tcg-suite.json"),JSON.stringify({requestId:e.requestId,suiteName:o}));let h=[],b=new Set;for(let s of c){let f=_(m,s.dir);b.has(f)||(N(f,{recursive:!0}),b.add(f));let u=_(f,s.file);ee(u,i(s.tc)),h.push(u)}ne(a)&&te(a,{recursive:!0,force:!0}),_e(m,a);let w=h.map(s=>s.replace(m,a));return{suiteDir:a,paths:w}}catch(h){try{te(m,{recursive:!0,force:!0})}catch{}throw h}}function Ae(e){return(e.category??"").trim().toLowerCase()==="functional"}function Te(e,t){try{return JSON.parse(ve(_(e,".tcg-suite.json"),"utf-8"))?.requestId===t}catch{return!1}}function T(e){return e&&e.length>0?e:void 0}function re(e,t){return e?e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean).slice(0,t).join("-"):""}function Ee(e){return e?e.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,""):""}function ht(e){let t=[];e.title&&t.push(e.title),e.description&&t.push("",e.description);let n=R(e.manual_steps);return n.length>0&&(t.push("","Steps:"),n.forEach((i,d)=>{t.push(`${d+1}. ${i.step}`)})),t.join(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as l}from"./chunk-
|
|
2
|
+
import{b as l}from"./chunk-MJBCBQC2.js";import{a as p}from"./chunk-RZ4F3BHX.js";import{a as m}from"./chunk-KHJXOFDM.js";import{a as f}from"./chunk-LHDNJJGE.js";import{a as c,c as s,i as a,x as u}from"./chunk-MMPFU2YC.js";var v="/public/skills/kane-cli";function C(){try{let n=new f().getDefaultEnv();if(n in u)return n}catch{}return"prod"}function k(){return`${m(C()).controllerBaseUrl}${v}`}import{readFileSync as S,writeFileSync as E,mkdirSync as g}from"fs";import{join as d}from"path";var h=d(s,"skill-check.json"),y=3600*1e3;function V(){try{let n=JSON.parse(S(h,"utf-8"));if(Date.now()-n.checkedAt<y)return n}catch{}return null}function A(n){try{g(s,{recursive:!0}),E(h,JSON.stringify({map:n,checkedAt:Date.now()}))}catch{}}function I(){for(let{dir:n}of a)try{let t=S(d(n,"VERSION"),"utf-8").trim();if(t)return t}catch{}return null}function M(n,t){let i=Object.keys(n.versions??{});if(i.length===0)return null;let o=i.slice().sort((r,e)=>l(r,e));for(let r of o){let e=n.versions[r]?.kaneCliMinVersion;if(!e||l(t,e)<=0)return r}return null}async function U(){try{let n=V()?.map;if(!n){let o=new AbortController,r=setTimeout(()=>o.abort(),5e3),e=await p(k(),{headers:{Accept:"application/json"},signal:o.signal});if(clearTimeout(r),!e.ok)return null;n=await e.json(),A(n)}let t=M(n,c);if(!t)return null;let i=I();return i===null?{current:null,latestCompatible:t}:l(i,t)>0?{current:i,latestCompatible:t}:null}catch{return null}}export{k as a,M as b,U as c};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-
|
|
2
|
+
import{a}from"./chunk-KHJXOFDM.js";import"./chunk-MMPFU2YC.js";import"./chunk-UR6MHSHU.js";export{a as getEnvironment};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as d,b as w,d as x}from"./chunk-GRB66C5S.js";import"./chunk-RN4OSVTG.js";import{e as b,f as k}from"./chunk-CJJXT5DO.js";import{d as $}from"./chunk-QM4S2APK.js";import"./chunk-BC7UVJJB.js";import{e as v}from"./chunk-EHN5HTUD.js";import{a as h}from"./chunk-L5LI2JF4.js";import{a as y}from"./chunk-
|
|
2
|
+
import{a as d,b as w,d as x}from"./chunk-GRB66C5S.js";import"./chunk-RN4OSVTG.js";import{e as b,f as k}from"./chunk-CJJXT5DO.js";import{d as $}from"./chunk-QM4S2APK.js";import"./chunk-BC7UVJJB.js";import{e as v}from"./chunk-EHN5HTUD.js";import{a as h}from"./chunk-L5LI2JF4.js";import{a as y}from"./chunk-7E24OCGX.js";import"./chunk-FRBYGSGJ.js";import"./chunk-6W6AIDLJ.js";import"./chunk-6HYW5RFX.js";import"./chunk-J2KSZUOO.js";import"./chunk-5YPBPZUR.js";import"./chunk-IAHKTEET.js";import"./chunk-UR6MHSHU.js";import{basename as f}from"path";import{statSync as R}from"fs";function S(s,e){if(!s)return 1;let r=s.resolve(e);return!r||r.superseded?1:s.getNode(r.tip)?.content.risk==="high"?3:1}function C(s,e){return s.usecases.map(r=>{let n=r.acceptance_criteria??[],a=n.filter(o=>(o.covered_by??[]).length>0),u=n.filter(o=>o.execution==="passed"),c=n.filter(o=>o.execution==="failed"),p=n.filter(o=>o.execution==="blocked"),i=0,l=0;for(let o of n){let g=S(e,o.id);i+=g,o.execution==="passed"&&(l+=g)}let t=i===0?0:Math.round(100*l/i),m=a.length===0?"uncovered":n.length===u.length?"covered":p.length>0&&c.length===0?"blocked":"partial";return{id:r.id,title:r.title,status:m,pct:t,acs:{total:n.length,covered:a.length,passed:u.length,failed:c.length,blocked:p.length},stale:n.filter(o=>o.fresh==="stale").map(o=>o.id)}})}async function A(s){let e=await b(s);return e.length===0?null:e.map(r=>({p:r,m:R(r).mtimeMs})).sort((r,n)=>n.m-r.m)[0].p}var D={covered:"\u2714",partial:"\u25D0",uncovered:"\u2716",blocked:"\u23F8"};function G(s){let e=Math.round(s/10);return"\u2588".repeat(e)+"\u2591".repeat(10-e)}async function E(s,e=x(),r=process.cwd()){let n=w(r,e);if(!n)return 2;let a=s.from?await k(s.from,r):await A(r);if(!a)return d(e,s.from?`no evidence pack at '${s.from}'`:"no evidence pack in .testmuai/evidence \u2014 run a test first, or pass --from <pack>"),2;let u=await v(a,"coverage/usecases.yaml");if(u==null)return d(e,`${f(a)} carries no coverage/usecases.yaml \u2014 the pack predates coverage or its project had no .context at seal time`),2;let c=h(u);if(!c||!Array.isArray(c.usecases))return d(e,`${f(a)}: coverage/usecases.yaml is not a usecases document`),2;let p=y(n),i=C(c,p),l=await $(p,"design");if(s.json)return e.out(JSON.stringify({pack:a,depth:i,completeness:l},null,2)),0;e.out(`coverage \u2014 ${f(a)}`),e.out(""),e.out("depth (proven by the pack):");for(let t of i){let m=t.stale.length?` \xB7 ${t.stale.length} stale`:"";e.out(` ${D[t.status]} ${G(t.pct)} ${String(t.pct).padStart(3)}% ${t.id} \u2014 ${t.status} (${t.acs.passed}/${t.acs.total} ACs proven${t.acs.failed?`, ${t.acs.failed} failed`:""}${t.acs.blocked?`, ${t.acs.blocked} blocked`:""})${m}`)}e.out(""),e.out("completeness (live graph):"),l.length===0&&e.out(" no design gaps \u2014 every AC verified, every use-case scenarioed");for(let t of l)e.out(` [${t.risk}] ${t.tag} ${t.ref} \u2014 ${t.why}`),e.out(` \u2192 ${t.ready_command}`);return 0}export{E as coverCommand,C as depthRows};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-
|
|
2
|
+
import{a}from"./chunk-LHDNJJGE.js";import"./chunk-MMPFU2YC.js";import"./chunk-UR6MHSHU.js";export{a as CredentialsManager};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i}from"./chunk-F7WKDMX7.js";import"./chunk-Q2F5QB2W.js";import"./chunk-VOHQA2SP.js";import"./chunk-NVGBE2DR.js";import"./chunk-IAHKTEET.js";import"./chunk-UR6MHSHU.js";export{a as DOCX_CONVERTER_POLICY,b as DOCX_CONVERTER_VERSION,d as DOCX_IMAGE_CAP,c as DOCX_IMAGE_DIMENSION_FLOOR,f as DOCX_IMAGE_MAX_BYTES,g as DOCX_IMAGE_MAX_PIXELS,e as DOCX_VISION_BYTE_BUDGET,i as convertDocx,h as renderTokens};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as u}from"./chunk-
|
|
2
|
+
import{a as u}from"./chunk-IQODWB32.js";import"./chunk-6W6AIDLJ.js";import"./chunk-6HYW5RFX.js";import"./chunk-J2KSZUOO.js";import"./chunk-5YPBPZUR.js";import"./chunk-IAHKTEET.js";import"./chunk-UR6MHSHU.js";var w=i=>`cite ${i.source_id??"?"} ${i.anchor??""}${i.quote?` \u2014 "${i.quote}"`:""}`;function C(i,_){let l=i.resolve(_);if(!l)return null;let c=l.tip,$=i.nodeLabel.get(c);if(!$)return null;let y=i.getNode(c);if(!y)return null;let s=y.content,f=i.displayNameOf(c)??_,d=[],r=(e,t,n=!1)=>{d.push({text:`${e.padEnd(12)} ${t}`,dim:n})},S=i.trust.get(c)??"derived";r("status",`${S}${i.superseded.has(c)?" \xB7 superseded":""}`,!0);let k=typeof s.risk=="string"?s.risk:null;k&&r("risk",k);for(let[e,t]of[["title",null],["description","description"],["value","value"],["summary","summary"],["statement","statement"],["text","text"],["intent","intent"],["case_type","case type"],["technique_notes","technique"],["kind","kind"],["change_note","change"]]){if(!t)continue;let n=s[e];typeof n=="string"&&n&&r(t,n)}let p=[];{let e=l.cid,t=new Set;for(;!t.has(e);){t.add(e),p.push(e);let n=i.superseded.get(e);if(typeof n!="string")break;e=n}}let g=p.flatMap(e=>i.edgesInto(e)).filter(e=>e.type==="DERIVES"),x=e=>{if(!e.source_cid||!e.anchor)return;let t=/^L(\d+)-L(\d+)$/.exec(e.anchor);if(!t)return;let n=i.getNode(e.source_cid)?.content?.text_blob;if(typeof n!="string")return;let o=n.split(`
|
|
3
3
|
`).slice(Number(t[1])-1,Number(t[2])).join(" ").trim();return o?o.length>120?`${o.slice(0,119)}\u2026`:o:void 0},h=new Map;for(let e of g){let t=e.props;t.claim&&h.set(t.claim,{source_id:t.source_id,anchor:t.anchor,quote:x(t)})}let L=Array.isArray(s.criteria)?s.criteria:[];for(let[e,t]of L.entries()){r(e===0?"criteria":"",`${e+1}. ${t}`);let n=h.get(t);n&&d.push({text:` ${w(n)}`,dim:!0})}let b=g.find(e=>!e.props.claim);if(b){let e=b.props;d.push({text:` ${w({...e,quote:x(e)})}`,dim:!0})}let a=s.check;a?.kind&&r("check",`${a.kind}${a.verified_against?` vs ${u(String(a.verified_against))}`:""}`);let m=s.expected_answer;m?.operator&&r("expects",`${m.operator} \xB7 ${String(m.operand??"")}`);let v=new Set,q=!0;for(let e of g){let t=e.props,n=`${t.source_id??"?"}@${t.source_cid??e.src}`;v.has(n)||(v.add(n),r(q?"provenance":"",`${t.source_id??"?"} @ ${String(t.source_cid??e.src).slice(7,15)}`,!0),q=!1)}let D=p.flatMap(e=>i.edgesFrom(e)).filter(e=>e.type==="depends_on");for(let[e,t]of D.entries()){let n=String(i.getNode(i.tipOf(t.dst))?.content?.title??""),o=i.displayNameOf(t.dst);r(e===0?"depends on":"",`${o?u(o):t.dst.slice(0,12)}${n?` ${n}`:""}`)}return{id:u(f),rawId:f,title:String(s.title??s.text??s.statement??f),label:$,lines:d}}export{C as buildDossier};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{$ as fa,A as J,B as K,C as L,D as M,E as N,F as O,G as P,H as Q,L as R,M as S,N as T,O as U,P as V,Q as W,R as X,S as Y,T as Z,U as _,V as $,W as aa,X as ba,Y as ca,Z as da,_ as ea,a,aa as ga,b,ba as ha,c,ca as ia,d,e,f,g,h,i,j,k as t,l as u,m as v,n as w,o as x,p as y,q as z,r as A,s as B,t as C,u as D,v as E,w as F,x as G,y as H,z as I}from"./chunk-
|
|
2
|
+
import{$ as fa,A as J,B as K,C as L,D as M,E as N,F as O,G as P,H as Q,L as R,M as S,N as T,O as U,P as V,Q as W,R as X,S as Y,T as Z,U as _,V as $,W as aa,X as ba,Y as ca,Z as da,_ as ea,a,aa as ga,b,ba as ha,c,ca as ia,d,e,f,g,h,i,j,k as t,l as u,m as v,n as w,o as x,p as y,q as z,r as A,s as B,t as C,u as D,v as E,w as F,x as G,y as H,z as I}from"./chunk-JXKRO2ZJ.js";import"./chunk-FCMLIK7P.js";import{a as n,b as o,c as p,e as q,f as r,g as s}from"./chunk-CJJXT5DO.js";import"./chunk-QM4S2APK.js";import"./chunk-ZPDM6FO7.js";import"./chunk-BC7UVJJB.js";import"./chunk-NVGBE2DR.js";import{a as k,b as l,c as m}from"./chunk-EHN5HTUD.js";import"./chunk-L5LI2JF4.js";import"./chunk-7E24OCGX.js";import"./chunk-FRBYGSGJ.js";import"./chunk-6W6AIDLJ.js";import"./chunk-6HYW5RFX.js";import"./chunk-J2KSZUOO.js";import"./chunk-5YPBPZUR.js";import"./chunk-IAHKTEET.js";import"./chunk-KHJXOFDM.js";import"./chunk-MMPFU2YC.js";import"./chunk-UR6MHSHU.js";export{P as EvidenceSession,C as appendExecutionPointer,M as assembleExecutionEnv,i as buildEnvironment,j as buildEvidenceRunConfig,g as buildExternalId,z as buildLogsMetaYaml,y as buildResultYaml,t as buildRunYaml,O as createCdpBrowserCapture,u as createRunningPack,v as createRunningPackRoot,H as declareLogsFromDir,J as diagnostics,x as discardPack,ba as ensureAuteurExecution,N as fetchCdpBrowserString,L as finalizeEvidencePack,U as finalizeInlineEvidence,K as finalizeMemberTestLogs,da as flattenAuteurLeafIds,ca as flattenAuteurLeaves,T as inlineEvidenceBlock,q as listPacks,p as newExecutionId,h as normalizeOs,S as noteInlineSpawn,$ as offerEvidenceView,o as packPath,I as packTestLogsDir,V as parseRange,D as readExecutionPointers,ia as readPackLeafIds,ha as readPackLeaves,s as recoverStore,fa as remapReplayActionIds,r as resolvePack,ga as resolveReplayResultSteps,F as rollupTestStatus,aa as runEvidenceMerge,_ as runEvidenceServe,E as runEvidenceValidate,Q as runStartupRecovery,l as sealPack,w as sealPackById,Z as serveHint,d as shortHash,c as slugify,W as startEvidenceLocalServer,R as startInlineEvidence,n as storeDir,m as sweepStore,ea as synthesizeSkippedTail,f as testIdForInline,e as testIdForTestmd,k as validatePack,a as verdictFromResultCode,X as viewerBaseFor,Y as viewerUrlFor,b as worstOf,G as worstResultCode,B as writeLogsMeta,A as writeResult};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d,e,f,g}from"./chunk-
|
|
2
|
+
import{a,b,c,d,e,f,g}from"./chunk-54IB6CXK.js";import"./chunk-GRB66C5S.js";import"./chunk-JFAFKHDX.js";import"./chunk-3C5GMAM4.js";import"./chunk-RN4OSVTG.js";import"./chunk-DNNZ353O.js";import"./chunk-BC7UVJJB.js";import"./chunk-NVGBE2DR.js";import"./chunk-7E24OCGX.js";import"./chunk-FRBYGSGJ.js";import"./chunk-6W6AIDLJ.js";import"./chunk-6HYW5RFX.js";import"./chunk-J2KSZUOO.js";import"./chunk-5YPBPZUR.js";import"./chunk-IAHKTEET.js";import"./chunk-UR6MHSHU.js";export{b as designStateOf,g as evolveCommand,c as evolveOneUc,f as liveRunDesignForUc,a as resolveParentUc,e as runEvolveCommand,d as staleTargets};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-
|
|
2
|
+
import{a}from"./chunk-FCHTL74E.js";import"./chunk-J2KSZUOO.js";import"./chunk-5YPBPZUR.js";import"./chunk-IAHKTEET.js";import"./chunk-UR6MHSHU.js";export{a as explain};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as x}from"./chunk-
|
|
2
|
+
import{a as x}from"./chunk-FCHTL74E.js";import{b as E}from"./chunk-KHU7C6EE.js";import{a as k}from"./chunk-BC7UVJJB.js";import"./chunk-L5LI2JF4.js";import{a as h}from"./chunk-7E24OCGX.js";import"./chunk-FRBYGSGJ.js";import"./chunk-6W6AIDLJ.js";import"./chunk-6HYW5RFX.js";import"./chunk-J2KSZUOO.js";import{d,e as g}from"./chunk-5YPBPZUR.js";import"./chunk-IAHKTEET.js";import"./chunk-UR6MHSHU.js";async function _(f,$={}){let m=$.contextDir??k(process.cwd()),e=$.out??(c=>process.stdout.write(c+`
|
|
3
3
|
`)),o=h(m),u=o.resolve(f);if(!u){let c=[...o.names.keys()].filter(n=>/^(t|sc|ac|gap)-/.test(n)).sort();return e(`no design rationale recorded for ${f} (exists: ${c.slice(0,12).join(", ")||"(no designed items)"})`),1}let a=u.tip,s=o.nodeLabel.get(a),r=o.getNode(a),l=o.nameOf.get(a)??a.slice(0,19);if(s===d.TEST){let c=String(r?.content.definitionId??""),n=c?E(m,c):null;if(!n){let i=null;for(let S of o.edgesFrom(a))if(S.type===g.VERIFIES){for(let p of o.edgesFrom(S.dst))if(p.type===g.SCOPED_TO){i=o.nameOf.get(p.dst)??p.dst.slice(0,19);break}if(i)break}return e(`no design rationale recorded for ${f} (exists: test ${l}, but its sidecar is missing \u2014 re-run: kane-cli design tests${i?` --use-case ${i}`:""} --force)`),1}e(`${l} \u2014 ${String(r?.content.title??"")}`),e(`technique: ${n.technique}`),e(`profile family: ${n.profile_family}`),e(`anchored to: ${n.anchor}`),e(`expected how: ${n.expected_how}`),e(`combinatorial: strength ${n.combinatorial.strength} \u2014 ${n.combinatorial.reason}`),e(`surface: ${n.surface_state} \xB7 deferred bindings: ${n.deferred_bindings}`);let t=r?.content.check;t&&e(`check: ${String(t.kind)} ${String(t.operator)} ${String(t.operand??t.within??"")} \u2014 verified against ${String(t.verified_against)}`);for(let i of o.edgesFrom(a))i.type===g.AUTOMATES&&e(`automates: ${o.nameOf.get(i.dst)??i.dst.slice(0,19)}`),i.type===g.VERIFIES&&e(`verifies: ${o.nameOf.get(i.dst)??i.dst.slice(0,19)}`),i.type===g.REUSES&&e(`imports: ${o.nameOf.get(i.dst)??i.dst.slice(0,19)}`);return 0}if(s===d.SCENARIO||s===d.AC||s===d.GAP){let n=x(m,o,f).entries.filter(t=>t.kind==="judgement"||t.kind==="review");if(e(`${l} \u2014 ${String(r?.content.title??r?.content.text??"")}`),s===d.SCENARIO&&(e(`case type: ${String(r?.content.case_type??"")} \xB7 intent: ${String(r?.content.intent??"")}`),e(`technique: ${String(r?.content.technique_notes??"")}`)),s===d.AC){let t=r?.content.expected_answer;e(`kind: ${String(r?.content.kind??"")}${t?` \xB7 oracle: ${String(t.operator)} ${String(t.operand??"")}`:""}`)}n.length===0&&e("(no recorded judgements yet \u2014 approvals and design-time judgements land here)");for(let t of n)e(t.kind==="judgement"?`judgement: ${t.rationale??t.detail}`:`review: ${t.detail}`);return 0}return e(`no design rationale recorded for ${f} (exists: ${s??"nothing"} ${l} \u2014 design explains tests, scenarios, ACs, and gaps)`),1}export{_ as designExplainCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as a}from"./chunk-GRB66C5S.js";import{a as i}from"./chunk-
|
|
2
|
+
import{b as a}from"./chunk-GRB66C5S.js";import{a as i}from"./chunk-FCHTL74E.js";import"./chunk-RN4OSVTG.js";import"./chunk-BC7UVJJB.js";import{a as n}from"./chunk-7E24OCGX.js";import"./chunk-FRBYGSGJ.js";import"./chunk-6W6AIDLJ.js";import"./chunk-6HYW5RFX.js";import"./chunk-J2KSZUOO.js";import"./chunk-5YPBPZUR.js";import"./chunk-IAHKTEET.js";import"./chunk-UR6MHSHU.js";async function f(s,p){let o=a(process.cwd(),{out:r=>process.stdout.write(r+`
|
|
3
3
|
`),err:r=>process.stderr.write(r+`
|
|
4
4
|
`),confirm:async()=>!1,isTTY:!!process.stdout.isTTY});if(!o)return 2;let c=n(o),t=i(o,c,s);if(p.json)return process.stdout.write(JSON.stringify(t)+`
|
|
5
5
|
`),t.target?0:1;if(!t.target)return process.stdout.write(`error: ${s} names nothing in the graph
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{e as Y,f as E}from"./chunk-
|
|
2
|
+
import{e as Y,f as E}from"./chunk-MTNUZEO7.js";import"./chunk-K7USHLVZ.js";import"./chunk-MR7CX5VT.js";import"./chunk-J44RN3FB.js";import"./chunk-JFAFKHDX.js";import{c as V}from"./chunk-YKTYVJBN.js";import"./chunk-CVOGP253.js";import"./chunk-427OQS2N.js";import{a as x}from"./chunk-M5PJQ5Y3.js";import{a as z}from"./chunk-3C5GMAM4.js";import"./chunk-GG43HSU2.js";import"./chunk-FMR2KPSK.js";import{d as N}from"./chunk-HLRLP6TQ.js";import{c as I}from"./chunk-RN4OSVTG.js";import"./chunk-V3UE6RJP.js";import"./chunk-DNNZ353O.js";import{a as M,b as R}from"./chunk-73OQDAXF.js";import"./chunk-FHKDTM5L.js";import"./chunk-2XMJ6YAE.js";import"./chunk-BKM2LWU2.js";import{a as P}from"./chunk-BC7UVJJB.js";import"./chunk-NVGBE2DR.js";import"./chunk-7E24OCGX.js";import"./chunk-FRBYGSGJ.js";import"./chunk-6W6AIDLJ.js";import"./chunk-6HYW5RFX.js";import"./chunk-J2KSZUOO.js";import"./chunk-5YPBPZUR.js";import"./chunk-IAHKTEET.js";import"./chunk-Y5RNCJAN.js";import"./chunk-5EOX4MEY.js";import"./chunk-RZ4F3BHX.js";import"./chunk-MMPFU2YC.js";import"./chunk-UR6MHSHU.js";async function W(o){let[{render:e},t,{QuestionBatchPrompt:m}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./ui-JEJGTURD.js")]),p=t.default??t;return new Promise(f=>{let n=e(p.createElement(m,{questions:o,onSubmit:h=>{n.unmount(),f(h)}}))})}async function J(o,e){let[{render:t},m,{ReviewChecklist:p}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./ui-JEJGTURD.js")]),f=m.default??m;return new Promise(n=>{let h=t(f.createElement(p,{items:o.map(a=>{let g=e.get(a.temp_ref);return{uc:a,dedupWith:g&&!g.archived?g.cid:void 0,archivedMatch:g?.archived?{cid:g.cid,reason:g.reason}:void 0}}),onSubmit:a=>{h.unmount(),n(a)}}))})}async function K(o){let{createInterface:e}=await import("readline/promises"),t=e({input:process.stdin,output:process.stdout});try{let m=await t.question(`${o} [y/N] `);return/^y(es)?$/i.test(m.trim())}finally{t.close()}}async function ie(o){let e=P(process.cwd()),t=R({verb:"extract",mode:o.plan?"cli":"interactive",contextRoot:e,env:M(),resumeSid:o.resume,write:!0,longSession:!0}),p={...await N(),...t.spawnEnv()},f=await V(p);if(!f.ok)return process.stderr.write((f.message??"error: turn-endpoint preflight failed")+`
|
|
3
3
|
`),process.stderr.write(t.supportFooter()+`
|
|
4
4
|
`),t.error("preflight_auth"),await t.end({exit_code:2}),2;let n=async()=>f;if(o.plan){let s=await E(o,{contextDir:e,agent:x,preflightTurn:n,ask:W,review:J,confirmStale:K,out:u=>process.stdout.write(u+`
|
|
5
5
|
`),progress:u=>process.stderr.write(u+`
|
|
6
6
|
`),isTTY:I(),auth:p,telemetry:t});return s===1&&process.stderr.write(t.supportFooter()+`
|
|
7
|
-
`),await t.end({exit_code:s}),s}let[{render:h},a,{ScrollbackProvider:g},{ChatSurface:k},{ScrollbackTap:i},{makeChatController:S},{setInkExit:C},H]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./scrollback-JLPJR25X.js"),import("./ChatSurface-
|
|
8
|
-
`),await t.end({exit_code:u}),u}finally{v=!0,_&&clearTimeout(_),await D.current?.flush();try{b.unmount()}catch{}}}async function ae(o){let e=R({verb:"extract",mode:o.mode,contextRoot:P(process.cwd()),env:M(),resumeSid:o.resume,write:!0,longSession:!0}),t={...await
|
|
7
|
+
`),await t.end({exit_code:s}),s}let[{render:h},a,{ScrollbackProvider:g},{ChatSurface:k},{ScrollbackTap:i},{makeChatController:S},{setInkExit:C},H]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./scrollback-JLPJR25X.js"),import("./ChatSurface-TZ554O4U.js"),import("./ScrollbackTap-Q3IOKNMS.js"),import("./chat-controller-QLORQWJZ.js"),import("./exit-manager-MXUD7GQ7.js"),Promise.all([import("./chat-committer-OS7ULZMH.js"),import("./descriptor-KXDJ4XYD.js"),import("./explain-EBVIUS2X.js"),import("./readmodel-S5RAQH3F.js")])]),[{commitChatTurn:$},{topologyDescriptor:L},{explain:O},{openGraph:y}]=H,A=a.default??a,c=S({commitChatTurn:$,descriptor:L(),contextDir:e,refreshGraph:()=>y(e),graph:y(e),explain:O,by:{kind:"human",id:"owner"},dedupFlags:s=>Y(s,y(e))}),D={current:null},j=0,_=null,v=!1,Q=()=>{if(j+=1,j>=2){try{b.unmount()}catch{}process.exit(130)}c.requestPause(),_=setTimeout(()=>{v||(v=!0,(async()=>{c.ledger({kind:"interrupted",detail:"the agent did not confirm the pause within 5s"}),await D.current?.flush();try{b.unmount()}catch{}process.exit(130)})())},5e3)},U=await import("./dossier-KJSJPWOW.js"),q=s=>{try{return U.buildDossier(y(e),s)}catch{return null}},B={listUcs:()=>{let s=y(e),u=new Set(c.state.turns.flatMap(r=>(r.items??[]).map(l=>l.title.toLowerCase()))),d={high:0,med:1,low:2};return s.byLabel("usecase").filter(r=>!s.superseded.has(r.cid)).map((r,l)=>{let w=r.content,T=String(w.title??r.cid.slice(0,12)),G=z(s,r.cid),F=G?G.designed_at_cid===r.cid?"current":"stale":void 0;return{key:r.cid,title:T,badge:F==="current"?"designed":F==="stale"?"designed \xB7 stale":u.has(T.toLowerCase())?"drafted this session":"existing",designed:F,risk:w.risk,i:l}}).sort((r,l)=>(d[r.risk??"zz"]??3)-(d[l.risk??"zz"]??3)||r.i-l.i).map(({key:r,title:l,badge:w,designed:T})=>({key:r,title:l,badge:w,designed:T}))},runDesignChild:async(s,u=!1)=>{let[{runDesign:d}]=await Promise.all([import("./run-2AIQUJ55.js")]),r="",l=await d({useCase:s,force:u,mode:"interactive"},{contextDir:e,agent:x,preflightTurn:n,ask:w=>c.ask(w),chat:c,nested:!0,out:w=>{r=w},progress:()=>{},isTTY:!0,auth:p});return l!==0&&r&&c.note(r),l}},b=h(A.createElement(g,null,A.createElement(i,{into:D}),A.createElement(k,{controller:c,verb:"extract",onCtrlC:Q,chain:B,inspect:q})),{exitOnCtrlC:!1});C(()=>b.unmount()),c.ledger({kind:"banner",text:"kane-cli context \xB7 extract \xB7 interactive"});try{let s=E(o,{contextDir:e,agent:x,preflightTurn:n,ask:d=>c.ask(d),review:async d=>new Map(d.map(r=>[r.temp_ref,{resolution:"skipped"}])),confirmStale:async()=>!0,out:d=>c.note(d),progress:()=>{},isTTY:I(),auth:p,chat:c,telemetry:t});s.finally(()=>{v=!0});let u=await s;return u===1&&process.stderr.write(t.supportFooter()+`
|
|
8
|
+
`),await t.end({exit_code:u}),u}finally{v=!0,_&&clearTimeout(_),await D.current?.flush();try{b.unmount()}catch{}}}async function ae(o){let e=R({verb:"extract",mode:o.mode,contextRoot:P(process.cwd()),env:M(),resumeSid:o.resume,write:!0,longSession:!0}),t={...await N(),...e.spawnEnv()},{makeHeadlessIO:m,resolveEncoding:p,guardedChannels:f}=await import("./headless-io-PWW6YKH2.js"),n=m(p(o.mode),"extract"),{makeInterruptGuard:h}=await import("./interrupt-guard-UREUWNRL.js"),a=h(x,i=>n.out(i)),k=f(n,()=>a.interrupted(),/^error: (agent failed|repair run failed|agent ended)/);try{let i=await E(o,{contextDir:P(process.cwd()),agent:a.agent,preflightTurn:()=>V(t),ask:async()=>[],review:async S=>new Map(S.map(C=>[C.temp_ref,{resolution:"skipped"}])),confirmStale:async()=>!1,out:k.out,emit:k.emit,progress:n.progress,isTTY:!1,auth:t,telemetry:e});return a.interrupted()&&i!==3?(n.out("interrupted \u2014 no session saved"),await e.end({exit_code:130}),n.done(130)):(i===1&&n.out(e.supportFooter()),await e.end({exit_code:i}),n.done(i))}catch(i){return n.event({type:"error",message:`error: extract failed: ${i instanceof Error?i.message:String(i)}`}),n.out(`error: extract failed: ${i instanceof Error?i.message:String(i)}`),n.out("hint: per-run trace logs live under .context/logs/ (extract-*.log)"),n.done(1)}finally{a.dispose()}}export{ae as bindExtractHeadless,ie as bindExtractInteractive};
|
|
@@ -3,4 +3,4 @@ import{a as s}from"./chunk-BC7UVJJB.js";import"./chunk-UR6MHSHU.js";import{exist
|
|
|
3
3
|
`),2;let n=async(r,t)=>{if(process.stderr.write(r+`
|
|
4
4
|
`),e.mode!=="agent")return 2;let{makeHeadlessIO:a,agentRefusal:c}=await import("./headless-io-PWW6YKH2.js");return c(a("ndjson","extract"),r,t)};if(e.apply)return n("extract: --apply is not implemented yet \u2014 coming with the plan\u2192apply workflow (run without --apply, or use --plan to preview)");{let{validateResumeMessage:r}=await import("./headless-io-PWW6YKH2.js"),t=r(e,"extract");if(t)return n(t)}if(!d(s(process.cwd())))return n("error: no context store here (run `kane-cli context ingest <files>` first)","NO_STORE");if(!e.mode&&!process.stdin.isTTY)return process.stderr.write(`extract: no TTY \u2014 pass an explicit --mode agent|ci|override to run headless
|
|
5
5
|
`),2;let i=e.mode??"interactive";if(i==="interactive"){if(!process.stdin.isTTY||!process.stdout.isTTY)return process.stderr.write(`extract: --mode interactive needs a TTY on stdin and stdout (use --mode agent|ci|override headless)
|
|
6
|
-
`),2;let{bindExtractInteractive:r}=await import("./extract-bind-
|
|
6
|
+
`),2;let{bindExtractInteractive:r}=await import("./extract-bind-6MQYKN3G.js");return r(e)}let{bindExtractHeadless:o}=await import("./extract-bind-6MQYKN3G.js");return o({...e,mode:i})}export{l as extractCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as x,b as J,d as ie}from"./chunk-GRB66C5S.js";import{a as re,b as oe}from"./chunk-SKRZN25J.js";import"./chunk-RN4OSVTG.js";import{a as X,b as Z,c as ee,d as te,e as ne,f as se}from"./chunk-FCMLIK7P.js";import{e as Q,f as L}from"./chunk-CJJXT5DO.js";import{a as I,b as W,c as M,d as K}from"./chunk-QM4S2APK.js";import"./chunk-ZPDM6FO7.js";import"./chunk-BC7UVJJB.js";import{e as Y}from"./chunk-EHN5HTUD.js";import{a as V}from"./chunk-L5LI2JF4.js";import{a as B}from"./chunk-SDRFTIRU.js";import"./chunk-RGDQMKNJ.js";import"./chunk-A46NBRAP.js";import"./chunk-L4JIMNKW.js";import"./chunk-MBXWXBDM.js";import"./chunk-IAHKTEET.js";import{d as R,e as U}from"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";import{basename as j}from"path";import{statSync as Re}from"fs";function ye(e,t){return e.length===0?"not_run":ee(e,t).verified?"proven":Z(e,t).some(n=>n.verdict==="failed")?"failing":"blocked"}function ce(e,t){let s=null;for(let{cid:p}of e.byLabel(R.TEST))for(let o of e.execHistory(p))(!s||String(o.started_at)>s.started_at)&&(s={execution_id:String(o.execution_id),started_at:String(o.started_at)});if(!s)return null;let n=X[t],r=se(e),c=te(r).aspects[t],i={},d={},l=0,f=0,a=0;for(let p of r.usecases){let o=[];for(let y of p.acceptance_criteria){let u=y.executions??[],_=ye(u,n);o.push(_),_==="failing"?l++:_==="blocked"?f++:_==="not_run"&&a++;let A=[],b;if(_==="failing"){let $=null;for(let P of y.covered_by){let w=e.execHistory(P).map(k=>({verdict:String(k.per_ac?.find(E=>E.ac_ref===y.id)?.verdict??k.verdict),oracle_mode:String(k.oracle_mode),ts:String(k.started_at),execution_id:String(k.execution_id)})).filter(k=>n.counted_verdicts.includes(k.verdict)&&n.accepted_oracle_modes.includes(k.oracle_mode)),O=w[w.length-1];O?.verdict==="failed"&&(A.push(P),(!$||O.ts>$.ts)&&($={ts:O.ts,execution_id:O.execution_id}))}b=$?.execution_id}else _==="blocked"&&(b=u[u.length-1]?.execution_id);i[y.id]={state:_,viaTests:A,...b?{executionId:b}:{}}}let m=o.some(y=>y!=="not_run"),g=c.usecases[p.id],h=m?g.status==="covered"?"proven":g.status==="partial"?"partial":o.includes("failing")?"failing":o.includes("blocked")?"blocked":"not_run":"not_run";d[p.id]={pct:g.pct,status:h}}return{aspect:t,pct:c.summary.coverage_pct,acs_proven:c.summary.acs_verified,failing:l,blocked:f,not_run:a,latest_run:s,perUc:d,perAc:i,config:{...n,source:"graph_execution_facts",denominator:"current_live_acs"}}}var be=["failing","blocked","needs-refresh","needs-tests","needs-scenarios","happy-only","possible-duplicate","not-yet-run"],_e={failing:"failing",blocked:"blocked","needs-refresh":"needs refresh","needs-tests":"needs tests","needs-scenarios":"needs scenarios","happy-only":"happy path only","possible-duplicate":"possible duplicate","not-yet-run":"not yet run"},G={high:0,med:1,low:2};function q(e,t){let s=/^(.*?)(\d+)$/.exec(e),n=/^(.*?)(\d+)$/.exec(t);return s&&n&&s[1]===n[1]?Number(s[2])-Number(n[2]):e<t?-1:e>t?1:0}function F(e){if(!e||/^sha256:/.test(e))return"(unnamed)";let t=/^(uc|ac|sc|t)-(\d+)$/.exec(e);return t?`${t[1].toUpperCase()}-${t[2]}`:e}function de(e,t=5){let s=e.trim().split(/\s+/);return s.slice(0,t).join(" ")+(s.length>t?"\u2026":"")}function $e(e,t){let s=e.resolve(t),n=s?e.getNode(e.tipOf(s.cid))?.content:null;return String(n?.title??n?.text??"")}function ae(e,t){let s=e.resolve(t);return{id:s?e.displayNameOf(e.tipOf(s.cid))??e.displayNameOf(s.cid):null,title:de($e(e,t),8)}}function ke(e,t){let s=e.resolve(t);if(!s)return null;let n=e.tipOf(s.cid);if(!I(e,n))return null;let r=e.nodeLabel.get(n);if(r===R.USECASE)return n;if(r===R.AC)return M(e,n);if(r===R.TEST){let c=e.edgesFrom(n).find(d=>d.type===U.VERIFIES&&I(e,d.dst));if(c)return M(e,c.dst);let i=e.edgesFrom(n).find(d=>d.type===U.AUTOMATES&&I(e,d.dst));if(i){let d=e.edgesFrom(i.dst).find(l=>l.type===U.BELONGS_TO&&I(e,l.dst));return d?d.dst:null}}return null}function N(e){if(e.tag==="reuse-candidate"&&e.stage==="design")return"possible-duplicate";switch(e.kind){case"no-verifies":return"needs-tests";case"zero-scenario":return"needs-scenarios";case"happy-only":return"happy-only";case"stale-ac":case"stale-test":return"needs-refresh";case"execution-failed":return"failing";case"execution-blocked":return"blocked";case"covered-not-run":return"not-yet-run";default:return"other"}}function xe(e,t){let s=e.resolve(t),n=s?e.getNode(e.tipOf(s.cid))?.content.risk:null;return n==="high"||n==="med"||n==="low"?n:"med"}function pe(e,t,s,n,r){let c=r.servePaths??new Map,i=e.byLabel(R.USECASE).filter(({cid:o})=>I(e,o)),d=new Map(i.map(o=>[o.cid,o])),l=new Map(i.map(({cid:o})=>[o,[]])),f=[];for(let o of t){if(o.stage!=="design")continue;let m={...o,...ae(e,o.ref)},g=ke(e,o.ref),h=g?l.get(g):void 0;h&&N(o)!=="other"?h.push(m):f.push(m)}let a=new Map(i.map(({cid:o})=>[o,{total:0,designed:0}]));for(let{cid:o}of e.byLabel(R.AC)){if(!I(e,o))continue;let m=M(e,o),g=m?a.get(m):void 0;if(!g)continue;g.total++;let h=W(e,o);if(h&&g.designed++,!n)continue;let y=e.nameOf.get(o)??o,u=n.perAc[y];if(!u)continue;let{id:_,title:A}=ae(e,y),b={ref:e.displayNameOf(o)??o,id:_,title:A,risk:xe(e,y),stage:"cover"},$=l.get(m);u.state==="failing"?$.push({...b,kind:"execution-failed",tag:"evolve",why:"covering test failed against this AC",ready_command:u.executionId&&c.has(u.executionId)?`kane-cli evidence serve ${c.get(u.executionId)}`:"kane-cli testrun run",via_tests:u.viaTests,...u.executionId?{execution_id:u.executionId}:{},...u.executionId&&c.has(u.executionId)?{servePath:c.get(u.executionId)}:{},...r.testFiles?{viaFiles:u.viaTests.map(P=>r.testFiles.get(P)??null)}:{}}):u.state==="blocked"?$.push({...b,kind:"execution-blocked",tag:"reuse-candidate",why:"the formula could count no run \u2014 broken/skipped or an unaccepted oracle",ready_command:u.executionId&&c.has(u.executionId)?`kane-cli evidence serve ${c.get(u.executionId)}`:"kane-cli testrun run",...u.executionId?{execution_id:u.executionId}:{},...u.executionId&&c.has(u.executionId)?{servePath:c.get(u.executionId)}:{}}):u.state==="not_run"&&h&&$.push({...b,kind:"covered-not-run",tag:"reuse-candidate",why:"a covering test exists but has not run yet",ready_command:"kane-cli testrun run"})}let p=[];for(let{cid:o,content:m}of i){let g=e.displayNameOf(o)??o,h=e.nameOf.get(o)??o,y=s.perUc[g]??{pct:0,status:"undesigned",staleAcs:0},u=n?n.perUc[h]??{pct:0,status:"not_run"}:null,_=n!==null&&(u===null||u.status==="not_run"),A=a.get(o),b=l.get(o)??[],$=new Set(b.filter(v=>N(v)==="needs-refresh").map(v=>v.ref)),P=b.some(v=>N(v)==="needs-tests"&&$.has(v.ref)),w=[];for(let v of be){let T=b.filter(S=>N(S)===v);if(v==="needs-tests"&&(T=T.filter(S=>!$.has(S.ref))),T.length===0)continue;T.sort((S,H)=>(G[S.risk]??3)-(G[H.risk]??3)||q(S.ref,H.ref));let ve=v==="failing"||v==="blocked"||T.length<=2||new Set(T.map(S=>S.ready_command)).size>1;w.push({key:v,label:_e[v],...v==="needs-refresh"?{suffix:"source moved since these were designed"}:{},alsoNeedsTests:v==="needs-refresh"&&P,rows:T,...ve?{}:{rosterCommand:T[0].ready_command}})}let O=w.some(v=>v.key==="failing"),k=w.some(v=>v.key==="blocked"),E=y.pct===100&&(n===null||u?.pct===100)&&w.length===0,me=u!==null&&u.pct>0,he=O?"\u2717":k?"\u23F8":E?"\u2714":y.pct===0&&!me?"\u2716":"\u25D0";p.push({slug:g,title:String(m.title??""),risk:String(m.risk??""),des:y,prov:u,provAbsent:_,acTotal:A.total,acDesigned:A.designed,mark:he,collapse:E,groups:w})}return p.sort((o,m)=>(G[o.risk]??3)-(G[m.risk]??3)||q(o.slug,m.slug)),f.sort((o,m)=>(G[o.risk]??3)-(G[m.risk]??3)||q(o.ref,m.ref)),{stage:r.stage,aspect:r.aspect,top:r.top,dc:s,pa:n,ucs:p,other:f}}function C(e,t){let s=Math.round(e/100*t);return"\u2588".repeat(s)+"\u2591".repeat(t-s)}function z(e){return e===100?"\u2714":e>0?"\u25D0":"\u2716"}function D(e,t){return e==="all"||t.stage===e}function fe(e,t){let{dc:s,pa:n}=e,r=Math.max(80,Math.min(t.width,120)),c=l=>t.color?`\x1B[2m${l}\x1B[22m`:l,i=[];if(n){i.push(`coverage \u2014 designed \xD7 proven \xB7 live graph \xB7 aspect ${n.aspect}`),i.push("");let l=s.ucs_needing_scenarios;i.push(` designed ${z(s.pct)} ${C(s.pct,10)} ${String(s.pct).padStart(3)}% \u2014 ${s.acs_designed} ACs have verifying tests`+(l>0?` \xB7 scenario debt: ${l} UC${l>1?"s":""}`:""));let f=[n.failing>0?`${n.failing} failing`:null,n.blocked>0?`${n.blocked} blocked`:null,n.not_run>0?`${n.not_run} not yet run`:null].filter(Boolean);i.push(` proven ${z(n.pct)} ${C(n.pct,10)} ${String(n.pct).padStart(3)}% \u2014 ${n.acs_proven} proven by execution`+(f.length?` \xB7 ${f.join(" \xB7 ")}`:""))}else i.push("AC design completeness \u2014 live graph (what design owes; execution proof not shown)"),i.push(""),i.push(` designed ${z(s.pct)} ${C(s.pct,10)} ${String(s.pct).padStart(3)}% \u2014 ${s.acs_designed} ACs have verifying tests \xB7 ${s.usecases_complete} UCs complete`),s.ucs_needing_scenarios>0&&i.push(` scenario debt: ${s.ucs_needing_scenarios} use-case${s.ucs_needing_scenarios>1?"s":""} need scenarios`),i.push(" proven \u2014 no runs recorded yet \xB7 run tests, then re-run");i.push("");let d=!1;for(let l of e.ucs){if(i.push(we(l,n!==null,r)),l.collapse)continue;let f=e.top??1/0;for(let a of l.groups){let p=a.rows.filter(h=>D(e.stage,h));if(p.length===0)continue;if(d=!0,f<=0){i.push(c(` \u2026 +${p.length} more ${a.label}`));continue}let o=p.slice(0,f),m=p.length-o.length;if(f-=o.length,(a.key==="needs-scenarios"||a.key==="happy-only")&&o.length===1&&o[0].ref===l.slug){i.push(` ${a.label}${a.key==="needs-scenarios"?" \u2014 design from scratch":""}`),i.push(c(` \u2192 ${o[0].ready_command}`));continue}let g=(a.suffix?` \u2014 ${a.suffix}`:"")+(a.alsoNeedsTests?" \u2014 also needs tests":"");if(i.push(` ${a.label} (${p.length})${g}`),a.rosterCommand&&a.key!=="failing"&&a.key!=="blocked")Se(i,o,r),i.push(c(` \u2192 ${a.rosterCommand}`));else for(let h of o)Te(i,h,a.key,c);m>0&&i.push(c(` \u2026 +${m} more ${a.label}`))}}return!d&&e.ucs.every(l=>l.groups.every(f=>f.rows.filter(a=>D(e.stage,a)).length===0))&&i.push(" nothing owed \u2014 design and execution are square"),i.push(""),i.push(c(" metric: live verifies edges \xB7 high \xD73 \xB7 staleness shown, not discounted")),n?i.push(c(` proven: graph execution facts \xB7 latest run ${n.latest_run?.started_at??"\u2014"} \xB7 ${n.aspect} formula verbatim`)):i.push(c(" proof: no runs recorded yet \u2014 run tests, then re-run")),i}function we(e,t,s){let n=F(e.slug);if(!t){let l=e.acTotal===0?"no scenarios yet":e.collapse||e.des.status==="complete"?`${e.acTotal} ACs \xB7 complete`:e.des.staleAcs>0?`${e.acTotal} ACs \xB7 ${e.des.staleAcs} stale`:`${e.acTotal} ACs \xB7 ${e.acTotal-e.acDesigned} unverified`,f=` ${e.mark} ${C(e.des.pct,10)} ${String(e.des.pct).padStart(3)}% ${n} `,a=Math.max(0,s-f.length-l.length-2);return`${f}${le(e.title,a).padEnd(a)} ${l}`}let r=e.provAbsent?"prov \xB7 not run":`prov ${C(e.prov?.pct??0,8)} ${String(e.prov?.pct??0).padStart(3)}%`,c=`des ${C(e.des.pct,8)} ${String(e.des.pct).padStart(3)}% \xB7 ${r}`,i=` ${e.mark} ${n} `,d=Math.max(0,s-i.length-c.length-2);return`${i}${le(e.title,d).padEnd(d)} ${c}`}function le(e,t){return e.length<=t?e:t<=1?e.slice(0,t):e.slice(0,t-1)+"\u2026"}function Te(e,t,s,n){let r=F(t.id??t.ref);if(s==="failing"){let c=(t.via_tests??[]).map((d,l)=>`${F(d)}${t.viaFiles?.[l]?` ${t.viaFiles[l]}`:""}`).join(", ");e.push(` \u2717 ${r} ${t.title} \u2014 failed${c?` \xB7 via ${c}`:""}`),t.servePath&&e.push(n(` \u2192 kane-cli evidence serve ${t.servePath} (see why it failed)`));let i=(t.viaFiles??[]).filter(d=>d!==null);i.length===1?e.push(n(` re-run after fixing: kane-cli testmd run ${i[0]} (heals on failure \u2014 fix the app first, or the test may re-author)`)):i.length>1&&e.push(n(" re-run after fixing: kane-cli testrun run (heals on failure \u2014 fix the app first, or the tests may re-author)"));return}if(s==="blocked"){e.push(` \u23F8 ${r} ${t.title} \u2014 (blocked \u2014 see why)`),t.servePath&&e.push(n(` \u2192 kane-cli evidence serve ${t.servePath} (see why)`));return}e.push(` ${r} ${t.title} \u2014 ${t.why}`),e.push(n(` \u2192 ${t.ready_command}`))}function Se(e,t,s){let n=t.map(c=>`${F(c.id??c.ref)} ${de(c.title,4)}`),r=" ";for(let c of n){let i=r.trim().length?" \xB7 ":"";r.length+i.length+c.length>s&&r.trim().length?(e.push(r),r=" "+c):r+=i+c}r.trim().length&&e.push(r)}function ge(e){let{dc:t,pa:s}=e,n=r=>e.top!==void 0?r.slice(0,e.top):r;return{stage:e.stage,rollup_version:1,design_completeness:{pct:t.pct,acs_designed:t.acs_designed,usecases_complete:t.usecases_complete,ucs_needing_scenarios:t.ucs_needing_scenarios,config:t.config},...s?{proven:{aspect:s.aspect,pct:s.pct,acs_proven:s.acs_proven,failing:s.failing,blocked:s.blocked,not_run:s.not_run,latest_run:s.latest_run,config:s.config}}:{},usecases:e.ucs.map(r=>({id:/^sha256:/.test(r.slug)?null:r.slug,title:r.title,risk:r.risk,design_completeness:{pct:r.des.pct,status:r.des.status},stale_acs:r.des.staleAcs,...s?{proven:r.prov??{pct:0,status:"not_run"}}:{},pending:n(r.groups.flatMap(c=>c.rows).filter(c=>D(e.stage,c))).map(ue)})),other:e.other.filter(r=>D(e.stage,r)).map(ue)}}function ue(e){let{servePath:t,viaFiles:s,meta:n,...r}=e;return{...r}}async function Ae(e){let t=await Q(e);return t.length===0?null:t.map(s=>({p:s,m:Re(s).mtimeMs})).sort((s,n)=>n.m-s.m)[0].p}async function Qe(e,t=ie(),s=process.cwd()){if(e.flat)return Ie(e,t,s);let n=e.stage??"all";if(n!=="design"&&n!=="cover"&&n!=="all")return x(t,`--stage must be design | cover | all, got '${n}'`),2;if(e.top!==void 0&&(!Number.isInteger(e.top)||e.top<1))return x(t,"--top must be a positive integer"),2;let r=e.aspect??"lenient";if(r!=="lenient"&&r!=="strict")return x(t,`--aspect must be lenient | strict, got '${r}'`),2;if(e.from)return x(t,"the tree reads the live graph \u2014 for a specific run's view use: kane-cli cover --from <pack> (legacy worklist: add --flat)"),2;let c=J(s,t);if(!c)return 2;let i=B(c),d=ne(i),l=ce(i,r),f=await K(i,"design"),a=new Map;if(l)for(let g of Object.values(l.perAc)){if(!g.executionId||a.has(g.executionId))continue;let h=await L(g.executionId,s);h&&a.set(g.executionId,h)}let p=new Map;for(let[g,h]of oe(re(s)))h.length===1&&p.set(g,j(h[0]));let o=pe(i,f,d,l,{stage:n,top:e.top,aspect:r,servePaths:a,testFiles:p});if(e.json)return t.out(JSON.stringify(ge(o),null,2)),0;if(d.usecases_complete==="0/0")return t.out("nothing to measure yet \u2014 no live use-cases in the graph"),0;let m=t.isTTY&&process.stdout.columns?process.stdout.columns:100;for(let g of fe(o,{width:m,color:t.isTTY}))t.out(g);return 0}async function Ie(e,t,s){let n=e.stage??"design";if(n!=="design"&&n!=="cover"&&n!=="all")return x(t,`--stage must be design | cover | all, got '${n}'`),2;if(e.top!==void 0&&(!Number.isInteger(e.top)||e.top<1))return x(t,"--top must be a positive integer"),2;let r=J(s,t);if(!r)return 2;let c,i;if(n!=="design"){let a=e.from?await L(e.from,s):await Ae(s);if(!a)return x(t,e.from?`no evidence pack at '${e.from}'`:`--stage ${n} needs an evidence pack \u2014 run a test first, or pass --from <pack> (live view: drop --flat)`),2;let p=await Y(a,"coverage/usecases.yaml");if(p==null)return x(t,`${j(a)} carries no coverage/usecases.yaml \u2014 re-run the tests to produce a coverage-bearing pack`),2;let o=V(p);if(!o||!Array.isArray(o.usecases))return x(t,`${j(a)}: coverage/usecases.yaml is not a usecases document`),2;c=o,i=j(a)}let d=B(r),l=await K(d,n,void 0,c),f=l.length;if(e.top!==void 0&&(l=l.slice(0,e.top)),e.json){let a=l.map(p=>Pe(d,p));return t.out(JSON.stringify({stage:n,...i?{pack:i}:{},total:f,rows:a},null,2)),0}return t.out(`gaps \u2014 stage ${n}${i?` \xB7 pack ${i}`:""} (${l.length}${l.length<f?` of ${f}`:""})`),l.length===0&&t.out(" nothing owed \u2014 design and execution are square"),l.forEach((a,p)=>{t.out(` ${String(p+1).padStart(2)}. [${a.risk}] ${a.tag} ${a.ref} \u2014 ${a.why}`),t.out(` \u2192 ${a.ready_command}`)}),0}function Pe(e,t){let s=e.resolve(t.ref),n=s?e.tipOf(s.cid):null,r=n?e.getNode(n)?.content:null;return{...t,id:n?e.displayNameOf(n)??e.displayNameOf(s.cid):null,title:String(r?.title??r?.text??"")}}export{Qe as gapsCommand};
|
|
2
|
+
import{a as x,b as J,d as ie}from"./chunk-GRB66C5S.js";import{a as re,b as oe}from"./chunk-3RZ63RBO.js";import"./chunk-RN4OSVTG.js";import{a as X,b as Z,c as ee,d as te,e as ne,f as se}from"./chunk-FCMLIK7P.js";import{e as Q,f as L}from"./chunk-CJJXT5DO.js";import{a as I,b as W,c as M,d as K}from"./chunk-QM4S2APK.js";import"./chunk-ZPDM6FO7.js";import"./chunk-BC7UVJJB.js";import{e as Y}from"./chunk-EHN5HTUD.js";import{a as V}from"./chunk-L5LI2JF4.js";import{a as B}from"./chunk-7E24OCGX.js";import"./chunk-FRBYGSGJ.js";import"./chunk-6W6AIDLJ.js";import"./chunk-6HYW5RFX.js";import"./chunk-J2KSZUOO.js";import{d as R,e as U}from"./chunk-5YPBPZUR.js";import"./chunk-IAHKTEET.js";import"./chunk-UR6MHSHU.js";import{basename as j}from"path";import{statSync as Re}from"fs";function ye(e,t){return e.length===0?"not_run":ee(e,t).verified?"proven":Z(e,t).some(n=>n.verdict==="failed")?"failing":"blocked"}function ce(e,t){let s=null;for(let{cid:p}of e.byLabel(R.TEST))for(let o of e.execHistory(p))(!s||String(o.started_at)>s.started_at)&&(s={execution_id:String(o.execution_id),started_at:String(o.started_at)});if(!s)return null;let n=X[t],r=se(e),c=te(r).aspects[t],i={},d={},l=0,f=0,a=0;for(let p of r.usecases){let o=[];for(let y of p.acceptance_criteria){let u=y.executions??[],_=ye(u,n);o.push(_),_==="failing"?l++:_==="blocked"?f++:_==="not_run"&&a++;let A=[],b;if(_==="failing"){let $=null;for(let P of y.covered_by){let w=e.execHistory(P).map(k=>({verdict:String(k.per_ac?.find(E=>E.ac_ref===y.id)?.verdict??k.verdict),oracle_mode:String(k.oracle_mode),ts:String(k.started_at),execution_id:String(k.execution_id)})).filter(k=>n.counted_verdicts.includes(k.verdict)&&n.accepted_oracle_modes.includes(k.oracle_mode)),O=w[w.length-1];O?.verdict==="failed"&&(A.push(P),(!$||O.ts>$.ts)&&($={ts:O.ts,execution_id:O.execution_id}))}b=$?.execution_id}else _==="blocked"&&(b=u[u.length-1]?.execution_id);i[y.id]={state:_,viaTests:A,...b?{executionId:b}:{}}}let m=o.some(y=>y!=="not_run"),g=c.usecases[p.id],h=m?g.status==="covered"?"proven":g.status==="partial"?"partial":o.includes("failing")?"failing":o.includes("blocked")?"blocked":"not_run":"not_run";d[p.id]={pct:g.pct,status:h}}return{aspect:t,pct:c.summary.coverage_pct,acs_proven:c.summary.acs_verified,failing:l,blocked:f,not_run:a,latest_run:s,perUc:d,perAc:i,config:{...n,source:"graph_execution_facts",denominator:"current_live_acs"}}}var be=["failing","blocked","needs-refresh","needs-tests","needs-scenarios","happy-only","possible-duplicate","not-yet-run"],_e={failing:"failing",blocked:"blocked","needs-refresh":"needs refresh","needs-tests":"needs tests","needs-scenarios":"needs scenarios","happy-only":"happy path only","possible-duplicate":"possible duplicate","not-yet-run":"not yet run"},G={high:0,med:1,low:2};function q(e,t){let s=/^(.*?)(\d+)$/.exec(e),n=/^(.*?)(\d+)$/.exec(t);return s&&n&&s[1]===n[1]?Number(s[2])-Number(n[2]):e<t?-1:e>t?1:0}function F(e){if(!e||/^sha256:/.test(e))return"(unnamed)";let t=/^(uc|ac|sc|t)-(\d+)$/.exec(e);return t?`${t[1].toUpperCase()}-${t[2]}`:e}function de(e,t=5){let s=e.trim().split(/\s+/);return s.slice(0,t).join(" ")+(s.length>t?"\u2026":"")}function $e(e,t){let s=e.resolve(t),n=s?e.getNode(e.tipOf(s.cid))?.content:null;return String(n?.title??n?.text??"")}function ae(e,t){let s=e.resolve(t);return{id:s?e.displayNameOf(e.tipOf(s.cid))??e.displayNameOf(s.cid):null,title:de($e(e,t),8)}}function ke(e,t){let s=e.resolve(t);if(!s)return null;let n=e.tipOf(s.cid);if(!I(e,n))return null;let r=e.nodeLabel.get(n);if(r===R.USECASE)return n;if(r===R.AC)return M(e,n);if(r===R.TEST){let c=e.edgesFrom(n).find(d=>d.type===U.VERIFIES&&I(e,d.dst));if(c)return M(e,c.dst);let i=e.edgesFrom(n).find(d=>d.type===U.AUTOMATES&&I(e,d.dst));if(i){let d=e.edgesFrom(i.dst).find(l=>l.type===U.BELONGS_TO&&I(e,l.dst));return d?d.dst:null}}return null}function N(e){if(e.tag==="reuse-candidate"&&e.stage==="design")return"possible-duplicate";switch(e.kind){case"no-verifies":return"needs-tests";case"zero-scenario":return"needs-scenarios";case"happy-only":return"happy-only";case"stale-ac":case"stale-test":return"needs-refresh";case"execution-failed":return"failing";case"execution-blocked":return"blocked";case"covered-not-run":return"not-yet-run";default:return"other"}}function xe(e,t){let s=e.resolve(t),n=s?e.getNode(e.tipOf(s.cid))?.content.risk:null;return n==="high"||n==="med"||n==="low"?n:"med"}function pe(e,t,s,n,r){let c=r.servePaths??new Map,i=e.byLabel(R.USECASE).filter(({cid:o})=>I(e,o)),d=new Map(i.map(o=>[o.cid,o])),l=new Map(i.map(({cid:o})=>[o,[]])),f=[];for(let o of t){if(o.stage!=="design")continue;let m={...o,...ae(e,o.ref)},g=ke(e,o.ref),h=g?l.get(g):void 0;h&&N(o)!=="other"?h.push(m):f.push(m)}let a=new Map(i.map(({cid:o})=>[o,{total:0,designed:0}]));for(let{cid:o}of e.byLabel(R.AC)){if(!I(e,o))continue;let m=M(e,o),g=m?a.get(m):void 0;if(!g)continue;g.total++;let h=W(e,o);if(h&&g.designed++,!n)continue;let y=e.nameOf.get(o)??o,u=n.perAc[y];if(!u)continue;let{id:_,title:A}=ae(e,y),b={ref:e.displayNameOf(o)??o,id:_,title:A,risk:xe(e,y),stage:"cover"},$=l.get(m);u.state==="failing"?$.push({...b,kind:"execution-failed",tag:"evolve",why:"covering test failed against this AC",ready_command:u.executionId&&c.has(u.executionId)?`kane-cli evidence serve ${c.get(u.executionId)}`:"kane-cli testrun run",via_tests:u.viaTests,...u.executionId?{execution_id:u.executionId}:{},...u.executionId&&c.has(u.executionId)?{servePath:c.get(u.executionId)}:{},...r.testFiles?{viaFiles:u.viaTests.map(P=>r.testFiles.get(P)??null)}:{}}):u.state==="blocked"?$.push({...b,kind:"execution-blocked",tag:"reuse-candidate",why:"the formula could count no run \u2014 broken/skipped or an unaccepted oracle",ready_command:u.executionId&&c.has(u.executionId)?`kane-cli evidence serve ${c.get(u.executionId)}`:"kane-cli testrun run",...u.executionId?{execution_id:u.executionId}:{},...u.executionId&&c.has(u.executionId)?{servePath:c.get(u.executionId)}:{}}):u.state==="not_run"&&h&&$.push({...b,kind:"covered-not-run",tag:"reuse-candidate",why:"a covering test exists but has not run yet",ready_command:"kane-cli testrun run"})}let p=[];for(let{cid:o,content:m}of i){let g=e.displayNameOf(o)??o,h=e.nameOf.get(o)??o,y=s.perUc[g]??{pct:0,status:"undesigned",staleAcs:0},u=n?n.perUc[h]??{pct:0,status:"not_run"}:null,_=n!==null&&(u===null||u.status==="not_run"),A=a.get(o),b=l.get(o)??[],$=new Set(b.filter(v=>N(v)==="needs-refresh").map(v=>v.ref)),P=b.some(v=>N(v)==="needs-tests"&&$.has(v.ref)),w=[];for(let v of be){let T=b.filter(S=>N(S)===v);if(v==="needs-tests"&&(T=T.filter(S=>!$.has(S.ref))),T.length===0)continue;T.sort((S,H)=>(G[S.risk]??3)-(G[H.risk]??3)||q(S.ref,H.ref));let ve=v==="failing"||v==="blocked"||T.length<=2||new Set(T.map(S=>S.ready_command)).size>1;w.push({key:v,label:_e[v],...v==="needs-refresh"?{suffix:"source moved since these were designed"}:{},alsoNeedsTests:v==="needs-refresh"&&P,rows:T,...ve?{}:{rosterCommand:T[0].ready_command}})}let O=w.some(v=>v.key==="failing"),k=w.some(v=>v.key==="blocked"),E=y.pct===100&&(n===null||u?.pct===100)&&w.length===0,me=u!==null&&u.pct>0,he=O?"\u2717":k?"\u23F8":E?"\u2714":y.pct===0&&!me?"\u2716":"\u25D0";p.push({slug:g,title:String(m.title??""),risk:String(m.risk??""),des:y,prov:u,provAbsent:_,acTotal:A.total,acDesigned:A.designed,mark:he,collapse:E,groups:w})}return p.sort((o,m)=>(G[o.risk]??3)-(G[m.risk]??3)||q(o.slug,m.slug)),f.sort((o,m)=>(G[o.risk]??3)-(G[m.risk]??3)||q(o.ref,m.ref)),{stage:r.stage,aspect:r.aspect,top:r.top,dc:s,pa:n,ucs:p,other:f}}function C(e,t){let s=Math.round(e/100*t);return"\u2588".repeat(s)+"\u2591".repeat(t-s)}function z(e){return e===100?"\u2714":e>0?"\u25D0":"\u2716"}function D(e,t){return e==="all"||t.stage===e}function fe(e,t){let{dc:s,pa:n}=e,r=Math.max(80,Math.min(t.width,120)),c=l=>t.color?`\x1B[2m${l}\x1B[22m`:l,i=[];if(n){i.push(`coverage \u2014 designed \xD7 proven \xB7 live graph \xB7 aspect ${n.aspect}`),i.push("");let l=s.ucs_needing_scenarios;i.push(` designed ${z(s.pct)} ${C(s.pct,10)} ${String(s.pct).padStart(3)}% \u2014 ${s.acs_designed} ACs have verifying tests`+(l>0?` \xB7 scenario debt: ${l} UC${l>1?"s":""}`:""));let f=[n.failing>0?`${n.failing} failing`:null,n.blocked>0?`${n.blocked} blocked`:null,n.not_run>0?`${n.not_run} not yet run`:null].filter(Boolean);i.push(` proven ${z(n.pct)} ${C(n.pct,10)} ${String(n.pct).padStart(3)}% \u2014 ${n.acs_proven} proven by execution`+(f.length?` \xB7 ${f.join(" \xB7 ")}`:""))}else i.push("AC design completeness \u2014 live graph (what design owes; execution proof not shown)"),i.push(""),i.push(` designed ${z(s.pct)} ${C(s.pct,10)} ${String(s.pct).padStart(3)}% \u2014 ${s.acs_designed} ACs have verifying tests \xB7 ${s.usecases_complete} UCs complete`),s.ucs_needing_scenarios>0&&i.push(` scenario debt: ${s.ucs_needing_scenarios} use-case${s.ucs_needing_scenarios>1?"s":""} need scenarios`),i.push(" proven \u2014 no runs recorded yet \xB7 run tests, then re-run");i.push("");let d=!1;for(let l of e.ucs){if(i.push(we(l,n!==null,r)),l.collapse)continue;let f=e.top??1/0;for(let a of l.groups){let p=a.rows.filter(h=>D(e.stage,h));if(p.length===0)continue;if(d=!0,f<=0){i.push(c(` \u2026 +${p.length} more ${a.label}`));continue}let o=p.slice(0,f),m=p.length-o.length;if(f-=o.length,(a.key==="needs-scenarios"||a.key==="happy-only")&&o.length===1&&o[0].ref===l.slug){i.push(` ${a.label}${a.key==="needs-scenarios"?" \u2014 design from scratch":""}`),i.push(c(` \u2192 ${o[0].ready_command}`));continue}let g=(a.suffix?` \u2014 ${a.suffix}`:"")+(a.alsoNeedsTests?" \u2014 also needs tests":"");if(i.push(` ${a.label} (${p.length})${g}`),a.rosterCommand&&a.key!=="failing"&&a.key!=="blocked")Se(i,o,r),i.push(c(` \u2192 ${a.rosterCommand}`));else for(let h of o)Te(i,h,a.key,c);m>0&&i.push(c(` \u2026 +${m} more ${a.label}`))}}return!d&&e.ucs.every(l=>l.groups.every(f=>f.rows.filter(a=>D(e.stage,a)).length===0))&&i.push(" nothing owed \u2014 design and execution are square"),i.push(""),i.push(c(" metric: live verifies edges \xB7 high \xD73 \xB7 staleness shown, not discounted")),n?i.push(c(` proven: graph execution facts \xB7 latest run ${n.latest_run?.started_at??"\u2014"} \xB7 ${n.aspect} formula verbatim`)):i.push(c(" proof: no runs recorded yet \u2014 run tests, then re-run")),i}function we(e,t,s){let n=F(e.slug);if(!t){let l=e.acTotal===0?"no scenarios yet":e.collapse||e.des.status==="complete"?`${e.acTotal} ACs \xB7 complete`:e.des.staleAcs>0?`${e.acTotal} ACs \xB7 ${e.des.staleAcs} stale`:`${e.acTotal} ACs \xB7 ${e.acTotal-e.acDesigned} unverified`,f=` ${e.mark} ${C(e.des.pct,10)} ${String(e.des.pct).padStart(3)}% ${n} `,a=Math.max(0,s-f.length-l.length-2);return`${f}${le(e.title,a).padEnd(a)} ${l}`}let r=e.provAbsent?"prov \xB7 not run":`prov ${C(e.prov?.pct??0,8)} ${String(e.prov?.pct??0).padStart(3)}%`,c=`des ${C(e.des.pct,8)} ${String(e.des.pct).padStart(3)}% \xB7 ${r}`,i=` ${e.mark} ${n} `,d=Math.max(0,s-i.length-c.length-2);return`${i}${le(e.title,d).padEnd(d)} ${c}`}function le(e,t){return e.length<=t?e:t<=1?e.slice(0,t):e.slice(0,t-1)+"\u2026"}function Te(e,t,s,n){let r=F(t.id??t.ref);if(s==="failing"){let c=(t.via_tests??[]).map((d,l)=>`${F(d)}${t.viaFiles?.[l]?` ${t.viaFiles[l]}`:""}`).join(", ");e.push(` \u2717 ${r} ${t.title} \u2014 failed${c?` \xB7 via ${c}`:""}`),t.servePath&&e.push(n(` \u2192 kane-cli evidence serve ${t.servePath} (see why it failed)`));let i=(t.viaFiles??[]).filter(d=>d!==null);i.length===1?e.push(n(` re-run after fixing: kane-cli testmd run ${i[0]} (heals on failure \u2014 fix the app first, or the test may re-author)`)):i.length>1&&e.push(n(" re-run after fixing: kane-cli testrun run (heals on failure \u2014 fix the app first, or the tests may re-author)"));return}if(s==="blocked"){e.push(` \u23F8 ${r} ${t.title} \u2014 (blocked \u2014 see why)`),t.servePath&&e.push(n(` \u2192 kane-cli evidence serve ${t.servePath} (see why)`));return}e.push(` ${r} ${t.title} \u2014 ${t.why}`),e.push(n(` \u2192 ${t.ready_command}`))}function Se(e,t,s){let n=t.map(c=>`${F(c.id??c.ref)} ${de(c.title,4)}`),r=" ";for(let c of n){let i=r.trim().length?" \xB7 ":"";r.length+i.length+c.length>s&&r.trim().length?(e.push(r),r=" "+c):r+=i+c}r.trim().length&&e.push(r)}function ge(e){let{dc:t,pa:s}=e,n=r=>e.top!==void 0?r.slice(0,e.top):r;return{stage:e.stage,rollup_version:1,design_completeness:{pct:t.pct,acs_designed:t.acs_designed,usecases_complete:t.usecases_complete,ucs_needing_scenarios:t.ucs_needing_scenarios,config:t.config},...s?{proven:{aspect:s.aspect,pct:s.pct,acs_proven:s.acs_proven,failing:s.failing,blocked:s.blocked,not_run:s.not_run,latest_run:s.latest_run,config:s.config}}:{},usecases:e.ucs.map(r=>({id:/^sha256:/.test(r.slug)?null:r.slug,title:r.title,risk:r.risk,design_completeness:{pct:r.des.pct,status:r.des.status},stale_acs:r.des.staleAcs,...s?{proven:r.prov??{pct:0,status:"not_run"}}:{},pending:n(r.groups.flatMap(c=>c.rows).filter(c=>D(e.stage,c))).map(ue)})),other:e.other.filter(r=>D(e.stage,r)).map(ue)}}function ue(e){let{servePath:t,viaFiles:s,meta:n,...r}=e;return{...r}}async function Ae(e){let t=await Q(e);return t.length===0?null:t.map(s=>({p:s,m:Re(s).mtimeMs})).sort((s,n)=>n.m-s.m)[0].p}async function Qe(e,t=ie(),s=process.cwd()){if(e.flat)return Ie(e,t,s);let n=e.stage??"all";if(n!=="design"&&n!=="cover"&&n!=="all")return x(t,`--stage must be design | cover | all, got '${n}'`),2;if(e.top!==void 0&&(!Number.isInteger(e.top)||e.top<1))return x(t,"--top must be a positive integer"),2;let r=e.aspect??"lenient";if(r!=="lenient"&&r!=="strict")return x(t,`--aspect must be lenient | strict, got '${r}'`),2;if(e.from)return x(t,"the tree reads the live graph \u2014 for a specific run's view use: kane-cli cover --from <pack> (legacy worklist: add --flat)"),2;let c=J(s,t);if(!c)return 2;let i=B(c),d=ne(i),l=ce(i,r),f=await K(i,"design"),a=new Map;if(l)for(let g of Object.values(l.perAc)){if(!g.executionId||a.has(g.executionId))continue;let h=await L(g.executionId,s);h&&a.set(g.executionId,h)}let p=new Map;for(let[g,h]of oe(re(s)))h.length===1&&p.set(g,j(h[0]));let o=pe(i,f,d,l,{stage:n,top:e.top,aspect:r,servePaths:a,testFiles:p});if(e.json)return t.out(JSON.stringify(ge(o),null,2)),0;if(d.usecases_complete==="0/0")return t.out("nothing to measure yet \u2014 no live use-cases in the graph"),0;let m=t.isTTY&&process.stdout.columns?process.stdout.columns:100;for(let g of fe(o,{width:m,color:t.isTTY}))t.out(g);return 0}async function Ie(e,t,s){let n=e.stage??"design";if(n!=="design"&&n!=="cover"&&n!=="all")return x(t,`--stage must be design | cover | all, got '${n}'`),2;if(e.top!==void 0&&(!Number.isInteger(e.top)||e.top<1))return x(t,"--top must be a positive integer"),2;let r=J(s,t);if(!r)return 2;let c,i;if(n!=="design"){let a=e.from?await L(e.from,s):await Ae(s);if(!a)return x(t,e.from?`no evidence pack at '${e.from}'`:`--stage ${n} needs an evidence pack \u2014 run a test first, or pass --from <pack> (live view: drop --flat)`),2;let p=await Y(a,"coverage/usecases.yaml");if(p==null)return x(t,`${j(a)} carries no coverage/usecases.yaml \u2014 re-run the tests to produce a coverage-bearing pack`),2;let o=V(p);if(!o||!Array.isArray(o.usecases))return x(t,`${j(a)}: coverage/usecases.yaml is not a usecases document`),2;c=o,i=j(a)}let d=B(r),l=await K(d,n,void 0,c),f=l.length;if(e.top!==void 0&&(l=l.slice(0,e.top)),e.json){let a=l.map(p=>Pe(d,p));return t.out(JSON.stringify({stage:n,...i?{pack:i}:{},total:f,rows:a},null,2)),0}return t.out(`gaps \u2014 stage ${n}${i?` \xB7 pack ${i}`:""} (${l.length}${l.length<f?` of ${f}`:""})`),l.length===0&&t.out(" nothing owed \u2014 design and execution are square"),l.forEach((a,p)=>{t.out(` ${String(p+1).padStart(2)}. [${a.risk}] ${a.tag} ${a.ref} \u2014 ${a.why}`),t.out(` \u2192 ${a.ready_command}`)}),0}function Pe(e,t){let s=e.resolve(t.ref),n=s?e.tipOf(s.cid):null,r=n?e.getNode(n)?.content:null;return{...t,id:n?e.displayNameOf(n)??e.displayNameOf(s.cid):null,title:String(r?.title??r?.text??"")}}export{Qe as gapsCommand};
|