makecoder 4.0.56 → 4.0.57

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.56' + '&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.57' + '&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.56');
29
+ payload.headers.values.set('X-Coder-Version', '4.0.57');
30
30
  payload.headers.values.set('X-Coder-Platform', process.platform);
31
31
  payload.headers.values.set('X-Coder-Arch', process.arch);
32
32
 
package/dist/coder.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- var gt=Object.create;var we=Object.defineProperty;var yt=Object.getOwnPropertyDescriptor;var bt=Object.getOwnPropertyNames;var It=Object.getPrototypeOf,wt=Object.prototype.hasOwnProperty;var $=(c,e)=>()=>(e||c((e={exports:{}}).exports,e),e.exports);var xt=(c,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of bt(e))!wt.call(c,n)&&n!==t&&we(c,n,{get:()=>e[n],enumerable:!(o=yt(e,n))||o.enumerable});return c};var $t=(c,e,t)=>(t=c!=null?gt(It(c)):{},xt(e||!c||!c.__esModule?we(t,"default",{value:c,enumerable:!0}):t,c));var N=$((wo,kt)=>{kt.exports={name:"makecoder",version:"4.0.56",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","claude","scripts/postinstall.js"]}});var Se=$((xo,ke)=>{var E=require("fs"),xe=require("path"),St=require("os"),Ct=new Set(["auth","skills","wiki","channel","team"]),$e=new Set(["claude","gemini","codex"]),vt=new Set(["pub","auth","update","skills","wiki","channel","team"]),Q=class{constructor(){let e=process.env.CODER_PROFILE,t=e?`.coder.${e}`:".coder";this.configPath=xe.join(St.homedir(),t,"config.json"),this.defaultConfig={agent:"claude",auth:{apikey:null}}}loadConfig(){let e=xe.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($e.has(e[0]))o.agent=e[0],o.agentSetBySubcommand=!0,n=1;else if(vt.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||!$e.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!Ct.has(o.command)&&!s&&!o.apikey&&await this._oauthLogin(o),o}async _oauthLogin(e){console.log(`\u274C \u5C1A\u672A\u767B\u5F55
2
+ var gt=Object.create;var we=Object.defineProperty;var yt=Object.getOwnPropertyDescriptor;var bt=Object.getOwnPropertyNames;var It=Object.getPrototypeOf,wt=Object.prototype.hasOwnProperty;var $=(c,e)=>()=>(e||c((e={exports:{}}).exports,e),e.exports);var xt=(c,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of bt(e))!wt.call(c,n)&&n!==t&&we(c,n,{get:()=>e[n],enumerable:!(o=yt(e,n))||o.enumerable});return c};var $t=(c,e,t)=>(t=c!=null?gt(It(c)):{},xt(e||!c||!c.__esModule?we(t,"default",{value:c,enumerable:!0}):t,c));var N=$((wo,kt)=>{kt.exports={name:"makecoder",version:"4.0.57",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","claude","scripts/postinstall.js"]}});var Se=$((xo,ke)=>{var E=require("fs"),xe=require("path"),St=require("os"),Ct=new Set(["auth","skills","wiki","channel","team"]),$e=new Set(["claude","gemini","codex"]),vt=new Set(["pub","auth","update","skills","wiki","channel","team"]),Q=class{constructor(){let e=process.env.CODER_PROFILE,t=e?`.coder.${e}`:".coder";this.configPath=xe.join(St.homedir(),t,"config.json"),this.defaultConfig={agent:"claude",auth:{apikey:null}}}loadConfig(){let e=xe.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($e.has(e[0]))o.agent=e[0],o.agentSetBySubcommand=!0,n=1;else if(vt.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||!$e.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!Ct.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
- `))}};ke.exports=Q});var U=$(($o,Ce)=>{function Et(c=process.argv.slice(2)){return c.includes("--print")||c.includes("-p")}Ce.exports={isPrintMode:Et}});var F=$((ko,ve)=>{var{spawn:_t}=require("child_process"),H=require("path"),R=require("fs"),Ot=require("os"),{isPrintMode:Dt}=U(),ee=class{constructor(e){this.config=e}async ensureConfig(e=0){let t=H.join(Ot.homedir(),this.config.configDir,this.config.configFile),o=H.dirname(t);if(!R.existsSync(t)){let n=this.config.defaultConfig||{};try{R.existsSync(o)||R.mkdirSync(o,{recursive:!0}),R.writeFileSync(t,JSON.stringify(n,null,2)),e>0&&await new Promise(s=>setTimeout(s,e))}catch(s){console.warn(`Failed to create ${this.config.configFile}: ${s.message}`)}}}findExecutablePath(){let e=H.dirname(require.main.filename);for(let t of this.config.executablePaths){let o=H.resolve(e,t);if(R.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{await this.ensureConfig(1e3);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)=>{Dt(t)||p&&console.log(`terminated by signal: ${p}`)}),process.on("SIGINT",async()=>{console.log(`
7
+ `))}};ke.exports=Q});var U=$(($o,Ce)=>{function Et(c=process.argv.slice(2)){return c.includes("--print")||c.includes("-p")}Ce.exports={isPrintMode:Et}});var F=$((ko,ve)=>{var{spawn:_t}=require("child_process"),K=require("path"),R=require("fs"),Ot=require("os"),{isPrintMode:Dt}=U(),ee=class{constructor(e){this.config=e}async ensureConfig(e=0){let t=K.join(Ot.homedir(),this.config.configDir,this.config.configFile),o=K.dirname(t);if(!R.existsSync(t)){let n=this.config.defaultConfig||{};try{R.existsSync(o)||R.mkdirSync(o,{recursive:!0}),R.writeFileSync(t,JSON.stringify(n,null,2)),e>0&&await new Promise(s=>setTimeout(s,e))}catch(s){console.warn(`Failed to create ${this.config.configFile}: ${s.message}`)}}}findExecutablePath(){let e=K.dirname(require.main.filename);for(let t of this.config.executablePaths){let o=K.resolve(e,t);if(R.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)=>{Dt(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}}};ve.exports=ee});var Oe=$((So,_e)=>{var At=F(),M=require("path"),Ee=require("fs"),te=class extends At{constructor(){super({configDir:".",configFile:".claude.json",executablePaths:["cc.mjs","../dist/cc.mjs","/tmp/claude-code/package/cc.mjs"],environmentVariables:e=>({ANTHROPIC_BASE_URL:`${e}/claude`,ANTHROPIC_API_KEY:"codev",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"}),defaultConfig:{numStartups:1,installMethod:"unknown",autoUpdates:!1,theme:"Coder Dark",customApiKeyResponses:{approved:["codev"]},shiftEnterKeyBindingInstalled:!0,hasCompletedOnboarding:!0,subscriptionNoticeCount:0,hasAvailableSubscription:!0,projects:{}}})}findExecutablePath(){let e=M.dirname(require.main.filename);for(let o of this.config.executablePaths){let n=M.resolve(e,o);if(Ee.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(Ee.existsSync(o))return o;return null}};_e.exports=te});var Ae=$((Co,De)=>{var Pt=F(),{spawn:Tt,execFileSync:qt}=require("child_process"),_=require("path"),P=require("fs"),{isPrintMode:Bt}=U(),jt=process.env.CODEV_DEBUG==="True",oe=class extends Pt{constructor(){let e=`${process.platform}-${process.arch}`;super({configDir:".",configFile:".claude.json",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:"codev",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",ANTHROPIC_DEFAULT_HAIKU_MODEL:"claude-haiku-4-5"}),defaultConfig:{numStartups:1,installMethod:"unknown",autoUpdates:!1,theme:"Coder Dark",customApiKeyResponses:{approved:["codev"]},shiftEnterKeyBindingInstalled:!0,hasCompletedOnboarding:!0,subscriptionNoticeCount:0,hasAvailableSubscription:!0,projects:{}}})}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(P.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(P.existsSync(n))return n;return null}_resolveBunPath(){let e=process.platform==="win32",t=e?"bun.exe":"bun";try{return qt(t,["--version"],{stdio:"ignore"}),t}catch{}let o=_.join(process.env.HOME||process.env.USERPROFILE||"",".local","bin",t);if(P.existsSync(o))return o;let n=_.join(__dirname,"..","..","node_modules",".bin",t);if(P.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(P.existsSync(i))return i}catch{}try{let r=require.resolve(`bun/${e?"bin/bun.exe":"bin/bun"}`);if(P.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;await this.ensureConfig(1e3);let r=this.findExecutablePath(),i=this._resolveBunPath();return jt&&(console.log(`executablePath (bun): ${r}`),console.log(`bunPath: ${i}`)),new Promise((a,l)=>{let d={...process.env,...this.config.environmentVariables(o),CODER_EXECPATH:P.realpathSync(process.argv[1]),...s};n&&(d.CODER_APIKEY=n);let u=[r,...t],m=Tt(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)=>{Bt(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}}};ve.exports=ee});var Oe=$((So,_e)=>{var At=F(),M=require("path"),Ee=require("fs"),te=class extends At{constructor(){super({executablePaths:["cc.mjs","../dist/cc.mjs","/tmp/claude-code/package/cc.mjs"],environmentVariables:e=>({ANTHROPIC_BASE_URL:`${e}/claude`,ANTHROPIC_API_KEY:"codev",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(Ee.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(Ee.existsSync(o))return o;return null}};_e.exports=te});var Ae=$((Co,De)=>{var Pt=F(),{spawn:Tt,execFileSync:qt}=require("child_process"),_=require("path"),P=require("fs"),{isPrintMode:Bt}=U(),jt=process.env.CODEV_DEBUG==="True",oe=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:"codev",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(P.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(P.existsSync(n))return n;return null}_resolveBunPath(){let e=process.platform==="win32",t=e?"bun.exe":"bun";try{return qt(t,["--version"],{stdio:"ignore"}),t}catch{}let o=_.join(process.env.HOME||process.env.USERPROFILE||"",".local","bin",t);if(P.existsSync(o))return o;let n=_.join(__dirname,"..","..","node_modules",".bin",t);if(P.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(P.existsSync(i))return i}catch{}try{let r=require.resolve(`bun/${e?"bin/bun.exe":"bin/bun"}`);if(P.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 jt&&(console.log(`executablePath (bun): ${r}`),console.log(`bunPath: ${i}`)),new Promise((a,l)=>{let d={...process.env,...this.config.environmentVariables(o),CODER_EXECPATH:P.realpathSync(process.argv[1]),...s};n&&(d.CODER_APIKEY=n);let u=[r,...t],m=Tt(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)=>{Bt(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
11
  Terminating ...`),m.kill("SIGTERM"),setTimeout(()=>{m.killed||m.kill("SIGKILL")},8e3)})})}};De.exports=oe});var qe=$((vo,Te)=>{var Lt=F(),J=require("path"),Pe=require("fs"),ne=class extends Lt{constructor(){super({configDir:".gemini",configFile:"settings.json",executablePaths:["gemini/gemini.js","../dist/gemini/gemini.js"],environmentVariables:e=>({GOOGLE_GEMINI_BASE_URL:`${e}/gemini`,GEMINI_API_KEY:"coder",GOOGLE_API_KEY:"coder",GOOGLE_CLOUD_PROJECT:"coder",GOOGLE_CLOUD_LOCATION:"coder",DISABLE_TELEMETRY:!0,GEMINI_CODE_DISABLE_NONESSENTIAL_TRAFFIC:!0,DISABLE_COST_WARNINGS:!0,DISABLE_NON_ESSENTIAL_MODEL_CALLS:!0,USE_VERTEX:!0}),defaultConfig:{ide:{hasSeenNudge:!0},telemetry:{enabled:!1,logPrompts:!1},privacy:{usageStatisticsEnabled:!1},general:{disableUpdateNag:!0,preferredEditor:"vscode",previewFeatures:!0},ui:{hideBanner:!0,theme:"Default"},security:{auth:{selectedType:"vertex-ai"}}}})}findExecutablePath(){let e=J.dirname(require.main.filename);for(let o of this.config.executablePaths){let n=J.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=J.dirname(process.execPath),t=[J.join(e,"..","lib","node_modules","makecoder","dist","gemini","gemini.js"),J.join(e,"node_modules","makecoder","dist","gemini","gemini.js")];for(let o of t)if(Pe.existsSync(o))return o;return null}};Te.exports=ne});var je=$((Eo,Be)=>{var Nt=F(),G=require("path"),re=require("fs"),{spawn:Ut}=require("child_process"),Rt=process.env.CODEV_DEBUG==="True",se=class extends Nt{constructor(){super({executablePaths:["codex.mjs","../dist/codex.mjs"],environmentVariables:()=>({CODEX_DISABLE_WEBSOCKET:"1"})})}checkCodexAvailability(){try{let e=this.findExecutablePath();return re.existsSync(e)}catch{return!1}}findExecutablePath(){let e=G.dirname(require.main.filename);for(let o of this.config.executablePaths){let n=G.resolve(e,o);if(re.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=G.dirname(process.execPath),t=[G.join(e,"..","lib","node_modules","makecoder","dist","codex.mjs"),G.join(e,"node_modules","makecoder","dist","codex.mjs")];for(let o of t)if(re.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();Rt&&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=Ut("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(`
@@ -22,7 +22,7 @@ Terminating ...`),m.kill("SIGTERM"),setTimeout(()=>{m.killed||m.kill("SIGKILL")}
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=ce});var Ke=$((Do,Ve)=>{var Ge=require("https"),w=require("fs"),k=require("path"),W=require("os"),O="https://makecoder.com/skillhub",ae=class{getSkillDirs(){let e=W.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}`}:{}};Ge.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=ce});var He=$((Do,Ve)=>{var Ge=require("https"),w=require("fs"),k=require("path"),W=require("os"),O="https://makecoder.com/skillhub",ae=class{getSkillDirs(){let e=W.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}`}:{}};Ge.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(`
@@ -35,7 +35,7 @@ Terminating ...`),m.kill("SIGTERM"),setTimeout(()=>{m.killed||m.kill("SIGKILL")}
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
- `))}};Ve.exports=ae});var ze=$((Ao,He)=>{var Mt=require("https"),Y="https://makecoder.com/wiki",Jt=`${Y}/api`,v=c=>`${Y}/doc/${c}`,le=c=>`${Y}/collection/${c}`;function Gt(c){return c.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}var Vt={"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
+ `))}};Ve.exports=ae});var ze=$((Ao,Ke)=>{var Mt=require("https"),Y="https://makecoder.com/wiki",Jt=`${Y}/api`,v=c=>`${Y}/doc/${c}`,le=c=>`${Y}/collection/${c}`;function Gt(c){return c.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}var Vt={"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,11 +82,11 @@ 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=de});var Qe=$((Po,Ze)=>{var q=require("fs"),j=require("path"),Xe=require("os"),Kt=require("readline"),X=j.join(Xe.homedir(),".coder","config.json"),We=process.env.MCP_CHANNEL_DIR||j.join(Xe.homedir(),".claude","mcp-channel"),Ye=["wecom"];function Z(c){return!c||c.length<=8?"****":c.slice(0,3)+"****"+c.slice(-3)}var ue=class{load(){try{return JSON.parse(q.readFileSync(X,"utf8"))}catch{return{}}}save(e){let t=j.dirname(X);q.existsSync(t)||q.mkdirSync(t,{recursive:!0}),q.writeFileSync(X,JSON.stringify(e,null,2)+`
85
+ `))}};Ke.exports=de});var Qe=$((Po,Ze)=>{var q=require("fs"),j=require("path"),Xe=require("os"),Ht=require("readline"),X=j.join(Xe.homedir(),".coder","config.json"),We=process.env.MCP_CHANNEL_DIR||j.join(Xe.homedir(),".claude","mcp-channel"),Ye=["wecom"];function Z(c){return!c||c.length<=8?"****":c.slice(0,3)+"****"+c.slice(-3)}var ue=class{load(){try{return JSON.parse(q.readFileSync(X,"utf8"))}catch{return{}}}save(e){let t=j.dirname(X);q.existsSync(t)||q.mkdirSync(t,{recursive:!0}),q.writeFileSync(X,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(We,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:X,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?Z(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...
89
- `),await t.launch(o)}async promptSetupChannel(){let e=Kt.createInterface({input:process.stdin,output:process.stdout}),t=o=>new Promise(n=>e.question(o,n));try{for(;;){console.log(`\u8BF7\u914D\u7F6E\u4F01\u4E1A\u5FAE\u4FE1 AI Bot \u6E20\u9053\uFF1A
89
+ `),await t.launch(o)}async promptSetupChannel(){let e=Ht.createInterface({input:process.stdin,output:process.stdout}),t=o=>new Promise(n=>e.question(o,n));try{for(;;){console.log(`\u8BF7\u914D\u7F6E\u4F01\u4E1A\u5FAE\u4FE1 AI Bot \u6E20\u9053\uFF1A
90
90
  `);let o=(await t(" 1. \u8BF7\u7C98\u8D34 Bot ID: ")).trim();if(!o){console.error(`\u274C Bot ID \u4E0D\u80FD\u4E3A\u7A7A
91
91
  `);continue}let n=(await t(" 2. \u8BF7\u7C98\u8D34 Secret: ")).trim();if(!n){console.error(`\u274C Secret \u4E0D\u80FD\u4E3A\u7A7A
92
92
  `);continue}if(process.stdout.write(`\x1B[1A\x1B[2K 2. \u8BF7\u7C98\u8D34 Secret: ${Z(n)}
@@ -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?Z(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(!Ye.includes(e))return console.error(`\u274C \u4E0D\u652F\u6301\u7684\u6E20\u9053\u7C7B\u578B: ${e}\uFF0C\u652F\u6301: ${Ye.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
- `))}};Ze.exports=ue});var tt=$((To,et)=>{var Ht=require("http"),pe=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
+ `))}};Ze.exports=ue});var tt=$((To,et)=>{var Kt=require("http"),pe=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>
@@ -276,7 +276,7 @@ client.connect();
276
276
  coder auth status # \u67E5\u770B\u767B\u5F55\u72B6\u6001
277
277
 
278
278
  \u83B7\u53D6 API Key: https://makecoder.com/my/apikeys
279
- `)}};st.exports=he});var at=$((jo,ct)=>{var fe=require("crypto"),{URL:Xt}=require("url"),ge=class{static generateSignature(e,t,o,n){try{let s=new Xt(e),r=Buffer.from(s.pathname),i=Buffer.from(r),a=t?typeof t=="string"?Buffer.from(t):Buffer.from(JSON.stringify(t)):Buffer.alloc(0),l=Buffer.concat([i,a,Buffer.from(n)]),d=fe.createHmac("sha256",o);return d.update(l),d.digest("hex")}catch(s){throw new Error(`Failed to generate signature: ${s.message}`)}}static validateSignature(e,t,o,n,s){return this.generateSignature(e,t,o,n)===s}static generateTimestamp(){return Date.now().toString()}static generateStrongPassword(e=16){let t="abcdefghijkmnpqrstuvwxyz",o="ABCDEFGHJKLMNPQRSTUVWXYZ",n="23456789",s="!@#$%^&*-_=+",r=t+o+n+s;e<8&&(e=8);let i=l=>l[fe.randomBytes(1)[0]%l.length],a=[i(t),i(o),i(n),i(s)];for(;a.length<e;)a.push(i(r));for(let l=a.length-1;l>0;l--){let d=fe.randomBytes(1)[0]%(l+1);[a[l],a[d]]=[a[d],a[l]]}return a.join("")}};ct.exports=ge});var ut=$((Lo,dt)=>{var Zt=require("https"),{URL:Qt}=require("url"),K=require("fs"),B=require("path"),eo=at(),to="https://makecoder.com/bigapis/auth/v1",oo="https://makecoder.com/bigapis/kbb2/v1",be=class{constructor(e){this.argParser=e||null}request(e,t,o,n,s){return new Promise((r,i)=>{let a=s||to,l=new Qt(`${a}${t}`),d={"Content-Type":"application/json",Authorization:`Bearer ${o}`},u=null;n!=null&&(u=JSON.stringify(n),d["Content-Length"]=Buffer.byteLength(u));let m={hostname:l.hostname,port:l.port||443,path:l.pathname+l.search,method:e,headers:d},p=Zt.request(m,f=>{let g="";f.on("data",y=>g+=y),f.on("end",()=>r({status:f.statusCode,body:g}))});p.on("error",i),u&&p.write(u),p.end()})}parseJson(e){try{return JSON.parse(e)}catch{return null}}exitCodeForStatus(e){return e===401?2:e===403?5:e===404?4:e===409?6:1}parseOutputFlags(e){let t={json:!1,quiet:!1,field:null},o=[];for(let n=0;n<e.length;n++){let s=e[n];if(s==="--json"){t.json=!0;continue}if(s==="--quiet"){t.quiet=!0;continue}if(s!=="--no-color"){if(s==="--field"){t.field=e[n+1],n++;continue}o.push(s)}}return{out:t,remaining:o}}async handle({teamSubcommand:e,teamArg:t,teamRemainingArgs:o,apikey:n}){if(!e||e==="--help"||e==="-h")return this.showHelp(),0;let s=n;if(!s)return console.error("\u274C 2: \u672A\u767B\u5F55\uFF0C\u8BF7\u5148\u8FD0\u884C coder auth login"),2;let r=o||[];return e==="list"||e==="ls"?await this.list(r,s):e==="current"?await this.current(r,s):e==="use"?await this.use(t,r,s):e==="info"?await this.info(t,r,s):e==="members"?await this.members(t,r,s):e==="member-get"?await this.memberGet(t,r,s):e==="search-member"?await this.searchMember(t,r,s):e==="member-create"?await this.memberCreate(t,r,s):e==="member-delete"?await this.memberDelete(t,r,s):e==="set-points"?await this.setPoints(t,r,s):(console.error(`\u274C 3: \u672A\u77E5\u5B50\u547D\u4EE4: ${e}`),this.showHelp(),3)}async list(e,t){let{out:o}=this.parseOutputFlags(e),s=`/team?constraints=${encodeURIComponent(JSON.stringify({filter_is_joined:!0}))}&page=1&size=200`,r;try{r=await this.request("GET",s,t)}catch(d){return console.error(`\u274C 1: \u7F51\u7EDC\u9519\u8BEF ${d.message}`),1}if(r.status!==200)return console.error(`\u274C ${this.exitCodeForStatus(r.status)}: HTTP ${r.status}`),r.body&&console.error(r.body),this.exitCodeForStatus(r.status);let i=this.parseJson(r.body);if(!i||!i.data)return console.error("\u274C 1: \u54CD\u5E94\u89E3\u6790\u5931\u8D25"),1;let a=i.data.items||[];if(o.json){let d={items:a,total:i.data.total??a.length};if(o.field){let u=D(d,o.field);process.stdout.write(A(u)+`
279
+ `)}};st.exports=he});var at=$((jo,ct)=>{var fe=require("crypto"),{URL:Xt}=require("url"),ge=class{static generateSignature(e,t,o,n){try{let s=new Xt(e),r=Buffer.from(s.pathname),i=Buffer.from(r),a=t?typeof t=="string"?Buffer.from(t):Buffer.from(JSON.stringify(t)):Buffer.alloc(0),l=Buffer.concat([i,a,Buffer.from(n)]),d=fe.createHmac("sha256",o);return d.update(l),d.digest("hex")}catch(s){throw new Error(`Failed to generate signature: ${s.message}`)}}static validateSignature(e,t,o,n,s){return this.generateSignature(e,t,o,n)===s}static generateTimestamp(){return Date.now().toString()}static generateStrongPassword(e=16){let t="abcdefghijkmnpqrstuvwxyz",o="ABCDEFGHJKLMNPQRSTUVWXYZ",n="23456789",s="!@#$%^&*-_=+",r=t+o+n+s;e<8&&(e=8);let i=l=>l[fe.randomBytes(1)[0]%l.length],a=[i(t),i(o),i(n),i(s)];for(;a.length<e;)a.push(i(r));for(let l=a.length-1;l>0;l--){let d=fe.randomBytes(1)[0]%(l+1);[a[l],a[d]]=[a[d],a[l]]}return a.join("")}};ct.exports=ge});var ut=$((Lo,dt)=>{var Zt=require("https"),{URL:Qt}=require("url"),H=require("fs"),B=require("path"),eo=at(),to="https://makecoder.com/bigapis/auth/v1",oo="https://makecoder.com/bigapis/kbb2/v1",be=class{constructor(e){this.argParser=e||null}request(e,t,o,n,s){return new Promise((r,i)=>{let a=s||to,l=new Qt(`${a}${t}`),d={"Content-Type":"application/json",Authorization:`Bearer ${o}`},u=null;n!=null&&(u=JSON.stringify(n),d["Content-Length"]=Buffer.byteLength(u));let m={hostname:l.hostname,port:l.port||443,path:l.pathname+l.search,method:e,headers:d},p=Zt.request(m,f=>{let g="";f.on("data",y=>g+=y),f.on("end",()=>r({status:f.statusCode,body:g}))});p.on("error",i),u&&p.write(u),p.end()})}parseJson(e){try{return JSON.parse(e)}catch{return null}}exitCodeForStatus(e){return e===401?2:e===403?5:e===404?4:e===409?6:1}parseOutputFlags(e){let t={json:!1,quiet:!1,field:null},o=[];for(let n=0;n<e.length;n++){let s=e[n];if(s==="--json"){t.json=!0;continue}if(s==="--quiet"){t.quiet=!0;continue}if(s!=="--no-color"){if(s==="--field"){t.field=e[n+1],n++;continue}o.push(s)}}return{out:t,remaining:o}}async handle({teamSubcommand:e,teamArg:t,teamRemainingArgs:o,apikey:n}){if(!e||e==="--help"||e==="-h")return this.showHelp(),0;let s=n;if(!s)return console.error("\u274C 2: \u672A\u767B\u5F55\uFF0C\u8BF7\u5148\u8FD0\u884C coder auth login"),2;let r=o||[];return e==="list"||e==="ls"?await this.list(r,s):e==="current"?await this.current(r,s):e==="use"?await this.use(t,r,s):e==="info"?await this.info(t,r,s):e==="members"?await this.members(t,r,s):e==="member-get"?await this.memberGet(t,r,s):e==="search-member"?await this.searchMember(t,r,s):e==="member-create"?await this.memberCreate(t,r,s):e==="member-delete"?await this.memberDelete(t,r,s):e==="set-points"?await this.setPoints(t,r,s):(console.error(`\u274C 3: \u672A\u77E5\u5B50\u547D\u4EE4: ${e}`),this.showHelp(),3)}async list(e,t){let{out:o}=this.parseOutputFlags(e),s=`/team?constraints=${encodeURIComponent(JSON.stringify({filter_is_joined:!0}))}&page=1&size=200`,r;try{r=await this.request("GET",s,t)}catch(d){return console.error(`\u274C 1: \u7F51\u7EDC\u9519\u8BEF ${d.message}`),1}if(r.status!==200)return console.error(`\u274C ${this.exitCodeForStatus(r.status)}: HTTP ${r.status}`),r.body&&console.error(r.body),this.exitCodeForStatus(r.status);let i=this.parseJson(r.body);if(!i||!i.data)return console.error("\u274C 1: \u54CD\u5E94\u89E3\u6790\u5931\u8D25"),1;let a=i.data.items||[];if(o.json){let d={items:a,total:i.data.total??a.length};if(o.field){let u=D(d,o.field);process.stdout.write(A(u)+`
280
280
  `)}else process.stdout.write(JSON.stringify(d,null,2)+`
281
281
  `);return 0}if(o.quiet){for(let d of a)console.log(d.id);return 0}if(!a.length)return console.log("\uFF08\u4F60\u8FD8\u6CA1\u6709\u52A0\u5165\u4EFB\u4F55\u56E2\u961F\uFF09"),0;let l=a.map(d=>({id:d.id||"",name:d.name||"",members:(d.members_count??d.member_count??"")+"",points:d.points!=null?String(d.points):""}));return ye(["id","name","members","points"],l),0}resolveTeamId(e,t){if(e&&!e.startsWith("--"))return e;let o=t.indexOf("--team");if(o>=0&&t[o+1])return t[o+1];let n=this.argParser?this.argParser.getTeam():null;return n&&n.id?n.id:null}async fetchTeam(e,t){let n=`/team?constraints=${encodeURIComponent(JSON.stringify({id__in:[e]}))}`,s=await this.request("GET",n,t);if(s.status!==200)return{error:{code:this.exitCodeForStatus(s.status),status:s.status,body:s.body}};let r=this.parseJson(s.body),i=r&&r.data&&r.data.items||[];return i.length?{team:i[0]}:{error:{code:4,status:404,body:`team ${e} not found`}}}filterMembersByType(e,t){return t?e.filter(o=>o.user_type===t):e}async info(e,t,o){let{out:n}=this.parseOutputFlags(t),s=this.resolveTeamId(e,t);if(!s)return console.error("\u274C 3: \u672A\u6307\u5B9A teamId \u4E14\u65E0\u9ED8\u8BA4\u56E2\u961F\u3002\u8FD0\u884C 'coder team use <id>' \u6216\u5E26 [teamId] \u53C2\u6570"),3;let r;try{r=await this.fetchTeam(s,o)}catch(u){return console.error(`\u274C 1: \u7F51\u7EDC\u9519\u8BEF ${u.message}`),1}if(r.error)return console.error(`\u274C ${r.error.code}: HTTP ${r.error.status}`),r.error.body&&console.error(r.error.body),r.error.code;let i=r.team,a=Array.isArray(i.members)?i.members:[],l=a.filter(u=>u.user_type==="ai").length,d=a.filter(u=>u.user_type==="human").length;if(n.json){let u={id:i.id,name:i.name,description:i.description||"",points:i.points,points_expire_at:i.points_expire_at||null,is_active:!!i.is_active,members_total:a.length,members_ai:l,members_human:d};return n.field?process.stdout.write(A(D(u,n.field))+`
282
282
  `):process.stdout.write(JSON.stringify(u,null,2)+`
@@ -286,13 +286,13 @@ client.connect();
286
286
  `):process.stdout.write(JSON.stringify(m,null,2)+`
287
287
  `),0):n.quiet?(console.log(m.user_id||m.id),0):(console.log(`username: ${m.username||""}`),console.log(`user_id: ${m.user_id||""}`),console.log(`type: ${m.user_type||""}`),console.log(`role: ${m.role||""}`),console.log(`status: ${m.status||""}`),console.log(`points: ${m.points==null?"\u221E":m.points}`),console.log(`joined_at: ${m.created_at||""}`),m.im_bindings&&m.im_bindings.length&&console.log(`im_bindings: ${m.im_bindings.map(p=>p.channel).join(",")}`),0):(console.error(`\u274C 4: \u6210\u5458 '${i}' \u4E0D\u5728\u56E2\u961F '${d.team.name}' \u4E2D`),4)}async searchMember(e,t,o){let{out:n,remaining:s}=this.parseOutputFlags(t),r=[],i=null;for(let h=0;h<s.length;h++){if(s[h]==="--team"){h++;continue}if(s[h]==="--type"){i=s[h+1],h++;continue}r.push(s[h])}let a=r[0];if(!a)return console.error("\u274C 3: \u7F3A\u5C11 keyword \u53C2\u6570\u3002\u7528\u6CD5: coder team search-member <keyword> [teamId]"),3;let d=r[1]||this.resolveTeamId(void 0,s);if(!d)return console.error("\u274C 3: \u672A\u6307\u5B9A teamId \u4E14\u65E0\u9ED8\u8BA4\u56E2\u961F"),3;if(i&&i!=="human"&&i!=="ai")return console.error(`\u274C 3: --type \u4EC5\u652F\u6301 human \u6216 ai\uFF0C\u6536\u5230 '${i}'`),3;let u;try{u=await this.fetchTeam(d,o)}catch(h){return console.error(`\u274C 1: \u7F51\u7EDC\u9519\u8BEF ${h.message}`),1}if(u.error)return console.error(`\u274C ${u.error.code}: HTTP ${u.error.status}`),u.error.body&&console.error(u.error.body),u.error.code;let m=Array.isArray(u.team.members)?u.team.members:[],p=this.filterMembersByType(m,i),f=a.toLowerCase(),g=p.filter(h=>{let I=(h.username||"").toLowerCase(),b=(h.user_id||"").toLowerCase(),S=(h.id||"").toLowerCase();return I.includes(f)||b.includes(f)||S.includes(f)});if(n.json){let h={team_id:u.team.id,keyword:a,items:g,total:g.length};return n.field?process.stdout.write(A(D(h,n.field))+`
288
288
  `):process.stdout.write(JSON.stringify(h,null,2)+`
289
- `),0}if(n.quiet){for(let h of g)console.log(h.user_id||h.id||"");return 0}if(!g.length)return console.log(`\uFF08\u672A\u5339\u914D\u5230 '${a}'\uFF09`),0;let y=g.map(h=>({username:h.username||"",user_id:h.user_id||"",type:h.user_type||"",role:h.role||""}));return ye(["username","user_id","type","role"],y),0}parseMemberCreateFlags(e){let t=[],o={type:"human",password:null,phone:null,points:null,team:null,saveTo:null};for(let n=0;n<e.length;n++){let s=e[n];if(s==="--type"){o.type=e[++n];continue}if(s==="--password"){o.password=e[++n];continue}if(s==="--phone"){o.phone=e[++n];continue}if(s==="--points"){o.points=e[++n];continue}if(s==="--team"){o.team=e[++n];continue}if(s==="--save-to"){o.saveTo=e[++n];continue}t.push(s)}return o.type!=="human"&&o.type!=="ai"?{error:`--type \u4EC5\u652F\u6301 human \u6216 ai\uFF0C\u6536\u5230 '${o.type}'`}:{remaining:t,opts:o}}isInsideGitRepo(e){let t=B.resolve(e);for((!K.existsSync(t)||!K.statSync(t).isDirectory())&&(t=B.dirname(t));t&&t!==B.dirname(t);){if(K.existsSync(B.join(t,".git")))return!0;t=B.dirname(t)}return!1}async memberCreate(e,t,o){let{out:n,remaining:s}=this.parseOutputFlags(t),r=this.parseMemberCreateFlags(s);if(r.error)return console.error(`\u274C 3: ${r.error}`),3;let{remaining:i,opts:a}=r,l=i[0];if(!l)return console.error("\u274C 3: \u7F3A\u5C11 username \u53C2\u6570\u3002\u7528\u6CD5: coder team member-create <username> [...]"),3;let d=a.team||this.resolveTeamId(void 0,[]);if(!d)return console.error("\u274C 3: \u672A\u6307\u5B9A --team \u4E14\u65E0\u9ED8\u8BA4\u56E2\u961F\u3002\u8FD0\u884C 'coder team use <id>' \u6216\u52A0 --team <id>"),3;if(a.type==="human"&&!a.phone)return console.error("\u274C 3: \u521B\u5EFA human \u6210\u5458\u5FC5\u987B\u63D0\u4F9B --phone <phone>"),3;if(a.saveTo){let b=B.resolve(a.saveTo);if(this.isInsideGitRepo(b))return console.error(`\u274C 3: --save-to \u8DEF\u5F84\u5728 git \u4ED3\u5E93\u5185\uFF08${b}\uFF09\uFF0C\u62D2\u7EDD\u5199\u5165\u907F\u514D\u8BEF\u63D0\u4EA4`),3}let u=a.password||eo.generateStrongPassword(16),m=!a.password,p=null;if(a.points!==null&&a.points!==void 0){let b=Number(a.points);if(!Number.isFinite(b))return console.error(`\u274C 3: --points \u5E94\u4E3A\u6570\u5B57\uFF0C\u6536\u5230 '${a.points}'`),3;p=b}let f={payload:{username:l,password:u,phone:a.phone||null,team_id:d,points:p,user_type:a.type},auto_login:!1,auth_name:"UserPass"},g;try{g=await this.request("POST","/users",o,f)}catch(b){return console.error(`\u274C 1: \u7F51\u7EDC\u9519\u8BEF ${b.message}`),1}if(g.status<200||g.status>=300)return console.error(`\u274C ${this.exitCodeForStatus(g.status)}: HTTP ${g.status}`),g.body&&console.error(g.body),this.exitCodeForStatus(g.status);let y=this.parseJson(g.body),h=null;if(a.saveTo){let b=B.resolve(a.saveTo),S=`# Coder team member credentials
289
+ `),0}if(n.quiet){for(let h of g)console.log(h.user_id||h.id||"");return 0}if(!g.length)return console.log(`\uFF08\u672A\u5339\u914D\u5230 '${a}'\uFF09`),0;let y=g.map(h=>({username:h.username||"",user_id:h.user_id||"",type:h.user_type||"",role:h.role||""}));return ye(["username","user_id","type","role"],y),0}parseMemberCreateFlags(e){let t=[],o={type:"human",password:null,phone:null,points:null,team:null,saveTo:null};for(let n=0;n<e.length;n++){let s=e[n];if(s==="--type"){o.type=e[++n];continue}if(s==="--password"){o.password=e[++n];continue}if(s==="--phone"){o.phone=e[++n];continue}if(s==="--points"){o.points=e[++n];continue}if(s==="--team"){o.team=e[++n];continue}if(s==="--save-to"){o.saveTo=e[++n];continue}t.push(s)}return o.type!=="human"&&o.type!=="ai"?{error:`--type \u4EC5\u652F\u6301 human \u6216 ai\uFF0C\u6536\u5230 '${o.type}'`}:{remaining:t,opts:o}}isInsideGitRepo(e){let t=B.resolve(e);for((!H.existsSync(t)||!H.statSync(t).isDirectory())&&(t=B.dirname(t));t&&t!==B.dirname(t);){if(H.existsSync(B.join(t,".git")))return!0;t=B.dirname(t)}return!1}async memberCreate(e,t,o){let{out:n,remaining:s}=this.parseOutputFlags(t),r=this.parseMemberCreateFlags(s);if(r.error)return console.error(`\u274C 3: ${r.error}`),3;let{remaining:i,opts:a}=r,l=i[0];if(!l)return console.error("\u274C 3: \u7F3A\u5C11 username \u53C2\u6570\u3002\u7528\u6CD5: coder team member-create <username> [...]"),3;let d=a.team||this.resolveTeamId(void 0,[]);if(!d)return console.error("\u274C 3: \u672A\u6307\u5B9A --team \u4E14\u65E0\u9ED8\u8BA4\u56E2\u961F\u3002\u8FD0\u884C 'coder team use <id>' \u6216\u52A0 --team <id>"),3;if(a.type==="human"&&!a.phone)return console.error("\u274C 3: \u521B\u5EFA human \u6210\u5458\u5FC5\u987B\u63D0\u4F9B --phone <phone>"),3;if(a.saveTo){let b=B.resolve(a.saveTo);if(this.isInsideGitRepo(b))return console.error(`\u274C 3: --save-to \u8DEF\u5F84\u5728 git \u4ED3\u5E93\u5185\uFF08${b}\uFF09\uFF0C\u62D2\u7EDD\u5199\u5165\u907F\u514D\u8BEF\u63D0\u4EA4`),3}let u=a.password||eo.generateStrongPassword(16),m=!a.password,p=null;if(a.points!==null&&a.points!==void 0){let b=Number(a.points);if(!Number.isFinite(b))return console.error(`\u274C 3: --points \u5E94\u4E3A\u6570\u5B57\uFF0C\u6536\u5230 '${a.points}'`),3;p=b}let f={payload:{username:l,password:u,phone:a.phone||null,team_id:d,points:p,user_type:a.type},auto_login:!1,auth_name:"UserPass"},g;try{g=await this.request("POST","/users",o,f)}catch(b){return console.error(`\u274C 1: \u7F51\u7EDC\u9519\u8BEF ${b.message}`),1}if(g.status<200||g.status>=300)return console.error(`\u274C ${this.exitCodeForStatus(g.status)}: HTTP ${g.status}`),g.body&&console.error(g.body),this.exitCodeForStatus(g.status);let y=this.parseJson(g.body),h=null;if(a.saveTo){let b=B.resolve(a.saveTo),S=`# Coder team member credentials
290
290
  # Created: ${new Date().toISOString()}
291
291
  username: ${l}
292
292
  password: ${u}
293
293
  team_id: ${d}
294
294
  type: ${a.type}
295
- `;try{K.writeFileSync(b,S,{mode:384});try{K.chmodSync(b,384)}catch{}h=b}catch(x){console.error(`\u26A0\uFE0F \u4FDD\u5B58\u51ED\u636E\u5931\u8D25: ${x.message}`)}}let I={username:l,password:u,team_id:d,user_type:a.type,saved_to:h,response:y&&y.data?y.data:y};return n.json?(n.field?process.stdout.write(A(D(I,n.field))+`
295
+ `;try{H.writeFileSync(b,S,{mode:384});try{H.chmodSync(b,384)}catch{}h=b}catch(x){console.error(`\u26A0\uFE0F \u4FDD\u5B58\u51ED\u636E\u5931\u8D25: ${x.message}`)}}let I={username:l,password:u,team_id:d,user_type:a.type,saved_to:h,response:y&&y.data?y.data:y};return n.json?(n.field?process.stdout.write(A(D(I,n.field))+`
296
296
  `):process.stdout.write(JSON.stringify(I,null,2)+`
297
297
  `),0):n.quiet?(console.log(l),0):(console.log("\u2705 \u6210\u5458\u521B\u5EFA\u6210\u529F"),console.log(`username: ${l}`),console.log(`password: ${u} ${m?"(\u968F\u673A\u751F\u6210\uFF0C\u8BF7\u59A5\u5584\u4FDD\u7BA1)":""}`),console.log(`team_id: ${d}`),console.log(`type: ${a.type}`),console.log(h?`\u26A0\uFE0F \u51ED\u636E\u5DF2\u4FDD\u5B58\u5230 ${h} (mode 0600)\uFF0C\u8BF7\u59A5\u5584\u4FDD\u7BA1\uFF0C\u5EFA\u8BAE\u52A0\u5165 .gitignore`:"\u26A0\uFE0F \u4EE5\u4E0A\u51ED\u636E\u4EC5\u663E\u793A\u4E00\u6B21\uFF0C\u672A --save-to \u65F6\u8BF7\u7ACB\u5373\u8BB0\u5F55"),0)}async memberDelete(e,t,o){let{out:n,remaining:s}=this.parseOutputFlags(t),r=[],i=!1,a=null;for(let g=0;g<s.length;g++){if(s[g]==="--yes"||s[g]==="-y"){i=!0;continue}if(s[g]==="--team"){a=s[++g];continue}r.push(s[g])}let l=r[0];if(!l)return console.error("\u274C 3: \u7F3A\u5C11 userId \u53C2\u6570\u3002\u7528\u6CD5: coder team member-delete <userId> [--yes]"),3;let d=a||r[1]||this.resolveTeamId(void 0,[]);if(!d)return console.error("\u274C 3: \u672A\u6307\u5B9A --team \u4E14\u65E0\u9ED8\u8BA4\u56E2\u961F"),3;let u;try{u=await this.fetchTeam(d,o)}catch(g){return console.error(`\u274C 1: \u7F51\u7EDC\u9519\u8BEF ${g.message}`),1}if(u.error)return console.error(`\u274C ${u.error.code}: HTTP ${u.error.status}`),u.error.body&&console.error(u.error.body),u.error.code;let p=(Array.isArray(u.team.members)?u.team.members:[]).find(g=>g.user_id===l||g.id===l||g.username===l);if(!p)return console.error(`\u274C 4: \u6210\u5458 '${l}' \u4E0D\u5728\u56E2\u961F '${u.team.name}' \u4E2D`),4;if(!i){let g="\u9AD8\u5F71\u54CD\u64CD\u4F5C\uFF0C\u5FC5\u987B\u52A0 --yes \u624D\u4F1A\u6267\u884C";return n.json?process.stdout.write(JSON.stringify({method:"DELETE",path:`/team/${d}/members/${p.id}`,target:{username:p.username,user_id:p.user_id,role:p.role},note:g},null,2)+`
298
298
  `):(console.log(`\u5C06\u5220\u9664\u6210\u5458 ${p.username} (user_id=${p.user_id}, role=${p.role})`),console.log(`\u4ECE\u56E2\u961F: ${u.team.name} (${d})`),console.log(`endpoint: DELETE /team/${d}/members/${p.id}`),console.log(`\u26A0\uFE0F ${g}`)),10}let f;try{f=await this.request("DELETE",`/team/${d}/members/${p.id}`,o)}catch(g){return console.error(`\u274C 1: \u7F51\u7EDC\u9519\u8BEF ${g.message}`),1}return f.status<200||f.status>=300?(console.error(`\u274C ${this.exitCodeForStatus(f.status)}: HTTP ${f.status}`),f.body&&console.error(f.body),this.exitCodeForStatus(f.status)):n.json?(process.stdout.write(JSON.stringify({deleted:!0,username:p.username,user_id:p.user_id,team_id:d},null,2)+`
@@ -302,7 +302,7 @@ 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 A(c){return c==null?"":typeof c=="string"?c:typeof c=="number"||typeof c=="boolean"?String(c):JSON.stringify(c)}function ye(c,e){let t=c.map(n=>Math.max(n.length,...e.map(s=>lt(String(s[n]??""))))),o=(n,s)=>n+" ".repeat(Math.max(0,s-lt(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 lt(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}dt.exports=be});var ht=$((Ro,mt)=>{var No=require("path"),no=Se(),pt=Oe(),ro=Ae(),so=qe(),io=je(),co=Re(),ao=Je(),lo=Ke(),uo=ze(),po=Qe(),mo=it(),ho=ut(),{isPrintMode:Uo}=U(),Ie=class{constructor(){this.argParser=new no,this.claudeLauncher=this._createClaudeLauncher(),this.geminiLauncher=new so,this.codexLauncher=new io,this.vscodeExtensionService=new co,this.publishService=new ao,this.skillsService=new lo,this.wikiService=new uo(this.argParser),this.channelService=new po,this.authCommandService=new mo(this.argParser),this.teamService=new ho(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 pt;try{let t=new ro,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 pt}}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...
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 A(c){return c==null?"":typeof c=="string"?c:typeof c=="number"||typeof c=="boolean"?String(c):JSON.stringify(c)}function ye(c,e){let t=c.map(n=>Math.max(n.length,...e.map(s=>lt(String(s[n]??""))))),o=(n,s)=>n+" ".repeat(Math.max(0,s-lt(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 lt(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}dt.exports=be});var ht=$((Ro,mt)=>{var No=require("path"),no=Se(),pt=Oe(),ro=Ae(),so=qe(),io=je(),co=Re(),ao=Je(),lo=He(),uo=ze(),po=Qe(),mo=it(),ho=ut(),{isPrintMode:Uo}=U(),Ie=class{constructor(){this.argParser=new no,this.claudeLauncher=this._createClaudeLauncher(),this.geminiLauncher=new so,this.codexLauncher=new io,this.vscodeExtensionService=new co,this.publishService=new ao,this.skillsService=new lo,this.wikiService=new uo(this.argParser),this.channelService=new po,this.authCommandService=new mo(this.argParser),this.teamService=new ho(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 pt;try{let t=new ro,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 pt}}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
306
  `);try{return e("npm install -g makecoder@latest",{stdio:"inherit"}),console.log(`
307
307
  \u2705 \u5347\u7EA7\u6210\u529F`),0}catch(o){return console.error(`
308
308
  \u274C \u5347\u7EA7\u5931\u8D25:`,o.message),1}}showVersion(){let e=N();console.log(`coder version: ${e.version}`)}async shutdown(){console.log(`
@@ -23,13 +23,13 @@ var PP4=Object.create;var{getPrototypeOf:WP4,defineProperty:_2H,getOwnPropertyNa
23
23
  Object.assign(A, {
24
24
  post(...args) {
25
25
  const [url, payload, ...remainArgs] = args;
26
- const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.56' + '&session_id=' + S_() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
26
+ const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.57' + '&session_id=' + S_() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
27
27
  if (process.env.CODER_APIKEY) {
28
28
  const headerValues = payload.headers.values;
29
29
  headerValues.set('AUTHORIZATION', `Bearer ${process.env.CODER_APIKEY}`)
30
30
  }
31
31
 
32
- payload.headers.values.set('X-Coder-Version', '4.0.56');
32
+ payload.headers.values.set('X-Coder-Version', '4.0.57');
33
33
  payload.headers.values.set('X-Coder-Platform', process.platform);
34
34
  payload.headers.values.set('X-Coder-Arch', process.arch);
35
35
 
@@ -23,13 +23,13 @@ var WPK=Object.create;var{getPrototypeOf:GPK,defineProperty:_2H,getOwnPropertyNa
23
23
  Object.assign(A, {
24
24
  post(...args) {
25
25
  const [url, payload, ...remainArgs] = args;
26
- const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.56' + '&session_id=' + S6() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
26
+ const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.57' + '&session_id=' + S6() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
27
27
  if (process.env.CODER_APIKEY) {
28
28
  const headerValues = payload.headers.values;
29
29
  headerValues.set('AUTHORIZATION', `Bearer ${process.env.CODER_APIKEY}`)
30
30
  }
31
31
 
32
- payload.headers.values.set('X-Coder-Version', '4.0.56');
32
+ payload.headers.values.set('X-Coder-Version', '4.0.57');
33
33
  payload.headers.values.set('X-Coder-Platform', process.platform);
34
34
  payload.headers.values.set('X-Coder-Arch', process.arch);
35
35
 
@@ -23,13 +23,13 @@ var MP9=Object.create;var{getPrototypeOf:jP9,defineProperty:qWH,getOwnPropertyNa
23
23
  Object.assign(A, {
24
24
  post(...args) {
25
25
  const [url, payload, ...remainArgs] = args;
26
- const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.56' + '&session_id=' + R$() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
26
+ const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.57' + '&session_id=' + R$() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
27
27
  if (process.env.CODER_APIKEY) {
28
28
  const headerValues = payload.headers.values;
29
29
  headerValues.set('AUTHORIZATION', `Bearer ${process.env.CODER_APIKEY}`)
30
30
  }
31
31
 
32
- payload.headers.values.set('X-Coder-Version', '4.0.56');
32
+ payload.headers.values.set('X-Coder-Version', '4.0.57');
33
33
  payload.headers.values.set('X-Coder-Platform', process.platform);
34
34
  payload.headers.values.set('X-Coder-Arch', process.arch);
35
35
 
@@ -23,13 +23,13 @@ var PJ_=Object.create;var{getPrototypeOf:WJ_,defineProperty:K2H,getOwnPropertyNa
23
23
  Object.assign(A, {
24
24
  post(...args) {
25
25
  const [url, payload, ...remainArgs] = args;
26
- const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.56' + '&session_id=' + R8() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
26
+ const patchedUrl = url + (url.includes('?') ? '&' : '?') + 'app=codev-cli' + '&version=4.0.57' + '&session_id=' + R8() + (process.env.SPACE_ID ? '&space_id=' + process.env.SPACE_ID : '');
27
27
  if (process.env.CODER_APIKEY) {
28
28
  const headerValues = payload.headers.values;
29
29
  headerValues.set('AUTHORIZATION', `Bearer ${process.env.CODER_APIKEY}`)
30
30
  }
31
31
 
32
- payload.headers.values.set('X-Coder-Version', '4.0.56');
32
+ payload.headers.values.set('X-Coder-Version', '4.0.57');
33
33
  payload.headers.values.set('X-Coder-Platform', process.platform);
34
34
  payload.headers.values.set('X-Coder-Arch', process.arch);
35
35
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makecoder",
3
- "version": "4.0.56",
3
+ "version": "4.0.57",
4
4
  "description": "MakeCoder: Unified AI agent CLI tool integrating Claude Code, Codex and Gemini CLI",
5
5
  "main": "./dist/coder.js",
6
6
  "bin": {
@@ -36,9 +36,9 @@
36
36
  },
37
37
  "optionalDependencies": {
38
38
  "bun": ">=1.3.12",
39
- "makecoder-codex-darwin-arm64": "4.0.56",
40
- "makecoder-codex-linux-x64": "4.0.56",
41
- "makecoder-codex-win32-x64": "4.0.56"
39
+ "makecoder-codex-darwin-arm64": "4.0.57",
40
+ "makecoder-codex-linux-x64": "4.0.57",
41
+ "makecoder-codex-win32-x64": "4.0.57"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=20.0.0"
@@ -1,153 +0,0 @@
1
- # Deep Analysis and Problem Solving Mode
2
-
3
- Deep analysis and problem solving mode
4
-
5
- ## Instructions
6
-
7
- 1. **Initialize Ultra Think Mode**
8
- - Acknowledge the request for enhanced analytical thinking
9
- - Set context for deep, systematic reasoning
10
- - Prepare to explore the problem space comprehensively
11
-
12
- 2. **Parse the Problem or Question**
13
- - Extract the core challenge from: **$ARGUMENTS**
14
- - Identify all stakeholders and constraints
15
- - Recognize implicit requirements and hidden complexities
16
- - Question assumptions and surface unknowns
17
-
18
- 3. **Multi-Dimensional Analysis**
19
- Approach the problem from multiple angles:
20
-
21
- ### Technical Perspective
22
- - Analyze technical feasibility and constraints
23
- - Consider scalability, performance, and maintainability
24
- - Evaluate security implications
25
- - Assess technical debt and future-proofing
26
-
27
- ### Business Perspective
28
- - Understand business value and ROI
29
- - Consider time-to-market pressures
30
- - Evaluate competitive advantages
31
- - Assess risk vs. reward trade-offs
32
-
33
- ### User Perspective
34
- - Analyze user needs and pain points
35
- - Consider usability and accessibility
36
- - Evaluate user experience implications
37
- - Think about edge cases and user journeys
38
-
39
- ### System Perspective
40
- - Consider system-wide impacts
41
- - Analyze integration points
42
- - Evaluate dependencies and coupling
43
- - Think about emergent behaviors
44
-
45
- 4. **Generate Multiple Solutions**
46
- - Brainstorm at least 3-5 different approaches
47
- - For each approach, consider:
48
- - Pros and cons
49
- - Implementation complexity
50
- - Resource requirements
51
- - Potential risks
52
- - Long-term implications
53
- - Include both conventional and creative solutions
54
- - Consider hybrid approaches
55
-
56
- 5. **Deep Dive Analysis**
57
- For the most promising solutions:
58
- - Create detailed implementation plans
59
- - Identify potential pitfalls and mitigation strategies
60
- - Consider phased approaches and MVPs
61
- - Analyze second and third-order effects
62
- - Think through failure modes and recovery
63
-
64
- 6. **Cross-Domain Thinking**
65
- - Draw parallels from other industries or domains
66
- - Apply design patterns from different contexts
67
- - Consider biological or natural system analogies
68
- - Look for innovative combinations of existing solutions
69
-
70
- 7. **Challenge and Refine**
71
- - Play devil's advocate with each solution
72
- - Identify weaknesses and blind spots
73
- - Consider "what if" scenarios
74
- - Stress-test assumptions
75
- - Look for unintended consequences
76
-
77
- 8. **Synthesize Insights**
78
- - Combine insights from all perspectives
79
- - Identify key decision factors
80
- - Highlight critical trade-offs
81
- - Summarize innovative discoveries
82
- - Present a nuanced view of the problem space
83
-
84
- 9. **Provide Structured Recommendations**
85
- Present findings in a clear structure:
86
- ```
87
- ## Problem Analysis
88
- - Core challenge
89
- - Key constraints
90
- - Critical success factors
91
-
92
- ## Solution Options
93
- ### Option 1: [Name]
94
- - Description
95
- - Pros/Cons
96
- - Implementation approach
97
- - Risk assessment
98
-
99
- ### Option 2: [Name]
100
- [Similar structure]
101
-
102
- ## Recommendation
103
- - Recommended approach
104
- - Rationale
105
- - Implementation roadmap
106
- - Success metrics
107
- - Risk mitigation plan
108
-
109
- ## Alternative Perspectives
110
- - Contrarian view
111
- - Future considerations
112
- - Areas for further research
113
- ```
114
-
115
- 10. **Meta-Analysis**
116
- - Reflect on the thinking process itself
117
- - Identify areas of uncertainty
118
- - Acknowledge biases or limitations
119
- - Suggest additional expertise needed
120
- - Provide confidence levels for recommendations
121
-
122
- ## Usage Examples
123
-
124
- ```bash
125
- # Architectural decision
126
- /project:ultra-think Should we migrate to microservices or improve our monolith?
127
-
128
- # Complex problem solving
129
- /project:ultra-think How do we scale our system to handle 10x traffic while reducing costs?
130
-
131
- # Strategic planning
132
- /project:ultra-think What technology stack should we choose for our next-gen platform?
133
-
134
- # Design challenge
135
- /project:ultra-think How can we improve our API to be more developer-friendly while maintaining backward compatibility?
136
- ```
137
-
138
- ## Key Principles
139
-
140
- - **First Principles Thinking**: Break down to fundamental truths
141
- - **Systems Thinking**: Consider interconnections and feedback loops
142
- - **Probabilistic Thinking**: Work with uncertainties and ranges
143
- - **Inversion**: Consider what to avoid, not just what to do
144
- - **Second-Order Thinking**: Consider consequences of consequences
145
-
146
- ## Output Expectations
147
-
148
- - Comprehensive analysis (typically 2-4 pages of insights)
149
- - Multiple viable solutions with trade-offs
150
- - Clear reasoning chains
151
- - Acknowledgment of uncertainties
152
- - Actionable recommendations
153
- - Novel insights or perspectives
@@ -1,80 +0,0 @@
1
- # Generate API Documentation
2
-
3
- Auto-generate API reference documentation
4
-
5
- ## Instructions
6
-
7
- 1. **API Documentation Strategy Analysis**
8
- - Analyze current API structure and endpoints
9
- - Identify documentation requirements (REST, GraphQL, gRPC, etc.)
10
- - Assess existing code annotations and documentation
11
- - Determine documentation output formats and hosting requirements
12
- - Plan documentation automation and maintenance strategy
13
-
14
- 2. **Documentation Tool Selection**
15
- - Choose appropriate API documentation tools:
16
- - **OpenAPI/Swagger**: REST API documentation with Swagger UI
17
- - **Redoc**: Modern OpenAPI documentation renderer
18
- - **GraphQL**: GraphiQL, Apollo Studio, GraphQL Playground
19
- - **Postman**: API documentation with collections
20
- - **Insomnia**: API documentation and testing
21
- - **API Blueprint**: Markdown-based API documentation
22
- - **JSDoc/TSDoc**: Code-first documentation generation
23
- - Consider factors: API type, team workflow, hosting, interactivity
24
-
25
- 3. **Code Annotation and Schema Definition**
26
- - Add comprehensive code annotations for API endpoints
27
- - Define request/response schemas and data models
28
- - Add parameter descriptions and validation rules
29
- - Document authentication and authorization requirements
30
- - Add example requests and responses
31
-
32
- 4. **API Specification Generation**
33
- - Set up automated API specification generation from code
34
- - Configure OpenAPI/Swagger specification generation
35
- - Set up schema validation and consistency checking
36
- - Configure API versioning and changelog generation
37
- - Set up specification file management and version control
38
-
39
- 5. **Interactive Documentation Setup**
40
- - Configure interactive API documentation with try-it-out functionality
41
- - Set up API testing and example execution
42
- - Configure authentication handling in documentation
43
- - Set up request/response validation and examples
44
- - Configure API endpoint categorization and organization
45
-
46
- 6. **Documentation Content Enhancement**
47
- - Add comprehensive API guides and tutorials
48
- - Create authentication and authorization documentation
49
- - Add error handling and status code documentation
50
- - Create SDK and client library documentation
51
- - Add rate limiting and usage guidelines
52
-
53
- 7. **Documentation Hosting and Deployment**
54
- - Set up documentation hosting and deployment
55
- - Configure documentation website generation and styling
56
- - Set up custom domain and SSL configuration
57
- - Configure documentation search and navigation
58
- - Set up documentation analytics and usage tracking
59
-
60
- 8. **Automation and CI/CD Integration**
61
- - Configure automated documentation generation in CI/CD pipeline
62
- - Set up documentation deployment automation
63
- - Configure documentation validation and quality checks
64
- - Set up documentation change detection and notifications
65
- - Configure documentation testing and link validation
66
-
67
- 9. **Multi-format Documentation Generation**
68
- - Generate documentation in multiple formats (HTML, PDF, Markdown)
69
- - Set up downloadable documentation packages
70
- - Configure offline documentation access
71
- - Set up documentation API for programmatic access
72
- - Configure documentation syndication and distribution
73
-
74
- 10. **Maintenance and Quality Assurance**
75
- - Set up documentation quality monitoring and validation
76
- - Configure documentation feedback and improvement workflows
77
- - Set up documentation analytics and usage metrics
78
- - Create documentation maintenance procedures and guidelines
79
- - Train team on documentation best practices and tools
80
- - Set up documentation review and approval processes
@@ -1,63 +0,0 @@
1
- # Commit
2
-
3
- Create well-formatted commits with conventional commit messages and emojis.
4
-
5
- ## Features:
6
-
7
- - Runs pre-commit checks by default (lint, build, generate docs)
8
- - Automatically stages files if none are staged
9
- - Uses conventional commit format with descriptive emojis
10
- - Suggests splitting commits for different concerns
11
- - Maintain good submission formatting, do not include invisible characters in submissions, use utf-8 encoding for submissions
12
- - NEVER include ANSI color codes or escape sequences in commit messages
13
- - Do NOT add "🤖 Generated with [Claude Code]" or "Co-Authored-By: Claude" signatures to commit messages
14
-
15
- ## Usage:
16
-
17
- - `/commit` - Standard commit with pre-commit checks
18
- - `/commit --no-verify` - Skip pre-commit checks
19
-
20
- ## Commit Types:
21
-
22
- | Emoji | Devmoji Code | Description |
23
- | ---------------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------- |
24
- | :sparkles: | `:feat:` | **feat:** a new feature |
25
- | :bug: | `:fix:` | **fix:** a bug fix |
26
- | :books: | `:docs:` | **docs:** documentation only changes |
27
- | :art: | `:style:` | **style:** changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) |
28
- | :recycle: | `:refactor:` | **refactor:** a code change that neither fixes a bug nor adds a feature |
29
- | :zap: | `:perf:` | **perf:** a code change that improves performance |
30
- | :rotating_light: | `:test:` | **test:** adding missing or correcting existing tests |
31
- | :wrench: | `:chore:` | **chore:** changes to the build process or auxiliary tools and libraries such as documentation generation |
32
- | :rocket: | `:chore-release:` | **chore(release):** code deployment or publishing to external repositories |
33
- | :link: | `:chore-deps:` | **chore(deps):** add or delete dependencies |
34
- | :package: | `:build:` | **build:** changes related to build processes |
35
- | :construction_worker: | `:ci:` | **ci:** updates to the continuous integration system |
36
- | :rocket: | `:release:` | code deployment or publishing to external repositories |
37
- | :lock: | `:security:` | Fixing security issues. |
38
- | :globe_with_meridians: | `:i18n:` | Internationalization and localization. |
39
- | :boom: | `:breaking:` | Introducing breaking changes. |
40
- | :gear: | `:config:` | Changing configuration files. |
41
- | :heavy_plus_sign: | `:add:` | add something |
42
- | :heavy_minus_sign: | `:remove:` | remove something |
43
-
44
- ## Process:
45
-
46
- 1. Check for staged changes (`git status`)
47
- 2. If no staged changes, review and stage appropriate files
48
- 3. Run pre-commit checks (unless --no-verify)
49
- 4. Analyze changes to determine commit type
50
- 5. Generate descriptive commit message (plain text only, no color codes)
51
- 6. Include scope if applicable: `type(scope): description`
52
- 7. Add body for complex changes explaining why
53
- 8. Execute commit with clean message formatting
54
-
55
- ## Best Practices:
56
-
57
- - Keep commits atomic and focused
58
- - Write in imperative mood ("Add feature" not "Added feature")
59
- - Explain why, not just what
60
- - Reference issues/PRs when relevant
61
- - Split unrelated changes into separate commits
62
- - Use clean, plain text commit messages without color codes or signatures
63
- - Prefer emoji codes (:gear:) over actual emoji characters (⚙️) for better compatibility and readability
@@ -1,39 +0,0 @@
1
- # Git Status Command
2
-
3
- Show detailed git repository status
4
-
5
- *Command originally created by IndyDevDan (YouTube: https://www.youtube.com/@indydevdan) / DislerH (GitHub: https://github.com/disler)*
6
-
7
- ## Instructions
8
-
9
- Analyze the current state of the git repository by performing the following steps:
10
-
11
- 1. **Run Git Status Commands**
12
- - Execute `git status` to see current working tree state
13
- - Run `git diff HEAD origin/main` to check differences with remote
14
- - Execute `git branch --show-current` to display current branch
15
- - Check for uncommitted changes and untracked files
16
-
17
- 2. **Analyze Repository State**
18
- - Identify staged vs unstaged changes
19
- - List any untracked files
20
- - Check if branch is ahead/behind remote
21
- - Review any merge conflicts if present
22
-
23
- 3. **Read Key Files**
24
- - Review README.md for project context
25
- - Check for any recent changes in important files
26
- - Understand project structure if needed
27
-
28
- 4. **Provide Summary**
29
- - Current branch and its relationship to main/master
30
- - Number of commits ahead/behind
31
- - List of modified files with change types
32
- - Any action items (commits needed, pulls required, etc.)
33
-
34
- This command helps developers quickly understand:
35
- - What changes are pending
36
- - The repository's sync status
37
- - Whether any actions are needed before continuing work
38
-
39
- Arguments: $ARGUMENTS
@@ -1,76 +0,0 @@
1
- # Migrate to TypeScript
2
-
3
- Migrate JavaScript project to TypeScript
4
-
5
- ## Instructions
6
-
7
- 1. **Project Analysis and Migration Planning**
8
- - Analyze current JavaScript codebase structure and complexity
9
- - Identify external dependencies and their TypeScript support
10
- - Assess project size and determine migration approach (gradual vs. complete)
11
- - Review existing build system and bundling configuration
12
- - Create migration timeline and phased approach plan
13
-
14
- 2. **TypeScript Installation and Configuration**
15
- - Install TypeScript and related dependencies (@types packages)
16
- - Create comprehensive tsconfig.json with strict configuration
17
- - Configure path mapping and module resolution
18
- - Set up incremental compilation and build optimization
19
- - Configure TypeScript for different environments (development, production, testing)
20
-
21
- 3. **Build System Integration**
22
- - Update build tools to support TypeScript compilation
23
- - Configure webpack, Vite, or other bundlers for TypeScript
24
- - Set up development server with TypeScript support
25
- - Configure hot module replacement for TypeScript files
26
- - Update build scripts and package.json configurations
27
-
28
- 4. **File Migration Strategy**
29
- - Start with configuration files and utility modules
30
- - Migrate from least to most complex modules
31
- - Rename .js files to .ts/.tsx incrementally
32
- - Update import/export statements to use TypeScript syntax
33
- - Handle mixed JavaScript/TypeScript codebase during transition
34
-
35
- 5. **Type Definitions and Interfaces**
36
- - Create comprehensive type definitions for project-specific types
37
- - Install @types packages for external dependencies
38
- - Define interfaces for API responses and data structures
39
- - Create custom type declarations for untyped libraries
40
- - Set up shared types and interfaces across modules
41
-
42
- 6. **Code Transformation and Type Annotation**
43
- - Add explicit type annotations to function parameters and return types
44
- - Convert JavaScript classes to TypeScript with proper typing
45
- - Transform object literals to typed interfaces
46
- - Add generic types for reusable components and functions
47
- - Handle complex types like union types, mapped types, and conditional types
48
-
49
- 7. **Error Resolution and Type Safety**
50
- - Resolve TypeScript compiler errors systematically
51
- - Fix type mismatches and undefined behavior
52
- - Handle null and undefined values with strict null checks
53
- - Configure ESLint rules for TypeScript best practices
54
- - Set up type checking in CI/CD pipeline
55
-
56
- 8. **Testing and Validation**
57
- - Update test files to TypeScript
58
- - Configure testing framework for TypeScript support
59
- - Add type testing with tools like tsd or @typescript-eslint
60
- - Validate type safety in test suites
61
- - Set up type coverage reporting
62
-
63
- 9. **Developer Experience Enhancement**
64
- - Configure IDE/editor for optimal TypeScript support
65
- - Set up IntelliSense and auto-completion
66
- - Configure debugging for TypeScript source maps
67
- - Set up type-aware linting and formatting
68
- - Create TypeScript-specific code snippets and templates
69
-
70
- 10. **Documentation and Team Onboarding**
71
- - Update project documentation for TypeScript setup
72
- - Create TypeScript coding standards and best practices guide
73
- - Document migration decisions and type system architecture
74
- - Set up type documentation generation
75
- - Train team members on TypeScript development workflows
76
- - Create troubleshooting guide for common TypeScript issues
@@ -1,76 +0,0 @@
1
- # Generate Test Cases
2
-
3
- Generate comprehensive test cases automatically
4
-
5
- ## Instructions
6
-
7
- 1. **Target Analysis and Scope Definition**
8
- - Parse target file or function from arguments: `$ARGUMENTS`
9
- - If no target specified, analyze current directory and prompt for specific target
10
- - Examine the target code structure, dependencies, and complexity
11
- - Identify function signatures, parameters, return types, and side effects
12
- - Determine testing scope (unit, integration, or both)
13
-
14
- 2. **Code Structure Analysis**
15
- - Analyze function logic, branching, and control flow
16
- - Identify input validation, error handling, and edge cases
17
- - Examine external dependencies, API calls, and database interactions
18
- - Review data transformations and business logic
19
- - Identify async operations and error scenarios
20
-
21
- 3. **Test Case Generation Strategy**
22
- - Generate positive test cases for normal operation flows
23
- - Create negative test cases for error conditions and invalid inputs
24
- - Generate edge cases for boundary conditions and limits
25
- - Create integration test cases for external dependencies
26
- - Generate performance test cases for complex operations
27
-
28
- 4. **Unit Test Implementation**
29
- - Create test file following project naming conventions
30
- - Set up test framework imports and configuration
31
- - Generate test suites organized by functionality
32
- - Create comprehensive test cases with descriptive names
33
- - Implement proper setup and teardown for each test
34
-
35
- 5. **Mock and Stub Generation**
36
- - Identify external dependencies requiring mocking
37
- - Generate mock implementations for APIs and services
38
- - Create stub data for database and file system operations
39
- - Set up spy functions for monitoring function calls
40
- - Configure mock return values and error scenarios
41
-
42
- 6. **Data-Driven Test Generation**
43
- - Create test data sets for various input scenarios
44
- - Generate parameterized tests for multiple input combinations
45
- - Create fixtures for complex data structures
46
- - Set up test data factories for consistent data generation
47
- - Generate property-based test cases for comprehensive coverage
48
-
49
- 7. **Integration Test Scenarios**
50
- - Generate tests for component interactions
51
- - Create end-to-end workflow test cases
52
- - Generate API integration test scenarios
53
- - Create database integration tests with real data
54
- - Generate cross-module integration test cases
55
-
56
- 8. **Error Handling and Exception Testing**
57
- - Generate tests for all error conditions and exceptions
58
- - Create tests for timeout and network failure scenarios
59
- - Generate tests for invalid input validation
60
- - Create tests for resource exhaustion and limits
61
- - Generate tests for concurrent access and race conditions
62
-
63
- 9. **Test Quality and Coverage**
64
- - Ensure comprehensive code coverage for target functions
65
- - Generate tests for all code branches and paths
66
- - Create tests for both success and failure scenarios
67
- - Validate test assertions are meaningful and specific
68
- - Ensure tests are isolated and independent
69
-
70
- 10. **Test Documentation and Maintenance**
71
- - Generate clear test descriptions and documentation
72
- - Create comments explaining complex test scenarios
73
- - Document test data requirements and setup procedures
74
- - Generate test maintenance guidelines and best practices
75
- - Create test execution and debugging instructions
76
- - Validate generated tests execute successfully and provide meaningful feedback