@litfamily/litcodex 1.0.21 โ 1.0.23
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-Ko-KR.md +9 -9
- package/README.md +9 -9
- package/dist/install/doctor-render.js +5 -0
- package/dist/install/doctor.js +9 -0
- package/dist/install/types.d.ts +4 -0
- package/marketplace/plugins/litcodex/.codex-plugin/plugin.json +1 -1
- package/marketplace/plugins/litcodex/.mcp.json +9 -1
- package/marketplace/plugins/litcodex/components/auto-update/package.json +1 -1
- package/marketplace/plugins/litcodex/components/comment-checker/package.json +1 -1
- package/marketplace/plugins/litcodex/components/git-bash/package.json +1 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-html.d.ts +1 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-html.js +313 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-mcp.d.ts +14 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-mcp.js +141 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-server.d.ts +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-server.js +38 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-status.d.ts +43 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-status.js +363 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/cli.js +5 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.d.ts +14 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.js +76 -2
- package/marketplace/plugins/litcodex/components/lit-loop/dist/live-step.d.ts +59 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/live-step.js +287 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-map.d.ts +30 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/workflow-map.js +113 -45
- package/marketplace/plugins/litcodex/components/lit-loop/package.json +1 -1
- package/marketplace/plugins/litcodex/components/lsp/package.json +1 -1
- package/marketplace/plugins/litcodex/components/rules/package.json +1 -1
- package/marketplace/plugins/litcodex/components/start-work-continuation/package.json +1 -1
- package/marketplace/plugins/litcodex/components/telemetry/package.json +1 -1
- package/marketplace/plugins/litcodex/components/wikify-knowledge/package.json +1 -1
- package/marketplace/plugins/litcodex/hooks/hooks.json +20 -0
- package/node_modules/@litcodex/lit-loop/dist/card-html.d.ts +1 -0
- package/node_modules/@litcodex/lit-loop/dist/card-html.js +313 -0
- package/node_modules/@litcodex/lit-loop/dist/card-mcp.d.ts +14 -0
- package/node_modules/@litcodex/lit-loop/dist/card-mcp.js +141 -0
- package/node_modules/@litcodex/lit-loop/dist/card-server.d.ts +2 -0
- package/node_modules/@litcodex/lit-loop/dist/card-server.js +38 -0
- package/node_modules/@litcodex/lit-loop/dist/card-status.d.ts +43 -0
- package/node_modules/@litcodex/lit-loop/dist/card-status.js +363 -0
- package/node_modules/@litcodex/lit-loop/dist/cli.js +5 -1
- package/node_modules/@litcodex/lit-loop/dist/hook-cli.d.ts +14 -0
- package/node_modules/@litcodex/lit-loop/dist/hook-cli.js +76 -2
- package/node_modules/@litcodex/lit-loop/dist/live-step.d.ts +59 -0
- package/node_modules/@litcodex/lit-loop/dist/live-step.js +287 -0
- package/node_modules/@litcodex/lit-loop/dist/workflow-map.d.ts +30 -0
- package/node_modules/@litcodex/lit-loop/dist/workflow-map.js +113 -45
- package/node_modules/@litcodex/lit-loop/package.json +1 -1
- package/package.json +2 -2
- package/readme-assets/badge-version.svg +1 -1
|
@@ -117,6 +117,16 @@
|
|
|
117
117
|
"statusMessage": "\ud83d\udd25 LIT IGNITED \u00b7 rules \ud83d\udd25"
|
|
118
118
|
}
|
|
119
119
|
]
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"hooks": [
|
|
123
|
+
{
|
|
124
|
+
"type": "command",
|
|
125
|
+
"command": "node \"${PLUGIN_ROOT}/components/lit-loop/dist/cli.js\" hook pre-tool-use-live",
|
|
126
|
+
"timeout": 5,
|
|
127
|
+
"statusMessage": "\ud83d\udd25 LIT \u00b7 live step"
|
|
128
|
+
}
|
|
129
|
+
]
|
|
120
130
|
}
|
|
121
131
|
],
|
|
122
132
|
"PostToolUse": [
|
|
@@ -174,6 +184,16 @@
|
|
|
174
184
|
"statusMessage": "\ud83d\udd25 LIT IGNITED \u00b7 rules \ud83d\udd25"
|
|
175
185
|
}
|
|
176
186
|
]
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"hooks": [
|
|
190
|
+
{
|
|
191
|
+
"type": "command",
|
|
192
|
+
"command": "node \"${PLUGIN_ROOT}/components/lit-loop/dist/cli.js\" hook post-tool-use-live",
|
|
193
|
+
"timeout": 5,
|
|
194
|
+
"statusMessage": "\ud83d\udd25 LIT \u00b7 live step"
|
|
195
|
+
}
|
|
196
|
+
]
|
|
177
197
|
}
|
|
178
198
|
],
|
|
179
199
|
"PostCompact": [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CARD_HTML = "<!doctype html>\n<html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n<title>LIT</title>\n<style>\n:root{color-scheme:dark;--bg:#10141c;--bg2:#0d1118;--ink:#e6edf3;--dim:#7d8590;--faint:#30363d;--rail:#3a434e;--flame:#ff6337;--pink:#ff2d95;--acc:#5fd7ff;--accfill:#5fd7ff;--green:#6bdb8f;--amber:#ffaf3c;--red:#ff5f5f;--pillink:#0b0f14;\n--mono:\"SF Mono\",SFMono-Regular,ui-monospace,Menlo,Monaco,Consolas,\"Liberation Mono\",monospace}\n:root.light{color-scheme:light;--bg:#ffffff;--bg2:#fafbfd;--ink:#1b1f27;--dim:#69717e;--faint:#dde2e8;--rail:#cfd6de;--flame:#e2521f;--pink:#d81b78;--acc:#0a87b8;--green:#1f9d55;--amber:#b86e00;--red:#d93a3a}\n*{box-sizing:border-box}\nhtml,body{margin:0;background:transparent}\nbody{color:var(--ink);font-size:12.5px;line-height:1.55;font-weight:500;-webkit-font-smoothing:antialiased}\n.lc,.lc *{font-family:var(--mono)!important}\n.lc{position:relative;border-radius:14px;padding:11px 14px 10px;margin:1px;\nbackground:radial-gradient(110% 120% at 0% 0%,color-mix(in srgb,var(--pink) 8%,transparent),transparent 55%),radial-gradient(80% 110% at 100% 0%,color-mix(in srgb,var(--acc) 6%,transparent),transparent 60%),linear-gradient(180deg,var(--bg),var(--bg2));\nborder:1px solid color-mix(in srgb,var(--acc) 55%,transparent);box-shadow:0 0 0 1px color-mix(in srgb,var(--acc) 8%,transparent),0 10px 30px -18px color-mix(in srgb,var(--acc) 50%,transparent);animation:breathe 4.8s ease-in-out infinite}\n.lc.is-done{border-color:color-mix(in srgb,var(--green) 55%,transparent);box-shadow:0 0 0 1px color-mix(in srgb,var(--green) 8%,transparent);animation:none}\n.lc.is-idle{border-color:color-mix(in srgb,var(--dim) 40%,transparent);box-shadow:none;animation:none}\n@keyframes breathe{0%,100%{border-color:color-mix(in srgb,var(--acc) 38%,transparent)}50%{border-color:color-mix(in srgb,var(--acc) 80%,transparent)}}\n.head{display:flex;align-items:center;gap:7px;white-space:nowrap;min-height:22px}\n.brand{position:relative;overflow:hidden;display:inline-flex;align-items:center;gap:3px;padding:1px 9px 1px 7px;border-radius:999px;background:linear-gradient(90deg,#ff2d95,#ff6337);color:#0b0f14;font-weight:800;letter-spacing:.03em;box-shadow:0 0 16px -6px rgba(255,45,149,.6)}\n.j{color:var(--faint)}\n.name{font-weight:700;overflow:hidden;text-overflow:ellipsis}.acc{color:var(--acc)}.dim{color:var(--dim)}.ok{color:var(--green)}\n.right{margin-left:auto;font-weight:700;letter-spacing:.04em;display:inline-flex;align-items:center;gap:6px}\n.dot{width:6px;height:6px;border-radius:50%;background:var(--acc);box-shadow:0 0 7px var(--acc);animation:pulse 1.6s ease-in-out infinite}\n@keyframes pulse{50%{opacity:.35}}\n.map{display:flex;align-items:center;gap:7px;margin:9px 0 6px;white-space:nowrap;overflow:hidden}\n.st em{font-style:normal;margin-left:3px}.st.todo{color:var(--dim)}.st.done{font-weight:600}\n.rail{position:relative;display:inline-block;height:2px;border-radius:2px;flex:1 1 12px;max-width:56px;min-width:10px;background:var(--rail)}\n.rail.lead{overflow:hidden}.headfill{position:absolute;inset:0;width:40%;background:linear-gradient(90deg,var(--acc),transparent)}\n.comet{position:absolute;top:50%;width:5px;height:5px;margin-top:-2.5px;border-radius:50%;background:#fff;box-shadow:0 0 7px 2px var(--acc);animation:comet 2.4s linear infinite}\n:root.light .comet{background:var(--accfill);box-shadow:0 0 5px 1px var(--accfill)}\n@keyframes comet{0%{left:-8%;opacity:0}15%,85%{opacity:1}100%{left:100%;opacity:0}}\n.nowpill{position:relative;overflow:hidden;display:inline-flex;gap:6px;align-items:center;padding:0 9px;border-radius:999px;background:var(--accfill);color:var(--pillink);font-weight:800;box-shadow:0 0 14px -4px color-mix(in srgb,var(--accfill) 80%,transparent)}\n.sweep{position:absolute;inset:0;background:linear-gradient(100deg,transparent 30%,rgba(255,255,255,.7) 50%,transparent 70%);transform:translateX(-120%);animation:sweep 3.2s ease-in-out infinite;pointer-events:none}\n@keyframes sweep{0%,55%{transform:translateX(-120%)}85%,100%{transform:translateX(120%)}}\n.is-done .sweep,.is-idle .sweep{display:none}\n.row{display:flex;align-items:center;gap:8px;white-space:nowrap;min-height:20px}\n.tl{display:inline-flex;align-items:center;gap:6px;overflow:hidden;min-width:0}\n.nx{overflow:hidden;text-overflow:ellipsis}\n.bar{display:inline-flex;gap:2px;vertical-align:middle}.seg{display:inline-block;width:6px;height:10px;border-radius:1.5px}.seg.off{background:var(--faint)}\n.live{display:inline-flex;align-items:center;gap:6px;flex:0 0 auto}.row .tl+.live{margin-left:auto}\n.live .tool{font-weight:700}.live .last{font-weight:600;overflow:hidden;text-overflow:ellipsis}.live.done{color:var(--green);font-weight:700}\n.spin{color:var(--acc);animation:spin 1s linear infinite;flex:0 0 auto}@keyframes spin{to{transform:rotate(360deg)}}\n.spin.soft{color:var(--dim)}\nkbd{font-size:12px;color:var(--acc);background:color-mix(in srgb,var(--acc) 12%,transparent);border:1px solid color-mix(in srgb,var(--acc) 32%,transparent);border-radius:6px;padding:0 6px}\n.foot{display:flex;align-items:center;gap:12px;margin-top:7px;padding-top:7px;border-top:1px solid color-mix(in srgb,var(--faint) 75%,transparent);font-size:11.5px;color:var(--dim);white-space:nowrap;overflow:hidden}\n.use{display:inline-flex;align-items:center;gap:5px}.use b{font-weight:600;color:var(--ink)}\n.mini{display:inline-flex;gap:1.5px}.mini i{display:inline-block;width:4px;height:8px;border-radius:1px;background:var(--faint)}\n.ws{margin-left:auto;overflow:hidden;text-overflow:ellipsis}\n/* the side pane (the host's fullscreen mode): a vertical timeline, the use bars at the bottom */\n:root.pane .lc{min-height:calc(100vh - 2px);display:flex;flex-direction:column;padding:18px 20px 16px;font-size:13px}\n:root.pane .brand{font-size:13.5px;padding:2px 11px 2px 9px}:root.pane .name{font-size:13.5px}\n.tline{margin:18px 0 6px}\n.stg{position:relative;padding:0 0 12px 24px}\n.stg::before{content:\"\";position:absolute;left:4px;top:0;bottom:0;width:2px;background:var(--line,var(--rail))}\n.stg:first-child::before{top:9px}.stg:last-child::before{bottom:auto;height:9px}.stg:last-child{padding-bottom:0}\n.stg .pt{position:absolute;left:0;top:4px;width:10px;height:10px;border-radius:50%;border:2px solid var(--rail);background:var(--bg)}\n.stg.done .pt{border-color:var(--c);background:var(--c)}\n.stg.cur .pt{border-color:var(--acc);background:var(--bg);box-shadow:0 0 0 3px color-mix(in srgb,var(--acc) 25%,transparent),0 0 10px var(--acc)}\n.stg .line1{display:flex;align-items:center;gap:8px;min-height:18px}\n.stg .w{font-weight:600}.stg.todo .w{color:var(--dim);font-weight:500}\n.stg .meta{margin-left:auto;color:var(--dim);font-size:12px}\n.detail{margin-top:8px;padding:8px 11px;border-radius:10px;border:1px solid color-mix(in srgb,var(--faint) 85%,transparent);background:color-mix(in srgb,var(--bg2) 60%,transparent);display:flex;flex-direction:column;gap:3px}\n.banner{display:flex;align-items:center;gap:8px;margin:14px 0 0;padding:7px 11px;border-radius:10px;color:var(--green);font-weight:700;background:color-mix(in srgb,var(--green) 11%,transparent);border:1px solid color-mix(in srgb,var(--green) 32%,transparent)}\n.banner .dim{font-weight:500}\n.usage{margin-top:auto;padding-top:14px;border-top:1px solid color-mix(in srgb,var(--faint) 75%,transparent);display:flex;flex-direction:column;gap:6px;font-size:12px;color:var(--dim)}\n.ub{display:grid;grid-template-columns:3.2em 1fr 3.4em;align-items:center;gap:10px}.ub .pct{text-align:right;color:var(--ink);font-weight:600}\n.track{height:5px;border-radius:3px;background:var(--faint);overflow:hidden}.track i{display:block;height:100%;border-radius:3px}\n.hero{text-align:center;padding:36px 0 10px}.flame{font-size:40px;filter:drop-shadow(0 0 16px rgba(255,99,55,.45))}\n.herot{font-weight:700;font-size:15px;margin-top:8px}.heros{color:var(--dim);margin:6px 0 14px}\n.examples{display:flex;flex-direction:column;align-items:center;gap:6px}\n@media (prefers-reduced-motion:reduce){.lc,.lc *{animation:none!important}.sweep,.comet{display:none}}\n</style></head>\n<body><div id=\"card\" class=\"lc is-idle\" role=\"status\" aria-live=\"polite\"><div class=\"head\"><span class=\"brand\">\uD83D\uDD25 LIT</span><span class=\"j\">\u00B7</span><span class=\"name dim\">starting\u2026</span></div></div>\n<script>\n(function(){\nvar STATUS_TOOL=\"lit_card_status\";\nvar FAST=1500,SLOW=5000,IDLE=15000,MAX_BACKOFF=30000;\nvar root=document.documentElement,card=document.getElementById(\"card\");\nvar status=null,thread=null,timer=null,ticker=null,failures=0,idleSince=Date.now(),bridge=null,hostMode=null;\nvar nextId=1,pending={};\n\nfunction el(tag,cls,text){var n=document.createElement(tag);if(cls)n.className=cls;if(text!=null)n.textContent=String(text);return n;}\nfunction add(parent){for(var i=1;i<arguments.length;i++){var c=arguments[i];if(c!=null)parent.appendChild(typeof c===\"string\"?document.createTextNode(c):c);}return parent;}\nfunction joiner(){return el(\"span\",\"j\",\"\u00B7\");}\n\n/* linear-RGB mixing, so the flame \u2192 pink \u2192 accent ramp keeps its brightness */\nfunction hex(c){c=c.trim().replace(\"#\",\"\");return[0,2,4].map(function(i){return parseInt(c.substr(i,2),16)/255;});}\nfunction lin(v){return v<=0.04045?v/12.92:Math.pow((v+0.055)/1.055,2.4);}\nfunction gam(v){return v<=0.0031308?v*12.92:1.055*Math.pow(v,1/2.4)-0.055;}\nfunction mix(a,b,t){var x=hex(a),y=hex(b);return\"#\"+x.map(function(v,i){var m=gam(lin(v)+(lin(y[i])-lin(v))*t);return(\"0\"+Math.round(Math.max(0,Math.min(1,m))*255).toString(16)).slice(-2);}).join(\"\");}\nfunction token(name){return getComputedStyle(root).getPropertyValue(name)||\"#ffffff\";}\nfunction ramp(t){var f=token(\"--flame\"),p=token(\"--pink\"),a=token(\"--acc\");return t<=0.5?mix(f,p,t*2):mix(p,a,(t-0.5)*2);}\n\nfunction clock(ms){var s=Math.max(0,Math.floor(ms/1000));return Math.floor(s/60)+\":\"+(\"0\"+(s%60)).slice(-2);}\nfunction span(ms){var s=Math.max(1,Math.round(ms/1000));if(s<60)return s+\"s\";var m=Math.floor(s/60);if(m<60)return s%60?m+\"m \"+(s%60)+\"s\":m+\"m\";return Math.floor(m/60)+\"h \"+(m%60)+\"m\";}\nfunction since(t){var n=el(\"span\",\"dim el\",\"\u00B7 \"+clock(Date.now()-t));n.setAttribute(\"data-since\",String(t));return n;}\nfunction pane(){var m=(window.openai&&window.openai.displayMode)||hostMode;return m===\"fullscreen\"||m===\"pip\";}\n\nfunction bar(done,total){\n var cells=Math.min(total,10),filled=total===0?0:Math.round(done/total*cells);\n if(done>0&&filled===0)filled=1;if(done<total&&filled===cells)filled=cells-1;\n var b=el(\"span\",\"bar\");\n for(var i=0;i<cells;i++){var s=el(\"i\",\"seg\"+(i<filled?\"\":\" off\"));if(i<filled)s.style.background=mix(token(\"--pink\"),token(\"--acc\"),cells<=1?0:i/(cells-1));b.appendChild(s);}\n return b;\n}\nfunction useColor(p){return p>=90?token(\"--red\"):p>=70?token(\"--amber\"):null;}\nfunction mini(p){var b=el(\"span\",\"mini\"),on=Math.round(p/10),warn=useColor(p);for(var i=0;i<10;i++){var c=el(\"i\");if(i<on)c.style.background=warn||mix(token(\"--pink\"),token(\"--acc\"),i/9);b.appendChild(c);}return b;}\nfunction spinner(soft){\n var ns=\"http://www.w3.org/2000/svg\",svg=document.createElementNS(ns,\"svg\");\n svg.setAttribute(\"class\",\"spin\"+(soft?\" soft\":\"\"));svg.setAttribute(\"viewBox\",\"0 0 16 16\");svg.setAttribute(\"width\",\"12\");svg.setAttribute(\"height\",\"12\");svg.setAttribute(\"aria-hidden\",\"true\");\n var c=document.createElementNS(ns,\"circle\");\n [[\"cx\",\"8\"],[\"cy\",\"8\"],[\"r\",\"5.6\"],[\"fill\",\"none\"],[\"stroke\",\"currentColor\"],[\"stroke-width\",\"2.2\"],[\"stroke-dasharray\",\"24 11.2\"],[\"stroke-linecap\",\"round\"]].forEach(function(a){c.setAttribute(a[0],a[1]);});\n svg.appendChild(c);return svg;\n}\nfunction currentCell(map){if(!map)return null;for(var i=0;i<map.cells.length;i++)if(map.cells[i].state===\"current\")return map.cells[i];return null;}\nfunction progressOf(map){if(!map)return null;for(var i=0;i<map.cells.length;i++)if(map.cells[i].progress)return map.cells[i].progress;return null;}\nfunction doneWord(s){return progressOf(s.map)?\"COMPLETE\":\"DONE\";}\nfunction took(s){if(s.turnEndedAt)return s.turnEndedAt-(s.turnStartedAt||s.ignitedAt||s.turnEndedAt);return (s.lastStepAt||s.now)-s.ignitedAt;}\n\n/* what LIT is doing now: the running tool, the turn's own time, or that it waits */\nfunction liveNode(s){\n var n=el(\"span\",\"live\");\n if(s.step){add(n,spinner(false),el(\"span\",\"tool\",s.step.tool),since(s.step.startedAt));return n;}\n if(s.state===\"complete\"){n.className=\"live done\";add(n,\"\u2713 \",el(\"span\",null,doneWord(s)===\"DONE\"?\"turn done\":\"all done\"));if(s.ignitedAt)add(n,el(\"span\",\"dim\",\"in \"+span(took(s))));return n;}\n if(s.state===\"ignited\"&&s.working){add(n,spinner(true),el(\"span\",\"dim\",\"thinking\"));if(s.turnStartedAt)n.appendChild(since(s.turnStartedAt));if(s.lastTool)add(n,el(\"span\",\"dim\",\"\u00B7 last\"),el(\"span\",\"acc\",\"\u25B8\"),el(\"span\",\"last\",s.lastTool));return n;}\n if(s.state===\"ignited\"){add(n,el(\"span\",\"dim\",\"\u25E6 waiting for you\"));return n;}\n return null;\n}\nfunction head(s){\n var h=el(\"div\",\"head\"),b=el(\"span\",\"brand\");add(b,el(\"span\",\"sweep\"),\"\uD83D\uDD25 LIT\");add(h,b,joiner());\n if(s.state===\"ready\"){add(h,el(\"span\",\"name dim\",\"ready\"),el(\"span\",\"right dim\",\"idle\"));return h;}\n add(h,el(\"span\",\"name acc\",s.mode||\"lit\"));\n if(s.state===\"complete\"){add(h,el(\"span\",\"right ok\",doneWord(s)+\" \u2713\"));return h;}\n var cur=currentCell(s.map),r=el(\"span\",\"right acc\",cur?(cur.label||cur.word.toUpperCase()):\"IGNITED\");if(s.working)r.appendChild(el(\"i\",\"dot\"));add(h,r);return h;\n}\nfunction pillExtra(c){var l=(c.label||\"\").toLowerCase(),w=c.word.toLowerCase();if(!l||l===w)return\"\";return l.indexOf(w+\" \")===0?l.slice(w.length+1):l;}\nfunction stageWord(c){var w=c.word;if(c.state===\"done\"&&c.label)w+=\" \"+c.label;else if(c.progress&&c.state!==\"current\")w+=\" \"+c.progress.done+\"/\"+c.progress.total;return w;}\nfunction mapRow(s){\n var m=el(\"div\",\"map\"),cells=s.map.cells,n=cells.length,lastColor=null;\n cells.forEach(function(c,i){\n var color=ramp(n<=1?0:i/(n-1)),cur=c.state===\"current\"&&s.state!==\"complete\";\n if(i>0){\n var r=el(\"span\",\"rail\");\n if((c.state===\"done\"||c.state===\"partial\")&&cells[i-1].state!==\"pending\")r.style.background=\"linear-gradient(90deg,\"+(lastColor||color)+\",\"+color+\")\";\n else if(cur){r.style.background=\"linear-gradient(90deg,\"+(lastColor||token(\"--acc\"))+\",\"+token(\"--acc\")+\")\";r.appendChild(el(\"i\",\"comet\"));}\n else if(cells[i-1].state===\"current\"&&s.state!==\"complete\"){r.className=\"rail lead\";r.appendChild(el(\"i\",\"headfill\"));}\n m.appendChild(r);\n }\n if(cur){\n var p=el(\"span\",\"st nowpill\");add(p,el(\"span\",\"sweep\"),c.word);var extra=pillExtra(c);if(extra)add(p,el(\"b\",null,extra));if(c.progress)add(p,el(\"b\",null,c.progress.done+\"/\"+c.progress.total));m.appendChild(p);lastColor=token(\"--acc\");\n }else if(c.state===\"pending\"){var t=el(\"span\",\"st todo\",c.word);t.appendChild(el(\"em\",null,\"\u00B7\"));m.appendChild(t);}\n else{var d=el(\"span\",\"st done\",stageWord(c));d.style.color=color;d.appendChild(el(\"em\",null,c.state===\"partial\"?\"\u2026\":\"\u2713\"));m.appendChild(d);lastColor=color;}\n });\n return m;\n}\n/* the task line: progress and next on the left, the live step on the right; just the live step otherwise */\nfunction taskRow(s){\n var row=el(\"div\",\"row\"),prog=progressOf(s.map),next=s.map&&s.map.next;\n if(prog||next){\n var left=el(\"span\",\"tl\");add(left,el(\"span\",\"dim\",\"\u2514\"));\n if(prog)add(left,el(\"span\",\"dim\",\"task\"),el(\"b\",null,prog.done+\"/\"+prog.total),bar(prog.done,prog.total));\n if(next){if(prog)left.appendChild(joiner());add(left,el(\"span\",\"dim\",\"next\"),el(\"span\",\"acc\",\"\u25B8\"),el(\"span\",\"nx\",next));}\n add(row,left,liveNode(s));return row;\n }\n add(row,el(\"span\",\"dim\",\"\u2514\"),liveNode(s));return row;\n}\nfunction useItems(s){\n var u=s.usage||{},items=[];\n [[\"ctx\",u.ctx],[\"5h\",u.fiveHour],[\"1w\",u.week]].forEach(function(x){if(typeof x[1]===\"number\")items.push(x);});\n return items;\n}\nfunction foot(s){\n var f=el(\"div\",\"foot\");\n useItems(s).forEach(function(x){var u=el(\"span\",\"use\");add(u,x[0],mini(x[1]),el(\"b\",null,x[1]+\"%\"));var w=useColor(x[1]);if(w)u.lastChild.style.color=w;f.appendChild(u);});\n if(s.branch){var g=el(\"span\",\"use\");add(g,\"git\",el(\"b\",null,s.branch));f.appendChild(g);}\n if(s.workspace)f.appendChild(el(\"span\",\"ws\",s.workspace));\n return f.childNodes.length?f:null;\n}\nfunction timeline(s){\n var t=el(\"div\",\"tline\"),cells=s.map.cells,n=cells.length;\n cells.forEach(function(c,i){\n var color=ramp(n<=1?0:i/(n-1)),cur=c.state===\"current\"&&s.state!==\"complete\",todo=c.state===\"pending\";\n var g=el(\"div\",\"stg \"+(cur?\"cur\":todo?\"todo\":\"done\"));g.style.setProperty(\"--c\",color);\n var nextCell=cells[i+1];if(!todo&&!cur&&nextCell&&nextCell.state!==\"pending\")g.style.setProperty(\"--line\",color);\n var l1=el(\"div\",\"line1\"),w;\n if(cur){w=el(\"span\",\"st nowpill\");add(w,el(\"span\",\"sweep\"),c.label||c.word.toUpperCase());}\n else{w=el(\"span\",\"w\",c.word);if(!todo)w.style.color=color;}\n var meta=el(\"span\",\"meta\");if(c.progress)meta.textContent=c.progress.done+\"/\"+c.progress.total;else if(!todo&&!cur)meta.textContent=c.label?c.label+\" \u2713\":\"\u2713\";\n add(l1,w,meta);add(g,el(\"span\",\"pt\"),l1);\n if(cur){\n var d=el(\"div\",\"detail\"),prog=c.progress;\n if(prog){var r1=el(\"div\",\"row\");add(r1,el(\"span\",\"dim\",\"tasks\"),el(\"b\",null,prog.done+\"/\"+prog.total),bar(prog.done,prog.total));d.appendChild(r1);}\n if(s.map.next){var r2=el(\"div\",\"row\");add(r2,el(\"span\",\"dim\",\"next\"),el(\"span\",\"acc\",\"\u25B8\"),el(\"span\",\"nx\",s.map.next));d.appendChild(r2);}\n var r3=el(\"div\",\"row\"),live=liveNode(s);if(live){r3.appendChild(live);d.appendChild(r3);}\n g.appendChild(d);\n }\n t.appendChild(g);\n });\n return t;\n}\nfunction usageBlock(s){\n var items=useItems(s);if(!items.length&&!s.branch&&!s.workspace)return null;\n var u=el(\"div\",\"usage\");\n items.forEach(function(x){var r=el(\"div\",\"ub\"),tr=el(\"span\",\"track\"),fill=el(\"i\"),w=useColor(x[1]);fill.style.width=x[1]+\"%\";fill.style.background=w||\"linear-gradient(90deg,\"+token(\"--pink\")+\",\"+token(\"--acc\")+\")\";tr.appendChild(fill);var pct=el(\"span\",\"pct\",x[1]+\"%\");if(w)pct.style.color=w;add(r,el(\"span\",null,x[0]),tr,pct);u.appendChild(r);});\n var g=el(\"div\",\"row\");if(s.branch)add(g,\"git\",el(\"b\",null,s.branch));if(s.workspace){if(s.branch)g.appendChild(joiner());g.appendChild(el(\"span\",null,s.workspace));}\n if(g.childNodes.length)u.appendChild(g);\n return u;\n}\nfunction renderInline(s){\n card.appendChild(head(s));\n if(s.state===\"ready\"){var hint=el(\"div\",\"row\");add(hint,el(\"span\",\"dim\",\"no LIT skill yet\"),joiner(),el(\"span\",\"dim\",\"type\"),el(\"kbd\",null,\"lit <task>\"),el(\"span\",\"dim\",\"to start one\"));hint.style.marginTop=\"6px\";card.appendChild(hint);return;}\n if(s.map)card.appendChild(mapRow(s));else card.appendChild(el(\"div\",\"map\"));\n card.appendChild(taskRow(s));\n var f=foot(s);if(f){card.appendChild(f);var ws=f.querySelector(\".ws\");if(ws&&ws.scrollWidth>ws.clientWidth+1)f.removeChild(ws);}\n}\nfunction renderPane(s){\n card.appendChild(head(s));\n if(s.state===\"ready\"){\n var hero=el(\"div\",\"hero\"),hs=el(\"div\",\"heros\");add(hs,\"type \",el(\"kbd\",null,\"lit <task>\"),\" in this thread to start one\");\n var ex=el(\"div\",\"examples\");[\"lit add a --shout flag\",\"lit plan the release note\",\"lit-loop fix the parser\"].forEach(function(t){ex.appendChild(el(\"kbd\",null,t));});\n add(hero,el(\"div\",\"flame\",\"\uD83D\uDD25\"),el(\"div\",\"herot\",\"no LIT skill yet\"),hs,ex);card.appendChild(hero);\n }else{\n if(s.state===\"complete\"){var prog=progressOf(s.map),bn=el(\"div\",\"banner\",doneWord(s)+\" \u2713\");if(prog)add(bn,el(\"span\",\"dim\",prog.done+\"/\"+prog.total+\" tasks\"));if(s.ignitedAt)add(bn,el(\"span\",\"dim\",\"\u00B7 \"+span(took(s))));card.appendChild(bn);}\n if(s.map)card.appendChild(timeline(s));else{var r=el(\"div\",\"row\");r.style.marginTop=\"14px\";add(r,liveNode(s));card.appendChild(r);}\n }\n var u=usageBlock(s);if(u)card.appendChild(u);\n}\nfunction render(){\n var s=status;if(!s)return;\n var p=pane();root.classList.toggle(\"pane\",p);\n card.className=\"lc\"+(s.state===\"complete\"?\" is-done\":s.state===\"ready\"?\" is-idle\":\"\");\n card.textContent=\"\";\n if(p)renderPane(s);else renderInline(s);\n reportSize();\n}\nfunction tick(){\n if(ticker){clearInterval(ticker);ticker=null;}\n if(document.hidden||!card.querySelector(\"[data-since]\"))return;\n ticker=setInterval(function(){var n=card.querySelectorAll(\"[data-since]\");for(var i=0;i<n.length;i++)n[i].textContent=\"\u00B7 \"+clock(Date.now()-Number(n[i].getAttribute(\"data-since\")));},1000);\n}\nfunction accept(s){\n if(!s||s.version!==1)return;\n status=s;if(s.thread)thread=s.thread;\n if(s.working)idleSince=Date.now();\n render();tick();\n}\n\n/* host bridge: window.openai when present, else MCP Apps JSON-RPC over postMessage */\nfunction rpc(method,params){return new Promise(function(resolve,reject){var id=nextId++;pending[id]={resolve:resolve,reject:reject};window.parent.postMessage({jsonrpc:\"2.0\",id:id,method:method,params:params},\"*\");setTimeout(function(){if(pending[id]){delete pending[id];reject(new Error(method+\" timed out\"));}},5000);});}\nwindow.addEventListener(\"message\",function(ev){\n var m=ev.data;if(ev.source!==window.parent||!m||m.jsonrpc!==\"2.0\")return;\n if(m.id!=null&&pending[m.id]){var p=pending[m.id];delete pending[m.id];if(m.error)p.reject(m.error);else p.resolve(m.result);return;}\n if(m.method===\"ui/notifications/tool-result\"&&m.params)accept(m.params.structuredContent);\n if(m.method===\"ui/notifications/host-context-changed\"&&m.params){if(m.params.displayMode)hostMode=m.params.displayMode;applyTheme(m.params.theme||null);}\n});\nwindow.addEventListener(\"openai:set_globals\",function(){if(window.openai){applyTheme(window.openai.theme);if(window.openai.toolOutput&&!status)accept(window.openai.toolOutput);else render();}});\nfunction callStatus(){\n var args=thread?{thread_id:thread}:{};\n if(bridge===\"openai\")return window.openai.callTool(STATUS_TOOL,args).then(function(r){return r&&(r.structuredContent||r.result&&r.result.structuredContent);});\n return rpc(\"tools/call\",{name:STATUS_TOOL,arguments:args}).then(function(r){return r&&r.structuredContent;});\n}\nvar lastHeight=0;\nfunction reportSize(){\n if(pane())return;\n var h=Math.ceil(card.getBoundingClientRect().height)+2;if(h===lastHeight)return;lastHeight=h;\n if(bridge===\"openai\"&&typeof window.openai.notifyIntrinsicHeight===\"function\"){try{window.openai.notifyIntrinsicHeight(h);}catch(e){}}\n else if(bridge===\"mcp\")window.parent.postMessage({jsonrpc:\"2.0\",method:\"ui/notifications/size-changed\",params:{height:h}},\"*\");\n}\nfunction applyTheme(theme){\n var dark=theme?theme===\"dark\":!(window.matchMedia&&window.matchMedia(\"(prefers-color-scheme: light)\").matches);\n root.classList.toggle(\"light\",!dark);if(status)render();\n}\n\nfunction delay(){\n if(failures>0)return Math.min(MAX_BACKOFF,FAST*Math.pow(2,failures));\n if(status&&status.working)return FAST;\n return Date.now()-idleSince>120000?IDLE:SLOW;\n}\nfunction schedule(){if(timer)clearTimeout(timer);timer=null;if(!document.hidden)timer=setTimeout(poll,delay());}\nfunction poll(){\n callStatus().then(function(s){failures=0;accept(s);},function(){failures=Math.min(failures+1,5);}).then(schedule);\n}\ndocument.addEventListener(\"visibilitychange\",function(){if(document.hidden){if(timer)clearTimeout(timer);timer=null;tick();}else{idleSince=Date.now();tick();poll();}});\nwindow.addEventListener(\"resize\",function(){if(status)render();});\n\nfunction start(){\n if(window.openai&&typeof window.openai.callTool===\"function\"){\n bridge=\"openai\";applyTheme(window.openai.theme);if(window.openai.toolOutput)accept(window.openai.toolOutput);poll();return;\n }\n bridge=\"mcp\";applyTheme(null);\n rpc(\"ui/initialize\",{protocolVersion:\"2026-01-26\",appInfo:{name:\"lit-card\",version:\"1\"},appCapabilities:{availableDisplayModes:[\"inline\",\"fullscreen\"]}}).then(function(r){\n window.parent.postMessage({jsonrpc:\"2.0\",method:\"ui/notifications/initialized\",params:{}},\"*\");\n var ctx=r&&r.hostContext;if(ctx&&ctx.displayMode)hostMode=ctx.displayMode;applyTheme(ctx&&ctx.theme||null);poll();\n },function(){poll();});\n}\nif(window.matchMedia)window.matchMedia(\"(prefers-color-scheme: light)\").addEventListener(\"change\",function(){if(!(window.openai&&window.openai.theme))applyTheme(null);});\nstart();\n})();\n</script></body></html>\n";
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
// src/card-html.ts โ the LIT card: one self-contained HTML page for the Codex desktop app (MCP App).
|
|
2
|
+
//
|
|
3
|
+
// Inline CSS and script only; no network, fonts or images. It draws the status from `lit_card_status`
|
|
4
|
+
// (activation, workflow map, live step, context and quota use) in the LIT look: the pink-to-flame LIT
|
|
5
|
+
// pill, lowercase stage words with โ or ยท, rails that run flame โ pink โ accent, the current stage as
|
|
6
|
+
// an accent pill with dark ink, and the running tool with its time.
|
|
7
|
+
//
|
|
8
|
+
// The host reports how it shows the card. Inline (in the thread) gets the compact card and tells the
|
|
9
|
+
// host its height through `notifyIntrinsicHeight`, because the host sizes inline frames from that; the
|
|
10
|
+
// side pane arrives as `fullscreen` and gets a vertical timeline with the use bars at the bottom. The
|
|
11
|
+
// card drew in a proportional face inside the app, so it pins its monospace face. Light and dark follow the
|
|
12
|
+
// host theme. It polls every 1.5 s while visible and working, slows down when idle and stops while
|
|
13
|
+
// hidden. It talks to the host through `window.openai` when present, else MCP Apps postMessage JSON-RPC.
|
|
14
|
+
export const CARD_HTML = `<!doctype html>
|
|
15
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
16
|
+
<title>LIT</title>
|
|
17
|
+
<style>
|
|
18
|
+
:root{color-scheme:dark;--bg:#10141c;--bg2:#0d1118;--ink:#e6edf3;--dim:#7d8590;--faint:#30363d;--rail:#3a434e;--flame:#ff6337;--pink:#ff2d95;--acc:#5fd7ff;--accfill:#5fd7ff;--green:#6bdb8f;--amber:#ffaf3c;--red:#ff5f5f;--pillink:#0b0f14;
|
|
19
|
+
--mono:"SF Mono",SFMono-Regular,ui-monospace,Menlo,Monaco,Consolas,"Liberation Mono",monospace}
|
|
20
|
+
:root.light{color-scheme:light;--bg:#ffffff;--bg2:#fafbfd;--ink:#1b1f27;--dim:#69717e;--faint:#dde2e8;--rail:#cfd6de;--flame:#e2521f;--pink:#d81b78;--acc:#0a87b8;--green:#1f9d55;--amber:#b86e00;--red:#d93a3a}
|
|
21
|
+
*{box-sizing:border-box}
|
|
22
|
+
html,body{margin:0;background:transparent}
|
|
23
|
+
body{color:var(--ink);font-size:12.5px;line-height:1.55;font-weight:500;-webkit-font-smoothing:antialiased}
|
|
24
|
+
.lc,.lc *{font-family:var(--mono)!important}
|
|
25
|
+
.lc{position:relative;border-radius:14px;padding:11px 14px 10px;margin:1px;
|
|
26
|
+
background:radial-gradient(110% 120% at 0% 0%,color-mix(in srgb,var(--pink) 8%,transparent),transparent 55%),radial-gradient(80% 110% at 100% 0%,color-mix(in srgb,var(--acc) 6%,transparent),transparent 60%),linear-gradient(180deg,var(--bg),var(--bg2));
|
|
27
|
+
border:1px solid color-mix(in srgb,var(--acc) 55%,transparent);box-shadow:0 0 0 1px color-mix(in srgb,var(--acc) 8%,transparent),0 10px 30px -18px color-mix(in srgb,var(--acc) 50%,transparent);animation:breathe 4.8s ease-in-out infinite}
|
|
28
|
+
.lc.is-done{border-color:color-mix(in srgb,var(--green) 55%,transparent);box-shadow:0 0 0 1px color-mix(in srgb,var(--green) 8%,transparent);animation:none}
|
|
29
|
+
.lc.is-idle{border-color:color-mix(in srgb,var(--dim) 40%,transparent);box-shadow:none;animation:none}
|
|
30
|
+
@keyframes breathe{0%,100%{border-color:color-mix(in srgb,var(--acc) 38%,transparent)}50%{border-color:color-mix(in srgb,var(--acc) 80%,transparent)}}
|
|
31
|
+
.head{display:flex;align-items:center;gap:7px;white-space:nowrap;min-height:22px}
|
|
32
|
+
.brand{position:relative;overflow:hidden;display:inline-flex;align-items:center;gap:3px;padding:1px 9px 1px 7px;border-radius:999px;background:linear-gradient(90deg,#ff2d95,#ff6337);color:#0b0f14;font-weight:800;letter-spacing:.03em;box-shadow:0 0 16px -6px rgba(255,45,149,.6)}
|
|
33
|
+
.j{color:var(--faint)}
|
|
34
|
+
.name{font-weight:700;overflow:hidden;text-overflow:ellipsis}.acc{color:var(--acc)}.dim{color:var(--dim)}.ok{color:var(--green)}
|
|
35
|
+
.right{margin-left:auto;font-weight:700;letter-spacing:.04em;display:inline-flex;align-items:center;gap:6px}
|
|
36
|
+
.dot{width:6px;height:6px;border-radius:50%;background:var(--acc);box-shadow:0 0 7px var(--acc);animation:pulse 1.6s ease-in-out infinite}
|
|
37
|
+
@keyframes pulse{50%{opacity:.35}}
|
|
38
|
+
.map{display:flex;align-items:center;gap:7px;margin:9px 0 6px;white-space:nowrap;overflow:hidden}
|
|
39
|
+
.st em{font-style:normal;margin-left:3px}.st.todo{color:var(--dim)}.st.done{font-weight:600}
|
|
40
|
+
.rail{position:relative;display:inline-block;height:2px;border-radius:2px;flex:1 1 12px;max-width:56px;min-width:10px;background:var(--rail)}
|
|
41
|
+
.rail.lead{overflow:hidden}.headfill{position:absolute;inset:0;width:40%;background:linear-gradient(90deg,var(--acc),transparent)}
|
|
42
|
+
.comet{position:absolute;top:50%;width:5px;height:5px;margin-top:-2.5px;border-radius:50%;background:#fff;box-shadow:0 0 7px 2px var(--acc);animation:comet 2.4s linear infinite}
|
|
43
|
+
:root.light .comet{background:var(--accfill);box-shadow:0 0 5px 1px var(--accfill)}
|
|
44
|
+
@keyframes comet{0%{left:-8%;opacity:0}15%,85%{opacity:1}100%{left:100%;opacity:0}}
|
|
45
|
+
.nowpill{position:relative;overflow:hidden;display:inline-flex;gap:6px;align-items:center;padding:0 9px;border-radius:999px;background:var(--accfill);color:var(--pillink);font-weight:800;box-shadow:0 0 14px -4px color-mix(in srgb,var(--accfill) 80%,transparent)}
|
|
46
|
+
.sweep{position:absolute;inset:0;background:linear-gradient(100deg,transparent 30%,rgba(255,255,255,.7) 50%,transparent 70%);transform:translateX(-120%);animation:sweep 3.2s ease-in-out infinite;pointer-events:none}
|
|
47
|
+
@keyframes sweep{0%,55%{transform:translateX(-120%)}85%,100%{transform:translateX(120%)}}
|
|
48
|
+
.is-done .sweep,.is-idle .sweep{display:none}
|
|
49
|
+
.row{display:flex;align-items:center;gap:8px;white-space:nowrap;min-height:20px}
|
|
50
|
+
.tl{display:inline-flex;align-items:center;gap:6px;overflow:hidden;min-width:0}
|
|
51
|
+
.nx{overflow:hidden;text-overflow:ellipsis}
|
|
52
|
+
.bar{display:inline-flex;gap:2px;vertical-align:middle}.seg{display:inline-block;width:6px;height:10px;border-radius:1.5px}.seg.off{background:var(--faint)}
|
|
53
|
+
.live{display:inline-flex;align-items:center;gap:6px;flex:0 0 auto}.row .tl+.live{margin-left:auto}
|
|
54
|
+
.live .tool{font-weight:700}.live .last{font-weight:600;overflow:hidden;text-overflow:ellipsis}.live.done{color:var(--green);font-weight:700}
|
|
55
|
+
.spin{color:var(--acc);animation:spin 1s linear infinite;flex:0 0 auto}@keyframes spin{to{transform:rotate(360deg)}}
|
|
56
|
+
.spin.soft{color:var(--dim)}
|
|
57
|
+
kbd{font-size:12px;color:var(--acc);background:color-mix(in srgb,var(--acc) 12%,transparent);border:1px solid color-mix(in srgb,var(--acc) 32%,transparent);border-radius:6px;padding:0 6px}
|
|
58
|
+
.foot{display:flex;align-items:center;gap:12px;margin-top:7px;padding-top:7px;border-top:1px solid color-mix(in srgb,var(--faint) 75%,transparent);font-size:11.5px;color:var(--dim);white-space:nowrap;overflow:hidden}
|
|
59
|
+
.use{display:inline-flex;align-items:center;gap:5px}.use b{font-weight:600;color:var(--ink)}
|
|
60
|
+
.mini{display:inline-flex;gap:1.5px}.mini i{display:inline-block;width:4px;height:8px;border-radius:1px;background:var(--faint)}
|
|
61
|
+
.ws{margin-left:auto;overflow:hidden;text-overflow:ellipsis}
|
|
62
|
+
/* the side pane (the host's fullscreen mode): a vertical timeline, the use bars at the bottom */
|
|
63
|
+
:root.pane .lc{min-height:calc(100vh - 2px);display:flex;flex-direction:column;padding:18px 20px 16px;font-size:13px}
|
|
64
|
+
:root.pane .brand{font-size:13.5px;padding:2px 11px 2px 9px}:root.pane .name{font-size:13.5px}
|
|
65
|
+
.tline{margin:18px 0 6px}
|
|
66
|
+
.stg{position:relative;padding:0 0 12px 24px}
|
|
67
|
+
.stg::before{content:"";position:absolute;left:4px;top:0;bottom:0;width:2px;background:var(--line,var(--rail))}
|
|
68
|
+
.stg:first-child::before{top:9px}.stg:last-child::before{bottom:auto;height:9px}.stg:last-child{padding-bottom:0}
|
|
69
|
+
.stg .pt{position:absolute;left:0;top:4px;width:10px;height:10px;border-radius:50%;border:2px solid var(--rail);background:var(--bg)}
|
|
70
|
+
.stg.done .pt{border-color:var(--c);background:var(--c)}
|
|
71
|
+
.stg.cur .pt{border-color:var(--acc);background:var(--bg);box-shadow:0 0 0 3px color-mix(in srgb,var(--acc) 25%,transparent),0 0 10px var(--acc)}
|
|
72
|
+
.stg .line1{display:flex;align-items:center;gap:8px;min-height:18px}
|
|
73
|
+
.stg .w{font-weight:600}.stg.todo .w{color:var(--dim);font-weight:500}
|
|
74
|
+
.stg .meta{margin-left:auto;color:var(--dim);font-size:12px}
|
|
75
|
+
.detail{margin-top:8px;padding:8px 11px;border-radius:10px;border:1px solid color-mix(in srgb,var(--faint) 85%,transparent);background:color-mix(in srgb,var(--bg2) 60%,transparent);display:flex;flex-direction:column;gap:3px}
|
|
76
|
+
.banner{display:flex;align-items:center;gap:8px;margin:14px 0 0;padding:7px 11px;border-radius:10px;color:var(--green);font-weight:700;background:color-mix(in srgb,var(--green) 11%,transparent);border:1px solid color-mix(in srgb,var(--green) 32%,transparent)}
|
|
77
|
+
.banner .dim{font-weight:500}
|
|
78
|
+
.usage{margin-top:auto;padding-top:14px;border-top:1px solid color-mix(in srgb,var(--faint) 75%,transparent);display:flex;flex-direction:column;gap:6px;font-size:12px;color:var(--dim)}
|
|
79
|
+
.ub{display:grid;grid-template-columns:3.2em 1fr 3.4em;align-items:center;gap:10px}.ub .pct{text-align:right;color:var(--ink);font-weight:600}
|
|
80
|
+
.track{height:5px;border-radius:3px;background:var(--faint);overflow:hidden}.track i{display:block;height:100%;border-radius:3px}
|
|
81
|
+
.hero{text-align:center;padding:36px 0 10px}.flame{font-size:40px;filter:drop-shadow(0 0 16px rgba(255,99,55,.45))}
|
|
82
|
+
.herot{font-weight:700;font-size:15px;margin-top:8px}.heros{color:var(--dim);margin:6px 0 14px}
|
|
83
|
+
.examples{display:flex;flex-direction:column;align-items:center;gap:6px}
|
|
84
|
+
@media (prefers-reduced-motion:reduce){.lc,.lc *{animation:none!important}.sweep,.comet{display:none}}
|
|
85
|
+
</style></head>
|
|
86
|
+
<body><div id="card" class="lc is-idle" role="status" aria-live="polite"><div class="head"><span class="brand">๐ฅ LIT</span><span class="j">ยท</span><span class="name dim">startingโฆ</span></div></div>
|
|
87
|
+
<script>
|
|
88
|
+
(function(){
|
|
89
|
+
var STATUS_TOOL="lit_card_status";
|
|
90
|
+
var FAST=1500,SLOW=5000,IDLE=15000,MAX_BACKOFF=30000;
|
|
91
|
+
var root=document.documentElement,card=document.getElementById("card");
|
|
92
|
+
var status=null,thread=null,timer=null,ticker=null,failures=0,idleSince=Date.now(),bridge=null,hostMode=null;
|
|
93
|
+
var nextId=1,pending={};
|
|
94
|
+
|
|
95
|
+
function el(tag,cls,text){var n=document.createElement(tag);if(cls)n.className=cls;if(text!=null)n.textContent=String(text);return n;}
|
|
96
|
+
function add(parent){for(var i=1;i<arguments.length;i++){var c=arguments[i];if(c!=null)parent.appendChild(typeof c==="string"?document.createTextNode(c):c);}return parent;}
|
|
97
|
+
function joiner(){return el("span","j","ยท");}
|
|
98
|
+
|
|
99
|
+
/* linear-RGB mixing, so the flame โ pink โ accent ramp keeps its brightness */
|
|
100
|
+
function hex(c){c=c.trim().replace("#","");return[0,2,4].map(function(i){return parseInt(c.substr(i,2),16)/255;});}
|
|
101
|
+
function lin(v){return v<=0.04045?v/12.92:Math.pow((v+0.055)/1.055,2.4);}
|
|
102
|
+
function gam(v){return v<=0.0031308?v*12.92:1.055*Math.pow(v,1/2.4)-0.055;}
|
|
103
|
+
function mix(a,b,t){var x=hex(a),y=hex(b);return"#"+x.map(function(v,i){var m=gam(lin(v)+(lin(y[i])-lin(v))*t);return("0"+Math.round(Math.max(0,Math.min(1,m))*255).toString(16)).slice(-2);}).join("");}
|
|
104
|
+
function token(name){return getComputedStyle(root).getPropertyValue(name)||"#ffffff";}
|
|
105
|
+
function ramp(t){var f=token("--flame"),p=token("--pink"),a=token("--acc");return t<=0.5?mix(f,p,t*2):mix(p,a,(t-0.5)*2);}
|
|
106
|
+
|
|
107
|
+
function clock(ms){var s=Math.max(0,Math.floor(ms/1000));return Math.floor(s/60)+":"+("0"+(s%60)).slice(-2);}
|
|
108
|
+
function span(ms){var s=Math.max(1,Math.round(ms/1000));if(s<60)return s+"s";var m=Math.floor(s/60);if(m<60)return s%60?m+"m "+(s%60)+"s":m+"m";return Math.floor(m/60)+"h "+(m%60)+"m";}
|
|
109
|
+
function since(t){var n=el("span","dim el","ยท "+clock(Date.now()-t));n.setAttribute("data-since",String(t));return n;}
|
|
110
|
+
function pane(){var m=(window.openai&&window.openai.displayMode)||hostMode;return m==="fullscreen"||m==="pip";}
|
|
111
|
+
|
|
112
|
+
function bar(done,total){
|
|
113
|
+
var cells=Math.min(total,10),filled=total===0?0:Math.round(done/total*cells);
|
|
114
|
+
if(done>0&&filled===0)filled=1;if(done<total&&filled===cells)filled=cells-1;
|
|
115
|
+
var b=el("span","bar");
|
|
116
|
+
for(var i=0;i<cells;i++){var s=el("i","seg"+(i<filled?"":" off"));if(i<filled)s.style.background=mix(token("--pink"),token("--acc"),cells<=1?0:i/(cells-1));b.appendChild(s);}
|
|
117
|
+
return b;
|
|
118
|
+
}
|
|
119
|
+
function useColor(p){return p>=90?token("--red"):p>=70?token("--amber"):null;}
|
|
120
|
+
function mini(p){var b=el("span","mini"),on=Math.round(p/10),warn=useColor(p);for(var i=0;i<10;i++){var c=el("i");if(i<on)c.style.background=warn||mix(token("--pink"),token("--acc"),i/9);b.appendChild(c);}return b;}
|
|
121
|
+
function spinner(soft){
|
|
122
|
+
var ns="http://www.w3.org/2000/svg",svg=document.createElementNS(ns,"svg");
|
|
123
|
+
svg.setAttribute("class","spin"+(soft?" soft":""));svg.setAttribute("viewBox","0 0 16 16");svg.setAttribute("width","12");svg.setAttribute("height","12");svg.setAttribute("aria-hidden","true");
|
|
124
|
+
var c=document.createElementNS(ns,"circle");
|
|
125
|
+
[["cx","8"],["cy","8"],["r","5.6"],["fill","none"],["stroke","currentColor"],["stroke-width","2.2"],["stroke-dasharray","24 11.2"],["stroke-linecap","round"]].forEach(function(a){c.setAttribute(a[0],a[1]);});
|
|
126
|
+
svg.appendChild(c);return svg;
|
|
127
|
+
}
|
|
128
|
+
function currentCell(map){if(!map)return null;for(var i=0;i<map.cells.length;i++)if(map.cells[i].state==="current")return map.cells[i];return null;}
|
|
129
|
+
function progressOf(map){if(!map)return null;for(var i=0;i<map.cells.length;i++)if(map.cells[i].progress)return map.cells[i].progress;return null;}
|
|
130
|
+
function doneWord(s){return progressOf(s.map)?"COMPLETE":"DONE";}
|
|
131
|
+
function took(s){if(s.turnEndedAt)return s.turnEndedAt-(s.turnStartedAt||s.ignitedAt||s.turnEndedAt);return (s.lastStepAt||s.now)-s.ignitedAt;}
|
|
132
|
+
|
|
133
|
+
/* what LIT is doing now: the running tool, the turn's own time, or that it waits */
|
|
134
|
+
function liveNode(s){
|
|
135
|
+
var n=el("span","live");
|
|
136
|
+
if(s.step){add(n,spinner(false),el("span","tool",s.step.tool),since(s.step.startedAt));return n;}
|
|
137
|
+
if(s.state==="complete"){n.className="live done";add(n,"โ ",el("span",null,doneWord(s)==="DONE"?"turn done":"all done"));if(s.ignitedAt)add(n,el("span","dim","in "+span(took(s))));return n;}
|
|
138
|
+
if(s.state==="ignited"&&s.working){add(n,spinner(true),el("span","dim","thinking"));if(s.turnStartedAt)n.appendChild(since(s.turnStartedAt));if(s.lastTool)add(n,el("span","dim","ยท last"),el("span","acc","โธ"),el("span","last",s.lastTool));return n;}
|
|
139
|
+
if(s.state==="ignited"){add(n,el("span","dim","โฆ waiting for you"));return n;}
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
function head(s){
|
|
143
|
+
var h=el("div","head"),b=el("span","brand");add(b,el("span","sweep"),"๐ฅ LIT");add(h,b,joiner());
|
|
144
|
+
if(s.state==="ready"){add(h,el("span","name dim","ready"),el("span","right dim","idle"));return h;}
|
|
145
|
+
add(h,el("span","name acc",s.mode||"lit"));
|
|
146
|
+
if(s.state==="complete"){add(h,el("span","right ok",doneWord(s)+" โ"));return h;}
|
|
147
|
+
var cur=currentCell(s.map),r=el("span","right acc",cur?(cur.label||cur.word.toUpperCase()):"IGNITED");if(s.working)r.appendChild(el("i","dot"));add(h,r);return h;
|
|
148
|
+
}
|
|
149
|
+
function pillExtra(c){var l=(c.label||"").toLowerCase(),w=c.word.toLowerCase();if(!l||l===w)return"";return l.indexOf(w+" ")===0?l.slice(w.length+1):l;}
|
|
150
|
+
function stageWord(c){var w=c.word;if(c.state==="done"&&c.label)w+=" "+c.label;else if(c.progress&&c.state!=="current")w+=" "+c.progress.done+"/"+c.progress.total;return w;}
|
|
151
|
+
function mapRow(s){
|
|
152
|
+
var m=el("div","map"),cells=s.map.cells,n=cells.length,lastColor=null;
|
|
153
|
+
cells.forEach(function(c,i){
|
|
154
|
+
var color=ramp(n<=1?0:i/(n-1)),cur=c.state==="current"&&s.state!=="complete";
|
|
155
|
+
if(i>0){
|
|
156
|
+
var r=el("span","rail");
|
|
157
|
+
if((c.state==="done"||c.state==="partial")&&cells[i-1].state!=="pending")r.style.background="linear-gradient(90deg,"+(lastColor||color)+","+color+")";
|
|
158
|
+
else if(cur){r.style.background="linear-gradient(90deg,"+(lastColor||token("--acc"))+","+token("--acc")+")";r.appendChild(el("i","comet"));}
|
|
159
|
+
else if(cells[i-1].state==="current"&&s.state!=="complete"){r.className="rail lead";r.appendChild(el("i","headfill"));}
|
|
160
|
+
m.appendChild(r);
|
|
161
|
+
}
|
|
162
|
+
if(cur){
|
|
163
|
+
var p=el("span","st nowpill");add(p,el("span","sweep"),c.word);var extra=pillExtra(c);if(extra)add(p,el("b",null,extra));if(c.progress)add(p,el("b",null,c.progress.done+"/"+c.progress.total));m.appendChild(p);lastColor=token("--acc");
|
|
164
|
+
}else if(c.state==="pending"){var t=el("span","st todo",c.word);t.appendChild(el("em",null,"ยท"));m.appendChild(t);}
|
|
165
|
+
else{var d=el("span","st done",stageWord(c));d.style.color=color;d.appendChild(el("em",null,c.state==="partial"?"โฆ":"โ"));m.appendChild(d);lastColor=color;}
|
|
166
|
+
});
|
|
167
|
+
return m;
|
|
168
|
+
}
|
|
169
|
+
/* the task line: progress and next on the left, the live step on the right; just the live step otherwise */
|
|
170
|
+
function taskRow(s){
|
|
171
|
+
var row=el("div","row"),prog=progressOf(s.map),next=s.map&&s.map.next;
|
|
172
|
+
if(prog||next){
|
|
173
|
+
var left=el("span","tl");add(left,el("span","dim","โ"));
|
|
174
|
+
if(prog)add(left,el("span","dim","task"),el("b",null,prog.done+"/"+prog.total),bar(prog.done,prog.total));
|
|
175
|
+
if(next){if(prog)left.appendChild(joiner());add(left,el("span","dim","next"),el("span","acc","โธ"),el("span","nx",next));}
|
|
176
|
+
add(row,left,liveNode(s));return row;
|
|
177
|
+
}
|
|
178
|
+
add(row,el("span","dim","โ"),liveNode(s));return row;
|
|
179
|
+
}
|
|
180
|
+
function useItems(s){
|
|
181
|
+
var u=s.usage||{},items=[];
|
|
182
|
+
[["ctx",u.ctx],["5h",u.fiveHour],["1w",u.week]].forEach(function(x){if(typeof x[1]==="number")items.push(x);});
|
|
183
|
+
return items;
|
|
184
|
+
}
|
|
185
|
+
function foot(s){
|
|
186
|
+
var f=el("div","foot");
|
|
187
|
+
useItems(s).forEach(function(x){var u=el("span","use");add(u,x[0],mini(x[1]),el("b",null,x[1]+"%"));var w=useColor(x[1]);if(w)u.lastChild.style.color=w;f.appendChild(u);});
|
|
188
|
+
if(s.branch){var g=el("span","use");add(g,"git",el("b",null,s.branch));f.appendChild(g);}
|
|
189
|
+
if(s.workspace)f.appendChild(el("span","ws",s.workspace));
|
|
190
|
+
return f.childNodes.length?f:null;
|
|
191
|
+
}
|
|
192
|
+
function timeline(s){
|
|
193
|
+
var t=el("div","tline"),cells=s.map.cells,n=cells.length;
|
|
194
|
+
cells.forEach(function(c,i){
|
|
195
|
+
var color=ramp(n<=1?0:i/(n-1)),cur=c.state==="current"&&s.state!=="complete",todo=c.state==="pending";
|
|
196
|
+
var g=el("div","stg "+(cur?"cur":todo?"todo":"done"));g.style.setProperty("--c",color);
|
|
197
|
+
var nextCell=cells[i+1];if(!todo&&!cur&&nextCell&&nextCell.state!=="pending")g.style.setProperty("--line",color);
|
|
198
|
+
var l1=el("div","line1"),w;
|
|
199
|
+
if(cur){w=el("span","st nowpill");add(w,el("span","sweep"),c.label||c.word.toUpperCase());}
|
|
200
|
+
else{w=el("span","w",c.word);if(!todo)w.style.color=color;}
|
|
201
|
+
var meta=el("span","meta");if(c.progress)meta.textContent=c.progress.done+"/"+c.progress.total;else if(!todo&&!cur)meta.textContent=c.label?c.label+" โ":"โ";
|
|
202
|
+
add(l1,w,meta);add(g,el("span","pt"),l1);
|
|
203
|
+
if(cur){
|
|
204
|
+
var d=el("div","detail"),prog=c.progress;
|
|
205
|
+
if(prog){var r1=el("div","row");add(r1,el("span","dim","tasks"),el("b",null,prog.done+"/"+prog.total),bar(prog.done,prog.total));d.appendChild(r1);}
|
|
206
|
+
if(s.map.next){var r2=el("div","row");add(r2,el("span","dim","next"),el("span","acc","โธ"),el("span","nx",s.map.next));d.appendChild(r2);}
|
|
207
|
+
var r3=el("div","row"),live=liveNode(s);if(live){r3.appendChild(live);d.appendChild(r3);}
|
|
208
|
+
g.appendChild(d);
|
|
209
|
+
}
|
|
210
|
+
t.appendChild(g);
|
|
211
|
+
});
|
|
212
|
+
return t;
|
|
213
|
+
}
|
|
214
|
+
function usageBlock(s){
|
|
215
|
+
var items=useItems(s);if(!items.length&&!s.branch&&!s.workspace)return null;
|
|
216
|
+
var u=el("div","usage");
|
|
217
|
+
items.forEach(function(x){var r=el("div","ub"),tr=el("span","track"),fill=el("i"),w=useColor(x[1]);fill.style.width=x[1]+"%";fill.style.background=w||"linear-gradient(90deg,"+token("--pink")+","+token("--acc")+")";tr.appendChild(fill);var pct=el("span","pct",x[1]+"%");if(w)pct.style.color=w;add(r,el("span",null,x[0]),tr,pct);u.appendChild(r);});
|
|
218
|
+
var g=el("div","row");if(s.branch)add(g,"git",el("b",null,s.branch));if(s.workspace){if(s.branch)g.appendChild(joiner());g.appendChild(el("span",null,s.workspace));}
|
|
219
|
+
if(g.childNodes.length)u.appendChild(g);
|
|
220
|
+
return u;
|
|
221
|
+
}
|
|
222
|
+
function renderInline(s){
|
|
223
|
+
card.appendChild(head(s));
|
|
224
|
+
if(s.state==="ready"){var hint=el("div","row");add(hint,el("span","dim","no LIT skill yet"),joiner(),el("span","dim","type"),el("kbd",null,"lit <task>"),el("span","dim","to start one"));hint.style.marginTop="6px";card.appendChild(hint);return;}
|
|
225
|
+
if(s.map)card.appendChild(mapRow(s));else card.appendChild(el("div","map"));
|
|
226
|
+
card.appendChild(taskRow(s));
|
|
227
|
+
var f=foot(s);if(f){card.appendChild(f);var ws=f.querySelector(".ws");if(ws&&ws.scrollWidth>ws.clientWidth+1)f.removeChild(ws);}
|
|
228
|
+
}
|
|
229
|
+
function renderPane(s){
|
|
230
|
+
card.appendChild(head(s));
|
|
231
|
+
if(s.state==="ready"){
|
|
232
|
+
var hero=el("div","hero"),hs=el("div","heros");add(hs,"type ",el("kbd",null,"lit <task>")," in this thread to start one");
|
|
233
|
+
var ex=el("div","examples");["lit add a --shout flag","lit plan the release note","lit-loop fix the parser"].forEach(function(t){ex.appendChild(el("kbd",null,t));});
|
|
234
|
+
add(hero,el("div","flame","๐ฅ"),el("div","herot","no LIT skill yet"),hs,ex);card.appendChild(hero);
|
|
235
|
+
}else{
|
|
236
|
+
if(s.state==="complete"){var prog=progressOf(s.map),bn=el("div","banner",doneWord(s)+" โ");if(prog)add(bn,el("span","dim",prog.done+"/"+prog.total+" tasks"));if(s.ignitedAt)add(bn,el("span","dim","ยท "+span(took(s))));card.appendChild(bn);}
|
|
237
|
+
if(s.map)card.appendChild(timeline(s));else{var r=el("div","row");r.style.marginTop="14px";add(r,liveNode(s));card.appendChild(r);}
|
|
238
|
+
}
|
|
239
|
+
var u=usageBlock(s);if(u)card.appendChild(u);
|
|
240
|
+
}
|
|
241
|
+
function render(){
|
|
242
|
+
var s=status;if(!s)return;
|
|
243
|
+
var p=pane();root.classList.toggle("pane",p);
|
|
244
|
+
card.className="lc"+(s.state==="complete"?" is-done":s.state==="ready"?" is-idle":"");
|
|
245
|
+
card.textContent="";
|
|
246
|
+
if(p)renderPane(s);else renderInline(s);
|
|
247
|
+
reportSize();
|
|
248
|
+
}
|
|
249
|
+
function tick(){
|
|
250
|
+
if(ticker){clearInterval(ticker);ticker=null;}
|
|
251
|
+
if(document.hidden||!card.querySelector("[data-since]"))return;
|
|
252
|
+
ticker=setInterval(function(){var n=card.querySelectorAll("[data-since]");for(var i=0;i<n.length;i++)n[i].textContent="ยท "+clock(Date.now()-Number(n[i].getAttribute("data-since")));},1000);
|
|
253
|
+
}
|
|
254
|
+
function accept(s){
|
|
255
|
+
if(!s||s.version!==1)return;
|
|
256
|
+
status=s;if(s.thread)thread=s.thread;
|
|
257
|
+
if(s.working)idleSince=Date.now();
|
|
258
|
+
render();tick();
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/* host bridge: window.openai when present, else MCP Apps JSON-RPC over postMessage */
|
|
262
|
+
function rpc(method,params){return new Promise(function(resolve,reject){var id=nextId++;pending[id]={resolve:resolve,reject:reject};window.parent.postMessage({jsonrpc:"2.0",id:id,method:method,params:params},"*");setTimeout(function(){if(pending[id]){delete pending[id];reject(new Error(method+" timed out"));}},5000);});}
|
|
263
|
+
window.addEventListener("message",function(ev){
|
|
264
|
+
var m=ev.data;if(ev.source!==window.parent||!m||m.jsonrpc!=="2.0")return;
|
|
265
|
+
if(m.id!=null&&pending[m.id]){var p=pending[m.id];delete pending[m.id];if(m.error)p.reject(m.error);else p.resolve(m.result);return;}
|
|
266
|
+
if(m.method==="ui/notifications/tool-result"&&m.params)accept(m.params.structuredContent);
|
|
267
|
+
if(m.method==="ui/notifications/host-context-changed"&&m.params){if(m.params.displayMode)hostMode=m.params.displayMode;applyTheme(m.params.theme||null);}
|
|
268
|
+
});
|
|
269
|
+
window.addEventListener("openai:set_globals",function(){if(window.openai){applyTheme(window.openai.theme);if(window.openai.toolOutput&&!status)accept(window.openai.toolOutput);else render();}});
|
|
270
|
+
function callStatus(){
|
|
271
|
+
var args=thread?{thread_id:thread}:{};
|
|
272
|
+
if(bridge==="openai")return window.openai.callTool(STATUS_TOOL,args).then(function(r){return r&&(r.structuredContent||r.result&&r.result.structuredContent);});
|
|
273
|
+
return rpc("tools/call",{name:STATUS_TOOL,arguments:args}).then(function(r){return r&&r.structuredContent;});
|
|
274
|
+
}
|
|
275
|
+
var lastHeight=0;
|
|
276
|
+
function reportSize(){
|
|
277
|
+
if(pane())return;
|
|
278
|
+
var h=Math.ceil(card.getBoundingClientRect().height)+2;if(h===lastHeight)return;lastHeight=h;
|
|
279
|
+
if(bridge==="openai"&&typeof window.openai.notifyIntrinsicHeight==="function"){try{window.openai.notifyIntrinsicHeight(h);}catch(e){}}
|
|
280
|
+
else if(bridge==="mcp")window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/size-changed",params:{height:h}},"*");
|
|
281
|
+
}
|
|
282
|
+
function applyTheme(theme){
|
|
283
|
+
var dark=theme?theme==="dark":!(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches);
|
|
284
|
+
root.classList.toggle("light",!dark);if(status)render();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function delay(){
|
|
288
|
+
if(failures>0)return Math.min(MAX_BACKOFF,FAST*Math.pow(2,failures));
|
|
289
|
+
if(status&&status.working)return FAST;
|
|
290
|
+
return Date.now()-idleSince>120000?IDLE:SLOW;
|
|
291
|
+
}
|
|
292
|
+
function schedule(){if(timer)clearTimeout(timer);timer=null;if(!document.hidden)timer=setTimeout(poll,delay());}
|
|
293
|
+
function poll(){
|
|
294
|
+
callStatus().then(function(s){failures=0;accept(s);},function(){failures=Math.min(failures+1,5);}).then(schedule);
|
|
295
|
+
}
|
|
296
|
+
document.addEventListener("visibilitychange",function(){if(document.hidden){if(timer)clearTimeout(timer);timer=null;tick();}else{idleSince=Date.now();tick();poll();}});
|
|
297
|
+
window.addEventListener("resize",function(){if(status)render();});
|
|
298
|
+
|
|
299
|
+
function start(){
|
|
300
|
+
if(window.openai&&typeof window.openai.callTool==="function"){
|
|
301
|
+
bridge="openai";applyTheme(window.openai.theme);if(window.openai.toolOutput)accept(window.openai.toolOutput);poll();return;
|
|
302
|
+
}
|
|
303
|
+
bridge="mcp";applyTheme(null);
|
|
304
|
+
rpc("ui/initialize",{protocolVersion:"2026-01-26",appInfo:{name:"lit-card",version:"1"},appCapabilities:{availableDisplayModes:["inline","fullscreen"]}}).then(function(r){
|
|
305
|
+
window.parent.postMessage({jsonrpc:"2.0",method:"ui/notifications/initialized",params:{}},"*");
|
|
306
|
+
var ctx=r&&r.hostContext;if(ctx&&ctx.displayMode)hostMode=ctx.displayMode;applyTheme(ctx&&ctx.theme||null);poll();
|
|
307
|
+
},function(){poll();});
|
|
308
|
+
}
|
|
309
|
+
if(window.matchMedia)window.matchMedia("(prefers-color-scheme: light)").addEventListener("change",function(){if(!(window.openai&&window.openai.theme))applyTheme(null);});
|
|
310
|
+
start();
|
|
311
|
+
})();
|
|
312
|
+
</script></body></html>
|
|
313
|
+
`;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const CARD_TOOL = "lit_card";
|
|
2
|
+
export declare const CARD_STATUS_TOOL = "lit_card_status";
|
|
3
|
+
export declare const CARD_MIME = "text/html;profile=mcp-app";
|
|
4
|
+
/** The card's `ui://` URI. Hosts cache by URI, so it carries a hash of the HTML and changes with it. */
|
|
5
|
+
export declare function cardResourceUri(): string;
|
|
6
|
+
export interface CardContext {
|
|
7
|
+
readonly env: NodeJS.ProcessEnv;
|
|
8
|
+
readonly now: () => number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Answer one parsed JSON-RPC message. Returns the reply, or null for a notification (no `id`). Never
|
|
12
|
+
* throws: a failure inside a handler becomes an internal-error reply.
|
|
13
|
+
*/
|
|
14
|
+
export declare function handleCardMessage(message: unknown, context: CardContext): unknown;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// src/card-mcp.ts โ the JSON-RPC side of the LIT card server (MCP over stdio, no dependencies).
|
|
2
|
+
//
|
|
3
|
+
// Two tools. `lit_card` is for the model: it opens the card (an MCP App: `_meta.ui.resourceUri` plus
|
|
4
|
+
// the `openai/outputTemplate` alias the Codex desktop app also reads) and returns the text map, so a
|
|
5
|
+
// host that draws no card still gets something useful. `lit_card_status` is for the card only
|
|
6
|
+
// (`visibility: ["app"]`, so the model and the terminal never list it); the card polls it with the
|
|
7
|
+
// thread id the host adds to `_meta`. Both are read-only. The module has no side effects at import.
|
|
8
|
+
import { createHash } from "node:crypto";
|
|
9
|
+
import { CARD_HTML } from "./card-html.js";
|
|
10
|
+
import { cardStatusText, readCardStatus } from "./card-status.js";
|
|
11
|
+
export const CARD_TOOL = "lit_card";
|
|
12
|
+
export const CARD_STATUS_TOOL = "lit_card_status";
|
|
13
|
+
export const CARD_MIME = "text/html;profile=mcp-app";
|
|
14
|
+
const SERVER_INFO = { name: "litcodex", title: "LIT card", version: "1" };
|
|
15
|
+
const PROTOCOL_VERSIONS = new Set(["2024-11-05", "2025-03-26", "2025-06-18", "2025-11-25"]);
|
|
16
|
+
const DEFAULT_PROTOCOL = "2025-06-18";
|
|
17
|
+
/** Without a thread id nothing is known about the thread, so the text claims nothing about it. */
|
|
18
|
+
const NO_THREAD_TEXT = "๐ฅ LIT ยท the host did not name the thread, so there is no LIT state to show here.";
|
|
19
|
+
let resourceUri = null;
|
|
20
|
+
/** The card's `ui://` URI. Hosts cache by URI, so it carries a hash of the HTML and changes with it. */
|
|
21
|
+
export function cardResourceUri() {
|
|
22
|
+
resourceUri ??= `ui://litcodex/lit-card-${createHash("sha256").update(CARD_HTML).digest("hex").slice(0, 12)}.html`;
|
|
23
|
+
return resourceUri;
|
|
24
|
+
}
|
|
25
|
+
function isRecord(value) {
|
|
26
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27
|
+
}
|
|
28
|
+
function tools() {
|
|
29
|
+
const uri = cardResourceUri();
|
|
30
|
+
return [
|
|
31
|
+
{
|
|
32
|
+
name: CARD_TOOL,
|
|
33
|
+
title: "LIT card",
|
|
34
|
+
description: "Opens the live LIT card for this thread: the LIT activation, the workflow map and the step running now. It updates by itself. Call it once per thread, when the LIT activation context asks for it. In a host without cards it returns the same map as text.",
|
|
35
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
36
|
+
annotations: { title: "LIT card", readOnlyHint: true, destructiveHint: false, openWorldHint: false },
|
|
37
|
+
_meta: { ui: { resourceUri: uri, visibility: ["model", "app"] }, "openai/outputTemplate": uri },
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: CARD_STATUS_TOOL,
|
|
41
|
+
title: "LIT card status",
|
|
42
|
+
description: "Current LIT state for the card's thread. Used by the LIT card only.",
|
|
43
|
+
inputSchema: {
|
|
44
|
+
type: "object",
|
|
45
|
+
properties: { thread_id: { type: "string", maxLength: 128 } },
|
|
46
|
+
additionalProperties: false,
|
|
47
|
+
},
|
|
48
|
+
annotations: { title: "LIT card status", readOnlyHint: true, destructiveHint: false, openWorldHint: false },
|
|
49
|
+
_meta: { ui: { visibility: ["app"] } },
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
/** The thread id from the host's `_meta` (poll or model call), else the card's own argument. */
|
|
54
|
+
function threadOf(params) {
|
|
55
|
+
const meta = isRecord(params["_meta"]) ? params["_meta"] : {};
|
|
56
|
+
const turn = isRecord(meta["x-codex-turn-metadata"]) ? meta["x-codex-turn-metadata"] : {};
|
|
57
|
+
const args = isRecord(params["arguments"]) ? params["arguments"] : {};
|
|
58
|
+
for (const value of [
|
|
59
|
+
meta["thread_id"],
|
|
60
|
+
meta["threadId"],
|
|
61
|
+
turn["thread_id"],
|
|
62
|
+
turn["session_id"],
|
|
63
|
+
args["thread_id"],
|
|
64
|
+
]) {
|
|
65
|
+
if (typeof value === "string" && value !== "" && value.length <= 128)
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
function callTool(params, context) {
|
|
71
|
+
const thread = threadOf(params);
|
|
72
|
+
const status = readCardStatus(thread, context.env, context.now());
|
|
73
|
+
if (params["name"] === CARD_STATUS_TOOL) {
|
|
74
|
+
return { content: [{ type: "text", text: JSON.stringify(status) }], structuredContent: status };
|
|
75
|
+
}
|
|
76
|
+
const text = thread === null ? NO_THREAD_TEXT : cardStatusText(status);
|
|
77
|
+
return { content: [{ type: "text", text }], structuredContent: status };
|
|
78
|
+
}
|
|
79
|
+
function result(id, value) {
|
|
80
|
+
return { jsonrpc: "2.0", id, result: value };
|
|
81
|
+
}
|
|
82
|
+
function failure(id, code, message) {
|
|
83
|
+
return { jsonrpc: "2.0", id, error: { code, message } };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Answer one parsed JSON-RPC message. Returns the reply, or null for a notification (no `id`). Never
|
|
87
|
+
* throws: a failure inside a handler becomes an internal-error reply.
|
|
88
|
+
*/
|
|
89
|
+
export function handleCardMessage(message, context) {
|
|
90
|
+
if (!isRecord(message) || message["jsonrpc"] !== "2.0" || typeof message["method"] !== "string") {
|
|
91
|
+
return failure(null, -32600, "invalid request");
|
|
92
|
+
}
|
|
93
|
+
const rawId = message["id"];
|
|
94
|
+
if (rawId === undefined)
|
|
95
|
+
return null;
|
|
96
|
+
const id = typeof rawId === "string" || typeof rawId === "number" ? rawId : null;
|
|
97
|
+
const params = isRecord(message["params"]) ? message["params"] : {};
|
|
98
|
+
try {
|
|
99
|
+
switch (message["method"]) {
|
|
100
|
+
case "initialize": {
|
|
101
|
+
const asked = params["protocolVersion"];
|
|
102
|
+
return result(id, {
|
|
103
|
+
protocolVersion: typeof asked === "string" && PROTOCOL_VERSIONS.has(asked) ? asked : DEFAULT_PROTOCOL,
|
|
104
|
+
capabilities: { tools: {}, resources: {}, extensions: { "io.modelcontextprotocol/ui": {} } },
|
|
105
|
+
serverInfo: SERVER_INFO,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
case "ping":
|
|
109
|
+
return result(id, {});
|
|
110
|
+
case "tools/list":
|
|
111
|
+
return result(id, { tools: tools() });
|
|
112
|
+
case "tools/call":
|
|
113
|
+
if (params["name"] !== CARD_TOOL && params["name"] !== CARD_STATUS_TOOL) {
|
|
114
|
+
return failure(id, -32602, "unknown tool");
|
|
115
|
+
}
|
|
116
|
+
return result(id, callTool(params, context));
|
|
117
|
+
case "resources/list":
|
|
118
|
+
return result(id, { resources: [{ uri: cardResourceUri(), name: "LIT card", mimeType: CARD_MIME }] });
|
|
119
|
+
case "resources/templates/list":
|
|
120
|
+
return result(id, { resourceTemplates: [] });
|
|
121
|
+
case "resources/read":
|
|
122
|
+
if (params["uri"] !== cardResourceUri())
|
|
123
|
+
return failure(id, -32602, "unknown resource");
|
|
124
|
+
return result(id, {
|
|
125
|
+
contents: [
|
|
126
|
+
{
|
|
127
|
+
uri: cardResourceUri(),
|
|
128
|
+
mimeType: CARD_MIME,
|
|
129
|
+
text: CARD_HTML,
|
|
130
|
+
_meta: { ui: { prefersBorder: false } },
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
});
|
|
134
|
+
default:
|
|
135
|
+
return failure(id, -32601, "method not found");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return failure(id, -32603, "internal error");
|
|
140
|
+
}
|
|
141
|
+
}
|