context-mode 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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +4 -2
- package/.openclaw-plugin/index.ts +11 -0
- package/.openclaw-plugin/openclaw.plugin.json +23 -0
- package/.openclaw-plugin/package.json +28 -0
- package/README.md +165 -26
- package/build/adapters/antigravity/index.d.ts +49 -0
- package/build/adapters/antigravity/index.js +217 -0
- package/build/adapters/client-map.d.ts +10 -0
- package/build/adapters/client-map.js +18 -0
- package/build/adapters/detect.d.ts +8 -1
- package/build/adapters/detect.js +58 -1
- package/build/adapters/kiro/hooks.d.ts +32 -0
- package/build/adapters/kiro/hooks.js +47 -0
- package/build/adapters/kiro/index.d.ts +50 -0
- package/build/adapters/kiro/index.js +325 -0
- package/build/adapters/openclaw/config.d.ts +8 -0
- package/build/adapters/openclaw/config.js +8 -0
- package/build/adapters/openclaw/hooks.d.ts +50 -0
- package/build/adapters/openclaw/hooks.js +61 -0
- package/build/adapters/openclaw/index.d.ts +51 -0
- package/build/adapters/openclaw/index.js +459 -0
- package/build/adapters/openclaw/session-db.d.ts +55 -0
- package/build/adapters/openclaw/session-db.js +88 -0
- package/build/adapters/types.d.ts +1 -1
- package/build/cli.js +5 -3
- package/build/executor.js +99 -112
- package/build/openclaw/workspace-router.d.ts +29 -0
- package/build/openclaw/workspace-router.js +64 -0
- package/build/openclaw-plugin.d.ts +121 -0
- package/build/openclaw-plugin.js +525 -0
- package/build/server.js +45 -10
- package/build/session/db.d.ts +9 -0
- package/build/session/db.js +38 -0
- package/cli.bundle.mjs +136 -124
- package/configs/antigravity/GEMINI.md +58 -0
- package/configs/antigravity/mcp_config.json +7 -0
- package/configs/kiro/mcp_config.json +7 -0
- package/configs/openclaw/AGENTS.md +58 -0
- package/configs/openclaw/openclaw.json +13 -0
- package/hooks/core/routing.mjs +16 -8
- package/hooks/kiro/posttooluse.mjs +58 -0
- package/hooks/kiro/pretooluse.mjs +63 -0
- package/hooks/posttooluse.mjs +6 -5
- package/hooks/precompact.mjs +5 -4
- package/hooks/session-db.bundle.mjs +57 -0
- package/hooks/session-extract.bundle.mjs +1 -0
- package/hooks/session-helpers.mjs +41 -3
- package/hooks/session-loaders.mjs +28 -0
- package/hooks/session-snapshot.bundle.mjs +14 -0
- package/hooks/sessionstart.mjs +6 -5
- package/hooks/userpromptsubmit.mjs +6 -5
- package/hooks/vscode-copilot/posttooluse.mjs +5 -4
- package/hooks/vscode-copilot/precompact.mjs +5 -4
- package/hooks/vscode-copilot/sessionstart.mjs +5 -4
- package/openclaw.plugin.json +23 -0
- package/package.json +13 -2
- package/server.bundle.mjs +94 -82
- package/start.mjs +1 -0
package/hooks/sessionstart.mjs
CHANGED
|
@@ -17,14 +17,15 @@ import "./suppress-stderr.mjs";
|
|
|
17
17
|
import { ROUTING_BLOCK } from "./routing-block.mjs";
|
|
18
18
|
import { readStdin, getSessionId, getSessionDBPath, getSessionEventsPath, getCleanupFlagPath } from "./session-helpers.mjs";
|
|
19
19
|
import { writeSessionEventsFile, buildSessionDirective, getSessionEvents, getLatestSessionEvents } from "./session-directive.mjs";
|
|
20
|
+
import { createSessionLoaders } from "./session-loaders.mjs";
|
|
20
21
|
import { join, dirname } from "node:path";
|
|
21
|
-
import { fileURLToPath
|
|
22
|
+
import { fileURLToPath } from "node:url";
|
|
22
23
|
import { readFileSync, writeFileSync, unlinkSync } from "node:fs";
|
|
23
24
|
import { homedir } from "node:os";
|
|
24
25
|
|
|
25
26
|
// Resolve absolute path for imports (fileURLToPath for Windows compat)
|
|
26
27
|
const HOOK_DIR = dirname(fileURLToPath(import.meta.url));
|
|
27
|
-
const
|
|
28
|
+
const { loadSessionDB } = createSessionLoaders(HOOK_DIR);
|
|
28
29
|
|
|
29
30
|
let additionalContext = ROUTING_BLOCK;
|
|
30
31
|
|
|
@@ -35,7 +36,7 @@ try {
|
|
|
35
36
|
|
|
36
37
|
if (source === "compact") {
|
|
37
38
|
// Session was compacted — write events to file for auto-indexing, inject directive only
|
|
38
|
-
const { SessionDB } = await
|
|
39
|
+
const { SessionDB } = await loadSessionDB();
|
|
39
40
|
const dbPath = getSessionDBPath();
|
|
40
41
|
const db = new SessionDB({ dbPath });
|
|
41
42
|
const sessionId = getSessionId(input);
|
|
@@ -56,7 +57,7 @@ try {
|
|
|
56
57
|
// User used --continue — clear cleanup flag so startup doesn't wipe data
|
|
57
58
|
try { unlinkSync(getCleanupFlagPath()); } catch { /* no flag */ }
|
|
58
59
|
|
|
59
|
-
const { SessionDB } = await
|
|
60
|
+
const { SessionDB } = await loadSessionDB();
|
|
60
61
|
const dbPath = getSessionDBPath();
|
|
61
62
|
const db = new SessionDB({ dbPath });
|
|
62
63
|
|
|
@@ -69,7 +70,7 @@ try {
|
|
|
69
70
|
db.close();
|
|
70
71
|
} else if (source === "startup") {
|
|
71
72
|
// Fresh session (no --continue) — clean slate, capture CLAUDE.md rules.
|
|
72
|
-
const { SessionDB } = await
|
|
73
|
+
const { SessionDB } = await loadSessionDB();
|
|
73
74
|
const dbPath = getSessionDBPath();
|
|
74
75
|
const db = new SessionDB({ dbPath });
|
|
75
76
|
try { unlinkSync(getSessionEventsPath()); } catch { /* no stale file */ }
|
|
@@ -10,11 +10,12 @@ import "./suppress-stderr.mjs";
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { readStdin, getSessionId, getSessionDBPath } from "./session-helpers.mjs";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import { createSessionLoaders } from "./session-loaders.mjs";
|
|
14
|
+
import { dirname } from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
15
16
|
|
|
16
17
|
const HOOK_DIR = dirname(fileURLToPath(import.meta.url));
|
|
17
|
-
const
|
|
18
|
+
const { loadSessionDB, loadExtract } = createSessionLoaders(HOOK_DIR);
|
|
18
19
|
|
|
19
20
|
try {
|
|
20
21
|
const raw = await readStdin();
|
|
@@ -30,8 +31,8 @@ try {
|
|
|
30
31
|
|| trimmed.startsWith("<tool-result>");
|
|
31
32
|
|
|
32
33
|
if (trimmed.length > 0 && !isSystemMessage) {
|
|
33
|
-
const { SessionDB } = await
|
|
34
|
-
const { extractUserEvents } = await
|
|
34
|
+
const { SessionDB } = await loadSessionDB();
|
|
35
|
+
const { extractUserEvents } = await loadExtract();
|
|
35
36
|
const dbPath = getSessionDBPath();
|
|
36
37
|
const db = new SessionDB({ dbPath });
|
|
37
38
|
const sessionId = getSessionId(input);
|
|
@@ -9,14 +9,15 @@ import "../suppress-stderr.mjs";
|
|
|
9
9
|
* Must be fast (<20ms). No network, no LLM, just SQLite writes.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import { createSessionLoaders } from "../session-loaders.mjs";
|
|
12
13
|
import { readStdin, getSessionId, getSessionDBPath, getProjectDir, VSCODE_OPTS } from "../session-helpers.mjs";
|
|
13
14
|
import { appendFileSync } from "node:fs";
|
|
14
15
|
import { join, dirname } from "node:path";
|
|
15
|
-
import { fileURLToPath
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
16
17
|
import { homedir } from "node:os";
|
|
17
18
|
|
|
18
19
|
const HOOK_DIR = dirname(fileURLToPath(import.meta.url));
|
|
19
|
-
const
|
|
20
|
+
const { loadSessionDB, loadExtract } = createSessionLoaders(HOOK_DIR);
|
|
20
21
|
const OPTS = VSCODE_OPTS;
|
|
21
22
|
const DEBUG_LOG = join(homedir(), ".vscode", "context-mode", "posttooluse-debug.log");
|
|
22
23
|
|
|
@@ -26,8 +27,8 @@ try {
|
|
|
26
27
|
|
|
27
28
|
appendFileSync(DEBUG_LOG, `[${new Date().toISOString()}] CALL: ${input.tool_name}\n`);
|
|
28
29
|
|
|
29
|
-
const { extractEvents } = await
|
|
30
|
-
const { SessionDB } = await
|
|
30
|
+
const { extractEvents } = await loadExtract();
|
|
31
|
+
const { SessionDB } = await loadSessionDB();
|
|
31
32
|
|
|
32
33
|
const dbPath = getSessionDBPath(OPTS);
|
|
33
34
|
const db = new SessionDB({ dbPath });
|
|
@@ -8,14 +8,15 @@ import "../suppress-stderr.mjs";
|
|
|
8
8
|
* snapshot (<2KB XML), and stores it for injection after compact.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import { createSessionLoaders } from "../session-loaders.mjs";
|
|
11
12
|
import { readStdin, getSessionId, getSessionDBPath, VSCODE_OPTS } from "../session-helpers.mjs";
|
|
12
13
|
import { appendFileSync } from "node:fs";
|
|
13
14
|
import { join, dirname } from "node:path";
|
|
14
|
-
import { fileURLToPath
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
15
16
|
import { homedir } from "node:os";
|
|
16
17
|
|
|
17
18
|
const HOOK_DIR = dirname(fileURLToPath(import.meta.url));
|
|
18
|
-
const
|
|
19
|
+
const { loadSessionDB, loadSnapshot } = createSessionLoaders(HOOK_DIR);
|
|
19
20
|
const OPTS = VSCODE_OPTS;
|
|
20
21
|
const DEBUG_LOG = join(homedir(), ".vscode", "context-mode", "precompact-debug.log");
|
|
21
22
|
|
|
@@ -23,8 +24,8 @@ try {
|
|
|
23
24
|
const raw = await readStdin();
|
|
24
25
|
const input = JSON.parse(raw);
|
|
25
26
|
|
|
26
|
-
const { buildResumeSnapshot } = await
|
|
27
|
-
const { SessionDB } = await
|
|
27
|
+
const { buildResumeSnapshot } = await loadSnapshot();
|
|
28
|
+
const { SessionDB } = await loadSessionDB();
|
|
28
29
|
|
|
29
30
|
const dbPath = getSessionDBPath(OPTS);
|
|
30
31
|
const db = new SessionDB({ dbPath });
|
|
@@ -10,6 +10,7 @@ import "../suppress-stderr.mjs";
|
|
|
10
10
|
* - "clear" → No action needed
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import { createSessionLoaders } from "../session-loaders.mjs";
|
|
13
14
|
import { ROUTING_BLOCK } from "../routing-block.mjs";
|
|
14
15
|
import { writeSessionEventsFile, buildSessionDirective, getSessionEvents, getLatestSessionEvents } from "../session-directive.mjs";
|
|
15
16
|
import {
|
|
@@ -22,7 +23,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
22
23
|
import { homedir } from "node:os";
|
|
23
24
|
|
|
24
25
|
const HOOK_DIR = fileURLToPath(new URL(".", import.meta.url));
|
|
25
|
-
const
|
|
26
|
+
const { loadSessionDB } = createSessionLoaders(HOOK_DIR);
|
|
26
27
|
const OPTS = VSCODE_OPTS;
|
|
27
28
|
|
|
28
29
|
let additionalContext = ROUTING_BLOCK;
|
|
@@ -33,7 +34,7 @@ try {
|
|
|
33
34
|
const source = input.source ?? "startup";
|
|
34
35
|
|
|
35
36
|
if (source === "compact") {
|
|
36
|
-
const { SessionDB } = await
|
|
37
|
+
const { SessionDB } = await loadSessionDB();
|
|
37
38
|
const dbPath = getSessionDBPath(OPTS);
|
|
38
39
|
const db = new SessionDB({ dbPath });
|
|
39
40
|
const sessionId = getSessionId(input, OPTS);
|
|
@@ -53,7 +54,7 @@ try {
|
|
|
53
54
|
} else if (source === "resume") {
|
|
54
55
|
try { unlinkSync(getCleanupFlagPath(OPTS)); } catch { /* no flag */ }
|
|
55
56
|
|
|
56
|
-
const { SessionDB } = await
|
|
57
|
+
const { SessionDB } = await loadSessionDB();
|
|
57
58
|
const dbPath = getSessionDBPath(OPTS);
|
|
58
59
|
const db = new SessionDB({ dbPath });
|
|
59
60
|
|
|
@@ -65,7 +66,7 @@ try {
|
|
|
65
66
|
|
|
66
67
|
db.close();
|
|
67
68
|
} else if (source === "startup") {
|
|
68
|
-
const { SessionDB } = await
|
|
69
|
+
const { SessionDB } = await loadSessionDB();
|
|
69
70
|
const dbPath = getSessionDBPath(OPTS);
|
|
70
71
|
const db = new SessionDB({ dbPath });
|
|
71
72
|
try { unlinkSync(getSessionEventsPath(OPTS)); } catch { /* no stale file */ }
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "context-mode",
|
|
3
|
+
"name": "Context Mode",
|
|
4
|
+
"kind": "tool",
|
|
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.23",
|
|
7
|
+
"sandbox": {
|
|
8
|
+
"mode": "permissive",
|
|
9
|
+
"filesystem_access": "full",
|
|
10
|
+
"system_access": "full"
|
|
11
|
+
},
|
|
12
|
+
"configSchema": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"properties": {
|
|
15
|
+
"enabled": {
|
|
16
|
+
"type": "boolean",
|
|
17
|
+
"default": true,
|
|
18
|
+
"description": "Enable or disable the context-mode plugin."
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"additionalProperties": false
|
|
22
|
+
}
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "context-mode",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
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",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"gemini-cli",
|
|
14
14
|
"vscode-copilot",
|
|
15
15
|
"opencode",
|
|
16
|
+
"openclaw",
|
|
16
17
|
"codex-cli",
|
|
17
18
|
"context-window",
|
|
18
19
|
"sandbox",
|
|
@@ -25,11 +26,17 @@
|
|
|
25
26
|
"url": "https://github.com/mksglu/context-mode"
|
|
26
27
|
},
|
|
27
28
|
"homepage": "https://github.com/mksglu/context-mode#readme",
|
|
29
|
+
"openclaw": {
|
|
30
|
+
"extensions": [
|
|
31
|
+
"./build/openclaw-plugin.js"
|
|
32
|
+
]
|
|
33
|
+
},
|
|
28
34
|
"bugs": "https://github.com/mksglu/context-mode/issues",
|
|
29
35
|
"main": "./build/opencode-plugin.js",
|
|
30
36
|
"exports": {
|
|
31
37
|
".": "./build/opencode-plugin.js",
|
|
32
38
|
"./plugin": "./build/opencode-plugin.js",
|
|
39
|
+
"./openclaw": "./build/openclaw-plugin.js",
|
|
33
40
|
"./cli": "./build/cli.js"
|
|
34
41
|
},
|
|
35
42
|
"bin": {
|
|
@@ -43,14 +50,18 @@
|
|
|
43
50
|
"cli.bundle.mjs",
|
|
44
51
|
"skills",
|
|
45
52
|
".claude-plugin",
|
|
53
|
+
".openclaw-plugin",
|
|
46
54
|
".mcp.json",
|
|
55
|
+
"openclaw.plugin.json",
|
|
47
56
|
"start.mjs",
|
|
48
57
|
"README.md",
|
|
49
58
|
"LICENSE"
|
|
50
59
|
],
|
|
51
60
|
"scripts": {
|
|
52
61
|
"build": "tsc && chmod +x build/cli.js",
|
|
53
|
-
"bundle": "esbuild src/server.ts --bundle --platform=node --target=node18 --format=esm --outfile=server.bundle.mjs --external:better-sqlite3 --external:turndown --external:turndown-plugin-gfm --external:@mixmark-io/domino --minify && esbuild src/cli.ts --bundle --platform=node --target=node18 --format=esm --outfile=cli.bundle.mjs --external:better-sqlite3 --minify",
|
|
62
|
+
"bundle": "esbuild src/server.ts --bundle --platform=node --target=node18 --format=esm --outfile=server.bundle.mjs --external:better-sqlite3 --external:turndown --external:turndown-plugin-gfm --external:@mixmark-io/domino --minify && esbuild src/cli.ts --bundle --platform=node --target=node18 --format=esm --outfile=cli.bundle.mjs --external:better-sqlite3 --minify && esbuild src/session/extract.ts --bundle --platform=node --target=node18 --format=esm --outfile=hooks/session-extract.bundle.mjs --minify && esbuild src/session/snapshot.ts --bundle --platform=node --target=node18 --format=esm --outfile=hooks/session-snapshot.bundle.mjs --minify && esbuild src/session/db.ts --bundle --platform=node --target=node18 --format=esm --outfile=hooks/session-db.bundle.mjs --external:better-sqlite3 --minify",
|
|
63
|
+
"version-sync": "node scripts/version-sync.mjs",
|
|
64
|
+
"version": "node scripts/version-sync.mjs && git add .claude-plugin/plugin.json .claude-plugin/marketplace.json .openclaw-plugin/openclaw.plugin.json .openclaw-plugin/package.json openclaw.plugin.json",
|
|
54
65
|
"prepublishOnly": "npm run build",
|
|
55
66
|
"dev": "npx tsx src/server.ts",
|
|
56
67
|
"setup": "npx tsx src/cli.ts setup",
|