@inkeep/open-knowledge 0.28.0-beta.1 → 0.28.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/cli.mjs +6 -6
- package/dist/constants-DQ9gCjtp.mjs +2 -0
- package/dist/{dist-BSd2Ezzl.mjs → dist-Cj2f9yMz.mjs} +1 -1
- package/dist/{dist-CPsLcVzP.mjs → dist-Dzsbf2ES.mjs} +10 -12
- package/dist/{git-handle-Bhgrj9qX-DBwQr-02.mjs → git-handle-B4hCEi7c-CXOP12Ds.mjs} +2 -2
- package/dist/git-handle-DG8d2xCi-C_CAAChL.mjs +1 -0
- package/dist/index.mjs +1 -1
- package/dist/{init-CqjCm8Nv.mjs → init-CylIL2_d.mjs} +4 -4
- package/dist/init-iEaa5yZe.mjs +1 -0
- package/dist/{loader-C6DwSh1a.mjs → loader-DL7cugZT.mjs} +2 -2
- package/dist/loader-Dnu5tSEp.mjs +1 -0
- package/dist/preview-B5POtWPo.mjs +1 -0
- package/dist/{preview-CPq8NQ67.mjs → preview-Bn8zUTY3.mjs} +2 -2
- package/dist/{repair-launch-json-Bx6AIRnT.mjs → repair-launch-json-BkY5nlM0.mjs} +2 -2
- package/dist/{repair-mcp-configs-C0PHLK4Q.mjs → repair-mcp-configs-Cz6iXpxD.mjs} +2 -2
- package/dist/repair-skills-BwkQh3gJ.mjs +1 -0
- package/dist/{repair-skills-D5IllzJm.mjs → repair-skills-DDLj2RIs.mjs} +2 -2
- package/dist/{src-Cvy2rszo.mjs → src-DL-hUlrv.mjs} +2 -2
- package/dist/{start-aKZT__Ag.mjs → start-OiE8Ork3.mjs} +2 -2
- package/dist/start-uZWiX6-B.mjs +1 -0
- package/dist/{write-project-skill-f17OygUR.mjs → write-project-skill-C7UNscN7.mjs} +2 -2
- package/package.json +1 -1
- package/dist/constants-BnzVSpjR.mjs +0 -2
- package/dist/git-handle-DjEtQkHv-DQXg1XhZ.mjs +0 -1
- package/dist/init-DNwD_Pli.mjs +0 -1
- package/dist/loader-B8SvxN0m.mjs +0 -1
- package/dist/preview-wdPR6Env.mjs +0 -1
- package/dist/repair-skills-J5Ty5dNP.mjs +0 -1
- package/dist/start-Dp2rloGz.mjs +0 -1
|
@@ -6,5 +6,5 @@ import{a as e,s as t,t as n}from"./chunk-C94x7I9S.mjs";import{normalize as r,res
|
|
|
6
6
|
`){return e.split(n).reduce((e,n)=>{let r=t?n.trim():n;return r&&e.push(r),e},[])}function nt(e,t){return A(e,!0).map(e=>t(e))}function rt(e){return(0,Ve.exists)(e,Ve.FOLDER)}function j(e,t){return Array.isArray(e)?e.includes(t)||e.push(t):e.add(t),t}function it(e,t){return Array.isArray(e)&&!e.includes(t)&&e.push(t),e}function at(e,t){if(Array.isArray(e)){let n=e.indexOf(t);n>=0&&e.splice(n,1)}else e.delete(t);return t}function M(e){return Array.isArray(e)?e:[e]}function ot(e){return e.replace(/[\s-]+(.)/g,(e,t)=>t.toUpperCase())}function N(e){return M(e).map(e=>e instanceof String?e:String(e))}function P(e,t=0){if(e==null)return t;let n=parseInt(e,10);return Number.isNaN(n)?t:n}function F(e,t){let n=[];for(let r=0,i=e.length;r<i;r++)n.push(t,e[r]);return n}function I(e){return(Array.isArray(e)?Buffer.concat(e):e).toString(`utf-8`)}function st(e,t){let n={};return t.forEach(t=>{e[t]!==void 0&&(n[t]=e[t])}),n}function ct(e=0){return new Promise(t=>setTimeout(t,e))}function lt(e){if(e!==!1)return e}var L,R,z,ut=S({"src/lib/utils/util.ts"(){vt(),L=`\0`,R=()=>{},z=Object.prototype.toString.call.bind(Object.prototype.toString)}});function B(e,t,n){return t(e)?e:arguments.length>2?n:void 0}function dt(e,t){let n=h(e)?`string`:typeof e;return/number|string|boolean/.test(n)&&(!t||!t.includes(n))}function ft(e){return!!e&&z(e)===`[object Object]`}function pt(e){return typeof e==`function`}var mt,ht,V,gt,_t,vt=S({"src/lib/utils/argument-filters.ts"(){ut(),mt=e=>Array.isArray(e),ht=e=>typeof e==`number`,V=e=>typeof e==`string`||h(e),gt=e=>V(e)||Array.isArray(e)&&e.every(V),_t=e=>e==null||`number|boolean|function`.includes(typeof e)?!1:typeof e.length==`number`}}),yt,bt=S({"src/lib/utils/exit-codes.ts"(){yt=(e=>(e[e.SUCCESS=0]=`SUCCESS`,e[e.ERROR=1]=`ERROR`,e[e.NOT_FOUND=-2]=`NOT_FOUND`,e[e.UNCLEAN=128]=`UNCLEAN`,e))(yt||{})}}),xt,St=S({"src/lib/utils/git-output-streams.ts"(){xt=class e{constructor(e,t){this.stdOut=e,this.stdErr=t}asStrings(){return new e(this.stdOut.toString(`utf8`),this.stdErr.toString(`utf8`))}}}});function Ct(){throw Error(`LineParser:useMatches not implemented`)}var H,U,wt=S({"src/lib/utils/line-parser.ts"(){H=class{constructor(e,t){this.matches=[],this.useMatches=Ct,this.parse=(e,t)=>(this.resetMatches(),this._regExp.every((t,n)=>this.addMatch(t,n,e(n)))?this.useMatches(t,this.prepareMatches())!==!1:!1),this._regExp=Array.isArray(e)?e:[e],t&&(this.useMatches=t)}resetMatches(){this.matches.length=0}prepareMatches(){return this.matches}addMatch(e,t,n){let r=n&&e.exec(n);return r&&this.pushMatch(t,r),!!r}pushMatch(e,t){this.matches.push(...t.slice(1))}},U=class extends H{addMatch(e,t,n){return/^remote:\s/.test(String(n))&&super.addMatch(e,t,n)}pushMatch(e,t){(e>0||t.length>1)&&super.pushMatch(e,t)}}}});function Tt(...e){let t=process.cwd(),n=Object.assign({baseDir:t,...Et},...e.filter(e=>typeof e==`object`&&e));return n.baseDir=n.baseDir||t,n.trimmed=n.trimmed===!0,n}var Et,Dt=S({"src/lib/utils/simple-git-options.ts"(){Et={binary:`git`,maxConcurrentProcesses:5,config:[],trimmed:!1}}});function Ot(e,t=[]){return ft(e)?Object.keys(e).reduce((t,n)=>{let r=e[n];if(h(r))t.push(r);else if(dt(r,[`boolean`]))t.push(n+`=`+r);else if(Array.isArray(r))for(let e of r)dt(e,[`string`,`number`])||t.push(n+`=`+e);else t.push(n);return t},t):t}function W(e,t=0,n=!1){let r=[];for(let n=0,i=t<0?e.length:t;n<i;n++)`string|number`.includes(typeof e[n])&&r.push(String(e[n]));return Ot(At(e),r),n||r.push(...kt(e)),r}function kt(e){return N(B(k(e,typeof k(e)==`function`?1:0),mt,[]))}function At(e){return B(k(e,pt(k(e))?1:0),ft)}function G(e,t=!0){let n=Ze(k(e));return t||Qe(n)?n:void 0}var jt=S({"src/lib/utils/task-options.ts"(){vt(),ut()}});function Mt(e,t){return e(t.stdOut,t.stdErr)}function K(e,t,n,r=!0){return M(n).forEach(n=>{for(let i=A(n,r),a=0,o=i.length;a<o;a++){let n=(e=0)=>{if(!(a+e>=o))return i[a+e]};t.some(({parse:t})=>t(n,e))}}),e}var Nt=S({"src/lib/utils/task-parser.ts"(){ut()}}),Pt={};C(Pt,{ExitCodes:()=>yt,GitOutputStreams:()=>xt,LineParser:()=>H,NOOP:()=>R,NULL:()=>L,RemoteLineParser:()=>U,append:()=>j,appendTaskOptions:()=>Ot,asArray:()=>M,asCamelCase:()=>ot,asFunction:()=>Ze,asNumber:()=>P,asStringArray:()=>N,bufferToString:()=>I,callTaskParser:()=>Mt,createInstanceConfig:()=>Tt,delay:()=>ct,filterArray:()=>mt,filterFunction:()=>pt,filterHasLength:()=>_t,filterNumber:()=>ht,filterPlainObject:()=>ft,filterPrimitives:()=>dt,filterString:()=>V,filterStringOrStringArray:()=>gt,filterType:()=>B,first:()=>et,folderExists:()=>rt,forEachLineWithContent:()=>nt,getTrailingOptions:()=>W,including:()=>it,isUserFunction:()=>Qe,last:()=>k,objectToString:()=>z,orVoid:()=>lt,parseStringResponse:()=>K,pick:()=>st,prefixedArray:()=>F,remove:()=>at,splitOn:()=>$e,toLinesWithContent:()=>A,trailingFunctionArgument:()=>G,trailingOptionsArgument:()=>At});var q=S({"src/lib/utils/index.ts"(){vt(),bt(),St(),wt(),Dt(),jt(),Nt(),ut()}}),Ft={};C(Ft,{CheckRepoActions:()=>Bt,checkIsBareRepoTask:()=>Rt,checkIsRepoRootTask:()=>Lt,checkIsRepoTask:()=>It});function It(e){switch(e){case`bare`:return Rt();case`root`:return Lt()}return{commands:[`rev-parse`,`--is-inside-work-tree`],format:`utf-8`,onError:Vt,parser:Ht}}function Lt(){return{commands:[`rev-parse`,`--git-dir`],format:`utf-8`,onError:Vt,parser(e){return/^\.(git)?$/.test(e.trim())}}}function Rt(){return{commands:[`rev-parse`,`--is-bare-repository`],format:`utf-8`,onError:Vt,parser:Ht}}function zt(e){return/(Not a git repository|Kein Git-Repository)/i.test(String(e))}var Bt,Vt,Ht,Ut=S({"src/lib/tasks/check-is-repo.ts"(){q(),Bt=(e=>(e.BARE=`bare`,e.IN_TREE=`tree`,e.IS_REPO_ROOT=`root`,e))(Bt||{}),Vt=({exitCode:e},t,n,r)=>{if(e===128&&zt(t))return n(Buffer.from(`false`));r(t)},Ht=e=>e.trim()===`true`}});function Wt(e,t){let n=new Gt(e),r=e?qt:Kt;return A(t).forEach(e=>{let t=e.replace(r,``);n.paths.push(t),(Jt.test(t)?n.folders:n.files).push(t)}),n}var Gt,Kt,qt,Jt,Yt=S({"src/lib/responses/CleanSummary.ts"(){q(),Gt=class{constructor(e){this.dryRun=e,this.paths=[],this.files=[],this.folders=[]}},Kt=/^[a-z]+\s*/i,qt=/^[a-z]+\s+[a-z]+\s*/i,Jt=/\/$/}}),Xt={};C(Xt,{EMPTY_COMMANDS:()=>tn,adhocExecTask:()=>Zt,configurationErrorTask:()=>J,isBufferTask:()=>$t,isEmptyTask:()=>en,straightThroughBufferTask:()=>Qt,straightThroughStringTask:()=>Y});function Zt(e){return{commands:tn,format:`empty`,parser:e}}function J(e){return{commands:tn,format:`empty`,parser(){throw typeof e==`string`?new Ye(e):e}}}function Y(e,t=!1){return{commands:e,format:`utf-8`,parser(e){return t?String(e).trim():e}}}function Qt(e){return{commands:e,format:`buffer`,parser(e){return e}}}function $t(e){return e.format===`buffer`}function en(e){return e.format===`empty`||!e.commands.length}var tn,X=S({"src/lib/tasks/task.ts"(){Xe(),tn=[]}}),nn={};C(nn,{CONFIG_ERROR_INTERACTIVE_MODE:()=>dn,CONFIG_ERROR_MODE_REQUIRED:()=>fn,CONFIG_ERROR_UNKNOWN_OPTION:()=>pn,CleanOptions:()=>mn,cleanTask:()=>an,cleanWithOptionsTask:()=>rn,isCleanOptionsArray:()=>on});function rn(e,t){let{cleanMode:n,options:r,valid:i}=sn(e);return n?i.options?(r.push(...t),r.some(un)?J(dn):an(n,r)):J(pn+JSON.stringify(e)):J(fn)}function an(e,t){return{commands:[`clean`,`-${e}`,...t],format:`utf-8`,parser(t){return Wt(e===`n`,t)}}}function on(e){return Array.isArray(e)&&e.every(e=>hn.has(e))}function sn(e){let t,n=[],r={cleanMode:!1,options:!0};return e.replace(/[^a-z]i/g,``).split(``).forEach(e=>{cn(e)?(t=e,r.cleanMode=!0):r.options=r.options&&ln(n[n.length]=`-${e}`)}),{cleanMode:t,options:n,valid:r}}function cn(e){return e===`f`||e===`n`}function ln(e){return/^-[a-z]$/i.test(e)&&hn.has(e.charAt(1))}function un(e){return/^-[^\-]/.test(e)?e.indexOf(`i`)>0:e===`--interactive`}var dn,fn,pn,mn,hn,gn=S({"src/lib/tasks/clean.ts"(){Yt(),q(),X(),dn=`Git clean interactive mode is not supported`,fn=`Git clean mode parameter ("n" or "f") is required`,pn=`Git clean unknown option found in: `,mn=(e=>(e.DRY_RUN=`n`,e.FORCE=`f`,e.IGNORED_INCLUDED=`x`,e.IGNORED_ONLY=`X`,e.EXCLUDING=`e`,e.QUIET=`q`,e.RECURSIVE=`d`,e))(mn||{}),hn=new Set([`i`,...N(Object.values(mn))])}});function _n(e){let t=new xn;for(let n of bn(e))t.addValue(n.file,String(n.key),n.value);return t}function vn(e,t){let n=null,r=[],i=new Map;for(let a of bn(e,t))a.key===t&&(r.push(n=a.value),i.has(a.file)||i.set(a.file,[]),i.get(a.file).push(n));return{key:t,paths:Array.from(i.keys()),scopes:i,value:n,values:r}}function yn(e){return e.replace(/^(file):/,``)}function*bn(e,t=null){let n=e.split(`\0`);for(let e=0,r=n.length-1;e<r;){let r=yn(n[e++]),i=n[e++],a=t;if(i.includes(`
|
|
7
7
|
`)){let e=$e(i,`
|
|
8
8
|
`);a=e[0],i=e[1]}yield{file:r,key:a,value:i}}}var xn,Sn=S({"src/lib/responses/ConfigList.ts"(){q(),xn=class{constructor(){this.files=[],this.values=Object.create(null)}get all(){return this._all||=this.files.reduce((e,t)=>Object.assign(e,this.values[t]),{}),this._all}addFile(e){if(!(e in this.values)){let t=k(this.files);this.values[e]=t?Object.create(this.values[t]):{},this.files.push(e)}return this.values[e]}addValue(e,t,n){let r=this.addFile(e);Object.hasOwn(r,t)?Array.isArray(r[t])?r[t].push(n):r[t]=[r[t],n]:r[t]=n,this._all=void 0}}}});function Cn(e,t){return typeof e==`string`&&Object.hasOwn(On,e)?e:t}function wn(e,t,n,r){let i=[`config`,`--${r}`];return n&&i.push(`--add`),i.push(e,t),{commands:i,format:`utf-8`,parser(e){return e}}}function Tn(e,t){let n=[`config`,`--null`,`--show-origin`,`--get-all`,e];return t&&n.splice(1,0,`--${t}`),{commands:n,format:`utf-8`,parser(t){return vn(t,e)}}}function En(e){let t=[`config`,`--list`,`--show-origin`,`--null`];return e&&t.push(`--${e}`),{commands:t,format:`utf-8`,parser(e){return _n(e)}}}function Dn(){return{addConfig(e,t,...n){return this._runTask(wn(e,t,n[0]===!0,Cn(n[1],`local`)),G(arguments))},getConfig(e,t){return this._runTask(Tn(e,Cn(t,void 0)),G(arguments))},listConfig(...e){return this._runTask(En(Cn(e[0],void 0)),G(arguments))}}}var On,kn=S({"src/lib/tasks/config.ts"(){Sn(),q(),On=(e=>(e.system=`system`,e.global=`global`,e.local=`local`,e.worktree=`worktree`,e))(On||{})}});function An(e){return Mn.has(e)}var jn,Mn,Nn=S({"src/lib/tasks/diff-name-status.ts"(){jn=(e=>(e.ADDED=`A`,e.COPIED=`C`,e.DELETED=`D`,e.MODIFIED=`M`,e.RENAMED=`R`,e.CHANGED=`T`,e.UNMERGED=`U`,e.UNKNOWN=`X`,e.BROKEN=`B`,e))(jn||{}),Mn=new Set(Object.values(jn))}});function Pn(...e){return new Bn().param(...e)}function Fn(e){let t=new Set,n={};return nt(e,e=>{let[r,i,a]=e.split(L);t.add(r),(n[r]=n[r]||[]).push({line:P(i),path:r,preview:a})}),{paths:t,results:n}}function In(){return{grep(e){let t=G(arguments),n=W(arguments);for(let e of Ln)if(n.includes(e))return this._runTask(J(`git.grep: use of "${e}" is not supported.`),t);typeof e==`string`&&(e=Pn().param(e));let r=[`grep`,`--null`,`-n`,`--full-name`,...n,...e];return this._runTask({commands:r,format:`utf-8`,parser(e){return Fn(e)}},t)}}}var Ln,Rn,zn,Bn,Vn=S({"src/lib/tasks/grep.ts"(){q(),X(),Ln=[`-h`],Rn=Symbol(`grepQuery`),Bn=class{constructor(){this[zn]=[]}*[(zn=Rn,Symbol.iterator)](){for(let e of this[Rn])yield e}and(...e){return e.length&&this[Rn].push(`--and`,`(`,...F(e,`-e`),`)`),this}param(...e){return this[Rn].push(...F(e,`-e`)),this}}}}),Hn={};C(Hn,{ResetMode:()=>Kn,getResetMode:()=>Wn,resetTask:()=>Un});function Un(e,t){let n=[`reset`];return Gn(e)&&n.push(`--${e}`),n.push(...t),Y(n)}function Wn(e){if(Gn(e))return e;switch(typeof e){case`string`:case`undefined`:return`soft`}}function Gn(e){return typeof e==`string`&&qn.includes(e)}var Kn,qn,Jn=S({"src/lib/tasks/reset.ts"(){q(),X(),Kn=(e=>(e.MIXED=`mixed`,e.SOFT=`soft`,e.HARD=`hard`,e.MERGE=`merge`,e.KEEP=`keep`,e))(Kn||{}),qn=N(Object.values(Kn))}});function Yn(){return(0,He.default)(`simple-git`)}function Xn(e,t,n){return!t||!String(t).replace(/\s*/,``)?n?(t,...r)=>{e(t,...r),n(t,...r)}:e:(r,...i)=>{e(`%s ${r}`,t,...i),n&&n(r,...i)}}function Zn(e,t,{namespace:n}){if(typeof e==`string`)return e;let r=t&&t.namespace||``;return r.startsWith(n)?r.substr(n.length+1):r||n}function Qn(e,t,n,r=Yn()){let i=e&&`[${e}]`||``,a=[],o=typeof t==`string`?r.extend(t):t,s=Zn(B(t,V),o,r);return l(n);function c(t,n){return j(a,Qn(e,s.replace(/^[^:]+/,t),n,r))}function l(t){let n=t&&`[${t}]`||``,a=o&&Xn(o,n)||R,s=Xn(r,`${i} ${n}`,a);return Object.assign(o?a:s,{label:e,sibling:c,info:s,step:l})}}var $n=S({"src/lib/git-logger.ts"(){q(),He.default.formatters.L=e=>String(_t(e)?e.length:`-`),He.default.formatters.B=e=>Buffer.isBuffer(e)?e.toString(`utf8`):z(e)}}),er,tr=S({"src/lib/runners/tasks-pending-queue.ts"(){E(),$n(),er=class e{constructor(e=`GitExecutor`){this.logLabel=e,this._queue=new Map}withProgress(e){return this._queue.get(e)}createProgress(t){let n=e.getName(t.commands[0]);return{task:t,logger:Qn(this.logLabel,n),name:n}}push(e){let t=this.createProgress(e);return t.logger(`Adding task to the queue, commands = %o`,e.commands),this._queue.set(e,t),t}fatal(e){for(let[t,{logger:n}]of Array.from(this._queue.entries()))t===e.task?(n.info(`Failed %o`,e),n(`Fatal exception, any as-yet un-started tasks run through this executor will not be attempted`)):n.info(`A fatal exception occurred in a previous task, the queue has been purged: %o`,e.message),this.complete(t);if(this._queue.size!==0)throw Error(`Queue size should be zero after fatal: ${this._queue.size}`)}complete(e){this.withProgress(e)&&this._queue.delete(e)}attempt(e){let t=this.withProgress(e);if(!t)throw new T(void 0,`TasksPendingQueue: attempt called for an unknown task`);return t.logger(`Starting task`),t}static getName(t=`empty`){return`task:${t}:${++e.counter}`}static{this.counter=0}}}});function Z(e,t){return{method:et(e.commands)||``,commands:t}}function nr(e,t){return n=>{t(`[ERROR] child process exception %o`,n),e.push(Buffer.from(String(n.stack),`ascii`))}}function rr(e,t,n,r){return i=>{n(`%s received %L bytes`,t,i),r(`%B`,i),e.push(i)}}var ir,ar=S({"src/lib/runners/git-executor-chain.ts"(){E(),X(),q(),tr(),ir=class{constructor(e,t,n){this._executor=e,this._scheduler=t,this._plugins=n,this._chain=Promise.resolve(),this._queue=new er}get cwd(){return this._cwd||this._executor.cwd}set cwd(e){this._cwd=e}get env(){return this._executor.env}get outputHandler(){return this._executor.outputHandler}chain(){return this}push(e){return this._queue.push(e),this._chain=this._chain.then(()=>this.attemptTask(e))}async attemptTask(e){let t=await this._scheduler.next(),n=()=>this._queue.complete(e);try{let{logger:t}=this._queue.attempt(e);return await(en(e)?this.attemptEmptyTask(e,t):this.attemptRemoteTask(e,t))}catch(t){throw this.onFatalException(e,t)}finally{n(),t()}}onFatalException(e,t){let n=t instanceof T?Object.assign(t,{task:e}):new T(e,t&&String(t));return this._chain=Promise.resolve(),this._queue.fatal(n),n}async attemptRemoteTask(e,t){let n=this._plugins.exec(`spawn.binary`,``,Z(e,e.commands)),r=this._plugins.exec(`spawn.args`,[...e.commands],{...Z(e,e.commands),env:{...this.env}}),i=await this.gitResponse(e,n,r,this.outputHandler,t.step(`SPAWN`)),a=await this.handleTaskData(e,r,i,t.step(`HANDLE`));return t(`passing response to task's parser as a %s`,e.format),$t(e)?Mt(e.parser,a):Mt(e.parser,a.asStrings())}async attemptEmptyTask(e,t){return t(`empty task bypassing child process to call to task's parser`),e.parser(this)}handleTaskData(e,t,n,r){let{exitCode:i,rejection:a,stdOut:o,stdErr:s}=n;return new Promise((c,l)=>{r(`Preparing to handle process response exitCode=%d stdOut=`,i);let{error:u}=this._plugins.exec(`task.error`,{error:a},{...Z(e,t),...n});if(u&&e.onError)return r.info(`exitCode=%s handling with custom error handler`),e.onError(n,u,e=>{r.info(`custom error handler treated as success`),r(`custom error returned a %s`,z(e)),c(new xt(Array.isArray(e)?Buffer.concat(e):e,Buffer.concat(s)))},l);if(u)return r.info(`handling as error: exitCode=%s stdErr=%s rejection=%o`,i,s.length,a),l(u);r.info(`retrieving task output complete`),c(new xt(Buffer.concat(o),Buffer.concat(s)))})}async gitResponse(e,t,n,r,i){let o=i.sibling(`output`),s=this._plugins.exec(`spawn.options`,{cwd:this.cwd,env:this.env,windowsHide:!0},Z(e,e.commands));return new Promise(c=>{let l=[],u=[];i.info(`%s %o`,t,n),i(`%O`,s);let d=this._beforeSpawn(e,n);if(d)return c({stdOut:l,stdErr:u,exitCode:9901,rejection:d});this._plugins.exec(`spawn.before`,void 0,{...Z(e,n),kill(e){d=e||d}});let f=a(t,n,s);f.stdout.on(`data`,rr(l,`stdOut`,i,o.step(`stdOut`))),f.stderr.on(`data`,rr(u,`stdErr`,i,o.step(`stdErr`))),f.on(`error`,nr(u,i)),r&&(i(`Passing child process stdOut/stdErr to custom outputHandler`),r(t,f.stdout,f.stderr,[...n])),this._plugins.exec(`spawn.after`,void 0,{...Z(e,n),spawned:f,close(e,t){c({stdOut:l,stdErr:u,exitCode:e,rejection:d||t})},kill(e){f.killed||(d=e,f.kill(`SIGINT`))}})})}_beforeSpawn(e,t){let n;return this._plugins.exec(`spawn.before`,void 0,{...Z(e,t),kill(e){n=e||n}}),n}}}}),or={};C(or,{GitExecutor:()=>sr});var sr,cr=S({"src/lib/runners/git-executor.ts"(){ar(),sr=class{constructor(e,t,n){this.cwd=e,this._scheduler=t,this._plugins=n,this._chain=new ir(this,this._scheduler,this._plugins)}chain(){return new ir(this,this._scheduler,this._plugins)}push(e){return this._chain.push(e)}}}});function lr(e,t,n=R){t.then(e=>{n(null,e)},t=>{t?.task===e&&n(t instanceof D?ur(t):t,void 0)})}function ur(e){let t=e=>{console.warn(`simple-git deprecation notice: accessing GitResponseError.${e} should be GitResponseError.git.${e}, this will no longer be available in version 3`),t=R};return Object.create(e,Object.getOwnPropertyNames(e.git).reduce(n,{}));function n(n,r){return r in e||(n[r]={enumerable:!1,configurable:!1,get(){return t(r),e.git[r]}}),n}}var dr=S({"src/lib/task-callback.ts"(){O(),q()}});function fr(e,t){return Zt(n=>{if(!rt(e))throw Error(`Git.cwd: cannot change to non-directory "${e}"`);return(t||n).cwd=e})}var pr=S({"src/lib/tasks/change-working-directory.ts"(){q(),X()}});function mr(e){let t=[`checkout`,...e];return t[1]===`-b`&&t.includes(`-B`)&&(t[1]=at(t,`-B`)),Y(t)}function hr(){return{checkout(){return this._runTask(mr(W(arguments,1)),G(arguments))},checkoutBranch(e,t){return this._runTask(mr([`-b`,e,t,...W(arguments)]),G(arguments))},checkoutLocalBranch(e){return this._runTask(mr([`-b`,e,...W(arguments)]),G(arguments))}}}var gr=S({"src/lib/tasks/checkout.ts"(){q(),X()}});function _r(){return{count:0,garbage:0,inPack:0,packs:0,prunePackable:0,size:0,sizeGarbage:0,sizePack:0}}function vr(){return{countObjects(){return this._runTask({commands:[`count-objects`,`--verbose`],format:`utf-8`,parser(e){return K(_r(),[yr],e)}})}}}var yr,br=S({"src/lib/tasks/count-objects.ts"(){q(),yr=new H(/([a-z-]+): (\d+)$/,(e,[t,n])=>{let r=ot(t);Object.hasOwn(e,r)&&(e[r]=P(n))})}});function xr(e){return K({author:null,branch:``,commit:``,root:!1,summary:{changes:0,insertions:0,deletions:0}},Sr,e)}var Sr,Cr=S({"src/lib/parsers/parse-commit.ts"(){q(),Sr=[new H(/^\[([^\s]+)( \([^)]+\))? ([^\]]+)/,(e,[t,n,r])=>{e.branch=t,e.commit=r,e.root=!!n}),new H(/\s*Author:\s(.+)/i,(e,[t])=>{let n=t.split(`<`),r=n.pop();!r||!r.includes(`@`)||(e.author={email:r.substr(0,r.length-1),name:n.join(`<`).trim()})}),new H(/(\d+)[^,]*(?:,\s*(\d+)[^,]*)(?:,\s*(\d+))/g,(e,[t,n,r])=>{e.summary.changes=parseInt(t,10)||0,e.summary.insertions=parseInt(n,10)||0,e.summary.deletions=parseInt(r,10)||0}),new H(/^(\d+)[^,]*(?:,\s*(\d+)[^(]+\(([+-]))?/,(e,[t,n,r])=>{e.summary.changes=parseInt(t,10)||0;let i=parseInt(n,10)||0;r===`-`?e.summary.deletions=i:r===`+`&&(e.summary.insertions=i)})]}});function wr(e,t,n){return{commands:[`-c`,`core.abbrev=40`,`commit`,...F(e,`-m`),...t,...n],format:`utf-8`,parser:xr}}function Tr(){return{commit(t,...n){let r=G(arguments),i=e(t)||wr(M(t),M(B(n[0],gt,[])),[...N(B(n[1],mt,[])),...W(arguments,0,!0)]);return this._runTask(i,r)}};function e(e){return!gt(e)&&J(`git.commit: requires the commit message to be supplied as a string/string[]`)}}var Er=S({"src/lib/tasks/commit.ts"(){Cr(),q(),X()}});function Dr(){return{firstCommit(){return this._runTask(Y([`rev-list`,`--max-parents=0`,`HEAD`],!0),G(arguments))}}}var Or=S({"src/lib/tasks/first-commit.ts"(){q(),X()}});function kr(e,t){let n=[`hash-object`,e];return t&&n.push(`-w`),Y(n,!0)}var Ar=S({"src/lib/tasks/hash-object.ts"(){X()}});function jr(e,t,n){let r=String(n).trim(),i;if(i=Nr.exec(r))return new Mr(e,t,!1,i[1]);if(i=Pr.exec(r))return new Mr(e,t,!0,i[1]);let a=``,o=r.split(` `);for(;o.length;)if(o.shift()===`in`){a=o.join(` `);break}return new Mr(e,t,/^re/i.test(r),a)}var Mr,Nr,Pr,Fr=S({"src/lib/responses/InitSummary.ts"(){Mr=class{constructor(e,t,n,r){this.bare=e,this.path=t,this.existing=n,this.gitDir=r}},Nr=/^Init.+ repository in (.+)$/,Pr=/^Rein.+ in (.+)$/}});function Ir(e){return e.includes(Rr)}function Lr(e=!1,t,n){let r=[`init`,...n];return e&&!Ir(r)&&r.splice(1,0,Rr),{commands:r,format:`utf-8`,parser(e){return jr(r.includes(`--bare`),t,e)}}}var Rr,zr=S({"src/lib/tasks/init.ts"(){Fr(),Rr=`--bare`}});function Br(e){for(let t=0;t<e.length;t++){let n=Hr.exec(e[t]);if(n)return`--${n[1]}`}return``}function Vr(e){return Hr.test(e)}var Hr,Ur=S({"src/lib/args/log-format.ts"(){Hr=/^--(stat|numstat|name-only|name-status)(=|$)/}}),Wr,Gr=S({"src/lib/responses/DiffSummary.ts"(){Wr=class{constructor(){this.changed=0,this.deletions=0,this.insertions=0,this.files=[]}}}});function Kr(e=``){let t=Zr[e];return e=>K(new Wr,t,e,!1)}var qr,Jr,Yr,Xr,Zr,Qr=S({"src/lib/parsers/parse-diff-summary.ts"(){Ur(),Gr(),Nn(),q(),qr=[new H(/^(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/,(e,[t,n,r=``])=>{e.files.push({file:t.trim(),changes:P(n),insertions:r.replace(/[^+]/g,``).length,deletions:r.replace(/[^-]/g,``).length,binary:!1})}),new H(/^(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)/,(e,[t,n,r])=>{e.files.push({file:t.trim(),before:P(n),after:P(r),binary:!0})}),new H(/(\d+) files? changed\s*((?:, \d+ [^,]+){0,2})/,(e,[t,n])=>{let r=/(\d+) i/.exec(n),i=/(\d+) d/.exec(n);e.changed=P(t),e.insertions=P(r?.[1]),e.deletions=P(i?.[1])})],Jr=[new H(/(\d+)\t(\d+)\t(.+)$/,(e,[t,n,r])=>{let i=P(t),a=P(n);e.changed++,e.insertions+=i,e.deletions+=a,e.files.push({file:r,changes:i+a,insertions:i,deletions:a,binary:!1})}),new H(/-\t-\t(.+)$/,(e,[t])=>{e.changed++,e.files.push({file:t,after:0,before:0,binary:!0})})],Yr=[new H(/(.+)$/,(e,[t])=>{e.changed++,e.files.push({file:t,changes:0,insertions:0,deletions:0,binary:!1})})],Xr=[new H(/([ACDMRTUXB])([0-9]{0,3})\t(.[^\t]*)(\t(.[^\t]*))?$/,(e,[t,n,r,i,a])=>{e.changed++,e.files.push({file:a??r,changes:0,insertions:0,deletions:0,binary:!1,status:lt(An(t)&&t),from:lt(!!a&&r!==a&&r),similarity:P(n)})})],Zr={"":qr,"--stat":qr,"--numstat":Jr,"--name-status":Xr,"--name-only":Yr}}});function $r(e,t){return t.reduce((t,n,r)=>(t[n]=e[r]||``,t),Object.create({diff:null}))}function ei(e=ri,t=ii,n=``){let r=Kr(n);return function(n){let i=A(n.trim(),!1,ti).map(function(n){let i=n.split(ni),a=$r(i[0].split(e),t);return i.length>1&&i[1].trim()&&(a.diff=r(i[1])),a});return{all:i,latest:i.length&&i[0]||null,total:i.length}}}var ti,ni,ri,ii,ai=S({"src/lib/parsers/parse-list-log-summary.ts"(){q(),Qr(),Ur(),ti=`òòòòòò `,ni=` òò`,ri=` ò `,ii=[`hash`,`date`,`message`,`refs`,`author_name`,`author_email`]}}),oi={};C(oi,{diffSummaryTask:()=>si,validateLogFormatConfig:()=>ci});function si(e){let t=Br(e),n=[`diff`];return t===``&&(t=`--stat`,n.push(`--stat=4096`)),n.push(...e),ci(n)||{commands:n,format:`utf-8`,parser:Kr(t)}}function ci(e){let t=e.filter(Vr);if(t.length>1)return J(`Summary flags are mutually exclusive - pick one of ${t.join(`,`)}`);if(t.length&&e.includes(`-z`))return J(`Summary flag ${t} parsing is not compatible with null termination option '-z'`)}var li=S({"src/lib/tasks/diff.ts"(){Ur(),Qr(),X()}});function ui(e,t){let n=[],r=[];return Object.keys(e).forEach(t=>{n.push(t),r.push(String(e[t]))}),[n,r.join(t)]}function di(e){return Object.keys(e).reduce((t,n)=>(n in hi||(t[n]=e[n]),t),{})}function fi(e={},t=[]){let n=B(e.splitter,V,ri),[r,i]=ui(ft(e.format)?e.format:{hash:`%H`,date:e.strictDate===!1?`%ai`:`%aI`,message:`%s`,refs:`%D`,body:e.multiLine?`%B`:`%b`,author_name:e.mailMap===!1?`%an`:`%aN`,author_email:e.mailMap===!1?`%ae`:`%aE`},n),a=[],o=[`--pretty=format:${ti}${i}${ni}`,...t],s=e.n||e[`max-count`]||e.maxCount;if(s&&o.push(`--max-count=${s}`),e.from||e.to){let t=e.symmetric===!1?`..`:`...`;a.push(`${e.from||``}${t}${e.to||``}`)}return V(e.file)&&o.push(`--follow`,ne(e.file)),Ot(di(e),o),{fields:r,splitter:n,commands:[...o,...a]}}function pi(e,t,n){let r=ei(e,t,Br(n));return{commands:[`log`,...n],format:`utf-8`,parser:r}}function mi(){return{log(...n){let r=G(arguments),i=fi(At(arguments),N(B(arguments[0],mt,[]))),a=t(...n)||ci(i.commands)||e(i);return this._runTask(a,r)}};function e(e){return pi(e.splitter,e.fields,e.commands)}function t(e,t){return V(e)&&V(t)&&J(`git.log(string, string) should be replaced with git.log({ from: string, to: string })`)}}var hi,gi=S({"src/lib/tasks/log.ts"(){Ur(),ai(),q(),X(),li(),hi=(e=>(e[e[`--pretty`]=0]=`--pretty`,e[e[`max-count`]=1]=`max-count`,e[e.maxCount=2]=`maxCount`,e[e.n=3]=`n`,e[e.file=4]=`file`,e[e.format=5]=`format`,e[e.from=6]=`from`,e[e.to=7]=`to`,e[e.splitter=8]=`splitter`,e[e.symmetric=9]=`symmetric`,e[e.mailMap=10]=`mailMap`,e[e.multiLine=11]=`multiLine`,e[e.strictDate=12]=`strictDate`,e))(hi||{})}}),_i,vi,yi=S({"src/lib/responses/MergeSummary.ts"(){_i=class{constructor(e,t=null,n){this.reason=e,this.file=t,this.meta=n}toString(){return`${this.file}:${this.reason}`}},vi=class{constructor(){this.conflicts=[],this.merges=[],this.result=`success`}get failed(){return this.conflicts.length>0}get reason(){return this.result}toString(){return this.conflicts.length?`CONFLICTS: ${this.conflicts.join(`, `)}`:`OK`}}}}),bi,xi,Si=S({"src/lib/responses/PullSummary.ts"(){bi=class{constructor(){this.remoteMessages={all:[]},this.created=[],this.deleted=[],this.files=[],this.deletions={},this.insertions={},this.summary={changes:0,deletions:0,insertions:0}}},xi=class{constructor(){this.remote=``,this.hash={local:``,remote:``},this.branch={local:``,remote:``},this.message=``}toString(){return this.message}}}});function Ci(e){return e.objects=e.objects||{compressing:0,counting:0,enumerating:0,packReused:0,reused:{count:0,delta:0},total:{count:0,delta:0}}}function wi(e){let t=/^\s*(\d+)/.exec(e),n=/delta (\d+)/i.exec(e);return{count:P(t&&t[1]||`0`),delta:P(n&&n[1]||`0`)}}var Ti,Ei=S({"src/lib/parsers/parse-remote-objects.ts"(){q(),Ti=[new U(/^remote:\s*(enumerating|counting|compressing) objects: (\d+),/i,(e,[t,n])=>{let r=t.toLowerCase(),i=Ci(e.remoteMessages);Object.assign(i,{[r]:P(n)})}),new U(/^remote:\s*(enumerating|counting|compressing) objects: \d+% \(\d+\/(\d+)\),/i,(e,[t,n])=>{let r=t.toLowerCase(),i=Ci(e.remoteMessages);Object.assign(i,{[r]:P(n)})}),new U(/total ([^,]+), reused ([^,]+), pack-reused (\d+)/i,(e,[t,n,r])=>{let i=Ci(e.remoteMessages);i.total=wi(t),i.reused=wi(n),i.packReused=P(r)})]}});function Di(e,t){return K({remoteMessages:new ki},Oi,t)}var Oi,ki,Ai=S({"src/lib/parsers/parse-remote-messages.ts"(){q(),Ei(),Oi=[new U(/^remote:\s*(.+)$/,(e,[t])=>(e.remoteMessages.all.push(t.trim()),!1)),...Ti,new U([/create a (?:pull|merge) request/i,/\s(https?:\/\/\S+)$/],(e,[t])=>{e.remoteMessages.pullRequestUrl=t}),new U([/found (\d+) vulnerabilities.+\(([^)]+)\)/i,/\s(https?:\/\/\S+)$/],(e,[t,n,r])=>{e.remoteMessages.vulnerabilities={count:P(t),summary:n,url:r}})],ki=class{constructor(){this.all=[]}}}});function ji(e,t){let n=K(new xi,Ii,[e,t]);return n.message&&n}var Mi,Ni,Pi,Fi,Ii,Li,Ri,zi=S({"src/lib/parsers/parse-pull.ts"(){Si(),q(),Ai(),Mi=/^\s*(.+?)\s+\|\s+\d+\s*(\+*)(-*)/,Ni=/(\d+)\D+((\d+)\D+\(\+\))?(\D+(\d+)\D+\(-\))?/,Pi=/^(create|delete) mode \d+ (.+)/,Fi=[new H(Mi,(e,[t,n,r])=>{e.files.push(t),n&&(e.insertions[t]=n.length),r&&(e.deletions[t]=r.length)}),new H(Ni,(e,[t,,n,,r])=>n!==void 0||r!==void 0?(e.summary.changes=+t||0,e.summary.insertions=+n||0,e.summary.deletions=+r||0,!0):!1),new H(Pi,(e,[t,n])=>{j(e.files,n),j(t===`create`?e.created:e.deleted,n)})],Ii=[new H(/^from\s(.+)$/i,(e,[t])=>void(e.remote=t)),new H(/^fatal:\s(.+)$/,(e,[t])=>void(e.message=t)),new H(/([a-z0-9]+)\.\.([a-z0-9]+)\s+(\S+)\s+->\s+(\S+)$/,(e,[t,n,r,i])=>{e.branch.local=r,e.hash.local=t,e.branch.remote=i,e.hash.remote=n})],Li=(e,t)=>K(new bi,Fi,[e,t]),Ri=(e,t)=>Object.assign(new bi,Li(e,t),Di(e,t))}}),Bi,Vi,Hi,Ui=S({"src/lib/parsers/parse-merge.ts"(){yi(),q(),zi(),Bi=[new H(/^Auto-merging\s+(.+)$/,(e,[t])=>{e.merges.push(t)}),new H(/^CONFLICT\s+\((.+)\): Merge conflict in (.+)$/,(e,[t,n])=>{e.conflicts.push(new _i(t,n))}),new H(/^CONFLICT\s+\((.+\/delete)\): (.+) deleted in (.+) and/,(e,[t,n,r])=>{e.conflicts.push(new _i(t,n,{deleteRef:r}))}),new H(/^CONFLICT\s+\((.+)\):/,(e,[t])=>{e.conflicts.push(new _i(t,null))}),new H(/^Automatic merge failed;\s+(.+)$/,(e,[t])=>{e.result=t})],Vi=(e,t)=>Object.assign(Hi(e,t),Ri(e,t)),Hi=e=>K(new vi,Bi,e)}});function Wi(e){return e.length?{commands:[`merge`,...e],format:`utf-8`,parser(e,t){let n=Vi(e,t);if(n.failed)throw new D(n);return n}}:J(`Git.merge requires at least one option`)}var Gi=S({"src/lib/tasks/merge.ts"(){O(),Ui(),X()}});function Ki(e,t,n){let r=n.includes(`deleted`),i=n.includes(`tag`)||/^refs\/tags/.test(e),a=!n.includes(`new`);return{deleted:r,tag:i,branch:!i,new:!a,alreadyUpdated:a,local:e,remote:t}}var qi,Ji,Yi,Xi=S({"src/lib/parsers/parse-push.ts"(){q(),Ai(),qi=[new H(/^Pushing to (.+)$/,(e,[t])=>{e.repo=t}),new H(/^updating local tracking ref '(.+)'/,(e,[t])=>{e.ref={...e.ref||{},local:t}}),new H(/^[=*-]\s+([^:]+):(\S+)\s+\[(.+)]$/,(e,[t,n,r])=>{e.pushed.push(Ki(t,n,r))}),new H(/^Branch '([^']+)' set up to track remote branch '([^']+)' from '([^']+)'/,(e,[t,n,r])=>{e.branch={...e.branch||{},local:t,remote:n,remoteName:r}}),new H(/^([^:]+):(\S+)\s+([a-z0-9]+)\.\.([a-z0-9]+)$/,(e,[t,n,r,i])=>{e.update={head:{local:t,remote:n},hash:{from:r,to:i}}})],Ji=(e,t)=>{let n=Yi(e,t),r=Di(e,t);return{...n,...r}},Yi=(e,t)=>K({pushed:[]},qi,[e,t])}}),Zi={};C(Zi,{pushTagsTask:()=>Qi,pushTask:()=>$i});function Qi(e={},t){return j(t,`--tags`),$i(e,t)}function $i(e={},t){let n=[`push`,...t];return e.branch&&n.splice(1,0,e.branch),e.remote&&n.splice(1,0,e.remote),at(n,`-v`),j(n,`--verbose`),j(n,`--porcelain`),{commands:n,format:`utf-8`,parser:Ji}}var ea=S({"src/lib/tasks/push.ts"(){Xi(),q()}});function ta(){return{showBuffer(){let e=[`show`,...W(arguments,1)];return e.includes(`--binary`)||e.splice(1,0,`--binary`),this._runTask(Qt(e),G(arguments))},show(){let e=[`show`,...W(arguments,1)];return this._runTask(Y(e),G(arguments))}}}var na=S({"src/lib/tasks/show.ts"(){q(),X()}}),ra,ia,aa=S({"src/lib/responses/FileStatusSummary.ts"(){ra=/^(.+)\0(.+)$/,ia=class{constructor(e,t,n){if(this.path=e,this.index=t,this.working_dir=n,t===`R`||n===`R`){let t=ra.exec(e)||[null,e,e];this.from=t[2]||``,this.path=t[1]||``}}}}});function oa(e){let[t,n]=e.split(L);return{from:n||t,to:t}}function Q(e,t,n){return[`${e}${t}`,n]}function sa(e,...t){return t.map(t=>Q(e,t,(e,t)=>e.conflicted.push(t)))}function ca(e,t){let n=t.trim();switch(` `){case n.charAt(2):return r(n.charAt(0),n.charAt(1),n.slice(3));case n.charAt(1):return r(` `,n.charAt(0),n.slice(2));default:return}function r(t,n,r){let i=`${t}${n}`,a=ua.get(i);a&&a(e,r),i!==`##`&&i!==`!!`&&e.files.push(new ia(r,t,n))}}var la,ua,da,fa=S({"src/lib/responses/StatusSummary.ts"(){q(),aa(),la=class{constructor(){this.not_added=[],this.conflicted=[],this.created=[],this.deleted=[],this.ignored=void 0,this.modified=[],this.renamed=[],this.files=[],this.staged=[],this.ahead=0,this.behind=0,this.current=null,this.tracking=null,this.detached=!1,this.isClean=()=>!this.files.length}},ua=new Map([Q(` `,`A`,(e,t)=>e.created.push(t)),Q(` `,`D`,(e,t)=>e.deleted.push(t)),Q(` `,`M`,(e,t)=>e.modified.push(t)),Q(`A`,` `,(e,t)=>{e.created.push(t),e.staged.push(t)}),Q(`A`,`M`,(e,t)=>{e.created.push(t),e.staged.push(t),e.modified.push(t)}),Q(`D`,` `,(e,t)=>{e.deleted.push(t),e.staged.push(t)}),Q(`M`,` `,(e,t)=>{e.modified.push(t),e.staged.push(t)}),Q(`M`,`M`,(e,t)=>{e.modified.push(t),e.staged.push(t)}),Q(`R`,` `,(e,t)=>{e.renamed.push(oa(t))}),Q(`R`,`M`,(e,t)=>{let n=oa(t);e.renamed.push(n),e.modified.push(n.to)}),Q(`!`,`!`,(e,t)=>{(e.ignored=e.ignored||[]).push(t)}),Q(`?`,`?`,(e,t)=>e.not_added.push(t)),...sa(`A`,`A`,`U`),...sa(`D`,`D`,`U`),...sa(`U`,`A`,`D`,`U`),[`##`,(e,t)=>{let n=/ahead (\d+)/,r=/behind (\d+)/,i=/^(.+?(?=(?:\.{3}|\s|$)))/,a=/\.{3}(\S*)/,o=/\son\s(\S+?)(?=\.{3}|$)/,s=n.exec(t);e.ahead=s&&+s[1]||0,s=r.exec(t),e.behind=s&&+s[1]||0,s=i.exec(t),e.current=B(s?.[1],V,null),s=a.exec(t),e.tracking=B(s?.[1],V,null),s=o.exec(t),s&&(e.current=B(s?.[1],V,e.current)),e.detached=/\(no branch\)/.test(t)}]]),da=function(e){let t=e.split(L),n=new la;for(let e=0,r=t.length;e<r;){let r=t[e++].trim();r&&(r.charAt(0)===`R`&&(r+=L+(t[e++]||``)),ca(n,r))}return n}}});function pa(e){return{format:`utf-8`,commands:[`status`,`--porcelain`,`-b`,`-u`,`--null`,...e.filter(e=>!ma.includes(e))],parser(e){return da(e)}}}var ma,ha=S({"src/lib/tasks/status.ts"(){fa(),ma=[`--null`,`-z`]}});function ga(e=0,t=0,n=0,r=``,i=!0){return Object.defineProperty({major:e,minor:t,patch:n,agent:r,installed:i},`toString`,{value(){return`${this.major}.${this.minor}.${this.patch}`},configurable:!1,enumerable:!1})}function _a(){return ga(0,0,0,``,!1)}function va(){return{version(){return this._runTask({commands:[`--version`],format:`utf-8`,parser:ya,onError(e,t,n,r){if(e.exitCode===-2)return n(Buffer.from(ba));r(t)}})}}}function ya(e){return e===ba?_a():K(ga(0,0,0,e),xa,e)}var ba,xa,Sa=S({"src/lib/tasks/version.ts"(){q(),ba=`installed=false`,xa=[new H(/version (\d+)\.(\d+)\.(\d+)(?:\s*\((.+)\))?/,(e,[t,n,r,i=``])=>{Object.assign(e,ga(P(t),P(n),P(r),i))}),new H(/version (\d+)\.(\d+)\.(\D+)(.+)?$/,(e,[t,n,r,i=``])=>{Object.assign(e,ga(P(t),P(n),r,i))})]}});function Ca(e,t,n,...r){return V(n)?t(n,B(r[0],V),W(arguments)):J(`git.${e}() requires a string 'repoPath'`)}function wa(){return{clone(e,...t){return this._runTask(Ca(`clone`,Ta,B(e,V),...t),G(arguments))},mirror(e,...t){return this._runTask(Ca(`mirror`,Ea,B(e,V),...t),G(arguments))}}}var Ta,Ea,Da=S({"src/lib/tasks/clone.ts"(){X(),q(),Ta=(e,t,n)=>{let r=[`clone`,...n];return V(e)&&r.push(ne(e)),V(t)&&r.push(ne(t)),Y(r)},Ea=(e,t,n)=>(j(n,`--mirror`),Ta(e,t,n))}}),Oa={};C(Oa,{SimpleGitApi:()=>ka});var ka,Aa=S({"src/lib/simple-git-api.ts"(){dr(),pr(),gr(),br(),Er(),kn(),Or(),Vn(),Ar(),zr(),gi(),Gi(),ea(),na(),ha(),X(),Sa(),q(),Da(),ka=class{constructor(e){this._executor=e}_runTask(e,t){let n=this._executor.chain(),r=n.push(e);return t&&lr(e,r,t),Object.create(this,{then:{value:r.then.bind(r)},catch:{value:r.catch.bind(r)},_executor:{value:n}})}add(e){return this._runTask(Y([`add`,...M(e)]),G(arguments))}cwd(e){let t=G(arguments);return typeof e==`string`?this._runTask(fr(e,this._executor),t):typeof e?.path==`string`?this._runTask(fr(e.path,e.root&&this._executor||void 0),t):this._runTask(J(`Git.cwd: workingDirectory must be supplied as a string`),t)}hashObject(e,t){return this._runTask(kr(e,t===!0),G(arguments))}init(e){return this._runTask(Lr(e===!0,this._executor.cwd,W(arguments)),G(arguments))}merge(){return this._runTask(Wi(W(arguments)),G(arguments))}mergeFromTo(e,t){return V(e)&&V(t)?this._runTask(Wi([e,t,...W(arguments)]),G(arguments,!1)):this._runTask(J(`Git.mergeFromTo requires that the 'remote' and 'branch' arguments are supplied as strings`))}outputHandler(e){return this._executor.outputHandler=e,this}push(){let e=$i({remote:B(arguments[0],V),branch:B(arguments[1],V)},W(arguments));return this._runTask(e,G(arguments))}stash(){return this._runTask(Y([`stash`,...W(arguments)]),G(arguments))}status(){return this._runTask(pa(W(arguments)),G(arguments))}},Object.assign(ka.prototype,hr(),wa(),Tr(),Dn(),vr(),Dr(),In(),mi(),ta(),va())}}),ja={};C(ja,{Scheduler:()=>Na});var Ma,Na,Pa=S({"src/lib/runners/scheduler.ts"(){q(),$n(),Ma=(()=>{let e=0;return()=>{e++;let{promise:t,done:n}=(0,x.createDeferred)();return{promise:t,done:n,id:e}}})(),Na=class{constructor(e=2){this.concurrency=e,this.logger=Qn(``,`scheduler`),this.pending=[],this.running=[],this.logger(`Constructed, concurrency=%s`,e)}schedule(){if(!this.pending.length||this.running.length>=this.concurrency){this.logger(`Schedule attempt ignored, pending=%s running=%s concurrency=%s`,this.pending.length,this.running.length,this.concurrency);return}let e=j(this.running,this.pending.shift());this.logger(`Attempting id=%s`,e.id),e.done(()=>{this.logger(`Completing id=`,e.id),at(this.running,e),this.schedule()})}next(){let{promise:e,id:t}=j(this.pending,Ma());return this.logger(`Scheduling id=%s`,t),this.schedule(),e}}}}),Fa={};C(Fa,{applyPatchTask:()=>Ia});function Ia(e,t){return Y([`apply`,...t,...e])}var La=S({"src/lib/tasks/apply-patch.ts"(){X()}});function Ra(e,t){return{branch:e,hash:t,success:!0}}function za(e){return{branch:e,hash:null,success:!1}}var Ba,Va=S({"src/lib/responses/BranchDeleteSummary.ts"(){Ba=class{constructor(){this.all=[],this.branches={},this.errors=[]}get success(){return!this.errors.length}}}});function Ha(e,t){return t===1&&Wa.test(e)}var Ua,Wa,Ga,Ka,qa=S({"src/lib/parsers/parse-branch-delete.ts"(){Va(),q(),Ua=/(\S+)\s+\(\S+\s([^)]+)\)/,Wa=/^error[^']+'([^']+)'/m,Ga=[new H(Ua,(e,[t,n])=>{let r=Ra(t,n);e.all.push(r),e.branches[t]=r}),new H(Wa,(e,[t])=>{let n=za(t);e.errors.push(n),e.all.push(n),e.branches[t]=n})],Ka=(e,t)=>K(new Ba,Ga,[e,t])}}),Ja,Ya=S({"src/lib/responses/BranchSummary.ts"(){Ja=class{constructor(){this.all=[],this.branches={},this.current=``,this.detached=!1}push(e,t,n,r,i){e===`*`&&(this.detached=t,this.current=n),this.all.push(n),this.branches[n]={current:e===`*`,linkedWorkTree:e===`+`,name:n,commit:r,label:i}}}}});function Xa(e){return e?e.charAt(0):``}function Za(e,t=!1){return K(new Ja,t?[$a]:Qa,e)}var Qa,$a,eo=S({"src/lib/parsers/parse-branch.ts"(){Ya(),q(),Qa=[new H(/^([*+]\s)?\((?:HEAD )?detached (?:from|at) (\S+)\)\s+([a-z0-9]+)\s(.*)$/,(e,[t,n,r,i])=>{e.push(Xa(t),!0,n,r,i)}),new H(/^([*+]\s)?(\S+)\s+([a-z0-9]+)\s?(.*)$/s,(e,[t,n,r,i])=>{e.push(Xa(t),!1,n,r,i)})],$a=new H(/^(\S+)$/s,(e,[t])=>{e.push(`*`,!1,t,``,``)})}}),to={};C(to,{branchLocalTask:()=>io,branchTask:()=>ro,containsDeleteBranchCommand:()=>no,deleteBranchTask:()=>oo,deleteBranchesTask:()=>ao});function no(e){let t=[`-d`,`-D`,`--delete`];return e.some(e=>t.includes(e))}function ro(e){let t=no(e),n=e.includes(`--show-current`),r=[`branch`,...e];return r.length===1&&r.push(`-a`),r.includes(`-v`)||r.splice(1,0,`-v`),{format:`utf-8`,commands:r,parser(e,r){return t?Ka(e,r).all[0]:Za(e,n)}}}function io(){return{format:`utf-8`,commands:[`branch`,`-v`],parser(e){return Za(e)}}}function ao(e,t=!1){return{format:`utf-8`,commands:[`branch`,`-v`,t?`-D`:`-d`,...e],parser(e,t){return Ka(e,t)},onError({exitCode:e,stdOut:t},n,r,i){if(!Ha(String(n),e))return i(n);r(t)}}}function oo(e,t=!1){let n={format:`utf-8`,commands:[`branch`,`-v`,t?`-D`:`-d`,e],parser(t,n){return Ka(t,n).branches[e]},onError({exitCode:e,stdErr:t,stdOut:r},i,a,o){if(!Ha(String(i),e))return o(i);throw new D(n.parser(I(r),I(t)),String(i))}};return n}var so=S({"src/lib/tasks/branch.ts"(){O(),qa(),eo(),q()}});function co(e){let t=e.trim().replace(/^["']|["']$/g,``);return t&&r(t)}var lo,uo=S({"src/lib/responses/CheckIgnore.ts"(){lo=e=>e.split(/\n/g).map(co).filter(Boolean)}}),fo={};C(fo,{checkIgnoreTask:()=>po});function po(e){return{commands:[`check-ignore`,...e],format:`utf-8`,parser:lo}}var mo=S({"src/lib/tasks/check-ignore.ts"(){uo()}});function ho(e,t){return K({raw:e,remote:null,branches:[],tags:[],updated:[],deleted:[]},go,[e,t])}var go,_o=S({"src/lib/parsers/parse-fetch.ts"(){q(),go=[new H(/From (.+)$/,(e,[t])=>{e.remote=t}),new H(/\* \[new branch]\s+(\S+)\s*-> (.+)$/,(e,[t,n])=>{e.branches.push({name:t,tracking:n})}),new H(/\* \[new tag]\s+(\S+)\s*-> (.+)$/,(e,[t,n])=>{e.tags.push({name:t,tracking:n})}),new H(/- \[deleted]\s+\S+\s*-> (.+)$/,(e,[t])=>{e.deleted.push({tracking:t})}),new H(/\s*([^.]+)\.\.(\S+)\s+(\S+)\s*-> (.+)$/,(e,[t,n,r,i])=>{e.updated.push({name:r,tracking:i,to:n,from:t})})]}}),vo={};C(vo,{fetchTask:()=>bo});function yo(e){return/^--upload-pack(=|$)/.test(e)}function bo(e,t,n){let r=[`fetch`,...n];return e&&t&&r.push(e,t),r.find(yo)?J(`git.fetch: potential exploit argument blocked.`):{commands:r,format:`utf-8`,parser:ho}}var xo=S({"src/lib/tasks/fetch.ts"(){_o(),X()}});function So(e){return K({moves:[]},Co,e)}var Co,wo=S({"src/lib/parsers/parse-move.ts"(){q(),Co=[new H(/^Renaming (.+) to (.+)$/,(e,[t,n])=>{e.moves.push({from:t,to:n})})]}}),To={};C(To,{moveTask:()=>Eo});function Eo(e,t){return{commands:[`mv`,`-v`,...M(e),t],format:`utf-8`,parser:So}}var Do=S({"src/lib/tasks/move.ts"(){wo(),q()}}),Oo={};C(Oo,{pullTask:()=>ko});function ko(e,t,n){let r=[`pull`,...n];return e&&t&&r.splice(1,0,e,t),{commands:r,format:`utf-8`,parser(e,t){return Ri(e,t)},onError(e,t,n,r){let i=ji(I(e.stdOut),I(e.stdErr));if(i)return r(new D(i));r(t)}}}var Ao=S({"src/lib/tasks/pull.ts"(){O(),zi(),q()}});function jo(e){let t={};return No(e,([e])=>t[e]={name:e}),Object.values(t)}function Mo(e){let t={};return No(e,([e,n,r])=>{Object.hasOwn(t,e)||(t[e]={name:e,refs:{fetch:``,push:``}}),r&&n&&(t[e].refs[r.replace(/[^a-z]/g,``)]=n)}),Object.values(t)}function No(e,t){nt(e,e=>t(e.split(/\s+/)))}var Po=S({"src/lib/responses/GetRemoteSummary.ts"(){q()}}),Fo={};C(Fo,{addRemoteTask:()=>Io,getRemotesTask:()=>Lo,listRemotesTask:()=>Ro,remoteTask:()=>zo,removeRemoteTask:()=>Bo});function Io(e,t,n){return Y([`remote`,`add`,...n,e,t])}function Lo(e){let t=[`remote`];return e&&t.push(`-v`),{commands:t,format:`utf-8`,parser:e?Mo:jo}}function Ro(e){let t=[...e];return t[0]!==`ls-remote`&&t.unshift(`ls-remote`),Y(t)}function zo(e){let t=[...e];return t[0]!==`remote`&&t.unshift(`remote`),Y(t)}function Bo(e){return Y([`remote`,`remove`,e])}var Vo=S({"src/lib/tasks/remote.ts"(){Po(),X()}}),Ho={};C(Ho,{stashListTask:()=>Uo});function Uo(e={},t){let n=fi(e),r=[`stash`,`list`,...n.commands,...t],i=ei(n.splitter,n.fields,Br(r));return ci(r)||{commands:r,format:`utf-8`,parser:i}}var Wo=S({"src/lib/tasks/stash-list.ts"(){Ur(),ai(),li(),gi()}}),Go={};C(Go,{addSubModuleTask:()=>Ko,initSubModuleTask:()=>qo,subModuleTask:()=>Jo,updateSubModuleTask:()=>Yo});function Ko(e,t){return Jo([`add`,e,t])}function qo(e){return Jo([`init`,...e])}function Jo(e){let t=[...e];return t[0]!==`submodule`&&t.unshift(`submodule`),Y(t)}function Yo(e){return Jo([`update`,...e])}var Xo=S({"src/lib/tasks/sub-module.ts"(){X()}});function Zo(e,t){let n=Number.isNaN(e);return n===Number.isNaN(t)?n?Qo(e,t):0:n?1:-1}function Qo(e,t){return e===t?0:e>t?1:-1}function $o(e){return e.trim()}function es(e){return typeof e==`string`&&parseInt(e.replace(/^\D+/g,``),10)||0}var ts,ns,rs=S({"src/lib/responses/TagList.ts"(){ts=class{constructor(e,t){this.all=e,this.latest=t}},ns=function(e,t=!1){let n=e.split(`
|
|
9
|
-
`).map($o).filter(Boolean);t||n.sort(function(e,t){let n=e.split(`.`),r=t.split(`.`);if(n.length===1||r.length===1)return Zo(es(n[0]),es(r[0]));for(let e=0,t=Math.max(n.length,r.length);e<t;e++){let t=Qo(es(n[e]),es(r[e]));if(t)return t}return 0});let r=t?n[0]:[...n].reverse().find(e=>e.indexOf(`.`)>=0);return new ts(n,r)}}}),is={};C(is,{addAnnotatedTagTask:()=>ss,addTagTask:()=>os,tagListTask:()=>as});function as(e=[]){let t=e.some(e=>/^--sort=/.test(e));return{format:`utf-8`,commands:[`tag`,`-l`,...e],parser(e){return ns(e,t)}}}function os(e){return{format:`utf-8`,commands:[`tag`,e],parser(){return{name:e}}}}function ss(e,t){return{format:`utf-8`,commands:[`tag`,`-a`,`-m`,t,e],parser(){return{name:e}}}}var cs=S({"src/lib/tasks/tag.ts"(){rs()}}),ls=qe({"src/git.js"(e,t){var{GitExecutor:n}=(cr(),w(or)),{SimpleGitApi:r}=(Aa(),w(Oa)),{Scheduler:i}=(Pa(),w(ja)),{adhocExecTask:a,configurationErrorTask:o}=(X(),w(Xt)),{asArray:s,filterArray:c,filterPrimitives:l,filterString:u,filterStringOrStringArray:d,filterType:f,getTrailingOptions:p,trailingFunctionArgument:m,trailingOptionsArgument:ee}=(q(),w(Pt)),{applyPatchTask:te}=(La(),w(Fa)),{branchTask:ne,branchLocalTask:h,deleteBranchesTask:g,deleteBranchTask:re}=(so(),w(to)),{checkIgnoreTask:ie}=(mo(),w(fo)),{checkIsRepoTask:ae}=(Ut(),w(Ft)),{cleanWithOptionsTask:oe,isCleanOptionsArray:se}=(gn(),w(nn)),{diffSummaryTask:ce}=(li(),w(oi)),{fetchTask:le}=(xo(),w(vo)),{moveTask:_}=(Do(),w(To)),{pullTask:ue}=(Ao(),w(Oo)),{pushTagsTask:de}=(ea(),w(Zi)),{addRemoteTask:fe,getRemotesTask:pe,listRemotesTask:me,remoteTask:he,removeRemoteTask:ge}=(Vo(),w(Fo)),{getResetMode:_e,resetTask:ve}=(Jn(),w(Hn)),{stashListTask:ye}=(Wo(),w(Ho)),{addSubModuleTask:be,initSubModuleTask:xe,subModuleTask:Se,updateSubModuleTask:Ce}=(Xo(),w(Go)),{addAnnotatedTagTask:we,addTagTask:Te,tagListTask:Ee}=(cs(),w(is)),{straightThroughBufferTask:v,straightThroughStringTask:y}=(X(),w(Xt));function b(e,t){this._plugins=t,this._executor=new n(e.baseDir,new i(e.maxConcurrentProcesses),t),this._trimmed=e.trimmed}(b.prototype=Object.create(r.prototype)).constructor=b,b.prototype.customBinary=function(e){return this._plugins.reconfigure(`binary`,e),this},b.prototype.env=function(e,t){return arguments.length===1&&typeof e==`object`?this._executor.env=e:(this._executor.env=this._executor.env||{})[e]=t,this},b.prototype.stashList=function(e){return this._runTask(ye(ee(arguments)||{},c(e)&&e||[]),m(arguments))},b.prototype.mv=function(e,t){return this._runTask(_(e,t),m(arguments))},b.prototype.checkoutLatestTag=function(e){var t=this;return this.pull(function(){t.tags(function(n,r){t.checkout(r.latest,e)})})},b.prototype.pull=function(e,t,n,r){return this._runTask(ue(f(e,u),f(t,u),p(arguments)),m(arguments))},b.prototype.fetch=function(e,t){return this._runTask(le(f(e,u),f(t,u),p(arguments)),m(arguments))},b.prototype.silent=function(e){return this._runTask(a(()=>console.warn("simple-git deprecation notice: git.silent: logging should be configured using the `debug` library / `DEBUG` environment variable, this method will be removed.")))},b.prototype.tags=function(e,t){return this._runTask(Ee(p(arguments)),m(arguments))},b.prototype.rebase=function(){return this._runTask(y([`rebase`,...p(arguments)]),m(arguments))},b.prototype.reset=function(e){return this._runTask(ve(_e(e),p(arguments)),m(arguments))},b.prototype.revert=function(e){let t=m(arguments);return typeof e==`string`?this._runTask(y([`revert`,...p(arguments,0,!0),e]),t):this._runTask(o(`Commit must be a string`),t)},b.prototype.addTag=function(e){let t=typeof e==`string`?Te(e):o(`Git.addTag requires a tag name`);return this._runTask(t,m(arguments))},b.prototype.addAnnotatedTag=function(e,t){return this._runTask(we(e,t),m(arguments))},b.prototype.deleteLocalBranch=function(e,t,n){return this._runTask(re(e,typeof t==`boolean`?t:!1),m(arguments))},b.prototype.deleteLocalBranches=function(e,t,n){return this._runTask(g(e,typeof t==`boolean`?t:!1),m(arguments))},b.prototype.branch=function(e,t){return this._runTask(ne(p(arguments)),m(arguments))},b.prototype.branchLocal=function(e){return this._runTask(h(),m(arguments))},b.prototype.raw=function(e){let t=!Array.isArray(e),n=[].slice.call(t?arguments:e,0);for(let e=0;e<n.length&&t;e++)if(!l(n[e])){n.splice(e,n.length-e);break}n.push(...p(arguments,0,!0));var r=m(arguments);return n.length?this._runTask(y(n,this._trimmed),r):this._runTask(o(`Raw: must supply one or more command to execute`),r)},b.prototype.submoduleAdd=function(e,t,n){return this._runTask(be(e,t),m(arguments))},b.prototype.submoduleUpdate=function(e,t){return this._runTask(Ce(p(arguments,!0)),m(arguments))},b.prototype.submoduleInit=function(e,t){return this._runTask(xe(p(arguments,!0)),m(arguments))},b.prototype.subModule=function(e,t){return this._runTask(Se(p(arguments)),m(arguments))},b.prototype.listRemote=function(){return this._runTask(me(p(arguments)),m(arguments))},b.prototype.addRemote=function(e,t,n){return this._runTask(fe(e,t,p(arguments)),m(arguments))},b.prototype.removeRemote=function(e,t){return this._runTask(ge(e),m(arguments))},b.prototype.getRemotes=function(e,t){return this._runTask(pe(e===!0),m(arguments))},b.prototype.remote=function(e,t){return this._runTask(he(p(arguments)),m(arguments))},b.prototype.tag=function(e,t){let n=p(arguments);return n[0]!==`tag`&&n.unshift(`tag`),this._runTask(y(n),m(arguments))},b.prototype.updateServerInfo=function(e){return this._runTask(y([`update-server-info`]),m(arguments))},b.prototype.pushTags=function(e,t){let n=de({remote:f(e,u)},p(arguments));return this._runTask(n,m(arguments))},b.prototype.rm=function(e){return this._runTask(y([`rm`,`-f`,...s(e)]),m(arguments))},b.prototype.rmKeepLocal=function(e){return this._runTask(y([`rm`,`--cached`,...s(e)]),m(arguments))},b.prototype.catFile=function(e,t){return this._catFile(`utf-8`,arguments)},b.prototype.binaryCatFile=function(){return this._catFile(`buffer`,arguments)},b.prototype._catFile=function(e,t){var n=m(t),r=[`cat-file`],i=t[0];if(typeof i==`string`)return this._runTask(o(`Git.catFile: options must be supplied as an array of strings`),n);Array.isArray(i)&&r.push.apply(r,i);let a=e===`buffer`?v(r):y(r);return this._runTask(a,n)},b.prototype.diff=function(e,t){let n=u(e)?o(`git.diff: supplying options as a single string is no longer supported, switch to an array of strings`):y([`diff`,...p(arguments)]);return this._runTask(n,m(arguments))},b.prototype.diffSummary=function(){return this._runTask(ce(p(arguments,1)),m(arguments))},b.prototype.applyPatch=function(e){let t=d(e)?te(s(e),p([].slice.call(arguments,1))):o(`git.applyPatch requires one or more string patches as the first argument`);return this._runTask(t,m(arguments))},b.prototype.revparse=function(){let e=[`rev-parse`,...p(arguments,!0)];return this._runTask(y(e,!0),m(arguments))},b.prototype.clean=function(e,t,n){let r=se(e),i=r&&e.join(``)||f(e,u)||``,a=p([].slice.call(arguments,r?1:0));return this._runTask(oe(i,a),m(arguments))},b.prototype.exec=function(e){return this._runTask({commands:[],format:`utf-8`,parser(){typeof e==`function`&&e()}})},b.prototype.clearQueue=function(){return this._runTask(a(()=>console.warn(`simple-git deprecation notice: clearQueue() is deprecated and will be removed, switch to using the abortPlugin instead.`)))},b.prototype.checkIgnore=function(e,t){return this._runTask(ie(s(f(e,d,[]))),m(arguments))},b.prototype.checkIsRepo=function(e,t){return this._runTask(ae(f(e,u)),m(arguments))},t.exports=b}});E();var us=class extends T{constructor(e,t){super(void 0,t),this.config=e}};E(),E();var $=class extends T{constructor(e,t,n){super(e,n),this.task=e,this.plugin=t,Object.setPrototypeOf(this,new.target.prototype)}};O(),Xe(),Ut(),gn(),kn(),Nn(),Vn(),Jn();function ds(e){if(e)return[{type:`spawn.before`,action(t,n){e.aborted&&n.kill(new $(void 0,`abort`,`Abort already signaled`))}},{type:`spawn.after`,action(t,n){function r(){n.kill(new $(void 0,`abort`,`Abort signal received`))}e.addEventListener(`abort`,r),n.spawned.on(`close`,()=>e.removeEventListener(`abort`,r))}}]}function fs(e={}){return{type:`spawn.args`,action(t,{env:n}){for(let r of Be(t,n))if(e[r.category]!==!0)throw new $(void 0,`unsafe`,r.message);return t}}}q();function ps(e){let t=F(e,`-c`);return{type:`spawn.args`,action(e){return[...t,...e]}}}q();var ms=(0,x.deferred)().promise;function hs({onClose:e=!0,onExit:t=50}={}){function n(){let n=-1,i={close:(0,x.deferred)(),closeTimeout:(0,x.deferred)(),exit:(0,x.deferred)(),exitTimeout:(0,x.deferred)()},a=Promise.race([e===!1?ms:i.closeTimeout.promise,t===!1?ms:i.exitTimeout.promise]);return r(e,i.close,i.closeTimeout),r(t,i.exit,i.exitTimeout),{close(e){n=e,i.close.done()},exit(e){n=e,i.exit.done()},get exitCode(){return n},result:a}}function r(e,t,n){e!==!1&&(e===!0?t.promise:t.promise.then(()=>ct(e))).then(n.done)}return{type:`spawn.after`,async action(e,{spawned:t,close:r}){let i=n(),a=!0,o=()=>void(a=!1);t.stdout?.on(`data`,o),t.stderr?.on(`data`,o),t.on(`error`,o),t.on(`close`,e=>i.close(e)),t.on(`exit`,e=>i.exit(e));try{await i.result,a&&await ct(50),r(i.exitCode)}catch(e){r(i.exitCode,e)}}}}q();var gs=`Invalid value supplied for custom binary, requires a single string or an array containing either one or two strings`,_s=`Invalid value supplied for custom binary, restricted characters must be removed or supply the unsafe.allowUnsafeCustomBinary option`;function vs(e){return!e||!/^([a-z]:)?([a-z0-9/.\\_~-]+)$/i.test(e)}function ys(e,t){if(e.length<1||e.length>2)throw new $(void 0,`binary`,gs);if(e.some(vs))if(t)console.warn(_s);else throw new $(void 0,`binary`,_s);let[n,r]=e;return{binary:n,prefix:r}}function bs(e,t=[`git`],n=!1){let r=ys(M(t),n);e.on(`binary`,e=>{r=ys(M(e),n)}),e.append(`spawn.binary`,()=>r.binary),e.append(`spawn.args`,e=>r.prefix?[r.prefix,...e]:e)}E();function xs(e){return!!(e.exitCode&&e.stdErr.length)}function Ss(e){return Buffer.concat([...e.stdOut,...e.stdErr])}function Cs(e=!1,t=xs,n=Ss){return(r,i)=>!e&&r||!t(i)?r:n(i)}function ws(e){return{type:`task.error`,action(t,n){let r=e(t.error,{stdErr:n.stdErr,stdOut:n.stdOut,exitCode:n.exitCode});return Buffer.isBuffer(r)?{error:new T(void 0,r.toString(`utf-8`))}:{error:r}}}}q();var Ts=class{constructor(){this.plugins=new Set,this.events=new o}on(e,t){this.events.on(e,t)}reconfigure(e,t){this.events.emit(e,t)}append(e,t){let n=j(this.plugins,{type:e,action:t});return()=>this.plugins.delete(n)}add(e){let t=[];return M(e).forEach(e=>e&&this.plugins.add(j(t,e))),()=>{t.forEach(e=>this.plugins.delete(e))}}exec(e,t,n){let r=t,i=Object.freeze(Object.create(n));for(let t of this.plugins)t.type===e&&(r=t.action(r,i));return r}};q();function Es(e){let t=`--progress`,n=[`checkout`,`clone`,`fetch`,`pull`,`push`];return[{type:`spawn.args`,action(e,r){return n.includes(r.method)?it(e,t):e}},{type:`spawn.after`,action(n,r){r.commands.includes(t)&&r.spawned.stderr?.on(`data`,t=>{let n=/^([\s\S]+?):\s*(\d+)% \((\d+)\/(\d+)\)/.exec(t.toString(`utf8`));n&&e({method:r.method,stage:Ds(n[1]),progress:P(n[2]),processed:P(n[3]),total:P(n[4])})})}}]}function Ds(e){return String(e.toLowerCase().split(` `,1))||`unknown`}q();function Os(e){let t=st(e,[`uid`,`gid`]);return{type:`spawn.options`,action(e){return{...t,...e}}}}function ks({block:e,stdErr:t=!0,stdOut:n=!0}){if(e>0)return{type:`spawn.after`,action(r,i){let a;function o(){a&&clearTimeout(a),a=setTimeout(c,e)}function s(){i.spawned.stdout?.off(`data`,o),i.spawned.stderr?.off(`data`,o),i.spawned.off(`exit`,s),i.spawned.off(`close`,s),a&&clearTimeout(a)}function c(){s(),i.kill(new $(void 0,`timeout`,`block timeout reached`))}n&&i.spawned.stdout?.on(`data`,o),t&&i.spawned.stderr?.on(`data`,o),i.spawned.on(`exit`,s),i.spawned.on(`close`,s),o()}}}function As(){return{type:`spawn.args`,action(e){let t=[],n;function r(e){(n||=[]).push(...e)}for(let n=0;n<e.length;n++){let i=e[n];if(h(i)){r(g(i));continue}if(i===`--`){r(e.slice(n+1).flatMap(e=>h(e)&&g(e)||e));break}t.push(i)}return n?[...t,`--`,...n.map(String)]:t}}}q();var js=ls();function Ms(e,t){let n=new Ts,r=Tt(e&&(typeof e==`string`?{baseDir:e}:e)||{},t);if(!rt(r.baseDir))throw new us(r,`Cannot use simple-git on a directory that does not exist`);return Array.isArray(r.config)&&n.add(ps(r.config)),n.add(fs(r.unsafe)),n.add(hs(r.completion)),r.abort&&n.add(ds(r.abort)),r.progress&&n.add(Es(r.progress)),r.timeout&&n.add(ks(r.timeout)),r.spawnOptions&&n.add(Os(r.spawnOptions)),n.add(As()),n.add(ws(Cs(!0))),r.errors&&n.add(ws(r.errors)),bs(n,r.binary,r.unsafe?.allowUnsafeCustomBinary),new js(r,n)}O();var Ns=Ms,Ps=Ms;const Fs=new class{_tail=Promise.resolve();enqueue(e){let t=this._tail.then(()=>e());return this._tail=t.catch(()=>void 0),t}};function Is(e){return Fs.enqueue(e)}const Ls=[`HOME`,`USERPROFILE`,`HOMEDRIVE`,`HOMEPATH`,`APPDATA`,`LOCALAPPDATA`,`ProgramData`,`ALLUSERSPROFILE`,`SystemRoot`,`WINDIR`,`windir`,`ComSpec`,`TEMP`,`TMP`,`USERNAME`,`USERDOMAIN`,`PATHEXT`,`SSH_AUTH_SOCK`,`ELECTRON_RUN_AS_NODE`];function Rs(e){let t={LANG:`C`,LC_ALL:`C`,GIT_TERMINAL_PROMPT:`0`},n=process.env.PATH??process.env.Path;n!==void 0&&(t.PATH=n);for(let e of Ls){let n=process.env[e];n!==void 0&&(t[e]=n)}return e&&(t.OK_GH_TOKEN=e.token,t.OK_GH_TOKEN_HOST=e.host),t}function zs(e,t){let n={...e.env};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return e.git.env(n)}function Bs(e){return e.split(`\0`).filter(e=>e.length>0)}function Vs(e,t={}){let{credentialArgs:n=[],gitIndexFile:r,ghToken:a,timeoutMs:o}=t,s=Rs(a);return r&&(s.GIT_INDEX_FILE=i(e,r)),{git:Ps({baseDir:e,config:[`commit.gpgsign=false`,`core.autocrlf=false`,...n.length>=2?[n[1]]:[]],unsafe:{allowUnsafeCredentialHelper:!0},...o===void 0?{}:{timeout:{block:o}}}).env(s),projectDir:e,credentialArgs:n,env:s}}export{Ps as a,Is as i,Vs as n,Ns as o,Bs as r,p as s,zs as t};
|
|
10
|
-
//# sourceMappingURL=git-handle-
|
|
9
|
+
`).map($o).filter(Boolean);t||n.sort(function(e,t){let n=e.split(`.`),r=t.split(`.`);if(n.length===1||r.length===1)return Zo(es(n[0]),es(r[0]));for(let e=0,t=Math.max(n.length,r.length);e<t;e++){let t=Qo(es(n[e]),es(r[e]));if(t)return t}return 0});let r=t?n[0]:[...n].reverse().find(e=>e.indexOf(`.`)>=0);return new ts(n,r)}}}),is={};C(is,{addAnnotatedTagTask:()=>ss,addTagTask:()=>os,tagListTask:()=>as});function as(e=[]){let t=e.some(e=>/^--sort=/.test(e));return{format:`utf-8`,commands:[`tag`,`-l`,...e],parser(e){return ns(e,t)}}}function os(e){return{format:`utf-8`,commands:[`tag`,e],parser(){return{name:e}}}}function ss(e,t){return{format:`utf-8`,commands:[`tag`,`-a`,`-m`,t,e],parser(){return{name:e}}}}var cs=S({"src/lib/tasks/tag.ts"(){rs()}}),ls=qe({"src/git.js"(e,t){var{GitExecutor:n}=(cr(),w(or)),{SimpleGitApi:r}=(Aa(),w(Oa)),{Scheduler:i}=(Pa(),w(ja)),{adhocExecTask:a,configurationErrorTask:o}=(X(),w(Xt)),{asArray:s,filterArray:c,filterPrimitives:l,filterString:u,filterStringOrStringArray:d,filterType:f,getTrailingOptions:p,trailingFunctionArgument:m,trailingOptionsArgument:ee}=(q(),w(Pt)),{applyPatchTask:te}=(La(),w(Fa)),{branchTask:ne,branchLocalTask:h,deleteBranchesTask:g,deleteBranchTask:re}=(so(),w(to)),{checkIgnoreTask:ie}=(mo(),w(fo)),{checkIsRepoTask:ae}=(Ut(),w(Ft)),{cleanWithOptionsTask:oe,isCleanOptionsArray:se}=(gn(),w(nn)),{diffSummaryTask:ce}=(li(),w(oi)),{fetchTask:le}=(xo(),w(vo)),{moveTask:_}=(Do(),w(To)),{pullTask:ue}=(Ao(),w(Oo)),{pushTagsTask:de}=(ea(),w(Zi)),{addRemoteTask:fe,getRemotesTask:pe,listRemotesTask:me,remoteTask:he,removeRemoteTask:ge}=(Vo(),w(Fo)),{getResetMode:_e,resetTask:ve}=(Jn(),w(Hn)),{stashListTask:ye}=(Wo(),w(Ho)),{addSubModuleTask:be,initSubModuleTask:xe,subModuleTask:Se,updateSubModuleTask:Ce}=(Xo(),w(Go)),{addAnnotatedTagTask:we,addTagTask:Te,tagListTask:Ee}=(cs(),w(is)),{straightThroughBufferTask:v,straightThroughStringTask:y}=(X(),w(Xt));function b(e,t){this._plugins=t,this._executor=new n(e.baseDir,new i(e.maxConcurrentProcesses),t),this._trimmed=e.trimmed}(b.prototype=Object.create(r.prototype)).constructor=b,b.prototype.customBinary=function(e){return this._plugins.reconfigure(`binary`,e),this},b.prototype.env=function(e,t){return arguments.length===1&&typeof e==`object`?this._executor.env=e:(this._executor.env=this._executor.env||{})[e]=t,this},b.prototype.stashList=function(e){return this._runTask(ye(ee(arguments)||{},c(e)&&e||[]),m(arguments))},b.prototype.mv=function(e,t){return this._runTask(_(e,t),m(arguments))},b.prototype.checkoutLatestTag=function(e){var t=this;return this.pull(function(){t.tags(function(n,r){t.checkout(r.latest,e)})})},b.prototype.pull=function(e,t,n,r){return this._runTask(ue(f(e,u),f(t,u),p(arguments)),m(arguments))},b.prototype.fetch=function(e,t){return this._runTask(le(f(e,u),f(t,u),p(arguments)),m(arguments))},b.prototype.silent=function(e){return this._runTask(a(()=>console.warn("simple-git deprecation notice: git.silent: logging should be configured using the `debug` library / `DEBUG` environment variable, this method will be removed.")))},b.prototype.tags=function(e,t){return this._runTask(Ee(p(arguments)),m(arguments))},b.prototype.rebase=function(){return this._runTask(y([`rebase`,...p(arguments)]),m(arguments))},b.prototype.reset=function(e){return this._runTask(ve(_e(e),p(arguments)),m(arguments))},b.prototype.revert=function(e){let t=m(arguments);return typeof e==`string`?this._runTask(y([`revert`,...p(arguments,0,!0),e]),t):this._runTask(o(`Commit must be a string`),t)},b.prototype.addTag=function(e){let t=typeof e==`string`?Te(e):o(`Git.addTag requires a tag name`);return this._runTask(t,m(arguments))},b.prototype.addAnnotatedTag=function(e,t){return this._runTask(we(e,t),m(arguments))},b.prototype.deleteLocalBranch=function(e,t,n){return this._runTask(re(e,typeof t==`boolean`?t:!1),m(arguments))},b.prototype.deleteLocalBranches=function(e,t,n){return this._runTask(g(e,typeof t==`boolean`?t:!1),m(arguments))},b.prototype.branch=function(e,t){return this._runTask(ne(p(arguments)),m(arguments))},b.prototype.branchLocal=function(e){return this._runTask(h(),m(arguments))},b.prototype.raw=function(e){let t=!Array.isArray(e),n=[].slice.call(t?arguments:e,0);for(let e=0;e<n.length&&t;e++)if(!l(n[e])){n.splice(e,n.length-e);break}n.push(...p(arguments,0,!0));var r=m(arguments);return n.length?this._runTask(y(n,this._trimmed),r):this._runTask(o(`Raw: must supply one or more command to execute`),r)},b.prototype.submoduleAdd=function(e,t,n){return this._runTask(be(e,t),m(arguments))},b.prototype.submoduleUpdate=function(e,t){return this._runTask(Ce(p(arguments,!0)),m(arguments))},b.prototype.submoduleInit=function(e,t){return this._runTask(xe(p(arguments,!0)),m(arguments))},b.prototype.subModule=function(e,t){return this._runTask(Se(p(arguments)),m(arguments))},b.prototype.listRemote=function(){return this._runTask(me(p(arguments)),m(arguments))},b.prototype.addRemote=function(e,t,n){return this._runTask(fe(e,t,p(arguments)),m(arguments))},b.prototype.removeRemote=function(e,t){return this._runTask(ge(e),m(arguments))},b.prototype.getRemotes=function(e,t){return this._runTask(pe(e===!0),m(arguments))},b.prototype.remote=function(e,t){return this._runTask(he(p(arguments)),m(arguments))},b.prototype.tag=function(e,t){let n=p(arguments);return n[0]!==`tag`&&n.unshift(`tag`),this._runTask(y(n),m(arguments))},b.prototype.updateServerInfo=function(e){return this._runTask(y([`update-server-info`]),m(arguments))},b.prototype.pushTags=function(e,t){let n=de({remote:f(e,u)},p(arguments));return this._runTask(n,m(arguments))},b.prototype.rm=function(e){return this._runTask(y([`rm`,`-f`,...s(e)]),m(arguments))},b.prototype.rmKeepLocal=function(e){return this._runTask(y([`rm`,`--cached`,...s(e)]),m(arguments))},b.prototype.catFile=function(e,t){return this._catFile(`utf-8`,arguments)},b.prototype.binaryCatFile=function(){return this._catFile(`buffer`,arguments)},b.prototype._catFile=function(e,t){var n=m(t),r=[`cat-file`],i=t[0];if(typeof i==`string`)return this._runTask(o(`Git.catFile: options must be supplied as an array of strings`),n);Array.isArray(i)&&r.push.apply(r,i);let a=e===`buffer`?v(r):y(r);return this._runTask(a,n)},b.prototype.diff=function(e,t){let n=u(e)?o(`git.diff: supplying options as a single string is no longer supported, switch to an array of strings`):y([`diff`,...p(arguments)]);return this._runTask(n,m(arguments))},b.prototype.diffSummary=function(){return this._runTask(ce(p(arguments,1)),m(arguments))},b.prototype.applyPatch=function(e){let t=d(e)?te(s(e),p([].slice.call(arguments,1))):o(`git.applyPatch requires one or more string patches as the first argument`);return this._runTask(t,m(arguments))},b.prototype.revparse=function(){let e=[`rev-parse`,...p(arguments,!0)];return this._runTask(y(e,!0),m(arguments))},b.prototype.clean=function(e,t,n){let r=se(e),i=r&&e.join(``)||f(e,u)||``,a=p([].slice.call(arguments,r?1:0));return this._runTask(oe(i,a),m(arguments))},b.prototype.exec=function(e){return this._runTask({commands:[],format:`utf-8`,parser(){typeof e==`function`&&e()}})},b.prototype.clearQueue=function(){return this._runTask(a(()=>console.warn(`simple-git deprecation notice: clearQueue() is deprecated and will be removed, switch to using the abortPlugin instead.`)))},b.prototype.checkIgnore=function(e,t){return this._runTask(ie(s(f(e,d,[]))),m(arguments))},b.prototype.checkIsRepo=function(e,t){return this._runTask(ae(f(e,u)),m(arguments))},t.exports=b}});E();var us=class extends T{constructor(e,t){super(void 0,t),this.config=e}};E(),E();var $=class extends T{constructor(e,t,n){super(e,n),this.task=e,this.plugin=t,Object.setPrototypeOf(this,new.target.prototype)}};O(),Xe(),Ut(),gn(),kn(),Nn(),Vn(),Jn();function ds(e){if(e)return[{type:`spawn.before`,action(t,n){e.aborted&&n.kill(new $(void 0,`abort`,`Abort already signaled`))}},{type:`spawn.after`,action(t,n){function r(){n.kill(new $(void 0,`abort`,`Abort signal received`))}e.addEventListener(`abort`,r),n.spawned.on(`close`,()=>e.removeEventListener(`abort`,r))}}]}function fs(e={}){return{type:`spawn.args`,action(t,{env:n}){for(let r of Be(t,n))if(e[r.category]!==!0)throw new $(void 0,`unsafe`,r.message);return t}}}q();function ps(e){let t=F(e,`-c`);return{type:`spawn.args`,action(e){return[...t,...e]}}}q();var ms=(0,x.deferred)().promise;function hs({onClose:e=!0,onExit:t=50}={}){function n(){let n=-1,i={close:(0,x.deferred)(),closeTimeout:(0,x.deferred)(),exit:(0,x.deferred)(),exitTimeout:(0,x.deferred)()},a=Promise.race([e===!1?ms:i.closeTimeout.promise,t===!1?ms:i.exitTimeout.promise]);return r(e,i.close,i.closeTimeout),r(t,i.exit,i.exitTimeout),{close(e){n=e,i.close.done()},exit(e){n=e,i.exit.done()},get exitCode(){return n},result:a}}function r(e,t,n){e!==!1&&(e===!0?t.promise:t.promise.then(()=>ct(e))).then(n.done)}return{type:`spawn.after`,async action(e,{spawned:t,close:r}){let i=n(),a=!0,o=()=>void(a=!1);t.stdout?.on(`data`,o),t.stderr?.on(`data`,o),t.on(`error`,o),t.on(`close`,e=>i.close(e)),t.on(`exit`,e=>i.exit(e));try{await i.result,a&&await ct(50),r(i.exitCode)}catch(e){r(i.exitCode,e)}}}}q();var gs=`Invalid value supplied for custom binary, requires a single string or an array containing either one or two strings`,_s=`Invalid value supplied for custom binary, restricted characters must be removed or supply the unsafe.allowUnsafeCustomBinary option`;function vs(e){return!e||!/^([a-z]:)?([a-z0-9/.\\_~-]+)$/i.test(e)}function ys(e,t){if(e.length<1||e.length>2)throw new $(void 0,`binary`,gs);if(e.some(vs))if(t)console.warn(_s);else throw new $(void 0,`binary`,_s);let[n,r]=e;return{binary:n,prefix:r}}function bs(e,t=[`git`],n=!1){let r=ys(M(t),n);e.on(`binary`,e=>{r=ys(M(e),n)}),e.append(`spawn.binary`,()=>r.binary),e.append(`spawn.args`,e=>r.prefix?[r.prefix,...e]:e)}E();function xs(e){return!!(e.exitCode&&e.stdErr.length)}function Ss(e){return Buffer.concat([...e.stdOut,...e.stdErr])}function Cs(e=!1,t=xs,n=Ss){return(r,i)=>!e&&r||!t(i)?r:n(i)}function ws(e){return{type:`task.error`,action(t,n){let r=e(t.error,{stdErr:n.stdErr,stdOut:n.stdOut,exitCode:n.exitCode});return Buffer.isBuffer(r)?{error:new T(void 0,r.toString(`utf-8`))}:{error:r}}}}q();var Ts=class{constructor(){this.plugins=new Set,this.events=new o}on(e,t){this.events.on(e,t)}reconfigure(e,t){this.events.emit(e,t)}append(e,t){let n=j(this.plugins,{type:e,action:t});return()=>this.plugins.delete(n)}add(e){let t=[];return M(e).forEach(e=>e&&this.plugins.add(j(t,e))),()=>{t.forEach(e=>this.plugins.delete(e))}}exec(e,t,n){let r=t,i=Object.freeze(Object.create(n));for(let t of this.plugins)t.type===e&&(r=t.action(r,i));return r}};q();function Es(e){let t=`--progress`,n=[`checkout`,`clone`,`fetch`,`pull`,`push`];return[{type:`spawn.args`,action(e,r){return n.includes(r.method)?it(e,t):e}},{type:`spawn.after`,action(n,r){r.commands.includes(t)&&r.spawned.stderr?.on(`data`,t=>{let n=/^([\s\S]+?):\s*(\d+)% \((\d+)\/(\d+)\)/.exec(t.toString(`utf8`));n&&e({method:r.method,stage:Ds(n[1]),progress:P(n[2]),processed:P(n[3]),total:P(n[4])})})}}]}function Ds(e){return String(e.toLowerCase().split(` `,1))||`unknown`}q();function Os(e){let t=st(e,[`uid`,`gid`]);return{type:`spawn.options`,action(e){return{...t,...e}}}}function ks({block:e,stdErr:t=!0,stdOut:n=!0}){if(e>0)return{type:`spawn.after`,action(r,i){let a;function o(){a&&clearTimeout(a),a=setTimeout(c,e)}function s(){i.spawned.stdout?.off(`data`,o),i.spawned.stderr?.off(`data`,o),i.spawned.off(`exit`,s),i.spawned.off(`close`,s),a&&clearTimeout(a)}function c(){s(),i.kill(new $(void 0,`timeout`,`block timeout reached`))}n&&i.spawned.stdout?.on(`data`,o),t&&i.spawned.stderr?.on(`data`,o),i.spawned.on(`exit`,s),i.spawned.on(`close`,s),o()}}}function As(){return{type:`spawn.args`,action(e){let t=[],n;function r(e){(n||=[]).push(...e)}for(let n=0;n<e.length;n++){let i=e[n];if(h(i)){r(g(i));continue}if(i===`--`){r(e.slice(n+1).flatMap(e=>h(e)&&g(e)||e));break}t.push(i)}return n?[...t,`--`,...n.map(String)]:t}}}q();var js=ls();function Ms(e,t){let n=new Ts,r=Tt(e&&(typeof e==`string`?{baseDir:e}:e)||{},t);if(!rt(r.baseDir))throw new us(r,`Cannot use simple-git on a directory that does not exist`);return Array.isArray(r.config)&&n.add(ps(r.config)),n.add(fs(r.unsafe)),n.add(hs(r.completion)),r.abort&&n.add(ds(r.abort)),r.progress&&n.add(Es(r.progress)),r.timeout&&n.add(ks(r.timeout)),r.spawnOptions&&n.add(Os(r.spawnOptions)),n.add(As()),n.add(ws(Cs(!0))),r.errors&&n.add(ws(r.errors)),bs(n,r.binary,r.unsafe?.allowUnsafeCustomBinary),new js(r,n)}O();var Ns=Ms,Ps=Ms;const Fs=new class{_tail=Promise.resolve();enqueue(e){let t=this._tail.then(()=>e());return this._tail=t.catch(()=>void 0),t}};function Is(e){return Fs.enqueue(e)}const Ls=[`HOME`,`USERPROFILE`,`HOMEDRIVE`,`HOMEPATH`,`APPDATA`,`LOCALAPPDATA`,`ProgramData`,`ALLUSERSPROFILE`,`SystemRoot`,`WINDIR`,`windir`,`ComSpec`,`TEMP`,`TMP`,`USERNAME`,`USERDOMAIN`,`PATHEXT`,`SSH_AUTH_SOCK`,`ELECTRON_RUN_AS_NODE`];function Rs(e){let t={LANG:`C`,LC_ALL:`C`,GIT_TERMINAL_PROMPT:`0`},n=process.env.PATH??process.env.Path;n!==void 0&&(t.PATH=n);for(let e of Ls){let n=process.env[e];n!==void 0&&(t[e]=n)}return e&&(t.OK_GH_TOKEN=e.token,t.OK_GH_TOKEN_HOST=e.host),t}function zs(e,t){let n={...e.env};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return e.git.env(n)}function Bs(e,t={}){let{credentialArgs:n=[],gitIndexFile:r,ghToken:a,timeoutMs:o}=t,s=Rs(a);return r&&(s.GIT_INDEX_FILE=i(e,r)),{git:Ps({baseDir:e,config:[`commit.gpgsign=false`,`core.autocrlf=false`,...n.length>=2?[n[1]]:[]],unsafe:{allowUnsafeCredentialHelper:!0},...o===void 0?{}:{timeout:{block:o}}}).env(s),projectDir:e,credentialArgs:n,env:s}}export{Ns as a,Ps as i,Bs as n,p as o,Is as r,zs as t};
|
|
10
|
+
//# sourceMappingURL=git-handle-B4hCEi7c-CXOP12Ds.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./git-handle-B4hCEi7c-CXOP12Ds.mjs";export{e as createGitInstance};
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,r as t,t as n}from"./gh-detect-DSpFEO46.mjs";import{B as r,C as i,E as a,F as o,I as s,L as c,P as l,R as u,S as d,a as f,b as p,i as m,l as h,m as g,n as _,u as v,z as y}from"./init-
|
|
1
|
+
import{i as e,r as t,t as n}from"./gh-detect-DSpFEO46.mjs";import{B as r,C as i,E as a,F as o,I as s,L as c,P as l,R as u,S as d,a as f,b as p,i as m,l as h,m as g,n as _,u as v,z as y}from"./init-CylIL2_d.mjs";import{_ as b,b as x,d as S,f as C,i as w,l as T,m as E,n as D,r as O,t as k,u as A,v as j,y as M}from"./src-DL-hUlrv.mjs";import{_ as N,a as P,d as F,g as I,h as L,i as R,l as z,n as B,o as V,r as H,t as U,u as W}from"./write-project-skill-C7UNscN7.mjs";import{n as G}from"./loader-DL7cugZT.mjs";import{n as K}from"./preview-Bn8zUTY3.mjs";import{n as q,t as J}from"./mcp-migrate-event-D0NrGjvc.mjs";export{V as ALL_EDITOR_IDS,z as EDITOR_LABELS,W as EDITOR_TARGETS,F as HOSTS_WITH_USER_SKILL_DIR,_ as LAUNCH_CONFIG_NAME,m as LAUNCH_UI_CHAIN_SENTINEL,f as LAUNCH_UI_CHAIN_V1,A as PATH_SHIM_BEGIN,S as PATH_SHIM_BLOCK_RE,C as PATH_SHIM_END,l as addOkPathsToGitExclude,U as assertProjectPathSafe,L as buildManagedServerEntry,O as buildMcpConfigDeclineEvent,J as buildMcpConfigMigrateEvent,h as classifyExistingMcpEntry,t as createTokenStore,n as detectGh,v as detectInstalledEditors,o as formatTrackedRemediation,s as getExcludedOkPaths,c as getOkArtifactPaths,I as isEntryUpToDate,N as isOwnManagedEntry,G as loadConfig,e as makeLazyProbeTokenStore,b as parseGitHubBlobUrl,j as parseGitHubShareUrl,M as parseGitHubTreeUrl,x as parseGitUrl,E as pathInstallMarkerPath,K as previewContent,u as probeTrackedOkPaths,g as readExistingMcpEntry,y as readSharingMode,r as removeOkPathsFromGitExclude,T as removeOwnMcpEntry,B as removeProjectSkill,R as removeUserGlobalSkillBundle,a as resolveProjectRoot,w as runStop,p as scaffoldLaunchJson,q as truncatePriorEntry,P as userGlobalSkillBundleTargets,D as validateLocalFolderForShare,d as writeEditorMcpConfig,k as writeProjectAiIntegrations,H as writeProjectSkill,i as writeUserMcpConfigs};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,s as t,t as n}from"./chunk-C94x7I9S.mjs";import{Ba as r,Bt as i,Et as a,Va as o,Xi as s,bi as c,bn as l,ja as u,mt as d}from"./server-lock-iLcBw_q0-D_cD26E0.mjs";import{$n as f,Ca as p,D as m,Gn as h,K as g,O as _,Qn as v,Zn as y,cr as b,d as x,ha as S,ia as C,ir as w,ra as T,ut as E,va as D,vn as ee}from"./dist-CPsLcVzP.mjs";import{r as O,t as k}from"./esm-CsQUg9js.mjs";import{t as te}from"./constants-BnzVSpjR.mjs";import{b as ne,f as re,h as A,i as ie,m as ae,o as oe,p as se,r as ce,t as j,u as M,y as N}from"./write-project-skill-f17OygUR.mjs";import{t as P}from"./is-object-Cg453afR.mjs";import{i as F,n as le,o as I,r as ue,s as L,t as R}from"./colors-8SzMRIVy.mjs";import{t as de}from"./preview-CPq8NQ67.mjs";import{createRequire as fe}from"node:module";import{execFileSync as pe}from"node:child_process";import me,{dirname as z,isAbsolute as he,join as B,relative as V,resolve as ge,sep as _e}from"node:path";import H from"node:process";import{fileURLToPath as ve}from"node:url";import{homedir as ye}from"node:os";import{existsSync as U,lstatSync as be,mkdirSync as xe,readFileSync as W,readlinkSync as Se,realpathSync as Ce,statSync as we,writeFileSync as Te}from"node:fs";import{randomUUID as Ee}from"node:crypto";import{inspect as De,stripVTControlCharacters as Oe,styleText as G}from"node:util";import{AsyncLocalStorage as ke,AsyncResource as Ae}from"node:async_hooks";import{createServer as je,request as Me}from"node:http";import*as Ne from"node:readline";import{connect as Pe}from"node:net";const Fe=new Set([`emacs`,`vim`]);function Ie(e){return Fe.has(e)}function Le(){let e=process.env.INQUIRER_KEYBINDINGS;return e?Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(Ie))):[]}const Re=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,ze=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,Be=e=>e.name===`space`,Ve=e=>e.name===`backspace`,He=e=>`1234567890`.includes(e.name),Ue=e=>e.name===`enter`||e.name===`return`;var We=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},Ge=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},Ke=class extends Error{name=`ExitPromptError`},qe=class extends Error{name=`HookError`},Je=class extends Error{name=`ValidationError`};const Ye=new ke;function Xe(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Ze(e,t){let n=Xe(e);return Ye.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function K(){let e=Ye.getStore();if(!e)throw new qe(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function Qe(){return K().rl}function $e(e){return Ae.bind((...t)=>{let n=K(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function et(e){let t=K(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function tt(){K().handleChange()}const nt={queue(e){let t=K(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(Qe());if(r!=null&&typeof r!=`function`)throw new Je(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=K();$e(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=K();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function rt(e){return typeof e==`function`}function q(e){return et(t=>{let n=Ae.bind(function(e){t.get()!==e&&(t.set(e),tt())});if(t.initialized)return[t.get(),n];let r=rt(e)?e():e;return t.set(r),[r,n]})}function it(e,t){et(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&nt.queue(e),n.set(t)})}function at(){return H.platform.startsWith(`win`)?!!H.env.CI||!!H.env.WT_SESSION||!!H.env.TERMINUS_SUBLIME||H.env.ConEmuTask===`{cmd::Cmder}`||H.env.TERM_PROGRAM===`Terminus-Sublime`||H.env.TERM_PROGRAM===`vscode`||H.env.TERM===`xterm-256color`||H.env.TERM===`alacritty`||H.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:H.env.TERM!==`linux`}const ot={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},st={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},ct={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},lt={...ot,...st},ut={...ot,...ct},dt=at()?lt:ut;Object.entries(st);const ft={prefix:{idle:G(`blue`,`?`),done:G(`green`,dt.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>G(`yellow`,e))},keybindings:[],style:{answer:e=>G(`cyan`,e),message:e=>G(`bold`,e),error:e=>G(`red`,`> ${e}`),defaultAnswer:e=>G(`dim`,`(${e})`),help:e=>G(`dim`,e),highlight:e=>G(`cyan`,e),key:e=>G(`cyan`,G(`bold`,`<${e}>`))}};function pt(){return{...ft,keybindings:Le()}}function mt(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ht(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=mt(n)&&mt(r)?ht(n,r):r}return t}function gt(...e){return ht(pt(),...e.filter(e=>e!=null))}function _t({status:e=`idle`,theme:t}){let[n,r]=q(!1),[i,a]=q(0),{prefix:o,spinner:s}=gt(t);return it(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}else r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function vt(e,t){return et(n=>{let r=n.get();if(!r||r.dependencies.length!==t.length||r.dependencies.some((e,n)=>e!==t[n])){let r=e();return n.set({value:r,dependencies:t}),r}return r.value})}function yt(e){return q({current:e})[0]}function bt(e){let t=yt(e);t.current=e,it(e=>{let n=!1,r=$e((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var xt=n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(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 e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}));const St=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),Ct=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,wt=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,Tt=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Et=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Dt=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Ot=/\t{1,1000}/y,kt=/[\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?))*/uy,At=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,jt=/\p{M}+/gu,Mt={limit:1/0,ellipsis:``},Nt=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Nt(i,Mt,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[At,l],[Tt,0],[Et,o],[Ot,s],[kt,c],[Dt,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(jt,``)){let t=e.codePointAt(0)||0;if(S=Ct(t)?2:wt(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===Dt?St(e.slice(p,n.lastIndex)):n===kt?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},Pt={limit:1/0,ellipsis:``,ellipsisWidth:0},J=(e,t={})=>Nt(e,Pt,t).width,Ft=`]8;;`,It=RegExp(`(?:\\[(?<code>\\d+)m|\\${Ft}(?<uri>.*))`,`y`),Lt=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},Rt=e=>`[${e}m`,zt=e=>`${Ft}${e}`,Bt=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:J(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=J(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===``)&&(i=!0,a=t.startsWith(Ft,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Vt=e=>{let t=e.split(` `),n=t.length;for(;n&&!J(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ht=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=J(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=J(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Bt(s,r,t),c=J(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Bt(s,r,t),c=J(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Bt(s,r,t),c=J(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Vt(e)));let l=s.join(`
|
|
1
|
+
import{a as e,s as t,t as n}from"./chunk-C94x7I9S.mjs";import{Ba as r,Bt as i,Et as a,Va as o,Xi as s,bi as c,bn as l,ja as u,mt as d}from"./server-lock-iLcBw_q0-D_cD26E0.mjs";import{$n as f,Ca as p,D as m,Gn as h,K as g,O as _,Qn as v,Zn as y,cr as b,d as x,ha as S,ia as C,ir as w,ra as T,ut as E,va as D,vn as ee}from"./dist-Dzsbf2ES.mjs";import{r as O,t as k}from"./esm-CsQUg9js.mjs";import{t as te}from"./constants-DQ9gCjtp.mjs";import{b as ne,f as re,h as A,i as ie,m as ae,o as oe,p as se,r as ce,t as j,u as M,y as N}from"./write-project-skill-C7UNscN7.mjs";import{t as P}from"./is-object-Cg453afR.mjs";import{i as F,n as le,o as I,r as ue,s as L,t as R}from"./colors-8SzMRIVy.mjs";import{t as de}from"./preview-Bn8zUTY3.mjs";import{createRequire as fe}from"node:module";import{execFileSync as pe}from"node:child_process";import me,{dirname as z,isAbsolute as he,join as B,relative as V,resolve as ge,sep as _e}from"node:path";import H from"node:process";import{fileURLToPath as ve}from"node:url";import{homedir as ye}from"node:os";import{existsSync as U,lstatSync as be,mkdirSync as xe,readFileSync as W,readlinkSync as Se,realpathSync as Ce,statSync as we,writeFileSync as Te}from"node:fs";import{randomUUID as Ee}from"node:crypto";import{inspect as De,stripVTControlCharacters as Oe,styleText as G}from"node:util";import{AsyncLocalStorage as ke,AsyncResource as Ae}from"node:async_hooks";import{createServer as je,request as Me}from"node:http";import*as Ne from"node:readline";import{connect as Pe}from"node:net";const Fe=new Set([`emacs`,`vim`]);function Ie(e){return Fe.has(e)}function Le(){let e=process.env.INQUIRER_KEYBINDINGS;return e?Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(Ie))):[]}const Re=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,ze=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,Be=e=>e.name===`space`,Ve=e=>e.name===`backspace`,He=e=>`1234567890`.includes(e.name),Ue=e=>e.name===`enter`||e.name===`return`;var We=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},Ge=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},Ke=class extends Error{name=`ExitPromptError`},qe=class extends Error{name=`HookError`},Je=class extends Error{name=`ValidationError`};const Ye=new ke;function Xe(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function Ze(e,t){let n=Xe(e);return Ye.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function K(){let e=Ye.getStore();if(!e)throw new qe(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function Qe(){return K().rl}function $e(e){return Ae.bind((...t)=>{let n=K(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function et(e){let t=K(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function tt(){K().handleChange()}const nt={queue(e){let t=K(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(Qe());if(r!=null&&typeof r!=`function`)throw new Je(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=K();$e(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=K();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function rt(e){return typeof e==`function`}function q(e){return et(t=>{let n=Ae.bind(function(e){t.get()!==e&&(t.set(e),tt())});if(t.initialized)return[t.get(),n];let r=rt(e)?e():e;return t.set(r),[r,n]})}function it(e,t){et(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&nt.queue(e),n.set(t)})}function at(){return H.platform.startsWith(`win`)?!!H.env.CI||!!H.env.WT_SESSION||!!H.env.TERMINUS_SUBLIME||H.env.ConEmuTask===`{cmd::Cmder}`||H.env.TERM_PROGRAM===`Terminus-Sublime`||H.env.TERM_PROGRAM===`vscode`||H.env.TERM===`xterm-256color`||H.env.TERM===`alacritty`||H.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:H.env.TERM!==`linux`}const ot={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},st={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},ct={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},lt={...ot,...st},ut={...ot,...ct},dt=at()?lt:ut;Object.entries(st);const ft={prefix:{idle:G(`blue`,`?`),done:G(`green`,dt.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>G(`yellow`,e))},keybindings:[],style:{answer:e=>G(`cyan`,e),message:e=>G(`bold`,e),error:e=>G(`red`,`> ${e}`),defaultAnswer:e=>G(`dim`,`(${e})`),help:e=>G(`dim`,e),highlight:e=>G(`cyan`,e),key:e=>G(`cyan`,G(`bold`,`<${e}>`))}};function pt(){return{...ft,keybindings:Le()}}function mt(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ht(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=mt(n)&&mt(r)?ht(n,r):r}return t}function gt(...e){return ht(pt(),...e.filter(e=>e!=null))}function _t({status:e=`idle`,theme:t}){let[n,r]=q(!1),[i,a]=q(0),{prefix:o,spinner:s}=gt(t);return it(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}else r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function vt(e,t){return et(n=>{let r=n.get();if(!r||r.dependencies.length!==t.length||r.dependencies.some((e,n)=>e!==t[n])){let r=e();return n.set({value:r,dependencies:t}),r}return r.value})}function yt(e){return q({current:e})[0]}function bt(e){let t=yt(e);t.current=e,it(e=>{let n=!1,r=$e((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var xt=n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(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 e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}));const St=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),Ct=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,wt=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,Tt=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Et=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Dt=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Ot=/\t{1,1000}/y,kt=/[\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?))*/uy,At=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,jt=/\p{M}+/gu,Mt={limit:1/0,ellipsis:``},Nt=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Nt(i,Mt,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[At,l],[Tt,0],[Et,o],[Ot,s],[kt,c],[Dt,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(jt,``)){let t=e.codePointAt(0)||0;if(S=Ct(t)?2:wt(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===Dt?St(e.slice(p,n.lastIndex)):n===kt?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},Pt={limit:1/0,ellipsis:``,ellipsisWidth:0},J=(e,t={})=>Nt(e,Pt,t).width,Ft=`]8;;`,It=RegExp(`(?:\\[(?<code>\\d+)m|\\${Ft}(?<uri>.*))`,`y`),Lt=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},Rt=e=>`[${e}m`,zt=e=>`${Ft}${e}`,Bt=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:J(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=J(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===``)&&(i=!0,a=t.startsWith(Ft,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Vt=e=>{let t=e.split(` `),n=t.length;for(;n&&!J(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ht=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=J(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=J(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Bt(s,r,t),c=J(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Bt(s,r,t),c=J(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Bt(s,r,t),c=J(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Vt(e)));let l=s.join(`
|
|
2
2
|
`),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===``){It.lastIndex=e+1;let t=It.exec(l)?.groups;if(t?.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t?.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}if(l[e+1]===`
|
|
3
3
|
`){a&&(r+=zt(``));let e=i?Lt(i):void 0;i&&e&&(r+=Rt(e))}else t===`
|
|
4
4
|
`&&(i&&Lt(i)&&(r+=Rt(i)),a&&(r+=zt(a)))}return r},Ut=/\r?\n/;function Wt(e,t,n){return String(e).normalize().split(Ut).map(e=>Ht(e,t,n)).join(`
|
|
@@ -628,7 +628,7 @@ export default function okBridge(pi: {
|
|
|
628
628
|
});
|
|
629
629
|
}
|
|
630
630
|
`}function bi(e,t){let n=V(t,e);return n.length>0&&!n.startsWith(`..`)&&!he(n)}const xi=e=>{try{let t=pe(`git`,[`rev-parse`,`--show-toplevel`],{cwd:e,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim();return t.length>0?t:null}catch{return null}};function Si(e,t={}){let n=t.homeDir??ye(),r=t.gitTopLevel??xi,i=ge(e),a;try{a=Ce(i)}catch{a=i}let o=a,s=0;for(;s<30&&!(o===n||o===`/`||o===``);){if(b(o))return{projectRoot:o,defaultContentDir:`.`,ancestorPromoted:o!==a,gitRootPromoted:!1};let e=z(o);if(e===o)break;o=e,s+=1}let c=r(a);return c!==null&&bi(c,n)?c===a?{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}:{projectRoot:c,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!0}:{projectRoot:i,defaultContentDir:`.`,ancestorPromoted:!1,gitRootPromoted:!1}}function Ci(e){let t=e&&typeof e==`object`&&`code`in e?e.code:void 0;return t===`MODULE_NOT_FOUND`||t===`ERR_MODULE_NOT_FOUND`}function $(e,t){if(!process.env.OK_DEBUG_NATIVE)return;let n=t instanceof Error?t.message:String(t);process.stderr.write(`[ok] native-config ${e}: ${n}\n`)}const wi=[`native`,`index.js`];function Ti(e={}){let t=e.moduleUrl??import.meta.url,n=e.requireModule??fe(t);try{return n(B(z(ve(t)),...wi))}catch(e){Ci(e)||$(`bundled loader failed to load`,e)}try{return n(`@inkeep/open-knowledge-native-config`)}catch(e){return Ci(e)||$(`workspace addon failed to load`,e),null}}function Ei(){let e=Ti();return e&&typeof e.resolveSymlinkWritePath==`function`?e:null}function Di(e){let t=e,n=new Set;for(;;){let r;try{r=be(t).isSymbolicLink()}catch(n){return n.code===`ENOENT`?{readPath:t,writePath:t}:{readPath:null,writePath:e}}if(!r)return{readPath:t,writePath:t};if(n.has(t))return{readPath:null,writePath:e};n.add(t);let i;try{i=Se(t)}catch(t){return $(`readlinkSync threw during symlink walk`,t),{readPath:null,writePath:e}}t=he(i)?i:B(z(t),i)}}let Oi;function ki(){return Oi===void 0&&(Oi=Ei()),Oi}function Ai(e,t=ki){let n=t();if(n)try{let t=n.resolveSymlinkWritePath(e);return{readPath:t.readPath??null,writePath:t.writePath}}catch(e){$(`resolveSymlinkWritePath threw`,e)}return Di(e)}function ji(){let e=Ti();return e&&typeof e.parseTomlToJson==`function`?e:null}function Mi(e){try{let t=e.parseTomlToJson(`probe = 1`);return typeof t==`string`&&t.includes(`probe`)}catch(e){return $(`addon loaded but probe failed`,e),!1}}function Ni(e){if(!P(e))throw Error(`TOML root is not a table`);return e}function Pi(e){return{backend:`native`,parseToObject(t){return Ni(JSON.parse(e.parseTomlToJson(t)))},upsertEntry(t,n,r){let i=e.upsertMcpServer(t,n,JSON.stringify(r));return{text:i.text,existed:i.existed}},removeEntry(t,n){let r=e.removeMcpServer(t,n);return{text:r.text,existed:r.existed}}}}function Fi(){return{backend:`fallback`,parseToObject(e){return Ni(ii(e))}}}function Ii(e=ji){let t=e();return t&&Mi(t)?Pi(t):Fi()}let Li=null;function Ri(){return Li===null&&(Li=Ii()),Li}function zi(e,t,n,r,i){let a=`urn:uuid:${Ee()}`;if(e.headersSent||e.writableEnded||e.destroyed){console.error(`[ok ui] emitProblem called after headers sent — suppressed`,{type:n,status:t,instance:a});return}let o={type:n,title:r,status:t,instance:a,...i===void 0?{}:{detail:i}},s=l.safeParse(o);if(!s.success){console.error(`[ok ui] emitProblem produced an invalid ProblemDetails body:`,{issues:s.error.issues,originalStatus:t,body:o}),e.writeHead(500,{"Content-Type":`application/problem+json`,"X-Content-Type-Options":`nosniff`,"Cache-Control":`no-store`}),e.end(JSON.stringify({type:`urn:ok:error:internal-server-error`,title:`Internal server error.`,status:500,instance:a}));return}e.writeHead(t,{"Content-Type":`application/problem+json`,"X-Content-Type-Options":`nosniff`,"Cache-Control":`no-store`}),e.end(JSON.stringify(o))}const Bi=1e4;function Vi(e,t){let n=e.socket?.remoteAddress;if(n!==void 0&&!w(n))return zi(t,403,`urn:ok:error:loopback-required`,`Request must originate from a loopback address.`),!0;if(!f(e.headers.host))return zi(t,403,`urn:ok:error:host-not-allowed`,`Host header is not in the loopback allowlist.`),!0;let r=e.headers.origin;return r!==void 0&&!v(r)?(zi(t,403,`urn:ok:error:invalid-origin`,`Origin header is not in the loopback allowlist.`),!0):!1}const Hi=3e4;function Ui(e,t){let n=e.socket?.remoteAddress;if(n!==void 0&&!w(n)||!f(e.headers.host))return t.destroy(),!0;let r=e.headers.origin;return typeof r==`string`&&!v(r)?(t.destroy(),!0):!1}function Wi(e,t,n,r,i,a){a.add(t),t.once(`close`,()=>a.delete(t));let o=Pe({host:r,port:i,timeout:Bi});a.add(o),o.once(`close`,()=>a.delete(o));let s=!1,c=n=>{if(!s){if(s=!0,n!==void 0){let t=n.err;console.warn(JSON.stringify({event:n.event,upstreamHost:r,upstreamPort:i,url:e.url,code:t instanceof Error?t.code:void 0,message:t instanceof Error?t.message:void 0}))}try{o.destroy()}catch{}try{t.destroy()}catch{}}};o.once(`connect`,()=>{o.setTimeout(0);let a=[`${e.method??`GET`} ${e.url??`/`} HTTP/1.1`,`host: ${r}:${i}`];for(let[t,n]of Object.entries(e.headers))if(t.toLowerCase()!==`host`&&n!==void 0)if(Array.isArray(n))for(let e of n)a.push(`${t}: ${e}`);else a.push(`${t}: ${n}`);try{o.write(`${a.join(`\r
|
|
631
|
-
`)}\r\n\r\n`),n.length>0&&o.write(n)}catch(e){c({event:`proxy-upgrade-handshake-write-failed`,err:e});return}o.on(`data`,e=>{t.writable&&t.write(e)}),t.on(`data`,e=>{o.writable&&o.write(e)})}),o.once(`timeout`,()=>{c({event:`proxy-upgrade-upstream-connect-timeout`})}),o.on(`error`,e=>c({event:`proxy-upgrade-upstream-error`,err:e})),t.on(`error`,e=>c({event:`proxy-upgrade-client-error`,err:e})),o.once(`close`,()=>c()),t.once(`close`,()=>c())}const Gi=[`connection`,`keep-alive`,`proxy-authenticate`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`cookie`,`set-cookie`];async function Ki(e){let t=e.upstreamTimeoutMs??Bi,n=new Set,r=je((n,r)=>{Vi(n,r)||Ji(n,r,e.upstreamHost,e.upstreamPort,t)});r.on(`upgrade`,(t,r,i)=>{Ui(t,r)||Wi(t,r,i,e.upstreamHost,e.upstreamPort,n)}),await new Promise((t,n)=>{let i=e=>n(e);r.once(`error`,i),r.listen(e.listenPort,e.host,()=>{r.off(`error`,i),t()})});let i=r.address();return{httpServer:r,port:typeof i==`object`&&i?i.port:e.listenPort,close:()=>new Promise(e=>{for(let e of n)try{e.destroy()}catch{}n.clear(),r.close(()=>e()),r.closeIdleConnections()})}}function qi(e,t,n){Ji(e,t,n.upstreamHost,n.upstreamPort,n.upstreamTimeoutMs??Bi)}function Ji(e,t,n,r,i){let a={...e.headers};delete a.host;for(let e of Gi)delete a[e];e.setTimeout(Hi,()=>{if(t.headersSent)try{t.end()}catch{}else try{zi(t,408,`urn:ok:error:request-timeout`,`Proxy request exceeded the per-request deadline.`,`Slow-loris-class: client did not finish within ${Hi/1e3}s.`)}catch{}try{e.socket?.destroy()}catch{}});let o=Me({host:n,port:r,method:e.method,path:e.url,headers:{...a,host:`${n}:${r}`}},e=>{let n={...e.headers};for(let e of Gi)delete n[e];t.writeHead(e.statusCode??502,n),e.pipe(t),e.once(`error`,()=>{try{t.end()}catch{}})});i>0&&o.setTimeout(i,()=>{if(!t.headersSent)zi(t,504,`urn:ok:error:gateway-timeout`,`Upstream did not respond before the gateway deadline.`,`Upstream timeout: ${i/1e3}s elapsed without a response.`);else try{t.end()}catch{}o.destroy()}),o.on(`error`,()=>{if(!t.headersSent)zi(t,502,`urn:ok:error:collab-server-not-running`,`Collab server is unreachable.`,`Upstream connection failed or dropped before a response was received.`);else try{t.end()}catch{}}),e.on(`error`,()=>{o.destroy()}),e.pipe(o)}const Yi=39847,Xi=39848;async function Zi(e){await Promise.all(e.map(e=>new Promise(t=>{e.close(()=>t())})))}async function Qi(e){let{existsSync:t}=await import(`node:fs`),{createServer:n}=await import(`node:http`),{resolve:i}=await import(`node:path`),{acquireUiLock:a,clearArmedPaneTarget:s,createAssetServeMiddleware:l,createContentFilter:f,readArmedPaneTarget:p,readServerLock:m,releaseUiLock:h,updateUiLockPort:g}=await import(`./dist-BSd2Ezzl.mjs`),{default:_}=await import(`./build-gfyDk62R.mjs`),{resolveContentDir:v,resolveLockDir:y}=await import(`./dist-BSd2Ezzl.mjs`),b=v(e.config,e.cwd),x=y(e.cwd);a(x,{port:0,worktreeRoot:e.cwd});let S=import.meta.dirname??new URL(`.`,import.meta.url).pathname,C=[i(S,`public`),i(S,`../../app/dist`),i(S,`../../../app/dist`)],w=e.assetDir??C.find(e=>t(e)),T=w?_(w,{single:!0,gzip:!0,etag:!0,dev:!0,extensions:[]}):null,E=t(b)?l({contentFilter:f({projectDir:e.cwd,contentDir:b}),contentSirv:_(b,{dotfiles:!1,dev:!0,extensions:[]}),inlineExtensions:o,assetExtensions:u,blocklistExtensions:r}):null,D=e.port,ee=null,O=(e,t)=>{let n=e.url?.split(`?`)[0];if(e.method===`GET`&&(n===`/`||n===``)){let e=p(x);if(e&&!/[\r\n]/.test(e)){s(x),t.statusCode=302,t.setHeader(`Location`,`/${e}`),t.setHeader(`Cache-Control`,`no-store`),t.end();return}}if((n===`/`||n===``)&&(e.url=`/index.html`),!(n?.startsWith(`/api/`)&&Vi(e,t))){if(n===`/api/config`&&e.method===`DELETE`){s(x),t.setHeader(`Cache-Control`,`no-store`),t.statusCode=204,t.end();return}if(n===`/api/config`&&(e.method===`GET`||e.method===`HEAD`)){ee?.();let n=m(x),r=e.headers.host??`localhost:${D}`,i=n&&n.port>0?`ws://${r}/collab`:null,a=p(x),o=JSON.stringify({collabUrl:i,previewUrl:null,port:D,paneTarget:a});t.setHeader(`Content-Type`,`application/json`),t.setHeader(`Cache-Control`,`no-store`),t.setHeader(`X-Content-Type-Options`,`nosniff`),t.statusCode=200,e.method===`HEAD`?t.end():t.end(o);return}if(n?.startsWith(`/api/`)){ee?.();let r=m(x);if(!r||r.port<=0){zi(t,503,`urn:ok:error:collab-server-not-running`,"Collab server not running. Start `ok start` or run `ok status`.",`Path: ${n}`);return}qi(e,t,{upstreamHost:d,upstreamPort:r.port});return}if(T&&n?.startsWith(`/assets/`)){T(e,t,()=>{E?E(e,t,()=>$i(t)):$i(t)});return}if(E){E(e,t,()=>{T?T(e,t):$i(t)});return}if(T){T(e,t);return}$i(t)}},k=new Set,te=(e,t,n)=>{if(Ui(e,t))return;let r=e.url?.split(`?`)[0]??``;if(r!==`/collab`&&!r.startsWith(`/collab/`)){t.destroy();return}let i=m(x);if(!i||i.port<=0){console.warn(JSON.stringify({event:`ok-ui-upgrade-no-collab-lock`,url:r,reason:"server.lock missing or port unbound — is `ok start` running?"})),t.destroy();return}Wi(e,t,n,d,i.port,k)},ne=()=>{for(let e of k)try{e.destroy()}catch{}k.clear()},re=e.host===void 0?[`::1`,`127.0.0.1`]:[e.host],A=[],ie=e.port,ae=e=>e instanceof Error&&e.code===`EADDRINUSE`,oe=async()=>{await Promise.all(A.splice(0).map(e=>new Promise(t=>{try{e.close(()=>t())}catch{t()}})))},se=async e=>{ie=e;for(let e of re){let t=n(O);t.on(`upgrade`,te),A.push(t),await new Promise((n,r)=>{let i=e=>r(e);t.once(`error`,i),t.listen(ie,e,()=>{t.off(`error`,i);let e=t.address();typeof e==`object`&&e&&(ie=e.port),n()})})}};try{try{await se(e.port)}catch(t){if(e.fallbackToKernel===!0&&ae(t))await oe(),await se(0);else throw t}}catch(e){await oe();try{h(x)}catch{}throw e}let ce=ie;D=ce,g(x,ce);let j=e.scheduler??c,M=e.safetyNetMs??432e5,N=null,P=!1,F=!1,le=()=>{P||(P=!0,N!==null&&(j.clearTimeout(N),N=null))},I=()=>{if(le(),!F){F=!0;try{h(x)}catch{}}},ue=()=>{P||M<=0||(N!==null&&(j.clearTimeout(N),N=null),N=j.setTimeout(()=>{N=null,console.warn(`[ui] safety-net (${M}ms) reached — shutting down (D-025 backstop)`);try{e.onSafetyNet?.()}catch{}ne();for(let e of A)try{e.close()}catch{}I()},M))},L=()=>{P||M<=0||ue()};return ee=L,ue(),{httpServers:A,port:ce,release:I,detachSafetyNet:le,nudgeSafetyNet:L,drainUpgradeSockets:ne}}function $i(e){e.headersSent||e.writableEnded||e.destroyed||(e.setHeader(`X-Content-Type-Options`,`nosniff`),e.setHeader(`Cache-Control`,`no-store`),e.statusCode=404,e.end())}function ea(e,t){if(e!==void 0){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<0||t>65535)throw Error(`Invalid --port value '${e}'`);return{port:t,fallbackToKernel:!1}}if(t!==void 0&&t!==``){let e=Number.parseInt(t,10);if(Number.isNaN(e)||e<0||e>65535)throw Error(`Invalid PORT env value '${t}'`);return{port:e,fallbackToKernel:!1}}return{port:Yi,fallbackToKernel:!0}}async function ta(e){let t=e.readLock??(async()=>{let{readUiLock:t}=await import(`./dist-BSd2Ezzl.mjs`);return t(e.lockDir)}),n=await t();if(!n)throw Error(`UI lock collision reported but the lock disappeared before handling — retry acquiring.`);if(n.port===e.requestedPort&&n.port>0)return{mode:`already-running`,port:n.port};let r=n.port;if(r===0){let n=Date.now()+(e.pollDeadlineMs??2e3),i=e.pollIntervalMs??100;for(;Date.now()<n;){await new Promise(e=>{setTimeout(e,i)});let e=await t();if(e&&e.port>0){r=e.port;break}}if(r===0)throw Error("UI did not bind within 2s; run `ok clean`");if(r===e.requestedPort)return{mode:`already-running`,port:r}}return{mode:`proxy`,handle:await Ki({listenPort:e.requestedPort,host:e.host,upstreamHost:`localhost`,upstreamPort:r}),upstreamPort:r}}function na(e){return new k(`ui`).description(`Serve the OpenKnowledge React editor UI`).option(`-p, --port <port>`,`UI port (default: $PORT env or ${Yi}, kernel-allocated fallback if busy)`).option(`-H, --host <host>`,"UI host. Default: two-socket loopback bind (`[::1]` + `127.0.0.1`) so cross-family collisions fail loud. Pass an explicit host (e.g. `127.0.0.1`, `0.0.0.0`) to bind a single socket on that host.").action(async t=>{let{dim:n}=await import(`./colors-CmkIIbww.mjs`),{UiLockCollisionError:r}=await import(`./dist-BSd2Ezzl.mjs`),{resolveLockDir:i}=await import(`./dist-BSd2Ezzl.mjs`),a=e(),o=t.host,s;try{s=ea(t.port,process.env.PORT)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1;return}let c=s.port;try{let e=await Qi({config:a,cwd:process.cwd(),port:c,fallbackToKernel:s.fallbackToKernel,host:o}),t=o===void 0||o===`::`||o===`0.0.0.0`?`localhost`:o;console.log(`${n(`[ui]`)} listening on http://${t}:${e.port}`);let r=!1,i=t=>{if(r)return;r=!0,console.log(n(`\n[ui] Shutting down (${t})`)),e.detachSafetyNet();let i=()=>{try{e.release()}finally{process.exit(process.exitCode??0)}};e.drainUpgradeSockets(),Zi(e.httpServers).then(i,i),setTimeout(i,2e3).unref()};process.once(`SIGINT`,()=>i(`SIGINT`)),process.once(`SIGTERM`,()=>i(`SIGTERM`));return}catch(e){if(!(e instanceof r))throw e;let t=i(process.cwd()),a=o??`localhost`,s;try{s=await ta({requestedPort:c,host:a,lockDir:t})}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}if(s.mode===`already-running`){if(console.log(`UI already running at http://${a}:${s.port}`),ra(process)){await new Promise(e=>{let t=t=>{console.log(n(`\n[ui-keepalive] Shutting down (${t})`)),e()};process.once(`SIGINT`,()=>t(`SIGINT`)),process.once(`SIGTERM`,()=>t(`SIGTERM`))});return}process.exit(0)}console.log(`UI running at http://${a}:${s.upstreamPort}; acting as HTTP proxy on port ${s.handle.port}`);let l=!1,u=e=>{l||(l=!0,console.log(n(`\n[ui-proxy] Shutting down (${e})`)),s.handle.close().finally(()=>process.exit(process.exitCode??0)),setTimeout(()=>process.exit(process.exitCode??0),2e3).unref())};process.once(`SIGINT`,()=>u(`SIGINT`)),process.once(`SIGTERM`,()=>u(`SIGTERM`))}})}function ra(e){let t=e.stdout.isTTY===!0,n=typeof e.env.PORT==`string`&&e.env.PORT!==``;return!t||n}const ia={allowTrailingComma:!0,disallowComments:!1};function aa(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function oa(e){let t=[],n=pr(e,t,ia);return t.some(t=>!aa(t,e))||!n||n.type!==`object`?null:n}function sa(e,t){let n=0;for(let r of e.children??[]){let e=r.children?.[0];e!==void 0&&mr(e)===t&&(n+=1)}return n}function ca(e,t){S(e,`${JSON.stringify(t,null,2)}\n`)}function la(e,t){let n=mi(t);S(e,n.endsWith(`
|
|
631
|
+
`)}\r\n\r\n`),n.length>0&&o.write(n)}catch(e){c({event:`proxy-upgrade-handshake-write-failed`,err:e});return}o.on(`data`,e=>{t.writable&&t.write(e)}),t.on(`data`,e=>{o.writable&&o.write(e)})}),o.once(`timeout`,()=>{c({event:`proxy-upgrade-upstream-connect-timeout`})}),o.on(`error`,e=>c({event:`proxy-upgrade-upstream-error`,err:e})),t.on(`error`,e=>c({event:`proxy-upgrade-client-error`,err:e})),o.once(`close`,()=>c()),t.once(`close`,()=>c())}const Gi=[`connection`,`keep-alive`,`proxy-authenticate`,`proxy-authorization`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`cookie`,`set-cookie`];async function Ki(e){let t=e.upstreamTimeoutMs??Bi,n=new Set,r=je((n,r)=>{Vi(n,r)||Ji(n,r,e.upstreamHost,e.upstreamPort,t)});r.on(`upgrade`,(t,r,i)=>{Ui(t,r)||Wi(t,r,i,e.upstreamHost,e.upstreamPort,n)}),await new Promise((t,n)=>{let i=e=>n(e);r.once(`error`,i),r.listen(e.listenPort,e.host,()=>{r.off(`error`,i),t()})});let i=r.address();return{httpServer:r,port:typeof i==`object`&&i?i.port:e.listenPort,close:()=>new Promise(e=>{for(let e of n)try{e.destroy()}catch{}n.clear(),r.close(()=>e()),r.closeIdleConnections()})}}function qi(e,t,n){Ji(e,t,n.upstreamHost,n.upstreamPort,n.upstreamTimeoutMs??Bi)}function Ji(e,t,n,r,i){let a={...e.headers};delete a.host;for(let e of Gi)delete a[e];e.setTimeout(Hi,()=>{if(t.headersSent)try{t.end()}catch{}else try{zi(t,408,`urn:ok:error:request-timeout`,`Proxy request exceeded the per-request deadline.`,`Slow-loris-class: client did not finish within ${Hi/1e3}s.`)}catch{}try{e.socket?.destroy()}catch{}});let o=Me({host:n,port:r,method:e.method,path:e.url,headers:{...a,host:`${n}:${r}`}},e=>{let n={...e.headers};for(let e of Gi)delete n[e];t.writeHead(e.statusCode??502,n),e.pipe(t),e.once(`error`,()=>{try{t.end()}catch{}})});i>0&&o.setTimeout(i,()=>{if(!t.headersSent)zi(t,504,`urn:ok:error:gateway-timeout`,`Upstream did not respond before the gateway deadline.`,`Upstream timeout: ${i/1e3}s elapsed without a response.`);else try{t.end()}catch{}o.destroy()}),o.on(`error`,()=>{if(!t.headersSent)zi(t,502,`urn:ok:error:collab-server-not-running`,`Collab server is unreachable.`,`Upstream connection failed or dropped before a response was received.`);else try{t.end()}catch{}}),e.on(`error`,()=>{o.destroy()}),e.pipe(o)}const Yi=39847,Xi=39848;async function Zi(e){await Promise.all(e.map(e=>new Promise(t=>{e.close(()=>t())})))}async function Qi(e){let{existsSync:t}=await import(`node:fs`),{createServer:n}=await import(`node:http`),{resolve:i}=await import(`node:path`),{acquireUiLock:a,clearArmedPaneTarget:s,createAssetServeMiddleware:l,createContentFilter:f,readArmedPaneTarget:p,readServerLock:m,releaseUiLock:h,updateUiLockPort:g}=await import(`./dist-Cj2f9yMz.mjs`),{default:_}=await import(`./build-gfyDk62R.mjs`),{resolveContentDir:v,resolveLockDir:y}=await import(`./dist-Cj2f9yMz.mjs`),b=v(e.config,e.cwd),x=y(e.cwd);a(x,{port:0,worktreeRoot:e.cwd});let S=import.meta.dirname??new URL(`.`,import.meta.url).pathname,C=[i(S,`public`),i(S,`../../app/dist`),i(S,`../../../app/dist`)],w=e.assetDir??C.find(e=>t(e)),T=w?_(w,{single:!0,gzip:!0,etag:!0,dev:!0,extensions:[]}):null,E=t(b)?l({contentFilter:f({projectDir:e.cwd,contentDir:b}),contentSirv:_(b,{dotfiles:!1,dev:!0,extensions:[]}),inlineExtensions:o,assetExtensions:u,blocklistExtensions:r}):null,D=e.port,ee=null,O=(e,t)=>{let n=e.url?.split(`?`)[0];if(e.method===`GET`&&(n===`/`||n===``)){let e=p(x);if(e&&!/[\r\n]/.test(e)){s(x),t.statusCode=302,t.setHeader(`Location`,`/${e}`),t.setHeader(`Cache-Control`,`no-store`),t.end();return}}if((n===`/`||n===``)&&(e.url=`/index.html`),!(n?.startsWith(`/api/`)&&Vi(e,t))){if(n===`/api/config`&&e.method===`DELETE`){s(x),t.setHeader(`Cache-Control`,`no-store`),t.statusCode=204,t.end();return}if(n===`/api/config`&&(e.method===`GET`||e.method===`HEAD`)){ee?.();let n=m(x),r=e.headers.host??`localhost:${D}`,i=n&&n.port>0?`ws://${r}/collab`:null,a=p(x),o=JSON.stringify({collabUrl:i,previewUrl:null,port:D,paneTarget:a});t.setHeader(`Content-Type`,`application/json`),t.setHeader(`Cache-Control`,`no-store`),t.setHeader(`X-Content-Type-Options`,`nosniff`),t.statusCode=200,e.method===`HEAD`?t.end():t.end(o);return}if(n?.startsWith(`/api/`)){ee?.();let r=m(x);if(!r||r.port<=0){zi(t,503,`urn:ok:error:collab-server-not-running`,"Collab server not running. Start `ok start` or run `ok status`.",`Path: ${n}`);return}qi(e,t,{upstreamHost:d,upstreamPort:r.port});return}if(T&&n?.startsWith(`/assets/`)){T(e,t,()=>{E?E(e,t,()=>$i(t)):$i(t)});return}if(E){E(e,t,()=>{T?T(e,t):$i(t)});return}if(T){T(e,t);return}$i(t)}},k=new Set,te=(e,t,n)=>{if(Ui(e,t))return;let r=e.url?.split(`?`)[0]??``;if(r!==`/collab`&&!r.startsWith(`/collab/`)){t.destroy();return}let i=m(x);if(!i||i.port<=0){console.warn(JSON.stringify({event:`ok-ui-upgrade-no-collab-lock`,url:r,reason:"server.lock missing or port unbound — is `ok start` running?"})),t.destroy();return}Wi(e,t,n,d,i.port,k)},ne=()=>{for(let e of k)try{e.destroy()}catch{}k.clear()},re=e.host===void 0?[`::1`,`127.0.0.1`]:[e.host],A=[],ie=e.port,ae=e=>e instanceof Error&&e.code===`EADDRINUSE`,oe=async()=>{await Promise.all(A.splice(0).map(e=>new Promise(t=>{try{e.close(()=>t())}catch{t()}})))},se=async e=>{ie=e;for(let e of re){let t=n(O);t.on(`upgrade`,te),A.push(t),await new Promise((n,r)=>{let i=e=>r(e);t.once(`error`,i),t.listen(ie,e,()=>{t.off(`error`,i);let e=t.address();typeof e==`object`&&e&&(ie=e.port),n()})})}};try{try{await se(e.port)}catch(t){if(e.fallbackToKernel===!0&&ae(t))await oe(),await se(0);else throw t}}catch(e){await oe();try{h(x)}catch{}throw e}let ce=ie;D=ce,g(x,ce);let j=e.scheduler??c,M=e.safetyNetMs??432e5,N=null,P=!1,F=!1,le=()=>{P||(P=!0,N!==null&&(j.clearTimeout(N),N=null))},I=()=>{if(le(),!F){F=!0;try{h(x)}catch{}}},ue=()=>{P||M<=0||(N!==null&&(j.clearTimeout(N),N=null),N=j.setTimeout(()=>{N=null,console.warn(`[ui] safety-net (${M}ms) reached — shutting down (D-025 backstop)`);try{e.onSafetyNet?.()}catch{}ne();for(let e of A)try{e.close()}catch{}I()},M))},L=()=>{P||M<=0||ue()};return ee=L,ue(),{httpServers:A,port:ce,release:I,detachSafetyNet:le,nudgeSafetyNet:L,drainUpgradeSockets:ne}}function $i(e){e.headersSent||e.writableEnded||e.destroyed||(e.setHeader(`X-Content-Type-Options`,`nosniff`),e.setHeader(`Cache-Control`,`no-store`),e.statusCode=404,e.end())}function ea(e,t){if(e!==void 0){let t=Number.parseInt(e,10);if(Number.isNaN(t)||t<0||t>65535)throw Error(`Invalid --port value '${e}'`);return{port:t,fallbackToKernel:!1}}if(t!==void 0&&t!==``){let e=Number.parseInt(t,10);if(Number.isNaN(e)||e<0||e>65535)throw Error(`Invalid PORT env value '${t}'`);return{port:e,fallbackToKernel:!1}}return{port:Yi,fallbackToKernel:!0}}async function ta(e){let t=e.readLock??(async()=>{let{readUiLock:t}=await import(`./dist-Cj2f9yMz.mjs`);return t(e.lockDir)}),n=await t();if(!n)throw Error(`UI lock collision reported but the lock disappeared before handling — retry acquiring.`);if(n.port===e.requestedPort&&n.port>0)return{mode:`already-running`,port:n.port};let r=n.port;if(r===0){let n=Date.now()+(e.pollDeadlineMs??2e3),i=e.pollIntervalMs??100;for(;Date.now()<n;){await new Promise(e=>{setTimeout(e,i)});let e=await t();if(e&&e.port>0){r=e.port;break}}if(r===0)throw Error("UI did not bind within 2s; run `ok clean`");if(r===e.requestedPort)return{mode:`already-running`,port:r}}return{mode:`proxy`,handle:await Ki({listenPort:e.requestedPort,host:e.host,upstreamHost:`localhost`,upstreamPort:r}),upstreamPort:r}}function na(e){return new k(`ui`).description(`Serve the OpenKnowledge React editor UI`).option(`-p, --port <port>`,`UI port (default: $PORT env or ${Yi}, kernel-allocated fallback if busy)`).option(`-H, --host <host>`,"UI host. Default: two-socket loopback bind (`[::1]` + `127.0.0.1`) so cross-family collisions fail loud. Pass an explicit host (e.g. `127.0.0.1`, `0.0.0.0`) to bind a single socket on that host.").action(async t=>{let{dim:n}=await import(`./colors-CmkIIbww.mjs`),{UiLockCollisionError:r}=await import(`./dist-Cj2f9yMz.mjs`),{resolveLockDir:i}=await import(`./dist-Cj2f9yMz.mjs`),a=e(),o=t.host,s;try{s=ea(t.port,process.env.PORT)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1;return}let c=s.port;try{let e=await Qi({config:a,cwd:process.cwd(),port:c,fallbackToKernel:s.fallbackToKernel,host:o}),t=o===void 0||o===`::`||o===`0.0.0.0`?`localhost`:o;console.log(`${n(`[ui]`)} listening on http://${t}:${e.port}`);let r=!1,i=t=>{if(r)return;r=!0,console.log(n(`\n[ui] Shutting down (${t})`)),e.detachSafetyNet();let i=()=>{try{e.release()}finally{process.exit(process.exitCode??0)}};e.drainUpgradeSockets(),Zi(e.httpServers).then(i,i),setTimeout(i,2e3).unref()};process.once(`SIGINT`,()=>i(`SIGINT`)),process.once(`SIGTERM`,()=>i(`SIGTERM`));return}catch(e){if(!(e instanceof r))throw e;let t=i(process.cwd()),a=o??`localhost`,s;try{s=await ta({requestedPort:c,host:a,lockDir:t})}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}if(s.mode===`already-running`){if(console.log(`UI already running at http://${a}:${s.port}`),ra(process)){await new Promise(e=>{let t=t=>{console.log(n(`\n[ui-keepalive] Shutting down (${t})`)),e()};process.once(`SIGINT`,()=>t(`SIGINT`)),process.once(`SIGTERM`,()=>t(`SIGTERM`))});return}process.exit(0)}console.log(`UI running at http://${a}:${s.upstreamPort}; acting as HTTP proxy on port ${s.handle.port}`);let l=!1,u=e=>{l||(l=!0,console.log(n(`\n[ui-proxy] Shutting down (${e})`)),s.handle.close().finally(()=>process.exit(process.exitCode??0)),setTimeout(()=>process.exit(process.exitCode??0),2e3).unref())};process.once(`SIGINT`,()=>u(`SIGINT`)),process.once(`SIGTERM`,()=>u(`SIGTERM`))}})}function ra(e){let t=e.stdout.isTTY===!0,n=typeof e.env.PORT==`string`&&e.env.PORT!==``;return!t||n}const ia={allowTrailingComma:!0,disallowComments:!1};function aa(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function oa(e){let t=[],n=pr(e,t,ia);return t.some(t=>!aa(t,e))||!n||n.type!==`object`?null:n}function sa(e,t){let n=0;for(let r of e.children??[]){let e=r.children?.[0];e!==void 0&&mr(e)===t&&(n+=1)}return n}function ca(e,t){S(e,`${JSON.stringify(t,null,2)}\n`)}function la(e,t){let n=mi(t);S(e,n.endsWith(`
|
|
632
632
|
`)?n:`${n}\n`)}const ua=10*1024*1024;function da(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((e,n)=>da(e,t[n]));if(P(e)&&P(t)){let n=Object.keys(e);return n.length===Object.keys(t).length?n.every(n=>Object.hasOwn(t,n)&&da(e[n],t[n])):!1}return!1}function fa(e){for(let t of e.split(`
|
|
633
633
|
`)){let e=t.trimStart();if(!(e.length===0||e.length===t.length))return t.charCodeAt(0)===9?{insertSpaces:!1,tabSize:1}:{insertSpaces:!0,tabSize:t.length-e.length}}return{insertSpaces:!0,tabSize:2}}function pa(e,t,n){return t===void 0?[e,n]:[e,t,n]}function ma(e,t,n,r){let i={[n]:r};return{[e]:t===void 0?i:{[t]:i}}}function ha(e,t,n){let r=e[t];return n===void 0?r:P(r)?r[n]:void 0}function ga(e,t,n,r,i){if(!U(e))return ca(e,ma(t,i,n,r)),{kind:`written`};let a;try{a=W(e,`utf-8`)}catch(e){return $(`json config read failed`,e),{kind:`declined`,reason:`unparseable`}}if(a.trim()===``)return ca(e,ma(t,i,n,r)),{kind:`written`};if(Buffer.byteLength(a,`utf-8`)>ua)return{kind:`declined`,reason:`oversize`};let o=oa(a);if(!o)return{kind:`declined`,reason:`unparseable`};if(sa(o,t)>1)return{kind:`declined`,reason:`duplicate-container`};let s=ha(mr(o),t,i),c=P(s)?s[n]:void 0,l=c!==void 0;if(l&&da(c,r))return{kind:`overwritten`};let u=a.charCodeAt(0)===65279,d=u?a.slice(1):a,f=d.includes(`\r
|
|
634
634
|
`)?`\r
|
|
@@ -655,6 +655,6 @@ UIPORT="\${PORT:-${Xi}}"
|
|
|
655
655
|
unset PORT
|
|
656
656
|
exec node "${N()}" start --ui-port "$UIPORT"`],port:Xi,autoPort:!0}:{name:ka,runtimeExecutable:`/bin/sh`,runtimeArgs:[`-l`,`-c`,Ma],port:Xi,autoPort:!0};try{if(j(n,e),!U(n))return xe(z(n),{recursive:!0}),Te(n,`${JSON.stringify({version:Oa,configurations:[r]},null,2)}\n`,`utf-8`),{action:`created`,configPath:n};let t=W(n,`utf-8`).trim(),i=t?JSON.parse(t):{};if(!P(i))return{action:`failed`,configPath:n,error:`launch.json root is not an object`};let a=Array.isArray(i.configurations)?i.configurations:[],o=a.findIndex(e=>P(e)&&e.name===`open-knowledge-ui`);o>=0?a[o]=r:a.push(r);let s={...i,version:i.version??Oa,configurations:a};return Te(n,`${JSON.stringify(s,null,2)}\n`,`utf-8`),{action:o>=0?`merged`:`created`,configPath:n}}catch(e){return{action:`failed`,configPath:n,error:e instanceof Error?e.message:String(e)}}}function Pa(e,t,n){try{return U(e.detectPath?.(t,n)??z(e.configPath(t,n)))}catch{return!1}}function Fa(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let s=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0;if(!i&&s&&!Pa(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{j(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return La(e,o,a,n,{isProjectScope:i!==void 0});let c;try{c=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{xe(z(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let l={action:`written`},u;try{D(`${o}.lock`,()=>{let t=Ai(o).writePath;if(xe(z(t),{recursive:!0}),e.format===`toml`){let n=_a(Ri(),t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}let n=ga(t,e.topLevelKey,a,c,e.serverMapSubKey);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){u=e instanceof Error?e:Error(String(e))}return u?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:u.message,...i===void 0?{}:{configScope:`project`}}:l.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:l.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:l.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const Ia={pi:yi};function La(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=Ia[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{xe(z(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{D(`${t}.lock`,()=>{let e=null;try{e=W(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}S(t,c,e===null?void 0:{mode:br(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}function Ra(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!U(n)))return{editorId:e.id,label:e.label,path:n}}async function za(e){let t=ne(e.editors).filter(e=>e.scope===`global`),n={mode:`published`,skipAvailabilityCheck:!0};return t.map(t=>Fa(t,``,n,e.home))}function Ba(e,t,n,r){let i=Ha(e,t,n,r);return i.kind===`present`?i.entry:null}function Va(e,t,n,r){let i=ha(e,t,r);if(!P(i))return{kind:`no-entry`};let a=i[n];return P(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Ha(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!U(i))return{kind:`absent`};try{if(we(i).size>ua)return{kind:`decline`,reason:`oversize`}}catch{return{kind:`decline`,reason:`unparseable`}}let a;try{a=W(i,`utf-8`)}catch{return{kind:`decline`,reason:`unparseable`}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:vi(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=Ri().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Va(t,e.topLevelKey,o,e.serverMapSubKey)}let s=oa(a);return s?sa(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Va(mr(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Ua(e={}){let t=ge(e.cwd??process.cwd()),n=Si(t,{homeDir:e.home}),r=n.projectRoot,i=!U(B(r,`.ok`)),a=n.gitRootPromoted?V(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:Ea(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${L(`[ok] Content scope promoted to the git repo root: ${r}`)}\n Ran in ${a}/, but .ok/ lives at the git root (one .ok/ per git repo),\n so the whole repo is now the content scope. To narrow it, re-run with\n \`ok init --content-dir .\`, or set content.dir: ${a} in .ok/config.yml.\n`);let s={mode:e.devMcp?`dev`:`published`},c=await ee(r),l;try{l=h(r,{contentDir:o})}catch(t){let i=M.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:c.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let u=l.created.includes(te),d=!1;if(c.didInit)try{d=C(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}let f=await xa({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),p=e.editors??Ya(r,e.home),m=e.editors??oe.filter(e=>M[e].projectConfigPath!==void 0),g=ne(p),_=ne(m),v=e.mcp===!1||f===null,b=Array.from(new Map([...g,...v?[]:_].map(e=>[e.id,e])).values()),S=g.filter(t=>Pa(t,r,e.home)),w=[],D=[],O=new Set;for(let t of b){if(v){let n=``;try{n=t.configPath(r,e.home)}catch{}w.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(va(f)&&g.includes(t)&&t.scope===`global`&&w.push(Fa(t,r,s,e.home)),ya(f)&&_.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=Fa(t,r,s,e.home,n);w.push(i),(i.action===`written`||i.action===`overwritten`)&&O.add(n)}}let k=new Set;for(let e of _){let t=e.projectSkillPath?.(r);!t||k.has(t)||(k.add(t),D.push(ce(e,r)))}let re=!v&&f!==null&&ya(f)?_.filter(e=>!e.projectConfigPath).map(e=>e.label):void 0,A=v?[]:S.map(e=>Ra(e,r)).filter(e=>e!==void 0).filter(e=>!O.has(e.path)),ae=S.some(e=>e.id===`claude`)&&!v?Na(r,s):void 0,se=e.installUserSkill??y,j=e.home??ye(),N=Ta(e.skills),P=!1,F=!1,le=!1,I=!1;for(let t of E){let n=N.has(t);if(await T(j,x[t],n).catch(()=>{}),n){P=!0;let n=await se({home:e.home,bundleId:t,force:!0});n===`installed`?F=!0:n===`failed`?le=!0:I=!0}else try{ie(j,t)}catch{}}let ue=le?`failed`:F?`installed`:P&&I?`skip-current`:`declined`,R=v?`skipped-flag`:`skipped-missing`,de=w.find(e=>e.editorId===`claude`)??w[0]??{action:R,configPath:M.claude.configPath(r,e.home)},fe=await Wa({projectRoot:r,desiredMode:await Ca({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:l.created,contentUpdated:l.updated,contentSkipped:l.skipped,editors:w,projectSkills:D,legacyProjectConfigs:A,launchJson:ae,skillInstall:ue,didGitInit:c.didInit,rootGitignoreCreated:d,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:u?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:de.action,mcpPath:de.configPath,mcpError:`error`in de?de.error:void 0,projectScopeUnsupportedLabels:re,sharing:fe}}async function Wa(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=kn(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=En(t);if(n===`local-only`){let e=Dn(t,a);if(e.kind===`refused-tracked`){let t=e;return{kind:`refused-tracked`,tracked:t.tracked,remediation:t.remediation}}return e.kind===`no-exclude`?{kind:`no-exclude`,reason:e.reason,localOnlyRequested:r===`local-only`}:Ga(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=On(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Ga(t,o,`remove`)}function Ga(e,t,n){let r=kn(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:[]}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function Ka(e){switch(e){case`oversize`:return`config too large to edit safely`;case`duplicate-container`:return`duplicate server block`;case`no-native-writer`:return`no format-preserving writer available`;default:return`config not readable`}}function qa(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`),s=e=>{let n=e.configPath.startsWith(t)?V(t,e.configPath):e.configPath;switch(e.action){case`created`:return` app preview server ${n} configured for Claude Code Desktop embedded browser`;case`merged`:return` app preview server ${n} updated for Claude Code Desktop embedded browser`;case`failed`:return` app preview server ${n} FAILED: ${e.error}`}};e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let c=B(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(R(`Content scaffolded at ${c}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(R(`Content already present at ${c}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0)if(n.push(R(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`);else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(R(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(R(`MCP server configuration:`));for(let r of e.editors){let i=r.configPath.startsWith(t)?V(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),a=r.serverName===`open-knowledge`?``:` (${r.serverName})`,o=r.configScope===`project`?` (project)`:``,c=`${r.label}${o}`,l=` `.repeat(Math.max(1,20-c.length)),u=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${c}${l}${i} ${I(`registered`)}${a}${u}`);break;case`overwritten`:n.push(` ${c}${l}${i} ${I(`updated`)}${a}${u}`);break;case`skipped-missing`:n.push(` ${c}${l}${i} config root missing; skipped`);break;case`failed`:n.push(` ${c}${l}${i} ${ue(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${c}${l}${i} left unchanged (${Ka(r.declineReason)})`);break;case`skipped-flag`:break;default:r.action}r.editorId===`claude`&&e.launchJson&&n.push(s(e.launchJson))}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(e.projectSkills.length>0){n.push(``),n.push(R(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?V(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${I(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${I(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${ue(`FAILED`)}: ${r.error}`);break}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${V(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(R(`User-global skill:`)),e.skillInstall){case`installed`:n.push(` open-knowledge ${I(`installed to detected agent hosts`)} via \`npx skills\``);break;case`skip-current`:n.push(` open-knowledge ${I(`already installed at current version`)}`);break;case`declined`:n.push(` open-knowledge ${le(`skipped (opted out via --no-skills)`)}`);break;case`failed`:n.push(` ${L(`open-knowledge install failed — MCP still configured; run manually:`)}`),n.push(` ${L(` npx skills@~1.5.0 add <bundled-path> --agent '*' -g -y --copy`)}`);break}if(e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(L(`⚠ --content-dir ${e.contentDirRequested} ignored — .ok/config.yml already exists`)),n.push(` Edit .ok/config.yml → content.dir directly to change the content scope.`)):e.contentDir!==void 0&&e.contentDir!==`.`?(n.push(``),n.push(`Content scope set to ${e.contentDir}/ (content.dir in .ok/config.yml).`)):e.gitRootPromoted&&e.contentDir===`.`&&e.contentDirRequested===void 0&&(n.push(``),n.push(L(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`ok init\` in${e.promotedFromDir?` (${e.promotedFromDir})`:``}. The whole repo is now the content scope.`),e.promotedFromDir&&(n.push(" To scope to just that sub-folder, re-run `ok init --content-dir .` from there, or set"),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(de(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...Qa(e.sharing,t)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${I(`✓`)} ${R(`Next steps:`)}`),n.push(` 1. Open your editor (${F(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${F(`ok seed`)} — empty repo, Karpathy 3-layer`),n.push(` - ${F(`mcp__open-knowledge__discover`)} — existing repo, extract conventions`),n.push(` 4. Use the MCP workflow tools as you build the wiki:`),n.push(` - ${F(`mcp__open-knowledge__ingest`)} — capture an external source`),n.push(` - ${F(`mcp__open-knowledge__research`)} — gather sources and write findings`),n.push(` - ${F(`mcp__open-knowledge__consolidate`)} — promote research to canonical articles`)}return n.join(`
|
|
657
657
|
`)}function Ja(e,t){return{projectRoot:e.projectRoot,gitRootPromoted:e.gitRootPromoted,promotedFromDir:e.promotedFromDir??null,contentDir:t.contentDir,contentDirRequested:e.contentDirRequested??null,contentDirApplied:e.contentDir!==void 0,contentFileCount:t.contentFileCount,previewError:e.previewWarning??null,didGitInit:e.didGitInit,mcpAction:e.mcpAction,editors:e.editors.map(e=>({editorId:e.editorId,label:e.label,action:e.action,configPath:e.configPath,scope:e.configScope===`project`?`project`:`user`}))}}function Ya(e,t){let n=[];for(let r of oe)Pa(M[r],e,t)&&n.push(r);return n}function Xa(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:De(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function Za(){return new k(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).option(`--content-dir <dir>`,`Limit content to <dir> instead of the whole project. <dir> is interpreted relative to your current directory (e.g. "." = the folder you run the command in), then saved to .ok/config.yml as content.dir.`).option(`--json`,`Emit a structured JSON summary to stdout (diagnostics stay on stderr)`).option(`--skills <ids>`,`Install only the named user-global skill bundles (comma list: discovery,write-skill)`).option(`--no-skills`,`Do not install any user-global skill bundles`).addOption(new O(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new O(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new O(`--local-only`,`Keep OK config out of git via .git/info/exclude (per-clone, not committed)`).conflicts(`shared`)).action(async e=>{let t=process.cwd(),n=e.shared?`shared`:e.localOnly?`local-only`:void 0,r=e.json?Xa():null;try{let r;try{r=await Ua({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof wa){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof m||e instanceof _){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof g){process.stderr.write(`open-knowledge could not initialize a git repo for this project. Re-run, or run 'git init' yourself in the project folder.
|
|
658
|
-
`),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-
|
|
658
|
+
`),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-Dnu5tSEp.mjs`),{resolveContentDir:s}=await import(`./dist-Cj2f9yMz.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-B5POtWPo.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(Ja(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${qa(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function Qa(e,t){let n=[];switch(e.kind){case`applied`:return n.push(R(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?n.push(` ${I(`local-only`)} — appended ${e.appended.length} path(s) to ${R(`${t}/.git/info/exclude`)} (per-clone, not committed).`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${I(`local-only`)} — already excluded; nothing to do.`):n.push(` ${I(`local-only`)}`):e.action===`removed`?n.push(` ${I(`shared`)} — removed OK paths from ${R(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${I(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(L(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
|
|
659
659
|
`))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${F(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(L(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${F(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${F(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(L(`Sharing mode unavailable: ${e.reason}.`));return n}}export{yr as A,On as B,za as C,_i as D,Si as E,Mn as F,gt as G,fn as H,An as I,q as K,En as L,mr as M,pr as N,kr as O,Dn as P,jn as R,Fa as S,Ri as T,bt as U,Tn as V,_t as W,Ea as _,Ma as a,Na as b,Ja as c,qa as d,Qa as f,xa as g,Ta as h,ja as i,xr as j,br as k,Ha as l,Ba as m,ka as n,Ia as o,Za as p,Ue as q,Aa as r,Wa as s,wa as t,Ya as u,Ca as v,na as w,pa as x,Ua as y,kn as z};
|
|
660
|
-
//# sourceMappingURL=init-
|
|
660
|
+
//# sourceMappingURL=init-CylIL2_d.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y as e}from"./init-CylIL2_d.mjs";export{e as runInit};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Go as e,Xa as t,Za as n,eo as r}from"./server-lock-iLcBw_q0-D_cD26E0.mjs";import{_ as i,_a as a,ga as o}from"./dist-
|
|
1
|
+
import{Go as e,Xa as t,Za as n,eo as r}from"./server-lock-iLcBw_q0-D_cD26E0.mjs";import{_ as i,_a as a,ga as o}from"./dist-Dzsbf2ES.mjs";import{t as s}from"./constants-DQ9gCjtp.mjs";import{t as c}from"./is-object-Cg453afR.mjs";import{resolve as l}from"node:path";import{existsSync as u,readFileSync as d}from"node:fs";import{realpath as f}from"node:fs/promises";async function p(e){let t=l(e);try{return await f(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}var m=e();function h(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];c(a)&&c(i)?n[r]=h(i,a):a!==void 0&&(n[r]=a)}return n}function g(e){if(!u(e))return{value:null,path:e,source:null,doc:null};let t;try{t=d(e,`utf-8`)}catch(t){return console.warn(`[config] Failed to read ${e}: ${t instanceof Error?t.message:t}`),{value:null,path:e,source:null,doc:null}}let n=(0,m.parseDocument)(t);if(n.errors.length>0)return console.warn(`[config] Failed to parse ${e}: ${n.errors.map(e=>e.message).join(`; `)}`),{value:null,path:e,source:t,doc:null};let r=n.toJSON();return c(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function _(e,t){return e.map(e=>{let n=e.path.map(e=>typeof e==`symbol`?String(e):e),i={path:n,message:e.message,issueCode:e.code};if(t.doc!==null&&t.source!==null){let e=r({file:t.path,source:t.source,doc:t.doc,path:n});if(e!==void 0)return{...i,source:e}}return i})}function v(e){let r=e??process.cwd(),c=[],u=a(`user`,r),d=o({absPath:u}),f={};d.valid&&d.source!==void 0?(f=h(f,d.value),c.push(u)):d.valid;let p=l(r,`.ok`,s),m=g(p);if(m.value!==null){let e=t({value:m.value,file:m.path,source:m.source,doc:m.doc});if(e.length>0)throw Error(e.map(n).join(`
|
|
2
2
|
|
|
3
3
|
`));f=h(f,m.value),c.push(p)}let v=i.safeParse(f);if(!v.success){let e={code:`SCHEMA_INVALID`,issues:_(v.error.issues,m)};throw Error(n(e))}return{config:v.data,sources:c}}function y(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??v,r=new Map,i=new Map,a=p(e.startupCwd);return async o=>{let s=await p(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{v as n,y as t};
|
|
4
|
-
//# sourceMappingURL=loader-
|
|
4
|
+
//# sourceMappingURL=loader-DL7cugZT.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./loader-DL7cugZT.mjs";export{e as loadConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./preview-Bn8zUTY3.mjs";export{t as formatPreviewBlock,e as previewContent};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{Yt as e}from"./dist-
|
|
1
|
+
import{Yt as e}from"./dist-Dzsbf2ES.mjs";import"./constants-DQ9gCjtp.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);return a.push(``),r(t(i,`.ok`,`config.yml`))?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
|
|
2
2
|
`)}export{c as n,l as t};
|
|
3
|
-
//# sourceMappingURL=preview-
|
|
3
|
+
//# sourceMappingURL=preview-Bn8zUTY3.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as e,r as t}from"./init-
|
|
2
|
-
//# sourceMappingURL=repair-launch-json-
|
|
1
|
+
import{b as e,r as t}from"./init-CylIL2_d.mjs";import{t as n}from"./is-object-Cg453afR.mjs";import{join as r}from"node:path";import{existsSync as i,readFileSync as a}from"node:fs";const o=[[`@inkeep/open-knowledge`,`ui`],[`-y`,`@inkeep/open-knowledge`,`ui`],t];function s(e){if(e.runtimeExecutable===`/bin/sh`&&Array.isArray(e.runtimeArgs)){let t=e.runtimeArgs[2];if(typeof t==`string`){if(t.includes(`# ok-ui-v1`))return`canonical`;if(/# ok-ui-v\d+/.test(t))return`legacy-bare`}return`preserved`}if(e.runtimeExecutable===`npx`&&Array.isArray(e.runtimeArgs)){for(let t of o)if(c(e.runtimeArgs,t))return`legacy-bare`}return`preserved`}function c(e,t){if(e.length!==t.length)return!1;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return!1;return!0}function l(t){let o=t.logger??u,c=r(t.projectDir,`.claude`,`launch.json`);if(t.reclaimDisableEnv===`1`)return o({event:`launch-json-repair-skipped`,reason:`reclaim-disabled`}),{outcome:{configPath:c,outcome:`skipped-reclaim-disabled`},repairedCount:0};if(!i(c))return{outcome:{configPath:c,outcome:`no-file`},repairedCount:0};let l;try{let e=a(c,`utf-8`).trim();l=e?JSON.parse(e):{}}catch(e){let t=e instanceof Error?e.message:String(e);return o({event:`launch-json-repair-read-failed`,configPath:c,error:t}),{outcome:{configPath:c,outcome:`read-failed`,error:t},repairedCount:0}}if(!n(l)){let e=`launch.json root is not an object`;return o({event:`launch-json-repair-read-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`read-failed`,error:e},repairedCount:0}}let d=l.configurations;if(!Array.isArray(d))return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let f=d.find(e=>n(e)&&e.name===`open-knowledge-ui`);if(!f)return{outcome:{configPath:c,outcome:`no-entry`},repairedCount:0};let p=s(f);if(p===`canonical`)return{outcome:{configPath:c,outcome:`canonical`},repairedCount:0};if(p===`preserved`)return{outcome:{configPath:c,outcome:`preserved`},repairedCount:0};let m=e(t.projectDir,{mode:`published`});if(m.action===`failed`){let e=m.error??`unknown write failure`;return o({event:`launch-json-repair-write-failed`,configPath:c,error:e}),{outcome:{configPath:c,outcome:`write-failed`,error:e},repairedCount:0}}return o({event:`launch-json-repair-applied`,configPath:c}),{outcome:{configPath:c,outcome:`repaired`},repairedCount:1}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{l as repairLaunchJson};
|
|
2
|
+
//# sourceMappingURL=repair-launch-json-BkY5nlM0.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{S as e,m as t}from"./init-
|
|
2
|
-
//# sourceMappingURL=repair-mcp-configs-
|
|
1
|
+
import{S as e,m as t}from"./init-CylIL2_d.mjs";import{g as n,o as r,u as i}from"./write-project-skill-C7UNscN7.mjs";import{t as a}from"./mcp-migrate-event-D0NrGjvc.mjs";import{homedir as o}from"node:os";function s(e){let t=e.logger??u,n=e.home??o(),a=[];if(e.reclaimDisableEnv===`1`)return t({event:`mcp-config-repair-skipped`,reason:`reclaim-disabled`}),{outcomes:a,repairedCount:0};for(let o of r){let r=i[o],s=c(()=>r.configPath(``,n));if(s!==null&&a.push(l({scope:`user`,editorId:o,target:r,home:n,cwd:``,configPath:s,configPathOverride:void 0,logger:t})),r.projectConfigPath){let n=r.projectConfigPath,i=c(()=>n(e.projectDir));i!==null&&a.push(l({scope:`project`,editorId:o,target:r,home:void 0,cwd:e.projectDir,configPath:i,configPathOverride:i,logger:t}))}}return{outcomes:a,repairedCount:a.filter(e=>e.outcome===`repaired`).length}}function c(e){try{return e()}catch{return null}}function l(r){let i={scope:r.scope,editorId:r.editorId,configPath:r.configPath},o=t(r.target,r.cwd,r.home,r.configPathOverride);if(o===null)return{...i,outcome:`no-entry`};if(n(o))return{...i,outcome:`canonical`};r.logger(a({scope:r.scope,surface:`cli-repair`,editorId:r.editorId,configPath:r.configPath,priorEntry:o}));let s=e(r.target,r.cwd,{mode:`published`,skipAvailabilityCheck:!0},r.home,r.configPathOverride);if(s.action===`failed`){let e=s.error??`unknown write failure`;return r.logger({event:`mcp-config-repair-write-failed`,scope:r.scope,editorId:r.editorId,configPath:r.configPath,error:e}),{...i,outcome:`write-failed`,error:e}}return s.action===`declined`?(r.logger({event:`mcp-config-repair-declined`,scope:r.scope,editorId:r.editorId,configPath:r.configPath,reason:s.declineReason}),{...i,outcome:`declined`}):{...i,outcome:`repaired`}}function u(e){process.stderr.write(`${JSON.stringify(e)}\n`)}export{s as repairMcpConfigs};
|
|
2
|
+
//# sourceMappingURL=repair-mcp-configs-Cz6iXpxD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./repair-skills-DDLj2RIs.mjs";export{e as repairSkills};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{ua as e}from"./server-lock-iLcBw_q0-D_cD26E0.mjs";import{Jr as t,Lr as n,Wr as r,d as i,ei as a,ra as o,sa as s,ut as c,zr as l}from"./dist-
|
|
1
|
+
import{ua as e}from"./server-lock-iLcBw_q0-D_cD26E0.mjs";import{Jr as t,Lr as n,Wr as r,d as i,ei as a,ra as o,sa as s,ut as c,zr as l}from"./dist-Dzsbf2ES.mjs";import{t as u}from"./esm-CsQUg9js.mjs";import{d,i as f,t as p,u as m}from"./write-project-skill-C7UNscN7.mjs";import{dirname as h,join as g,resolve as _}from"node:path";import{homedir as v}from"node:os";import{existsSync as y,mkdirSync as b,readFileSync as x,readdirSync as S,rmSync as C,statSync as w,writeFileSync as T}from"node:fs";const E={existsSync:e=>y(e),isDirectory:e=>{try{return w(e).isDirectory()}catch(e){if(e.code===`ENOENT`)return!1;throw e}},readdirSync:e=>S(e),readFileSync:e=>x(e),writeFileSync:(e,t)=>{T(e,t)},mkdirSync:(e,t)=>{b(e,t)},rmSync:(e,t)=>{C(e,t)}},D={resolveProjectBundledSkillDir:()=>a(`project`,{checkDesktop:!1}),resolveUserBundledSkillDir:e=>a(e,{checkDesktop:!1}),readBundledVersion:()=>l(),readRecordedVersion:e=>r(e,`cli-hosts`),writeRecordedVersion:(e,t)=>s(e,`cli-hosts`,t,`cli-start`),recordEvent:e=>t(e),readBundleDecision:(e,t)=>n(e,t),writeBundleDecision:(e,t,n)=>o(e,t,n),removeBundleFromDisk:(e,t)=>f(e,t)};function O(e){process.stderr.write(`${JSON.stringify(e)}\n`)}function k(e,t,n){n.rmSync(t,{recursive:!0,force:!0}),n.mkdirSync(h(t),{recursive:!0}),A(e,t,n)}function A(e,t,n){n.mkdirSync(t,{recursive:!0});for(let r of n.readdirSync(e)){let i=g(e,r),a=g(t,r);n.isDirectory(i)?A(i,a,n):n.writeFileSync(a,n.readFileSync(i))}}function j(e,t,n,r,i,a){let o=[],s=g(e,`.agents`,`skills`,t),c=r.existsSync(s),l=!1;try{k(n,s,r),l=!0,o.push({kind:`central`,path:s,outcome:c?`overwritten`:`written`}),i({event:`user-skill-reclaim-central-written`,scope:`user`,path:s,preexisting:c,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`central`,path:s,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-central-failed`,scope:`user`,path:s,error:t})}for(let c of d){let l=g(e,c.hostDir),u=g(l,`skills`,t);if(u===s){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-collapsed-with-central`});continue}if(!r.existsSync(l)){o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`skipped-host-absent`});continue}let d=r.existsSync(u);try{k(n,u,r),o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:d?`overwritten`:`written`}),i({event:`user-skill-reclaim-host-written`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,preexisting:d,version:a})}catch(e){let t=e instanceof Error?e.message:String(e);o.push({kind:`host`,editorId:c.editorId,hostDir:c.hostDir,path:u,outcome:`failed`,error:t}),i({event:`user-skill-reclaim-host-failed`,scope:`user`,editorId:c.editorId,hostDir:c.hostDir,path:u,error:t})}}return{entries:o,centralWritten:l}}function M(e,t){if(!e)return!1;try{if(!t.existsSync(e))return!1;let n=t.readFileSync(e).toString(`utf8`);return n.includes(`# ok-mcp-v1`)||n.includes(`# ok-mcp-win-v1`)}catch{return!1}}function N(e,t,n,r){let i;try{i=t.resolveProjectBundledSkillDir()}catch(e){return r({event:`project-skill-reclaim-bundle-missing`,scope:`project`,error:e instanceof Error?e.message:String(e)}),{outcome:`skipped`,reason:`bundle-missing`}}let a=[];for(let t of d){let o=g(e,t.hostDir,`skills`,`open-knowledge`),s=g(o,`SKILL.md`),c=n.existsSync(s),l=m[t.editorId]?.projectConfigPath?.(e),u=!c&&M(l,n);if(!c&&!u){a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`no-token`}),r({event:`project-skill-reclaim-no-token`,scope:`project`,editorId:t.editorId,path:o});continue}try{p(o,e),k(i,o,n);let s=c?`reclaimed`:`created`;a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:s}),r({event:c?`project-skill-reclaim-reclaimed`:`project-skill-reclaim-created`,scope:`project`,editorId:t.editorId,path:o})}catch(e){let n=e instanceof Error?e.message:String(e);a.push({editorId:t.editorId,hostDir:t.hostDir,path:o,outcome:`failed`,error:n}),r({event:`project-skill-reclaim-failed`,scope:`project`,editorId:t.editorId,path:o,error:n})}}return{outcome:`done`,entries:a}}async function P(t,n,r,a){let o=e=>{n.recordEvent(e).catch(()=>{})},s=()=>new Date().toISOString(),l;try{l=await n.readBundledVersion()}catch(e){let t=e instanceof Error?e.message:String(e);return a({event:`user-skill-reclaim-version-read-failed`,scope:`user`,error:t}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:`discovery`,outcome:`failed`,reason:`version-read-failed:${t}`}),{outcome:`skipped`,reason:`version-read-failed`}}let u;try{u=await n.readRecordedVersion(t)}catch(e){a({event:`user-skill-reclaim-version-read-error`,scope:`user`,error:e instanceof Error?e.message:String(e)}),u=null}let d=[],f=null;for(let e of c)try{d.push({id:e,sourceDir:n.resolveUserBundledSkillDir(e)})}catch(e){f=e instanceof Error?e.message:String(e)}if(d.length===0)return a({event:`user-skill-reclaim-bundle-missing`,scope:`user`,error:f??`no user-global bundles`}),o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,reason:`bundle-missing:${f}`}),{outcome:`skipped`,reason:`bundle-missing`};let p=[];for(let o of d){let s=i[o.id],c=r.existsSync(g(t,`.agents`,`skills`,s)),l=await n.readBundleDecision(t,s).catch(()=>null);if(!e(l,{installedOnDisk:c})){if(c)try{n.removeBundleFromDisk(t,o.id),a({event:`user-skill-reclaim-bundle-declined-removed`,scope:`user`,bundle:o.id})}catch(e){a({event:`user-skill-reclaim-bundle-remove-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}continue}if(l===null&&c)try{await n.writeBundleDecision(t,s,!0)}catch(e){a({event:`user-skill-reclaim-grandfather-write-failed`,scope:`user`,bundle:o.id,error:e instanceof Error?e.message:String(e)})}p.push(o)}if(p.length===0)return{outcome:`skipped`,reason:`all-bundles-declined`};let m=p.every(e=>r.existsSync(g(t,`.agents`,`skills`,i[e.id])));if(u!==null&&u===l&&m)return a({event:`user-skill-reclaim-skipped-version-current`,scope:`user`,version:l}),{outcome:`skipped`,reason:`version-current`};let h=[],_=d.length===c.length,v=!0;for(let{id:e,sourceDir:n}of p){let o=j(t,i[e],n,r,a,l);h.push(...o.entries),o.centralWritten||(v=!1)}let y=h.some(e=>e.kind===`central`&&(e.outcome===`written`||e.outcome===`overwritten`));if(_&&v&&y){let e=null;try{await n.writeRecordedVersion(t,l),a({event:`user-skill-reclaim-version-recorded`,scope:`user`,version:l})}catch(t){e=t instanceof Error?t.message:String(t),a({event:`user-skill-reclaim-version-record-failed`,scope:`user`,version:l,error:e})}for(let{id:t}of p)o({ts:s(),surface:`cli-start`,target:`cli-hosts`,bundle:t,outcome:e===null?`installed`:`failed`,version:l,...e===null?{}:{reason:`state-write-failed:${e}`}})}else{let e=h.some(e=>e.kind===`host`&&e.outcome===`failed`);o({ts:s(),surface:`cli-start`,target:`cli-hosts`,outcome:`failed`,version:l,reason:e?`all-writes-failed`:`no-hosts-installed`})}return{outcome:`done`,version:l,entries:h}}async function F(e){let t=e.logger??O,n=e.fs??E,r=e.home??v(),i={...D,...e.deps};return e.reclaimDisableEnv===`1`?(t({event:`skill-repair-skipped`,reason:`reclaim-disabled`}),{status:`skipped`,reason:`reclaim-disabled`}):{status:`done`,project:N(e.projectDir,i,n,t),user:await P(r,i,n,t)}}function I(e){return e.status===`skipped`?e.reason===`reclaim-disabled`?0:1:e.project.outcome===`skipped`||e.user.outcome===`skipped`&&e.user.reason!==`version-current`&&e.user.reason!==`all-bundles-declined`||e.project.entries.some(e=>e.outcome===`failed`)||e.user.outcome===`done`&&e.user.entries.some(e=>e.outcome===`failed`)?1:0}function L(e){if(e.status===`skipped`)return`Skipped: ${e.reason}`;let t=[`Skill reclaim complete.`];if(e.project.outcome===`done`){let n=e.project.entries.filter(e=>e.outcome===`reclaimed`).length,r=e.project.entries.filter(e=>e.outcome===`created`).length,i=e.project.entries.filter(e=>e.outcome===`no-token`).length,a=e.project.entries.filter(e=>e.outcome===`failed`).length;t.push(` Project: ${n} reclaimed, ${r} created, ${i} no-token, ${a} failed.`)}else t.push(` Project: skipped (${e.project.reason}).`);if(e.user.outcome===`done`){let n=e.user.entries.filter(e=>e.outcome===`written`||e.outcome===`overwritten`).length,r=e.user.entries.filter(e=>e.outcome===`skipped-host-absent`||e.outcome===`skipped-collapsed-with-central`).length,i=e.user.entries.filter(e=>e.outcome===`failed`).length;t.push(` User (${e.user.version}): ${n} written, ${r} skipped, ${i} failed.`)}else t.push(` User: skipped (${e.user.reason}).`);return t.join(`
|
|
2
2
|
`)}function R(){return new u(`repair-skills`).description("Refresh bundled SKILL.md files for installed AI editors (project-local + user-global). Runs automatically during `ok start`; this command forces an explicit sweep.").action(async()=>{let e=await F({projectDir:_(process.cwd()),reclaimDisableEnv:process.env.OK_RECLAIM_DISABLE??null});process.stdout.write(`${L(e)}\n`),process.exitCode=I(e)})}export{R as n,F as t};
|
|
3
|
-
//# sourceMappingURL=repair-skills-
|
|
3
|
+
//# sourceMappingURL=repair-skills-DDLj2RIs.mjs.map
|