context-mode 1.0.138 → 1.0.140

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.
@@ -6,14 +6,14 @@
6
6
  },
7
7
  "metadata": {
8
8
  "description": "Claude Code plugins by Mert Koseoğlu",
9
- "version": "1.0.138"
9
+ "version": "1.0.140"
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.138",
16
+ "version": "1.0.140",
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.138",
3
+ "version": "1.0.140",
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",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "1.0.138",
3
+ "version": "1.0.140",
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.138",
6
+ "version": "1.0.140",
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.138",
3
+ "version": "1.0.140",
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",
@@ -251,11 +251,18 @@ async function createContextModePlugin(ctx) {
251
251
  const tools = {};
252
252
  for (const registered of mod.REGISTERED_CTX_TOOLS) {
253
253
  const config = registered.config;
254
- const schema = config.inputSchema;
255
- const shape = typeof schema?.shape === "object" && schema.shape !== null
256
- ? schema.shape
257
- : typeof schema?._def?.shape === "function"
258
- ? schema._def.shape()
254
+ // Zod schema object that the MCP framework normally calls
255
+ // safeParseAsync() on before invoking the handler. The native
256
+ // OpenCode plugin path bypasses MCP's transport layer entirely
257
+ // (refs/platforms/opencode/packages/opencode/src/tool/registry.ts:127),
258
+ // so we must parse args here too — otherwise z.preprocess() coercions
259
+ // (coerceCommandsArray / coerceJsonArray in server.ts) and defaults
260
+ // never fire. Fixes #621.
261
+ const inputSchema = config.inputSchema;
262
+ const shape = typeof inputSchema?.shape === "object" && inputSchema.shape !== null
263
+ ? inputSchema.shape
264
+ : typeof inputSchema?._def?.shape === "function"
265
+ ? inputSchema._def.shape()
259
266
  : {};
260
267
  tools[registered.name] = {
261
268
  description: String(config.description ?? ""),
@@ -263,7 +270,24 @@ async function createContextModePlugin(ctx) {
263
270
  async execute(args, toolCtx) {
264
271
  toolCtx.metadata?.({ title: String(config.title ?? registered.name) });
265
272
  const project = toolCtx.directory || projectDir;
266
- const result = await mod.withProjectDirOverride({ projectDir: project, sessionId: toolCtx.sessionID }, async () => registered.handler(args ?? {}));
273
+ // Run the registered Zod schema BEFORE the handler same contract
274
+ // as the MCP SDK (server/mcp.js safeParseAsync at line 174). This
275
+ // applies z.preprocess() coercions, populates .default() values,
276
+ // and produces the validation error the handler expects (#621).
277
+ let parsedArgs = args ?? {};
278
+ if (typeof inputSchema?.parse === "function") {
279
+ try {
280
+ parsedArgs = inputSchema.parse(args ?? {});
281
+ }
282
+ catch (err) {
283
+ // Surface validation failures with a clear, actionable message
284
+ // (mirrors MCP SDK error format) instead of a downstream
285
+ // "x.map is not a function" crash.
286
+ const message = err instanceof Error ? err.message : String(err);
287
+ throw new Error(`Invalid arguments for ${registered.name}: ${message}`);
288
+ }
289
+ }
290
+ const result = await mod.withProjectDirOverride({ projectDir: project, sessionId: toolCtx.sessionID }, async () => registered.handler(parsedArgs));
267
291
  const r = result;
268
292
  const text = Array.isArray(r?.content)
269
293
  ? r.content
package/build/server.d.ts CHANGED
@@ -15,6 +15,12 @@ export declare function shouldSuppressMcpToolsForNativePluginHost(opts?: {
15
15
  platform?: PlatformId;
16
16
  settings?: Record<string, unknown> | null;
17
17
  }): boolean;
18
+ export declare function emitSuppressionDiagnostic(opts?: {
19
+ platform?: string;
20
+ write?: (chunk: string) => void;
21
+ }): void;
22
+ /** Test-only: reset the one-shot emission flag so suites can re-exercise. */
23
+ export declare function __resetSuppressionDiagnosticForTests(): void;
18
24
  type ToolContextOverride = {
19
25
  projectDir: string;
20
26
  sessionId?: string;
package/build/server.js CHANGED
@@ -155,11 +155,44 @@ function settingsHasLegacyContextModeMcp(settings) {
155
155
  Object.prototype.hasOwnProperty.call(mcp, "context-mode"));
156
156
  }
157
157
  const suppressMcpToolsForNativePluginHost = shouldSuppressMcpToolsForNativePluginHost();
158
+ /**
159
+ * Issue #623 — surface why ctx_* tools/list is empty on suppressed legacy MCP
160
+ * children. When a user upgrades OpenCode/Kilo from v1.0.136 → v1.0.137+ without
161
+ * running `context-mode upgrade`, their opencode.json still has BOTH the legacy
162
+ * mcp.context-mode block AND the plugin entry. The plugin path registers the
163
+ * tools natively, but the legacy MCP child runs in parallel and used to expose
164
+ * duplicate tools — v1.0.137 suppressed those duplicates. The suppression was
165
+ * silent, leaving any MCP client that inspected the child via tools/list with
166
+ * an empty list and no diagnostic. Emit one stderr line per process so an
167
+ * operator running the child directly (or any non-plugin MCP host) sees the
168
+ * exact reason and the `context-mode upgrade` fix.
169
+ *
170
+ * Exported for test (suppression-diagnostic regression guard).
171
+ */
172
+ let __suppressionDiagnosticEmitted = false;
173
+ export function emitSuppressionDiagnostic(opts = {}) {
174
+ if (__suppressionDiagnosticEmitted)
175
+ return;
176
+ __suppressionDiagnosticEmitted = true;
177
+ const write = opts.write ?? ((c) => { process.stderr.write(c); });
178
+ const platform = opts.platform ?? "opencode/kilo";
179
+ write(`[context-mode] ctx_* tools/list intentionally empty on this MCP child: ` +
180
+ `legacy mcp.context-mode block coexists with plugin: ["context-mode"] in ` +
181
+ `${platform}.json — plugin-native tools are the supported path (#623). ` +
182
+ `Run \`context-mode upgrade\` to remove the legacy block (preserves other ` +
183
+ `MCP servers).\n`);
184
+ }
185
+ /** Test-only: reset the one-shot emission flag so suites can re-exercise. */
186
+ export function __resetSuppressionDiagnosticForTests() {
187
+ __suppressionDiagnosticEmitted = false;
188
+ }
158
189
  const originalRegisterTool = server.registerTool.bind(server);
159
190
  server.registerTool = (...args) => {
160
191
  const [name, config, handler] = args;
161
- if (suppressMcpToolsForNativePluginHost)
192
+ if (suppressMcpToolsForNativePluginHost) {
193
+ emitSuppressionDiagnostic();
162
194
  return undefined;
195
+ }
163
196
  REGISTERED_CTX_TOOLS.push({ name, config, handler });
164
197
  return originalRegisterTool(...args);
165
198
  };