@maincode-ai/matilda-code 0.21.11 → 0.21.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.
Files changed (174) hide show
  1. package/bundled/mainy/docs/configuration/model-providers.md +0 -82
  2. package/bundled/mainy/docs/configuration/settings.md +46 -7
  3. package/bundled/mainy/docs/configuration/trusted-folders.md +12 -6
  4. package/bundled/mainy/docs/features/auto-mode.md +1 -1
  5. package/bundled/mainy/docs/features/channels/_meta.ts +0 -3
  6. package/bundled/mainy/docs/features/channels/overview.md +8 -16
  7. package/bundled/mainy/docs/features/commands.md +4 -4
  8. package/bundled/mainy/docs/features/hooks.md +9 -7
  9. package/bundled/mainy/docs/features/language.md +2 -29
  10. package/bundled/mainy/docs/features/worktree.md +0 -2
  11. package/bundled/mainy/docs/integration-github-action.md +3 -3
  12. package/bundled/mainy/docs/quickstart.md +2 -2
  13. package/bundled/mainy/docs/support/troubleshooting.md +1 -1
  14. package/chunks/agent-SRAIVZEE.js +3 -0
  15. package/chunks/agent-headless-XRDOZESG.js +3 -0
  16. package/chunks/{anthropicContentGenerator-IYZILRDW.js → anthropicContentGenerator-LLDIKDMQ.js} +3 -3
  17. package/chunks/{askUserQuestion-XWHJY3DM.js → askUserQuestion-BNSWGD26.js} +1 -1
  18. package/chunks/{ca-EUJBUYX5.js → ca-NPYL24ME.js} +2 -2
  19. package/chunks/{chunk-4YVN5HXG.js → chunk-27HUYW23.js} +2 -2
  20. package/chunks/{chunk-MH2P4YXC.js → chunk-27Q5KW3A.js} +2 -2
  21. package/chunks/{chunk-NYEWHSBL.js → chunk-2HTPVSGT.js} +1 -1
  22. package/chunks/{chunk-EQGA7LH7.js → chunk-3B2HABK7.js} +1 -1
  23. package/chunks/chunk-3MTZTNAU.js +101 -0
  24. package/chunks/{chunk-WHG6N5X2.js → chunk-5OHGYMKP.js} +1 -1
  25. package/chunks/{chunk-QH7736R5.js → chunk-6EQMZNIY.js} +1 -1
  26. package/chunks/chunk-6I6VGTKD.js +8 -0
  27. package/chunks/{chunk-5427BPR2.js → chunk-6M5G5FBH.js} +1 -1
  28. package/chunks/{chunk-4FVBPNTZ.js → chunk-6T2GIM76.js} +1 -1
  29. package/chunks/chunk-7ZODGQO6.js +4 -0
  30. package/chunks/chunk-AOOZREGV.js +9 -0
  31. package/chunks/{chunk-JXUDKX6D.js → chunk-DE3HKC2W.js} +1 -1
  32. package/chunks/chunk-DHDD5YJC.js +207 -0
  33. package/chunks/{chunk-SPW5DXX4.js → chunk-EZDV7A76.js} +1 -1
  34. package/chunks/{chunk-ODZOYHIC.js → chunk-GOJCMVJJ.js} +1 -1
  35. package/chunks/{chunk-FFFZ2QMG.js → chunk-GTVCJCHR.js} +1 -1
  36. package/chunks/{chunk-Q55AVE2N.js → chunk-IJEGHQ7Z.js} +11 -11
  37. package/chunks/{chunk-SUH3UUWZ.js → chunk-JCE3JAVC.js} +1 -1
  38. package/chunks/chunk-KHHJYBR5.js +9 -0
  39. package/chunks/{chunk-GO2GA2GY.js → chunk-LUNDTQ3G.js} +1 -1
  40. package/chunks/{chunk-NIQK6NX3.js → chunk-LWARA7JY.js} +1 -1
  41. package/chunks/{chunk-YMIF2DMT.js → chunk-MEV5XQI2.js} +1 -1
  42. package/chunks/{chunk-4CSSDBOS.js → chunk-P5TG5CON.js} +10 -10
  43. package/chunks/chunk-PEKAUGYV.js +2621 -0
  44. package/chunks/chunk-PGUG43HG.js +24 -0
  45. package/chunks/{chunk-ELH4YHJR.js → chunk-PGXQZVLX.js} +1 -1
  46. package/chunks/{chunk-SNLH42QJ.js → chunk-QZI2ZGZY.js} +1 -1
  47. package/chunks/chunk-RI54U73U.js +56 -0
  48. package/chunks/chunk-RPFSFS7Z.js +39 -0
  49. package/chunks/chunk-SOEIVSM5.js +113 -0
  50. package/chunks/{chunk-4J6DC24J.js → chunk-SVSY6AWS.js} +1 -1
  51. package/chunks/{chunk-T4P4KEDW.js → chunk-TWJLOEAI.js} +2 -2
  52. package/chunks/{chunk-HYVP4472.js → chunk-V6UPUMP3.js} +1 -1
  53. package/chunks/chunk-W4QSMIWO.js +9 -0
  54. package/chunks/chunk-WC2VTVCE.js +27 -0
  55. package/chunks/{chunk-GUFIMKF5.js → chunk-YV3PUOBU.js} +1 -1
  56. package/chunks/chunk-ZX34M2GF.js +14 -0
  57. package/chunks/{computer-use-SXP25RZQ.js → computer-use-J4GAM4M6.js} +1 -1
  58. package/chunks/contextCommand-5F5M7NA4.js +3 -0
  59. package/chunks/{cron-create-2UI4AT4Q.js → cron-create-IDWSZENI.js} +1 -1
  60. package/chunks/{cron-delete-ZB6BOTFF.js → cron-delete-NQCDZDUI.js} +1 -1
  61. package/chunks/{cron-list-YYAXNHB6.js → cron-list-Z4XMC3TO.js} +1 -1
  62. package/chunks/{de-DNEPG7S7.js → de-34YZHGC6.js} +3 -3
  63. package/chunks/{devtools-5JRKK3E7.js → devtools-XRQ4YJ5S.js} +1 -1
  64. package/chunks/{dist-P6SLWL5V.js → dist-PH6JW7XD.js} +1 -1
  65. package/chunks/edit-X2S2ZXRN.js +43 -0
  66. package/chunks/{en-NOD6KQNM.js → en-QLGMD6OS.js} +3 -3
  67. package/chunks/{enter-worktree-X47BSJLE.js → enter-worktree-TUCGNCLO.js} +1 -1
  68. package/chunks/{enterPlanMode-F22ZNTYJ.js → enterPlanMode-SQEZAAIR.js} +1 -1
  69. package/chunks/{exit-worktree-XY5UMDHX.js → exit-worktree-7FLITFZI.js} +1 -1
  70. package/chunks/exitPlanMode-O5UUJ3GM.js +120 -0
  71. package/chunks/{fr-2OE5WLJ4.js → fr-EDNBQACJ.js} +3 -3
  72. package/chunks/geminiContentGenerator-FIZFLPU3.js +8 -0
  73. package/chunks/glob-GSFTYAS2.js +22 -0
  74. package/chunks/{goal-tools-6QTC3UI7.js → goal-tools-YQOA6OKU.js} +1 -1
  75. package/chunks/{grep-6TTPZ524.js → grep-VAB2VSXM.js} +1 -1
  76. package/chunks/{ja-3B6V5KS7.js → ja-LV4RLM3M.js} +3 -3
  77. package/chunks/{keychain-token-storage-54BNK6VH.js → keychain-token-storage-KQK6MNOJ.js} +1 -1
  78. package/chunks/{ls-YWZU3FYL.js → ls-IZJ3CKZY.js} +1 -1
  79. package/chunks/{lsp-4CJDKEEC.js → lsp-NGLDRHZU.js} +1 -1
  80. package/chunks/matildaAgentContentGenerator-QQHPCFJ5.js +8 -0
  81. package/chunks/matildaContentGenerator-W7Z33ONU.js +8 -0
  82. package/chunks/{matildaOAuth2-WOY7ZS43.js → matildaOAuth2-7COTQQR2.js} +1 -1
  83. package/chunks/mcp-client-DXUNIEIB.js +3 -0
  84. package/chunks/monitor-4PFIGAGG.js +32 -0
  85. package/chunks/notebook-edit-MWJYAATJ.js +17 -0
  86. package/chunks/{openaiContentGenerator-MGASUFQL.js → openaiContentGenerator-NDVJL6QL.js} +1 -1
  87. package/chunks/{pt-KP2JCPUY.js → pt-5SQ4DGL7.js} +3 -3
  88. package/chunks/read-file-WPZKPXWA.js +3 -0
  89. package/chunks/ripGrep-7LZDZFTX.js +3 -0
  90. package/chunks/{ru-K7IQQKHC.js → ru-7K24S53N.js} +3 -3
  91. package/chunks/scheduler-DK2MVKXX.js +8 -0
  92. package/chunks/{send-message-OO2HAKCC.js → send-message-TCPX5UDU.js} +1 -1
  93. package/chunks/{serve-ZQX2WBLF.js → serve-GSZPJI2O.js} +59 -48
  94. package/chunks/shell-PRS47PDP.js +3 -0
  95. package/chunks/{skill-KDM3UUML.js → skill-ETQM5NI3.js} +1 -1
  96. package/chunks/src-UB7DZRYK.js +3 -0
  97. package/chunks/{symbol-search-ALYOX5JN.js → symbol-search-HARHZ5AH.js} +1 -1
  98. package/chunks/{syntheticOutput-UASKABJH.js → syntheticOutput-WZDPECYS.js} +1 -1
  99. package/chunks/task-create-XRNIDT4T.js +3 -0
  100. package/chunks/{task-detach-I67ZE5MX.js → task-detach-TBAVUOTC.js} +1 -1
  101. package/chunks/task-list-Z6BDZZID.js +9 -0
  102. package/chunks/{task-stop-ERI5X4AO.js → task-stop-HDSARSJ6.js} +1 -1
  103. package/chunks/{task-update-CD3W556L.js → task-update-MW2VT2XV.js} +1 -1
  104. package/chunks/{team-create-F4KQRGMB.js → team-create-VMYNLZCC.js} +1 -1
  105. package/chunks/team-delete-F7QDC2TE.js +8 -0
  106. package/chunks/todoWrite-SCF5M24M.js +3 -0
  107. package/chunks/{tool-search-JFCD5W5M.js → tool-search-WX6FOE35.js} +1 -1
  108. package/chunks/tree-sitter-bash-2SWKO5B7.js +3 -0
  109. package/chunks/{web-fetch-REWGIRWQ.js → web-fetch-CKYBHGLF.js} +13 -13
  110. package/chunks/{web-search-OX2DPEVN.js → web-search-67DFNS5V.js} +1 -1
  111. package/chunks/{workflow-SEFYGBED.js → workflow-WBSRQG3N.js} +2 -2
  112. package/chunks/write-file-S5FAX4JJ.js +15 -0
  113. package/cli.js +462 -455
  114. package/locales/ca.js +1 -3
  115. package/locales/de.js +1 -3
  116. package/locales/en.js +1 -3
  117. package/locales/fr.js +1 -3
  118. package/locales/ja.js +1 -3
  119. package/locales/pt.js +1 -3
  120. package/locales/ru.js +1 -3
  121. package/package.json +2 -2
  122. package/sandbox-macos-permissive-closed.sb +0 -1
  123. package/sandbox-macos-permissive-open.sb +0 -1
  124. package/sandbox-macos-permissive-proxied.sb +0 -1
  125. package/sandbox-macos-restrictive-closed.sb +3 -1
  126. package/sandbox-macos-restrictive-open.sb +3 -1
  127. package/sandbox-macos-restrictive-proxied.sb +3 -1
  128. package/bundled/mainy/docs/features/channels/dingtalk.md +0 -134
  129. package/bundled/mainy/docs/features/channels/feishu.md +0 -186
  130. package/bundled/mainy/docs/features/channels/weixin.md +0 -106
  131. package/chunks/agent-ZFZ4HJQC.js +0 -3
  132. package/chunks/agent-headless-KH2BKLP7.js +0 -3
  133. package/chunks/chunk-25NCTG5H.js +0 -184
  134. package/chunks/chunk-2HQMJ2IU.js +0 -8
  135. package/chunks/chunk-6GBNB5Z2.js +0 -3
  136. package/chunks/chunk-GHBKFIHC.js +0 -35
  137. package/chunks/chunk-HWOQNYAO.js +0 -27
  138. package/chunks/chunk-LJR4RZZ2.js +0 -3
  139. package/chunks/chunk-NVM7W7TG.js +0 -101
  140. package/chunks/chunk-PA6532AY.js +0 -6
  141. package/chunks/chunk-QFNFLE2I.js +0 -2625
  142. package/chunks/chunk-QN6WSWMM.js +0 -9
  143. package/chunks/chunk-RK2AKQAX.js +0 -39
  144. package/chunks/chunk-U347OO7S.js +0 -9
  145. package/chunks/chunk-UIRBHC5X.js +0 -3
  146. package/chunks/chunk-W5CGKUM4.js +0 -15
  147. package/chunks/chunk-WRQLIPXW.js +0 -113
  148. package/chunks/chunk-WVY2P6WH.js +0 -26
  149. package/chunks/chunk-WZ75OGYY.js +0 -14
  150. package/chunks/chunk-XCFLI3OC.js +0 -9
  151. package/chunks/chunk-XMZIY7XX.js +0 -13
  152. package/chunks/contextCommand-3GN5CAOK.js +0 -3
  153. package/chunks/dist-ME6647DQ.js +0 -195
  154. package/chunks/dist-VG3ZDJ2A.js +0 -28
  155. package/chunks/dist-YTCHM57U.js +0 -23
  156. package/chunks/edit-KX6V4PH3.js +0 -39
  157. package/chunks/exitPlanMode-G3QLIWJ4.js +0 -90
  158. package/chunks/geminiContentGenerator-EQEGOXOV.js +0 -8
  159. package/chunks/glob-KSBEWI3E.js +0 -22
  160. package/chunks/matildaAgentContentGenerator-OV4U6DJD.js +0 -8
  161. package/chunks/matildaContentGenerator-ETIAWE22.js +0 -8
  162. package/chunks/monitor-F4K5HOZX.js +0 -32
  163. package/chunks/notebook-edit-TL7CI5EA.js +0 -17
  164. package/chunks/read-file-6EAPS2KG.js +0 -3
  165. package/chunks/ripGrep-K6SFFUIE.js +0 -3
  166. package/chunks/scheduler-TKWPD4LP.js +0 -8
  167. package/chunks/shell-AZRK5GIO.js +0 -3
  168. package/chunks/src-SGI6VLOS.js +0 -3
  169. package/chunks/task-create-EBJD55TB.js +0 -3
  170. package/chunks/task-list-5BGX4G5N.js +0 -9
  171. package/chunks/team-delete-5U3GBFKJ.js +0 -8
  172. package/chunks/todoWrite-YGG6AZ3A.js +0 -3
  173. package/chunks/tree-sitter-bash-XNCMPQBK.js +0 -3
  174. package/chunks/write-file-UAGVBZMC.js +0 -15
@@ -1,15 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import{a as _}from"./chunk-4FVBPNTZ.js";import{Ae as q,Bc as Z,Xe as C,Ye as u,cf as G,df as Q,ga as S,gf as V,jf as Y,ze as k}from"./chunk-QFNFLE2I.js";import"./chunk-M53RP3YP.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-NYEWHSBL.js";import"./chunk-QN6WSWMM.js";import"./chunk-2HQMJ2IU.js";import"./chunk-W5CGKUM4.js";import"./chunk-TISQNFB5.js";import"./chunk-MTMU7JYZ.js";import"./chunk-SPW5DXX4.js";import"./chunk-RNKDFE2S.js";import"./chunk-GHBKFIHC.js";import"./chunk-5427BPR2.js";import"./chunk-47XR7IMP.js";import"./chunk-FFFZ2QMG.js";import"./chunk-SNLH42QJ.js";import"./chunk-HYVP4472.js";import"./chunk-QKYGQLWC.js";import"./chunk-QH7736R5.js";import"./chunk-4CSSDBOS.js";import"./chunk-JXUDKX6D.js";import"./chunk-Q55AVE2N.js";import"./chunk-GUFIMKF5.js";import"./chunk-WRQLIPXW.js";import"./chunk-DC7LAFZZ.js";import"./chunk-4F4DA5UI.js";import"./chunk-SUH3UUWZ.js";import"./chunk-4J6DC24J.js";import"./chunk-LJR4RZZ2.js";import"./chunk-U347OO7S.js";import"./chunk-SDTWBD62.js";import{Lb as z,Oa as B,ca as U,cd as K,ha as w}from"./chunk-25NCTG5H.js";import"./chunk-WVY2P6WH.js";import"./chunk-UIRBHC5X.js";import{w as H}from"./chunk-ELH4YHJR.js";import"./chunk-WHG6N5X2.js";import{g as $,i as N,p as L,q as j}from"./chunk-T4P4KEDW.js";import"./chunk-HWOQNYAO.js";import"./chunk-XCFLI3OC.js";import"./chunk-VI74YQQO.js";import"./chunk-3YLXGE6T.js";import"./chunk-GO2GA2GY.js";import{D as R,E as b,G as O,b as d,ba as M,d as D}from"./chunk-MH2P4YXC.js";import"./chunk-G7R2XEEF.js";import"./chunk-OA56BXPD.js";import"./chunk-FWDMPRKU.js";import{b as I}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";I();import P from"node:fs";import y from"node:path";var F=M("WRITE_FILE"),ae=["filePath","filepath","path","file","filename"];function le(f){if(!(typeof f.file_path=="string"&&f.file_path.trim()))for(let a of ae){let o=f[a];if(typeof o=="string"&&o.trim()){f.file_path=o,delete f[a];return}}}function ce(f){let a=f.content;if(typeof a!="string"||!a.includes("<arg_")&&!a.includes("</arg_"))return;let o={},e=/<arg_key>\s*([A-Za-z_][\w]*)\s*<\/arg_key>\s*<arg_value>\s*([\s\S]+?)(?:<\/arg_value>|(?=<arg_key\b)|$)/gi,r;for(;(r=e.exec(a))!==null;){let i=r[1].toLowerCase(),n=r[2].trim();n&&(o[i]=n)}let l=/(?:^|[^>])([A-Za-z_][\w]*)\s*<\/arg_key>\s*<arg_value>\s*([\s\S]+?)(?:<\/arg_value>|(?=<arg_key\b)|(?=[A-Za-z_][\w]*\s*<\/arg_key>)|$)/gi;for(;(r=l.exec(a))!==null;){let i=r[1].toLowerCase(),n=r[2].trim();(n&&!o[i]||n&&n.length>=(o[i]?.length??0))&&(o[i]=n)}let h=[a.search(/<arg_key\b/i),a.search(/<\/arg_key\b/i),a.search(/<arg_value\b/i)].filter(i=>i>=0),g=h.length>0?Math.min(...h):-1;if(g>=0&&a.slice(g,g+10).startsWith("</arg_key")){let i=a.slice(0,g),n=/([A-Za-z_][\w]*)\s*$/.exec(i);n&&(g=n.index)}let c=g>=0?a.slice(0,g).trimEnd():a;c=c.replace(/<\/?arg_(?:key|value)\b[^>]*>/gi,"").trimEnd(),f.content=c;let m=new Set(["file_path","filepath","path","file","filename"]);for(let[i,n]of Object.entries(o))!m.has(i)||!n||!n.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(n)||(typeof f.file_path!="string"||!String(f.file_path).trim()||n.length>String(f.file_path).length)&&(f.file_path=n)}var A=class extends ${constructor(o,e){super(e);this.config=o}toolLocations(){return[{path:this.params.file_path}]}getDescription(){let o=b(this.params.file_path,this.config.getTargetDir());return`Writing to ${R(o)}`}async getDefaultPermission(){let o=this.config.getProjectRoot();return H(y.resolve(this.params.file_path),o)?"allow":"ask"}async getConfirmationDetails(o){let e=_(this.config,this.params.file_path);if(e)throw new C(e,"path_not_in_workspace");let r="",l=await w(this.params.file_path);if(!this.config.getFileReadCacheDisabled()){let i=await u(this.config.getFileReadCache(),this.params.file_path,"overwriting");if(!i.ok)throw new C(i.rawMessage,i.type)}if(l)try{let{content:i}=await this.config.getFileSystemService().readTextFile({path:this.params.file_path});r=i}catch(i){if(d(i)&&i.code==="ENOENT")l=!1;else throw new Error(`Error reading existing file for confirmation: ${D(i)}`)}if(l&&!this.config.getFileReadCacheDisabled()){let i=await u(this.config.getFileReadCache(),this.params.file_path,"overwriting",{expectExisting:!0});if(!i.ok)throw F.warn("post-read TOCTOU rejection (confirmation)",{path:this.params.file_path,reason:i.type}),new C(i.rawMessage,i.type)}let h=b(this.params.file_path,this.config.getTargetDir()),g=y.basename(this.params.file_path),c=S(g,r,this.params.content,"Current","Proposed",k);return{type:"edit",title:`Confirm Write: ${R(h)}`,fileName:g,filePath:this.params.file_path,fileDiff:c,originalContent:r,newContent:this.params.content,onConfirm:async i=>{i==="proceed_always"&&this.config.setApprovalMode("auto-edit")}}}async execute(o){let{file_path:e,content:r,ai_proposed_content:l,modified_by_user:h}=this.params,g=_(this.config,e);if(g)return{llmContent:g,returnDisplay:g,error:{message:g,type:"path_not_in_workspace"}};let c=await w(e),m="",i=!1,n,W,J=y.dirname(e);if(!this.config.getFileReadCacheDisabled()){let t=await u(this.config.getFileReadCache(),e,"overwriting");if(!t.ok)return{llmContent:t.rawMessage,returnDisplay:`Error: ${t.displayMessage}`,error:{message:t.rawMessage,type:t.type}}}if(c)try{let t=await this.config.getFileSystemService().readTextFile({path:e});t._meta?.bom!==void 0?i=t._meta.bom:i=t.content.length>0&&t.content.codePointAt(0)===65279,n=t._meta?.encoding||"utf-8",W=V(t.content),m=t.content,c=!0}catch(t){if(d(t)&&t.code==="ENOENT")c=!1;else{let s={message:D(t),code:d(t)?t.code:void 0},p=s.code?`Error checking existing file '${e}': ${s.message} (${s.code})`:`Error checking existing file: ${s.message}`;return{llmContent:p,returnDisplay:p,error:{message:p,type:"file_write_failure"}}}}if(c&&!this.config.getFileReadCacheDisabled()){let t=await u(this.config.getFileReadCache(),e,"overwriting",{expectExisting:!0});if(!t.ok)return F.warn("post-read TOCTOU rejection (execute)",{path:e,reason:t.type}),{llmContent:t.rawMessage,returnDisplay:`Error: ${t.displayMessage}`,error:{message:t.rawMessage,type:t.type}}}if(!c){let t=this.config.getDefaultFileEncoding();t===G.UTF8_BOM?i=!0:t===void 0&&(i=Q(e)),n=void 0}try{await this.config.getFileHistoryService().trackEdit(e)}catch{}if(!this.config.getFileReadCacheDisabled()){let t=await u(this.config.getFileReadCache(),e,"overwriting",{expectExisting:c});if(!t.ok)return F.warn("pre-write TOCTOU rejection",{path:e,reason:t.type}),{llmContent:t.rawMessage,returnDisplay:`Error: ${t.displayMessage}`,error:{message:t.rawMessage,type:t.type}}}let E=_(this.config,e);if(E)return{llmContent:E,returnDisplay:E,error:{message:E,type:"path_not_in_workspace"}};c||P.mkdirSync(J,{recursive:!0});try{let t=_(this.config,e);if(t)return{llmContent:t,returnDisplay:t,error:{message:t,type:"path_not_in_workspace"}};await this.config.getFileSystemService().writeTextFile({path:e,content:r,_meta:{bom:i,encoding:n,lineEnding:W}}),h||Z.getInstance().recordEdit(e,c?m:null,r);try{let T=P.statSync(e);this.config.getFileReadCache().recordWrite(e,T)}catch{}let s=y.basename(e),p=m,X=S(s,p,r,"Original","Written",k),ee=q(s,p,l||r,r),v=[c?`Successfully overwrote file: ${e}.`:`Successfully created and wrote to new file: ${e}.`];h&&v.push(`User modified the \`content\` to be: ${r}`);let te=U(e),ie=B(e),oe=y.extname(e),re=c?"update":"create",ne=r.split(`
4
- `).length;z(this.config,new K(x.Name,re,ne,te,oe,ie));let se={fileDiff:X,fileName:s,originalContent:m,newContent:r,diffStat:ee};try{let T=await Y(this.config,e);T&&v.push(`
5
-
6
- ${T}`)}catch{}return{llmContent:v.join(" "),returnDisplay:se}}catch(t){let s,p="file_write_failure";return d(t)?(s=`Error writing to file '${e}': ${t.message} (${t.code})`,t.code==="EACCES"?(s=`Permission denied writing to file: ${e} (${t.code})`,p="permission_denied"):t.code==="ENOSPC"?(s=`No space left on device: ${e} (${t.code})`,p="no_space_left"):t.code==="EISDIR"&&(s=`Target is a directory, not a file: ${e} (${t.code})`,p="target_is_directory"),this.config.getDebugMode()&&t.stack&&F.debug("Write file error stack:",t.stack)):t instanceof Error?s=`Error writing to file: ${t.message}`:s=`Error writing to file: ${String(t)}`,{llmContent:s,returnDisplay:s,error:{message:s,type:p}}}}},x=class f extends N{constructor(o){super(f.Name,j.WRITE_FILE,`Writes content to a specified file in the local filesystem.
7
-
8
- CRITICAL: Always emit file_path FIRST (absolute path), then content. Never omit file_path. Construct absolute paths from the project root + relative path (e.g. '/path/to/project/' + 'foo/bar.txt'). Relative paths are not supported.
9
-
10
- The user has the ability to modify \`content\`. If modified, this will be stated in the response.`,"edit",{properties:{file_path:{description:"REQUIRED. Absolute path to write (e.g. '/home/user/project/src/auth.ts'). Emit this BEFORE content.",type:"string"},content:{description:"The full file contents to write. Only after file_path is set.",type:"string"}},required:["file_path","content"],type:"object"});this.config=o}static Name=L.WRITE_FILE;validateToolParams(o){let e=o;return ce(e),le(e),(typeof o.file_path!="string"||!o.file_path.trim())&&typeof o.content=="string"&&o.content.length>0?'WriteFile requires absolute "file_path" (emit file_path first, then content). Retry with both file_path and content.':super.validateToolParams(o)}validateToolParamValues(o){let e=O(o.file_path.trim());if(o.file_path=e,!e)return'Missing or empty "file_path"';if(!y.isAbsolute(e))return`File path must be absolute: ${e}`;try{if(P.existsSync(e)&&P.lstatSync(e).isDirectory())return`Path is a directory, not a file: ${e}`}catch(r){return`Error accessing path properties for validation: ${e}. Reason: ${r instanceof Error?r.message:String(r)}`}return null}createInvocation(o){return new A(this.config,o)}toAutoClassifierInput(o){let e=o.content??"";return{file_path:o.file_path,byte_count:Buffer.byteLength(e,"utf8"),content_preview:e.slice(0,300),content_truncated:e.length>300}}getModifyContext(o){return{getFilePath:e=>e.file_path,getCurrentContent:async e=>{if(await w(e.file_path))try{let{content:l}=await this.config.getFileSystemService().readTextFile({path:e.file_path});return l}catch(l){if(!d(l)||l.code!=="ENOENT")throw l;return""}else return""},getProposedContent:async e=>e.content,createUpdatedParams:(e,r,l)=>{let h=l.content;return{...l,ai_proposed_content:h,content:r,modified_by_user:!0}}}}};export{x as WriteFileTool,le as normalizeWriteFilePathAliases,ce as repairLeakedWriteFileToolArgMarkup};
11
- /**
12
- * @license
13
- * Copyright 2025 Google LLC
14
- * SPDX-License-Identifier: Apache-2.0
15
- */