@grundy40/contextslice 0.3.4 → 0.3.5

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.
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * ctxslice-mcp.mjs — Global Multi-Language MCP Server v0.3.4
3
+ * ctxslice-mcp.mjs — Global Multi-Language MCP Server v0.3.5
4
4
  * Features: Embedded Base64 Tree-sitter WASM + Lazy Cache (~/.contextslice/parsers),
5
5
  * State-Machine Brace Matcher Fallback, True Call Graph (BFS), TF-IDF, subPath Sandbox, mtime Cache
6
6
  */
@@ -11,7 +11,7 @@ import readline from 'node:readline';
11
11
  import { createRequire } from 'node:module';
12
12
 
13
13
  if (process.argv.includes('--version') || process.argv.includes('-v')) {
14
- process.stdout.write('ctxslice-mcp v0.3.4\n');
14
+ process.stdout.write('ctxslice-mcp v0.3.5\n');
15
15
  process.exit(0);
16
16
  }
17
17
 
@@ -381,7 +381,7 @@ function expandQueryTerms(query) {
381
381
 
382
382
  const TOOL_DEF = {
383
383
  name: 'get_context_slice',
384
- description: 'PRIMARY code-reading tool (v0.3.4) with Tree-sitter WASM / State-Machine AST parsing, True Call Graph, TF-IDF & omitted summary.',
384
+ description: 'PRIMARY code-reading tool (v0.3.5) with Tree-sitter WASM / State-Machine AST parsing, True Call Graph, TF-IDF & omitted summary.',
385
385
  annotations: { readOnlyHint: true },
386
386
  inputSchema: {
387
387
  type: 'object',
@@ -1532,7 +1532,7 @@ async function sliceProject(query, projectPath, budget = 32768, autoExpand = tru
1532
1532
 
1533
1533
  const expandTag = autoExpandedNames.length > 0 ? ` autoExpanded="${autoExpandedNames.join(',')}"` : '';
1534
1534
  const subPathTag = subPath ? ` subPath="${subPath}"` : '';
1535
- return `<context_slice root="${root}" version="0.3.4"${subPathTag} budget="${budget}" used="${used}"${expandTag}>${headerTag}\n<skeletons>\n${finalSkelChunks.join('\n')}\n</skeletons>\n<focal>\n${fullChunks.join('\n\n')}\n</focal>${footerTag}${omittedTag}\n</context_slice>`;
1535
+ return `<context_slice root="${root}" version="0.3.5"${subPathTag} budget="${budget}" used="${used}"${expandTag}>${headerTag}\n<skeletons>\n${finalSkelChunks.join('\n')}\n</skeletons>\n<focal>\n${fullChunks.join('\n\n')}\n</focal>${footerTag}${omittedTag}\n</context_slice>`;
1536
1536
  } catch (err) {
1537
1537
  return `Error: ${err.message}`;
1538
1538
  }
@@ -1551,7 +1551,7 @@ rl.on('line', async (line) => {
1551
1551
  return send({
1552
1552
  protocolVersion: req.params?.protocolVersion || '2024-11-05',
1553
1553
  capabilities: { tools: {} },
1554
- serverInfo: { name: 'ctxslice-thin', version: '0.3.4' }
1554
+ serverInfo: { name: 'ctxslice-thin', version: '0.3.5' }
1555
1555
  });
1556
1556
  }
1557
1557
  if (req.method === 'ping') return send({});
package/bin/ctxslice.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * ctxslice.mjs — Zero-Config Multi-Language Local AST Context Pre-Compiler (v0.3.4)
3
+ * ctxslice.mjs — Zero-Config Multi-Language Local AST Context Pre-Compiler (v0.3.5)
4
4
  * Features: Multi-Language AST Extractors, State-Machine Brace Matcher, True Call Graph (BFS), TF-IDF, Directory Quota Cap
5
5
  */
6
6
  import fs from 'node:fs';
@@ -372,12 +372,12 @@ function expandQueryTerms(query) {
372
372
 
373
373
  const args = process.argv.slice(2);
374
374
  if (args.includes('--version') || args.includes('-v')) {
375
- process.stdout.write('ctxslice v0.3.4\n');
375
+ process.stdout.write('ctxslice v0.3.5\n');
376
376
  process.exit(0);
377
377
  }
378
378
  if (args.includes('--help') || args.includes('-h')) {
379
379
  process.stdout.write(
380
- 'ContextSlice CLI v0.3.4 — Zero-Config Multi-Language AST Slicer\n\n' +
380
+ 'ContextSlice CLI v0.3.5 — Zero-Config Multi-Language AST Slicer\n\n' +
381
381
  'Usage:\n ctxslice "<query>" [--root <dir>] [--budget <tokens>]\n\n' +
382
382
  'Options:\n --root <dir> Target repository path (default: current directory)\n' +
383
383
  ' --budget <num> Max token budget (default: 32768)\n' +
@@ -437,9 +437,13 @@ function walk(dir, acc = []) {
437
437
  }
438
438
 
439
439
  function estimateTokens(str) {
440
- return Math.max(1, Math.round(str.length / 3.8));
440
+ if (!str) return 0;
441
+ let cjk = 0;
442
+ for (let i = 0; i < str.length; i++) if (str.charCodeAt(i) >= 128) cjk++;
443
+ return Math.max(1, Math.round((str.length - cjk) / 2.1 + cjk * 1.6));
441
444
  }
442
445
 
446
+
443
447
  function maskCommentsAndStrings(code) {
444
448
  return code
445
449
  .replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, ' '))
@@ -1078,7 +1082,7 @@ while (qHead < bfsQ.length) {
1078
1082
  }
1079
1083
 
1080
1084
  let remaining = budget;
1081
- const out = ['<context_slice root="' + path.basename(targetRoot) + '" version="0.3.4" budget="' + budget + '">'];
1085
+ const out = ['<context_slice root="' + path.basename(targetRoot) + '" version="0.3.5" budget="' + budget + '">'];
1082
1086
  const includedIds = new Set();
1083
1087
  const includedFiles = new Set();
1084
1088
  const fullStart1EndLine = new Map();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grundy40/contextslice",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Zero-dependency multi-language AST code slicer & 1-Tool MCP server for AI coding assistants (Claude Code, OpenCode, Pi Agent, Cursor).",
5
5
  "type": "module",
6
6
  "bin": {