@papicandela/mcx-core 0.2.8 → 0.2.9

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/dist/index.js CHANGED
@@ -6551,6 +6551,20 @@ class BunWorkerSandbox {
6551
6551
  return lines.slice(Math.max(0, idx - ctx), Math.min(lines.length, idx + ctx + 1));
6552
6552
  };
6553
6553
 
6554
+ /**
6555
+ * Get specific line range (1-indexed, inclusive).
6556
+ * @param file - File object with .lines array
6557
+ * @param start - Start line number (1-indexed)
6558
+ * @param end - End line number (1-indexed, inclusive)
6559
+ */
6560
+ globalThis.lines = (file, start, end) => {
6561
+ const fileLines = file?.lines;
6562
+ if (!Array.isArray(fileLines)) return [];
6563
+ if (start < 1) start = 1;
6564
+ if (end > fileLines.length) end = fileLines.length;
6565
+ return fileLines.slice(start - 1, end);
6566
+ };
6567
+
6554
6568
  /**
6555
6569
  * Extract code block containing a line (detects by indentation).
6556
6570
  * @param file - File object with .lines array
@@ -6565,12 +6579,11 @@ class BunWorkerSandbox {
6565
6579
  const targetIndent = lines[idx].search(/\\S/);
6566
6580
  if (targetIndent < 0) return [lines[idx]];
6567
6581
 
6568
- // Find block start
6582
+ // Find block start (line with less indentation)
6569
6583
  let start = idx;
6570
6584
  for (let i = idx - 1; i >= 0; i--) {
6571
6585
  const lineIndent = lines[i].search(/\\S/);
6572
6586
  if (lineIndent >= 0 && lineIndent < targetIndent) { start = i; break; }
6573
- if (lineIndent === 0 && lines[i].trim()) { start = i; break; }
6574
6587
  }
6575
6588
 
6576
6589
  // Find block end
@@ -6631,7 +6644,7 @@ class BunWorkerSandbox {
6631
6644
  const line = lines[i];
6632
6645
  for (const pat of patterns) {
6633
6646
  if (pat.test(line)) {
6634
- signatures.push((i + 1) + ': ' + line.trim().slice(0, 80));
6647
+ signatures.push({ line: i + 1, text: line.trim().slice(0, 80) });
6635
6648
  break;
6636
6649
  }
6637
6650
  }
@@ -6646,7 +6659,7 @@ class BunWorkerSandbox {
6646
6659
  'pendingCalls', 'callId', 'logs', 'console', 'adapters',
6647
6660
  'fetch', 'XMLHttpRequest', 'WebSocket', 'EventSource',
6648
6661
  'pick', 'table', 'count', 'sum', 'first', 'safeStr', 'poll', 'waitFor',
6649
- 'around', 'block', 'grep', 'outline'
6662
+ 'around', 'lines', 'block', 'grep', 'outline'
6650
6663
  ]);
6651
6664
 
6652
6665
  self.onmessage = async (event) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@papicandela/mcx-core",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "MCX Core - MCP Code Execution Framework",
5
5
  "author": "papicandela",
6
6
  "license": "MIT",
@@ -348,6 +348,20 @@ export class BunWorkerSandbox implements ISandbox {
348
348
  return lines.slice(Math.max(0, idx - ctx), Math.min(lines.length, idx + ctx + 1));
349
349
  };
350
350
 
351
+ /**
352
+ * Get specific line range (1-indexed, inclusive).
353
+ * @param file - File object with .lines array
354
+ * @param start - Start line number (1-indexed)
355
+ * @param end - End line number (1-indexed, inclusive)
356
+ */
357
+ globalThis.lines = (file, start, end) => {
358
+ const fileLines = file?.lines;
359
+ if (!Array.isArray(fileLines)) return [];
360
+ if (start < 1) start = 1;
361
+ if (end > fileLines.length) end = fileLines.length;
362
+ return fileLines.slice(start - 1, end);
363
+ };
364
+
351
365
  /**
352
366
  * Extract code block containing a line (detects by indentation).
353
367
  * @param file - File object with .lines array
@@ -362,12 +376,11 @@ export class BunWorkerSandbox implements ISandbox {
362
376
  const targetIndent = lines[idx].search(/\\S/);
363
377
  if (targetIndent < 0) return [lines[idx]];
364
378
 
365
- // Find block start
379
+ // Find block start (line with less indentation)
366
380
  let start = idx;
367
381
  for (let i = idx - 1; i >= 0; i--) {
368
382
  const lineIndent = lines[i].search(/\\S/);
369
383
  if (lineIndent >= 0 && lineIndent < targetIndent) { start = i; break; }
370
- if (lineIndent === 0 && lines[i].trim()) { start = i; break; }
371
384
  }
372
385
 
373
386
  // Find block end
@@ -428,7 +441,7 @@ export class BunWorkerSandbox implements ISandbox {
428
441
  const line = lines[i];
429
442
  for (const pat of patterns) {
430
443
  if (pat.test(line)) {
431
- signatures.push((i + 1) + ': ' + line.trim().slice(0, 80));
444
+ signatures.push({ line: i + 1, text: line.trim().slice(0, 80) });
432
445
  break;
433
446
  }
434
447
  }
@@ -443,7 +456,7 @@ export class BunWorkerSandbox implements ISandbox {
443
456
  'pendingCalls', 'callId', 'logs', 'console', 'adapters',
444
457
  'fetch', 'XMLHttpRequest', 'WebSocket', 'EventSource',
445
458
  'pick', 'table', 'count', 'sum', 'first', 'safeStr', 'poll', 'waitFor',
446
- 'around', 'block', 'grep', 'outline'
459
+ 'around', 'lines', 'block', 'grep', 'outline'
447
460
  ]);
448
461
 
449
462
  self.onmessage = async (event) => {