context-mode 1.0.72 → 1.0.73
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/.openclaw-plugin/openclaw.plugin.json +1 -1
- package/.openclaw-plugin/package.json +1 -1
- package/build/session/analytics.js +15 -3
- package/cli.bundle.mjs +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/server.bundle.mjs +14 -14
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
},
|
|
7
7
|
"metadata": {
|
|
8
8
|
"description": "Claude Code plugins by Mert Koseoğlu",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.73"
|
|
10
10
|
},
|
|
11
11
|
"plugins": [
|
|
12
12
|
{
|
|
13
13
|
"name": "context-mode",
|
|
14
14
|
"source": "./",
|
|
15
15
|
"description": "Claude Code MCP plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
|
|
16
|
-
"version": "1.0.
|
|
16
|
+
"version": "1.0.73",
|
|
17
17
|
"author": {
|
|
18
18
|
"name": "Mert Koseoğlu"
|
|
19
19
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "context-mode",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.73",
|
|
4
4
|
"description": "MCP server that saves 98% of your context window with session continuity. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and automatic state restore across compactions.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mert Koseoğlu",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "Context Mode",
|
|
4
4
|
"kind": "tool",
|
|
5
5
|
"description": "OpenClaw plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.73",
|
|
7
7
|
"sandbox": {
|
|
8
8
|
"mode": "permissive",
|
|
9
9
|
"filesystem_access": "full",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "context-mode",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.73",
|
|
4
4
|
"description": "OpenClaw plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mert Koseoğlu",
|
|
@@ -320,12 +320,24 @@ export function formatReport(report, version, latestVersion) {
|
|
|
320
320
|
lines.push(` ${t.tool.padEnd(22)} ${callLabel.padEnd(10)} ${kb(returned)} used`);
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
-
// ──
|
|
323
|
+
// ── Session continuity breakdown ──
|
|
324
|
+
if (report.continuity.by_category.length > 0) {
|
|
325
|
+
lines.push("");
|
|
326
|
+
lines.push(`Session continuity: ${report.continuity.total_events} events preserved across ${report.continuity.compact_count} compaction${report.continuity.compact_count !== 1 ? "s" : ""}`);
|
|
327
|
+
lines.push("");
|
|
328
|
+
for (const c of report.continuity.by_category) {
|
|
329
|
+
const cat = c.category.padEnd(9);
|
|
330
|
+
const count = String(c.count).padStart(3);
|
|
331
|
+
const preview = c.preview.length > 45 ? c.preview.slice(0, 42) + "..." : c.preview;
|
|
332
|
+
lines.push(` ${cat} ${count} ${preview.padEnd(47)} ${c.why}`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
// ── Footer: version + outdated warning ──
|
|
324
336
|
const footerParts = [];
|
|
325
|
-
if (report.continuity.compact_count > 0) {
|
|
337
|
+
if (report.continuity.by_category.length === 0 && report.continuity.compact_count > 0) {
|
|
326
338
|
footerParts.push(`${report.continuity.compact_count} compaction${report.continuity.compact_count !== 1 ? "s" : ""}`);
|
|
327
339
|
}
|
|
328
|
-
if (report.continuity.total_events > 0) {
|
|
340
|
+
if (report.continuity.by_category.length === 0 && report.continuity.total_events > 0) {
|
|
329
341
|
footerParts.push(`${report.continuity.total_events} event${report.continuity.total_events !== 1 ? "s" : ""} preserved`);
|
|
330
342
|
}
|
|
331
343
|
const versionStr = version ? `v${version}` : "context-mode";
|
package/cli.bundle.mjs
CHANGED
|
@@ -336,7 +336,7 @@ ${n}
|
|
|
336
336
|
|
|
337
337
|
stderr:
|
|
338
338
|
${o}`}}var hk=b(()=>{"use strict"});function KN(){let t=process.ppid;return!(t!==GN||t===0||t===1)}function gk(t){let e=t.checkIntervalMs??3e4,r=t.isParentAlive??KN,n=!1,o=()=>{n||(n=!0,t.onShutdown())},s=setInterval(()=>{r()||o()},e);s.unref();let i=()=>o();process.stdin.resume(),process.stdin.on("end",i),process.stdin.on("close",i),process.stdin.on("error",i);let a=["SIGTERM","SIGINT"];process.platform!=="win32"&&a.push("SIGHUP");for(let c of a)process.on(c,o);return()=>{n=!0,clearInterval(s),process.stdin.removeListener("end",i),process.stdin.removeListener("close",i),process.stdin.removeListener("error",i);for(let c of a)process.removeListener(c,o)}}var GN,_k=b(()=>{"use strict";GN=process.ppid});import{createHash as JN}from"node:crypto";import{execFileSync as YN}from"node:child_process";function kh(){let t=process.env.CONTEXT_MODE_SESSION_SUFFIX;if(t!==void 0)return t?`__${t}`:"";try{let e=process.cwd(),r=YN("git",["worktree","list","--porcelain"],{encoding:"utf-8",timeout:2e3,stdio:["ignore","pipe","ignore"]}).split(/\r?\n/).find(n=>n.startsWith("worktree "))?.replace("worktree ","")?.trim();if(r&&e!==r)return`__${JN("sha256").update(e).digest("hex").slice(0,8)}`}catch{}return""}var yk=b(()=>{"use strict";ii()});function ai(t){return t>=1024*1024?`${(t/1024/1024).toFixed(1)} MB`:t>=1024?`${(t/1024).toFixed(1)} KB`:`${t} B`}function ej(t){let e=parseFloat(t);if(isNaN(e)||e<1)return"< 1 min";if(e<60)return`${Math.round(e)} min`;let r=Math.floor(e/60),n=Math.round(e%60);return n>0?`${r}h ${n}m`:`${r}h`}function tj(t,e){let n="#".repeat(40),o=t>0?Math.max(1,Math.round(e/t*40)):40,s="#".repeat(o)+" ".repeat(40-o);return{withoutBar:n,withBar:s}}function Nc(t,e,r){let n=[],o=ej(t.session.uptime_min),s=t.savings.kept_out+(t.cache?t.cache.bytes_saved:0),i=t.savings.total_bytes_returned,a=t.savings.total_calls;if(s===0){if(n.push(`context-mode -- session (${o})`),n.push(""),a===0)n.push("No tool calls yet.");else{let _=a===1?"1 tool call":`${a} tool calls`;n.push(`${_} | ${ai(i)} in context | no savings yet`)}return n.push(""),n.push("Tip: Use ctx_execute to analyze files in sandbox -- savings start there."),n.push(""),n.push(e?`v${e}`:"context-mode"),e&&r&&r!=="unknown"&&r!==e&&n.push(`Update available: v${e} -> v${r} | Run: ctx_upgrade`),n.join(`
|
|
339
|
-
`)}let c=s+i,u=c>0?(s/c*100).toFixed(1):"0.0",l=Math.round(s/4/1e3);n.push(`context-mode -- session (${o})`),n.push("");let{withoutBar:d,withBar:m}=tj(c,i);n.push(`Without context-mode: |${d}| ${ai(c)} in your conversation`),n.push(`With context-mode: |${m}| ${ai(i)} in your conversation`),n.push("");let f=`${ai(s)} processed in sandbox, never entered your conversation. (${u}% reduction)`;if(n.push(f),l>0){let _=l>=60?`+${Math.floor(l/60)}h ${l%60}m`:`+${l}m`;n.push(`${_} session time gained.`)}let p=t.savings.by_tool.filter(_=>_.calls>0);if(p.length>=2){n.push("");for(let _ of p){let y=_.context_kb*1024,x=`${_.calls} call${_.calls!==1?"s":""}`;n.push(` ${_.tool.padEnd(22)} ${x.padEnd(10)} ${ai(y)} used`)}}let h=[];t.continuity.compact_count>0&&h.push(`${t.continuity.compact_count} compaction${t.continuity.compact_count!==1?"s":""}`),t.continuity.total_events>0&&h.push(`${t.continuity.total_events} event${t.continuity.total_events!==1?"s":""} preserved`);let g=e?`v${e}`:"context-mode";return h.push(g),n.push(""),n.push(h.join(" | ")),e&&r&&r!=="unknown"&&r!==e&&n.push(`Update available: v${e} -> v${r} | Run: ctx_upgrade`),n.join(`
|
|
339
|
+
`)}let c=s+i,u=c>0?(s/c*100).toFixed(1):"0.0",l=Math.round(s/4/1e3);n.push(`context-mode -- session (${o})`),n.push("");let{withoutBar:d,withBar:m}=tj(c,i);n.push(`Without context-mode: |${d}| ${ai(c)} in your conversation`),n.push(`With context-mode: |${m}| ${ai(i)} in your conversation`),n.push("");let f=`${ai(s)} processed in sandbox, never entered your conversation. (${u}% reduction)`;if(n.push(f),l>0){let _=l>=60?`+${Math.floor(l/60)}h ${l%60}m`:`+${l}m`;n.push(`${_} session time gained.`)}let p=t.savings.by_tool.filter(_=>_.calls>0);if(p.length>=2){n.push("");for(let _ of p){let y=_.context_kb*1024,x=`${_.calls} call${_.calls!==1?"s":""}`;n.push(` ${_.tool.padEnd(22)} ${x.padEnd(10)} ${ai(y)} used`)}}if(t.continuity.by_category.length>0){n.push(""),n.push(`Session continuity: ${t.continuity.total_events} events preserved across ${t.continuity.compact_count} compaction${t.continuity.compact_count!==1?"s":""}`),n.push("");for(let _ of t.continuity.by_category){let y=_.category.padEnd(9),x=String(_.count).padStart(3),$=_.preview.length>45?_.preview.slice(0,42)+"...":_.preview;n.push(` ${y} ${x} ${$.padEnd(47)} ${_.why}`)}}let h=[];t.continuity.by_category.length===0&&t.continuity.compact_count>0&&h.push(`${t.continuity.compact_count} compaction${t.continuity.compact_count!==1?"s":""}`),t.continuity.by_category.length===0&&t.continuity.total_events>0&&h.push(`${t.continuity.total_events} event${t.continuity.total_events!==1?"s":""} preserved`);let g=e?`v${e}`:"context-mode";return h.push(g),n.push(""),n.push(h.join(" | ")),e&&r&&r!=="unknown"&&r!==e&&n.push(`Update available: v${e} -> v${r} | Run: ctx_upgrade`),n.join(`
|
|
340
340
|
`)}var XN,QN,jo,vk=b(()=>{"use strict";XN={file:"Files tracked",rule:"Project rules (CLAUDE.md)",prompt:"Your requests saved",mcp:"Plugin tools used",git:"Git operations",env:"Environment setup",error:"Errors caught",task:"Tasks in progress",decision:"Your decisions",cwd:"Working directory",skill:"Skills used",subagent:"Delegated work",intent:"Session mode",data:"Data references",role:"Behavioral directives"},QN={file:"Restored after compact \u2014 no need to re-read",rule:"Your project instructions survive context resets",prompt:"Continues exactly where you left off",decision:"Applied automatically \u2014 won\u2019t ask again",task:"Picks up from where it stopped",error:"Tracked and monitored across compacts",git:"Branch, commit, and repo state preserved",env:"Runtime config carried forward",mcp:"Tool usage patterns remembered",subagent:"Delegation history preserved",skill:"Skill invocations tracked"},jo=class{db;constructor(e){this.db=e}static contextSavingsTotal(e,r){let n=e-r,o=e>0?Math.round(n/e*1e3)/10:0;return{rawBytes:e,contextBytes:r,savedBytes:n,savedPercent:o}}static thinkInCodeComparison(e,r){let n=r>0?Math.round(e/r*10)/10:0;return{fileBytes:e,outputBytes:r,ratio:n}}static toolSavings(e){return e.map(r=>({...r,savedBytes:r.rawBytes-r.contextBytes}))}static sandboxIO(e,r){return{inputBytes:e,outputBytes:r}}queryAll(e){let n=this.db.prepare("SELECT session_id FROM session_meta ORDER BY started_at DESC LIMIT 1").get()?.session_id??"",o=Object.values(e.bytesReturned).reduce((z,Pe)=>z+Pe,0),s=Object.values(e.calls).reduce((z,Pe)=>z+Pe,0),i=e.bytesIndexed+e.bytesSandboxed,a=i+o,c=a/Math.max(o,1),u=a>0?Math.round((1-o/a)*100):0,l=new Set([...Object.keys(e.calls),...Object.keys(e.bytesReturned)]),d=Array.from(l).sort().map(z=>({tool:z,calls:e.calls[z]||0,context_kb:Math.round((e.bytesReturned[z]||0)/1024*10)/10,tokens:Math.round((e.bytesReturned[z]||0)/4)})),f=((Date.now()-e.sessionStart)/6e4).toFixed(1),p;if(e.cacheHits>0||e.cacheBytesSaved>0){let z=a+e.cacheBytesSaved,Pe=z/Math.max(o,1),pe=Math.max(0,24-Math.floor((Date.now()-e.sessionStart)/(3600*1e3)));p={hits:e.cacheHits,bytes_saved:e.cacheBytesSaved,ttl_hours_left:pe,total_with_cache:z,total_savings_ratio:Pe}}let h=this.db.prepare("SELECT COUNT(*) as cnt FROM session_events").get().cnt,g=this.db.prepare("SELECT category, COUNT(*) as cnt FROM session_events GROUP BY category ORDER BY cnt DESC").all(),y=this.db.prepare("SELECT compact_count FROM session_meta ORDER BY started_at DESC LIMIT 1").get()?.compact_count??0,x=this.db.prepare("SELECT event_count, consumed FROM session_resume ORDER BY created_at DESC LIMIT 1").get(),$=x?!x.consumed:!1,T=this.db.prepare("SELECT category, type, data FROM session_events ORDER BY id DESC").all(),Q=new Map;for(let z of T){Q.has(z.category)||Q.set(z.category,new Set);let Pe=Q.get(z.category);if(Pe.size<5){let pe=z.data;z.category==="file"?pe=z.data.split("/").pop()||z.data:z.category==="prompt"&&(pe=pe.length>50?pe.slice(0,47)+"...":pe),pe.length>40&&(pe=pe.slice(0,37)+"..."),Pe.add(pe)}}let q=g.map(z=>({category:z.category,count:z.cnt,label:XN[z.category]||z.category,preview:Q.get(z.category)?Array.from(Q.get(z.category)).join(", "):"",why:QN[z.category]||"Survives context resets"}));return{savings:{processed_kb:Math.round(a/1024*10)/10,entered_kb:Math.round(o/1024*10)/10,saved_kb:Math.round(i/1024*10)/10,pct:u,savings_ratio:Math.round(c*10)/10,by_tool:d,total_calls:s,total_bytes_returned:o,kept_out:i,total_processed:a},cache:p,session:{id:n,uptime_min:f},continuity:{total_events:h,by_category:q,compact_count:y,resume_ready:$}}}}});var Ik={};De(Ik,{extractSnippet:()=>Ch,formatBatchQueryResults:()=>Ok,positionsFromHighlight:()=>Rk});import{createRequire as $k}from"node:module";import{createHash as rj}from"node:crypto";import{existsSync as yr,unlinkSync as zn,readdirSync as nj,readFileSync as wk,writeFileSync as oj,rmSync as sj,mkdirSync as Ek}from"node:fs";import{join as Rt,dirname as ci,resolve as Nn}from"node:path";import{fileURLToPath as ij}from"node:url";import{homedir as Ph,tmpdir as Tk}from"node:os";import{request as aj}from"node:https";function cj(t){try{let e=Hc();if(!yr(e))return;let r=nj(e).filter(n=>n.endsWith("-events.md"));for(let n of r){let o=Rt(e,n);try{t.index({path:o,source:"session-events"}),zn(o)}catch{}}}catch{}}function Hc(){if(Dc)return Dc.getSessionDir();let t=Rt(Ph(),".claude","context-mode","sessions");return Ek(t,{recursive:!0}),t}function uj(){return process.env.CLAUDE_PROJECT_DIR||process.env.GEMINI_PROJECT_DIR||process.env.VSCODE_CWD||process.env.OPENCODE_PROJECT_DIR||process.env.PI_PROJECT_DIR||process.env.CONTEXT_MODE_PROJECT_DIR||process.cwd()}function Lc(){let e=uj().replace(/\\/g,"/");return rj("sha256").update(e).digest("hex").slice(0,16)}function Th(){let t=Lc(),e=Hc(),r=Rt(ci(e),"content");return Ek(r,{recursive:!0}),Rt(r,`${t}.db`)}function Mn(){if(!or){let t=Th();or=new zc(t);try{let e=ci(Th());yh(e,14),or.cleanupStaleSources(14);let r=Rt(Ph(),".context-mode","content");yr(r)&&yh(r,0)}catch{}_h()}return cj(or),or}async function pj(){return new Promise(t=>{let e=aj("https://registry.npmjs.org/context-mode/latest",{headers:{Connection:"close"}},r=>{let n="";r.on("data",o=>{n+=o}),r.on("end",()=>{try{let o=JSON.parse(n);t(o.version??"unknown")}catch{t("unknown")}})});e.on("error",()=>t("unknown")),e.setTimeout(5e3,()=>{e.destroy(),t("unknown")}),e.end()})}function mj(){let t=Dc?.name;return t==="Claude Code"?"/ctx-upgrade":t==="OpenClaw"?"npm run install:openclaw":t==="Pi"?"npm run build":"npm update -g context-mode"}function fj(){return!Br||Br==="unknown"?!1:Br!==qr}function hj(){if(!fj())return!1;let t=Date.now();if(jc>=lj){if(t-xk<dj)return!1;jc=0}return jc===0&&(xk=t),jc++,!0}function B(t,e){if(hj()&&e.content.length>0){let n=mj();e.content[0].text=`\u26A0\uFE0F context-mode v${qr} outdated \u2192 v${Br} available. Upgrade: ${n}
|
|
341
341
|
|
|
342
342
|
`+e.content[0].text}let r=e.content.reduce((n,o)=>n+Buffer.byteLength(o.text),0);return Ae.calls[t]=(Ae.calls[t]||0)+1,Ae.bytesReturned[t]=(Ae.bytesReturned[t]||0)+r,e}function Ut(t){Ae.bytesIndexed+=t}function Oh(t,e){try{let r=xh(process.env.CLAUDE_PROJECT_DIR),n=bh(t,r);if(n.decision==="deny")return B(e,{content:[{type:"text",text:`Command blocked by security policy: matches deny pattern ${n.matchedPattern}`}],isError:!0})}catch{}return null}function Pk(t,e,r){try{let n=mk(t,e);if(n.length===0)return null;let o=xh(process.env.CLAUDE_PROJECT_DIR);for(let s of n){let i=bh(s,o);if(i.decision==="deny")return B(r,{content:[{type:"text",text:`Command blocked by security policy: embedded shell command "${s}" matches deny pattern ${i.matchedPattern}`}],isError:!0})}}catch{}return null}function gj(t,e){try{let r=dk("Read",process.env.CLAUDE_PROJECT_DIR),n=pk(t,r);if(n.denied)return B(e,{content:[{type:"text",text:`File access blocked by security policy: path matches Read deny pattern ${n.matchedPattern}`}],isError:!0})}catch{}return null}function Rk(t){let e=[],r=0,n=0;for(;n<t.length;)if(t[n]===vj){for(e.push(r),n++;n<t.length&&t[n]!==xj;)r++,n++;n<t.length&&n++}else r++,n++;return e}function Ch(t,e,r=1500,n){if(t.length<=r)return t;let o=[];if(n)for(let u of Rk(n))o.push(u);if(o.length===0){let u=e.toLowerCase().split(/\s+/).filter(d=>d.length>2),l=t.toLowerCase();for(let d of u){let m=l.indexOf(d);for(;m!==-1;)o.push(m),m=l.indexOf(d,m+1)}}if(o.length===0)return t.slice(0,r)+`
|
package/openclaw.plugin.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "Context Mode",
|
|
4
4
|
"kind": "tool",
|
|
5
5
|
"description": "OpenClaw plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.73",
|
|
7
7
|
"sandbox": {
|
|
8
8
|
"mode": "permissive",
|
|
9
9
|
"filesystem_access": "full",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "context-mode",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.73",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "MCP plugin that saves 98% of your context window. Works with Claude Code, Gemini CLI, VS Code Copilot, OpenCode, and Codex CLI. Sandboxed code execution, FTS5 knowledge base, and intent-driven search.",
|
|
6
6
|
"author": "Mert Koseoğlu",
|