kaizen-agent 1.52.0 → 1.53.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/cli/chat-window.py +37 -0
- package/cli/chat.test.ts +38 -5
- package/cli/chat.ts +56 -13
- package/cli/install.ts +76 -1
- package/cli/settings.ts +25 -0
- package/cli/state.test.ts +10 -1
- package/cli/state.ts +17 -4
- package/cli/web.ts +134 -20
- package/package.json +1 -1
- package/skills/kaizen/config.default.yml +4 -0
- package/web/board/cards.ts +16 -4
- package/web/board/chat.ts +8 -12
- package/web/board/dom.ts +23 -3
- package/web/board/home.ts +18 -2
- package/web/board/settings.ts +16 -4
- package/web/board/toast.ts +45 -0
- package/web/board.html +3 -1
- package/web/board.js +41 -40
- package/web/notebook.js +1 -1
- package/web/popup.html +141 -0
- package/web/term.js +1 -1
- package/web/video.js +1 -1
package/web/notebook.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* kaizen notebook
|
|
1
|
+
/* kaizen notebook a36c21f9c721a2eb -- generated by bun run build:web from web/notebook.ts; do not edit */
|
|
2
2
|
var Ss=[],ua=[];(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map((t)=>t?parseInt(t,36):1);for(let t=0,i=0;t<e.length;t++)(t%2?ua:Ss).push(i=i+e[t])})();function op(e){if(e<768)return!1;for(let t=0,i=Ss.length;;){let n=t+i>>1;if(e<Ss[n])i=n;else if(e>=ua[n])t=n+1;else return!0;if(t==i)return!1}}function ha(e){return e>=127462&&e<=127487}var fa=8205;function da(e,t,i=!0,n=!0){return(i?Oa:lp)(e,t,n)}function Oa(e,t,i){if(t==e.length)return t;if(t&&pa(e.charCodeAt(t))&&ma(e.charCodeAt(t-1)))t--;let n=bs(e,t);t+=ca(n);while(t<e.length){let r=bs(e,t);if(n==fa||r==fa||i&&op(r))t+=ca(r),n=r;else if(ha(r)){let s=0,o=t-2;while(o>=0&&ha(bs(e,o)))s++,o-=2;if(s%2==0)break;else t+=2}else break}return t}function lp(e,t,i){while(t>1){let n=Oa(e,t-2,i);if(n<t)return n;t--}return 0}function bs(e,t){let i=e.charCodeAt(t);if(!ma(i)||t+1==e.length)return i;let n=e.charCodeAt(t+1);if(!pa(n))return i;return(i-55296<<10)+(n-56320)+65536}function pa(e){return e>=56320&&e<57344}function ma(e){return e>=55296&&e<56320}function ca(e){return e<65536?1:2}class _{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=vi(this,e,t);let n=[];if(this.decompose(0,e,n,2),i.length)i.decompose(0,i.length,n,3);return this.decompose(t,this.length,n,1),ft.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=vi(this,e,t);let i=[];return this.decompose(e,t,i,0),ft.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new wi(this),r=new wi(e);for(let s=t,o=t;;){if(n.next(s),r.next(s),s=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(o+=n.value.length,n.done||o>=i)return!0}}iter(e=1){return new wi(this,e)}iterRange(e,t=this.length){return new Ts(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{if(t==null)t=this.lines+1;let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new As(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw RangeError("A document must have at least one line");if(e.length==1&&!e[0])return _.empty;return e.length<=32?new oe(e):ft.from(oe.split(e,[]))}}class oe extends _{constructor(e,t=ap(e)){super();this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let s=this.text[r],o=n+s.length;if((t?i:o)>=e)return new ka(n,o,i,s);n=o+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new oe(ga(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(n&1){let s=i.pop(),o=cr(r.text,s.text.slice(),0,r.length);if(o.length<=32)i.push(new oe(o,s.length+r.length));else{let l=o.length>>1;i.push(new oe(o.slice(0,l)),new oe(o.slice(l)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof oe))return super.replace(e,t,i);[e,t]=vi(this,e,t);let n=cr(this.text,cr(i.text,ga(this.text,0,e)),t),r=this.length+i.length-(t-e);if(n.length<=32)return new oe(n,r);return ft.from(oe.split(n,[]),r)}sliceString(e,t=this.length,i=`
|
|
3
3
|
`){[e,t]=vi(this,e,t);let n="";for(let r=0,s=0;r<=t&&s<this.text.length;s++){let o=this.text[s],l=r+o.length;if(r>e&&s)n+=i;if(e<l&&t>r)n+=o.slice(Math.max(0,e-r),t-r);r=l+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let r of e)if(i.push(r),n+=r.length+1,i.length==32)t.push(new oe(i,n)),i=[],n=-1;if(n>-1)t.push(new oe(i,n));return t}}class ft extends _{constructor(e,t){super();this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,n){for(let r=0;;r++){let s=this.children[r],o=n+s.length,l=i+s.lines-1;if((t?l:o)>=e)return s.lineInner(e,t,i,n);n=o+1,i=l+1}}decompose(e,t,i,n){for(let r=0,s=0;s<=t&&r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e<=l&&t>=s){let a=n&((s<=e?1:0)|(l>=t?2:0));if(s>=e&&l<=t&&!a)i.push(o);else o.decompose(e-s,t-s,i,a)}s=l+1}}replace(e,t,i){if([e,t]=vi(this,e,t),i.lines<this.lines)for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],o=r+s.length;if(e>=r&&t<=o){let l=s.replace(e-r,t-r,i),a=this.lines-s.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let h=this.children.slice();return h[n]=l,new ft(h,this.length-(t-e)+i.length)}return super.replace(r,o,l)}r=o+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
|
|
4
4
|
`){[e,t]=vi(this,e,t);let n="";for(let r=0,s=0;r<this.children.length&&s<=t;r++){let o=this.children[r],l=s+o.length;if(s>e&&r)n+=i;if(e<l&&t>s)n+=o.sliceString(e-s,t-s,i);s=l+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof ft))return 0;let i=0,[n,r,s,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,r+=t){if(n==s||r==o)return i;let l=this.children[n],a=e.children[r];if(l!=a)return i+l.scanIdentical(a,t);i+=l.length+1}}static from(e,t=e.reduce((i,n)=>i+n.length+1,-1)){let i=0;for(let u of e)i+=u.lines;if(i<32){let u=[];for(let d of e)d.flatten(u);return new oe(u,t)}let n=Math.max(32,i>>5),r=n<<1,s=n>>1,o=[],l=0,a=-1,h=[];function f(u){let d;if(u.lines>r&&u instanceof ft)for(let O of u.children)f(O);else if(u.lines>s&&(l>s||!l))c(),o.push(u);else if(u instanceof oe&&l&&(d=h[h.length-1])instanceof oe&&u.lines+d.lines<=32)l+=u.lines,a+=u.length+1,h[h.length-1]=new oe(d.text.concat(u.text),d.length+1+u.length);else{if(l+u.lines>n)c();l+=u.lines,a+=u.length+1,h.push(u)}}function c(){if(l==0)return;o.push(h.length==1?h[0]:ft.from(h,a)),a=-1,l=h.length=0}for(let u of e)f(u);return c(),o.length==1?o[0]:new ft(o,t)}}_.empty=new oe([""],0);function ap(e){let t=-1;for(let i of e)t+=i.length+1;return t}function cr(e,t,i=0,n=1e9){for(let r=0,s=0,o=!0;s<e.length&&r<=n;s++){let l=e[s],a=r+l.length;if(a>=i){if(a>n)l=l.slice(0,n-r);if(r<i)l=l.slice(i-r);if(o)t[t.length-1]+=l,o=!1;else t.push(l)}r=a+1}return t}function ga(e,t,i){return cr(e,[""],t,i)}class wi{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof oe?e.text.length:e.children.length)<<1]}nextInner(e,t){this.done=this.lineBreak=!1;for(;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],s=r>>1,o=n instanceof oe?n.text.length:n.children.length;if(s==(t>0?o:0)){if(i==0)return this.done=!0,this.value="",this;if(t>0)this.offsets[i-1]++;this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
|
package/web/popup.html
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>kaizen chat</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root{--bg-2:#fff;--line:#d9e0ee;--ink:#0c162f;--dim:#5b6b8c;--accent:#2d50a5;--danger:#c8322f;color-scheme:light}
|
|
9
|
+
@media(prefers-color-scheme:dark){:root{--bg-2:#121e3c;--line:#22305a;--ink:#eef2fa;--dim:#96aacd;--accent:#486ed9;--danger:#e85050;color-scheme:dark}}
|
|
10
|
+
*{box-sizing:border-box}
|
|
11
|
+
/* No window background: only the bubbles, the input and the buttons show. */
|
|
12
|
+
html{background:transparent}
|
|
13
|
+
/* A soft dark glow behind the chat, fading to nothing at the edges, so text reads over any wallpaper. */
|
|
14
|
+
body{background:radial-gradient(closest-side at 50% 62%,#0005,#0002 60%,transparent)}
|
|
15
|
+
html,body{margin:0;height:100%;color:var(--ink);font:14px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
|
|
16
|
+
body{display:flex;gap:8px;padding:14px}
|
|
17
|
+
main{flex:1;min-width:0;display:flex;flex-direction:column}
|
|
18
|
+
/* The icon rail beside the chat, level with the input. */
|
|
19
|
+
nav{display:flex;flex-direction:column;gap:8px;padding-bottom:3px}
|
|
20
|
+
nav .sp{flex:1}
|
|
21
|
+
#drag{cursor:grab}
|
|
22
|
+
/* A soft shadow under every floating piece, so it reads over any wallpaper. */
|
|
23
|
+
:root{--shadow:0 1px 2px #0003,0 6px 18px #0006}
|
|
24
|
+
button{display:grid;place-items:center;width:36px;height:36px;padding:0;color:var(--dim);background:var(--bg-2);border:1px solid var(--line);border-radius:50%;cursor:pointer;box-shadow:var(--shadow)}
|
|
25
|
+
button[hidden]{display:none}
|
|
26
|
+
button svg{width:17px;height:17px}
|
|
27
|
+
button.on{color:#fff;background:var(--accent);border-color:var(--accent)}
|
|
28
|
+
button:hover{color:var(--ink);border-color:var(--accent)}
|
|
29
|
+
/* Older bubbles fade out toward the top as the chat grows. */
|
|
30
|
+
#log{flex:1;min-height:0;overflow-y:auto;scrollbar-width:none;margin:0 -6px 0 -14px;padding:10px 6px 10px 14px;display:flex;flex-direction:column;gap:8px;-webkit-mask-image:linear-gradient(transparent,#000 22%);mask-image:linear-gradient(transparent,#000 22%)}
|
|
31
|
+
#log::-webkit-scrollbar{display:none}
|
|
32
|
+
#log>:first-child{margin-top:auto}
|
|
33
|
+
.m{max-width:85%;padding:8px 12px;border-radius:18px;white-space:pre-wrap;word-wrap:break-word;box-shadow:var(--shadow)}
|
|
34
|
+
.m.pop{animation:pop .28s cubic-bezier(.2,1.4,.4,1) both}
|
|
35
|
+
@keyframes pop{from{opacity:0;transform:translateY(10px) scale(.85)}}
|
|
36
|
+
.u{align-self:flex-end;background:var(--accent);color:#fff;border-bottom-right-radius:6px;transform-origin:bottom right}
|
|
37
|
+
.a{align-self:flex-start;background:var(--bg-2);border:1px solid var(--line);border-bottom-left-radius:6px;transform-origin:bottom left}
|
|
38
|
+
.a.wait{color:var(--dim);font-style:italic}
|
|
39
|
+
.err{color:var(--danger)}
|
|
40
|
+
form{display:flex;margin-top:6px}
|
|
41
|
+
textarea{flex:1;resize:none;font:inherit;color:inherit;background:var(--bg-2);border:1px solid var(--line);border-radius:22px;padding:9px 16px;max-height:140px;outline:none;box-shadow:var(--shadow)}
|
|
42
|
+
textarea:focus{border-color:var(--accent)}
|
|
43
|
+
@media(prefers-reduced-motion:reduce){.m.pop{animation:none}}
|
|
44
|
+
</style>
|
|
45
|
+
</head>
|
|
46
|
+
<body>
|
|
47
|
+
<main><div id="log"></div>
|
|
48
|
+
<form id="f"><textarea id="t" rows="1" placeholder="Ask kaizen…" autofocus></textarea></form></main>
|
|
49
|
+
<nav><button id="drag" hidden title="Drag to move" aria-label="Drag to move"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="6" r=".6"/><circle cx="15" cy="6" r=".6"/><circle cx="9" cy="12" r=".6"/><circle cx="15" cy="12" r=".6"/><circle cx="9" cy="18" r=".6"/><circle cx="15" cy="18" r=".6"/></svg></button><span class="sp"></span><button id="stop" hidden title="Stop" aria-label="Stop"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="7" width="10" height="10" rx="2"/></svg></button><button id="board" title="Back to the board" aria-label="Back to the board"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 0 11H11"/></svg></button><button id="new" title="New chat" aria-label="New chat"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5v14M5 12h14"/></svg></button></nav>
|
|
50
|
+
<script>
|
|
51
|
+
// A small window over the desktop, on Home's chat: same chats, same agent.
|
|
52
|
+
// Enter sends, Shift+Enter is a new line, Esc closes the window.
|
|
53
|
+
const $ = (id) => document.getElementById(id);
|
|
54
|
+
const K = "kz-popup-chat";
|
|
55
|
+
let id = null, msgs = [], busy = false;
|
|
56
|
+
try { id = localStorage.getItem(K); } catch (e) {}
|
|
57
|
+
// Popped out of Home (`kaizen chat --chat <id>`): continue that chat.
|
|
58
|
+
const handed = new URLSearchParams(location.search).get("chat");
|
|
59
|
+
if (handed) { id = handed; try { localStorage.setItem(K, id); } catch (e) {} }
|
|
60
|
+
|
|
61
|
+
let shown = 0;
|
|
62
|
+
function draw() {
|
|
63
|
+
const log = $("log");
|
|
64
|
+
log.replaceChildren(...msgs.map((m, i) => {
|
|
65
|
+
const d = document.createElement("div");
|
|
66
|
+
// Only bubbles not shown before pop in; redraws of a streaming reply do not.
|
|
67
|
+
d.className = "m " + (m.role === "user" ? "u" : "a") + (m.wait ? " wait" : "") + (m.error ? " err" : "") + (i >= shown ? " pop" : "");
|
|
68
|
+
d.textContent = m.error || m.text || m.wait || "";
|
|
69
|
+
return d;
|
|
70
|
+
}));
|
|
71
|
+
shown = msgs.length;
|
|
72
|
+
log.scrollTop = log.scrollHeight;
|
|
73
|
+
$("stop").hidden = !busy;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function open() {
|
|
77
|
+
if (!id) return draw();
|
|
78
|
+
const r = await fetch("/chat?id=" + encodeURIComponent(id));
|
|
79
|
+
if (!r.ok) { id = null; return draw(); }
|
|
80
|
+
const c = await r.json();
|
|
81
|
+
msgs = (c.messages || []).map((m) => ({ role: m.role, text: m.text, error: m.error }));
|
|
82
|
+
busy = !!c.busy;
|
|
83
|
+
draw();
|
|
84
|
+
// A turn still running from before this window opened: show it when it ends.
|
|
85
|
+
if (busy) setTimeout(open, 2000);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function send(text) {
|
|
89
|
+
const reply = { role: "assistant", text: "", wait: "Thinking…" };
|
|
90
|
+
msgs.push({ role: "user", text }, reply);
|
|
91
|
+
busy = true; draw();
|
|
92
|
+
try {
|
|
93
|
+
const r = await fetch("/chat", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ id, text }) });
|
|
94
|
+
if (!r.ok) { reply.error = (await r.json().catch(() => ({}))).error || "Could not send"; return; }
|
|
95
|
+
const rd = r.body.getReader(), dec = new TextDecoder();
|
|
96
|
+
let buf = "";
|
|
97
|
+
for (let x; !(x = await rd.read()).done; ) {
|
|
98
|
+
buf += dec.decode(x.value, { stream: true });
|
|
99
|
+
let i;
|
|
100
|
+
while ((i = buf.indexOf("\n")) >= 0) {
|
|
101
|
+
let e;
|
|
102
|
+
try { e = JSON.parse(buf.slice(0, i)); } catch (err) { e = {}; }
|
|
103
|
+
buf = buf.slice(i + 1);
|
|
104
|
+
if (e.t === "chat") { id = e.id; try { localStorage.setItem(K, id); } catch (err) {} }
|
|
105
|
+
if (e.t === "text") { reply.text += (reply.text ? "\n\n" : "") + e.text; delete reply.wait; }
|
|
106
|
+
if (e.t === "status" && !reply.text) reply.wait = e.text;
|
|
107
|
+
if (e.t === "error") reply.error = e.error;
|
|
108
|
+
draw();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
} catch (e) {
|
|
112
|
+
reply.error = "Lost the connection; the agent keeps going and the chat saves when it finishes.";
|
|
113
|
+
} finally {
|
|
114
|
+
busy = false;
|
|
115
|
+
if (!reply.text && !reply.error) reply.wait = "(no reply)";
|
|
116
|
+
draw();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
$("t").onkeydown = (e) => {
|
|
121
|
+
if (e.key !== "Enter" || e.shiftKey) return;
|
|
122
|
+
e.preventDefault();
|
|
123
|
+
const text = $("t").value.trim();
|
|
124
|
+
if (!text || busy) return;
|
|
125
|
+
$("t").value = "";
|
|
126
|
+
send(text);
|
|
127
|
+
};
|
|
128
|
+
$("t").oninput = () => { $("t").style.height = "auto"; $("t").style.height = $("t").scrollHeight + "px"; };
|
|
129
|
+
$("new").onclick = () => { if (busy) return; id = null; msgs = []; try { localStorage.removeItem(K); } catch (e) {} draw(); $("t").focus(); };
|
|
130
|
+
// Back to the board: the server shows and focuses its window, then closes this one.
|
|
131
|
+
$("board").onclick = () => fetch("/popup/board", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ id }) });
|
|
132
|
+
// The see-through window (cli/chat-window.py) moves itself; Chromium's has no handler.
|
|
133
|
+
const host = window.webkit?.messageHandlers?.kaizen;
|
|
134
|
+
$("drag").hidden = !host;
|
|
135
|
+
$("drag").onpointerdown = (e) => { if (e.button === 0) host.postMessage("drag"); };
|
|
136
|
+
$("stop").onclick = () => fetch("/chat/stop", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ id }) });
|
|
137
|
+
addEventListener("keydown", (e) => { if (e.key === "Escape") window.close(); });
|
|
138
|
+
open();
|
|
139
|
+
</script>
|
|
140
|
+
</body>
|
|
141
|
+
</html>
|
package/web/term.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* kaizen terminal
|
|
1
|
+
/* kaizen terminal a36c21f9c721a2eb -- generated by bun run build:web from web/term.ts; do not edit */
|
|
2
2
|
(()=>{var{defineProperty:Ao,getOwnPropertyDescriptor:Jh}=Object,Qh=(e,t)=>{for(var i in t)Ao(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&&Ao(t,i,r),r},P=(e,t)=>(i,s)=>t(i,s,e),Rn="Terminal input",rr={get:()=>Rn,set:(e)=>Rn=e},Dn="Too much output to announce, navigate to rows manually to read",nr={get:()=>Dn,set:(e)=>Dn=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");Po(r,t,i,s)}}function Po(e,t,i,s){e=el(e),e=tl(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function Oo(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 Tn(e,t,i,s,r){Oo(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Bt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function us(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,f=this.interim[0];f&=(f&224)===192?31:(f&240)===224?15:7;let v=0,b;for(;(b=this.interim[++v]&63)&&v<4;)f<<=6,f|=b;let E=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,A=E-v;for(;h<A;){if(h>=i)return 0;if(b=e[h++],(b&192)!==128){h--,u=!0;break}else this.interim[v++]=b,f<<=6,f|=b&63}u||(E===2?f<128?h--:t[s++]=f:E===3?f<2048||f>=55296&&f<=57343||f===65279||(t[s++]=f):f<65536||f>1114111||(t[s++]=f)),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}},Io="",At=" ",Ri=class e{constructor(){this.fg=0,this.bg=0,this.extended=new ss}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}},ss=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}},Ye=class e extends Ri{constructor(){super(...arguments);this.content=0,this.fg=0,this.bg=0,this.extended=new ss,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?Bt(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()]}},Bn="di$target",or="di$dependencies",$s=new Map;function ol(e){return e[or]||[]}function xe(e){if($s.has(e))return $s.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,$s.set(e,t),t}function al(e,t,i){t[Bn]===t?t[or].push({id:e,index:i}):(t[or]=[{id:e,index:i}],t[Bn]=t)}var Pe=xe("BufferService"),No=xe("CoreMouseService"),Gt=xe("CoreService"),hl=xe("CharsetService"),Pr=xe("InstantiationService"),Fo=xe("LogService"),Oe=xe("OptionsService"),Wo=xe("OscLinkService"),ll=xe("UnicodeService"),Di=xe("DecorationService"),ar=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 Ye,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}},f=!1;if(!r?.allowNonHttpProtocols)try{let v=new URL(c);["http:","https:"].includes(v.protocol)||(f=!0)}catch{f=!0}f||s.push({text:c,range:u,activate:(v,b)=>r?r.activate(v,b,u):cl(v,b),hover:(v,b)=>r?.hover?.(v,b,u),leave:(v,b)=>r?.leave?.(v,b,u)})}h=!1,n.hasExtendedAttrs()&&n.extended.urlId?(l=d,a=n.extended.urlId):(l=-1,a=-1)}}t(s)}};ar=he([P(0,Pe),P(1,Oe),P(2,Wo)],ar);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 _s=xe("CharSizeService"),gt=xe("CoreBrowserService"),Or=xe("MouseService"),pt=xe("RenderService"),dl=xe("SelectionService"),zo=xe("CharacterJoinerService"),Qt=xe("ThemeService"),Ho=xe("LinkProviderService"),ul=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?An.isErrorNoTelemetry(e)?new An(e.message+`
|
package/web/video.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* kaizen video page
|
|
1
|
+
/* kaizen video page a36c21f9c721a2eb -- generated by bun run build:web from web/video.ts; do not edit */
|
|
2
2
|
(()=>{var W={TikTok:"9x16","Instagram Reels":"9x16","YouTube Shorts":"9x16","WhatsApp Status":"9x16",YouTube:"16x9","Instagram feed":"4x5"},de={"9x16":[1080,1920],"16x9":[1920,1080],"4x5":[1080,1350]},X=["#b4462f","#a8720a","#2d50a5","#0f8fa3","#1f9d55","#7a4fb5","#c2416b","#5b6b8c"],p=(e)=>document.getElementById(e),l=(e)=>String(e??"").replace(/[&<>"']/g,(t)=>`&#${t.charCodeAt(0)};`),E=(e)=>e==null?"":`${Math.floor(e/60)}:${String(Math.round(e%60)).padStart(2,"0")}`,O=(e)=>(e??"9x16").replace("x",":"),I=(e,t)=>`/video/f/${e.place}/${encodeURIComponent(e.name)}/${t.split("/").map(encodeURIComponent).join("/")}`,ce={draft:"Draft",queued:"Queued",building:"Building preview",rendering:"Rendering",ready:"Ready",failed:"Failed"},_=[],ue=[],pe=[],He=(e,t)=>ue.filter((n)=>n.place===e&&n.name===t).sort((n,i)=>i.at-n.at)[0],D="",Ee;function h(e){let t=p("toast");t.textContent=e,t.classList.add("on"),clearTimeout(Ee),Ee=setTimeout(()=>t.classList.remove("on"),3200)}async function M(e,t){let n=await fetch(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}),i=await n.json().catch(()=>({}));if(!n.ok)throw Error(i.error||i.why||`${n.status}`);return i}async function R(){let e;try{e=await fetch("/video/list")}catch{h("The board is not running");return}let t=await e.json();if(_=t.videos,ue=t.agents??[],pe=t.places,p("emptyhow").innerHTML=`Videos are folders under <code>videos/</code> in ${t.places.map((n)=>`<code>${l(n.dir)}</code>`).join(" or ")}. Ask the kaizen-video skill to make one, and it shows up here.`,me(),y)xe(),Ae();ye()}function De(){return _.flatMap((e)=>{let t=e.outputs.filter((s)=>s.kind!=="history"&&s.kind!=="trying"),n=t.length?t:[null],i=new Map;for(let s of n)if(!i.has(s?.format??e.formats[0]))i.set(s?.format??e.formats[0],s);return[...i].map(([s,a])=>({v:e,f:s,o:a}))})}function me(){let e=p("q").value.trim().toLowerCase().split(/\s+/).filter(Boolean),t=De(),n=t.filter(({v:s})=>{let a=[s.title,s.name,s.text,s.preset,s.where,s.mode,...s.platforms].join(" ").toLowerCase();return(D==="busy"?["queued","building","rendering"].includes(s.status):!D||s.status===D)&&e.every((o)=>a.includes(o))}),i=ue.filter((s)=>s.alive&&!_.some((a)=>a.place===s.place&&a.name===s.name)&&e.every((a)=>s.name.includes(a))&&(!D||D==="busy"||D==="draft"));p("grid").removeAttribute("aria-busy"),p("grid").innerHTML=i.map((s)=>`<article class="vid" tabindex="0" data-p="${s.place}" data-n="${l(s.name)}" aria-label="${l(s.name)}, being made">
|
|
3
3
|
<div class="thumb making" style="--ar:9/16"><span class="t">${s.asking?"Claude is asking you something":"Claude is making this"}</span></div>
|
|
4
4
|
<div class="meta"><b>${l(s.name)}</b><div class="plats"><i class="where">${l(pe[s.place]?.label??"")}</i></div>
|