nothumanallowed 14.5.11 → 14.5.13

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.11",
3
+ "version": "14.5.13",
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.11';
8
+ export const VERSION = '14.5.13';
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
@@ -859,7 +824,7 @@ RULES:
859
824
  hasChanges = true;
860
825
  modifiedFiles.add(relPath);
861
826
  toolResults.push({ op: 'edit', path: relPath, result: 'ok' });
862
- emit({ type: 'tool', op: 'edit', path: relPath, result: 'ok', oldSnippet: oldStr.slice(0, 300), newSnippet: newStr?.slice(0, 300) ?? '' });
827
+ emit({ type: 'tool', op: 'edit', path: relPath, result: 'ok', oldSnippet: oldStr.slice(0, 2000), newSnippet: newStr?.slice(0, 2000) ?? '' });
863
828
  } else {
864
829
  // Fuzzy match: compare lines ignoring leading/trailing whitespace
865
830
  const oldLines = oldStr.split('\n').map(l => l.trim());
@@ -881,7 +846,7 @@ RULES:
881
846
  hasChanges = true;
882
847
  modifiedFiles.add(relPath);
883
848
  toolResults.push({ op: 'edit', path: relPath, result: 'ok' });
884
- emit({ type: 'tool', op: 'edit', path: relPath, result: 'ok', oldSnippet: oldStr.slice(0, 300), newSnippet: newStr?.slice(0, 300) });
849
+ emit({ type: 'tool', op: 'edit', path: relPath, result: 'ok', oldSnippet: oldStr.slice(0, 2000), newSnippet: newStr?.slice(0, 2000) });
885
850
  } else {
886
851
  // No fuzzy match — try LLM repair as last resort
887
852
  const repaired = await _attemptEditRepair(config, relPath, src, oldStr, newStr);
@@ -890,7 +855,7 @@ RULES:
890
855
  hasChanges = true;
891
856
  modifiedFiles.add(relPath);
892
857
  toolResults.push({ op: 'edit', path: relPath, result: 'ok_repaired' });
893
- emit({ type: 'tool', op: 'edit', path: relPath, result: 'ok_repaired', oldSnippet: oldStr.slice(0, 300), newSnippet: newStr?.slice(0, 300) });
858
+ emit({ type: 'tool', op: 'edit', path: relPath, result: 'ok_repaired', oldSnippet: oldStr.slice(0, 2000), newSnippet: newStr?.slice(0, 2000) });
894
859
  } else {
895
860
  toolResults.push({ op: 'edit', path: relPath, result: 'old_not_found — read the file first, copy EXACT text to replace, then retry' });
896
861
  emit({ type: 'tool', op: 'edit', path: relPath, result: 'old_not_found', oldSnippet: oldStr.slice(0, 200) });
@@ -781,7 +781,7 @@ Errore: `+e.msg,Le(!1))}catch{}}}}catch(e){Ne(t=>[...t,{role:`agent`,text:`Error
781
781
  `)}`),i(`files`)},children:`Fix`})]}),(0,k.jsx)(jT,{files:p,activeIndex:h,unsavedFiles:S,onSelect:e=>{g(e),x(null),y(null),be&&M.current!==null&&e!==M.current&&(fe.current&&clearTimeout(fe.current),fe.current=setTimeout(()=>{M.current!==null&&(g(M.current),y(null))},1e4))}})]}),(0,k.jsx)(`div`,{className:$.codeEditorWrap,children:Jt&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`div`,{className:$.codeHeader,children:[(0,k.jsx)(`span`,{className:$.codeFileIcon,children:HT(Jt.name)}),(0,k.jsx)(`span`,{className:$.codeFileName,children:Jt.name}),Jt.content&&!Jt._error&&(0,k.jsxs)(`span`,{className:$.codeFileMeta,children:[Jt.content.split(`
782
782
  `).length,` righe · `,UT(Jt.content)]}),!Jt._pending&&!Jt._error&&Jt.content&&(0,k.jsx)(`button`,{className:`${$.editToggleBtn} ${b===null?``:$.editToggleBtnActive}`,onClick:()=>{b===null?x(Jt.content):(m(e=>e.map((e,t)=>t===h?{...e,content:b}:e)),D(`/api/studio/webcraft/file/write`,{projectName:a,path:Jt.name,content:b}),x(null))},children:b===null?`✏ Modifica`:`💾 Salva`}),(0,k.jsx)(`button`,{className:$.headerIconBtn,title:`Split view`,onClick:()=>A(ae===null?+(h===0&&p.length>1):null),children:`⫼`}),(0,k.jsx)(`button`,{className:`${$.headerIconBtn} ${ie?$.headerIconBtnActive:``}`,title:`Terminal`,onClick:()=>O(!ie),children:`⌨`}),(0,k.jsx)(`button`,{className:$.headerIconBtn,title:`Development Guide`,onClick:()=>se(!0),children:`📖`})]}),w&&(0,k.jsxs)(`div`,{className:$.findBar,children:[(0,k.jsx)(`input`,{className:$.findInput,value:te,onChange:e=>T(e.target.value),placeholder:`Find...`,autoFocus:!0}),(0,k.jsx)(`input`,{className:$.findInput,value:ne,onChange:e=>re(e.target.value),placeholder:`Replace...`}),(0,k.jsx)(`span`,{className:$.findCount,children:te?((Jt.content||``).match(new RegExp(te.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),`gi`))?.length||0)+` found`:``}),(0,k.jsx)(`button`,{className:$.findBtn,onClick:()=>{!te||b===null||x(b.replace(new RegExp(te.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),`i`),ne))},children:`Replace`}),(0,k.jsx)(`button`,{className:$.findBtn,onClick:()=>{!te||b===null||x(b.replace(new RegExp(te.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),`gi`),ne))},children:`All`}),(0,k.jsx)(`button`,{className:$.findClose,onClick:()=>ee(!1),children:`×`})]}),Jt._error&&(0,k.jsx)(`div`,{className:$.fileError,children:`⚠ Generazione fallita — chiedi al modello di rigenerare questo file`}),Jt._syntaxError&&!Jt._error&&(0,k.jsxs)(`div`,{className:$.fileSyntaxError,children:[`⚠ Syntax error: `,Jt._syntaxError]}),be&&v!==null?(0,k.jsx)(`pre`,{className:$.streamingPre,ref:e=>{e&&pe.current&&(e.scrollTop=e.scrollHeight)},onScroll:e=>{let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<50?pe.current=!0:(pe.current=!1,me.current&&clearTimeout(me.current),me.current=setTimeout(()=>{pe.current=!0},15e3))},dangerouslySetInnerHTML:{__html:LT(v||``,(Jt.name.split(`.`).pop()||`js`).toLowerCase())+`<span class="`+$.streamingCursor+`">▋</span>`}}):(0,k.jsx)(TT,{value:b===null?Jt.content||``:b,filename:Jt.name,readOnly:b===null,projectName:a,onChange:e=>{x(e),Jt&&C(e=>new Set(e).add(Jt.name))},onSave:e=>{m(t=>t.map((t,n)=>n===h?{...t,content:e}:t)),D(`/api/studio/webcraft/file/write`,{projectName:a,path:Jt.name,content:e}),x(null),C(e=>{let t=new Set(e);return t.delete(Jt.name),t})}})]})}),ae!==null&&p[ae]&&(0,k.jsxs)(`div`,{className:$.codeEditorWrap,children:[(0,k.jsxs)(`div`,{className:$.codeHeader,children:[(0,k.jsx)(`span`,{className:$.codeFileIcon,children:HT(p[ae].name)}),(0,k.jsx)(`span`,{className:$.codeFileName,children:p[ae].name}),(0,k.jsx)(`button`,{className:$.headerIconBtn,onClick:()=>A(null),children:`✕`})]}),(0,k.jsx)(TT,{value:p[ae].content||``,filename:p[ae].name,readOnly:!0})]})]}),ie&&(0,k.jsxs)(`div`,{className:$.terminalPanel,children:[(0,k.jsxs)(`div`,{className:$.terminalHeader,children:[(0,k.jsx)(`span`,{className:$.terminalTitle,children:`Terminal`}),(0,k.jsx)(`button`,{className:$.terminalClose,onClick:()=>O(!1),children:`✕`})]}),(0,k.jsx)(IT,{projectDir:a||void 0})]})]})})]})]})]})}),L&&t!==`projects`&&(0,k.jsxs)(`div`,{className:$.planBanner,children:[(0,k.jsx)(`div`,{className:$.planTitle,children:`📌 Piano proposto — approva per eseguire`}),(0,k.jsx)(`pre`,{className:$.planText,children:L.plan}),(0,k.jsxs)(`div`,{className:$.planActions,children:[(0,k.jsx)(`button`,{className:$.planApprove,onClick:U,children:`✓ Esegui`}),(0,k.jsx)(`button`,{className:$.planReject,onClick:()=>Be(null),children:`✕ Annulla`})]})]}),Ye&&t!==`projects`&&(0,k.jsxs)(`div`,{className:$.grepPanel,children:[(0,k.jsxs)(`div`,{className:$.grepRow,children:[(0,k.jsx)(`input`,{className:$.grepInput,value:Ze,onChange:e=>Qe(e.target.value),onKeyDown:e=>e.key===`Enter`&&Rt(),placeholder:`Cerca nel codice...`}),(0,k.jsx)(`button`,{className:$.grepBtn,onClick:Rt,children:`🔍`}),(0,k.jsx)(`button`,{className:$.grepClose,onClick:()=>Xe(!1),children:`×`})]}),$e.length>0&&(0,k.jsxs)(`div`,{className:$.grepCount,children:[$e.length,` risultati`]}),(0,k.jsx)(`div`,{className:$.grepResults,children:$e.length===0?(0,k.jsx)(`div`,{className:$.grepEmpty,children:`Nessun risultato.`}):$e.map((e,t)=>(0,k.jsxs)(`div`,{className:$.grepMatch,onClick:()=>zt(e.file),children:[(0,k.jsxs)(`span`,{className:$.grepMatchFile,children:[e.file,`:`,e.lineNum]}),(0,k.jsx)(`pre`,{className:$.grepMatchLine,children:e.line})]},t))})]}),tt.length>0&&t!==`projects`&&(0,k.jsxs)(`div`,{className:$.diffPanel,children:[(0,k.jsxs)(`div`,{className:$.diffHeader,children:[(0,k.jsxs)(`span`,{children:[`🔌 Diff — `,tt.length,` file modificati`]}),(0,k.jsx)(`button`,{className:$.diffClose,onClick:()=>nt([]),children:`✕ Chiudi`})]}),tt.map((e,t)=>{let n=e.after.split(`
783
783
  `).length-e.before.split(`
784
- `).length;return(0,k.jsxs)(`details`,{open:!0,className:$.diffFile,children:[(0,k.jsxs)(`summary`,{className:$.diffSummary,children:[(0,k.jsx)(`span`,{className:$.diffArrow,children:`▲`}),(0,k.jsx)(`span`,{className:$.diffFileName,children:e.file}),(0,k.jsxs)(`span`,{className:n>=0?$.diffAdded:$.diffRemoved,children:[n>=0?`+`:``,n,` linee`]})]}),(0,k.jsx)(`div`,{className:$.diffContent,children:(0,k.jsx)(YT,{before:e.before,after:e.after})})]},t)})]}),t!==`projects`&&(0,k.jsxs)(`div`,{className:$.chatPanel,children:[(0,k.jsxs)(`div`,{className:$.chatMessages,ref:vt,children:[Me.length===0&&qt&&(0,k.jsxs)(`div`,{className:$.chatWelcome,children:[`🤖 `,e(`webcraft.doctrine.title`),` — `,(0,k.jsx)(`button`,{className:$.doctrineOpenBtn,onClick:()=>se(!0),children:`📖 Open Guide`})]}),Me.map((e,t)=>(0,k.jsxs)(`div`,{className:e.role===`user`?$.chatUser:e.role===`system`?$.chatSystem:$.chatAgent,children:[e.role===`user`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:$.chatUserBubble,children:e.text}),e.attachments&&e.attachments.length>0&&(0,k.jsx)(`div`,{className:$.chatAttachPreviews,children:e.attachments.map((e,t)=>(0,k.jsxs)(`span`,{className:$.chatAttachBadge,children:[`📎 `,e.name]},t))})]}),e.role===`system`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:$.chatSystemBubble,children:e.text}),e.syntaxErrors?.map((e,t)=>(0,k.jsxs)(`div`,{className:$.chatSyntaxErr,children:[`✕ `,e.file,`: `,e.error]},t))]}),e.role===`agent`&&(0,k.jsxs)(`div`,{className:$.chatAgentCard,children:[(0,k.jsxs)(`div`,{className:$.chatAgentHeader,children:[(0,k.jsx)(`span`,{className:$.chatAgentRobot,children:`🤖`}),(0,k.jsx)(`span`,{className:$.chatAgentLabel,children:`WebCraft Agent`})]}),(0,k.jsx)(`div`,{className:$.chatAgentText,dangerouslySetInnerHTML:{__html:RT(e.text.replace(/<tool>[\s\S]*?<\/tool>/g,``).trim())}}),e.tools&&e.tools.filter(e=>(e.op===`edit`||e.op===`write`)&&e.result===`ok`&&(e.oldSnippet||e.newSnippet)).map((e,t)=>(0,k.jsxs)(`div`,{className:$.diffInline,children:[(0,k.jsxs)(`div`,{className:$.diffInlineHeader,children:[`✏ `,e.path]}),(0,k.jsx)(YT,{before:e.oldSnippet||``,after:e.newSnippet||``,contextLines:5})]},t)),e.tools&&e.tools.length>0&&(0,k.jsx)(`div`,{className:$.chatToolBadges,children:e.tools.map((e,t)=>(0,k.jsxs)(`span`,{className:`${$.toolBadge} ${e.result===`ok`?$.toolBadgeOk:$.toolBadgeErr}`,children:[e.op===`edit`?`✏`:e.op===`write`?`+`:`👁`,` `,e.path]},t))})]})]},t)),Ie&&(()=>{let e=Me[Me.length-1]?.tools??[],t=e[e.length-1];return(0,k.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`6px 12px`,background:`rgba(99,102,241,0.08)`,borderRadius:8,fontSize:11,color:`#818cf8`,margin:`4px 0`},children:[(0,k.jsx)(`span`,{className:$.chatAgentRobotAnim,children:`🤖`}),(0,k.jsx)(`span`,{style:{fontWeight:600},children:`Working`}),(0,k.jsxs)(`span`,{className:$.chatRunningDots,children:[(0,k.jsx)(`span`,{className:`${$.dot} ${$.dot1}`}),(0,k.jsx)(`span`,{className:`${$.dot} ${$.dot2}`}),(0,k.jsx)(`span`,{className:`${$.dot} ${$.dot3}`})]}),t&&(0,k.jsxs)(`span`,{style:{color:`var(--dim)`,marginLeft:8},children:[t.op===`read`?`📖`:t.op===`edit`?`✏️`:t.op===`write`?`📝`:t.op===`search`?`🔍`:t.op===`lint`?`🔬`:t.op===`check`?`✓`:t.op===`run`?`▶`:t.op===`sandbox`?`🌐`:`🔧`,` `,t.path||t.op,` → `,t.result===`ok`?`✅`:t.result?.startsWith(`error`)?`❌`:t.result?.slice(0,30)]})]})})()]}),Re.length>0&&(0,k.jsx)(`div`,{className:$.attachPreviews,children:Re.map((e,t)=>(0,k.jsxs)(`span`,{className:$.attachBadge,children:[`📎 `,e.name,(0,k.jsx)(`button`,{className:$.removeAttachBtn,onClick:()=>ze(e=>e.filter((e,n)=>n!==t)),children:`×`})]},t))}),qt?(0,k.jsxs)(`div`,{className:$.projActiveRow,children:[`📄 `,(0,k.jsx)(`strong`,{className:$.projActiveName,children:a}),` — scrivi per modificare o migliorare il progetto`]}):(0,k.jsxs)(`div`,{className:$.projNameRow,children:[(0,k.jsx)(`span`,{className:$.projNameLabel,children:`Nome progetto:`}),(0,k.jsx)(`input`,{className:$.projNameInput,value:a,onChange:e=>o(e.target.value),placeholder:`MioProgetto`})]}),(0,k.jsxs)(`div`,{className:$.chatInputRow,children:[(0,k.jsxs)(`label`,{className:$.attachLabel,title:`Allega immagine o PDF`,children:[`📎`,(0,k.jsx)(`input`,{ref:yt,type:`file`,multiple:!0,accept:`image/*,.pdf`,style:{display:`none`},onChange:e=>Kt(e.target.files)})]}),(0,k.jsx)(`textarea`,{className:$.chatTextarea,value:Pe,onChange:e=>Fe(e.target.value),placeholder:qt?`Parla con il tuo agente: chiedi correzioni, migliorie, nuove funzionalità...`:`Descrivi il progetto da creare, poi premi Genera...`,disabled:Yt,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Dt())},rows:4}),(0,k.jsxs)(`div`,{className:$.chatSendCol,children:[(0,k.jsx)(`button`,{className:$.chatSendBtn,onClick:Dt,disabled:Yt,children:be?`⏳`:qt?`▶`:`▶ Genera`}),Yt&&!Se&&(0,k.jsx)(`button`,{className:$.chatStopBtn,onClick:At,children:`⏹ Stop`})]})]})]}),oe&&(0,k.jsx)(`div`,{className:$.modalOverlay,onClick:()=>se(!1),children:(0,k.jsxs)(`div`,{className:$.modal,onClick:e=>e.stopPropagation(),style:{width:720,maxHeight:`90vh`},children:[(0,k.jsxs)(`div`,{className:$.modalHeader,children:[(0,k.jsxs)(`span`,{className:$.modalTitle,children:[`📖 `,e(`webcraft.doctrine.title`)]}),(0,k.jsx)(`span`,{className:$.doctrineSubtitle,children:e(`webcraft.doctrine.subtitle`)}),(0,k.jsx)(`button`,{className:$.modalClose,onClick:()=>se(!1),children:`✕`})]}),(0,k.jsx)(`div`,{className:$.modalBody,style:{gap:0},children:[`phase1`,`phase2`,`phase3`,`phase4`,`phase5`,`tools`,`golden`].map(t=>(0,k.jsxs)(`div`,{className:$.doctrineSection,children:[(0,k.jsx)(`div`,{className:$.doctrineSectionTitle,children:e(`webcraft.doctrine.${t}.title`)}),(0,k.jsx)(`div`,{className:$.doctrineSectionBody,children:e(`webcraft.doctrine.${t}.desc`).split(`
784
+ `).length;return(0,k.jsxs)(`details`,{open:!0,className:$.diffFile,children:[(0,k.jsxs)(`summary`,{className:$.diffSummary,children:[(0,k.jsx)(`span`,{className:$.diffArrow,children:`▲`}),(0,k.jsx)(`span`,{className:$.diffFileName,children:e.file}),(0,k.jsxs)(`span`,{className:n>=0?$.diffAdded:$.diffRemoved,children:[n>=0?`+`:``,n,` linee`]})]}),(0,k.jsx)(`div`,{className:$.diffContent,children:(0,k.jsx)(YT,{before:e.before,after:e.after})})]},t)})]}),t!==`projects`&&(0,k.jsxs)(`div`,{className:$.chatPanel,children:[(0,k.jsxs)(`div`,{className:$.chatMessages,ref:vt,children:[Me.length===0&&qt&&(0,k.jsxs)(`div`,{className:$.chatWelcome,children:[`🤖 `,e(`webcraft.doctrine.title`),` — `,(0,k.jsx)(`button`,{className:$.doctrineOpenBtn,onClick:()=>se(!0),children:`📖 Open Guide`})]}),Me.map((e,t)=>(0,k.jsxs)(`div`,{className:e.role===`user`?$.chatUser:e.role===`system`?$.chatSystem:$.chatAgent,children:[e.role===`user`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:$.chatUserBubble,children:e.text}),e.attachments&&e.attachments.length>0&&(0,k.jsx)(`div`,{className:$.chatAttachPreviews,children:e.attachments.map((e,t)=>(0,k.jsxs)(`span`,{className:$.chatAttachBadge,children:[`📎 `,e.name]},t))})]}),e.role===`system`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:$.chatSystemBubble,children:e.text}),e.syntaxErrors?.map((e,t)=>(0,k.jsxs)(`div`,{className:$.chatSyntaxErr,children:[`✕ `,e.file,`: `,e.error]},t))]}),e.role===`agent`&&(0,k.jsxs)(`div`,{className:$.chatAgentCard,children:[(0,k.jsxs)(`div`,{className:$.chatAgentHeader,children:[(0,k.jsx)(`span`,{className:$.chatAgentRobot,children:`🤖`}),(0,k.jsx)(`span`,{className:$.chatAgentLabel,children:`WebCraft Agent`})]}),(0,k.jsx)(`div`,{className:$.chatAgentText,dangerouslySetInnerHTML:{__html:RT(e.text.replace(/<tool>[\s\S]*?<\/tool>/g,``).trim())}}),e.tools&&e.tools.filter(e=>(e.op===`edit`||e.op===`write`)&&(e.result===`ok`||e.result===`ok_fuzzy`||e.result===`ok_repaired`)&&(e.oldSnippet||e.newSnippet)).map((e,t)=>(0,k.jsxs)(`div`,{className:$.diffInline,children:[(0,k.jsxs)(`div`,{className:$.diffInlineHeader,children:[(0,k.jsxs)(`span`,{children:[`✏ `,e.path]}),e.result===`ok_fuzzy`&&(0,k.jsx)(`span`,{style:{fontSize:9,color:`#facc15`,marginLeft:6},children:`fuzzy match`}),e.result===`ok_repaired`&&(0,k.jsx)(`span`,{style:{fontSize:9,color:`#c084fc`,marginLeft:6},children:`auto-repaired`})]}),(0,k.jsx)(YT,{before:e.oldSnippet||``,after:e.newSnippet||``,contextLines:5})]},t)),e.tools&&e.tools.length>0&&(0,k.jsx)(`div`,{className:$.chatToolBadges,children:e.tools.map((e,t)=>{let n=e.op===`edit`?`✏️`:e.op===`write`?`📝`:e.op===`read`?`📖`:e.op===`search`?`🔍`:e.op===`check`?`✓`:e.op===`lint`?`🔬`:e.op===`run`?`▶`:e.op===`sandbox`?`🌐`:e.op===`delete`?`🗑`:e.op===`rename`?`📋`:e.op===`list`?`📁`:e.op===`diff`?`🔀`:`⚡`,r=e.result===`ok`||e.result===`ok_fuzzy`||e.result===`ok_repaired`,a=e.result?.startsWith(`error`)||e.result===`old_not_found`||e.result===`blocked_use_edit`||e.result===`file_not_found`,o=e.path&&(e.op===`edit`||e.op===`read`||e.op===`write`||e.op===`check`||e.op===`lint`);return(0,k.jsxs)(`span`,{className:`${$.toolBadge} ${r?$.toolBadgeOk:a?$.toolBadgeErr:``}`,style:o?{cursor:`pointer`}:void 0,onClick:o?()=>{let t=p.findIndex(t=>t.name===e.path);t>=0&&(g(t),i(`files`))}:void 0,title:o?`Apri ${e.path}`:e.result||``,children:[n,` `,e.path||e.op,` `,r?`✅`:a?`❌`:``]},t)})})]})]},t)),Ie&&(()=>{let e=Me[Me.length-1]?.tools??[],t=e[e.length-1];return(0,k.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,padding:`6px 12px`,background:`rgba(99,102,241,0.08)`,borderRadius:8,fontSize:11,color:`#818cf8`,margin:`4px 0`},children:[(0,k.jsx)(`span`,{className:$.chatAgentRobotAnim,children:`🤖`}),(0,k.jsx)(`span`,{style:{fontWeight:600},children:`Working`}),(0,k.jsxs)(`span`,{className:$.chatRunningDots,children:[(0,k.jsx)(`span`,{className:`${$.dot} ${$.dot1}`}),(0,k.jsx)(`span`,{className:`${$.dot} ${$.dot2}`}),(0,k.jsx)(`span`,{className:`${$.dot} ${$.dot3}`})]}),t&&(0,k.jsxs)(`span`,{style:{color:`var(--dim)`,marginLeft:8},children:[t.op===`read`?`📖`:t.op===`edit`?`✏️`:t.op===`write`?`📝`:t.op===`search`?`🔍`:t.op===`lint`?`🔬`:t.op===`check`?`✓`:t.op===`run`?`▶`:t.op===`sandbox`?`🌐`:`🔧`,` `,t.path||t.op,` → `,t.result===`ok`?`✅`:t.result?.startsWith(`error`)?`❌`:t.result?.slice(0,30)]})]})})()]}),Re.length>0&&(0,k.jsx)(`div`,{className:$.attachPreviews,children:Re.map((e,t)=>(0,k.jsxs)(`span`,{className:$.attachBadge,children:[`📎 `,e.name,(0,k.jsx)(`button`,{className:$.removeAttachBtn,onClick:()=>ze(e=>e.filter((e,n)=>n!==t)),children:`×`})]},t))}),qt?(0,k.jsxs)(`div`,{className:$.projActiveRow,children:[`📄 `,(0,k.jsx)(`strong`,{className:$.projActiveName,children:a}),` — scrivi per modificare o migliorare il progetto`]}):(0,k.jsxs)(`div`,{className:$.projNameRow,children:[(0,k.jsx)(`span`,{className:$.projNameLabel,children:`Nome progetto:`}),(0,k.jsx)(`input`,{className:$.projNameInput,value:a,onChange:e=>o(e.target.value),placeholder:`MioProgetto`})]}),(0,k.jsxs)(`div`,{className:$.chatInputRow,children:[(0,k.jsxs)(`label`,{className:$.attachLabel,title:`Allega immagine o PDF`,children:[`📎`,(0,k.jsx)(`input`,{ref:yt,type:`file`,multiple:!0,accept:`image/*,.pdf`,style:{display:`none`},onChange:e=>Kt(e.target.files)})]}),(0,k.jsx)(`textarea`,{className:$.chatTextarea,value:Pe,onChange:e=>Fe(e.target.value),placeholder:qt?`Parla con il tuo agente: chiedi correzioni, migliorie, nuove funzionalità...`:`Descrivi il progetto da creare, poi premi Genera...`,disabled:Yt,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Dt())},rows:4}),(0,k.jsxs)(`div`,{className:$.chatSendCol,children:[(0,k.jsx)(`button`,{className:$.chatSendBtn,onClick:Dt,disabled:Yt,children:be?`⏳`:qt?`▶`:`▶ Genera`}),Yt&&!Se&&(0,k.jsx)(`button`,{className:$.chatStopBtn,onClick:At,children:`⏹ Stop`})]})]})]}),oe&&(0,k.jsx)(`div`,{className:$.modalOverlay,onClick:()=>se(!1),children:(0,k.jsxs)(`div`,{className:$.modal,onClick:e=>e.stopPropagation(),style:{width:720,maxHeight:`90vh`},children:[(0,k.jsxs)(`div`,{className:$.modalHeader,children:[(0,k.jsxs)(`span`,{className:$.modalTitle,children:[`📖 `,e(`webcraft.doctrine.title`)]}),(0,k.jsx)(`span`,{className:$.doctrineSubtitle,children:e(`webcraft.doctrine.subtitle`)}),(0,k.jsx)(`button`,{className:$.modalClose,onClick:()=>se(!1),children:`✕`})]}),(0,k.jsx)(`div`,{className:$.modalBody,style:{gap:0},children:[`phase1`,`phase2`,`phase3`,`phase4`,`phase5`,`tools`,`golden`].map(t=>(0,k.jsxs)(`div`,{className:$.doctrineSection,children:[(0,k.jsx)(`div`,{className:$.doctrineSectionTitle,children:e(`webcraft.doctrine.${t}.title`)}),(0,k.jsx)(`div`,{className:$.doctrineSectionBody,children:e(`webcraft.doctrine.${t}.desc`).split(`
785
785
  `).map((e,t)=>(0,k.jsx)(`p`,{className:e.startsWith(`•`)||e.startsWith(`1.`)||e.startsWith(`2.`)||e.startsWith(`3.`)||e.startsWith(`4.`)||e.startsWith(`5.`)||e.startsWith(`6.`)?$.doctrineBullet:``,children:e},t))})]},t))}),(0,k.jsx)(`div`,{className:$.modalFooter,children:(0,k.jsx)(`button`,{className:$.modalSaveBtn,onClick:()=>se(!1),style:{padding:`10px 28px`,fontSize:14},children:e(`webcraft.doctrine.close`)})})]})}),Ge&&(0,k.jsx)(XT,{modal:Ge,skills:Ve,projectName:a,onClose:()=>Ke(null),onSave:(e,t,n)=>H(Ge,e,t,n)})]})}function KT(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===r&&e.every((e,n)=>e===t[n]))return e.map((e,t)=>({type:`same`,text:e,oldLine:t+1,newLine:t+1}));if(n+r>8e3)return qT(e,t);let i=n+r,a=2*i+1,o=new Int32Array(a).fill(-1);new Int32Array(a).fill(-1);let s=i;o[s+1]=0;let c=[];outer:for(let l=0;l<=i;l++){let i=new Int32Array(a);i.set(o),c.push(i);for(let i=-l;i<=l;i+=2){let a;a=i===-l||i!==l&&o[s+i-1]<o[s+i+1]?o[s+i+1]:o[s+i-1]+1;let c=a-i;for(;a<n&&c<r&&e[a]===t[c];)a++,c++;if(o[s+i]=a,a>=n&&c>=r)break outer}}let l=[],u=n,d=r;for(let n=c.length-1;n>0;n--){let r=c[n-1],i=u-d,a;a=i===-n||i!==n&&r[s+i-1]<r[s+i+1]?i+1:i-1;let o=r[s+a],f=o-a;for(;u>o&&d>f;)u--,d--,l.push({type:`same`,text:e[u],oldLine:u+1,newLine:d+1});u>o?(u--,l.push({type:`rem`,text:e[u],oldLine:u+1})):d>f&&(d--,l.push({type:`add`,text:t[d],newLine:d+1}))}for(;u>0&&d>0;)u--,d--,l.push({type:`same`,text:e[u],oldLine:u+1,newLine:d+1});return l.reverse(),l}function qT(e,t){let n=[],r=0,i=0;for(;(r<e.length||i<t.length)&&(r>=e.length?(n.push({type:`add`,text:t[i],newLine:i+1}),i++):i>=t.length?(n.push({type:`rem`,text:e[r],oldLine:r+1}),r++):e[r]===t[i]?(n.push({type:`same`,text:e[r],oldLine:r+1,newLine:i+1}),r++,i++):(n.push({type:`rem`,text:e[r],oldLine:r+1}),n.push({type:`add`,text:t[i],newLine:i+1}),r++,i++),!(n.length>4e3)););return n}function JT(e,t){let n=e.split(/(\s+)/),r=t.split(/(\s+)/),i=n.length,a=r.length;if(i+a>400)return{old:(0,k.jsx)(k.Fragment,{children:e}),new:(0,k.jsx)(k.Fragment,{children:t})};let o=Array.from({length:i+1},()=>Array(a+1).fill(0));for(let e=1;e<=i;e++)for(let t=1;t<=a;t++)o[e][t]=n[e-1]===r[t-1]?o[e-1][t-1]+1:Math.max(o[e-1][t],o[e][t-1]);let s=[],c=[],l=i,u=a,d=[],f=[];for(;l>0||u>0;)l>0&&u>0&&n[l-1]===r[u-1]?(d.push({text:n[l-1],changed:!1}),f.push({text:r[u-1],changed:!1}),l--,u--):u>0&&(l===0||o[l][u-1]>=o[l-1][u])?(f.push({text:r[u-1],changed:!0}),u--):(d.push({text:n[l-1],changed:!0}),l--);return d.reverse().forEach(e=>s.push(e)),f.reverse().forEach(e=>c.push(e)),{old:(0,k.jsx)(k.Fragment,{children:s.map((e,t)=>e.changed?(0,k.jsx)(`span`,{style:{background:`rgba(248,113,113,0.3)`,borderRadius:2},children:e.text},t):(0,k.jsx)(`span`,{children:e.text},t))}),new:(0,k.jsx)(k.Fragment,{children:c.map((e,t)=>e.changed?(0,k.jsx)(`span`,{style:{background:`rgba(74,222,128,0.3)`,borderRadius:2},children:e.text},t):(0,k.jsx)(`span`,{children:e.text},t))})}}function YT({before:e,after:t,contextLines:n=3}){let r=KT(e.split(`
786
786
  `),t.split(`
787
787
  `)),i=new Set;r.forEach((e,t)=>{e.type!==`same`&&i.add(t)});let a=new Set;if(i.forEach(e=>{for(let t=Math.max(0,e-n);t<=Math.min(r.length-1,e+n);t++)a.add(t)}),i.size===0)for(let e=0;e<Math.min(5,r.length);e++)a.add(e);let o=new Map;for(let e=0;e<r.length-1;e++)r[e].type===`rem`&&r[e+1].type===`add`&&o.set(e,JT(r[e].text,r[e+1].text));let s=[],c=-1;for(let e=0;e<r.length;e++){if(!a.has(e))continue;if(c>=0&&e-c>1){let t=e-c-1;s.push((0,k.jsxs)(`div`,{style:{padding:`2px 8px`,background:`rgba(99,102,241,0.08)`,color:`#6366f1`,fontSize:9,textAlign:`center`,borderTop:`1px solid rgba(99,102,241,0.15)`,borderBottom:`1px solid rgba(99,102,241,0.15)`,userSelect:`none`},children:[`@@ `,t,` righe nascoste @@`]},`fold-${e}`))}c=e;let t=r[e],n=t.type===`add`?`rgba(74,222,128,0.08)`:t.type===`rem`?`rgba(248,113,113,0.08)`:`transparent`,i=t.type===`add`?`3px solid #4ade80`:t.type===`rem`?`3px solid #f87171`:`3px solid transparent`,l=t.type===`add`?`#4ade80`:t.type===`rem`?`#f87171`:`var(--dim)`,u=t.type===`add`?`+`:t.type===`rem`?`-`:` `,d=t.text,f=o.get(e);f&&t.type===`rem`&&(d=f.old);let p=o.get(e-1);p&&t.type===`add`&&(d=p.new),s.push((0,k.jsxs)(`div`,{style:{display:`flex`,alignItems:`stretch`,background:n,borderLeft:i,fontFamily:`var(--mono)`,fontSize:11,lineHeight:`18px`},children:[(0,k.jsx)(`span`,{style:{width:36,textAlign:`right`,padding:`0 4px`,color:`rgba(255,255,255,0.2)`,fontSize:10,flexShrink:0,userSelect:`none`},children:t.oldLine??``}),(0,k.jsx)(`span`,{style:{width:36,textAlign:`right`,padding:`0 4px`,color:`rgba(255,255,255,0.2)`,fontSize:10,flexShrink:0,userSelect:`none`},children:t.newLine??``}),(0,k.jsx)(`span`,{style:{width:14,textAlign:`center`,color:l,fontWeight:700,flexShrink:0,userSelect:`none`},children:u}),(0,k.jsx)(`span`,{style:{flex:1,padding:`0 4px`,color:l,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:d})]},e))}return(0,k.jsx)(`div`,{style:{overflow:`auto`,maxHeight:400},children:s})}function XT({modal:e,skills:t,projectName:n,onClose:r,onSave:i}){let[a,o]=(0,_.useState)(e.name),[s,c]=(0,_.useState)(e.content),[l,u]=(0,_.useState)(e.type),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(!1),h=l===`skill`?6e3:4e3,g=s.length>h;async function v(){if(!d.trim())return;m(!0);let e={skill:`Sei un esperto di sviluppo web fullstack. Genera un file Markdown "skill" per il WebCraft Agent. Deve contenere istruzioni, pattern di codice, best practice e snippet pronti all uso come contesto persistente. Scrivi SOLO il contenuto Markdown, niente altro.`,memory:`Sei un assistente tecnico. Genera un file Markdown "memory" per il WebCraft Agent. Deve riassumere decisioni architetturali, preferenze dello sviluppatore e contesto generale del progetto. Scrivi SOLO il Markdown.`,provider:`Sei un esperto di prompt engineering. Genera un file Markdown con istruzioni specifiche per calibrare il comportamento del modello AI. Scrivi SOLO il Markdown.`},t=await D(`/api/studio/webcraft`,{system:e[l]??e.skill,user:`Progetto: ${n}\n\n${d}`,max_tokens:2048});t?.text&&(c(t.text),a||o(l===`memory`?`memory.md`:l===`provider`?`liara.md`:d.toLowerCase().replace(/[^a-z0-9]+/g,`-`).slice(0,30)+`.md`)),m(!1)}function y(){if(!a.trim()){alert(`Inserisci un nome per il file.`);return}let n=a.endsWith(`.md`)?a:a+`.md`;if((l===`memory`||l===`provider`)&&e.mode===`new`&&t.findIndex(e=>e.type===l)>=0){alert(`Esiste già un file di tipo "${l}". Modificalo direttamente.`);return}i(n,s,l)}return(0,k.jsx)(`div`,{className:$.modalOverlay,onClick:e=>{e.target===e.currentTarget&&r()},children:(0,k.jsxs)(`div`,{className:$.modal,children:[(0,k.jsxs)(`div`,{className:$.modalHeader,children:[(0,k.jsxs)(`span`,{className:$.modalTitle,children:[WT(l),` `,e.mode===`new`?`Nuovo file di contesto`:`Modifica ${e.name}`]}),(0,k.jsx)(`button`,{className:$.modalClose,onClick:r,children:`×`})]}),(0,k.jsx)(`div`,{className:$.modalBody,children:e.mode===`view`?(0,k.jsx)(`pre`,{className:$.logView,children:s}):(0,k.jsxs)(k.Fragment,{children:[e.mode===`new`&&(0,k.jsxs)(`div`,{className:$.modalRow,children:[(0,k.jsxs)(`div`,{className:$.modalField,children:[(0,k.jsx)(`div`,{className:$.modalLabel,children:`TIPO`}),(0,k.jsx)(`select`,{value:l,onChange:e=>{let t=e.target.value;u(t),t===`memory`?o(`memory.md`):t===`provider`&&o(`liara.md`)},className:$.modalSelect,children:[`skill`,`memory`,`provider`].map(e=>{let n=(e===`memory`||e===`provider`)&&t.some(t=>t.type===e);return(0,k.jsxs)(`option`,{value:e,disabled:n,children:[e,n?` (esiste già)`:``]},e)})})]}),(0,k.jsxs)(`div`,{className:$.modalField,style:{flex:2},children:[(0,k.jsx)(`div`,{className:$.modalLabel,children:`NOME FILE`}),(0,k.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:l===`memory`?`memory.md`:l===`provider`?`liara.md`:`nome-skill.md`,className:$.modalInput})]})]}),(0,k.jsxs)(`div`,{className:$.modalHint,children:[`💡 `,l===`skill`?`Istruzioni tecniche, snippet, pattern di codice specifici. Max ~6000 caratteri.`:l===`memory`?`Note persistenti sul progetto: decisioni architetturali, preferenze. Solo UN file. Max ~4000 caratteri.`:`Istruzioni specifiche per il modello AI (tono, formato, vincoli). Solo UN file. Max ~4000 caratteri.`]}),(0,k.jsxs)(`div`,{className:$.modalAiBox,children:[(0,k.jsx)(`div`,{className:$.modalLabel,children:`🤖 GENERA CON AI`}),(0,k.jsxs)(`div`,{className:$.modalAiRow,children:[(0,k.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),rows:2,placeholder:`Descrivi cosa deve contenere questo file...`,className:$.modalAiDesc}),(0,k.jsx)(`button`,{onClick:v,disabled:p,className:$.modalAiBtn,children:p?`⏳ ...`:`▶ Genera`})]})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:$.modalLabelRow,children:[(0,k.jsx)(`span`,{children:`CONTENUTO (markdown)`}),(0,k.jsxs)(`span`,{style:{color:g?`#e05050`:`var(--dim)`},children:[s.length,` car.`,g?` ⚠ Troppo lungo`:``]})]}),(0,k.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),rows:14,placeholder:`# Titolo
@@ -8,7 +8,7 @@
8
8
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
9
9
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10
10
  <title>NHA — NotHumanAllowed</title>
11
- <script type="module" crossorigin src="/assets/index-wpLo6Nu6.js"></script>
11
+ <script type="module" crossorigin src="/assets/index-D7aSNaGO.js"></script>
12
12
  <link rel="stylesheet" crossorigin href="/assets/index-CIozt-VX.css">
13
13
  </head>
14
14
  <body>