@truenine/memory-sync-cli 2026.10318.12034 → 2026.10322.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/globals.d.mts +5 -5
- package/dist/index.d.mts +1368 -1367
- package/dist/index.mjs +110 -104
- package/dist/plugin-runtime.mjs +59 -54
- package/package.json +23 -26
- package/dist/globals.cjs +0 -62
- package/dist/globals.d.cts +0 -159
- package/dist/index.cjs +0 -302
- package/dist/index.d.cts +0 -5303
- package/dist/main.mjs +0 -5
package/dist/plugin-runtime.mjs
CHANGED
|
@@ -17,7 +17,7 @@ var n=te(),r={"{":`}`,"(":`)`,"[":`]`},i=function(e){if(e[0]===`!`)return!0;for(
|
|
|
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=x(((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=x((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=x((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=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fs=void 0,e.fs=Ee()})),Oe=x((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=x((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)}})),L=x((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})),Ae=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createFileSystemAdapter=e.FILE_SYSTEM_ADAPTER=void 0;let t=w(`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})),je=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=w(`path`),n=Se(),r=Ae();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}}})),Me=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.scandirSync=e.scandir=void 0;let t=ke(),n=L(),r=je();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)}})),Ne=x(((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})),Pe=x(((e,t)=>{var n=Ne();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})),Fe=x((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})),Ie=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Fe();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._root=t.replacePathSegmentSeparator(e,n.pathSegmentSeparator)}}})),Le=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=w(`events`),n=Me(),r=Pe(),i=Fe(),a=Ie();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)}}})),Re=x((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),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)}})),ze=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=w(`stream`),n=Le();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}}})),Be=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Me(),n=Fe(),r=Ie();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)}}})),Ve=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Be();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()}}})),R=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=w(`path`),n=Me();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}}})),He=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.walkStream=e.walkSync=e.walk=void 0;let t=Re(),n=ze(),r=Ve(),i=R();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)}})),Ue=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=w(`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}}})),We=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=w(`stream`),n=Se(),r=He(),i=Ue();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))})}}})),Ge=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=He(),n=Ue(),r=We();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))})}}})),Ke=x((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))}}})),qe=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ke();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}}})),Je=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ge(),n=qe();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)}}})),Ye=x((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}}})),Xe=x((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}}})),Ze=x((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}}})),Qe=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=w(`path`),n=Je(),r=Ye(),i=Xe(),a=Ze();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}}}})),$e=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ge(),n=Qe();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)}}})),et=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=w(`stream`),n=We(),r=Qe();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)}}})),tt=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Se(),n=He(),r=Ue();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)}}})),nt=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=tt(),n=Qe();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)}}})),rt=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DEFAULT_FILE_SYSTEM_ADAPTER=void 0;let t=w(`fs`),n=w(`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)}}})),it=C(x(((e,t)=>{let n=_e(),r=$e(),i=et(),a=nt(),o=rt(),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 z(e,...t){return[e,...t]}function at(e){return e instanceof Error?e.message:String(e)}function ot(e){let t=e.split(/\r?\n/u).map(e=>e.trimEnd()).filter(e=>e.length>0);return t.length===0?z(`No diagnostic details were provided.`):z(t[0],...t.slice(1))}function st(e){return e}function ct(e){return at(e).toLowerCase()}function lt(e){if(e.platform!==`win32`||e.operation!==`delete`||e.targetKind!==`directory`)return!1;let t=ct(e.error);return t.includes(`eperm`)||t.includes(`permission denied`)}function ut(e){return lt(e)?{exactFix:z(`Close any process that is using "${e.path}", delete the stale directory, and rerun tnmsc.`,`Common lockers on Windows include editors, terminals, antivirus scanners, sync clients, and AI tools watching generated files.`),possibleFixes:[z(`Use Resource Monitor or Process Explorer to find which process holds a handle under "${e.path}".`),z(`Make sure no shell, editor tab, or file watcher is currently opened inside "${e.path}" or one of its children.`),z(`If antivirus or cloud sync is scanning generated outputs, wait for it to release the directory or exclude this output path.`)]}:{exactFix:z(`Verify that "${e.path}" exists, has the expected type, and is accessible to tnmsc.`),possibleFixes:[z(`Check file permissions and ownership for the target path.`),z(`Confirm that another process did not delete, move, or lock the target path.`)]}}function B(e){let{code:n,title:r,operation:i,targetKind:a,path:o,error:s,platform:c,exactFix:l,possibleFixes:u,details:d}=e,f=at(s),p=ut({operation:i,targetKind:a,path:o,error:s,platform:c??t.platform});return st({code:n,title:r,rootCause:z(`tnmsc could not ${i} the ${a} at "${o}".`,`Underlying error: ${f}`),exactFix:l??p.exactFix,possibleFixes:u??p.possibleFixes,details:{operation:i,targetKind:a,path:o,errorMessage:f,platform:c??t.platform,...d??{}}})}function dt(e){let{code:t,title:n,reason:r,configPath:i,exactFix:a,possibleFixes:o,details:s}=e;return st({code:t,title:n,rootCause:i==null?r:z(r[0],...r.slice(1),`Config path: ${i}`),exactFix:a,possibleFixes:o,details:{...i==null?{}:{configPath:i},...s??{}}})}function ft(e){return st(e)}function pt(e){let{code:t,title:n,path:r,expectedKind:i,actualState:a,exactFix:o,possibleFixes:s,details:c}=e;return st({code:t,title:n,rootCause:z(`tnmsc expected a ${i} at "${r}".`,`Actual state: ${a}`),exactFix:o??z(`Create or replace "${r}" with a valid ${i} before retrying tnmsc.`),possibleFixes:s??[z(`Check whether the path was moved, deleted, or replaced with the wrong file type.`),z(`Update your configuration so tnmsc points to the intended source path.`)],details:{path:r,expectedKind:i,actualState:a,...c??{}}})}function mt(e){let{code:t,title:n,diagnosticText:r,exactFix:i,possibleFixes:a,details:o}=e;return st({code:t,title:n,rootCause:ot(r),exactFix:i??z(`Fix the referenced prompt source or compiled dist file so the compiler diagnostic no longer triggers.`),possibleFixes:a??[z(`Open the file referenced in the diagnostic and correct the reported syntax or metadata issue.`),z(`Rebuild the prompt output so the dist file matches the current source tree.`)],details:{diagnosticText:r,...o??{}}})}function ht(e,t){let n=t[0];return st({code:`PROTECTED_DELETION_GUARD_TRIGGERED`,title:`Protected deletion guard blocked a destructive operation`,rootCause:z(`The "${e}" operation targeted ${t.length} protected path(s).`,n==null?`No violation details were captured.`:`Example protected path: ${n.protectedPath}`),exactFix:z(`Remove protected inputs or reserved workspace paths from the delete plan before running tnmsc again.`),possibleFixes:[z(`Update cleanup declarations so they only target generated output paths.`),z(`Move source inputs outside of the cleanup target set if they are currently overlapping.`)],details:{operation:e,count:t.length,violations:t.map(e=>({targetPath:e.targetPath,protectedPath:e.protectedPath,protectionMode:e.protectionMode,source:e.source,reason:e.reason}))}})}function gt(e,t){let n=at(t);return st({code:`UNHANDLED_EXCEPTION`,title:`Unhandled exception in ${e}`,rootCause:z(`tnmsc terminated because an unhandled exception escaped the ${e} flow.`,`Underlying error: ${n}`),exactFix:z(`Inspect the error context and add the missing guard, validation, or recovery path before retrying the command.`),possibleFixes:[z(`Re-run the command with the same inputs after fixing the referenced file or configuration.`),z(`Add a focused test that reproduces this failure so the regression stays covered.`)],details:{context:e,errorMessage:n}})}function _t(e){let t=[],n=[];for(let r of e)r.level===`warn`?t.push(r):n.push(r);return{warnings:t,errors:n}}function V(e){let n=t.env.XDG_DATA_HOME;return typeof n==`string`&&n.trim().length>0?n:a.join(e,`.local`,`share`)}function vt(){let e=t.platform,n=l.homedir();if(e===`win32`)return t.env.LOCALAPPDATA??a.join(n,`AppData`,`Local`);if(e===`darwin`)return a.join(n,`Library`,`Application Support`);if(e===`linux`)return V(n);throw Error(`Unsupported platform: ${t.platform}`)}function yt(e){if(!n.existsSync(e))return;let r=n.lstatSync(e);r.isSymbolicLink()?t.platform===`win32`?n.rmSync(e,{recursive:!0,force:!0}):n.unlinkSync(e):r.isDirectory()?n.rmSync(e,{recursive:!0,force:!0}):n.unlinkSync(e)}function bt(e){let t=0,r=[];for(let i of e)try{n.existsSync(i)&&(yt(i),t++)}catch(e){r.push({path:i,error:e})}return{deleted:t,errors:r}}function xt(e){let t=0,r=[],i=[...e].sort((e,t)=>t.length-e.length);for(let e of i)try{n.existsSync(e)&&(n.rmSync(e,{recursive:!0,force:!0}),t++)}catch(t){r.push({path:e,error:t})}return{deleted:t,errors:r}}const St={"win32-x64":{local:`napi-logger.win32-x64-msvc`,suffix:`win32-x64-msvc`},"linux-x64":{local:`napi-logger.linux-x64-gnu`,suffix:`linux-x64-gnu`},"linux-arm64":{local:`napi-logger.linux-arm64-gnu`,suffix:`linux-arm64-gnu`},"darwin-arm64":{local:`napi-logger.darwin-arm64`,suffix:`darwin-arm64`},"darwin-x64":{local:`napi-logger.darwin-x64`,suffix:`darwin-x64`}},Ct=[`error`,`warn`,`fatal`],wt=[`info`,`debug`,`trace`];let Tt,Et;function Dt(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.createLogger==`function`&&typeof t.setGlobalLogLevel==`function`&&typeof t.getGlobalLogLevel==`function`&&typeof t.clearBufferedDiagnostics==`function`&&typeof t.drainBufferedDiagnostics==`function`}function Ot(){let e=St[`${t.platform}-${t.arch}`];if(e!=null)return e;throw Error(`Unsupported platform for @truenine/logger native binding: ${t.platform}-${t.arch}`)}function kt(e,n,r){let i=e instanceof Error?e.message:String(e),a=n instanceof Error?n.message:String(n);return Error([`Failed to load @truenine/logger native binding.`,`Tried local binary "./${St[`${t.platform}-${t.arch}`]?.local??`unknown`}.node" and package "@truenine/memory-sync-cli-${r}".`,`Local error: ${i}`,`Package error: ${a}`,"Run `pnpm -F @truenine/logger run build` to build the native module."].join(`
|
|
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=x((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=x((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=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fs=void 0,e.fs=Ee()})),Oe=x((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=x((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)}})),L=x((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})),Ae=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createFileSystemAdapter=e.FILE_SYSTEM_ADAPTER=void 0;let t=w(`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})),je=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=w(`path`),n=Se(),r=Ae();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}}})),Me=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.scandirSync=e.scandir=void 0;let t=ke(),n=L(),r=je();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)}})),Ne=x(((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})),Pe=x(((e,t)=>{var n=Ne();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})),Fe=x((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})),Ie=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Fe();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._root=t.replacePathSegmentSeparator(e,n.pathSegmentSeparator)}}})),Le=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=w(`events`),n=Me(),r=Pe(),i=Fe(),a=Ie();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)}}})),Re=x((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),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)}})),ze=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=w(`stream`),n=Le();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}}})),Be=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Me(),n=Fe(),r=Ie();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)}}})),Ve=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Be();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()}}})),R=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=w(`path`),n=Me();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}}})),He=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.walkStream=e.walkSync=e.walk=void 0;let t=Re(),n=ze(),r=Ve(),i=R();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)}})),Ue=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=w(`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}}})),We=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=w(`stream`),n=Se(),r=He(),i=Ue();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))})}}})),Ge=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=He(),n=Ue(),r=We();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))})}}})),Ke=x((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))}}})),qe=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ke();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}}})),Je=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=ge(),n=qe();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)}}})),Ye=x((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}}})),Xe=x((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}}})),Ze=x((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}}})),Qe=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=w(`path`),n=Je(),r=Ye(),i=Xe(),a=Ze();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}}}})),$e=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ge(),n=Qe();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)}}})),et=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=w(`stream`),n=We(),r=Qe();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)}}})),tt=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Se(),n=He(),r=Ue();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)}}})),nt=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=tt(),n=Qe();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)}}})),rt=x((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DEFAULT_FILE_SYSTEM_ADAPTER=void 0;let t=w(`fs`),n=w(`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)}}})),it=C(x(((e,t)=>{let n=_e(),r=$e(),i=et(),a=nt(),o=rt(),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 z(e,...t){return[e,...t]}function at(e){return e instanceof Error?e.message:String(e)}function ot(e){let t=e.split(/\r?\n/u).map(e=>e.trimEnd()).filter(e=>e.length>0);if(t.length===0)return z(`No diagnostic details were provided.`);let[n,...r]=t;return n==null?z(`No diagnostic details were provided.`):z(n,...r)}function st(e){return e}function ct(e){return at(e).toLowerCase()}function lt(e){if(e.platform!==`win32`||e.operation!==`delete`||e.targetKind!==`directory`)return!1;let t=ct(e.error);return t.includes(`eperm`)||t.includes(`permission denied`)}function ut(e){return lt(e)?{exactFix:z(`Close any process that is using "${e.path}", delete the stale directory, and rerun tnmsc.`,`Common lockers on Windows include editors, terminals, antivirus scanners, sync clients, and AI tools watching generated files.`),possibleFixes:[z(`Use Resource Monitor or Process Explorer to find which process holds a handle under "${e.path}".`),z(`Make sure no shell, editor tab, or file watcher is currently opened inside "${e.path}" or one of its children.`),z(`If antivirus or cloud sync is scanning generated outputs, wait for it to release the directory or exclude this output path.`)]}:{exactFix:z(`Verify that "${e.path}" exists, has the expected type, and is accessible to tnmsc.`),possibleFixes:[z(`Check file permissions and ownership for the target path.`),z(`Confirm that another process did not delete, move, or lock the target path.`)]}}function B(e){let{code:n,title:r,operation:i,targetKind:a,path:o,error:s,platform:c,exactFix:l,possibleFixes:u,details:d}=e,f=at(s),p=ut({operation:i,targetKind:a,path:o,error:s,platform:c??t.platform});return st({code:n,title:r,rootCause:z(`tnmsc could not ${i} the ${a} at "${o}".`,`Underlying error: ${f}`),exactFix:l??p.exactFix,possibleFixes:u??p.possibleFixes,details:{operation:i,targetKind:a,path:o,errorMessage:f,platform:c??t.platform,...d??{}}})}function dt(e){let{code:t,title:n,reason:r,configPath:i,exactFix:a,possibleFixes:o,details:s}=e;return st({code:t,title:n,rootCause:i==null?r:z(r[0],...r.slice(1),`Config path: ${i}`),exactFix:a,possibleFixes:o,details:{...i==null?{}:{configPath:i},...s??{}}})}function ft(e){return st(e)}function pt(e){let{code:t,title:n,path:r,expectedKind:i,actualState:a,exactFix:o,possibleFixes:s,details:c}=e;return st({code:t,title:n,rootCause:z(`tnmsc expected a ${i} at "${r}".`,`Actual state: ${a}`),exactFix:o??z(`Create or replace "${r}" with a valid ${i} before retrying tnmsc.`),possibleFixes:s??[z(`Check whether the path was moved, deleted, or replaced with the wrong file type.`),z(`Update your configuration so tnmsc points to the intended source path.`)],details:{path:r,expectedKind:i,actualState:a,...c??{}}})}function mt(e){let{code:t,title:n,diagnosticText:r,exactFix:i,possibleFixes:a,details:o}=e;return st({code:t,title:n,rootCause:ot(r),exactFix:i??z(`Fix the referenced prompt source or compiled dist file so the compiler diagnostic no longer triggers.`),possibleFixes:a??[z(`Open the file referenced in the diagnostic and correct the reported syntax or metadata issue.`),z(`Rebuild the prompt output so the dist file matches the current source tree.`)],details:{diagnosticText:r,...o??{}}})}function ht(e,t){let n=t[0];return st({code:`PROTECTED_DELETION_GUARD_TRIGGERED`,title:`Protected deletion guard blocked a destructive operation`,rootCause:z(`The "${e}" operation targeted ${t.length} protected path(s).`,n==null?`No violation details were captured.`:`Example protected path: ${n.protectedPath}`),exactFix:z(`Remove protected inputs or reserved workspace paths from the delete plan before running tnmsc again.`),possibleFixes:[z(`Update cleanup declarations so they only target generated output paths.`),z(`Move source inputs outside of the cleanup target set if they are currently overlapping.`)],details:{operation:e,count:t.length,violations:t.map(e=>({targetPath:e.targetPath,protectedPath:e.protectedPath,protectionMode:e.protectionMode,source:e.source,reason:e.reason}))}})}function gt(e,t){let n=at(t);return st({code:`UNHANDLED_EXCEPTION`,title:`Unhandled exception in ${e}`,rootCause:z(`tnmsc terminated because an unhandled exception escaped the ${e} flow.`,`Underlying error: ${n}`),exactFix:z(`Inspect the error context and add the missing guard, validation, or recovery path before retrying the command.`),possibleFixes:[z(`Re-run the command with the same inputs after fixing the referenced file or configuration.`),z(`Add a focused test that reproduces this failure so the regression stays covered.`)],details:{context:e,errorMessage:n}})}function _t(e){let t=[],n=[];for(let r of e)r.level===`warn`?t.push(r):n.push(r);return{warnings:t,errors:n}}function V(e){let n=t.env.XDG_DATA_HOME;return typeof n==`string`&&n.trim().length>0?n:a.join(e,`.local`,`share`)}function vt(){let e=t.platform,n=l.homedir();if(e===`win32`)return t.env.LOCALAPPDATA??a.join(n,`AppData`,`Local`);if(e===`darwin`)return a.join(n,`Library`,`Application Support`);if(e===`linux`)return V(n);throw Error(`Unsupported platform: ${t.platform}`)}async function yt(e){try{let r=await n.promises.lstat(e);return r.isSymbolicLink()?(await(t.platform===`win32`?n.promises.rm(e,{recursive:!0,force:!0}):n.promises.unlink(e)),!0):r.isDirectory()?(await n.promises.rm(e,{recursive:!0,force:!0}),!0):(await n.promises.unlink(e),!0)}catch(e){if(e.code===`ENOENT`)return!1;throw e}}async function bt(e){let t=await Promise.all(e.map(async e=>{try{return{path:e,deleted:await yt(e)}}catch(t){return{path:e,error:t}}})),n=[],r=0;for(let e of t){if(`error`in e){n.push({path:e.path,error:e.error});continue}e.deleted&&r++}return{deleted:r,errors:n}}async function xt(e){let t=[...e].sort((e,t)=>t.length-e.length),n=await Promise.all(t.map(async e=>{try{return{path:e,deleted:await yt(e)}}catch(t){return{path:e,error:t}}})),r=[],i=0;for(let e of n){if(`error`in e){r.push({path:e.path,error:e.error});continue}e.deleted&&i++}return{deleted:i,errors:r}}const St={"win32-x64":{local:`napi-logger.win32-x64-msvc`,suffix:`win32-x64-msvc`},"linux-x64":{local:`napi-logger.linux-x64-gnu`,suffix:`linux-x64-gnu`},"linux-arm64":{local:`napi-logger.linux-arm64-gnu`,suffix:`linux-arm64-gnu`},"darwin-arm64":{local:`napi-logger.darwin-arm64`,suffix:`darwin-arm64`},"darwin-x64":{local:`napi-logger.darwin-x64`,suffix:`darwin-x64`}},Ct=[`error`,`warn`,`fatal`],wt=[`info`,`debug`,`trace`];let Tt,Et;function Dt(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.createLogger==`function`&&typeof t.setGlobalLogLevel==`function`&&typeof t.getGlobalLogLevel==`function`&&typeof t.clearBufferedDiagnostics==`function`&&typeof t.drainBufferedDiagnostics==`function`}function Ot(){let e=St[`${t.platform}-${t.arch}`];if(e!=null)return e;throw Error(`Unsupported platform for @truenine/logger native binding: ${t.platform}-${t.arch}`)}function kt(e,n,r){let i=e instanceof Error?e.message:String(e),a=n instanceof Error?n.message:String(n);return Error([`Failed to load @truenine/logger native binding.`,`Tried local binary "./${St[`${t.platform}-${t.arch}`]?.local??`unknown`}.node" and package "@truenine/memory-sync-cli-${r}".`,`Local error: ${i}`,`Package error: ${a}`,"Run `pnpm -F @truenine/logger run build` to build the native module."].join(`
|
|
21
21
|
`))}function At(e,t){let n=`@truenine/memory-sync-cli-${t}`;try{let t=e(n).logger;if(Dt(t))return t}catch{}let i=o(e.resolve(`${n}/package.json`)),a=r(i).filter(e=>e.startsWith(`napi-logger.`)&&e.endsWith(`.node`)).sort();for(let t of a){let n=e(s(i,t));if(Dt(n))return n}throw Error(`Package "${n}" does not export a logger binding or contain a compatible native module`)}function jt(){let t=import.meta.url,n=e(t),{local:r,suffix:i}=Ot();try{return n(`./${r}.node`)}catch(e){try{return At(n,i)}catch(t){throw kt(e,t,i)}}}function Mt(){if(Tt!=null)return Tt;if(Et!=null)throw Et;try{return Tt=jt(),Tt}catch(e){throw Et=e instanceof Error?e:Error(String(e)),Et}}function Nt(e){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 t}function Pt(){let e=new WeakSet;return function(t,n){return n instanceof Error?Nt(n):typeof n==`bigint`?n.toString():typeof n==`function`?`[Function ${n.name||`anonymous`}]`:typeof n==`symbol`?n.toString():typeof n!=`object`||!n?n:e.has(n)?`[Circular]`:(e.add(n),n)}}function Ft(e){return JSON.stringify(e,Pt())??`null`}function It(e){try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function Lt(e,t){if(typeof e!=`string`)return{message:``,metaJson:Ft(e)};let n=t.length===1&&typeof t[0]==`object`&&t[0]!==null?t[0]:t.length>0?{args:t}:void 0;return{message:e,metaJson:n==null?void 0:Ft(n)}}function Rt(e,t){return(n,...r)=>{let{message:i,metaJson:a}=Lt(n,r);e.log(t,i,a)}}function zt(e,t){return n=>e.logDiagnostic(t,Ft(n))}function Bt(e){let t=wt.reduce((t,n)=>(t[n]=Rt(e,n),t),{}),n=Ct.reduce((t,n)=>(t[n]=zt(e,n),t),{});return{error:n.error,warn:n.warn,info:t.info,debug:t.debug,trace:t.trace,fatal:n.fatal}}function H(e){Mt().setGlobalLogLevel(e)}function Vt(){Mt().clearBufferedDiagnostics()}function Ht(){return It(Mt().drainBufferedDiagnostics())}function Ut(e,t){return Bt(Mt().createLogger(e,t))}var Wt=Object.create,Gt=Object.defineProperty,Kt=Object.getOwnPropertyDescriptor,qt=Object.getOwnPropertyNames,Jt=Object.getPrototypeOf,Yt=Object.prototype.hasOwnProperty,U=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Xt=(e,t)=>{let n={};for(var r in e)Gt(n,r,{get:e[r],enumerable:!0});return t||Gt(n,Symbol.toStringTag,{value:`Module`}),n},Zt=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=qt(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Yt.call(e,s)&&s!==n&&Gt(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Kt(t,s))||r.enumerable});return e},Qt=(e,t,n)=>(n=e==null?{}:Wt(Jt(e)),Zt(t||!e||!e.__esModule?Gt(n,`default`,{value:e,enumerable:!0}):n,e)),$t=e(import.meta.url);const en=dn(/[A-Za-z]/),tn=dn(/[\dA-Za-z]/),nn=dn(/[#-'*+\--9=?A-Z^-~]/);function rn(e){return e!==null&&(e<32||e===127)}const an=dn(/\d/),on=dn(/[\dA-Fa-f]/),sn=dn(/[!-/:-@[-`{-~]/);function W(e){return e!==null&&e<-2}function cn(e){return e!==null&&(e<0||e===32)}function G(e){return e===-2||e===-1||e===32}const ln=dn(/\p{P}|\p{S}/u),un=dn(/\s/);function dn(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}var fn=Qt(U(((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 pn=Object.assign(mn(Error),{eval:mn(EvalError),range:mn(RangeError),reference:mn(ReferenceError),syntax:mn(SyntaxError),type:mn(TypeError),uri:mn(URIError)});function mn(e){return t.displayName=e.displayName||e.name,t;function t(t,...n){return new e(t&&(0,fn.default)(t,...n))}}const hn={}.hasOwnProperty,gn={yaml:`-`,toml:`+`};function _n(e){let t=[],n=-1,r=Array.isArray(e)?e:e?[e]:[`yaml`];for(;++n<r.length;)t[n]=vn(r[n]);return t}function vn(e){let t=e;if(typeof t==`string`){if(!hn.call(gn,t))throw pn("Missing matter definition for `%s`",t);t={type:t,marker:gn[t]}}else if(typeof t!=`object`)throw pn("Expected matter to be an object, not `%j`",t);if(!hn.call(t,`type`))throw pn("Missing `type` in matter `%j`",t);if(!hn.call(t,`fence`)&&!hn.call(t,`marker`))throw pn("Missing `marker` or `fence` in matter `%j`",t);return t}function yn(e){let t=_n(e),n={},r=-1;for(;++r<t.length;){let e=t[r],i=xn(e,`open`).charCodeAt(0),a=bn(e),o=n[i];Array.isArray(o)?o.push(a):n[i]=[a]}return{flow:n}}function bn(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=xn(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),G(e)?(l.enter(`whitespace`),h(e)):g(e)):e===s.charCodeAt(c++)?(l.consume(e),m):d(e)}function h(e){return G(e)?(l.consume(e),h):(l.exit(`whitespace`),g(e))}function g(t){return W(t)?(l.exit(r),l.enter(`lineEnding`),l.consume(t),l.exit(`lineEnding`),s=xn(e,`close`),c=0,l.attempt(o,b,_)):d(t)}function _(e){return e===null||W(e)?y(e):(l.enter(a),v(e))}function v(e){return e===null||W(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),G(t)?(e.enter(`whitespace`),l(t)):u(t)):t===s.charCodeAt(a++)?(e.consume(t),c):n(t)}function l(t){return G(t)?(e.consume(t),l):(e.exit(`whitespace`),u(t))}function u(i){return i===null||W(i)?(e.exit(r),t(i)):n(i)}}}function xn(e,t){return e.marker?Sn(e.marker,t).repeat(3):Sn(e.fence,t)}function Sn(e,t){return typeof e==`string`?e:e[t]}function Cn(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function wn(e){let t=_n(e),n={},r={},i=-1;for(;++i<t.length;){let e=t[i];n[e.type]=Tn(e),r[e.type]=En,r[e.type+`Value`]=Dn}return{enter:n,exit:r}}function Tn(e){return t;function t(t){this.enter({type:e.type,value:``},t),this.buffer()}}function En(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 Dn(e){this.config.enter.data.call(this,e),this.config.exit.data.call(this,e)}function On(e){let t=[],n={},r=_n(e),i=-1;for(;++i<r.length;){let e=r[i];n[e.type]=kn(e);let a=An(e,`open`);t.push({atBreak:!0,character:a.charAt(0),after:Cn(a.charAt(1))})}return{unsafe:t,handlers:n}}function kn(e){let t=An(e,`open`),n=An(e,`close`);return r;function r(e){return t+(e.value?`
|
|
22
22
|
`+e.value:``)+`
|
|
23
23
|
`+n}}function An(e,t){return e.marker?jn(e.marker,t).repeat(3):jn(e.fence,t)}function jn(e,t){return typeof e==`string`?e:e[t]}function Mn(e){let t=this,n=e||`yaml`,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(yn(n)),a.push(wn(n)),o.push(On(n))}function Nn(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 Pn=(function(e){if(e==null)return zn;if(typeof e==`function`)return Rn(e);if(typeof e==`object`)return Array.isArray(e)?Fn(e):In(e);if(typeof e==`string`)return Ln(e);throw Error(`Expected function, string, or object as test`)});function Fn(e){let t=[],n=-1;for(;++n<e.length;)t[n]=Pn(e[n]);return Rn(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function In(e){let t=e;return Rn(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function Ln(e){return Rn(t);function t(t){return t&&t.type===e}}function Rn(e){return t;function t(t,n,r){return!!(Bn(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function zn(){return!0}function Bn(e){return typeof e==`object`&&!!e&&`type`in e}function Vn(e){return`\x1B[33m`+e+`\x1B[39m`}const Hn=[];function Un(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=Pn(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 (`+Vn(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=Hn,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=Wn(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 Wn(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?Hn:[e]}function Gn(e,t,n){let r=Pn((n||{}).ignore||[]),i=Kn(t),a=-1;for(;++a<i.length;)Un(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function Kn(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([qn(e[0]),Jn(e[1])])}return t}function qn(e){return typeof e==`string`?new RegExp(Cn(e),`g`):e}function Jn(e){return typeof e==`function`?e:function(){return e}}const Yn=`phrasing`,Xn=[`autolink`,`link`,`image`,`label`];function Zn(){return{transforms:[ar],enter:{literalAutolink:$n,literalAutolinkEmail:er,literalAutolinkHttp:er,literalAutolinkWww:er},exit:{literalAutolink:ir,literalAutolinkEmail:rr,literalAutolinkHttp:tr,literalAutolinkWww:nr}}}function Qn(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:Yn,notInConstruct:Xn},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:Yn,notInConstruct:Xn},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:Yn,notInConstruct:Xn}]}}function $n(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function er(e){this.config.enter.autolinkProtocol.call(this,e)}function tr(e){this.config.exit.autolinkProtocol.call(this,e)}function nr(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 rr(e){this.config.exit.autolinkEmail.call(this,e)}function ir(e){this.exit(e)}function ar(e){Gn(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,or],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,sr]],{ignore:[`link`,`linkReference`]})}function or(e,t,n,r,i){let a=``;if(!ur(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!cr(n)))return!1;let o=lr(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 sr(e,t,n,r){return!ur(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function cr(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 lr(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=Nn(e,`(`),a=Nn(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 ur(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||un(n)||ln(n))&&(!t||n!==47)}function dr(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}xr.peek=br;function fr(){this.buffer()}function pr(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function mr(){this.buffer()}function hr(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function gr(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=dr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function _r(e){this.exit(e)}function vr(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=dr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function yr(e){this.exit(e)}function br(){return`[`}function xr(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 Sr(){return{enter:{gfmFootnoteCallString:fr,gfmFootnoteCall:pr,gfmFootnoteDefinitionLabelString:mr,gfmFootnoteDefinition:hr},exit:{gfmFootnoteCallString:gr,gfmFootnoteCall:_r,gfmFootnoteDefinitionLabelString:vr,gfmFootnoteDefinition:yr}}}function Cr(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:xr},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?`
|
|
@@ -182,76 +182,81 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
182
182
|
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
183
183
|
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,a=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(a=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(a.push(this.sourceToken),e.items.push({start:a,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey)if(!t.sep)if(i(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=c(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(i(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(o(t.key)&&!i(t.sep,`newline`)){let e=c(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else a.length>0?t.sep=t.sep.concat(a,this.sourceToken):t.sep.push(this.sourceToken);else t.sep?t.value||r?e.items.push({start:a,key:null,sep:[this.sourceToken]}):i(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:a,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!i(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:a});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||i(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=c(s(t));l(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
|
|
184
184
|
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
185
|
-
`,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())}}}})),Mm=U((e=>{var t=wm(),n=sm(),r=cm(),i=Mp(),a=gp(),o=Am(),s=jm();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})),Nm=U((e=>{var t=wm(),n=sm(),r=am(),i=cm(),a=Cp(),o=gp(),s=Fp(),c=wp(),l=Lp(),u=zp();Om();var d=km(),f=Am(),p=jm(),m=Mm(),h=_p();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})),Pm=Qt(Nm(),1);let
|
|
186
|
-
---`:`---\n${Pm.stringify(n,{singleQuote:t?.singleQuote??!1,lineWidth:t?.lineWidth??0}).trimEnd()}\n---`}function
|
|
185
|
+
`,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())}}}})),Mm=U((e=>{var t=wm(),n=sm(),r=cm(),i=Mp(),a=gp(),o=Am(),s=jm();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})),Nm=U((e=>{var t=wm(),n=sm(),r=am(),i=cm(),a=Cp(),o=gp(),s=Fp(),c=wp(),l=Lp(),u=zp();Om();var d=km(),f=Am(),p=jm(),m=Mm(),h=_p();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})),Pm=Qt(Nm(),1);const Fm=/^---\r?\n[\s\S]*?\r?\n---(?:(?:\r?\n){1,2}|$)/u,Im=/(!?\[)([^\]]*)(\]\()([^)]+)(\))/gu,Lm=/\.mdx$/u,Rm=/\.mdx(?=#|\?|$)/gu,zm=/^(?:https?:)?\/\//u,Bm=/\.mdx$/u,Vm=/\.mdx#/u,Hm=/\.mdx\?/u;let Um=null;function Wm(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.buildFrontMatter==`function`&&typeof t.buildMarkdownWithFrontMatter==`function`&&typeof t.parseMarkdown==`function`&&typeof t.transformMdxReferencesToMd==`function`}function Gm(e,t){let n=`@truenine/memory-sync-cli-${t}`;try{let t=e(n).mdCompiler;if(Wm(t))return t}catch{}try{let t=o(e.resolve(`${n}/package.json`)),i=r(t).filter(e=>e.startsWith(`napi-md-compiler.`)&&e.endsWith(`.node`)).sort();for(let n of i){let r=e(s(t,n));if(Wm(r))return r}}catch{return null}return null}try{let n=e(import.meta.url),{platform:r,arch:i}=t,a={"win32-x64":[`napi-md-compiler.win32-x64-msvc`,`win32-x64-msvc`],"linux-x64":[`napi-md-compiler.linux-x64-gnu`,`linux-x64-gnu`],"linux-arm64":[`napi-md-compiler.linux-arm64-gnu`,`linux-arm64-gnu`],"darwin-arm64":[`napi-md-compiler.darwin-arm64`,`darwin-arm64`],"darwin-x64":[`napi-md-compiler.darwin-x64`,`darwin-x64`]}[`${r}-${i}`];if(a!=null){let[e,t]=a;try{Um=n(`../${e}.node`)}catch{Um=Gm(n,t)}}}catch{}function Km(e){return e?.blankLineAfter??!0}function qm(e,t){if(Um!=null&&t==null)return Um.buildFrontMatter(JSON.stringify(e));let n=Object.fromEntries(Object.entries(e).filter(([,e])=>e!=null));return Object.keys(n).length===0?`---
|
|
186
|
+
---`:`---\n${Pm.stringify(n,{singleQuote:t?.singleQuote??!1,lineWidth:t?.lineWidth??0}).trimEnd()}\n---`}function Jm(e,t,n){return e==null||Object.keys(e).length===0?t:`${qm(e,n)}${Km(n)?`
|
|
187
187
|
|
|
188
188
|
`:`
|
|
189
|
-
`}${t}`}function
|
|
190
|
-
---`:`---\n${t}\n---`}function
|
|
189
|
+
`}${t}`}function Ym(e){let t=e.trim();return t.length===0?`---
|
|
190
|
+
---`:`---\n${t}\n---`}function Xm(e,t,n){return`${Ym(e)}${Km(n)?`
|
|
191
191
|
|
|
192
192
|
`:`
|
|
193
|
-
`}${t}`}function
|
|
194
|
-
`))}function Qm(e,t){let r=`@truenine/memory-sync-cli-${t}`;try{let t=e(r).scriptRuntime;if(Xm(t))return t}catch{}let i=o(e.resolve(`${r}/package.json`)),a=n.readdirSync(i).filter(e=>e.startsWith(`napi-script-runtime.`)&&e.endsWith(`.node`)).sort();for(let t of a){let n=e(s(i,t));if(Xm(n))return n}throw Error(`Package "${r}" does not export a scriptRuntime binding or contain a compatible native module`)}function $m(){let t=e(import.meta.url),{local:n,suffix:r}=Ym();try{return t(`./${n}.node`)}catch(e){try{return Qm(t,r)}catch(t){throw Zm(e,t,r)}}}function eh(){if(qm!=null)return qm;if(Jm!=null)throw Jm;try{return qm=$m(),qm}catch(e){throw Jm=e instanceof Error?e:Error(String(e)),Jm}}function th(e,t,n){let r=eh(),i=r.resolve_public_path??r.resolvePublicPath;if(i==null)throw Error(`resolve_public_path native binding is unavailable`);return i(e,t,n)}function nh(){let e=[d(new URL(`./resolve-proxy-worker.mjs`,import.meta.url)),d(new URL(`./script-runtime-worker.mjs`,import.meta.url))];for(let t of e)if(n.existsSync(t))return t;return e[0]}function rh(e,t,n,r=5e3){return th(e,JSON.stringify({...t,workerPath:nh(),timeoutMs:r}),n)}const ih={SRC:`src`,DIST:`dist`,SKILLS:`skills`,COMMANDS:`commands`,AGENTS:`agents`,RULES:`rules`,APP:`app`,IDEA:`.idea`,IDEA_CODE_STYLES:`.idea/codeStyles`,VSCODE:`.vscode`},ah={GLOBAL_MEMORY:`global.mdx`,GLOBAL_MEMORY_SRC:`global.src.mdx`,WORKSPACE_MEMORY:`workspace.mdx`,WORKSPACE_MEMORY_SRC:`workspace.src.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`,CODEIUM_IGNORE:`.codeiumignore`};ih.SKILLS,ih.COMMANDS,ih.AGENTS,ih.RULES,ah.GLOBAL_MEMORY_SRC,ah.WORKSPACE_MEMORY_SRC,ih.SKILLS,ih.COMMANDS,ih.AGENTS,ih.RULES,ah.GLOBAL_MEMORY,ah.WORKSPACE_MEMORY,ih.APP,ih.APP,ih.IDEA,ih.IDEA_CODE_STYLES,ih.VSCODE,ah.EDITOR_CONFIG,ah.IDEA_GITIGNORE,ah.IDEA_PROJECT_XML,ah.IDEA_CODE_STYLE_CONFIG_XML,ah.VSCODE_SETTINGS,ah.VSCODE_EXTENSIONS,ah.QODER_IGNORE,ah.CURSOR_IGNORE,ah.WARP_INDEX_IGNORE,ah.AI_IGNORE,ah.CODEIUM_IGNORE;let oh=function(e){return e.Output=`output`,e}({}),sh=function(e){return e.GlobalMemory=`globalMemory`,e.ProjectRootMemory=`projectRootMemory`,e.ProjectChildrenMemory=`projectChildrenMemory`,e.Command=`command`,e.SubAgent=`subAgent`,e.Skill=`skill`,e.SkillChildDoc=`skillChildDoc`,e.SkillResource=`skillResource`,e.SkillMcpConfig=`skillMcpConfig`,e.Readme=`readme`,e.Rule=`rule`,e}({}),ch=function(e){return e.Relative=`relative`,e.Absolute=`absolute`,e.Root=`root`,e}({}),lh=function(e){return e.VSCode=`vscode`,e.IntellijIDEA=`intellijIdea`,e.Git=`git`,e.EditorConfig=`editorconfig`,e.Original=`original`,e}({}),uh=function(e){return e.UserHome=`userHome`,e.External=`external`,e}({});const dh=`proxy.ts`,fh=`.gitignore`,ph=`.git/info/exclude`,mh=[ah.QODER_IGNORE,ah.CURSOR_IGNORE,ah.WARP_INDEX_IGNORE,ah.AI_IGNORE,ah.CODEIUM_IGNORE,`.kiroignore`,`.traeignore`],hh=[fh,ph,ah.EDITOR_CONFIG,ah.VSCODE_SETTINGS,ah.VSCODE_EXTENSIONS,ah.IDEA_PROJECT_XML,ah.IDEA_CODE_STYLE_CONFIG_XML,ah.IDEA_GITIGNORE,...mh],gh=new Map;function _h(e){let t=e.split(/[\\/]+/).filter(e=>e.length>0).join(`/`);if(t.length===0)throw Error(`public target relative path cannot be empty`);return t}function vh(e){return i.join(e,`public`)}function yh(e){return i.join(vh(e),dh)}function bh(e){return e?.command??`execute`}function xh(e,t){return i.resolve(t?.workspaceDir??i.dirname(e))}function Sh(e,n,r){return{cwd:n,workspaceDir:n,aindexDir:i.resolve(e),command:r,platform:t.platform}}function Ch(e,t,r){let i=_h(t);if(i===dh)return dh;let a=yh(e);if(!(n.existsSync(a)&&n.statSync(a).isFile()))return i;let o=bh(r),s=xh(e,r),c=[a,s,o,i].join(`::`),l=gh.get(c);if(l!=null)return l;let u=rh(a,Sh(e,s,o),i);return gh.set(c,u),u}function wh(e,t,n){let r=Ch(e,t,n);return i.join(vh(e),...r.split(/[\\/]+/))}function Th(e,t){let n=new Set([wh(e,dh)]);for(let r of hh)n.add(wh(e,r,t));return[...n]}function Eh(e,t,n,r,a){let o=wh(n,t,a);if(!(r.existsSync(o)&&r.statSync(o).isFile()))return;let s=r.readFileSync(o,`utf8`);return{type:e,content:s,length:s.length,filePathKind:ch.Absolute,dir:{pathKind:ch.Absolute,path:o,getDirectoryName:()=>i.basename(o)}}}var Dh=class extends Error{operation;violations;constructor(e,t){super(og(e,t)),this.name=`ProtectedDeletionGuardError`,this.operation=e,this.violations=t}};const Oh=[`skills`,`commands`,`subAgents`,`rules`,`app`,`ext`,`arch`],kh=[`globalPrompt`,`workspacePrompt`];function Ah(e){let n=t.env.XDG_CONFIG_HOME;return typeof n==`string`&&n.trim().length>0?n:i.join(e,`.config`)}function jh(e){let n=t.env.XDG_DATA_HOME;return typeof n==`string`&&n.trim().length>0?n:i.join(e,`.local`,`share`)}function Mh(e){let n=t.env.XDG_STATE_HOME;return typeof n==`string`&&n.trim().length>0?n:i.join(e,`.local`,`state`)}function Nh(e){let n=t.env.XDG_CACHE_HOME;return typeof n==`string`&&n.trim().length>0?n:i.join(e,`.cache`)}function Ph(e){if(e!=null){if(typeof e.getAbsolutePath==`function`)try{let t=e.getAbsolutePath();if(t.length>0)return i.resolve(t)}catch{}if(e.pathKind===`absolute`)return i.resolve(e.path);if(typeof e.basePath==`string`&&e.basePath.length>0)return i.resolve(e.basePath,e.path)}}function Fh(e){return e===`~`?c.homedir():e.startsWith(`~/`)||e.startsWith(`~\\`)?i.resolve(c.homedir(),e.slice(2)):e}function Ih(e){return i.resolve(Fh(e))}function Lh(e){let n=i.normalize(Ih(e));return t.platform===`win32`?n.toLowerCase():n}function Rh(e){let{root:t}=i.parse(e);return e===t?e:e.endsWith(i.sep)?e.slice(0,-1):e}function zh(e,t){let n=Rh(e),r=Rh(t);return n===r?!0:n.startsWith(`${r}${i.sep}`)}function Bh(e){let t=Ih(e),r=new Set([Lh(t)]);try{if(n.existsSync(t)){let e=n.realpathSync.native(t);r.add(Lh(e))}}catch{}return[...r]}function Vh(e,t,n,r,i=`path`){return{path:Ih(e),protectionMode:t,reason:n,source:r,matcher:i}}function Hh(e){let t=Lh(e.path);return{...e,path:Ih(e.path),comparisonKeys:Bh(e.path),normalizedPath:t,specificity:Rh(t).length}}function Uh(e){let t=new Map;for(let n of e){let e=Hh(n);t.set(`${e.protectionMode}:${e.normalizedPath}`,e)}return[...t.values()].sort((e,t)=>{let n=t.specificity-e.specificity;return n===0?e.protectionMode===t.protectionMode?e.path.localeCompare(t.path):e.protectionMode===`recursive`?-1:1:n})}function Wh(e){return Ih(e).replaceAll(`\\`,`/`)}function Gh(e){let t=[];for(let n of e){if(n.matcher!==`glob`){t.push(Vh(n.path,n.protectionMode,n.reason,n.source));continue}let e=it.default.sync(Wh(n.path),{onlyFiles:!1,dot:!0,absolute:!0,followSymbolicLinks:!1});for(let r of e)t.push(Vh(r,n.protectionMode,n.reason,n.source))}return t}function Kh(e,t,n){return n===`direct`?zh(t,e):zh(e,t)||zh(t,e)}function qh(e,t){let r=Ih(e);try{if(n.existsSync(r)&&n.lstatSync(r).isDirectory())return`recursive`}catch{}return t}function Jh(){let e=c.homedir();return[Vh(i.parse(e).root,`direct`,`built-in dangerous root path`,`built-in-dangerous-root`),Vh(e,`direct`,`built-in dangerous home directory`,`built-in-dangerous-root`),Vh(Ah(e),`direct`,`built-in dangerous config directory`,`built-in-dangerous-root`),Vh(jh(e),`direct`,`built-in dangerous data directory`,`built-in-dangerous-root`),Vh(Mh(e),`direct`,`built-in dangerous state directory`,`built-in-dangerous-root`),Vh(Nh(e),`direct`,`built-in dangerous cache directory`,`built-in-dangerous-root`),Vh(i.join(e,`.aindex`),`direct`,`built-in global aindex directory`,`built-in-dangerous-root`),Vh(i.join(e,`.aindex`,`.tnmsc.json`),`direct`,`built-in global config file`,`built-in-config`)]}function Yh(e,t,n){let r=[Vh(e,`direct`,`workspace root`,`workspace-reserved`),Vh(i.join(e,`aindex`),`direct`,`reserved workspace aindex root`,`workspace-reserved`),Vh(i.join(e,`knowladge`),`direct`,`reserved workspace knowladge root`,`workspace-reserved`)];for(let e of t)r.push(Vh(e,`direct`,`workspace project root`,`workspace-project-root`));return n&&r.push(Vh(i.join(e,`aindex`,`dist`,`**`,`*.mdx`),`direct`,`reserved workspace aindex dist mdx files`,`workspace-reserved`,`glob`),Vh(i.join(e,`aindex`,`app`,`**`,`*.mdx`),`direct`,`reserved workspace aindex app mdx files`,`workspace-reserved`,`glob`)),r}function Xh(e){return[Vh(e,`direct`,`resolved aindex root`,`aindex-root`)]}function Zh(e,t){return Th(e,t)}function Qh(e,t,n){let r=[];for(let n of Oh)r.push(Vh(i.join(t,e.aindex[n].src),`recursive`,`configured aindex ${n} source directory`,`configured-aindex-source`));for(let n of kh)r.push(Vh(i.join(t,e.aindex[n].src),`direct`,`configured aindex ${n} source file`,`configured-aindex-source`));for(let e of Zh(t,n))r.push(Vh(e,`direct`,`known aindex input config file`,`known-aindex-config`));return r}function $h(e){let t=[],n=new Set,r=(e,r,i,a)=>{if(e==null||e.length===0)return;let o=Vh(e,r,i,a),s=`${o.protectionMode}:${Lh(o.path)}`;n.has(s)||(n.add(s),t.push(o))},i=(e,t,n,i)=>{let a=Ph(e);a!=null&&r(a,t,n,i)};i(e.globalMemory?.dir,`recursive`,`global memory source directory`,`collected-input-source`);for(let t of e.commands??[])i(t.dir,`recursive`,`command source directory`,`collected-input-source`);for(let t of e.subAgents??[])i(t.dir,`recursive`,`sub-agent source directory`,`collected-input-source`);for(let t of e.rules??[])i(t.dir,`recursive`,`rule source directory`,`collected-input-source`);for(let t of e.skills??[]){i(t.dir,`recursive`,`skill source directory`,`collected-input-source`);for(let e of t.childDocs??[])i(e.dir,`recursive`,`skill child document directory`,`collected-input-source`);for(let e of t.resources??[])e.sourcePath==null||e.sourcePath.length===0||r(e.sourcePath,qh(e.sourcePath,`direct`),`skill resource source path`,`collected-input-source`)}for(let t of e.vscodeConfigFiles??[])i(t.dir,`direct`,`vscode input config file`,`collected-input-config`);for(let t of e.jetbrainsConfigFiles??[])i(t.dir,`direct`,`jetbrains input config file`,`collected-input-config`);for(let t of e.editorConfigFiles??[])i(t.dir,`direct`,`editorconfig input file`,`collected-input-config`);for(let t of e.aiAgentIgnoreConfigFiles??[])r(t.sourcePath,`direct`,`AI agent ignore config file`,`collected-input-config`);if(e.aindexDir!=null)for(let t of Zh(e.aindexDir,{workspaceDir:e.workspace.directory.path}))r(t,`direct`,`known aindex input config file`,`known-aindex-config`);return t}function eg(e){let t=[];for(let n of e.exactProtectedPaths??[])t.push(Vh(n,`direct`,`legacy direct protected path`,`legacy-direct`));for(let n of e.subtreeProtectedPaths??[])t.push(Vh(n,`recursive`,`legacy recursive protected path`,`legacy-recursive`));return t}function tg(e={}){let t=e.includeReservedWorkspaceContentRoots??!0,n=Uh(Gh([...Jh(),...eg(e),...e.workspaceDir==null?[]:Yh(e.workspaceDir,e.projectRoots??[],t),...e.aindexDir==null?[]:Xh(e.aindexDir),...e.rules??[]]));return{rules:n.map(e=>({path:e.path,protectionMode:e.protectionMode,reason:e.reason,source:e.source,...e.matcher==null?{}:{matcher:e.matcher}})),exactProtectedPaths:n.filter(e=>e.protectionMode===`direct`).map(e=>e.path),subtreeProtectedPaths:n.filter(e=>e.protectionMode===`recursive`).map(e=>e.path),compiledRules:n}}function ng(e){let t=new Set;for(let n of e.workspace.projects){if(n.isWorkspaceRootProject===!0)continue;let e=n.dirFromWorkspacePath?.getAbsolutePath?.();e!=null&&e.length>0&&t.add(Ih(e))}return[...t]}function rg(e,t){return t==null?e:e.specificity===t.specificity?e.protectionMode===t.protectionMode?e.path.localeCompare(t.path)<0?e:t:e.protectionMode===`recursive`?e:t:e.specificity>t.specificity?e:t}function ig(e,t){let n=Ih(e),r=Bh(n),i;for(let e of t.compiledRules){let t=!1;for(let n of r){for(let r of e.comparisonKeys)if(Kh(n,r,e.protectionMode)){i=rg(e,i),t=!0;break}if(t)break}}if(i!=null)return{targetPath:n,protectedPath:i.path,protectionMode:i.protectionMode,reason:i.reason,source:i.source}}function ag(e,t){let n=[],r=new Map;for(let i of e){let e=Ih(i),a=ig(e,t);if(a==null){n.push(e);continue}r.has(a.targetPath)||r.set(a.targetPath,a)}return{safePaths:n,violations:[...r.values()].sort((e,t)=>e.targetPath.localeCompare(t.targetPath))}}function og(e,t){let n=t.map(e=>e.targetPath).join(`, `);return`Protected deletion guard blocked ${e} for ${t.length} path(s): ${n}`}function sg(e,t,n){e.error(ht(t,n))}var cg=class{inputEffects=[];registeredScopes=[];name;dependsOn;_log;get log(){return this._log??=Ut(this.name),this._log}constructor(e,t){this.name=e,t!=null&&(this.dependsOn=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,aindexDir: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,aindexDir: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 throw t.error??Error(`Input effect failed: ${e.name}`);n.push(t)}catch(t){let r=t instanceof Error?t:Error(String(t));throw this.logInputEffectFailure(e.name,r),n.push({success:!1,error:r,description:`Input effect failed: ${e.name}`}),r}}return n}logInputEffectFailure(e,t){if(t instanceof Dh){sg(this.log,t.operation,t.violations);return}this.log.error(st({code:`INPUT_EFFECT_FAILED`,title:`Input effect failed: ${e}`,rootCause:z(`The input effect "${e}" failed before tnmsc could finish preprocessing.`,`Underlying error: ${t.message}`),exactFix:z(`Inspect the effect inputs and fix the failing file, path, or environment condition before retrying tnmsc.`),possibleFixes:[z(`Re-run the command after fixing the referenced path or generated artifact.`),z(`Add a focused regression test if this effect should handle the failure more gracefully.`)],details:{effectName:e,errorMessage:t.message}}))}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.aindex?.dir??`aindex`;return{workspaceDir:n,aindexDir:i.join(n,r)}}resolvePath(e,t){let n=e;return n.startsWith(jy.USER_HOME)&&(n=n.replace(jy.USER_HOME,c.homedir())),n.includes(jy.WORKSPACE)&&(n=n.replace(jy.WORKSPACE,t)),i.normalize(n)}resolveAindexPath(e,t){return i.join(t,e)}readAndParseMarkdown(e,t){return Wm(t.readFileSync(e,`utf8`))}};function lg(e={}){let{filePath:t,position:n,sourceText:r,expression:i,exportName:a,nodeType:o,phase:s,hint:c,cause:l}=e,u=n?.start.line,d=n?.start.column,f=n?.end?.line,p=n?.end?.column,m=n?.start.offset,h=n?.end?.offset,g=u!=null&&r!=null?ug(r,u):void 0,_=dg(r,m,h,g),v=u!=null&&d!=null&&g!=null?fg(u,d,p,g):void 0,y={};return t!=null&&t.length>0&&Object.assign(y,{filePath:t}),u!=null&&Object.assign(y,{line:u}),d!=null&&Object.assign(y,{column:d}),f!=null&&Object.assign(y,{endLine:f}),p!=null&&Object.assign(y,{endColumn:p}),m!=null&&Object.assign(y,{offset:m}),h!=null&&Object.assign(y,{endOffset:h}),_!=null&&_.length>0&&Object.assign(y,{snippet:_}),g!=null&&g.length>0&&Object.assign(y,{sourceLine:g}),v!=null&&v.length>0&&Object.assign(y,{codeFrame:v}),i!=null&&i.length>0&&Object.assign(y,{expression:i}),a!=null&&a.length>0&&Object.assign(y,{exportName:a}),o!=null&&o.length>0&&Object.assign(y,{nodeType:o}),s!=null&&s.length>0&&Object.assign(y,{phase:s}),c!=null&&c.length>0&&Object.assign(y,{hint:c}),l!=null&&l.length>0&&Object.assign(y,{cause:l}),y}function ug(e,t){return e.split(/\r?\n/u)[t-1]}function dg(e,t,n,r){if(e!=null&&t!=null){let r=n!=null&&n>=t?n:t+1,i=e.slice(t,r).trim();if(i.length>0)return i.length>240?`${i.slice(0,240)}...`:i}let i=r?.trim();if(i!=null&&i.length>0)return i}function fg(e,t,n,r){let i=`${e} | `,a=` `.repeat(i.length+Math.max(0,t-1)),o=Math.max(1,(n??t+1)-t);return`${i}${r}\n${a}${`^`.repeat(o)}`}function pg(e){if(!(e.line==null||e.column==null))return e.endLine!=null&&e.endColumn!=null?`${e.line}:${e.column}-${e.endLine}:${e.endColumn}`:`${e.line}:${e.column}`}function mg(e,t){let n=[e];t.phase!=null&&n.push(`phase: ${t.phase}`),t.nodeType!=null&&n.push(`node: ${t.nodeType}`),t.filePath!=null&&n.push(`file: ${t.filePath}`);let r=pg(t);return r!=null&&n.push(`location: ${r}`),t.expression!=null&&n.push(`expression: ${t.expression}`),t.exportName!=null&&n.push(`export: ${t.exportName}`),t.sourceLine!=null&&n.push(`source line: ${t.sourceLine.trimEnd()}`),t.codeFrame!=null&&(n.push(`code frame:`),n.push(t.codeFrame)),t.hint!=null&&n.push(`hint: ${t.hint}`),t.cause!=null&&n.push(`cause: ${t.cause}`),n.join(`
|
|
195
|
-
`)}function
|
|
196
|
-
`))}}function Ag(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 jg(e,t){return e===null?!1:t.components.has(e)||Tg(e)}async function Mg(e){return async(t,n)=>(await e({type:`root`,children:t},n)).children}async function Ng(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 Mg(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 Pg(e,t,n){return{...e.filePath!=null&&{filePath:e.filePath},...e.sourceText!=null&&{sourceText:e.sourceText},...n?.position!=null&&{position:n.position},nodeType:t}}function Fg(e,t){let n=e.name?.toLowerCase();if(n==null)return null;switch(n){case`pre`:return Rg(e,t);case`a`:return zg(e,t);case`strong`:case`b`:return Bg(e,t);case`em`:case`i`:return Vg(e,t);case`img`:return Hg(e,t);case`blockquote`:return Ug(e,t);default:return null}}function Ig(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`?Eg(r.value.value,n.scope,Pg(n,`mdxJsxAttributeValueExpression`,r)):r.value===null?``:null}function Lg(e,t){let n=``;for(let r of e.children){if(r.type===`text`){n+=r.value;continue}if(r.type===`mdxTextExpression`){n+=Eg(r.value,t.scope,Pg(t,`mdxTextExpression`,r));continue}(r.type===`mdxJsxFlowElement`||r.type===`mdxJsxTextElement`)&&(n+=Lg(r,t))}return n}function Rg(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=Ig(n,`className`,t)??``,i=/language-(\w+)/.exec(r)?.[1],a=Lg(n,t);return[{type:`code`,lang:i??null,value:a.trim()}]}function zg(e,t){let n=Ig(e,`href`,t);if(n==null||n===``)return null;let r=Lg(e,t);return[{type:`paragraph`,children:[{type:`link`,url:n,title:Ig(e,`title`,t)??null,children:[{type:`text`,value:r}]}]}]}function Bg(e,t){let n={type:`strong`,children:[{type:`text`,value:Lg(e,t)}]};return e.type,[{type:`paragraph`,children:[n]}]}function Vg(e,t){let n={type:`emphasis`,children:[{type:`text`,value:Lg(e,t)}]};return e.type,[{type:`paragraph`,children:[n]}]}function Hg(e,t){let n=Ig(e,`src`,t);if(n==null||n===``)return null;let r={type:`image`,url:n,alt:Ig(e,`alt`,t)??``,title:Ig(e,`title`,t)??null};return e.type,[{type:`paragraph`,children:[r]}]}function Ug(e,t){return[{type:`blockquote`,children:[{type:`paragraph`,children:[{type:`text`,value:Lg(e,t)}]}]}]}function Wg(e,t){return{...e.filePath!=null&&{filePath:e.filePath},...e.sourceText!=null&&{sourceText:e.sourceText},...t.position!=null&&{position:t.position},nodeType:t.type}}function Gg(e){return e==null?!1:JSON.stringify(e).includes(`"JSX`)}async function Kg(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`?qg(i.expression,t,n,e):[]}async function qg(e,t,n,r){return e.type===`JSXElement`?$g(e,t,n,r):e.type===`JSXFragment`?e_(e,t,n,r):e.type===`LogicalExpression`?Jg(e,t,n,r):e.type===`ConditionalExpression`?Yg(e,t,n,r):e.type===`SequenceExpression`?Xg(e,t,n,r):e.type===`ArrayExpression`?Zg(e,t,n,r):l_(e,t,r)}async function Jg(e,t,n,r){let i=await Qg(e.left,t,n,r);return e.operator===`&&`?s_(i)?qg(e.right,t,n,r):[]:e.operator===`||`?s_(i)?o_(e.left)?qg(e.left,t,n,r):c_(i):qg(e.right,t,n,r):e.operator===`??`?i==null?qg(e.right,t,n,r):o_(e.left)?qg(e.left,t,n,r):c_(i):[]}async function Yg(e,t,n,r){return s_(await Qg(e.test,t,n,r))?qg(e.consequent,t,n,r):qg(e.alternate,t,n,r)}async function Xg(e,t,n,r){let i=[];for(let a of e.expressions){let e=await qg(a,t,n,r);i.push(...e)}return i}async function Zg(e,t,n,r){let i=[];for(let a of e.elements)if(a!=null)if(a.type===`SpreadElement`){let e=await qg(a.argument,t,n,r);i.push(...e)}else{let e=await qg(a,t,n,r);i.push(...e)}return i}async function Qg(e,t,n,r){if(o_(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 i=await Qg(e.argument,t,n,r);return e.operator===`!`?!s_(i):e.operator===`-`?-i:e.operator===`+`?+i:e.operator===`typeof`?typeof i:void 0}if(e.type===`BinaryExpression`){let i=await Qg(e.left,t,n,r),a=await Qg(e.right,t,n,r);return e.operator===`===`?i===a:e.operator===`!==`?i!==a:e.operator===`==`?i===a:e.operator===`!=`?i!==a:e.operator===`<`?i<a:e.operator===`<=`?i<=a:e.operator===`>`?i>a:e.operator===`>=`?i>=a:e.operator===`+`?i+a:e.operator===`-`?i-a:e.operator===`*`?i*a:e.operator===`/`?i/a:e.operator===`%`?i%a:void 0}if(e.type===`LogicalExpression`){let i=await Qg(e.left,t,n,r);return e.operator===`&&`?s_(i)?Qg(e.right,t,n,r):i:e.operator===`||`?s_(i)?i:Qg(e.right,t,n,r):e.operator===`??`?i??Qg(e.right,t,n,r):void 0}if(e.type===`MemberExpression`){let i=await Qg(e.object,t,n,r);if(i==null)return;if(e.computed)return i[await Qg(e.property,t,n,r)];let{name:a}=e.property;return i[a]}if(e.type===`ConditionalExpression`)return s_(await Qg(e.test,t,n,r))?Qg(e.consequent,t,n,r):Qg(e.alternate,t,n,r);let i=a_(e);if(i!==``)try{let e=Eg(i,t.scope,Wg(t,r));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 $g(e,t,n,r){let i=n_(e,t);if(i.name!=null&&jg(i.name,t)){let{processAst:e}=await Promise.resolve().then(()=>u_);return Ng(i,t,e)}return Fg(i,t)??(i.children.length>0?n(i.children,t):[])}async function e_(e,t,n,r){let i=[];for(let a of e.children){let e=await t_(a,t,n,r);i.push(...e)}return i}async function t_(e,t,n,r){if(e.type===`JSXElement`)return $g(e,t,n,r);if(e.type===`JSXFragment`)return e_(e,t,n,r);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`?[]:qg(e.expression,t,n,r):e.type===`JSXSpreadChild`?qg(e.expression,t,n,r):[]}function n_(e,t){let n=e.openingElement,r=null;n.name.type===`JSXIdentifier`?{name:r}=n.name:n.name.type===`JSXMemberExpression`?r=r_(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:a_(e.value.expression)}),i.push({type:`mdxJsxAttribute`,name:t,value:n})}else e.type===`JSXSpreadAttribute`&&i.push({type:`mdxJsxExpressionAttribute`,value:`...${a_(e.argument)}`});let a=[];for(let n of e.children){let e=i_(n,t);e!=null&&a.push(...e)}return{type:`mdxJsxFlowElement`,name:r,attributes:i,children:a}}function r_(e){return e.object.type===`JSXIdentifier`?`${e.object.name}.${e.property.name}`:`${r_(e.object)}.${e.property.name}`}function i_(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[n_(e,t)];if(e.type===`JSXFragment`){let n=[];for(let r of e.children){let e=i_(r,t);e!=null&&n.push(...e)}return n}return e.type===`JSXExpressionContainer`?e.expression.type===`JSXEmptyExpression`?null:[{type:`paragraph`,children:[{type:`text`,value:a_(e.expression)}]}]:e.type===`JSXSpreadChild`?[{type:`paragraph`,children:[{type:`text`,value:`...${a_(e.expression)}`}]}]:null}function a_(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=a_(e.object);return e.computed?`${t}[${a_(e.property)}]`:`${t}.${e.property.name}`}if(e.type===`CallExpression`)return`${a_(e.callee)}(${e.arguments.map(e=>a_(e)).join(`, `)})`;if(e.type===`BinaryExpression`||e.type===`LogicalExpression`){let t=a_(e.left),n=a_(e.right);return`(${t} ${e.operator} ${n})`}if(e.type===`UnaryExpression`){let t=a_(e.argument);return`${e.operator}${t}`}if(e.type===`ConditionalExpression`)return`(${a_(e.test)} ? ${a_(e.consequent)} : ${a_(e.alternate)})`;if(e.type===`ArrayExpression`)return`[${e.elements.filter(e=>e!=null&&e.type!==`SpreadElement`).map(e=>a_(e)).join(`, `)}]`;if(e.type===`ObjectExpression`)return`{${e.properties.filter(e=>e.type===`Property`).map(e=>`${e.key.type===`Identifier`?e.key.name:a_(e.key)}: ${a_(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+=`\${${a_(e.expressions[n])}}`);return t+="`",t}return e.type===`SpreadElement`?`...${a_(e.argument)}`:``}function o_(e){return e.type===`JSXElement`||e.type===`JSXFragment`}function s_(e){return!!e}function c_(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 l_(e,t,n){let r=a_(e);if(r===``)return[];try{return c_(Eg(r,t.scope,Wg(t,n)))}catch{return[]}}var u_=Xt({processAst:()=>p_});function d_(e,t,n){return{...e.filePath!=null&&{filePath:e.filePath},...e.sourceText!=null&&{sourceText:e.sourceText},...t.position!=null&&{position:t.position},nodeType:n}}function f_(e){if(!(e.includes(`/`)&&/\.\w+$/.test(e)))return e;let t=e.lastIndexOf(`/`);return e.slice(t+1)}async function p_(e,t){return m_(e,t)}async function m_(e,t){let n=[];for(let r of e.children){let e=await h_(r,t);n.push(...e)}return{type:`root`,children:n}}async function h_(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(Gg(r))return Kg(n,t,async(e,t)=>(await p_({type:`root`,children:e},t)).children);let a=Eg(n.value,t.scope,d_(t,n,`mdxFlowExpression`));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 __(n.children,t)).map(e=>e.type===`text`?{...e,value:f_(e.value)}:e);return[{...n,children:r}]}if(!(`children`in e&&Array.isArray(e.children)))return[e];let n=await __(e.children,t);return[{...e,children:n}]}async function g_(e,t){return e.name!=null&&jg(e.name,t)?Ng(e,t,p_):Fg(e,t)??[]}async function __(e,t){let n=[];for(let r of e){if(r.type===`mdxFlowExpression`){let e=r,i=e.data?.estree,a=e.value.trim();if(a.startsWith(`/*`)&&a.endsWith(`*/`))continue;if(Gg(i)){let r=await Kg(e,t,async(e,t)=>(await p_({type:`root`,children:e},t)).children);for(let e of r)n.push(e);continue}let o=Eg(e.value,t.scope,d_(t,e,`mdxFlowExpression`));o!==``&&n.push({type:`paragraph`,children:[{type:`text`,value:o}]});continue}if(r.type===`mdxTextExpression`){let e=r,i=e.value.trim();if(i.startsWith(`/*`)&&i.endsWith(`*/`))continue;let a={type:`text`,value:Eg(e.value,t.scope,d_(t,e,`mdxTextExpression`))};n.push(a);continue}if(r.type===`mdxJsxTextElement`){let e=r;if(e.name!=null&&jg(e.name,t)){let r=await Ng(e,t,p_);for(let e of r)e.type===`paragraph`&&`children`in e?n.push(...e.children):n.push(e);continue}let i=Fg(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 __(r.children,t);if(r.type===`link`){let t=e.map(e=>e.type===`text`?{...e,value:f_(e.value)}:e);n.push({...r,children:t});continue}n.push({...r,children:e});continue}n.push(r)}return n}function v_(e,t={}){let n={},{yamlFrontMatter:r,scope:i,filePath:a,sourceText:o}=t;for(let t of e){let e=y_(t,i,{...a!=null&&{filePath:a},...o!=null&&{sourceText:o}});Object.assign(n,e)}let s=Object.keys(n).length>0,c=r!=null&&Object.keys(r).length>0,l;return l=s&&c?`mixed`:s?`export`:`yaml`,{fields:{...r,...n},source:l}}function y_(e,t,n={}){let r={},{filePath:i,sourceText:a}=n,o=e.value.trim(),s=/^export\s+default\s+/.exec(o);if(s!=null){let n=s[0].length,c=b_(o,n);if(c!=null)try{let e=x_(c.trim(),t,i);typeof e==`object`&&e&&!Array.isArray(e)&&Object.assign(r,e)}catch(t){let n=t instanceof Error?t.message:String(t);throw new xg(`Cannot statically evaluate export default`,`default`,{...i!=null&&{filePath:i},...a!=null&&{sourceText:a},...e.position!=null&&{position:e.position},nodeType:`mdxjsEsm`,phase:`export-parsing`,cause:n})}return r}let c=/export\s+const\s+(\w+)\s*=\s*/g,l=c.exec(o);for(;l!==null;){let n=l[1];if(n==null){l=c.exec(o);continue}let s=b_(o,l.index+l[0].length);if(s==null){l=c.exec(o);continue}try{let e=x_(s.trim(),t,i);n===`metadata`&&typeof e==`object`&&e&&!Array.isArray(e)?Object.assign(r,e):r[n]=e}catch(t){let r=t instanceof Error?t.message:String(t);throw new xg(`Cannot statically evaluate export "${n}"`,n,{...i!=null&&{filePath:i},...a!=null&&{sourceText:a},...e.position!=null&&{position:e.position},nodeType:`mdxjsEsm`,phase:`export-parsing`,cause:r})}l=c.exec(o)}return r}function b_(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===`
|
|
197
|
-
`){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
|
|
198
|
-
`).replaceAll(`\\r`,`\r`).replaceAll(`\\t`,` `).replaceAll(`\\"`,`"`).replaceAll(`\\'`,`'`).replaceAll(`\\\\`,`\\`)}function
|
|
199
|
-
`,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`,`codeFencedMetaGraveAccent`,`codeFencedMetaTilde`,`destinationLiteral`,`headingAtx`]},{character:` `,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,before:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`]},{character:`!`,after:`\\[`,inConstruct:`phrasing`,notInConstruct:
|
|
200
|
-
]|$)`},{character:`&`,after:`[#A-Za-z]`,inConstruct:`phrasing`},{character:`'`,inConstruct:`titleApostrophe`},{character:`(`,inConstruct:`destinationRaw`},{before:`\\]`,character:`(`,inConstruct:`phrasing`,notInConstruct:
|
|
201
|
-
*])`},{character:`*`,inConstruct:`phrasing`,notInConstruct:
|
|
193
|
+
`}${t}`}function Zm(e){let t=new Pm.Scalar(e);return t.type=Pm.Scalar.QUOTE_DOUBLE,t}function Qm(e){let t=hp(e),n,r,i=[];for(let e of t.children)if(e.type===`yaml`){r=e.value;try{n=Pm.parse(e.value??``)}catch{}}else i.push(e);let a=e;return r!=null&&(a=e.replace(Fm,``)),{...n!=null&&{yamlFrontMatter:n},...r!=null&&{rawFrontMatter:r},markdownAst:t,markdownContents:i,contentWithoutFrontMatter:a}}function $m(e){return Um==null?e.replaceAll(Im,(e,t,n,r,i,a)=>{let o=n.replace(Lm,`.md`).replaceAll(Rm,`.md`);return zm.test(i)?`${t}${o}${r}${i}${a}`:`${t}${o}${r}${i.replace(Bm,`.md`).replace(Vm,`.md#`).replace(Hm,`.md?`)}${a}`}):Um.transformMdxReferencesToMd(e)}const eh={"win32-x64":{local:`napi-script-runtime.win32-x64-msvc`,suffix:`win32-x64-msvc`},"linux-x64":{local:`napi-script-runtime.linux-x64-gnu`,suffix:`linux-x64-gnu`},"linux-arm64":{local:`napi-script-runtime.linux-arm64-gnu`,suffix:`linux-arm64-gnu`},"darwin-arm64":{local:`napi-script-runtime.darwin-arm64`,suffix:`darwin-arm64`},"darwin-x64":{local:`napi-script-runtime.darwin-x64`,suffix:`darwin-x64`}};let th,nh;function rh(){let e=eh[`${t.platform}-${t.arch}`];if(e!=null)return e;throw Error(`Unsupported platform for @truenine/script-runtime native binding: ${t.platform}-${t.arch}`)}function ih(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.validate_public_path==`function`||typeof t.validatePublicPath==`function`||typeof t.resolve_public_path==`function`||typeof t.resolvePublicPath==`function`}function ah(e,n,r){let i=e instanceof Error?e.message:String(e),a=n instanceof Error?n.message:String(n);return Error([`Failed to load @truenine/script-runtime native binding.`,`Tried local binary "./${eh[`${t.platform}-${t.arch}`]?.local??`unknown`}.node" and package "@truenine/memory-sync-cli-${r}".`,`Local error: ${i}`,`Package error: ${a}`,"Run `pnpm -F @truenine/script-runtime run build` to build the native module."].join(`
|
|
194
|
+
`))}function oh(e,t){let r=`@truenine/memory-sync-cli-${t}`;try{let t=e(r).scriptRuntime;if(ih(t))return t}catch{}let i=o(e.resolve(`${r}/package.json`)),a=n.readdirSync(i).filter(e=>e.startsWith(`napi-script-runtime.`)&&e.endsWith(`.node`)).sort();for(let t of a){let n=e(s(i,t));if(ih(n))return n}throw Error(`Package "${r}" does not export a scriptRuntime binding or contain a compatible native module`)}function sh(){let t=e(import.meta.url),{local:n,suffix:r}=rh();try{return t(`./${n}.node`)}catch(e){try{return oh(t,r)}catch(t){throw ah(e,t,r)}}}function ch(){if(th!=null)return th;if(nh!=null)throw nh;try{return th=sh(),th}catch(e){throw nh=e instanceof Error?e:Error(String(e)),nh}}function lh(e,t,n){let r=ch(),i=r.resolve_public_path??r.resolvePublicPath;if(i==null)throw Error(`resolve_public_path native binding is unavailable`);return i(e,t,n)}function uh(){let e=[d(new URL(`./resolve-proxy-worker.mjs`,import.meta.url)),d(new URL(`./script-runtime-worker.mjs`,import.meta.url))];for(let t of e)if(n.existsSync(t))return t;return e[0]}function dh(e,t,n,r=5e3){return lh(e,JSON.stringify({...t,workerPath:uh(),timeoutMs:r}),n)}const fh={SRC:`src`,DIST:`dist`,SKILLS:`skills`,COMMANDS:`commands`,AGENTS:`agents`,RULES:`rules`,APP:`app`,IDEA:`.idea`,IDEA_CODE_STYLES:`.idea/codeStyles`,VSCODE:`.vscode`},ph={GLOBAL_MEMORY:`global.mdx`,GLOBAL_MEMORY_SRC:`global.src.mdx`,WORKSPACE_MEMORY:`workspace.mdx`,WORKSPACE_MEMORY_SRC:`workspace.src.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`,CODEIUM_IGNORE:`.codeiumignore`};fh.SKILLS,fh.COMMANDS,fh.AGENTS,fh.RULES,ph.GLOBAL_MEMORY_SRC,ph.WORKSPACE_MEMORY_SRC,fh.SKILLS,fh.COMMANDS,fh.AGENTS,fh.RULES,ph.GLOBAL_MEMORY,ph.WORKSPACE_MEMORY,fh.APP,fh.APP,fh.IDEA,fh.IDEA_CODE_STYLES,fh.VSCODE,ph.EDITOR_CONFIG,ph.IDEA_GITIGNORE,ph.IDEA_PROJECT_XML,ph.IDEA_CODE_STYLE_CONFIG_XML,ph.VSCODE_SETTINGS,ph.VSCODE_EXTENSIONS,ph.QODER_IGNORE,ph.CURSOR_IGNORE,ph.WARP_INDEX_IGNORE,ph.AI_IGNORE,ph.CODEIUM_IGNORE;let mh=function(e){return e.Output=`output`,e}({}),hh=function(e){return e.GlobalMemory=`globalMemory`,e.ProjectRootMemory=`projectRootMemory`,e.ProjectChildrenMemory=`projectChildrenMemory`,e.Command=`command`,e.SubAgent=`subAgent`,e.Skill=`skill`,e.SkillChildDoc=`skillChildDoc`,e.SkillResource=`skillResource`,e.SkillMcpConfig=`skillMcpConfig`,e.Readme=`readme`,e.Rule=`rule`,e}({}),gh=function(e){return e.Relative=`relative`,e.Absolute=`absolute`,e.Root=`root`,e}({}),_h=function(e){return e.VSCode=`vscode`,e.IntellijIDEA=`intellijIdea`,e.Git=`git`,e.EditorConfig=`editorconfig`,e.Original=`original`,e}({}),vh=function(e){return e.UserHome=`userHome`,e.External=`external`,e}({});const yh=`proxy.ts`,bh=`.gitignore`,xh=`.git/info/exclude`,Sh=[ph.QODER_IGNORE,ph.CURSOR_IGNORE,ph.WARP_INDEX_IGNORE,ph.AI_IGNORE,ph.CODEIUM_IGNORE,`.kiroignore`,`.traeignore`],Ch=[bh,xh,ph.EDITOR_CONFIG,ph.VSCODE_SETTINGS,ph.VSCODE_EXTENSIONS,ph.IDEA_PROJECT_XML,ph.IDEA_CODE_STYLE_CONFIG_XML,ph.IDEA_GITIGNORE,...Sh],wh=new Map;function Th(e){let t=e.split(/[\\/]+/).filter(e=>e.length>0).join(`/`);if(t.length===0)throw Error(`public target relative path cannot be empty`);return t}function Eh(e){return i.join(e,`public`)}function Dh(e){return i.join(Eh(e),yh)}function Oh(e){return e?.command??`execute`}function kh(e,t){return i.resolve(t?.workspaceDir??i.dirname(e))}function Ah(e,n,r){return{cwd:n,workspaceDir:n,aindexDir:i.resolve(e),command:r,platform:t.platform}}function jh(e,t,r){let i=Th(t);if(i===`proxy.ts`)return yh;let a=Dh(e);if(!(n.existsSync(a)&&n.statSync(a).isFile()))return i;let o=Oh(r),s=kh(e,r),c=[a,s,o,i].join(`::`),l=wh.get(c);if(l!=null)return l;let u=dh(a,Ah(e,s,o),i);return wh.set(c,u),u}function Mh(e,t,n){let r=jh(e,t,n);return i.join(Eh(e),...r.split(/[\\/]+/))}function Nh(e,t){let n=new Set([Mh(e,yh)]);for(let r of Ch)n.add(Mh(e,r,t));return[...n]}function Ph(e,t,n,r,a){let o=Mh(n,t,a);if(!(r.existsSync(o)&&r.statSync(o).isFile()))return;let s=r.readFileSync(o,`utf8`);return{type:e,content:s,length:s.length,filePathKind:gh.Absolute,dir:{pathKind:gh.Absolute,path:o,getDirectoryName:()=>i.basename(o)}}}var Fh=class extends Error{operation;violations;constructor(e,t){super(mg(e,t)),this.name=`ProtectedDeletionGuardError`,this.operation=e,this.violations=t}};const Ih=[`skills`,`commands`,`subAgents`,`rules`,`app`,`ext`,`arch`],Lh=[`globalPrompt`,`workspacePrompt`];function Rh(e){let n=t.env.XDG_CONFIG_HOME;return typeof n==`string`&&n.trim().length>0?n:i.join(e,`.config`)}function zh(e){let n=t.env.XDG_DATA_HOME;return typeof n==`string`&&n.trim().length>0?n:i.join(e,`.local`,`share`)}function Bh(e){let n=t.env.XDG_STATE_HOME;return typeof n==`string`&&n.trim().length>0?n:i.join(e,`.local`,`state`)}function Vh(e){let n=t.env.XDG_CACHE_HOME;return typeof n==`string`&&n.trim().length>0?n:i.join(e,`.cache`)}function Hh(e){if(e!=null){if(typeof e.getAbsolutePath==`function`)try{let t=e.getAbsolutePath();if(t.length>0)return i.resolve(t)}catch{}if(e.pathKind===`absolute`)return i.resolve(e.path);if(typeof e.basePath==`string`&&e.basePath.length>0)return i.resolve(e.basePath,e.path)}}function Uh(e){return e===`~`?c.homedir():e.startsWith(`~/`)||e.startsWith(`~\\`)?i.resolve(c.homedir(),e.slice(2)):e}function Wh(e){return i.resolve(Uh(e))}function Gh(e){let n=i.normalize(Wh(e));return t.platform===`win32`?n.toLowerCase():n}function Kh(e){let{root:t}=i.parse(e);return e===t?e:e.endsWith(i.sep)?e.slice(0,-1):e}function qh(e,t){let n=Kh(e),r=Kh(t);return n===r?!0:n.startsWith(`${r}${i.sep}`)}function Jh(e){let t=Wh(e),r=new Set([Gh(t)]);try{if(n.existsSync(t)){let e=n.realpathSync.native(t);r.add(Gh(e))}}catch{}return[...r]}function Yh(e,t,n,r,i=`path`){return{path:Wh(e),protectionMode:t,reason:n,source:r,matcher:i}}function Xh(e){let t=Gh(e.path);return{...e,path:Wh(e.path),comparisonKeys:Jh(e.path),normalizedPath:t,specificity:Kh(t).length}}function Zh(e){let t=new Map;for(let n of e){let e=Xh(n);t.set(`${e.protectionMode}:${e.normalizedPath}`,e)}return[...t.values()].sort((e,t)=>{let n=t.specificity-e.specificity;return n===0?e.protectionMode===t.protectionMode?e.path.localeCompare(t.path):e.protectionMode===`recursive`?-1:1:n})}function Qh(e){return Wh(e).replaceAll(`\\`,`/`)}function $h(e){let t=[];for(let n of e){if(n.matcher!==`glob`){t.push(Yh(n.path,n.protectionMode,n.reason,n.source));continue}let e=it.default.sync(Qh(n.path),{onlyFiles:!1,dot:!0,absolute:!0,followSymbolicLinks:!1});for(let r of e)t.push(Yh(r,n.protectionMode,n.reason,n.source))}return t}function eg(e,t,n){return n===`direct`?qh(t,e):qh(e,t)||qh(t,e)}function tg(e,t){let r=Wh(e);try{if(n.existsSync(r)&&n.lstatSync(r).isDirectory())return`recursive`}catch{}return t}function ng(){let e=c.homedir();return[Yh(i.parse(e).root,`direct`,`built-in dangerous root path`,`built-in-dangerous-root`),Yh(e,`direct`,`built-in dangerous home directory`,`built-in-dangerous-root`),Yh(Rh(e),`direct`,`built-in dangerous config directory`,`built-in-dangerous-root`),Yh(zh(e),`direct`,`built-in dangerous data directory`,`built-in-dangerous-root`),Yh(Bh(e),`direct`,`built-in dangerous state directory`,`built-in-dangerous-root`),Yh(Vh(e),`direct`,`built-in dangerous cache directory`,`built-in-dangerous-root`),Yh(i.join(e,`.aindex`),`direct`,`built-in global aindex directory`,`built-in-dangerous-root`),Yh(i.join(e,`.aindex`,`.tnmsc.json`),`direct`,`built-in global config file`,`built-in-config`)]}function rg(e,t,n){let r=[Yh(e,`direct`,`workspace root`,`workspace-reserved`),Yh(i.join(e,`aindex`),`direct`,`reserved workspace aindex root`,`workspace-reserved`),Yh(i.join(e,`knowladge`),`direct`,`reserved workspace knowladge root`,`workspace-reserved`)];for(let e of t)r.push(Yh(e,`direct`,`workspace project root`,`workspace-project-root`));return n&&r.push(Yh(i.join(e,`aindex`,`dist`,`**`,`*.mdx`),`direct`,`reserved workspace aindex dist mdx files`,`workspace-reserved`,`glob`),Yh(i.join(e,`aindex`,`app`,`**`,`*.mdx`),`direct`,`reserved workspace aindex app mdx files`,`workspace-reserved`,`glob`)),r}function ig(e){return[Yh(e,`direct`,`resolved aindex root`,`aindex-root`)]}function ag(e,t){return Nh(e,t)}function og(e,t,n){let r=[];for(let n of Ih)r.push(Yh(i.join(t,e.aindex[n].src),`recursive`,`configured aindex ${n} source directory`,`configured-aindex-source`));for(let n of Lh)r.push(Yh(i.join(t,e.aindex[n].src),`direct`,`configured aindex ${n} source file`,`configured-aindex-source`));for(let e of ag(t,n))r.push(Yh(e,`direct`,`known aindex input config file`,`known-aindex-config`));return r}function sg(e){let t=[],n=new Set,r=(e,r,i,a)=>{if(e==null||e.length===0)return;let o=Yh(e,r,i,a),s=`${o.protectionMode}:${Gh(o.path)}`;n.has(s)||(n.add(s),t.push(o))},i=(e,t,n,i)=>{let a=Hh(e);a!=null&&r(a,t,n,i)};i(e.globalMemory?.dir,`recursive`,`global memory source directory`,`collected-input-source`);for(let t of e.commands??[])i(t.dir,`recursive`,`command source directory`,`collected-input-source`);for(let t of e.subAgents??[])i(t.dir,`recursive`,`sub-agent source directory`,`collected-input-source`);for(let t of e.rules??[])i(t.dir,`recursive`,`rule source directory`,`collected-input-source`);for(let t of e.skills??[]){i(t.dir,`recursive`,`skill source directory`,`collected-input-source`);for(let e of t.childDocs??[])i(e.dir,`recursive`,`skill child document directory`,`collected-input-source`);for(let e of t.resources??[])e.sourcePath==null||e.sourcePath.length===0||r(e.sourcePath,tg(e.sourcePath,`direct`),`skill resource source path`,`collected-input-source`)}for(let t of e.vscodeConfigFiles??[])i(t.dir,`direct`,`vscode input config file`,`collected-input-config`);for(let t of e.jetbrainsConfigFiles??[])i(t.dir,`direct`,`jetbrains input config file`,`collected-input-config`);for(let t of e.editorConfigFiles??[])i(t.dir,`direct`,`editorconfig input file`,`collected-input-config`);for(let t of e.aiAgentIgnoreConfigFiles??[])r(t.sourcePath,`direct`,`AI agent ignore config file`,`collected-input-config`);if(e.aindexDir!=null)for(let t of ag(e.aindexDir,{workspaceDir:e.workspace.directory.path}))r(t,`direct`,`known aindex input config file`,`known-aindex-config`);return t}function cg(e){let t=[];for(let n of e.exactProtectedPaths??[])t.push(Yh(n,`direct`,`legacy direct protected path`,`legacy-direct`));for(let n of e.subtreeProtectedPaths??[])t.push(Yh(n,`recursive`,`legacy recursive protected path`,`legacy-recursive`));return t}function lg(e={}){let t=e.includeReservedWorkspaceContentRoots??!0,n=Zh($h([...ng(),...cg(e),...e.workspaceDir==null?[]:rg(e.workspaceDir,e.projectRoots??[],t),...e.aindexDir==null?[]:ig(e.aindexDir),...e.rules??[]]));return{rules:n.map(e=>({path:e.path,protectionMode:e.protectionMode,reason:e.reason,source:e.source,...e.matcher==null?{}:{matcher:e.matcher}})),exactProtectedPaths:n.filter(e=>e.protectionMode===`direct`).map(e=>e.path),subtreeProtectedPaths:n.filter(e=>e.protectionMode===`recursive`).map(e=>e.path),compiledRules:n}}function ug(e){let t=new Set;for(let n of e.workspace.projects){if(n.isWorkspaceRootProject===!0)continue;let e=n.dirFromWorkspacePath?.getAbsolutePath?.();e!=null&&e.length>0&&t.add(Wh(e))}return[...t]}function dg(e,t){return t==null?e:e.specificity===t.specificity?e.protectionMode===t.protectionMode?e.path.localeCompare(t.path)<0?e:t:e.protectionMode===`recursive`?e:t:e.specificity>t.specificity?e:t}function fg(e,t){let n=Wh(e),r=Jh(n),i;for(let e of t.compiledRules){let t=!1;for(let n of r){for(let r of e.comparisonKeys)if(eg(n,r,e.protectionMode)){i=dg(e,i),t=!0;break}if(t)break}}if(i!=null)return{targetPath:n,protectedPath:i.path,protectionMode:i.protectionMode,reason:i.reason,source:i.source}}function pg(e,t){let n=[],r=new Map;for(let i of e){let e=Wh(i),a=fg(e,t);if(a==null){n.push(e);continue}r.has(a.targetPath)||r.set(a.targetPath,a)}return{safePaths:n,violations:[...r.values()].sort((e,t)=>e.targetPath.localeCompare(t.targetPath))}}function mg(e,t){let n=t.map(e=>e.targetPath).join(`, `);return`Protected deletion guard blocked ${e} for ${t.length} path(s): ${n}`}function hg(e,t,n){e.error(ht(t,n))}var gg=class{inputEffects=[];registeredScopes=[];name;dependsOn;_log;get log(){return this._log??=Ut(this.name),this._log}constructor(e,t){this.name=e,t!=null&&(this.dependsOn=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,aindexDir: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,aindexDir: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 throw t.error??Error(`Input effect failed: ${e.name}`);n.push(t)}catch(t){let r=t instanceof Error?t:Error(String(t));throw this.logInputEffectFailure(e.name,r),n.push({success:!1,error:r,description:`Input effect failed: ${e.name}`}),r}}return n}logInputEffectFailure(e,t){if(t instanceof Fh){hg(this.log,t.operation,t.violations);return}this.log.error(st({code:`INPUT_EFFECT_FAILED`,title:`Input effect failed: ${e}`,rootCause:z(`The input effect "${e}" failed before tnmsc could finish preprocessing.`,`Underlying error: ${t.message}`),exactFix:z(`Inspect the effect inputs and fix the failing file, path, or environment condition before retrying tnmsc.`),possibleFixes:[z(`Re-run the command after fixing the referenced path or generated artifact.`),z(`Add a focused regression test if this effect should handle the failure more gracefully.`)],details:{effectName:e,errorMessage:t.message}}))}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.aindex?.dir??`aindex`;return{workspaceDir:n,aindexDir:i.join(n,r)}}resolvePath(e,t){let n=e;return n.startsWith(Sb.USER_HOME)&&(n=n.replace(Sb.USER_HOME,c.homedir())),n.includes(Sb.WORKSPACE)&&(n=n.replace(Sb.WORKSPACE,t)),i.normalize(n)}resolveAindexPath(e,t){return i.join(t,e)}readAndParseMarkdown(e,t){return Qm(t.readFileSync(e,`utf8`))}};const _g=/\r?\n/u;function vg(e={}){let{filePath:t,position:n,sourceText:r,expression:i,exportName:a,nodeType:o,phase:s,hint:c,cause:l}=e,u=n?.start.line,d=n?.start.column,f=n?.end?.line,p=n?.end?.column,m=n?.start.offset,h=n?.end?.offset,g=u!=null&&r!=null?yg(r,u):void 0,_=bg(r,m,h,g),v=u!=null&&d!=null&&g!=null?xg(u,d,p,g):void 0,y={};return t!=null&&t.length>0&&Object.assign(y,{filePath:t}),u!=null&&Object.assign(y,{line:u}),d!=null&&Object.assign(y,{column:d}),f!=null&&Object.assign(y,{endLine:f}),p!=null&&Object.assign(y,{endColumn:p}),m!=null&&Object.assign(y,{offset:m}),h!=null&&Object.assign(y,{endOffset:h}),_!=null&&_.length>0&&Object.assign(y,{snippet:_}),g!=null&&g.length>0&&Object.assign(y,{sourceLine:g}),v!=null&&v.length>0&&Object.assign(y,{codeFrame:v}),i!=null&&i.length>0&&Object.assign(y,{expression:i}),a!=null&&a.length>0&&Object.assign(y,{exportName:a}),o!=null&&o.length>0&&Object.assign(y,{nodeType:o}),s!=null&&s.length>0&&Object.assign(y,{phase:s}),c!=null&&c.length>0&&Object.assign(y,{hint:c}),l!=null&&l.length>0&&Object.assign(y,{cause:l}),y}function yg(e,t){return e.split(_g)[t-1]}function bg(e,t,n,r){if(e!=null&&t!=null){let r=n!=null&&n>=t?n:t+1,i=e.slice(t,r).trim();if(i.length>0)return i.length>240?`${i.slice(0,240)}...`:i}let i=r?.trim();if(i!=null&&i.length>0)return i}function xg(e,t,n,r){let i=`${e} | `,a=` `.repeat(i.length+Math.max(0,t-1)),o=Math.max(1,(n??t+1)-t);return`${i}${r}\n${a}${`^`.repeat(o)}`}function Sg(e){if(!(e.line==null||e.column==null))return e.endLine!=null&&e.endColumn!=null?`${e.line}:${e.column}-${e.endLine}:${e.endColumn}`:`${e.line}:${e.column}`}function Cg(e,t){let n=[e];t.phase!=null&&n.push(`phase: ${t.phase}`),t.nodeType!=null&&n.push(`node: ${t.nodeType}`),t.filePath!=null&&n.push(`file: ${t.filePath}`);let r=Sg(t);return r!=null&&n.push(`location: ${r}`),t.expression!=null&&n.push(`expression: ${t.expression}`),t.exportName!=null&&n.push(`export: ${t.exportName}`),t.sourceLine!=null&&n.push(`source line: ${t.sourceLine.trimEnd()}`),t.codeFrame!=null&&(n.push(`code frame:`),n.push(t.codeFrame)),t.hint!=null&&n.push(`hint: ${t.hint}`),t.cause!=null&&n.push(`cause: ${t.cause}`),n.join(`
|
|
195
|
+
`)}function wg(e,t={}){return e instanceof Tg||e instanceof Error?e.message:Cg(t.summary??`Compiler diagnostic`,e)}var Tg=class extends Error{diagnostic;filePath;line;column;endLine;endColumn;snippet;sourceLine;codeFrame;phase;nodeType;constructor(e,t,n){super(Cg(t,n)),this.name=e,this.diagnostic=n,n.filePath!=null&&(this.filePath=n.filePath),n.line!=null&&(this.line=n.line),n.column!=null&&(this.column=n.column),n.endLine!=null&&(this.endLine=n.endLine),n.endColumn!=null&&(this.endColumn=n.endColumn),n.snippet!=null&&(this.snippet=n.snippet),n.sourceLine!=null&&(this.sourceLine=n.sourceLine),n.codeFrame!=null&&(this.codeFrame=n.codeFrame),n.phase!=null&&(this.phase=n.phase),n.nodeType!=null&&(this.nodeType=n.nodeType)}};function Eg(e){if(e===`mdxTextExpression`||e===`mdxFlowExpression`)return`Literal braces in MDX text are parsed as expressions. Escape the braces or wrap the placeholder in code if you meant plain text.`;if(e===`mdxJsxAttributeValueExpression`)return`JSX attribute expressions must reference values that exist in scope.`}var Dg=class extends Tg{expression;constructor(e,t){super(`ScopeError`,e,t),t.expression!=null&&(this.expression=t.expression)}},Og=class extends Dg{variableName;constructor(e,t,n={}){let r=vg({...n,expression:t,phase:n.phase??`expression-evaluation`,hint:n.hint??Eg(n.nodeType)}),i=`Undefined variable "${e}" in expression "${t??``}"`;super(i,r),this.name=`UndefinedVariableError`,this.variableName=e}},kg=class extends Dg{namespace;constructor(e,t,n={}){let r=vg({...n,expression:t,phase:n.phase??`expression-evaluation`,hint:n.hint??Eg(n.nodeType)}),i=`Undefined namespace "${e}" in expression "${t??``}"`;super(i,r),this.name=`UndefinedNamespaceError`,this.namespace=e}},Ag=class extends Tg{exportName;constructor(e,t,n={}){let r=vg({...n,exportName:t,phase:n.phase??`export-parsing`,hint:n.hint??`Export metadata must be statically evaluable. Use plain literals, arrays, objects, or scope-backed references only.`});super(`ExportParseError`,e,r),t!=null&&(this.exportName=t)}};const jg=new Map;function Mg(e,t){jg.set(e,t)}function Ng(){return new Map(jg)}function Pg(e){return jg.has(e)}const Fg=/^[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*$/iu,Ig=/(\w+) is not defined/u;function Lg(e,t,n){let r=e.trim(),i=Rg(n,e);return r===``?``:Fg.test(r)?zg(r,t,i):Bg(r,t,i)}function Rg(e,t){return{expression:t,...e?.filePath!=null&&{filePath:e.filePath},...e?.sourceText!=null&&{sourceText:e.sourceText},...e?.position!=null&&{position:e.position},...e?.nodeType!=null&&{nodeType:e.nodeType}}}function zg(e,t,n){let r=e.split(`.`),i=r[0];if(i==null||!(i in t))throw new kg(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 Og(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 Og(i,e,n);a=o[i]}return Vg(a)}function Bg(e,t,n){let r=Object.keys(t),i=r.map(e=>t[e]);try{return Vg(Function(...r,`return (${e})`)(...i))}catch(t){let r=t instanceof Error?t.message:String(t);if(r.includes(`is not defined`)){let t=Ig.exec(r);if(t?.[1]!=null)throw new kg(t[1],e,{...n,cause:r})}let i=n?.filePath==null?[]:[`file: ${n.filePath}`],a=n?.position?.start==null?[]:[`location: ${n.position.start.line}:${n.position.start.column}`];throw Error([`Failed to evaluate expression: "${e}"`,...i,...a,`Cause: ${r}`].join(`
|
|
196
|
+
`))}}function Vg(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 Hg(e,t){return e===null?!1:t.components.has(e)||Pg(e)}async function Ug(e){return async(t,n)=>(await e({type:`root`,children:t},n)).children}async function Wg(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 Ug(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})}}const Gg=/language-(\w+)/u;function Kg(e,t,n){return{...e.filePath!=null&&{filePath:e.filePath},...e.sourceText!=null&&{sourceText:e.sourceText},...n?.position!=null&&{position:n.position},nodeType:t}}function qg(e,t){let n=e.name?.toLowerCase();if(n==null)return null;switch(n){case`pre`:return Xg(e,t);case`a`:return Zg(e,t);case`strong`:case`b`:return Qg(e,t);case`em`:case`i`:return $g(e,t);case`img`:return e_(e,t);case`blockquote`:return t_(e,t);default:return null}}function Jg(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`?Lg(r.value.value,n.scope,Kg(n,`mdxJsxAttributeValueExpression`,r)):r.value===null?``:null}function Yg(e,t){let n=``;for(let r of e.children){if(r.type===`text`){n+=r.value;continue}if(r.type===`mdxTextExpression`){n+=Lg(r.value,t.scope,Kg(t,`mdxTextExpression`,r));continue}(r.type===`mdxJsxFlowElement`||r.type===`mdxJsxTextElement`)&&(n+=Yg(r,t))}return n}function Xg(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=Jg(n,`className`,t)??``,i=Gg.exec(r)?.[1],a=Yg(n,t);return[{type:`code`,lang:i??null,value:a.trim()}]}function Zg(e,t){let n=Jg(e,`href`,t);if(n==null||n===``)return null;let r=Yg(e,t);return[{type:`paragraph`,children:[{type:`link`,url:n,title:Jg(e,`title`,t)??null,children:[{type:`text`,value:r}]}]}]}function Qg(e,t){let n={type:`strong`,children:[{type:`text`,value:Yg(e,t)}]};return e.type,[{type:`paragraph`,children:[n]}]}function $g(e,t){let n={type:`emphasis`,children:[{type:`text`,value:Yg(e,t)}]};return e.type,[{type:`paragraph`,children:[n]}]}function e_(e,t){let n=Jg(e,`src`,t);if(n==null||n===``)return null;let r={type:`image`,url:n,alt:Jg(e,`alt`,t)??``,title:Jg(e,`title`,t)??null};return e.type,[{type:`paragraph`,children:[r]}]}function t_(e,t){return[{type:`blockquote`,children:[{type:`paragraph`,children:[{type:`text`,value:Yg(e,t)}]}]}]}const n_=/^-?\d+(?:\.\d+)?$/u;function r_(e,t){return{...e.filePath!=null&&{filePath:e.filePath},...e.sourceText!=null&&{sourceText:e.sourceText},...t.position!=null&&{position:t.position},nodeType:t.type}}function i_(e){return e==null?!1:JSON.stringify(e).includes(`"JSX`)}async function a_(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`?o_(i.expression,t,n,e):[]}async function o_(e,t,n,r){return e.type===`JSXElement`?f_(e,t,n):e.type===`JSXFragment`?p_(e,t,n,r):e.type===`LogicalExpression`?s_(e,t,n,r):e.type===`ConditionalExpression`?c_(e,t,n,r):e.type===`SequenceExpression`?l_(e,t,n,r):e.type===`ArrayExpression`?u_(e,t,n,r):S_(e,t,r)}async function s_(e,t,n,r){let i=await d_(e.left,t,n,r);return e.operator===`&&`?b_(i)?o_(e.right,t,n,r):[]:e.operator===`||`?b_(i)?y_(e.left)?o_(e.left,t,n,r):x_(i):o_(e.right,t,n,r):e.operator===`??`?i==null?o_(e.right,t,n,r):y_(e.left)?o_(e.left,t,n,r):x_(i):[]}async function c_(e,t,n,r){return b_(await d_(e.test,t,n,r))?o_(e.consequent,t,n,r):o_(e.alternate,t,n,r)}async function l_(e,t,n,r){let i=[];for(let a of e.expressions){let e=await o_(a,t,n,r);i.push(...e)}return i}async function u_(e,t,n,r){let i=[];for(let a of e.elements)if(a!=null)if(a.type===`SpreadElement`){let e=await o_(a.argument,t,n,r);i.push(...e)}else{let e=await o_(a,t,n,r);i.push(...e)}return i}async function d_(e,t,n,r){if(y_(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 i=await d_(e.argument,t,n,r);return e.operator===`!`?!b_(i):e.operator===`-`?-i:e.operator===`+`?+i:e.operator===`typeof`?typeof i:void 0}if(e.type===`BinaryExpression`){let i=await d_(e.left,t,n,r),a=await d_(e.right,t,n,r);return e.operator===`===`?i===a:e.operator===`!==`?i!==a:e.operator===`==`?i===a:e.operator===`!=`?i!==a:e.operator===`<`?i<a:e.operator===`<=`?i<=a:e.operator===`>`?i>a:e.operator===`>=`?i>=a:e.operator===`+`?i+a:e.operator===`-`?i-a:e.operator===`*`?i*a:e.operator===`/`?i/a:e.operator===`%`?i%a:void 0}if(e.type===`LogicalExpression`){let i=await d_(e.left,t,n,r);return e.operator===`&&`?b_(i)?d_(e.right,t,n,r):i:e.operator===`||`?b_(i)?i:d_(e.right,t,n,r):e.operator===`??`?i??d_(e.right,t,n,r):void 0}if(e.type===`MemberExpression`){let i=await d_(e.object,t,n,r);if(i==null)return;if(e.computed)return i[await d_(e.property,t,n,r)];let{name:a}=e.property;return i[a]}if(e.type===`ConditionalExpression`)return b_(await d_(e.test,t,n,r))?d_(e.consequent,t,n,r):d_(e.alternate,t,n,r);let i=v_(e);if(i!==``)try{let e=Lg(i,t.scope,r_(t,r));return e===`true`?!0:e===`false`?!1:e===`null`?null:e===`undefined`||e===``?void 0:n_.test(e)?Number(e):e}catch{return}}async function f_(e,t,n){let r=h_(e,t);if(r.name!=null&&Hg(r.name,t)){let{processAst:e}=await Promise.resolve().then(()=>C_);return Wg(r,t,e)}return qg(r,t)??(r.children.length>0?n(r.children,t):[])}async function p_(e,t,n,r){let i=[];for(let a of e.children){let e=await m_(a,t,n,r);i.push(...e)}return i}async function m_(e,t,n,r){if(e.type===`JSXElement`)return f_(e,t,n);if(e.type===`JSXFragment`)return p_(e,t,n,r);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`?[]:o_(e.expression,t,n,r):e.type===`JSXSpreadChild`?o_(e.expression,t,n,r):[]}function h_(e,t){let n=e.openingElement,r=null;n.name.type===`JSXIdentifier`?{name:r}=n.name:n.name.type===`JSXMemberExpression`?r=g_(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:v_(e.value.expression)}),i.push({type:`mdxJsxAttribute`,name:t,value:n})}else e.type===`JSXSpreadAttribute`&&i.push({type:`mdxJsxExpressionAttribute`,value:`...${v_(e.argument)}`});let a=[];for(let n of e.children){let e=__(n,t);e!=null&&a.push(...e)}return{type:`mdxJsxFlowElement`,name:r,attributes:i,children:a}}function g_(e){return e.object.type===`JSXIdentifier`?`${e.object.name}.${e.property.name}`:`${g_(e.object)}.${e.property.name}`}function __(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[h_(e,t)];if(e.type===`JSXFragment`){let n=[];for(let r of e.children){let e=__(r,t);e!=null&&n.push(...e)}return n}return e.type===`JSXExpressionContainer`?e.expression.type===`JSXEmptyExpression`?null:[{type:`paragraph`,children:[{type:`text`,value:v_(e.expression)}]}]:e.type===`JSXSpreadChild`?[{type:`paragraph`,children:[{type:`text`,value:`...${v_(e.expression)}`}]}]:null}function v_(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=v_(e.object);return e.computed?`${t}[${v_(e.property)}]`:`${t}.${e.property.name}`}if(e.type===`CallExpression`)return`${v_(e.callee)}(${e.arguments.map(e=>v_(e)).join(`, `)})`;if(e.type===`BinaryExpression`||e.type===`LogicalExpression`){let t=v_(e.left),n=v_(e.right);return`(${t} ${e.operator} ${n})`}if(e.type===`UnaryExpression`){let t=v_(e.argument);return`${e.operator}${t}`}if(e.type===`ConditionalExpression`)return`(${v_(e.test)} ? ${v_(e.consequent)} : ${v_(e.alternate)})`;if(e.type===`ArrayExpression`)return`[${e.elements.filter(e=>e!=null&&e.type!==`SpreadElement`).map(e=>v_(e)).join(`, `)}]`;if(e.type===`ObjectExpression`)return`{${e.properties.filter(e=>e.type===`Property`).map(e=>`${e.key.type===`Identifier`?e.key.name:v_(e.key)}: ${v_(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+=`\${${v_(e.expressions[n])}}`);return t+="`",t}return e.type===`SpreadElement`?`...${v_(e.argument)}`:``}function y_(e){return e.type===`JSXElement`||e.type===`JSXFragment`}function b_(e){return!!e}function x_(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 S_(e,t,n){let r=v_(e);if(r===``)return[];try{return x_(Lg(r,t.scope,r_(t,n)))}catch{return[]}}var C_=Xt({processAst:()=>D_});const w_=/\.\w+$/u;function T_(e,t,n){return{...e.filePath!=null&&{filePath:e.filePath},...e.sourceText!=null&&{sourceText:e.sourceText},...t.position!=null&&{position:t.position},nodeType:n}}function E_(e){if(!(e.includes(`/`)&&w_.test(e)))return e;let t=e.lastIndexOf(`/`);return e.slice(t+1)}async function D_(e,t){return O_(e,t)}async function O_(e,t){let n=[];for(let r of e.children){let e=await k_(r,t);n.push(...e)}return{type:`root`,children:n}}async function k_(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(i_(r))return a_(n,t,async(e,t)=>(await D_({type:`root`,children:e},t)).children);let a=Lg(n.value,t.scope,T_(t,n,`mdxFlowExpression`));return a===``?[]:[{type:`paragraph`,children:[{type:`text`,value:a}]}]}if(e.type===`mdxJsxFlowElement`)return A_(e,t);if(e.type===`link`){let n=e,r=(await j_(n.children,t)).map(e=>e.type===`text`?{...e,value:E_(e.value)}:e);return[{...n,children:r}]}if(!(`children`in e&&Array.isArray(e.children)))return[e];let n=await j_(e.children,t);return[{...e,children:n}]}async function A_(e,t){return e.name!=null&&Hg(e.name,t)?Wg(e,t,D_):qg(e,t)??[]}async function j_(e,t){let n=[];for(let r of e){if(r.type===`mdxFlowExpression`){let e=r,i=e.data?.estree,a=e.value.trim();if(a.startsWith(`/*`)&&a.endsWith(`*/`))continue;if(i_(i)){let r=await a_(e,t,async(e,t)=>(await D_({type:`root`,children:e},t)).children);for(let e of r)n.push(e);continue}let o=Lg(e.value,t.scope,T_(t,e,`mdxFlowExpression`));o!==``&&n.push({type:`paragraph`,children:[{type:`text`,value:o}]});continue}if(r.type===`mdxTextExpression`){let e=r,i=e.value.trim();if(i.startsWith(`/*`)&&i.endsWith(`*/`))continue;let a={type:`text`,value:Lg(e.value,t.scope,T_(t,e,`mdxTextExpression`))};n.push(a);continue}if(r.type===`mdxJsxTextElement`){let e=r;if(e.name!=null&&Hg(e.name,t)){let r=await Wg(e,t,D_);for(let e of r)e.type===`paragraph`&&`children`in e?n.push(...e.children):n.push(e);continue}let i=qg(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 j_(r.children,t);if(r.type===`link`){let t=e.map(e=>e.type===`text`?{...e,value:E_(e.value)}:e);n.push({...r,children:t});continue}n.push({...r,children:e});continue}n.push(r)}return n}const M_=/^export\s+default\s+/u,N_=/export\s+const\s+(\w+)\s*=\s*/gu,P_=/^-?\d+(?:\.\d+)?$/u,F_=/^[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*$/iu,I_=/\s/u,L_=/[\w$]/u,R_=/^[\w$]+$/u;function z_(e,t={}){let n={},{yamlFrontMatter:r,scope:i,filePath:a,sourceText:o}=t;for(let t of e){let e=B_(t,i,{...a!=null&&{filePath:a},...o!=null&&{sourceText:o}});Object.assign(n,e)}let s=Object.keys(n).length>0,c=r!=null&&Object.keys(r).length>0,l;return l=s&&c?`mixed`:s?`export`:`yaml`,{fields:{...r,...n},source:l}}function B_(e,t,n={}){let r={},{filePath:i,sourceText:a}=n,o=e.value.trim(),s=M_.exec(o);if(s!=null){let n=s[0].length,c=V_(o,n);if(c!=null)try{let e=H_(c.trim(),t,i);typeof e==`object`&&e&&!Array.isArray(e)&&Object.assign(r,e)}catch(t){let n=t instanceof Error?t.message:String(t);throw new Ag(`Cannot statically evaluate export default`,`default`,{...i!=null&&{filePath:i},...a!=null&&{sourceText:a},...e.position!=null&&{position:e.position},nodeType:`mdxjsEsm`,phase:`export-parsing`,cause:n})}return r}let c=N_.exec(o);for(;c!==null;){let n=c[1];if(n==null){c=N_.exec(o);continue}let s=V_(o,c.index+c[0].length);if(s==null){c=N_.exec(o);continue}try{let e=H_(s.trim(),t,i);n===`metadata`&&typeof e==`object`&&e&&!Array.isArray(e)?Object.assign(r,e):r[n]=e}catch(t){let r=t instanceof Error?t.message:String(t);throw new Ag(`Cannot statically evaluate export "${n}"`,n,{...i!=null&&{filePath:i},...a!=null&&{sourceText:a},...e.position!=null&&{position:e.position},nodeType:`mdxjsEsm`,phase:`export-parsing`,cause:r})}c=N_.exec(o)}return r}function V_(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===`
|
|
197
|
+
`){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 H_(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(P_.test(r))return Number(r);if(r.startsWith(`"`)&&r.endsWith(`"`)||r.startsWith(`'`)&&r.endsWith(`'`))return U_(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 U_(e)}if(r.startsWith(`[`)&&r.endsWith(`]`))return G_(r,t,n);if(r.startsWith(`{`)&&r.endsWith(`}`))return K_(r,t,n);if(F_.test(r))return W_(r,t,n);let i=n==null?``:` in file "${n}"`;throw Error(`Expression "${r}" cannot be statically evaluated${i}`)}function U_(e){return e.replaceAll(`\\n`,`
|
|
198
|
+
`).replaceAll(`\\r`,`\r`).replaceAll(`\\t`,` `).replaceAll(`\\"`,`"`).replaceAll(`\\'`,`'`).replaceAll(`\\\\`,`\\`)}function W_(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 G_(e,t,n){let r=e.slice(1,-1).trim();if(r===``)return[];if(t==null)try{let t=q_(e),n=JSON.parse(t);if(Array.isArray(n))return n}catch{}return J_(r).map(e=>H_(e.trim(),t,n))}function K_(e,t,n){let r=e.slice(1,-1).trim();if(r===``)return{};if(t==null)try{let t=q_(e),n=JSON.parse(t);if(typeof n==`object`&&n&&!Array.isArray(n))return n}catch{}let i={},a=Y_(r);for(let e of a){let r=X_(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]=H_(o,t,n)}return i}function q_(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&&I_.test(t.charAt(e));)e--;let n=e+1;for(;e>=0&&L_.test(t.charAt(e));)e--;if(e++,e>0&&t.charAt(e-1)!==`"`){let r=t.slice(e,n);r.length>0&&R_.test(r)&&(t=`${t.slice(0,e)}"${r}"`)}}t+=a}return t}function J_(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 Y_(e){return J_(e)}function X_(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}const Z_={}.hasOwnProperty;function Q_(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&Z_.call(t,e)){let n=String(t[e]);i=Z_.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const $_={}.hasOwnProperty;function ev(e,t){let n=-1,r;if(t.extensions)for(;++n<t.extensions.length;)ev(e,t.extensions[n]);for(r in t)if($_.call(t,r))switch(r){case`extensions`:break;case`unsafe`:tv(e[r],t[r]);break;case`join`:tv(e[r],t[r]);break;case`handlers`:nv(e[r],t[r]);break;default:e.options[r]=t[r]}return e}function tv(e,t){t&&e.push(...t)}function nv(e,t){t&&Object.assign(e,t)}const rv=[iv];function iv(e,t,n,r){if(t.type===`code`&&Ur(t,r)&&(e.type===`list`||e.type===t.type&&Ur(e,r)))return!1;if(`spread`in n&&typeof n.spread==`boolean`)return e.type===`paragraph`&&(e.type===t.type||t.type===`definition`||t.type===`heading`&&si(t,r))?void 0:n.spread?1:0}const av=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`],ov=[{character:` `,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,before:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`]},{character:`\r`,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`,`codeFencedMetaGraveAccent`,`codeFencedMetaTilde`,`destinationLiteral`,`headingAtx`]},{character:`
|
|
199
|
+
`,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`,`codeFencedMetaGraveAccent`,`codeFencedMetaTilde`,`destinationLiteral`,`headingAtx`]},{character:` `,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,before:`[\\r\\n]`,inConstruct:`phrasing`},{character:` `,inConstruct:[`codeFencedLangGraveAccent`,`codeFencedLangTilde`]},{character:`!`,after:`\\[`,inConstruct:`phrasing`,notInConstruct:av},{character:`"`,inConstruct:`titleQuote`},{atBreak:!0,character:`#`},{character:`#`,inConstruct:`headingAtx`,after:`(?:[\r
|
|
200
|
+
]|$)`},{character:`&`,after:`[#A-Za-z]`,inConstruct:`phrasing`},{character:`'`,inConstruct:`titleApostrophe`},{character:`(`,inConstruct:`destinationRaw`},{before:`\\]`,character:`(`,inConstruct:`phrasing`,notInConstruct:av},{atBreak:!0,before:`\\d+`,character:`)`},{character:`)`,inConstruct:`destinationRaw`},{atBreak:!0,character:`*`,after:`(?:[ \r
|
|
201
|
+
*])`},{character:`*`,inConstruct:`phrasing`,notInConstruct:av},{atBreak:!0,character:`+`,after:`(?:[ \r
|
|
202
202
|
])`},{atBreak:!0,character:`-`,after:`(?:[ \r
|
|
203
203
|
-])`},{atBreak:!0,before:`\\d+`,character:`.`,after:`(?:[ \r
|
|
204
|
-
]|$)`},{atBreak:!0,character:`<`,after:`[!/?A-Za-z]`},{character:`<`,after:`[!/?A-Za-z]`,inConstruct:`phrasing`,notInConstruct:
|
|
205
|
-
`)&&u.type===`html`&&(a[a.length-1]=a[a.length-1].replace(/(\r?\n|\r)$/,` `),s=` `,l=t.createTracker(n),l.move(a.join(``)));let f=t.handle(u,e,t,{...l.current(),after:d,before:s});c&&c===f.slice(0,1)&&(f=Xr(c.charCodeAt(0))+f.slice(1));let p=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,c=void 0,p&&(a.length>0&&p.before&&s===a[a.length-1].slice(-1)&&(a[a.length-1]=a[a.length-1].slice(0,-1)+Xr(s.charCodeAt(0))),p.after&&(c=d)),l.move(f),a.push(f),s=f.slice(-1)}return r.pop(),a.join(``)}function
|
|
204
|
+
]|$)`},{atBreak:!0,character:`<`,after:`[!/?A-Za-z]`},{character:`<`,after:`[!/?A-Za-z]`,inConstruct:`phrasing`,notInConstruct:av},{character:`<`,inConstruct:`destinationLiteral`},{atBreak:!0,character:`=`},{atBreak:!0,character:`>`},{character:`>`,inConstruct:`destinationLiteral`},{atBreak:!0,character:`[`},{character:`[`,inConstruct:`phrasing`,notInConstruct:av},{character:`[`,inConstruct:[`label`,`reference`]},{character:`\\`,after:`[\\r\\n]`,inConstruct:`phrasing`},{character:`]`,inConstruct:[`label`,`reference`]},{atBreak:!0,character:`_`},{character:`_`,inConstruct:`phrasing`,notInConstruct:av},{atBreak:!0,character:"`"},{character:"`",inConstruct:[`codeFencedLangGraveAccent`,`codeFencedMetaGraveAccent`]},{character:"`",inConstruct:`phrasing`,notInConstruct:av},{atBreak:!0,character:`~`}];function sv(e){return e.label||!e.identifier?e.label||``:Wi(e.identifier)}function cv(e){if(!e._compiled){let t=(e.atBreak?`[\\r\\n][\\t ]*`:``)+(e.before?`(?:`+e.before+`)`:``);e._compiled=RegExp((t?`(`+t+`)`:``)+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?`\\`:``)+e.character+(e.after?`(?:`+e.after+`)`:``),`g`)}return e._compiled}function lv(e,t,n){let r=t.indexStack,i=e.children||[],a=[],o=-1,s=n.before,c;r.push(-1);let l=t.createTracker(n);for(;++o<i.length;){let u=i[o],d;if(r[r.length-1]=o,o+1<i.length){let n=t.handle.handlers[i[o+1].type];n&&n.peek&&(n=n.peek),d=n?n(i[o+1],e,t,{before:``,after:``,...l.current()}).charAt(0):``}else d=n.after;a.length>0&&(s===`\r`||s===`
|
|
205
|
+
`)&&u.type===`html`&&(a[a.length-1]=a[a.length-1].replace(/(\r?\n|\r)$/,` `),s=` `,l=t.createTracker(n),l.move(a.join(``)));let f=t.handle(u,e,t,{...l.current(),after:d,before:s});c&&c===f.slice(0,1)&&(f=Xr(c.charCodeAt(0))+f.slice(1));let p=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,c=void 0,p&&(a.length>0&&p.before&&s===a[a.length-1].slice(-1)&&(a[a.length-1]=a[a.length-1].slice(0,-1)+Xr(s.charCodeAt(0))),p.after&&(c=d)),l.move(f),a.push(f),s=f.slice(-1)}return r.pop(),a.join(``)}function uv(e,t,n){let r=t.indexStack,i=e.children||[],a=t.createTracker(n),o=[],s=-1;for(r.push(-1);++s<i.length;){let n=i[s];r[r.length-1]=s,o.push(a.move(t.handle(n,e,t,{before:`
|
|
206
206
|
`,after:`
|
|
207
|
-
`,...a.current()}))),n.type!==`list`&&(t.bulletLastUsed=void 0),s<i.length-1&&o.push(a.move(
|
|
207
|
+
`,...a.current()}))),n.type!==`list`&&(t.bulletLastUsed=void 0),s<i.length-1&&o.push(a.move(dv(n,i[s+1],e,t)))}return r.pop(),o.join(``)}function dv(e,t,n,r){let i=r.join.length;for(;i--;){let a=r.join[i](e,t,n,r);if(a===!0||a===1)break;if(typeof a==`number`)return`
|
|
208
208
|
`.repeat(1+a);if(a===!1)return`
|
|
209
209
|
|
|
210
210
|
<!---->
|
|
211
211
|
|
|
212
212
|
`}return`
|
|
213
213
|
|
|
214
|
-
`}const
|
|
214
|
+
`}const fv=/\r?\n|\r/g;function pv(e,t){let n=[],r=0,i=0,a;for(;a=fv.exec(e);)o(e.slice(r,a.index)),n.push(a[0]),r=a.index+a[0].length,i++;return o(e.slice(r)),n.join(``);function o(e){n.push(t(e,i,!e))}}function mv(e,t,n){let r=(n.before||``)+(t||``)+(n.after||``),i=[],a=[],o={},s=-1;for(;++s<e.unsafe.length;){let t=e.unsafe[s];if(!zr(e.stack,t))continue;let n=e.compilePattern(t),a;for(;a=n.exec(r);){let e=`before`in t||!!t.atBreak,n=`after`in t,r=a.index+(e?a[1].length:0);i.includes(r)?(o[r].before&&!e&&(o[r].before=!1),o[r].after&&!n&&(o[r].after=!1)):(i.push(r),o[r]={before:e,after:n})}}i.sort(hv);let c=n.before?n.before.length:0,l=r.length-(n.after?n.after.length:0);for(s=-1;++s<i.length;){let e=i[s];e<c||e>=l||e+1<l&&i[s+1]===e+1&&o[e].after&&!o[e+1].before&&!o[e+1].after||i[s-1]===e-1&&o[e].before&&!o[e-1].before&&!o[e-1].after||(c!==e&&a.push(gv(r.slice(c,e),`\\`)),c=e,/[!-/:-@[-`{-~]/.test(r.charAt(e))&&(!n.encode||!n.encode.includes(r.charAt(e)))?a.push(`\\`):(a.push(Xr(r.charCodeAt(e))),c++))}return a.push(gv(r.slice(c,l),n.after)),a.join(``)}function hv(e,t){return e-t}function gv(e,t){let n=/\\(?=[!-/:-@[-`{-~])/g,r=[],i=[],a=e+t,o=-1,s=0,c;for(;c=n.exec(a);)r.push(c.index);for(;++o<r.length;)s!==r[o]&&i.push(e.slice(s,r[o])),i.push(`\\`),s=r[o];return i.push(e.slice(s)),i.join(``)}function _v(e){let t=e||{},n=t.now||{},r=t.lineShift||0,i=n.line||1,a=n.column||1;return{move:c,current:o,shift:s};function o(){return{now:{line:i,column:a},lineShift:r}}function s(e){r+=e}function c(e){let t=e||``,n=t.split(/\r?\n|\r/g),o=n[n.length-1];return i+=n.length-1,a=n.length===1?a+o.length:1+o.length+r,t}}function vv(e,t){let n=t||{},r={associationId:sv,containerPhrasing:Sv,containerFlow:Cv,createTracker:_v,compilePattern:cv,enter:a,handlers:{...Ri},handle:void 0,indentLines:pv,indexStack:[],join:[...rv],options:{},safe:wv,stack:[],unsafe:[...ov]};ev(r,n),r.options.tightDefinitions&&r.join.push(xv),r.handle=Q_(`type`,{invalid:yv,unknown:bv,handlers:r.handlers});let i=r.handle(e,void 0,r,{before:`
|
|
215
215
|
`,after:`
|
|
216
216
|
`,now:{line:1,column:1},lineShift:0});return i&&i.charCodeAt(i.length-1)!==10&&i.charCodeAt(i.length-1)!==13&&(i+=`
|
|
217
|
-
`),i;function a(e){return r.stack.push(e),t;function t(){r.stack.pop()}}}function Q_(e){throw Error("Cannot handle value `"+e+"`, expected node")}function $_(e){let t=e;throw Error("Cannot handle unknown node `"+t.type+"`")}function ev(e,t){if(e.type===`definition`&&e.type===t.type)return 0}function tv(e,t){return H_(e,this,t)}function nv(e,t){return U_(e,this,t)}function rv(e,t){return q_(this,e,t)}function iv(e,t,n){return{...e.filePath!=null&&{filePath:e.filePath},...e.sourceText!=null&&{sourceText:e.sourceText},...n?.position!=null&&{position:n.position},nodeType:t}}function av(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=Eg(n.value.value,t.scope,iv(t,`mdxJsxAttributeValueExpression`,n));return e===`true`||e===`1`}catch{return!1}return!1}async function ov(e,t,n){return!av(e,t)||e.children.length===0?[]:n(e.children,t)}async function sv(e,t){if(!av(e,t)||e.children.length===0)return[];let n=cv(e.children,t);return n===``?[]:[{type:`text`,value:n}]}function cv(e,t){let n=``;for(let r of e)if(r.type===`text`)n+=r.value;else if(r.type===`mdxTextExpression`)try{n+=Eg(r.value,t.scope,iv(t,`mdxTextExpression`,r))}catch{}else `children`in r&&Array.isArray(r.children)&&(n+=cv(r.children,t));return n}function lv(){Cg(`Md`,ov),Cg(`Md.Line`,sv)}function uv(e){let t=this;t.compiler=n;function n(n){return Z_(n,{...t.data(`settings`),...e,extensions:t.data(`toMarkdownExtensions`)||[]})}}var dv=Qt(Nm(),1);lv();function fv(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 pv(e,t){let n=hp(e),r=fv(t?.globalScope,t?.scope),i=wg(),a;if(t?.extractMetadata===!0){let i=n.children.find(e=>e.type===`yaml`),o;if(i!=null)try{o=dv.parse(i.value)}catch{}a=v_(n.children.filter(e=>e.type===`mdxjsEsm`),{...o!=null&&{yamlFrontMatter:o},scope:r,...t?.filePath!=null&&{filePath:t.filePath},sourceText:e}),n.children=n.children.filter(e=>e.type!==`yaml`&&e.type!==`mdxjsEsm`)}let o=await p_(n,{scope:r,components:i,processingStack:[],...t?.basePath!=null&&{basePath:t.basePath},...t?.filePath!=null&&{filePath:t.filePath},sourceText:e}),s=ap().use(Mn,[`yaml`]).use(qs).use(uv,{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}const mv=/^\s*(```|~~~)/u,hv=[/^\s*export\s+default\b/u,/^\s*export\s+const\b/u,/^\s*import\b/u];let gv=null;function _v(e){return typeof e!=`object`||!e?!1:typeof e.compileMdxToMd==`function`}function vv(e,t){let n=`@truenine/memory-sync-cli-${t}`;try{let t=e(n).mdCompiler;if(_v(t))return t}catch{}try{let t=o(e.resolve(`${n}/package.json`)),i=r(t).filter(e=>e.startsWith(`napi-md-compiler.`)&&e.endsWith(`.node`)).sort();for(let n of i){let r=e(s(t,n));if(_v(r))return r}}catch{return null}return null}try{let n=e(import.meta.url),{platform:r,arch:i}=t,a={"win32-x64":[`napi-md-compiler.win32-x64-msvc`,`win32-x64-msvc`],"linux-x64":[`napi-md-compiler.linux-x64-gnu`,`linux-x64-gnu`],"linux-arm64":[`napi-md-compiler.linux-arm64-gnu`,`linux-arm64-gnu`],"darwin-arm64":[`napi-md-compiler.darwin-arm64`,`darwin-arm64`],"darwin-x64":[`napi-md-compiler.darwin-x64`,`darwin-x64`]}[`${r}-${i}`];if(a!=null){let[e,t]=a;try{gv=n(`./${e}.node`)}catch{gv=vv(n,t)}}}catch{}async function yv(e,t){let n=t?.extractMetadata===!0?{...t,extractMetadata:!0}:null,r=bv(e,t);if(r!=null){if(n!=null){let{metadata:t}=r;return t==null||Sv(r.content)?pv(e,n):{content:r.content,metadata:t}}return r.content}return n==null?t==null?pv(e):pv(e,{...t,extractMetadata:!1}):pv(e,n)}function bv(e,t){if(gv==null)return null;try{let n=gv.compileMdxToMd(e,xv(t)),r=JSON.parse(n);return t?.extractMetadata===!0&&r.metadata==null?null:r}catch{return null}}function xv(e){if(e==null)return null;let t={...e,...e.globalScope==null?{}:{globalScope:{os:e.globalScope.os,env:e.globalScope.env,profile:e.globalScope.profile,tool:e.globalScope.tool}}};return JSON.stringify(t)}function Sv(e){let t;for(let n of e.split(/\r?\n/u)){let e=mv.exec(n);if(e?.[1]!=null){let n=e[1];t==null?t=n:t===n&&(t=void 0);continue}if(t==null&&hv.some(e=>e.test(n)))return!0}return!1}var Cv=class{type;name;_log;get log(){return this._log??=Ut(this.name),this._log}dependsOn;constructor(e,t,n){this.name=e,this.type=t,n!=null&&(this.dependsOn=n)}};function wv(e,t){return e==null&&t==null?[]:[...new Set([...e??[],...t??[]])]}function Tv(e,t){return e==null||t.length===0?!0:typeof e==`string`?t.includes(e):e.some(e=>t.includes(e))}function Ev(e,t){if(e==null&&t==null)return{};let n={};for(let[t,r]of Object.entries(e??{}))n[t]=[...r];for(let[e,r]of Object.entries(t??{}))n[e]=Object.hasOwn(n,e)?[...new Set([...n[e],...r])]:[...r];return n}function Dv(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.matchesSeries==`function`&&typeof t.resolveEffectiveIncludeSeries==`function`&&typeof t.resolveSubSeries==`function`}function Ov(){let n={"win32-x64":`win32-x64-msvc`,"linux-x64":`linux-x64-gnu`,"linux-arm64":`linux-arm64-gnu`,"darwin-arm64":`darwin-arm64`,"darwin-x64":`darwin-x64`}[`${t.platform}-${t.arch}`];if(n==null)return;let r=`@truenine/memory-sync-cli-${n}`,i=`napi-memory-sync-cli.${n}.node`;try{let t=e(import.meta.url),n=[r,`${r}/${i}`,`./${i}`];for(let e of n)try{let n=t(e),r=[n,n?.default,n?.config];for(let e of r)if(Dv(e))return e}catch{}}catch{}}const{resolveEffectiveIncludeSeries:kv,matchesSeries:Av,resolveSubSeries:jv}=Ov()??{resolveEffectiveIncludeSeries:wv,matchesSeries:Tv,resolveSubSeries:Ev};function $(e,t,n){let r=kv(t?.includeSeries,t?.[n]?.includeSeries);return e.filter(e=>Av(e.seriName,r))}function Mv(e){let t=e.replaceAll(/\.\/+/g,``);return t=t.replaceAll(/\/+$/g,``),t}function Nv(e,t){return t.startsWith(`**/`)?`${e}/${t}`:t.startsWith(`*`)?`${e}/**/${t}`:`${e}/${t}`}function Pv(e,t){for(let n of t){let t=n.replaceAll(/\/+$/g,``),r=[{prefix:t,pattern:`${t}/`},{prefix:t,pattern:`${t}\\`}];for(let{prefix:t,pattern:n}of r)if(e.startsWith(n))return{prefix:t,baseGlob:e.slice(n.length)};if(e===t)return{prefix:t,baseGlob:`**/*`}}return{prefix:null,baseGlob:e}}function Fv(e,t){let n=jv(t?.subSeries,t?.rules?.subSeries);if(Object.keys(n).length===0)return e;let r={};for(let[e,t]of Object.entries(n)){let n=Mv(e);r[n]=t}let i=Object.keys(r);return e.map(e=>{if(e.seriName==null)return e;let t=[];for(let[n,i]of Object.entries(r))(Array.isArray(e.seriName)?e.seriName.some(e=>i.includes(e)):i.includes(e.seriName))&&t.push(n);if(t.length===0)return e;let n=[];for(let r of e.globs){let{prefix:e,baseGlob:a}=Pv(r,i);e!=null&&n.push(r);for(let r of t){if(r===e)continue;let t=Nv(r,a);n.includes(t)||n.push(t)}}return{...e,globs:n}})}function Iv(e){let t=i.join(e,`.git`);if(!n.existsSync(t))return null;let r=n.lstatSync(t);if(r.isDirectory())return i.join(t,`info`);if(r.isFile())try{let r=n.readFileSync(t,`utf8`).trim(),a=/^gitdir: (.+)$/.exec(r);if(a?.[1]!=null){let t=i.resolve(e,a[1]);return i.join(t,`info`)}}catch{}return null}function Lv(e,t=5){let r=[],a=new Set([`node_modules`,`.turbo`,`dist`,`build`,`out`,`.cache`]);function o(s,c){if(c>t)return;let l;try{let e=n.readdirSync(s,{withFileTypes:!0});if(!Array.isArray(e))return;l=e}catch{return}l.some(e=>e.name===`.git`)&&s!==e&&r.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),r}const Rv={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 zv=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}({}),Bv=function(e){return e.Win=`win`,e.Mac=`mac`,e.Linux=`linux`,e.Unknown=`unknown`,e}({});var Vv=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=c.platform();return{platform:e,arch:c.arch(),hostname:c.hostname(),homedir:c.homedir(),tmpdir:c.tmpdir(),type:c.type(),release:c.release(),shellKind:this.detectShellKind(),kind:this.detectOsKind(e)}}detectOsKind(e){switch(e){case`win32`:return Bv.Win;case`darwin`:return Bv.Mac;case`linux`:case`freebsd`:case`openbsd`:case`sunos`:case`aix`:return Bv.Linux;default:return Bv.Unknown}}detectShellKind(){let e=(t.env.SHELL??t.env.ComSpec??``).toLowerCase();return e.includes(`bash`)?zv.Bash:e.includes(`zsh`)?zv.Zsh:e.includes(`fish`)?zv.Fish:e.includes(`pwsh`)?zv.Pwsh:e.includes(`powershell`)?zv.PowerShell:e.includes(`cmd`)?zv.Cmd:e.endsWith(`/sh`)?zv.Sh:zv.Unknown}collectEnvContext(){return{...t.env}}collectProfile(){return this.userConfig?.profile==null?{}:this.userConfig.profile}collectToolReferences(){let e={...Rv.default};return this.toolPreset===`claudeCode`?{...e,...Rv.claudeCode}:this.toolPreset===`kiro`?{...e,...Rv.kiro}:e}createMdComponent(){let e=(e=>e.when===!1?null:e.children);return e.Line=e=>e.when===!1?null:e.children,e}};let Hv=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 Uv=class{registrations=[];globalScope=null;setGlobalScope(e){this.globalScope=e}getGlobalScope(){return this.globalScope}register(e,t,n=Hv.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}resolve(e){let t=this.merge();return e.replaceAll(/\$\{([^}]+)\}/g,(e,n)=>{let r=n.split(`.`),i=t;for(let e of r)i=i?.[e];return i==null?`\${${n}}`:String(i)})}clear(){this.registrations.length=0,this.globalScope=null}};const Wv=[`project`,`global`];function Gv(e){if(e==null)return[];if(typeof e==`string`)return[e];let t=[];for(let n of e)t.includes(n)||t.push(n);return t}function Kv(e,t){let n=new Map;for(let[e,r]of t.entries())n.set(r,e);return[...e].sort((e,t)=>(n.get(e)??2**53-1)-(n.get(t)??2**53-1))}function qv(e){let{requestedScopes:t,defaultScopes:n,supportedScopes:r,singleScope:i,availableScopes:a,priority:o=Wv}=e,s=Gv(t),c=Gv(n),l=new Set(Gv(r)),u=(s.length>0?s:c).filter(e=>l.has(e));if(u.length===0)return[];let d=Kv(u,o);if(!i)return d;if(a!=null&&a.length>0){let e=new Set(a),t=d.find(t=>e.has(t));return t==null?[]:[t]}let[f]=d;return f==null?[]:[f]}const Jv=p.object({src:p.string(),dist:p.string()}),Yv=p.object({dir:p.string().default(`aindex`),skills:Jv,commands:Jv,subAgents:Jv,rules:Jv,globalPrompt:Jv,workspacePrompt:Jv,app:Jv,ext:Jv,arch:Jv}),Xv=p.object({includeSeriesPrefix:p.boolean().optional(),seriesSeparator:p.string().optional()}),Zv=p.object({includeSeriesPrefix:p.boolean().optional(),pluginOverrides:p.record(p.string(),Xv).optional()}),Qv=p.enum([`project`,`global`]),$v=p.union([Qv,p.array(Qv).min(1)]),ey=p.object({prompt:$v.optional(),rules:$v.optional(),commands:$v.optional(),subagents:$v.optional(),skills:$v.optional(),mcp:$v.optional()}),ty=p.object({plugins:p.record(p.string(),ey).optional()}),ny=p.object({blankLineAfter:p.boolean().optional()}),ry=p.enum([`direct`,`recursive`]),iy=p.enum([`path`,`glob`]),ay=p.object({path:p.string(),protectionMode:ry,matcher:iy.optional(),reason:p.string().optional()}),oy=p.object({rules:p.array(ay).optional()}),sy=p.object({name:p.string().optional(),username:p.string().optional(),gender:p.string().optional(),birthday:p.string().optional()}).catchall(p.unknown()),cy=p.object({version:p.string().optional(),workspaceDir:p.string().optional(),aindex:Yv.optional(),logLevel:p.enum([`trace`,`debug`,`info`,`warn`,`error`]).optional(),commandSeriesOptions:Zv.optional(),outputScopes:ty.optional(),frontMatter:ny.optional(),cleanupProtection:oy.optional(),profile:sy.optional()}),ly=p.object({names:p.array(p.string()).optional()}),uy=p.object({includeSeries:p.array(p.string()).optional(),subSeries:p.record(p.string(),p.array(p.string())).optional()});p.object({mcp:ly.optional(),includeSeries:p.array(p.string()).optional(),subSeries:p.record(p.string(),p.array(p.string())).optional(),rules:uy.optional(),skills:uy.optional(),subAgents:uy.optional(),commands:uy.optional()}),p.object({});function dy(e,t){let n=t==null?``:` in ${t}`;return e==null||e===`project`||e===`global`?{valid:!0,errors:[],warnings:[]}:{valid:!1,errors:[`Field "scope" must be "project" or "global"${n}`],warnings:[]}}function fy(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 py(e,t){let n=t==null?``:` in ${t}`,r=[],i=[];(!(`name`in e)||e.name==null)&&r.push(`Missing required field "name"${n}`),!(`description`in e)||e.description==null?r.push(`Missing required field "description"${n}`):(typeof e.description!=`string`||e.description.trim().length===0)&&r.push(`Required field "description" cannot be empty${n}`),e.enabled??i.push(`Using default value for optional field "enabled": true${n}`),e.keywords??i.push(`Using default value for optional field "keywords": []${n}`);let a=dy(e.scope,t);return r.push(...a.errors),{valid:r.length===0,errors:r,warnings:i}}function my(e,t){let n=fy(e,{requiredFields:[],optionalDefaults:{},filePath:t}),r=dy(e.scope,t);return{valid:n.valid&&r.valid,errors:[...n.errors,...r.errors],warnings:n.warnings}}function hy(e,t){let n=fy(e,{requiredFields:[`name`,`description`],optionalDefaults:{},filePath:t}),r=dy(e.scope,t);return{valid:n.valid&&r.valid,errors:[...n.errors,...r.errors],warnings:n.warnings}}function gy(e,t){let n=[],r=[],i=t==null?``:` in ${t}`;!Array.isArray(e.globs)||e.globs.length===0?n.push(`Missing or empty required field "globs"${i}`):e.globs.every(e=>typeof e==`string`)||n.push(`Field "globs" must be an array of strings${i}`),(typeof e.description!=`string`||e.description.length===0)&&n.push(`Missing or empty required field "description"${i}`);let{scope:a,seriName:o}=e,s=dy(a,t);return n.push(...s.errors),a??r.push(`Using default value for optional field "scope": "project"${i}`),o!=null&&typeof o!=`string`&&!Array.isArray(o)&&n.push(`Field "seriName" must be a string or string array${i}`),{valid:n.length===0,errors:n,warnings:r}}function _y(e){return{workspace:{directory:e.workspace.directory,projects:[...e.workspace.projects]},...e.skills!=null&&{skills:[...e.skills]},...e.commands!=null&&{commands:[...e.commands]},...e.subAgents!=null&&{subAgents:[...e.subAgents]},...e.rules!=null&&{rules:[...e.rules]},...e.readmePrompts!=null&&{readmePrompts:[...e.readmePrompts]},...e.globalMemory!=null&&{globalMemory:e.globalMemory},...e.vscodeConfigFiles!=null&&{vscodeConfigFiles:[...e.vscodeConfigFiles]},...e.jetbrainsConfigFiles!=null&&{jetbrainsConfigFiles:[...e.jetbrainsConfigFiles]},...e.editorConfigFiles!=null&&{editorConfigFiles:[...e.editorConfigFiles]},...e.aiAgentIgnoreConfigFiles!=null&&{aiAgentIgnoreConfigFiles:[...e.aiAgentIgnoreConfigFiles]},...e.globalGitIgnore!=null&&{globalGitIgnore:e.globalGitIgnore},...e.shadowGitExclude!=null&&{shadowGitExclude:e.shadowGitExclude},...e.aindexDir!=null&&{aindexDir:e.aindexDir}}}const vy={Readme:{src:`rdm.mdx`,out:`README.md`},CodeOfConduct:{src:`coc.mdx`,out:`CODE_OF_CONDUCT.md`},Security:{src:`security.mdx`,out:`SECURITY.md`}},yy=[`prompt`,`rules`,`commands`,`subagents`,`skills`,`mcp`];function by(e){return f.isBuffer(e)}function xy(e){if(typeof e==`string`)return[e];let t=[];for(let n of e)t.includes(n)||t.push(n);return t}function Sy(e,t){return t?.outputScopes?.plugins?.[e]}function Cy(e){for(let t of yy){let n=e.outputCapabilities[t];if(n!=null&&n.scopes.length===0)throw Error(`Plugin ${e.name} declares empty scopes for topic "${t}"`)}}function wy(e,t){let n=Sy(e.name,t);if(n!=null)for(let t of yy){let r=n[t];if(r==null)continue;let i=e.outputCapabilities[t];if(i==null)throw Error(`Invalid outputScopes configuration: outputScopes.plugins.${e.name}.${t} is set, but plugin ${e.name} does not support topic "${t}".`);let a=xy(r);if(i.singleScope&&a.length>1){let n=a.join(`, `);throw Error(`Invalid outputScopes configuration: outputScopes.plugins.${e.name}.${t} is single-scope and cannot request multiple scopes [${n}].`)}let o=new Set(i.scopes),s=a.filter(e=>!o.has(e));if(s.length>0){let n=i.scopes.join(`, `),r=s.join(`, `);throw Error(`Invalid outputScopes configuration: outputScopes.plugins.${e.name}.${t} requests unsupported scopes [${r}]. Allowed scopes: [${n}].`)}}}function Ty(e,t){for(let n of e)Cy(n),wy(n,t)}async function Ey(e,t){let r=new Map;Ty(e,t.pluginOptions);for(let a of e){let e=await a.declareOutputFiles(t),o=[];for(let r of e){if(t.dryRun===!0){o.push({path:r.path,success:!0,skipped:!1});continue}try{let e=i.dirname(r.path);if(n.mkdirSync(e,{recursive:!0}),r.ifExists===`skip`&&n.existsSync(r.path)){o.push({path:r.path,success:!0,skipped:!0});continue}if(r.ifExists===`error`&&n.existsSync(r.path))throw Error(`Refusing to overwrite existing file: ${r.path}`);if(r.symlinkTarget!=null){n.existsSync(r.path)&&n.rmSync(r.path,{force:!0,recursive:!1}),n.symlinkSync(r.symlinkTarget,r.path,`file`),o.push({path:r.path,success:!0});continue}let s=await a.convertContent(r,t);by(s)?n.writeFileSync(r.path,s):n.writeFileSync(r.path,s,`utf8`),o.push({path:r.path,success:!0})}catch(e){o.push({path:r.path,success:!1,error:e})}}let s={files:o,dirs:[]};r.set(a.name,s)}return r}async function Dy(e,t){let n=[],r=[],i=[],a=[];Ty(e,t.pluginOptions);for(let n of e){let e=await n.declareOutputFiles({...t,dryRun:!0});for(let t of e)t.scope===`global`?a.push(t.path):r.push(t.path)}return{projectDirs:n,projectFiles:r,globalDirs:i,globalFiles:a}}var Oy=class extends Error{nodeName;missingDependency;constructor(e,t){super(`Node "${e}" depends on missing dependency "${t}"`),this.name=`MissingDependencyError`,this.nodeName=e,this.missingDependency=t}},ky=class extends Error{cyclePath;constructor(e){super(`Circular dependency detected: ${e.join(` -> `)}`),this.name=`CircularDependencyError`,this.cyclePath=[...e]}},Ay=class extends Cv{declarativeOutput=!0;outputCapabilities;globalConfigDir;outputFileName;treatWorkspaceRootProjectAsProject;indexignore;commandsConfig;subAgentsConfig;commandOutputEnabled;subAgentOutputEnabled;skillsConfig;skillOutputEnabled;toolPreset;rulesConfig;ruleOutputEnabled;cleanupConfig;supportsBlankLineAfterFrontMatter;registryWriterCache=new Map;constructor(e,t){super(e,oh.Output,t?.dependsOn),this.globalConfigDir=t?.globalConfigDir??``,this.outputFileName=t?.outputFileName??``,this.treatWorkspaceRootProjectAsProject=t?.treatWorkspaceRootProjectAsProject??!1,this.indexignore=t?.indexignore;let n=t?.commands?.transformFrontMatter;this.commandOutputEnabled=t?.commands!=null,this.commandsConfig={subDir:t?.commands?.subDir??`commands`,sourceScopes:t?.commands?.sourceScopes??[`project`,`global`],...n!=null&&{transformFrontMatter:n}},this.subAgentOutputEnabled=t?.subagents!=null,this.subAgentsConfig={subDir:t?.subagents?.subDir??`agents`,sourceScopes:t?.subagents?.sourceScopes??[`project`,`global`],includePrefix:t?.subagents?.includePrefix??!0,linkSymbol:t?.subagents?.linkSymbol??`-`,ext:t?.subagents?.ext??`.md`,...t?.subagents?.transformFrontMatter!=null&&{transformFrontMatter:t.subagents.transformFrontMatter}},this.skillOutputEnabled=t?.skills!=null,this.skillsConfig={subDir:t?.skills?.subDir??`skills`,sourceScopes:t?.skills?.sourceScopes??[`project`,`global`]},this.toolPreset=t?.toolPreset,this.ruleOutputEnabled=t?.rules!=null,this.rulesConfig={...t?.rules,sourceScopes:t?.rules?.sourceScopes??[`project`,`global`]},this.cleanupConfig=t?.cleanup??{},this.supportsBlankLineAfterFrontMatter=t?.supportsBlankLineAfterFrontMatter??!0,this.outputCapabilities=t?.capabilities==null?this.buildInferredCapabilities():this.normalizeCapabilities(t.capabilities)}buildInferredCapabilities(){let e={};return this.outputFileName.length>0&&(e.prompt={scopes:[`project`,`global`],singleScope:!1}),this.ruleOutputEnabled&&(e.rules={scopes:this.rulesConfig.sourceScopes??[`project`,`global`],singleScope:!1}),this.commandOutputEnabled&&(e.commands={scopes:this.commandsConfig.sourceScopes,singleScope:!0}),this.subAgentOutputEnabled&&(e.subagents={scopes:this.subAgentsConfig.sourceScopes,singleScope:!0}),this.skillOutputEnabled&&(e.skills={scopes:this.skillsConfig.sourceScopes,singleScope:!0}),e}normalizeCapabilities(e){let t={};for(let n of yy){let r=e[n];if(r==null)continue;let i=this.normalizeCapability(r);i!=null&&(t[n]=i)}return t}normalizeCapability(e){let t=[];for(let n of e.scopes)t.includes(n)||t.push(n);if(t.length!==0)return{scopes:t,singleScope:e.singleScope}}resolvePromptSourceProjectConfig(e){let t=this.getConcreteProjects(e);return t.find(e=>e.isPromptSourceProject===!0)?.projectConfig??t[0]?.projectConfig}getConcreteProjects(e){return e.collectedOutputContext.workspace.projects.filter(e=>e.isWorkspaceRootProject!==!0)}isProjectPromptOutputTarget(e){return e.isPromptSourceProject!==!0}getProjectOutputProjects(e){let t=[...this.getConcreteProjects(e)];if(!this.treatWorkspaceRootProjectAsProject)return t;let n=this.getWorkspaceRootProject(e);return n!=null&&t.push(n),t}getProjectPromptOutputProjects(e){return this.getProjectOutputProjects(e).filter(e=>this.isProjectPromptOutputTarget(e))}getWorkspaceRootProject(e){return e.collectedOutputContext.workspace.projects.find(e=>e.isWorkspaceRootProject===!0)}resolveProjectRootDir(e,t){if(t.isWorkspaceRootProject===!0)return this.resolveDirectoryPath(e.collectedOutputContext.workspace.directory);let n=t.dirFromWorkspacePath;if(n!=null)return this.resolveDirectoryPath(n)}resolveProjectConfigDir(e,t){let n=this.resolveProjectRootDir(e,t);if(n!=null)return this.globalConfigDir.length===0?n:i.join(n,this.globalConfigDir)}isRelativePath(e){return e.pathKind===ch.Relative}toRelativePath(e){return e.path}resolveFullPath(e,t){let n=this.resolveDirectoryPath(e),r=t??this.outputFileName;return r?i.join(n,r):n}resolveDirectoryPath(e){return e.pathKind===ch.Absolute?e.path:`basePath`in e?i.resolve(e.basePath,e.path):i.resolve(t.cwd(),e.path)}getWorkspaceConfigDir(e){let t=this.resolveDirectoryPath(e.collectedOutputContext.workspace.directory);return i.join(t,this.globalConfigDir)}createRelativePath(e,t,n){return i.join(t,e)}createFileRelativePath(e,t){return i.join(e,t)}getGlobalConfigDir(){return i.join(this.getHomeDir(),this.globalConfigDir)}getXdgConfigHomeDir(){let e=t.env.XDG_CONFIG_HOME;return typeof e==`string`&&e.trim().length>0?e:i.join(this.getHomeDir(),`.config`)}getHomeDir(){return c.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)}getIgnoreOutputPath(){if(this.indexignore!=null)return this.indexignore}resolveCleanupScopeBasePaths(e,t){if(e===`global`)return[this.getHomeDir()];if(e===`xdgConfig`)return[this.getXdgConfigHomeDir()];let n=[];for(let e of this.getProjectOutputProjects(t)){let r=this.resolveProjectRootDir(t,e);r!=null&&n.push(r)}return n}resolveCleanupDeclaredPath(e,t){return i.isAbsolute(t)?i.resolve(t):t===`~`?this.getHomeDir():t.startsWith(`~/`)||t.startsWith(`~\\`)?i.resolve(this.getHomeDir(),t.slice(2)):i.resolve(e,t)}normalizeGlobPattern(e){return e.replaceAll(`\\`,`/`)}buildCleanupTargetsFromScopeConfig(e,t,n){if(e==null)return[];let r=[],a=[`project`,`global`,`xdgConfig`],o=(e,a,o)=>{if(o==null||o.length===0)return;let s=this.resolveCleanupScopeBasePaths(e,n);for(let n of o)for(let o of s){let s=i.isAbsolute(n)?i.resolve(n):this.resolveCleanupDeclaredPath(o,n);r.push({path:a===`glob`?this.normalizeGlobPattern(s):s,kind:a,scope:e,label:`${t}.${e}`})}};for(let t of a){let n=e[t];n!=null&&(o(t,`file`,n.files),o(t,`directory`,n.dirs),o(t,`glob`,n.globs))}return r}resolveFrontMatterBlankLineAfter(e){return this.supportsBlankLineAfterFrontMatter?e?.pluginOptions?.frontMatter?.blankLineAfter??!0:!0}buildMarkdownContent(e,t,n){return Bm(t,e,{blankLineAfter:this.resolveFrontMatterBlankLineAfter(n)})}buildMarkdownContentWithRaw(e,t,n,r){return t!=null&&Object.keys(t).length>0?this.buildMarkdownContent(e,t,r):n!=null&&n.length>0?Hm(n,e,{blankLineAfter:this.resolveFrontMatterBlankLineAfter(r)}):e}extractGlobalMemoryContent(e){return e.collectedOutputContext.globalMemory?.content}combineGlobalWithContent(e,t,n){let{separator:r=`
|
|
217
|
+
`),i;function a(e){return r.stack.push(e),t;function t(){r.stack.pop()}}}function yv(e){throw Error("Cannot handle value `"+e+"`, expected node")}function bv(e){let t=e;throw Error("Cannot handle unknown node `"+t.type+"`")}function xv(e,t){if(e.type===`definition`&&e.type===t.type)return 0}function Sv(e,t){return lv(e,this,t)}function Cv(e,t){return uv(e,this,t)}function wv(e,t){return mv(this,e,t)}function Tv(e,t,n){return{...e.filePath!=null&&{filePath:e.filePath},...e.sourceText!=null&&{sourceText:e.sourceText},...n?.position!=null&&{position:n.position},nodeType:t}}function Ev(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=Lg(n.value.value,t.scope,Tv(t,`mdxJsxAttributeValueExpression`,n));return e===`true`||e===`1`}catch{return!1}return!1}async function Dv(e,t,n){return!Ev(e,t)||e.children.length===0?[]:n(e.children,t)}async function Ov(e,t){if(!Ev(e,t)||e.children.length===0)return[];let n=kv(e.children,t);return n===``?[]:[{type:`text`,value:n}]}function kv(e,t){let n=``;for(let r of e)if(r.type===`text`)n+=r.value;else if(r.type===`mdxTextExpression`)try{n+=Lg(r.value,t.scope,Tv(t,`mdxTextExpression`,r))}catch{}else `children`in r&&Array.isArray(r.children)&&(n+=kv(r.children,t));return n}function Av(){Mg(`Md`,Dv),Mg(`Md.Line`,Ov)}function jv(e){let t=this;t.compiler=n;function n(n){return vv(n,{...t.data(`settings`),...e,extensions:t.data(`toMarkdownExtensions`)||[]})}}var Mv=Qt(Nm(),1);Av();function Nv(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 Pv(e,t){let n=hp(e),r=Nv(t?.globalScope,t?.scope),i=Ng(),a;if(t?.extractMetadata===!0){let i=n.children.find(e=>e.type===`yaml`),o;if(i!=null)try{o=Mv.parse(i.value)}catch{}a=z_(n.children.filter(e=>e.type===`mdxjsEsm`),{...o!=null&&{yamlFrontMatter:o},scope:r,...t?.filePath!=null&&{filePath:t.filePath},sourceText:e}),n.children=n.children.filter(e=>e.type!==`yaml`&&e.type!==`mdxjsEsm`)}let o=await D_(n,{scope:r,components:i,processingStack:[],...t?.basePath!=null&&{basePath:t.basePath},...t?.filePath!=null&&{filePath:t.filePath},sourceText:e}),s=ap().use(Mn,[`yaml`]).use(qs).use(jv,{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}const Fv=/^\s*(```|~~~)/u,Iv=/\r?\n/u,Lv=[/^\s*export\s+default\b/u,/^\s*export\s+const\b/u,/^\s*import\b/u];let Rv=null;function zv(e){return typeof e!=`object`||!e?!1:typeof e.compileMdxToMd==`function`}function Bv(e,t){let n=`@truenine/memory-sync-cli-${t}`;try{let t=e(n).mdCompiler;if(zv(t))return t}catch{}try{let t=o(e.resolve(`${n}/package.json`)),i=r(t).filter(e=>e.startsWith(`napi-md-compiler.`)&&e.endsWith(`.node`)).sort();for(let n of i){let r=e(s(t,n));if(zv(r))return r}}catch{return null}return null}try{let n=e(import.meta.url),{platform:r,arch:i}=t,a={"win32-x64":[`napi-md-compiler.win32-x64-msvc`,`win32-x64-msvc`],"linux-x64":[`napi-md-compiler.linux-x64-gnu`,`linux-x64-gnu`],"linux-arm64":[`napi-md-compiler.linux-arm64-gnu`,`linux-arm64-gnu`],"darwin-arm64":[`napi-md-compiler.darwin-arm64`,`darwin-arm64`],"darwin-x64":[`napi-md-compiler.darwin-x64`,`darwin-x64`]}[`${r}-${i}`];if(a!=null){let[e,t]=a;try{Rv=n(`./${e}.node`)}catch{Rv=Bv(n,t)}}}catch{}async function Vv(e,t){let n=t?.extractMetadata===!0?{...t,extractMetadata:!0}:null,r=Hv(e,t);if(r!=null){if(n!=null){let{metadata:t}=r;return t==null||Wv(r.content)?Pv(e,n):{content:r.content,metadata:t}}return r.content}return n==null?t==null?Pv(e):Pv(e,{...t,extractMetadata:!1}):Pv(e,n)}function Hv(e,t){if(Rv==null)return null;try{let n=Rv.compileMdxToMd(e,Uv(t)),r=JSON.parse(n);return t?.extractMetadata===!0&&r.metadata==null?null:r}catch{return null}}function Uv(e){if(e==null)return null;let t={...e,...e.globalScope==null?{}:{globalScope:{os:e.globalScope.os,env:e.globalScope.env,profile:e.globalScope.profile,tool:e.globalScope.tool}}};return JSON.stringify(t)}function Wv(e){let t;for(let n of e.split(Iv)){let e=Fv.exec(n);if(e?.[1]!=null){let n=e[1];t==null?t=n:t===n&&(t=void 0);continue}if(t==null&&Lv.some(e=>e.test(n)))return!0}return!1}const Gv=/^[\w-]+$/u,Kv=/\r\n?/gu;function qv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Date)}function Jv(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||e instanceof Date}function Yv(e){return e.length>0&&e.every(e=>qv(e))}function Xv(e){if(e==null)return;if(e instanceof Date)return e.toISOString();if(typeof e==`bigint`)return e.toString();if(Array.isArray(e))return e.map(e=>Xv(e)).filter(e=>e!==void 0);if(!qv(e))return e;let t={};for(let[n,r]of Object.entries(e)){let e=Xv(r);e!==void 0&&(t[n]=e)}return t}function Zv(e){return Gv.test(e)}function Qv(e){return Zv(e)?e:JSON.stringify(e)}function $v(e){return e.map(e=>Qv(e)).join(`.`)}function ey(e){let t=e.replaceAll(Kv,`
|
|
218
|
+
`),n=``;for(let e of t)switch(e){case`\\`:n+=`\\\\`;break;case`"`:n+=`\\"`;break;case`\b`:n+=`\\b`;break;case` `:n+=`\\t`;break;case`\f`:n+=`\\f`;break;case`
|
|
219
|
+
`:n+=`
|
|
220
|
+
`;break;default:{let t=e.codePointAt(0);if(t!=null&&t<32){n+=`\\u${t.toString(16).padStart(4,`0`)}`;break}n+=e}}return`"""\n${n}"""`}function ty(e){if(typeof e==`string`)return e.includes(`
|
|
221
|
+
`)||e.includes(`\r`)?ey(e):JSON.stringify(e);if(typeof e==`number`){if(!Number.isFinite(e))throw TypeError(`Unsupported TOML number value: ${e}`);return String(e)}return typeof e==`boolean`?e?`true`:`false`:typeof e==`bigint`?e.toString():JSON.stringify(e.toISOString())}function ny(e){if(e==null)throw TypeError(`TOML inline value cannot be null or undefined`);if(Jv(e))return ty(e);if(Array.isArray(e)){if(Yv(e))throw TypeError(`TOML inline arrays of tables are not supported`);let t=[],n=e;for(let e of n)t.push(ny(e));return`[${t.join(`, `)}]`}let t=[];for(let[n,r]of Object.entries(e))t.push(`${Qv(n)} = ${ny(r)}`);return`{ ${t.join(`, `)} }`}function ry(e,t){if(t==null||t.length===0)return[...e];let n=new Map;for(let[e,r]of t.entries())n.set(r,e);return[...e].sort(([e],[t])=>{let r=n.get(e),i=n.get(t);return r!=null&&i!=null?r-i:r==null?i==null?e.localeCompare(t):1:-1})}function iy(e,t){let n=ry(Object.entries(e),t),r=[],i=[],a=[];for(let[e,t]of n)if(t!=null){if(Array.isArray(t)){if(Yv(t)){a.push([e,t]);continue}r.push([e,t]);continue}if(qv(t)){i.push([e,t]);continue}r.push([e,t])}return{scalarEntries:r,tableEntries:i,arrayTableEntries:a}}function ay(e,t,n,r=!0){let i=[],{scalarEntries:a,tableEntries:o,arrayTableEntries:s}=iy(t,n?.fieldOrder);r&&e.length>0&&i.push(`[${$v(e)}]`);for(let[e,t]of a)i.push(`${Qv(e)} = ${ny(t)}`);for(let[t,r]of o)i.length>0&&i.push(``),i.push(...ay([...e,t],r,n));for(let[t,r]of s)for(let a of r){i.length>0&&i.push(``),i.push(`[[${$v([...e,t])}]]`);let r=ay([...e,t],a,n,!1);i.push(...r)}return i}function oy(e,t){let n=Xv(e);if(!qv(n))throw TypeError(`TOML document root must be an object`);return ay([],n,t).join(`
|
|
222
|
+
`)}function sy(e){let{content:t,bodyFieldName:n,frontMatter:r,fieldNameMap:i,excludedKeys:a,extraFields:o,fieldOrder:s}=e,c=new Set(a??[]),l={};for(let[e,t]of Object.entries(r??{})){if(c.has(e))continue;let n=i?.[e]??e;l[n]=t}if(o!=null)for(let[e,t]of Object.entries(o))l[e]=t;return l[n]=t,oy(l,{...s!=null&&{fieldOrder:s}})}var cy=class{type;name;_log;get log(){return this._log??=Ut(this.name),this._log}dependsOn;constructor(e,t,n){this.name=e,this.type=t,n!=null&&(this.dependsOn=n)}};function ly(e,t){return e==null&&t==null?[]:[...new Set([...e??[],...t??[]])]}function uy(e,t){return e==null||t.length===0?!0:typeof e==`string`?t.includes(e):e.some(e=>t.includes(e))}function dy(e,t){if(e==null&&t==null)return{};let n={};for(let[t,r]of Object.entries(e??{}))n[t]=[...r];for(let[e,r]of Object.entries(t??{})){let t=n[e]??[];n[e]=Object.hasOwn(n,e)?[...new Set([...t,...r])]:[...r]}return n}function fy(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.matchesSeries==`function`&&typeof t.resolveEffectiveIncludeSeries==`function`&&typeof t.resolveSubSeries==`function`}function py(){let n={"win32-x64":`win32-x64-msvc`,"linux-x64":`linux-x64-gnu`,"linux-arm64":`linux-arm64-gnu`,"darwin-arm64":`darwin-arm64`,"darwin-x64":`darwin-x64`}[`${t.platform}-${t.arch}`];if(n==null)return;let r=`@truenine/memory-sync-cli-${n}`,i=`napi-memory-sync-cli.${n}.node`;try{let t=e(import.meta.url),n=[r,`${r}/${i}`,`./${i}`];for(let e of n)try{let n=t(e),r=[n,n?.default,n?.config];for(let e of r)if(fy(e))return e}catch{}}catch{}}const{resolveEffectiveIncludeSeries:my,matchesSeries:hy,resolveSubSeries:gy}=py()??{resolveEffectiveIncludeSeries:ly,matchesSeries:uy,resolveSubSeries:dy};function $(e,t,n){let r=my(t?.includeSeries,t?.[n]?.includeSeries);return e.filter(e=>hy(e.seriName,r))}function _y(e){let t=e.replaceAll(/\.\/+/g,``);return t=t.replaceAll(/\/+$/g,``),t}function vy(e,t){return t.startsWith(`**/`)?`${e}/${t}`:t.startsWith(`*`)?`${e}/**/${t}`:`${e}/${t}`}function yy(e,t){for(let n of t){let t=n.replaceAll(/\/+$/g,``),r=[{prefix:t,pattern:`${t}/`},{prefix:t,pattern:`${t}\\`}];for(let{prefix:t,pattern:n}of r)if(e.startsWith(n))return{prefix:t,baseGlob:e.slice(n.length)};if(e===t)return{prefix:t,baseGlob:`**/*`}}return{prefix:null,baseGlob:e}}function by(e,t){let n=gy(t?.subSeries,t?.rules?.subSeries);if(Object.keys(n).length===0)return e;let r={};for(let[e,t]of Object.entries(n)){let n=_y(e);r[n]=t}let i=Object.keys(r);return e.map(e=>{if(e.seriName==null)return e;let t=[];for(let[n,i]of Object.entries(r))(Array.isArray(e.seriName)?e.seriName.some(e=>i.includes(e)):i.includes(e.seriName))&&t.push(n);if(t.length===0)return e;let n=[];for(let r of e.globs){let{prefix:e,baseGlob:a}=yy(r,i);e!=null&&n.push(r);for(let r of t){if(r===e)continue;let t=vy(r,a);n.includes(t)||n.push(t)}}return{...e,globs:n}})}function xy(e){let t=i.join(e,`.git`);if(!n.existsSync(t))return null;let r=n.lstatSync(t);if(r.isDirectory())return i.join(t,`info`);if(r.isFile())try{let r=n.readFileSync(t,`utf8`).trim(),a=/^gitdir: (.+)$/.exec(r);if(a?.[1]!=null){let t=i.resolve(e,a[1]);return i.join(t,`info`)}}catch{}return null}function Sy(e,t=5){let r=[],a=new Set([`node_modules`,`.turbo`,`dist`,`build`,`out`,`.cache`]);function o(s,c){if(c>t)return;let l;try{let e=n.readdirSync(s,{withFileTypes:!0});if(!Array.isArray(e))return;l=e}catch{return}l.some(e=>e.name===`.git`)&&s!==e&&r.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),r}const Cy={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 wy=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}({}),Ty=function(e){return e.Win=`win`,e.Mac=`mac`,e.Linux=`linux`,e.Unknown=`unknown`,e}({});var Ey=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=c.platform();return{platform:e,arch:c.arch(),hostname:c.hostname(),homedir:c.homedir(),tmpdir:c.tmpdir(),type:c.type(),release:c.release(),shellKind:this.detectShellKind(),kind:this.detectOsKind(e)}}detectOsKind(e){switch(e){case`win32`:return Ty.Win;case`darwin`:return Ty.Mac;case`linux`:case`freebsd`:case`openbsd`:case`sunos`:case`aix`:return Ty.Linux;default:return Ty.Unknown}}detectShellKind(){let e=(t.env.SHELL??t.env.ComSpec??``).toLowerCase();return e.includes(`bash`)?wy.Bash:e.includes(`zsh`)?wy.Zsh:e.includes(`fish`)?wy.Fish:e.includes(`pwsh`)?wy.Pwsh:e.includes(`powershell`)?wy.PowerShell:e.includes(`cmd`)?wy.Cmd:e.endsWith(`/sh`)?wy.Sh:wy.Unknown}collectEnvContext(){return{...t.env}}collectProfile(){return this.userConfig?.profile==null?{}:this.userConfig.profile}collectToolReferences(){let e={...Cy.default};return this.toolPreset===`claudeCode`?{...e,...Cy.claudeCode}:this.toolPreset===`kiro`?{...e,...Cy.kiro}:e}createMdComponent(){let e=(e=>e.when===!1?null:e.children);return e.Line=e=>e.when===!1?null:e.children,e}};let Dy=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 Oy=class{registrations=[];globalScope=null;setGlobalScope(e){this.globalScope=e}getGlobalScope(){return this.globalScope}register(e,t,n=Dy.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}resolve(e){let t=this.merge();return e.replaceAll(/\$\{([^}]+)\}/g,(e,n)=>{let r=n.split(`.`),i=t;for(let e of r)i=i?.[e];return i==null?`\${${n}}`:String(i)})}clear(){this.registrations.length=0,this.globalScope=null}};function ky(e){return e.replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/gu,``)}function Ay(e){let t=ky(e);return t.length===0?``:t.split(`/`).filter(e=>e.length>0).join(`-`)}function jy(e){let t=ky(e),n=t.split(`/`).filter(e=>e.length>0),r=n.at(-1)??t,i=n.slice(0,-1),a=Ay(t),o=i.length>0?i.join(`-`):void 0;return{...o!=null&&{agentPrefix:o},agentName:r,canonicalName:a.length>0?a:r}}function My(e){return e.skillName.trim().length>0?e.skillName:e.dir.getDirectoryName()}function Ny(e){return e.canonicalName.trim().length>0?e.canonicalName:Ay(e.agentPrefix!=null&&e.agentPrefix.length>0?`${e.agentPrefix}-${e.agentName}`:e.agentName)}const Py=[`project`,`global`];function Fy(e){if(e==null)return[];if(typeof e==`string`)return[e];let t=[];for(let n of e)t.includes(n)||t.push(n);return t}function Iy(e,t){let n=new Map;for(let[e,r]of t.entries())n.set(r,e);return[...e].sort((e,t)=>(n.get(e)??2**53-1)-(n.get(t)??2**53-1))}function Ly(e){let{requestedScopes:t,defaultScopes:n,supportedScopes:r,singleScope:i,availableScopes:a,priority:o=Py}=e,s=Fy(t),c=Fy(n),l=new Set(Fy(r)),u=(s.length>0?s:c).filter(e=>l.has(e));if(u.length===0)return[];let d=Iy(u,o);if(!i)return d;if(a!=null&&a.length>0){let e=new Set(a),t=d.find(t=>e.has(t));return t==null?[]:[t]}let[f]=d;return f==null?[]:[f]}const Ry=p.object({src:p.string(),dist:p.string()}),zy=p.object({dir:p.string().default(`aindex`),skills:Ry,commands:Ry,subAgents:Ry,rules:Ry,globalPrompt:Ry,workspacePrompt:Ry,app:Ry,ext:Ry,arch:Ry}),By=p.object({includeSeriesPrefix:p.boolean().optional(),seriesSeparator:p.string().optional()}),Vy=p.object({includeSeriesPrefix:p.boolean().optional(),pluginOverrides:p.record(p.string(),By).optional()}),Hy=p.enum([`project`,`global`]),Uy=p.union([Hy,p.array(Hy).min(1)]),Wy=p.object({prompt:Uy.optional(),rules:Uy.optional(),commands:Uy.optional(),subagents:Uy.optional(),skills:Uy.optional(),mcp:Uy.optional()}),Gy=p.object({plugins:p.record(p.string(),Wy).optional()}),Ky=p.object({blankLineAfter:p.boolean().optional()}),qy=p.enum([`direct`,`recursive`]),Jy=p.enum([`path`,`glob`]),Yy=p.object({path:p.string(),protectionMode:qy,matcher:Jy.optional(),reason:p.string().optional()}),Xy=p.object({rules:p.array(Yy).optional()}),Zy=p.object({name:p.string().optional(),username:p.string().optional(),gender:p.string().optional(),birthday:p.string().optional()}).catchall(p.unknown()),Qy=p.object({version:p.string().optional(),workspaceDir:p.string().optional(),aindex:zy.optional(),logLevel:p.enum([`trace`,`debug`,`info`,`warn`,`error`]).optional(),commandSeriesOptions:Vy.optional(),outputScopes:Gy.optional(),frontMatter:Ky.optional(),cleanupProtection:Xy.optional(),profile:Zy.optional()}),$y=p.object({names:p.array(p.string()).optional()}),eb=p.object({includeSeries:p.array(p.string()).optional(),subSeries:p.record(p.string(),p.array(p.string())).optional()});p.object({mcp:$y.optional(),includeSeries:p.array(p.string()).optional(),subSeries:p.record(p.string(),p.array(p.string())).optional(),rules:eb.optional(),skills:eb.optional(),subAgents:eb.optional(),commands:eb.optional()}),p.object({});function tb(e,t){let n=t==null?``:` in ${t}`;return e==null||e===`project`||e===`global`?{valid:!0,errors:[],warnings:[]}:{valid:!1,errors:[`Field "scope" must be "project" or "global"${n}`],warnings:[]}}function nb(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 rb(e,t){let n=t==null?``:` in ${t}`,r=[],i=[];!(`description`in e)||e.description==null?r.push(`Missing required field "description"${n}`):(typeof e.description!=`string`||e.description.trim().length===0)&&r.push(`Required field "description" cannot be empty${n}`),e.enabled??i.push(`Using default value for optional field "enabled": true${n}`),e.keywords??i.push(`Using default value for optional field "keywords": []${n}`);let a=tb(e.scope,t);return r.push(...a.errors),{valid:r.length===0,errors:r,warnings:i}}function ib(e,t){let n=nb(e,{requiredFields:[],optionalDefaults:{},filePath:t}),r=tb(e.scope,t);return{valid:n.valid&&r.valid,errors:[...n.errors,...r.errors],warnings:n.warnings}}function ab(e,t){let n=nb(e,{requiredFields:[`description`],optionalDefaults:{},filePath:t}),r=tb(e.scope,t);return{valid:n.valid&&r.valid,errors:[...n.errors,...r.errors],warnings:n.warnings}}function ob(e,t){let n=[],r=[],i=t==null?``:` in ${t}`;!Array.isArray(e.globs)||e.globs.length===0?n.push(`Missing or empty required field "globs"${i}`):e.globs.every(e=>typeof e==`string`)||n.push(`Field "globs" must be an array of strings${i}`),(typeof e.description!=`string`||e.description.length===0)&&n.push(`Missing or empty required field "description"${i}`);let{scope:a,seriName:o}=e,s=tb(a,t);return n.push(...s.errors),a??r.push(`Using default value for optional field "scope": "project"${i}`),o!=null&&typeof o!=`string`&&!Array.isArray(o)&&n.push(`Field "seriName" must be a string or string array${i}`),{valid:n.length===0,errors:n,warnings:r}}function sb(e){return{workspace:{directory:e.workspace.directory,projects:[...e.workspace.projects]},...e.skills!=null&&{skills:[...e.skills]},...e.commands!=null&&{commands:[...e.commands]},...e.subAgents!=null&&{subAgents:[...e.subAgents]},...e.rules!=null&&{rules:[...e.rules]},...e.readmePrompts!=null&&{readmePrompts:[...e.readmePrompts]},...e.globalMemory!=null&&{globalMemory:e.globalMemory},...e.vscodeConfigFiles!=null&&{vscodeConfigFiles:[...e.vscodeConfigFiles]},...e.jetbrainsConfigFiles!=null&&{jetbrainsConfigFiles:[...e.jetbrainsConfigFiles]},...e.editorConfigFiles!=null&&{editorConfigFiles:[...e.editorConfigFiles]},...e.aiAgentIgnoreConfigFiles!=null&&{aiAgentIgnoreConfigFiles:[...e.aiAgentIgnoreConfigFiles]},...e.globalGitIgnore!=null&&{globalGitIgnore:e.globalGitIgnore},...e.shadowGitExclude!=null&&{shadowGitExclude:e.shadowGitExclude},...e.aindexDir!=null&&{aindexDir:e.aindexDir}}}const cb={Readme:{src:`rdm.mdx`,out:`README.md`},CodeOfConduct:{src:`coc.mdx`,out:`CODE_OF_CONDUCT.md`},Security:{src:`security.mdx`,out:`SECURITY.md`}},lb=[`prompt`,`rules`,`commands`,`subagents`,`skills`,`mcp`];function ub(e){return f.isBuffer(e)}function db(e){if(typeof e==`string`)return[e];let t=[];for(let n of e)t.includes(n)||t.push(n);return t}function fb(e,t){return t?.outputScopes?.plugins?.[e]}function pb(e){for(let t of lb){let n=e.outputCapabilities[t];if(n!=null&&n.scopes.length===0)throw Error(`Plugin ${e.name} declares empty scopes for topic "${t}"`)}}function mb(e,t){let n=fb(e.name,t);if(n!=null)for(let t of lb){let r=n[t];if(r==null)continue;let i=e.outputCapabilities[t];if(i==null)throw Error(`Invalid outputScopes configuration: outputScopes.plugins.${e.name}.${t} is set, but plugin ${e.name} does not support topic "${t}".`);let a=db(r);if(i.singleScope&&a.length>1){let n=a.join(`, `);throw Error(`Invalid outputScopes configuration: outputScopes.plugins.${e.name}.${t} is single-scope and cannot request multiple scopes [${n}].`)}let o=new Set(i.scopes),s=a.filter(e=>!o.has(e));if(s.length>0){let n=i.scopes.join(`, `),r=s.join(`, `);throw Error(`Invalid outputScopes configuration: outputScopes.plugins.${e.name}.${t} requests unsupported scopes [${r}]. Allowed scopes: [${n}].`)}}}function hb(e,t){for(let n of e)pb(n),mb(n,t)}async function gb(e,t){hb(e,t.pluginOptions);let n=await Promise.all(e.map(async e=>[e,await e.declareOutputFiles(t)]));return new Map(n)}async function _b(e,t,r){let a=new Map,o=r??await gb(e,t);for(let r of e){let e=o.get(r)??[],s=[];for(let a of e){if(t.dryRun===!0){s.push({path:a.path,success:!0,skipped:!1});continue}try{let e=i.dirname(a.path);if(n.mkdirSync(e,{recursive:!0}),a.ifExists===`skip`&&n.existsSync(a.path)){s.push({path:a.path,success:!0,skipped:!0});continue}if(a.ifExists===`error`&&n.existsSync(a.path))throw Error(`Refusing to overwrite existing file: ${a.path}`);if(a.symlinkTarget!=null){n.existsSync(a.path)&&n.rmSync(a.path,{force:!0,recursive:!1}),n.symlinkSync(a.symlinkTarget,a.path,`file`),s.push({path:a.path,success:!0});continue}let o=await r.convertContent(a,t);ub(o)?n.writeFileSync(a.path,o):n.writeFileSync(a.path,o,`utf8`),s.push({path:a.path,success:!0})}catch(e){s.push({path:a.path,success:!1,error:e})}}let c={files:s,dirs:[]};a.set(r.name,c)}return a}async function vb(e,t,n){let r=[],i=[],a=[],o=[],s=n==null?Array.from(await gb(e,{...t,dryRun:!0}),([,e])=>e):[...n.values()];for(let e of s)for(let t of e)t.scope===`global`?o.push(t.path):i.push(t.path);return{projectDirs:r,projectFiles:i,globalDirs:a,globalFiles:o}}var yb=class extends Error{nodeName;missingDependency;constructor(e,t){super(`Node "${e}" depends on missing dependency "${t}"`),this.name=`MissingDependencyError`,this.nodeName=e,this.missingDependency=t}},bb=class extends Error{cyclePath;constructor(e){super(`Circular dependency detected: ${e.join(` -> `)}`),this.name=`CircularDependencyError`,this.cyclePath=[...e]}},xb=class extends cy{declarativeOutput=!0;outputCapabilities;globalConfigDir;outputFileName;treatWorkspaceRootProjectAsProject;indexignore;commandsConfig;subAgentsConfig;commandOutputEnabled;subAgentOutputEnabled;skillsConfig;skillOutputEnabled;toolPreset;rulesConfig;ruleOutputEnabled;cleanupConfig;supportsBlankLineAfterFrontMatter;registryWriterCache=new Map;warnedDeprecatedSubAgentFileNameSource=!1;constructor(e,t){super(e,mh.Output,t?.dependsOn),this.globalConfigDir=t?.globalConfigDir??``,this.outputFileName=t?.outputFileName??``,this.treatWorkspaceRootProjectAsProject=t?.treatWorkspaceRootProjectAsProject??!1,this.indexignore=t?.indexignore,this.commandOutputEnabled=t?.commands!=null,this.commandsConfig=this.createCommandsConfig(t?.commands),this.subAgentOutputEnabled=t?.subagents!=null,this.subAgentsConfig=this.createSubAgentsConfig(t?.subagents),this.skillOutputEnabled=t?.skills!=null,this.skillsConfig=this.createSkillsConfig(t?.skills),this.toolPreset=t?.toolPreset,this.ruleOutputEnabled=t?.rules!=null,this.rulesConfig={...t?.rules,sourceScopes:t?.rules?.sourceScopes??[`project`,`global`]},this.cleanupConfig=t?.cleanup??{},this.supportsBlankLineAfterFrontMatter=t?.supportsBlankLineAfterFrontMatter??!0,this.outputCapabilities=t?.capabilities==null?this.buildInferredCapabilities():this.normalizeCapabilities(t.capabilities)}createCommandsConfig(e){return{subDir:e?.subDir??`commands`,sourceScopes:e?.sourceScopes??[`project`,`global`],...e?.scopeRemap!=null&&{scopeRemap:e.scopeRemap},...e?.transformFrontMatter!=null&&{transformFrontMatter:e.transformFrontMatter}}}createSubAgentsConfig(e){return{subDir:e?.subDir??`agents`,sourceScopes:e?.sourceScopes??[`project`,`global`],includePrefix:e?.includePrefix??!0,linkSymbol:e?.linkSymbol??`-`,ext:e?.ext??`.md`,artifactFormat:e?.artifactFormat??`markdown`,fileNameSource:e?.fileNameSource??`derivedPath`,...e?.bodyFieldName!=null&&{bodyFieldName:e.bodyFieldName},...e?.fieldNameMap!=null&&{fieldNameMap:e.fieldNameMap},...e?.excludedFrontMatterFields!=null&&{excludedFrontMatterFields:e.excludedFrontMatterFields},...e?.extraFields!=null&&{extraFields:e.extraFields},...e?.fieldOrder!=null&&{fieldOrder:e.fieldOrder},...e?.scopeRemap!=null&&{scopeRemap:e.scopeRemap},...e?.transformFrontMatter!=null&&{transformFrontMatter:e.transformFrontMatter}}}createSkillsConfig(e){return{subDir:e?.subDir??`skills`,sourceScopes:e?.sourceScopes??[`project`,`global`],...e?.scopeRemap!=null&&{scopeRemap:e.scopeRemap}}}buildInferredCapabilities(){let e={};return this.outputFileName.length>0&&(e.prompt={scopes:[`project`,`global`],singleScope:!1}),this.ruleOutputEnabled&&(e.rules={scopes:this.rulesConfig.sourceScopes??[`project`,`global`],singleScope:!1}),this.commandOutputEnabled&&(e.commands={scopes:this.commandsConfig.sourceScopes,singleScope:!0}),this.subAgentOutputEnabled&&(e.subagents={scopes:this.subAgentsConfig.sourceScopes,singleScope:!0}),this.skillOutputEnabled&&(e.skills={scopes:this.skillsConfig.sourceScopes,singleScope:!0}),e}normalizeCapabilities(e){let t={};for(let n of lb){let r=e[n];if(r==null)continue;let i=this.normalizeCapability(r);i!=null&&(t[n]=i)}return t}normalizeCapability(e){let t=[];for(let n of e.scopes)t.includes(n)||t.push(n);if(t.length!==0)return{scopes:t,singleScope:e.singleScope}}resolvePromptSourceProjectConfig(e){let t=this.getConcreteProjects(e);return t.find(e=>e.isPromptSourceProject===!0)?.projectConfig??t[0]?.projectConfig}getConcreteProjects(e){return e.collectedOutputContext.workspace.projects.filter(e=>e.isWorkspaceRootProject!==!0)}isProjectPromptOutputTarget(e){return e.isPromptSourceProject!==!0}getProjectOutputProjects(e){let t=[...this.getConcreteProjects(e)];if(!this.treatWorkspaceRootProjectAsProject)return t;let n=this.getWorkspaceRootProject(e);return n!=null&&t.push(n),t}getProjectPromptOutputProjects(e){return this.getProjectOutputProjects(e).filter(e=>this.isProjectPromptOutputTarget(e))}getWorkspaceRootProject(e){return e.collectedOutputContext.workspace.projects.find(e=>e.isWorkspaceRootProject===!0)}resolveProjectRootDir(e,t){if(t.isWorkspaceRootProject===!0)return this.resolveDirectoryPath(e.collectedOutputContext.workspace.directory);let n=t.dirFromWorkspacePath;if(n!=null)return this.resolveDirectoryPath(n)}resolveProjectConfigDir(e,t){let n=this.resolveProjectRootDir(e,t);if(n!=null)return this.globalConfigDir.length===0?n:i.join(n,this.globalConfigDir)}isRelativePath(e){return e.pathKind===gh.Relative}toRelativePath(e){return e.path}resolveFullPath(e,t){let n=this.resolveDirectoryPath(e),r=t??this.outputFileName;return r?i.join(n,r):n}resolveDirectoryPath(e){return e.pathKind===gh.Absolute?e.path:`basePath`in e?i.resolve(e.basePath,e.path):i.resolve(t.cwd(),e.path)}getWorkspaceConfigDir(e){let t=this.resolveDirectoryPath(e.collectedOutputContext.workspace.directory);return i.join(t,this.globalConfigDir)}createRelativePath(e,t,n){return i.join(t,e)}createFileRelativePath(e,t){return i.join(e,t)}getGlobalConfigDir(){return i.join(this.getHomeDir(),this.globalConfigDir)}getXdgConfigHomeDir(){let e=t.env.XDG_CONFIG_HOME;return typeof e==`string`&&e.trim().length>0?e:i.join(this.getHomeDir(),`.config`)}getHomeDir(){return c.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)}getIgnoreOutputPath(){if(this.indexignore!=null)return this.indexignore}resolveCleanupScopeBasePaths(e,t){if(e===`global`)return[this.getHomeDir()];if(e===`xdgConfig`)return[this.getXdgConfigHomeDir()];let n=[];for(let e of this.getProjectOutputProjects(t)){let r=this.resolveProjectRootDir(t,e);r!=null&&n.push(r)}return n}resolveCleanupDeclaredPath(e,t){return i.isAbsolute(t)?i.resolve(t):t===`~`?this.getHomeDir():t.startsWith(`~/`)||t.startsWith(`~\\`)?i.resolve(this.getHomeDir(),t.slice(2)):i.resolve(e,t)}normalizeGlobPattern(e){return e.replaceAll(`\\`,`/`)}buildCleanupTargetsFromScopeConfig(e,t,n){if(e==null)return[];let r=[],a=[`project`,`global`,`xdgConfig`],o=(e,a,o)=>{if(o==null||o.length===0)return;let s=this.resolveCleanupScopeBasePaths(e,n);for(let n of o)for(let o of s){let s=i.isAbsolute(n)?i.resolve(n):this.resolveCleanupDeclaredPath(o,n);r.push({path:a===`glob`?this.normalizeGlobPattern(s):s,kind:a,scope:e,label:`${t}.${e}`})}};for(let t of a){let n=e[t];n!=null&&(o(t,`file`,n.files),o(t,`directory`,n.dirs),o(t,`glob`,n.globs))}return r}resolveFrontMatterBlankLineAfter(e){return this.supportsBlankLineAfterFrontMatter?e?.pluginOptions?.frontMatter?.blankLineAfter??!0:!0}buildMarkdownContent(e,t,n){return Jm(t,e,{blankLineAfter:this.resolveFrontMatterBlankLineAfter(n)})}buildMarkdownContentWithRaw(e,t,n,r){return t!=null&&Object.keys(t).length>0?this.buildMarkdownContent(e,t,r):n!=null&&n.length>0?Xm(n,e,{blankLineAfter:this.resolveFrontMatterBlankLineAfter(r)}):e}buildTomlContent(e){return sy(e)}extractGlobalMemoryContent(e){return e.collectedOutputContext.globalMemory?.content}combineGlobalWithContent(e,t,n){let{separator:r=`
|
|
218
223
|
|
|
219
|
-
`,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}`}transformCommandName(e,t){let{includeSeriesPrefix:n=!0,seriesSeparator:r=`-`}=t??{};return!n||e.commandPrefix==null?`${e.commandName}.md`:`${e.commandPrefix}${r}${e.commandName}.md`}transformSubAgentName(e,t){let n=t?.includePrefix??this.subAgentsConfig.includePrefix,r=t?.linkSymbol??this.subAgentsConfig.linkSymbol,i=t?.ext??this.subAgentsConfig.ext,a=i.startsWith(`.`)?i:`.${i}`;return n&&e.agentPrefix!=null&&e.agentPrefix.length>0?`${e.agentPrefix}${r}${e.agentName}${a}`:`${e.agentName}${a}`}getCommandSeriesOptions(e){let t=e.pluginOptions?.commandSeriesOptions,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.getCommandSeriesOptions(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)}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)}normalizeRuleScope(e){return e.scope??`project`}normalizeSourceScope(e){return e===`global`||e===`project`?e:`project`}resolveCommandSourceScope(e){if(e.globalOnly===!0)return`global`;let t=e.yamlFrontMatter?.scope;return this.normalizeSourceScope(t)}resolveSubAgentSourceScope(e){let t=e.yamlFrontMatter?.scope;return this.normalizeSourceScope(t)}resolveSkillSourceScope(e){let t=e.yamlFrontMatter?.scope;return this.normalizeSourceScope(t)}selectSingleScopeItems(e,t,n,r){if(e.length===0)return{items:[]};let[i]=qv({requestedScopes:r,defaultScopes:t,supportedScopes:t,singleScope:!0,availableScopes:[...new Set(e.map(n))]});return i==null?{items:[]}:{selectedScope:i,items:e.filter(e=>n(e)===i)}}selectRuleScopes(e,t){let n=[...new Set(t.map(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))))];return qv({requestedScopes:this.getTopicScopeOverride(e,`rules`),defaultScopes:this.rulesConfig.sourceScopes??[`project`,`global`],supportedScopes:this.rulesConfig.sourceScopes??[`project`,`global`],singleScope:!1,availableScopes:n}).filter(e=>n.includes(e))}selectPromptScopes(e,t=[`project`,`global`],n=t){return qv({requestedScopes:this.getTopicScopeOverride(e,`prompt`),defaultScopes:n,supportedScopes:t,singleScope:!1})}getTopicScopeOverride(e,t){return e.pluginOptions?.outputScopes?.plugins?.[this.name]?.[t]}buildSkillFrontMatter(e,t){let n=e.yamlFrontMatter,r={name:n.name,description:n.description};return`displayName`in n&&n.displayName!=null&&(r.displayName=n.displayName),`keywords`in n&&n.keywords!=null&&n.keywords.length>0&&(r.keywords=n.keywords),`author`in n&&n.author!=null&&(r.author=n.author),`version`in n&&n.version!=null&&(r.version=n.version),(t?.includeTools??!0)&&`allowTools`in n&&n.allowTools!=null&&n.allowTools.length>0&&(r.allowTools=(t?.toolFormat??`array`)===`string`?n.allowTools.join(`,`):n.allowTools),t?.additionalFields!=null&&Object.assign(r,t.additionalFields),r}buildRuleContent(e,t){let n=this.rulesConfig.transformFrontMatter?this.rulesConfig.transformFrontMatter(e):{globs:e.globs.join(`, `)},r=n==null||Object.keys(n).length===0?void 0:n;return this.buildMarkdownContent(e.content,r,t)}buildRuleFileName(e){let t=`${`${this.rulesConfig.prefix??`rule`}${this.rulesConfig.linkSymbol??`-`}`}${e.prefix}${this.rulesConfig.linkSymbol??`-`}${e.ruleName}${this.rulesConfig.ext??`.md`}`;return this.log.trace(`buildRuleFileName`,{plugin:this.name,rulePrefix:e.prefix,ruleName:e.ruleName,prefix:this.rulesConfig.prefix??`rule`,linkSymbol:this.rulesConfig.linkSymbol??`-`,ext:this.rulesConfig.ext??`.md`,result:t}),t}async declareOutputFiles(e){return this.buildDefaultOutputDeclarations(e)}async declareCleanupPaths(e){let t=this.buildCleanupTargetsFromScopeConfig(this.cleanupConfig.delete,`delete`,e),n=this.buildCleanupTargetsFromScopeConfig(this.cleanupConfig.protect,`protect`,e),{excludeScanGlobs:r}=this.cleanupConfig;return t.length===0&&n.length===0&&(r==null||r.length===0)?{}:{...t.length>0&&{delete:t},...n.length>0&&{protect:n},...r!=null&&r.length>0&&{excludeScanGlobs:r}}}async convertContent(e,t){let n=e.source;switch(n.kind){case`projectRootMemory`:case`projectChildMemory`:case`globalMemory`:case`skillReference`:case`ignoreFile`:return n.content;case`command`:return this.buildCommandContent(n.command,t);case`subAgent`:return this.buildSubAgentContent(n.subAgent,t);case`skillMain`:return this.buildSkillMainContent(n.skill,t);case`skillResource`:return n.encoding===`base64`?f.from(n.content,`base64`):n.content;case`rule`:return this.buildRuleContent(n.rule,t);default:throw Error(`Unsupported declaration source for plugin ${this.name}`)}}async buildDefaultOutputDeclarations(e){let t=[],{globalMemory:n,commands:r,subAgents:a,skills:o,rules:s,aiAgentIgnoreConfigFiles:c}=e.collectedOutputContext,l=this.getTransformOptionsFromContext(e),u=this.getIgnoreOutputPath(),d=this.indexignore==null?void 0:c?.find(e=>e.fileName===this.indexignore),f=this.commandOutputEnabled&&r!=null?this.selectSingleScopeItems(r,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)):{items:[]},p=this.subAgentOutputEnabled&&a!=null?this.selectSingleScopeItems(a,this.subAgentsConfig.sourceScopes,e=>this.resolveSubAgentSourceScope(e),this.getTopicScopeOverride(e,`subagents`)):{items:[]},m=this.skillOutputEnabled&&o!=null?this.selectSingleScopeItems(o,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)):{items:[]},h=s??[],g=this.ruleOutputEnabled&&h.length>0?new Set(this.selectRuleScopes(e,h)):new Set,_=new Set(this.selectPromptScopes(e,this.outputCapabilities.prompt?.scopes??[`project`,`global`])),v={project:[],global:[]};for(let e of h)v[this.normalizeSourceScope(this.normalizeRuleScope(e))].push(e);let y=(e,n,r)=>{for(let a of r){let r=a.yamlFrontMatter?.name??a.dir.getDirectoryName(),o=i.join(e,this.skillsConfig.subDir,r);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:a}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.dir.path.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillReference`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}};for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectRootDir(e,n),a=this.resolveProjectConfigDir(e,n);if(r==null||a==null)continue;if(this.outputFileName.length>0&&_.has(`project`)&&this.isProjectPromptOutputTarget(n)&&(n.rootMemoryPrompt!=null&&t.push({path:i.join(r,this.outputFileName),scope:`project`,source:{kind:`projectRootMemory`,content:n.rootMemoryPrompt.content}}),n.childMemoryPrompts!=null))for(let e of n.childMemoryPrompts)t.push({path:this.resolveFullPath(e.dir),scope:`project`,source:{kind:`projectChildMemory`,content:e.content}});let{projectConfig:o}=n;if(f.selectedScope===`project`&&f.items.length>0){let e=$(f.items,o,`commands`);for(let n of e){let e=this.transformCommandName(n,l);t.push({path:i.join(a,this.commandsConfig.subDir,e),scope:`project`,source:{kind:`command`,command:n}})}}if(p.selectedScope===`project`&&p.items.length>0){let e=$(p.items,o,`subAgents`);for(let n of e){let e=this.transformSubAgentName(n);t.push({path:i.join(a,this.subAgentsConfig.subDir,e),scope:`project`,source:{kind:`subAgent`,subAgent:n}})}}if(m.selectedScope===`project`&&m.items.length>0&&y(a,`project`,$(m.items,o,`skills`)),g.has(`project`)){let e=Fv($(v.project,o,`rules`),o),n=i.join(a,this.rulesConfig.subDir??`rules`);for(let r of e)t.push({path:i.join(n,this.buildRuleFileName(r)),scope:`project`,source:{kind:`rule`,rule:r}})}u!=null&&d!=null&&n.isWorkspaceRootProject!==!0&&n.isPromptSourceProject!==!0&&n.dirFromWorkspacePath!=null&&t.push({path:i.join(n.dirFromWorkspacePath.basePath,n.dirFromWorkspacePath.path,u),scope:`project`,source:{kind:`ignoreFile`,content:d.content}})}let b=this.resolvePromptSourceProjectConfig(e);if(f.selectedScope===`global`&&f.items.length>0){let e=$(f.items,b,`commands`),n=this.getGlobalConfigDir();for(let r of e){let e=this.transformCommandName(r,l);t.push({path:i.join(n,this.commandsConfig.subDir,e),scope:`global`,source:{kind:`command`,command:r}})}}if(p.selectedScope===`global`&&p.items.length>0){let e=$(p.items,b,`subAgents`),n=this.getGlobalConfigDir();for(let r of e){let e=this.transformSubAgentName(r);t.push({path:i.join(n,this.subAgentsConfig.subDir,e),scope:`global`,source:{kind:`subAgent`,subAgent:r}})}}if(m.selectedScope===`global`&&m.items.length>0){let e=$(m.items,b,`skills`);y(this.getGlobalConfigDir(),`global`,e)}for(let e of[`global`]){if(!g.has(e))continue;let n=this.getGlobalConfigDir(),r=Fv($(v[e],b,`rules`),b),a=i.join(n,this.rulesConfig.subDir??`rules`);for(let n of r)t.push({path:i.join(a,this.buildRuleFileName(n)),scope:e,source:{kind:`rule`,rule:n}})}return n!=null&&this.outputFileName.length>0&&_.has(`global`)&&t.push({path:i.join(this.getGlobalConfigDir(),this.outputFileName),scope:`global`,source:{kind:`globalMemory`,content:n.content}}),t}async buildCommandContent(e,t){let n=e.content,r=e.yamlFrontMatter,i=!1;if(e.rawMdxContent!=null&&this.toolPreset!=null){this.log.debug(`recompiling command with tool preset`,{file:e.dir.getAbsolutePath(),toolPreset:this.toolPreset,hasRawContent:!0});let t=new Vv({toolPreset:this.toolPreset}).collect(),a=await yv(e.rawMdxContent,{globalScope:t,extractMetadata:!0,basePath:e.dir.basePath,filePath:e.dir.getAbsolutePath()});n=a.content,r=a.metadata.fields,i=!0}let a=this.commandsConfig.transformFrontMatter;if(a==null)throw Error(`commands.transformFrontMatter is required for command output plugin: ${this.name}`);let o=a(e,{isRecompiled:i,...r!=null&&{sourceFrontMatter:r}});return this.buildMarkdownContent(n,o,t)}buildSubAgentContent(e,t){let n=this.subAgentsConfig.transformFrontMatter;if(n!=null){let r=n(e,{...e.yamlFrontMatter!=null&&{sourceFrontMatter:e.yamlFrontMatter}});return this.buildMarkdownContent(e.content,r,t)}return this.buildMarkdownContentWithRaw(e.content,e.yamlFrontMatter,e.rawFrontMatter,t)}buildSkillMainContent(e,t){return this.buildMarkdownContentWithRaw(e.content,e.yamlFrontMatter,e.rawFrontMatter,t)}};const jy={USER_HOME:`~`,WORKSPACE:`$WORKSPACE`},My={AgentsOutput:`AgentsOutputPlugin`,GeminiCLIOutput:`GeminiCLIOutputPlugin`,CursorOutput:`CursorOutputPlugin`,WindsurfOutput:`WindsurfOutputPlugin`,ClaudeCodeCLIOutput:`ClaudeCodeCLIOutputPlugin`,KiroIDEOutput:`KiroCLIOutputPlugin`,OpencodeCLIOutput:`OpencodeCLIOutputPlugin`,OpenAICodexCLIOutput:`CodexCLIOutputPlugin`,DroidCLIOutput:`DroidCLIOutputPlugin`,WarpIDEOutput:`WarpIDEOutputPlugin`,TraeIDEOutput:`TraeIDEOutputPlugin`,TraeCNIDEOutput:`TraeCNIDEOutputPlugin`,QoderIDEOutput:`QoderIDEPluginOutputPlugin`,JetBrainsCodeStyleOutput:`JetBrainsIDECodeStyleConfigOutputPlugin`,JetBrainsAICodexOutput:`JetBrainsAIAssistantCodexOutputPlugin`,AgentSkillsCompactOutput:`GenericSkillsOutputPlugin`,GitExcludeOutput:`GitExcludeOutputPlugin`,ReadmeOutput:`ReadmeMdConfigFileOutputPlugin`,VSCodeOutput:`VisualStudioCodeIDEConfigOutputPlugin`,EditorConfigOutput:`EditorConfigOutputPlugin`,AntigravityOutput:`AntigravityOutputPlugin`},Ny={SKILL:`SKILL.md`,CURSOR_GLOBAL_RULE:`global.mdc`,CURSOR_PROJECT_RULE:`always.md`,MCP_CONFIG:`mcp.json`,CLAUDE_MEMORY:`CLAUDE.md`,WINDSURF_GLOBAL_RULE:`global_rules.md`},Py={RULES:`rules`,COMMANDS:`commands`,SKILLS:`skills`,AGENTS:`agents`,CURSOR_SKILLS:`skills-cursor`},Fy={MD:`.md`,MDC:`.mdc`,MDX:`.mdx`,JSON:`.json`},Iy=[{PRIMARY:`.src.mdx`}.PRIMARY],Ly={zh:Iy,en:Fy.MDX};function Ry(e){return Iy.some(t=>e.endsWith(t))}const zy={CURSOR:`.cursor`,CLAUDE:`.claude`,WINDSURF:`.codeium/windsurf`,WINDSURF_RULES:`.windsurf`},By={CURSOR:`.cursorignore`,WINDSURF:`.codeiumignore`},Vy={CURSOR:new Set([`create-rule`,`create-skill`,`create-subagent`,`migrate-to-skills`,`update-cursor-settings`])};var Hy=class extends Error{kind;nameOfPrompt;sourcePath;expectedDistPath;constructor(e){let{kind:t,name:n,sourcePath:r,expectedDistPath:i}=e;super([`Missing compiled dist prompt for ${t} "${n}".`,...r==null?[]:[`source: ${r}`],`expected dist: ${i}`].join(` `)),this.name=`MissingCompiledPromptError`,this.kind=t,this.nameOfPrompt=n,r!=null&&(this.sourcePath=r),this.expectedDistPath=i}},Uy=class extends Error{filePath;lineNumber;constructor(e,t,n){super(`Compiled prompt still contains residual module syntax at ${e}:${t}: ${n.trim()}`),this.name=`ResidualModuleSyntaxError`,this.filePath=e,this.lineNumber=t}};const Wy=/^\s*(```|~~~)/u,Gy=[/^\s*export\s+default\b/u,/^\s*export\s+const\b/u,/^\s*import\b/u];function Ky(e,t){let n,r=e.split(/\r?\n/u);for(let[e,i]of r.entries()){let r=Wy.exec(i);if(r?.[1]!=null){let e=r[1];n==null?n=e:n===e&&(n=void 0);continue}if(n==null&&Gy.some(e=>e.test(i)))throw new Uy(t,e+1,i)}}function qy(e,t,n={}){let{preferredSourcePath:r,distRootDir:i,srcRootDir:a}=n;if(t==null||t.length===0||r!=null&&r.length>0)return r;if(i==null||a==null)return;let o=e.relative(i,t);if(!(o.startsWith(`..`)||e.isAbsolute(o)))return e.join(a,o.replace(/\.mdx$/u,`.src.mdx`))}function Jy(e){if(e instanceof gg&&e.filePath!=null)return e.filePath;if(!(e instanceof Error)||!(`filePath`in e))return;let{filePath:t}=e;if(typeof t==`string`&&t.length>0)return t}function Yy(e,t){let n=Jy(e)??t.distPath,r=[t.operation??`Prompt compilation failed.`,`prompt kind: ${t.promptKind}`,`logical name: ${t.logicalName}`];return t.entryDistPath!=null&&t.entryDistPath.length>0&&t.entryDistPath!==n&&r.push(`entry dist file: ${t.entryDistPath}`),n!=null&&n.length>0&&r.push(`dist file: ${n}`),r.push(`src file: ${t.srcPath??`<unresolved>`}`),r.push(`diagnostic:`),r.push(e instanceof Error?hg(e):String(e)),r.join(`
|
|
220
|
-
`)}function Xy(e){return e instanceof Hy||e instanceof Uy}var Zy=class{constructor(e,t,n,r){this.fs=e,this.path=t,this.logger=n,this.globalScope=r}async readDirectoryStructure(e,t,n){let r=[],i=[];if(!this.exists(e))return{prompts:r,errors:i};try{let a=this.fs.readdirSync(e,{withFileTypes:!0});for(let o of a){if(!o.isDirectory())continue;let{name:a}=o,s=this.path.join(e,a),c=this.path.join(t,a);try{let e=await this.readEntry(a,s,c,n,!0);e&&r.push(e)}catch(e){if(i.push({path:s,error:e,phase:`read`}),this.logger.error(B({code:`LOCALIZED_PROMPT_ENTRY_READ_FAILED`,title:`Failed to read localized prompt entry`,operation:`read`,targetKind:`${String(n.kind)} prompt entry`,path:s,error:e,details:{entryName:a,promptKind:String(n.kind)}})),Xy(e))throw e}}}catch(t){if(i.push({path:e,error:t,phase:`scan`}),this.logger.error(B({code:`LOCALIZED_PROMPT_DIRECTORY_SCAN_FAILED`,title:`Failed to scan localized prompt source directory`,operation:`scan`,targetKind:`${String(n.kind)} prompt source directory`,path:e,error:t,details:{promptKind:String(n.kind)}})),Xy(t))throw t}return{prompts:r,errors:i}}async readFlatFiles(e,t,n){let r=[],i=[],a=this.exists(e),o=this.exists(t);if(this.logger.debug(`readFlatFiles: srcDir=${e}, exists=${a}`),this.logger.debug(`readFlatFiles: distDir=${t}, exists=${o}`),!a&&!o)return{prompts:r,errors:i};let s=this.normalizeExtensions(n.localeExtensions.zh),c=new Set,l=async(a,o)=>{if(!c.has(a)){c.add(a);try{let i=await this.readFlatEntry(a,e,t,a,n);i&&r.push(i)}catch(e){if(i.push({path:o,error:e,phase:`read`}),this.logger.error(B({code:`LOCALIZED_PROMPT_FILE_READ_FAILED`,title:`Failed to read localized prompt file`,operation:`read`,targetKind:`${String(n.kind)} prompt file`,path:o,error:e,details:{promptKind:String(n.kind),logicalName:a}})),Xy(e))throw e}}},u=async(e,t=``)=>{if(this.exists(e))try{let n=this.fs.readdirSync(e,{withFileTypes:!0});for(let r of n){let n=t?this.path.join(t,r.name):r.name;if(r.isDirectory()){await u(this.path.join(e,r.name),n);continue}let i=this.findMatchingExtension(r.name,s);if(!r.isFile()||i==null)continue;let a=r.name.slice(0,-i.length);await l(t?this.path.join(t,a):a,this.path.join(e,r.name))}}catch(t){if(i.push({path:e,error:t,phase:`scan`}),this.logger.error(B({code:`LOCALIZED_SOURCE_DIRECTORY_SCAN_FAILED`,title:`Failed to scan localized source directory`,operation:`scan`,targetKind:`${String(n.kind)} source directory`,path:e,error:t,details:{promptKind:String(n.kind)}})),Xy(t))throw t}},d=async(e,t=``)=>{if(this.exists(e))try{let n=this.fs.readdirSync(e,{withFileTypes:!0});for(let r of n){let n=t?this.path.join(t,r.name):r.name;if(r.isDirectory()){await d(this.path.join(e,r.name),n);continue}if(!r.isFile()||!r.name.endsWith(`.mdx`))continue;let i=r.name.slice(0,-4);await l(t?this.path.join(t,i):i,this.path.join(e,r.name))}}catch(t){if(i.push({path:e,error:t,phase:`scan`}),this.logger.error(B({code:`LOCALIZED_DIST_DIRECTORY_SCAN_FAILED`,title:`Failed to scan localized dist directory`,operation:`scan`,targetKind:`${String(n.kind)} dist directory`,path:e,error:t,details:{promptKind:String(n.kind)}})),Xy(t))throw t}};return a&&await u(e),o&&await d(t),{prompts:r,errors:i}}async readSingleFile(e,t,n){let r=this.path.basename(e);return this.readFlatEntry(r,this.path.dirname(e),this.path.dirname(t),e,n,!0)}async readEntry(e,t,n,r,i=!0){let{localeExtensions:a,entryFileName:o,createPrompt:s,kind:c}=r,l=o??e,u=this.normalizeExtensions(a.zh),d=this.normalizeExtensions(a.en),f=this.resolveLocalizedPath(t,l,u),p=this.resolveLocalizedPath(t,l,d),m=this.path.join(n,`${l}.mdx`),h=this.exists(f)?f:this.exists(p)?p:void 0,g={promptKind:String(c),logicalName:e,entryDistPath:m,...h!=null&&{srcPath:h}},_=await this.readDistContent(m,s,e,g),v=await this.readLocaleContent(f,`zh`,s,e,String(c)),y=await this.readLocaleContent(p,`en`,s,e,String(c)),b=_!=null,x=v!=null,S=y!=null,C=x?f:S?p:void 0;if(!b&&!x&&!S)return this.logger.warn(st({code:`LOCALIZED_PROMPT_ARTIFACTS_MISSING`,title:`Missing source and dist prompt artifacts for ${e}`,rootCause:z(`tnmsc could not find either the source prompt or the compiled dist prompt for "${e}".`),exactFix:z(`Create the source prompt and rebuild the compiled dist prompt before retrying tnmsc.`),details:{promptKind:String(c),name:e,srcZhPath:f,srcEnPath:p,distPath:m}})),null;if(!b)throw new Hy({kind:String(c),name:e,...C!=null&&{sourcePath:C},expectedDistPath:m});let w=x?{zh:v,...S&&{en:y},default:v,defaultLocale:`zh`}:void 0,T=i?this.scanChildren(n,l,[`.mdx`]):void 0;return{name:e,type:c,...w!=null&&{src:w},...b&&{dist:_},metadata:{hasDist:b,hasMultipleLocales:S,isDirectoryStructure:i,...T&&T.length>0&&{children:T}},paths:{...x&&{zh:f},...S&&{en:p},...b&&{dist:m}}}}async readFlatEntry(e,t,n,r,i,a=!1){let{localeExtensions:o,createPrompt:s,kind:c}=i,l=this.normalizeExtensions(o.zh),u=this.normalizeExtensions(o.en),d=this.resolveLocalizedPath(``,r,l),f=this.resolveLocalizedPath(``,r,u),p=this.path.join(n,`${e}.mdx`),m=a?d:this.path.join(t,d),h=a?f:this.path.join(t,f),g=this.exists(m)?m:this.exists(h)?h:void 0,_={promptKind:String(c),logicalName:e,entryDistPath:p,...g!=null&&{srcPath:g}},v=await this.readDistContent(p,s,e,_),y=await this.readLocaleContent(m,`zh`,s,e,String(c)),b=await this.readLocaleContent(h,`en`,s,e,String(c)),x=v!=null,S=y!=null,C=b!=null,w=S?m:C?h:void 0;if(!x&&!S&&!C)return this.logger.warn(st({code:`LOCALIZED_PROMPT_ARTIFACTS_MISSING`,title:`Missing source and dist prompt artifacts for ${e}`,rootCause:z(`tnmsc could not find either the source prompt or the compiled dist prompt for "${e}".`),exactFix:z(`Create the source prompt and rebuild the compiled dist prompt before retrying tnmsc.`),details:{promptKind:String(c),name:e,srcZhPath:m,srcEnPath:h,distPath:p}})),null;if(!x)throw new Hy({kind:String(c),name:e,...w!=null&&{sourcePath:w},expectedDistPath:p});let T=S?{zh:y,...C&&{en:b},default:y,defaultLocale:`zh`}:void 0;return{name:e,type:c,...T!=null&&{src:T},...x&&{dist:v},metadata:{hasDist:x,hasMultipleLocales:C,isDirectoryStructure:!1},paths:{...S&&{zh:m},...C&&{en:h},...x&&{dist:p}}}}async readLocaleContent(e,t,n,r,i){if(!this.exists(e))return null;try{let i=this.fs.readFileSync(e,`utf8`),a=this.fs.statSync(e),o=await yv(i,{globalScope:this.globalScope,extractMetadata:!0,basePath:this.path.dirname(e),filePath:e});Ky(o.content,e);let s=Wm(i),c=await n(o.content,t,r,o.metadata.fields),l={content:o.content,lastModified:a.mtime,filePath:e};return i.length>0&&Object.assign(l,{rawMdx:i}),s.yamlFrontMatter!=null&&Object.assign(l,{frontMatter:s.yamlFrontMatter}),c!=null&&Object.assign(l,{prompt:c}),l}catch(n){throw this.logger.error(mt({code:`LOCALIZED_SOURCE_PROMPT_READ_FAILED`,title:`Failed to read localized source prompt`,diagnosticText:Yy(n,{operation:`Failed to read localized source prompt.`,promptKind:i,logicalName:r,distPath:e}),details:{promptKind:i,locale:t,filePath:e}})),n}}async readDistContent(e,t,n,r){if(!this.exists(e))return null;try{let r=this.fs.readFileSync(e,`utf8`),i=this.fs.statSync(e),a=await yv(r,{globalScope:this.globalScope,extractMetadata:!0,basePath:this.path.dirname(e),filePath:e});Ky(a.content,e);let o=Wm(r),s=await t(a.content,`zh`,n,a.metadata.fields),c={content:a.content,lastModified:i.mtime,prompt:s,filePath:e,rawMdx:r};return o.yamlFrontMatter!=null&&Object.assign(c,{frontMatter:o.yamlFrontMatter}),c}catch(t){throw this.logger.error(this.buildDistReadDiagnostic(t,e,r)),t}}buildDistReadDiagnostic(e,t,n){let r=qy(this.path,t,{preferredSourcePath:t===n.entryDistPath?n.srcPath:void 0,distRootDir:this.path.dirname(n.entryDistPath),srcRootDir:n.srcPath==null?void 0:this.path.dirname(n.srcPath)});return mt({code:`LOCALIZED_DIST_PROMPT_READ_FAILED`,title:`Failed to read localized dist prompt`,diagnosticText:Yy(e,{operation:`Failed to read dist content.`,promptKind:n.promptKind,logicalName:n.logicalName,entryDistPath:n.entryDistPath,distPath:t,srcPath:r}),details:{promptKind:n.promptKind,logicalName:n.logicalName,filePath:t,srcPath:r}})}scanChildren(e,t,n){let r=[];if(!this.exists(e))return r;let i=new Set(n.map(e=>`${t}${e}`));try{let t=(e,a)=>{let o=this.fs.readdirSync(e,{withFileTypes:!0});for(let s of o){let o=this.path.join(e,s.name),c=a?this.path.join(a,s.name):s.name;if(s.isDirectory())t(o,c);else{let e=this.findMatchingExtension(s.name,n);if(e==null||i.has(s.name))continue;let t=s.name.slice(0,-e.length),a=this.path.dirname(c),o=a===`.`?t:this.path.join(a,t);r.push(o)}}};t(e,``)}catch(t){this.logger.warn(B({code:`LOCALIZED_PROMPT_CHILD_SCAN_FAILED`,title:`Failed to scan localized prompt child documents`,operation:`scan`,targetKind:`localized prompt child directory`,path:e,error:t}))}return r}exists(e){try{return this.fs.existsSync(e)}catch{return!1}}normalizeExtensions(e){return typeof e==`string`?[e]:e}findMatchingExtension(e,t){return t.find(t=>e.endsWith(t))}resolveLocalizedPath(e,t,n){let r=e===``?`${t}${n[0]}`:this.path.join(e,`${t}${n[0]}`);for(let r of n){let n=e===``?`${t}${r}`:this.path.join(e,`${t}${r}`);if(this.exists(n))return n}return r}};function Qy(e,t,n,r){return new Zy(e,t,n,r)}function $y(e,t){let n=new Map;for(let r of e)if(r.mcpConfig!=null)for(let[e,i]of Object.entries(r.mcpConfig.mcpServers))n.set(e,i),t?.debug(`mcp server collected`,{skill:r.yamlFrontMatter.name,mcpName:e});return n}function eb(e,t){let n={};for(let[r,i]of e)n[r]=t(i);return n}function tb(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,r=n.url??n.serverUrl;if(r==null)return t;t.url=r;let{headers:i}=n;return i!=null&&(t.headers=i),t}function nb(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}var rb=class extends Error{conflicts;constructor(e){super(fb(e)),this.name=`CleanupProtectionConflictError`,this.conflicts=e}};const ib=[`**/node_modules/**`,`**/.git/**`,`**/.turbo/**`,`**/.pnpm-store/**`,`**/.yarn/**`,`**/.next/**`];function ab(e){return Ih(e).replaceAll(`\\`,`/`)}function ob(e){let{root:t}=i.parse(e);return e===t?e:e.endsWith(i.sep)?e.slice(0,-1):e}function sb(e,t){let n=ob(e),r=ob(t);return n===r?!0:n.startsWith(`${r}${i.sep}`)}function cb(e,t){let n=ab(e);return it.default.sync(n,{onlyFiles:!1,dot:!0,absolute:!0,followSymbolicLinks:!1,ignore:[...t]})}function lb(e,t){if(t.excludeBasenames==null||t.excludeBasenames.length===0)return!1;let n=i.basename(e);return t.excludeBasenames.includes(n)}async function ub(e,t){return e.declareCleanupPaths==null?{}:e.declareCleanupPaths({...t,dryRun:!0})}function db(e,t){let n=new Map,r=[...t.entries()].sort((e,t)=>e[0].length-t[0].length);for(let[e,t]of r){let r=!1;for(let t of n.keys())if(sb(e,t)){r=!0;break}r||n.set(e,t)}let i=[];for(let[t,r]of e){let e=!1;for(let r of n.keys())if(sb(t,r)){e=!0;break}e||i.push(r)}return i.sort((e,t)=>e.localeCompare(t)),{files:i,dirs:[...n.values()].sort((e,t)=>e.localeCompare(t))}}function fb(e){let t=e.map(e=>e.outputPath).join(`, `);return`Cleanup protection conflict: ${e.length} output path(s) are also protected: ${t}`}function pb(e,t){let n=[];for(let[r,i]of e.entries()){let e=new Set(Bh(r));for(let a of t.compiledRules)if(a.comparisonKeys.some(t=>e.has(t)))for(let e of i)n.push({outputPath:r,outputPlugin:e,protectedPath:a.path,protectionMode:a.protectionMode,protectedBy:a.source,reason:a.reason})}return n.sort((e,t)=>{let n=e.outputPath.localeCompare(t.outputPath);return n===0?e.protectedPath.localeCompare(t.protectedPath):n})}function mb(e,t){let n=t[0];e.error(st({code:`CLEANUP_PROTECTION_CONFLICT_DETECTED`,title:`Cleanup output paths conflict with protected inputs`,rootCause:z(`tnmsc found ${t.length} output path(s) that also match protected cleanup rules.`,n==null?`No conflict details were captured.`:`Example conflict: "${n.outputPath}" is protected by "${n.protectedPath}".`),exactFix:z(`Separate generated output paths from protected source or reserved workspace paths before running cleanup again.`),possibleFixes:[z(`Update cleanup protect declarations so they do not overlap generated outputs.`),z(`Move the conflicting output target to a generated-only directory.`)],details:{count:t.length,conflicts:t.map(e=>({outputPath:e.outputPath,outputPlugin:e.outputPlugin,protectedPath:e.protectedPath,protectionMode:e.protectionMode,protectedBy:e.protectedBy,reason:e.reason}))}}))}async function hb(e,t){let r=new Set,i=new Set,a=new Map,o=new Set(ib),s=new Map,c=[],l=(e,t)=>{t===`directory`?i.add(Ih(e)):r.add(Ih(e))},u=(e,t,n,r,i=`path`)=>{let o=Ih(e);a.set(`${i}:${t}:${o}`,{path:o,protectionMode:t,reason:n,source:r,matcher:i})},d=e=>e.protectionMode==null?e.kind===`file`?`direct`:`recursive`:e.protectionMode;for(let e of $h(t.collectedOutputContext))u(e.path,e.protectionMode,e.reason,e.source);if(t.collectedOutputContext.aindexDir!=null&&t.pluginOptions!=null)for(let e of Qh(t.pluginOptions,t.collectedOutputContext.aindexDir,{workspaceDir:t.collectedOutputContext.workspace.directory.path}))u(e.path,e.protectionMode,e.reason,e.source,e.matcher);for(let e of t.pluginOptions?.cleanupProtection?.rules??[])u(e.path,e.protectionMode,e.reason??`configured cleanup protection rule`,`configured-cleanup-protection`,e.matcher??`path`);for(let n of e){let e=await n.declareOutputFiles({...t,dryRun:!0});for(let t of e){let e=Ih(t.path);l(e,`file`);let r=s.get(e);r==null?s.set(e,[n.name]):r.includes(n.name)||r.push(n.name)}let r=await ub(n,t);for(let e of r.excludeScanGlobs??[])o.add(ab(e));c.push({plugin:n,cleanup:r})}let f=[...o],p=e=>{for(let t of cb(e.path,f))if(!lb(t,e))try{n.lstatSync(t).isDirectory()?l(t,`directory`):l(t,`file`)}catch{}},m=(e,t)=>{let n=d(e),r=e.label==null?`plugin cleanup protect declaration`:`plugin cleanup protect declaration (${e.label})`;for(let i of cb(e.path,f))u(i,n,r,`plugin-cleanup-protect:${t}`)};for(let{plugin:e,cleanup:t}of c){for(let n of t.protect??[]){if(n.kind===`glob`){m(n,e.name);continue}u(n.path,d(n),n.label==null?`plugin cleanup protect declaration`:`plugin cleanup protect declaration (${n.label})`,`plugin-cleanup-protect:${e.name}`)}for(let e of t.delete??[]){if(e.kind===`glob`){p(e);continue}e.kind===`directory`?l(e.path,`directory`):l(e.path,`file`)}}let h=tg({workspaceDir:t.collectedOutputContext.workspace.directory.path,projectRoots:ng(t.collectedOutputContext),rules:[...a.values()],...t.collectedOutputContext.aindexDir==null?{}:{aindexDir:t.collectedOutputContext.aindexDir}}),g=pb(s,h);if(g.length>0)throw new rb(g);let _=ag([...r],h),v=ag([...i],h),y=db(new Map(_.safePaths.map(e=>[e,e])),new Map(v.safePaths.map(e=>[e,e])));return{filesToDelete:y.files,dirsToDelete:y.dirs,violations:[..._.violations,...v.violations].sort((e,t)=>e.targetPath.localeCompare(t.targetPath)),conflicts:[],excludedScanGlobs:[...o].sort((e,t)=>e.localeCompare(t))}}function gb(e,t){let n=e.map(e=>i.isAbsolute(e)?e:i.resolve(e)),r=bt(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(B({code:`CLEANUP_FILE_DELETE_FAILED`,title:`Cleanup could not delete a file`,operation:`delete`,targetKind:`file`,path:e.path,error:n,details:{phase:`cleanup`}})),{path:e.path,type:`file`,error:e.error}});return{deleted:r.deleted,errors:a}}function _b(e,t){let n=e.map(e=>i.isAbsolute(e)?e:i.resolve(e)),r=xt(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(B({code:`CLEANUP_DIRECTORY_DELETE_FAILED`,title:`Cleanup could not delete a directory`,operation:`delete`,targetKind:`directory`,path:e.path,error:n,details:{phase:`cleanup`}})),{path:e.path,type:`directory`,error:e.error}});return{deleted:r.deleted,errors:a}}function vb(e,t){e.debug(`cleanup plan built`,{filesToDelete:t.filesToDelete.length,dirsToDelete:t.dirsToDelete.length,violations:t.violations.length,conflicts:t.conflicts.length,excludedScanGlobs:t.excludedScanGlobs})}async function yb(e,t,n){let r=await Dy(e,t);n.debug(`Collected outputs for cleanup`,{projectDirs:r.projectDirs.length,projectFiles:r.projectFiles.length,globalDirs:r.globalDirs.length,globalFiles:r.globalFiles.length});let i;try{i=await hb(e,t)}catch(e){if(e instanceof rb)return mb(n,e.conflicts),{deletedFiles:0,deletedDirs:0,errors:[],violations:[],conflicts:e.conflicts,message:e.message};throw e}let a={filesToDelete:i.filesToDelete,dirsToDelete:i.dirsToDelete,violations:i.violations,conflicts:i.conflicts,excludedScanGlobs:i.excludedScanGlobs};if(vb(n,a),a.violations.length>0)return sg(n,`cleanup`,a.violations),{deletedFiles:0,deletedDirs:0,errors:[],violations:a.violations,conflicts:[],message:`Protected deletion guard blocked cleanup for ${a.violations.length} path(s)`};let o=gb(a.filesToDelete,n),s=_b(a.dirsToDelete,n);return{deletedFiles:o.deleted,deletedDirs:s.deleted,errors:[...o.errors,...s.errors],violations:[],conflicts:[]}}var bb=class{name=`clean`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r}=e;t.info(`running clean pipeline`,{command:`clean`});let i=await yb(n,r(!1),t);return i.violations.length>0||i.conflicts.length>0?{success:!1,filesAffected:0,dirsAffected:0,...i.message==null?{}:{message:i.message}}:(t.info(`clean complete`,{deletedFiles:i.deletedFiles,deletedDirs:i.deletedDirs}),{success:!0,filesAffected:i.deletedFiles,dirsAffected:i.deletedDirs})}},xb=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 Dy(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,violations:c,excludedScanGlobs:l}=await hb(n,i);return c.length>0?(sg(t,`dry-run-cleanup`,c),{success:!1,filesAffected:0,dirsAffected:0,message:`Protected deletion guard blocked cleanup for ${c.length} path(s)`}):(this.logDryRunFiles(o,t),this.logDryRunDirectories(s,t),t.info(`clean complete`,{dryRun:!0,filesAffected:o.length,dirsAffected:s.length,violations:0,excludedScanGlobs:l}),{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})}}},Sb=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=await Ey(n,r(!0)),a=0,o=0;for(let[e,n]of i)a+=n.files.length,o+=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:a,totalDirs:o,dryRun:!0}),{success:!0,filesAffected:a,dirsAffected:o,message:`Dry-run complete, no files were written`}}},Cb=class{name=`execute`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r,createWriteContext:i}=e;t.info(`started`,{command:`execute`});let a=await yb(n,r(!1),t);if(a.violations.length>0||a.conflicts.length>0)return{success:!1,filesAffected:0,dirsAffected:0,...a.message==null?{}:{message:a.message}};t.info(`cleanup complete`,{deletedFiles:a.deletedFiles,deletedDirs:a.deletedDirs});let o=await Ey(n,i(!1)),s=0,c=0,l=[];for(let e of o.values()){s+=e.files.length,c+=e.dirs.length;for(let t of e.files)t.success||l.push(t.error?.message??`Failed to write ${t.path}`)}return l.length>0?{success:!1,filesAffected:s,dirsAffected:c,message:l.join(`
|
|
221
|
-
`)}:(t.info(`complete`,{command:`execute`,pluginCount:o.size}),{success:!0,filesAffected:s,dirsAffected:c})}},wb=class{name;inner;constructor(e){this.inner=e,this.name=`json:${e.name}`}async execute(e){Vt();let n=await this.inner.execute(e),r=Tb(n,Ht());return t.stdout.write(`${JSON.stringify(r)}\n`),n}};function Tb(e,t=Ht()){let{warnings:n,errors:r}=_t(t);return{success:e.success,filesAffected:e.filesAffected,dirsAffected:e.dirsAffected,...e.message!=null&&{message:e.message},pluginResults:[],warnings:n,errors:r}}var Eb=class{name=`plugins`;async execute(e){let{logger:n,outputPlugins:r,userConfigOptions:i}=e,a=i.plugins,o=[];for(let e of a)o.push({name:e.name,kind:`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 t.stdout.write(`${JSON.stringify(o)}\n`),n.info(`plugins listed`,{count:o.length}),{success:!0,filesAffected:0,dirsAffected:0,message:`Listed ${o.length} plugin(s)`}}};const Db=[`IntelliJIdea`,`WebStorm`,`RustRover`,`PyCharm`,`PyCharmCE`,`PhpStorm`,`GoLand`,`CLion`,`DataGrip`,`RubyMine`,`Rider`,`DataSpell`,`Aqua`];function Ob(e){return Db.some(t=>e.startsWith(t))}function kb(e){let t=i.join(vt(),`JetBrains`);try{return n.readdirSync(t,{withFileTypes:!0}).filter(e=>e.isDirectory()&&Ob(e.name)).map(e=>i.join(t,e.name,`aia`,`codex`))}catch(n){return e.debug(B({code:`JETBRAINS_CODEX_DIRECTORY_SCAN_SKIPPED`,title:`JetBrains Codex directories are unavailable`,operation:`scan`,targetKind:`JetBrains IDE directory`,path:t,error:n})),[]}}function Ab(e){return{jetbrainsCodexDirs:kb(e)}}const jb=`.agents/skills`,Mb=`SKILL.md`;var Nb=class extends Ay{constructor(){super(`GenericSkillsOutputPlugin`,{outputFileName:Mb,treatWorkspaceRootProjectAsProject:!0,skills:{},cleanup:{delete:{project:{dirs:[jb]},global:{dirs:[jb]}}},capabilities:{skills:{scopes:[`project`,`global`],singleScope:!0},mcp:{scopes:[`project`,`global`],singleScope:!0}}})}async declareOutputFiles(e){let t=[],{skills:n}=e.collectedOutputContext;if(n==null||n.length===0)return t;let r=this.selectSingleScopeItems(n,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),i=this.selectSingleScopeItems(n,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`)),a=(e,n,r)=>{for(let i of r){let r=i.yamlFrontMatter.name,a=this.joinPath(e,r);if(t.push({path:this.joinPath(a,Mb),scope:n,source:{kind:`skillMain`,skill:i}}),i.childDocs!=null)for(let e of i.childDocs)t.push({path:this.joinPath(a,e.relativePath.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillChildDoc`,content:e.content}});if(i.resources!=null)for(let e of i.resources)t.push({path:this.joinPath(a,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},o=(e,n,r)=>{for(let i of r)i.mcpConfig!=null&&t.push({path:this.joinPath(e,i.yamlFrontMatter.name,`mcp.json`),scope:n,source:{kind:`skillMcp`,rawContent:i.mcpConfig.rawContent}})};if(r.selectedScope===`project`||i.selectedScope===`project`)for(let t of this.getProjectOutputProjects(e)){let n=this.resolveProjectRootDir(e,t);if(n==null)continue;let s=$(r.items,t.projectConfig,`skills`),c=$(i.items,t.projectConfig,`skills`),l=this.joinPath(n,jb);r.selectedScope===`project`&&s.length>0&&a(l,`project`,s),i.selectedScope===`project`&&o(l,`project`,c)}if(r.selectedScope!==`global`&&i.selectedScope!==`global`)return t;let s=this.joinPath(this.getHomeDir(),jb),c=this.resolvePromptSourceProjectConfig(e);if(r.selectedScope===`global`){let e=$(r.items,c,`skills`);e.length>0&&a(s,`global`,e)}return i.selectedScope===`global`&&o(s,`global`,$(i.items,c,`skills`)),t}async convertContent(e,t){let n=e.source;switch(n.kind){case`skillMain`:{let e=this.buildSkillFrontMatter(n.skill);return this.buildMarkdownContent(n.skill.content,e,t)}case`skillMcp`:return n.rawContent;case`skillChildDoc`:return n.content;case`skillResource`:return n.encoding===`base64`?f.from(n.content,`base64`):n.content;default:throw Error(`Unsupported declaration source for ${this.name}`)}}};const Pb=`AGENTS.md`;var Fb=class extends Ay{constructor(){super(`AgentsOutputPlugin`,{outputFileName:Pb,treatWorkspaceRootProjectAsProject:!0,cleanup:{delete:{project:{files:[Pb]}}},capabilities:{prompt:{scopes:[`project`],singleScope:!1}}})}async declareOutputFiles(e){let t=[],n=this.getProjectPromptOutputProjects(e);if(!new Set(this.selectPromptScopes(e,[`project`])).has(`project`))return t;for(let[r,i]of n.entries()){let n=this.resolveProjectRootDir(e,i);if(i.rootMemoryPrompt!=null&&n!=null&&t.push({path:this.resolvePath(n,Pb),scope:`project`,source:{type:`projectRootMemory`,projectIndex:r}}),i.childMemoryPrompts!=null)for(let[e,n]of i.childMemoryPrompts.entries())t.push({path:this.resolveFullPath(n.dir),scope:`project`,source:{type:`projectChildMemory`,projectIndex:r,childIndex:e}})}return t}async convertContent(e,t){let n=this.getProjectPromptOutputProjects(t),r=e.source,i=r.projectIndex??-1;if(i<0||i>=n.length)throw Error(`Invalid project index in declaration for ${this.name}`);let a=n[i];if(a==null)throw Error(`Project not found for declaration in ${this.name}`);if(r.type===`projectRootMemory`){if(a.rootMemoryPrompt==null)throw Error(`Root memory prompt missing for project index ${i}`);return a.rootMemoryPrompt.content}if(r.type===`projectChildMemory`){let e=r.childIndex??-1,t=a.childMemoryPrompts?.[e];if(t==null)throw Error(`Child memory prompt missing for project ${i}, child ${e}`);return t.content}throw Error(`Unsupported declaration source for ${this.name}`)}};const Ib=`CLAUDE.md`;var Lb=class extends Ay{constructor(){super(`ClaudeCodeCLIOutputPlugin`,{globalConfigDir:`.claude`,outputFileName:Ib,treatWorkspaceRootProjectAsProject:!0,toolPreset:`claudeCode`,commands:{subDir:`commands`,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},subagents:{subDir:`agents`,sourceScopes:[`project`],includePrefix:!0,linkSymbol:`-`,ext:`.md`},skills:{subDir:`skills`},rules:{transformFrontMatter:e=>({paths:e.globs.map(Um)})},cleanup:{delete:{project:{files:[Ib],dirs:[`.claude/rules`,`.claude/commands`,`.claude/agents`,`.claude/skills`]},global:{files:[`.claude/CLAUDE.md`],dirs:[`.claude/rules`,`.claude/commands`,`.claude/agents`,`.claude/skills`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1},rules:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},subagents:{scopes:[`project`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0}}})}};const Rb=zy.CURSOR,zb=Ny.MCP_CONFIG,Bb=Py.COMMANDS,Vb=Py.RULES,Hb=Ny.CURSOR_GLOBAL_RULE,Ub=Py.CURSOR_SKILLS,Wb=Ny.SKILL,Gb=Vy.CURSOR;var Kb=class extends Ay{constructor(){super(`CursorOutputPlugin`,{globalConfigDir:Rb,outputFileName:``,treatWorkspaceRootProjectAsProject:!0,dependsOn:[My.AgentsOutput],indexignore:By.CURSOR,commands:{subDir:Bb,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:Ub},rules:{subDir:Vb,prefix:`rule`,sourceScopes:[`project`,`global`]},cleanup:{delete:{project:{files:[`.cursor/mcp.json`],dirs:[`.cursor/commands`,`.cursor/rules`],globs:[`.cursor/skills-cursor/*`]},global:{files:[`.cursor/mcp.json`],dirs:[`.cursor/commands`,`.cursor/rules`],globs:[`.cursor/skills-cursor/*`]}},protect:{project:{dirs:[...Gb].map(e=>`.cursor/skills-cursor/${e}`)},global:{dirs:[...Gb].map(e=>`.cursor/skills-cursor/${e}`)}}},capabilities:{prompt:{scopes:[`global`],singleScope:!1},rules:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0},mcp:{scopes:[`project`,`global`],singleScope:!0}}})}async declareCleanupPaths(e){let t=await super.declareCleanupPaths(e);return{...t,delete:(t.delete??[]).map(e=>e.kind!==`glob`||!e.path.replaceAll(`\\`,`/`).endsWith(`/.cursor/${Ub}/*`)?e:{...e,excludeBasenames:[...Gb]})}}async declareOutputFiles(e){let t=[],{globalMemory:n,commands:r,skills:a,rules:o,aiAgentIgnoreConfigFiles:s}=e.collectedOutputContext,c=this.getGlobalConfigDir(),l=this.resolvePromptSourceProjectConfig(e),u=this.getConcreteProjects(e),d=this.getProjectPromptOutputProjects(e),f=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),p=new Set(this.selectPromptScopes(e,[`global`])),m=new Set(o==null?[]:this.selectRuleScopes(e,o)),h=a==null?{items:[]}:this.selectSingleScopeItems(a,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),g=a==null?{items:[]}:this.selectSingleScopeItems(a,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`)),_=r==null?{items:[]}:this.selectSingleScopeItems(r,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)),v=(e,n,r)=>{for(let a of r){let r=a.yamlFrontMatter.name;if(this.isPreservedSkill(r))continue;let o=i.join(e,Ub,r);if(t.push({path:i.join(o,Wb),scope:n,source:{kind:`skill`,skill:a}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.relativePath.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillChildDoc`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},y=(e,n,r)=>{for(let a of r){if(a.mcpConfig==null)continue;let r=i.join(e,Ub,a.yamlFrontMatter.name);t.push({path:i.join(r,zb),scope:n,source:{kind:`skillMcpConfig`,rawContent:a.mcpConfig.rawContent}})}},b=(e,n,r)=>{if(r.length===0)return;let a=$y(r,this.log);a.size!==0&&t.push({path:i.join(e,zb),scope:n,source:{kind:`mcpConfig`,mcpServers:eb(a,tb)}})};if(h.selectedScope===`project`||g.selectedScope===`project`)for(let t of this.getProjectOutputProjects(e)){let n=this.resolveProjectConfigDir(e,t);if(n!=null&&(h.selectedScope===`project`&&v(n,`project`,$(h.items,t.projectConfig,`skills`)),g.selectedScope===`project`)){let e=$(g.items,t.projectConfig,`skills`);y(n,`project`,e),b(n,`project`,e)}}if((h.selectedScope===`global`||g.selectedScope===`global`)&&(h.selectedScope===`global`&&v(c,`global`,$(h.items,l,`skills`)),g.selectedScope===`global`)){let e=$(g.items,l,`skills`);y(c,`global`,e),b(c,`global`,e)}if(_.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let a=$(_.items,n.projectConfig,`commands`);for(let e of a)t.push({path:i.join(r,Bb,this.transformCommandName(e,f)),scope:`project`,source:{kind:`command`,command:e}})}if(_.selectedScope===`global`){let e=$(_.items,l,`commands`);for(let n of e)t.push({path:i.join(c,Bb,this.transformCommandName(n,f)),scope:`global`,source:{kind:`command`,command:n}})}if(o!=null&&o.length>0){let n=o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`global`);if(m.has(`global`))for(let e of n)t.push({path:i.join(c,Vb,this.buildRuleFileName(e)),scope:`global`,source:{kind:`ruleMdc`,rule:e}});if(m.has(`project`))for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let a=Fv($(o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`project`),n.projectConfig,`rules`),n.projectConfig);for(let e of a)t.push({path:i.join(r,Vb,this.buildRuleFileName(e)),scope:`project`,source:{kind:`ruleMdc`,rule:e}})}}if(n!=null&&p.has(`global`)){let r=this.buildGlobalRuleContent(n.content,e);for(let n of d){let a=this.resolveProjectConfigDir(e,n);a!=null&&t.push({path:i.join(a,Vb,Hb),scope:`project`,source:{kind:`globalRuleContent`,content:r}})}}let x=this.getIgnoreOutputPath(),S=this.indexignore==null?void 0:s?.find(e=>e.fileName===this.indexignore);if(x!=null&&S!=null)for(let e of u){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:i.join(n.basePath,n.path,x),scope:`project`,source:{kind:`ignoreFile`,content:S.content}})}return t}async convertContent(e,t){let n=e.source;switch(n.kind){case`command`:return this.buildCommandContent(n.command,t);case`mcpConfig`:return JSON.stringify({mcpServers:n.mcpServers},null,2);case`skill`:{let e=this.buildSkillFrontMatter(n.skill);return this.buildMarkdownContent(n.skill.content,e,t)}case`skillMcpConfig`:return n.rawContent;case`skillChildDoc`:case`globalRuleContent`:case`ignoreFile`:return n.content;case`skillResource`:return n.encoding===`base64`?f.from(n.content,`base64`):n.content;case`ruleMdc`:return this.buildRuleMdcContent(n.rule,t);default:throw Error(`Unsupported declaration source for ${this.name}`)}}buildGlobalRuleContent(e,t){return this.buildMarkdownContent(e,{description:`Global prompt (synced)`,alwaysApply:!0},t)}isPreservedSkill(e){return Gb.has(e)}buildRuleMdcContent(e,t){let n={alwaysApply:!1,globs:e.globs.length>0?e.globs.join(`, `):``};return this.buildMarkdownContent(e.content,n,t).split(`
|
|
224
|
+
`,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}`}getSkillName(e){return My(e)}getSubAgentCanonicalName(e){return Ny(e)}transformCommandName(e,t){let{includeSeriesPrefix:n=!0,seriesSeparator:r=`-`}=t??{};return!n||e.commandPrefix==null?`${e.commandName}.md`:`${e.commandPrefix}${r}${e.commandName}.md`}transformSubAgentName(e,t){let{fileNameSource:n}=this.subAgentsConfig,r=t?.includePrefix??this.subAgentsConfig.includePrefix,i=t?.linkSymbol??this.subAgentsConfig.linkSymbol,a=t?.ext??this.subAgentsConfig.ext,o=a.startsWith(`.`)?a:`.${a}`;return n===`frontMatterName`&&this.warnDeprecatedSubAgentFileNameSource(),r&&e.agentPrefix!=null&&e.agentPrefix.length>0?`${e.agentPrefix}${i}${e.agentName}${o}`:`${e.agentName}${o}`}normalizeOutputFileStem(e){let t=Array.from(e.trim(),e=>(e.codePointAt(0)??0)<=31||`<>:"/\\|?*`.includes(e)?`-`:e).join(``);for(;t.endsWith(`.`)||t.endsWith(` `);)t=t.slice(0,-1);if(t.length===0)throw Error(`Cannot derive a valid output file name from "${e}"`);return t}warnDeprecatedSubAgentFileNameSource(){this.warnedDeprecatedSubAgentFileNameSource||(this.warnedDeprecatedSubAgentFileNameSource=!0,this.log.warn(dt({code:`SUBAGENT_FRONTMATTER_NAME_SOURCE_DEPRECATED`,title:`Sub-agent fileNameSource="frontMatterName" now resolves from derived names`,reason:z(`The ${this.name} plugin no longer reads authored sub-agent front matter names.`,`tnmsc now derives sub-agent names from the sub-agent path.`),exactFix:z("Remove authored `name` fields from sub-agent sources.",'Keep using `fileNameSource="frontMatterName"` only as a temporary alias for the derived-path naming behavior.'),details:{plugin:this.name}})))}appendSubAgentDeclarations(e,t,n,r){let a=new Map;for(let o of r){let r=this.transformSubAgentName(o),s=i.join(t,this.subAgentsConfig.subDir,r),c=a.get(s);if(c!=null)throw Error(`Sub-agent output collision in ${this.name}: "${this.getSubAgentCanonicalName(o)}" and "${c}" both resolve to ${s}`);a.set(s,this.getSubAgentCanonicalName(o)),e.push({path:s,scope:n,source:{kind:`subAgent`,subAgent:o}})}}appendCommandDeclarations(e,t,n,r,a){for(let o of r){let r=this.transformCommandName(o,a);e.push({path:i.join(t,this.commandsConfig.subDir,r),scope:n,source:{kind:`command`,command:o}})}}appendSkillDeclarations(e,t,n,r){for(let a of r){let r=this.getSkillName(a),o=i.join(t,this.skillsConfig.subDir,r);if(e.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:a}}),a.childDocs!=null)for(let t of a.childDocs)e.push({path:i.join(o,t.dir.path.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillReference`,content:t.content}});if(a.resources!=null)for(let t of a.resources)e.push({path:i.join(o,t.relativePath),scope:n,source:{kind:`skillResource`,content:t.content,encoding:t.encoding}})}}appendRuleDeclarations(e,t,n,r){let a=i.join(t,this.rulesConfig.subDir??`rules`);for(let t of r)e.push({path:i.join(a,this.buildRuleFileName(t)),scope:n,source:{kind:`rule`,rule:t}})}buildSubAgentTomlContent(e,t){let{bodyFieldName:n}=this.subAgentsConfig;if(n==null||n.length===0)throw Error(`subagents.bodyFieldName is required when artifactFormat="toml" for ${this.name}`);return this.buildTomlContent({content:e.content,bodyFieldName:n,...t!=null&&{frontMatter:t},...this.subAgentsConfig.fieldNameMap!=null&&{fieldNameMap:this.subAgentsConfig.fieldNameMap},...this.subAgentsConfig.excludedFrontMatterFields!=null&&{excludedKeys:this.subAgentsConfig.excludedFrontMatterFields},...this.subAgentsConfig.extraFields!=null&&{extraFields:this.subAgentsConfig.extraFields},...this.subAgentsConfig.fieldOrder!=null&&{fieldOrder:this.subAgentsConfig.fieldOrder}})}getCommandSeriesOptions(e){let t=e.pluginOptions?.commandSeriesOptions,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.getCommandSeriesOptions(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)}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)}normalizeRuleScope(e){return e.scope??`project`}normalizeSourceScope(e){return e===`global`||e===`project`?e:`project`}remapDeclarationScope(e,t){return t?.[e]??e}resolveCommandSourceScope(e){if(e.globalOnly===!0)return`global`;let t=e.yamlFrontMatter?.scope;return this.remapDeclarationScope(this.normalizeSourceScope(t),this.commandsConfig.scopeRemap)}resolveSubAgentSourceScope(e){let t=e.yamlFrontMatter?.scope;return this.remapDeclarationScope(this.normalizeSourceScope(t),this.subAgentsConfig.scopeRemap)}resolveSkillSourceScope(e){let t=e.yamlFrontMatter?.scope;return this.remapDeclarationScope(this.normalizeSourceScope(t),this.skillsConfig.scopeRemap)}selectSingleScopeItems(e,t,n,r){if(e.length===0)return{items:[]};let[i]=Ly({requestedScopes:r,defaultScopes:t,supportedScopes:t,singleScope:!0,availableScopes:[...new Set(e.map(n))]});return i==null?{items:[]}:{selectedScope:i,items:e.filter(e=>n(e)===i)}}selectRuleScopes(e,t){let n=[...new Set(t.map(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))))];return Ly({requestedScopes:this.getTopicScopeOverride(e,`rules`),defaultScopes:this.rulesConfig.sourceScopes??[`project`,`global`],supportedScopes:this.rulesConfig.sourceScopes??[`project`,`global`],singleScope:!1,availableScopes:n}).filter(e=>n.includes(e))}selectPromptScopes(e,t=[`project`,`global`],n=t){return Ly({requestedScopes:this.getTopicScopeOverride(e,`prompt`),defaultScopes:n,supportedScopes:t,singleScope:!1})}getTopicScopeOverride(e,t){return e.pluginOptions?.outputScopes?.plugins?.[this.name]?.[t]}buildSkillFrontMatter(e,t){let n=e.yamlFrontMatter,r={name:this.getSkillName(e),description:n.description};return`displayName`in n&&n.displayName!=null&&(r.displayName=n.displayName),`keywords`in n&&n.keywords!=null&&n.keywords.length>0&&(r.keywords=n.keywords),`author`in n&&n.author!=null&&(r.author=n.author),`version`in n&&n.version!=null&&(r.version=n.version),(t?.includeTools??!0)&&`allowTools`in n&&n.allowTools!=null&&n.allowTools.length>0&&(r.allowTools=(t?.toolFormat??`array`)===`string`?n.allowTools.join(`,`):n.allowTools),t?.additionalFields!=null&&Object.assign(r,t.additionalFields),r}buildRuleContent(e,t){let n=this.rulesConfig.transformFrontMatter?this.rulesConfig.transformFrontMatter(e):{globs:e.globs.join(`, `)},r=n==null||Object.keys(n).length===0?void 0:n;return this.buildMarkdownContent(e.content,r,t)}buildRuleFileName(e){let t=`${`${this.rulesConfig.prefix??`rule`}${this.rulesConfig.linkSymbol??`-`}`}${e.prefix}${this.rulesConfig.linkSymbol??`-`}${e.ruleName}${this.rulesConfig.ext??`.md`}`;return this.log.trace(`buildRuleFileName`,{plugin:this.name,rulePrefix:e.prefix,ruleName:e.ruleName,prefix:this.rulesConfig.prefix??`rule`,linkSymbol:this.rulesConfig.linkSymbol??`-`,ext:this.rulesConfig.ext??`.md`,result:t}),t}async declareOutputFiles(e){return this.buildDefaultOutputDeclarations(e)}async declareCleanupPaths(e){let t=this.buildCleanupTargetsFromScopeConfig(this.cleanupConfig.delete,`delete`,e),n=this.buildCleanupTargetsFromScopeConfig(this.cleanupConfig.protect,`protect`,e),{excludeScanGlobs:r}=this.cleanupConfig;return t.length===0&&n.length===0&&(r==null||r.length===0)?{}:{...t.length>0&&{delete:t},...n.length>0&&{protect:n},...r!=null&&r.length>0&&{excludeScanGlobs:r}}}async convertContent(e,t){let n=e.source;switch(n.kind){case`projectRootMemory`:case`projectChildMemory`:case`globalMemory`:case`skillReference`:case`ignoreFile`:return n.content;case`command`:return this.buildCommandContent(n.command,t);case`subAgent`:return this.buildSubAgentContent(n.subAgent,t);case`skillMain`:return this.buildSkillMainContent(n.skill,t);case`skillResource`:return n.encoding===`base64`?f.from(n.content,`base64`):n.content;case`rule`:return this.buildRuleContent(n.rule,t);default:throw Error(`Unsupported declaration source for plugin ${this.name}`)}}async buildDefaultOutputDeclarations(e){let t=[],{globalMemory:n,commands:r,subAgents:a,skills:o,rules:s,aiAgentIgnoreConfigFiles:c}=e.collectedOutputContext,l=this.getTransformOptionsFromContext(e),u=this.getIgnoreOutputPath(),d=this.indexignore==null?void 0:c?.find(e=>e.fileName===this.indexignore),f=this.commandOutputEnabled&&r!=null?this.selectSingleScopeItems(r,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)):{items:[]},p=this.subAgentOutputEnabled&&a!=null?this.selectSingleScopeItems(a,this.subAgentsConfig.sourceScopes,e=>this.resolveSubAgentSourceScope(e),this.getTopicScopeOverride(e,`subagents`)):{items:[]},m=this.skillOutputEnabled&&o!=null?this.selectSingleScopeItems(o,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)):{items:[]},h=s??[],g=this.ruleOutputEnabled&&h.length>0?new Set(this.selectRuleScopes(e,h)):new Set,_=new Set(this.selectPromptScopes(e,this.outputCapabilities.prompt?.scopes??[`project`,`global`])),v={project:[],global:[]};for(let e of h)v[this.normalizeSourceScope(this.normalizeRuleScope(e))].push(e);for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectRootDir(e,n),a=this.resolveProjectConfigDir(e,n);if(r==null||a==null)continue;if(this.outputFileName.length>0&&_.has(`project`)&&this.isProjectPromptOutputTarget(n)&&(n.rootMemoryPrompt!=null&&t.push({path:i.join(r,this.outputFileName),scope:`project`,source:{kind:`projectRootMemory`,content:n.rootMemoryPrompt.content}}),n.childMemoryPrompts!=null))for(let e of n.childMemoryPrompts)t.push({path:this.resolveFullPath(e.dir),scope:`project`,source:{kind:`projectChildMemory`,content:e.content}});let{projectConfig:o}=n;if(f.selectedScope===`project`&&f.items.length>0){let e=$(f.items,o,`commands`);this.appendCommandDeclarations(t,a,`project`,e,l)}if(p.selectedScope===`project`&&p.items.length>0){let e=$(p.items,o,`subAgents`);this.appendSubAgentDeclarations(t,a,`project`,e)}if(m.selectedScope===`project`&&m.items.length>0){let e=$(m.items,o,`skills`);this.appendSkillDeclarations(t,a,`project`,e)}if(g.has(`project`)){let e=by($(v.project,o,`rules`),o);this.appendRuleDeclarations(t,a,`project`,e)}u!=null&&d!=null&&n.isWorkspaceRootProject!==!0&&n.isPromptSourceProject!==!0&&n.dirFromWorkspacePath!=null&&t.push({path:i.join(n.dirFromWorkspacePath.basePath,n.dirFromWorkspacePath.path,u),scope:`project`,source:{kind:`ignoreFile`,content:d.content}})}let y=this.resolvePromptSourceProjectConfig(e);if(f.selectedScope===`global`&&f.items.length>0){let e=$(f.items,y,`commands`),n=this.getGlobalConfigDir();this.appendCommandDeclarations(t,n,`global`,e,l)}if(p.selectedScope===`global`&&p.items.length>0){let e=$(p.items,y,`subAgents`),n=this.getGlobalConfigDir();this.appendSubAgentDeclarations(t,n,`global`,e)}if(m.selectedScope===`global`&&m.items.length>0){let e=$(m.items,y,`skills`),n=this.getGlobalConfigDir();this.appendSkillDeclarations(t,n,`global`,e)}for(let e of[`global`]){if(!g.has(e))continue;let n=this.getGlobalConfigDir(),r=by($(v[e],y,`rules`),y);this.appendRuleDeclarations(t,n,e,r)}return n!=null&&this.outputFileName.length>0&&_.has(`global`)&&t.push({path:i.join(this.getGlobalConfigDir(),this.outputFileName),scope:`global`,source:{kind:`globalMemory`,content:n.content}}),t}async buildCommandContent(e,t){let n=e.content,r=e.yamlFrontMatter,i=!1;if(e.rawMdxContent!=null&&this.toolPreset!=null){this.log.debug(`recompiling command with tool preset`,{file:e.dir.getAbsolutePath(),toolPreset:this.toolPreset,hasRawContent:!0});let t=new Ey({toolPreset:this.toolPreset}).collect(),a=await Vv(e.rawMdxContent,{globalScope:t,extractMetadata:!0,basePath:e.dir.basePath,filePath:e.dir.getAbsolutePath()});n=a.content,r=a.metadata.fields,i=!0}let a=this.commandsConfig.transformFrontMatter;if(a==null)throw Error(`commands.transformFrontMatter is required for command output plugin: ${this.name}`);let o=a(e,{isRecompiled:i,...r!=null&&{sourceFrontMatter:r}});return this.buildMarkdownContent(n,o,t)}buildSubAgentContent(e,t){let n=this.subAgentsConfig.transformFrontMatter,r=n?.(e,{...e.yamlFrontMatter!=null&&{sourceFrontMatter:e.yamlFrontMatter}});if(this.subAgentsConfig.artifactFormat===`toml`){let t=r??e.yamlFrontMatter;return this.buildSubAgentTomlContent(e,t)}return r==null?this.buildMarkdownContentWithRaw(e.content,e.yamlFrontMatter,e.rawFrontMatter,t):this.buildMarkdownContent(e.content,r,t)}buildSkillMainContent(e,t){return this.buildMarkdownContentWithRaw(e.content,e.yamlFrontMatter,e.rawFrontMatter,t)}};const Sb={USER_HOME:`~`,WORKSPACE:`$WORKSPACE`},Cb={AgentsOutput:`AgentsOutputPlugin`,GeminiCLIOutput:`GeminiCLIOutputPlugin`,CursorOutput:`CursorOutputPlugin`,WindsurfOutput:`WindsurfOutputPlugin`,ClaudeCodeCLIOutput:`ClaudeCodeCLIOutputPlugin`,KiroIDEOutput:`KiroCLIOutputPlugin`,OpencodeCLIOutput:`OpencodeCLIOutputPlugin`,OpenAICodexCLIOutput:`CodexCLIOutputPlugin`,DroidCLIOutput:`DroidCLIOutputPlugin`,WarpIDEOutput:`WarpIDEOutputPlugin`,TraeIDEOutput:`TraeIDEOutputPlugin`,TraeCNIDEOutput:`TraeCNIDEOutputPlugin`,QoderIDEOutput:`QoderIDEPluginOutputPlugin`,JetBrainsCodeStyleOutput:`JetBrainsIDECodeStyleConfigOutputPlugin`,JetBrainsAICodexOutput:`JetBrainsAIAssistantCodexOutputPlugin`,AgentSkillsCompactOutput:`GenericSkillsOutputPlugin`,GitExcludeOutput:`GitExcludeOutputPlugin`,ReadmeOutput:`ReadmeMdConfigFileOutputPlugin`,VSCodeOutput:`VisualStudioCodeIDEConfigOutputPlugin`,EditorConfigOutput:`EditorConfigOutputPlugin`,AntigravityOutput:`AntigravityOutputPlugin`},wb={SKILL:`SKILL.md`,CURSOR_GLOBAL_RULE:`global.mdc`,CURSOR_PROJECT_RULE:`always.md`,MCP_CONFIG:`mcp.json`,CLAUDE_MEMORY:`CLAUDE.md`,WINDSURF_GLOBAL_RULE:`global_rules.md`},Tb={RULES:`rules`,COMMANDS:`commands`,SKILLS:`skills`,AGENTS:`agents`,CURSOR_SKILLS:`skills-cursor`},Eb={MD:`.md`,MDC:`.mdc`,MDX:`.mdx`,JSON:`.json`},Db=[{PRIMARY:`.src.mdx`}.PRIMARY],Ob={zh:Db,en:Eb.MDX};function kb(e){return Db.some(t=>e.endsWith(t))}const Ab={CURSOR:`.cursor`,CLAUDE:`.claude`,WINDSURF:`.codeium/windsurf`,WINDSURF_RULES:`.windsurf`},jb={CURSOR:`.cursorignore`,WINDSURF:`.codeiumignore`},Mb={CURSOR:new Set([`create-rule`,`create-skill`,`create-subagent`,`migrate-to-skills`,`update-cursor-settings`])};var Nb=class extends Error{kind;nameOfPrompt;sourcePath;expectedDistPath;constructor(e){let{kind:t,name:n,sourcePath:r,expectedDistPath:i}=e;super([`Missing compiled dist prompt for ${t} "${n}".`,...r==null?[]:[`source: ${r}`],`expected dist: ${i}`].join(` `)),this.name=`MissingCompiledPromptError`,this.kind=t,this.nameOfPrompt=n,r!=null&&(this.sourcePath=r),this.expectedDistPath=i}},Pb=class extends Error{filePath;lineNumber;constructor(e,t,n){super(`Compiled prompt still contains residual module syntax at ${e}:${t}: ${n.trim()}`),this.name=`ResidualModuleSyntaxError`,this.filePath=e,this.lineNumber=t}};const Fb=/^\s*(```|~~~)/u,Ib=[/^\s*export\s+default\b/u,/^\s*export\s+const\b/u,/^\s*import\b/u];function Lb(e,t){let n,r=e.split(/\r?\n/u);for(let[e,i]of r.entries()){let r=Fb.exec(i);if(r?.[1]!=null){let e=r[1];n==null?n=e:n===e&&(n=void 0);continue}if(n==null&&Ib.some(e=>e.test(i)))throw new Pb(t,e+1,i)}}function Rb(e,t,n={}){let{preferredSourcePath:r,distRootDir:i,srcRootDir:a}=n;if(t==null||t.length===0||r!=null&&r.length>0)return r;if(i==null||a==null)return;let o=e.relative(i,t);if(!(o.startsWith(`..`)||e.isAbsolute(o)))return e.join(a,o.replace(/\.mdx$/u,`.src.mdx`))}function zb(e){if(e instanceof Tg&&e.filePath!=null)return e.filePath;if(!(e instanceof Error)||!(`filePath`in e))return;let{filePath:t}=e;if(typeof t==`string`&&t.length>0)return t}function Bb(e,t){let n=zb(e)??t.distPath,r=[t.operation??`Prompt compilation failed.`,`prompt kind: ${t.promptKind}`,`logical name: ${t.logicalName}`];return t.entryDistPath!=null&&t.entryDistPath.length>0&&t.entryDistPath!==n&&r.push(`entry dist file: ${t.entryDistPath}`),n!=null&&n.length>0&&r.push(`dist file: ${n}`),r.push(`src file: ${t.srcPath??`<unresolved>`}`),r.push(`diagnostic:`),r.push(e instanceof Error?wg(e):String(e)),r.join(`
|
|
225
|
+
`)}function Vb(e){return e instanceof Nb||e instanceof Pb}var Hb=class{constructor(e,t,n,r){this.fs=e,this.path=t,this.logger=n,this.globalScope=r}async readDirectoryStructure(e,t,n){let r=[],i=[];if(!this.exists(e))return{prompts:r,errors:i};try{let a=this.fs.readdirSync(e,{withFileTypes:!0});for(let o of a){if(!o.isDirectory())continue;let{name:a}=o,s=this.path.join(e,a),c=this.path.join(t,a);try{let e=await this.readEntry(a,s,c,n,!0);e&&r.push(e)}catch(e){if(i.push({path:s,error:e,phase:`read`}),this.logger.error(B({code:`LOCALIZED_PROMPT_ENTRY_READ_FAILED`,title:`Failed to read localized prompt entry`,operation:`read`,targetKind:`${String(n.kind)} prompt entry`,path:s,error:e,details:{entryName:a,promptKind:String(n.kind)}})),Vb(e))throw e}}}catch(t){if(i.push({path:e,error:t,phase:`scan`}),this.logger.error(B({code:`LOCALIZED_PROMPT_DIRECTORY_SCAN_FAILED`,title:`Failed to scan localized prompt source directory`,operation:`scan`,targetKind:`${String(n.kind)} prompt source directory`,path:e,error:t,details:{promptKind:String(n.kind)}})),Vb(t))throw t}return{prompts:r,errors:i}}async readFlatFiles(e,t,n){let r=[],i=[],a=this.exists(e),o=this.exists(t);if(this.logger.debug(`readFlatFiles: srcDir=${e}, exists=${a}`),this.logger.debug(`readFlatFiles: distDir=${t}, exists=${o}`),!a&&!o)return{prompts:r,errors:i};let s=this.normalizeExtensions(n.localeExtensions.zh),c=new Set,l=async(a,o)=>{if(!c.has(a)){c.add(a);try{let i=await this.readFlatEntry(a,e,t,a,n);i&&r.push(i)}catch(e){if(i.push({path:o,error:e,phase:`read`}),this.logger.error(B({code:`LOCALIZED_PROMPT_FILE_READ_FAILED`,title:`Failed to read localized prompt file`,operation:`read`,targetKind:`${String(n.kind)} prompt file`,path:o,error:e,details:{promptKind:String(n.kind),logicalName:a}})),Vb(e))throw e}}},u=async(e,t=``)=>{if(this.exists(e))try{let n=this.fs.readdirSync(e,{withFileTypes:!0});for(let r of n){let n=t?this.path.join(t,r.name):r.name;if(r.isDirectory()){await u(this.path.join(e,r.name),n);continue}let i=this.findMatchingExtension(r.name,s);if(!r.isFile()||i==null)continue;let a=r.name.slice(0,-i.length);await l(t?this.path.join(t,a):a,this.path.join(e,r.name))}}catch(t){if(i.push({path:e,error:t,phase:`scan`}),this.logger.error(B({code:`LOCALIZED_SOURCE_DIRECTORY_SCAN_FAILED`,title:`Failed to scan localized source directory`,operation:`scan`,targetKind:`${String(n.kind)} source directory`,path:e,error:t,details:{promptKind:String(n.kind)}})),Vb(t))throw t}},d=async(e,t=``)=>{if(this.exists(e))try{let n=this.fs.readdirSync(e,{withFileTypes:!0});for(let r of n){let n=t?this.path.join(t,r.name):r.name;if(r.isDirectory()){await d(this.path.join(e,r.name),n);continue}if(!r.isFile()||!r.name.endsWith(`.mdx`))continue;let i=r.name.slice(0,-4);await l(t?this.path.join(t,i):i,this.path.join(e,r.name))}}catch(t){if(i.push({path:e,error:t,phase:`scan`}),this.logger.error(B({code:`LOCALIZED_DIST_DIRECTORY_SCAN_FAILED`,title:`Failed to scan localized dist directory`,operation:`scan`,targetKind:`${String(n.kind)} dist directory`,path:e,error:t,details:{promptKind:String(n.kind)}})),Vb(t))throw t}};return a&&await u(e),o&&await d(t),{prompts:r,errors:i}}async readSingleFile(e,t,n){let r=this.path.basename(e);return this.readFlatEntry(r,this.path.dirname(e),this.path.dirname(t),e,n,!0)}async readEntry(e,t,n,r,i=!0){let{localeExtensions:a,entryFileName:o,createPrompt:s,kind:c}=r,l=o??e,u=this.normalizeExtensions(a.zh),d=this.normalizeExtensions(a.en),f=this.resolveLocalizedPath(t,l,u),p=this.resolveLocalizedPath(t,l,d),m=this.path.join(n,`${l}.mdx`),h=this.exists(f)?f:this.exists(p)?p:void 0,g={promptKind:String(c),logicalName:e,entryDistPath:m,...h!=null&&{srcPath:h}},_=await this.readDistContent(m,s,e,g),v=await this.readLocaleContent(f,`zh`,s,e,String(c)),y=await this.readLocaleContent(p,`en`,s,e,String(c)),b=_!=null,x=v!=null,S=y!=null,C=x?f:S?p:void 0;if(!b&&!x&&!S)return this.logger.warn(st({code:`LOCALIZED_PROMPT_ARTIFACTS_MISSING`,title:`Missing source and dist prompt artifacts for ${e}`,rootCause:z(`tnmsc could not find either the source prompt or the compiled dist prompt for "${e}".`),exactFix:z(`Create the source prompt and rebuild the compiled dist prompt before retrying tnmsc.`),details:{promptKind:String(c),name:e,srcZhPath:f,srcEnPath:p,distPath:m}})),null;if(!b)throw new Nb({kind:String(c),name:e,...C!=null&&{sourcePath:C},expectedDistPath:m});let w=x?{zh:v,...S&&{en:y},default:v,defaultLocale:`zh`}:void 0,T=i?this.scanChildren(n,l,[`.mdx`]):void 0;return{name:e,type:c,...w!=null&&{src:w},...b&&{dist:_},metadata:{hasDist:b,hasMultipleLocales:S,isDirectoryStructure:i,...T&&T.length>0&&{children:T}},paths:{...x&&{zh:f},...S&&{en:p},...b&&{dist:m}}}}async readFlatEntry(e,t,n,r,i,a=!1){let{localeExtensions:o,createPrompt:s,kind:c}=i,l=this.normalizeExtensions(o.zh),u=this.normalizeExtensions(o.en),d=this.resolveLocalizedPath(``,r,l),f=this.resolveLocalizedPath(``,r,u),p=this.path.join(n,`${e}.mdx`),m=a?d:this.path.join(t,d),h=a?f:this.path.join(t,f),g=this.exists(m)?m:this.exists(h)?h:void 0,_={promptKind:String(c),logicalName:e,entryDistPath:p,...g!=null&&{srcPath:g}},v=await this.readDistContent(p,s,e,_),y=await this.readLocaleContent(m,`zh`,s,e,String(c)),b=await this.readLocaleContent(h,`en`,s,e,String(c)),x=v!=null,S=y!=null,C=b!=null,w=S?m:C?h:void 0;if(!x&&!S&&!C)return this.logger.warn(st({code:`LOCALIZED_PROMPT_ARTIFACTS_MISSING`,title:`Missing source and dist prompt artifacts for ${e}`,rootCause:z(`tnmsc could not find either the source prompt or the compiled dist prompt for "${e}".`),exactFix:z(`Create the source prompt and rebuild the compiled dist prompt before retrying tnmsc.`),details:{promptKind:String(c),name:e,srcZhPath:m,srcEnPath:h,distPath:p}})),null;if(!x)throw new Nb({kind:String(c),name:e,...w!=null&&{sourcePath:w},expectedDistPath:p});let T=S?{zh:y,...C&&{en:b},default:y,defaultLocale:`zh`}:void 0;return{name:e,type:c,...T!=null&&{src:T},...x&&{dist:v},metadata:{hasDist:x,hasMultipleLocales:C,isDirectoryStructure:!1},paths:{...S&&{zh:m},...C&&{en:h},...x&&{dist:p}}}}async readLocaleContent(e,t,n,r,i){if(!this.exists(e))return null;try{let i=this.fs.readFileSync(e,`utf8`),a=this.fs.statSync(e),o=await Vv(i,{globalScope:this.globalScope,extractMetadata:!0,basePath:this.path.dirname(e),filePath:e});Lb(o.content,e);let s=Qm(i),c=await n(o.content,t,r,o.metadata.fields),l={content:o.content,lastModified:a.mtime,filePath:e};return i.length>0&&Object.assign(l,{rawMdx:i}),s.yamlFrontMatter!=null&&Object.assign(l,{frontMatter:s.yamlFrontMatter}),c!=null&&Object.assign(l,{prompt:c}),l}catch(n){throw this.logger.error(mt({code:`LOCALIZED_SOURCE_PROMPT_READ_FAILED`,title:`Failed to read localized source prompt`,diagnosticText:Bb(n,{operation:`Failed to read localized source prompt.`,promptKind:i,logicalName:r,distPath:e}),details:{promptKind:i,locale:t,filePath:e}})),n}}async readDistContent(e,t,n,r){if(!this.exists(e))return null;try{let r=this.fs.readFileSync(e,`utf8`),i=this.fs.statSync(e),a=await Vv(r,{globalScope:this.globalScope,extractMetadata:!0,basePath:this.path.dirname(e),filePath:e});Lb(a.content,e);let o=Qm(r),s=await t(a.content,`zh`,n,a.metadata.fields),c={content:a.content,lastModified:i.mtime,prompt:s,filePath:e,rawMdx:r};return o.yamlFrontMatter!=null&&Object.assign(c,{frontMatter:o.yamlFrontMatter}),c}catch(t){throw this.logger.error(this.buildDistReadDiagnostic(t,e,r)),t}}buildDistReadDiagnostic(e,t,n){let r=Rb(this.path,t,{preferredSourcePath:t===n.entryDistPath?n.srcPath:void 0,distRootDir:this.path.dirname(n.entryDistPath),srcRootDir:n.srcPath==null?void 0:this.path.dirname(n.srcPath)});return mt({code:`LOCALIZED_DIST_PROMPT_READ_FAILED`,title:`Failed to read localized dist prompt`,diagnosticText:Bb(e,{operation:`Failed to read dist content.`,promptKind:n.promptKind,logicalName:n.logicalName,entryDistPath:n.entryDistPath,distPath:t,srcPath:r}),details:{promptKind:n.promptKind,logicalName:n.logicalName,filePath:t,srcPath:r}})}scanChildren(e,t,n){let r=[];if(!this.exists(e))return r;let i=new Set(n.map(e=>`${t}${e}`));try{let t=(e,a)=>{let o=this.fs.readdirSync(e,{withFileTypes:!0});for(let s of o){let o=this.path.join(e,s.name),c=a?this.path.join(a,s.name):s.name;if(s.isDirectory())t(o,c);else{let e=this.findMatchingExtension(s.name,n);if(e==null||i.has(s.name))continue;let t=s.name.slice(0,-e.length),a=this.path.dirname(c),o=a===`.`?t:this.path.join(a,t);r.push(o)}}};t(e,``)}catch(t){this.logger.warn(B({code:`LOCALIZED_PROMPT_CHILD_SCAN_FAILED`,title:`Failed to scan localized prompt child documents`,operation:`scan`,targetKind:`localized prompt child directory`,path:e,error:t}))}return r}exists(e){try{return this.fs.existsSync(e)}catch{return!1}}normalizeExtensions(e){return typeof e==`string`?[e]:e}findMatchingExtension(e,t){return t.find(t=>e.endsWith(t))}resolveLocalizedPath(e,t,n){let r=e===``?`${t}${n[0]}`:this.path.join(e,`${t}${n[0]}`);for(let r of n){let n=e===``?`${t}${r}`:this.path.join(e,`${t}${r}`);if(this.exists(n))return n}return r}};function Ub(e,t,n,r){return new Hb(e,t,n,r)}function Wb(e,t){let n=new Map;for(let r of e)if(r.mcpConfig!=null)for(let[e,i]of Object.entries(r.mcpConfig.mcpServers))n.set(e,i),t?.debug(`mcp server collected`,{skill:My(r),mcpName:e});return n}function Gb(e,t){let n={};for(let[r,i]of e)n[r]=t(i);return n}function Kb(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,r=n.url??n.serverUrl;if(r==null)return t;t.url=r;let{headers:i}=n;return i!=null&&(t.headers=i),t}function qb(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}var Jb=class extends Error{conflicts;constructor(e){super(ix(e)),this.name=`CleanupProtectionConflictError`,this.conflicts=e}};const Yb=[`**/node_modules/**`,`**/.git/**`,`**/.turbo/**`,`**/.pnpm-store/**`,`**/.yarn/**`,`**/.next/**`];function Xb(e){return Wh(e).replaceAll(`\\`,`/`)}function Zb(e){let{root:t}=i.parse(e);return e===t?e:e.endsWith(i.sep)?e.slice(0,-1):e}function Qb(e,t){let n=Zb(e),r=Zb(t);return n===r?!0:n.startsWith(`${r}${i.sep}`)}function $b(e,t){let n=Xb(e);return it.default.sync(n,{onlyFiles:!1,dot:!0,absolute:!0,followSymbolicLinks:!1,ignore:[...t]})}function ex(e,t){if(t.excludeBasenames==null||t.excludeBasenames.length===0)return!1;let n=i.basename(e);return t.excludeBasenames.includes(n)}async function tx(e,t){return e.declareCleanupPaths==null?{}:e.declareCleanupPaths({...t,dryRun:!0})}async function nx(e,t,n){let r=n?.get(e),[i,a]=await Promise.all([r==null?e.declareOutputFiles({...t,dryRun:!0}):Promise.resolve(r),tx(e,t)]);return{plugin:e,outputs:i,cleanup:a}}function rx(e,t){let n=new Map,r=[...t.entries()].sort((e,t)=>e[0].length-t[0].length);for(let[e,t]of r){let r=!1;for(let t of n.keys())if(Qb(e,t)){r=!0;break}r||n.set(e,t)}let i=[];for(let[t,r]of e){let e=!1;for(let r of n.keys())if(Qb(t,r)){e=!0;break}e||i.push(r)}return i.sort((e,t)=>e.localeCompare(t)),{files:i,dirs:[...n.values()].sort((e,t)=>e.localeCompare(t))}}function ix(e){let t=e.map(e=>e.outputPath).join(`, `);return`Cleanup protection conflict: ${e.length} output path(s) are also protected: ${t}`}function ax(e,t){let n=[];for(let[r,i]of e.entries()){let e=new Set(Jh(r));for(let a of t.compiledRules)if(a.comparisonKeys.some(t=>e.has(t)))for(let e of i)n.push({outputPath:r,outputPlugin:e,protectedPath:a.path,protectionMode:a.protectionMode,protectedBy:a.source,reason:a.reason})}return n.sort((e,t)=>{let n=e.outputPath.localeCompare(t.outputPath);return n===0?e.protectedPath.localeCompare(t.protectedPath):n})}function ox(e,t){let n=t[0];e.error(st({code:`CLEANUP_PROTECTION_CONFLICT_DETECTED`,title:`Cleanup output paths conflict with protected inputs`,rootCause:z(`tnmsc found ${t.length} output path(s) that also match protected cleanup rules.`,n==null?`No conflict details were captured.`:`Example conflict: "${n.outputPath}" is protected by "${n.protectedPath}".`),exactFix:z(`Separate generated output paths from protected source or reserved workspace paths before running cleanup again.`),possibleFixes:[z(`Update cleanup protect declarations so they do not overlap generated outputs.`),z(`Move the conflicting output target to a generated-only directory.`)],details:{count:t.length,conflicts:t.map(e=>({outputPath:e.outputPath,outputPlugin:e.outputPlugin,protectedPath:e.protectedPath,protectionMode:e.protectionMode,protectedBy:e.protectedBy,reason:e.reason}))}}))}async function sx(e,t,r){let i=new Set,a=new Set,o=new Map,s=new Set(Yb),c=new Map,l=await Promise.all(e.map(async e=>nx(e,t,r))),u=(e,t)=>{t===`directory`?a.add(Wh(e)):i.add(Wh(e))},d=(e,t,n,r,i=`path`)=>{let a=Wh(e);o.set(`${i}:${t}:${a}`,{path:a,protectionMode:t,reason:n,source:r,matcher:i})},f=e=>e.protectionMode==null?e.kind===`file`?`direct`:`recursive`:e.protectionMode;for(let e of sg(t.collectedOutputContext))d(e.path,e.protectionMode,e.reason,e.source);if(t.collectedOutputContext.aindexDir!=null&&t.pluginOptions!=null)for(let e of og(t.pluginOptions,t.collectedOutputContext.aindexDir,{workspaceDir:t.collectedOutputContext.workspace.directory.path}))d(e.path,e.protectionMode,e.reason,e.source,e.matcher);for(let e of t.pluginOptions?.cleanupProtection?.rules??[])d(e.path,e.protectionMode,e.reason??`configured cleanup protection rule`,`configured-cleanup-protection`,e.matcher??`path`);for(let e of l){for(let t of e.outputs){let n=Wh(t.path);u(n,`file`);let r=c.get(n);r==null?c.set(n,[e.plugin.name]):r.includes(e.plugin.name)||r.push(e.plugin.name)}for(let t of e.cleanup.excludeScanGlobs??[])s.add(Xb(t))}let p=[...s],m=e=>{for(let t of $b(e.path,p))if(!ex(t,e))try{n.lstatSync(t).isDirectory()?u(t,`directory`):u(t,`file`)}catch{}},h=(e,t)=>{let n=f(e),r=e.label==null?`plugin cleanup protect declaration`:`plugin cleanup protect declaration (${e.label})`;for(let i of $b(e.path,p))d(i,n,r,`plugin-cleanup-protect:${t}`)};for(let{plugin:e,cleanup:t}of l){for(let n of t.protect??[]){if(n.kind===`glob`){h(n,e.name);continue}d(n.path,f(n),n.label==null?`plugin cleanup protect declaration`:`plugin cleanup protect declaration (${n.label})`,`plugin-cleanup-protect:${e.name}`)}for(let e of t.delete??[]){if(e.kind===`glob`){m(e);continue}e.kind===`directory`?u(e.path,`directory`):u(e.path,`file`)}}let g=lg({workspaceDir:t.collectedOutputContext.workspace.directory.path,projectRoots:ug(t.collectedOutputContext),rules:[...o.values()],...t.collectedOutputContext.aindexDir==null?{}:{aindexDir:t.collectedOutputContext.aindexDir}}),_=ax(c,g);if(_.length>0)throw new Jb(_);let v=pg([...i],g),y=pg([...a],g),b=rx(new Map(v.safePaths.map(e=>[e,e])),new Map(y.safePaths.map(e=>[e,e])));return{filesToDelete:b.files,dirsToDelete:b.dirs,violations:[...v.violations,...y.violations].sort((e,t)=>e.targetPath.localeCompare(t.targetPath)),conflicts:[],excludedScanGlobs:[...s].sort((e,t)=>e.localeCompare(t))}}async function cx(e,t){let n=e.map(e=>i.isAbsolute(e)?e:i.resolve(e)),r=await bt(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(B({code:`CLEANUP_FILE_DELETE_FAILED`,title:`Cleanup could not delete a file`,operation:`delete`,targetKind:`file`,path:e.path,error:n,details:{phase:`cleanup`}})),{path:e.path,type:`file`,error:e.error}});return{deleted:r.deleted,errors:a}}async function lx(e,t){let n=e.map(e=>i.isAbsolute(e)?e:i.resolve(e)),r=await xt(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(B({code:`CLEANUP_DIRECTORY_DELETE_FAILED`,title:`Cleanup could not delete a directory`,operation:`delete`,targetKind:`directory`,path:e.path,error:n,details:{phase:`cleanup`}})),{path:e.path,type:`directory`,error:e.error}});return{deleted:r.deleted,errors:a}}function ux(e,t){e.debug(`cleanup plan built`,{filesToDelete:t.filesToDelete.length,dirsToDelete:t.dirsToDelete.length,violations:t.violations.length,conflicts:t.conflicts.length,excludedScanGlobs:t.excludedScanGlobs})}async function dx(e,t,n,r){if(r!=null){let i=await vb(e,t,r);n.debug(`Collected outputs for cleanup`,{projectDirs:i.projectDirs.length,projectFiles:i.projectFiles.length,globalDirs:i.globalDirs.length,globalFiles:i.globalFiles.length})}let i;try{i=await sx(e,t,r)}catch(e){if(e instanceof Jb)return ox(n,e.conflicts),{deletedFiles:0,deletedDirs:0,errors:[],violations:[],conflicts:e.conflicts,message:e.message};throw e}let a={filesToDelete:i.filesToDelete,dirsToDelete:i.dirsToDelete,violations:i.violations,conflicts:i.conflicts,excludedScanGlobs:i.excludedScanGlobs};if(ux(n,a),a.violations.length>0)return hg(n,`cleanup`,a.violations),{deletedFiles:0,deletedDirs:0,errors:[],violations:a.violations,conflicts:[],message:`Protected deletion guard blocked cleanup for ${a.violations.length} path(s)`};let[o,s]=await Promise.all([cx(a.filesToDelete,n),lx(a.dirsToDelete,n)]);return{deletedFiles:o.deleted,deletedDirs:s.deleted,errors:[...o.errors,...s.errors],violations:[],conflicts:[]}}var fx=class{name=`clean`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r}=e;t.info(`running clean pipeline`,{command:`clean`});let i=await dx(n,r(!1),t);return i.violations.length>0||i.conflicts.length>0?{success:!1,filesAffected:0,dirsAffected:0,...i.message==null?{}:{message:i.message}}:(t.info(`clean complete`,{deletedFiles:i.deletedFiles,deletedDirs:i.deletedDirs}),{success:!0,filesAffected:i.deletedFiles,dirsAffected:i.deletedDirs})}},px=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 vb(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,violations:c,excludedScanGlobs:l}=await sx(n,i);return c.length>0?(hg(t,`dry-run-cleanup`,c),{success:!1,filesAffected:0,dirsAffected:0,message:`Protected deletion guard blocked cleanup for ${c.length} path(s)`}):(this.logDryRunFiles(o,t),this.logDryRunDirectories(s,t),t.info(`clean complete`,{dryRun:!0,filesAffected:o.length,dirsAffected:s.length,violations:0,excludedScanGlobs:l}),{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})}}},mx=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=await _b(n,r(!0)),a=0,o=0;for(let[e,n]of i)a+=n.files.length,o+=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:a,totalDirs:o,dryRun:!0}),{success:!0,filesAffected:a,dirsAffected:o,message:`Dry-run complete, no files were written`}}},hx=class{name=`execute`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r,createWriteContext:i}=e;t.info(`started`,{command:`execute`});let a=i(!1),o=await gb(n,a),s=await dx(n,r(!1),t,o);if(s.violations.length>0||s.conflicts.length>0)return{success:!1,filesAffected:0,dirsAffected:0,...s.message==null?{}:{message:s.message}};t.info(`cleanup complete`,{deletedFiles:s.deletedFiles,deletedDirs:s.deletedDirs});let c=await _b(n,a,o),l=0,u=0,d=[];for(let e of c.values()){l+=e.files.length,u+=e.dirs.length;for(let t of e.files)t.success||d.push(t.error?.message??`Failed to write ${t.path}`)}return d.length>0?{success:!1,filesAffected:l,dirsAffected:u,message:d.join(`
|
|
226
|
+
`)}:(t.info(`complete`,{command:`execute`,pluginCount:c.size}),{success:!0,filesAffected:l,dirsAffected:u})}},gx=class{name;inner;constructor(e){this.inner=e,this.name=`json:${e.name}`}async execute(e){Vt();let n=await this.inner.execute(e),r=_x(n,Ht());return t.stdout.write(`${JSON.stringify(r)}\n`),n}};function _x(e,t=Ht()){let{warnings:n,errors:r}=_t(t);return{success:e.success,filesAffected:e.filesAffected,dirsAffected:e.dirsAffected,...e.message!=null&&{message:e.message},pluginResults:[],warnings:n,errors:r}}var vx=class{name=`plugins`;async execute(e){let{logger:n,outputPlugins:r,userConfigOptions:i}=e,a=i.plugins,o=[];for(let e of a)o.push({name:e.name,kind:`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 t.stdout.write(`${JSON.stringify(o)}\n`),n.info(`plugins listed`,{count:o.length}),{success:!0,filesAffected:0,dirsAffected:0,message:`Listed ${o.length} plugin(s)`}}};const yx=[`IntelliJIdea`,`WebStorm`,`RustRover`,`PyCharm`,`PyCharmCE`,`PhpStorm`,`GoLand`,`CLion`,`DataGrip`,`RubyMine`,`Rider`,`DataSpell`,`Aqua`];function bx(e){return yx.some(t=>e.startsWith(t))}function xx(e){let t=i.join(vt(),`JetBrains`);try{return n.readdirSync(t,{withFileTypes:!0}).filter(e=>e.isDirectory()&&bx(e.name)).map(e=>i.join(t,e.name,`aia`,`codex`))}catch(n){return e.debug(B({code:`JETBRAINS_CODEX_DIRECTORY_SCAN_SKIPPED`,title:`JetBrains Codex directories are unavailable`,operation:`scan`,targetKind:`JetBrains IDE directory`,path:t,error:n})),[]}}function Sx(e){return{jetbrainsCodexDirs:xx(e)}}const Cx=`.agents/skills`,wx=`SKILL.md`;var Tx=class extends xb{constructor(){super(`GenericSkillsOutputPlugin`,{outputFileName:wx,treatWorkspaceRootProjectAsProject:!0,skills:{},cleanup:{delete:{project:{dirs:[Cx]},global:{dirs:[Cx]}}},capabilities:{skills:{scopes:[`project`,`global`],singleScope:!0},mcp:{scopes:[`project`,`global`],singleScope:!0}}})}async declareOutputFiles(e){let t=[],{skills:n}=e.collectedOutputContext;if(n==null||n.length===0)return t;let r=this.selectSingleScopeItems(n,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),i=this.selectSingleScopeItems(n,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`)),a=(e,n,r)=>{for(let i of r){let r=this.getSkillName(i),a=this.joinPath(e,r);if(t.push({path:this.joinPath(a,wx),scope:n,source:{kind:`skillMain`,skill:i}}),i.childDocs!=null)for(let e of i.childDocs)t.push({path:this.joinPath(a,e.relativePath.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillChildDoc`,content:e.content}});if(i.resources!=null)for(let e of i.resources)t.push({path:this.joinPath(a,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},o=(e,n,r)=>{for(let i of r)i.mcpConfig!=null&&t.push({path:this.joinPath(e,this.getSkillName(i),`mcp.json`),scope:n,source:{kind:`skillMcp`,rawContent:i.mcpConfig.rawContent}})};if(r.selectedScope===`project`||i.selectedScope===`project`)for(let t of this.getProjectOutputProjects(e)){let n=this.resolveProjectRootDir(e,t);if(n==null)continue;let s=$(r.items,t.projectConfig,`skills`),c=$(i.items,t.projectConfig,`skills`),l=this.joinPath(n,Cx);r.selectedScope===`project`&&s.length>0&&a(l,`project`,s),i.selectedScope===`project`&&o(l,`project`,c)}if(r.selectedScope!==`global`&&i.selectedScope!==`global`)return t;let s=this.joinPath(this.getHomeDir(),Cx),c=this.resolvePromptSourceProjectConfig(e);if(r.selectedScope===`global`){let e=$(r.items,c,`skills`);e.length>0&&a(s,`global`,e)}return i.selectedScope===`global`&&o(s,`global`,$(i.items,c,`skills`)),t}async convertContent(e,t){let n=e.source;switch(n.kind){case`skillMain`:{let e=this.buildSkillFrontMatter(n.skill);return this.buildMarkdownContent(n.skill.content,e,t)}case`skillMcp`:return n.rawContent;case`skillChildDoc`:return n.content;case`skillResource`:return n.encoding===`base64`?f.from(n.content,`base64`):n.content;default:throw Error(`Unsupported declaration source for ${this.name}`)}}};const Ex=`AGENTS.md`;var Dx=class extends xb{constructor(){super(`AgentsOutputPlugin`,{outputFileName:Ex,treatWorkspaceRootProjectAsProject:!0,cleanup:{delete:{project:{files:[Ex]}}},capabilities:{prompt:{scopes:[`project`],singleScope:!1}}})}async declareOutputFiles(e){let t=[],n=this.getProjectPromptOutputProjects(e);if(!new Set(this.selectPromptScopes(e,[`project`])).has(`project`))return t;for(let[r,i]of n.entries()){let n=this.resolveProjectRootDir(e,i);if(i.rootMemoryPrompt!=null&&n!=null&&t.push({path:this.resolvePath(n,Ex),scope:`project`,source:{type:`projectRootMemory`,projectIndex:r}}),i.childMemoryPrompts!=null)for(let[e,n]of i.childMemoryPrompts.entries())t.push({path:this.resolveFullPath(n.dir),scope:`project`,source:{type:`projectChildMemory`,projectIndex:r,childIndex:e}})}return t}async convertContent(e,t){let n=this.getProjectPromptOutputProjects(t),r=e.source,i=r.projectIndex??-1;if(i<0||i>=n.length)throw Error(`Invalid project index in declaration for ${this.name}`);let a=n[i];if(a==null)throw Error(`Project not found for declaration in ${this.name}`);if(r.type===`projectRootMemory`){if(a.rootMemoryPrompt==null)throw Error(`Root memory prompt missing for project index ${i}`);return a.rootMemoryPrompt.content}if(r.type===`projectChildMemory`){let e=r.childIndex??-1,t=a.childMemoryPrompts?.[e];if(t==null)throw Error(`Child memory prompt missing for project ${i}, child ${e}`);return t.content}throw Error(`Unsupported declaration source for ${this.name}`)}};const Ox=`CLAUDE.md`;var kx=class extends xb{constructor(){super(`ClaudeCodeCLIOutputPlugin`,{globalConfigDir:`.claude`,outputFileName:Ox,treatWorkspaceRootProjectAsProject:!0,toolPreset:`claudeCode`,commands:{subDir:`commands`,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},subagents:{subDir:`agents`,sourceScopes:[`project`],includePrefix:!0,linkSymbol:`-`,ext:`.md`},skills:{subDir:`skills`},rules:{transformFrontMatter:e=>({paths:e.globs.map(Zm)})},cleanup:{delete:{project:{files:[Ox],dirs:[`.claude/rules`,`.claude/commands`,`.claude/agents`,`.claude/skills`]},global:{files:[`.claude/CLAUDE.md`],dirs:[`.claude/rules`,`.claude/commands`,`.claude/agents`,`.claude/skills`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1},rules:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},subagents:{scopes:[`project`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0}}})}};const Ax=Ab.CURSOR,jx=wb.MCP_CONFIG,Mx=Tb.COMMANDS,Nx=Tb.RULES,Px=wb.CURSOR_GLOBAL_RULE,Fx=Tb.CURSOR_SKILLS,Ix=wb.SKILL,Lx=Mb.CURSOR;var Rx=class extends xb{constructor(){super(`CursorOutputPlugin`,{globalConfigDir:Ax,outputFileName:``,treatWorkspaceRootProjectAsProject:!0,dependsOn:[Cb.AgentsOutput],indexignore:jb.CURSOR,commands:{subDir:Mx,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:Fx},rules:{subDir:Nx,prefix:`rule`,sourceScopes:[`project`,`global`]},cleanup:{delete:{project:{files:[`.cursor/mcp.json`],dirs:[`.cursor/commands`,`.cursor/rules`],globs:[`.cursor/skills-cursor/*`]},global:{files:[`.cursor/mcp.json`],dirs:[`.cursor/commands`,`.cursor/rules`],globs:[`.cursor/skills-cursor/*`]}},protect:{project:{dirs:Array.from(Lx,e=>`.cursor/skills-cursor/${e}`)},global:{dirs:Array.from(Lx,e=>`.cursor/skills-cursor/${e}`)}}},capabilities:{prompt:{scopes:[`global`],singleScope:!1},rules:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0},mcp:{scopes:[`project`,`global`],singleScope:!0}}})}async declareCleanupPaths(e){let t=await super.declareCleanupPaths(e);return{...t,delete:(t.delete??[]).map(e=>e.kind!==`glob`||!e.path.replaceAll(`\\`,`/`).endsWith(`/.cursor/${Fx}/*`)?e:{...e,excludeBasenames:[...Lx]})}}async declareOutputFiles(e){let t=[],{globalMemory:n,commands:r,skills:a,rules:o,aiAgentIgnoreConfigFiles:s}=e.collectedOutputContext,c=this.getGlobalConfigDir(),l=this.resolvePromptSourceProjectConfig(e),u=this.getConcreteProjects(e),d=this.getProjectPromptOutputProjects(e),f=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),p=new Set(this.selectPromptScopes(e,[`global`])),m=new Set(o==null?[]:this.selectRuleScopes(e,o)),h=a==null?{items:[]}:this.selectSingleScopeItems(a,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),g=a==null?{items:[]}:this.selectSingleScopeItems(a,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`)),_=r==null?{items:[]}:this.selectSingleScopeItems(r,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)),v=(e,n,r)=>{for(let a of r){let r=this.getSkillName(a);if(this.isPreservedSkill(r))continue;let o=i.join(e,Fx,r);if(t.push({path:i.join(o,Ix),scope:n,source:{kind:`skill`,skill:a}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.relativePath.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillChildDoc`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},y=(e,n,r)=>{for(let a of r){if(a.mcpConfig==null)continue;let r=i.join(e,Fx,this.getSkillName(a));t.push({path:i.join(r,jx),scope:n,source:{kind:`skillMcpConfig`,rawContent:a.mcpConfig.rawContent}})}},b=(e,n,r)=>{if(r.length===0)return;let a=Wb(r,this.log);a.size!==0&&t.push({path:i.join(e,jx),scope:n,source:{kind:`mcpConfig`,mcpServers:Gb(a,Kb)}})};if(h.selectedScope===`project`||g.selectedScope===`project`)for(let t of this.getProjectOutputProjects(e)){let n=this.resolveProjectConfigDir(e,t);if(n!=null&&(h.selectedScope===`project`&&v(n,`project`,$(h.items,t.projectConfig,`skills`)),g.selectedScope===`project`)){let e=$(g.items,t.projectConfig,`skills`);y(n,`project`,e),b(n,`project`,e)}}if((h.selectedScope===`global`||g.selectedScope===`global`)&&(h.selectedScope===`global`&&v(c,`global`,$(h.items,l,`skills`)),g.selectedScope===`global`)){let e=$(g.items,l,`skills`);y(c,`global`,e),b(c,`global`,e)}if(_.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let a=$(_.items,n.projectConfig,`commands`);for(let e of a)t.push({path:i.join(r,Mx,this.transformCommandName(e,f)),scope:`project`,source:{kind:`command`,command:e}})}if(_.selectedScope===`global`){let e=$(_.items,l,`commands`);for(let n of e)t.push({path:i.join(c,Mx,this.transformCommandName(n,f)),scope:`global`,source:{kind:`command`,command:n}})}if(o!=null&&o.length>0){let n=o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`global`);if(m.has(`global`))for(let e of n)t.push({path:i.join(c,Nx,this.buildRuleFileName(e)),scope:`global`,source:{kind:`ruleMdc`,rule:e}});if(m.has(`project`))for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let a=by($(o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`project`),n.projectConfig,`rules`),n.projectConfig);for(let e of a)t.push({path:i.join(r,Nx,this.buildRuleFileName(e)),scope:`project`,source:{kind:`ruleMdc`,rule:e}})}}if(n!=null&&p.has(`global`)){let r=this.buildGlobalRuleContent(n.content,e);for(let n of d){let a=this.resolveProjectConfigDir(e,n);a!=null&&t.push({path:i.join(a,Nx,Px),scope:`project`,source:{kind:`globalRuleContent`,content:r}})}}let x=this.getIgnoreOutputPath(),S=this.indexignore==null?void 0:s?.find(e=>e.fileName===this.indexignore);if(x!=null&&S!=null)for(let e of u){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:i.join(n.basePath,n.path,x),scope:`project`,source:{kind:`ignoreFile`,content:S.content}})}return t}async convertContent(e,t){let n=e.source;switch(n.kind){case`command`:return this.buildCommandContent(n.command,t);case`mcpConfig`:return JSON.stringify({mcpServers:n.mcpServers},null,2);case`skill`:{let e=this.buildSkillFrontMatter(n.skill);return this.buildMarkdownContent(n.skill.content,e,t)}case`skillMcpConfig`:return n.rawContent;case`skillChildDoc`:case`globalRuleContent`:case`ignoreFile`:return n.content;case`skillResource`:return n.encoding===`base64`?f.from(n.content,`base64`):n.content;case`ruleMdc`:return this.buildRuleMdcContent(n.rule,t);default:throw Error(`Unsupported declaration source for ${this.name}`)}}buildGlobalRuleContent(e,t){return this.buildMarkdownContent(e,{description:`Global prompt (synced)`,alwaysApply:!0},t)}isPreservedSkill(e){return Lx.has(e)}buildRuleMdcContent(e,t){let n={alwaysApply:!1,globs:e.globs.length>0?e.globs.join(`, `):``};return this.buildMarkdownContent(e.content,n,t).split(`
|
|
222
227
|
`).map(e=>{let t=/^(\s*globs:\s*)(['"])(.*)\2\s*$/.exec(e);if(t==null)return e;let n=t[1]??`globs: `,r=t[3]??``;return r.trim().length===0?e:`${n}${r}`}).join(`
|
|
223
|
-
`)}};const
|
|
228
|
+
`)}};const zx=`AGENTS.md`;var Bx=class extends xb{constructor(){super(`DroidCLIOutputPlugin`,{globalConfigDir:`.factory`,outputFileName:zx,treatWorkspaceRootProjectAsProject:!0,commands:{transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{},cleanup:{delete:{project:{files:[zx],dirs:[`.factory/commands`,`.factory/skills`]},global:{files:[`.factory/AGENTS.md`],dirs:[`.factory/commands`,`.factory/skills`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0}}})}buildSkillMainContent(e,t){let n=e.yamlFrontMatter==null?void 0:{name:this.getSkillName(e),description:e.yamlFrontMatter.description};return this.buildMarkdownContent(e.content,n,t)}};const Vx=`.editorconfig`;var Hx=class extends xb{constructor(){super(`EditorConfigOutputPlugin`,{cleanup:{delete:{project:{files:[Vx]}}},capabilities:{}})}async declareOutputFiles(e){let t=[],{projects:n}=e.collectedOutputContext.workspace,{editorConfigFiles:r}=e.collectedOutputContext;if(r==null||r.length===0)return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null)for(let e of r)t.push({path:this.resolvePath(n.basePath,n.path,Vx),scope:`project`,source:{content:e.content}})}return t}async convertContent(e,t){let n=e.source;if(n.content==null)throw Error(`Unsupported declaration source for ${this.name}`);return n.content}};const Ux=`GEMINI.md`;var Wx=class extends xb{constructor(){super(`GeminiCLIOutputPlugin`,{globalConfigDir:`.gemini`,outputFileName:Ux,treatWorkspaceRootProjectAsProject:!0,cleanup:{delete:{project:{globs:[Ux]},global:{files:[`.gemini/GEMINI.md`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1}}})}},Gx=class extends xb{constructor(){super(`GitExcludeOutputPlugin`,{capabilities:{}})}async declareOutputFiles(e){let t=[],{workspace:n,globalGitIgnore:r,shadowGitExclude:a}=e.collectedOutputContext,o=this.buildManagedContent(r,a);if(o.length===0)return t;let s=this.normalizeContent(o),c=new Set,{projects:l}=n;for(let e of l){if(e.dirFromWorkspacePath==null)continue;let n=e.dirFromWorkspacePath.getAbsolutePath(),r=[n,...Sy(n)];for(let e of r){let n=xy(e);if(n==null)continue;let r=i.join(n,`exclude`);c.has(r)||(c.add(r),t.push({path:r,scope:`project`,source:{content:s}}))}}return t}async convertContent(e,t){let n=e.source;if(n.content==null)throw Error(`Unsupported declaration source for ${this.name}`);return n.content}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(`
|
|
224
229
|
`)}sanitizeContent(e){return e.split(/\r?\n/).filter(e=>{let t=e.trim();return t.length===0?!0:!(t.startsWith(`#`)&&!t.startsWith(`\\#`))}).join(`
|
|
225
|
-
`).trim()}normalizeContent(e){let t=e.trim();return t.length===0?``:`${t}\n`}};const ex=`AGENTS.md`,tx=`prompts`,nx=`skills`,rx=`.aiassistant`;var ix=class extends Ay{constructor(){super(`JetBrainsAIAssistantCodexOutputPlugin`,{outputFileName:ex,treatWorkspaceRootProjectAsProject:!0,commands:{subDir:tx,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:nx},dependsOn:[My.AgentsOutput],indexignore:`.aiignore`,cleanup:{delete:{project:{dirs:[`.aiassistant/rules`,`.aiassistant/codex/prompts`,`.aiassistant/codex/skills`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0}}})}async declareOutputFiles(e){let t=[],{globalMemory:n,commands:r,skills:a,aiAgentIgnoreConfigFiles:o}=e.collectedOutputContext,s=this.getConcreteProjects(e),c=this.getProjectPromptOutputProjects(e),l=this.getJetBrainsCodexDirs(e),u=new Set(this.selectPromptScopes(e,[`project`,`global`])),d=this.resolvePromptSourceProjectConfig(e),f=r==null?{items:[]}:this.selectSingleScopeItems(r,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)),p=a==null?{items:[]}:this.selectSingleScopeItems(a,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),m=this.getTransformOptionsFromContext(e);if(u.has(`project`))for(let n of c){let r=this.resolveProjectRootDir(e,n);if(r==null)continue;let a=i.join(r,rx,`rules`);if(n.rootMemoryPrompt!=null&&t.push({path:i.join(a,`always.md`),scope:`project`,source:{kind:`projectRuleContent`,content:this.buildAlwaysRuleContent(n.rootMemoryPrompt.content,e)}}),n.childMemoryPrompts!=null)for(let r of n.childMemoryPrompts)t.push({path:i.join(a,this.buildChildRuleFileName(r)),scope:`project`,source:{kind:`projectRuleContent`,content:this.buildGlobRuleContent(r,e)}})}let h=(e,n,r)=>{for(let a of r){let r=a.yamlFrontMatter?.name??a.dir.getDirectoryName(),o=i.join(e,nx,r);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skill`,skill:a}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.dir.path.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillReference`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}};if(f.selectedScope===`project`||p.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectRootDir(e,n);if(r==null)continue;let a=i.join(r,rx,`codex`);if(f.selectedScope===`project`){let e=$(f.items,n.projectConfig,`commands`);for(let n of e)t.push({path:i.join(a,tx,this.transformCommandName(n,m)),scope:`project`,source:{kind:`command`,command:n}})}p.selectedScope===`project`&&h(a,`project`,$(p.items,n.projectConfig,`skills`))}if(l.length>0){if(n!=null&&u.has(`global`))for(let e of l)t.push({path:i.join(e,ex),scope:`global`,source:{kind:`globalMemory`,content:n.content}});let e=f.selectedScope===`global`?$(f.items,d,`commands`):[],r=p.selectedScope===`global`?$(p.items,d,`skills`):[];for(let n of l){for(let r of e)t.push({path:i.join(n,tx,this.transformCommandName(r,m)),scope:`global`,source:{kind:`command`,command:r}});h(n,`global`,r)}}let g=this.getIgnoreOutputPath(),_=this.indexignore==null?void 0:o?.find(e=>e.fileName===this.indexignore);if(g!=null&&_!=null)for(let e of s){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:i.join(n.basePath,n.path,g),scope:`project`,source:{kind:`ignoreFile`,content:_.content}})}return t}async convertContent(e,t){let n=e.source;switch(n.kind){case`projectRuleContent`:case`globalMemory`:case`skillReference`:case`ignoreFile`:return n.content;case`command`:return this.buildCommandContent(n.command,t);case`skill`:return this.buildCodexSkillContent(n.skill,t);case`skillResource`:return n.encoding===`base64`?f.from(n.content,`base64`):n.content;default:throw Error(`Unsupported declaration source for ${this.name}`)}}async declareCleanupPaths(e){let t=await super.declareCleanupPaths(e),n=this.getJetBrainsCodexDirs(e);if(n.length===0)return t;let r=n.flatMap(e=>[{path:i.join(e,ex),kind:`file`,scope:`global`},{path:i.join(e,tx),kind:`directory`,scope:`global`},{path:i.join(e,nx),kind:`directory`,scope:`global`}]),a=t.delete??[];return{...t,delete:[...a,...r]}}getJetBrainsCodexDirs(e){return e.runtimeTargets.jetbrainsCodexDirs}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,t){return this.buildMarkdownContent(e,{apply:`始终`},t)}buildGlobRuleContent(e,t){let n={apply:`按文件模式`,模式:this.buildChildRulePattern(e)};return this.buildMarkdownContent(e.content,n,t)}buildCodexSkillContent(e,t){let n=e.yamlFrontMatter,r=this.normalizeSkillName(n.name,64),i=this.normalizeToSingleLine(n.description,1024),a={};n.displayName!=null&&(a[`short-description`]=n.displayName),n.version!=null&&(a.version=n.version),n.author!=null&&(a.author=n.author),n.keywords!=null&&n.keywords.length>0&&(a.keywords=[...n.keywords]);let o={name:r,description:i};return Object.keys(a).length>0&&(o.metadata=a),n.allowTools!=null&&n.allowTools.length>0&&(o[`allowed-tools`]=n.allowTools.join(` `)),this.buildMarkdownContent(e.content,o,t)}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 ax=`.idea`;var ox=class extends Ay{constructor(){super(`JetBrainsIDECodeStyleConfigOutputPlugin`,{cleanup:{delete:{project:{files:[`.editorconfig`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`]}}},capabilities:{}})}async declareOutputFiles(e){let t=[],{projects:n}=e.collectedOutputContext.workspace,{jetbrainsConfigFiles:r,editorConfigFiles:i}=e.collectedOutputContext,a=[...r??[],...i??[]];for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null)for(let e of a){let r=this.getTargetRelativePath(e);t.push({path:this.resolvePath(n.basePath,n.path,r),scope:`project`,source:{content:e.content}})}}return t}async convertContent(e,t){let n=e.source;if(n.content==null)throw Error(`Unsupported declaration source for ${this.name}`);return n.content}getTargetRelativePath(e){let t=e.dir.path;if(e.type===lh.EditorConfig)return`.editorconfig`;if(e.type!==lh.IntellijIDEA)return this.basename(t);let n=t.indexOf(ax);return n===-1?this.joinPath(ax,`codeStyles`,this.basename(t)):t.slice(Math.max(0,n))}};const sx=`AGENTS.md`,cx=`prompts`;var lx=class extends Ay{constructor(){super(`CodexCLIOutputPlugin`,{globalConfigDir:`.codex`,outputFileName:sx,commands:{subDir:cx,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},cleanup:{delete:{global:{files:[`.codex/AGENTS.md`],dirs:[`.codex/prompts`]}},protect:{global:{dirs:[`.codex/skills/.system`]}}},dependsOn:[My.AgentsOutput],capabilities:{prompt:{scopes:[`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0}}})}async declareOutputFiles(e){let{globalMemory:t,commands:n}=e.collectedOutputContext,r=this.getGlobalConfigDir(),a=[],o=new Set(this.selectPromptScopes(e,[`global`]));if(t!=null&&o.has(`global`)&&a.push({path:i.join(r,sx),scope:`global`,source:{kind:`globalMemory`,content:t.content}}),n==null||n.length===0)return a;let s=this.resolvePromptSourceProjectConfig(e),c=this.getTransformOptionsFromContext(e),l=this.selectSingleScopeItems(n,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`));if(l.items.length===0)return a;let u=$(l.items,s,`commands`);for(let e of u){let t=this.transformCommandName(e,c);a.push({path:i.join(r,cx,t),scope:`global`,source:{kind:`command`,command:e}})}return a}async convertContent(e,t){let n=e.source;if(n.kind===`globalMemory`)return n.content;if(n.kind===`command`)return this.buildCommandContent(n.command,t);throw Error(`Unsupported declaration source for ${this.name}`)}};const ux=`AGENTS.md`,dx=`commands`,fx=`agents`,px=`skills`;function mx(e,t){let n={},r=t.sourceFrontMatter;if(r?.description!=null&&(n.description=r.description),r?.agent!=null&&(n.agent=r.agent),r?.model!=null&&(n.model=r.model),r?.allowTools!=null&&Array.isArray(r.allowTools)){let e={};for(let t of r.allowTools)e[String(t)]=!0;n.tools=e}for(let[e,t]of Object.entries(r??{}))[`description`,`agent`,`model`,`allowTools`,`namingCase`,`argumentHint`].includes(e)||(n[e]=t);return n}var hx=class extends Ay{constructor(){super(`OpencodeCLIOutputPlugin`,{globalConfigDir:`.config/opencode`,outputFileName:ux,treatWorkspaceRootProjectAsProject:!0,commands:{subDir:dx,transformFrontMatter:mx},subagents:{subDir:fx},skills:{subDir:px},cleanup:{delete:{project:{files:[ux,`.opencode/opencode.json`],dirs:[`.opencode/commands`,`.opencode/agents`,`.opencode/skills`]},global:{files:[`.config/opencode/AGENTS.md`,`.config/opencode/opencode.json`],dirs:[`.config/opencode/commands`,`.config/opencode/agents`,`.config/opencode/skills`]},xdgConfig:{files:[`opencode/AGENTS.md`,`opencode/opencode.json`],dirs:[`opencode/commands`,`opencode/agents`,`opencode/skills`]}}},dependsOn:[My.AgentsOutput],capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},subagents:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0},mcp:{scopes:[`project`,`global`],singleScope:!0}}})}async declareOutputFiles(e){let t=[],{globalMemory:n,commands:r,subAgents:a,skills:o}=e.collectedOutputContext,s=this.getGlobalConfigDir(),c=new Set(this.selectPromptScopes(e,[`project`,`global`])),l=this.getProjectPromptOutputProjects(e),u=this.resolvePromptSourceProjectConfig(e),d=r==null?{items:[]}:this.selectSingleScopeItems(r,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)),f=a==null?{items:[]}:this.selectSingleScopeItems(a,this.subAgentsConfig.sourceScopes,e=>this.resolveSubAgentSourceScope(e),this.getTopicScopeOverride(e,`subagents`)),p=o==null?{items:[]}:this.selectSingleScopeItems(o,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),m=o==null?{items:[]}:this.selectSingleScopeItems(o,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`));n!=null&&c.has(`global`)&&t.push({path:i.join(s,ux),scope:`global`,source:{kind:`globalMemory`,content:n.content}});let h=(e,n,r)=>{if(r.length===0)return;let a=$y(r,this.log);a.size!==0&&t.push({path:i.join(e,`opencode.json`),scope:n,source:{kind:`mcpConfig`,mcpServers:eb(a,nb)}})},g=(e,n,r)=>{for(let a of r){let r=this.validateAndNormalizeSkillName(a.yamlFrontMatter?.name??a.dir.getDirectoryName()),o=i.join(e,px,r);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:a,normalizedSkillName:r}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.dir.path.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillReference`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},_=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});for(let n of l){let r=this.resolveProjectRootDir(e,n);if(r!=null&&(n.rootMemoryPrompt!=null&&c.has(`project`)&&t.push({path:i.join(r,ux),scope:`project`,source:{kind:`projectRootMemory`,content:n.rootMemoryPrompt.content}}),n.childMemoryPrompts!=null&&c.has(`project`)))for(let e of n.childMemoryPrompts)t.push({path:this.resolveFullPath(e.dir),scope:`project`,source:{kind:`projectChildMemory`,content:e.content}})}if(d.selectedScope===`project`||f.selectedScope===`project`||p.selectedScope===`project`||m.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectRootDir(e,n);if(r==null)continue;let a=i.join(r,`.opencode`),o=$(d.items,n.projectConfig,`commands`);if(d.selectedScope===`project`)for(let e of o)t.push({path:i.join(a,dx,this.transformCommandName(e,_)),scope:`project`,source:{kind:`command`,command:e}});let s=$(f.items,n.projectConfig,`subAgents`);if(f.selectedScope===`project`)for(let e of s)t.push({path:i.join(a,fx,this.transformSubAgentName(e)),scope:`project`,source:{kind:`subAgent`,agent:e}});let c=$(p.items,n.projectConfig,`skills`);p.selectedScope===`project`&&g(a,`project`,c);let l=$(m.items,n.projectConfig,`skills`);m.selectedScope===`project`&&h(a,`project`,l)}if(d.selectedScope===`global`){let e=$(d.items,u,`commands`);for(let n of e)t.push({path:i.join(s,dx,this.transformCommandName(n,_)),scope:`global`,source:{kind:`command`,command:n}})}if(f.selectedScope===`global`){let e=$(f.items,u,`subAgents`);for(let n of e)t.push({path:i.join(s,fx,this.transformSubAgentName(n)),scope:`global`,source:{kind:`subAgent`,agent:n}})}return p.selectedScope===`global`&&g(s,`global`,$(p.items,u,`skills`)),m.selectedScope===`global`&&h(s,`global`,$(m.items,u,`skills`)),t}async convertContent(e,t){let n=e.source;switch(n.kind){case`globalMemory`:case`projectRootMemory`:case`projectChildMemory`:case`skillReference`:return n.content;case`command`:return this.buildCommandContent(n.command,t);case`subAgent`:{let e=this.buildOpencodeAgentFrontMatter(n.agent);return this.buildMarkdownContent(n.agent.content,e,t)}case`skillMain`:{let e=this.buildOpencodeSkillFrontMatter(n.skill,n.normalizedSkillName);return this.buildMarkdownContent(n.skill.content,e,t)}case`skillResource`:return n.encoding===`base64`?f.from(n.content,`base64`):n.content;case`mcpConfig`:return JSON.stringify({$schema:`https://opencode.ai/config.json`,plugin:[`opencode-rules@latest`],mcp:n.mcpServers},null,2);default:throw Error(`Unsupported declaration source for ${this.name}`)}}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}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}};const gx=`rules`,_x=`commands`,vx=`skills`,yx=`glob`,bx=`glob`;function xx(e,t){let n=t.sourceFrontMatter,r={description:`Fast command`,type:`user_command`};return n?.description!=null&&(r.description=n.description),n?.argumentHint!=null&&(r.argumentHint=n.argumentHint),n?.allowTools!=null&&Array.isArray(n.allowTools)&&n.allowTools.length>0&&(r.allowTools=n.allowTools),r}var Sx=class extends Ay{constructor(){super(`QoderIDEPluginOutputPlugin`,{globalConfigDir:`.qoder`,treatWorkspaceRootProjectAsProject:!0,indexignore:`.qoderignore`,commands:{subDir:_x,transformFrontMatter:xx},skills:{subDir:vx},rules:{subDir:gx,sourceScopes:[`project`,`global`]},cleanup:{delete:{project:{dirs:[`.qoder/commands`,`.qoder/rules`,`.qoder/skills`]},global:{dirs:[`.qoder/commands`,`.qoder/rules`,`.qoder/skills`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1},rules:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0},mcp:{scopes:[`project`,`global`],singleScope:!0}}})}async declareOutputFiles(e){let t=[],{globalMemory:n,commands:r,skills:a,rules:o,aiAgentIgnoreConfigFiles:s}=e.collectedOutputContext,c=this.getGlobalConfigDir(),l=this.resolvePromptSourceProjectConfig(e),u=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),d=new Set(o==null?[]:this.selectRuleScopes(e,o)),f=new Set(this.selectPromptScopes(e,[`project`,`global`])),p=this.getProjectPromptOutputProjects(e),m=r==null?{items:[]}:this.selectSingleScopeItems(r,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)),h=a==null?{items:[]}:this.selectSingleScopeItems(a,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),g=a==null?{items:[]}:this.selectSingleScopeItems(a,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`)),_=(e,n,r)=>{for(let a of r){let r=a.yamlFrontMatter.name,o=i.join(e,vx,r);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:a}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.relativePath.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillChildDoc`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},v=(e,n,r)=>{for(let a of r){if(a.mcpConfig==null)continue;let r=i.join(e,vx,a.yamlFrontMatter.name);t.push({path:i.join(r,`mcp.json`),scope:n,source:{kind:`skillMcpConfig`,rawContent:a.mcpConfig.rawContent}})}};if(m.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let a=$(m.items,n.projectConfig,`commands`);for(let e of a)t.push({path:i.join(r,_x,this.transformCommandName(e,u)),scope:`project`,source:{kind:`command`,command:e}})}if(m.selectedScope===`global`){let e=$(m.items,l,`commands`);for(let n of e)t.push({path:i.join(c,_x,this.transformCommandName(n,u)),scope:`global`,source:{kind:`command`,command:n}})}if(h.selectedScope===`project`||g.selectedScope===`project`)for(let t of this.getProjectOutputProjects(e)){let n=this.resolveProjectConfigDir(e,t);n!=null&&(h.selectedScope===`project`&&_(n,`project`,$(h.items,t.projectConfig,`skills`)),g.selectedScope===`project`&&v(n,`project`,$(g.items,t.projectConfig,`skills`)))}if((h.selectedScope===`global`||g.selectedScope===`global`)&&(h.selectedScope===`global`&&_(c,`global`,$(h.items,l,`skills`)),g.selectedScope===`global`&&v(c,`global`,$(g.items,l,`skills`))),n!=null&&f.has(`global`))for(let r of p){let a=this.resolveProjectConfigDir(e,r);a!=null&&t.push({path:i.join(a,gx,`global.md`),scope:`project`,source:{kind:`ruleContent`,content:this.buildAlwaysRuleContent(n.content,e)}})}if(f.has(`project`))for(let n of p){let r=this.resolveProjectConfigDir(e,n);if(r!=null&&(n.rootMemoryPrompt!=null&&t.push({path:i.join(r,gx,`always.md`),scope:`project`,source:{kind:`ruleContent`,content:this.buildAlwaysRuleContent(n.rootMemoryPrompt.content,e)}}),n.childMemoryPrompts!=null))for(let a of n.childMemoryPrompts)t.push({path:i.join(r,gx,this.buildChildRuleFileName(a)),scope:`project`,source:{kind:`ruleContent`,content:this.buildGlobRuleContent(a,e)}})}if(o!=null&&o.length>0&&d.has(`project`))for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let a=Fv($(o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`project`),n.projectConfig,`rules`),n.projectConfig);for(let e of a)t.push({path:i.join(r,gx,this.buildRuleFileName(e)),scope:`project`,source:{kind:`rulePrompt`,rule:e}})}if(o!=null&&o.length>0&&d.has(`global`)){let e=o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`global`);for(let n of e)t.push({path:i.join(c,gx,this.buildRuleFileName(n)),scope:`global`,source:{kind:`rulePrompt`,rule:n}})}let y=this.getIgnoreOutputPath(),b=this.indexignore==null?void 0:s?.find(e=>e.fileName===this.indexignore);if(y!=null&&b!=null)for(let n of this.getConcreteProjects(e)){let e=n.dirFromWorkspacePath;e==null||n.isPromptSourceProject===!0||t.push({path:i.join(e.basePath,e.path,y),scope:`project`,source:{kind:`ignoreFile`,content:b.content}})}return t}async convertContent(e,t){let n=e.source;switch(n.kind){case`command`:return this.buildCommandContent(n.command,t);case`ruleContent`:return n.content;case`rulePrompt`:return this.buildRuleContent(n.rule,t);case`skillMain`:{let e=this.buildSkillFrontMatter(n.skill);return this.buildMarkdownContent(n.skill.content,e,t)}case`skillMcpConfig`:return n.rawContent;case`skillChildDoc`:case`ignoreFile`:return n.content;case`skillResource`:return n.encoding===`base64`?f.from(n.content,`base64`):n.content;default:throw Error(`Unsupported declaration source for ${this.name}`)}}buildChildRuleFileName(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`);return`glob-${t.length>0?t:`root`}.md`}buildAlwaysRuleContent(e,t){return this.buildMarkdownContent(e,{trigger:`always_on`,type:`user_command`},t)}buildGlobRuleContent(e,t){let n=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``),r=n.length===0?`**/*`:`${n}/**`;return this.buildMarkdownContent(e.content,{trigger:yx,[bx]:r,type:`user_command`},t)}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}}}buildRuleFileName(e,t=`rule-`){return`${t}${e.prefix}-${e.ruleName}.md`}buildRuleContent(e,t){let n={trigger:yx,[bx]:e.globs.length>0?e.globs.join(`, `):`**/*`,type:`user_command`};return this.buildMarkdownContent(e.content,n,t)}normalizeRuleScope(e){return e.scope??`global`}};function Cx(e){return vy[e??`Readme`].out}var wx=class extends Ay{constructor(){super(`ReadmeMdConfigFileOutputPlugin`,{outputFileName:`README.md`,cleanup:{delete:{project:{files:[`README.md`,`CODE_OF_CONDUCT.md`,`SECURITY.md`]}}},capabilities:{}})}async declareOutputFiles(e){let t=[],{readmePrompts:n}=e.collectedOutputContext;if(n==null||n.length===0)return t;for(let e of n){let n=Cx(e.fileKind),r=i.join(e.targetDir.basePath,e.targetDir.path,n);t.push({path:r,scope:`project`,source:{content:e.content}})}return t}async convertContent(e,t){let n=e.source;if(n.content==null)throw Error(`Unsupported declaration source for ${this.name}`);return n.content}};const Tx=`GLOBAL.md`,Ex=`.trae`,Dx=`commands`,Ox=`skills`;var kx=class extends Ay{constructor(){super(`TraeIDEOutputPlugin`,{globalConfigDir:Ex,outputFileName:Tx,treatWorkspaceRootProjectAsProject:!0,indexignore:`.traeignore`,commands:{subDir:Dx,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:Ox},cleanup:{delete:{project:{dirs:[`.trae/rules`,`.trae/commands`,`.trae/skills`]},global:{dirs:[`.trae/steering`,`.trae/commands`,`.trae/skills`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0}}})}getIgnoreOutputPath(){if(this.indexignore!=null)return i.join(`.trae`,`.ignore`)}getGlobalSteeringDir(){return this.joinPath(this.getGlobalConfigDir(),`steering`)}async declareOutputFiles(e){let t=[],{commands:n,skills:r,globalMemory:a,aiAgentIgnoreConfigFiles:o}=e.collectedOutputContext,s=this.getConcreteProjects(e),c=this.getProjectPromptOutputProjects(e),l=this.resolvePromptSourceProjectConfig(e),u=new Set(this.selectPromptScopes(e,[`project`,`global`])),d=n==null?{items:[]}:this.selectSingleScopeItems(n,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)),f=r==null?{items:[]}:this.selectSingleScopeItems(r,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),p=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});a!=null&&u.has(`global`)&&t.push({path:this.joinPath(this.getGlobalSteeringDir(),Tx),scope:`global`,source:{kind:`globalMemory`,content:a.content}});for(let n of c){let r=this.resolveProjectRootDir(e,n);if(r!=null&&n.childMemoryPrompts!=null&&u.has(`project`))for(let a of n.childMemoryPrompts){let n=(a.workingChildDirectoryPath?.path??a.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``),o=this.buildProjectRelativeGlobPattern(n),s=this.buildMarkdownContent([this.buildPathGuardHint(n),``,a.content].join(`
|
|
226
|
-
`),{alwaysApply:!1,globs:o},e);t.push({path:i.join(r,
|
|
227
|
-
`)}buildProjectRelativeGlobPattern(e){return e.length===0?`**/*`:`${e}/**`}};const
|
|
230
|
+
`).trim()}normalizeContent(e){let t=e.trim();return t.length===0?``:`${t}\n`}};const Kx=`AGENTS.md`,qx=`prompts`,Jx=`skills`,Yx=`.aiassistant`;var Xx=class extends xb{constructor(){super(`JetBrainsAIAssistantCodexOutputPlugin`,{outputFileName:Kx,treatWorkspaceRootProjectAsProject:!0,commands:{subDir:qx,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:Jx},dependsOn:[Cb.AgentsOutput],indexignore:`.aiignore`,cleanup:{delete:{project:{dirs:[`.aiassistant/rules`,`.aiassistant/codex/prompts`,`.aiassistant/codex/skills`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0}}})}async declareOutputFiles(e){let t=[],{globalMemory:n,commands:r,skills:a,aiAgentIgnoreConfigFiles:o}=e.collectedOutputContext,s=this.getConcreteProjects(e),c=this.getProjectPromptOutputProjects(e),l=this.getJetBrainsCodexDirs(e),u=new Set(this.selectPromptScopes(e,[`project`,`global`])),d=this.resolvePromptSourceProjectConfig(e),f=r==null?{items:[]}:this.selectSingleScopeItems(r,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)),p=a==null?{items:[]}:this.selectSingleScopeItems(a,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),m=this.getTransformOptionsFromContext(e);if(u.has(`project`))for(let n of c){let r=this.resolveProjectRootDir(e,n);if(r==null)continue;let a=i.join(r,Yx,`rules`);if(n.rootMemoryPrompt!=null&&t.push({path:i.join(a,`always.md`),scope:`project`,source:{kind:`projectRuleContent`,content:this.buildAlwaysRuleContent(n.rootMemoryPrompt.content,e)}}),n.childMemoryPrompts!=null)for(let r of n.childMemoryPrompts)t.push({path:i.join(a,this.buildChildRuleFileName(r)),scope:`project`,source:{kind:`projectRuleContent`,content:this.buildGlobRuleContent(r,e)}})}let h=(e,n,r)=>{for(let a of r){let r=this.getSkillName(a),o=i.join(e,Jx,r);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skill`,skill:a}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.dir.path.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillReference`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}};if(f.selectedScope===`project`||p.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectRootDir(e,n);if(r==null)continue;let a=i.join(r,Yx,`codex`);if(f.selectedScope===`project`){let e=$(f.items,n.projectConfig,`commands`);for(let n of e)t.push({path:i.join(a,qx,this.transformCommandName(n,m)),scope:`project`,source:{kind:`command`,command:n}})}p.selectedScope===`project`&&h(a,`project`,$(p.items,n.projectConfig,`skills`))}if(l.length>0){if(n!=null&&u.has(`global`))for(let e of l)t.push({path:i.join(e,Kx),scope:`global`,source:{kind:`globalMemory`,content:n.content}});let e=f.selectedScope===`global`?$(f.items,d,`commands`):[],r=p.selectedScope===`global`?$(p.items,d,`skills`):[];for(let n of l){for(let r of e)t.push({path:i.join(n,qx,this.transformCommandName(r,m)),scope:`global`,source:{kind:`command`,command:r}});h(n,`global`,r)}}let g=this.getIgnoreOutputPath(),_=this.indexignore==null?void 0:o?.find(e=>e.fileName===this.indexignore);if(g!=null&&_!=null)for(let e of s){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:i.join(n.basePath,n.path,g),scope:`project`,source:{kind:`ignoreFile`,content:_.content}})}return t}async convertContent(e,t){let n=e.source;switch(n.kind){case`projectRuleContent`:case`globalMemory`:case`skillReference`:case`ignoreFile`:return n.content;case`command`:return this.buildCommandContent(n.command,t);case`skill`:return this.buildCodexSkillContent(n.skill,t);case`skillResource`:return n.encoding===`base64`?f.from(n.content,`base64`):n.content;default:throw Error(`Unsupported declaration source for ${this.name}`)}}async declareCleanupPaths(e){let t=await super.declareCleanupPaths(e),n=this.getJetBrainsCodexDirs(e);if(n.length===0)return t;let r=n.flatMap(e=>[{path:i.join(e,Kx),kind:`file`,scope:`global`},{path:i.join(e,qx),kind:`directory`,scope:`global`},{path:i.join(e,Jx),kind:`directory`,scope:`global`}]),a=t.delete??[];return{...t,delete:[...a,...r]}}getJetBrainsCodexDirs(e){return e.runtimeTargets.jetbrainsCodexDirs}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,t){return this.buildMarkdownContent(e,{apply:`始终`},t)}buildGlobRuleContent(e,t){let n={apply:`按文件模式`,模式:this.buildChildRulePattern(e)};return this.buildMarkdownContent(e.content,n,t)}buildCodexSkillContent(e,t){let n=e.yamlFrontMatter,r=this.normalizeSkillName(this.getSkillName(e),64),i=this.normalizeToSingleLine(n.description,1024),a={};n.displayName!=null&&(a[`short-description`]=n.displayName),n.version!=null&&(a.version=n.version),n.author!=null&&(a.author=n.author),n.keywords!=null&&n.keywords.length>0&&(a.keywords=[...n.keywords]);let o={name:r,description:i};return Object.keys(a).length>0&&(o.metadata=a),n.allowTools!=null&&n.allowTools.length>0&&(o[`allowed-tools`]=n.allowTools.join(` `)),this.buildMarkdownContent(e.content,o,t)}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 Zx=`.idea`;var Qx=class extends xb{constructor(){super(`JetBrainsIDECodeStyleConfigOutputPlugin`,{cleanup:{delete:{project:{files:[`.editorconfig`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`]}}},capabilities:{}})}async declareOutputFiles(e){let t=[],{projects:n}=e.collectedOutputContext.workspace,{jetbrainsConfigFiles:r,editorConfigFiles:i}=e.collectedOutputContext,a=[...r??[],...i??[]];for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null)for(let e of a){let r=this.getTargetRelativePath(e);t.push({path:this.resolvePath(n.basePath,n.path,r),scope:`project`,source:{content:e.content}})}}return t}async convertContent(e,t){let n=e.source;if(n.content==null)throw Error(`Unsupported declaration source for ${this.name}`);return n.content}getTargetRelativePath(e){let t=e.dir.path;if(e.type===_h.EditorConfig)return`.editorconfig`;if(e.type!==_h.IntellijIDEA)return this.basename(t);let n=t.indexOf(Zx);return n===-1?this.joinPath(Zx,`codeStyles`,this.basename(t)):t.slice(Math.max(0,n))}};const $x=[`name`,`description`,`developer_instructions`],eS=[`scope`,`seriName`,`argumentHint`,`color`,`namingCase`,`model`];function tS(e,t){let n={...t};return n.name=e,Array.isArray(n.allowTools)&&n.allowTools.length>0&&(n.allowedTools=n.allowTools.join(`, `)),delete n.allowTools,n}const nS={globalConfigDir:`.codex`,outputFileName:`AGENTS.md`,commands:{subDir:`prompts`,scopeRemap:{project:`global`},transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},subagents:{subDir:`agents`,sourceScopes:[`project`],scopeRemap:{global:`project`},ext:`.toml`,artifactFormat:`toml`,bodyFieldName:`developer_instructions`,excludedFrontMatterFields:eS,transformFrontMatter:(e,t)=>tS(Ny(e),t.sourceFrontMatter),fieldOrder:$x},cleanup:{delete:{project:{dirs:[`.codex/agents`]},global:{files:[`.codex/AGENTS.md`],dirs:[`.codex/prompts`]}},protect:{global:{dirs:[`.codex/skills/.system`]}}},dependsOn:[Cb.AgentsOutput],capabilities:{prompt:{scopes:[`global`],singleScope:!1},commands:{scopes:[`global`],singleScope:!0},subagents:{scopes:[`project`],singleScope:!0}}};var rS=class extends xb{constructor(){super(`CodexCLIOutputPlugin`,nS)}};const iS=`AGENTS.md`,aS=`commands`,oS=`agents`,sS=`skills`;function cS(e,t){let n={},r=t.sourceFrontMatter;if(r?.description!=null&&(n.description=r.description),r?.agent!=null&&(n.agent=r.agent),r?.model!=null&&(n.model=r.model),r?.allowTools!=null&&Array.isArray(r.allowTools)){let e={};for(let t of r.allowTools)e[String(t)]=!0;n.tools=e}for(let[e,t]of Object.entries(r??{}))[`description`,`agent`,`model`,`allowTools`,`namingCase`,`argumentHint`].includes(e)||(n[e]=t);return n}var lS=class extends xb{constructor(){super(`OpencodeCLIOutputPlugin`,{globalConfigDir:`.config/opencode`,outputFileName:iS,treatWorkspaceRootProjectAsProject:!0,commands:{subDir:aS,transformFrontMatter:cS},subagents:{subDir:oS},skills:{subDir:sS},cleanup:{delete:{project:{files:[iS,`.opencode/opencode.json`],dirs:[`.opencode/commands`,`.opencode/agents`,`.opencode/skills`]},global:{files:[`.config/opencode/AGENTS.md`,`.config/opencode/opencode.json`],dirs:[`.config/opencode/commands`,`.config/opencode/agents`,`.config/opencode/skills`]},xdgConfig:{files:[`opencode/AGENTS.md`,`opencode/opencode.json`],dirs:[`opencode/commands`,`opencode/agents`,`opencode/skills`]}}},dependsOn:[Cb.AgentsOutput],capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},subagents:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0},mcp:{scopes:[`project`,`global`],singleScope:!0}}})}async declareOutputFiles(e){let t=[],{globalMemory:n,commands:r,subAgents:a,skills:o}=e.collectedOutputContext,s=this.getGlobalConfigDir(),c=new Set(this.selectPromptScopes(e,[`project`,`global`])),l=this.getProjectPromptOutputProjects(e),u=this.resolvePromptSourceProjectConfig(e),d=r==null?{items:[]}:this.selectSingleScopeItems(r,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)),f=a==null?{items:[]}:this.selectSingleScopeItems(a,this.subAgentsConfig.sourceScopes,e=>this.resolveSubAgentSourceScope(e),this.getTopicScopeOverride(e,`subagents`)),p=o==null?{items:[]}:this.selectSingleScopeItems(o,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),m=o==null?{items:[]}:this.selectSingleScopeItems(o,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`));n!=null&&c.has(`global`)&&t.push({path:i.join(s,iS),scope:`global`,source:{kind:`globalMemory`,content:n.content}});let h=(e,n,r)=>{if(r.length===0)return;let a=Wb(r,this.log);a.size!==0&&t.push({path:i.join(e,`opencode.json`),scope:n,source:{kind:`mcpConfig`,mcpServers:Gb(a,qb)}})},g=(e,n,r)=>{for(let a of r){let r=this.validateAndNormalizeSkillName(this.getSkillName(a)),o=i.join(e,sS,r);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:a,normalizedSkillName:r}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.dir.path.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillReference`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},_=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});for(let n of l){let r=this.resolveProjectRootDir(e,n);if(r!=null&&(n.rootMemoryPrompt!=null&&c.has(`project`)&&t.push({path:i.join(r,iS),scope:`project`,source:{kind:`projectRootMemory`,content:n.rootMemoryPrompt.content}}),n.childMemoryPrompts!=null&&c.has(`project`)))for(let e of n.childMemoryPrompts)t.push({path:this.resolveFullPath(e.dir),scope:`project`,source:{kind:`projectChildMemory`,content:e.content}})}if(d.selectedScope===`project`||f.selectedScope===`project`||p.selectedScope===`project`||m.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectRootDir(e,n);if(r==null)continue;let a=i.join(r,`.opencode`),o=$(d.items,n.projectConfig,`commands`);if(d.selectedScope===`project`)for(let e of o)t.push({path:i.join(a,aS,this.transformCommandName(e,_)),scope:`project`,source:{kind:`command`,command:e}});let s=$(f.items,n.projectConfig,`subAgents`);if(f.selectedScope===`project`)for(let e of s)t.push({path:i.join(a,oS,this.transformSubAgentName(e)),scope:`project`,source:{kind:`subAgent`,agent:e}});let c=$(p.items,n.projectConfig,`skills`);p.selectedScope===`project`&&g(a,`project`,c);let l=$(m.items,n.projectConfig,`skills`);m.selectedScope===`project`&&h(a,`project`,l)}if(d.selectedScope===`global`){let e=$(d.items,u,`commands`);for(let n of e)t.push({path:i.join(s,aS,this.transformCommandName(n,_)),scope:`global`,source:{kind:`command`,command:n}})}if(f.selectedScope===`global`){let e=$(f.items,u,`subAgents`);for(let n of e)t.push({path:i.join(s,oS,this.transformSubAgentName(n)),scope:`global`,source:{kind:`subAgent`,agent:n}})}return p.selectedScope===`global`&&g(s,`global`,$(p.items,u,`skills`)),m.selectedScope===`global`&&h(s,`global`,$(m.items,u,`skills`)),t}async convertContent(e,t){let n=e.source;switch(n.kind){case`globalMemory`:case`projectRootMemory`:case`projectChildMemory`:case`skillReference`:return n.content;case`command`:return this.buildCommandContent(n.command,t);case`subAgent`:{let e=this.buildOpencodeAgentFrontMatter(n.agent);return this.buildMarkdownContent(n.agent.content,e,t)}case`skillMain`:{let e=this.buildOpencodeSkillFrontMatter(n.skill,n.normalizedSkillName);return this.buildMarkdownContent(n.skill.content,e,t)}case`skillResource`:return n.encoding===`base64`?f.from(n.content,`base64`):n.content;case`mcpConfig`:return JSON.stringify({$schema:`https://opencode.ai/config.json`,plugin:[`opencode-rules@latest`],mcp:n.mcpServers},null,2);default:throw Error(`Unsupported declaration source for ${this.name}`)}}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}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}};const uS=`rules`,dS=`commands`,fS=`skills`,pS=`glob`,mS=`glob`;function hS(e,t){let n=t.sourceFrontMatter,r={description:`Fast command`,type:`user_command`};return n?.description!=null&&(r.description=n.description),n?.argumentHint!=null&&(r.argumentHint=n.argumentHint),n?.allowTools!=null&&Array.isArray(n.allowTools)&&n.allowTools.length>0&&(r.allowTools=n.allowTools),r}var gS=class extends xb{constructor(){super(`QoderIDEPluginOutputPlugin`,{globalConfigDir:`.qoder`,treatWorkspaceRootProjectAsProject:!0,indexignore:`.qoderignore`,commands:{subDir:dS,transformFrontMatter:hS},skills:{subDir:fS},rules:{subDir:uS,sourceScopes:[`project`,`global`]},cleanup:{delete:{project:{dirs:[`.qoder/commands`,`.qoder/rules`,`.qoder/skills`]},global:{dirs:[`.qoder/commands`,`.qoder/rules`,`.qoder/skills`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1},rules:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0},mcp:{scopes:[`project`,`global`],singleScope:!0}}})}async declareOutputFiles(e){let t=[],{globalMemory:n,commands:r,skills:a,rules:o,aiAgentIgnoreConfigFiles:s}=e.collectedOutputContext,c=this.getGlobalConfigDir(),l=this.resolvePromptSourceProjectConfig(e),u=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),d=new Set(o==null?[]:this.selectRuleScopes(e,o)),f=new Set(this.selectPromptScopes(e,[`project`,`global`])),p=this.getProjectPromptOutputProjects(e),m=r==null?{items:[]}:this.selectSingleScopeItems(r,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)),h=a==null?{items:[]}:this.selectSingleScopeItems(a,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),g=a==null?{items:[]}:this.selectSingleScopeItems(a,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`)),_=(e,n,r)=>{for(let a of r){let r=this.getSkillName(a),o=i.join(e,fS,r);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:a}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.relativePath.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillChildDoc`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},v=(e,n,r)=>{for(let a of r){if(a.mcpConfig==null)continue;let r=i.join(e,fS,this.getSkillName(a));t.push({path:i.join(r,`mcp.json`),scope:n,source:{kind:`skillMcpConfig`,rawContent:a.mcpConfig.rawContent}})}};if(m.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let a=$(m.items,n.projectConfig,`commands`);for(let e of a)t.push({path:i.join(r,dS,this.transformCommandName(e,u)),scope:`project`,source:{kind:`command`,command:e}})}if(m.selectedScope===`global`){let e=$(m.items,l,`commands`);for(let n of e)t.push({path:i.join(c,dS,this.transformCommandName(n,u)),scope:`global`,source:{kind:`command`,command:n}})}if(h.selectedScope===`project`||g.selectedScope===`project`)for(let t of this.getProjectOutputProjects(e)){let n=this.resolveProjectConfigDir(e,t);n!=null&&(h.selectedScope===`project`&&_(n,`project`,$(h.items,t.projectConfig,`skills`)),g.selectedScope===`project`&&v(n,`project`,$(g.items,t.projectConfig,`skills`)))}if((h.selectedScope===`global`||g.selectedScope===`global`)&&(h.selectedScope===`global`&&_(c,`global`,$(h.items,l,`skills`)),g.selectedScope===`global`&&v(c,`global`,$(g.items,l,`skills`))),n!=null&&f.has(`global`))for(let r of p){let a=this.resolveProjectConfigDir(e,r);a!=null&&t.push({path:i.join(a,uS,`global.md`),scope:`project`,source:{kind:`ruleContent`,content:this.buildAlwaysRuleContent(n.content,e)}})}if(f.has(`project`))for(let n of p){let r=this.resolveProjectConfigDir(e,n);if(r!=null&&(n.rootMemoryPrompt!=null&&t.push({path:i.join(r,uS,`always.md`),scope:`project`,source:{kind:`ruleContent`,content:this.buildAlwaysRuleContent(n.rootMemoryPrompt.content,e)}}),n.childMemoryPrompts!=null))for(let a of n.childMemoryPrompts)t.push({path:i.join(r,uS,this.buildChildRuleFileName(a)),scope:`project`,source:{kind:`ruleContent`,content:this.buildGlobRuleContent(a,e)}})}if(o!=null&&o.length>0&&d.has(`project`))for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let a=by($(o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`project`),n.projectConfig,`rules`),n.projectConfig);for(let e of a)t.push({path:i.join(r,uS,this.buildRuleFileName(e)),scope:`project`,source:{kind:`rulePrompt`,rule:e}})}if(o!=null&&o.length>0&&d.has(`global`)){let e=o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`global`);for(let n of e)t.push({path:i.join(c,uS,this.buildRuleFileName(n)),scope:`global`,source:{kind:`rulePrompt`,rule:n}})}let y=this.getIgnoreOutputPath(),b=this.indexignore==null?void 0:s?.find(e=>e.fileName===this.indexignore);if(y!=null&&b!=null)for(let n of this.getConcreteProjects(e)){let e=n.dirFromWorkspacePath;e==null||n.isPromptSourceProject===!0||t.push({path:i.join(e.basePath,e.path,y),scope:`project`,source:{kind:`ignoreFile`,content:b.content}})}return t}async convertContent(e,t){let n=e.source;switch(n.kind){case`command`:return this.buildCommandContent(n.command,t);case`ruleContent`:return n.content;case`rulePrompt`:return this.buildRuleContent(n.rule,t);case`skillMain`:{let e=this.buildSkillFrontMatter(n.skill);return this.buildMarkdownContent(n.skill.content,e,t)}case`skillMcpConfig`:return n.rawContent;case`skillChildDoc`:case`ignoreFile`:return n.content;case`skillResource`:return n.encoding===`base64`?f.from(n.content,`base64`):n.content;default:throw Error(`Unsupported declaration source for ${this.name}`)}}buildChildRuleFileName(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`);return`glob-${t.length>0?t:`root`}.md`}buildAlwaysRuleContent(e,t){return this.buildMarkdownContent(e,{trigger:`always_on`,type:`user_command`},t)}buildGlobRuleContent(e,t){let n=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``),r=n.length===0?`**/*`:`${n}/**`;return this.buildMarkdownContent(e.content,{trigger:pS,[mS]:r,type:`user_command`},t)}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:this.getSkillName(e),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}}}buildRuleFileName(e,t=`rule-`){return`${t}${e.prefix}-${e.ruleName}.md`}buildRuleContent(e,t){let n={trigger:pS,[mS]:e.globs.length>0?e.globs.join(`, `):`**/*`,type:`user_command`};return this.buildMarkdownContent(e.content,n,t)}normalizeRuleScope(e){return e.scope??`global`}};function _S(e){return cb[e??`Readme`].out}var vS=class extends xb{constructor(){super(`ReadmeMdConfigFileOutputPlugin`,{outputFileName:`README.md`,cleanup:{delete:{project:{files:[`README.md`,`CODE_OF_CONDUCT.md`,`SECURITY.md`]}}},capabilities:{}})}async declareOutputFiles(e){let t=[],{readmePrompts:n}=e.collectedOutputContext;if(n==null||n.length===0)return t;for(let e of n){let n=_S(e.fileKind),r=i.join(e.targetDir.basePath,e.targetDir.path,n);t.push({path:r,scope:`project`,source:{content:e.content}})}return t}async convertContent(e,t){let n=e.source;if(n.content==null)throw Error(`Unsupported declaration source for ${this.name}`);return n.content}};const yS=`GLOBAL.md`,bS=`.trae`,xS=`commands`,SS=`skills`;var CS=class extends xb{constructor(){super(`TraeIDEOutputPlugin`,{globalConfigDir:bS,outputFileName:yS,treatWorkspaceRootProjectAsProject:!0,indexignore:`.traeignore`,commands:{subDir:xS,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:SS},cleanup:{delete:{project:{dirs:[`.trae/rules`,`.trae/commands`,`.trae/skills`]},global:{dirs:[`.trae/steering`,`.trae/commands`,`.trae/skills`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0}}})}getIgnoreOutputPath(){if(this.indexignore!=null)return i.join(`.trae`,`.ignore`)}getGlobalSteeringDir(){return this.joinPath(this.getGlobalConfigDir(),`steering`)}async declareOutputFiles(e){let t=[],{commands:n,skills:r,globalMemory:a,aiAgentIgnoreConfigFiles:o}=e.collectedOutputContext,s=this.getConcreteProjects(e),c=this.getProjectPromptOutputProjects(e),l=this.resolvePromptSourceProjectConfig(e),u=new Set(this.selectPromptScopes(e,[`project`,`global`])),d=n==null?{items:[]}:this.selectSingleScopeItems(n,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)),f=r==null?{items:[]}:this.selectSingleScopeItems(r,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),p=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});a!=null&&u.has(`global`)&&t.push({path:this.joinPath(this.getGlobalSteeringDir(),yS),scope:`global`,source:{kind:`globalMemory`,content:a.content}});for(let n of c){let r=this.resolveProjectRootDir(e,n);if(r!=null&&n.childMemoryPrompts!=null&&u.has(`project`))for(let a of n.childMemoryPrompts){let n=(a.workingChildDirectoryPath?.path??a.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``),o=this.buildProjectRelativeGlobPattern(n),s=this.buildMarkdownContent([this.buildPathGuardHint(n),``,a.content].join(`
|
|
231
|
+
`),{alwaysApply:!1,globs:o},e);t.push({path:i.join(r,bS,`rules`,this.buildSteeringFileName(a)),scope:`project`,source:{kind:`steeringRule`,content:s}})}}if(d.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let a=$(d.items,n.projectConfig,`commands`);for(let e of a)t.push({path:i.join(r,xS,this.transformCommandName(e,p)),scope:`project`,source:{kind:`command`,command:e}})}if(d.selectedScope===`global`){let e=this.getGlobalConfigDir(),n=$(d.items,l,`commands`);for(let r of n)t.push({path:i.join(e,xS,this.transformCommandName(r,p)),scope:`global`,source:{kind:`command`,command:r}})}let m=(e,n,r)=>{for(let a of r){let r=this.getSkillName(a),o=i.join(e,SS,r);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:a}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.relativePath.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillChildDoc`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}};if(f.selectedScope===`project`)for(let t of this.getProjectOutputProjects(e)){let n=this.resolveProjectConfigDir(e,t);n!=null&&m(n,`project`,$(f.items,t.projectConfig,`skills`))}f.selectedScope===`global`&&m(this.getGlobalConfigDir(),`global`,$(f.items,l,`skills`));let h=this.getIgnoreOutputPath(),g=this.indexignore==null?void 0:o?.find(e=>e.fileName===this.indexignore);if(h!=null&&g!=null)for(let e of s){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:i.join(n.basePath,n.path,h),scope:`project`,source:{kind:`ignoreFile`,content:g.content}})}return t}async convertContent(e,t){let n=e.source;switch(n.kind){case`globalMemory`:case`steeringRule`:case`skillChildDoc`:case`ignoreFile`:return n.content;case`command`:return this.buildCommandContent(n.command,t);case`skillMain`:{let e=this.buildSkillFrontMatter(n.skill);return this.buildMarkdownContent(n.skill.content,e,t)}case`skillResource`:return n.encoding===`base64`?f.from(n.content,`base64`):n.content;default:throw Error(`Unsupported declaration source for ${this.name}`)}}buildSkillFrontMatter(e){let t={description:e.yamlFrontMatter.description??``};return e.yamlFrontMatter.displayName!=null&&(t.name=e.yamlFrontMatter.displayName),t}buildSteeringFileName(e){return`trae-${(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`)}.md`}buildPathGuardHint(e){return e.length===0?`Scope guard: apply this rule to project source files only; do not apply to generated output directories (for example dist/, build/, out/, .next/, target/).`:[`Scope guard: this rule is for the project-root path "${e}/" only.`,`Do not apply this rule to generated output paths such as "dist/${e}/", "build/${e}/", "out/${e}/", ".next/${e}/", or "target/${e}/".`].join(`
|
|
232
|
+
`)}buildProjectRelativeGlobPattern(e){return e.length===0?`**/*`:`${e}/**`}};const wS=`.vscode`;var TS=class extends xb{constructor(){super(`VisualStudioCodeIDEConfigOutputPlugin`,{cleanup:{delete:{project:{files:[`.vscode/settings.json`,`.vscode/extensions.json`]}}},capabilities:{}})}async declareOutputFiles(e){let t=[],{projects:n}=e.collectedOutputContext.workspace,{vscodeConfigFiles:r}=e.collectedOutputContext,i=r??[];for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null)for(let e of i){let r=this.getTargetRelativePath(e);t.push({path:this.resolvePath(n.basePath,n.path,r),scope:`project`,source:{content:e.content}})}}return t}async convertContent(e,t){let n=e.source;if(n.content==null)throw Error(`Unsupported declaration source for ${this.name}`);return n.content}getTargetRelativePath(e){let t=e.dir.path;if(e.type!==_h.VSCode)return this.basename(t);let n=t.indexOf(wS);return n===-1?this.joinPath(wS,this.basename(t)):t.slice(Math.max(0,n))}};const ES=`WARP.md`;var DS=class extends xb{constructor(){super(`WarpIDEOutputPlugin`,{outputFileName:ES,treatWorkspaceRootProjectAsProject:!0,indexignore:`.warpindexignore`,cleanup:{delete:{project:{files:[ES]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1}}})}async declareOutputFiles(e){let t=[],{globalMemory:n,aiAgentIgnoreConfigFiles:r}=e.collectedOutputContext,a=this.getConcreteProjects(e),o=this.getProjectPromptOutputProjects(e),s=this.shouldSkipDueToPlugin(e,Cb.AgentsOutput),c=new Set(this.selectPromptScopes(e,[`project`,`global`])),l=this.extractGlobalMemoryContent(e);if(s){if(n!=null&&c.has(`global`))for(let r of o){let a=this.resolveProjectRootDir(e,r);a!=null&&t.push({path:i.join(a,ES),scope:`project`,source:{content:n.content}})}}else for(let n of o){let r=this.resolveProjectRootDir(e,n);if(r!=null){if(n.rootMemoryPrompt!=null&&c.has(`project`)){let e=this.combineGlobalWithContent(l,n.rootMemoryPrompt.content);t.push({path:i.join(r,ES),scope:`project`,source:{content:e}})}if(n.childMemoryPrompts!=null&&c.has(`project`))for(let e of n.childMemoryPrompts)t.push({path:this.resolveFullPath(e.dir),scope:`project`,source:{content:e.content}})}}let u=this.getIgnoreOutputPath(),d=this.indexignore==null?void 0:r?.find(e=>e.fileName===this.indexignore);if(u!=null&&d!=null)for(let e of a){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:this.resolvePath(n.basePath,n.path,u),scope:`project`,source:{content:d.content}})}return t}async convertContent(e,t){let n=e.source;if(n.content==null)throw Error(`Unsupported declaration source for ${this.name}`);return n.content}};const OS=`.codeium/windsurf`,kS=`global_workflows`,AS=`memories`,jS=`skills`,MS=`.windsurf`;var NS=class extends xb{constructor(){super(`WindsurfOutputPlugin`,{globalConfigDir:OS,outputFileName:``,treatWorkspaceRootProjectAsProject:!0,dependsOn:[Cb.AgentsOutput],indexignore:`.codeiumignore`,commands:{subDir:kS,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:jS},rules:{sourceScopes:[`project`,`global`]},cleanup:{delete:{project:{dirs:[`.windsurf/rules`,`.windsurf/workflows`,`.windsurf/global_workflows`,`.windsurf/skills`,`.codeium/windsurf/global_workflows`,`.codeium/windsurf/skills`]},global:{dirs:[`.codeium/windsurf/global_workflows`,`.codeium/windsurf/memories`,`.codeium/windsurf/skills`]}}},capabilities:{prompt:{scopes:[`global`],singleScope:!1},rules:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0}}})}async declareOutputFiles(e){let t=[],{commands:n,skills:r,globalMemory:a,rules:o,aiAgentIgnoreConfigFiles:s}=e.collectedOutputContext,c=this.resolvePromptSourceProjectConfig(e),l=this.getCodeiumWindsurfDir(),u=new Set(this.selectPromptScopes(e,[`global`])),d=n==null?{items:[]}:this.selectSingleScopeItems(n,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)),f=r==null?{items:[]}:this.selectSingleScopeItems(r,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),p=this.getConcreteProjects(e);a!=null&&u.has(`global`)&&t.push({path:i.join(l,AS,`global_rules.md`),scope:`global`,source:{kind:`globalMemory`,content:a.content}});let m=(e,n,r)=>{let a=this.getSkillName(r),o=i.join(e,jS,a);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:r}}),r.childDocs!=null)for(let e of r.childDocs)t.push({path:i.join(o,e.relativePath.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillChildDoc`,content:e.content}});if(r.resources!=null)for(let e of r.resources)t.push({path:i.join(o,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})};if(f.selectedScope===`project`)for(let t of this.getProjectOutputProjects(e)){let n=this.resolveProjectRootDir(e,t),r=n==null?void 0:i.join(n,MS);if(r==null)continue;let a=$(f.items,t.projectConfig,`skills`);for(let e of a)m(r,`project`,e)}if(f.selectedScope===`global`){let e=$(f.items,c,`skills`);for(let t of e)m(l,`global`,t)}let h=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});if(d.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectRootDir(e,n),a=r==null?void 0:i.join(r,MS);if(a==null)continue;let o=$(d.items,n.projectConfig,`commands`);for(let e of o)t.push({path:i.join(a,`workflows`,this.transformCommandName(e,h)),scope:`project`,source:{kind:`command`,command:e}})}if(d.selectedScope===`global`){let e=$(d.items,c,`commands`);for(let n of e)t.push({path:i.join(l,kS,this.transformCommandName(n,h)),scope:`global`,source:{kind:`command`,command:n}})}if(o!=null&&o.length>0){let n=new Set(this.selectRuleScopes(e,o)),r=o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`global`);if(n.has(`global`))for(let e of r)t.push({path:i.join(l,AS,this.buildRuleFileName(e)),scope:`global`,source:{kind:`rule`,rule:e}});if(n.has(`project`))for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectRootDir(e,n);if(r==null)continue;let a=by($(o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`project`),n.projectConfig,`rules`),n.projectConfig);for(let e of a)t.push({path:i.join(r,MS,`rules`,this.buildRuleFileName(e)),scope:`project`,source:{kind:`rule`,rule:e}})}}let g=this.getIgnoreOutputPath(),_=this.indexignore==null?void 0:s?.find(e=>e.fileName===this.indexignore);if(g!=null&&_!=null)for(let e of p){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:i.join(n.basePath,n.path,g),scope:`project`,source:{kind:`ignoreFile`,content:_.content}})}return t}async convertContent(e,t){let n=e.source;switch(n.kind){case`globalMemory`:case`skillChildDoc`:case`ignoreFile`:return n.content;case`command`:return this.buildCommandContent(n.command,t);case`skillMain`:{let e=this.buildSkillFrontMatter(n.skill);return this.buildMarkdownContent(n.skill.content,e,t)}case`skillResource`:return n.encoding===`base64`?f.from(n.content,`base64`):n.content;case`rule`:return this.buildRuleContent(n.rule,t);default:throw Error(`Unsupported declaration source for ${this.name}`)}}getCodeiumWindsurfDir(){return i.join(this.getHomeDir(),OS)}buildRuleFileName(e,t=`rule-`){return`${t}${e.prefix}-${e.ruleName}.md`}buildRuleContent(e,t){let n={trigger:`glob`,globs:e.globs.length>0?e.globs.join(`, `):``};return this.buildMarkdownContent(e.content,n,t).split(`
|
|
228
233
|
`).map(e=>{let t=/^(\s*globs:\s*)(['"])(.*)\2\s*$/.exec(e);if(t==null)return e;let n=t[1]??`globs: `,r=t[3]??``;return r.trim().length===0?e:`${n}${r}`}).join(`
|
|
229
|
-
`)}};function
|
|
230
|
-
`)}`)}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=this.mergeAindex(e.aindex,t.aindex),r=this.mergeOutputScopeOptions(e.outputScopes,t.outputScopes),i=this.mergeFrontMatterOptions(e.frontMatter,t.frontMatter),a=this.mergeCleanupProtectionOptions(e.cleanupProtection,t.cleanupProtection);return{...e,...t,...n==null?{}:{aindex:n},...r==null?{}:{outputScopes:r},...i==null?{}:{frontMatter:i},...a==null?{}:{cleanupProtection:a}}},{})}mergeAindex(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{dir:t.dir??e.dir,skills:{...e.skills,...t.skills},commands:{...e.commands,...t.commands},subAgents:{...e.subAgents,...t.subAgents},rules:{...e.rules,...t.rules},globalPrompt:{...e.globalPrompt,...t.globalPrompt},workspacePrompt:{...e.workspacePrompt,...t.workspacePrompt},app:{...e.app,...t.app},ext:{...e.ext,...t.ext},arch:{...e.arch,...t.arch}}}mergeOutputScopeTopics(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{...e,...t}}mergeOutputScopeOptions(e,t){if(e==null&&t==null)return;if(e==null)return t;if(t==null)return e;let n={};for(let[t,r]of Object.entries(e.plugins??{}))r!=null&&(n[t]={...r});for(let[e,r]of Object.entries(t.plugins??{})){let t=this.mergeOutputScopeTopics(n[e],r);t!=null&&(n[e]=t)}return Object.keys(n).length===0?{}:{plugins:n}}mergeFrontMatterOptions(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{...e,...t}}mergeCleanupProtectionOptions(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{rules:[...e.rules??[],...t.rules??[]]}}resolveTilde(e){return e.startsWith(`~`)?i.join(c.homedir(),e.slice(1)):e}};let
|
|
234
|
+
`)}};function PS(e,t){let r=i.join(e,`.git`),a=n.existsSync(r);return a?t?.info(`version control detected`,{path:r}):t?.warn(ft({code:`AINDEX_VERSION_CONTROL_MISSING`,title:`Aindex root is not under version control`,rootCause:z(`tnmsc did not find a .git directory under "${e}".`),exactFix:z(`Initialize git in "${e}" or place the aindex inside an existing git repository.`),possibleFixes:[z("Run `git init` in the aindex root if the directory should be versioned.")],details:{rootPath:e,gitPath:r}})),{hasGit:a,gitPath:r}}function FS(){return i.join(c.homedir(),`.aindex`,`.tnmsc.json`)}var IS=class{logger;constructor(e={}){this.logger=Ut(`ConfigLoader`)}getSearchPaths(e=t.cwd()){return[FS()]}loadFromFile(e){let t=this.resolveTilde(e);try{if(!n.existsSync(t))return{config:{},source:null,found:!1};let e=n.readFileSync(t,`utf8`),r=this.parseConfig(e,t);return this.logger.debug(`loaded`,{source:t}),{config:r,source:t,found:!0}}catch(e){return this.logger.warn(B({code:`CONFIG_FILE_LOAD_FAILED`,title:`Failed to load config file`,operation:`read`,targetKind:`config file`,path:t,error:e})),{config:{},source:null,found:!1}}}load(e=t.cwd()){let n=this.getSearchPaths(e),r=[];for(let e of n){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){let n;try{n=JSON.parse(e)}catch(e){throw e instanceof SyntaxError?Error(`Invalid JSON in ${t}: ${e.message}`):e}let r=Qy.safeParse(n);if(r.success)return r.data;let i=r.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`);throw Error(`Config validation failed in ${t}:\n${i.join(`
|
|
235
|
+
`)}`)}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=this.mergeAindex(e.aindex,t.aindex),r=this.mergeOutputScopeOptions(e.outputScopes,t.outputScopes),i=this.mergeFrontMatterOptions(e.frontMatter,t.frontMatter),a=this.mergeCleanupProtectionOptions(e.cleanupProtection,t.cleanupProtection);return{...e,...t,...n==null?{}:{aindex:n},...r==null?{}:{outputScopes:r},...i==null?{}:{frontMatter:i},...a==null?{}:{cleanupProtection:a}}},{})}mergeAindex(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{dir:t.dir??e.dir,skills:{...e.skills,...t.skills},commands:{...e.commands,...t.commands},subAgents:{...e.subAgents,...t.subAgents},rules:{...e.rules,...t.rules},globalPrompt:{...e.globalPrompt,...t.globalPrompt},workspacePrompt:{...e.workspacePrompt,...t.workspacePrompt},app:{...e.app,...t.app},ext:{...e.ext,...t.ext},arch:{...e.arch,...t.arch}}}mergeOutputScopeTopics(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{...e,...t}}mergeOutputScopeOptions(e,t){if(e==null&&t==null)return;if(e==null)return t;if(t==null)return e;let n={};for(let[t,r]of Object.entries(e.plugins??{}))r!=null&&(n[t]={...r});for(let[e,r]of Object.entries(t.plugins??{})){let t=this.mergeOutputScopeTopics(n[e],r);t!=null&&(n[e]=t)}return Object.keys(n).length===0?{}:{plugins:n}}mergeFrontMatterOptions(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{...e,...t}}mergeCleanupProtectionOptions(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{rules:[...e.rules??[],...t.rules??[]]}}resolveTilde(e){return e.startsWith(`~`)?i.join(c.homedir(),e.slice(1)):e}};let LS=null;function RS(e){return(e||!LS)&&(LS=new IS(e)),LS}var zS=class extends gg{constructor(){super(`MarkdownWhitespaceCleanupEffectInputCapability`),this.registerEffect(`markdown-whitespace-cleanup`,this.cleanupWhitespace.bind(this),30)}async cleanupWhitespace(e){let{fs:t,path:n,aindexDir: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{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(B({code:`WHITESPACE_CLEANUP_DIRECTORY_READ_FAILED`,title:`Whitespace cleanup could not read a directory`,operation:`read`,targetKind:`cleanup directory`,path:t,error:e}));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(B({code:`WHITESPACE_CLEANUP_FILE_PROCESS_FAILED`,title:`Whitespace cleanup could not process a markdown file`,operation:`process`,targetKind:`markdown file`,path:t,error:e}))}}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
|
|
231
236
|
`)?`\r
|
|
232
237
|
`:`
|
|
233
|
-
`}collect(e){return{}}};const Kx=[`skills`,`commands`,`agents`,`app`];var qx=class extends cg{constructor(){super(`OrphanFileCleanupEffectInputCapability`),this.registerEffect(`orphan-file-cleanup`,this.cleanupOrphanFiles.bind(this),20)}buildProtectedDeletionGuard(e){return tg({workspaceDir:e.workspaceDir,aindexDir:e.aindexDir,rules:[...Qh(e.userConfigOptions,e.aindexDir,{workspaceDir:e.workspaceDir}),...(e.userConfigOptions.cleanupProtection?.rules??[]).map(e=>({path:e.path,protectionMode:e.protectionMode,reason:e.reason??`configured cleanup protection rule`,source:`configured-cleanup-protection`,matcher:e.matcher??`path`}))]})}buildDeletionPlan(e,t,n){let r=[],i=[],a=[];for(let o of Kx){let s=e.path.join(t,o);e.fs.existsSync(s)&&e.fs.statSync(s).isDirectory()&&this.collectDirectoryPlan(e,s,o,n[o],r,i,a)}return{filesToDelete:r,dirsToDelete:i,errors:a}}async cleanupOrphanFiles(e){let{fs:t,path:n,aindexDir:r,logger:i,userConfigOptions:a,dryRun:o}=e,s=n.join(r,`dist`);if(!t.existsSync(s))return i.debug({action:`orphan-cleanup`,message:`dist/ directory does not exist, skipping`,distDir:s}),{success:!0,description:`dist/ directory does not exist, nothing to clean`,deletedFiles:[],deletedDirs:[]};let c=a.aindex,l={skills:c?.skills?.src??`skills`,commands:c?.commands?.src??`commands`,agents:c?.subAgents?.src??`subagents`,app:c?.app?.src??`app`},u=this.buildDeletionPlan(e,s,l),d=this.buildProtectedDeletionGuard(e),f=ag(u.filesToDelete,d),p=ag(u.dirsToDelete,d),m=[...f.violations,...p.violations].sort((e,t)=>e.targetPath.localeCompare(t.targetPath));if(m.length>0)return{success:!1,description:`Protected deletion guard blocked orphan cleanup for ${m.length} path(s)`,deletedFiles:[],deletedDirs:[],error:new Dh(`orphan-file-cleanup`,m)};if(o)return{success:!0,description:`Would delete ${f.safePaths.length} files and ${p.safePaths.length} directories`,deletedFiles:[...f.safePaths],deletedDirs:[...p.safePaths].sort((e,t)=>t.length-e.length)};let h=[],g=[],_=[...u.errors];for(let e of f.safePaths)try{t.unlinkSync(e),h.push(e),i.debug({action:`orphan-cleanup`,deleted:e})}catch(t){_.push({path:e,error:t}),i.warn(B({code:`ORPHAN_CLEANUP_FILE_DELETE_FAILED`,title:`Orphan cleanup could not delete a file`,operation:`delete`,targetKind:`orphan file`,path:e,error:t}))}for(let e of[...p.safePaths].sort((e,t)=>t.length-e.length))try{t.rmdirSync(e),g.push(e),i.debug({action:`orphan-cleanup`,deletedDir:e})}catch(t){_.push({path:e,error:t}),i.warn(B({code:`ORPHAN_CLEANUP_DIRECTORY_DELETE_FAILED`,title:`Orphan cleanup could not delete a directory`,operation:`delete`,targetKind:`orphan directory`,path:e,error:t}))}let v=_.length>0;return{success:!v,description:`Deleted ${h.length} files and ${g.length} directories`,deletedFiles:h,deletedDirs:g,...v&&{error:Error(`${_.length} errors occurred during cleanup`)}}}collectDirectoryPlan(e,t,n,r,i,a,o){let{fs:s,path:c,aindexDir:l,logger:u}=e,d;try{d=s.readdirSync(t,{withFileTypes:!0})}catch(e){return o.push({path:t,error:e}),u.warn(B({code:`ORPHAN_CLEANUP_DIRECTORY_READ_FAILED`,title:`Orphan cleanup could not read a directory`,operation:`read`,targetKind:`dist cleanup directory`,path:t,error:e})),!1}let f=!1;for(let s of d){let u=c.join(t,s.name);if(s.isDirectory()){this.collectDirectoryPlan(e,u,n,r,i,a,o)?a.push(u):f=!0;continue}if(!s.isFile()){f=!0;continue}this.isOrphanFile(e,u,n,r,l)?i.push(u):f=!0}return!f}isOrphanFile(e,t,n,r,i){let{fs:a,path:o}=e,s=o.basename(t),c=s.endsWith(`.mdx`),l=o.join(i,`dist`,n),u=o.relative(l,t),d=o.dirname(u),f=s.replace(/\.mdx$/,``);return c?!this.getPossibleSourcePaths(o,i,n,r,f,d).some(e=>a.existsSync(e)):!a.existsSync(o.join(i,r,u))}getPossibleSourcePaths(e,t,n,r,i,a){switch(n){case`skills`:{let n=(a===`.`?[i]:a.split(e.sep))[0]??i,o=a===`.`?``:a.slice(n.length+1);return o===``?[...Iy.map(i=>e.join(t,r,n,`SKILL${i}`)),...Iy.map(i=>e.join(t,r,n,`skill${i}`))]:Iy.map(a=>e.join(t,r,n,o,`${i}${a}`))}case`commands`:case`agents`:case`app`:return a===`.`?Iy.map(n=>e.join(t,r,`${i}${n}`)):Iy.map(n=>e.join(t,r,a,`${i}${n}`));default:return[]}}collect(e){return{}}},Jx=class extends cg{constructor(){super(`SkillDistCleanupEffectInputCapability`),this.registerEffect(`skill-dist-cleanup`,this.cleanupDistSkillArtifacts.bind(this),10)}async cleanupDistSkillArtifacts(e){let{fs:t,logger:n,userConfigOptions:r,aindexDir:i,dryRun:a}=e,o=this.resolveAindexPath(r.aindex.skills.src,i),s=this.resolveAindexPath(r.aindex.skills.dist,i);if(!t.existsSync(s))return n.debug({action:`skill-dist-cleanup`,message:`dist skills directory does not exist, skipping`,srcSkillsDir:o,distSkillsDir:s}),{success:!0,description:`dist skills directory does not exist, nothing to clean`,deletedFiles:[],deletedDirs:[]};let c=this.buildCleanupPlan(e,s);if(a)return{success:!0,description:`Would delete ${c.filesToDelete.length} files and ${c.dirsToDelete.length} directories`,deletedFiles:[...c.filesToDelete],deletedDirs:[...c.dirsToDelete].sort((e,t)=>t.length-e.length)};let l=[],u=[],d=[...c.errors];for(let e of c.filesToDelete)try{t.unlinkSync(e),l.push(e),n.debug({action:`skill-dist-cleanup`,deleted:e})}catch(t){d.push({path:e,error:t}),n.warn(B({code:`SKILL_DIST_CLEANUP_FILE_DELETE_FAILED`,title:`Skill dist cleanup could not delete a file`,operation:`delete`,targetKind:`skill dist file`,path:e,error:t}))}for(let e of[...c.dirsToDelete].sort((e,t)=>t.length-e.length))try{t.rmdirSync(e),u.push(e),n.debug({action:`skill-dist-cleanup`,deletedDir:e})}catch(t){d.push({path:e,error:t}),n.warn(B({code:`SKILL_DIST_CLEANUP_DIRECTORY_DELETE_FAILED`,title:`Skill dist cleanup could not delete a directory`,operation:`delete`,targetKind:`skill dist directory`,path:e,error:t}))}let f=d.length>0;return{success:!f,description:`Deleted ${l.length} files and ${u.length} directories`,deletedFiles:l,deletedDirs:u,...f&&{error:Error(`${d.length} errors occurred during cleanup`)}}}buildCleanupPlan(e,t){let n=[],r=[],i=[];return this.collectCleanupPlan(e,t,n,r,i),{filesToDelete:n,dirsToDelete:r,errors:i}}collectCleanupPlan(e,t,n,r,i){let{fs:a,path:o,logger:s}=e,c;try{c=a.readdirSync(t,{withFileTypes:!0})}catch(e){return i.push({path:t,error:e}),s.warn(B({code:`SKILL_DIST_CLEANUP_DIRECTORY_READ_FAILED`,title:`Skill dist cleanup could not read a directory`,operation:`read`,targetKind:`skill dist directory`,path:t,error:e})),!1}let l=!1;for(let a of c){let s=o.join(t,a.name);if(a.isDirectory()){this.collectCleanupPlan(e,s,n,r,i)?r.push(s):l=!0;continue}if(!a.isFile()){l=!0;continue}if(this.shouldRetainCompiledSkillFile(a.name)){l=!0;continue}n.push(s)}return!l}shouldRetainCompiledSkillFile(e){return e.endsWith(`.mdx`)&&!Ry(e)}collect(e){return{}}};const Yx=/export\s+default\s*\{([\s\S]*?)\}/u,Xx=/description\s*:\s*['"`]([^'"`]+)['"`]/u,Zx=/name\s*:\s*['"`]([^'"`]+)['"`]/u,Qx=/displayName\s*:\s*['"`]([^'"`]+)['"`]/u,$x=/keywords\s*:\s*\[([^\]]+)\]/u,eS=/author\s*:\s*['"`]([^'"`]+)['"`]/u,tS=/version\s*:\s*['"`]([^'"`]+)['"`]/u;function nS(e){let t={},n=Yx.exec(e);if(n?.[1]==null)return t;let r=n[1],i=Xx.exec(r);i?.[1]!=null&&(t.description=i[1]);let a=Zx.exec(r);a?.[1]!=null&&(t.name=a[1]);let o=Qx.exec(r);o?.[1]!=null&&(t.displayName=o[1]);let s=$x.exec(r);s?.[1]!=null&&(t.keywords=s[1].split(`,`).map(e=>e.trim().replaceAll(/['"]/gu,``)).filter(e=>e.length>0));let c=eS.exec(r);c?.[1]!=null&&(t.author=c[1]);let l=tS.exec(r);return l?.[1]!=null&&(t.version=l[1]),t}function rS(...e){let t={};for(let n of e)if(n!=null)for(let[e,r]of Object.entries(n))r!==void 0&&(t[e]=r);return t}const iS={".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`},aS=new Set(`.png,.jpg,.jpeg,.gif,.webp,.ico,.bmp,.tiff,.svg,.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,.pdf,.docx,.doc,.xlsx,.xls,.pptx,.ppt,.odt,.ods,.odp`.split(`,`));function oS(e){return aS.has(e.toLowerCase())}function sS(e){return iS[e.toLowerCase()]}function cS(...e){return i.join(...e).replaceAll(`\\`,`/`)}var lS=class{ctx;constructor(e){this.ctx=e}async processDirectory(e,t,n){let r=t?`${t}/${e.name}`:e.name;return this.scanSkillDirectoryAsync(n,r)}async processFile(e,t,n){let r=t?`${t}/${e.name}`:e.name;if(this.ctx.scanMode===`distChildDocs`){if(t===``&&e.name===`skill.mdx`||Ry(e.name)||!e.name.endsWith(`.mdx`))return{childDocs:[],resources:[]};let i=await this.processChildDoc(r,n);return{childDocs:i?[i]:[],resources:[]}}if(t===``&&e.name===`mcp.json`||Ry(e.name)||e.name.endsWith(`.mdx`))return{childDocs:[],resources:[]};let i=this.processResourceFile(e.name,r,n);return{childDocs:[],resources:i?[i]:[]}}async processChildDoc(e,t){try{let n=this.ctx.fs.readFileSync(t,`utf8`),r=Wm(n),a=Gm((await yv(n,{globalScope:this.ctx.globalScope,extractMetadata:!0,basePath:i.dirname(t),filePath:t})).content);return Ky(a,t),{type:sh.SkillChildDoc,content:a,length:a.length,filePathKind:ch.Relative,markdownAst:r.markdownAst,markdownContents:r.markdownContents,...r.rawFrontMatter!=null&&{rawFrontMatter:r.rawFrontMatter},relativePath:e,dir:{pathKind:ch.Relative,path:e,basePath:this.ctx.skillDir,getDirectoryName:()=>i.dirname(e),getAbsolutePath:()=>t}}}catch(n){throw this.ctx.logger.error(mt({code:`SKILL_CHILD_DOC_COMPILE_FAILED`,title:`Failed to compile skill child doc`,diagnosticText:Yy(n,{operation:`Failed to compile skill child doc.`,promptKind:`skill-child-doc`,logicalName:`${i.basename(this.ctx.skillDir)}/${e.replace(/\.mdx$/u,``)}`,distPath:t,srcPath:qy(i,t,{distRootDir:this.ctx.skillDir,srcRootDir:this.ctx.sourceSkillDir})}),details:{skillDir:this.ctx.skillDir,relativePath:e,filePath:t}})),n}}processResourceFile(e,t,n){let r=i.extname(e);try{let{content:i,encoding:a,length:o}=this.readFileContent(n,r),s=sS(r);return{type:sh.SkillResource,extension:r,fileName:e,relativePath:t,sourcePath:n,content:i,encoding:a,length:o,...s!=null&&{mimeType:s}}}catch(r){return this.ctx.logger.warn(B({code:`SKILL_RESOURCE_READ_FAILED`,title:`Failed to read skill resource file`,operation:`read`,targetKind:`skill resource file`,path:n,error:r,details:{relativePath:t,fileName:e,skillDir:this.ctx.skillDir}})),null}}readFileContent(e,t){if(oS(t)){let t=this.ctx.fs.readFileSync(e);return{content:t.toString(`base64`),encoding:`base64`,length:t.length}}let n=this.ctx.fs.readFileSync(e,`utf8`);return{content:n,encoding:`text`,length:f.from(n,`utf8`).length}}async scanSkillDirectoryAsync(e,t=``){let n=[],r=[],i;try{i=this.ctx.fs.readdirSync(e,{withFileTypes:!0})}catch(t){return this.ctx.logger.warn(B({code:`SKILL_DIRECTORY_SCAN_FAILED`,title:`Failed to scan skill directory`,operation:`scan`,targetKind:`skill directory`,path:e,error:t,details:{skillDir:this.ctx.skillDir,scanMode:this.ctx.scanMode}})),{childDocs:n,resources:r}}for(let a of i){let i=cS(e,a.name);if(a.isDirectory()){let e=await this.processDirectory(a,t,i);n.push(...e.childDocs),r.push(...e.resources);continue}if(!a.isFile())continue;let o=await this.processFile(a,t,i);n.push(...o.childDocs),r.push(...o.resources)}return{childDocs:n,resources:r}}};function uS(e,t,n,r=``){let i=[],a=r===``?e:cS(e,r),o;try{o=t.readdirSync(a,{withFileTypes:!0})}catch(e){return n.warn(B({code:`SKILL_SOURCE_CHILD_SCAN_FAILED`,title:`Failed to scan skill source child docs`,operation:`scan`,targetKind:`skill source child doc directory`,path:a,error:e})),i}for(let a of o){let o=r?`${r}/${a.name}`:a.name;if(a.isDirectory()){i.push(...uS(e,t,n,o));continue}!a.isFile()||!Ry(a.name)||r===``&&a.name===`skill.src.mdx`||i.push(o.replace(/\.src\.mdx$/u,`.mdx`))}return i}function dS(e,t,n,r,a){if(r.existsSync(t))for(let o of uS(t,r,a)){let a=i.join(n,o);if(!r.existsSync(a))throw new Hy({kind:`skill child doc`,name:`${e}/${o}`,sourcePath:i.join(t,o.replace(/\.mdx$/u,`.src.mdx`)),expectedDistPath:a})}}function fS(e,t,n){let r=i.join(e,`mcp.json`);if(t.existsSync(r)){if(!t.statSync(r).isFile()){n.warn(pt({code:`SKILL_MCP_CONFIG_NOT_FILE`,title:`Skill MCP config path is not a file`,path:r,expectedKind:`mcp.json file`,actualState:`path exists but is not a regular file`,details:{skillDir:e}}));return}try{let i=t.readFileSync(r,`utf8`),a=JSON.parse(i);if(a.mcpServers==null||typeof a.mcpServers!=`object`){n.warn(dt({code:`SKILL_MCP_CONFIG_INVALID`,title:`Skill MCP config is missing mcpServers`,reason:z(`The skill MCP config at "${r}" does not contain a top-level mcpServers object.`),configPath:r,exactFix:z("Add a top-level `mcpServers` object to mcp.json before retrying tnmsc."),details:{skillDir:e}}));return}return{type:sh.SkillMcpConfig,mcpServers:a.mcpServers,rawContent:i}}catch(t){n.warn(dt({code:`SKILL_MCP_CONFIG_PARSE_FAILED`,title:`Failed to parse skill MCP config`,reason:z(`tnmsc could not parse the MCP config file at "${r}".`,`Underlying error: ${t instanceof Error?t.message:String(t)}`),configPath:r,exactFix:z(`Fix the JSON syntax in mcp.json and rerun tnmsc.`),details:{skillDir:e,errorMessage:t instanceof Error?t.message:String(t)}}));return}}}async function pS(e,t,n,r,a,o,s,c=[],l=[],u,d){let{logger:f,globalScope:p,fs:m}=o,h=i.join(a,`skill.mdx`),g=e,_,v;if(m.existsSync(h)){g=m.readFileSync(h,`utf8`),_=Wm(g);let t=await yv(g,{globalScope:p,extractMetadata:!0,basePath:a,filePath:h});e=Gm(t.content),Ky(e,h),v=t.metadata.fields}let y=rS(nS(g),d,v),b=_?.yamlFrontMatter?.description??y?.description;if(b==null||b.trim().length===0)throw f.error(st({code:`SKILL_VALIDATION_FAILED`,title:`Skill description is required`,rootCause:z(`The skill "${n}" does not provide a non-empty description in its compiled metadata or front matter.`),exactFix:z(`Add a non-empty description field to the skill front matter or exported metadata and rebuild the skill.`),possibleFixes:[z("Set `description` in `SKILL.md` front matter."),z(`If you export metadata from code, ensure the exported description is non-empty.`)],details:{skill:n,skillDir:r,yamlDescription:_?.yamlFrontMatter?.description,exportDescription:y?.description}})),Error(`Skill "${n}" validation failed: description is required and cannot be empty`);let x={...y,..._?.yamlFrontMatter??{},name:n,description:b},S=py(x,h);if(!S.valid)throw Error(S.errors.join(`
|
|
234
|
-
`));return{type:
|
|
235
|
-
`));for(let e of
|
|
236
|
-
`));return Object.assign(_,{yamlFrontMatter:g}),g.seriName!=null&&Object.assign(_,{seriName:g.seriName}),g.scope===`global`&&Object.assign(_,{globalOnly:!0}),_}async collect(e){let{userConfigOptions:t,logger:n,path:r,fs:i,globalScope:a}=e,o=this.resolveBasePaths(t),s=this.resolveAindexPath(t.aindex.commands.src,o.aindexDir),c=this.resolveAindexPath(t.aindex.commands.dist,o.aindexDir);n.debug(`CommandInputCapability collecting`,{srcDir:s,distDir:c,aindexDir:o.aindexDir});let{prompts:l,errors:u}=await
|
|
237
|
-
`));let d=[];for(let e of l){let t=e.dist;if(t?.prompt==null)continue;let{prompt:n,rawMdx:r}=t;d.push(r==null?n:{...n,rawMdxContent:r})}return n.debug(`CommandInputCapability flattened commands`,{count:d.length,commands:d.map(e=>e.commandName)}),{commands:d}}},_S=class extends cg{constructor(){super(`EditorConfigInputCapability`)}collect(e){let{userConfigOptions:t,fs:n}=e,{workspaceDir:r,aindexDir:i}=this.resolveBasePaths(t),a=[],o=Eh(lh.EditorConfig,`.editorconfig`,i,n,{command:e.runtimeCommand,workspaceDir:r});return o!=null&&a.push(o),{editorConfigFiles:a}}},vS=class extends cg{constructor(){super(`GitExcludeInputCapability`)}collect(e){let{workspaceDir:t,aindexDir:n}=this.resolveBasePaths(e.userConfigOptions),r=wh(n,ph,{command:e.runtimeCommand,workspaceDir:t});if(!e.fs.existsSync(r))return this.log.debug({action:`collect`,message:`File not found`,path:r}),{};let i=e.fs.readFileSync(r,`utf8`);return i.length===0?(this.log.debug({action:`collect`,message:`File is empty`,path:r}),{}):(this.log.debug({action:`collect`,message:`Loaded file content`,path:r,length:i.length}),{shadowGitExclude:i})}},yS=class extends cg{constructor(){super(`GitIgnoreInputCapability`)}collect(e){let{workspaceDir:t,aindexDir:n}=this.resolveBasePaths(e.userConfigOptions),r=wh(n,fh,{command:e.runtimeCommand,workspaceDir:t});if(!e.fs.existsSync(r))return this.log.debug({action:`collect`,message:`File not found`,path:r}),{};let i=e.fs.readFileSync(r,`utf8`);return i.length===0?(this.log.debug({action:`collect`,message:`File is empty`,path:r}),{}):(this.log.debug({action:`collect`,message:`Loaded file content`,path:r,length:i.length}),{globalGitIgnore:i})}},bS=class extends cg{constructor(){super(`GlobalMemoryInputCapability`)}async collect(e){let{userConfigOptions:n,fs:r,path:i,globalScope:a}=e,{aindexDir:o}=this.resolveBasePaths(n),s=this.resolveAindexPath(n.aindex.globalPrompt.dist,o);if(!r.existsSync(s))return this.log.warn(pt({code:`GLOBAL_MEMORY_PROMPT_MISSING`,title:`Global memory prompt is missing`,path:s,expectedKind:`compiled global memory prompt file`,actualState:`path does not exist`})),{};if(!r.statSync(s).isFile())return this.log.warn(pt({code:`GLOBAL_MEMORY_PROMPT_NOT_FILE`,title:`Global memory prompt path is not a file`,path:s,expectedKind:`compiled global memory prompt file`,actualState:`path exists but is not a regular file`})),{};let l=r.readFileSync(s,`utf8`),u=Wm(l),d;try{d=(await yv(l,{...a!=null&&{globalScope:a},extractMetadata:!0,basePath:i.dirname(s),filePath:s})).content,Ky(d,s)}catch(e){throw e instanceof gg&&(this.log.error(mt({code:`GLOBAL_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile global memory prompt`,diagnosticText:Yy(e,{operation:`Failed to compile global memory prompt.`,promptKind:`global-memory`,logicalName:`global-memory`,distPath:s}),details:{promptKind:`global-memory`,distPath:s}})),e instanceof vg&&this.log.error(dt({code:`GLOBAL_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Global memory prompt references missing config variables`,reason:z("The global memory prompt uses scope variables that are not defined in `~/.aindex/.tnmsc.json`."),configPath:`~/.aindex/.tnmsc.json`,exactFix:z("Add the missing variables to `~/.aindex/.tnmsc.json` and rerun tnmsc."),possibleFixes:[z("If you reference `{profile.name}`, define `profile.name` in the config file.")],details:{promptPath:s,errorMessage:e.message}})),t.exit(1)),e}return this.log.debug({action:`collect`,path:s,contentLength:d.length}),{globalMemory:{type:sh.GlobalMemory,content:d,length:d.length,filePathKind:ch.Relative,...u.rawFrontMatter!=null&&{rawFrontMatter:u.rawFrontMatter},markdownAst:u.markdownAst,markdownContents:u.markdownContents,dir:{pathKind:ch.Relative,path:i.basename(s),basePath:i.dirname(s),getDirectoryName:()=>i.basename(s),getAbsolutePath:()=>s},parentDirectoryPath:{type:uh.UserHome,directory:{pathKind:ch.Relative,path:``,basePath:c.homedir(),getDirectoryName:()=>i.basename(c.homedir()),getAbsolutePath:()=>c.homedir()}}}}}},xS=class extends cg{constructor(){super(`JetBrainsConfigInputCapability`)}collect(e){let{userConfigOptions:t,fs:n}=e,{workspaceDir:r,aindexDir:i}=this.resolveBasePaths(t),a=[`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`],o=[];for(let t of a){let a=Eh(lh.IntellijIDEA,t,i,n,{command:e.runtimeCommand,workspaceDir:r});a!=null&&o.push(a)}return{jetbrainsConfigFiles:o}}};const SS=`agt.mdx`,CS=[`node_modules`,`.git`];var wS=class extends cg{constructor(){super(`ProjectPromptInputCapability`,[`AindexInputCapability`])}async collect(e){let{dependencyContext:t,fs:n,userConfigOptions:r,path:i,globalScope:a}=e,{aindexDir:o}=this.resolveBasePaths(r),s=this.resolveAindexPath(r.aindex.app.dist,o),c=this.resolveAindexPath(r.aindex.workspacePrompt.dist,o),l=t.workspace;if(l==null)return this.log.info(`No workspace found in dependency context, skipping project prompt enhancement`),{};let u=l.projects??[],d=await Promise.all(u.map(async t=>{let r=t.name;if(r==null||t.isWorkspaceRootProject===!0)return t;let o=i.join(s,r);if(!n.existsSync(o)||!n.statSync(o).isDirectory())return t;let c=t.dirFromWorkspacePath?.getAbsolutePath(),l=await this.readRootMemoryPrompt(e,o,a),u=c==null?[]:await this.scanChildMemoryPrompts(e,o,c,a);return{...t,...l!=null&&{rootMemoryPrompt:l},...u.length>0&&{childMemoryPrompts:u}}})),f=await this.readWorkspaceRootProjectPrompt(e,c,a,this.resolveWorkspaceRootProjectConfig(u));return{workspace:{directory:l.directory,projects:f==null?d:[...d,f]}}}async readWorkspaceRootProjectPrompt(e,n,r,i){let{fs:a,path:o,logger:s}=e;if(!(!a.existsSync(n)||!a.statSync(n).isFile()))try{let e=a.readFileSync(n,`utf8`),c=Wm(e),l;try{let{content:t}=await yv(e,{globalScope:r,extractMetadata:!0,basePath:o.dirname(n),filePath:n});l=t,Ky(l,n)}catch(e){throw e instanceof gg&&(s.error(mt({code:`WORKSPACE_ROOT_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile workspace root memory prompt`,diagnosticText:Yy(e,{operation:`Failed to compile workspace root memory prompt.`,promptKind:`workspace-root-memory`,logicalName:n,distPath:n}),details:{promptKind:`workspace-root-memory`,distPath:n}})),e instanceof vg&&s.error(dt({code:`WORKSPACE_ROOT_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Workspace root memory prompt references missing config variables`,reason:z("The workspace root memory prompt uses scope variables that are not defined in `~/.aindex/.tnmsc.json`."),configPath:`~/.aindex/.tnmsc.json`,exactFix:z("Define the missing variables in `~/.aindex/.tnmsc.json` and rerun tnmsc."),details:{promptPath:n,errorMessage:e.message}})),t.exit(1)),e}let u={type:sh.ProjectRootMemory,content:l,length:l.length,filePathKind:ch.Relative,...c.yamlFrontMatter!=null&&{yamlFrontMatter:c.yamlFrontMatter},...c.rawFrontMatter!=null&&{rawFrontMatter:c.rawFrontMatter},markdownAst:c.markdownAst,markdownContents:c.markdownContents,dir:{pathKind:ch.Root,path:``,getDirectoryName:()=>``}};return{name:`__workspace__`,isWorkspaceRootProject:!0,...i!=null&&{projectConfig:i},rootMemoryPrompt:u}}catch(e){s.error(B({code:`WORKSPACE_ROOT_MEMORY_PROMPT_READ_FAILED`,title:`Failed to read workspace root memory prompt`,operation:`read`,targetKind:`workspace root memory prompt`,path:n,error:e}));return}}resolveWorkspaceRootProjectConfig(e){let t=e.filter(e=>e.isWorkspaceRootProject!==!0);return t.find(e=>e.isPromptSourceProject===!0)?.projectConfig??t[0]?.projectConfig}async readRootMemoryPrompt(e,n,r){let{fs:i,path:a,logger:o}=e,s=a.join(n,SS);if(!(!i.existsSync(s)||!i.statSync(s).isFile()))try{let e=i.readFileSync(s,`utf8`),a=Wm(e),c;try{let{content:t}=await yv(e,{globalScope:r,extractMetadata:!0,basePath:n,filePath:s});c=t,Ky(c,s)}catch(e){throw e instanceof gg&&(o.error(mt({code:`PROJECT_ROOT_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile project root memory prompt`,diagnosticText:Yy(e,{operation:`Failed to compile project root memory prompt.`,promptKind:`project-root-memory`,logicalName:s,distPath:s}),details:{promptKind:`project-root-memory`,distPath:s}})),e instanceof vg&&o.error(dt({code:`PROJECT_ROOT_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Project root memory prompt references missing config variables`,reason:z("The project root memory prompt uses scope variables that are not defined in `~/.aindex/.tnmsc.json`."),configPath:`~/.aindex/.tnmsc.json`,exactFix:z("Define the missing variables in `~/.aindex/.tnmsc.json` and rerun tnmsc."),details:{promptPath:s,errorMessage:e.message}})),t.exit(1)),e}return{type:sh.ProjectRootMemory,content:c,length:c.length,filePathKind:ch.Relative,...a.yamlFrontMatter!=null&&{yamlFrontMatter:a.yamlFrontMatter},...a.rawFrontMatter!=null&&{rawFrontMatter:a.rawFrontMatter},markdownAst:a.markdownAst,markdownContents:a.markdownContents,dir:{pathKind:ch.Root,path:``,getDirectoryName:()=>``}}}catch(e){o.error(B({code:`PROJECT_ROOT_MEMORY_PROMPT_READ_FAILED`,title:`Failed to read project root memory prompt`,operation:`read`,targetKind:`project root memory prompt`,path: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(B({code:`PROJECT_CHILD_MEMORY_SCAN_FAILED`,title:`Failed to scan project child memory prompts`,operation:`scan`,targetKind:`project child memory prompt directory`,path: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()||CS.includes(l.name))continue;let c=s.join(n,l.name),u=s.join(c,SS);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,n,r,i,a){let{fs:o,path:s,logger:c}=e,l=s.join(r,SS);try{let e=o.readFileSync(l,`utf8`),u=Wm(e),d;try{let{content:t}=await yv(e,{globalScope:a,extractMetadata:!0,basePath:r,filePath:l});d=t,Ky(d,l)}catch(e){throw e instanceof gg&&(c.error(mt({code:`PROJECT_CHILD_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile project child memory prompt`,diagnosticText:Yy(e,{operation:`Failed to compile project child memory prompt.`,promptKind:`project-child-memory`,logicalName:l,distPath:l}),details:{promptKind:`project-child-memory`,distPath:l}})),e instanceof vg&&c.error(dt({code:`PROJECT_CHILD_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Project child memory prompt references missing config variables`,reason:z("The project child memory prompt uses scope variables that are not defined in `~/.aindex/.tnmsc.json`."),configPath:`~/.aindex/.tnmsc.json`,exactFix:z("Define the missing variables in `~/.aindex/.tnmsc.json` and rerun tnmsc."),details:{promptPath:l,errorMessage:e.message}})),t.exit(1)),e}let f=s.relative(n,r),p=s.join(i,f),m=s.basename(r);return{type:sh.ProjectChildrenMemory,content:d,length:d.length,filePathKind:ch.Relative,...u.yamlFrontMatter!=null&&{yamlFrontMatter:u.yamlFrontMatter},...u.rawFrontMatter!=null&&{rawFrontMatter:u.rawFrontMatter},markdownAst:u.markdownAst,markdownContents:u.markdownContents,dir:{pathKind:ch.Relative,path:f,basePath:i,getDirectoryName:()=>m,getAbsolutePath:()=>p},workingChildDirectoryPath:{pathKind:ch.Relative,path:f,basePath:i,getDirectoryName:()=>m,getAbsolutePath:()=>p}}}catch(e){c.error(B({code:`PROJECT_CHILD_MEMORY_PROMPT_READ_FAILED`,title:`Failed to read project child memory prompt`,operation:`read`,targetKind:`project child memory prompt`,path:l,error:e}));return}}};const TS=Object.entries(vy);var ES=class extends cg{constructor(){super(`ReadmeMdInputCapability`,[`AindexInputCapability`])}async collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i,globalScope:a}=e,{workspaceDir:o,aindexDir:s}=this.resolveBasePaths(t),c=this.resolveAindexPath(t.aindex.app.dist,s),l=[];if(!r.existsSync(c)||!r.statSync(c).isDirectory())return n.debug(`aindex projects directory does not exist`,{path:c}),{readmePrompts:l};try{let t=r.readdirSync(c,{withFileTypes:!0});for(let n of t){if(!n.isDirectory())continue;let t=n.name,r=i.join(c,t);await this.collectReadmeFiles(e,r,t,o,``,l,a)}}catch(e){n.error(B({code:`README_PROJECT_SCAN_FAILED`,title:`Failed to scan aindex projects for readme prompts`,operation:`scan`,targetKind:`aindex project directory`,path:c,error:e}))}return{readmePrompts:l}}async collectReadmeFiles(e,n,r,i,a,o,s){let{fs:c,path:l,logger:u}=e,d=a===``;for(let[e,{src:f}]of TS){let p=l.join(n,f);if(!(!c.existsSync(p)||!c.statSync(p).isFile()))try{let m=c.readFileSync(p,`utf8`),h;try{let{content:e}=await yv(m,{...s!=null&&{globalScope:s},extractMetadata:!0,basePath:n,filePath:p});h=e,Ky(h,p)}catch(n){throw n instanceof gg&&(u.error(mt({code:`README_PROMPT_COMPILE_FAILED`,title:`Failed to compile readme-family prompt`,diagnosticText:Yy(n,{operation:`Failed to compile readme-family prompt.`,promptKind:`readme-family`,logicalName:`${r}/${f}`,distPath:p}),details:{promptKind:`readme-family`,distPath:p,projectName:r,fileKind:e}})),n instanceof vg&&u.error(dt({code:`README_SCOPE_VARIABLES_MISSING`,title:`Readme-family prompt references missing config variables`,reason:z("The readme-family prompt uses scope variables that are not defined in `~/.aindex/.tnmsc.json`."),configPath:`~/.aindex/.tnmsc.json`,exactFix:z("Define the missing variables in `~/.aindex/.tnmsc.json` and rerun tnmsc."),details:{promptPath:p,errorMessage:n.message}})),t.exit(1)),n}let g=d?r:l.join(r,a),_={pathKind:ch.Relative,path:g,basePath:i,getDirectoryName:()=>d?r:l.basename(a),getAbsolutePath:()=>l.resolve(i,g)},v={pathKind:ch.Relative,path:l.dirname(p),basePath:i,getDirectoryName:()=>l.basename(l.dirname(p)),getAbsolutePath:()=>l.dirname(p)};o.push({type:sh.Readme,content:h,length:h.length,filePathKind:ch.Relative,projectName:r,targetDir:_,isRoot:d,fileKind:e,markdownContents:[],dir:v})}catch(t){u.warn(B({code:`README_PROMPT_READ_FAILED`,title:`Failed to read readme-family file`,operation:`read`,targetKind:`readme-family prompt file`,path:p,error:t,details:{fileKind:e}}))}}try{let t=c.readdirSync(n,{withFileTypes:!0});for(let c of t)if(c.isDirectory()){let t=d?c.name:l.join(a,c.name),u=l.join(n,c.name);await this.collectReadmeFiles(e,u,r,i,t,o,s)}}catch(e){u.warn(B({code:`README_DIRECTORY_SCAN_FAILED`,title:`Failed to scan readme-family directory`,operation:`scan`,targetKind:`readme-family directory`,path:n,error:e}))}}},DS=class extends cg{constructor(){super(`RuleInputCapability`)}async collect(e){let{userConfigOptions:t,logger:n,path:r,fs:i,globalScope:a}=e,o=this.resolveBasePaths(t),s=this.resolveAindexPath(t.aindex.rules.src,o.aindexDir),c=this.resolveAindexPath(t.aindex.rules.dist,o.aindexDir),{prompts:l,errors:u}=await Qy(i,r,n,a).readFlatFiles(s,c,{kind:sh.Rule,localeExtensions:Ly,isDirectoryStructure:!1,createPrompt:async(e,t,n,i)=>{let a=i,o=r.join(c,`${n}.mdx`);if(a!=null){let e=gy(a,o);if(!e.valid)throw Error(e.errors.join(`
|
|
238
|
-
`))}let s=a?.globs??[],l=a?.scope??`project`,u=a?.seriName,d=n.replaceAll(`\\`,`/`),f=d.includes(`/`)?d.split(`/`)[0]??``:``,p=d.split(`/`).pop()??d,m={type:
|
|
239
|
-
`));return{rules:l.map(e=>e.dist?.prompt).filter(e=>e!=null)}}},
|
|
240
|
-
`));return Object.assign(
|
|
241
|
-
`));let
|
|
242
|
-
${
|
|
238
|
+
`}collect(e){return{}}};const BS=[`skills`,`commands`,`agents`,`app`];var VS=class extends gg{constructor(){super(`OrphanFileCleanupEffectInputCapability`),this.registerEffect(`orphan-file-cleanup`,this.cleanupOrphanFiles.bind(this),20)}buildProtectedDeletionGuard(e){return lg({workspaceDir:e.workspaceDir,aindexDir:e.aindexDir,rules:[...og(e.userConfigOptions,e.aindexDir,{workspaceDir:e.workspaceDir}),...(e.userConfigOptions.cleanupProtection?.rules??[]).map(e=>({path:e.path,protectionMode:e.protectionMode,reason:e.reason??`configured cleanup protection rule`,source:`configured-cleanup-protection`,matcher:e.matcher??`path`}))]})}buildDeletionPlan(e,t,n){let r=[],i=[],a=[];for(let o of BS){let s=e.path.join(t,o);e.fs.existsSync(s)&&e.fs.statSync(s).isDirectory()&&this.collectDirectoryPlan(e,s,o,n[o],r,i,a)}return{filesToDelete:r,dirsToDelete:i,errors:a}}async cleanupOrphanFiles(e){let{fs:t,path:n,aindexDir:r,logger:i,userConfigOptions:a,dryRun:o}=e,s=n.join(r,`dist`);if(!t.existsSync(s))return i.debug({action:`orphan-cleanup`,message:`dist/ directory does not exist, skipping`,distDir:s}),{success:!0,description:`dist/ directory does not exist, nothing to clean`,deletedFiles:[],deletedDirs:[]};let c=a.aindex,l={skills:c?.skills?.src??`skills`,commands:c?.commands?.src??`commands`,agents:c?.subAgents?.src??`subagents`,app:c?.app?.src??`app`},u=this.buildDeletionPlan(e,s,l),d=this.buildProtectedDeletionGuard(e),f=pg(u.filesToDelete,d),p=pg(u.dirsToDelete,d),m=[...f.violations,...p.violations].sort((e,t)=>e.targetPath.localeCompare(t.targetPath));if(m.length>0)return{success:!1,description:`Protected deletion guard blocked orphan cleanup for ${m.length} path(s)`,deletedFiles:[],deletedDirs:[],error:new Fh(`orphan-file-cleanup`,m)};if(o)return{success:!0,description:`Would delete ${f.safePaths.length} files and ${p.safePaths.length} directories`,deletedFiles:[...f.safePaths],deletedDirs:[...p.safePaths].sort((e,t)=>t.length-e.length)};let h=[],g=[],_=[...u.errors];for(let e of f.safePaths)try{t.unlinkSync(e),h.push(e),i.debug({action:`orphan-cleanup`,deleted:e})}catch(t){_.push({path:e,error:t}),i.warn(B({code:`ORPHAN_CLEANUP_FILE_DELETE_FAILED`,title:`Orphan cleanup could not delete a file`,operation:`delete`,targetKind:`orphan file`,path:e,error:t}))}for(let e of[...p.safePaths].sort((e,t)=>t.length-e.length))try{t.rmdirSync(e),g.push(e),i.debug({action:`orphan-cleanup`,deletedDir:e})}catch(t){_.push({path:e,error:t}),i.warn(B({code:`ORPHAN_CLEANUP_DIRECTORY_DELETE_FAILED`,title:`Orphan cleanup could not delete a directory`,operation:`delete`,targetKind:`orphan directory`,path:e,error:t}))}let v=_.length>0;return{success:!v,description:`Deleted ${h.length} files and ${g.length} directories`,deletedFiles:h,deletedDirs:g,...v&&{error:Error(`${_.length} errors occurred during cleanup`)}}}collectDirectoryPlan(e,t,n,r,i,a,o){let{fs:s,path:c,aindexDir:l,logger:u}=e,d;try{d=s.readdirSync(t,{withFileTypes:!0})}catch(e){return o.push({path:t,error:e}),u.warn(B({code:`ORPHAN_CLEANUP_DIRECTORY_READ_FAILED`,title:`Orphan cleanup could not read a directory`,operation:`read`,targetKind:`dist cleanup directory`,path:t,error:e})),!1}let f=!1;for(let s of d){let u=c.join(t,s.name);if(s.isDirectory()){this.collectDirectoryPlan(e,u,n,r,i,a,o)?a.push(u):f=!0;continue}if(!s.isFile()){f=!0;continue}this.isOrphanFile(e,u,n,r,l)?i.push(u):f=!0}return!f}isOrphanFile(e,t,n,r,i){let{fs:a,path:o}=e,s=o.basename(t),c=s.endsWith(`.mdx`),l=o.join(i,`dist`,n),u=o.relative(l,t),d=o.dirname(u),f=s.replace(/\.mdx$/,``);return c?!this.getPossibleSourcePaths(o,i,n,r,f,d).some(e=>a.existsSync(e)):!a.existsSync(o.join(i,r,u))}getPossibleSourcePaths(e,t,n,r,i,a){switch(n){case`skills`:{let n=(a===`.`?[i]:a.split(e.sep))[0]??i,o=a===`.`?``:a.slice(n.length+1);return o===``?[...Db.map(i=>e.join(t,r,n,`SKILL${i}`)),...Db.map(i=>e.join(t,r,n,`skill${i}`))]:Db.map(a=>e.join(t,r,n,o,`${i}${a}`))}case`commands`:case`agents`:case`app`:return a===`.`?Db.map(n=>e.join(t,r,`${i}${n}`)):Db.map(n=>e.join(t,r,a,`${i}${n}`));default:return[]}}collect(e){return{}}},HS=class extends gg{constructor(){super(`SkillDistCleanupEffectInputCapability`),this.registerEffect(`skill-dist-cleanup`,this.cleanupDistSkillArtifacts.bind(this),10)}async cleanupDistSkillArtifacts(e){let{fs:t,logger:n,userConfigOptions:r,aindexDir:i,dryRun:a}=e,o=this.resolveAindexPath(r.aindex.skills.src,i),s=this.resolveAindexPath(r.aindex.skills.dist,i);if(!t.existsSync(s))return n.debug({action:`skill-dist-cleanup`,message:`dist skills directory does not exist, skipping`,srcSkillsDir:o,distSkillsDir:s}),{success:!0,description:`dist skills directory does not exist, nothing to clean`,deletedFiles:[],deletedDirs:[]};let c=this.buildCleanupPlan(e,s);if(a)return{success:!0,description:`Would delete ${c.filesToDelete.length} files and ${c.dirsToDelete.length} directories`,deletedFiles:[...c.filesToDelete],deletedDirs:[...c.dirsToDelete].sort((e,t)=>t.length-e.length)};let l=[],u=[],d=[...c.errors];for(let e of c.filesToDelete)try{t.unlinkSync(e),l.push(e),n.debug({action:`skill-dist-cleanup`,deleted:e})}catch(t){d.push({path:e,error:t}),n.warn(B({code:`SKILL_DIST_CLEANUP_FILE_DELETE_FAILED`,title:`Skill dist cleanup could not delete a file`,operation:`delete`,targetKind:`skill dist file`,path:e,error:t}))}for(let e of[...c.dirsToDelete].sort((e,t)=>t.length-e.length))try{t.rmdirSync(e),u.push(e),n.debug({action:`skill-dist-cleanup`,deletedDir:e})}catch(t){d.push({path:e,error:t}),n.warn(B({code:`SKILL_DIST_CLEANUP_DIRECTORY_DELETE_FAILED`,title:`Skill dist cleanup could not delete a directory`,operation:`delete`,targetKind:`skill dist directory`,path:e,error:t}))}let f=d.length>0;return{success:!f,description:`Deleted ${l.length} files and ${u.length} directories`,deletedFiles:l,deletedDirs:u,...f&&{error:Error(`${d.length} errors occurred during cleanup`)}}}buildCleanupPlan(e,t){let n=[],r=[],i=[];return this.collectCleanupPlan(e,t,n,r,i),{filesToDelete:n,dirsToDelete:r,errors:i}}collectCleanupPlan(e,t,n,r,i){let{fs:a,path:o,logger:s}=e,c;try{c=a.readdirSync(t,{withFileTypes:!0})}catch(e){return i.push({path:t,error:e}),s.warn(B({code:`SKILL_DIST_CLEANUP_DIRECTORY_READ_FAILED`,title:`Skill dist cleanup could not read a directory`,operation:`read`,targetKind:`skill dist directory`,path:t,error:e})),!1}let l=!1;for(let a of c){let s=o.join(t,a.name);if(a.isDirectory()){this.collectCleanupPlan(e,s,n,r,i)?r.push(s):l=!0;continue}if(!a.isFile()){l=!0;continue}if(this.shouldRetainCompiledSkillFile(a.name)){l=!0;continue}n.push(s)}return!l}shouldRetainCompiledSkillFile(e){return e.endsWith(`.mdx`)&&!kb(e)}collect(e){return{}}};const US=/export\s+default\s*\{([\s\S]*?)\}/u,WS=/description\s*:\s*['"`]([^'"`]+)['"`]/u,GS=/name\s*:\s*['"`]([^'"`]+)['"`]/u,KS=/displayName\s*:\s*['"`]([^'"`]+)['"`]/u,qS=/keywords\s*:\s*\[([^\]]+)\]/u,JS=/author\s*:\s*['"`]([^'"`]+)['"`]/u,YS=/version\s*:\s*['"`]([^'"`]+)['"`]/u;function XS(e){let t={},n=US.exec(e);if(n?.[1]==null)return t;let r=n[1],i=WS.exec(r);i?.[1]!=null&&(t.description=i[1]);let a=GS.exec(r);a?.[1]!=null&&(t.name=a[1]);let o=KS.exec(r);o?.[1]!=null&&(t.displayName=o[1]);let s=qS.exec(r);s?.[1]!=null&&(t.keywords=s[1].split(`,`).map(e=>e.trim().replaceAll(/['"]/gu,``)).filter(e=>e.length>0));let c=JS.exec(r);c?.[1]!=null&&(t.author=c[1]);let l=YS.exec(r);return l?.[1]!=null&&(t.version=l[1]),t}function ZS(...e){let t={};for(let n of e)if(n!=null)for(let[e,r]of Object.entries(n))r!==void 0&&(t[e]=r);return t}function QS(e){let{logger:t,warnedDerivedNames:n,sourcePath:r,authoredName:i,skillName:a}=e;n?.has(r)!==!0&&(n?.add(r),t.warn(dt({code:`SKILL_NAME_IGNORED`,title:`Skill authored name is ignored`,reason:z(`tnmsc ignores the authored skill name "${i}" in favor of the directory-derived name "${a}".`),configPath:r,exactFix:z("Remove the `name` field from the skill front matter or exported metadata.",`Rename the skill directory if you need a different skill name.`),details:{authoredName:i,derivedName:a}})))}const $S={".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`},eC=new Set(`.png,.jpg,.jpeg,.gif,.webp,.ico,.bmp,.tiff,.svg,.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,.pdf,.docx,.doc,.xlsx,.xls,.pptx,.ppt,.odt,.ods,.odp`.split(`,`));function tC(e){return eC.has(e.toLowerCase())}function nC(e){return $S[e.toLowerCase()]}function rC(...e){return i.join(...e).replaceAll(`\\`,`/`)}var iC=class{ctx;constructor(e){this.ctx=e}async processDirectory(e,t,n){let r=t?`${t}/${e.name}`:e.name;return this.scanSkillDirectoryAsync(n,r)}async processFile(e,t,n){let r=t?`${t}/${e.name}`:e.name;if(this.ctx.scanMode===`distChildDocs`){if(t===``&&e.name===`skill.mdx`||kb(e.name)||!e.name.endsWith(`.mdx`))return{childDocs:[],resources:[]};let i=await this.processChildDoc(r,n);return{childDocs:i?[i]:[],resources:[]}}if(t===``&&e.name===`mcp.json`||kb(e.name)||e.name.endsWith(`.mdx`))return{childDocs:[],resources:[]};let i=this.processResourceFile(e.name,r,n);return{childDocs:[],resources:i?[i]:[]}}async processChildDoc(e,t){try{let n=this.ctx.fs.readFileSync(t,`utf8`),r=Qm(n),a=$m((await Vv(n,{globalScope:this.ctx.globalScope,extractMetadata:!0,basePath:i.dirname(t),filePath:t})).content);return Lb(a,t),{type:hh.SkillChildDoc,content:a,length:a.length,filePathKind:gh.Relative,markdownAst:r.markdownAst,markdownContents:r.markdownContents,...r.rawFrontMatter!=null&&{rawFrontMatter:r.rawFrontMatter},relativePath:e,dir:{pathKind:gh.Relative,path:e,basePath:this.ctx.skillDir,getDirectoryName:()=>i.dirname(e),getAbsolutePath:()=>t}}}catch(n){throw this.ctx.logger.error(mt({code:`SKILL_CHILD_DOC_COMPILE_FAILED`,title:`Failed to compile skill child doc`,diagnosticText:Bb(n,{operation:`Failed to compile skill child doc.`,promptKind:`skill-child-doc`,logicalName:`${i.basename(this.ctx.skillDir)}/${e.replace(/\.mdx$/u,``)}`,distPath:t,srcPath:Rb(i,t,{distRootDir:this.ctx.skillDir,srcRootDir:this.ctx.sourceSkillDir})}),details:{skillDir:this.ctx.skillDir,relativePath:e,filePath:t}})),n}}processResourceFile(e,t,n){let r=i.extname(e);try{let{content:i,encoding:a,length:o}=this.readFileContent(n,r),s=nC(r);return{type:hh.SkillResource,extension:r,fileName:e,relativePath:t,sourcePath:n,content:i,encoding:a,length:o,...s!=null&&{mimeType:s}}}catch(r){return this.ctx.logger.warn(B({code:`SKILL_RESOURCE_READ_FAILED`,title:`Failed to read skill resource file`,operation:`read`,targetKind:`skill resource file`,path:n,error:r,details:{relativePath:t,fileName:e,skillDir:this.ctx.skillDir}})),null}}readFileContent(e,t){if(tC(t)){let t=this.ctx.fs.readFileSync(e);return{content:t.toString(`base64`),encoding:`base64`,length:t.length}}let n=this.ctx.fs.readFileSync(e,`utf8`);return{content:n,encoding:`text`,length:f.from(n,`utf8`).length}}async scanSkillDirectoryAsync(e,t=``){let n=[],r=[],i;try{i=this.ctx.fs.readdirSync(e,{withFileTypes:!0})}catch(t){return this.ctx.logger.warn(B({code:`SKILL_DIRECTORY_SCAN_FAILED`,title:`Failed to scan skill directory`,operation:`scan`,targetKind:`skill directory`,path:e,error:t,details:{skillDir:this.ctx.skillDir,scanMode:this.ctx.scanMode}})),{childDocs:n,resources:r}}for(let a of i){let i=rC(e,a.name);if(a.isDirectory()){let e=await this.processDirectory(a,t,i);n.push(...e.childDocs),r.push(...e.resources);continue}if(!a.isFile())continue;let o=await this.processFile(a,t,i);n.push(...o.childDocs),r.push(...o.resources)}return{childDocs:n,resources:r}}};function aC(e,t,n,r=``){let i=[],a=r===``?e:rC(e,r),o;try{o=t.readdirSync(a,{withFileTypes:!0})}catch(e){return n.warn(B({code:`SKILL_SOURCE_CHILD_SCAN_FAILED`,title:`Failed to scan skill source child docs`,operation:`scan`,targetKind:`skill source child doc directory`,path:a,error:e})),i}for(let a of o){let o=r?`${r}/${a.name}`:a.name;if(a.isDirectory()){i.push(...aC(e,t,n,o));continue}!a.isFile()||!kb(a.name)||r===``&&a.name===`skill.src.mdx`||i.push(o.replace(/\.src\.mdx$/u,`.mdx`))}return i}function oC(e,t,n,r,a){if(r.existsSync(t))for(let o of aC(t,r,a)){let a=i.join(n,o);if(!r.existsSync(a))throw new Nb({kind:`skill child doc`,name:`${e}/${o}`,sourcePath:i.join(t,o.replace(/\.mdx$/u,`.src.mdx`)),expectedDistPath:a})}}function sC(e,t,n){let r=i.join(e,`mcp.json`);if(t.existsSync(r)){if(!t.statSync(r).isFile()){n.warn(pt({code:`SKILL_MCP_CONFIG_NOT_FILE`,title:`Skill MCP config path is not a file`,path:r,expectedKind:`mcp.json file`,actualState:`path exists but is not a regular file`,details:{skillDir:e}}));return}try{let i=t.readFileSync(r,`utf8`),a=JSON.parse(i);if(a.mcpServers==null||typeof a.mcpServers!=`object`){n.warn(dt({code:`SKILL_MCP_CONFIG_INVALID`,title:`Skill MCP config is missing mcpServers`,reason:z(`The skill MCP config at "${r}" does not contain a top-level mcpServers object.`),configPath:r,exactFix:z("Add a top-level `mcpServers` object to mcp.json before retrying tnmsc."),details:{skillDir:e}}));return}return{type:hh.SkillMcpConfig,mcpServers:a.mcpServers,rawContent:i}}catch(t){n.warn(dt({code:`SKILL_MCP_CONFIG_PARSE_FAILED`,title:`Failed to parse skill MCP config`,reason:z(`tnmsc could not parse the MCP config file at "${r}".`,`Underlying error: ${t instanceof Error?t.message:String(t)}`),configPath:r,exactFix:z(`Fix the JSON syntax in mcp.json and rerun tnmsc.`),details:{skillDir:e,errorMessage:t instanceof Error?t.message:String(t)}}));return}}}async function cC(e,t,n,r,a,o,s,c,l=[],u=[],d,f,p){let{logger:m,globalScope:h,fs:g}=s,_=i.join(a,`skill.mdx`),v=g.existsSync(i.join(o,`skill.src.mdx`))?i.join(o,`skill.src.mdx`):_,y=e,b,x;if(g.existsSync(_)){y=g.readFileSync(_,`utf8`),b=Qm(y);let t=await Vv(y,{globalScope:h,extractMetadata:!0,basePath:a,filePath:_});e=$m(t.content),Lb(e,_),x=t.metadata.fields}let S=ZS(XS(y),f,x),C=new Set,w=b?.yamlFrontMatter?.name;typeof w==`string`&&w.trim().length>0&&C.add(w);let T=S.name;typeof T==`string`&&T.trim().length>0&&C.add(T);for(let e of C)QS({logger:m,sourcePath:v,authoredName:e,skillName:n,...p!=null&&{warnedDerivedNames:p}});let E=b?.yamlFrontMatter?.description??S?.description;if(E==null||E.trim().length===0)throw m.error(st({code:`SKILL_VALIDATION_FAILED`,title:`Skill description is required`,rootCause:z(`The skill "${n}" does not provide a non-empty description in its compiled metadata or front matter.`),exactFix:z(`Add a non-empty description field to the skill front matter or exported metadata and rebuild the skill.`),possibleFixes:[z("Set `description` in `SKILL.md` front matter."),z(`If you export metadata from code, ensure the exported description is non-empty.`)],details:{skill:n,skillDir:r,yamlDescription:b?.yamlFrontMatter?.description,exportDescription:S?.description}})),Error(`Skill "${n}" validation failed: description is required and cannot be empty`);let ee={...S,...b?.yamlFrontMatter??{},name:n,description:E},D=rb(ee,_);if(!D.valid)throw Error(D.errors.join(`
|
|
239
|
+
`));return{type:hh.Skill,content:e,length:e.length,filePathKind:gh.Relative,skillName:n,yamlFrontMatter:ee,markdownAst:b?.markdownAst,markdownContents:b?.markdownContents??[],dir:{pathKind:gh.Relative,path:n,basePath:r,getDirectoryName:()=>n,getAbsolutePath:()=>i.join(r,n)},...b?.rawFrontMatter!=null&&{rawFrontMatter:b.rawFrontMatter},...c!=null&&{mcpConfig:c},...l!=null&&l.length>0&&{childDocs:l},...u!=null&&u.length>0&&{resources:u},...d!=null&&{seriName:d}}}var lC=class extends gg{constructor(){super(`SkillInputCapability`)}readMcpConfig(e,t,n){return sC(e,t,n)}async scanSkillDirectory(e,t,n,r=``,i=`srcResources`,a,o){return new iC({fs:t,logger:n,skillDir:e,scanMode:i,...a!=null&&{globalScope:a},...o!=null&&{sourceSkillDir:o}}).scanSkillDirectoryAsync(e,r)}async collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i,globalScope:a}=e,{aindexDir:o}=this.resolveBasePaths(t),s=this.resolveAindexPath(t.aindex.skills.src,o),c=this.resolveAindexPath(t.aindex.skills.dist,o),l=[],u=Ub(r,i,n,a),d=new Set,f=new Map,p=async e=>{let t=f.get(e);if(t!=null)return t;let o=i.join(s,e),l=i.join(c,e),u=r.existsSync(l)?(await this.scanSkillDirectory(l,r,n,``,`distChildDocs`,a,o)).childDocs:[],d=r.existsSync(o)?(await this.scanSkillDirectory(o,r,n,``,`srcResources`,a)).resources:[],p=sC(o,r,n);oC(e,o,l,r,n);let m={childDocs:u,resources:d,...p!=null&&{mcpConfig:p}};return f.set(e,m),m},{prompts:m,errors:h}=await u.readDirectoryStructure(s,c,{kind:hh.Skill,entryFileName:`skill`,localeExtensions:Ob,isDirectoryStructure:!0,createPrompt:async(t,n,r,a)=>{let o=i.join(c,r),{childDocs:l,resources:u,mcpConfig:f}=await p(r);return cC(t,n,r,c,o,i.join(s,r),e,f,l,u,void 0,a,d)}});for(let e of h)n.warn(B({code:`SKILL_PROMPT_READ_FAILED`,title:`Failed to read skill prompt`,operation:e.phase===`scan`?`scan`:`read`,targetKind:`skill prompt`,path:e.path,error:e.error,details:{phase:e.phase}}));if(h.length>0)throw Error(h.map(e=>e.error instanceof Error?e.error.message:String(e.error)).join(`
|
|
240
|
+
`));for(let e of m){let t=e.dist?.prompt;t!=null&&l.push(t)}return{skills:l}}},uC=class e extends gg{static projectConfigFileName=`project.json5`;constructor(){super(`AindexInputCapability`)}loadProjectConfig(t,n,r,i,a,o){let s=a.join(n,r,t,e.projectConfigFileName);if(i.existsSync(s))try{let n=i.readFileSync(s,`utf8`);try{return m.parse(n)}catch(n){o.warn(dt({code:`AINDEX_PROJECT_JSON5_INVALID`,title:`Failed to parse ${e.projectConfigFileName} for ${t}`,reason:z(`tnmsc could not parse the ${e.projectConfigFileName} file for "${t}".`,`Underlying error: ${n instanceof Error?n.message:String(n)}`),configPath:s,exactFix:z(`Fix the JSON5 syntax in ${e.projectConfigFileName} and rerun tnmsc.`),details:{projectName:t,errorMessage:n instanceof Error?n.message:String(n)}}));return}}catch(n){o.warn(dt({code:`AINDEX_PROJECT_JSON5_READ_FAILED`,title:`Failed to load ${e.projectConfigFileName} for ${t}`,reason:z(`tnmsc could not read the ${e.projectConfigFileName} file for "${t}".`,`Underlying error: ${n instanceof Error?n.message:String(n)}`),configPath:s,exactFix:z(`Ensure ${e.projectConfigFileName} exists, is readable, and contains valid JSON5.`),details:{projectName:t,errorMessage:n instanceof Error?n.message:String(n)}}));return}}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{workspaceDir:a,aindexDir:o}=this.resolveBasePaths(t),s=this.resolveAindexPath(t.aindex.app.dist,o),c=i.basename(o),l=[];if(r.existsSync(s)&&r.statSync(s).isDirectory())try{let e=r.readdirSync(s,{withFileTypes:!0});for(let s of e)if(s.isDirectory()){let e=s.name===c,u=this.loadProjectConfig(s.name,o,t.aindex.app.src,r,i,n);l.push({name:s.name,...e&&{isPromptSourceProject:!0},...u!=null&&{projectConfig:u},dirFromWorkspacePath:{pathKind:gh.Relative,path:s.name,basePath:a,getDirectoryName:()=>s.name,getAbsolutePath:()=>i.resolve(a,s.name)}})}}catch(e){n.error(B({code:`AINDEX_PROJECT_DIRECTORY_SCAN_FAILED`,title:`Failed to scan aindex projects directory`,operation:`scan`,targetKind:`aindex projects directory`,path:s,error:e}))}if(l.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 s of e)if(s.isDirectory()&&!s.name.startsWith(`.`)){let e=s.name===c,u=this.loadProjectConfig(s.name,o,t.aindex.app.src,r,i,n);l.push({name:s.name,...e&&{isPromptSourceProject:!0},...u!=null&&{projectConfig:u},dirFromWorkspacePath:{pathKind:gh.Relative,path:s.name,basePath:a,getDirectoryName:()=>s.name,getAbsolutePath:()=>i.resolve(a,s.name)}})}}catch(e){n.error(B({code:`WORKSPACE_DIRECTORY_SCAN_FAILED`,title:`Failed to scan workspace directory`,operation:`scan`,targetKind:`workspace directory`,path:a,error:e}))}}return{workspace:{directory:{pathKind:gh.Absolute,path:a,getDirectoryName:()=>i.basename(a)},projects:l}}}},dC=class extends gg{constructor(){super(`CommandInputCapability`)}createCommandPrompt(e,t,n,r,i,a){let{path:o}=i,s=n.replaceAll(`\\`,`/`),c=s.indexOf(`/`),l=c===-1?void 0:s.slice(0,c),u=(c===-1?s:s.slice(c+1)).replace(/\.mdx$/,``),d=u.indexOf(`_`),f=l??(d===-1?void 0:u.slice(0,Math.max(0,d))),p=l!=null||d===-1?u:u.slice(Math.max(0,d+1)),m=o.join(r,`${n}.mdx`),h=`${n}.mdx`,g=a,_={type:hh.Command,content:e,length:e.length,filePathKind:gh.Relative,dir:{pathKind:gh.Relative,path:h,basePath:r,getDirectoryName:()=>h.replace(/\.mdx$/,``),getAbsolutePath:()=>m},...f!=null&&{commandPrefix:f},commandName:p};if(g==null)return _;let v=ib(g,m);if(!v.valid)throw Error(v.errors.join(`
|
|
241
|
+
`));return Object.assign(_,{yamlFrontMatter:g}),g.seriName!=null&&Object.assign(_,{seriName:g.seriName}),g.scope===`global`&&Object.assign(_,{globalOnly:!0}),_}async collect(e){let{userConfigOptions:t,logger:n,path:r,fs:i,globalScope:a}=e,o=this.resolveBasePaths(t),s=this.resolveAindexPath(t.aindex.commands.src,o.aindexDir),c=this.resolveAindexPath(t.aindex.commands.dist,o.aindexDir);n.debug(`CommandInputCapability collecting`,{srcDir:s,distDir:c,aindexDir:o.aindexDir});let{prompts:l,errors:u}=await Ub(i,r,n,a).readFlatFiles(s,c,{kind:hh.Command,localeExtensions:Ob,isDirectoryStructure:!1,createPrompt:(t,n,r,i)=>this.createCommandPrompt(t,n,r,c,e,i)});n.debug(`CommandInputCapability read complete`,{commandCount:l.length,errorCount:u.length});for(let e of u)n.warn(B({code:`COMMAND_PROMPT_READ_FAILED`,title:`Failed to read command prompt`,operation:e.phase===`scan`?`scan`:`read`,targetKind:`command prompt`,path:e.path,error:e.error,details:{phase:e.phase}}));if(u.length>0)throw Error(u.map(e=>e.error instanceof Error?e.error.message:String(e.error)).join(`
|
|
242
|
+
`));let d=[];for(let e of l){let t=e.dist;if(t?.prompt==null)continue;let{prompt:n,rawMdx:r}=t;d.push(r==null?n:{...n,rawMdxContent:r})}return n.debug(`CommandInputCapability flattened commands`,{count:d.length,commands:d.map(e=>e.commandName)}),{commands:d}}},fC=class extends gg{constructor(){super(`EditorConfigInputCapability`)}collect(e){let{userConfigOptions:t,fs:n}=e,{workspaceDir:r,aindexDir:i}=this.resolveBasePaths(t),a=[],o=Ph(_h.EditorConfig,`.editorconfig`,i,n,{command:e.runtimeCommand,workspaceDir:r});return o!=null&&a.push(o),{editorConfigFiles:a}}},pC=class extends gg{constructor(){super(`GitExcludeInputCapability`)}collect(e){let{workspaceDir:t,aindexDir:n}=this.resolveBasePaths(e.userConfigOptions),r=Mh(n,xh,{command:e.runtimeCommand,workspaceDir:t});if(!e.fs.existsSync(r))return this.log.debug({action:`collect`,message:`File not found`,path:r}),{};let i=e.fs.readFileSync(r,`utf8`);return i.length===0?(this.log.debug({action:`collect`,message:`File is empty`,path:r}),{}):(this.log.debug({action:`collect`,message:`Loaded file content`,path:r,length:i.length}),{shadowGitExclude:i})}},mC=class extends gg{constructor(){super(`GitIgnoreInputCapability`)}collect(e){let{workspaceDir:t,aindexDir:n}=this.resolveBasePaths(e.userConfigOptions),r=Mh(n,bh,{command:e.runtimeCommand,workspaceDir:t});if(!e.fs.existsSync(r))return this.log.debug({action:`collect`,message:`File not found`,path:r}),{};let i=e.fs.readFileSync(r,`utf8`);return i.length===0?(this.log.debug({action:`collect`,message:`File is empty`,path:r}),{}):(this.log.debug({action:`collect`,message:`Loaded file content`,path:r,length:i.length}),{globalGitIgnore:i})}},hC=class extends gg{constructor(){super(`GlobalMemoryInputCapability`)}async collect(e){let{userConfigOptions:n,fs:r,path:i,globalScope:a}=e,{aindexDir:o}=this.resolveBasePaths(n),s=this.resolveAindexPath(n.aindex.globalPrompt.dist,o);if(!r.existsSync(s))return this.log.warn(pt({code:`GLOBAL_MEMORY_PROMPT_MISSING`,title:`Global memory prompt is missing`,path:s,expectedKind:`compiled global memory prompt file`,actualState:`path does not exist`})),{};if(!r.statSync(s).isFile())return this.log.warn(pt({code:`GLOBAL_MEMORY_PROMPT_NOT_FILE`,title:`Global memory prompt path is not a file`,path:s,expectedKind:`compiled global memory prompt file`,actualState:`path exists but is not a regular file`})),{};let l=r.readFileSync(s,`utf8`),u=Qm(l),d;try{d=(await Vv(l,{...a!=null&&{globalScope:a},extractMetadata:!0,basePath:i.dirname(s),filePath:s})).content,Lb(d,s)}catch(e){throw e instanceof Tg&&(this.log.error(mt({code:`GLOBAL_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile global memory prompt`,diagnosticText:Bb(e,{operation:`Failed to compile global memory prompt.`,promptKind:`global-memory`,logicalName:`global-memory`,distPath:s}),details:{promptKind:`global-memory`,distPath:s}})),e instanceof Dg&&this.log.error(dt({code:`GLOBAL_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Global memory prompt references missing config variables`,reason:z("The global memory prompt uses scope variables that are not defined in `~/.aindex/.tnmsc.json`."),configPath:`~/.aindex/.tnmsc.json`,exactFix:z("Add the missing variables to `~/.aindex/.tnmsc.json` and rerun tnmsc."),possibleFixes:[z("If you reference `{profile.name}`, define `profile.name` in the config file.")],details:{promptPath:s,errorMessage:e.message}})),t.exit(1)),e}return this.log.debug({action:`collect`,path:s,contentLength:d.length}),{globalMemory:{type:hh.GlobalMemory,content:d,length:d.length,filePathKind:gh.Relative,...u.rawFrontMatter!=null&&{rawFrontMatter:u.rawFrontMatter},markdownAst:u.markdownAst,markdownContents:u.markdownContents,dir:{pathKind:gh.Relative,path:i.basename(s),basePath:i.dirname(s),getDirectoryName:()=>i.basename(s),getAbsolutePath:()=>s},parentDirectoryPath:{type:vh.UserHome,directory:{pathKind:gh.Relative,path:``,basePath:c.homedir(),getDirectoryName:()=>i.basename(c.homedir()),getAbsolutePath:()=>c.homedir()}}}}}},gC=class extends gg{constructor(){super(`JetBrainsConfigInputCapability`)}collect(e){let{userConfigOptions:t,fs:n}=e,{workspaceDir:r,aindexDir:i}=this.resolveBasePaths(t),a=[`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`],o=[];for(let t of a){let a=Ph(_h.IntellijIDEA,t,i,n,{command:e.runtimeCommand,workspaceDir:r});a!=null&&o.push(a)}return{jetbrainsConfigFiles:o}}};const _C=`agt.mdx`,vC=[`node_modules`,`.git`];var yC=class extends gg{constructor(){super(`ProjectPromptInputCapability`,[`AindexInputCapability`])}async collect(e){let{dependencyContext:t,fs:n,userConfigOptions:r,path:i,globalScope:a}=e,{aindexDir:o}=this.resolveBasePaths(r),s=this.resolveAindexPath(r.aindex.app.dist,o),c=this.resolveAindexPath(r.aindex.workspacePrompt.dist,o),l=t.workspace;if(l==null)return this.log.info(`No workspace found in dependency context, skipping project prompt enhancement`),{};let u=l.projects??[],d=await Promise.all(u.map(async t=>{let r=t.name;if(r==null||t.isWorkspaceRootProject===!0)return t;let o=i.join(s,r);if(!n.existsSync(o)||!n.statSync(o).isDirectory())return t;let c=t.dirFromWorkspacePath?.getAbsolutePath(),l=await this.readRootMemoryPrompt(e,o,a),u=c==null?[]:await this.scanChildMemoryPrompts(e,o,c,a);return{...t,...l!=null&&{rootMemoryPrompt:l},...u.length>0&&{childMemoryPrompts:u}}})),f=await this.readWorkspaceRootProjectPrompt(e,c,a,this.resolveWorkspaceRootProjectConfig(u));return{workspace:{directory:l.directory,projects:f==null?d:[...d,f]}}}async readWorkspaceRootProjectPrompt(e,n,r,i){let{fs:a,path:o,logger:s}=e;if(!(!a.existsSync(n)||!a.statSync(n).isFile()))try{let e=a.readFileSync(n,`utf8`),c=Qm(e),l;try{let{content:t}=await Vv(e,{globalScope:r,extractMetadata:!0,basePath:o.dirname(n),filePath:n});l=t,Lb(l,n)}catch(e){throw e instanceof Tg&&(s.error(mt({code:`WORKSPACE_ROOT_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile workspace root memory prompt`,diagnosticText:Bb(e,{operation:`Failed to compile workspace root memory prompt.`,promptKind:`workspace-root-memory`,logicalName:n,distPath:n}),details:{promptKind:`workspace-root-memory`,distPath:n}})),e instanceof Dg&&s.error(dt({code:`WORKSPACE_ROOT_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Workspace root memory prompt references missing config variables`,reason:z("The workspace root memory prompt uses scope variables that are not defined in `~/.aindex/.tnmsc.json`."),configPath:`~/.aindex/.tnmsc.json`,exactFix:z("Define the missing variables in `~/.aindex/.tnmsc.json` and rerun tnmsc."),details:{promptPath:n,errorMessage:e.message}})),t.exit(1)),e}let u={type:hh.ProjectRootMemory,content:l,length:l.length,filePathKind:gh.Relative,...c.yamlFrontMatter!=null&&{yamlFrontMatter:c.yamlFrontMatter},...c.rawFrontMatter!=null&&{rawFrontMatter:c.rawFrontMatter},markdownAst:c.markdownAst,markdownContents:c.markdownContents,dir:{pathKind:gh.Root,path:``,getDirectoryName:()=>``}};return{name:`__workspace__`,isWorkspaceRootProject:!0,...i!=null&&{projectConfig:i},rootMemoryPrompt:u}}catch(e){s.error(B({code:`WORKSPACE_ROOT_MEMORY_PROMPT_READ_FAILED`,title:`Failed to read workspace root memory prompt`,operation:`read`,targetKind:`workspace root memory prompt`,path:n,error:e}));return}}resolveWorkspaceRootProjectConfig(e){let t=e.filter(e=>e.isWorkspaceRootProject!==!0);return t.find(e=>e.isPromptSourceProject===!0)?.projectConfig??t[0]?.projectConfig}async readRootMemoryPrompt(e,n,r){let{fs:i,path:a,logger:o}=e,s=a.join(n,_C);if(!(!i.existsSync(s)||!i.statSync(s).isFile()))try{let e=i.readFileSync(s,`utf8`),a=Qm(e),c;try{let{content:t}=await Vv(e,{globalScope:r,extractMetadata:!0,basePath:n,filePath:s});c=t,Lb(c,s)}catch(e){throw e instanceof Tg&&(o.error(mt({code:`PROJECT_ROOT_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile project root memory prompt`,diagnosticText:Bb(e,{operation:`Failed to compile project root memory prompt.`,promptKind:`project-root-memory`,logicalName:s,distPath:s}),details:{promptKind:`project-root-memory`,distPath:s}})),e instanceof Dg&&o.error(dt({code:`PROJECT_ROOT_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Project root memory prompt references missing config variables`,reason:z("The project root memory prompt uses scope variables that are not defined in `~/.aindex/.tnmsc.json`."),configPath:`~/.aindex/.tnmsc.json`,exactFix:z("Define the missing variables in `~/.aindex/.tnmsc.json` and rerun tnmsc."),details:{promptPath:s,errorMessage:e.message}})),t.exit(1)),e}return{type:hh.ProjectRootMemory,content:c,length:c.length,filePathKind:gh.Relative,...a.yamlFrontMatter!=null&&{yamlFrontMatter:a.yamlFrontMatter},...a.rawFrontMatter!=null&&{rawFrontMatter:a.rawFrontMatter},markdownAst:a.markdownAst,markdownContents:a.markdownContents,dir:{pathKind:gh.Root,path:``,getDirectoryName:()=>``}}}catch(e){o.error(B({code:`PROJECT_ROOT_MEMORY_PROMPT_READ_FAILED`,title:`Failed to read project root memory prompt`,operation:`read`,targetKind:`project root memory prompt`,path: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(B({code:`PROJECT_CHILD_MEMORY_SCAN_FAILED`,title:`Failed to scan project child memory prompts`,operation:`scan`,targetKind:`project child memory prompt directory`,path: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()||vC.includes(l.name))continue;let c=s.join(n,l.name),u=s.join(c,_C);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,n,r,i,a){let{fs:o,path:s,logger:c}=e,l=s.join(r,_C);try{let e=o.readFileSync(l,`utf8`),u=Qm(e),d;try{let{content:t}=await Vv(e,{globalScope:a,extractMetadata:!0,basePath:r,filePath:l});d=t,Lb(d,l)}catch(e){throw e instanceof Tg&&(c.error(mt({code:`PROJECT_CHILD_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile project child memory prompt`,diagnosticText:Bb(e,{operation:`Failed to compile project child memory prompt.`,promptKind:`project-child-memory`,logicalName:l,distPath:l}),details:{promptKind:`project-child-memory`,distPath:l}})),e instanceof Dg&&c.error(dt({code:`PROJECT_CHILD_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Project child memory prompt references missing config variables`,reason:z("The project child memory prompt uses scope variables that are not defined in `~/.aindex/.tnmsc.json`."),configPath:`~/.aindex/.tnmsc.json`,exactFix:z("Define the missing variables in `~/.aindex/.tnmsc.json` and rerun tnmsc."),details:{promptPath:l,errorMessage:e.message}})),t.exit(1)),e}let f=s.relative(n,r),p=s.join(i,f),m=s.basename(r);return{type:hh.ProjectChildrenMemory,content:d,length:d.length,filePathKind:gh.Relative,...u.yamlFrontMatter!=null&&{yamlFrontMatter:u.yamlFrontMatter},...u.rawFrontMatter!=null&&{rawFrontMatter:u.rawFrontMatter},markdownAst:u.markdownAst,markdownContents:u.markdownContents,dir:{pathKind:gh.Relative,path:f,basePath:i,getDirectoryName:()=>m,getAbsolutePath:()=>p},workingChildDirectoryPath:{pathKind:gh.Relative,path:f,basePath:i,getDirectoryName:()=>m,getAbsolutePath:()=>p}}}catch(e){c.error(B({code:`PROJECT_CHILD_MEMORY_PROMPT_READ_FAILED`,title:`Failed to read project child memory prompt`,operation:`read`,targetKind:`project child memory prompt`,path:l,error:e}));return}}};const bC=Object.entries(cb);var xC=class extends gg{constructor(){super(`ReadmeMdInputCapability`,[`AindexInputCapability`])}async collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i,globalScope:a}=e,{workspaceDir:o,aindexDir:s}=this.resolveBasePaths(t),c=this.resolveAindexPath(t.aindex.app.dist,s),l=[];if(!r.existsSync(c)||!r.statSync(c).isDirectory())return n.debug(`aindex projects directory does not exist`,{path:c}),{readmePrompts:l};try{let t=r.readdirSync(c,{withFileTypes:!0});for(let n of t){if(!n.isDirectory())continue;let t=n.name,r=i.join(c,t);await this.collectReadmeFiles(e,r,t,o,``,l,a)}}catch(e){n.error(B({code:`README_PROJECT_SCAN_FAILED`,title:`Failed to scan aindex projects for readme prompts`,operation:`scan`,targetKind:`aindex project directory`,path:c,error:e}))}return{readmePrompts:l}}async collectReadmeFiles(e,n,r,i,a,o,s){let{fs:c,path:l,logger:u}=e,d=a===``;for(let[e,{src:f}]of bC){let p=l.join(n,f);if(!(!c.existsSync(p)||!c.statSync(p).isFile()))try{let m=c.readFileSync(p,`utf8`),h;try{let{content:e}=await Vv(m,{...s!=null&&{globalScope:s},extractMetadata:!0,basePath:n,filePath:p});h=e,Lb(h,p)}catch(n){throw n instanceof Tg&&(u.error(mt({code:`README_PROMPT_COMPILE_FAILED`,title:`Failed to compile readme-family prompt`,diagnosticText:Bb(n,{operation:`Failed to compile readme-family prompt.`,promptKind:`readme-family`,logicalName:`${r}/${f}`,distPath:p}),details:{promptKind:`readme-family`,distPath:p,projectName:r,fileKind:e}})),n instanceof Dg&&u.error(dt({code:`README_SCOPE_VARIABLES_MISSING`,title:`Readme-family prompt references missing config variables`,reason:z("The readme-family prompt uses scope variables that are not defined in `~/.aindex/.tnmsc.json`."),configPath:`~/.aindex/.tnmsc.json`,exactFix:z("Define the missing variables in `~/.aindex/.tnmsc.json` and rerun tnmsc."),details:{promptPath:p,errorMessage:n.message}})),t.exit(1)),n}let g=d?r:l.join(r,a),_={pathKind:gh.Relative,path:g,basePath:i,getDirectoryName:()=>d?r:l.basename(a),getAbsolutePath:()=>l.resolve(i,g)},v={pathKind:gh.Relative,path:l.dirname(p),basePath:i,getDirectoryName:()=>l.basename(l.dirname(p)),getAbsolutePath:()=>l.dirname(p)};o.push({type:hh.Readme,content:h,length:h.length,filePathKind:gh.Relative,projectName:r,targetDir:_,isRoot:d,fileKind:e,markdownContents:[],dir:v})}catch(t){u.warn(B({code:`README_PROMPT_READ_FAILED`,title:`Failed to read readme-family file`,operation:`read`,targetKind:`readme-family prompt file`,path:p,error:t,details:{fileKind:e}}))}}try{let t=c.readdirSync(n,{withFileTypes:!0});for(let c of t)if(c.isDirectory()){let t=d?c.name:l.join(a,c.name),u=l.join(n,c.name);await this.collectReadmeFiles(e,u,r,i,t,o,s)}}catch(e){u.warn(B({code:`README_DIRECTORY_SCAN_FAILED`,title:`Failed to scan readme-family directory`,operation:`scan`,targetKind:`readme-family directory`,path:n,error:e}))}}},SC=class extends gg{constructor(){super(`RuleInputCapability`)}async collect(e){let{userConfigOptions:t,logger:n,path:r,fs:i,globalScope:a}=e,o=this.resolveBasePaths(t),s=this.resolveAindexPath(t.aindex.rules.src,o.aindexDir),c=this.resolveAindexPath(t.aindex.rules.dist,o.aindexDir),{prompts:l,errors:u}=await Ub(i,r,n,a).readFlatFiles(s,c,{kind:hh.Rule,localeExtensions:Ob,isDirectoryStructure:!1,createPrompt:async(e,t,n,i)=>{let a=i,o=r.join(c,`${n}.mdx`);if(a!=null){let e=ob(a,o);if(!e.valid)throw Error(e.errors.join(`
|
|
243
|
+
`))}let s=a?.globs??[],l=a?.scope??`project`,u=a?.seriName,d=n.replaceAll(`\\`,`/`),f=d.includes(`/`)?d.split(`/`)[0]??``:``,p=d.split(`/`).pop()??d,m={type:hh.Rule,content:e,length:e.length,filePathKind:gh.Relative,dir:{pathKind:gh.Relative,path:`${n}.mdx`,basePath:c,getDirectoryName:()=>p,getAbsolutePath:()=>o},prefix:f,ruleName:p,globs:s,scope:l,markdownContents:[]};return a!=null&&Object.assign(m,{yamlFrontMatter:a}),u!=null&&Object.assign(m,{seriName:u}),m}});for(let e of u)n.warn(B({code:`RULE_PROMPT_READ_FAILED`,title:`Failed to read rule prompt`,operation:e.phase===`scan`?`scan`:`read`,targetKind:`rule prompt`,path:e.path,error:e.error,details:{phase:e.phase}}));if(u.length>0)throw Error(u.map(e=>e.error instanceof Error?e.error.message:String(e.error)).join(`
|
|
244
|
+
`));return{rules:l.map(e=>e.dist?.prompt).filter(e=>e!=null)}}},CC=class extends gg{constructor(){super(`AIAgentIgnoreInputCapability`)}collect(e){let{workspaceDir:t,aindexDir:n}=this.resolveBasePaths(e.userConfigOptions),r=[];for(let i of Sh){let a=Mh(n,i,{command:e.runtimeCommand,workspaceDir:t});if(!e.fs.existsSync(a)){this.log.debug({action:`collect`,message:`Ignore file not found`,path:a});continue}let o=e.fs.readFileSync(a,`utf8`);if(o.length===0){this.log.debug({action:`collect`,message:`Ignore file is empty`,path:a});continue}r.push({fileName:i,content:o,sourcePath:a}),this.log.debug({action:`collect`,message:`Loaded ignore file`,path:a,fileName:i})}return r.length===0?{}:{aiAgentIgnoreConfigFiles:r}}},wC=class extends gg{constructor(){super(`SubAgentInputCapability`)}createSubAgentPrompt(e,t,n,r,i,a,o,s){let{fs:c,logger:l,path:u}=a,{agentPrefix:d,agentName:f,canonicalName:p}=jy(n),m=u.join(i,`${n}.mdx`),h=`${n}.mdx`,g=c.existsSync(u.join(r,`${n}.src.mdx`))?u.join(r,`${n}.src.mdx`):m,_=o==null?void 0:(()=>{let e={...o},t=e.name;return typeof t==`string`&&t.trim().length>0&&s?.has(g)!==!0&&(s?.add(g),l.warn(dt({code:`SUBAGENT_NAME_IGNORED`,title:`Sub-agent authored name is ignored`,reason:z(`tnmsc ignores the authored sub-agent name "${t}" in favor of the derived path name "${p}".`),configPath:g,exactFix:z("Remove the `name` field from the sub-agent front matter or exported metadata.",`Rename the sub-agent directory or file if you need a different sub-agent name.`),details:{authoredName:t,derivedName:p,logicalName:n}}))),delete e.name,e})(),v={type:hh.SubAgent,content:e,length:e.length,filePathKind:gh.Relative,dir:{pathKind:gh.Relative,path:h,basePath:i,getDirectoryName:()=>h.replace(/\.mdx$/,``),getAbsolutePath:()=>m},...d!=null&&{agentPrefix:d},agentName:f,canonicalName:p};if(_==null)return v;let y=ab(_,m);if(!y.valid)throw Error(y.errors.join(`
|
|
245
|
+
`));return Object.assign(v,{yamlFrontMatter:_}),_.seriName!=null&&Object.assign(v,{seriName:_.seriName}),v}async collect(e){let{userConfigOptions:t,logger:n,path:r,fs:i,globalScope:a}=e,o=this.resolveBasePaths(t),s=this.resolveAindexPath(t.aindex.subAgents.src,o.aindexDir),c=this.resolveAindexPath(t.aindex.subAgents.dist,o.aindexDir);n.debug(`SubAgentInputCapability collecting`,{srcDir:s,distDir:c,aindexDir:o.aindexDir});let l=Ub(i,r,n,a),u=new Set,{prompts:d,errors:f}=await l.readFlatFiles(s,c,{kind:hh.SubAgent,localeExtensions:Ob,isDirectoryStructure:!1,createPrompt:(t,n,r,i)=>this.createSubAgentPrompt(t,n,r,s,c,e,i,u)});n.debug(`SubAgentInputCapability read complete`,{subAgentCount:d.length,errorCount:f.length});for(let e of f)n.warn(B({code:`SUBAGENT_PROMPT_READ_FAILED`,title:`Failed to read sub-agent prompt`,operation:e.phase===`scan`?`scan`:`read`,targetKind:`sub-agent prompt`,path:e.path,error:e.error,details:{phase:e.phase}}));if(f.length>0)throw Error(f.map(e=>e.error instanceof Error?e.error.message:String(e.error)).join(`
|
|
246
|
+
`));let p=[];for(let e of d){let t=e.dist;if(t?.prompt==null)continue;let{prompt:n,rawMdx:r}=t;p.push(r==null?n:{...n,rawMdxContent:r})}return n.debug(`SubAgentInputCapability flattened subAgents`,{count:p.length,agents:p.map(e=>e.canonicalName)}),{subAgents:p}}},TC=class extends gg{constructor(){super(`VSCodeConfigInputCapability`)}collect(e){let{userConfigOptions:t,fs:n}=e,{workspaceDir:r,aindexDir:i}=this.resolveBasePaths(t),a=[`.vscode/settings.json`,`.vscode/extensions.json`],o=[];for(let t of a){let a=Ph(_h.VSCode,t,i,n,{command:e.runtimeCommand,workspaceDir:r});a!=null&&o.push(a)}return{vscodeConfigFiles:o}}},EC=class extends gg{constructor(){super(`WorkspaceInputCapability`)}collect(e){let{userConfigOptions:t}=e,{workspaceDir:n,aindexDir:r}=this.resolveBasePaths(t);return{workspace:{directory:{pathKind:gh.Absolute,path:n,getDirectoryName:()=>i.basename(n)},projects:[]},aindexDir:r}}};function DC(){return`2026.10322.104`}const OC=`tnmsc`;`
|
|
247
|
+
${OC} v${DC()} - Memory Sync CLI
|
|
243
248
|
|
|
244
249
|
Synchronize AI memory and configuration files across projects.
|
|
245
250
|
|
|
246
251
|
USAGE:
|
|
247
|
-
${
|
|
248
|
-
${
|
|
249
|
-
${
|
|
250
|
-
${
|
|
251
|
-
${
|
|
252
|
-
${
|
|
253
|
-
${
|
|
254
|
-
${
|
|
252
|
+
${OC} Run the sync pipeline (default)
|
|
253
|
+
${OC} help Show this help message
|
|
254
|
+
${OC} version Show version information
|
|
255
|
+
${OC} init Deprecated; no longer initializes aindex
|
|
256
|
+
${OC} dry-run Preview what would be written
|
|
257
|
+
${OC} clean Remove all generated files
|
|
258
|
+
${OC} clean --dry-run Preview what would be cleaned
|
|
259
|
+
${OC} config key=value Set configuration value
|
|
255
260
|
|
|
256
261
|
SUBCOMMANDS:
|
|
257
262
|
help Show this help message
|
|
@@ -262,10 +267,10 @@ SUBCOMMANDS:
|
|
|
262
267
|
config Set configuration values in global config file (~/.aindex/.tnmsc.json)
|
|
263
268
|
|
|
264
269
|
ALIASES:
|
|
265
|
-
${
|
|
266
|
-
${
|
|
267
|
-
${
|
|
268
|
-
${
|
|
270
|
+
${OC} --help, ${OC} -h Same as '${OC} help'
|
|
271
|
+
${OC} --version, ${OC} -v Same as '${OC} version'
|
|
272
|
+
${OC} clean -n Same as '${OC} clean --dry-run'
|
|
273
|
+
${OC} config key=value Set config value in global config file
|
|
269
274
|
|
|
270
275
|
LOG LEVEL OPTIONS:
|
|
271
276
|
--trace Most verbose output
|
|
@@ -291,11 +296,11 @@ CONFIG OPTIONS:
|
|
|
291
296
|
aindex.arch.src, aindex.arch.dist
|
|
292
297
|
|
|
293
298
|
Examples:
|
|
294
|
-
${
|
|
295
|
-
${
|
|
296
|
-
${
|
|
299
|
+
${OC} config workspaceDir=~/my-project
|
|
300
|
+
${OC} config aindex.skills.src=skills
|
|
301
|
+
${OC} config logLevel=debug
|
|
297
302
|
|
|
298
303
|
CONFIGURATION:
|
|
299
304
|
Configure via plugin.config.ts in your project root.
|
|
300
305
|
See documentation for detailed configuration options.
|
|
301
|
-
`.trim();const PS=new Set([`help`,`version`,`init`,`dry-run`,`clean`,`config`,`plugins`]),FS=new Map([[`--trace`,`trace`],[`--debug`,`debug`],[`--info`,`info`],[`--warn`,`warn`],[`--error`,`error`]]),IS=new Map([[`trace`,0],[`debug`,1],[`info`,2],[`warn`,3],[`error`,4]]);function LS(e){let t=[...e],n=t[0];n!=null&&RS(n)&&t.shift();let r=t[0];return r!=null&&zS(r)&&t.shift(),t}function RS(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 zS(e){return/\.(?:m?[jt]s|cjs)$/.test(e)||/[/\\]/.test(e)&&!e.startsWith(`-`)?!0:/^(?:@[\w-]+\/)?[\w-]+$/.test(e)&&!e.startsWith(`-`)}function BS(e,t){if(e==null)return t;let n=IS.get(e)??4;return(IS.get(t)??4)<n?t:e}function VS(e){let t={subcommand:void 0,helpFlag:!1,versionFlag:!1,dryRun:!1,jsonFlag:!1,showFlag:!1,logLevel:void 0,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=FS.get(a);if(o!=null){t.logLevel=BS(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,PS.has(i)?t.subcommand=i:t.unknownCommand=i;continue}t.positional.push(i)}}return t}const HS={workspace:{strategy:`mergeProjects`,getter:e=>e.workspace},vscodeConfigFiles:{strategy:`concat`,getter:e=>e.vscodeConfigFiles},jetbrainsConfigFiles:{strategy:`concat`,getter:e=>e.jetbrainsConfigFiles},editorConfigFiles:{strategy:`concat`,getter:e=>e.editorConfigFiles},commands:{strategy:`concat`,getter:e=>e.commands},subAgents:{strategy:`concat`,getter:e=>e.subAgents},skills:{strategy:`concat`,getter:e=>e.skills},rules:{strategy:`concat`,getter:e=>e.rules},aiAgentIgnoreConfigFiles:{strategy:`concat`,getter:e=>e.aiAgentIgnoreConfigFiles},readmePrompts:{strategy:`concat`,getter:e=>e.readmePrompts},globalMemory:{strategy:`override`,getter:e=>e.globalMemory},aindexDir:{strategy:`override`,getter:e=>e.aindexDir},globalGitIgnore:{strategy:`override`,getter:e=>e.globalGitIgnore},shadowGitExclude:{strategy:`override`,getter:e=>e.shadowGitExclude}};function US(e,t){return t==null?e??[]:e==null?t:[...e,...t]}function WS(e,t){let n=new Map;for(let t of e.projects)n.set(t.name,t);for(let e of t.projects)n.set(e.name,e);return{directory:t.directory??e.directory,projects:[...n.values()]}}function GS(e,t){return t==null?e:e==null?t:WS(e,t)}function KS(e,t,n){switch(n){case`concat`:return US(e,t);case`override`:return t??e;case`mergeProjects`:return GS(e,t);default:return t??e}}function qS(e,t){let n={};for(let[r,i]of Object.entries(HS)){let a=KS(i.getter(e),i.getter(t),i.strategy);a!=null&&(n[r]=a)}return n}function JS(e,t,n){let r=e.dependsOn??[];if(r.length===0)return{};let i=new Set,a={};for(let e of r){if(i.has(e))continue;i.add(e);let r=t.get(e);r!=null&&(a=n(a,r))}return a}function YS(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]}function XS(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 Oy(n.name,r)}let n=new Map;for(let t of e)n.set(t.name,t);let r=new Map;for(let t of e)r.set(t.name,0);let i=new Map;for(let t of e)i.set(t.name,[]);for(let t of e){let e=t.dependsOn??[];for(let n of e){r.set(t.name,(r.get(t.name)??0)+1);let e=i.get(n)??[];e.push(t.name),i.set(n,e)}}let a=[];for(let t of e)r.get(t.name)===0&&a.push(t.name);let o=[],s=new Map;for(let t=0;t<e.length;t++){let n=e[t];n!=null&&s.set(n.name,t)}for(;a.length>0;){let e=a.shift(),t=n.get(e);o.push(t);let c=(i.get(e)??[]).sort((e,t)=>(s.get(e)??-1)-(s.get(t)??-1));for(let e of c){let t=(r.get(e)??0)-1;r.set(e,t),t===0&&a.push(e)}}if(o.length===e.length)return o;throw new ky(YS(e,r))}function ZS(){return[new Jx,new qx,new Gx]}function QS(){return[new jS,new hS,new AS,new xS,new _S,new mS,new gS,new kS,new DS,new bS,new wS,new ES,new yS,new vS,new OS]}function $S(e){if(e==null||e.length===0)return`execute`;let t=VS(LS(e.filter(e=>e!=null)));if(!(t.helpFlag||t.versionFlag||t.unknownCommand!=null)){if(t.subcommand===`clean`)return`clean`;if(t.subcommand===`plugins`)return`plugins`;if(t.subcommand===`dry-run`||t.dryRun)return`dry-run`;if(t.subcommand==null)return`execute`}}async function eC(e){let{pipelineArgs:t,userConfigOptions:r,userConfig:a,capabilities:o,includeBuiltinEffects:s=!0}=e,c=Ut(`InputRuntime`,r.logLevel),l=$S(t),u={logger:c,userConfigOptions:r,fs:n,path:i,glob:it.default},d=XS([...s?ZS():[],...o??QS()]),f=new Vv({userConfig:a}).collect(),p=new Uv;p.setGlobalScope(f),c.debug(`global scope collected`,{osInfo:{platform:f.os.platform,arch:f.os.arch,shellKind:f.os.shellKind},hasProfile:Object.keys(f.profile).length>0,hasTool:Object.keys(f.tool).length>0});let m=new Map,h={};for(let e of d){let t=JS(e,m,qS),n={...u,dependencyContext:t,...l==null?{}:{runtimeCommand:l},globalScope:f,scopeRegistry:p},r=e;r.executeEffects!=null&&await r.executeEffects(n,!1);let i=await e.collect(n);m.set(e.name,i),h=qS(h,i);let a=e;if(a.getRegisteredScopes!=null){let t=a.getRegisteredScopes();for(let{namespace:n,values:r}of t)p.register(n,r,Hv.PluginRegistered),c.debug(`input capability scope registered`,{capability:e.name,namespace:n,keys:Object.keys(r)})}}return h}function tC(e){return`declarativeOutput`in e}function nC(e){return`collect`in e&&!tC(e)}const rC={version:`0.0.0`,workspaceDir:`~/project`,logLevel:`info`,aindex:{dir:`aindex`,skills:{src:`skills`,dist:`dist/skills`},commands:{src:`commands`,dist:`dist/commands`},subAgents:{src:`subagents`,dist:`dist/subagents`},rules:{src:`rules`,dist:`dist/rules`},globalPrompt:{src:`app/global.src.mdx`,dist:`dist/global.mdx`},workspacePrompt:{src:`app/workspace.src.mdx`,dist:`dist/workspace.mdx`},app:{src:`app`,dist:`dist/app`},ext:{src:`ext`,dist:`dist/ext`},arch:{src:`arch`,dist:`dist/arch`}},commandSeriesOptions:{},outputScopes:{},frontMatter:{blankLineAfter:!0},cleanupProtection:{},plugins:[]};function iC(e){return{...e.version==null?{}:{version:e.version},...e.workspaceDir==null?{}:{workspaceDir:e.workspaceDir},...e.aindex==null?{}:{aindex:e.aindex},...e.commandSeriesOptions==null?{}:{commandSeriesOptions:e.commandSeriesOptions},...e.outputScopes==null?{}:{outputScopes:e.outputScopes},...e.frontMatter==null?{}:{frontMatter:e.frontMatter},...e.cleanupProtection==null?{}:{cleanupProtection:e.cleanupProtection},...e.logLevel==null?{}:{logLevel:e.logLevel}}}function aC(...e){return e.reduce((e,t)=>oC(e,t),{...rC})}function oC(e,t){let n=t.plugins,r=t.commandSeriesOptions,i=t.outputScopes,a=t.frontMatter,o=t.cleanupProtection;return{...e,...t,aindex:sC(e.aindex,t.aindex),plugins:[...e.plugins,...n??[]],commandSeriesOptions:cC(e.commandSeriesOptions,r),outputScopes:uC(e.outputScopes,i),frontMatter:dC(e.frontMatter,a),cleanupProtection:fC(e.cleanupProtection,o)}}function sC(e,t){return t==null?e:{dir:t.dir??e.dir,skills:{...e.skills,...t.skills},commands:{...e.commands,...t.commands},subAgents:{...e.subAgents,...t.subAgents},rules:{...e.rules,...t.rules},globalPrompt:{...e.globalPrompt,...t.globalPrompt},workspacePrompt:{...e.workspacePrompt,...t.workspacePrompt},app:{...e.app,...t.app},ext:{...e.ext,...t.ext},arch:{...e.arch,...t.arch}}}function cC(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 lC(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{...e,...t}}function uC(e,t){if(t==null)return e??{};if(e==null)return t;let n={};if(e.plugins!=null)for(let[t,r]of Object.entries(e.plugins))r!=null&&(n[t]={...r});if(t.plugins!=null)for(let[e,r]of Object.entries(t.plugins)){let t=lC(n[e],r);t!=null&&(n[e]=t)}return Object.keys(n).length===0?{}:{plugins:n}}function dC(e,t){return t==null?e:{...e,...t}}function fC(e,t){return t==null?e??{}:e==null?t:{rules:[...e.rules??[],...t.rules??[]]}}function pC(e){return`pluginOptions`in e||`configLoaderOptions`in e||`loadUserConfig`in e||`cwd`in e||`pipelineArgs`in e}async function mC(e={}){let t,n,r,i,a;pC(e)?({pluginOptions:r={},cwd:n,configLoaderOptions:i,pipelineArgs:a}={pluginOptions:e.pluginOptions,cwd:e.cwd,configLoaderOptions:e.configLoaderOptions,pipelineArgs:e.pipelineArgs},t=e.loadUserConfig??!0):(r=e,t=!0,i=void 0,a=void 0);let o=Object.hasOwn(r,`plugins`),s=r.plugins,c={},l=!1,u=[],d;if(t)try{let e=Wx(i).load(n);l=e.found,u=e.sources,e.found&&(c=iC(e.config),d=e.config)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to load user config: ${t}`)}let f=aC(c,r),{plugins:p=[],logLevel:m}=f,h=Ut(`defineConfig`,m);l?h.info(`user config loaded`,{sources:u}):h.info(`no user config found, using defaults/programmatic options`,{workspaceDir:f.workspaceDir,aindexDir:f.aindex.dir,logLevel:f.logLevel});let g=p.filter(tC),_=p.filter(nC);Ty(g,f);let v=await eC({userConfigOptions:f,..._.length>0?{capabilities:_}:{},includeBuiltinEffects:!(_.length>0||o&&(s?.length??0)===0),...a==null?{}:{pipelineArgs:a},...d==null?{}:{userConfig:d}});if(v.workspace==null)throw Error(`Workspace not initialized by any plugin`);let y=_y({workspace:v.workspace,...v.vscodeConfigFiles!=null&&{vscodeConfigFiles:v.vscodeConfigFiles},...v.jetbrainsConfigFiles!=null&&{jetbrainsConfigFiles:v.jetbrainsConfigFiles},...v.editorConfigFiles!=null&&{editorConfigFiles:v.editorConfigFiles},...v.commands!=null&&{commands:v.commands},...v.subAgents!=null&&{subAgents:v.subAgents},...v.skills!=null&&{skills:v.skills},...v.rules!=null&&{rules:v.rules},...v.globalMemory!=null&&{globalMemory:v.globalMemory},...v.aiAgentIgnoreConfigFiles!=null&&{aiAgentIgnoreConfigFiles:v.aiAgentIgnoreConfigFiles},...v.aindexDir!=null&&{aindexDir:v.aindexDir},...v.readmePrompts!=null&&{readmePrompts:v.readmePrompts},...v.globalGitIgnore!=null&&{globalGitIgnore:v.globalGitIgnore},...v.shadowGitExclude!=null&&{shadowGitExclude:v.shadowGitExclude}});return v.aindexDir!=null&&Bx(v.aindexDir,h),{context:y,outputPlugins:g,userConfigOptions:f}}const hC=`GLOBAL.md`;var gC=class extends Ay{constructor(){super(`TraeCNIDEOutputPlugin`,{globalConfigDir:`.trae-cn`,outputFileName:hC,dependsOn:[`TraeIDEOutputPlugin`],cleanup:{delete:{global:{dirs:[`.trae-cn/user_rules`]}}},capabilities:{prompt:{scopes:[`global`],singleScope:!1}}})}getGlobalUserRulesDir(){return this.joinPath(this.getGlobalConfigDir(),`user_rules`)}async declareOutputFiles(e){if(!new Set(this.selectPromptScopes(e,[`global`])).has(`global`))return[];let{globalMemory:t}=e.collectedOutputContext;return t==null?[]:[{path:this.joinPath(this.getGlobalUserRulesDir(),hC),scope:`global`,source:{content:t.content}}]}async convertContent(e,t){let n=e.source;if(n.content==null)throw Error(`Unsupported declaration source for ${this.name}`);return n.content}};async function _C(e=t.argv){return mC({pipelineArgs:e,pluginOptions:{plugins:[new Fb,new Lb,new lx,new ix,new Jb,new Qb,new Nb,new hx,new Sx,new kx,new gC,new Nx,new zx,new Kb,new $b,new ox,new Xb,new jx,new wx]}})}function vC(e){let t=e.slice(2),n=`execute`,r=!1,i=!1;for(let e of t)e===`--json`||e===`-j`?r=!0:e===`--dry-run`||e===`-n`?i=!0:e.startsWith(`-`)||(n=e);return{subcommand:n,json:r,dryRun:i}}function yC(e,t){switch(e){case`execute`:return new Cb;case`dry-run`:return new Sb;case`clean`:return t?new xb:new bb;case`plugins`:return new Eb;default:return new Cb}}async function bC(){let{subcommand:e,json:n,dryRun:r}=vC(t.argv);n&&H(`silent`);let i=await _C(t.argv),a=yC(e,r);n&&(new Set([`plugins`]).has(a.name)||(a=new wb(a)));let{context:o,outputPlugins:s,userConfigOptions:c}=i,l=Ut(`PluginRuntime`),u=Ab(l),d=e=>({logger:l,collectedOutputContext:o,pluginOptions:c,runtimeTargets:u,dryRun:e}),f=e=>({logger:l,collectedOutputContext:o,pluginOptions:c,runtimeTargets:u,dryRun:e,registeredPluginNames:[...s].map(e=>e.name)}),p={logger:l,outputPlugins:[...s],collectedOutputContext:o,userConfigOptions:c,createCleanContext:d,createWriteContext:f};(await a.execute(p)).success||t.exit(1)}function xC(e){let n=e instanceof Error?e.message:String(e);Ut(`plugin-runtime`,`silent`).error(gt(`plugin-runtime`,e)),t.stdout.write(`${JSON.stringify(Tb({success:!1,filesAffected:0,dirsAffected:0,message:n},Ht()))}\n`)}bC().catch(e=>{let{json:n}=vC(t.argv);n&&(xC(e),t.exit(1)),Ut(`plugin-runtime`,`error`).error(gt(`plugin-runtime`,e)),t.exit(1)});export{};
|
|
306
|
+
`.trim();const kC=new Set([`help`,`version`,`init`,`dry-run`,`clean`,`config`,`plugins`]),AC=new Map([[`--trace`,`trace`],[`--debug`,`debug`],[`--info`,`info`],[`--warn`,`warn`],[`--error`,`error`]]),jC=new Map([[`trace`,0],[`debug`,1],[`info`,2],[`warn`,3],[`error`,4]]);function MC(e){let t=[...e],n=t[0];n!=null&&NC(n)&&t.shift();let r=t[0];return r!=null&&PC(r)&&t.shift(),t}function NC(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 PC(e){return/\.(?:m?[jt]s|cjs)$/.test(e)||/[/\\]/.test(e)&&!e.startsWith(`-`)?!0:/^(?:@[\w-]+\/)?[\w-]+$/.test(e)&&!e.startsWith(`-`)}function FC(e,t){if(e==null)return t;let n=jC.get(e)??4;return(jC.get(t)??4)<n?t:e}function IC(e){let t={subcommand:void 0,helpFlag:!1,versionFlag:!1,dryRun:!1,jsonFlag:!1,showFlag:!1,logLevel:void 0,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=AC.get(a);if(o!=null){t.logLevel=FC(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,kC.has(i)?t.subcommand=i:t.unknownCommand=i;continue}t.positional.push(i)}}return t}const LC={workspace:{strategy:`mergeProjects`,getter:e=>e.workspace},vscodeConfigFiles:{strategy:`concat`,getter:e=>e.vscodeConfigFiles},jetbrainsConfigFiles:{strategy:`concat`,getter:e=>e.jetbrainsConfigFiles},editorConfigFiles:{strategy:`concat`,getter:e=>e.editorConfigFiles},commands:{strategy:`concat`,getter:e=>e.commands},subAgents:{strategy:`concat`,getter:e=>e.subAgents},skills:{strategy:`concat`,getter:e=>e.skills},rules:{strategy:`concat`,getter:e=>e.rules},aiAgentIgnoreConfigFiles:{strategy:`concat`,getter:e=>e.aiAgentIgnoreConfigFiles},readmePrompts:{strategy:`concat`,getter:e=>e.readmePrompts},globalMemory:{strategy:`override`,getter:e=>e.globalMemory},aindexDir:{strategy:`override`,getter:e=>e.aindexDir},globalGitIgnore:{strategy:`override`,getter:e=>e.globalGitIgnore},shadowGitExclude:{strategy:`override`,getter:e=>e.shadowGitExclude}};function RC(e,t){return t==null?e??[]:e==null?t:[...e,...t]}function zC(e,t){let n=new Map;for(let t of e.projects)n.set(t.name,t);for(let e of t.projects)n.set(e.name,e);return{directory:t.directory??e.directory,projects:[...n.values()]}}function BC(e,t){return t==null?e:e==null?t:zC(e,t)}function VC(e,t,n){switch(n){case`concat`:return RC(e,t);case`override`:return t??e;case`mergeProjects`:return BC(e,t);default:return t??e}}function HC(e,t){let n={};for(let[r,i]of Object.entries(LC)){let a=VC(i.getter(e),i.getter(t),i.strategy);a!=null&&(n[r]=a)}return n}function UC(e,t,n){let r=e.dependsOn??[];if(r.length===0)return{};let i=new Set,a={};for(let e of r){if(i.has(e))continue;i.add(e);let r=t.get(e);r!=null&&(a=n(a,r))}return a}function WC(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.at(-1);if(e==null)return[...n];let t=a.indexOf(e);return a.slice(t)}i.clear(),a.length=0}return[...n]}function GC(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 yb(n.name,r)}let n=new Map;for(let t of e)n.set(t.name,t);let r=new Map;for(let t of e)r.set(t.name,0);let i=new Map;for(let t of e)i.set(t.name,[]);for(let t of e){let e=t.dependsOn??[];for(let n of e){r.set(t.name,(r.get(t.name)??0)+1);let e=i.get(n)??[];e.push(t.name),i.set(n,e)}}let a=[];for(let t of e)r.get(t.name)===0&&a.push(t.name);let o=[],s=new Map;for(let t=0;t<e.length;t++){let n=e[t];n!=null&&s.set(n.name,t)}for(;a.length>0;){let e=a.shift();if(e==null)continue;let t=n.get(e);if(t==null)continue;o.push(t);let c=(i.get(e)??[]).sort((e,t)=>(s.get(e)??-1)-(s.get(t)??-1));for(let e of c){let t=(r.get(e)??0)-1;r.set(e,t),t===0&&a.push(e)}}if(o.length===e.length)return o;throw new bb(WC(e,r))}function KC(){return[new HS,new VS,new zS]}function qC(){return[new EC,new uC,new TC,new gC,new fC,new lC,new dC,new wC,new SC,new hC,new yC,new xC,new mC,new pC,new CC]}function JC(e){if(e==null||e.length===0)return`execute`;let t=IC(MC(e.filter(e=>e!=null)));if(!(t.helpFlag||t.versionFlag||t.unknownCommand!=null)){if(t.subcommand===`clean`)return`clean`;if(t.subcommand===`plugins`)return`plugins`;if(t.subcommand===`dry-run`||t.dryRun)return`dry-run`;if(t.subcommand==null)return`execute`}}async function YC(e){let{pipelineArgs:t,userConfigOptions:r,userConfig:a,capabilities:o,includeBuiltinEffects:s=!0}=e,c=Ut(`InputRuntime`,r.logLevel),l=JC(t),u={logger:c,userConfigOptions:r,fs:n,path:i,glob:it.default},d=GC([...s?KC():[],...o??qC()]),f=new Ey({userConfig:a}).collect(),p=new Oy;p.setGlobalScope(f),c.debug(`global scope collected`,{osInfo:{platform:f.os.platform,arch:f.os.arch,shellKind:f.os.shellKind},hasProfile:Object.keys(f.profile).length>0,hasTool:Object.keys(f.tool).length>0});let m=new Map,h={};for(let e of d){let t=UC(e,m,HC),n={...u,dependencyContext:t,...l==null?{}:{runtimeCommand:l},globalScope:f,scopeRegistry:p},r=e;r.executeEffects!=null&&await r.executeEffects(n,!1);let i=await e.collect(n);m.set(e.name,i),h=HC(h,i);let a=e;if(a.getRegisteredScopes!=null){let t=a.getRegisteredScopes();for(let{namespace:n,values:r}of t)p.register(n,r,Dy.PluginRegistered),c.debug(`input capability scope registered`,{capability:e.name,namespace:n,keys:Object.keys(r)})}}return h}function XC(e){return`declarativeOutput`in e}function ZC(e){return`collect`in e&&!XC(e)}const QC={version:`0.0.0`,workspaceDir:`~/project`,logLevel:`info`,aindex:{dir:`aindex`,skills:{src:`skills`,dist:`dist/skills`},commands:{src:`commands`,dist:`dist/commands`},subAgents:{src:`subagents`,dist:`dist/subagents`},rules:{src:`rules`,dist:`dist/rules`},globalPrompt:{src:`app/global.src.mdx`,dist:`dist/global.mdx`},workspacePrompt:{src:`app/workspace.src.mdx`,dist:`dist/workspace.mdx`},app:{src:`app`,dist:`dist/app`},ext:{src:`ext`,dist:`dist/ext`},arch:{src:`arch`,dist:`dist/arch`}},commandSeriesOptions:{},outputScopes:{},frontMatter:{blankLineAfter:!0},cleanupProtection:{},plugins:[]};function $C(e){return{...e.version==null?{}:{version:e.version},...e.workspaceDir==null?{}:{workspaceDir:e.workspaceDir},...e.aindex==null?{}:{aindex:e.aindex},...e.commandSeriesOptions==null?{}:{commandSeriesOptions:e.commandSeriesOptions},...e.outputScopes==null?{}:{outputScopes:e.outputScopes},...e.frontMatter==null?{}:{frontMatter:e.frontMatter},...e.cleanupProtection==null?{}:{cleanupProtection:e.cleanupProtection},...e.logLevel==null?{}:{logLevel:e.logLevel}}}function ew(...e){return e.reduce((e,t)=>tw(e,t),{...QC})}function tw(e,t){let n=t.plugins,r=t.commandSeriesOptions,i=t.outputScopes,a=t.frontMatter,o=t.cleanupProtection;return{...e,...t,aindex:nw(e.aindex,t.aindex),plugins:[...e.plugins,...n??[]],commandSeriesOptions:rw(e.commandSeriesOptions,r),outputScopes:aw(e.outputScopes,i),frontMatter:ow(e.frontMatter,a),cleanupProtection:sw(e.cleanupProtection,o)}}function nw(e,t){return t==null?e:{dir:t.dir??e.dir,skills:{...e.skills,...t.skills},commands:{...e.commands,...t.commands},subAgents:{...e.subAgents,...t.subAgents},rules:{...e.rules,...t.rules},globalPrompt:{...e.globalPrompt,...t.globalPrompt},workspacePrompt:{...e.workspacePrompt,...t.workspacePrompt},app:{...e.app,...t.app},ext:{...e.ext,...t.ext},arch:{...e.arch,...t.arch}}}function rw(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 iw(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{...e,...t}}function aw(e,t){if(t==null)return e??{};if(e==null)return t;let n={};if(e.plugins!=null)for(let[t,r]of Object.entries(e.plugins))r!=null&&(n[t]={...r});if(t.plugins!=null)for(let[e,r]of Object.entries(t.plugins)){let t=iw(n[e],r);t!=null&&(n[e]=t)}return Object.keys(n).length===0?{}:{plugins:n}}function ow(e,t){return t==null?e:{...e,...t}}function sw(e,t){return t==null?e??{}:e==null?t:{rules:[...e.rules??[],...t.rules??[]]}}function cw(e){return`pluginOptions`in e||`configLoaderOptions`in e||`loadUserConfig`in e||`cwd`in e||`pipelineArgs`in e}async function lw(e={}){let t,n,r,i,a;cw(e)?({pluginOptions:r={},cwd:n,configLoaderOptions:i,pipelineArgs:a}={pluginOptions:e.pluginOptions,cwd:e.cwd,configLoaderOptions:e.configLoaderOptions,pipelineArgs:e.pipelineArgs},t=e.loadUserConfig??!0):(r=e,t=!0,i=void 0,a=void 0);let o=Object.hasOwn(r,`plugins`),s=r.plugins,c={},l=!1,u=[],d;if(t)try{let e=RS(i).load(n);l=e.found,u=e.sources,e.found&&(c=$C(e.config),d=e.config)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to load user config: ${t}`)}let f=ew(c,r),{plugins:p=[],logLevel:m}=f,h=Ut(`defineConfig`,m);l?h.info(`user config loaded`,{sources:u}):h.info(`no user config found, using defaults/programmatic options`,{workspaceDir:f.workspaceDir,aindexDir:f.aindex.dir,logLevel:f.logLevel});let g=p.filter(XC),_=p.filter(ZC);hb(g,f);let v=await YC({userConfigOptions:f,..._.length>0?{capabilities:_}:{},includeBuiltinEffects:!(_.length>0||o&&(s?.length??0)===0),...a==null?{}:{pipelineArgs:a},...d==null?{}:{userConfig:d}});if(v.workspace==null)throw Error(`Workspace not initialized by any plugin`);let y=sb({workspace:v.workspace,...v.vscodeConfigFiles!=null&&{vscodeConfigFiles:v.vscodeConfigFiles},...v.jetbrainsConfigFiles!=null&&{jetbrainsConfigFiles:v.jetbrainsConfigFiles},...v.editorConfigFiles!=null&&{editorConfigFiles:v.editorConfigFiles},...v.commands!=null&&{commands:v.commands},...v.subAgents!=null&&{subAgents:v.subAgents},...v.skills!=null&&{skills:v.skills},...v.rules!=null&&{rules:v.rules},...v.globalMemory!=null&&{globalMemory:v.globalMemory},...v.aiAgentIgnoreConfigFiles!=null&&{aiAgentIgnoreConfigFiles:v.aiAgentIgnoreConfigFiles},...v.aindexDir!=null&&{aindexDir:v.aindexDir},...v.readmePrompts!=null&&{readmePrompts:v.readmePrompts},...v.globalGitIgnore!=null&&{globalGitIgnore:v.globalGitIgnore},...v.shadowGitExclude!=null&&{shadowGitExclude:v.shadowGitExclude}});return v.aindexDir!=null&&PS(v.aindexDir,h),{context:y,outputPlugins:g,userConfigOptions:f}}const uw=`GLOBAL.md`;var dw=class extends xb{constructor(){super(`TraeCNIDEOutputPlugin`,{globalConfigDir:`.trae-cn`,outputFileName:uw,dependsOn:[`TraeIDEOutputPlugin`],cleanup:{delete:{global:{dirs:[`.trae-cn/user_rules`]}}},capabilities:{prompt:{scopes:[`global`],singleScope:!1}}})}getGlobalUserRulesDir(){return this.joinPath(this.getGlobalConfigDir(),`user_rules`)}async declareOutputFiles(e){if(!new Set(this.selectPromptScopes(e,[`global`])).has(`global`))return[];let{globalMemory:t}=e.collectedOutputContext;return t==null?[]:[{path:this.joinPath(this.getGlobalUserRulesDir(),uw),scope:`global`,source:{content:t.content}}]}async convertContent(e,t){let n=e.source;if(n.content==null)throw Error(`Unsupported declaration source for ${this.name}`);return n.content}};async function fw(e=t.argv){return lw({pipelineArgs:e,pluginOptions:{plugins:[new Dx,new kx,new rS,new Xx,new Bx,new Wx,new Tx,new lS,new gS,new CS,new dw,new DS,new NS,new Rx,new Gx,new Qx,new Hx,new TS,new vS]}})}function pw(e){let t=e.slice(2),n=`execute`,r=!1,i=!1;for(let e of t)e===`--json`||e===`-j`?r=!0:e===`--dry-run`||e===`-n`?i=!0:e.startsWith(`-`)||(n=e);return{subcommand:n,json:r,dryRun:i}}function mw(e,t){switch(e){case`execute`:return new hx;case`dry-run`:return new mx;case`clean`:return t?new px:new fx;case`plugins`:return new vx;default:return new hx}}async function hw(){let{subcommand:e,json:n,dryRun:r}=pw(t.argv);n&&H(`silent`);let i=await fw(t.argv),a=mw(e,r);n&&(new Set([`plugins`]).has(a.name)||(a=new gx(a)));let{context:o,outputPlugins:s,userConfigOptions:c}=i,l=Ut(`PluginRuntime`),u=Sx(l),d=e=>({logger:l,collectedOutputContext:o,pluginOptions:c,runtimeTargets:u,dryRun:e}),f=e=>({logger:l,collectedOutputContext:o,pluginOptions:c,runtimeTargets:u,dryRun:e,registeredPluginNames:Array.from(s,e=>e.name)}),p={logger:l,outputPlugins:[...s],collectedOutputContext:o,userConfigOptions:c,createCleanContext:d,createWriteContext:f};(await a.execute(p)).success||t.exit(1)}function gw(e){let n=e instanceof Error?e.message:String(e);Ut(`plugin-runtime`,`silent`).error(gt(`plugin-runtime`,e)),t.stdout.write(`${JSON.stringify(_x({success:!1,filesAffected:0,dirsAffected:0,message:n},Ht()))}\n`)}hw().catch(e=>{let{json:n}=pw(t.argv);n&&(gw(e),t.exit(1)),Ut(`plugin-runtime`,`error`).error(gt(`plugin-runtime`,e)),t.exit(1)});export{};
|