@opensumi/cli-engine 3.9.1-next-1747897586.0 → 3.9.1-next-1747965564.0

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.
@@ -31738,7 +31738,7 @@ ${(c=L.applyResult)===null||c===void 0?void 0:c.diff}
31738
31738
  `)[0])))]};t.EditFileToolComponent=d},95292:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ListDirToolComponent=t.GrepSearchToolComponent=t.FileSearchToolComponent=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(80564),a=e(41869),p=e(54414),v=e(51500),m=e(19413),_=n.__importDefault(e(51601)),s=({args:u,toolCallId:d,messageId:E})=>r.default.createElement(h,{args:u,toolCallId:d,messageId:E,toolName:"fileSearch",headerText:`Searched files "${u.query}"`});t.FileSearchToolComponent=s;const g=({args:u,toolCallId:d,messageId:E})=>r.default.createElement(h,{args:u,toolCallId:d,messageId:E,toolName:"grepSearch",headerText:`Grepped codebase "${u.query}"`});t.GrepSearchToolComponent=g;const l=({args:u,toolCallId:d,messageId:E})=>r.default.createElement(h,{args:u,toolCallId:d,messageId:E,toolName:"listDir",headerText:`Listed directory "${u.relative_workspace_path}"`});t.ListDirToolComponent=l;const h=({args:u,toolCallId:d,toolName:E,messageId:f,headerText:c})=>{const[y,b]=(0,r.useState)(!1),A=(0,a.useInjectable)(a.LabelService),S=(0,a.useInjectable)(p.WorkbenchEditorService),D=(0,a.useInjectable)(v.IWorkspaceService),I=(0,a.useInjectable)(a.CommandService),w=(0,r.useMemo)(()=>{var k,F;return a.URI.parse((F=(k=D.tryGetRoots())===null||k===void 0?void 0:k[0])===null||F===void 0?void 0:F.uri)},[]),T=(0,a.useInjectable)(m.IChatInternalService),[R,P]=(0,r.useState)([]);(0,r.useEffect)(()=>{const k=T.sessionModel.history.onMessageAdditionalChange(F=>{F[d]&&P(F[d].files||[])});return()=>{k.dispose()}},[]);const O=async k=>{if(!k.isDirectory)S.open(a.URI.parse(k.uri));else{const F=a.URI.parse(k.uri);I.executeCommand("filetree.location",F)}},M=(0,r.useMemo)(()=>R.map(k=>{const F=a.URI.parse(k.uri);return{iconClass:A.getIcon(F,{isDirectory:k.isDirectory}),name:F.path.base,path:a.path.relative(w.codeUri.fsPath,F.path.dir.toString()),uri:k.uri,isDirectory:k.isDirectory}}),[R]);return r.default.createElement("div",{className:_.default.container},r.default.createElement("div",{className:_.default.header,onClick:()=>b(!y)},r.default.createElement("span",{style:{transform:`rotate(${y?"90deg":"0deg"})`,display:"flex"}},r.default.createElement(o.Icon,{iconClass:"codicon codicon-chevron-right"})),r.default.createElement("span",null,c," \xB7 ",R.length," files")),y&&r.default.createElement("ul",{className:_.default.fileList},M.map((k,F)=>r.default.createElement("li",{key:F,className:_.default.fileItem,onClick:()=>O({uri:k.uri,isDirectory:k.isDirectory})},r.default.createElement("span",{className:k.iconClass}),r.default.createElement("span",{style:{flex:1}},k.name),r.default.createElement("span",{className:_.default.filePath},k.path)))))}},24706:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.TerminalToolComponent=void 0;const n=e(85608),r=n.__importStar(e(14041)),o=e(41869),a=e(81878),p=e(52141),v=e(89897),m=e(43718),_=e(71990),s=e(83854),g=e(22559),l=e(62471),h=n.__importDefault(e(51601));function u(f){const c={};try{const y=JSON.parse(f);return y.isError&&(c.isError=y.isError),y.content&&(c.text=y.content.map(b=>b.text).join(`
31739
31739
  `)),c}catch{return null}}const d={[s.ETerminalAutoExecutionPolicy.always]:"ai.native.terminal.autorun.always",[s.ETerminalAutoExecutionPolicy.auto]:"ai.native.terminal.autorun.auto",[s.ETerminalAutoExecutionPolicy.off]:"ai.native.terminal.autorun.off"};function E(f){return(0,m.localize)(d[f])}t.TerminalToolComponent=(0,r.memo)(f=>{const{args:c,toolCallId:y}=f,b=(0,o.useInjectable)(g.RunCommandHandler),A=(0,o.useInjectable)(o.PreferenceService),S=(0,o.useInjectable)(m.CommandService),[D,I]=(0,r.useState)(!1),w=A.get(_.AINativeSettingSectionsId.TerminalAutoRun),T=(0,r.useMemo)(()=>{var M;return!!(w===s.ETerminalAutoExecutionPolicy.off||w===s.ETerminalAutoExecutionPolicy.auto&&(!((M=f.args)===null||M===void 0)&&M.require_user_approval))},[f.args]);(0,r.useEffect)(()=>{f.state==="result"?I(!1):T||I(!0)},[f]);const R=(0,r.useCallback)(()=>{S.executeCommand("workbench.action.openSettings","ai.native.terminal.autorun")},[]),P=(0,r.useCallback)(M=>{y&&(b.handleApproval(y,M),I(!0))},[]),O=(0,r.useMemo)(()=>f.result?u(f.result):null,[f]);return r.default.createElement("div",{className:h.default.run_cmd_tool},r.default.createElement("div",null,r.default.createElement("div",{className:h.default.command_title},r.default.createElement(a.Icon,{icon:"terminal"}),r.default.createElement("span",null,T?(0,m.localize)("ai.native.mcp.terminal.allow-question"):(0,m.localize)("ai.native.mcp.terminal.command"))),r.default.createElement("p",{className:h.default.command_content},r.default.createElement("code",null,"$ ",c?.command)),r.default.createElement("p",{className:h.default.comand_description},c?.explanation),f.state==="complete"&&T&&c&&!D&&r.default.createElement("div",{className:h.default.cmmand_footer},r.default.createElement(a.Button,{type:"link",size:"small",onClick:()=>P(!0)},(0,m.localize)("ai.native.mcp.terminal.allow")),r.default.createElement(a.Button,{type:"link",size:"small",onClick:()=>P(!1)},(0,m.localize)("ai.native.mcp.terminal.deny"))),f.state==="result"&&O&&r.default.createElement(r.default.Fragment,null,r.default.createElement("div",{className:h.default.command_content},r.default.createElement(a.Icon,{icon:"output"}),r.default.createElement("code",{dangerouslySetInnerHTML:{__html:(0,l.computeAnsiLogString)(O.text||"")}})),r.default.createElement("div",{className:h.default.auto_execution_policy},r.default.createElement("span",{className:h.default.auto_execution_policy_label},E(w||s.ETerminalAutoExecutionPolicy.auto)),r.default.createElement(p.EnhancePopover,{id:"policy-config-popover",title:(0,m.localize)("ai.native.terminal.autorun.command")},r.default.createElement(a.Icon,{size:"small",iconClass:"codicon codicon-settings-gear",onClick:R}))))),D&&r.default.createElement("div",{className:h.default.running},r.default.createElement(v.Loading,null),r.default.createElement("span",null,(0,m.localize)("ai.native.terminal.autorun.running"))))})},62471:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.computeAnsiLogString=p;const n=e(85608),r=n.__importDefault(e(30002)),o=n.__importDefault(e(39718)),a=new r.default;function p(v,m=!0,_=!1){const s=v.split(`
31740
31740
  `);let g=m?(0,o.default)(s):s;return _&&(g=g.map(h=>h.replace("\r","")).filter(h=>!!h)),g.map(h=>a.ansi_to_html(h)).join(`
31741
- `)}},39718:(x,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cursorUp=t.eraseEndLine=t.eraseLine=t.ESC=void 0,t.default=n,t.ESC="\x1B[",t.eraseLine=t.ESC+"2K",t.eraseEndLine=t.ESC+"K";const e=(r=1)=>t.ESC+r+"A";t.cursorUp=e;function n(r){const o=(0,t.cursorUp)(1)+t.eraseLine,a=t.eraseLine,p=`\r${t.eraseEndLine}`,v=["\\r","\\u001b\\[G","\\u001b\\[1G"],m=new RegExp(`${v.join("|")}`);return r.reduce((s,g)=>{let l=0;const h=o.length;for(;l=g.indexOf(o,l),l>=0;)l+=h,s.pop();let u=g.lastIndexOf(a);u<0&&(u=g.lastIndexOf(p)),u>0&&(g=g.slice(u));const d=g.split(m).filter(E=>!!E);return d.length>1&&(g=d.reduce((E,f)=>{const c=E.slice(f.length);return f+c},"")),s.push(g),s},[])}},7228:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateNewFileWithTextTool=void 0;const n=e(85608),r=e(75995),o=e(76003),a=e(43718),p=e(14951),v=e(51500),m=e(77633),_=e(73974),s=e(58260),g=r.z.object({target_file:r.z.string().describe("The relative path where the file should be created"),code_edit:r.z.string().describe("The content to write into the new file")}).transform(h=>({targetFile:h.target_file,codeEdit:h.code_edit}));let l=class{registerMCPServer(u){u.registerMCPTool(this.getToolDefinition()),u.registerToolComponent("create_new_file_with_text",s.EditFileToolComponent)}getToolDefinition(){return{name:"create_new_file_with_text",label:"Create File",order:7,description:`Creates a new file at the specified path within the project directory and populates it with the provided text. Use this tool to generate new files in your project structure. Returns one of two possible responses: "ok" if the file was successfully created and populated, "can't find project dir" if the project directory cannot be determined. Note: This tool creates any necessary parent directories automatically.`,inputSchema:g,handler:this.handler.bind(this)}}async handler(u,d){try{const E=this.workspaceService.tryGetRoots();if(!E||E.length===0)return d.appendLine("Error: Cannot determine project directory"),{content:[{type:"text",text:"can't find project dir"}],isError:!0};const f=a.URI.parse(E[0].uri),c=a.path.join(f.codeUri.fsPath,u.targetFile),y=a.URI.file(c),b=a.path.dirname(c),A=a.URI.file(b);await this.fileService.createFolder(A.toString()),await this.fileService.createFile(y.toString());const S=await this.applyService.registerCodeBlock(u.targetFile,u.codeEdit,u.toolCallId);return await this.applyService.apply(S),d.appendLine(`Successfully created file at: ${u.targetFile}`),{content:[{type:"text",text:"ok"}]}}catch(E){return d.appendLine(`Error during file creation: ${E}`),{content:[{type:"text",text:E.message}],isError:!0}}}};t.CreateNewFileWithTextTool=l,n.__decorate([(0,o.Autowired)(v.IWorkspaceService),n.__metadata("design:type",Object)],l.prototype,"workspaceService",void 0),n.__decorate([(0,o.Autowired)(p.IFileServiceClient),n.__metadata("design:type",Object)],l.prototype,"fileService",void 0),n.__decorate([(0,o.Autowired)(_.BaseApplyService),n.__metadata("design:type",_.BaseApplyService)],l.prototype,"applyService",void 0),t.CreateNewFileWithTextTool=l=n.__decorate([(0,a.Domain)(m.MCPServerContribution)],l)},90977:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditFileTool=void 0;const n=e(85608),r=e(75995),o=e(76003),a=e(43718),p=e(77633),v=e(58260),m=e(9343),_=r.z.object({target_file:r.z.string().describe("The target file to modify. Always specify the target file as the first argument and use the relative path in the workspace of the file to edit"),instructions:r.z.string().optional().describe("A single sentence instruction describing what you are going to do for the sketched edit. This is used to assist the less intelligent model in applying the edit. Please use the first person to describe what you are going to do. Dont repeat what you have said previously in normal messages. And use it to disambiguate uncertainty in the edit."),code_edit:r.z.string().describe("Specify ONLY the precise lines of code that you wish to edit. **NEVER specify or write out unchanged code**. Instead, represent all unchanged code using the comment of the language you're editing in - example: `// ... existing code ...`")}).transform(g=>({targetFile:g.target_file,instructions:g.instructions,codeEdit:g.code_edit}));let s=class{registerMCPServer(l){l.registerMCPTool(this.getToolDefinition()),l.registerToolComponent("edit_file",v.EditFileToolComponent)}getToolDefinition(){return{name:"edit_file",label:"Edit File",order:5,description:`Use this tool to propose an edit to an existing file.
31741
+ `)}},39718:(x,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cursorUp=t.eraseEndLine=t.eraseLine=t.ESC=void 0,t.default=n,t.ESC="\x1B[",t.eraseLine=t.ESC+"2K",t.eraseEndLine=t.ESC+"K";const e=(r=1)=>t.ESC+r+"A";t.cursorUp=e;function n(r){const o=(0,t.cursorUp)(1)+t.eraseLine,a=t.eraseLine,p=`\r${t.eraseEndLine}`,v=["\\r","\\u001b\\[G","\\u001b\\[1G"],m=new RegExp(`${v.join("|")}`);return r.reduce((s,g)=>{let l=0;const h=o.length;for(;l=g.indexOf(o,l),l>=0;)l+=h,s.pop();let u=g.lastIndexOf(a);u<0&&(u=g.lastIndexOf(p)),u>0&&(g=g.slice(u));const d=g.split(m).filter(E=>!!E);return d.length>1&&(g=d.reduce((E,f)=>{const c=E.slice(f.length);return f+c},"")),s.push(g),s},[])}},7228:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateNewFileWithTextTool=void 0;const n=e(85608),r=e(75995),o=e(76003),a=e(43718),p=e(77633),v=e(58260),m=e(79346),_=r.z.object({target_file:r.z.string().describe("The relative path where the file should be created"),code_edit:r.z.string().describe("The content to write into the new file")}).transform(g=>({targetFile:g.target_file,codeEdit:g.code_edit}));let s=class{registerMCPServer(l){l.registerMCPTool(this.getToolDefinition()),l.registerToolComponent("create_new_file_with_text",v.EditFileToolComponent)}getToolDefinition(){return{name:"create_new_file_with_text",label:"Create File",order:7,description:`Creates a new file at the specified path within the project directory and populates it with the provided text. Use this tool to generate new files in your project structure. Returns one of two possible responses: "ok" if the file was successfully created and populated, "can't find project dir" if the project directory cannot be determined. Note: This tool creates any necessary parent directories automatically.`,inputSchema:_,handler:this.handler.bind(this)}}async handler(l,h){try{return await this.createNewFileWithTextHandler.handler(l,l.toolCallId,h),{content:[{type:"text",text:"create file with text success"}]}}catch(u){return{content:[{type:"text",text:u.message}],isError:!0}}}};t.CreateNewFileWithTextTool=s,n.__decorate([(0,o.Autowired)(m.CreateNewFileWithTextHandler),n.__metadata("design:type",m.CreateNewFileWithTextHandler)],s.prototype,"createNewFileWithTextHandler",void 0),t.CreateNewFileWithTextTool=s=n.__decorate([(0,a.Domain)(p.MCPServerContribution)],s)},90977:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditFileTool=void 0;const n=e(85608),r=e(75995),o=e(76003),a=e(43718),p=e(77633),v=e(58260),m=e(9343),_=r.z.object({target_file:r.z.string().describe("The target file to modify. Always specify the target file as the first argument and use the relative path in the workspace of the file to edit"),instructions:r.z.string().optional().describe("A single sentence instruction describing what you are going to do for the sketched edit. This is used to assist the less intelligent model in applying the edit. Please use the first person to describe what you are going to do. Dont repeat what you have said previously in normal messages. And use it to disambiguate uncertainty in the edit."),code_edit:r.z.string().describe("Specify ONLY the precise lines of code that you wish to edit. **NEVER specify or write out unchanged code**. Instead, represent all unchanged code using the comment of the language you're editing in - example: `// ... existing code ...`")}).transform(g=>({targetFile:g.target_file,instructions:g.instructions,codeEdit:g.code_edit}));let s=class{registerMCPServer(l){l.registerMCPTool(this.getToolDefinition()),l.registerToolComponent("edit_file",v.EditFileToolComponent)}getToolDefinition(){return{name:"edit_file",label:"Edit File",order:5,description:`Use this tool to propose an edit to an existing file.
31742
31742
  This will be read by a less intelligent model, which will quickly apply the edit. You should make it clear what the edit is, while also minimizing the unchanged code you write.
31743
31743
  When writing the edit, you should specify each edit in sequence, with the special comment \`// ... existing code ...\` to represent unchanged code in between edited lines.
31744
31744
  For example:
@@ -31778,7 +31778,7 @@ ${k.reduce((F,L)=>F.find(B=>B.line===L.line)?F:[...F,L],[]).map(F=>`Line: ${F.li
31778
31778
  Content: ${F.lineText||F.renderLineText}`).join(`
31779
31779
  `)}`),R.push({uri:M,isDirectory:!1});D.resolve(T.join(`
31780
31780
 
31781
- `));const P=this.chatInternalService.sessionModel.history.getMessages(),O=(w=P[P.length-1])===null||w===void 0?void 0:w.id;O&&this.chatInternalService.sessionModel.history.setMessageAdditional(O,{[f.toolCallId]:{files:R}})}),{content:[{type:"text",text:await D.promise}]}}};t.GrepSearchTool=d,n.__decorate([(0,o.Autowired)(m.IWorkspaceService),n.__metadata("design:type",Object)],d.prototype,"workspaceService",void 0),n.__decorate([(0,o.Autowired)(p.IContentSearchClientService),n.__metadata("design:type",v.ContentSearchClientService)],d.prototype,"searchService",void 0),n.__decorate([(0,o.Autowired)(_.IChatInternalService),n.__metadata("design:type",s.ChatInternalService)],d.prototype,"chatInternalService",void 0),t.GrepSearchTool=d=n.__decorate([(0,a.Domain)(g.MCPServerContribution)],d)},9343:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditFileHandler=void 0;const n=e(85608),r=e(76003),o=e(73974);let a=class{async handler(v,m){const{targetFile:_,codeEdit:s,instructions:g}=v,l=await this.applyService.registerCodeBlock(_,s,m,g);return await this.applyService.apply(l)}};t.EditFileHandler=a,n.__decorate([(0,r.Autowired)(o.BaseApplyService),n.__metadata("design:type",o.BaseApplyService)],a.prototype,"applyService",void 0),t.EditFileHandler=a=n.__decorate([(0,r.Injectable)()],a)},64942:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ListDirHandler=void 0;const n=e(85608),r=e(76003),o=e(41869),a=e(14951);class p{constructor(_){this.maxConcurrent=_,this.currentCount=0,this.pendingQueue=[]}async execute(_){this.currentCount>=this.maxConcurrent&&await new Promise(s=>this.pendingQueue.push(s)),this.currentCount++;try{return await _()}finally{if(this.currentCount--,this.pendingQueue.length>0){const s=this.pendingQueue.shift();s?.()}}}}let v=class{constructor(){this.MAX_FILE_SIZE=1024*1024,this.MAX_INDEXED_FILES=50}getWorkspaceDir(){return this.appConfig.workspaceDir}async handler(_){var s,g;const{relativeWorkspacePath:l}=_;if(!l)throw new Error("No list dir parameters provided. Need to give at least the path.");const h=o.path.join(this.appConfig.workspaceDir,l),u=await this.fileSystemService.getFileStat(h,!0);if(!u||!u.isDirectory)throw new Error(`Could not find file ${l} in the workspace.`);const d=((s=u.children)===null||s===void 0?void 0:s.filter(y=>!y.isDirectory&&y.size!==void 0&&y.size<=this.MAX_FILE_SIZE).slice(0,this.MAX_INDEXED_FILES))||[],E=new Set(d.map(y=>new o.URI(y.uri).displayName)),f=new p(4);return{files:await Promise.all(((g=u.children)===null||g===void 0?void 0:g.sort((y,b)=>b.lastModification-y.lastModification).map(async y=>{var b;const A=new o.URI(y.uri),S=`${h}/${A.displayName}`;let D;return E.has(A.displayName)&&(D=await f.execute(async()=>this.countFileLines(S))),{name:A.displayName,isDirectory:y.isDirectory,size:y.size,lastModified:y.lastModification,numChildren:(b=y.children)===null||b===void 0?void 0:b.length,numLines:D}}))||[]),directoryRelativeWorkspacePath:l}}async countFileLines(_){return(await this.fileSystemService.readFile(o.URI.file(_).toString())).toString().split(`
31781
+ `));const P=this.chatInternalService.sessionModel.history.getMessages(),O=(w=P[P.length-1])===null||w===void 0?void 0:w.id;O&&this.chatInternalService.sessionModel.history.setMessageAdditional(O,{[f.toolCallId]:{files:R}})}),{content:[{type:"text",text:await D.promise}]}}};t.GrepSearchTool=d,n.__decorate([(0,o.Autowired)(m.IWorkspaceService),n.__metadata("design:type",Object)],d.prototype,"workspaceService",void 0),n.__decorate([(0,o.Autowired)(p.IContentSearchClientService),n.__metadata("design:type",v.ContentSearchClientService)],d.prototype,"searchService",void 0),n.__decorate([(0,o.Autowired)(_.IChatInternalService),n.__metadata("design:type",s.ChatInternalService)],d.prototype,"chatInternalService",void 0),t.GrepSearchTool=d=n.__decorate([(0,a.Domain)(g.MCPServerContribution)],d)},79346:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateNewFileWithTextHandler=void 0;const n=e(85608),r=e(76003),o=e(43718),a=e(14951),p=e(51500),v=e(73974);let m=class{async handler(s,g,l){const h=this.workspaceService.tryGetRoots();if(!h||h.length===0)throw l.appendLine("Error: Cannot determine project directory"),new Error("can't find project dir");const u=o.URI.parse(h[0].uri),d=o.path.join(u.codeUri.fsPath,s.targetFile),E=o.URI.file(d),f=o.path.dirname(d),c=o.URI.file(f);await this.fileService.createFolder(c.toString()),await this.fileService.createFile(E.toString());const y=await this.applyService.registerCodeBlock(s.targetFile,s.codeEdit,g);await this.applyService.apply(y),l.appendLine(`Successfully created file at: ${s.targetFile}`)}};t.CreateNewFileWithTextHandler=m,n.__decorate([(0,r.Autowired)(p.IWorkspaceService),n.__metadata("design:type",Object)],m.prototype,"workspaceService",void 0),n.__decorate([(0,r.Autowired)(a.IFileServiceClient),n.__metadata("design:type",Object)],m.prototype,"fileService",void 0),n.__decorate([(0,r.Autowired)(v.BaseApplyService),n.__metadata("design:type",v.BaseApplyService)],m.prototype,"applyService",void 0),t.CreateNewFileWithTextHandler=m=n.__decorate([(0,r.Injectable)()],m)},9343:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EditFileHandler=void 0;const n=e(85608),r=e(76003),o=e(73974);let a=class{async handler(v,m){const{targetFile:_,codeEdit:s,instructions:g}=v,l=await this.applyService.registerCodeBlock(_,s,m,g);return await this.applyService.apply(l)}};t.EditFileHandler=a,n.__decorate([(0,r.Autowired)(o.BaseApplyService),n.__metadata("design:type",o.BaseApplyService)],a.prototype,"applyService",void 0),t.EditFileHandler=a=n.__decorate([(0,r.Injectable)()],a)},64942:(x,t,e)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ListDirHandler=void 0;const n=e(85608),r=e(76003),o=e(41869),a=e(14951);class p{constructor(_){this.maxConcurrent=_,this.currentCount=0,this.pendingQueue=[]}async execute(_){this.currentCount>=this.maxConcurrent&&await new Promise(s=>this.pendingQueue.push(s)),this.currentCount++;try{return await _()}finally{if(this.currentCount--,this.pendingQueue.length>0){const s=this.pendingQueue.shift();s?.()}}}}let v=class{constructor(){this.MAX_FILE_SIZE=1024*1024,this.MAX_INDEXED_FILES=50}getWorkspaceDir(){return this.appConfig.workspaceDir}async handler(_){var s,g;const{relativeWorkspacePath:l}=_;if(!l)throw new Error("No list dir parameters provided. Need to give at least the path.");const h=o.path.join(this.appConfig.workspaceDir,l),u=await this.fileSystemService.getFileStat(h,!0);if(!u||!u.isDirectory)throw new Error(`Could not find file ${l} in the workspace.`);const d=((s=u.children)===null||s===void 0?void 0:s.filter(y=>!y.isDirectory&&y.size!==void 0&&y.size<=this.MAX_FILE_SIZE).slice(0,this.MAX_INDEXED_FILES))||[],E=new Set(d.map(y=>new o.URI(y.uri).displayName)),f=new p(4);return{files:await Promise.all(((g=u.children)===null||g===void 0?void 0:g.sort((y,b)=>b.lastModification-y.lastModification).map(async y=>{var b;const A=new o.URI(y.uri),S=`${h}/${A.displayName}`;let D;return E.has(A.displayName)&&(D=await f.execute(async()=>this.countFileLines(S))),{name:A.displayName,isDirectory:y.isDirectory,size:y.size,lastModified:y.lastModification,numChildren:(b=y.children)===null||b===void 0?void 0:b.length,numLines:D}}))||[]),directoryRelativeWorkspacePath:l}}async countFileLines(_){return(await this.fileSystemService.readFile(o.URI.file(_).toString())).toString().split(`
31782
31782
  `).length}};t.ListDirHandler=v,n.__decorate([(0,r.Autowired)(o.AppConfig),n.__metadata("design:type",Object)],v.prototype,"appConfig",void 0),n.__decorate([(0,r.Autowired)(a.IFileServiceClient),n.__metadata("design:type",Object)],v.prototype,"fileSystemService",void 0),t.ListDirHandler=v=n.__decorate([(0,r.Injectable)()],v)},707:(x,t,e)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.FileHandler=void 0;const r=e(85608),o=e(76003),a=e(79240),p=e(41869),v=e(43718),m=e(57517),_=e(14951);let s=n=class{constructor(){this.fileResultMap=new Map}async findSimilarFiles(l,h){return(await this.fileSearchQuickCommandHandler.getQueryFiles(l,new Set,v.CancellationToken.None)).slice(0,h).map(d=>{var E;return(E=d.getUri())===null||E===void 0?void 0:E.codeUri.fsPath}).filter(Boolean)}createFileNotFoundError(l,h){const u=h.length>0?`Could not find file '${l}'. Did you mean one of:
31783
31783
  ${h.map(d=>`- ${d}`).join(`
31784
31784
  `)}`:`Could not find file '${l}' in the workspace.`;return new Error(JSON.stringify({clientVisibleErrorMessage:u,modelVisibleErrorMessage:u,actualErrorMessage:`File not found: ${l}`}))}createFileTooLargeError(l,h){return new Error(JSON.stringify({clientVisibleErrorMessage:`File is too large, >${l}MB`,modelVisibleErrorMessage:`The file is too large to read, was >${l}MB`,actualErrorMessage:`File is too large to read, was >${l}MB, size: ${h} bytes`}))}trimContent(l,h){return l.slice(0,h).split(n.NEWLINE).slice(0,-1).join(n.NEWLINE)}getLineRange(l,h){var u,d;let E=(u=l.startLineOneIndexed)!==null&&u!==void 0?u:1,f=(d=l.endLineOneIndexedInclusive)!==null&&d!==void 0?d:E+n.MAX_LINES-1,c=!1,y=!1;return h?{start:E,end:f,didShorten:c,didSetDefault:y}:(l.endLineOneIndexedInclusive===void 0||l.startLineOneIndexed===void 0?(E=1,f=n.MAX_LINES,y=!0):l.endLineOneIndexedInclusive-l.startLineOneIndexed>n.MAX_LINES&&(f=l.startLineOneIndexed+n.MAX_LINES,c=!0),{start:E,end:f,didShorten:c,didSetDefault:y})}async readFile(l){if(!l)throw new Error("No read file parameters provided. Need to give at least the path.");const h=new v.URI(v.path.join(this.appConfig.workspaceDir,l.relativeWorkspacePath));if(!h){const f=await this.findSimilarFiles(l.relativeWorkspacePath,3);throw this.createFileNotFoundError(l.relativeWorkspacePath,f)}const u=(n.MAX_FILE_SIZE_BYTES/1e6).toFixed(2),d=await this.fileSystemService.getFileStat(h.toString());if(d?.size&&d.size>n.MAX_FILE_SIZE_BYTES)throw this.createFileTooLargeError(u,d.size);let E;try{E=await this.modelService.createModelReference(h);const f=E.instance.getMonacoModel().getValue(),c=f.split(n.NEWLINE),y=!(l.readEntireFile&&l.fileIsAllowedToBeReadEntirely),b=l.readEntireFile&&!l.fileIsAllowedToBeReadEntirely;let A=!1;if(y){const{start:D,end:I,didShorten:w,didSetDefault:T}=this.getLineRange(l,b),R=Math.max(D,1),P=Math.min(I,c.length);let O=c.slice(R-1,P).join(n.NEWLINE);return O.length>n.MAX_CHARS&&(A=!0,O=this.trimContent(O,n.MAX_CHARS)),w&&this.fileResultMap.set(l.relativeWorkspacePath,{content:O,startLineOneIndexed:R,endLineOneIndexedInclusive:P}),{contents:O,didDowngradeToLineRange:b,didShortenLineRange:w,didShortenCharRange:A,didSetDefaultLineRange:T,fullFileContents:f,startLineOneIndexed:R,endLineOneIndexedInclusive:P,relativeWorkspacePath:l.relativeWorkspacePath}}let S=f;return S.length>n.MAX_CHARS&&(A=!0,S=this.trimContent(S,n.MAX_CHARS)),{contents:S,fullFileContents:f,didDowngradeToLineRange:!1,didShortenCharRange:A}}finally{E?.dispose()}}getFileReadResult(l){return this.fileResultMap.get(l)}};t.FileHandler=s,s.MAX_FILE_SIZE_BYTES=2e6,s.MAX_LINES=250,s.MAX_CHARS=1e5,s.NEWLINE=`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opensumi/cli-engine",
3
- "version": "3.9.1-next-1747897586.0",
3
+ "version": "3.9.1-next-1747965564.0",
4
4
  "description": "Integration engine runtime for opensumi-cli and opensumi extension",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -26,14 +26,14 @@
26
26
  "dependencies": {
27
27
  "@koa/cors": "^5.0.0",
28
28
  "@opensumi/di": "^1.8.0",
29
- "@opensumi/ide-core-browser": "3.9.1-next-1747897586.0",
30
- "@opensumi/ide-core-common": "3.9.1-next-1747897586.0",
31
- "@opensumi/ide-core-node": "3.9.1-next-1747897586.0",
32
- "@opensumi/ide-express-file-server": "3.9.1-next-1747897586.0",
33
- "@opensumi/ide-extension": "3.9.1-next-1747897586.0",
34
- "@opensumi/ide-i18n": "3.9.1-next-1747897586.0",
35
- "@opensumi/ide-main-layout": "3.9.1-next-1747897586.0",
36
- "@opensumi/ide-startup": "3.9.1-next-1747897586.0",
29
+ "@opensumi/ide-core-browser": "3.9.1-next-1747965564.0",
30
+ "@opensumi/ide-core-common": "3.9.1-next-1747965564.0",
31
+ "@opensumi/ide-core-node": "3.9.1-next-1747965564.0",
32
+ "@opensumi/ide-express-file-server": "3.9.1-next-1747965564.0",
33
+ "@opensumi/ide-extension": "3.9.1-next-1747965564.0",
34
+ "@opensumi/ide-i18n": "3.9.1-next-1747965564.0",
35
+ "@opensumi/ide-main-layout": "3.9.1-next-1747965564.0",
36
+ "@opensumi/ide-startup": "3.9.1-next-1747965564.0",
37
37
  "chalk": "^4.1.2",
38
38
  "ejs": "^3.1.7",
39
39
  "ip": "^1.1.8",
@@ -72,5 +72,5 @@
72
72
  "webpack": "^5.90.0",
73
73
  "webpack-cli": "^5.1.4"
74
74
  },
75
- "gitHead": "d9d184251a55864b66ad58cef0097d78eed4b4f7"
75
+ "gitHead": "530be4f4e7e75f2ba69374c600bf6292629838f2"
76
76
  }