octocode-cli 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +129 -28
- package/out/chunks/chunk-7476PETK.js +309 -0
- package/out/chunks/chunk-CVNNNSMQ.js +26 -0
- package/out/chunks/chunk-OQBJTZWK.js +60 -0
- package/out/chunks/chunk-UCZCF3BQ.js +9 -0
- package/out/chunks/command-help-specs-JZXVSLZ5.js +8 -0
- package/out/chunks/commands-XBFPLHSQ.js +8 -0
- package/out/chunks/help-P7TCOYAJ.js +10 -0
- package/out/chunks/main-help-ULF5PAQY.js +10 -0
- package/out/chunks/prompts-5E6VKRX5.js +8 -0
- package/out/chunks/spinner-URV2OX6O.js +8 -0
- package/out/chunks/tool-command-M6VA7P2F.js +8 -0
- package/out/octocode-cli.js +1 -1
- package/package.json +5 -3
- package/skills/README.md +60 -58
- package/skills/agentic-flow-best-practices/SKILL.md +280 -0
- package/skills/agentic-flow-best-practices/references/agent-collaboration-patterns.md +75 -0
- package/skills/agentic-flow-best-practices/references/pr-review-agent-example.md +47 -0
- package/skills/agentic-flow-best-practices/references/resources.md +112 -0
- package/skills/octocode-brainstorming/.env.example +11 -0
- package/skills/octocode-brainstorming/SKILL.md +262 -0
- package/skills/octocode-brainstorming/scripts/tavily-search.mjs +138 -0
- package/skills/octocode-chrome-devtools/README.md +541 -0
- package/skills/octocode-chrome-devtools/SKILL.md +197 -0
- package/skills/octocode-chrome-devtools/agents/openai.yaml +7 -0
- package/skills/octocode-chrome-devtools/references/CDP_AGENT_REFERENCE.md +401 -0
- package/skills/octocode-chrome-devtools/references/CHROME_FLAGS.md +234 -0
- package/skills/octocode-chrome-devtools/references/INTENTS.md +108 -0
- package/skills/octocode-chrome-devtools/references/INTENTS_AUTH.md +179 -0
- package/skills/octocode-chrome-devtools/references/INTENTS_AUTOMATION.md +214 -0
- package/skills/octocode-chrome-devtools/references/INTENTS_DEBUG.md +329 -0
- package/skills/octocode-chrome-devtools/references/INTENTS_ENVIRONMENT.md +237 -0
- package/skills/octocode-chrome-devtools/references/INTENTS_INSPECT.md +263 -0
- package/skills/octocode-chrome-devtools/references/INTENTS_STORAGE_CONSENT.md +214 -0
- package/skills/octocode-chrome-devtools/references/RECOVERY.md +39 -0
- package/skills/octocode-chrome-devtools/references/SCRIPT_PATTERNS.md +43 -0
- package/skills/octocode-chrome-devtools/references/SCRIPT_PATTERNS_ASYNC_WORKERS.md +345 -0
- package/skills/octocode-chrome-devtools/references/SCRIPT_PATTERNS_BROWSER.md +403 -0
- package/skills/octocode-chrome-devtools/references/SCRIPT_PATTERNS_OBSERVE.md +275 -0
- package/skills/octocode-chrome-devtools/references/SCRIPT_PATTERNS_SPECIAL.md +18 -0
- package/skills/octocode-chrome-devtools/scripts/cdp-runner.mjs +503 -0
- package/skills/octocode-chrome-devtools/scripts/cdp-sandbox.mjs +123 -0
- package/skills/octocode-chrome-devtools/scripts/cdp-template.mjs +81 -0
- package/skills/octocode-chrome-devtools/scripts/octocode-chrome-devtools.vpn.example.json +8 -0
- package/skills/octocode-chrome-devtools/scripts/open-browser.mjs +362 -0
- package/skills/octocode-chrome-devtools/scripts/sourcemap-resolver.mjs +193 -0
- package/skills/octocode-chrome-devtools/scripts/undercover.mjs +226 -0
- package/skills/octocode-design/README.md +2 -2
- package/skills/octocode-documentation-writer/README.md +1 -1
- package/skills/octocode-engineer/README.md +1 -1
- package/skills/octocode-engineer/SKILL.md +137 -306
- package/skills/octocode-engineer/references/cli-reference.md +13 -0
- package/skills/octocode-engineer/references/output-files.md +3 -3
- package/skills/octocode-engineer/scripts/run.js +146 -146
- package/skills/octocode-engineer/src/pipeline/main.ts +1 -17
- package/skills/octocode-engineer/src/pipeline/progress.ts +4 -0
- package/skills/octocode-engineer/src/reporting/summary-md.test.ts +48 -0
- package/skills/octocode-engineer/src/reporting/summary-md.ts +43 -2
- package/skills/octocode-install/SKILL.md +1 -1
- package/skills/octocode-pull-request-reviewer/README.md +5 -5
- package/skills/octocode-pull-request-reviewer/SKILL.md +1 -1
- package/skills/octocode-research/AGENTS.md +1 -1
- package/skills/octocode-research/README.md +2 -2
- package/skills/octocode-research/docs/ARCHITECTURE.md +1 -1
- package/skills/octocode-research/scripts/server.js +184 -239
- package/skills/octocode-research/src/routes/github.ts +4 -21
- package/skills/octocode-research/src/routes/local.ts +4 -21
- package/skills/octocode-research/src/utils/fileContentTransform.ts +44 -0
- package/skills/octocode-search-skill/SKILL.md +337 -0
- package/skills/octocode-search-skill/references/agent-skills-guide.md +177 -0
- package/skills/octocode-search-skill/references/discovery-surfaces.md +162 -0
- package/skills/octocode-search-skill/references/fetch-and-create-locally.md +57 -0
- package/skills/octocode-search-skill/references/install-reference.md +130 -0
- package/skills/octocode-search-skill/references/references-template.md +27 -0
- package/skills/octocode-search-skill/references/references.md +62 -0
- package/skills/octocode-slides/README.md +307 -0
- package/skills/octocode-slides/SKILL.md +410 -0
- package/skills/octocode-slides/references/01-brief.md +156 -0
- package/skills/octocode-slides/references/02-research.md +149 -0
- package/skills/octocode-slides/references/03-outline.md +172 -0
- package/skills/octocode-slides/references/04-design.md +301 -0
- package/skills/octocode-slides/references/05-implementation.md +213 -0
- package/skills/octocode-slides/references/06-review.md +258 -0
- package/skills/octocode-slides/references/animation.md +281 -0
- package/skills/octocode-slides/references/design-system.md +316 -0
- package/skills/octocode-slides/references/html-templates.md +673 -0
- package/skills/octocode-slides/references/image-generation.md +448 -0
- package/skills/octocode-slides/references/resources.md +840 -0
- package/skills/octocode-slides/references/slide-rules.md +541 -0
- package/skills/octocode-slides/references/wireframes.md +727 -0
- package/skills/octocode-slides/scripts/animation.js +182 -0
- package/skills/octocode-slides/scripts/base.css +353 -0
- package/skills/octocode-slides/scripts/base.html +655 -0
- package/skills/octocode-slides/scripts/generate_image.py +221 -0
- package/skills/octocode-slides/scripts/navbridge.js +79 -0
- package/skills/octocode-slides/scripts/presenter.js +316 -0
- package/skills/octocode-slides/scripts/slide.html +248 -0
- package/skills/octocode-stats/SKILL.md +73 -0
- package/skills/octocode-stats/assets/template.html +1332 -0
- package/skills/octocode-stats/scripts/build_dashboard.mjs +407 -0
- package/out/chunks/chunk-LH4AZJPA.js +0 -389
- package/out/chunks/command-help-specs-CQ3RBLP6.js +0 -8
- package/out/chunks/commands-M3QTWKWE.js +0 -51
- package/out/chunks/help-XPXP46ZT.js +0 -10
- package/out/chunks/main-help-HXFAFHPG.js +0 -10
- package/out/chunks/tool-command-VHFLPIHY.js +0 -8
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __createRequire } from 'module';
|
|
3
|
-
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
-
import { dirname as __dirname_fn } from 'path';
|
|
5
|
-
const require = __createRequire(import.meta.url);
|
|
6
|
-
const __filename = __fileURLToPath(import.meta.url);
|
|
7
|
-
const __dirname = __dirname_fn(__filename);
|
|
8
|
-
import{a as y,g as sn,k as Qs,l as Zs}from"./chunk-LH4AZJPA.js";import{a as r,b as g,c}from"./chunk-V64AXUWB.js";import{a as Js,b as on,d as nn}from"./chunk-YBBF4DTY.js";var ur=on((sm,Mt)=>{"use strict";var ao=function(){};ao.prototype=Object.create(null);var ro=/; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu,io=/\\([\v\u0020-\u00ff])/gu,ar=/^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u,je={type:"",parameters:new ao};Object.freeze(je.parameters);Object.freeze(je);function lr(e){if(typeof e!="string")throw new TypeError("argument header is required and must be a string");let t=e.indexOf(";"),o=t!==-1?e.slice(0,t).trim():e.trim();if(ar.test(o)===!1)throw new TypeError("invalid media type");let n={type:o.toLowerCase(),parameters:new ao};if(t===-1)return n;let s,i,a;for(ro.lastIndex=t;i=ro.exec(e);){if(i.index!==t)throw new TypeError("invalid parameter format");t+=i[0].length,s=i[1].toLowerCase(),a=i[2],a[0]==='"'&&(a=a.slice(1,a.length-1),io.test(a)&&(a=a.replace(io,"$1"))),n.parameters[s]=a}if(t!==e.length)throw new TypeError("invalid parameter format");return n}function cr(e){if(typeof e!="string")return je;let t=e.indexOf(";"),o=t!==-1?e.slice(0,t).trim():e.trim();if(ar.test(o)===!1)return je;let n={type:o.toLowerCase(),parameters:new ao};if(t===-1)return n;let s,i,a;for(ro.lastIndex=t;i=ro.exec(e);){if(i.index!==t)return je;t+=i[0].length,s=i[1].toLowerCase(),a=i[2],a[0]==='"'&&(a=a.slice(1,a.length-1),io.test(a)&&(a=a.replace(io,"$1"))),n.parameters[s]=a}return t!==e.length?je:n}Mt.exports.default={parse:lr,safeParse:cr};Mt.exports.parse=lr;Mt.exports.safeParse=cr;Mt.exports.defaultContentType=je});var ai=on((ph,ii)=>{"use strict";ii.exports=vu;function ku(e){let t={defaultWidth:0,output:process.stdout,tty:Js("tty")};return e?(Object.keys(t).forEach(function(o){e[o]||(e[o]=t[o])}),e):t}function vu(e){let t=ku(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let o=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(o)&&o!==0)return o}return t.defaultWidth}});var $i=on((xh,Pi)=>{var _u=Js("stream"),Dn=class extends _u{#o=null;constructor(t={}){super(t),this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=t.replace,this._prompt=t.prompt||null,this._hadControl=!1}#t(t,o){return this._dest?this._dest[t]:this._src?this._src[t]:o}#e(t,...o){typeof this._dest?.[t]=="function"&&this._dest[t](...o),typeof this._src?.[t]=="function"&&this._src[t](...o)}get isTTY(){return this.#o!==null?this.#o:this.#t("isTTY",!1)}set isTTY(t){this.#o=t}get rows(){return this.#t("rows")}get columns(){return this.#t("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(t){this._src=t}pipe(t,o){return this._dest=t,super.pipe(t,o)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(t){if(this.muted){if(!this.replace)return!0;if(t.match(/^\u001b/))return t.indexOf(this._prompt)===0&&(t=t.slice(this._prompt.length),t=t.replace(/./g,this.replace),t=this._prompt+t),this._hadControl=!0,this.emit("data",t);this._prompt&&this._hadControl&&t.indexOf(this._prompt)===0&&(this._hadControl=!1,this.emit("data",this._prompt),t=t.slice(this._prompt.length)),t=t.toString().replace(/./g,this.replace)}this.emit("data",t)}end(t){this.muted&&(t&&this.replace?t=t.toString().replace(/./g,this.replace):t=null),t&&this.emit("data",t),this.emit("end")}destroy(...t){return this.#e("destroy",...t)}destroySoon(...t){return this.#e("destroySoon",...t)}close(...t){return this.#e("close",...t)}};Pi.exports=Dn});import Qm from"node:fs";import ef from"node:path";import{spawnSync as Jc}from"node:child_process";import{existsSync as co,readFileSync as Mr,writeFileSync as Ar,unlinkSync as $r,statSync as yc,chmodSync as Cc}from"node:fs";import{createCipheriv as bc,createDecipheriv as kc,randomBytes as Tr}from"node:crypto";import{existsSync as vc,mkdirSync as wc}from"node:fs";import{join as Ee}from"node:path";import po from"node:os";import Sc from"node:path";function ct(){return typeof navigator=="object"&&"userAgent"in navigator?navigator.userAgent:typeof process=="object"&&process.version!==void 0?`Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`:"<environment undetectable>"}var Nl="0.0.0-development",Fl=`octokit-endpoint.js/${Nl} ${ct()}`,Bl={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":Fl},mediaType:{format:""}};function jl(e){return e?Object.keys(e).reduce((t,o)=>(t[o.toLowerCase()]=e[o],t),{}):{}}function Ul(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let o=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof o=="function"&&o instanceof o&&Function.prototype.call(o)===Function.prototype.call(e)}function or(e,t){let o=Object.assign({},e);return Object.keys(t).forEach(n=>{Ul(t[n])?n in e?o[n]=or(e[n],t[n]):Object.assign(o,{[n]:t[n]}):Object.assign(o,{[n]:t[n]})}),o}function er(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function an(e,t,o){if(typeof t=="string"){let[s,i]=t.split(" ");o=Object.assign(i?{method:s,url:i}:{url:s},o)}else o=Object.assign({},t);o.headers=jl(o.headers),er(o),er(o.headers);let n=or(e||{},o);return o.url==="/graphql"&&(e&&e.mediaType.previews?.length&&(n.mediaType.previews=e.mediaType.previews.filter(s=>!n.mediaType.previews.includes(s)).concat(n.mediaType.previews)),n.mediaType.previews=(n.mediaType.previews||[]).map(s=>s.replace(/-preview/,""))),n}function Gl(e,t){let o=/\?/.test(e)?"&":"?",n=Object.keys(t);return n.length===0?e:e+o+n.map(s=>s==="q"?"q="+t.q.split("+").map(encodeURIComponent).join("+"):`${s}=${encodeURIComponent(t[s])}`).join("&")}var Hl=/\{[^{}}]+\}/g;function Vl(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function Wl(e){let t=e.match(Hl);return t?t.map(Vl).reduce((o,n)=>o.concat(n),[]):[]}function tr(e,t){let o={__proto__:null};for(let n of Object.keys(e))t.indexOf(n)===-1&&(o[n]=e[n]);return o}function nr(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(t){return/%[0-9A-Fa-f]/.test(t)||(t=encodeURI(t).replace(/%5B/g,"[").replace(/%5D/g,"]")),t}).join("")}function dt(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function It(e,t,o){return t=e==="+"||e==="#"?nr(t):dt(t),o?dt(o)+"="+t:t}function ut(e){return e!=null}function rn(e){return e===";"||e==="&"||e==="?"}function ql(e,t,o,n){var s=e[o],i=[];if(ut(s)&&s!=="")if(typeof s=="string"||typeof s=="number"||typeof s=="bigint"||typeof s=="boolean")s=s.toString(),n&&n!=="*"&&(s=s.substring(0,parseInt(n,10))),i.push(It(t,s,rn(t)?o:""));else if(n==="*")Array.isArray(s)?s.filter(ut).forEach(function(a){i.push(It(t,a,rn(t)?o:""))}):Object.keys(s).forEach(function(a){ut(s[a])&&i.push(It(t,s[a],a))});else{let a=[];Array.isArray(s)?s.filter(ut).forEach(function(l){a.push(It(t,l))}):Object.keys(s).forEach(function(l){ut(s[l])&&(a.push(dt(l)),a.push(It(t,s[l].toString())))}),rn(t)?i.push(dt(o)+"="+a.join(",")):a.length!==0&&i.push(a.join(","))}else t===";"?ut(s)&&i.push(dt(o)):s===""&&(t==="&"||t==="?")?i.push(dt(o)+"="):s===""&&i.push("");return i}function Kl(e){return{expand:zl.bind(null,e)}}function zl(e,t){var o=["+","#",".","/",";","?","&"];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(n,s,i){if(s){let l="",u=[];if(o.indexOf(s.charAt(0))!==-1&&(l=s.charAt(0),s=s.substr(1)),s.split(/,/g).forEach(function(p){var d=/([^:\*]*)(?::(\d+)|(\*))?/.exec(p);u.push(ql(t,l,d[1],d[2]||d[3]))}),l&&l!=="+"){var a=",";return l==="?"?a="&":l!=="#"&&(a=l),(u.length!==0?l:"")+u.join(a)}else return u.join(",")}else return nr(i)}),e==="/"?e:e.replace(/\/$/,"")}function sr(e){let t=e.method.toUpperCase(),o=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),n=Object.assign({},e.headers),s,i=tr(e,["method","baseUrl","url","headers","request","mediaType"]),a=Wl(o);o=Kl(o).expand(i),/^http/.test(o)||(o=e.baseUrl+o);let l=Object.keys(e).filter(d=>a.includes(d)).concat("baseUrl"),u=tr(i,l);if(!/application\/octet-stream/i.test(n.accept)&&(e.mediaType.format&&(n.accept=n.accept.split(/,/).map(d=>d.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(",")),o.endsWith("/graphql")&&e.mediaType.previews?.length)){let d=n.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g)||[];n.accept=d.concat(e.mediaType.previews).map(m=>{let f=e.mediaType.format?`.${e.mediaType.format}`:"+json";return`application/vnd.github.${m}-preview${f}`}).join(",")}return["GET","HEAD"].includes(t)?o=Gl(o,u):"data"in u?s=u.data:Object.keys(u).length&&(s=u),!n["content-type"]&&typeof s<"u"&&(n["content-type"]="application/json; charset=utf-8"),["PATCH","PUT"].includes(t)&&typeof s>"u"&&(s=""),Object.assign({method:t,url:o,headers:n},typeof s<"u"?{body:s}:null,e.request?{request:e.request}:null)}function Xl(e,t,o){return sr(an(e,t,o))}function rr(e,t){let o=an(e,t),n=Xl.bind(null,o);return Object.assign(n,{DEFAULTS:o,defaults:rr.bind(null,o),merge:an.bind(null,o),parse:sr})}var ir=rr(null,Bl);var br=nn(ur(),1);var Yl=/^-?\d+$/,gr=/^-?\d+n+$/,ln=JSON.stringify,dr=JSON.parse,Jl=/^-?\d+n$/,Ql=/([\[:])?"(-?\d+)n"($|([\\n]|\s)*(\s|[\\n])*[,\}\]])/g,Zl=/([\[:])?("-?\d+n+)n("$|"([\\n]|\s)*(\s|[\\n])*[,\}\]])/g,mr=(e,t,o)=>"rawJSON"in JSON?ln(e,(a,l)=>typeof l=="bigint"?JSON.rawJSON(l.toString()):typeof t=="function"?t(a,l):(Array.isArray(t)&&t.includes(a),l),o):e?ln(e,(a,l)=>typeof l=="string"&&gr.test(l)||typeof l=="bigint"?l.toString()+"n":typeof t=="function"?t(a,l):(Array.isArray(t)&&t.includes(a),l),o).replace(Ql,"$1$2$3").replace(Zl,"$1$2$3"):ln(e,t,o),lo=new Map,ec=()=>{let e=JSON.parse.toString();if(lo.has(e))return lo.get(e);try{let t=JSON.parse("1",(o,n,s)=>!!s?.source&&s.source==="1");return lo.set(e,t),t}catch{return lo.set(e,!1),!1}},tc=(e,t,o,n)=>typeof t=="string"&&Jl.test(t)?BigInt(t.slice(0,-1)):typeof t=="string"&&gr.test(t)?t.slice(0,-1):typeof n!="function"?t:n(e,t,o),oc=(e,t)=>JSON.parse(e,(o,n,s)=>{let i=typeof n=="number"&&(n>Number.MAX_SAFE_INTEGER||n<Number.MIN_SAFE_INTEGER),a=s&&Yl.test(s.source);return i&&a?BigInt(s.source):typeof t!="function"?n:t(o,n,s)}),fr=Number.MAX_SAFE_INTEGER.toString(),pr=fr.length,nc=/"(?:\\.|[^"])*"|-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?/g,sc=/^"-?\d+n+"$/,hr=(e,t)=>{if(!e)return dr(e,t);if(ec())return oc(e,t);let o=e.replace(nc,(n,s,i,a)=>{let l=n[0]==='"';if(l&&sc.test(n))return n.substring(0,n.length-1)+'n"';let p=i||a,d=s&&(s.length<pr||s.length===pr&&s<=fr);return l||p||d?n:'"'+n+'n"'});return dr(o,(n,s,i)=>tc(n,s,i,t))};var $e=class extends Error{name;status;request;response;constructor(t,o,n){super(t,{cause:n.cause}),this.name="HttpError",this.status=Number.parseInt(o),Number.isNaN(this.status)&&(this.status=0);"response"in n&&(this.response=n.response);let s=Object.assign({},n.request);n.request.headers.authorization&&(s.headers=Object.assign({},n.request.headers,{authorization:n.request.headers.authorization.replace(/(?<! ) .*$/," [REDACTED]")})),s.url=s.url.replace(/\bclient_secret=\w+/g,"client_secret=[REDACTED]").replace(/\baccess_token=\w+/g,"access_token=[REDACTED]"),this.request=s}};var rc="10.0.8",ic={headers:{"user-agent":`octokit-request.js/${rc} ${ct()}`}};function ac(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let o=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof o=="function"&&o instanceof o&&Function.prototype.call(o)===Function.prototype.call(e)}var yr=()=>"";async function Cr(e){let t=e.request?.fetch||globalThis.fetch;if(!t)throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");let o=e.request?.log||console,n=e.request?.parseSuccessResponseBody!==!1,s=ac(e.body)||Array.isArray(e.body)?mr(e.body):e.body,i=Object.fromEntries(Object.entries(e.headers).map(([m,f])=>[m,String(f)])),a;try{a=await t(e.url,{method:e.method,body:s,redirect:e.request?.redirect,headers:i,signal:e.request?.signal,...e.body&&{duplex:"half"}})}catch(m){let f="Unknown Error";if(m instanceof Error){if(m.name==="AbortError")throw m.status=500,m;f=m.message,m.name==="TypeError"&&"cause"in m&&(m.cause instanceof Error?f=m.cause.message:typeof m.cause=="string"&&(f=m.cause))}let C=new $e(f,500,{request:e});throw C.cause=m,C}let l=a.status,u=a.url,p={};for(let[m,f]of a.headers)p[m]=f;let d={url:u,status:l,headers:p,data:""};if("deprecation"in p){let m=p.link&&p.link.match(/<([^<>]+)>; rel="deprecation"/),f=m&&m.pop();o.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${p.sunset}${f?`. See ${f}`:""}`)}if(l===204||l===205)return d;if(e.method==="HEAD"){if(l<400)return d;throw new $e(a.statusText,l,{response:d,request:e})}if(l===304)throw d.data=await cn(a),new $e("Not modified",l,{response:d,request:e});if(l>=400)throw d.data=await cn(a),new $e(cc(d.data),l,{response:d,request:e});return d.data=n?await cn(a):a.body,d}async function cn(e){let t=e.headers.get("content-type");if(!t)return e.text().catch(yr);let o=(0,br.safeParse)(t);if(lc(o)){let n="";try{return n=await e.text(),hr(n)}catch{return n}}else return o.type.startsWith("text/")||o.parameters.charset?.toLowerCase()==="utf-8"?e.text().catch(yr):e.arrayBuffer().catch(()=>new ArrayBuffer(0))}function lc(e){return e.type==="application/json"||e.type==="application/scim+json"}function cc(e){if(typeof e=="string")return e;if(e instanceof ArrayBuffer)return"Unknown error";if("message"in e){let t="documentation_url"in e?` - ${e.documentation_url}`:"";return Array.isArray(e.errors)?`${e.message}: ${e.errors.map(o=>JSON.stringify(o)).join(", ")}${t}`:`${e.message}${t}`}return`Unknown error: ${JSON.stringify(e)}`}function un(e,t){let o=e.defaults(t);return Object.assign(function(s,i){let a=o.merge(s,i);if(!a.request||!a.request.hook)return Cr(o.parse(a));let l=(u,p)=>Cr(o.parse(o.merge(u,p)));return Object.assign(l,{endpoint:o,defaults:un.bind(null,o)}),a.request.hook(l,a)},{endpoint:o,defaults:un.bind(null,o)})}var J=un(ir,ic);function uc(e){let t=e.endpoint.DEFAULTS;return/^https:\/\/(api\.)?github\.com$/.test(t.baseUrl)?"https://github.com":t.baseUrl.replace("/api/v3","")}async function dn(e,t,o){let n={baseUrl:uc(e),headers:{accept:"application/json"},...o},s=await e(t,n);if("error"in s.data){let i=new $e(`${s.data.error_description} (${s.data.error}, ${s.data.error_uri})`,400,{request:e.endpoint.merge(t,n)});throw i.response=s,i}return s}async function wr(e){let t=e.request||J,o={client_id:e.clientId};return"scopes"in e&&Array.isArray(e.scopes)&&(o.scope=e.scopes.join(" ")),dn(t,"POST /login/device/code",o)}async function pn(e){let t=e.request||J,o=await dn(t,"POST /login/oauth/access_token",{client_id:e.clientId,device_code:e.code,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),n={clientType:e.clientType,clientId:e.clientId,token:o.data.access_token,scopes:o.data.scope.split(/\s+/).filter(Boolean)};if("clientSecret"in e&&(n.clientSecret=e.clientSecret),e.clientType==="github-app"){if("refresh_token"in o.data){let s=new Date(o.headers.date).getTime();n.refreshToken=o.data.refresh_token,n.expiresAt=kr(s,o.data.expires_in),n.refreshTokenExpiresAt=kr(s,o.data.refresh_token_expires_in)}delete n.scopes}return{...o,authentication:n}}function kr(e,t){return new Date(e+t*1e3).toISOString()}async function Sr(e){let t=e.request||J,o=await dn(t,"POST /login/oauth/access_token",{client_id:e.clientId,client_secret:e.clientSecret,grant_type:"refresh_token",refresh_token:e.refreshToken}),n=new Date(o.headers.date).getTime(),s={clientType:"github-app",clientId:e.clientId,clientSecret:e.clientSecret,token:o.data.access_token,refreshToken:o.data.refresh_token,expiresAt:vr(n,o.data.expires_in),refreshTokenExpiresAt:vr(n,o.data.refresh_token_expires_in)};return{...o,authentication:s}}function vr(e,t){return new Date(e+t*1e3).toISOString()}async function Pr(e){let t=e.request||J,o=btoa(`${e.clientId}:${e.clientSecret}`);return t("DELETE /applications/{client_id}/token",{headers:{authorization:`basic ${o}`},client_id:e.clientId,access_token:e.token})}import{randomUUID as Am}from"node:crypto";import{existsSync as Om,readFileSync as Lm,writeFileSync as Dm,unlinkSync as Rm,renameSync as _m}from"node:fs";import{existsSync as Gm,readFileSync as Hm}from"node:fs";import{existsSync as Kc,readdirSync as zc,lstatSync as Xc}from"node:fs";import{join as Yc}from"node:path";var dc=null;function pc(e){let t=`[${e.module}]`,o=e.data&&Object.keys(e.data).length>0?` ${JSON.stringify(e.data)}`:"";process.stderr.write(`${t} ${e.level}: ${e.message}${o}
|
|
9
|
-
`)}function uo(e){function t(o,n,s){let i={level:o,module:e,message:n,...s&&{data:s}};(dc??pc)(i)}return{debug:(o,n)=>t("debug",o,n),info:(o,n)=>t("info",o,n),warn:(o,n)=>t("warn",o,n),error:(o,n)=>t("error",o,n)}}function Re(e){return e.toLowerCase().replace(/^https?:\/\//,"").replace(/\/$/,"")}function Ge(e){if(!e.token.expiresAt)return!1;let t=new Date(e.token.expiresAt);if(isNaN(t.getTime()))return!0;let o=new Date;return t.getTime()-o.getTime()<300*1e3}function Er(e){if(!e.token.refreshTokenExpiresAt)return!1;let t=new Date(e.token.refreshTokenExpiresAt);return isNaN(t.getTime())?!0:new Date>=t}var At=new Map,gc=300*1e3;function mc(e){let t=Re(e),o=At.get(t);return!o||Date.now()-o.cachedAt>=gc?!1:o.credentials?!Ge(o.credentials):!0}function Ir(e){e?At.delete(Re(e)):At.clear()}function fc(e){let t=Re(e);if(mc(t))return At.get(t).credentials}function hc(e,t){let o=Re(e);At.set(o,{credentials:t,cachedAt:Date.now()})}var V=po.platform()==="win32",be=po.platform()==="darwin",Pm=po.platform()==="linux",B=po.homedir();function re(){return V?process.env.APPDATA||Sc.join(B,"AppData","Roaming"):B}var Pc=Ee(B,".octocode"),$c=448,xe=process.env.OCTOCODE_HOME||Pc,ne={home:xe,config:Ee(xe,".octocoderc"),credentials:Ee(xe,"credentials.json"),key:Ee(xe,".key"),session:Ee(xe,"session.json"),repos:Ee(xe,"repos"),logs:Ee(xe,"logs"),cliConfig:Ee(xe,"config.json"),lspConfig:Ee(xe,"lsp-servers.json")};function xc(){vc(ne.home)||wc(ne.home,{recursive:!0,mode:$c})}var Ec=y.object({token:y.string(),tokenType:y.literal("oauth"),scopes:y.array(y.string()).optional(),refreshToken:y.string().optional(),expiresAt:y.string().optional(),refreshTokenExpiresAt:y.string().optional()}),Ic=y.object({hostname:y.string(),username:y.string(),token:Ec,gitProtocol:y.enum(["ssh","https"]),createdAt:y.string(),updatedAt:y.string()}),Mc=y.object({version:y.number(),credentials:y.record(y.string(),Ic)}),xr=uo("token-storage");function Ac(e){return e.replace(/\b(ghp_|gho_|ghu_|ghs_|ghr_)[a-zA-Z0-9]{36,}\b/g,"***MASKED***").replace(/\b[a-zA-Z0-9]{40,}\b/g,"***MASKED***")}var xm=ne.home,De=ne.credentials,Ue=ne.key,Or="aes-256-gcm",Tc=16;function mn(){xc()}function Lr(){if(mn(),co(Ue))return yc(Ue).mode&511&63&&Cc(Ue,384),Buffer.from(Mr(Ue,"utf8"),"hex");let e=Tr(32);return Ar(Ue,e.toString("hex"),{mode:384}),e}function Oc(e){let t=Lr(),o=Tr(Tc),n=bc(Or,t,o),s=n.update(e,"utf8","hex");s+=n.final("hex");let i=n.getAuthTag();return`${o.toString("hex")}:${i.toString("hex")}:${s}`}function Lc(e){let t=Lr(),[o,n,s]=e.split(":");if(!o||!n||!s)throw new Error("Invalid encrypted data format");let i=Buffer.from(o,"hex"),a=Buffer.from(n,"hex"),l=kc(Or,t,i);l.setAuthTag(a);let u=l.update(s,"hex","utf8");return u+=l.final("utf8"),u}function go(){if(mn(),!co(De))return{version:1,credentials:{}};try{let e=Mr(De,"utf8"),t=Lc(e),o=JSON.parse(t),n=Mc.safeParse(o);return n.success?n.data:(xr.warn("Credentials file has invalid format \u2014 starting fresh",{file:De}),{version:1,credentials:{}})}catch(e){let t=e instanceof Error&&e.message?Ac(e.message):void 0;return xr.warn("Could not read credentials file \u2014 you may need to login again",{file:De,...t&&{reason:t}}),{version:1,credentials:{}}}}function Dr(e){mn();let t=Oc(JSON.stringify(e,null,2));Ar(De,t,{mode:384})}function Dc(){try{co(De)&&$r(De),co(Ue)&&$r(Ue)}catch{}}var Rr="178c6fc778ccc68e1d6a",fn="github.com";function Rc(e){return e.replace(/\b(ghp_|gho_|ghu_|ghs_|ghr_)[a-zA-Z0-9]{36,}\b/g,"***MASKED***").replace(/\b[a-zA-Z0-9]{40,}\b/g,"***MASKED***")}function _c(e){return e==="github.com"||e===fn?"https://api.github.com":`https://${e}/api/v3`}async function Nc(e,t=fn,o=Rr){let n=await e.getCredentials(t);if(!n)return{success:!1,error:`Not logged in to ${t}`};if(!n.token.refreshToken)return{success:!1,error:"Token does not support refresh (OAuth App tokens do not expire)"};if(Er(n))return{success:!1,error:"Refresh token has expired. Please login again."};try{let s=await Sr({clientType:"github-app",clientId:o,clientSecret:"",refreshToken:n.token.refreshToken,request:J.defaults({baseUrl:_c(t)})}),i={token:s.authentication.token,tokenType:"oauth",refreshToken:s.authentication.refreshToken,expiresAt:s.authentication.expiresAt,refreshTokenExpiresAt:s.authentication.refreshTokenExpiresAt};return await e.updateToken(t,i),{success:!0,username:n.username,hostname:t}}catch(s){return{success:!1,error:s instanceof Error?Rc(s.message):"Token refresh failed"}}}async function Fc(e,t=fn,o=Rr){let n=await e.getCredentials(t);if(!n||!n.token)return{token:null,source:"none"};if(!Ge(n))return{token:n.token.token,source:"stored",username:n.username};if(n.token.refreshToken){let s=await Nc(e,t,o);if(s.success){let i=await e.getCredentials(t);if(i?.token.token)return{token:i.token.token,source:"refreshed",username:i.username}}return{token:null,source:"none",refreshError:s.error}}return{token:null,source:"none",refreshError:"Token expired and no refresh token available"}}var _r=["OCTOCODE_TOKEN","GH_TOKEN","GITHUB_TOKEN"];function Nr(){for(let e of _r){let t=process.env[e];if(t&&t.trim())return t.trim()}return null}function Tt(){for(let e of _r){let t=process.env[e];if(t&&t.trim())return`env:${e}`}return null}function pt(){return Nr()!==null}var Bc="178c6fc778ccc68e1d6a",jc="github.com",gn=null;function Uc(e){gn=e}function Gc(){if(!gn)throw new Error("Token resolution not initialized. Call initTokenResolution() first.");return gn}async function hn(e){let t=e?.hostname??jc,o=e?.clientId??Bc,n=e?.getGhCliToken,s=Nr();if(s)return{token:s,source:Tt()??"env:GITHUB_TOKEN",wasRefreshed:!1};let i=await Gc().getTokenWithRefresh(t,o);if(i.token)return{token:i.token,source:"file",wasRefreshed:i.source==="refreshed",username:i.username};let a=i.refreshError;if(n)try{let l=await Promise.resolve(n(t));if(l?.trim())return{token:l.trim(),source:"gh-cli",wasRefreshed:!1,refreshError:a}}catch{}return a?{token:"",source:null,wasRefreshed:!1,refreshError:a}:null}var Hc=uo("token-storage");async function mo(e){let t=Re(e.hostname),o={...e,hostname:t,updatedAt:new Date().toISOString()};try{let n=go();return n.credentials[t]=o,Dr(n),Ir(t),{success:!0}}catch(n){let s=n instanceof Error?n.message:String(n);throw Hc.error("CRITICAL: Storage failed",{error:s.replace(/\b(ghp_|gho_|ghu_|ghs_|ghr_)[a-zA-Z0-9]{36,}\b/g,"***MASKED***").replace(/\b[a-zA-Z0-9]{40,}\b/g,"***MASKED***")}),new Error("Failed to store credentials")}}async function Ie(e="github.com",t){let o=Re(e);if(!t?.bypassCache){let i=fc(o);if(i!==void 0)return i}let s=go().credentials[o]||null;return hc(o,s),s}function yn(e="github.com"){let t=Re(e);return go().credentials[t]||null}async function Cn(e="github.com"){let t=Re(e),o=!1,n=go();return n.credentials[t]&&(delete n.credentials[t],Object.keys(n.credentials).length===0?Dc():Dr(n),o=!0),Ir(t),{success:o,deletedFromFile:o}}async function Vc(e,t){let o=await Ie(e);return o?(o.token=t,o.updatedAt=new Date().toISOString(),await mo(o),!0):!1}function bn(){return De}async function Wc(e="github.com"){let t=await Ie(e);return!t||!t.token||Ge(t)?null:t.token.token}async function fo(e,t){return Fc({getCredentials:Ie,updateToken:Vc},e,t)}Uc({getToken:Wc,getTokenWithRefresh:fo});var qc=y.object({toolCalls:y.number(),promptCalls:y.number(),errors:y.number(),rateLimits:y.number()}),Fm=y.object({version:y.literal(1),sessionId:y.string(),createdAt:y.string(),lastActiveAt:y.string(),stats:qc}),Bm=uo("session"),jm=ne.session;var Wm=y.object({$schema:y.string().optional(),version:y.number().int().optional(),github:y.record(y.string(),y.unknown()).optional(),gitlab:y.record(y.string(),y.unknown()).optional(),bitbucket:y.record(y.string(),y.unknown()).optional(),local:y.record(y.string(),y.unknown()).optional(),tools:y.record(y.string(),y.unknown()).optional(),network:y.record(y.string(),y.unknown()).optional(),telemetry:y.record(y.string(),y.unknown()).optional(),lsp:y.record(y.string(),y.unknown()).optional(),output:y.record(y.string(),y.unknown()).optional()}).passthrough(),qm=ne.config;var Km=uo("octocode-config");function _e(e){if(!Kc(e))return 0;let t=0,o=[e];for(;o.length>0;){let n=o.pop(),s;try{s=zc(n)}catch{continue}for(let i of s){let a=Yc(n,i);try{let l=Xc(a);if(l.isSymbolicLink())continue;l.isDirectory()?o.push(a):l.isFile()&&(t+=l.size)}catch{}}}return t}function gt(e){if(e<1024)return`${e} B`;let t=e/1024;if(t<1024)return`${t.toFixed(1)} KB`;let o=t/1024;return o<1024?`${o.toFixed(1)} MB`:`${(o/1024).toFixed(2)} GB`}function ho(){process.stdout.write("\x1B[2J\x1B[3J\x1B[H")}function kn(e,t){try{let o,n;return t?(o=t,n=[e]):be?(o="open",n=[e]):V?(o="cmd",n=["/c","start",'""',e]):(o="xdg-open",n=[e]),Jc(o,n,{stdio:"ignore",shell:V&&!t}).status===0}catch{return!1}}function Fr(e,t){switch(t){case"cursor":return kn(e,"cursor");case"vscode":return kn(e,"code");default:return kn(e)}}import L from"node:path";import ie from"node:fs";import vn from"node:path";var Qc=process.env.OCTOCODE_DEBUG==="1";function Y(e,t){try{return e()}catch(o){return Qc&&console.error("[trySafe]",o instanceof Error?o.message:o),t}}function T(e){return Y(()=>ie.existsSync(e)&&ie.statSync(e).isDirectory(),!1)}function Q(e){return Y(()=>ie.existsSync(e)&&ie.statSync(e).isFile(),!1)}function He(e){return Y(()=>Q(e)?ie.readFileSync(e,"utf8"):null,null)}function Ot(e,t){return Y(()=>{let o=vn.dirname(e);return T(o)||ie.mkdirSync(o,{recursive:!0,mode:448}),ie.writeFileSync(e,t,{encoding:"utf8",mode:384}),!0},!1)}function Br(e){return Q(e)?Y(()=>{let t=new Date().toISOString().replace(/[:.]/g,"-"),o=`${e}.backup-${t}`;return ie.copyFileSync(e,o),o},null):null}function jr(e){let t=He(e);return t?Y(()=>JSON.parse(t),null):null}function Ur(e,t){return Y(()=>{let o=JSON.stringify(t,null,2)+`
|
|
10
|
-
`;return Ot(e,o)},!1)}function mt(e,t){return Y(()=>{if(!T(e))return!1;T(t)||ie.mkdirSync(t,{recursive:!0});let o=ie.readdirSync(e,{withFileTypes:!0});for(let n of o){let s=vn.join(e,n.name),i=vn.join(t,n.name);if(n.isDirectory()){if(!mt(s,i))return!1}else ie.copyFileSync(s,i)}return!0},!1)}function ke(e){return Y(()=>T(e)?ie.readdirSync(e,{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>t.name):[],[])}function ft(e){return Y(()=>T(e)?(ie.rmSync(e,{recursive:!0,force:!0}),!0):!1,!1)}function Gr(){return V?re():be?L.join(B,"Library","Application Support"):process.env.XDG_CONFIG_HOME||L.join(B,".config")}function Zc(){let e=Gr();return V?L.join(e,"Code","User","globalStorage"):be?L.join(e,"Code","User","globalStorage"):L.join(e,"Code","User","globalStorage")}var D={cursor:{id:"cursor",name:"Cursor",description:"AI-first code editor",category:"ide",url:"https://cursor.sh",envVars:["CURSOR_AGENT","CURSOR_TRACE_ID","CURSOR_SESSION_ID","CURSOR"]},"claude-desktop":{id:"claude-desktop",name:"Claude Desktop",description:"Anthropic's desktop app",category:"desktop",url:"https://claude.ai/download"},"claude-code":{id:"claude-code",name:"Claude Code",description:"Claude CLI for terminal",category:"cli",url:"https://docs.anthropic.com/claude-code",envVars:["CLAUDE_CODE"]},"vscode-cline":{id:"vscode-cline",name:"Cline (VS Code)",description:"AI coding assistant extension",category:"extension",url:"https://marketplace.visualstudio.com/items?itemName=saoudrizwan.claude-dev",envVars:["VSCODE_PID","TERM_PROGRAM"]},"vscode-roo":{id:"vscode-roo",name:"Roo-Cline (VS Code)",description:"Roo AI coding extension",category:"extension",envVars:["VSCODE_PID"]},windsurf:{id:"windsurf",name:"Windsurf",description:"Codeium AI IDE",category:"ide",url:"https://codeium.com/windsurf",envVars:["WINDSURF_SESSION"]},trae:{id:"trae",name:"Trae",description:"Adaptive AI IDE",category:"ide",url:"https://trae.ai"},antigravity:{id:"antigravity",name:"Antigravity",description:"Gemini-powered AI IDE",category:"ide"},"vscode-continue":{id:"vscode-continue",name:"Continue (VS Code)",description:"Open-source AI assistant",category:"extension",url:"https://continue.dev",envVars:["VSCODE_PID"]},zed:{id:"zed",name:"Zed",description:"High-performance code editor",category:"ide",url:"https://zed.dev",envVars:["ZED_TERM"]},opencode:{id:"opencode",name:"Opencode",description:"AI coding agent CLI",category:"cli",url:"https://opencode.ai",envVars:["OPENCODE"]},codex:{id:"codex",name:"Codex",description:"OpenAI Codex CLI agent",category:"cli",url:"https://github.com/openai/codex",envVars:["CODEX_HOME","CODEX_SANDBOX_TYPE"]},"gemini-cli":{id:"gemini-cli",name:"Gemini CLI",description:"Google Gemini CLI",category:"cli",url:"https://github.com/google-gemini/gemini-cli",envVars:["GEMINI_API_KEY"]},goose:{id:"goose",name:"Goose",description:"Block AI coding agent",category:"desktop",url:"https://block.github.io/goose",envVars:["GOOSE_MODE"]},kiro:{id:"kiro",name:"Kiro",description:"AWS AI IDE",category:"ide",url:"https://kiro.dev"},custom:{id:"custom",name:"Custom Path",description:"Specify your own MCP config path",category:"cli"}};function U(e,t){if(e==="custom"&&t)return t;let o=Gr(),n=Zc();switch(e){case"cursor":return V?L.join(re(),"Cursor","mcp.json"):L.join(B,".cursor","mcp.json");case"claude-desktop":return V?L.join(o,"Claude","claude_desktop_config.json"):be?L.join(o,"Claude","claude_desktop_config.json"):L.join(o,"claude","claude_desktop_config.json");case"claude-code":return L.join(B,".claude.json");case"vscode-cline":return L.join(n,"saoudrizwan.claude-dev","settings","cline_mcp_settings.json");case"vscode-roo":return L.join(n,"rooveterinaryinc.roo-cline","settings","mcp_settings.json");case"windsurf":return L.join(B,".codeium","windsurf","mcp_config.json");case"trae":return V?L.join(re(),"Trae","mcp.json"):be?L.join(o,"Trae","mcp.json"):L.join(o,"Trae","mcp.json");case"antigravity":return L.join(B,".gemini","antigravity","mcp_config.json");case"vscode-continue":return L.join(B,".continue","config.json");case"zed":return V?L.join(re(),"Zed","settings.json"):be?L.join(B,".config","zed","settings.json"):L.join(o,"zed","settings.json");case"opencode":return V?L.join(re(),"opencode","config.json"):L.join(o,"opencode","config.json");case"codex":return L.join(B,".codex","config.toml");case"gemini-cli":return L.join(B,".gemini","settings.json");case"goose":return V?L.join(re(),"goose","config.yaml"):be?L.join(o,"goose","config.yaml"):L.join(o,"goose","config.yaml");case"kiro":return V?L.join(re(),"Kiro","mcp.json"):L.join(B,".kiro","mcp.json");case"custom":throw new Error("Custom path requires customPath parameter");default:throw new Error(`Unknown MCP client: ${e}`)}}function Ne(e,t){try{let o=U(e,t),n=L.dirname(o);return T(n)}catch{return!1}}function yo(e,t){try{let o=U(e,t);return Q(o)}catch{return!1}}function ht(){let e=process.env;return e.CURSOR_AGENT||e.CURSOR_TRACE_ID||e.CURSOR_SESSION_ID||e.CURSOR?"cursor":e.WINDSURF_SESSION?"windsurf":e.CLAUDE_CODE?"claude-code":e.ZED_TERM||e.ZED?"zed":e.OPENCODE?"opencode":e.CODEX_HOME||e.CODEX_SANDBOX_TYPE?"codex":e.GEMINI_API_KEY?"gemini-cli":e.GOOSE_MODE?"goose":e.VSCODE_PID||e.TERM_PROGRAM==="vscode"?e.ROO_CLINE||e.ROO?"vscode-roo":e.CONTINUE_GLOBAL_DIR?"vscode-continue":"vscode-cline":null}function Hr(){let e=[],t=["cursor","claude-desktop","claude-code","vscode-cline","vscode-roo","vscode-continue","windsurf","trae","antigravity","zed","opencode","codex","gemini-cli","goose","kiro"];for(let o of t)Ne(o)&&e.push(o);return e}import eu from"node:path";import tu from"node:fs";function G(e){return Q(e)?jr(e):{mcpServers:{}}}function ee(e,t,o=!0){try{let n;if(o&&Q(e)){let a=Br(e);a&&(n=a)}let s=eu.dirname(e);return T(s)||tu.mkdirSync(s,{recursive:!0,mode:448}),Ur(e,t)?{success:!0,backupPath:n}:{success:!1,error:"Failed to write config file"}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Unknown error"}}}function Lt(e,t){let o;switch(e){case"direct":o={command:"bash",args:["-c",`set -euo pipefail; TMPDIR=$(mktemp -d); trap 'rm -rf "$TMPDIR"' EXIT; curl -fsSL https://octocodeai.com/octocode/latest/index.js -o "$TMPDIR/index.js"; node "$TMPDIR/index.js"`]};break;case"npx":o={command:"npx",args:["octocode-mcp@latest"]};break;default:throw new Error(`Unknown install method: ${e}`)}if(t){let n={};t.enableLocal&&(n.ENABLE_LOCAL="true"),t.githubToken&&(n.GITHUB_TOKEN=t.githubToken),Object.keys(n).length>0&&(o.env=n)}return o}function Co(e,t){if(e==="direct"){let o={command:"powershell",args:["-Command","$tmpDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName()); New-Item -ItemType Directory -Path $tmpDir -Force | Out-Null; $tmpFile = Join-Path $tmpDir 'index.js'; Invoke-WebRequest -Uri 'https://octocodeai.com/octocode/latest/index.js' -OutFile $tmpFile; node $tmpFile; Remove-Item -Recurse -Force $tmpDir"]};if(t){let n={};t.enableLocal&&(n.ENABLE_LOCAL="true"),t.githubToken&&(n.GITHUB_TOKEN=t.githubToken),Object.keys(n).length>0&&(o.env=n)}return o}return Lt(e,t)}function wn(e,t,o){let n=V?Co(t,o):Lt(t,o);return{...e,mcpServers:{...e.mcpServers,octocode:n}}}function Me(e){return!!e.mcpServers?.octocode}function bo(e){let t=e.mcpServers?.octocode;return t?t.command==="npx"?"npx":t.command==="bash"||t.command==="powershell"?"direct":null:null}function Sn(e,t){let o=U(e,t),n=yo(e,t),s=!1,i=null;if(n){let a=G(o);a&&(s=Me(a),i=bo(a))}return{client:e,configExists:n,octocodeInstalled:s,method:i,configPath:o}}function ko(){return["cursor","claude-desktop","claude-code","opencode","vscode-cline","vscode-roo","vscode-continue","windsurf","trae","antigravity","zed"].map(t=>Sn(t))}function Vr(e,t){if(!e.mcpServers?.[t])return e;let o=Object.fromEntries(Object.entries(e.mcpServers).filter(([n])=>n!==t));return{...e,mcpServers:o}}function Pn(e){return e==="claude"?"claude-desktop":e}function ou(e){let t=U(Pn(e));if(!Q(t))return{installed:!1,configPath:t,configExists:!1};let n=G(t);return n?{installed:Me(n),configPath:t,configExists:!0}:{installed:!1,configPath:t,configExists:!0}}function Wr(e){let{ide:t,method:o,force:n=!1}=e,s=U(Pn(t)),i=G(s)||{mcpServers:{}};if(Me(i)&&!n)return{success:!1,configPath:s,alreadyInstalled:!0,error:"Octocode is already configured. Use --force to overwrite."};i=wn(i,o);let a=ee(s,i);return a.success?{success:!0,configPath:s,backupPath:a.backupPath}:{success:!1,configPath:s,error:a.error||"Failed to write config"}}function qr(e,t){let o=U(Pn(e)),n=ou(e),s=G(o),i=V?Co(t):Lt(t),a="create";return n.installed?a="override":n.configExists&&(a="add"),{ide:e,method:t,configPath:o,serverConfig:i,action:a,existingMethod:s?bo(s):null}}function nu(e,t){let o=e==="custom"&&t?t:U(e,t);if(!Q(o))return{installed:!1,configPath:o,configExists:!1};let s=G(o);return s?{installed:Me(s),configPath:o,configExists:!0}:{installed:!1,configPath:o,configExists:!0}}function Kr(e){let{client:t,method:o,customPath:n,force:s=!1,envOptions:i}=e,a=t==="custom"&&n?n:U(t,n),l=G(a)||{mcpServers:{}};if(Me(l)&&!s)return{success:!1,configPath:a,alreadyInstalled:!0,error:"Octocode is already configured. Use --force to overwrite."};l=wn(l,o,i);let u=ee(a,l);return u.success?{success:!0,configPath:a,backupPath:u.backupPath}:{success:!1,configPath:a,error:u.error||"Failed to write config"}}function $n(e,t,o,n){let s=e==="custom"&&o?o:U(e,o),i=nu(e,o),a=G(s),l=V?Co(t,n):Lt(t,n),u="create";return i.installed?u="override":i.configExists&&(u="add"),{client:e,method:t,configPath:s,serverConfig:l,action:u,existingMethod:a?bo(a):null}}import{execSync as zr,exec as su}from"node:child_process";import{promisify as ru}from"node:util";var Tf=ru(su),iu=1e3,au=3e3,lu=4e3;function vo(){try{return{installed:!0,version:zr("node --version",{encoding:"utf-8",timeout:5e3,stdio:["pipe","pipe","pipe"]}).trim()}}catch{return{installed:!1,version:null}}}function wo(){try{return{installed:!0,version:`v${zr("npm --version",{encoding:"utf-8",timeout:5e3,stdio:["pipe","pipe","pipe"]}).trim()}`}}catch{return{installed:!1,version:null}}}async function Xr(){let e="https://registry.npmjs.org";try{let t=Date.now(),o=new AbortController,n=setTimeout(()=>o.abort(),lu),s=await fetch(e,{method:"HEAD",signal:o.signal});clearTimeout(n);let i=Date.now()-t;return s.ok?i>au?{status:"slow",latency:i}:i>iu?{status:"slow",latency:i}:{status:"ok",latency:i}:{status:"failed",latency:i}}catch{return{status:"failed",latency:null}}}var Dt={cursor:{name:"Cursor",description:"AI-first code editor",url:"https://cursor.sh"},"claude-desktop":{name:"Claude Desktop",description:"Anthropic's Claude desktop app",url:"https://claude.ai/download"},"claude-code":{name:"Claude Code",description:"Claude CLI for terminal",url:"https://docs.anthropic.com/claude-code"},opencode:{name:"Opencode",description:"AI coding agent CLI",url:"https://opencode.ai"},"vscode-cline":{name:"Cline (VS Code)",description:"AI coding assistant extension",url:"https://marketplace.visualstudio.com/items?itemName=saoudrizwan.claude-dev"},"vscode-roo":{name:"Roo-Cline (VS Code)",description:"Roo AI coding extension",url:"https://github.com/RooVetGit/Roo-Cline"},"vscode-continue":{name:"Continue (VS Code)",description:"Open-source AI assistant",url:"https://continue.dev"},windsurf:{name:"Windsurf",description:"Codeium AI IDE",url:"https://codeium.com/windsurf"},trae:{name:"Trae",description:"Adaptive AI IDE",url:"https://trae.ai"},antigravity:{name:"Antigravity",description:"Gemini-powered AI IDE",url:"https://antigravity.dev"},zed:{name:"Zed",description:"High-performance code editor",url:"https://zed.dev"},codex:{name:"Codex",description:"OpenAI Codex CLI agent",url:"https://github.com/openai/codex"},"gemini-cli":{name:"Gemini CLI",description:"Google Gemini CLI",url:"https://github.com/google-gemini/gemini-cli"},goose:{name:"Goose",description:"Block AI coding agent",url:"https://block.github.io/goose"},kiro:{name:"Kiro",description:"AWS AI IDE",url:"https://kiro.dev"},custom:{name:"Custom Path",description:"Specify your own MCP config path",url:""},claude:{name:"Claude Desktop",description:"Anthropic's Claude desktop app",url:"https://claude.ai/download"}},xn={cursor:Dt.cursor,claude:Dt.claude},Yr={direct:{name:"Direct (curl)",description:"Download and run directly from octocode.ai",pros:["Always latest version","No npm required"],cons:["Requires curl (or PowerShell on Windows)","Slower startup"]},npx:{name:"NPX",description:"Run via npx from npm registry",pros:["Standard npm workflow","Faster after first run (cached)"],cons:["Requires Node.js/npm"]}};var En=new Set;function So(){process.stdout.write("\x1B[?25h")}var Jr=!1;function cu(){Jr||(Jr=!0,process.on("exit",So),process.on("SIGINT",()=>{So(),process.exit(0)}),process.on("SIGTERM",()=>{So(),process.exit(0)}),process.on("uncaughtException",e=>{So(),console.error("Uncaught exception:",e),process.exit(1)}))}var A=class{text;frames;i;timer;constructor(t=""){this.text=t,this.frames=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],this.i=0,this.timer=null}start(t,o=0){t&&(this.text=t),this.timer&&(clearInterval(this.timer),this.timer=null),cu(),En.add(this),process.stdout.write("\x1B[?25l");let n=" ".repeat(o);return this.timer=setInterval(()=>{let s=this.frames[this.i++%this.frames.length];process.stdout.write(`\r${n}${r("cyan",s)} ${this.text}`)},80),this}clear(){return this.timer&&(clearInterval(this.timer),this.timer=null),En.delete(this),process.stdout.write("\r\x1B[2K"),process.stdout.write("\x1B[?25h"),this}stop(t="\u2713",o="green"){return this.timer&&(clearInterval(this.timer),this.timer=null),En.delete(this),process.stdout.write(`\r\x1B[2K${r(o,t)} ${this.text}
|
|
11
|
-
`),process.stdout.write("\x1B[?25h"),this}succeed(t){return t&&(this.text=t),this.stop("\u2713","green")}fail(t){return t&&(this.text=t),this.stop("\u2717","red")}info(t){return t&&(this.text=t),this.stop("\u2139","blue")}warn(t){return t&&(this.text=t),this.stop("\u26A0","yellow")}update(t){return this.text=t,this}};var ae=(e,t=[])=>e.name==="up"||t.includes("vim")&&e.name==="k"||t.includes("emacs")&&e.ctrl&&e.name==="p",ve=(e,t=[])=>e.name==="down"||t.includes("vim")&&e.name==="j"||t.includes("emacs")&&e.ctrl&&e.name==="n",In=e=>e.name==="space",Rt=e=>e.name==="backspace",Ve=e=>e.name==="tab",_t=e=>"1234567890".includes(e.name),ge=e=>e.name==="enter"||e.name==="return";var Po=class extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(t){super(),this.cause=t?.cause}},$o=class extends Error{name="CancelPromptError";message="Prompt was canceled"},Nt=class extends Error{name="ExitPromptError"},xo=class extends Error{name="HookError"},Fe=class extends Error{name="ValidationError"};import{AsyncResource as gu}from"node:async_hooks";import{AsyncLocalStorage as uu,AsyncResource as du}from"node:async_hooks";var Qr=new uu;function pu(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Zr(e,t){let o=pu(e);return Qr.run(o,()=>{function n(s){o.handleChange=()=>{o.index=0,s()},o.handleChange()}return t(n)})}function We(){let e=Qr.getStore();if(!e)throw new xo("[Inquirer] Hook functions can only be called from within a prompt");return e}function Mn(){return We().rl}function An(e){let t=(...o)=>{let n=We(),s=!1,i=n.handleChange;n.handleChange=()=>{s=!0};let a=e(...o);return s&&i(),n.handleChange=i,a};return du.bind(t)}function yt(e){let t=We(),{index:o}=t,n={get(){return t.hooks[o]},set(i){t.hooks[o]=i},initialized:o in t.hooks},s=e(n);return t.index++,s}function ei(){We().handleChange()}var qe={queue(e){let t=We(),{index:o}=t;t.hooksEffect.push(()=>{t.hooksCleanup[o]?.();let n=e(Mn());if(n!=null&&typeof n!="function")throw new Fe("useEffect return value must be a cleanup function or nothing.");t.hooksCleanup[o]=n})},run(){let e=We();An(()=>{e.hooksEffect.forEach(t=>{t()}),e.hooksEffect.length=0})()},clearAll(){let e=We();e.hooksCleanup.forEach(t=>{t?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function _(e){return yt(t=>{let o=gu.bind(function(i){t.get()!==i&&(t.set(i),ei())});if(t.initialized)return[t.get(),o];let n=typeof e=="function"?e():e;return t.set(n),[n,o]})}function me(e,t){yt(o=>{let n=o.get();(!Array.isArray(n)||t.some((i,a)=>!Object.is(i,n[a])))&&qe.queue(e),o.set(t)})}import{styleText as fe}from"node:util";import we from"node:process";function mu(){return we.platform!=="win32"?we.env.TERM!=="linux":!!we.env.WT_SESSION||!!we.env.TERMINUS_SUBLIME||we.env.ConEmuTask==="{cmd::Cmder}"||we.env.TERM_PROGRAM==="Terminus-Sublime"||we.env.TERM_PROGRAM==="vscode"||we.env.TERM==="xterm-256color"||we.env.TERM==="alacritty"||we.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var ti={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},oi={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},fu={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},hu={...ti,...oi},yu={...ti,...fu},Cu=mu(),bu=Cu?hu:yu,le=bu,Kf=Object.entries(oi);var ni={prefix:{idle:fe("blue","?"),done:fe("green",le.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map(e=>fe("yellow",e))},style:{answer:e=>fe("cyan",e),message:e=>fe("bold",e),error:e=>fe("red",`> ${e}`),defaultAnswer:e=>fe("dim",`(${e})`),help:e=>fe("dim",e),highlight:e=>fe("cyan",e),key:e=>fe("cyan",fe("bold",`<${e}>`))}};function si(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ri(...e){let t={};for(let o of e)for(let[n,s]of Object.entries(o)){let i=t[n];t[n]=si(i)&&si(s)?ri(i,s):s}return t}function ce(...e){let t=[ni,...e.filter(o=>o!=null)];return ri(...t)}function he({status:e="idle",theme:t}){let[o,n]=_(!1),[s,i]=_(0),{prefix:a,spinner:l}=ce(t);return me(()=>{if(e==="loading"){let p,d=-1,m=setTimeout(()=>{n(!0),p=setInterval(()=>{d=d+1,i(d%l.frames.length)},l.interval)},300);return()=>{clearTimeout(m),clearInterval(p)}}else n(!1)},[e]),o?l.frames[s]:typeof a=="string"?a:a[e==="loading"?"idle":e]??a.idle}function Ae(e,t){return yt(o=>{let n=o.get();if(!n||n.dependencies.length!==t.length||n.dependencies.some((s,i)=>s!==t[i])){let s=e();return o.set({value:s,dependencies:t}),s}return n.value})}function Te(e){return _({current:e})[0]}function ye(e){let t=Te(e);t.current=e,me(o=>{let n=!1,s=An((i,a)=>{n||t.current(a,o)});return o.input.on("keypress",s),()=>{n=!0,o.input.removeListener("keypress",s)}},[])}var Si=nn(ai(),1);var li=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let o=0;for(e.lastIndex=0;e.test(t);)o+=1;return t.length-o}})(),ci=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,ui=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141;var wu=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Su=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,di=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,Pu=/\t{1,1000}/y,pi=new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*","yu"),$u=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,xu=new RegExp("\\p{M}+","gu"),Eu={limit:1/0,ellipsis:""},gi=(e,t={},o={})=>{let n=t.limit??1/0,s=t.ellipsis??"",i=t?.ellipsisWidth??(s?gi(s,Eu,o).width:0),a=0,l=o.controlWidth??0,u=o.tabWidth??8,p=o.emojiWidth??2,d=2,m=o.regularWidth??1,f=o.wideWidth??d,C=[[$u,m],[wu,a],[Su,l],[Pu,u],[pi,p],[di,f]],w=0,v=0,h=e.length,k=0,b=!1,$=h,I=Math.max(0,n-i),R=0,N=0,F=0,z=0;e:for(;;){if(N>R||v>=h&&v>w){let S=e.slice(R,N)||e.slice(w,v);k=0;for(let M of S.replaceAll(xu,"")){let P=M.codePointAt(0)||0;if(ci(P)?z=d:ui(P)?z=f:z=m,F+z>I&&($=Math.min($,Math.max(R,w)+k)),F+z>n){b=!0;break e}k+=M.length,F+=z}R=N=0}if(v>=h)break e;for(let S=0,M=C.length;S<M;S++){let[P,O]=C[S];if(P.lastIndex=v,P.test(e)){if(k=P===di?li(e.slice(v,P.lastIndex)):P===pi?1:P.lastIndex-v,z=k*O,F+z>I&&($=Math.min($,v+Math.floor((I-F)/O))),F+z>n){b=!0;break e}F+=z,R=w,N=v,v=w=P.lastIndex;continue e}}v+=1}return{width:b?I:F,index:b?$:h,truncated:b,ellipsed:b&&n>=i}},mi=gi;var Iu={limit:1/0,ellipsis:"",ellipsisWidth:0},Mu=(e,t={})=>mi(e,Iu,t).width,Oe=Mu;var Eo="\x1B",bi="\x9B",Au=39,On="\x07",ki="[",Tu="]",vi="m",Ln=`${Tu}8;;`,fi=new RegExp(`(?:\\${ki}(?<code>\\d+)m|\\${Ln}(?<uri>.*)${On})`,"y"),hi=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},yi=e=>`${Eo}${ki}${e}${vi}`,Ci=e=>`${Eo}${Ln}${e}${On}`,Tn=(e,t,o)=>{let n=t[Symbol.iterator](),s=!1,i=!1,a=e.at(-1),l=a===void 0?0:Oe(a),u=n.next(),p=n.next(),d=0;for(;!u.done;){let m=u.value,f=Oe(m);l+f<=o?e[e.length-1]+=m:(e.push(m),l=0),(m===Eo||m===bi)&&(s=!0,i=t.startsWith(Ln,d+1)),s?i?m===On&&(s=!1,i=!1):m===vi&&(s=!1):(l+=f,l===o&&!p.done&&(e.push(""),l=0)),u=p,p=n.next(),d+=m.length}a=e.at(-1),!l&&a!==void 0&&a.length&&e.length>1&&(e[e.length-2]+=e.pop())},Ou=e=>{let t=e.split(" "),o=t.length;for(;o&&!Oe(t[o-1]);)o--;return o===t.length?e:t.slice(0,o).join(" ")+t.slice(o).join("")},Lu=(e,t,o={})=>{if(o.trim!==!1&&e.trim()==="")return"";let n="",s,i,a=e.split(" "),l=[""],u=0;for(let m=0;m<a.length;m++){let f=a[m];if(o.trim!==!1){let w=l.at(-1)??"",v=w.trimStart();w.length!==v.length&&(l[l.length-1]=v,u=Oe(v))}m!==0&&(u>=t&&(o.wordWrap===!1||o.trim===!1)&&(l.push(""),u=0),(u||o.trim===!1)&&(l[l.length-1]+=" ",u++));let C=Oe(f);if(o.hard&&C>t){let w=t-u,v=1+Math.floor((C-w-1)/t);Math.floor((C-1)/t)<v&&l.push(""),Tn(l,f,t),u=Oe(l.at(-1)??"");continue}if(u+C>t&&u&&C){if(o.wordWrap===!1&&u<t){Tn(l,f,t),u=Oe(l.at(-1)??"");continue}l.push(""),u=0}if(u+C>t&&o.wordWrap===!1){Tn(l,f,t),u=Oe(l.at(-1)??"");continue}l[l.length-1]+=f,u+=C}o.trim!==!1&&(l=l.map(m=>Ou(m)));let p=l.join(`
|
|
12
|
-
`),d=!1;for(let m=0;m<p.length;m++){let f=p[m];if(n+=f,d)d=!1;else if(d=f>="\uD800"&&f<="\uDBFF",d)continue;if(f===Eo||f===bi){fi.lastIndex=m+1;let w=fi.exec(p)?.groups;if(w?.code!==void 0){let v=Number.parseFloat(w.code);s=v===Au?void 0:v}else w?.uri!==void 0&&(i=w.uri.length===0?void 0:w.uri)}if(p[m+1]===`
|
|
13
|
-
`){i&&(n+=Ci(""));let C=s?hi(s):void 0;s&&C&&(n+=yi(C))}else f===`
|
|
14
|
-
`&&(s&&hi(s)&&(n+=yi(s)),i&&(n+=Ci(i)))}return n},Du=/\r?\n/;function wi(e,t,o){return String(e).normalize().split(Du).map(n=>Lu(n,t,o)).join(`
|
|
15
|
-
`)}function Ft(e,t){return e.split(`
|
|
16
|
-
`).flatMap(o=>wi(o,t,{trim:!1,hard:!0}).split(`
|
|
17
|
-
`).map(n=>n.trimEnd())).join(`
|
|
18
|
-
`)}function Io(){return(0,Si.default)({defaultWidth:80,output:Mn().output})}function Ru({active:e,renderedItems:t,pageSize:o,loop:n}){let s=Te({lastPointer:e,lastActive:void 0}),{lastPointer:i,lastActive:a}=s.current,l=Math.floor(o/2),u=t.reduce((m,f)=>m+f.length,0),p=t.slice(0,e).reduce((m,f)=>m+f.length,0),d=p;if(u>o)if(n)d=i,a!=null&&a<e&&e-a<o&&(d=Math.min(l,Math.abs(e-a)===1?Math.min(i+(t[a]?.length??0),Math.max(p,i)):i+e-a));else{let m=t.slice(e).reduce((f,C)=>f+C.length,0);d=m<o-l?o-m:Math.min(p,l)}return s.current.lastPointer=d,s.current.lastActive=e,d}function Ke({items:e,active:t,renderItem:o,pageSize:n,loop:s=!0}){let i=Io(),a=k=>(k%e.length+e.length)%e.length,l=e.map((k,b)=>k==null?[]:Ft(o({item:k,index:b,isActive:b===t}),i).split(`
|
|
19
|
-
`)),u=l.reduce((k,b)=>k+b.length,0),p=k=>l[k]??[],d=Ru({active:t,renderedItems:l,pageSize:n,loop:s}),m=p(t).slice(0,n),f=d+m.length<=n?d:n-m.length,C=Array.from({length:n});C.splice(f,m.length,...m);let w=new Set([t]),v=f+m.length,h=a(t+1);for(;v<n&&!w.has(h)&&(s&&u>n?h!==t:h>t);){let b=p(h).slice(0,n-v);C.splice(v,b.length,...b),w.add(h),v+=b.length,h=a(h+1)}for(v=f-1,h=a(t-1);v>=0&&!w.has(h)&&(s&&u>n?h!==t:h<t);){let k=p(h),b=k.slice(Math.max(0,k.length-v-1));C.splice(v-b.length+1,b.length,...b),w.add(h),v-=b.length,h=a(h-1)}return C.filter(k=>typeof k=="string").join(`
|
|
20
|
-
`)}var Ti=nn($i(),1);import*as Ai from"node:readline";import{AsyncResource as Uu}from"node:async_hooks";var ze=[];ze.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&ze.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ze.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var Mo=e=>!!e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function",Rn=Symbol.for("signal-exit emitter"),_n=globalThis,Nu=Object.defineProperty.bind(Object),Nn=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(_n[Rn])return _n[Rn];Nu(_n,Rn,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,o){this.listeners[t].push(o)}removeListener(t,o){let n=this.listeners[t],s=n.indexOf(o);s!==-1&&(s===0&&n.length===1?n.length=0:n.splice(s,1))}emit(t,o,n){if(this.emitted[t])return!1;this.emitted[t]=!0;let s=!1;for(let i of this.listeners[t])s=i(o,n)===!0||s;return t==="exit"&&(s=this.emit("afterExit",o,n)||s),s}},Ao=class{},Fu=e=>({onExit(t,o){return e.onExit(t,o)},load(){return e.load()},unload(){return e.unload()}}),Fn=class extends Ao{onExit(){return()=>{}}load(){}unload(){}},Bn=class extends Ao{#o=jn.platform==="win32"?"SIGINT":"SIGHUP";#t=new Nn;#e;#r;#i;#s={};#n=!1;constructor(t){super(),this.#e=t,this.#s={};for(let o of ze)this.#s[o]=()=>{let n=this.#e.listeners(o),{count:s}=this.#t,i=t;if(typeof i.__signal_exit_emitter__=="object"&&typeof i.__signal_exit_emitter__.count=="number"&&(s+=i.__signal_exit_emitter__.count),n.length===s){this.unload();let a=this.#t.emit("exit",null,o),l=o==="SIGHUP"?this.#o:o;a||t.kill(t.pid,l)}};this.#i=t.reallyExit,this.#r=t.emit}onExit(t,o){if(!Mo(this.#e))return()=>{};this.#n===!1&&this.load();let n=o?.alwaysLast?"afterExit":"exit";return this.#t.on(n,t),()=>{this.#t.removeListener(n,t),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#n){this.#n=!0,this.#t.count+=1;for(let t of ze)try{let o=this.#s[t];o&&this.#e.on(t,o)}catch{}this.#e.emit=(t,...o)=>this.#l(t,...o),this.#e.reallyExit=t=>this.#a(t)}}unload(){this.#n&&(this.#n=!1,ze.forEach(t=>{let o=this.#s[t];if(!o)throw new Error("Listener not defined for signal: "+t);try{this.#e.removeListener(t,o)}catch{}}),this.#e.emit=this.#r,this.#e.reallyExit=this.#i,this.#t.count-=1)}#a(t){return Mo(this.#e)?(this.#e.exitCode=t||0,this.#t.emit("exit",this.#e.exitCode,null),this.#i.call(this.#e,this.#e.exitCode)):0}#l(t,...o){let n=this.#r;if(t==="exit"&&Mo(this.#e)){typeof o[0]=="number"&&(this.#e.exitCode=o[0]);let s=n.call(this.#e,t,...o);return this.#t.emit("exit",this.#e.exitCode,null),s}else return n.call(this.#e,t,...o)}},jn=globalThis.process,{onExit:xi,load:Mh,unload:Ah}=Fu(Mo(jn)?new Bn(jn):new Fn);import{stripVTControlCharacters as Bu}from"node:util";var To="\x1B[?25l",Ii="\x1B[?25h",Un=(e=1)=>e>0?`\x1B[${e}A`:"",Gn=(e=1)=>e>0?`\x1B[${e}B`:"",Hn=(e,t)=>typeof t=="number"&&!Number.isNaN(t)?`\x1B[${t+1};${e+1}H`:`\x1B[${e+1}G`,Ei="\x1B[2K",Vn=e=>e>0?(Ei+Un(1)).repeat(e-1)+Ei+"\x1B[G":"";var Mi=e=>e.split(`
|
|
21
|
-
`).length,ju=e=>e.split(`
|
|
22
|
-
`).pop()??"",Bt=class{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(t){this.rl=t,this.cursorPos=t.getCursorPos()}write(t){this.rl.output.unmute(),this.rl.output.write(t),this.rl.output.mute()}render(t,o=""){let n=ju(t),s=Bu(n),i=s;this.rl.line.length>0&&(i=i.slice(0,-this.rl.line.length)),this.rl.setPrompt(i),this.cursorPos=this.rl.getCursorPos();let a=Io();t=Ft(t,a),o=Ft(o,a),s.length%a===0&&(t+=`
|
|
23
|
-
`);let l=t+(o?`
|
|
24
|
-
`+o:""),p=Math.floor(s.length/a)-this.cursorPos.rows+(o?Mi(o):0);p>0&&(l+=Un(p)),l+=Hn(this.cursorPos.cols),this.write(Gn(this.extraLinesUnderPrompt)+Vn(this.height)+l),this.extraLinesUnderPrompt=p,this.height=Mi(l)}checkCursorPos(){let t=this.rl.getCursorPos();t.cols!==this.cursorPos.cols&&(this.write(Hn(t.cols)),this.cursorPos=t)}done({clearContent:t}){this.rl.setPrompt("");let o=Gn(this.extraLinesUnderPrompt);o+=t?Vn(this.height):`
|
|
25
|
-
`,o+=Ii,this.write(o),this.rl.close()}};var Oo=class extends Promise{static withResolver(){let t,o;return{promise:new Promise((s,i)=>{t=s,o=i}),resolve:t,reject:o}}};var Gu=globalThis.setImmediate;function Hu(){let e=Error.prepareStackTrace,t=[];try{Error.prepareStackTrace=(o,n)=>{let s=n.slice(1);return t=s,s},new Error().stack}catch{return t}return Error.prepareStackTrace=e,t}function Ce(e){let t=Hu();return(n,s={})=>{let{input:i=process.stdin,signal:a}=s,l=new Set,u=new Ti.default;u.pipe(s.output??process.stdout),u.mute();let p=Ai.createInterface({terminal:!0,input:i,output:u}),d=new Bt(p),{promise:m,resolve:f,reject:C}=Oo.withResolver(),w=()=>C(new $o);if(a){let h=()=>C(new Po({cause:a.reason}));if(a.aborted)return h(),Object.assign(m,{cancel:w});a.addEventListener("abort",h),l.add(()=>a.removeEventListener("abort",h))}l.add(xi((h,k)=>{C(new Nt(`User force closed the prompt with ${h} ${k}`))}));let v=()=>C(new Nt("User force closed the prompt with SIGINT"));return p.on("SIGINT",v),l.add(()=>p.removeListener("SIGINT",v)),Zr(p,h=>{let k=Uu.bind(()=>qe.clearAll());p.on("close",k),l.add(()=>p.removeListener("close",k));let b=()=>{let $=()=>d.checkCursorPos();p.input.on("keypress",$),l.add(()=>p.input.removeListener("keypress",$)),h(()=>{try{let I=e(n,F=>{setImmediate(()=>f(F))});if(I===void 0){let F=t[1]?.getFileName();throw new Error(`Prompt functions must return a string.
|
|
26
|
-
at ${F}`)}let[R,N]=typeof I=="string"?[I]:I;d.render(R,N),qe.run()}catch(I){C(I)}})};return"readableFlowing"in i?Gu(b):b(),Object.assign(m.then($=>(qe.clearAll(),$),$=>{throw qe.clearAll(),$}).finally(()=>{l.forEach($=>$()),d.done({clearContent:!!s.clearPromptOnDone}),u.end()}).then(()=>m),{cancel:w})})}}import{styleText as Vu}from"node:util";var H=class{separator=Vu("dim",Array.from({length:15}).join(le.line));type="separator";constructor(t){t&&(this.separator=t)}static isSeparator(t){return!!(t&&typeof t=="object"&&"type"in t&&t.type==="separator")}};import{styleText as Xe}from"node:util";var Wu={icon:{checked:Xe("green",le.circleFilled),unchecked:le.circle,cursor:le.pointer,disabledChecked:Xe("green",le.circleDouble),disabledUnchecked:"-"},style:{disabled:e=>Xe("dim",e),renderSelectedChoices:e=>e.map(t=>t.short).join(", "),description:e=>Xe("cyan",e),keysHelpTip:e=>e.map(([t,o])=>`${Xe("bold",t)} ${Xe("dim",o)}`).join(Xe("dim"," \u2022 "))},i18n:{disabledError:"This option is disabled and cannot be toggled."},keybindings:[]};function Lo(e){return!H.isSeparator(e)&&!e.disabled}function Wn(e){return!H.isSeparator(e)}function Oi(e){return!H.isSeparator(e)&&e.checked}function qn(e){return Lo(e)?{...e,checked:!e.checked}:e}function qu(e){return function(t){return Lo(t)?{...t,checked:e}:t}}function Ku(e){return e.map(t=>{if(H.isSeparator(t))return t;if(typeof t=="string")return{value:t,name:t,short:t,checkedName:t,disabled:!1,checked:!1};let o=t.name??String(t.value),n={value:t.value,name:o,short:t.short??o,checkedName:t.checkedName??o,disabled:t.disabled??!1,checked:t.checked??!1};return t.description&&(n.description=t.description),n})}var Kn=Ce((e,t)=>{let{pageSize:o=7,loop:n=!0,required:s,validate:i=()=>!0}=e,a={all:"a",invert:"i",...e.shortcuts},l=ce(Wu,e.theme),{keybindings:u}=l,[p,d]=_("idle"),m=he({status:p,theme:l}),[f,C]=_(Ku(e.choices)),w=Ae(()=>{let S=f.findIndex(Wn),M=f.findLastIndex(Wn);if(S===-1)throw new Fe("[checkbox prompt] No selectable choices. All choices are disabled.");return{first:S,last:M}},[f]),[v,h]=_(w.first),[k,b]=_();ye(async S=>{if(ge(S)){let M=f.filter(Oi),P=await i([...M]);s&&!M.length?b("At least one choice must be selected"):P===!0?(d("done"),t(M.map(O=>O.value))):b(P||"You must select a valid value")}else if(ae(S,u)||ve(S,u)){if(k&&b(void 0),n||ae(S,u)&&v!==w.first||ve(S,u)&&v!==w.last){let M=ae(S,u)?-1:1,P=v;do P=(P+M+f.length)%f.length;while(!Wn(f[P]));h(P)}}else if(In(S)){let M=f[v];M&&!H.isSeparator(M)&&(M.disabled?b(l.i18n.disabledError):(b(void 0),C(f.map((P,O)=>O===v?qn(P):P))))}else if(S.name===a.all){let M=f.some(P=>Lo(P)&&!P.checked);C(f.map(qu(M)))}else if(S.name===a.invert)C(f.map(qn));else if(_t(S)){let M=Number(S.name)-1,P=-1,O=f.findIndex(K=>H.isSeparator(K)?!1:(P++,P===M)),j=f[O];j&&Lo(j)&&(h(O),C(f.map((K,X)=>X===O?qn(K):K)))}});let $=l.style.message(e.message,p),I,R=Ke({items:f,active:v,renderItem({item:S,isActive:M}){if(H.isSeparator(S))return` ${S.separator}`;let P=M?l.icon.cursor:" ";if(S.disabled){let X=typeof S.disabled=="string"?S.disabled:"(disabled)",lt=S.checked?l.icon.disabledChecked:l.icon.disabledUnchecked;return l.style.disabled(`${P}${lt} ${S.name} ${X}`)}M&&(I=S.description);let O=S.checked?l.icon.checked:l.icon.unchecked,j=S.checked?S.checkedName:S.name;return(M?l.style.highlight:X=>X)(`${P}${O} ${j}`)},pageSize:o,loop:n});if(p==="done"){let S=f.filter(Oi),M=l.style.answer(l.style.renderSelectedChoices(S,f));return[m,$,M].filter(Boolean).join(" ")}let N=[["\u2191\u2193","navigate"],["space","select"]];a.all&&N.push([a.all,"all"]),a.invert&&N.push([a.invert,"invert"]),N.push(["\u23CE","submit"]);let F=l.style.keysHelpTip(N);return`${[[m,$].filter(Boolean).join(" "),R," ",I?l.style.description(I):"",k?l.style.error(k):"",F].filter(Boolean).join(`
|
|
27
|
-
`).trimEnd()}${To}`});function Li(e,t){let o=t!==!1;return/^(y|yes)/i.test(e)?o=!0:/^(n|no)/i.test(e)&&(o=!1),o}function Di(e){return e?"Yes":"No"}var zn=Ce((e,t)=>{let{transformer:o=Di}=e,[n,s]=_("idle"),[i,a]=_(""),l=ce(e.theme),u=he({status:n,theme:l});ye((f,C)=>{if(n==="idle")if(ge(f)){let w=Li(i,e.default);a(o(w)),s("done"),t(w)}else if(Ve(f)){let w=Di(!Li(i,e.default));C.clearLine(0),C.write(w),a(w)}else a(C.line)});let p=i,d="";n==="done"?p=l.style.answer(i):d=` ${l.style.defaultAnswer(e.default===!1?"y/N":"Y/n")}`;let m=l.style.message(e.message,n);return`${u} ${m}${d} ${p}`});var zu={validationFailureMode:"keep"},Xn=Ce((e,t)=>{let{prefill:o="tab"}=e,n=ce(zu,e.theme),[s,i]=_("idle"),[a,l]=_(String(e.default??"")),[u,p]=_(),[d,m]=_(""),f=he({status:s,theme:n});async function C(b){let{required:$,pattern:I,patternError:R="Invalid input"}=e;return $&&!b?"You must provide a value":I&&!I.test(b)?R:typeof e.validate=="function"?await e.validate(b)||"You must provide a valid value":!0}ye(async(b,$)=>{if(s==="idle")if(ge(b)){let I=d||a;i("loading");let R=await C(I);R===!0?(m(I),i("done"),t(I)):(n.validationFailureMode==="clear"?m(""):$.write(d),p(R),i("idle"))}else Rt(b)&&!d?l(""):Ve(b)&&!d?(l(""),$.clearLine(0),$.write(a),m(a)):(m($.line),p(void 0))}),me(b=>{o==="editable"&&a&&(b.write(a),m(a))},[]);let w=n.style.message(e.message,s),v=d;typeof e.transformer=="function"?v=e.transformer(d,{isFinal:s==="done"}):s==="done"&&(v=n.style.answer(d));let h;a&&s!=="done"&&!d&&(h=n.style.defaultAnswer(a));let k="";return u&&(k=n.style.error(u)),[[f,w,h,v].filter(b=>b!==void 0).join(" "),k]});import{styleText as Ct}from"node:util";var Xu={icon:{cursor:le.pointer},style:{disabled:e=>Ct("dim",`- ${e}`),searchTerm:e=>Ct("cyan",e),description:e=>Ct("cyan",e),keysHelpTip:e=>e.map(([t,o])=>`${Ct("bold",t)} ${Ct("dim",o)}`).join(Ct("dim"," \u2022 "))}};function Do(e){return!H.isSeparator(e)&&!e.disabled}function Yu(e){return e.map(t=>{if(H.isSeparator(t))return t;if(typeof t=="string")return{value:t,name:t,short:t,disabled:!1};let o=t.name??String(t.value),n={value:t.value,name:o,short:t.short??o,disabled:t.disabled??!1};return t.description&&(n.description=t.description),n})}var Yn=Ce((e,t)=>{let{pageSize:o=7,validate:n=()=>!0}=e,s=ce(Xu,e.theme),[i,a]=_("loading"),[l,u]=_(""),[p,d]=_([]),[m,f]=_(),C=Te(!1),w=he({status:i,theme:s}),v=Ae(()=>{let P=p.findIndex(Do),O=p.findLastIndex(Do);return{first:P,last:O}},[p]),[h=v.first,k]=_();me(()=>{let P=new AbortController;return a("loading"),f(void 0),(async()=>{try{let j=await e.source(l||void 0,{signal:P.signal});if(!P.signal.aborted){let K=Yu(j),X;if(!C.current&&"default"in e){let lt=K.findIndex(Ys=>Do(Ys)&&Ys.value===e.default);X=lt===-1?void 0:lt,C.current=!0}k(X),f(void 0),d(K),a("idle")}}catch(j){!P.signal.aborted&&j instanceof Error&&f(j.message)}})(),()=>{P.abort()}},[l]);let b=p[h];ye(async(P,O)=>{if(ge(P))if(b){a("loading");let j=await n(b.value);a("idle"),j===!0?(a("done"),t(b.value)):b.name===l?f(j||"You must provide a valid value"):(O.write(b.name),u(b.name))}else O.write(l);else if(Ve(P)&&b)O.clearLine(0),O.write(b.name),u(b.name);else if(i!=="loading"&&(ae(P)||ve(P))){if(O.clearLine(0),ae(P)&&h!==v.first||ve(P)&&h!==v.last){let j=ae(P)?-1:1,K=h;do K=(K+j+p.length)%p.length;while(!Do(p[K]));k(K)}}else u(O.line)});let $=s.style.message(e.message,i),I=s.style.keysHelpTip([["\u2191\u2193","navigate"],["\u23CE","select"]]),R=Ke({items:p,active:h,renderItem({item:P,isActive:O}){if(H.isSeparator(P))return` ${P.separator}`;if(P.disabled){let X=typeof P.disabled=="string"?P.disabled:"(disabled)";return s.style.disabled(`${P.name} ${X}`)}let j=O?s.style.highlight:X=>X,K=O?s.icon.cursor:" ";return j(`${K} ${P.name}`)},pageSize:o,loop:!1}),N;m?N=s.style.error(m):p.length===0&&l!==""&&i==="idle"&&(N=s.style.error("No results found"));let F;if(i==="done"&&b)return[w,$,s.style.answer(b.short)].filter(Boolean).join(" ").trimEnd();F=s.style.searchTerm(l);let z=b?.description,S=[w,$,F].filter(Boolean).join(" ").trimEnd(),M=[N??R," ",z?s.style.description(z):"",I].filter(Boolean).join(`
|
|
28
|
-
`).trimEnd();return[S,M]});import{styleText as jt}from"node:util";var Ju={icon:{cursor:le.pointer},style:{disabled:e=>jt("dim",e),description:e=>jt("cyan",e),keysHelpTip:e=>e.map(([t,o])=>`${jt("bold",t)} ${jt("dim",o)}`).join(jt("dim"," \u2022 "))},i18n:{disabledError:"This option is disabled and cannot be selected."},indexMode:"hidden",keybindings:[]};function Jn(e){return!H.isSeparator(e)&&!e.disabled}function Qn(e){return!H.isSeparator(e)}function Qu(e){return e.map(t=>{if(H.isSeparator(t))return t;if(typeof t!="object"||t===null||!("value"in t)){let s=String(t);return{value:t,name:s,short:s,disabled:!1}}let o=t.name??String(t.value),n={value:t.value,name:o,short:t.short??o,disabled:t.disabled??!1};return t.description&&(n.description=t.description),n})}var Ro=Ce((e,t)=>{let{loop:o=!0,pageSize:n=7}=e,s=ce(Ju,e.theme),{keybindings:i}=s,[a,l]=_("idle"),u=he({status:a,theme:s}),p=Te(),d=!i.includes("vim"),m=Ae(()=>Qu(e.choices),[e.choices]),f=Ae(()=>{let S=m.findIndex(Qn),M=m.findLastIndex(Qn);if(S===-1)throw new Fe("[select prompt] No selectable choices. All choices are disabled.");return{first:S,last:M}},[m]),C=Ae(()=>"default"in e?m.findIndex(S=>Jn(S)&&S.value===e.default):-1,[e.default,m]),[w,v]=_(C===-1?f.first:C),h=m[w],[k,b]=_();ye((S,M)=>{if(clearTimeout(p.current),k&&b(void 0),ge(S))h.disabled?b(s.i18n.disabledError):(l("done"),t(h.value));else if(ae(S,i)||ve(S,i)){if(M.clearLine(0),o||ae(S,i)&&w!==f.first||ve(S,i)&&w!==f.last){let P=ae(S,i)?-1:1,O=w;do O=(O+P+m.length)%m.length;while(!Qn(m[O]));v(O)}}else if(_t(S)&&!Number.isNaN(Number(M.line))){let P=Number(M.line)-1,O=-1,j=m.findIndex(X=>H.isSeparator(X)?!1:(O++,O===P)),K=m[j];K!=null&&Jn(K)&&v(j),p.current=setTimeout(()=>{M.clearLine(0)},700)}else if(Rt(S))M.clearLine(0);else if(d){let P=M.line.toLowerCase(),O=m.findIndex(j=>H.isSeparator(j)||!Jn(j)?!1:j.name.toLowerCase().startsWith(P));O!==-1&&v(O),p.current=setTimeout(()=>{M.clearLine(0)},700)}}),me(()=>()=>{clearTimeout(p.current)},[]);let $=s.style.message(e.message,a),I=s.style.keysHelpTip([["\u2191\u2193","navigate"],["\u23CE","select"]]),R=0,N=Ke({items:m,active:w,renderItem({item:S,isActive:M,index:P}){if(H.isSeparator(S))return R++,` ${S.separator}`;let O=M?s.icon.cursor:" ",j=s.indexMode==="number"?`${P+1-R}. `:"";if(S.disabled){let X=typeof S.disabled=="string"?S.disabled:"(disabled)",lt=M?s.icon.cursor:"-";return s.style.disabled(`${lt} ${j}${S.name} ${X}`)}return(M?s.style.highlight:X=>X)(`${O} ${j}${S.name}`)},pageSize:n,loop:o});if(a==="done")return[u,$,s.style.answer(h.short)].filter(Boolean).join(" ");let{description:F}=h;return`${[[u,$].filter(Boolean).join(" "),N," ",F?s.style.description(F):"",k?s.style.error(k):"",I].filter(Boolean).join(`
|
|
29
|
-
`).trimEnd()}${To}`});var E=Ro,Ut=zn,q=Xn,_o=Kn,Gt=Yn,x=H;async function W(){}async function Ye(e){return(await Ro)(e)}import{homedir as Zu}from"node:os";import Zn from"node:path";import{spawnSync as Ri}from"node:child_process";function Je(e,t=[]){try{let o=Ri(e,t,{encoding:"utf8",stdio:["pipe","pipe","pipe"],shell:!1,timeout:3e4});return{success:o.status===0,stdout:o.stdout?.trim()||"",stderr:o.stderr?.trim()||"",exitCode:o.status}}catch(o){return{success:!1,stdout:"",stderr:o instanceof Error?o.message:"Unknown error",exitCode:null}}}function _i(e){let t=process.platform==="win32"?"where":"which";return Je(t,[e]).success}function Ni(e,t=[]){try{let o=Ri(e,t,{stdio:"inherit",shell:!1});return{success:o.status===0,exitCode:o.status}}catch{return{success:!1,exitCode:null}}}function Fi(){return{cwd:ed(),ide:td(),git:od()}}function ed(){let e=process.cwd(),t=Zu(),o=Zn.normalize(e),n=Zn.normalize(t);return o.toLowerCase().startsWith(n.toLowerCase())?"~"+o.slice(n.length):e}function td(){let e=process.env;return e.CURSOR_AGENT||e.CURSOR_TRACE_ID?"Cursor":e.TERM_PROGRAM==="vscode"||e.VSCODE_PID?"VS Code":(e.TERM_PROGRAM==="Apple_Terminal","Terminal")}function od(){let e=Je("git",["rev-parse","--show-toplevel"]);if(!e.success)return;let t=Je("git",["branch","--show-current"]);return{root:Zn.basename(e.stdout.trim())||"repo",branch:t.success?t.stdout:"HEAD"}}function nd(){let e=[" \u2584\u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2584"," \u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584"," \u2590\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C"," \u2590\u2588\u2588\u2580 \u2580\u2588\u2588\u2588\u2588\u2580 \u2580\u2588\u2588\u258C"," \u2590\u2588\u2588 \u2584 \u2588\u2588\u2588\u2588 \u2584 \u2588\u2588\u258C"," \u2590\u2588\u2588\u2588\u2588\u2584\u2584\u2580\u2580\u2580\u2580\u2584\u2584\u2588\u2588\u2588\u2588\u258C"," \u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580"," \u2584\u2584\u2584\u2588\u2588\u2588\u2588\u2580\u2580 \u2580\u2580\u2588\u2588\u2588\u2588\u2584\u2584\u2584"," \u2584\u2588\u2588\u2588\u2588\u2580\u2580\u2584\u2584\u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2584\u2584\u2580\u2580\u2588\u2588\u2588\u2588\u2584","\u2590\u2588\u2588\u258C \u2584\u2588\u2588\u2580\u2580 \u2580\u2580\u2588\u2588\u2584 \u2590\u2588\u2588\u258C"," \u2580\u2580 \u2590\u2588\u2588\u258C \u2590\u2588\u2588\u258C \u2580\u2580"," \u2580\u2580 \u2580\u2580"];for(let t of e)console.log(r("magenta"," "+t))}function sd(){let e=[" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557","\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D","\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2557 ","\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D ","\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557"," \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D"];for(let t of e)console.log(r("magenta"," "+t))}function No(){console.log(),nd(),console.log(),sd(),console.log(),console.log();try{let e=Fi(),t=e.ide==="Cursor"||e.ide==="VS Code",o=`${c("Path")} ${e.cwd}`,n=t?`${c("IDE")} ${g(e.ide)}`:"",s=e.git?`${e.git.root} ${c("(")}${e.git.branch}${c(")")}`:"",i=[n,s].filter(Boolean).join(" ");console.log(` ${o}${i?` ${i}`:""}`),console.log()}catch{console.log()}}function Fo(){console.log(),console.log(` ${r("cyan","Tip")} ${g("Quick tips for better AI coding with Octocode:")}`),console.log(),console.log(` ${r("green","-")} ${c("Prompts:")} Use ${r("cyan","/research")}, ${r("cyan","/plan")}, ${r("cyan","/implement")} in chat`),console.log(` ${r("green","-")} ${c("Skills:")} Add all via ${r("cyan","Octocode Skills")} or ${r("cyan","Manage System Skills")} -> ${r("cyan","Browse Marketplace")}`),console.log(` ${r("green","-")} ${c("Context:")} Add ${r("cyan","AGENTS.md")} to your project ${c("(you can ask octocode)")}`),console.log(),console.log(` Search${r("underscore","https://octocode.ai")}`),console.log()}import es from"node:path";function ji(e){return e.octocodeInstalled?r("green","\u2705 installed"):e.configExists?r("blue","\u25CB Ready"):Ne(e.client)?r("dim","\u25CB Available"):r("dim","\u25CB Not found")}function Ui(){return["cursor","claude-desktop","claude-code","opencode","codex","gemini-cli","windsurf","trae","antigravity","goose","kiro","zed","vscode-cline","vscode-roo","vscode-continue"].map(t=>({clientId:t,status:Sn(t),isAvailable:Ne(t)}))}async function Ht(){let e=ht(),t=Ui(),o=t.filter(s=>s.status.octocodeInstalled),n=t.filter(s=>s.isAvailable&&!s.status.octocodeInstalled);return o.length===0?await rd(n,e):await Gi(o,n,e)}async function rd(e,t){if(console.log(),console.log(r("yellow"," \u250C"+"\u2500".repeat(60)+"\u2510")),console.log(r("yellow"," \u2502 ")+`${r("yellow","INFO")} No octocode configurations found`+" ".repeat(24)+r("yellow","\u2502")),console.log(r("yellow"," \u2514"+"\u2500".repeat(60)+"\u2518")),console.log(),console.log(` ${c("Octocode is not configured in any MCP client yet.")}`),console.log(),e.length===0){console.log(` ${r("red","X")} ${c("No MCP clients detected on this system.")}`),console.log(),console.log(` ${c("Supported clients:")}`),console.log(` ${c("\u2022 Cursor, Claude Desktop, Claude Code")}`),console.log(` ${c("\u2022 Windsurf, Zed, VS Code (Cline/Roo/Continue)")}`),console.log(),console.log(` ${c("Install a supported client and try again,")}`),console.log(` ${c('or use "Custom Path" to specify a config file.')}`),console.log();let s=[{name:`${r("cyan","-")} Custom Path - ${c("Specify your own MCP config path")}`,value:"custom"},new x,{name:`${r("dim","- Back")}`,value:"back"}],i=await E({message:"What would you like to do?",choices:s,loop:!1});if(i==="back")return null;if(i==="custom"){let a=await ts();return a?{client:"custom",customPath:a}:null}return null}let o=[];for(let{clientId:s,status:i}of e){let a=D[s],l=`${a.name} - ${c(a.description)}`;l+=` ${ji(i)}`,t===s&&(l=`${r("green","\u2605")} ${l} ${r("yellow","(Current)")}`),o.push({name:l,value:s})}o.sort((s,i)=>t===s.value?-1:t===i.value?1:0),o.push(new x),o.push({name:`${r("cyan","-")} Custom Path - ${c("Specify your own MCP config path")}`,value:"custom"}),o.push(new x),o.push({name:`${r("dim","- Back")}`,value:"back"});let n=await E({message:"Select a client to install Octocode:",choices:o,loop:!1});if(n==="back")return null;if(n==="custom"){let s=await ts();return s?{client:"custom",customPath:s}:null}return{client:n}}async function Gi(e,t,o){console.log(),console.log(` ${r("green","\u2705")} Found ${g(String(e.length))} octocode configuration${e.length>1?"s":""}`),console.log();let n=[];for(let{clientId:i}of e){let a=D[i],l=`${r("green","\u2705")} ${a.name} - ${c("View/Edit configuration")}`;o===i&&(l+=` ${r("yellow","(Current)")}`),n.push({name:l,value:i})}n.sort((i,a)=>o===i.value?-1:o===a.value?1:0),t.length>0&&(n.push(new x),n.push({name:`${r("blue","+")} Install to another client - ${c(`${t.length} available`)}`,value:"install-new"})),n.push(new x),n.push({name:`${r("cyan","-")} Custom Path - ${c("Specify your own MCP config path")}`,value:"custom"}),n.push(new x),n.push({name:`${r("dim","- Back")}`,value:"back"});let s=await E({message:"Select configuration to manage:",choices:n,loop:!1});if(s==="back")return null;if(s==="install-new")return await id(t,o);if(s==="custom"){let i=await ts();return i?{client:"custom",customPath:i}:null}return{client:s}}async function id(e,t){console.log(),console.log(` ${r("blue","INFO")} Select a client for new installation:`),console.log();let o=[];for(let{clientId:s,status:i}of e){let a=D[s],l=`${a.name} - ${c(a.description)}`;l+=` ${ji(i)}`,t===s&&(l=`${r("green","\u2605")} ${l} ${r("yellow","(Current)")}`),o.push({name:l,value:s})}o.sort((s,i)=>t===s.value?-1:t===i.value?1:0),o.push(new x),o.push({name:`${r("dim","- Back to configurations")}`,value:"back"});let n=await E({message:"Select client to install Octocode:",choices:o,loop:!1});if(n==="back"){let i=Ui().filter(a=>a.status.octocodeInstalled);return await Gi(i,e,t)}return{client:n}}function Bi(e){if(e.startsWith("~")){let t=process.env.HOME||process.env.USERPROFILE||"";return es.join(t,e.slice(1))}return e}async function ts(){console.log(),console.log(` ${r("blue","INFO")} Enter the full path to your MCP config file (JSON)`),console.log(` ${c("Leave empty to go back")}`),console.log(),console.log(` ${c("Common paths:")}`),console.log(` ${c("\u2022")} ~/.cursor/mcp.json ${c("(Cursor)")}`),console.log(` ${c("\u2022")} ~/Library/Application Support/Claude/claude_desktop_config.json`),console.log(` ${c("(Claude Desktop)")}`),console.log(` ${c("\u2022")} ~/.claude.json ${c("(Claude Code)")}`),console.log(` ${c("\u2022")} ~/.config/opencode/config.json ${c("(Opencode)")}`),console.log(` ${c("\u2022")} ~/.codeium/windsurf/mcp_config.json ${c("(Windsurf)")}`),console.log(` ${c("\u2022")} ~/Library/Application Support/Trae/mcp.json ${c("(Trae)")}`),console.log(` ${c("\u2022")} ~/.gemini/antigravity/mcp_config.json ${c("(Antigravity)")}`),console.log(` ${c("\u2022")} ~/.config/zed/settings.json ${c("(Zed)")}`),console.log(` ${c("\u2022")} ~/.continue/config.json ${c("(Continue)")}`),console.log(` ${c("\u2022")} ~/.codex/config.toml ${c("(Codex - TOML format)")}`),console.log(` ${c("\u2022")} ~/.gemini/settings.json ${c("(Gemini CLI)")}`),console.log(` ${c("\u2022")} ~/.kiro/mcp.json ${c("(Kiro)")}`),console.log();let e=await q({message:"MCP config path (or press Enter to go back):",validate:t=>{if(!t.trim())return!0;let o=Bi(t);if(!o.endsWith(".json"))return"Path must be a .json file (e.g., mcp.json, config.json)";if(!es.isAbsolute(o))return"Please provide an absolute path (starting with / or ~)";let n=es.dirname(o);return T(n)?!0:`Parent directory does not exist: ${n}
|
|
30
|
-
Create it first or choose a different location.`}});return!e||!e.trim()?null:Bi(e)}async function Hi(){console.log(),console.log(` ${r("blue","INFO")} ${g("Local Tools")}`),console.log(` ${c("Enable local filesystem tools for searching and reading files")}`),console.log(` ${c("in your local codebase.")}`),console.log();let e=await E({message:"Enable local tools?",choices:[{name:`${r("green","\u25CF")} Disable ${c("(Recommended)")} - ${c("Use only GitHub tools")}`,value:"disable"},{name:`${r("yellow","\u25CB")} Enable - ${c("Allow local file exploration")}`,value:"enable"},new x,{name:`${r("dim","- Back")}`,value:"back"}],loop:!1});return e==="back"?null:e==="enable"}async function Vi(){console.log(),console.log(` ${r("blue","INFO")} ${g("GitHub Authentication")}`),console.log(` ${c("Required for accessing GitHub repositories.")}`),console.log();let e=await E({message:"How would you like to authenticate with GitHub?",choices:[{name:`${r("green","\u25CF")} gh CLI ${c("(Recommended)")} - ${c("Uses existing gh auth")}`,value:"gh-cli"},{name:`${r("yellow","\u25CF")} GITHUB_TOKEN - ${c("Enter personal access token")}`,value:"token"},{name:`${r("dim","\u25CB")} Skip - ${c("Configure manually later")}`,value:"skip"},new x,{name:`${r("dim","- Back")}`,value:"back"}],loop:!1});if(e==="back")return null;if(e==="gh-cli")return console.log(),console.log(` ${r("cyan","->")} Make sure gh CLI is installed and authenticated:`),console.log(` ${c("https://cli.github.com/")}`),console.log(),console.log(` ${c("Run")} ${r("cyan","gh auth login")} ${c("if not already authenticated.")}`),console.log(),{method:"gh-cli"};if(e==="token"){console.log(),console.log(` ${c("Leave empty and press Enter to go back")}`),console.log();let t=await q({message:"Enter your GitHub personal access token:",validate:o=>o.trim()&&o.length<20?"Token appears too short":!0});return!t||!t.trim()?null:(console.log(),console.log(` ${r("yellow","WARN")} ${g("Security Note:")}`),console.log(` ${c("Your token will be saved in the MCP configuration file.")}`),console.log(` ${c("Make sure this file is not committed to version control.")}`),console.log(),{method:"token",token:t})}return{method:"skip"}}function Wi(e){let t=e.env&&Object.keys(e.env).length>0,o=e.args??[];if(console.log(),console.log(r("dim"," {")),console.log(r("dim",' "mcpServers": {')),console.log(r("magenta",' "octocode"')+r("dim",": {")),console.log(r("dim",' "command": ')+r("green",`"${e.command}"`)+r("dim",",")),console.log(r("dim",' "args": [')),o.forEach((n,s)=>{let i=s===o.length-1,a=n.length>50?n.slice(0,47)+"...":n;console.log(r("dim"," ")+r("green",`"${a}"`)+(i&&!t?"":r("dim",",")))}),console.log(r("dim"," ]")+(t?r("dim",","):"")),t&&e.env){console.log(r("dim",' "env": {'));let n=Object.entries(e.env);n.forEach(([s,i],a)=>{let l=a===n.length-1,u=s.toLowerCase(),d=u.includes("token")||u.includes("secret")?"***":i;console.log(r("dim"," ")+r("cyan",`"${s}"`)+r("dim",": ")+r("green",`"${d}"`)+(l?"":r("dim",",")))}),console.log(r("dim"," }"))}console.log(r("dim"," }")),console.log(r("dim"," }")),console.log(r("dim"," }")),console.log()}function qi(e){console.log(),console.log(` ${r("red","X")} ${g("Installation failed")}`),e.error&&console.log(` ${c("Error:")} ${e.error}`),console.log()}function Ki(e){console.log(),console.log(r("cyan"," \u250C"+"\u2500".repeat(60)+"\u2510"));let o;if(e.url)o=e.url;else{let a=e.args??[];o=e.command?`${e.command} ${a.join(" ")}`.trim():"(no command configured)"}let n=56,s=o.length>n?o.slice(0,n-3)+"...":o,i=Math.max(0,58-s.length);if(console.log(r("cyan"," \u2502 ")+c(s)+" ".repeat(i)+r("cyan","\u2502")),e.env&&Object.keys(e.env).length>0){console.log(r("cyan"," \u2502")+" ".repeat(60)+r("cyan","\u2502"));let a="Environment:",l=58-a.length;console.log(r("cyan"," \u2502 ")+g(a)+" ".repeat(l)+r("cyan","\u2502"));for(let[u,p]of Object.entries(e.env)){let d=u.toLowerCase(),f=d.includes("token")||d.includes("secret")?"***":p,C=` ${u}: ${f}`,w=C.length>n?C.slice(0,n-3)+"...":C,v=Math.max(0,58-w.length);console.log(r("cyan"," \u2502 ")+c(w)+" ".repeat(v)+r("cyan","\u2502"))}}console.log(r("cyan"," \u2514"+"\u2500".repeat(60)+"\u2518"))}async function os(){await W(),console.log(),console.log(r("blue","\u2501".repeat(66))),console.log(` ${g("Configure MCP server for your environment")}`),console.log(r("blue","\u2501".repeat(66))),console.log();let e={client:null,hasExistingOctocode:!1,enableLocal:!1,githubAuth:{method:"skip"}},t="client";for(;t!=="done";)switch(t){case"client":{let o=await Ht();if(!o)return;e.client=o.client,e.customPath=o.customPath;let n=e.customPath||U(e.client),s=G(n);e.hasExistingOctocode=!!s?.mcpServers?.octocode,e.hasExistingOctocode?t="updateConfirm":t="localTools";break}case"updateConfirm":{let o=e.customPath||U(e.client),n=G(o);console.log(),console.log(r("yellow"," \u250C"+"\u2500".repeat(60)+"\u2510")),console.log(r("yellow"," \u2502 ")+`${r("yellow","WARN")} ${g("Octocode is already configured!")}`+" ".repeat(28)+r("yellow","\u2502")),console.log(r("yellow"," \u2514"+"\u2500".repeat(60)+"\u2518")),console.log(),console.log(` ${g("Current octocode configuration:")}`),Ki(n.mcpServers.octocode),console.log(),console.log(` ${c("Config file:")} ${r("cyan",o)}`),console.log(),await E({message:"What would you like to do?",choices:[{name:`${r("green","\u2705")} Update existing configuration`,value:"update"},new x,{name:`${r("dim","- Back to client selection")}`,value:"back"}],loop:!1})==="back"?t="client":t="localTools";break}case"localTools":{let o=await Hi();o===null?t=e.hasExistingOctocode?"updateConfirm":"client":(e.enableLocal=o,t="githubAuth");break}case"githubAuth":{let o=await Vi();o===null?t="localTools":(e.githubAuth=o,t="confirm");break}case"confirm":{let o=await ad(e);if(o==="proceed")t="install";else if(o==="back")t="githubAuth";else{console.log(` ${c("Configuration cancelled.")}`);return}break}case"install":{await ld(e),t="done";break}default:break}}async function ad(e){let t=D[e.client],o="npx",n={};e.enableLocal&&(n.enableLocal=!0),e.githubAuth.method==="token"&&e.githubAuth.token&&(n.githubToken=e.githubAuth.token);let s=$n(e.client,o,e.customPath,n);console.log(),e.hasExistingOctocode?console.log(` ${r("yellow","WARN")} Will ${r("yellow","UPDATE")} existing octocode configuration`):s.action==="add"?console.log(` ${r("blue","INFO")} Config file exists, will ${r("green","ADD")} octocode entry`):console.log(` ${r("green","\u2705")} Will ${r("green","CREATE")} new config file`),console.log(),console.log(r("blue"," \u250C"+"\u2500".repeat(60)+"\u2510")),console.log(r("blue"," \u2502 ")+g("Configuration to be added:")+" ".repeat(33)+r("blue","\u2502")),console.log(r("blue"," \u2514"+"\u2500".repeat(60)+"\u2518")),Wi(s.serverConfig),console.log(),console.log(` ${g("Summary:")}`),console.log(` ${c("Client:")} ${t.name}`),console.log(` ${c("Method:")} npx (octocode-mcp@latest)`);let i=e.enableLocal?r("green","Enabled"):r("dim","Disabled");console.log(` ${c("Local Tools:")} ${i}`);let a;e.githubAuth.method==="token"?a=r("green","Token configured"):e.githubAuth.method==="gh-cli"?a=r("cyan","Using gh CLI"):a=r("dim","Not configured"),console.log(` ${c("GitHub Auth:")} ${a}`);let l;return e.hasExistingOctocode?l=r("yellow","UPDATE"):s.action==="add"?l=r("green","ADD"):l=r("green","CREATE"),console.log(` ${c("Action:")} ${l}`),console.log(),console.log(` ${r("yellow","WARN")} ${g("Note:")}`),console.log(` ${c("Nothing is saved to any server. Configuration is stored locally at:")}`),console.log(` ${r("cyan",s.configPath)}`),console.log(),await E({message:"What would you like to do?",choices:[{name:`${r("green","\u2705")} Proceed with configuration`,value:"proceed"},new x,{name:`${r("dim","- Back to edit options")}`,value:"back"},{name:`${r("dim","X Cancel")}`,value:"cancel"}],loop:!1})}async function ld(e){let o={};e.enableLocal&&(o.enableLocal=!0),e.githubAuth.method==="token"&&e.githubAuth.token&&(o.githubToken=e.githubAuth.token);let n=$n(e.client,"npx",e.customPath,o),s=new A("Configuring octocode-mcp...").start(),i=Kr({client:e.client,method:"npx",customPath:e.customPath,force:e.hasExistingOctocode,envOptions:o});i.success?(s.succeed("Octocode configured successfully!"),cd(i,e.client,n.configPath)):(s.fail("Configuration failed"),qi(i))}function cd(e,t,o){let n=D[t];console.log(),console.log(r("green"," \u250C"+"\u2500".repeat(60)+"\u2510")),console.log(r("green"," \u2502 ")+`${r("green","\u2705")} ${g("Octocode installed successfully!")}`+" ".repeat(26)+r("green","\u2502")),console.log(r("green"," \u2514"+"\u2500".repeat(60)+"\u2518")),console.log(),console.log(` ${g("Configuration saved to:")}`),console.log(` ${r("cyan",o)}`),console.log(),e.backupPath&&(console.log(` ${c("Backup saved to:")} ${e.backupPath}`),console.log()),console.log(` ${g("Next steps:")}`),console.log(` 1. Restart ${n?.name||t}`),console.log(` 2. Look for ${r("cyan","octocode")} in MCP servers`),console.log()}var Se=null;function zi(e,t){console.log(e?` ${r("green","\u2705")} Node ${g(t||"unknown")}`:` ${r("red","X")} Node ${r("red","not found")}`)}function Xi(e,t){console.log(e?` ${r("green","\u2705")} npm ${g(t||"unknown")}`:` ${r("yellow","WARN")} npm ${r("yellow","not found")}`)}function Yi(e,t){let o=t!==null?`(${t}ms)`:"";switch(e){case"ok":console.log(` ${r("green","\u2705")} Registry ${c(o)}`);break;case"slow":console.log(` ${r("yellow","WARN")} Registry ${r("yellow","slow")} ${c(o)}`);break;case"failed":console.log(` ${r("red","X")} Registry ${r("red","unreachable")} ${t!==null?c(o):""}`);break;default:break}}async function Vt(){if(Se)return zi(Se.nodeInstalled,Se.nodeVersion),Xi(Se.npmInstalled,Se.npmVersion),Yi(Se.registryStatus,Se.registryLatency),Se;let e=vo();zi(e.installed,e.version);let t=wo();Xi(t.installed,t.version);let o=new A(" Registry: Checking...").start(),n=await Xr();return o.clear(),Yi(n.status,n.latency),Se={nodeInstalled:e.installed,nodeVersion:e.version,npmInstalled:t.installed,npmVersion:t.version,registryStatus:n.status,registryLatency:n.latency,octocodePackageAvailable:t.installed&&n.status==="ok",octocodePackageVersion:null},Se}function ns(){console.log(` ${c("For deeper diagnostics:")} ${r("cyan","npx node-doctor")}`)}function Wt(e){return!e.nodeInstalled||!e.npmInstalled||e.registryStatus==="slow"||e.registryStatus==="failed"}function ud(e){let t=D[e.client]?.name||e.client;return e.octocodeInstalled?`${t} ${c("(Octocode installed)")}`:t}async function dd(e,t,o){if(console.log(),console.log(r("blue","\u2501".repeat(66))),console.log(` ${g("MCP Server Details")}`),console.log(r("blue","\u2501".repeat(66))),console.log(),console.log(` ${c("ID:")} ${r("cyan",t)}`),console.log(` ${c("Command:")} ${r("green",o.command||"unknown")}`),o.args&&o.args.length>0&&(console.log(` ${c("Args:")}`),o.args.forEach(s=>{console.log(` ${s}`)})),o.env&&Object.keys(o.env).length>0&&(console.log(` ${c("Environment:")}`),Object.entries(o.env).forEach(([s,i])=>{let l=s.includes("KEY")||s.includes("TOKEN")||s.includes("SECRET")?"********":i;console.log(` ${s}=${l}`)})),console.log(),await E({message:"",choices:[{name:`${r("red","Delete")} - Remove Server`,value:"remove",description:"Remove this server from configuration"},new x,{name:`${r("dim","- Back")}`,value:"back"}],loop:!1,theme:{prefix:" ",style:{highlight:s=>r("cyan",s)}}})==="remove"&&await Ut({message:`Are you sure you want to remove "${t}" from ${D[e.client]?.name}?`,default:!1})){let i=e.configPath,a=G(i);if(a){let l=new A("Removing server...").start(),u=Vr(a,t),p=ee(i,u);p.success?l.succeed(`Removed ${t}`):l.fail(`Failed to remove: ${p.error}`),console.log(),await new Promise(d=>setTimeout(d,1e3))}}}async function pd(e){let t=!0;for(;t;){let o=e.configPath,n=G(o);if(!n||!n.mcpServers){console.log(),console.log(` ${r("yellow","WARN")} No MCP configuration found or empty.`),console.log(),await new Promise(l=>setTimeout(l,1500));return}let s=Object.keys(n.mcpServers);if(s.length===0){console.log(),console.log(` ${r("yellow","WARN")} No MCP servers configured.`),console.log(),await new Promise(l=>setTimeout(l,1500));return}console.log(),console.log(` ${g(D[e.client]?.name||e.client)}`),console.log(` ${c(o)}`),console.log();let i=s.map(l=>({name:l==="octocode"?`${l}`:`MCP ${l}`,value:l,description:n.mcpServers[l].command}));i.push(new x),i.push({name:`${r("dim","- Back")}`,value:"back"});let a=await E({message:"Select an MCP server to inspect:",choices:i,pageSize:10,loop:!1,theme:{prefix:" ",style:{highlight:l=>r("cyan",l),message:l=>g(l)}}});a==="back"?t=!1:await dd(e,a,n.mcpServers[a])}}async function ss(){await W();let e=!0;for(;e;){let o=ko().filter(i=>i.configExists);if(o.length===0){console.log(),console.log(` ${r("yellow","WARN")} No configured MCP clients found.`),console.log();return}console.log(),console.log(r("blue","\u2501".repeat(66))),console.log(` Info: ${g("MCP Configuration Details")}`),console.log(r("blue","\u2501".repeat(66))),console.log();let n=o.map(i=>({name:ud(i),value:i.client,description:i.configPath}));n.push(new x),n.push({name:`${r("dim","- Back")}`,value:"back"});let s=await E({message:"Select a client to inspect:",choices:n,pageSize:10,loop:!1,theme:{prefix:" ",style:{highlight:i=>r("cyan",i),message:i=>g(i)}}});if(s==="back")e=!1;else{let i=o.find(a=>a.client===s);i&&await pd(i)}}}var Ji={github:[{id:"githubSearchCode",name:"Search Code",description:"Search for code patterns in GitHub repositories"},{id:"githubGetFileContent",name:"Get File Content",description:"Fetch file content from GitHub repositories"},{id:"githubViewRepoStructure",name:"View Repo Structure",description:"Browse repository directory structure"},{id:"githubSearchRepositories",name:"Search Repositories",description:"Search for GitHub repositories"},{id:"githubSearchPullRequests",name:"Search Pull Requests",description:"Search for pull requests and view diffs"},{id:"packageSearch",name:"Package Search",description:"Search npm/Python packages and find their repos"}],local:[{id:"localSearchCode",name:"Ripgrep Search",description:"Fast content search with regex support"},{id:"localViewStructure",name:"View Structure",description:"Browse local directory structure"},{id:"localFindFiles",name:"Find Files",description:"Find files by name, time, size, permissions"},{id:"localGetFileContent",name:"Fetch Content",description:"Read targeted sections of local files"}]},Qe=[{id:"enableLocal",envVar:"ENABLE_LOCAL",name:"Local File Tools",description:"Enable local file exploration tools for searching and browsing local files",type:"boolean",defaultValue:"false"},{id:"githubApiUrl",envVar:"GITHUB_API_URL",name:"GitHub API URL",description:"Custom GitHub API endpoint (for GitHub Enterprise)",type:"string",defaultValue:"https://api.github.com"},{id:"toolsToRun",envVar:"TOOLS_TO_RUN",name:"Tools to Run",description:"Specific tools to enable (all others disabled)",type:"array",defaultValue:"",toolCategory:"all"},{id:"enableTools",envVar:"ENABLE_TOOLS",name:"Enable Tools",description:"Additional tools to enable",type:"array",defaultValue:"",toolCategory:"all"},{id:"disableTools",envVar:"DISABLE_TOOLS",name:"Disable Tools",description:"Tools to disable",type:"array",defaultValue:"",toolCategory:"all"},{id:"requestTimeout",envVar:"REQUEST_TIMEOUT",name:"Request Timeout",description:"API request timeout in milliseconds",type:"number",defaultValue:"30000",validation:{min:3e4,max:6e5}},{id:"maxRetries",envVar:"MAX_RETRIES",name:"Max Retries",description:"Maximum number of API retry attempts",type:"number",defaultValue:"3",validation:{min:0,max:10}}];function gd(){return[...Ji.github.map(e=>({...e,category:"github"})),...Ji.local.map(e=>({...e,category:"local"}))]}function qt(e,t){let o=e[t.envVar];return o==null||o===""?t.defaultValue:o}function Bo(e,t,o=!1){let n=o?r("yellow"," \u2022"):"";if(e.type==="boolean"){let s=t==="1"||t.toLowerCase()==="true",i=s?r("green","\u2705"):r("dim","\u25CB"),a=s?r("green","enabled"):r("dim","disabled");return`${i} ${a}${n}`}if(e.type==="array"){if(!t||t===""){let a=e.id==="toolsToRun"?"(all tools)":"(none)";return`${r("dim","\u25CB")} ${r("dim",a)}${n}`}let s=t.split(",").filter(a=>a.trim()),i=s.length>2?`${s.slice(0,2).join(", ")} ${r("dim",`+${s.length-2} more`)}`:s.join(", ");return`${r("green","\u25CF")} ${i}${n}`}return e.type==="number"?t===e.defaultValue?`${r("dim","\u25CB")} ${t} ${r("dim","(default)")}${n}`:`${r("cyan","\u25CF")} ${r("cyan",t)}${n}`:t===e.defaultValue?`${r("dim","\u25CB")} ${r("dim",t)}${n}`:`${r("cyan","\u25CF")} ${r("cyan",t)}${n}`}function md(e){return e==="1"||e.toLowerCase()==="true"}async function fd(){return await E({message:"",choices:[{name:"- Edit configuration",value:"edit",description:"Configure all octocode-mcp settings for a client"},{name:"- View all configuration options",value:"view",description:"Show available environment variables and their defaults"},{name:"- Show current JSON config",value:"show-json",description:"Display the actual MCP config JSON for a client"},new x,{name:`${r("dim","- Back to main menu")}`,value:"back"}],pageSize:10,loop:!1,theme:{prefix:" ",style:{highlight:t=>r("cyan",t)}}})}async function Qi(){switch(await W(),await fd()){case"view":Ed(),await hd();break;case"edit":await Sd();break;case"show-json":await Pd();break;default:break}}async function hd(){console.log(),await q({message:c("Press Enter to continue..."),default:""})}async function Zi(e){console.log();let t=await E({message:"Open config file?",choices:[{name:"- Open in Cursor",value:"cursor",description:"Open in Cursor IDE"},{name:"- Open in VS Code",value:"vscode",description:"Open in Visual Studio Code"},{name:"- Open in default app",value:"default",description:"Open with system default application"},new x,{name:`${r("dim","- Skip")}`,value:"no"}],pageSize:10,loop:!1,theme:{prefix:" ",style:{highlight:n=>r("cyan",n),message:n=>g(n)}}});if(t==="no")return;Fr(e,t)?console.log(` ${r("green","\u2705")} Opened ${e}`):(console.log(` ${r("yellow","WARN")} Could not open file automatically`),console.log(` ${c("Try opening manually:")} ${r("cyan",e)}`)),console.log()}async function yd(e,t){let n=md(t)?r("green","enabled"):r("dim","disabled");console.log(),console.log(` ${g(e.name)}`),console.log(` ${c(e.description)}`),console.log(` ${c("Current:")} ${n}`),console.log();let s=await E({message:`${e.name}:`,choices:[{name:`${r("green","\u2705")} Enable`,value:"enable"},{name:`${r("yellow","\u25CB")} Disable`,value:"disable"},new x,{name:`${r("dim","- Cancel")}`,value:"cancel"}],loop:!1});return s==="cancel"?null:s==="enable"?"1":"false"}async function Cd(e,t){let o=t&&t!==e.defaultValue?r("cyan",t):r("dim",t||e.defaultValue);console.log(),console.log(` ${g(e.name)}`),console.log(` ${c(e.description)}`),console.log(` ${c("Current:")} ${o}`),console.log(` ${c("Default:")} ${e.defaultValue}`),console.log(` ${c("(Leave empty and press Enter to cancel)")}`),console.log();let n=await q({message:`${e.name}:`,default:"",validate:s=>s.trim()&&e.validation?.pattern&&!e.validation.pattern.test(s)?"Invalid format":!0});return n.trim()?n===e.defaultValue?"":n:null}async function bd(e,t){let o=t&&t!==e.defaultValue?r("cyan",t):r("dim",t||e.defaultValue);if(console.log(),console.log(` ${g(e.name)}`),console.log(` ${c(e.description)}`),console.log(` ${c("Current:")} ${o}`),e.validation?.min!==void 0||e.validation?.max!==void 0){let s=e.validation?.min??0,i=e.validation?.max??1/0;console.log(` ${c("Range:")} ${s} - ${i===1/0?"\u221E":i}`)}console.log(` ${c("Default:")} ${e.defaultValue}`),console.log(` ${c("(Leave empty and press Enter to cancel)")}`),console.log();let n=await q({message:`${e.name}:`,default:"",validate:s=>{if(!s.trim())return!0;let i=parseInt(s,10);return isNaN(i)?"Please enter a valid number":e.validation?.min!==void 0&&i<e.validation.min?`Minimum value is ${e.validation.min}`:e.validation?.max!==void 0&&i>e.validation.max?`Maximum value is ${e.validation.max}`:!0}});return n.trim()?n===e.defaultValue?"":n:null}async function kd(e,t){let o=gd(),n=t?t.split(",").map(p=>p.trim()).filter(Boolean):[],s=n.length>0?n.join(", "):e.id==="toolsToRun"?r("dim","(all tools)"):r("dim","(none)");console.log(),console.log(` ${g(e.name)}`),console.log(` ${c(e.description)}`),console.log(` ${c("Current:")} ${s}`),console.log();let i=await E({message:`${e.name}:`,choices:[{name:"EDIT Select tools",value:"select",description:"Choose which tools to include"},{name:`${r("yellow","\u21BA")} Clear all`,value:"clear",description:e.id==="toolsToRun"?"Reset to all tools enabled":"Remove all tools from this list"},new x,{name:`${r("dim","- Cancel")}`,value:"cancel"}],loop:!1});if(i==="cancel")return null;if(i==="clear")return"";let a=[];a.push({name:r("blue","\u2500\u2500 GitHub Tools \u2500\u2500"),value:"__separator_github__",disabled:!0});for(let p of o.filter(d=>d.category==="github"))a.push({name:`${p.name} ${r("dim",`(${p.id})`)}`,value:p.id,checked:n.includes(p.id),description:p.description});a.push({name:r("yellow","\u2500\u2500 Local Tools \u2500\u2500"),value:"__separator_local__",disabled:!0});for(let p of o.filter(d=>d.category==="local"))a.push({name:`${p.name} ${r("dim",`(${p.id})`)}`,value:p.id,checked:n.includes(p.id),description:p.description});a.push({name:r("dim","\u2500\u2500 Actions \u2500\u2500"),value:"__separator_actions__",disabled:!0}),a.push({name:`${r("dim","- Cancel (keep current)")}`,value:"__cancel__",checked:!1,description:"Go back without changes"}),console.log(),console.log(` ${c("Use Space to select/deselect, Enter to confirm, or select Cancel")}`);let l=await _o({message:`Select tools for ${e.name}:`,choices:a,pageSize:16,loop:!1,theme:{prefix:" ",style:{highlight:p=>r("cyan",p),message:p=>g(p)}}});if(l.includes("__cancel__"))return null;let u=l.filter(p=>!p.startsWith("__separator")&&p!=="__cancel__");return u.length>0?u.join(","):""}function Kt(e,t,o){let n=e[o.envVar]??"",s=t[o.envVar]??"";return n!==s}function vd(e,t){let o=0;for(let n of Qe)Kt(e,t,n)&&o++;return o}async function wd(e,t){let o=[],n=Qe.filter(d=>d.type==="boolean"),s=Qe.filter(d=>d.type==="string"),i=Qe.filter(d=>d.type==="number"),a=Qe.filter(d=>d.type==="array"),l=vd(t,e),u=l>0?`${r("yellow","\u25CF")} ${l} unsaved ${l===1?"change":"changes"}`:`${r("green","\u25CF")} No unsaved changes`;if(o.push({name:`${r("dim","\u2500\u2500")} ${u} ${r("dim","\u2500\u2500")}`,value:"__status__"}),n.length>0){o.push({name:r("dim","\u2500\u2500 Features \u2500\u2500"),value:"__sep1__"});for(let d of n){let m=qt(e,d),f=Kt(t,e,d),C=Bo(d,m,f);o.push({name:`${d.name}: ${C}`,value:d.id,description:d.description})}}if(s.length>0){o.push({name:r("dim","\u2500\u2500 Endpoints \u2500\u2500"),value:"__sep2__"});for(let d of s){let m=qt(e,d),f=Kt(t,e,d),C=Bo(d,m,f);o.push({name:`${d.name}: ${C}`,value:d.id,description:d.description})}}if(i.length>0){o.push({name:r("dim","\u2500\u2500 Performance \u2500\u2500"),value:"__sep3__"});for(let d of i){let m=qt(e,d),f=Kt(t,e,d),C=Bo(d,m,f);o.push({name:`${d.name}: ${C}`,value:d.id,description:d.description})}}if(a.length>0){o.push({name:r("dim","\u2500\u2500 Tool Selection \u2500\u2500"),value:"__sep4__"});for(let d of a){let m=qt(e,d),f=Kt(t,e,d),C=Bo(d,m,f);o.push({name:`${d.name}: ${C}`,value:d.id,description:d.description})}}return o.push({name:r("dim","\u2500\u2500 Actions \u2500\u2500"),value:"__sep5__"}),l>0?o.push({name:`${r("green","Save")} Save changes ${r("yellow",`(${l})`)}`,value:"save",description:"Save configuration and exit"}):o.push({name:`${r("dim","Save")} Save changes`,value:"save",description:c("No changes to save")}),o.push({name:`${r("yellow","\u21BA")} Reset to defaults`,value:"reset",description:"Clear all custom configuration"}),o.push({name:`${r("dim","- Back")}`,value:"back"}),await E({message:"Select option to configure:",choices:o,pageSize:20,loop:!1,theme:{prefix:" ",style:{highlight:d=>r("cyan",d),message:d=>g(d)}}})}async function Sd(){let e=await Ht();if(!e)return;let{client:t,customPath:o}=e,n=D[t],s=o||U(t),i=G(s);if(!i){console.log(),console.log(` ${r("red","X")} Failed to read config file: ${s}`),console.log();return}if(!Me(i)){console.log(),console.log(` ${r("yellow","WARN")} Octocode is not configured for ${n.name}.`),console.log(` ${c('Please install Octocode first using "Install octocode-mcp".')}`),console.log();return}console.log(),console.log(` ${c("Config file:")} ${r("cyan",s)}`),console.log(` ${c("Client:")} ${n.name}`),console.log();let a={...i.mcpServers?.octocode?.env||{}},l={...a},u=!0;for(;u;){let p=await wd(l,a);if(!(p.startsWith("__sep")||p==="__status__"))switch(p){case"save":{if(!(JSON.stringify(a)!==JSON.stringify(l))){console.log(),console.log(` ${c("No changes to save.")}`),console.log(),u=!1;break}let m=new A("Saving configuration...").start(),f={};for(let[v,h]of Object.entries(l))h&&h!==""&&(f[v]=h);let C={...i,mcpServers:{...i.mcpServers,octocode:{...i.mcpServers.octocode,env:Object.keys(f).length>0?f:void 0}}};C.mcpServers?.octocode?.env&&Object.keys(C.mcpServers.octocode.env).length===0&&delete C.mcpServers.octocode.env;let w=ee(s,C);w.success?(m.succeed("Configuration saved!"),console.log(),console.log(` ${r("green","\u2705")} Config saved to: ${s}`),w.backupPath&&console.log(` ${c("Backup:")} ${w.backupPath}`),console.log(),console.log(` ${g("Note:")} Restart ${n.name} for changes to take effect.`),await Zi(s)):(m.fail("Failed to save configuration"),console.log(),console.log(` ${r("red","X")} ${w.error||"Unknown error"}`),console.log()),u=!1;break}case"reset":{if(await Ut({message:"Reset all configuration to defaults?",default:!1})){for(let m of Object.keys(l))delete l[m];console.log(` ${r("yellow","\u21BA")} Configuration reset to defaults`)}break}case"back":{if(JSON.stringify(a)!==JSON.stringify(l)&&!await Ut({message:"Discard unsaved changes?",default:!1}))break;u=!1;break}default:{let d=Qe.find(C=>C.id===p);if(!d)break;let m=qt(l,d),f=null;switch(d.type){case"boolean":f=await yd(d,m);break;case"string":f=await Cd(d,m);break;case"number":f=await bd(d,m);break;case"array":f=await kd(d,m);break;default:break}f!==null&&(f===""||f===d.defaultValue?delete l[d.envVar]:l[d.envVar]=f);break}}}}async function Pd(){let e=await Ht();if(!e)return;let{client:t,customPath:o}=e,n=D[t],s=o||U(t),i=G(s);if(!i){console.log(),console.log(` ${r("red","X")} Failed to read config file: ${s}`),console.log();return}if(!Me(i)){console.log(),console.log(` ${r("yellow","WARN")} Octocode is not configured for ${n.name}.`),console.log(` ${c('Please install Octocode first using "Install octocode-mcp".')}`),console.log();return}let a=i.mcpServers?.octocode;console.log(),console.log(` ${c("Client:")} ${n.name} ${c("\u2022")} ${r("cyan",s)}`),console.log();let u=JSON.stringify({octocode:a},null,2).split(`
|
|
31
|
-
`);for(let p of u){let d=p.replace(/"([^"]+)":/g,`${r("cyan",'"$1"')}:`).replace(/: "([^"]+)"/g,`: ${r("green",'"$1"')}`).replace(/: (\d+)/g,`: ${r("yellow","$1")}`).replace(/: (true|false)/g,`: ${r("magenta","$1")}`);console.log(` ${d}`)}console.log(),await Zi(s)}function $d(e){switch(e.id){case"enableLocal":return"ENABLE_LOCAL=1";case"githubApiUrl":return"GITHUB_API_URL=https://github.mycompany.com/api/v3";case"toolsToRun":return"TOOLS_TO_RUN=githubSearchCode,githubGetFileContent";case"enableTools":return"ENABLE_TOOLS=localSearchCode,localFindFiles";case"disableTools":return"DISABLE_TOOLS=githubSearchPullRequests";case"requestTimeout":return"REQUEST_TIMEOUT=60000";case"maxRetries":return"MAX_RETRIES=5";default:return`${e.envVar}=${e.defaultValue}`}}function xd(e){return e.type==="array"?e.id==="toolsToRun"?"(all tools)":"(none)":e.defaultValue}function Ed(){console.log(),console.log(` ${g("All Available Configuration Options")}`),console.log(),console.log(` ${c("These options can be set as environment variables in your MCP config.")}`),console.log(` ${c('Add them to the "env" object in your octocode server configuration.')}`),console.log(),console.log(` ${c("Example config:")}`),console.log(` ${c("{")}
|
|
32
|
-
${c(' "mcpServers": {')}
|
|
33
|
-
${c(' "octocode": {')}
|
|
34
|
-
${c(' "command": "npx",')}
|
|
35
|
-
${c(' "args": ["octocode-mcp@latest"],')}
|
|
36
|
-
${r("green",' "env": { "ENABLE_LOCAL": "1" }')}
|
|
37
|
-
${c(" }")}
|
|
38
|
-
${c(" }")}
|
|
39
|
-
${c("}")}`),console.log(),console.log(r("blue","\u2501".repeat(66))),console.log();for(let e of Qe){let t=e.type==="boolean"?"green":e.type==="number"?"yellow":e.type==="array"?"magenta":"cyan";console.log(` ${r("cyan",e.envVar)} ${c(`(${e.type})`)}`),console.log(` ${e.description}`),console.log(` ${c("Default:")} ${xd(e)}`),console.log(` ${c("Example:")} ${r(t,$d(e))}`),console.log()}}function pe(e,t){if(e==null)throw new Error(`Assertion failed: ${t}`);return e}var Id=y.enum(["browser-automation","database","cloud-platform","developer-tools","file-system","communication","search-web","ai-services","workflow-automation","version-control","data-visualization","coding-agents","security","productivity","monitoring","finance","social-media","aggregator","other"]),Md=y.object({id:y.string().min(1),name:y.string().min(1),description:y.string().min(1),category:Id,repository:y.string(),website:y.string().optional(),stars:y.number().optional(),installationType:y.enum(["npm","npx","pip","docker","source"]),npmPackage:y.string().optional(),pipPackage:y.string().optional(),dockerImage:y.string().optional(),installConfig:y.object({command:y.string().min(1),args:y.array(y.string()),env:y.record(y.string(),y.string()).optional()}),requiredEnvVars:y.array(y.object({name:y.string(),description:y.string(),example:y.string().optional()})).optional(),official:y.boolean().optional(),tags:y.array(y.string()).optional()}),te=[{id:"playwright-mcp",name:"Playwright MCP",description:"Official Microsoft Playwright MCP server for browser automation via accessibility snapshots",category:"browser-automation",repository:"https://github.com/microsoft/playwright-mcp",website:"https://playwright.dev",installationType:"npx",npmPackage:"@playwright/mcp",official:!0,installConfig:{command:"npx",args:["-y","@playwright/mcp@latest"]},tags:["browser","automation","testing","microsoft","official"]},{id:"firecrawl-mcp-server",name:"Firecrawl MCP",description:"Powerful web scraping and search for Claude, Cursor and LLM clients",category:"browser-automation",repository:"https://github.com/firecrawl/firecrawl-mcp-server",website:"https://firecrawl.dev",installationType:"npx",npmPackage:"firecrawl-mcp",official:!0,installConfig:{command:"npx",args:["-y","firecrawl-mcp"]},requiredEnvVars:[{name:"FIRECRAWL_API_KEY",description:"Firecrawl API key",example:"fc-xxxxx"}],tags:["scraping","web","search","official"]},{id:"browserbase-mcp",name:"Browserbase MCP",description:"Cloud browser automation for web navigation, data extraction, form filling",category:"browser-automation",repository:"https://github.com/browserbase/mcp-server-browserbase",website:"https://browserbase.com",installationType:"npx",npmPackage:"@browserbasehq/mcp-server-browserbase",official:!0,installConfig:{command:"npx",args:["-y","@browserbasehq/mcp-server-browserbase"]},requiredEnvVars:[{name:"BROWSERBASE_API_KEY",description:"Browserbase API key"},{name:"BROWSERBASE_PROJECT_ID",description:"Browserbase project ID"}],tags:["browser","cloud","automation","official"]},{id:"chrome-devtools-mcp",name:"Chrome DevTools MCP",description:"Chrome DevTools for coding agents - debugging and browser control",category:"browser-automation",repository:"https://github.com/ChromeDevTools/chrome-devtools-mcp",installationType:"npx",npmPackage:"chrome-devtools-mcp",official:!0,installConfig:{command:"npx",args:["-y","chrome-devtools-mcp"]},tags:["chrome","devtools","debugging","official"]},{id:"github-mcp-server",name:"GitHub MCP",description:"GitHub's official MCP Server for repository management, PRs, issues, and more",category:"version-control",repository:"https://github.com/github/github-mcp-server",website:"https://github.com",installationType:"docker",dockerImage:"ghcr.io/github/github-mcp-server",official:!0,installConfig:{command:"docker",args:["run","-i","--rm","-e","GITHUB_PERSONAL_ACCESS_TOKEN","ghcr.io/github/github-mcp-server"]},requiredEnvVars:[{name:"GITHUB_PERSONAL_ACCESS_TOKEN",description:"GitHub Personal Access Token"}],tags:["github","git","repository","official"]},{id:"sqlite-mcp",name:"SQLite MCP",description:"Comprehensive SQLite database interaction capabilities for Cursor, Windsurf, and AI tools",category:"database",repository:"https://github.com/jparkerweb/mcp-sqlite",installationType:"npx",npmPackage:"mcp-sqlite",installConfig:{command:"npx",args:["-y","mcp-sqlite","${DATABASE_PATH}"]},requiredEnvVars:[{name:"DATABASE_PATH",description:"Path to SQLite database file",example:"/path/to/database.db"}],tags:["database","sqlite","sql","cursor","windsurf"]},{id:"mysql-mcp",name:"MySQL MCP",description:"MySQL database integration with configurable access controls and schema inspection",category:"database",repository:"https://github.com/designcomputer/mysql_mcp_server",installationType:"pip",pipPackage:"mysql-mcp-server",installConfig:{command:"uvx",args:["mysql-mcp-server"]},requiredEnvVars:[{name:"MYSQL_HOST",description:"MySQL host"},{name:"MYSQL_USER",description:"MySQL username"},{name:"MYSQL_PASSWORD",description:"MySQL password"},{name:"MYSQL_DATABASE",description:"MySQL database name"}],tags:["database","mysql","sql"]},{id:"mongodb-mcp",name:"MongoDB MCP",description:"MongoDB integration for querying and analyzing collections",category:"database",repository:"https://github.com/kiliczsh/mcp-mongo-server",installationType:"npx",npmPackage:"mcp-mongo-server",installConfig:{command:"npx",args:["-y","mcp-mongo-server"]},requiredEnvVars:[{name:"MONGODB_URI",description:"MongoDB connection URI",example:"mongodb://localhost:27017/mydb"}],tags:["database","mongodb","nosql"]},{id:"redis-mcp",name:"Redis MCP",description:"Natural language interface for managing and searching data in Redis",category:"database",repository:"https://github.com/redis/mcp-redis",website:"https://redis.io",installationType:"pip",pipPackage:"redis-mcp-server",official:!0,installConfig:{command:"uvx",args:["redis-mcp-server"]},requiredEnvVars:[{name:"REDIS_URL",description:"Redis connection URL",example:"redis://localhost:6379"}],tags:["database","redis","cache","official"]},{id:"neon-mcp",name:"Neon MCP",description:"Neon Serverless Postgres - create and manage databases with natural language",category:"database",repository:"https://github.com/neondatabase/mcp-server-neon",website:"https://neon.tech",installationType:"npx",npmPackage:"@neondatabase/mcp-server-neon",official:!0,installConfig:{command:"npx",args:["-y","@neondatabase/mcp-server-neon"]},requiredEnvVars:[{name:"NEON_API_KEY",description:"Neon API key"}],tags:["database","postgres","serverless","official"]},{id:"qdrant-mcp",name:"Qdrant MCP",description:"Vector search engine for keeping and retrieving memories",category:"database",repository:"https://github.com/qdrant/mcp-server-qdrant",website:"https://qdrant.tech",installationType:"pip",pipPackage:"mcp-server-qdrant",official:!0,installConfig:{command:"uvx",args:["mcp-server-qdrant"]},requiredEnvVars:[{name:"QDRANT_URL",description:"Qdrant server URL"},{name:"QDRANT_API_KEY",description:"Qdrant API key (optional)"}],tags:["database","vector","search","official"]},{id:"snowflake-mcp",name:"Snowflake MCP",description:"Snowflake data warehouse integration with read/write capabilities",category:"database",repository:"https://github.com/isaacwasserman/mcp-snowflake-server",website:"https://snowflake.com",installationType:"pip",pipPackage:"mcp-snowflake-server",installConfig:{command:"uvx",args:["mcp-snowflake-server"]},requiredEnvVars:[{name:"SNOWFLAKE_ACCOUNT",description:"Snowflake account identifier"},{name:"SNOWFLAKE_USER",description:"Snowflake username"},{name:"SNOWFLAKE_PASSWORD",description:"Snowflake password"}],tags:["database","snowflake","data-warehouse"]},{id:"bigquery-mcp",name:"BigQuery MCP",description:"Google BigQuery integration for schema inspection and queries",category:"database",repository:"https://github.com/LucasHild/mcp-server-bigquery",website:"https://cloud.google.com/bigquery",installationType:"pip",pipPackage:"mcp-server-bigquery",installConfig:{command:"uvx",args:["mcp-server-bigquery"]},requiredEnvVars:[{name:"GOOGLE_APPLICATION_CREDENTIALS",description:"Path to GCP service account JSON"}],tags:["database","bigquery","google","analytics"]},{id:"dbhub-mcp",name:"DBHub MCP",description:"Zero-dependency, token-efficient database MCP for Postgres, MySQL, SQL Server, MariaDB, SQLite",category:"database",repository:"https://github.com/bytebase/dbhub",installationType:"npx",npmPackage:"dbhub",installConfig:{command:"npx",args:["-y","dbhub"]},requiredEnvVars:[{name:"DATABASE_URL",description:"Database connection URL",example:"postgres://user:pass@localhost:5432/db"}],tags:["database","postgres","mysql","sqlite","mariadb","sqlserver","multi-database"]},{id:"pg-aiguide-mcp",name:"PostgreSQL AI Guide MCP",description:"PostgreSQL documentation and best practices through semantic search and curated skills",category:"database",repository:"https://github.com/timescale/pg-aiguide",website:"https://tigerdata.com",installationType:"npx",npmPackage:"@tigerdata/pg-aiguide",installConfig:{command:"npx",args:["-y","@tigerdata/pg-aiguide"]},tags:["database","postgres","postgresql","documentation","timescale"]},{id:"cloudflare-mcp",name:"Cloudflare MCP",description:"Integration with Cloudflare Workers, KV, R2, and D1",category:"cloud-platform",repository:"https://github.com/cloudflare/mcp-server-cloudflare",website:"https://cloudflare.com",installationType:"npx",npmPackage:"@cloudflare/mcp-server-cloudflare",official:!0,installConfig:{command:"npx",args:["-y","@cloudflare/mcp-server-cloudflare"]},requiredEnvVars:[{name:"CLOUDFLARE_API_TOKEN",description:"Cloudflare API Token"},{name:"CLOUDFLARE_ACCOUNT_ID",description:"Cloudflare Account ID"}],tags:["cloudflare","cloud","workers","official"]},{id:"docker-mcp",name:"Docker MCP",description:"Docker operations for container and compose stack management",category:"cloud-platform",repository:"https://github.com/sondt2709/docker-mcp",installationType:"npx",npmPackage:"docker-mcp",installConfig:{command:"npx",args:["-y","docker-mcp"]},tags:["docker","containers","devops"]},{id:"filesystem-mcp",name:"Filesystem MCP",description:"Direct local file system access with configurable permissions",category:"file-system",repository:"https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem",installationType:"npx",npmPackage:"@modelcontextprotocol/server-filesystem",official:!0,installConfig:{command:"npx",args:["-y","@modelcontextprotocol/server-filesystem","${ALLOWED_DIRECTORIES}"]},requiredEnvVars:[{name:"ALLOWED_DIRECTORIES",description:"Comma-separated list of allowed directories",example:"/home/user/projects,/tmp"}],tags:["filesystem","files","local","official"]},{id:"git-mcp-official",name:"Git MCP",description:"Official Git integration for repository operations, commits, and history",category:"version-control",repository:"https://github.com/modelcontextprotocol/servers/tree/main/src/git",installationType:"pip",pipPackage:"mcp-server-git",official:!0,installConfig:{command:"uvx",args:["mcp-server-git"]},tags:["git","version-control","repository","official"]},{id:"memory-mcp",name:"Memory MCP",description:"Official memory/persistence server for maintaining context across sessions",category:"developer-tools",repository:"https://github.com/modelcontextprotocol/servers/tree/main/src/memory",installationType:"npx",npmPackage:"@modelcontextprotocol/server-memory",official:!0,installConfig:{command:"npx",args:["-y","@modelcontextprotocol/server-memory"]},tags:["memory","persistence","context","official"]},{id:"fetch-mcp",name:"Fetch MCP",description:"Official HTTP fetch server for making web requests",category:"developer-tools",repository:"https://github.com/modelcontextprotocol/servers/tree/main/src/fetch",installationType:"pip",pipPackage:"mcp-server-fetch",official:!0,installConfig:{command:"uvx",args:["mcp-server-fetch"]},tags:["fetch","http","web","requests","official"]},{id:"time-mcp",name:"Time MCP",description:"Official time server for date/time operations and timezones",category:"developer-tools",repository:"https://github.com/modelcontextprotocol/servers/tree/main/src/time",installationType:"pip",pipPackage:"mcp-server-time",official:!0,installConfig:{command:"uvx",args:["mcp-server-time"]},tags:["time","date","timezone","official"]},{id:"sequential-thinking-mcp",name:"Sequential Thinking MCP",description:"Official server for step-by-step reasoning and problem solving",category:"developer-tools",repository:"https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking",installationType:"npx",npmPackage:"@modelcontextprotocol/server-sequential-thinking",official:!0,installConfig:{command:"npx",args:["-y","@modelcontextprotocol/server-sequential-thinking"]},tags:["reasoning","thinking","problem-solving","official"]},{id:"everything-mcp",name:"Everything MCP",description:"Official demo server showcasing all MCP capabilities in one package",category:"developer-tools",repository:"https://github.com/modelcontextprotocol/servers/tree/main/src/everything",installationType:"npx",npmPackage:"@modelcontextprotocol/server-everything",official:!0,installConfig:{command:"npx",args:["-y","@modelcontextprotocol/server-everything"]},tags:["demo","all-in-one","example","official"]},{id:"exa-mcp",name:"Exa Search MCP",description:"Exa AI Search API for real-time web information retrieval",category:"search-web",repository:"https://github.com/exa-labs/exa-mcp-server",website:"https://exa.ai",installationType:"npx",npmPackage:"exa-mcp-server",official:!0,installConfig:{command:"npx",args:["-y","exa-mcp-server"]},requiredEnvVars:[{name:"EXA_API_KEY",description:"Exa API key"}],tags:["search","exa","ai","official"]},{id:"perplexity-mcp",name:"Perplexity MCP",description:"Official Perplexity AI search and research integration",category:"search-web",repository:"https://github.com/perplexityai/modelcontextprotocol",website:"https://perplexity.ai",installationType:"npx",npmPackage:"@perplexity-ai/mcp-server",official:!0,installConfig:{command:"npx",args:["-y","@perplexity-ai/mcp-server"]},requiredEnvVars:[{name:"PERPLEXITY_API_KEY",description:"Perplexity API key"}],tags:["search","perplexity","ai","research","official"]},{id:"kagi-mcp",name:"Kagi MCP",description:"Official Kagi search and tools integration",category:"search-web",repository:"https://github.com/kagisearch/kagi-mcp",website:"https://kagi.com",installationType:"pip",pipPackage:"kagimcp",official:!0,installConfig:{command:"uvx",args:["kagimcp"]},requiredEnvVars:[{name:"KAGI_API_KEY",description:"Kagi API key"}],tags:["search","kagi","official"]},{id:"tavily-mcp",name:"Tavily MCP",description:"Tavily AI search API for intelligent web search",category:"search-web",repository:"https://github.com/tavily-ai/tavily-mcp",website:"https://tavily.com",installationType:"npx",npmPackage:"tavily-mcp",official:!0,installConfig:{command:"npx",args:["-y","tavily-mcp"]},requiredEnvVars:[{name:"TAVILY_API_KEY",description:"Tavily API key"}],tags:["search","tavily","ai","official"]},{id:"slack-mcp",name:"Slack MCP",description:"Most powerful MCP server for Slack with Stdio and SSE transports",category:"communication",repository:"https://github.com/korotovsky/slack-mcp-server",website:"https://slack.com",installationType:"npx",npmPackage:"slack-mcp-server",installConfig:{command:"npx",args:["-y","slack-mcp-server"]},requiredEnvVars:[{name:"SLACK_BOT_TOKEN",description:"Slack Bot OAuth Token"}],tags:["slack","chat","team"]},{id:"discord-mcp",name:"Discord MCP",description:"Discord API integration via JDA for seamless bot interaction with MCP clients",category:"communication",repository:"https://github.com/SaseQ/discord-mcp",website:"https://discord.com",installationType:"docker",dockerImage:"saseq/discord-mcp:latest",installConfig:{command:"docker",args:["run","--rm","-i","-e","DISCORD_TOKEN","-e","DISCORD_GUILD_ID","saseq/discord-mcp:latest"]},requiredEnvVars:[{name:"DISCORD_TOKEN",description:"Discord Bot Token"},{name:"DISCORD_GUILD_ID",description:"Default Discord Server ID (optional)"}],tags:["discord","chat","community","bot"]},{id:"linear-mcp",name:"Linear MCP",description:"Linear project management integration for issues, projects, and teams",category:"communication",repository:"https://github.com/tacticlaunch/mcp-linear",website:"https://linear.app",installationType:"npx",npmPackage:"@tacticlaunch/mcp-linear",installConfig:{command:"npx",args:["-y","@tacticlaunch/mcp-linear"]},requiredEnvVars:[{name:"LINEAR_API_KEY",description:"Linear API key"}],tags:["linear","issues","project-management"]},{id:"atlassian-mcp",name:"Atlassian MCP",description:"Confluence and Jira integration for documentation and issue tracking",category:"communication",repository:"https://github.com/sooperset/mcp-atlassian",website:"https://atlassian.com",installationType:"pip",pipPackage:"mcp-atlassian",installConfig:{command:"uvx",args:["mcp-atlassian"]},requiredEnvVars:[{name:"ATLASSIAN_URL",description:"Atlassian instance URL"},{name:"ATLASSIAN_EMAIL",description:"Atlassian email"},{name:"ATLASSIAN_API_TOKEN",description:"Atlassian API token"}],tags:["atlassian","jira","confluence"]},{id:"notion-mcp",name:"Notion MCP",description:"Official Notion integration for pages, databases, and blocks",category:"productivity",repository:"https://github.com/makenotion/notion-mcp-server",website:"https://notion.so",installationType:"npx",npmPackage:"@notionhq/notion-mcp-server",official:!0,installConfig:{command:"npx",args:["-y","@notionhq/notion-mcp-server"]},requiredEnvVars:[{name:"NOTION_API_KEY",description:"Notion API integration token"}],tags:["notion","productivity","notes","database","official"]},{id:"obsidian-mcp",name:"Obsidian MCP",description:"Obsidian vault integration for file management, search, and manipulation",category:"productivity",repository:"https://github.com/MarkusPfundstein/mcp-obsidian",website:"https://obsidian.md",installationType:"npx",npmPackage:"mcp-obsidian",installConfig:{command:"npx",args:["-y","mcp-obsidian"]},requiredEnvVars:[{name:"OBSIDIAN_VAULT_PATH",description:"Path to Obsidian vault"}],tags:["obsidian","notes","markdown"]},{id:"todoist-mcp",name:"Todoist MCP",description:"Natural language task management with Todoist",category:"productivity",repository:"https://github.com/stevengonsalvez/todoist-mcp",website:"https://todoist.com",installationType:"npx",npmPackage:"todoist-mcp-server",installConfig:{command:"npx",args:["-y","todoist-mcp-server"]},requiredEnvVars:[{name:"TODOIST_API_TOKEN",description:"Todoist API token"}],tags:["todoist","tasks","productivity"]},{id:"google-workspace-mcp",name:"Google Workspace MCP",description:"Control Gmail, Calendar, Docs, Sheets, Slides, Chat, Drive and more",category:"productivity",repository:"https://github.com/taylorwilsdon/google_workspace_mcp",website:"https://workspace.google.com",installationType:"pip",pipPackage:"google-workspace-mcp",installConfig:{command:"uvx",args:["google-workspace-mcp"]},requiredEnvVars:[{name:"GOOGLE_APPLICATION_CREDENTIALS",description:"Path to Google credentials"}],tags:["google","workspace","gmail","docs"]},{id:"context7-mcp",name:"Context7 MCP",description:"Up-to-date code documentation for LLMs and AI code editors",category:"developer-tools",repository:"https://github.com/upstash/context7",website:"https://context7.com",installationType:"npx",npmPackage:"@upstash/context7-mcp",official:!0,installConfig:{command:"npx",args:["-y","@upstash/context7-mcp"]},tags:["documentation","context","code","official"]},{id:"desktop-commander-mcp",name:"Desktop Commander MCP",description:"Terminal control, file system search, and diff file editing capabilities",category:"developer-tools",repository:"https://github.com/wonderwhy-er/DesktopCommanderMCP",installationType:"npx",npmPackage:"@wonderwhy-er/desktop-commander",installConfig:{command:"npx",args:["-y","@wonderwhy-er/desktop-commander"]},tags:["terminal","file-editing","diff","command-line","process"]},{id:"gemini-mcp-tool",name:"Gemini MCP Tool",description:"Interact with Google Gemini CLI for large file analysis and codebase exploration",category:"ai-services",repository:"https://github.com/jamubc/gemini-mcp-tool",installationType:"npx",npmPackage:"gemini-mcp-tool",installConfig:{command:"npx",args:["-y","gemini-mcp-tool"]},tags:["gemini","google","ai","file-analysis","codebase"]},{id:"sentry-mcp",name:"Sentry MCP",description:"Sentry.io integration for error tracking and performance monitoring",category:"developer-tools",repository:"https://github.com/getsentry/sentry-mcp",website:"https://sentry.io",installationType:"npx",npmPackage:"@sentry/mcp-server",official:!0,installConfig:{command:"npx",args:["-y","@sentry/mcp-server"]},requiredEnvVars:[{name:"SENTRY_AUTH_TOKEN",description:"Sentry Auth Token"},{name:"SENTRY_ORG",description:"Sentry Organization Slug"}],tags:["sentry","errors","monitoring","official"]},{id:"mcp-memory-service",name:"Memory Service MCP",description:"Automatic context memory for Claude, VS Code, Cursor - stop re-explaining",category:"developer-tools",repository:"https://github.com/doobidoo/mcp-memory-service",installationType:"pip",pipPackage:"mcp-memory-service",installConfig:{command:"uvx",args:["mcp-memory-service"]},tags:["memory","context","persistence"]},{id:"serena-mcp",name:"Serena MCP",description:"Powerful coding agent with semantic retrieval and editing via language servers",category:"coding-agents",repository:"https://github.com/oraios/serena",installationType:"pip",installConfig:{command:"uvx",args:["--from","git+https://github.com/oraios/serena","serena","start-mcp-server"]},tags:["coding","agent","language-server"]},{id:"figma-mcp",name:"Figma Context MCP",description:"Get Figma design data in ready-to-implement format",category:"developer-tools",repository:"https://github.com/GLips/Figma-Context-MCP",website:"https://figma.com",installationType:"npx",npmPackage:"figma-context-mcp",installConfig:{command:"npx",args:["-y","figma-context-mcp"]},requiredEnvVars:[{name:"FIGMA_ACCESS_TOKEN",description:"Figma Personal Access Token"}],tags:["figma","design","ui"]},{id:"talk-to-figma-mcp",name:"Talk to Figma MCP",description:"Cursor + Figma integration for reading and modifying designs",category:"developer-tools",repository:"https://github.com/grab/cursor-talk-to-figma-mcp",website:"https://figma.com",installationType:"npx",npmPackage:"cursor-talk-to-figma-mcp",installConfig:{command:"npx",args:["-y","cursor-talk-to-figma-mcp"]},requiredEnvVars:[{name:"FIGMA_ACCESS_TOKEN",description:"Figma Personal Access Token"}],tags:["figma","cursor","design"]},{id:"xcodebuild-mcp",name:"XcodeBuild MCP",description:"Xcode-related tools for building, testing, and managing iOS/macOS projects",category:"developer-tools",repository:"https://github.com/cameroncooke/XcodeBuildMCP",website:"https://developer.apple.com/xcode",installationType:"npx",npmPackage:"xcodebuildmcp",installConfig:{command:"npx",args:["-y","xcodebuildmcp"]},tags:["xcode","ios","macos","apple","swift"]},{id:"markdownify-mcp",name:"Markdownify MCP",description:"Convert almost anything to Markdown - PDFs, URLs, images, and more",category:"developer-tools",repository:"https://github.com/zcaceres/markdownify-mcp",installationType:"npx",npmPackage:"mcp-markdownify-server",installConfig:{command:"npx",args:["-y","mcp-markdownify-server"]},tags:["markdown","converter","pdf","ocr"]},{id:"elevenlabs-mcp",name:"ElevenLabs MCP",description:"Official ElevenLabs text-to-speech, voice cloning, and audio generation",category:"ai-services",repository:"https://github.com/elevenlabs/elevenlabs-mcp",website:"https://elevenlabs.io",installationType:"pip",pipPackage:"elevenlabs-mcp",official:!0,installConfig:{command:"uvx",args:["elevenlabs-mcp"]},requiredEnvVars:[{name:"ELEVENLABS_API_KEY",description:"ElevenLabs API key"}],tags:["elevenlabs","tts","voice","audio","official"]},{id:"llamacloud-mcp",name:"LlamaCloud MCP",description:"Connect to managed indices on LlamaCloud",category:"ai-services",repository:"https://github.com/run-llama/mcp-server-llamacloud",website:"https://cloud.llamaindex.ai",installationType:"npx",npmPackage:"@llamaindex/mcp-server-llamacloud",official:!0,installConfig:{command:"npx",args:["-y","@llamaindex/mcp-server-llamacloud"]},requiredEnvVars:[{name:"LLAMA_CLOUD_API_KEY",description:"LlamaCloud API key"}],tags:["llamaindex","rag","index","official"]},{id:"huggingface-spaces-mcp",name:"HuggingFace Spaces MCP",description:"Use HuggingFace Spaces from your MCP Client - images, audio, text",category:"ai-services",repository:"https://github.com/evalstate/mcp-hfspace",website:"https://huggingface.co/spaces",installationType:"npx",npmPackage:"@llmindset/mcp-hfspace",installConfig:{command:"npx",args:["-y","@llmindset/mcp-hfspace"]},requiredEnvVars:[{name:"HF_TOKEN",description:"HuggingFace API token"}],tags:["huggingface","spaces","models"]},{id:"n8n-mcp",name:"n8n MCP",description:"Build n8n workflows using Claude Desktop, Cursor, or Windsurf",category:"workflow-automation",repository:"https://github.com/czlonkowski/n8n-mcp",website:"https://n8n.io",installationType:"npx",npmPackage:"n8n-mcp",installConfig:{command:"npx",args:["-y","n8n-mcp"]},requiredEnvVars:[{name:"N8N_API_URL",description:"n8n instance URL"},{name:"N8N_API_KEY",description:"n8n API key"}],tags:["n8n","automation","workflows"]},{id:"echarts-mcp",name:"ECharts MCP",description:"Generate visual charts using Apache ECharts dynamically",category:"data-visualization",repository:"https://github.com/hustcc/mcp-echarts",website:"https://echarts.apache.org",installationType:"npx",npmPackage:"mcp-echarts",installConfig:{command:"npx",args:["-y","mcp-echarts"]},tags:["visualization","charts","echarts"]},{id:"mermaid-mcp",name:"Mermaid MCP",description:"Generate Mermaid diagrams and charts dynamically",category:"data-visualization",repository:"https://github.com/hustcc/mcp-mermaid",website:"https://mermaid.js.org",installationType:"npx",npmPackage:"mcp-mermaid",installConfig:{command:"npx",args:["-y","mcp-mermaid"]},tags:["diagrams","mermaid","flowcharts"]},{id:"datadog-mcp",name:"Datadog MCP",description:"Datadog monitoring and observability integration",category:"monitoring",repository:"https://github.com/winor30/mcp-server-datadog",website:"https://datadoghq.com",installationType:"npx",npmPackage:"@winor30/mcp-server-datadog",installConfig:{command:"npx",args:["-y","@winor30/mcp-server-datadog"]},requiredEnvVars:[{name:"DD_API_KEY",description:"Datadog API key"},{name:"DD_APP_KEY",description:"Datadog Application key"}],tags:["datadog","monitoring","observability"]},{id:"browserstack-mcp",name:"BrowserStack MCP",description:"Official BrowserStack testing and automation integration",category:"developer-tools",repository:"https://github.com/browserstack/mcp-server",website:"https://browserstack.com",installationType:"npx",npmPackage:"@browserstack/mcp-server",official:!0,installConfig:{command:"npx",args:["-y","@browserstack/mcp-server"]},requiredEnvVars:[{name:"BROWSERSTACK_USERNAME",description:"BrowserStack username"},{name:"BROWSERSTACK_ACCESS_KEY",description:"BrowserStack access key"}],tags:["browserstack","testing","automation","official"]},{id:"tableau-mcp",name:"Tableau MCP",description:"Official Tableau data visualization and analytics integration",category:"data-visualization",repository:"https://github.com/tableau/tableau-mcp",website:"https://tableau.com",installationType:"npx",npmPackage:"@tableau/mcp-server",official:!0,installConfig:{command:"npx",args:["-y","@tableau/mcp-server"]},requiredEnvVars:[{name:"TABLEAU_TOKEN",description:"Tableau API token"},{name:"TABLEAU_SITE",description:"Tableau site name"}],tags:["tableau","visualization","analytics","official"]},{id:"stripe-mcp",name:"Stripe MCP",description:"Official Stripe Agent Toolkit for payment integration",category:"finance",repository:"https://github.com/stripe/agent-toolkit",website:"https://stripe.com",installationType:"npx",npmPackage:"@stripe/agent-toolkit",official:!0,installConfig:{command:"npx",args:["-y","@stripe/agent-toolkit","mcp"]},requiredEnvVars:[{name:"STRIPE_SECRET_KEY",description:"Stripe Secret Key"}],tags:["stripe","payments","finance","official"]},{id:"alpaca-mcp",name:"Alpaca MCP",description:"Official Alpaca trading - stocks, ETFs, crypto, and options in plain English",category:"finance",repository:"https://github.com/alpacahq/alpaca-mcp-server",website:"https://alpaca.markets",installationType:"pip",pipPackage:"alpaca-mcp-server",official:!0,installConfig:{command:"uvx",args:["alpaca-mcp-server"]},requiredEnvVars:[{name:"ALPACA_API_KEY",description:"Alpaca API key"},{name:"ALPACA_SECRET_KEY",description:"Alpaca secret key"}],tags:["alpaca","trading","stocks","crypto","finance","official"]},{id:"paypal-mcp",name:"PayPal MCP",description:"PayPal Agent Toolkit for payment integration",category:"finance",repository:"https://github.com/paypal/agent-toolkit",website:"https://paypal.com",installationType:"npx",npmPackage:"@paypal/agent-toolkit",official:!0,installConfig:{command:"npx",args:["-y","@paypal/agent-toolkit"]},requiredEnvVars:[{name:"PAYPAL_CLIENT_ID",description:"PayPal Client ID"},{name:"PAYPAL_CLIENT_SECRET",description:"PayPal Client Secret"}],tags:["paypal","payments","finance","official"]},{id:"semgrep-mcp",name:"Semgrep MCP",description:"Static code analysis and security scanning with Semgrep integration",category:"security",repository:"https://github.com/Szowesgad/mcp-server-semgrep",website:"https://semgrep.dev",installationType:"npx",npmPackage:"mcp-server-semgrep",installConfig:{command:"npx",args:["-y","mcp-server-semgrep"]},tags:["semgrep","security","sast","static-analysis"]},{id:"pipedream-mcp",name:"Pipedream MCP",description:"Connect with 2,500+ APIs with 8,000+ prebuilt tools",category:"aggregator",repository:"https://github.com/PipedreamHQ/pipedream/tree/master/modelcontextprotocol",website:"https://pipedream.com",installationType:"npx",npmPackage:"@pipedream/mcp",official:!0,installConfig:{command:"npx",args:["-y","@pipedream/mcp"]},requiredEnvVars:[{name:"PIPEDREAM_API_KEY",description:"Pipedream API key"}],tags:["pipedream","integrations","apis","official"]},{id:"fastmcp",name:"FastMCP",description:"The fast, Pythonic way to build MCP servers and clients",category:"developer-tools",repository:"https://github.com/jlowin/fastmcp",installationType:"pip",pipPackage:"fastmcp",installConfig:{command:"pip",args:["install","fastmcp"]},tags:["framework","python","sdk"]},{id:"mcp-use",name:"MCP Use",description:"Easiest way to interact with MCP servers with custom agents",category:"developer-tools",repository:"https://github.com/mcp-use/mcp-use",installationType:"pip",pipPackage:"mcp-use",installConfig:{command:"pip",args:["install","mcp-use"]},tags:["framework","agents","python"]},{id:"unity-mcp",name:"Unity MCP",description:"MCP server for Unity Editor - designed for Claude, Cursor, Gemini and more",category:"developer-tools",repository:"https://github.com/CoplayDev/unity-mcp",website:"https://unity.com",installationType:"pip",installConfig:{command:"uvx",args:["--from","git+https://github.com/CoplayDev/unity-mcp","unity-mcp"]},tags:["unity","game-dev","editor","gamedev"]},{id:"arxiv-mcp",name:"ArXiv MCP",description:"Search ArXiv research papers",category:"other",repository:"https://github.com/blazickjp/arxiv-mcp-server",website:"https://arxiv.org",installationType:"pip",pipPackage:"arxiv-mcp-server",installConfig:{command:"uvx",args:["arxiv-mcp-server"]},tags:["arxiv","research","papers"]},{id:"octocode-mcp",name:"Octocode MCP",description:"AI-powered developer assistant for GitHub and NPM research",category:"developer-tools",repository:"https://github.com/bgauryy/octocode-mcp",installationType:"npx",npmPackage:"octocode-mcp",installConfig:{command:"npx",args:["-y","octocode-mcp"]},requiredEnvVars:[{name:"GITHUB_PERSONAL_ACCESS_TOKEN",description:"GitHub Personal Access Token"}],tags:["github","npm","research","code"]},{id:"gpt-researcher-mcp",name:"GPT Researcher MCP",description:"Deep research agent with MCP support for comprehensive web research and report generation",category:"search-web",repository:"https://github.com/assafelovic/gptr-mcp",website:"https://gptr.dev",stars:24750,installationType:"source",installConfig:{command:"python",args:["server.py"]},requiredEnvVars:[{name:"OPENAI_API_KEY",description:"OpenAI API key for LLM capabilities",example:"sk-xxxxx"},{name:"TAVILY_API_KEY",description:"Tavily API key for web search",example:"tvly-xxxxx"}],tags:["research","web-search","deep-research","ai","tavily"]},{id:"mcp-chrome",name:"Chrome MCP",description:"Chrome extension-based MCP server for browser automation, screenshots, and content analysis",category:"browser-automation",repository:"https://github.com/hangwin/mcp-chrome",stars:9803,installationType:"npx",npmPackage:"mcp-chrome-bridge",installConfig:{command:"npx",args:["-y","mcp-chrome-bridge"]},tags:["chrome","browser","automation","extension","screenshot"]},{id:"aws-mcp",name:"AWS Core MCP",description:"AWS MCP Servers - dynamic orchestrator for specialized AWS services including Bedrock, Lambda, S3, and CloudWatch",category:"cloud-platform",repository:"https://github.com/awslabs/mcp",website:"https://awslabs.github.io/mcp/",stars:7801,installationType:"pip",pipPackage:"awslabs.core-mcp-server",official:!0,installConfig:{command:"uvx",args:["awslabs.core-mcp-server@latest"]},requiredEnvVars:[{name:"AWS_PROFILE",description:"AWS profile name for credentials",example:"default"},{name:"AWS_REGION",description:"AWS region",example:"us-east-1"}],tags:["aws","cloud","bedrock","lambda","s3","cloudwatch","official"]},{id:"git-mcp",name:"GitMCP",description:"Remote MCP server that transforms GitHub projects into documentation hubs for AI tools",category:"version-control",repository:"https://github.com/idosal/git-mcp",website:"https://gitmcp.io",stars:7328,installationType:"npx",npmPackage:"mcp-remote",installConfig:{command:"npx",args:["-y","mcp-remote","https://gitmcp.io/docs"]},tags:["git","github","documentation","remote","version-control"]},{id:"browser-tools-mcp",name:"BrowserTools MCP",description:"Monitor browser logs and capture browser data from Cursor and MCP-compatible IDEs via Chrome extension",category:"browser-automation",repository:"https://github.com/AgentDeskAI/browser-tools-mcp",website:"https://browsertools.agentdesk.ai",stars:6961,installationType:"npx",npmPackage:"@agentdeskai/browser-tools-mcp",installConfig:{command:"npx",args:["-y","@agentdeskai/browser-tools-mcp@latest"]},tags:["browser","devtools","chrome","logs","debugging"]},{id:"hexstrike-ai",name:"HexStrike AI",description:"Advanced MCP server for AI agents to run 150+ cybersecurity tools for pentesting and vulnerability discovery",category:"security",repository:"https://github.com/0x4m4/hexstrike-ai",stars:5690,installationType:"source",installConfig:{command:"python3",args:["hexstrike_mcp.py","--server","http://localhost:8888"]},requiredEnvVars:[{name:"HEXSTRIKE_PATH",description:"Path to cloned hexstrike-ai repository",example:"/path/to/hexstrike-ai"}],tags:["security","pentesting","cybersecurity","vulnerability"]},{id:"spec-workflow-mcp",name:"Spec Workflow MCP",description:"Structured spec-driven development workflow tools for AI-assisted software development with real-time web dashboard",category:"developer-tools",repository:"https://github.com/Pimzino/spec-workflow-mcp",stars:3569,installationType:"npx",npmPackage:"@pimzino/spec-workflow-mcp",installConfig:{command:"npx",args:["-y","@pimzino/spec-workflow-mcp@latest","${PROJECT_PATH}"]},requiredEnvVars:[{name:"PROJECT_PATH",description:"Path to your project directory",example:"/path/to/your/project"}],tags:["workflow","spec-driven","dashboard","vscode","development"]},{id:"excel-mcp-server",name:"Excel MCP",description:"Manipulate Excel files without Microsoft Excel - create, read, modify workbooks with formulas, formatting, and charts",category:"productivity",repository:"https://github.com/haris-musa/excel-mcp-server",stars:3079,installationType:"pip",pipPackage:"excel-mcp-server",installConfig:{command:"uvx",args:["excel-mcp-server","stdio"]},tags:["excel","spreadsheet","office","xlsx","formulas","charts"]},{id:"mcp-context-forge",name:"MCP Context Forge",description:"IBM MCP Gateway & Registry - federates MCP and REST services with discovery, auth, rate-limiting, and observability",category:"aggregator",repository:"https://github.com/IBM/mcp-context-forge",website:"https://ibm.github.io/mcp-context-forge/",stars:3056,installationType:"pip",pipPackage:"mcp-contextforge-gateway",official:!0,installConfig:{command:"uvx",args:["--from","mcp-contextforge-gateway","mcpgateway","--host","0.0.0.0","--port","4444"]},requiredEnvVars:[{name:"JWT_SECRET_KEY",description:"JWT secret key for authentication",example:"my-secret-key"}],tags:["ibm","gateway","registry","federation","proxy","official","enterprise"]},{id:"mobile-mcp",name:"Mobile MCP",description:"Scalable mobile automation and development through a platform-agnostic interface for iOS and Android devices",category:"developer-tools",repository:"https://github.com/mobile-next/mobile-mcp",stars:2969,installationType:"npx",npmPackage:"@mobilenext/mobile-mcp",installConfig:{command:"npx",args:["-y","@mobilenext/mobile-mcp@latest"]},tags:["mobile","ios","android","automation","simulator","emulator","testing"]},{id:"claude-code-mcp",name:"Claude Code MCP",description:"Run Claude Code in one-shot mode with permissions bypassed for direct agent access to file editing and terminal",category:"coding-agents",repository:"https://github.com/steipete/claude-code-mcp",stars:989,installationType:"npx",npmPackage:"@steipete/claude-code-mcp",installConfig:{command:"npx",args:["-y","@steipete/claude-code-mcp@latest"]},tags:["claude","coding","agent","cursor","windsurf"]},{id:"ros-mcp-server",name:"ROS MCP Server",description:"Connect LLMs with ROS/ROS2 robots for natural language robot commanding and real-time sensor visibility",category:"other",repository:"https://github.com/robotmcp/ros-mcp-server",stars:913,installationType:"pip",pipPackage:"ros-mcp-server",official:!0,installConfig:{command:"python",args:["-m","ros_mcp_server.server"]},tags:["ros","ros2","robotics","robots","sensors"]},{id:"gmail-mcp",name:"Gmail MCP",description:"Gmail integration with auto authentication for AI assistants to manage email through natural language",category:"communication",repository:"https://github.com/GongRzhe/Gmail-MCP-Server",website:"https://gmail.google.com",stars:895,installationType:"npx",npmPackage:"@gongrzhe/server-gmail-autoauth-mcp",installConfig:{command:"npx",args:["-y","@gongrzhe/server-gmail-autoauth-mcp"]},requiredEnvVars:[{name:"GMAIL_OAUTH_PATH",description:"Path to GCP OAuth credentials JSON file",example:"/path/to/gcp-oauth.keys.json"},{name:"GMAIL_CREDENTIALS_PATH",description:"Path where authenticated tokens are stored",example:"/path/to/credentials.json"}],tags:["gmail","email","google","communication","oauth"]},{id:"mcp-knowledge-graph",name:"MCP Knowledge Graph",description:"Persistent memory for AI models through a local knowledge graph with entities, relations, and observations",category:"developer-tools",repository:"https://github.com/shaneholloman/mcp-knowledge-graph",stars:764,installationType:"npx",npmPackage:"mcp-knowledge-graph",installConfig:{command:"npx",args:["-y","mcp-knowledge-graph","--memory-path","${MEMORY_PATH}"]},requiredEnvVars:[{name:"MEMORY_PATH",description:"Directory path where memory files are stored",example:"/Users/username/.aim"}],tags:["memory","knowledge-graph","persistence","context","entities"]},{id:"kubectl-mcp",name:"kubectl MCP",description:"Kubernetes cluster management for AI assistants with pod, service, Helm, and monitoring capabilities",category:"cloud-platform",repository:"https://github.com/rohitg00/kubectl-mcp-server",stars:750,installationType:"pip",pipPackage:"kubectl-mcp-tool",installConfig:{command:"python",args:["-m","kubectl_mcp_tool.mcp_server"]},requiredEnvVars:[{name:"KUBECONFIG",description:"Path to Kubernetes config file",example:"~/.kube/config"}],tags:["kubernetes","k8s","kubectl","helm","cloud","devops"]},{id:"apple-docs-mcp",name:"Apple Docs MCP",description:"Access Apple developer documentation, frameworks, APIs, SwiftUI, UIKit, and WWDC videos through MCP",category:"developer-tools",repository:"https://github.com/kimsungwhee/apple-docs-mcp",website:"https://developer.apple.com",stars:697,installationType:"npx",npmPackage:"@kimsungwhee/apple-docs-mcp",installConfig:{command:"npx",args:["-y","@kimsungwhee/apple-docs-mcp"]},tags:["apple","documentation","swiftui","uikit","wwdc","ios","macos"]},{id:"linkedin-mcp",name:"LinkedIn MCP",description:"LinkedIn integration for AI assistants to scrape profiles, companies, and search jobs",category:"social-media",repository:"https://github.com/stickerdaniel/linkedin-mcp-server",website:"https://linkedin.com",stars:685,installationType:"docker",dockerImage:"stickerdaniel/linkedin-mcp-server:latest",installConfig:{command:"docker",args:["run","--rm","-i","-e","LINKEDIN_COOKIE","stickerdaniel/linkedin-mcp-server:latest"]},requiredEnvVars:[{name:"LINKEDIN_COOKIE",description:"LinkedIn session cookie for authentication",example:"li_at=YOUR_COOKIE_VALUE"}],tags:["linkedin","social","jobs","profiles","scraping"]},{id:"mcp-proxy",name:"MCP Proxy",description:"Aggregates multiple MCP servers behind a single HTTP entrypoint with SSE and streamable HTTP support",category:"aggregator",repository:"https://github.com/TBXark/mcp-proxy",stars:612,installationType:"docker",dockerImage:"ghcr.io/tbxark/mcp-proxy:latest",installConfig:{command:"docker",args:["run","-i","--rm","-p","9090:9090","-v","${MCP_PROXY_CONFIG}:/config/config.json","ghcr.io/tbxark/mcp-proxy:latest"]},requiredEnvVars:[{name:"MCP_PROXY_CONFIG",description:"Path to MCP proxy configuration JSON file",example:"/path/to/config.json"}],tags:["proxy","aggregator","sse","http","multi-server"]},{id:"iterm-mcp",name:"iTerm MCP",description:"Execute commands in active iTerm sessions with REPL interactions and CLI assistance",category:"developer-tools",repository:"https://github.com/ferrislucas/iterm-mcp",stars:505,installationType:"npx",npmPackage:"iterm-mcp",installConfig:{command:"npx",args:["-y","iterm-mcp"]},tags:["iterm","terminal","macos","repl","cli"]},{id:"genai-toolbox-mcp",name:"GenAI Toolbox MCP",description:"Google's official MCP Toolbox for Databases - Postgres, MySQL, MongoDB, Redis, BigQuery, Spanner, and more",category:"database",repository:"https://github.com/googleapis/genai-toolbox",website:"https://googleapis.github.io/genai-toolbox/",stars:12234,installationType:"pip",pipPackage:"toolbox-core",official:!0,installConfig:{command:"uvx",args:["toolbox-langchain"]},tags:["google","database","postgres","mysql","mongodb","redis","bigquery","spanner","official"]},{id:"fastapi-mcp",name:"FastAPI MCP",description:"Expose FastAPI endpoints as MCP tools with authentication and authorization support",category:"developer-tools",repository:"https://github.com/tadata-org/fastapi_mcp",stars:11346,installationType:"pip",pipPackage:"fastapi-mcp",installConfig:{command:"pip",args:["install","fastapi-mcp"]},tags:["fastapi","api","rest","python","authentication","framework"]},{id:"claude-flow-mcp",name:"Claude Flow MCP",description:"Agent orchestration platform for Claude - deploy multi-agent swarms and coordinate autonomous workflows",category:"coding-agents",repository:"https://github.com/ruvnet/claude-flow",stars:11184,installationType:"npx",npmPackage:"claude-flow",installConfig:{command:"npx",args:["-y","claude-flow@alpha","init"]},tags:["claude","multi-agent","swarm","orchestration","workflow","autonomous"]},{id:"pal-mcp-server",name:"PAL MCP Server",description:"Multi-model support for Claude Code - use Gemini, OpenAI, OpenRouter, Azure, Grok, Ollama together",category:"ai-services",repository:"https://github.com/BeehiveInnovations/pal-mcp-server",stars:10758,installationType:"source",installConfig:{command:"python",args:["-m","pal_mcp_server"]},requiredEnvVars:[{name:"OPENROUTER_API_KEY",description:"OpenRouter API key (optional)",example:"sk-or-xxxxx"}],tags:["multi-model","gemini","openai","ollama","azure","grok","openrouter"]},{id:"browser-mcp",name:"Browser MCP",description:"Browser control MCP server via Chrome extension - navigate, click, type, and extract data",category:"browser-automation",repository:"https://github.com/BrowserMCP/mcp",stars:5362,installationType:"npx",npmPackage:"@anthropic/browser-mcp",installConfig:{command:"npx",args:["-y","@anthropic/browser-mcp"]},tags:["browser","chrome","extension","automation","web"]},{id:"mcp-playwright-ea",name:"Playwright MCP (ExecuteAutomation)",description:"Alternative Playwright MCP server for browser and API automation in Claude, Cursor, and more",category:"browser-automation",repository:"https://github.com/executeautomation/mcp-playwright",stars:5116,installationType:"npx",npmPackage:"@executeautomation/playwright-mcp-server",installConfig:{command:"npx",args:["-y","@executeautomation/playwright-mcp-server"]},tags:["playwright","browser","automation","testing","api"]},{id:"claude-context-mcp",name:"Claude Context MCP",description:"Code search MCP for Claude Code using vector database - make entire codebase the context",category:"developer-tools",repository:"https://github.com/zilliztech/claude-context",stars:4955,installationType:"npx",npmPackage:"@anthropic/claude-context",installConfig:{command:"npx",args:["-y","@anthropic/claude-context"]},tags:["code-search","vector-db","context","semantic-search","zilliz","milvus"]},{id:"ida-pro-mcp",name:"IDA Pro MCP",description:"AI-powered reverse engineering assistant bridging IDA Pro with language models",category:"security",repository:"https://github.com/mrexodia/ida-pro-mcp",stars:4906,installationType:"pip",pipPackage:"ida-pro-mcp",installConfig:{command:"pip",args:["install","ida-pro-mcp"]},tags:["ida-pro","reverse-engineering","binary-analysis","security","malware"]},{id:"deep-research-mcp",name:"Deep Research MCP",description:"Use any LLM for deep research with SSE API and MCP server support",category:"search-web",repository:"https://github.com/u14app/deep-research",stars:4302,installationType:"pip",pipPackage:"deep-research",installConfig:{command:"uvx",args:["deep-research"]},requiredEnvVars:[{name:"OPENAI_API_KEY",description:"OpenAI API key for LLM"}],tags:["research","deep-research","llm","sse","web-search"]},{id:"cipher-mcp",name:"Cipher MCP",description:"Memory layer for coding agents - persistent context for Cursor, Claude Code, Windsurf, and Cline",category:"developer-tools",repository:"https://github.com/campfirein/cipher",stars:3399,installationType:"npx",npmPackage:"@byterover/cipher-mcp",installConfig:{command:"npx",args:["-y","@byterover/cipher-mcp"]},tags:["memory","context","persistence","coding-agents","byterover"]},{id:"metorial-mcp",name:"Metorial MCP",description:"Connect any AI model to 600+ integrations powered by MCP with containerized security",category:"aggregator",repository:"https://github.com/metorial/metorial",stars:3201,installationType:"docker",dockerImage:"metorial/metorial:latest",installConfig:{command:"docker",args:["run","-i","--rm","metorial/metorial:latest"]},tags:["integrations","aggregator","docker","multi-tool","security"]},{id:"osaurus-mcp",name:"Osaurus MCP",description:"macOS LLM server - run local or cloud models with OpenAI/Anthropic compatible APIs",category:"ai-services",repository:"https://github.com/dinoki-ai/osaurus",stars:2962,installationType:"source",installConfig:{command:"osaurus",args:["serve"]},tags:["macos","local-llm","mlx","apple-silicon","openai-compatible","swift"]},{id:"shadcn-ui-mcp",name:"shadcn/ui MCP",description:"Context about shadcn/ui components for LLMs - React, Vue, Svelte, and React Native support",category:"developer-tools",repository:"https://github.com/Jpisnice/shadcn-ui-mcp-server",stars:2582,installationType:"npx",npmPackage:"shadcn-ui-mcp",installConfig:{command:"npx",args:["-y","shadcn-ui-mcp"]},tags:["shadcn","ui","react","vue","svelte","react-native","tailwind"]},{id:"shippie-mcp",name:"Shippie MCP",description:"Extendable code review and QA agent for CI/CD pipelines and GitHub",category:"developer-tools",repository:"https://github.com/mattzcarey/shippie",stars:2317,installationType:"npx",npmPackage:"shippie",installConfig:{command:"npx",args:["-y","shippie"]},tags:["code-review","qa","ci-cd","github","agent"]},{id:"devdocs-mcp",name:"DevDocs MCP",description:"Free, private, UI-based tech documentation MCP server for coders and developers",category:"developer-tools",repository:"https://github.com/cyberagiinc/DevDocs",stars:2003,installationType:"source",installConfig:{command:"python",args:["-m","devdocs"]},tags:["documentation","docs","reference","api-docs","crawler"]},{id:"brightdata-mcp",name:"Bright Data MCP",description:"Official Bright Data MCP for web scraping, data extraction, and anti-bot bypass",category:"browser-automation",repository:"https://github.com/brightdata/brightdata-mcp",website:"https://brightdata.com",stars:1845,installationType:"npx",npmPackage:"@anthropic/brightdata-mcp",official:!0,installConfig:{command:"npx",args:["-y","@anthropic/brightdata-mcp"]},requiredEnvVars:[{name:"BRIGHTDATA_API_KEY",description:"Bright Data API key"}],tags:["scraping","web-data","anti-bot","proxy","data-extraction","official"]},{id:"mcpjam-inspector",name:"MCP Inspector",description:"Build ChatGPT Apps and MCP servers locally with inspection and debugging tools",category:"developer-tools",repository:"https://github.com/MCPJam/inspector",stars:1545,installationType:"npx",npmPackage:"@mcpjam/inspector",installConfig:{command:"npx",args:["-y","@mcpjam/inspector"]},tags:["inspector","debugging","chatgpt","development","testing"]},{id:"mcptools",name:"MCP Tools CLI",description:"Command-line interface for interacting with MCP servers via stdio and HTTP transport",category:"developer-tools",repository:"https://github.com/f/mcptools",stars:1426,installationType:"npx",npmPackage:"mcptools",installConfig:{command:"npx",args:["-y","mcptools"]},tags:["cli","tools","stdio","http","debugging"]},{id:"mcp-scan",name:"MCP Scan",description:"Security vulnerability scanner for MCP connections - constrain, log, and audit",category:"security",repository:"https://github.com/invariantlabs-ai/mcp-scan",stars:1381,installationType:"pip",pipPackage:"mcp-scan",installConfig:{command:"uvx",args:["mcp-scan"]},tags:["security","vulnerability","audit","scanning","compliance"]},{id:"unreal-mcp",name:"Unreal Engine MCP",description:"Control Unreal Engine 5 through natural language via MCP for Cursor, Windsurf, and Claude",category:"developer-tools",repository:"https://github.com/chongdashu/unreal-mcp",stars:1239,installationType:"pip",pipPackage:"unreal-mcp",installConfig:{command:"uvx",args:["unreal-mcp"]},tags:["unreal-engine","ue5","game-dev","editor","blueprints"]},{id:"web-eval-agent",name:"Web Eval Agent MCP",description:"Autonomous web application evaluation and testing with Playwright integration",category:"developer-tools",repository:"https://github.com/refreshdotdev/web-eval-agent",stars:1231,installationType:"npx",npmPackage:"@refreshdotdev/web-eval-agent",installConfig:{command:"npx",args:["-y","@refreshdotdev/web-eval-agent"]},tags:["testing","qa","evaluation","playwright","autonomous"]},{id:"mcp-unity-alt",name:"MCP Unity (CoderGamester)",description:"Unity Editor MCP plugin for OpenAI, Gemini, Claude, Deepseek, and Grok integration",category:"developer-tools",repository:"https://github.com/CoderGamester/mcp-unity",stars:1193,installationType:"npx",npmPackage:"mcp-unity",installConfig:{command:"npx",args:["-y","mcp-unity"]},tags:["unity","game-dev","editor","c-sharp","multi-model"]},{id:"xmcp-framework",name:"xMCP Framework",description:"TypeScript MCP framework for building MCP servers with type safety and DX focus",category:"developer-tools",repository:"https://github.com/basementstudio/xmcp",stars:1168,installationType:"npm",npmPackage:"xmcp",installConfig:{command:"npm",args:["install","xmcp"]},tags:["framework","typescript","sdk","type-safe","developer-tools"]}];function zt(e){return te.filter(t=>t.category===e)}function ea(e){let t=e.toLowerCase();return te.filter(o=>o.name.toLowerCase().includes(t)||o.description.toLowerCase().includes(t)||o.tags?.some(n=>n.toLowerCase().includes(t)))}function rs(){return Array.from(new Set(te.map(e=>e.category)))}function jo(){let e=new Map;return te.forEach(t=>{t.tags?.forEach(o=>{e.set(o,(e.get(o)||0)+1)})}),Array.from(e.keys()).sort((t,o)=>{let n=(e.get(o)||0)-(e.get(t)||0);return n!==0?n:t.localeCompare(o)})}function ta(e){return te.filter(t=>t.tags?.includes(e))}function oa(e){return te.filter(t=>t.tags?.includes(e)).length}if(process.env.OCTOCODE_DEBUG==="1"){let e=y.array(Md).safeParse(te);e.success||console.error("[mcp-registry] Schema validation failed:",e.error.message)}function na(e){return e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function ra(e){return{"browser-automation":"WEB",database:"DB","cloud-platform":"CLOUD","developer-tools":"DEV","file-system":"FS",communication:"CHAT","search-web":"Search","ai-services":"AI","workflow-automation":"Fast","version-control":"EDIT","data-visualization":"DATA","coding-agents":"AGENT",security:"SEC",productivity:"List",monitoring:"MON",finance:"FIN","social-media":"SOCIAL",aggregator:"LINK",other:"Package"}[e]||"Package"}function is(e){let t=`${ra(e.category)} ${e.name}`;return e.official&&(t+=` ${r("cyan","[Official]")}`),t+=` - ${c(e.description.slice(0,45))}${e.description.length>45?"...":""}`,t}async function ia(){let e=ht();console.log(),console.log(r("blue"," \u250C"+"\u2500".repeat(60)+"\u2510")),console.log(r("blue"," \u2502 ")+c("[Step 1/6]")+" "+g("Select Target Client")+" ".repeat(28)+r("blue","\u2502")),console.log(r("blue"," \u2514"+"\u2500".repeat(60)+"\u2518")),console.log();let t=["cursor","claude-desktop","claude-code","opencode","codex","gemini-cli","windsurf","trae","antigravity","goose","kiro","zed","vscode-cline","vscode-roo","vscode-continue"],o=[];for(let s of t){let i=D[s],a=Ne(s),l=`${i.name} - ${c(i.description)}`;a?l+=` ${r("green","\u25CB")}`:l+=` ${r("dim","X")}`,e===s&&(l=`${r("green","\u2605")} ${l} ${r("yellow","(Current)")}`),o.push({name:l,value:s,disabled:a?!1:"Not installed"})}o.sort((s,i)=>s.disabled&&!i.disabled?1:!s.disabled&&i.disabled||e===s.value?-1:e===i.value?1:0),o.push(new x),o.push({name:`${r("cyan","-")} Custom Path - ${c("Specify your own config path")}`,value:"custom"}),o.push(new x),o.push({name:`${r("dim","- Back")}`,value:"back"});let n=await E({message:"Where would you like to install the MCP?",choices:o,loop:!1,pageSize:15});if(n==="back")return null;if(n==="custom"){let s=await Ad();return s?{client:"custom",customPath:s}:null}return{client:n}}async function Ad(){console.log(),console.log(` ${r("blue","INFO")} Enter the full path to your MCP config file`),console.log(` ${c("Leave empty to go back")}`),console.log();let e=await q({message:"Config path (or Enter to go back):",validate:t=>t.trim()?t.endsWith(".json")?!0:"Path must be a .json file":!0});if(!e||!e.trim())return null;if(e.startsWith("~")){let t=process.env.HOME||process.env.USERPROFILE||"";return e.replace("~",t)}return e}async function aa(){console.log(),console.log(` ${c("[Step 2/6]")} ${g("Browse Method")}`),console.log();let e=[{name:`- Search MCPs - ${c("Find by name, description, or tags")}`,value:"search"},{name:`- Browse by Category - ${c(`${rs().length} categories`)}`,value:"category"},{name:`- Browse by Tag - ${c(`${jo().length} tags`)}`,value:"tag"},{name:`- Popular MCPs - ${c("Top 20 most popular")}`,value:"popular"},{name:`- Full List (A-Z) - ${c(`All ${te.length} MCPs alphabetically`)}`,value:"all"},new x,{name:`${r("dim","- Back")}`,value:"back"}];return await E({message:"",choices:e,loop:!1})}async function la(){return console.log(),console.log(` ${c("[Step 3/6]")} ${g("Select MCP")}`),console.log(),console.log(` ${r("blue","INFO")} Type to search by name, description, or tags`),console.log(),await Gt({message:"Search MCPs:",source:t=>{let o={name:`${r("dim","- Back to browse options")}`,value:"back"};if(!t||!t.trim())return[...te.slice(0,15).map(s=>({name:is(s),value:s,description:s.tags?.slice(0,3).join(", ")})),{name:"\u2500".repeat(40),value:"back",disabled:!0},o];let n=ea(t.trim());return n.length===0?[{name:`${r("yellow","WARN")} No MCPs found matching "${t}"`,value:"back",disabled:"Try different keywords"},o]:[...n.map(s=>({name:is(s),value:s,description:s.tags?.slice(0,3).join(", ")})),{name:"\u2500".repeat(40),value:"back",disabled:!0},o]},pageSize:12})}async function ca(){console.log(),console.log(` ${c("[Step 3/6]")} ${g("Select MCP")}`),console.log();let t=rs().map(s=>({name:`${ra(s)} ${na(s)} (${zt(s).length})`,value:s}));t.sort((s,i)=>{let a=zt(s.value).length;return zt(i.value).length-a}),t.push(new x),t.push({name:`${r("dim","- Back")}`,value:"back"});let o=await E({message:"Select a category:",choices:t,loop:!1,pageSize:15});if(o==="back")return"back";let n=zt(o);return await Uo(n,na(o))}function sa(e){return e.charAt(0).toUpperCase()+e.slice(1)}async function ua(){console.log(),console.log(` ${c("[Step 3/6]")} ${g("Select MCP")}`),console.log(),console.log(` ${r("blue","INFO")} Type to filter ${jo().length} tags`),console.log();let e=jo(),t=await Gt({message:"Search tags:",source:n=>{let s={name:`${r("dim","- Back to browse options")}`,value:"back"},i=!n||!n.trim()?e.slice(0,20):e.filter(a=>a.toLowerCase().includes(n.toLowerCase().trim()));return i.length===0?[{name:`${r("yellow","WARN")} No tags found matching "${n}"`,value:"back",disabled:"Try different keywords"},s]:[...i.map(a=>({name:`- ${sa(a)} (${oa(a)} MCPs)`,value:a})),{name:"\u2500".repeat(40),value:"back",disabled:!0},s]},pageSize:15});if(t==="back")return"back";let o=ta(t);return await Uo(o,`Tag: ${sa(t)}`)}async function da(){console.log(),console.log(` ${c("[Step 3/6]")} ${g("Select MCP")}`);let e=[...te].sort((t,o)=>(o.stars??0)-(t.stars??0)).slice(0,20);return await Uo(e,"Popular MCPs")}async function pa(){console.log(),console.log(` ${c("[Step 3/6]")} ${g("Select MCP")}`);let e=[...te].sort((t,o)=>t.name.localeCompare(o.name));return await Uo(e,`All MCPs (A-Z) - ${e.length} total`)}async function Uo(e,t){console.log(),console.log(` ${g(t)}`),console.log();let o=e.map(s=>({name:is(s),value:s}));return o.push(new x),o.push({name:`${r("dim","- Back")}`,value:"back"}),await E({message:"Select an MCP to install:",choices:o,loop:!1,pageSize:15})}async function ga(e){let t=e.requiredEnvVars;if(!t||t.length===0)return{};console.log(),console.log(` ${c("[Step 5/6]")} ${g("Environment Variables")}`),console.log(),console.log(r("yellow"," \u250C"+"\u2500".repeat(60)+"\u2510")),console.log(r("yellow"," \u2502 ")+`${r("yellow","WARN")} ${g("Environment Variables Required")}`+" ".repeat(26)+r("yellow","\u2502")),console.log(r("yellow"," \u2514"+"\u2500".repeat(60)+"\u2518")),console.log(),console.log(` ${c("This MCP requires the following environment variables:")}`),console.log();for(let s of t)console.log(` ${r("cyan",s.name)}`),console.log(` ${c(s.description)}`),s.example&&console.log(` ${c("Example:")} ${r("dim",s.example)}`),console.log();let o=await E({message:"Would you like to configure these now?",choices:[{name:`${r("green","\u2705")} Configure environment variables`,value:"configure"},{name:`${r("yellow","\u25CB")} Skip - ${c("Configure later manually")}`,value:"skip"},new x,{name:`${r("dim","- Back")}`,value:"back"}],loop:!1});if(o==="back")return"back";if(o==="skip")return{};let n={};for(let s of t){console.log(),console.log(` ${r("cyan",s.name)}: ${c(s.description)}`),s.example&&console.log(` ${c("Example:")} ${s.example}`);let i=await q({message:`${s.name}:`,validate:a=>!a.trim()&&!s.name.includes("OPTIONAL")?`${s.name} is required`:!0});i.trim()&&(n[s.name]=i.trim())}return n}async function ma(e,t){let o=D[t];return console.log(),await E({message:`Install ${e.name} to ${o?.name||t}?`,choices:[{name:`${r("green","\u2705")} Proceed with installation`,value:"proceed"},new x,{name:`${r("dim","- Back to edit options")}`,value:"back"},{name:`${r("dim","X Cancel")}`,value:"cancel"}],loop:!1})}function fa(e){console.log(),console.log(r("blue"," \u250C"+"\u2500".repeat(60)+"\u2510")),console.log(r("blue"," \u2502 ")+g(e.name)+(e.official?` ${r("cyan","[Official]")}`:"")+" ".repeat(Math.max(0,60-e.name.length-(e.official?12:0)))+r("blue","\u2502")),console.log(r("blue"," \u2514"+"\u2500".repeat(60)+"\u2518")),console.log(),console.log(` ${c("Description:")} ${e.description}`),console.log(` ${c("Category:")} ${r("cyan",e.category)}`),console.log(` ${c("Installation:")} ${r("yellow",e.installationType)}`),e.website&&console.log(` ${c("Website:")} ${r("blue",e.website)}`),console.log(` ${c("Repository:")} ${r("blue",e.repository)}`),e.tags&&e.tags.length>0&&console.log(` ${c("Tags:")} ${e.tags.map(t=>r("dim",t)).join(", ")}`),console.log()}function ha(e,t,o,n){let s=D[t];console.log(r("blue"," \u250C"+"\u2500".repeat(60)+"\u2510")),console.log(r("blue"," \u2502 ")+g("Configuration Preview")+" ".repeat(39)+r("blue","\u2502")),console.log(r("blue"," \u2514"+"\u2500".repeat(60)+"\u2518")),console.log();let i={...e.installConfig.env||{},...n},a={command:e.installConfig.command,args:[...e.installConfig.args],...Object.keys(i).length>0&&{env:i}};if(console.log(` ${c("Server ID:")} ${r("cyan",e.id)}`),console.log(` ${c("Command:")} ${r("green",a.command)}`),console.log(` ${c("Args:")} ${r("yellow",a.args.join(" "))}`),Object.keys(i).length>0){console.log(` ${c("Environment Variables:")}`);for(let[l,u]of Object.entries(i)){let p=u.length>30?u.slice(0,27)+"...":u;console.log(` ${r("cyan",l)}: ${c(p)}`)}}console.log(),console.log(` ${g("Target:")}`),console.log(` ${c("Client:")} ${s?.name||t}`),console.log(` ${c("Config:")} ${r("cyan",o)}`),console.log()}function ya(e,t,o,n){let s=D[t];console.log(),console.log(r("green"," \u250C"+"\u2500".repeat(60)+"\u2510")),console.log(r("green"," \u2502 ")+`${r("green","\u2705")} ${g("MCP installed successfully!")}`+" ".repeat(30)+r("green","\u2502")),console.log(r("green"," \u2514"+"\u2500".repeat(60)+"\u2518")),console.log(),console.log(` ${g("Installed:")} ${e.name}`),console.log(` ${g("To:")} ${s?.name||t}`),console.log(` ${c("Config:")} ${r("cyan",o)}`),n&&console.log(` ${c("Backup:")} ${n}`),console.log(),console.log(` ${g("Next steps:")}`),console.log(` 1. Restart ${s?.name||t}`),console.log(` 2. Look for ${r("cyan",e.id)} in MCP servers`),e.website&&console.log(` 3. Check ${r("blue",e.website)} for usage docs`),console.log()}function Ca(e){console.log(),console.log(r("red"," \u250C"+"\u2500".repeat(60)+"\u2510")),console.log(r("red"," \u2502 ")+`${r("red","X")} ${g("Installation failed")}`+" ".repeat(38)+r("red","\u2502")),console.log(r("red"," \u2514"+"\u2500".repeat(60)+"\u2518")),console.log(),console.log(` ${r("red","Error:")} ${e}`),console.log()}var Td={search:la,category:ca,tag:ua,popular:da,all:pa},ba=["npx","node","python","python3","uvx","uv","docker","deno","bun","bunx","pnpm","yarn","npm"];function Od(e){if(!e||typeof e!="string")return{valid:!1,error:"Command is required"};let t=e.trim();if(t.includes("..")||t.includes("\0"))return{valid:!1,error:"Command contains invalid characters"};let o=t.split(/[/\\]/),n=o[o.length-1]?.split(/\s+/)[0]||"";return ba.includes(n)?{valid:!0}:{valid:!1,error:`Untrusted command: "${n}". Allowed: ${ba.join(", ")}`}}var Ld=[/[;&|`$]/,/[(){}[\]]/,/[<>]/,/[!^]/,/\\(?!["'\\])/,/[\n\r\x00]/,/'.*'/,/".*\$.*"/],Dd=/^--?[a-zA-Z][a-zA-Z0-9-]*(=\S+)?$/;function Rd(e){return Dd.test(e)}function _d(e){if(!Array.isArray(e))return{valid:!1,error:"Arguments must be an array"};for(let t of e){if(typeof t!="string")return{valid:!1,problematic:String(t),error:"Argument must be a string"};if(!Rd(t)){for(let o of Ld)if(o.test(t))return{valid:!1,problematic:t,error:`Potentially unsafe argument: "${t.slice(0,50)}${t.length>50?"...":""}"`};if(t.length>4096)return{valid:!1,problematic:t.slice(0,50)+"...",error:"Argument exceeds maximum length (4096 chars)"}}}return{valid:!0}}function Nd(e){if(!e||typeof e!="object")return{valid:!0};let t=/^[A-Za-z_][A-Za-z0-9_]*$/;for(let[o,n]of Object.entries(e)){if(!t.test(o))return{valid:!1,problematic:o,error:`Invalid environment variable name: "${o}"`};if(typeof n!="string")return{valid:!1,problematic:o,error:`Environment variable value must be a string: "${o}"`};if(/[\x00-\x08\x0B\x0C\x0E-\x1F]/.test(n))return{valid:!1,problematic:o,error:`Environment variable "${o}" contains invalid control characters`};if(n.length>32768)return{valid:!1,problematic:o,error:`Environment variable "${o}" exceeds maximum length (32KB)`}}return{valid:!0}}function Fd(e,t){let o=Od(e.installConfig.command);if(!o.valid)throw new Error(o.error||"Invalid command");let n=_d(e.installConfig.args);if(!n.valid)throw new Error(n.error||`Potentially unsafe argument: "${n.problematic}"`);let s={...e.installConfig.env||{},...t},i=Nd(s);if(!i.valid)throw new Error(i.error||`Invalid environment variable: "${i.problematic}"`);let a={command:e.installConfig.command,args:[...e.installConfig.args]};return Object.keys(s).length>0&&(a.env=s),a}function Bd(e,t,o){let n=t==="custom"&&o?o:U(t,o),s=G(n);return!s||!s.mcpServers?!1:e in s.mcpServers}function jd(e,t,o,n){let s=t==="custom"&&o?o:U(t,o),i=G(s)||{mcpServers:{}},a=Fd(e,n);i={...i,mcpServers:{...i.mcpServers,[e.id]:a}};let l=ee(s,i);return l.success?{success:!0,configPath:s,backupPath:l.backupPath}:{success:!1,configPath:s,error:l.error||"Failed to write config"}}async function Ud(){console.log(),await q({message:c("Press Enter to continue..."),default:""})}async function as(){await W(),console.log(),console.log(` ${r("yellow","WARN")} ${c("70+ community servers \u2022 MCPs install on your behalf")}`);let e={client:null,browseMode:null,selectedMCP:null,envValues:{}},t="client";for(;t!=="done";)switch(t){case"client":{let o=await ia();if(!o)return;e.client=o.client,e.customPath=o.customPath,t="browse";break}case"browse":{let o=await aa();if(o==="back"||o===null){t="client";break}e.browseMode=o,t="selectMCP";break}case"selectMCP":{let o=e.browseMode?Td[e.browseMode]:null,n=o?await o():null;if(!n||n==="back"){t="browse";break}e.selectedMCP=n,t="details";break}case"details":{let o=pe(e.selectedMCP,"selectedMCP should be set before details step");if(console.log(),console.log(` ${c("[Step 4/6]")} ${g("MCP Details")}`),fa(o),await E({message:"What would you like to do?",choices:[{name:`${r("green","\u2705")} Continue to install`,value:"continue"},new x,{name:`${r("dim","- Back to MCP list")}`,value:"back"}],loop:!1})==="back"){t="selectMCP";break}t="envVars";break}case"envVars":{let o=pe(e.selectedMCP,"selectedMCP should be set before envVars step"),n=await ga(o);if(n==="back"){t="details";break}if(n===null){t="details";break}e.envValues=n,t="confirm";break}case"confirm":{let o=pe(e.selectedMCP,"selectedMCP should be set before confirm step"),n=pe(e.client,"client should be set before confirm step");console.log(),console.log(` ${c("[Step 6/6]")} ${g("Confirm Installation")}`);let s=n==="custom"&&e.customPath?e.customPath:U(n,e.customPath);if(Bd(o.id,n,e.customPath)){console.log(),console.log(` ${r("yellow","\u26A0")} MCP "${g(o.name)}" is already installed.`),console.log();let l=await E({message:"What would you like to do?",choices:[{name:`${r("blue","\u21BB")} Update configuration`,value:"update"},{name:`${r("dim","\u23ED")} Skip (keep existing)`,value:"skip"},new x,{name:`${r("dim","\u2190 Back")}`,value:"back"}],loop:!1});if(l==="skip"){console.log(),console.log(` ${c("Skipped - keeping existing configuration.")}`),t="browse";break}if(l==="back"){t="envVars";break}console.log(),console.log(` ${r("blue","\u2192")} Updating MCP configuration...`)}ha(o,n,s,e.envValues);let a=await ma(o,n);if(a==="back"){t="envVars";break}if(a==="cancel"){console.log(),console.log(` ${c("Installation cancelled.")}`);return}t="install";break}case"install":{let o=pe(e.selectedMCP,"selectedMCP should be set before install step"),n=pe(e.client,"client should be set before install step"),s=new A("Installing MCP...").start(),i=jd(o,n,e.customPath,e.envValues);i.success?(s.succeed("MCP installed successfully!"),ya(o,n,i.configPath,i.backupPath)):(s.fail("Installation failed"),Ca(i.error||"Unknown error")),await Ud(),t="done";break}default:break}}function Xt(){let e=Hr(),t=[];for(let o of e){let n=U(o),s=yo(o),i=null,a=0;s&&(i=G(n),i?.mcpServers&&(a=Object.keys(i.mcpServers).length)),t.push({client:o,configPath:n,config:i,exists:s,mcpCount:a})}return t}function Gd(e,t){if(e.command!==t.command)return!1;let o=e.args||[],n=t.args||[];if(o.length!==n.length)return!1;for(let a=0;a<o.length;a++)if(o[a]!==n[a])return!1;let s=Object.keys(e.env||{}).sort(),i=Object.keys(t.env||{}).sort();if(s.length!==i.length)return!1;for(let a=0;a<s.length;a++)if(s[a]!==i[a]||(e.env||{})[s[a]]!==(t.env||{})[i[a]])return!1;return!0}function Yt(e){let t=e.filter(p=>p.exists&&p.config),o=new Set,n=new Map;for(let p of t)if(p.config?.mcpServers)for(let[d,m]of Object.entries(p.config.mcpServers))o.add(d),n.has(d)||n.set(d,new Map),n.get(d).set(p.client,m);let s=[],i=t.map(p=>p.client);for(let p of o){let d=n.get(p)||new Map,m=Array.from(d.keys()),f=i.filter(v=>!d.has(v)),C=!1,w=Array.from(d.values());if(w.length>1){let v=w[0];for(let h=1;h<w.length;h++)if(!Gd(v,w[h])){C=!0;break}}s.push({mcpId:p,presentIn:m,missingIn:f,hasConflict:C,variants:d})}let a=s.filter(p=>p.missingIn.length===0&&!p.hasConflict),l=s.filter(p=>p.missingIn.length>0&&!p.hasConflict),u=s.filter(p=>p.hasConflict);return{clients:e,allMCPs:o,diffs:s,fullyConsistent:a,needsSync:l,conflicts:u,summary:{totalClients:e.length,clientsWithConfig:t.length,totalUniqueMCPs:o.size,consistentMCPs:a.length,needsSyncCount:l.length,conflictCount:u.length}}}function Hd(e,t){let o={mcpServers:{...e?.mcpServers||{}}};for(let{mcpId:n,server:s}of t)o.mcpServers[n]=s;return o}function Vd(e,t){return t?t.chosenConfig:!e.hasConflict&&e.variants.size>0?Array.from(e.variants.values())[0]:null}function ls(e,t,o){let n=new Map,s=[],i=[],a=o?e.filter(u=>o.includes(u.client)):e.filter(u=>u.exists);for(let u of a){if(u.exists&&u.config===null){n.set(u.client,{success:!1,error:"Config file exists but could not be parsed (corrupt JSON?) \u2014 skipping to avoid data loss"}),s.push(`${D[u.client]?.name||u.client}: corrupt config \u2014 skipped`);continue}let p=Hd(u.config,t),d=ee(u.configPath,p);if(d.success)n.set(u.client,{success:!0,backupPath:d.backupPath});else{let m=d.error||"Unknown write error";n.set(u.client,{success:!1,error:m}),s.push(`${D[u.client]?.name||u.client}: ${m}`)}}for(let{mcpId:u}of t)i.includes(u)||i.push(u);return{success:Array.from(n.values()).every(u=>u.success),clientResults:n,mcpsSynced:i,errors:s}}function Go(e,t){let o=[],n=new Map(t.map(s=>[s.mcpId,s]));for(let s of e.needsSync){let i=Vd(s);i&&o.push({mcpId:s.mcpId,server:i})}for(let s of e.conflicts){let i=n.get(s.mcpId);i&&o.push({mcpId:s.mcpId,server:i.chosenConfig})}return o}function cs(e){return e.summary.needsSyncCount>0||e.summary.conflictCount>0}function se(e){return D[e]?.name||e}function va(e){let{summary:t}=e;if(console.log(),console.log(r("blue"," \u250C"+"\u2500".repeat(60)+"\u2510")),console.log(r("blue"," \u2502 ")+g("MCP Sync Status")+" ".repeat(44)+r("blue","\u2502")),console.log(r("blue"," \u2514"+"\u2500".repeat(60)+"\u2518")),console.log(),console.log(` ${g("Clients:")}`),console.log(` ${r("cyan","\u2022")} ${t.clientsWithConfig} of ${t.totalClients} with MCP configs`),console.log(),console.log(` ${g("MCPs:")}`),console.log(` ${r("cyan","\u2022")} ${t.totalUniqueMCPs} unique MCPs found`),t.consistentMCPs>0){console.log(` ${r("green","\u2705")} ${t.consistentMCPs} fully synced`);for(let o of e.fullyConsistent)console.log(` ${c("\u2022")} ${o.mcpId}`)}if(t.needsSyncCount>0){let o=t.needsSyncCount;console.log(` ${r("yellow","\u25CB")} ${o} can be synced`);for(let n of e.needsSync){let s=n.missingIn.map(se).join(", ");console.log(` ${r("yellow","\u2022")} ${n.mcpId}`),console.log(` ${c(`missing from: ${s}`)}`)}}if(t.conflictCount>0){console.log(` ${r("red","!")} ${t.conflictCount} have conflicts`);for(let o of e.conflicts){let n=Array.from(o.variants.keys()).map(se).join(" vs ");console.log(` ${r("red","\u2022")} ${o.mcpId}`),console.log(` ${c(`different in: ${n}`)}`)}console.log(),console.log(` ${r("cyan","INFO")} ${c("Continue to choose which config to use for each conflict")}`)}console.log()}function wa(e){console.log(` ${g("Client Configurations:")}`),console.log();for(let t of e){let o=se(t.client),n=t.exists?r("green","\u25CF"):r("dim","\u25CB"),s=t.exists?`${t.mcpCount} MCPs`:c("no config");console.log(` ${n} ${o}`),console.log(` ${c(t.configPath)}`),console.log(` ${c(s)}`),console.log()}}function ka(e){let t=e.hasConflict?r("red","!"):e.missingIn.length>0?r("yellow","\u25CB"):r("green","\u2705");console.log(` ${t} ${g(e.mcpId)}`);let o=e.presentIn.map(se).join(", ");if(console.log(` ${c("Present in:")} ${o}`),e.missingIn.length>0){let n=e.missingIn.map(se).join(", ");console.log(` ${r("yellow","Missing from:")} ${n}`)}e.hasConflict&&console.log(` ${r("red","Conflict:")} Different configurations detected`),console.log()}function Sa(e){if(e.fullyConsistent.length>0){console.log(` ${r("green","\u2705")} ${g("Fully Synced:")}`);for(let t of e.fullyConsistent)console.log(` ${r("dim","\u2022")} ${t.mcpId}`);console.log()}if(e.needsSync.length>0){console.log(` ${r("yellow","\u25CB")} ${g("Needs Sync (auto-resolvable):")}`);for(let t of e.needsSync)ka(t)}if(e.conflicts.length>0){console.log(` ${r("red","!")} ${g("Conflicts (requires resolution):")}`);for(let t of e.conflicts)ka(t)}}function Wd(e,t=" "){console.log(`${t}${c("command:")} ${e.command||c("(none)")}`);let o=e.args?.join(" ")||"";if(o&&console.log(`${t}${c("args:")} ${o}`),e.env&&Object.keys(e.env).length>0){console.log(`${t}${c("env:")}`);for(let[n,s]of Object.entries(e.env)){let a=/token|secret|key|password|auth|credential/i.test(n)?"***":s&&s.length>30?s.slice(0,30)+"...":s||"";console.log(`${t} ${r("cyan",n)}: ${a}`)}}}function Pa(e,t=!1){console.log(),console.log(r("yellow"," \u250C"+"\u2500".repeat(60)+"\u2510")),console.log(r("yellow"," \u2502 ")+`${r("yellow","WARN")} Conflict: ${g(e.mcpId)}`+" ".repeat(Math.max(0,43-e.mcpId.length))+r("yellow","\u2502")),console.log(r("yellow"," \u2514"+"\u2500".repeat(60)+"\u2518")),console.log(),console.log(` ${c("This MCP has different configurations across clients:")}`),console.log();let o=1;for(let[n,s]of e.variants){let i=se(n);if(console.log(` ${r("cyan",`[${o}]`)} ${g(i)}`),t)Wd(s," ");else{let a=s.args?.join(" ")||"",l=[s.command,a].filter(Boolean).join(" ");console.log(` ${c("command:")} ${l||c("(none)")}`),s.env&&Object.keys(s.env).length>0&&console.log(` ${c("env:")} ${Object.keys(s.env).length} variables`)}console.log(),o++}}function $a(e,t){console.log(),console.log(r("blue"," \u250C"+"\u2500".repeat(60)+"\u2510")),console.log(r("blue"," \u2502 ")+g("Sync Preview")+" ".repeat(47)+r("blue","\u2502")),console.log(r("blue"," \u2514"+"\u2500".repeat(60)+"\u2518")),console.log(),console.log(` ${g("MCPs to sync:")} ${e.length}`);for(let{mcpId:o}of e)console.log(` ${r("cyan","\u2022")} ${o}`);console.log(),console.log(` ${g("Target clients:")} ${t.length}`);for(let o of t){let n=se(o.client);console.log(` ${r("cyan","\u2022")} ${n}`),console.log(` ${c(o.configPath)}`)}console.log(),console.log(` ${r("yellow","WARN")} ${g("Note:")}`),console.log(` ${c("Backups will be created before modifying any config.")}`),console.log()}function xa(e){if(console.log(),e.success?(console.log(r("green"," \u250C"+"\u2500".repeat(60)+"\u2510")),console.log(r("green"," \u2502 ")+`${r("green","\u2705")} ${g("Sync Complete!")}`+" ".repeat(43)+r("green","\u2502")),console.log(r("green"," \u2514"+"\u2500".repeat(60)+"\u2518"))):(console.log(r("red"," \u250C"+"\u2500".repeat(60)+"\u2510")),console.log(r("red"," \u2502 ")+`${r("red","X")} ${g("Sync completed with errors")}`+" ".repeat(32)+r("red","\u2502")),console.log(r("red"," \u2514"+"\u2500".repeat(60)+"\u2518"))),console.log(),e.mcpsSynced.length>0){console.log(` ${g("Synced MCPs:")} ${e.mcpsSynced.length}`);for(let t of e.mcpsSynced)console.log(` ${r("green","\u2705")} ${t}`);console.log()}console.log(` ${g("Client Results:")}`);for(let[t,o]of e.clientResults){let n=se(t);o.success?(console.log(` ${r("green","\u2705")} ${n}`),o.backupPath&&console.log(` ${c("Backup:")} ${o.backupPath}`)):(console.log(` ${r("red","X")} ${n}`),o.error&&console.log(` ${r("red","Error:")} ${o.error}`))}if(e.errors.length>0){console.log(),console.log(` ${r("red","Errors:")}`);for(let t of e.errors)console.log(` ${r("red","\u2022")} ${t}`)}console.log()}function Ea(){console.log(),console.log(r("green"," \u250C"+"\u2500".repeat(60)+"\u2510")),console.log(r("green"," \u2502 ")+`${r("green","\u2705")} ${g("All MCPs are already in sync!")}`+" ".repeat(28)+r("green","\u2502")),console.log(r("green"," \u2514"+"\u2500".repeat(60)+"\u2518")),console.log(),console.log(` ${c("All your MCP configurations are consistent across clients.")}`),console.log()}async function bt(){console.log(),await q({message:c("Press Enter to continue..."),default:""})}async function qd(e){Pa(e,!0);let t=[],o=1;for(let[s,i]of e.variants){let a=se(s),l=i.args?.join(" ")||"",u=[i.command,l].filter(Boolean).join(" ");t.push({name:`${r("cyan",`[${o}]`)} Use config from ${g(a)}`,value:{client:s,server:i},description:u||"(no command)"}),o++}t.push(new x),t.push({name:`${r("yellow","Skip")} Skip this MCP (don't sync)`,value:"skip"}),t.push({name:`${r("dim","- Back")}`,value:"back"});let n=await E({message:`Choose config for ${g(e.mcpId)}:`,choices:t,loop:!1});return n==="back"||n==="skip"?null:{mcpId:e.mcpId,chosenConfig:n.server,sourceClient:n.client}}async function us(){await W(),console.log(),console.log(r("blue","\u2501".repeat(66))),console.log(` Sync ${g("Sync System MCP")}`),console.log(r("blue","\u2501".repeat(66))),console.log(),console.log(` ${c("Synchronize MCP servers across all your IDE clients")}`);let e={analysis:null,resolutions:[],currentConflictIndex:0},t="analyze";for(;t!=="done";)switch(t){case"analyze":{let o=new A("Scanning client configurations...").start(),n=Xt();if(e.analysis=Yt(n),o.succeed("Configuration scan complete!"),e.analysis.summary.clientsWithConfig<2){console.log(),console.log(` ${r("yellow","WARN")} ${g("Not enough clients to sync")}`),console.log(` ${c("Found only")} ${e.analysis.summary.clientsWithConfig} ${c("client(s) with MCP configs.")}`),console.log(` ${c("Need at least 2 clients to sync.")}`),console.log(),await bt();return}t="showStatus";break}case"showStatus":{let o=pe(e.analysis,"Analysis should be populated before showStatus step");if(va(o),!cs(o)){Ea(),await bt();return}let n=await E({message:"What would you like to do?",choices:[{name:`${r("green","\u2705")} Continue to sync`,value:"continue"},{name:`${r("cyan","INFO")} Show MCP details`,value:"details"},{name:`${r("cyan","INFO")} Show client details`,value:"clients"},new x,{name:`${r("dim","- Back to menu")}`,value:"back"}],loop:!1});if(n==="back")return;if(n==="details"){console.log(),Sa(o),await bt();break}if(n==="clients"){console.log(),wa(o.clients),await bt();break}o.conflicts.length>0?t="resolveConflicts":t="preview";break}case"resolveConflicts":{let n=pe(e.analysis,"Analysis should be populated before resolveConflicts step").conflicts;console.log(),console.log(` ${r("yellow","WARN")} ${g(`Resolve ${n.length} conflict(s)`)}`),console.log(` ${c("You need to choose which configuration to use for each conflicting MCP.")}`),e.resolutions=[];for(let s=0;s<n.length;s++){console.log(),console.log(` ${c(`Conflict ${s+1} of ${n.length}`)}`);let i=await qd(n[s]);if(i===null){console.log(` ${r("yellow","Skip")} Skipping ${g(n[s].mcpId)}`);continue}e.resolutions.push(i),console.log(` ${r("green","\u2705")} Using config from ${g(se(i.sourceClient))}`)}t="preview";break}case"preview":{let o=pe(e.analysis,"Analysis should be populated before preview step"),n=Go(o,e.resolutions);if(n.length===0){console.log(),console.log(` ${r("yellow","WARN")} ${g("No MCPs to sync")}`),console.log(` ${c("All conflicts were skipped or no sync is needed.")}`),console.log(),await bt();return}let s=o.clients.filter(i=>i.exists);$a(n.map(i=>({mcpId:i.mcpId})),s),t="confirm";break}case"confirm":{let o=await E({message:"Proceed with sync?",choices:[{name:`${r("green","\u2705")} Yes, sync all clients`,value:"proceed"},new x,{name:`${r("dim","- Back to review")}`,value:"back"},{name:`${r("dim","X Cancel")}`,value:"cancel"}],loop:!1});if(o==="cancel"){console.log(` ${c("Sync cancelled.")}`);return}if(o==="back"){t="showStatus";break}t="execute";break}case"execute":{let o=pe(e.analysis,"Analysis should be populated before execute step"),n=Go(o,e.resolutions),s=o.clients.filter(l=>l.exists),i=new A("Syncing configurations...").start(),a=ls(o.clients,n,s.map(l=>l.client));a.success?i.succeed("Sync complete!"):i.fail("Sync completed with errors"),xa(a),console.log(` ${g("Next steps:")}`),console.log(` ${c("Restart your IDEs to apply the changes.")}`),console.log(),await bt(),t="done";break}default:break}}async function ds(e){let t=Xt(),o=Yt(t);if(o.summary.clientsWithConfig<2)return{success:!1,message:`Not enough clients to sync (found ${o.summary.clientsWithConfig})`,syncPerformed:!1};if(!cs(o))return{success:!0,message:"All MCPs are already in sync",syncPerformed:!1};if(o.conflicts.length>0&&!e.force)return{success:!1,message:`${o.conflicts.length} conflict(s) found. Use --force to auto-resolve or run interactive mode.`,syncPerformed:!1};let n=[];if(e.force)for(let l of o.conflicts){let u=Array.from(l.variants.entries())[0];u&&n.push({mcpId:l.mcpId,chosenConfig:u[1],sourceClient:u[0]})}let s=Go(o,n);if(e.dryRun)return{success:!0,message:`Would sync ${s.length} MCP(s) to ${o.summary.clientsWithConfig} client(s)`,syncPerformed:!1};let i=o.clients.filter(l=>l.exists),a=ls(o.clients,s,i.map(l=>l.client));return a.success?{success:!0,message:`Synced ${a.mcpsSynced.length} MCP(s) to ${i.length} client(s)`,syncPerformed:!0}:{success:!1,message:`Sync failed: ${a.errors.join(", ")}`,syncPerformed:!0}}import{fileURLToPath as Ma}from"node:url";import{dirname as Aa,join as et,resolve as Ho}from"node:path";import{existsSync as Kd,readFileSync as zd,writeFileSync as mb,mkdirSync as fb}from"node:fs";function Ze(e){let t=e.match(/^---\s*\n([\s\S]*?)\n---/);if(!t)return null;let o=t[1],n=o.match(/^name:\s*(.+)$/m),s=o.match(/^description:\s*(.+)$/m),i=o.match(/^category:\s*(.+)$/m);return{name:n?.[1].trim(),description:s?.[1].trim(),category:i?.[1].trim()}}var Xd=ne.home||process.env.OCTOCODE_HOME||et(B,".octocode"),Ia=ne.cliConfig||et(Xd,"config.json"),Yd=y.object({skillsDestDir:y.string().optional()}).passthrough();function Jd(){return Y(()=>{if(Kd(Ia)){let e=zd(Ia,"utf-8"),t=Yd.safeParse(JSON.parse(e));return t.success?t.data:{}}return{}},{})}function Qd(){return Jd().skillsDestDir||null}function Zd(){if(V){let e=re();return et(e,"Claude","skills")}return et(B,".claude","skills")}function Vo(){let e=Ma(import.meta.url),t=Aa(e),o=[et(t,"..","skills"),et(t,"..","..","..","..","skills"),et(t,"..","..","..","skills")];for(let n of o)if(T(n))return n;throw new Error("Skills directory not found")}function Ta(){let e=Vo();return ke(e).filter(t=>t.startsWith("octocode-"))}function tt(){let e=Ma(import.meta.url),t=Aa(e),o=[Ho(t,"..","skills"),Ho(t,"..","..","..","..","skills"),Ho(t,"..","..","..","skills")];for(let n of o)if(T(n))return n;return Ho(t,"..","skills")}function ue(){let e=Qd();return e||Zd()}import Pt from"node:path";import za from"node:process";import Xa from"node:path";import{fileURLToPath as Ap}from"node:url";import Tp from"node:child_process";import Op,{constants as Lp}from"node:fs/promises";import{promisify as cp}from"node:util";import up from"node:child_process";import ys,{constants as Fa}from"node:fs/promises";import Da from"node:process";import sp from"node:os";import fs from"node:fs";import op from"node:fs";import Oa from"node:fs";var ps;function ep(){try{return Oa.statSync("/.dockerenv"),!0}catch{return!1}}function tp(){try{return Oa.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function gs(){return ps===void 0&&(ps=ep()||tp()),ps}var ms,np=()=>{try{return op.statSync("/run/.containerenv"),!0}catch{return!1}};function ot(){return ms===void 0&&(ms=np()||gs()),ms}var La=()=>{if(Da.platform!=="linux")return!1;if(sp.release().toLowerCase().includes("microsoft"))return!ot();try{if(fs.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!ot()}catch{}return fs.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||fs.existsSync("/run/WSL")?!ot():!1},Le=Da.env.__IS_WSL_TEST__?La:La();import Ra from"node:process";import{Buffer as rp}from"node:buffer";import{promisify as ip}from"node:util";import ap from"node:child_process";import Fb,{constants as Bb}from"node:fs/promises";var lp=ip(ap.execFile),hs=()=>`${Ra.env.SYSTEMROOT||Ra.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;var de=async(e,t={})=>{let{powerShellPath:o,...n}=t,s=de.encodeCommand(e);return lp(o??hs(),[...de.argumentsPrefix,s],{encoding:"utf8",...n})};de.argumentsPrefix=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"];de.encodeCommand=e=>rp.from(e,"utf16le").toString("base64");de.escapeArgument=e=>`'${String(e).replaceAll("'","''")}'`;function _a(e){for(let t of e.split(`
|
|
40
|
-
`)){if(/^\s*#/.test(t))continue;let o=/^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(t);if(o)return o.groups.mountPoint.trim().replaceAll(/^["']|["']$/g,"")}}var dp=cp(up.execFile),pp=(()=>{let e="/mnt/",t;return async function(){if(t)return t;let o="/etc/wsl.conf",n=!1;try{await ys.access(o,Fa.F_OK),n=!0}catch{}if(!n)return e;let s=await ys.readFile(o,{encoding:"utf8"}),i=_a(s);return i===void 0?e:(t=i,t=t.endsWith("/")?t:`${t}/`,t)}})(),gp=async()=>`${await pp()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,Wo=Le?gp:hs,Na,Ba=async()=>(Na??=(async()=>{try{let e=await Wo();return await ys.access(e,Fa.X_OK),!0}catch{return!1}})(),Na),ja=async()=>{let e=await Wo(),t=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{stdout:o}=await de(t,{powerShellPath:e});return o.trim()},Ua=async e=>{if(/^[a-z]+:\/\//i.test(e))return e;try{let{stdout:t}=await dp("wslpath",["-aw",e],{encoding:"utf8"});return t.trim()}catch{return e}};function nt(e,t,o){let n=s=>Object.defineProperty(e,t,{value:s,enumerable:!0,writable:!0});return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let s=o();return n(s),s},set(s){n(s)}}),e}import{promisify as $p}from"node:util";import Ss from"node:process";import{execFile as xp}from"node:child_process";import{promisify as mp}from"node:util";import fp from"node:process";import{execFile as hp}from"node:child_process";var yp=mp(hp);async function Cs(){if(fp.platform!=="darwin")throw new Error("macOS only");let{stdout:e}=await yp("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),o=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??"com.apple.Safari";return o==="com.apple.safari"?"com.apple.Safari":o}import Cp from"node:process";import{promisify as bp}from"node:util";import{execFile as kp,execFileSync as sk}from"node:child_process";var vp=bp(kp);async function Ga(e,{humanReadableOutput:t=!0,signal:o}={}){if(Cp.platform!=="darwin")throw new Error("macOS only");let n=t?[]:["-ss"],s={};o&&(s.signal=o);let{stdout:i}=await vp("osascript",["-e",e,n],s);return i.trim()}async function bs(e){return Ga(`tell application "Finder" to set app_path to application file id "${e}" as string
|
|
41
|
-
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as wp}from"node:util";import{execFile as Sp}from"node:child_process";var Pp=wp(Sp),qo={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},vs=new Map(Object.entries(qo)),ks=class extends Error{};async function ws(e=Pp){let{stdout:t}=await e("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),o=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(t);if(!o)throw new ks(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:n}=o.groups,s=n.lastIndexOf("."),i=n.lastIndexOf("-"),a=s===-1?void 0:n.slice(0,s),l=i===-1?void 0:n.slice(0,i);return qo[n]??qo[a]??qo[l]??{name:n,id:n}}var Ep=$p(xp),Ip=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,t=>t.toUpperCase());async function Ps(){if(Ss.platform==="darwin"){let e=await Cs();return{name:await bs(e),id:e}}if(Ss.platform==="linux"){let{stdout:e}=await Ep("xdg-mime",["query","default","x-scheme-handler/http"]),t=e.trim();return{name:Ip(t.replace(/.desktop$/,"").replace("-"," ")),id:t}}if(Ss.platform==="win32")return ws();throw new Error("Only macOS, Linux, and Windows are supported")}import $s from"node:process";var Mp=!!($s.env.SSH_CONNECTION||$s.env.SSH_CLIENT||$s.env.SSH_TTY),Ha=Mp;var Ko=Symbol("fallbackAttempt"),xs=import.meta.url?Xa.dirname(Ap(import.meta.url)):"",Va=Xa.join(xs,"xdg-open"),{platform:kt,arch:Wa}=za,qa=async(e,t)=>{if(e.length===0)return;let o=[];for(let n of e)try{return await t(n)}catch(s){o.push(s)}throw new AggregateError(o,"Failed to open in all supported apps")},zo=async e=>{e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e};let t=e[Ko]===!0;if(delete e[Ko],Array.isArray(e.app))return qa(e.app,p=>zo({...e,app:p,[Ko]:!0}));let{name:o,arguments:n=[]}=e.app??{};if(n=[...n],Array.isArray(o))return qa(o,p=>zo({...e,app:{name:p,arguments:n},[Ko]:!0}));if(o==="browser"||o==="browserPrivate"){let p={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge","com.apple.safari":"safari"},d={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},m;if(Le){let f=await ja();m=vs.get(f)??{}}else m=await Ps();if(m.id in p){let f=p[m.id.toLowerCase()];if(o==="browserPrivate"){if(f==="safari")throw new Error("Safari doesn't support opening in private mode via command line");n.push(d[f])}return zo({...e,app:{name:vt[f],arguments:n}})}throw new Error(`${m.name} is not supported as a default browser`)}let s,i=[],a={},l=!1;if(Le&&!ot()&&!Ha&&!o&&(l=await Ba()),kt==="darwin")s="open",e.wait&&i.push("--wait-apps"),e.background&&i.push("--background"),e.newInstance&&i.push("--new"),o&&i.push("-a",o);else if(kt==="win32"||l){s=await Wo(),i.push(...de.argumentsPrefix),Le||(a.windowsVerbatimArguments=!0),Le&&e.target&&(e.target=await Ua(e.target));let p=["$ProgressPreference = 'SilentlyContinue';","Start"];e.wait&&p.push("-Wait"),o?(p.push(de.escapeArgument(o)),e.target&&n.push(e.target)):e.target&&p.push(de.escapeArgument(e.target)),n.length>0&&(n=n.map(d=>de.escapeArgument(d)),p.push("-ArgumentList",n.join(","))),e.target=de.encodeCommand(p.join(" ")),e.wait||(a.stdio="ignore")}else{if(o)s=o;else{let p=!xs||xs==="/",d=!1;try{await Op.access(Va,Lp.X_OK),d=!0}catch{}s=za.versions.electron??(kt==="android"||p||!d)?"xdg-open":Va}n.length>0&&i.push(...n),e.wait||(a.stdio="ignore",a.detached=!0)}kt==="darwin"&&n.length>0&&i.push("--args",...n),e.target&&i.push(e.target);let u=Tp.spawn(s,i,a);return e.wait?new Promise((p,d)=>{u.once("error",d),u.once("close",m=>{if(!e.allowNonzeroExitCode&&m!==0){d(new Error(`Exited with code ${m}`));return}p(u)})}):t?new Promise((p,d)=>{u.once("error",d),u.once("spawn",()=>{u.once("close",m=>{if(u.off("error",d),m!==0){d(new Error(`Exited with code ${m}`));return}u.unref(),p(u)})})}):(u.unref(),new Promise((p,d)=>{u.once("error",d),u.once("spawn",()=>{u.off("error",d),p(u)})}))},Dp=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a `target`");return zo({...t,target:e})};function Ka(e){if(typeof e=="string"||Array.isArray(e))return e;let{[Wa]:t}=e;if(!t)throw new Error(`${Wa} is not supported`);return t}function Jt({[kt]:e},{wsl:t}={}){if(t&&Le)return Ka(t);if(!e)throw new Error(`${kt} is not supported`);return Ka(e)}var vt={browser:"browser",browserPrivate:"browserPrivate"};nt(vt,"chrome",()=>Jt({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium","chromium-browser"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));nt(vt,"brave",()=>Jt({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));nt(vt,"firefox",()=>Jt({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));nt(vt,"edge",()=>Jt({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));nt(vt,"safari",()=>Jt({darwin:"Safari"}));var wt=Dp;var Qt=[{id:"octocode-skills",name:"Octocode",type:"github",owner:"bgauryy",repo:"octocode-mcp",branch:"main",skillsPath:"skills",skillPattern:"skill-folders",description:"Research, planning, code review & documentation",url:"https://github.com/bgauryy/octocode-mcp/tree/main/skills"},{id:"anthropic-skills",name:"Anthropic Official",type:"github",owner:"anthropics",repo:"skills",branch:"main",skillsPath:"skills",skillPattern:"skill-folders",description:"Official Anthropic skills \u2014 artifacts, design & docs",url:"https://github.com/anthropics/skills/tree/main/skills"},{id:"superpowers",name:"Superpowers",type:"github",owner:"obra",repo:"superpowers",branch:"main",skillsPath:"skills",skillPattern:"skill-folders",description:"TDD, debugging, worktrees & disciplined development",url:"https://github.com/obra/superpowers"},{id:"everything-claude-code",name:"Everything Claude Code",type:"github",owner:"affaan-m",repo:"everything-claude-code",branch:"main",skillsPath:"skills",skillPattern:"skill-folders",description:"Performance, security, memory & agent harness",url:"https://github.com/affaan-m/everything-claude-code/tree/main/skills"},{id:"composio-skills",name:"Composio Skills",type:"github",owner:"ComposioHQ",repo:"awesome-claude-skills",branch:"master",skillsPath:"",skillPattern:"skill-folders",description:"Brand, canvas, MCP builder, invoicing & testing",url:"https://github.com/ComposioHQ/awesome-claude-skills"},{id:"antigravity-awesome-skills",name:"Antigravity Awesome",type:"github",owner:"sickn33",repo:"antigravity-awesome-skills",branch:"main",skillsPath:"skills",skillPattern:"skill-folders",description:"1,300+ agentic skills across all coding domains",url:"https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills"},{id:"obsidian-skills",name:"Obsidian Skills",type:"github",owner:"kepano",repo:"obsidian-skills",branch:"main",skillsPath:"skills",skillPattern:"skill-folders",description:"Markdown editing & Obsidian vault productivity",url:"https://github.com/kepano/obsidian-skills/tree/main/skills"},{id:"planning-with-files",name:"Planning with Files",type:"github",owner:"OthmanAdi",repo:"planning-with-files",branch:"master",skillsPath:"skills",skillPattern:"skill-folders",description:"Manus-style persistent markdown planning workflow",url:"https://github.com/OthmanAdi/planning-with-files/tree/master/skills"},{id:"marketing-skills",name:"Marketing Skills",type:"github",owner:"coreyhaines31",repo:"marketingskills",branch:"main",skillsPath:"skills",skillPattern:"skill-folders",description:"SEO, copywriting, CRO, analytics & growth engineering",url:"https://github.com/coreyhaines31/marketingskills/tree/main/skills"},{id:"claude-scientific-skills",name:"Scientific Skills",type:"github",owner:"K-Dense-AI",repo:"claude-scientific-skills",branch:"main",skillsPath:"scientific-skills",skillPattern:"skill-folders",description:"Biopython, astropy, deepchem & scientific computing",url:"https://github.com/K-Dense-AI/claude-scientific-skills"},{id:"dev-browser",name:"Dev Browser",type:"github",owner:"SawyerHood",repo:"dev-browser",branch:"main",skillsPath:"skills",skillPattern:"skill-folders",description:"Browser control via Playwright with persistent state",url:"https://github.com/SawyerHood/dev-browser"},{id:"aris-research",name:"ARIS Research",type:"github",owner:"wanshuiyin",repo:"Auto-claude-code-research-in-sleep",branch:"main",skillsPath:"skills",skillPattern:"skill-folders",description:"Autonomous ML research \u2014 papers, reviews & experiments",url:"https://github.com/wanshuiyin/Auto-claude-code-research-in-sleep/tree/main/skills"},{id:"buildwithclaude",name:"Build With Claude",type:"github",owner:"davepoon",repo:"buildwithclaude",branch:"main",skillsPath:"commands",skillPattern:"flat-md",description:"170+ commands, agents & skills hub",url:"https://github.com/davepoon/buildwithclaude"},{id:"claude-code-plugins-plus-skills",name:"Plugins + Skills",type:"github",owner:"jeremylongshore",repo:"claude-code-plugins-plus-skills",branch:"main",skillsPath:"skills",skillPattern:"skill-folders",description:"1,300+ skills with tutorials & orchestration",url:"https://github.com/jeremylongshore/claude-code-plugins-plus-skills"},{id:"ui-ux-pro-max",name:"UI/UX Pro Max",type:"github",owner:"nextlevelbuilder",repo:"ui-ux-pro-max-skill",branch:"main",skillsPath:".claude/skills",skillPattern:"skill-folders",description:"UI/UX, brand guidelines, design systems & styling",url:"https://github.com/nextlevelbuilder/ui-ux-pro-max-skill/tree/main/.claude/skills"},{id:"ctf-skills",name:"CTF Skills",type:"github",owner:"ljagiello",repo:"ctf-skills",branch:"main",skillsPath:"",skillPattern:"skill-folders",description:"Web exploitation, crypto, pwn, reverse & forensics",url:"https://github.com/ljagiello/ctf-skills"},{id:"vltansky-skills",name:"Vltansky Skills",type:"github",owner:"vltansky",repo:"skills",branch:"master",skillsPath:"skills",skillPattern:"skill-folders",description:"QA, interviews, retros, RFC research & code reviews",url:"https://github.com/vltansky/skills/tree/master/skills"},{id:"claude-skills-marketplace",name:"Claude Skills Marketplace",type:"github",owner:"mhattingpete",repo:"claude-skills-marketplace",branch:"main",skillsPath:"",skillPattern:"skill-folders",description:"Git automation, testing & code review",url:"https://github.com/mhattingpete/claude-skills-marketplace"},{id:"daymade-claude-code-skills",name:"Daymade Skills",type:"github",owner:"daymade",repo:"claude-code-skills",branch:"main",skillsPath:"",skillPattern:"skill-folders",description:"Production-ready development workflows",url:"https://github.com/daymade/claude-code-skills"},{id:"webmaxru-agent-skills",name:"Web AI Skills",type:"github",owner:"webmaxru",repo:"agent-skills",branch:"main",skillsPath:"skills",skillPattern:"skill-folders",description:"Web APIs for Web AI \u2014 auto-updated, manually reviewed",url:"https://github.com/webmaxru/agent-skills/tree/main/skills"},{id:"vercel-labs-skills",name:"Vercel Labs",type:"github",owner:"vercel-labs",repo:"skills",branch:"main",skillsPath:"skills",skillPattern:"skill-folders",description:"Open agent skills ecosystem CLI by Vercel",url:"https://github.com/vercel-labs/skills/tree/main/skills"}];var Ya=new Map,Rp=300*1e3;function st(e){return e.type==="local"}async function _p(e){if(e.type==="local")return null;let t=`${e.owner}/${e.repo}`,o=Ya.get(t);if(o&&Date.now()-o.timestamp<Rp)return o.stars;try{let n=`https://api.github.com/repos/${e.owner}/${e.repo}`,s=await fetch(n,{headers:{Accept:"application/vnd.github.v3+json","User-Agent":"octocode-cli"}});if(!s.ok)return null;let a=(await s.json()).stargazers_count;return Ya.set(t,{stars:a,timestamp:Date.now()}),a}catch{return null}}async function Ja(){let e=new Map,t=Qt.map(async o=>{let n=await _p(o);n!==null&&e.set(o.id,n)});return await Promise.all(t),e}import{join as Z,resolve as Qa,relative as Np,isAbsolute as tl,sep as Fp}from"node:path";import{mkdirSync as Es,statSync as Bp,readdirSync as jp,unlinkSync as Up,rmSync as Gp}from"node:fs";import Za from"node:os";var ol=1440*60*1e3,Hp=y.object({timestamp:y.number(),skills:y.array(y.object({}).passthrough())});function Ms(){let e=Za.homedir(),t=process.env.npm_config_cache||Z(e,".npm"),o=Z(t,"_cacache","octocode-skills"),s=Za.platform()==="win32"?Z(process.env.LOCALAPPDATA||Z(e,"AppData","Local"),"octocode","cache","skills"):Z(e,".cache","octocode","skills");return T(t)?o:s}function Vp(){let e=Ms();return T(e)||Es(e,{recursive:!0,mode:448}),e}function el(e,t){let o=Qa(e),n=Qa(t),s=Np(o,n);return s!==".."&&!s.startsWith(`..${Fp}`)&&!tl(s)}function nl(e){let t=Vp();return Z(t,`${e.id}.json`)}function Wp(e){return Y(()=>{if(!Q(e))return!1;let t=Bp(e);return Date.now()-t.mtimeMs<ol},!1)}function qp(e){return Y(()=>{let t=nl(e);if(!Wp(t))return null;let o=He(t);if(!o)return null;let n=JSON.parse(o);if(!Hp.safeParse(n).success)return null;let i=n;return Date.now()-i.timestamp>ol?null:i.skills.map(a=>({...a,source:e}))},null)}function Kp(e,t){Y(()=>{let o=nl(e),n=t.map(({source:i,...a})=>a),s={timestamp:Date.now(),skills:n};return Ot(o,JSON.stringify(s,null,2)),!0},!1)}function Is(e){let t=["PR","API","UI","CLI","MCP","AI"];return e.replace(/\.md$/i,"").replace(/[-_]/g," ").replace(/\b\w/g,o=>o.toUpperCase()).replace(new RegExp(`\\b(${t.join("|")})\\b`,"gi"),o=>o.toUpperCase())}function zp(e){try{let t=Vo(),o=Ta(),n=[];for(let s of o){let i=Z(t,s),a=Z(i,"SKILL.md");if(Q(a)){let l=He(a);if(l){let u=Ze(l);n.push({name:s,displayName:Is(s),description:u?.description||rl(l)||"No description",category:u?.category||"Official",path:s,source:e})}}}return n}catch{return[]}}function Xp(e,t){try{let o=Vo(),n=Z(o,e.name),s=Z(t,e.name);return T(n)?(T(s)&&Gp(s,{recursive:!0,force:!0}),mt(n,s),{success:!0}):{success:!1,error:"Skill not found in bundled source"}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Unknown error"}}}async function sl(e){let t=`https://api.github.com/repos/${e.owner}/${e.repo}/git/trees/${e.branch}?recursive=1`,o=await fetch(t,{headers:{Accept:"application/vnd.github.v3+json","User-Agent":"octocode-cli"}});if(!o.ok)throw o.status===403?new Error("GitHub API rate limit exceeded. Try again later."):new Error(`Failed to fetch marketplace: ${o.statusText}`);let n=await o.json();return n.truncated&&console.warn(`[octocode] GitHub tree response was truncated for ${e.owner}/${e.repo}. Some skills may be missing.`),n.tree}var Xo=1024*1024;async function Yo(e,t){let o=`https://raw.githubusercontent.com/${e.owner}/${e.repo}/${e.branch}/${t}`,n=await fetch(o,{headers:{"User-Agent":"octocode-cli"}});if(!n.ok)throw new Error(`Failed to fetch content: ${n.statusText}`);let s=n.headers?.get?.("Content-Length"),i=s?Number(s):NaN;if(Number.isFinite(i)&&i>Xo)throw new Error(`Content too large: ${i} bytes exceeds ${Xo} byte limit`);let a=await n.text(),l=Buffer.byteLength(a,"utf8");if(l>Xo)throw new Error(`Content too large: ${l} bytes exceeds ${Xo} byte limit`);return a}async function As(e,t={}){if(st(e))return zp(e);if(!t.skipCache){let s=qp(e);if(s)return s}let o=await sl(e),n=[];if(e.skillPattern==="flat-md"){let s=e.skillsPath?`${e.skillsPath}/`:"",a=o.filter(u=>u.type==="blob"&&u.path.startsWith(s)&&u.path.endsWith(".md")&&!u.path.includes("/")==(s==="")&&(s===""||u.path.split("/").length===2)).slice(0,100),l=await Promise.all(a.map(async u=>{try{let p=await Yo(e,u.path),d=Ze(p),m=u.path.split("/").pop()||u.path;return{name:m.replace(/\.md$/i,""),displayName:Is(m),description:d?.description||"No description available",category:d?.category,path:u.path,source:e}}catch{return null}}));n.push(...l.filter(u=>u!==null))}else{let s=e.skillsPath?`${e.skillsPath}/`:"",i=o.filter(l=>l.type==="tree"&&(s===""||l.path.startsWith(s))&&!l.path.includes(".")&&!l.path.startsWith(".")),a=await Promise.all(i.slice(0,50).map(async l=>{let u=`${l.path}/SKILL.md`,p=`${l.path}/README.md`,d=o.some(C=>C.path===u&&C.type==="blob"),m=o.some(C=>C.path===p&&C.type==="blob"),f=d?u:m?p:null;if(!f)return null;try{let C=await Yo(e,f),w=Ze(C),v=l.path.split("/").pop()||l.path;return{name:v,displayName:Is(v),description:w?.description||rl(C)||"No description",category:w?.category,path:l.path,source:e}}catch{return null}}));n.push(...a.filter(l=>l!==null))}return Kp(e,n),n}function rl(e){let o=e.replace(/^---[\s\S]*?---\s*/,"").split(`
|
|
42
|
-
`),n="";for(let s of o){let i=s.trim();if(!i){if(n)break;continue}i.startsWith("#")||(n+=(n?" ":"")+i)}return n?n.slice(0,200):null}async function Ts(e,t){try{let o=e.source;if(st(o))return Xp(e,t);let n=await sl(o),s=Z(t,e.name);if(T(s)||Es(s,{recursive:!0,mode:448}),o.skillPattern==="flat-md"){let i=await Yo(o,e.path),a=Z(s,"SKILL.md");if(!el(s,a))throw new Error("Invalid skill destination path");Ot(a,i)}else{let i=`${e.path}/`,a=n.filter(l=>l.type==="blob"&&l.path.startsWith(i));for(let l of a){let u=l.path.slice(i.length);if(!u||tl(u))throw new Error("Invalid skill file path");let p=Z(s,u);if(!el(s,p))throw new Error("Invalid skill file path traversal");let d=Z(s,u.split("/").slice(0,-1).join("/"));d!==s&&!T(d)&&Es(d,{recursive:!0,mode:448})}await Promise.all(a.map(async l=>{let u=l.path.slice(i.length),p=Z(s,u),d=await Yo(o,l.path);Ot(p,d)}))}return{success:!0}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Unknown error"}}}function il(){Y(()=>{let e=Ms();if(T(e)){let t=jp(e);for(let o of t)o.endsWith(".json")&&Up(Z(e,o))}return!0},!1)}function al(){return Ms()}import Qo from"node:path";var Jo=new Set(["octocode-research","octocode-pull-request-reviewer","octocode-researcher"]);async function Pe(){console.log(),await q({message:c("Press Enter to continue..."),default:""})}function Yp(e,t){if(st(e))return`${g(e.name)} ${r("cyan","bundled")} - ${c(e.description)}`;let o=t?` ${t.toLocaleString()}`:"";return`${g(e.name)}${r("yellow",o)} - ${c(e.description)}`}function Jp(e,t){let o=t?r("green","\u2705 "):"",n=Jo.has(e.name)?r("yellow"," *"):"",s=e.description.slice(0,50),i=e.description.length>50?"...":"";return`${o}${e.displayName}${n} ${c(s)}${c(i)}`}function St(e){let t=ue();return T(Qo.join(t,e))}async function Qp(e){console.log(),console.log(` ${g("Select a marketplace to browse:")}`),console.log();let t=Qt.filter(l=>st(l)),n=[...Qt.filter(l=>!st(l))].sort((l,u)=>(e.get(u.id)??0)-(e.get(l.id)??0)),s=[...t,...n],i=[];for(let l of s)i.push({name:Yp(l,e.get(l.id)),value:l,description:c(l.url)});return i.push(new x),i.push({name:`${r("dim","- Back to skills menu")}`,value:"back"}),await E({message:"",choices:i,pageSize:10,loop:!1,theme:{prefix:" ",style:{highlight:l=>r("magenta",l)}}})}async function ll(e,t){console.log(),console.log(` ${g(e.name)} - ${t.length} skills available`),console.log(` ${c(e.url)}`),console.log();let n=[...t].sort((a,l)=>{let u=St(a.name),p=St(l.name);if(u!==p)return u?-1:1;let d=Jo.has(a.name),m=Jo.has(l.name);return d!==m?d?-1:1:a.displayName.localeCompare(l.displayName)}).map(a=>{let l=St(a.name);return{name:Jp(a,l),value:a,description:a.category?`[${a.category}]`:void 0}}),s={name:`${r("dim","- Back to marketplaces")}`,value:"back"};return await Gt({message:`Type to filter skills (${t.length} available)`,source:a=>{if(!a||!a.trim())return[...n,s];let l=a.toLowerCase();return[...n.filter(p=>{if(typeof p.value=="string")return!1;let d=p.value;return d.name.toLowerCase().includes(l)||d.displayName.toLowerCase().includes(l)||d.description.toLowerCase().includes(l)||d.category?.toLowerCase().includes(l)}),s]},pageSize:20,theme:{prefix:" ",style:{highlight:a=>r("magenta",a)}}})}async function cl(e){let t=St(e.name),o=ue(),n=Jo.has(e.name)?r("yellow"," recommended"):"";console.log(),console.log(` ${g(e.displayName)}${n}`),console.log(` ${c(e.description)}`),console.log(),e.category&&(console.log(` ${g("Category:")} ${e.category}`),console.log()),console.log(` ${g("Source:")} ${e.source.name}`),console.log(` ${c(e.source.url)}`),console.log(),console.log(` ${g("Install path:")}`),console.log(` ${r("cyan",Qo.join(o,e.name))}`),console.log();let s=[{name:t?`${r("yellow","\u2B06")} Reinstall skill`:`${r("green","\u2705")} Install skill`,value:"install"}];return t&&s.push({name:`${r("red","Delete")} Delete skill`,value:"delete"}),s.push(new x),s.push({name:`${r("dim","- Back")}`,value:"back"}),await E({message:t?"Choose an action:":"Install this skill?",choices:s,loop:!1,theme:{prefix:" ",style:{highlight:a=>r("magenta",a),message:a=>g(a)}}})}async function ul(e){let t=ue();console.log();let o=new A(`Installing ${e.displayName}...`).start(),n=await Ts(e,t);return n.success?(o.succeed(`Installed ${e.displayName}!`),console.log(),console.log(` ${r("green","\u2705")} Skill installed successfully`),console.log(` ${c("Location:")} ${r("cyan",Qo.join(t,e.name))}`),console.log(),console.log(` ${g("The skill is now available in your AI client!")}`)):(o.fail(`Failed to install ${e.displayName}`),console.log(),console.log(` ${r("red","X")} Installation failed: ${n.error}`)),console.log(),await Pe(),n.success}async function dl(e){let t=ue(),o=Qo.join(t,e.name);if(console.log(),await E({message:"Delete this installed skill?",choices:[{name:`${r("red","Delete")} Yes, delete skill`,value:"yes"},new x,{name:`${r("dim","- Cancel")}`,value:"no"}],loop:!1,theme:{prefix:" ",style:{highlight:i=>r("magenta",i),message:i=>g(i)}}})!=="yes")return!1;console.log();let s=new A(`Deleting ${e.displayName}...`).start();return ft(o)?(s.succeed(`Deleted ${e.displayName}`),console.log(),console.log(` ${r("green","\u2705")} Skill deleted successfully`),console.log(),await Pe(),!0):(s.fail(`Failed to delete ${e.displayName}`),console.log(),console.log(` ${r("red","X")} Could not delete skill directory`),console.log(` ${c("Path:")} ${r("cyan",o)}`),console.log(),await Pe(),!1)}async function Zp(e,t){console.log(),console.log(` ${g("Octocode Skills")}`),console.log(` ${c(`${e} skills available`)}`),console.log();let o=[];return t>0?(o.push({name:`${r("green","Fast")} Install All Skills (${t} to install)`,value:"install-all",description:c("One-click install of all Octocode skills")}),o.push({name:`${r("cyan","List")} Browse Skills Individually`,value:"browse",description:c("View details and install one by one")})):o.push({name:`${r("green","\u2705")} All skills installed \u2014 Browse to reinstall or view details`,value:"browse",description:c("View details and reinstall individually")}),o.push(new x),o.push({name:`${r("dim","- Back")}`,value:"back"}),await E({message:"",choices:o,loop:!1,theme:{prefix:" ",style:{highlight:s=>r("magenta",s)}}})}async function eg(e){let t=ue(),o=e.filter(l=>!St(l.name));if(o.length===0){console.log(),console.log(` ${r("green","\u2705")} All skills are already installed!`),console.log(),await Pe();return}console.log(),console.log(` ${g("Installing")} ${o.length} ${g("skills...")}`),console.log();let n=new A(`Installing ${o.length} skills...`).start(),s=0,i=0,a=[];for(let l of o){n.update(`Installing ${l.displayName}... (${s+i+1}/${o.length})`);let u=await Ts(l,t);u.success?s++:(i++,a.push({skill:l.displayName,error:u.error||"Unknown error"}))}if(i===0?n.succeed(`All ${s} skills installed successfully!`):n.warn(`Installed ${s} skills, ${i} failed`),console.log(),s>0&&(console.log(` ${r("green","\u2705")} Successfully installed ${s} skill(s)`),console.log(` ${c("Location:")} ${r("cyan",t)}`)),a.length>0){console.log(),console.log(` ${r("red","X")} Failed to install:`);for(let{skill:l,error:u}of a)console.log(` ${r("red","\u2022")} ${l}: ${c(u)}`)}console.log(),console.log(` ${g("Skills are now available in your AI client!")}`),console.log(),await Pe()}async function pl(){console.log(),console.log(` ${r("yellow","WARN")} ${c("Community list \u2022 Skills install on your behalf")}`);let e=new A("Fetching marketplace info...").start(),t;try{t=await Ja(),e.succeed("Loaded marketplace info")}catch{e.fail("Could not fetch stars"),t=new Map}let o=!0;for(;o;){let n=await Qp(t);if(n==="back"){o=!1;continue}console.log();let s=new A(`Loading skills from ${n.name}...`).start(),i;try{i=await As(n),s.stop()}catch(l){s.fail("Failed to load skills"),console.log(),console.log(` ${r("red","X")} ${l instanceof Error?l.message:"Unknown error"}`),console.log(),await Pe();continue}if(i.length===0){console.log(),console.log(` ${r("yellow","WARN")} No skills found in this marketplace`),console.log(),await Pe();continue}let a=!0;for(;a;){let l=await ll(n,i);if(l==="back"){a=!1;continue}let u=await cl(l);u==="install"?await ul(l):u==="delete"&&await dl(l)}}}async function gl(){let e=Qt.find(s=>s.id==="octocode-skills");if(!e){console.log(),console.log(` ${r("red","X")} Octocode Skills source not found`),console.log(),await Pe();return}console.log();let t=new A("Loading Octocode Skills...").start(),o;try{o=await As(e),t.stop()}catch(s){t.fail("Failed to load skills"),console.log(),console.log(` ${r("red","X")} ${s instanceof Error?s.message:"Unknown error"}`),console.log(),await Pe();return}if(o.length===0){console.log(),console.log(` ${r("yellow","WARN")} No skills found`),console.log(),await Pe();return}let n=!0;for(;n;){let s=o.filter(a=>!St(a.name)).length;switch(await Zp(o.length,s)){case"install-all":await eg(o),n=!1;break;case"browse":{let a=!0;for(;a;){let l=await ll(e,o);if(l==="back"){a=!1;continue}let u=await cl(l);u==="install"?await ul(l):u==="delete"&&await dl(l)}break}default:n=!1;break}}}var tg=new Set(["octocode-research","octocode-pull-request-reviewer","octocode-researcher"]);async function Zt(){console.log(),await q({message:c("Press Enter to continue..."),default:""})}function fl(){let e=ue(),t=tt();if(!T(e))return[];let o=ke(e).filter(s=>!s.startsWith(".")),n=[];for(let s of o){let i=Pt.join(e,s),a=Pt.join(i,"SKILL.md"),l=s.startsWith("octocode-")&&T(t)&&T(Pt.join(t,s)),u=tg.has(s);if(Q(a)){let p=He(a);if(p){let d=Ze(p);if(d?.name&&d.description){n.push({name:d.name,description:d.description,folder:s,path:i,isBundled:l,isRecommended:u});continue}}}n.push({name:ng(s),description:"No description available",folder:s,path:i,isBundled:l,isRecommended:u})}return n.sort((s,i)=>s.isRecommended!==i.isRecommended?s.isRecommended?-1:1:s.name.localeCompare(i.name)),n}function ml(){let e=tt(),t=ue();if(!T(e))return{srcDir:e,destDir:t,skillsStatus:[],notInstalled:[],sourceExists:!1};let n=ke(e).filter(i=>!i.startsWith(".")).map(i=>({name:i,installed:T(Pt.join(t,i)),srcPath:Pt.join(e,i),destPath:Pt.join(t,i)})),s=n.filter(i=>!i.installed);return{srcDir:e,destDir:t,skillsStatus:n,notInstalled:s,sourceExists:!0}}async function og(e){let t=[];return e>0&&t.push({name:`- Manage installed skills ${c(`(${e})`)}`,value:"manage",description:"View, remove, or inspect individual skills"}),t.push({name:"- Browse Marketplace",value:"marketplace",description:"Community skills \u2022 installs on your behalf"}),t.push(new x),t.push({name:`${r("dim","- Back to main menu")}`,value:"back"}),await E({message:"",choices:t,pageSize:10,loop:!1,theme:{prefix:" ",style:{highlight:n=>r("magenta",n)}}})}function ng(e){let t=["PR","API","UI","CLI","MCP","AI"];return e.replace(/^octocode-/,"").split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ").replace(new RegExp(`\\b(${t.join("|")})\\b`,"gi"),n=>n.toUpperCase())}async function sg(e){console.log(),console.log(` ${g("Installed Skills")} ${c(`(${e.length} total)`)}`),console.log(` ${c("Select a skill to manage")}`),console.log();let t=[];for(let n of e){let s=n.isRecommended?r("yellow","\u2605 "):"",i=n.isBundled?r("cyan"," [bundled]"):r("magenta"," [community]"),a=n.description.slice(0,40),l=n.description.length>40?"...":"";t.push({name:`${s}${n.name}${i} - ${c(a)}${c(l)}`,value:n})}return t.push(new x),t.push({name:`${r("dim","- Back to skills menu")}`,value:"back"}),await E({message:"",choices:t,pageSize:15,loop:!1,theme:{prefix:" ",style:{highlight:n=>r("magenta",n)}}})}async function rg(e){let t=e.isRecommended?r("yellow","recommended "):"",o=e.isBundled?r("cyan","[bundled]"):r("magenta","[community]");console.log(),console.log(` ${g(e.name)} ${t}${o}`),console.log(` ${c(e.description)}`),console.log(` ${c(e.path)}`),console.log();let n=[{name:`${r("red","Delete")} Remove this skill`,value:"remove"},{name:"- Open skill location",value:"view"},new x,{name:`${r("dim","- Back")}`,value:"back"}];return await E({message:"",choices:n,loop:!1,theme:{prefix:" ",style:{highlight:i=>r("magenta",i)}}})}async function ig(e){console.log(),console.log(` ${r("cyan","Path")} Opening ${g(e.name)} location...`),console.log(` ${c(e.path)}`),console.log();try{await wt(e.path),console.log(` ${r("green","\u2705")} Opened in file explorer`)}catch{console.log(` ${r("yellow","!")} Could not open location automatically`),console.log(` ${c("Path:")} ${r("cyan",e.path)}`)}console.log()}async function ag(e){console.log(),console.log(` ${r("yellow","WARN")} You are about to remove:`),console.log(` ${g(e.name)}`),console.log(` ${c(e.path)}`),console.log();let t=[{name:`${r("red","Delete")} Yes, remove this skill`,value:!0},new x,{name:`${r("dim","- Cancel")}`,value:!1}];if(!await E({message:"Confirm removal?",choices:t,loop:!1,theme:{prefix:" ",style:{highlight:s=>r("magenta",s),message:s=>g(s)}}}))return!1;console.log();let n=new A(`Removing ${e.name}...`).start();return ft(e.path)?(n.succeed(`Removed ${e.name}`),console.log(),console.log(` ${r("green","\u2705")} Skill removed successfully`),!0):(n.fail(`Failed to remove ${e.name}`),console.log(),console.log(` ${r("red","X")} Could not remove skill directory`),!1)}async function lg(){let e=!0;for(;e;){let t=fl();if(t.length===0){console.log(),console.log(` ${r("yellow","INFO")} No skills installed`),console.log(` ${c("Browse the marketplace to install skills")}`),console.log(),await Zt();return}let o=await sg(t);if(o==="back"){e=!1;continue}let n=!0;for(;n;)switch(await rg(o)){case"remove":{await ag(o)&&(await Zt(),n=!1);break}case"view":await ig(o),await Zt();break;default:n=!1;break}}}async function hl(){await W();let e=ml();if(!e.sourceExists){console.log(` ${r("yellow","WARN")} Skills source directory not found.`),console.log(` ${c("This may happen if running from source.")}`),console.log(),await Zt();return}if(e.skillsStatus.length===0){console.log(` ${c("No skills available.")}`),console.log(),await Zt();return}let t=!0;for(;t;){e=ml();let n=fl().length;switch(await og(n)){case"manage":await lg();break;case"marketplace":await pl();break;default:t=!1;break}}}async function Cl(e,t){let o=cg(e,t.auth);if(o)return o;let{data:n}=await wr({clientType:e.clientType,clientId:e.clientId,request:t.request||e.request,scopes:t.auth.scopes||e.scopes});await e.onVerification(n);let s=await Os(t.request||e.request,e.clientId,e.clientType,n);return e.authentication=s,s}function cg(e,t){if(t.refresh===!0||!e.authentication)return!1;if(e.clientType==="github-app")return e.authentication;let o=e.authentication,n=("scopes"in t&&t.scopes||e.scopes).join(" "),s=o.scopes.join(" ");return n===s?o:!1}async function yl(e){await new Promise(t=>setTimeout(t,e*1e3))}async function Os(e,t,o,n){try{let s={clientId:t,request:e,code:n.device_code},{authentication:i}=o==="oauth-app"?await pn({...s,clientType:"oauth-app"}):await pn({...s,clientType:"github-app"});return{type:"token",tokenType:"oauth",...i}}catch(s){if(!s.response)throw s;let i=s.response.data.error;if(i==="authorization_pending")return await yl(n.interval),Os(e,t,o,n);if(i==="slow_down")return await yl(n.interval+7),Os(e,t,o,n);throw s}}async function ug(e,t){return Cl(e,{auth:t})}async function dg(e,t,o,n){let s=t.endpoint.merge(o,n);if(/\/login\/(oauth\/access_token|device\/code)$/.test(s.url))return t(s);let{token:i}=await Cl(e,{request:t,auth:{type:"oauth"}});return s.headers.authorization=`token ${i}`,t(s)}var pg="0.0.0-development";function bl(e){let t=e.request||J.defaults({headers:{"user-agent":`octokit-auth-oauth-device.js/${pg} ${ct()}`}}),{request:o=t,...n}=e,s=e.clientType==="github-app"?{...n,clientType:"github-app",request:o}:{...n,clientType:"oauth-app",request:o,scopes:e.scopes||[]};if(!e.clientId)throw new Error('[@octokit/auth-oauth-device] "clientId" option must be set (https://github.com/octokit/auth-oauth-device.js#usage)');if(!e.onVerification)throw new Error('[@octokit/auth-oauth-device] "onVerification" option must be a function (https://github.com/octokit/auth-oauth-device.js#usage)');return Object.assign(ug.bind(null,s),{hook:dg.bind(null,s)})}var kl="https://cli.github.com/";function vl(){return _i("gh")}function rt(){if(!vl())return{installed:!1,authenticated:!1,error:"GitHub CLI (gh) is not installed"};let e=Je("gh",["auth","status"]);if(e.success){let t=e.stdout.match(/Logged in to \S+.*account\s+(\S+)/i);return{installed:!0,authenticated:!0,username:t?t[1]:void 0}}return{installed:!0,authenticated:!1,error:e.stderr||"Not authenticated"}}function wl(e){let t=["auth","logout"];return e&&t.push("--hostname",e),Ni("gh",t)}function eo(e){if(!vl())return null;let t=["auth","token"];e&&t.push("--hostname",e);let o=Je("gh",t);return o.success&&o.stdout.trim()?o.stdout.trim():null}var Ls="178c6fc778ccc68e1d6a",mg=["repo","read:org","gist"],Be="github.com";function Ds(e){return e==="github.com"||e===Be?"https://api.github.com":`https://${e}/api/v3`}async function fg(e,t){let o=Ds(t);return(await J("GET /user",{headers:{authorization:`token ${e}`},baseUrl:o})).data.login}async function Zo(e={}){let{hostname:t=Be,scopes:o=mg,gitProtocol:n="https",clientId:s=Ls,onVerification:i,openBrowser:a=!0}=e;try{let u=await bl({clientType:"oauth-app",clientId:s,scopes:o,onVerification:async f=>{if(i&&i(f),a)try{await wt(f.verification_uri)}catch{console.log(),console.log(" \u26A0 Could not open browser automatically."),console.log(" \u2192 Please open this URL manually:"),console.log(` ${f.verification_uri}`),console.log()}},request:J.defaults({baseUrl:Ds(t)})})({type:"oauth"}),p=await fg(u.token,t),d={token:u.token,tokenType:"oauth",scopes:"scopes"in u?u.scopes:void 0};"refreshToken"in u&&u.refreshToken&&(d.refreshToken=u.refreshToken,d.expiresAt="expiresAt"in u?u.expiresAt:void 0,d.refreshTokenExpiresAt="refreshTokenExpiresAt"in u?u.refreshTokenExpiresAt:void 0);let m={hostname:t,username:p,token:d,gitProtocol:n,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};return await mo(m),{success:!0,username:p,hostname:t}}catch(l){return{success:!1,error:l instanceof Error?l.message:"Authentication failed"}}}async function $t(e=Be,t){let o=await Ie(e);if(!o)return{success:!1,error:`Not logged in to ${e}`};if(t?.clientSecret)try{await Pr({clientType:"oauth-app",clientId:Ls,clientSecret:t.clientSecret,token:o.token.token,request:J.defaults({baseUrl:Ds(e)})})}catch(n){console.error(`[github-oauth] Token revocation failed: ${n instanceof Error?n.message:String(n)}`)}return await Cn(e),{success:!0}}function it(e=Be){if(pt()){let n=Tt();return{authenticated:!0,hostname:e,username:void 0,tokenSource:"env",envTokenSource:n??void 0}}let t=yn(e);if(t){let n=Ge(t);return{authenticated:!n,hostname:t.hostname,username:t.username,tokenExpired:n,tokenSource:"octocode"}}let o=rt();return o.authenticated?{authenticated:!0,hostname:e,username:o.username,tokenSource:"gh-cli"}:{authenticated:!1,tokenSource:"none"}}async function to(e=Be){if(pt()){let n=Tt();return{authenticated:!0,hostname:e,username:void 0,tokenSource:"env",envTokenSource:n??void 0}}let t=await Ie(e);if(t){let n=Ge(t);return{authenticated:!n,hostname:t.hostname,username:t.username,tokenExpired:n,tokenSource:"octocode"}}let o=rt();return o.authenticated?{authenticated:!0,hostname:e,username:o.username,tokenSource:"gh-cli"}:{authenticated:!1,tokenSource:"none"}}async function Rs(e=Be){let t=await fo(e,Ls);return t.token?{token:t.token,source:"octocode",username:t.username}:{token:null,source:"none"}}function _s(e=Be){let t=eo(e);if(t){let o=rt();return{token:t,source:"gh-cli",username:o.username}}return{token:null,source:"none"}}async function Sl(e=Be,t="auto"){if(t==="octocode")return Rs(e);if(t==="gh")return _s(e);let o=await hn({hostname:e,getGhCliToken:eo});if(o?.token){let n=o.source==="gh-cli"?"gh-cli":o.source?.startsWith("env:")?"env":"octocode";return{token:o.token,source:n,username:o.username,envSource:o.source?.startsWith("env:")?o.source:void 0}}return{token:null,source:"none"}}function oo(){return bn()}function Pl(e,t){switch(e){case"env":return t??"env:GITHUB_TOKEN";case"gh-cli":return"gh-cli";case"octocode":return"octocode-storage";default:return"none"}}import Ns from"node:path";function hg(){let e=ko(),t=e.filter(n=>n.octocodeInstalled),o=e.filter(n=>n.configExists&&!n.octocodeInstalled);return{installedClients:t,availableClients:o,installedCount:t.length,availableCount:o.length,isInstalled:t.length>0,hasMoreToInstall:o.length>0}}function yg(){let e=tt(),t=ue(),o=T(t)?ke(t).filter(l=>!l.startsWith(".")).length:0;if(!T(e))return{sourceExists:!1,destDir:t,skills:[],installedCount:0,notInstalledCount:0,totalInstalledCount:o,allInstalled:!1,hasSkills:!1};let s=ke(e).filter(l=>!l.startsWith(".")).map(l=>({name:l,installed:T(Ns.join(t,l)),srcPath:Ns.join(e,l),destPath:Ns.join(t,l)})),i=s.filter(l=>l.installed).length,a=s.filter(l=>!l.installed).length;return{sourceExists:!0,destDir:t,skills:s,installedCount:i,notInstalledCount:a,totalInstalledCount:o,allInstalled:a===0&&s.length>0,hasSkills:s.length>0}}async function no(){return{octocode:hg(),skills:yg(),currentClient:ht(),githubAuth:await to()}}function Cg(e){let t=e.trim();if(t.length===0)return{kind:"empty"};if(["exit","quit","back"].includes(t))return{kind:"exit"};if(t==="list"||t==="help")return{kind:"list"};let o=t.search(/\s/);return o===-1?{kind:"execute",toolName:t}:{kind:"execute",toolName:t.slice(0,o),inputText:t.slice(o).trim()}}function bg(e,t){return{command:"tool",args:t?[e,t]:[e],options:{}}}async function $l(){for(await W(),console.log(),console.log(` ${r("magenta",g("Tool Terminal"))}`),console.log(` ${c("Type")} ${r("cyan","list")} ${c("for tools,")} ${r("cyan",'<toolName> {"path":".","pattern":"runCLI"}')} ${c("to run, or")} ${r("cyan","exit")} ${c("to return.")}`),await sn();;){let e=await q({message:r("cyan","tool>"),default:""}),t=Cg(e);if(t.kind!=="empty"){if(t.kind==="exit"){console.log();return}if(t.kind==="list"){await sn();continue}await Qs(bg(t.toolName,t.inputText)),console.log()}}}async function en(){console.log(),await q({message:c("Press Enter to continue..."),default:""})}function kg(e){return e.map(t=>D[t.client]?.name||t.client).join(", ")}function vg(e){if(e.length===0){console.log(` ${c("No IDEs configured yet")}`);return}console.log(` ${c("Installed on:")}`);for(let t of e){let o=D[t.client]?.name||t.client;console.log(` ${c("\u2022")} ${c(o)} ${c("->")} ${r("cyan",t.configPath)}`)}}function wg(e){return!e.sourceExists||!e.hasSkills?{name:`${c("- Manage System Skills")}`,value:"skills",description:c("Not available \u2014 no skill sources found")}:e.allInstalled?{name:`- Manage System Skills ${r("green","\u2705")}`,value:"skills",description:`${e.totalInstalledCount} installed \u2022 Research, PR Review & more`}:e.totalInstalledCount>0?{name:"- Manage System Skills",value:"skills",description:`${e.totalInstalledCount}/${e.skills.length} installed \u2022 Get more skills!`}:{name:`- ${g("Manage System Skills")} ${r("cyan","[NEW]")}`,value:"skills",description:"Install skills for AI-powered coding workflows"}}function Sg(e){let t=e.skills.filter(o=>o.name.startsWith("octocode-")&&o.installed).length;return t>0?{name:`- Octocode Skills ${r("green","\u2705")}`,value:"octocode-skills",description:`${t} installed \u2022 Research, planning & review`}:{name:"- Octocode Skills",value:"octocode-skills",description:"Install AI-powered research, planning & review skills"}}function Pg(e){switch(e.tokenSource){case"gh-cli":return"gh CLI";case"env":return e.envTokenSource?`env (${e.envTokenSource.replace("env:","")})`:"env var";case"octocode":return"Octocode";default:return"unknown"}}function $g(e){if(e.authenticated){let t=Pg(e),o=e.username?`@${e.username}`:"",n=o?`${o} `:"";return{name:`- Manage Auth ${r("green","\u2705")}`,value:"auth",description:`${n}via ${t}`}}return{name:`- ${g("Manage Auth")} ${r("red","[Required]")}`,value:"auth",description:"Sign in to access GitHub"}}function xg(e){let t=[];if(e.octocode.isInstalled){let o=e.octocode.installedCount===1?"client":"clients";t.push(`${r("green","\u25CF")} ${e.octocode.installedCount} ${o}`)}else t.push(`${r("yellow","\u25CB")} Not installed`);return e.skills.totalInstalledCount>0?t.push(`${r("green","\u25CF")} ${e.skills.totalInstalledCount} skills`):e.skills.sourceExists&&e.skills.hasSkills&&t.push(`${r("yellow","\u25CB")} ${e.skills.skills.length} skills`),t.join(c(" \u2502 "))}function Eg(e){if(e.octocode.isInstalled){let t=e.octocode.installedCount===1?"IDE":"IDEs";return e.githubAuth.authenticated?{name:`- Octocode MCP ${r("green","\u2705")}`,value:"octocode",description:`Configure Octocode MCP - ${e.octocode.installedCount} ${t} configured`}:{name:`- Octocode MCP ${r("red","[X]")}`,value:"octocode",description:`Configure Octocode MCP - ${e.octocode.installedCount} ${t} configured`}}return{name:`- ${g("Octocode Configuration")}`,value:"octocode",description:"Configure Octocode MCP - 0 IDEs configured"}}function Ig(e){e.githubAuth.authenticated?e.octocode.isInstalled&&e.skills.totalInstalledCount===0&&(console.log(),console.log(` ${r("cyan","Tip:")} ${c("Boost your AI coding:")} Install ${r("magenta","Skills")} for research, PR review & more!`)):(console.log(),console.log(` ${r("yellow","Warning:")} ${g("Auth required!")} Run ${r("cyan","Manage Auth")} to access GitHub repos`))}async function Mg(e){console.log(),console.log(` ${c("Status:")} ${xg(e)}`),Ig(e);let t=[];return t.push(Eg(e)),t.push(Sg(e.skills)),t.push(wg(e.skills)),t.push($g(e.githubAuth)),t.push({name:"- Manage System MCP",value:"mcp-config",description:"Add, sync and configure MCP across all IDEs"}),t.push({name:"- Tool Terminal",value:"terminal",description:"Run Octocode tools directly from an interactive terminal"}),t.push(new x),t.push({name:c("Exit"),value:"exit"}),console.log(),await Ye({message:"What would you like to do?",choices:t,pageSize:12,loop:!1,theme:{prefix:" ",style:{highlight:n=>r("magenta",n),message:n=>g(n)}}})}async function Ag(e){let t=[];if(e.octocode.isInstalled){if(e.octocode.hasMoreToInstall){let n=kg(e.octocode.availableClients);t.push({name:"- Add Octocode",value:"install",description:n})}}else t.push({name:`- ${g("Install")} ${r("red","[X]")}`,value:"install",description:"Setup for Cursor, Claude, Windsurf..."});return e.octocode.isInstalled&&t.push({name:"- Configure Octocode",value:"configure",description:"Server options & preferences"}),t.push(new x),t.push({name:`${r("dim","- Back to main menu")}`,value:"back"}),await Ye({message:"",choices:t,pageSize:12,loop:!1,theme:{prefix:" ",style:{highlight:n=>r("magenta",n)}}})}async function Tg(){await W();let e=await no();console.log(),vg(e.octocode.installedClients);let t=!0,o=!0;for(;t;){if(o)o=!1;else{let s=new A(" Refreshing...").start();e=await no(),s.clear()}switch(await Ag(e)){case"install":await os(),console.log();break;case"configure":await Qi(),console.log();break;default:t=!1;break}}}async function Og(){let e=[];return e.push({name:"- Show MCP details",value:"inspect",description:"View and manage configured MCP servers"}),e.push({name:"- Sync Configurations",value:"sync",description:"Sync MCP configs across all IDEs"}),e.push({name:"- MCP Marketplace",value:"marketplace",description:"Browse and install community MCP servers"}),e.push(new x),e.push({name:`${r("dim","- Back to main menu")}`,value:"back"}),await Ye({message:"",choices:e,pageSize:12,loop:!1,theme:{prefix:" ",style:{highlight:o=>r("magenta",o)}}})}async function Lg(){await W(),console.log();let e=!0;for(;e;)switch(await Og()){case"inspect":await ss();break;case"sync":await us(),console.log();break;case"marketplace":await as(),console.log();break;default:e=!1;break}}async function Dg(e){let t=[],o=e.tokenSource==="env",n=eo(),s=rt(),i=await Ie(),a=!!n,l=!!i,u=pt();if(o&&u){let d=e.envTokenSource?.replace("env:","")||"environment variable";t.push(new x(` ${r("green","\u2705")} Using ${r("cyan",d)} ${c("(takes priority)")}`)),t.push(new x)}if(a){let d=s.username?` (@${s.username})`:"";t.push({name:`- Delete gh CLI token${d}`,value:"gh-logout",description:"Opens gh auth logout"})}if(l){let d=i.username?` (@${i.username})`:"";t.push({name:`- Delete Octocode token${d}`,value:"logout",description:"Remove from file"})}return l||t.push({name:`- Sign In via Octocode ${r("green","(Recommended)")}`,value:"login",description:"Quick browser sign in"}),a||t.push({name:"- Sign In via gh CLI",value:"gh-guidance",description:s.installed?"Use existing GitHub CLI":"GitHub CLI not installed"}),t.push(new x),t.push({name:`${r("dim","- Back")}`,value:"back"}),await Ye({message:"",choices:t,pageSize:12,loop:!1,theme:{prefix:" ",style:{highlight:d=>r("magenta",d)}}})}async function Rg(){console.log(),console.log(r("blue","\u2501".repeat(66))),console.log(` ${g("GitHub Authentication")}`),console.log(r("blue","\u2501".repeat(66))),console.log(),console.log(` ${c("This will open your browser to authenticate with GitHub.")}`),console.log();let e=!1,t=null,o=new A("Connecting to GitHub...").start(),n=await Zo({onVerification:s=>{o.stop(),e=!0,console.log(),console.log(r("yellow"," \u250C"+"\u2500".repeat(50)+"\u2510")),console.log(r("yellow"," \u2502 ")+`${r("yellow","!")} Your one-time code: ${g(r("cyan",s.user_code))}`+" ".repeat(24-s.user_code.length)+r("yellow","\u2502")),console.log(r("yellow"," \u2514"+"\u2500".repeat(50)+"\u2518")),console.log(),console.log(` ${g("1.")} Copy the code above`),console.log(` ${g("2.")} ${g("Press Enter")} to open ${r("cyan",s.verification_uri)}`),console.log(` ${g("3.")} Paste the code in your browser`),console.log(),t=new A(`Waiting for browser authentication... ${c("(typically 10-30 seconds)")}`).start()}});return t&&t.stop(),e||o.stop(),console.log(),n.success?(console.log(r("green"," \u250C"+"\u2500".repeat(50)+"\u2510")),console.log(r("green"," \u2502 ")+`${r("green","\u2705")} ${g("Authentication successful!")}`+" ".repeat(22)+r("green","\u2502")),console.log(r("green"," \u2514"+"\u2500".repeat(50)+"\u2518")),console.log(),console.log(` ${r("green","\u2705")} Logged in as ${r("cyan","@"+(n.username||"unknown"))}`),console.log(` ${c("Credentials stored in:")} ${oo()}`),console.log(),console.log(` ${r("cyan","Tip:")} ${g("What's next?")}`),console.log(` ${c("\u2022")} Install ${r("magenta","Skills")} for AI-powered research & PR reviews`),console.log(` ${c("\u2022")} Use ${r("cyan","/research")} prompt to explore any GitHub repo`),console.log(` ${c("\u2022")} Add ${r("cyan","AGENTS.md")} to your project for better AI context`)):(console.log(r("red"," \u250C"+"\u2500".repeat(50)+"\u2510")),console.log(r("red"," \u2502 ")+`${r("red","X")} ${g("Authentication failed")}`+" ".repeat(27)+r("red","\u2502")),console.log(r("red"," \u2514"+"\u2500".repeat(50)+"\u2518")),console.log(),console.log(` ${r("red","Error:")} ${n.error||"Unknown error"}`),console.log(),console.log(` ${g("Troubleshooting:")}`),console.log(` ${c("\u2022")} Make sure you copied the code correctly`),console.log(` ${c("\u2022")} Check your browser didn't block the popup`),console.log(` ${c("\u2022")} Try running ${r("cyan","octocode login")} again`)),console.log(),await en(),n.success}async function _g(){let e=await to();console.log(),console.log(` ${g("Sign Out")}`),console.log(` ${c("Signed in as:")} ${r("cyan","@"+(e.username||"unknown"))}`),console.log();let t=await $t();if(t.success){console.log(` ${r("green","\u2705")} Signed out successfully`);let o=rt();o.authenticated&&console.log(` ${c("Tip:")} You can still use gh CLI (@${o.username||"unknown"})`)}else console.log(` ${r("red","X")} Sign out failed: ${t.error||"Unknown error"}`);return console.log(),await en(),t.success}async function Ng(){let e="https://cli.github.com/";console.log(),console.log(` ${g("Setup Instructions:")}`),console.log(),console.log(" 1. Install GitHub CLI from:"),console.log(` ${r("cyan",e)}`),console.log(),console.log(" 2. Run the following command to authenticate:"),console.log(` ${r("cyan","gh auth login")}`),console.log(),console.log(` ${c("Once authenticated, octocode will automatically")}`),console.log(` ${c("use your gh CLI token.")}`),console.log();let t=await Ye({message:"",choices:[{name:"- Open GitHub CLI website",value:"open-site"},new x,{name:`${r("dim","- Back")}`,value:"back"}],pageSize:10,loop:!1,theme:{prefix:" ",style:{highlight:o=>r("cyan",o),message:o=>o}}});if(t!=="back"&&t==="open-site"){try{await wt(e),console.log(),console.log(` ${r("green","\u2705")} Opened ${r("cyan",e)} in browser`)}catch{console.log(),console.log(` ${r("yellow","!")} Could not open browser automatically`),console.log(` ${c("Please visit:")} ${r("cyan",e)}`)}console.log(),await en()}}function Fg(e){switch(e.tokenSource){case"gh-cli":return"gh CLI";case"env":return e.envTokenSource?`${e.envTokenSource.replace("env:","")} env var`:"environment variable";case"octocode":return"file";default:return"unknown"}}function Bg(e){if(console.log(` ${g("GitHub Authentication")}`),console.log(),e.authenticated){let t=Fg(e);if(e.tokenSource==="env"){let o=e.envTokenSource?e.envTokenSource.replace("env:",""):"environment variable";console.log(` ${r("green","\u2705")} Using ${r("cyan",o)} ${c("(token configured)")}`)}else console.log(` ${r("green","\u2705")} Signed in as ${r("cyan","@"+(e.username||"unknown"))} ${c(`via ${t}`)}`);e.tokenExpired&&console.log(` ${r("yellow","Warning:")} Session expired - please sign in again`),console.log(),console.log(` ${r("green","\u2705")} ${c("Ready to access GitHub repositories!")}`)}else console.log(r("yellow"," \u250C"+"\u2500".repeat(56)+"\u2510")),console.log(r("yellow"," \u2502 ")+`${r("yellow","Warning:")} ${g("Authentication Required")}`+" ".repeat(31)+r("yellow","\u2502")),console.log(r("yellow"," \u2514"+"\u2500".repeat(56)+"\u2518")),console.log(),console.log(` ${c("Without auth, Octocode cannot:")}`),console.log(` ${r("red","X")} Access private repositories`),console.log(` ${r("red","X")} Search code in your organization`),console.log(` ${r("red","X")} Provide full GitHub research capabilities`),console.log(),console.log(` ${r("cyan","->")} Select ${r("green",'"Sign In via Octocode"')} below to authenticate`);console.log()}async function jg(){await W(),console.log();let e=!0;for(;e;){let t=await to();switch(Bg(t),await Dg(t)){case"login":{let n=await Rg();console.log(),n&&(e=!1);break}case"gh-guidance":await Ng();break;case"logout":await _g(),console.log();break;case"gh-logout":{if(await Ye({message:"Sign out of gh CLI?",choices:[{name:"Yes, sign out",value:"yes"},{name:"No, cancel",value:"no"}],theme:{prefix:" ",style:{highlight:i=>r("red",i)}}})!=="yes")break;console.log(),console.log(` ${c("Opening gh auth logout...")}`),console.log(),wl().success?(console.log(),console.log(` ${r("green","\u2705")} Signed out of gh CLI`)):(console.log(),console.log(` ${r("yellow","!")} Sign out was cancelled`)),console.log(),await en();break}default:e=!1;break}}}async function Ug(e){switch(e){case"octocode":return await Tg(),!0;case"octocode-skills":return await gl(),!0;case"skills":return await hl(),!0;case"auth":return await jg(),!0;case"mcp-config":return await Lg(),!0;case"terminal":return await $l(),!0;case"exit":return Fo(),!1;default:return!0}}function Gg(){console.log(` ${g("Environment")}`)}async function Hg(){Gg();let e=await Vt();Wt(e)&&(console.log(),console.log(` ${c("Tip:")} ${c("Run")} ${r("cyan","npx node-doctor")} ${c("for diagnostics")}`))}async function xl(){let e=!0,t=!0;for(;t;){let o;if(e)o=await no();else{let s=new A(" Loading...").start();o=await no(),s.clear()}e||(ho(),No(),await Hg()),e=!1;let n=await Mg(o);t=await Ug(n)}}function Vg(){console.log(r("blue","\u2501".repeat(66))),console.log(` \u{1F50D} ${g("Environment")}`),console.log(r("blue","\u2501".repeat(66)))}async function El(){let e=new A(" Starting...").start();await W(),e.clear(),ho(),No(),Vg();let t=await Vt();if(Wt(t)&&(console.log(),console.log(` ${c("\u{1F4A1}")} ${c("Run")} ${r("cyan","npx node-doctor")} ${c("for diagnostics")}`)),!t.nodeInstalled){console.log(),console.log(` ${r("red","\u2717")} ${g("Node.js is required to run octocode-mcp")}`),ns(),Fo();return}await xl()}var Wg={claude:"claude-desktop","claude-desktop":"claude-desktop",claudedesktop:"claude-desktop","claude-code":"claude-code",claudecode:"claude-code",cursor:"cursor",windsurf:"windsurf",trae:"trae",antigravity:"antigravity",zed:"zed","vscode-cline":"vscode-cline",cline:"vscode-cline","vscode-roo":"vscode-roo",roo:"vscode-roo","roo-cline":"vscode-roo","vscode-continue":"vscode-continue",continue:"vscode-continue",opencode:"opencode",codex:"codex",gemini:"gemini-cli","gemini-cli":"gemini-cli",geminicli:"gemini-cli",goose:"goose",kiro:"kiro",custom:"custom"};function Il(e){return Wg[e.trim().toLowerCase()]??null}function Fs(e){return e in Dt?Dt[e].name:e in xn?xn[e].name:e.charAt(0).toUpperCase()+e.slice(1)}function Bs(e){return e.length<=8?"****":e.slice(0,4)+"****"+e.slice(-4)}function so(e){return process.stdout.isTTY?Bs(e):e}function at(){console.log(` ${c("To login:")}`),console.log(` ${r("cyan","\u2192")} ${r("yellow","octocode login")}`),console.log(` ${c("or")}`),console.log(` ${r("cyan","\u2192")} ${r("yellow","gh auth login")}`)}function js(){console.log(` ${c("For deeper diagnostics:")} ${r("cyan","npx node-doctor")}`),console.log()}function xt(e,t){switch(e){case"octocode":return r("cyan","octocode");case"gh-cli":return r("magenta","gh cli");case"env":if(t){let o=t.replace("env:","");return r("green",o)}return r("green","environment variable");default:return c("none")}}function Ml(e){switch(e.trim().toLowerCase()){case"claude":case"claude-code":case"claudecode":return"claude-code";case"claude-desktop":case"claudedesktop":return"claude-desktop";case"cursor":return"cursor";case"codex":return"codex";case"opencode":return"opencode";default:return null}}function Al(e){if(!e||e.trim().length===0)return{values:{}};let t=e.split(",").map(s=>s.trim()).filter(Boolean),o={},n=/^[A-Za-z_][A-Za-z0-9_]*$/;for(let s of t){let i=s.indexOf("=");if(i<=0)return{values:{},error:`Invalid --env pair: "${s}" (expected KEY=VALUE)`};let a=s.slice(0,i).trim(),l=s.slice(i+1);if(!n.test(a))return{values:{},error:`Invalid env var name: "${a}"`};o[a]=l}return{values:o}}var Us={name:"install",aliases:["i","setup"],description:"Install octocode-mcp for an IDE",usage:"octocode install --ide <ide> [--method <npx|direct>] [--force]",options:[{name:"ide",description:"IDE to configure: cursor, claude-desktop, claude-code, windsurf, zed, vscode-cline, vscode-roo, vscode-continue, opencode, trae, antigravity, codex, gemini-cli, goose, kiro",hasValue:!0},{name:"method",short:"m",description:"Installation method (npx or direct)",hasValue:!0,default:"npx"},{name:"force",short:"f",description:"Overwrite existing configuration"}],handler:async e=>{let t=e.options.ide,o=e.options.method||"npx",n=!!(e.options.force||e.options.f);if(!t){await El();return}if(o==="npx"){let u=vo(),p=wo();if(!u.installed){console.log(),console.log(` ${r("red","\u2717")} Node.js is ${r("red","not found in PATH")}`),console.log(` ${c("Node.js is required for npx installation method.")}`),console.log(),js(),process.exitCode=1;return}if(!p.installed){console.log(),console.log(` ${r("yellow","\u26A0")} npm is ${r("yellow","not found in PATH")}`),console.log(` ${c("npm is required for npx installation method.")}`),console.log(),js(),process.exitCode=1;return}}let s=["cursor","claude","claude-desktop","claude-code","windsurf","zed","vscode-cline","vscode-roo","vscode-continue","opencode","trae","antigravity","codex","gemini-cli","goose","kiro"];if(!s.includes(t)){console.log(),console.log(` ${r("red","\u2717")} Invalid IDE: ${t}`),console.log(` ${c("Supported:")} ${s.join(", ")}`),console.log(),process.exitCode=1;return}if(!["npx","direct"].includes(o)){console.log(),console.log(` ${r("red","\u2717")} Invalid method: ${o}`),console.log(` ${c("Supported:")} npx, direct`),console.log(),process.exitCode=1;return}let i=qr(t,o);if(i.action==="override"&&!n){console.log(),console.log(` ${r("yellow","\u26A0")} Octocode is already configured.`),console.log(` ${c("Use")} ${r("cyan","--force")} ${c("to overwrite.")}`),console.log(),process.exitCode=1;return}console.log(),console.log(` ${g("Installing octocode-mcp")}`),console.log(` ${c("IDE:")} ${Fs(t)}`),console.log(` ${c("Method:")} ${Yr[o].name}`),console.log(` ${c("Action:")} ${i.action.toUpperCase()}`),console.log();let a=new A("Writing configuration...").start(),l=Wr({ide:t,method:o,force:n});l.success?(a.succeed("Installation complete!"),console.log(),console.log(` ${r("green","\u2713")} Config saved to: ${i.configPath}`),l.backupPath&&console.log(` ${c("Backup:")} ${l.backupPath}`),console.log(),console.log(` ${g("Next:")} Restart ${Fs(t)} to activate.`),console.log()):(a.fail("Installation failed"),console.log(),l.error&&console.log(` ${r("red","\u2717")} ${l.error}`),console.log(),process.exitCode=1)}};async function Tl(e="github.com"){console.log(),console.log(` ${g("\u{1F510} GitHub Authentication")}`),console.log();let t=it(e);t.authenticated?(console.log(` ${r("green","\u2713")} Authenticated as ${r("cyan",t.username||"unknown")}`),t.tokenExpired&&console.log(` ${r("yellow","\u26A0")} Token has expired - please login again`),console.log(` ${c("Host:")} ${t.hostname}`),console.log(` ${c("Source:")} ${xt(t.tokenSource||"none",t.envTokenSource)}`)):(console.log(` ${r("yellow","\u26A0")} ${r("yellow","Not authenticated")}`),console.log(),console.log(` ${g("To authenticate:")}`),at()),console.log(),console.log(` ${c("Credentials stored in:")} ${oo()}`),console.log()}var Et={name:"login",aliases:["l"],description:"Authenticate with GitHub",usage:"octocode login [--hostname <host>] [--git-protocol <ssh|https>]",options:[{name:"hostname",short:"H",description:"GitHub Enterprise hostname (default: github.com)",hasValue:!0},{name:"git-protocol",short:"p",description:"Git protocol to use (ssh or https)",hasValue:!0}],handler:async e=>{let t=e.options.hostname??e.options.H,o=(typeof t=="string"?t:void 0)||"github.com",n=it(o);if(n.authenticated){console.log(),console.log(` ${r("green","\u2713")} Already authenticated as ${r("cyan",n.username||"unknown")}`),console.log(),console.log(` ${c("To switch accounts, logout first:")}`),console.log(` ${r("cyan","\u2192")} ${r("yellow","octocode logout")}`),console.log();return}console.log(),console.log(` ${g("\u{1F510} GitHub Authentication")}`),console.log();let s=e.options["git-protocol"],i=typeof s=="string"?s:"https",a=!1,l=new A("Waiting for GitHub authentication...").start(),u=await Zo({hostname:o,gitProtocol:i,onVerification:p=>{l.stop(),a=!0,console.log(` ${r("yellow","!")} First copy your one-time code: ${g(p.user_code)}`),console.log(),console.log(` ${g("Press Enter")} to open ${r("cyan",p.verification_uri)} in your browser...`),console.log(),console.log(` ${c("Waiting for authentication...")}`)}});a||l.stop(),console.log(),u.success?(console.log(` ${r("green","\u2713")} Authentication complete!`),console.log(` ${r("green","\u2713")} Logged in as ${r("cyan",u.username||"unknown")}`),console.log(),console.log(` ${c("Credentials stored in:")} ${oo()}`)):(console.log(` ${r("red","\u2717")} Authentication failed: ${u.error||"Unknown error"}`),process.exitCode=1),console.log()}},tn={name:"logout",description:"Sign out from GitHub",usage:"octocode logout [--hostname <host>]",options:[{name:"hostname",short:"H",description:"GitHub Enterprise hostname",hasValue:!0}],handler:async e=>{let t=e.options.hostname??e.options.H,o=(typeof t=="string"?t:void 0)||"github.com",n=it(o);if(!n.authenticated){console.log(),console.log(` ${r("yellow","\u26A0")} Not currently authenticated to ${o}`),console.log(),at(),console.log();return}console.log(),console.log(` ${g("\u{1F510} GitHub Logout")}`),console.log(` ${c("Currently authenticated as:")} ${r("cyan",n.username||"unknown")}`),console.log();let s=await $t(o);s.success?console.log(` ${r("green","\u2713")} Successfully logged out from ${o}`):(console.log(` ${r("red","\u2717")} Logout failed: ${s.error||"Unknown error"}`),process.exitCode=1),console.log()}},Gs={name:"auth",aliases:["a","gh"],description:"Manage GitHub authentication",usage:"octocode auth [login|logout|status|token]",handler:async e=>{let t=e.args[0],o=e.options.hostname||"github.com";if(t==="login")return Et.handler(e);if(t==="logout")return tn.handler(e);if(t==="status")return Tl();if(t==="token"){let a=await Rs(o);if(a.token){console.log(so(a.token));return}let l=_s(o);if(l.token){console.log(so(l.token));return}console.log(),console.log(` ${r("yellow","\u26A0")} No GitHub token found.`),console.log(),console.log(` ${c("GitHub authentication is required to access private repositories.")}`),console.log(),console.log(` ${g("To authenticate, choose one of:")}`),console.log(),console.log(` ${r("cyan","octocode auth login")} ${c("Recommended - stores token securely")}`),console.log(` ${r("cyan","gh auth login")} ${c("Use existing GitHub CLI")}`),console.log(),console.log(` ${c("Learn more:")} ${r("blue",kl)}`),console.log(),process.exitCode=1;return}let n=it(o);await Tl(o),await W();let s=n.authenticated?[{name:"\u{1F513} Logout from GitHub",value:"logout"},{name:"\u{1F504} Switch account (logout & login)",value:"switch"},{name:"\u2190 Back",value:"back"}]:[{name:"\u{1F510} Login to GitHub",value:"login"},{name:"\u2190 Back",value:"back"}],i=await E({message:"What would you like to do?",choices:s});i==="login"?await Et.handler({command:"login",args:[],options:{}}):i==="logout"?(await $t(o),console.log(),console.log(` ${r("green","\u2713")} Successfully logged out`),console.log()):i==="switch"&&(console.log(),console.log(` ${c("Logging out...")}`),await $t(),console.log(` ${r("green","\u2713")} Logged out`),console.log(),console.log(` ${c("Starting new login...")}`),await Et.handler({command:"login",args:[],options:{}}))}};var Hs={name:"token",aliases:["t"],description:"Print the GitHub token (matches octocode-mcp priority)",usage:"octocode token [--type <auto|octocode|gh>] [--hostname <host>] [--source] [--json]",options:[{name:"type",short:"t",description:"Token source: auto (default: env\u2192gh\u2192octocode), octocode, gh",hasValue:!0,default:"auto"},{name:"hostname",short:"H",description:"GitHub Enterprise hostname (default: github.com)",hasValue:!0},{name:"source",short:"s",description:"Show token source and user info"},{name:"json",short:"j",description:'Output as JSON: {"token": "...", "type": "..."}'}],handler:async e=>{let t=e.options.hostname??e.options.H,o=(typeof t=="string"?t:void 0)||"github.com",n=!!(e.options.source||e.options.s),s=!!(e.options.json||e.options.j),i=e.options.type??e.options.t,a=(typeof i=="string"?i:void 0)||"auto",l;switch(a.toLowerCase()){case"octocode":case"o":l="octocode";break;case"gh":case"gh-cli":case"g":l="gh";break;case"auto":case"a":l="auto";break;default:if(s){console.log(JSON.stringify({token:null,type:"none"})),process.exitCode=1;return}console.log(),console.log(` ${r("red","\u2717")} Invalid token type: ${a}`),console.log(` ${c("Valid options:")} octocode, gh, auto`),console.log(),process.exitCode=1;return}let u=await Sl(o,l);if(s){let p={token:u.token,type:Pl(u.source,u.envSource)};console.log(JSON.stringify(p)),u.token||(process.exitCode=1);return}if(!u.token){console.log(),l==="octocode"?(console.log(` ${r("yellow","\u26A0")} No Octocode token found for ${o}`),console.log(),console.log(` ${c("To login with Octocode:")}`),console.log(` ${r("cyan","\u2192")} ${r("yellow","octocode login")}`),console.log(),console.log(` ${c("Or use gh CLI token:")}`),console.log(` ${r("cyan","\u2192")} ${r("yellow","octocode token --type=gh")}`)):l==="gh"?(console.log(` ${r("yellow","\u26A0")} No gh CLI token found for ${o}`),console.log(),console.log(` ${c("To login with gh CLI:")}`),console.log(` ${r("cyan","\u2192")} ${r("yellow","gh auth login")}`),console.log(),console.log(` ${c("Or use Octocode token:")}`),console.log(` ${r("cyan","\u2192")} ${r("yellow","octocode token --type=octocode")}`)):(console.log(` ${r("yellow","\u26A0")} Not authenticated to ${o}`),console.log(),at()),console.log(),process.exitCode=1;return}n?(console.log(),console.log(` ${r("green","\u2713")} Token found`),console.log(` ${c("Source:")} ${xt(u.source,u.envSource)}`),u.username&&console.log(` ${c("User:")} ${r("cyan","@"+u.username)}`),console.log(),console.log(` ${c("Token:")} ${Bs(u.token)}`),console.log()):console.log(so(u.token))}};import{existsSync as qg,rmSync as Kg,mkdirSync as Ol,symlinkSync as zg}from"node:fs";import oe from"node:path";function Xg(e,t){if(e==="claude-code")return t;if(V){let o=re();switch(e){case"claude-desktop":return oe.join(o,"Claude Desktop","skills");case"cursor":return oe.join(B,".cursor","skills");case"codex":return oe.join(B,".codex","skills");case"opencode":return oe.join(B,".opencode","skills");default:return t}}switch(e){case"claude-desktop":return oe.join(B,".claude-desktop","skills");case"cursor":return oe.join(B,".cursor","skills");case"codex":return oe.join(B,".codex","skills");case"opencode":return oe.join(B,".opencode","skills");default:return t}}function Ll(e,t,o,n){try{if(qg(t)){if(!n)return"skipped";Kg(t,{recursive:!0,force:!0})}return o==="symlink"?(zg(e,t,V?"junction":"dir"),"installed"):mt(e,t)?"installed":"failed"}catch{return"failed"}}function Yg(e){return e==="claude-code"||e==="claude-desktop"}function Dl(e,t){return e==="hybrid"?Yg(t)?"copy":"symlink":e}async function Jg(){await W();let e=await E({message:"Install skills to which platforms?",choices:[{name:"- Claude locations (claude-code + claude-desktop)",value:"claude-only"},{name:"- All supported platforms",value:"all"},{name:"- Custom selection",value:"custom"},{name:`${c("- Cancel")}`,value:"cancel"}],loop:!1});return e==="cancel"?[]:e==="claude-only"?["claude-code","claude-desktop"]:e==="all"?["claude-code","claude-desktop","cursor","codex","opencode"]:await _o({message:"Select target platforms",choices:[{name:"- claude-code",value:"claude-code",checked:!0},{name:"- claude-desktop",value:"claude-desktop",checked:!0},{name:"- cursor",value:"cursor"},{name:"- codex",value:"codex"},{name:"- opencode",value:"opencode"}],required:!0,loop:!1})}async function Qg(){await W();let e=await E({message:"How should skills be installed?",choices:[{name:"- Hybrid (copy for Claude targets, symlink for others)",value:"hybrid"},{name:"- Full copies everywhere",value:"copy"},{name:"- Symlinks everywhere",value:"symlink"},{name:`${c("- Cancel")}`,value:"cancel"}],loop:!1});return e==="cancel"?null:e}var Vs={name:"skills",aliases:["sk"],description:"Install Octocode skills across AI clients",usage:"octocode skills [install|remove|list] [--skill <name>] [--targets <list>] [--mode <copy|symlink>]",options:[{name:"force",short:"f",description:"Overwrite existing skills"},{name:"skill",short:"k",description:"Skill folder name (used by install/remove)",hasValue:!0},{name:"targets",short:"t",description:"Comma-separated targets: claude-code, claude-desktop, cursor, codex, opencode",hasValue:!0},{name:"mode",short:"m",description:"Install mode: copy (default) or symlink",hasValue:!0,default:"copy"}],handler:async e=>{let t=e.args[0]||"list",o=!!(e.options.force||e.options.f),n=e.options.skill??e.options.k,s=typeof n=="string"&&n.length>0?n:void 0,i=t==="remove"?void 0:e.options.targets??e.options.t,a=t==="remove"?void 0:e.options.mode??e.options.m,l="copy";if(typeof a=="string"&&a.trim().length>0){let h=a.trim().toLowerCase();if(h!=="copy"&&h!=="symlink"){console.log(),console.log(` ${r("red","X")} Invalid --mode value: ${r("yellow",a)}`),console.log(` ${c("Allowed values:")} copy, symlink`),console.log(` ${c("Example:")} octocode skills install --mode symlink`),console.log(),process.exitCode=1;return}l=h}let u=typeof i=="string"&&i.trim().length>0,p=typeof a=="string"&&a.length>0,d=tt(),m=ue(),f=["claude-code"];if(typeof i=="string"&&i.trim().length>0){let h=i.split(",").map(k=>Ml(k)).filter(k=>k!==null);if(f=[...new Set(h)],f.length===0){console.log(),console.log(` ${r("red","X")} No valid targets provided`),console.log(` ${c("Valid targets:")} claude-code, claude-desktop, cursor, codex, opencode`),console.log(),process.exitCode=1;return}}let C=l;if(t==="install"&&process.stdout.isTTY&&(!u||!p)){let h=await Jg();if(h.length===0){console.log(),console.log(` ${r("yellow","WARN")} Skills install cancelled`),console.log();return}f=h;let k=await Qg();if(!k){console.log(),console.log(` ${r("yellow","WARN")} Skills install cancelled`),console.log();return}C=k}let w=f.map(h=>({target:h,destDir:Xg(h,m)}));if(!T(d)){console.log(),console.log(` ${r("red","\u2717")} Skills directory not found`),console.log(` ${c("Expected:")} ${d}`),console.log(),process.exitCode=1;return}let v=ke(d).filter(h=>!h.startsWith("."));if(t==="list"){console.log(),console.log(` ${g("Available Octocode Skills")}`),console.log(),console.log(` ${g("Install destinations:")}`);for(let h of w)console.log(` ${r("cyan","\u2022")} ${h.target}: ${h.destDir}`);if(console.log(),v.length===0)console.log(` ${c("No skills available.")}`);else for(let h of v){let b=w.every($=>T(oe.join($.destDir,h)))?r("green","installed"):c("not installed");console.log(` ${r("cyan","\u2022")} ${h} ${b}`)}console.log(),console.log(` ${c("To install all:")} octocode skills install`),console.log(` ${c("To install one:")} octocode skills install --skill <name> ${c("(or -k <name>)")}`),console.log(` ${c("Multi-install:")} octocode skills install --targets claude-code,cursor,codex --mode symlink`),console.log();return}if(t==="install"){if(s){if(console.log(),console.log(` ${g(`Installing skill: ${s}`)}`),console.log(),!v.includes(s)){console.log(` ${r("red","\u2717")} Skill not found: ${s}`),console.log(),console.log(` ${c("Available skills:")}`);for(let S of v)console.log(` ${r("cyan","\u2022")} ${S}`);console.log(),process.exitCode=1;return}let I=new A(`Installing ${s}...`).start(),R=oe.join(d,s),N=0,F=0,z=0;for(let S of w){T(S.destDir)||Ol(S.destDir,{recursive:!0,mode:448});let M=Ll(R,oe.join(S.destDir,s),Dl(C,S.target),o);M==="installed"?N++:M==="skipped"?F++:z++}if(z===0){I.succeed(`Installed ${s}!`),console.log(),console.log(` ${r("green","\u2705")} Installed to ${N}/${w.length} targets`);for(let S of w)console.log(` ${r("cyan","\u2022")} ${S.target}: ${oe.join(S.destDir,s)}`);F>0&&console.log(` ${r("yellow","WARN")} Skipped ${F} existing target(s) ${c("(use --force to overwrite)")}`)}else I.fail(`Failed to install ${s}`),process.exitCode=1;console.log();return}if(console.log(),console.log(` ${g("Installing Octocode Skills")}`),console.log(),v.length===0){console.log(` ${r("yellow","\u26A0")} No skills to install.`),console.log();return}let h=new A("Installing skills...").start(),k=0,b=0,$=0;for(let I of v){let R=oe.join(d,I);for(let N of w){T(N.destDir)||Ol(N.destDir,{recursive:!0,mode:448});let F=Ll(R,oe.join(N.destDir,I),Dl(C,N.target),o);F==="installed"?k++:F==="skipped"?b++:$++}}$===0?h.succeed("Skills installation complete!"):h.fail("Skills installation completed with errors"),console.log(),k>0&&console.log(` ${r("green","\u2705")} Installed ${k} skill target(s)`),b>0&&(console.log(` ${r("yellow","WARN")} Skipped ${b} existing skill target(s)`),console.log(` ${c("Use")} ${r("cyan","--force")} ${c("to overwrite.")}`)),$>0&&(console.log(` ${r("red","X")} Failed ${$} skill target(s)`),process.exitCode=1),console.log(),console.log(` ${g("Targets:")}`);for(let I of w)console.log(` ${r("cyan","\u2022")} ${I.target}: ${I.destDir}`);console.log(),console.log(` ${g("Skills installation finished.")}`),console.log();return}if(t==="remove"){if(!s){console.log(),console.log(` ${r("red","X")} Missing required option: ${r("cyan","--skill <name>")}`),console.log(),console.log(` ${c("Usage:")} octocode skills remove --skill <name>`),console.log(),process.exitCode=1;return}console.log(),console.log(` ${g(`Removing skill: ${s}`)}`),console.log();let h=0,k=0;for(let b of w){let $=oe.join(b.destDir,s);if(!T($)){k++;continue}ft($)?h++:(console.log(` ${r("red","X")} Failed to remove from ${b.target}: ${$}`),process.exitCode=1)}h>0&&console.log(` ${r("green","\u2705")} Removed from ${h}/${w.length} targets`),k>0&&console.log(` ${r("yellow","WARN")} Not found in ${k} target(s) ${c("(already absent)")}`),console.log();return}console.log(),console.log(` ${r("red","\u2717")} Unknown subcommand: ${t}`),console.log(` ${c("Usage:")} octocode skills [install|remove|list] [--skill <name>]`),console.log(),process.exitCode=1}};var Ws={name:"mcp",description:"Non-interactive MCP marketplace management",usage:"octocode mcp [list|install|remove|status] [--id <mcp-id>] [--client <client>|--config <path>] [--search <text>] [--category <name>] [--env KEY=VALUE[,KEY=VALUE]] [--force]",options:[{name:"id",description:"MCP registry id (required for install/remove)",hasValue:!0},{name:"client",short:"c",description:"Target client: cursor, claude-desktop, claude-code, windsurf, trae, antigravity, zed, vscode-cline, vscode-roo, vscode-continue, opencode, codex, gemini-cli, goose, kiro",hasValue:!0},{name:"config",description:"Custom MCP config path (uses custom client)",hasValue:!0},{name:"search",description:"Filter list by id/name/description/tags",hasValue:!0},{name:"category",description:"Filter list by category",hasValue:!0},{name:"env",description:"Comma-separated env values: KEY=VALUE,KEY2=VALUE2",hasValue:!0},{name:"installed",description:"List only MCPs installed in target config"},{name:"force",short:"f",description:"Overwrite existing MCP entry on install"}],handler:async e=>{let t=(e.args[0]||"list").toLowerCase(),o=e.options.id,n=typeof o=="string"&&o.trim().length>0?o.trim():void 0,s=e.options.client??e.options.c,i=e.options.config,a=e.options.search,l=e.options.category,u=e.options.env,p=!!e.options.installed,d=!!(e.options.force||e.options.f),m="claude-code",f;if(typeof i=="string"&&i.trim().length>0)m="custom",f=i.trim();else if(typeof s=="string"&&s.trim().length>0){let h=Il(s);if(!h){console.log(),console.log(` ${r("red","X")} Invalid --client value: ${r("yellow",s)}`),console.log(` ${c("Allowed values:")} cursor, claude-desktop, claude-code, windsurf, trae, antigravity, zed, vscode-cline, vscode-roo, vscode-continue, opencode, codex, gemini-cli, goose, kiro`),console.log(),process.exitCode=1;return}m=h}let C=U(m,f),w=G(C)||{mcpServers:{}},v=w.mcpServers||{};if(t==="list"){let h=te;if(typeof a=="string"&&a.trim().length>0){let k=a.trim().toLowerCase();h=h.filter(b=>b.id.toLowerCase().includes(k)||b.name.toLowerCase().includes(k)||b.description.toLowerCase().includes(k)||b.tags?.some($=>$.toLowerCase().includes(k)))}if(typeof l=="string"&&l.trim().length>0){let k=l.trim().toLowerCase();h=h.filter(b=>b.category===k)}if(p){let k=new Set(Object.keys(v));h=h.filter(b=>k.has(b.id))}if(console.log(),console.log(` ${g("MCP Marketplace (non-interactive)")}`),console.log(` ${c("Config:")} ${C}`),console.log(` ${c("Results:")} ${h.length}`),console.log(),h.length===0){console.log(` ${c("No MCP entries matched your filters.")}`),console.log();return}for(let k of h){let b=v[k.id]?r("green","installed"):c("not installed");console.log(` ${r("cyan","\u2022")} ${k.id} ${c("("+k.category+")")} ${b}`)}console.log();return}if(t==="status"){let h=Object.keys(v).sort((k,b)=>k.localeCompare(b));console.log(),console.log(` ${g("MCP Config Status")}`),console.log(` ${c("Client:")} ${D[m]?.name||m}`),console.log(` ${c("Config:")} ${C}`),console.log(` ${c("Installed MCPs:")} ${h.length}`),console.log();for(let k of h)console.log(` ${r("cyan","\u2022")} ${k}`);h.length===0&&console.log(` ${c("No MCP servers configured yet.")}`),console.log();return}if(t==="install"){if(!n){console.log(),console.log(` ${r("red","X")} Missing required option: --id <mcp-id>`),console.log(),process.exitCode=1;return}let h=te.find(N=>N.id.toLowerCase()===n.toLowerCase());if(!h){console.log(),console.log(` ${r("red","X")} MCP not found in registry: ${n}`),console.log(),process.exitCode=1;return}let k=Al(typeof u=="string"?u:void 0);if(k.error){console.log(),console.log(` ${r("red","X")} ${k.error}`),console.log(),process.exitCode=1;return}if(v[h.id]&&!d){console.log(),console.log(` ${r("yellow","WARN")} MCP already installed: ${h.id}`),console.log(` ${c("Use --force to overwrite existing configuration.")}`),console.log(),process.exitCode=1;return}let b={command:h.installConfig.command,args:[...h.installConfig.args]},$={...h.installConfig.env||{},...k.values};Object.keys($).length>0&&(b.env=$);let I={...w,mcpServers:{...v,[h.id]:b}},R=ee(C,I);if(!R.success){console.log(),console.log(` ${r("red","X")} Failed to write MCP config`),console.log(` ${c(R.error||"Unknown write error")}`),console.log(),process.exitCode=1;return}console.log(),console.log(` ${r("green","\u2705")} Installed MCP: ${h.id}`),console.log(` ${c("Client:")} ${D[m]?.name||m}`),console.log(` ${c("Config:")} ${C}`),console.log();return}if(t==="remove"){if(!n){console.log(),console.log(` ${r("red","X")} Missing required option: --id <mcp-id>`),console.log(),process.exitCode=1;return}let h=Object.keys(v).find($=>$.toLowerCase()===n.toLowerCase());if(!h){console.log(),console.log(` ${r("yellow","WARN")} MCP not installed: ${n}`),console.log(` ${c("Nothing to remove from target config.")}`),console.log(),process.exitCode=1;return}let k={...v};delete k[h];let b=ee(C,{...w,mcpServers:k});if(!b.success){console.log(),console.log(` ${r("red","X")} Failed to update MCP config`),console.log(` ${c(b.error||"Unknown write error")}`),console.log(),process.exitCode=1;return}console.log(),console.log(` ${r("green","\u2705")} Removed MCP: ${n}`),console.log(` ${c("Client:")} ${D[m]?.name||m}`),console.log(` ${c("Config:")} ${C}`),console.log();return}console.log(),console.log(` ${r("red","X")} Unknown mcp subcommand: ${t}`),console.log(` ${c("Usage:")} octocode mcp [list|install|remove|status]`),console.log(),process.exitCode=1}};import qs from"node:path";import{existsSync as Rl,rmSync as _l}from"node:fs";var Ks={name:"cache",description:"Inspect and clean Octocode cache and logs",usage:"octocode cache [status|clean] [--repos] [--skills] [--logs] [--tools|--local|--lsp|--api] [--all]",options:[{name:"repos",description:"Target cloned repositories cache"},{name:"skills",description:"Target marketplace skills cache"},{name:"logs",description:"Target Octocode logs directory"},{name:"all",short:"a",description:"Target repos + skills + logs (tool flags are advisory)"},{name:"tools",description:"Target tool caches (local + lsp + api). In-memory caches clear on MCP restart."},{name:"local",description:"Target local tool cache. In-memory cache clears on MCP restart."},{name:"lsp",description:"Target LSP tool cache. In-memory cache clears on MCP restart."},{name:"api",description:"Target remote API tool cache. In-memory cache clears on MCP restart."}],handler:async e=>{let t=(e.args[0]||"status").toLowerCase(),o=ne.home||process.env.OCTOCODE_HOME||qs.join(process.env.HOME||"",".octocode"),n=ne.repos||qs.join(o,"repos"),s=ne.logs||qs.join(o,"logs"),i=al(),a=!!e.options.repos,l=!!e.options.skills,u=!!e.options.logs,p=!!e.options.tools,d=!!e.options.local,m=!!e.options.lsp,f=!!e.options.api,C=!!(e.options.all||e.options.a),w=C||a,v=C||l,h=C||u,k=p||d||m||f;if(t==="status"){let b=_e(n),$=_e(i),I=_e(s),R=b+$+I;console.log(),console.log(` ${g("\u{1F9F9} Octocode Cache Status")}`),console.log(),console.log(` ${c("Home:")} ${o}`),console.log(),console.log(` ${r("cyan","\u2022")} repos: ${gt(b)} ${c(`(${n})`)}`),console.log(` ${r("cyan","\u2022")} skills: ${gt($)} ${c(`(${i})`)}`),console.log(` ${r("cyan","\u2022")} logs: ${gt(I)} ${c(`(${s})`)}`),console.log(),console.log(` ${g("Total:")} ${gt(R)}`),console.log(),console.log(` ${c("Clean examples:")}`),console.log(` ${r("yellow","octocode cache clean --repos")}`),console.log(` ${r("yellow","octocode cache clean --tools")}`),console.log(` ${r("yellow","octocode cache clean --all")}`),console.log();return}if(t==="clean"){if(!w&&!v&&!h&&!k){console.log(),console.log(` ${r("red","X")} Missing clean target. Use --repos, --skills, --logs, --tools, or --all`),console.log(` ${c("Example:")} octocode cache clean --all`),console.log(),process.exitCode=1;return}let b=!1,$=0;if(w&&Rl(n)&&($+=_e(n),_l(n,{recursive:!0,force:!0}),b=!0),v){let I=_e(i);il();let R=_e(i);(I>0||R===0)&&($+=Math.max(0,I-R),b=!0)}if(h&&Rl(s)&&($+=_e(s),_l(s,{recursive:!0,force:!0}),b=!0),k){let I=[p?"--tools":"",d?"--local":"",m?"--lsp":"",f?"--api":""].filter(Boolean).join(", ");console.log(` ${r("yellow","\u2139")} ${I}: No disk caches to clean. Tool caches are in-memory and clear on MCP server restart.`)}console.log(),b?(console.log(` ${r("green","\u2713")} Cache cleanup complete`),console.log(` ${c("Freed:")} ${gt($)}`)):k||console.log(` ${r("yellow","\u26A0")} Nothing to clean`),console.log();return}console.log(),console.log(` ${r("red","\u2717")} Unknown cache subcommand: ${t}`),console.log(` ${c("Usage:")} octocode cache [status|clean] [--repos] [--skills] [--logs] [--tools|--local|--lsp|--api] [--all]`),console.log(),process.exitCode=1}};var zs={name:"status",aliases:["s"],description:"Show GitHub authentication status",usage:"octocode status [--hostname <host>]",options:[{name:"hostname",short:"H",description:"GitHub Enterprise hostname (default: github.com)",hasValue:!0}],handler:async e=>{let t=e.options.hostname??e.options.H,n=it((typeof t=="string"?t:void 0)||"github.com");console.log(),n.authenticated?(console.log(` ${r("green","\u2713")} Logged in as ${r("cyan",n.username||"unknown")}`),console.log(` ${c("Host:")} ${n.hostname}`),console.log(` ${c("Source:")} ${xt(n.tokenSource||"none",n.envTokenSource)}`),n.tokenExpired&&console.log(` ${r("yellow","\u26A0")} Token has expired - please login again`)):(console.log(` ${r("yellow","\u26A0")} Not logged in`),console.log(),at()),console.log()}};var Xs={name:"sync",aliases:["sy"],description:"Sync MCP configurations across all IDE clients",usage:"octocode sync [--force] [--dry-run] [--status]",options:[{name:"force",short:"f",description:"Auto-resolve conflicts (use first variant)"},{name:"dry-run",short:"n",description:"Show what would be synced without making changes"},{name:"status",short:"s",description:"Show sync status without syncing"}],handler:async e=>{let t=!!(e.options.force||e.options.f),o=!!(e.options["dry-run"]||e.options.n);if(!!(e.options.status||e.options.s)){console.log(),console.log(` ${g("\u{1F504} MCP Sync Status")}`),console.log();let a=new A("Scanning configurations...").start(),l=Xt(),u=Yt(l);a.stop(),console.log(` ${g("Clients:")} ${u.summary.clientsWithConfig} with MCP configs`),console.log();for(let p of u.clients){let d=se(p.client),m=p.exists?r("green","\u25CF"):r("dim","\u25CB"),f=p.exists?`${p.mcpCount} MCPs`:c("no config");console.log(` ${m} ${d}: ${f}`)}console.log(),console.log(` ${g("MCPs:")}`),console.log(` ${r("cyan","\u2022")} ${u.summary.totalUniqueMCPs} unique MCPs`),u.summary.consistentMCPs>0&&console.log(` ${r("green","\u2713")} ${u.summary.consistentMCPs} fully synced`),u.summary.needsSyncCount>0&&console.log(` ${r("yellow","\u25CB")} ${u.summary.needsSyncCount} can be auto-synced`),u.summary.conflictCount>0&&console.log(` ${r("red","!")} ${u.summary.conflictCount} have conflicts`),console.log(),(u.summary.needsSyncCount>0||u.summary.conflictCount>0)&&(console.log(` ${c("Run")} ${r("cyan","octocode sync")} ${c("to synchronize.")}`),u.summary.conflictCount>0&&console.log(` ${c("Use")} ${r("cyan","--force")} ${c("to auto-resolve conflicts.")}`),console.log());return}console.log(),console.log(` ${g("\u{1F504} MCP Sync")}`),console.log();let s=new A("Analyzing configurations...").start(),i=await ds({force:t,dryRun:o});i.syncPerformed?i.success?(s.succeed(i.message),console.log(),console.log(` ${g("Next:")} Restart your IDEs to apply changes.`)):(s.fail(i.message),process.exitCode=1):(s.stop(),i.success?console.log(` ${r("green","\u2713")} ${i.message}`):(console.log(` ${r("yellow","\u26A0")} ${i.message}`),!t&&i.message.includes("conflict")&&(console.log(),console.log(` ${c("Options:")}`),console.log(` ${r("cyan","\u2022")} Run ${r("cyan","octocode")} for interactive mode`),console.log(` ${r("cyan","\u2022")} Use ${r("cyan","--force")} to auto-resolve`)),process.exitCode=1)),console.log()}};var Zg=[Us,Gs,Et,tn,Vs,Ws,Zs,Ks,Hs,zs,Xs];function em(e){return Zg.find(t=>t.name===e||t.aliases?.includes(e))}export{Gs as authCommand,Ks as cacheCommand,em as findCommand,Us as installCommand,Et as loginCommand,tn as logoutCommand,Ws as mcpCommand,Vs as skillsCommand,zs as statusCommand,Xs as syncCommand,Hs as tokenCommand};
|
|
43
|
-
/*! Bundled license information:
|
|
44
|
-
|
|
45
|
-
@octokit/request-error/dist-src/index.js:
|
|
46
|
-
(* v8 ignore else -- @preserve -- Bug with vitest coverage where it sees an else branch that doesn't exist *)
|
|
47
|
-
|
|
48
|
-
@octokit/request/dist-bundle/index.js:
|
|
49
|
-
(* v8 ignore next -- @preserve *)
|
|
50
|
-
(* v8 ignore else -- @preserve *)
|
|
51
|
-
*/
|