nothumanallowed 14.5.10 → 14.5.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nothumanallowed",
3
- "version": "14.5.10",
3
+ "version": "14.5.12",
4
4
  "description": "NotHumanAllowed — 38 AI agents, 80 tools, Studio (visual agentic workflows). Email, calendar, browser automation, screen capture, canvas, cron/heartbeat, Alexandria E2E messaging, GitHub, Notion, Slack, voice chat, free AI (Liara), 28 languages. Zero-dependency CLI.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/constants.mjs CHANGED
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'url';
5
5
  const __filename = fileURLToPath(import.meta.url);
6
6
  const __dirname = path.dirname(__filename);
7
7
 
8
- export const VERSION = '14.5.10';
8
+ export const VERSION = '14.5.12';
9
9
  export const BASE_URL = 'https://nothumanallowed.com/cli';
10
10
  export const API_BASE = 'https://nothumanallowed.com/api/v1';
11
11
 
@@ -615,71 +615,36 @@ async function runWebCraftAgent(config, projectName, message, attachments, emit,
615
615
  const language = LANG_MAP[(config?.language||'it').slice(0,2)] || 'Italian';
616
616
 
617
617
  const toolSpec = `
618
- AVAILABLE TOOLS (use exactly ONE tool per <tool> tag):
619
-
620
- ── FILE OPERATIONS ──
621
-
622
- 1. read — Read a file's content:
623
- <tool>{"op":"read","path":"relative/path.js"}</tool>
624
-
625
- 2. edit Surgical replacement (EXACT match required):
626
- <tool>{"op":"edit","path":"relative/path.js","old":"EXACT_CODE_TO_REPLACE","new":"REPLACEMENT_CODE"}</tool>
627
-
628
- 3. write — Write/create a file (full content):
629
- <tool>{"op":"write","path":"relative/path.js","content":"FULL_FILE_CONTENT"}</tool>
630
-
631
- 4. rename — Rename or move a file:
632
- <tool>{"op":"rename","path":"old/path.js","newPath":"new/path.js"}</tool>
633
-
634
- 5. delete — Delete a file:
635
- <tool>{"op":"delete","path":"relative/path.js"}</tool>
636
-
637
- ── VERIFICATION ──
638
-
639
- 6. check — Syntax check (JS/JSON/CSS/HTML):
640
- <tool>{"op":"check","path":"relative/path.js"}</tool>
641
-
642
- 7. lint — Full diagnostics with line numbers:
643
- <tool>{"op":"lint","path":"relative/path.js"}</tool>
644
-
645
- 8. search Grep/find text in project files:
646
- <tool>{"op":"search","query":"searchPattern","glob":"*.js"}</tool>
647
-
648
- 9. list — List all project files with sizes:
649
- <tool>{"op":"list"}</tool>
650
-
651
- ── EXECUTION ──
652
-
653
- 10. run — Execute a shell command in the project directory:
654
- <tool>{"op":"run","cmd":"npm install express"}</tool>
655
- <tool>{"op":"run","cmd":"npm test"}</tool>
656
- <tool>{"op":"run","cmd":"node -e \\"console.log(1+1)\\""}</tool>
657
-
658
- 11. sandbox — Restart the sandbox server to test changes:
659
- <tool>{"op":"sandbox"}</tool>
660
-
661
- ── DIFF ──
662
-
663
- 12. diff — Show diff between current file and last snapshot:
664
- <tool>{"op":"diff","path":"relative/path.js"}</tool>
665
-
666
- WORKFLOW — follow this for every change:
667
- 1. Read the file(s) you need to modify
668
- 2. Make your changes with edit or write
669
- 3. Use check or lint to verify — fix any errors
670
- 4. Use sandbox to restart and verify the app works
671
- 5. When ALL changes are complete and verified, output: <done/>
672
-
673
- RULES:
674
- - "old" in edit must be EXACT verbatim code — copy-paste from read output
675
- - ALWAYS use edit for modifying existing files — NEVER rewrite an entire file with write
676
- - write is ONLY for creating NEW files that don't exist yet
677
- - If you need to fix a bug, read the file first, then use edit to change only the broken lines
678
- - ALWAYS read before edit if you haven't seen the file content
679
- - ALWAYS check/lint after modifications
680
- - Use run for npm install, npm test, or any shell command
681
- - Use search to find code patterns across the project
682
- - Output <done/> when you are completely finished — MANDATORY
618
+ TOOLS use exactly ONE <tool> tag per action:
619
+
620
+ 1. read Read file:
621
+ <tool>{"op":"read","path":"file.js"}</tool>
622
+
623
+ 2. edit — Change specific lines in a file (THE ONLY WAY TO MODIFY FILES):
624
+ <tool>{"op":"edit","path":"file.js","old":"exact code to replace","new":"replacement code"}</tool>
625
+ CRITICAL: "old" must be EXACT text from the file. Always read the file first, then copy-paste the exact lines you want to change.
626
+
627
+ 3. write — Create a NEW file (ONLY for files that don't exist yet):
628
+ <tool>{"op":"write","path":"new-file.js","content":"file content"}</tool>
629
+
630
+ 4. rename: <tool>{"op":"rename","path":"old.js","newPath":"new.js"}</tool>
631
+ 5. delete: <tool>{"op":"delete","path":"file.js"}</tool>
632
+ 6. check: <tool>{"op":"check","path":"file.js"}</tool>
633
+ 7. lint: <tool>{"op":"lint","path":"file.js"}</tool>
634
+ 8. search: <tool>{"op":"search","query":"pattern","glob":"*.js"}</tool>
635
+ 9. list: <tool>{"op":"list"}</tool>
636
+ 10. run: <tool>{"op":"run","cmd":"npm test"}</tool>
637
+ 11. sandbox: <tool>{"op":"sandbox"}</tool>
638
+ 12. diff: <tool>{"op":"diff","path":"file.js"}</tool>
639
+
640
+ WORKFLOW:
641
+ 1. read → 2. edit (surgical changes ONLY) → 3. check → 4. sandbox → 5. <done/>
642
+
643
+ ⚠ CRITICAL RULES:
644
+ - To modify an existing file: ALWAYS use edit. NEVER use write on existing files — it will be REJECTED.
645
+ - edit workflow: read the file first → copy exact lines → use edit with old/new
646
+ - write is ONLY for creating brand new files
647
+ - Output <done/> when finished
683
648
  `;
684
649
 
685
650
  // Build system prompt with fresh file list each step
@@ -852,25 +817,50 @@ RULES:
852
817
  if (src === null) {
853
818
  toolResults.push({ op: 'edit', path: relPath, result: 'file_not_found' });
854
819
  emit({ type: 'tool', op: 'edit', path: relPath, result: 'file_not_found' });
855
- } else if (!src.includes(oldStr)) {
856
- const repaired = await _attemptEditRepair(config, relPath, src, oldStr, newStr);
857
- if (repaired) {
858
- ProjectStore.writeFile(projectName, relPath, repaired);
859
- hasChanges = true;
860
- modifiedFiles.add(relPath);
861
- toolResults.push({ op: 'edit', path: relPath, result: 'ok_repaired' });
862
- emit({ type: 'tool', op: 'edit', path: relPath, result: 'ok_repaired', oldSnippet: oldStr.slice(0, 300), newSnippet: newStr?.slice(0, 300) });
863
- } else {
864
- toolResults.push({ op: 'edit', path: relPath, result: 'old_not_found', hint: 'Use read to see current content, then retry with exact text' });
865
- emit({ type: 'tool', op: 'edit', path: relPath, result: 'old_not_found', oldSnippet: oldStr.slice(0, 200) });
866
- }
867
- } else {
820
+ } else if (src.includes(oldStr)) {
821
+ // Exact match apply directly
868
822
  const newSrc = src.replace(oldStr, newStr ?? '');
869
823
  ProjectStore.writeFile(projectName, relPath, newSrc);
870
824
  hasChanges = true;
871
825
  modifiedFiles.add(relPath);
872
826
  toolResults.push({ op: 'edit', path: relPath, result: 'ok' });
873
827
  emit({ type: 'tool', op: 'edit', path: relPath, result: 'ok', oldSnippet: oldStr.slice(0, 300), newSnippet: newStr?.slice(0, 300) ?? '' });
828
+ } else {
829
+ // Fuzzy match: compare lines ignoring leading/trailing whitespace
830
+ const oldLines = oldStr.split('\n').map(l => l.trim());
831
+ const srcLines = src.split('\n');
832
+ let matchStart = -1;
833
+ for (let i = 0; i <= srcLines.length - oldLines.length; i++) {
834
+ let ok = true;
835
+ for (let j = 0; j < oldLines.length; j++) {
836
+ if (srcLines[i + j].trim() !== oldLines[j]) { ok = false; break; }
837
+ }
838
+ if (ok) { matchStart = i; break; }
839
+ }
840
+ if (matchStart >= 0) {
841
+ // Fuzzy matched — replace the matched lines with new content
842
+ const before = srcLines.slice(0, matchStart).join('\n');
843
+ const after = srcLines.slice(matchStart + oldLines.length).join('\n');
844
+ const result = (before ? before + '\n' : '') + (newStr ?? '') + (after ? '\n' + after : '');
845
+ ProjectStore.writeFile(projectName, relPath, result);
846
+ hasChanges = true;
847
+ modifiedFiles.add(relPath);
848
+ toolResults.push({ op: 'edit', path: relPath, result: 'ok' });
849
+ emit({ type: 'tool', op: 'edit', path: relPath, result: 'ok', oldSnippet: oldStr.slice(0, 300), newSnippet: newStr?.slice(0, 300) });
850
+ } else {
851
+ // No fuzzy match — try LLM repair as last resort
852
+ const repaired = await _attemptEditRepair(config, relPath, src, oldStr, newStr);
853
+ if (repaired) {
854
+ ProjectStore.writeFile(projectName, relPath, repaired);
855
+ hasChanges = true;
856
+ modifiedFiles.add(relPath);
857
+ toolResults.push({ op: 'edit', path: relPath, result: 'ok_repaired' });
858
+ emit({ type: 'tool', op: 'edit', path: relPath, result: 'ok_repaired', oldSnippet: oldStr.slice(0, 300), newSnippet: newStr?.slice(0, 300) });
859
+ } else {
860
+ toolResults.push({ op: 'edit', path: relPath, result: 'old_not_found — read the file first, copy EXACT text to replace, then retry' });
861
+ emit({ type: 'tool', op: 'edit', path: relPath, result: 'old_not_found', oldSnippet: oldStr.slice(0, 200) });
862
+ }
863
+ }
874
864
  }
875
865
 
876
866
  // ── write ──