You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

context-mode

Package Overview
Dependencies
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

context-mode - npm Package Compare versions

Comparing version
1.0.44
to
1.0.45
+2
-2
.claude-plugin/marketplace.json

@@ -9,3 +9,3 @@ {

"description": "Claude Code plugins by Mert Koseoğlu",
"version": "1.0.44"
"version": "1.0.45"
},

@@ -17,3 +17,3 @@ "plugins": [

"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.",
"version": "1.0.44",
"version": "1.0.45",
"author": {

@@ -20,0 +20,0 @@ "name": "Mert Koseoğlu"

{
"name": "context-mode",
"version": "1.0.44",
"version": "1.0.45",
"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,0 +5,0 @@ "author": {

@@ -6,3 +6,3 @@ {

"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.",
"version": "1.0.44",
"version": "1.0.45",
"sandbox": {

@@ -9,0 +9,0 @@ "mode": "permissive",

{
"name": "context-mode",
"version": "1.0.44",
"version": "1.0.45",
"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,0 +5,0 @@ "author": {

@@ -99,7 +99,9 @@ /**

const mod = require("better-sqlite3");
// Bun's require("better-sqlite3") doesn't throw — returns undefined (#163).
// Validate the result is a usable constructor before assigning.
// Bun's require("better-sqlite3") may return undefined, false, or a stub function
// that crashes on use (#163). Validate by actually instantiating a test database.
if (!mod || typeof mod !== "function") {
throw new Error("better-sqlite3 loaded but not usable (Bun compatibility issue)");
throw new Error("better-sqlite3 loaded but not usable");
}
const testDb = new mod(":memory:");
testDb.close();
_Database = mod;

@@ -106,0 +108,0 @@ }

@@ -1,2 +0,2 @@

import{createRequire as l}from"node:module";import{unlinkSync as g}from"node:fs";import{tmpdir as h}from"node:os";import{join as y}from"node:path";var E=class{#t;constructor(t){this.#t=t}pragma(t){let s=this.#t.prepare(`PRAGMA ${t}`).all();if(!s||s.length===0)return;if(s.length>1)return s;let i=Object.values(s[0]);return i.length===1?i[0]:s[0]}exec(t){let e="",s=null;for(let o=0;o<t.length;o++){let a=t[o];if(s)e+=a,a===s&&(s=null);else if(a==="'"||a==='"')e+=a,s=a;else if(a===";"){let d=e.trim();d&&this.#t.prepare(d).run(),e=""}else e+=a}let i=e.trim();return i&&this.#t.prepare(i).run(),this}prepare(t){let e=this.#t.prepare(t);return{run:(...s)=>e.run(...s),get:(...s)=>{let i=e.get(...s);return i===null?void 0:i},all:(...s)=>e.all(...s),iterate:(...s)=>e.iterate(...s)}}transaction(t){return this.#t.transaction(t)}close(){this.#t.close()}},c=null;function R(){if(!c){let r=l(import.meta.url);try{c=r("better-sqlite3")}catch{if(!globalThis.Bun)throw new Error("better-sqlite3 failed to load and Bun runtime not detected");let t=["bun","sqlite"].join(":"),e=r(t).Database;c=function(i,o){let a=new e(i,{readonly:o?.readonly,create:!0});return new E(a)}}}return c}function S(r){r.pragma("journal_mode = WAL"),r.pragma("synchronous = NORMAL")}function v(r){for(let t of["","-wal","-shm"])try{g(r+t)}catch{}}function m(r){try{r.pragma("wal_checkpoint(TRUNCATE)")}catch{}try{r.close()}catch{}}function p(r="context-mode"){return y(h(),`${r}-${process.pid}.db`)}var u=class{#t;#e;constructor(t){let e=R();this.#t=t,this.#e=new e(t,{timeout:5e3}),S(this.#e),this.initSchema(),this.prepareStatements()}get db(){return this.#e}get dbPath(){return this.#t}close(){m(this.#e)}cleanup(){m(this.#e),v(this.#t)}};import{createHash as T}from"node:crypto";import{execFileSync as L}from"node:child_process";function U(){let r=process.env.CONTEXT_MODE_SESSION_SUFFIX;if(r!==void 0)return r?`__${r}`:"";try{let t=process.cwd(),e=L("git",["worktree","list","--porcelain"],{encoding:"utf-8",timeout:2e3,stdio:["ignore","pipe","ignore"]}).split(/\r?\n/).find(s=>s.startsWith("worktree "))?.replace("worktree ","")?.trim();if(e&&t!==e)return`__${T("sha256").update(t).digest("hex").slice(0,8)}`}catch{}return""}var N=1e3,f=5,n={insertEvent:"insertEvent",getEvents:"getEvents",getEventsByType:"getEventsByType",getEventsByPriority:"getEventsByPriority",getEventsByTypeAndPriority:"getEventsByTypeAndPriority",getEventCount:"getEventCount",checkDuplicate:"checkDuplicate",evictLowestPriority:"evictLowestPriority",updateMetaLastEvent:"updateMetaLastEvent",ensureSession:"ensureSession",getSessionStats:"getSessionStats",incrementCompactCount:"incrementCompactCount",upsertResume:"upsertResume",getResume:"getResume",markResumeConsumed:"markResumeConsumed",deleteEvents:"deleteEvents",deleteMeta:"deleteMeta",deleteResume:"deleteResume",getOldSessions:"getOldSessions"},_=class extends u{constructor(t){super(t?.dbPath??p("session"))}stmt(t){return this.stmts.get(t)}initSchema(){try{let e=this.db.pragma("table_xinfo(session_events)").find(s=>s.name==="data_hash");e&&e.hidden!==0&&this.db.exec("DROP TABLE session_events")}catch{}this.db.exec(`
import{createRequire as T}from"node:module";import{unlinkSync as g}from"node:fs";import{tmpdir as h}from"node:os";import{join as y}from"node:path";var E=class{#t;constructor(t){this.#t=t}pragma(t){let s=this.#t.prepare(`PRAGMA ${t}`).all();if(!s||s.length===0)return;if(s.length>1)return s;let i=Object.values(s[0]);return i.length===1?i[0]:s[0]}exec(t){let e="",s=null;for(let o=0;o<t.length;o++){let a=t[o];if(s)e+=a,a===s&&(s=null);else if(a==="'"||a==='"')e+=a,s=a;else if(a===";"){let d=e.trim();d&&this.#t.prepare(d).run(),e=""}else e+=a}let i=e.trim();return i&&this.#t.prepare(i).run(),this}prepare(t){let e=this.#t.prepare(t);return{run:(...s)=>e.run(...s),get:(...s)=>{let i=e.get(...s);return i===null?void 0:i},all:(...s)=>e.all(...s),iterate:(...s)=>e.iterate(...s)}}transaction(t){return this.#t.transaction(t)}close(){this.#t.close()}},c=null;function R(){if(!c){let r=T(import.meta.url);try{let t=r("better-sqlite3");if(!t||typeof t!="function")throw new Error("better-sqlite3 loaded but not usable (Bun compatibility issue)");c=t}catch{if(!globalThis.Bun)throw new Error("better-sqlite3 failed to load and Bun runtime not detected");let t=["bun","sqlite"].join(":"),e=r(t).Database;c=function(i,o){let a=new e(i,{readonly:o?.readonly,create:!0});return new E(a)}}}return c}function S(r){r.pragma("journal_mode = WAL"),r.pragma("synchronous = NORMAL")}function v(r){for(let t of["","-wal","-shm"])try{g(r+t)}catch{}}function m(r){try{r.pragma("wal_checkpoint(TRUNCATE)")}catch{}try{r.close()}catch{}}function p(r="context-mode"){return y(h(),`${r}-${process.pid}.db`)}var u=class{#t;#e;constructor(t){let e=R();this.#t=t,this.#e=new e(t,{timeout:5e3}),S(this.#e),this.initSchema(),this.prepareStatements()}get db(){return this.#e}get dbPath(){return this.#t}close(){m(this.#e)}cleanup(){m(this.#e),v(this.#t)}};import{createHash as l}from"node:crypto";import{execFileSync as L}from"node:child_process";function U(){let r=process.env.CONTEXT_MODE_SESSION_SUFFIX;if(r!==void 0)return r?`__${r}`:"";try{let t=process.cwd(),e=L("git",["worktree","list","--porcelain"],{encoding:"utf-8",timeout:2e3,stdio:["ignore","pipe","ignore"]}).split(/\r?\n/).find(s=>s.startsWith("worktree "))?.replace("worktree ","")?.trim();if(e&&t!==e)return`__${l("sha256").update(t).digest("hex").slice(0,8)}`}catch{}return""}var N=1e3,f=5,n={insertEvent:"insertEvent",getEvents:"getEvents",getEventsByType:"getEventsByType",getEventsByPriority:"getEventsByPriority",getEventsByTypeAndPriority:"getEventsByTypeAndPriority",getEventCount:"getEventCount",checkDuplicate:"checkDuplicate",evictLowestPriority:"evictLowestPriority",updateMetaLastEvent:"updateMetaLastEvent",ensureSession:"ensureSession",getSessionStats:"getSessionStats",incrementCompactCount:"incrementCompactCount",upsertResume:"upsertResume",getResume:"getResume",markResumeConsumed:"markResumeConsumed",deleteEvents:"deleteEvents",deleteMeta:"deleteMeta",deleteResume:"deleteResume",getOldSessions:"getOldSessions"},_=class extends u{constructor(t){super(t?.dbPath??p("session"))}stmt(t){return this.stmts.get(t)}initSchema(){try{let e=this.db.pragma("table_xinfo(session_events)").find(s=>s.name==="data_hash");e&&e.hidden!==0&&this.db.exec("DROP TABLE session_events")}catch{}this.db.exec(`
CREATE TABLE IF NOT EXISTS session_events (

@@ -57,2 +57,2 @@ id INTEGER PRIMARY KEY AUTOINCREMENT,

created_at = datetime('now'),
consumed = 0`),t(n.getResume,"SELECT snapshot, event_count, consumed FROM session_resume WHERE session_id = ?"),t(n.markResumeConsumed,"UPDATE session_resume SET consumed = 1 WHERE session_id = ?"),t(n.deleteEvents,"DELETE FROM session_events WHERE session_id = ?"),t(n.deleteMeta,"DELETE FROM session_meta WHERE session_id = ?"),t(n.deleteResume,"DELETE FROM session_resume WHERE session_id = ?"),t(n.getOldSessions,"SELECT session_id FROM session_meta WHERE started_at < datetime('now', ? || ' days')")}insertEvent(t,e,s="PostToolUse"){let i=T("sha256").update(e.data).digest("hex").slice(0,16).toUpperCase();this.db.transaction(()=>{if(this.stmt(n.checkDuplicate).get(t,f,e.type,i))return;this.stmt(n.getEventCount).get(t).cnt>=N&&this.stmt(n.evictLowestPriority).run(t),this.stmt(n.insertEvent).run(t,e.type,e.category,e.priority,e.data,s,i),this.stmt(n.updateMetaLastEvent).run(t)})()}getEvents(t,e){let s=e?.limit??1e3,i=e?.type,o=e?.minPriority;return i&&o!==void 0?this.stmt(n.getEventsByTypeAndPriority).all(t,i,o,s):i?this.stmt(n.getEventsByType).all(t,i,s):o!==void 0?this.stmt(n.getEventsByPriority).all(t,o,s):this.stmt(n.getEvents).all(t,s)}getEventCount(t){return this.stmt(n.getEventCount).get(t).cnt}ensureSession(t,e){this.stmt(n.ensureSession).run(t,e)}getSessionStats(t){return this.stmt(n.getSessionStats).get(t)??null}incrementCompactCount(t){this.stmt(n.incrementCompactCount).run(t)}upsertResume(t,e,s){this.stmt(n.upsertResume).run(t,e,s??0)}getResume(t){return this.stmt(n.getResume).get(t)??null}markResumeConsumed(t){this.stmt(n.markResumeConsumed).run(t)}deleteSession(t){this.db.transaction(()=>{this.stmt(n.deleteEvents).run(t),this.stmt(n.deleteResume).run(t),this.stmt(n.deleteMeta).run(t)})()}cleanupOldSessions(t=7){let e=`-${t}`,s=this.stmt(n.getOldSessions).all(e);for(let{session_id:i}of s)this.deleteSession(i);return s.length}};export{_ as SessionDB,U as getWorktreeSuffix};
consumed = 0`),t(n.getResume,"SELECT snapshot, event_count, consumed FROM session_resume WHERE session_id = ?"),t(n.markResumeConsumed,"UPDATE session_resume SET consumed = 1 WHERE session_id = ?"),t(n.deleteEvents,"DELETE FROM session_events WHERE session_id = ?"),t(n.deleteMeta,"DELETE FROM session_meta WHERE session_id = ?"),t(n.deleteResume,"DELETE FROM session_resume WHERE session_id = ?"),t(n.getOldSessions,"SELECT session_id FROM session_meta WHERE started_at < datetime('now', ? || ' days')")}insertEvent(t,e,s="PostToolUse"){let i=l("sha256").update(e.data).digest("hex").slice(0,16).toUpperCase();this.db.transaction(()=>{if(this.stmt(n.checkDuplicate).get(t,f,e.type,i))return;this.stmt(n.getEventCount).get(t).cnt>=N&&this.stmt(n.evictLowestPriority).run(t),this.stmt(n.insertEvent).run(t,e.type,e.category,e.priority,e.data,s,i),this.stmt(n.updateMetaLastEvent).run(t)})()}getEvents(t,e){let s=e?.limit??1e3,i=e?.type,o=e?.minPriority;return i&&o!==void 0?this.stmt(n.getEventsByTypeAndPriority).all(t,i,o,s):i?this.stmt(n.getEventsByType).all(t,i,s):o!==void 0?this.stmt(n.getEventsByPriority).all(t,o,s):this.stmt(n.getEvents).all(t,s)}getEventCount(t){return this.stmt(n.getEventCount).get(t).cnt}ensureSession(t,e){this.stmt(n.ensureSession).run(t,e)}getSessionStats(t){return this.stmt(n.getSessionStats).get(t)??null}incrementCompactCount(t){this.stmt(n.incrementCompactCount).run(t)}upsertResume(t,e,s){this.stmt(n.upsertResume).run(t,e,s??0)}getResume(t){return this.stmt(n.getResume).get(t)??null}markResumeConsumed(t){this.stmt(n.markResumeConsumed).run(t)}deleteSession(t){this.db.transaction(()=>{this.stmt(n.deleteEvents).run(t),this.stmt(n.deleteResume).run(t),this.stmt(n.deleteMeta).run(t)})()}cleanupOldSessions(t=7){let e=`-${t}`,s=this.stmt(n.getOldSessions).all(e);for(let{session_id:i}of s)this.deleteSession(i);return s.length}};export{_ as SessionDB,U as getWorktreeSuffix};

@@ -6,3 +6,3 @@ {

"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.",
"version": "1.0.44",
"version": "1.0.45",
"sandbox": {

@@ -9,0 +9,0 @@ "mode": "permissive",

{
"name": "context-mode",
"version": "1.0.44",
"version": "1.0.45",
"type": "module",

@@ -5,0 +5,0 @@ "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.",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display