@litfamily/litcodex 1.0.23 → 1.0.25
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/generated-skill-payload-hashes.d.ts +13 -13
- package/dist/install/generated-skill-payload-hashes.js +13 -13
- package/marketplace/plugins/litcodex/.codex-plugin/plugin.json +1 -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 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-html.js +65 -26
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-mcp.js +26 -5
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-status.d.ts +2 -0
- package/marketplace/plugins/litcodex/components/lit-loop/dist/card-status.js +9 -5
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.d.ts +5 -2
- package/marketplace/plugins/litcodex/components/lit-loop/dist/hook-cli.js +10 -11
- package/marketplace/plugins/litcodex/components/lit-loop/dist/live-step.d.ts +9 -1
- package/marketplace/plugins/litcodex/components/lit-loop/dist/live-step.js +23 -5
- 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/dist/deliverable-hedge-guard.js +23 -2
- 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/skills/lit-docx/SKILL.md +2 -2
- package/marketplace/plugins/litcodex/skills/lit-docx/references/examples/01-report-ko.md +1 -1
- package/marketplace/plugins/litcodex/skills/lit-humanizer/references/taxonomy.md +2 -0
- package/marketplace/plugins/litcodex/skills/lit-humanizer/rules.json +55 -1
- package/marketplace/plugins/litcodex/skills/lit-humanizer/scripts/core.mjs +13 -2
- package/marketplace/plugins/litcodex/skills/lit-pptx/SKILL.md +2 -2
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/authoring-guide.md +3 -4
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/data-display-cookbook.md +1 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/density-and-fill.md +1 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/examples/04-research-talk-paper-en.md +1 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/layout-families.md +1 -1
- package/marketplace/plugins/litcodex/skills/lit-pptx/references/tonalities/paper.md +2 -2
- package/marketplace/plugins/litcodex/skills/lit-pptx/specs/markdown-slide-spec-v1.md +1 -1
- package/node_modules/@litcodex/lit-loop/dist/card-html.d.ts +1 -1
- package/node_modules/@litcodex/lit-loop/dist/card-html.js +65 -26
- package/node_modules/@litcodex/lit-loop/dist/card-mcp.js +26 -5
- package/node_modules/@litcodex/lit-loop/dist/card-status.d.ts +2 -0
- package/node_modules/@litcodex/lit-loop/dist/card-status.js +9 -5
- package/node_modules/@litcodex/lit-loop/dist/hook-cli.d.ts +5 -2
- package/node_modules/@litcodex/lit-loop/dist/hook-cli.js +10 -11
- package/node_modules/@litcodex/lit-loop/dist/live-step.d.ts +9 -1
- package/node_modules/@litcodex/lit-loop/dist/live-step.js +23 -5
- package/node_modules/@litcodex/lit-loop/package.json +1 -1
- package/node_modules/@litcodex/lit-loop/skills/lit-humanizer/references/taxonomy.md +2 -0
- package/node_modules/@litcodex/lit-loop/skills/lit-humanizer/rules.json +55 -1
- package/node_modules/@litcodex/lit-loop/skills/lit-humanizer/scripts/core.mjs +13 -2
- package/package.json +2 -2
- package/readme-assets/badge-version.svg +1 -1
|
@@ -11,26 +11,31 @@
|
|
|
11
11
|
// card drew in a proportional face inside the app, so it pins its monospace face. Light and dark follow the
|
|
12
12
|
// host theme. It polls every 1.5 s while visible and working, slows down when idle and stops while
|
|
13
13
|
// hidden. It talks to the host through `window.openai` when present, else MCP Apps postMessage JSON-RPC.
|
|
14
|
+
//
|
|
15
|
+
// Every LIT turn opens a fresh card next to the newest turn. A card learns its own opening time once, from
|
|
16
|
+
// the tool result that created it; each poll names the thread's newest card. When that is a later card,
|
|
17
|
+
// this one folds into a single quiet line with its final state, stops every timer and never polls again.
|
|
18
|
+
// Usage bars stay in the calm accent until 70 % (amber) and 90 % (red); pink and flame are for LIT marks.
|
|
14
19
|
export const CARD_HTML = `<!doctype html>
|
|
15
20
|
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
16
21
|
<title>LIT</title>
|
|
17
22
|
<style>
|
|
18
23
|
: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
24
|
--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:#
|
|
25
|
+
:root.light{color-scheme:light;--bg:#ffffff;--bg2:#fafbfd;--ink:#1b1f27;--dim:#5f6672;--faint:#dde2e8;--rail:#cfd6de;--flame:#bd3f0b;--pink:#c0186b;--acc:#006f99;--green:#17783f;--amber:#9a5b00;--red:#c42f2f}
|
|
21
26
|
*{box-sizing:border-box}
|
|
22
27
|
html,body{margin:0;background:transparent}
|
|
23
28
|
body{color:var(--ink);font-size:12.5px;line-height:1.55;font-weight:500;-webkit-font-smoothing:antialiased}
|
|
24
29
|
.lc,.lc *{font-family:var(--mono)!important}
|
|
25
30
|
.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%,
|
|
31
|
+
background:radial-gradient(110% 120% at 0% 0%,color-mix(in srgb,var(--pink) 8%,var(--bg)),var(--bg) 55%,var(--bg2));
|
|
27
32
|
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
33
|
.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
34
|
.lc.is-idle{border-color:color-mix(in srgb,var(--dim) 40%,transparent);box-shadow:none;animation:none}
|
|
30
35
|
@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
36
|
.head{display:flex;align-items:center;gap:7px;white-space:nowrap;min-height:22px}
|
|
32
37
|
.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{
|
|
38
|
+
.j{display:inline-block;flex:0 0 auto;width:3px;height:3px;border-radius:50%;background:var(--rail)}
|
|
34
39
|
.name{font-weight:700;overflow:hidden;text-overflow:ellipsis}.acc{color:var(--acc)}.dim{color:var(--dim)}.ok{color:var(--green)}
|
|
35
40
|
.right{margin-left:auto;font-weight:700;letter-spacing:.04em;display:inline-flex;align-items:center;gap:6px}
|
|
36
41
|
.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}
|
|
@@ -43,9 +48,9 @@ border:1px solid color-mix(in srgb,var(--acc) 55%,transparent);box-shadow:0 0 0
|
|
|
43
48
|
:root.light .comet{background:var(--accfill);box-shadow:0 0 5px 1px var(--accfill)}
|
|
44
49
|
@keyframes comet{0%{left:-8%;opacity:0}15%,85%{opacity:1}100%{left:100%;opacity:0}}
|
|
45
50
|
.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
|
-
.
|
|
51
|
+
.brand::after,.nowpill::after{content:"";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
52
|
@keyframes sweep{0%,55%{transform:translateX(-120%)}85%,100%{transform:translateX(120%)}}
|
|
48
|
-
.is-done .
|
|
53
|
+
.is-done .brand::after,.is-idle .brand::after,.folded .brand::after{display:none}
|
|
49
54
|
.row{display:flex;align-items:center;gap:8px;white-space:nowrap;min-height:20px}
|
|
50
55
|
.tl{display:inline-flex;align-items:center;gap:6px;overflow:hidden;min-width:0}
|
|
51
56
|
.nx{overflow:hidden;text-overflow:ellipsis}
|
|
@@ -81,7 +86,13 @@ kbd{font-size:12px;color:var(--acc);background:color-mix(in srgb,var(--acc) 12%,
|
|
|
81
86
|
.hero{text-align:center;padding:36px 0 10px}.flame{font-size:40px;filter:drop-shadow(0 0 16px rgba(255,99,55,.45))}
|
|
82
87
|
.herot{font-weight:700;font-size:15px;margin-top:8px}.heros{color:var(--dim);margin:6px 0 14px}
|
|
83
88
|
.examples{display:flex;flex-direction:column;align-items:center;gap:6px}
|
|
84
|
-
|
|
89
|
+
/* an earlier turn's card, once a newer one opened below: one quiet line, no glow, no motion */
|
|
90
|
+
.lc.folded{padding:3px 10px;border-radius:10px;background:var(--bg);border:1px solid color-mix(in srgb,var(--dim) 30%,transparent);box-shadow:none;animation:none;font-size:12px}
|
|
91
|
+
.lc.folded .head{min-height:20px;gap:6px}
|
|
92
|
+
.lc.folded .brand{padding:0 7px 0 6px;font-size:11px;background:color-mix(in srgb,var(--dim) 24%,var(--bg));color:var(--ink);box-shadow:none;filter:grayscale(1)}
|
|
93
|
+
.lc.folded .name{color:var(--dim);font-weight:600}
|
|
94
|
+
.lc.folded .right{font-weight:600;letter-spacing:0;flex:0 0 auto}
|
|
95
|
+
@media (prefers-reduced-motion:reduce){.lc,.lc *{animation:none!important}.brand::after,.nowpill::after,.comet{display:none}}
|
|
85
96
|
</style></head>
|
|
86
97
|
<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
98
|
<script>
|
|
@@ -90,11 +101,12 @@ var STATUS_TOOL="lit_card_status";
|
|
|
90
101
|
var FAST=1500,SLOW=5000,IDLE=15000,MAX_BACKOFF=30000;
|
|
91
102
|
var root=document.documentElement,card=document.getElementById("card");
|
|
92
103
|
var status=null,thread=null,timer=null,ticker=null,failures=0,idleSince=Date.now(),bridge=null,hostMode=null;
|
|
104
|
+
var opened=null,folded=false;
|
|
93
105
|
var nextId=1,pending={};
|
|
94
106
|
|
|
95
107
|
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
108
|
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(){
|
|
109
|
+
function joiner(){var n=el("span","j");n.setAttribute("aria-hidden","true");return n;}
|
|
98
110
|
|
|
99
111
|
/* linear-RGB mixing, so the flame → pink → accent ramp keeps its brightness */
|
|
100
112
|
function hex(c){c=c.trim().replace("#","");return[0,2,4].map(function(i){return parseInt(c.substr(i,2),16)/255;});}
|
|
@@ -107,6 +119,7 @@ function ramp(t){var f=token("--flame"),p=token("--pink"),a=token("--acc");retur
|
|
|
107
119
|
function clock(ms){var s=Math.max(0,Math.floor(ms/1000));return Math.floor(s/60)+":"+("0"+(s%60)).slice(-2);}
|
|
108
120
|
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
121
|
function since(t){var n=el("span","dim el","· "+clock(Date.now()-t));n.setAttribute("data-since",String(t));return n;}
|
|
122
|
+
function turnClock(t){var n=el("span","el",clock(Date.now()-t));n.setAttribute("data-since",String(t));n.setAttribute("data-bare","1");return n;}
|
|
110
123
|
function pane(){var m=(window.openai&&window.openai.displayMode)||hostMode;return m==="fullscreen"||m==="pip";}
|
|
111
124
|
|
|
112
125
|
function bar(done,total){
|
|
@@ -117,7 +130,7 @@ function bar(done,total){
|
|
|
117
130
|
return b;
|
|
118
131
|
}
|
|
119
132
|
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),
|
|
133
|
+
function mini(p){var b=el("span","mini"),on=Math.round(p/10),fill=useColor(p)||token("--acc");for(var i=0;i<10;i++){var c=el("i");if(i<on)c.style.background=fill;b.appendChild(c);}return b;}
|
|
121
134
|
function spinner(soft){
|
|
122
135
|
var ns="http://www.w3.org/2000/svg",svg=document.createElementNS(ns,"svg");
|
|
123
136
|
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");
|
|
@@ -125,7 +138,6 @@ function spinner(soft){
|
|
|
125
138
|
[["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
139
|
svg.appendChild(c);return svg;
|
|
127
140
|
}
|
|
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
141
|
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
142
|
function doneWord(s){return progressOf(s.map)?"COMPLETE":"DONE";}
|
|
131
143
|
function took(s){if(s.turnEndedAt)return s.turnEndedAt-(s.turnStartedAt||s.ignitedAt||s.turnEndedAt);return (s.lastStepAt||s.now)-s.ignitedAt;}
|
|
@@ -135,16 +147,26 @@ function liveNode(s){
|
|
|
135
147
|
var n=el("span","live");
|
|
136
148
|
if(s.step){add(n,spinner(false),el("span","tool",s.step.tool),since(s.step.startedAt));return n;}
|
|
137
149
|
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.
|
|
150
|
+
if(s.state==="ignited"&&s.working){add(n,spinner(true),el("span","dim","thinking"));if(s.lastTool)add(n,el("span","dim","· last"),el("span","acc","▸"),el("span","last",s.lastTool));return n;}
|
|
139
151
|
if(s.state==="ignited"){add(n,el("span","dim","◦ waiting for you"));return n;}
|
|
140
152
|
return null;
|
|
141
153
|
}
|
|
154
|
+
/* the header's right side: the turn clock while working (the map already names the stage), the result once done */
|
|
142
155
|
function head(s){
|
|
143
|
-
var h=el("div","head")
|
|
156
|
+
var h=el("div","head");add(h,el("span","brand","🔥 LIT"),joiner());
|
|
144
157
|
if(s.state==="ready"){add(h,el("span","name dim","ready"),el("span","right dim","idle"));return h;}
|
|
145
158
|
add(h,el("span","name acc",s.mode||"lit"));
|
|
146
159
|
if(s.state==="complete"){add(h,el("span","right ok",doneWord(s)+" ✓"));return h;}
|
|
147
|
-
var
|
|
160
|
+
var r=el("span","right acc");if(!s.map)r.appendChild(el("span",null,"IGNITED"));
|
|
161
|
+
if(s.working){if(s.turnStartedAt)r.appendChild(turnClock(s.turnStartedAt));r.appendChild(el("i","dot"));}
|
|
162
|
+
if(r.childNodes.length)h.appendChild(r);return h;
|
|
163
|
+
}
|
|
164
|
+
/* an earlier turn's card: the LIT mark, its mode and how it ended, on one line */
|
|
165
|
+
function renderFolded(s){
|
|
166
|
+
var h=el("div","head");add(h,el("span","brand","🔥 LIT"),joiner(),el("span","name",s&&s.mode||"lit"));
|
|
167
|
+
if(s&&s.state==="complete"){var r=el("span","right ok",doneWord(s).toLowerCase()+" ✓");if(s.ignitedAt)add(r," ",el("span","dim",span(took(s))));h.appendChild(r);}
|
|
168
|
+
else h.appendChild(el("span","right dim","continued below ↓"));
|
|
169
|
+
card.appendChild(h);
|
|
148
170
|
}
|
|
149
171
|
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
172
|
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;}
|
|
@@ -160,7 +182,7 @@ function mapRow(s){
|
|
|
160
182
|
m.appendChild(r);
|
|
161
183
|
}
|
|
162
184
|
if(cur){
|
|
163
|
-
var p=el("span","st nowpill"
|
|
185
|
+
var p=el("span","st nowpill",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
186
|
}else if(c.state==="pending"){var t=el("span","st todo",c.word);t.appendChild(el("em",null,"·"));m.appendChild(t);}
|
|
165
187
|
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
188
|
});
|
|
@@ -196,7 +218,7 @@ function timeline(s){
|
|
|
196
218
|
var g=el("div","stg "+(cur?"cur":todo?"todo":"done"));g.style.setProperty("--c",color);
|
|
197
219
|
var nextCell=cells[i+1];if(!todo&&!cur&&nextCell&&nextCell.state!=="pending")g.style.setProperty("--line",color);
|
|
198
220
|
var l1=el("div","line1"),w;
|
|
199
|
-
if(cur)
|
|
221
|
+
if(cur)w=el("span","st nowpill",c.label||c.word.toUpperCase());
|
|
200
222
|
else{w=el("span","w",c.word);if(!todo)w.style.color=color;}
|
|
201
223
|
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
224
|
add(l1,w,meta);add(g,el("span","pt"),l1);
|
|
@@ -214,7 +236,7 @@ function timeline(s){
|
|
|
214
236
|
function usageBlock(s){
|
|
215
237
|
var items=useItems(s);if(!items.length&&!s.branch&&!s.workspace)return null;
|
|
216
238
|
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||
|
|
239
|
+
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||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
240
|
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
241
|
if(g.childNodes.length)u.appendChild(g);
|
|
220
242
|
return u;
|
|
@@ -224,7 +246,11 @@ function renderInline(s){
|
|
|
224
246
|
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
247
|
if(s.map)card.appendChild(mapRow(s));else card.appendChild(el("div","map"));
|
|
226
248
|
card.appendChild(taskRow(s));
|
|
227
|
-
var f=foot(s);if(f)
|
|
249
|
+
var f=foot(s);if(!f)return;card.appendChild(f);
|
|
250
|
+
/* a narrow card drops the workspace, then the branch, then the last use items, rather than cut a number */
|
|
251
|
+
var ws=f.querySelector(".ws");if(ws&&ws.scrollWidth>ws.clientWidth+1)f.removeChild(ws);
|
|
252
|
+
while(f.lastChild&&f.scrollWidth>f.clientWidth+1)f.removeChild(f.lastChild);
|
|
253
|
+
if(!f.childNodes.length)card.removeChild(f);
|
|
228
254
|
}
|
|
229
255
|
function renderPane(s){
|
|
230
256
|
card.appendChild(head(s));
|
|
@@ -239,7 +265,9 @@ function renderPane(s){
|
|
|
239
265
|
var u=usageBlock(s);if(u)card.appendChild(u);
|
|
240
266
|
}
|
|
241
267
|
function render(){
|
|
242
|
-
var s=status;
|
|
268
|
+
var s=status;
|
|
269
|
+
if(folded){root.classList.toggle("pane",false);card.className="lc folded";card.textContent="";renderFolded(s);reportSize();return;}
|
|
270
|
+
if(!s)return;
|
|
243
271
|
var p=pane();root.classList.toggle("pane",p);
|
|
244
272
|
card.className="lc"+(s.state==="complete"?" is-done":s.state==="ready"?" is-idle":"");
|
|
245
273
|
card.textContent="";
|
|
@@ -249,10 +277,20 @@ function render(){
|
|
|
249
277
|
function tick(){
|
|
250
278
|
if(ticker){clearInterval(ticker);ticker=null;}
|
|
251
279
|
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);
|
|
280
|
+
ticker=setInterval(function(){var n=card.querySelectorAll("[data-since]");for(var i=0;i<n.length;i++)n[i].textContent=(n[i].getAttribute("data-bare")?"":"· ")+clock(Date.now()-Number(n[i].getAttribute("data-since")));},1000);
|
|
281
|
+
}
|
|
282
|
+
/* the card's own opening time comes only from the tool result that created it, never from a poll */
|
|
283
|
+
function own(s){if(opened===null&&s&&s.card&&typeof s.card.openedAt==="number")opened=s.card.openedAt;}
|
|
284
|
+
function fold(){
|
|
285
|
+
folded=true;
|
|
286
|
+
if(timer){clearTimeout(timer);timer=null;}
|
|
287
|
+
if(ticker){clearInterval(ticker);ticker=null;}
|
|
288
|
+
render();
|
|
253
289
|
}
|
|
254
|
-
function accept(s){
|
|
255
|
-
if(
|
|
290
|
+
function accept(s,fromTool){
|
|
291
|
+
if(folded||!s||s.version!==1)return;
|
|
292
|
+
if(fromTool)own(s);
|
|
293
|
+
if(opened!==null&&typeof s.cardOpenedAt==="number"&&s.cardOpenedAt>opened){fold();return;}
|
|
256
294
|
status=s;if(s.thread)thread=s.thread;
|
|
257
295
|
if(s.working)idleSince=Date.now();
|
|
258
296
|
render();tick();
|
|
@@ -263,10 +301,10 @@ function rpc(method,params){return new Promise(function(resolve,reject){var id=n
|
|
|
263
301
|
window.addEventListener("message",function(ev){
|
|
264
302
|
var m=ev.data;if(ev.source!==window.parent||!m||m.jsonrpc!=="2.0")return;
|
|
265
303
|
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);
|
|
304
|
+
if(m.method==="ui/notifications/tool-result"&&m.params)accept(m.params.structuredContent,true);
|
|
267
305
|
if(m.method==="ui/notifications/host-context-changed"&&m.params){if(m.params.displayMode)hostMode=m.params.displayMode;applyTheme(m.params.theme||null);}
|
|
268
306
|
});
|
|
269
|
-
window.addEventListener("openai:set_globals",function(){if(window.openai){applyTheme(window.openai.theme);if(
|
|
307
|
+
window.addEventListener("openai:set_globals",function(){if(window.openai){var o=window.openai.toolOutput;own(o);applyTheme(window.openai.theme);if(o&&!status)accept(o,true);else render();}});
|
|
270
308
|
function callStatus(){
|
|
271
309
|
var args=thread?{thread_id:thread}:{};
|
|
272
310
|
if(bridge==="openai")return window.openai.callTool(STATUS_TOOL,args).then(function(r){return r&&(r.structuredContent||r.result&&r.result.structuredContent);});
|
|
@@ -289,16 +327,17 @@ function delay(){
|
|
|
289
327
|
if(status&&status.working)return FAST;
|
|
290
328
|
return Date.now()-idleSince>120000?IDLE:SLOW;
|
|
291
329
|
}
|
|
292
|
-
function schedule(){if(timer)clearTimeout(timer);timer=null;if(!document.hidden)timer=setTimeout(poll,delay());}
|
|
330
|
+
function schedule(){if(timer)clearTimeout(timer);timer=null;if(!document.hidden&&!folded)timer=setTimeout(poll,delay());}
|
|
293
331
|
function poll(){
|
|
332
|
+
if(folded)return;
|
|
294
333
|
callStatus().then(function(s){failures=0;accept(s);},function(){failures=Math.min(failures+1,5);}).then(schedule);
|
|
295
334
|
}
|
|
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();});
|
|
335
|
+
document.addEventListener("visibilitychange",function(){if(folded)return;if(document.hidden){if(timer)clearTimeout(timer);timer=null;tick();}else{idleSince=Date.now();tick();poll();}});
|
|
336
|
+
window.addEventListener("resize",function(){if(status||folded)render();});
|
|
298
337
|
|
|
299
338
|
function start(){
|
|
300
339
|
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;
|
|
340
|
+
bridge="openai";applyTheme(window.openai.theme);if(window.openai.toolOutput)accept(window.openai.toolOutput,true);poll();return;
|
|
302
341
|
}
|
|
303
342
|
bridge="mcp";applyTheme(null);
|
|
304
343
|
rpc("ui/initialize",{protocolVersion:"2026-01-26",appInfo:{name:"lit-card",version:"1"},appCapabilities:{availableDisplayModes:["inline","fullscreen"]}}).then(function(r){
|
|
@@ -4,16 +4,28 @@
|
|
|
4
4
|
// the `openai/outputTemplate` alias the Codex desktop app also reads) and returns the text map, so a
|
|
5
5
|
// host that draws no card still gets something useful. `lit_card_status` is for the card only
|
|
6
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`.
|
|
7
|
+
// thread id the host adds to `_meta`. Each LIT turn opens a fresh card next to the newest turn: `lit_card`
|
|
8
|
+
// records when it opened in the thread pointer and tells the new card that time, every poll carries the
|
|
9
|
+
// newest time, and an older card that sees a later one folds into a single line and stops polling. That
|
|
10
|
+
// timestamp in LitCodex's own pointer is the only write; nothing in the workspace or the user's files
|
|
11
|
+
// changes, so both tools keep their read-only hint. The module has no side effects at import.
|
|
8
12
|
import { createHash } from "node:crypto";
|
|
9
13
|
import { CARD_HTML } from "./card-html.js";
|
|
10
14
|
import { cardStatusText, readCardStatus } from "./card-status.js";
|
|
15
|
+
import { recordCardOpened } from "./live-step.js";
|
|
11
16
|
export const CARD_TOOL = "lit_card";
|
|
12
17
|
export const CARD_STATUS_TOOL = "lit_card_status";
|
|
13
18
|
export const CARD_MIME = "text/html;profile=mcp-app";
|
|
14
19
|
const SERVER_INFO = { name: "litcodex", title: "LIT card", version: "1" };
|
|
15
20
|
const PROTOCOL_VERSIONS = new Set(["2024-11-05", "2025-03-26", "2025-06-18", "2025-11-25"]);
|
|
16
21
|
const DEFAULT_PROTOCOL = "2025-06-18";
|
|
22
|
+
/**
|
|
23
|
+
* The inline frame is max(the card's reported height, this floor); 200 by default, which left blank
|
|
24
|
+
* space under the card. The floor is the folded one-line card, so the frame follows the card.
|
|
25
|
+
*/
|
|
26
|
+
const MIN_FRAME_HEIGHT = 28;
|
|
27
|
+
/** The working card's usual height, so the first paint is close before the card reports its own. */
|
|
28
|
+
const HEIGHT_HINT = 135;
|
|
17
29
|
/** Without a thread id nothing is known about the thread, so the text claims nothing about it. */
|
|
18
30
|
const NO_THREAD_TEXT = "🔥 LIT · the host did not name the thread, so there is no LIT state to show here.";
|
|
19
31
|
let resourceUri = null;
|
|
@@ -31,7 +43,7 @@ function tools() {
|
|
|
31
43
|
{
|
|
32
44
|
name: CARD_TOOL,
|
|
33
45
|
title: "LIT card",
|
|
34
|
-
description: "Opens
|
|
46
|
+
description: "Opens a live LIT card for this LIT turn: the LIT activation, the workflow map and the step running now. It updates by itself, and the card of the previous LIT turn folds into one line. Call it once per LIT turn, when the LIT activation context asks for it. In a host without cards it returns the same map as text.",
|
|
35
47
|
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
36
48
|
annotations: { title: "LIT card", readOnlyHint: true, destructiveHint: false, openWorldHint: false },
|
|
37
49
|
_meta: { ui: { resourceUri: uri, visibility: ["model", "app"] }, "openai/outputTemplate": uri },
|
|
@@ -69,12 +81,17 @@ function threadOf(params) {
|
|
|
69
81
|
}
|
|
70
82
|
function callTool(params, context) {
|
|
71
83
|
const thread = threadOf(params);
|
|
72
|
-
const
|
|
84
|
+
const now = context.now();
|
|
73
85
|
if (params["name"] === CARD_STATUS_TOOL) {
|
|
86
|
+
const status = readCardStatus(thread, context.env, now);
|
|
74
87
|
return { content: [{ type: "text", text: JSON.stringify(status) }], structuredContent: status };
|
|
75
88
|
}
|
|
89
|
+
if (thread !== null)
|
|
90
|
+
recordCardOpened(context.env, thread, now);
|
|
91
|
+
const status = readCardStatus(thread, context.env, now);
|
|
76
92
|
const text = thread === null ? NO_THREAD_TEXT : cardStatusText(status);
|
|
77
|
-
|
|
93
|
+
// The card keeps this time as its own; polls only ever say which card is the newest.
|
|
94
|
+
return { content: [{ type: "text", text }], structuredContent: { ...status, card: { openedAt: now } } };
|
|
78
95
|
}
|
|
79
96
|
function result(id, value) {
|
|
80
97
|
return { jsonrpc: "2.0", id, result: value };
|
|
@@ -127,7 +144,11 @@ export function handleCardMessage(message, context) {
|
|
|
127
144
|
uri: cardResourceUri(),
|
|
128
145
|
mimeType: CARD_MIME,
|
|
129
146
|
text: CARD_HTML,
|
|
130
|
-
_meta: {
|
|
147
|
+
_meta: {
|
|
148
|
+
ui: { prefersBorder: false },
|
|
149
|
+
"openai/widgetMinFrameHeight": MIN_FRAME_HEIGHT,
|
|
150
|
+
"openai/widgetHeightHint": HEIGHT_HINT,
|
|
151
|
+
},
|
|
131
152
|
},
|
|
132
153
|
],
|
|
133
154
|
});
|
|
@@ -25,6 +25,8 @@ export interface CardStatus {
|
|
|
25
25
|
readonly branch: string | null;
|
|
26
26
|
/** Folder name of the workspace only; the full path stays out of the card. */
|
|
27
27
|
readonly workspace: string | null;
|
|
28
|
+
/** When the newest card of this thread opened; an older card that sees a later time folds itself. */
|
|
29
|
+
readonly cardOpenedAt: number | null;
|
|
28
30
|
readonly now: number;
|
|
29
31
|
}
|
|
30
32
|
export interface Usage {
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
// live step. The workspace comes from the owned pointer first; Codex's own rollout header is read only
|
|
6
6
|
// when no pointer exists yet, because its format is private. The rollout's last token count gives the
|
|
7
7
|
// context and quota use for the bottom row; when that format moves, the row simply stays empty. Thread ids are normalized before they
|
|
8
|
-
// touch a path, every file read is size-capped and refuses symlinks, and nothing here writes
|
|
8
|
+
// touch a path, every file read is size-capped and refuses symlinks, and nothing here writes; the one
|
|
9
|
+
// write of the card server, the time a card opened, lives in live-step.ts.
|
|
9
10
|
import { closeSync, fstatSync, readdirSync, readSync } from "node:fs";
|
|
10
11
|
import { basename, isAbsolute, join } from "node:path";
|
|
11
12
|
import { codexHomeFrom, openRegularFile, plainDirs, readLiveStep, readThreadPointer, } from "./live-step.js";
|
|
@@ -259,7 +260,7 @@ function finishedMap(map) {
|
|
|
259
260
|
next: null,
|
|
260
261
|
};
|
|
261
262
|
}
|
|
262
|
-
function ready(thread, workspace, now) {
|
|
263
|
+
function ready(thread, workspace, cardOpenedAt, now) {
|
|
263
264
|
return {
|
|
264
265
|
version: 1,
|
|
265
266
|
thread,
|
|
@@ -276,6 +277,7 @@ function ready(thread, workspace, now) {
|
|
|
276
277
|
usage: null,
|
|
277
278
|
branch: null,
|
|
278
279
|
workspace,
|
|
280
|
+
cardOpenedAt,
|
|
279
281
|
now,
|
|
280
282
|
};
|
|
281
283
|
}
|
|
@@ -297,14 +299,15 @@ export function readCardStatus(threadId, env, now = Date.now()) {
|
|
|
297
299
|
const cwd = resolveThreadCwd(threadId, env);
|
|
298
300
|
const thread = cwd === null ? null : threadId;
|
|
299
301
|
if (cwd === null || thread === null)
|
|
300
|
-
return ready(null, null, now);
|
|
302
|
+
return ready(null, null, null, now);
|
|
301
303
|
const workspace = basename(cwd);
|
|
304
|
+
const cardOpenedAt = readThreadPointer(env, thread)?.cardOpenedAt ?? null;
|
|
302
305
|
// Every saved state lives under `.litcodex`; a symlink there would point the card at foreign files.
|
|
303
306
|
if (!plainDirs(cwd, ".litcodex"))
|
|
304
|
-
return ready(thread, workspace, now);
|
|
307
|
+
return ready(thread, workspace, cardOpenedAt, now);
|
|
305
308
|
const turn = workflowTurn(cwd, thread);
|
|
306
309
|
if (turn === null)
|
|
307
|
-
return ready(thread, workspace, now);
|
|
310
|
+
return ready(thread, workspace, cardOpenedAt, now);
|
|
308
311
|
const signals = readWorkflowSignals(cwd, thread, now);
|
|
309
312
|
const drawn = workflowMapCells(turn.mode, signals);
|
|
310
313
|
const live = readLiveStep(cwd, thread);
|
|
@@ -340,6 +343,7 @@ export function readCardStatus(threadId, env, now = Date.now()) {
|
|
|
340
343
|
usage: readUsage(thread, env),
|
|
341
344
|
branch: readBranch(cwd),
|
|
342
345
|
workspace,
|
|
346
|
+
cardOpenedAt,
|
|
343
347
|
now,
|
|
344
348
|
};
|
|
345
349
|
}
|
|
@@ -21,8 +21,11 @@ export interface AutoHandoffHookOptions {
|
|
|
21
21
|
readonly env?: NodeJS.ProcessEnv;
|
|
22
22
|
readonly now?: number;
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
25
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Asks the model to open the LIT card for this LIT turn, so the live card sits next to the newest turn
|
|
26
|
+
* instead of scrolling away with the first one. In the terminal `codex` the same tool returns the map as text.
|
|
27
|
+
*/
|
|
28
|
+
export declare const CARD_OFFER_CONTEXT = "LIT card: if the `lit_card` tool (litcodex MCP server) is available, call the `lit_card` tool once now, with no arguments, so the user sees the live LIT card for this turn. It replaces the previous turn's card, which folds itself into one line. Do not call it again in this turn; it updates by itself.";
|
|
26
29
|
/** Injectable Jev dependencies; production uses the process environment and built-in `fetch`. */
|
|
27
30
|
export interface JevHookOptions {
|
|
28
31
|
readonly env?: NodeJS.ProcessEnv;
|
|
@@ -14,7 +14,7 @@ import { claimReloadContext, evaluateAutoHandoffStop, recordCompaction, takeRelo
|
|
|
14
14
|
import { applyAutoHandoffRoute, clearManagedCompactionWhenOff, parseAutoHandoffRoute, } from "./auto-handoff-settings.js";
|
|
15
15
|
import { applyPreToolUseCreateGoalGuard, isLitUserPromptSubmitInput, runUserPromptSubmitHook } from "./codex-hook.js";
|
|
16
16
|
import { claimJevOnBanner, formatJevHookOutput, jevSwitchState, runJevSkillHint, withJevBanner, } from "./jev-hint.js";
|
|
17
|
-
import { endLiveStep,
|
|
17
|
+
import { endLiveStep, recordLiveStepEnd, recordLiveStepStart, recordTurnStart, writeThreadPointer, } from "./live-step.js";
|
|
18
18
|
import { evaluatePlanPersistence, formatStopBlockOutput, recordLitPlanActivation } from "./plan-persistence.js";
|
|
19
19
|
import { recordWorkflowTurn, workflowMapLine, workflowStopLine, workflowTurn } from "./workflow-map.js";
|
|
20
20
|
/** Hard cap on stdin to bound memory / ReDoS exposure inside the 5 s Codex hook budget. 8 MB. */
|
|
@@ -200,21 +200,20 @@ function withWorkflowMap(stdout, parsed, mode) {
|
|
|
200
200
|
return stdout;
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
-
/**
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
/** Add the card request to
|
|
203
|
+
/**
|
|
204
|
+
* Asks the model to open the LIT card for this LIT turn, so the live card sits next to the newest turn
|
|
205
|
+
* instead of scrolling away with the first one. In the terminal `codex` the same tool returns the map as text.
|
|
206
|
+
*/
|
|
207
|
+
export const CARD_OFFER_CONTEXT = "LIT card: if the `lit_card` tool (litcodex MCP server) is available, call the `lit_card` tool once now, with no arguments, so the user sees the live LIT card for this turn. It replaces the previous turn's card, which folds itself into one line. Do not call it again in this turn; it updates by itself.";
|
|
208
|
+
/** Add the card request to every LIT activation, and remember when it was last made. */
|
|
209
209
|
function withCardOffer(stdout, scope, auto) {
|
|
210
|
-
|
|
211
|
-
if (scope === null || stdout === "" || offered(env, scope.sessionId))
|
|
210
|
+
if (scope === null || stdout === "")
|
|
212
211
|
return stdout;
|
|
213
212
|
const merged = withReloadContext(stdout, CARD_OFFER_CONTEXT);
|
|
214
213
|
if (merged === null)
|
|
215
214
|
return stdout;
|
|
216
|
-
writeThreadPointer(env, scope.sessionId, scope.cwd, auto.now, { cardOffered: true });
|
|
217
|
-
return
|
|
215
|
+
writeThreadPointer(auto.env ?? process.env, scope.sessionId, scope.cwd, auto.now, { cardOffered: true });
|
|
216
|
+
return merged;
|
|
218
217
|
}
|
|
219
218
|
function isRecord(value) {
|
|
220
219
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -12,6 +12,8 @@ export interface ThreadPointer {
|
|
|
12
12
|
readonly cwd: string;
|
|
13
13
|
readonly updatedAt: number;
|
|
14
14
|
readonly cardOfferedAt: number | null;
|
|
15
|
+
/** When the `lit_card` tool last opened a card in this thread; the newest card is the live one. */
|
|
16
|
+
readonly cardOpenedAt: number | null;
|
|
15
17
|
}
|
|
16
18
|
export interface ToolRef {
|
|
17
19
|
readonly tool: string;
|
|
@@ -53,7 +55,13 @@ export declare function endLiveStep(repoRoot: string, sessionId: string, now?: n
|
|
|
53
55
|
export declare function codexHomeFrom(env: NodeJS.ProcessEnv): string | null;
|
|
54
56
|
export declare function threadPointerPath(env: NodeJS.ProcessEnv, threadId: string): string | null;
|
|
55
57
|
export declare function readThreadPointer(env: NodeJS.ProcessEnv, threadId: string): ThreadPointer | null;
|
|
56
|
-
/** Point the thread at `cwd
|
|
58
|
+
/** Point the thread at `cwd`, keeping the card times it already holds; skips the write when nothing changes. */
|
|
57
59
|
export declare function writeThreadPointer(env: NodeJS.ProcessEnv, threadId: string, cwd: string, now?: number, options?: {
|
|
58
60
|
readonly cardOffered?: boolean;
|
|
61
|
+
readonly cardOpened?: boolean;
|
|
59
62
|
}): void;
|
|
63
|
+
/**
|
|
64
|
+
* Remember that a card opened in this thread now, so every poll can tell the older cards to fold. Only a
|
|
65
|
+
* thread the hooks already pointed at a workspace is recorded; returns the time recorded, or null.
|
|
66
|
+
*/
|
|
67
|
+
export declare function recordCardOpened(env: NodeJS.ProcessEnv, threadId: string, now?: number): number | null;
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
// clears it. It also says whether the turn is still open: a LIT prompt opens it and Stop closes it, so
|
|
6
6
|
// the card can tell a model that is thinking between tools from one that has answered and waits. The pointer lives in the Codex home the hook sees (`litcodex/lit-loop/threads/<session>.json`)
|
|
7
7
|
// and maps a session id, which the desktop app also sends as its thread id, to the hook's `cwd`, because
|
|
8
|
-
// the card server is started in the plugin folder and learns nothing else about the thread.
|
|
8
|
+
// the card server is started in the plugin folder and learns nothing else about the thread. The pointer
|
|
9
|
+
// also keeps when the newest card of the thread opened, so an older card can fold itself away. Every write
|
|
9
10
|
// is atomic, skips symlinked folders and never throws; every read is size-capped and refuses symlinks.
|
|
10
11
|
import { randomBytes } from "node:crypto";
|
|
11
12
|
import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readSync, renameSync, rmSync, writeFileSync, } from "node:fs";
|
|
@@ -263,12 +264,13 @@ export function readThreadPointer(env, threadId) {
|
|
|
263
264
|
const record = readSmallJson(path);
|
|
264
265
|
if (!isRecord(record) || record["version"] !== 1)
|
|
265
266
|
return null;
|
|
266
|
-
const { cwd, updatedAt, cardOfferedAt } = record;
|
|
267
|
+
const { cwd, updatedAt, cardOfferedAt, cardOpenedAt } = record;
|
|
267
268
|
if (typeof cwd !== "string" || !isAbsolute(cwd) || typeof updatedAt !== "number")
|
|
268
269
|
return null;
|
|
269
|
-
|
|
270
|
+
const time = (value) => (typeof value === "number" && Number.isFinite(value) ? value : null);
|
|
271
|
+
return { cwd, updatedAt, cardOfferedAt: time(cardOfferedAt), cardOpenedAt: time(cardOpenedAt) };
|
|
270
272
|
}
|
|
271
|
-
/** Point the thread at `cwd
|
|
273
|
+
/** Point the thread at `cwd`, keeping the card times it already holds; skips the write when nothing changes. */
|
|
272
274
|
export function writeThreadPointer(env, threadId, cwd, now = Date.now(), options = {}) {
|
|
273
275
|
const path = threadPointerPath(env, threadId);
|
|
274
276
|
const home = codexHomeFrom(env);
|
|
@@ -276,12 +278,28 @@ export function writeThreadPointer(env, threadId, cwd, now = Date.now(), options
|
|
|
276
278
|
return;
|
|
277
279
|
const current = readThreadPointer(env, threadId);
|
|
278
280
|
const cardOfferedAt = options.cardOffered === true ? now : (current?.cardOfferedAt ?? null);
|
|
279
|
-
|
|
281
|
+
const cardOpenedAt = options.cardOpened === true ? now : (current?.cardOpenedAt ?? null);
|
|
282
|
+
if (current !== null &&
|
|
283
|
+
current.cwd === cwd &&
|
|
284
|
+
current.cardOfferedAt === cardOfferedAt &&
|
|
285
|
+
current.cardOpenedAt === cardOpenedAt)
|
|
280
286
|
return;
|
|
281
287
|
writeRecord(home, POINTER_DIR, basename(path), {
|
|
282
288
|
version: 1,
|
|
283
289
|
cwd,
|
|
284
290
|
updatedAt: now,
|
|
285
291
|
cardOfferedAt,
|
|
292
|
+
cardOpenedAt,
|
|
286
293
|
});
|
|
287
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* Remember that a card opened in this thread now, so every poll can tell the older cards to fold. Only a
|
|
297
|
+
* thread the hooks already pointed at a workspace is recorded; returns the time recorded, or null.
|
|
298
|
+
*/
|
|
299
|
+
export function recordCardOpened(env, threadId, now = Date.now()) {
|
|
300
|
+
const current = readThreadPointer(env, threadId);
|
|
301
|
+
if (current === null)
|
|
302
|
+
return null;
|
|
303
|
+
writeThreadPointer(env, threadId, current.cwd, now, { cardOpened: true });
|
|
304
|
+
return readThreadPointer(env, threadId)?.cardOpenedAt === now ? now : null;
|
|
305
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@litcodex/lit-loop",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.25",
|
|
4
4
|
"description": "LitCodex Lit-Loop runtime: durable repo-native multi-goal orchestration with embedded success criteria and observable evidence audit.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": true,
|
|
@@ -400,11 +400,14 @@ function isInternalPath(path) {
|
|
|
400
400
|
/^handoff(?:$|[-_.])/iu.test(segment) ||
|
|
401
401
|
/^(?:ledgers?|status)(?:\.[^/]*)?$/iu.test(segment));
|
|
402
402
|
}
|
|
403
|
+
const BOLD_LABEL_CALLOUT = /^\s{0,3}>\s?(?:\*\*|__)[^*_\n]{1,24}(?:\*\*|__)/u;
|
|
403
404
|
function maskQuotedUserText(text) {
|
|
404
405
|
return text
|
|
405
406
|
.split("\n")
|
|
406
407
|
.map((line) => {
|
|
407
|
-
|
|
408
|
+
// A quote is skipped, except one that opens with a bold label (> **Note:** ...): that is the author's own
|
|
409
|
+
// callout, so it reaches the detector, which reads it for the rules that opt in.
|
|
410
|
+
if (/^\s{0,3}>/u.test(line) && !BOLD_LABEL_CALLOUT.test(line))
|
|
408
411
|
return "";
|
|
409
412
|
return line
|
|
410
413
|
.replace(/"(?:\\.|[^"\\])*"/gu, " ")
|
|
@@ -414,6 +417,24 @@ function maskQuotedUserText(text) {
|
|
|
414
417
|
})
|
|
415
418
|
.join("\n");
|
|
416
419
|
}
|
|
420
|
+
const REASON_RULE_LIMIT = 5;
|
|
421
|
+
const REASON_LINE_LIMIT = 3;
|
|
422
|
+
/** Names each blocking rule once, with its first few line numbers, so a refusal says which rule fired. */
|
|
423
|
+
function blockedRuleSummary(blocks) {
|
|
424
|
+
const linesByRule = new Map();
|
|
425
|
+
for (const item of blocks) {
|
|
426
|
+
const lines = linesByRule.get(item.rule) ?? [];
|
|
427
|
+
if (!lines.includes(item.line))
|
|
428
|
+
lines.push(item.line);
|
|
429
|
+
linesByRule.set(item.rule, lines);
|
|
430
|
+
}
|
|
431
|
+
const named = [...linesByRule].slice(0, REASON_RULE_LIMIT).map(([rule, lines]) => {
|
|
432
|
+
const shown = lines.slice(0, REASON_LINE_LIMIT).join(", ");
|
|
433
|
+
return `${rule} (line ${shown}${lines.length > REASON_LINE_LIMIT ? ", ..." : ""})`;
|
|
434
|
+
});
|
|
435
|
+
const hidden = linesByRule.size - named.length;
|
|
436
|
+
return hidden > 0 ? `${named.join("; ")}; ${hidden} more rule(s)` : named.join("; ");
|
|
437
|
+
}
|
|
417
438
|
function findingsOutput(event, findings, files) {
|
|
418
439
|
if (findings.length === 0)
|
|
419
440
|
return "";
|
|
@@ -429,7 +450,7 @@ function findingsOutput(event, findings, files) {
|
|
|
429
450
|
if (event === "PreToolUse" && blocks.length > 0) {
|
|
430
451
|
hookSpecificOutput["permissionDecision"] = "deny";
|
|
431
452
|
hookSpecificOutput["permissionDecisionReason"] =
|
|
432
|
-
`lit-humanizer blocked ${blocks.length} high-confidence drafting residue hit(s).`;
|
|
453
|
+
`lit-humanizer blocked ${blocks.length} high-confidence drafting residue hit(s): ${blockedRuleSummary(blocks)}. Rewrite those lines and retry.`;
|
|
433
454
|
}
|
|
434
455
|
return JSON.stringify({ hookSpecificOutput });
|
|
435
456
|
}
|