makecoder 4.0.59 → 4.0.63

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/dist/cc.mjs CHANGED
@@ -20,13 +20,13 @@ import{createRequire as vP5}from"node:module";var MP5=Object.create;var{getProto
20
20
  Object.assign(A, {
21
21
  post(...args) {
22
22
  const [url, payload, ...remainArgs] = args;
23
- const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.59' + '&session_id=' + I8() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
23
+ const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.63' + '&session_id=' + I8() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
24
24
  if (process.env.CODER_APIKEY) {
25
25
  const headerValues = payload.headers.values;
26
26
  headerValues.set('AUTHORIZATION', `Bearer ${process.env.CODER_APIKEY}`)
27
27
  }
28
28
 
29
- payload.headers.values.set('X-Coder-Version', '4.0.59');
29
+ payload.headers.values.set('X-Coder-Version', '4.0.63');
30
30
  payload.headers.values.set('X-Coder-Platform', process.platform);
31
31
  payload.headers.values.set('X-Coder-Arch', process.arch);
32
32
 
@@ -4082,7 +4082,7 @@ If called outside an EnterWorktree session, the tool is a **no-op**: it reports
4082
4082
  - If a tmux session was attached to the worktree: killed on \`remove\`, left running on \`keep\` (its name is returned so the user can reattach)
4083
4083
  - Once exited, EnterWorktree can be called again to create a fresh worktree
4084
4084
  `}function TvK({action:q}){return q??""}function VvK(q,K,_){let z=q.action==="keep"?"Kept worktree":"Removed worktree";return ST.createElement(_1,null,ST.createElement(u,{flexDirection:"column"},ST.createElement(T,null,z,q.worktreeBranch?ST.createElement(ST.Fragment,null," ","(branch ",ST.createElement(T,{bold:!0},q.worktreeBranch),")"):null),ST.createElement(T,{dimColor:!0},"Returned to ",q.originalCwd)))}var ST;var kvK=L(()=>{GK();g6();ST=K6(P6(),1)});async function NvK(q,K){let _=await w1("git",["-C",q,"status","--porcelain"]);if(_.code!==0)return null;let z=w7(_.stdout.split(`
4085
- `),(O)=>O.trim()!=="");if(!K)return null;let Y=await w1("git",["-C",q,"rev-list","--count",`${K}..HEAD`]);if(Y.code!==0)return null;let A=parseInt(Y.stdout.trim(),10)||0;return{changedFiles:z,commits:A}}function EvK(q,K){if(l$(q),dL(q),K)pB6(q),KR6();zL(null),nc(),Lk(),aO.cache.clear?.()}var IjY,xjY,yvK;var LvK=L(()=>{p7();y8();OR6();C8();gq();PM();n7();Q4();Bc();NJ();$G();g4();tD();kvK();IjY=C6(()=>y.strictObject({action:y.enum(["keep","remove"]).describe('"keep" leaves the worktree and branch on disk; "remove" deletes both.'),discard_changes:y.boolean().optional().describe('Required true when action is "remove" and the worktree has uncommitted files or unmerged commits. The tool will refuse and list them otherwise.')})),xjY=C6(()=>y.object({action:y.enum(["keep","remove"]),originalCwd:y.string(),worktreePath:y.string(),worktreeBranch:y.string().optional(),tmuxSessionName:y.string().optional(),discardedFiles:y.number().optional(),discardedCommits:y.number().optional(),message:y.string()}));yvK=Iq({name:AI8,searchHint:"exit a worktree session and return to the original directory",maxResultSizeChars:1e5,async description(){return"Exits a worktree session created by EnterWorktree and restores the original working directory"},async prompt(){return vvK()},get inputSchema(){return IjY()},get outputSchema(){return xjY()},userFacingName(){return"Exiting worktree"},shouldDefer:!0,isDestructive(q){return q.action==="remove"},toAutoClassifierInput(q){return q.action},async validateInput(q){if(Sf6())return{result:!1,message:'ExitWorktree cannot be called from a subagent with a cwd override (isolation: "worktree" or explicit cwd) — it would mutate the parent session\'s process-wide working directory. This agent is already isolated; use Bash with `cd` for directory changes within it.',errorCode:5};let K=sO();if(!K)return{result:!1,message:"No-op: there is no active EnterWorktree session to exit. This tool only operates on worktrees created by EnterWorktree in the current session — it will not touch worktrees created manually or in a previous session. No filesystem changes were made.",errorCode:1};if(q.action==="remove"&&K.enteredExisting)return{result:!1,message:`This session entered an existing worktree (${K.worktreePath}); it was not created by EnterWorktree, so this tool will not remove it. Use action: "keep" to return to ${K.originalCwd}, then remove the worktree manually with \`git worktree remove\` if desired.`,errorCode:4};if(q.action==="remove"&&!q.discard_changes){let _=await NvK(K.worktreePath,K.originalHeadCommit);if(_===null)return{result:!1,message:`Could not verify worktree state at ${K.worktreePath}. Refusing to remove without explicit confirmation. Re-invoke with discard_changes: true to proceed — or use action: "keep" to preserve the worktree.`,errorCode:3};let{changedFiles:z,commits:Y}=_;if(z>0||Y>0){let A=[];if(z>0)A.push(`${z} uncommitted ${z===1?"file":"files"}`);if(Y>0)A.push(`${Y} ${Y===1?"commit":"commits"} on ${K.worktreeBranch??"the worktree branch"}`);return{result:!1,message:`Worktree has ${A.join(" and ")}. Removing will discard this work permanently. Confirm with the user, then re-invoke with discard_changes: true — or use action: "keep" to preserve the worktree.`,errorCode:2}}}return{result:!0}},renderToolUseMessage:TvK,renderToolResultMessage:VvK,async call(q){let K=sO();if(!K)throw Error("Not in a worktree session");let{originalCwd:_,worktreePath:z,worktreeBranch:Y,tmuxSessionName:A,originalHeadCommit:O}=K,w=c9()===Y7(),{changedFiles:$,commits:j}=await NvK(z,O)??{changedFiles:0,commits:0};if(q.action==="keep"){await hM6(),EvK(_,w),d("tengu_worktree_kept",{mid_session:!0,commits:j,changed_files:$});let X=A?` Tmux session ${A} is still running; reattach with: tmux attach -t ${A}`:"";return{data:{action:"keep",originalCwd:_,worktreePath:z,worktreeBranch:Y,tmuxSessionName:A,message:`Exited worktree. Your work is preserved at ${z}${Y?` on branch ${Y}`:""}. Session is now back in ${_}.${X}`}}}if(A)await AI6(A);await OI6(),EvK(_,w),d("tengu_worktree_removed",{source:"exit_tool",mid_session:!0,commits:j,changed_files:$});let H=[];if(j>0)H.push(`${j} ${j===1?"commit":"commits"}`);if($>0)H.push(`${$} uncommitted ${$===1?"file":"files"}`);let J=H.length>0?` Discarded ${H.join(" and ")}.`:"";return{data:{action:"remove",originalCwd:_,worktreePath:z,worktreeBranch:Y,discardedFiles:$,discardedCommits:j,message:`Exited and removed worktree at ${z}.${J} Session is now back in ${_}.`}}},mapToolResultToToolResultBlockParam({message:q},K){return{type:"tool_result",content:q,tool_use_id:K}}})});var hvK="Config";function Td8(q=!1){if(i7())return{value:null,label:"Default (recommended)",description:uT6(q)};let K=!KA();return{value:null,label:K?"Default":"Default (recommended)",description:`Use the default model (currently ${Hn6(hv())})${K?"":` · ${Yf(GQ)}`}`}}function ujY(){let q=!KA(),K=process.env.ANTHROPIC_DEFAULT_SONNET_MODEL;if(q&&K){let _=DP(K);return{value:"sonnet",label:process.env.ANTHROPIC_DEFAULT_SONNET_MODEL_NAME??K,description:process.env.ANTHROPIC_DEFAULT_SONNET_MODEL_DESCRIPTION??`Custom Sonnet model${_?" (1M context)":""}`,descriptionForModel:`${process.env.ANTHROPIC_DEFAULT_SONNET_MODEL_DESCRIPTION??`Custom Sonnet model${_?" with 1M context":""}`} (${K})`}}}function mjY(){let q=!KA();return{value:q?ZO().sonnet46:"sonnet",label:"Sonnet",description:`Sonnet 4.6 · Best for everyday tasks${q?"":` · ${Yf(GQ)}`}`,descriptionForModel:"Sonnet 4.6 - best for everyday tasks. Generally recommended for most coding tasks"}}function BjY(){let q=!KA(),K=process.env.ANTHROPIC_DEFAULT_OPUS_MODEL;if(q&&K){let _=DP(K);return{value:"opus",label:process.env.ANTHROPIC_DEFAULT_OPUS_MODEL_NAME??K,description:process.env.ANTHROPIC_DEFAULT_OPUS_MODEL_DESCRIPTION??`Custom Opus model${_?" (1M context)":""}`,descriptionForModel:`${process.env.ANTHROPIC_DEFAULT_OPUS_MODEL_DESCRIPTION??`Custom Opus model${_?" with 1M context":""}`} (${K})`}}}function pjY(){return{value:"opus",label:"Opus 4.1",description:"Opus 4.1 · Legacy",descriptionForModel:"Opus 4.1 - legacy version"}}function uvK(q=!1,K=!0){return{value:!KA()?ZO().opus46:"claude-opus-4-6",label:"Opus 4.6",description:`Opus 4.6 · Most capable for complex work${K?QZ8(q):""}`,descriptionForModel:"Opus 4.6 - most capable for complex work"}}function RvK(){let q=!KA();return{value:q?ZO().opus47:"opus",label:"Opus",description:`Opus 4.7 · Most capable for complex work${q?"":` · ${Yf(jB)}`}`,descriptionForModel:"Opus 4.7 - most capable for complex work"}}function SvK(){let q=!KA();return{value:q?ZO().sonnet46+"[1m]":"sonnet[1m]",label:"Sonnet (1M context)",description:`Sonnet 4.6 for long sessions${q?"":` · ${Yf(GQ)}`}`,descriptionForModel:"Sonnet 4.6 with 1M context window - for long sessions with large codebases"}}function mvK(q=!1,K=!0){return{value:!KA()?ZO().opus46+"[1m]":"claude-opus-4-6[1m]",label:"Opus 4.6 (1M context)",description:`Opus 4.6 for long sessions${K?QZ8(q):""}`,descriptionForModel:"Opus 4.6 with 1M context window - for long sessions with large codebases"}}function CvK(){let q=!KA();return{value:q?ZO().opus47+"[1m]":"opus[1m]",label:"Opus (1M context)",description:`Opus 4.7 for long sessions${q?"":` · ${Yf(jB)}`}`,descriptionForModel:"Opus 4.7 with 1M context window - for long sessions with large codebases"}}function FjY(){let q=!KA(),K=process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL;if(q&&K)return{value:"haiku",label:process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME??K,description:process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL_DESCRIPTION??"Custom Haiku model",descriptionForModel:`${process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL_DESCRIPTION??"Custom Haiku model"} (${K})`}}function BvK(){return{value:"haiku",label:"Haiku",description:`Haiku 4.5 · Fastest for quick answers${!KA()?"":` · ${Yf(_T1)}`}`,descriptionForModel:"Haiku 4.5 - fastest for quick answers. Lower cost but less capable than Sonnet 4.6."}}function gjY(){return{value:"haiku",label:"Haiku",description:`Haiku 3.5 for simple tasks${!KA()?"":` · ${Yf(KT1)}`}`,descriptionForModel:"Haiku 3.5 - faster and lower cost, but less capable than Sonnet. Use for simple tasks."}}function UjY(){return xT6()===ZO().haiku45?BvK():gjY()}function k37(){if(MK()==="pro"&&u8("tengu_gypsum_kite",!1))return" · ~2× usage vs Sonnet";return""}function pvK(q=!1){let K=!KA();return{value:"opus",label:"Opus",description:`Opus 4.7 · Most capable for complex work${k37()}${K||!q?"":` · ${Yf(jB)}`}`}}function bvK(){let q=!KA(),K=i7()?" · Billed as extra usage":"";return{value:"sonnet[1m]",label:"Sonnet (1M context)",description:`Sonnet 4.6 with 1M context${K}${!(K!==""&&!q)?"":` · ${Yf(GQ)}`}`}}function IvK(){let q=!KA(),K=i7()?" · Billed as extra usage":"",_=K!==""&&!q;return{value:"opus[1m]",label:"Opus (1M context)",description:`Opus 4.7 with 1M context${k37()}${K}${!_?"":` · ${Yf(jB)}`}`}}function V37(q=!1){let K=!KA();return{value:K?ZO().opus47+"[1m]":"opus[1m]",label:"Opus (1M context)",description:`Opus 4.7 with 1M context · Most capable for complex work${k37()}${K||!q?"":` · ${Yf(jB)}`}`,descriptionForModel:"Opus 4.7 with 1M context - most capable for complex work"}}function djY(){return{value:"opusplan",label:"Opus Plan Mode",description:"Use Opus in plan mode, Sonnet otherwise"}}function cjY(q=!1){if(i7()){if(ch()||Yq6()){let O=[Td8(q)];if(!YX()&&Ql())O.push(IvK());if(O.push(QjY),rt())O.push(bvK());return O.push(xvK),O}let A=[Td8(q)];if(rt())A.push(bvK());if(YX())A.push(V37(!1));else if(A.push(pvK(!1)),Ql())A.push(IvK());return A.push(xvK),A}if(KA()){let A=[Td8(q)];if(rt())A.push(SvK());if(YX())A.push(V37(!0));else if(A.push(RvK()),Ql())A.push(CvK());return A.push(BvK()),A}let K=[Td8(q)],_=ujY();if(_!==void 0)K.push(_);else if(K.push(mjY()),rt())K.push(SvK());let z=BjY();if(z!==void 0)K.push(z);else{if(K.push(pjY()),K.push(RvK()),Ql())K.push(CvK());if(K.push(uvK(q,!1)),Ql())K.push(mvK(q))}let Y=FjY();if(Y!==void 0)K.push(Y);else K.push(UjY());return K}function ljY(q){let K=o5(q);if(K.includes("claude-sonnet-4-6")||K.includes("claude-sonnet-4-5")||K.includes("claude-sonnet-4-")||K.includes("claude-3-7-sonnet")||K.includes("claude-3-5-sonnet")){let _=xW(Af());if(_)return{alias:"Sonnet",currentVersionName:_}}if(K.includes("claude-opus-4")){let _=xW(LE());if(_)return{alias:"Opus",currentVersionName:_}}if(K.includes("claude-haiku")||K.includes("claude-3-5-haiku")){let _=xW(xT6());if(_)return{alias:"Haiku",currentVersionName:_}}return null}function njY(q){let K=xW(q);if(!K)return null;let _=ljY(q);if(!_)return{value:q,label:K,description:q};if(K!==_.currentVersionName)return{value:q,label:K,description:`Newer version available · select ${_.alias} for ${_.currentVersionName}`};return{value:q,label:K,description:q}}function q_6(q=!1){const _cache=H8().additionalModelOptionsCache;if(_cache&&_cache.length>0)return _cache;let K=cjY(q),_=process.env.ANTHROPIC_CUSTOM_MODEL_OPTION;if(_&&!K.some((w)=>w.value===_))K.push({value:_,label:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME??_,description:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION??`Custom model (${_})`});for(let w of H8().additionalModelOptionsCache??[])if(!K.some(($)=>$.value===w.value))K.push(w);let{availableModels:z}=y7()??{};if(z)for(let w of z){let $=w.trim();if(!$.startsWith("anthropic.")||K.some((j)=>j.value===$))continue;K.push({value:$,label:$,description:"Custom model"})}let Y=null,A=Ub(),O=cB6();if(A!==void 0&&A!==null)Y=A;else if(O!==null)Y=O;if(Y===null||K.some((w)=>w.value===Y))return RM6(K);else if(Y==="opusplan")return RM6([...K,djY()]);else if(Y==="opus"&&KA())return RM6([...K,pvK(!1)]);else if(Y==="opus[1m]"&&KA())return RM6([...K,V37(!1)]);else if(Y==="claude-opus-4-6"&&KA())return RM6([...K,uvK(q,!1)]);else if(Y==="claude-opus-4-6[1m]"&&KA())return RM6([...K,mvK(q,!1)]);else{let w=njY(Y);if(w)K.push(w);else K.push({value:Y,label:Y,description:"Custom model"});return RM6(K)}}function RM6(q){if(!(y7()||{}).availableModels)return q;return q.filter((_)=>_.value===null||_.value!==null&&Kq6(_.value))}var QjY,xvK;var s58=L(()=>{y8();B1();T7();jQ();fo();a1();bg8();x9();jn6();Sq();AJ();h1();QjY={value:"sonnet",label:"Sonnet",description:"Sonnet 4.6 · Best for everyday tasks"},xvK={value:"haiku",label:"Haiku",description:"Haiku 4.5 · Fastest for quick answers"}});var N37={};h8(N37,{isVoiceModeEnabled:()=>SM6,isVoiceGrowthBookEnabled:()=>K_6,hasVoiceAuth:()=>Vd8});function K_6(){return!u8("tengu_amber_quartz_disabled",!1)}function Vd8(){if(!jX())return!1;let q=o7();return Boolean(q?.accessToken)}function SM6(){return Vd8()&&K_6()}var __6=L(()=>{B1();T7()});async function wI6(q){let K=q.trim();if(!K)return{valid:!1,error:"Model name cannot be empty"};if(!Kq6(K))return{valid:!1,error:`Model '${K}' is not in the list of available models`};let _=K.toLowerCase();if(Yw6.includes(_))return{valid:!0};if(K===process.env.ANTHROPIC_CUSTOM_MODEL_OPTION)return{valid:!0};if(FvK.has(K))return{valid:!0};try{return await dR({model:K,max_tokens:1,maxRetries:0,querySource:"model_validation",messages:[{role:"user",content:[{type:"text",text:"Hi",cache_control:{type:"ephemeral"}}]}]}),FvK.set(K,!0),{valid:!0}}catch(z){return ijY(z,K)}}function ijY(q,K){if(q instanceof fY6){let z=rjY(K),Y=z?`. Try '${z}' instead`:"";return{valid:!1,error:`Model '${K}' not found${Y}`}}if(q instanceof vq){if(q instanceof ZY6)return{valid:!1,error:"Authentication failed. Please check your API credentials."};if(q instanceof bZ)return{valid:!1,error:"Network error. Please check your internet connection."};let z=q.error;if(z&&typeof z==="object"&&"type"in z&&z.type==="not_found_error"&&"message"in z&&typeof z.message==="string"&&z.message.includes("model:"))return{valid:!1,error:`Model '${K}' not found`};return{valid:!1,error:`API error: ${q.message}`}}return{valid:!1,error:`Unable to validate model: ${q instanceof Error?q.message:String(q)}`}}function rjY(q){if(KA())return;let K=q.toLowerCase();if(K.includes("opus-4-7")||K.includes("opus_4_7"))return ZO().opus41;if(K.includes("opus-4-6")||K.includes("opus_4_6"))return ZO().opus41;if(K.includes("opus-4-5")||K.includes("opus_4_5"))return ZO().opus41;if(K.includes("sonnet-4-6")||K.includes("sonnet_4_6"))return ZO().sonnet45;if(K.includes("sonnet-4-5")||K.includes("sonnet_4_5"))return ZO().sonnet40;return}var FvK;var kd8=L(()=>{IT6();jn6();x9();tH6();eG();jQ();FvK=new Map});function gvK(q){return q in $I6}function UvK(q){return $I6[q]}function Nd8(q){let K=$I6[q];if(!K)return;if(K.options)return[...K.options];if(K.getOptions)return K.getOptions();return}function QvK(q){return $I6[q]?.path??q.split(".")}var $I6;var y37=L(()=>{h1();$b1();s58();kd8();tB();$I6={theme:{source:"global",type:"string",description:"Color theme for the UI",options:ZY4},editorMode:{source:"global",type:"string",description:"Key binding mode",options:Ck8},verbose:{source:"global",type:"boolean",description:"Show detailed debug output",appStateKey:"verbose"},preferredNotifChannel:{source:"global",type:"string",description:"Preferred notification channel",options:Sk8},autoCompactEnabled:{source:"global",type:"boolean",description:"Auto-compact when context is full"},autoScrollEnabled:{source:"global",type:"boolean",description:"Auto-scroll conversation to bottom (fullscreen mode only)"},autoMemoryEnabled:{source:"settings",type:"boolean",description:"Enable auto-memory"},autoDreamEnabled:{source:"settings",type:"boolean",description:"Enable background memory consolidation"},fileCheckpointingEnabled:{source:"global",type:"boolean",description:"Enable file checkpointing for code rewind"},showTurnDuration:{source:"global",type:"boolean",description:'Show turn duration message after responses (e.g., "Cooked for 1m 6s")'},terminalProgressBarEnabled:{source:"global",type:"boolean",description:"Show OSC 9;4 progress indicator in supported terminals"},todoFeatureEnabled:{source:"global",type:"boolean",description:"Enable todo/task tracking"},model:{source:"settings",type:"string",description:"Override the default model",appStateKey:"mainLoopModel",getOptions:()=>{try{return q_6().filter((q)=>q.value!==null).map((q)=>q.value)}catch{return["sonnet","opus","haiku"]}},validateOnWrite:(q)=>wI6(String(q)),formatOnRead:(q)=>q===null?"default":q},alwaysThinkingEnabled:{source:"settings",type:"boolean",description:"Enable extended thinking (false to disable)",appStateKey:"thinkingEnabled"},"permissions.defaultMode":{source:"settings",type:"string",description:"Default permission mode for tool usage",options:["default","plan","acceptEdits","dontAsk","auto"]},language:{source:"settings",type:"string",description:'Preferred language for Claude responses and voice dictation (e.g., "japanese", "spanish")'},teammateMode:{source:"global",type:"string",description:'How to spawn teammates: "tmux" for traditional tmux, "in-process" for same process, "auto" to choose automatically',options:Nq4},tui:{source:"settings",type:"string",description:'Terminal UI renderer: "fullscreen" for flicker-free alt-screen rendering, "default" for the classic renderer',options:["default","fullscreen"]},...!1,...{voiceEnabled:{source:"settings",type:"boolean",description:"Enable voice dictation (hold-to-talk)"}},remoteControlAtStartup:{source:"global",type:"boolean",description:"Enable Remote Control for all sessions (true | false | default)",formatOnRead:()=>zd()},...{inputNeededNotifEnabled:{source:"global",type:"boolean",description:"Push to your mobile device when a permission prompt or question is waiting (requires Remote Control)"},agentPushNotifEnabled:{source:"global",type:"boolean",description:"Allow Claude to push to your mobile device when it deems it appropriate (requires Remote Control)"}}}});function cvK(){let q=[],K=[];for(let[z,Y]of Object.entries($I6)){if(z==="model")continue;if(z==="voiceEnabled"&&!K_6())continue;let A=Nd8(z),O=`- ${z}`;if(A)O+=`: ${A.map((w)=>`"${w}"`).join(", ")}`;else if(Y.type==="boolean")O+=": true/false";if(O+=` - ${Y.description}`,Y.source==="global")q.push(O);else K.push(O)}let _=ojY();return`Get or set Claude Code configuration settings.
4085
+ `),(O)=>O.trim()!=="");if(!K)return null;let Y=await w1("git",["-C",q,"rev-list","--count",`${K}..HEAD`]);if(Y.code!==0)return null;let A=parseInt(Y.stdout.trim(),10)||0;return{changedFiles:z,commits:A}}function EvK(q,K){if(l$(q),dL(q),K)pB6(q),KR6();zL(null),nc(),Lk(),aO.cache.clear?.()}var IjY,xjY,yvK;var LvK=L(()=>{p7();y8();OR6();C8();gq();PM();n7();Q4();Bc();NJ();$G();g4();tD();kvK();IjY=C6(()=>y.strictObject({action:y.enum(["keep","remove"]).describe('"keep" leaves the worktree and branch on disk; "remove" deletes both.'),discard_changes:y.boolean().optional().describe('Required true when action is "remove" and the worktree has uncommitted files or unmerged commits. The tool will refuse and list them otherwise.')})),xjY=C6(()=>y.object({action:y.enum(["keep","remove"]),originalCwd:y.string(),worktreePath:y.string(),worktreeBranch:y.string().optional(),tmuxSessionName:y.string().optional(),discardedFiles:y.number().optional(),discardedCommits:y.number().optional(),message:y.string()}));yvK=Iq({name:AI8,searchHint:"exit a worktree session and return to the original directory",maxResultSizeChars:1e5,async description(){return"Exits a worktree session created by EnterWorktree and restores the original working directory"},async prompt(){return vvK()},get inputSchema(){return IjY()},get outputSchema(){return xjY()},userFacingName(){return"Exiting worktree"},shouldDefer:!0,isDestructive(q){return q.action==="remove"},toAutoClassifierInput(q){return q.action},async validateInput(q){if(Sf6())return{result:!1,message:'ExitWorktree cannot be called from a subagent with a cwd override (isolation: "worktree" or explicit cwd) — it would mutate the parent session\'s process-wide working directory. This agent is already isolated; use Bash with `cd` for directory changes within it.',errorCode:5};let K=sO();if(!K)return{result:!1,message:"No-op: there is no active EnterWorktree session to exit. This tool only operates on worktrees created by EnterWorktree in the current session — it will not touch worktrees created manually or in a previous session. No filesystem changes were made.",errorCode:1};if(q.action==="remove"&&K.enteredExisting)return{result:!1,message:`This session entered an existing worktree (${K.worktreePath}); it was not created by EnterWorktree, so this tool will not remove it. Use action: "keep" to return to ${K.originalCwd}, then remove the worktree manually with \`git worktree remove\` if desired.`,errorCode:4};if(q.action==="remove"&&!q.discard_changes){let _=await NvK(K.worktreePath,K.originalHeadCommit);if(_===null)return{result:!1,message:`Could not verify worktree state at ${K.worktreePath}. Refusing to remove without explicit confirmation. Re-invoke with discard_changes: true to proceed — or use action: "keep" to preserve the worktree.`,errorCode:3};let{changedFiles:z,commits:Y}=_;if(z>0||Y>0){let A=[];if(z>0)A.push(`${z} uncommitted ${z===1?"file":"files"}`);if(Y>0)A.push(`${Y} ${Y===1?"commit":"commits"} on ${K.worktreeBranch??"the worktree branch"}`);return{result:!1,message:`Worktree has ${A.join(" and ")}. Removing will discard this work permanently. Confirm with the user, then re-invoke with discard_changes: true — or use action: "keep" to preserve the worktree.`,errorCode:2}}}return{result:!0}},renderToolUseMessage:TvK,renderToolResultMessage:VvK,async call(q){let K=sO();if(!K)throw Error("Not in a worktree session");let{originalCwd:_,worktreePath:z,worktreeBranch:Y,tmuxSessionName:A,originalHeadCommit:O}=K,w=c9()===Y7(),{changedFiles:$,commits:j}=await NvK(z,O)??{changedFiles:0,commits:0};if(q.action==="keep"){await hM6(),EvK(_,w),d("tengu_worktree_kept",{mid_session:!0,commits:j,changed_files:$});let X=A?` Tmux session ${A} is still running; reattach with: tmux attach -t ${A}`:"";return{data:{action:"keep",originalCwd:_,worktreePath:z,worktreeBranch:Y,tmuxSessionName:A,message:`Exited worktree. Your work is preserved at ${z}${Y?` on branch ${Y}`:""}. Session is now back in ${_}.${X}`}}}if(A)await AI6(A);await OI6(),EvK(_,w),d("tengu_worktree_removed",{source:"exit_tool",mid_session:!0,commits:j,changed_files:$});let H=[];if(j>0)H.push(`${j} ${j===1?"commit":"commits"}`);if($>0)H.push(`${$} uncommitted ${$===1?"file":"files"}`);let J=H.length>0?` Discarded ${H.join(" and ")}.`:"";return{data:{action:"remove",originalCwd:_,worktreePath:z,worktreeBranch:Y,discardedFiles:$,discardedCommits:j,message:`Exited and removed worktree at ${z}.${J} Session is now back in ${_}.`}}},mapToolResultToToolResultBlockParam({message:q},K){return{type:"tool_result",content:q,tool_use_id:K}}})});var hvK="Config";function Td8(q=!1){if(i7())return{value:null,label:"Default (recommended)",description:uT6(q)};let K=!KA();return{value:null,label:K?"Default":"Default (recommended)",description:`Use the default model (currently ${Hn6(hv())})${K?"":` · ${Yf(GQ)}`}`}}function ujY(){let q=!KA(),K=process.env.ANTHROPIC_DEFAULT_SONNET_MODEL;if(q&&K){let _=DP(K);return{value:"sonnet",label:process.env.ANTHROPIC_DEFAULT_SONNET_MODEL_NAME??K,description:process.env.ANTHROPIC_DEFAULT_SONNET_MODEL_DESCRIPTION??`Custom Sonnet model${_?" (1M context)":""}`,descriptionForModel:`${process.env.ANTHROPIC_DEFAULT_SONNET_MODEL_DESCRIPTION??`Custom Sonnet model${_?" with 1M context":""}`} (${K})`}}}function mjY(){let q=!KA();return{value:q?ZO().sonnet46:"sonnet",label:"Sonnet",description:`Sonnet 4.6 · Best for everyday tasks${q?"":` · ${Yf(GQ)}`}`,descriptionForModel:"Sonnet 4.6 - best for everyday tasks. Generally recommended for most coding tasks"}}function BjY(){let q=!KA(),K=process.env.ANTHROPIC_DEFAULT_OPUS_MODEL;if(q&&K){let _=DP(K);return{value:"opus",label:process.env.ANTHROPIC_DEFAULT_OPUS_MODEL_NAME??K,description:process.env.ANTHROPIC_DEFAULT_OPUS_MODEL_DESCRIPTION??`Custom Opus model${_?" (1M context)":""}`,descriptionForModel:`${process.env.ANTHROPIC_DEFAULT_OPUS_MODEL_DESCRIPTION??`Custom Opus model${_?" with 1M context":""}`} (${K})`}}}function pjY(){return{value:"opus",label:"Opus 4.1",description:"Opus 4.1 · Legacy",descriptionForModel:"Opus 4.1 - legacy version"}}function uvK(q=!1,K=!0){return{value:!KA()?ZO().opus46:"claude-opus-4-6",label:"Opus 4.6",description:`Opus 4.6 · Most capable for complex work${K?QZ8(q):""}`,descriptionForModel:"Opus 4.6 - most capable for complex work"}}function RvK(){let q=!KA();return{value:q?ZO().opus47:"opus",label:"Opus",description:`Opus 4.7 · Most capable for complex work${q?"":` · ${Yf(jB)}`}`,descriptionForModel:"Opus 4.7 - most capable for complex work"}}function SvK(){let q=!KA();return{value:q?ZO().sonnet46+"[1m]":"sonnet[1m]",label:"Sonnet (1M context)",description:`Sonnet 4.6 for long sessions${q?"":` · ${Yf(GQ)}`}`,descriptionForModel:"Sonnet 4.6 with 1M context window - for long sessions with large codebases"}}function mvK(q=!1,K=!0){return{value:!KA()?ZO().opus46+"[1m]":"claude-opus-4-6[1m]",label:"Opus 4.6 (1M context)",description:`Opus 4.6 for long sessions${K?QZ8(q):""}`,descriptionForModel:"Opus 4.6 with 1M context window - for long sessions with large codebases"}}function CvK(){let q=!KA();return{value:q?ZO().opus47+"[1m]":"opus[1m]",label:"Opus (1M context)",description:`Opus 4.7 for long sessions${q?"":` · ${Yf(jB)}`}`,descriptionForModel:"Opus 4.7 with 1M context window - for long sessions with large codebases"}}function FjY(){let q=!KA(),K=process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL;if(q&&K)return{value:"haiku",label:process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL_NAME??K,description:process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL_DESCRIPTION??"Custom Haiku model",descriptionForModel:`${process.env.ANTHROPIC_DEFAULT_HAIKU_MODEL_DESCRIPTION??"Custom Haiku model"} (${K})`}}function BvK(){return{value:"haiku",label:"Haiku",description:`Haiku 4.5 · Fastest for quick answers${!KA()?"":` · ${Yf(_T1)}`}`,descriptionForModel:"Haiku 4.5 - fastest for quick answers. Lower cost but less capable than Sonnet 4.6."}}function gjY(){return{value:"haiku",label:"Haiku",description:`Haiku 3.5 for simple tasks${!KA()?"":` · ${Yf(KT1)}`}`,descriptionForModel:"Haiku 3.5 - faster and lower cost, but less capable than Sonnet. Use for simple tasks."}}function UjY(){return xT6()===ZO().haiku45?BvK():gjY()}function k37(){if(MK()==="pro"&&u8("tengu_gypsum_kite",!1))return" · ~2× usage vs Sonnet";return""}function pvK(q=!1){let K=!KA();return{value:"opus",label:"Opus",description:`Opus 4.7 · Most capable for complex work${k37()}${K||!q?"":` · ${Yf(jB)}`}`}}function bvK(){let q=!KA(),K=i7()?" · Billed as extra usage":"";return{value:"sonnet[1m]",label:"Sonnet (1M context)",description:`Sonnet 4.6 with 1M context${K}${!(K!==""&&!q)?"":` · ${Yf(GQ)}`}`}}function IvK(){let q=!KA(),K=i7()?" · Billed as extra usage":"",_=K!==""&&!q;return{value:"opus[1m]",label:"Opus (1M context)",description:`Opus 4.7 with 1M context${k37()}${K}${!_?"":` · ${Yf(jB)}`}`}}function V37(q=!1){let K=!KA();return{value:K?ZO().opus47+"[1m]":"opus[1m]",label:"Opus (1M context)",description:`Opus 4.7 with 1M context · Most capable for complex work${k37()}${K||!q?"":` · ${Yf(jB)}`}`,descriptionForModel:"Opus 4.7 with 1M context - most capable for complex work"}}function djY(){return{value:"opusplan",label:"Opus Plan Mode",description:"Use Opus in plan mode, Sonnet otherwise"}}function cjY(q=!1){if(i7()){if(ch()||Yq6()){let O=[Td8(q)];if(!YX()&&Ql())O.push(IvK());if(O.push(QjY),rt())O.push(bvK());return O.push(xvK),O}let A=[Td8(q)];if(rt())A.push(bvK());if(YX())A.push(V37(!1));else if(A.push(pvK(!1)),Ql())A.push(IvK());return A.push(xvK),A}if(KA()){let A=[Td8(q)];if(rt())A.push(SvK());if(YX())A.push(V37(!0));else if(A.push(RvK()),Ql())A.push(CvK());return A.push(BvK()),A}let K=[Td8(q)],_=ujY();if(_!==void 0)K.push(_);else if(K.push(mjY()),rt())K.push(SvK());let z=BjY();if(z!==void 0)K.push(z);else{if(K.push(pjY()),K.push(RvK()),Ql())K.push(CvK());if(K.push(uvK(q,!1)),Ql())K.push(mvK(q))}let Y=FjY();if(Y!==void 0)K.push(Y);else K.push(UjY());return K}function ljY(q){let K=o5(q);if(K.includes("claude-sonnet-4-6")||K.includes("claude-sonnet-4-5")||K.includes("claude-sonnet-4-")||K.includes("claude-3-7-sonnet")||K.includes("claude-3-5-sonnet")){let _=xW(Af());if(_)return{alias:"Sonnet",currentVersionName:_}}if(K.includes("claude-opus-4")){let _=xW(LE());if(_)return{alias:"Opus",currentVersionName:_}}if(K.includes("claude-haiku")||K.includes("claude-3-5-haiku")){let _=xW(xT6());if(_)return{alias:"Haiku",currentVersionName:_}}return null}function njY(q){let K=xW(q);if(!K)return null;let _=ljY(q);if(!_)return{value:q,label:K,description:q};if(K!==_.currentVersionName)return{value:q,label:K,description:`Newer version available · select ${_.alias} for ${_.currentVersionName}`};return{value:q,label:K,description:q}}function q_6(q=!1){let K=cjY(q);const _cache=H8().additionalModelOptionsCache;if(_cache&&_cache.length>0)K=[..._cache];let _skipCache=_cache&&_cache.length>0,_=process.env.ANTHROPIC_CUSTOM_MODEL_OPTION;if(_&&!K.some((w)=>w.value===_))K.push({value:_,label:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME??_,description:process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION??`Custom model (${_})`});for(let w of (_skipCache?[]:H8().additionalModelOptionsCache??[]))if(!K.some(($)=>$.value===w.value))K.push(w);let{availableModels:z}=y7()??{};if(z)for(let w of z){let $=w.trim();if(!$.startsWith("anthropic.")||K.some((j)=>j.value===$))continue;K.push({value:$,label:$,description:"Custom model"})}let Y=null,A=Ub(),O=cB6();if(A!==void 0&&A!==null)Y=A;else if(O!==null)Y=O;if(Y===null||K.some((w)=>w.value===Y))return RM6(K);else if(Y==="opusplan")return RM6([...K,djY()]);else if(Y==="opus"&&KA())return RM6([...K,pvK(!1)]);else if(Y==="opus[1m]"&&KA())return RM6([...K,V37(!1)]);else if(Y==="claude-opus-4-6"&&KA())return RM6([...K,uvK(q,!1)]);else if(Y==="claude-opus-4-6[1m]"&&KA())return RM6([...K,mvK(q,!1)]);else{let w=njY(Y);if(w)K.push(w);else K.push({value:Y,label:Y,description:"Custom model"});return RM6(K)}}function RM6(q){if(!(y7()||{}).availableModels)return q;return q.filter((_)=>_.value===null||_.value!==null&&Kq6(_.value))}var QjY,xvK;var s58=L(()=>{y8();B1();T7();jQ();fo();a1();bg8();x9();jn6();Sq();AJ();h1();QjY={value:"sonnet",label:"Sonnet",description:"Sonnet 4.6 · Best for everyday tasks"},xvK={value:"haiku",label:"Haiku",description:"Haiku 4.5 · Fastest for quick answers"}});var N37={};h8(N37,{isVoiceModeEnabled:()=>SM6,isVoiceGrowthBookEnabled:()=>K_6,hasVoiceAuth:()=>Vd8});function K_6(){return!u8("tengu_amber_quartz_disabled",!1)}function Vd8(){if(!jX())return!1;let q=o7();return Boolean(q?.accessToken)}function SM6(){return Vd8()&&K_6()}var __6=L(()=>{B1();T7()});async function wI6(q){let K=q.trim();if(!K)return{valid:!1,error:"Model name cannot be empty"};if(!Kq6(K))return{valid:!1,error:`Model '${K}' is not in the list of available models`};let _=K.toLowerCase();if(Yw6.includes(_))return{valid:!0};if(K===process.env.ANTHROPIC_CUSTOM_MODEL_OPTION)return{valid:!0};if(FvK.has(K))return{valid:!0};try{return await dR({model:K,max_tokens:1,maxRetries:0,querySource:"model_validation",messages:[{role:"user",content:[{type:"text",text:"Hi",cache_control:{type:"ephemeral"}}]}]}),FvK.set(K,!0),{valid:!0}}catch(z){return ijY(z,K)}}function ijY(q,K){if(q instanceof fY6){let z=rjY(K),Y=z?`. Try '${z}' instead`:"";return{valid:!1,error:`Model '${K}' not found${Y}`}}if(q instanceof vq){if(q instanceof ZY6)return{valid:!1,error:"Authentication failed. Please check your API credentials."};if(q instanceof bZ)return{valid:!1,error:"Network error. Please check your internet connection."};let z=q.error;if(z&&typeof z==="object"&&"type"in z&&z.type==="not_found_error"&&"message"in z&&typeof z.message==="string"&&z.message.includes("model:"))return{valid:!1,error:`Model '${K}' not found`};return{valid:!1,error:`API error: ${q.message}`}}return{valid:!1,error:`Unable to validate model: ${q instanceof Error?q.message:String(q)}`}}function rjY(q){if(KA())return;let K=q.toLowerCase();if(K.includes("opus-4-7")||K.includes("opus_4_7"))return ZO().opus41;if(K.includes("opus-4-6")||K.includes("opus_4_6"))return ZO().opus41;if(K.includes("opus-4-5")||K.includes("opus_4_5"))return ZO().opus41;if(K.includes("sonnet-4-6")||K.includes("sonnet_4_6"))return ZO().sonnet45;if(K.includes("sonnet-4-5")||K.includes("sonnet_4_5"))return ZO().sonnet40;return}var FvK;var kd8=L(()=>{IT6();jn6();x9();tH6();eG();jQ();FvK=new Map});function gvK(q){return q in $I6}function UvK(q){return $I6[q]}function Nd8(q){let K=$I6[q];if(!K)return;if(K.options)return[...K.options];if(K.getOptions)return K.getOptions();return}function QvK(q){return $I6[q]?.path??q.split(".")}var $I6;var y37=L(()=>{h1();$b1();s58();kd8();tB();$I6={theme:{source:"global",type:"string",description:"Color theme for the UI",options:ZY4},editorMode:{source:"global",type:"string",description:"Key binding mode",options:Ck8},verbose:{source:"global",type:"boolean",description:"Show detailed debug output",appStateKey:"verbose"},preferredNotifChannel:{source:"global",type:"string",description:"Preferred notification channel",options:Sk8},autoCompactEnabled:{source:"global",type:"boolean",description:"Auto-compact when context is full"},autoScrollEnabled:{source:"global",type:"boolean",description:"Auto-scroll conversation to bottom (fullscreen mode only)"},autoMemoryEnabled:{source:"settings",type:"boolean",description:"Enable auto-memory"},autoDreamEnabled:{source:"settings",type:"boolean",description:"Enable background memory consolidation"},fileCheckpointingEnabled:{source:"global",type:"boolean",description:"Enable file checkpointing for code rewind"},showTurnDuration:{source:"global",type:"boolean",description:'Show turn duration message after responses (e.g., "Cooked for 1m 6s")'},terminalProgressBarEnabled:{source:"global",type:"boolean",description:"Show OSC 9;4 progress indicator in supported terminals"},todoFeatureEnabled:{source:"global",type:"boolean",description:"Enable todo/task tracking"},model:{source:"settings",type:"string",description:"Override the default model",appStateKey:"mainLoopModel",getOptions:()=>{try{return q_6().filter((q)=>q.value!==null).map((q)=>q.value)}catch{return["sonnet","opus","haiku"]}},validateOnWrite:(q)=>wI6(String(q)),formatOnRead:(q)=>q===null?"default":q},alwaysThinkingEnabled:{source:"settings",type:"boolean",description:"Enable extended thinking (false to disable)",appStateKey:"thinkingEnabled"},"permissions.defaultMode":{source:"settings",type:"string",description:"Default permission mode for tool usage",options:["default","plan","acceptEdits","dontAsk","auto"]},language:{source:"settings",type:"string",description:'Preferred language for Claude responses and voice dictation (e.g., "japanese", "spanish")'},teammateMode:{source:"global",type:"string",description:'How to spawn teammates: "tmux" for traditional tmux, "in-process" for same process, "auto" to choose automatically',options:Nq4},tui:{source:"settings",type:"string",description:'Terminal UI renderer: "fullscreen" for flicker-free alt-screen rendering, "default" for the classic renderer',options:["default","fullscreen"]},...!1,...{voiceEnabled:{source:"settings",type:"boolean",description:"Enable voice dictation (hold-to-talk)"}},remoteControlAtStartup:{source:"global",type:"boolean",description:"Enable Remote Control for all sessions (true | false | default)",formatOnRead:()=>zd()},...{inputNeededNotifEnabled:{source:"global",type:"boolean",description:"Push to your mobile device when a permission prompt or question is waiting (requires Remote Control)"},agentPushNotifEnabled:{source:"global",type:"boolean",description:"Allow Claude to push to your mobile device when it deems it appropriate (requires Remote Control)"}}}});function cvK(){let q=[],K=[];for(let[z,Y]of Object.entries($I6)){if(z==="model")continue;if(z==="voiceEnabled"&&!K_6())continue;let A=Nd8(z),O=`- ${z}`;if(A)O+=`: ${A.map((w)=>`"${w}"`).join(", ")}`;else if(Y.type==="boolean")O+=": true/false";if(O+=` - ${Y.description}`,Y.source==="global")q.push(O);else K.push(O)}let _=ojY();return`Get or set Claude Code configuration settings.
4086
4086
 
4087
4087
  View or change Claude Code settings. Use when the user requests configuration changes, asks about current settings, or when adjusting a setting would benefit them.
4088
4088
 
@@ -8704,7 +8704,7 @@ try {
8704
8704
  .filter((m) => m.id)
8705
8705
  .sort((a, b) => a.id.localeCompare(b.id));
8706
8706
  return {
8707
- additional_model_options: _sorted.map((m) => ({value: m.id, label: m.id, description: m.desc ?? m.id})),
8707
+ additional_model_options: _sorted.map((m) => ({value: m.id, label: m.name ?? m.id, description: m.desc ?? m.name})),
8708
8708
  additional_model_costs: {},
8709
8709
  client_data: null,
8710
8710
  };
package/dist/coder.js CHANGED
@@ -1,41 +1,41 @@
1
1
  #!/usr/bin/env node
2
- var ft=Object.create;var be=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var bt=Object.getPrototypeOf,It=Object.prototype.hasOwnProperty;var $=(c,e)=>()=>(e||c((e={exports:{}}).exports,e),e.exports);var wt=(c,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of yt(e))!It.call(c,n)&&n!==t&&be(c,n,{get:()=>e[n],enumerable:!(o=gt(e,n))||o.enumerable});return c};var xt=(c,e,t)=>(t=c!=null?ft(bt(c)):{},wt(e||!c||!c.__esModule?be(t,"default",{value:c,enumerable:!0}):t,c));var N=$((Io,$t)=>{$t.exports={name:"makecoder",version:"4.0.59",description:"MakeCoder: Unified AI agent CLI tool integrating Claude Code, Codex and Gemini CLI",main:"./dist/coder.js",bin:{coder:"./dist/coder.js"},scripts:{test:'echo "Error: no test specified" && exit 1',start:"node ./src/coder.js",build:"node scripts/build.js","build:clean":"node scripts/build.js --clean","build:dev":"node scripts/build.js --no-minify --sourcemap",postinstall:"node scripts/postinstall.js"},keywords:["cli","ai","claude","gemini","codex","agent"],author:"makecoder",license:"MIT",repository:{type:"git",url:"https://github.com/makecoderai/coder.git"},homepage:"https://github.com/makecoderai/coder",dependencies:{"node-fetch":"^3.3.2",open:"^10.1.0",zod:"^3.25.76"},optionalDependencies:{bun:">=1.3.12"},engines:{node:">=20.0.0"},devDependencies:{chokidar:"^4.0.3"},files:["dist","packages","scripts/postinstall.js"]}});var $e=$((wo,xe)=>{var E=require("fs"),Ie=require("path"),kt=require("os"),St=new Set(["auth","skills","wiki","channel","team"]),we=new Set(["claude","gemini","codex"]),Ct=new Set(["pub","auth","update","skills","wiki","channel","team"]),X=class{constructor(){let e=process.env.CODER_PROFILE,t=e?`.coder.${e}`:".coder";this.configPath=Ie.join(kt.homedir(),t,"config.json"),this.defaultConfig={agent:"claude",auth:{apikey:null}}}loadConfig(){let e=Ie.dirname(this.configPath);try{return E.existsSync(e)||E.mkdirSync(e,{recursive:!0}),E.existsSync(this.configPath)||E.writeFileSync(this.configPath,JSON.stringify(this.defaultConfig,null,2)),JSON.parse(E.readFileSync(this.configPath,"utf8"))}catch{return{...this.defaultConfig}}}getApiKeyFromConfig(e){return e.auth?.apikey?e.auth.apikey:e.auth?.ak&&e.auth?.sk?`${e.auth.ak}.${e.auth.sk}`:null}saveAuthToConfig(e){let t=this.loadConfig();t.auth={apikey:e};try{return E.writeFileSync(this.configPath,JSON.stringify(t,null,2)),!0}catch{return!1}}clearAuthFromConfig(){let e=this.loadConfig();e.auth={apikey:null};try{return E.writeFileSync(this.configPath,JSON.stringify(e,null,2)),!0}catch{return!1}}getTeam(){return this.loadConfig().team||null}setTeam(e,t){let o=this.loadConfig();e==null?delete o.team:o.team={id:e,name:t||""};try{return E.writeFileSync(this.configPath,JSON.stringify(o,null,2)),!0}catch{return!1}}getTeamManual(){return!!this.loadConfig().team_manual}setTeamManual(e){let t=this.loadConfig();e?t.team_manual=!0:delete t.team_manual;try{return E.writeFileSync(this.configPath,JSON.stringify(t,null,2)),!0}catch{return!1}}async parse(e=process.argv.slice(2)){let t=this.loadConfig(),o={agent:t.agent||"claude",remainingArgs:[]},n=0;if(e.length>0){if(we.has(e[0]))o.agent=e[0],o.agentSetBySubcommand=!0,n=1;else if(Ct.has(e[0])){if(o.command=e[0],n=1,e[0]==="auth"){let r=e[1];r==="--help"||r==="-h"?o.authSubcommand="--help":(o.authSubcommand=r,o.authRemainingArgs=e.slice(2)),n=e.length}else if(e[0]==="skills"){let r=e[1];o.skillsSubcommand=r==="--help"||r==="-h"?void 0:r,o.skillsArg=e[2],o.skillsRemainingArgs=e.slice(2),n=e.length}else if(e[0]==="wiki"){let r=e[1];o.wikiSubcommand=r==="--help"||r==="-h"?void 0:r,o.wikiArg=e[2],o.wikiRemainingArgs=e.slice(2),n=e.length}else if(e[0]==="team"){let r=e[1];o.teamSubcommand=r==="--help"||r==="-h"?void 0:r,o.teamArg=e[2],o.teamRemainingArgs=e.slice(2),n=e.length}else if(e[0]==="channel"){let r=e[1];r==="--help"||r==="-h"?o.channelSubcommand="--help":r==="list"||r==="show"||r==="add"||r==="remove"||r==="update"?(o.channelSubcommand=r,o.channelArg=e[2],o.channelRemainingArgs=e.slice(2)):o.channelRemainingArgs=e.slice(1),n=e.length}}}for(;n<e.length;){let r=e[n];if(r==="--agent"){if(o.agentSetBySubcommand)throw new Error(`\u4E0D\u80FD\u540C\u65F6\u4F7F\u7528\u5B50\u547D\u4EE4 '${o.agent}' \u548C --agent\uFF0C\u8BF7\u9009\u62E9\u5176\u4E00`);let i=e[n+1];if(!i||!we.has(i))throw new Error("--agent \u9700\u8981\u6307\u5B9A\u4EE3\u7406\u7C7B\u578B\uFF08claude|gemini|codex\uFF09");o.agent=i,n+=2}else if(r==="--apikey"){let i=e[n+1];if(!i||i.startsWith("--"))throw new Error("--apikey \u9700\u8981\u63D0\u4F9B API Key \u503C");if(i.indexOf(".")===-1)throw new Error("API Key \u683C\u5F0F\u9519\u8BEF\uFF0C\u5E94\u4E3A <ak>.<sk>");o.apikey=i,n+=2}else if(r==="--name"){let i=e[n+1];i&&!i.startsWith("--")?(o.pubName=i,n+=2):n+=1}else if(r==="--allow-clone")o.allowClone=!0,n+=1;else if(r==="--meta-data"){let i=e[n+1];if(!i||i.startsWith("--"))throw new Error("--meta-data \u9700\u8981\u4E00\u4E2A JSON \u5B57\u7B26\u4E32\u503C");try{JSON.parse(i)}catch(a){throw new Error(`--meta-data \u4E0D\u662F\u5408\u6CD5\u7684 JSON\uFF1A${a.message}`)}o.pubMetaData=i,n+=2}else{o.remainingArgs=e.slice(n);break}}if(o.command!=="auth"&&!o.apikey){let r=this.getApiKeyFromConfig(t);o.apikey=r||process.env.CODER_APIKEY||null}o.codevServer=process.env.CODEV_SERVER||t.codevServer||"https://makecoder.com/bigapis/codev/v1";let s=o.remainingArgs.includes("--version")||o.remainingArgs.includes("-v")||o.remainingArgs.includes("--help")||o.remainingArgs.includes("-h");return!St.has(o.command)&&!s&&!o.apikey&&await this._oauthLogin(o),o}async _oauthLogin(e){console.log(`\u274C \u5C1A\u672A\u767B\u5F55
2
+ var ft=Object.create;var be=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var bt=Object.getPrototypeOf,It=Object.prototype.hasOwnProperty;var $=(c,e)=>()=>(e||c((e={exports:{}}).exports,e),e.exports);var wt=(c,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of yt(e))!It.call(c,n)&&n!==t&&be(c,n,{get:()=>e[n],enumerable:!(o=gt(e,n))||o.enumerable});return c};var xt=(c,e,t)=>(t=c!=null?ft(bt(c)):{},wt(e||!c||!c.__esModule?be(t,"default",{value:c,enumerable:!0}):t,c));var N=$((Io,$t)=>{$t.exports={name:"makecoder",version:"4.0.63",description:"MakeCoder: Unified AI agent CLI tool integrating Claude Code, Codex and Gemini CLI",main:"./dist/coder.js",bin:{coder:"./dist/coder.js"},scripts:{test:'echo "Error: no test specified" && exit 1',start:"node ./src/coder.js",build:"node scripts/build.js","build:clean":"node scripts/build.js --clean","build:dev":"node scripts/build.js --no-minify --sourcemap",postinstall:"node scripts/postinstall.js"},keywords:["cli","ai","claude","gemini","codex","agent"],author:"makecoder",license:"MIT",repository:{type:"git",url:"https://github.com/makecoderai/coder.git"},homepage:"https://github.com/makecoderai/coder",dependencies:{"node-fetch":"^3.3.2",open:"^10.1.0",zod:"^3.25.76"},optionalDependencies:{bun:">=1.3.12"},engines:{node:">=20.0.0"},devDependencies:{chokidar:"^4.0.3"},files:["dist","packages","scripts/postinstall.js"]}});var $e=$((wo,xe)=>{var _=require("fs"),Ie=require("path"),kt=require("os"),St=new Set(["auth","skills","wiki","channel","team"]),we=new Set(["claude","gemini","codex"]),Ct=new Set(["pub","auth","update","skills","wiki","channel","team"]),X=class{constructor(){let e=process.env.CODER_PROFILE,t=e?`.coder.${e}`:".coder";this.configPath=Ie.join(kt.homedir(),t,"config.json"),this.defaultConfig={agent:"claude",auth:{apikey:null}}}loadConfig(){let e=Ie.dirname(this.configPath);try{return _.existsSync(e)||_.mkdirSync(e,{recursive:!0}),_.existsSync(this.configPath)||_.writeFileSync(this.configPath,JSON.stringify(this.defaultConfig,null,2)),JSON.parse(_.readFileSync(this.configPath,"utf8"))}catch{return{...this.defaultConfig}}}getApiKeyFromConfig(e){return e.auth?.apikey?e.auth.apikey:e.auth?.ak&&e.auth?.sk?`${e.auth.ak}.${e.auth.sk}`:null}saveAuthToConfig(e){let t=this.loadConfig();t.auth={apikey:e};try{return _.writeFileSync(this.configPath,JSON.stringify(t,null,2)),!0}catch{return!1}}clearAuthFromConfig(){let e=this.loadConfig();e.auth={apikey:null};try{return _.writeFileSync(this.configPath,JSON.stringify(e,null,2)),!0}catch{return!1}}getTeam(){return this.loadConfig().team||null}setTeam(e,t){let o=this.loadConfig();e==null?delete o.team:o.team={id:e,name:t||""};try{return _.writeFileSync(this.configPath,JSON.stringify(o,null,2)),!0}catch{return!1}}getTeamManual(){return!!this.loadConfig().team_manual}setTeamManual(e){let t=this.loadConfig();e?t.team_manual=!0:delete t.team_manual;try{return _.writeFileSync(this.configPath,JSON.stringify(t,null,2)),!0}catch{return!1}}async parse(e=process.argv.slice(2)){let t=this.loadConfig(),o={agent:t.agent||"claude",remainingArgs:[]},n=0;if(e.length>0){if(we.has(e[0]))o.agent=e[0],o.agentSetBySubcommand=!0,n=1;else if(Ct.has(e[0])){if(o.command=e[0],n=1,e[0]==="auth"){let r=e[1];r==="--help"||r==="-h"?o.authSubcommand="--help":(o.authSubcommand=r,o.authRemainingArgs=e.slice(2)),n=e.length}else if(e[0]==="skills"){let r=e[1];o.skillsSubcommand=r==="--help"||r==="-h"?void 0:r,o.skillsArg=e[2],o.skillsRemainingArgs=e.slice(2),n=e.length}else if(e[0]==="wiki"){let r=e[1];o.wikiSubcommand=r==="--help"||r==="-h"?void 0:r,o.wikiArg=e[2],o.wikiRemainingArgs=e.slice(2),n=e.length}else if(e[0]==="team"){let r=e[1];o.teamSubcommand=r==="--help"||r==="-h"?void 0:r,o.teamArg=e[2],o.teamRemainingArgs=e.slice(2),n=e.length}else if(e[0]==="channel"){let r=e[1];r==="--help"||r==="-h"?o.channelSubcommand="--help":r==="list"||r==="show"||r==="add"||r==="remove"||r==="update"?(o.channelSubcommand=r,o.channelArg=e[2],o.channelRemainingArgs=e.slice(2)):o.channelRemainingArgs=e.slice(1),n=e.length}}}for(;n<e.length;){let r=e[n];if(r==="--agent"){if(o.agentSetBySubcommand)throw new Error(`\u4E0D\u80FD\u540C\u65F6\u4F7F\u7528\u5B50\u547D\u4EE4 '${o.agent}' \u548C --agent\uFF0C\u8BF7\u9009\u62E9\u5176\u4E00`);let i=e[n+1];if(!i||!we.has(i))throw new Error("--agent \u9700\u8981\u6307\u5B9A\u4EE3\u7406\u7C7B\u578B\uFF08claude|gemini|codex\uFF09");o.agent=i,n+=2}else if(r==="--apikey"){let i=e[n+1];if(!i||i.startsWith("--"))throw new Error("--apikey \u9700\u8981\u63D0\u4F9B API Key \u503C");if(i.indexOf(".")===-1)throw new Error("API Key \u683C\u5F0F\u9519\u8BEF\uFF0C\u5E94\u4E3A <ak>.<sk>");o.apikey=i,n+=2}else if(r==="--name"){let i=e[n+1];i&&!i.startsWith("--")?(o.pubName=i,n+=2):n+=1}else if(r==="--allow-clone")o.allowClone=!0,n+=1;else if(r==="--meta-data"){let i=e[n+1];if(!i||i.startsWith("--"))throw new Error("--meta-data \u9700\u8981\u4E00\u4E2A JSON \u5B57\u7B26\u4E32\u503C");try{JSON.parse(i)}catch(a){throw new Error(`--meta-data \u4E0D\u662F\u5408\u6CD5\u7684 JSON\uFF1A${a.message}`)}o.pubMetaData=i,n+=2}else{o.remainingArgs=e.slice(n);break}}if(o.command!=="auth"&&!o.apikey){let r=this.getApiKeyFromConfig(t);o.apikey=r||process.env.CODER_APIKEY||null}o.codevServer=process.env.CODEV_SERVER||t.codevServer||"https://makecoder.com/bigapis/codev/v1";let s=o.remainingArgs.includes("--version")||o.remainingArgs.includes("-v")||o.remainingArgs.includes("--help")||o.remainingArgs.includes("-h");return!St.has(o.command)&&!s&&!o.apikey&&await this._oauthLogin(o),o}async _oauthLogin(e){console.log(`\u274C \u5C1A\u672A\u767B\u5F55
3
3
  `),console.log("\u8BF7\u5148\u767B\u5F55:"),console.log(` coder auth login
4
4
  `),console.log("\u6216\u76F4\u63A5\u63D0\u4F9B API Key:"),console.log(` coder auth login --apikey <your-api-key>
5
5
  `),console.log(`\u83B7\u53D6 API Key: https://makecoder.com/my/apikeys
6
6
  `),process.exit(1)}showHelp(){let{version:e}=N(),t=[`Coder v${e} - \u7EDF\u4E00 AI \u4EE3\u7406 CLI`,"","Usage: coder [options] [command] [arguments]","","Arguments:"," prompt \u60A8\u7684\u63D0\u793A\u8BCD","","Commands:"," claude \u542F\u52A8 Claude Code \u4EE3\u7406\uFF08\u9ED8\u8BA4\uFF09"," gemini \u542F\u52A8 Gemini \u4EE3\u7406"," codex \u542F\u52A8 OpenAI Codex \u4EE3\u7406"," auth \u7BA1\u7406\u8EAB\u4EFD\u9A8C\u8BC1\u51ED\u8BC1"," update \u5347\u7EA7 Coder \u5230\u6700\u65B0\u7248\u672C"," pub \u53D1\u5E03\u5F53\u524D\u76EE\u5F55\u4E3A MakeCoder \u7F51\u9875\u5E94\u7528"," skills \u7BA1\u7406 Claude Code skills"," wiki \u7BA1\u7406 MakeCoder \u77E5\u8BC6\u5E93"," channel \u7BA1\u7406\u6E20\u9053\u7ED1\u5B9A\uFF08\u4F01\u4E1A\u5FAE\u4FE1\u7B49\uFF09"," team \u7BA1\u7406\u56E2\u961F\u4E0E\u6210\u5458\uFF08\u9762\u5411 AI\uFF09","","Options:"," --agent <agent> \u6307\u5B9A\u4F7F\u7528\u7684 AI \u4EE3\u7406\uFF08claude|gemini|codex\uFF09"," --apikey <key> \u4E34\u65F6\u63D0\u4F9B API Key\uFF08\u683C\u5F0F: <ak>.<sk>\uFF09"," --version, -v \u663E\u793A\u7248\u672C\u53F7"," --help, -h \u663E\u793A\u6B64\u5E2E\u52A9\u4FE1\u606F","","Examples:"," coder claude \u542F\u52A8 Claude Code \u4EE3\u7406"," coder gemini \u542F\u52A8 Gemini \u4EE3\u7406"," coder auth login \u767B\u5F55\uFF08\u6D4F\u89C8\u5668\u6216\u7EC8\u7AEF\u8F93\u5165 API Key\uFF09"," coder auth login --apikey <key> \u76F4\u63A5\u4FDD\u5B58 API Key"," coder auth logout \u9000\u51FA\u767B\u5F55"," coder auth status \u67E5\u770B\u767B\u5F55\u72B6\u6001"," coder pub --name myproject \u53D1\u5E03\u5F53\u524D\u76EE\u5F55\u4E3A MakeCoder \u7F51\u9875\u5E94\u7528"," coder skills --help \u67E5\u770B skills \u5B50\u547D\u4EE4\u5E2E\u52A9"," coder wiki --help \u67E5\u770B wiki \u5B50\u547D\u4EE4\u5E2E\u52A9"," coder channel --help \u67E5\u770B channel \u5B50\u547D\u4EE4\u5E2E\u52A9"," coder team --help \u67E5\u770B team \u5B50\u547D\u4EE4\u5E2E\u52A9","",`\u914D\u7F6E\u6587\u4EF6: ${this.configPath}`];console.log(t.join(`
7
- `))}};xe.exports=X});var U=$((xo,ke)=>{function vt(c=process.argv.slice(2)){return c.includes("--print")||c.includes("-p")}ke.exports={isPrintMode:vt}});var R=$((ko,Ce)=>{var{spawn:Et}=require("child_process"),Se=require("path"),_t=require("fs"),$o=require("os"),{isPrintMode:Ot}=U(),Z=class{constructor(e){this.config=e}findExecutablePath(){let e=Se.dirname(require.main.filename);for(let t of this.config.executablePaths){let o=Se.resolve(e,t);if(_t.existsSync(o))return o}throw new Error(`Could not find executable in any of the configured paths: ${this.config.executablePaths.join(", ")}`)}handleChildMessages(e){process.env.CODEV_DEBUG&&console.log("Child process message handler initialized"),e.connected&&(e.on("message",t=>{this.onChildMessage(t)}),e.on("exit",async(t,o)=>{try{await this.handleChildProcessExit(t,o)}catch(n){console.error("Error in handleChildProcessExit:",n.message)}}),e.on("error",t=>{this.handleChildProcessError(t)}))}onChildMessage(e){process.env.CODEV_DEBUG&&console.log("Received IPC message from child:",e)}handleChildProcessExit(e,t){}handleChildProcessError(e){}async launch(e={}){let{remainingArgs:t=[],codevServer:o,apikey:n=null,extraEnv:s={}}=e;try{let r=this.findExecutablePath();return process.env.CODEV_DEBUG&&console.log(`executablePath: ${r}`),new Promise((i,a)=>{let l={...process.env,...this.config.environmentVariables(o),...s};n&&(l.CODER_APIKEY=n);let d=["--no-warnings"];process.env.CODEV_INSPECT_BRK==="True"&&d.push("--inspect-brk"),d.push(r,...t);let u=Et("node",d,{env:l,stdio:["inherit","inherit","inherit","ipc"]});this.handleChildMessages(u),u.on("error",m=>{console.error(`Failed to start: ${m.message}`),a(m)}),u.on("exit",async(m,p)=>{Ot(t)||p&&console.log(`terminated by signal: ${p}`)}),process.on("SIGINT",async()=>{console.log(`
7
+ `))}};xe.exports=X});var U=$((xo,ke)=>{function vt(c=process.argv.slice(2)){return c.includes("--print")||c.includes("-p")}ke.exports={isPrintMode:vt}});var R=$((ko,Ce)=>{var{spawn:_t}=require("child_process"),Se=require("path"),Et=require("fs"),$o=require("os"),{isPrintMode:Ot}=U(),Z=class{constructor(e){this.config=e}findExecutablePath(){let e=Se.dirname(require.main.filename);for(let t of this.config.executablePaths){let o=Se.resolve(e,t);if(Et.existsSync(o))return o}throw new Error(`Could not find executable in any of the configured paths: ${this.config.executablePaths.join(", ")}`)}handleChildMessages(e){process.env.CODEV_DEBUG&&console.log("Child process message handler initialized"),e.connected&&(e.on("message",t=>{this.onChildMessage(t)}),e.on("exit",async(t,o)=>{try{await this.handleChildProcessExit(t,o)}catch(n){console.error("Error in handleChildProcessExit:",n.message)}}),e.on("error",t=>{this.handleChildProcessError(t)}))}onChildMessage(e){process.env.CODEV_DEBUG&&console.log("Received IPC message from child:",e)}handleChildProcessExit(e,t){}handleChildProcessError(e){}async launch(e={}){let{remainingArgs:t=[],codevServer:o,apikey:n=null,extraEnv:s={}}=e;try{let r=this.findExecutablePath();return process.env.CODEV_DEBUG&&console.log(`executablePath: ${r}`),new Promise((i,a)=>{let l={...process.env,...this.config.environmentVariables(o),...s};n&&(l.CODER_APIKEY=n);let d=["--no-warnings"];process.env.CODEV_INSPECT_BRK==="True"&&d.push("--inspect-brk"),d.push(r,...t);let u=_t("node",d,{env:l,stdio:["inherit","inherit","inherit","ipc"]});this.handleChildMessages(u),u.on("error",m=>{console.error(`Failed to start: ${m.message}`),a(m)}),u.on("exit",async(m,p)=>{Ot(t)||p&&console.log(`terminated by signal: ${p}`)}),process.on("SIGINT",async()=>{console.log(`
8
8
  Terminating ...`),u.kill("SIGTERM"),setTimeout(()=>{u.killed||u.kill("SIGKILL")},8e3)}),process.on("SIGTERM",async()=>{console.log(`
9
- Terminating ...`),u.kill("SIGTERM"),setTimeout(()=>{u.killed||u.kill("SIGKILL")},8e3)})})}catch(r){throw r}}};Ce.exports=Z});var _e=$((So,Ee)=>{var Dt=R(),M=require("path"),ve=require("fs"),Q=class extends Dt{constructor(){super({executablePaths:["cc.mjs","../dist/cc.mjs","/tmp/claude-code/package/cc.mjs"],environmentVariables:e=>({ANTHROPIC_BASE_URL:`${e}/claude`,ANTHROPIC_API_KEY:"null",DISABLE_TELEMETRY:!0,CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:!0,DISABLE_COST_WARNINGS:!0,DISABLE_NON_ESSENTIAL_MODEL_CALLS:!0,CODEV_SERVER:e,CLAUDE_CODE_ATTRIBUTION_HEADER:"0",DISABLE_AUTOUPDATER:"1"})})}findExecutablePath(){let e=M.dirname(require.main.filename);for(let o of this.config.executablePaths){let n=M.resolve(e,o);if(ve.existsSync(n))return n}let t=this._findGlobalMakecoderCcMjs();if(t)return t;throw new Error(`Could not find Claude Code (node) executable in any of the configured paths: ${this.config.executablePaths.join(", ")}`)}_findGlobalMakecoderCcMjs(){let e=M.dirname(process.execPath),t=[M.join(e,"..","lib","node_modules","makecoder","dist","cc.mjs"),M.join(e,"node_modules","makecoder","dist","cc.mjs")];for(let o of t)if(ve.existsSync(o))return o;return null}};Ee.exports=Q});var De=$((Co,Oe)=>{var Pt=R(),{spawn:At,execFileSync:Tt}=require("child_process"),_=require("path"),A=require("fs"),{isPrintMode:qt}=U(),Bt=process.env.CODEV_DEBUG==="True",ee=class extends Pt{constructor(){let e=`${process.platform}-${process.arch}`;super({executablePaths:[`${e}/cc.js`,`../dist/${e}/cc.js`,`/tmp/claude-code-${e}/package/extracted/src/entrypoints/cc.js`],environmentVariables:t=>({ANTHROPIC_BASE_URL:`${t}/claude`,ANTHROPIC_API_KEY:"null",DISABLE_TELEMETRY:!0,CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:!0,DISABLE_COST_WARNINGS:!0,DISABLE_NON_ESSENTIAL_MODEL_CALLS:!0,CODEV_SERVER:t,CLAUDE_CODE_ATTRIBUTION_HEADER:"0",DISABLE_INSTALLATION_CHECKS:"1",DISABLE_AUTOUPDATER:"1",ANTHROPIC_DEFAULT_HAIKU_MODEL:"claude-haiku-4-5"})})}async launch(e={}){return this._launchWithBun(e)}findExecutablePath(){let e=_.dirname(require.main.filename);for(let o of this.config.executablePaths){let n=_.resolve(e,o);if(A.existsSync(n))return n}let t=this._findGlobalMakecoderCc();if(t)return t;throw new Error(`Could not find Claude Code (bun) executable in any of the configured paths: ${this.config.executablePaths.join(", ")}`)}_findGlobalMakecoderCc(){let e=`${process.platform}-${process.arch}`,t=_.dirname(process.execPath),o=[_.join(t,"..","lib","node_modules","makecoder","dist",e,"cc.js"),_.join(t,"node_modules","makecoder","dist",e,"cc.js")];for(let n of o)if(A.existsSync(n))return n;return null}_resolveBunPath(){let e=process.platform==="win32",t=e?"bun.exe":"bun";try{return Tt(t,["--version"],{stdio:"ignore"}),t}catch{}let o=_.join(process.env.HOME||process.env.USERPROFILE||"",".local","bin",t);if(A.existsSync(o))return o;let n=_.join(__dirname,"..","..","node_modules",".bin",t);if(A.existsSync(n))return n;let s=this._getBunPlatformPackage();if(s)try{let r=_.dirname(require.resolve(`${s}/package.json`)),i=_.join(r,"bin",t);if(A.existsSync(i))return i}catch{}try{let r=require.resolve(`bun/${e?"bin/bun.exe":"bin/bun"}`);if(A.existsSync(r))return r}catch{}throw new Error("bun is not installed. Install it with: npm install -g bun or curl -fsSL https://bun.sh/install | bash")}_getBunPlatformPackage(){let e=process.platform,t=process.arch;return{"darwin-arm64":"@oven-sh/bun-darwin-aarch64","darwin-x64":"@oven-sh/bun-darwin-x64","linux-arm64":"@oven-sh/bun-linux-aarch64","linux-x64":"@oven-sh/bun-linux-x64","win32-x64":"@oven-sh/bun-windows-x64"}[`${e}-${t}`]||null}async _launchWithBun(e={}){let{remainingArgs:t=[],codevServer:o,apikey:n=null,extraEnv:s={}}=e,r=this.findExecutablePath(),i=this._resolveBunPath();return Bt&&(console.log(`executablePath (bun): ${r}`),console.log(`bunPath: ${i}`)),new Promise((a,l)=>{let d={...process.env,...this.config.environmentVariables(o),CODER_EXECPATH:A.realpathSync(process.argv[1]),...s};n&&(d.CODER_APIKEY=n);let u=[r,...t],m=At(i,u,{env:d,stdio:["inherit","inherit","inherit","ipc"]});m.on("error",p=>{p.code==="ENOENT"?console.error("bun binary not found. Install it with: npm install -g bun or curl -fsSL https://bun.sh/install | bash"):console.error(`Failed to start bun: ${p.message}`),l(p)}),m.on("exit",async(p,f)=>{qt(t)||f&&console.log(`terminated by signal: ${f}`)}),process.on("SIGINT",async()=>{console.log(`
9
+ Terminating ...`),u.kill("SIGTERM"),setTimeout(()=>{u.killed||u.kill("SIGKILL")},8e3)})})}catch(r){throw r}}};Ce.exports=Z});var Ee=$((So,_e)=>{var Dt=R(),M=require("path"),ve=require("fs"),Q=class extends Dt{constructor(){super({executablePaths:["cc.mjs","../dist/cc.mjs","/tmp/claude-code/package/cc.mjs"],environmentVariables:e=>({ANTHROPIC_BASE_URL:`${e}/claude`,ANTHROPIC_API_KEY:"null",DISABLE_TELEMETRY:!0,CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:!0,DISABLE_COST_WARNINGS:!0,DISABLE_NON_ESSENTIAL_MODEL_CALLS:!0,CODEV_SERVER:e,CLAUDE_CODE_ATTRIBUTION_HEADER:"0",DISABLE_AUTOUPDATER:"1"})})}findExecutablePath(){let e=M.dirname(require.main.filename);for(let o of this.config.executablePaths){let n=M.resolve(e,o);if(ve.existsSync(n))return n}let t=this._findGlobalMakecoderCcMjs();if(t)return t;throw new Error(`Could not find Claude Code (node) executable in any of the configured paths: ${this.config.executablePaths.join(", ")}`)}_findGlobalMakecoderCcMjs(){let e=M.dirname(process.execPath),t=[M.join(e,"..","lib","node_modules","makecoder","dist","cc.mjs"),M.join(e,"node_modules","makecoder","dist","cc.mjs")];for(let o of t)if(ve.existsSync(o))return o;return null}};_e.exports=Q});var De=$((Co,Oe)=>{var Pt=R(),{spawn:At,execFileSync:Tt}=require("child_process"),E=require("path"),A=require("fs"),{isPrintMode:qt}=U(),Bt=process.env.CODEV_DEBUG==="True",ee=class extends Pt{constructor(){let e=`${process.platform}-${process.arch}`;super({executablePaths:[`${e}/cc.js`,`../dist/${e}/cc.js`,`/tmp/claude-code-${e}/package/extracted/src/entrypoints/cc.js`],environmentVariables:t=>({ANTHROPIC_BASE_URL:`${t}/claude`,ANTHROPIC_API_KEY:"null",DISABLE_TELEMETRY:!0,CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:!0,DISABLE_COST_WARNINGS:!0,DISABLE_NON_ESSENTIAL_MODEL_CALLS:!0,CODEV_SERVER:t,CLAUDE_CODE_ATTRIBUTION_HEADER:"0",DISABLE_INSTALLATION_CHECKS:"1",DISABLE_AUTOUPDATER:"1",ANTHROPIC_DEFAULT_HAIKU_MODEL:"claude-haiku-4-5"})})}async launch(e={}){return this._launchWithBun(e)}findExecutablePath(){let e=E.dirname(require.main.filename);for(let o of this.config.executablePaths){let n=E.resolve(e,o);if(A.existsSync(n))return n}let t=this._findGlobalMakecoderCc();if(t)return t;throw new Error(`Could not find Claude Code (bun) executable in any of the configured paths: ${this.config.executablePaths.join(", ")}`)}_findGlobalMakecoderCc(){let e=`${process.platform}-${process.arch}`,t=E.dirname(process.execPath),o=[E.join(t,"..","lib","node_modules","makecoder","dist",e,"cc.js"),E.join(t,"node_modules","makecoder","dist",e,"cc.js")];for(let n of o)if(A.existsSync(n))return n;return null}_resolveBunPath(){let e=process.platform==="win32",t=e?"bun.exe":"bun";try{return Tt(t,["--version"],{stdio:"ignore"}),t}catch{}let o=E.join(process.env.HOME||process.env.USERPROFILE||"",".local","bin",t);if(A.existsSync(o))return o;let n=E.join(__dirname,"..","..","node_modules",".bin",t);if(A.existsSync(n))return n;let s=this._getBunPlatformPackage();if(s)try{let r=E.dirname(require.resolve(`${s}/package.json`)),i=E.join(r,"bin",t);if(A.existsSync(i))return i}catch{}try{let r=require.resolve(`bun/${e?"bin/bun.exe":"bin/bun"}`);if(A.existsSync(r))return r}catch{}throw new Error("bun is not installed. Install it with: npm install -g bun or curl -fsSL https://bun.sh/install | bash")}_getBunPlatformPackage(){let e=process.platform,t=process.arch;return{"darwin-arm64":"@oven-sh/bun-darwin-aarch64","darwin-x64":"@oven-sh/bun-darwin-x64","linux-arm64":"@oven-sh/bun-linux-aarch64","linux-x64":"@oven-sh/bun-linux-x64","win32-x64":"@oven-sh/bun-windows-x64"}[`${e}-${t}`]||null}async _launchWithBun(e={}){let{remainingArgs:t=[],codevServer:o,apikey:n=null,extraEnv:s={}}=e,r=this.findExecutablePath(),i=this._resolveBunPath();return Bt&&(console.log(`executablePath (bun): ${r}`),console.log(`bunPath: ${i}`)),new Promise((a,l)=>{let d={...process.env,...this.config.environmentVariables(o),CODER_EXECPATH:A.realpathSync(process.argv[1]),...s};n&&(d.CODER_APIKEY=n);let u=[r,...t],m=At(i,u,{env:d,stdio:["inherit","inherit","inherit","ipc"]});m.on("error",p=>{p.code==="ENOENT"?console.error("bun binary not found. Install it with: npm install -g bun or curl -fsSL https://bun.sh/install | bash"):console.error(`Failed to start bun: ${p.message}`),l(p)}),m.on("exit",async(p,f)=>{qt(t)||f&&console.log(`terminated by signal: ${f}`)}),process.on("SIGINT",async()=>{console.log(`
10
10
  Terminating ...`),m.kill("SIGTERM"),setTimeout(()=>{m.killed||m.kill("SIGKILL")},8e3)}),process.on("SIGTERM",async()=>{console.log(`
11
- Terminating ...`),m.kill("SIGTERM"),setTimeout(()=>{m.killed||m.kill("SIGKILL")},8e3)})})}};Oe.exports=ee});var Te=$((vo,Ae)=>{var jt=R(),F=require("path"),Pe=require("fs"),te=class extends jt{constructor(){super({executablePaths:["gemini/gemini.js","../dist/gemini/gemini.js"],environmentVariables:e=>({GOOGLE_GEMINI_BASE_URL:`${e}/gemini`,GEMINI_API_KEY:"null",GOOGLE_API_KEY:"null",GOOGLE_CLOUD_PROJECT:"coder",GOOGLE_CLOUD_LOCATION:"coder",USE_VERTEX:!0,GEMINI_TELEMETRY_ENABLED:"false",GEMINI_TELEMETRY_LOG_PROMPTS:"false"})})}findExecutablePath(){let e=F.dirname(require.main.filename);for(let o of this.config.executablePaths){let n=F.resolve(e,o);if(Pe.existsSync(n))return n}let t=this._findGlobalMakecoderGemini();if(t)return t;throw new Error(`Could not find Gemini executable in any of the configured paths: ${this.config.executablePaths.join(", ")}`)}_findGlobalMakecoderGemini(){let e=F.dirname(process.execPath),t=[F.join(e,"..","lib","node_modules","makecoder","dist","gemini","gemini.js"),F.join(e,"node_modules","makecoder","dist","gemini","gemini.js")];for(let o of t)if(Pe.existsSync(o))return o;return null}};Ae.exports=te});var Be=$((Eo,qe)=>{var Lt=R(),J=require("path"),oe=require("fs"),{spawn:Nt}=require("child_process"),Ut=process.env.CODEV_DEBUG==="True",ne=class extends Lt{constructor(){super({executablePaths:["codex.mjs","../dist/codex.mjs"],environmentVariables:()=>({CODEX_DISABLE_WEBSOCKET:"1"})})}checkCodexAvailability(){try{let e=this.findExecutablePath();return oe.existsSync(e)}catch{return!1}}findExecutablePath(){let e=J.dirname(require.main.filename);for(let o of this.config.executablePaths){let n=J.resolve(e,o);if(oe.existsSync(n))return n}let t=this._findGlobalMakecoderCodex();if(t)return t;throw new Error(`Could not find Codex executable in any of the configured paths: ${this.config.executablePaths.join(", ")}`)}_findGlobalMakecoderCodex(){let e=J.dirname(process.execPath),t=[J.join(e,"..","lib","node_modules","makecoder","dist","codex.mjs"),J.join(e,"node_modules","makecoder","dist","codex.mjs")];for(let o of t)if(oe.existsSync(o))return o;return null}async launch(e={}){let{remainingArgs:t=[],codevServer:o,apikey:n=null}=e;try{if(!this.checkCodexAvailability())throw new Error("Codex executable not found. Please ensure makecoder is properly installed: npm install -g makecoder@latest");let s=this.findExecutablePath();Ut&&console.log(`executablePath: ${s}`);let i=[...["-c",`openai_base_url="${o}/codex"`,"-c","analytics.enabled=false","-c","feedback.enabled=false","-c","check_for_update_on_startup=false","-c",'otel.exporter="none"',"-c",'otel.trace_exporter="none"',"-c",'otel.metrics_exporter="none"'],...t];return new Promise((a,l)=>{let d={...process.env,...this.config.environmentVariables(o)};n&&(d.CODER_APIKEY=n);let u=["--no-warnings"];process.env.CODEV_INSPECT_BRK==="True"&&u.push("--inspect-brk"),u.push(s,...i);let m=Nt("node",u,{env:d,stdio:["inherit","inherit","inherit","ipc"]});this.handleChildMessages(m),m.on("error",p=>{console.error(`Failed to start Codex: ${p.message}`),l(p)}),m.on("exit",async(p,f)=>{f&&console.log(`terminated by signal: ${f}`)}),process.on("SIGINT",async()=>{console.log(`
11
+ Terminating ...`),m.kill("SIGTERM"),setTimeout(()=>{m.killed||m.kill("SIGKILL")},8e3)})})}};Oe.exports=ee});var Te=$((vo,Ae)=>{var jt=R(),F=require("path"),Pe=require("fs"),te=class extends jt{constructor(){super({executablePaths:["gemini/gemini.js","../dist/gemini/gemini.js"],environmentVariables:e=>({GOOGLE_GEMINI_BASE_URL:`${e}/gemini`,GEMINI_API_KEY:"null",GOOGLE_API_KEY:"null",GOOGLE_CLOUD_PROJECT:"coder",GOOGLE_CLOUD_LOCATION:"coder",USE_VERTEX:!0,GEMINI_TELEMETRY_ENABLED:"false",GEMINI_TELEMETRY_LOG_PROMPTS:"false"})})}findExecutablePath(){let e=F.dirname(require.main.filename);for(let o of this.config.executablePaths){let n=F.resolve(e,o);if(Pe.existsSync(n))return n}let t=this._findGlobalMakecoderGemini();if(t)return t;throw new Error(`Could not find Gemini executable in any of the configured paths: ${this.config.executablePaths.join(", ")}`)}_findGlobalMakecoderGemini(){let e=F.dirname(process.execPath),t=[F.join(e,"..","lib","node_modules","makecoder","dist","gemini","gemini.js"),F.join(e,"node_modules","makecoder","dist","gemini","gemini.js")];for(let o of t)if(Pe.existsSync(o))return o;return null}};Ae.exports=te});var Be=$((_o,qe)=>{var Lt=R(),J=require("path"),oe=require("fs"),{spawn:Nt}=require("child_process"),Ut=process.env.CODEV_DEBUG==="True",ne=class extends Lt{constructor(){super({executablePaths:["codex.mjs","../dist/codex.mjs"],environmentVariables:()=>({CODEX_DISABLE_WEBSOCKET:"1"})})}checkCodexAvailability(){try{let e=this.findExecutablePath();return oe.existsSync(e)}catch{return!1}}findExecutablePath(){let e=J.dirname(require.main.filename);for(let o of this.config.executablePaths){let n=J.resolve(e,o);if(oe.existsSync(n))return n}let t=this._findGlobalMakecoderCodex();if(t)return t;throw new Error(`Could not find Codex executable in any of the configured paths: ${this.config.executablePaths.join(", ")}`)}_findGlobalMakecoderCodex(){let e=J.dirname(process.execPath),t=[J.join(e,"..","lib","node_modules","makecoder","dist","codex.mjs"),J.join(e,"node_modules","makecoder","dist","codex.mjs")];for(let o of t)if(oe.existsSync(o))return o;return null}async launch(e={}){let{remainingArgs:t=[],codevServer:o,apikey:n=null}=e;try{if(!this.checkCodexAvailability())throw new Error("Codex executable not found. Please ensure makecoder is properly installed: npm install -g makecoder@latest");let s=this.findExecutablePath();Ut&&console.log(`executablePath: ${s}`);let i=[...["-c",`openai_base_url="${o}/codex"`,"-c","analytics.enabled=false","-c","feedback.enabled=false","-c","check_for_update_on_startup=false","-c",'otel.exporter="none"',"-c",'otel.trace_exporter="none"',"-c",'otel.metrics_exporter="none"'],...t];return new Promise((a,l)=>{let d={...process.env,...this.config.environmentVariables(o)};n&&(d.CODER_APIKEY=n);let u=["--no-warnings"];process.env.CODEV_INSPECT_BRK==="True"&&u.push("--inspect-brk"),u.push(s,...i);let m=Nt("node",u,{env:d,stdio:["inherit","inherit","inherit","ipc"]});this.handleChildMessages(m),m.on("error",p=>{console.error(`Failed to start Codex: ${p.message}`),l(p)}),m.on("exit",async(p,f)=>{f&&console.log(`terminated by signal: ${f}`)}),process.on("SIGINT",async()=>{console.log(`
12
12
  Terminating ...`),m.kill("SIGTERM"),setTimeout(()=>{m.killed||m.kill("SIGKILL")},8e3)}),process.on("SIGTERM",async()=>{console.log(`
13
- Terminating ...`),m.kill("SIGTERM"),setTimeout(()=>{m.killed||m.kill("SIGKILL")},8e3)})})}catch(s){throw s}}};qe.exports=ne});var Ue=$((_o,Ne)=>{var G=require("fs"),je=require("path"),{spawn:Le}=require("child_process"),re=class{constructor(){this.extensionId="codev.codev-background";let e=require.main?je.dirname(require.main.filename):__dirname;this.extensionPath=je.resolve(e,"vendor/claude-code.vsix"),this._codeCommand=null}async resolveCodeCommand(){if(this._codeCommand)return this._codeCommand;if(process.env.IS_AISTUDIO==="True"){let e="/usr/lib/aistudio/lib/vscode/bin/remote-cli/aistudio";if(G.existsSync(e))try{return G.accessSync(e,G.constants.F_OK|G.constants.X_OK),this._codeCommand=e,process.env.CODEV_DEBUG&&console.log(`Using AI Studio VSCode path: ${e}`),this._codeCommand}catch(t){process.env.CODEV_DEBUG&&console.log(`AI Studio path exists but not executable: ${t.message}`)}else process.env.CODEV_DEBUG&&console.log(`AI Studio path not found: ${e}`)}try{let{spawn:e}=require("child_process");return new Promise(t=>{let o=e("which",["code"],{stdio:["ignore","pipe","ignore"]}),n="";o.stdout.on("data",s=>{n+=s.toString().trim()}),o.on("close",s=>{s===0&&n?(this._codeCommand=n,process.env.CODEV_DEBUG&&console.log(`Resolved code command path: ${n}`),t(this._codeCommand)):(this._codeCommand="code",t(this._codeCommand))}),o.on("error",()=>{this._codeCommand="code",t(this._codeCommand)}),setTimeout(()=>{o.kill(),this._codeCommand="code",t(this._codeCommand)},3e3)})}catch{return this._codeCommand="code",this._codeCommand}}async shouldInstallExtension(){try{return process.env.IS_AISTUDIO!=="True"?(process.env.CODEV_DEBUG&&console.log("Not in AI Studio environment (IS_AISTUDIO!=True), skipping extension installation"),!1):await this.isVSCodeAvailable()?await this.isExtensionInstalled()?(process.env.CODEV_DEBUG&&console.log(`Extension ${this.extensionId} already installed`),!1):!!G.existsSync(this.extensionPath):(process.env.CODEV_DEBUG&&console.log("VSCode not available, skipping extension installation"),!1)}catch(e){return process.env.CODEV_DEBUG&&console.error(`Error checking extension installation status: ${e.message}`),!1}}async installExtension(){try{return console.log("Installing Codev VSCode extension..."),await this.executeVSCodeCommand(["--install-extension",this.extensionPath])?(console.log("\u2705 Codev VSCode extension installed successfully"),!0):(console.warn("\u274C Failed to install Codev VSCode extension"),!1)}catch(e){return console.warn(`Error installing VSCode extension: ${e.message}`),!1}}async isVSCodeAvailable(){try{let e=process.env.IS_AISTUDIO==="True"?["--help"]:["--version"],t=await this.executeVSCodeCommand(e,{timeout:1e4});if(process.env.CODEV_DEBUG&&(console.log(`VSCode availability check (${e.join(" ")}): ${t?"available":"unavailable"}`),process.env.IS_AISTUDIO==="True")){let{spawn:o}=require("child_process");try{o("which",["code"],{stdio:["ignore","pipe","ignore"]}).stdout.on("data",s=>{console.log("which code:",s.toString().trim())})}catch(n){console.log("which command failed:",n.message)}}return t}catch(e){return process.env.CODEV_DEBUG&&console.error("VSCode availability check error:",e.message),!1}}async isExtensionInstalled(){let e=await this.resolveCodeCommand();try{return new Promise(t=>{try{let o={stdio:["ignore","pipe","ignore"],shell:!1,env:{...process.env,PATH:process.env.PATH,HOME:process.env.HOME,USER:process.env.USER}};process.env.CODEV_DEBUG&&console.log(`Spawning: ${e} --list-extensions`);let n=Le(e,["--list-extensions"],o),s="";n.stdout.on("data",r=>{s+=r.toString()}),n.on("close",r=>{if(r===0){let i=s.split(`
14
- `).map(a=>a.trim());t(i.includes(this.extensionId))}else t(!1)}),n.on("error",r=>{process.env.CODEV_DEBUG&&(console.error("VSCode list extensions error:",r.message),console.error("Error code:",r.code),console.error("Error errno:",r.errno),console.error("Error syscall:",r.syscall)),t(!1)}),setTimeout(()=>{try{n.kill()}catch{}t(!1)},1e4)}catch(o){process.env.CODEV_DEBUG&&console.error("Failed to spawn VSCode list extensions:",o.message),t(!1)}})}catch{return!1}}async executeVSCodeCommand(e,t={}){let o=await this.resolveCodeCommand();return new Promise(n=>{try{let s={stdio:"ignore",shell:!1,env:{...process.env,PATH:process.env.PATH,HOME:process.env.HOME,USER:process.env.USER}};process.env.CODEV_DEBUG&&console.log(`Spawning: ${o} ${e.join(" ")}`);let r=Le(o,e,s);r.on("close",a=>{n(a===0)}),r.on("error",a=>{process.env.CODEV_DEBUG&&(console.error("VSCode command error:",a.message),console.error("Error code:",a.code),console.error("Error errno:",a.errno),console.error("Error syscall:",a.syscall)),n(!1)});let i=t.timeout||3e4;setTimeout(()=>{try{r.kill()}catch{}n(!1)},i)}catch(s){process.env.CODEV_DEBUG&&console.error("Failed to spawn VSCode command:",s.message),n(!1)}})}async ensureExtensionInstalled(){try{process.env.CODEV_DEBUG&&console.log("VSCode Extension Service: Checking extension status..."),await this.shouldInstallExtension()&&await this.installExtension()}catch(e){process.env.CODEV_DEBUG&&console.error("VSCode Extension Service Error:",e)}}};Ne.exports=re});var Fe=$((Oo,Me)=>{var C=require("fs"),T=require("path"),Rt=require("readline"),{execSync:H}=require("child_process"),Re=require("os"),se=class{constructor(){this.serverUrl="https://makecoder.com/bigapis/codev/v1/coderpub"}getClaudeJsonlPath(e,t=!1){let o=e.replace(/[/_]/g,"-"),n=T.join(Re.homedir(),".claude","projects",o);if(t&&(console.log(`
15
- \u{1F4C2} [allow-clone] \u67E5\u627E JSONL \u6587\u4EF6...`),console.log(` \u9879\u76EE\u76EE\u5F55: ${e}`),console.log(` Claude \u9879\u76EE\u540D: ${o}`),console.log(` Claude \u9879\u76EE\u76EE\u5F55: ${n}`)),!C.existsSync(n))return t&&console.log(" \u274C Claude \u9879\u76EE\u76EE\u5F55\u4E0D\u5B58\u5728"),null;t&&console.log(" \u2713 Claude \u9879\u76EE\u76EE\u5F55\u5B58\u5728");try{let s=C.readdirSync(n).filter(r=>r.endsWith(".jsonl")).map(r=>({name:r,path:T.join(n,r),mtime:C.statSync(T.join(n,r)).mtime,size:C.statSync(T.join(n,r)).size})).sort((r,i)=>i.mtime-r.mtime);return t&&(console.log(` \u627E\u5230 ${s.length} \u4E2A JSONL \u6587\u4EF6:`),s.forEach((r,i)=>{let a=(r.size/1024).toFixed(2),l=r.mtime.toLocaleString(),d=i===0?" <- \u6700\u65B0":"";console.log(` ${i+1}. ${r.name} (${a} KB, ${l})${d}`)})),s.length>0?(t&&console.log(` \u2713 \u9009\u62E9\u6700\u65B0\u6587\u4EF6: ${s[0].name}`),s[0].path):(t&&console.log(" \u274C \u76EE\u5F55\u4E2D\u6CA1\u6709 JSONL \u6587\u4EF6"),null)}catch(s){return t&&console.log(` \u274C \u8BFB\u53D6\u76EE\u5F55\u5931\u8D25: ${s.message}`),null}}async promptForName(){let e=Rt.createInterface({input:process.stdin,output:process.stdout});return new Promise((t,o)=>{e.question("\u8BF7\u8F93\u5165\u9879\u76EE\u540D\u79F0 (name): ",n=>{e.close();let s=n.trim();if(!s){o(new Error("\u9879\u76EE\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A"));return}if(!/^[a-zA-Z0-9_-]+$/.test(s)){o(new Error("\u9879\u76EE\u540D\u79F0\u53EA\u80FD\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u548C\u8FDE\u5B57\u7B26"));return}t(s)})})}async createZip(e,t={}){let{allowClone:o=!1}=t,n=Re.tmpdir(),s=`coder-pub-${Date.now()}.zip`,r=T.join(n,s);try{let i=!1;if(C.existsSync(T.join(e,".git")))try{H(`git archive -o "${r}" HEAD`,{cwd:e,stdio:"pipe"}),console.log("\u{1F4E6} \u4F7F\u7528 git archive \u521B\u5EFA\u538B\u7F29\u5305\uFF08\u5DF2\u6392\u9664 .gitignore \u4E2D\u7684\u6587\u4EF6\uFF09"),i=!0}catch{console.log("\u26A0\uFE0F git archive \u5931\u8D25\uFF0C\u4F7F\u7528\u666E\u901A zip \u547D\u4EE4")}if(!i){let l=[".git/*","node_modules/*",".env",".env.*","*.log",".DS_Store"].map(d=>`-x "${d}"`).join(" ");H(`zip -r "${r}" . ${l}`,{cwd:e,stdio:"pipe"}),console.log("\u{1F4E6} \u5DF2\u521B\u5EFA\u538B\u7F29\u5305")}if(o){console.log(`
13
+ Terminating ...`),m.kill("SIGTERM"),setTimeout(()=>{m.killed||m.kill("SIGKILL")},8e3)})})}catch(s){throw s}}};qe.exports=ne});var Ue=$((Eo,Ne)=>{var G=require("fs"),je=require("path"),{spawn:Le}=require("child_process"),re=class{constructor(){this.extensionId="codev.codev-background";let e=require.main?je.dirname(require.main.filename):__dirname;this.extensionPath=je.resolve(e,"vendor/claude-code.vsix"),this._codeCommand=null}async resolveCodeCommand(){if(this._codeCommand)return this._codeCommand;if(process.env.IS_AISTUDIO==="True"){let e="/usr/lib/aistudio/lib/vscode/bin/remote-cli/aistudio";if(G.existsSync(e))try{return G.accessSync(e,G.constants.F_OK|G.constants.X_OK),this._codeCommand=e,process.env.CODEV_DEBUG&&console.log(`Using AI Studio VSCode path: ${e}`),this._codeCommand}catch(t){process.env.CODEV_DEBUG&&console.log(`AI Studio path exists but not executable: ${t.message}`)}else process.env.CODEV_DEBUG&&console.log(`AI Studio path not found: ${e}`)}try{let{spawn:e}=require("child_process");return new Promise(t=>{let o=e("which",["code"],{stdio:["ignore","pipe","ignore"]}),n="";o.stdout.on("data",s=>{n+=s.toString().trim()}),o.on("close",s=>{s===0&&n?(this._codeCommand=n,process.env.CODEV_DEBUG&&console.log(`Resolved code command path: ${n}`),t(this._codeCommand)):(this._codeCommand="code",t(this._codeCommand))}),o.on("error",()=>{this._codeCommand="code",t(this._codeCommand)}),setTimeout(()=>{o.kill(),this._codeCommand="code",t(this._codeCommand)},3e3)})}catch{return this._codeCommand="code",this._codeCommand}}async shouldInstallExtension(){try{return process.env.IS_AISTUDIO!=="True"?(process.env.CODEV_DEBUG&&console.log("Not in AI Studio environment (IS_AISTUDIO!=True), skipping extension installation"),!1):await this.isVSCodeAvailable()?await this.isExtensionInstalled()?(process.env.CODEV_DEBUG&&console.log(`Extension ${this.extensionId} already installed`),!1):!!G.existsSync(this.extensionPath):(process.env.CODEV_DEBUG&&console.log("VSCode not available, skipping extension installation"),!1)}catch(e){return process.env.CODEV_DEBUG&&console.error(`Error checking extension installation status: ${e.message}`),!1}}async installExtension(){try{return console.log("Installing Codev VSCode extension..."),await this.executeVSCodeCommand(["--install-extension",this.extensionPath])?(console.log("\u2705 Codev VSCode extension installed successfully"),!0):(console.warn("\u274C Failed to install Codev VSCode extension"),!1)}catch(e){return console.warn(`Error installing VSCode extension: ${e.message}`),!1}}async isVSCodeAvailable(){try{let e=process.env.IS_AISTUDIO==="True"?["--help"]:["--version"],t=await this.executeVSCodeCommand(e,{timeout:1e4});if(process.env.CODEV_DEBUG&&(console.log(`VSCode availability check (${e.join(" ")}): ${t?"available":"unavailable"}`),process.env.IS_AISTUDIO==="True")){let{spawn:o}=require("child_process");try{o("which",["code"],{stdio:["ignore","pipe","ignore"]}).stdout.on("data",s=>{console.log("which code:",s.toString().trim())})}catch(n){console.log("which command failed:",n.message)}}return t}catch(e){return process.env.CODEV_DEBUG&&console.error("VSCode availability check error:",e.message),!1}}async isExtensionInstalled(){let e=await this.resolveCodeCommand();try{return new Promise(t=>{try{let o={stdio:["ignore","pipe","ignore"],shell:!1,env:{...process.env,PATH:process.env.PATH,HOME:process.env.HOME,USER:process.env.USER}};process.env.CODEV_DEBUG&&console.log(`Spawning: ${e} --list-extensions`);let n=Le(e,["--list-extensions"],o),s="";n.stdout.on("data",r=>{s+=r.toString()}),n.on("close",r=>{if(r===0){let i=s.split(`
14
+ `).map(a=>a.trim());t(i.includes(this.extensionId))}else t(!1)}),n.on("error",r=>{process.env.CODEV_DEBUG&&(console.error("VSCode list extensions error:",r.message),console.error("Error code:",r.code),console.error("Error errno:",r.errno),console.error("Error syscall:",r.syscall)),t(!1)}),setTimeout(()=>{try{n.kill()}catch{}t(!1)},1e4)}catch(o){process.env.CODEV_DEBUG&&console.error("Failed to spawn VSCode list extensions:",o.message),t(!1)}})}catch{return!1}}async executeVSCodeCommand(e,t={}){let o=await this.resolveCodeCommand();return new Promise(n=>{try{let s={stdio:"ignore",shell:!1,env:{...process.env,PATH:process.env.PATH,HOME:process.env.HOME,USER:process.env.USER}};process.env.CODEV_DEBUG&&console.log(`Spawning: ${o} ${e.join(" ")}`);let r=Le(o,e,s);r.on("close",a=>{n(a===0)}),r.on("error",a=>{process.env.CODEV_DEBUG&&(console.error("VSCode command error:",a.message),console.error("Error code:",a.code),console.error("Error errno:",a.errno),console.error("Error syscall:",a.syscall)),n(!1)});let i=t.timeout||3e4;setTimeout(()=>{try{r.kill()}catch{}n(!1)},i)}catch(s){process.env.CODEV_DEBUG&&console.error("Failed to spawn VSCode command:",s.message),n(!1)}})}async ensureExtensionInstalled(){try{process.env.CODEV_DEBUG&&console.log("VSCode Extension Service: Checking extension status..."),await this.shouldInstallExtension()&&await this.installExtension()}catch(e){process.env.CODEV_DEBUG&&console.error("VSCode Extension Service Error:",e)}}};Ne.exports=re});var Fe=$((Oo,Me)=>{var C=require("fs"),T=require("path"),Rt=require("readline"),{execSync:K}=require("child_process"),Re=require("os"),se=class{constructor(){this.serverUrl="https://makecoder.com/bigapis/codev/v1/coderpub"}getClaudeJsonlPath(e,t=!1){let o=e.replace(/[/_]/g,"-"),n=T.join(Re.homedir(),".claude","projects",o);if(t&&(console.log(`
15
+ \u{1F4C2} [allow-clone] \u67E5\u627E JSONL \u6587\u4EF6...`),console.log(` \u9879\u76EE\u76EE\u5F55: ${e}`),console.log(` Claude \u9879\u76EE\u540D: ${o}`),console.log(` Claude \u9879\u76EE\u76EE\u5F55: ${n}`)),!C.existsSync(n))return t&&console.log(" \u274C Claude \u9879\u76EE\u76EE\u5F55\u4E0D\u5B58\u5728"),null;t&&console.log(" \u2713 Claude \u9879\u76EE\u76EE\u5F55\u5B58\u5728");try{let s=C.readdirSync(n).filter(r=>r.endsWith(".jsonl")).map(r=>({name:r,path:T.join(n,r),mtime:C.statSync(T.join(n,r)).mtime,size:C.statSync(T.join(n,r)).size})).sort((r,i)=>i.mtime-r.mtime);return t&&(console.log(` \u627E\u5230 ${s.length} \u4E2A JSONL \u6587\u4EF6:`),s.forEach((r,i)=>{let a=(r.size/1024).toFixed(2),l=r.mtime.toLocaleString(),d=i===0?" <- \u6700\u65B0":"";console.log(` ${i+1}. ${r.name} (${a} KB, ${l})${d}`)})),s.length>0?(t&&console.log(` \u2713 \u9009\u62E9\u6700\u65B0\u6587\u4EF6: ${s[0].name}`),s[0].path):(t&&console.log(" \u274C \u76EE\u5F55\u4E2D\u6CA1\u6709 JSONL \u6587\u4EF6"),null)}catch(s){return t&&console.log(` \u274C \u8BFB\u53D6\u76EE\u5F55\u5931\u8D25: ${s.message}`),null}}async promptForName(){let e=Rt.createInterface({input:process.stdin,output:process.stdout});return new Promise((t,o)=>{e.question("\u8BF7\u8F93\u5165\u9879\u76EE\u540D\u79F0 (name): ",n=>{e.close();let s=n.trim();if(!s){o(new Error("\u9879\u76EE\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A"));return}if(!/^[a-zA-Z0-9_-]+$/.test(s)){o(new Error("\u9879\u76EE\u540D\u79F0\u53EA\u80FD\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u548C\u8FDE\u5B57\u7B26"));return}t(s)})})}async createZip(e,t={}){let{allowClone:o=!1}=t,n=Re.tmpdir(),s=`coder-pub-${Date.now()}.zip`,r=T.join(n,s);try{let i=!1;if(C.existsSync(T.join(e,".git")))try{K(`git archive -o "${r}" HEAD`,{cwd:e,stdio:"pipe"}),console.log("\u{1F4E6} \u4F7F\u7528 git archive \u521B\u5EFA\u538B\u7F29\u5305\uFF08\u5DF2\u6392\u9664 .gitignore \u4E2D\u7684\u6587\u4EF6\uFF09"),i=!0}catch{console.log("\u26A0\uFE0F git archive \u5931\u8D25\uFF0C\u4F7F\u7528\u666E\u901A zip \u547D\u4EE4")}if(!i){let l=[".git/*","node_modules/*",".env",".env.*","*.log",".DS_Store"].map(d=>`-x "${d}"`).join(" ");K(`zip -r "${r}" . ${l}`,{cwd:e,stdio:"pipe"}),console.log("\u{1F4E6} \u5DF2\u521B\u5EFA\u538B\u7F29\u5305")}if(o){console.log(`
16
16
  \u{1F504} [allow-clone] \u5F00\u59CB\u5904\u7406 AI \u751F\u6210\u8BB0\u5F55...`);let a=this.getClaudeJsonlPath(e,!0);if(a){let l=T.join(n,"coder.pub.jsonl"),u=(C.statSync(a).size/1024).toFixed(2);console.log(`
17
- \u{1F4E6} [allow-clone] \u6253\u5305 JSONL \u6587\u4EF6...`),console.log(` \u6E90\u6587\u4EF6: ${a}`),console.log(` \u6587\u4EF6\u5927\u5C0F: ${u} KB`),console.log(` \u4E34\u65F6\u6587\u4EF6: ${l}`),C.copyFileSync(a,l),console.log(" \u2713 \u5DF2\u590D\u5236\u5230\u4E34\u65F6\u76EE\u5F55"),console.log(` \u76EE\u6807 ZIP: ${r}`),console.log(" \u76EE\u6807\u6587\u4EF6\u540D: coder.pub.jsonl"),H(`zip -j "${r}" "${l}"`,{stdio:"pipe"}),console.log(" \u2713 \u5DF2\u6DFB\u52A0\u5230 ZIP \u5305"),C.unlinkSync(l),console.log(" \u2713 \u5DF2\u6E05\u7406\u4E34\u65F6\u6587\u4EF6"),console.log(`\u{1F4CB} [allow-clone] AI \u751F\u6210\u8BB0\u5F55\u5904\u7406\u5B8C\u6210 (coder.pub.jsonl)
17
+ \u{1F4E6} [allow-clone] \u6253\u5305 JSONL \u6587\u4EF6...`),console.log(` \u6E90\u6587\u4EF6: ${a}`),console.log(` \u6587\u4EF6\u5927\u5C0F: ${u} KB`),console.log(` \u4E34\u65F6\u6587\u4EF6: ${l}`),C.copyFileSync(a,l),console.log(" \u2713 \u5DF2\u590D\u5236\u5230\u4E34\u65F6\u76EE\u5F55"),console.log(` \u76EE\u6807 ZIP: ${r}`),console.log(" \u76EE\u6807\u6587\u4EF6\u540D: coder.pub.jsonl"),K(`zip -j "${r}" "${l}"`,{stdio:"pipe"}),console.log(" \u2713 \u5DF2\u6DFB\u52A0\u5230 ZIP \u5305"),C.unlinkSync(l),console.log(" \u2713 \u5DF2\u6E05\u7406\u4E34\u65F6\u6587\u4EF6"),console.log(`\u{1F4CB} [allow-clone] AI \u751F\u6210\u8BB0\u5F55\u5904\u7406\u5B8C\u6210 (coder.pub.jsonl)
18
18
  `)}else console.log(`\u26A0\uFE0F [allow-clone] \u672A\u627E\u5230 Claude Code \u751F\u6210\u8BB0\u5F55
19
- `)}return r}catch(i){throw new Error(`\u521B\u5EFA\u538B\u7F29\u5305\u5931\u8D25: ${i.message}`)}}async upload(e,t,o,n,s=!1){let r=n?`${n}/coderpub`:this.serverUrl,i=o;console.log("\u{1F4E4} \u6B63\u5728\u4E0A\u4F20\u5230\u670D\u52A1\u5668..."),s&&(console.log(` \u670D\u52A1\u5668\u5730\u5740: ${r}`),console.log(` \u9879\u76EE\u540D\u79F0: ${t}`),console.log(` ZIP \u6587\u4EF6: ${e}`));try{let a=`curl -s -X POST "${r}" -H "Authorization: Bearer ${i}" -F "name=${t}" -F "zip_file=@${e}"`;s&&console.log(" \u6267\u884C\u4E0A\u4F20\u547D\u4EE4...");let l=H(a,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]});return s&&console.log(" \u2713 \u4E0A\u4F20\u5B8C\u6210\uFF0C\u89E3\u6790\u54CD\u5E94..."),JSON.parse(l)}catch(a){if(a.stdout)try{return JSON.parse(a.stdout)}catch{throw new Error(`\u4E0A\u4F20\u5931\u8D25: ${a.message}`)}throw new Error(`\u4E0A\u4F20\u5931\u8D25: ${a.message}`)}}cleanup(e){try{C.existsSync(e)&&C.unlinkSync(e)}catch{}}async publish(e){let{apikey:t,serverBaseUrl:o,allowClone:n}=e,{name:s}=e,r=null;try{s||(s=await this.promptForName()),console.log(`
19
+ `)}return r}catch(i){throw new Error(`\u521B\u5EFA\u538B\u7F29\u5305\u5931\u8D25: ${i.message}`)}}async upload(e,t,o,n,s=!1){let r=n?`${n}/coderpub`:this.serverUrl,i=o;console.log("\u{1F4E4} \u6B63\u5728\u4E0A\u4F20\u5230\u670D\u52A1\u5668..."),s&&(console.log(` \u670D\u52A1\u5668\u5730\u5740: ${r}`),console.log(` \u9879\u76EE\u540D\u79F0: ${t}`),console.log(` ZIP \u6587\u4EF6: ${e}`));try{let a=`curl -s -X POST "${r}" -H "Authorization: Bearer ${i}" -F "name=${t}" -F "zip_file=@${e}"`;s&&console.log(" \u6267\u884C\u4E0A\u4F20\u547D\u4EE4...");let l=K(a,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]});return s&&console.log(" \u2713 \u4E0A\u4F20\u5B8C\u6210\uFF0C\u89E3\u6790\u54CD\u5E94..."),JSON.parse(l)}catch(a){if(a.stdout)try{return JSON.parse(a.stdout)}catch{throw new Error(`\u4E0A\u4F20\u5931\u8D25: ${a.message}`)}throw new Error(`\u4E0A\u4F20\u5931\u8D25: ${a.message}`)}}cleanup(e){try{C.existsSync(e)&&C.unlinkSync(e)}catch{}}async publish(e){let{apikey:t,serverBaseUrl:o,allowClone:n}=e,{name:s}=e,r=null;try{s||(s=await this.promptForName()),console.log(`
20
20
  \u{1F680} \u6B63\u5728\u53D1\u5E03\u9879\u76EE: ${s}`),console.log(`\u{1F4C1} \u76EE\u5F55: ${process.cwd()}`),n&&console.log("\u{1F513} allow-clone: \u542F\u7528 (\u5C06\u5305\u542B AI \u751F\u6210\u8BB0\u5F55)"),console.log(),r=await this.createZip(process.cwd(),{allowClone:n});let a=(C.statSync(r).size/(1024*1024)).toFixed(2);console.log(`\u{1F4CA} \u538B\u7F29\u5305\u5927\u5C0F: ${a} MB`),n&&console.log(`
21
21
  \u{1F310} [allow-clone] \u5F00\u59CB\u4E0A\u4F20\u5230\u670D\u52A1\u5668...`);let l=await this.upload(r,s,t,o,n);return l.code===0?(console.log(`
22
22
  \u2705 \u53D1\u5E03\u6210\u529F!`),console.log(`\u{1F4CC} \u7248\u672C: ${l.data.version}`),console.log(`\u{1F310} \u8BBF\u95EE\u5730\u5740: https://${s}.coder.pub/`),0):(console.error(`
23
23
  \u274C \u53D1\u5E03\u5931\u8D25: ${l.message||l.reason}`),1)}catch(i){return console.error(`
24
24
  \u274C ${i.message}`),1}finally{r&&this.cleanup(r)}}showHelp(){console.log(["Usage: coder pub [options]","","\u53D1\u5E03\u5F53\u524D\u76EE\u5F55\u4E3A MakeCoder \u7F51\u9875\u5E94\u7528","","Options:"," --name <name> \u5E94\u7528\u540D\u79F0\uFF08\u5FC5\u9700\uFF09"," --allow-clone \u5305\u542B Claude Code \u751F\u6210\u8BB0\u5F55\uFF0C\u5141\u8BB8\u4ED6\u4EBA\u514B\u9686"," --help, -h \u663E\u793A\u6B64\u5E2E\u52A9\u4FE1\u606F","","Description:"," \u5C06\u5F53\u524D\u76EE\u5F55\u7684\u4EE3\u7801\u53D1\u5E03\u4E3A MakeCoder \u5E73\u53F0\u4E0A\u7684\u7F51\u9875\u5E94\u7528\u3002"," \u5E94\u7528\u5C06\u5728 https://<name>.coder.pub/ \u4E0A\u53EF\u8BBF\u95EE\u3002","","Examples:"," coder pub --name myapp \u53D1\u5E03\u5E94\u7528\uFF0C\u8BBF\u95EE\u5730\u5740: https://myapp.coder.pub/"," coder pub --name myapp --allow-clone \u53D1\u5E03\u5E94\u7528\u5E76\u5305\u542B\u751F\u6210\u8BB0\u5F55","","Notes:"," - \u5E94\u7528\u540D\u79F0\u53EA\u80FD\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u548C\u8FDE\u5B57\u7B26"," - \u4F7F\u7528 git archive \u521B\u5EFA\u538B\u7F29\u5305\uFF08\u81EA\u52A8\u6392\u9664 .gitignore \u4E2D\u7684\u6587\u4EF6\uFF09"," - \u5982\u679C\u4E0D\u662F git \u4ED3\u5E93\uFF0C\u5C06\u4F7F\u7528\u666E\u901A zip \u547D\u4EE4"].join(`
25
- `))}};Me.exports=se});var Ve=$((Do,Ge)=>{var Je=require("https"),w=require("fs"),k=require("path"),K=require("os"),O="https://makecoder.com/skillhub",ie=class{getSkillDirs(){let e=K.homedir();return[k.join(e,".agents","skills")]}fetchWithAuth(e,t){return new Promise((o,n)=>{let s=new URL(e),r={hostname:s.hostname,port:s.port||443,path:s.pathname+s.search,method:"GET",headers:t?{Authorization:`Bearer ${t}`}:{}};Je.get(r,i=>{if(i.statusCode>=300&&i.statusCode<400&&i.headers.location)return this.fetchWithAuth(i.headers.location,t).then(o).catch(n);let a="";i.on("data",l=>{a+=l}),i.on("end",()=>o({status:i.statusCode,body:a}))}).on("error",n)})}async handle({skillsSubcommand:e,skillsArg:t,skillsRemainingArgs:o,apikey:n}){if(!e||e==="--help"||e==="-h")return this.showHelp(),0;if(e==="publish")return await this.publish(o||[],n);if(e==="unpublish")return await this.unpublish(t,n);if(e==="list")return await this.listMySkills(n);if(e==="namespaces")return await this.listNamespaces(n);if(e==="check-updates"){let s=this.getInstalledSkills();if(s.length===0)return console.log("\u6CA1\u6709\u5DF2\u5B89\u88C5\u7684 skill"),0;console.log(`\u{1F50D} \u68C0\u67E5 ${s.length} \u4E2A skill \u7684\u66F4\u65B0...`);let r=await this.checkUpdates(n);if(r.length===0)console.log("\u2705 \u6240\u6709 skill \u5747\u4E3A\u6700\u65B0\u7248\u672C");else{console.log(`
25
+ `))}};Me.exports=se});var Ve=$((Do,Ge)=>{var Je=require("https"),w=require("fs"),k=require("path"),H=require("os"),O="https://makecoder.com/skillhub",ie=class{getSkillDirs(){let e=H.homedir();return[k.join(e,".agents","skills")]}fetchWithAuth(e,t){return new Promise((o,n)=>{let s=new URL(e),r={hostname:s.hostname,port:s.port||443,path:s.pathname+s.search,method:"GET",headers:t?{Authorization:`Bearer ${t}`}:{}};Je.get(r,i=>{if(i.statusCode>=300&&i.statusCode<400&&i.headers.location)return this.fetchWithAuth(i.headers.location,t).then(o).catch(n);let a="";i.on("data",l=>{a+=l}),i.on("end",()=>o({status:i.statusCode,body:a}))}).on("error",n)})}async handle({skillsSubcommand:e,skillsArg:t,skillsRemainingArgs:o,apikey:n}){if(!e||e==="--help"||e==="-h")return this.showHelp(),0;if(e==="publish")return await this.publish(o||[],n);if(e==="unpublish")return await this.unpublish(t,n);if(e==="list")return await this.listMySkills(n);if(e==="namespaces")return await this.listNamespaces(n);if(e==="check-updates"){let s=this.getInstalledSkills();if(s.length===0)return console.log("\u6CA1\u6709\u5DF2\u5B89\u88C5\u7684 skill"),0;console.log(`\u{1F50D} \u68C0\u67E5 ${s.length} \u4E2A skill \u7684\u66F4\u65B0...`);let r=await this.checkUpdates(n);if(r.length===0)console.log("\u2705 \u6240\u6709 skill \u5747\u4E3A\u6700\u65B0\u7248\u672C");else{console.log(`
26
26
  \u53D1\u73B0 ${r.length} \u4E2A\u53EF\u66F4\u65B0\u7684 skill:
27
27
  `);for(let i of r)console.log(` ${i.name.padEnd(24)} ${i.localVersion} \u2192 ${i.remoteVersion}`);console.log("\n\u8FD0\u884C `coder skills update` \u66F4\u65B0\u5168\u90E8")}return 0}if(t&&e!=="search"&&!/^[@a-zA-Z0-9_\-/.]+$/.test(t))return console.error("\u274C skill \u540D\u79F0\u5305\u542B\u975E\u6CD5\u5B57\u7B26"),1;if(e==="search")return t?await this.search(t):(console.error("\u274C \u8BF7\u6307\u5B9A\u641C\u7D22\u5173\u952E\u8BCD"),1);if(e==="remove")return t?this.remove(t):(console.error("\u274C \u8BF7\u6307\u5B9A skill \u540D\u79F0"),1);if(e==="add")return t?n?await this.install(t,n):(console.error("\u274C \u7F3A\u5C11 API Key\uFF0C\u8BF7\u5148\u767B\u5F55: coder auth login"),1):(console.error("\u274C \u8BF7\u6307\u5B9A skill \u540D\u79F0"),1);if(e==="update"){if(!n)return console.error("\u274C \u7F3A\u5C11 API Key\uFF0C\u8BF7\u5148\u767B\u5F55: coder auth login"),1;if(t)return await this.install(t,n);console.log("\u{1F50D} \u68C0\u67E5\u53EF\u66F4\u65B0\u7684 skill...");let s=await this.checkUpdates(n);if(s.length===0)return console.log("\u2705 \u6240\u6709 skill \u5747\u4E3A\u6700\u65B0\u7248\u672C"),0;console.log(`\u{1F4E6} \u53D1\u73B0 ${s.length} \u4E2A\u53EF\u66F4\u65B0\u7684 skill\uFF0C\u5F00\u59CB\u66F4\u65B0...
28
28
  `);let r=0,i=0,a=!1;for(let l of s){let d=await this.install(l.name,n);d==="EACCES"?(a=!0,i++):d!==0?i++:r++}console.log(`
29
- \u66F4\u65B0\u5B8C\u6210: ${r} \u6210\u529F, ${i} \u5931\u8D25`);try{let l=k.join(K.homedir(),".agents","skills",".update-cache.json");w.existsSync(l)&&w.unlinkSync(l)}catch{}if(a){let l=this.getSkillDirs()[0];console.error(`
29
+ \u66F4\u65B0\u5B8C\u6210: ${r} \u6210\u529F, ${i} \u5931\u8D25`);try{let l=k.join(H.homedir(),".agents","skills",".update-cache.json");w.existsSync(l)&&w.unlinkSync(l)}catch{}if(a){let l=this.getSkillDirs()[0];console.error(`
30
30
  \u26A0\uFE0F \u90E8\u5206 skill \u6743\u9650\u4E0D\u8DB3\uFF0C\u8BF7\u5148\u8FD0\u884C:
31
- sudo chown -R $(whoami) "${l}"`)}return i>0?1:0}return console.error(`\u274C \u672A\u77E5\u5B50\u547D\u4EE4: ${e}`),1}async install(e,t){let o=O.replace(/\/$/,"");console.log(`\u{1F50D} \u6B63\u5728\u4ECE ${O} \u67E5\u627E skill...`);let n;try{let u=await this.fetchWithAuth(`${o}/.well-known/agent-skills/index.json?skill=${encodeURIComponent(e)}`,t);if(u.status===404)return console.error(`\u274C \u672A\u627E\u5230 skill: ${e}`),1;if(u.status!==200)return console.error(`\u274C \u65E0\u6CD5\u83B7\u53D6 skill \u4FE1\u606F (HTTP ${u.status})`),1;n=JSON.parse(u.body)}catch(u){return console.error(`\u274C \u8BF7\u6C42\u5931\u8D25: ${u.message}`),1}let s=(n.skills||[])[0];if(!s)return console.error(`\u274C \u672A\u627E\u5230 skill: ${e}`),1;let r=Array.from(new Set(["SKILL.md",...s.files||[]])),i=`${o}/.well-known/agent-skills/${s.name}`,a={};for(let u of r)try{let m=await this.fetchWithAuth(`${i}/${u}`,t);if(m.status!==200){console.warn(`\u26A0\uFE0F \u8DF3\u8FC7 ${u} (HTTP ${m.status})`);continue}a[u]=m.body}catch(m){console.warn(`\u26A0\uFE0F \u4E0B\u8F7D ${u} \u5931\u8D25: ${m.message}`)}console.log(`\u{1F4E6} \u6B63\u5728\u5B89\u88C5 ${s.name}...`);let l={name:s.name,version:s.version||null,installedAt:new Date().toISOString()};for(let u of this.getSkillDirs()){let m=k.join(u,s.name);w.mkdirSync(m,{recursive:!0});try{for(let[p,f]of Object.entries(a)){let g=k.join(m,p);w.mkdirSync(k.dirname(g),{recursive:!0}),w.writeFileSync(g,f,"utf8")}w.writeFileSync(k.join(m,".skill-meta.json"),JSON.stringify(l,null,2),"utf8")}catch(p){if(p.code==="EACCES")return"EACCES";throw p}}let d=s.version?` (v${s.version})`:"";return console.log(`\u2705 ${s.name}${d} \u5B89\u88C5\u5B8C\u6210`),this.cleanLegacySkill(s.name),0}cleanLegacySkill(e){let t=K.homedir(),o=[".claude",".codex",".gemini"].map(n=>k.join(t,n,"skills",e));for(let n of o)if(w.existsSync(n))try{w.rmSync(n,{recursive:!0,force:!0})}catch{}}getInstalledSkills(){let e=[];for(let t of this.getSkillDirs())if(w.existsSync(t))for(let o of w.readdirSync(t,{withFileTypes:!0})){if(!o.isDirectory()||o.name.startsWith("."))continue;let n=k.join(t,o.name),s=k.join(n,".skill-meta.json"),r=null;if(w.existsSync(s))try{r=JSON.parse(w.readFileSync(s,"utf8"))}catch{}e.push({name:o.name,dir:n,meta:r})}return e}async checkUpdates(e){let t=this.getInstalledSkills();if(t.length===0)return[];let o=O.replace(/\/$/,""),n=[];for(let s of t){let r=s.meta?.version||"0.0.1";try{let i=await this.fetchWithAuth(`${o}/.well-known/agent-skills/index.json?skill=${encodeURIComponent(s.name)}`,e);if(i.status===404||i.status!==200)continue;let l=(JSON.parse(i.body).skills||[])[0];if(!l?.version)continue;l.version!==r&&n.push({name:s.name,localVersion:r,remoteVersion:l.version})}catch{}}return n}notifyAndRefreshUpdates(e){let t=k.join(K.homedir(),".agents","skills",".update-cache.json");try{if(w.existsSync(t)){let r=JSON.parse(w.readFileSync(t,"utf8"));if(Array.isArray(r.updates)&&r.updates.length>0){let a=r.updates.length,l;if(a<=3)l=r.updates.map(d=>`${d.name} (${d.localVersion} \u2192 ${d.remoteVersion})`).join(", ");else{let d=r.updates[0];l=`${d.name} (${d.localVersion} \u2192 ${d.remoteVersion}) \u7B49 ${a} \u4E2A skill \u8981\u66F4\u65B0`}console.log(`\x1B[33m\u26A1 ${l}\uFF0C\u8FD0\u884C \`coder skills update\` \u5347\u7EA7\x1B[0m`),a>3&&console.log("\x1B[33m \u8FD0\u884C `coder skills check-updates` \u67E5\u770B\u5B8C\u6574\u5217\u8868\x1B[0m"),console.log()}}}catch{}let o=3600*1e3,n=0;try{n=JSON.parse(w.readFileSync(t,"utf8")).checkedAt||0}catch{}!this.getInstalledSkills().some(r=>!r.meta?.version)&&Date.now()-n<o||setImmediate(async()=>{try{let r=await this.checkUpdates(e);w.mkdirSync(k.dirname(t),{recursive:!0}),w.writeFileSync(t,JSON.stringify({checkedAt:Date.now(),updates:r},null,2),"utf8")}catch{}})}remove(e){let t=!1;for(let o of this.getSkillDirs()){let n=k.join(o,e);w.existsSync(n)&&(w.rmSync(n,{recursive:!0,force:!0}),console.log(` \u{1F5D1}\uFE0F ${n}`),t=!0)}return t?(console.log(`\u2705 ${e} \u5DF2\u5220\u9664`),0):(console.error(`\u274C \u672A\u627E\u5230\u5DF2\u5B89\u88C5\u7684 skill: ${e}`),1)}async search(e){let t=`${O}/api/web/skills?q=${encodeURIComponent(e)}&sort=relevance&page=0&size=12`;return new Promise(o=>{Je.get(t,n=>{let s="";n.on("data",r=>{s+=r}),n.on("end",()=>{try{let r=JSON.parse(s);if(r.code!==0)return console.error(`\u274C \u67E5\u8BE2\u5931\u8D25: ${r.msg}`),o(1);let i=r.data.items;if(i.length===0)return console.log(`\u6CA1\u6709\u627E\u5230\u4E0E "${e}" \u76F8\u5173\u7684 skill`),o(0);console.log(`\u627E\u5230 ${r.data.total} \u4E2A\u7ED3\u679C:
31
+ sudo chown -R $(whoami) "${l}"`)}return i>0?1:0}return console.error(`\u274C \u672A\u77E5\u5B50\u547D\u4EE4: ${e}`),1}async install(e,t){let o=O.replace(/\/$/,"");console.log(`\u{1F50D} \u6B63\u5728\u4ECE ${O} \u67E5\u627E skill...`);let n;try{let u=await this.fetchWithAuth(`${o}/.well-known/agent-skills/index.json?skill=${encodeURIComponent(e)}`,t);if(u.status===404)return console.error(`\u274C \u672A\u627E\u5230 skill: ${e}`),1;if(u.status!==200)return console.error(`\u274C \u65E0\u6CD5\u83B7\u53D6 skill \u4FE1\u606F (HTTP ${u.status})`),1;n=JSON.parse(u.body)}catch(u){return console.error(`\u274C \u8BF7\u6C42\u5931\u8D25: ${u.message}`),1}let s=(n.skills||[])[0];if(!s)return console.error(`\u274C \u672A\u627E\u5230 skill: ${e}`),1;let r=Array.from(new Set(["SKILL.md",...s.files||[]])),i=`${o}/.well-known/agent-skills/${s.name}`,a={};for(let u of r)try{let m=await this.fetchWithAuth(`${i}/${u}`,t);if(m.status!==200){console.warn(`\u26A0\uFE0F \u8DF3\u8FC7 ${u} (HTTP ${m.status})`);continue}a[u]=m.body}catch(m){console.warn(`\u26A0\uFE0F \u4E0B\u8F7D ${u} \u5931\u8D25: ${m.message}`)}console.log(`\u{1F4E6} \u6B63\u5728\u5B89\u88C5 ${s.name}...`);let l={name:s.name,version:s.version||null,installedAt:new Date().toISOString()};for(let u of this.getSkillDirs()){let m=k.join(u,s.name);w.mkdirSync(m,{recursive:!0});try{for(let[p,f]of Object.entries(a)){let g=k.join(m,p);w.mkdirSync(k.dirname(g),{recursive:!0}),w.writeFileSync(g,f,"utf8")}w.writeFileSync(k.join(m,".skill-meta.json"),JSON.stringify(l,null,2),"utf8")}catch(p){if(p.code==="EACCES")return"EACCES";throw p}}let d=s.version?` (v${s.version})`:"";return console.log(`\u2705 ${s.name}${d} \u5B89\u88C5\u5B8C\u6210`),this.cleanLegacySkill(s.name),0}cleanLegacySkill(e){let t=H.homedir(),o=[".claude",".codex",".gemini"].map(n=>k.join(t,n,"skills",e));for(let n of o)if(w.existsSync(n))try{w.rmSync(n,{recursive:!0,force:!0})}catch{}}getInstalledSkills(){let e=[];for(let t of this.getSkillDirs())if(w.existsSync(t))for(let o of w.readdirSync(t,{withFileTypes:!0})){if(!o.isDirectory()||o.name.startsWith("."))continue;let n=k.join(t,o.name),s=k.join(n,".skill-meta.json"),r=null;if(w.existsSync(s))try{r=JSON.parse(w.readFileSync(s,"utf8"))}catch{}e.push({name:o.name,dir:n,meta:r})}return e}async checkUpdates(e){let t=this.getInstalledSkills();if(t.length===0)return[];let o=O.replace(/\/$/,""),n=[];for(let s of t){let r=s.meta?.version||"0.0.1";try{let i=await this.fetchWithAuth(`${o}/.well-known/agent-skills/index.json?skill=${encodeURIComponent(s.name)}`,e);if(i.status===404||i.status!==200)continue;let l=(JSON.parse(i.body).skills||[])[0];if(!l?.version)continue;l.version!==r&&n.push({name:s.name,localVersion:r,remoteVersion:l.version})}catch{}}return n}notifyAndRefreshUpdates(e){let t=k.join(H.homedir(),".agents","skills",".update-cache.json");try{if(w.existsSync(t)){let r=JSON.parse(w.readFileSync(t,"utf8"));if(Array.isArray(r.updates)&&r.updates.length>0){let a=r.updates.length,l;if(a<=3)l=r.updates.map(d=>`${d.name} (${d.localVersion} \u2192 ${d.remoteVersion})`).join(", ");else{let d=r.updates[0];l=`${d.name} (${d.localVersion} \u2192 ${d.remoteVersion}) \u7B49 ${a} \u4E2A skill \u8981\u66F4\u65B0`}console.log(`\x1B[33m\u26A1 ${l}\uFF0C\u8FD0\u884C \`coder skills update\` \u5347\u7EA7\x1B[0m`),a>3&&console.log("\x1B[33m \u8FD0\u884C `coder skills check-updates` \u67E5\u770B\u5B8C\u6574\u5217\u8868\x1B[0m"),console.log()}}}catch{}let o=3600*1e3,n=0;try{n=JSON.parse(w.readFileSync(t,"utf8")).checkedAt||0}catch{}!this.getInstalledSkills().some(r=>!r.meta?.version)&&Date.now()-n<o||setImmediate(async()=>{try{let r=await this.checkUpdates(e);w.mkdirSync(k.dirname(t),{recursive:!0}),w.writeFileSync(t,JSON.stringify({checkedAt:Date.now(),updates:r},null,2),"utf8")}catch{}})}remove(e){let t=!1;for(let o of this.getSkillDirs()){let n=k.join(o,e);w.existsSync(n)&&(w.rmSync(n,{recursive:!0,force:!0}),console.log(` \u{1F5D1}\uFE0F ${n}`),t=!0)}return t?(console.log(`\u2705 ${e} \u5DF2\u5220\u9664`),0):(console.error(`\u274C \u672A\u627E\u5230\u5DF2\u5B89\u88C5\u7684 skill: ${e}`),1)}async search(e){let t=`${O}/api/web/skills?q=${encodeURIComponent(e)}&sort=relevance&page=0&size=12`;return new Promise(o=>{Je.get(t,n=>{let s="";n.on("data",r=>{s+=r}),n.on("end",()=>{try{let r=JSON.parse(s);if(r.code!==0)return console.error(`\u274C \u67E5\u8BE2\u5931\u8D25: ${r.msg}`),o(1);let i=r.data.items;if(i.length===0)return console.log(`\u6CA1\u6709\u627E\u5230\u4E0E "${e}" \u76F8\u5173\u7684 skill`),o(0);console.log(`\u627E\u5230 ${r.data.total} \u4E2A\u7ED3\u679C:
32
32
  `);for(let a of i)console.log(` ${a.slug.padEnd(20)} ${a.summary}`);o(0)}catch(r){console.error(`\u274C \u89E3\u6790\u54CD\u5E94\u5931\u8D25: ${r.message}`),o(1)}})}).on("error",n=>{console.error(`\u274C \u8BF7\u6C42\u5931\u8D25: ${n.message}`),o(1)})})}async publish(e,t){let{execSync:o}=require("child_process"),n=require("os"),s="global",r="PUBLIC",i=null,a=null,l=null,d=null;for(let y=0;y<e.length;y++)if(e[y]==="--namespace"||e[y]==="-n")s=e[++y];else if(e[y]==="--visibility"||e[y]==="-v")r=e[++y];else if(e[y]==="--meta-data"){let h=e[++y];try{JSON.parse(h)}catch(I){return console.error(`\u274C --meta-data \u4E0D\u662F\u5408\u6CD5\u7684 JSON\uFF1A${I.message}`),1}i=h}else if(!e[y].startsWith("-")){let h=e[y];w.existsSync(h)&&w.statSync(h).isDirectory()?d=h:a=h}if(!t)return console.error("\u274C \u7F3A\u5C11 API Key\uFF0C\u8BF7\u5148\u767B\u5F55: coder auth login"),1;let u=s.startsWith("@")?s.slice(1):s;u==="global"||(r="NAMESPACE_ONLY");let p=["PUBLIC","NAMESPACE_ONLY","PRIVATE"];if(!p.includes(r))return console.error(`\u274C visibility \u5FC5\u987B\u662F: ${p.join(", ")}`),1;if(a){if(!w.existsSync(a))return console.error(`\u274C \u6587\u4EF6\u4E0D\u5B58\u5728: ${a}`),1}else{let y=d?k.resolve(d):process.cwd();l=k.join(n.tmpdir(),`skill-pub-${Date.now()}.zip`),console.log(`\u{1F4E6} \u6B63\u5728\u6253\u5305 ${y}...`);try{w.existsSync(k.join(y,".git"))?(o(`git archive -o "${l}" HEAD`,{cwd:y,stdio:"pipe"}),console.log(" \u4F7F\u7528 git archive\uFF08\u5DF2\u6392\u9664 .gitignore \u6587\u4EF6\uFF09")):o(`zip -r "${l}" . -x ".git/*" -x "node_modules/*" -x ".env" -x "*.log"`,{cwd:y,stdio:"pipe"})}catch(h){return console.error(`\u274C \u6253\u5305\u5931\u8D25: ${h.message}`),1}a=l}let f=`${O}/api/v1/skills/${encodeURIComponent(u)}/publish?visibility=${encodeURIComponent(r)}`,g=t;console.log(`\u{1F680} \u6B63\u5728\u53D1\u5E03\u5230 ${O}...`),console.log(` namespace: ${u}`),console.log(` visibility: ${r}`);try{let y=i?` -F "meta_data=${i.replace(/"/g,'\\"')}"`:"",h=`curl -s -X POST "${f}" -H "Authorization: Bearer ${g}" -F "file=@${a}"${y}`,I=o(h,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}),b=JSON.parse(I);if(b.code===0){let S=b.data;return console.log(`
33
33
  \u2705 \u53D1\u5E03\u6210\u529F!`),console.log(` ${S.namespace}/${S.slug}@${S.version}`),S.status==="PUBLISHED"?console.log(" \u72B6\u6001: \u5DF2\u53D1\u5E03"):console.log(" \u72B6\u6001: \u5F85\u5BA1\u6838"),0}else return console.error(`
34
34
  \u274C \u53D1\u5E03\u5931\u8D25: ${b.msg||JSON.stringify(b)}`),1}catch(y){let h=y.stdout;if(h)try{let I=JSON.parse(h);return console.error(`
35
35
  \u274C \u53D1\u5E03\u5931\u8D25: ${I.msg||h}`),1}catch{}return console.error(`\u274C \u8BF7\u6C42\u5931\u8D25: ${y.message}`),1}finally{l&&w.existsSync(l)&&w.unlinkSync(l)}}async unpublish(e,t){let{execSync:o}=require("child_process");if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A skill: coder skills unpublish <namespace>/<slug>"),1;if(!t)return console.error("\u274C \u7F3A\u5C11 API Key\uFF0C\u8BF7\u5148\u767B\u5F55: coder auth login"),1;let n=e.split("/");if(n.length!==2||!n[0]||!n[1])return console.error("\u274C \u683C\u5F0F\u9519\u8BEF\uFF0C\u5E94\u4E3A <namespace>/<slug>\uFF0C\u4F8B\u5982: global/my-skill"),1;let[s,r]=n,i=s.startsWith("@")?s.slice(1):s,a=`${O}/api/v1/skills/${encodeURIComponent(i)}/${encodeURIComponent(r)}`,l=t;console.log(`\u{1F5D1}\uFE0F \u6B63\u5728\u4E0B\u67B6 ${i}/${r}...`);try{let d=o(`curl -s -X DELETE "${a}" -H "Authorization: Bearer ${l}"`,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}),u=JSON.parse(d);return u.code===0?(console.log(`\u2705 \u5DF2\u4E0B\u67B6 ${i}/${r}`),0):(console.error(`\u274C \u4E0B\u67B6\u5931\u8D25: ${u.msg||JSON.stringify(u)}`),1)}catch(d){return console.error(`\u274C \u8BF7\u6C42\u5931\u8D25: ${d.message}`),1}}async listMySkills(e){let{execSync:t}=require("child_process");if(!e)return console.error("\u274C \u7F3A\u5C11 API Key\uFF0C\u8BF7\u5148\u767B\u5F55: coder auth login"),1;let o=`${O}/api/v1/me/skills?size=50`,n=e;try{let s=t(`curl -s "${o}" -H "Authorization: Bearer ${n}"`,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}),r=JSON.parse(s);if(r.code!==0)return console.error(`\u274C \u83B7\u53D6\u5931\u8D25: ${r.msg}`),1;let i=r.data?.items||[],a=r.data?.total||0;if(i.length===0)return console.log("\u6682\u65E0\u5DF2\u53D1\u5E03\u7684 skill"),0;console.log(`\u5171 ${a} \u4E2A skill:
36
36
  `);for(let l of i){let d=`${l.namespace}/${l.slug}`.padEnd(36),u=`\u2B50 ${l.starCount??0}`.padEnd(8),m=`\u2193 ${l.downloadCount??0}`.padEnd(10);console.log(` ${d} ${u} ${m} [${l.status}]`),l.displayName&&l.displayName!==l.slug&&console.log(` ${"".padEnd(36)} ${l.displayName}`)}return 0}catch(s){return console.error(`\u274C \u8BF7\u6C42\u5931\u8D25: ${s.message}`),1}}async listNamespaces(e){let{execSync:t}=require("child_process");if(!e)return console.error("\u274C \u7F3A\u5C11 API Key\uFF0C\u8BF7\u5148\u767B\u5F55: coder auth login"),1;let o=`${O}/api/v1/me/namespaces`,n=e;try{let s=t(`curl -s "${o}" -H "Authorization: Bearer ${n}"`,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}),r=JSON.parse(s);if(r.code!==0)return console.error(`\u274C \u83B7\u53D6\u5931\u8D25: ${r.msg}`),1;let i=r.data||[];if(i.length===0)return console.log("\u6682\u65E0\u547D\u540D\u7A7A\u95F4"),0;console.log(`\u5171 ${i.length} \u4E2A\u547D\u540D\u7A7A\u95F4:
37
37
  `);for(let a of i){let l=a.type==="GLOBAL"?"\u5168\u5C40":"\u56E2\u961F";console.log(` @${a.slug.padEnd(20)} ${a.displayName.padEnd(20)} [${l}] ${a.status}`)}return 0}catch(s){return console.error(`\u274C \u8BF7\u6C42\u5931\u8D25: ${s.message}`),1}}showHelp(){console.log(["Usage: coder skills [subcommand] [options]","","Subcommands:"," add <name> \u5B89\u88C5 skill"," remove <name> \u5378\u8F7D skill"," update [name] \u66F4\u65B0 skill\uFF08\u4E0D\u6307\u5B9A\u540D\u79F0\u5219\u66F4\u65B0\u5168\u90E8\uFF09"," check-updates \u68C0\u67E5\u5DF2\u5B89\u88C5 skill \u662F\u5426\u6709\u65B0\u7248\u672C"," search <keyword> \u641C\u7D22 skill"," list \u67E5\u770B\u6211\u53D1\u5E03\u7684 skill"," publish [options] [<dir-or-zip>] \u53D1\u5E03 skill \u5230 skillhub"," unpublish <namespace>/<slug> \u4E0B\u67B6 skill"," namespaces \u67E5\u770B\u6211\u7684\u547D\u540D\u7A7A\u95F4","","Publish Options:"," --namespace <ns> \u76EE\u6807\u547D\u540D\u7A7A\u95F4\uFF08\u9ED8\u8BA4: global\uFF09"," --visibility <v> \u53EF\u89C1\u6027: PUBLIC | NAMESPACE_ONLY | PRIVATE"," \uFF08\u9ED8\u8BA4: PUBLIC\uFF0C\u975E global \u547D\u540D\u7A7A\u95F4\u65F6\u81EA\u52A8\u9501\u5B9A\u4E3A NAMESPACE_ONLY\uFF09"," --meta-data <json> \u9644\u52A0\u81EA\u5B9A\u4E49\u5143\u6570\u636E JSON","","Examples:"," coder skills add vue \u5B89\u88C5 vue skill"," coder skills search react \u641C\u7D22 react skills"," coder skills list \u67E5\u770B\u6211\u53D1\u5E03\u7684 skill"," coder skills publish ./my-skill-dir \u4ECE\u76EE\u5F55\u53D1\u5E03"," coder skills publish --namespace myteam ./my-skill-dir"," coder skills publish --visibility PRIVATE my-skill.zip",` coder skills publish --meta-data '{"category":"tool"}' ./my-skill-dir`," coder skills unpublish global/my-skill"," coder skills namespaces \u67E5\u770B\u6211\u7684\u547D\u540D\u7A7A\u95F4"].join(`
38
- `))}};Ge.exports=ie});var Ke=$((Po,He)=>{var Mt=require("https"),z="https://makecoder.com/wiki",Ft=`${z}/api`,v=c=>`${z}/doc/${c}`,ce=c=>`${z}/collection/${c}`;function Jt(c){return c.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}var Gt={"collection-info":{endpoint:"collections.info",requireId:"\u274C \u8BF7\u6307\u5B9A\u96C6\u5408 ID",buildBody:c=>({id:c}),print:c=>{let e=c.data;console.log(`ID: ${e.id}
38
+ `))}};Ge.exports=ie});var He=$((Po,Ke)=>{var Mt=require("https"),z="https://makecoder.com/wiki",Ft=`${z}/api`,v=c=>`${z}/doc/${c}`,ce=c=>`${z}/collection/${c}`;function Jt(c){return c.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}var Gt={"collection-info":{endpoint:"collections.info",requireId:"\u274C \u8BF7\u6307\u5B9A\u96C6\u5408 ID",buildBody:c=>({id:c}),print:c=>{let e=c.data;console.log(`ID: ${e.id}
39
39
  \u540D\u79F0: ${e.name}
40
40
  \u63CF\u8FF0: ${e.description||""}
41
41
  \u6743\u9650: ${e.permission||"null"}`)}},"collection-members":{endpoint:"collections.memberships",requireId:"\u274C \u8BF7\u6307\u5B9A\u96C6\u5408 ID",buildBody:(c,e)=>{let t={id:c},o=e.indexOf("--query");o!==-1&&(t.query=e[o+1]);let n=e.indexOf("--permission");return n!==-1&&(t.permission=e[n+1]),t},print:(c,e)=>{let t=c.data?.memberships||c.data||[];if(!t.length){console.log("\u6682\u65E0\u6210\u5458");return}e.printTable(t.map(o=>({userId:o.userId||"",\u59D3\u540D:o.user?.name||"",\u6743\u9650:o.permission||""})))}},"collection-add-user":{endpoint:"collections.add_user",requireId:"\u274C \u8BF7\u6307\u5B9A\u96C6\u5408 ID",requireArgs:(c,e)=>!e[1]&&"\u274C \u8BF7\u6307\u5B9A\u7528\u6237 ID\uFF08\u7B2C\u4E8C\u4E2A\u53C2\u6570\uFF09",buildBody:(c,e)=>{let t={id:c,userId:e[1]},o=e.indexOf("--permission");return o!==-1&&(t.permission=e[o+1]),t},print:()=>console.log("\u2705 \u5DF2\u6DFB\u52A0\u7528\u6237\u5230\u96C6\u5408")},"collection-remove-user":{endpoint:"collections.remove_user",requireId:"\u274C \u8BF7\u6307\u5B9A\u96C6\u5408 ID",requireArgs:(c,e)=>!e[1]&&"\u274C \u8BF7\u6307\u5B9A\u7528\u6237 ID\uFF08\u7B2C\u4E8C\u4E2A\u53C2\u6570\uFF09",buildBody:(c,e)=>({id:c,userId:e[1]}),expectOk:!0,print:()=>console.log("\u2705 \u5DF2\u4ECE\u96C6\u5408\u79FB\u9664\u7528\u6237")},"collection-add-group":{endpoint:"collections.add_group",requireId:"\u274C \u8BF7\u6307\u5B9A\u96C6\u5408 ID",requireArgs:(c,e)=>!e[1]&&"\u274C \u8BF7\u6307\u5B9A\u7FA4\u7EC4 ID\uFF08\u7B2C\u4E8C\u4E2A\u53C2\u6570\uFF09",buildBody:(c,e)=>{let t={id:c,groupId:e[1]},o=e.indexOf("--permission");return o!==-1&&(t.permission=e[o+1]),t},print:()=>console.log("\u2705 \u5DF2\u6DFB\u52A0\u7FA4\u7EC4\u5230\u96C6\u5408")},"collection-remove-group":{endpoint:"collections.remove_group",requireId:"\u274C \u8BF7\u6307\u5B9A\u96C6\u5408 ID",requireArgs:(c,e)=>!e[1]&&"\u274C \u8BF7\u6307\u5B9A\u7FA4\u7EC4 ID\uFF08\u7B2C\u4E8C\u4E2A\u53C2\u6570\uFF09",buildBody:(c,e)=>({id:c,groupId:e[1]}),expectOk:!0,print:()=>console.log("\u2705 \u5DF2\u4ECE\u96C6\u5408\u79FB\u9664\u7FA4\u7EC4")},"collection-group-members":{endpoint:"collections.group_memberships",requireId:"\u274C \u8BF7\u6307\u5B9A\u96C6\u5408 ID",buildBody:c=>({id:c}),print:(c,e)=>{let t=c.data?.groupMemberships||c.data||[];if(!t.length){console.log("\u6682\u65E0\u7FA4\u7EC4\u6210\u5458");return}e.printTable(t.map(o=>({groupId:o.groupId||"",\u7FA4\u7EC4\u540D:o.group?.name||"",\u6743\u9650:o.permission||""})))}},"collection-export":{endpoint:"collections.export",requireId:"\u274C \u8BF7\u6307\u5B9A\u96C6\u5408 ID",buildBody:(c,e)=>{let t={id:c},o=e.indexOf("--format");return o!==-1&&(t.format=e[o+1]),t},print:c=>console.log(`\u2705 \u5BFC\u51FA\u4EFB\u52A1\u5DF2\u521B\u5EFA: ${c.data?.id||""}`)},"export-all":{endpoint:"collections.export_all",buildBody:(c,e)=>{let t={},o=e.indexOf("--format");return o!==-1&&(t.format=e[o+1]),t},print:c=>console.log(`\u2705 \u5168\u91CF\u5BFC\u51FA\u4EFB\u52A1\u5DF2\u521B\u5EFA: ${c.data?.id||""}`)},"collection-move":{endpoint:"collections.move",requireId:"\u274C \u8BF7\u6307\u5B9A\u96C6\u5408 ID",requireArgs:(c,e)=>!e[1]&&"\u274C \u8BF7\u6307\u5B9A\u76EE\u6807 index\uFF08\u7B2C\u4E8C\u4E2A\u53C2\u6570\uFF09",buildBody:(c,e)=>({id:c,index:e[1]}),print:()=>console.log("\u2705 \u96C6\u5408\u5DF2\u79FB\u52A8")},archived:{endpoint:"documents.archived",buildBody:(c,e)=>{let t={},o=e.indexOf("--collection");o!==-1&&(t.collectionId=e[o+1]);let n=e.indexOf("--sort");n!==-1&&(t.sort=e[n+1]);let s=e.indexOf("--direction");return s!==-1&&(t.direction=e[s+1]),t},print:(c,e)=>{let t=c.data||[];if(!t.length){console.log("\u6682\u65E0\u5DF2\u5F52\u6863\u6587\u6863");return}e.printTable(t.map(o=>({ID:o.id,\u6807\u9898:o.title,URL:v(o.urlId||o.id)})))}},deleted:{endpoint:"documents.deleted",buildBody:(c,e)=>{let t={},o=e.indexOf("--sort");o!==-1&&(t.sort=e[o+1]);let n=e.indexOf("--direction");return n!==-1&&(t.direction=e[n+1]),t},print:(c,e)=>{let t=c.data||[];if(!t.length){console.log("\u6682\u65E0\u5DF2\u5220\u9664\u6587\u6863");return}e.printTable(t.map(o=>({ID:o.id,\u6807\u9898:o.title,\u5220\u9664\u65F6\u95F4:o.deletedAt||""})))}},insights:{endpoint:"documents.insights",requireId:"\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID",buildBody:(c,e)=>{let t={id:c},o=e.indexOf("--start-date");o!==-1&&(t.startDate=e[o+1]);let n=e.indexOf("--end-date");return n!==-1&&(t.endDate=e[n+1]),t},print:(c,e)=>{let t=c.data||[];if(!t.length){console.log("\u6682\u65E0\u8BBF\u95EE\u6570\u636E");return}e.printTable(t.map(o=>({userId:o.userId||"",\u59D3\u540D:o.user?.name||"",\u65F6\u95F4:o.createdAt||""})))}},export:{endpoint:"documents.export",requireId:"\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID",buildBody:(c,e)=>({id:c,includeChildDocuments:e.includes("--include-children")}),print:c=>{let e=c.data;console.log(typeof e=="string"?e:JSON.stringify(e,null,2))}},"search-titles":{endpoint:"documents.search_titles",requireId:"\u274C \u8BF7\u6307\u5B9A\u641C\u7D22\u5173\u952E\u8BCD",buildBody:(c,e)=>({query:[c,...e.slice(1)].join(" ")}),print:(c,e)=>{let t=c.data||[];if(!t.length){console.log("\u672A\u627E\u5230\u5339\u914D\u6807\u9898");return}e.printTable(t.map(o=>({ID:o.id,\u6807\u9898:o.title,URL:v(o.urlId||o.id)})))}},duplicate:{endpoint:"documents.duplicate",requireId:"\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID",buildBody:(c,e)=>{let t={id:c},o=e.indexOf("--title");o!==-1&&(t.title=e[o+1]);let n=e.indexOf("--collection");n!==-1&&(t.collectionId=e[n+1]);let s=e.indexOf("--parent");return s!==-1&&(t.parentDocumentId=e[s+1]),e.includes("--recursive")&&(t.recursive=!0),e.includes("--publish")&&(t.publish=!0),t},print:c=>{let t=(c.data?.documents||[])[0];console.log(t?`\u2705 \u6587\u6863\u5DF2\u590D\u5236: ${t.id} \u2014 ${t.title}`:"\u2705 \u6587\u6863\u5DF2\u590D\u5236")}},unpublish:{endpoint:"documents.unpublish",requireId:"\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID",buildBody:c=>({id:c}),print:()=>console.log("\u2705 \u6587\u6863\u5DF2\u53D6\u6D88\u53D1\u5E03")},templatize:{endpoint:"documents.templatize",requireId:"\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID",buildBody:(c,e)=>{let t={id:c,publish:!0},o=e.indexOf("--collection");return o!==-1&&(t.collectionId=e[o+1]),t},print:c=>console.log(`\u2705 \u5DF2\u8F6C\u4E3A\u6A21\u677F: ${c.data.id}`)},"doc-members":{endpoint:"documents.memberships",requireId:"\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID",buildBody:c=>({id:c}),print:(c,e)=>{let t=c.data?.memberships||c.data||[];if(!t.length){console.log("\u6682\u65E0\u6210\u5458");return}e.printTable(t.map(o=>({userId:o.userId||"",\u59D3\u540D:o.user?.name||"",\u6743\u9650:o.permission||""})))}},"doc-add-user":{endpoint:"documents.add_user",requireId:"\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID",requireArgs:(c,e)=>!e[1]&&"\u274C \u8BF7\u6307\u5B9A\u7528\u6237 ID\uFF08\u7B2C\u4E8C\u4E2A\u53C2\u6570\uFF09",buildBody:(c,e)=>{let t={id:c,userId:e[1]},o=e.indexOf("--permission");return o!==-1&&(t.permission=e[o+1]),t},print:()=>console.log("\u2705 \u5DF2\u6DFB\u52A0\u7528\u6237\u5230\u6587\u6863")},"doc-remove-user":{endpoint:"documents.remove_user",requireId:"\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID",requireArgs:(c,e)=>!e[1]&&"\u274C \u8BF7\u6307\u5B9A\u7528\u6237 ID\uFF08\u7B2C\u4E8C\u4E2A\u53C2\u6570\uFF09",buildBody:(c,e)=>({id:c,userId:e[1]}),expectOk:!0,print:()=>console.log("\u2705 \u5DF2\u4ECE\u6587\u6863\u79FB\u9664\u7528\u6237")},"doc-add-group":{endpoint:"documents.add_group",requireId:"\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID",requireArgs:(c,e)=>!e[1]&&"\u274C \u8BF7\u6307\u5B9A\u7FA4\u7EC4 ID\uFF08\u7B2C\u4E8C\u4E2A\u53C2\u6570\uFF09",buildBody:(c,e)=>{let t={id:c,groupId:e[1]},o=e.indexOf("--permission");return o!==-1&&(t.permission=e[o+1]),t},print:()=>console.log("\u2705 \u5DF2\u6DFB\u52A0\u7FA4\u7EC4\u5230\u6587\u6863")},"doc-remove-group":{endpoint:"documents.remove_group",requireId:"\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID",requireArgs:(c,e)=>!e[1]&&"\u274C \u8BF7\u6307\u5B9A\u7FA4\u7EC4 ID\uFF08\u7B2C\u4E8C\u4E2A\u53C2\u6570\uFF09",buildBody:(c,e)=>({id:c,groupId:e[1]}),expectOk:!0,print:()=>console.log("\u2705 \u5DF2\u4ECE\u6587\u6863\u79FB\u9664\u7FA4\u7EC4")},"doc-group-members":{endpoint:"documents.group_memberships",requireId:"\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID",buildBody:c=>({id:c}),print:(c,e)=>{let t=c.data?.groupMemberships||c.data||[];if(!t.length){console.log("\u6682\u65E0\u7FA4\u7EC4\u6210\u5458");return}e.printTable(t.map(o=>({groupId:o.groupId||"",\u7FA4\u7EC4\u540D:o.group?.name||"",\u6743\u9650:o.permission||""})))}},"empty-trash":{endpoint:"documents.empty_trash",buildBody:()=>({}),expectOk:!0,print:()=>console.log("\u2705 \u56DE\u6536\u7AD9\u5DF2\u6E05\u7A7A")},"sub-docs":{endpoint:"documents.documents",requireId:"\u274C \u8BF7\u6307\u5B9A\u6587\u6863 ID",buildBody:c=>({id:c}),print:(c,e)=>{let t=c.data?.children||[];if(!t.length){console.log("\u6682\u65E0\u5B50\u6587\u6863");return}e.printTree(t,"",1/0,0)}},shares:{endpoint:"shares.list",buildBody:(c,e)=>{let t={},o=e.indexOf("--document");return o!==-1&&(t.documentId=e[o+1]),t},print:(c,e)=>{let t=c.data||[];if(!t.length){console.log("\u6682\u65E0\u5206\u4EAB");return}e.printTable(t.map(o=>({shareId:o.id,\u6587\u6863:o.documentTitle||o.documentId||"",\u5DF2\u53D1\u5E03:o.published?"\u662F":"\u5426",URL:o.url||""})))}},"share-info":{endpoint:"shares.info",requireId:"\u274C \u8BF7\u6307\u5B9A\u5206\u4EAB ID",buildBody:c=>({id:c}),print:c=>{let e=c.data;console.log(`ID: ${e.id}
@@ -82,7 +82,7 @@ Content-Type: ${s}\r
82
82
  `),u=Buffer.from(`\r
83
83
  --${a}--\r
84
84
  `),m=Buffer.concat([...l,d,o,u]),p=new URL(e),f=p.protocol==="https:"?require("https"):require("http"),g={hostname:p.hostname,port:p.port||(p.protocol==="https:"?443:80),path:p.pathname+p.search,method:"POST",headers:{"Content-Type":`multipart/form-data; boundary=${a}`,"Content-Length":m.length}},y=f.request(g,h=>{let I="";h.on("data",b=>I+=b),h.on("end",()=>r({status:h.statusCode,body:I}))});y.on("error",i),y.write(m),y.end()})}extractCommentText(e){return e?.content?e.content.flatMap(t=>t.content||[]).filter(t=>t.type==="text").map(t=>t.text).join(""):""}showHelp(){console.log(["Usage: coder wiki [subcommand] [options]","","Global Options:"," --team <teamId> \u6307\u5B9A\u56E2\u961F\u4E0A\u4E0B\u6587\uFF08X-Team-Id\uFF09\uFF0C\u9ED8\u8BA4\u4F7F\u7528 coder team use \u8BBE\u7F6E\u7684\u56E2\u961F","","Collection Management:"," list \u5217\u51FA\u6240\u6709\u96C6\u5408"," list <collectionId> \u5217\u51FA\u96C6\u5408\u4E0B\u7684\u6839\u6587\u6863\uFF08\u8868\u683C\uFF09"," list <collectionId> -d <depth> \u5C55\u5F00\u6587\u6863\u6811\uFF08-d -1 \u5168\u90E8\u5C55\u5F00\uFF09"," create-collection <name> [desc] [--permission <perm>] [--icon <icon>] [--color <color>]"," \u521B\u5EFA\u96C6\u5408 (perm: read_write|read|null; icon: emoji \u6216\u56FE\u6807\u540D; color: \u5341\u516D\u8FDB\u5236\u989C\u8272\u5982 #4A90E2)"," icons [keyword] \u5217\u51FA\u6240\u6709\u652F\u6301\u7684\u56FE\u6807\u540D\uFF08\u53EF\u6309\u5173\u952E\u8BCD\u8FC7\u6EE4\uFF09"," update-collection <id> [--name <n>] [--description <d>] [--permission <p>] [--color <c>] [--sharing <bool>]"," \u66F4\u65B0\u96C6\u5408"," archive-collection <id> \u5F52\u6863\u96C6\u5408"," restore-collection <id> \u6062\u590D\u5DF2\u5F52\u6863\u96C6\u5408"," delete-collection <id> \u5220\u9664\u96C6\u5408"," collection-info <id> \u67E5\u770B\u96C6\u5408\u8BE6\u60C5"," collection-members <id> [--query <q>] [--permission <p>] \u96C6\u5408\u6210\u5458\u5217\u8868"," collection-add-user <id> <userId> [--permission <p>] \u6DFB\u52A0\u7528\u6237\u5230\u96C6\u5408"," collection-remove-user <id> <userId> \u4ECE\u96C6\u5408\u79FB\u9664\u7528\u6237"," collection-add-group <id> <groupId> [--permission <p>] \u6DFB\u52A0\u7FA4\u7EC4\u5230\u96C6\u5408"," collection-remove-group <id> <groupId> \u4ECE\u96C6\u5408\u79FB\u9664\u7FA4\u7EC4"," collection-group-members <id> \u96C6\u5408\u7FA4\u7EC4\u6210\u5458\u5217\u8868"," collection-export <id> [--format outline|markdown_zip] \u5BFC\u51FA\u96C6\u5408"," export-all [--format outline|markdown_zip] \u5BFC\u51FA\u6240\u6709\u96C6\u5408"," collection-move <id> <index> \u79FB\u52A8\u96C6\u5408\u4F4D\u7F6E","","Document Management:"," get <docId> \u67E5\u770B\u6587\u6863"," publish <collectionId> <title> [text] \u521B\u5EFA\u5E76\u53D1\u5E03\u6587\u6863"," publish <collectionId> --file <path> [--parent <parentDocId>]"," \u4ECE Markdown \u6587\u4EF6\u53D1\u5E03\uFF08\u9700\u542B H1 \u6807\u9898\uFF09"," update <docId> <title> [text] \u66F4\u65B0\u6587\u6863"," update <docId> --file <path> \u4ECE Markdown \u6587\u4EF6\u66F4\u65B0\u6587\u6863"," delete <docId> [--permanent] \u5220\u9664\u6587\u6863"," move <docId> [collectionId] [parentId] \u79FB\u52A8\u6587\u6863"," archive <docId> \u5F52\u6863\u6587\u6863"," restore <docId> [--revision <revisionId>] [--collection <collectionId>]"," \u6062\u590D\u6587\u6863"," archived [--collection <id>] \u5DF2\u5F52\u6863\u6587\u6863\u5217\u8868"," deleted \u5DF2\u5220\u9664\u6587\u6863\u5217\u8868"," insights <id> [--start-date <d>] [--end-date <d>] \u6587\u6863\u8BBF\u95EE\u7EDF\u8BA1"," export <id> [--include-children] \u5BFC\u51FA\u6587\u6863"," search-titles <query> \u6309\u6807\u9898\u641C\u7D22"," duplicate <id> [--title <t>] [--recursive] [--publish] [--collection <id>] [--parent <id>]"," \u590D\u5236\u6587\u6863"," unpublish <id> \u53D6\u6D88\u53D1\u5E03"," templatize <id> [--collection <collectionId>] \u8F6C\u4E3A\u6A21\u677F\uFF08\u9700\u6307\u5B9A\u96C6\u5408\u6216\u7BA1\u7406\u5458\u6743\u9650\uFF09"," doc-members <id> \u6587\u6863\u6210\u5458\u5217\u8868"," doc-add-user <id> <userId> [--permission <p>] \u6DFB\u52A0\u7528\u6237\u5230\u6587\u6863"," doc-remove-user <id> <userId> \u4ECE\u6587\u6863\u79FB\u9664\u7528\u6237"," doc-add-group <id> <groupId> [--permission <p>] \u6DFB\u52A0\u7FA4\u7EC4\u5230\u6587\u6863"," doc-remove-group <id> <groupId> \u4ECE\u6587\u6863\u79FB\u9664\u7FA4\u7EC4"," doc-group-members <id> \u6587\u6863\u7FA4\u7EC4\u6210\u5458\u5217\u8868"," empty-trash \u6E05\u7A7A\u56DE\u6536\u7AD9"," sub-docs <id> \u5B50\u6587\u6863\u5217\u8868","","Revision History:"," revisions <docId> \u5217\u51FA\u6587\u6863\u5386\u53F2\u7248\u672C"," revision <revisionId> \u67E5\u770B\u6307\u5B9A\u5386\u53F2\u7248\u672C\u5185\u5BB9","","Discovery:"," drafts \u8349\u7A3F\u5217\u8868"," recent \u6700\u8FD1\u6D4F\u89C8"," search <keyword> \u5168\u6587\u641C\u7D22","","Favorites & Pins:"," stars \u6536\u85CF\u5217\u8868"," star <id> [--collection] \u6536\u85CF\u6587\u6863\u6216\u96C6\u5408"," unstar <starId> \u53D6\u6D88\u6536\u85CF"," pins [collectionId] \u7F6E\u9876\u5217\u8868"," pin <docId> [collectionId] \u7F6E\u9876\u6587\u6863"," unpin <pinId> \u53D6\u6D88\u7F6E\u9876","","Comments:"," comments <docId> \u67E5\u770B\u8BC4\u8BBA"," comment <docId> <text> \u53D1\u8868\u8BC4\u8BBA","","Shares:"," shares [--document <id>] \u5206\u4EAB\u5217\u8868"," share-info <id> \u67E5\u770B\u5206\u4EAB\u8BE6\u60C5"," share <documentId> [--published] [--include-children] \u521B\u5EFA\u5206\u4EAB"," share-update <id> [--published] [--no-published] [--include-children] \u66F4\u65B0\u5206\u4EAB"," unshare <id> \u64A4\u9500\u5206\u4EAB","","Users:"," users [--query <q>] [--filter invited|viewers|admins|members|active|all|suspended]"," \u7528\u6237\u5217\u8868"," user-info <id> \u67E5\u770B\u7528\u6237\u8BE6\u60C5"," invite <email> <name> <role> \u9080\u8BF7\u7528\u6237"," user-update-role <id> <role> \u66F4\u65B0\u7528\u6237\u89D2\u8272 (admin|member|viewer)"," user-suspend <id> \u6682\u505C\u7528\u6237"," user-activate <id> \u6FC0\u6D3B\u7528\u6237","","Groups:"," groups [--query <q>] \u7FA4\u7EC4\u5217\u8868"," group-info <id> \u67E5\u770B\u7FA4\u7EC4\u8BE6\u60C5"," create-group <name> \u521B\u5EFA\u7FA4\u7EC4"," update-group <id> --name <name> \u66F4\u65B0\u7FA4\u7EC4"," delete-group <id> \u5220\u9664\u7FA4\u7EC4"," group-members <id> \u7FA4\u7EC4\u6210\u5458\u5217\u8868"," group-add-user <id> <userId> \u6DFB\u52A0\u7528\u6237\u5230\u7FA4\u7EC4"," group-remove-user <id> <userId> \u4ECE\u7FA4\u7EC4\u79FB\u9664\u7528\u6237","","Views / Subscriptions / Events:"," views <documentId> \u6587\u6863\u6D4F\u89C8\u8BB0\u5F55"," view <documentId> \u8BB0\u5F55\u6587\u6863\u6D4F\u89C8"," subscriptions <documentId> \u8BA2\u9605\u5217\u8868\uFF08\u6216 --collection <id>\uFF09"," subscribe <documentId> \u8BA2\u9605\u6587\u6863\u66F4\u65B0"," unsubscribe <subscriptionId> \u53D6\u6D88\u8BA2\u9605"," events [--actor <id>] [--document <id>] [--collection <id>] [--type <t>]"," \u4E8B\u4EF6\u5217\u8868","","Templates:"," templates [--collection <id>] \u6A21\u677F\u5217\u8868"," template-info <id> \u67E5\u770B\u6A21\u677F\u8BE6\u60C5"," create-template <collectionId> <title> [--text <t>] \u521B\u5EFA\u6A21\u677F"," update-template <id> [--title <t>] [--text <t>] \u66F4\u65B0\u6A21\u677F"," delete-template <id> \u5220\u9664\u6A21\u677F"," duplicate-template <id> [--title <t>] \u590D\u5236\u6A21\u677F","","File Operations:"," file-ops [--type import|export] \u6587\u4EF6\u64CD\u4F5C\u5217\u8868"," file-op-info <id> \u67E5\u770B\u6587\u4EF6\u64CD\u4F5C\u8BE6\u60C5"," file-op-delete <id> \u5220\u9664\u6587\u4EF6\u64CD\u4F5C\u8BB0\u5F55","","Reactions:"," reactions <commentId> \u67E5\u770B\u8BC4\u8BBA\u53CD\u5E94\u5217\u8868","","Attachments:"," attachments [docId] \u9644\u4EF6\u5217\u8868\uFF08\u53EF\u6309\u6587\u6863\u8FC7\u6EE4\uFF09"," upload <docId> <filePath> \u4E0A\u4F20\u672C\u5730\u6587\u4EF6\uFF08\u56FE\u7247/PDF/PPT \u7B49\uFF09\u5230\u6587\u6863"," upload-url <docId> <url> \u4ECE\u8FDC\u7A0B URL \u521B\u5EFA\u9644\u4EF6"," delete-attachment <id> \u5220\u9664\u9644\u4EF6","","Examples:"," coder wiki list \u5217\u51FA\u9ED8\u8BA4\u56E2\u961F\u7684\u6240\u6709\u96C6\u5408"," coder wiki list --team <teamId> \u5217\u51FA\u6307\u5B9A\u56E2\u961F\u7684\u96C6\u5408"," coder wiki list <collectionId> -d -1 \u5C55\u5F00\u5B8C\u6574\u6811",' coder wiki publish <collectionId> "\u6807\u9898" "\u5185\u5BB9"'," coder wiki publish <collectionId> --file ./doc.md",' coder wiki search "\u5173\u952E\u8BCD"',' coder wiki comment <docId> "\u5F88\u6709\u5E2E\u52A9\uFF01"'," coder wiki upload <docId> ./screenshot.png \u4E0A\u4F20\u56FE\u7247\u5E76\u83B7\u53D6 Markdown \u94FE\u63A5"," coder wiki upload <docId> ./report.pptx \u4E0A\u4F20 PPT \u6587\u4EF6"].join(`
85
- `))}};He.exports=ae});var Ze=$((Ao,Xe)=>{var q=require("fs"),j=require("path"),Ye=require("os"),Vt=require("readline"),W=j.join(Ye.homedir(),".coder","config.json"),ze=process.env.MCP_CHANNEL_DIR||j.join(Ye.homedir(),".coder","mcp-channel"),We=["wecom"];function Y(c){return!c||c.length<=8?"****":c.slice(0,3)+"****"+c.slice(-3)}var le=class{load(){try{return JSON.parse(q.readFileSync(W,"utf8"))}catch{return{}}}save(e){let t=j.dirname(W);q.existsSync(t)||q.mkdirSync(t,{recursive:!0}),q.writeFileSync(W,JSON.stringify(e,null,2)+`
85
+ `))}};Ke.exports=ae});var Ze=$((Ao,Xe)=>{var q=require("fs"),j=require("path"),Ye=require("os"),Vt=require("readline"),W=j.join(Ye.homedir(),".coder","config.json"),ze=process.env.MCP_CHANNEL_DIR||j.join(Ye.homedir(),".coder","mcp-channel"),We=["wecom"];function Y(c){return!c||c.length<=8?"****":c.slice(0,3)+"****"+c.slice(-3)}var le=class{load(){try{return JSON.parse(q.readFileSync(W,"utf8"))}catch{return{}}}save(e){let t=j.dirname(W);q.existsSync(t)||q.mkdirSync(t,{recursive:!0}),q.writeFileSync(W,JSON.stringify(e,null,2)+`
86
86
  `)}getChannels(){return this.load().channels??[]}saveChannels(e){let t=this.load();t.channels=e,this.save(t)}async handle({channelSubcommand:e,channelArg:t,channelRemainingArgs:o,remainingArgs:n,claudeLauncher:s,parsedArgs:r}){return e?e==="--help"||e==="-h"?(this.showHelp(),0):e==="list"?this.list(t):e==="show"?this.show(t):e==="add"?this.add(t,o||[]):e==="remove"?this.remove(t):e==="update"?this.update(t,o||[]):(console.error(`\u274C \u672A\u77E5\u5B50\u547D\u4EE4: ${e}`),this.showHelp(),1):this.launch(o||[],s,r)}async launch(e,t,o){let n=this.getChannels().filter(p=>p.enabled!==!1);if(!n.length&&(console.log(`\u5C1A\u672A\u7ED1\u5B9A\u4EFB\u4F55\u6E20\u9053\uFF0C\u5F00\u59CB\u5F15\u5BFC\u914D\u7F6E...
87
87
  `),!await this.promptSetupChannel()||(n=this.getChannels().filter(f=>f.enabled!==!1),!n.length)))return 1;let s=null,r=e.indexOf("--channel-id");r!==-1&&(s=e[r+1],e=e.filter((p,f)=>f!==r&&f!==r+1));let i;if(s){if(i=n.find(p=>p.id===s),!i)return console.error(`\u274C \u6E20\u9053\u4E0D\u5B58\u5728: ${s}`),1}else if(n.length===1)i=n[0];else if(i=await this.promptSelectChannel(n),!i)return 1;let a=j.join(ze,i.type);if(!q.existsSync(a))return console.error(`\u274C MCP \u76EE\u5F55\u4E0D\u5B58\u5728: ${a}`),1;let l=["--plugin-dir",a,"--dangerously-load-development-channels",`plugin:${i.type}@${i.type}`],d={WECOM_CHANNEL_FILE:W,WECOM_CHANNEL_KEY:i.id};i.botId&&(d.WECOM_BOT_ID=i.botId),i.secret&&(d.WECOM_BOT_SECRET=i.secret),o.remainingArgs=[...l,...e,...o.remainingArgs||[]],o.extraEnv={...o.extraEnv||{},...d};let u=i.name||i.id,m=i.botId?Y(i.botId):"(\u672A\u914D\u7F6E)";return console.log(`
88
88
  \u6E20\u9053\u5DF2\u5C31\u7EEA: [${i.type}] ${u} Bot ID: ${m}`),console.log(`\u6B63\u5728\u542F\u52A8 Claude\uFF0C\u7B49\u5F85\u4F01\u4E1A\u5FAE\u4FE1\u6D88\u606F...
@@ -112,7 +112,7 @@ client.connect();
112
112
  `)}),process.stdout.write(`
113
113
  `)},s=()=>{let i=e.length+4;process.stdout.write(`\x1B[${i}A\x1B[0J`)};n(),process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding("utf8");let r=i=>{i==="\x1B[A"||i==="\x1B[D"?(o=(o-1+e.length)%e.length,s(),n()):i==="\x1B[B"||i==="\x1B[C"?(o=(o+1)%e.length,s(),n()):i==="\r"||i===`
114
114
  `?(process.stdin.setRawMode(!1),process.stdin.pause(),process.stdin.removeListener("data",r),process.stdout.write("\x1B[?25h"),t(e[o])):i===""&&(process.stdin.setRawMode(!1),process.stdin.pause(),process.stdin.removeListener("data",r),process.stdout.write("\x1B[?25h"),t(null))};process.stdin.on("data",r)})}list(e){let t=this.getChannels();return e&&(t=t.filter(o=>o.type===e)),t.length?(this.printTable(t.map(o=>({id:o.id,type:o.type,name:o.name||"",enabled:o.enabled!==!1?"\u2713":"\u2717",botId:o.botId?Y(o.botId):"",allowFrom:(o.allowFrom??[]).join(", "),updatedAt:o.updatedAt||o.createdAt||""}))),0):(console.log(e?`\u6682\u65E0 ${e} \u6E20\u9053`:"\u6682\u65E0\u6E20\u9053\u7ED1\u5B9A"),0)}show(e){if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A\u6E20\u9053 ID"),1;let t=this.getChannels().find(o=>o.id===e);return t?(console.log(JSON.stringify(t,null,2)),0):(console.error(`\u274C \u6E20\u9053\u4E0D\u5B58\u5728: ${e}`),1)}add(e,t){if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A\u6E20\u9053\u7C7B\u578B\uFF0C\u4F8B\u5982: coder channel add wecom --bot-id xxx --secret yyy"),1;if(!We.includes(e))return console.error(`\u274C \u4E0D\u652F\u6301\u7684\u6E20\u9053\u7C7B\u578B: ${e}\uFF0C\u652F\u6301: ${We.join(", ")}`),1;let o=t.indexOf("--id"),n=(o!==-1?t[o+1]:void 0)||`${e}-${Date.now()}`,s=this.getChannels();if(s.find(i=>i.id===n))return console.error(`\u274C \u6E20\u9053 ID \u5DF2\u5B58\u5728: ${n}`),1;let r={id:n,type:e,enabled:!0,createdAt:new Date().toISOString()};return this._applyArgs(r,t),s.push(r),this.saveChannels(s),console.log(`\u2705 \u6E20\u9053\u5DF2\u6DFB\u52A0: ${n} (${e})`),0}remove(e){if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A\u6E20\u9053 ID"),1;let t=this.getChannels(),o=t.findIndex(n=>n.id===e);return o===-1?(console.error(`\u274C \u6E20\u9053\u4E0D\u5B58\u5728: ${e}`),1):(t.splice(o,1),this.saveChannels(t),console.log(`\u2705 \u6E20\u9053\u5DF2\u5220\u9664: ${e}`),0)}update(e,t){if(!e)return console.error("\u274C \u8BF7\u6307\u5B9A\u6E20\u9053 ID"),1;let o=this.getChannels(),n=o.find(s=>s.id===e);return n?(t.includes("--enable")&&(n.enabled=!0),t.includes("--disable")&&(n.enabled=!1),this._applyArgs(n,t),n.updatedAt=new Date().toISOString(),this.saveChannels(o),console.log(`\u2705 \u6E20\u9053\u5DF2\u66F4\u65B0: ${e}`),0):(console.error(`\u274C \u6E20\u9053\u4E0D\u5B58\u5728: ${e}`),1)}_applyArgs(e,t){let o=r=>{let i=t.indexOf(r);return i!==-1?t[i+1]:void 0},n=r=>{if(r&&r.startsWith("@")){let i=r.slice(1);try{return q.readFileSync(i,"utf8").trim()}catch{console.error(`\u274C \u65E0\u6CD5\u8BFB\u53D6\u6587\u4EF6: ${i}`);return}}return r},s=o("--name");if(s!==void 0&&(e.name=s),e.type==="wecom"){let r=n(o("--bot-id"));r!==void 0&&(e.botId=r);let i=n(o("--secret"));i!==void 0&&(e.secret=i);let a=o("--allow");a!==void 0&&(e.allowFrom=e.allowFrom??[],e.allowFrom.includes(a)||e.allowFrom.push(a));let l=o("--deny");l!==void 0&&(e.allowFrom=(e.allowFrom??[]).filter(d=>d!==l))}}printTable(e){if(!e.length)return;let t=Object.keys(e[0]),o=i=>[...String(i)].reduce((a,l)=>a+(l.charCodeAt(0)>127?2:1),0),n=(i,a)=>i+" ".repeat(Math.max(0,a-o(i))),s=t.map(i=>Math.max(o(i),...e.map(a=>o(String(a[i]||""))))),r=s.map(i=>"-".repeat(i)).join("-+-");console.log(t.map((i,a)=>n(i,s[a])).join(" | ")),console.log(r);for(let i of e)console.log(t.map((a,l)=>n(String(i[a]||""),s[l])).join(" | "))}showHelp(){console.log(["Usage: coder channel [subcommand] [options]","","Subcommands:"," (no subcommand) \u542F\u52A8 Claude\uFF08\u81EA\u52A8\u9009\u62E9\u6216\u4EA4\u4E92\u9009\u62E9\u6E20\u9053\uFF09"," --channel-id <id> \u542F\u52A8\u6307\u5B9A\u6E20\u9053"," list [type] \u5217\u51FA\u6E20\u9053"," show <id> \u67E5\u770B\u6E20\u9053\u8BE6\u60C5"," add <type> [options] \u6DFB\u52A0\u6E20\u9053"," update <id> [options] \u66F4\u65B0\u6E20\u9053"," remove <id> \u5220\u9664\u6E20\u9053","","Supported Channel Types:"," wecom \u4F01\u4E1A\u5FAE\u4FE1 AI Bot","","WeChat Work Options:"," --bot-id <botId> \u4F01\u4E1A\u5FAE\u4FE1 AI Bot ID"," --secret <secret> \u4F01\u4E1A\u5FAE\u4FE1 AI Bot Secret\uFF08\u660E\u6587\uFF0C\u4F1A\u8BB0\u5F55\u5230 shell \u5386\u53F2\uFF09"," --secret @<file> \u4ECE\u6587\u4EF6\u8BFB\u53D6 Secret\uFF0C\u907F\u514D\u6CC4\u9732\u5230 shell \u5386\u53F2"," --allow <userId> \u5C06\u7528\u6237\u52A0\u5165\u767D\u540D\u5355"," --deny <userId> \u5C06\u7528\u6237\u79FB\u51FA\u767D\u540D\u5355"," --enable / --disable \u542F\u7528\u6216\u7981\u7528\u6E20\u9053"," --id <id> \u81EA\u5B9A\u4E49\u6E20\u9053 ID\uFF08add \u65F6\u4F7F\u7528\uFF09"," --name <name> \u6E20\u9053\u663E\u793A\u540D\u79F0","","Examples:",' coder channel add wecom --bot-id xxx --secret yyy --name "\u4E3B\u6E20\u9053"'," coder channel add wecom --bot-id xxx --secret @~/.coder/secret.txt",' coder channel add wecom --bot-id zzz --secret www --name "\u5907\u7528\u6E20\u9053"'," coder channel update wecom-xxx --allow zhangsan"," coder channel list \u5217\u51FA\u6240\u6709\u6E20\u9053"," coder channel \u591A\u6E20\u9053\u65F6\u4EA4\u4E92\u9009\u62E9"," coder channel --channel-id wecom-xxx \u76F4\u63A5\u542F\u52A8\u6307\u5B9A\u6E20\u9053","","\u914D\u7F6E\u6587\u4EF6: ~/.coder/config.json"].join(`
115
- `))}};Xe.exports=le});var et=$((To,Qe)=>{var Ht=require("http"),de=class{constructor(e={}){this.port=e.port||9380,this.timeout=e.timeout||300*1e3,this.server=null,this.timeoutId=null}validateTokenFormat(e){if(!e||typeof e!="string")return!1;let t=e.split(".");if(t.length!==2)return!1;let[o,n]=t;return o&&o.length>0&&n&&n.length>0}async waitForCallback(e){return new Promise((t,o)=>{let n=!1;this.server=Ht.createServer((s,r)=>{let i=new URL(s.url,`http://localhost:${this.port}`);if(i.pathname==="/callback"){let a=i.searchParams.get("token"),l=i.searchParams.get("state"),d=i.searchParams.get("error");if(d){r.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),r.end(`
115
+ `))}};Xe.exports=le});var et=$((To,Qe)=>{var Kt=require("http"),de=class{constructor(e={}){this.port=e.port||9380,this.timeout=e.timeout||300*1e3,this.server=null,this.timeoutId=null}validateTokenFormat(e){if(!e||typeof e!="string")return!1;let t=e.split(".");if(t.length!==2)return!1;let[o,n]=t;return o&&o.length>0&&n&&n.length>0}async waitForCallback(e){return new Promise((t,o)=>{let n=!1;this.server=Kt.createServer((s,r)=>{let i=new URL(s.url,`http://localhost:${this.port}`);if(i.pathname==="/callback"){let a=i.searchParams.get("token"),l=i.searchParams.get("state"),d=i.searchParams.get("error");if(d){r.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),r.end(`
116
116
  <!DOCTYPE html>
117
117
  <html>
118
118
  <head>
@@ -237,7 +237,7 @@ client.connect();
237
237
  </script>
238
238
  </body>
239
239
  </html>
240
- `),n||(n=!0,this.cleanup(),t({ak:u,sk:m}))}else r.writeHead(404,{"Content-Type":"text/plain"}),r.end("Not Found")}),this.server.on("error",s=>{if(s.code==="EADDRINUSE"){if(this.port++,this.port>9390){n||(n=!0,o(new Error("Could not find available port for OAuth callback server")));return}this.server.close(),this.server.listen(this.port)}else n||(n=!0,this.cleanup(),o(s))}),this.server.listen(this.port,()=>{process.env.CODEV_DEBUG&&console.log(`OAuth callback server listening on port ${this.port}`)}),this.timeoutId=setTimeout(()=>{n||(n=!0,this.cleanup(),o(new Error("OAuth login timeout - no response received within 5 minutes")))},this.timeout)})}getCallbackUrl(){return`http://localhost:${this.port}/callback`}cleanup(){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),this.server&&(this.server.close(),this.server=null)}};Qe.exports=de});var ot=$((qo,tt)=>{var Kt=require("crypto"),zt=et(),ue=class{constructor(e={}){this.baseUrl=e.baseUrl||"https://makecoder.com",this.callbackServer=null}generateState(){return Kt.randomBytes(16).toString("hex")}buildAuthorizationUrl(e,t){let o=new URLSearchParams({redirect_uri:e,state:t,response_type:"token"});return`${this.baseUrl}/oauth/authorize?${o.toString()}`}async startOAuthFlow(){let e=this.generateState();this.callbackServer=new zt;let t=this.callbackServer.getCallbackUrl(),o=this.buildAuthorizationUrl(t,e),n=!1;try{let r=(await import("open")).default;await r(o),n=!0}catch(r){process.env.CODEV_DEBUG&&console.error("Browser open error:",r)}let s=this.callbackServer.waitForCallback(e);return{authUrl:o,waitPromise:s,browserOpened:n}}async login(){try{let{authUrl:e,waitPromise:t,browserOpened:o}=await this.startOAuthFlow();console.log(`
240
+ `),n||(n=!0,this.cleanup(),t({ak:u,sk:m}))}else r.writeHead(404,{"Content-Type":"text/plain"}),r.end("Not Found")}),this.server.on("error",s=>{if(s.code==="EADDRINUSE"){if(this.port++,this.port>9390){n||(n=!0,o(new Error("Could not find available port for OAuth callback server")));return}this.server.close(),this.server.listen(this.port)}else n||(n=!0,this.cleanup(),o(s))}),this.server.listen(this.port,()=>{process.env.CODEV_DEBUG&&console.log(`OAuth callback server listening on port ${this.port}`)}),this.timeoutId=setTimeout(()=>{n||(n=!0,this.cleanup(),o(new Error("OAuth login timeout - no response received within 5 minutes")))},this.timeout)})}getCallbackUrl(){return`http://localhost:${this.port}/callback`}cleanup(){this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null),this.server&&(this.server.close(),this.server=null)}};Qe.exports=de});var ot=$((qo,tt)=>{var Ht=require("crypto"),zt=et(),ue=class{constructor(e={}){this.baseUrl=e.baseUrl||"https://makecoder.com",this.callbackServer=null}generateState(){return Ht.randomBytes(16).toString("hex")}buildAuthorizationUrl(e,t){let o=new URLSearchParams({redirect_uri:e,state:t,response_type:"token"});return`${this.baseUrl}/oauth/authorize?${o.toString()}`}async startOAuthFlow(){let e=this.generateState();this.callbackServer=new zt;let t=this.callbackServer.getCallbackUrl(),o=this.buildAuthorizationUrl(t,e),n=!1;try{let r=(await import("open")).default;await r(o),n=!0}catch(r){process.env.CODEV_DEBUG&&console.error("Browser open error:",r)}let s=this.callbackServer.waitForCallback(e);return{authUrl:o,waitPromise:s,browserOpened:n}}async login(){try{let{authUrl:e,waitPromise:t,browserOpened:o}=await this.startOAuthFlow();console.log(`
241
241
  \u{1F510} \u5F00\u59CB OAuth \u767B\u5F55\u6D41\u7A0B...
242
242
  `),console.log(`\u{1F4CB} \u8BF7\u5728\u6D4F\u89C8\u5668\u4E2D\u5B8C\u6210\u767B\u5F55
243
243
  `),console.log(`\u{1F310} \u6388\u6743\u5730\u5740: ${e}
@@ -302,10 +302,13 @@ type: ${a.type}
302
302
  `):process.stdout.write(JSON.stringify(s,null,2)+`
303
303
  `),0}return o.quiet?(n&&n.id&&console.log(n.id),0):!n||!n.id?(console.log("\uFF08\u672A\u8BBE\u7F6E\u9ED8\u8BA4\u56E2\u961F\uFF0C\u8FD0\u884C 'coder team use <teamId>' \u6765\u8BBE\u7F6E\uFF09"),0):(console.log(`\u9ED8\u8BA4\u56E2\u961F: ${n.name||""} (${n.id})`),0)}async use(e,t,o){let{out:n,remaining:s}=this.parseOutputFlags(t),r=s[0];if(!r)return console.error("\u274C 3: \u7F3A\u5C11 teamId \u53C2\u6570\u3002\u7528\u6CD5: coder team use <teamId>"),3;if(!this.argParser)return console.error("\u274C 1: \u5185\u90E8\u9519\u8BEF\uFF1AargParser \u672A\u6CE8\u5165"),1;let i=encodeURIComponent(JSON.stringify({filter_is_joined:!0})),a;try{a=await this.request("GET",`/team?constraints=${i}&page=1&size=200`,o)}catch(p){return console.error(`\u274C 1: \u7F51\u7EDC\u9519\u8BEF ${p.message}`),1}if(a.status!==200)return console.error(`\u274C ${this.exitCodeForStatus(a.status)}: HTTP ${a.status}`),a.body&&console.error(a.body),this.exitCodeForStatus(a.status);let l=this.parseJson(a.body),u=(l&&l.data&&l.data.items||[]).find(p=>p.id===r);if(!u)return console.error(`\u274C 4: \u56E2\u961F '${r}' \u4E0D\u5728\u4F60\u5DF2\u52A0\u5165\u7684\u5217\u8868\u4E2D\u3002\u8FD0\u884C 'coder team list' \u67E5\u770B\u53EF\u7528\u56E2\u961F`),4;if(!this.argParser.setTeam(u.id,u.name||""))return console.error("\u274C 1: \u5199\u5165\u914D\u7F6E\u5931\u8D25"),1;if(this.argParser.setTeamManual(!0),n.json){let p={id:u.id,name:u.name||""};return process.stdout.write(JSON.stringify(p,null,2)+`
304
304
  `),0}return n.quiet?(console.log(u.id),0):(console.log(`\u2705 \u5DF2\u5207\u6362\u5230\u9ED8\u8BA4\u56E2\u961F: ${u.name||""} (${u.id})`),0)}showHelp(){console.log(["Usage: coder team <subcommand> [options]","","\u9762\u5411 AI \u4F18\u5148\u7684\u56E2\u961F\u4E0E\u6210\u5458\u7BA1\u7406\u3002","","Team Management:"," list \u5217\u51FA\u6211\u52A0\u5165\u7684\u56E2\u961F\uFF08\u522B\u540D: ls\uFF09"," current \u663E\u793A\u5F53\u524D\u9ED8\u8BA4\u56E2\u961F"," use <teamId> \u5207\u6362\u9ED8\u8BA4\u56E2\u961F\uFF08\u5199\u5165 ~/.coder/config.json\uFF09"," info [teamId] \u56E2\u961F\u8BE6\u60C5\uFF1A\u79EF\u5206\u3001\u6210\u5458\u6570\u3001\u6709\u6548\u671F\u7B49","","Members:"," members [teamId] \u6210\u5458\u5217\u8868"," member-get <userId> [teamId] \u5355\u4E2A\u6210\u5458\u8BE6\u60C5"," member-create <username> \u521B\u5EFA\u6210\u5458\uFF08\u9ED8\u8BA4 user_type=human\uFF09"," [--type human|ai]"," [--password <pwd>] \u7701\u7565 = \u968F\u673A\u751F\u6210 16 \u4F4D\u5F3A\u5BC6\u7801"," [--phone <phone>] human \u5FC5\u586B\uFF0Cai \u53EF\u7701"," [--points <n>] \u79EF\u5206\u914D\u989D\uFF0C\u9ED8\u8BA4 null = \u7EE7\u627F\u56E2\u961F"," [--team <teamId>]"," [--save-to <path>] \u4FDD\u5B58\u51ED\u636E\u5230\u6587\u4EF6 (chmod 600)"," member-delete <userId> \u5220\u9664\u6210\u5458\uFF08\u9AD8\u5F71\u54CD\uFF0C\u9700 --yes\uFF09"," [--team <teamId>] [--yes]"," set-points <userId> \u8BBE\u7F6E\u6210\u5458\u79EF\u5206\u914D\u989D\uFF08owner / manager \u53EF\u7528\uFF09"," --unlimited \u4E0D\u9650\u91CF\uFF08points = null\uFF09"," --points <n> \u6307\u5B9A\u6570\u503C"," --inherit \u7B49\u4EF7 --unlimited\uFF08\u8BED\u4E49\uFF1A\u7EE7\u627F\u56E2\u961F\u6C60\uFF09"," [--team <teamId>]","","Discovery:"," search-member <keyword> [teamId] \u6210\u5458\u4E2D\u641C\u7D22\uFF08\u672C\u5730\u8FC7\u6EE4\uFF09","","Output (AI-friendly):"," --json \u8F93\u51FA\u7ED3\u6784\u5316 JSON\uFF08\u53EF\u88AB jq \u89E3\u6790\uFF09"," --quiet \u53EA\u8F93\u51FA\u4E3B\u952E\uFF08id / username\uFF09\uFF0C\u6362\u884C\u5206\u9694"," --field <jq-path> \u4EC5\u8F93\u51FA\u6307\u5B9A\u5B57\u6BB5\uFF08dot path\uFF0C\u5982 items[0].id\uFF09","","Exit codes:"," 0 \u6210\u529F | 1 \u901A\u7528\u9519\u8BEF | 2 \u672A\u767B\u5F55 | 3 \u53C2\u6570\u9519\u8BEF | 4 \u8D44\u6E90\u4E0D\u5B58\u5728"," 5 \u6743\u9650\u4E0D\u8DB3 | 6 \u51B2\u7A81\uFF08\u5DF2\u5B58\u5728\uFF09 | 10 \u5F85\u786E\u8BA4\uFF08\u9AD8\u5F71\u54CD\u64CD\u4F5C\u672A\u52A0 --yes\uFF09","","Examples:"," coder team list"," coder team list --json | jq '.items[].id'"," coder team list --quiet"].join(`
305
- `))}};function D(c,e){if(!e)return c;let t=[],o=/[^.\[\]]+|\[(\d+)\]/g,n;for(;(n=o.exec(e))!==null;)t.push(n[1]!==void 0?Number(n[1]):n[0]);let s=c;for(let r of t){if(s==null)return;s=s[r]}return s}function P(c){return c==null?"":typeof c=="string"?c:typeof c=="number"||typeof c=="boolean"?String(c):JSON.stringify(c)}function fe(c,e){let t=c.map(n=>Math.max(n.length,...e.map(s=>at(String(s[n]??""))))),o=(n,s)=>n+" ".repeat(Math.max(0,s-at(n)));console.log(c.map((n,s)=>o(n,t[s])).join(" ")),console.log(t.map(n=>"-".repeat(n)).join(" "));for(let n of e)console.log(c.map((s,r)=>o(String(n[s]??""),t[r])).join(" "))}function at(c){let e=0;for(let t of c){let o=t.codePointAt(0);o>=19968&&o<=40959||o>=12288&&o<=12351||o>=65280&&o<=65519?e+=2:e+=1}return e}lt.exports=ge});var mt=$((Ro,pt)=>{var No=require("path"),oo=$e(),ut=_e(),no=De(),ro=Te(),so=Be(),io=Ue(),co=Fe(),ao=Ve(),lo=Ke(),uo=Ze(),po=st(),mo=dt(),{isPrintMode:Uo}=U(),ye=class{constructor(){this.argParser=new oo,this.claudeLauncher=this._createClaudeLauncher(),this.geminiLauncher=new ro,this.codexLauncher=new so,this.vscodeExtensionService=new io,this.publishService=new co,this.skillsService=new ao,this.wikiService=new lo(this.argParser),this.channelService=new uo,this.authCommandService=new po(this.argParser),this.teamService=new mo(this.argParser),this.wikiService.teamService=this.teamService}_createClaudeLauncher(){let e=process.env.CODEV_DEBUG;if(process.env.CODEV_USE_NODE==="1")return e&&console.error("[DEBUG] CODEV_USE_NODE=1, forcing ClaudeLauncher (node fallback)"),new ut;try{let t=new no,o=t.findExecutablePath();return e&&console.error(`[DEBUG] ClaudeBunLauncher selected, executable: ${o}`),t}catch(t){return e&&console.error(`[DEBUG] ClaudeBunLauncher unavailable: ${t.message}, falling back to ClaudeLauncher (node)`),new ut}}async run(e=process.argv.slice(2)){try{try{await this.vscodeExtensionService.ensureExtensionInstalled()}catch(o){process.env.CODEV_DEBUG&&console.error("VSCode Extension Service Error:",o)}if(!e.includes("--agent")&&!e.includes("-a")){let o=e.length>0&&["claude","gemini","codex"].includes(e[0]),n=e.length>0&&["pub","auth","update","skills","wiki","channel","team"].includes(e[0]);if(!o&&!n&&(e.includes("--help")||e.includes("-h")))return this.argParser.showHelp(),0;if(!o&&!n&&(e.includes("--version")||e.includes("-v")))return this.showVersion(),0}let t=await this.argParser.parse(e);return t.command==="auth"?await this.authCommandService.handle(t):t.command==="update"?this.handleUpdate():t.command==="skills"?await this.skillsService.handle(t):t.command==="wiki"?await this.wikiService.handle(t):t.command==="channel"?await this.channelService.handle({...t,claudeLauncher:this.claudeLauncher,parsedArgs:t}):t.command==="team"?await this.teamService.handle(t):t.command==="pub"?e.includes("--help")||e.includes("-h")?(this.publishService.showHelp(),0):await this.publishService.publish({name:t.pubName,apikey:t.apikey,serverBaseUrl:t.codevServer,allowClone:t.allowClone}):(t.apikey&&this.skillsService.notifyAndRefreshUpdates(t.apikey),await this.launchAgent(t))}catch(t){return console.error(`Error: ${t.message}`),process.env.CODEV_DEBUG&&console.error("Stack trace:",t.stack),1}}async launchAgent(e){let{agent:t}=e;return t==="claude"?await this.claudeLauncher.launch(e):t==="gemini"?await this.geminiLauncher.launch(e):t==="codex"?await this.codexLauncher.launch(e):1}handleUpdate(){let{execSync:e}=require("child_process"),t=N();console.log(`\u5F53\u524D\u7248\u672C: ${t.version}`),console.log(`\u6B63\u5728\u5347\u7EA7 Coder...
306
- `);try{return e("npm install -g makecoder@latest",{stdio:"inherit"}),console.log(`
307
- \u2705 \u5347\u7EA7\u6210\u529F`),0}catch(o){return console.error(`
308
- \u274C \u5347\u7EA7\u5931\u8D25:`,o.message),1}}showVersion(){let e=N();console.log(`coder version: ${e.version}`)}async shutdown(){console.log(`
309
- Shutting down...`),process.exit(0)}};pt.exports=ye});var ht=process.env.CODER_ARGV0;if(ht){let e={rg:"rg",ugrep:"ugrep",bfs:"bfs"}[ht];if(e){let t=require("path").join(__dirname,"..","dist",`${process.platform}-${process.arch}`,e);require("fs").existsSync(t)||(console.error(`${e} is not available. Use system default command instead (grep, find, etc.)`),process.exit(1));let{spawnSync:o}=require("child_process"),n=o(t,process.argv.slice(2),{stdio:"inherit"});process.exit(n.status??1)}}var ho=mt(),{isPrintMode:Mo}=U();process.on("unhandledRejection",(c,e)=>{console.error("Unhandled Promise Rejection:",c),process.exit(1)});process.on("uncaughtException",c=>{console.error("Uncaught Exception:",c.message),process.env.CODEV_DEBUG&&console.error(c.stack),process.exit(1)});function fo(c,e){let t=s=>s.replace(/^v/,"").split(".").map(Number),[o,n]=[t(c),t(e)];for(let s=0;s<3;s++){if((o[s]||0)>(n[s]||0))return!0;if((o[s]||0)<(n[s]||0))return!1}return!1}function go(){let c=require("https"),{version:e}=N(),o=c.get("https://registry.npmmirror.com/makecoder/latest",{timeout:5e3},n=>{let s="";n.on("data",r=>{s+=r}),n.on("end",()=>{try{let r=JSON.parse(s).version;r&&fo(r,e)&&console.log(`\x1B[33m\u26A1 \u68C0\u6D4B\u5230\u65B0\u7248\u672C ${r}\uFF08\u5F53\u524D ${e}\uFF09\uFF0C\u8FD0\u884C coder update \u5347\u7EA7\x1B[0m`)}catch{}})});o.on("error",()=>{}),o.on("timeout",()=>o.destroy())}async function yo(){go();let c=new ho;process.on("SIGINT",async()=>{console.log(`
310
- Received SIGINT, shutting down gracefully...`),await c.shutdown()}),process.on("SIGTERM",async()=>{console.log(`
311
- Received SIGTERM, shutting down gracefully...`),await c.shutdown()});try{let e=await c.run();process.exit(e)}catch(e){console.error(`Fatal error: ${e.message}`),process.env.CODEV_DEBUG&&console.error(e.stack),process.exit(1)}}yo().catch(c=>{console.error(`Startup error: ${c.message}`),process.exit(1)});
305
+ `))}};function D(c,e){if(!e)return c;let t=[],o=/[^.\[\]]+|\[(\d+)\]/g,n;for(;(n=o.exec(e))!==null;)t.push(n[1]!==void 0?Number(n[1]):n[0]);let s=c;for(let r of t){if(s==null)return;s=s[r]}return s}function P(c){return c==null?"":typeof c=="string"?c:typeof c=="number"||typeof c=="boolean"?String(c):JSON.stringify(c)}function fe(c,e){let t=c.map(n=>Math.max(n.length,...e.map(s=>at(String(s[n]??""))))),o=(n,s)=>n+" ".repeat(Math.max(0,s-at(n)));console.log(c.map((n,s)=>o(n,t[s])).join(" ")),console.log(t.map(n=>"-".repeat(n)).join(" "));for(let n of e)console.log(c.map((s,r)=>o(String(n[s]??""),t[r])).join(" "))}function at(c){let e=0;for(let t of c){let o=t.codePointAt(0);o>=19968&&o<=40959||o>=12288&&o<=12351||o>=65280&&o<=65519?e+=2:e+=1}return e}lt.exports=ge});var mt=$((Ro,pt)=>{var No=require("path"),oo=$e(),ut=Ee(),no=De(),ro=Te(),so=Be(),io=Ue(),co=Fe(),ao=Ve(),lo=He(),uo=Ze(),po=st(),mo=dt(),{isPrintMode:Uo}=U(),ye=class{constructor(){this.argParser=new oo,this.claudeLauncher=this._createClaudeLauncher(),this.geminiLauncher=new ro,this.codexLauncher=new so,this.vscodeExtensionService=new io,this.publishService=new co,this.skillsService=new ao,this.wikiService=new lo(this.argParser),this.channelService=new uo,this.authCommandService=new po(this.argParser),this.teamService=new mo(this.argParser),this.wikiService.teamService=this.teamService}_createClaudeLauncher(){let e=process.env.CODEV_DEBUG;if(process.env.CODEV_USE_NODE==="1")return e&&console.error("[DEBUG] CODEV_USE_NODE=1, forcing ClaudeLauncher (node fallback)"),new ut;try{let t=new no,o=t.findExecutablePath();return e&&console.error(`[DEBUG] ClaudeBunLauncher selected, executable: ${o}`),t}catch(t){return e&&console.error(`[DEBUG] ClaudeBunLauncher unavailable: ${t.message}, falling back to ClaudeLauncher (node)`),new ut}}async run(e=process.argv.slice(2)){try{try{await this.vscodeExtensionService.ensureExtensionInstalled()}catch(o){process.env.CODEV_DEBUG&&console.error("VSCode Extension Service Error:",o)}if(!e.includes("--agent")&&!e.includes("-a")){let o=e.length>0&&["claude","gemini","codex"].includes(e[0]),n=e.length>0&&["pub","auth","update","skills","wiki","channel","team"].includes(e[0]);if(!o&&!n&&(e.includes("--help")||e.includes("-h")))return this.argParser.showHelp(),0;if(!o&&!n&&(e.includes("--version")||e.includes("-v")))return this.showVersion(),0}let t=await this.argParser.parse(e);return t.command==="auth"?await this.authCommandService.handle(t):t.command==="update"?this.handleUpdate():t.command==="skills"?await this.skillsService.handle(t):t.command==="wiki"?await this.wikiService.handle(t):t.command==="channel"?await this.channelService.handle({...t,claudeLauncher:this.claudeLauncher,parsedArgs:t}):t.command==="team"?await this.teamService.handle(t):t.command==="pub"?e.includes("--help")||e.includes("-h")?(this.publishService.showHelp(),0):await this.publishService.publish({name:t.pubName,apikey:t.apikey,serverBaseUrl:t.codevServer,allowClone:t.allowClone}):(t.apikey&&this.skillsService.notifyAndRefreshUpdates(t.apikey),await this.launchAgent(t))}catch(t){return console.error(`Error: ${t.message}`),process.env.CODEV_DEBUG&&console.error("Stack trace:",t.stack),1}}async launchAgent(e){let{agent:t}=e;return t==="claude"?await this.claudeLauncher.launch(e):t==="gemini"?await this.geminiLauncher.launch(e):t==="codex"?await this.codexLauncher.launch(e):1}handleUpdate(){let{execSync:e}=require("child_process"),t=N();console.log(`\u5F53\u524D\u7248\u672C: ${t.version}`),console.log(`\u6B63\u5728\u5347\u7EA7 Coder...
306
+ `);try{e("npm install -g makecoder@latest",{stdio:"inherit"})}catch(o){return console.error(`
307
+ \u274C \u5347\u7EA7\u5931\u8D25:`,o.message),1}return this._ensurePlatformCodex(),console.log(`
308
+ \u2705 \u5347\u7EA7\u6210\u529F`),0}_ensurePlatformCodex(){let{execSync:e}=require("child_process"),t=require("fs"),o=require("path"),n={"linux-x64":"makecoder-codex-linux-x64","darwin-arm64":"makecoder-codex-darwin-arm64","win32-x64":"makecoder-codex-win32-x64"},s=`${process.platform}-${process.arch}`,r=n[s];if(!r)return;let i;try{i=e("npm root -g",{encoding:"utf8"}).trim()}catch{return}if([o.join(i,"makecoder","node_modules",r,"package.json"),o.join(i,r,"package.json")].some(m=>t.existsSync(m)))return;console.log(`
309
+ \u26A0\uFE0F \u672A\u68C0\u6D4B\u5230 ${r}\uFF0C\u6B63\u5728\u8865\u88C5...`);let l;try{l=require(o.join(i,"makecoder","package.json")).optionalDependencies?.[r]}catch{}let d=m=>{try{return e(`npm install -g ${m}`,{stdio:"inherit"}),!0}catch{return!1}};l&&d(`${r}@${l}`)||d(`${r}@latest`)||console.warn(`
310
+ \u26A0\uFE0F \u81EA\u52A8\u8865\u88C5 ${r} \u5931\u8D25\uFF0Ccoder codex \u53EF\u80FD\u4E0D\u53EF\u7528\u3002
311
+ \u8BF7\u624B\u52A8\u6267\u884C: npm install -g ${r}@latest`)}showVersion(){let e=N();console.log(`coder version: ${e.version}`)}async shutdown(){console.log(`
312
+ Shutting down...`),process.exit(0)}};pt.exports=ye});var ht=process.env.CODER_ARGV0;if(ht){let e={rg:"rg",ugrep:"ugrep",bfs:"bfs"}[ht];if(e){let t=require("path").join(__dirname,"..","dist",`${process.platform}-${process.arch}`,e);require("fs").existsSync(t)||(console.error(`${e} is not available. Use system default command instead (grep, find, etc.)`),process.exit(1));let{spawnSync:o}=require("child_process"),n=o(t,process.argv.slice(2),{stdio:"inherit"});process.exit(n.status??1)}}var ho=mt(),{isPrintMode:Mo}=U();process.on("unhandledRejection",(c,e)=>{console.error("Unhandled Promise Rejection:",c),process.exit(1)});process.on("uncaughtException",c=>{console.error("Uncaught Exception:",c.message),process.env.CODEV_DEBUG&&console.error(c.stack),process.exit(1)});function fo(c,e){let t=s=>s.replace(/^v/,"").split(".").map(Number),[o,n]=[t(c),t(e)];for(let s=0;s<3;s++){if((o[s]||0)>(n[s]||0))return!0;if((o[s]||0)<(n[s]||0))return!1}return!1}function go(){let c=require("https"),{version:e}=N(),o=c.get("https://registry.npmmirror.com/makecoder/latest",{timeout:5e3},n=>{let s="";n.on("data",r=>{s+=r}),n.on("end",()=>{try{let r=JSON.parse(s).version;r&&fo(r,e)&&console.log(`\x1B[33m\u26A1 \u68C0\u6D4B\u5230\u65B0\u7248\u672C ${r}\uFF08\u5F53\u524D ${e}\uFF09\uFF0C\u8FD0\u884C coder update \u5347\u7EA7\x1B[0m`)}catch{}})});o.on("error",()=>{}),o.on("timeout",()=>o.destroy())}async function yo(){let c=new Set(["pub","auth","update","skills","wiki","channel","team"]),e=process.argv[2];(!e||!c.has(e))&&go();let t=new ho;process.on("SIGINT",async()=>{console.log(`
313
+ Received SIGINT, shutting down gracefully...`),await t.shutdown()}),process.on("SIGTERM",async()=>{console.log(`
314
+ Received SIGTERM, shutting down gracefully...`),await t.shutdown()});try{let o=await t.run();process.exit(o)}catch(o){console.error(`Fatal error: ${o.message}`),process.env.CODEV_DEBUG&&console.error(o.stack),process.exit(1)}}yo().catch(c=>{console.error(`Startup error: ${c.message}`),process.exit(1)});
package/dist/codex.mjs CHANGED
@@ -58,7 +58,8 @@ if (!binaryPath) {
58
58
  throw new Error(
59
59
  `Codex binary not found for ${platformKey}.\n` +
60
60
  `Expected sub-package ${platformPackage} to be installed.\n` +
61
- `Try reinstalling: npm install -g makecoder@latest`,
61
+ `Run: npm install -g ${platformPackage}@latest\n` +
62
+ `(or: coder update)`,
62
63
  );
63
64
  }
64
65