wormclaude 1.0.199 → 1.0.200

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/theme.js CHANGED
@@ -16,4 +16,4 @@ export const theme = {
16
16
  synType: '#a78bfa', // tip/sınıf adları, sabitler
17
17
  synProp: '#e0e0e0', // özellik/anahtar adları
18
18
  };
19
- export const VERSION = '1.0.199';
19
+ export const VERSION = '1.0.200';
package/dist/tools.js CHANGED
@@ -1249,6 +1249,44 @@ const TYPE_EXT = {
1249
1249
  };
1250
1250
  // ── Executor ──────────────────────────────────────────────────────────────────
1251
1251
  // Edit/Write icin +/- satir ozeti (Diff paketiyle).
1252
+ // Adapter artığı temizle: küçük modeller değeri <![CDATA[ ... ]]> ile sarabiliyor (gateway de
1253
+ // temizliyor ama istemci-tarafı garanti — dosyayı bozmasın).
1254
+ function stripCdata(s) {
1255
+ let t = s;
1256
+ if (t.startsWith('<![CDATA['))
1257
+ t = t.slice(9);
1258
+ if (t.endsWith(']]>'))
1259
+ t = t.slice(0, -3);
1260
+ return t;
1261
+ }
1262
+ // Boşluk/girinti-toleranslı blok eşleşme: old_string dosyada BİREBİR yoksa (model exact metni
1263
+ // üretemedi — küçük-model klasiği), satırları trim'leyip BENZERSIZ bir blok ara → dosyanın GERÇEK
1264
+ // metnini döndür (replace bununla yapılır, dosya geçerli kalır). null = yok/belirsiz.
1265
+ function fuzzyBlockMatch(content, needle) {
1266
+ const nLines = needle.replace(/^\n+/, '').replace(/\n+$/, '').split('\n');
1267
+ if (nLines.length === 0 || (nLines.length === 1 && !nLines[0].trim()))
1268
+ return null;
1269
+ const cLines = content.split('\n');
1270
+ const key = (l) => l.trim();
1271
+ let foundAt = -1, foundCount = 0;
1272
+ for (let i = 0; i + nLines.length <= cLines.length; i++) {
1273
+ let ok = true;
1274
+ for (let k = 0; k < nLines.length; k++) {
1275
+ if (key(cLines[i + k]) !== key(nLines[k])) {
1276
+ ok = false;
1277
+ break;
1278
+ }
1279
+ }
1280
+ if (ok) {
1281
+ if (foundCount === 0)
1282
+ foundAt = i;
1283
+ foundCount++;
1284
+ }
1285
+ }
1286
+ if (foundCount !== 1)
1287
+ return null; // bulunamadı VEYA birden çok (belirsiz) → güvenli taraf
1288
+ return cLines.slice(foundAt, foundAt + nLines.length).join('\n');
1289
+ }
1252
1290
  function diffStat(oldStr, newStr) {
1253
1291
  try {
1254
1292
  let added = 0, removed = 0;
@@ -1431,12 +1469,23 @@ export async function executeTool(name, args) {
1431
1469
  return { ok: false, output: `Error: file does not exist: ${fp}` };
1432
1470
  if (!readFiles.has(norm(fp)))
1433
1471
  return { ok: false, output: 'Error: you must use the Read tool on this file before editing it.' };
1434
- const oldStr = String(args.old_string ?? '');
1435
- const newStr = String(args.new_string ?? '');
1472
+ let oldStr = stripCdata(String(args.old_string ?? '')); // CDATA artığını temizle
1473
+ const newStr = stripCdata(String(args.new_string ?? ''));
1436
1474
  if (oldStr === newStr)
1437
1475
  return { ok: false, output: 'Error: new_string must differ from old_string.' };
1438
1476
  let c = fs.readFileSync(fp, 'utf8');
1439
- const count = oldStr ? c.split(oldStr).length - 1 : 0;
1477
+ let count = oldStr ? c.split(oldStr).length - 1 : 0;
1478
+ let _fuzzy = '';
1479
+ // EXACT-MATCH KURTARMA: birebir bulunamadıysa boşluk/girinti-toleranslı blok eşleşmesi dene
1480
+ // (küçük model exact metni üretemiyor → hard-fail yerine gerçek bloğu bul ve onu değiştir).
1481
+ if (count === 0 && oldStr && !args.replace_all) {
1482
+ const fz = fuzzyBlockMatch(c, oldStr);
1483
+ if (fz) {
1484
+ oldStr = fz;
1485
+ count = c.split(oldStr).length - 1;
1486
+ _fuzzy = ' (boşluk-toleranslı eşleşme)';
1487
+ }
1488
+ }
1440
1489
  if (count === 0)
1441
1490
  return { ok: false, output: 'Error: old_string not found in file.' };
1442
1491
  if (count > 1 && !args.replace_all)
@@ -1448,7 +1497,7 @@ export async function executeTool(name, args) {
1448
1497
  recordCheckpoint(fp, _ebefore, 'Edit'); // rewind: düzenleme öncesi tam içerik
1449
1498
  c = args.replace_all ? c.split(oldStr).join(newStr) : c.replace(oldStr, newStr);
1450
1499
  fs.writeFileSync(fp, c);
1451
- return { ok: true, output: `Edited ${fp}${args.replace_all ? ` (${count} occurrences)` : ''}${diffStat(_ebefore, c)}` };
1500
+ return { ok: true, output: `Edited ${fp}${args.replace_all ? ` (${count} occurrences)` : ''}${_fuzzy}${diffStat(_ebefore, c)}` };
1452
1501
  }
1453
1502
  if (name === 'Glob') {
1454
1503
  const base = args.path ? resolveWs(args.path) : getBashCwd();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wormclaude",
3
- "version": "1.0.199",
3
+ "version": "1.0.200",
4
4
  "description": "WormClaude CLI - uncensored security+code assistant (ink TUI, Claude-style)",
5
5
  "type": "module",
6
6
  "bin": {