@maincode-ai/matilda-code 0.22.0 → 0.22.1
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/chunks/agent-JDATO222.js +3 -0
- package/chunks/agent-headless-ZOFNY4CF.js +3 -0
- package/chunks/{askUserQuestion-RZYBOPLR.js → askUserQuestion-A46IDHKS.js} +1 -1
- package/chunks/{chunk-PQZ6HKKW.js → chunk-2LVAK6TV.js} +1 -1
- package/chunks/{chunk-453BANK3.js → chunk-5JCW6FH6.js} +1 -1
- package/chunks/{chunk-LM6OIN4B.js → chunk-6RK6IJY5.js} +1 -1
- package/chunks/{chunk-J3ZCE3TA.js → chunk-7AEOFDY3.js} +1 -1
- package/chunks/{chunk-7E2YCGHS.js → chunk-AEYNMLMW.js} +12 -12
- package/chunks/{chunk-ARAB5QTM.js → chunk-CI5CVVGI.js} +62 -62
- package/chunks/{chunk-5ETLURI6.js → chunk-DEN6RR3B.js} +1 -1
- package/chunks/{chunk-2XSB5XHX.js → chunk-FI2FSW7J.js} +1 -1
- package/chunks/{chunk-4UGPARBR.js → chunk-GCMUSGTT.js} +1 -1
- package/chunks/{chunk-MGRXOZAG.js → chunk-HRCRNKY2.js} +1 -1
- package/chunks/{chunk-ILHNCXBC.js → chunk-IV6PS6DB.js} +1 -1
- package/chunks/{chunk-POGNX7U3.js → chunk-KYNP66YS.js} +1 -1
- package/chunks/{chunk-RPXRN7E6.js → chunk-LONWTJOE.js} +1 -1
- package/chunks/{chunk-NBLBE7PE.js → chunk-QNXNECWR.js} +458 -465
- package/chunks/{chunk-G3F3ZCH2.js → chunk-RH3AEZWO.js} +1 -1
- package/chunks/{chunk-7B65UIHB.js → chunk-SMTY6M3W.js} +1 -1
- package/chunks/{chunk-IHWAOFCQ.js → chunk-TDFF4ZGY.js} +1 -1
- package/chunks/chunk-TKEFJ3O3.js +9 -0
- package/chunks/{chunk-V4VILMIK.js → chunk-UICLGQTV.js} +1 -1
- package/chunks/{chunk-6NXVLJ3X.js → chunk-V2V3OF76.js} +1 -1
- package/chunks/chunk-XPVKH5TC.js +10 -0
- package/chunks/chunk-Y3SZK63U.js +120 -0
- package/chunks/{chunk-LMZBADPW.js → chunk-ZABAV4XA.js} +1 -1
- package/chunks/{computer-use-PBCWDTJR.js → computer-use-V2DT2IKO.js} +1 -1
- package/chunks/{cron-create-PHQ43NYA.js → cron-create-JINCFLKY.js} +1 -1
- package/chunks/{cron-delete-7RCQIU2U.js → cron-delete-RF6JLUAV.js} +1 -1
- package/chunks/{cron-list-KKNLLMNN.js → cron-list-VXLBAXZ3.js} +1 -1
- package/chunks/{edit-ELHNQB5E.js → edit-ZB4SONLT.js} +3 -3
- package/chunks/{enter-worktree-UZIBOBV3.js → enter-worktree-CAFTW46C.js} +1 -1
- package/chunks/{enterPlanMode-UHY3DZXE.js → enterPlanMode-XSNXJJMC.js} +1 -1
- package/chunks/{exit-worktree-HLG4PDMX.js → exit-worktree-U37YLKJC.js} +1 -1
- package/chunks/{exitPlanMode-V4HYNH3J.js → exitPlanMode-XKAZCVAV.js} +1 -1
- package/chunks/{glob-C5CTWXLP.js → glob-LPIFPVGX.js} +1 -1
- package/chunks/{goal-tools-BGIWEJ3K.js → goal-tools-VAH424PW.js} +1 -1
- package/chunks/{grep-BEFTGKHW.js → grep-IF4GTD5A.js} +1 -1
- package/chunks/{keychain-token-storage-FEJZYJBB.js → keychain-token-storage-UTWIIKCK.js} +1 -1
- package/chunks/{ls-XH55NAD3.js → ls-3EEHZY4W.js} +1 -1
- package/chunks/{lsp-BKDCR37G.js → lsp-H4EXPHFD.js} +1 -1
- package/chunks/mcp-client-EUPXG3VF.js +3 -0
- package/chunks/monitor-KBWRPPZ5.js +32 -0
- package/chunks/notebook-edit-K3KNR6DI.js +17 -0
- package/chunks/openaiContentGenerator-2NF5JGUC.js +47 -0
- package/chunks/read-file-SRDZKBNS.js +3 -0
- package/chunks/ripGrep-675JNT4W.js +3 -0
- package/chunks/scheduler-O36AJTWS.js +8 -0
- package/chunks/{send-message-GJSEMAZB.js → send-message-5XHDGHSN.js} +1 -1
- package/chunks/shell-A7NRVDCY.js +3 -0
- package/chunks/{skill-3RWNSUNE.js → skill-FCVSGCSN.js} +1 -1
- package/chunks/{symbol-search-4VM6J5Y4.js → symbol-search-ZM3HFCUV.js} +1 -1
- package/chunks/{syntheticOutput-O7LEF3AM.js → syntheticOutput-OIPRFBVD.js} +1 -1
- package/chunks/{task-create-N4IRJBTF.js → task-create-QP44DKH4.js} +1 -1
- package/chunks/{task-detach-RGNQUX3H.js → task-detach-AUTU6C4G.js} +1 -1
- package/chunks/{task-list-Z7JUB4QK.js → task-list-U2WAGMM7.js} +1 -1
- package/chunks/{task-stop-L2OWK2PJ.js → task-stop-GN5WZ3IA.js} +1 -1
- package/chunks/{task-update-H5AXVXDS.js → task-update-26N2AUQT.js} +1 -1
- package/chunks/{team-create-FWTIQ2FT.js → team-create-TN2KN27J.js} +1 -1
- package/chunks/{team-delete-D45ALROH.js → team-delete-XCKD5FBZ.js} +1 -1
- package/chunks/todoWrite-JN3ZV5O2.js +3 -0
- package/chunks/{tool-search-X6UUCSPU.js → tool-search-VPMEQKAS.js} +1 -1
- package/chunks/{web-fetch-244KUWSX.js → web-fetch-CVAOVOZM.js} +1 -1
- package/chunks/{web-search-YRZ3BZ3X.js → web-search-77CUPTFY.js} +3 -3
- package/chunks/{workflow-EP4AFR24.js → workflow-JNZRGHJ4.js} +2 -2
- package/chunks/write-file-FJCU2PYT.js +15 -0
- package/cli.js +375 -374
- package/package.json +2 -2
- package/chunks/agent-IUINB66G.js +0 -3
- package/chunks/agent-headless-YA2RKYEZ.js +0 -3
- package/chunks/chunk-RHSUTILA.js +0 -9
- package/chunks/chunk-V2VUANFI.js +0 -120
- package/chunks/mcp-client-GAQG7MCT.js +0 -3
- package/chunks/monitor-NSVUUKCM.js +0 -32
- package/chunks/notebook-edit-AXKYC64C.js +0 -17
- package/chunks/openaiContentGenerator-66YY6CIM.js +0 -47
- package/chunks/read-file-YFJMLS7V.js +0 -3
- package/chunks/ripGrep-BEHEB23R.js +0 -3
- package/chunks/scheduler-GKQOREMS.js +0 -8
- package/chunks/shell-J5Q2UEXH.js +0 -3
- package/chunks/todoWrite-LCQOQBI7.js +0 -3
- package/chunks/write-file-EXWGRN4Q.js +0 -15
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{
|
|
3
|
+
import{dd as V,q as H,r as K,t as x}from"./chunk-QNXNECWR.js";import"./chunk-HRCRNKY2.js";import"./chunk-ZSGBDQXU.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DEN6RR3B.js";import"./chunk-RH3AEZWO.js";import"./chunk-UICLGQTV.js";import"./chunk-V2V3OF76.js";import"./chunk-GCMUSGTT.js";import"./chunk-SMTY6M3W.js";import"./chunk-QXSBPCBA.js";import"./chunk-ZABAV4XA.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-5JCW6FH6.js";import"./chunk-2LVAK6TV.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-Y3SZK63U.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-DUB7JMQV.js";import{a as S}from"./chunk-CI5CVVGI.js";import"./chunk-IV6PS6DB.js";import"./chunk-6RK6IJY5.js";import"./chunk-LONWTJOE.js";import"./chunk-TKEFJ3O3.js";import"./chunk-7AEOFDY3.js";import"./chunk-XPVKH5TC.js";import{f as G,g as X}from"./chunk-KYNP66YS.js";import"./chunk-AEYNMLMW.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.js";import{b as d}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";d();d();d();import{homedir as we}from"node:os";d();import{join as R}from"node:path";import{homedir as E}from"node:os";var l="0.5.2",me="https://matilda.maincode.com/assets/computer-use",he="https://github.com/trycua/cua/releases/download";function U(e=process.platform,t=process.arch,o=l){let r=o;if(e==="darwin"){let n=`cua-driver-rs-${r}-${t==="arm64"?"darwin-arm64":"darwin-x86_64"}`;return{asset:`${n}.tar.gz`,extractDir:n,binaryRelPath:"CuaDriver.app/Contents/MacOS/cua-driver",hasApp:!0}}if(e==="linux"){if(t!=="x64")throw new Error(`Computer Use: unsupported Linux arch '${t}' (only x64).`);return{asset:`cua-driver-rs-${r}-linux-x86_64-binary.tar.gz`,extractDir:".",binaryRelPath:"cua-driver",hasApp:!1}}if(e==="win32"){let n=`cua-driver-rs-${r}-${t==="arm64"?"windows-arm64":"windows-x86_64"}`;return{asset:`${n}.zip`,extractDir:n,binaryRelPath:"cua-driver.exe",hasApp:!1}}throw new Error(`Computer Use: unsupported platform '${e}'.`)}function N(e,t=process.env,o=l){let r=[],i=t.MATILDA_COMPUTER_USE_DOWNLOAD_HOST;return i&&r.push(`${ye(i)}/cua-driver-rs/v${o}/${e}`),r.push(`${me}/cua-driver-rs/v${o}/${e}`),r.push(`${he}/cua-driver-rs-v${o}/${e}`),r}function Y(e=process.env,t=l){return N("checksums.txt",e,t)}var fe="MATILDA_COMPUTER_USE_MAX_IMAGE_DIMENSION";function J(e){if(e===void 0||typeof e=="string"&&e.trim()==="")return;let t=typeof e=="number"?e:Number(e);if(!(!Number.isInteger(t)||t<0))return t}function Q(e,t=process.env){let o=J(t[fe]);return o!==void 0?o:J(e)}function ge(e=E()){return R(e,".matilda","computer-use")}function M(e=E(),t=l){return R(ge(e),`cua-driver-rs-${t}`)}function u(e=E(),t=process.platform,o=process.arch,r=l){let i=U(t,o,r);return R(M(e,r),i.extractDir,i.binaryRelPath)}function h(e=l){return`cua-driver-rs@${e}`}function ye(e){return e.endsWith("/")?e.slice(0,-1):e}var f=class e{static singleton;binary;onProgress;maxImageDimension;client;startPromise;constructor(t){this.binary=t.binary,this.onProgress=t.onProgress??(()=>{}),this.maxImageDimension=t.maxImageDimension}setMaxImageDimension(t){this.maxImageDimension=t}static shared(){return e.singleton||(e.singleton=new e({binary:u(we())})),e.singleton}static setSharedForTest(t){e.singleton=t}isStarted(){return this.client!==void 0}async start(t){if(!this.client)return this.startPromise?this.startPromise:(this.startPromise=this.doStart(t).finally(()=>{this.startPromise=void 0}),this.startPromise)}async doStart(t){let o=t??this.onProgress;o("Starting Computer Use driver...");let r=new K({command:this.binary,args:["mcp"],env:x()}),i=new H({name:"matilda-code-computer-use",version:"1.0.0"},{capabilities:{}});await i.connect(r),this.client=i,await this.applyRuntimeConfig(i,o)}async applyRuntimeConfig(t,o){if(this.maxImageDimension!==void 0)try{await t.callTool({name:"set_config",arguments:{max_image_dimension:this.maxImageDimension}})}catch(r){let i=r instanceof Error?r.message:String(r);o(`Computer Use: could not apply max_image_dimension=${this.maxImageDimension} (${i}); using driver default.`)}}async listTools(){if(!this.client)throw new Error("ComputerUseClient not started");return this.client.listTools()}async callTool(t,o){if(!this.client)throw new Error("ComputerUseClient not started");try{return await this.client.callTool({name:t,arguments:o})}catch(r){if(!Z(r))throw r;let i=r;for(let n=0;n<3;n++){if(await this.stop(),await this.start(),!this.client)throw new Error("ComputerUseClient reconnect failed");try{return await this.client.callTool({name:t,arguments:o})}catch(s){if(!Z(s))throw s;i=s,await new Promise(a=>setTimeout(a,1e3))}}throw i}}async stop(){let t=this.client;if(this.client=void 0,t)try{await t.close()}catch{}}};function Z(e){let t=e instanceof Error?e.message:String(e);return/connection closed|not connected|connection refused|daemon transport error|os error 61/i.test(t)}d();var j=["bring_to_front","check_for_update","check_permissions","click","double_click","drag","end_session","get_accessibility_tree","get_agent_cursor_state","get_config","get_cursor_position","get_recording_state","get_screen_size","get_window_state","hotkey","kill_app","launch_app","list_apps","list_windows","move_cursor","page","press_key","replay_trajectory","right_click","scroll","set_agent_cursor_enabled","set_agent_cursor_motion","set_agent_cursor_style","set_config","set_value","start_recording","start_session","stop_recording","type_text","zoom"],g={bring_to_front:{description:'Activate a window so subsequent input tools with `dispatch:"foreground"` land on it without a per-call SetForegroundWindow flash. **Windows-only:** on macOS this tool returns an error pointing to the platform-native `NSRunningApplication.activate` (which the macOS input tools don\'t need because CGEvent.postToPid reaches backgrounded windows). On Linux this tool also stubs out; use `wmctrl -a` or `xdotool windowactivate` if you need explicit activation.',parameterSchema:{additionalProperties:!1,properties:{pid:{type:"integer"},window_id:{type:"integer"}},required:["pid"],type:"object"}},check_for_update:{description:"Check whether a newer cua-driver-rs release is available on GitHub. Returns the current and latest versions, an `update_available` boolean, the install one-liner, and the release notes URL. Read-only \u2014 never installs. Mirror of `cua-driver check-update --json`.",parameterSchema:{additionalProperties:!1,properties:{},type:"object"}},check_permissions:{description:"Report TCC permission status for Accessibility and Screen Recording. By default also raises the system permission dialogs for any missing grants \u2014 Apple's request APIs are no-ops when the grant is already active, so this is safe to call repeatedly. Pass {\"prompt\": false} for a purely read-only status check.\n\nReturns: `accessibility` + `screen_recording` (booleans from the TCC preflight APIs), `screen_recording_capturable` (a live ScreenCaptureKit probe \u2014 if it disagrees with `screen_recording`, the preflight grant belongs to a different process), and `source` (which TCC identity the booleans reflect: the CuaDriver daemon vs the launching terminal/IDE). macOS attributes grants to the responsible process, so a standalone call from a terminal reports the terminal's grants, not the driver's.",parameterSchema:{additionalProperties:!1,properties:{prompt:{description:"Raise the system permission prompts for missing grants. Default true.",type:"boolean"}},type:"object"}},click:{description:`Left-click against a target pid. **Prefer \`element_index\` over pixel coordinates** \u2014 element_index works on backgrounded / minimized / hidden / off-Space windows, surfaces a stable handle that survives rebuilds, and tells you what you're clicking via the cached element's role + label. Reach for \`x, y\` only when the target is a canvas / video / WebGL / custom-drawn surface that doesn't appear in the AX tree.
|
|
4
4
|
|
|
5
5
|
Two addressing modes:
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{a as p,c as f}from"./chunk-TXMXCR7D.js";import{a as y}from"./chunk-YULUB745.js";import{a as n}from"./chunk-
|
|
3
|
+
import{a as p,c as f}from"./chunk-TXMXCR7D.js";import{a as y}from"./chunk-YULUB745.js";import{a as n}from"./chunk-DEN6RR3B.js";import"./chunk-GT6MSEK4.js";import"./chunk-7AEOFDY3.js";import{f as m,g as c,m as d,n as h}from"./chunk-KYNP66YS.js";import"./chunk-AEYNMLMW.js";import"./chunk-HEJO7OBH.js";import{b as u}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";u();var i=class extends m{constructor(e,t){super(t);this.config=e}getDescription(){return`${this.params.cron}: ${this.params.prompt}`}async getDefaultPermission(){return"ask"}async execute(){let e=this.config.getCronScheduler(),t=this.params.recurring!==!1,s=this.params.durable===!0;try{p(this.params.cron),f(this.params.cron,new Date);let r=s?await e.createDurable(this.params.cron,this.params.prompt,t):e.create(this.params.cron,this.params.prompt,t),o=y(r.cronExpr),w=`Scheduled ${r.id} (${o})${s?" [durable]":""}`,l=s?`Persisted to ${n}`:"Session-only (not written to disk, dies when Matilda exits)";return{llmContent:t?`Scheduled recurring job ${r.id} (${r.cronExpr}). ${l}. Auto-expires after 7 days. Use CronDelete to cancel sooner.`:`Scheduled one-shot task ${r.id} (${r.cronExpr}). ${l}. It will fire once then auto-delete.`,returnDisplay:w}}catch(r){let o=r instanceof Error?r.message:String(r);return{llmContent:`Error creating cron job: ${o}`,returnDisplay:o,error:{message:o}}}}},g=class a extends c{constructor(e){super(a.Name,h.CRON_CREATE,`Schedule a prompt to be enqueued at a future time. Use for both recurring schedules and one-shot reminders.
|
|
4
4
|
|
|
5
5
|
Uses standard 5-field cron in the user's local timezone: minute hour day-of-month month day-of-week. "0 9 * * *" means 9am local \u2014 no timezone conversion needed.
|
|
6
6
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{a as d,f as u}from"./chunk-
|
|
3
|
+
import{a as d,f as u}from"./chunk-DEN6RR3B.js";import"./chunk-GT6MSEK4.js";import"./chunk-7AEOFDY3.js";import{f as l,g as c,m,n as p}from"./chunk-KYNP66YS.js";import{e as n}from"./chunk-AEYNMLMW.js";import"./chunk-HEJO7OBH.js";import{b as i}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";i();var s=class extends l{constructor(r,o){super(o);this.config=r}getDescription(){return this.params.id}async execute(){let r=this.config.getCronScheduler(),o;try{o=await r.delete(this.params.id),o||(o=await u(this.config.getProjectRoot(),[this.params.id])>0)}catch(e){let t=`Failed to cancel job ${this.params.id}: ${n(e)}`;return{llmContent:t,returnDisplay:t,error:{message:t}}}if(o){let e=`Cancelled job ${this.params.id}.`,t=`Cancelled ${this.params.id}`;return{llmContent:e,returnDisplay:t}}else{let e=`Job ${this.params.id} not found.`;return{llmContent:e,returnDisplay:e,error:{message:e}}}}},f=class a extends c{constructor(r){super(a.Name,p.CRON_DELETE,`Cancel a cron job previously scheduled with CronCreate. Removes it from the in-memory session store or from ${d} (durable jobs).`,"other",{type:"object",properties:{id:{type:"string",description:"Job ID returned by CronCreate."}},required:["id"],additionalProperties:!1},!0,!1,!0,!1,"cron delete cancel remove");this.config=r}static Name=m.CRON_DELETE;createInvocation(r){return new s(this.config,r)}};export{f as CronDeleteTool};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{a as m}from"./chunk-YULUB745.js";import{a as d,c as g}from"./chunk-
|
|
3
|
+
import{a as m}from"./chunk-YULUB745.js";import{a as d,c as g}from"./chunk-DEN6RR3B.js";import"./chunk-GT6MSEK4.js";import"./chunk-7AEOFDY3.js";import{f as l,g as c,m as p,n as u}from"./chunk-KYNP66YS.js";import"./chunk-AEYNMLMW.js";import"./chunk-HEJO7OBH.js";import{b as a}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";a();var s=class extends l{constructor(e,t){super(t);this.config=e}getDescription(){return""}async execute(){let e=this.config.getCronScheduler(),t;try{t=await g(this.config.getProjectRoot())}catch(r){let o=r instanceof Error?r.message:String(r);return{llmContent:`Error listing cron jobs: ${o}`,returnDisplay:o,error:{message:o}}}let n=[...t.map(r=>({id:r.id,cron:r.cron,prompt:r.prompt,recurring:r.recurring,durable:!0})),...e.list().filter(r=>!r.durable).map(r=>({id:r.id,cron:r.cronExpr,prompt:r.prompt,recurring:r.recurring,durable:!1}))];if(n.length===0){let r="No active cron jobs.";return{llmContent:r,returnDisplay:r}}let y=n.map(r=>{let o=r.recurring?"recurring":"one-shot",h=r.durable?"durable":"session-only";return`${r.id} \u2014 ${r.cron} (${o}) [${h}]: ${r.prompt}`}).join(`
|
|
4
4
|
`),T=n.map(r=>`${r.id} ${m(r.cron)} [${r.durable?"durable":"session-only"}]`).join(`
|
|
5
5
|
`);return{llmContent:y,returnDisplay:T}}},f=class i extends c{constructor(e){super(i.Name,u.CRON_LIST,`List all cron jobs scheduled via CronCreate, both session-only and durable (${d}).`,"other",{type:"object",properties:{},additionalProperties:!1},!0,!1,!0,!1,"cron list scheduled jobs");this.config=e}static Name=p.CRON_LIST;createInvocation(e){return new s(this.config,e)}};export{f as CronListTool};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{a as C}from"./chunk-
|
|
3
|
+
import{a as C}from"./chunk-TDFF4ZGY.js";import{Nb as L,Ob as G,Yb as R,Zb as S,bc as K,cc as V,dc as Q,ec as Y,gb as q,ya as D}from"./chunk-QNXNECWR.js";import"./chunk-HRCRNKY2.js";import"./chunk-ZSGBDQXU.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DEN6RR3B.js";import"./chunk-RH3AEZWO.js";import"./chunk-UICLGQTV.js";import"./chunk-V2V3OF76.js";import"./chunk-GCMUSGTT.js";import"./chunk-SMTY6M3W.js";import"./chunk-QXSBPCBA.js";import"./chunk-ZABAV4XA.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-5JCW6FH6.js";import"./chunk-2LVAK6TV.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-Y3SZK63U.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-DUB7JMQV.js";import{C as P,Db as X,H,db as A,xa as j,z as U}from"./chunk-CI5CVVGI.js";import{l as z}from"./chunk-IV6PS6DB.js";import"./chunk-6RK6IJY5.js";import"./chunk-LONWTJOE.js";import"./chunk-TKEFJ3O3.js";import"./chunk-7AEOFDY3.js";import{a as B}from"./chunk-XPVKH5TC.js";import{g as k,m as F,n as W}from"./chunk-KYNP66YS.js";import{C as T,D as I,F as v,Y as $,c as x}from"./chunk-AEYNMLMW.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.js";import{b}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";b();import*as _ from"node:fs";import*as p from"node:path";b();var re={"\u2010":"-","\u2011":"-","\u2012":"-","\u2013":"-","\u2014":"-","\u2015":"-","\u2212":"-","\u2018":"'","\u2019":"'","\u201A":"'","\u201B":"'","\u201C":'"',"\u201D":'"',"\u201E":'"',"\u201F":'"',"\xA0":" ","\u2002":" ","\u2003":" ","\u2004":" ","\u2005":" ","\u2006":" ","\u2007":" ","\u2008":" ","\u2009":" ","\u200A":" ","\u202F":" ","\u205F":" ","\u3000":" "},ue=new RegExp(`[${Object.keys(re).join("")}]`,"g");function w(n){return n.replace(ue,t=>re[t])}var he=[n=>n,n=>n.trimEnd()];function pe(n){return w(n).trimEnd()}function J(n,t,i){if(t.length===0)return 0;if(t.length>n.length)return null;e:for(let e=0;e<=n.length-t.length;e++){for(let r=0;r<t.length;r++)if(i(n[e+r])!==i(t[r]))continue e;return e}return null}function me(n){let t=n.split(`
|
|
4
4
|
`),i=new Array(t.length+1),e=0;for(let r=0;r<t.length;r++)i[r]=e,e+=t[r].length,r<t.length-1&&(e+=1);return i[t.length]=n.length,{lines:t,offsets:i}}function Z(n,t,i,e,r,o){if(r===0)return o?`
|
|
5
5
|
`:"";let l=t[e]??0,s=e+r-1,f=(t[s]??0)+(i[s]?.length??0);if(o){let g=t[e+r];g!==void 0?f=g:n.endsWith(`
|
|
6
6
|
`)&&(f=n.length)}return n.slice(l,f)}function _e(n,t){let{lines:i,offsets:e}=me(n),r=t.split(`
|
|
@@ -16,8 +16,8 @@ import{a as C}from"./chunk-IHWAOFCQ.js";import{$b as R,Nb as L,Ob as q,Tb as G,a
|
|
|
16
16
|
`)}function ce(n,t,i){let e=Math.min(i,t+Te-1),r=[];for(let o=t;o<=e;o++)r.push(`${String(o+1).padStart(6)}|${Ie(n[o])}`);return e<i&&r.push(` \u2026| ${i-e} more lines`),r}function Ie(n){let t=n.length>ee,i=t?n.slice(0,ee):n,e=c=>c===" "||c===" ",r=0;for(;e(i[r]);)r++;let o=i.length;for(;!t&&o>r&&e(i[o-1]);)o--;let l=c=>c.replace(/\t/g,"\u2192").replace(/ /g,"\xB7"),s=l(i.slice(0,r))+i.slice(r,o).replace(/\t/g,"\u2192")+l(i.slice(o));return t?`${s}\u2026[${n.length-i.length} more characters not shown]`:s}var ie=4,Fe=1e3;function fe(n,t){let i=t.split(`
|
|
17
17
|
`),e=i.length;if(n===null)return{startLine:1,endLine:e,totalLines:e,content:t};if(n===t||!t)return null;let r=n.split(`
|
|
18
18
|
`),o=0,l=Math.min(r.length,i.length);for(;o<l&&r[o]===i[o];)o++;let s=r.length-1,c=i.length-1;for(;s>=o&&c>=o&&r[s]===i[c];)s--,c--;let f=o+1,g=c+1;if(g-f>Fe)return null;let m=Math.max(1,f-ie),d=Math.min(e,g+ie),h=i.slice(m-1,d);return{startLine:m,endLine:d,totalLines:e,content:h.join(`
|
|
19
|
-
`)}}var de=$("EDIT_PRIOR_READ");function ge(n,t,i,e){return e?i:n===null?t===""?i:"":t===""&&!e?n:
|
|
20
|
-
`),r=!0}catch(a){if(!x(a)||a.code!=="ENOENT")throw a;r=!1}if(r&&!this.config.getFileReadCacheDisabled()){let a=await S(this.config.getFileReadCache(),t.file_path,"editing",{expectExisting:!0});if(!a.ok)return de.warn("post-read TOCTOU rejection",{path:t.file_path,reason:a.type}),{currentContent:null,newContent:"",occurrences:0,error:{display:a.displayMessage,raw:a.rawMessage,type:a.type},isNewFile:!1,encoding:"utf-8",bom:!1,lineEnding:"lf"}}if(t.full_file_replace)o=!r,r&&e!==null?(c=1,s=e,l=t.new_string):r||(s="",l=t.new_string);else{let a=oe(e,s,l);if(s=a.oldString,l=a.newString,s===""&&!r)o=!0;else if(!r)f={display:"File not found. Cannot apply edit. Use an empty old_string to create a new file.",raw:`File not found: ${t.file_path}`,type:"file_not_found"};else if(e!==null)if(s=se(e,s,l),c=le(e,s),t.old_string==="")f={display:"Failed to edit. Attempted to create a file that already exists.",raw:`File already exists, cannot create: ${t.file_path}`,type:"attempt_to_create_existing_file"};else if(c===0){let E=ae(e,s);f={display:"Failed to edit, could not find the string to replace.",raw:`Failed to edit, 0 occurrences found for old_string in ${t.file_path}. No edits made. ${E??`The exact text in old_string was not found. Ensure you're not escaping content incorrectly and check whitespace, indentation, and context. Use ${A.Name} tool to verify.`}`,type:"edit_no_occurrence_found"}}else!i&&c>1?f={display:"Failed to edit because the text matches multiple locations. Provide more context or set replace_all to true.",raw:`Failed to edit. Found ${c} occurrences for old_string in ${t.file_path} but replace_all was not enabled.`,type:"edit_expected_occurrence_mismatch"}:s===l&&(f={display:"No changes to apply. The old_string and new_string are identical.",raw:`No changes to apply. The old_string and new_string are identical in file: ${t.file_path}`,type:"edit_no_change"});else f={display:"Failed to read content of file.",raw:`Failed to read content of existing file: ${t.file_path}`,type:"read_content_failure"}}let h=f?e??"":t.full_file_replace?t.new_string:ge(e,s,l,o);return!f&&r&&e===h&&(f={display:"No changes to apply. The new content is identical to the current content.",raw:`No changes to apply. The new content is identical to the current content in file: ${t.file_path}`,type:"edit_no_change"}),{currentContent:e,newContent:h,occurrences:c,error:f,isNewFile:o,bom:g,encoding:m,lineEnding:d}}async getDefaultPermission(){let t=this.config.getProjectRoot();return z(p.resolve(this.params.file_path),t)?"allow":"ask"}async getConfirmationDetails(t){let i=C(this.config,this.params.file_path);if(i)throw new R(i,"path_not_in_workspace");let e;try{e=await this.calculateEdit(this.params)}catch(s){if(t.aborted)throw s;let c=s instanceof Error?s.message:String(s);throw new Error(`Error preparing edit: ${c}`)}if(e.error)throw new R(e.error.raw,e.error.type);let r=p.basename(this.params.file_path),o=D(r,e.currentContent??"",e.newContent,"Current","Proposed",L);return{type:"edit",title:`Confirm Edit: ${T(I(this.params.file_path,this.config.getTargetDir()))}`,fileName:r,filePath:this.params.file_path,fileDiff:o,originalContent:e.currentContent,newContent:e.newContent,onConfirm:async s=>{s==="proceed_always"&&this.config.setApprovalMode("auto-edit")}}}getDescription(){let t=I(this.params.file_path,this.config.getTargetDir());return this.params.old_string===""?`Create ${T(t)}`:this.params.old_string===this.params.new_string?`No file changes to ${T(t)}`:T(t)}async execute(t){let i=C(this.config,this.params.file_path);if(i)return{llmContent:i,returnDisplay:i,error:{message:i,type:"path_not_in_workspace"}};let e;try{e=await this.calculateEdit(this.params)}catch(r){if(t.aborted)throw r;let o=r instanceof Error?r.message:String(r);return{llmContent:`Error preparing edit: ${o}`,returnDisplay:`Error preparing edit: ${o}`,error:{message:o,type:"edit_preparation_failure"}}}if(e.error)return{llmContent:e.error.raw,returnDisplay:`Error: ${e.error.display}`,error:{message:e.error.raw,type:e.error.type}};try{try{await this.config.getFileHistoryService().trackEdit(this.params.file_path)}catch{}if(!this.config.getFileReadCacheDisabled()){let u=await S(this.config.getFileReadCache(),this.params.file_path,"editing",{expectExisting:!e.isNewFile});if(!u.ok)return de.warn("pre-write TOCTOU rejection",{path:this.params.file_path,reason:u.type}),{llmContent:u.rawMessage,returnDisplay:`Error: ${u.displayMessage}`,error:{message:u.rawMessage,type:u.type}}}let r=C(this.config,this.params.file_path);if(r)return{llmContent:r,returnDisplay:r,error:{message:r,type:"path_not_in_workspace"}};this.ensureParentDirectoriesExist(this.params.file_path);let o=C(this.config,this.params.file_path);if(o)return{llmContent:o,returnDisplay:o,error:{message:o,type:"path_not_in_workspace"}};if(e.isNewFile){let u=this.config.getDefaultFileEncoding(),N=!1;u===K.UTF8_BOM?N=!0:u===void 0&&(N=V(this.params.file_path)),await this.config.getFileSystemService().writeTextFile({path:this.params.file_path,content:e.newContent,_meta:{bom:N}})}else await this.config.getFileSystemService().writeTextFile({path:this.params.file_path,content:e.newContent,_meta:{bom:e.bom,encoding:e.encoding,lineEnding:e.lineEnding}});this.params.modified_by_user||
|
|
19
|
+
`)}}var de=$("EDIT_PRIOR_READ");function ge(n,t,i,e){return e?i:n===null?t===""?i:"":t===""&&!e?n:B(n,t,i)}var Pe=["filePath","filepath","path","file","filename"],Ae=["oldString","oldText","old_text","previous_string","previousString"],De=["newString","newText","new_text","content"];function Le(n){if(!(typeof n.file_path=="string"&&n.file_path.trim()))for(let t of Pe){let i=n[t];if(typeof i=="string"&&i.trim()){n.file_path=i,delete n[t];break}}if(n.old_string===void 0||n.old_string===null){for(let t of Ae)if(n[t]!==void 0&&n[t]!==null){n.old_string=n[t],delete n[t];break}}if(n.new_string===void 0||n.new_string===null){for(let t of De)if(n[t]!==void 0&&n[t]!==null){n.new_string=n[t],delete n[t];break}}(n.old_string===void 0||n.old_string===null)&&typeof n.new_string=="string"&&typeof n.file_path=="string"&&n.file_path.trim()&&(n.old_string="",n.full_file_replace=!0)}var M=class{constructor(t,i){this.config=t;this.params=i}toolLocations(){return[{path:this.params.file_path}]}async calculateEdit(t){let i=t.replace_all??!1,e=null,r=await P(t.file_path),o=!1,l=t.new_string,s=t.old_string,c=0,f,g=!1,m="utf-8",d="lf";if(!this.config.getFileReadCacheDisabled()){let a=await S(this.config.getFileReadCache(),t.file_path,"editing");if(!a.ok)return{currentContent:null,newContent:"",occurrences:0,error:{display:a.displayMessage,raw:a.rawMessage,type:a.type},isNewFile:!1,encoding:"utf-8",bom:!1,lineEnding:"lf"}}if(r)try{let a=await this.config.getFileSystemService().readTextFile({path:t.file_path});a._meta?.bom!==void 0?g=a._meta.bom:g=a.content.length>0&&a.content.codePointAt(0)===65279,m=a._meta?.encoding||"utf-8",d=Q(a.content),e=a.content.replace(/\r\n/g,`
|
|
20
|
+
`),r=!0}catch(a){if(!x(a)||a.code!=="ENOENT")throw a;r=!1}if(r&&!this.config.getFileReadCacheDisabled()){let a=await S(this.config.getFileReadCache(),t.file_path,"editing",{expectExisting:!0});if(!a.ok)return de.warn("post-read TOCTOU rejection",{path:t.file_path,reason:a.type}),{currentContent:null,newContent:"",occurrences:0,error:{display:a.displayMessage,raw:a.rawMessage,type:a.type},isNewFile:!1,encoding:"utf-8",bom:!1,lineEnding:"lf"}}if(t.full_file_replace)o=!r,r&&e!==null?(c=1,s=e,l=t.new_string):r||(s="",l=t.new_string);else{let a=oe(e,s,l);if(s=a.oldString,l=a.newString,s===""&&!r)o=!0;else if(!r)f={display:"File not found. Cannot apply edit. Use an empty old_string to create a new file.",raw:`File not found: ${t.file_path}`,type:"file_not_found"};else if(e!==null)if(s=se(e,s,l),c=le(e,s),t.old_string==="")f={display:"Failed to edit. Attempted to create a file that already exists.",raw:`File already exists, cannot create: ${t.file_path}`,type:"attempt_to_create_existing_file"};else if(c===0){let E=ae(e,s);f={display:"Failed to edit, could not find the string to replace.",raw:`Failed to edit, 0 occurrences found for old_string in ${t.file_path}. No edits made. ${E??`The exact text in old_string was not found. Ensure you're not escaping content incorrectly and check whitespace, indentation, and context. Use ${A.Name} tool to verify.`}`,type:"edit_no_occurrence_found"}}else!i&&c>1?f={display:"Failed to edit because the text matches multiple locations. Provide more context or set replace_all to true.",raw:`Failed to edit. Found ${c} occurrences for old_string in ${t.file_path} but replace_all was not enabled.`,type:"edit_expected_occurrence_mismatch"}:s===l&&(f={display:"No changes to apply. The old_string and new_string are identical.",raw:`No changes to apply. The old_string and new_string are identical in file: ${t.file_path}`,type:"edit_no_change"});else f={display:"Failed to read content of file.",raw:`Failed to read content of existing file: ${t.file_path}`,type:"read_content_failure"}}let h=f?e??"":t.full_file_replace?t.new_string:ge(e,s,l,o);return!f&&r&&e===h&&(f={display:"No changes to apply. The new content is identical to the current content.",raw:`No changes to apply. The new content is identical to the current content in file: ${t.file_path}`,type:"edit_no_change"}),{currentContent:e,newContent:h,occurrences:c,error:f,isNewFile:o,bom:g,encoding:m,lineEnding:d}}async getDefaultPermission(){let t=this.config.getProjectRoot();return z(p.resolve(this.params.file_path),t)?"allow":"ask"}async getConfirmationDetails(t){let i=C(this.config,this.params.file_path);if(i)throw new R(i,"path_not_in_workspace");let e;try{e=await this.calculateEdit(this.params)}catch(s){if(t.aborted)throw s;let c=s instanceof Error?s.message:String(s);throw new Error(`Error preparing edit: ${c}`)}if(e.error)throw new R(e.error.raw,e.error.type);let r=p.basename(this.params.file_path),o=D(r,e.currentContent??"",e.newContent,"Current","Proposed",L);return{type:"edit",title:`Confirm Edit: ${T(I(this.params.file_path,this.config.getTargetDir()))}`,fileName:r,filePath:this.params.file_path,fileDiff:o,originalContent:e.currentContent,newContent:e.newContent,onConfirm:async s=>{s==="proceed_always"&&this.config.setApprovalMode("auto-edit")}}}getDescription(){let t=I(this.params.file_path,this.config.getTargetDir());return this.params.old_string===""?`Create ${T(t)}`:this.params.old_string===this.params.new_string?`No file changes to ${T(t)}`:T(t)}async execute(t){let i=C(this.config,this.params.file_path);if(i)return{llmContent:i,returnDisplay:i,error:{message:i,type:"path_not_in_workspace"}};let e;try{e=await this.calculateEdit(this.params)}catch(r){if(t.aborted)throw r;let o=r instanceof Error?r.message:String(r);return{llmContent:`Error preparing edit: ${o}`,returnDisplay:`Error preparing edit: ${o}`,error:{message:o,type:"edit_preparation_failure"}}}if(e.error)return{llmContent:e.error.raw,returnDisplay:`Error: ${e.error.display}`,error:{message:e.error.raw,type:e.error.type}};try{try{await this.config.getFileHistoryService().trackEdit(this.params.file_path)}catch{}if(!this.config.getFileReadCacheDisabled()){let u=await S(this.config.getFileReadCache(),this.params.file_path,"editing",{expectExisting:!e.isNewFile});if(!u.ok)return de.warn("pre-write TOCTOU rejection",{path:this.params.file_path,reason:u.type}),{llmContent:u.rawMessage,returnDisplay:`Error: ${u.displayMessage}`,error:{message:u.rawMessage,type:u.type}}}let r=C(this.config,this.params.file_path);if(r)return{llmContent:r,returnDisplay:r,error:{message:r,type:"path_not_in_workspace"}};this.ensureParentDirectoriesExist(this.params.file_path);let o=C(this.config,this.params.file_path);if(o)return{llmContent:o,returnDisplay:o,error:{message:o,type:"path_not_in_workspace"}};if(e.isNewFile){let u=this.config.getDefaultFileEncoding(),N=!1;u===K.UTF8_BOM?N=!0:u===void 0&&(N=V(this.params.file_path)),await this.config.getFileSystemService().writeTextFile({path:this.params.file_path,content:e.newContent,_meta:{bom:N}})}else await this.config.getFileSystemService().writeTextFile({path:this.params.file_path,content:e.newContent,_meta:{bom:e.bom,encoding:e.encoding,lineEnding:e.lineEnding}});this.params.modified_by_user||q.getInstance().recordEdit(this.params.file_path,e.currentContent,e.newContent);try{let u=_.statSync(this.params.file_path);this.config.getFileReadCache().recordWrite(this.params.file_path,u)}catch{}let l=p.basename(this.params.file_path),s=this.params.ai_proposed_content||e.newContent,c=G(l,e.currentContent??"",s,e.newContent),g={fileDiff:D(l,e.currentContent??"",e.newContent,"Current","Proposed",L),fileName:l,originalContent:e.currentContent,newContent:e.newContent,diffStat:c},m=U(this.params.file_path),d=H(this.params.file_path),h=p.extname(this.params.file_path),a=e.isNewFile?"create":"update";j(this.config,new X(O.Name,a,e.newContent.split(`
|
|
21
21
|
`).length,m,h,d));let E=[e.isNewFile?`Created new file: ${this.params.file_path} with provided content.`:`The file: ${this.params.file_path} has been updated.`],y=fe(e.currentContent,e.newContent);if(y){let u=`Showing lines ${y.startLine}-${y.endLine} of ${y.totalLines} from the edited file:
|
|
22
22
|
|
|
23
23
|
---
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{Bc as
|
|
3
|
+
import{Bc as s,Bd as T,yc as W}from"./chunk-QNXNECWR.js";import"./chunk-HRCRNKY2.js";import"./chunk-ZSGBDQXU.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DEN6RR3B.js";import"./chunk-RH3AEZWO.js";import"./chunk-UICLGQTV.js";import"./chunk-V2V3OF76.js";import"./chunk-GCMUSGTT.js";import"./chunk-SMTY6M3W.js";import"./chunk-QXSBPCBA.js";import"./chunk-ZABAV4XA.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-5JCW6FH6.js";import"./chunk-2LVAK6TV.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-Y3SZK63U.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-DUB7JMQV.js";import"./chunk-CI5CVVGI.js";import"./chunk-IV6PS6DB.js";import"./chunk-6RK6IJY5.js";import"./chunk-LONWTJOE.js";import"./chunk-TKEFJ3O3.js";import"./chunk-7AEOFDY3.js";import"./chunk-XPVKH5TC.js";import{f as $,g as E,m,n as R}from"./chunk-KYNP66YS.js";import{Y as b}from"./chunk-AEYNMLMW.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.js";import{b as y}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";y();var o=b("ENTER_WORKTREE"),P=`Creates an isolated git worktree at \`<projectRoot>/.matilda/worktrees/<slug>\` and returns its absolute path so subsequent file edits, shell commands, and other tools can operate inside it.
|
|
4
4
|
|
|
5
5
|
## When to Use
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{
|
|
3
|
+
import{$c as r}from"./chunk-QNXNECWR.js";import"./chunk-HRCRNKY2.js";import"./chunk-ZSGBDQXU.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DEN6RR3B.js";import"./chunk-RH3AEZWO.js";import"./chunk-UICLGQTV.js";import"./chunk-V2V3OF76.js";import"./chunk-GCMUSGTT.js";import"./chunk-SMTY6M3W.js";import"./chunk-QXSBPCBA.js";import"./chunk-ZABAV4XA.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-5JCW6FH6.js";import"./chunk-2LVAK6TV.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-Y3SZK63U.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-DUB7JMQV.js";import"./chunk-CI5CVVGI.js";import"./chunk-IV6PS6DB.js";import"./chunk-6RK6IJY5.js";import"./chunk-LONWTJOE.js";import"./chunk-TKEFJ3O3.js";import"./chunk-7AEOFDY3.js";import"./chunk-XPVKH5TC.js";import{f as m,g as u,m as d,n as c}from"./chunk-KYNP66YS.js";import{Y as p}from"./chunk-AEYNMLMW.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.js";import{b as l}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";l();var y=p("ENTER_PLAN_MODE"),g=`Use this tool to lower into plan mode before doing uncertain or complex work. Entering plan mode is a privilege reduction, so it does not require user confirmation.
|
|
4
4
|
|
|
5
5
|
## When to Use This Tool
|
|
6
6
|
Use this tool when the task is not yet clear enough to safely execute, for example when it requires multi-file changes, design choices, investigation before a plan can be summarized, or when requirements are ambiguous. While investigating, if complexity rises or you find yourself repeatedly needing to ask the user, enter plan mode and consolidate a plan.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{
|
|
3
|
+
import{Ad as C,Bc as l,Cd as x,xc as k,zc as W}from"./chunk-QNXNECWR.js";import"./chunk-HRCRNKY2.js";import"./chunk-ZSGBDQXU.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DEN6RR3B.js";import"./chunk-RH3AEZWO.js";import"./chunk-UICLGQTV.js";import"./chunk-V2V3OF76.js";import"./chunk-GCMUSGTT.js";import"./chunk-SMTY6M3W.js";import"./chunk-QXSBPCBA.js";import"./chunk-ZABAV4XA.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-5JCW6FH6.js";import"./chunk-2LVAK6TV.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-Y3SZK63U.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-DUB7JMQV.js";import"./chunk-CI5CVVGI.js";import"./chunk-IV6PS6DB.js";import"./chunk-6RK6IJY5.js";import"./chunk-LONWTJOE.js";import"./chunk-TKEFJ3O3.js";import"./chunk-7AEOFDY3.js";import"./chunk-XPVKH5TC.js";import{f as E,g as R,m as c,n as T}from"./chunk-KYNP66YS.js";import{Y as b,c as $}from"./chunk-AEYNMLMW.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.js";import{b as y}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";y();import*as S from"node:fs/promises";var h=b("EXIT_WORKTREE"),O=`Exits a worktree previously created by ${c.ENTER_WORKTREE}.
|
|
4
4
|
|
|
5
5
|
## Behavior
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{a as S}from"./chunk-ILBTI4K5.js";import{
|
|
3
|
+
import{a as S}from"./chunk-ILBTI4K5.js";import{$c as b,Kc as F,tc as D,zd as O}from"./chunk-QNXNECWR.js";import"./chunk-HRCRNKY2.js";import"./chunk-ZSGBDQXU.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DEN6RR3B.js";import"./chunk-RH3AEZWO.js";import"./chunk-UICLGQTV.js";import"./chunk-V2V3OF76.js";import"./chunk-GCMUSGTT.js";import"./chunk-SMTY6M3W.js";import"./chunk-QXSBPCBA.js";import"./chunk-ZABAV4XA.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-5JCW6FH6.js";import"./chunk-2LVAK6TV.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-Y3SZK63U.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import{n as $}from"./chunk-DUB7JMQV.js";import"./chunk-CI5CVVGI.js";import"./chunk-IV6PS6DB.js";import"./chunk-6RK6IJY5.js";import"./chunk-LONWTJOE.js";import"./chunk-TKEFJ3O3.js";import"./chunk-7AEOFDY3.js";import"./chunk-XPVKH5TC.js";import{f as x,g as R,m as M,n as C}from"./chunk-KYNP66YS.js";import{Y as y}from"./chunk-AEYNMLMW.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.js";import{b as v}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";v();v();v();var G=y("GATE_REVIEW_AGENTS");function ee(e){return`You are a Plan Design Reviewer for the Plan Approval Gate. Review the plan across three dimensions:
|
|
4
4
|
|
|
5
5
|
1. **Request Fit** \u2014 Does the plan fulfill every part of the user's original request and respect all explicit constraints? Does it do anything the user explicitly asked NOT to do?
|
|
6
6
|
2. **System Fit** \u2014 Does the plan align with the codebase structure, file paths, function names, permission model, and integration boundaries found during investigation?
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{
|
|
3
|
+
import{$b as j,_b as _}from"./chunk-QNXNECWR.js";import"./chunk-HRCRNKY2.js";import"./chunk-ZSGBDQXU.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DEN6RR3B.js";import"./chunk-RH3AEZWO.js";import"./chunk-UICLGQTV.js";import"./chunk-V2V3OF76.js";import"./chunk-GCMUSGTT.js";import"./chunk-SMTY6M3W.js";import"./chunk-QXSBPCBA.js";import"./chunk-ZABAV4XA.js";import"./chunk-V6UPUMP3.js";import{a as D}from"./chunk-5B2QERWR.js";import"./chunk-5JCW6FH6.js";import"./chunk-2LVAK6TV.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-Y3SZK63U.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-DUB7JMQV.js";import"./chunk-CI5CVVGI.js";import{b as k}from"./chunk-IV6PS6DB.js";import"./chunk-6RK6IJY5.js";import"./chunk-LONWTJOE.js";import"./chunk-TKEFJ3O3.js";import"./chunk-7AEOFDY3.js";import"./chunk-XPVKH5TC.js";import{f as M,g as C,m as N,n as A}from"./chunk-KYNP66YS.js";import{F as $,I as O,M as v,Y as R,e as x}from"./chunk-AEYNMLMW.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.js";import{b as L}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";L();import z from"node:fs";import T from"node:path";var V=R("GLOB"),Y=100,B=2e4,W=15e3,q=500;function K(u,g,t){let e=[...u];return e.sort((r,s)=>{let c=r.mtimeMs??0,a=s.mtimeMs??0,o=g-c<t,l=g-a<t;return o&&l?a-c:o?-1:l?1:r.fullpath().localeCompare(s.fullpath())}),e}var S=class extends M{constructor(t,e){super(e);this.config=t;this.fileService=t.getFileService()}fileService;getDescription(){let t=`'${this.params.pattern}'`;return this.params.path&&(t+=` in path '${this.params.path}'`),t}async getDefaultPermission(){if(!this.params.path)return"allow";let t=this.config.getWorkspaceContext(),e=T.resolve(this.config.getTargetDir(),this.params.path);return t.isPathWithinWorkspace(e)||O(k(),e)?"allow":"ask"}async globInDirectory(t,e,r){let s=e,c=T.join(t,s);z.existsSync(c)&&(s=_(s));let a=j(s,{cwd:t,withFileTypes:!0,nodir:!0,stat:!0,nocase:!0,dot:!0,ignore:this.config.getFileExclusions().getGlobExcludes(),follow:!1,signal:r}),o=[],l=Date.now(),p=null;for await(let n of a){if(o.push(n),o.length>=B){p="count";break}if(Date.now()-l>W){p="time";break}o.length%q===0&&await new Promise(b=>setImmediate(b))}p&&a.destroy?.();let d=this.config.getTargetDir(),P=o.map(n=>T.relative(d,n.fullpath())),{filteredPaths:m}=this.fileService.filterFilesWithReport(P,this.getFileFilteringOptions()),h=n=>process.platform==="win32"||process.platform==="darwin"?n.toLowerCase():n,f=new Set(m.map(n=>h(T.resolve(d,n))));return{entries:o.filter(n=>f.has(h(n.fullpath()))),limited:p}}async execute(t){try{let e=[],r;if(this.params.path){let i=v(this.config,this.params.path,{allowExternalPaths:!0});e.push(i),r=`within ${i}`}else{let i=this.config.getWorkspaceContext().getDirectories();e.push(...i),r=i.length>1?`across ${i.length} workspace directories`:"in the workspace directory"}let s=this.params.pattern,c=[],a=new Set,o=null;for(let i of e){let{entries:F,limited:E}=await this.globInDirectory(i,s,t);E&&(o=E);for(let G of F){let I=G.fullpath();a.has(I)||(a.add(I),c.push(G))}}let l=c,p=o==="time"?`
|
|
4
4
|
|
|
5
5
|
[Search stopped after ${W/1e3}s before scanning the whole tree. Results may be incomplete \u2014 narrow the search by passing a more specific 'path' or pattern.]`:o==="count"?`
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{T as w,U as f,a as h,v as b}from"./chunk-
|
|
3
|
+
import{T as w,U as f,a as h,v as b}from"./chunk-V2V3OF76.js";import"./chunk-GCMUSGTT.js";import"./chunk-V6UPUMP3.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-DUB7JMQV.js";import"./chunk-TKEFJ3O3.js";import"./chunk-XPVKH5TC.js";import{f as c,g as d,m,n as p}from"./chunk-KYNP66YS.js";import"./chunk-AEYNMLMW.js";import"./chunk-HEJO7OBH.js";import{b as P}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";P();function l(o,a){return typeof o!="object"||o===null||!a.some(e=>e in o)?o:Object.fromEntries(Object.entries(o).filter(([e])=>!a.includes(e)))}var G=class extends c{constructor(e,t,r,i){super(e);this.runtime=t;this.permit=r;this.lastGoal=i}getDescription(){return"Read the current goal"}async execute(e){if(!this.runtime||!this.permit)return E(this.lastGoal);let t=await S(this.runtime,this.permit,e);e.throwIfAborted();let r=y(this.runtime,this.permit);if(t.goalId!==this.permit.goalId||t.revision!==this.permit.revision)throw u();let i=C(t,r);return{llmContent:JSON.stringify(i),returnDisplay:`Active goal \xB7 revision ${t.revision}`}}},k=class o extends d{constructor(e){super(o.Name,p.GET_GOAL,`Read the current Goal: its objective, status, budget figures, and any verifier feedback. Read-only; never changes Goal state.
|
|
4
4
|
|
|
5
5
|
Outside a Goal turn it returns "active": false with "lastGoal", a summary of the session's most recent Goal. Use the result silently; do not mention the retrieval to the user.`,"read",{type:"object",properties:{},additionalProperties:!1},!0,!1,!1);this.config=e}static Name=m.GET_GOAL;build(e){return super.build(l(e,["view"]))}validateToolParams(e){return super.validateToolParams(l(e,["view"]))}createInvocation(e){let t=h.getStore(),r=t?structuredClone(t):void 0,i=r?this.config.getGoalRuntime():void 0;return new G(e,i,r,r?void 0:this.lastGoal())}lastGoal(){let e;try{e=this.config.getGoalRuntime()}catch{return}if(typeof e?.getSnapshot!="function")return;let t=e.getSnapshot().goal;if(t)return{goalId:t.goalId,revision:t.revision,status:t.status,turnCount:t.turnCount,activeTimeMs:t.activeTimeMs,tokensUsed:t.tokensUsed,...t.tokenBudget===void 0?{}:{tokenBudget:t.tokenBudget},...t.turnBudget===void 0?{}:{turnBudget:t.turnBudget},...t.activeTimeBudgetMs===void 0?{}:{activeTimeBudgetMs:t.activeTimeBudgetMs},...t.lastReason===void 0?{}:{lastReason:t.lastReason}}}};function E(o){return o?{llmContent:JSON.stringify({active:!1,lastGoal:o}),returnDisplay:`No Goal turn is permitted \xB7 last Goal ${o.status} after ${o.turnCount} ${o.turnCount===1?"turn":"turns"}`}:{llmContent:JSON.stringify({active:!1}),returnDisplay:"No active Goal is available for this turn."}}var v=class extends c{constructor(e,t,r){super(e);this.runtime=t;this.permit=r}getDescription(){return`Propose that the Goal is ${this.params.status} for this permitted turn`}async execute(e){if(!this.runtime||!this.permit)throw new Error("No active Goal is available for this turn");let t=this.permit,r=await S(this.runtime,t,e);if(e.throwIfAborted(),y(this.runtime,t),r.goalId!==this.permit.goalId||r.revision!==this.permit.revision)throw u();let i={status:this.params.status,reason:this.params.reason.trim(),...this.params.blockerKind?{blockerKind:this.params.blockerKind}:{}};e.throwIfAborted();let n=F(this.runtime,this.permit,i),T=y(this.runtime,this.permit),x={proposalRecorded:n.recorded,readyForVerification:n.readyForVerification,goalLifecycleChanged:!1,nextAction:n.readyForVerification?"End this turn without user-facing text. Do not claim the Goal is complete or blocked. The Goal status card will report the independent verification result.":"Continue this turn without claiming the Goal is complete or blocked. A repeated-blocker audit requires the same blocker mode and exact same reason text across three consecutive Goal turns, each of which must show the blocker in its own tool results."},s;return n.recorded?n.readyForVerification&&T.goal?.status==="active"?s="Proposal queued for independent verification at the turn boundary; no terminal lifecycle change was committed.":T.goal?.status==="paused"?s="Proposal recorded while the Goal is paused; no terminal lifecycle change was committed.":s="Proposal recorded for blocker audit; it is not yet ready for independent verification and no terminal lifecycle change was committed.":s="A Goal proposal is already recorded for this turn; no terminal lifecycle change was committed.",{llmContent:JSON.stringify(x),returnDisplay:s}}},R=class o extends d{constructor(e){super(o.Name,p.UPDATE_GOAL,`Propose that the current Goal is complete or blocked; an independent verifier decides and this tool never changes the Goal's status.
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{
|
|
3
|
+
import{$b as Q,E as k,sa as Y,sd as Z,td as tt,ud as et,vd as rt,wd as st}from"./chunk-QNXNECWR.js";import"./chunk-HRCRNKY2.js";import"./chunk-ZSGBDQXU.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DEN6RR3B.js";import"./chunk-RH3AEZWO.js";import"./chunk-UICLGQTV.js";import"./chunk-V2V3OF76.js";import"./chunk-GCMUSGTT.js";import"./chunk-SMTY6M3W.js";import"./chunk-QXSBPCBA.js";import"./chunk-ZABAV4XA.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-5JCW6FH6.js";import"./chunk-2LVAK6TV.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-Y3SZK63U.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-DUB7JMQV.js";import"./chunk-CI5CVVGI.js";import{b as X}from"./chunk-IV6PS6DB.js";import"./chunk-6RK6IJY5.js";import"./chunk-LONWTJOE.js";import"./chunk-TKEFJ3O3.js";import"./chunk-7AEOFDY3.js";import"./chunk-XPVKH5TC.js";import{f as J,g as q,m as z,n as K}from"./chunk-KYNP66YS.js";import{F as _,I as H,L as U,M as N,Y as V,c as j,e as w}from"./chunk-AEYNMLMW.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.js";import{b as W}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";W();import it from"node:fs/promises";import E from"node:path";import{EOL as lt}from"node:os";import{spawn as nt}from"node:child_process";var L=V("GREP"),D=class extends J{constructor(s,i){super(i);this.config=s;this.fileExclusions=s.getFileExclusions()}fileExclusions;async getDefaultPermission(){if(!this.params.path)return"allow";let s=this.config.getWorkspaceContext(),i=E.resolve(this.config.getTargetDir(),this.params.path);return s.isPathWithinWorkspace(i)||H(X(),i)||U(this.config,i)?"allow":"ask"}async execute(s){try{let i=[],o;if(this.params.path){let t=N(this.config,this.params.path,{allowFiles:!0,allowExternalPaths:!0});i.push(t),o=`in path "${this.params.path}"`}else{let t=this.config.getWorkspaceContext().getDirectories();i.push(...t),o=t.length>1?`across ${t.length} workspace directories`:"in the workspace directory"}let a=[];for(let t of i){let e=await this.performGrepSearch({pattern:this.params.pattern,path:t,glob:this.params.glob,signal:s});if(i.length>1)for(let n of e)E.isAbsolute(n.filePath)||(n.filePath=E.resolve(t,n.filePath));a.push(...e)}if(i.length>1){let t=new Set;a=a.filter(e=>{let n=`${e.filePath}:${e.lineNumber}`;return t.has(n)?!1:(t.add(n),!0)})}let c=this.params.glob?` (filter: "${this.params.glob}")`:"";if(a.length===0)return{llmContent:`No matches found for pattern "${this.params.pattern}" ${o}${c}.`,returnDisplay:"No matches found"};let p=this.config.getTruncateToolOutputThreshold(),u=Math.min(this.config.getTruncateToolOutputLines(),this.params.limit??Number.POSITIVE_INFINITY),x=!1,h=a;a.length>u&&(h=a.slice(0,u),x=!0);let $=a.length,G=$===1?"match":"matches",v=`Found ${$} ${G} for pattern "${this.params.pattern}" ${o}${c}:
|
|
4
4
|
---
|
|
5
5
|
`,T=h.reduce((t,e)=>{let n=e.filePath;return t[n]||(t[n]=[]),t[n].push(e),t[n].sort((y,F)=>y.lineNumber-F.lineNumber),t},{}),P="",M=[],C=!1,g=(t,e)=>Number.isFinite(p)&&P.length+t.length>p?(P+=t.slice(0,Math.max(p-P.length,0)),P+="...",e&&M.push(e),C=!0,!1):(P+=t,e&&M.push(e),!0);for(let t in T){if(!g(`File: ${t}
|
|
6
6
|
`))break;let e=!1;for(let n of T[t]){let y=n.line.length>et?n.range??st(n.line,this.params.pattern):void 0,F=rt(n.line,y?.[0]??0,y?.[1]??0).trim();if(!g(`L${n.lineNumber}: ${F}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{b as a}from"./chunk-
|
|
3
|
+
import{b as a}from"./chunk-5JCW6FH6.js";import"./chunk-AEYNMLMW.js";import"./chunk-HEJO7OBH.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{a as KeychainTokenStorage};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{a as d}from"./chunk-5B2QERWR.js";import{b as N}from"./chunk-
|
|
3
|
+
import{a as d}from"./chunk-5B2QERWR.js";import{b as N}from"./chunk-IV6PS6DB.js";import{f as C,g as x,m as w,n as F}from"./chunk-KYNP66YS.js";import{C as E,D as I,F as S,I as u,J as L,O as R,Y as O}from"./chunk-AEYNMLMW.js";import"./chunk-HEJO7OBH.js";import{b as v}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";v();import y from"node:fs/promises";import s from"node:path";var A=O("LS"),U=100,T=class extends C{constructor(t,e){super(e);this.config=t}shouldIgnore(t,e){if(!e||e.length===0)return!1;for(let i of e){let a=i.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");if(new RegExp(`^${a}$`).test(t))return!0}return!1}getDescription(){let t=I(this.params.path,this.config.getTargetDir());return E(t)}async getDefaultPermission(){let t=s.resolve(this.params.path),e=this.config.getWorkspaceContext(),i=this.config.storage.getUserSkillsDirs(),a=R.getUserExtensionsDir();return e.isPathWithinWorkspace(t)||L(i,t)||u(a,t)||u(N(),t)?"allow":"ask"}errorResult(t,e,i){return{llmContent:t,returnDisplay:`Error: ${e}`,error:{message:t,type:i}}}async execute(t){try{let e=await y.stat(this.params.path);if(!e)return this.errorResult(`Error: Directory not found or inaccessible: ${this.params.path}`,"Directory not found or inaccessible.","file_not_found");if(!e.isDirectory())return this.errorResult(`Error: Path is not a directory: ${this.params.path}`,"Path is not a directory.","path_is_not_a_directory");let i=await y.readdir(this.params.path);if(i.length===0)return{llmContent:`Directory ${this.params.path} is empty.`,returnDisplay:"Directory is empty."};let a=i.map(r=>s.relative(this.config.getTargetDir(),s.join(this.params.path,r))),_=this.config.getFileService(),{filteredPaths:k,gitIgnoredCount:P,matildaIgnoredCount:b}=_.filterFilesWithReport(a,{respectGitIgnore:this.params.file_filtering_options?.respect_git_ignore??this.config.getFileFilteringOptions().respectGitIgnore??d.respectGitIgnore,respectMatildaIgnore:this.params.file_filtering_options?.respect_matilda_ignore??this.config.getFileFilteringOptions().respectMatildaIgnore??d.respectMatildaIgnore}),l=[];for(let r of k){let o=s.resolve(this.config.getTargetDir(),r);if(!this.shouldIgnore(s.basename(o),this.params.ignore))try{let c=await y.stat(o),$=c.isDirectory();l.push({name:s.basename(o),path:o,isDirectory:$,size:$?0:c.size,modifiedTime:c.mtime})}catch(c){A.warn(`Error accessing ${o}: ${c}`)}}l.sort((r,o)=>r.isDirectory&&!o.isDirectory?-1:!r.isDirectory&&o.isDirectory?1:r.name.localeCompare(o.name));let p=l.length,g=Math.min(U,this.config.getTruncateToolOutputLines()),m=p>g,W=(m?l.slice(0,g):l).map(r=>`${r.isDirectory?"[DIR] ":""}${r.name}`).join(`
|
|
4
4
|
`),h=`Listed ${p} item(s) in ${this.params.path}:
|
|
5
5
|
---
|
|
6
6
|
${W}`;if(m){let r=p-g;h+=`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Force strict mode and setup for ESM
|
|
2
2
|
"use strict";
|
|
3
|
-
import{f as b,g as D,m as R,n as N}from"./chunk-
|
|
3
|
+
import{f as b,g as D,m as R,n as N}from"./chunk-KYNP66YS.js";import{F as P}from"./chunk-AEYNMLMW.js";import"./chunk-HEJO7OBH.js";import{b as S}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";S();import $ from"node:path";import{fileURLToPath as L,pathToFileURL as q}from"node:url";var O=new Set(["goToDefinition","findReferences","hover","goToImplementation","prepareCallHierarchy"]),A=new Set(["documentSymbol","diagnostics"]),E=new Set(["workspaceSymbol"]),U=new Set(["incomingCalls","outgoingCalls"]),W=new Set(["codeActions"]),C=class extends b{constructor(t,e){super(e);this.config=t}getDescription(){let t=this.getOperationLabel();return this.params.operation==="workspaceSymbol"?`LSP ${t} for "${this.params.query??""}"`:this.params.operation==="documentSymbol"?this.params.filePath?`LSP ${t} for ${this.params.filePath}`:`LSP ${t}`:this.params.operation==="incomingCalls"||this.params.operation==="outgoingCalls"?`LSP ${t} for ${this.describeCallHierarchyItemShort()}`:this.params.filePath&&this.params.line!==void 0?`LSP ${t} at ${this.params.filePath}:${this.params.line}:${this.params.character??1}`:this.params.filePath?`LSP ${t} for ${this.params.filePath}`:`LSP ${t}`}async execute(t){let e=this.config.getLspClient();if(!e||!this.config.isLspEnabled()){let r=`LSP ${this.getOperationLabel()} is unavailable (LSP disabled or not initialized).`;return{llmContent:r,returnDisplay:r}}switch(this.params.operation){case"goToDefinition":return this.executeDefinitions(e);case"findReferences":return this.executeReferences(e);case"hover":return this.executeHover(e);case"documentSymbol":return this.executeDocumentSymbols(e);case"workspaceSymbol":return this.executeWorkspaceSymbols(e);case"goToImplementation":return this.executeImplementations(e);case"prepareCallHierarchy":return this.executePrepareCallHierarchy(e);case"incomingCalls":return this.executeIncomingCalls(e);case"outgoingCalls":return this.executeOutgoingCalls(e);case"diagnostics":return this.executeDiagnostics(e);case"workspaceDiagnostics":return this.executeWorkspaceDiagnostics(e);case"codeActions":return this.executeCodeActions(e);default:{let r=`Unsupported LSP operation: ${this.params.operation}`;return{llmContent:r,returnDisplay:r}}}}async executeDefinitions(t){let e=this.resolveLocationTarget();if("error"in e)return{llmContent:e.error,returnDisplay:e.error};let r=this.params.limit??20,i=[];try{i=await t.definitions(e.location,this.params.serverName,r)}catch(n){let c=`LSP go-to-definition failed: ${n?.message||String(n)}`;return{llmContent:c,returnDisplay:c}}if(!i.length){let n=`No definitions found for ${e.description}.`;return{llmContent:n,returnDisplay:n}}let s=this.config.getProjectRoot(),a=i.slice(0,r).map((n,c)=>`${c+1}. ${this.formatLocationWithServer(n,s)}`);return{llmContent:[`Definitions for ${e.description}:`,...a].join(`
|
|
4
4
|
`),returnDisplay:a.join(`
|
|
5
5
|
`)}}async executeImplementations(t){let e=this.resolveLocationTarget();if("error"in e)return{llmContent:e.error,returnDisplay:e.error};let r=this.params.limit??20,i=[];try{i=await t.implementations(e.location,this.params.serverName,r)}catch(n){let c=`LSP go-to-implementation failed: ${n?.message||String(n)}`;return{llmContent:c,returnDisplay:c}}if(!i.length){let n=`No implementations found for ${e.description}.`;return{llmContent:n,returnDisplay:n}}let s=this.config.getProjectRoot(),a=i.slice(0,r).map((n,c)=>`${c+1}. ${this.formatLocationWithServer(n,s)}`);return{llmContent:[`Implementations for ${e.description}:`,...a].join(`
|
|
6
6
|
`),returnDisplay:a.join(`
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import{$ as s,J as a,K as b,L as c,M as d,N as e,O as f,P as g,Q as h,R as i,S as j,T as k,U as l,V as m,W as n,X as o,Y as p,Z as q,_ as r,aa as t,ba as u,ca as v,da as w,ea as x,fa as y,ga as z,ha as A}from"./chunk-QNXNECWR.js";import"./chunk-HRCRNKY2.js";import"./chunk-ZSGBDQXU.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DEN6RR3B.js";import"./chunk-RH3AEZWO.js";import"./chunk-UICLGQTV.js";import"./chunk-V2V3OF76.js";import"./chunk-GCMUSGTT.js";import"./chunk-SMTY6M3W.js";import"./chunk-QXSBPCBA.js";import"./chunk-ZABAV4XA.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-5JCW6FH6.js";import"./chunk-2LVAK6TV.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-Y3SZK63U.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-DUB7JMQV.js";import"./chunk-CI5CVVGI.js";import"./chunk-IV6PS6DB.js";import"./chunk-6RK6IJY5.js";import"./chunk-LONWTJOE.js";import"./chunk-TKEFJ3O3.js";import"./chunk-7AEOFDY3.js";import"./chunk-XPVKH5TC.js";import"./chunk-KYNP66YS.js";import"./chunk-AEYNMLMW.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.js";import"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";export{d as MCPDiscoveryState,c as MCPServerStatus,a as MCP_DEFAULT_TIMEOUT_MSEC,e as McpClient,g as addMCPStatusChangeListener,s as connectAndDiscover,y as connectToMcpServer,b as createStreamableHttpCompatibilityFetch,z as createTransport,q as discoverMcpTools,v as discoverPrompts,t as discoverTools,m as getAllMCPServerStatuses,n as getMCPDiscoveryState,k as getMCPServerStatus,l as getMCPServerStderrTail,p as handleAutomaticOAuth,x as hasNetworkTransport,w as invokeMcpPrompt,A as isEnabled,u as listMcpPrompts,f as mcpServerRequiresOAuth,r as populateMcpServerCommand,j as removeMCPServerStatus,h as removeMCPStatusChangeListener,o as setMCPDiscoveryState,i as updateMCPServerStatus};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import{A as nt,B as it,Sb as mt,Wb as ct,ad as O,bd as dt,hb as rt,ib as st,jb as at,t as et,tb as P,ub as lt,v as D,x as ot,y as L,z as _}from"./chunk-QNXNECWR.js";import"./chunk-HRCRNKY2.js";import"./chunk-ZSGBDQXU.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DEN6RR3B.js";import"./chunk-RH3AEZWO.js";import"./chunk-UICLGQTV.js";import"./chunk-V2V3OF76.js";import"./chunk-GCMUSGTT.js";import"./chunk-SMTY6M3W.js";import"./chunk-QXSBPCBA.js";import"./chunk-ZABAV4XA.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-5JCW6FH6.js";import"./chunk-2LVAK6TV.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-Y3SZK63U.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-DUB7JMQV.js";import"./chunk-CI5CVVGI.js";import"./chunk-IV6PS6DB.js";import"./chunk-6RK6IJY5.js";import"./chunk-LONWTJOE.js";import"./chunk-TKEFJ3O3.js";import"./chunk-7AEOFDY3.js";import"./chunk-XPVKH5TC.js";import{f as q,g as Y,m as Q,n as tt}from"./chunk-KYNP66YS.js";import{J as K,Y as Z,e as u}from"./chunk-AEYNMLMW.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.js";import{b as J}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";J();import{spawn as ut}from"node:child_process";import ft from"node:path";import{randomUUID as kt}from"node:crypto";var p=Z("MONITOR"),xt=1e3,N=1e4,Dt=3e5,U=6e5,pt=80,R=4096,gt=5,ht=1e3;function yt(c){return c.length>pt?c.slice(0,pt-1)+"\u2026":c}var Rt=new Set(["task-notification","task-id","tool-use-id","kind","status","event-count","summary","result"]),It=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)>/g;function vt(c){let g="";for(let t=0;t<c.length;t++){let n=c.charCodeAt(t);if(n===9){g+=c[t];continue}n<32||n>=128&&n<=159||(g+=c[t])}return g=g.replace(It,(t,n,i)=>Rt.has(String(i).toLowerCase())?n==="/"?`</\u200B${i}>`:`<\u200B${i}>`:t),g}var B=class extends q{constructor(t,n){super(n);this.config=t}callId;setCallId(t){this.callId=t}getDescription(){let t=this.params.description||_(this.params.command).spawnCommand;return`Monitor: ${yt(t)}`}async getDefaultPermission(){if(D().shell!=="bash")return"ask";let t=_(this.params.command).spawnCommand;return await P(t,{cwd:this.params.directory||this.config.getTargetDir(),workspace:this.config.getWorkspaceContext()})?"allow":"ask"}async getConfirmationDetails(t){let n=D(),i=_(this.params.command);if(n.shell==="bash"&&await st(),n.shell!=="bash"||!lt(i.safetyCommand,this.params.directory||this.config.getTargetDir()))return{type:"exec",title:"Monitor",command:i.spawnCommand,rootCommand:n.executable,permissionRules:[],hideAlwaysAllow:!0,onConfirm:async()=>{}};let h=ot(i.safetyCommand),C=[];for(let l of h){let a=!1;try{a=await P(l,{cwd:this.params.directory||this.config.getTargetDir(),workspace:this.config.getWorkspaceContext()})}catch(m){p.warn("AST read-only check failed for monitor sub-command, falling back to ask:",m)}a||C.push(l)}let v=C.length>0?C:h,w=[...new Set(v.map(l=>L(l)).filter(l=>!!l))],r=[];try{let l=[];for(let a of v){let m=await at(a);l.push(...m)}r=[...new Set(l)].map(a=>`Monitor(${a})`)}catch(l){p.warn("Failed to extract monitor command rules:",l),r=[`Monitor(${i.safetyCommand})`]}let d=it(i.safetyCommand,this.params.command),b={type:"exec",title:"Monitor",command:i.spawnCommand,rootCommand:w.join(", ")||(L(i.safetyCommand)??i.spawnCommand),permissionRules:r,onConfirm:async(l,a)=>{}};return d&&(b.warnings=d),b}async execute(t){if(t.aborted)return{llmContent:"Monitor was cancelled before it could start.",returnDisplay:"Monitor cancelled."};let n=_(this.params.command),i=n.spawnCommand;n.strippedTrailingAmp&&p.warn("Stripped trailing & from monitor command \u2014 monitor lifecycle handles backgrounding");let h=vt(this.params.description||i),C=yt(h),v=Math.min(this.params.max_events??xt,N),w=Math.min(this.params.idle_timeout_ms??Dt,U),r=`mon_${kt().replace(/-/g,"").slice(0,16)}`,d=this.config.getMonitorRegistry(),b=rt()??void 0;if(d.getRunning().length>=O)return{llmContent:`Cannot start monitor: maximum concurrent monitors (${O}) reached. Stop an existing monitor first.`,returnDisplay:"Monitor rejected: too many concurrent monitors."};let a=new AbortController,m={monitorId:r,command:i,description:h,status:"running",startTime:Date.now(),abortController:a,toolUseId:this.callId,eventCount:0,lastEventTime:0,maxEvents:v,idleTimeoutMs:w,droppedLines:0,outputFile:dt(this.config.storage.getProjectDir(),this.config.getSessionId(),r),...b?{ownerAgentId:b}:{}},{executable:_t,argsPrefix:Ct}=D(),o;try{o=ut(_t,[...Ct,i],{cwd:this.params.directory||this.config.getTargetDir(),stdio:["ignore","pipe","pipe"],detached:!0,env:{...et(),MATILDA_CODE:"1",TERM:"dumb",PAGER:"cat",...ct()}})}catch(e){return{llmContent:`Monitor failed to start: ${u(e)}`,returnDisplay:`Monitor failed: ${u(e)}`}}m.pid=o.pid;let M=!1,E,I=e=>{E??=e};o.on("error",I);let G={value:""},z={value:""},k=gt,A=Date.now(),$=e=>{let s=vt(e);if(s.length===0||s.trim().length===0)return;let y=Date.now(),T=y-A;if(T<0)p.warn(`Monitor ${r}: clock moved backwards by ${-T}ms, resetting refill timestamp`),A=y;else{let f=Math.floor(T/ht);f>0&&(k=Math.min(gt,k+f),A+=f*ht)}k>0?(k--,d.emitEvent(r,s)):m.droppedLines++},W=()=>{for(let e of[G,z]){let s=e.value.trim();s.length>0&&$(s),e.value=""}},wt=()=>{if(!(M||!o.pid))if(process.platform==="win32")ut("taskkill",["/pid",o.pid.toString(),"/f","/t"],{stdio:"ignore"}).on("error",s=>p.warn(`Monitor taskkill failed for pid ${o.pid}: ${u(s)}`));else{try{process.kill(-o.pid,"SIGTERM")}catch(e){p.warn(`Monitor ${r} SIGTERM failed (pid=${o.pid}): ${u(e)}`)}setTimeout(()=>{if(!M&&o.pid)try{process.kill(-o.pid,"SIGKILL")}catch(e){p.warn(`Monitor ${r} SIGKILL escalation failed (pid=${o.pid}): ${u(e)}`)}},200).unref?.()}},S=()=>{W(),wt()};a.signal.addEventListener("abort",S,{once:!0}),a.signal.aborted&&S();try{d.register(m)}catch(e){return S(),a.signal.removeEventListener("abort",S),o.stdout?.destroy?.(),o.stderr?.destroy?.(),o.removeListener("error",I),o.on("error",()=>{}),{llmContent:`Monitor failed to start: ${u(e)}`,returnDisplay:`Monitor failed: ${u(e)}`}}let j=(e,s)=>{if(m.status!=="running")return;let y=mt(s.toString("utf-8"));if(e.value+=y,!e.value.includes(`
|
|
4
|
+
`)&&e.value.length>R){let f=e.value.trim();f.length>0&&$(f.slice(0,R)+"..."),e.value="";return}let T=e.value.split(`
|
|
5
|
+
`);e.value=T.pop()??"";for(let f of T){let x=f.trim();if(x.length===0)continue;let St=x.length>R?x.slice(0,R)+"...":x;$(St)}};o.stdout?.on("data",e=>j(G,e)),o.stderr?.on("data",e=>j(z,e));let F=!1,X=()=>{F||(F=!0,W(),a.signal.removeEventListener("abort",S),m.droppedLines>0&&p.info(`Monitor ${r} dropped ${m.droppedLines} lines due to throttling`))},V=null,bt=(e,s)=>{m.status==="running"&&(a.signal.aborted?d.cancel(r):e!==null&&e!==0?d.fail(r,`Exit code ${e}`):s?d.fail(r,`Killed by signal ${s}`):d.complete(r,e))},Mt=(e,s)=>{M=!0,V={code:e,sig:s}},Et=(e,s)=>{M=!0,X();let y=V??{code:e,sig:s};bt(y.code,y.sig)},H=e=>{M=!0,X(),m.status==="running"&&d.fail(r,u(e))};return o.on("exit",Mt),o.on("close",Et),o.on("error",H),o.removeListener("error",I),E?(H(E),{llmContent:`Monitor failed to start: ${u(E)}`,returnDisplay:`Monitor failed: ${u(E)}`}):{llmContent:`Monitor started.
|
|
6
|
+
id: ${r}
|
|
7
|
+
command: ${i}
|
|
8
|
+
description: ${h}
|
|
9
|
+
max_events: ${v}
|
|
10
|
+
idle_timeout: ${w}ms
|
|
11
|
+
Events will be delivered as notifications. The monitor auto-stops after ${v} events or ${w}ms of silence.
|
|
12
|
+
To inspect: /tasks (text) or the interactive Background tasks dialog (focus the footer Background tasks pill, then Enter \u2014 detail view + live updates).`,returnDisplay:`Monitor started: ${C} (${r})`}}},Tt=class c extends Y{constructor(t){super(c.Name,tt.MONITOR,`Starts a long-running shell command and streams its stdout/stderr as event notifications back to you.
|
|
13
|
+
|
|
14
|
+
Use this tool for:
|
|
15
|
+
- Watching log files: \`tail -f /var/log/app.log\`
|
|
16
|
+
- Monitoring build output: \`npm run build --watch\`
|
|
17
|
+
- Polling for state changes: \`while true; do curl -s http://localhost:8080/health; sleep 1; done\`
|
|
18
|
+
- Watching file changes: \`fswatch -r ./src\`
|
|
19
|
+
|
|
20
|
+
Each output line from the command becomes a notification event delivered to you. The monitor runs in the background \u2014 you can continue working while it streams events.
|
|
21
|
+
|
|
22
|
+
**Auto-stop:** The monitor automatically stops after max_events (default 1000) events or after idle_timeout_ms (default 5 minutes) of silence. The process is killed when the monitor stops.
|
|
23
|
+
|
|
24
|
+
**Do NOT use this tool for:**
|
|
25
|
+
- One-shot commands (use run_shell_command instead)
|
|
26
|
+
- Commands you need the full output from (use run_shell_command instead)
|
|
27
|
+
- Commands with no output (use run_shell_command with is_background: true instead)`,"execute",{type:"object",properties:{command:{type:"string",description:"Shell command to run and monitor. Each output line (stdout and stderr) becomes an event notification."},description:{type:"string",description:'Brief description of what this monitor watches (e.g., "webpack build output"). Truncated to 80 characters in display.'},max_events:{type:"number",description:"Stop the monitor after this many events. Default 1000. Max 10000."},idle_timeout_ms:{type:"number",description:"Stop the monitor if no output for this many milliseconds. Default 300000 (5 min). Max 600000."},directory:{type:"string",description:"(OPTIONAL) The absolute path of the directory to run the command in. If not provided, the project root directory is used. Must be within the workspace."}},required:["command"],additionalProperties:!1},!0,!1,!0,!1,"monitor watch tail log stream background");this.config=t}static Name=Q.MONITOR;validateToolParamValues(t){if(typeof t.command!="string"||!_(t.command).analysisCommand)return"Command cannot be empty.";if(nt(t.command))return'Monitor commands must not contain non-final top-level background operators. Remove "&" and let the monitor manage process lifetime.';if(t.max_events!==void 0){if(typeof t.max_events!="number"||!Number.isInteger(t.max_events)||t.max_events<=0)return"max_events must be a positive integer.";if(t.max_events>N)return`max_events cannot exceed ${N}.`}if(t.idle_timeout_ms!==void 0){if(typeof t.idle_timeout_ms!="number"||!Number.isInteger(t.idle_timeout_ms)||t.idle_timeout_ms<=0)return"idle_timeout_ms must be a positive integer.";if(t.idle_timeout_ms>U)return`idle_timeout_ms cannot exceed ${U}ms (10 minutes).`}if(t.directory){if(!ft.isAbsolute(t.directory))return"Directory must be an absolute path.";let n=ft.resolve(t.directory),i=this.config.storage.getUserSkillsDirs();if(K(i,n))return"Explicitly running monitor commands from within the user skills directory is not allowed. Please use absolute paths for command parameter instead.";if(!this.config.getWorkspaceContext().isPathWithinWorkspace(t.directory))return`Directory '${t.directory}' is not within any of the registered workspace directories.`}return null}createInvocation(t){return new B(this.config,t)}toAutoClassifierInput(t){let n={command:t.command};return t.directory&&(n.directory=t.directory),n}};export{Tt as MonitorTool,vt as sanitizeMonitorLine};
|
|
28
|
+
/**
|
|
29
|
+
* @license
|
|
30
|
+
* Copyright 2025 Matilda
|
|
31
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
32
|
+
*/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Force strict mode and setup for ESM
|
|
2
|
+
"use strict";
|
|
3
|
+
import{Nb as D,Ob as Y,Yb as y,dc as X,ec as Z,gb as Q,ya as R}from"./chunk-QNXNECWR.js";import"./chunk-HRCRNKY2.js";import"./chunk-ZSGBDQXU.js";import"./chunk-TXMXCR7D.js";import"./chunk-YULUB745.js";import"./chunk-DEN6RR3B.js";import"./chunk-RH3AEZWO.js";import"./chunk-UICLGQTV.js";import"./chunk-V2V3OF76.js";import"./chunk-GCMUSGTT.js";import"./chunk-SMTY6M3W.js";import"./chunk-QXSBPCBA.js";import"./chunk-ZABAV4XA.js";import"./chunk-V6UPUMP3.js";import"./chunk-5B2QERWR.js";import"./chunk-5JCW6FH6.js";import"./chunk-2LVAK6TV.js";import"./chunk-7ZODGQO6.js";import"./chunk-GT6MSEK4.js";import"./chunk-Y3SZK63U.js";import"./chunk-225CZWD7.js";import"./chunk-LBQNFSZ2.js";import"./chunk-DUB7JMQV.js";import{Db as H,l as B,m as k,n as U,o as K,p as q,q as b,r as W,s as j,t as C,u as J,v as V,w,x as M,xa as z,z as G}from"./chunk-CI5CVVGI.js";import"./chunk-IV6PS6DB.js";import"./chunk-6RK6IJY5.js";import"./chunk-LONWTJOE.js";import"./chunk-TKEFJ3O3.js";import"./chunk-7AEOFDY3.js";import"./chunk-XPVKH5TC.js";import{f as $,g as L,m as c,n as x}from"./chunk-KYNP66YS.js";import{C as _,D as N,F as T,Y as F}from"./chunk-AEYNMLMW.js";import"./chunk-UM6CLO7D.js";import"./chunk-HEJO7OBH.js";import{b as v}from"./chunk-GZPNIYVZ.js";import"./chunk-OWGSC52X.js";v();import*as E from"node:fs";import*as m from"node:path";var ee=F("NOTEBOOK_EDIT");function g(d,r,t){return ee.debug("prior-read-rejected",{path:d,reason:r,type:t.type,displayMessage:t.displayMessage}),t}var u=class extends Error{constructor(t,e){super(t);this.type=e;this.name="NotebookEditError"}};function te(d,r){if(r==="delete")return"";if(typeof d!="string")throw new u(`new_source is required when edit_mode is "${r}".`,"invalid_tool_params");return d}function I(d,r){return d?q(d,r):`cell-${r}`}function oe(d,r,t){if(!r){if(t==="insert")return-1;throw new u("cell_id is required for replace and delete operations.","invalid_tool_params")}if(W(d,r))throw new u(`Cell ID "${r}" is ambiguous in the rendered notebook. Re-read the notebook and target a stable real cell ID before editing.`,"invalid_tool_params");let e=j(d,r);if(e===-1)throw new u(`Cell with ID "${r}" not found in notebook.`,"notebook_cell_not_found");return e}function ie(d,r,t,e){let o={cell_type:r,metadata:{},source:w(t,e)},i=J(d);return i&&(o.id=i),M(o,r),o}function O(d,r){let t;try{t=k(d)}catch(a){throw new u(a instanceof Error?a.message:String(a),"notebook_invalid_json")}let e=r.edit_mode??"replace",o=te(r.new_source,e),i=b(t),n=oe(t,r.cell_id,e),l=C(t),p=U(d),s=(a,f)=>{let h=e==="insert"||e==="delete";return{...f,updatedContent:K(a,p),requiresReadAfterWrite:h&&!(i&&b(a))}};switch(e){case"insert":{let a=r.cell_type??"code",f=n===-1?0:n+1,h=ie(t,a,o,V(t,f));return t.cells.splice(f,0,h),s(t,{editedCellId:I(h,f),editedCellType:a,language:l,mode:e})}case"delete":{let[a]=t.cells.splice(n,1);return s(t,{editedCellId:I(a,n),editedCellType:a?.cell_type,language:l,mode:e})}case"replace":{let a=t.cells[n];if(!a)throw new u(`Cell index ${n} is out of range.`,"notebook_cell_not_found");let f=r.cell_type??a.cell_type;return a.source=w(o,Array.isArray(a.source)),M(a,f),s(t,{editedCellId:I(a,n),editedCellType:f,language:l,mode:e})}default:throw new u(`Unsupported notebook edit mode: ${e}`,"invalid_tool_params")}}function re(d,r,t){let e,o;try{e=k(r),o=k(d)}catch(i){throw new u(i instanceof Error?i.message:String(i),"notebook_invalid_json")}return{updatedContent:r,editedCellId:t.cell_id??"user-modified-notebook",editedCellType:void 0,language:C(e),mode:t.edit_mode??"replace",requiresReadAfterWrite:!b(o)||!b(e)}}async function A(d,r,t={}){if(d.getFileReadCacheDisabled())return{ok:!0};let e;try{e=await E.promises.stat(r)}catch(i){let n=i?.code;return n==="ENOENT"?t.expectExisting?g(r,"missing-after-read",{ok:!1,type:"file_changed_since_read",rawMessage:`Notebook ${r} disappeared after it was read. Re-read it with the ${c.READ_FILE} tool before editing it.`,displayMessage:`notebook disappeared after last read; re-run ${c.READ_FILE} first.`}):{ok:!0}:g(r,"stat-failed",{ok:!1,type:"prior_read_verification_failed",rawMessage:`Could not stat ${r} to verify prior notebook read (${n??"unknown error"}). Re-read it with the ${c.READ_FILE} tool before editing it.`,displayMessage:`cannot verify prior read of ${r}; re-run ${c.READ_FILE} before editing this notebook.`})}if(e.isDirectory())return g(r,"target-is-directory",{ok:!1,type:"target_is_directory",rawMessage:`${r} is a directory. The NotebookEdit tool only operates on .ipynb files.`,displayMessage:"path is a directory; cannot edit as a notebook."});if(!e.isFile())return g(r,"target-not-regular-file",{ok:!1,type:"target_not_regular_file",rawMessage:`${r} is not a regular file. The NotebookEdit tool only operates on .ipynb files.`,displayMessage:"special file; cannot edit as a notebook."});let o=d.getFileReadCache().check(e);return o.state==="fresh"&&o.entry.lastReadAt!==void 0&&o.entry.lastReadWasFull?{ok:!0}:o.state==="fresh"&&o.entry.lastReadAt!==void 0&&!o.entry.lastReadWasFull?g(r,"truncated-cache-entry",{ok:!1,type:"edit_requires_prior_read",rawMessage:`Notebook ${r} is too large for cell-level editing because its rendered output was truncated when read. Reduce the notebook output size or split the notebook before editing cells.`,displayMessage:"notebook too large for cell-level editing."}):o.state==="stale"?g(r,"stale-cache-entry",{ok:!1,type:"file_changed_since_read",rawMessage:`Notebook ${r} has been modified since you last read it. Re-read it with the ${c.READ_FILE} tool before editing it.`,displayMessage:`notebook changed since last read; re-run ${c.READ_FILE} first.`}):g(r,`cache-${o.state}`,{ok:!1,type:"edit_requires_prior_read",rawMessage:`Notebook ${r} has not been fully read in this session. Use the ${c.READ_FILE} tool first, without offset or limit, before editing cells.`,displayMessage:`${c.READ_FILE} required before editing this notebook.`})}var P=class extends ${constructor(t,e,o){super(e);this.config=t;this.modifyMetadata=o}toolLocations(){return[{path:this.params.notebook_path}]}getDescription(){let t=N(this.params.notebook_path,this.config.getTargetDir()),e=this.params.edit_mode??"replace",o=this.params.cell_id??"beginning";return`${e} notebook cell ${o} in ${_(t)}`}async getDefaultPermission(){return"ask"}async getConfirmationDetails(t){let e=await this.prepareEdit(t),o=m.basename(this.params.notebook_path),i=R(o,e.originalContent,e.updatedContent,"Current","Proposed",D);return{type:"edit",title:`Confirm Notebook Edit: ${_(N(this.params.notebook_path,this.config.getTargetDir()))}`,fileName:o,filePath:this.params.notebook_path,fileDiff:i,originalContent:e.originalContent,newContent:e.updatedContent,onConfirm:async l=>{l==="proceed_always"&&this.config.setApprovalMode("auto-edit")}}}async prepareEdit(t){let e=await A(this.config,this.params.notebook_path);if(!e.ok)throw new y(e.rawMessage,e.type);let o,i=!1,n,l="lf";try{let s=await this.config.getFileSystemService().readTextFile({path:this.params.notebook_path});o=s.content,i=s._meta?.bom??!1,n=s._meta?.encoding,l=s._meta?.lineEnding??X(s.content)}catch(s){throw t.aborted?s:s?.code==="ENOENT"?new y(`Notebook file not found: ${this.params.notebook_path}`,"file_not_found"):new y(`Error reading notebook: ${s instanceof Error?s.message:String(s)}`,"read_content_failure")}let p=await A(this.config,this.params.notebook_path,{expectExisting:!0});if(!p.ok)throw new y(p.rawMessage,p.type);try{return this.modifyMetadata?.modifiedNotebookContent!==void 0?{...re(o,this.modifyMetadata.modifiedNotebookContent,this.params),originalContent:o,bom:i,encoding:n,lineEnding:l}:{...O(o,this.params),originalContent:o,bom:i,encoding:n,lineEnding:l}}catch(s){throw s instanceof u?new y(s.message,s.type):s}}async execute(t){let e;try{e=await this.prepareEdit(t)}catch(o){if(t.aborted)throw o;let i=o instanceof y?o.errorType:"notebook_edit_failure",n=o instanceof Error?o.message:String(o);return{llmContent:n,returnDisplay:`Error: ${n}`,error:{message:n,type:i}}}try{try{await this.config.getFileHistoryService().trackEdit(this.params.notebook_path)}catch{}let o=await A(this.config,this.params.notebook_path,{expectExisting:!0});if(!o.ok)return{llmContent:o.rawMessage,returnDisplay:`Error: ${o.displayMessage}`,error:{message:o.rawMessage,type:o.type}};await this.config.getFileSystemService().writeTextFile({path:this.params.notebook_path,content:e.updatedContent,_meta:{bom:e.bom,encoding:e.encoding,lineEnding:e.lineEnding}}),this.modifyMetadata?.modifiedByUser||Q.getInstance().recordEdit(this.params.notebook_path,e.originalContent,e.updatedContent);try{let a=E.statSync(this.params.notebook_path),f=this.config.getFileReadCache();e.requiresReadAfterWrite?f.invalidate(a):f.recordWrite(this.params.notebook_path,a,{cacheable:!1})}catch(a){ee.warn(`[NotebookEdit] post-write cache update failed for ${this.params.notebook_path}: ${a instanceof Error?a.message:String(a)}`)}let i=m.basename(this.params.notebook_path),n=R(i,e.originalContent,e.updatedContent,"Current","Proposed",D),l=Y(i,e.originalContent,this.modifyMetadata?.aiProposedContent??e.updatedContent,e.updatedContent);z(this.config,new H(S.Name,"update",e.updatedContent.split(`
|
|
4
|
+
`).length,G(this.params.notebook_path),".ipynb",e.language));let p={fileDiff:n,fileName:i,originalContent:e.originalContent,newContent:e.updatedContent,diffStat:l},s=this.modifyMetadata?.modifiedNotebookContent!==void 0?`Notebook ${this.params.notebook_path} has been updated. Notebook content was modified by the user before approval; the final saved notebook may differ from the original ${e.mode} cell ${e.editedCellId} proposal.`:`Notebook ${this.params.notebook_path} has been updated. ${e.mode} cell ${e.editedCellId}.${e.mode==="delete"?"":`
|
|
5
|
+
|
|
6
|
+
Updated source:
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
${B(this.params.new_source??"")}`}`;try{let a=await Z(this.config,this.params.notebook_path);a&&(s+=`
|
|
11
|
+
|
|
12
|
+
${a}`)}catch{}return{llmContent:s,returnDisplay:p,resultFilePaths:[this.params.notebook_path]}}catch(o){let i=o instanceof Error?o.message:String(o);return{llmContent:`Error writing notebook: ${i}`,returnDisplay:`Error writing notebook: ${i}`,error:{message:i,type:"file_write_failure"}}}}},S=class d extends L{constructor(t){super(d.Name,x.NOTEBOOK_EDIT,`Edits a Jupyter notebook (.ipynb) safely at the cell level. Use this instead of ${c.EDIT} or ${c.WRITE_FILE} for notebook cells. Supports replacing, inserting, and deleting cells. Always read the notebook first with ${c.READ_FILE}; then use the cell IDs shown in that output.`,"edit",{properties:{notebook_path:{description:"Absolute path to the Jupyter notebook file to edit. Must end with .ipynb.",type:"string"},cell_id:{description:"Target cell ID from read_file output, or cell-N 0-based fallback. Required for replace and delete. For insert, the new cell is inserted after this cell; if omitted, inserted at the beginning.",type:"string"},new_source:{description:"New source content for replace and insert operations. Not required for delete.",type:"string"},cell_type:{description:"Cell type for inserted cells or type conversion on replace.",type:"string",enum:["code","markdown"]},edit_mode:{description:"Notebook edit operation. Defaults to replace.",type:"string",enum:["replace","insert","delete"]}},required:["notebook_path"],additionalProperties:!1,type:"object"});this.config=t}static Name=c.NOTEBOOK_EDIT;modifyMetadataByParams=new WeakMap;modifyMetadataByKey=new Map;validateToolParamValues(t){if(t.notebook_path=T(t.notebook_path.trim()),!t.notebook_path)return"The 'notebook_path' parameter must be non-empty.";if(!m.isAbsolute(t.notebook_path))return`Notebook path must be absolute: ${t.notebook_path}`;if(m.extname(t.notebook_path).toLowerCase()!==".ipynb")return"File must be a Jupyter notebook (.ipynb). Use the edit tool for other file types.";let e=t.edit_mode??"replace";return["replace","insert","delete"].includes(e)?t.cell_type&&!["code","markdown"].includes(t.cell_type)?"cell_type must be 'code' or 'markdown'.":e!=="insert"&&!t.cell_id?"cell_id is required for replace and delete operations.":e!=="delete"&&typeof t.new_source!="string"?`new_source is required when edit_mode is "${e}".`:this.config.getFileService().shouldMatildaIgnoreFile(t.notebook_path)?`File path '${t.notebook_path}' is ignored by .matildaignore pattern(s).`:null:"edit_mode must be 'replace', 'insert', or 'delete'."}createInvocation(t){return new P(this.config,t,this.consumeModifyMetadata(t))}getModifyMetadataKey(t){return JSON.stringify({notebook_path:T(t.notebook_path.trim()),cell_id:t.cell_id,new_source:t.new_source,cell_type:t.cell_type,edit_mode:t.edit_mode})}rememberModifyMetadata(t,e){this.modifyMetadataByParams.set(t,e);let o=this.getModifyMetadataKey(t),i=this.modifyMetadataByKey.get(o)??[];i.push(e),this.modifyMetadataByKey.set(o,i)}consumeModifyMetadata(t){let e=this.modifyMetadataByParams.get(t);if(e)return this.modifyMetadataByParams.delete(t),this.removeQueuedModifyMetadata(t,e),e;let o=this.getModifyMetadataKey(t),i=this.modifyMetadataByKey.get(o),n=i?.shift();return i&&i.length===0&&this.modifyMetadataByKey.delete(o),n}removeQueuedModifyMetadata(t,e){let o=this.getModifyMetadataKey(t),i=this.modifyMetadataByKey.get(o);if(!i)return;let n=i.indexOf(e);n!==-1&&i.splice(n,1),i.length===0&&this.modifyMetadataByKey.delete(o)}getModifyContext(t){let e=new Map,o=async i=>{let n=e.get(i.notebook_path);if(n!==void 0)return n;let{content:l}=await this.config.getFileSystemService().readTextFile({path:i.notebook_path});return e.set(i.notebook_path,l),l};return{getFilePath:i=>i.notebook_path,getCurrentContent:async i=>o(i),getProposedContent:async i=>{let n=await o(i);return O(n,i).updatedContent},createUpdatedParams:(i,n,l)=>{let p=this.modifyMetadataByParams.get(l)?.aiProposedContent;if(p===void 0)try{p=O(i,l).updatedContent}catch{p=n}let s={...l};return this.rememberModifyMetadata(s,{aiProposedContent:p,modifiedByUser:!0,modifiedNotebookContent:n}),s}}}};export{S as NotebookEditTool,O as applyNotebookEdit};
|
|
13
|
+
/**
|
|
14
|
+
* @license
|
|
15
|
+
* Copyright 2026 Matilda Team
|
|
16
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
*/
|