kaizen-agent 1.61.2 → 1.61.3
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/cli/state.test.ts +20 -0
- package/cli/state.ts +18 -6
- package/package.json +1 -1
- package/web/board.html +1 -1
- package/web/board.js +1 -1
- package/web/notebook.js +1 -1
- package/web/term.js +2 -2
- package/web/term.ts +2 -1
- package/web/video.js +1 -1
package/cli/state.test.ts
CHANGED
|
@@ -1545,3 +1545,23 @@ test("runGit: a run owns the files its report lists as changed, not ones it only
|
|
|
1545
1545
|
expect(files("b")).toEqual(["whole.txt"]);
|
|
1546
1546
|
rmSync(proj, { recursive: true, force: true });
|
|
1547
1547
|
});
|
|
1548
|
+
|
|
1549
|
+
test("a committed run does not claim a file edited after its commit", () => {
|
|
1550
|
+
const root = mkdtempSync(join(tmpdir(), "kz-seal-")), st = join(root, ".kaizen"), run = join(st, "runs", "r1");
|
|
1551
|
+
mkdirSync(run, { recursive: true });
|
|
1552
|
+
const ago = (s: number) => Math.floor(Date.now() / 1000) - s;
|
|
1553
|
+
const sh = (at: number, ...a: string[]) => Bun.spawnSync(["git", "-c", "user.name=t", "-c", "user.email=t@t", ...a], { cwd: root, env: { ...process.env, GIT_AUTHOR_DATE: `${at} +0000`, GIT_COMMITTER_DATE: `${at} +0000` } }).stdout.toString().trim();
|
|
1554
|
+
sh(ago(300), "init", "-q"); sh(ago(300), "remote", "add", "origin", "https://example.com/x.git");
|
|
1555
|
+
writeFileSync(join(root, "a.txt"), "1"); sh(ago(300), "add", "a.txt"); sh(ago(300), "commit", "-qm", "init");
|
|
1556
|
+
writeFileSync(join(run, "03-impl.md"), "## Changed\n- `a.txt`: edit\n");
|
|
1557
|
+
utimesSync(join(run, "03-impl.md"), ago(200), ago(200));
|
|
1558
|
+
writeFileSync(join(root, "b.txt"), "1"); sh(ago(100), "add", "b.txt"); sh(ago(100), "commit", "-qm", "the run");
|
|
1559
|
+
writeFileSync(join(root, "a.txt"), "2");
|
|
1560
|
+
const before: Record<string, string> = {}, after: Record<string, string> = {};
|
|
1561
|
+
cardsGit(st, ["r1"], before as any);
|
|
1562
|
+
expect(before.r1).toBe("commit"); // no commit recorded: still the run's
|
|
1563
|
+
writeFileSync(join(run, "07-commit.md"), `commit: ${sh(ago(0), "rev-parse", "--short", "HEAD")}\npushed: no\n`);
|
|
1564
|
+
cardsGit(st, ["r1"], after as any);
|
|
1565
|
+
expect(after.r1).not.toBe("commit");
|
|
1566
|
+
rmSync(root, { recursive: true, force: true });
|
|
1567
|
+
});
|
package/cli/state.ts
CHANGED
|
@@ -1973,10 +1973,19 @@ const lastCommit = (dir: string, p: string) => Number(git(dir, "--literal-pathsp
|
|
|
1973
1973
|
// A changed file is the run's unless it was committed after the report: then the run's
|
|
1974
1974
|
// work in it is in, and what changed since is someone else's. A commit in the same
|
|
1975
1975
|
// second as the report keeps the file offered; hiding real work is the worse mistake.
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1976
|
+
// A run with a recorded commit is closed: a file edited after that commit is someone
|
|
1977
|
+
// else's, even when the commit left it out, unless a later report (a fix) reopened the run.
|
|
1978
|
+
const commitTime = (dir: string, sha?: string) => (sha && /^[0-9a-f]{4,40}$/i.test(sha) ? Number(git(dir, "show", "-s", "--format=%ct", sha).out) * 1000 || 0 : 0);
|
|
1979
|
+
const editedAfter = (dir: string, p: string, t: number) => {
|
|
1980
|
+
try { return statSync(join(dir, p)).mtimeMs >= t + 1000; } catch { return false; }
|
|
1981
|
+
};
|
|
1982
|
+
const runFiles = (dir: string, changed: string[], mine: Report, rest: Report[]) => {
|
|
1983
|
+
const sealed = commitTime(dir, mine.sha);
|
|
1984
|
+
return changed.filter((l) => {
|
|
1985
|
+
const p = statusPath(l);
|
|
1986
|
+
return owns(mine, rest, p, Infinity) && !(lastCommit(dir, p) > mine.at) && !(sealed >= mine.at - 1000 && sealed > 0 && editedAfter(dir, p, sealed));
|
|
1987
|
+
});
|
|
1988
|
+
};
|
|
1980
1989
|
// How many unpushed commits each run has, worked out once for every run. A commit is
|
|
1981
1990
|
// one run's, so a wide commit is not pinned on every old run that once touched a file
|
|
1982
1991
|
// in it: the run whose record holds its SHA, then the report holding its subject, else, of
|
|
@@ -2170,10 +2179,13 @@ export function cardsGit(state: string, ids: string[], due: Record<string, "comm
|
|
|
2170
2179
|
const all = runReports(state), ahead = aheadBy(s, all);
|
|
2171
2180
|
for (const id of ids) {
|
|
2172
2181
|
const mine = all.find((r) => r.id === id) ?? { id, text: "", named: "", at: 0 }, k = readCommit(state, id);
|
|
2173
|
-
|
|
2182
|
+
// A run in its own worktree is judged there: the project folder's changes are not its.
|
|
2183
|
+
const wt = codeDir(dir, id), st = wt === dir ? s : gitStatus(wt);
|
|
2184
|
+
if (!st.repo) continue;
|
|
2185
|
+
const files = runFiles(wt, st.files, mine, all.filter((o) => o.id !== id)).length;
|
|
2174
2186
|
if (files) out[id] = "pending", due[id] = "commit";
|
|
2175
2187
|
else if (k?.pushed) out[id] = "pushed";
|
|
2176
|
-
else if (ahead(id) > 0) out[id] = "pending", due[id] = "push";
|
|
2188
|
+
else if ((wt === dir ? ahead : aheadBy(st, all))(id) > 0) out[id] = "pending", due[id] = "push";
|
|
2177
2189
|
else if (k || mine.text) out[id] = "pushed";
|
|
2178
2190
|
}
|
|
2179
2191
|
return out;
|
package/package.json
CHANGED
package/web/board.html
CHANGED
|
@@ -748,7 +748,7 @@ aside .foot .more .menu-pop{left:0;right:auto;top:auto;bottom:calc(100% + 4px)}.
|
|
|
748
748
|
.sjump{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}.sjump button{padding:3px 10px;border:1px solid var(--line);border-radius:var(--r-pill);font-size:12px;color:var(--dim)}.sjump button:hover{background:var(--hover);color:var(--ink)}
|
|
749
749
|
.snone{color:var(--dim);margin-top:20px}
|
|
750
750
|
/* settings, laid out as Orca's: its own sidebar in place of the rail, one page per item, rows in one card */
|
|
751
|
-
@media(min-width:641px){body.setv .rail{display:none}body.setv #panel>header{display:none}body.setv #panel>.body{padding:0!important;overflow:hidden}body.setv #panel{background:none;border-color:transparent;box-shadow:none}.sset .snav{background:none;border-right:0}.sset .snav .sq{border-block:0;padding
|
|
751
|
+
@media(min-width:641px){body.setv .rail{display:none}body.setv #panel>header{display:none}body.setv #panel>.body{padding:0!important;overflow:hidden}body.setv #panel{background:none;border-color:transparent;box-shadow:none}body.setv .app{margin:0;background:none;border:0;border-radius:0}.sset .snav{background:none;border-right:0;padding:18px 12px 14px}.sset .sback{margin:0 0 6px;padding:0 var(--padx);height:var(--row);gap:var(--gap);font-size:var(--fs);font-weight:500}.sset .snav .sq{border-block:0;padding:0 0 8px}.sset .snavs{padding:6px 0 0}.sset .snavg{margin-bottom:14px}.sset .snavg p{margin:0 0 2px;padding:0 var(--padx);font-size:var(--fs-xs);font-weight:600;text-transform:none;letter-spacing:0}.sset .snavg button{height:var(--row);padding:0 var(--padx);gap:var(--gap);font-size:var(--fs);font-weight:500}.sset .snavg button[aria-current]{background:color-mix(in srgb,var(--accent) 14%,transparent);color:var(--ink);font-weight:500}.sset .snavg button[aria-current] svg{color:var(--accent)}.sset .smain{margin:8px 8px 0 0;background:var(--bg);border:1px solid var(--line);border-radius:12px}}
|
|
752
752
|
.sset{display:grid;grid-template-columns:280px minmax(0,1fr);height:100%}
|
|
753
753
|
.snav{min-height:0;display:flex;flex-direction:column;background:var(--bg-2);border-right:1px solid var(--line)}
|
|
754
754
|
.sback{flex:none;display:flex;align-items:center;gap:8px;padding:0 12px;margin:12px;height:var(--btn-s);border-radius:var(--r-s);font-size:13px;color:var(--dim);text-align:left}.sback:hover,.sup:hover{color:var(--ink)}
|
package/web/board.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* kaizen board
|
|
1
|
+
/* kaizen board 0faf2181372af590 -- generated by bun run build:web from web/board/main.ts; do not edit */
|
|
2
2
|
(()=>{var f={S:{project:null,projects:[],cards:[],now:Date.now(),all:!1,dir:null},all:new URLSearchParams(location.search).get("all")!=="0",dir:null,openKey:null,mode:null,modeKey:null,menuKey:null,flash:new Set,tab:"request",lastTab:"request",runDoc:null,clearMenu:!1,sevMenu:!1,wantTerm:null,wantPty:null,shells:[],setQ:"",setScope:"all",setPage:null,setBack:!1,pageGen:0,PL:[],shown:new Set((()=>{try{return JSON.parse(localStorage.getItem("kz-show"))||[]}catch(e){return[]}})())};var i=(e)=>document.getElementById(e),tn=(e)=>String(e).replace(/[&<>"]/g,(t)=>({"&":"&","<":"<",">":">",'"':"""})[t]);class Ro{s;constructor(e){this.s=e}toString(){return this.s}}var R=(e)=>new Ro(String(e)),Mi=(e)=>e instanceof Ro?e.s:Array.isArray(e)?e.map(Mi).join(""):e==null||e===!1?"":tn(e),c=(e,...t)=>R(e.reduce((n,s,o)=>n+Mi(t[o-1])+s)),E=(e)=>R(`<svg><use href="#i-${e}"/></svg>`),Ti=R('<div aria-busy="true" aria-label="Loading"><span class="skel" style="height:16px;width:35%;margin:20px 0 14px"></span>'+'<span class="skel" style="height:44px;margin-bottom:10px"></span>'.repeat(4)+"</div>"),Vc=1500000;async function Yc(e){if(e.size<=Vc||!/^image\/(jpeg|png|webp|bmp|heic|heif)$/.test(e.type))return e;try{let t=await createImageBitmap(e),n=Math.min(1,2560/Math.max(t.width,t.height)),s=document.createElement("canvas");s.width=Math.round(t.width*n),s.height=Math.round(t.height*n),s.getContext("2d").drawImage(t,0,0,s.width,s.height);let o=await new Promise((a)=>s.toBlob(a,"image/jpeg",0.85));return o&&o.size<e.size?new File([o],e.name.replace(/\.\w+$/,"")+".jpg",{type:"image/jpeg"}):e}catch{return e}}var nn=(e)=>Promise.all(e.map(async(t)=>{let n=await Yc(t);return new Promise((s)=>{let o=new FileReader;o.onload=()=>s({name:n.name,data:o.result}),o.readAsDataURL(n)})}));function Xe(e){let t=document.createElement("dialog");return t.className="kz",t.innerHTML=`<form class="inl" method="dialog">${e}</form>`,t.onclose=()=>t.remove(),t.onclick=(n)=>{if(n.target===t)t.close()},document.body.appendChild(t),t.showModal(),t}var Vn=()=>{let e=document.documentElement.dataset.motion;return e?e==="full":!matchMedia("(prefers-reduced-motion: reduce)").matches},gt=(e)=>Vn()&&document.startViewTransition?document.startViewTransition(e).updateCallbackDone:(e(),Promise.resolve());var Ci;function j(e,t){let n=i("toast");if(n.textContent=e,n.classList.toggle("rep",!!t),t){let s=document.createElement("a");s.href="/issue?"+new URLSearchParams(t),s.target="_blank",s.rel="noopener",s.textContent="Report",n.append(" ",s)}n.classList.add("on"),clearTimeout(Ci),Ci=setTimeout(()=>n.classList.remove("on"),t?8000:4000)}function bt(){try{if(typeof Notification<"u"&&Notification.permission==="default")Notification.requestPermission()}catch(e){}}var qi=(e,t)=>{try{return localStorage.getItem(e)||t}catch(n){return t}},Ms=()=>qi("kz-notify","on")==="on",bn=()=>qi("kz-sound","Bellatrix"),ji=["Adara","Alya","Bellatrix","Beryllium","Cobalt","Fluorine","Krypton","Palladium","Rubidium","Xenon"],Ts=["off",...ji,"chime","bell","pop"],Ai={chime:[[880,0,0.25],[1320,0.12,0.35]],bell:[[660,0,0.9]],pop:[[520,0,0.08]]},rt;function Yn(e=bn()){try{if(ji.includes(e)){let n=new Audio(`/sounds/${e}.mp3`);n.volume=0.35,n.play().catch(()=>{});return}if(!Ai[e])return;rt=rt||new AudioContext,rt.resume();let t=rt.currentTime+0.02;for(let[n,s,o]of Ai[e]){let a=rt.createOscillator(),l=rt.createGain();a.type=e==="pop"?"triangle":"sine",a.frequency.value=n,l.gain.setValueAtTime(0.0001,t+s),l.gain.exponentialRampToValueAtTime(0.25,t+s+0.01),l.gain.exponentialRampToValueAtTime(0.0001,t+s+o),a.connect(l).connect(rt.destination),a.start(t+s),a.stop(t+s+o+0.05)}}catch(t){}}addEventListener("pointerdown",()=>{try{rt=rt||new AudioContext,rt.resume()}catch(e){}},{once:!0});function No(e,t){if(!Ms())return;Yn();try{if(typeof Notification<"u"&&Notification.permission==="granted")new Notification("kaizen",{body:e,icon:"/logo.png",tag:t})}catch(n){}}var Qc="https://cdn.jsdelivr.net/npm/@huggingface/transformers@4.3.0",Hi={tiny:"onnx-community/whisper-tiny",base:"onnx-community/whisper-base",small:"onnx-community/whisper-small","large-v3-turbo":"onnx-community/whisper-large-v3-turbo"},Io=null,Xc=`import{pipeline}from"${Qc}";let asr=null;
|
|
3
3
|
onmessage=async e=>{const m=e.data;try{
|
|
4
4
|
if(m.type==="load"){const prog=p=>{if(p.status==="progress")postMessage({type:"progress",file:p.file,pct:p.progress||0})};
|
package/web/notebook.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* kaizen notebook
|
|
1
|
+
/* kaizen notebook 0faf2181372af590 -- generated by bun run build:web from web/notebook.ts; do not edit */
|
|
2
2
|
var Ka=null,Ja=(e)=>{Ka=e};function Am(e,t,i){Vr++,Ka?.(e,t,i)}var Vr=0,Fa="",Ur=!1,As=!1;async function Nr(){if(Ur){As=!0;return}Ur=!0;do{As=!1;let e=Vr;try{let t=await fetch("/state?all=1");if(!t.ok)continue;let i=await t.text(),n=i.replace(/"now":\d+\}$/,"");if(n===Fa)continue;let{cards:s,projects:r,rail:o,agents:l}=JSON.parse(i);if(!As&&e===Vr)Fa=n,Am(s,[...r,...o??[]],l)}catch{}}while(As);Ur=!1}var Xm={S:{project:null,projects:[],cards:[],now:Date.now(),all:!1,dir:null},all:new URLSearchParams(location.search).get("all")!=="0",dir:null,openKey:null,mode:null,modeKey:null,menuKey:null,flash:new Set,tab:"request",lastTab:"request",runDoc:null,clearMenu:!1,sevMenu:!1,wantTerm:null,wantPty:null,shells:[],setQ:"",setScope:"all",setPage:null,setBack:!1,pageGen:0,PL:[],shown:new Set((()=>{try{return JSON.parse(localStorage.getItem("kz-show"))||[]}catch(e){return[]}})())};var G=(e)=>document.getElementById(e),Zm=(e)=>String(e).replace(/[&<>"]/g,(t)=>({"&":"&","<":"<",">":">",'"':"""})[t]);class Gr{s;constructor(e){this.s=e}toString(){return this.s}}var bt=(e)=>new Gr(String(e)),eh=(e)=>e instanceof Gr?e.s:Array.isArray(e)?e.map(eh).join(""):e==null||e===!1?"":Zm(e),R=(e,...t)=>bt(e.reduce((i,n,s)=>i+eh(t[s-1])+n));var vw=bt('<div aria-busy="true" aria-label="Loading"><span class="skel" style="height:16px;width:35%;margin:20px 0 14px"></span>'+'<span class="skel" style="height:44px;margin-bottom:10px"></span>'.repeat(4)+"</div>");function Xs(e){let t=document.createElement("dialog");return t.className="kz",t.innerHTML=`<form class="inl" method="dialog">${e}</form>`,t.onclose=()=>t.remove(),t.onclick=(i)=>{if(i.target===t)t.close()},document.body.appendChild(t),t.showModal(),t}var mi=(e,t)=>{let i=t-e;return i<3600000?Math.round(i/60000)+"m":i<86400000?Math.round(i/3600000)+"h":Math.round(i/86400000)+"d"};var Kr=(e)=>typeof e==="string"?[e]:e.kids.flatMap(Kr);var Jr=(e,t)=>`ws:${e}:${t}`,sh=(e)=>e.kind==="run"&&e.status==="done"&&e.accept!=="needs"&&!e.archived&&e.git==="pending";var rh=3000,Ms=new Map,vn=(e)=>e.key+"@"+(e.born??0),th={asking:0,working:1,done:2},Zs={asking:"Asking",working:"Working",done:"Done"},Mm={asking:"wait",working:"build",done:"done"};function Rm(e,t,i=Ms){if(e.asking)return"asking";if(e.busy)return i.set(vn(e),t),"working";return t-(i.get(vn(e))??-1/0)<rh?"working":"done"}var oh=(e,t,i=Ms)=>Math.min(1/0,...e.filter((n)=>!n.asking&&!n.busy&&i.has(vn(n))).map((n)=>rh-(t-i.get(vn(n)))).filter((n)=>n>0)),lh=(e,t=Ms)=>{let i=new Set(e.map(vn));for(let n of t.keys())if(!i.has(n))t.delete(n)},ah=(e,t,i,n,s,r=Ms)=>e.filter((o)=>o.dir===t&&n({state:o.dir,ws:o.ws})===i).map((o)=>({a:o,st:Rm(o,s,r)})).sort((o,l)=>th[o.st]-th[l.st]),ih=({a:e,st:t})=>e.last||`${Zs[t]} - ${e.name}`,nh=(e,t)=>!e?"":t-e<60000?"now":mi(e,t),jm=(e,t)=>e+"\x00"+t;function hh(e,t,i){let n=jm(t,i);if(e[n])delete e[n];else e[n]=!0;return e}var Lm=["claude","codex","gemini"],Hr=(e)=>R`<svg aria-hidden="true"><use href="#i-${Lm.includes(e.agent??"")?e.agent:"ai"}"/></svg>`,Fr=(e)=>R`<i class="si ${Mm[e]}"></i>`,Em=R`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 9l6 6 6-6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;function ch(e,t,i,n,s){if(!e.length)return"";let r=R`data-dir="${n}" data-ws="${s}"`;if(e.length===1){let a=e[0];return R`<div class="wag"><button type="button" class="aone" data-term="${a.a.key}" ${r} title="${a.a.name}: open its terminal">${Fr(a.st)}${Hr(a.a)}<span class="atx">${Zs[a.st]} - ${a.a.name}</span><small>${nh(a.a.at,t)}</small></button></div>`}let o=R`<button type="button" class="wchev${i?" on":""}" data-wopen ${r} aria-expanded="${String(i)}" aria-label="${String(e.length)} agents: ${i?"hide":"show"} the list">${Em}</button>`;if(i)return R`<div class="wag"><span class="aht">${String(e.length)} agents</span>${o}</div><div class="alist">${e.map((a)=>R`<button type="button" class="arow" data-term="${a.a.key}" ${r} title="${ih(a)}">${Fr(a.st)}${Hr(a.a)}<span class="atx">${ih(a)}</span><small>${nh(a.a.at,t)}</small></button>`)}</div>`;let l=["asking","working","done"].map((a)=>({st:a,rs:e.filter((h)=>h.st===a)})).filter((a)=>a.rs.length);return R`<div class="wag"><span class="chips">${l.map((a)=>R`<span class="chip">${Fr(a.st)}${a.rs.map((h)=>R`<button type="button" class="amark" data-term="${h.a.key}" ${r} title="${h.a.name} - ${Zs[a.st]}: open its terminal" aria-label="${h.a.name} - ${Zs[a.st]}: open its terminal">${Hr(h.a)}</button>`)}</span>`)}</span>${o}</div>`}function eo(e){return e.toLowerCase().trim().replace(/[^a-z0-9/._-]+/g,"-").replace(/\.{2,}/g,".").replace(/\/{2,}/g,"/").replace(/(^|\/)[-.]+/g,"$1").slice(0,60).replace(/[-./]+(\/|$)/g,"$1").replace(/\/$/,"").replace(/\.lock(\/|$)/g,"-lock$1")}var _m=(e)=>e.includes("\\")?"\\":"/";async function Ut(e,t){try{let i=await fetch(e,t?{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}:void 0),n=await i.json().catch(()=>({}));return{ok:i.ok,d:i.ok?n:{error:n.error||n.why||"that did not work"}}}catch{return{ok:!1,d:{error:"the board is offline"}}}}function Pn(e={}){let t=Xs(""),i=t.querySelector("form");t.setAttribute("aria-label","Add a project");let n=e.start==="ws",s=(u)=>i.elements.namedItem(u),r=(u,d,p,O)=>(u.disabled=d,u.textContent=d?p:O),o=n?"":R`<button type="button" class="btn ghost" data-a="back">Back to add options</button>`,l=(u)=>R`<small class="att err" role="alert"></small><div class="row">${o}<button type="button" class="btn ghost" data-a="x">Cancel</button><button class="btn pri" data-a="go">${u}</button></div>`,a=(u)=>i.querySelector(".err").textContent=u,h=(u,d)=>{a(d);try{localStorage.setItem("kz-proj",u)}catch{}setTimeout(()=>location.href="/?view=board",900)},c=async(u,d)=>{let p=await Ut("/pick-folder",{});if(p.d.path)u.value=d?p.d.path.replace(/[\\/]+$/,"")+_m(p.d.path)+d():p.d.path},f=(u)=>{let d=fh();if(t.classList.toggle("wsnew",u==="ws"),u==="menu")i.innerHTML=R`<b>Add a project</b><small class="att">Add a project to get started with kaizen.</small><button type="button" class="btn opt" data-go="folder"><b>Existing folder</b><small>A project, a Git repo, or any folder</small></button><small class="att">Other ways to add</small><button type="button" class="btn opt" data-go="clone"><b>Clone from URL</b><small>Clone a remote Git repository</small></button><button type="button" class="btn opt" data-go="create"><b>Create new project</b><small>Start from an empty folder</small></button>${d.length?R`<button type="button" class="btn opt" data-go="ws"><b>New workspace</b><small>A branch in its own folder, in a project you have</small></button>`:""}<div class="row"><button type="button" class="btn ghost" data-a="x">Cancel</button></div>`.toString(),i.querySelectorAll("[data-go]").forEach((O)=>O.onclick=()=>f(O.dataset.go)),i.onsubmit=(O)=>O.preventDefault();else if(u==="folder")i.innerHTML=R`<b>Existing folder</b><small class="att">Pick a folder, or type its path. A .kaizen folder is added to it.</small><div class="row"><input name="path" placeholder="/path/to/folder" aria-label="Folder" autocomplete="off" spellcheck="false" required><button type="button" class="btn ghost" data-a="pick">Pick…</button></div>${l("Add project")}`.toString(),s("path").focus(),i.onsubmit=async(O)=>{O.preventDefault();let g=i.querySelector("[data-a=go]");r(g,!0,"Adding...","Add project");let b=await Ut("/add-project",{path:s("path").value.trim()});r(g,!1,"","Add project"),b.ok?h(b.d.dir,b.d.already?"Project already added":"Project added"):a(b.d.error)},i.querySelector("[data-a=pick]").onclick=()=>c(s("path"));else if(u==="clone"){i.innerHTML=R`<b>Clone from URL</b><small class="att">Enter the Git URL (https or ssh) and choose where to clone it.</small><input name="url" placeholder="https://github.com/user/repo.git" aria-label="Git URL" autocomplete="off" spellcheck="false" required><div class="row"><input name="to" placeholder="Folder to clone into" aria-label="Clone into" autocomplete="off" spellcheck="false"><button type="button" class="btn ghost" data-a="pick">Pick…</button></div>${l("Clone")}`.toString(),s("url").focus();let O="",g="",b=async()=>{let y=s("url").value.trim();if(!y)return!1;let S=await Ut("/clone",{url:y,check:!0});if(!S.ok)return a(S.d.error),!1;if(a(""),O=S.d.name,!s("to").value.trim()||s("to").value===g)s("to").value=g=S.d.to;return!0};s("url").onchange=b,i.querySelector("[data-a=pick]").onclick=async()=>await b()?c(s("to"),()=>O):s("url").focus(),i.onsubmit=async(y)=>{if(y.preventDefault(),!await b())return;let S=i.querySelector("[data-a=go]");r(S,!0,"Cloning...","Clone");let x=await Ut("/clone",{url:s("url").value.trim(),to:s("to").value.trim()||void 0});r(S,!1,"","Clone"),x.ok?h(x.d.dir,"Cloned"):a(x.d.error)}}else if(u==="create"){i.innerHTML=R`<b>Create a new project</b><small class="att">Name it and kaizen will create the folder with a .kaizen inside.</small><input name="name" placeholder="my-project" aria-label="Name" autocomplete="off" spellcheck="false" required><div class="row"><input name="to" placeholder="Folder to create" aria-label="Create in" autocomplete="off" spellcheck="false"><button type="button" class="btn ghost" data-a="pick">Pick…</button></div><label class="att"><input type="checkbox" name="git" checked> Git repository</label>${l("Create project")}`.toString(),s("name").focus();let O="";s("name").oninput=async()=>{let g=s("name").value.trim();if(!g||/[\\/:*?"<>|]/.test(g)||s("to").value.trim()&&s("to").value!==O)return;let b=await Ut("/new-project",{name:g,check:!0});if(b.ok&&s("name").value.trim()===g)s("to").value=O=b.d.to},i.querySelector("[data-a=pick]").onclick=()=>c(s("to"),()=>s("name").value.trim()),i.onsubmit=async(g)=>{g.preventDefault();let b=i.querySelector("[data-a=go]");r(b,!0,"Creating...","Create project");let y=await Ut("/new-project",{name:s("name").value.trim(),to:s("to").value.trim()||void 0,git:s("git").checked});if(r(b,!1,"","Create project"),!y.ok)return a(y.d.error);h(y.d.dir,y.d.git===!1?"Project created, but git init failed":"Project created")}}else{let O=d.some((S)=>S.dir===e.dir)?e.dir:d[0]?.dir,g=/Mac/.test(navigator.platform)?"⌘":"Ctrl";i.innerHTML=R`<b>New workspace</b><label class="att">Project<select name="project" aria-label="Project">${d.map((S)=>R`<option value="${S.dir}"${S.dir===O?" selected":""}>${S.name}</option>`)}</select></label><div class="wsfrom"><span class="att" id="wsfl">Create from <i>[Optional]</i></span><label class="wsbase">from <select name="base" aria-label="Start from branch"></select></label></div><input name="name" placeholder="What is this workspace for?" aria-labelledby="wsfl" autocomplete="off" spellcheck="false"><details class="wsadv"><summary>Advanced</summary><label class="att">Branch name<input name="branch" placeholder="feature/my-branch" aria-label="Branch name" autocomplete="off" spellcheck="false"></label></details><small class="att err" role="alert"></small><div class="row">${o}<button type="button" class="btn ghost" data-a="x">Cancel</button><button class="btn pri" data-a="go">Create workspace</button><kbd class="wskey" aria-hidden="true">${g} ↵</kbd></div>`.toString(),s("name").focus();let b=i.elements.namedItem("base");s("name").oninput=()=>s("branch").placeholder=eo(s("name").value)||"feature/my-branch";let y=async()=>{let S=await Ut("/branches?dir="+encodeURIComponent(s("project").value)),{def:x="",branches:v=[]}=S.ok?S.d:{};b.innerHTML=v.map((X)=>R`<option${X===x?" selected":""}>${X}</option>`.toString()).join("")||'<option value="">current branch</option>'};i.elements.namedItem("project").onchange=y,y(),i.onkeydown=(S)=>{if(S.key==="Enter"&&(S.ctrlKey||S.metaKey))S.preventDefault(),i.requestSubmit()},i.onsubmit=async(S)=>{S.preventDefault();let x=s("project").value,v=i.querySelector("[data-a=go]");if(v.disabled)return;a("");let X=s("branch").value.trim()||eo(s("name").value)||"workspace-"+Math.random().toString(36).slice(2,6);r(v,!0,"Creating...","Create workspace");let T=await Ut("/worktree",{dir:x,branch:X,base:b.value||void 0});r(v,!1,"","Create workspace"),T.ok?(t.close(),location.href=Vt(x,T.d.path)):a(T.d.error)}}i.querySelector("[data-a=x]").onclick=()=>t.close();let p=i.querySelector("[data-a=back]");if(p)p.onclick=()=>f("menu")};f(e.start??"menu")}function uh(e,t){let i=t.toLowerCase().split(/\s+/).filter(Boolean);if(!i.length)return e;let n=t.trim().toLowerCase(),s=(r)=>{let o=r.title.toLowerCase();return o.startsWith(n)?0:o.includes(n)?1:2};return e.filter((r)=>{let o=(r.title+" "+(r.sub??"")+" "+r.hay).toLowerCase();return i.every((l)=>o.includes(l))}).sort((r,o)=>s(r)-s(o)||(o.at??0)-(r.at??0))}var js=(e,t)=>!dispatchEvent(new CustomEvent(e,{cancelable:!0,detail:t})),gi=(e,t)=>()=>{let i=document.querySelector(`.rail a.it[data-view="${e}"]`);i?i.click():location.href=t},dh=(e,t)=>{if(!js("kz-open-ws",{dir:e,ws:t}))location.href=Vt(e,t)},mh=()=>{try{return JSON.parse(localStorage.getItem("kz-runtabs")||"{}")}catch{return{}}},zm=(e,t,i)=>{if(js("kz-open-tab",{dir:e,ws:t,id:i}))return;let n=mh(),s=n[Jr(e,t)],r=s?.screens?.find((o)=>Kr(o.tree).includes(i));if(r)try{s.on=r.id,localStorage.setItem("kz-runtabs",JSON.stringify(n))}catch{}location.href=Vt(e,t)},Ym=["local","preview","note","history","shell"],qm=(e)=>{try{return localStorage.getItem("kz-browse:"+e)?.replace(/^https?:\/\//,"").replace(/\/$/,"")}catch{}},Dm={ws:'<circle cx="6" cy="6" r="2"/><circle cx="6" cy="18" r="2"/><circle cx="18" cy="8" r="2"/><path d="M6 8v8M18 10c0 4-6 3-12 6"/>',run:'<path d="M5 4l14 8-14 8z"/>',idea:'<path d="M9 18h6M10 21h4M12 3a6 6 0 0 0-4 10.5c.7.7 1 1.5 1 2.5h6c0-1 .3-1.8 1-2.5A6 6 0 0 0 12 3z"/>',chat:'<path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z"/>',term:'<path d="M4 17l6-5-6-5M12 19h8"/>',proj:'<path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>',page:'<rect x="4" y="4" width="16" height="16" rx="2"/><path d="M4 9h16"/>',act:'<path d="M13 3L5 14h6l-1 7 8-11h-6z"/>',tab:'<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 9h8V5"/>',plus:'<path d="M12 5v14M5 12h14"/>',search:'<circle cx="11" cy="11" r="7"/><path d="M20 20l-4-4"/>'},gh=(e)=>bt(`<svg viewBox="0 0 24 24" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${Dm[e]}</g></svg>`),bh=[];function Wm(){let{cards:e,projects:t=[],agents:i=[]}=kh(),n=Date.now(),s=new URLSearchParams(location.search),r=s.get("id")&&e.find((u)=>u.kind==="run"&&u.state===s.get("dir")&&u.id===s.get("id")),o=s.get("ws")??(r?Yi(r,t):null),l=[],a=mh(),h=new Map;for(let u of e){let d=u.state+"\x00"+Yi(u,t);h.set(d,Math.max(h.get(d)??0,u.moved??0))}for(let u of t){let d=Ve(u.dir,t);for(let p of u.workspaces??[]){let O=s.get("dir")===u.dir&&o===p.path,g=h.get(u.dir+"\x00"+p.path);l.push({group:O?"Current":"Workspaces",title:bi(p),sub:d,when:g?mi(g,n):void 0,hay:`${bi(p)} ${d} ${p.path} workspace`,at:O?1/0:g??0,ico:"ws",act:()=>dh(u.dir,p.path)});let b=Jr(u.dir,p.path),y=a[b];for(let S of y?.tabs??[]){if(!Ym.includes(S.kind)||y.hidden?.includes(S.id))continue;let x=S.kind==="local"&&qm(b)||S.title;l.push({group:"Tabs",title:x,sub:`${bi(p)} · ${d}`,hay:`${x} ${S.title} ${S.kind} ${S.note??""} ${bi(p)} ${d} tab`,ico:"tab",act:()=>zm(u.dir,p.path,S.id)})}}l.push({group:"Projects",title:d,hay:`${d} ${u.dir} project`,ico:"proj",act:()=>{let p=u.workspaces?.find((O)=>O.main)??u.workspaces?.[0];p?dh(u.dir,p.path):gi("board","/?view=board")()}})}for(let u of e.filter((d)=>!d.archived)){let d=yi(u);l.push({group:u.kind==="run"?"Runs":"Ideas",title:io(u)||u.id,sub:Ve(u.state,t),when:u.moved?mi(u.moved,n):void 0,hay:`${io(u)} ${u.id??""} ${u.text??""} ${Ve(u.state,t)} ${d}`,at:u.moved??0,dot:d,ico:u.kind==="run"?"run":"idea",act:()=>{if(!js("kz-open-card",{dir:u.state,id:u.kind==="run"?u.id:void 0,text:u.text}))location.href=Sh(u)}})}for(let u of bh){let d=Date.parse(u.updated)||0;l.push({group:"Chats & terminals",title:u.title||"Chat",sub:u.project?Ve(u.project,t):void 0,when:d?mi(d,n):void 0,hay:`${u.title} chat ${u.project??""}`,at:d,dot:u.busy?"build":void 0,ico:"chat",act:()=>{try{sessionStorage.setItem("kz-chat",u.id)}catch{}gi("home","/")()}})}for(let u of i)l.push({group:"Chats & terminals",title:u.name||u.agent||"Terminal",sub:Ve(u.dir,t),hay:`${u.name} ${u.agent??""} ${u.run??""} ${u.last??""} ${Ve(u.dir,t)} terminal agent`,at:u.at??u.born??0,dot:u.asking?"wait":u.busy?"build":"done",ico:"term",act:()=>{if(!js("kz-open-term",{dir:u.dir,ws:u.ws,key:u.key}))location.href=Vt(u.dir,u.ws??"")}});let c=(u)=>()=>G(u)?.click(),f=[["Home","page",gi("home","/"),"chat"],["Icebox","page",gi("sources","/?view=icebox"),"requests sources gathered"],["Ideas","page",gi("ideas","/?view=ideas"),"backlog"],["Board","page",gi("board","/?view=board"),"kanban runs"],["Notes","page",()=>location.href="/notebook","notebook docs"],["Settings","page",gi("settings","/?view=settings"),"preferences config"],["New idea","act",()=>G("newtop")?G("newtop").click():location.href="/?view=board","create add run"],["Add a project","act",()=>Pn({dir:null}),"clone folder create workspace"],["Toggle theme","act",c("themet"),"dark light"],["Collapse or expand menu","act",c("fold"),"sidebar rail"],["Keyboard shortcuts","act",c("kbd"),"keys help"],["Report an issue","act",()=>open("/issue","_blank","noopener"),"bug feedback"]];for(let[u,d,p,O]of f)l.push({group:"Actions",title:u,hay:`${u} ${O??""}`,ico:d,act:p});return l}var Bm=["Current","Workspaces","Tabs","Chats & terminals","Runs","Ideas","Projects","Actions"],Im={Workspaces:5,Tabs:4,"Chats & terminals":5,Runs:5,Ideas:3,Projects:5},H=null,nt=[],st=0;function Rs(){let e=H.querySelector("input").value,t=Wm(),i=e.trim()?uh(t,e):t.slice().sort((o,l)=>(l.at??0)-(o.at??0));nt=[];let n=e.trim()?[...new Set(i.map((o)=>o.group))]:Bm;for(let o of n){let l=i.filter((a)=>a.group===o);nt.push(...l.slice(0,e.trim()?8:Im[o]??l.length))}if(e.trim())nt.push({group:"Create",title:`New idea "${e.trim()}"`,hay:"",ico:"plus",act:()=>Um(e.trim())});st=Math.min(st,nt.length-1);let s=H.querySelector(".gs-list"),r="";s.innerHTML=String(R`${nt.map((o,l)=>{let a=o.group!==r?(r=o.group,R`<div class="gs-h" role="presentation">${o.group}</div>`):"";return R`${a}<div class="gs-i" role="option" id="gs-${l}" data-n="${l}" aria-selected="${String(l===st)}">${gh(o.ico)}${o.dot?R`<span class="si ${o.dot}"></span>`:""}<span class="gs-t">${o.title}</span>${o.sub?R`<span class="gs-s">${o.sub}</span>`:""}${o.when?R`<span class="gs-w">${o.when}</span>`:""}</div>`})}${nt.length===1&&e.trim()?R`<div class="gs-none">No results</div>`:""}`),to(st),H.querySelector(".gs-live").textContent=`${nt.length} result${nt.length===1?"":"s"} found`}function to(e){H.querySelector(`#gs-${st}`)?.setAttribute("aria-selected","false"),st=e;let t=H.querySelector(`#gs-${e}`);t?.setAttribute("aria-selected","true"),H.querySelector("input").setAttribute("aria-activedescendant","gs-"+e),t?.scrollIntoView({block:"nearest"})}function Um(e){if(!G("newtop"))return void(location.href="/?view=board");G("newtop").click();let t=document.querySelector("dialog[open] textarea");if(t)t.value=e,t.dispatchEvent(new Event("input",{bubbles:!0}))}function ph(e){let t=nt[e];if(!t)return;H.close(),t.act()}function Oh(){if(H)return H.querySelector("input").focus();H=document.createElement("dialog"),H.className="gs",H.setAttribute("aria-label","Search"),H.innerHTML=String(R`<div class="gs-box"><div class="gs-q">${gh("search")}<input type="text" placeholder="Search" aria-label="Search" role="combobox" aria-expanded="true" aria-controls="gs-list" autocomplete="off" spellcheck="false"></div><div class="gs-list" id="gs-list" role="listbox"></div><span class="gs-live" role="status" aria-live="polite"></span></div>`),document.body.append(H);let e=H.querySelector("input");st=0,e.oninput=()=>(st=0,Rs()),e.onkeydown=(i)=>{let n={ArrowDown:1,ArrowUp:-1}[i.key]??(i.ctrlKey&&i.key==="n"?1:i.ctrlKey&&i.key==="p"?-1:0);if(n)i.preventDefault(),to((st+n+nt.length)%nt.length);else if(i.key==="Enter")i.preventDefault(),ph(st)};let t=H.querySelector(".gs-list");t.onclick=(i)=>{let n=i.target.closest(".gs-i");if(n)ph(+n.dataset.n)},t.onpointermove=(i)=>{let n=i.target.closest(".gs-i");if(n&&+n.dataset.n!==st)to(+n.dataset.n)},H.onclick=(i)=>i.target===H&&H.close(),H.onclose=()=>(H.remove(),H=null),H.showModal(),Rs(),fetch("/chats").then((i)=>i.json()).then((i)=>{if(bh=i.chats??[],H)Rs()}).catch(()=>{})}var Vm=`dialog.gs{border:0;padding:0;margin:14vh auto auto;background:none;width:min(560px,calc(100vw - 32px));color:var(--ink);overflow:visible}
|
|
3
3
|
dialog.gs::backdrop{background:rgb(0 0 0/.35)}
|
|
4
4
|
.gs-box{display:flex;flex-direction:column;max-height:min(480px,72vh);background:var(--bg);border:1px solid var(--line);border-radius:10px;box-shadow:0 16px 40px rgb(0 0 0/.25);overflow:hidden}
|
package/web/term.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* kaizen terminal
|
|
1
|
+
/* kaizen terminal 0faf2181372af590 -- generated by bun run build:web from web/term.ts; do not edit */
|
|
2
2
|
(()=>{var{defineProperty:Oo,getOwnPropertyDescriptor:Jh}=Object,Qh=(e,t)=>{for(var i in t)Oo(e,i,{get:t[i],enumerable:!0})},he=(e,t,i,s)=>{for(var r=s>1?void 0:s?Jh(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&Oo(t,i,r),r},P=(e,t)=>(i,s)=>t(i,s,e),Tn="Terminal input",or={get:()=>Tn,set:(e)=>Tn=e},Bn="Too much output to announce, navigate to rows manually to read",ar={get:()=>Bn,set:(e)=>Bn=e};function el(e){return e.replace(/\r?\n/g,"\r")}function tl(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function il(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function sl(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");Io(r,t,i,s)}}function Io(e,t,i,s){e=el(e),e=tl(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function No(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function An(e,t,i,s,r){No(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function At(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function _s(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let n=e[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var rl=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[s++]=(this._interim-55296)*1024+n-56320+65536:(t[s++]=this._interim,t[s++]=n),this._interim=0}for(let n=r;n<i;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,s;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[s++]=(o-55296)*1024+a-56320+65536:(t[s++]=o,t[s++]=a);continue}o!==65279&&(t[s++]=o)}return s}},nl=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,n,o,a,l=0,h=0;if(this.interim[0]){let u=!1,g=this.interim[0];g&=(g&224)===192?31:(g&240)===224?15:7;let p=0,b;for(;(b=this.interim[++p]&63)&&p<4;)g<<=6,g|=b;let E=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,B=E-p;for(;h<B;){if(h>=i)return 0;if(b=e[h++],(b&192)!==128){h--,u=!0;break}else this.interim[p++]=b,g<<=6,g|=b&63}u||(E===2?g<128?h--:t[s++]=g:E===3?g<2048||g>=55296&&g<=57343||g===65279||(t[s++]=g):g<65536||g>1114111||(t[s++]=g)),this.interim.fill(0)}let d=i-4,c=h;for(;c<i;){for(;c<d&&!((r=e[c])&128)&&!((n=e[c+1])&128)&&!((o=e[c+2])&128)&&!((a=e[c+3])&128);)t[s++]=r,t[s++]=n,t[s++]=o,t[s++]=a,c+=4;if(r=e[c++],r<128)t[s++]=r;else if((r&224)===192){if(c>=i)return this.interim[0]=r,s;if(n=e[c++],(n&192)!==128){c--;continue}if(l=(r&31)<<6|n&63,l<128){c--;continue}t[s++]=l}else if((r&240)===224){if(c>=i)return this.interim[0]=r,s;if(n=e[c++],(n&192)!==128){c--;continue}if(c>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[c++],(o&192)!==128){c--;continue}if(l=(r&15)<<12|(n&63)<<6|o&63,l<2048||l>=55296&&l<=57343||l===65279)continue;t[s++]=l}else if((r&248)===240){if(c>=i)return this.interim[0]=r,s;if(n=e[c++],(n&192)!==128){c--;continue}if(c>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[c++],(o&192)!==128){c--;continue}if(c>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(a=e[c++],(a&192)!==128){c--;continue}if(l=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,l<65536||l>1114111)continue;t[s++]=l}}return s}},Fo="",Pt=" ",Di=class e{constructor(){this.fg=0,this.bg=0,this.extended=new rs}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},rs=class e{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Xe=class e extends Di{constructor(){super(...arguments);this.content=0,this.fg=0,this.bg=0,this.extended=new rs,this.combinedData=""}static fromCharData(t){let i=new e;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?At(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Pn="di$target",hr="di$dependencies",Ks=new Map;function ol(e){return e[hr]||[]}function ye(e){if(Ks.has(e))return Ks.get(e);let t=function(i,s,r){if(arguments.length!==3)throw Error("@IServiceName-decorator can only be used to decorate a parameter");al(t,i,r)};return t._id=e,Ks.set(e,t),t}function al(e,t,i){t[Pn]===t?t[hr].push({id:e,index:i}):(t[hr]=[{id:e,index:i}],t[Pn]=t)}var Oe=ye("BufferService"),Wo=ye("CoreMouseService"),jt=ye("CoreService"),hl=ye("CharsetService"),Ir=ye("InstantiationService"),zo=ye("LogService"),Ie=ye("OptionsService"),Ho=ye("OscLinkService"),ll=ye("UnicodeService"),Ti=ye("DecorationService"),lr=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,n=new Xe,o=i.getTrimmedLength(),a=-1,l=-1,h=!1;for(let d=0;d<o;d++)if(!(l===-1&&!i.hasContent(d))){if(i.loadCell(d,n),n.hasExtendedAttrs()&&n.extended.urlId)if(l===-1){l=d,a=n.extended.urlId;continue}else h=n.extended.urlId!==a;else l!==-1&&(h=!0);if(h||l!==-1&&d===o-1){let c=this._oscLinkService.getLinkData(a)?.uri;if(c){let u={start:{x:l+1,y:e},end:{x:d+(!h&&d===o-1?1:0),y:e}},g=!1;if(!r?.allowNonHttpProtocols)try{let p=new URL(c);["http:","https:"].includes(p.protocol)||(g=!0)}catch{g=!0}g||s.push({text:c,range:u,activate:(p,b)=>r?r.activate(p,b,u):cl(p,b),hover:(p,b)=>r?.hover?.(p,b,u),leave:(p,b)=>r?.leave?.(p,b,u)})}h=!1,n.hasExtendedAttrs()&&n.extended.urlId?(l=d,a=n.extended.urlId):(l=-1,a=-1)}}t(s)}};lr=he([P(0,Oe),P(1,Ie),P(2,Ho)],lr);function cl(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
3
3
|
|
|
4
4
|
WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var fs=ye("CharSizeService"),vt=ye("CoreBrowserService"),Nr=ye("MouseService"),mt=ye("RenderService"),dl=ye("SelectionService"),$o=ye("CharacterJoinerService"),ei=ye("ThemeService"),Uo=ye("LinkProviderService"),ul=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?On.isErrorNoTelemetry(e)?new On(e.message+`
|
|
@@ -143,7 +143,7 @@ ${d.join(`
|
|
|
143
143
|
`))}},wg=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},bg=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Cg=0,Os=class{constructor(e){this.value=e,this.id=Cg++}},yg=2,xg=(e,t)=>{if(e instanceof Os)t(e);else for(let i=0;i<e.length;i++){let s=e[i];s&&t(s)}},Is;if(pg){let e=[];setInterval(()=>{e.length!==0&&(console.warn("[LEAKING LISTENERS] GC'ed these listeners that were NOT yet disposed:"),console.warn(e.join(`
|
|
144
144
|
`)),e.length=0)},3000),Is=new FinalizationRegistry((t)=>{typeof t=="string"&&e.push(t)})}var ct=class{constructor(e){this._size=0,this._options=e,this._leakageMon=Fh>0||this._options?.leakWarningThreshold?new Sg(e?.onListenerError??Sn,this._options?.leakWarningThreshold??Fh):void 0,this._perfMon=this._options?._profName?new mg(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){if(!this._disposed){if(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners){if(Nh){let e=this._listeners;queueMicrotask(()=>{xg(e,(t)=>t.stack?.print())})}this._listeners=void 0,this._size=0}this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose()}}get event(){return this._event??=(e,t,i)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let a=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(a);let l=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],h=new bg(`${a}. HINT: Stack shows most frequent listener (${l[1]}-times)`,l[0]);return(this._options?.onListenerError||Sn)(h),dt.None}if(this._disposed)return dt.None;t&&(e=e.bind(t));let s=new Os(e),r,n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*0.2)&&(s.stack=xn.create(),r=this._leakageMon.check(s.stack,this._size+1)),Nh&&(s.stack=n??xn.create()),this._listeners?this._listeners instanceof Os?(this._deliveryQueue??=new kg,this._listeners=[this._listeners,s]):this._listeners.push(s):(this._options?.onWillAddFirstListener?.(this),this._listeners=s,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=ci(()=>{Is?.unregister(o),r?.(),this._removeListener(s)});if(i instanceof En?i.add(o):Array.isArray(i)&&i.push(o),Is){let a=Error().stack.split(`
|
|
145
145
|
`).slice(2,3).join(`
|
|
146
|
-
`).trim(),l=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(a);Is.register(o,l?.[2]??a,o)}return o},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,t[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*yg<=t.length){let r=0;for(let n=0;n<t.length;n++)t[n]?t[r++]=t[n]:s&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=r}}_deliver(e,t){if(!e)return;let i=this._options?.onListenerError||Sn;if(!i){e.value(t);return}try{e.value(t)}catch(s){i(s)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Os)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},kg=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Vh=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),Lg;((e)=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Eg?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Mn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Vh})})(Lg||={});var Eg=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Vh:(this._emitter||(this._emitter=new ct),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},hi="en",kn=!1,Ln=!1,Ns=!1,Mg=!1,Rg=!1,Gh=!1,Dg=!1,Tg=!1,Bg=!1,Ag=!1,Ps,Fs=hi,Wh=hi,Pg,Et,Mt=globalThis,Ge;typeof Mt.vscode<"u"&&typeof Mt.vscode.process<"u"?Ge=Mt.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Ge=process);var jh=typeof Ge?.versions?.electron=="string",Og=jh&&Ge?.type==="renderer";if(typeof Ge=="object"){kn=Ge.platform==="win32",Ln=Ge.platform==="darwin",Ns=Ge.platform==="linux",Mg=Ns&&!!Ge.env.SNAP&&!!Ge.env.SNAP_REVISION,Dg=jh,Bg=!!Ge.env.CI||!!Ge.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ps=hi,Fs=hi;let e=Ge.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ps=t.userLocale,Wh=t.osLocale,Fs=t.resolvedLanguage||hi,Pg=t.languagePack?.translationsConfigFile}catch{}Rg=!0}else typeof navigator=="object"&&!Og?(Et=navigator.userAgent,kn=Et.indexOf("Windows")>=0,Ln=Et.indexOf("Macintosh")>=0,Tg=(Et.indexOf("Macintosh")>=0||Et.indexOf("iPad")>=0||Et.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ns=Et.indexOf("Linux")>=0,Ag=Et?.indexOf("Mobi")>=0,Gh=!0,Fs=globalThis._VSCODE_NLS_LANGUAGE||hi,Ps=navigator.language.toLowerCase(),Wh=Ps):console.error("Unable to resolve platform.");var wn=0;Ln?wn=1:kn?wn=3:Ns&&(wn=2);var Ig=Gh&&typeof Mt.importScripts=="function",V0=Ig?Mt.origin:void 0,ut=Et,zt=Fs,Ng;((e)=>{function t(){return zt}e.value=t;function i(){return zt.length===2?zt==="en":zt.length>=3?zt[0]==="e"&&zt[1]==="n"&&zt[2]==="-":!1}e.isDefaultVariant=i;function s(){return zt==="en"}e.isDefault=s})(Ng||={});var Fg=typeof Mt.postMessage=="function"&&!Mt.importScripts,Wg=(()=>{if(Fg){let e=[];Mt.addEventListener("message",(i)=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s<r;s++){let n=e[s];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),n.callback();return}}});let t=0;return(i)=>{let s=++t;e.push({id:s,callback:i}),Mt.postMessage({vscodeScheduleAsyncWork:s},"*")}}return(e)=>setTimeout(e)})(),zg=!!(ut&&ut.indexOf("Chrome")>=0),G0=!!(ut&&ut.indexOf("Firefox")>=0),j0=!!(!zg&&ut&&ut.indexOf("Safari")>=0),Y0=!!(ut&&ut.indexOf("Edg/")>=0),X0=!!(ut&&ut.indexOf("Android")>=0),Z0=Symbol("MicrotaskDelay");function Yh(e,t=0,i){let s=setTimeout(()=>{e(),i&&r.dispose()},t),r=ci(()=>{clearTimeout(s),i?.deleteAndLeak(r)});return i?.add(r),r}var Hg,bn;(function(){typeof globalThis.requestIdleCallback!="function"||typeof globalThis.cancelIdleCallback!="function"?bn=(e,t)=>{Wg(()=>{if(i)return;let s=Date.now()+15;t(Object.freeze({didTimeout:!0,timeRemaining(){return Math.max(0,s-Date.now())}}))});let i=!1;return{dispose(){i||(i=!0)}}}:bn=(e,t,i)=>{let s=e.requestIdleCallback(t,typeof i=="number"?{timeout:i}:void 0),r=!1;return{dispose(){r||(r=!0,e.cancelIdleCallback(s))}}},Hg=(e)=>bn(globalThis,e)})();var $g;((e)=>{async function t(s){let r,n=await Promise.all(s.map((o)=>o.then((a)=>a,(a)=>{r||(r=a)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})($g||={});var zh=class e{static fromArray(t){return new e((i)=>{i.emitMany(t)})}static fromPromise(t){return new e(async(i)=>{i.emitMany(await t)})}static fromPromises(t){return new e(async(i)=>{await Promise.all(t.map(async(s)=>i.emitOne(await s)))})}static merge(t){return new e(async(i)=>{await Promise.all(t.map(async(s)=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new ct,queueMicrotask(async()=>{let s={emitOne:(r)=>this.emitOne(r),emitMany:(r)=>this.emitMany(r),reject:(r)=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Mn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,i){return new e(async(s)=>{for await(let r of t)s.emitOne(i(r))})}map(t){return e.map(this,t)}static filter(t,i){return new e(async(s)=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,(i)=>!!i)}coalesce(){return e.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return e.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};zh.EMPTY=zh.fromArray([]);var Ug=class extends dt{constructor(e){super();this._terminal=e,this._linesCacheTimeout=this._register(new Ws),this._linesCacheDisposables=this._register(new Ws),this._register(ci(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Uh(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=Yh(()=>this._destroyLinesCache(),15000)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let i=[],s=[0],r=this._terminal.buffer.active.getLine(e);for(;r;){let n=this._terminal.buffer.active.getLine(e+1),o=n?n.isWrapped:!1,a=r.translateToString(!o&&t);if(o&&n){let l=r.getCell(r.length-1);l&&l.getCode()===0&&l.getWidth()===1&&n.getCell(0)?.getWidth()===2&&(a=a.slice(0,-1))}if(i.push(a),o)s.push(s[s.length-1]+a.length);else break;e++,r=n}return[i.join(""),s]}},Kg=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},qg=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,i,s){if(!e||e.length===0){this._terminal.clearSelection();return}if(i>this._terminal.cols)throw Error(`Invalid col: ${i} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let r={startRow:t,startCol:i},n=this._findInLine(e,r,s);if(!n)for(let o=t+1;o<this._terminal.buffer.active.baseY+this._terminal.rows&&(r.startRow=o,r.startCol=0,n=this._findInLine(e,r,s),!n);o++);return n}findNextWithSelection(e,t,i){if(!e||e.length===0){this._terminal.clearSelection();return}let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=0,n=0;s&&(i===e?(r=s.end.x,n=s.end.y):(r=s.start.x,n=s.start.y)),this._lineCache.initLinesCache();let o={startRow:n,startCol:r},a=this._findInLine(e,o,t);if(!a)for(let l=n+1;l<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);if(!a&&n!==0)for(let l=0;l<n&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);return!a&&s&&(o.startRow=s.start.y,o.startCol=0,a=this._findInLine(e,o,t)),a}findPreviousWithSelection(e,t,i){if(!e||e.length===0){this._terminal.clearSelection();return}let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=this._terminal.buffer.active.baseY+this._terminal.rows-1,n=this._terminal.cols,o=!0;this._lineCache.initLinesCache();let a={startRow:r,startCol:n},l;if(s&&(a.startRow=r=s.start.y,a.startCol=n=s.start.x,i!==e&&(l=this._findInLine(e,a,t,!1),l||(a.startRow=r=s.end.y,a.startCol=n=s.end.x))),l||(l=this._findInLine(e,a,t,o)),!l){a.startCol=Math.max(a.startCol,this._terminal.cols);for(let h=r-1;h>=0&&(a.startRow=h,l=this._findInLine(e,a,t,o),!l);h--);}if(!l&&r!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let h=this._terminal.buffer.active.baseY+this._terminal.rows-1;h>=r&&(a.startRow=h,l=this._findInLine(e,a,t,o),!l);h--);return l}_isWholeWord(e,t,i){return(e===0||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e-1]))&&(e+i.length===t.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e+i.length]))}_findInLine(e,t,i={},s=!1){let{startRow:r,startCol:n}=t;if(this._terminal.buffer.active.getLine(r)?.isWrapped){if(s){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,i)}let o=this._lineCache.getLineFromCache(r);o||(o=this._lineCache.translateBufferLineToStringWithWrap(r,!0),this._lineCache.setLineInCache(r,o));let[a,l]=o,h=this._bufferColsToStringOffset(r,n),d=e,c=a;i.regex||(d=i.caseSensitive?e:e.toLowerCase(),c=i.caseSensitive?a:a.toLowerCase());let u=-1;if(i.regex){let g=RegExp(d,i.caseSensitive?"g":"gi"),p;if(s)for(;p=g.exec(c.slice(0,h));)u=g.lastIndex-p[0].length,e=p[0],g.lastIndex-=e.length-1;else p=g.exec(c.slice(h)),p&&p[0].length>0&&(u=h+(g.lastIndex-p[0].length),e=p[0])}else s?h-d.length>=0&&(u=c.lastIndexOf(d,h-d.length)):u=c.indexOf(d,h);if(u>=0){if(i.wholeWord&&!this._isWholeWord(u,c,e))return;let g=0;for(;g<l.length-1&&u>=l[g+1];)g++;let p=g;for(;p<l.length-1&&u+e.length>=l[p+1];)p++;let b=u-l[g],E=u+e.length-l[p],B=this._stringLengthToBufferSize(r+g,b),A=this._stringLengthToBufferSize(r+p,E)-B+this._terminal.cols*(p-g);return{term:e,col:B,row:r+g,size:A}}}_stringLengthToBufferSize(e,t){let i=this._terminal.buffer.active.getLine(e);if(!i)return 0;for(let s=0;s<t;s++){let r=i.getCell(s);if(!r)break;let n=r.getChars();n.length>1&&(t-=n.length-1);let o=i.getCell(s+1);o&&o.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let i=e,s=0,r=this._terminal.buffer.active.getLine(i);for(;t>0&&r;){for(let n=0;n<t&&n<this._terminal.cols;n++){let o=r.getCell(n);if(!o)break;o.getWidth()&&(s+=o.getCode()===0?1:o.getChars().length)}if(i++,r=this._terminal.buffer.active.getLine(i),r&&!r.isWrapped)break;t-=this._terminal.cols}return s}},Vg=class extends dt{constructor(e){super();this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(ci(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let i of e){let s=this._createResultDecorations(i,t,!1);if(s)for(let r of s)this._storeDecoration(r,i)}}createActiveDecoration(e,t){let i=this._createResultDecorations(e,t,!0);if(i)return{decorations:i,match:e,dispose(){Ui(i)}}}clearHighlightDecorations(){Ui(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,i){e.classList.contains("xterm-find-result-decoration")||(e.classList.add("xterm-find-result-decoration"),t&&(e.style.outline=`1px solid ${t}`)),i&&e.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(e,t,i){let s=[],{col:r,size:n}=e,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;n>0;){let l=Math.min(this._terminal.cols-r,n);s.push([o,r,l]),r=0,n-=l,o++}let a=[];for(let l of s){let h=this._terminal.registerMarker(l[0]),d=this._terminal.registerDecoration({marker:h,x:l[1],width:l[2],backgroundColor:i?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(h.line)?void 0:{color:i?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:"center"}});if(d){let c=[];c.push(h),c.push(d.onRender((u)=>this._applyStyles(u,i?t.activeMatchBorder:t.matchBorder,!1))),c.push(d.onDispose(()=>Ui(c))),a.push(d)}}return a.length===0?void 0:a}},Gg=class extends dt{constructor(){super(...arguments);this._searchResults=[],this._onDidChangeResults=this._register(new ct)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let i=this._searchResults[t];if(i.row===e.row&&i.col===e.col&&i.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},Xh=class extends dt{constructor(e){super();this._highlightTimeout=this._register(new Ws),this._lineCache=this._register(new Ws),this._state=new Kg,this._resultTracker=this._register(new Gg),this._highlightLimit=e?.highlightLimit??1000}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new Ug(e),this._engine=new qg(e,this._lineCache.value),this._decorationManager=new Vg(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(ci(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=Yh(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,i){if(!this._terminal||!this._engine)throw Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let s=this._findNextAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,s}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let i=[],s,r=this._engine.find(e,0,0,t);for(;r&&(s?.row!==r.row||s?.col!==r.col)&&!(i.length>=this._highlightLimit);)s=r,i.push(s),r=this._engine.find(e,s.col+s.term.length>=this._terminal.cols?s.row+1:s.row,s.col+s.term.length>=this._terminal.cols?0:s.col+1,t);this._resultTracker.updateResults(i,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(i,t.decorations)}_findNextAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let s=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(s,t?.decorations,i?.noScroll)}findPrevious(e,t,i){if(!this._terminal||!this._engine)throw Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let s=this._findPreviousAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,s}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let s=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(s,t?.decorations,i?.noScroll)}_selectResult(e,t,i){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let s=this._decorationManager.createActiveDecoration(e,t);s&&(this._resultTracker.selectedDecoration=s)}if(!i&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let s=e.row-this._terminal.buffer.active.viewportY;s-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(s)}return!0}};function jg(e,t,i){let s=getComputedStyle(e),r=(x)=>s.getPropertyValue(x).trim()||void 0,n=()=>({background:r("--bg"),foreground:r("--ink-hi"),cursor:r("--accent"),selectionBackground:r("--line")}),o=new wa({cursorBlink:!0,fontFamily:r("--mono"),fontSize:12,scrollback:5000,allowProposedApi:!0,theme:n()}),a=()=>requestAnimationFrame(()=>o.options.theme=n()),l=matchMedia("(prefers-color-scheme: dark)");addEventListener("kz-theme",a),l.addEventListener("change",a);let h=new ba;o.loadAddon(h),o.loadAddon(new Th((x,F)=>window.open(F,"_blank","noopener")));let d=new Xh;o.loadAddon(d),o.open(e);try{let x=new Dh;x.onContextLoss(()=>x.dispose()),o.loadAddon(x)}catch{}let c=[1,2,4,8,15],u,g=0,p,b=!1,E=(x)=>{if(u?.readyState===WebSocket.OPEN)u.send(JSON.stringify(x))},B=(x=!1)=>{if(!e.offsetWidth)return;if(!u)return A();if(h.fit(),x&&o.rows>5)E({t:"r",c:o.cols,r:o.rows-1}),setTimeout(()=>E({t:"r",c:o.cols,r:o.rows}),80);else E({t:"r",c:o.cols,r:o.rows})},A=()=>{if(clearTimeout(p),u)u.onopen=u.onmessage=u.onclose=null,u.close();u=new WebSocket(`${location.protocol==="https:"?"wss":"ws"}://${location.host}/pty?key=${encodeURIComponent(t)}`),u.onopen=()=>{if(b)o.reset();b=!1,g=0,m.hidden=!0,B(!0)},u.onmessage=(x)=>o.write(String(x.data)),u.onclose=(x)=>{if(x.reason==="ended")o.write(`\r
|
|
146
|
+
`).trim(),l=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(a);Is.register(o,l?.[2]??a,o)}return o},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,i=t.indexOf(e);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,t[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*yg<=t.length){let r=0;for(let n=0;n<t.length;n++)t[n]?t[r++]=t[n]:s&&(this._deliveryQueue.end--,r<this._deliveryQueue.i&&this._deliveryQueue.i--);t.length=r}}_deliver(e,t){if(!e)return;let i=this._options?.onListenerError||Sn;if(!i){e.value(t);return}try{e.value(t)}catch(s){i(s)}}_deliverQueue(e){let t=e.current._listeners;for(;e.i<e.end;)this._deliver(t[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof Os)this._deliver(this._listeners,e);else{let t=this._deliveryQueue;t.enqueue(this,e,this._listeners.length),this._deliverQueue(t)}this._perfMon?.stop()}hasListeners(){return this._size>0}},kg=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Vh=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),Lg;((e)=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Eg?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Mn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Vh})})(Lg||={});var Eg=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Vh:(this._emitter||(this._emitter=new ct),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},hi="en",kn=!1,Ln=!1,Ns=!1,Mg=!1,Rg=!1,Gh=!1,Dg=!1,Tg=!1,Bg=!1,Ag=!1,Ps,Fs=hi,Wh=hi,Pg,Et,Mt=globalThis,Ge;typeof Mt.vscode<"u"&&typeof Mt.vscode.process<"u"?Ge=Mt.vscode.process:typeof process<"u"&&typeof process?.versions?.node=="string"&&(Ge=process);var jh=typeof Ge?.versions?.electron=="string",Og=jh&&Ge?.type==="renderer";if(typeof Ge=="object"){kn=Ge.platform==="win32",Ln=Ge.platform==="darwin",Ns=Ge.platform==="linux",Mg=Ns&&!!Ge.env.SNAP&&!!Ge.env.SNAP_REVISION,Dg=jh,Bg=!!Ge.env.CI||!!Ge.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ps=hi,Fs=hi;let e=Ge.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ps=t.userLocale,Wh=t.osLocale,Fs=t.resolvedLanguage||hi,Pg=t.languagePack?.translationsConfigFile}catch{}Rg=!0}else typeof navigator=="object"&&!Og?(Et=navigator.userAgent,kn=Et.indexOf("Windows")>=0,Ln=Et.indexOf("Macintosh")>=0,Tg=(Et.indexOf("Macintosh")>=0||Et.indexOf("iPad")>=0||Et.indexOf("iPhone")>=0)&&!!navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Ns=Et.indexOf("Linux")>=0,Ag=Et?.indexOf("Mobi")>=0,Gh=!0,Fs=globalThis._VSCODE_NLS_LANGUAGE||hi,Ps=navigator.language.toLowerCase(),Wh=Ps):console.error("Unable to resolve platform.");var wn=0;Ln?wn=1:kn?wn=3:Ns&&(wn=2);var Ig=Gh&&typeof Mt.importScripts=="function",V0=Ig?Mt.origin:void 0,ut=Et,zt=Fs,Ng;((e)=>{function t(){return zt}e.value=t;function i(){return zt.length===2?zt==="en":zt.length>=3?zt[0]==="e"&&zt[1]==="n"&&zt[2]==="-":!1}e.isDefaultVariant=i;function s(){return zt==="en"}e.isDefault=s})(Ng||={});var Fg=typeof Mt.postMessage=="function"&&!Mt.importScripts,Wg=(()=>{if(Fg){let e=[];Mt.addEventListener("message",(i)=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s<r;s++){let n=e[s];if(n.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),n.callback();return}}});let t=0;return(i)=>{let s=++t;e.push({id:s,callback:i}),Mt.postMessage({vscodeScheduleAsyncWork:s},"*")}}return(e)=>setTimeout(e)})(),zg=!!(ut&&ut.indexOf("Chrome")>=0),G0=!!(ut&&ut.indexOf("Firefox")>=0),j0=!!(!zg&&ut&&ut.indexOf("Safari")>=0),Y0=!!(ut&&ut.indexOf("Edg/")>=0),X0=!!(ut&&ut.indexOf("Android")>=0),Z0=Symbol("MicrotaskDelay");function Yh(e,t=0,i){let s=setTimeout(()=>{e(),i&&r.dispose()},t),r=ci(()=>{clearTimeout(s),i?.deleteAndLeak(r)});return i?.add(r),r}var Hg,bn;(function(){typeof globalThis.requestIdleCallback!="function"||typeof globalThis.cancelIdleCallback!="function"?bn=(e,t)=>{Wg(()=>{if(i)return;let s=Date.now()+15;t(Object.freeze({didTimeout:!0,timeRemaining(){return Math.max(0,s-Date.now())}}))});let i=!1;return{dispose(){i||(i=!0)}}}:bn=(e,t,i)=>{let s=e.requestIdleCallback(t,typeof i=="number"?{timeout:i}:void 0),r=!1;return{dispose(){r||(r=!0,e.cancelIdleCallback(s))}}},Hg=(e)=>bn(globalThis,e)})();var $g;((e)=>{async function t(s){let r,n=await Promise.all(s.map((o)=>o.then((a)=>a,(a)=>{r||(r=a)})));if(typeof r<"u")throw r;return n}e.settled=t;function i(s){return new Promise(async(r,n)=>{try{await s(r,n)}catch(o){n(o)}})}e.withAsyncBody=i})($g||={});var zh=class e{static fromArray(t){return new e((i)=>{i.emitMany(t)})}static fromPromise(t){return new e(async(i)=>{i.emitMany(await t)})}static fromPromises(t){return new e(async(i)=>{await Promise.all(t.map(async(s)=>i.emitOne(await s)))})}static merge(t){return new e(async(i)=>{await Promise.all(t.map(async(s)=>{for await(let r of s)i.emitOne(r)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new ct,queueMicrotask(async()=>{let s={emitOne:(r)=>this.emitOne(r),emitMany:(r)=>this.emitMany(r),reject:(r)=>this.reject(r)};try{await Promise.resolve(t(s)),this.resolve()}catch(r){this.reject(r)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Mn.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,i){return new e(async(s)=>{for await(let r of t)s.emitOne(i(r))})}map(t){return e.map(this,t)}static filter(t,i){return new e(async(s)=>{for await(let r of t)i(r)&&s.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,(i)=>!!i)}coalesce(){return e.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return e.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};zh.EMPTY=zh.fromArray([]);var Ug=class extends dt{constructor(e){super();this._terminal=e,this._linesCacheTimeout=this._register(new Ws),this._linesCacheDisposables=this._register(new Ws),this._register(ci(()=>this._destroyLinesCache()))}initLinesCache(){this._linesCache||(this._linesCache=Array(this._terminal.buffer.active.length),this._linesCacheDisposables.value=Uh(this._terminal.onLineFeed(()=>this._destroyLinesCache()),this._terminal.onCursorMove(()=>this._destroyLinesCache()),this._terminal.onResize(()=>this._destroyLinesCache()))),this._linesCacheTimeout.value=Yh(()=>this._destroyLinesCache(),15000)}_destroyLinesCache(){this._linesCache=void 0,this._linesCacheDisposables.clear(),this._linesCacheTimeout.clear()}getLineFromCache(e){return this._linesCache?.[e]}setLineInCache(e,t){this._linesCache&&(this._linesCache[e]=t)}translateBufferLineToStringWithWrap(e,t){let i=[],s=[0],r=this._terminal.buffer.active.getLine(e);for(;r;){let n=this._terminal.buffer.active.getLine(e+1),o=n?n.isWrapped:!1,a=r.translateToString(!o&&t);if(o&&n){let l=r.getCell(r.length-1);l&&l.getCode()===0&&l.getWidth()===1&&n.getCell(0)?.getWidth()===2&&(a=a.slice(0,-1))}if(i.push(a),o)s.push(s[s.length-1]+a.length);else break;e++,r=n}return[i.join(""),s]}},Kg=class{get cachedSearchTerm(){return this._cachedSearchTerm}set cachedSearchTerm(e){this._cachedSearchTerm=e}get lastSearchOptions(){return this._lastSearchOptions}set lastSearchOptions(e){this._lastSearchOptions=e}isValidSearchTerm(e){return!!(e&&e.length>0)}didOptionsChange(e){return this._lastSearchOptions?e?this._lastSearchOptions.caseSensitive!==e.caseSensitive||this._lastSearchOptions.regex!==e.regex||this._lastSearchOptions.wholeWord!==e.wholeWord:!1:!0}shouldUpdateHighlighting(e,t){return t?.decorations?this._cachedSearchTerm===void 0||e!==this._cachedSearchTerm||this.didOptionsChange(t):!1}clearCachedTerm(){this._cachedSearchTerm=void 0}reset(){this._cachedSearchTerm=void 0,this._lastSearchOptions=void 0}},qg=class{constructor(e,t){this._terminal=e,this._lineCache=t}find(e,t,i,s){if(!e||e.length===0){this._terminal.clearSelection();return}if(i>this._terminal.cols)throw Error(`Invalid col: ${i} to search in terminal of ${this._terminal.cols} cols`);this._lineCache.initLinesCache();let r={startRow:t,startCol:i},n=this._findInLine(e,r,s);if(!n)for(let o=t+1;o<this._terminal.buffer.active.baseY+this._terminal.rows&&(r.startRow=o,r.startCol=0,n=this._findInLine(e,r,s),!n);o++);return n}findNextWithSelection(e,t,i){if(!e||e.length===0){this._terminal.clearSelection();return}let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=0,n=0;s&&(i===e?(r=s.end.x,n=s.end.y):(r=s.start.x,n=s.start.y)),this._lineCache.initLinesCache();let o={startRow:n,startCol:r},a=this._findInLine(e,o,t);if(!a)for(let l=n+1;l<this._terminal.buffer.active.baseY+this._terminal.rows&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);if(!a&&n!==0)for(let l=0;l<n&&(o.startRow=l,o.startCol=0,a=this._findInLine(e,o,t),!a);l++);return!a&&s&&(o.startRow=s.start.y,o.startCol=0,a=this._findInLine(e,o,t)),a}findPreviousWithSelection(e,t,i){if(!e||e.length===0){this._terminal.clearSelection();return}let s=this._terminal.getSelectionPosition();this._terminal.clearSelection();let r=this._terminal.buffer.active.baseY+this._terminal.rows-1,n=this._terminal.cols,o=!0;this._lineCache.initLinesCache();let a={startRow:r,startCol:n},l;if(s&&(a.startRow=r=s.start.y,a.startCol=n=s.start.x,i!==e&&(l=this._findInLine(e,a,t,!1),l||(a.startRow=r=s.end.y,a.startCol=n=s.end.x))),l||(l=this._findInLine(e,a,t,o)),!l){a.startCol=Math.max(a.startCol,this._terminal.cols);for(let h=r-1;h>=0&&(a.startRow=h,l=this._findInLine(e,a,t,o),!l);h--);}if(!l&&r!==this._terminal.buffer.active.baseY+this._terminal.rows-1)for(let h=this._terminal.buffer.active.baseY+this._terminal.rows-1;h>=r&&(a.startRow=h,l=this._findInLine(e,a,t,o),!l);h--);return l}_isWholeWord(e,t,i){return(e===0||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e-1]))&&(e+i.length===t.length||" ~!@#$%^&*()+`-=[]{}|\\;:\"',./<>?".includes(t[e+i.length]))}_findInLine(e,t,i={},s=!1){let{startRow:r,startCol:n}=t;if(this._terminal.buffer.active.getLine(r)?.isWrapped){if(s){t.startCol+=this._terminal.cols;return}return t.startRow--,t.startCol+=this._terminal.cols,this._findInLine(e,t,i)}let o=this._lineCache.getLineFromCache(r);o||(o=this._lineCache.translateBufferLineToStringWithWrap(r,!0),this._lineCache.setLineInCache(r,o));let[a,l]=o,h=this._bufferColsToStringOffset(r,n),d=e,c=a;i.regex||(d=i.caseSensitive?e:e.toLowerCase(),c=i.caseSensitive?a:a.toLowerCase());let u=-1;if(i.regex){let g=RegExp(d,i.caseSensitive?"g":"gi"),p;if(s)for(;p=g.exec(c.slice(0,h));)u=g.lastIndex-p[0].length,e=p[0],g.lastIndex-=e.length-1;else p=g.exec(c.slice(h)),p&&p[0].length>0&&(u=h+(g.lastIndex-p[0].length),e=p[0])}else s?h-d.length>=0&&(u=c.lastIndexOf(d,h-d.length)):u=c.indexOf(d,h);if(u>=0){if(i.wholeWord&&!this._isWholeWord(u,c,e))return;let g=0;for(;g<l.length-1&&u>=l[g+1];)g++;let p=g;for(;p<l.length-1&&u+e.length>=l[p+1];)p++;let b=u-l[g],E=u+e.length-l[p],B=this._stringLengthToBufferSize(r+g,b),A=this._stringLengthToBufferSize(r+p,E)-B+this._terminal.cols*(p-g);return{term:e,col:B,row:r+g,size:A}}}_stringLengthToBufferSize(e,t){let i=this._terminal.buffer.active.getLine(e);if(!i)return 0;for(let s=0;s<t;s++){let r=i.getCell(s);if(!r)break;let n=r.getChars();n.length>1&&(t-=n.length-1);let o=i.getCell(s+1);o&&o.getWidth()===0&&t++}return t}_bufferColsToStringOffset(e,t){let i=e,s=0,r=this._terminal.buffer.active.getLine(i);for(;t>0&&r;){for(let n=0;n<t&&n<this._terminal.cols;n++){let o=r.getCell(n);if(!o)break;o.getWidth()&&(s+=o.getCode()===0?1:o.getChars().length)}if(i++,r=this._terminal.buffer.active.getLine(i),r&&!r.isWrapped)break;t-=this._terminal.cols}return s}},Vg=class extends dt{constructor(e){super();this._terminal=e,this._highlightDecorations=[],this._highlightedLines=new Set,this._register(ci(()=>this.clearHighlightDecorations()))}createHighlightDecorations(e,t){this.clearHighlightDecorations();for(let i of e){let s=this._createResultDecorations(i,t,!1);if(s)for(let r of s)this._storeDecoration(r,i)}}createActiveDecoration(e,t){let i=this._createResultDecorations(e,t,!0);if(i)return{decorations:i,match:e,dispose(){Ui(i)}}}clearHighlightDecorations(){Ui(this._highlightDecorations),this._highlightDecorations=[],this._highlightedLines.clear()}_storeDecoration(e,t){this._highlightedLines.add(e.marker.line),this._highlightDecorations.push({decoration:e,match:t,dispose(){e.dispose()}})}_applyStyles(e,t,i){e.classList.contains("xterm-find-result-decoration")||(e.classList.add("xterm-find-result-decoration"),t&&(e.style.outline=`1px solid ${t}`)),i&&e.classList.add("xterm-find-active-result-decoration")}_createResultDecorations(e,t,i){let s=[],{col:r,size:n}=e,o=-this._terminal.buffer.active.baseY-this._terminal.buffer.active.cursorY+e.row;for(;n>0;){let l=Math.min(this._terminal.cols-r,n);s.push([o,r,l]),r=0,n-=l,o++}let a=[];for(let l of s){let h=this._terminal.registerMarker(l[0]),d=this._terminal.registerDecoration({marker:h,x:l[1],width:l[2],backgroundColor:i?t.activeMatchBackground:t.matchBackground,overviewRulerOptions:this._highlightedLines.has(h.line)?void 0:{color:i?t.activeMatchColorOverviewRuler:t.matchOverviewRuler,position:"center"}});if(d){let c=[];c.push(h),c.push(d.onRender((u)=>this._applyStyles(u,i?t.activeMatchBorder:t.matchBorder,!1))),c.push(d.onDispose(()=>Ui(c))),a.push(d)}}return a.length===0?void 0:a}},Gg=class extends dt{constructor(){super(...arguments);this._searchResults=[],this._onDidChangeResults=this._register(new ct)}get onDidChangeResults(){return this._onDidChangeResults.event}get searchResults(){return this._searchResults}get selectedDecoration(){return this._selectedDecoration}set selectedDecoration(e){this._selectedDecoration=e}updateResults(e,t){this._searchResults=e.slice(0,t)}clearResults(){this._searchResults=[]}clearSelectedDecoration(){this._selectedDecoration&&(this._selectedDecoration.dispose(),this._selectedDecoration=void 0)}findResultIndex(e){for(let t=0;t<this._searchResults.length;t++){let i=this._searchResults[t];if(i.row===e.row&&i.col===e.col&&i.size===e.size)return t}return-1}fireResultsChanged(e){if(!e)return;let t=-1;this._selectedDecoration&&(t=this.findResultIndex(this._selectedDecoration.match)),this._onDidChangeResults.fire({resultIndex:t,resultCount:this._searchResults.length})}reset(){this.clearSelectedDecoration(),this.clearResults()}},Xh=class extends dt{constructor(e){super();this._highlightTimeout=this._register(new Ws),this._lineCache=this._register(new Ws),this._state=new Kg,this._resultTracker=this._register(new Gg),this._highlightLimit=e?.highlightLimit??1000}get onDidChangeResults(){return this._resultTracker.onDidChangeResults}activate(e){this._terminal=e,this._lineCache.value=new Ug(e),this._engine=new qg(e,this._lineCache.value),this._decorationManager=new Vg(e),this._register(this._terminal.onWriteParsed(()=>this._updateMatches())),this._register(this._terminal.onResize(()=>this._updateMatches())),this._register(ci(()=>this.clearDecorations()))}_updateMatches(){this._highlightTimeout.clear(),this._state.cachedSearchTerm&&this._state.lastSearchOptions?.decorations&&(this._highlightTimeout.value=Yh(()=>{let e=this._state.cachedSearchTerm;this._state.clearCachedTerm(),this.findPrevious(e,{...this._state.lastSearchOptions,incremental:!0},{noScroll:!0})},200))}clearDecorations(e){this._resultTracker.clearSelectedDecoration(),this._decorationManager?.clearHighlightDecorations(),this._resultTracker.clearResults(),e||this._state.clearCachedTerm()}clearActiveDecoration(){this._resultTracker.clearSelectedDecoration()}findNext(e,t,i){if(!this._terminal||!this._engine)throw Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let s=this._findNextAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,s}_highlightAllMatches(e,t){if(!this._terminal||!this._engine||!this._decorationManager)throw Error("Cannot use addon until it has been loaded");if(!this._state.isValidSearchTerm(e)){this.clearDecorations();return}this.clearDecorations(!0);let i=[],s,r=this._engine.find(e,0,0,t);for(;r&&(s?.row!==r.row||s?.col!==r.col)&&!(i.length>=this._highlightLimit);)s=r,i.push(s),r=this._engine.find(e,s.col+s.term.length>=this._terminal.cols?s.row+1:s.row,s.col+s.term.length>=this._terminal.cols?0:s.col+1,t);this._resultTracker.updateResults(i,this._highlightLimit),t.decorations&&this._decorationManager.createHighlightDecorations(i,t.decorations)}_findNextAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let s=this._engine.findNextWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(s,t?.decorations,i?.noScroll)}findPrevious(e,t,i){if(!this._terminal||!this._engine)throw Error("Cannot use addon until it has been loaded");this._state.lastSearchOptions=t,this._state.shouldUpdateHighlighting(e,t)&&this._highlightAllMatches(e,t);let s=this._findPreviousAndSelect(e,t,i);return this._fireResults(t),this._state.cachedSearchTerm=e,s}_fireResults(e){this._resultTracker.fireResultsChanged(!!e?.decorations)}_findPreviousAndSelect(e,t,i){if(!this._terminal||!this._engine)return!1;if(!this._state.isValidSearchTerm(e))return this._terminal.clearSelection(),this.clearDecorations(),!1;let s=this._engine.findPreviousWithSelection(e,t,this._state.cachedSearchTerm);return this._selectResult(s,t?.decorations,i?.noScroll)}_selectResult(e,t,i){if(!this._terminal||!this._decorationManager)return!1;if(this._resultTracker.clearSelectedDecoration(),!e)return this._terminal.clearSelection(),!1;if(this._terminal.select(e.col,e.row,e.size),t){let s=this._decorationManager.createActiveDecoration(e,t);s&&(this._resultTracker.selectedDecoration=s)}if(!i&&(e.row>=this._terminal.buffer.active.viewportY+this._terminal.rows||e.row<this._terminal.buffer.active.viewportY)){let s=e.row-this._terminal.buffer.active.viewportY;s-=Math.floor(this._terminal.rows/2),this._terminal.scrollLines(s)}return!0}};function jg(e,t,i){let s=getComputedStyle(e),r=(x)=>s.getPropertyValue(x).trim()||void 0,n=()=>({background:r("--bg"),foreground:r("--ink-hi"),cursor:r("--accent"),selectionBackground:r("--line")}),o=new wa({cursorBlink:!0,fontFamily:`"JetBrainsMono Nerd Font",${r("--mono")}`,fontSize:12,scrollback:5000,allowProposedApi:!0,theme:n()}),a=()=>requestAnimationFrame(()=>o.options.theme=n()),l=matchMedia("(prefers-color-scheme: dark)");addEventListener("kz-theme",a),l.addEventListener("change",a);let h=new ba;o.loadAddon(h),o.loadAddon(new Th((x,F)=>window.open(F,"_blank","noopener")));let d=new Xh;o.loadAddon(d),o.open(e);try{let x=new Dh;x.onContextLoss(()=>x.dispose()),o.loadAddon(x)}catch{}let c=[1,2,4,8,15],u,g=0,p,b=!1,E=(x)=>{if(u?.readyState===WebSocket.OPEN)u.send(JSON.stringify(x))},B=(x=!1)=>{if(!e.offsetWidth)return;if(!u)return A();if(h.fit(),x&&o.rows>5)E({t:"r",c:o.cols,r:o.rows-1}),setTimeout(()=>E({t:"r",c:o.cols,r:o.rows}),80);else E({t:"r",c:o.cols,r:o.rows})},A=()=>{if(clearTimeout(p),u)u.onopen=u.onmessage=u.onclose=null,u.close();u=new WebSocket(`${location.protocol==="https:"?"wss":"ws"}://${location.host}/pty?key=${encodeURIComponent(t)}`),u.onopen=()=>{if(b)o.reset();b=!1,g=0,m.hidden=!0,B(!0)},u.onmessage=(x)=>o.write(String(x.data)),u.onclose=(x)=>{if(x.reason==="ended")o.write(`\r
|
|
147
147
|
\x1B[2m[agent ended]\x1B[0m\r
|
|
148
148
|
`),m.hidden=!0;else{if(!b)o.write(`\r
|
|
149
149
|
\x1B[2m[connection to the board lost]\x1B[0m\r
|
package/web/term.ts
CHANGED
|
@@ -13,7 +13,8 @@ function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void
|
|
|
13
13
|
const theme = () => ({ background: tok("--bg"), foreground: tok("--ink-hi"), cursor: tok("--accent"), selectionBackground: tok("--line") });
|
|
14
14
|
const term = new Terminal({
|
|
15
15
|
cursorBlink: true,
|
|
16
|
-
|
|
16
|
+
// Nerd Font first: shell prompts print private-use glyphs that plain monospace fonts lack.
|
|
17
|
+
fontFamily: `"JetBrainsMono Nerd Font",${tok("--mono")}`,
|
|
17
18
|
fontSize: 12,
|
|
18
19
|
scrollback: 5000,
|
|
19
20
|
allowProposedApi: true, // search match decorations
|
package/web/video.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* kaizen video page
|
|
1
|
+
/* kaizen video page 0faf2181372af590 -- generated by bun run build:web from web/video.ts; do not edit */
|
|
2
2
|
(()=>{var gt=null,ht=(e)=>{gt=e};function cn(e,t,n){Oe++,gt?.(e,t,n)}var Oe=0,ft="",Pe=!1,we=!1;async function qe(){if(Pe){we=!0;return}Pe=!0;do{we=!1;let e=Oe;try{let t=await fetch("/state?all=1");if(!t.ok)continue;let n=await t.text(),a=n.replace(/"now":\d+\}$/,"");if(a===ft)continue;let{cards:s,projects:i,rail:l,agents:r}=JSON.parse(n);if(!we&&e===Oe)ft=a,cn(s,[...i,...l??[]],r)}catch{}}while(we);Pe=!1}var pn={S:{project:null,projects:[],cards:[],now:Date.now(),all:!1,dir:null},all:new URLSearchParams(location.search).get("all")!=="0",dir:null,openKey:null,mode:null,modeKey:null,menuKey:null,flash:new Set,tab:"request",lastTab:"request",runDoc:null,clearMenu:!1,sevMenu:!1,wantTerm:null,wantPty:null,shells:[],setQ:"",setScope:"all",setPage:null,setBack:!1,pageGen:0,PL:[],shown:new Set((()=>{try{return JSON.parse(localStorage.getItem("kz-show"))||[]}catch(e){return[]}})())};var L=(e)=>document.getElementById(e),un=(e)=>String(e).replace(/[&<>"]/g,(t)=>({"&":"&","<":"<",">":">",'"':"""})[t]);class Fe{s;constructor(e){this.s=e}toString(){return this.s}}var U=(e)=>new Fe(String(e)),bt=(e)=>e instanceof Fe?e.s:Array.isArray(e)?e.map(bt).join(""):e==null||e===!1?"":un(e),w=(e,...t)=>U(e.reduce((n,a,s)=>n+bt(t[s-1])+a));var as=U('<div aria-busy="true" aria-label="Loading"><span class="skel" style="height:16px;width:35%;margin:20px 0 14px"></span>'+'<span class="skel" style="height:44px;margin-bottom:10px"></span>'.repeat(4)+"</div>");function $e(e){let t=document.createElement("dialog");return t.className="kz",t.innerHTML=`<form class="inl" method="dialog">${e}</form>`,t.onclose=()=>t.remove(),t.onclick=(n)=>{if(n.target===t)t.close()},document.body.appendChild(t),t.showModal(),t}var te=(e,t)=>{let n=t-e;return n<3600000?Math.round(n/60000)+"m":n<86400000?Math.round(n/3600000)+"h":Math.round(n/86400000)+"d"};var Ke=(e)=>typeof e==="string"?[e]:e.kids.flatMap(Ke);var Ve=(e,t)=>`ws:${e}:${t}`,$t=(e)=>e.kind==="run"&&e.status==="done"&&e.accept!=="needs"&&!e.archived&&e.git==="pending";var kt=3000,xe=new Map,me=(e)=>e.key+"@"+(e.born??0),vt={asking:0,working:1,done:2},ke={asking:"Asking",working:"Working",done:"Done"},mn={asking:"wait",working:"build",done:"done"};function fn(e,t,n=xe){if(e.asking)return"asking";if(e.busy)return n.set(me(e),t),"working";return t-(n.get(me(e))??-1/0)<kt?"working":"done"}var xt=(e,t,n=xe)=>Math.min(1/0,...e.filter((a)=>!a.asking&&!a.busy&&n.has(me(a))).map((a)=>kt-(t-n.get(me(a)))).filter((a)=>a>0)),Et=(e,t=xe)=>{let n=new Set(e.map(me));for(let a of t.keys())if(!n.has(a))t.delete(a)},Lt=(e,t,n,a,s,i=xe)=>e.filter((l)=>l.dir===t&&a({state:l.dir,ws:l.ws})===n).map((l)=>({a:l,st:fn(l,s,i)})).sort((l,r)=>vt[l.st]-vt[r.st]),yt=({a:e,st:t})=>e.last||`${ke[t]} - ${e.name}`,wt=(e,t)=>!e?"":t-e<60000?"now":te(e,t),gn=(e,t)=>e+"\x00"+t;function Mt(e,t,n){let a=gn(t,n);if(e[a])delete e[a];else e[a]=!0;return e}var hn=["claude","codex","gemini"],Ue=(e)=>w`<svg aria-hidden="true"><use href="#i-${hn.includes(e.agent??"")?e.agent:"ai"}"/></svg>`,We=(e)=>w`<i class="si ${mn[e]}"></i>`,bn=w`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 9l6 6 6-6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;function St(e,t,n,a,s){if(!e.length)return"";let i=w`data-dir="${a}" data-ws="${s}"`;if(e.length===1){let p=e[0];return w`<div class="wag"><button type="button" class="aone" data-term="${p.a.key}" ${i} title="${p.a.name}: open its terminal">${We(p.st)}${Ue(p.a)}<span class="atx">${ke[p.st]} - ${p.a.name}</span><small>${wt(p.a.at,t)}</small></button></div>`}let l=w`<button type="button" class="wchev${n?" on":""}" data-wopen ${i} aria-expanded="${String(n)}" aria-label="${String(e.length)} agents: ${n?"hide":"show"} the list">${bn}</button>`;if(n)return w`<div class="wag"><span class="aht">${String(e.length)} agents</span>${l}</div><div class="alist">${e.map((p)=>w`<button type="button" class="arow" data-term="${p.a.key}" ${i} title="${yt(p)}">${We(p.st)}${Ue(p.a)}<span class="atx">${yt(p)}</span><small>${wt(p.a.at,t)}</small></button>`)}</div>`;let r=["asking","working","done"].map((p)=>({st:p,rs:e.filter((k)=>k.st===p)})).filter((p)=>p.rs.length);return w`<div class="wag"><span class="chips">${r.map((p)=>w`<span class="chip">${We(p.st)}${p.rs.map((k)=>w`<button type="button" class="amark" data-term="${k.a.key}" ${i} title="${k.a.name} - ${ke[p.st]}: open its terminal" aria-label="${k.a.name} - ${ke[p.st]}: open its terminal">${Ue(k.a)}</button>`)}</span>`)}</span>${l}</div>`}function Je(e){return e.toLowerCase().trim().replace(/[^a-z0-9/._-]+/g,"-").replace(/\.{2,}/g,".").replace(/\/{2,}/g,"/").replace(/(^|\/)[-.]+/g,"$1").slice(0,60).replace(/[-./]+(\/|$)/g,"$1").replace(/\/$/,"").replace(/\.lock(\/|$)/g,"-lock$1")}var vn=(e)=>e.includes("\\")?"\\":"/";async function Y(e,t){try{let n=await fetch(e,t?{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}:void 0),a=await n.json().catch(()=>({}));return{ok:n.ok,d:n.ok?a:{error:a.error||a.why||"that did not work"}}}catch{return{ok:!1,d:{error:"the board is offline"}}}}function fe(e={}){let t=$e(""),n=t.querySelector("form");t.setAttribute("aria-label","Add a project");let a=e.start==="ws",s=(o)=>n.elements.namedItem(o),i=(o,d,u,b)=>(o.disabled=d,o.textContent=d?u:b),l=a?"":w`<button type="button" class="btn ghost" data-a="back">Back to add options</button>`,r=(o)=>w`<small class="att err" role="alert"></small><div class="row">${l}<button type="button" class="btn ghost" data-a="x">Cancel</button><button class="btn pri" data-a="go">${o}</button></div>`,p=(o)=>n.querySelector(".err").textContent=o,k=(o,d)=>{p(d);try{localStorage.setItem("kz-proj",o)}catch{}setTimeout(()=>location.href="/?view=board",900)},M=async(o,d)=>{let u=await Y("/pick-folder",{});if(u.d.path)o.value=d?u.d.path.replace(/[\\/]+$/,"")+vn(u.d.path)+d():u.d.path},f=(o)=>{let d=Tt();if(t.classList.toggle("wsnew",o==="ws"),o==="menu")n.innerHTML=w`<b>Add a project</b><small class="att">Add a project to get started with kaizen.</small><button type="button" class="btn opt" data-go="folder"><b>Existing folder</b><small>A project, a Git repo, or any folder</small></button><small class="att">Other ways to add</small><button type="button" class="btn opt" data-go="clone"><b>Clone from URL</b><small>Clone a remote Git repository</small></button><button type="button" class="btn opt" data-go="create"><b>Create new project</b><small>Start from an empty folder</small></button>${d.length?w`<button type="button" class="btn opt" data-go="ws"><b>New workspace</b><small>A branch in its own folder, in a project you have</small></button>`:""}<div class="row"><button type="button" class="btn ghost" data-a="x">Cancel</button></div>`.toString(),n.querySelectorAll("[data-go]").forEach((b)=>b.onclick=()=>f(b.dataset.go)),n.onsubmit=(b)=>b.preventDefault();else if(o==="folder")n.innerHTML=w`<b>Existing folder</b><small class="att">Pick a folder, or type its path. A .kaizen folder is added to it.</small><div class="row"><input name="path" placeholder="/path/to/folder" aria-label="Folder" autocomplete="off" spellcheck="false" required><button type="button" class="btn ghost" data-a="pick">Pick…</button></div>${r("Add project")}`.toString(),s("path").focus(),n.onsubmit=async(b)=>{b.preventDefault();let v=n.querySelector("[data-a=go]");i(v,!0,"Adding...","Add project");let y=await Y("/add-project",{path:s("path").value.trim()});i(v,!1,"","Add project"),y.ok?k(y.d.dir,y.d.already?"Project already added":"Project added"):p(y.d.error)},n.querySelector("[data-a=pick]").onclick=()=>M(s("path"));else if(o==="clone"){n.innerHTML=w`<b>Clone from URL</b><small class="att">Enter the Git URL (https or ssh) and choose where to clone it.</small><input name="url" placeholder="https://github.com/user/repo.git" aria-label="Git URL" autocomplete="off" spellcheck="false" required><div class="row"><input name="to" placeholder="Folder to clone into" aria-label="Clone into" autocomplete="off" spellcheck="false"><button type="button" class="btn ghost" data-a="pick">Pick…</button></div>${r("Clone")}`.toString(),s("url").focus();let b="",v="",y=async()=>{let C=s("url").value.trim();if(!C)return!1;let x=await Y("/clone",{url:C,check:!0});if(!x.ok)return p(x.d.error),!1;if(p(""),b=x.d.name,!s("to").value.trim()||s("to").value===v)s("to").value=v=x.d.to;return!0};s("url").onchange=y,n.querySelector("[data-a=pick]").onclick=async()=>await y()?M(s("to"),()=>b):s("url").focus(),n.onsubmit=async(C)=>{if(C.preventDefault(),!await y())return;let x=n.querySelector("[data-a=go]");i(x,!0,"Cloning...","Clone");let E=await Y("/clone",{url:s("url").value.trim(),to:s("to").value.trim()||void 0});i(x,!1,"","Clone"),E.ok?k(E.d.dir,"Cloned"):p(E.d.error)}}else if(o==="create"){n.innerHTML=w`<b>Create a new project</b><small class="att">Name it and kaizen will create the folder with a .kaizen inside.</small><input name="name" placeholder="my-project" aria-label="Name" autocomplete="off" spellcheck="false" required><div class="row"><input name="to" placeholder="Folder to create" aria-label="Create in" autocomplete="off" spellcheck="false"><button type="button" class="btn ghost" data-a="pick">Pick…</button></div><label class="att"><input type="checkbox" name="git" checked> Git repository</label>${r("Create project")}`.toString(),s("name").focus();let b="";s("name").oninput=async()=>{let v=s("name").value.trim();if(!v||/[\\/:*?"<>|]/.test(v)||s("to").value.trim()&&s("to").value!==b)return;let y=await Y("/new-project",{name:v,check:!0});if(y.ok&&s("name").value.trim()===v)s("to").value=b=y.d.to},n.querySelector("[data-a=pick]").onclick=()=>M(s("to"),()=>s("name").value.trim()),n.onsubmit=async(v)=>{v.preventDefault();let y=n.querySelector("[data-a=go]");i(y,!0,"Creating...","Create project");let C=await Y("/new-project",{name:s("name").value.trim(),to:s("to").value.trim()||void 0,git:s("git").checked});if(i(y,!1,"","Create project"),!C.ok)return p(C.d.error);k(C.d.dir,C.d.git===!1?"Project created, but git init failed":"Project created")}}else{let b=d.some((x)=>x.dir===e.dir)?e.dir:d[0]?.dir,v=/Mac/.test(navigator.platform)?"⌘":"Ctrl";n.innerHTML=w`<b>New workspace</b><label class="att">Project<select name="project" aria-label="Project">${d.map((x)=>w`<option value="${x.dir}"${x.dir===b?" selected":""}>${x.name}</option>`)}</select></label><div class="wsfrom"><span class="att" id="wsfl">Create from <i>[Optional]</i></span><label class="wsbase">from <select name="base" aria-label="Start from branch"></select></label></div><input name="name" placeholder="What is this workspace for?" aria-labelledby="wsfl" autocomplete="off" spellcheck="false"><details class="wsadv"><summary>Advanced</summary><label class="att">Branch name<input name="branch" placeholder="feature/my-branch" aria-label="Branch name" autocomplete="off" spellcheck="false"></label></details><small class="att err" role="alert"></small><div class="row">${l}<button type="button" class="btn ghost" data-a="x">Cancel</button><button class="btn pri" data-a="go">Create workspace</button><kbd class="wskey" aria-hidden="true">${v} ↵</kbd></div>`.toString(),s("name").focus();let y=n.elements.namedItem("base");s("name").oninput=()=>s("branch").placeholder=Je(s("name").value)||"feature/my-branch";let C=async()=>{let x=await Y("/branches?dir="+encodeURIComponent(s("project").value)),{def:E="",branches:W=[]}=x.ok?x.d:{};y.innerHTML=W.map((G)=>w`<option${G===E?" selected":""}>${G}</option>`.toString()).join("")||'<option value="">current branch</option>'};n.elements.namedItem("project").onchange=C,C(),n.onkeydown=(x)=>{if(x.key==="Enter"&&(x.ctrlKey||x.metaKey))x.preventDefault(),n.requestSubmit()},n.onsubmit=async(x)=>{x.preventDefault();let E=s("project").value,W=n.querySelector("[data-a=go]");if(W.disabled)return;p("");let G=s("branch").value.trim()||Je(s("name").value)||"workspace-"+Math.random().toString(36).slice(2,6);i(W,!0,"Creating...","Create workspace");let ue=await Y("/worktree",{dir:E,branch:G,base:y.value||void 0});i(W,!1,"","Create workspace"),ue.ok?(t.close(),location.href=X(E,ue.d.path)):p(ue.d.error)}}n.querySelector("[data-a=x]").onclick=()=>t.close();let u=n.querySelector("[data-a=back]");if(u)u.onclick=()=>f("menu")};f(e.start??"menu")}function jt(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);if(!n.length)return e;let a=t.trim().toLowerCase(),s=(i)=>{let l=i.title.toLowerCase();return l.startsWith(a)?0:l.includes(a)?1:2};return e.filter((i)=>{let l=(i.title+" "+(i.sub??"")+" "+i.hay).toLowerCase();return n.every((r)=>l.includes(r))}).sort((i,l)=>s(i)-s(l)||(l.at??0)-(i.at??0))}var Le=(e,t)=>!dispatchEvent(new CustomEvent(e,{cancelable:!0,detail:t})),ne=(e,t)=>()=>{let n=document.querySelector(`.rail a.it[data-view="${e}"]`);n?n.click():location.href=t},Ct=(e,t)=>{if(!Le("kz-open-ws",{dir:e,ws:t}))location.href=X(e,t)},At=()=>{try{return JSON.parse(localStorage.getItem("kz-runtabs")||"{}")}catch{return{}}},yn=(e,t,n)=>{if(Le("kz-open-tab",{dir:e,ws:t,id:n}))return;let a=At(),s=a[Ve(e,t)],i=s?.screens?.find((l)=>Ke(l.tree).includes(n));if(i)try{s.on=i.id,localStorage.setItem("kz-runtabs",JSON.stringify(a))}catch{}location.href=X(e,t)},wn=["local","preview","note","history","shell"],$n=(e)=>{try{return localStorage.getItem("kz-browse:"+e)?.replace(/^https?:\/\//,"").replace(/\/$/,"")}catch{}},kn={ws:'<circle cx="6" cy="6" r="2"/><circle cx="6" cy="18" r="2"/><circle cx="18" cy="8" r="2"/><path d="M6 8v8M18 10c0 4-6 3-12 6"/>',run:'<path d="M5 4l14 8-14 8z"/>',idea:'<path d="M9 18h6M10 21h4M12 3a6 6 0 0 0-4 10.5c.7.7 1 1.5 1 2.5h6c0-1 .3-1.8 1-2.5A6 6 0 0 0 12 3z"/>',chat:'<path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z"/>',term:'<path d="M4 17l6-5-6-5M12 19h8"/>',proj:'<path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>',page:'<rect x="4" y="4" width="16" height="16" rx="2"/><path d="M4 9h16"/>',act:'<path d="M13 3L5 14h6l-1 7 8-11h-6z"/>',tab:'<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 9h8V5"/>',plus:'<path d="M12 5v14M5 12h14"/>',search:'<circle cx="11" cy="11" r="7"/><path d="M20 20l-4-4"/>'},Rt=(e)=>U(`<svg viewBox="0 0 24 24" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${kn[e]}</g></svg>`),Bt=[];function xn(){let{cards:e,projects:t=[],agents:n=[]}=Dt(),a=Date.now(),s=new URLSearchParams(location.search),i=s.get("id")&&e.find((o)=>o.kind==="run"&&o.state===s.get("dir")&&o.id===s.get("id")),l=s.get("ws")??(i?ce(i,t):null),r=[],p=At(),k=new Map;for(let o of e){let d=o.state+"\x00"+ce(o,t);k.set(d,Math.max(k.get(d)??0,o.moved??0))}for(let o of t){let d=N(o.dir,t);for(let u of o.workspaces??[]){let b=s.get("dir")===o.dir&&l===u.path,v=k.get(o.dir+"\x00"+u.path);r.push({group:b?"Current":"Workspaces",title:se(u),sub:d,when:v?te(v,a):void 0,hay:`${se(u)} ${d} ${u.path} workspace`,at:b?1/0:v??0,ico:"ws",act:()=>Ct(o.dir,u.path)});let y=Ve(o.dir,u.path),C=p[y];for(let x of C?.tabs??[]){if(!wn.includes(x.kind)||C.hidden?.includes(x.id))continue;let E=x.kind==="local"&&$n(y)||x.title;r.push({group:"Tabs",title:E,sub:`${se(u)} · ${d}`,hay:`${E} ${x.title} ${x.kind} ${x.note??""} ${se(u)} ${d} tab`,ico:"tab",act:()=>yn(o.dir,u.path,x.id)})}}r.push({group:"Projects",title:d,hay:`${d} ${o.dir} project`,ico:"proj",act:()=>{let u=o.workspaces?.find((b)=>b.main)??o.workspaces?.[0];u?Ct(o.dir,u.path):ne("board","/?view=board")()}})}for(let o of e.filter((d)=>!d.archived)){let d=ae(o);r.push({group:o.kind==="run"?"Runs":"Ideas",title:Ge(o)||o.id,sub:N(o.state,t),when:o.moved?te(o.moved,a):void 0,hay:`${Ge(o)} ${o.id??""} ${o.text??""} ${N(o.state,t)} ${d}`,at:o.moved??0,dot:d,ico:o.kind==="run"?"run":"idea",act:()=>{if(!Le("kz-open-card",{dir:o.state,id:o.kind==="run"?o.id:void 0,text:o.text}))location.href=zt(o)}})}for(let o of Bt){let d=Date.parse(o.updated)||0;r.push({group:"Chats & terminals",title:o.title||"Chat",sub:o.project?N(o.project,t):void 0,when:d?te(d,a):void 0,hay:`${o.title} chat ${o.project??""}`,at:d,dot:o.busy?"build":void 0,ico:"chat",act:()=>{try{sessionStorage.setItem("kz-chat",o.id)}catch{}ne("home","/")()}})}for(let o of n)r.push({group:"Chats & terminals",title:o.name||o.agent||"Terminal",sub:N(o.dir,t),hay:`${o.name} ${o.agent??""} ${o.run??""} ${o.last??""} ${N(o.dir,t)} terminal agent`,at:o.at??o.born??0,dot:o.asking?"wait":o.busy?"build":"done",ico:"term",act:()=>{if(!Le("kz-open-term",{dir:o.dir,ws:o.ws,key:o.key}))location.href=X(o.dir,o.ws??"")}});let M=(o)=>()=>L(o)?.click(),f=[["Home","page",ne("home","/"),"chat"],["Icebox","page",ne("sources","/?view=icebox"),"requests sources gathered"],["Ideas","page",ne("ideas","/?view=ideas"),"backlog"],["Board","page",ne("board","/?view=board"),"kanban runs"],["Notes","page",()=>location.href="/notebook","notebook docs"],["Settings","page",ne("settings","/?view=settings"),"preferences config"],["New idea","act",()=>L("newtop")?L("newtop").click():location.href="/?view=board","create add run"],["Add a project","act",()=>fe({dir:null}),"clone folder create workspace"],["Toggle theme","act",M("themet"),"dark light"],["Collapse or expand menu","act",M("fold"),"sidebar rail"],["Keyboard shortcuts","act",M("kbd"),"keys help"],["Report an issue","act",()=>open("/issue","_blank","noopener"),"bug feedback"]];for(let[o,d,u,b]of f)r.push({group:"Actions",title:o,hay:`${o} ${b??""}`,ico:d,act:u});return r}var En=["Current","Workspaces","Tabs","Chats & terminals","Runs","Ideas","Projects","Actions"],Ln={Workspaces:5,Tabs:4,"Chats & terminals":5,Runs:5,Ideas:3,Projects:5},S=null,P=[],O=0;function Ee(){let e=S.querySelector("input").value,t=xn(),n=e.trim()?jt(t,e):t.slice().sort((l,r)=>(r.at??0)-(l.at??0));P=[];let a=e.trim()?[...new Set(n.map((l)=>l.group))]:En;for(let l of a){let r=n.filter((p)=>p.group===l);P.push(...r.slice(0,e.trim()?8:Ln[l]??r.length))}if(e.trim())P.push({group:"Create",title:`New idea "${e.trim()}"`,hay:"",ico:"plus",act:()=>Mn(e.trim())});O=Math.min(O,P.length-1);let s=S.querySelector(".gs-list"),i="";s.innerHTML=String(w`${P.map((l,r)=>{let p=l.group!==i?(i=l.group,w`<div class="gs-h" role="presentation">${l.group}</div>`):"";return w`${p}<div class="gs-i" role="option" id="gs-${r}" data-n="${r}" aria-selected="${String(r===O)}">${Rt(l.ico)}${l.dot?w`<span class="si ${l.dot}"></span>`:""}<span class="gs-t">${l.title}</span>${l.sub?w`<span class="gs-s">${l.sub}</span>`:""}${l.when?w`<span class="gs-w">${l.when}</span>`:""}</div>`})}${P.length===1&&e.trim()?w`<div class="gs-none">No results</div>`:""}`),_e(O),S.querySelector(".gs-live").textContent=`${P.length} result${P.length===1?"":"s"} found`}function _e(e){S.querySelector(`#gs-${O}`)?.setAttribute("aria-selected","false"),O=e;let t=S.querySelector(`#gs-${e}`);t?.setAttribute("aria-selected","true"),S.querySelector("input").setAttribute("aria-activedescendant","gs-"+e),t?.scrollIntoView({block:"nearest"})}function Mn(e){if(!L("newtop"))return void(location.href="/?view=board");L("newtop").click();let t=document.querySelector("dialog[open] textarea");if(t)t.value=e,t.dispatchEvent(new Event("input",{bubbles:!0}))}function Ht(e){let t=P[e];if(!t)return;S.close(),t.act()}function It(){if(S)return S.querySelector("input").focus();S=document.createElement("dialog"),S.className="gs",S.setAttribute("aria-label","Search"),S.innerHTML=String(w`<div class="gs-box"><div class="gs-q">${Rt("search")}<input type="text" placeholder="Search" aria-label="Search" role="combobox" aria-expanded="true" aria-controls="gs-list" autocomplete="off" spellcheck="false"></div><div class="gs-list" id="gs-list" role="listbox"></div><span class="gs-live" role="status" aria-live="polite"></span></div>`),document.body.append(S);let e=S.querySelector("input");O=0,e.oninput=()=>(O=0,Ee()),e.onkeydown=(n)=>{let a={ArrowDown:1,ArrowUp:-1}[n.key]??(n.ctrlKey&&n.key==="n"?1:n.ctrlKey&&n.key==="p"?-1:0);if(a)n.preventDefault(),_e((O+a+P.length)%P.length);else if(n.key==="Enter")n.preventDefault(),Ht(O)};let t=S.querySelector(".gs-list");t.onclick=(n)=>{let a=n.target.closest(".gs-i");if(a)Ht(+a.dataset.n)},t.onpointermove=(n)=>{let a=n.target.closest(".gs-i");if(a&&+a.dataset.n!==O)_e(+a.dataset.n)},S.onclick=(n)=>n.target===S&&S.close(),S.onclose=()=>(S.remove(),S=null),S.showModal(),Ee(),fetch("/chats").then((n)=>n.json()).then((n)=>{if(Bt=n.chats??[],S)Ee()}).catch(()=>{})}var Sn=`dialog.gs{border:0;padding:0;margin:14vh auto auto;background:none;width:min(560px,calc(100vw - 32px));color:var(--ink);overflow:visible}
|
|
3
3
|
dialog.gs::backdrop{background:rgb(0 0 0/.35)}
|
|
4
4
|
.gs-box{display:flex;flex-direction:column;max-height:min(480px,72vh);background:var(--bg);border:1px solid var(--line);border-radius:10px;box-shadow:0 16px 40px rgb(0 0 0/.25);overflow:hidden}
|