context-mode 1.0.26 → 1.0.27
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/cli.js +5 -5
- package/build/db-base.d.ts +15 -3
- package/build/db-base.js +96 -4
- package/build/server.js +2 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
|
@@ -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.27"
|
|
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.27",
|
|
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.27",
|
|
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.27",
|
|
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.27",
|
|
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",
|
package/build/cli.js
CHANGED
|
@@ -256,21 +256,21 @@ async function doctor() {
|
|
|
256
256
|
p.log.warn(color.yellow("Plugin enabled: WARN") +
|
|
257
257
|
` — ${pluginCheck.message}`);
|
|
258
258
|
}
|
|
259
|
-
// FTS5 /
|
|
260
|
-
p.log.step("Checking FTS5 /
|
|
259
|
+
// FTS5 / SQLite
|
|
260
|
+
p.log.step("Checking FTS5 / SQLite...");
|
|
261
261
|
try {
|
|
262
|
-
const Database = (await import("
|
|
262
|
+
const Database = (await import("./db-base.js")).loadDatabase();
|
|
263
263
|
const db = new Database(":memory:");
|
|
264
264
|
db.exec("CREATE VIRTUAL TABLE fts_test USING fts5(content)");
|
|
265
265
|
db.exec("INSERT INTO fts_test(content) VALUES ('hello world')");
|
|
266
266
|
const row = db.prepare("SELECT * FROM fts_test WHERE fts_test MATCH 'hello'").get();
|
|
267
267
|
db.close();
|
|
268
268
|
if (row && row.content === "hello world") {
|
|
269
|
-
p.log.success(color.green("FTS5 /
|
|
269
|
+
p.log.success(color.green("FTS5 / SQLite: PASS") + " — native module works");
|
|
270
270
|
}
|
|
271
271
|
else {
|
|
272
272
|
criticalFails++;
|
|
273
|
-
p.log.error(color.red("FTS5 /
|
|
273
|
+
p.log.error(color.red("FTS5 / SQLite: FAIL") + " — query returned unexpected result");
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
catch (err) {
|
package/build/db-base.d.ts
CHANGED
|
@@ -22,9 +22,21 @@ export interface PreparedStatement {
|
|
|
22
22
|
iterate(...params: unknown[]): IterableIterator<unknown>;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
|
|
25
|
+
* Wraps a bun:sqlite Database to provide better-sqlite3-compatible API.
|
|
26
|
+
* Bridges: .pragma(), multi-statement .exec(), .get() null→undefined.
|
|
27
|
+
*/
|
|
28
|
+
export declare class BunSQLiteAdapter {
|
|
29
|
+
#private;
|
|
30
|
+
constructor(rawDb: any);
|
|
31
|
+
pragma(source: string): any;
|
|
32
|
+
exec(sql: string): any;
|
|
33
|
+
prepare(sql: string): any;
|
|
34
|
+
transaction(fn: (...args: any[]) => any): any;
|
|
35
|
+
close(): void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Lazy-load better-sqlite3. Falls back to bun:sqlite via BunSQLiteAdapter
|
|
39
|
+
* when better-sqlite3 is unavailable (Bun runtime, issue #45).
|
|
28
40
|
*/
|
|
29
41
|
export declare function loadDatabase(): typeof DatabaseConstructor;
|
|
30
42
|
/**
|
package/build/db-base.js
CHANGED
|
@@ -10,18 +10,110 @@ import { unlinkSync } from "node:fs";
|
|
|
10
10
|
import { tmpdir } from "node:os";
|
|
11
11
|
import { join } from "node:path";
|
|
12
12
|
// ─────────────────────────────────────────────────────────
|
|
13
|
+
// bun:sqlite adapter (#45)
|
|
14
|
+
// ─────────────────────────────────────────────────────────
|
|
15
|
+
/**
|
|
16
|
+
* Wraps a bun:sqlite Database to provide better-sqlite3-compatible API.
|
|
17
|
+
* Bridges: .pragma(), multi-statement .exec(), .get() null→undefined.
|
|
18
|
+
*/
|
|
19
|
+
export class BunSQLiteAdapter {
|
|
20
|
+
#raw;
|
|
21
|
+
constructor(rawDb) {
|
|
22
|
+
this.#raw = rawDb;
|
|
23
|
+
}
|
|
24
|
+
pragma(source) {
|
|
25
|
+
const stmt = this.#raw.prepare(`PRAGMA ${source}`);
|
|
26
|
+
const rows = stmt.all();
|
|
27
|
+
if (!rows || rows.length === 0)
|
|
28
|
+
return undefined;
|
|
29
|
+
// Multi-row pragmas (table_xinfo, etc.) → return array
|
|
30
|
+
if (rows.length > 1)
|
|
31
|
+
return rows;
|
|
32
|
+
// Single-row: extract scalar value (e.g. journal_mode = "wal")
|
|
33
|
+
const values = Object.values(rows[0]);
|
|
34
|
+
return values.length === 1 ? values[0] : rows[0];
|
|
35
|
+
}
|
|
36
|
+
exec(sql) {
|
|
37
|
+
// bun:sqlite .exec() is single-statement only.
|
|
38
|
+
// Split multi-statement SQL respecting string literals (don't split on ; inside quotes).
|
|
39
|
+
let current = "";
|
|
40
|
+
let inString = null;
|
|
41
|
+
for (let i = 0; i < sql.length; i++) {
|
|
42
|
+
const ch = sql[i];
|
|
43
|
+
if (inString) {
|
|
44
|
+
current += ch;
|
|
45
|
+
if (ch === inString)
|
|
46
|
+
inString = null;
|
|
47
|
+
}
|
|
48
|
+
else if (ch === "'" || ch === '"') {
|
|
49
|
+
current += ch;
|
|
50
|
+
inString = ch;
|
|
51
|
+
}
|
|
52
|
+
else if (ch === ";") {
|
|
53
|
+
const trimmed = current.trim();
|
|
54
|
+
if (trimmed)
|
|
55
|
+
this.#raw.prepare(trimmed).run();
|
|
56
|
+
current = "";
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
current += ch;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const trimmed = current.trim();
|
|
63
|
+
if (trimmed)
|
|
64
|
+
this.#raw.prepare(trimmed).run();
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
prepare(sql) {
|
|
68
|
+
const stmt = this.#raw.prepare(sql);
|
|
69
|
+
return {
|
|
70
|
+
run: (...args) => stmt.run(...args),
|
|
71
|
+
get: (...args) => {
|
|
72
|
+
const r = stmt.get(...args);
|
|
73
|
+
return r === null ? undefined : r;
|
|
74
|
+
},
|
|
75
|
+
all: (...args) => stmt.all(...args),
|
|
76
|
+
iterate: (...args) => stmt.iterate(...args),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
transaction(fn) {
|
|
80
|
+
return this.#raw.transaction(fn);
|
|
81
|
+
}
|
|
82
|
+
close() {
|
|
83
|
+
this.#raw.close();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// ─────────────────────────────────────────────────────────
|
|
13
87
|
// Lazy loader
|
|
14
88
|
// ─────────────────────────────────────────────────────────
|
|
15
89
|
let _Database = null;
|
|
16
90
|
/**
|
|
17
|
-
* Lazy-load better-sqlite3.
|
|
18
|
-
*
|
|
19
|
-
* is not yet installed (marketplace first-run scenario).
|
|
91
|
+
* Lazy-load better-sqlite3. Falls back to bun:sqlite via BunSQLiteAdapter
|
|
92
|
+
* when better-sqlite3 is unavailable (Bun runtime, issue #45).
|
|
20
93
|
*/
|
|
21
94
|
export function loadDatabase() {
|
|
22
95
|
if (!_Database) {
|
|
23
96
|
const require = createRequire(import.meta.url);
|
|
24
|
-
|
|
97
|
+
try {
|
|
98
|
+
_Database = require("better-sqlite3");
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// better-sqlite3 unavailable (Bun runtime) — wrap bun:sqlite
|
|
102
|
+
if (!globalThis.Bun) {
|
|
103
|
+
throw new Error("better-sqlite3 failed to load and Bun runtime not detected");
|
|
104
|
+
}
|
|
105
|
+
// Compute module name at runtime to prevent esbuild from resolving at bundle time.
|
|
106
|
+
// esbuild constant-folds string concat but NOT Array.join().
|
|
107
|
+
const bunSqliteMod = ["bun", "sqlite"].join(":");
|
|
108
|
+
const BunDB = require(bunSqliteMod).Database;
|
|
109
|
+
_Database = function BunDatabaseFactory(path, opts) {
|
|
110
|
+
const raw = new BunDB(path, {
|
|
111
|
+
readonly: opts?.readonly,
|
|
112
|
+
create: true,
|
|
113
|
+
});
|
|
114
|
+
return new BunSQLiteAdapter(raw);
|
|
115
|
+
};
|
|
116
|
+
}
|
|
25
117
|
}
|
|
26
118
|
return _Database;
|
|
27
119
|
}
|
package/build/server.js
CHANGED
|
@@ -15,6 +15,7 @@ import { detectRuntimes, getRuntimeSummary, getAvailableLanguages, hasBunRuntime
|
|
|
15
15
|
import { classifyNonZeroExit } from "./exit-classify.js";
|
|
16
16
|
import { startLifecycleGuard } from "./lifecycle.js";
|
|
17
17
|
import { getWorktreeSuffix } from "./session/db.js";
|
|
18
|
+
import { loadDatabase } from "./db-base.js";
|
|
18
19
|
const __pkg_dir = dirname(fileURLToPath(import.meta.url));
|
|
19
20
|
const VERSION = (() => {
|
|
20
21
|
for (const rel of ["../package.json", "./package.json"]) {
|
|
@@ -1318,8 +1319,7 @@ server.registerTool("ctx_stats", {
|
|
|
1318
1319
|
const worktreeSuffix = getWorktreeSuffix();
|
|
1319
1320
|
const sessionDbPath = join(homedir(), ".claude", "context-mode", "sessions", `${dbHash}${worktreeSuffix}.db`);
|
|
1320
1321
|
if (existsSync(sessionDbPath)) {
|
|
1321
|
-
const
|
|
1322
|
-
const Database = require("better-sqlite3");
|
|
1322
|
+
const Database = loadDatabase();
|
|
1323
1323
|
const sdb = new Database(sessionDbPath, { readonly: true });
|
|
1324
1324
|
const eventTotal = sdb.prepare("SELECT COUNT(*) as cnt FROM session_events").get();
|
|
1325
1325
|
const byCategory = sdb.prepare("SELECT category, COUNT(*) as cnt FROM session_events GROUP BY category ORDER BY cnt DESC").all();
|
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.27",
|
|
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.27",
|
|
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",
|