jorgex-stack 1.7.3 → 1.7.4

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.
Files changed (2) hide show
  1. package/dist/cli.js +68 -15
  2. package/package.json +3 -1
package/dist/cli.js CHANGED
@@ -402,23 +402,67 @@ function headerName(line) {
402
402
  if (!match) return null;
403
403
  return match[1].split(".").map((part) => part.trim().replace(/^["']|["']$/g, "")).join(".");
404
404
  }
405
- function multilineStringMask(lines) {
406
- const mask = [];
407
- let inside = null;
408
- for (const line of lines) {
409
- if (inside !== null) {
410
- mask.push(true);
411
- if (line.includes(inside)) inside = null;
405
+ function quoteRunLength(line, start, quote) {
406
+ let end = start + 1;
407
+ while (end < line.length && line[end] === quote) end++;
408
+ return end - start;
409
+ }
410
+ function skipShortString(line, start, quote) {
411
+ let index = start + 1;
412
+ while (index < line.length) {
413
+ if (line[index] === quote) return index + 1;
414
+ if (quote === '"' && line[index] === "\\") {
415
+ index += 2;
412
416
  continue;
413
417
  }
414
- mask.push(false);
415
- for (const delim of ["'''", '"""']) {
416
- if ((line.split(delim).length - 1) % 2 === 1) {
417
- inside = delim;
418
- break;
418
+ index++;
419
+ }
420
+ return line.length;
421
+ }
422
+ function scanTomlLine(line, initial) {
423
+ let inside = initial;
424
+ let index = 0;
425
+ while (index < line.length) {
426
+ if (inside !== null) {
427
+ const quote = inside === '"""' ? '"' : "'";
428
+ if (line[index] === quote) {
429
+ const run2 = quoteRunLength(line, index, quote);
430
+ if (run2 >= 3) {
431
+ inside = null;
432
+ }
433
+ index += run2;
434
+ continue;
435
+ }
436
+ if (inside === '"""' && line[index] === "\\") {
437
+ index += 2;
438
+ continue;
419
439
  }
440
+ index++;
441
+ continue;
442
+ }
443
+ const char = line[index];
444
+ if (char === "#") break;
445
+ if (char !== '"' && char !== "'") {
446
+ index++;
447
+ continue;
448
+ }
449
+ const run = quoteRunLength(line, index, char);
450
+ if (run >= 3) {
451
+ inside = char === '"' ? '"""' : "'''";
452
+ index += 3;
453
+ } else {
454
+ index = skipShortString(line, index, char);
420
455
  }
421
456
  }
457
+ return inside;
458
+ }
459
+ function multilineStringMask(lines) {
460
+ const mask = [];
461
+ let inside = null;
462
+ for (const line of lines) {
463
+ mask.push(inside !== null);
464
+ inside = scanTomlLine(line, inside);
465
+ }
422
466
  return mask;
423
467
  }
424
468
  function findTomlSection(lines, section) {
@@ -435,7 +479,15 @@ function upsertTomlSection(existing, section, body) {
435
479
  ${body.trim()}
436
480
  `;
437
481
  if (existing === null || existing.trim() === "") return block;
438
- const lines = existing.split(/\r?\n/);
482
+ const rawLines = existing.split("\n");
483
+ const lines = rawLines.map((line) => line.endsWith("\r") ? line.slice(0, -1) : line);
484
+ const lineStarts = [];
485
+ let offset = 0;
486
+ for (let index = 0; index < rawLines.length; index++) {
487
+ lineStarts.push(offset);
488
+ offset += rawLines[index].length;
489
+ if (index < rawLines.length - 1) offset++;
490
+ }
439
491
  const found = findTomlSection(lines, section);
440
492
  if (found === null) {
441
493
  const sep = existing.endsWith("\n") ? "\n" : "\n\n";
@@ -443,8 +495,9 @@ ${body.trim()}
443
495
  }
444
496
  let sectionEnd = found.end;
445
497
  while (sectionEnd > found.start + 1 && lines[sectionEnd - 1].trim() === "") sectionEnd--;
446
- const result = [...lines.slice(0, found.start), block.trimEnd(), ...lines.slice(sectionEnd)].join("\n");
447
- return result.endsWith("\n") ? result : result + "\n";
498
+ const startOffset = lineStarts[found.start];
499
+ const endOffset = lineStarts[sectionEnd] ?? existing.length;
500
+ return existing.slice(0, startOffset) + block.trimEnd() + "\n" + existing.slice(endOffset);
448
501
  }
449
502
  function removeTomlSection(existing, section) {
450
503
  const eol = existing.includes("\r\n") ? "\r\n" : "\n";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jorgex-stack",
3
- "version": "1.7.3",
3
+ "version": "1.7.4",
4
4
  "description": "Harness multi-agente portable: instala la config JorgeX (agentes, skills, hooks, Engram, MCPs) en Claude Code, Codex CLI, OpenCode y Pi",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -42,6 +42,7 @@
42
42
  "dev": "tsup --watch",
43
43
  "typecheck": "tsc --noEmit",
44
44
  "test": "vitest run",
45
+ "test:property": "vitest run --dir pilots/property",
45
46
  "cli": "node dist/cli.js",
46
47
  "prepublishOnly": "pnpm typecheck && pnpm test && pnpm build"
47
48
  },
@@ -50,6 +51,7 @@
50
51
  },
51
52
  "devDependencies": {
52
53
  "@types/node": "^25.9.2",
54
+ "fast-check": "4.9.0",
53
55
  "tsup": "^8.5.1",
54
56
  "typescript": "^6.0.3",
55
57
  "vitest": "^4.1.8"