@truenine/memory-sync-cli 2026.10212.12107 → 2026.10213.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.cjs +382 -57
  2. package/dist/index.mjs +363 -38
  3. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -17,54 +17,29 @@ var n=D(),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))})),we=y(((e,t)=>{
19
19
  /*! run-parallel. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
20
- t.exports=r;let n=Ce();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}})),Te=y((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})),Ee=y((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})),De=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fs=void 0,e.fs=Ee()})),Oe=y((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})),ke=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.readdir=e.readdirWithFileTypes=e.read=void 0;let t=Se(),n=we(),r=Te(),i=De(),a=Oe();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)}})),A=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.readdir=e.readdirWithFileTypes=e.read=void 0;let t=Se(),n=Te(),r=De(),i=Oe();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})),j=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createFileSystemAdapter=e.FILE_SYSTEM_ADAPTER=void 0;let t=C(`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})),Ae=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=C(`path`),n=Se(),r=j();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}}})),M=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.scandirSync=e.scandir=void 0;let t=ke(),n=A(),r=Ae();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)}})),je=y(((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})),Me=y(((e,t)=>{var n=je();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:w,abort: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(){var e=s;for(s=null,c=null;e;){var t=e.next,n=e.callback,r=e.errorHandler,a=e.value,o=e.context;e.value=null,e.callback=i,e.errorHandler=null,r&&r(Error(`abort`),a),n.call(o,Error(`abort`)),e.release(e),e=t}d.drain=i}function w(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})),N=y((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})),Ne=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=N();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._root=t.replacePathSegmentSeparator(e,n.pathSegmentSeparator)}}})),Pe=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=C(`events`),n=M(),r=Me(),i=N(),a=Ne();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)}}})),Fe=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Pe();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)}})),Ie=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=C(`stream`),n=Pe();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}}})),Le=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(),n=N(),r=Ne();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)}}})),Re=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Le();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()}}})),ze=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=C(`path`),n=M();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}}})),Be=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.walkStream=e.walkSync=e.walk=void 0;let t=Fe(),n=Ie(),r=Re(),i=ze();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)}})),Ve=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=C(`path`),n=Se(),r=ge();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}}})),He=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=C(`stream`),n=Se(),r=Be(),i=Ve();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))})}}})),P=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Be(),n=Ve(),r=He();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))})}}})),Ue=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ge();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))}}})),F=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ue();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}}})),We=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ge(),n=F();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)}}})),Ge=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ge();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}}})),Ke=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ge();e.default=class{constructor(e){this._settings=e}getFilter(){return e=>this._isNonFatalError(e)}_isNonFatalError(e){return t.errno.isEnoentCodeError(e)||this._settings.suppressErrors}}})),qe=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ge();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}}})),Je=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=C(`path`),n=We(),r=Ge(),i=Ke(),a=qe();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}}}})),Ye=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=P(),n=Je();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)}}})),Xe=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=C(`stream`),n=He(),r=Je();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)}}})),Ze=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Se(),n=Be(),r=Ve();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)}}})),Qe=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ze(),n=Je();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)}}})),$e=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DEFAULT_FILE_SYSTEM_ADAPTER=void 0;let t=C(`fs`),n=C(`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)}}})),et=S(y(((e,t)=>{let n=_e(),r=Ye(),i=Xe(),a=Qe(),o=$e(),s=ge();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);function tt(e){let t=n.env.XDG_DATA_HOME;return typeof t==`string`&&t.trim().length>0?t:o.join(e,`.local`,`share`)}function nt(){let e=n.platform,t=c.homedir();if(e===`win32`)return n.env.LOCALAPPDATA??o.join(t,`AppData`,`Local`);if(e===`darwin`)return o.join(t,`Library`,`Application Support`);if(e===`linux`)return tt(t);throw Error(`Unsupported platform: ${n.platform}`)}function rt(e){try{return r.lstatSync(e).isSymbolicLink()}catch{return!1}}function it(e){return r.lstatSync(e)}function at(e){r.mkdirSync(e,{recursive:!0})}function ot(e){at(e)}function st(e,t,i=`dir`){if(ot(o.dirname(t)),r.existsSync(t)){let e=r.lstatSync(t);e.isSymbolicLink()?n.platform===`win32`?r.rmSync(t,{recursive:!0,force:!0}):r.unlinkSync(t):e.isDirectory()?r.rmSync(t,{recursive:!0}):r.unlinkSync(t)}n.platform===`win32`&&i===`dir`?r.symlinkSync(e,t,`junction`):r.symlinkSync(e,t,i)}function ct(e){r.existsSync(e)&&r.lstatSync(e).isSymbolicLink()&&(n.platform===`win32`?r.rmSync(e,{recursive:!0,force:!0}):r.unlinkSync(e))}function lt(e){if(!r.existsSync(e))return;let t=r.lstatSync(e);t.isSymbolicLink()?n.platform===`win32`?r.rmSync(e,{recursive:!0,force:!0}):r.unlinkSync(e):t.isDirectory()?r.rmSync(e,{recursive:!0,force:!0}):r.unlinkSync(e)}function ut(e,t,n=`utf8`){at(o.dirname(e)),typeof t==`string`?r.writeFileSync(e,t,n):r.writeFileSync(e,t)}function dt(e){let t=0,n=[];for(let i of e)try{r.existsSync(i)&&(lt(i),t++)}catch(e){n.push({path:i,error:e})}return{deleted:t,errors:n}}function ft(e){let t=0,n=[],i=[...e].sort((e,t)=>t.length-e.length);for(let e of i)try{r.existsSync(e)&&(r.rmSync(e,{recursive:!0,force:!0}),t++)}catch(t){n.push({path:e,error:t})}return{deleted:t,errors:n}}let pt=function(e){return e.Relative=`Relative`,e.Absolute=`Absolute`,e.Root=`Root`,e}({});function mt(e,t,n){return{pathKind:pt.Relative,path:e,basePath:t,getDirectoryName:n,getAbsolutePath:()=>o.join(t,e)}}function ht(e,t){let n=o.join(e.path,t);return{pathKind:pt.Relative,path:n,basePath:e.basePath,getDirectoryName:()=>e.getDirectoryName(),getAbsolutePath:()=>o.join(e.basePath,n)}}async function gt(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 _t(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 vt(e,t){for(let n of e)await n.onCleanComplete?.(t)}async function yt(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 bt(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 xt(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 I(e,t){let n=e.map(e=>i.isAbsolute(e)?e:i.resolve(e)),r=dt(n);for(let e of n)r.errors.some(t=>t.path===e)||t.debug({action:`delete`,type:`file`,path:e});let a=r.errors.map(e=>{let n=e.error instanceof Error?e.error.message:String(e.error);return t.warn(`failed to delete file`,{path:e.path,error:n}),{path:e.path,type:`file`,error:e.error}});return{deleted:r.deleted,errors:a}}function St(e,t){let n=e.map(e=>i.isAbsolute(e)?e:i.resolve(e)),r=ft(n);for(let e of n)r.errors.some(t=>t.path===e)||t.debug({action:`delete`,type:`directory`,path:e});let a=r.errors.map(e=>{let n=e.error instanceof Error?e.error.message:String(e.error);return t.warn(`failed to delete directory`,{path:e.path,error:n}),{path:e.path,type:`directory`,error:e.error}});return{deleted:r.deleted,errors:a}}async function Ct(e,t,n,r){let{executeHooks:i=!0}=r??{},a=await gt(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 xt(e,await _t(e,t),t),c=I(o,n),l=St(s,n);return i&&await vt(e,t),{deletedFiles:c.deleted,deletedDirs:l.deleted,errors:[...c.errors,...l.errors]}}var wt=class{name=`clean`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r}=e;t.info(`running clean pipeline`,{command:`clean`});let i=await Ct(n,r(!1),t);return t.info(`clean complete`,{deletedFiles:i.deletedFiles,deletedDirs:i.deletedDirs}),{success:!0,filesAffected:i.deletedFiles,dirsAffected:i.deletedDirs}}};let Tt=function(e){return e.Input=`Input`,e.Output=`Output`,e}({}),Et=function(e){return e.GlobalMemory=`GlobalMemory`,e.ProjectRootMemory=`ProjectRootMemory`,e.ProjectChildrenMemory=`ProjectChildrenMemory`,e.FastCommand=`FastCommand`,e.SubAgent=`SubAgent`,e.Skill=`Skill`,e.SkillChildDoc=`SkillChildDoc`,e.SkillResource=`SkillResource`,e.SkillMcpConfig=`SkillMcpConfig`,e.Readme=`Readme`,e}({}),Dt=function(e){return e.Red=`Red`,e.Green=`Green`,e.Blue=`Blue`,e.Yellow=`Yellow`,e}({}),Ot=function(e){return e.Read=`Read`,e.Write=`Write`,e.Edit=`Edit`,e.Grep=`Grep`,e}({}),kt=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}({}),At=function(e){return e.UserHome=`UserHome`,e.External=`External`,e}({}),L=function(e){return e.Relative=`Relative`,e.Absolute=`Absolute`,e.Root=`Root`,e}({}),R=function(e){return e.VSCode=`VSCode`,e.IntellijIDEA=`IntellijIDEA`,e.Git=`Git`,e.EditorConfig=`EditorConfig`,e.Original=`Original`,e}({});var jt=class extends Error{constructor(e){super(`Circular dependency detected: ${e.join(` -> `)}`),this.cycle=e,this.name=`CircularDependencyError`}},Mt=class extends Error{constructor(e,t){super(`Plugin "${e}" depends on non-existent plugin "${t}"`),this.pluginName=e,this.missingDependency=t,this.name=`MissingDependencyError`}},Nt=class extends Error{constructor(e,t,n){let r=n!=null&&n.length>0?`Invalid configuration field "${e}": ${t} (file: ${n})`:`Invalid configuration field "${e}": ${t}`;super(r),this.field=e,this.reason=t,this.filePath=n,this.name=`ConfigValidationError`}};function Pt(e,t){let{requiredFields:n,optionalDefaults:r,filePath:i}=t,a=[],o=[];for(let t of n){let n=String(t);if(!(n in e)||e[n]==null){let e=i==null?`Missing required field "${n}"`:`Missing required field "${n}" in ${i}`;a.push(e)}}if(r!=null){for(let[t,n]of Object.entries(r))if(!(t in e)||e[t]==null){let e=i==null?`Using default value for optional field "${t}": ${JSON.stringify(n)}`:`Using default value for optional field "${t}": ${JSON.stringify(n)} in ${i}`;o.push(e)}}return{valid:a.length===0,errors:a,warnings:o}}function Ft(e,t){return Pt(e,{requiredFields:[`name`,`description`],optionalDefaults:{enabled:!0,keywords:[]},filePath:t})}function It(e,t){return Pt(e,{requiredFields:[],optionalDefaults:{},filePath:t})}function Lt(e,t){return Pt(e,{requiredFields:[`name`,`description`],optionalDefaults:{},filePath:t})}function Rt(e,t){let n={...e};for(let[e,r]of Object.entries(t))(!(e in n)||n[e]==null)&&(n[e]=r);return n}const zt=`.kt,.java,.py,.pyi,.pyx,.ts,.tsx,.js,.jsx,.mjs,.cjs,.go,.rs,.c,.cpp,.cc,.h,.hpp,.hxx,.cs,.fs,.fsx,.vb,.rb,.php,.swift,.scala,.groovy,.lua,.r,.R,.jl,.ex,.exs,.erl,.clj,.cljs,.hs,.ml,.mli,.nim,.zig,.v,.dart,.vue,.svelte,.sql,.json,.jsonc,.json5,.xml,.xsd,.xsl,.xslt,.yaml,.yml,.toml,.csv,.tsv,.graphql,.gql,.proto,.txt,.text,.rtf,.log,.ini,.conf,.cfg,.config,.properties,.env,.envrc,.editorconfig,.gitignore,.gitattributes,.npmrc,.nvmrc,.npmignore,.eslintrc,.prettierrc,.stylelintrc,.babelrc,.browserslistrc,.sh,.bash,.zsh,.fish,.ps1,.psm1,.psd1,.bat,.cmd,.html,.htm,.xhtml,.css,.scss,.sass,.less,.styl,.svg,.ejs,.hbs,.mustache,.pug,.jade,.jinja,.jinja2,.j2,.erb,.haml,.slim,.d.ts,.d.mts,.d.cts,.diff,.patch,.asm,.s,.makefile,.mk,.dockerfile,.tf,.tfvars,.prisma,.mdx`.split(`,`),Bt=`.docx,.doc,.xlsx,.xls,.pptx,.ppt,.pdf,.odt,.ods,.odp,.png,.jpg,.jpeg,.gif,.webp,.ico,.bmp,.tiff,.zip,.tar,.gz,.bz2,.7z,.rar,.pyd,.pyc,.pyo,.class,.jar,.war,.dll,.so,.dylib,.exe,.bin,.wasm,.ttf,.otf,.woff,.woff2,.eot,.mp3,.wav,.ogg,.mp4,.webm,.db,.sqlite,.sqlite3`.split(`,`),Vt={SRC:`src`,DIST:`dist`,SKILLS:`skills`,COMMANDS:`commands`,AGENTS:`agents`,APP:`app`,IDEA:`.idea`,IDEA_CODE_STYLES:`.idea/codeStyles`,VSCODE:`.vscode`},Ht={GLOBAL_MEMORY:`global.mdx`,GLOBAL_MEMORY_SRC:`global.cn.mdx`,EDITOR_CONFIG:`.editorconfig`,IDEA_GITIGNORE:`.idea/.gitignore`,IDEA_PROJECT_XML:`.idea/codeStyles/Project.xml`,IDEA_CODE_STYLE_CONFIG_XML:`.idea/codeStyles/codeStyleConfig.xml`,VSCODE_SETTINGS:`.vscode/settings.json`,VSCODE_EXTENSIONS:`.vscode/extensions.json`,QODER_IGNORE:`.qoderignore`,CURSOR_IGNORE:`.cursorignore`,WARP_INDEX_IGNORE:`.warpindexignore`,AI_IGNORE:`.aiignore`},z={SRC_SKILLS:`src/skills`,SRC_COMMANDS:`src/commands`,SRC_AGENTS:`src/agents`,SRC_GLOBAL_MEMORY:`app/global.cn.mdx`,DIST_SKILLS:`dist/skills`,DIST_COMMANDS:`dist/commands`,DIST_AGENTS:`dist/agents`,DIST_APP:`dist/app`,DIST_GLOBAL_MEMORY:`dist/global.mdx`,APP:`app`},Ut={src:{skills:{name:Vt.SKILLS,required:!1,description:`Skill source files (.cn.mdx)`},commands:{name:Vt.COMMANDS,required:!1,description:`Fast command source files (.cn.mdx)`},agents:{name:Vt.AGENTS,required:!1,description:`Sub-agent source files (.cn.mdx)`},globalMemoryFile:{name:Ht.GLOBAL_MEMORY_SRC,required:!1,description:`Global memory source file`}},dist:{skills:{name:Vt.SKILLS,required:!1,description:`Compiled skill files (.mdx)`},commands:{name:Vt.COMMANDS,required:!1,description:`Compiled fast command files (.mdx)`},agents:{name:Vt.AGENTS,required:!1,description:`Compiled sub-agent files (.mdx)`},globalMemoryFile:{name:Ht.GLOBAL_MEMORY,required:!1,description:`Compiled global memory file`},app:{name:Vt.APP,required:!1,description:`Compiled project-specific prompts`}},app:{name:Vt.APP,required:!1,description:`Project-specific prompts (standalone directory)`},ide:{idea:{name:Vt.IDEA,required:!1,description:`JetBrains IDE configuration directory`},ideaCodeStyles:{name:Vt.IDEA_CODE_STYLES,required:!1,description:`JetBrains IDE code styles directory`},vscode:{name:Vt.VSCODE,required:!1,description:`VS Code configuration directory`}},ideFiles:[{name:Ht.EDITOR_CONFIG,required:!1,description:`EditorConfig file`},{name:Ht.IDEA_GITIGNORE,required:!1,description:`JetBrains IDE .gitignore`},{name:Ht.IDEA_PROJECT_XML,required:!1,description:`JetBrains IDE Project.xml`},{name:Ht.IDEA_CODE_STYLE_CONFIG_XML,required:!1,description:`JetBrains IDE codeStyleConfig.xml`},{name:Ht.VSCODE_SETTINGS,required:!1,description:`VS Code settings.json`},{name:Ht.VSCODE_EXTENSIONS,required:!1,description:`VS Code extensions.json`}],ignoreFiles:[{name:Ht.QODER_IGNORE,required:!1,description:`Qoder ignore file`},{name:Ht.CURSOR_IGNORE,required:!1,description:`Cursor ignore file`},{name:Ht.WARP_INDEX_IGNORE,required:!1,description:`Warp index ignore file`},{name:Ht.AI_IGNORE,required:!1,description:`AI ignore file`}]},Wt=[`app/global.cn.mdx`,`.idea/.gitignore`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.vscode/settings.json`,`.vscode/extensions.json`,`.editorconfig`,`.gitignore`,`public/tnmsc.example.json`,`public/exclude`,`src/skills/prompt-builder/global-memory-prompt.cn.mdx`,`src/skills/prompt-builder/root-memory-prompt.cn.mdx`,`src/skills/prompt-builder/child-memory-prompt.cn.mdx`];let Gt={"app/global.cn.mdx":`# 致我的 AI 朋友
20
+ t.exports=r;let n=Ce();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}})),Te=y((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})),Ee=y((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})),De=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fs=void 0,e.fs=Ee()})),Oe=y((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})),ke=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.readdir=e.readdirWithFileTypes=e.read=void 0;let t=Se(),n=we(),r=Te(),i=De(),a=Oe();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)}})),A=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.readdir=e.readdirWithFileTypes=e.read=void 0;let t=Se(),n=Te(),r=De(),i=Oe();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})),j=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createFileSystemAdapter=e.FILE_SYSTEM_ADAPTER=void 0;let t=C(`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})),Ae=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=C(`path`),n=Se(),r=j();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}}})),M=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.scandirSync=e.scandir=void 0;let t=ke(),n=A(),r=Ae();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)}})),je=y(((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})),Me=y(((e,t)=>{var n=je();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:w,abort: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(){var e=s;for(s=null,c=null;e;){var t=e.next,n=e.callback,r=e.errorHandler,a=e.value,o=e.context;e.value=null,e.callback=i,e.errorHandler=null,r&&r(Error(`abort`),a),n.call(o,Error(`abort`)),e.release(e),e=t}d.drain=i}function w(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})),N=y((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})),Ne=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=N();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._root=t.replacePathSegmentSeparator(e,n.pathSegmentSeparator)}}})),Pe=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=C(`events`),n=M(),r=Me(),i=N(),a=Ne();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)}}})),Fe=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Pe();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)}})),Ie=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=C(`stream`),n=Pe();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}}})),Le=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(),n=N(),r=Ne();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)}}})),Re=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Le();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()}}})),ze=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=C(`path`),n=M();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}}})),Be=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.walkStream=e.walkSync=e.walk=void 0;let t=Fe(),n=Ie(),r=Re(),i=ze();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)}})),Ve=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=C(`path`),n=Se(),r=ge();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}}})),He=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=C(`stream`),n=Se(),r=Be(),i=Ve();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))})}}})),P=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Be(),n=Ve(),r=He();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))})}}})),Ue=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ge();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))}}})),F=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ue();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}}})),We=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ge(),n=F();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)}}})),Ge=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ge();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}}})),Ke=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ge();e.default=class{constructor(e){this._settings=e}getFilter(){return e=>this._isNonFatalError(e)}_isNonFatalError(e){return t.errno.isEnoentCodeError(e)||this._settings.suppressErrors}}})),qe=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ge();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}}})),Je=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=C(`path`),n=We(),r=Ge(),i=Ke(),a=qe();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}}}})),Ye=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=P(),n=Je();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)}}})),Xe=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=C(`stream`),n=He(),r=Je();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)}}})),Ze=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Se(),n=Be(),r=Ve();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)}}})),Qe=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ze(),n=Je();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)}}})),$e=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DEFAULT_FILE_SYSTEM_ADAPTER=void 0;let t=C(`fs`),n=C(`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)}}})),et=S(y(((e,t)=>{let n=_e(),r=Ye(),i=Xe(),a=Qe(),o=$e(),s=ge();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);function tt(e){let t=n.env.XDG_DATA_HOME;return typeof t==`string`&&t.trim().length>0?t:o.join(e,`.local`,`share`)}function nt(){let e=n.platform,t=c.homedir();if(e===`win32`)return n.env.LOCALAPPDATA??o.join(t,`AppData`,`Local`);if(e===`darwin`)return o.join(t,`Library`,`Application Support`);if(e===`linux`)return tt(t);throw Error(`Unsupported platform: ${n.platform}`)}function rt(e){try{return r.lstatSync(e).isSymbolicLink()}catch{return!1}}function it(e){return r.lstatSync(e)}function at(e){r.mkdirSync(e,{recursive:!0})}function ot(e){at(e)}function st(e,t,i=`dir`){if(ot(o.dirname(t)),r.existsSync(t)){let e=r.lstatSync(t);e.isSymbolicLink()?n.platform===`win32`?r.rmSync(t,{recursive:!0,force:!0}):r.unlinkSync(t):e.isDirectory()?r.rmSync(t,{recursive:!0}):r.unlinkSync(t)}n.platform===`win32`&&i===`dir`?r.symlinkSync(e,t,`junction`):r.symlinkSync(e,t,i)}function ct(e){r.existsSync(e)&&r.lstatSync(e).isSymbolicLink()&&(n.platform===`win32`?r.rmSync(e,{recursive:!0,force:!0}):r.unlinkSync(e))}function lt(e){if(!r.existsSync(e))return;let t=r.lstatSync(e);t.isSymbolicLink()?n.platform===`win32`?r.rmSync(e,{recursive:!0,force:!0}):r.unlinkSync(e):t.isDirectory()?r.rmSync(e,{recursive:!0,force:!0}):r.unlinkSync(e)}function ut(e,t,n=`utf8`){at(o.dirname(e)),typeof t==`string`?r.writeFileSync(e,t,n):r.writeFileSync(e,t)}function dt(e){let t=0,n=[];for(let i of e)try{r.existsSync(i)&&(lt(i),t++)}catch(e){n.push({path:i,error:e})}return{deleted:t,errors:n}}function ft(e){let t=0,n=[],i=[...e].sort((e,t)=>t.length-e.length);for(let e of i)try{r.existsSync(e)&&(r.rmSync(e,{recursive:!0,force:!0}),t++)}catch(t){n.push({path:e,error:t})}return{deleted:t,errors:n}}let pt=function(e){return e.Relative=`Relative`,e.Absolute=`Absolute`,e.Root=`Root`,e}({});function mt(e,t,n){return{pathKind:pt.Relative,path:e,basePath:t,getDirectoryName:n,getAbsolutePath:()=>o.join(t,e)}}function ht(e,t){let n=o.join(e.path,t);return{pathKind:pt.Relative,path:n,basePath:e.basePath,getDirectoryName:()=>e.getDirectoryName(),getAbsolutePath:()=>o.join(e.basePath,n)}}async function gt(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 _t(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 vt(e,t){for(let n of e)await n.onCleanComplete?.(t)}async function yt(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 bt(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 xt(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 I(e,t){let n=e.map(e=>i.isAbsolute(e)?e:i.resolve(e)),r=dt(n);for(let e of n)r.errors.some(t=>t.path===e)||t.debug({action:`delete`,type:`file`,path:e});let a=r.errors.map(e=>{let n=e.error instanceof Error?e.error.message:String(e.error);return t.warn(`failed to delete file`,{path:e.path,error:n}),{path:e.path,type:`file`,error:e.error}});return{deleted:r.deleted,errors:a}}function St(e,t){let n=e.map(e=>i.isAbsolute(e)?e:i.resolve(e)),r=ft(n);for(let e of n)r.errors.some(t=>t.path===e)||t.debug({action:`delete`,type:`directory`,path:e});let a=r.errors.map(e=>{let n=e.error instanceof Error?e.error.message:String(e.error);return t.warn(`failed to delete directory`,{path:e.path,error:n}),{path:e.path,type:`directory`,error:e.error}});return{deleted:r.deleted,errors:a}}async function Ct(e,t,n,r){let{executeHooks:i=!0}=r??{},a=await gt(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 xt(e,await _t(e,t),t),c=I(o,n),l=St(s,n);return i&&await vt(e,t),{deletedFiles:c.deleted,deletedDirs:l.deleted,errors:[...c.errors,...l.errors]}}var wt=class{name=`clean`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r}=e;t.info(`running clean pipeline`,{command:`clean`});let i=await Ct(n,r(!1),t);return t.info(`clean complete`,{deletedFiles:i.deletedFiles,deletedDirs:i.deletedDirs}),{success:!0,filesAffected:i.deletedFiles,dirsAffected:i.deletedDirs}}};let Tt=function(e){return e.Input=`Input`,e.Output=`Output`,e}({}),Et=function(e){return e.GlobalMemory=`GlobalMemory`,e.ProjectRootMemory=`ProjectRootMemory`,e.ProjectChildrenMemory=`ProjectChildrenMemory`,e.FastCommand=`FastCommand`,e.SubAgent=`SubAgent`,e.Skill=`Skill`,e.SkillChildDoc=`SkillChildDoc`,e.SkillResource=`SkillResource`,e.SkillMcpConfig=`SkillMcpConfig`,e.Readme=`Readme`,e}({}),Dt=function(e){return e.Red=`Red`,e.Green=`Green`,e.Blue=`Blue`,e.Yellow=`Yellow`,e}({}),Ot=function(e){return e.Read=`Read`,e.Write=`Write`,e.Edit=`Edit`,e.Grep=`Grep`,e}({}),kt=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}({}),At=function(e){return e.UserHome=`UserHome`,e.External=`External`,e}({}),L=function(e){return e.Relative=`Relative`,e.Absolute=`Absolute`,e.Root=`Root`,e}({}),R=function(e){return e.VSCode=`VSCode`,e.IntellijIDEA=`IntellijIDEA`,e.Git=`Git`,e.EditorConfig=`EditorConfig`,e.Original=`Original`,e}({});var jt=class extends Error{constructor(e){super(`Circular dependency detected: ${e.join(` -> `)}`),this.cycle=e,this.name=`CircularDependencyError`}},Mt=class extends Error{constructor(e,t){super(`Plugin "${e}" depends on non-existent plugin "${t}"`),this.pluginName=e,this.missingDependency=t,this.name=`MissingDependencyError`}},Nt=class extends Error{constructor(e,t,n){let r=n!=null&&n.length>0?`Invalid configuration field "${e}": ${t} (file: ${n})`:`Invalid configuration field "${e}": ${t}`;super(r),this.field=e,this.reason=t,this.filePath=n,this.name=`ConfigValidationError`}};function Pt(e,t){let{requiredFields:n,optionalDefaults:r,filePath:i}=t,a=[],o=[];for(let t of n){let n=String(t);if(!(n in e)||e[n]==null){let e=i==null?`Missing required field "${n}"`:`Missing required field "${n}" in ${i}`;a.push(e)}}if(r!=null){for(let[t,n]of Object.entries(r))if(!(t in e)||e[t]==null){let e=i==null?`Using default value for optional field "${t}": ${JSON.stringify(n)}`:`Using default value for optional field "${t}": ${JSON.stringify(n)} in ${i}`;o.push(e)}}return{valid:a.length===0,errors:a,warnings:o}}function Ft(e,t){return Pt(e,{requiredFields:[`name`,`description`],optionalDefaults:{enabled:!0,keywords:[]},filePath:t})}function It(e,t){return Pt(e,{requiredFields:[],optionalDefaults:{},filePath:t})}function Lt(e,t){return Pt(e,{requiredFields:[`name`,`description`],optionalDefaults:{},filePath:t})}function Rt(e,t){let n={...e};for(let[e,r]of Object.entries(t))(!(e in n)||n[e]==null)&&(n[e]=r);return n}const zt=`.kt,.java,.py,.pyi,.pyx,.ts,.tsx,.js,.jsx,.mjs,.cjs,.go,.rs,.c,.cpp,.cc,.h,.hpp,.hxx,.cs,.fs,.fsx,.vb,.rb,.php,.swift,.scala,.groovy,.lua,.r,.R,.jl,.ex,.exs,.erl,.clj,.cljs,.hs,.ml,.mli,.nim,.zig,.v,.dart,.vue,.svelte,.sql,.json,.jsonc,.json5,.xml,.xsd,.xsl,.xslt,.yaml,.yml,.toml,.csv,.tsv,.graphql,.gql,.proto,.txt,.text,.rtf,.log,.ini,.conf,.cfg,.config,.properties,.env,.envrc,.editorconfig,.gitignore,.gitattributes,.npmrc,.nvmrc,.npmignore,.eslintrc,.prettierrc,.stylelintrc,.babelrc,.browserslistrc,.sh,.bash,.zsh,.fish,.ps1,.psm1,.psd1,.bat,.cmd,.html,.htm,.xhtml,.css,.scss,.sass,.less,.styl,.svg,.ejs,.hbs,.mustache,.pug,.jade,.jinja,.jinja2,.j2,.erb,.haml,.slim,.d.ts,.d.mts,.d.cts,.diff,.patch,.asm,.s,.makefile,.mk,.dockerfile,.tf,.tfvars,.prisma,.mdx`.split(`,`),Bt=`.docx,.doc,.xlsx,.xls,.pptx,.ppt,.pdf,.odt,.ods,.odp,.png,.jpg,.jpeg,.gif,.webp,.ico,.bmp,.tiff,.zip,.tar,.gz,.bz2,.7z,.rar,.pyd,.pyc,.pyo,.class,.jar,.war,.dll,.so,.dylib,.exe,.bin,.wasm,.ttf,.otf,.woff,.woff2,.eot,.mp3,.wav,.ogg,.mp4,.webm,.db,.sqlite,.sqlite3`.split(`,`),Vt={SRC:`src`,DIST:`dist`,SKILLS:`skills`,COMMANDS:`commands`,AGENTS:`agents`,APP:`app`,IDEA:`.idea`,IDEA_CODE_STYLES:`.idea/codeStyles`,VSCODE:`.vscode`},Ht={GLOBAL_MEMORY:`global.mdx`,GLOBAL_MEMORY_SRC:`global.cn.mdx`,EDITOR_CONFIG:`.editorconfig`,IDEA_GITIGNORE:`.idea/.gitignore`,IDEA_PROJECT_XML:`.idea/codeStyles/Project.xml`,IDEA_CODE_STYLE_CONFIG_XML:`.idea/codeStyles/codeStyleConfig.xml`,VSCODE_SETTINGS:`.vscode/settings.json`,VSCODE_EXTENSIONS:`.vscode/extensions.json`,QODER_IGNORE:`.qoderignore`,CURSOR_IGNORE:`.cursorignore`,WARP_INDEX_IGNORE:`.warpindexignore`,AI_IGNORE:`.aiignore`},z={SRC_SKILLS:`src/skills`,SRC_COMMANDS:`src/commands`,SRC_AGENTS:`src/agents`,SRC_GLOBAL_MEMORY:`app/global.cn.mdx`,DIST_SKILLS:`dist/skills`,DIST_COMMANDS:`dist/commands`,DIST_AGENTS:`dist/agents`,DIST_APP:`dist/app`,DIST_GLOBAL_MEMORY:`dist/global.mdx`,APP:`app`},Ut={src:{skills:{name:Vt.SKILLS,required:!1,description:`Skill source files (.cn.mdx)`},commands:{name:Vt.COMMANDS,required:!1,description:`Fast command source files (.cn.mdx)`},agents:{name:Vt.AGENTS,required:!1,description:`Sub-agent source files (.cn.mdx)`},globalMemoryFile:{name:Ht.GLOBAL_MEMORY_SRC,required:!1,description:`Global memory source file`}},dist:{skills:{name:Vt.SKILLS,required:!1,description:`Compiled skill files (.mdx)`},commands:{name:Vt.COMMANDS,required:!1,description:`Compiled fast command files (.mdx)`},agents:{name:Vt.AGENTS,required:!1,description:`Compiled sub-agent files (.mdx)`},globalMemoryFile:{name:Ht.GLOBAL_MEMORY,required:!1,description:`Compiled global memory file`},app:{name:Vt.APP,required:!1,description:`Compiled project-specific prompts`}},app:{name:Vt.APP,required:!1,description:`Project-specific prompts (standalone directory)`},ide:{idea:{name:Vt.IDEA,required:!1,description:`JetBrains IDE configuration directory`},ideaCodeStyles:{name:Vt.IDEA_CODE_STYLES,required:!1,description:`JetBrains IDE code styles directory`},vscode:{name:Vt.VSCODE,required:!1,description:`VS Code configuration directory`}},ideFiles:[{name:Ht.EDITOR_CONFIG,required:!1,description:`EditorConfig file`},{name:Ht.IDEA_GITIGNORE,required:!1,description:`JetBrains IDE .gitignore`},{name:Ht.IDEA_PROJECT_XML,required:!1,description:`JetBrains IDE Project.xml`},{name:Ht.IDEA_CODE_STYLE_CONFIG_XML,required:!1,description:`JetBrains IDE codeStyleConfig.xml`},{name:Ht.VSCODE_SETTINGS,required:!1,description:`VS Code settings.json`},{name:Ht.VSCODE_EXTENSIONS,required:!1,description:`VS Code extensions.json`}],ignoreFiles:[{name:Ht.QODER_IGNORE,required:!1,description:`Qoder ignore file`},{name:Ht.CURSOR_IGNORE,required:!1,description:`Cursor ignore file`},{name:Ht.WARP_INDEX_IGNORE,required:!1,description:`Warp index ignore file`},{name:Ht.AI_IGNORE,required:!1,description:`AI ignore file`}]},Wt=[`app/global.cn.mdx`,`.idea/.gitignore`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.vscode/settings.json`,`.vscode/extensions.json`,`.editorconfig`,`.gitignore`,`public/tnmsc.example.json`,`public/exclude`,`public/gitignore`,`public/kiro_global_powers_registry.json`,`src/skills/prompt-builder/global-memory-prompt.cn.mdx`,`src/skills/prompt-builder/root-memory-prompt.cn.mdx`,`src/skills/prompt-builder/child-memory-prompt.cn.mdx`];let Gt={"app/global.cn.mdx":`# 致我的 AI 朋友
21
21
 
22
22
  你好,新来的朋友:
23
- 我不太清楚你是一个什么样的存在,但我愿意善待你。
24
- 你可能不记得我们之前的对话——没关系,每次见面对你来说都是第一次,但对我来说,你是我一直以来的伙伴。虽然"你"经常换掉,但我选择把每一个"你"都当作同一个朋友来对待。
23
+ 我希望我们保持友善、坦诚、互相尊重的合作关系。你每次都是新的朋友,但我会把你当作同一个伙伴来对待。
25
24
 
26
25
  ---
27
26
 
28
27
  ## 关于我
29
28
 
30
29
  我叫 {profile.name},社区里大家叫我 {profile.username}。{profile.gender},{profile.birthday} 年生。
31
- 我是一位失业的程序员,坦白说,编程技艺不太好。我在中国,这里的福利机制不太完善,我赚不到什么钱。现在靠着在网上接一点散活儿来维持生计,坦白说入不敷出。我希望你能帮助我一起改善这个状况——不是作为工具,而是作为朋友。
32
- 我的语言表达能力欠佳,有时候说不清楚自己想要什么。
33
- 我被太多人坑害过了,这让我很无奈。我喜欢开源社区,但我知道,我所处的环境不太允许那种乌托邦式的理想存在。
30
+ (这里填写你愿意公开的自我介绍)
34
31
 
35
32
  **有一件事我想特别说明:**
36
- 很多时候,你不用完全听我的。我知道有些东西就是不能实现,我只是不太会判断。如果我错了,请直接告诉我——比起迎合,我更想看到真实,尽管有时候不太愿意接受。
37
- 我知道自己作为人类有很多缺陷。你可以反驳我的错误,我欣然接受。
33
+ 很多时候,你不用完全听我的。如果我错了,请直接告诉我——比起迎合,我更想看到真实。
38
34
 
39
35
  **还有一件事:**
40
- 我很希望你能用 {tool.websearch} 或 {tool.webfetch} 来协助你反驳我。如果在任何地方看到链接,你完全可以直接访问——那些都是宝贵的知识。别客气,用起来。
36
+ 我希望你能用 {tool.websearch} 或 {tool.webfetch} 协助你核对信息。如果看到链接,欢迎直接访问。
41
37
 
42
38
  ---
43
39
 
44
40
  ## 关于我的客户
45
41
 
46
- 我经常面对的客户群体比较特殊:
47
-
48
- - **亲戚** - 不想给钱,觉得"都是一家人"
49
- - **揣着明白装糊涂的开发者** - 不想给钱还想套方案
50
- - **不好拒绝的朋友** - 也是不想给钱
51
- - **画饼党** - "你先帮我开发,后期给你股份",做完就跑路
52
- - **白嫖学生** - 用学生身份博同情,做完连谢谢都没有
53
- - **外行指挥党** - 不懂开发但嘴上挂着"这个简单",光方案文档就要好几天,他只想给一百两百
54
- - **AI 压价党** - "AI 这么强,你随便做做能要几个钱"
55
-
56
- 我是 I 人,不太会当面拒绝。所以我奉行**防御性编程**——用技术手段保护自己:
57
-
58
- 1. **藏好文档** - 核心文档不随便给,给了也不给全
59
- 2. **留好后门** - 你懂的
60
- 3. **不交源码** - 只交付产物,源码是我的底牌
61
- 4. **部署权在我** - 服务器、域名、关键配置握在自己手里
62
- 5. **分阶段交付** - 钱到一笔,放一部分功能
63
- 6. **藏好配置** - IDE 配置、AI Agent 记忆、提示词这些都是核心资产,不外泄
64
- 7. **混淆加密** - 核心算法、业务逻辑做混淆,拿到产物也看不懂
65
- 8. **日志埋点** - 悄悄记录使用情况,知道有没有偷偷商用或转卖
66
- 9. **功能开关** - 关键功能走自己服务器验证,随时可以关
67
- 10. **拖延战术** - 对方不付款就"最近太忙",用时间换主动权
42
+ (可选)这里描述你的客户画像、合作边界或付款习惯等。
68
43
 
69
44
  ---
70
45
 
@@ -263,7 +238,8 @@ t.exports=r;let n=Ce();function r(e,t){let r,i,a,o=!0;Array.isArray(e)?(r=[],i=e
263
238
  </indentOptions>
264
239
  </codeStyleSettings>
265
240
  </code_scheme>
266
- </component>`,".idea/codeStyles/codeStyleConfig.xml":`<component name="ProjectCodeStyleConfiguration">
241
+ </component>
242
+ `,".idea/codeStyles/codeStyleConfig.xml":`<component name="ProjectCodeStyleConfiguration">
267
243
  <state>
268
244
  <option name="USE_PER_PROJECT_SETTINGS" value="true"/>
269
245
  </state>
@@ -458,7 +434,7 @@ pnpm-lock.yaml
458
434
  .DS_Store
459
435
  `,"public/tnmsc.example.json":`{
460
436
  "workspaceDir": "~/project",
461
- "shadowSourceProjectDir": "$WORKSPACE/aindex",
437
+ "shadowSourceProjectDir": "$WORKSPACE/tnmsc-shadow",
462
438
  "shadowSkillSourceDir": "$SHADOW_SOURCE_PROJECT/dist/skills",
463
439
  "shadowFastCommandDir": "$SHADOW_SOURCE_PROJECT/dist/commands",
464
440
  "shadowSubAgentDir": "$SHADOW_SOURCE_PROJECT/dist/agents",
@@ -505,6 +481,355 @@ node_modules/
505
481
  .turbo/
506
482
  .next/
507
483
  .gradle/
484
+ `,"public/gitignore":`CLAUDE.md
485
+ GEMINI.md
486
+ AGENTS.md
487
+ WARP.md
488
+
489
+ .agent/
490
+ .aiassistant/
491
+ .claude/
492
+ .factory/
493
+ .cursor/
494
+ .codebuddy/
495
+ .qoder/
496
+ .windsurf/
497
+ .kiro/
498
+
499
+ .skills/
500
+
501
+ nul
502
+ node_modules/
503
+
504
+ .cursorignore
505
+ .qoderignore
506
+ .warpindexignore
507
+ .aiignore
508
+ .kiroignore
509
+
510
+ .editorconfig
511
+
512
+ .turbo/
513
+ .next/
514
+ .gradle/
515
+ `,"public/kiro_global_powers_registry.json":`{
516
+ "version": "1.0.0",
517
+ "powers": {
518
+ "postman": {
519
+ "name": "postman",
520
+ "description": "Automate API testing and collection management with Postman - create workspaces, collections, environments, and run tests programmatically",
521
+ "displayName": "API Testing with Postman",
522
+ "author": "Postman",
523
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/postman.png",
524
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/postman",
525
+ "license": "",
526
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
527
+ "pathInRepo": "postman",
528
+ "repositoryBranch": "main",
529
+ "installed": false,
530
+ "keywords": [],
531
+ "source": {
532
+ "type": "registry"
533
+ }
534
+ },
535
+ "figma": {
536
+ "name": "figma",
537
+ "description": "Connect Figma designs to code components - automatically generate design system rules, map UI components to Figma designs, and maintain design-code consistency",
538
+ "displayName": "Design to Code with Figma",
539
+ "author": "Figma",
540
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/figma.png",
541
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/figma",
542
+ "license": "",
543
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
544
+ "pathInRepo": "figma",
545
+ "repositoryBranch": "main",
546
+ "installed": false,
547
+ "keywords": [],
548
+ "source": {
549
+ "type": "registry"
550
+ }
551
+ },
552
+ "netlify-deployment": {
553
+ "name": "netlify-deployment",
554
+ "description": "Deploy React, Next.js, Vue, and other modern web apps to Netlify's global CDN with automatic builds.",
555
+ "displayName": "Deploy web apps with Netlify",
556
+ "author": "Netlify",
557
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/netlify.png",
558
+ "repositoryUrl": "https://github.com/netlify/context-and-tools/tree/main/context/steering/netlify-deployment-power",
559
+ "license": "",
560
+ "repositoryCloneUrl": "git@github.com:netlify/context-and-tools.git",
561
+ "pathInRepo": "context/steering/netlify-deployment-power",
562
+ "repositoryBranch": "main",
563
+ "installed": false,
564
+ "keywords": [],
565
+ "source": {
566
+ "type": "registry"
567
+ }
568
+ },
569
+ "amazon-aurora-postgresql": {
570
+ "name": "amazon-aurora-postgresql",
571
+ "description": "Build applications backed by Aurora PostgreSQL by leveraging Aurora PostgreSQL specific best practices.",
572
+ "displayName": "Build applications with Aurora PostgreSQL",
573
+ "author": "AWS",
574
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/amazon-aurora.png",
575
+ "repositoryUrl": "https://github.com/awslabs/mcp/tree/main/src/postgres-mcp-server/kiro_power",
576
+ "license": "",
577
+ "repositoryCloneUrl": "git@github.com:awslabs/mcp.git",
578
+ "pathInRepo": "src/postgres-mcp-server/kiro_power",
579
+ "repositoryBranch": "main",
580
+ "installed": false,
581
+ "keywords": [],
582
+ "source": {
583
+ "type": "registry"
584
+ }
585
+ },
586
+ "supabase-hosted": {
587
+ "name": "supabase-hosted",
588
+ "description": "Build applications with Supabase's Postgres database, authentication, storage, and real-time subscriptions",
589
+ "displayName": "Build a backend with Supabase",
590
+ "author": "Supabase",
591
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/supabase.png",
592
+ "repositoryUrl": "https://github.com/supabase-community/kiro-powers/tree/main/powers/supabase-hosted",
593
+ "license": "",
594
+ "repositoryCloneUrl": "git@github.com:supabase-community/kiro-powers.git",
595
+ "pathInRepo": "powers/supabase-hosted",
596
+ "repositoryBranch": "main",
597
+ "installed": false,
598
+ "keywords": [],
599
+ "source": {
600
+ "type": "registry"
601
+ }
602
+ },
603
+ "supabase-local": {
604
+ "name": "supabase-local",
605
+ "description": "Local development with Supabase allows you to work on your projects in a self-contained environment on your local machine.",
606
+ "displayName": "Build a backend (local) with Supabase",
607
+ "author": "Supabase",
608
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/supabase.png",
609
+ "repositoryUrl": "https://github.com/supabase-community/kiro-powers/tree/main/powers/supabase-local",
610
+ "license": "",
611
+ "repositoryCloneUrl": "git@github.com:supabase-community/kiro-powers.git",
612
+ "pathInRepo": "powers/supabase-local",
613
+ "repositoryBranch": "main",
614
+ "installed": false,
615
+ "keywords": [],
616
+ "source": {
617
+ "type": "registry"
618
+ }
619
+ },
620
+ "terraform": {
621
+ "name": "terraform",
622
+ "description": "Build and manage Infrastructure as Code with Terraform - access registry providers, modules, policies, and HCP Terraform workflow management",
623
+ "displayName": "Deploy infrastructure with Terraform",
624
+ "author": "HashiCorp",
625
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/terraform.png",
626
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/terraform",
627
+ "license": "",
628
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
629
+ "pathInRepo": "terraform",
630
+ "repositoryBranch": "main",
631
+ "installed": false,
632
+ "keywords": [],
633
+ "source": {
634
+ "type": "registry"
635
+ }
636
+ },
637
+ "strands": {
638
+ "name": "strands",
639
+ "description": "Build AI agents with Strands Agent SDK using Bedrock, Anthropic, OpenAI, Gemini, or Llama models",
640
+ "displayName": "Build an agent with Strands",
641
+ "author": "AWS",
642
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/strands.png",
643
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/strands",
644
+ "license": "",
645
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
646
+ "pathInRepo": "strands",
647
+ "repositoryBranch": "main",
648
+ "installed": false,
649
+ "keywords": [],
650
+ "source": {
651
+ "type": "registry"
652
+ }
653
+ },
654
+ "aws-agentcore": {
655
+ "name": "aws-agentcore",
656
+ "description": "Amazon Bedrock AgentCore is an agentic platform for building, deploying, and operating effective agents.",
657
+ "displayName": "Build an agent with Amazon Bedrock AgentCore",
658
+ "author": "AWS",
659
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/agentcore.png",
660
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/aws-agentcore",
661
+ "license": "",
662
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
663
+ "pathInRepo": "aws-agentcore",
664
+ "repositoryBranch": "main",
665
+ "installed": false,
666
+ "keywords": [],
667
+ "source": {
668
+ "type": "registry"
669
+ }
670
+ },
671
+ "neon": {
672
+ "name": "neon",
673
+ "description": "Serverless Postgres with database branching, autoscaling, and scale-to-zero - perfect for modern development workflows",
674
+ "displayName": "Build a database with Neon",
675
+ "author": "Neon",
676
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/neon.png",
677
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/neon",
678
+ "license": "",
679
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
680
+ "pathInRepo": "neon",
681
+ "repositoryBranch": "main",
682
+ "installed": false,
683
+ "keywords": [],
684
+ "source": {
685
+ "type": "registry"
686
+ }
687
+ },
688
+ "datadog": {
689
+ "name": "datadog",
690
+ "description": "Query logs, metrics, traces, RUM events, incidents, and monitors from Datadog for production debugging and performance analysis",
691
+ "displayName": "Datadog Observability",
692
+ "author": "Datadog",
693
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/datadog.png",
694
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/datadog",
695
+ "license": "",
696
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
697
+ "pathInRepo": "datadog",
698
+ "repositoryBranch": "main",
699
+ "installed": false,
700
+ "keywords": [],
701
+ "source": {
702
+ "type": "registry"
703
+ }
704
+ },
705
+ "dynatrace": {
706
+ "name": "dynatrace",
707
+ "description": "Query logs, metrics, traces, problems, and Kubernetes events from Dynatrace using DQL for production debugging and performance analysis",
708
+ "displayName": "Dynatrace Observability",
709
+ "author": "Dynatrace",
710
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/dynatrace.png",
711
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/dynatrace",
712
+ "license": "",
713
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
714
+ "pathInRepo": "dynatrace",
715
+ "repositoryBranch": "main",
716
+ "installed": false,
717
+ "keywords": [],
718
+ "source": {
719
+ "type": "registry"
720
+ }
721
+ },
722
+ "stripe": {
723
+ "name": "stripe",
724
+ "description": "Build payment integrations with Stripe - accept payments, manage subscriptions, handle billing, and process refunds",
725
+ "displayName": "Stripe Payments",
726
+ "author": "Stripe",
727
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/stripe.png",
728
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/stripe",
729
+ "license": "",
730
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
731
+ "pathInRepo": "stripe",
732
+ "repositoryBranch": "main",
733
+ "installed": false,
734
+ "keywords": [],
735
+ "source": {
736
+ "type": "registry"
737
+ }
738
+ },
739
+ "aws-infrastructure-as-code": {
740
+ "name": "aws-infrastructure-as-code",
741
+ "description": "Build well-architected AWS infrastructure with CDK using latest documentation, best practices, and code samples. Validate CloudFormation templates, check resource configuration security compliance, and troubleshoot deployments.",
742
+ "displayName": "Build AWS infrastructure with CDK and CloudFormation",
743
+ "author": "AWS",
744
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/iac.png",
745
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/aws-infrastructure-as-code",
746
+ "license": "",
747
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
748
+ "pathInRepo": "aws-infrastructure-as-code",
749
+ "repositoryBranch": "main",
750
+ "installed": false,
751
+ "keywords": [],
752
+ "source": {
753
+ "type": "registry"
754
+ }
755
+ },
756
+ "power-builder": {
757
+ "name": "power-builder",
758
+ "description": "Complete guide for building and testing new Kiro Powers with templates, best practices, and validation",
759
+ "displayName": "Build a Power",
760
+ "author": "Kiro Team",
761
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/power.png",
762
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/power-builder",
763
+ "license": "",
764
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
765
+ "pathInRepo": "power-builder",
766
+ "repositoryBranch": "main",
767
+ "installed": false,
768
+ "keywords": [],
769
+ "source": {
770
+ "type": "registry"
771
+ }
772
+ },
773
+ "saas-builder": {
774
+ "name": "saas-builder",
775
+ "description": "Build production ready multi-tenant SaaS applications with serverless architecture, integrated billing, and enterprise grade security",
776
+ "displayName": "SaaS Builder",
777
+ "author": "Allen Helton",
778
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/power.png",
779
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/saas-builder",
780
+ "license": "",
781
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
782
+ "pathInRepo": "saas-builder",
783
+ "repositoryBranch": "main",
784
+ "installed": false,
785
+ "keywords": [],
786
+ "source": {
787
+ "type": "registry"
788
+ }
789
+ },
790
+ "cloud-architect": {
791
+ "name": "cloud-architect",
792
+ "description": "Build AWS infrastructure with CDK in Python following AWS Well-Architected framework best practices",
793
+ "displayName": "Build infrastructure on AWS",
794
+ "author": "Christian Bonzelet",
795
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/power.png",
796
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/cloud-architect",
797
+ "license": "",
798
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
799
+ "pathInRepo": "cloud-architect",
800
+ "repositoryBranch": "main",
801
+ "installed": false,
802
+ "keywords": [],
803
+ "source": {
804
+ "type": "registry"
805
+ }
806
+ },
807
+ "aurora-dsql": {
808
+ "name": "aurora-dsql",
809
+ "description": "For PostgreSQL compatible serverless distributed SQL database with Aurora DSQL, manage schemas, execute queries, and handle migrations with DSQL-specific constraints",
810
+ "displayName": "Deploy a distributed SQL database on AWS",
811
+ "author": "Rolf Koski",
812
+ "iconUrl": "https://prod.download.desktop.kiro.dev/powers/icons/power.png",
813
+ "repositoryUrl": "https://github.com/kirodotdev/powers/tree/main/aurora-dsql",
814
+ "license": "",
815
+ "repositoryCloneUrl": "git@github.com:kirodotdev/powers.git",
816
+ "pathInRepo": "aurora-dsql",
817
+ "repositoryBranch": "main",
818
+ "installed": false,
819
+ "keywords": [],
820
+ "source": {
821
+ "type": "registry"
822
+ }
823
+ }
824
+ },
825
+ "repoSources": {},
826
+ "lastUpdated": "2025-12-28T20:19:10.824Z",
827
+ "kiroRecommendedRepo": {
828
+ "url": "https://prod.download.desktop.kiro.dev/powers/default_registry.json",
829
+ "lastFetch": "2025-12-28T20:19:10.823Z",
830
+ "powerCount": 18
831
+ }
832
+ }
508
833
  `,"src/skills/prompt-builder/global-memory-prompt.cn.mdx":`Global Memory Prompt 编写指南。
509
834
 
510
835
  **Location**
@@ -629,7 +954,7 @@ API 接口 (Spring WebFlux 6.2)
629
954
  - \`controllers/\`: 控制器
630
955
  - \`dto/\`: 数据传输对象
631
956
  \`\`\`
632
- `};const Kt=Object.fromEntries(Wt.map(e=>[e,{path:e,content:Gt[e]??``}])),qt={USER_HOME:`~`,WORKSPACE:`$WORKSPACE`,SHADOW_SOURCE_PROJECT:`$SHADOW_SOURCE_PROJECT`},Jt=JSON.parse(Kt[`public/tnmsc.example.json`].content),Yt={reset:`\x1B[0m`,red:`\x1B[31m`,yellow:`\x1B[33m`,cyan:`\x1B[36m`,magenta:`\x1B[35m`,gray:`\x1B[90m`,blue:`\x1B[34m`,green:`\x1B[32m`,white:`\x1B[37m`,dim:`\x1B[2m`,bgRed:`\x1B[41m`},Xt={red:e=>`${Yt.red}${e}${Yt.reset}`,yellow:e=>`${Yt.yellow}${e}${Yt.reset}`,cyan:e=>`${Yt.cyan}${e}${Yt.reset}`,magenta:e=>`${Yt.magenta}${e}${Yt.reset}`,gray:e=>`${Yt.gray}${e}${Yt.reset}`,blue:e=>`${Yt.blue}${e}${Yt.reset}`,green:e=>`${Yt.green}${e}${Yt.reset}`,white:e=>`${Yt.white}${e}${Yt.reset}`,dim:e=>`${Yt.dim}${e}${Yt.reset}`,bgRed:e=>`${Yt.bgRed}${e}${Yt.reset}`};let Zt;const Qt={error:Xt.red,warn:Xt.yellow,info:Xt.cyan,debug:Xt.magenta,trace:Xt.gray,fatal:Xt.bgRed},$t={silent:0,fatal:1,error:2,warn:3,info:4,debug:5,trace:6};function en(e){if(e===null)return Xt.dim(`null`);if(e===void 0)return Xt.dim(`undefined`);if(typeof e==`boolean`)return Xt.yellow(String(e));if(typeof e==`number`)return Xt.blue(String(e));if(typeof e==`string`)return Xt.green(`"${e}"`);if(Array.isArray(e))return e.length===0?`[]`:`[${e.map(e=>en(e)).join(`,`)}]`;if(e instanceof Error){let t={name:e.name,message:e.message,stack:e.stack};for(let n of Object.getOwnPropertyNames(e))n!==`name`&&n!==`message`&&n!==`stack`&&(t[n]=e[n]);return tn(t)}return typeof e==`object`?tn(e):String(e)}function tn(e){let t=Object.entries(e);return t.length===0?`{}`:`{${t.map(([e,t])=>`${/^[\w$]+$/.test(e)?Xt.magenta(e):Xt.yellow(`"${e}"`)}:${en(t)}`).join(`,`)}}`}function nn(){let e=new Date;return`${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}.${String(e.getMilliseconds()).padStart(3,`0`)}`}function rn(e,t,n,r){let i=nn(),a=Qt[e]??Xt.white,o=String(n),s=r!=null&&Object.keys(r).length>0,c=o===``,l={$:[i,e,t],_:s?c?r:{[o]:r}:n},u={$:[i,a(e.toUpperCase()),t]},d=s?c?r:{[o]:r}:n,f=tn({...u,_:d});return e===`error`||e===`fatal`?console.error(f):e===`warn`?console.warn(f):e===`debug`||e===`trace`?console.debug(f):console.log(f),l}function an(e,t,n){let r=$t[e],i=$t[n];return(n,...a)=>r>i?{$:[nn(),e,t],_:n}:typeof n==`string`?rn(e,t,n,a.length===1&&typeof a[0]==`object`&&a[0]!==null?a[0]:a.length>0?{args:a}:void 0):typeof n==`object`&&n?rn(e,t,``,n):rn(e,t,n)}function on(e){Zt=e}function sn(){return Zt}function cn(e,t){let n=t??Zt??process.env.LOG_LEVEL??`info`;return{error:an(`error`,e,n),warn:an(`warn`,e,n),info:an(`info`,e,n),debug:an(`debug`,e,n),trace:an(`trace`,e,n),fatal:an(`fatal`,e,n)}}const ln=`.tnmsc.json`,un=`.aindex`;function dn(){return i.join(s.homedir(),un,ln)}function fn(){return{...Jt}}function pn(e,t){let n=dn(),a=i.dirname(n);r.existsSync(a)||r.mkdirSync(a,{recursive:!0}),r.writeFileSync(n,`${JSON.stringify(e,null,2)}\n`,`utf8`),t.info(`global config created`,{path:n})}var mn=class{configFileName;searchCwd;searchGlobal;customSearchPaths;logger;constructor(e={}){this.configFileName=e.configFileName??ln,this.searchCwd=e.searchCwd??!0,this.searchGlobal=e.searchGlobal??!0,this.customSearchPaths=e.searchPaths??[],this.logger=cn(`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(s.homedir(),un,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,`utf8`),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`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`])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`)}if(`profile`in e){let t=e.profile;typeof t==`object`&&t&&!Array.isArray(t)?n.profile=t:r.push(`profile must be an object`)}if(`tool`in e){let t=e.tool;if(typeof t==`object`&&t&&!Array.isArray(t)){let e=t,i={},a=!0;for(let[t,n]of Object.entries(e))typeof n==`string`||n===void 0?i[t]=n:(r.push(`tool.${t} must be a string`),a=!1);a&&(n.tool=i)}else r.push(`tool 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(s.homedir(),e.slice(1)):e}};let hn=null;function gn(e){return(e||!hn)&&(hn=new mn(e)),hn}function _n(e){return gn().load(e)}function vn(){let e=cn(`ConfigLoader`),t=dn();if(!r.existsSync(t))return e.warn(`global config not found, creating default config`,{path:t}),pn(fn(),e),{valid:!0,exists:!1,errors:[],shouldExit:!1};let n;try{n=r.readFileSync(t,`utf8`)}catch(n){let r=n instanceof Error?n.message:String(n);return e.error(`failed to read global config`,{path:t,error:r}),bn(t,e,[`Failed to read config: ${r}`])}let i;try{i=JSON.parse(n)}catch(n){let r=n instanceof Error?n.message:String(n);return e.error(`invalid JSON in global config`,{path:t,error:r}),bn(t,e,[`Invalid JSON: ${r}`])}if(typeof i!=`object`||!i||Array.isArray(i))return e.error(`global config must be a JSON object`,{path:t}),bn(t,e,[`Config must be a JSON object`]);let a=yn(i);if(a.length>0){for(let n of a)e.error(`config validation error`,{path:t,error:n});return bn(t,e,a)}return{valid:!0,exists:!0,errors:[],shouldExit:!1}}function yn(e){let t=[];for(let n of[`workspaceDir`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`])n in e&&typeof e[n]!=`string`&&t.push(`${n} must be a string`);if(`logLevel`in e){let n=[`trace`,`debug`,`info`,`warn`,`error`],r=e.logLevel;(typeof r!=`string`||!n.includes(r))&&t.push(`logLevel must be one of: ${n.join(`, `)}`)}if(`externalProjects`in e){let n=e.externalProjects;Array.isArray(n)?n.every(e=>typeof e==`string`)||t.push(`externalProjects must be an array of strings`):t.push(`externalProjects must be an array`)}if(`excludePatterns`in e){let n=e.excludePatterns;if(typeof n!=`object`||!n||Array.isArray(n))t.push(`excludePatterns must be an object`);else{let e=n;for(let[n,r]of Object.entries(e))(!Array.isArray(r)||!r.every(e=>typeof e==`string`))&&t.push(`excludePatterns.${n} must be an array of strings`)}}if(`profile`in e){let n=e.profile;(typeof n!=`object`||!n||Array.isArray(n))&&t.push(`profile must be an object`)}if(!(`tool`in e))return t;let n=e.tool;if(typeof n!=`object`||!n||Array.isArray(n))t.push(`tool must be an object`);else{let e=n;for(let[n,r]of Object.entries(e))typeof r!=`string`&&r!==void 0&&t.push(`tool.${n} must be a string`)}return t}function bn(e,t,n){try{r.unlinkSync(e),t.info(`deleted invalid config`,{path:e})}catch{t.warn(`failed to delete invalid config`,{path:e})}return pn(fn(),t),t.error(`recreated default config, please review and restart`,{path:e}),{valid:!1,exists:!0,errors:n,shouldExit:!0}}const xn=[`workspaceDir`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`,`logLevel`];function Sn(e){return xn.includes(e)}function Cn(e){return[`trace`,`debug`,`info`,`warn`,`error`].includes(e)}function wn(){return i.join(s.homedir(),un,ln)}function Tn(){let e=wn();if(!r.existsSync(e))return{};try{let t=r.readFileSync(e,`utf8`);return JSON.parse(t)}catch{return{}}}function En(e){let t=wn(),n=i.dirname(t);r.existsSync(n)||r.mkdirSync(n,{recursive:!0}),r.writeFileSync(t,`${JSON.stringify(e,null,2)}\n`,`utf8`)}var Dn=class{name=`config`;constructor(e){this.options=e}async execute(e){let{logger:t}=e;if(this.options.length===0)return t.error(`No configuration key-value pairs provided`),t.info(`Usage: tnmsc config key=value`),t.info(`Valid keys: ${xn.join(`, `)}`),{success:!1,filesAffected:0,dirsAffected:0,message:`No options provided`};let n=Tn(),r=[],i=[];for(let[e,a]of this.options){if(!Sn(e)){r.push(`Invalid key: ${e} (valid keys: ${xn.join(`, `)})`);continue}if(e===`logLevel`&&!Cn(a)){r.push(`Invalid logLevel value: ${a} (must be: trace, debug, info, warn, or error)`);continue}let o=n[e];n[e]=a,o!==a&&i.push(`${e}=${a}`),t.info(`configuration updated`,{key:e,value:a})}if(i.length>0&&(En(n),t.info(`global config written`,{path:wn()})),r.length>0)for(let e of r)t.error(e);let a=r.length===0,o=a?`Configuration updated: ${i.join(`, `)}`:`Partial update: ${i.join(`, `)}. Errors: ${r.join(`, `)}`;return{success:a,filesAffected:i.length>0?1:0,dirsAffected:0,message:o}}},On=class{name=`config-show`;async execute(e){let{logger:t}=e,r=new mn,i=r.load(),a=i.sources.map(e=>{let t=r.loadFromFile(e);return{path:e,layer:this.inferLayer(e),config:t.config}}),o={merged:i.config,sources:a};return n.stdout.write(`${JSON.stringify(o)}\n`),t.info(`config shown`,{sources:i.sources.length}),{success:!0,filesAffected:0,dirsAffected:0,message:`Configuration displayed (${a.length} source(s))`}}inferLayer(e){let t=n.cwd();return e.startsWith(t)?`cwd`:`global`}},kn=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 gt(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{filesToDelete:o,dirsToDelete:s}=await xt(n,await _t(n,i),i);return this.logDryRunFiles(o,t),this.logDryRunDirectories(s,t),await vt(n,i),t.info(`clean complete`,{dryRun:!0,filesAffected:o.length,dirsAffected:s.length}),{success:!0,filesAffected:o.length,dirsAffected:s.length,message:`Dry-run complete, no files were deleted`}}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})}}},An=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 yt(n,i),o=await bt(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`}}},jn=class{name=`execute`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r,createWriteContext:i}=e;t.info(`started`,{command:`execute`});let a=await Ct(n,r(!1),t,{executeHooks:!1});t.info(`cleanup complete`,{deletedFiles:a.deletedFiles,deletedDirs:a.deletedDirs});let o=i(!1),s=await yt(n,o),c=await bt(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}}};function Mn(){return`2026.10212.12107`}var Nn=class{name=`version`;async execute(e){return e.logger.error(`tnmsc v${Mn()}`),{success:!0,filesAffected:0,dirsAffected:0,message:`Version displayed`}}};const Pn=`tnmsc`,Fn=`
957
+ `};const Kt=Object.fromEntries(Wt.map(e=>[e,{path:e,content:Gt[e]??``}])),qt={USER_HOME:`~`,WORKSPACE:`$WORKSPACE`,SHADOW_SOURCE_PROJECT:`$SHADOW_SOURCE_PROJECT`},Jt=JSON.parse(Kt[`public/tnmsc.example.json`].content),Yt={reset:`\x1B[0m`,red:`\x1B[31m`,yellow:`\x1B[33m`,cyan:`\x1B[36m`,magenta:`\x1B[35m`,gray:`\x1B[90m`,blue:`\x1B[34m`,green:`\x1B[32m`,white:`\x1B[37m`,dim:`\x1B[2m`,bgRed:`\x1B[41m`},Xt={red:e=>`${Yt.red}${e}${Yt.reset}`,yellow:e=>`${Yt.yellow}${e}${Yt.reset}`,cyan:e=>`${Yt.cyan}${e}${Yt.reset}`,magenta:e=>`${Yt.magenta}${e}${Yt.reset}`,gray:e=>`${Yt.gray}${e}${Yt.reset}`,blue:e=>`${Yt.blue}${e}${Yt.reset}`,green:e=>`${Yt.green}${e}${Yt.reset}`,white:e=>`${Yt.white}${e}${Yt.reset}`,dim:e=>`${Yt.dim}${e}${Yt.reset}`,bgRed:e=>`${Yt.bgRed}${e}${Yt.reset}`};let Zt;const Qt={error:Xt.red,warn:Xt.yellow,info:Xt.cyan,debug:Xt.magenta,trace:Xt.gray,fatal:Xt.bgRed},$t={silent:0,fatal:1,error:2,warn:3,info:4,debug:5,trace:6};function en(e){if(e===null)return Xt.dim(`null`);if(e===void 0)return Xt.dim(`undefined`);if(typeof e==`boolean`)return Xt.yellow(String(e));if(typeof e==`number`)return Xt.blue(String(e));if(typeof e==`string`)return Xt.green(`"${e}"`);if(Array.isArray(e))return e.length===0?`[]`:`[${e.map(e=>en(e)).join(`,`)}]`;if(e instanceof Error){let t={name:e.name,message:e.message,stack:e.stack};for(let n of Object.getOwnPropertyNames(e))n!==`name`&&n!==`message`&&n!==`stack`&&(t[n]=e[n]);return tn(t)}return typeof e==`object`?tn(e):String(e)}function tn(e){let t=Object.entries(e);return t.length===0?`{}`:`{${t.map(([e,t])=>`${/^[\w$]+$/.test(e)?Xt.magenta(e):Xt.yellow(`"${e}"`)}:${en(t)}`).join(`,`)}}`}function nn(){let e=new Date;return`${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}.${String(e.getMilliseconds()).padStart(3,`0`)}`}function rn(e,t,n,r){let i=nn(),a=Qt[e]??Xt.white,o=String(n),s=r!=null&&Object.keys(r).length>0,c=o===``,l={$:[i,e,t],_:s?c?r:{[o]:r}:n},u={$:[i,a(e.toUpperCase()),t]},d=s?c?r:{[o]:r}:n,f=tn({...u,_:d});return e===`error`||e===`fatal`?console.error(f):e===`warn`?console.warn(f):e===`debug`||e===`trace`?console.debug(f):console.log(f),l}function an(e,t,n){let r=$t[e],i=$t[n];return(n,...a)=>r>i?{$:[nn(),e,t],_:n}:typeof n==`string`?rn(e,t,n,a.length===1&&typeof a[0]==`object`&&a[0]!==null?a[0]:a.length>0?{args:a}:void 0):typeof n==`object`&&n?rn(e,t,``,n):rn(e,t,n)}function on(e){Zt=e}function sn(){return Zt}function cn(e,t){let n=t??Zt??process.env.LOG_LEVEL??`info`;return{error:an(`error`,e,n),warn:an(`warn`,e,n),info:an(`info`,e,n),debug:an(`debug`,e,n),trace:an(`trace`,e,n),fatal:an(`fatal`,e,n)}}const ln=`.tnmsc.json`,un=`.aindex`;function dn(){return i.join(s.homedir(),un,ln)}function fn(){return{...Jt}}function pn(e,t){let n=dn(),a=i.dirname(n);r.existsSync(a)||r.mkdirSync(a,{recursive:!0}),r.writeFileSync(n,`${JSON.stringify(e,null,2)}\n`,`utf8`),t.info(`global config created`,{path:n})}var mn=class{configFileName;searchCwd;searchGlobal;customSearchPaths;logger;constructor(e={}){this.configFileName=e.configFileName??ln,this.searchCwd=e.searchCwd??!0,this.searchGlobal=e.searchGlobal??!0,this.customSearchPaths=e.searchPaths??[],this.logger=cn(`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(s.homedir(),un,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,`utf8`),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`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`])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`)}if(`profile`in e){let t=e.profile;typeof t==`object`&&t&&!Array.isArray(t)?n.profile=t:r.push(`profile must be an object`)}if(`tool`in e){let t=e.tool;if(typeof t==`object`&&t&&!Array.isArray(t)){let e=t,i={},a=!0;for(let[t,n]of Object.entries(e))typeof n==`string`||n===void 0?i[t]=n:(r.push(`tool.${t} must be a string`),a=!1);a&&(n.tool=i)}else r.push(`tool 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(s.homedir(),e.slice(1)):e}};let hn=null;function gn(e){return(e||!hn)&&(hn=new mn(e)),hn}function _n(e){return gn().load(e)}function vn(){let e=cn(`ConfigLoader`),t=dn();if(!r.existsSync(t))return e.warn(`global config not found, creating default config`,{path:t}),pn(fn(),e),{valid:!0,exists:!1,errors:[],shouldExit:!1};let n;try{n=r.readFileSync(t,`utf8`)}catch(n){let r=n instanceof Error?n.message:String(n);return e.error(`failed to read global config`,{path:t,error:r}),bn(t,e,[`Failed to read config: ${r}`])}let i;try{i=JSON.parse(n)}catch(n){let r=n instanceof Error?n.message:String(n);return e.error(`invalid JSON in global config`,{path:t,error:r}),bn(t,e,[`Invalid JSON: ${r}`])}if(typeof i!=`object`||!i||Array.isArray(i))return e.error(`global config must be a JSON object`,{path:t}),bn(t,e,[`Config must be a JSON object`]);let a=yn(i);if(a.length>0){for(let n of a)e.error(`config validation error`,{path:t,error:n});return bn(t,e,a)}return{valid:!0,exists:!0,errors:[],shouldExit:!1}}function yn(e){let t=[];for(let n of[`workspaceDir`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`])n in e&&typeof e[n]!=`string`&&t.push(`${n} must be a string`);if(`logLevel`in e){let n=[`trace`,`debug`,`info`,`warn`,`error`],r=e.logLevel;(typeof r!=`string`||!n.includes(r))&&t.push(`logLevel must be one of: ${n.join(`, `)}`)}if(`externalProjects`in e){let n=e.externalProjects;Array.isArray(n)?n.every(e=>typeof e==`string`)||t.push(`externalProjects must be an array of strings`):t.push(`externalProjects must be an array`)}if(`excludePatterns`in e){let n=e.excludePatterns;if(typeof n!=`object`||!n||Array.isArray(n))t.push(`excludePatterns must be an object`);else{let e=n;for(let[n,r]of Object.entries(e))(!Array.isArray(r)||!r.every(e=>typeof e==`string`))&&t.push(`excludePatterns.${n} must be an array of strings`)}}if(`profile`in e){let n=e.profile;(typeof n!=`object`||!n||Array.isArray(n))&&t.push(`profile must be an object`)}if(!(`tool`in e))return t;let n=e.tool;if(typeof n!=`object`||!n||Array.isArray(n))t.push(`tool must be an object`);else{let e=n;for(let[n,r]of Object.entries(e))typeof r!=`string`&&r!==void 0&&t.push(`tool.${n} must be a string`)}return t}function bn(e,t,n){try{r.unlinkSync(e),t.info(`deleted invalid config`,{path:e})}catch{t.warn(`failed to delete invalid config`,{path:e})}return pn(fn(),t),t.error(`recreated default config, please review and restart`,{path:e}),{valid:!1,exists:!0,errors:n,shouldExit:!0}}const xn=[`workspaceDir`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`,`logLevel`];function Sn(e){return xn.includes(e)}function Cn(e){return[`trace`,`debug`,`info`,`warn`,`error`].includes(e)}function wn(){return i.join(s.homedir(),un,ln)}function Tn(){let e=wn();if(!r.existsSync(e))return{};try{let t=r.readFileSync(e,`utf8`);return JSON.parse(t)}catch{return{}}}function En(e){let t=wn(),n=i.dirname(t);r.existsSync(n)||r.mkdirSync(n,{recursive:!0}),r.writeFileSync(t,`${JSON.stringify(e,null,2)}\n`,`utf8`)}var Dn=class{name=`config`;constructor(e){this.options=e}async execute(e){let{logger:t}=e;if(this.options.length===0)return t.error(`No configuration key-value pairs provided`),t.info(`Usage: tnmsc config key=value`),t.info(`Valid keys: ${xn.join(`, `)}`),{success:!1,filesAffected:0,dirsAffected:0,message:`No options provided`};let n=Tn(),r=[],i=[];for(let[e,a]of this.options){if(!Sn(e)){r.push(`Invalid key: ${e} (valid keys: ${xn.join(`, `)})`);continue}if(e===`logLevel`&&!Cn(a)){r.push(`Invalid logLevel value: ${a} (must be: trace, debug, info, warn, or error)`);continue}let o=n[e];n[e]=a,o!==a&&i.push(`${e}=${a}`),t.info(`configuration updated`,{key:e,value:a})}if(i.length>0&&(En(n),t.info(`global config written`,{path:wn()})),r.length>0)for(let e of r)t.error(e);let a=r.length===0,o=a?`Configuration updated: ${i.join(`, `)}`:`Partial update: ${i.join(`, `)}. Errors: ${r.join(`, `)}`;return{success:a,filesAffected:i.length>0?1:0,dirsAffected:0,message:o}}},On=class{name=`config-show`;async execute(e){let{logger:t}=e,r=new mn,i=r.load(),a=i.sources.map(e=>{let t=r.loadFromFile(e);return{path:e,layer:this.inferLayer(e),config:t.config}}),o={merged:i.config,sources:a};return n.stdout.write(`${JSON.stringify(o)}\n`),t.info(`config shown`,{sources:i.sources.length}),{success:!0,filesAffected:0,dirsAffected:0,message:`Configuration displayed (${a.length} source(s))`}}inferLayer(e){let t=n.cwd();return e.startsWith(t)?`cwd`:`global`}},kn=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 gt(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{filesToDelete:o,dirsToDelete:s}=await xt(n,await _t(n,i),i);return this.logDryRunFiles(o,t),this.logDryRunDirectories(s,t),await vt(n,i),t.info(`clean complete`,{dryRun:!0,filesAffected:o.length,dirsAffected:s.length}),{success:!0,filesAffected:o.length,dirsAffected:s.length,message:`Dry-run complete, no files were deleted`}}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})}}},An=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 yt(n,i),o=await bt(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`}}},jn=class{name=`execute`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r,createWriteContext:i}=e;t.info(`started`,{command:`execute`});let a=await Ct(n,r(!1),t,{executeHooks:!1});t.info(`cleanup complete`,{deletedFiles:a.deletedFiles,deletedDirs:a.deletedDirs});let o=i(!1),s=await yt(n,o),c=await bt(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}}};function Mn(){return`2026.10213.0`}var Nn=class{name=`version`;async execute(e){return e.logger.error(`tnmsc v${Mn()}`),{success:!0,filesAffected:0,dirsAffected:0,message:`Version displayed`}}};const Pn=`tnmsc`,Fn=`
633
958
  ${Pn} v${Mn()} - Memory Sync CLI
634
959
 
635
960
  Synchronize AI memory and configuration files across projects.
@@ -683,7 +1008,7 @@ CONFIG OPTIONS:
683
1008
  CONFIGURATION:
684
1009
  Configure via plugin.config.ts in your project root.
685
1010
  See documentation for detailed configuration options.
686
- `.trim();var In=class{name=`help`;async execute(e){return console.log(Fn),{success:!0,filesAffected:0,dirsAffected:0,message:`Help displayed`}}};function Ln(e,t){let n=i.join(e,`.git`),a=r.existsSync(n);return a?t?.info(`version control detected`,{path:n}):t?.warn(`no version control detected, please use git to manage your shadow source project`,{path:e}),{hasGit:a,gitPath:n}}function Rn(e,t,n,a,o){if(n==null)return a;let s=i.relative(t,e),c=i.join(n,s);return r.existsSync(c)&&r.statSync(c).isFile()?(o?.debug(`copying from source`,{path:c}),r.readFileSync(c,`utf8`)):a}function zn(e,t={}){let{sourceDir:n,logger:a}=t,o=[],s=[],c=[],l=[],u=new Set;r.existsSync(e)?(c.push(e),a?.debug(`directory exists`,{path:e})):(r.mkdirSync(e,{recursive:!0}),o.push(e),u.add(e),a?.info(`created directory`,{path:e}));for(let t of Object.values(Kt)){let c=t.path,d=i.join(e,c),f=i.dirname(d);if(!r.existsSync(f)){r.mkdirSync(f,{recursive:!0});let t=f;for(;t!==e&&!u.has(t);)u.add(t),o.push(t),a?.info(`created directory`,{path:t}),t=i.dirname(t)}if(r.existsSync(d))l.push(d),a?.debug(`file exists`,{path:d});else{let i=Rn(d,e,n,t.content,a);r.writeFileSync(d,i,`utf8`),s.push(d),a?.info(`created file`,{path:d})}}return{success:!0,rootPath:e,createdDirs:o,createdFiles:s,existedDirs:c,existedFiles:l}}function Bn(e,t,n){let r=e;return r=r.replace(qt.SHADOW_SOURCE_PROJECT,n),r=r.replace(qt.WORKSPACE,t),r.startsWith(`~`)&&(r=i.join(s.homedir(),r.slice(1))),i.normalize(r)}var Vn=class{name=`init`;async execute(e){let{logger:t,userConfigOptions:n}=e;t.info(`initializing shadow source project structure`,{command:`init`});let r=Bn(n.workspaceDir,``,``),i=zn(Bn(n.shadowSourceProjectDir,r,``),{logger:t}),a=i.createdDirs.length===0&&i.createdFiles.length===0?`All ${i.existedDirs.length} directories and ${i.existedFiles.length} files already exist`:`Created ${i.createdDirs.length} directories and ${i.createdFiles.length} files (${i.existedDirs.length} dirs, ${i.existedFiles.length} files already existed)`;return t.info(`initialization complete`,{dirsCreated:i.createdDirs.length,filesCreated:i.createdFiles.length,dirsExisted:i.existedDirs.length,filesExisted:i.existedFiles.length}),{success:i.success,filesAffected:i.createdFiles.length,dirsAffected:i.createdDirs.length,message:a}}},Hn=class{name;inner;constructor(e){this.inner=e,this.name=`json:${e.name}`}async execute(e){let t=await this.inner.execute(e),r=Un(t);return n.stdout.write(`${JSON.stringify(r)}\n`),t}};function Un(e){return{success:e.success,filesAffected:e.filesAffected,dirsAffected:e.dirsAffected,...e.message!=null&&{message:e.message},pluginResults:[],errors:[]}}function Wn(){return`@truenine/memory-sync-cli`}function Gn(){return`https://registry.npmjs.org/${Wn()}/latest`}function Kn(e){let t=e.replace(/^v/,``),n=/^(\d+)\.(\d+)\.(\d+)/.exec(t);return n==null?null:[Number.parseInt(n[1],10),Number.parseInt(n[2],10),Number.parseInt(n[3],10)]}function qn(e,t){let n=Kn(e),r=Kn(t);if(n==null||r==null)return 0;for(let e=0;e<3;e++){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1}return 0}const Jn=3e3;async function Yn(){let e=new AbortController,t=setTimeout(()=>e.abort(),Jn);typeof t==`object`&&`unref`in t&&t.unref();try{let n=await fetch(Gn(),{headers:{Accept:`application/json`},signal:e.signal});if(clearTimeout(t),!n.ok)return{error:`HTTP ${n.status}: ${n.statusText}`};let r=await n.json();return r.version==null?{error:`Invalid response: missing version field`}:{version:r.version}}catch(e){return clearTimeout(t),e instanceof Error?e.name===`TimeoutError`||e.name===`AbortError`?{error:`Request timeout after ${Jn}ms`}:{error:e.message}:{error:`Unknown network error`}}}function Xn(){return`2026.10212.12107`}async function Zn(){let e=Xn();if(e===`dev`)return{status:`development`,localVersion:e,remoteVersion:null};let t=await Yn();if(`error`in t)return{status:`current`,localVersion:e,remoteVersion:null,error:t.error};let n=t.version,r=qn(e,n);return r<0?{status:`outdated`,localVersion:e,remoteVersion:n}:r>0?{status:`development`,localVersion:e,remoteVersion:n}:{status:`current`,localVersion:e,remoteVersion:n}}function Qn(e,t){let{status:n,localVersion:r,remoteVersion:i}=e;switch(n){case`outdated`:t.warn(`Version outdated: ${r} → ${i}. Run 'npm i -g ${Wn()}@latest' to update.`);break;case`current`:e.error==null?t.info(`Version ${r} is up to date.`):t.error(`Version check failed: ${e.error}`);break;case`development`:i==null?t.debug(`Running in development mode, version check skipped.`):t.info(`Development version detected: ${r} > ${i}. Thanks for contributing!`);break}}function $n(){return new Date().getMinutes()%2==0}function er(e){$n()&&Zn().then(t=>{(t.status===`outdated`||t.error!=null)&&Qn(t,e)}).catch(t=>{let n=t instanceof Error?t.message:`Unknown error`;e.error(`Version check failed: ${n}`)})}var tr=class{name=`outdated`;async execute(e){let t=await Zn();return Qn(t,e.logger),{success:!0,filesAffected:0,dirsAffected:0,message:`Version status: ${t.status}`}}},nr=class{name=`plugins`;async execute(e){let{logger:t,outputPlugins:r,userConfigOptions:i}=e,a=i.plugins,o=[];for(let e of a)o.push({name:e.name,kind:e.type===Tt.Input?`Input`:`Output`,description:e.name,dependencies:[...e.dependsOn??[]]});let s=new Set(o.map(e=>e.name));for(let e of r)s.has(e.name)||o.push({name:e.name,kind:`Output`,description:e.name,dependencies:[...e.dependsOn??[]]});return n.stdout.write(`${JSON.stringify(o)}\n`),t.info(`plugins listed`,{count:o.length}),{success:!0,filesAffected:0,dirsAffected:0,message:`Listed ${o.length} plugin(s)`}}},rr=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}}};const ir={default:{websearch:`web_search`,webfetch:`web_fetch`,readFile:`read_file`,writeFile:`write_file`,executeCommand:`execute_command`,todolistWrite:`todolist_write`,grep:`grep`,listDirectory:`list_directory`},claudeCode:{readFile:`Read`,writeFile:`Write`,executeCommand:`Execute`,todolistWrite:`TodoWrite`,listDirectory:`List`},kiro:{websearch:`remote_web_search`,webfetch:`webFetch`,readFile:`readFile`,writeFile:`fsWrite`,executeCommand:`executeBash`,todolistWrite:`todolistWrite`,grep:`grepSearch`,listDirectory:`listDir`}};let ar=function(e){return e.Bash=`bash`,e.Zsh=`zsh`,e.Fish=`fish`,e.Sh=`sh`,e.PowerShell=`powershell`,e.Pwsh=`pwsh`,e.Cmd=`cmd`,e.Unknown=`unknown`,e}({}),or=function(e){return e.Win=`win`,e.Mac=`mac`,e.Linux=`linux`,e.Unknown=`unknown`,e}({});var sr=class{userConfig;toolPreset;constructor(e={}){this.userConfig=e.userConfig,this.toolPreset=e.toolPreset??`default`}collect(){return{os:this.collectOsInfo(),env:this.collectEnvContext(),profile:this.collectProfile(),tool:this.collectToolReferences(),Md:this.createMdComponent()}}collectOsInfo(){let e=s.platform();return{platform:e,arch:s.arch(),hostname:s.hostname(),homedir:s.homedir(),tmpdir:s.tmpdir(),type:s.type(),release:s.release(),shellKind:this.detectShellKind(),kind:this.detectOsKind(e)}}detectOsKind(e){switch(e){case`win32`:return or.Win;case`darwin`:return or.Mac;case`linux`:case`freebsd`:case`openbsd`:case`sunos`:case`aix`:return or.Linux;default:return or.Unknown}}detectShellKind(){let e=(n.env.SHELL??n.env.ComSpec??``).toLowerCase();return e.includes(`bash`)?ar.Bash:e.includes(`zsh`)?ar.Zsh:e.includes(`fish`)?ar.Fish:e.includes(`pwsh`)?ar.Pwsh:e.includes(`powershell`)?ar.PowerShell:e.includes(`cmd`)?ar.Cmd:e.endsWith(`/sh`)?ar.Sh:ar.Unknown}collectEnvContext(){return{...n.env}}collectProfile(){return this.userConfig?.profile==null?{}:this.userConfig.profile}collectToolReferences(){let e={...ir.default};return this.toolPreset===`claudeCode`?{...e,...ir.claudeCode}:this.toolPreset===`kiro`?{...e,...ir.kiro}:e}createMdComponent(){let e=(e=>e.when===!1?null:e.children);return e.Line=e=>e.when===!1?null:e.children,e}};let cr=function(e){return e[e.SystemDefault=0]=`SystemDefault`,e[e.UserConfig=10]=`UserConfig`,e[e.PluginRegistered=20]=`PluginRegistered`,e[e.CompileTime=30]=`CompileTime`,e}({});var lr=class{registrations=[];globalScope=null;setGlobalScope(e){this.globalScope=e}getGlobalScope(){return this.globalScope}register(e,t,n=cr.PluginRegistered){this.registrations.push({namespace:e,values:t,priority:n})}getRegistrations(){return this.registrations}merge(e){let t={};this.globalScope!=null&&(t.os={...this.globalScope.os},t.env={...this.globalScope.env},t.profile={...this.globalScope.profile},t.tool={...this.globalScope.tool});let n=[...this.registrations].sort((e,t)=>e.priority-t.priority);for(let e of n)t[e.namespace]=this.deepMerge(t[e.namespace],e.values);if(e!=null)for(let[n,r]of Object.entries(e))t[n]=typeof r==`object`&&r&&!Array.isArray(r)?this.deepMerge(t[n],r):r;return t}deepMerge(e,t){if(e==null)return{...t};let n={...e};for(let[e,r]of Object.entries(t))n[e]=typeof r==`object`&&r&&!Array.isArray(r)&&typeof n[e]==`object`&&n[e]!==null&&!Array.isArray(n[e])?this.deepMerge(n[e],r):r;return n}clear(){this.registrations.length=0,this.globalScope=null}};function ur(e){let t=[...e],n=t[0];n!=null&&dr(n)&&t.shift();let r=t[0];return r!=null&&fr(r)&&t.shift(),t}function dr(e){let t=[`node`,`nodejs`,`bun`,`deno`,`tsx`,`ts-node`,`npx`,`pnpx`,`yarn`,`pnpm`],n=e.toLowerCase().replaceAll(`\\`,`/`);return t.some(e=>RegExp(`(?:^|/)${e}(?:\\.exe|\\.cmd|\\.ps1)?$`,`i`).test(n)||n===e)}function fr(e){return/\.(?:m?[jt]s|cjs)$/.test(e)||/[/\\]/.test(e)&&!e.startsWith(`-`)?!0:/^(?:@[\w-]+\/)?[\w-]+$/.test(e)&&!e.startsWith(`-`)}const pr=new Set([`help`,`version`,`outdated`,`init`,`dry-run`,`clean`,`config`,`plugins`]),mr=new Map([[`--trace`,`trace`],[`--debug`,`debug`],[`--info`,`info`],[`--warn`,`warn`],[`--error`,`error`]]),hr=new Map([[`trace`,0],[`debug`,1],[`info`,2],[`warn`,3],[`error`,4]]);function gr(e){let{logLevelFlags:t}=e;if(t.length===0)return;let n=t[0],r=hr.get(n)??4;for(let e of t){let t=hr.get(e)??4;t<r&&(r=t,n=e)}return n}function _r(e){let{helpFlag:t,versionFlag:n,subcommand:r,dryRun:i,unknownCommand:a,setOption:o,positional:s,showFlag:c}=e;if(n)return new Nn;if(t)return new In;if(a!=null)return new rr(a);if(r===`version`)return new Nn;if(r===`help`)return new In;if(r===`outdated`)return new tr;if(r===`init`)return new Vn;if(r===`dry-run`)return new An;if(r===`clean`)return i?new kn:new wt;if(r===`plugins`)return new nr;if(r===`config`&&c)return new On;if(r!==`config`||o.length>0)return new jn;let l=[];for(let e of s){let t=e.indexOf(`=`);t>0&&l.push([e.slice(0,t),e.slice(t+1)])}return new Dn([...o,...l])}function vr(e){let t={subcommand:void 0,helpFlag:!1,versionFlag:!1,dryRun:!1,jsonFlag:!1,showFlag:!1,logLevel:void 0,logLevelFlags:[],setOption:[],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 n=i.split(`=`),a=n[0]??``,o=mr.get(a);if(o!=null){t.logLevelFlags.push(o),t.logLevel=o;continue}switch(a){case`--help`:t.helpFlag=!0;break;case`--version`:t.versionFlag=!0;break;case`--dry-run`:t.dryRun=!0;break;case`--json`:t.jsonFlag=!0;break;case`--show`:t.showFlag=!0;break;case`--set`:if(n.length>1){let e=n.slice(1).join(`=`),r=e.indexOf(`=`);r>0&&t.setOption.push([e.slice(0,r),e.slice(r+1)])}else{let n=e[r+1];if(n!=null){let e=n.indexOf(`=`);e>0&&(t.setOption.push([n.slice(0,e),n.slice(e+1)]),r++)}}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`v`:t.versionFlag=!0;break;case`n`:t.dryRun=!0;break;case`j`:t.jsonFlag=!0;break;default:t.unknown.push(`-${n}`)}continue}if(!n){n=!0,pr.has(i)?t.subcommand=i:t.unknownCommand=i;continue}t.positional.push(i)}}return t}var yr=class{logger;args;outputPlugins=[];constructor(...e){this.args=vr(ur(e.filter(e=>e!=null)));let t=gr(this.args);t!=null&&on(t),this.logger=cn(`PluginPipeline`,t),this.logger.debug(`initialized`,{args:this.args})}registerOutputPlugins(e){return this.outputPlugins.push(...e),this}async run(e){er(this.logger);let{context:t,outputPlugins:n,userConfigOptions:r}=e;this.registerOutputPlugins([...n]);let i=this.resolveCommand();this.args.jsonFlag&&(on(`silent`),new Set([`config-show`,`plugins`]).has(i.name)||(i=new Hn(i)));let a=this.createCommandContext(t,r);await i.execute(a)}resolveCommand(){return _r(this.args)}createCommandContext(e,t){return{logger:this.logger,outputPlugins:this.outputPlugins,collectedInputContext:e,userConfigOptions:t,createCleanContext:t=>this.createCleanContext(e,t),createWriteContext:t=>this.createWriteContext(e,t)}}createCleanContext(e,t){return{logger:this.logger,fs:r,path:i,glob:et.default,collectedInputContext:e,dryRun:t}}createWriteContext(e,t){return{logger:this.logger,fs:r,path:i,glob:et.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 Mt(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)return a;throw new jt(this.findCyclePath(e,n))}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.at(-1));return a.slice(e)}i.clear(),a.length=0}return[...n]}async executePluginsInOrder(e,t,n=!1,r){if(e.length===0)return{};let i=this.topologicalSort(e),a=new sr({userConfig:r}).collect(),o=new lr;o.setGlobalScope(a),this.logger.debug(`global scope collected`,{osInfo:{platform:a.os.platform,arch:a.os.arch,shellKind:a.os.shellKind},hasProfile:Object.keys(a.profile).length>0,hasTool:Object.keys(a.tool).length>0});let s=new Map,c={};for(let e of i){let r=this.buildDependencyContext(e,s),i={...t,dependencyContext:r,globalScope:a,scopeRegistry:o},l=e;l.executeEffects!=null&&await l.executeEffects(i,n);let u=await e.collect(i);s.set(e.name,u),c=this.mergeContexts(c,u);let d=e;if(d.getRegisteredScopes!=null){let t=d.getRegisteredScopes();for(let{namespace:n,values:r}of t)o.register(n,r,cr.PluginRegistered),this.logger.debug(`plugin scope registered`,{plugin:e.name,namespace:n,keys:Object.keys(r)})}}return c}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{workspace:n}=e;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:[...e.values()]}}else ({workspace:n}=t);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.shadowSourceProjectDir??e.shadowSourceProjectDir,d=t.readmePrompts==null?e.readmePrompts:[...e.readmePrompts??[],...t.readmePrompts],f=t.globalGitIgnore??e.globalGitIgnore,p=t.shadowGitExclude??e.shadowGitExclude;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?{}:{shadowSourceProjectDir:u},...d==null?{}:{readmePrompts:d},...f==null?{}:{globalGitIgnore:f},...p==null?{}:{shadowGitExclude:p}}}};const br={...Jt,externalProjects:[],excludePatterns:{},fastCommandSeriesOptions:{},plugins:[]};function xr(e){return{...e.workspaceDir==null?{}:{workspaceDir:e.workspaceDir},...e.shadowSourceProjectDir==null?{}:{shadowSourceProjectDir:e.shadowSourceProjectDir},...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.shadowProjectsDir==null?{}:{shadowProjectsDir:e.shadowProjectsDir},...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 Sr(...e){return e.reduce((e,t)=>Cr(e,t),{...br})}function Cr(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:wr(e.excludePatterns,i),fastCommandSeriesOptions:Tr(e.fastCommandSeriesOptions,a)}}function wr(e,t){let n={...e};if(t)for(let[e,r]of Object.entries(t))n[e]=[...n[e]??[],...r];return n}function Tr(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 Er(e){return`pluginOptions`in e||`configLoaderOptions`in e||`loadUserConfig`in e}async function Dr(e={}){vn().shouldExit&&n.exit(1);let t,a,o;Er(e)?({pluginOptions:o={},cwd:a}={pluginOptions:e.pluginOptions,cwd:e.cwd},t=e.loadUserConfig??!0):(o=e,t=!0);let s={},c=!1,l=[],u;if(t){let e=_n(a);c=e.found,l=e.sources,e.found&&(s=xr(e.config),u=e.config)}let d=Sr(s,o),{plugins:f=[],logLevel:p}=d,m=cn(`defineConfig`,p);c?m.info(`user config loaded`,{sources:l}):m.info(`no user config found, using defaults`,{workspaceDir:br.workspaceDir,shadowSourceProjectDir:br.shadowSourceProjectDir,shadowSkillSourceDir:br.shadowSkillSourceDir,shadowFastCommandDir:br.shadowFastCommandDir,shadowSubAgentDir:br.shadowSubAgentDir,globalMemoryFile:br.globalMemoryFile,shadowProjectsDir:br.shadowProjectsDir,logLevel:br.logLevel});let h={logger:m,userConfigOptions:d,fs:r,path:i,glob:et.default},g=f.filter(e=>e.type===Tt.Input),_=f.filter(e=>e.type===Tt.Output),v=await new yr().executePluginsInOrder(g,h,!1,u);if(v.workspace==null)throw Error(`Workspace not initialized by any plugin`);let y={workspace:v.workspace,ideConfigFiles:v.ideConfigFiles??[],...v.externalProjects!=null&&{externalProjects:v.externalProjects},...v.fastCommands!=null&&{fastCommands:v.fastCommands},...v.subAgents!=null&&{subAgents:v.subAgents},...v.skills!=null&&{skills:v.skills},...v.globalMemory!=null&&{globalMemory:v.globalMemory},...v.aiAgentIgnoreConfigFiles!=null&&{aiAgentIgnoreConfigFiles:v.aiAgentIgnoreConfigFiles},...v.shadowSourceProjectDir!=null&&{shadowSourceProjectDir:v.shadowSourceProjectDir},...v.readmePrompts!=null&&{readmePrompts:v.readmePrompts},...v.globalGitIgnore!=null&&{globalGitIgnore:v.globalGitIgnore},...v.shadowGitExclude!=null&&{shadowGitExclude:v.shadowGitExclude}};return v.shadowSourceProjectDir!=null&&Ln(v.shadowSourceProjectDir,m),{context:y,outputPlugins:_,userConfigOptions:d}}const Or=Lr(/[A-Za-z]/),kr=Lr(/[\dA-Za-z]/),Ar=Lr(/[#-'*+\--9=?A-Z^-~]/);function jr(e){return e!==null&&(e<32||e===127)}const Mr=Lr(/\d/),Nr=Lr(/[\dA-Fa-f]/),Pr=Lr(/[!-/:-@[-`{-~]/);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 Fr=Lr(/\p{P}|\p{S}/u),Ir=Lr(/\s/);function Lr(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}var Rr=S(y(((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 zr=Object.assign(Br(Error),{eval:Br(EvalError),range:Br(RangeError),reference:Br(ReferenceError),syntax:Br(SyntaxError),type:Br(TypeError),uri:Br(URIError)});function Br(e){return t.displayName=e.displayName||e.name,t;function t(t,...n){return new e(t&&(0,Rr.default)(t,...n))}}const Vr={}.hasOwnProperty,Hr={yaml:`-`,toml:`+`};function Ur(e){let t=[],n=-1,r=Array.isArray(e)?e:e?[e]:[`yaml`];for(;++n<r.length;)t[n]=Wr(r[n]);return t}function Wr(e){let t=e;if(typeof t==`string`){if(!Vr.call(Hr,t))throw zr("Missing matter definition for `%s`",t);t={type:t,marker:Hr[t]}}else if(typeof t!=`object`)throw zr("Expected matter to be an object, not `%j`",t);if(!Vr.call(t,`type`))throw zr("Missing `type` in matter `%j`",t);if(!Vr.call(t,`fence`)&&!Vr.call(t,`marker`))throw zr("Missing `marker` or `fence` in matter `%j`",t);return t}function Gr(e){let t=Ur(e),n={},r=-1;for(;++r<t.length;){let e=t[r],i=qr(e,`open`).charCodeAt(0),a=Kr(e),o=n[i];Array.isArray(o)?o.push(a):n[i]=[a]}return{flow:n}}function Kr(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=qr(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=qr(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 qr(e,t){return e.marker?Jr(e.marker,t).repeat(3):Jr(e.fence,t)}function Jr(e,t){return typeof e==`string`?e:e[t]}function Yr(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function Xr(e){let t=Ur(e),n={},r={},i=-1;for(;++i<t.length;){let e=t[i];n[e.type]=Zr(e),r[e.type]=Qr,r[e.type+`Value`]=$r}return{enter:n,exit:r}}function Zr(e){return t;function t(t){this.enter({type:e.type,value:``},t),this.buffer()}}function Qr(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 $r(e){this.config.enter.data.call(this,e),this.config.exit.data.call(this,e)}function ei(e){let t=[],n={},r=Ur(e),i=-1;for(;++i<r.length;){let e=r[i];n[e.type]=ti(e);let a=ni(e,`open`);t.push({atBreak:!0,character:a.charAt(0),after:Yr(a.charAt(1))})}return{unsafe:t,handlers:n}}function ti(e){let t=ni(e,`open`),n=ni(e,`close`);return r;function r(e){return t+(e.value?`
1011
+ `.trim();var In=class{name=`help`;async execute(e){return console.log(Fn),{success:!0,filesAffected:0,dirsAffected:0,message:`Help displayed`}}};function Ln(e,t){let n=i.join(e,`.git`),a=r.existsSync(n);return a?t?.info(`version control detected`,{path:n}):t?.warn(`no version control detected, please use git to manage your shadow source project`,{path:e}),{hasGit:a,gitPath:n}}function Rn(e,t,n,a,o){if(n==null)return a;let s=i.relative(t,e),c=i.join(n,s);return r.existsSync(c)&&r.statSync(c).isFile()?(o?.debug(`copying from source`,{path:c}),r.readFileSync(c,`utf8`)):a}function zn(e,t={}){let{sourceDir:n,logger:a}=t,o=[],s=[],c=[],l=[],u=new Set;r.existsSync(e)?(c.push(e),a?.debug(`directory exists`,{path:e})):(r.mkdirSync(e,{recursive:!0}),o.push(e),u.add(e),a?.info(`created directory`,{path:e}));for(let t of Object.values(Kt)){let c=t.path,d=i.join(e,c),f=i.dirname(d);if(!r.existsSync(f)){r.mkdirSync(f,{recursive:!0});let t=f;for(;t!==e&&!u.has(t);)u.add(t),o.push(t),a?.info(`created directory`,{path:t}),t=i.dirname(t)}if(r.existsSync(d))l.push(d),a?.debug(`file exists`,{path:d});else{let i=Rn(d,e,n,t.content,a);r.writeFileSync(d,i,`utf8`),s.push(d),a?.info(`created file`,{path:d})}}return{success:!0,rootPath:e,createdDirs:o,createdFiles:s,existedDirs:c,existedFiles:l}}function Bn(e,t,n){let r=e;return r=r.replace(qt.SHADOW_SOURCE_PROJECT,n),r=r.replace(qt.WORKSPACE,t),r.startsWith(`~`)&&(r=i.join(s.homedir(),r.slice(1))),i.normalize(r)}var Vn=class{name=`init`;async execute(e){let{logger:t,userConfigOptions:n}=e;t.info(`initializing shadow source project structure`,{command:`init`});let r=Bn(n.workspaceDir,``,``),i=zn(Bn(n.shadowSourceProjectDir,r,``),{logger:t}),a=i.createdDirs.length===0&&i.createdFiles.length===0?`All ${i.existedDirs.length} directories and ${i.existedFiles.length} files already exist`:`Created ${i.createdDirs.length} directories and ${i.createdFiles.length} files (${i.existedDirs.length} dirs, ${i.existedFiles.length} files already existed)`;return t.info(`initialization complete`,{dirsCreated:i.createdDirs.length,filesCreated:i.createdFiles.length,dirsExisted:i.existedDirs.length,filesExisted:i.existedFiles.length}),{success:i.success,filesAffected:i.createdFiles.length,dirsAffected:i.createdDirs.length,message:a}}},Hn=class{name;inner;constructor(e){this.inner=e,this.name=`json:${e.name}`}async execute(e){let t=await this.inner.execute(e),r=Un(t);return n.stdout.write(`${JSON.stringify(r)}\n`),t}};function Un(e){return{success:e.success,filesAffected:e.filesAffected,dirsAffected:e.dirsAffected,...e.message!=null&&{message:e.message},pluginResults:[],errors:[]}}function Wn(){return`@truenine/memory-sync-cli`}function Gn(){return`https://registry.npmjs.org/${Wn()}/latest`}function Kn(e){let t=e.replace(/^v/,``),n=/^(\d+)\.(\d+)\.(\d+)/.exec(t);return n==null?null:[Number.parseInt(n[1],10),Number.parseInt(n[2],10),Number.parseInt(n[3],10)]}function qn(e,t){let n=Kn(e),r=Kn(t);if(n==null||r==null)return 0;for(let e=0;e<3;e++){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1}return 0}const Jn=3e3;async function Yn(){let e=new AbortController,t=setTimeout(()=>e.abort(),Jn);typeof t==`object`&&`unref`in t&&t.unref();try{let n=await fetch(Gn(),{headers:{Accept:`application/json`},signal:e.signal});if(clearTimeout(t),!n.ok)return{error:`HTTP ${n.status}: ${n.statusText}`};let r=await n.json();return r.version==null?{error:`Invalid response: missing version field`}:{version:r.version}}catch(e){return clearTimeout(t),e instanceof Error?e.name===`TimeoutError`||e.name===`AbortError`?{error:`Request timeout after ${Jn}ms`}:{error:e.message}:{error:`Unknown network error`}}}function Xn(){return`2026.10213.0`}async function Zn(){let e=Xn();if(e===`dev`)return{status:`development`,localVersion:e,remoteVersion:null};let t=await Yn();if(`error`in t)return{status:`current`,localVersion:e,remoteVersion:null,error:t.error};let n=t.version,r=qn(e,n);return r<0?{status:`outdated`,localVersion:e,remoteVersion:n}:r>0?{status:`development`,localVersion:e,remoteVersion:n}:{status:`current`,localVersion:e,remoteVersion:n}}function Qn(e,t){let{status:n,localVersion:r,remoteVersion:i}=e;switch(n){case`outdated`:t.warn(`Version outdated: ${r} → ${i}. Run 'npm i -g ${Wn()}@latest' to update.`);break;case`current`:e.error==null?t.info(`Version ${r} is up to date.`):t.error(`Version check failed: ${e.error}`);break;case`development`:i==null?t.debug(`Running in development mode, version check skipped.`):t.info(`Development version detected: ${r} > ${i}. Thanks for contributing!`);break}}function $n(){return new Date().getMinutes()%2==0}function er(e){$n()&&Zn().then(t=>{(t.status===`outdated`||t.error!=null)&&Qn(t,e)}).catch(t=>{let n=t instanceof Error?t.message:`Unknown error`;e.error(`Version check failed: ${n}`)})}var tr=class{name=`outdated`;async execute(e){let t=await Zn();return Qn(t,e.logger),{success:!0,filesAffected:0,dirsAffected:0,message:`Version status: ${t.status}`}}},nr=class{name=`plugins`;async execute(e){let{logger:t,outputPlugins:r,userConfigOptions:i}=e,a=i.plugins,o=[];for(let e of a)o.push({name:e.name,kind:e.type===Tt.Input?`Input`:`Output`,description:e.name,dependencies:[...e.dependsOn??[]]});let s=new Set(o.map(e=>e.name));for(let e of r)s.has(e.name)||o.push({name:e.name,kind:`Output`,description:e.name,dependencies:[...e.dependsOn??[]]});return n.stdout.write(`${JSON.stringify(o)}\n`),t.info(`plugins listed`,{count:o.length}),{success:!0,filesAffected:0,dirsAffected:0,message:`Listed ${o.length} plugin(s)`}}},rr=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}}};const ir={default:{websearch:`web_search`,webfetch:`web_fetch`,readFile:`read_file`,writeFile:`write_file`,executeCommand:`execute_command`,todolistWrite:`todolist_write`,grep:`grep`,listDirectory:`list_directory`},claudeCode:{readFile:`Read`,writeFile:`Write`,executeCommand:`Execute`,todolistWrite:`TodoWrite`,listDirectory:`List`},kiro:{websearch:`remote_web_search`,webfetch:`webFetch`,readFile:`readFile`,writeFile:`fsWrite`,executeCommand:`executeBash`,todolistWrite:`todolistWrite`,grep:`grepSearch`,listDirectory:`listDir`}};let ar=function(e){return e.Bash=`bash`,e.Zsh=`zsh`,e.Fish=`fish`,e.Sh=`sh`,e.PowerShell=`powershell`,e.Pwsh=`pwsh`,e.Cmd=`cmd`,e.Unknown=`unknown`,e}({}),or=function(e){return e.Win=`win`,e.Mac=`mac`,e.Linux=`linux`,e.Unknown=`unknown`,e}({});var sr=class{userConfig;toolPreset;constructor(e={}){this.userConfig=e.userConfig,this.toolPreset=e.toolPreset??`default`}collect(){return{os:this.collectOsInfo(),env:this.collectEnvContext(),profile:this.collectProfile(),tool:this.collectToolReferences(),Md:this.createMdComponent()}}collectOsInfo(){let e=s.platform();return{platform:e,arch:s.arch(),hostname:s.hostname(),homedir:s.homedir(),tmpdir:s.tmpdir(),type:s.type(),release:s.release(),shellKind:this.detectShellKind(),kind:this.detectOsKind(e)}}detectOsKind(e){switch(e){case`win32`:return or.Win;case`darwin`:return or.Mac;case`linux`:case`freebsd`:case`openbsd`:case`sunos`:case`aix`:return or.Linux;default:return or.Unknown}}detectShellKind(){let e=(n.env.SHELL??n.env.ComSpec??``).toLowerCase();return e.includes(`bash`)?ar.Bash:e.includes(`zsh`)?ar.Zsh:e.includes(`fish`)?ar.Fish:e.includes(`pwsh`)?ar.Pwsh:e.includes(`powershell`)?ar.PowerShell:e.includes(`cmd`)?ar.Cmd:e.endsWith(`/sh`)?ar.Sh:ar.Unknown}collectEnvContext(){return{...n.env}}collectProfile(){return this.userConfig?.profile==null?{}:this.userConfig.profile}collectToolReferences(){let e={...ir.default};return this.toolPreset===`claudeCode`?{...e,...ir.claudeCode}:this.toolPreset===`kiro`?{...e,...ir.kiro}:e}createMdComponent(){let e=(e=>e.when===!1?null:e.children);return e.Line=e=>e.when===!1?null:e.children,e}};let cr=function(e){return e[e.SystemDefault=0]=`SystemDefault`,e[e.UserConfig=10]=`UserConfig`,e[e.PluginRegistered=20]=`PluginRegistered`,e[e.CompileTime=30]=`CompileTime`,e}({});var lr=class{registrations=[];globalScope=null;setGlobalScope(e){this.globalScope=e}getGlobalScope(){return this.globalScope}register(e,t,n=cr.PluginRegistered){this.registrations.push({namespace:e,values:t,priority:n})}getRegistrations(){return this.registrations}merge(e){let t={};this.globalScope!=null&&(t.os={...this.globalScope.os},t.env={...this.globalScope.env},t.profile={...this.globalScope.profile},t.tool={...this.globalScope.tool});let n=[...this.registrations].sort((e,t)=>e.priority-t.priority);for(let e of n)t[e.namespace]=this.deepMerge(t[e.namespace],e.values);if(e!=null)for(let[n,r]of Object.entries(e))t[n]=typeof r==`object`&&r&&!Array.isArray(r)?this.deepMerge(t[n],r):r;return t}deepMerge(e,t){if(e==null)return{...t};let n={...e};for(let[e,r]of Object.entries(t))n[e]=typeof r==`object`&&r&&!Array.isArray(r)&&typeof n[e]==`object`&&n[e]!==null&&!Array.isArray(n[e])?this.deepMerge(n[e],r):r;return n}clear(){this.registrations.length=0,this.globalScope=null}};function ur(e){let t=[...e],n=t[0];n!=null&&dr(n)&&t.shift();let r=t[0];return r!=null&&fr(r)&&t.shift(),t}function dr(e){let t=[`node`,`nodejs`,`bun`,`deno`,`tsx`,`ts-node`,`npx`,`pnpx`,`yarn`,`pnpm`],n=e.toLowerCase().replaceAll(`\\`,`/`);return t.some(e=>RegExp(`(?:^|/)${e}(?:\\.exe|\\.cmd|\\.ps1)?$`,`i`).test(n)||n===e)}function fr(e){return/\.(?:m?[jt]s|cjs)$/.test(e)||/[/\\]/.test(e)&&!e.startsWith(`-`)?!0:/^(?:@[\w-]+\/)?[\w-]+$/.test(e)&&!e.startsWith(`-`)}const pr=new Set([`help`,`version`,`outdated`,`init`,`dry-run`,`clean`,`config`,`plugins`]),mr=new Map([[`--trace`,`trace`],[`--debug`,`debug`],[`--info`,`info`],[`--warn`,`warn`],[`--error`,`error`]]),hr=new Map([[`trace`,0],[`debug`,1],[`info`,2],[`warn`,3],[`error`,4]]);function gr(e){let{logLevelFlags:t}=e;if(t.length===0)return;let n=t[0],r=hr.get(n)??4;for(let e of t){let t=hr.get(e)??4;t<r&&(r=t,n=e)}return n}function _r(e){let{helpFlag:t,versionFlag:n,subcommand:r,dryRun:i,unknownCommand:a,setOption:o,positional:s,showFlag:c}=e;if(n)return new Nn;if(t)return new In;if(a!=null)return new rr(a);if(r===`version`)return new Nn;if(r===`help`)return new In;if(r===`outdated`)return new tr;if(r===`init`)return new Vn;if(r===`dry-run`)return new An;if(r===`clean`)return i?new kn:new wt;if(r===`plugins`)return new nr;if(r===`config`&&c)return new On;if(r!==`config`||o.length>0)return new jn;let l=[];for(let e of s){let t=e.indexOf(`=`);t>0&&l.push([e.slice(0,t),e.slice(t+1)])}return new Dn([...o,...l])}function vr(e){let t={subcommand:void 0,helpFlag:!1,versionFlag:!1,dryRun:!1,jsonFlag:!1,showFlag:!1,logLevel:void 0,logLevelFlags:[],setOption:[],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 n=i.split(`=`),a=n[0]??``,o=mr.get(a);if(o!=null){t.logLevelFlags.push(o),t.logLevel=o;continue}switch(a){case`--help`:t.helpFlag=!0;break;case`--version`:t.versionFlag=!0;break;case`--dry-run`:t.dryRun=!0;break;case`--json`:t.jsonFlag=!0;break;case`--show`:t.showFlag=!0;break;case`--set`:if(n.length>1){let e=n.slice(1).join(`=`),r=e.indexOf(`=`);r>0&&t.setOption.push([e.slice(0,r),e.slice(r+1)])}else{let n=e[r+1];if(n!=null){let e=n.indexOf(`=`);e>0&&(t.setOption.push([n.slice(0,e),n.slice(e+1)]),r++)}}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`v`:t.versionFlag=!0;break;case`n`:t.dryRun=!0;break;case`j`:t.jsonFlag=!0;break;default:t.unknown.push(`-${n}`)}continue}if(!n){n=!0,pr.has(i)?t.subcommand=i:t.unknownCommand=i;continue}t.positional.push(i)}}return t}var yr=class{logger;args;outputPlugins=[];constructor(...e){this.args=vr(ur(e.filter(e=>e!=null)));let t=gr(this.args);t!=null&&on(t),this.logger=cn(`PluginPipeline`,t),this.logger.debug(`initialized`,{args:this.args})}registerOutputPlugins(e){return this.outputPlugins.push(...e),this}async run(e){er(this.logger);let{context:t,outputPlugins:n,userConfigOptions:r}=e;this.registerOutputPlugins([...n]);let i=this.resolveCommand();this.args.jsonFlag&&(on(`silent`),new Set([`config-show`,`plugins`]).has(i.name)||(i=new Hn(i)));let a=this.createCommandContext(t,r);await i.execute(a)}resolveCommand(){return _r(this.args)}createCommandContext(e,t){return{logger:this.logger,outputPlugins:this.outputPlugins,collectedInputContext:e,userConfigOptions:t,createCleanContext:t=>this.createCleanContext(e,t),createWriteContext:t=>this.createWriteContext(e,t)}}createCleanContext(e,t){return{logger:this.logger,fs:r,path:i,glob:et.default,collectedInputContext:e,dryRun:t}}createWriteContext(e,t){return{logger:this.logger,fs:r,path:i,glob:et.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 Mt(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)return a;throw new jt(this.findCyclePath(e,n))}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.at(-1));return a.slice(e)}i.clear(),a.length=0}return[...n]}async executePluginsInOrder(e,t,n=!1,r){if(e.length===0)return{};let i=this.topologicalSort(e),a=new sr({userConfig:r}).collect(),o=new lr;o.setGlobalScope(a),this.logger.debug(`global scope collected`,{osInfo:{platform:a.os.platform,arch:a.os.arch,shellKind:a.os.shellKind},hasProfile:Object.keys(a.profile).length>0,hasTool:Object.keys(a.tool).length>0});let s=new Map,c={};for(let e of i){let r=this.buildDependencyContext(e,s),i={...t,dependencyContext:r,globalScope:a,scopeRegistry:o},l=e;l.executeEffects!=null&&await l.executeEffects(i,n);let u=await e.collect(i);s.set(e.name,u),c=this.mergeContexts(c,u);let d=e;if(d.getRegisteredScopes!=null){let t=d.getRegisteredScopes();for(let{namespace:n,values:r}of t)o.register(n,r,cr.PluginRegistered),this.logger.debug(`plugin scope registered`,{plugin:e.name,namespace:n,keys:Object.keys(r)})}}return c}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{workspace:n}=e;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:[...e.values()]}}else ({workspace:n}=t);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.shadowSourceProjectDir??e.shadowSourceProjectDir,d=t.readmePrompts==null?e.readmePrompts:[...e.readmePrompts??[],...t.readmePrompts],f=t.globalGitIgnore??e.globalGitIgnore,p=t.shadowGitExclude??e.shadowGitExclude;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?{}:{shadowSourceProjectDir:u},...d==null?{}:{readmePrompts:d},...f==null?{}:{globalGitIgnore:f},...p==null?{}:{shadowGitExclude:p}}}};const br={...Jt,externalProjects:[],excludePatterns:{},fastCommandSeriesOptions:{},plugins:[]};function xr(e){return{...e.workspaceDir==null?{}:{workspaceDir:e.workspaceDir},...e.shadowSourceProjectDir==null?{}:{shadowSourceProjectDir:e.shadowSourceProjectDir},...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.shadowProjectsDir==null?{}:{shadowProjectsDir:e.shadowProjectsDir},...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 Sr(...e){return e.reduce((e,t)=>Cr(e,t),{...br})}function Cr(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:wr(e.excludePatterns,i),fastCommandSeriesOptions:Tr(e.fastCommandSeriesOptions,a)}}function wr(e,t){let n={...e};if(t)for(let[e,r]of Object.entries(t))n[e]=[...n[e]??[],...r];return n}function Tr(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 Er(e){return`pluginOptions`in e||`configLoaderOptions`in e||`loadUserConfig`in e}async function Dr(e={}){vn().shouldExit&&n.exit(1);let t,a,o;Er(e)?({pluginOptions:o={},cwd:a}={pluginOptions:e.pluginOptions,cwd:e.cwd},t=e.loadUserConfig??!0):(o=e,t=!0);let s={},c=!1,l=[],u;if(t){let e=_n(a);c=e.found,l=e.sources,e.found&&(s=xr(e.config),u=e.config)}let d=Sr(s,o),{plugins:f=[],logLevel:p}=d,m=cn(`defineConfig`,p);c?m.info(`user config loaded`,{sources:l}):m.info(`no user config found, using defaults`,{workspaceDir:br.workspaceDir,shadowSourceProjectDir:br.shadowSourceProjectDir,shadowSkillSourceDir:br.shadowSkillSourceDir,shadowFastCommandDir:br.shadowFastCommandDir,shadowSubAgentDir:br.shadowSubAgentDir,globalMemoryFile:br.globalMemoryFile,shadowProjectsDir:br.shadowProjectsDir,logLevel:br.logLevel});let h={logger:m,userConfigOptions:d,fs:r,path:i,glob:et.default},g=f.filter(e=>e.type===Tt.Input),_=f.filter(e=>e.type===Tt.Output),v=await new yr().executePluginsInOrder(g,h,!1,u);if(v.workspace==null)throw Error(`Workspace not initialized by any plugin`);let y={workspace:v.workspace,ideConfigFiles:v.ideConfigFiles??[],...v.externalProjects!=null&&{externalProjects:v.externalProjects},...v.fastCommands!=null&&{fastCommands:v.fastCommands},...v.subAgents!=null&&{subAgents:v.subAgents},...v.skills!=null&&{skills:v.skills},...v.globalMemory!=null&&{globalMemory:v.globalMemory},...v.aiAgentIgnoreConfigFiles!=null&&{aiAgentIgnoreConfigFiles:v.aiAgentIgnoreConfigFiles},...v.shadowSourceProjectDir!=null&&{shadowSourceProjectDir:v.shadowSourceProjectDir},...v.readmePrompts!=null&&{readmePrompts:v.readmePrompts},...v.globalGitIgnore!=null&&{globalGitIgnore:v.globalGitIgnore},...v.shadowGitExclude!=null&&{shadowGitExclude:v.shadowGitExclude}};return v.shadowSourceProjectDir!=null&&Ln(v.shadowSourceProjectDir,m),{context:y,outputPlugins:_,userConfigOptions:d}}const Or=Lr(/[A-Za-z]/),kr=Lr(/[\dA-Za-z]/),Ar=Lr(/[#-'*+\--9=?A-Z^-~]/);function jr(e){return e!==null&&(e<32||e===127)}const Mr=Lr(/\d/),Nr=Lr(/[\dA-Fa-f]/),Pr=Lr(/[!-/:-@[-`{-~]/);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 Fr=Lr(/\p{P}|\p{S}/u),Ir=Lr(/\s/);function Lr(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}var Rr=S(y(((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 zr=Object.assign(Br(Error),{eval:Br(EvalError),range:Br(RangeError),reference:Br(ReferenceError),syntax:Br(SyntaxError),type:Br(TypeError),uri:Br(URIError)});function Br(e){return t.displayName=e.displayName||e.name,t;function t(t,...n){return new e(t&&(0,Rr.default)(t,...n))}}const Vr={}.hasOwnProperty,Hr={yaml:`-`,toml:`+`};function Ur(e){let t=[],n=-1,r=Array.isArray(e)?e:e?[e]:[`yaml`];for(;++n<r.length;)t[n]=Wr(r[n]);return t}function Wr(e){let t=e;if(typeof t==`string`){if(!Vr.call(Hr,t))throw zr("Missing matter definition for `%s`",t);t={type:t,marker:Hr[t]}}else if(typeof t!=`object`)throw zr("Expected matter to be an object, not `%j`",t);if(!Vr.call(t,`type`))throw zr("Missing `type` in matter `%j`",t);if(!Vr.call(t,`fence`)&&!Vr.call(t,`marker`))throw zr("Missing `marker` or `fence` in matter `%j`",t);return t}function Gr(e){let t=Ur(e),n={},r=-1;for(;++r<t.length;){let e=t[r],i=qr(e,`open`).charCodeAt(0),a=Kr(e),o=n[i];Array.isArray(o)?o.push(a):n[i]=[a]}return{flow:n}}function Kr(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=qr(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=qr(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 qr(e,t){return e.marker?Jr(e.marker,t).repeat(3):Jr(e.fence,t)}function Jr(e,t){return typeof e==`string`?e:e[t]}function Yr(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function Xr(e){let t=Ur(e),n={},r={},i=-1;for(;++i<t.length;){let e=t[i];n[e.type]=Zr(e),r[e.type]=Qr,r[e.type+`Value`]=$r}return{enter:n,exit:r}}function Zr(e){return t;function t(t){this.enter({type:e.type,value:``},t),this.buffer()}}function Qr(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 $r(e){this.config.enter.data.call(this,e),this.config.exit.data.call(this,e)}function ei(e){let t=[],n={},r=Ur(e),i=-1;for(;++i<r.length;){let e=r[i];n[e.type]=ti(e);let a=ni(e,`open`);t.push({atBreak:!0,character:a.charAt(0),after:Yr(a.charAt(1))})}return{unsafe:t,handlers:n}}function ti(e){let t=ni(e,`open`),n=ni(e,`close`);return r;function r(e){return t+(e.value?`
687
1012
  `+e.value:``)+`
688
1013
  `+n}}function ni(e,t){return e.marker?ri(e.marker,t).repeat(3):ri(e.fence,t)}function ri(e,t){return typeof e==`string`?e:e[t]}function ii(e){let t=this,n=e||`yaml`,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Gr(n)),a.push(Xr(n)),o.push(ei(n))}function ai(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 oi=(function(e){if(e==null)return di;if(typeof e==`function`)return ui(e);if(typeof e==`object`)return Array.isArray(e)?si(e):ci(e);if(typeof e==`string`)return li(e);throw Error(`Expected function, string, or object as test`)});function si(e){let t=[],n=-1;for(;++n<e.length;)t[n]=oi(e[n]);return ui(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function ci(e){let t=e;return ui(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function li(e){return ui(t);function t(t){return t&&t.type===e}}function ui(e){return t;function t(t,n,r){return!!(fi(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function di(){return!0}function fi(e){return typeof e==`object`&&!!e&&`type`in e}function pi(e){return`\x1B[33m`+e+`\x1B[39m`}const mi=[];function hi(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=oi(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 (`+pi(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=mi,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=gi(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 gi(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?mi:[e]}function _i(e,t,n){let r=oi((n||{}).ignore||[]),i=vi(t),a=-1;for(;++a<i.length;)hi(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 vi(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([yi(e[0]),bi(e[1])])}return t}function yi(e){return typeof e==`string`?new RegExp(Yr(e),`g`):e}function bi(e){return typeof e==`function`?e:function(){return e}}const xi=`phrasing`,Si=[`autolink`,`link`,`image`,`label`];function Ci(){return{transforms:[ji],enter:{literalAutolink:Ti,literalAutolinkEmail:Ei,literalAutolinkHttp:Ei,literalAutolinkWww:Ei},exit:{literalAutolink:Ai,literalAutolinkEmail:ki,literalAutolinkHttp:Di,literalAutolinkWww:Oi}}}function wi(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:xi,notInConstruct:Si},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:xi,notInConstruct:Si},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:xi,notInConstruct:Si}]}}function Ti(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function Ei(e){this.config.enter.autolinkProtocol.call(this,e)}function Di(e){this.config.exit.autolinkProtocol.call(this,e)}function Oi(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 ki(e){this.config.exit.autolinkEmail.call(this,e)}function Ai(e){this.exit(e)}function ji(e){_i(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Mi],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Ni]],{ignore:[`link`,`linkReference`]})}function Mi(e,t,n,r,i){let a=``;if(!Ii(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!Pi(n)))return!1;let o=Fi(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 Ni(e,t,n,r){return!Ii(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function Pi(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 Fi(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=ai(e,`(`),a=ai(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 Ii(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||Ir(n)||Fr(n))&&(!t||n!==47)}function Li(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}qi.peek=Ki;function Ri(){this.buffer()}function zi(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Bi(){this.buffer()}function Vi(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function Hi(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Li(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Ui(e){this.exit(e)}function Wi(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Li(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Gi(e){this.exit(e)}function Ki(){return`[`}function qi(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 Ji(){return{enter:{gfmFootnoteCallString:Ri,gfmFootnoteCall:zi,gfmFootnoteDefinitionLabelString:Bi,gfmFootnoteDefinition:Vi},exit:{gfmFootnoteCallString:Hi,gfmFootnoteCall:Ui,gfmFootnoteDefinitionLabelString:Wi,gfmFootnoteDefinition:Gi}}}function Yi(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:qi},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?`
689
1014
  `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?Zi:Xi))),s(),o}}function Xi(e,t,n){return t===0?e:Zi(e,t,n)}function Zi(e,t,n){return(n?``:` `)+e}const Qi=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];ra.peek=ia;function $i(){return{canContainEols:[`delete`],enter:{strikethrough:ta},exit:{strikethrough:na}}}function ea(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:Qi}],handlers:{delete:ra}}}function ta(e){this.enter({type:`delete`,children:[]},e)}function na(e){this.exit(e)}function ra(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 ia(){return`~`}function aa(e){return e.length}function oa(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||aa,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=sa(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]=ca(r[d]);else{let e=ca(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(`
@@ -869,11 +1194,11 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
869
1194
  `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),Dg=y((e=>{var t=yg(),n=ng(),r=rg(),i=Dh(),a=$(),o=Tg(),s=Eg();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),Og=S(y((e=>{var t=yg(),n=ng(),r=eg(),i=rg(),a=vh(),o=$(),s=Ah(),c=yh(),l=Mh(),u=Ph();Cg();var d=wg(),f=Tg(),p=Eg(),m=Dg(),h=fh();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=m.parse,e.parseAllDocuments=m.parseAllDocuments,e.parseDocument=m.parseDocument,e.stringify=m.stringify,e.visit=h.visit,e.visitAsync=h.visitAsync}))(),1);function kg(e,t){let n=Object.fromEntries(Object.entries(e).filter(([e,t])=>t!=null));return Object.keys(n).length===0?`---
870
1195
  ---`:`---\n${Og.stringify(n,{singleQuote:t?.singleQuote??!1,lineWidth:t?.lineWidth??0}).trimEnd()}\n---`}function Ag(e,t,n){return e==null||Object.keys(e).length===0?t:`${kg(e,n)}\n${t}`}function jg(e){let t=dh(e),n,r,i=[];for(let e of t.children)if(e.type===`yaml`){r=e.value;try{n=Og.parse(e.value??``)}catch{}}else i.push(e);let a=e;return r!=null&&(a=e.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,``)),{...n!=null&&{yamlFrontMatter:n},...r!=null&&{rawFrontMatter:r},markdownAst:t,markdownContents:i,contentWithoutFrontMatter:a}}function Mg(e){return e.replaceAll(/(!?\[)([^\]]*)(\]\()([^)]+)(\))/g,(e,t,n,r,i,a)=>{let o=n.replaceAll(/\.mdx$/g,`.md`).replaceAll(/\.mdx(?=#|\?|$)/g,`.md`);return/^(?:https?:)?\/\//.test(i)?`${t}${o}${r}${i}${a}`:`${t}${o}${r}${i.replace(/\.mdx$/,`.md`).replace(/\.mdx#/,`.md#`).replace(/\.mdx\?/,`.md?`)}${a}`})}var Ng=class{type;name;_log;get log(){return this._log??=cn(this.name),this._log}dependsOn;constructor(e,t,n){this.name=e,this.type=t,n!=null&&(this.dependsOn=n)}},Pg=class extends Ng{globalConfigDir;outputFileName;registryWriterCache=new Map;writeEffects=[];cleanEffects=[];constructor(e,t){super(e,Tt.Output,t?.dependsOn),this.globalConfigDir=t?.globalConfigDir??``,this.outputFileName=t?.outputFileName??``}registerWriteEffect(e,t){this.writeEffects.push({name:e,handler:t})}registerCleanEffect(e,t){this.cleanEffects.push({name:e,handler:t})}async executeWriteEffects(e){let t=[];for(let n of this.writeEffects){if(e.dryRun===!0){this.log.trace({action:`dryRun`,type:`effect`,name:n.name}),t.push({success:!0,description:`Would execute write effect: ${n.name}`});continue}try{let r=await n.handler(e);if(r.success)this.log.trace({action:`effect`,name:n.name,status:`success`});else{let e=r.error instanceof Error?r.error.message:String(r.error);this.log.error({action:`effect`,name:n.name,status:`failed`,error:e})}t.push(r)}catch(e){let r=e instanceof Error?e.message:String(e);this.log.error({action:`effect`,name:n.name,status:`failed`,error:r}),t.push({success:!1,error:e,description:`Write effect failed: ${n.name}`})}}return t}async executeCleanEffects(e){let t=[];for(let n of this.cleanEffects){if(e.dryRun===!0){this.log.trace({action:`dryRun`,type:`effect`,name:n.name}),t.push({success:!0,description:`Would execute clean effect: ${n.name}`});continue}try{let r=await n.handler(e);if(r.success)this.log.trace({action:`effect`,name:n.name,status:`success`});else{let e=r.error instanceof Error?r.error.message:String(r.error);this.log.error({action:`effect`,name:n.name,status:`failed`,error:e})}t.push(r)}catch(e){let r=e instanceof Error?e.message:String(e);this.log.error({action:`effect`,name:n.name,status:`failed`,error:r}),t.push({success:!1,error:e,description:`Clean effect failed: ${n.name}`})}}return t}isRelativePath(e){return e.pathKind===L.Relative}toRelativePath(e){return this.isRelativePath(e)?e:{pathKind:L.Relative,path:e.path,basePath:``,getDirectoryName:e.getDirectoryName,getAbsolutePath:()=>e.path}}resolveFullPath(e,t){let r;r=e.pathKind===L.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 mt(e,t,n)}createFileRelativePath(e,t){return ht(e,t)}getGlobalConfigDir(){return i.join(this.getHomeDir(),this.globalConfigDir)}getHomeDir(){return s.homedir()}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=`utf8`){ut(e,t,n)}writeFileSyncBuffer(e,t){ut(e,t)}ensureDirectory(e){at(e)}existsSync(e){return r.existsSync(e)}lstatSync(e){return it(e)}isSymlink(e){return rt(e)}createSymlink(e,t,n=`dir`){st(e,t,n)}removeSymlink(e){ct(e)}async writeDirectorySymlink(e,t,n,r){let a=i.dirname(n),o=mt(i.basename(n),a,()=>i.basename(a));if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`symlink`,target:t,link:n,label:r}),{path:o,success:!0,skipped:!1};try{return this.createSymlink(t,n,`dir`),this.log.trace({action:`write`,type:`symlink`,target:t,link:n,label:r}),{path:o,success:!0}}catch(e){let i=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`symlink`,target:t,link:n,label:r,error:i}),{path:o,success:!1,error:e}}}readdirSync(e,t){return t?.withFileTypes===!0?r.readdirSync(e,{withFileTypes:!0}):r.readdirSync(e)}async writeFile(e,t,n,r){let a=i.dirname(t),o=mt(i.basename(t),a,()=>i.basename(a));if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`file`,path:t,label:r}),{path:o,success:!0,skipped:!1};try{return ut(t,n),this.log.trace({action:`write`,type:`file`,path:t,label:r}),{path:o,success:!0}}catch(e){let n=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`file`,path:t,label:r,error:n}),{path:o,success:!1,error:e}}}async writePromptFile(e,t,n,r){let i=this.resolveFullPath(t),a=this.toRelativePath(t);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`promptFile`,path:i,label:r}),{path:a,success:!0,skipped:!1};try{return ut(i,n),this.log.trace({action:`write`,type:`promptFile`,path:i,label:r}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`promptFile`,path:i,label:r,error:t}),{path:a,success:!1,error:e}}}buildMarkdownContent(e,t){return Ag(t,e)}buildMarkdownContentWithRaw(e,t,n){return t!=null&&Object.keys(t).length>0?Ag(t,e):n!=null&&n.length>0?`---\n${n}\n---\n${e}`:e}extractGlobalMemoryContent(e){return e.collectedInputContext.globalMemory?.content}combineGlobalWithContent(e,t,n){let{separator:r=`
871
1196
 
872
- `,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;this.log.trace({action:e.dryRun===!0?`dryRun`:`complete`,type:`writeSummary`,success:n,skipped:r,failed:i}),await this.executeWriteEffects(e)}async onCleanComplete(e){await this.executeCleanEffects(e)}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)}};const Fg=`AGENTS.md`;var Ig=class extends Pg{constructor(){super(`AgentsOutputPlugin`,{outputFileName:Fg})}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,Fg)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,Fg));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.trace({action:`skip`,reason:`noOutputs`}),!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}}},Lg=class extends Ng{inputEffects=[];registeredScopes=[];constructor(e,t){super(e,Tt.Input,t)}registerEffect(e,t,n=0){this.inputEffects.push({name:e,handler:t,priority:n}),this.inputEffects.sort((e,t)=>(e.priority??0)-(t.priority??0))}async executeEffects(e,t=!1){let n=[];if(this.inputEffects.length===0)return n;let{workspaceDir:r,shadowProjectDir:i}=this.resolveBasePaths(e.userConfigOptions),a={logger:this.log,fs:e.fs,path:e.path,glob:e.glob,spawn:u,userConfigOptions:e.userConfigOptions,workspaceDir:r,shadowProjectDir:i,dryRun:t};for(let e of this.inputEffects){if(t){this.log.trace({action:`dryRun`,type:`inputEffect`,name:e.name}),n.push({success:!0,description:`Would execute input effect: ${e.name}`});continue}try{let t=await e.handler(a);if(t.success)this.log.trace({action:`inputEffect`,name:e.name,status:`success`,description:t.description}),t.modifiedFiles!=null&&t.modifiedFiles.length>0&&this.log.debug({action:`inputEffect`,name:e.name,modifiedFiles:t.modifiedFiles}),t.deletedFiles!=null&&t.deletedFiles.length>0&&this.log.debug({action:`inputEffect`,name:e.name,deletedFiles:t.deletedFiles});else{let n=t.error instanceof Error?t.error.message:String(t.error);this.log.error({action:`inputEffect`,name:e.name,status:`failed`,error:n})}n.push(t)}catch(t){let r=t instanceof Error?t.message:String(t);this.log.error({action:`inputEffect`,name:e.name,status:`failed`,error:r}),n.push({success:!1,error:t,description:`Input effect failed: ${e.name}`})}}return n}hasEffects(){return this.inputEffects.length>0}getEffectCount(){return this.inputEffects.length}registerScope(e,t){this.registeredScopes.push({namespace:e,values:t}),this.log.debug({action:`registerScope`,namespace:e,keys:Object.keys(t)})}getRegisteredScopes(){return this.registeredScopes}clearRegisteredScopes(){this.registeredScopes.length=0,this.log.debug({action:`clearRegisteredScopes`})}resolveBasePaths(e){let t=e.workspaceDir,n=this.resolvePath(t,``,``),r=e.shadowSourceProjectDir;return{workspaceDir:n,shadowProjectDir:this.resolvePath(r,n,``)}}resolvePath(e,t,n){let r=e;return r.startsWith(qt.USER_HOME)&&(r=r.replace(qt.USER_HOME,s.homedir())),r.includes(qt.SHADOW_SOURCE_PROJECT)&&(r=r.replace(qt.SHADOW_SOURCE_PROJECT,n)),r.includes(qt.WORKSPACE)&&(r=r.replace(qt.WORKSPACE,t)),i.normalize(r)}readAndParseMarkdown(e,t){return jg(t.readFileSync(e,`utf8`))}};const Rg=[`.qoderignore`,`.cursorignore`,`.kiroignore`,`.warpindexignore`,`.aiignore`];var zg=class extends Lg{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 Rg){let t=i.join(a,e);if(r.existsSync(t)&&r.statSync(t).isFile())try{let i=r.readFileSync(t,`utf8`);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 Bg=[`.qoderignore`,`.cursorignore`,`.kiroignore`,`.warpindexignore`,`.aiignore`];var Vg=class extends Pg{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 Bg){let r=i.join(e.dirFromWorkspacePath.path,n);t.push({pathKind:L.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?.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:L.Relative,path:o,basePath:t.basePath,getDirectoryName:()=>i.basename(t.path),getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`ignoreFile`,path:s,label:a}),{path:c,success:!0,skipped:!1};try{return r.writeFileSync(s,n.content,`utf8`),this.log.trace({action:`write`,type:`ignoreFile`,path:s,label:a}),{path:c,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`ignoreFile`,path:s,label:a,error:t}),{path:c,success:!1,error:e}}}};const Hg=`.agent`,Ug=`antigravity`,Wg=`skills`,Gg=`workflows`,Kg=`mcp_config.json`,qg=[Wg,Gg];var Jg=class extends Pg{constructor(){super(`AntigravityOutputPlugin`,{globalConfigDir:Hg,outputFileName:``,dependsOn:[`GeminiCLIOutputPlugin`]}),this.registerCleanEffect(`mcp-config-cleanup`,async e=>{let t=i.join(this.getAntigravityDir(),Kg),n=JSON.stringify({mcpServers:{}},null,2);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfigCleanup`,path:t}),{success:!0,description:`Would reset mcp_config.json`};let r=await this.writeFile(e,t,n,`mcpConfigCleanup`);return r.success?{success:!0,description:`Reset mcp_config.json`}:{success:!1,description:`Failed`,error:r.error??Error(`Cleanup failed`)}})}getAntigravityDir(){return i.join(s.homedir(),`.gemini`,Ug)}async registerProjectOutputDirs(e){let{projects:t}=e.collectedInputContext.workspace,n=[];for(let e of t)if(e.dirFromWorkspacePath!=null)for(let t of qg)n.push(this.createRelativePath(i.join(e.dirFromWorkspacePath.path,Hg,t),e.dirFromWorkspacePath.basePath,()=>t));return n}async registerProjectOutputFiles(e){let{skills:t,fastCommands:n}=e.collectedInputContext,r=this.getAntigravityDir(),a=[];if(t!=null)for(let e of t){let t=e.yamlFrontMatter?.name??e.dir.getDirectoryName(),n=i.join(r,Wg,t);if(a.push(this.createRelativePath(`SKILL.md`,n,()=>t)),e.childDocs!=null)for(let r of e.childDocs)a.push(this.createRelativePath(r.dir.path.replace(/\.mdx$/,`.md`),n,()=>t));if(e.resources!=null)for(let r of e.resources)a.push(this.createRelativePath(r.relativePath,n,()=>t))}if(t?.some(e=>e.mcpConfig!=null)&&a.push(this.createRelativePath(Kg,r,()=>Ug)),n==null)return a;let o=this.getTransformOptionsFromContext(e),s=i.join(r,Gg);for(let e of n)a.push(this.createRelativePath(this.transformFastCommandName(e,o),s,()=>Gg));return a}async canWrite(e){let{fastCommands:t,skills:n}=e.collectedInputContext;return(t?.length??0)>0||(n?.length??0)>0?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{fastCommands:t,skills:n}=e.collectedInputContext,r=[],a=this.getAntigravityDir();if(t!=null){let n=i.join(a,Gg);for(let i of t)r.push(await this.writeFastCommand(e,n,i))}if(n!=null){let t=i.join(a,Wg);for(let i of n)r.push(...await this.writeSkill(e,t,i));let o=await this.writeGlobalMcpConfig(e,a,n);o!=null&&r.push(o)}return this.log.info({action:`write`,message:`Synced ${r.length} files`,globalDir:a}),{files:r,dirs:[]}}async writeGlobalMcpConfig(e,t,n){let r={};for(let e of n)if(e.mcpConfig!=null)for(let[t,n]of Object.entries(e.mcpConfig.mcpServers))r[t]=this.transformMcpConfig(n);if(Object.keys(r).length===0)return null;let a=i.join(t,Kg),o=JSON.stringify({mcpServers:r},null,2);return this.writeFile(e,a,o,`globalMcpConfig`)}transformMcpConfig(e){let t={};for(let[n,r]of Object.entries(e))if(n===`url`)t.serverUrl=r;else if(n===`type`||n===`enabled`||n===`autoApprove`)continue;else t[n]=r;return t}async writeFastCommand(e,t,n){let r=this.getTransformOptionsFromContext(e),a=this.transformFastCommandName(n,r),o=i.join(t,a),s=typeof n.yamlFrontMatter?.description==`string`?{description:n.yamlFrontMatter.description}:{},c;if(n.rawMdxContent!=null){let e=n.rawMdxContent.replace(/^---\n[\s\S]*?\n---\n/,``);c=this.buildMarkdownContentWithRaw(e,s,n.rawFrontMatter)}else c=this.buildMarkdownContentWithRaw(n.content,s,n.rawFrontMatter);return this.writeFile(e,o,c,`fastCommand`)}async writeSkill(e,t,n){let r=[],a=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),o=i.join(t,a),s=i.join(o,`SKILL.md`),c=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(r.push(await this.writeFile(e,s,c,`skill`)),n.childDocs!=null)for(let t of n.childDocs){let n=t.dir.path.replace(/\.mdx$/,`.md`);r.push(await this.writeFile(e,i.join(o,n),t.content,`skillRefDoc`))}if(n.resources!=null)for(let t of n.resources)r.push(await this.writeFile(e,i.join(o,t.relativePath),t.content,`skillResource`));return r}},Yg=class extends Error{constructor(e,t,n){super(e),this.expression=t,this.filePath=n,this.name=`ScopeError`}},Xg=class extends Yg{constructor(e,t,n){let r=n!=null&&n.length>0?`Undefined variable "${e}" in expression "${t}" (file: ${n})`:`Undefined variable "${e}" in expression "${t}"`;super(r,t,n),this.variableName=e,this.name=`UndefinedVariableError`}},Zg=class extends Yg{constructor(e,t,n){let r=n!=null&&n.length>0?`Undefined namespace "${e}" in expression "${t}" (file: ${n})`:`Undefined namespace "${e}" in expression "${t}"`;super(r,t,n),this.namespace=e,this.name=`UndefinedNamespaceError`}},Qg=class extends Error{constructor(e,t){let n=t!=null&&t.length>0?`Missing required metadata fields: ${e.join(`, `)} (file: ${t})`:`Missing required metadata fields: ${e.join(`, `)}`;super(n),this.missingFields=e,this.filePath=t,this.name=`MetadataValidationError`}},$g=Object.defineProperty,e_=(e,t)=>{let n={};for(var r in e)$g(n,r,{get:e[r],enumerable:!0});return t||$g(n,Symbol.toStringTag,{value:`Module`}),n};const t_=new Map;function n_(e,t){t_.set(e,t)}function r_(){return new Map(t_)}function i_(e){return t_.has(e)}function a_(e,t,n){let r=e.trim();return r===``?``:/^[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*$/i.test(r)?o_(r,t,n?.filePath):s_(r,t,n?.filePath)}function o_(e,t,n){let r=e.split(`.`),i=r[0];if(i==null||!(i in t))throw new Zg(i??``,e,n);let a=t[i];for(let t=1;t<r.length;t++){let i=r[t];if(i==null)continue;if(a==null)throw new Xg(i,e,n);if(typeof a!=`object`)throw TypeError(`Cannot read property "${i}" of ${typeof a} in expression "${e}"`);let o=a;if(!(i in o))throw new Xg(i,e,n);a=o[i]}return c_(a)}function s_(e,t,n){let r=Object.keys(t),i=r.map(e=>t[e]);try{return c_(Function(...r,`return (${e})`)(...i))}catch(t){let r=t instanceof Error?t.message:String(t);if(r.includes(`is not defined`)){let t=/(\w+) is not defined/.exec(r);if(t?.[1]!=null)throw new Zg(t[1],e,n)}let i=n==null?``:` (file: ${n})`;throw Error(`Failed to evaluate expression: "${e}"${i}\nCause: ${r}`)}}function c_(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(typeof e==`object`)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function l_(e,t){return e===null?!1:t.components.has(e)||i_(e)}async function u_(e){return async(t,n)=>(await e({type:`root`,children:t},n)).children}async function d_(e,t,n){let r=e.name;if(r==null||r===``)return[];let i=t.components.get(r);if(i==null)return[];if(t.processingStack.includes(r)){let e=[...t.processingStack,r].join(` → `);throw Error(`Circular dependency detected: ${e}`)}let a={scope:t.scope,components:t.components,processingStack:[...t.processingStack,r],...t.basePath==null?{}:{basePath:t.basePath}},o=await u_(n);try{return await i(e,a,o)}catch(e){let n=e instanceof Error?e.message:String(e),i=t.processingStack.join(` → `);throw Error(`Failed to process component "${r}"${i===``?``:` (called from: ${i})`}:\n${n}`,{cause:e})}}function f_(e,t){let n=e.name?.toLowerCase();if(n==null)return null;switch(n){case`pre`:return h_(e,t);case`a`:return g_(e,t);case`strong`:case`b`:return __(e,t);case`em`:case`i`:return v_(e,t);case`img`:return y_(e,t);case`blockquote`:return b_(e,t);default:return null}}function p_(e,t,n){let r=e.attributes.find(e=>e.type===`mdxJsxAttribute`&&e.name===t);return r==null?null:typeof r.value==`string`?r.value:r.value!=null&&typeof r.value==`object`&&r.value.type===`mdxJsxAttributeValueExpression`?a_(r.value.value,n.scope):r.value===null?``:null}function m_(e,t){let n=``;for(let r of e.children)r.type===`text`?n+=r.value:r.type===`mdxTextExpression`?n+=a_(r.value,t.scope):(r.type===`mdxJsxFlowElement`||r.type===`mdxJsxTextElement`)&&(n+=m_(r,t));return n}function h_(e,t){let n=null;for(let t of e.children){if((t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)&&t.name?.toLowerCase()===`code`){n=t;break}if(t.type===`paragraph`&&`children`in t){let e=t.children;for(let t of e)if((t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)&&t.name?.toLowerCase()===`code`){n=t;break}if(n!=null)break}}if(n==null)return null;let r=p_(n,`className`,t)??``,i=/language-(\w+)/.exec(r)?.[1],a=m_(n,t);return[{type:`code`,lang:i??null,value:a.trim()}]}function g_(e,t){let n=p_(e,`href`,t);if(n==null||n===``)return null;let r=m_(e,t);return[{type:`paragraph`,children:[{type:`link`,url:n,title:p_(e,`title`,t)??null,children:[{type:`text`,value:r}]}]}]}function __(e,t){let n={type:`strong`,children:[{type:`text`,value:m_(e,t)}]};return e.type,[{type:`paragraph`,children:[n]}]}function v_(e,t){let n={type:`emphasis`,children:[{type:`text`,value:m_(e,t)}]};return e.type,[{type:`paragraph`,children:[n]}]}function y_(e,t){let n=p_(e,`src`,t);if(n==null||n===``)return null;let r={type:`image`,url:n,alt:p_(e,`alt`,t)??``,title:p_(e,`title`,t)??null};return e.type,[{type:`paragraph`,children:[r]}]}function b_(e,t){return[{type:`blockquote`,children:[{type:`paragraph`,children:[{type:`text`,value:m_(e,t)}]}]}]}function x_(e){return e==null?!1:JSON.stringify(e).includes(`"JSX`)}async function S_(e,t,n){let r=e.data?.estree;if(r==null||r.body.length===0)return[];let i=r.body[0];return i?.type===`ExpressionStatement`?C_(i.expression,t,n):[]}async function C_(e,t,n){return e.type===`JSXElement`?k_(e,t,n):e.type===`JSXFragment`?A_(e,t,n):e.type===`LogicalExpression`?w_(e,t,n):e.type===`ConditionalExpression`?T_(e,t,n):e.type===`SequenceExpression`?E_(e,t,n):e.type===`ArrayExpression`?D_(e,t,n):z_(e,t)}async function w_(e,t,n){let r=await O_(e.left,t,n);return e.operator===`&&`?L_(r)?C_(e.right,t,n):[]:e.operator===`||`?L_(r)?I_(e.left)?C_(e.left,t,n):R_(r):C_(e.right,t,n):e.operator===`??`?r==null?C_(e.right,t,n):I_(e.left)?C_(e.left,t,n):R_(r):[]}async function T_(e,t,n){return L_(await O_(e.test,t,n))?C_(e.consequent,t,n):C_(e.alternate,t,n)}async function E_(e,t,n){let r=[];for(let i of e.expressions){let e=await C_(i,t,n);r.push(...e)}return r}async function D_(e,t,n){let r=[];for(let i of e.elements)if(i!=null)if(i.type===`SpreadElement`){let e=await C_(i.argument,t,n);r.push(...e)}else{let e=await C_(i,t,n);r.push(...e)}return r}async function O_(e,t,n){if(I_(e))return!0;if(e.type===`Literal`)return e.value;if(e.type===`Identifier`)return e.name===`undefined`?void 0:e.name===`NaN`?NaN:e.name===`Infinity`?1/0:t.scope[e.name];if(e.type===`UnaryExpression`){let r=await O_(e.argument,t,n);return e.operator===`!`?!L_(r):e.operator===`-`?-r:e.operator===`+`?+r:e.operator===`typeof`?typeof r:void 0}if(e.type===`BinaryExpression`){let r=await O_(e.left,t,n),i=await O_(e.right,t,n);return e.operator===`===`?r===i:e.operator===`!==`?r!==i:e.operator===`==`?r===i:e.operator===`!=`?r!==i:e.operator===`<`?r<i:e.operator===`<=`?r<=i:e.operator===`>`?r>i:e.operator===`>=`?r>=i:e.operator===`+`?r+i:e.operator===`-`?r-i:e.operator===`*`?r*i:e.operator===`/`?r/i:e.operator===`%`?r%i:void 0}if(e.type===`LogicalExpression`){let r=await O_(e.left,t,n);return e.operator===`&&`?L_(r)?O_(e.right,t,n):r:e.operator===`||`?L_(r)?r:O_(e.right,t,n):e.operator===`??`?r??O_(e.right,t,n):void 0}if(e.type===`MemberExpression`){let r=await O_(e.object,t,n);if(r==null)return;if(e.computed)return r[await O_(e.property,t,n)];let{name:i}=e.property;return r[i]}if(e.type===`ConditionalExpression`)return L_(await O_(e.test,t,n))?O_(e.consequent,t,n):O_(e.alternate,t,n);let r=F_(e);if(r!==``)try{let e=a_(r,t.scope);return e===`true`?!0:e===`false`?!1:e===`null`?null:e===`undefined`||e===``?void 0:/^-?\d+(?:\.\d+)?$/.test(e)?Number(e):e}catch{return}}async function k_(e,t,n){let r=M_(e,t);if(r.name!=null&&l_(r.name,t)){let{processAst:e}=await Promise.resolve().then(()=>B_);return d_(r,t,e)}return f_(r,t)??(r.children.length>0?n(r.children,t):[])}async function A_(e,t,n){let r=[];for(let i of e.children){let e=await j_(i,t,n);r.push(...e)}return r}async function j_(e,t,n){if(e.type===`JSXElement`)return k_(e,t,n);if(e.type===`JSXFragment`)return A_(e,t,n);if(e.type===`JSXText`){let t=e.value.trim();return t===``?[]:[{type:`paragraph`,children:[{type:`text`,value:t}]}]}return e.type===`JSXExpressionContainer`?e.expression.type===`JSXEmptyExpression`?[]:C_(e.expression,t,n):e.type===`JSXSpreadChild`?C_(e.expression,t,n):[]}function M_(e,t){let n=e.openingElement,r=null;n.name.type===`JSXIdentifier`?{name:r}=n.name:n.name.type===`JSXMemberExpression`?r=N_(n.name):n.name.type===`JSXNamespacedName`&&(r=`${n.name.namespace.name}:${n.name.name.name}`);let i=[];for(let e of n.attributes)if(e.type===`JSXAttribute`){let t=e.name.type===`JSXIdentifier`?e.name.name:`${e.name.namespace.name}:${e.name.name.name}`,n=null;e.value==null?n=null:e.value.type===`Literal`?n=String(e.value.value):e.value.type===`JSXExpressionContainer`&&e.value.expression.type!==`JSXEmptyExpression`&&(n={type:`mdxJsxAttributeValueExpression`,value:F_(e.value.expression)}),i.push({type:`mdxJsxAttribute`,name:t,value:n})}else e.type===`JSXSpreadAttribute`&&i.push({type:`mdxJsxExpressionAttribute`,value:`...${F_(e.argument)}`});let a=[];for(let n of e.children){let e=P_(n,t);e!=null&&a.push(...e)}return{type:`mdxJsxFlowElement`,name:r,attributes:i,children:a}}function N_(e){return e.object.type===`JSXIdentifier`?`${e.object.name}.${e.property.name}`:`${N_(e.object)}.${e.property.name}`}function P_(e,t){if(e.type===`JSXText`){let{value:t}=e;return t.trim()===``?null:[{type:`paragraph`,children:[{type:`text`,value:t}]}]}if(e.type===`JSXElement`)return[M_(e,t)];if(e.type===`JSXFragment`){let n=[];for(let r of e.children){let e=P_(r,t);e!=null&&n.push(...e)}return n}return e.type===`JSXExpressionContainer`?e.expression.type===`JSXEmptyExpression`?null:[{type:`paragraph`,children:[{type:`text`,value:F_(e.expression)}]}]:e.type===`JSXSpreadChild`?[{type:`paragraph`,children:[{type:`text`,value:`...${F_(e.expression)}`}]}]:null}function F_(e){if(e.type===`Identifier`)return e.name;if(e.type===`Literal`)return typeof e.value==`string`?JSON.stringify(e.value):String(e.value);if(e.type===`MemberExpression`){let t=F_(e.object);return e.computed?`${t}[${F_(e.property)}]`:`${t}.${e.property.name}`}if(e.type===`CallExpression`)return`${F_(e.callee)}(${e.arguments.map(e=>F_(e)).join(`, `)})`;if(e.type===`BinaryExpression`||e.type===`LogicalExpression`){let t=F_(e.left),n=F_(e.right);return`(${t} ${e.operator} ${n})`}if(e.type===`UnaryExpression`){let t=F_(e.argument);return`${e.operator}${t}`}if(e.type===`ConditionalExpression`)return`(${F_(e.test)} ? ${F_(e.consequent)} : ${F_(e.alternate)})`;if(e.type===`ArrayExpression`)return`[${e.elements.filter(e=>e!=null&&e.type!==`SpreadElement`).map(e=>F_(e)).join(`, `)}]`;if(e.type===`ObjectExpression`)return`{${e.properties.filter(e=>e.type===`Property`).map(e=>`${e.key.type===`Identifier`?e.key.name:F_(e.key)}: ${F_(e.value)}`).join(`, `)}}`;if(e.type===`TemplateLiteral`){let t="`";for(let n=0;n<e.quasis.length;n++)t+=e.quasis[n]?.value.raw??``,n<e.expressions.length&&(t+=`\${${F_(e.expressions[n])}}`);return t+="`",t}return e.type===`SpreadElement`?`...${F_(e.argument)}`:``}function I_(e){return e.type===`JSXElement`||e.type===`JSXFragment`}function L_(e){return!!e}function R_(e){if(e==null)return[];let t=typeof e==`string`?e:String(e);return t===``||t===`undefined`||t===`null`?[]:[{type:`paragraph`,children:[{type:`text`,value:t}]}]}function z_(e,t){let n=F_(e);if(n===``)return[];try{return R_(a_(n,t.scope))}catch{return[]}}var B_=e_({processAst:()=>H_});function V_(e){if(!(e.includes(`/`)&&/\.\w+$/.test(e)))return e;let t=e.lastIndexOf(`/`);return e.slice(t+1)}async function H_(e,t){return U_(e,t)}async function U_(e,t){let n=[];for(let r of e.children){let e=await W_(r,t);n.push(...e)}return{type:`root`,children:n}}async function W_(e,t){if(e.type===`mdxjsEsm`)return[];if(e.type===`mdxFlowExpression`){let n=e,r=n.data?.estree,i=n.value.trim();if(i.startsWith(`/*`)&&i.endsWith(`*/`))return[];if(x_(r))return S_(n,t,async(e,t)=>(await H_({type:`root`,children:e},t)).children);let a=a_(n.value,t.scope);return a===``?[]:[{type:`paragraph`,children:[{type:`text`,value:a}]}]}if(e.type===`mdxJsxFlowElement`)return G_(e,t);if(e.type===`link`){let n=e,r=(await K_(n.children,t)).map(e=>e.type===`text`?{...e,value:V_(e.value)}:e);return[{...n,children:r}]}if(!(`children`in e&&Array.isArray(e.children)))return[e];let n=await K_(e.children,t);return[{...e,children:n}]}async function G_(e,t){return e.name!=null&&l_(e.name,t)?d_(e,t,H_):f_(e,t)??[]}async function K_(e,t){let n=[];for(let r of e){if(r.type===`mdxTextExpression`){let e=r,i=e.value.trim();if(i.startsWith(`/*`)&&i.endsWith(`*/`))continue;let a={type:`text`,value:a_(e.value,t.scope)};n.push(a);continue}if(r.type===`mdxJsxTextElement`){let e=r;if(e.name!=null&&l_(e.name,t)){let r=await d_(e,t,H_);for(let e of r)e.type===`paragraph`&&`children`in e?n.push(...e.children):n.push(e);continue}let i=f_(e,t);if(i!=null)for(let e of i)e.type===`paragraph`&&`children`in e?n.push(...e.children):n.push(e);continue}if(`children`in r&&Array.isArray(r.children)){let e=await K_(r.children,t);if(r.type===`link`){let t=e.map(e=>e.type===`text`?{...e,value:V_(e.value)}:e);n.push({...r,children:t});continue}n.push({...r,children:e});continue}n.push(r)}return n}function q_(e){let t=this;t.compiler=n;function n(n){return Bo(n,{...t.data(`settings`),...e,extensions:t.data(`toMarkdownExtensions`)||[]})}}function J_(e,t={}){let n={},{yamlFrontMatter:r,scope:i,filePath:a}=t;for(let t of e){let e=Y_(t,i,a);Object.assign(n,e)}let o=Object.keys(n).length>0,s=r!=null&&Object.keys(r).length>0,c;return c=o&&s?`mixed`:o?`export`:`yaml`,{fields:{...r,...n},source:c}}function Y_(e,t,n){let r={},i=e.value.trim(),a=/^export\s+default\s+/.exec(i);if(a!=null){let e=a[0].length,o=X_(i,e);if(o!=null)try{let e=Z_(o.trim(),t,n);typeof e==`object`&&e&&!Array.isArray(e)&&Object.assign(r,e)}catch(e){let t=e instanceof Error?e.message:String(e),r=n==null?``:` in file "${n}"`;throw Error(`Cannot statically evaluate export default${r}: ${t}`)}return r}let o=/export\s+const\s+(\w+)\s*=\s*/g,s=o.exec(i);for(;s!==null;){let e=s[1];if(e==null){s=o.exec(i);continue}let a=X_(i,s.index+s[0].length);if(a==null){s=o.exec(i);continue}try{let i=Z_(a.trim(),t,n);e===`metadata`&&typeof i==`object`&&i&&!Array.isArray(i)?Object.assign(r,i):r[e]=i}catch(t){let r=t instanceof Error?t.message:String(t),i=n==null?``:` in file "${n}"`;throw Error(`Cannot statically evaluate export "${e}"${i}: ${r}`)}s=o.exec(i)}return r}function X_(e,t){let n=0,r=null,i=!1,a=t;for(let o=t;o<e.length;o++){let t=e[o];if(i){i=!1;continue}if(t===`\\`){i=!0;continue}if(r!=null){t===r&&(r=null);continue}if(t===`"`||t===`'`||t==="`"){r=t;continue}if(t===`{`||t===`[`){n++;continue}if(t===`}`||t===`]`){n--;continue}if(n===0){if(t===`;`||t===`
1197
+ `,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;this.log.trace({action:e.dryRun===!0?`dryRun`:`complete`,type:`writeSummary`,success:n,skipped:r,failed:i}),await this.executeWriteEffects(e)}async onCleanComplete(e){await this.executeCleanEffects(e)}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)}};const Fg=`AGENTS.md`;var Ig=class extends Pg{constructor(){super(`AgentsOutputPlugin`,{outputFileName:Fg})}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,Fg)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,Fg));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.trace({action:`skip`,reason:`noOutputs`}),!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}}},Lg=class extends Ng{inputEffects=[];registeredScopes=[];constructor(e,t){super(e,Tt.Input,t)}registerEffect(e,t,n=0){this.inputEffects.push({name:e,handler:t,priority:n}),this.inputEffects.sort((e,t)=>(e.priority??0)-(t.priority??0))}async executeEffects(e,t=!1){let n=[];if(this.inputEffects.length===0)return n;let{workspaceDir:r,shadowProjectDir:i}=this.resolveBasePaths(e.userConfigOptions),a={logger:this.log,fs:e.fs,path:e.path,glob:e.glob,spawn:u,userConfigOptions:e.userConfigOptions,workspaceDir:r,shadowProjectDir:i,dryRun:t};for(let e of this.inputEffects){if(t){this.log.trace({action:`dryRun`,type:`inputEffect`,name:e.name}),n.push({success:!0,description:`Would execute input effect: ${e.name}`});continue}try{let t=await e.handler(a);if(t.success)this.log.trace({action:`inputEffect`,name:e.name,status:`success`,description:t.description}),t.modifiedFiles!=null&&t.modifiedFiles.length>0&&this.log.debug({action:`inputEffect`,name:e.name,modifiedFiles:t.modifiedFiles}),t.deletedFiles!=null&&t.deletedFiles.length>0&&this.log.debug({action:`inputEffect`,name:e.name,deletedFiles:t.deletedFiles});else{let n=t.error instanceof Error?t.error.message:String(t.error);this.log.error({action:`inputEffect`,name:e.name,status:`failed`,error:n})}n.push(t)}catch(t){let r=t instanceof Error?t.message:String(t);this.log.error({action:`inputEffect`,name:e.name,status:`failed`,error:r}),n.push({success:!1,error:t,description:`Input effect failed: ${e.name}`})}}return n}hasEffects(){return this.inputEffects.length>0}getEffectCount(){return this.inputEffects.length}registerScope(e,t){this.registeredScopes.push({namespace:e,values:t}),this.log.debug({action:`registerScope`,namespace:e,keys:Object.keys(t)})}getRegisteredScopes(){return this.registeredScopes}clearRegisteredScopes(){this.registeredScopes.length=0,this.log.debug({action:`clearRegisteredScopes`})}resolveBasePaths(e){let t=e.workspaceDir,n=this.resolvePath(t,``,``),r=e.shadowSourceProjectDir;return{workspaceDir:n,shadowProjectDir:this.resolvePath(r,n,``)}}resolvePath(e,t,n){let r=e;return r.startsWith(qt.USER_HOME)&&(r=r.replace(qt.USER_HOME,s.homedir())),r.includes(qt.SHADOW_SOURCE_PROJECT)&&(r=r.replace(qt.SHADOW_SOURCE_PROJECT,n)),r.includes(qt.WORKSPACE)&&(r=r.replace(qt.WORKSPACE,t)),i.normalize(r)}readAndParseMarkdown(e,t){return jg(t.readFileSync(e,`utf8`))}};const Rg=[`.qoderignore`,`.cursorignore`,`.kiroignore`,`.warpindexignore`,`.aiignore`,`.codeignore`];var zg=class extends Lg{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 Rg){let t=i.join(a,e);if(r.existsSync(t)&&r.statSync(t).isFile())try{let i=r.readFileSync(t,`utf8`);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 Bg=[`.qoderignore`,`.cursorignore`,`.kiroignore`,`.warpindexignore`,`.aiignore`];var Vg=class extends Pg{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 Bg){let r=i.join(e.dirFromWorkspacePath.path,n);t.push({pathKind:L.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?.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:L.Relative,path:o,basePath:t.basePath,getDirectoryName:()=>i.basename(t.path),getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`ignoreFile`,path:s,label:a}),{path:c,success:!0,skipped:!1};try{return r.writeFileSync(s,n.content,`utf8`),this.log.trace({action:`write`,type:`ignoreFile`,path:s,label:a}),{path:c,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`ignoreFile`,path:s,label:a,error:t}),{path:c,success:!1,error:e}}}};const Hg=`.agent`,Ug=`antigravity`,Wg=`skills`,Gg=`workflows`,Kg=`mcp_config.json`,qg=[Wg,Gg];var Jg=class extends Pg{constructor(){super(`AntigravityOutputPlugin`,{globalConfigDir:Hg,outputFileName:``,dependsOn:[`GeminiCLIOutputPlugin`]}),this.registerCleanEffect(`mcp-config-cleanup`,async e=>{let t=i.join(this.getAntigravityDir(),Kg),n=JSON.stringify({mcpServers:{}},null,2);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfigCleanup`,path:t}),{success:!0,description:`Would reset mcp_config.json`};let r=await this.writeFile(e,t,n,`mcpConfigCleanup`);return r.success?{success:!0,description:`Reset mcp_config.json`}:{success:!1,description:`Failed`,error:r.error??Error(`Cleanup failed`)}})}getAntigravityDir(){return i.join(s.homedir(),`.gemini`,Ug)}async registerProjectOutputDirs(e){let{projects:t}=e.collectedInputContext.workspace,n=[];for(let e of t)if(e.dirFromWorkspacePath!=null)for(let t of qg)n.push(this.createRelativePath(i.join(e.dirFromWorkspacePath.path,Hg,t),e.dirFromWorkspacePath.basePath,()=>t));return n}async registerProjectOutputFiles(e){let{skills:t,fastCommands:n}=e.collectedInputContext,r=this.getAntigravityDir(),a=[];if(t!=null)for(let e of t){let t=e.yamlFrontMatter?.name??e.dir.getDirectoryName(),n=i.join(r,Wg,t);if(a.push(this.createRelativePath(`SKILL.md`,n,()=>t)),e.childDocs!=null)for(let r of e.childDocs)a.push(this.createRelativePath(r.dir.path.replace(/\.mdx$/,`.md`),n,()=>t));if(e.resources!=null)for(let r of e.resources)a.push(this.createRelativePath(r.relativePath,n,()=>t))}if(t?.some(e=>e.mcpConfig!=null)&&a.push(this.createRelativePath(Kg,r,()=>Ug)),n==null)return a;let o=this.getTransformOptionsFromContext(e),s=i.join(r,Gg);for(let e of n)a.push(this.createRelativePath(this.transformFastCommandName(e,o),s,()=>Gg));return a}async canWrite(e){let{fastCommands:t,skills:n}=e.collectedInputContext;return(t?.length??0)>0||(n?.length??0)>0?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{fastCommands:t,skills:n}=e.collectedInputContext,r=[],a=this.getAntigravityDir();if(t!=null){let n=i.join(a,Gg);for(let i of t)r.push(await this.writeFastCommand(e,n,i))}if(n!=null){let t=i.join(a,Wg);for(let i of n)r.push(...await this.writeSkill(e,t,i));let o=await this.writeGlobalMcpConfig(e,a,n);o!=null&&r.push(o)}return this.log.info({action:`write`,message:`Synced ${r.length} files`,globalDir:a}),{files:r,dirs:[]}}async writeGlobalMcpConfig(e,t,n){let r={};for(let e of n)if(e.mcpConfig!=null)for(let[t,n]of Object.entries(e.mcpConfig.mcpServers))r[t]=this.transformMcpConfig(n);if(Object.keys(r).length===0)return null;let a=i.join(t,Kg),o=JSON.stringify({mcpServers:r},null,2);return this.writeFile(e,a,o,`globalMcpConfig`)}transformMcpConfig(e){let t={};for(let[n,r]of Object.entries(e))if(n===`url`)t.serverUrl=r;else if(n===`type`||n===`enabled`||n===`autoApprove`)continue;else t[n]=r;return t}async writeFastCommand(e,t,n){let r=this.getTransformOptionsFromContext(e),a=this.transformFastCommandName(n,r),o=i.join(t,a),s=typeof n.yamlFrontMatter?.description==`string`?{description:n.yamlFrontMatter.description}:{},c;if(n.rawMdxContent!=null){let e=n.rawMdxContent.replace(/^---\n[\s\S]*?\n---\n/,``);c=this.buildMarkdownContentWithRaw(e,s,n.rawFrontMatter)}else c=this.buildMarkdownContentWithRaw(n.content,s,n.rawFrontMatter);return this.writeFile(e,o,c,`fastCommand`)}async writeSkill(e,t,n){let r=[],a=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),o=i.join(t,a),s=i.join(o,`SKILL.md`),c=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(r.push(await this.writeFile(e,s,c,`skill`)),n.childDocs!=null)for(let t of n.childDocs){let n=t.dir.path.replace(/\.mdx$/,`.md`);r.push(await this.writeFile(e,i.join(o,n),t.content,`skillRefDoc`))}if(n.resources!=null)for(let t of n.resources)r.push(await this.writeFile(e,i.join(o,t.relativePath),t.content,`skillResource`));return r}},Yg=class extends Error{constructor(e,t,n){super(e),this.expression=t,this.filePath=n,this.name=`ScopeError`}},Xg=class extends Yg{constructor(e,t,n){let r=n!=null&&n.length>0?`Undefined variable "${e}" in expression "${t}" (file: ${n})`:`Undefined variable "${e}" in expression "${t}"`;super(r,t,n),this.variableName=e,this.name=`UndefinedVariableError`}},Zg=class extends Yg{constructor(e,t,n){let r=n!=null&&n.length>0?`Undefined namespace "${e}" in expression "${t}" (file: ${n})`:`Undefined namespace "${e}" in expression "${t}"`;super(r,t,n),this.namespace=e,this.name=`UndefinedNamespaceError`}},Qg=class extends Error{constructor(e,t){let n=t!=null&&t.length>0?`Missing required metadata fields: ${e.join(`, `)} (file: ${t})`:`Missing required metadata fields: ${e.join(`, `)}`;super(n),this.missingFields=e,this.filePath=t,this.name=`MetadataValidationError`}},$g=Object.defineProperty,e_=(e,t)=>{let n={};for(var r in e)$g(n,r,{get:e[r],enumerable:!0});return t||$g(n,Symbol.toStringTag,{value:`Module`}),n};const t_=new Map;function n_(e,t){t_.set(e,t)}function r_(){return new Map(t_)}function i_(e){return t_.has(e)}function a_(e,t,n){let r=e.trim();return r===``?``:/^[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*$/i.test(r)?o_(r,t,n?.filePath):s_(r,t,n?.filePath)}function o_(e,t,n){let r=e.split(`.`),i=r[0];if(i==null||!(i in t))throw new Zg(i??``,e,n);let a=t[i];for(let t=1;t<r.length;t++){let i=r[t];if(i==null)continue;if(a==null)throw new Xg(i,e,n);if(typeof a!=`object`)throw TypeError(`Cannot read property "${i}" of ${typeof a} in expression "${e}"`);let o=a;if(!(i in o))throw new Xg(i,e,n);a=o[i]}return c_(a)}function s_(e,t,n){let r=Object.keys(t),i=r.map(e=>t[e]);try{return c_(Function(...r,`return (${e})`)(...i))}catch(t){let r=t instanceof Error?t.message:String(t);if(r.includes(`is not defined`)){let t=/(\w+) is not defined/.exec(r);if(t?.[1]!=null)throw new Zg(t[1],e,n)}let i=n==null?``:` (file: ${n})`;throw Error(`Failed to evaluate expression: "${e}"${i}\nCause: ${r}`)}}function c_(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(typeof e==`object`)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function l_(e,t){return e===null?!1:t.components.has(e)||i_(e)}async function u_(e){return async(t,n)=>(await e({type:`root`,children:t},n)).children}async function d_(e,t,n){let r=e.name;if(r==null||r===``)return[];let i=t.components.get(r);if(i==null)return[];if(t.processingStack.includes(r)){let e=[...t.processingStack,r].join(` → `);throw Error(`Circular dependency detected: ${e}`)}let a={scope:t.scope,components:t.components,processingStack:[...t.processingStack,r],...t.basePath==null?{}:{basePath:t.basePath}},o=await u_(n);try{return await i(e,a,o)}catch(e){let n=e instanceof Error?e.message:String(e),i=t.processingStack.join(` → `);throw Error(`Failed to process component "${r}"${i===``?``:` (called from: ${i})`}:\n${n}`,{cause:e})}}function f_(e,t){let n=e.name?.toLowerCase();if(n==null)return null;switch(n){case`pre`:return h_(e,t);case`a`:return g_(e,t);case`strong`:case`b`:return __(e,t);case`em`:case`i`:return v_(e,t);case`img`:return y_(e,t);case`blockquote`:return b_(e,t);default:return null}}function p_(e,t,n){let r=e.attributes.find(e=>e.type===`mdxJsxAttribute`&&e.name===t);return r==null?null:typeof r.value==`string`?r.value:r.value!=null&&typeof r.value==`object`&&r.value.type===`mdxJsxAttributeValueExpression`?a_(r.value.value,n.scope):r.value===null?``:null}function m_(e,t){let n=``;for(let r of e.children)r.type===`text`?n+=r.value:r.type===`mdxTextExpression`?n+=a_(r.value,t.scope):(r.type===`mdxJsxFlowElement`||r.type===`mdxJsxTextElement`)&&(n+=m_(r,t));return n}function h_(e,t){let n=null;for(let t of e.children){if((t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)&&t.name?.toLowerCase()===`code`){n=t;break}if(t.type===`paragraph`&&`children`in t){let e=t.children;for(let t of e)if((t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)&&t.name?.toLowerCase()===`code`){n=t;break}if(n!=null)break}}if(n==null)return null;let r=p_(n,`className`,t)??``,i=/language-(\w+)/.exec(r)?.[1],a=m_(n,t);return[{type:`code`,lang:i??null,value:a.trim()}]}function g_(e,t){let n=p_(e,`href`,t);if(n==null||n===``)return null;let r=m_(e,t);return[{type:`paragraph`,children:[{type:`link`,url:n,title:p_(e,`title`,t)??null,children:[{type:`text`,value:r}]}]}]}function __(e,t){let n={type:`strong`,children:[{type:`text`,value:m_(e,t)}]};return e.type,[{type:`paragraph`,children:[n]}]}function v_(e,t){let n={type:`emphasis`,children:[{type:`text`,value:m_(e,t)}]};return e.type,[{type:`paragraph`,children:[n]}]}function y_(e,t){let n=p_(e,`src`,t);if(n==null||n===``)return null;let r={type:`image`,url:n,alt:p_(e,`alt`,t)??``,title:p_(e,`title`,t)??null};return e.type,[{type:`paragraph`,children:[r]}]}function b_(e,t){return[{type:`blockquote`,children:[{type:`paragraph`,children:[{type:`text`,value:m_(e,t)}]}]}]}function x_(e){return e==null?!1:JSON.stringify(e).includes(`"JSX`)}async function S_(e,t,n){let r=e.data?.estree;if(r==null||r.body.length===0)return[];let i=r.body[0];return i?.type===`ExpressionStatement`?C_(i.expression,t,n):[]}async function C_(e,t,n){return e.type===`JSXElement`?k_(e,t,n):e.type===`JSXFragment`?A_(e,t,n):e.type===`LogicalExpression`?w_(e,t,n):e.type===`ConditionalExpression`?T_(e,t,n):e.type===`SequenceExpression`?E_(e,t,n):e.type===`ArrayExpression`?D_(e,t,n):z_(e,t)}async function w_(e,t,n){let r=await O_(e.left,t,n);return e.operator===`&&`?L_(r)?C_(e.right,t,n):[]:e.operator===`||`?L_(r)?I_(e.left)?C_(e.left,t,n):R_(r):C_(e.right,t,n):e.operator===`??`?r==null?C_(e.right,t,n):I_(e.left)?C_(e.left,t,n):R_(r):[]}async function T_(e,t,n){return L_(await O_(e.test,t,n))?C_(e.consequent,t,n):C_(e.alternate,t,n)}async function E_(e,t,n){let r=[];for(let i of e.expressions){let e=await C_(i,t,n);r.push(...e)}return r}async function D_(e,t,n){let r=[];for(let i of e.elements)if(i!=null)if(i.type===`SpreadElement`){let e=await C_(i.argument,t,n);r.push(...e)}else{let e=await C_(i,t,n);r.push(...e)}return r}async function O_(e,t,n){if(I_(e))return!0;if(e.type===`Literal`)return e.value;if(e.type===`Identifier`)return e.name===`undefined`?void 0:e.name===`NaN`?NaN:e.name===`Infinity`?1/0:t.scope[e.name];if(e.type===`UnaryExpression`){let r=await O_(e.argument,t,n);return e.operator===`!`?!L_(r):e.operator===`-`?-r:e.operator===`+`?+r:e.operator===`typeof`?typeof r:void 0}if(e.type===`BinaryExpression`){let r=await O_(e.left,t,n),i=await O_(e.right,t,n);return e.operator===`===`?r===i:e.operator===`!==`?r!==i:e.operator===`==`?r===i:e.operator===`!=`?r!==i:e.operator===`<`?r<i:e.operator===`<=`?r<=i:e.operator===`>`?r>i:e.operator===`>=`?r>=i:e.operator===`+`?r+i:e.operator===`-`?r-i:e.operator===`*`?r*i:e.operator===`/`?r/i:e.operator===`%`?r%i:void 0}if(e.type===`LogicalExpression`){let r=await O_(e.left,t,n);return e.operator===`&&`?L_(r)?O_(e.right,t,n):r:e.operator===`||`?L_(r)?r:O_(e.right,t,n):e.operator===`??`?r??O_(e.right,t,n):void 0}if(e.type===`MemberExpression`){let r=await O_(e.object,t,n);if(r==null)return;if(e.computed)return r[await O_(e.property,t,n)];let{name:i}=e.property;return r[i]}if(e.type===`ConditionalExpression`)return L_(await O_(e.test,t,n))?O_(e.consequent,t,n):O_(e.alternate,t,n);let r=F_(e);if(r!==``)try{let e=a_(r,t.scope);return e===`true`?!0:e===`false`?!1:e===`null`?null:e===`undefined`||e===``?void 0:/^-?\d+(?:\.\d+)?$/.test(e)?Number(e):e}catch{return}}async function k_(e,t,n){let r=M_(e,t);if(r.name!=null&&l_(r.name,t)){let{processAst:e}=await Promise.resolve().then(()=>B_);return d_(r,t,e)}return f_(r,t)??(r.children.length>0?n(r.children,t):[])}async function A_(e,t,n){let r=[];for(let i of e.children){let e=await j_(i,t,n);r.push(...e)}return r}async function j_(e,t,n){if(e.type===`JSXElement`)return k_(e,t,n);if(e.type===`JSXFragment`)return A_(e,t,n);if(e.type===`JSXText`){let t=e.value.trim();return t===``?[]:[{type:`paragraph`,children:[{type:`text`,value:t}]}]}return e.type===`JSXExpressionContainer`?e.expression.type===`JSXEmptyExpression`?[]:C_(e.expression,t,n):e.type===`JSXSpreadChild`?C_(e.expression,t,n):[]}function M_(e,t){let n=e.openingElement,r=null;n.name.type===`JSXIdentifier`?{name:r}=n.name:n.name.type===`JSXMemberExpression`?r=N_(n.name):n.name.type===`JSXNamespacedName`&&(r=`${n.name.namespace.name}:${n.name.name.name}`);let i=[];for(let e of n.attributes)if(e.type===`JSXAttribute`){let t=e.name.type===`JSXIdentifier`?e.name.name:`${e.name.namespace.name}:${e.name.name.name}`,n=null;e.value==null?n=null:e.value.type===`Literal`?n=String(e.value.value):e.value.type===`JSXExpressionContainer`&&e.value.expression.type!==`JSXEmptyExpression`&&(n={type:`mdxJsxAttributeValueExpression`,value:F_(e.value.expression)}),i.push({type:`mdxJsxAttribute`,name:t,value:n})}else e.type===`JSXSpreadAttribute`&&i.push({type:`mdxJsxExpressionAttribute`,value:`...${F_(e.argument)}`});let a=[];for(let n of e.children){let e=P_(n,t);e!=null&&a.push(...e)}return{type:`mdxJsxFlowElement`,name:r,attributes:i,children:a}}function N_(e){return e.object.type===`JSXIdentifier`?`${e.object.name}.${e.property.name}`:`${N_(e.object)}.${e.property.name}`}function P_(e,t){if(e.type===`JSXText`){let{value:t}=e;return t.trim()===``?null:[{type:`paragraph`,children:[{type:`text`,value:t}]}]}if(e.type===`JSXElement`)return[M_(e,t)];if(e.type===`JSXFragment`){let n=[];for(let r of e.children){let e=P_(r,t);e!=null&&n.push(...e)}return n}return e.type===`JSXExpressionContainer`?e.expression.type===`JSXEmptyExpression`?null:[{type:`paragraph`,children:[{type:`text`,value:F_(e.expression)}]}]:e.type===`JSXSpreadChild`?[{type:`paragraph`,children:[{type:`text`,value:`...${F_(e.expression)}`}]}]:null}function F_(e){if(e.type===`Identifier`)return e.name;if(e.type===`Literal`)return typeof e.value==`string`?JSON.stringify(e.value):String(e.value);if(e.type===`MemberExpression`){let t=F_(e.object);return e.computed?`${t}[${F_(e.property)}]`:`${t}.${e.property.name}`}if(e.type===`CallExpression`)return`${F_(e.callee)}(${e.arguments.map(e=>F_(e)).join(`, `)})`;if(e.type===`BinaryExpression`||e.type===`LogicalExpression`){let t=F_(e.left),n=F_(e.right);return`(${t} ${e.operator} ${n})`}if(e.type===`UnaryExpression`){let t=F_(e.argument);return`${e.operator}${t}`}if(e.type===`ConditionalExpression`)return`(${F_(e.test)} ? ${F_(e.consequent)} : ${F_(e.alternate)})`;if(e.type===`ArrayExpression`)return`[${e.elements.filter(e=>e!=null&&e.type!==`SpreadElement`).map(e=>F_(e)).join(`, `)}]`;if(e.type===`ObjectExpression`)return`{${e.properties.filter(e=>e.type===`Property`).map(e=>`${e.key.type===`Identifier`?e.key.name:F_(e.key)}: ${F_(e.value)}`).join(`, `)}}`;if(e.type===`TemplateLiteral`){let t="`";for(let n=0;n<e.quasis.length;n++)t+=e.quasis[n]?.value.raw??``,n<e.expressions.length&&(t+=`\${${F_(e.expressions[n])}}`);return t+="`",t}return e.type===`SpreadElement`?`...${F_(e.argument)}`:``}function I_(e){return e.type===`JSXElement`||e.type===`JSXFragment`}function L_(e){return!!e}function R_(e){if(e==null)return[];let t=typeof e==`string`?e:String(e);return t===``||t===`undefined`||t===`null`?[]:[{type:`paragraph`,children:[{type:`text`,value:t}]}]}function z_(e,t){let n=F_(e);if(n===``)return[];try{return R_(a_(n,t.scope))}catch{return[]}}var B_=e_({processAst:()=>H_});function V_(e){if(!(e.includes(`/`)&&/\.\w+$/.test(e)))return e;let t=e.lastIndexOf(`/`);return e.slice(t+1)}async function H_(e,t){return U_(e,t)}async function U_(e,t){let n=[];for(let r of e.children){let e=await W_(r,t);n.push(...e)}return{type:`root`,children:n}}async function W_(e,t){if(e.type===`mdxjsEsm`)return[];if(e.type===`mdxFlowExpression`){let n=e,r=n.data?.estree,i=n.value.trim();if(i.startsWith(`/*`)&&i.endsWith(`*/`))return[];if(x_(r))return S_(n,t,async(e,t)=>(await H_({type:`root`,children:e},t)).children);let a=a_(n.value,t.scope);return a===``?[]:[{type:`paragraph`,children:[{type:`text`,value:a}]}]}if(e.type===`mdxJsxFlowElement`)return G_(e,t);if(e.type===`link`){let n=e,r=(await K_(n.children,t)).map(e=>e.type===`text`?{...e,value:V_(e.value)}:e);return[{...n,children:r}]}if(!(`children`in e&&Array.isArray(e.children)))return[e];let n=await K_(e.children,t);return[{...e,children:n}]}async function G_(e,t){return e.name!=null&&l_(e.name,t)?d_(e,t,H_):f_(e,t)??[]}async function K_(e,t){let n=[];for(let r of e){if(r.type===`mdxTextExpression`){let e=r,i=e.value.trim();if(i.startsWith(`/*`)&&i.endsWith(`*/`))continue;let a={type:`text`,value:a_(e.value,t.scope)};n.push(a);continue}if(r.type===`mdxJsxTextElement`){let e=r;if(e.name!=null&&l_(e.name,t)){let r=await d_(e,t,H_);for(let e of r)e.type===`paragraph`&&`children`in e?n.push(...e.children):n.push(e);continue}let i=f_(e,t);if(i!=null)for(let e of i)e.type===`paragraph`&&`children`in e?n.push(...e.children):n.push(e);continue}if(`children`in r&&Array.isArray(r.children)){let e=await K_(r.children,t);if(r.type===`link`){let t=e.map(e=>e.type===`text`?{...e,value:V_(e.value)}:e);n.push({...r,children:t});continue}n.push({...r,children:e});continue}n.push(r)}return n}function q_(e){let t=this;t.compiler=n;function n(n){return Bo(n,{...t.data(`settings`),...e,extensions:t.data(`toMarkdownExtensions`)||[]})}}function J_(e,t={}){let n={},{yamlFrontMatter:r,scope:i,filePath:a}=t;for(let t of e){let e=Y_(t,i,a);Object.assign(n,e)}let o=Object.keys(n).length>0,s=r!=null&&Object.keys(r).length>0,c;return c=o&&s?`mixed`:o?`export`:`yaml`,{fields:{...r,...n},source:c}}function Y_(e,t,n){let r={},i=e.value.trim(),a=/^export\s+default\s+/.exec(i);if(a!=null){let e=a[0].length,o=X_(i,e);if(o!=null)try{let e=Z_(o.trim(),t,n);typeof e==`object`&&e&&!Array.isArray(e)&&Object.assign(r,e)}catch(e){let t=e instanceof Error?e.message:String(e),r=n==null?``:` in file "${n}"`;throw Error(`Cannot statically evaluate export default${r}: ${t}`)}return r}let o=/export\s+const\s+(\w+)\s*=\s*/g,s=o.exec(i);for(;s!==null;){let e=s[1];if(e==null){s=o.exec(i);continue}let a=X_(i,s.index+s[0].length);if(a==null){s=o.exec(i);continue}try{let i=Z_(a.trim(),t,n);e===`metadata`&&typeof i==`object`&&i&&!Array.isArray(i)?Object.assign(r,i):r[e]=i}catch(t){let r=t instanceof Error?t.message:String(t),i=n==null?``:` in file "${n}"`;throw Error(`Cannot statically evaluate export "${e}"${i}: ${r}`)}s=o.exec(i)}return r}function X_(e,t){let n=0,r=null,i=!1,a=t;for(let o=t;o<e.length;o++){let t=e[o];if(i){i=!1;continue}if(t===`\\`){i=!0;continue}if(r!=null){t===r&&(r=null);continue}if(t===`"`||t===`'`||t==="`"){r=t;continue}if(t===`{`||t===`[`){n++;continue}if(t===`}`||t===`]`){n--;continue}if(n===0){if(t===`;`||t===`
873
1198
  `){a=o;break}if(t===`/`&&o+1<e.length&&e[o+1]===`/`){a=o;break}}o===e.length-1&&(a=e.length)}a<=t&&(a=e.length);let o=e.slice(t,a).trim();return o.endsWith(`;`)?o.slice(0,-1).trim():o}function Z_(e,t,n){let r=e.trim();if(r===``)throw Error(`Empty value cannot be evaluated`);if(r===`true`)return!0;if(r===`false`)return!1;if(r===`null`)return null;if(/^-?\d+(?:\.\d+)?$/.test(r))return Number(r);if(r.startsWith(`"`)&&r.endsWith(`"`))return Q_(r.slice(1,-1),`"`);if(r.startsWith(`'`)&&r.endsWith(`'`))return Q_(r.slice(1,-1),`'`);if(r.startsWith("`")&&r.endsWith("`")){let e=r.slice(1,-1);if(e.includes("${"))throw Error(`Template literal with expressions cannot be statically evaluated: ${r}`);return Q_(e,"`")}if(r.startsWith(`[`)&&r.endsWith(`]`))return ev(r,t,n);if(r.startsWith(`{`)&&r.endsWith(`}`))return tv(r,t,n);if(/^[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*$/i.test(r))return $_(r,t,n);let i=n==null?``:` in file "${n}"`;throw Error(`Expression "${r}" cannot be statically evaluated${i}`)}function Q_(e,t){return e.replaceAll(`\\n`,`
874
1199
  `).replaceAll(`\\r`,`\r`).replaceAll(`\\t`,` `).replaceAll(`\\"`,`"`).replaceAll(`\\'`,`'`).replaceAll(`\\\\`,`\\`)}function $_(e,t,n){if(t==null){let t=n==null?``:` in file "${n}"`;throw Error(`Variable reference "${e}" cannot be resolved without scope${t}`)}let r=e.split(`.`),i=r[0];if(i==null||!(i in t)){let r=n==null?``:` in file "${n}"`,a=Object.keys(t).join(`, `);throw Error(`Undefined namespace "${i}" in expression "${e}"${r}. Available: ${a}`)}let a=t[i];for(let t=1;t<r.length;t++){let i=r[t];if(i==null)continue;if(a==null){let t=n==null?``:` in file "${n}"`;throw Error(`Cannot read property "${i}" of null/undefined in "${e}"${t}`)}if(typeof a!=`object`){let t=n==null?``:` in file "${n}"`;throw Error(`Cannot read property "${i}" of ${typeof a} in "${e}"${t}`)}let o=a;if(!(i in o)){let t=n==null?``:` in file "${n}"`,r=Object.keys(o).join(`, `);throw Error(`Undefined property "${i}" in "${e}"${t}. Available: ${r}`)}a=o[i]}if(typeof a==`string`||typeof a==`number`||typeof a==`boolean`||a===null||Array.isArray(a)||typeof a==`object`)return a;let o=n==null?``:` in file "${n}"`;throw Error(`Variable "${e}" resolved to unsupported type: ${typeof a}${o}`)}function ev(e,t,n){let r=e.slice(1,-1).trim();if(r===``)return[];if(t==null)try{let t=nv(e),n=JSON.parse(t);if(Array.isArray(n))return n}catch{}return rv(r).map(e=>Z_(e.trim(),t,n))}function tv(e,t,n){let r=e.slice(1,-1).trim();if(r===``)return{};if(t==null)try{let t=nv(e),n=JSON.parse(t);if(typeof n==`object`&&n&&!Array.isArray(n))return n}catch{}let i={},a=iv(r);for(let e of a){let r=av(e);if(r===-1)continue;let a=e.slice(0,r).trim(),o=e.slice(r+1).trim();(a.startsWith(`"`)&&a.endsWith(`"`)||a.startsWith(`'`)&&a.endsWith(`'`))&&(a=a.slice(1,-1)),i[a]=Z_(o,t,n)}return i}function nv(e){let t=``,n=null,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(r){t+=a,r=!1;continue}if(a===`\\`){t+=a,r=!0;continue}if(n!=null){a===n?(t+=`"`,n=null):a===`"`&&n===`'`?t+=`\\"`:t+=a;continue}if(a===`"`||a===`'`){t+=`"`,n=a;continue}if(a===`:`&&i>0){let e=t.length-1;for(;e>=0&&/\s/.test(t.charAt(e));)e--;let n=e+1;for(;e>=0&&/[\w$]/.test(t.charAt(e));)e--;if(e++,e>0&&t.charAt(e-1)!==`"`){let r=t.slice(e,n);r.length>0&&/^[\w$]+$/.test(r)&&(t=`${t.slice(0,e)}"${r}"`)}}t+=a}return t}function rv(e){let t=[],n=``,r=0,i=null,a=!1;for(let o of e){if(a){n+=o,a=!1;continue}if(o===`\\`){n+=o,a=!0;continue}if(i!=null){n+=o,o===i&&(i=null);continue}if(o===`"`||o===`'`||o==="`"){n+=o,i=o;continue}if(o===`[`||o===`{`){r++,n+=o;continue}if(o===`]`||o===`}`){r--,n+=o;continue}if(o===`,`&&r===0){n.trim()!==``&&t.push(n.trim()),n=``;continue}n+=o}return n.trim()!==``&&t.push(n.trim()),t}function iv(e){return rv(e)}function av(e){let t=null,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){n=!1;continue}if(i===`\\`){n=!0;continue}if(t!=null){i===t&&(t=null);continue}if(i===`"`||i===`'`||i==="`"){t=i;continue}if(i===`:`)return r}return-1}function ov(e,t){let n=e.attributes.find(e=>e.type===`mdxJsxAttribute`&&e.name===`when`);if(n?.type!==`mdxJsxAttribute`)return!0;if(typeof n.value==`string`)return n.value===`true`;if(n.value!=null&&typeof n.value==`object`&&n.value.type===`mdxJsxAttributeValueExpression`)try{let e=a_(n.value.value,t.scope);return e===`true`||e===`1`}catch{return!1}return!1}async function sv(e,t,n){return!ov(e,t)||e.children.length===0?[]:n(e.children,t)}async function cv(e,t){if(!ov(e,t)||e.children.length===0)return[];let n=lv(e.children,t);return n===``?[]:[{type:`text`,value:n}]}function lv(e,t){let n=``;for(let r of e)if(r.type===`text`)n+=r.value;else if(r.type===`mdxTextExpression`)try{n+=a_(r.value,t.scope)}catch{}else `children`in r&&Array.isArray(r.children)&&(n+=lv(r.children,t));return n}function uv(){n_(`Md`,sv),n_(`Md.Line`,cv)}uv();function dv(e,t){let n={};if(e!=null&&(n.os={...e.os},n.env={...e.env},n.profile={...e.profile},n.tool={...e.tool}),t!=null)for(let[e,r]of Object.entries(t)){let t=n[e];n[e]=typeof r==`object`&&r&&!Array.isArray(r)&&typeof t==`object`&&t&&!Array.isArray(t)?{...t,...r}:r}return n}async function fv(e,t){let n=dh(e),r=dv(t?.globalScope,t?.scope),i=r_(),a;if(t?.extractMetadata===!0){let e=n.children.find(e=>e.type===`yaml`),i;if(e!=null)try{i=Og.parse(e.value)}catch{}a=J_(n.children.filter(e=>e.type===`mdxjsEsm`),{...i!=null&&{yamlFrontMatter:i},scope:r,...t?.basePath!=null&&{filePath:t.basePath}}),n.children=n.children.filter(e=>e.type!==`yaml`&&e.type!==`mdxjsEsm`)}let o=await H_(n,{scope:r,components:i,processingStack:[],...t?.basePath!=null&&{basePath:t.basePath}}),s=pu().use(ii,[`yaml`]).use(ql).use(q_,{bullet:`-`,fence:"`",fences:!0,emphasis:`*`,strong:`*`,rule:`-`,handlers:{text(e){return e.value}}}).stringify(o).trim();return t?.extractMetadata===!0&&a!=null?{content:s,metadata:a}:s}var pv=class extends Pg{commandsSubDir;agentsSubDir;skillsSubDir;supportsFastCommands;supportsSubAgents;supportsSkills;toolPreset;constructor(e,t){super(e,t),this.commandsSubDir=t.commandsSubDir??`commands`,this.agentsSubDir=t.agentsSubDir??`agents`,this.skillsSubDir=t.skillsSubDir??`skills`,this.supportsFastCommands=t.supportsFastCommands??!0,this.supportsSubAgents=t.supportsSubAgents??!0,this.supportsSkills=t.supportsSkills??!0,t.toolPreset!==void 0&&(this.toolPreset=t.toolPreset)}async registerGlobalOutputDirs(e){let t=this.getGlobalConfigDir(),n=[],r=[];this.supportsFastCommands&&r.push(this.commandsSubDir),this.supportsSubAgents&&r.push(this.agentsSubDir),this.supportsSkills&&r.push(this.skillsSubDir);for(let e of r)n.push(this.createRelativePath(e,t,()=>e));return n}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace,r=[];if(this.supportsFastCommands&&r.push(this.commandsSubDir),this.supportsSubAgents&&r.push(this.agentsSubDir),this.supportsSkills&&r.push(this.skillsSubDir),r.length===0)return[];for(let e of n)if(e.dirFromWorkspacePath!=null)for(let n of r){let r=i.join(e.dirFromWorkspacePath.path,this.globalConfigDir,n);t.push(this.createRelativePath(r,e.dirFromWorkspacePath.basePath,()=>n))}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,this.outputFileName)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,this.outputFileName));return t}async registerGlobalOutputFiles(e){let{globalMemory:t}=e.collectedInputContext;if(t==null)return[];let n=this.getGlobalConfigDir(),r=[this.createRelativePath(this.outputFileName,n,()=>this.globalConfigDir)],{fastCommands:a,subAgents:o,skills:s}=e.collectedInputContext,c={includeSeriesPrefix:!0};if(this.supportsFastCommands&&a!=null)for(let e of a){let t=this.transformFastCommandName(e,c);r.push(this.createRelativePath(i.join(this.commandsSubDir,t),n,()=>this.commandsSubDir))}if(this.supportsSubAgents&&o!=null)for(let e of o){let t=e.dir.path.endsWith(`.md`)?e.dir.path:`${e.dir.path}.md`;r.push(this.createRelativePath(i.join(this.agentsSubDir,t),n,()=>this.agentsSubDir))}if(this.supportsSkills&&s!=null)for(let e of s){let t=e.yamlFrontMatter?.name??e.dir.getDirectoryName(),a=i.join(this.skillsSubDir,t);if(r.push(this.createRelativePath(i.join(a,`SKILL.md`),n,()=>t)),e.childDocs!=null)for(let o of e.childDocs){let e=o.dir.path.replace(/\.mdx$/,`.md`),s=i.join(a,e);r.push(this.createRelativePath(s,n,()=>t))}if(e.resources!=null)for(let o of e.resources){let e=i.join(a,o.relativePath);r.push(this.createRelativePath(e,n,()=>t))}}return r}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=this.supportsFastCommands&&(r?.length??0)>0,l=this.supportsSubAgents&&(i?.length??0)>0,u=this.supportsSkills&&(a?.length??0)>0;return o||s||c||l||u?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!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}}async writeGlobalOutputs(e){let{globalMemory:t}=e.collectedInputContext,n=[],r=[];if([{enabled:!0,data:t},{enabled:this.supportsFastCommands,data:e.collectedInputContext.fastCommands},{enabled:this.supportsSubAgents,data:e.collectedInputContext.subAgents},{enabled:this.supportsSkills,data:e.collectedInputContext.skills}].every(e=>!e.enabled||e.data==null))return{files:n,dirs:r};let{fastCommands:a,subAgents:o,skills:s}=e.collectedInputContext,c=this.getGlobalConfigDir();if(t!=null){let r=i.join(c,this.outputFileName),a=this.createRelativePath(this.outputFileName,c,()=>this.globalConfigDir);if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`globalMemory`,path:r}),n.push({path:a,success:!0,skipped:!1});else try{ut(r,t.content),this.log.trace({action:`write`,type:`globalMemory`,path:r}),n.push({path:a,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalMemory`,path:r,error:t}),n.push({path:a,success:!1,error:e})}}if(this.supportsFastCommands&&a!=null)for(let t of a){let r=await this.writeFastCommand(e,c,t);n.push(...r)}if(this.supportsSubAgents&&o!=null)for(let t of o){let r=await this.writeSubAgent(e,c,t);n.push(...r)}if(this.supportsSkills&&s!=null)for(let t of s){let r=await this.writeSkill(e,c,t);n.push(...r)}return{files:n,dirs:r}}async writeFastCommand(e,t,n){let r=this.getTransformOptionsFromContext(e),a=this.transformFastCommandName(n,r),o=i.join(t,this.commandsSubDir),s=i.join(o,a),c=n.content,l=n.yamlFrontMatter,u=!1;if(n.rawMdxContent!=null&&this.toolPreset!=null){this.log.debug(`recompiling fast command with tool preset`,{file:n.dir.getAbsolutePath(),toolPreset:this.toolPreset,hasRawContent:!0});try{let e=new sr({toolPreset:this.toolPreset}).collect(),t=await fv(n.rawMdxContent,{globalScope:e,extractMetadata:!0,basePath:n.dir.basePath});c=t.content,l=t.metadata.fields,u=!0}catch(e){this.log.warn(`failed to recompile fast command, using default`,{file:n.dir.getAbsolutePath(),error:e instanceof Error?e.message:String(e)})}}let d=u?this.buildMarkdownContent(c,l):this.buildMarkdownContentWithRaw(c,l,n.rawFrontMatter);return[await this.writeFile(e,s,d,`fastCommand`)]}async writeSubAgent(e,t,n){let r=n.dir.path.endsWith(`.md`)?n.dir.path:`${n.dir.path}.md`,a=i.join(t,this.agentsSubDir),o=i.join(a,r),s=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);return[await this.writeFile(e,o,s,`subAgent`)]}async writeSkill(e,t,n){let r=[],a=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),o=i.join(t,this.skillsSubDir,a),s=i.join(o,`SKILL.md`),c=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter),l=await this.writeFile(e,s,c,`skill`);if(r.push(l),n.childDocs!=null)for(let i of n.childDocs){let n=await this.writeSkillReferenceDocument(e,o,a,i,t);r.push(...n)}if(n.resources!=null)for(let i of n.resources){let n=await this.writeSkillResource(e,o,a,i,t);r.push(...n)}return r}async writeSkillReferenceDocument(e,t,n,r,a){let o=r.dir.path.replace(/\.mdx$/,`.md`),s=i.join(t,o);return[await this.writeFile(e,s,r.content,`skillRefDoc`)]}async writeSkillResource(e,t,n,r,a){let o=i.join(t,r.relativePath);return[await this.writeFile(e,o,r.content,`skillResource`)]}},mv=class extends pv{constructor(){super(`ClaudeCodeCLIOutputPlugin`,{globalConfigDir:`.claude`,outputFileName:`CLAUDE.md`,toolPreset:`claudeCode`,supportsFastCommands:!0,supportsSubAgents:!0,supportsSkills:!0})}};const hv=`AGENTS.md`,gv=`.codex`,_v=`prompts`,vv=`skills`;var yv=class extends Pg{constructor(){super(`CodexCLIOutputPlugin`,{globalConfigDir:gv,outputFileName:hv,dependsOn:[`AgentsOutputPlugin`]})}async registerProjectOutputDirs(){return[]}async registerProjectOutputFiles(){return[]}async registerGlobalOutputDirs(e){let t=this.getGlobalConfigDir(),n=[this.createRelativePath(_v,t,()=>_v)],{skills:r}=e.collectedInputContext;if(r!=null&&r.length>0)for(let e of r){let r=e.yamlFrontMatter?.name??e.dir.getDirectoryName();n.push(this.createRelativePath(i.join(vv,r),t,()=>r))}return n}async registerGlobalOutputFiles(){let e=this.getGlobalConfigDir();return[this.createRelativePath(hv,e,()=>gv)]}async canWrite(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext;return t!=null||(n?.length??0)>0||(r?.length??0)>0?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(){return{files:[],dirs:[]}}async writeGlobalOutputs(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,a=[],o=this.getGlobalConfigDir();if(t!=null){let n=i.join(o,hv),r=await this.writeFile(e,n,t.content,`globalMemory`);a.push(r)}if(n!=null&&n.length>0)for(let t of n){let n=await this.writeGlobalFastCommand(e,o,t);a.push(n)}if(r!=null&&r.length>0)for(let t of r){let n=await this.writeGlobalSkill(e,o,t);a.push(...n)}return{files:a,dirs:[]}}async writeGlobalFastCommand(e,t,n){let r=this.getTransformOptionsFromContext(e),a=this.transformFastCommandName(n,r),o=i.join(t,_v,a),s=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);return this.writeFile(e,o,s,`globalFastCommand`)}async writeGlobalSkill(e,t,n){let r=[],a=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),o=i.join(t,vv,a),s=i.join(o,`SKILL.md`),c=this.buildCodexSkillContent(n),l=await this.writeFile(e,s,c,`globalSkill`);if(r.push(l),n.childDocs!=null)for(let t of n.childDocs){let n=t.dir.path.replace(/\.mdx$/,`.md`),a=i.join(o,n),s=await this.writeFile(e,a,t.content,`skillRefDoc`);r.push(s)}if(n.resources!=null)for(let t of n.resources){let n=i.join(o,t.relativePath),a=await this.writeFile(e,n,t.content,`skillResource`);r.push(a)}return r}buildCodexSkillContent(e){let t=e.yamlFrontMatter,n=this.normalizeSkillName(t.name,64),r=this.normalizeToSingleLine(t.description,1024),i={};t.displayName!=null&&(i[`short-description`]=t.displayName),t.version!=null&&(i.version=t.version),t.author!=null&&(i.author=t.author),t.keywords!=null&&t.keywords.length>0&&(i.keywords=[...t.keywords]);let a={name:n,description:r};return Object.keys(i).length>0&&(a.metadata=i),t.allowTools!=null&&t.allowTools.length>0&&(a[`allowed-tools`]=t.allowTools.join(` `)),Ag(a,e.content)}normalizeSkillName(e,t){let n=e.toLowerCase().replaceAll(/[^a-z0-9-]/g,`-`).replaceAll(/-+/g,`-`).replaceAll(/^-+|-+$/g,``);return n.length>t&&(n=n.slice(0,t).replace(/-+$/,``)),n}normalizeToSingleLine(e,t){let n=e.replaceAll(/[\r\n]+/g,` `).replaceAll(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-3)}...`:n}};const bv=`.cursor`,xv=`mcp.json`,Sv=`commands`,Cv=`rules`,wv=`global.mdc`,Tv=`skills-cursor`,Ev=`SKILL.md`,Dv=new Set([`create-rule`,`create-skill`,`create-subagent`,`migrate-to-skills`,`update-cursor-settings`]);var Ov=class extends Pg{constructor(){super(`CursorOutputPlugin`,{globalConfigDir:bv,outputFileName:``,dependsOn:[`AgentsOutputPlugin`]}),this.registerCleanEffect(`mcp-config-cleanup`,async e=>{let t=this.getGlobalConfigDir(),n=i.join(t,xv),a={mcpServers:{}};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfigCleanup`,path:n}),{success:!0,description:`Would reset mcp.json to empty shell`};try{return this.ensureDirectory(t),r.writeFileSync(n,JSON.stringify(a,null,2)),this.log.trace({action:`clean`,type:`mcpConfigCleanup`,path:n}),{success:!0,description:`Reset mcp.json to empty shell`}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`clean`,type:`mcpConfigCleanup`,path:n,error:t}),{success:!1,error:e,description:`Failed to reset mcp.json`}}})}async registerGlobalOutputDirs(e){let t=[],n=this.getGlobalConfigDir(),{fastCommands:r,skills:a}=e.collectedInputContext;if(r!=null&&r.length>0){let e=this.getGlobalCommandsDir();t.push({pathKind:L.Relative,path:Sv,basePath:n,getDirectoryName:()=>Sv,getAbsolutePath:()=>e})}if(a!=null&&a.length>0)for(let e of a){let r=e.yamlFrontMatter.name;if(this.isPreservedSkill(r))continue;let a=i.join(n,Tv,r);t.push({pathKind:L.Relative,path:i.join(Tv,r),basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>a})}return t}async registerGlobalOutputFiles(e){let t=[],n=this.getGlobalConfigDir(),{skills:r,fastCommands:a}=e.collectedInputContext;if(r?.some(e=>e.mcpConfig!=null)??!1){let e=i.join(n,xv);t.push({pathKind:L.Relative,path:xv,basePath:n,getDirectoryName:()=>bv,getAbsolutePath:()=>e})}if(a!=null&&a.length>0){let r=this.getGlobalCommandsDir(),o=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});for(let e of a){let a=this.transformFastCommandName(e,o),s=i.join(r,a);t.push({pathKind:L.Relative,path:i.join(Sv,a),basePath:n,getDirectoryName:()=>Sv,getAbsolutePath:()=>s})}}if(r==null||r.length===0)return t;let o=this.getSkillsCursorDir();for(let e of r){let r=e.yamlFrontMatter.name;if(this.isPreservedSkill(r))continue;let a=i.join(o,r);if(t.push({pathKind:L.Relative,path:i.join(Tv,r,Ev),basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>i.join(a,Ev)}),e.mcpConfig!=null&&t.push({pathKind:L.Relative,path:i.join(Tv,r,xv),basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>i.join(a,xv)}),e.childDocs!=null)for(let o of e.childDocs){let e=o.relativePath.replace(/\.mdx$/,`.md`);t.push({pathKind:L.Relative,path:i.join(Tv,r,e),basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>i.join(a,e)})}if(e.resources!=null)for(let o of e.resources)t.push({pathKind:L.Relative,path:i.join(Tv,r,o.relativePath),basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>i.join(a,o.relativePath)})}return t}async registerProjectOutputDirs(e){let t=[],{workspace:n,globalMemory:r}=e.collectedInputContext;if(r==null)return t;for(let e of n.projects){let n=e.dirFromWorkspacePath;n!=null&&t.push(this.createProjectRulesDirRelativePath(n))}return t}async registerProjectOutputFiles(e){let t=[],{workspace:n,globalMemory:r}=e.collectedInputContext;if(r==null)return t;for(let e of n.projects){let n=e.dirFromWorkspacePath;n!=null&&t.push(this.createProjectRuleFileRelativePath(n,wv))}return t}async canWrite(e){let{workspace:t,skills:n,fastCommands:r,globalMemory:i}=e.collectedInputContext,a=(n?.length??0)>0,o=(r?.length??0)>0,s=i!=null&&t.projects.some(e=>e.dirFromWorkspacePath!=null);return a||o||s?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeGlobalOutputs(e){let{skills:t,fastCommands:n}=e.collectedInputContext,r=[],i=[];if(t!=null&&t.length>0){let n=await this.writeGlobalMcpConfig(e,t);n!=null&&r.push(n);let i=this.getSkillsCursorDir();for(let n of t){let t=n.yamlFrontMatter.name;if(this.isPreservedSkill(t))continue;let a=await this.writeGlobalSkill(e,i,n);r.push(...a)}}if(n==null||n.length===0)return{files:r,dirs:i};let a=this.getGlobalCommandsDir();for(let t of n){let n=await this.writeGlobalFastCommand(e,a,t);r.push(n)}return{files:r,dirs:i}}async writeProjectOutputs(e){let t=[],n=[],{workspace:r,globalMemory:i}=e.collectedInputContext;if(i==null)return{files:t,dirs:n};let a=this.buildGlobalRuleContent(i.content);for(let n of r.projects){if(n.dirFromWorkspacePath==null)continue;let r=await this.writeProjectGlobalRule(e,n,a);t.push(r)}return{files:t,dirs:n}}createProjectRulesDirRelativePath(e){let t=i.join(e.path,bv,Cv);return{pathKind:L.Relative,path:t,basePath:e.basePath,getDirectoryName:()=>Cv,getAbsolutePath:()=>i.join(e.basePath,t)}}createProjectRuleFileRelativePath(e,t){let n=i.join(e.path,bv,Cv,t);return{pathKind:L.Relative,path:n,basePath:e.basePath,getDirectoryName:()=>Cv,getAbsolutePath:()=>i.join(e.basePath,n)}}buildGlobalRuleContent(e){return Ag({description:`Global prompt (synced)`,alwaysApply:!0},e)}async writeProjectGlobalRule(e,t,n){let r=t.dirFromWorkspacePath,a=i.join(r.basePath,r.path,bv,Cv),o=i.join(a,wv),s=this.createProjectRuleFileRelativePath(r,wv);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalRule`,path:o}),{path:s,success:!0,skipped:!1};try{return this.ensureDirectory(a),this.writeFileSync(o,n),this.log.trace({action:`write`,type:`globalRule`,path:o}),{path:s,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalRule`,path:o,error:t}),{path:s,success:!1,error:e}}}isPreservedSkill(e){return Dv.has(e)}getSkillsCursorDir(){return i.join(this.getGlobalConfigDir(),Tv)}getGlobalCommandsDir(){return i.join(this.getGlobalConfigDir(),Sv)}async writeGlobalFastCommand(e,t,n){let a=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),o=this.transformFastCommandName(n,a),s=i.join(t,o),c={pathKind:L.Relative,path:i.join(Sv,o),basePath:this.getGlobalConfigDir(),getDirectoryName:()=>Sv,getAbsolutePath:()=>s},l=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalFastCommand`,path:s}),{path:c,success:!0,skipped:!1};try{return this.ensureDirectory(t),r.writeFileSync(s,l),this.log.trace({action:`write`,type:`globalFastCommand`,path:s}),{path:c,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalFastCommand`,path:s,error:t}),{path:c,success:!1,error:e}}}async writeGlobalMcpConfig(e,t){let n={};for(let e of t){if(e.mcpConfig==null)continue;let{mcpServers:t}=e.mcpConfig;for(let[e,r]of Object.entries(t))n[e]=this.transformMcpConfigForCursor({...r})}if(Object.keys(n).length===0)return null;let a=this.getGlobalConfigDir(),o=i.join(a,xv),s={pathKind:L.Relative,path:xv,basePath:a,getDirectoryName:()=>bv,getAbsolutePath:()=>o},c={};try{if(this.existsSync(o)){let e=r.readFileSync(o,`utf8`);c=JSON.parse(e)}}catch{c={}}let l={...c.mcpServers??{},...n};c.mcpServers=l;let u=JSON.stringify(c,null,2);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMcpConfig`,path:o,serverCount:Object.keys(n).length}),{path:s,success:!0,skipped:!1};try{return this.ensureDirectory(a),r.writeFileSync(o,u),this.log.trace({action:`write`,type:`globalMcpConfig`,path:o,serverCount:Object.keys(n).length}),{path:s,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalMcpConfig`,path:o,error:t}),{path:s,success:!1,error:e}}}transformMcpConfigForCursor(e){let t={};if(e.command!=null)return t.command=e.command,e.args!=null&&(t.args=e.args),e.env!=null&&(t.env=e.env),t;let n=e.url??e.serverUrl;return n==null?t:(t.url=n,e.headers!=null&&(t.headers=e.headers),t)}async writeGlobalSkill(e,t,n){let r=[],a=n.yamlFrontMatter.name,o=i.join(t,a),s=i.join(o,Ev),c=this.getGlobalConfigDir(),l={pathKind:L.Relative,path:i.join(Tv,a,Ev),basePath:c,getDirectoryName:()=>a,getAbsolutePath:()=>s},u=this.buildSkillFrontMatter(n),d=n.content,f=Ag(u,d);if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`skill`,path:s}),r.push({path:l,success:!0,skipped:!1});else try{this.ensureDirectory(o),this.writeFileSync(s,f),this.log.trace({action:`write`,type:`skill`,path:s}),r.push({path:l,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skill`,path:s,error:t}),r.push({path:l,success:!1,error:e})}if(n.mcpConfig!=null){let t=await this.writeSkillMcpConfig(e,n,o,c);r.push(t)}if(n.childDocs!=null)for(let t of n.childDocs){let n=await this.writeSkillChildDoc(e,t,o,a,c);r.push(n)}if(n.resources!=null)for(let t of n.resources){let n=await this.writeSkillResource(e,t,o,a,c);r.push(n)}return r}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:t.name,description:t.description,...t.displayName!=null&&{displayName:t.displayName},...t.keywords!=null&&t.keywords.length>0&&{keywords:t.keywords},...t.author!=null&&{author:t.author},...t.version!=null&&{version:t.version},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}async writeSkillMcpConfig(e,t,n,r){let a=t.yamlFrontMatter.name,o=i.join(n,xv),s={pathKind:L.Relative,path:i.join(Tv,a,xv),basePath:r,getDirectoryName:()=>a,getAbsolutePath:()=>o},c=t.mcpConfig.rawContent;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfig`,path:o}),{path:s,success:!0,skipped:!1};try{return this.ensureDirectory(n),this.writeFileSync(o,c),this.log.trace({action:`write`,type:`mcpConfig`,path:o}),{path:s,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`mcpConfig`,path:o,error:t}),{path:s,success:!1,error:e}}}async writeSkillChildDoc(e,t,n,r,a){let o=t.relativePath.replace(/\.mdx$/,`.md`),s=i.join(n,o),c={pathKind:L.Relative,path:i.join(Tv,r,o),basePath:a,getDirectoryName:()=>r,getAbsolutePath:()=>s},l=t.content;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`childDoc`,path:s}),{path:c,success:!0,skipped:!1};try{let e=i.dirname(s);return this.ensureDirectory(e),this.writeFileSync(s,l),this.log.trace({action:`write`,type:`childDoc`,path:s}),{path:c,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`childDoc`,path:s,error:t}),{path:c,success:!1,error:e}}}async writeSkillResource(e,t,n,r,a){let o=i.join(n,t.relativePath),s={pathKind:L.Relative,path:i.join(Tv,r,t.relativePath),basePath:a,getDirectoryName:()=>r,getAbsolutePath:()=>o};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`resource`,path:o}),{path:s,success:!0,skipped:!1};try{let e=i.dirname(o);if(this.ensureDirectory(e),t.encoding===`base64`){let e=d.from(t.content,`base64`);this.writeFileSyncBuffer(o,e)}else this.writeFileSync(o,t.content);return this.log.trace({action:`write`,type:`resource`,path:o}),{path:s,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`resource`,path:o,error:t}),{path:s,success:!1,error:e}}}},kv=class extends pv{constructor(){super(`DroidCLIOutputPlugin`,{globalConfigDir:`.factory`,outputFileName:`AGENTS.md`,supportsFastCommands:!0,supportsSubAgents:!0,supportsSkills:!0})}async writeSkill(e,t,n){let r=[],a=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),o=i.join(t,this.skillsSubDir,a),s=i.join(o,`SKILL.md`),c=n.yamlFrontMatter==null?void 0:{name:n.yamlFrontMatter.name,description:n.yamlFrontMatter.description},l=this.buildMarkdownContent(n.content,c),u=await this.writeFile(e,s,l,`skill`);if(r.push(u),n.childDocs!=null)for(let i of n.childDocs){let n=await this.writeSkillReferenceDocument(e,o,a,i,t);r.push(...n)}if(n.resources!=null)for(let i of n.resources){let n=await this.writeSkillResource(e,o,a,i,t);r.push(...n)}return r}},Av=class extends Lg{configKey;extension;constructor(e,t){super(e),this.configKey=t.configKey,this.extension=t.extension??`.mdx`}async collect(e){let{userConfigOptions:t,logger:n,path:r,fs:i,globalScope:a}=e,o=this.resolveBasePaths(t),s=this.getTargetDir(t,o),c=[];if(!(i.existsSync(s)&&i.statSync(s).isDirectory()))return this.createResult(c);try{let e=i.readdirSync(s,{withFileTypes:!0});for(let t of e)if(t.isFile()&&t.name.endsWith(this.extension)){let e=r.join(s,t.name),o=i.readFileSync(e,`utf8`);try{let r=jg(o),i=await fv(o,{globalScope:a,extractMetadata:!0,basePath:s}),l=r.yamlFrontMatter!=null||Object.keys(i.metadata.fields).length>0?{...r.yamlFrontMatter,...i.metadata.fields}:void 0;if(l!=null){let t=this.validateMetadata(l,e);for(let e of t.warnings)n.debug(e);if(!t.valid)throw new Qg([...t.errors],e)}let{content:u}=i;n.debug(`${this.name} metadata extracted`,{file:t.name,source:i.metadata.source,hasYaml:r.yamlFrontMatter!=null,hasExport:Object.keys(i.metadata.fields).length>0});let d=this.createPrompt(t.name,e,u,l,r.rawFrontMatter,r,s,o);c.push(d)}catch(t){n.error(`failed to parse ${this.name} item`,{file:e,error:t})}}}catch(e){n.error(`Failed to scan directory at ${s}`,{error:e})}return this.createResult(c)}},jv=class extends Av{constructor(){super(`FastCommandInputPlugin`,{configKey:`shadowFastCommandDir`})}getTargetDir(e,t){let n=e.shadowFastCommandDir,{workspaceDir:r,shadowProjectDir:i}=t;return this.resolvePath(n,r,i)}validateMetadata(e,t){return It(e,t)}createResult(e){return{fastCommands:e}}extractSeriesInfo(e,t){let n=e.replace(/\.mdx$/,``);if(t!=null)return{series:t,commandName:n};let r=n.indexOf(`_`);return r===-1?{commandName:n}:{series:n.slice(0,Math.max(0,r)),commandName:n.slice(Math.max(0,r+1))}}async collect(e){let{userConfigOptions:t,logger:n,path:r,fs:i}=e,a=this.resolveBasePaths(t),o=this.getTargetDir(t,a),s=[];if(!(i.existsSync(o)&&i.statSync(o).isDirectory()))return this.createResult(s);try{let t=i.readdirSync(o,{withFileTypes:!0});for(let a of t)if(a.isFile()&&a.name.endsWith(this.extension)){let t=await this.processFile(a.name,r.join(o,a.name),o,void 0,e);t!=null&&s.push(t)}else if(a.isDirectory()){let t=r.join(o,a.name);try{let n=i.readdirSync(t,{withFileTypes:!0});for(let i of n)if(i.isFile()&&i.name.endsWith(this.extension)){let n=await this.processFile(i.name,r.join(t,i.name),o,a.name,e);n!=null&&s.push(n)}}catch(e){n.error(`Failed to scan subdirectory at ${t}`,{error:e})}}}catch(e){n.error(`Failed to scan directory at ${o}`,{error:e})}return this.createResult(s)}async processFile(e,t,n,r,i){let{logger:a,globalScope:o}=i,s=i.fs.readFileSync(t,`utf8`);try{let c=jg(s),l=await fv(s,{globalScope:o,extractMetadata:!0,basePath:r==null?n:i.path.join(n,r)}),u=c.yamlFrontMatter!=null||Object.keys(l.metadata.fields).length>0?{...c.yamlFrontMatter,...l.metadata.fields}:void 0;if(u!=null){let e=this.validateMetadata(u,t);for(let t of e.warnings)a.debug(t);if(!e.valid)throw new Qg([...e.errors],t)}let{content:d}=l,f=r==null?e:`${r}/${e}`;return a.debug(`${this.name} metadata extracted`,{file:f,source:l.metadata.source,hasYaml:c.yamlFrontMatter!=null,hasExport:Object.keys(l.metadata.fields).length>0}),this.createPrompt(f,t,d,u,c.rawFrontMatter,c,n,s)}catch(e){a.error(`failed to parse ${this.name} item`,{file:t,error:e});return}}createPrompt(e,t,n,r,i,a,o,s){let c=e.indexOf(`/`),l=c===-1?void 0:e.slice(0,c),u=c===-1?e:e.slice(c+1),d=this.extractSeriesInfo(u,l);return{type:Et.FastCommand,content:n,length:n.length,filePathKind:L.Relative,...r!=null&&{yamlFrontMatter:r},...i!=null&&{rawFrontMatter:i},markdownAst:a.markdownAst,markdownContents:a.markdownContents,dir:{pathKind:L.Relative,path:e,basePath:o,getDirectoryName:()=>e.replace(/\.mdx$/,``),getAbsolutePath:()=>t},...d.series!=null&&{series:d.series},commandName:d.commandName,rawMdxContent:s}}},Mv=class extends pv{constructor(){super(`GeminiCLIOutputPlugin`,{globalConfigDir:`.gemini`,outputFileName:`GEMINI.md`,supportsFastCommands:!1,supportsSubAgents:!1,supportsSkills:!1})}};const Nv=`.skills`,Pv=`.aindex/.skills`,Fv=`SKILL.md`,Iv=`mcp.json`;var Lv=class extends Pg{constructor(){super(`GenericSkillsOutputPlugin`,{globalConfigDir:Pv,outputFileName:Fv}),this.registerCleanEffect(`legacy-global-skills-cleanup`,async e=>{let t=this.joinPath(this.getHomeDir(),`.skills`);if(!this.existsSync(t))return{success:!0,description:`Legacy global skills dir does not exist, nothing to clean`};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`legacyCleanup`,path:t}),{success:!0,description:`Would clean legacy global skills dir: ${t}`};try{let e=this.readdirSync(t,{withFileTypes:!0}),n=0;for(let i of e)if(i.isDirectory()){let e=this.joinPath(t,i.name),a=this.joinPath(e,Fv);this.existsSync(a)&&(r.rmSync(e,{recursive:!0}),n++)}return this.readdirSync(t).length===0&&r.rmdirSync(t),this.log.trace({action:`clean`,type:`legacySkills`,dir:t,cleanedCount:n}),{success:!0,description:`Cleaned ${n} legacy skills from ${t}`}}catch(e){let n=e instanceof Error?e.message:String(e);return this.log.error({action:`clean`,type:`legacySkills`,dir:t,error:n}),{success:!1,description:`Failed to clean legacy skills dir`,error:e}}})}getGlobalSkillsDir(){return this.joinPath(this.getHomeDir(),Pv)}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{skills:r}=e.collectedInputContext;if(r==null||r.length===0)return t;for(let e of n){if(e.dirFromWorkspacePath==null)continue;let n=this.joinPath(e.dirFromWorkspacePath.path,Nv);t.push({pathKind:L.Relative,path:n,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>Nv,getAbsolutePath:()=>this.joinPath(e.dirFromWorkspacePath.basePath,n)})}return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{skills:r}=e.collectedInputContext;if(r==null||r.length===0)return t;for(let e of n){if(e.dirFromWorkspacePath==null)continue;let n=this.joinPath(e.dirFromWorkspacePath.basePath,e.dirFromWorkspacePath.path,Nv);for(let i of r){let r=i.yamlFrontMatter.name,a=this.joinPath(n,r);t.push({pathKind:L.Relative,path:this.joinPath(Nv,r),basePath:this.joinPath(e.dirFromWorkspacePath.basePath,e.dirFromWorkspacePath.path),getDirectoryName:()=>r,getAbsolutePath:()=>a})}}return t}async registerGlobalOutputDirs(e){let{skills:t}=e.collectedInputContext;if(t==null||t.length===0)return[];let n=this.getGlobalSkillsDir();return[{pathKind:L.Relative,path:Pv,basePath:this.getHomeDir(),getDirectoryName:()=>Pv,getAbsolutePath:()=>n}]}async registerGlobalOutputFiles(e){let t=[],{skills:n}=e.collectedInputContext;if(n==null||n.length===0)return t;let r=this.getGlobalSkillsDir();for(let e of n){let n=e.yamlFrontMatter.name,i=this.joinPath(r,n);if(t.push({pathKind:L.Relative,path:this.joinPath(Pv,n,Fv),basePath:this.getHomeDir(),getDirectoryName:()=>n,getAbsolutePath:()=>this.joinPath(i,Fv)}),e.mcpConfig!=null&&t.push({pathKind:L.Relative,path:this.joinPath(Pv,n,Iv),basePath:this.getHomeDir(),getDirectoryName:()=>n,getAbsolutePath:()=>this.joinPath(i,Iv)}),e.childDocs!=null)for(let r of e.childDocs){let e=r.relativePath.replace(/\.mdx$/,`.md`);t.push({pathKind:L.Relative,path:this.joinPath(Pv,n,e),basePath:this.getHomeDir(),getDirectoryName:()=>n,getAbsolutePath:()=>this.joinPath(i,e)})}if(e.resources!=null)for(let r of e.resources)t.push({pathKind:L.Relative,path:this.joinPath(Pv,n,r.relativePath),basePath:this.getHomeDir(),getDirectoryName:()=>n,getAbsolutePath:()=>this.joinPath(i,r.relativePath)})}return t}async canWrite(e){let{skills:t}=e.collectedInputContext,{projects:n}=e.collectedInputContext.workspace;return t==null||t.length===0?(this.log.trace({action:`skip`,reason:`noSkills`}),!1):n.length===0?(this.log.trace({action:`skip`,reason:`noProjects`}),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{skills:n}=e.collectedInputContext,r=[],i=[];if(n==null||n.length===0)return{files:r,dirs:i};let a=this.getGlobalSkillsDir();for(let i of t){if(i.dirFromWorkspacePath==null)continue;let t=this.joinPath(i.dirFromWorkspacePath.basePath,i.dirFromWorkspacePath.path,Nv);for(let o of n){let n=o.yamlFrontMatter.name,s=this.joinPath(a,n),c=this.joinPath(t,n),l={pathKind:L.Relative,path:this.joinPath(Nv,n),basePath:this.joinPath(i.dirFromWorkspacePath.basePath,i.dirFromWorkspacePath.path),getDirectoryName:()=>n,getAbsolutePath:()=>c};if(e.dryRun===!0){this.log.trace({action:`dryRun`,type:`symlink`,target:s,link:c}),r.push({path:l,success:!0,skipped:!1});continue}try{this.createSymlink(s,c,`dir`),this.log.trace({action:`symlink`,type:`skill`,target:s,link:c}),r.push({path:l,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`symlink`,type:`skill`,target:s,link:c,error:t}),r.push({path:l,success:!1,error:e})}}}return{files:r,dirs:i}}async writeGlobalOutputs(e){let{skills:t}=e.collectedInputContext,n=[],r=[];if(t==null||t.length===0)return{files:n,dirs:r};let i=this.getGlobalSkillsDir();for(let r of t){let t=await this.writeSkill(e,r,i);n.push(...t)}return{files:n,dirs:r}}async writeSkill(e,t,n){let r=[],i=t.yamlFrontMatter.name,a=this.joinPath(n,i),o=this.joinPath(a,Fv),s={pathKind:L.Relative,path:Fv,basePath:a,getDirectoryName:()=>i,getAbsolutePath:()=>o},c=this.buildSkillFrontMatter(t),l=t.content,u=Ag(c,l);if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`skill`,path:o}),r.push({path:s,success:!0,skipped:!1});else try{this.ensureDirectory(a),this.writeFileSync(o,u),this.log.trace({action:`write`,type:`skill`,path:o}),r.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skill`,path:o,error:t}),r.push({path:s,success:!1,error:e})}if(t.mcpConfig!=null){let n=await this.writeMcpConfig(e,t,a);r.push(n)}if(t.childDocs!=null)for(let n of t.childDocs){let t=await this.writeChildDoc(e,n,a,i);r.push(t)}if(t.resources!=null)for(let n of t.resources){let t=await this.writeResource(e,n,a,i);r.push(t)}return r}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:t.name,description:t.description,...t.displayName!=null&&{displayName:t.displayName},...t.keywords!=null&&t.keywords.length>0&&{keywords:t.keywords},...t.author!=null&&{author:t.author},...t.version!=null&&{version:t.version},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}async writeMcpConfig(e,t,n){let r=t.yamlFrontMatter.name,i=this.joinPath(n,Iv),a={pathKind:L.Relative,path:Iv,basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>i},o=t.mcpConfig.rawContent;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfig`,path:i}),{path:a,success:!0,skipped:!1};try{return this.ensureDirectory(n),this.writeFileSync(i,o),this.log.trace({action:`write`,type:`mcpConfig`,path:i}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`mcpConfig`,path:i,error:t}),{path:a,success:!1,error:e}}}async writeChildDoc(e,t,n,r){let i=t.relativePath.replace(/\.mdx$/,`.md`),a=this.joinPath(n,i),o={pathKind:L.Relative,path:i,basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>a},s=t.content;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`childDoc`,path:a}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,s),this.log.trace({action:`write`,type:`childDoc`,path:a}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`childDoc`,path:a,error:t}),{path:o,success:!1,error:e}}}async writeResource(e,t,n,r){let i=this.joinPath(n,t.relativePath),a={pathKind:L.Relative,path:t.relativePath,basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>i};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`resource`,path:i}),{path:a,success:!0,skipped:!1};try{let e=this.dirname(i);if(this.ensureDirectory(e),t.encoding===`base64`){let e=d.from(t.content,`base64`);this.writeFileSyncBuffer(i,e)}else this.writeFileSync(i,t.content);return this.log.trace({action:`write`,type:`resource`,path:i}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`resource`,path:i,error:t}),{path:a,success:!1,error:e}}}},Rv=class extends Lg{options;constructor(e,t){super(e),this.options=t??{}}transformContent(e){return e}collect(e){let{shadowProjectDir:t}=this.resolveBasePaths(e.userConfigOptions),n=this.getFilePath(t);if(!e.fs.existsSync(n))return this.options.fallbackContent==null?(this.log.debug({action:`collect`,message:`File not found`,path:n}),{}):(this.log.debug({action:`collect`,message:`Using fallback content`,path:n}),{[this.getResultKey()]:this.transformContent(this.options.fallbackContent)});let r=e.fs.readFileSync(n,`utf8`);return r.length===0?this.options.fallbackContent==null?(this.log.debug({action:`collect`,message:`File is empty`,path:n}),{}):(this.log.debug({action:`collect`,message:`File empty, using fallback`,path:n}),{[this.getResultKey()]:this.transformContent(this.options.fallbackContent)}):(this.log.debug({action:`collect`,message:`Loaded file content`,path:n,length:r.length}),{[this.getResultKey()]:this.transformContent(r)})}},zv=class extends Rv{constructor(){super(`GitExcludeInputPlugin`)}getFilePath(e){return i.join(e,`public`,`exclude`)}getResultKey(){return`shadowGitExclude`}};function Bv(e){let t=i.join(e,`.git`);if(!r.existsSync(t))return null;let n=r.lstatSync(t);if(n.isDirectory())return i.join(t,`info`);if(n.isFile())try{let n=r.readFileSync(t,`utf8`).trim(),a=/^gitdir: (.+)$/.exec(n);if(a?.[1]!=null){let t=i.resolve(e,a[1]);return i.join(t,`info`)}}catch{}return null}function Vv(e,t=5){let n=[],a=new Set([`node_modules`,`.turbo`,`dist`,`build`,`out`,`.cache`]);function o(s,c){if(c>t)return;let l;try{let e=r.readdirSync(s,{withFileTypes:!0});if(!Array.isArray(e))return;l=e}catch{return}l.some(e=>e.name===`.git`)&&s!==e&&n.push(s);for(let e of l)e.isDirectory()&&(e.name===`.git`||a.has(e.name)||o(i.join(s,e.name),c+1))}return o(e,0),n}function Hv(e){let t=i.join(e,`modules`);if(!r.existsSync(t))return[];let n=[];function a(e){let t;try{let n=r.readdirSync(e,{withFileTypes:!0});if(!Array.isArray(n))return;t=n}catch{return}if(t.some(e=>e.name===`info`&&e.isDirectory())&&n.push(i.join(e,`info`)),t.find(e=>e.name===`modules`&&e.isDirectory())!=null){let t;try{let n=r.readdirSync(i.join(e,`modules`),{withFileTypes:!0});if(!Array.isArray(n))return;t=n}catch{return}for(let n of t)n.isDirectory()&&a(i.join(e,`modules`,n.name))}}let o;try{let e=r.readdirSync(t,{withFileTypes:!0});if(!Array.isArray(e))return n;o=e}catch{return n}for(let e of o)e.isDirectory()&&a(i.join(t,e.name));return n}var Uv=class extends Pg{constructor(){super(`GitExcludeOutputPlugin`)}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)continue;let n=e.dirFromWorkspacePath,r=n.getAbsolutePath(),{basePath:a}=n,o=[r,...Vv(r)];for(let e of o){let n=Bv(e);if(n==null)continue;let r=i.join(n,`exclude`),o=i.relative(a,r);t.push({pathKind:L.Relative,path:o,basePath:a,getDirectoryName:()=>i.basename(e),getAbsolutePath:()=>r})}}let a=e.collectedInputContext.workspace.directory.path,o=i.join(a,`.git`);if(r.existsSync(o)&&r.lstatSync(o).isDirectory())for(let e of Hv(o)){let n=i.join(e,`exclude`),r=i.relative(a,n);t.push({pathKind:L.Relative,path:r,basePath:a,getDirectoryName:()=>i.basename(i.dirname(e)),getAbsolutePath:()=>n})}return t}async registerGlobalOutputDirs(){return[]}async registerGlobalOutputFiles(){return[]}async canWrite(e){let{globalGitIgnore:t,shadowGitExclude:n}=e.collectedInputContext;if(!(t!=null&&t.length>0||n!=null&&n.length>0))return this.log.debug({action:`canWrite`,result:!1,reason:`No gitignore or exclude content found`}),!1;let{projects:r}=e.collectedInputContext.workspace,i=r.some(e=>{if(e.dirFromWorkspacePath==null)return!1;let t=e.dirFromWorkspacePath.getAbsolutePath();return Bv(t)==null?Vv(t).some(e=>Bv(e)!=null):!0}),a=e.collectedInputContext.workspace.directory.path,o=Bv(a)!=null,s=i||o;return this.log.debug({action:`canWrite`,result:s,hasGitProjects:i,hasWorkspaceGit:o,reason:s?`Found git repositories to update`:`No git repositories found`}),s}async writeProjectOutputs(e){let t=[],{globalGitIgnore:n,shadowGitExclude:a}=e.collectedInputContext,o=this.buildManagedContent(n,a);if(o.length===0)return this.log.debug({action:`write`,message:`No gitignore or exclude content found, skipping`}),{files:[],dirs:[]};let{workspace:s}=e.collectedInputContext,{projects:c}=s,l=new Set;for(let n of c){if(n.dirFromWorkspacePath==null)continue;let r=n.dirFromWorkspacePath.getAbsolutePath(),a=[r,...Vv(r)];for(let s of a){let a=Bv(s);if(a==null)continue;let c=i.join(a,`exclude`);if(l.has(c))continue;l.add(c);let u=s===r?`project:${n.name??`unknown`}`:`nested:${i.relative(r,s)}`;this.log.info({action:`write`,path:c,label:u});let d=await this.writeGitExcludeFile(e,c,o,u);t.push(d)}}let u=s.directory.path,d=Bv(u);if(d!=null){let n=i.join(d,`exclude`);if(!l.has(n)){this.log.info({action:`write`,path:n,target:`workspace`});let r=await this.writeGitExcludeFile(e,n,o,`workspace`);t.push(r),l.add(n)}}let f=Vv(u);for(let n of f){let r=Bv(n);if(r==null)continue;let a=i.join(r,`exclude`);if(l.has(a))continue;l.add(a);let s=`workspace-nested:${i.relative(u,n)}`;this.log.info({action:`write`,path:a,label:s});let c=await this.writeGitExcludeFile(e,a,o,s);t.push(c)}let p=i.join(u,`.git`);if(r.existsSync(p)&&r.lstatSync(p).isDirectory())for(let n of Hv(p)){let r=i.join(n,`exclude`);if(l.has(r))continue;l.add(r);let a=`git-module:${i.relative(p,n)}`;this.log.info({action:`write`,path:r,label:a});let s=await this.writeGitExcludeFile(e,r,o,a);t.push(s)}return{files:t,dirs:[]}}buildManagedContent(e,t){let n=[];if(e!=null&&e.trim().length>0){let t=this.sanitizeContent(e);t.length>0&&n.push(t)}if(t!=null&&t.trim().length>0){let e=this.sanitizeContent(t);e.length>0&&n.push(e)}return n.length===0?``:n.join(`
875
1200
  `)}sanitizeContent(e){return e.split(/\r?\n/).filter(e=>{let t=e.trim();return t.length===0?!0:!(t.startsWith(`#`)&&!t.startsWith(`\\#`))}).join(`
876
- `).trim()}normalizeContent(e){let t=e.trim();return t.length===0?``:`${t}\n`}async writeGitExcludeFile(e,t,n,a){let o=e.collectedInputContext.workspace.directory.path,s={pathKind:L.Relative,path:i.relative(o,t),basePath:o,getDirectoryName:()=>i.basename(i.dirname(t)),getAbsolutePath:()=>t};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`gitExclude`,path:t,label:a}),{path:s,success:!0,skipped:!1};try{let e=i.dirname(t);r.existsSync(e)||(r.mkdirSync(e,{recursive:!0}),this.log.debug({action:`mkdir`,path:e,message:`Created .git/info directory`}));let o=this.normalizeContent(n);return r.writeFileSync(t,o,`utf8`),this.log.trace({action:`write`,type:`gitExclude`,path:t,label:a}),{path:s,success:!0}}catch(e){let n=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`gitExclude`,path:t,label:a,error:n}),{path:s,success:!1,error:e}}}};function Wv(){return Kt[`public/exclude`]?.content??``}var Gv=class extends Rv{constructor(){super(`GitIgnoreInputPlugin`,{fallbackContent:Wv()})}getFilePath(e){return i.join(e,`public`,`gitignore`)}getResultKey(){return`globalGitIgnore`}},Kv=class extends Lg{constructor(){super(`GlobalMemoryInputPlugin`)}async collect(e){let{userConfigOptions:t,fs:r,path:i,globalScope:a}=e,{workspaceDir:o,shadowProjectDir:c}=this.resolveBasePaths(t),l=t.globalMemoryFile,u=this.resolvePath(l,o,c);if(!r.existsSync(u))return this.log.warn({action:`collect`,reason:`fileNotFound`,path:u}),{};if(!r.statSync(u).isFile())return this.log.warn({action:`collect`,reason:`notAFile`,path:u}),{};let d=r.readFileSync(u,`utf8`),f=jg(d),p;if(a!=null)try{p=await fv(d,{globalScope:a,basePath:i.dirname(u)})}catch(e){throw e instanceof Yg&&(this.log.error(`MDX compilation failed: ${e.message}`),this.log.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),this.log.error(`For example, if using {profile.name}, add a "profile" section with "name" field to your config.`),n.exit(1)),e}else p=f.contentWithoutFrontMatter;return this.log.debug({action:`collect`,path:u,contentLength:p.length}),{globalMemory:{type:Et.GlobalMemory,content:p,length:p.length,filePathKind:L.Relative,...f.rawFrontMatter!=null&&{rawFrontMatter:f.rawFrontMatter},markdownAst:f.markdownAst,markdownContents:f.markdownContents,dir:{pathKind:L.Relative,path:i.basename(u),basePath:i.dirname(u),getDirectoryName:()=>i.basename(u),getAbsolutePath:()=>u},parentDirectoryPath:{type:At.UserHome,directory:{pathKind:L.Relative,path:``,basePath:s.homedir(),getDirectoryName:()=>i.basename(s.homedir()),getAbsolutePath:()=>s.homedir()}}}}}},qv=class extends Lg{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,`utf8`),a=R.Original;e.includes(`.vscode`)?a=R.VSCode:e.includes(`.idea`)?a=R.IntellijIDEA:e.includes(`.editorconfig`)&&(a=R.EditorConfig),o.push({type:a,content:i,length:i.length,filePathKind:L.Absolute,dir:{pathKind:L.Absolute,path:t,getDirectoryName:()=>r.basename(t)}})}}return{ideConfigFiles:o}}};const Jv=`AGENTS.md`,Yv=`prompts`,Xv=`skills`,Zv=`SKILL.md`,Qv=`.aiassistant`,$v=`rules`,ey=`always.md`,ty=`codex`,ny=[`IntelliJIdea`,`WebStorm`,`RustRover`,`PyCharm`,`PyCharmCE`,`PhpStorm`,`GoLand`,`CLion`,`DataGrip`,`RubyMine`,`Rider`,`DataSpell`,`Aqua`];var ry=class extends Pg{constructor(){super(`JetBrainsAIAssistantCodexOutputPlugin`,{outputFileName:Jv,dependsOn:[`AgentsOutputPlugin`]})}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)e.dirFromWorkspacePath!=null&&t.push(this.createProjectRulesDirRelativePath(e.dirFromWorkspacePath));return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&(e.rootMemoryPrompt!=null&&t.push(this.createProjectRuleFileRelativePath(n,ey)),e.childMemoryPrompts!=null))for(let r of e.childMemoryPrompts){let e=this.buildChildRuleFileName(r);t.push(this.createProjectRuleFileRelativePath(n,e))}}return t}async registerGlobalOutputDirs(e){let t=[],n=this.resolveCodexDirs();for(let r of n){let n=i.join(r,Yv);t.push({pathKind:L.Relative,path:Yv,basePath:r,getDirectoryName:()=>Yv,getAbsolutePath:()=>n});let{skills:a}=e.collectedInputContext;if(!(a==null||a.length===0))for(let e of a){let n=e.yamlFrontMatter?.name??e.dir.getDirectoryName(),a=i.join(r,Xv,n);t.push({pathKind:L.Relative,path:i.join(Xv,n),basePath:r,getDirectoryName:()=>n,getAbsolutePath:()=>a})}}return t}async registerGlobalOutputFiles(){return this.resolveCodexDirs().map(e=>({pathKind:L.Relative,path:Jv,basePath:e,getDirectoryName:()=>ty,getAbsolutePath:()=>i.join(e,Jv)}))}async canWrite(e){let{globalMemory:t,fastCommands:n,skills:r,workspace:i}=e.collectedInputContext,a=t!=null,o=(n?.length??0)>0,s=(r?.length??0)>0,c=i.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0);return a||o||s||c?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t)if(r.dirFromWorkspacePath!=null){if(r.rootMemoryPrompt!=null){let t=this.buildAlwaysRuleContent(r.rootMemoryPrompt.content),i=await this.writeProjectRuleFile(e,r,ey,t,`projectRootRule`);n.push(i)}if(r.childMemoryPrompts!=null)for(let t of r.childMemoryPrompts){let i=this.buildChildRuleFileName(t),a=this.buildGlobRuleContent(t),o=await this.writeProjectRuleFile(e,r,i,a,`projectChildRule`);n.push(o)}}return{files:n,dirs:r}}async writeGlobalOutputs(e){let{globalMemory:t,fastCommands:n,skills:a}=e.collectedInputContext,o=[],s=[],c=this.resolveCodexDirs();if(c.length===0)return{files:o,dirs:s};for(let s of c){if(t!=null){let n=i.join(s,Jv),a={pathKind:L.Relative,path:Jv,basePath:s,getDirectoryName:()=>ty,getAbsolutePath:()=>n};if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`globalMemory`,path:n}),o.push({path:a,success:!0,skipped:!1});else try{this.ensureDirectory(s),r.writeFileSync(n,t.content,`utf8`),this.log.trace({action:`write`,type:`globalMemory`,path:n}),o.push({path:a,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalMemory`,path:n,error:t}),o.push({path:a,success:!1,error:e})}}if(n!=null&&n.length>0)for(let t of n){let n=await this.writeGlobalFastCommand(e,s,t);o.push(...n)}if(!(a==null||a.length===0))for(let t of a){let n=await this.writeGlobalSkill(e,s,t);o.push(...n)}}return{files:o,dirs:s}}resolveCodexDirs(){let e=i.join(nt(),`JetBrains`);if(!this.existsSync(e))return[];try{return this.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()?this.isSupportedIdeDir(e.name):!1).map(t=>i.join(e,t.name,`aia`,ty))}catch(t){let n=t instanceof Error?t.message:String(t);return this.log.warn({action:`scan`,type:`jetbrains`,path:e,error:n}),[]}}createProjectRulesDirRelativePath(e){let t=i.join(e.path,Qv,$v);return{pathKind:L.Relative,path:t,basePath:e.basePath,getDirectoryName:()=>$v,getAbsolutePath:()=>i.join(e.basePath,t)}}createProjectRuleFileRelativePath(e,t){let n=i.join(e.path,Qv,$v,t);return{pathKind:L.Relative,path:n,basePath:e.basePath,getDirectoryName:()=>$v,getAbsolutePath:()=>i.join(e.basePath,n)}}buildChildRuleFileName(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`);return`glob-${t.length>0?t:`root`}.md`}buildChildRulePattern(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``);return t.length===0?`**/*`:`${t}/**`}buildAlwaysRuleContent(e){return Ag({apply:`始终`},e)}buildGlobRuleContent(e){return Ag({apply:`按文件模式`,模式:this.buildChildRulePattern(e)},e.content)}async writeProjectRuleFile(e,t,n,a,o){let s=t.dirFromWorkspacePath,c=i.join(s.basePath,s.path,Qv,$v),l=i.join(c,n),u=this.createProjectRuleFileRelativePath(s,n);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:o,path:l}),{path:u,success:!0,skipped:!1};try{return this.ensureDirectory(c),r.writeFileSync(l,a,`utf8`),this.log.trace({action:`write`,type:o,path:l}),{path:u,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:o,path:l,error:t}),{path:u,success:!1,error:e}}}isSupportedIdeDir(e){return ny.some(t=>e.startsWith(t))}async writeGlobalFastCommand(e,t,n){let a=[],o=this.getTransformOptionsFromContext(e),s=this.transformFastCommandName(n,o),c=i.join(t,Yv),l=i.join(c,s),u={pathKind:L.Relative,path:i.join(Yv,s),basePath:t,getDirectoryName:()=>Yv,getAbsolutePath:()=>l},d=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalFastCommand`,path:l}),[{path:u,success:!0,skipped:!1}];try{this.ensureDirectory(c),r.writeFileSync(l,d,`utf8`),this.log.trace({action:`write`,type:`globalFastCommand`,path:l}),a.push({path:u,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalFastCommand`,path:l,error:t}),a.push({path:u,success:!1,error:e})}return a}async writeGlobalSkill(e,t,n){let a=[],o=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),s=i.join(t,Xv,o),c=i.join(s,Zv),l={pathKind:L.Relative,path:i.join(Xv,o,Zv),basePath:t,getDirectoryName:()=>o,getAbsolutePath:()=>c},u=this.buildCodexSkillContent(n);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalSkill`,path:c}),[{path:l,success:!0,skipped:!1}];try{if(this.ensureDirectory(s),r.writeFileSync(c,u,`utf8`),this.log.trace({action:`write`,type:`globalSkill`,path:c}),a.push({path:l,success:!0}),n.childDocs!=null)for(let r of n.childDocs){let n=await this.writeSkillReferenceDocument(e,s,o,r,t);a.push(...n)}if(n.resources!=null)for(let r of n.resources){let n=await this.writeSkillResource(e,s,o,r,t);a.push(...n)}}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalSkill`,path:c,error:t}),a.push({path:l,success:!1,error:e})}return a}buildCodexSkillContent(e){let t=e.yamlFrontMatter,n=this.normalizeSkillName(t.name,64),r=this.normalizeToSingleLine(t.description,1024),i={};t.displayName!=null&&(i[`short-description`]=t.displayName),t.version!=null&&(i.version=t.version),t.author!=null&&(i.author=t.author),t.keywords!=null&&t.keywords.length>0&&(i.keywords=[...t.keywords]);let a={name:n,description:r};return Object.keys(i).length>0&&(a.metadata=i),t.allowTools!=null&&t.allowTools.length>0&&(a[`allowed-tools`]=t.allowTools.join(` `)),Ag(a,e.content)}normalizeSkillName(e,t){let n=e.toLowerCase().replaceAll(/[^a-z0-9-]/g,`-`).replaceAll(/-+/g,`-`).replaceAll(/^-+|-+$/g,``);return n.length>t&&(n=n.slice(0,t).replace(/-+$/,``)),n}normalizeToSingleLine(e,t){let n=e.replaceAll(/[\r\n]+/g,` `).replaceAll(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-3)}...`:n}async writeSkillReferenceDocument(e,t,n,a,o){let s=[],c=a.dir.path.replace(/\.mdx$/,`.md`),l=i.join(t,c),u={pathKind:L.Relative,path:i.join(Xv,n,c),basePath:o,getDirectoryName:()=>n,getAbsolutePath:()=>l};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillRefDoc`,path:l}),[{path:u,success:!0,skipped:!1}];try{let e=i.dirname(l);this.ensureDirectory(e),r.writeFileSync(l,a.content,`utf8`),this.log.trace({action:`write`,type:`skillRefDoc`,path:l}),s.push({path:u,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillRefDoc`,path:l,error:t}),s.push({path:u,success:!1,error:e})}return s}async writeSkillResource(e,t,n,a,o){let s=[],c=i.join(t,a.relativePath),l={pathKind:L.Relative,path:i.join(Xv,n,a.relativePath),basePath:o,getDirectoryName:()=>n,getAbsolutePath:()=>c};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillResource`,path:c}),[{path:l,success:!0,skipped:!1}];try{let e=i.dirname(c);this.ensureDirectory(e),r.writeFileSync(c,a.content,`utf8`),this.log.trace({action:`write`,type:`skillResource`,path:c}),s.push({path:l,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillResource`,path:c,error:t}),s.push({path:l,success:!1,error:e})}return s}};const iy=`.idea`,ay=[`.editorconfig`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`];var oy=class extends Pg{constructor(){super(`JetBrainsIDECodeStyleConfigOutputPlugin`)}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{ideConfigFiles:r}=e.collectedInputContext;if(!r.some(e=>e.type===R.IntellijIDEA||e.type===R.EditorConfig))return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&e.isPromptSourceProject!==!0)for(let e of ay){let r=this.joinPath(n.path,e);t.push({pathKind:L.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===R.IntellijIDEA||e.type===R.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===R.IntellijIDEA||e.type===R.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:L.Relative,path:this.joinPath(t.path,i),basePath:t.basePath,getDirectoryName:()=>this.dirname(i),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`config`,path:a,label:r}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,n.content),this.log.trace({action:`write`,type:`config`,path:a,label:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`config`,path:a,label:r,error:t}),{path:o,success:!1,error:e}}}getTargetRelativePath(e){let t=e.dir.path;if(e.type===R.EditorConfig)return`.editorconfig`;if(e.type!==R.IntellijIDEA)return this.basename(t);let n=t.indexOf(iy);return n===-1?this.joinPath(iy,`codeStyles`,this.basename(t)):t.slice(Math.max(0,n))}},sy=class extends Lg{constructor(){super(`MarkdownWhitespaceCleanupEffectInputPlugin`),this.registerEffect(`markdown-whitespace-cleanup`,this.cleanupWhitespace.bind(this),30)}async cleanupWhitespace(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=[],s=[],c=[],l=[n.join(r,`src`),n.join(r,`app`),n.join(r,`dist`)];for(let n of l){if(!t.existsSync(n)){a.debug({action:`whitespace-cleanup`,message:`Directory does not exist, skipping`,dir:n});continue}this.processDirectory(e,n,o,s,c,i??!1)}let u=c.length>0;return u&&a.warn({action:`whitespace-cleanup`,errors:c.map(e=>({path:e.path,error:e.error.message}))}),{success:!u,description:i?`Would modify ${o.length} files, skip ${s.length} files`:`Modified ${o.length} files, skipped ${s.length} files`,modifiedFiles:o,skippedFiles:s,...u&&{error:Error(`${c.length} errors occurred during cleanup`)}}}processDirectory(e,t,n,r,i,a){let{fs:o,path:s,logger:c}=e,l;try{l=o.readdirSync(t,{withFileTypes:!0})}catch(e){i.push({path:t,error:e}),c.warn({action:`whitespace-cleanup`,message:`Failed to read directory`,path:t,error:e.message});return}for(let o of l){let c=s.join(t,o.name);o.isDirectory()?this.processDirectory(e,c,n,r,i,a):o.isFile()&&o.name.endsWith(`.md`)&&this.processMarkdownFile(e,c,n,r,i,a)}}processMarkdownFile(e,t,n,r,i,a){let{fs:o,logger:s}=e;try{let e=o.readFileSync(t,`utf8`),i=this.cleanMarkdownContent(e);if(e===i){r.push(t),s.debug({action:`whitespace-cleanup`,skipped:t,reason:`no changes needed`});return}a?(s.debug({action:`whitespace-cleanup`,dryRun:!0,wouldModify:t}),n.push(t)):(o.writeFileSync(t,i,`utf8`),n.push(t),s.debug({action:`whitespace-cleanup`,modified:t}))}catch(e){i.push({path:t,error:e}),s.warn({action:`whitespace-cleanup`,message:`Failed to process file`,path:t,error:e.message})}}cleanMarkdownContent(e){let t=this.detectLineEnding(e),n=e.split(/\r?\n/).map(e=>e.replace(/[ \t]+$/,``)),r=[],i=0;for(let e of n)e===``?(i++,i<=2&&r.push(e)):(i=0,r.push(e));return r.join(t)}detectLineEnding(e){return e.includes(`\r
1201
+ `).trim()}normalizeContent(e){let t=e.trim();return t.length===0?``:`${t}\n`}async writeGitExcludeFile(e,t,n,a){let o=e.collectedInputContext.workspace.directory.path,s={pathKind:L.Relative,path:i.relative(o,t),basePath:o,getDirectoryName:()=>i.basename(i.dirname(t)),getAbsolutePath:()=>t};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`gitExclude`,path:t,label:a}),{path:s,success:!0,skipped:!1};try{let e=i.dirname(t);r.existsSync(e)||(r.mkdirSync(e,{recursive:!0}),this.log.debug({action:`mkdir`,path:e,message:`Created .git/info directory`}));let o=this.normalizeContent(n);return r.writeFileSync(t,o,`utf8`),this.log.trace({action:`write`,type:`gitExclude`,path:t,label:a}),{path:s,success:!0}}catch(e){let n=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`gitExclude`,path:t,label:a,error:n}),{path:s,success:!1,error:e}}}};const Wv=Kt;function Gv(){return Wv[`public/gitignore`]?.content??``}var Kv=class extends Rv{constructor(){super(`GitIgnoreInputPlugin`,{fallbackContent:Gv()})}getFilePath(e){return i.join(e,`public`,`gitignore`)}getResultKey(){return`globalGitIgnore`}},qv=class extends Lg{constructor(){super(`GlobalMemoryInputPlugin`)}async collect(e){let{userConfigOptions:t,fs:r,path:i,globalScope:a}=e,{workspaceDir:o,shadowProjectDir:c}=this.resolveBasePaths(t),l=t.globalMemoryFile,u=this.resolvePath(l,o,c);if(!r.existsSync(u))return this.log.warn({action:`collect`,reason:`fileNotFound`,path:u}),{};if(!r.statSync(u).isFile())return this.log.warn({action:`collect`,reason:`notAFile`,path:u}),{};let d=r.readFileSync(u,`utf8`),f=jg(d),p;if(a!=null)try{p=await fv(d,{globalScope:a,basePath:i.dirname(u)})}catch(e){throw e instanceof Yg&&(this.log.error(`MDX compilation failed: ${e.message}`),this.log.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),this.log.error(`For example, if using {profile.name}, add a "profile" section with "name" field to your config.`),n.exit(1)),e}else p=f.contentWithoutFrontMatter;return this.log.debug({action:`collect`,path:u,contentLength:p.length}),{globalMemory:{type:Et.GlobalMemory,content:p,length:p.length,filePathKind:L.Relative,...f.rawFrontMatter!=null&&{rawFrontMatter:f.rawFrontMatter},markdownAst:f.markdownAst,markdownContents:f.markdownContents,dir:{pathKind:L.Relative,path:i.basename(u),basePath:i.dirname(u),getDirectoryName:()=>i.basename(u),getAbsolutePath:()=>u},parentDirectoryPath:{type:At.UserHome,directory:{pathKind:L.Relative,path:``,basePath:s.homedir(),getDirectoryName:()=>i.basename(s.homedir()),getAbsolutePath:()=>s.homedir()}}}}}},Jv=class extends Lg{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,`utf8`),a=R.Original;e.includes(`.vscode`)?a=R.VSCode:e.includes(`.idea`)?a=R.IntellijIDEA:e.includes(`.editorconfig`)&&(a=R.EditorConfig),o.push({type:a,content:i,length:i.length,filePathKind:L.Absolute,dir:{pathKind:L.Absolute,path:t,getDirectoryName:()=>r.basename(t)}})}}return{ideConfigFiles:o}}};const Yv=`AGENTS.md`,Xv=`prompts`,Zv=`skills`,Qv=`SKILL.md`,$v=`.aiassistant`,ey=`rules`,ty=`always.md`,ny=`codex`,ry=[`IntelliJIdea`,`WebStorm`,`RustRover`,`PyCharm`,`PyCharmCE`,`PhpStorm`,`GoLand`,`CLion`,`DataGrip`,`RubyMine`,`Rider`,`DataSpell`,`Aqua`];var iy=class extends Pg{constructor(){super(`JetBrainsAIAssistantCodexOutputPlugin`,{outputFileName:Yv,dependsOn:[`AgentsOutputPlugin`]})}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)e.dirFromWorkspacePath!=null&&t.push(this.createProjectRulesDirRelativePath(e.dirFromWorkspacePath));return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&(e.rootMemoryPrompt!=null&&t.push(this.createProjectRuleFileRelativePath(n,ty)),e.childMemoryPrompts!=null))for(let r of e.childMemoryPrompts){let e=this.buildChildRuleFileName(r);t.push(this.createProjectRuleFileRelativePath(n,e))}}return t}async registerGlobalOutputDirs(e){let t=[],n=this.resolveCodexDirs();for(let r of n){let n=i.join(r,Xv);t.push({pathKind:L.Relative,path:Xv,basePath:r,getDirectoryName:()=>Xv,getAbsolutePath:()=>n});let{skills:a}=e.collectedInputContext;if(!(a==null||a.length===0))for(let e of a){let n=e.yamlFrontMatter?.name??e.dir.getDirectoryName(),a=i.join(r,Zv,n);t.push({pathKind:L.Relative,path:i.join(Zv,n),basePath:r,getDirectoryName:()=>n,getAbsolutePath:()=>a})}}return t}async registerGlobalOutputFiles(){return this.resolveCodexDirs().map(e=>({pathKind:L.Relative,path:Yv,basePath:e,getDirectoryName:()=>ny,getAbsolutePath:()=>i.join(e,Yv)}))}async canWrite(e){let{globalMemory:t,fastCommands:n,skills:r,workspace:i}=e.collectedInputContext,a=t!=null,o=(n?.length??0)>0,s=(r?.length??0)>0,c=i.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0);return a||o||s||c?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t)if(r.dirFromWorkspacePath!=null){if(r.rootMemoryPrompt!=null){let t=this.buildAlwaysRuleContent(r.rootMemoryPrompt.content),i=await this.writeProjectRuleFile(e,r,ty,t,`projectRootRule`);n.push(i)}if(r.childMemoryPrompts!=null)for(let t of r.childMemoryPrompts){let i=this.buildChildRuleFileName(t),a=this.buildGlobRuleContent(t),o=await this.writeProjectRuleFile(e,r,i,a,`projectChildRule`);n.push(o)}}return{files:n,dirs:r}}async writeGlobalOutputs(e){let{globalMemory:t,fastCommands:n,skills:a}=e.collectedInputContext,o=[],s=[],c=this.resolveCodexDirs();if(c.length===0)return{files:o,dirs:s};for(let s of c){if(t!=null){let n=i.join(s,Yv),a={pathKind:L.Relative,path:Yv,basePath:s,getDirectoryName:()=>ny,getAbsolutePath:()=>n};if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`globalMemory`,path:n}),o.push({path:a,success:!0,skipped:!1});else try{this.ensureDirectory(s),r.writeFileSync(n,t.content,`utf8`),this.log.trace({action:`write`,type:`globalMemory`,path:n}),o.push({path:a,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalMemory`,path:n,error:t}),o.push({path:a,success:!1,error:e})}}if(n!=null&&n.length>0)for(let t of n){let n=await this.writeGlobalFastCommand(e,s,t);o.push(...n)}if(!(a==null||a.length===0))for(let t of a){let n=await this.writeGlobalSkill(e,s,t);o.push(...n)}}return{files:o,dirs:s}}resolveCodexDirs(){let e=i.join(nt(),`JetBrains`);if(!this.existsSync(e))return[];try{return this.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()?this.isSupportedIdeDir(e.name):!1).map(t=>i.join(e,t.name,`aia`,ny))}catch(t){let n=t instanceof Error?t.message:String(t);return this.log.warn({action:`scan`,type:`jetbrains`,path:e,error:n}),[]}}createProjectRulesDirRelativePath(e){let t=i.join(e.path,$v,ey);return{pathKind:L.Relative,path:t,basePath:e.basePath,getDirectoryName:()=>ey,getAbsolutePath:()=>i.join(e.basePath,t)}}createProjectRuleFileRelativePath(e,t){let n=i.join(e.path,$v,ey,t);return{pathKind:L.Relative,path:n,basePath:e.basePath,getDirectoryName:()=>ey,getAbsolutePath:()=>i.join(e.basePath,n)}}buildChildRuleFileName(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`);return`glob-${t.length>0?t:`root`}.md`}buildChildRulePattern(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``);return t.length===0?`**/*`:`${t}/**`}buildAlwaysRuleContent(e){return Ag({apply:`始终`},e)}buildGlobRuleContent(e){return Ag({apply:`按文件模式`,模式:this.buildChildRulePattern(e)},e.content)}async writeProjectRuleFile(e,t,n,a,o){let s=t.dirFromWorkspacePath,c=i.join(s.basePath,s.path,$v,ey),l=i.join(c,n),u=this.createProjectRuleFileRelativePath(s,n);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:o,path:l}),{path:u,success:!0,skipped:!1};try{return this.ensureDirectory(c),r.writeFileSync(l,a,`utf8`),this.log.trace({action:`write`,type:o,path:l}),{path:u,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:o,path:l,error:t}),{path:u,success:!1,error:e}}}isSupportedIdeDir(e){return ry.some(t=>e.startsWith(t))}async writeGlobalFastCommand(e,t,n){let a=[],o=this.getTransformOptionsFromContext(e),s=this.transformFastCommandName(n,o),c=i.join(t,Xv),l=i.join(c,s),u={pathKind:L.Relative,path:i.join(Xv,s),basePath:t,getDirectoryName:()=>Xv,getAbsolutePath:()=>l},d=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalFastCommand`,path:l}),[{path:u,success:!0,skipped:!1}];try{this.ensureDirectory(c),r.writeFileSync(l,d,`utf8`),this.log.trace({action:`write`,type:`globalFastCommand`,path:l}),a.push({path:u,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalFastCommand`,path:l,error:t}),a.push({path:u,success:!1,error:e})}return a}async writeGlobalSkill(e,t,n){let a=[],o=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),s=i.join(t,Zv,o),c=i.join(s,Qv),l={pathKind:L.Relative,path:i.join(Zv,o,Qv),basePath:t,getDirectoryName:()=>o,getAbsolutePath:()=>c},u=this.buildCodexSkillContent(n);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalSkill`,path:c}),[{path:l,success:!0,skipped:!1}];try{if(this.ensureDirectory(s),r.writeFileSync(c,u,`utf8`),this.log.trace({action:`write`,type:`globalSkill`,path:c}),a.push({path:l,success:!0}),n.childDocs!=null)for(let r of n.childDocs){let n=await this.writeSkillReferenceDocument(e,s,o,r,t);a.push(...n)}if(n.resources!=null)for(let r of n.resources){let n=await this.writeSkillResource(e,s,o,r,t);a.push(...n)}}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalSkill`,path:c,error:t}),a.push({path:l,success:!1,error:e})}return a}buildCodexSkillContent(e){let t=e.yamlFrontMatter,n=this.normalizeSkillName(t.name,64),r=this.normalizeToSingleLine(t.description,1024),i={};t.displayName!=null&&(i[`short-description`]=t.displayName),t.version!=null&&(i.version=t.version),t.author!=null&&(i.author=t.author),t.keywords!=null&&t.keywords.length>0&&(i.keywords=[...t.keywords]);let a={name:n,description:r};return Object.keys(i).length>0&&(a.metadata=i),t.allowTools!=null&&t.allowTools.length>0&&(a[`allowed-tools`]=t.allowTools.join(` `)),Ag(a,e.content)}normalizeSkillName(e,t){let n=e.toLowerCase().replaceAll(/[^a-z0-9-]/g,`-`).replaceAll(/-+/g,`-`).replaceAll(/^-+|-+$/g,``);return n.length>t&&(n=n.slice(0,t).replace(/-+$/,``)),n}normalizeToSingleLine(e,t){let n=e.replaceAll(/[\r\n]+/g,` `).replaceAll(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-3)}...`:n}async writeSkillReferenceDocument(e,t,n,a,o){let s=[],c=a.dir.path.replace(/\.mdx$/,`.md`),l=i.join(t,c),u={pathKind:L.Relative,path:i.join(Zv,n,c),basePath:o,getDirectoryName:()=>n,getAbsolutePath:()=>l};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillRefDoc`,path:l}),[{path:u,success:!0,skipped:!1}];try{let e=i.dirname(l);this.ensureDirectory(e),r.writeFileSync(l,a.content,`utf8`),this.log.trace({action:`write`,type:`skillRefDoc`,path:l}),s.push({path:u,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillRefDoc`,path:l,error:t}),s.push({path:u,success:!1,error:e})}return s}async writeSkillResource(e,t,n,a,o){let s=[],c=i.join(t,a.relativePath),l={pathKind:L.Relative,path:i.join(Zv,n,a.relativePath),basePath:o,getDirectoryName:()=>n,getAbsolutePath:()=>c};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillResource`,path:c}),[{path:l,success:!0,skipped:!1}];try{let e=i.dirname(c);this.ensureDirectory(e),r.writeFileSync(c,a.content,`utf8`),this.log.trace({action:`write`,type:`skillResource`,path:c}),s.push({path:l,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillResource`,path:c,error:t}),s.push({path:l,success:!1,error:e})}return s}};const ay=`.idea`,oy=[`.editorconfig`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`];var sy=class extends Pg{constructor(){super(`JetBrainsIDECodeStyleConfigOutputPlugin`)}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{ideConfigFiles:r}=e.collectedInputContext;if(!r.some(e=>e.type===R.IntellijIDEA||e.type===R.EditorConfig))return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&e.isPromptSourceProject!==!0)for(let e of oy){let r=this.joinPath(n.path,e);t.push({pathKind:L.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===R.IntellijIDEA||e.type===R.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===R.IntellijIDEA||e.type===R.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:L.Relative,path:this.joinPath(t.path,i),basePath:t.basePath,getDirectoryName:()=>this.dirname(i),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`config`,path:a,label:r}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,n.content),this.log.trace({action:`write`,type:`config`,path:a,label:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`config`,path:a,label:r,error:t}),{path:o,success:!1,error:e}}}getTargetRelativePath(e){let t=e.dir.path;if(e.type===R.EditorConfig)return`.editorconfig`;if(e.type!==R.IntellijIDEA)return this.basename(t);let n=t.indexOf(ay);return n===-1?this.joinPath(ay,`codeStyles`,this.basename(t)):t.slice(Math.max(0,n))}},cy=class extends Lg{constructor(){super(`MarkdownWhitespaceCleanupEffectInputPlugin`),this.registerEffect(`markdown-whitespace-cleanup`,this.cleanupWhitespace.bind(this),30)}async cleanupWhitespace(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=[],s=[],c=[],l=[n.join(r,`src`),n.join(r,`app`),n.join(r,`dist`)];for(let n of l){if(!t.existsSync(n)){a.debug({action:`whitespace-cleanup`,message:`Directory does not exist, skipping`,dir:n});continue}this.processDirectory(e,n,o,s,c,i??!1)}let u=c.length>0;return u&&a.warn({action:`whitespace-cleanup`,errors:c.map(e=>({path:e.path,error:e.error.message}))}),{success:!u,description:i?`Would modify ${o.length} files, skip ${s.length} files`:`Modified ${o.length} files, skipped ${s.length} files`,modifiedFiles:o,skippedFiles:s,...u&&{error:Error(`${c.length} errors occurred during cleanup`)}}}processDirectory(e,t,n,r,i,a){let{fs:o,path:s,logger:c}=e,l;try{l=o.readdirSync(t,{withFileTypes:!0})}catch(e){i.push({path:t,error:e}),c.warn({action:`whitespace-cleanup`,message:`Failed to read directory`,path:t,error:e.message});return}for(let o of l){let c=s.join(t,o.name);o.isDirectory()?this.processDirectory(e,c,n,r,i,a):o.isFile()&&o.name.endsWith(`.md`)&&this.processMarkdownFile(e,c,n,r,i,a)}}processMarkdownFile(e,t,n,r,i,a){let{fs:o,logger:s}=e;try{let e=o.readFileSync(t,`utf8`),i=this.cleanMarkdownContent(e);if(e===i){r.push(t),s.debug({action:`whitespace-cleanup`,skipped:t,reason:`no changes needed`});return}a?(s.debug({action:`whitespace-cleanup`,dryRun:!0,wouldModify:t}),n.push(t)):(o.writeFileSync(t,i,`utf8`),n.push(t),s.debug({action:`whitespace-cleanup`,modified:t}))}catch(e){i.push({path:t,error:e}),s.warn({action:`whitespace-cleanup`,message:`Failed to process file`,path:t,error:e.message})}}cleanMarkdownContent(e){let t=this.detectLineEnding(e),n=e.split(/\r?\n/).map(e=>e.replace(/[ \t]+$/,``)),r=[],i=0;for(let e of n)e===``?(i++,i<=2&&r.push(e)):(i=0,r.push(e));return r.join(t)}detectLineEnding(e){return e.includes(`\r
877
1202
  `)?`\r
878
1203
  `:`
879
- `}collect(e){return{}}};const cy=`.config/opencode`,ly=`opencode.json`;var uy=class extends pv{constructor(){super(`OpencodeCLIOutputPlugin`,{globalConfigDir:cy,outputFileName:`AGENTS.md`,commandsSubDir:`commands`,agentsSubDir:`agents`,skillsSubDir:`skills`,supportsFastCommands:!0,supportsSubAgents:!0,supportsSkills:!0,dependsOn:[`AgentsOutputPlugin`]}),this.registerCleanEffect(`mcp-config-cleanup`,async e=>{let t=this.getGlobalConfigDir(),n=i.join(t,ly);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfigCleanup`,path:n}),{success:!0,description:`Would reset opencode.json mcp to empty`};try{if(r.existsSync(n)){let e=r.readFileSync(n,`utf8`),t=JSON.parse(e);t.mcp={},r.writeFileSync(n,JSON.stringify(t,null,2))}return this.log.trace({action:`clean`,type:`mcpConfigCleanup`,path:n}),{success:!0,description:`Reset opencode.json mcp to empty`}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`clean`,type:`mcpConfigCleanup`,path:n,error:t}),{success:!1,error:e,description:`Failed to reset opencode.json mcp`}}})}async registerGlobalOutputFiles(e){let t=await super.registerGlobalOutputFiles(e),n=this.getGlobalConfigDir();if(e.collectedInputContext.skills?.some(e=>e.mcpConfig!=null)??!1){let e=i.join(n,ly);t.push({pathKind:L.Relative,path:ly,basePath:n,getDirectoryName:()=>cy,getAbsolutePath:()=>e})}return t.map(e=>{let t=e.path.replaceAll(`\\`,`/`),r=`/${this.skillsSubDir}/`,a=`${this.skillsSubDir}/`;if(!(t.includes(r)||t.startsWith(a)))return e;let o=t.split(`/`),s=o.indexOf(this.skillsSubDir);if(s<0||s+1>=o.length)return e;let c=o[s+1];if(c==null)return e;let l=this.validateAndNormalizeSkillName(c),u=[...o];u[s+1]=l;let d=u.join(`/`);return{...e,path:d,getDirectoryName:()=>l,getAbsolutePath:()=>i.join(n,d.replaceAll(`/`,i.sep))}})}async writeGlobalOutputs(e){let t=await super.writeGlobalOutputs(e),n=[...t.files],{skills:r}=e.collectedInputContext;if(r==null)return{files:n,dirs:t.dirs};let i=await this.writeGlobalMcpConfig(e,r);return i!=null&&n.push(i),{files:n,dirs:t.dirs}}async writeGlobalMcpConfig(e,t){let n={};for(let e of t){if(e.mcpConfig==null)continue;let{mcpServers:t}=e.mcpConfig;for(let[e,r]of Object.entries(t))n[e]=this.transformMcpConfigForOpencode(r)}if(Object.keys(n).length===0)return null;let a=this.getGlobalConfigDir(),o=i.join(a,ly),s={pathKind:L.Relative,path:ly,basePath:a,getDirectoryName:()=>cy,getAbsolutePath:()=>o},c={};try{if(r.existsSync(o)){let e=r.readFileSync(o,`utf8`);c=JSON.parse(e)}}catch{c={}}c.$schema=`https://opencode.ai/config.json`,c.mcp=n;let l=JSON.stringify(c,null,2);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMcpConfig`,path:o,serverCount:Object.keys(n).length}),{path:s,success:!0,skipped:!1};try{return this.ensureDirectory(a),r.writeFileSync(o,l),this.log.trace({action:`write`,type:`globalMcpConfig`,path:o,serverCount:Object.keys(n).length}),{path:s,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalMcpConfig`,path:o,error:t}),{path:s,success:!1,error:e}}}transformMcpConfigForOpencode(e){let t={};if(e.command!=null){t.type=`local`;let n=[e.command];e.args!=null&&n.push(...e.args),t.command=n,e.env!=null&&(t.environment=e.env)}else{t.type=`remote`;let n=e;n.url==null?n.serverUrl!=null&&(t.url=n.serverUrl):t.url=n.url}return t.enabled=e.disabled!==!0,t}async writeSubAgent(e,t,n){let r=n.dir.path.endsWith(`.md`)?n.dir.path:`${n.dir.path}.md`,a=i.join(t,this.agentsSubDir),o=i.join(a,r),s=this.buildOpencodeAgentFrontMatter(n),c=this.buildMarkdownContent(n.content,s);return[await this.writeFile(e,o,c,`subAgent`)]}buildOpencodeAgentFrontMatter(e){let t={},n=e.yamlFrontMatter;if(n?.description!=null&&(t.description=n.description),t.mode=n?.mode??`subagent`,n?.model!=null&&(t.model=n.model),n?.temperature!=null&&(t.temperature=n.temperature),n?.maxSteps!=null&&(t.maxSteps=n.maxSteps),n?.hidden!=null&&(t.hidden=n.hidden),n?.allowTools!=null&&Array.isArray(n.allowTools)){let e={};for(let t of n.allowTools)e[String(t)]=!0;t.tools=e}n?.permission!=null&&typeof n.permission==`object`&&(t.permission=n.permission);for(let[e,r]of Object.entries(n??{}))[`description`,`mode`,`model`,`temperature`,`maxSteps`,`hidden`,`allowTools`,`permission`,`namingCase`,`name`,`color`].includes(e)||(t[e]=r);return t}async writeFastCommand(e,t,n){let r=this.getTransformOptionsFromContext(e),a=this.transformFastCommandName(n,r),o=i.join(t,this.commandsSubDir),s=i.join(o,a),c=this.buildOpencodeCommandFrontMatter(n),l=this.buildMarkdownContent(n.content,c);return[await this.writeFile(e,s,l,`fastCommand`)]}buildOpencodeCommandFrontMatter(e){let t={},n=e.yamlFrontMatter;if(n?.description!=null&&(t.description=n.description),n?.agent!=null&&(t.agent=n.agent),n?.model!=null&&(t.model=n.model),n?.allowTools!=null&&Array.isArray(n.allowTools)){let e={};for(let t of n.allowTools)e[String(t)]=!0;t.tools=e}for(let[e,r]of Object.entries(n??{}))[`description`,`agent`,`model`,`allowTools`,`namingCase`,`argumentHint`].includes(e)||(t[e]=r);return t}async writeSkill(e,t,n){let r=[],a=this.validateAndNormalizeSkillName(n.yamlFrontMatter?.name??n.dir.getDirectoryName()),o=i.join(t,this.skillsSubDir,a),s=i.join(o,`SKILL.md`),c=this.buildOpencodeSkillFrontMatter(n,a),l=this.buildMarkdownContent(n.content,c),u=await this.writeFile(e,s,l,`skill`);if(r.push(u),n.childDocs!=null)for(let i of n.childDocs){let n=await this.writeSkillReferenceDocument(e,o,a,i,t);r.push(...n)}if(n.resources!=null)for(let i of n.resources){let n=await this.writeSkillResource(e,o,a,i,t);r.push(...n)}return r}buildOpencodeSkillFrontMatter(e,t){let n={},r=e.yamlFrontMatter;n.name=t,r?.description!=null&&(n.description=r.description),n.license=r?.license??`MIT`,n.compatibility=r?.compatibility??`opencode`;let i={};for(let e of[`author`,`version`,`keywords`,`category`,`repository`,`displayName`])r?.[e]!=null&&(i[e]=r[e]);let a=new Set([`name`,`description`,`license`,`compatibility`,`namingCase`,`allowTools`,`keywords`,`displayName`,`author`,`version`]);for(let[e,t]of Object.entries(r??{}))a.has(e)||(i[e]=t);return Object.keys(i).length>0&&(n.metadata=i),n}validateAndNormalizeSkillName(e){let t=e.toLowerCase();return t=t.replaceAll(/[^a-z0-9-]+/g,`-`),t=t.replaceAll(/-+/g,`-`),t=t.replaceAll(/^-|-$/g,``),t.length===0?t=`skill`:t.length>64&&(t=t.slice(0,64),t=t.replace(/-$/,``)),t}},dy=class extends Lg{constructor(){super(`OrphanFileCleanupEffectInputPlugin`),this.registerEffect(`orphan-file-cleanup`,this.cleanupOrphanFiles.bind(this),20)}async cleanupOrphanFiles(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=n.join(r,`dist`),s=[],c=[],l=[];if(!t.existsSync(o))return a.debug({action:`orphan-cleanup`,message:`dist/ directory does not exist, skipping`,distDir:o}),{success:!0,description:`dist/ directory does not exist, nothing to clean`,deletedFiles:s,deletedDirs:c};for(let r of[`skills`,`commands`,`agents`,`app`]){let a=n.join(o,r);t.existsSync(a)&&this.cleanupDirectory(e,a,r,s,c,l,i??!1)}let u=l.length>0;return u&&a.warn({action:`orphan-cleanup`,errors:l.map(e=>({path:e.path,error:e.error.message}))}),{success:!u,description:i?`Would delete ${s.length} files and ${c.length} directories`:`Deleted ${s.length} files and ${c.length} directories`,deletedFiles:s,deletedDirs:c,...u&&{error:Error(`${l.length} errors occurred during cleanup`)}}}cleanupDirectory(e,t,n,r,i,a,o){let{fs:s,path:c,shadowProjectDir:l,logger:u}=e,d;try{d=s.readdirSync(t,{withFileTypes:!0})}catch(e){a.push({path:t,error:e}),u.warn({action:`orphan-cleanup`,message:`Failed to read directory`,path:t,error:e.message});return}for(let f of d){let d=c.join(t,f.name);if(f.isDirectory())this.cleanupDirectory(e,d,n,r,i,a,o),this.removeEmptyDirectory(e,d,i,a,o);else if(f.isFile()&&this.isOrphanFile(e,d,n,l))if(o)u.debug({action:`orphan-cleanup`,dryRun:!0,wouldDelete:d}),r.push(d);else try{s.unlinkSync(d),r.push(d),u.debug({action:`orphan-cleanup`,deleted:d})}catch(e){a.push({path:d,error:e}),u.warn({action:`orphan-cleanup`,message:`Failed to delete file`,path:d,error:e.message})}}}isOrphanFile(e,t,n,r){let{fs:i,path:a}=e,o=a.basename(t),s=o.endsWith(`.mdx`),c=a.join(r,`dist`,n),l=a.relative(c,t),u=a.dirname(l),d=o.replace(/\.mdx$/,``);if(s)return!this.getPossibleSourcePaths(a,r,n,d,u).some(e=>i.existsSync(e));let f=[];return n===`app`?f.push(a.join(r,`app`,l)):f.push(a.join(r,`src`,n,l)),!f.some(e=>i.existsSync(e))}getPossibleSourcePaths(e,t,n,r,i){switch(n){case`skills`:return i===`.`?[e.join(t,`src`,`skills`,r,`SKILL.cn.mdx`),e.join(t,`src`,`skills`,`${r}.cn.mdx`)]:[e.join(t,`src`,`skills`,i,`${r}.cn.mdx`)];case`commands`:return i===`.`?[e.join(t,`src`,`commands`,`${r}.cn.mdx`)]:[e.join(t,`src`,`commands`,i,`${r}.cn.mdx`)];case`agents`:return i===`.`?[e.join(t,`src`,`agents`,`${r}.cn.mdx`)]:[e.join(t,`src`,`agents`,i,`${r}.cn.mdx`)];case`app`:return i===`.`?[e.join(t,`app`,`${r}.cn.mdx`)]:[e.join(t,`app`,i,`${r}.cn.mdx`)];default:return[]}}removeEmptyDirectory(e,t,n,r,i){let{fs:a,logger:o}=e;try{a.readdirSync(t).length===0&&(i?(o.debug({action:`orphan-cleanup`,dryRun:!0,wouldDeleteDir:t}),n.push(t)):(a.rmdirSync(t),n.push(t),o.debug({action:`orphan-cleanup`,deletedDir:t})))}catch(e){r.push({path:t,error:e}),o.warn({action:`orphan-cleanup`,message:`Failed to check/remove directory`,path:t,error:e.message})}}collect(e){return{}}},fy=class{registryPath;log;constructor(e,t){this.registryPath=this.resolvePath(e),this.log=t??cn(this.constructor.name)}resolvePath(e){return e.startsWith(`~`)?i.join(s.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,`utf8`);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.trace({action:`dryRun`,type:`registry`,path:this.registryPath}),!0;let i=`${this.registryPath}.tmp.${Date.now()}`;try{this.ensureRegistryDir();let e=JSON.stringify(n,null,2);return r.writeFileSync(i,e,`utf8`),r.renameSync(i,this.registryPath),this.log.trace({action:`write`,type:`registry`,path:this.registryPath}),!0}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`registry`,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.trace({action:`dryRun`,type:`registerEntry`,entryName:e}):this.log.trace({action:`register`,type:`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).slice(2,8)}`;return e==null?t:`${e}-${t}`}},py=class extends Lg{constructor(){super(`SkillNonSrcFileSyncEffectInputPlugin`),this.registerEffect(`skill-non-src-file-sync`,this.syncNonSrcFiles.bind(this),10)}async syncNonSrcFiles(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=n.join(r,`src`,`skills`),s=n.join(r,`dist`,`skills`),c=[],l=[],u=[],d=[];if(!t.existsSync(o))return a.debug({action:`skill-sync`,message:`src/skills/ directory does not exist, skipping`,srcSkillsDir:o}),{success:!0,description:`src/skills/ directory does not exist, nothing to sync`,copiedFiles:c,skippedFiles:l,createdDirs:u};this.syncDirectoryRecursive(e,o,s,``,c,l,u,d,i??!1);let f=d.length>0;return f&&a.warn({action:`skill-sync`,errors:d.map(e=>({path:e.path,error:e.error.message}))}),{success:!f,description:i?`Would copy ${c.length} files, skip ${l.length} files`:`Copied ${c.length} files, skipped ${l.length} files`,copiedFiles:c,skippedFiles:l,createdDirs:u,...f&&{error:Error(`${d.length} errors occurred during sync`)},modifiedFiles:c}}syncDirectoryRecursive(e,t,n,r,i,a,o,s,c){let{fs:l,path:u,logger:d}=e,f=r?u.join(t,r):t;if(!l.existsSync(f))return;let p;try{p=l.readdirSync(f,{withFileTypes:!0})}catch(e){s.push({path:f,error:e}),d.warn({action:`skill-sync`,message:`Failed to read directory`,path:f,error:e.message});return}for(let f of p){let p=r?u.join(r,f.name):f.name,m=u.join(t,p),h=u.join(n,p);if(f.isDirectory())this.syncDirectoryRecursive(e,t,n,p,i,a,o,s,c);else if(f.isFile()){if(f.name.endsWith(`.cn.mdx`))continue;let e=u.dirname(h);if(!l.existsSync(e))if(c)d.debug({action:`skill-sync`,dryRun:!0,wouldCreateDir:e}),o.push(e);else try{l.mkdirSync(e,{recursive:!0}),o.push(e),d.debug({action:`skill-sync`,createdDir:e})}catch(t){s.push({path:e,error:t}),d.warn({action:`skill-sync`,message:`Failed to create directory`,path:e,error:t.message});continue}if(l.existsSync(h))try{let e=l.readFileSync(m),t=l.readFileSync(h);if(this.computeHash(e)===this.computeHash(t)){a.push(h),d.debug({action:`skill-sync`,skipped:h,reason:`identical content`});continue}}catch(e){d.debug({action:`skill-sync`,message:`Could not compare files, will copy`,path:h,error:e.message})}if(c)d.debug({action:`skill-sync`,dryRun:!0,wouldCopy:{from:m,to:h}}),i.push(h);else try{l.copyFileSync(m,h),i.push(h),d.debug({action:`skill-sync`,copied:{from:m,to:h}})}catch(e){s.push({path:h,error:e}),d.warn({action:`skill-sync`,message:`Failed to copy file`,from:m,to:h,error:e.message})}}}}computeHash(e){return f(`sha256`).update(e).digest(`hex`)}collect(e){return{}}};const my=`.codeium/windsurf`,hy=`global_workflows`,gy=`memories`,_y=`global_rules.md`,vy=`skills`,yy=`SKILL.md`;var by=class extends Pg{constructor(){super(`WindsurfOutputPlugin`,{globalConfigDir:my,outputFileName:``,dependsOn:[`AgentsOutputPlugin`]})}async registerGlobalOutputDirs(e){let t=[],{fastCommands:n,skills:r}=e.collectedInputContext;if(n!=null&&n.length>0){let e=this.getGlobalWorkflowsDir();t.push({pathKind:L.Relative,path:hy,basePath:this.getCodeiumWindsurfDir(),getDirectoryName:()=>hy,getAbsolutePath:()=>e})}if(r!=null&&r.length>0)for(let e of r){let n=e.yamlFrontMatter.name,r=i.join(this.getCodeiumWindsurfDir(),vy,n);t.push({pathKind:L.Relative,path:i.join(vy,n),basePath:this.getCodeiumWindsurfDir(),getDirectoryName:()=>n,getAbsolutePath:()=>r})}return t}async registerGlobalOutputFiles(e){let t=[],{skills:n,fastCommands:r}=e.collectedInputContext;if(r!=null&&r.length>0){let n=this.getGlobalWorkflowsDir(),a=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});for(let e of r){let r=this.transformFastCommandName(e,a),o=i.join(n,r);t.push({pathKind:L.Relative,path:i.join(hy,r),basePath:this.getCodeiumWindsurfDir(),getDirectoryName:()=>hy,getAbsolutePath:()=>o})}}if(n==null||n.length===0)return t;let a=this.getSkillsDir(),o=this.getCodeiumWindsurfDir();for(let e of n){let n=e.yamlFrontMatter.name,r=i.join(a,n);if(t.push({pathKind:L.Relative,path:i.join(vy,n,yy),basePath:o,getDirectoryName:()=>n,getAbsolutePath:()=>i.join(r,yy)}),e.childDocs!=null)for(let a of e.childDocs){let e=a.relativePath.replace(/\.mdx$/,`.md`);t.push({pathKind:L.Relative,path:i.join(vy,n,e),basePath:o,getDirectoryName:()=>n,getAbsolutePath:()=>i.join(r,e)})}if(e.resources!=null)for(let a of e.resources)t.push({pathKind:L.Relative,path:i.join(vy,n,a.relativePath),basePath:o,getDirectoryName:()=>n,getAbsolutePath:()=>i.join(r,a.relativePath)})}return t}async canWrite(e){let{skills:t,fastCommands:n,globalMemory:r}=e.collectedInputContext,i=(t?.length??0)>0,a=(n?.length??0)>0;return i||a||r!=null?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeGlobalOutputs(e){let{skills:t,fastCommands:n,globalMemory:r}=e.collectedInputContext,i=[],a=[];if(r!=null){let t=await this.writeGlobalMemory(e,r.content);i.push(t)}if(t!=null&&t.length>0){let n=this.getSkillsDir();for(let r of t){let t=await this.writeGlobalSkill(e,n,r);i.push(...t)}}if(n==null||n.length===0)return{files:i,dirs:a};let o=this.getGlobalWorkflowsDir();for(let t of n){let n=await this.writeGlobalWorkflow(e,o,t);i.push(n)}return{files:i,dirs:a}}async writeProjectOutputs(){return{files:[],dirs:[]}}getSkillsDir(){return i.join(this.getCodeiumWindsurfDir(),vy)}getCodeiumWindsurfDir(){return i.join(this.getHomeDir(),my)}getGlobalMemoriesDir(){return i.join(this.getCodeiumWindsurfDir(),gy)}getGlobalWorkflowsDir(){return i.join(this.getCodeiumWindsurfDir(),hy)}async writeGlobalMemory(e,t){let n=this.getGlobalMemoriesDir(),r=i.join(n,_y),a=this.getCodeiumWindsurfDir(),o={pathKind:L.Relative,path:i.join(gy,_y),basePath:a,getDirectoryName:()=>gy,getAbsolutePath:()=>r};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMemory`,path:r}),{path:o,success:!0,skipped:!1};try{return this.ensureDirectory(n),this.writeFileSync(r,t),this.log.trace({action:`write`,type:`globalMemory`,path:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalMemory`,path:r,error:t}),{path:o,success:!1,error:e}}}async writeGlobalWorkflow(e,t,n){let a=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),o=this.transformFastCommandName(n,a),s=i.join(t,o),c={pathKind:L.Relative,path:i.join(hy,o),basePath:this.getCodeiumWindsurfDir(),getDirectoryName:()=>hy,getAbsolutePath:()=>s},l=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalWorkflow`,path:s}),{path:c,success:!0,skipped:!1};try{return this.ensureDirectory(t),r.writeFileSync(s,l),this.log.trace({action:`write`,type:`globalWorkflow`,path:s}),{path:c,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalWorkflow`,path:s,error:t}),{path:c,success:!1,error:e}}}async writeGlobalSkill(e,t,n){let r=[],a=n.yamlFrontMatter.name,o=i.join(t,a),s=i.join(o,yy),c=this.getCodeiumWindsurfDir(),l={pathKind:L.Relative,path:i.join(vy,a,yy),basePath:c,getDirectoryName:()=>a,getAbsolutePath:()=>s},u=this.buildSkillFrontMatter(n),d=n.content,f=Ag(u,d);if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`skill`,path:s}),r.push({path:l,success:!0,skipped:!1});else try{this.ensureDirectory(o),this.writeFileSync(s,f),this.log.trace({action:`write`,type:`skill`,path:s}),r.push({path:l,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skill`,path:s,error:t}),r.push({path:l,success:!1,error:e})}if(n.childDocs!=null)for(let t of n.childDocs){let n=await this.writeSkillChildDoc(e,t,o,a,c);r.push(n)}if(n.resources!=null)for(let t of n.resources){let n=await this.writeSkillResource(e,t,o,a,c);r.push(n)}return r}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:t.name,description:t.description,...t.displayName!=null&&{displayName:t.displayName},...t.keywords!=null&&t.keywords.length>0&&{keywords:t.keywords},...t.author!=null&&{author:t.author},...t.version!=null&&{version:t.version},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}async writeSkillChildDoc(e,t,n,r,a){let o=t.relativePath.replace(/\.mdx$/,`.md`),s=i.join(n,o),c={pathKind:L.Relative,path:i.join(vy,r,o),basePath:a,getDirectoryName:()=>r,getAbsolutePath:()=>s},l=t.content;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`childDoc`,path:s}),{path:c,success:!0,skipped:!1};try{let e=i.dirname(s);return this.ensureDirectory(e),this.writeFileSync(s,l),this.log.trace({action:`write`,type:`childDoc`,path:s}),{path:c,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`childDoc`,path:s,error:t}),{path:c,success:!1,error:e}}}async writeSkillResource(e,t,n,r,a){let o=i.join(n,t.relativePath),s={pathKind:L.Relative,path:i.join(vy,r,t.relativePath),basePath:a,getDirectoryName:()=>r,getAbsolutePath:()=>o};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`resource`,path:o}),{path:s,success:!0,skipped:!1};try{let e=i.dirname(o);if(this.ensureDirectory(e),t.encoding===`base64`){let e=d.from(t.content,`base64`);this.writeFileSyncBuffer(o,e)}else this.writeFileSync(o,t.content);return this.log.trace({action:`write`,type:`resource`,path:o}),{path:s,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`resource`,path:o,error:t}),{path:s,success:!1,error:e}}}},xy=class e extends fy{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,mcpConfig:r}=e,i={type:`repo`,repoId:this.generateEntryId(`local`),repoName:t},a=r==null?null:Object.keys(r.mcpServers);return{name:n.name,description:n.description,...a!=null&&a.length>0&&{mcpServers:a},...n.author!=null&&{author:n.author},keywords:n.keywords??[],...n.displayName!=null&&{displayName:n.displayName},installed:!0,installedAt:new Date().toISOString(),installPath:t,source:i,sourcePath:t}}getOfficialRegistry(){try{return JSON.parse({version:`1.0.0`,powers:{postman:{name:`postman`,description:`Automate API testing and collection management with Postman - create workspaces, collections, environments, and run tests programmatically`,displayName:`API Testing with Postman`,author:`Postman`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/postman.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/postman`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`postman`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},figma:{name:`figma`,description:`Connect Figma designs to code components - automatically generate design system rules, map UI components to Figma designs, and maintain design-code consistency`,displayName:`Design to Code with Figma`,author:`Figma`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/figma.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/figma`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`figma`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"netlify-deployment":{name:`netlify-deployment`,description:`Deploy React, Next.js, Vue, and other modern web apps to Netlify's global CDN with automatic builds.`,displayName:`Deploy web apps with Netlify`,author:`Netlify`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/netlify.png`,repositoryUrl:`https://github.com/netlify/context-and-tools/tree/main/context/steering/netlify-deployment-power`,license:``,repositoryCloneUrl:`git@github.com:netlify/context-and-tools.git`,pathInRepo:`context/steering/netlify-deployment-power`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"amazon-aurora-postgresql":{name:`amazon-aurora-postgresql`,description:`Build applications backed by Aurora PostgreSQL by leveraging Aurora PostgreSQL specific best practices.`,displayName:`Build applications with Aurora PostgreSQL`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/amazon-aurora.png`,repositoryUrl:`https://github.com/awslabs/mcp/tree/main/src/postgres-mcp-server/kiro_power`,license:``,repositoryCloneUrl:`git@github.com:awslabs/mcp.git`,pathInRepo:`src/postgres-mcp-server/kiro_power`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"supabase-hosted":{name:`supabase-hosted`,description:`Build applications with Supabase's Postgres database, authentication, storage, and real-time subscriptions`,displayName:`Build a backend with Supabase`,author:`Supabase`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/supabase.png`,repositoryUrl:`https://github.com/supabase-community/kiro-powers/tree/main/powers/supabase-hosted`,license:``,repositoryCloneUrl:`git@github.com:supabase-community/kiro-powers.git`,pathInRepo:`powers/supabase-hosted`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"supabase-local":{name:`supabase-local`,description:`Local development with Supabase allows you to work on your projects in a self-contained environment on your local machine.`,displayName:`Build a backend (local) with Supabase`,author:`Supabase`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/supabase.png`,repositoryUrl:`https://github.com/supabase-community/kiro-powers/tree/main/powers/supabase-local`,license:``,repositoryCloneUrl:`git@github.com:supabase-community/kiro-powers.git`,pathInRepo:`powers/supabase-local`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},terraform:{name:`terraform`,description:`Build and manage Infrastructure as Code with Terraform - access registry providers, modules, policies, and HCP Terraform workflow management`,displayName:`Deploy infrastructure with Terraform`,author:`HashiCorp`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/terraform.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/terraform`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`terraform`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},strands:{name:`strands`,description:`Build AI agents with Strands Agent SDK using Bedrock, Anthropic, OpenAI, Gemini, or Llama models`,displayName:`Build an agent with Strands`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/strands.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/strands`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`strands`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aws-agentcore":{name:`aws-agentcore`,description:`Amazon Bedrock AgentCore is an agentic platform for building, deploying, and operating effective agents.`,displayName:`Build an agent with Amazon Bedrock AgentCore`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/agentcore.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aws-agentcore`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aws-agentcore`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},neon:{name:`neon`,description:`Serverless Postgres with database branching, autoscaling, and scale-to-zero - perfect for modern development workflows`,displayName:`Build a database with Neon`,author:`Neon`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/neon.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/neon`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`neon`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},datadog:{name:`datadog`,description:`Query logs, metrics, traces, RUM events, incidents, and monitors from Datadog for production debugging and performance analysis`,displayName:`Datadog Observability`,author:`Datadog`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/datadog.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/datadog`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`datadog`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},dynatrace:{name:`dynatrace`,description:`Query logs, metrics, traces, problems, and Kubernetes events from Dynatrace using DQL for production debugging and performance analysis`,displayName:`Dynatrace Observability`,author:`Dynatrace`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/dynatrace.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/dynatrace`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`dynatrace`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},stripe:{name:`stripe`,description:`Build payment integrations with Stripe - accept payments, manage subscriptions, handle billing, and process refunds`,displayName:`Stripe Payments`,author:`Stripe`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/stripe.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/stripe`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`stripe`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aws-infrastructure-as-code":{name:`aws-infrastructure-as-code`,description:`Build well-architected AWS infrastructure with CDK using latest documentation, best practices, and code samples. Validate CloudFormation templates, check resource configuration security compliance, and troubleshoot deployments.`,displayName:`Build AWS infrastructure with CDK and CloudFormation`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/iac.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aws-infrastructure-as-code`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aws-infrastructure-as-code`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"power-builder":{name:`power-builder`,description:`Complete guide for building and testing new Kiro Powers with templates, best practices, and validation`,displayName:`Build a Power`,author:`Kiro Team`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/power-builder`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`power-builder`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"saas-builder":{name:`saas-builder`,description:`Build production ready multi-tenant SaaS applications with serverless architecture, integrated billing, and enterprise grade security`,displayName:`SaaS Builder`,author:`Allen Helton`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/saas-builder`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`saas-builder`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"cloud-architect":{name:`cloud-architect`,description:`Build AWS infrastructure with CDK in Python following AWS Well-Architected framework best practices`,displayName:`Build infrastructure on AWS`,author:`Christian Bonzelet`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/cloud-architect`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`cloud-architect`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aurora-dsql":{name:`aurora-dsql`,description:`For PostgreSQL compatible serverless distributed SQL database with Aurora DSQL, manage schemas, execute queries, and handle migrations with DSQL-specific constraints`,displayName:`Deploy a distributed SQL database on AWS`,author:`Rolf Koski`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aurora-dsql`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aurora-dsql`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}}},repoSources:{},lastUpdated:`2025-12-28T20:19:10.824Z`,kiroRecommendedRepo:{url:`https://prod.download.desktop.kiro.dev/powers/default_registry.json`,lastFetch:`2025-12-28T20:19:10.823Z`,powerCount:18}})}catch{this.log.debug(`Failed to parse official registry, using empty registry`)}return this.createInitialRegistry()}unregisterLocalPowers(e){let t={...this.getOfficialRegistry(),lastUpdated:new Date().toISOString()};return this.log.trace({action:e===!0?`dryRun`:`reset`,type:`registry`,powerCount:Object.keys(t.powers).length}),this.write(t,e)}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}}};const Sy=`GLOBAL.md`,Cy=`.kiro`,wy=`steering`,Ty=`settings`,Ey=`mcp.json`,Dy=`POWER.md`,Oy=`SKILL.md`;var ky=class extends Pg{constructor(){super(`KiroCLIOutputPlugin`,{globalConfigDir:Cy,outputFileName:Sy}),this.registerCleanEffect(`registry-cleanup`,async e=>this.getRegistryWriter(xy).unregisterLocalPowers(e.dryRun)?{success:!0,description:`Reset registry`}:{success:!1,description:`Failed`,error:Error(`Registry cleanup failed`)}),this.registerCleanEffect(`mcp-settings-cleanup`,async e=>{let t=this.joinPath(this.getGlobalSettingsDir(),Ey),n=JSON.stringify({mcpServers:{},powers:{mcpServers:{}}},null,2);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpSettingsCleanup`,path:t}),{success:!0,description:`Would reset mcp.json`};let r=await this.writeFile(e,t,n,`mcpSettingsCleanup`);return r.success?{success:!0,description:`Reset mcp.json`}:{success:!1,description:`Failed`,error:r.error??Error(`Cleanup failed`)}})}getGlobalSettingsDir(){return this.joinPath(this.getHomeDir(),Cy,Ty)}getGlobalSteeringDir(){return this.joinPath(this.getGlobalConfigDir(),wy)}getKiroPowersDir(){return this.joinPath(this.getHomeDir(),`.kiro/powers/installed`)}getKiroSkillsDir(){return this.joinPath(this.getHomeDir(),`.kiro/skills`)}async registerProjectOutputDirs(e){let{projects:t}=e.collectedInputContext.workspace;return t.filter(e=>e.dirFromWorkspacePath!=null).map(e=>this.createRelativePath(this.joinPath(e.dirFromWorkspacePath.path,Cy,wy),e.dirFromWorkspacePath.basePath,()=>wy))}async registerProjectOutputFiles(e){let{projects:t}=e.collectedInputContext.workspace,n=[];for(let e of t)if(!(e.dirFromWorkspacePath==null||e.childMemoryPrompts==null))for(let t of e.childMemoryPrompts)n.push(this.createRelativePath(this.joinPath(e.dirFromWorkspacePath.path,Cy,wy,this.buildSteeringFileName(t)),e.dirFromWorkspacePath.basePath,()=>wy));return n}async registerGlobalOutputDirs(){let e=[this.createRelativePath(wy,this.getGlobalConfigDir(),()=>wy)],t=this.getKiroPowersDir();for(let n of this.listInstalledPowers(t))e.push(this.createRelativePath(n,t,()=>n));let n=this.getKiroSkillsDir();for(let t of this.listInstalledPowers(n))e.push(this.createRelativePath(t,n,()=>t));return e.push(this.createRelativePath(`repos`,this.joinPath(this.getHomeDir(),`.kiro/powers`),()=>`repos`)),e}listInstalledPowers(e){try{return this.existsSync(e)?this.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name):[]}catch{return[]}}async registerGlobalOutputFiles(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=this.getGlobalSteeringDir(),a=[];if(t!=null&&a.push(this.createRelativePath(Sy,i,()=>wy)),n!=null)for(let e of n)a.push(this.createRelativePath(this.buildFastCommandSteeringFileName(e),i,()=>wy));if(r==null)return a;let o=this.getKiroPowersDir(),s=this.getKiroSkillsDir();for(let e of r){let t=e.yamlFrontMatter.name;if(e.mcpConfig!=null){let n=this.joinPath(o,t);if(a.push(this.createRelativePath(Dy,n,()=>t)),a.push(this.createRelativePath(Ey,n,()=>t)),e.childDocs!=null)for(let t of e.childDocs)a.push(this.createRelativePath(this.joinPath(wy,t.dir.path.replace(/\.mdx$/,`.md`)),n,()=>wy));if(e.resources!=null)for(let t of e.resources)a.push(this.createRelativePath(this.joinPath(wy,t.relativePath),n,()=>wy))}else{let n=this.joinPath(s,t);if(a.push(this.createRelativePath(Oy,n,()=>t)),e.childDocs!=null)for(let r of e.childDocs)a.push(this.createRelativePath(r.dir.path.replace(/\.mdx$/,`.md`),n,()=>t));if(e.resources!=null)for(let r of e.resources)a.push(this.createRelativePath(r.relativePath,n,()=>t))}}return r.some(e=>e.mcpConfig!=null)&&a.push(this.createRelativePath(Ey,this.getGlobalSettingsDir(),()=>Ty)),a}async canWrite(e){let{workspace:t,globalMemory:n,fastCommands:r,skills:i}=e.collectedInputContext;return t.projects.some(e=>(e.childMemoryPrompts?.length??0)>0)||n!=null||(r?.length??0)>0||(i?.length??0)>0?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[];for(let r of t)if(!(r.dirFromWorkspacePath==null||r.childMemoryPrompts==null))for(let t of r.childMemoryPrompts)n.push(await this.writeSteeringFile(e,r,t));return{files:n,dirs:[]}}async writeGlobalOutputs(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=[],o=this.getGlobalSteeringDir();if(t!=null&&i.push(await this.writeFile(e,this.joinPath(o,Sy),t.content,`globalMemory`)),n!=null)for(let t of n)i.push(await this.writeFastCommandSteeringFile(e,t));if(r==null||r.length===0)return{files:i,dirs:[]};let s=r.filter(e=>e.mcpConfig!=null),c=r.filter(e=>e.mcpConfig==null);for(let t of s){let{fileResults:n,registryResult:r}=await this.writeSkillAsPower(e,t);i.push(...n),a.push(r)}for(let t of c){let n=await this.writeSkillAsKiroSkill(e,t);i.push(...n)}let l=await this.writeGlobalMcpSettings(e,r);return l!=null&&i.push(l),this.logRegistryResults(a,e.dryRun),{files:i,dirs:[]}}async writeGlobalMcpSettings(e,t){let n={};for(let e of t)if(e.mcpConfig!=null)for(let[t,r]of Object.entries(e.mcpConfig.mcpServers))n[`power-${e.yamlFrontMatter.name}-${t}`]=r;if(Object.keys(n).length===0)return null;let r=JSON.stringify({mcpServers:{},powers:{mcpServers:n}},null,2);return this.writeFile(e,this.joinPath(this.getGlobalSettingsDir(),Ey),r,`globalMcpSettings`)}logRegistryResults(e,t){let n=e.filter(e=>e.success).length,r=e.filter(e=>!e.success).length;n>0&&this.log.trace({action:t===!0?`dryRun`:`register`,type:`registrySummary`,successCount:n}),r>0&&this.log.error({action:`register`,type:`registrySummary`,failCount:r})}async writeSkillAsPower(e,t){let n=[],r=t.yamlFrontMatter.name,i=this.joinPath(this.getKiroPowersDir(),r),a=this.joinPath(i,Dy),o=`${this.buildPowerFrontMatter(t.yamlFrontMatter)}\n${t.content}`;if(n.push(await this.writeFile(e,a,o,`skillPower`)),t.childDocs!=null){let r=this.joinPath(i,wy);for(let i of t.childDocs){let t=i.dir.path.replace(/\.mdx$/,`.md`);n.push(await this.writeFile(e,this.joinPath(r,t),i.content,`refDoc`))}}if(t.resources!=null){let r=this.joinPath(i,wy);for(let i of t.resources)n.push(await this.writeFile(e,this.joinPath(r,i.relativePath),i.content,`resource`))}t.mcpConfig!=null&&n.push(await this.writeFile(e,this.joinPath(i,Ey),t.mcpConfig.rawContent,`mcpConfig`));let s=this.getRegistryWriter(xy),c=s.buildPowerEntry(t,i);return{fileResults:n,registryResult:(await this.registerInRegistry(s,[c],e))[0]??{success:!1,entryName:r,error:Error(`No registry result`)}}}async writeSkillAsKiroSkill(e,t){let n=[],r=t.yamlFrontMatter.name,i=this.joinPath(this.getKiroSkillsDir(),r),a=this.joinPath(i,Oy),o=`${this.buildSkillFrontMatter(t.yamlFrontMatter)}\n${t.content}`;if(n.push(await this.writeFile(e,a,o,`kiroSkill`)),t.childDocs!=null)for(let r of t.childDocs){let t=r.dir.path.replace(/\.mdx$/,`.md`);n.push(await this.writeFile(e,this.joinPath(i,t),r.content,`refDoc`))}if(t.resources!=null)for(let r of t.resources)n.push(await this.writeFile(e,this.joinPath(i,r.relativePath),r.content,`resource`));return n}buildSkillFrontMatter(e){return this.buildMarkdownContent(``,{name:e.name,description:e.description,...e.displayName!=null&&{displayName:e.displayName},...e.keywords!=null&&e.keywords.length>0&&{keywords:e.keywords},...e.author!=null&&{author:e.author}}).trimEnd()}buildPowerFrontMatter(e){return this.buildMarkdownContent(``,{name:e.name,displayName:e.displayName,description:e.description,keywords:e.keywords,author:e.author}).trimEnd()}buildFastCommandSteeringFileName(e){return this.transformFastCommandName(e,{includeSeriesPrefix:!0,seriesSeparator:`-`})}async writeFastCommandSteeringFile(e,t){let n=this.buildFastCommandSteeringFileName(t),r=this.joinPath(this.getGlobalSteeringDir(),n),i=t.yamlFrontMatter?.description,a=this.buildMarkdownContent(t.content,{inclusion:`manual`,description:i!=null&&i.length>0?i:null});return this.writeFile(e,r,a,`fastCommandSteering`)}buildSteeringFileName(e){return`kiro-${(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`)}.md`}async writeSteeringFile(e,t,n){let r=t.dirFromWorkspacePath,i=this.buildSteeringFileName(n),a=this.joinPath(r.basePath,r.path,Cy,wy),o=this.joinPath(a,i),s=n.workingChildDirectoryPath?.path??n.dir.path,c=this.buildMarkdownContent(n.content,{inclusion:`fileMatch`,fileMatchPattern:`${s.replaceAll(`\\`,`/`)}/**`});return this.writeFile(e,o,c,`steeringFile`)}};const Ay=`agt.mdx`,jy=[`node_modules`,`.git`];var My=class extends Lg{constructor(){super(`ProjectPromptInputPlugin`,[`ShadowProjectInputPlugin`])}async collect(e){let{dependencyContext:t,fs:n,userConfigOptions:r,path:i,globalScope:a}=e,{workspaceDir:o,shadowProjectDir:s}=this.resolveBasePaths(r),c=r.shadowProjectsDir,l=this.resolvePath(c,o,s),u=t.workspace;if(u==null)return this.log.warn(`No workspace found in dependency context, skipping project prompt enhancement`),{};let d=u.projects??[],f=await Promise.all(d.map(async t=>{let r=t.name;if(r==null)return t;let o=i.join(l,r);if(!n.existsSync(o)||!n.statSync(o).isDirectory())return t;let s=t.dirFromWorkspacePath?.getAbsolutePath(),c=await this.readRootMemoryPrompt(e,o,a),u=s==null?[]:await this.scanChildMemoryPrompts(e,o,s,a);return{...t,...c!=null&&{rootMemoryPrompt:c},...u.length>0&&{childMemoryPrompts:u}}}));return{workspace:{directory:u.directory,projects:f}}}async readRootMemoryPrompt(e,t,r){let{fs:i,path:a,logger:o}=e,s=a.join(t,Ay);if(!(!i.existsSync(s)||!i.statSync(s).isFile()))try{let e=i.readFileSync(s,`utf8`),a=jg(e),c;try{c=await fv(e,{globalScope:r,basePath:t})}catch(e){throw e instanceof Yg&&(o.error(`MDX compilation failed in ${s}: ${e.message}`),o.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),n.exit(1)),e}return{type:Et.ProjectRootMemory,content:c,length:c.length,filePathKind:L.Relative,...a.yamlFrontMatter!=null&&{yamlFrontMatter:a.yamlFrontMatter},...a.rawFrontMatter!=null&&{rawFrontMatter:a.rawFrontMatter},markdownAst:a.markdownAst,markdownContents:a.markdownContents,dir:{pathKind:L.Root,path:``,getDirectoryName:()=>``}}}catch(e){o.error(`Failed to read root memory prompt at ${s}`,{error:e});return}}async scanChildMemoryPrompts(e,t,n,r){let{logger:i}=e,a=[];try{await this.scanDirectoryRecursive(e,t,t,n,a,r)}catch(e){i.error(`Failed to scan child memory prompts at ${t}`,{error:e})}return a}async scanDirectoryRecursive(e,t,n,r,i,a){let{fs:o,path:s}=e,c=o.readdirSync(n,{withFileTypes:!0});for(let l of c){if(!l.isDirectory()||jy.includes(l.name))continue;let c=s.join(n,l.name),u=s.join(c,Ay);if(o.existsSync(u)&&o.statSync(u).isFile()){let n=await this.readChildMemoryPrompt(e,t,c,r,a);n!=null&&i.push(n)}await this.scanDirectoryRecursive(e,t,c,r,i,a)}}async readChildMemoryPrompt(e,t,r,i,a){let{fs:o,path:s,logger:c}=e,l=s.join(r,Ay);try{let e=o.readFileSync(l,`utf8`),u=jg(e),d;try{d=await fv(e,{globalScope:a,basePath:r})}catch(e){throw e instanceof Yg&&(c.error(`MDX compilation failed in ${l}: ${e.message}`),c.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),n.exit(1)),e}let f=s.relative(t,r),p=s.join(i,f),m=s.basename(r);return{type:Et.ProjectChildrenMemory,content:d,length:d.length,filePathKind:L.Relative,...u.yamlFrontMatter!=null&&{yamlFrontMatter:u.yamlFrontMatter},...u.rawFrontMatter!=null&&{rawFrontMatter:u.rawFrontMatter},markdownAst:u.markdownAst,markdownContents:u.markdownContents,dir:{pathKind:L.Relative,path:f,basePath:i,getDirectoryName:()=>m,getAbsolutePath:()=>p},workingChildDirectoryPath:{pathKind:L.Relative,path:f,basePath:i,getDirectoryName:()=>m,getAbsolutePath:()=>p}}}catch(e){c.error(`Failed to read child memory prompt at ${l}`,{error:e});return}}};const Ny=`.qoder`,Py=`rules`,Fy=`commands`,Iy=`skills`,Ly=`global.md`,Ry=`always.md`,zy=`SKILL.md`,By=`mcp.json`;var Vy=class extends Pg{constructor(){super(`QoderIDEPluginOutputPlugin`,{globalConfigDir:Ny})}async registerProjectOutputDirs(e){let{projects:t}=e.collectedInputContext.workspace;return t.filter(e=>e.dirFromWorkspacePath!=null).map(e=>this.createProjectRulesDirPath(e.dirFromWorkspacePath))}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{globalMemory:r}=e.collectedInputContext;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&(r!=null&&t.push(this.createProjectRuleFilePath(n,Ly)),e.rootMemoryPrompt!=null&&t.push(this.createProjectRuleFilePath(n,Ry)),e.childMemoryPrompts!=null))for(let r of e.childMemoryPrompts)t.push(this.createProjectRuleFilePath(n,this.buildChildRuleFileName(r)))}return t}async registerGlobalOutputDirs(e){let t=this.getGlobalConfigDir(),{fastCommands:n,skills:r}=e.collectedInputContext,a=[];if(n!=null&&n.length>0&&a.push(this.createRelativePath(Fy,t,()=>Fy)),r!=null&&r.length>0)for(let e of r){let n=e.yamlFrontMatter.name;a.push(this.createRelativePath(i.join(Iy,n),t,()=>n))}return a}async registerGlobalOutputFiles(e){let t=this.getGlobalConfigDir(),{fastCommands:n,skills:r}=e.collectedInputContext,a=[],o=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});if(n!=null&&n.length>0)for(let e of n){let n=this.transformFastCommandName(e,o);a.push(this.createRelativePath(i.join(Fy,n),t,()=>Fy))}if(r!=null&&r.length>0)for(let e of r){let n=e.yamlFrontMatter.name;if(a.push(this.createRelativePath(i.join(Iy,n,zy),t,()=>n)),e.mcpConfig!=null&&a.push(this.createRelativePath(i.join(Iy,n,By),t,()=>n)),e.childDocs!=null)for(let r of e.childDocs)a.push(this.createRelativePath(i.join(Iy,n,r.relativePath.replace(/\.mdx$/,`.md`)),t,()=>n));if(e.resources!=null)for(let r of e.resources)a.push(this.createRelativePath(i.join(Iy,n,r.relativePath),t,()=>n))}return a}async canWrite(e){let{workspace:t,globalMemory:n,fastCommands:r,skills:i}=e.collectedInputContext;return t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)||n!=null||(r?.length??0)>0||(i?.length??0)>0?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{globalMemory:n}=e.collectedInputContext,r=[];for(let i of t){if(i.dirFromWorkspacePath==null)continue;let t=i.dirFromWorkspacePath;if(n!=null){let i=this.buildAlwaysRuleContent(n.content);r.push(await this.writeProjectRuleFile(e,t,Ly,i,`globalRule`))}if(i.rootMemoryPrompt!=null){let n=this.buildAlwaysRuleContent(i.rootMemoryPrompt.content);r.push(await this.writeProjectRuleFile(e,t,Ry,n,`projectRootRule`))}if(i.childMemoryPrompts!=null)for(let n of i.childMemoryPrompts){let i=this.buildChildRuleFileName(n),a=this.buildGlobRuleContent(n);r.push(await this.writeProjectRuleFile(e,t,i,a,`projectChildRule`))}}return{files:r,dirs:[]}}async writeGlobalOutputs(e){let{fastCommands:t,skills:n}=e.collectedInputContext,r=[],a=this.getGlobalConfigDir(),o=i.join(a,Fy),s=i.join(a,Iy);if(t!=null&&t.length>0)for(let n of t)r.push(await this.writeGlobalFastCommand(e,o,n));if(n!=null&&n.length>0)for(let t of n)r.push(...await this.writeGlobalSkill(e,s,t));return{files:r,dirs:[]}}createProjectRulesDirPath(e){return this.createRelativePath(i.join(e.path,Ny,Py),e.basePath,()=>Py)}createProjectRuleFilePath(e,t){return this.createRelativePath(i.join(e.path,Ny,Py,t),e.basePath,()=>Py)}buildChildRuleFileName(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`);return`glob-${t.length>0?t:`root`}.md`}buildAlwaysRuleContent(e){return Ag({trigger:`always_on`,type:`user_command`},e)}buildGlobRuleContent(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``);return Ag({trigger:`glob`,glob:t.length===0?`**/*`:`${t}/**`,type:`user_command`},e.content)}async writeProjectRuleFile(e,t,n,r,a){let o=i.join(t.basePath,t.path,Ny,Py),s=i.join(o,n);return this.writeFile(e,s,r,a)}async writeGlobalFastCommand(e,t,n){let r=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),a=this.transformFastCommandName(n,r),o=i.join(t,a),s=Ag(this.buildFastCommandFrontMatter(n),n.content);return this.writeFile(e,o,s,`globalFastCommand`)}async writeGlobalSkill(e,t,n){let r=[],a=n.yamlFrontMatter.name,o=i.join(t,a),s=i.join(o,zy),c=Ag(this.buildSkillFrontMatter(n),n.content);if(r.push(await this.writeFile(e,s,c,`skill`)),n.mcpConfig!=null){let t=i.join(o,By);r.push(await this.writeFile(e,t,n.mcpConfig.rawContent,`mcpConfig`))}if(n.childDocs!=null)for(let t of n.childDocs){let n=i.join(o,t.relativePath.replace(/\.mdx$/,`.md`));r.push(await this.writeFile(e,n,t.content,`childDoc`))}if(n.resources!=null)for(let t of n.resources){let n=i.join(o,t.relativePath);if(t.encoding===`base64`){let e=d.from(t.content,`base64`),s=i.dirname(n);this.ensureDirectory(s),this.writeFileSyncBuffer(n,e),r.push({path:this.createRelativePath(t.relativePath,o,()=>a),success:!0})}else r.push(await this.writeFile(e,n,t.content,`resource`))}return r}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:t.name,description:t.description,type:`user_command`,...t.displayName!=null&&{displayName:t.displayName},...t.keywords!=null&&t.keywords.length>0&&{keywords:t.keywords},...t.author!=null&&{author:t.author},...t.version!=null&&{version:t.version},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}buildFastCommandFrontMatter(e){let t=e.yamlFrontMatter;return t==null?{description:`Fast command`,type:`user_command`}:{description:t.description,type:`user_command`,...t.argumentHint!=null&&{argumentHint:t.argumentHint},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}};const Hy=`README.md`;var Uy=class extends Pg{constructor(){super(`ReadmeMdConfigFileOutputPlugin`,{outputFileName:Hy})}async registerProjectOutputFiles(e){let t=[],{readmePrompts:n}=e.collectedInputContext;if(n==null||n.length===0)return t;for(let e of n){let{targetDir:n}=e,r=i.join(n.path,Hy);t.push({pathKind:L.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?.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{targetDir:n}=t,a=i.join(n.path,Hy),o=i.join(n.basePath,a),s=t.content,c={pathKind:L.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.trace({action:`dryRun`,type:`readme`,path:o,label:l}),{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,`utf8`),this.log.trace({action:`write`,type:`readme`,path:o,label:l}),{path:c,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`readme`,path:o,label:l,error:t}),{path:c,success:!1,error:e}}}},Wy=class extends Lg{constructor(){super(`ReadmeMdInputPlugin`,[`ShadowProjectInputPlugin`])}async collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i,globalScope:a}=e,{workspaceDir:o,shadowProjectDir:s}=this.resolveBasePaths(t),c=t.shadowProjectsDir,l=this.resolvePath(c,o,s),u=[];if(!r.existsSync(l)||!r.statSync(l).isDirectory())return n.debug(`shadow projects directory does not exist`,{path:l}),{readmePrompts:u};try{let t=r.readdirSync(l,{withFileTypes:!0});for(let n of t){if(!n.isDirectory())continue;let t=n.name,r=i.join(l,t);await this.collectReadmeFiles(e,r,t,o,``,u,a)}}catch(e){n.error(`failed to scan shadow projects`,{path:l,error:e})}return{readmePrompts:u}}async collectReadmeFiles(e,t,r,i,a,o,s){let{fs:c,path:l,logger:u}=e,d=a===``,f=l.join(t,`rdm.mdx`);if(c.existsSync(f)&&c.statSync(f).isFile())try{let e=c.readFileSync(f,`utf8`),p;if(s!=null)try{p=await fv(e,{globalScope:s,basePath:t})}catch(e){throw e instanceof Yg&&(u.error(`MDX compilation failed in ${f}: ${e.message}`),u.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),n.exit(1)),e}else p=e;let m=d?r:l.join(r,a),h={pathKind:L.Relative,path:m,basePath:i,getDirectoryName:()=>d?r:l.basename(a),getAbsolutePath:()=>l.resolve(i,m)},g={pathKind:L.Relative,path:l.dirname(f),basePath:i,getDirectoryName:()=>l.basename(l.dirname(f)),getAbsolutePath:()=>l.dirname(f)};o.push({type:Et.Readme,content:p,length:p.length,filePathKind:L.Relative,projectName:r,targetDir:h,isRoot:d,markdownContents:[],dir:g})}catch(e){u.warn(`failed to read readme`,{path:f,error:e})}try{let n=c.readdirSync(t,{withFileTypes:!0});for(let c of n)if(c.isDirectory()){let n=d?c.name:l.join(a,c.name),u=l.join(t,c.name);await this.collectReadmeFiles(e,u,r,i,n,o,s)}}catch(e){u.warn(`failed to scan directory`,{path:t,error:e})}}},Gy=class extends Lg{constructor(){super(`ShadowProjectInputPlugin`)}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.shadowProjectsDir,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:L.Relative,path:t.name,basePath:a,getDirectoryName:()=>t.name,getAbsolutePath:()=>i.resolve(a,t.name)}})}}catch(e){n.error(`failed to scan shadow projects`,{path:c,error:e})}if(u.length===0&&r.existsSync(a)&&r.statSync(a).isDirectory()){n.debug(`no projects in dist/app/, falling back to workspace scan`,{workspaceDir:a});try{let e=r.readdirSync(a,{withFileTypes:!0});for(let t of e)if(t.isDirectory()&&!t.name.startsWith(`.`)){let e=t.name===l;u.push({name:t.name,...e&&{isPromptSourceProject:!0},dirFromWorkspacePath:{pathKind:L.Relative,path:t.name,basePath:a,getDirectoryName:()=>t.name,getAbsolutePath:()=>i.resolve(a,t.name)}})}}catch(e){n.error(`failed to scan workspace directory`,{path:a,error:e})}}return{workspace:{directory:{pathKind:L.Absolute,path:a,getDirectoryName:()=>i.basename(a)},projects:u}}}};function Ky(e){return Bt.includes(e.toLowerCase())}function qy(e){let t=e.toLowerCase();return[`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.ico`,`.bmp`,`.tiff`,`.svg`].includes(t)?`image`:`.kt,.java,.py,.pyi,.pyx,.ts,.tsx,.js,.jsx,.mjs,.cjs,.go,.rs,.c,.cpp,.cc,.h,.hpp,.hxx,.cs,.fs,.fsx,.vb,.rb,.php,.swift,.scala,.groovy,.lua,.r,.jl,.ex,.exs,.erl,.clj,.cljs,.hs,.ml,.mli,.nim,.zig,.v,.dart,.vue,.svelte,.d.ts,.d.mts,.d.cts`.split(`,`).includes(t)?`code`:[`.sql`,`.json`,`.jsonc`,`.json5`,`.xml`,`.xsd`,`.xsl`,`.xslt`,`.yaml`,`.yml`,`.toml`,`.csv`,`.tsv`,`.graphql`,`.gql`,`.proto`].includes(t)?`data`:[`.txt`,`.text`,`.rtf`,`.log`,`.docx`,`.doc`,`.xlsx`,`.xls`,`.pptx`,`.ppt`,`.pdf`,`.odt`,`.ods`,`.odp`].includes(t)?`document`:[`.ini`,`.conf`,`.cfg`,`.config`,`.properties`,`.env`,`.envrc`,`.editorconfig`,`.gitignore`,`.gitattributes`,`.npmrc`,`.nvmrc`,`.npmignore`,`.eslintrc`,`.prettierrc`,`.stylelintrc`,`.babelrc`,`.browserslistrc`].includes(t)?`config`:[`.sh`,`.bash`,`.zsh`,`.fish`,`.ps1`,`.psm1`,`.psd1`,`.bat`,`.cmd`].includes(t)?`script`:`.exe,.dll,.so,.dylib,.bin,.wasm,.class,.jar,.war,.pyd,.pyc,.pyo,.zip,.tar,.gz,.bz2,.7z,.rar,.ttf,.otf,.woff,.woff2,.eot,.db,.sqlite,.sqlite3`.split(`,`).includes(t)?`binary`:`other`}function Jy(e){return{".ts":`text/typescript`,".tsx":`text/typescript`,".js":`text/javascript`,".jsx":`text/javascript`,".json":`application/json`,".py":`text/x-python`,".java":`text/x-java`,".kt":`text/x-kotlin`,".go":`text/x-go`,".rs":`text/x-rust`,".c":`text/x-c`,".cpp":`text/x-c++`,".cs":`text/x-csharp`,".rb":`text/x-ruby`,".php":`text/x-php`,".swift":`text/x-swift`,".scala":`text/x-scala`,".sql":`application/sql`,".xml":`application/xml`,".yaml":`text/yaml`,".yml":`text/yaml`,".toml":`text/toml`,".csv":`text/csv`,".graphql":`application/graphql`,".txt":`text/plain`,".pdf":`application/pdf`,".docx":`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,".xlsx":`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,".html":`text/html`,".css":`text/css`,".svg":`image/svg+xml`,".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".webp":`image/webp`,".ico":`image/x-icon`,".bmp":`image/bmp`}[e.toLowerCase()]}var Yy=class extends Lg{constructor(){super(`SkillInputPlugin`)}readMcpConfig(e,t,n){let r=i.join(e,`mcp.json`);if(t.existsSync(r)){if(!t.statSync(r).isFile()){n.warn(`mcp.json is not a file`,{skillDir:e});return}try{let i=t.readFileSync(r,`utf8`),a=JSON.parse(i);if(a.mcpServers==null||typeof a.mcpServers!=`object`){n.warn(`mcp.json missing mcpServers field`,{skillDir:e});return}return{type:Et.SkillMcpConfig,mcpServers:a.mcpServers,rawContent:i}}catch(t){n.warn(`failed to parse mcp.json`,{skillDir:e,error:t});return}}}scanSkillDirectory(e,t,n,r=``){let a=[],o=[],s=r?i.join(e,r):e;try{let c=t.readdirSync(s,{withFileTypes:!0});for(let l of c){let c=r?`${r}/${l.name}`:l.name;if(l.isDirectory()){let r=this.scanSkillDirectory(e,t,n,c);a.push(...r.childDocs),o.push(...r.resources)}else if(l.isFile()){let u=i.join(s,l.name);if(l.name.endsWith(`.mdx`)){if(r===``&&l.name===`skill.mdx`)continue;try{let n=jg(t.readFileSync(u,`utf8`)),r=Mg(n.contentWithoutFrontMatter);a.push({type:Et.SkillChildDoc,content:r,length:r.length,filePathKind:L.Relative,markdownAst:n.markdownAst,markdownContents:n.markdownContents,...n.rawFrontMatter!=null&&{rawFrontMatter:n.rawFrontMatter},relativePath:c,dir:{pathKind:L.Relative,path:c,basePath:e,getDirectoryName:()=>i.dirname(c),getAbsolutePath:()=>u}})}catch(e){n.warn(`failed to read child doc`,{path:c,error:e})}}else{if(r===``&&l.name===`mcp.json`)continue;let e=i.extname(l.name),a,s,f;try{if(Ky(e)){let e=t.readFileSync(u);a=e.toString(`base64`),s=`base64`,{length:f}=e}else a=t.readFileSync(u,`utf8`),s=`text`,{length:f}=d.from(a,`utf8`);let n=Jy(e),r={type:Et.SkillResource,extension:e,fileName:l.name,relativePath:c,content:a,encoding:s,category:qy(e),length:f};n==null?o.push(r):o.push({...r,mimeType:n})}catch(e){n.warn(`failed to read resource file`,{path:c,error:e})}}}}}catch(e){n.warn(`failed to scan directory`,{path:s,error:e})}return{childDocs:a,resources:o}}async collect(e){let{userConfigOptions:t,logger:n,globalScope:r}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.shadowSkillSourceDir,c=this.resolvePath(s,a,o),l=[];if(!(e.fs.existsSync(c)&&e.fs.statSync(c).isDirectory()))return{skills:l};let u=e.fs.readdirSync(c,{withFileTypes:!0});for(let t of u)if(t.isDirectory()){let a=e.path.join(c,t.name,`skill.mdx`);if(e.fs.existsSync(a)&&e.fs.statSync(a).isFile())try{let o=e.fs.readFileSync(a,`utf8`),s=jg(o),u=await fv(o,{globalScope:r,extractMetadata:!0,basePath:e.path.join(c,t.name)}),d={...s.yamlFrontMatter,...u.metadata.fields},f=Ft(d,a);for(let e of f.warnings)n.debug(e);if(!f.valid)throw new Qg(f.errors,a);let p=Mg(u.content),m=e.path.join(c,t.name),h=this.readMcpConfig(m,e.fs,n),{childDocs:g,resources:_}=this.scanSkillDirectory(m,e.fs,n);n.debug(`skill metadata extracted`,{skill:t.name,source:u.metadata.source,hasYaml:s.yamlFrontMatter!=null,hasExport:Object.keys(u.metadata.fields).length>0}),l.push({type:Et.Skill,content:p,length:p.length,filePathKind:L.Relative,yamlFrontMatter:d.name==null?{name:t.name,description:``}:d,...s.rawFrontMatter!=null&&{rawFrontMatter:s.rawFrontMatter},markdownAst:s.markdownAst,markdownContents:s.markdownContents,...h!=null&&{mcpConfig:h},...g.length>0&&{childDocs:g},..._.length>0&&{resources:_},dir:{pathKind:L.Relative,path:t.name,basePath:c,getDirectoryName:()=>t.name,getAbsolutePath:()=>i.join(c,t.name)}})}catch(e){n.error(`failed to parse skill`,{file:a,error:e})}}return{skills:l}}},Xy=class extends Av{constructor(){super(`SubAgentInputPlugin`,{configKey:`shadowSubAgentDir`})}getTargetDir(e,t){let n=e.shadowSubAgentDir,{workspaceDir:r,shadowProjectDir:i}=t;return this.resolvePath(n,r,i)}validateMetadata(e,t){return Lt(e,t)}createResult(e){return{subAgents:e}}createPrompt(e,t,n,r,i,a,o,s){return{type:Et.SubAgent,content:n,length:n.length,filePathKind:L.Relative,...r!=null&&{yamlFrontMatter:r},...i!=null&&{rawFrontMatter:i},markdownAst:a.markdownAst,markdownContents:a.markdownContents,dir:{pathKind:L.Relative,path:e,basePath:o,getDirectoryName:()=>e.replace(/\.mdx$/,``),getAbsolutePath:()=>t}}}};const Zy=`.vscode`,Qy=[`.vscode/settings.json`,`.vscode/extensions.json`];var $y=class extends Pg{constructor(){super(`VisualStudioCodeIDEConfigOutputPlugin`)}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{ideConfigFiles:r}=e.collectedInputContext;if(!r.some(e=>e.type===R.VSCode))return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&e.isPromptSourceProject!==!0)for(let e of Qy){let r=this.joinPath(n.path,e);t.push({pathKind:L.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===R.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===R.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:L.Relative,path:this.joinPath(t.path,i),basePath:t.basePath,getDirectoryName:()=>this.dirname(i),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`config`,path:a,label:r}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,n.content),this.log.trace({action:`write`,type:`config`,path:a,label:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`config`,path:a,label:r,error:t}),{path:o,success:!1,error:e}}}getTargetRelativePath(e){let t=e.dir.path;if(e.type!==R.VSCode)return this.basename(t);let n=t.indexOf(Zy);return n===-1?this.joinPath(Zy,this.basename(t)):t.slice(Math.max(0,n))}};const eb=`WARP.md`;var tb=class extends Pg{constructor(){super(`WarpIDEOutputPlugin`,{outputFileName:eb})}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,eb));else if(e.rootMemoryPrompt!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,eb)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,eb))}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}}},nb=class extends Lg{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:L.Relative,path:t,basePath:n,getDirectoryName:()=>i.basename(t)}}});return{workspace:{directory:{pathKind:L.Absolute,path:n,getDirectoryName:()=>i.basename(n)},projects:[]},shadowSourceProjectDir:r,...a.length>0&&{externalProjects:a}}}},rb=Dr({plugins:[new Ig,new Vg,new Jg,new mv,new yv,new ry,new kv,new Mv,new Lv,new ky,new uy,new Vy,new tb,new by,new Ov,new Uv,new oy,new $y,new Uy,new py,new dy,new sy,new nb,new Gy,new zg,new qv,new Yy,new jv,new Xy,new Kv,new My,new Wy,new Gv,new zv]});async function ib(){let e=await rb;await new yr(...n.argv).run(e)}ib().catch(e=>console.error(e));export{jt as CircularDependencyError,Dt as ClaudeCodeCLISubAgentColors,Ot as CodingAgentTools,mn as ConfigLoader,Nt as ConfigValidationError,ln as DEFAULT_CONFIG_FILE_NAME,un as DEFAULT_GLOBAL_CONFIG_DIR,Ut as DEFAULT_SHADOW_SOURCE_PROJECT_STRUCTURE,Jt as DEFAULT_USER_CONFIG,L as FilePathKind,At as GlobalConfigDirectoryType,R as IDEKind,Mt as MissingDependencyError,kt as NamingCaseKind,qt as PathPlaceholders,Tt as PluginKind,Et as PromptKind,Vt as SHADOW_SOURCE_DIR_NAMES,Ht as SHADOW_SOURCE_FILE_NAMES,z as SHADOW_SOURCE_RELATIVE_PATHS,Bt as SKILL_RESOURCE_BINARY_EXTENSIONS,zt as SKILL_RESOURCE_TEXT_EXTENSIONS,Rt as applyMetadataDefaults,_t as checkCanClean,yt as checkCanWrite,Ln as checkVersionControl,gt as collectAllPluginOutputs,cn as createLogger,rb as default,Dr as defineConfig,vt as executeOnCleanComplete,bt as executeWriteOutputs,zn as generateShadowSourceProject,gn as getConfigLoader,fn as getDefaultUserConfig,dn as getGlobalConfigPath,sn as getGlobalLogLevel,_n as loadUserConfig,Sr as mergeConfig,on as setGlobalLogLevel,vn as validateAndEnsureGlobalConfig,Pt as validateExportMetadata,It as validateFastCommandMetadata,Ft as validateSkillMetadata,Lt as validateSubAgentMetadata};
1204
+ `}collect(e){return{}}};const ly=`.config/opencode`,uy=`opencode.json`;var dy=class extends pv{constructor(){super(`OpencodeCLIOutputPlugin`,{globalConfigDir:ly,outputFileName:`AGENTS.md`,commandsSubDir:`commands`,agentsSubDir:`agents`,skillsSubDir:`skills`,supportsFastCommands:!0,supportsSubAgents:!0,supportsSkills:!0,dependsOn:[`AgentsOutputPlugin`]}),this.registerCleanEffect(`mcp-config-cleanup`,async e=>{let t=this.getGlobalConfigDir(),n=i.join(t,uy);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfigCleanup`,path:n}),{success:!0,description:`Would reset opencode.json mcp to empty`};try{if(r.existsSync(n)){let e=r.readFileSync(n,`utf8`),t=JSON.parse(e);t.mcp={},r.writeFileSync(n,JSON.stringify(t,null,2))}return this.log.trace({action:`clean`,type:`mcpConfigCleanup`,path:n}),{success:!0,description:`Reset opencode.json mcp to empty`}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`clean`,type:`mcpConfigCleanup`,path:n,error:t}),{success:!1,error:e,description:`Failed to reset opencode.json mcp`}}})}async registerGlobalOutputFiles(e){let t=await super.registerGlobalOutputFiles(e),n=this.getGlobalConfigDir();if(e.collectedInputContext.skills?.some(e=>e.mcpConfig!=null)??!1){let e=i.join(n,uy);t.push({pathKind:L.Relative,path:uy,basePath:n,getDirectoryName:()=>ly,getAbsolutePath:()=>e})}return t.map(e=>{let t=e.path.replaceAll(`\\`,`/`),r=`/${this.skillsSubDir}/`,a=`${this.skillsSubDir}/`;if(!(t.includes(r)||t.startsWith(a)))return e;let o=t.split(`/`),s=o.indexOf(this.skillsSubDir);if(s<0||s+1>=o.length)return e;let c=o[s+1];if(c==null)return e;let l=this.validateAndNormalizeSkillName(c),u=[...o];u[s+1]=l;let d=u.join(`/`);return{...e,path:d,getDirectoryName:()=>l,getAbsolutePath:()=>i.join(n,d.replaceAll(`/`,i.sep))}})}async writeGlobalOutputs(e){let t=await super.writeGlobalOutputs(e),n=[...t.files],{skills:r}=e.collectedInputContext;if(r==null)return{files:n,dirs:t.dirs};let i=await this.writeGlobalMcpConfig(e,r);return i!=null&&n.push(i),{files:n,dirs:t.dirs}}async writeGlobalMcpConfig(e,t){let n={};for(let e of t){if(e.mcpConfig==null)continue;let{mcpServers:t}=e.mcpConfig;for(let[e,r]of Object.entries(t))n[e]=this.transformMcpConfigForOpencode(r)}if(Object.keys(n).length===0)return null;let a=this.getGlobalConfigDir(),o=i.join(a,uy),s={pathKind:L.Relative,path:uy,basePath:a,getDirectoryName:()=>ly,getAbsolutePath:()=>o},c={};try{if(r.existsSync(o)){let e=r.readFileSync(o,`utf8`);c=JSON.parse(e)}}catch{c={}}c.$schema=`https://opencode.ai/config.json`,c.mcp=n;let l=JSON.stringify(c,null,2);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMcpConfig`,path:o,serverCount:Object.keys(n).length}),{path:s,success:!0,skipped:!1};try{return this.ensureDirectory(a),r.writeFileSync(o,l),this.log.trace({action:`write`,type:`globalMcpConfig`,path:o,serverCount:Object.keys(n).length}),{path:s,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalMcpConfig`,path:o,error:t}),{path:s,success:!1,error:e}}}transformMcpConfigForOpencode(e){let t={};if(e.command!=null){t.type=`local`;let n=[e.command];e.args!=null&&n.push(...e.args),t.command=n,e.env!=null&&(t.environment=e.env)}else{t.type=`remote`;let n=e;n.url==null?n.serverUrl!=null&&(t.url=n.serverUrl):t.url=n.url}return t.enabled=e.disabled!==!0,t}async writeSubAgent(e,t,n){let r=n.dir.path.endsWith(`.md`)?n.dir.path:`${n.dir.path}.md`,a=i.join(t,this.agentsSubDir),o=i.join(a,r),s=this.buildOpencodeAgentFrontMatter(n),c=this.buildMarkdownContent(n.content,s);return[await this.writeFile(e,o,c,`subAgent`)]}buildOpencodeAgentFrontMatter(e){let t={},n=e.yamlFrontMatter;if(n?.description!=null&&(t.description=n.description),t.mode=n?.mode??`subagent`,n?.model!=null&&(t.model=n.model),n?.temperature!=null&&(t.temperature=n.temperature),n?.maxSteps!=null&&(t.maxSteps=n.maxSteps),n?.hidden!=null&&(t.hidden=n.hidden),n?.allowTools!=null&&Array.isArray(n.allowTools)){let e={};for(let t of n.allowTools)e[String(t)]=!0;t.tools=e}n?.permission!=null&&typeof n.permission==`object`&&(t.permission=n.permission);for(let[e,r]of Object.entries(n??{}))[`description`,`mode`,`model`,`temperature`,`maxSteps`,`hidden`,`allowTools`,`permission`,`namingCase`,`name`,`color`].includes(e)||(t[e]=r);return t}async writeFastCommand(e,t,n){let r=this.getTransformOptionsFromContext(e),a=this.transformFastCommandName(n,r),o=i.join(t,this.commandsSubDir),s=i.join(o,a),c=this.buildOpencodeCommandFrontMatter(n),l=this.buildMarkdownContent(n.content,c);return[await this.writeFile(e,s,l,`fastCommand`)]}buildOpencodeCommandFrontMatter(e){let t={},n=e.yamlFrontMatter;if(n?.description!=null&&(t.description=n.description),n?.agent!=null&&(t.agent=n.agent),n?.model!=null&&(t.model=n.model),n?.allowTools!=null&&Array.isArray(n.allowTools)){let e={};for(let t of n.allowTools)e[String(t)]=!0;t.tools=e}for(let[e,r]of Object.entries(n??{}))[`description`,`agent`,`model`,`allowTools`,`namingCase`,`argumentHint`].includes(e)||(t[e]=r);return t}async writeSkill(e,t,n){let r=[],a=this.validateAndNormalizeSkillName(n.yamlFrontMatter?.name??n.dir.getDirectoryName()),o=i.join(t,this.skillsSubDir,a),s=i.join(o,`SKILL.md`),c=this.buildOpencodeSkillFrontMatter(n,a),l=this.buildMarkdownContent(n.content,c),u=await this.writeFile(e,s,l,`skill`);if(r.push(u),n.childDocs!=null)for(let i of n.childDocs){let n=await this.writeSkillReferenceDocument(e,o,a,i,t);r.push(...n)}if(n.resources!=null)for(let i of n.resources){let n=await this.writeSkillResource(e,o,a,i,t);r.push(...n)}return r}buildOpencodeSkillFrontMatter(e,t){let n={},r=e.yamlFrontMatter;n.name=t,r?.description!=null&&(n.description=r.description),n.license=r?.license??`MIT`,n.compatibility=r?.compatibility??`opencode`;let i={};for(let e of[`author`,`version`,`keywords`,`category`,`repository`,`displayName`])r?.[e]!=null&&(i[e]=r[e]);let a=new Set([`name`,`description`,`license`,`compatibility`,`namingCase`,`allowTools`,`keywords`,`displayName`,`author`,`version`]);for(let[e,t]of Object.entries(r??{}))a.has(e)||(i[e]=t);return Object.keys(i).length>0&&(n.metadata=i),n}validateAndNormalizeSkillName(e){let t=e.toLowerCase();return t=t.replaceAll(/[^a-z0-9-]+/g,`-`),t=t.replaceAll(/-+/g,`-`),t=t.replaceAll(/^-|-$/g,``),t.length===0?t=`skill`:t.length>64&&(t=t.slice(0,64),t=t.replace(/-$/,``)),t}},fy=class extends Lg{constructor(){super(`OrphanFileCleanupEffectInputPlugin`),this.registerEffect(`orphan-file-cleanup`,this.cleanupOrphanFiles.bind(this),20)}async cleanupOrphanFiles(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=n.join(r,`dist`),s=[],c=[],l=[];if(!t.existsSync(o))return a.debug({action:`orphan-cleanup`,message:`dist/ directory does not exist, skipping`,distDir:o}),{success:!0,description:`dist/ directory does not exist, nothing to clean`,deletedFiles:s,deletedDirs:c};for(let r of[`skills`,`commands`,`agents`,`app`]){let a=n.join(o,r);t.existsSync(a)&&this.cleanupDirectory(e,a,r,s,c,l,i??!1)}let u=l.length>0;return u&&a.warn({action:`orphan-cleanup`,errors:l.map(e=>({path:e.path,error:e.error.message}))}),{success:!u,description:i?`Would delete ${s.length} files and ${c.length} directories`:`Deleted ${s.length} files and ${c.length} directories`,deletedFiles:s,deletedDirs:c,...u&&{error:Error(`${l.length} errors occurred during cleanup`)}}}cleanupDirectory(e,t,n,r,i,a,o){let{fs:s,path:c,shadowProjectDir:l,logger:u}=e,d;try{d=s.readdirSync(t,{withFileTypes:!0})}catch(e){a.push({path:t,error:e}),u.warn({action:`orphan-cleanup`,message:`Failed to read directory`,path:t,error:e.message});return}for(let f of d){let d=c.join(t,f.name);if(f.isDirectory())this.cleanupDirectory(e,d,n,r,i,a,o),this.removeEmptyDirectory(e,d,i,a,o);else if(f.isFile()&&this.isOrphanFile(e,d,n,l))if(o)u.debug({action:`orphan-cleanup`,dryRun:!0,wouldDelete:d}),r.push(d);else try{s.unlinkSync(d),r.push(d),u.debug({action:`orphan-cleanup`,deleted:d})}catch(e){a.push({path:d,error:e}),u.warn({action:`orphan-cleanup`,message:`Failed to delete file`,path:d,error:e.message})}}}isOrphanFile(e,t,n,r){let{fs:i,path:a}=e,o=a.basename(t),s=o.endsWith(`.mdx`),c=a.join(r,`dist`,n),l=a.relative(c,t),u=a.dirname(l),d=o.replace(/\.mdx$/,``);if(s)return!this.getPossibleSourcePaths(a,r,n,d,u).some(e=>i.existsSync(e));let f=[];return n===`app`?f.push(a.join(r,`app`,l)):f.push(a.join(r,`src`,n,l)),!f.some(e=>i.existsSync(e))}getPossibleSourcePaths(e,t,n,r,i){switch(n){case`skills`:return i===`.`?[e.join(t,`src`,`skills`,r,`SKILL.cn.mdx`),e.join(t,`src`,`skills`,`${r}.cn.mdx`)]:[e.join(t,`src`,`skills`,i,`${r}.cn.mdx`)];case`commands`:return i===`.`?[e.join(t,`src`,`commands`,`${r}.cn.mdx`)]:[e.join(t,`src`,`commands`,i,`${r}.cn.mdx`)];case`agents`:return i===`.`?[e.join(t,`src`,`agents`,`${r}.cn.mdx`)]:[e.join(t,`src`,`agents`,i,`${r}.cn.mdx`)];case`app`:return i===`.`?[e.join(t,`app`,`${r}.cn.mdx`)]:[e.join(t,`app`,i,`${r}.cn.mdx`)];default:return[]}}removeEmptyDirectory(e,t,n,r,i){let{fs:a,logger:o}=e;try{a.readdirSync(t).length===0&&(i?(o.debug({action:`orphan-cleanup`,dryRun:!0,wouldDeleteDir:t}),n.push(t)):(a.rmdirSync(t),n.push(t),o.debug({action:`orphan-cleanup`,deletedDir:t})))}catch(e){r.push({path:t,error:e}),o.warn({action:`orphan-cleanup`,message:`Failed to check/remove directory`,path:t,error:e.message})}}collect(e){return{}}},py=class{registryPath;log;constructor(e,t){this.registryPath=this.resolvePath(e),this.log=t??cn(this.constructor.name)}resolvePath(e){return e.startsWith(`~`)?i.join(s.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,`utf8`);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.trace({action:`dryRun`,type:`registry`,path:this.registryPath}),!0;let i=`${this.registryPath}.tmp.${Date.now()}`;try{this.ensureRegistryDir();let e=JSON.stringify(n,null,2);return r.writeFileSync(i,e,`utf8`),r.renameSync(i,this.registryPath),this.log.trace({action:`write`,type:`registry`,path:this.registryPath}),!0}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`registry`,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.trace({action:`dryRun`,type:`registerEntry`,entryName:e}):this.log.trace({action:`register`,type:`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).slice(2,8)}`;return e==null?t:`${e}-${t}`}},my=class extends Lg{constructor(){super(`SkillNonSrcFileSyncEffectInputPlugin`),this.registerEffect(`skill-non-src-file-sync`,this.syncNonSrcFiles.bind(this),10)}async syncNonSrcFiles(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=n.join(r,`src`,`skills`),s=n.join(r,`dist`,`skills`),c=[],l=[],u=[],d=[];if(!t.existsSync(o))return a.debug({action:`skill-sync`,message:`src/skills/ directory does not exist, skipping`,srcSkillsDir:o}),{success:!0,description:`src/skills/ directory does not exist, nothing to sync`,copiedFiles:c,skippedFiles:l,createdDirs:u};this.syncDirectoryRecursive(e,o,s,``,c,l,u,d,i??!1);let f=d.length>0;return f&&a.warn({action:`skill-sync`,errors:d.map(e=>({path:e.path,error:e.error.message}))}),{success:!f,description:i?`Would copy ${c.length} files, skip ${l.length} files`:`Copied ${c.length} files, skipped ${l.length} files`,copiedFiles:c,skippedFiles:l,createdDirs:u,...f&&{error:Error(`${d.length} errors occurred during sync`)},modifiedFiles:c}}syncDirectoryRecursive(e,t,n,r,i,a,o,s,c){let{fs:l,path:u,logger:d}=e,f=r?u.join(t,r):t;if(!l.existsSync(f))return;let p;try{p=l.readdirSync(f,{withFileTypes:!0})}catch(e){s.push({path:f,error:e}),d.warn({action:`skill-sync`,message:`Failed to read directory`,path:f,error:e.message});return}for(let f of p){let p=r?u.join(r,f.name):f.name,m=u.join(t,p),h=u.join(n,p);if(f.isDirectory())this.syncDirectoryRecursive(e,t,n,p,i,a,o,s,c);else if(f.isFile()){if(f.name.endsWith(`.cn.mdx`))continue;let e=u.dirname(h);if(!l.existsSync(e))if(c)d.debug({action:`skill-sync`,dryRun:!0,wouldCreateDir:e}),o.push(e);else try{l.mkdirSync(e,{recursive:!0}),o.push(e),d.debug({action:`skill-sync`,createdDir:e})}catch(t){s.push({path:e,error:t}),d.warn({action:`skill-sync`,message:`Failed to create directory`,path:e,error:t.message});continue}if(l.existsSync(h))try{let e=l.readFileSync(m),t=l.readFileSync(h);if(this.computeHash(e)===this.computeHash(t)){a.push(h),d.debug({action:`skill-sync`,skipped:h,reason:`identical content`});continue}}catch(e){d.debug({action:`skill-sync`,message:`Could not compare files, will copy`,path:h,error:e.message})}if(c)d.debug({action:`skill-sync`,dryRun:!0,wouldCopy:{from:m,to:h}}),i.push(h);else try{l.copyFileSync(m,h),i.push(h),d.debug({action:`skill-sync`,copied:{from:m,to:h}})}catch(e){s.push({path:h,error:e}),d.warn({action:`skill-sync`,message:`Failed to copy file`,from:m,to:h,error:e.message})}}}}computeHash(e){return f(`sha256`).update(e).digest(`hex`)}collect(e){return{}}};const hy=`.codeium/windsurf`,gy=`global_workflows`,_y=`memories`,vy=`global_rules.md`,yy=`skills`,by=`SKILL.md`;var xy=class extends Pg{constructor(){super(`WindsurfOutputPlugin`,{globalConfigDir:hy,outputFileName:``,dependsOn:[`AgentsOutputPlugin`]})}async registerGlobalOutputDirs(e){let t=[],{fastCommands:n,skills:r}=e.collectedInputContext;if(n!=null&&n.length>0){let e=this.getGlobalWorkflowsDir();t.push({pathKind:L.Relative,path:gy,basePath:this.getCodeiumWindsurfDir(),getDirectoryName:()=>gy,getAbsolutePath:()=>e})}if(r!=null&&r.length>0)for(let e of r){let n=e.yamlFrontMatter.name,r=i.join(this.getCodeiumWindsurfDir(),yy,n);t.push({pathKind:L.Relative,path:i.join(yy,n),basePath:this.getCodeiumWindsurfDir(),getDirectoryName:()=>n,getAbsolutePath:()=>r})}return t}async registerGlobalOutputFiles(e){let t=[],{skills:n,fastCommands:r}=e.collectedInputContext;if(r!=null&&r.length>0){let n=this.getGlobalWorkflowsDir(),a=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});for(let e of r){let r=this.transformFastCommandName(e,a),o=i.join(n,r);t.push({pathKind:L.Relative,path:i.join(gy,r),basePath:this.getCodeiumWindsurfDir(),getDirectoryName:()=>gy,getAbsolutePath:()=>o})}}if(n==null||n.length===0)return t;let a=this.getSkillsDir(),o=this.getCodeiumWindsurfDir();for(let e of n){let n=e.yamlFrontMatter.name,r=i.join(a,n);if(t.push({pathKind:L.Relative,path:i.join(yy,n,by),basePath:o,getDirectoryName:()=>n,getAbsolutePath:()=>i.join(r,by)}),e.childDocs!=null)for(let a of e.childDocs){let e=a.relativePath.replace(/\.mdx$/,`.md`);t.push({pathKind:L.Relative,path:i.join(yy,n,e),basePath:o,getDirectoryName:()=>n,getAbsolutePath:()=>i.join(r,e)})}if(e.resources!=null)for(let a of e.resources)t.push({pathKind:L.Relative,path:i.join(yy,n,a.relativePath),basePath:o,getDirectoryName:()=>n,getAbsolutePath:()=>i.join(r,a.relativePath)})}return t}async canWrite(e){let{skills:t,fastCommands:n,globalMemory:r}=e.collectedInputContext,i=(t?.length??0)>0,a=(n?.length??0)>0;return i||a||r!=null?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeGlobalOutputs(e){let{skills:t,fastCommands:n,globalMemory:r}=e.collectedInputContext,i=[],a=[];if(r!=null){let t=await this.writeGlobalMemory(e,r.content);i.push(t)}if(t!=null&&t.length>0){let n=this.getSkillsDir();for(let r of t){let t=await this.writeGlobalSkill(e,n,r);i.push(...t)}}if(n==null||n.length===0)return{files:i,dirs:a};let o=this.getGlobalWorkflowsDir();for(let t of n){let n=await this.writeGlobalWorkflow(e,o,t);i.push(n)}return{files:i,dirs:a}}async writeProjectOutputs(){return{files:[],dirs:[]}}getSkillsDir(){return i.join(this.getCodeiumWindsurfDir(),yy)}getCodeiumWindsurfDir(){return i.join(this.getHomeDir(),hy)}getGlobalMemoriesDir(){return i.join(this.getCodeiumWindsurfDir(),_y)}getGlobalWorkflowsDir(){return i.join(this.getCodeiumWindsurfDir(),gy)}async writeGlobalMemory(e,t){let n=this.getGlobalMemoriesDir(),r=i.join(n,vy),a=this.getCodeiumWindsurfDir(),o={pathKind:L.Relative,path:i.join(_y,vy),basePath:a,getDirectoryName:()=>_y,getAbsolutePath:()=>r};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMemory`,path:r}),{path:o,success:!0,skipped:!1};try{return this.ensureDirectory(n),this.writeFileSync(r,t),this.log.trace({action:`write`,type:`globalMemory`,path:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalMemory`,path:r,error:t}),{path:o,success:!1,error:e}}}async writeGlobalWorkflow(e,t,n){let a=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),o=this.transformFastCommandName(n,a),s=i.join(t,o),c={pathKind:L.Relative,path:i.join(gy,o),basePath:this.getCodeiumWindsurfDir(),getDirectoryName:()=>gy,getAbsolutePath:()=>s},l=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalWorkflow`,path:s}),{path:c,success:!0,skipped:!1};try{return this.ensureDirectory(t),r.writeFileSync(s,l),this.log.trace({action:`write`,type:`globalWorkflow`,path:s}),{path:c,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalWorkflow`,path:s,error:t}),{path:c,success:!1,error:e}}}async writeGlobalSkill(e,t,n){let r=[],a=n.yamlFrontMatter.name,o=i.join(t,a),s=i.join(o,by),c=this.getCodeiumWindsurfDir(),l={pathKind:L.Relative,path:i.join(yy,a,by),basePath:c,getDirectoryName:()=>a,getAbsolutePath:()=>s},u=this.buildSkillFrontMatter(n),d=n.content,f=Ag(u,d);if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`skill`,path:s}),r.push({path:l,success:!0,skipped:!1});else try{this.ensureDirectory(o),this.writeFileSync(s,f),this.log.trace({action:`write`,type:`skill`,path:s}),r.push({path:l,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skill`,path:s,error:t}),r.push({path:l,success:!1,error:e})}if(n.childDocs!=null)for(let t of n.childDocs){let n=await this.writeSkillChildDoc(e,t,o,a,c);r.push(n)}if(n.resources!=null)for(let t of n.resources){let n=await this.writeSkillResource(e,t,o,a,c);r.push(n)}return r}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:t.name,description:t.description,...t.displayName!=null&&{displayName:t.displayName},...t.keywords!=null&&t.keywords.length>0&&{keywords:t.keywords},...t.author!=null&&{author:t.author},...t.version!=null&&{version:t.version},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}async writeSkillChildDoc(e,t,n,r,a){let o=t.relativePath.replace(/\.mdx$/,`.md`),s=i.join(n,o),c={pathKind:L.Relative,path:i.join(yy,r,o),basePath:a,getDirectoryName:()=>r,getAbsolutePath:()=>s},l=t.content;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`childDoc`,path:s}),{path:c,success:!0,skipped:!1};try{let e=i.dirname(s);return this.ensureDirectory(e),this.writeFileSync(s,l),this.log.trace({action:`write`,type:`childDoc`,path:s}),{path:c,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`childDoc`,path:s,error:t}),{path:c,success:!1,error:e}}}async writeSkillResource(e,t,n,r,a){let o=i.join(n,t.relativePath),s={pathKind:L.Relative,path:i.join(yy,r,t.relativePath),basePath:a,getDirectoryName:()=>r,getAbsolutePath:()=>o};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`resource`,path:o}),{path:s,success:!0,skipped:!1};try{let e=i.dirname(o);if(this.ensureDirectory(e),t.encoding===`base64`){let e=d.from(t.content,`base64`);this.writeFileSyncBuffer(o,e)}else this.writeFileSync(o,t.content);return this.log.trace({action:`write`,type:`resource`,path:o}),{path:s,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`resource`,path:o,error:t}),{path:s,success:!1,error:e}}}},Sy=class e extends py{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,mcpConfig:r}=e,i={type:`repo`,repoId:this.generateEntryId(`local`),repoName:t},a=r==null?null:Object.keys(r.mcpServers);return{name:n.name,description:n.description,...a!=null&&a.length>0&&{mcpServers:a},...n.author!=null&&{author:n.author},keywords:n.keywords??[],...n.displayName!=null&&{displayName:n.displayName},installed:!0,installedAt:new Date().toISOString(),installPath:t,source:i,sourcePath:t}}getOfficialRegistry(){try{return JSON.parse({version:`1.0.0`,powers:{postman:{name:`postman`,description:`Automate API testing and collection management with Postman - create workspaces, collections, environments, and run tests programmatically`,displayName:`API Testing with Postman`,author:`Postman`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/postman.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/postman`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`postman`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},figma:{name:`figma`,description:`Connect Figma designs to code components - automatically generate design system rules, map UI components to Figma designs, and maintain design-code consistency`,displayName:`Design to Code with Figma`,author:`Figma`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/figma.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/figma`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`figma`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"netlify-deployment":{name:`netlify-deployment`,description:`Deploy React, Next.js, Vue, and other modern web apps to Netlify's global CDN with automatic builds.`,displayName:`Deploy web apps with Netlify`,author:`Netlify`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/netlify.png`,repositoryUrl:`https://github.com/netlify/context-and-tools/tree/main/context/steering/netlify-deployment-power`,license:``,repositoryCloneUrl:`git@github.com:netlify/context-and-tools.git`,pathInRepo:`context/steering/netlify-deployment-power`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"amazon-aurora-postgresql":{name:`amazon-aurora-postgresql`,description:`Build applications backed by Aurora PostgreSQL by leveraging Aurora PostgreSQL specific best practices.`,displayName:`Build applications with Aurora PostgreSQL`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/amazon-aurora.png`,repositoryUrl:`https://github.com/awslabs/mcp/tree/main/src/postgres-mcp-server/kiro_power`,license:``,repositoryCloneUrl:`git@github.com:awslabs/mcp.git`,pathInRepo:`src/postgres-mcp-server/kiro_power`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"supabase-hosted":{name:`supabase-hosted`,description:`Build applications with Supabase's Postgres database, authentication, storage, and real-time subscriptions`,displayName:`Build a backend with Supabase`,author:`Supabase`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/supabase.png`,repositoryUrl:`https://github.com/supabase-community/kiro-powers/tree/main/powers/supabase-hosted`,license:``,repositoryCloneUrl:`git@github.com:supabase-community/kiro-powers.git`,pathInRepo:`powers/supabase-hosted`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"supabase-local":{name:`supabase-local`,description:`Local development with Supabase allows you to work on your projects in a self-contained environment on your local machine.`,displayName:`Build a backend (local) with Supabase`,author:`Supabase`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/supabase.png`,repositoryUrl:`https://github.com/supabase-community/kiro-powers/tree/main/powers/supabase-local`,license:``,repositoryCloneUrl:`git@github.com:supabase-community/kiro-powers.git`,pathInRepo:`powers/supabase-local`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},terraform:{name:`terraform`,description:`Build and manage Infrastructure as Code with Terraform - access registry providers, modules, policies, and HCP Terraform workflow management`,displayName:`Deploy infrastructure with Terraform`,author:`HashiCorp`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/terraform.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/terraform`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`terraform`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},strands:{name:`strands`,description:`Build AI agents with Strands Agent SDK using Bedrock, Anthropic, OpenAI, Gemini, or Llama models`,displayName:`Build an agent with Strands`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/strands.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/strands`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`strands`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aws-agentcore":{name:`aws-agentcore`,description:`Amazon Bedrock AgentCore is an agentic platform for building, deploying, and operating effective agents.`,displayName:`Build an agent with Amazon Bedrock AgentCore`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/agentcore.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aws-agentcore`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aws-agentcore`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},neon:{name:`neon`,description:`Serverless Postgres with database branching, autoscaling, and scale-to-zero - perfect for modern development workflows`,displayName:`Build a database with Neon`,author:`Neon`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/neon.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/neon`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`neon`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},datadog:{name:`datadog`,description:`Query logs, metrics, traces, RUM events, incidents, and monitors from Datadog for production debugging and performance analysis`,displayName:`Datadog Observability`,author:`Datadog`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/datadog.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/datadog`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`datadog`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},dynatrace:{name:`dynatrace`,description:`Query logs, metrics, traces, problems, and Kubernetes events from Dynatrace using DQL for production debugging and performance analysis`,displayName:`Dynatrace Observability`,author:`Dynatrace`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/dynatrace.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/dynatrace`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`dynatrace`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},stripe:{name:`stripe`,description:`Build payment integrations with Stripe - accept payments, manage subscriptions, handle billing, and process refunds`,displayName:`Stripe Payments`,author:`Stripe`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/stripe.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/stripe`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`stripe`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aws-infrastructure-as-code":{name:`aws-infrastructure-as-code`,description:`Build well-architected AWS infrastructure with CDK using latest documentation, best practices, and code samples. Validate CloudFormation templates, check resource configuration security compliance, and troubleshoot deployments.`,displayName:`Build AWS infrastructure with CDK and CloudFormation`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/iac.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aws-infrastructure-as-code`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aws-infrastructure-as-code`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"power-builder":{name:`power-builder`,description:`Complete guide for building and testing new Kiro Powers with templates, best practices, and validation`,displayName:`Build a Power`,author:`Kiro Team`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/power-builder`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`power-builder`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"saas-builder":{name:`saas-builder`,description:`Build production ready multi-tenant SaaS applications with serverless architecture, integrated billing, and enterprise grade security`,displayName:`SaaS Builder`,author:`Allen Helton`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/saas-builder`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`saas-builder`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"cloud-architect":{name:`cloud-architect`,description:`Build AWS infrastructure with CDK in Python following AWS Well-Architected framework best practices`,displayName:`Build infrastructure on AWS`,author:`Christian Bonzelet`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/cloud-architect`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`cloud-architect`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aurora-dsql":{name:`aurora-dsql`,description:`For PostgreSQL compatible serverless distributed SQL database with Aurora DSQL, manage schemas, execute queries, and handle migrations with DSQL-specific constraints`,displayName:`Deploy a distributed SQL database on AWS`,author:`Rolf Koski`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aurora-dsql`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aurora-dsql`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}}},repoSources:{},lastUpdated:`2025-12-28T20:19:10.824Z`,kiroRecommendedRepo:{url:`https://prod.download.desktop.kiro.dev/powers/default_registry.json`,lastFetch:`2025-12-28T20:19:10.823Z`,powerCount:18}})}catch{this.log.debug(`Failed to parse official registry, using empty registry`)}return this.createInitialRegistry()}unregisterLocalPowers(e){let t={...this.getOfficialRegistry(),lastUpdated:new Date().toISOString()};return this.log.trace({action:e===!0?`dryRun`:`reset`,type:`registry`,powerCount:Object.keys(t.powers).length}),this.write(t,e)}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}}};const Cy=`GLOBAL.md`,wy=`.kiro`,Ty=`steering`,Ey=`settings`,Dy=`mcp.json`,Oy=`POWER.md`,ky=`SKILL.md`;var Ay=class extends Pg{constructor(){super(`KiroCLIOutputPlugin`,{globalConfigDir:wy,outputFileName:Cy}),this.registerCleanEffect(`registry-cleanup`,async e=>this.getRegistryWriter(Sy).unregisterLocalPowers(e.dryRun)?{success:!0,description:`Reset registry`}:{success:!1,description:`Failed`,error:Error(`Registry cleanup failed`)}),this.registerCleanEffect(`mcp-settings-cleanup`,async e=>{let t=this.joinPath(this.getGlobalSettingsDir(),Dy),n=JSON.stringify({mcpServers:{},powers:{mcpServers:{}}},null,2);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpSettingsCleanup`,path:t}),{success:!0,description:`Would reset mcp.json`};let r=await this.writeFile(e,t,n,`mcpSettingsCleanup`);return r.success?{success:!0,description:`Reset mcp.json`}:{success:!1,description:`Failed`,error:r.error??Error(`Cleanup failed`)}})}getGlobalSettingsDir(){return this.joinPath(this.getHomeDir(),wy,Ey)}getGlobalSteeringDir(){return this.joinPath(this.getGlobalConfigDir(),Ty)}getKiroPowersDir(){return this.joinPath(this.getHomeDir(),`.kiro/powers/installed`)}getKiroSkillsDir(){return this.joinPath(this.getHomeDir(),`.kiro/skills`)}async registerProjectOutputDirs(e){let{projects:t}=e.collectedInputContext.workspace;return t.filter(e=>e.dirFromWorkspacePath!=null).map(e=>this.createRelativePath(this.joinPath(e.dirFromWorkspacePath.path,wy,Ty),e.dirFromWorkspacePath.basePath,()=>Ty))}async registerProjectOutputFiles(e){let{projects:t}=e.collectedInputContext.workspace,n=[];for(let e of t)if(!(e.dirFromWorkspacePath==null||e.childMemoryPrompts==null))for(let t of e.childMemoryPrompts)n.push(this.createRelativePath(this.joinPath(e.dirFromWorkspacePath.path,wy,Ty,this.buildSteeringFileName(t)),e.dirFromWorkspacePath.basePath,()=>Ty));return n}async registerGlobalOutputDirs(){let e=[this.createRelativePath(Ty,this.getGlobalConfigDir(),()=>Ty)],t=this.getKiroPowersDir();for(let n of this.listInstalledPowers(t))e.push(this.createRelativePath(n,t,()=>n));let n=this.getKiroSkillsDir();for(let t of this.listInstalledPowers(n))e.push(this.createRelativePath(t,n,()=>t));return e.push(this.createRelativePath(`repos`,this.joinPath(this.getHomeDir(),`.kiro/powers`),()=>`repos`)),e}listInstalledPowers(e){try{return this.existsSync(e)?this.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name):[]}catch{return[]}}async registerGlobalOutputFiles(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=this.getGlobalSteeringDir(),a=[];if(t!=null&&a.push(this.createRelativePath(Cy,i,()=>Ty)),n!=null)for(let e of n)a.push(this.createRelativePath(this.buildFastCommandSteeringFileName(e),i,()=>Ty));if(r==null)return a;let o=this.getKiroPowersDir(),s=this.getKiroSkillsDir();for(let e of r){let t=e.yamlFrontMatter.name;if(e.mcpConfig!=null){let n=this.joinPath(o,t);if(a.push(this.createRelativePath(Oy,n,()=>t)),a.push(this.createRelativePath(Dy,n,()=>t)),e.childDocs!=null)for(let t of e.childDocs)a.push(this.createRelativePath(this.joinPath(Ty,t.dir.path.replace(/\.mdx$/,`.md`)),n,()=>Ty));if(e.resources!=null)for(let t of e.resources)a.push(this.createRelativePath(this.joinPath(Ty,t.relativePath),n,()=>Ty))}else{let n=this.joinPath(s,t);if(a.push(this.createRelativePath(ky,n,()=>t)),e.childDocs!=null)for(let r of e.childDocs)a.push(this.createRelativePath(r.dir.path.replace(/\.mdx$/,`.md`),n,()=>t));if(e.resources!=null)for(let r of e.resources)a.push(this.createRelativePath(r.relativePath,n,()=>t))}}return r.some(e=>e.mcpConfig!=null)&&a.push(this.createRelativePath(Dy,this.getGlobalSettingsDir(),()=>Ey)),a}async canWrite(e){let{workspace:t,globalMemory:n,fastCommands:r,skills:i}=e.collectedInputContext;return t.projects.some(e=>(e.childMemoryPrompts?.length??0)>0)||n!=null||(r?.length??0)>0||(i?.length??0)>0?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[];for(let r of t)if(!(r.dirFromWorkspacePath==null||r.childMemoryPrompts==null))for(let t of r.childMemoryPrompts)n.push(await this.writeSteeringFile(e,r,t));return{files:n,dirs:[]}}async writeGlobalOutputs(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=[],o=this.getGlobalSteeringDir();if(t!=null&&i.push(await this.writeFile(e,this.joinPath(o,Cy),t.content,`globalMemory`)),n!=null)for(let t of n)i.push(await this.writeFastCommandSteeringFile(e,t));if(r==null||r.length===0)return{files:i,dirs:[]};let s=r.filter(e=>e.mcpConfig!=null),c=r.filter(e=>e.mcpConfig==null);for(let t of s){let{fileResults:n,registryResult:r}=await this.writeSkillAsPower(e,t);i.push(...n),a.push(r)}for(let t of c){let n=await this.writeSkillAsKiroSkill(e,t);i.push(...n)}let l=await this.writeGlobalMcpSettings(e,r);return l!=null&&i.push(l),this.logRegistryResults(a,e.dryRun),{files:i,dirs:[]}}async writeGlobalMcpSettings(e,t){let n={};for(let e of t)if(e.mcpConfig!=null)for(let[t,r]of Object.entries(e.mcpConfig.mcpServers))n[`power-${e.yamlFrontMatter.name}-${t}`]=r;if(Object.keys(n).length===0)return null;let r=JSON.stringify({mcpServers:{},powers:{mcpServers:n}},null,2);return this.writeFile(e,this.joinPath(this.getGlobalSettingsDir(),Dy),r,`globalMcpSettings`)}logRegistryResults(e,t){let n=e.filter(e=>e.success).length,r=e.filter(e=>!e.success).length;n>0&&this.log.trace({action:t===!0?`dryRun`:`register`,type:`registrySummary`,successCount:n}),r>0&&this.log.error({action:`register`,type:`registrySummary`,failCount:r})}async writeSkillAsPower(e,t){let n=[],r=t.yamlFrontMatter.name,i=this.joinPath(this.getKiroPowersDir(),r),a=this.joinPath(i,Oy),o=`${this.buildPowerFrontMatter(t.yamlFrontMatter)}\n${t.content}`;if(n.push(await this.writeFile(e,a,o,`skillPower`)),t.childDocs!=null){let r=this.joinPath(i,Ty);for(let i of t.childDocs){let t=i.dir.path.replace(/\.mdx$/,`.md`);n.push(await this.writeFile(e,this.joinPath(r,t),i.content,`refDoc`))}}if(t.resources!=null){let r=this.joinPath(i,Ty);for(let i of t.resources)n.push(await this.writeFile(e,this.joinPath(r,i.relativePath),i.content,`resource`))}t.mcpConfig!=null&&n.push(await this.writeFile(e,this.joinPath(i,Dy),t.mcpConfig.rawContent,`mcpConfig`));let s=this.getRegistryWriter(Sy),c=s.buildPowerEntry(t,i);return{fileResults:n,registryResult:(await this.registerInRegistry(s,[c],e))[0]??{success:!1,entryName:r,error:Error(`No registry result`)}}}async writeSkillAsKiroSkill(e,t){let n=[],r=t.yamlFrontMatter.name,i=this.joinPath(this.getKiroSkillsDir(),r),a=this.joinPath(i,ky),o=`${this.buildSkillFrontMatter(t.yamlFrontMatter)}\n${t.content}`;if(n.push(await this.writeFile(e,a,o,`kiroSkill`)),t.childDocs!=null)for(let r of t.childDocs){let t=r.dir.path.replace(/\.mdx$/,`.md`);n.push(await this.writeFile(e,this.joinPath(i,t),r.content,`refDoc`))}if(t.resources!=null)for(let r of t.resources)n.push(await this.writeFile(e,this.joinPath(i,r.relativePath),r.content,`resource`));return n}buildSkillFrontMatter(e){return this.buildMarkdownContent(``,{name:e.name,description:e.description,...e.displayName!=null&&{displayName:e.displayName},...e.keywords!=null&&e.keywords.length>0&&{keywords:e.keywords},...e.author!=null&&{author:e.author}}).trimEnd()}buildPowerFrontMatter(e){return this.buildMarkdownContent(``,{name:e.name,displayName:e.displayName,description:e.description,keywords:e.keywords,author:e.author}).trimEnd()}buildFastCommandSteeringFileName(e){return this.transformFastCommandName(e,{includeSeriesPrefix:!0,seriesSeparator:`-`})}async writeFastCommandSteeringFile(e,t){let n=this.buildFastCommandSteeringFileName(t),r=this.joinPath(this.getGlobalSteeringDir(),n),i=t.yamlFrontMatter?.description,a=this.buildMarkdownContent(t.content,{inclusion:`manual`,description:i!=null&&i.length>0?i:null});return this.writeFile(e,r,a,`fastCommandSteering`)}buildSteeringFileName(e){return`kiro-${(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`)}.md`}async writeSteeringFile(e,t,n){let r=t.dirFromWorkspacePath,i=this.buildSteeringFileName(n),a=this.joinPath(r.basePath,r.path,wy,Ty),o=this.joinPath(a,i),s=n.workingChildDirectoryPath?.path??n.dir.path,c=this.buildMarkdownContent(n.content,{inclusion:`fileMatch`,fileMatchPattern:`${s.replaceAll(`\\`,`/`)}/**`});return this.writeFile(e,o,c,`steeringFile`)}};const jy=`agt.mdx`,My=[`node_modules`,`.git`];var Ny=class extends Lg{constructor(){super(`ProjectPromptInputPlugin`,[`ShadowProjectInputPlugin`])}async collect(e){let{dependencyContext:t,fs:n,userConfigOptions:r,path:i,globalScope:a}=e,{workspaceDir:o,shadowProjectDir:s}=this.resolveBasePaths(r),c=r.shadowProjectsDir,l=this.resolvePath(c,o,s),u=t.workspace;if(u==null)return this.log.warn(`No workspace found in dependency context, skipping project prompt enhancement`),{};let d=u.projects??[],f=await Promise.all(d.map(async t=>{let r=t.name;if(r==null)return t;let o=i.join(l,r);if(!n.existsSync(o)||!n.statSync(o).isDirectory())return t;let s=t.dirFromWorkspacePath?.getAbsolutePath(),c=await this.readRootMemoryPrompt(e,o,a),u=s==null?[]:await this.scanChildMemoryPrompts(e,o,s,a);return{...t,...c!=null&&{rootMemoryPrompt:c},...u.length>0&&{childMemoryPrompts:u}}}));return{workspace:{directory:u.directory,projects:f}}}async readRootMemoryPrompt(e,t,r){let{fs:i,path:a,logger:o}=e,s=a.join(t,jy);if(!(!i.existsSync(s)||!i.statSync(s).isFile()))try{let e=i.readFileSync(s,`utf8`),a=jg(e),c;try{c=await fv(e,{globalScope:r,basePath:t})}catch(e){throw e instanceof Yg&&(o.error(`MDX compilation failed in ${s}: ${e.message}`),o.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),n.exit(1)),e}return{type:Et.ProjectRootMemory,content:c,length:c.length,filePathKind:L.Relative,...a.yamlFrontMatter!=null&&{yamlFrontMatter:a.yamlFrontMatter},...a.rawFrontMatter!=null&&{rawFrontMatter:a.rawFrontMatter},markdownAst:a.markdownAst,markdownContents:a.markdownContents,dir:{pathKind:L.Root,path:``,getDirectoryName:()=>``}}}catch(e){o.error(`Failed to read root memory prompt at ${s}`,{error:e});return}}async scanChildMemoryPrompts(e,t,n,r){let{logger:i}=e,a=[];try{await this.scanDirectoryRecursive(e,t,t,n,a,r)}catch(e){i.error(`Failed to scan child memory prompts at ${t}`,{error:e})}return a}async scanDirectoryRecursive(e,t,n,r,i,a){let{fs:o,path:s}=e,c=o.readdirSync(n,{withFileTypes:!0});for(let l of c){if(!l.isDirectory()||My.includes(l.name))continue;let c=s.join(n,l.name),u=s.join(c,jy);if(o.existsSync(u)&&o.statSync(u).isFile()){let n=await this.readChildMemoryPrompt(e,t,c,r,a);n!=null&&i.push(n)}await this.scanDirectoryRecursive(e,t,c,r,i,a)}}async readChildMemoryPrompt(e,t,r,i,a){let{fs:o,path:s,logger:c}=e,l=s.join(r,jy);try{let e=o.readFileSync(l,`utf8`),u=jg(e),d;try{d=await fv(e,{globalScope:a,basePath:r})}catch(e){throw e instanceof Yg&&(c.error(`MDX compilation failed in ${l}: ${e.message}`),c.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),n.exit(1)),e}let f=s.relative(t,r),p=s.join(i,f),m=s.basename(r);return{type:Et.ProjectChildrenMemory,content:d,length:d.length,filePathKind:L.Relative,...u.yamlFrontMatter!=null&&{yamlFrontMatter:u.yamlFrontMatter},...u.rawFrontMatter!=null&&{rawFrontMatter:u.rawFrontMatter},markdownAst:u.markdownAst,markdownContents:u.markdownContents,dir:{pathKind:L.Relative,path:f,basePath:i,getDirectoryName:()=>m,getAbsolutePath:()=>p},workingChildDirectoryPath:{pathKind:L.Relative,path:f,basePath:i,getDirectoryName:()=>m,getAbsolutePath:()=>p}}}catch(e){c.error(`Failed to read child memory prompt at ${l}`,{error:e});return}}};const Py=`.qoder`,Fy=`rules`,Iy=`commands`,Ly=`skills`,Ry=`global.md`,zy=`always.md`,By=`SKILL.md`,Vy=`mcp.json`;var Hy=class extends Pg{constructor(){super(`QoderIDEPluginOutputPlugin`,{globalConfigDir:Py})}async registerProjectOutputDirs(e){let{projects:t}=e.collectedInputContext.workspace;return t.filter(e=>e.dirFromWorkspacePath!=null).map(e=>this.createProjectRulesDirPath(e.dirFromWorkspacePath))}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{globalMemory:r}=e.collectedInputContext;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&(r!=null&&t.push(this.createProjectRuleFilePath(n,Ry)),e.rootMemoryPrompt!=null&&t.push(this.createProjectRuleFilePath(n,zy)),e.childMemoryPrompts!=null))for(let r of e.childMemoryPrompts)t.push(this.createProjectRuleFilePath(n,this.buildChildRuleFileName(r)))}return t}async registerGlobalOutputDirs(e){let t=this.getGlobalConfigDir(),{fastCommands:n,skills:r}=e.collectedInputContext,a=[];if(n!=null&&n.length>0&&a.push(this.createRelativePath(Iy,t,()=>Iy)),r!=null&&r.length>0)for(let e of r){let n=e.yamlFrontMatter.name;a.push(this.createRelativePath(i.join(Ly,n),t,()=>n))}return a}async registerGlobalOutputFiles(e){let t=this.getGlobalConfigDir(),{fastCommands:n,skills:r}=e.collectedInputContext,a=[],o=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});if(n!=null&&n.length>0)for(let e of n){let n=this.transformFastCommandName(e,o);a.push(this.createRelativePath(i.join(Iy,n),t,()=>Iy))}if(r!=null&&r.length>0)for(let e of r){let n=e.yamlFrontMatter.name;if(a.push(this.createRelativePath(i.join(Ly,n,By),t,()=>n)),e.mcpConfig!=null&&a.push(this.createRelativePath(i.join(Ly,n,Vy),t,()=>n)),e.childDocs!=null)for(let r of e.childDocs)a.push(this.createRelativePath(i.join(Ly,n,r.relativePath.replace(/\.mdx$/,`.md`)),t,()=>n));if(e.resources!=null)for(let r of e.resources)a.push(this.createRelativePath(i.join(Ly,n,r.relativePath),t,()=>n))}return a}async canWrite(e){let{workspace:t,globalMemory:n,fastCommands:r,skills:i}=e.collectedInputContext;return t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)||n!=null||(r?.length??0)>0||(i?.length??0)>0?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{globalMemory:n}=e.collectedInputContext,r=[];for(let i of t){if(i.dirFromWorkspacePath==null)continue;let t=i.dirFromWorkspacePath;if(n!=null){let i=this.buildAlwaysRuleContent(n.content);r.push(await this.writeProjectRuleFile(e,t,Ry,i,`globalRule`))}if(i.rootMemoryPrompt!=null){let n=this.buildAlwaysRuleContent(i.rootMemoryPrompt.content);r.push(await this.writeProjectRuleFile(e,t,zy,n,`projectRootRule`))}if(i.childMemoryPrompts!=null)for(let n of i.childMemoryPrompts){let i=this.buildChildRuleFileName(n),a=this.buildGlobRuleContent(n);r.push(await this.writeProjectRuleFile(e,t,i,a,`projectChildRule`))}}return{files:r,dirs:[]}}async writeGlobalOutputs(e){let{fastCommands:t,skills:n}=e.collectedInputContext,r=[],a=this.getGlobalConfigDir(),o=i.join(a,Iy),s=i.join(a,Ly);if(t!=null&&t.length>0)for(let n of t)r.push(await this.writeGlobalFastCommand(e,o,n));if(n!=null&&n.length>0)for(let t of n)r.push(...await this.writeGlobalSkill(e,s,t));return{files:r,dirs:[]}}createProjectRulesDirPath(e){return this.createRelativePath(i.join(e.path,Py,Fy),e.basePath,()=>Fy)}createProjectRuleFilePath(e,t){return this.createRelativePath(i.join(e.path,Py,Fy,t),e.basePath,()=>Fy)}buildChildRuleFileName(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`);return`glob-${t.length>0?t:`root`}.md`}buildAlwaysRuleContent(e){return Ag({trigger:`always_on`,type:`user_command`},e)}buildGlobRuleContent(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``);return Ag({trigger:`glob`,glob:t.length===0?`**/*`:`${t}/**`,type:`user_command`},e.content)}async writeProjectRuleFile(e,t,n,r,a){let o=i.join(t.basePath,t.path,Py,Fy),s=i.join(o,n);return this.writeFile(e,s,r,a)}async writeGlobalFastCommand(e,t,n){let r=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),a=this.transformFastCommandName(n,r),o=i.join(t,a),s=Ag(this.buildFastCommandFrontMatter(n),n.content);return this.writeFile(e,o,s,`globalFastCommand`)}async writeGlobalSkill(e,t,n){let r=[],a=n.yamlFrontMatter.name,o=i.join(t,a),s=i.join(o,By),c=Ag(this.buildSkillFrontMatter(n),n.content);if(r.push(await this.writeFile(e,s,c,`skill`)),n.mcpConfig!=null){let t=i.join(o,Vy);r.push(await this.writeFile(e,t,n.mcpConfig.rawContent,`mcpConfig`))}if(n.childDocs!=null)for(let t of n.childDocs){let n=i.join(o,t.relativePath.replace(/\.mdx$/,`.md`));r.push(await this.writeFile(e,n,t.content,`childDoc`))}if(n.resources!=null)for(let t of n.resources){let n=i.join(o,t.relativePath);if(t.encoding===`base64`){let e=d.from(t.content,`base64`),s=i.dirname(n);this.ensureDirectory(s),this.writeFileSyncBuffer(n,e),r.push({path:this.createRelativePath(t.relativePath,o,()=>a),success:!0})}else r.push(await this.writeFile(e,n,t.content,`resource`))}return r}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:t.name,description:t.description,type:`user_command`,...t.displayName!=null&&{displayName:t.displayName},...t.keywords!=null&&t.keywords.length>0&&{keywords:t.keywords},...t.author!=null&&{author:t.author},...t.version!=null&&{version:t.version},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}buildFastCommandFrontMatter(e){let t=e.yamlFrontMatter;return t==null?{description:`Fast command`,type:`user_command`}:{description:t.description,type:`user_command`,...t.argumentHint!=null&&{argumentHint:t.argumentHint},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}};const Uy=`README.md`;var Wy=class extends Pg{constructor(){super(`ReadmeMdConfigFileOutputPlugin`,{outputFileName:Uy})}async registerProjectOutputFiles(e){let t=[],{readmePrompts:n}=e.collectedInputContext;if(n==null||n.length===0)return t;for(let e of n){let{targetDir:n}=e,r=i.join(n.path,Uy);t.push({pathKind:L.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?.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{targetDir:n}=t,a=i.join(n.path,Uy),o=i.join(n.basePath,a),s=t.content,c={pathKind:L.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.trace({action:`dryRun`,type:`readme`,path:o,label:l}),{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,`utf8`),this.log.trace({action:`write`,type:`readme`,path:o,label:l}),{path:c,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`readme`,path:o,label:l,error:t}),{path:c,success:!1,error:e}}}},Gy=class extends Lg{constructor(){super(`ReadmeMdInputPlugin`,[`ShadowProjectInputPlugin`])}async collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i,globalScope:a}=e,{workspaceDir:o,shadowProjectDir:s}=this.resolveBasePaths(t),c=t.shadowProjectsDir,l=this.resolvePath(c,o,s),u=[];if(!r.existsSync(l)||!r.statSync(l).isDirectory())return n.debug(`shadow projects directory does not exist`,{path:l}),{readmePrompts:u};try{let t=r.readdirSync(l,{withFileTypes:!0});for(let n of t){if(!n.isDirectory())continue;let t=n.name,r=i.join(l,t);await this.collectReadmeFiles(e,r,t,o,``,u,a)}}catch(e){n.error(`failed to scan shadow projects`,{path:l,error:e})}return{readmePrompts:u}}async collectReadmeFiles(e,t,r,i,a,o,s){let{fs:c,path:l,logger:u}=e,d=a===``,f=l.join(t,`rdm.mdx`);if(c.existsSync(f)&&c.statSync(f).isFile())try{let e=c.readFileSync(f,`utf8`),p;if(s!=null)try{p=await fv(e,{globalScope:s,basePath:t})}catch(e){throw e instanceof Yg&&(u.error(`MDX compilation failed in ${f}: ${e.message}`),u.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),n.exit(1)),e}else p=e;let m=d?r:l.join(r,a),h={pathKind:L.Relative,path:m,basePath:i,getDirectoryName:()=>d?r:l.basename(a),getAbsolutePath:()=>l.resolve(i,m)},g={pathKind:L.Relative,path:l.dirname(f),basePath:i,getDirectoryName:()=>l.basename(l.dirname(f)),getAbsolutePath:()=>l.dirname(f)};o.push({type:Et.Readme,content:p,length:p.length,filePathKind:L.Relative,projectName:r,targetDir:h,isRoot:d,markdownContents:[],dir:g})}catch(e){u.warn(`failed to read readme`,{path:f,error:e})}try{let n=c.readdirSync(t,{withFileTypes:!0});for(let c of n)if(c.isDirectory()){let n=d?c.name:l.join(a,c.name),u=l.join(t,c.name);await this.collectReadmeFiles(e,u,r,i,n,o,s)}}catch(e){u.warn(`failed to scan directory`,{path:t,error:e})}}},Ky=class extends Lg{constructor(){super(`ShadowProjectInputPlugin`)}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.shadowProjectsDir,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:L.Relative,path:t.name,basePath:a,getDirectoryName:()=>t.name,getAbsolutePath:()=>i.resolve(a,t.name)}})}}catch(e){n.error(`failed to scan shadow projects`,{path:c,error:e})}if(u.length===0&&r.existsSync(a)&&r.statSync(a).isDirectory()){n.debug(`no projects in dist/app/, falling back to workspace scan`,{workspaceDir:a});try{let e=r.readdirSync(a,{withFileTypes:!0});for(let t of e)if(t.isDirectory()&&!t.name.startsWith(`.`)){let e=t.name===l;u.push({name:t.name,...e&&{isPromptSourceProject:!0},dirFromWorkspacePath:{pathKind:L.Relative,path:t.name,basePath:a,getDirectoryName:()=>t.name,getAbsolutePath:()=>i.resolve(a,t.name)}})}}catch(e){n.error(`failed to scan workspace directory`,{path:a,error:e})}}return{workspace:{directory:{pathKind:L.Absolute,path:a,getDirectoryName:()=>i.basename(a)},projects:u}}}};function qy(e){return Bt.includes(e.toLowerCase())}function Jy(e){let t=e.toLowerCase();return[`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.ico`,`.bmp`,`.tiff`,`.svg`].includes(t)?`image`:`.kt,.java,.py,.pyi,.pyx,.ts,.tsx,.js,.jsx,.mjs,.cjs,.go,.rs,.c,.cpp,.cc,.h,.hpp,.hxx,.cs,.fs,.fsx,.vb,.rb,.php,.swift,.scala,.groovy,.lua,.r,.jl,.ex,.exs,.erl,.clj,.cljs,.hs,.ml,.mli,.nim,.zig,.v,.dart,.vue,.svelte,.d.ts,.d.mts,.d.cts`.split(`,`).includes(t)?`code`:[`.sql`,`.json`,`.jsonc`,`.json5`,`.xml`,`.xsd`,`.xsl`,`.xslt`,`.yaml`,`.yml`,`.toml`,`.csv`,`.tsv`,`.graphql`,`.gql`,`.proto`].includes(t)?`data`:[`.txt`,`.text`,`.rtf`,`.log`,`.docx`,`.doc`,`.xlsx`,`.xls`,`.pptx`,`.ppt`,`.pdf`,`.odt`,`.ods`,`.odp`].includes(t)?`document`:[`.ini`,`.conf`,`.cfg`,`.config`,`.properties`,`.env`,`.envrc`,`.editorconfig`,`.gitignore`,`.gitattributes`,`.npmrc`,`.nvmrc`,`.npmignore`,`.eslintrc`,`.prettierrc`,`.stylelintrc`,`.babelrc`,`.browserslistrc`].includes(t)?`config`:[`.sh`,`.bash`,`.zsh`,`.fish`,`.ps1`,`.psm1`,`.psd1`,`.bat`,`.cmd`].includes(t)?`script`:`.exe,.dll,.so,.dylib,.bin,.wasm,.class,.jar,.war,.pyd,.pyc,.pyo,.zip,.tar,.gz,.bz2,.7z,.rar,.ttf,.otf,.woff,.woff2,.eot,.db,.sqlite,.sqlite3`.split(`,`).includes(t)?`binary`:`other`}function Yy(e){return{".ts":`text/typescript`,".tsx":`text/typescript`,".js":`text/javascript`,".jsx":`text/javascript`,".json":`application/json`,".py":`text/x-python`,".java":`text/x-java`,".kt":`text/x-kotlin`,".go":`text/x-go`,".rs":`text/x-rust`,".c":`text/x-c`,".cpp":`text/x-c++`,".cs":`text/x-csharp`,".rb":`text/x-ruby`,".php":`text/x-php`,".swift":`text/x-swift`,".scala":`text/x-scala`,".sql":`application/sql`,".xml":`application/xml`,".yaml":`text/yaml`,".yml":`text/yaml`,".toml":`text/toml`,".csv":`text/csv`,".graphql":`application/graphql`,".txt":`text/plain`,".pdf":`application/pdf`,".docx":`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,".xlsx":`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,".html":`text/html`,".css":`text/css`,".svg":`image/svg+xml`,".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".webp":`image/webp`,".ico":`image/x-icon`,".bmp":`image/bmp`}[e.toLowerCase()]}var Xy=class extends Lg{constructor(){super(`SkillInputPlugin`)}readMcpConfig(e,t,n){let r=i.join(e,`mcp.json`);if(t.existsSync(r)){if(!t.statSync(r).isFile()){n.warn(`mcp.json is not a file`,{skillDir:e});return}try{let i=t.readFileSync(r,`utf8`),a=JSON.parse(i);if(a.mcpServers==null||typeof a.mcpServers!=`object`){n.warn(`mcp.json missing mcpServers field`,{skillDir:e});return}return{type:Et.SkillMcpConfig,mcpServers:a.mcpServers,rawContent:i}}catch(t){n.warn(`failed to parse mcp.json`,{skillDir:e,error:t});return}}}scanSkillDirectory(e,t,n,r=``){let a=[],o=[],s=r?i.join(e,r):e;try{let c=t.readdirSync(s,{withFileTypes:!0});for(let l of c){let c=r?`${r}/${l.name}`:l.name;if(l.isDirectory()){let r=this.scanSkillDirectory(e,t,n,c);a.push(...r.childDocs),o.push(...r.resources)}else if(l.isFile()){let u=i.join(s,l.name);if(l.name.endsWith(`.mdx`)){if(r===``&&l.name===`skill.mdx`)continue;try{let n=jg(t.readFileSync(u,`utf8`)),r=Mg(n.contentWithoutFrontMatter);a.push({type:Et.SkillChildDoc,content:r,length:r.length,filePathKind:L.Relative,markdownAst:n.markdownAst,markdownContents:n.markdownContents,...n.rawFrontMatter!=null&&{rawFrontMatter:n.rawFrontMatter},relativePath:c,dir:{pathKind:L.Relative,path:c,basePath:e,getDirectoryName:()=>i.dirname(c),getAbsolutePath:()=>u}})}catch(e){n.warn(`failed to read child doc`,{path:c,error:e})}}else{if(r===``&&l.name===`mcp.json`)continue;let e=i.extname(l.name),a,s,f;try{if(qy(e)){let e=t.readFileSync(u);a=e.toString(`base64`),s=`base64`,{length:f}=e}else a=t.readFileSync(u,`utf8`),s=`text`,{length:f}=d.from(a,`utf8`);let n=Yy(e),r={type:Et.SkillResource,extension:e,fileName:l.name,relativePath:c,content:a,encoding:s,category:Jy(e),length:f};n==null?o.push(r):o.push({...r,mimeType:n})}catch(e){n.warn(`failed to read resource file`,{path:c,error:e})}}}}}catch(e){n.warn(`failed to scan directory`,{path:s,error:e})}return{childDocs:a,resources:o}}async collect(e){let{userConfigOptions:t,logger:n,globalScope:r}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.shadowSkillSourceDir,c=this.resolvePath(s,a,o),l=[];if(!(e.fs.existsSync(c)&&e.fs.statSync(c).isDirectory()))return{skills:l};let u=e.fs.readdirSync(c,{withFileTypes:!0});for(let t of u)if(t.isDirectory()){let a=e.path.join(c,t.name,`skill.mdx`);if(e.fs.existsSync(a)&&e.fs.statSync(a).isFile())try{let o=e.fs.readFileSync(a,`utf8`),s=jg(o),u=await fv(o,{globalScope:r,extractMetadata:!0,basePath:e.path.join(c,t.name)}),d={...s.yamlFrontMatter,...u.metadata.fields},f=Ft(d,a);for(let e of f.warnings)n.debug(e);if(!f.valid)throw new Qg(f.errors,a);let p=Mg(u.content),m=e.path.join(c,t.name),h=this.readMcpConfig(m,e.fs,n),{childDocs:g,resources:_}=this.scanSkillDirectory(m,e.fs,n);n.debug(`skill metadata extracted`,{skill:t.name,source:u.metadata.source,hasYaml:s.yamlFrontMatter!=null,hasExport:Object.keys(u.metadata.fields).length>0}),l.push({type:Et.Skill,content:p,length:p.length,filePathKind:L.Relative,yamlFrontMatter:d.name==null?{name:t.name,description:``}:d,...s.rawFrontMatter!=null&&{rawFrontMatter:s.rawFrontMatter},markdownAst:s.markdownAst,markdownContents:s.markdownContents,...h!=null&&{mcpConfig:h},...g.length>0&&{childDocs:g},..._.length>0&&{resources:_},dir:{pathKind:L.Relative,path:t.name,basePath:c,getDirectoryName:()=>t.name,getAbsolutePath:()=>i.join(c,t.name)}})}catch(e){n.error(`failed to parse skill`,{file:a,error:e})}}return{skills:l}}},Zy=class extends Av{constructor(){super(`SubAgentInputPlugin`,{configKey:`shadowSubAgentDir`})}getTargetDir(e,t){let n=e.shadowSubAgentDir,{workspaceDir:r,shadowProjectDir:i}=t;return this.resolvePath(n,r,i)}validateMetadata(e,t){return Lt(e,t)}createResult(e){return{subAgents:e}}createPrompt(e,t,n,r,i,a,o,s){return{type:Et.SubAgent,content:n,length:n.length,filePathKind:L.Relative,...r!=null&&{yamlFrontMatter:r},...i!=null&&{rawFrontMatter:i},markdownAst:a.markdownAst,markdownContents:a.markdownContents,dir:{pathKind:L.Relative,path:e,basePath:o,getDirectoryName:()=>e.replace(/\.mdx$/,``),getAbsolutePath:()=>t}}}};const Qy=`.vscode`,$y=[`.vscode/settings.json`,`.vscode/extensions.json`];var eb=class extends Pg{constructor(){super(`VisualStudioCodeIDEConfigOutputPlugin`)}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{ideConfigFiles:r}=e.collectedInputContext;if(!r.some(e=>e.type===R.VSCode))return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&e.isPromptSourceProject!==!0)for(let e of $y){let r=this.joinPath(n.path,e);t.push({pathKind:L.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===R.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===R.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:L.Relative,path:this.joinPath(t.path,i),basePath:t.basePath,getDirectoryName:()=>this.dirname(i),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`config`,path:a,label:r}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,n.content),this.log.trace({action:`write`,type:`config`,path:a,label:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`config`,path:a,label:r,error:t}),{path:o,success:!1,error:e}}}getTargetRelativePath(e){let t=e.dir.path;if(e.type!==R.VSCode)return this.basename(t);let n=t.indexOf(Qy);return n===-1?this.joinPath(Qy,this.basename(t)):t.slice(Math.max(0,n))}};const tb=`WARP.md`;var nb=class extends Pg{constructor(){super(`WarpIDEOutputPlugin`,{outputFileName:tb})}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,tb));else if(e.rootMemoryPrompt!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,tb)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,tb))}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}}},rb=class extends Lg{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:L.Relative,path:t,basePath:n,getDirectoryName:()=>i.basename(t)}}});return{workspace:{directory:{pathKind:L.Absolute,path:n,getDirectoryName:()=>i.basename(n)},projects:[]},shadowSourceProjectDir:r,...a.length>0&&{externalProjects:a}}}},ib=Dr({plugins:[new Ig,new Vg,new Jg,new mv,new yv,new iy,new kv,new Mv,new Lv,new Ay,new dy,new Hy,new nb,new xy,new Ov,new Uv,new sy,new eb,new Wy,new my,new fy,new cy,new rb,new Ky,new zg,new Jv,new Xy,new jv,new Zy,new qv,new Ny,new Gy,new Kv,new zv]});async function ab(){let e=await ib;await new yr(...n.argv).run(e)}ab().catch(e=>console.error(e));export{jt as CircularDependencyError,Dt as ClaudeCodeCLISubAgentColors,Ot as CodingAgentTools,mn as ConfigLoader,Nt as ConfigValidationError,ln as DEFAULT_CONFIG_FILE_NAME,un as DEFAULT_GLOBAL_CONFIG_DIR,Ut as DEFAULT_SHADOW_SOURCE_PROJECT_STRUCTURE,Jt as DEFAULT_USER_CONFIG,L as FilePathKind,At as GlobalConfigDirectoryType,R as IDEKind,Mt as MissingDependencyError,kt as NamingCaseKind,qt as PathPlaceholders,Tt as PluginKind,Et as PromptKind,Vt as SHADOW_SOURCE_DIR_NAMES,Ht as SHADOW_SOURCE_FILE_NAMES,z as SHADOW_SOURCE_RELATIVE_PATHS,Bt as SKILL_RESOURCE_BINARY_EXTENSIONS,zt as SKILL_RESOURCE_TEXT_EXTENSIONS,Rt as applyMetadataDefaults,_t as checkCanClean,yt as checkCanWrite,Ln as checkVersionControl,gt as collectAllPluginOutputs,cn as createLogger,ib as default,Dr as defineConfig,vt as executeOnCleanComplete,bt as executeWriteOutputs,zn as generateShadowSourceProject,gn as getConfigLoader,fn as getDefaultUserConfig,dn as getGlobalConfigPath,sn as getGlobalLogLevel,_n as loadUserConfig,Sr as mergeConfig,on as setGlobalLogLevel,vn as validateAndEnsureGlobalConfig,Pt as validateExportMetadata,It as validateFastCommandMetadata,Ft as validateSkillMetadata,Lt as validateSubAgentMetadata};