wormclaude 1.0.217 → 1.0.218
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 +1 -1
- package/dist/tools.js +45 -3
- package/package.json +1 -1
package/dist/theme.js
CHANGED
package/dist/tools.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// OpenAI function şemaları + Node executor'ları. Açıklamalar ve davranışlar
|
|
3
3
|
// WormClaude'un gerçek prompt.ts/şemalarından alınmıştır; sadece marka adı ve
|
|
4
4
|
// WormClaude'da bulunmayan araç referansları (Agent tool, sandbox) uyarlandı.
|
|
5
|
-
import { spawn } from 'node:child_process';
|
|
5
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
6
7
|
import * as fs from 'node:fs';
|
|
7
8
|
import * as os from 'node:os';
|
|
8
9
|
import * as path from 'node:path';
|
|
@@ -1415,6 +1416,47 @@ function diffStat(oldStr, newStr) {
|
|
|
1415
1416
|
return '';
|
|
1416
1417
|
}
|
|
1417
1418
|
}
|
|
1419
|
+
// Edit/Write sonrası HAFIF syntax kontrolü → hata varsa model'e geri-besle (self-correct).
|
|
1420
|
+
// TS/JS: ts.transpileModule tek-dosya SYNTAX teşhisi (tip değil; cross-file false-positive yok).
|
|
1421
|
+
// Python: py_compile. Gerçek-codebase testi modelin karmaşık if/else'i bozduğunu (TS1128) gösterdi;
|
|
1422
|
+
// bu kontrol o sınıf hatayı yakalayıp model'in bir sonraki turda düzeltmesini sağlar. Engelleme YOK.
|
|
1423
|
+
const _nreq = createRequire(import.meta.url); // ESM dist'te çıplak require tanımsız → bunu kullan
|
|
1424
|
+
function syntaxCheck(fp, content) {
|
|
1425
|
+
const ext = path.extname(fp).toLowerCase();
|
|
1426
|
+
try {
|
|
1427
|
+
if (['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'].includes(ext)) {
|
|
1428
|
+
const ts = _nreq('typescript');
|
|
1429
|
+
// createSourceFile().parseDiagnostics = SADECE syntax hataları (tip yok → cross-file false-pozitif yok).
|
|
1430
|
+
const kind = ext === '.tsx' ? ts.ScriptKind.TSX : ext === '.jsx' ? ts.ScriptKind.JSX
|
|
1431
|
+
: ext === '.ts' ? ts.ScriptKind.TS : ts.ScriptKind.JS;
|
|
1432
|
+
const sf = ts.createSourceFile(fp, content, ts.ScriptTarget.Latest, true, kind);
|
|
1433
|
+
const pd = sf.parseDiagnostics || [];
|
|
1434
|
+
if (pd.length) {
|
|
1435
|
+
const d = pd[0];
|
|
1436
|
+
const msg = ts.flattenDiagnosticMessageText(d.messageText, ' ');
|
|
1437
|
+
const lc = sf.getLineAndCharacterOfPosition(d.start || 0);
|
|
1438
|
+
return `TS${d.code} (satır ${lc.line + 1}): ${msg}`;
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
else if (ext === '.py') {
|
|
1442
|
+
for (const py of ['python', 'python3']) {
|
|
1443
|
+
const r = spawnSync(py, ['-m', 'py_compile', fp], { encoding: 'utf8', timeout: 10000 });
|
|
1444
|
+
if (r.error)
|
|
1445
|
+
continue; // bu python yok → diğerini dene
|
|
1446
|
+
if (r.status !== 0)
|
|
1447
|
+
return (String(r.stderr || '').trim().split('\n').filter(Boolean).pop() || 'syntax error').slice(0, 200);
|
|
1448
|
+
return ''; // derlendi
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
catch { /* kontrol başarısız → sessiz geç, asla engelleme */ }
|
|
1453
|
+
return '';
|
|
1454
|
+
}
|
|
1455
|
+
// Yazılan dosyada syntax hatası varsa tool çıktısına eklenecek geri-besleme metni.
|
|
1456
|
+
function syntaxWarn(fp, content) {
|
|
1457
|
+
const err = syntaxCheck(fp, content);
|
|
1458
|
+
return err ? `\n⚠️ SYNTAX HATASI bu düzenlemeden sonra: ${err}\nDosya yazıldı ama BOZUK — bu hatayı şimdi düzelt (doğru sözdizimiyle tekrar Edit et).` : '';
|
|
1459
|
+
}
|
|
1418
1460
|
export async function executeTool(name, args) {
|
|
1419
1461
|
try {
|
|
1420
1462
|
if (name === 'See') {
|
|
@@ -1586,7 +1628,7 @@ export async function executeTool(name, args) {
|
|
|
1586
1628
|
}
|
|
1587
1629
|
readFiles.add(norm(_wfp));
|
|
1588
1630
|
const _ovr = (_existed && _wold !== _wnew) ? ' (uzerine yazildi)' : '';
|
|
1589
|
-
return { ok: true, output: `Wrote ${_wfp} (${_wnew.length} chars)${_ovr}${diffStat(_wold, _wnew)}` };
|
|
1631
|
+
return { ok: true, output: `Wrote ${_wfp} (${_wnew.length} chars)${_ovr}${diffStat(_wold, _wnew)}${syntaxWarn(_wfp, _wnew)}` };
|
|
1590
1632
|
}
|
|
1591
1633
|
if (name === 'Edit') {
|
|
1592
1634
|
const fp = resolveWs(args.file_path);
|
|
@@ -1622,7 +1664,7 @@ export async function executeTool(name, args) {
|
|
|
1622
1664
|
recordCheckpoint(fp, _ebefore, 'Edit'); // rewind: düzenleme öncesi tam içerik
|
|
1623
1665
|
c = args.replace_all ? c.split(oldStr).join(newStr) : c.replace(oldStr, newStr);
|
|
1624
1666
|
fs.writeFileSync(fp, c);
|
|
1625
|
-
return { ok: true, output: `Edited ${fp}${args.replace_all ? ` (${count} occurrences)` : ''}${_fuzzy}${diffStat(_ebefore, c)}` };
|
|
1667
|
+
return { ok: true, output: `Edited ${fp}${args.replace_all ? ` (${count} occurrences)` : ''}${_fuzzy}${diffStat(_ebefore, c)}${syntaxWarn(fp, c)}` };
|
|
1626
1668
|
}
|
|
1627
1669
|
if (name === 'Glob') {
|
|
1628
1670
|
const base = args.path ? resolveWs(args.path) : getBashCwd();
|