@truenine/memory-sync-cli 0.0.17 → 0.0.18
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/index.mjs +6 -7
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -17,7 +17,7 @@ var n=T(),r={"{":`}`,"(":`)`,"[":`]`},i=function(e){if(e[0]===`!`)return!0;for(v
|
|
|
17
17
|
/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
18
18
|
let n;t.exports=typeof queueMicrotask==`function`?queueMicrotask.bind(typeof window<`u`?window:global):e=>(n||=Promise.resolve()).then(e).catch(e=>setTimeout(()=>{throw e},0))})),he=g(((e,t)=>{
|
|
19
19
|
/*! run-parallel. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
20
|
-
t.exports=r;let n=me();function r(e,t){let r,i,a,o=!0;Array.isArray(e)?(r=[],i=e.length):(a=Object.keys(e),r={},i=a.length);function s(e){function i(){t&&t(e,r),t=null}o?n(i):i()}function c(e,t,n){r[e]=n,(--i===0||t)&&s(t)}i?a?a.forEach(function(t){e[t](function(e,n){c(t,e,n)})}):e.forEach(function(e,t){e(function(e,n){c(t,e,n)})}):s(null),o=!1}})),ge=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.IS_SUPPORT_READDIR_WITH_FILE_TYPES=void 0;let t=process.versions.node.split(`.`);if(t[0]===void 0||t[1]===void 0)throw Error(`Unexpected behavior. The 'process.versions.node' variable has invalid value: ${process.versions.node}`);let n=Number.parseInt(t[0],10),r=Number.parseInt(t[1],10);e.IS_SUPPORT_READDIR_WITH_FILE_TYPES=n>10||n===10&&r>=10})),_e=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createDirentFromStats=void 0;var t=class{constructor(e,t){this.name=e,this.isBlockDevice=t.isBlockDevice.bind(t),this.isCharacterDevice=t.isCharacterDevice.bind(t),this.isDirectory=t.isDirectory.bind(t),this.isFIFO=t.isFIFO.bind(t),this.isFile=t.isFile.bind(t),this.isSocket=t.isSocket.bind(t),this.isSymbolicLink=t.isSymbolicLink.bind(t)}};function n(e,n){return new t(e,n)}e.createDirentFromStats=n})),ve=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fs=void 0,e.fs=_e()})),ye=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.joinPathSegments=void 0;function t(e,t,n){return e.endsWith(n)?e+t:e+n+t}e.joinPathSegments=t})),be=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.readdir=e.readdirWithFileTypes=e.read=void 0;let t=pe(),n=he(),r=ge(),i=ve(),a=ye();function o(e,t,n){if(!t.stats&&r.IS_SUPPORT_READDIR_WITH_FILE_TYPES){s(e,t,n);return}l(e,t,n)}e.read=o;function s(e,t,r){t.fs.readdir(e,{withFileTypes:!0},(i,o)=>{if(i!==null){u(r,i);return}let s=o.map(n=>({dirent:n,name:n.name,path:a.joinPathSegments(e,n.name,t.pathSegmentSeparator)}));if(!t.followSymbolicLinks){d(r,s);return}n(s.map(e=>c(e,t)),(e,t)=>{if(e!==null){u(r,e);return}d(r,t)})})}e.readdirWithFileTypes=s;function c(e,t){return n=>{if(!e.dirent.isSymbolicLink()){n(null,e);return}t.fs.stat(e.path,(r,a)=>{if(r!==null){if(t.throwErrorOnBrokenSymbolicLink){n(r);return}n(null,e);return}e.dirent=i.fs.createDirentFromStats(e.name,a),n(null,e)})}}function l(e,r,o){r.fs.readdir(e,(s,c)=>{if(s!==null){u(o,s);return}n(c.map(n=>{let o=a.joinPathSegments(e,n,r.pathSegmentSeparator);return e=>{t.stat(o,r.fsStatSettings,(t,a)=>{if(t!==null){e(t);return}let s={name:n,path:o,dirent:i.fs.createDirentFromStats(n,a)};r.stats&&(s.stats=a),e(null,s)})}}),(e,t)=>{if(e!==null){u(o,e);return}d(o,t)})})}e.readdir=l;function u(e,t){e(t)}function d(e,t){e(null,t)}})),xe=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.readdir=e.readdirWithFileTypes=e.read=void 0;let t=pe(),n=ge(),r=ve(),i=ye();function a(e,t){return!t.stats&&n.IS_SUPPORT_READDIR_WITH_FILE_TYPES?o(e,t):s(e,t)}e.read=a;function o(e,t){return t.fs.readdirSync(e,{withFileTypes:!0}).map(n=>{let a={dirent:n,name:n.name,path:i.joinPathSegments(e,n.name,t.pathSegmentSeparator)};if(a.dirent.isSymbolicLink()&&t.followSymbolicLinks)try{let e=t.fs.statSync(a.path);a.dirent=r.fs.createDirentFromStats(a.name,e)}catch(e){if(t.throwErrorOnBrokenSymbolicLink)throw e}return a})}e.readdirWithFileTypes=o;function s(e,n){return n.fs.readdirSync(e).map(a=>{let o=i.joinPathSegments(e,a,n.pathSegmentSeparator),s=t.statSync(o,n.fsStatSettings),c={name:a,path:o,dirent:r.fs.createDirentFromStats(a,s)};return n.stats&&(c.stats=s),c})}e.readdir=s})),Se=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createFileSystemAdapter=e.FILE_SYSTEM_ADAPTER=void 0;let t=b(`fs`);e.FILE_SYSTEM_ADAPTER={lstat:t.lstat,stat:t.stat,lstatSync:t.lstatSync,statSync:t.statSync,readdir:t.readdir,readdirSync:t.readdirSync};function n(t){return t===void 0?e.FILE_SYSTEM_ADAPTER:Object.assign(Object.assign({},e.FILE_SYSTEM_ADAPTER),t)}e.createFileSystemAdapter=n})),Ce=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=b(`path`),n=pe(),r=Se();e.default=class{constructor(e={}){this._options=e,this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,!1),this.fs=r.createFileSystemAdapter(this._options.fs),this.pathSegmentSeparator=this._getValue(this._options.pathSegmentSeparator,t.sep),this.stats=this._getValue(this._options.stats,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!0),this.fsStatSettings=new n.Settings({followSymbolicLink:this.followSymbolicLinks,fs:this.fs,throwErrorOnBrokenSymbolicLink:this.throwErrorOnBrokenSymbolicLink})}_getValue(e,t){return e??t}}})),we=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.scandirSync=e.scandir=void 0;let t=be(),n=xe(),r=Ce();e.Settings=r.default;function i(e,n,r){if(typeof n==`function`){t.read(e,o(),n);return}t.read(e,o(n),r)}e.scandir=i;function a(e,t){let r=o(t);return n.read(e,r)}e.scandirSync=a;function o(e={}){return e instanceof r.default?e:new r.default(e)}})),Te=g(((e,t)=>{function n(e){var t=new e,n=t;function r(){var r=t;return r.next?t=r.next:(t=new e,n=t),r.next=null,r}function i(e){n.next=e,n=e}return{get:r,release:i}}t.exports=n})),Ee=g(((e,t)=>{var n=Te();function r(e,t,r){if(typeof e==`function`&&(r=t,t=e,e=null),!(r>=1))throw Error(`fastqueue concurrency must be equal to or greater than 1`);var o=n(a),s=null,c=null,l=0,u=null,d={push:v,drain:i,saturated:i,pause:p,paused:!1,get concurrency(){return r},set concurrency(e){if(!(e>=1))throw Error(`fastqueue concurrency must be equal to or greater than 1`);if(r=e,!d.paused)for(;s&&l<r;)l++,b()},running:f,resume:g,idle:_,length:m,getQueue:h,unshift:y,empty:i,kill:x,killAndDrain:S,error:C};return d;function f(){return l}function p(){d.paused=!0}function m(){for(var e=s,t=0;e;)e=e.next,t++;return t}function h(){for(var e=s,t=[];e;)t.push(e.value),e=e.next;return t}function g(){if(d.paused){if(d.paused=!1,s===null){l++,b();return}for(;s&&l<r;)l++,b()}}function _(){return l===0&&d.length()===0}function v(n,a){var f=o.get();f.context=e,f.release=b,f.value=n,f.callback=a||i,f.errorHandler=u,l>=r||d.paused?c?(c.next=f,c=f):(s=f,c=f,d.saturated()):(l++,t.call(e,f.value,f.worked))}function y(n,a){var f=o.get();f.context=e,f.release=b,f.value=n,f.callback=a||i,f.errorHandler=u,l>=r||d.paused?s?(f.next=s,s=f):(s=f,c=f,d.saturated()):(l++,t.call(e,f.value,f.worked))}function b(n){n&&o.release(n);var i=s;i&&l<=r?d.paused?l--:(c===s&&(c=null),s=i.next,i.next=null,t.call(e,i.value,i.worked),c===null&&d.empty()):--l===0&&d.drain()}function x(){s=null,c=null,d.drain=i}function S(){s=null,c=null,d.drain(),d.drain=i}function C(e){u=e}}function i(){}function a(){this.value=null,this.callback=i,this.next=null,this.release=i,this.context=null,this.errorHandler=null;var e=this;this.worked=function(t,n){var r=e.callback,a=e.errorHandler,o=e.value;e.value=null,e.callback=i,e.errorHandler&&a(t,o),r.call(e.context,t,n),e.release(e)}}function o(e,t,n){typeof e==`function`&&(n=t,t=e,e=null);function a(e,n){t.call(this,e).then(function(e){n(null,e)},n)}var o=r(e,a,n),s=o.push,c=o.unshift;return o.push=l,o.unshift=u,o.drained=d,o;function l(e){var t=new Promise(function(t,n){s(e,function(e,r){if(e){n(e);return}t(r)})});return t.catch(i),t}function u(e){var t=new Promise(function(t,n){c(e,function(e,r){if(e){n(e);return}t(r)})});return t.catch(i),t}function d(){return new Promise(function(e){process.nextTick(function(){if(o.idle())e();else{var t=o.drain;o.drain=function(){typeof t==`function`&&t(),e(),o.drain=t}}})})}}t.exports=r,t.exports.promise=o})),De=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.joinPathSegments=e.replacePathSegmentSeparator=e.isAppliedFilter=e.isFatalError=void 0;function t(e,t){return e.errorFilter===null?!0:!e.errorFilter(t)}e.isFatalError=t;function n(e,t){return e===null||e(t)}e.isAppliedFilter=n;function r(e,t){return e.split(/[/\\]/).join(t)}e.replacePathSegmentSeparator=r;function i(e,t,n){return e===``?t:e.endsWith(n)?e+t:e+n+t}e.joinPathSegments=i})),Oe=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=De();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._root=t.replacePathSegmentSeparator(e,n.pathSegmentSeparator)}}})),ke=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=b(`events`),n=we(),r=Ee(),i=De(),a=Oe();e.default=class extends a.default{constructor(e,i){super(e,i),this._settings=i,this._scandir=n.scandir,this._emitter=new t.EventEmitter,this._queue=r(this._worker.bind(this),this._settings.concurrency),this._isFatalError=!1,this._isDestroyed=!1,this._queue.drain=()=>{this._isFatalError||this._emitter.emit(`end`)}}read(){return this._isFatalError=!1,this._isDestroyed=!1,setImmediate(()=>{this._pushToQueue(this._root,this._settings.basePath)}),this._emitter}get isDestroyed(){return this._isDestroyed}destroy(){if(this._isDestroyed)throw Error(`The reader is already destroyed`);this._isDestroyed=!0,this._queue.killAndDrain()}onEntry(e){this._emitter.on(`entry`,e)}onError(e){this._emitter.once(`error`,e)}onEnd(e){this._emitter.once(`end`,e)}_pushToQueue(e,t){let n={directory:e,base:t};this._queue.push(n,e=>{e!==null&&this._handleError(e)})}_worker(e,t){this._scandir(e.directory,this._settings.fsScandirSettings,(n,r)=>{if(n!==null){t(n,void 0);return}for(let t of r)this._handleEntry(t,e.base);t(null,void 0)})}_handleError(e){this._isDestroyed||!i.isFatalError(this._settings,e)||(this._isFatalError=!0,this._isDestroyed=!0,this._emitter.emit(`error`,e))}_handleEntry(e,t){if(this._isDestroyed||this._isFatalError)return;let n=e.path;t!==void 0&&(e.path=i.joinPathSegments(t,e.name,this._settings.pathSegmentSeparator)),i.isAppliedFilter(this._settings.entryFilter,e)&&this._emitEntry(e),e.dirent.isDirectory()&&i.isAppliedFilter(this._settings.deepFilter,e)&&this._pushToQueue(n,t===void 0?void 0:e.path)}_emitEntry(e){this._emitter.emit(`entry`,e)}}})),Ae=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ke();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._reader=new t.default(this._root,this._settings),this._storage=[]}read(e){this._reader.onError(t=>{n(e,t)}),this._reader.onEntry(e=>{this._storage.push(e)}),this._reader.onEnd(()=>{r(e,this._storage)}),this._reader.read()}};function n(e,t){e(t)}function r(e,t){e(null,t)}})),je=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=b(`stream`),n=ke();e.default=class{constructor(e,r){this._root=e,this._settings=r,this._reader=new n.default(this._root,this._settings),this._stream=new t.Readable({objectMode:!0,read:()=>{},destroy:()=>{this._reader.isDestroyed||this._reader.destroy()}})}read(){return this._reader.onError(e=>{this._stream.emit(`error`,e)}),this._reader.onEntry(e=>{this._stream.push(e)}),this._reader.onEnd(()=>{this._stream.push(null)}),this._reader.read(),this._stream}}})),Me=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=we(),n=De(),r=Oe();e.default=class extends r.default{constructor(){super(...arguments),this._scandir=t.scandirSync,this._storage=[],this._queue=new Set}read(){return this._pushToQueue(this._root,this._settings.basePath),this._handleQueue(),this._storage}_pushToQueue(e,t){this._queue.add({directory:e,base:t})}_handleQueue(){for(let e of this._queue.values())this._handleDirectory(e.directory,e.base)}_handleDirectory(e,t){try{let n=this._scandir(e,this._settings.fsScandirSettings);for(let e of n)this._handleEntry(e,t)}catch(e){this._handleError(e)}}_handleError(e){if(n.isFatalError(this._settings,e))throw e}_handleEntry(e,t){let r=e.path;t!==void 0&&(e.path=n.joinPathSegments(t,e.name,this._settings.pathSegmentSeparator)),n.isAppliedFilter(this._settings.entryFilter,e)&&this._pushToStorage(e),e.dirent.isDirectory()&&n.isAppliedFilter(this._settings.deepFilter,e)&&this._pushToQueue(r,t===void 0?void 0:e.path)}_pushToStorage(e){this._storage.push(e)}}})),Ne=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Me();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._reader=new t.default(this._root,this._settings)}read(){return this._reader.read()}}})),Pe=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=b(`path`),n=we();e.default=class{constructor(e={}){this._options=e,this.basePath=this._getValue(this._options.basePath,void 0),this.concurrency=this._getValue(this._options.concurrency,1/0),this.deepFilter=this._getValue(this._options.deepFilter,null),this.entryFilter=this._getValue(this._options.entryFilter,null),this.errorFilter=this._getValue(this._options.errorFilter,null),this.pathSegmentSeparator=this._getValue(this._options.pathSegmentSeparator,t.sep),this.fsScandirSettings=new n.Settings({followSymbolicLinks:this._options.followSymbolicLinks,fs:this._options.fs,pathSegmentSeparator:this._options.pathSegmentSeparator,stats:this._options.stats,throwErrorOnBrokenSymbolicLink:this._options.throwErrorOnBrokenSymbolicLink})}_getValue(e,t){return e??t}}})),Fe=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.walkStream=e.walkSync=e.walk=void 0;let t=Ae(),n=je(),r=Ne(),i=Pe();e.Settings=i.default;function a(e,n,r){if(typeof n==`function`){new t.default(e,c()).read(n);return}new t.default(e,c(n)).read(r)}e.walk=a;function o(e,t){let n=c(t);return new r.default(e,n).read()}e.walkSync=o;function s(e,t){let r=c(t);return new n.default(e,r).read()}e.walkStream=s;function c(e={}){return e instanceof i.default?e:new i.default(e)}})),Ie=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=b(`path`),n=pe(),r=se();e.default=class{constructor(e){this._settings=e,this._fsStatSettings=new n.Settings({followSymbolicLink:this._settings.followSymbolicLinks,fs:this._settings.fs,throwErrorOnBrokenSymbolicLink:this._settings.followSymbolicLinks})}_getFullEntryPath(e){return t.resolve(this._settings.cwd,e)}_makeEntry(e,t){let n={name:t,path:t,dirent:r.fs.createDirentFromStats(t,e)};return this._settings.stats&&(n.stats=e),n}_isFatalError(e){return!r.errno.isEnoentCodeError(e)&&!this._settings.suppressErrors}}})),Le=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=b(`stream`),n=pe(),r=Fe(),i=Ie();e.default=class extends i.default{constructor(){super(...arguments),this._walkStream=r.walkStream,this._stat=n.stat}dynamic(e,t){return this._walkStream(e,t)}static(e,n){let r=e.map(this._getFullEntryPath,this),i=new t.PassThrough({objectMode:!0});i._write=(t,a,o)=>this._getEntry(r[t],e[t],n).then(e=>{e!==null&&n.entryFilter(e)&&i.push(e),t===r.length-1&&i.end(),o()}).catch(o);for(let e=0;e<r.length;e++)i.write(e);return i}_getEntry(e,t,n){return this._getStat(e).then(e=>this._makeEntry(e,t)).catch(e=>{if(n.errorFilter(e))return null;throw e})}_getStat(e){return new Promise((t,n)=>{this._stat(e,this._fsStatSettings,(e,r)=>e===null?t(r):n(e))})}}})),Re=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Fe(),n=Ie(),r=Le();e.default=class extends n.default{constructor(){super(...arguments),this._walkAsync=t.walk,this._readerStream=new r.default(this._settings)}dynamic(e,t){return new Promise((n,r)=>{this._walkAsync(e,t,(e,t)=>{e===null?n(t):r(e)})})}async static(e,t){let n=[],r=this._readerStream.static(e,t);return new Promise((e,t)=>{r.once(`error`,t),r.on(`data`,e=>n.push(e)),r.once(`end`,()=>e(n))})}}})),ze=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=se();e.default=class{constructor(e,t,n){this._patterns=e,this._settings=t,this._micromatchOptions=n,this._storage=[],this._fillStorage()}_fillStorage(){for(let e of this._patterns){let t=this._getPatternSegments(e),n=this._splitSegmentsIntoSections(t);this._storage.push({complete:n.length<=1,pattern:e,segments:t,sections:n})}}_getPatternSegments(e){return t.pattern.getPatternParts(e,this._micromatchOptions).map(e=>t.pattern.isDynamicPattern(e,this._settings)?{dynamic:!0,pattern:e,patternRe:t.pattern.makeRe(e,this._micromatchOptions)}:{dynamic:!1,pattern:e})}_splitSegmentsIntoSections(e){return t.array.splitWhen(e,e=>e.dynamic&&t.pattern.hasGlobStar(e.pattern))}}})),Be=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ze();e.default=class extends t.default{match(e){let t=e.split(`/`),n=t.length,r=this._storage.filter(e=>!e.complete||e.segments.length>n);for(let e of r){let r=e.sections[0];if(!e.complete&&n>r.length||t.every((t,n)=>{let r=e.segments[n];return!!(r.dynamic&&r.patternRe.test(t)||!r.dynamic&&r.pattern===t)}))return!0}return!1}}})),Ve=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=se(),n=Be();e.default=class{constructor(e,t){this._settings=e,this._micromatchOptions=t}getFilter(e,t,n){let r=this._getMatcher(t),i=this._getNegativePatternsRe(n);return t=>this._filter(e,t,r,i)}_getMatcher(e){return new n.default(e,this._settings,this._micromatchOptions)}_getNegativePatternsRe(e){let n=e.filter(t.pattern.isAffectDepthOfReadingPattern);return t.pattern.convertPatternsToRe(n,this._micromatchOptions)}_filter(e,n,r,i){if(this._isSkippedByDeep(e,n.path)||this._isSkippedSymbolicLink(n))return!1;let a=t.path.removeLeadingDotSegment(n.path);return this._isSkippedByPositivePatterns(a,r)?!1:this._isSkippedByNegativePatterns(a,i)}_isSkippedByDeep(e,t){return this._settings.deep===1/0?!1:this._getEntryLevel(e,t)>=this._settings.deep}_getEntryLevel(e,t){let n=t.split(`/`).length;return e===``?n:n-e.split(`/`).length}_isSkippedSymbolicLink(e){return!this._settings.followSymbolicLinks&&e.dirent.isSymbolicLink()}_isSkippedByPositivePatterns(e,t){return!this._settings.baseNameMatch&&!t.match(e)}_isSkippedByNegativePatterns(e,n){return!t.pattern.matchAny(e,n)}}})),He=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=se();e.default=class{constructor(e,t){this._settings=e,this._micromatchOptions=t,this.index=new Map}getFilter(e,n){let[r,i]=t.pattern.partitionAbsoluteAndRelative(n),a={positive:{all:t.pattern.convertPatternsToRe(e,this._micromatchOptions)},negative:{absolute:t.pattern.convertPatternsToRe(r,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0})),relative:t.pattern.convertPatternsToRe(i,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0}))}};return e=>this._filter(e,a)}_filter(e,n){let r=t.path.removeLeadingDotSegment(e.path);if(this._settings.unique&&this._isDuplicateEntry(r)||this._onlyFileFilter(e)||this._onlyDirectoryFilter(e))return!1;let i=this._isMatchToPatternsSet(r,n,e.dirent.isDirectory());return this._settings.unique&&i&&this._createIndexRecord(r),i}_isDuplicateEntry(e){return this.index.has(e)}_createIndexRecord(e){this.index.set(e,void 0)}_onlyFileFilter(e){return this._settings.onlyFiles&&!e.dirent.isFile()}_onlyDirectoryFilter(e){return this._settings.onlyDirectories&&!e.dirent.isDirectory()}_isMatchToPatternsSet(e,t,n){return!(!this._isMatchToPatterns(e,t.positive.all,n)||this._isMatchToPatterns(e,t.negative.relative,n)||this._isMatchToAbsoluteNegative(e,t.negative.absolute,n))}_isMatchToAbsoluteNegative(e,n,r){if(n.length===0)return!1;let i=t.path.makeAbsolute(this._settings.cwd,e);return this._isMatchToPatterns(i,n,r)}_isMatchToPatterns(e,n,r){if(n.length===0)return!1;let i=t.pattern.matchAny(e,n);return!i&&r?t.pattern.matchAny(e+`/`,n):i}}})),Ue=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=se();e.default=class{constructor(e){this._settings=e}getFilter(){return e=>this._isNonFatalError(e)}_isNonFatalError(e){return t.errno.isEnoentCodeError(e)||this._settings.suppressErrors}}})),We=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=se();e.default=class{constructor(e){this._settings=e}getTransformer(){return e=>this._transform(e)}_transform(e){let n=e.path;return this._settings.absolute&&(n=t.path.makeAbsolute(this._settings.cwd,n),n=t.path.unixify(n)),this._settings.markDirectories&&e.dirent.isDirectory()&&(n+=`/`),this._settings.objectMode?Object.assign(Object.assign({},e),{path:n}):n}}})),Ge=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=b(`path`),n=Ve(),r=He(),i=Ue(),a=We();e.default=class{constructor(e){this._settings=e,this.errorFilter=new i.default(this._settings),this.entryFilter=new r.default(this._settings,this._getMicromatchOptions()),this.deepFilter=new n.default(this._settings,this._getMicromatchOptions()),this.entryTransformer=new a.default(this._settings)}_getRootDirectory(e){return t.resolve(this._settings.cwd,e.base)}_getReaderOptions(e){let t=e.base===`.`?``:e.base;return{basePath:t,pathSegmentSeparator:`/`,concurrency:this._settings.concurrency,deepFilter:this.deepFilter.getFilter(t,e.positive,e.negative),entryFilter:this.entryFilter.getFilter(e.positive,e.negative),errorFilter:this.errorFilter.getFilter(),followSymbolicLinks:this._settings.followSymbolicLinks,fs:this._settings.fs,stats:this._settings.stats,throwErrorOnBrokenSymbolicLink:this._settings.throwErrorOnBrokenSymbolicLink,transform:this.entryTransformer.getTransformer()}}_getMicromatchOptions(){return{dot:this._settings.dot,matchBase:this._settings.baseNameMatch,nobrace:!this._settings.braceExpansion,nocase:!this._settings.caseSensitiveMatch,noext:!this._settings.extglob,noglobstar:!this._settings.globstar,posix:!0,strictSlashes:!1}}}})),Ke=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Re(),n=Ge();e.default=class extends n.default{constructor(){super(...arguments),this._reader=new t.default(this._settings)}async read(e){let t=this._getRootDirectory(e),n=this._getReaderOptions(e);return(await this.api(t,e,n)).map(e=>n.transform(e))}api(e,t,n){return t.dynamic?this._reader.dynamic(e,n):this._reader.static(t.patterns,n)}}})),qe=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=b(`stream`),n=Le(),r=Ge();e.default=class extends r.default{constructor(){super(...arguments),this._reader=new n.default(this._settings)}read(e){let n=this._getRootDirectory(e),r=this._getReaderOptions(e),i=this.api(n,e,r),a=new t.Readable({objectMode:!0,read:()=>{}});return i.once(`error`,e=>a.emit(`error`,e)).on(`data`,e=>a.emit(`data`,r.transform(e))).once(`end`,()=>a.emit(`end`)),a.once(`close`,()=>i.destroy()),a}api(e,t,n){return t.dynamic?this._reader.dynamic(e,n):this._reader.static(t.patterns,n)}}})),Je=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=pe(),n=Fe(),r=Ie();e.default=class extends r.default{constructor(){super(...arguments),this._walkSync=n.walkSync,this._statSync=t.statSync}dynamic(e,t){return this._walkSync(e,t)}static(e,t){let n=[];for(let r of e){let e=this._getFullEntryPath(r),i=this._getEntry(e,r,t);i===null||!t.entryFilter(i)||n.push(i)}return n}_getEntry(e,t,n){try{let n=this._getStat(e);return this._makeEntry(n,t)}catch(e){if(n.errorFilter(e))return null;throw e}}_getStat(e){return this._statSync(e,this._fsStatSettings)}}})),Ye=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Je(),n=Ge();e.default=class extends n.default{constructor(){super(...arguments),this._reader=new t.default(this._settings)}read(e){let t=this._getRootDirectory(e),n=this._getReaderOptions(e);return this.api(t,e,n).map(n.transform)}api(e,t,n){return t.dynamic?this._reader.dynamic(e,n):this._reader.static(t.patterns,n)}}})),Xe=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DEFAULT_FILE_SYSTEM_ADAPTER=void 0;let t=b(`fs`),n=b(`os`),r=Math.max(n.cpus().length,1);e.DEFAULT_FILE_SYSTEM_ADAPTER={lstat:t.lstat,lstatSync:t.lstatSync,stat:t.stat,statSync:t.statSync,readdir:t.readdir,readdirSync:t.readdirSync},e.default=class{constructor(e={}){this._options=e,this.absolute=this._getValue(this._options.absolute,!1),this.baseNameMatch=this._getValue(this._options.baseNameMatch,!1),this.braceExpansion=this._getValue(this._options.braceExpansion,!0),this.caseSensitiveMatch=this._getValue(this._options.caseSensitiveMatch,!0),this.concurrency=this._getValue(this._options.concurrency,r),this.cwd=this._getValue(this._options.cwd,process.cwd()),this.deep=this._getValue(this._options.deep,1/0),this.dot=this._getValue(this._options.dot,!1),this.extglob=this._getValue(this._options.extglob,!0),this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,!0),this.fs=this._getFileSystemMethods(this._options.fs),this.globstar=this._getValue(this._options.globstar,!0),this.ignore=this._getValue(this._options.ignore,[]),this.markDirectories=this._getValue(this._options.markDirectories,!1),this.objectMode=this._getValue(this._options.objectMode,!1),this.onlyDirectories=this._getValue(this._options.onlyDirectories,!1),this.onlyFiles=this._getValue(this._options.onlyFiles,!0),this.stats=this._getValue(this._options.stats,!1),this.suppressErrors=this._getValue(this._options.suppressErrors,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!1),this.unique=this._getValue(this._options.unique,!0),this.onlyDirectories&&(this.onlyFiles=!1),this.stats&&(this.objectMode=!0),this.ignore=[].concat(this.ignore)}_getValue(e,t){return e===void 0?t:e}_getFileSystemMethods(t={}){return Object.assign(Object.assign({},e.DEFAULT_FILE_SYSTEM_ADAPTER),t)}}})),Ze=y(g(((e,t)=>{let n=ce(),r=Ke(),i=qe(),a=Ye(),o=Xe(),s=se();async function c(e,t){u(e);let n=l(e,r.default,t),i=await Promise.all(n);return s.array.flatten(i)}(function(e){e.glob=e,e.globSync=t,e.globStream=r,e.async=e;function t(e,t){u(e);let n=l(e,a.default,t);return s.array.flatten(n)}e.sync=t;function r(e,t){u(e);let n=l(e,i.default,t);return s.stream.merge(n)}e.stream=r;function c(e,t){u(e);let r=[].concat(e),i=new o.default(t);return n.generate(r,i)}e.generateTasks=c;function d(e,t){u(e);let n=new o.default(t);return s.pattern.isDynamicPattern(e,n)}e.isDynamicPattern=d;function f(e){return u(e),s.path.escape(e)}e.escapePath=f;function p(e){return u(e),s.path.convertPathToPattern(e)}e.convertPathToPattern=p,(function(e){function t(e){return u(e),s.path.escapePosixPath(e)}e.escapePath=t;function n(e){return u(e),s.path.convertPosixPathToPattern(e)}e.convertPathToPattern=n})(e.posix||={}),(function(e){function t(e){return u(e),s.path.escapeWindowsPath(e)}e.escapePath=t;function n(e){return u(e),s.path.convertWindowsPathToPattern(e)}e.convertPathToPattern=n})(e.win32||={})})(c||={});function l(e,t,r){let i=[].concat(e),a=new o.default(r),s=n.generate(i,a),c=new t(a);return s.map(c.read,c)}function u(e){if(![].concat(e).every(e=>s.string.isString(e)&&!s.string.isEmpty(e)))throw TypeError(`Patterns must be a string (non empty) or an array of strings`)}t.exports=c}))(),1);async function Qe(e,t){let n=[],r=[],i=[],a=[];for(let o of e)o.registerProjectOutputDirs&&n.push(...await o.registerProjectOutputDirs(t)),o.registerProjectOutputFiles&&r.push(...await o.registerProjectOutputFiles(t)),o.registerGlobalOutputDirs&&i.push(...await o.registerGlobalOutputDirs(t)),o.registerGlobalOutputFiles&&a.push(...await o.registerGlobalOutputFiles(t));return{projectDirs:n,projectFiles:r,globalDirs:i,globalFiles:a}}async function $e(e,t){let n=new Map;for(let r of e)n.set(r.name,{project:await r.canCleanProject?.(t)??!0,global:await r.canCleanGlobal?.(t)??!0});return n}async function et(e,t){for(let n of e)await n.onCleanComplete?.(t)}async function tt(e,t){let n=new Map;for(let r of e){let e=await r.canWrite?.(t)??!0;n.set(r.name,{project:e,global:e})}return n}async function nt(e,t){let n=new Map;for(let r of e){let e=await r.writeProjectOutputs?.(t)??{files:[],dirs:[]},i=await r.writeGlobalOutputs?.(t)??{files:[],dirs:[]},a={files:[...e.files,...i.files],dirs:[...e.dirs,...i.dirs]};n.set(r.name,a),await r.onWriteComplete?.(t,a)}return n}async function rt(e,t,n){let r=[],i=[];for(let a of e){let e=t.get(a.name);if(e?.project){let e=await a.registerProjectOutputFiles?.(n)??[],t=await a.registerProjectOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}if(e?.global){let e=await a.registerGlobalOutputFiles?.(n)??[],t=await a.registerGlobalOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}}return{filesToDelete:r,dirsToDelete:i}}function it(e,t){let n=0,a=[];for(let o of e){let e=i.isAbsolute(o)?o:i.resolve(o);try{r.existsSync(e)&&(r.unlinkSync(e),t.info(`Deleted file: ${e}`),n++)}catch(n){t.warn(`Failed to delete file: ${e}`,{error:n}),a.push({path:e,type:`file`,error:n})}}return{deleted:n,errors:a}}function at(e,t){let n=0,a=[],o=[...e].sort((e,t)=>t.length-e.length);for(let e of o){let o=i.isAbsolute(e)?e:i.resolve(e);try{r.existsSync(o)&&(r.rmSync(o,{recursive:!0,force:!0}),t.info(`Deleted directory: ${o}`),n++)}catch(e){t.warn(`Failed to delete directory: ${o}`,{error:e}),a.push({path:o,type:`directory`,error:e})}}return{deleted:n,errors:a}}async function ot(e,t,n,r){let{executeHooks:i=!0}=r??{},a=await Qe(e,t);n.debug(`Collected outputs for cleanup`,{projectDirs:a.projectDirs.length,projectFiles:a.projectFiles.length,globalDirs:a.globalDirs.length,globalFiles:a.globalFiles.length});let{filesToDelete:o,dirsToDelete:s}=await rt(e,await $e(e,t),t),c=it(o,n),l=at(s,n);return i&&await et(e,t),{deletedFiles:c.deleted,deletedDirs:l.deleted,errors:[...c.errors,...l.errors]}}var st=class{name=`clean`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r}=e;t.info(`Running clean pipeline`);let i=await ot(n,r(!1),t);return t.info(`Clean complete: ${i.deletedFiles} files, ${i.deletedDirs} directories`),{success:!0,filesAffected:i.deletedFiles,dirsAffected:i.deletedDirs}}};let ct=function(e){return e.Input=`Input`,e.Output=`Output`,e}({}),lt=function(e){return e.GlobalMemory=`GlobalMemory`,e.ProjectRootMemory=`ProjectRootMemory`,e.ProjectChildrenMemory=`ProjectChildrenMemory`,e.FastCommand=`FastCommand`,e.SubAgent=`SubAgent`,e.Skill=`Skill`,e.SkillReferenceDocument=`SkillReferenceDocument`,e.Readme=`Readme`,e}({}),ut=function(e){return e.Red=`Red`,e.Green=`Green`,e.Blue=`Blue`,e.Yellow=`Yellow`,e}({}),dt=function(e){return e.Read=`Read`,e.Write=`Write`,e.Edit=`Edit`,e.Grep=`Grep`,e}({}),ft=function(e){return e.CamelCase=`CamelCase`,e.PascalCase=`PascalCase`,e.SnakeCase=`SnakeCase`,e.KebabCase=`KebabCase`,e.UpperCase=`UpperCase`,e.LowerCase=`LowerCase`,e.Original=`Original`,e}({}),pt=function(e){return e.UserHome=`UserHome`,e.External=`External`,e}({}),I=function(e){return e.Relative=`Relative`,e.Absolute=`Absolute`,e.Root=`Root`,e}({}),L=function(e){return e.VSCode=`VSCode`,e.IntellijIDEA=`IntellijIDEA`,e.Git=`Git`,e.EditorConfig=`EditorConfig`,e.Original=`Original`,e}({});var mt=class extends Error{constructor(e){super(`Circular dependency detected: ${e.join(` -> `)}`),this.cycle=e,this.name=`CircularDependencyError`}},ht=class extends Error{constructor(e,t){super(`Plugin "${e}" depends on non-existent plugin "${t}"`),this.pluginName=e,this.missingDependency=t,this.name=`MissingDependencyError`}};const gt={USER_HOME:`~`,WORKSPACE:`$WORKSPACE`,SHADOW_PROJECT:`$SHADOW_PROJECT`},_t=`~/project`,vt=`aindex`,yt=`$SHADOW_PROJECT/dist/skills`,bt=`$SHADOW_PROJECT/dist/commands`,xt=`$SHADOW_PROJECT/dist/agents`,St=`$SHADOW_PROJECT/ref`,Ct=`$SHADOW_PROJECT/dist/GLOBAL.md`,R=jt(/[A-Za-z]/),z=jt(/[\dA-Za-z]/),wt=jt(/[#-'*+\--9=?A-Z^-~]/);function Tt(e){return e!==null&&(e<32||e===127)}const Et=jt(/\d/),Dt=jt(/[\dA-Fa-f]/),Ot=jt(/[!-/:-@[-`{-~]/);function B(e){return e!==null&&e<-2}function V(e){return e!==null&&(e<0||e===32)}function H(e){return e===-2||e===-1||e===32}const kt=jt(/\p{P}|\p{S}/u),At=jt(/\s/);function jt(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}var Mt=y(g(((e,t)=>{(function(){var e=t===void 0?function(){return this||(0,eval)(`this`)}():t.exports=i;e.format=i,e.vsprintf=r,typeof console<`u`&&typeof console.log==`function`&&(e.printf=n);function n(){console.log(i.apply(null,arguments))}function r(e,t){return i.apply(null,[e].concat(t))}function i(e){for(var t=1,n=[].slice.call(arguments),r=0,i=e.length,a=``,o,s=!1,c,l,u=!1,d,f=function(){return n[t++]},p=function(){for(var t=``;/\d/.test(e[r]);)t+=e[r++],o=e[r];return t.length>0?parseInt(t):null};r<i;++r)if(o=e[r],s)switch(s=!1,o==`.`?(u=!1,o=e[++r]):o==`0`&&e[r+1]==`.`?(u=!0,r+=2,o=e[r]):u=!0,d=p(),o){case`b`:a+=parseInt(f(),10).toString(2);break;case`c`:c=f(),typeof c==`string`||c instanceof String?a+=c:a+=String.fromCharCode(parseInt(c,10));break;case`d`:a+=parseInt(f(),10);break;case`f`:l=String(parseFloat(f()).toFixed(d||6)),a+=u?l:l.replace(/^0/,``);break;case`j`:a+=JSON.stringify(f());break;case`o`:a+=`0`+parseInt(f(),10).toString(8);break;case`s`:a+=f();break;case`x`:a+=`0x`+parseInt(f(),10).toString(16);break;case`X`:a+=`0x`+parseInt(f(),10).toString(16).toUpperCase();break;default:a+=o;break}else o===`%`?s=!0:a+=o;return a}})()}))(),1);const Nt=Object.assign(Pt(Error),{eval:Pt(EvalError),range:Pt(RangeError),reference:Pt(ReferenceError),syntax:Pt(SyntaxError),type:Pt(TypeError),uri:Pt(URIError)});function Pt(e){return t.displayName=e.displayName||e.name,t;function t(t,...n){return new e(t&&(0,Mt.default)(t,...n))}}const Ft={}.hasOwnProperty,It={yaml:`-`,toml:`+`};function Lt(e){let t=[],n=-1,r=Array.isArray(e)?e:e?[e]:[`yaml`];for(;++n<r.length;)t[n]=Rt(r[n]);return t}function Rt(e){let t=e;if(typeof t==`string`){if(!Ft.call(It,t))throw Nt("Missing matter definition for `%s`",t);t={type:t,marker:It[t]}}else if(typeof t!=`object`)throw Nt("Expected matter to be an object, not `%j`",t);if(!Ft.call(t,`type`))throw Nt("Missing `type` in matter `%j`",t);if(!Ft.call(t,`fence`)&&!Ft.call(t,`marker`))throw Nt("Missing `marker` or `fence` in matter `%j`",t);return t}function zt(e){let t=Lt(e),n={},r=-1;for(;++r<t.length;){let e=t[r],i=Vt(e,`open`).charCodeAt(0),a=Bt(e),o=n[i];Array.isArray(o)?o.push(a):n[i]=[a]}return{flow:n}}function Bt(e){let t=e.anywhere,n=e.type,r=n+`Fence`,i=r+`Sequence`,a=n+`Value`,o={tokenize:u,partial:!0},s,c=0;return{tokenize:l,concrete:!0};function l(l,u,d){let f=this;return p;function p(a){let o=f.now();return o.column===1&&(o.line===1||t)&&(s=Vt(e,`open`),c=0,a===s.charCodeAt(c))?(l.enter(n),l.enter(r),l.enter(i),m(a)):d(a)}function m(e){return c===s.length?(l.exit(i),H(e)?(l.enter(`whitespace`),h(e)):g(e)):e===s.charCodeAt(c++)?(l.consume(e),m):d(e)}function h(e){return H(e)?(l.consume(e),h):(l.exit(`whitespace`),g(e))}function g(t){return B(t)?(l.exit(r),l.enter(`lineEnding`),l.consume(t),l.exit(`lineEnding`),s=Vt(e,`close`),c=0,l.attempt(o,b,_)):d(t)}function _(e){return e===null||B(e)?y(e):(l.enter(a),v(e))}function v(e){return e===null||B(e)?(l.exit(a),y(e)):(l.consume(e),v)}function y(e){return e===null?d(e):(l.enter(`lineEnding`),l.consume(e),l.exit(`lineEnding`),l.attempt(o,b,_))}function b(e){return l.exit(n),u(e)}}function u(e,t,n){let a=0;return o;function o(t){return t===s.charCodeAt(a)?(e.enter(r),e.enter(i),c(t)):n(t)}function c(t){return a===s.length?(e.exit(i),H(t)?(e.enter(`whitespace`),l(t)):u(t)):t===s.charCodeAt(a++)?(e.consume(t),c):n(t)}function l(t){return H(t)?(e.consume(t),l):(e.exit(`whitespace`),u(t))}function u(i){return i===null||B(i)?(e.exit(r),t(i)):n(i)}}}function Vt(e,t){return e.marker?Ht(e.marker,t).repeat(3):Ht(e.fence,t)}function Ht(e,t){return typeof e==`string`?e:e[t]}function Ut(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function Wt(e){let t=Lt(e),n={},r={},i=-1;for(;++i<t.length;){let e=t[i];n[e.type]=Gt(e),r[e.type]=Kt,r[e.type+`Value`]=qt}return{enter:n,exit:r}}function Gt(e){return t;function t(t){this.enter({type:e.type,value:``},t),this.buffer()}}function Kt(e){let t=this.resume(),n=this.stack[this.stack.length-1];`value`in n,this.exit(e),n.value=t.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``)}function qt(e){this.config.enter.data.call(this,e),this.config.exit.data.call(this,e)}function Jt(e){let t=[],n={},r=Lt(e),i=-1;for(;++i<r.length;){let e=r[i];n[e.type]=Yt(e);let a=Xt(e,`open`);t.push({atBreak:!0,character:a.charAt(0),after:Ut(a.charAt(1))})}return{unsafe:t,handlers:n}}function Yt(e){let t=Xt(e,`open`),n=Xt(e,`close`);return r;function r(e){return t+(e.value?`
|
|
20
|
+
t.exports=r;let n=me();function r(e,t){let r,i,a,o=!0;Array.isArray(e)?(r=[],i=e.length):(a=Object.keys(e),r={},i=a.length);function s(e){function i(){t&&t(e,r),t=null}o?n(i):i()}function c(e,t,n){r[e]=n,(--i===0||t)&&s(t)}i?a?a.forEach(function(t){e[t](function(e,n){c(t,e,n)})}):e.forEach(function(e,t){e(function(e,n){c(t,e,n)})}):s(null),o=!1}})),ge=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.IS_SUPPORT_READDIR_WITH_FILE_TYPES=void 0;let t=process.versions.node.split(`.`);if(t[0]===void 0||t[1]===void 0)throw Error(`Unexpected behavior. The 'process.versions.node' variable has invalid value: ${process.versions.node}`);let n=Number.parseInt(t[0],10),r=Number.parseInt(t[1],10);e.IS_SUPPORT_READDIR_WITH_FILE_TYPES=n>10||n===10&&r>=10})),_e=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createDirentFromStats=void 0;var t=class{constructor(e,t){this.name=e,this.isBlockDevice=t.isBlockDevice.bind(t),this.isCharacterDevice=t.isCharacterDevice.bind(t),this.isDirectory=t.isDirectory.bind(t),this.isFIFO=t.isFIFO.bind(t),this.isFile=t.isFile.bind(t),this.isSocket=t.isSocket.bind(t),this.isSymbolicLink=t.isSymbolicLink.bind(t)}};function n(e,n){return new t(e,n)}e.createDirentFromStats=n})),ve=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fs=void 0,e.fs=_e()})),ye=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.joinPathSegments=void 0;function t(e,t,n){return e.endsWith(n)?e+t:e+n+t}e.joinPathSegments=t})),be=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.readdir=e.readdirWithFileTypes=e.read=void 0;let t=pe(),n=he(),r=ge(),i=ve(),a=ye();function o(e,t,n){if(!t.stats&&r.IS_SUPPORT_READDIR_WITH_FILE_TYPES){s(e,t,n);return}l(e,t,n)}e.read=o;function s(e,t,r){t.fs.readdir(e,{withFileTypes:!0},(i,o)=>{if(i!==null){u(r,i);return}let s=o.map(n=>({dirent:n,name:n.name,path:a.joinPathSegments(e,n.name,t.pathSegmentSeparator)}));if(!t.followSymbolicLinks){d(r,s);return}n(s.map(e=>c(e,t)),(e,t)=>{if(e!==null){u(r,e);return}d(r,t)})})}e.readdirWithFileTypes=s;function c(e,t){return n=>{if(!e.dirent.isSymbolicLink()){n(null,e);return}t.fs.stat(e.path,(r,a)=>{if(r!==null){if(t.throwErrorOnBrokenSymbolicLink){n(r);return}n(null,e);return}e.dirent=i.fs.createDirentFromStats(e.name,a),n(null,e)})}}function l(e,r,o){r.fs.readdir(e,(s,c)=>{if(s!==null){u(o,s);return}n(c.map(n=>{let o=a.joinPathSegments(e,n,r.pathSegmentSeparator);return e=>{t.stat(o,r.fsStatSettings,(t,a)=>{if(t!==null){e(t);return}let s={name:n,path:o,dirent:i.fs.createDirentFromStats(n,a)};r.stats&&(s.stats=a),e(null,s)})}}),(e,t)=>{if(e!==null){u(o,e);return}d(o,t)})})}e.readdir=l;function u(e,t){e(t)}function d(e,t){e(null,t)}})),xe=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.readdir=e.readdirWithFileTypes=e.read=void 0;let t=pe(),n=ge(),r=ve(),i=ye();function a(e,t){return!t.stats&&n.IS_SUPPORT_READDIR_WITH_FILE_TYPES?o(e,t):s(e,t)}e.read=a;function o(e,t){return t.fs.readdirSync(e,{withFileTypes:!0}).map(n=>{let a={dirent:n,name:n.name,path:i.joinPathSegments(e,n.name,t.pathSegmentSeparator)};if(a.dirent.isSymbolicLink()&&t.followSymbolicLinks)try{let e=t.fs.statSync(a.path);a.dirent=r.fs.createDirentFromStats(a.name,e)}catch(e){if(t.throwErrorOnBrokenSymbolicLink)throw e}return a})}e.readdirWithFileTypes=o;function s(e,n){return n.fs.readdirSync(e).map(a=>{let o=i.joinPathSegments(e,a,n.pathSegmentSeparator),s=t.statSync(o,n.fsStatSettings),c={name:a,path:o,dirent:r.fs.createDirentFromStats(a,s)};return n.stats&&(c.stats=s),c})}e.readdir=s})),Se=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createFileSystemAdapter=e.FILE_SYSTEM_ADAPTER=void 0;let t=b(`fs`);e.FILE_SYSTEM_ADAPTER={lstat:t.lstat,stat:t.stat,lstatSync:t.lstatSync,statSync:t.statSync,readdir:t.readdir,readdirSync:t.readdirSync};function n(t){return t===void 0?e.FILE_SYSTEM_ADAPTER:Object.assign(Object.assign({},e.FILE_SYSTEM_ADAPTER),t)}e.createFileSystemAdapter=n})),Ce=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=b(`path`),n=pe(),r=Se();e.default=class{constructor(e={}){this._options=e,this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,!1),this.fs=r.createFileSystemAdapter(this._options.fs),this.pathSegmentSeparator=this._getValue(this._options.pathSegmentSeparator,t.sep),this.stats=this._getValue(this._options.stats,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!0),this.fsStatSettings=new n.Settings({followSymbolicLink:this.followSymbolicLinks,fs:this.fs,throwErrorOnBrokenSymbolicLink:this.throwErrorOnBrokenSymbolicLink})}_getValue(e,t){return e??t}}})),we=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.scandirSync=e.scandir=void 0;let t=be(),n=xe(),r=Ce();e.Settings=r.default;function i(e,n,r){if(typeof n==`function`){t.read(e,o(),n);return}t.read(e,o(n),r)}e.scandir=i;function a(e,t){let r=o(t);return n.read(e,r)}e.scandirSync=a;function o(e={}){return e instanceof r.default?e:new r.default(e)}})),Te=g(((e,t)=>{function n(e){var t=new e,n=t;function r(){var r=t;return r.next?t=r.next:(t=new e,n=t),r.next=null,r}function i(e){n.next=e,n=e}return{get:r,release:i}}t.exports=n})),Ee=g(((e,t)=>{var n=Te();function r(e,t,r){if(typeof e==`function`&&(r=t,t=e,e=null),!(r>=1))throw Error(`fastqueue concurrency must be equal to or greater than 1`);var o=n(a),s=null,c=null,l=0,u=null,d={push:v,drain:i,saturated:i,pause:p,paused:!1,get concurrency(){return r},set concurrency(e){if(!(e>=1))throw Error(`fastqueue concurrency must be equal to or greater than 1`);if(r=e,!d.paused)for(;s&&l<r;)l++,b()},running:f,resume:g,idle:_,length:m,getQueue:h,unshift:y,empty:i,kill:x,killAndDrain:S,error:C};return d;function f(){return l}function p(){d.paused=!0}function m(){for(var e=s,t=0;e;)e=e.next,t++;return t}function h(){for(var e=s,t=[];e;)t.push(e.value),e=e.next;return t}function g(){if(d.paused){if(d.paused=!1,s===null){l++,b();return}for(;s&&l<r;)l++,b()}}function _(){return l===0&&d.length()===0}function v(n,a){var f=o.get();f.context=e,f.release=b,f.value=n,f.callback=a||i,f.errorHandler=u,l>=r||d.paused?c?(c.next=f,c=f):(s=f,c=f,d.saturated()):(l++,t.call(e,f.value,f.worked))}function y(n,a){var f=o.get();f.context=e,f.release=b,f.value=n,f.callback=a||i,f.errorHandler=u,l>=r||d.paused?s?(f.next=s,s=f):(s=f,c=f,d.saturated()):(l++,t.call(e,f.value,f.worked))}function b(n){n&&o.release(n);var i=s;i&&l<=r?d.paused?l--:(c===s&&(c=null),s=i.next,i.next=null,t.call(e,i.value,i.worked),c===null&&d.empty()):--l===0&&d.drain()}function x(){s=null,c=null,d.drain=i}function S(){s=null,c=null,d.drain(),d.drain=i}function C(e){u=e}}function i(){}function a(){this.value=null,this.callback=i,this.next=null,this.release=i,this.context=null,this.errorHandler=null;var e=this;this.worked=function(t,n){var r=e.callback,a=e.errorHandler,o=e.value;e.value=null,e.callback=i,e.errorHandler&&a(t,o),r.call(e.context,t,n),e.release(e)}}function o(e,t,n){typeof e==`function`&&(n=t,t=e,e=null);function a(e,n){t.call(this,e).then(function(e){n(null,e)},n)}var o=r(e,a,n),s=o.push,c=o.unshift;return o.push=l,o.unshift=u,o.drained=d,o;function l(e){var t=new Promise(function(t,n){s(e,function(e,r){if(e){n(e);return}t(r)})});return t.catch(i),t}function u(e){var t=new Promise(function(t,n){c(e,function(e,r){if(e){n(e);return}t(r)})});return t.catch(i),t}function d(){return new Promise(function(e){process.nextTick(function(){if(o.idle())e();else{var t=o.drain;o.drain=function(){typeof t==`function`&&t(),e(),o.drain=t}}})})}}t.exports=r,t.exports.promise=o})),De=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.joinPathSegments=e.replacePathSegmentSeparator=e.isAppliedFilter=e.isFatalError=void 0;function t(e,t){return e.errorFilter===null?!0:!e.errorFilter(t)}e.isFatalError=t;function n(e,t){return e===null||e(t)}e.isAppliedFilter=n;function r(e,t){return e.split(/[/\\]/).join(t)}e.replacePathSegmentSeparator=r;function i(e,t,n){return e===``?t:e.endsWith(n)?e+t:e+n+t}e.joinPathSegments=i})),Oe=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=De();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._root=t.replacePathSegmentSeparator(e,n.pathSegmentSeparator)}}})),ke=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=b(`events`),n=we(),r=Ee(),i=De(),a=Oe();e.default=class extends a.default{constructor(e,i){super(e,i),this._settings=i,this._scandir=n.scandir,this._emitter=new t.EventEmitter,this._queue=r(this._worker.bind(this),this._settings.concurrency),this._isFatalError=!1,this._isDestroyed=!1,this._queue.drain=()=>{this._isFatalError||this._emitter.emit(`end`)}}read(){return this._isFatalError=!1,this._isDestroyed=!1,setImmediate(()=>{this._pushToQueue(this._root,this._settings.basePath)}),this._emitter}get isDestroyed(){return this._isDestroyed}destroy(){if(this._isDestroyed)throw Error(`The reader is already destroyed`);this._isDestroyed=!0,this._queue.killAndDrain()}onEntry(e){this._emitter.on(`entry`,e)}onError(e){this._emitter.once(`error`,e)}onEnd(e){this._emitter.once(`end`,e)}_pushToQueue(e,t){let n={directory:e,base:t};this._queue.push(n,e=>{e!==null&&this._handleError(e)})}_worker(e,t){this._scandir(e.directory,this._settings.fsScandirSettings,(n,r)=>{if(n!==null){t(n,void 0);return}for(let t of r)this._handleEntry(t,e.base);t(null,void 0)})}_handleError(e){this._isDestroyed||!i.isFatalError(this._settings,e)||(this._isFatalError=!0,this._isDestroyed=!0,this._emitter.emit(`error`,e))}_handleEntry(e,t){if(this._isDestroyed||this._isFatalError)return;let n=e.path;t!==void 0&&(e.path=i.joinPathSegments(t,e.name,this._settings.pathSegmentSeparator)),i.isAppliedFilter(this._settings.entryFilter,e)&&this._emitEntry(e),e.dirent.isDirectory()&&i.isAppliedFilter(this._settings.deepFilter,e)&&this._pushToQueue(n,t===void 0?void 0:e.path)}_emitEntry(e){this._emitter.emit(`entry`,e)}}})),Ae=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ke();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._reader=new t.default(this._root,this._settings),this._storage=[]}read(e){this._reader.onError(t=>{n(e,t)}),this._reader.onEntry(e=>{this._storage.push(e)}),this._reader.onEnd(()=>{r(e,this._storage)}),this._reader.read()}};function n(e,t){e(t)}function r(e,t){e(null,t)}})),je=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=b(`stream`),n=ke();e.default=class{constructor(e,r){this._root=e,this._settings=r,this._reader=new n.default(this._root,this._settings),this._stream=new t.Readable({objectMode:!0,read:()=>{},destroy:()=>{this._reader.isDestroyed||this._reader.destroy()}})}read(){return this._reader.onError(e=>{this._stream.emit(`error`,e)}),this._reader.onEntry(e=>{this._stream.push(e)}),this._reader.onEnd(()=>{this._stream.push(null)}),this._reader.read(),this._stream}}})),Me=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=we(),n=De(),r=Oe();e.default=class extends r.default{constructor(){super(...arguments),this._scandir=t.scandirSync,this._storage=[],this._queue=new Set}read(){return this._pushToQueue(this._root,this._settings.basePath),this._handleQueue(),this._storage}_pushToQueue(e,t){this._queue.add({directory:e,base:t})}_handleQueue(){for(let e of this._queue.values())this._handleDirectory(e.directory,e.base)}_handleDirectory(e,t){try{let n=this._scandir(e,this._settings.fsScandirSettings);for(let e of n)this._handleEntry(e,t)}catch(e){this._handleError(e)}}_handleError(e){if(n.isFatalError(this._settings,e))throw e}_handleEntry(e,t){let r=e.path;t!==void 0&&(e.path=n.joinPathSegments(t,e.name,this._settings.pathSegmentSeparator)),n.isAppliedFilter(this._settings.entryFilter,e)&&this._pushToStorage(e),e.dirent.isDirectory()&&n.isAppliedFilter(this._settings.deepFilter,e)&&this._pushToQueue(r,t===void 0?void 0:e.path)}_pushToStorage(e){this._storage.push(e)}}})),Ne=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Me();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._reader=new t.default(this._root,this._settings)}read(){return this._reader.read()}}})),Pe=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=b(`path`),n=we();e.default=class{constructor(e={}){this._options=e,this.basePath=this._getValue(this._options.basePath,void 0),this.concurrency=this._getValue(this._options.concurrency,1/0),this.deepFilter=this._getValue(this._options.deepFilter,null),this.entryFilter=this._getValue(this._options.entryFilter,null),this.errorFilter=this._getValue(this._options.errorFilter,null),this.pathSegmentSeparator=this._getValue(this._options.pathSegmentSeparator,t.sep),this.fsScandirSettings=new n.Settings({followSymbolicLinks:this._options.followSymbolicLinks,fs:this._options.fs,pathSegmentSeparator:this._options.pathSegmentSeparator,stats:this._options.stats,throwErrorOnBrokenSymbolicLink:this._options.throwErrorOnBrokenSymbolicLink})}_getValue(e,t){return e??t}}})),Fe=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.walkStream=e.walkSync=e.walk=void 0;let t=Ae(),n=je(),r=Ne(),i=Pe();e.Settings=i.default;function a(e,n,r){if(typeof n==`function`){new t.default(e,c()).read(n);return}new t.default(e,c(n)).read(r)}e.walk=a;function o(e,t){let n=c(t);return new r.default(e,n).read()}e.walkSync=o;function s(e,t){let r=c(t);return new n.default(e,r).read()}e.walkStream=s;function c(e={}){return e instanceof i.default?e:new i.default(e)}})),Ie=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=b(`path`),n=pe(),r=se();e.default=class{constructor(e){this._settings=e,this._fsStatSettings=new n.Settings({followSymbolicLink:this._settings.followSymbolicLinks,fs:this._settings.fs,throwErrorOnBrokenSymbolicLink:this._settings.followSymbolicLinks})}_getFullEntryPath(e){return t.resolve(this._settings.cwd,e)}_makeEntry(e,t){let n={name:t,path:t,dirent:r.fs.createDirentFromStats(t,e)};return this._settings.stats&&(n.stats=e),n}_isFatalError(e){return!r.errno.isEnoentCodeError(e)&&!this._settings.suppressErrors}}})),Le=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=b(`stream`),n=pe(),r=Fe(),i=Ie();e.default=class extends i.default{constructor(){super(...arguments),this._walkStream=r.walkStream,this._stat=n.stat}dynamic(e,t){return this._walkStream(e,t)}static(e,n){let r=e.map(this._getFullEntryPath,this),i=new t.PassThrough({objectMode:!0});i._write=(t,a,o)=>this._getEntry(r[t],e[t],n).then(e=>{e!==null&&n.entryFilter(e)&&i.push(e),t===r.length-1&&i.end(),o()}).catch(o);for(let e=0;e<r.length;e++)i.write(e);return i}_getEntry(e,t,n){return this._getStat(e).then(e=>this._makeEntry(e,t)).catch(e=>{if(n.errorFilter(e))return null;throw e})}_getStat(e){return new Promise((t,n)=>{this._stat(e,this._fsStatSettings,(e,r)=>e===null?t(r):n(e))})}}})),Re=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Fe(),n=Ie(),r=Le();e.default=class extends n.default{constructor(){super(...arguments),this._walkAsync=t.walk,this._readerStream=new r.default(this._settings)}dynamic(e,t){return new Promise((n,r)=>{this._walkAsync(e,t,(e,t)=>{e===null?n(t):r(e)})})}async static(e,t){let n=[],r=this._readerStream.static(e,t);return new Promise((e,t)=>{r.once(`error`,t),r.on(`data`,e=>n.push(e)),r.once(`end`,()=>e(n))})}}})),ze=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=se();e.default=class{constructor(e,t,n){this._patterns=e,this._settings=t,this._micromatchOptions=n,this._storage=[],this._fillStorage()}_fillStorage(){for(let e of this._patterns){let t=this._getPatternSegments(e),n=this._splitSegmentsIntoSections(t);this._storage.push({complete:n.length<=1,pattern:e,segments:t,sections:n})}}_getPatternSegments(e){return t.pattern.getPatternParts(e,this._micromatchOptions).map(e=>t.pattern.isDynamicPattern(e,this._settings)?{dynamic:!0,pattern:e,patternRe:t.pattern.makeRe(e,this._micromatchOptions)}:{dynamic:!1,pattern:e})}_splitSegmentsIntoSections(e){return t.array.splitWhen(e,e=>e.dynamic&&t.pattern.hasGlobStar(e.pattern))}}})),Be=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ze();e.default=class extends t.default{match(e){let t=e.split(`/`),n=t.length,r=this._storage.filter(e=>!e.complete||e.segments.length>n);for(let e of r){let r=e.sections[0];if(!e.complete&&n>r.length||t.every((t,n)=>{let r=e.segments[n];return!!(r.dynamic&&r.patternRe.test(t)||!r.dynamic&&r.pattern===t)}))return!0}return!1}}})),Ve=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=se(),n=Be();e.default=class{constructor(e,t){this._settings=e,this._micromatchOptions=t}getFilter(e,t,n){let r=this._getMatcher(t),i=this._getNegativePatternsRe(n);return t=>this._filter(e,t,r,i)}_getMatcher(e){return new n.default(e,this._settings,this._micromatchOptions)}_getNegativePatternsRe(e){let n=e.filter(t.pattern.isAffectDepthOfReadingPattern);return t.pattern.convertPatternsToRe(n,this._micromatchOptions)}_filter(e,n,r,i){if(this._isSkippedByDeep(e,n.path)||this._isSkippedSymbolicLink(n))return!1;let a=t.path.removeLeadingDotSegment(n.path);return this._isSkippedByPositivePatterns(a,r)?!1:this._isSkippedByNegativePatterns(a,i)}_isSkippedByDeep(e,t){return this._settings.deep===1/0?!1:this._getEntryLevel(e,t)>=this._settings.deep}_getEntryLevel(e,t){let n=t.split(`/`).length;return e===``?n:n-e.split(`/`).length}_isSkippedSymbolicLink(e){return!this._settings.followSymbolicLinks&&e.dirent.isSymbolicLink()}_isSkippedByPositivePatterns(e,t){return!this._settings.baseNameMatch&&!t.match(e)}_isSkippedByNegativePatterns(e,n){return!t.pattern.matchAny(e,n)}}})),He=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=se();e.default=class{constructor(e,t){this._settings=e,this._micromatchOptions=t,this.index=new Map}getFilter(e,n){let[r,i]=t.pattern.partitionAbsoluteAndRelative(n),a={positive:{all:t.pattern.convertPatternsToRe(e,this._micromatchOptions)},negative:{absolute:t.pattern.convertPatternsToRe(r,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0})),relative:t.pattern.convertPatternsToRe(i,Object.assign(Object.assign({},this._micromatchOptions),{dot:!0}))}};return e=>this._filter(e,a)}_filter(e,n){let r=t.path.removeLeadingDotSegment(e.path);if(this._settings.unique&&this._isDuplicateEntry(r)||this._onlyFileFilter(e)||this._onlyDirectoryFilter(e))return!1;let i=this._isMatchToPatternsSet(r,n,e.dirent.isDirectory());return this._settings.unique&&i&&this._createIndexRecord(r),i}_isDuplicateEntry(e){return this.index.has(e)}_createIndexRecord(e){this.index.set(e,void 0)}_onlyFileFilter(e){return this._settings.onlyFiles&&!e.dirent.isFile()}_onlyDirectoryFilter(e){return this._settings.onlyDirectories&&!e.dirent.isDirectory()}_isMatchToPatternsSet(e,t,n){return!(!this._isMatchToPatterns(e,t.positive.all,n)||this._isMatchToPatterns(e,t.negative.relative,n)||this._isMatchToAbsoluteNegative(e,t.negative.absolute,n))}_isMatchToAbsoluteNegative(e,n,r){if(n.length===0)return!1;let i=t.path.makeAbsolute(this._settings.cwd,e);return this._isMatchToPatterns(i,n,r)}_isMatchToPatterns(e,n,r){if(n.length===0)return!1;let i=t.pattern.matchAny(e,n);return!i&&r?t.pattern.matchAny(e+`/`,n):i}}})),Ue=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=se();e.default=class{constructor(e){this._settings=e}getFilter(){return e=>this._isNonFatalError(e)}_isNonFatalError(e){return t.errno.isEnoentCodeError(e)||this._settings.suppressErrors}}})),We=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=se();e.default=class{constructor(e){this._settings=e}getTransformer(){return e=>this._transform(e)}_transform(e){let n=e.path;return this._settings.absolute&&(n=t.path.makeAbsolute(this._settings.cwd,n),n=t.path.unixify(n)),this._settings.markDirectories&&e.dirent.isDirectory()&&(n+=`/`),this._settings.objectMode?Object.assign(Object.assign({},e),{path:n}):n}}})),Ge=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=b(`path`),n=Ve(),r=He(),i=Ue(),a=We();e.default=class{constructor(e){this._settings=e,this.errorFilter=new i.default(this._settings),this.entryFilter=new r.default(this._settings,this._getMicromatchOptions()),this.deepFilter=new n.default(this._settings,this._getMicromatchOptions()),this.entryTransformer=new a.default(this._settings)}_getRootDirectory(e){return t.resolve(this._settings.cwd,e.base)}_getReaderOptions(e){let t=e.base===`.`?``:e.base;return{basePath:t,pathSegmentSeparator:`/`,concurrency:this._settings.concurrency,deepFilter:this.deepFilter.getFilter(t,e.positive,e.negative),entryFilter:this.entryFilter.getFilter(e.positive,e.negative),errorFilter:this.errorFilter.getFilter(),followSymbolicLinks:this._settings.followSymbolicLinks,fs:this._settings.fs,stats:this._settings.stats,throwErrorOnBrokenSymbolicLink:this._settings.throwErrorOnBrokenSymbolicLink,transform:this.entryTransformer.getTransformer()}}_getMicromatchOptions(){return{dot:this._settings.dot,matchBase:this._settings.baseNameMatch,nobrace:!this._settings.braceExpansion,nocase:!this._settings.caseSensitiveMatch,noext:!this._settings.extglob,noglobstar:!this._settings.globstar,posix:!0,strictSlashes:!1}}}})),Ke=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Re(),n=Ge();e.default=class extends n.default{constructor(){super(...arguments),this._reader=new t.default(this._settings)}async read(e){let t=this._getRootDirectory(e),n=this._getReaderOptions(e);return(await this.api(t,e,n)).map(e=>n.transform(e))}api(e,t,n){return t.dynamic?this._reader.dynamic(e,n):this._reader.static(t.patterns,n)}}})),qe=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=b(`stream`),n=Le(),r=Ge();e.default=class extends r.default{constructor(){super(...arguments),this._reader=new n.default(this._settings)}read(e){let n=this._getRootDirectory(e),r=this._getReaderOptions(e),i=this.api(n,e,r),a=new t.Readable({objectMode:!0,read:()=>{}});return i.once(`error`,e=>a.emit(`error`,e)).on(`data`,e=>a.emit(`data`,r.transform(e))).once(`end`,()=>a.emit(`end`)),a.once(`close`,()=>i.destroy()),a}api(e,t,n){return t.dynamic?this._reader.dynamic(e,n):this._reader.static(t.patterns,n)}}})),Je=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=pe(),n=Fe(),r=Ie();e.default=class extends r.default{constructor(){super(...arguments),this._walkSync=n.walkSync,this._statSync=t.statSync}dynamic(e,t){return this._walkSync(e,t)}static(e,t){let n=[];for(let r of e){let e=this._getFullEntryPath(r),i=this._getEntry(e,r,t);i===null||!t.entryFilter(i)||n.push(i)}return n}_getEntry(e,t,n){try{let n=this._getStat(e);return this._makeEntry(n,t)}catch(e){if(n.errorFilter(e))return null;throw e}}_getStat(e){return this._statSync(e,this._fsStatSettings)}}})),Ye=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Je(),n=Ge();e.default=class extends n.default{constructor(){super(...arguments),this._reader=new t.default(this._settings)}read(e){let t=this._getRootDirectory(e),n=this._getReaderOptions(e);return this.api(t,e,n).map(n.transform)}api(e,t,n){return t.dynamic?this._reader.dynamic(e,n):this._reader.static(t.patterns,n)}}})),Xe=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DEFAULT_FILE_SYSTEM_ADAPTER=void 0;let t=b(`fs`),n=b(`os`),r=Math.max(n.cpus().length,1);e.DEFAULT_FILE_SYSTEM_ADAPTER={lstat:t.lstat,lstatSync:t.lstatSync,stat:t.stat,statSync:t.statSync,readdir:t.readdir,readdirSync:t.readdirSync},e.default=class{constructor(e={}){this._options=e,this.absolute=this._getValue(this._options.absolute,!1),this.baseNameMatch=this._getValue(this._options.baseNameMatch,!1),this.braceExpansion=this._getValue(this._options.braceExpansion,!0),this.caseSensitiveMatch=this._getValue(this._options.caseSensitiveMatch,!0),this.concurrency=this._getValue(this._options.concurrency,r),this.cwd=this._getValue(this._options.cwd,process.cwd()),this.deep=this._getValue(this._options.deep,1/0),this.dot=this._getValue(this._options.dot,!1),this.extglob=this._getValue(this._options.extglob,!0),this.followSymbolicLinks=this._getValue(this._options.followSymbolicLinks,!0),this.fs=this._getFileSystemMethods(this._options.fs),this.globstar=this._getValue(this._options.globstar,!0),this.ignore=this._getValue(this._options.ignore,[]),this.markDirectories=this._getValue(this._options.markDirectories,!1),this.objectMode=this._getValue(this._options.objectMode,!1),this.onlyDirectories=this._getValue(this._options.onlyDirectories,!1),this.onlyFiles=this._getValue(this._options.onlyFiles,!0),this.stats=this._getValue(this._options.stats,!1),this.suppressErrors=this._getValue(this._options.suppressErrors,!1),this.throwErrorOnBrokenSymbolicLink=this._getValue(this._options.throwErrorOnBrokenSymbolicLink,!1),this.unique=this._getValue(this._options.unique,!0),this.onlyDirectories&&(this.onlyFiles=!1),this.stats&&(this.objectMode=!0),this.ignore=[].concat(this.ignore)}_getValue(e,t){return e===void 0?t:e}_getFileSystemMethods(t={}){return Object.assign(Object.assign({},e.DEFAULT_FILE_SYSTEM_ADAPTER),t)}}})),Ze=y(g(((e,t)=>{let n=ce(),r=Ke(),i=qe(),a=Ye(),o=Xe(),s=se();async function c(e,t){u(e);let n=l(e,r.default,t),i=await Promise.all(n);return s.array.flatten(i)}(function(e){e.glob=e,e.globSync=t,e.globStream=r,e.async=e;function t(e,t){u(e);let n=l(e,a.default,t);return s.array.flatten(n)}e.sync=t;function r(e,t){u(e);let n=l(e,i.default,t);return s.stream.merge(n)}e.stream=r;function c(e,t){u(e);let r=[].concat(e),i=new o.default(t);return n.generate(r,i)}e.generateTasks=c;function d(e,t){u(e);let n=new o.default(t);return s.pattern.isDynamicPattern(e,n)}e.isDynamicPattern=d;function f(e){return u(e),s.path.escape(e)}e.escapePath=f;function p(e){return u(e),s.path.convertPathToPattern(e)}e.convertPathToPattern=p,(function(e){function t(e){return u(e),s.path.escapePosixPath(e)}e.escapePath=t;function n(e){return u(e),s.path.convertPosixPathToPattern(e)}e.convertPathToPattern=n})(e.posix||={}),(function(e){function t(e){return u(e),s.path.escapeWindowsPath(e)}e.escapePath=t;function n(e){return u(e),s.path.convertWindowsPathToPattern(e)}e.convertPathToPattern=n})(e.win32||={})})(c||={});function l(e,t,r){let i=[].concat(e),a=new o.default(r),s=n.generate(i,a),c=new t(a);return s.map(c.read,c)}function u(e){if(![].concat(e).every(e=>s.string.isString(e)&&!s.string.isEmpty(e)))throw TypeError(`Patterns must be a string (non empty) or an array of strings`)}t.exports=c}))(),1);async function Qe(e,t){let n=[],r=[],i=[],a=[];for(let o of e)o.registerProjectOutputDirs&&n.push(...await o.registerProjectOutputDirs(t)),o.registerProjectOutputFiles&&r.push(...await o.registerProjectOutputFiles(t)),o.registerGlobalOutputDirs&&i.push(...await o.registerGlobalOutputDirs(t)),o.registerGlobalOutputFiles&&a.push(...await o.registerGlobalOutputFiles(t));return{projectDirs:n,projectFiles:r,globalDirs:i,globalFiles:a}}async function $e(e,t){let n=new Map;for(let r of e)n.set(r.name,{project:await r.canCleanProject?.(t)??!0,global:await r.canCleanGlobal?.(t)??!0});return n}async function et(e,t){for(let n of e)await n.onCleanComplete?.(t)}async function tt(e,t){let n=new Map;for(let r of e){let e=await r.canWrite?.(t)??!0;n.set(r.name,{project:e,global:e})}return n}async function nt(e,t){let n=new Map;for(let r of e){let e=await r.writeProjectOutputs?.(t)??{files:[],dirs:[]},i=await r.writeGlobalOutputs?.(t)??{files:[],dirs:[]},a={files:[...e.files,...i.files],dirs:[...e.dirs,...i.dirs]};n.set(r.name,a),await r.onWriteComplete?.(t,a)}return n}async function rt(e,t,n){let r=[],i=[];for(let a of e){let e=t.get(a.name);if(e?.project){let e=await a.registerProjectOutputFiles?.(n)??[],t=await a.registerProjectOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}if(e?.global){let e=await a.registerGlobalOutputFiles?.(n)??[],t=await a.registerGlobalOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}}return{filesToDelete:r,dirsToDelete:i}}function it(e,t){let n=0,a=[];for(let o of e){let e=i.isAbsolute(o)?o:i.resolve(o);try{r.existsSync(e)&&(r.unlinkSync(e),t.info(`deleted file`,{path:e}),n++)}catch(n){let r=n instanceof Error?n.message:String(n);t.warn(`failed to delete file`,{path:e,error:r}),a.push({path:e,type:`file`,error:n})}}return{deleted:n,errors:a}}function at(e,t){let n=0,a=[],o=[...e].sort((e,t)=>t.length-e.length);for(let e of o){let o=i.isAbsolute(e)?e:i.resolve(e);try{r.existsSync(o)&&(r.rmSync(o,{recursive:!0,force:!0}),t.info(`deleted directory`,{path:o}),n++)}catch(e){let n=e instanceof Error?e.message:String(e);t.warn(`failed to delete directory`,{path:o,error:n}),a.push({path:o,type:`directory`,error:e})}}return{deleted:n,errors:a}}async function ot(e,t,n,r){let{executeHooks:i=!0}=r??{},a=await Qe(e,t);n.debug(`Collected outputs for cleanup`,{projectDirs:a.projectDirs.length,projectFiles:a.projectFiles.length,globalDirs:a.globalDirs.length,globalFiles:a.globalFiles.length});let{filesToDelete:o,dirsToDelete:s}=await rt(e,await $e(e,t),t),c=it(o,n),l=at(s,n);return i&&await et(e,t),{deletedFiles:c.deleted,deletedDirs:l.deleted,errors:[...c.errors,...l.errors]}}var st=class{name=`clean`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r}=e;t.info(`running clean pipeline`,{command:`clean`});let i=await ot(n,r(!1),t);return t.info(`clean complete`,{deletedFiles:i.deletedFiles,deletedDirs:i.deletedDirs}),{success:!0,filesAffected:i.deletedFiles,dirsAffected:i.deletedDirs}}};let ct=function(e){return e.Input=`Input`,e.Output=`Output`,e}({}),lt=function(e){return e.GlobalMemory=`GlobalMemory`,e.ProjectRootMemory=`ProjectRootMemory`,e.ProjectChildrenMemory=`ProjectChildrenMemory`,e.FastCommand=`FastCommand`,e.SubAgent=`SubAgent`,e.Skill=`Skill`,e.SkillReferenceDocument=`SkillReferenceDocument`,e.Readme=`Readme`,e}({}),ut=function(e){return e.Red=`Red`,e.Green=`Green`,e.Blue=`Blue`,e.Yellow=`Yellow`,e}({}),dt=function(e){return e.Read=`Read`,e.Write=`Write`,e.Edit=`Edit`,e.Grep=`Grep`,e}({}),ft=function(e){return e.CamelCase=`CamelCase`,e.PascalCase=`PascalCase`,e.SnakeCase=`SnakeCase`,e.KebabCase=`KebabCase`,e.UpperCase=`UpperCase`,e.LowerCase=`LowerCase`,e.Original=`Original`,e}({}),pt=function(e){return e.UserHome=`UserHome`,e.External=`External`,e}({}),I=function(e){return e.Relative=`Relative`,e.Absolute=`Absolute`,e.Root=`Root`,e}({}),L=function(e){return e.VSCode=`VSCode`,e.IntellijIDEA=`IntellijIDEA`,e.Git=`Git`,e.EditorConfig=`EditorConfig`,e.Original=`Original`,e}({});var mt=class extends Error{constructor(e){super(`Circular dependency detected: ${e.join(` -> `)}`),this.cycle=e,this.name=`CircularDependencyError`}},ht=class extends Error{constructor(e,t){super(`Plugin "${e}" depends on non-existent plugin "${t}"`),this.pluginName=e,this.missingDependency=t,this.name=`MissingDependencyError`}};const gt={USER_HOME:`~`,WORKSPACE:`$WORKSPACE`,SHADOW_PROJECT:`$SHADOW_PROJECT`},_t=`~/project`,vt=`aindex`,yt=`$SHADOW_PROJECT/dist/skills`,bt=`$SHADOW_PROJECT/dist/commands`,xt=`$SHADOW_PROJECT/dist/agents`,St=`$SHADOW_PROJECT/ref`,Ct=`$SHADOW_PROJECT/dist/GLOBAL.md`,R=jt(/[A-Za-z]/),z=jt(/[\dA-Za-z]/),wt=jt(/[#-'*+\--9=?A-Z^-~]/);function Tt(e){return e!==null&&(e<32||e===127)}const Et=jt(/\d/),Dt=jt(/[\dA-Fa-f]/),Ot=jt(/[!-/:-@[-`{-~]/);function B(e){return e!==null&&e<-2}function V(e){return e!==null&&(e<0||e===32)}function H(e){return e===-2||e===-1||e===32}const kt=jt(/\p{P}|\p{S}/u),At=jt(/\s/);function jt(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}var Mt=y(g(((e,t)=>{(function(){var e=t===void 0?function(){return this||(0,eval)(`this`)}():t.exports=i;e.format=i,e.vsprintf=r,typeof console<`u`&&typeof console.log==`function`&&(e.printf=n);function n(){console.log(i.apply(null,arguments))}function r(e,t){return i.apply(null,[e].concat(t))}function i(e){for(var t=1,n=[].slice.call(arguments),r=0,i=e.length,a=``,o,s=!1,c,l,u=!1,d,f=function(){return n[t++]},p=function(){for(var t=``;/\d/.test(e[r]);)t+=e[r++],o=e[r];return t.length>0?parseInt(t):null};r<i;++r)if(o=e[r],s)switch(s=!1,o==`.`?(u=!1,o=e[++r]):o==`0`&&e[r+1]==`.`?(u=!0,r+=2,o=e[r]):u=!0,d=p(),o){case`b`:a+=parseInt(f(),10).toString(2);break;case`c`:c=f(),typeof c==`string`||c instanceof String?a+=c:a+=String.fromCharCode(parseInt(c,10));break;case`d`:a+=parseInt(f(),10);break;case`f`:l=String(parseFloat(f()).toFixed(d||6)),a+=u?l:l.replace(/^0/,``);break;case`j`:a+=JSON.stringify(f());break;case`o`:a+=`0`+parseInt(f(),10).toString(8);break;case`s`:a+=f();break;case`x`:a+=`0x`+parseInt(f(),10).toString(16);break;case`X`:a+=`0x`+parseInt(f(),10).toString(16).toUpperCase();break;default:a+=o;break}else o===`%`?s=!0:a+=o;return a}})()}))(),1);const Nt=Object.assign(Pt(Error),{eval:Pt(EvalError),range:Pt(RangeError),reference:Pt(ReferenceError),syntax:Pt(SyntaxError),type:Pt(TypeError),uri:Pt(URIError)});function Pt(e){return t.displayName=e.displayName||e.name,t;function t(t,...n){return new e(t&&(0,Mt.default)(t,...n))}}const Ft={}.hasOwnProperty,It={yaml:`-`,toml:`+`};function Lt(e){let t=[],n=-1,r=Array.isArray(e)?e:e?[e]:[`yaml`];for(;++n<r.length;)t[n]=Rt(r[n]);return t}function Rt(e){let t=e;if(typeof t==`string`){if(!Ft.call(It,t))throw Nt("Missing matter definition for `%s`",t);t={type:t,marker:It[t]}}else if(typeof t!=`object`)throw Nt("Expected matter to be an object, not `%j`",t);if(!Ft.call(t,`type`))throw Nt("Missing `type` in matter `%j`",t);if(!Ft.call(t,`fence`)&&!Ft.call(t,`marker`))throw Nt("Missing `marker` or `fence` in matter `%j`",t);return t}function zt(e){let t=Lt(e),n={},r=-1;for(;++r<t.length;){let e=t[r],i=Vt(e,`open`).charCodeAt(0),a=Bt(e),o=n[i];Array.isArray(o)?o.push(a):n[i]=[a]}return{flow:n}}function Bt(e){let t=e.anywhere,n=e.type,r=n+`Fence`,i=r+`Sequence`,a=n+`Value`,o={tokenize:u,partial:!0},s,c=0;return{tokenize:l,concrete:!0};function l(l,u,d){let f=this;return p;function p(a){let o=f.now();return o.column===1&&(o.line===1||t)&&(s=Vt(e,`open`),c=0,a===s.charCodeAt(c))?(l.enter(n),l.enter(r),l.enter(i),m(a)):d(a)}function m(e){return c===s.length?(l.exit(i),H(e)?(l.enter(`whitespace`),h(e)):g(e)):e===s.charCodeAt(c++)?(l.consume(e),m):d(e)}function h(e){return H(e)?(l.consume(e),h):(l.exit(`whitespace`),g(e))}function g(t){return B(t)?(l.exit(r),l.enter(`lineEnding`),l.consume(t),l.exit(`lineEnding`),s=Vt(e,`close`),c=0,l.attempt(o,b,_)):d(t)}function _(e){return e===null||B(e)?y(e):(l.enter(a),v(e))}function v(e){return e===null||B(e)?(l.exit(a),y(e)):(l.consume(e),v)}function y(e){return e===null?d(e):(l.enter(`lineEnding`),l.consume(e),l.exit(`lineEnding`),l.attempt(o,b,_))}function b(e){return l.exit(n),u(e)}}function u(e,t,n){let a=0;return o;function o(t){return t===s.charCodeAt(a)?(e.enter(r),e.enter(i),c(t)):n(t)}function c(t){return a===s.length?(e.exit(i),H(t)?(e.enter(`whitespace`),l(t)):u(t)):t===s.charCodeAt(a++)?(e.consume(t),c):n(t)}function l(t){return H(t)?(e.consume(t),l):(e.exit(`whitespace`),u(t))}function u(i){return i===null||B(i)?(e.exit(r),t(i)):n(i)}}}function Vt(e,t){return e.marker?Ht(e.marker,t).repeat(3):Ht(e.fence,t)}function Ht(e,t){return typeof e==`string`?e:e[t]}function Ut(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function Wt(e){let t=Lt(e),n={},r={},i=-1;for(;++i<t.length;){let e=t[i];n[e.type]=Gt(e),r[e.type]=Kt,r[e.type+`Value`]=qt}return{enter:n,exit:r}}function Gt(e){return t;function t(t){this.enter({type:e.type,value:``},t),this.buffer()}}function Kt(e){let t=this.resume(),n=this.stack[this.stack.length-1];`value`in n,this.exit(e),n.value=t.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``)}function qt(e){this.config.enter.data.call(this,e),this.config.exit.data.call(this,e)}function Jt(e){let t=[],n={},r=Lt(e),i=-1;for(;++i<r.length;){let e=r[i];n[e.type]=Yt(e);let a=Xt(e,`open`);t.push({atBreak:!0,character:a.charAt(0),after:Ut(a.charAt(1))})}return{unsafe:t,handlers:n}}function Yt(e){let t=Xt(e,`open`),n=Xt(e,`close`);return r;function r(e){return t+(e.value?`
|
|
21
21
|
`+e.value:``)+`
|
|
22
22
|
`+n}}function Xt(e,t){return e.marker?Zt(e.marker,t).repeat(3):Zt(e.fence,t)}function Zt(e,t){return typeof e==`string`?e:e[t]}function Qt(e){let t=this,n=e||`yaml`,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(zt(n)),a.push(Wt(n)),o.push(Jt(n))}function $t(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}const en=(function(e){if(e==null)return on;if(typeof e==`function`)return an(e);if(typeof e==`object`)return Array.isArray(e)?tn(e):nn(e);if(typeof e==`string`)return rn(e);throw Error(`Expected function, string, or object as test`)});function tn(e){let t=[],n=-1;for(;++n<e.length;)t[n]=en(e[n]);return an(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function nn(e){let t=e;return an(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function rn(e){return an(t);function t(t){return t&&t.type===e}}function an(e){return t;function t(t,n,r){return!!(sn(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function on(){return!0}function sn(e){return typeof e==`object`&&!!e&&`type`in e}function cn(e){return`\x1B[33m`+e+`\x1B[39m`}const ln=[];function un(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=en(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,`name`,{value:`node (`+cn(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=ln,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=dn(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function dn(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?ln:[e]}function fn(e,t,n){let r=en((n||{}).ignore||[]),i=pn(t),a=-1;for(;++a<i.length;)un(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function pn(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([mn(e[0]),hn(e[1])])}return t}function mn(e){return typeof e==`string`?new RegExp(Ut(e),`g`):e}function hn(e){return typeof e==`function`?e:function(){return e}}const gn=`phrasing`,_n=[`autolink`,`link`,`image`,`label`];function vn(){return{transforms:[En],enter:{literalAutolink:bn,literalAutolinkEmail:xn,literalAutolinkHttp:xn,literalAutolinkWww:xn},exit:{literalAutolink:Tn,literalAutolinkEmail:wn,literalAutolinkHttp:Sn,literalAutolinkWww:Cn}}}function yn(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:gn,notInConstruct:_n},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:gn,notInConstruct:_n},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:gn,notInConstruct:_n}]}}function bn(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function xn(e){this.config.enter.autolinkProtocol.call(this,e)}function Sn(e){this.config.exit.autolinkProtocol.call(this,e)}function Cn(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function wn(e){this.config.exit.autolinkEmail.call(this,e)}function Tn(e){this.exit(e)}function En(e){fn(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Dn],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,On]],{ignore:[`link`,`linkReference`]})}function Dn(e,t,n,r,i){let a=``;if(!jn(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!kn(n)))return!1;let o=An(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function On(e,t,n,r){return!jn(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function kn(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function An(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=$t(e,`(`),a=$t(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function jn(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||At(n)||kt(n))&&(!t||n!==47)}function Mn(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}Hn.peek=Vn;function Nn(){this.buffer()}function Pn(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Fn(){this.buffer()}function In(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function Ln(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Mn(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Rn(e){this.exit(e)}function zn(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Mn(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Bn(e){this.exit(e)}function Vn(){return`[`}function Hn(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function Un(){return{enter:{gfmFootnoteCallString:Nn,gfmFootnoteCall:Pn,gfmFootnoteDefinitionLabelString:Fn,gfmFootnoteDefinition:In},exit:{gfmFootnoteCallString:Ln,gfmFootnoteCall:Rn,gfmFootnoteDefinitionLabelString:zn,gfmFootnoteDefinition:Bn}}}function Wn(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Hn},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
23
23
|
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?Kn:Gn))),s(),o}}function Gn(e,t,n){return t===0?e:Kn(e,t,n)}function Kn(e,t,n){return(n?``:` `)+e}const qn=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];Qn.peek=$n;function Jn(){return{canContainEols:[`delete`],enter:{strikethrough:Xn},exit:{strikethrough:Zn}}}function Yn(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:qn}],handlers:{delete:Qn}}}function Xn(e){this.enter({type:`delete`,children:[]},e)}function Zn(e){this.exit(e)}function Qn(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function $n(){return`~`}function er(e){return e.length}function tr(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||er,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=nr(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=rr(r[d]);else{let e=rr(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&!(n.alignDelimiters===!1&&i===``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
|
|
@@ -164,9 +164,9 @@ var n=b(`buffer`),r=n.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}r.from&&r.
|
|
|
164
164
|
`),stack:e&&e.stack,exception:!0,date:new Date().toString(),process:this.getProcessInfo(),os:this.getOsInfo(),trace:this.getTrace(e)}}getProcessInfo(){return{pid:process.pid,uid:process.getuid?process.getuid():null,gid:process.getgid?process.getgid():null,cwd:process.cwd(),execPath:process.execPath,version:process.version,argv:process.argv,memoryUsage:process.memoryUsage()}}getOsInfo(){return{loadavg:n.loadavg(),uptime:n.uptime()}}getTrace(e){return(e?o.parse(e):o.get()).map(e=>({column:e.getColumnNumber(),file:e.getFileName(),function:e.getFunctionName(),line:e.getLineNumber(),method:e.getMethodName(),native:e.isNative()}))}_addHandler(e){if(!this.handlers.has(e)){e.handleExceptions=!0;let t=new s(e);this.handlers.set(e,t),this.logger.pipe(t)}}_uncaughtException(e){let t=this.getAllInfo(e),n=this._getExceptionHandlers(),o=typeof this.logger.exitOnError==`function`?this.logger.exitOnError(e):this.logger.exitOnError,s;!n.length&&o&&(console.warn(`winston: exitOnError cannot be true with no exception handlers.`),console.warn(`winston: not exiting process.`),o=!1);function c(){i(`doExit`,o),i(`process._exiting`,process._exiting),o&&!process._exiting&&(s&&clearTimeout(s),process.exit(1))}if(!n||n.length===0)return process.nextTick(c);r(n,(e,t)=>{let n=a(t),r=e.transport||e;function o(e){return()=>{i(e),n()}}r._ending=!0,r.once(`finish`,o(`finished`)),r.once(`error`,o(`error`))},()=>o&&c()),this.logger.log(t),o&&(s=setTimeout(c,3e3))}_getExceptionHandlers(){return this.logger.transports.filter(e=>(e.transport||e).handleExceptions)}}})),Vd=g(((e,t)=>{let{Writable:n}=md();t.exports=class extends n{constructor(e){if(super({objectMode:!0}),!e)throw Error(`RejectionStream requires a TransportStream instance.`);this.handleRejections=!0,this.transport=e}_write(e,t,n){return e.rejection?this.transport.log(e,n):(n(),!0)}}})),Hd=g(((e,t)=>{let n=b(`os`),r=Fd(),i=Td()(`winston:rejection`),a=Ld(),o=Rd(),s=Vd();t.exports=class{constructor(e){if(!e)throw Error(`Logger is required to handle rejections`);this.logger=e,this.handlers=new Map}handle(...e){e.forEach(e=>{if(Array.isArray(e))return e.forEach(e=>this._addHandler(e));this._addHandler(e)}),this.catcher||(this.catcher=this._unhandledRejection.bind(this),process.on(`unhandledRejection`,this.catcher))}unhandle(){this.catcher&&(process.removeListener(`unhandledRejection`,this.catcher),this.catcher=!1,Array.from(this.handlers.values()).forEach(e=>this.logger.unpipe(e)))}getAllInfo(e){let t=null;return e&&(t=typeof e==`string`?e:e.message),{error:e,level:`error`,message:[`unhandledRejection: ${t||`(no error message)`}`,e&&e.stack||` No stack trace`].join(`
|
|
165
165
|
`),stack:e&&e.stack,rejection:!0,date:new Date().toString(),process:this.getProcessInfo(),os:this.getOsInfo(),trace:this.getTrace(e)}}getProcessInfo(){return{pid:process.pid,uid:process.getuid?process.getuid():null,gid:process.getgid?process.getgid():null,cwd:process.cwd(),execPath:process.execPath,version:process.version,argv:process.argv,memoryUsage:process.memoryUsage()}}getOsInfo(){return{loadavg:n.loadavg(),uptime:n.uptime()}}getTrace(e){return(e?o.parse(e):o.get()).map(e=>({column:e.getColumnNumber(),file:e.getFileName(),function:e.getFunctionName(),line:e.getLineNumber(),method:e.getMethodName(),native:e.isNative()}))}_addHandler(e){if(!this.handlers.has(e)){e.handleRejections=!0;let t=new s(e);this.handlers.set(e,t),this.logger.pipe(t)}}_unhandledRejection(e){let t=this.getAllInfo(e),n=this._getRejectionHandlers(),o=typeof this.logger.exitOnError==`function`?this.logger.exitOnError(e):this.logger.exitOnError,s;!n.length&&o&&(console.warn(`winston: exitOnError cannot be true with no rejection handlers.`),console.warn(`winston: not exiting process.`),o=!1);function c(){i(`doExit`,o),i(`process._exiting`,process._exiting),o&&!process._exiting&&(s&&clearTimeout(s),process.exit(1))}if(!n||n.length===0)return process.nextTick(c);r(n,(e,t)=>{let n=a(t),r=e.transport||e;function o(e){return()=>{i(e),n()}}r._ending=!0,r.once(`finish`,o(`finished`)),r.once(`error`,o(`error`))},()=>o&&c()),this.logger.log(t),o&&(s=setTimeout(c,3e3))}_getRejectionHandlers(){return this.logger.transports.filter(e=>(e.transport||e).handleRejections)}}})),Ud=g(((e,t)=>{t.exports=class{constructor(e){let t=Wd();if(typeof e!=`object`||Array.isArray(e)||!(e instanceof t))throw Error(`Logger is required for profiling`);this.logger=e,this.start=Date.now()}done(...e){typeof e[e.length-1]==`function`&&(console.warn(`Callback function no longer supported as of winston@3.0.0`),e.pop());let t=typeof e[e.length-1]==`object`?e.pop():{};return t.level=t.level||`info`,t.durationMs=Date.now()-this.start,this.logger.write(t)}}})),Wd=g(((e,t)=>{let{Stream:n,Transform:r}=md(),i=Fd(),{LEVEL:a,SPLAT:o}=Z(),s=kd(),c=Bd(),l=Hd(),u=Gu(),d=Ud(),{warn:f}=Eu(),p=Md(),m=/%[scdjifoO%]/g;var h=class extends r{constructor(e){super({objectMode:!0}),this.configure(e)}child(e){let t=this;return Object.create(t,{write:{value:function(n){let r=Object.assign({},e,n);n instanceof Error&&(r.stack=n.stack,r.message=n.message,r.cause=n.cause),t.write(r)}}})}configure({silent:e,format:t,defaultMeta:n,levels:r,level:i=`info`,exitOnError:a=!0,transports:o,colors:s,emitErrs:u,formatters:d,padLevels:f,rewriters:m,stripColors:h,exceptionHandlers:g,rejectionHandlers:_}={}){if(this.transports.length&&this.clear(),this.silent=e,this.format=t||this.format||fu()(),this.defaultMeta=n||null,this.levels=r||this.levels||p.npm.levels,this.level=i,this.exceptions&&this.exceptions.unhandle(),this.rejections&&this.rejections.unhandle(),this.exceptions=new c(this),this.rejections=new l(this),this.profilers={},this.exitOnError=a,o&&(o=Array.isArray(o)?o:[o],o.forEach(e=>this.add(e))),s||u||d||f||m||h)throw Error([`{ colors, emitErrs, formatters, padLevels, rewriters, stripColors } were removed in winston@3.0.0.`,`Use a custom winston.format(function) instead.`,`See: https://github.com/winstonjs/winston/tree/master/UPGRADE-3.0.md`].join(`
|
|
166
166
|
`));g&&this.exceptions.handle(g),_&&this.rejections.handle(_)}getHighestLogLevel(){let e=g(this.levels,this.level);return!this.transports||this.transports.length===0?e:this.transports.reduce((e,t)=>{let n=g(this.levels,t.level);return n!==null&&n>e?n:e},e)}isLevelEnabled(e){let t=g(this.levels,e);if(t===null)return!1;let n=g(this.levels,this.level);return n===null?!1:!this.transports||this.transports.length===0?n>=t:this.transports.findIndex(e=>{let r=g(this.levels,e.level);return r===null&&(r=n),r>=t})!==-1}log(e,t,...n){if(arguments.length===1)return e[a]=e.level,this._addDefaultMeta(e),this.write(e),this;if(arguments.length===2)return t&&typeof t==`object`?(t[a]=t.level=e,this._addDefaultMeta(t),this.write(t),this):(t={[a]:e,level:e,message:t},this._addDefaultMeta(t),this.write(t),this);let[r]=n;if(typeof r==`object`&&r&&!(t&&t.match&&t.match(m))){let i=Object.assign({},this.defaultMeta,r,{[a]:e,[o]:n,level:e,message:t});return r.message&&(i.message=`${i.message} ${r.message}`),r.stack&&(i.stack=r.stack),r.cause&&(i.cause=r.cause),this.write(i),this}return this.write(Object.assign({},this.defaultMeta,{[a]:e,[o]:n,level:e,message:t})),this}_transform(e,t,n){if(this.silent)return n();e[a]||(e[a]=e.level),!this.levels[e[a]]&&this.levels[e[a]]!==0&&console.error(`[winston] Unknown logger level: %s`,e[a]),this._readableState.pipes||console.error(`[winston] Attempt to write logs with no transports, which can increase memory usage: %j`,e);try{this.push(this.format.transform(e,this.format.options))}finally{this._writableState.sync=!1,n()}}_final(e){i(this.transports.slice(),(e,t)=>{if(!e||e.finished)return setImmediate(t);e.once(`finish`,t),e.end()},e)}add(e){let t=!s(e)||e.log.length>2?new u({transport:e}):e;if(!t._writableState||!t._writableState.objectMode)throw Error(`Transports must WritableStreams in objectMode. Set { objectMode: true }.`);return this._onEvent(`error`,t),this._onEvent(`warn`,t),this.pipe(t),e.handleExceptions&&this.exceptions.handle(),e.handleRejections&&this.rejections.handle(),this}remove(e){if(!e)return this;let t=e;return(!s(e)||e.log.length>2)&&(t=this.transports.filter(t=>t.transport===e)[0]),t&&this.unpipe(t),this}clear(){return this.unpipe(),this}close(){return this.exceptions.unhandle(),this.rejections.unhandle(),this.clear(),this.emit(`close`),this}setLevels(){f.deprecated(`setLevels`)}query(e,t){typeof e==`function`&&(t=e,e={}),e||={};let n={},r=Object.assign({},e.query||{});function a(t,n){e.query&&typeof t.formatQuery==`function`&&(e.query=t.formatQuery(r)),t.query(e,(r,i)=>{if(r)return n(r);typeof t.formatResults==`function`&&(i=t.formatResults(i,e.format)),n(null,i)})}function o(e,t){a(e,(r,i)=>{t&&(i=r||i,i&&(n[e.name]=i),t()),t=null})}i(this.transports.filter(e=>!!e.query),o,()=>t(null,n))}stream(e={}){let t=new n,r=[];return t._streams=r,t.destroy=()=>{let e=r.length;for(;e--;)r[e].destroy()},this.transports.filter(e=>!!e.stream).forEach(n=>{let i=n.stream(e);i&&(r.push(i),i.on(`log`,e=>{e.transport=e.transport||[],e.transport.push(n.name),t.emit(`log`,e)}),i.on(`error`,e=>{e.transport=e.transport||[],e.transport.push(n.name),t.emit(`error`,e)}))}),t}startTimer(){return new d(this)}profile(e,...t){let n=Date.now();if(this.profilers[e]){let r=this.profilers[e];delete this.profilers[e],typeof t[t.length-2]==`function`&&(console.warn(`Callback function no longer supported as of winston@3.0.0`),t.pop());let i=typeof t[t.length-1]==`object`?t.pop():{};return i.level=i.level||`info`,i.durationMs=n-r,i.message=i.message||e,this.write(i)}return this.profilers[e]=n,this}handleExceptions(...e){console.warn(`Deprecated: .handleExceptions() will be removed in winston@4. Use .exceptions.handle()`),this.exceptions.handle(...e)}unhandleExceptions(...e){console.warn(`Deprecated: .unhandleExceptions() will be removed in winston@4. Use .exceptions.unhandle()`),this.exceptions.unhandle(...e)}cli(){throw Error([`Logger.cli() was removed in winston@3.0.0`,`Use a custom winston.formats.cli() instead.`,`See: https://github.com/winstonjs/winston/tree/master/UPGRADE-3.0.md`].join(`
|
|
167
|
-
`))}_onEvent(e,t){function n(n){e===`error`&&!this.transports.includes(t)&&this.add(t),this.emit(e,n,t)}t[`__winston`+e]||(t[`__winston`+e]=n.bind(this),t.on(e,t[`__winston`+e]))}_addDefaultMeta(e){this.defaultMeta&&Object.assign(e,this.defaultMeta)}};function g(e,t){let n=e[t];return!n&&n!==0?null:n}Object.defineProperty(h.prototype,`transports`,{configurable:!1,enumerable:!0,get(){let{pipes:e}=this._readableState;return Array.isArray(e)?e:[e].filter(Boolean)}}),t.exports=h})),Gd=g(((e,t)=>{let{LEVEL:n}=Z(),r=Md(),i=Wd(),a=Td()(`winston:create-logger`);function o(e){return`is`+e.charAt(0).toUpperCase()+e.slice(1)+`Enabled`}t.exports=function(e={}){e.levels=e.levels||r.npm.levels;class t extends i{constructor(e){super(e)}}let s=new t(e);return Object.keys(e.levels).forEach(function(e){if(a(`Define prototype method for "%s"`,e),e===`log`){console.warn(`Level "log" not defined: conflicts with the method "log". Use a different level name.`);return}t.prototype[e]=function(...t){let r=this||s;if(t.length===1){let[i]=t,a=i&&i.message&&i||{message:i};return a.level=a[n]=e,r._addDefaultMeta(a),r.write(a),this||s}return t.length===0?(r.log(e,``),r):r.log(e,...t)},t.prototype[o(e)]=function(){return(this||s).isLevelEnabled(e)}}),s}})),Kd=g(((e,t)=>{let n=Gd();t.exports=class{constructor(e={}){this.loggers=new Map,this.options=e}add(e,t){if(!this.loggers.has(e)){t=Object.assign({},t||this.options);let r=t.transports||this.options.transports;r?t.transports=Array.isArray(r)?r.slice():[r]:t.transports=[];let i=n(t);i.on(`close`,()=>this._delete(e)),this.loggers.set(e,i)}return this.loggers.get(e)}get(e,t){return this.add(e,t)}has(e){return!!this.loggers.has(e)}close(e){if(e)return this._removeLogger(e);this.loggers.forEach((e,t)=>this._removeLogger(t))}_removeLogger(e){this.loggers.has(e)&&(this.loggers.get(e).close(),this._delete(e))}_delete(e){this.loggers.delete(e)}}})),qd=y(g((e=>{let t=Tu(),{warn:n}=Eu();e.version=Du().version,e.transports=jd(),e.config=Md(),e.addColors=t.levels,e.format=t.format,e.createLogger=Gd(),e.Logger=Wd(),e.ExceptionHandler=Bd(),e.RejectionHandler=Hd(),e.Container=Kd(),e.Transport=Ku(),e.loggers=new e.Container;let r=e.createLogger();Object.keys(e.config.npm.levels).concat([`log`,`query`,`stream`,`add`,`remove`,`clear`,`profile`,`startTimer`,`handleExceptions`,`unhandleExceptions`,`handleRejections`,`unhandleRejections`,`configure`,`child`]).forEach(t=>e[t]=(...e)=>r[t](...e)),Object.defineProperty(e,`level`,{get(){return r.level},set(e){r.level=e}}),Object.defineProperty(e,`exceptions`,{get(){return r.exceptions}}),Object.defineProperty(e,`rejections`,{get(){return r.rejections}}),[`exitOnError`].forEach(t=>{Object.defineProperty(e,t,{get(){return r[t]},set(e){r[t]=e}})}),Object.defineProperty(e,`default`,{get(){return{exceptionHandlers:r.exceptionHandlers,rejectionHandlers:r.rejectionHandlers,transports:r.transports}}}),n.deprecated(e,`setLevels`),n.forFunctions(e,`useFormat`,[`cli`]),n.forProperties(e,`useFormat`,[`padLevels`,`stripColors`]),n.forFunctions(e,`deprecated`,[`addRewriter`,`addFilter`,`clone`,`extend`]),n.forProperties(e,`deprecated`,[`emitErrs`,`levelLength`])}))(),1);const Jd={error:l.red,warn:l.yellow,info:l.cyan,debug:l.magenta};function Yd(e){return e===null?l.dim(`null`):e===void 0?l.dim(`undefined`):typeof e==`boolean`?l.yellow(String(e)):typeof e==`number`?l.blue(String(e)):typeof e==`string`?l.green(`
|
|
167
|
+
`))}_onEvent(e,t){function n(n){e===`error`&&!this.transports.includes(t)&&this.add(t),this.emit(e,n,t)}t[`__winston`+e]||(t[`__winston`+e]=n.bind(this),t.on(e,t[`__winston`+e]))}_addDefaultMeta(e){this.defaultMeta&&Object.assign(e,this.defaultMeta)}};function g(e,t){let n=e[t];return!n&&n!==0?null:n}Object.defineProperty(h.prototype,`transports`,{configurable:!1,enumerable:!0,get(){let{pipes:e}=this._readableState;return Array.isArray(e)?e:[e].filter(Boolean)}}),t.exports=h})),Gd=g(((e,t)=>{let{LEVEL:n}=Z(),r=Md(),i=Wd(),a=Td()(`winston:create-logger`);function o(e){return`is`+e.charAt(0).toUpperCase()+e.slice(1)+`Enabled`}t.exports=function(e={}){e.levels=e.levels||r.npm.levels;class t extends i{constructor(e){super(e)}}let s=new t(e);return Object.keys(e.levels).forEach(function(e){if(a(`Define prototype method for "%s"`,e),e===`log`){console.warn(`Level "log" not defined: conflicts with the method "log". Use a different level name.`);return}t.prototype[e]=function(...t){let r=this||s;if(t.length===1){let[i]=t,a=i&&i.message&&i||{message:i};return a.level=a[n]=e,r._addDefaultMeta(a),r.write(a),this||s}return t.length===0?(r.log(e,``),r):r.log(e,...t)},t.prototype[o(e)]=function(){return(this||s).isLevelEnabled(e)}}),s}})),Kd=g(((e,t)=>{let n=Gd();t.exports=class{constructor(e={}){this.loggers=new Map,this.options=e}add(e,t){if(!this.loggers.has(e)){t=Object.assign({},t||this.options);let r=t.transports||this.options.transports;r?t.transports=Array.isArray(r)?r.slice():[r]:t.transports=[];let i=n(t);i.on(`close`,()=>this._delete(e)),this.loggers.set(e,i)}return this.loggers.get(e)}get(e,t){return this.add(e,t)}has(e){return!!this.loggers.has(e)}close(e){if(e)return this._removeLogger(e);this.loggers.forEach((e,t)=>this._removeLogger(t))}_removeLogger(e){this.loggers.has(e)&&(this.loggers.get(e).close(),this._delete(e))}_delete(e){this.loggers.delete(e)}}})),qd=y(g((e=>{let t=Tu(),{warn:n}=Eu();e.version=Du().version,e.transports=jd(),e.config=Md(),e.addColors=t.levels,e.format=t.format,e.createLogger=Gd(),e.Logger=Wd(),e.ExceptionHandler=Bd(),e.RejectionHandler=Hd(),e.Container=Kd(),e.Transport=Ku(),e.loggers=new e.Container;let r=e.createLogger();Object.keys(e.config.npm.levels).concat([`log`,`query`,`stream`,`add`,`remove`,`clear`,`profile`,`startTimer`,`handleExceptions`,`unhandleExceptions`,`handleRejections`,`unhandleRejections`,`configure`,`child`]).forEach(t=>e[t]=(...e)=>r[t](...e)),Object.defineProperty(e,`level`,{get(){return r.level},set(e){r.level=e}}),Object.defineProperty(e,`exceptions`,{get(){return r.exceptions}}),Object.defineProperty(e,`rejections`,{get(){return r.rejections}}),[`exitOnError`].forEach(t=>{Object.defineProperty(e,t,{get(){return r[t]},set(e){r[t]=e}})}),Object.defineProperty(e,`default`,{get(){return{exceptionHandlers:r.exceptionHandlers,rejectionHandlers:r.rejectionHandlers,transports:r.transports}}}),n.deprecated(e,`setLevels`),n.forFunctions(e,`useFormat`,[`cli`]),n.forProperties(e,`useFormat`,[`padLevels`,`stripColors`]),n.forFunctions(e,`deprecated`,[`addRewriter`,`addFilter`,`clone`,`extend`]),n.forProperties(e,`deprecated`,[`emitErrs`,`levelLength`])}))(),1);const Jd={error:l.red,warn:l.yellow,info:l.cyan,debug:l.magenta};function Yd(e){return e===null?l.dim(`null`):e===void 0?l.dim(`undefined`):typeof e==`boolean`?l.yellow(String(e)):typeof e==`number`?l.blue(String(e)):typeof e==`string`?l.green(`"${e}"`):Array.isArray(e)?e.length===0?`[]`:`[${e.map(e=>Yd(e)).join(`,`)}]`:typeof e==`object`?Xd(e):String(e)}function Xd(e){let t=Object.entries(e);return t.length===0?`{}`:`{${t.map(([e,t])=>`${/^[\w$]+$/.test(e)?l.magenta(e):l.yellow(`"${e}"`)}:${Yd(t)}`).join(`,`)}}`}function Zd(e){let{timestamp:t,level:n,message:r,scope:i,...a}=e,o={$:[t,(Jd[n]??l.white)(n.toUpperCase()),i]};if(r==null)return Xd(o);let s=Object.keys(a).length>0?{[r]:a}:r;return Xd({...o,_:s})}function Qd(e,t){return qd.createLogger({level:t??n.env.LOG_LEVEL??`info`,defaultMeta:{scope:e},format:qd.format.combine(qd.format.timestamp({format:`HH:mm:ss.SSS`}),qd.format.printf(Zd)),transports:[new qd.transports.Console]})}var $d=class{type;name;log;dependsOn;constructor(e,t,n){this.name=e,this.type=t,this.log=Qd(e),n!=null&&(this.dependsOn=n)}},ef=class extends $d{constructor(e,t){super(e,ct.Input,t)}resolveBasePaths(e){let t=e.workspaceDir??_t,n=this.resolvePath(t,``,``),r=e.shadowProjectDir??`${gt.WORKSPACE}/${vt}`;return{workspaceDir:n,shadowProjectDir:this.resolvePath(r,n,``)}}resolvePath(e,t,n){let r=e;return r.startsWith(gt.USER_HOME)&&(r=r.replace(gt.USER_HOME,o.homedir())),r.includes(gt.SHADOW_PROJECT)&&(r=r.replace(gt.SHADOW_PROJECT,n)),r.includes(gt.WORKSPACE)&&(r=r.replace(gt.WORKSPACE,t)),i.normalize(r)}readAndParseMarkdown(e,t){return Hl(t.readFileSync(e,`utf-8`))}},tf=class extends $d{globalConfigDir;outputFileName;registryWriterCache=new Map;constructor(e,t){super(e,ct.Output,t?.dependsOn),this.globalConfigDir=t?.globalConfigDir??``,this.outputFileName=t?.outputFileName??``}isRelativePath(e){return e.pathKind===I.Relative}toRelativePath(e){return this.isRelativePath(e)?e:{pathKind:I.Relative,path:e.path,basePath:``,getDirectoryName:e.getDirectoryName,getAbsolutePath:()=>e.path}}resolveFullPath(e,t){let r;r=e.pathKind===I.Absolute?e.path:this.isRelativePath(e)?i.resolve(e.basePath,e.path):i.resolve(n.cwd(),e.path);let a=t??this.outputFileName;return a?i.join(r,a):r}createRelativePath(e,t,n){return{pathKind:I.Relative,path:e,basePath:t,getDirectoryName:n,getAbsolutePath:()=>i.join(t,e)}}createFileRelativePath(e,t){let n=i.join(e.path,t);return{pathKind:I.Relative,path:n,basePath:e.basePath,getDirectoryName:()=>e.getDirectoryName(),getAbsolutePath:()=>i.join(e.basePath,n)}}getGlobalConfigDir(){return i.join(o.homedir(),this.globalConfigDir)}joinPath(...e){return i.join(...e)}resolvePath(...e){return i.resolve(...e)}dirname(e){return i.dirname(e)}basename(e,t){return i.basename(e,t)}writeFileSync(e,t,n=`utf-8`){r.writeFileSync(e,t,n)}ensureDirectory(e){r.existsSync(e)||r.mkdirSync(e,{recursive:!0})}async writeFile(e,t,n,a){let o=i.dirname(t),s=i.basename(t),c={pathKind:I.Relative,path:s,basePath:o,getDirectoryName:()=>i.basename(o),getAbsolutePath:()=>t};if(e.dryRun===!0)return this.log.info(`would write`,{path:t,label:a,dryRun:!0}),{path:c,success:!0,skipped:!1};try{return this.ensureDirectory(o),r.writeFileSync(t,n,`utf-8`),this.log.info(`written`,{path:t,label:a}),{path:c,success:!0}}catch(e){let n=e instanceof Error?e.message:String(e);return this.log.error(`write failed`,{path:t,label:a,error:n}),{path:c,success:!1,error:e}}}async writePromptFile(e,t,n,a){let o=this.resolveFullPath(t),s=this.toRelativePath(t);if(e.dryRun===!0)return this.log.info(`would write`,{path:o,label:a,dryRun:!0}),{path:s,success:!0,skipped:!1};try{let e=i.dirname(o);return this.ensureDirectory(e),r.writeFileSync(o,n,`utf-8`),this.log.info(`written`,{path:o,label:a}),{path:s,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error(`write failed`,{path:o,label:a,error:t}),{path:s,success:!1,error:e}}}buildMarkdownContent(e,t){return e!=null&&e.length>0?`${e}\n${t}`:t}extractGlobalMemoryContent(e){return e.collectedInputContext.globalMemory?.content}combineGlobalWithContent(e,t,n){let{separator:r=`
|
|
168
168
|
|
|
169
|
-
`,skipIfEmpty:i=!0,position:a=`before`}=n??{};if(i&&(e==null||e.trim().length===0))return t;let o=e??``;return a===`after`?`${t}${r}${o}`:`${o}${r}${t}`}transformFastCommandName(e,t){let{includeSeriesPrefix:n=!0,seriesSeparator:r=`_`}=t??{};return!n||e.series==null?`${e.commandName}.md`:`${e.series}${r}${e.commandName}.md`}getFastCommandSeriesOptions(e){let t=e.pluginOptions?.fastCommandSeriesOptions,n=t?.pluginOverrides?.[this.name],r=n?.includeSeriesPrefix??t?.includeSeriesPrefix,i=n?.seriesSeparator;return r!=null&&i!=null?{includeSeriesPrefix:r,seriesSeparator:i}:r==null?i==null?{}:{seriesSeparator:i}:{includeSeriesPrefix:r}}getTransformOptionsFromContext(e,t){let n=this.getFastCommandSeriesOptions(e),r=n.includeSeriesPrefix??t?.includeSeriesPrefix,i=n.seriesSeparator??t?.seriesSeparator;return r!=null&&i!=null?{includeSeriesPrefix:r,seriesSeparator:i}:r==null?i==null?{}:{seriesSeparator:i}:{includeSeriesPrefix:r}}shouldSkipDueToPlugin(e,t){let n=e.registeredPluginNames;return n==null?!1:n.includes(t)}async onWriteComplete(e,t){let n=t.files.filter(e=>e.success).length,r=t.files.filter(e=>e.skipped).length,i=t.files.filter(e=>!e.success&&!e.skipped).length
|
|
169
|
+
`,skipIfEmpty:i=!0,position:a=`before`}=n??{};if(i&&(e==null||e.trim().length===0))return t;let o=e??``;return a===`after`?`${t}${r}${o}`:`${o}${r}${t}`}transformFastCommandName(e,t){let{includeSeriesPrefix:n=!0,seriesSeparator:r=`_`}=t??{};return!n||e.series==null?`${e.commandName}.md`:`${e.series}${r}${e.commandName}.md`}getFastCommandSeriesOptions(e){let t=e.pluginOptions?.fastCommandSeriesOptions,n=t?.pluginOverrides?.[this.name],r=n?.includeSeriesPrefix??t?.includeSeriesPrefix,i=n?.seriesSeparator;return r!=null&&i!=null?{includeSeriesPrefix:r,seriesSeparator:i}:r==null?i==null?{}:{seriesSeparator:i}:{includeSeriesPrefix:r}}getTransformOptionsFromContext(e,t){let n=this.getFastCommandSeriesOptions(e),r=n.includeSeriesPrefix??t?.includeSeriesPrefix,i=n.seriesSeparator??t?.seriesSeparator;return r!=null&&i!=null?{includeSeriesPrefix:r,seriesSeparator:i}:r==null?i==null?{}:{seriesSeparator:i}:{includeSeriesPrefix:r}}shouldSkipDueToPlugin(e,t){let n=e.registeredPluginNames;return n==null?!1:n.includes(t)}async onWriteComplete(e,t){let n=t.files.filter(e=>e.success).length,r=t.files.filter(e=>e.skipped).length,i=t.files.filter(e=>!e.success&&!e.skipped).length;e.dryRun===!0?this.log.info(`write complete`,{success:n,skipped:r,failed:i,dryRun:!0}):this.log.info(`write complete`,{success:n,skipped:r,failed:i})}getRegistryWriter(e){let t=e.name,n=this.registryWriterCache.get(t);if(n!=null)return n;let r=new e(this.log);return this.registryWriterCache.set(t,r),r}async registerInRegistry(e,t,n){return e.register(t,n.dryRun)}},nf=class{registryPath;log;constructor(e,t){this.registryPath=this.resolvePath(e),this.log=t??Qd(this.constructor.name)}resolvePath(e){return e.startsWith(`~`)?i.join(o.homedir(),e.slice(1)):i.resolve(e)}getRegistryDir(){return i.dirname(this.registryPath)}ensureRegistryDir(){let e=this.getRegistryDir();r.existsSync(e)||r.mkdirSync(e,{recursive:!0})}read(){if(!r.existsSync(this.registryPath))return this.log.debug(`registry not found`,{path:this.registryPath}),this.createInitialRegistry();try{let e=r.readFileSync(this.registryPath,`utf-8`);return JSON.parse(e)}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error(`parse failed`,{path:this.registryPath,error:t}),this.createInitialRegistry()}}write(e,t){let n={...e,lastUpdated:new Date().toISOString()};if(t===!0)return this.log.info(`would write registry`,{path:this.registryPath,dryRun:!0}),!0;let i=`${this.registryPath}.tmp.${Date.now()}`;try{this.ensureRegistryDir();let e=JSON.stringify(n,null,2);return r.writeFileSync(i,e,`utf-8`),r.renameSync(i,this.registryPath),this.log.info(`written registry`,{path:this.registryPath}),!0}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`write registry failed`,{path:this.registryPath,error:t});try{r.existsSync(i)&&r.unlinkSync(i)}catch{}return!1}}register(e,t){let n=[],r=this.read(),i=this.merge(r,e),a=this.write(i,t);for(let r of e){let e=this.getEntryName(r);a?(n.push({success:!0,entryName:e}),t===!0?this.log.info(`would register entry`,{entryName:e,dryRun:!0}):this.log.info(`registered entry`,{entryName:e})):(n.push({success:!1,entryName:e,error:Error(`Failed to write registry file`)}),this.log.error(`register entry failed`,{entryName:e}))}return n}generateEntryId(e){let t=`${Date.now()}-${Math.random().toString(36).substring(2,8)}`;return e==null?t:`${e}-${t}`}},rf=class e extends nf{static REGISTRY_PATH=`~/.kiro/powers/registry.json`;static DEFAULT_VERSION=`1.0.0`;constructor(t){super(e.REGISTRY_PATH,t)}createInitialRegistry(){return{version:e.DEFAULT_VERSION,powers:{},repoSources:{},lastUpdated:new Date().toISOString()}}getEntryName(e){return e.name}merge(e,t){let n={...e.powers},r={...e.repoSources};for(let e of t){n[e.name]=e;let t=this.buildRepoSource(e),i=e.source.repoId??e.name;r[i]=t}return{version:e.version,powers:n,repoSources:r,...e.kiroRecommendedRepo!=null&&{kiroRecommendedRepo:e.kiroRecommendedRepo},lastUpdated:e.lastUpdated}}buildPowerEntry(e,t){let{yamlFrontMatter:n}=e,r={type:`repo`,repoId:this.generateEntryId(`local`),repoName:t};return{name:n.name,description:n.description,...n.author!=null&&{author:n.author},keywords:n.keywords??[],...n.displayName!=null&&{displayName:n.displayName},installed:!0,installedAt:new Date().toISOString(),installPath:t,source:r,sourcePath:t}}buildRepoSource(e){let t=new Date().toISOString();return{name:e.sourcePath??e.installPath??e.name,type:`local`,enabled:!0,addedAt:t,powerCount:1,...e.sourcePath!=null&&{path:e.sourcePath},lastSync:t}}},af=class{name=`dry-run-clean`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r}=e;t.info(`running clean pipeline`,{command:`dry-run-clean`,dryRun:!0});let i=r(!0),a=await Qe(n,i);t.info(`collected outputs for cleanup`,{dryRun:!0,projectDirs:a.projectDirs.length,projectFiles:a.projectFiles.length,globalDirs:a.globalDirs.length,globalFiles:a.globalFiles.length});let o=await $e(n,i),{filesToDelete:s,dirsToDelete:c}=await this.collectDeletionTargets(e,o,i);return this.logDryRunFiles(s,t),this.logDryRunDirectories(c,t),await et(n,i),t.info(`clean complete`,{dryRun:!0,filesAffected:s.length,dirsAffected:c.length}),{success:!0,filesAffected:s.length,dirsAffected:c.length,message:`Dry-run complete, no files were deleted`}}async collectDeletionTargets(e,t,n){let r=[],i=[];for(let a of e.outputPlugins){let e=t.get(a.name);if(e?.project){let e=await a.registerProjectOutputFiles?.(n)??[],t=await a.registerProjectOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}if(e?.global){let e=await a.registerGlobalOutputFiles?.(n)??[],t=await a.registerGlobalOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}}return{filesToDelete:r,dirsToDelete:i}}logDryRunFiles(e,t){for(let n of e){let e=i.isAbsolute(n)?n:i.resolve(n);t.info(`would delete file`,{path:e,dryRun:!0})}}logDryRunDirectories(e,t){let n=[...e].sort((e,t)=>t.length-e.length);for(let e of n){let n=i.isAbsolute(e)?e:i.resolve(e);t.info(`would delete directory`,{path:n,dryRun:!0})}}},of=class{name=`dry-run-output`;async execute(e){let{logger:t,outputPlugins:n,createWriteContext:r}=e;t.info(`started`,{command:`dry-run-output`,dryRun:!0});let i=r(!0),a=await tt(n,i),o=await nt(n.filter(e=>!!(a.get(e.name)?.project??!0)),i),s=0,c=0;for(let[e,n]of o)s+=n.files.length,c+=n.dirs.length,t.info(`plugin result`,{plugin:e,files:n.files.length,dirs:n.dirs.length,dryRun:!0});return t.info(`complete`,{command:`dry-run-output`,totalFiles:s,totalDirs:c,dryRun:!0}),{success:!0,filesAffected:s,dirsAffected:c,message:`Dry-run complete, no files were written`}}},sf=class{name=`execute`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r,createWriteContext:i}=e;t.info(`started`,{command:`execute`});let a=await ot(n,r(!1),t,{executeHooks:!1});t.info(`cleanup complete`,{deletedFiles:a.deletedFiles,deletedDirs:a.deletedDirs});let o=i(!1),s=await tt(n,o),c=await nt(n.filter(e=>s.get(e.name)?.project??!0),o),l=0,u=0;for(let e of c.values())l+=e.files.length,u+=e.dirs.length;return t.info(`complete`,{command:`execute`,pluginCount:c.size}),{success:!0,filesAffected:l,dirsAffected:u}}};const Q=`tnmsc`,cf=`
|
|
170
170
|
${Q} v0.0.6 - Memory Sync CLI
|
|
171
171
|
|
|
172
172
|
Synchronize AI memory and configuration files across projects.
|
|
@@ -202,10 +202,9 @@ CLEAN OPTIONS:
|
|
|
202
202
|
CONFIGURATION:
|
|
203
203
|
Configure via plugin.config.ts in your project root.
|
|
204
204
|
See documentation for detailed configuration options.
|
|
205
|
-
`.trim();var lf=class{name=`help`;async execute(e){return console.log(cf),{success:!0,filesAffected:0,dirsAffected:0,message:`Help displayed`}}};const uf=`.tnmsc.json`,df=`.aindex`;var ff=class{configFileName;searchCwd;searchGlobal;customSearchPaths;logger;constructor(e={}){this.configFileName=e.configFileName??uf,this.searchCwd=e.searchCwd??!0,this.searchGlobal=e.searchGlobal??!0,this.customSearchPaths=e.searchPaths??[],this.logger=Qd(`ConfigLoader`)}getSearchPaths(e=n.cwd()){let t=[];for(let e of this.customSearchPaths)t.push(this.resolveTilde(e));return this.searchCwd&&t.push(i.join(e,this.configFileName)),this.searchGlobal&&t.push(i.join(o.homedir(),df,this.configFileName)),t}loadFromFile(e){let t=this.resolveTilde(e);try{if(!r.existsSync(t))return{config:{},source:null,found:!1};let e=r.readFileSync(t,`utf-8`),n=this.parseConfig(e,t);return this.logger.debug(`
|
|
206
|
-
- `)}`),n}mergeConfigs(e){if(e.length===0)return{};let t=e[0];return e.length===1&&t!=null?t:[...e].reverse().reduce((e,t)=>{let n=[...e.externalProjects??[],...t.externalProjects??[]],r=this.mergeExcludePatterns(e.excludePatterns,t.excludePatterns);return{...e,...t,...n.length>0?{externalProjects:n}:{},...r==null?{}:{excludePatterns:r}}},{})}mergeExcludePatterns(e,t){if(e==null&&t==null)return null;if(e==null)return t??null;if(t==null)return e;let n={...e};for(let[e,r]of Object.entries(t))n[e]=[...n[e]??[],...r];return n}resolveTilde(e){return e.startsWith(`~`)?i.join(o.homedir(),e.slice(1)):e}};let pf=null;function mf(e){return(e||!pf)&&(pf=new ff(e)),pf}function hf(e){return mf().load(e)}function gf(e,t,n){let r=e;return r=r.replace(gt.SHADOW_PROJECT,n),r=r.replace(gt.WORKSPACE,t),r.startsWith(`~`)&&(r=i.join(o.homedir(),r.slice(1))),i.normalize(r)}var _f=class{name=`init`;async execute(e){let{logger:t}=e;t.info(`Initializing directory structure...`);let n=hf().config,a=gf(n.workspaceDir??_t,``,``),o=gf(n.shadowProjectDir??`${gt.WORKSPACE}/${vt}`,a,``),s=gf(n.shadowSkillSourceDir??yt,a,o),c=gf(n.shadowFastCommandDir??bt,a,o),l=gf(n.shadowSubAgentDir??xt,a,o),u=gf(n.shadowSourceProjectDir??St,a,o),d=gf(n.globalMemoryFile??Ct,a,o),f=[{path:a,name:`workspace`},{path:o,name:`shadow project`},{path:s,name:`skills`},{path:c,name:`commands`},{path:l,name:`agents`},{path:u,name:`ref`}],p=0,m=0,h=0,g=0;for(let e of f)r.existsSync(e.path)?(t.info(`${e.name} directory already exists: ${e.path}`),m++):(r.mkdirSync(e.path,{recursive:!0}),t.info(`Created ${e.name} directory: ${e.path}`),p++);let _=i.dirname(d);r.existsSync(_)||(r.mkdirSync(_,{recursive:!0}),p++),r.existsSync(d)?(t.info(`Global memory file already exists: ${d}`),g++):(r.writeFileSync(d,`# Global Memory
|
|
205
|
+
`.trim();var lf=class{name=`help`;async execute(e){return console.log(cf),{success:!0,filesAffected:0,dirsAffected:0,message:`Help displayed`}}};const uf=`.tnmsc.json`,df=`.aindex`;var ff=class{configFileName;searchCwd;searchGlobal;customSearchPaths;logger;constructor(e={}){this.configFileName=e.configFileName??uf,this.searchCwd=e.searchCwd??!0,this.searchGlobal=e.searchGlobal??!0,this.customSearchPaths=e.searchPaths??[],this.logger=Qd(`ConfigLoader`)}getSearchPaths(e=n.cwd()){let t=[];for(let e of this.customSearchPaths)t.push(this.resolveTilde(e));return this.searchCwd&&t.push(i.join(e,this.configFileName)),this.searchGlobal&&t.push(i.join(o.homedir(),df,this.configFileName)),t}loadFromFile(e){let t=this.resolveTilde(e);try{if(!r.existsSync(t))return{config:{},source:null,found:!1};let e=r.readFileSync(t,`utf-8`),n=this.parseConfig(e,t);return this.logger.debug(`loaded`,{source:t}),{config:n,source:t,found:!0}}catch(e){return this.logger.warn(`load failed`,{path:t,error:e}),{config:{},source:null,found:!1}}}load(e=n.cwd()){let t=this.getSearchPaths(e),r=[];for(let e of t){let t=this.loadFromFile(e);t.found&&r.push(t)}return{config:this.mergeConfigs(r.map(e=>e.config)),sources:r.map(e=>e.source).filter(e=>e!==null),found:r.length>0}}parseConfig(e,t){try{let n=JSON.parse(e);if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`Config must be a JSON object`);return this.validateConfig(n,t)}catch(e){throw e instanceof SyntaxError?Error(`Invalid JSON in ${t}: ${e.message}`):e}}validateConfig(e,t){let n={},r=[];for(let t of[`workspaceDir`,`shadowProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowSourceProjectDir`])t in e&&(typeof e[t]==`string`?n[t]=e[t]:r.push(`${t} must be a string`));if(`logLevel`in e){let t=[`trace`,`debug`,`info`,`warn`,`error`],i=e.logLevel;typeof i==`string`&&t.includes(i)?n.logLevel=i:r.push(`logLevel must be one of: ${t.join(`, `)}`)}if(`externalProjects`in e){let t=e.externalProjects;Array.isArray(t)?t.every(e=>typeof e==`string`)?n.externalProjects=t:r.push(`externalProjects must be an array of strings`):r.push(`externalProjects must be an array`)}if(`excludePatterns`in e){let t=e.excludePatterns;if(typeof t==`object`&&t){let e=t,i={},a=!0;for(let[t,n]of Object.entries(e))Array.isArray(n)&&n.every(e=>typeof e==`string`)?i[t]=n:(r.push(`excludePatterns.${t} must be an array of strings`),a=!1);a&&(n.excludePatterns=i)}else r.push(`excludePatterns must be an object`)}return r.length>0&&this.logger.warn(`validation warnings`,{path:t,errors:r}),n}mergeConfigs(e){if(e.length===0)return{};let t=e[0];return e.length===1&&t!=null?t:[...e].reverse().reduce((e,t)=>{let n=[...e.externalProjects??[],...t.externalProjects??[]],r=this.mergeExcludePatterns(e.excludePatterns,t.excludePatterns);return{...e,...t,...n.length>0?{externalProjects:n}:{},...r==null?{}:{excludePatterns:r}}},{})}mergeExcludePatterns(e,t){if(e==null&&t==null)return null;if(e==null)return t??null;if(t==null)return e;let n={...e};for(let[e,r]of Object.entries(t))n[e]=[...n[e]??[],...r];return n}resolveTilde(e){return e.startsWith(`~`)?i.join(o.homedir(),e.slice(1)):e}};let pf=null;function mf(e){return(e||!pf)&&(pf=new ff(e)),pf}function hf(e){return mf().load(e)}function gf(e,t,n){let r=e;return r=r.replace(gt.SHADOW_PROJECT,n),r=r.replace(gt.WORKSPACE,t),r.startsWith(`~`)&&(r=i.join(o.homedir(),r.slice(1))),i.normalize(r)}var _f=class{name=`init`;async execute(e){let{logger:t}=e;t.info(`initializing directory structure`,{command:`init`});let n=hf().config,a=gf(n.workspaceDir??_t,``,``),o=gf(n.shadowProjectDir??`${gt.WORKSPACE}/${vt}`,a,``),s=gf(n.shadowSkillSourceDir??yt,a,o),c=gf(n.shadowFastCommandDir??bt,a,o),l=gf(n.shadowSubAgentDir??xt,a,o),u=gf(n.shadowSourceProjectDir??St,a,o),d=gf(n.globalMemoryFile??Ct,a,o),f=[{path:a,name:`workspace`},{path:o,name:`shadow project`},{path:s,name:`skills`},{path:c,name:`commands`},{path:l,name:`agents`},{path:u,name:`ref`}],p=0,m=0,h=0,g=0;for(let e of f)r.existsSync(e.path)?(t.debug(`directory already exists`,{name:e.name,path:e.path}),m++):(r.mkdirSync(e.path,{recursive:!0}),t.info(`created directory`,{name:e.name,path:e.path}),p++);let _=i.dirname(d);r.existsSync(_)||(r.mkdirSync(_,{recursive:!0}),p++),r.existsSync(d)?(t.debug(`global memory file already exists`,{path:d}),g++):(r.writeFileSync(d,`# Global Memory
|
|
207
206
|
|
|
208
|
-
`,`utf-8`),t.info(`Created global memory file: ${d}`),h++),t.info(`Initialization complete`,{dirsCreated:p,dirsExisted:m,filesCreated:h,filesExisted:g});let v=p===0&&h===0?`All ${m} directories and ${g} files already exist`:`Created ${p} directories and ${h} files (${m} dirs, ${g} files already existed)`;return{success:!0,filesAffected:h,dirsAffected:p,message:v}}},vf=class{name=`unknown`;constructor(e){this.unknownCmd=e}async execute(e){return console.error(`Unknown command: ${this.unknownCmd}`),console.error(`Run "tnmsc help" for available commands.`),{success:!1,filesAffected:0,dirsAffected:0}}};function yf(e){let t=[...e],n=t[0];n!=null&&bf(n)&&t.shift();let r=t[0];return r!=null&&xf(r)&&t.shift(),t}function bf(e){let t=[`node`,`nodejs`,`bun`,`deno`,`tsx`,`ts-node`,`npx`,`pnpx`,`yarn`,`pnpm`],n=e.toLowerCase().replace(/\\/g,`/`);return t.some(e=>RegExp(`(?:^|/)${e}(?:\\.exe|\\.cmd|\\.ps1)?$`,`i`).test(n)||n===e)}function xf(e){return!!(/\.(?:m?[jt]s|cjs)$/.test(e)||/[/\\]/.test(e)&&!e.startsWith(`-`)||/^(?:@[\w-]+\/)?[\w-]+$/.test(e)&&!e.startsWith(`-`))}const Sf=new Set([`help`,`init`,`dry-run`,`clean`]),Cf=new Map([[`--trace`,`trace`],[`--debug`,`debug`],[`--info`,`info`],[`--warn`,`warn`],[`--error`,`error`]]),wf=new Map([[`trace`,0],[`debug`,1],[`info`,2],[`warn`,3],[`error`,4]]);function Tf(e){let{logLevelFlags:t}=e;if(t.length===0)return;let n=t[0],r=wf.get(n)??4;for(let e of t){let t=wf.get(e)??4;t<r&&(r=t,n=e)}return n}function Ef(e){let{helpFlag:t,subcommand:n,dryRun:r,unknownCommand:i}=e;return t?new lf:i==null?n===`help`?new lf:n===`init`?new _f:n===`dry-run`?new of:n===`clean`?r?new af:new st:new sf:new vf(i)}function Df(e){let t={subcommand:void 0,helpFlag:!1,dryRun:!1,logLevel:void 0,logLevelFlags:[],unknownCommand:void 0,positional:[],unknown:[]},n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i!=null){if(i===`--`){t.positional.push(...e.slice(r+1).filter(e=>e!=null));break}if(i.startsWith(`--`)){let e=i.split(`=`)[0]??``,n=Cf.get(e);if(n!=null){t.logLevelFlags.push(n),t.logLevel=n;continue}switch(e){case`--help`:t.helpFlag=!0;break;case`--dry-run`:t.dryRun=!0;break;default:t.unknown.push(i)}continue}if(i.startsWith(`-`)&&i.length>1){let e=i.slice(1);for(let n of e)switch(n){case`h`:t.helpFlag=!0;break;case`n`:t.dryRun=!0;break;default:t.unknown.push(`-${n}`)}continue}if(!n){n=!0,Sf.has(i)?t.subcommand=i:t.unknownCommand=i;continue}t.positional.push(i)}}return t}var Of=class{logger;args;outputPlugins=[];constructor(...e){this.args=Df(yf(e.filter(e=>e!=null))),this.logger=Qd(`PluginPipeline`,Tf(this.args)),this.logger.info(`PluginPipeline initialized`,{args:this.args})}registerOutputPlugins(e){return this.outputPlugins.push(...e),this}async run(e){let{context:t,outputPlugins:n}=e;this.registerOutputPlugins([...n]);let r=this.resolveCommand(),i=this.createCommandContext(t);await r.execute(i)}resolveCommand(){return Ef(this.args)}createCommandContext(e){return{logger:this.logger,outputPlugins:this.outputPlugins,collectedInputContext:e,createCleanContext:t=>this.createCleanContext(e,t),createWriteContext:t=>this.createWriteContext(e,t)}}createCleanContext(e,t){return{logger:this.logger,fs:r,path:i,glob:Ze.default,collectedInputContext:e,dryRun:t}}createWriteContext(e,t){return{logger:this.logger,fs:r,path:i,glob:Ze.default,collectedInputContext:e,dryRun:t,registeredPluginNames:this.outputPlugins.map(e=>e.name)}}buildDependencyGraph(e){let t=new Map;for(let n of e){let e=n.dependsOn??[];t.set(n.name,[...e])}return t}validateDependencies(e){let t=new Set(e.map(e=>e.name));for(let n of e){let e=n.dependsOn??[];for(let r of e)if(!t.has(r))throw new ht(n.name,r)}}topologicalSort(e){this.validateDependencies(e);let t=new Map;for(let n of e)t.set(n.name,n);let n=new Map;for(let t of e)n.set(t.name,0);let r=new Map;for(let t of e)r.set(t.name,[]);for(let t of e){let e=t.dependsOn??[];for(let i of e){n.set(t.name,(n.get(t.name)??0)+1);let e=r.get(i)??[];e.push(t.name),r.set(i,e)}}let i=[];for(let t of e)n.get(t.name)===0&&i.push(t.name);let a=[];for(;i.length>0;){let o=i.shift(),s=t.get(o);a.push(s);let c=(r.get(o)??[]).sort((t,n)=>e.findIndex(e=>e.name===t)-e.findIndex(e=>e.name===n));for(let e of c){let t=(n.get(e)??0)-1;n.set(e,t),t===0&&i.push(e)}}if(a.length!==e.length)throw new mt(this.findCyclePath(e,n));return a}findCyclePath(e,t){let n=new Set;for(let[e,r]of t)r>0&&n.add(e);let r=new Map;for(let t of e)if(n.has(t.name)){let e=(t.dependsOn??[]).filter(e=>n.has(e));r.set(t.name,e)}let i=new Set,a=[],o=e=>{if(a.includes(e))return a.push(e),!0;if(i.has(e))return!1;i.add(e),a.push(e);for(let t of r.get(e)??[])if(o(t))return!0;return a.pop(),!1};for(let e of n){if(o(e)){let e=a.indexOf(a[a.length-1]);return a.slice(e)}i.clear(),a.length=0}return Array.from(n)}executePluginsInOrder(e,t){if(e.length===0)return{};let n=this.topologicalSort(e),r=new Map,i={};for(let e of n){let n=this.buildDependencyContext(e,r),a={...t,dependencyContext:n},o=e.collect(a);r.set(e.name,o),i=this.mergeContexts(i,o)}return i}buildDependencyContext(e,t){if((e.dependsOn??[]).length===0)return{};let n=this.collectTransitiveDependencies(e,t),r={};for(let e of n){let n=t.get(e);n!=null&&(r=this.mergeContexts(r,n))}return r}collectTransitiveDependencies(e,t){let n=new Set,r=[];return(e=>{for(let i of e)n.has(i)||(n.add(i),t.get(i)!=null&&r.push(i))})(e.dependsOn??[]),r}mergeContexts(e,t){let n=e.workspace;if(t.workspace!=null)if(n!=null){let e=new Map;for(let t of n.projects)e.set(t.name,t);for(let n of t.workspace.projects)e.set(n.name,n);n={directory:t.workspace.directory??n.directory,projects:Array.from(e.values())}}else n=t.workspace;let r=t.externalProjects==null?e.externalProjects:[...e.externalProjects??[],...t.externalProjects],i=t.ideConfigFiles==null?e.ideConfigFiles:[...e.ideConfigFiles??[],...t.ideConfigFiles],a=t.fastCommands==null?e.fastCommands:[...e.fastCommands??[],...t.fastCommands],o=t.subAgents==null?e.subAgents:[...e.subAgents??[],...t.subAgents],s=t.skills==null?e.skills:[...e.skills??[],...t.skills],c=t.aiAgentIgnoreConfigFiles==null?e.aiAgentIgnoreConfigFiles:[...e.aiAgentIgnoreConfigFiles??[],...t.aiAgentIgnoreConfigFiles],l=t.globalMemory??e.globalMemory,u=t.shadowProjectDir??e.shadowProjectDir,d=t.readmePrompts==null?e.readmePrompts:[...e.readmePrompts??[],...t.readmePrompts];return{...n==null?{}:{workspace:n},...r==null?{}:{externalProjects:r},...i==null?{}:{ideConfigFiles:i},...a==null?{}:{fastCommands:a},...o==null?{}:{subAgents:o},...s==null?{}:{skills:s},...c==null?{}:{aiAgentIgnoreConfigFiles:c},...l==null?{}:{globalMemory:l},...u==null?{}:{shadowProjectDir:u},...d==null?{}:{readmePrompts:d}}}};const kf={workspaceDir:_t,shadowProjectDir:`$WORKSPACE/${vt}`,shadowSkillSourceDir:yt,shadowFastCommandDir:bt,shadowSubAgentDir:xt,globalMemoryFile:Ct,shadowSourceProjectDir:St,externalProjects:[],excludePatterns:{},fastCommandSeriesOptions:{},plugins:[],logLevel:`info`};function Af(e){return{...e.workspaceDir==null?{}:{workspaceDir:e.workspaceDir},...e.shadowProjectDir==null?{}:{shadowProjectDir:e.shadowProjectDir},...e.shadowSkillSourceDir==null?{}:{shadowSkillSourceDir:e.shadowSkillSourceDir},...e.shadowFastCommandDir==null?{}:{shadowFastCommandDir:e.shadowFastCommandDir},...e.shadowSubAgentDir==null?{}:{shadowSubAgentDir:e.shadowSubAgentDir},...e.globalMemoryFile==null?{}:{globalMemoryFile:e.globalMemoryFile},...e.shadowSourceProjectDir==null?{}:{shadowSourceProjectDir:e.shadowSourceProjectDir},...e.externalProjects==null?{}:{externalProjects:e.externalProjects},...e.excludePatterns==null?{}:{excludePatterns:e.excludePatterns},...e.fastCommandSeriesOptions==null?{}:{fastCommandSeriesOptions:e.fastCommandSeriesOptions},...e.logLevel==null?{}:{logLevel:e.logLevel}}}function jf(...e){return e.reduce((e,t)=>Mf(e,t),{...kf})}function Mf(e,t){let n=t.externalProjects,r=t.plugins,i=t.excludePatterns,a=t.fastCommandSeriesOptions;return{...e,...t,externalProjects:[...e.externalProjects,...n??[]],plugins:[...e.plugins,...r??[]],excludePatterns:Nf(e.excludePatterns,i),fastCommandSeriesOptions:Pf(e.fastCommandSeriesOptions,a)}}function Nf(e,t){let n={...e};if(t)for(let[e,r]of Object.entries(t))n[e]=[...n[e]??[],...r];return n}function Pf(e,t){if(t==null)return e??{};if(e==null)return t;let n={};if(e.pluginOverrides!=null)for(let[t,r]of Object.entries(e.pluginOverrides))n[t]={...r};if(t.pluginOverrides!=null)for(let[e,r]of Object.entries(t.pluginOverrides))n[e]={...n[e],...r};let r=t.includeSeriesPrefix??e.includeSeriesPrefix,i=Object.keys(n).length>0;return r!=null&&i?{includeSeriesPrefix:r,pluginOverrides:n}:r==null?i?{pluginOverrides:n}:{}:{includeSeriesPrefix:r}}function Ff(e){return`pluginOptions`in e||`configLoaderOptions`in e||`loadUserConfig`in e}function If(e={}){let t,n,a;Ff(e)?(t=e.pluginOptions??{},n=e.loadUserConfig??!0,a=e.cwd):(t=e,n=!0);let o={};if(n){let e=hf(a);e.found&&(o=Af(e.config),Qd(`defineConfig`,t.logLevel??e.config.logLevel).debug(`Loaded config from: ${e.sources.join(`, `)}`))}let s=jf(o,t),{plugins:c=[],logLevel:l}=s,u={logger:Qd(`defineConfig`,l),userConfigOptions:s,fs:r,path:i,glob:Ze.default},d=c.filter(e=>e.type===ct.Input),f=c.filter(e=>e.type===ct.Output),p=new Of().executePluginsInOrder(d,u);if(p.workspace==null)throw Error(`Workspace not initialized by any plugin`);return{context:{workspace:p.workspace,ideConfigFiles:p.ideConfigFiles??[],...p.externalProjects!=null&&{externalProjects:p.externalProjects},...p.fastCommands!=null&&{fastCommands:p.fastCommands},...p.subAgents!=null&&{subAgents:p.subAgents},...p.skills!=null&&{skills:p.skills},...p.globalMemory!=null&&{globalMemory:p.globalMemory},...p.aiAgentIgnoreConfigFiles!=null&&{aiAgentIgnoreConfigFiles:p.aiAgentIgnoreConfigFiles},...p.shadowProjectDir!=null&&{shadowProjectDir:p.shadowProjectDir},...p.readmePrompts!=null&&{readmePrompts:p.readmePrompts}},outputPlugins:f}}const Lf=`AGENTS.md`;var Rf=class extends tf{constructor(){super(`AgentsOutputPlugin`,{outputFileName:Lf})}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.rootMemoryPrompt!=null&&e.dirFromWorkspacePath!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,Lf)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,Lf));return t}async canWrite(e){let{workspace:t}=e.collectedInputContext;return t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)?!0:(this.log.info(`No outputs to write, skipping`),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t){let t=r.name??`unknown`,i=r.dirFromWorkspacePath;if(i!=null){if(r.rootMemoryPrompt!=null){let a=await this.writePromptFile(e,i,r.rootMemoryPrompt.content,`project:${t}/root`);n.push(a)}if(r.childMemoryPrompts!=null)for(let i of r.childMemoryPrompts){let r=await this.writePromptFile(e,i.dir,i.content,`project:${t}/child:${i.workingChildDirectoryPath?.path??`unknown`}`);n.push(r)}}}return{files:n,dirs:r}}};const zf=[`.qoderignore`,`.cursorignore`,`.warpindexignore`];var Bf=class extends ef{constructor(){super(`AIAgentIgnoreConfigFileInputPlugin`)}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{shadowProjectDir:a}=this.resolveBasePaths(t),o=[];for(let e of zf){let t=i.join(a,e);if(r.existsSync(t)&&r.statSync(t).isFile())try{let i=r.readFileSync(t,`utf-8`);o.push({fileName:e,content:i}),n.debug(`Read ignore file: ${t}`)}catch(e){n.warn(`Failed to read ignore file ${t}`,{error:e})}}return{aiAgentIgnoreConfigFiles:o}}};const Vf=[`.qoderignore`,`.cursorignore`,`.warpindexignore`];var Hf=class extends tf{constructor(){super(`AIAgentIgnoreConfigFileOutputPlugin`)}async registerProjectOutputDirs(){return[]}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.dirFromWorkspacePath!=null&&e.isPromptSourceProject!==!0)for(let n of Vf){let r=i.join(e.dirFromWorkspacePath.path,n);t.push({pathKind:I.Relative,path:r,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>i.basename(e.dirFromWorkspacePath.path),getAbsolutePath:()=>i.join(e.dirFromWorkspacePath.basePath,r)})}return t}async registerGlobalOutputDirs(){return[]}async registerGlobalOutputFiles(){return[]}async canWrite(e){let{aiAgentIgnoreConfigFiles:t}=e.collectedInputContext;return t==null||t.length===0?(this.log.info(`No ignore config files to write, skipping`),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{aiAgentIgnoreConfigFiles:n}=e.collectedInputContext,r=[],i=[];if(n==null||n.length===0)return{files:r,dirs:i};for(let i of t){let t=i.dirFromWorkspacePath;if(t==null)continue;let a=i.name??`unknown`;for(let i of n){let n=await this.writeIgnoreFile(e,t,i,`project:${a}/${i.fileName}`);r.push(n)}}return{files:r,dirs:i}}async writeIgnoreFile(e,t,n,a){let o=i.join(t.path,n.fileName),s=i.join(t.basePath,o),c={pathKind:I.Relative,path:o,basePath:t.basePath,getDirectoryName:()=>i.basename(t.path),getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write ignore config file -> ${s}`),{path:c,success:!0,skipped:!1};try{return r.writeFileSync(s,n.content,`utf-8`),this.log.info(`Written ignore config file -> ${s}`),{path:c,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error(`Failed to write ignore config file ${a}: ${t}`),{path:c,success:!1,error:e}}}};const Uf=`CLAUDE.md`,Wf=`.claude`,Gf=`commands`,Kf=`agents`,qf=`skills`,Jf=[Gf,Kf,qf];var Yf=class extends tf{constructor(){super(`ClaudeCodeCLIOutputPlugin`,{globalConfigDir:Wf,outputFileName:Uf})}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.dirFromWorkspacePath!=null)for(let n of Jf){let r=i.join(e.dirFromWorkspacePath.path,Wf,n);t.push({pathKind:I.Relative,path:r,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>i.join(e.dirFromWorkspacePath.basePath,r)})}return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.rootMemoryPrompt!=null&&e.dirFromWorkspacePath!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,Uf)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,Uf));return t}async registerGlobalOutputFiles(e){let{globalMemory:t}=e.collectedInputContext;if(t==null)return[];let n=this.getGlobalConfigDir();return[{pathKind:I.Relative,path:Uf,basePath:n,getDirectoryName:()=>Wf,getAbsolutePath:()=>i.join(n,Uf)}]}async canWrite(e){let{workspace:t,globalMemory:n,fastCommands:r,subAgents:i,skills:a}=e.collectedInputContext,o=t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0),s=n!=null,c=(r?.length??0)>0,l=(i?.length??0)>0,u=(a?.length??0)>0;return!o&&!s&&!c&&!l&&!u?(this.log.info(`No outputs to write, skipping`),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{fastCommands:n,subAgents:r,skills:i}=e.collectedInputContext,a=[],o=[];for(let o of t){let t=o.name??`unknown`,s=o.dirFromWorkspacePath;if(s!=null){if(o.rootMemoryPrompt!=null){let n=await this.writePromptFile(e,s,o.rootMemoryPrompt.content,`project:${t}/root`);a.push(n)}if(o.childMemoryPrompts!=null)for(let n of o.childMemoryPrompts){let r=await this.writePromptFile(e,n.dir,n.content,`project:${t}/child:${n.workingChildDirectoryPath?.path??`unknown`}`);a.push(r)}if(n!=null)for(let t of n){let n=await this.writeFastCommand(e,s,t);a.push(...n)}if(r!=null)for(let t of r){let n=await this.writeSubAgent(e,s,t);a.push(...n)}if(i!=null)for(let t of i){let n=await this.writeSkill(e,s,t);a.push(...n)}}}return{files:a,dirs:o}}async writeGlobalOutputs(e){let{globalMemory:t}=e.collectedInputContext,n=[],a=[];if(t==null)return{files:n,dirs:a};let o=this.getGlobalConfigDir(),s=i.join(o,Uf),c={pathKind:I.Relative,path:Uf,basePath:o,getDirectoryName:()=>Wf,getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write global memory -> ${s}`),{files:[{path:c,success:!0,skipped:!1}],dirs:a};try{this.ensureDirectory(o),r.writeFileSync(s,t.content,`utf-8`),this.log.info(`Written global memory -> ${s}`),n.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write global memory: ${t}`),n.push({path:c,success:!1,error:e})}return{files:n,dirs:a}}async writeFastCommand(e,t,n){let a=[],o=this.getTransformOptionsFromContext(e),s=this.transformFastCommandName(n,o),c=i.join(t.basePath,t.path,Wf,Gf),l=i.join(c,s),u={pathKind:I.Relative,path:i.join(t.path,Wf,Gf,s),basePath:t.basePath,getDirectoryName:()=>Gf,getAbsolutePath:()=>l},d=this.buildMarkdownContent(n.rawFrontMatter,n.content);if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write fast command -> ${l}`),[{path:u,success:!0,skipped:!1}];try{this.ensureDirectory(c),r.writeFileSync(l,d,`utf-8`),this.log.info(`Written fast command -> ${l}`),a.push({path:u,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write fast command: ${t}`),a.push({path:u,success:!1,error:e})}return a}async writeSubAgent(e,t,n){let a=[],o=n.dir.path.endsWith(`.md`)?n.dir.path:`${n.dir.path}.md`,s=i.join(t.basePath,t.path,Wf,Kf),c=i.join(s,o),l={pathKind:I.Relative,path:i.join(t.path,Wf,Kf,o),basePath:t.basePath,getDirectoryName:()=>Kf,getAbsolutePath:()=>c},u=this.buildMarkdownContent(n.rawFrontMatter,n.content);if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write sub agent -> ${c}`),[{path:l,success:!0,skipped:!1}];try{this.ensureDirectory(s),r.writeFileSync(c,u,`utf-8`),this.log.info(`Written sub agent -> ${c}`),a.push({path:l,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write sub agent: ${t}`),a.push({path:l,success:!1,error:e})}return a}async writeSkill(e,t,n){let a=[],o=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),s=i.join(t.basePath,t.path,Wf,qf,o),c=i.join(s,`SKILL.md`),l={pathKind:I.Relative,path:i.join(t.path,Wf,qf,o,`SKILL.md`),basePath:t.basePath,getDirectoryName:()=>o,getAbsolutePath:()=>c},u=this.buildMarkdownContent(n.rawFrontMatter,n.content);if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write skill -> ${c}`),[{path:l,success:!0,skipped:!1}];try{if(this.ensureDirectory(s),r.writeFileSync(c,u,`utf-8`),this.log.info(`Written skill -> ${c}`),a.push({path:l,success:!0}),n.referenceDocuments!=null)for(let r of n.referenceDocuments){let n=await this.writeSkillReferenceDocument(e,s,o,r,t);a.push(...n)}}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write skill: ${t}`),a.push({path:l,success:!1,error:e})}return a}async writeSkillReferenceDocument(e,t,n,a,o){let s=[],c=a.dir.path,l=i.join(t,c),u={pathKind:I.Relative,path:i.join(o.path,Wf,qf,n,c),basePath:o.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>l};if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write skill reference doc -> ${l}`),[{path:u,success:!0,skipped:!1}];try{r.writeFileSync(l,a.content,`utf-8`),this.log.info(`Written skill reference doc -> ${l}`),s.push({path:u,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write skill reference doc: ${t}`),s.push({path:u,success:!1,error:e})}return s}};const Xf=`AGENTS.md`,Zf=`.factory`,Qf=`commands`,$f=`agents`,ep=`skills`,tp=[Qf,$f,ep];var np=class extends tf{constructor(){super(`DroidCLIOutputPlugin`,{globalConfigDir:Zf,outputFileName:Xf})}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.dirFromWorkspacePath!=null)for(let n of tp){let r=i.join(e.dirFromWorkspacePath.path,Zf,n);t.push({pathKind:I.Relative,path:r,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>i.join(e.dirFromWorkspacePath.basePath,r)})}return t}async registerProjectOutputFiles(e){return[]}async registerGlobalOutputFiles(e){let{globalMemory:t}=e.collectedInputContext;if(t==null)return[];let n=this.getGlobalConfigDir();return[{pathKind:I.Relative,path:Xf,basePath:n,getDirectoryName:()=>Zf,getAbsolutePath:()=>i.join(n,Xf)}]}async canWrite(e){let{globalMemory:t,fastCommands:n,subAgents:r,skills:i}=e.collectedInputContext,a=t!=null,o=(n?.length??0)>0,s=(r?.length??0)>0,c=(i?.length??0)>0;return!a&&!o&&!s&&!c?(this.log.info(`No outputs to write, skipping`),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{fastCommands:n,subAgents:r,skills:i}=e.collectedInputContext,a=[],o=[];for(let o of t){let t=o.dirFromWorkspacePath;if(t!=null){if(n!=null)for(let r of n){let n=await this.writeFastCommand(e,t,r);a.push(...n)}if(r!=null)for(let n of r){let r=await this.writeSubAgent(e,t,n);a.push(...r)}if(i!=null)for(let n of i){let r=await this.writeSkill(e,t,n);a.push(...r)}}}return{files:a,dirs:o}}async writeGlobalOutputs(e){let{globalMemory:t}=e.collectedInputContext,n=[],a=[];if(t==null)return{files:n,dirs:a};let o=this.getGlobalConfigDir(),s=i.join(o,Xf),c={pathKind:I.Relative,path:Xf,basePath:o,getDirectoryName:()=>Zf,getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write global memory -> ${s}`),{files:[{path:c,success:!0,skipped:!1}],dirs:a};try{this.ensureDirectory(o),r.writeFileSync(s,t.content,`utf-8`),this.log.info(`Written global memory -> ${s}`),n.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write global memory: ${t}`),n.push({path:c,success:!1,error:e})}return{files:n,dirs:a}}async writeFastCommand(e,t,n){let a=[],o=this.getTransformOptionsFromContext(e),s=this.transformFastCommandName(n,o),c=i.join(t.basePath,t.path,Zf,Qf),l=i.join(c,s),u={pathKind:I.Relative,path:i.join(t.path,Zf,Qf,s),basePath:t.basePath,getDirectoryName:()=>Qf,getAbsolutePath:()=>l},d=this.buildMarkdownContent(n.rawFrontMatter,n.content);if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write fast command -> ${l}`),[{path:u,success:!0,skipped:!1}];try{this.ensureDirectory(c),r.writeFileSync(l,d,`utf-8`),this.log.info(`Written fast command -> ${l}`),a.push({path:u,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write fast command: ${t}`),a.push({path:u,success:!1,error:e})}return a}async writeSubAgent(e,t,n){let a=[],o=n.dir.path.endsWith(`.md`)?n.dir.path:`${n.dir.path}.md`,s=i.join(t.basePath,t.path,Zf,$f),c=i.join(s,o),l={pathKind:I.Relative,path:i.join(t.path,Zf,$f,o),basePath:t.basePath,getDirectoryName:()=>$f,getAbsolutePath:()=>c},u=this.buildMarkdownContent(n.rawFrontMatter,n.content);if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write sub agent -> ${c}`),[{path:l,success:!0,skipped:!1}];try{this.ensureDirectory(s),r.writeFileSync(c,u,`utf-8`),this.log.info(`Written sub agent -> ${c}`),a.push({path:l,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write sub agent: ${t}`),a.push({path:l,success:!1,error:e})}return a}async writeSkill(e,t,n){let a=[],o=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),s=i.join(t.basePath,t.path,Zf,ep,o),c=i.join(s,`SKILL.md`),l={pathKind:I.Relative,path:i.join(t.path,Zf,ep,o,`SKILL.md`),basePath:t.basePath,getDirectoryName:()=>o,getAbsolutePath:()=>c},u=this.buildMarkdownContent(n.rawFrontMatter,n.content);if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write skill -> ${c}`),[{path:l,success:!0,skipped:!1}];try{if(this.ensureDirectory(s),r.writeFileSync(c,u,`utf-8`),this.log.info(`Written skill -> ${c}`),a.push({path:l,success:!0}),n.referenceDocuments!=null)for(let r of n.referenceDocuments){let n=await this.writeSkillReferenceDocument(e,s,o,r,t);a.push(...n)}}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write skill: ${t}`),a.push({path:l,success:!1,error:e})}return a}async writeSkillReferenceDocument(e,t,n,a,o){let s=[],c=a.dir.path,l=i.join(t,c),u={pathKind:I.Relative,path:i.join(o.path,Zf,ep,n,c),basePath:o.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>l};if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write skill reference doc -> ${l}`),[{path:u,success:!0,skipped:!1}];try{r.writeFileSync(l,a.content,`utf-8`),this.log.info(`Written skill reference doc -> ${l}`),s.push({path:u,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write skill reference doc: ${t}`),s.push({path:u,success:!1,error:e})}return s}},rp=class extends ef{constructor(){super(`FastCommandInputPlugin`)}extractSeriesInfo(e){let t=e.replace(/\.md$/,``),n=t.indexOf(`_`);return n===-1?{commandName:t}:{series:t.substring(0,n),commandName:t.substring(n+1)}}collect(e){let{userConfigOptions:t,logger:n}=e,{workspaceDir:r,shadowProjectDir:i}=this.resolveBasePaths(t),a=t.shadowFastCommandDir??bt,o=this.resolvePath(a,r,i),s=[];if(e.fs.existsSync(o)&&e.fs.statSync(o).isDirectory())try{let t=e.fs.readdirSync(o,{withFileTypes:!0});for(let n of t)if(n.isFile()&&n.name.endsWith(`.md`)){let t=e.path.join(o,n.name),r=Hl(e.fs.readFileSync(t,`utf-8`)),i=r.contentWithoutFrontMatter,a=this.extractSeriesInfo(n.name);s.push({type:lt.FastCommand,content:i,length:i.length,filePathKind:I.Relative,...r.yamlFrontMatter!=null&&{yamlFrontMatter:r.yamlFrontMatter},...r.rawFrontMatter!=null&&{rawFrontMatter:r.rawFrontMatter},markdownAst:r.markdownAst,markdownContents:r.markdownContents,dir:{pathKind:I.Relative,path:n.name,basePath:o,getDirectoryName:()=>n.name.replace(/\.md$/,``),getAbsolutePath:()=>t},...a.series!=null&&{series:a.series},commandName:a.commandName})}}catch(e){n.error(`Failed to scan fast commands at ${o}`,{error:e})}return{fastCommands:s}}};const ip=`GEMINI.md`,ap=`.gemini`;var op=class extends tf{constructor(){super(`GeminiCLIOutputPlugin`,{globalConfigDir:ap,outputFileName:ip})}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.rootMemoryPrompt!=null&&e.dirFromWorkspacePath!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,ip)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,ip));return t}async registerGlobalOutputFiles(e){let{globalMemory:t}=e.collectedInputContext;if(t==null)return[];let n=this.getGlobalConfigDir();return[{pathKind:I.Relative,path:ip,basePath:n,getDirectoryName:()=>ap,getAbsolutePath:()=>i.join(n,ip)}]}async canWrite(e){let{workspace:t,globalMemory:n}=e.collectedInputContext;return!t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)&&n==null?(this.log.info(`No outputs to write, skipping`),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t){let t=r.name??`unknown`,i=r.dirFromWorkspacePath;if(i!=null){if(r.rootMemoryPrompt!=null){let a=await this.writePromptFile(e,i,r.rootMemoryPrompt.content,`project:${t}/root`);n.push(a)}if(r.childMemoryPrompts!=null)for(let i of r.childMemoryPrompts){let r=await this.writePromptFile(e,i.dir,i.content,`project:${t}/child:${i.workingChildDirectoryPath?.path??`unknown`}`);n.push(r)}}}return{files:n,dirs:r}}async writeGlobalOutputs(e){let{globalMemory:t}=e.collectedInputContext,n=[],a=[];if(t==null)return{files:n,dirs:a};let o=this.getGlobalConfigDir(),s=i.join(o,ip),c={pathKind:I.Relative,path:ip,basePath:o,getDirectoryName:()=>ap,getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write global memory -> ${s}`),{files:[{path:c,success:!0,skipped:!1}],dirs:a};try{this.ensureDirectory(o),r.writeFileSync(s,t.content,`utf-8`),this.log.info(`Written global memory -> ${s}`),n.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write global memory: ${t}`),n.push({path:c,success:!1,error:e})}return{files:n,dirs:a}}},sp=class extends ef{constructor(){super(`GlobalMemoryInputPlugin`)}collect(e){let{userConfigOptions:t,fs:n,path:r}=e,{workspaceDir:i,shadowProjectDir:a}=this.resolveBasePaths(t),s=t.globalMemoryFile??Ct,c=this.resolvePath(s,i,a);if(n.existsSync(c)&&n.statSync(c).isFile()){let e=Hl(n.readFileSync(c,`utf-8`)),t=e.contentWithoutFrontMatter;return{globalMemory:{type:lt.GlobalMemory,content:t,length:t.length,filePathKind:I.Relative,...e.rawFrontMatter!=null&&{rawFrontMatter:e.rawFrontMatter},markdownAst:e.markdownAst,markdownContents:e.markdownContents,dir:{pathKind:I.Relative,path:r.basename(c),basePath:r.dirname(c),getDirectoryName:()=>r.basename(c),getAbsolutePath:()=>c},parentDirectoryPath:{type:pt.UserHome,directory:{pathKind:I.Relative,path:``,basePath:o.homedir(),getDirectoryName:()=>r.basename(o.homedir()),getAbsolutePath:()=>o.homedir()}}}}}return{}}},cp=class extends ef{constructor(){super(`IdeConfigInputPlugin`)}collect(e){let{userConfigOptions:t,fs:n,path:r}=e,{shadowProjectDir:i}=this.resolveBasePaths(t),a=[`.editorconfig`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`,`.vscode/settings.json`,`.vscode/extensions.json`],o=[];for(let e of a){let t=r.join(i,e);if(n.existsSync(t)&&n.statSync(t).isFile()){let i=n.readFileSync(t,`utf-8`),a=L.Original;e.includes(`.vscode`)?a=L.VSCode:e.includes(`.idea`)?a=L.IntellijIDEA:e.includes(`.editorconfig`)&&(a=L.EditorConfig),o.push({type:a,content:i,length:i.length,filePathKind:I.Absolute,dir:{pathKind:I.Absolute,path:t,getDirectoryName:()=>r.basename(t)}})}}return{ideConfigFiles:o}}};const lp=`.idea`,up=[`.editorconfig`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`];var dp=class extends tf{constructor(){super(`JetBrainsIDECodeStyleConfigOutputPlugin`)}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{ideConfigFiles:r}=e.collectedInputContext;if(!r.some(e=>e.type===L.IntellijIDEA||e.type===L.EditorConfig))return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&e.isPromptSourceProject!==!0)for(let e of up){let r=this.joinPath(n.path,e);t.push({pathKind:I.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>this.dirname(e),getAbsolutePath:()=>this.resolvePath(n.basePath,r)})}}return t}async canWrite(e){let{ideConfigFiles:t}=e.collectedInputContext;return t.some(e=>e.type===L.IntellijIDEA||e.type===L.EditorConfig)?!0:(this.log.info(`No JetBrains IDE config files found, skipping`),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{ideConfigFiles:n}=e.collectedInputContext,r=[],i=[],a=n.filter(e=>e.type===L.IntellijIDEA||e.type===L.EditorConfig);for(let n of t){let t=n.dirFromWorkspacePath;if(t==null)continue;let i=n.name??`unknown`;for(let n of a){let a=await this.writeConfigFile(e,t,n,`project:${i}`);r.push(a)}}return{files:r,dirs:i}}async writeConfigFile(e,t,n,r){let i=this.getTargetRelativePath(n),a=this.resolvePath(t.basePath,t.path,i),o={pathKind:I.Relative,path:this.joinPath(t.path,i),basePath:t.basePath,getDirectoryName:()=>this.dirname(i),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write ${r} -> ${a}`),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,n.content),this.log.info(`Written ${r} -> ${a}`),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error(`Failed to write ${r}: ${t}`),{path:o,success:!1,error:e}}}getTargetRelativePath(e){let t=e.dir.path;if(e.type===L.EditorConfig)return`.editorconfig`;if(e.type===L.IntellijIDEA){let e=t.indexOf(lp);return e===-1?this.joinPath(lp,`codeStyles`,this.basename(t)):t.substring(e)}return this.basename(t)}};const fp=`GLOBAL.md`,pp=`.kiro`,$=`steering`,mp=`POWER.md`;var hp=class extends tf{constructor(){super(`KiroCLIOutputPlugin`,{globalConfigDir:pp,outputFileName:fp})}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n){if(e.dirFromWorkspacePath==null)continue;let n=this.joinPath(e.dirFromWorkspacePath.path,pp,$);t.push({pathKind:I.Relative,path:n,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(e.dirFromWorkspacePath.basePath,n)})}return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.dirFromWorkspacePath!=null&&e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts){let r=this.buildSteeringFileName(n),i=this.joinPath(e.dirFromWorkspacePath.path,pp,$,r);t.push({pathKind:I.Relative,path:i,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(e.dirFromWorkspacePath.basePath,i)})}return t}async registerGlobalOutputDirs(e){let t=this.getGlobalSteeringDir(),n=[{pathKind:I.Relative,path:$,basePath:this.joinPath(this.getGlobalConfigDir()),getDirectoryName:()=>$,getAbsolutePath:()=>t}],{skills:r}=e.collectedInputContext;if(r!=null){let e=this.getKiroPowersDir();for(let t of r){let r=t.yamlFrontMatter.name,i=this.joinPath(e,r);n.push({pathKind:I.Relative,path:r,basePath:e,getDirectoryName:()=>r,getAbsolutePath:()=>i})}}return n}async registerGlobalOutputFiles(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=this.getGlobalSteeringDir();if(t!=null&&i.push({pathKind:I.Relative,path:fp,basePath:a,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(a,fp)}),n!=null)for(let e of n){let t=this.buildFastCommandSteeringFileName(e);i.push({pathKind:I.Relative,path:t,basePath:a,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(a,t)})}if(r!=null){let e=this.getKiroPowersDir();for(let t of r){let n=t.yamlFrontMatter.name,r=this.joinPath(e,n);if(i.push({pathKind:I.Relative,path:mp,basePath:r,getDirectoryName:()=>n,getAbsolutePath:()=>this.joinPath(r,mp)}),t.referenceDocuments!=null){let e=this.joinPath(r,$);for(let n of t.referenceDocuments){let t=n.dir.path;i.push({pathKind:I.Relative,path:this.joinPath($,t),basePath:r,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(e,t)})}}}}return i}async canWrite(e){let{workspace:t,globalMemory:n,fastCommands:r,skills:i}=e.collectedInputContext,a=t.projects.some(e=>(e.childMemoryPrompts?.length??0)>0),o=n!=null,s=(r?.length??0)>0,c=(i?.length??0)>0;return!a&&!o&&!s&&!c?(this.log.info(`No outputs to write, skipping`),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t)if(r.dirFromWorkspacePath!=null&&r.childMemoryPrompts!=null)for(let t of r.childMemoryPrompts){let i=await this.writeSteeringFile(e,r,t);n.push(i)}return{files:n,dirs:r}}async writeGlobalOutputs(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=[],o=[];if(t!=null){let n=this.getGlobalSteeringDir(),r=this.joinPath(n,fp),a={pathKind:I.Relative,path:fp,basePath:n,getDirectoryName:()=>$,getAbsolutePath:()=>r};if(e.dryRun===!0)this.log.info(`[DRY-RUN] Would write global memory -> ${r}`),i.push({path:a,success:!0,skipped:!1});else try{this.ensureDirectory(n),this.writeFileSync(r,t.content),this.log.info(`Written global memory -> ${r}`),i.push({path:a,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write global memory: ${t}`),i.push({path:a,success:!1,error:e})}}if(n!=null)for(let t of n){let n=await this.writeFastCommandSteeringFile(e,t);i.push(n)}if(r!=null&&r.length>0){this.log.debug(`Processing ${r.length} skills as Kiro Powers`);for(let t of r){let{fileResults:n,registryResult:r}=await this.writeSkillAsPower(e,t);i.push(...n),o.push(r)}this.logRegistryResults(o,e.dryRun)}return{files:i,dirs:a}}logRegistryResults(e,t){let n=t===!0?`[DRY-RUN] `:``,r=e.filter(e=>e.success).length,i=e.filter(e=>!e.success).length;if(r>0&&this.log.info(`${n}Registry: ${r} power(s) registered successfully`),i>0){this.log.error(`${n}Registry: ${i} power(s) failed to register`);for(let t of e)if(!t.success){let e=t.error?.message??`Unknown error`;this.log.error(` - ${t.entryName}: ${e}`)}}}getGlobalSteeringDir(){return this.joinPath(this.getGlobalConfigDir(),$)}getKiroPowersDir(){return this.joinPath(this.getHomeDir(),`.kiro/powers/installed`)}getHomeDir(){return s.homedir()}buildPowerFrontMatter(e){let t=e.name,n=e.description,r=e.displayName,i=e.keywords,a=e.author,o=[`---`];if(o.push(`name: "${t}"`),r!=null&&r.length>0&&o.push(`displayName: "${r}"`),n.length>0&&o.push(`description: "${n}"`),i!=null&&i.length>0){let e=i.map(e=>`"${e}"`).join(`, `);o.push(`keywords: [${e}]`)}return a!=null&&a.length>0&&o.push(`author: "${a}"`),o.push(`---`),o.join(`
|
|
207
|
+
`,`utf-8`),t.info(`created global memory file`,{path:d}),h++),t.info(`Initialization complete`,{dirsCreated:p,dirsExisted:m,filesCreated:h,filesExisted:g});let v=p===0&&h===0?`All ${m} directories and ${g} files already exist`:`Created ${p} directories and ${h} files (${m} dirs, ${g} files already existed)`;return{success:!0,filesAffected:h,dirsAffected:p,message:v}}},vf=class{name=`unknown`;constructor(e){this.unknownCmd=e}async execute(e){return console.error(`Unknown command: ${this.unknownCmd}`),console.error(`Run "tnmsc help" for available commands.`),{success:!1,filesAffected:0,dirsAffected:0}}};function yf(e){let t=[...e],n=t[0];n!=null&&bf(n)&&t.shift();let r=t[0];return r!=null&&xf(r)&&t.shift(),t}function bf(e){let t=[`node`,`nodejs`,`bun`,`deno`,`tsx`,`ts-node`,`npx`,`pnpx`,`yarn`,`pnpm`],n=e.toLowerCase().replace(/\\/g,`/`);return t.some(e=>RegExp(`(?:^|/)${e}(?:\\.exe|\\.cmd|\\.ps1)?$`,`i`).test(n)||n===e)}function xf(e){return!!(/\.(?:m?[jt]s|cjs)$/.test(e)||/[/\\]/.test(e)&&!e.startsWith(`-`)||/^(?:@[\w-]+\/)?[\w-]+$/.test(e)&&!e.startsWith(`-`))}const Sf=new Set([`help`,`init`,`dry-run`,`clean`]),Cf=new Map([[`--trace`,`trace`],[`--debug`,`debug`],[`--info`,`info`],[`--warn`,`warn`],[`--error`,`error`]]),wf=new Map([[`trace`,0],[`debug`,1],[`info`,2],[`warn`,3],[`error`,4]]);function Tf(e){let{logLevelFlags:t}=e;if(t.length===0)return;let n=t[0],r=wf.get(n)??4;for(let e of t){let t=wf.get(e)??4;t<r&&(r=t,n=e)}return n}function Ef(e){let{helpFlag:t,subcommand:n,dryRun:r,unknownCommand:i}=e;return t?new lf:i==null?n===`help`?new lf:n===`init`?new _f:n===`dry-run`?new of:n===`clean`?r?new af:new st:new sf:new vf(i)}function Df(e){let t={subcommand:void 0,helpFlag:!1,dryRun:!1,logLevel:void 0,logLevelFlags:[],unknownCommand:void 0,positional:[],unknown:[]},n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i!=null){if(i===`--`){t.positional.push(...e.slice(r+1).filter(e=>e!=null));break}if(i.startsWith(`--`)){let e=i.split(`=`)[0]??``,n=Cf.get(e);if(n!=null){t.logLevelFlags.push(n),t.logLevel=n;continue}switch(e){case`--help`:t.helpFlag=!0;break;case`--dry-run`:t.dryRun=!0;break;default:t.unknown.push(i)}continue}if(i.startsWith(`-`)&&i.length>1){let e=i.slice(1);for(let n of e)switch(n){case`h`:t.helpFlag=!0;break;case`n`:t.dryRun=!0;break;default:t.unknown.push(`-${n}`)}continue}if(!n){n=!0,Sf.has(i)?t.subcommand=i:t.unknownCommand=i;continue}t.positional.push(i)}}return t}var Of=class{logger;args;outputPlugins=[];constructor(...e){this.args=Df(yf(e.filter(e=>e!=null))),this.logger=Qd(`PluginPipeline`,Tf(this.args)),this.logger.debug(`initialized`,{args:this.args})}registerOutputPlugins(e){return this.outputPlugins.push(...e),this}async run(e){let{context:t,outputPlugins:n}=e;this.registerOutputPlugins([...n]);let r=this.resolveCommand(),i=this.createCommandContext(t);await r.execute(i)}resolveCommand(){return Ef(this.args)}createCommandContext(e){return{logger:this.logger,outputPlugins:this.outputPlugins,collectedInputContext:e,createCleanContext:t=>this.createCleanContext(e,t),createWriteContext:t=>this.createWriteContext(e,t)}}createCleanContext(e,t){return{logger:this.logger,fs:r,path:i,glob:Ze.default,collectedInputContext:e,dryRun:t}}createWriteContext(e,t){return{logger:this.logger,fs:r,path:i,glob:Ze.default,collectedInputContext:e,dryRun:t,registeredPluginNames:this.outputPlugins.map(e=>e.name)}}buildDependencyGraph(e){let t=new Map;for(let n of e){let e=n.dependsOn??[];t.set(n.name,[...e])}return t}validateDependencies(e){let t=new Set(e.map(e=>e.name));for(let n of e){let e=n.dependsOn??[];for(let r of e)if(!t.has(r))throw new ht(n.name,r)}}topologicalSort(e){this.validateDependencies(e);let t=new Map;for(let n of e)t.set(n.name,n);let n=new Map;for(let t of e)n.set(t.name,0);let r=new Map;for(let t of e)r.set(t.name,[]);for(let t of e){let e=t.dependsOn??[];for(let i of e){n.set(t.name,(n.get(t.name)??0)+1);let e=r.get(i)??[];e.push(t.name),r.set(i,e)}}let i=[];for(let t of e)n.get(t.name)===0&&i.push(t.name);let a=[];for(;i.length>0;){let o=i.shift(),s=t.get(o);a.push(s);let c=(r.get(o)??[]).sort((t,n)=>e.findIndex(e=>e.name===t)-e.findIndex(e=>e.name===n));for(let e of c){let t=(n.get(e)??0)-1;n.set(e,t),t===0&&i.push(e)}}if(a.length!==e.length)throw new mt(this.findCyclePath(e,n));return a}findCyclePath(e,t){let n=new Set;for(let[e,r]of t)r>0&&n.add(e);let r=new Map;for(let t of e)if(n.has(t.name)){let e=(t.dependsOn??[]).filter(e=>n.has(e));r.set(t.name,e)}let i=new Set,a=[],o=e=>{if(a.includes(e))return a.push(e),!0;if(i.has(e))return!1;i.add(e),a.push(e);for(let t of r.get(e)??[])if(o(t))return!0;return a.pop(),!1};for(let e of n){if(o(e)){let e=a.indexOf(a[a.length-1]);return a.slice(e)}i.clear(),a.length=0}return Array.from(n)}executePluginsInOrder(e,t){if(e.length===0)return{};let n=this.topologicalSort(e),r=new Map,i={};for(let e of n){let n=this.buildDependencyContext(e,r),a={...t,dependencyContext:n},o=e.collect(a);r.set(e.name,o),i=this.mergeContexts(i,o)}return i}buildDependencyContext(e,t){if((e.dependsOn??[]).length===0)return{};let n=this.collectTransitiveDependencies(e,t),r={};for(let e of n){let n=t.get(e);n!=null&&(r=this.mergeContexts(r,n))}return r}collectTransitiveDependencies(e,t){let n=new Set,r=[];return(e=>{for(let i of e)n.has(i)||(n.add(i),t.get(i)!=null&&r.push(i))})(e.dependsOn??[]),r}mergeContexts(e,t){let n=e.workspace;if(t.workspace!=null)if(n!=null){let e=new Map;for(let t of n.projects)e.set(t.name,t);for(let n of t.workspace.projects)e.set(n.name,n);n={directory:t.workspace.directory??n.directory,projects:Array.from(e.values())}}else n=t.workspace;let r=t.externalProjects==null?e.externalProjects:[...e.externalProjects??[],...t.externalProjects],i=t.ideConfigFiles==null?e.ideConfigFiles:[...e.ideConfigFiles??[],...t.ideConfigFiles],a=t.fastCommands==null?e.fastCommands:[...e.fastCommands??[],...t.fastCommands],o=t.subAgents==null?e.subAgents:[...e.subAgents??[],...t.subAgents],s=t.skills==null?e.skills:[...e.skills??[],...t.skills],c=t.aiAgentIgnoreConfigFiles==null?e.aiAgentIgnoreConfigFiles:[...e.aiAgentIgnoreConfigFiles??[],...t.aiAgentIgnoreConfigFiles],l=t.globalMemory??e.globalMemory,u=t.shadowProjectDir??e.shadowProjectDir,d=t.readmePrompts==null?e.readmePrompts:[...e.readmePrompts??[],...t.readmePrompts];return{...n==null?{}:{workspace:n},...r==null?{}:{externalProjects:r},...i==null?{}:{ideConfigFiles:i},...a==null?{}:{fastCommands:a},...o==null?{}:{subAgents:o},...s==null?{}:{skills:s},...c==null?{}:{aiAgentIgnoreConfigFiles:c},...l==null?{}:{globalMemory:l},...u==null?{}:{shadowProjectDir:u},...d==null?{}:{readmePrompts:d}}}};const kf={workspaceDir:_t,shadowProjectDir:`$WORKSPACE/${vt}`,shadowSkillSourceDir:yt,shadowFastCommandDir:bt,shadowSubAgentDir:xt,globalMemoryFile:Ct,shadowSourceProjectDir:St,externalProjects:[],excludePatterns:{},fastCommandSeriesOptions:{},plugins:[],logLevel:`info`};function Af(e){return{...e.workspaceDir==null?{}:{workspaceDir:e.workspaceDir},...e.shadowProjectDir==null?{}:{shadowProjectDir:e.shadowProjectDir},...e.shadowSkillSourceDir==null?{}:{shadowSkillSourceDir:e.shadowSkillSourceDir},...e.shadowFastCommandDir==null?{}:{shadowFastCommandDir:e.shadowFastCommandDir},...e.shadowSubAgentDir==null?{}:{shadowSubAgentDir:e.shadowSubAgentDir},...e.globalMemoryFile==null?{}:{globalMemoryFile:e.globalMemoryFile},...e.shadowSourceProjectDir==null?{}:{shadowSourceProjectDir:e.shadowSourceProjectDir},...e.externalProjects==null?{}:{externalProjects:e.externalProjects},...e.excludePatterns==null?{}:{excludePatterns:e.excludePatterns},...e.fastCommandSeriesOptions==null?{}:{fastCommandSeriesOptions:e.fastCommandSeriesOptions},...e.logLevel==null?{}:{logLevel:e.logLevel}}}function jf(...e){return e.reduce((e,t)=>Mf(e,t),{...kf})}function Mf(e,t){let n=t.externalProjects,r=t.plugins,i=t.excludePatterns,a=t.fastCommandSeriesOptions;return{...e,...t,externalProjects:[...e.externalProjects,...n??[]],plugins:[...e.plugins,...r??[]],excludePatterns:Nf(e.excludePatterns,i),fastCommandSeriesOptions:Pf(e.fastCommandSeriesOptions,a)}}function Nf(e,t){let n={...e};if(t)for(let[e,r]of Object.entries(t))n[e]=[...n[e]??[],...r];return n}function Pf(e,t){if(t==null)return e??{};if(e==null)return t;let n={};if(e.pluginOverrides!=null)for(let[t,r]of Object.entries(e.pluginOverrides))n[t]={...r};if(t.pluginOverrides!=null)for(let[e,r]of Object.entries(t.pluginOverrides))n[e]={...n[e],...r};let r=t.includeSeriesPrefix??e.includeSeriesPrefix,i=Object.keys(n).length>0;return r!=null&&i?{includeSeriesPrefix:r,pluginOverrides:n}:r==null?i?{pluginOverrides:n}:{}:{includeSeriesPrefix:r}}function Ff(e){return`pluginOptions`in e||`configLoaderOptions`in e||`loadUserConfig`in e}function If(e={}){let t,n,a;Ff(e)?(t=e.pluginOptions??{},n=e.loadUserConfig??!0,a=e.cwd):(t=e,n=!0);let o={};if(n){let e=hf(a);e.found&&(o=Af(e.config),Qd(`defineConfig`,t.logLevel??e.config.logLevel).debug(`loaded`,{sources:e.sources}))}let s=jf(o,t),{plugins:c=[],logLevel:l}=s,u={logger:Qd(`defineConfig`,l),userConfigOptions:s,fs:r,path:i,glob:Ze.default},d=c.filter(e=>e.type===ct.Input),f=c.filter(e=>e.type===ct.Output),p=new Of().executePluginsInOrder(d,u);if(p.workspace==null)throw Error(`Workspace not initialized by any plugin`);return{context:{workspace:p.workspace,ideConfigFiles:p.ideConfigFiles??[],...p.externalProjects!=null&&{externalProjects:p.externalProjects},...p.fastCommands!=null&&{fastCommands:p.fastCommands},...p.subAgents!=null&&{subAgents:p.subAgents},...p.skills!=null&&{skills:p.skills},...p.globalMemory!=null&&{globalMemory:p.globalMemory},...p.aiAgentIgnoreConfigFiles!=null&&{aiAgentIgnoreConfigFiles:p.aiAgentIgnoreConfigFiles},...p.shadowProjectDir!=null&&{shadowProjectDir:p.shadowProjectDir},...p.readmePrompts!=null&&{readmePrompts:p.readmePrompts}},outputPlugins:f}}const Lf=`AGENTS.md`;var Rf=class extends tf{constructor(){super(`AgentsOutputPlugin`,{outputFileName:Lf})}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.rootMemoryPrompt!=null&&e.dirFromWorkspacePath!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,Lf)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,Lf));return t}async canWrite(e){let{workspace:t}=e.collectedInputContext;return t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)?!0:(this.log.info(`No outputs to write, skipping`),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t){let t=r.name??`unknown`,i=r.dirFromWorkspacePath;if(i!=null){if(r.rootMemoryPrompt!=null){let a=await this.writePromptFile(e,i,r.rootMemoryPrompt.content,`project:${t}/root`);n.push(a)}if(r.childMemoryPrompts!=null)for(let i of r.childMemoryPrompts){let r=await this.writePromptFile(e,i.dir,i.content,`project:${t}/child:${i.workingChildDirectoryPath?.path??`unknown`}`);n.push(r)}}}return{files:n,dirs:r}}};const zf=[`.qoderignore`,`.cursorignore`,`.warpindexignore`];var Bf=class extends ef{constructor(){super(`AIAgentIgnoreConfigFileInputPlugin`)}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{shadowProjectDir:a}=this.resolveBasePaths(t),o=[];for(let e of zf){let t=i.join(a,e);if(r.existsSync(t)&&r.statSync(t).isFile())try{let i=r.readFileSync(t,`utf-8`);o.push({fileName:e,content:i}),n.debug(`read ignore file`,{path:t})}catch(e){n.warn(`failed to read ignore file`,{path:t,error:e})}}return{aiAgentIgnoreConfigFiles:o}}};const Vf=[`.qoderignore`,`.cursorignore`,`.warpindexignore`];var Hf=class extends tf{constructor(){super(`AIAgentIgnoreConfigFileOutputPlugin`)}async registerProjectOutputDirs(){return[]}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.dirFromWorkspacePath!=null&&e.isPromptSourceProject!==!0)for(let n of Vf){let r=i.join(e.dirFromWorkspacePath.path,n);t.push({pathKind:I.Relative,path:r,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>i.basename(e.dirFromWorkspacePath.path),getAbsolutePath:()=>i.join(e.dirFromWorkspacePath.basePath,r)})}return t}async registerGlobalOutputDirs(){return[]}async registerGlobalOutputFiles(){return[]}async canWrite(e){let{aiAgentIgnoreConfigFiles:t}=e.collectedInputContext;return t==null||t.length===0?(this.log.debug(`skipped`,{reason:`no ignore config files to write`}),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{aiAgentIgnoreConfigFiles:n}=e.collectedInputContext,r=[],i=[];if(n==null||n.length===0)return{files:r,dirs:i};for(let i of t){let t=i.dirFromWorkspacePath;if(t==null)continue;let a=i.name??`unknown`;for(let i of n){let n=await this.writeIgnoreFile(e,t,i,`project:${a}/${i.fileName}`);r.push(n)}}return{files:r,dirs:i}}async writeIgnoreFile(e,t,n,a){let o=i.join(t.path,n.fileName),s=i.join(t.basePath,o),c={pathKind:I.Relative,path:o,basePath:t.basePath,getDirectoryName:()=>i.basename(t.path),getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.info(`would write`,{path:s,label:a,dryRun:!0}),{path:c,success:!0,skipped:!1};try{return r.writeFileSync(s,n.content,`utf-8`),this.log.info(`written`,{path:s,label:a}),{path:c,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error(`write failed`,{path:s,label:a,error:t}),{path:c,success:!1,error:e}}}};const Uf=`CLAUDE.md`,Wf=`.claude`,Gf=`commands`,Kf=`agents`,qf=`skills`,Jf=[Gf,Kf,qf];var Yf=class extends tf{constructor(){super(`ClaudeCodeCLIOutputPlugin`,{globalConfigDir:Wf,outputFileName:Uf})}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.dirFromWorkspacePath!=null)for(let n of Jf){let r=i.join(e.dirFromWorkspacePath.path,Wf,n);t.push({pathKind:I.Relative,path:r,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>i.join(e.dirFromWorkspacePath.basePath,r)})}return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.rootMemoryPrompt!=null&&e.dirFromWorkspacePath!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,Uf)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,Uf));return t}async registerGlobalOutputFiles(e){let{globalMemory:t}=e.collectedInputContext;if(t==null)return[];let n=this.getGlobalConfigDir();return[{pathKind:I.Relative,path:Uf,basePath:n,getDirectoryName:()=>Wf,getAbsolutePath:()=>i.join(n,Uf)}]}async canWrite(e){let{workspace:t,globalMemory:n,fastCommands:r,subAgents:i,skills:a}=e.collectedInputContext,o=t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0),s=n!=null,c=(r?.length??0)>0,l=(i?.length??0)>0,u=(a?.length??0)>0;return!o&&!s&&!c&&!l&&!u?(this.log.info(`No outputs to write, skipping`),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{fastCommands:n,subAgents:r,skills:i}=e.collectedInputContext,a=[],o=[];for(let o of t){let t=o.name??`unknown`,s=o.dirFromWorkspacePath;if(s!=null){if(o.rootMemoryPrompt!=null){let n=await this.writePromptFile(e,s,o.rootMemoryPrompt.content,`project:${t}/root`);a.push(n)}if(o.childMemoryPrompts!=null)for(let n of o.childMemoryPrompts){let r=await this.writePromptFile(e,n.dir,n.content,`project:${t}/child:${n.workingChildDirectoryPath?.path??`unknown`}`);a.push(r)}if(n!=null)for(let t of n){let n=await this.writeFastCommand(e,s,t);a.push(...n)}if(r!=null)for(let t of r){let n=await this.writeSubAgent(e,s,t);a.push(...n)}if(i!=null)for(let t of i){let n=await this.writeSkill(e,s,t);a.push(...n)}}}return{files:a,dirs:o}}async writeGlobalOutputs(e){let{globalMemory:t}=e.collectedInputContext,n=[],a=[];if(t==null)return{files:n,dirs:a};let o=this.getGlobalConfigDir(),s=i.join(o,Uf),c={pathKind:I.Relative,path:Uf,basePath:o,getDirectoryName:()=>Wf,getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write global memory -> ${s}`),{files:[{path:c,success:!0,skipped:!1}],dirs:a};try{this.ensureDirectory(o),r.writeFileSync(s,t.content,`utf-8`),this.log.info(`Written global memory -> ${s}`),n.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write global memory: ${t}`),n.push({path:c,success:!1,error:e})}return{files:n,dirs:a}}async writeFastCommand(e,t,n){let a=[],o=this.getTransformOptionsFromContext(e),s=this.transformFastCommandName(n,o),c=i.join(t.basePath,t.path,Wf,Gf),l=i.join(c,s),u={pathKind:I.Relative,path:i.join(t.path,Wf,Gf,s),basePath:t.basePath,getDirectoryName:()=>Gf,getAbsolutePath:()=>l},d=this.buildMarkdownContent(n.rawFrontMatter,n.content);if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write fast command -> ${l}`),[{path:u,success:!0,skipped:!1}];try{this.ensureDirectory(c),r.writeFileSync(l,d,`utf-8`),this.log.info(`Written fast command -> ${l}`),a.push({path:u,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write fast command: ${t}`),a.push({path:u,success:!1,error:e})}return a}async writeSubAgent(e,t,n){let a=[],o=n.dir.path.endsWith(`.md`)?n.dir.path:`${n.dir.path}.md`,s=i.join(t.basePath,t.path,Wf,Kf),c=i.join(s,o),l={pathKind:I.Relative,path:i.join(t.path,Wf,Kf,o),basePath:t.basePath,getDirectoryName:()=>Kf,getAbsolutePath:()=>c},u=this.buildMarkdownContent(n.rawFrontMatter,n.content);if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write sub agent -> ${c}`),[{path:l,success:!0,skipped:!1}];try{this.ensureDirectory(s),r.writeFileSync(c,u,`utf-8`),this.log.info(`Written sub agent -> ${c}`),a.push({path:l,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write sub agent: ${t}`),a.push({path:l,success:!1,error:e})}return a}async writeSkill(e,t,n){let a=[],o=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),s=i.join(t.basePath,t.path,Wf,qf,o),c=i.join(s,`SKILL.md`),l={pathKind:I.Relative,path:i.join(t.path,Wf,qf,o,`SKILL.md`),basePath:t.basePath,getDirectoryName:()=>o,getAbsolutePath:()=>c},u=this.buildMarkdownContent(n.rawFrontMatter,n.content);if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write skill -> ${c}`),[{path:l,success:!0,skipped:!1}];try{if(this.ensureDirectory(s),r.writeFileSync(c,u,`utf-8`),this.log.info(`Written skill -> ${c}`),a.push({path:l,success:!0}),n.referenceDocuments!=null)for(let r of n.referenceDocuments){let n=await this.writeSkillReferenceDocument(e,s,o,r,t);a.push(...n)}}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write skill: ${t}`),a.push({path:l,success:!1,error:e})}return a}async writeSkillReferenceDocument(e,t,n,a,o){let s=[],c=a.dir.path,l=i.join(t,c),u={pathKind:I.Relative,path:i.join(o.path,Wf,qf,n,c),basePath:o.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>l};if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write skill reference doc -> ${l}`),[{path:u,success:!0,skipped:!1}];try{r.writeFileSync(l,a.content,`utf-8`),this.log.info(`Written skill reference doc -> ${l}`),s.push({path:u,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write skill reference doc: ${t}`),s.push({path:u,success:!1,error:e})}return s}};const Xf=`AGENTS.md`,Zf=`.factory`,Qf=`commands`,$f=`agents`,ep=`skills`,tp=[Qf,$f,ep];var np=class extends tf{constructor(){super(`DroidCLIOutputPlugin`,{globalConfigDir:Zf,outputFileName:Xf})}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.dirFromWorkspacePath!=null)for(let n of tp){let r=i.join(e.dirFromWorkspacePath.path,Zf,n);t.push({pathKind:I.Relative,path:r,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>i.join(e.dirFromWorkspacePath.basePath,r)})}return t}async registerProjectOutputFiles(e){return[]}async registerGlobalOutputFiles(e){let{globalMemory:t}=e.collectedInputContext;if(t==null)return[];let n=this.getGlobalConfigDir();return[{pathKind:I.Relative,path:Xf,basePath:n,getDirectoryName:()=>Zf,getAbsolutePath:()=>i.join(n,Xf)}]}async canWrite(e){let{globalMemory:t,fastCommands:n,subAgents:r,skills:i}=e.collectedInputContext,a=t!=null,o=(n?.length??0)>0,s=(r?.length??0)>0,c=(i?.length??0)>0;return!a&&!o&&!s&&!c?(this.log.info(`No outputs to write, skipping`),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{fastCommands:n,subAgents:r,skills:i}=e.collectedInputContext,a=[],o=[];for(let o of t){let t=o.dirFromWorkspacePath;if(t!=null){if(n!=null)for(let r of n){let n=await this.writeFastCommand(e,t,r);a.push(...n)}if(r!=null)for(let n of r){let r=await this.writeSubAgent(e,t,n);a.push(...r)}if(i!=null)for(let n of i){let r=await this.writeSkill(e,t,n);a.push(...r)}}}return{files:a,dirs:o}}async writeGlobalOutputs(e){let{globalMemory:t}=e.collectedInputContext,n=[],a=[];if(t==null)return{files:n,dirs:a};let o=this.getGlobalConfigDir(),s=i.join(o,Xf),c={pathKind:I.Relative,path:Xf,basePath:o,getDirectoryName:()=>Zf,getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write global memory -> ${s}`),{files:[{path:c,success:!0,skipped:!1}],dirs:a};try{this.ensureDirectory(o),r.writeFileSync(s,t.content,`utf-8`),this.log.info(`Written global memory -> ${s}`),n.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write global memory: ${t}`),n.push({path:c,success:!1,error:e})}return{files:n,dirs:a}}async writeFastCommand(e,t,n){let a=[],o=this.getTransformOptionsFromContext(e),s=this.transformFastCommandName(n,o),c=i.join(t.basePath,t.path,Zf,Qf),l=i.join(c,s),u={pathKind:I.Relative,path:i.join(t.path,Zf,Qf,s),basePath:t.basePath,getDirectoryName:()=>Qf,getAbsolutePath:()=>l},d=this.buildMarkdownContent(n.rawFrontMatter,n.content);if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write fast command -> ${l}`),[{path:u,success:!0,skipped:!1}];try{this.ensureDirectory(c),r.writeFileSync(l,d,`utf-8`),this.log.info(`Written fast command -> ${l}`),a.push({path:u,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write fast command: ${t}`),a.push({path:u,success:!1,error:e})}return a}async writeSubAgent(e,t,n){let a=[],o=n.dir.path.endsWith(`.md`)?n.dir.path:`${n.dir.path}.md`,s=i.join(t.basePath,t.path,Zf,$f),c=i.join(s,o),l={pathKind:I.Relative,path:i.join(t.path,Zf,$f,o),basePath:t.basePath,getDirectoryName:()=>$f,getAbsolutePath:()=>c},u=this.buildMarkdownContent(n.rawFrontMatter,n.content);if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write sub agent -> ${c}`),[{path:l,success:!0,skipped:!1}];try{this.ensureDirectory(s),r.writeFileSync(c,u,`utf-8`),this.log.info(`Written sub agent -> ${c}`),a.push({path:l,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write sub agent: ${t}`),a.push({path:l,success:!1,error:e})}return a}async writeSkill(e,t,n){let a=[],o=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),s=i.join(t.basePath,t.path,Zf,ep,o),c=i.join(s,`SKILL.md`),l={pathKind:I.Relative,path:i.join(t.path,Zf,ep,o,`SKILL.md`),basePath:t.basePath,getDirectoryName:()=>o,getAbsolutePath:()=>c},u=this.buildMarkdownContent(n.rawFrontMatter,n.content);if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write skill -> ${c}`),[{path:l,success:!0,skipped:!1}];try{if(this.ensureDirectory(s),r.writeFileSync(c,u,`utf-8`),this.log.info(`Written skill -> ${c}`),a.push({path:l,success:!0}),n.referenceDocuments!=null)for(let r of n.referenceDocuments){let n=await this.writeSkillReferenceDocument(e,s,o,r,t);a.push(...n)}}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write skill: ${t}`),a.push({path:l,success:!1,error:e})}return a}async writeSkillReferenceDocument(e,t,n,a,o){let s=[],c=a.dir.path,l=i.join(t,c),u={pathKind:I.Relative,path:i.join(o.path,Zf,ep,n,c),basePath:o.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>l};if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write skill reference doc -> ${l}`),[{path:u,success:!0,skipped:!1}];try{r.writeFileSync(l,a.content,`utf-8`),this.log.info(`Written skill reference doc -> ${l}`),s.push({path:u,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write skill reference doc: ${t}`),s.push({path:u,success:!1,error:e})}return s}},rp=class extends ef{constructor(){super(`FastCommandInputPlugin`)}extractSeriesInfo(e){let t=e.replace(/\.md$/,``),n=t.indexOf(`_`);return n===-1?{commandName:t}:{series:t.substring(0,n),commandName:t.substring(n+1)}}collect(e){let{userConfigOptions:t,logger:n}=e,{workspaceDir:r,shadowProjectDir:i}=this.resolveBasePaths(t),a=t.shadowFastCommandDir??bt,o=this.resolvePath(a,r,i),s=[];if(e.fs.existsSync(o)&&e.fs.statSync(o).isDirectory())try{let t=e.fs.readdirSync(o,{withFileTypes:!0});for(let n of t)if(n.isFile()&&n.name.endsWith(`.md`)){let t=e.path.join(o,n.name),r=Hl(e.fs.readFileSync(t,`utf-8`)),i=r.contentWithoutFrontMatter,a=this.extractSeriesInfo(n.name);s.push({type:lt.FastCommand,content:i,length:i.length,filePathKind:I.Relative,...r.yamlFrontMatter!=null&&{yamlFrontMatter:r.yamlFrontMatter},...r.rawFrontMatter!=null&&{rawFrontMatter:r.rawFrontMatter},markdownAst:r.markdownAst,markdownContents:r.markdownContents,dir:{pathKind:I.Relative,path:n.name,basePath:o,getDirectoryName:()=>n.name.replace(/\.md$/,``),getAbsolutePath:()=>t},...a.series!=null&&{series:a.series},commandName:a.commandName})}}catch(e){n.error(`Failed to scan fast commands at ${o}`,{error:e})}return{fastCommands:s}}};const ip=`GEMINI.md`,ap=`.gemini`;var op=class extends tf{constructor(){super(`GeminiCLIOutputPlugin`,{globalConfigDir:ap,outputFileName:ip})}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.rootMemoryPrompt!=null&&e.dirFromWorkspacePath!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,ip)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,ip));return t}async registerGlobalOutputFiles(e){let{globalMemory:t}=e.collectedInputContext;if(t==null)return[];let n=this.getGlobalConfigDir();return[{pathKind:I.Relative,path:ip,basePath:n,getDirectoryName:()=>ap,getAbsolutePath:()=>i.join(n,ip)}]}async canWrite(e){let{workspace:t,globalMemory:n}=e.collectedInputContext;return!t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)&&n==null?(this.log.info(`No outputs to write, skipping`),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t){let t=r.name??`unknown`,i=r.dirFromWorkspacePath;if(i!=null){if(r.rootMemoryPrompt!=null){let a=await this.writePromptFile(e,i,r.rootMemoryPrompt.content,`project:${t}/root`);n.push(a)}if(r.childMemoryPrompts!=null)for(let i of r.childMemoryPrompts){let r=await this.writePromptFile(e,i.dir,i.content,`project:${t}/child:${i.workingChildDirectoryPath?.path??`unknown`}`);n.push(r)}}}return{files:n,dirs:r}}async writeGlobalOutputs(e){let{globalMemory:t}=e.collectedInputContext,n=[],a=[];if(t==null)return{files:n,dirs:a};let o=this.getGlobalConfigDir(),s=i.join(o,ip),c={pathKind:I.Relative,path:ip,basePath:o,getDirectoryName:()=>ap,getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write global memory -> ${s}`),{files:[{path:c,success:!0,skipped:!1}],dirs:a};try{this.ensureDirectory(o),r.writeFileSync(s,t.content,`utf-8`),this.log.info(`Written global memory -> ${s}`),n.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write global memory: ${t}`),n.push({path:c,success:!1,error:e})}return{files:n,dirs:a}}},sp=class extends ef{constructor(){super(`GlobalMemoryInputPlugin`)}collect(e){let{userConfigOptions:t,fs:n,path:r}=e,{workspaceDir:i,shadowProjectDir:a}=this.resolveBasePaths(t),s=t.globalMemoryFile??Ct,c=this.resolvePath(s,i,a);if(n.existsSync(c)&&n.statSync(c).isFile()){let e=Hl(n.readFileSync(c,`utf-8`)),t=e.contentWithoutFrontMatter;return{globalMemory:{type:lt.GlobalMemory,content:t,length:t.length,filePathKind:I.Relative,...e.rawFrontMatter!=null&&{rawFrontMatter:e.rawFrontMatter},markdownAst:e.markdownAst,markdownContents:e.markdownContents,dir:{pathKind:I.Relative,path:r.basename(c),basePath:r.dirname(c),getDirectoryName:()=>r.basename(c),getAbsolutePath:()=>c},parentDirectoryPath:{type:pt.UserHome,directory:{pathKind:I.Relative,path:``,basePath:o.homedir(),getDirectoryName:()=>r.basename(o.homedir()),getAbsolutePath:()=>o.homedir()}}}}}return{}}},cp=class extends ef{constructor(){super(`IdeConfigInputPlugin`)}collect(e){let{userConfigOptions:t,fs:n,path:r}=e,{shadowProjectDir:i}=this.resolveBasePaths(t),a=[`.editorconfig`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`,`.vscode/settings.json`,`.vscode/extensions.json`],o=[];for(let e of a){let t=r.join(i,e);if(n.existsSync(t)&&n.statSync(t).isFile()){let i=n.readFileSync(t,`utf-8`),a=L.Original;e.includes(`.vscode`)?a=L.VSCode:e.includes(`.idea`)?a=L.IntellijIDEA:e.includes(`.editorconfig`)&&(a=L.EditorConfig),o.push({type:a,content:i,length:i.length,filePathKind:I.Absolute,dir:{pathKind:I.Absolute,path:t,getDirectoryName:()=>r.basename(t)}})}}return{ideConfigFiles:o}}};const lp=`.idea`,up=[`.editorconfig`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`];var dp=class extends tf{constructor(){super(`JetBrainsIDECodeStyleConfigOutputPlugin`)}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{ideConfigFiles:r}=e.collectedInputContext;if(!r.some(e=>e.type===L.IntellijIDEA||e.type===L.EditorConfig))return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&e.isPromptSourceProject!==!0)for(let e of up){let r=this.joinPath(n.path,e);t.push({pathKind:I.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>this.dirname(e),getAbsolutePath:()=>this.resolvePath(n.basePath,r)})}}return t}async canWrite(e){let{ideConfigFiles:t}=e.collectedInputContext;return t.some(e=>e.type===L.IntellijIDEA||e.type===L.EditorConfig)?!0:(this.log.debug(`skipped`,{reason:`no JetBrains IDE config files found`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{ideConfigFiles:n}=e.collectedInputContext,r=[],i=[],a=n.filter(e=>e.type===L.IntellijIDEA||e.type===L.EditorConfig);for(let n of t){let t=n.dirFromWorkspacePath;if(t==null)continue;let i=n.name??`unknown`;for(let n of a){let a=await this.writeConfigFile(e,t,n,`project:${i}`);r.push(a)}}return{files:r,dirs:i}}async writeConfigFile(e,t,n,r){let i=this.getTargetRelativePath(n),a=this.resolvePath(t.basePath,t.path,i),o={pathKind:I.Relative,path:this.joinPath(t.path,i),basePath:t.basePath,getDirectoryName:()=>this.dirname(i),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.info(`would write`,{path:a,label:r,dryRun:!0}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,n.content),this.log.info(`written`,{path:a,label:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error(`write failed`,{path:a,label:r,error:t}),{path:o,success:!1,error:e}}}getTargetRelativePath(e){let t=e.dir.path;if(e.type===L.EditorConfig)return`.editorconfig`;if(e.type===L.IntellijIDEA){let e=t.indexOf(lp);return e===-1?this.joinPath(lp,`codeStyles`,this.basename(t)):t.substring(e)}return this.basename(t)}};const fp=`GLOBAL.md`,pp=`.kiro`,$=`steering`,mp=`POWER.md`;var hp=class extends tf{constructor(){super(`KiroCLIOutputPlugin`,{globalConfigDir:pp,outputFileName:fp})}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n){if(e.dirFromWorkspacePath==null)continue;let n=this.joinPath(e.dirFromWorkspacePath.path,pp,$);t.push({pathKind:I.Relative,path:n,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(e.dirFromWorkspacePath.basePath,n)})}return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.dirFromWorkspacePath!=null&&e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts){let r=this.buildSteeringFileName(n),i=this.joinPath(e.dirFromWorkspacePath.path,pp,$,r);t.push({pathKind:I.Relative,path:i,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(e.dirFromWorkspacePath.basePath,i)})}return t}async registerGlobalOutputDirs(e){let t=this.getGlobalSteeringDir(),n=[{pathKind:I.Relative,path:$,basePath:this.joinPath(this.getGlobalConfigDir()),getDirectoryName:()=>$,getAbsolutePath:()=>t}],{skills:r}=e.collectedInputContext;if(r!=null){let e=this.getKiroPowersDir();for(let t of r){let r=t.yamlFrontMatter.name,i=this.joinPath(e,r);n.push({pathKind:I.Relative,path:r,basePath:e,getDirectoryName:()=>r,getAbsolutePath:()=>i})}}return n}async registerGlobalOutputFiles(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=this.getGlobalSteeringDir();if(t!=null&&i.push({pathKind:I.Relative,path:fp,basePath:a,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(a,fp)}),n!=null)for(let e of n){let t=this.buildFastCommandSteeringFileName(e);i.push({pathKind:I.Relative,path:t,basePath:a,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(a,t)})}if(r!=null){let e=this.getKiroPowersDir();for(let t of r){let n=t.yamlFrontMatter.name,r=this.joinPath(e,n);if(i.push({pathKind:I.Relative,path:mp,basePath:r,getDirectoryName:()=>n,getAbsolutePath:()=>this.joinPath(r,mp)}),t.referenceDocuments!=null){let e=this.joinPath(r,$);for(let n of t.referenceDocuments){let t=n.dir.path;i.push({pathKind:I.Relative,path:this.joinPath($,t),basePath:r,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(e,t)})}}}}return i}async canWrite(e){let{workspace:t,globalMemory:n,fastCommands:r,skills:i}=e.collectedInputContext,a=t.projects.some(e=>(e.childMemoryPrompts?.length??0)>0),o=n!=null,s=(r?.length??0)>0,c=(i?.length??0)>0;return!a&&!o&&!s&&!c?(this.log.info(`No outputs to write, skipping`),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t)if(r.dirFromWorkspacePath!=null&&r.childMemoryPrompts!=null)for(let t of r.childMemoryPrompts){let i=await this.writeSteeringFile(e,r,t);n.push(i)}return{files:n,dirs:r}}async writeGlobalOutputs(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=[],o=[];if(t!=null){let n=this.getGlobalSteeringDir(),r=this.joinPath(n,fp),a={pathKind:I.Relative,path:fp,basePath:n,getDirectoryName:()=>$,getAbsolutePath:()=>r};if(e.dryRun===!0)this.log.info(`[DRY-RUN] Would write global memory -> ${r}`),i.push({path:a,success:!0,skipped:!1});else try{this.ensureDirectory(n),this.writeFileSync(r,t.content),this.log.info(`Written global memory -> ${r}`),i.push({path:a,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write global memory: ${t}`),i.push({path:a,success:!1,error:e})}}if(n!=null)for(let t of n){let n=await this.writeFastCommandSteeringFile(e,t);i.push(n)}if(r!=null&&r.length>0){this.log.debug(`Processing ${r.length} skills as Kiro Powers`);for(let t of r){let{fileResults:n,registryResult:r}=await this.writeSkillAsPower(e,t);i.push(...n),o.push(r)}this.logRegistryResults(o,e.dryRun)}return{files:i,dirs:a}}logRegistryResults(e,t){let n=t===!0?`[DRY-RUN] `:``,r=e.filter(e=>e.success).length,i=e.filter(e=>!e.success).length;if(r>0&&this.log.info(`${n}Registry: ${r} power(s) registered successfully`),i>0){this.log.error(`${n}Registry: ${i} power(s) failed to register`);for(let t of e)if(!t.success){let e=t.error?.message??`Unknown error`;this.log.error(` - ${t.entryName}: ${e}`)}}}getGlobalSteeringDir(){return this.joinPath(this.getGlobalConfigDir(),$)}getKiroPowersDir(){return this.joinPath(this.getHomeDir(),`.kiro/powers/installed`)}getHomeDir(){return s.homedir()}buildPowerFrontMatter(e){let t=e.name,n=e.description,r=e.displayName,i=e.keywords,a=e.author,o=[`---`];if(o.push(`name: "${t}"`),r!=null&&r.length>0&&o.push(`displayName: "${r}"`),n.length>0&&o.push(`description: "${n}"`),i!=null&&i.length>0){let e=i.map(e=>`"${e}"`).join(`, `);o.push(`keywords: [${e}]`)}return a!=null&&a.length>0&&o.push(`author: "${a}"`),o.push(`---`),o.join(`
|
|
209
208
|
`)}async writeSkillAsPower(e,t){let n=[],r=t.yamlFrontMatter.name,i=this.joinPath(this.getKiroPowersDir(),r),a=this.joinPath(i,mp),o={pathKind:I.Relative,path:mp,basePath:i,getDirectoryName:()=>r,getAbsolutePath:()=>a},s=`${this.buildPowerFrontMatter(t.yamlFrontMatter)}\n${t.content}`;if(e.dryRun===!0)this.log.info(`[DRY-RUN] Would write skill power -> ${a}`),n.push({path:o,success:!0,skipped:!1});else try{this.ensureDirectory(i),this.writeFileSync(a,s),this.log.info(`Written skill power -> ${a}`),n.push({path:o,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write skill power: ${t}`),n.push({path:o,success:!1,error:e})}if(t.referenceDocuments!=null){let r=this.joinPath(i,$);for(let a of t.referenceDocuments){let t=a.dir.path,o=this.joinPath(r,t),s={pathKind:I.Relative,path:this.joinPath($,t),basePath:i,getDirectoryName:()=>$,getAbsolutePath:()=>o},c=a.content;if(e.dryRun===!0)this.log.info(`[DRY-RUN] Would write reference document -> ${o}`),n.push({path:s,success:!0,skipped:!1});else try{this.ensureDirectory(r),this.writeFileSync(o,c),this.log.info(`Written reference document -> ${o}`),n.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error(`Failed to write reference document: ${t}`),n.push({path:s,success:!1,error:e})}}}let c=this.getRegistryWriter(rf),l=c.buildPowerEntry(t,i);return{fileResults:n,registryResult:(await this.registerInRegistry(c,[l],e))[0]??{success:!1,entryName:r,error:Error(`No registry result returned`)}}}buildFastCommandSteeringFileName(e){return this.transformFastCommandName(e,{includeSeriesPrefix:!0,seriesSeparator:`-`})}buildFastCommandSteeringContent(e){let t=e.yamlFrontMatter?.description??``,n=[`---`,`inclusion: manual`];return t.length>0&&n.push(`description: '${t}'`),n.push(`---`),`${n.join(`
|
|
210
209
|
`)}\n${e.content}`}async writeFastCommandSteeringFile(e,t){let n=this.getGlobalSteeringDir(),r=this.buildFastCommandSteeringFileName(t),i=this.joinPath(n,r),a={pathKind:I.Relative,path:r,basePath:n,getDirectoryName:()=>$,getAbsolutePath:()=>i},o=this.buildFastCommandSteeringContent(t);if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write fast command steering -> ${i}`),{path:a,success:!0,skipped:!1};try{return this.ensureDirectory(n),this.writeFileSync(i,o),this.log.info(`Written fast command steering -> ${i}`),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error(`Failed to write fast command steering: ${t}`),{path:a,success:!1,error:e}}}buildSteeringFileName(e){return`kiro-${(e.workingChildDirectoryPath?.path??e.dir.path).replace(/\\/g,`/`).replace(/^\/+|\/+$/g,``).replace(/\//g,`-`)}.md`}buildSteeringContent(e){return`${[`---`,`inclusion: fileMatch`,`fileMatchPattern: '${(e.workingChildDirectoryPath?.path??e.dir.path).replace(/\\/g,`/`)}/**'`,`---`].join(`
|
|
211
|
-
`)}\n${e.content}`}async writeSteeringFile(e,t,n){let r=t.dirFromWorkspacePath,i=this.buildSteeringFileName(n),a=this.joinPath(r.basePath,r.path,pp,$),o=this.joinPath(a,i),s={pathKind:I.Relative,path:this.joinPath(r.path,pp,$,i),basePath:r.basePath,getDirectoryName:()=>$,getAbsolutePath:()=>o},c=this.buildSteeringContent(n);if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write steering file -> ${o}`),{path:s,success:!0,skipped:!1};try{return this.ensureDirectory(a),this.writeFileSync(o,c),this.log.info(`Written steering file -> ${o}`),{path:s,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error(`Failed to write steering file: ${t}`),{path:s,success:!1,error:e}}}};const gp=`AGENTS.md`;var _p=class extends ef{constructor(){super(`ProjectPromptInputPlugin`,[`ShadowProjectInputPlugin`])}collect(e){let{dependencyContext:t,fs:n,userConfigOptions:r,path:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(r),s=r.shadowSourceProjectDir??St,c=this.resolvePath(s,a,o),l=t.workspace;if(l==null)return this.log.warn(`No workspace found in dependency context, skipping project prompt enhancement`),{};let u=(l.projects??[]).map(t=>{let r=t.name;if(r==null)return t;let a=i.join(c,r,`dist`);if(!n.existsSync(a)||!n.statSync(a).isDirectory())return t;let o=t.dirFromWorkspacePath?.getAbsolutePath(),s=this.readRootMemoryPrompt(e,a),l=o==null?[]:this.scanChildMemoryPrompts(e,a,o);return{...t,...s!=null&&{rootMemoryPrompt:s},...l.length>0&&{childMemoryPrompts:l}}});return{workspace:{directory:l.directory,projects:u}}}readRootMemoryPrompt(e,t){let{fs:n,path:r,logger:i}=e,a=r.join(t,gp);if(!(!n.existsSync(a)||!n.statSync(a).isFile()))try{let e=Hl(n.readFileSync(a,`utf-8`)),t=e.contentWithoutFrontMatter;return{type:lt.ProjectRootMemory,content:t,length:t.length,filePathKind:I.Relative,...e.yamlFrontMatter!=null&&{yamlFrontMatter:e.yamlFrontMatter},...e.rawFrontMatter!=null&&{rawFrontMatter:e.rawFrontMatter},markdownAst:e.markdownAst,markdownContents:e.markdownContents,dir:{pathKind:I.Root,path:``,getDirectoryName:()=>``}}}catch(e){i.error(`Failed to read root memory prompt at ${a}`,{error:e});return}}scanChildMemoryPrompts(e,t,n){let{logger:r}=e,i=[];try{this.scanDirectoryRecursive(e,t,t,n,i)}catch(e){r.error(`Failed to scan child memory prompts at ${t}`,{error:e})}return i}scanDirectoryRecursive(e,t,n,r,i){let{fs:a,path:o}=e,s=a.readdirSync(n,{withFileTypes:!0});for(let c of s){if(!c.isDirectory()||c.name.startsWith(`.`)||c.name===`node_modules`)continue;let s=o.join(n,c.name),l=o.join(s,gp);if(a.existsSync(l)&&a.statSync(l).isFile()){let n=this.readChildMemoryPrompt(e,t,s,r);n!=null&&i.push(n)}this.scanDirectoryRecursive(e,t,s,r,i)}}readChildMemoryPrompt(e,t,n,r){let{fs:i,path:a,logger:o}=e,s=a.join(n,gp);try{let e=Hl(i.readFileSync(s,`utf-8`)),o=e.contentWithoutFrontMatter,c=a.relative(t,n),l=a.join(r,c),u=a.basename(n);return{type:lt.ProjectChildrenMemory,content:o,length:o.length,filePathKind:I.Relative,...e.yamlFrontMatter!=null&&{yamlFrontMatter:e.yamlFrontMatter},...e.rawFrontMatter!=null&&{rawFrontMatter:e.rawFrontMatter},markdownAst:e.markdownAst,markdownContents:e.markdownContents,dir:{pathKind:I.Relative,path:c,basePath:r,getDirectoryName:()=>u,getAbsolutePath:()=>l},workingChildDirectoryPath:{pathKind:I.Relative,path:c,basePath:r,getDirectoryName:()=>u,getAbsolutePath:()=>l}}}catch(e){o.error(`Failed to read child memory prompt at ${s}`,{error:e});return}}};const vp=`README.md`;var yp=class extends tf{constructor(){super(`ReadmeMdConfigFileOutputPlugin`,{outputFileName:vp})}async registerProjectOutputFiles(e){let t=[],{readmePrompts:n}=e.collectedInputContext;if(n==null||n.length===0)return t;for(let e of n){let n=e.targetDir,r=i.join(n.path,vp);t.push({pathKind:I.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>n.getDirectoryName(),getAbsolutePath:()=>i.join(n.basePath,r)})}return t}async canWrite(e){let{readmePrompts:t}=e.collectedInputContext;return t==null||t.length===0?(this.log.info(`No README prompts to write, skipping`),!1):!0}async writeProjectOutputs(e){let t=[],n=[],{readmePrompts:r}=e.collectedInputContext;if(r==null||r.length===0)return{files:t,dirs:n};for(let n of r){let r=await this.writeReadmeFile(e,n);t.push(r)}return{files:t,dirs:n}}async writeReadmeFile(e,t){let n=t.targetDir,a=i.join(n.path,vp),o=i.join(n.basePath,a),s=t.content,c={pathKind:I.Relative,path:a,basePath:n.basePath,getDirectoryName:()=>n.getDirectoryName(),getAbsolutePath:()=>o},l=t.isRoot?`project:${t.projectName}/README.md`:`project:${t.projectName}/${n.path}/README.md`;if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write ${l} -> ${o}`),{path:c,success:!0,skipped:!1};try{let e=i.dirname(o);return r.existsSync(e)||r.mkdirSync(e,{recursive:!0}),r.writeFileSync(o,s,`utf-8`),this.log.info(`Written ${l} -> ${o}`),{path:c,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error(`Failed to write ${l}: ${t}`),{path:c,success:!1,error:e}}}},bp=class extends ef{constructor(){super(`ReadmeMdInputPlugin`,[`ShadowProjectInputPlugin`])}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.shadowSourceProjectDir??St,c=this.resolvePath(s,a,o),l=[];if(!r.existsSync(c)||!r.statSync(c).isDirectory())return n.debug(`Shadow source project directory does not exist: ${c}`),{readmePrompts:l};try{let t=r.readdirSync(c,{withFileTypes:!0});for(let n of t){if(!n.isDirectory())continue;let t=n.name,o=i.join(c,t,`dist`);!r.existsSync(o)||!r.statSync(o).isDirectory()||this.collectReadmeFiles(e,o,t,a,``,l)}}catch(e){n.error(`Failed to scan shadow source projects at ${c}`,{error:e})}return{readmePrompts:l}}collectReadmeFiles(e,t,n,r,i,a){let{fs:o,path:s,logger:c}=e,l=i===``,u=s.join(t,`README.md`);if(o.existsSync(u)&&o.statSync(u).isFile())try{let e=o.readFileSync(u,`utf-8`),t=l?n:s.join(n,i),c={pathKind:I.Relative,path:t,basePath:r,getDirectoryName:()=>l?n:s.basename(i),getAbsolutePath:()=>s.resolve(r,t)},d={pathKind:I.Relative,path:s.dirname(u),basePath:r,getDirectoryName:()=>s.basename(s.dirname(u)),getAbsolutePath:()=>s.dirname(u)};a.push({type:lt.Readme,content:e,length:e.length,filePathKind:I.Relative,projectName:n,targetDir:c,isRoot:l,markdownContents:[],dir:d})}catch(e){c.warn(`Failed to read README.md at ${u}`,{error:e})}try{let c=o.readdirSync(t,{withFileTypes:!0});for(let o of c)if(o.isDirectory()){let c=l?o.name:s.join(i,o.name),u=s.join(t,o.name);this.collectReadmeFiles(e,u,n,r,c,a)}}catch(e){c.warn(`Failed to scan directory ${t}`,{error:e})}}},xp=class extends ef{constructor(){super(`ShadowProjectInputPlugin`)}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.shadowSourceProjectDir??St,c=this.resolvePath(s,a,o),l=i.basename(o),u=[];if(r.existsSync(c)&&r.statSync(c).isDirectory())try{let e=r.readdirSync(c,{withFileTypes:!0});for(let t of e)if(t.isDirectory()){let e=t.name===l;u.push({name:t.name,...e&&{isPromptSourceProject:!0},dirFromWorkspacePath:{pathKind:I.Relative,path:t.name,basePath:a,getDirectoryName:()=>t.name,getAbsolutePath:()=>i.resolve(a,t.name)}})}}catch(e){n.error(`Failed to scan shadow source projects at ${c}`,{error:e})}return{workspace:{directory:{pathKind:I.Absolute,path:a,getDirectoryName:()=>i.basename(a)},projects:u}}}},Sp=class extends ef{constructor(){super(`SkillInputPlugin`)}extractReferenceDocumentLinks(e){let t=[],n=e=>{if(e.type===`link`){let n=e,r=n.url;if(r.startsWith(`http://`)||r.startsWith(`https://`)||r.startsWith(`/`))return;let i=[];for(let e of n.children)e.type===`text`&&e.value!=null&&i.push(e.value);t.push({text:i.join(``),path:r})}if(`children`in e&&Array.isArray(e.children))for(let t of e.children)n(t)};for(let t of e)n(t);return t}readReferenceDocuments(e,t,n,r){let a=[];for(let o of t){let t=i.resolve(e,o.path);if(!n.existsSync(t)){r.warn(`Reference document not found: ${o.path} in skill directory ${e}`);continue}if(!n.statSync(t).isFile()){r.warn(`Reference document path is not a file: ${o.path}`);continue}try{let r=Hl(n.readFileSync(t,`utf-8`)),s=r.contentWithoutFrontMatter,c=i.dirname(o.path);a.push({type:lt.SkillReferenceDocument,content:s,length:s.length,filePathKind:I.Relative,markdownAst:r.markdownAst,markdownContents:r.markdownContents,...r.rawFrontMatter!=null&&{rawFrontMatter:r.rawFrontMatter},dir:{pathKind:I.Relative,path:o.path,basePath:e,getDirectoryName:()=>c===`.`?``:c,getAbsolutePath:()=>t}})}catch(e){r.warn(`Failed to read reference document: ${o.path}`,{error:e})}}return a}collect(e){let{userConfigOptions:t,logger:n}=e,{workspaceDir:r,shadowProjectDir:a}=this.resolveBasePaths(t),o=t.shadowSkillSourceDir??yt,s=this.resolvePath(o,r,a),c=[];if(e.fs.existsSync(s)&&e.fs.statSync(s).isDirectory())try{let t=e.fs.readdirSync(s,{withFileTypes:!0});for(let r of t)if(r.isDirectory()){let t=e.path.join(s,r.name,`SKILL.md`);if(e.fs.existsSync(t)&&e.fs.statSync(t).isFile()){let a=Hl(e.fs.readFileSync(t,`utf-8`)),o=a.contentWithoutFrontMatter,l=this.extractReferenceDocumentLinks(a.markdownContents),u=e.path.join(s,r.name),d=this.readReferenceDocuments(u,l,e.fs,n);c.push({type:lt.Skill,content:o,length:o.length,filePathKind:I.Relative,yamlFrontMatter:a.yamlFrontMatter??{name:r.name,description:``},...a.rawFrontMatter!=null&&{rawFrontMatter:a.rawFrontMatter},markdownAst:a.markdownAst,markdownContents:a.markdownContents,...d.length>0&&{referenceDocuments:d},dir:{pathKind:I.Relative,path:r.name,basePath:s,getDirectoryName:()=>r.name,getAbsolutePath:()=>i.join(s,r.name)}})}}}catch(e){n.error(`Failed to scan skills at ${s}`,{error:e})}return{skills:c}}},Cp=class extends ef{constructor(){super(`SubAgentInputPlugin`)}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.shadowSubAgentDir??xt,c=this.resolvePath(s,a,o),l=[];if(r.existsSync(c)&&r.statSync(c).isDirectory())try{let e=r.readdirSync(c,{withFileTypes:!0});for(let t of e)if(t.isFile()&&t.name.endsWith(`.md`)){let e=i.join(c,t.name),n=Hl(r.readFileSync(e,`utf-8`)),a=n.contentWithoutFrontMatter;l.push({type:lt.SubAgent,content:a,length:a.length,filePathKind:I.Relative,...n.yamlFrontMatter!=null&&{yamlFrontMatter:n.yamlFrontMatter},...n.rawFrontMatter!=null&&{rawFrontMatter:n.rawFrontMatter},markdownAst:n.markdownAst,markdownContents:n.markdownContents,dir:{pathKind:I.Relative,path:t.name,basePath:c,getDirectoryName:()=>t.name.replace(/\.md$/,``),getAbsolutePath:()=>e}})}}catch(e){n.error(`Failed to scan sub agents at ${c}`,{error:e})}return{subAgents:l}}};const wp=`WARP.md`;var Tp=class extends tf{constructor(){super(`WarpIDEOutputPlugin`,{outputFileName:wp})}isAgentsPluginRegistered(e){return`registeredPluginNames`in e&&e.registeredPluginNames!=null?e.registeredPluginNames.includes(`AgentsOutputPlugin`):!1}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,r=this.isAgentsPluginRegistered(e);for(let e of n)if(e.dirFromWorkspacePath!=null){if(r)t.push(this.createFileRelativePath(e.dirFromWorkspacePath,wp));else if(e.rootMemoryPrompt!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,wp)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,wp))}return t}async canWrite(e){let t=this.isAgentsPluginRegistered(e),{workspace:n,globalMemory:r}=e.collectedInputContext;return t?r==null?(this.log.info(`AgentsOutputPlugin registered but no global memory, skipping global WARP.md`),!1):!0:n.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)?!0:(this.log.info(`No outputs to write, skipping`),!1)}async writeProjectOutputs(e){let t=this.isAgentsPluginRegistered(e),{workspace:n,globalMemory:r}=e.collectedInputContext,{projects:i}=n,a=[],o=[];if(t){if(r==null)return{files:[],dirs:[]};for(let t of i){let n=t.dirFromWorkspacePath;if(n==null)continue;let i=t.name??`unknown`,o=await this.writePromptFile(e,n,r.content,`project:${i}/global-warp`);a.push(o)}return{files:a,dirs:o}}let s=this.extractGlobalMemoryContent(e);for(let t of i){let n=t.name??`unknown`,r=t.dirFromWorkspacePath;if(r!=null){if(t.rootMemoryPrompt!=null){let i=this.combineGlobalWithContent(s,t.rootMemoryPrompt.content),o=await this.writePromptFile(e,r,i,`project:${n}/root`);a.push(o)}if(t.childMemoryPrompts!=null)for(let r of t.childMemoryPrompts){let t=await this.writePromptFile(e,r.dir,r.content,`project:${n}/child:${r.workingChildDirectoryPath?.path??`unknown`}`);a.push(t)}}}return{files:a,dirs:o}}},Ep=class extends ef{constructor(){super(`WorkspaceInputPlugin`)}collect(e){let{userConfigOptions:t}=e,{workspaceDir:n,shadowProjectDir:r}=this.resolveBasePaths(t),a=(t.externalProjects||[]).map(e=>{let t=this.resolvePath(e,n,r);return{name:i.basename(t),dirFromWorkspacePath:{pathKind:I.Relative,path:t,basePath:n,getDirectoryName:()=>i.basename(t)}}});return{workspace:{directory:{pathKind:I.Absolute,path:n,getDirectoryName:()=>i.basename(n)},projects:[]},shadowProjectDir:r,...a.length>0&&{externalProjects:a}}}};const Dp=`.vscode`,Op=[`.vscode/settings.json`,`.vscode/extensions.json`];var kp=class extends tf{constructor(){super(`VisualStudioCodeIDEConfigOutputPlugin`)}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{ideConfigFiles:r}=e.collectedInputContext;if(!r.some(e=>e.type===L.VSCode))return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&e.isPromptSourceProject!==!0)for(let e of Op){let r=this.joinPath(n.path,e);t.push({pathKind:I.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>this.dirname(e),getAbsolutePath:()=>this.resolvePath(n.basePath,r)})}}return t}async canWrite(e){let{ideConfigFiles:t}=e.collectedInputContext;return t.some(e=>e.type===L.VSCode)?!0:(this.log.info(`No VS Code config files found, skipping`),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{ideConfigFiles:n}=e.collectedInputContext,r=[],i=[],a=n.filter(e=>e.type===L.VSCode);for(let n of t){let t=n.dirFromWorkspacePath;if(t==null)continue;let i=n.name??`unknown`;for(let n of a){let a=await this.writeConfigFile(e,t,n,`project:${i}`);r.push(a)}}return{files:r,dirs:i}}async writeConfigFile(e,t,n,r){let i=this.getTargetRelativePath(n),a=this.resolvePath(t.basePath,t.path,i),o={pathKind:I.Relative,path:this.joinPath(t.path,i),basePath:t.basePath,getDirectoryName:()=>this.dirname(i),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write ${r} -> ${a}`),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,n.content),this.log.info(`Written ${r} -> ${a}`),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error(`Failed to write ${r}: ${t}`),{path:o,success:!1,error:e}}}getTargetRelativePath(e){let t=e.dir.path;if(e.type===L.VSCode){let e=t.indexOf(Dp);return e===-1?this.joinPath(Dp,this.basename(t)):t.substring(e)}return this.basename(t)}},Ap=If({plugins:[new Rf,new Hf,new Yf,new np,new op,new hp,new Tp,new dp,new kp,new yp,new Ep,new xp,new Bf,new cp,new Sp,new rp,new Cp,new sp,new _p,new bp]}),jp=Ap;async function Mp(){await new Of(...n.argv).run(Ap)}Mp().catch(e=>{console.error(e)});export{ef as AbstractInputPlugin,tf as AbstractOutputPlugin,$d as AbstractPlugin,mt as CircularDependencyError,ut as ClaudeCodeCLISubAgentColors,dt as CodingAgentTools,ff as ConfigLoader,uf as DEFAULT_CONFIG_FILE_NAME,df as DEFAULT_GLOBAL_CONFIG_DIR,Ct as DEFAULT_GLOBAL_MEMORY_FILE,bt as DEFAULT_SHADOW_FAST_COMMAND_DIR,vt as DEFAULT_SHADOW_PROJECT_SUFFIX,yt as DEFAULT_SHADOW_SKILL_SOURCE_DIR,St as DEFAULT_SHADOW_SOURCE_PROJECT_DIR,xt as DEFAULT_SHADOW_SUB_AGENT_DIR,_t as DEFAULT_WORKSPACE_DIR,I as FilePathKind,pt as GlobalConfigDirectoryType,L as IDEKind,ht as MissingDependencyError,ft as NamingCaseKind,gt as PathPlaceholders,ct as PluginKind,lt as PromptKind,$e as checkCanClean,tt as checkCanWrite,Qe as collectAllPluginOutputs,Qd as createLogger,jp as default,If as defineConfig,et as executeOnCleanComplete,nt as executeWriteOutputs,mf as getConfigLoader,hf as loadUserConfig,jf as mergeConfig};
|
|
210
|
+
`)}\n${e.content}`}async writeSteeringFile(e,t,n){let r=t.dirFromWorkspacePath,i=this.buildSteeringFileName(n),a=this.joinPath(r.basePath,r.path,pp,$),o=this.joinPath(a,i),s={pathKind:I.Relative,path:this.joinPath(r.path,pp,$,i),basePath:r.basePath,getDirectoryName:()=>$,getAbsolutePath:()=>o},c=this.buildSteeringContent(n);if(e.dryRun===!0)return this.log.info(`[DRY-RUN] Would write steering file -> ${o}`),{path:s,success:!0,skipped:!1};try{return this.ensureDirectory(a),this.writeFileSync(o,c),this.log.info(`Written steering file -> ${o}`),{path:s,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error(`Failed to write steering file: ${t}`),{path:s,success:!1,error:e}}}};const gp=`AGENTS.md`;var _p=class extends ef{constructor(){super(`ProjectPromptInputPlugin`,[`ShadowProjectInputPlugin`])}collect(e){let{dependencyContext:t,fs:n,userConfigOptions:r,path:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(r),s=r.shadowSourceProjectDir??St,c=this.resolvePath(s,a,o),l=t.workspace;if(l==null)return this.log.warn(`No workspace found in dependency context, skipping project prompt enhancement`),{};let u=(l.projects??[]).map(t=>{let r=t.name;if(r==null)return t;let a=i.join(c,r,`dist`);if(!n.existsSync(a)||!n.statSync(a).isDirectory())return t;let o=t.dirFromWorkspacePath?.getAbsolutePath(),s=this.readRootMemoryPrompt(e,a),l=o==null?[]:this.scanChildMemoryPrompts(e,a,o);return{...t,...s!=null&&{rootMemoryPrompt:s},...l.length>0&&{childMemoryPrompts:l}}});return{workspace:{directory:l.directory,projects:u}}}readRootMemoryPrompt(e,t){let{fs:n,path:r,logger:i}=e,a=r.join(t,gp);if(!(!n.existsSync(a)||!n.statSync(a).isFile()))try{let e=Hl(n.readFileSync(a,`utf-8`)),t=e.contentWithoutFrontMatter;return{type:lt.ProjectRootMemory,content:t,length:t.length,filePathKind:I.Relative,...e.yamlFrontMatter!=null&&{yamlFrontMatter:e.yamlFrontMatter},...e.rawFrontMatter!=null&&{rawFrontMatter:e.rawFrontMatter},markdownAst:e.markdownAst,markdownContents:e.markdownContents,dir:{pathKind:I.Root,path:``,getDirectoryName:()=>``}}}catch(e){i.error(`Failed to read root memory prompt at ${a}`,{error:e});return}}scanChildMemoryPrompts(e,t,n){let{logger:r}=e,i=[];try{this.scanDirectoryRecursive(e,t,t,n,i)}catch(e){r.error(`Failed to scan child memory prompts at ${t}`,{error:e})}return i}scanDirectoryRecursive(e,t,n,r,i){let{fs:a,path:o}=e,s=a.readdirSync(n,{withFileTypes:!0});for(let c of s){if(!c.isDirectory()||c.name.startsWith(`.`)||c.name===`node_modules`)continue;let s=o.join(n,c.name),l=o.join(s,gp);if(a.existsSync(l)&&a.statSync(l).isFile()){let n=this.readChildMemoryPrompt(e,t,s,r);n!=null&&i.push(n)}this.scanDirectoryRecursive(e,t,s,r,i)}}readChildMemoryPrompt(e,t,n,r){let{fs:i,path:a,logger:o}=e,s=a.join(n,gp);try{let e=Hl(i.readFileSync(s,`utf-8`)),o=e.contentWithoutFrontMatter,c=a.relative(t,n),l=a.join(r,c),u=a.basename(n);return{type:lt.ProjectChildrenMemory,content:o,length:o.length,filePathKind:I.Relative,...e.yamlFrontMatter!=null&&{yamlFrontMatter:e.yamlFrontMatter},...e.rawFrontMatter!=null&&{rawFrontMatter:e.rawFrontMatter},markdownAst:e.markdownAst,markdownContents:e.markdownContents,dir:{pathKind:I.Relative,path:c,basePath:r,getDirectoryName:()=>u,getAbsolutePath:()=>l},workingChildDirectoryPath:{pathKind:I.Relative,path:c,basePath:r,getDirectoryName:()=>u,getAbsolutePath:()=>l}}}catch(e){o.error(`Failed to read child memory prompt at ${s}`,{error:e});return}}};const vp=`README.md`;var yp=class extends tf{constructor(){super(`ReadmeMdConfigFileOutputPlugin`,{outputFileName:vp})}async registerProjectOutputFiles(e){let t=[],{readmePrompts:n}=e.collectedInputContext;if(n==null||n.length===0)return t;for(let e of n){let n=e.targetDir,r=i.join(n.path,vp);t.push({pathKind:I.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>n.getDirectoryName(),getAbsolutePath:()=>i.join(n.basePath,r)})}return t}async canWrite(e){let{readmePrompts:t}=e.collectedInputContext;return t==null||t.length===0?(this.log.debug(`skipped`,{reason:`no README prompts to write`}),!1):!0}async writeProjectOutputs(e){let t=[],n=[],{readmePrompts:r}=e.collectedInputContext;if(r==null||r.length===0)return{files:t,dirs:n};for(let n of r){let r=await this.writeReadmeFile(e,n);t.push(r)}return{files:t,dirs:n}}async writeReadmeFile(e,t){let n=t.targetDir,a=i.join(n.path,vp),o=i.join(n.basePath,a),s=t.content,c={pathKind:I.Relative,path:a,basePath:n.basePath,getDirectoryName:()=>n.getDirectoryName(),getAbsolutePath:()=>o},l=t.isRoot?`project:${t.projectName}/README.md`:`project:${t.projectName}/${n.path}/README.md`;if(e.dryRun===!0)return this.log.info(`would write`,{path:o,label:l,dryRun:!0}),{path:c,success:!0,skipped:!1};try{let e=i.dirname(o);return r.existsSync(e)||r.mkdirSync(e,{recursive:!0}),r.writeFileSync(o,s,`utf-8`),this.log.info(`written`,{path:o,label:l}),{path:c,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error(`write failed`,{path:o,label:l,error:t}),{path:c,success:!1,error:e}}}},bp=class extends ef{constructor(){super(`ReadmeMdInputPlugin`,[`ShadowProjectInputPlugin`])}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.shadowSourceProjectDir??St,c=this.resolvePath(s,a,o),l=[];if(!r.existsSync(c)||!r.statSync(c).isDirectory())return n.debug(`shadow source project directory does not exist`,{path:c}),{readmePrompts:l};try{let t=r.readdirSync(c,{withFileTypes:!0});for(let n of t){if(!n.isDirectory())continue;let t=n.name,o=i.join(c,t,`dist`);!r.existsSync(o)||!r.statSync(o).isDirectory()||this.collectReadmeFiles(e,o,t,a,``,l)}}catch(e){n.error(`failed to scan shadow source projects`,{path:c,error:e})}return{readmePrompts:l}}collectReadmeFiles(e,t,n,r,i,a){let{fs:o,path:s,logger:c}=e,l=i===``,u=s.join(t,`README.md`);if(o.existsSync(u)&&o.statSync(u).isFile())try{let e=o.readFileSync(u,`utf-8`),t=l?n:s.join(n,i),c={pathKind:I.Relative,path:t,basePath:r,getDirectoryName:()=>l?n:s.basename(i),getAbsolutePath:()=>s.resolve(r,t)},d={pathKind:I.Relative,path:s.dirname(u),basePath:r,getDirectoryName:()=>s.basename(s.dirname(u)),getAbsolutePath:()=>s.dirname(u)};a.push({type:lt.Readme,content:e,length:e.length,filePathKind:I.Relative,projectName:n,targetDir:c,isRoot:l,markdownContents:[],dir:d})}catch(e){c.warn(`failed to read README.md`,{path:u,error:e})}try{let c=o.readdirSync(t,{withFileTypes:!0});for(let o of c)if(o.isDirectory()){let c=l?o.name:s.join(i,o.name),u=s.join(t,o.name);this.collectReadmeFiles(e,u,n,r,c,a)}}catch(e){c.warn(`failed to scan directory`,{path:t,error:e})}}},xp=class extends ef{constructor(){super(`ShadowProjectInputPlugin`)}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.shadowSourceProjectDir??St,c=this.resolvePath(s,a,o),l=i.basename(o),u=[];if(r.existsSync(c)&&r.statSync(c).isDirectory())try{let e=r.readdirSync(c,{withFileTypes:!0});for(let t of e)if(t.isDirectory()){let e=t.name===l;u.push({name:t.name,...e&&{isPromptSourceProject:!0},dirFromWorkspacePath:{pathKind:I.Relative,path:t.name,basePath:a,getDirectoryName:()=>t.name,getAbsolutePath:()=>i.resolve(a,t.name)}})}}catch(e){n.error(`failed to scan shadow source projects`,{path:c,error:e})}return{workspace:{directory:{pathKind:I.Absolute,path:a,getDirectoryName:()=>i.basename(a)},projects:u}}}},Sp=class extends ef{constructor(){super(`SkillInputPlugin`)}extractReferenceDocumentLinks(e){let t=[],n=e=>{if(e.type===`link`){let n=e,r=n.url;if(r.startsWith(`http://`)||r.startsWith(`https://`)||r.startsWith(`/`))return;let i=[];for(let e of n.children)e.type===`text`&&e.value!=null&&i.push(e.value);t.push({text:i.join(``),path:r})}if(`children`in e&&Array.isArray(e.children))for(let t of e.children)n(t)};for(let t of e)n(t);return t}readReferenceDocuments(e,t,n,r){let a=[];for(let o of t){let t=i.resolve(e,o.path);if(!n.existsSync(t)){r.warn(`reference document not found`,{path:o.path,skillDir:e});continue}if(!n.statSync(t).isFile()){r.warn(`reference document path is not a file`,{path:o.path});continue}try{let r=Hl(n.readFileSync(t,`utf-8`)),s=r.contentWithoutFrontMatter,c=i.dirname(o.path);a.push({type:lt.SkillReferenceDocument,content:s,length:s.length,filePathKind:I.Relative,markdownAst:r.markdownAst,markdownContents:r.markdownContents,...r.rawFrontMatter!=null&&{rawFrontMatter:r.rawFrontMatter},dir:{pathKind:I.Relative,path:o.path,basePath:e,getDirectoryName:()=>c===`.`?``:c,getAbsolutePath:()=>t}})}catch(e){r.warn(`failed to read reference document`,{path:o.path,error:e})}}return a}collect(e){let{userConfigOptions:t,logger:n}=e,{workspaceDir:r,shadowProjectDir:a}=this.resolveBasePaths(t),o=t.shadowSkillSourceDir??yt,s=this.resolvePath(o,r,a),c=[];if(e.fs.existsSync(s)&&e.fs.statSync(s).isDirectory())try{let t=e.fs.readdirSync(s,{withFileTypes:!0});for(let r of t)if(r.isDirectory()){let t=e.path.join(s,r.name,`SKILL.md`);if(e.fs.existsSync(t)&&e.fs.statSync(t).isFile()){let a=Hl(e.fs.readFileSync(t,`utf-8`)),o=a.contentWithoutFrontMatter,l=this.extractReferenceDocumentLinks(a.markdownContents),u=e.path.join(s,r.name),d=this.readReferenceDocuments(u,l,e.fs,n);c.push({type:lt.Skill,content:o,length:o.length,filePathKind:I.Relative,yamlFrontMatter:a.yamlFrontMatter??{name:r.name,description:``},...a.rawFrontMatter!=null&&{rawFrontMatter:a.rawFrontMatter},markdownAst:a.markdownAst,markdownContents:a.markdownContents,...d.length>0&&{referenceDocuments:d},dir:{pathKind:I.Relative,path:r.name,basePath:s,getDirectoryName:()=>r.name,getAbsolutePath:()=>i.join(s,r.name)}})}}}catch(e){n.error(`failed to scan skills`,{path:s,error:e})}return{skills:c}}},Cp=class extends ef{constructor(){super(`SubAgentInputPlugin`)}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.shadowSubAgentDir??xt,c=this.resolvePath(s,a,o),l=[];if(r.existsSync(c)&&r.statSync(c).isDirectory())try{let e=r.readdirSync(c,{withFileTypes:!0});for(let t of e)if(t.isFile()&&t.name.endsWith(`.md`)){let e=i.join(c,t.name),n=Hl(r.readFileSync(e,`utf-8`)),a=n.contentWithoutFrontMatter;l.push({type:lt.SubAgent,content:a,length:a.length,filePathKind:I.Relative,...n.yamlFrontMatter!=null&&{yamlFrontMatter:n.yamlFrontMatter},...n.rawFrontMatter!=null&&{rawFrontMatter:n.rawFrontMatter},markdownAst:n.markdownAst,markdownContents:n.markdownContents,dir:{pathKind:I.Relative,path:t.name,basePath:c,getDirectoryName:()=>t.name.replace(/\.md$/,``),getAbsolutePath:()=>e}})}}catch(e){n.error(`Failed to scan sub agents at ${c}`,{error:e})}return{subAgents:l}}};const wp=`WARP.md`;var Tp=class extends tf{constructor(){super(`WarpIDEOutputPlugin`,{outputFileName:wp})}isAgentsPluginRegistered(e){return`registeredPluginNames`in e&&e.registeredPluginNames!=null?e.registeredPluginNames.includes(`AgentsOutputPlugin`):!1}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,r=this.isAgentsPluginRegistered(e);for(let e of n)if(e.dirFromWorkspacePath!=null){if(r)t.push(this.createFileRelativePath(e.dirFromWorkspacePath,wp));else if(e.rootMemoryPrompt!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,wp)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,wp))}return t}async canWrite(e){let t=this.isAgentsPluginRegistered(e),{workspace:n,globalMemory:r}=e.collectedInputContext;return t?r==null?(this.log.debug(`skipped`,{reason:`AgentsOutputPlugin registered but no global memory`}),!1):!0:n.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)?!0:(this.log.debug(`skipped`,{reason:`no outputs to write`}),!1)}async writeProjectOutputs(e){let t=this.isAgentsPluginRegistered(e),{workspace:n,globalMemory:r}=e.collectedInputContext,{projects:i}=n,a=[],o=[];if(t){if(r==null)return{files:[],dirs:[]};for(let t of i){let n=t.dirFromWorkspacePath;if(n==null)continue;let i=t.name??`unknown`,o=await this.writePromptFile(e,n,r.content,`project:${i}/global-warp`);a.push(o)}return{files:a,dirs:o}}let s=this.extractGlobalMemoryContent(e);for(let t of i){let n=t.name??`unknown`,r=t.dirFromWorkspacePath;if(r!=null){if(t.rootMemoryPrompt!=null){let i=this.combineGlobalWithContent(s,t.rootMemoryPrompt.content),o=await this.writePromptFile(e,r,i,`project:${n}/root`);a.push(o)}if(t.childMemoryPrompts!=null)for(let r of t.childMemoryPrompts){let t=await this.writePromptFile(e,r.dir,r.content,`project:${n}/child:${r.workingChildDirectoryPath?.path??`unknown`}`);a.push(t)}}}return{files:a,dirs:o}}},Ep=class extends ef{constructor(){super(`WorkspaceInputPlugin`)}collect(e){let{userConfigOptions:t}=e,{workspaceDir:n,shadowProjectDir:r}=this.resolveBasePaths(t),a=(t.externalProjects||[]).map(e=>{let t=this.resolvePath(e,n,r);return{name:i.basename(t),dirFromWorkspacePath:{pathKind:I.Relative,path:t,basePath:n,getDirectoryName:()=>i.basename(t)}}});return{workspace:{directory:{pathKind:I.Absolute,path:n,getDirectoryName:()=>i.basename(n)},projects:[]},shadowProjectDir:r,...a.length>0&&{externalProjects:a}}}};const Dp=`.vscode`,Op=[`.vscode/settings.json`,`.vscode/extensions.json`];var kp=class extends tf{constructor(){super(`VisualStudioCodeIDEConfigOutputPlugin`)}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{ideConfigFiles:r}=e.collectedInputContext;if(!r.some(e=>e.type===L.VSCode))return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&e.isPromptSourceProject!==!0)for(let e of Op){let r=this.joinPath(n.path,e);t.push({pathKind:I.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>this.dirname(e),getAbsolutePath:()=>this.resolvePath(n.basePath,r)})}}return t}async canWrite(e){let{ideConfigFiles:t}=e.collectedInputContext;return t.some(e=>e.type===L.VSCode)?!0:(this.log.debug(`skipped`,{reason:`no VS Code config files found`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{ideConfigFiles:n}=e.collectedInputContext,r=[],i=[],a=n.filter(e=>e.type===L.VSCode);for(let n of t){let t=n.dirFromWorkspacePath;if(t==null)continue;let i=n.name??`unknown`;for(let n of a){let a=await this.writeConfigFile(e,t,n,`project:${i}`);r.push(a)}}return{files:r,dirs:i}}async writeConfigFile(e,t,n,r){let i=this.getTargetRelativePath(n),a=this.resolvePath(t.basePath,t.path,i),o={pathKind:I.Relative,path:this.joinPath(t.path,i),basePath:t.basePath,getDirectoryName:()=>this.dirname(i),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.info(`would write`,{path:a,label:r,dryRun:!0}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,n.content),this.log.info(`written`,{path:a,label:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error(`write failed`,{path:a,label:r,error:t}),{path:o,success:!1,error:e}}}getTargetRelativePath(e){let t=e.dir.path;if(e.type===L.VSCode){let e=t.indexOf(Dp);return e===-1?this.joinPath(Dp,this.basename(t)):t.substring(e)}return this.basename(t)}},Ap=If({plugins:[new Rf,new Hf,new Yf,new np,new op,new hp,new Tp,new dp,new kp,new yp,new Ep,new xp,new Bf,new cp,new Sp,new rp,new Cp,new sp,new _p,new bp]}),jp=Ap;async function Mp(){await new Of(...n.argv).run(Ap)}Mp().catch(e=>{console.error(e)});export{ef as AbstractInputPlugin,tf as AbstractOutputPlugin,$d as AbstractPlugin,mt as CircularDependencyError,ut as ClaudeCodeCLISubAgentColors,dt as CodingAgentTools,ff as ConfigLoader,uf as DEFAULT_CONFIG_FILE_NAME,df as DEFAULT_GLOBAL_CONFIG_DIR,Ct as DEFAULT_GLOBAL_MEMORY_FILE,bt as DEFAULT_SHADOW_FAST_COMMAND_DIR,vt as DEFAULT_SHADOW_PROJECT_SUFFIX,yt as DEFAULT_SHADOW_SKILL_SOURCE_DIR,St as DEFAULT_SHADOW_SOURCE_PROJECT_DIR,xt as DEFAULT_SHADOW_SUB_AGENT_DIR,_t as DEFAULT_WORKSPACE_DIR,I as FilePathKind,pt as GlobalConfigDirectoryType,L as IDEKind,ht as MissingDependencyError,ft as NamingCaseKind,gt as PathPlaceholders,ct as PluginKind,lt as PromptKind,$e as checkCanClean,tt as checkCanWrite,Qe as collectAllPluginOutputs,Qd as createLogger,jp as default,If as defineConfig,et as executeOnCleanComplete,nt as executeWriteOutputs,mf as getConfigLoader,hf as loadUserConfig,jf as mergeConfig};
|