@minimax-ai/code 0.4.7 → 0.4.9
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/CHANGELOG.md +43 -0
- package/CHANGELOG.zh-CN.md +31 -0
- package/README.md +16 -3
- package/README.zh-CN.md +24 -2
- package/assets/agents/_v2/explore.md.hbs +8 -0
- package/assets/agents/explore/agent.md +1 -0
- package/assets/agents/explore/system-prompt.md.hbs +9 -0
- package/assets/agents/mavis/features/delegation.md.hbs +4 -2
- package/chunks/{anthropic-LCJD7NOY.js → anthropic-MQQCIUHP.js} +1 -1
- package/chunks/{application-OZ6YEJNG.js → application-6MCV7ILB.js} +1 -1
- package/chunks/{auth-command-TP25VHV4.js → auth-command-T5DRRUNT.js} +1 -1
- package/chunks/{chunk-BNU46XHR.js → chunk-2CEKQTMO.js} +1 -1
- package/chunks/{chunk-RPO5CDCP.js → chunk-3V6OPTHM.js} +9 -9
- package/chunks/{chunk-YBZTB54I.js → chunk-AULSFRR7.js} +649 -646
- package/chunks/{chunk-2SW3R5AB.js → chunk-DV5WIEGS.js} +1 -1
- package/chunks/{chunk-SLRPB56L.js → chunk-HJ6CAPCI.js} +1 -1
- package/chunks/{chunk-SYLCIHHV.js → chunk-HMP2XYHW.js} +1 -1
- package/chunks/{chunk-OVLV6FQA.js → chunk-PMTJEVJF.js} +531 -531
- package/chunks/{chunk-W7JHDTPW.js → chunk-VCJI7AJO.js} +1 -1
- package/chunks/{chunk-C2OVBAOI.js → chunk-VOK3LP4U.js} +1 -1
- package/chunks/{chunk-QJWOGW27.js → chunk-VPHVKGPT.js} +1 -1
- package/chunks/{chunk-22LVIQ2T.js → chunk-WAVNKSSE.js} +1 -1
- package/chunks/{chunk-NELAOQAA.js → chunk-X5PAB4UH.js} +2 -2
- package/chunks/chunk-Z44TXDGK.js +50 -0
- package/chunks/{chunk-KVMK6REW.js → chunk-ZCP4JGO4.js} +1 -1
- package/chunks/{chunk-AJSGEEWR.js → chunk-ZRZKBTCU.js} +1 -1
- package/chunks/{data-dir-KTXCGPJZ.js → data-dir-YVQZ5MXP.js} +1 -1
- package/chunks/{dist-MM7GHB2J.js → dist-N5YYFCWT.js} +1 -1
- package/chunks/{dist-XS6VO2LU.js → dist-Z3PYNW6P.js} +1 -1
- package/chunks/{install-source-3CE52ZIN.js → install-source-GWYHWTTG.js} +1 -1
- package/chunks/{launcher-BNIFOBXD.js → launcher-BM4HRRYX.js} +141 -141
- package/chunks/{lifecycle-EKT5LQIE.js → lifecycle-4CWHNXF2.js} +1 -1
- package/chunks/{main-FAPYW7S4.js → main-CU2PB45W.js} +11 -11
- package/chunks/{plugin-command-TD3DWK7U.js → plugin-command-OU7V7644.js} +1 -1
- package/chunks/{provider-command-AQPDCWDR.js → provider-command-GGEFE5SP.js} +1 -1
- package/chunks/{run-acp-command-OPS4CBHL.js → run-acp-command-4J3QAQRK.js} +2 -2
- package/chunks/run-exec-command-KD5OCRTX.js +17 -0
- package/chunks/{update-KWS4AOND.js → update-CG3K6TMW.js} +1 -1
- package/cli.js +2 -2
- package/image-preview-worker.js +1 -1
- package/package.json +1 -1
- package/chunks/chunk-B2NJMA4I.js +0 -50
- package/chunks/run-exec-command-QR3TWWDO.js +0 -17
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
|
|
2
|
-
import{a,b}from"./chunk-
|
|
2
|
+
import{a,b}from"./chunk-AULSFRR7.js";import"./chunk-R6GVNV7J.js";import"./chunk-4ESEMCSG.js";import"./chunk-PMTJEVJF.js";import"./chunk-VPHVKGPT.js";import"./chunk-A2CQYOXE.js";import"./chunk-C3JRMX7L.js";import"./chunk-XYXCVIX2.js";import"./chunk-KCTHWRGJ.js";import"./chunk-PPIEC7ZM.js";import"./chunk-X4N2MWNJ.js";import"./chunk-75PL5LYJ.js";import"./chunk-SHXPTUWI.js";import"./chunk-4Y64C4JT.js";import"./chunk-X5PAB4UH.js";import"./chunk-AABEG2OJ.js";import"./chunk-SD6SJL3L.js";import"./chunk-PWQHCWDV.js";import"./chunk-HQ2U4QVQ.js";import"./chunk-WAVNKSSE.js";import"./chunk-DV5WIEGS.js";import"./chunk-ZITT4GJK.js";import"./chunk-2ZG44JU6.js";import"./chunk-Z44TXDGK.js";import"./chunk-CWWDVX6C.js";import"./chunk-IIHJNKC3.js";import"./chunk-3V6OPTHM.js";import"./chunk-LOQ4VVEN.js";import"./chunk-2UWBSJDH.js";import"./chunk-GUFBGYOC.js";import"./chunk-CK62QLTS.js";import"./chunk-WFWSBUYD.js";import"./chunk-D76SO2ME.js";export{a as createTuiRuntime,b as shutdownTuiRuntime};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
|
|
2
|
-
import{a as Z,b as ee,c as w,d as te,f as re}from"./chunk-U62SRHG3.js";import{a as M,b as ne}from"./chunk-I3GV76MP.js";import{c as ie}from"./chunk-A2CQYOXE.js";import{a as Q}from"./chunk-O6RIRKRN.js";import{o as X,q as Y}from"./chunk-
|
|
3
|
-
`).replace(/^/gm," ".repeat(r))}let c=[`Usage: ${t.commandUsage(e)}`,""],d=t.commandDescription(e);d.length>0&&(c=c.concat([t.wrap(d,i,0),""]));let p=t.visibleArguments(e).map(m=>l(t.argumentTerm(m),t.argumentDescription(m)));p.length>0&&(c=c.concat(["Arguments:",a(p),""]));let u=t.visibleOptions(e).map(m=>l(t.optionTerm(m),t.optionDescription(m)));if(u.length>0&&(c=c.concat(["Options:",a(u),""])),this.showGlobalOptions){let m=t.visibleGlobalOptions(e).map(
|
|
2
|
+
import{a as Z,b as ee,c as w,d as te,f as re}from"./chunk-U62SRHG3.js";import{a as M,b as ne}from"./chunk-I3GV76MP.js";import{c as ie}from"./chunk-A2CQYOXE.js";import{a as Q}from"./chunk-O6RIRKRN.js";import{o as X,q as Y}from"./chunk-WAVNKSSE.js";import"./chunk-DV5WIEGS.js";import"./chunk-ZITT4GJK.js";import"./chunk-2ZG44JU6.js";import"./chunk-Z44TXDGK.js";import"./chunk-CWWDVX6C.js";import{a as x,c as O,e as k}from"./chunk-D76SO2ME.js";var P=O($=>{var A=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},R=class extends A{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};$.CommanderError=A;$.InvalidArgumentError=R});var E=O(H=>{var{InvalidArgumentError:$e}=P(),V=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new $e(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Ve(o){let e=o.name()+(o.variadic===!0?"...":"");return o.required?"<"+e+">":"["+e+"]"}H.Argument=V;H.humanReadableArgName=Ve});var L=O(oe=>{var{humanReadableArgName:He}=E(),I=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((i,r)=>i.name().localeCompare(r.name())),t}compareOptions(e,t){let n=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),r=n.long&&e._findOption(n.long);!i&&!r?t.push(n):n.long&&!r?t.push(e.createOption(n.long,n.description)):n.short&&!i&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let i=n.options.filter(r=>!r.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(n=>He(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((n,i)=>Math.max(n,t.subcommandTerm(i).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,i)=>Math.max(n,t.optionTerm(i).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,t.optionTerm(i).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,i)=>Math.max(n,t.argumentTerm(i).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatHelp(e,t){let n=t.padWidth(e,t),i=t.helpWidth||80,r=2,s=2;function l(m,y){if(y){let S=`${m.padEnd(n+s)}${y}`;return t.wrap(S,i-r,n+s)}return m}function a(m){return m.join(`
|
|
3
|
+
`).replace(/^/gm," ".repeat(r))}let c=[`Usage: ${t.commandUsage(e)}`,""],d=t.commandDescription(e);d.length>0&&(c=c.concat([t.wrap(d,i,0),""]));let p=t.visibleArguments(e).map(m=>l(t.argumentTerm(m),t.argumentDescription(m)));p.length>0&&(c=c.concat(["Arguments:",a(p),""]));let u=t.visibleOptions(e).map(m=>l(t.optionTerm(m),t.optionDescription(m)));if(u.length>0&&(c=c.concat(["Options:",a(u),""])),this.showGlobalOptions){let m=t.visibleGlobalOptions(e).map(y=>l(t.optionTerm(y),t.optionDescription(y)));m.length>0&&(c=c.concat(["Global Options:",a(m),""]))}let f=t.visibleCommands(e).map(m=>l(t.subcommandTerm(m),t.subcommandDescription(m)));return f.length>0&&(c=c.concat(["Commands:",a(f),""])),c.join(`
|
|
4
4
|
`)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,n,i=40){let r=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",s=new RegExp(`[\\n][${r}]+`);if(e.match(s))return e;let l=t-n;if(l<i)return e;let a=e.slice(0,n),c=e.slice(n).replace(`\r
|
|
5
5
|
`,`
|
|
6
6
|
`),d=" ".repeat(n),u="\\s\u200B",f=new RegExp(`
|
|
7
|
-
|.{1,${l-1}}([${u}]|$)|[^${u}]+?([${u}]|$)`,"g"),m=c.match(f)||[];return a+m.map((
|
|
8
|
-
`?"":(S>0?d:"")+
|
|
7
|
+
|.{1,${l-1}}([${u}]|$)|[^${u}]+?([${u}]|$)`,"g"),m=c.match(f)||[];return a+m.map((y,S)=>y===`
|
|
8
|
+
`?"":(S>0?d:"")+y.trimEnd()).join(`
|
|
9
9
|
`)}};oe.Help=I});var q=O(j=>{var{InvalidArgumentError:Ie}=P(),N=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=Ne(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new Ie(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,n):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return Le(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},D=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,n)=>{this.positiveOptions.has(n)&&this.dualOptions.add(n)})}valueFromOption(e,t){let n=t.attributeName();if(!this.dualOptions.has(n))return!0;let i=this.negativeOptions.get(n).presetArg,r=i!==void 0?i:!1;return t.negate===(r===e)}};function Le(o){return o.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Ne(o){let e,t,n=o.split(/[ |,]+/);return n.length>1&&!/^[[<]/.test(n[1])&&(e=n.shift()),t=n.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}j.Option=N;j.DualOptions=D});var ae=O(se=>{function De(o,e){if(Math.abs(o.length-e.length)>3)return Math.max(o.length,e.length);let t=[];for(let n=0;n<=o.length;n++)t[n]=[n];for(let n=0;n<=e.length;n++)t[0][n]=n;for(let n=1;n<=e.length;n++)for(let i=1;i<=o.length;i++){let r=1;o[i-1]===e[n-1]?r=0:r=1,t[i][n]=Math.min(t[i-1][n]+1,t[i][n-1]+1,t[i-1][n-1]+r),i>1&&n>1&&o[i-1]===e[n-2]&&o[i-2]===e[n-1]&&(t[i][n]=Math.min(t[i][n],t[i-2][n-2]+1))}return t[o.length][e.length]}function je(o,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=o.startsWith("--");t&&(o=o.slice(2),e=e.map(s=>s.slice(2)));let n=[],i=3,r=.4;return e.forEach(s=>{if(s.length<=1)return;let l=De(o,s),a=Math.max(o.length,s.length);(a-l)/a>r&&(l<i?(i=l,n=[s]):l===i&&n.push(s))}),n.sort((s,l)=>s.localeCompare(l)),t&&(n=n.map(s=>`--${s}`)),n.length>1?`
|
|
10
10
|
(Did you mean one of ${n.join(", ")}?)`:n.length===1?`
|
|
11
|
-
(Did you mean ${n[0]}?)`:""}se.suggestSimilar=je});var he=O(de=>{var qe=x("node:events").EventEmitter,F=x("node:child_process"),
|
|
11
|
+
(Did you mean ${n[0]}?)`:""}se.suggestSimilar=je});var he=O(de=>{var qe=x("node:events").EventEmitter,F=x("node:child_process"),v=x("node:path"),U=x("node:fs"),g=x("node:process"),{Argument:Fe,humanReadableArgName:Ue}=E(),{CommanderError:W}=P(),{Help:We}=L(),{Option:ue,DualOptions:Be}=q(),{suggestSimilar:le}=ae(),B=class o extends qe{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:t=>g.stdout.write(t),writeErr:t=>g.stderr.write(t),getOutHelpWidth:()=>g.stdout.isTTY?g.stdout.columns:void 0,getErrHelpWidth:()=>g.stderr.isTTY?g.stderr.columns:void 0,outputError:(t,n)=>n(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,n){let i=t,r=n;typeof i=="object"&&i!==null&&(r=i,i=null),r=r||{};let[,s,l]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(s);return i&&(a.description(i),a._executableHandler=!0),r.isDefault&&(this._defaultCommandName=a._name),a._hidden=!!(r.noHelp||r.hidden),a._executableFile=r.executableFile||null,l&&a.arguments(l),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),i?this:a}createCommand(e){return new o(e)}createHelp(){return Object.assign(new We,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
12
12
|
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new Fe(e,t)}argument(e,t,n,i){let r=this.createArgument(e,t);return typeof n=="function"?r.default(i).argParser(n):r.default(n),this.addArgument(r),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,n,i]=e.match(/([^ ]+) *(.*)/),r=t??"display help for command",s=this.createCommand(n);return s.helpOption(!1),i&&s.arguments(i),r&&s.description(r),this._addImplicitHelpCommand=!0,this._helpCommand=s,this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let n=["preSubcommand","preAction","postAction"];if(!n.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
13
13
|
Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,n){this._exitCallback&&this._exitCallback(new W(e,t,n)),g.exit(e)}action(e){let t=n=>{let i=this.registeredArguments.length,r=n.slice(0,i);return this._storeOptionsAsProperties?r[i]=this:r[i]=this.opts(),r.push(this),e.apply(this,r)};return this._actionHandler=t,this}createOption(e,t){return new ue(e,t)}_callParseArg(e,t,n,i){try{return e.parseArg(t,n)}catch(r){if(r.code==="commander.invalidArgument"){let s=`${i} ${r.message}`;this.error(s,{exitCode:r.exitCode,code:r.code})}throw r}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
|
|
14
|
-
- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=i=>[i.name()].concat(i.aliases()),n=t(e).find(i=>this._findCommand(i));if(n){let i=t(this._findCommand(n)).join("|"),r=t(e).join("|");throw new Error(`cannot add command '${r}' as already have command '${i}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();if(e.negate){let r=e.long.replace(/^--no-/,"--");this._findOption(r)||this.setOptionValueWithSource(n,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,"default");let i=(r,s,l)=>{r==null&&e.presetArg!==void 0&&(r=e.presetArg);let a=this.getOptionValue(n);r!==null&&e.parseArg?r=this._callParseArg(e,r,a,s):r!==null&&e.variadic&&(r=e._concatValue(r,a)),r==null&&(e.negate?r=!1:e.isBoolean()||e.optional?r=!0:r=""),this.setOptionValueWithSource(n,r,l)};return this.on("option:"+t,r=>{let s=`error: option '${e.flags}' argument '${r}' is invalid.`;i(r,s,"cli")}),e.envVar&&this.on("optionEnv:"+t,r=>{let s=`error: option '${e.flags}' value '${r}' from env '${e.envVar}' is invalid.`;i(r,s,"env")}),this}_optionEx(e,t,n,i,r){if(typeof t=="object"&&t instanceof ue)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let s=this.createOption(t,n);if(s.makeOptionMandatory(!!e.mandatory),typeof i=="function")s.default(r).argParser(i);else if(i instanceof RegExp){let l=i;i=(a,c)=>{let d=l.exec(a);return d?d[0]:c},s.default(r).argParser(i)}else s.default(i);return this.addOption(s)}option(e,t,n,i){return this._optionEx({},e,t,n,i)}requiredOption(e,t,n,i){return this._optionEx({mandatory:!0},e,t,n,i)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){g.versions?.electron&&(t.from="electron");let i=g.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(t.from="eval")}e===void 0&&(e=g.argv),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":g.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case"user":n=e.slice(0);break;case"eval":n=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(e,t){let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_executeSubCommand(e,t){t=t.slice();let n=!1,i=[".js",".ts",".tsx",".mjs",".cjs"];function r(d,p){let u=
|
|
14
|
+
- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=i=>[i.name()].concat(i.aliases()),n=t(e).find(i=>this._findCommand(i));if(n){let i=t(this._findCommand(n)).join("|"),r=t(e).join("|");throw new Error(`cannot add command '${r}' as already have command '${i}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),n=e.attributeName();if(e.negate){let r=e.long.replace(/^--no-/,"--");this._findOption(r)||this.setOptionValueWithSource(n,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,"default");let i=(r,s,l)=>{r==null&&e.presetArg!==void 0&&(r=e.presetArg);let a=this.getOptionValue(n);r!==null&&e.parseArg?r=this._callParseArg(e,r,a,s):r!==null&&e.variadic&&(r=e._concatValue(r,a)),r==null&&(e.negate?r=!1:e.isBoolean()||e.optional?r=!0:r=""),this.setOptionValueWithSource(n,r,l)};return this.on("option:"+t,r=>{let s=`error: option '${e.flags}' argument '${r}' is invalid.`;i(r,s,"cli")}),e.envVar&&this.on("optionEnv:"+t,r=>{let s=`error: option '${e.flags}' value '${r}' from env '${e.envVar}' is invalid.`;i(r,s,"env")}),this}_optionEx(e,t,n,i,r){if(typeof t=="object"&&t instanceof ue)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let s=this.createOption(t,n);if(s.makeOptionMandatory(!!e.mandatory),typeof i=="function")s.default(r).argParser(i);else if(i instanceof RegExp){let l=i;i=(a,c)=>{let d=l.exec(a);return d?d[0]:c},s.default(r).argParser(i)}else s.default(i);return this.addOption(s)}option(e,t,n,i){return this._optionEx({},e,t,n,i)}requiredOption(e,t,n,i){return this._optionEx({mandatory:!0},e,t,n,i)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,n){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(t=n.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){g.versions?.electron&&(t.from="electron");let i=g.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(t.from="eval")}e===void 0&&(e=g.argv),this.rawArgs=e.slice();let n;switch(t.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":g.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case"user":n=e.slice(0);break;case"eval":n=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(e,t){let n=this._prepareUserArgs(e,t);return this._parseCommand([],n),this}async parseAsync(e,t){let n=this._prepareUserArgs(e,t);return await this._parseCommand([],n),this}_executeSubCommand(e,t){t=t.slice();let n=!1,i=[".js",".ts",".tsx",".mjs",".cjs"];function r(d,p){let u=v.resolve(d,p);if(U.existsSync(u))return u;if(i.includes(v.extname(p)))return;let f=i.find(m=>U.existsSync(`${u}${m}`));if(f)return`${u}${f}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=e._executableFile||`${this._name}-${e._name}`,l=this._executableDir||"";if(this._scriptPath){let d;try{d=U.realpathSync(this._scriptPath)}catch{d=this._scriptPath}l=v.resolve(v.dirname(d),l)}if(l){let d=r(l,s);if(!d&&!e._executableFile&&this._scriptPath){let p=v.basename(this._scriptPath,v.extname(this._scriptPath));p!==this._name&&(d=r(l,`${p}-${e._name}`))}s=d||s}n=i.includes(v.extname(s));let a;g.platform!=="win32"?n?(t.unshift(s),t=ce(g.execArgv).concat(t),a=F.spawn(g.argv[0],t,{stdio:"inherit"})):a=F.spawn(s,t,{stdio:"inherit"}):(t.unshift(s),t=ce(g.execArgv).concat(t),a=F.spawn(g.execPath,t,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(p=>{g.on(p,()=>{a.killed===!1&&a.exitCode===null&&a.kill(p)})});let c=this._exitCallback;a.on("close",d=>{d=d??1,c?c(new W(d,"commander.executeSubCommandAsync","(close)")):g.exit(d)}),a.on("error",d=>{if(d.code==="ENOENT"){let p=l?`searched for local subcommand relative to directory '${l}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",u=`'${s}' does not exist
|
|
15
15
|
- if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
16
16
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
17
17
|
- ${p}`;throw new Error(u)}else if(d.code==="EACCES")throw new Error(`'${s}' not executable`);if(!c)g.exit(1);else{let p=new W(1,"commander.executeSubCommandAsync","(error)");p.nestedError=d,c(p)}}),this.runningCommand=a}_dispatchSubcommand(e,t,n){let i=this._findCommand(e);i||this.help({error:!0});let r;return r=this._chainOrCallSubCommandHook(r,i,"preSubcommand"),r=this._chainOrCall(r,()=>{if(i._executableHandler)this._executeSubCommand(i,t.concat(n));else return i._parseCommand(t,n)}),r}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(n,i,r)=>{let s=i;if(i!==null&&n.parseArg){let l=`error: command-argument value '${i}' is invalid for argument '${n.name()}'.`;s=this._callParseArg(n,i,r,l)}return s};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,i)=>{let r=n.defaultValue;n.variadic?i<this.args.length?(r=this.args.slice(i),n.parseArg&&(r=r.reduce((s,l)=>e(n,l,s),n.defaultValue))):r===void 0&&(r=[]):i<this.args.length&&(r=this.args[i],n.parseArg&&(r=e(n,r,n.defaultValue))),t[i]=r}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,i=[];return this._getCommandAndAncestors().reverse().filter(r=>r._lifeCycleHooks[t]!==void 0).forEach(r=>{r._lifeCycleHooks[t].forEach(s=>{i.push({hookedCommand:r,callback:s})})}),t==="postAction"&&i.reverse(),i.forEach(r=>{n=this._chainOrCall(n,()=>r.callback(r.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let i=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(r=>{i=this._chainOrCall(i,()=>r(this,t))}),i}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){i(),this._processArguments();let s;return s=this._chainOrCallHooks(s,"preAction"),s=this._chainOrCall(s,()=>this._actionHandler(this.processedArgs)),this.parent&&(s=this._chainOrCall(s,()=>{this.parent.emit(r,e,t)})),s=this._chainOrCallHooks(s,"postAction"),s}if(this.parent&&this.parent.listenerCount(r))i(),this._processArguments(),this.parent.emit(r,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(i(),this._processArguments())}else this.commands.length?(i(),this.help({error:!0})):(i(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(n=>{let i=n.attributeName();return this.getOptionValue(i)===void 0?!1:this.getOptionValueSource(i)!=="default"});e.filter(n=>n.conflictsWith.length>0).forEach(n=>{let i=e.find(r=>n.conflictsWith.includes(r.attributeName()));i&&this._conflictingOption(n,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],i=t,r=e.slice();function s(a){return a.length>1&&a[0]==="-"}let l=null;for(;r.length;){let a=r.shift();if(a==="--"){i===n&&i.push(a),i.push(...r);break}if(l&&!s(a)){this.emit(`option:${l.name()}`,a);continue}if(l=null,s(a)){let c=this._findOption(a);if(c){if(c.required){let d=r.shift();d===void 0&&this.optionMissingArgument(c),this.emit(`option:${c.name()}`,d)}else if(c.optional){let d=null;r.length>0&&!s(r[0])&&(d=r.shift()),this.emit(`option:${c.name()}`,d)}else this.emit(`option:${c.name()}`);l=c.variadic?c:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let c=this._findOption(`-${a[1]}`);if(c){c.required||c.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${c.name()}`,a.slice(2)):(this.emit(`option:${c.name()}`),r.unshift(`-${a.slice(2)}`));continue}}if(/^--[^=]+=/.test(a)){let c=a.indexOf("="),d=this._findOption(a.slice(0,c));if(d&&(d.required||d.optional)){this.emit(`option:${d.name()}`,a.slice(c+1));continue}}if(s(a)&&(i=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(a)){t.push(a),r.length>0&&n.push(...r);break}else if(this._getHelpCommand()&&a===this._getHelpCommand().name()){t.push(a),r.length>0&&t.push(...r);break}else if(this._defaultCommandName){n.push(a),r.length>0&&n.push(...r);break}}if(this._passThroughOptions){i.push(a),r.length>0&&i.push(...r);break}i.push(a)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let i=this.options[n].attributeName();e[i]=i===this._versionOptionName?this._version:this[i]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
|
|
18
18
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
19
19
|
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
20
20
|
`),this.outputHelp({error:!0}));let n=t||{},i=n.exitCode||1,r=n.code||"commander.error";this._exit(i,r,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in g.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,g.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Be(this.options),t=n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(i=>!t(i)).forEach(i=>{this.setOptionValueWithSource(i,n.implied[i],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let n=s=>{let l=s.attributeName(),a=this.getOptionValue(l),c=this.options.find(p=>p.negate&&l===p.attributeName()),d=this.options.find(p=>!p.negate&&l===p.attributeName());return c&&(c.presetArg===void 0&&a===!1||c.presetArg!==void 0&&a===c.presetArg)?c:d||s},i=s=>{let l=n(s),a=l.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${l.envVar}'`:`option '${l.flags}'`},r=`error: ${i(e)} cannot be used with ${i(t)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],r=this;do{let s=r.createHelp().visibleOptions(r).filter(l=>l.long).map(l=>l.long);i=i.concat(s),r=r.parent}while(r&&!r._enablePositionalOptions);t=le(e,i)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?"":"s",r=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${n} but got ${e.length}.`;this.error(r,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(r=>{i.push(r.name()),r.alias()&&i.push(r.alias())}),t=le(e,i)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:"commander.unknownCommand"})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",n=n||"output the version number";let i=this.createOption(t,n);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
21
|
-
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(e);if(n){let i=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(n=>Ue(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=
|
|
21
|
+
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(e);if(n){let i=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(n=>Ue(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=v.basename(e,v.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},n;return t.error?n=i=>this._outputConfiguration.writeErr(i):n=i=>this._outputConfiguration.writeOut(i),t.write=e.write||n,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let n=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(r=>r.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let i=this.helpInformation(n);if(t&&(i=t(i),typeof i!="string"&&!Buffer.isBuffer(i)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach(r=>r.emit("afterAllHelp",n))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=g.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
22
22
|
Expecting one of '${n.join("', '")}'`);let i=`${e}Help`;return this.on(i,r=>{let s;typeof t=="function"?s=t({error:r.error,command:r.command}):s=t,s&&r.write(`${s}
|
|
23
|
-
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ce(o){return o.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="127.0.0.1",i="9229",r;return(r=e.match(/^(--inspect(-brk)?)$/))!==null?t=r[1]:(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=r[1],/^\d+$/.test(r[3])?i=r[3]:n=r[3]):(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=r[1],n=r[3],i=r[4]),t&&i!=="0"?`${t}=${n}:${parseInt(i)+1}`:e})}de.Command=B});var ge=O(_=>{var{Argument:pe}=E(),{Command:G}=he(),{CommanderError:Ge,InvalidArgumentError:me}=P(),{Help:Je}=L(),{Option:fe}=q();_.program=new G;_.createCommand=o=>new G(o);_.createOption=(o,e)=>new fe(o,e);_.createArgument=(o,e)=>new pe(o,e);_.Command=G;_.Option=fe;_.Argument=pe;_.Help=Je;_.CommanderError=Ge;_.InvalidArgumentError=me;_.InvalidOptionArgumentError=me});var _e=k(ge(),1),{program:At,createCommand:Et,createArgument:Tt,createOption:St,CommanderError:kt,InvalidArgumentError:b,InvalidOptionArgumentError:Mt,Command:we,Argument:$t,Option:h,Help:Rt}=_e.default;var Ke=new Set(["git","changes","projects"]);function ye(o,e={}){let t=o.argument("[prompt]","task to execute in the interactive TUI").addOption(new h("--lane <lane>","managed backend lane for test or staging builds")).addOption(new h("--session [id]","open a Session by id, or browse Sessions when id is omitted")).addOption(new h("-c, --continue","continue the latest Session in the current workspace")).addOption(new h("--tui-mode <mode>","TUI mode: regular (default) or fullscreen").argParser(ze)).addOption(new h("--resume <id>").hideHelp()).allowExcessArguments(!1).showHelpAfterError();return e.allowStartupEnvironmentSelection&&t.addOption(new h("--env <environment>","startup environment for the internal package: test, staging (pre), or prod").argParser(Xe)),t}function ve(o,e){if(o&&Ke.has(o))throw new Error("too many arguments");let t=typeof e.session=="string"?e.session.trim():void 0,n=e.resume?.trim(),i=e.session===!0;if([!!(t||i),!!n,e.continue===!0].filter(Boolean).length>1)throw new Error("--session, --continue, and --resume cannot be combined");let s=t||n;return{...o?{initialPrompt:o}:{},...s?{sessionId:s}:{},...i?{showSessionPicker:!0}:{},...e.continue?{continueLatestSession:!0}:{},...e.tuiMode?{tuiMode:e.tuiMode}:{},...e.lane?{lane:e.lane}:{}}}function be(o){return o.argument("[prompt]","task to execute").addOption(new h("--input <source>",'read explicit input; only "-" is supported')).addOption(new h("--input-format <format>","input format: text or json").default("text")).addOption(new h("--cwd <path>","workspace directory")).addOption(new h("--file <path>","attach a file (repeatable)").argParser(Ye).default([])).addOption(new h("--model <provider/model>","override the model for this Run only")).addOption(new h("--prompt-mode <mode>","Prompt mode: tui, coding, or work").choices(["tui","coding","work"]).default("tui")).addOption(new h("--session <id>","run in an existing active Session")).addOption(new h("--continue","continue the latest active Session in --cwd")).addOption(new h("--config <path>","use an explicit Runtime config file for this process")).addOption(new h("--permission <policy>","permission policy: smart, full, or off (ask requires TUI/ACP)").default("smart")).addOption(new h("--timeout <duration>","Run timeout, for example 30s or 2m")).addOption(new h("--max-steps <count>","maximum assistant steps")).addOption(new h("--output-format <format>","output format: text, json, or stream-json")).addOption(new h("--diagnostics-dir <path>","save bounded execution diagnostics to a fresh directory")).addOption(new h("--output-schema <schema>","JSON Schema file or inline object for the final answer")).addOption(new h("-o, --output-last-message <path>","write the final agent message to a file"))}function Oe(o){return o.addOption(new h("--cwd <path>","workspace directory")).addOption(new h("--model <provider/model>","override the model for this Run only")).addOption(new h("--config <path>","use an explicit Runtime config file for this process")).addOption(new h("--permission <policy>","permission policy: smart, full, or off (ask requires TUI/ACP)").default("smart")).addOption(new h("--timeout <duration>","Run timeout, for example 30s or 2m")).addOption(new h("--max-steps <count>","maximum assistant steps")).addOption(new h("--output-format <format>","output format: text, json, or stream-json")).addOption(new h("-o, --output-last-message <path>","write the final review result to a file")).allowExcessArguments(!1).showHelpAfterError()}function ze(o){if(o==="regular"||o==="fullscreen")return o;throw new b("TUI mode must be regular or fullscreen")}function Xe(o){try{return X(o)}catch(e){throw new b(e instanceof Error?e.message:String(e))}}function Ye(o,e){return[...e,o]}function Ee(o){let e,t=u=>({...u,...e?{lane:e}:{}}),n=u=>e?xe(o)(u,e):xe(o)(u),i=u=>e?Pe(o)(u,e):Pe(o)(u),r=ye(new we().name("mcode").description("Minimax Code \u2014 terminal coding agent").version(o.version).enablePositionalOptions(),{allowStartupEnvironmentSelection:o.allowStartupEnvironmentSelection}).action((u,f)=>o.launchTui(t(ve(u,f))));r.hook("preAction",()=>{e=(o.resolveLane??Y)(r.opts().lane)}),r.command("init").description("Analyze the codebase and generate AGENTS.md with the Runtime init Skill").argument("[directory]","project directory",".").action(u=>o.launchTui(t({initialPrompt:"/init",workspaceDir:u})));let s=r.command("exec").description("Run one prompt without starting the TUI");be(s).action((u,f)=>e?o.runExec(u,f,e):o.runExec(u,f)),Oe(s.command("review").description("Review staged, unstaged, and untracked local changes")).action((u,f)=>{let m=Qe(s,f);return e?o.runExec(void 0,m,e):o.runExec(void 0,m)}),r.command("acp").description("Run MiniMax Code as an Agent Client Protocol server over stdio").allowExcessArguments(!1).action(()=>e?Ae(o)(e):Ae(o)()).command("login").description("Sign in to use MiniMax Code Agent features").option("--region <region>","account region: cn or global",J).option("--no-browser","print the authorization URL without opening a browser").allowExcessArguments(!1).action(u=>e?o.runLogin(u.region,u.browser!==!1,e):o.runLogin(u.region,u.browser!==!1)),r.command("login").description("Sign in to use MiniMax Code Agent features").option("--region <region>","account region: cn or global",J).option("--no-browser","print the authorization URL without opening a browser").allowExcessArguments(!1).action(u=>e?o.runLogin(u.region,u.browser!==!1,e):o.runLogin(u.region,u.browser!==!1)),r.command("logout").description("Sign out of the MiniMax account used by this CLI").option("--region <region>","account region: cn or global",J).allowExcessArguments(!1).action(u=>o.runLogout(u.region)),r.command("update").description("Check for and install a Minimax Code update").allowExcessArguments(!1).action(o.runUpdate);let a=r.command("provider").description("Manage model providers and API keys").allowExcessArguments(!1).action(()=>o.launchTui(t({initialPrompt:"/provider"})));a.command("list").description("List configured providers").option("--json","print a JSON document").action(u=>n({action:"list",json:u.json})),a.command("add").description("Add a custom provider").requiredOption("--name <name>","provider display name").requiredOption("--base-url <url>","provider API base URL").option("--api-format <format>",M.join(", "),et,"anthropic-messages").option("--model <id>","model ID (repeatable)",Ze,[]).option("--api-key-env <name>","environment variable containing the API key").option("--use","select the first model as the default").action(u=>{if(u.model.length===0)throw new Error("At least one --model <id> is required.");return n({action:"add",name:u.name,baseUrl:u.baseUrl,apiFormat:u.apiFormat,models:u.model,apiKeyEnv:u.apiKeyEnv,saveAndUse:u.use})}),a.command("remove").description("Remove a custom provider").argument("<provider-id>","custom_provider:<id>").option("--yes","confirm removal").action((u,f)=>n({action:"remove",providerId:u,confirmed:!!f.yes})),a.command("test").description("Test a provider or one configured model").argument("<provider-id>","provider id").option("--model <id>","test one model").option("--json","print a JSON document").action((u,f)=>n({action:"test",providerId:u,modelId:f.model,json:f.json})),a.command("use").description("Choose the MiniMax credential source").argument("<source>","token-plan or api-key",tt).action(u=>n({action:"use",source:u})),a.command("set-minimax-key").description("Save and use a MiniMax API key").option("--api-key-env <name>","environment variable containing the API key").action(u=>n({action:"set-minimax-key",apiKeyEnv:u.apiKeyEnv}));let c=r.command("plugin").description("Manage MiniMax Code Plugins").allowExcessArguments(!1).action(()=>o.launchTui(t({initialPrompt:"/plugins"})));c.command("list").description("List installed or available Plugins").option("-m, --marketplace <marketplace>","official or local",Ce).option("--available","include uninstalled Plugins").option("--json","print a JSON document").action(u=>i({action:"list",marketplace:u.marketplace,available:u.available,json:u.json}));for(let u of["add","remove","enable","disable"])c.command(u).description(`${nt(u)} a Plugin`).argument("<plugin[@marketplace]>","Plugin selector").option("-m, --marketplace <marketplace>","official or local",Ce).option("--json","print a JSON document").action((f,m)=>i({action:u,selector:f,marketplace:m.marketplace,json:m.json}));let d=c.command("marketplace").description("List or refresh MiniMax Code Plugin sources");d.command("list").description("List Plugin sources").option("--json","print a JSON document").action(u=>i({action:"marketplace-list",json:u.json})),d.command("upgrade").description("Refresh all Plugin source snapshots").option("--json","print a JSON document").action(u=>i({action:"marketplace-upgrade",json:u.json}));let p=new te;p.registerAll(o.commandContributions??[]);for(let u of p.freeze()){if(r.commands.some(f=>f.name()===u.name))throw new Error(`Duplicate CLI command name: ${u.name}`);u.register(r,o)}return r}function Qe(o,e){let t={...e.opts(),review:!0},n=new Set(e.options.map(i=>i.attributeName()));for(let i of o.options){let r=i.attributeName();o.getOptionValueSource(r)==="cli"&&(n.has(r)||e.error(`error: option '${i.long}' is not supported by 'exec review'`,{code:"commander.unknownOption"}),e.getOptionValueSource(r)!=="cli"&&Object.assign(t,{[r]:o.getOptionValue(r)}))}return t}function Ze(o,e){return[...e,o]}function J(o){if(o==="cn")return"cn";if(o==="global")return"en";throw new b('expected "cn" or "global"')}function et(o){if(ne(o))return o;throw new b(`expected one of: ${M.join(", ")}`)}function tt(o){if(o==="token-plan")return"token_plan";if(o==="api-key")return"minimax_api_key";throw new b('expected "token-plan" or "api-key"')}function Ce(o){let e=o.trim().toLocaleLowerCase();if(e==="official"||e==="local")return e;throw new b('expected "official" or "local"')}function nt(o){return o==="add"?"Install":o==="remove"?"Uninstall":o==="enable"?"Enable":"Disable"}function xe(o){if(!o.runProvider)throw new Error("Provider management is unavailable.");return o.runProvider}function Pe(o){if(!o.runPlugin)throw new Error("Plugin management is unavailable.");return o.runPlugin}function Ae(o){if(!o.runAcp)throw new Error("ACP server is unavailable.");return o.runAcp}var T=k(Q(),1),C=k(Q(),1),it=["localhost","127.0.0.1","::1"];function rt(o=process.env){let e=K(o,"ALL_PROXY","all_proxy"),t=K(o,"HTTP_PROXY","http_proxy")??e,n=K(o,"HTTPS_PROXY","https_proxy")??e??t;return!t&&!n?{mode:"direct"}:(Te(t),Te(n),{mode:"proxy",httpProxy:t?.value??"",httpsProxy:n?.value??"",noProxy:ot(o.NO_PROXY??o.no_proxy)})}function Se(o={}){let e=rt(o.environment);if(e.mode==="direct")return e;let n=(o.createProxyDispatcher??(i=>new z(i)))({httpProxy:e.httpProxy,httpsProxy:e.httpsProxy,noProxy:e.noProxy});return(o.setGlobalDispatcher??T.setGlobalDispatcher)(n),(o.installFetch??st)(),e}function K(o,...e){for(let t of e){let n=o[t]?.trim();if(n)return{name:t,value:n}}}function Te(o){if(!o)return;let e;try{e=new URL(o.value)}catch{throw new Error(`${o.name} must be an http:// or https:// URL.`)}if(e.protocol!=="http:"&&e.protocol!=="https:"||!e.hostname)throw new Error(`${o.name} must be an http:// or https:// URL.`)}function ot(o){let e=[];for(let t of(o??"").split(",")){let n=t.trim();n&&!e.includes(n)&&e.push(n)}for(let t of it)e.includes(t)||e.push(t);return e.join(",")}function st(){T.install?.()}var z=class extends C.Dispatcher{#e=new C.Agent;#t;#n;#i;#r;constructor(e){super(),this.#t=e.httpProxy?new C.ProxyAgent({uri:e.httpProxy}):this.#e,this.#n=e.httpsProxy?e.httpsProxy===e.httpProxy?this.#t:new C.ProxyAgent({uri:e.httpsProxy}):this.#e,this.#i=[...new Set([this.#e,this.#t,this.#n])],this.#r=e.noProxy}dispatch(e,t){let n=new URL(e.origin??"");return at(n,this.#r)?this.#e.dispatch(e,t):(n.protocol==="https:"?this.#n:this.#t).dispatch(e,t)}close(e){let t=Promise.all(this.#i.map(n=>n.close())).then(()=>{});if(!e)return t;t.then(e,e)}destroy(e,t){let n=typeof e=="function"?null:e??null,i=typeof e=="function"?e:t,r=Promise.all(this.#i.map(s=>s.destroy(n))).then(()=>{});if(!i)return r;r.then(i,i)}};function at(o,e){let t=ke(o.hostname),n=Number(o.port)||(o.protocol==="https:"?443:80);for(let i of e.split(/[\s,]+/u)){let r=ut(i);if(r){if(r.hostname==="*")return!0;if(!(r.port!==void 0&&r.port!==n)&&(t===r.hostname||r.includeSubdomains&&t.endsWith(`.${r.hostname}`)))return!0}}return!1}function ut(o){let e=o.trim().toLowerCase();if(!e)return;if(e==="*")return{hostname:"*",includeSubdomains:!0};let t;if(e.startsWith("[")){let r=e.indexOf("]");if(r>0){let s=e.slice(r+1);/^:\d+$/u.test(s)&&(t=Number(s.slice(1))),e=e.slice(1,r)}}else if(e.split(":").length===2){let[r,s]=e.split(":");r&&/^\d+$/u.test(s??"")&&(e=r,t=Number(s))}let n=e.startsWith(".")||e.startsWith("*");e=e.replace(/^\*?\./u,"");let i=ke(e);return i?{hostname:i,port:t,includeSubdomains:n}:void 0}function ke(o){return o.toLowerCase().replace(/^\[|\]$/gu,"")}var Me=250,lt="minimax-code";async function Xt(o={}){let e=o.processRef??process;e.title=lt;let t=re(e.env);if(!(o.supportsNodeVersion??(r=>ee(r)))(e.versions.node)){e.stderr.write(`Minimax Code supports Node.js ${Z}; current version is ${e.versions.node}.
|
|
23
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ce(o){return o.map(e=>{if(!e.startsWith("--inspect"))return e;let t,n="127.0.0.1",i="9229",r;return(r=e.match(/^(--inspect(-brk)?)$/))!==null?t=r[1]:(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=r[1],/^\d+$/.test(r[3])?i=r[3]:n=r[3]):(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=r[1],n=r[3],i=r[4]),t&&i!=="0"?`${t}=${n}:${parseInt(i)+1}`:e})}de.Command=B});var ge=O(_=>{var{Argument:pe}=E(),{Command:G}=he(),{CommanderError:Ge,InvalidArgumentError:me}=P(),{Help:Je}=L(),{Option:fe}=q();_.program=new G;_.createCommand=o=>new G(o);_.createOption=(o,e)=>new fe(o,e);_.createArgument=(o,e)=>new pe(o,e);_.Command=G;_.Option=fe;_.Argument=pe;_.Help=Je;_.CommanderError=Ge;_.InvalidArgumentError=me;_.InvalidOptionArgumentError=me});var _e=k(ge(),1),{program:At,createCommand:Et,createArgument:Tt,createOption:St,CommanderError:kt,InvalidArgumentError:b,InvalidOptionArgumentError:Mt,Command:we,Argument:Rt,Option:h,Help:$t}=_e.default;var Ke=new Set(["git","changes","projects"]);function ve(o,e={}){let t=o.argument("[prompt]","task to execute in the interactive TUI").addOption(new h("--lane <lane>","managed backend lane for test or staging builds")).addOption(new h("--session [id]","open a Session by id, or browse Sessions when id is omitted")).addOption(new h("-c, --continue","continue the latest Session in the current workspace")).addOption(new h("--tui-mode <mode>","TUI mode: regular (default) or fullscreen").argParser(ze)).addOption(new h("--resume <id>").hideHelp()).allowExcessArguments(!1).showHelpAfterError();return e.allowStartupEnvironmentSelection&&t.addOption(new h("--env <environment>","startup environment for the internal package: test, staging (pre), or prod").argParser(Xe)),t}function ye(o,e){if(o&&Ke.has(o))throw new Error("too many arguments");let t=typeof e.session=="string"?e.session.trim():void 0,n=e.resume?.trim(),i=e.session===!0;if([!!(t||i),!!n,e.continue===!0].filter(Boolean).length>1)throw new Error("--session, --continue, and --resume cannot be combined");let s=t||n;return{...o?{initialPrompt:o}:{},...s?{sessionId:s}:{},...i?{showSessionPicker:!0}:{},...e.continue?{continueLatestSession:!0}:{},...e.tuiMode?{tuiMode:e.tuiMode}:{},...e.lane?{lane:e.lane}:{}}}function be(o){return o.argument("[prompt]","task to execute").addOption(new h("--input <source>",'read explicit input; only "-" is supported')).addOption(new h("--input-format <format>","input format: text or json").default("text")).addOption(new h("--cwd <path>","workspace directory")).addOption(new h("--file <path>","attach a file (repeatable)").argParser(Ye).default([])).addOption(new h("--model <provider/model>","override the model for this Run only")).addOption(new h("--effort <level>","override the reasoning effort for this Run only")).addOption(new h("--prompt-mode <mode>","Prompt mode: tui, coding, or work").choices(["tui","coding","work"]).default("tui")).addOption(new h("--session <id>","run in an existing active Session")).addOption(new h("--continue","continue the latest active Session in --cwd")).addOption(new h("--config <path>","use an explicit Runtime config file for this process")).addOption(new h("--permission <policy>","permission policy: smart, full, or off (ask requires TUI/ACP)").default("smart")).addOption(new h("--timeout <duration>","Run timeout, for example 30s or 2m")).addOption(new h("--max-steps <count>","maximum assistant steps")).addOption(new h("--output-format <format>","output format: text, json, or stream-json")).addOption(new h("--diagnostics-dir <path>","save bounded execution diagnostics to a fresh directory")).addOption(new h("--output-schema <schema>","JSON Schema file or inline object for the final answer")).addOption(new h("-o, --output-last-message <path>","write the final agent message to a file"))}function Oe(o){return o.addOption(new h("--cwd <path>","workspace directory")).addOption(new h("--model <provider/model>","override the model for this Run only")).addOption(new h("--effort <level>","override the reasoning effort for this Run only")).addOption(new h("--config <path>","use an explicit Runtime config file for this process")).addOption(new h("--permission <policy>","permission policy: smart, full, or off (ask requires TUI/ACP)").default("smart")).addOption(new h("--timeout <duration>","Run timeout, for example 30s or 2m")).addOption(new h("--max-steps <count>","maximum assistant steps")).addOption(new h("--output-format <format>","output format: text, json, or stream-json")).addOption(new h("-o, --output-last-message <path>","write the final review result to a file")).allowExcessArguments(!1).showHelpAfterError()}function ze(o){if(o==="regular"||o==="fullscreen")return o;throw new b("TUI mode must be regular or fullscreen")}function Xe(o){try{return X(o)}catch(e){throw new b(e instanceof Error?e.message:String(e))}}function Ye(o,e){return[...e,o]}function Ee(o){let e,t=u=>({...u,...e?{lane:e}:{}}),n=u=>e?xe(o)(u,e):xe(o)(u),i=u=>e?Pe(o)(u,e):Pe(o)(u),r=ve(new we().name("mcode").description("Minimax Code \u2014 terminal coding agent").version(o.version).enablePositionalOptions(),{allowStartupEnvironmentSelection:o.allowStartupEnvironmentSelection}).action((u,f)=>o.launchTui(t(ye(u,f))));r.hook("preAction",()=>{e=(o.resolveLane??Y)(r.opts().lane)}),r.command("init").description("Analyze the codebase and generate AGENTS.md with the Runtime init Skill").argument("[directory]","project directory",".").action(u=>o.launchTui(t({initialPrompt:"/init",workspaceDir:u})));let s=r.command("exec").description("Run one prompt without starting the TUI");be(s).action((u,f)=>e?o.runExec(u,f,e):o.runExec(u,f)),Oe(s.command("review").description("Review staged, unstaged, and untracked local changes")).action((u,f)=>{let m=Qe(s,f);return e?o.runExec(void 0,m,e):o.runExec(void 0,m)}),r.command("acp").description("Run MiniMax Code as an Agent Client Protocol server over stdio").allowExcessArguments(!1).action(()=>e?Ae(o)(e):Ae(o)()).command("login").description("Sign in to use MiniMax Code Agent features").option("--region <region>","account region: cn or global",J).option("--no-browser","print the authorization URL without opening a browser").allowExcessArguments(!1).action(u=>e?o.runLogin(u.region,u.browser!==!1,e):o.runLogin(u.region,u.browser!==!1)),r.command("login").description("Sign in to use MiniMax Code Agent features").option("--region <region>","account region: cn or global",J).option("--no-browser","print the authorization URL without opening a browser").allowExcessArguments(!1).action(u=>e?o.runLogin(u.region,u.browser!==!1,e):o.runLogin(u.region,u.browser!==!1)),r.command("logout").description("Sign out of the MiniMax account used by this CLI").option("--region <region>","account region: cn or global",J).allowExcessArguments(!1).action(u=>o.runLogout(u.region)),r.command("update").description("Check for and install a Minimax Code update").allowExcessArguments(!1).action(o.runUpdate);let a=r.command("provider").description("Manage model providers and API keys").allowExcessArguments(!1).action(()=>o.launchTui(t({initialPrompt:"/provider"})));a.command("list").description("List configured providers").option("--json","print a JSON document").action(u=>n({action:"list",json:u.json})),a.command("add").description("Add a custom provider").requiredOption("--name <name>","provider display name").requiredOption("--base-url <url>","provider API base URL").option("--api-format <format>",M.join(", "),et,"anthropic-messages").option("--model <id>","model ID (repeatable)",Ze,[]).option("--api-key-env <name>","environment variable containing the API key").option("--use","select the first model as the default").action(u=>{if(u.model.length===0)throw new Error("At least one --model <id> is required.");return n({action:"add",name:u.name,baseUrl:u.baseUrl,apiFormat:u.apiFormat,models:u.model,apiKeyEnv:u.apiKeyEnv,saveAndUse:u.use})}),a.command("remove").description("Remove a custom provider").argument("<provider-id>","custom_provider:<id>").option("--yes","confirm removal").action((u,f)=>n({action:"remove",providerId:u,confirmed:!!f.yes})),a.command("test").description("Test a provider or one configured model").argument("<provider-id>","provider id").option("--model <id>","test one model").option("--json","print a JSON document").action((u,f)=>n({action:"test",providerId:u,modelId:f.model,json:f.json})),a.command("use").description("Choose the MiniMax credential source").argument("<source>","token-plan or api-key",tt).action(u=>n({action:"use",source:u})),a.command("set-minimax-key").description("Save and use a MiniMax API key").option("--api-key-env <name>","environment variable containing the API key").action(u=>n({action:"set-minimax-key",apiKeyEnv:u.apiKeyEnv}));let c=r.command("plugin").description("Manage MiniMax Code Plugins").allowExcessArguments(!1).action(()=>o.launchTui(t({initialPrompt:"/plugins"})));c.command("list").description("List installed or available Plugins").option("-m, --marketplace <marketplace>","official or local",Ce).option("--available","include uninstalled Plugins").option("--json","print a JSON document").action(u=>i({action:"list",marketplace:u.marketplace,available:u.available,json:u.json}));for(let u of["add","remove","enable","disable"])c.command(u).description(`${nt(u)} a Plugin`).argument("<plugin[@marketplace]>","Plugin selector").option("-m, --marketplace <marketplace>","official or local",Ce).option("--json","print a JSON document").action((f,m)=>i({action:u,selector:f,marketplace:m.marketplace,json:m.json}));let d=c.command("marketplace").description("List or refresh MiniMax Code Plugin sources");d.command("list").description("List Plugin sources").option("--json","print a JSON document").action(u=>i({action:"marketplace-list",json:u.json})),d.command("upgrade").description("Refresh all Plugin source snapshots").option("--json","print a JSON document").action(u=>i({action:"marketplace-upgrade",json:u.json}));let p=new te;p.registerAll(o.commandContributions??[]);for(let u of p.freeze()){if(r.commands.some(f=>f.name()===u.name))throw new Error(`Duplicate CLI command name: ${u.name}`);u.register(r,o)}return r}function Qe(o,e){let t={...e.opts(),review:!0},n=new Set(e.options.map(i=>i.attributeName()));for(let i of o.options){let r=i.attributeName();o.getOptionValueSource(r)==="cli"&&(n.has(r)||e.error(`error: option '${i.long}' is not supported by 'exec review'`,{code:"commander.unknownOption"}),e.getOptionValueSource(r)!=="cli"&&Object.assign(t,{[r]:o.getOptionValue(r)}))}return t}function Ze(o,e){return[...e,o]}function J(o){if(o==="cn")return"cn";if(o==="global")return"en";throw new b('expected "cn" or "global"')}function et(o){if(ne(o))return o;throw new b(`expected one of: ${M.join(", ")}`)}function tt(o){if(o==="token-plan")return"token_plan";if(o==="api-key")return"minimax_api_key";throw new b('expected "token-plan" or "api-key"')}function Ce(o){let e=o.trim().toLocaleLowerCase();if(e==="official"||e==="local")return e;throw new b('expected "official" or "local"')}function nt(o){return o==="add"?"Install":o==="remove"?"Uninstall":o==="enable"?"Enable":"Disable"}function xe(o){if(!o.runProvider)throw new Error("Provider management is unavailable.");return o.runProvider}function Pe(o){if(!o.runPlugin)throw new Error("Plugin management is unavailable.");return o.runPlugin}function Ae(o){if(!o.runAcp)throw new Error("ACP server is unavailable.");return o.runAcp}var T=k(Q(),1),C=k(Q(),1),it=["localhost","127.0.0.1","::1"];function rt(o=process.env){let e=K(o,"ALL_PROXY","all_proxy"),t=K(o,"HTTP_PROXY","http_proxy")??e,n=K(o,"HTTPS_PROXY","https_proxy")??e??t;return!t&&!n?{mode:"direct"}:(Te(t),Te(n),{mode:"proxy",httpProxy:t?.value??"",httpsProxy:n?.value??"",noProxy:ot(o.NO_PROXY??o.no_proxy)})}function Se(o={}){let e=rt(o.environment);if(e.mode==="direct")return e;let n=(o.createProxyDispatcher??(i=>new z(i)))({httpProxy:e.httpProxy,httpsProxy:e.httpsProxy,noProxy:e.noProxy});return(o.setGlobalDispatcher??T.setGlobalDispatcher)(n),(o.installFetch??st)(),e}function K(o,...e){for(let t of e){let n=o[t]?.trim();if(n)return{name:t,value:n}}}function Te(o){if(!o)return;let e;try{e=new URL(o.value)}catch{throw new Error(`${o.name} must be an http:// or https:// URL.`)}if(e.protocol!=="http:"&&e.protocol!=="https:"||!e.hostname)throw new Error(`${o.name} must be an http:// or https:// URL.`)}function ot(o){let e=[];for(let t of(o??"").split(",")){let n=t.trim();n&&!e.includes(n)&&e.push(n)}for(let t of it)e.includes(t)||e.push(t);return e.join(",")}function st(){T.install?.()}var z=class extends C.Dispatcher{#e=new C.Agent;#t;#n;#i;#r;constructor(e){super(),this.#t=e.httpProxy?new C.ProxyAgent({uri:e.httpProxy}):this.#e,this.#n=e.httpsProxy?e.httpsProxy===e.httpProxy?this.#t:new C.ProxyAgent({uri:e.httpsProxy}):this.#e,this.#i=[...new Set([this.#e,this.#t,this.#n])],this.#r=e.noProxy}dispatch(e,t){let n=new URL(e.origin??"");return at(n,this.#r)?this.#e.dispatch(e,t):(n.protocol==="https:"?this.#n:this.#t).dispatch(e,t)}close(e){let t=Promise.all(this.#i.map(n=>n.close())).then(()=>{});if(!e)return t;t.then(e,e)}destroy(e,t){let n=typeof e=="function"?null:e??null,i=typeof e=="function"?e:t,r=Promise.all(this.#i.map(s=>s.destroy(n))).then(()=>{});if(!i)return r;r.then(i,i)}};function at(o,e){let t=ke(o.hostname),n=Number(o.port)||(o.protocol==="https:"?443:80);for(let i of e.split(/[\s,]+/u)){let r=ut(i);if(r){if(r.hostname==="*")return!0;if(!(r.port!==void 0&&r.port!==n)&&(t===r.hostname||r.includeSubdomains&&t.endsWith(`.${r.hostname}`)))return!0}}return!1}function ut(o){let e=o.trim().toLowerCase();if(!e)return;if(e==="*")return{hostname:"*",includeSubdomains:!0};let t;if(e.startsWith("[")){let r=e.indexOf("]");if(r>0){let s=e.slice(r+1);/^:\d+$/u.test(s)&&(t=Number(s.slice(1))),e=e.slice(1,r)}}else if(e.split(":").length===2){let[r,s]=e.split(":");r&&/^\d+$/u.test(s??"")&&(e=r,t=Number(s))}let n=e.startsWith(".")||e.startsWith("*");e=e.replace(/^\*?\./u,"");let i=ke(e);return i?{hostname:i,port:t,includeSubdomains:n}:void 0}function ke(o){return o.toLowerCase().replace(/^\[|\]$/gu,"")}var Me=250,lt="minimax-code";async function Xt(o={}){let e=o.processRef??process;e.title=lt;let t=re(e.env);if(!(o.supportsNodeVersion??(r=>ee(r)))(e.versions.node)){e.stderr.write(`Minimax Code supports Node.js ${Z}; current version is ${e.versions.node}.
|
|
24
24
|
`),e.exitCode=1;return}let i;try{if((o.configureNetworkProxy??Se)({environment:e.env}),await(o.createProgram??Ee)({version:w,allowStartupEnvironmentSelection:o.allowStartupEnvironmentSelection,launchTui:async({initialPrompt:s,sessionId:l,showSessionPicker:a,continueLatestSession:c,workspaceDir:d,tuiMode:p,lane:u})=>{await(o.launchTui??dt)({version:w,...s?{initialPrompt:s}:{},...l?{sessionId:l}:{},...a?{showSessionPicker:!0}:{},...c?{continueLatestSession:!0}:{},...d?{workspaceDir:d}:{},...p?{tuiMode:p}:{},...u?{lane:u}:{},...t?{resumeDraftAfterLogin:!0}:{}}),i="force"},runExec:async(s,l,a)=>{await(o.runExec??ht)(s,a?{...l,lane:a}:l,w),i="natural"},runAcp:async s=>{await(o.runAcp??pt)(w,s),i="natural"},runLogin:async(s,l,a)=>{let c=o.runLogin??mt;e.stdout.write(`${await c(s,l,a)}
|
|
25
25
|
`),i="natural"},runLogout:async s=>{let l=o.runLogout??ft;e.stdout.write(`${await l(s)}
|
|
26
26
|
`),i="natural"},runUpdate:async()=>{i="natural",await(o.runUpdate??gt)(w)},runProvider:async(s,l)=>{let a=o.runProvider??_t;e.stdout.write(`${await a(s,w,l)}
|
|
27
27
|
`),i="natural"},runPlugin:async(s,l)=>{let a=o.runPlugin??wt;e.stdout.write(`${await a(s,w,l)}
|
|
28
|
-
`),i="natural"}}).parseAsync(e.argv,{from:"node"}),i){let s=typeof e.exitCode=="number"?e.exitCode:0;await Promise.all([
|
|
29
|
-
`),e.exitCode=1}}async function ct(o){let e=ie(o);if(!/better[-_]sqlite3/iu.test(e)||!/Could not locate the bindings file|Cannot find (?:module|package)|NODE_MODULE_VERSION|Module did not self-register/iu.test(e))return e;let{buildMcodePackageManagerCommand:t}=await import("./install-source-
|
|
30
|
-
`)}function
|
|
28
|
+
`),i="natural"}}).parseAsync(e.argv,{from:"node"}),i){let s=typeof e.exitCode=="number"?e.exitCode:0;await Promise.all([Re(e.stdout,o.outputDrainTimeoutMs??Me),Re(e.stderr,o.outputDrainTimeoutMs??Me)]),(o.platform??process.platform)==="win32"&&i==="natural"?e.exitCode=s:e.exit(s)}}catch(r){e.stderr.write(`${await ct(r)}
|
|
29
|
+
`),e.exitCode=1}}async function ct(o){let e=ie(o);if(!/better[-_]sqlite3/iu.test(e)||!/Could not locate the bindings file|Cannot find (?:module|package)|NODE_MODULE_VERSION|Module did not self-register/iu.test(e))return e;let{buildMcodePackageManagerCommand:t}=await import("./install-source-GWYHWTTG.js");return["MCode could not load its native SQLite dependency.","If npm reported blocked install scripts, the installation needs explicit script approval.","Reinstall with the original installer. For npm installations, run:",` ${t("npm-global",w).display} --foreground-scripts`,"",`Original error: ${e}`].join(`
|
|
30
|
+
`)}function Re(o,e){return o.destroyed||o.writableEnded?Promise.resolve():new Promise(t=>{let n=!1,i,r=()=>s(!0),s=(l=!1)=>{n||(n=!0,i&&clearTimeout(i),l||o.off?.("error",r),t())};i=setTimeout(s,e),i.unref?.(),o.once?.("error",r);try{o.write("",l=>s(!!l))}catch{s()}})}async function dt(o){let{launchTui:e}=await import("./launcher-BM4HRRYX.js");await e(o)}async function ht(o,e,t){let{runTuiExecCommand:n}=await import("./run-exec-command-KD5OCRTX.js");await n(o,e,t)}async function pt(o,e){let{runTuiAcpCommand:t}=await import("./run-acp-command-4J3QAQRK.js");await t(o,{},e)}async function mt(o,e=!0,t){let{runTuiLogin:n}=await import("./auth-command-T5DRRUNT.js");return n({region:o,openBrowser:e,lane:t})}async function ft(o){let{runTuiLogout:e}=await import("./auth-command-T5DRRUNT.js");return e({region:o})}async function gt(o){let{runMcodeUpdate:e}=await import("./update-CG3K6TMW.js");await e(o)}async function _t(o,e,t){let{runMcodeProviderCommand:n}=await import("./provider-command-GGEFE5SP.js");return n({request:o,version:e,lane:t})}async function wt(o,e,t){let{runMcodePluginCommand:n}=await import("./plugin-command-OU7V7644.js");return n({request:o,version:e,lane:t})}export{Re as drainTuiOutput,Xt as runTuiCli};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
|
|
2
|
-
import{a as u}from"./chunk-ZQPXBOPP.js";import{a as m,b as g}from"./chunk-
|
|
2
|
+
import{a as u}from"./chunk-ZQPXBOPP.js";import{a as m,b as g}from"./chunk-AULSFRR7.js";import"./chunk-R6GVNV7J.js";import"./chunk-4ESEMCSG.js";import"./chunk-PMTJEVJF.js";import"./chunk-VPHVKGPT.js";import"./chunk-A2CQYOXE.js";import"./chunk-C3JRMX7L.js";import"./chunk-XYXCVIX2.js";import"./chunk-KCTHWRGJ.js";import"./chunk-PPIEC7ZM.js";import"./chunk-X4N2MWNJ.js";import"./chunk-75PL5LYJ.js";import"./chunk-SHXPTUWI.js";import"./chunk-4Y64C4JT.js";import"./chunk-X5PAB4UH.js";import"./chunk-AABEG2OJ.js";import"./chunk-SD6SJL3L.js";import"./chunk-PWQHCWDV.js";import"./chunk-HQ2U4QVQ.js";import{d as s}from"./chunk-HMP2XYHW.js";import"./chunk-WAVNKSSE.js";import"./chunk-DV5WIEGS.js";import"./chunk-ZITT4GJK.js";import"./chunk-2ZG44JU6.js";import"./chunk-Z44TXDGK.js";import"./chunk-CWWDVX6C.js";import"./chunk-IIHJNKC3.js";import"./chunk-3V6OPTHM.js";import"./chunk-LOQ4VVEN.js";import"./chunk-2UWBSJDH.js";import"./chunk-GUFBGYOC.js";import"./chunk-CK62QLTS.js";import"./chunk-WFWSBUYD.js";import"./chunk-D76SO2ME.js";import P from"node:path";async function v(e){let n=e.createContext?await e.createContext(e.lane):await h(e.version,e.lane);try{let a=e.request;if(a.action==="marketplace-list"){let t=[{name:"official",kind:"registry"},{name:"local",kind:"directory",path:P.join(n.dataDir,"plugins")}];return a.json?JSON.stringify(t,null,2):t.map(l=>`${l.name} ${l.kind}${"path"in l?` ${l.path}`:""}`).join(`
|
|
3
3
|
`)}if(a.action==="marketplace-upgrade"){await n.application.refresh();let t={marketplace:"all",refreshed:!0};return a.json?JSON.stringify(t,null,2):"Refreshed all Plugin sources."}if(a.action!=="list"){let{name:t,marketplace:l}=w(a.selector,a.marketplace),o=await n.application.catalog({includeAvailable:a.action==="add",marketplace:l}),r=M(a.action==="add"?[...o.installed,...o.available]:o.installed,t,l),d=a.action==="add"?await n.application.install(r):a.action==="remove"?await n.application.remove(r):await n.application.setEnabled(r,a.action==="enable");return a.json?JSON.stringify(c(d),null,2):f(d)}let i=await n.application.catalog({includeAvailable:!!a.available,marketplace:a.marketplace});return a.json?JSON.stringify({installed:i.installed.map(c),available:i.available.map(c)},null,2):p(i)}finally{await n.shutdown()}}function c(e){return{pluginId:e.pluginId,name:e.name,displayName:e.displayName,marketplaceName:e.marketplace,...e.version?{version:e.version}:{},...e.description?{description:e.description}:{},...e.author?{author:e.author}:{},installed:e.installed,enabled:e.enabled,capabilities:e.capabilities}}function p(e){return[...e.installed,...e.available].map(n=>{let a=n.enabled?"[*]":n.installed?"[-]":"[ ]",i=n.installed?n.enabled?"enabled":"disabled":"available";return`${a} ${n.pluginId} ${i}`}).join(`
|
|
4
4
|
`)}function f(e){return p({installed:e.installed?[e]:[],available:e.installed?[]:[e]})}function w(e,n){let a=/^([^@]+?)(?:@(official|local))?$/.exec(e.trim());if(!a?.[1])throw new Error(`Invalid Plugin selector: ${e}`);let i=a[2];if(i&&n&&i!==n)throw new Error(`Plugin selector marketplace conflicts with --marketplace ${n}.`);return{name:a[1],marketplace:i??n}}function M(e,n,a){let i=e.filter(t=>t.name===n&&(a===void 0||t.marketplace===a));if(i.length===0)throw new Error(`Plugin not found: ${n}${a?`@${a}`:""}`);if(i.length>1)throw new Error(`Plugin ${n} matches multiple marketplaces; use ${n}@official or ${n}@local.`);return i[0]}async function h(e="unknown",n){let a=await s(),i=await m({dataDir:a,workspaceDir:process.cwd(),version:e,surface:"headless",...n?{lane:n}:{}});return{application:new u(i.adapter),dataDir:a,shutdown:async()=>{await g(i)}}}export{v as runMcodePluginCommand};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
|
|
2
|
-
import{a as d}from"./chunk-JCDDI4WJ.js";import"./chunk-I3GV76MP.js";import{a as l,b as c}from"./chunk-
|
|
2
|
+
import{a as d}from"./chunk-JCDDI4WJ.js";import"./chunk-I3GV76MP.js";import{a as l,b as c}from"./chunk-AULSFRR7.js";import"./chunk-R6GVNV7J.js";import"./chunk-4ESEMCSG.js";import"./chunk-PMTJEVJF.js";import"./chunk-VPHVKGPT.js";import{b as t}from"./chunk-A2CQYOXE.js";import"./chunk-C3JRMX7L.js";import"./chunk-XYXCVIX2.js";import"./chunk-KCTHWRGJ.js";import"./chunk-PPIEC7ZM.js";import"./chunk-X4N2MWNJ.js";import"./chunk-75PL5LYJ.js";import"./chunk-SHXPTUWI.js";import"./chunk-4Y64C4JT.js";import"./chunk-X5PAB4UH.js";import"./chunk-AABEG2OJ.js";import"./chunk-SD6SJL3L.js";import"./chunk-PWQHCWDV.js";import"./chunk-HQ2U4QVQ.js";import{d as s}from"./chunk-HMP2XYHW.js";import"./chunk-WAVNKSSE.js";import"./chunk-DV5WIEGS.js";import"./chunk-ZITT4GJK.js";import"./chunk-2ZG44JU6.js";import"./chunk-Z44TXDGK.js";import"./chunk-CWWDVX6C.js";import"./chunk-IIHJNKC3.js";import"./chunk-3V6OPTHM.js";import"./chunk-LOQ4VVEN.js";import"./chunk-2UWBSJDH.js";import"./chunk-GUFBGYOC.js";import"./chunk-CK62QLTS.js";import"./chunk-WFWSBUYD.js";import"./chunk-D76SO2ME.js";async function f(r){let a=r.createContext?await r.createContext(r.lane):await m(r.version,r.workspaceDir,r.lane);try{let{request:e}=r;if(e.action==="list")return p(await a.application.snapshot(),!!e.json);if(e.action==="add"){let n=e.apiKeyEnv?.trim()||"MCODE_PROVIDER_API_KEY",i=(r.environment??process.env)[n]?.trim();if(!i)throw new Error(`Provider API key is missing. Set ${n} or pass --api-key-env <name>.`);return await a.application.create({name:e.name,baseUrl:e.baseUrl,apiKey:i,apiFormat:e.apiFormat,models:e.models.map(o=>({modelId:o})),saveAndUse:e.saveAndUse}),`Provider added: ${e.name}`}if(e.action==="remove"){if(!e.confirmed)throw new Error("Refusing to remove a provider without --yes.");return await a.application.remove(e.providerId),`Provider removed: ${e.providerId}`}if(e.action==="test"){if(e.providerId==="minimax_oauth"){let i="MiniMax OAuth sign-in and connectivity are managed by /login.";return e.json?JSON.stringify({success:!1,status:{state:"unsupported",lastErrorMessage:i}},null,2):t(i,{summary:"MiniMax OAuth provider test skipped.",nextStep:"Run /login to manage Token Plan sign-in."})}let n=await a.application.test(e.providerId,e.modelId);return e.json?JSON.stringify(n,null,2):n.success?`Provider available: ${e.providerId}${e.modelId?`/${e.modelId}`:""}`:t(n.status.lastErrorMessage??n.status.state,{summary:"Provider test failed.",nextStep:"Check the URL, API key, and model ID, then retry."})}if(e.action==="set-minimax-key"){let n=e.apiKeyEnv?.trim()||"MCODE_PROVIDER_API_KEY",i=(r.environment??process.env)[n]?.trim();if(!i)throw new Error(`MiniMax API key is missing. Set ${n} or pass --api-key-env <name>.`);return await a.application.setMiniMaxApiKey(i),"MiniMax API Key saved and selected."}return await a.application.setMiniMaxSource(e.source),e.source==="token_plan"?"Using MiniMax Token Plan.":"Using MiniMax API Key."}finally{await a.shutdown()}}async function m(r,a=process.cwd(),e){let n=await l({dataDir:await s(),workspaceDir:a,version:r,surface:"headless",...e?{lane:e}:{}});return{application:new d(n.adapter),shutdown:async()=>{await c(n)}}}function p(r,a){return a?JSON.stringify(r,null,2):r.providers.map(n=>{let i=n.active?"active":n.enabled?"enabled":"disabled",o=n.kind==="minimax-oauth"?"managed login":n.hasApiKey?n.maskedApiKey??"key saved":"no key";return`${n.active?"*":" "} ${n.providerId} ${i} ${o}`}).join(`
|
|
3
3
|
`)}export{f as runMcodeProviderCommand};
|