@truenine/memory-sync-cli 2026.10106.107 → 2026.10107.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/globals/index.d.mts
CHANGED
|
@@ -112,20 +112,69 @@ interface OsInfo {
|
|
|
112
112
|
kind?: OsKind;
|
|
113
113
|
[key: string]: string | ShellKind | OsKind | undefined;
|
|
114
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Md component props - wrapper for conditional Markdown content
|
|
117
|
+
* @example <Md when={os.kind === 'mac'}>macOS specific content</Md>
|
|
118
|
+
*/
|
|
119
|
+
interface MdProps {
|
|
120
|
+
/** Condition for rendering content. If omitted, content always renders. */
|
|
121
|
+
when?: boolean;
|
|
122
|
+
/** Child content to render when condition is met */
|
|
123
|
+
children?: unknown;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Md.Line component props - inline conditional text
|
|
127
|
+
* @example <Md.Line when={os.kind === 'win'}>PowerShell</Md.Line>
|
|
128
|
+
*/
|
|
129
|
+
interface MdLineProps {
|
|
130
|
+
/** Condition for rendering content. If omitted, content always renders. */
|
|
131
|
+
when?: boolean;
|
|
132
|
+
/** Inline text content to render when condition is met */
|
|
133
|
+
children?: unknown;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Md component type with Line sub-component
|
|
137
|
+
*/
|
|
138
|
+
interface MdComponent {
|
|
139
|
+
/**
|
|
140
|
+
* Block-level conditional Markdown wrapper
|
|
141
|
+
* @param props - Component props including optional `when` condition
|
|
142
|
+
* @returns Rendered content or nothing if condition is false
|
|
143
|
+
*/
|
|
144
|
+
(props: MdProps): unknown;
|
|
145
|
+
/**
|
|
146
|
+
* Inline conditional text component
|
|
147
|
+
* @param props - Component props including optional `when` condition
|
|
148
|
+
* @returns Inline text or nothing if condition is false
|
|
149
|
+
*/
|
|
150
|
+
Line: (props: MdLineProps) => unknown;
|
|
151
|
+
}
|
|
115
152
|
/**
|
|
116
153
|
* Global scope available in MDX expressions
|
|
117
154
|
*/
|
|
118
155
|
interface MdxGlobalScope {
|
|
156
|
+
/** User profile information */
|
|
119
157
|
profile: UserProfile;
|
|
158
|
+
/** Tool name references for AI assistants */
|
|
120
159
|
tool: ToolReferences;
|
|
160
|
+
/** Environment variables context */
|
|
121
161
|
env: EnvironmentContext;
|
|
162
|
+
/** Operating system information */
|
|
122
163
|
os: OsInfo;
|
|
164
|
+
/** Conditional Markdown component with Line sub-component */
|
|
165
|
+
Md: MdComponent;
|
|
123
166
|
}
|
|
124
167
|
declare global {
|
|
168
|
+
/** User profile information */
|
|
125
169
|
const profile: UserProfile;
|
|
170
|
+
/** Tool name references for AI assistants */
|
|
126
171
|
const tool: ToolReferences;
|
|
172
|
+
/** Environment variables context */
|
|
127
173
|
const env: EnvironmentContext;
|
|
174
|
+
/** Operating system information */
|
|
128
175
|
const os: OsInfo;
|
|
176
|
+
/** Conditional Markdown component with Line sub-component */
|
|
177
|
+
const Md: MdComponent;
|
|
129
178
|
}
|
|
130
179
|
//#endregion
|
|
131
|
-
export { EnvironmentContext, MdxGlobalScope, OsInfo, OsKind, ShellKind, ToolPresets, ToolReferences, UserProfile };
|
|
180
|
+
export { EnvironmentContext, MdComponent, MdLineProps, MdProps, MdxGlobalScope, OsInfo, OsKind, ShellKind, ToolPresets, ToolReferences, UserProfile };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./transformer-
|
|
1
|
+
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./transformer--AYrc-x_.mjs";import{createRequire as f}from"node:module";import p,{default as m}from"node:process";import*as h from"node:fs";import*as g from"node:path";import _ from"node:path";import*as v from"node:os";import y from"picocolors";import{fileURLToPath as b}from"node:url";import{spawn as x}from"node:child_process";import S from"remark-stringify";import C from"remark-mdx";import{Buffer as w}from"node:buffer";import{createHash as T}from"node:crypto";var E=Object.create,D=Object.defineProperty,O=Object.getOwnPropertyDescriptor,k=Object.getOwnPropertyNames,A=Object.getPrototypeOf,ee=Object.prototype.hasOwnProperty,j=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),te=(e,t)=>{let n={};for(var r in e)D(n,r,{get:e[r],enumerable:!0});return t&&D(n,Symbol.toStringTag,{value:`Module`}),n},ne=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=k(t),a=0,o=i.length,s;a<o;a++)s=i[a],!ee.call(e,s)&&s!==n&&D(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=O(t,s))||r.enumerable});return e},re=(e,t,n)=>(n=e==null?{}:E(A(e)),ne(t||!e||!e.__esModule?D(n,`default`,{value:e,enumerable:!0}):n,e)),M=f(import.meta.url),ie=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.splitWhen=e.flatten=void 0;function t(e){return e.reduce((e,t)=>[].concat(e,t),[])}e.flatten=t;function n(e,t){let n=[[]],r=0;for(let i of e)t(i)?(r++,n[r]=[]):n[r].push(i);return n}e.splitWhen=n})),ae=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isEnoentCodeError=void 0;function t(e){return e.code===`ENOENT`}e.isEnoentCodeError=t})),oe=j((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})),se=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.convertPosixPathToPattern=e.convertWindowsPathToPattern=e.convertPathToPattern=e.escapePosixPath=e.escapeWindowsPath=e.escape=e.removeLeadingDotSegment=e.makeAbsolute=e.unixify=void 0;let t=M(`os`),n=M(`path`),r=t.platform()===`win32`,i=/(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g,a=/(\\?)([()[\]{}]|^!|[!+@](?=\())/g,o=/^\\\\([.?])/,s=/\\(?![!()+@[\]{}])/g;function c(e){return e.replace(/\\/g,`/`)}e.unixify=c;function l(e,t){return n.resolve(e,t)}e.makeAbsolute=l;function u(e){if(e.charAt(0)===`.`){let t=e.charAt(1);if(t===`/`||t===`\\`)return e.slice(2)}return e}e.removeLeadingDotSegment=u,e.escape=r?d:f;function d(e){return e.replace(a,`\\$2`)}e.escapeWindowsPath=d;function f(e){return e.replace(i,`\\$2`)}e.escapePosixPath=f,e.convertPathToPattern=r?p:m;function p(e){return d(e).replace(o,`//$1`).replace(s,`/`)}e.convertWindowsPathToPattern=p;function m(e){return f(e)}e.convertPosixPathToPattern=m})),ce=j(((e,t)=>{
|
|
2
2
|
/*!
|
|
3
3
|
* is-extglob <https://github.com/jonschlinkert/is-extglob>
|
|
4
4
|
*
|
|
@@ -17,7 +17,7 @@ var n=ce(),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))})),Pe=j(((e,t)=>{
|
|
19
19
|
/*! run-parallel. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
20
|
-
t.exports=r;let n=Ne();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}})),Fe=j((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})),Ie=j((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})),Le=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fs=void 0,e.fs=Ie()})),Re=j((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})),ze=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.readdir=e.readdirWithFileTypes=e.read=void 0;let t=Me(),n=Pe(),r=Fe(),i=Le(),a=Re();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)}})),Be=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.readdir=e.readdirWithFileTypes=e.read=void 0;let t=Me(),n=Fe(),r=Le(),i=Re();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})),Ve=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createFileSystemAdapter=e.FILE_SYSTEM_ADAPTER=void 0;let t=M(`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})),He=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(`path`),n=Me(),r=Ve();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}}})),Ue=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.scandirSync=e.scandir=void 0;let t=ze(),n=Be(),r=He();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)}})),We=j(((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})),Ge=j(((e,t)=>{var n=We();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})),Ke=j((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})),qe=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ke();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._root=t.replacePathSegmentSeparator(e,n.pathSegmentSeparator)}}})),Je=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(`events`),n=Ue(),r=Ge(),i=Ke(),a=qe();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)}}})),Ye=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Je();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)}})),Xe=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(`stream`),n=Je();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}}})),Ze=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ue(),n=Ke(),r=qe();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)}}})),Qe=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ze();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()}}})),$e=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(`path`),n=Ue();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}}})),et=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.walkStream=e.walkSync=e.walk=void 0;let t=Ye(),n=Xe(),r=Qe(),i=$e();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)}})),tt=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(`path`),n=Me(),r=Ee();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}}})),nt=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(`stream`),n=Me(),r=et(),i=tt();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))})}}})),rt=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=et(),n=tt(),r=nt();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))})}}})),it=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ee();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))}}})),at=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=it();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}}})),ot=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ee(),n=at();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)}}})),st=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ee();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}}})),ct=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ee();e.default=class{constructor(e){this._settings=e}getFilter(){return e=>this._isNonFatalError(e)}_isNonFatalError(e){return t.errno.isEnoentCodeError(e)||this._settings.suppressErrors}}})),lt=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ee();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}}})),ut=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(`path`),n=ot(),r=st(),i=ct(),a=lt();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}}}})),dt=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=rt(),n=ut();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)}}})),ft=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(`stream`),n=nt(),r=ut();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)}}})),pt=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Me(),n=et(),r=tt();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)}}})),mt=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=pt(),n=ut();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)}}})),ht=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DEFAULT_FILE_SYSTEM_ADAPTER=void 0;let t=M(`fs`),n=M(`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)}}})),gt=re(j(((e,t)=>{let n=De(),r=dt(),i=ft(),a=mt(),o=ht(),s=Ee();async function c(e,t){u(e);let n=l(e,r.default,t),i=await Promise.all(n);return s.array.flatten(i)}(function(e){e.glob=e,e.globSync=t,e.globStream=r,e.async=e;function t(e,t){u(e);let n=l(e,a.default,t);return s.array.flatten(n)}e.sync=t;function r(e,t){u(e);let n=l(e,i.default,t);return s.stream.merge(n)}e.stream=r;function c(e,t){u(e);let r=[].concat(e),i=new o.default(t);return n.generate(r,i)}e.generateTasks=c;function d(e,t){u(e);let n=new o.default(t);return s.pattern.isDynamicPattern(e,n)}e.isDynamicPattern=d;function f(e){return u(e),s.path.escape(e)}e.escapePath=f;function p(e){return u(e),s.path.convertPathToPattern(e)}e.convertPathToPattern=p,(function(e){function t(e){return u(e),s.path.escapePosixPath(e)}e.escapePath=t;function n(e){return u(e),s.path.convertPosixPathToPattern(e)}e.convertPathToPattern=n})(e.posix||={}),(function(e){function t(e){return u(e),s.path.escapeWindowsPath(e)}e.escapePath=t;function n(e){return u(e),s.path.convertWindowsPathToPattern(e)}e.convertPathToPattern=n})(e.win32||={})})(c||={});function l(e,t,r){let i=[].concat(e),a=new o.default(r),s=n.generate(i,a),c=new t(a);return s.map(c.read,c)}function u(e){if(![].concat(e).every(e=>s.string.isString(e)&&!s.string.isEmpty(e)))throw TypeError(`Patterns must be a string (non empty) or an array of strings`)}t.exports=c}))(),1);async function _t(e,t){let n=[],r=[],i=[],a=[];for(let o of e)o.registerProjectOutputDirs&&n.push(...await o.registerProjectOutputDirs(t)),o.registerProjectOutputFiles&&r.push(...await o.registerProjectOutputFiles(t)),o.registerGlobalOutputDirs&&i.push(...await o.registerGlobalOutputDirs(t)),o.registerGlobalOutputFiles&&a.push(...await o.registerGlobalOutputFiles(t));return{projectDirs:n,projectFiles:r,globalDirs:i,globalFiles:a}}async function vt(e,t){let n=new Map;for(let r of e)n.set(r.name,{project:await r.canCleanProject?.(t)??!0,global:await r.canCleanGlobal?.(t)??!0});return n}async function yt(e,t){for(let n of e)await n.onCleanComplete?.(t)}async function bt(e,t){let n=new Map;for(let r of e){let e=await r.canWrite?.(t)??!0;n.set(r.name,{project:e,global:e})}return n}async function xt(e,t){let n=new Map;for(let r of e){let e=await r.writeProjectOutputs?.(t)??{files:[],dirs:[]},i=await r.writeGlobalOutputs?.(t)??{files:[],dirs:[]},a={files:[...e.files,...i.files],dirs:[...e.dirs,...i.dirs]};n.set(r.name,a),await r.onWriteComplete?.(t,a)}return n}async function St(e,t,n){let r=[],i=[];for(let a of e){let e=t.get(a.name);if(e?.project){let e=await a.registerProjectOutputFiles?.(n)??[],t=await a.registerProjectOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}if(e?.global){let e=await a.registerGlobalOutputFiles?.(n)??[],t=await a.registerGlobalOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}}return{filesToDelete:r,dirsToDelete:i}}function Ct(e,t){let n=0,r=[];for(let i of e){let e=g.isAbsolute(i)?i:g.resolve(i);try{h.existsSync(e)&&(h.unlinkSync(e),t.debug({action:`delete`,type:`file`,path:e}),n++)}catch(n){let i=n instanceof Error?n.message:String(n);t.warn(`failed to delete file`,{path:e,error:i}),r.push({path:e,type:`file`,error:n})}}return{deleted:n,errors:r}}function wt(e,t){let n=0,r=[],i=[...e].sort((e,t)=>t.length-e.length);for(let e of i){let i=g.isAbsolute(e)?e:g.resolve(e);try{h.existsSync(i)&&(h.rmSync(i,{recursive:!0,force:!0}),t.debug({action:`delete`,type:`directory`,path:i}),n++)}catch(e){let n=e instanceof Error?e.message:String(e);t.warn(`failed to delete directory`,{path:i,error:n}),r.push({path:i,type:`directory`,error:e})}}return{deleted:n,errors:r}}async function Tt(e,t,n,r){let{executeHooks:i=!0}=r??{},a=await _t(e,t);n.debug(`Collected outputs for cleanup`,{projectDirs:a.projectDirs.length,projectFiles:a.projectFiles.length,globalDirs:a.globalDirs.length,globalFiles:a.globalFiles.length});let{filesToDelete:o,dirsToDelete:s}=await St(e,await vt(e,t),t),c=Ct(o,n),l=wt(s,n);return i&&await yt(e,t),{deletedFiles:c.deleted,deletedDirs:l.deleted,errors:[...c.errors,...l.errors]}}var Et=class{name=`clean`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r}=e;t.info(`running clean pipeline`,{command:`clean`});let i=await Tt(n,r(!1),t);return t.info(`clean complete`,{deletedFiles:i.deletedFiles,deletedDirs:i.deletedDirs}),{success:!0,filesAffected:i.deletedFiles,dirsAffected:i.deletedDirs}}};let Dt=function(e){return e.Input=`Input`,e.Output=`Output`,e}({}),Ot=function(e){return e.GlobalMemory=`GlobalMemory`,e.ProjectRootMemory=`ProjectRootMemory`,e.ProjectChildrenMemory=`ProjectChildrenMemory`,e.FastCommand=`FastCommand`,e.SubAgent=`SubAgent`,e.Skill=`Skill`,e.SkillChildDoc=`SkillChildDoc`,e.SkillResource=`SkillResource`,e.SkillMcpConfig=`SkillMcpConfig`,e.Readme=`Readme`,e}({}),kt=function(e){return e.Red=`Red`,e.Green=`Green`,e.Blue=`Blue`,e.Yellow=`Yellow`,e}({}),At=function(e){return e.Read=`Read`,e.Write=`Write`,e.Edit=`Edit`,e.Grep=`Grep`,e}({}),jt=function(e){return e.CamelCase=`CamelCase`,e.PascalCase=`PascalCase`,e.SnakeCase=`SnakeCase`,e.KebabCase=`KebabCase`,e.UpperCase=`UpperCase`,e.LowerCase=`LowerCase`,e.Original=`Original`,e}({}),Mt=function(e){return e.UserHome=`UserHome`,e.External=`External`,e}({}),N=function(e){return e.Relative=`Relative`,e.Absolute=`Absolute`,e.Root=`Root`,e}({}),P=function(e){return e.VSCode=`VSCode`,e.IntellijIDEA=`IntellijIDEA`,e.Git=`Git`,e.EditorConfig=`EditorConfig`,e.Original=`Original`,e}({});function Nt(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 Pt(e,t){return Nt(e,{requiredFields:[`name`,`description`],optionalDefaults:{enabled:!0,keywords:[]},filePath:t})}function Ft(e,t){return Nt(e,{requiredFields:[],optionalDefaults:{},filePath:t})}function It(e,t){return Nt(e,{requiredFields:[`name`,`description`],optionalDefaults:{},filePath:t})}function Lt(e,t){let n={...e};for(let[e,r]of Object.entries(t))(!(e in n)||n[e]==null)&&(n[e]=r);return n}const Rt=`.kt,.java,.py,.pyi,.pyx,.ts,.tsx,.js,.jsx,.mjs,.cjs,.go,.rs,.c,.cpp,.cc,.h,.hpp,.hxx,.cs,.fs,.fsx,.vb,.rb,.php,.swift,.scala,.groovy,.lua,.r,.R,.jl,.ex,.exs,.erl,.clj,.cljs,.hs,.ml,.mli,.nim,.zig,.v,.dart,.vue,.svelte,.sql,.json,.jsonc,.json5,.xml,.xsd,.xsl,.xslt,.yaml,.yml,.toml,.csv,.tsv,.graphql,.gql,.proto,.txt,.text,.rtf,.log,.ini,.conf,.cfg,.config,.properties,.env,.envrc,.editorconfig,.gitignore,.gitattributes,.npmrc,.nvmrc,.npmignore,.eslintrc,.prettierrc,.stylelintrc,.babelrc,.browserslistrc,.sh,.bash,.zsh,.fish,.ps1,.psm1,.psd1,.bat,.cmd,.html,.htm,.xhtml,.css,.scss,.sass,.less,.styl,.svg,.ejs,.hbs,.mustache,.pug,.jade,.jinja,.jinja2,.j2,.erb,.haml,.slim,.d.ts,.d.mts,.d.cts,.diff,.patch,.asm,.s,.makefile,.mk,.dockerfile,.tf,.tfvars,.prisma,.mdx`.split(`,`),zt=`.docx,.doc,.xlsx,.xls,.pptx,.ppt,.pdf,.odt,.ods,.odp,.png,.jpg,.jpeg,.gif,.webp,.ico,.bmp,.tiff,.zip,.tar,.gz,.bz2,.7z,.rar,.pyd,.pyc,.pyo,.class,.jar,.war,.dll,.so,.dylib,.exe,.bin,.wasm,.ttf,.otf,.woff,.woff2,.eot,.mp3,.wav,.ogg,.mp4,.webm,.db,.sqlite,.sqlite3`.split(`,`),F={SRC:`src`,DIST:`dist`,SKILLS:`skills`,COMMANDS:`commands`,AGENTS:`agents`,APP:`app`,IDEA:`.idea`,IDEA_CODE_STYLES:`.idea/codeStyles`,VSCODE:`.vscode`},I={GLOBAL_MEMORY:`global.mdx`,GLOBAL_MEMORY_SRC:`global.cn.mdx`,EDITOR_CONFIG:`.editorconfig`,IDEA_GITIGNORE:`.idea/.gitignore`,IDEA_PROJECT_XML:`.idea/codeStyles/Project.xml`,IDEA_CODE_STYLE_CONFIG_XML:`.idea/codeStyles/codeStyleConfig.xml`,VSCODE_SETTINGS:`.vscode/settings.json`,VSCODE_EXTENSIONS:`.vscode/extensions.json`,QODER_IGNORE:`.qoderignore`,CURSOR_IGNORE:`.cursorignore`,WARP_INDEX_IGNORE:`.warpindexignore`},L={SRC_SKILLS:`src/skills`,SRC_COMMANDS:`src/commands`,SRC_AGENTS:`src/agents`,SRC_GLOBAL_MEMORY:`app/global.cn.mdx`,DIST_SKILLS:`dist/skills`,DIST_COMMANDS:`dist/commands`,DIST_AGENTS:`dist/agents`,DIST_APP:`dist/app`,DIST_GLOBAL_MEMORY:`dist/global.mdx`,APP:`app`},Bt={src:{skills:{name:F.SKILLS,required:!1,description:`Skill source files (.cn.mdx)`},commands:{name:F.COMMANDS,required:!1,description:`Fast command source files (.cn.mdx)`},agents:{name:F.AGENTS,required:!1,description:`Sub-agent source files (.cn.mdx)`},globalMemoryFile:{name:I.GLOBAL_MEMORY_SRC,required:!1,description:`Global memory source file`}},dist:{skills:{name:F.SKILLS,required:!1,description:`Compiled skill files (.mdx)`},commands:{name:F.COMMANDS,required:!1,description:`Compiled fast command files (.mdx)`},agents:{name:F.AGENTS,required:!1,description:`Compiled sub-agent files (.mdx)`},globalMemoryFile:{name:I.GLOBAL_MEMORY,required:!1,description:`Compiled global memory file`},app:{name:F.APP,required:!1,description:`Compiled project-specific prompts`}},app:{name:F.APP,required:!1,description:`Project-specific prompts (standalone directory)`},ide:{idea:{name:F.IDEA,required:!1,description:`JetBrains IDE configuration directory`},ideaCodeStyles:{name:F.IDEA_CODE_STYLES,required:!1,description:`JetBrains IDE code styles directory`},vscode:{name:F.VSCODE,required:!1,description:`VS Code configuration directory`}},ideFiles:[{name:I.EDITOR_CONFIG,required:!1,description:`EditorConfig file`},{name:I.IDEA_GITIGNORE,required:!1,description:`JetBrains IDE .gitignore`},{name:I.IDEA_PROJECT_XML,required:!1,description:`JetBrains IDE Project.xml`},{name:I.IDEA_CODE_STYLE_CONFIG_XML,required:!1,description:`JetBrains IDE codeStyleConfig.xml`},{name:I.VSCODE_SETTINGS,required:!1,description:`VS Code settings.json`},{name:I.VSCODE_EXTENSIONS,required:!1,description:`VS Code extensions.json`}],ignoreFiles:[{name:I.QODER_IGNORE,required:!1,description:`Qoder ignore file`},{name:I.CURSOR_IGNORE,required:!1,description:`Cursor ignore file`},{name:I.WARP_INDEX_IGNORE,required:!1,description:`Warp index ignore file`}]};var Vt=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 _t(n,i);t.info(`collected outputs for cleanup`,{dryRun:!0,projectDirs:a.projectDirs.length,projectFiles:a.projectFiles.length,globalDirs:a.globalDirs.length,globalFiles:a.globalFiles.length});let o=await vt(n,i),{filesToDelete:s,dirsToDelete:c}=await this.collectDeletionTargets(e,o,i);return this.logDryRunFiles(s,t),this.logDryRunDirectories(c,t),await yt(n,i),t.info(`clean complete`,{dryRun:!0,filesAffected:s.length,dirsAffected:c.length}),{success:!0,filesAffected:s.length,dirsAffected:c.length,message:`Dry-run complete, no files were deleted`}}async collectDeletionTargets(e,t,n){let r=[],i=[];for(let a of e.outputPlugins){let e=t.get(a.name);if(e?.project){let e=await a.registerProjectOutputFiles?.(n)??[],t=await a.registerProjectOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}if(e?.global){let e=await a.registerGlobalOutputFiles?.(n)??[],t=await a.registerGlobalOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}}return{filesToDelete:r,dirsToDelete:i}}logDryRunFiles(e,t){for(let n of e){let e=g.isAbsolute(n)?n:g.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=g.isAbsolute(e)?e:g.resolve(e);t.info(`would delete directory`,{path:n,dryRun:!0})}}},Ht=class{name=`dry-run-output`;async execute(e){let{logger:t,outputPlugins:n,createWriteContext:r}=e;t.info(`started`,{command:`dry-run-output`,dryRun:!0});let i=r(!0),a=await bt(n,i),o=await xt(n.filter(e=>!!(a.get(e.name)?.project??!0)),i),s=0,c=0;for(let[e,n]of o)s+=n.files.length,c+=n.dirs.length,t.info(`plugin result`,{plugin:e,files:n.files.length,dirs:n.dirs.length,dryRun:!0});return t.info(`complete`,{command:`dry-run-output`,totalFiles:s,totalDirs:c,dryRun:!0}),{success:!0,filesAffected:s,dirsAffected:c,message:`Dry-run complete, no files were written`}}},Ut=class{name=`execute`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r,createWriteContext:i}=e;t.info(`started`,{command:`execute`});let a=await Tt(n,r(!1),t,{executeHooks:!1});t.info(`cleanup complete`,{deletedFiles:a.deletedFiles,deletedDirs:a.deletedDirs});let o=i(!1),s=await bt(n,o),c=await xt(n.filter(e=>s.get(e.name)?.project??!0),o),l=0,u=0;for(let e of c.values())l+=e.files.length,u+=e.dirs.length;return t.info(`complete`,{command:`execute`,pluginCount:c.size}),{success:!0,filesAffected:l,dirsAffected:u}}};function Wt(){return`2026.10106.107`}var Gt=class{name=`version`;async execute(e){return e.logger.error(`tnmsc v${Wt()}`),{success:!0,filesAffected:0,dirsAffected:0,message:`Version displayed`}}};const R=`tnmsc`,Kt=`
|
|
20
|
+
t.exports=r;let n=Ne();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}})),Fe=j((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})),Ie=j((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})),Le=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fs=void 0,e.fs=Ie()})),Re=j((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})),ze=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.readdir=e.readdirWithFileTypes=e.read=void 0;let t=Me(),n=Pe(),r=Fe(),i=Le(),a=Re();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)}})),Be=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.readdir=e.readdirWithFileTypes=e.read=void 0;let t=Me(),n=Fe(),r=Le(),i=Re();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})),Ve=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createFileSystemAdapter=e.FILE_SYSTEM_ADAPTER=void 0;let t=M(`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})),He=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(`path`),n=Me(),r=Ve();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}}})),Ue=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.scandirSync=e.scandir=void 0;let t=ze(),n=Be(),r=He();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)}})),We=j(((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})),Ge=j(((e,t)=>{var n=We();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})),Ke=j((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})),qe=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ke();e.default=class{constructor(e,n){this._root=e,this._settings=n,this._root=t.replacePathSegmentSeparator(e,n.pathSegmentSeparator)}}})),Je=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(`events`),n=Ue(),r=Ge(),i=Ke(),a=qe();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)}}})),Ye=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Je();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)}})),Xe=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(`stream`),n=Je();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}}})),Ze=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ue(),n=Ke(),r=qe();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)}}})),Qe=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ze();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()}}})),$e=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(`path`),n=Ue();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}}})),et=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Settings=e.walkStream=e.walkSync=e.walk=void 0;let t=Ye(),n=Xe(),r=Qe(),i=$e();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)}})),tt=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(`path`),n=Me(),r=Ee();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}}})),nt=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(`stream`),n=Me(),r=et(),i=tt();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))})}}})),rt=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=et(),n=tt(),r=nt();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))})}}})),it=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ee();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))}}})),at=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=it();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}}})),ot=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ee(),n=at();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)}}})),st=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ee();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}}})),ct=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ee();e.default=class{constructor(e){this._settings=e}getFilter(){return e=>this._isNonFatalError(e)}_isNonFatalError(e){return t.errno.isEnoentCodeError(e)||this._settings.suppressErrors}}})),lt=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Ee();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}}})),ut=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(`path`),n=ot(),r=st(),i=ct(),a=lt();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}}}})),dt=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=rt(),n=ut();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)}}})),ft=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=M(`stream`),n=nt(),r=ut();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)}}})),pt=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=Me(),n=et(),r=tt();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)}}})),mt=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=pt(),n=ut();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)}}})),ht=j((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DEFAULT_FILE_SYSTEM_ADAPTER=void 0;let t=M(`fs`),n=M(`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)}}})),gt=re(j(((e,t)=>{let n=De(),r=dt(),i=ft(),a=mt(),o=ht(),s=Ee();async function c(e,t){u(e);let n=l(e,r.default,t),i=await Promise.all(n);return s.array.flatten(i)}(function(e){e.glob=e,e.globSync=t,e.globStream=r,e.async=e;function t(e,t){u(e);let n=l(e,a.default,t);return s.array.flatten(n)}e.sync=t;function r(e,t){u(e);let n=l(e,i.default,t);return s.stream.merge(n)}e.stream=r;function c(e,t){u(e);let r=[].concat(e),i=new o.default(t);return n.generate(r,i)}e.generateTasks=c;function d(e,t){u(e);let n=new o.default(t);return s.pattern.isDynamicPattern(e,n)}e.isDynamicPattern=d;function f(e){return u(e),s.path.escape(e)}e.escapePath=f;function p(e){return u(e),s.path.convertPathToPattern(e)}e.convertPathToPattern=p,(function(e){function t(e){return u(e),s.path.escapePosixPath(e)}e.escapePath=t;function n(e){return u(e),s.path.convertPosixPathToPattern(e)}e.convertPathToPattern=n})(e.posix||={}),(function(e){function t(e){return u(e),s.path.escapeWindowsPath(e)}e.escapePath=t;function n(e){return u(e),s.path.convertWindowsPathToPattern(e)}e.convertPathToPattern=n})(e.win32||={})})(c||={});function l(e,t,r){let i=[].concat(e),a=new o.default(r),s=n.generate(i,a),c=new t(a);return s.map(c.read,c)}function u(e){if(![].concat(e).every(e=>s.string.isString(e)&&!s.string.isEmpty(e)))throw TypeError(`Patterns must be a string (non empty) or an array of strings`)}t.exports=c}))(),1);async function _t(e,t){let n=[],r=[],i=[],a=[];for(let o of e)o.registerProjectOutputDirs&&n.push(...await o.registerProjectOutputDirs(t)),o.registerProjectOutputFiles&&r.push(...await o.registerProjectOutputFiles(t)),o.registerGlobalOutputDirs&&i.push(...await o.registerGlobalOutputDirs(t)),o.registerGlobalOutputFiles&&a.push(...await o.registerGlobalOutputFiles(t));return{projectDirs:n,projectFiles:r,globalDirs:i,globalFiles:a}}async function vt(e,t){let n=new Map;for(let r of e)n.set(r.name,{project:await r.canCleanProject?.(t)??!0,global:await r.canCleanGlobal?.(t)??!0});return n}async function yt(e,t){for(let n of e)await n.onCleanComplete?.(t)}async function bt(e,t){let n=new Map;for(let r of e){let e=await r.canWrite?.(t)??!0;n.set(r.name,{project:e,global:e})}return n}async function xt(e,t){let n=new Map;for(let r of e){let e=await r.writeProjectOutputs?.(t)??{files:[],dirs:[]},i=await r.writeGlobalOutputs?.(t)??{files:[],dirs:[]},a={files:[...e.files,...i.files],dirs:[...e.dirs,...i.dirs]};n.set(r.name,a),await r.onWriteComplete?.(t,a)}return n}async function St(e,t,n){let r=[],i=[];for(let a of e){let e=t.get(a.name);if(e?.project){let e=await a.registerProjectOutputFiles?.(n)??[],t=await a.registerProjectOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}if(e?.global){let e=await a.registerGlobalOutputFiles?.(n)??[],t=await a.registerGlobalOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}}return{filesToDelete:r,dirsToDelete:i}}function Ct(e,t){let n=0,r=[];for(let i of e){let e=g.isAbsolute(i)?i:g.resolve(i);try{h.existsSync(e)&&(h.unlinkSync(e),t.debug({action:`delete`,type:`file`,path:e}),n++)}catch(n){let i=n instanceof Error?n.message:String(n);t.warn(`failed to delete file`,{path:e,error:i}),r.push({path:e,type:`file`,error:n})}}return{deleted:n,errors:r}}function wt(e,t){let n=0,r=[],i=[...e].sort((e,t)=>t.length-e.length);for(let e of i){let i=g.isAbsolute(e)?e:g.resolve(e);try{h.existsSync(i)&&(h.rmSync(i,{recursive:!0,force:!0}),t.debug({action:`delete`,type:`directory`,path:i}),n++)}catch(e){let n=e instanceof Error?e.message:String(e);t.warn(`failed to delete directory`,{path:i,error:n}),r.push({path:i,type:`directory`,error:e})}}return{deleted:n,errors:r}}async function Tt(e,t,n,r){let{executeHooks:i=!0}=r??{},a=await _t(e,t);n.debug(`Collected outputs for cleanup`,{projectDirs:a.projectDirs.length,projectFiles:a.projectFiles.length,globalDirs:a.globalDirs.length,globalFiles:a.globalFiles.length});let{filesToDelete:o,dirsToDelete:s}=await St(e,await vt(e,t),t),c=Ct(o,n),l=wt(s,n);return i&&await yt(e,t),{deletedFiles:c.deleted,deletedDirs:l.deleted,errors:[...c.errors,...l.errors]}}var Et=class{name=`clean`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r}=e;t.info(`running clean pipeline`,{command:`clean`});let i=await Tt(n,r(!1),t);return t.info(`clean complete`,{deletedFiles:i.deletedFiles,deletedDirs:i.deletedDirs}),{success:!0,filesAffected:i.deletedFiles,dirsAffected:i.deletedDirs}}};let Dt=function(e){return e.Input=`Input`,e.Output=`Output`,e}({}),Ot=function(e){return e.GlobalMemory=`GlobalMemory`,e.ProjectRootMemory=`ProjectRootMemory`,e.ProjectChildrenMemory=`ProjectChildrenMemory`,e.FastCommand=`FastCommand`,e.SubAgent=`SubAgent`,e.Skill=`Skill`,e.SkillChildDoc=`SkillChildDoc`,e.SkillResource=`SkillResource`,e.SkillMcpConfig=`SkillMcpConfig`,e.Readme=`Readme`,e}({}),kt=function(e){return e.Red=`Red`,e.Green=`Green`,e.Blue=`Blue`,e.Yellow=`Yellow`,e}({}),At=function(e){return e.Read=`Read`,e.Write=`Write`,e.Edit=`Edit`,e.Grep=`Grep`,e}({}),jt=function(e){return e.CamelCase=`CamelCase`,e.PascalCase=`PascalCase`,e.SnakeCase=`SnakeCase`,e.KebabCase=`KebabCase`,e.UpperCase=`UpperCase`,e.LowerCase=`LowerCase`,e.Original=`Original`,e}({}),Mt=function(e){return e.UserHome=`UserHome`,e.External=`External`,e}({}),N=function(e){return e.Relative=`Relative`,e.Absolute=`Absolute`,e.Root=`Root`,e}({}),P=function(e){return e.VSCode=`VSCode`,e.IntellijIDEA=`IntellijIDEA`,e.Git=`Git`,e.EditorConfig=`EditorConfig`,e.Original=`Original`,e}({});function Nt(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 Pt(e,t){return Nt(e,{requiredFields:[`name`,`description`],optionalDefaults:{enabled:!0,keywords:[]},filePath:t})}function Ft(e,t){return Nt(e,{requiredFields:[],optionalDefaults:{},filePath:t})}function It(e,t){return Nt(e,{requiredFields:[`name`,`description`],optionalDefaults:{},filePath:t})}function Lt(e,t){let n={...e};for(let[e,r]of Object.entries(t))(!(e in n)||n[e]==null)&&(n[e]=r);return n}const Rt=`.kt,.java,.py,.pyi,.pyx,.ts,.tsx,.js,.jsx,.mjs,.cjs,.go,.rs,.c,.cpp,.cc,.h,.hpp,.hxx,.cs,.fs,.fsx,.vb,.rb,.php,.swift,.scala,.groovy,.lua,.r,.R,.jl,.ex,.exs,.erl,.clj,.cljs,.hs,.ml,.mli,.nim,.zig,.v,.dart,.vue,.svelte,.sql,.json,.jsonc,.json5,.xml,.xsd,.xsl,.xslt,.yaml,.yml,.toml,.csv,.tsv,.graphql,.gql,.proto,.txt,.text,.rtf,.log,.ini,.conf,.cfg,.config,.properties,.env,.envrc,.editorconfig,.gitignore,.gitattributes,.npmrc,.nvmrc,.npmignore,.eslintrc,.prettierrc,.stylelintrc,.babelrc,.browserslistrc,.sh,.bash,.zsh,.fish,.ps1,.psm1,.psd1,.bat,.cmd,.html,.htm,.xhtml,.css,.scss,.sass,.less,.styl,.svg,.ejs,.hbs,.mustache,.pug,.jade,.jinja,.jinja2,.j2,.erb,.haml,.slim,.d.ts,.d.mts,.d.cts,.diff,.patch,.asm,.s,.makefile,.mk,.dockerfile,.tf,.tfvars,.prisma,.mdx`.split(`,`),zt=`.docx,.doc,.xlsx,.xls,.pptx,.ppt,.pdf,.odt,.ods,.odp,.png,.jpg,.jpeg,.gif,.webp,.ico,.bmp,.tiff,.zip,.tar,.gz,.bz2,.7z,.rar,.pyd,.pyc,.pyo,.class,.jar,.war,.dll,.so,.dylib,.exe,.bin,.wasm,.ttf,.otf,.woff,.woff2,.eot,.mp3,.wav,.ogg,.mp4,.webm,.db,.sqlite,.sqlite3`.split(`,`),F={SRC:`src`,DIST:`dist`,SKILLS:`skills`,COMMANDS:`commands`,AGENTS:`agents`,APP:`app`,IDEA:`.idea`,IDEA_CODE_STYLES:`.idea/codeStyles`,VSCODE:`.vscode`},I={GLOBAL_MEMORY:`global.mdx`,GLOBAL_MEMORY_SRC:`global.cn.mdx`,EDITOR_CONFIG:`.editorconfig`,IDEA_GITIGNORE:`.idea/.gitignore`,IDEA_PROJECT_XML:`.idea/codeStyles/Project.xml`,IDEA_CODE_STYLE_CONFIG_XML:`.idea/codeStyles/codeStyleConfig.xml`,VSCODE_SETTINGS:`.vscode/settings.json`,VSCODE_EXTENSIONS:`.vscode/extensions.json`,QODER_IGNORE:`.qoderignore`,CURSOR_IGNORE:`.cursorignore`,WARP_INDEX_IGNORE:`.warpindexignore`},L={SRC_SKILLS:`src/skills`,SRC_COMMANDS:`src/commands`,SRC_AGENTS:`src/agents`,SRC_GLOBAL_MEMORY:`app/global.cn.mdx`,DIST_SKILLS:`dist/skills`,DIST_COMMANDS:`dist/commands`,DIST_AGENTS:`dist/agents`,DIST_APP:`dist/app`,DIST_GLOBAL_MEMORY:`dist/global.mdx`,APP:`app`},Bt={src:{skills:{name:F.SKILLS,required:!1,description:`Skill source files (.cn.mdx)`},commands:{name:F.COMMANDS,required:!1,description:`Fast command source files (.cn.mdx)`},agents:{name:F.AGENTS,required:!1,description:`Sub-agent source files (.cn.mdx)`},globalMemoryFile:{name:I.GLOBAL_MEMORY_SRC,required:!1,description:`Global memory source file`}},dist:{skills:{name:F.SKILLS,required:!1,description:`Compiled skill files (.mdx)`},commands:{name:F.COMMANDS,required:!1,description:`Compiled fast command files (.mdx)`},agents:{name:F.AGENTS,required:!1,description:`Compiled sub-agent files (.mdx)`},globalMemoryFile:{name:I.GLOBAL_MEMORY,required:!1,description:`Compiled global memory file`},app:{name:F.APP,required:!1,description:`Compiled project-specific prompts`}},app:{name:F.APP,required:!1,description:`Project-specific prompts (standalone directory)`},ide:{idea:{name:F.IDEA,required:!1,description:`JetBrains IDE configuration directory`},ideaCodeStyles:{name:F.IDEA_CODE_STYLES,required:!1,description:`JetBrains IDE code styles directory`},vscode:{name:F.VSCODE,required:!1,description:`VS Code configuration directory`}},ideFiles:[{name:I.EDITOR_CONFIG,required:!1,description:`EditorConfig file`},{name:I.IDEA_GITIGNORE,required:!1,description:`JetBrains IDE .gitignore`},{name:I.IDEA_PROJECT_XML,required:!1,description:`JetBrains IDE Project.xml`},{name:I.IDEA_CODE_STYLE_CONFIG_XML,required:!1,description:`JetBrains IDE codeStyleConfig.xml`},{name:I.VSCODE_SETTINGS,required:!1,description:`VS Code settings.json`},{name:I.VSCODE_EXTENSIONS,required:!1,description:`VS Code extensions.json`}],ignoreFiles:[{name:I.QODER_IGNORE,required:!1,description:`Qoder ignore file`},{name:I.CURSOR_IGNORE,required:!1,description:`Cursor ignore file`},{name:I.WARP_INDEX_IGNORE,required:!1,description:`Warp index ignore file`}]};var Vt=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 _t(n,i);t.info(`collected outputs for cleanup`,{dryRun:!0,projectDirs:a.projectDirs.length,projectFiles:a.projectFiles.length,globalDirs:a.globalDirs.length,globalFiles:a.globalFiles.length});let o=await vt(n,i),{filesToDelete:s,dirsToDelete:c}=await this.collectDeletionTargets(e,o,i);return this.logDryRunFiles(s,t),this.logDryRunDirectories(c,t),await yt(n,i),t.info(`clean complete`,{dryRun:!0,filesAffected:s.length,dirsAffected:c.length}),{success:!0,filesAffected:s.length,dirsAffected:c.length,message:`Dry-run complete, no files were deleted`}}async collectDeletionTargets(e,t,n){let r=[],i=[];for(let a of e.outputPlugins){let e=t.get(a.name);if(e?.project){let e=await a.registerProjectOutputFiles?.(n)??[],t=await a.registerProjectOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}if(e?.global){let e=await a.registerGlobalOutputFiles?.(n)??[],t=await a.registerGlobalOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}}return{filesToDelete:r,dirsToDelete:i}}logDryRunFiles(e,t){for(let n of e){let e=g.isAbsolute(n)?n:g.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=g.isAbsolute(e)?e:g.resolve(e);t.info(`would delete directory`,{path:n,dryRun:!0})}}},Ht=class{name=`dry-run-output`;async execute(e){let{logger:t,outputPlugins:n,createWriteContext:r}=e;t.info(`started`,{command:`dry-run-output`,dryRun:!0});let i=r(!0),a=await bt(n,i),o=await xt(n.filter(e=>!!(a.get(e.name)?.project??!0)),i),s=0,c=0;for(let[e,n]of o)s+=n.files.length,c+=n.dirs.length,t.info(`plugin result`,{plugin:e,files:n.files.length,dirs:n.dirs.length,dryRun:!0});return t.info(`complete`,{command:`dry-run-output`,totalFiles:s,totalDirs:c,dryRun:!0}),{success:!0,filesAffected:s,dirsAffected:c,message:`Dry-run complete, no files were written`}}},Ut=class{name=`execute`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r,createWriteContext:i}=e;t.info(`started`,{command:`execute`});let a=await Tt(n,r(!1),t,{executeHooks:!1});t.info(`cleanup complete`,{deletedFiles:a.deletedFiles,deletedDirs:a.deletedDirs});let o=i(!1),s=await bt(n,o),c=await xt(n.filter(e=>s.get(e.name)?.project??!0),o),l=0,u=0;for(let e of c.values())l+=e.files.length,u+=e.dirs.length;return t.info(`complete`,{command:`execute`,pluginCount:c.size}),{success:!0,filesAffected:l,dirsAffected:u}}};function Wt(){return`2026.10107.0`}var Gt=class{name=`version`;async execute(e){return e.logger.error(`tnmsc v${Wt()}`),{success:!0,filesAffected:0,dirsAffected:0,message:`Version displayed`}}};const R=`tnmsc`,Kt=`
|
|
21
21
|
${R} v${Wt()} - Memory Sync CLI
|
|
22
22
|
|
|
23
23
|
Synchronize AI memory and configuration files across projects.
|
|
@@ -91,7 +91,7 @@ CONFIGURATION:
|
|
|
91
91
|
"birthday": "1990-01-01"
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
`);function Xt(e,t){let n=g.join(e,`.git`),r=h.existsSync(n);return r?t?.info(`version control detected`,{path:n}):t?.warn(`no version control detected, please use git to manage your shadow source project`,{path:e}),{hasGit:r,gitPath:n}}function Zt(e,t=Bt){let n=[];Qt(e,F.SRC,t.src.skills,n),Qt(e,F.SRC,t.src.commands,n),Qt(e,F.SRC,t.src.agents,n),en(e,L.SRC_GLOBAL_MEMORY,t.src.globalMemoryFile,n),Qt(e,F.DIST,t.dist.skills,n),Qt(e,F.DIST,t.dist.commands,n),Qt(e,F.DIST,t.dist.agents,n),Qt(e,F.DIST,t.dist.app,n),en(e,L.DIST_GLOBAL_MEMORY,t.dist.globalMemoryFile,n),$t(e,t.app,n),$t(e,t.ide.idea,n),$t(e,t.ide.ideaCodeStyles,n),$t(e,t.ide.vscode,n);for(let r of t.ideFiles)tn(e,r,n);for(let r of t.ignoreFiles)tn(e,r,n);let r=n.filter(e=>!e.exists&&e.required),i=n.filter(e=>!e.exists&&!e.required);return{valid:r.length===0,rootPath:e,items:n,missingRequired:r,missingOptional:i}}function Qt(e,t,n,r){let i=g.join(e,t,n.name);r.push({path:i,exists:h.existsSync(i)&&h.statSync(i).isDirectory(),required:n.required,type:`directory`})}function $t(e,t,n){let r=g.join(e,t.name);n.push({path:r,exists:h.existsSync(r)&&h.statSync(r).isDirectory(),required:t.required,type:`directory`})}function en(e,t,n,r){let i=g.join(e,t);r.push({path:i,exists:h.existsSync(i)&&h.statSync(i).isFile(),required:n.required,type:`file`})}function tn(e,t,n){let r=g.join(e,t.name);n.push({path:r,exists:h.existsSync(r)&&h.statSync(r).isFile(),required:t.required,type:`file`})}function nn(e,t={}){let{sourceDir:n,logger:r}=t,i=[],a=[],o=[],s=[],c=(e,t)=>{if(n
|
|
94
|
+
`);function Xt(e,t){let n=g.join(e,`.git`),r=h.existsSync(n);return r?t?.info(`version control detected`,{path:n}):t?.warn(`no version control detected, please use git to manage your shadow source project`,{path:e}),{hasGit:r,gitPath:n}}function Zt(e,t=Bt){let n=[];Qt(e,F.SRC,t.src.skills,n),Qt(e,F.SRC,t.src.commands,n),Qt(e,F.SRC,t.src.agents,n),en(e,L.SRC_GLOBAL_MEMORY,t.src.globalMemoryFile,n),Qt(e,F.DIST,t.dist.skills,n),Qt(e,F.DIST,t.dist.commands,n),Qt(e,F.DIST,t.dist.agents,n),Qt(e,F.DIST,t.dist.app,n),en(e,L.DIST_GLOBAL_MEMORY,t.dist.globalMemoryFile,n),$t(e,t.app,n),$t(e,t.ide.idea,n),$t(e,t.ide.ideaCodeStyles,n),$t(e,t.ide.vscode,n);for(let r of t.ideFiles)tn(e,r,n);for(let r of t.ignoreFiles)tn(e,r,n);let r=n.filter(e=>!e.exists&&e.required),i=n.filter(e=>!e.exists&&!e.required);return{valid:r.length===0,rootPath:e,items:n,missingRequired:r,missingOptional:i}}function Qt(e,t,n,r){let i=g.join(e,t,n.name);r.push({path:i,exists:h.existsSync(i)&&h.statSync(i).isDirectory(),required:n.required,type:`directory`})}function $t(e,t,n){let r=g.join(e,t.name);n.push({path:r,exists:h.existsSync(r)&&h.statSync(r).isDirectory(),required:t.required,type:`directory`})}function en(e,t,n,r){let i=g.join(e,t);r.push({path:i,exists:h.existsSync(i)&&h.statSync(i).isFile(),required:n.required,type:`file`})}function tn(e,t,n){let r=g.join(e,t.name);n.push({path:r,exists:h.existsSync(r)&&h.statSync(r).isFile(),required:t.required,type:`file`})}function nn(e,t={}){let{sourceDir:n,logger:r}=t,i=[],a=[],o=[],s=[],c=(e,t)=>{if(n==null)return t;let i=g.join(n,e);return h.existsSync(i)&&h.statSync(i).isFile()?(r?.debug(`copying from source`,{path:i}),h.readFileSync(i,`utf8`)):t},l=e=>{h.existsSync(e)?(o.push(e),r?.debug(`directory exists`,{path:e})):(h.mkdirSync(e,{recursive:!0}),i.push(e),r?.info(`created directory`,{path:e}))},u=(e,t,n)=>{let o=g.dirname(e);if(h.existsSync(o)||(h.mkdirSync(o,{recursive:!0}),i.push(o),r?.info(`created directory`,{path:o})),h.existsSync(e))s.push(e),r?.debug(`file exists`,{path:e});else{let i=c(t,n);h.writeFileSync(e,i,`utf8`),a.push(e),r?.info(`created file`,{path:e})}};return l(e),l(g.join(e,L.SRC_SKILLS)),l(g.join(e,L.SRC_COMMANDS)),l(g.join(e,L.SRC_AGENTS)),l(g.join(e,L.APP)),u(g.join(e,L.SRC_GLOBAL_MEMORY),L.SRC_GLOBAL_MEMORY,`# Global Memory
|
|
95
95
|
|
|
96
96
|
`),l(g.join(e,L.DIST_SKILLS)),l(g.join(e,L.DIST_COMMANDS)),l(g.join(e,L.DIST_AGENTS)),l(g.join(e,L.DIST_APP)),u(g.join(e,L.DIST_GLOBAL_MEMORY),L.DIST_GLOBAL_MEMORY,`# Global Memory
|
|
97
97
|
|
|
@@ -140,7 +140,7 @@ WARP.md
|
|
|
140
140
|
nul
|
|
141
141
|
node_modules/
|
|
142
142
|
pnpm-lock.yaml
|
|
143
|
-
`}function dn(e,t,n){let r=e;return r=r.replace(Jt.SHADOW_SOURCE_PROJECT,n),r=r.replace(Jt.WORKSPACE,t),r.startsWith(`~`)&&(r=g.join(v.homedir(),r.slice(1))),g.normalize(r)}var fn=class{name=`init`;async execute(e){let{logger:t,userConfigOptions:n}=e;t.info(`initializing shadow source project structure`,{command:`init`});let r=dn(n.workspaceDir,``,``),i=nn(dn(n.shadowSourceProjectDir,r,``),{logger:t}),a=i.createdDirs.length===0&&i.createdFiles.length===0?`All ${i.existedDirs.length} directories and ${i.existedFiles.length} files already exist`:`Created ${i.createdDirs.length} directories and ${i.createdFiles.length} files (${i.existedDirs.length} dirs, ${i.existedFiles.length} files already existed)`;return t.info(`initialization complete`,{dirsCreated:i.createdDirs.length,filesCreated:i.createdFiles.length,dirsExisted:i.existedDirs.length,filesExisted:i.existedFiles.length}),{success:i.success,filesAffected:i.createdFiles.length,dirsAffected:i.createdDirs.length,message:a}}};function pn(){return`@truenine/memory-sync-cli`}function mn(){return`https://registry.npmjs.org/${pn()}/latest`}function hn(e){let t=e.replace(/^v/,``),n=/^(\d+)\.(\d+)\.(\d+)/.exec(t);return n==null?null:[Number.parseInt(n[1],10),Number.parseInt(n[2],10),Number.parseInt(n[3],10)]}function gn(e,t){let n=hn(e),r=hn(t);if(n==null||r==null)return 0;for(let e=0;e<3;e++){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1}return 0}const _n=3e3;async function vn(){let e=new AbortController,t=setTimeout(()=>e.abort(),_n);typeof t==`object`&&`unref`in t&&t.unref();try{let n=await fetch(mn(),{headers:{Accept:`application/json`},signal:e.signal});if(clearTimeout(t),!n.ok)return{error:`HTTP ${n.status}: ${n.statusText}`};let r=await n.json();return r.version==null?{error:`Invalid response: missing version field`}:{version:r.version}}catch(e){return clearTimeout(t),e instanceof Error?e.name===`TimeoutError`||e.name===`AbortError`?{error:`Request timeout after ${_n}ms`}:{error:e.message}:{error:`Unknown network error`}}}function yn(){return`2026.10106.107`}async function bn(){let e=yn();if(e===`dev`)return{status:`development`,localVersion:e,remoteVersion:null};let t=await vn();if(`error`in t)return{status:`current`,localVersion:e,remoteVersion:null,error:t.error};let n=t.version,r=gn(e,n);return r<0?{status:`outdated`,localVersion:e,remoteVersion:n}:r>0?{status:`development`,localVersion:e,remoteVersion:n}:{status:`current`,localVersion:e,remoteVersion:n}}function xn(e,t){let{status:n,localVersion:r,remoteVersion:i}=e;switch(n){case`outdated`:t.warn(`Version outdated: ${r} → ${i}. Run 'npm i -g ${pn()}@latest' to update.`);break;case`current`:e.error==null?t.info(`Version ${r} is up to date.`):t.error(`Version check failed: ${e.error}`);break;case`development`:i==null?t.debug(`Running in development mode, version check skipped.`):t.info(`Development version detected: ${r} > ${i}. Thanks for contributing!`);break}}function Sn(){return new Date().getMinutes()%2==0}function Cn(e){Sn()&&bn().then(t=>{(t.status===`outdated`||t.error!=null)&&xn(t,e)}).catch(t=>{let n=t instanceof Error?t.message:`Unknown error`;e.error(`Version check failed: ${n}`)})}var wn=class{name=`outdated`;async execute(e){let t=await bn();return xn(t,e.logger),{success:!0,filesAffected:0,dirsAffected:0,message:`Version status: ${t.status}`}}};let Tn;function En(e){Tn=e}function Dn(){return Tn}const On={error:y.red,warn:y.yellow,info:y.cyan,debug:y.magenta,trace:y.gray,fatal:y.bgRed},kn={silent:0,fatal:1,error:2,warn:3,info:4,debug:5,trace:6};function An(e){return e===null?y.dim(`null`):e===void 0?y.dim(`undefined`):typeof e==`boolean`?y.yellow(String(e)):typeof e==`number`?y.blue(String(e)):typeof e==`string`?y.green(`"${e}"`):Array.isArray(e)?e.length===0?`[]`:`[${e.map(e=>An(e)).join(`,`)}]`:typeof e==`object`?jn(e):String(e)}function jn(e){let t=Object.entries(e);return t.length===0?`{}`:`{${t.map(([e,t])=>`${/^[\w$]+$/.test(e)?y.magenta(e):y.yellow(`"${e}"`)}:${An(t)}`).join(`,`)}}`}function Mn(){let e=new Date;return`${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}.${String(e.getMilliseconds()).padStart(3,`0`)}`}function Nn(e,t,n,r){let i=Mn(),a=On[e]??y.white,o={$:[i,e,t],_:r!=null&&Object.keys(r).length>0?{[String(n)]:r}:n},s={$:[i,a(e.toUpperCase()),t]},c=r!=null&&Object.keys(r).length>0?{[String(n)]:r}:n,l=jn({...s,_:c});return console.log(l),o}function Pn(e,t,n){let r=kn[e],i=kn[n];return(n,...a)=>r>i?{$:[Mn(),e,t],_:n}:typeof n==`string`?Nn(e,t,n,a.length===1&&typeof a[0]==`object`&&a[0]!==null?a[0]:a.length>0?{args:a}:void 0):typeof n==`object`&&n?Nn(e,t,``,n):Nn(e,t,n)}function Fn(e,t){let n=t??Tn??m.env.LOG_LEVEL??`info`;return{error:Pn(`error`,e,n),warn:Pn(`warn`,e,n),info:Pn(`info`,e,n),debug:Pn(`debug`,e,n),trace:Pn(`trace`,e,n),fatal:Pn(`fatal`,e,n)}}const In=`.tnmsc.json`,Ln=`.aindex`;function Rn(){return g.join(v.homedir(),Ln,In)}function zn(){return{...Yt}}function Bn(e,t){let n=Rn(),r=g.dirname(n);h.existsSync(r)||h.mkdirSync(r,{recursive:!0}),h.writeFileSync(n,`${JSON.stringify(e,null,2)}\n`,`utf-8`),t.info(`global config created`,{path:n})}var Vn=class{configFileName;searchCwd;searchGlobal;customSearchPaths;logger;constructor(e={}){this.configFileName=e.configFileName??In,this.searchCwd=e.searchCwd??!0,this.searchGlobal=e.searchGlobal??!0,this.customSearchPaths=e.searchPaths??[],this.logger=Fn(`ConfigLoader`)}getSearchPaths(e=m.cwd()){let t=[];for(let e of this.customSearchPaths)t.push(this.resolveTilde(e));return this.searchCwd&&t.push(g.join(e,this.configFileName)),this.searchGlobal&&t.push(g.join(v.homedir(),Ln,this.configFileName)),t}loadFromFile(e){let t=this.resolveTilde(e);try{if(!h.existsSync(t))return{config:{},source:null,found:!1};let e=h.readFileSync(t,`utf-8`),n=this.parseConfig(e,t);return this.logger.debug(`loaded`,{source:t}),{config:n,source:t,found:!0}}catch(e){return this.logger.warn(`load failed`,{path:t,error:e}),{config:{},source:null,found:!1}}}load(e=m.cwd()){let t=this.getSearchPaths(e),n=[];for(let e of t){let t=this.loadFromFile(e);t.found&&n.push(t)}return{config:this.mergeConfigs(n.map(e=>e.config)),sources:n.map(e=>e.source).filter(e=>e!==null),found:n.length>0}}parseConfig(e,t){try{let n=JSON.parse(e);if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`Config must be a JSON object`);return this.validateConfig(n,t)}catch(e){throw e instanceof SyntaxError?Error(`Invalid JSON in ${t}: ${e.message}`):e}}validateConfig(e,t){let n={},r=[];for(let t of[`workspaceDir`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`])t in e&&(typeof e[t]==`string`?n[t]=e[t]:r.push(`${t} must be a string`));if(`logLevel`in e){let t=[`trace`,`debug`,`info`,`warn`,`error`],i=e.logLevel;typeof i==`string`&&t.includes(i)?n.logLevel=i:r.push(`logLevel must be one of: ${t.join(`, `)}`)}if(`externalProjects`in e){let t=e.externalProjects;Array.isArray(t)?t.every(e=>typeof e==`string`)?n.externalProjects=t:r.push(`externalProjects must be an array of strings`):r.push(`externalProjects must be an array`)}if(`excludePatterns`in e){let t=e.excludePatterns;if(typeof t==`object`&&t){let e=t,i={},a=!0;for(let[t,n]of Object.entries(e))Array.isArray(n)&&n.every(e=>typeof e==`string`)?i[t]=n:(r.push(`excludePatterns.${t} must be an array of strings`),a=!1);a&&(n.excludePatterns=i)}else r.push(`excludePatterns must be an object`)}if(`profile`in e){let t=e.profile;typeof t==`object`&&t&&!Array.isArray(t)?n.profile=t:r.push(`profile must be an object`)}if(`tool`in e){let t=e.tool;if(typeof t==`object`&&t&&!Array.isArray(t)){let e=t,i={},a=!0;for(let[t,n]of Object.entries(e))typeof n==`string`||n===void 0?i[t]=n:(r.push(`tool.${t} must be a string`),a=!1);a&&(n.tool=i)}else r.push(`tool must be an object`)}return r.length>0&&this.logger.warn(`validation warnings`,{path:t,errors:r}),n}mergeConfigs(e){if(e.length===0)return{};let t=e[0];return e.length===1&&t!=null?t:[...e].reverse().reduce((e,t)=>{let n=[...e.externalProjects??[],...t.externalProjects??[]],r=this.mergeExcludePatterns(e.excludePatterns,t.excludePatterns);return{...e,...t,...n.length>0?{externalProjects:n}:{},...r==null?{}:{excludePatterns:r}}},{})}mergeExcludePatterns(e,t){if(e==null&&t==null)return null;if(e==null)return t??null;if(t==null)return e;let n={...e};for(let[e,r]of Object.entries(t))n[e]=[...n[e]??[],...r];return n}resolveTilde(e){return e.startsWith(`~`)?g.join(v.homedir(),e.slice(1)):e}};let Hn=null;function Un(e){return(e||!Hn)&&(Hn=new Vn(e)),Hn}function Wn(e){return Un().load(e)}function Gn(){let e=Fn(`ConfigLoader`),t=Rn();if(!h.existsSync(t))return e.warn(`global config not found, creating default config`,{path:t}),Bn(zn(),e),{valid:!0,exists:!1,errors:[],shouldExit:!1};let n;try{n=h.readFileSync(t,`utf-8`)}catch(n){let r=n instanceof Error?n.message:String(n);return e.error(`failed to read global config`,{path:t,error:r}),qn(t,e,[`Failed to read config: ${r}`])}let r;try{r=JSON.parse(n)}catch(n){let r=n instanceof Error?n.message:String(n);return e.error(`invalid JSON in global config`,{path:t,error:r}),qn(t,e,[`Invalid JSON: ${r}`])}if(typeof r!=`object`||!r||Array.isArray(r))return e.error(`global config must be a JSON object`,{path:t}),qn(t,e,[`Config must be a JSON object`]);let i=Kn(r);if(i.length>0){for(let n of i)e.error(`config validation error`,{path:t,error:n});return qn(t,e,i)}return{valid:!0,exists:!0,errors:[],shouldExit:!1}}function Kn(e){let t=[];for(let n of[`workspaceDir`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`])n in e&&typeof e[n]!=`string`&&t.push(`${n} must be a string`);if(`logLevel`in e){let n=[`trace`,`debug`,`info`,`warn`,`error`],r=e.logLevel;(typeof r!=`string`||!n.includes(r))&&t.push(`logLevel must be one of: ${n.join(`, `)}`)}if(`externalProjects`in e){let n=e.externalProjects;Array.isArray(n)?n.every(e=>typeof e==`string`)||t.push(`externalProjects must be an array of strings`):t.push(`externalProjects must be an array`)}if(`excludePatterns`in e){let n=e.excludePatterns;if(typeof n!=`object`||!n||Array.isArray(n))t.push(`excludePatterns must be an object`);else{let e=n;for(let[n,r]of Object.entries(e))(!Array.isArray(r)||!r.every(e=>typeof e==`string`))&&t.push(`excludePatterns.${n} must be an array of strings`)}}if(`profile`in e){let n=e.profile;(typeof n!=`object`||!n||Array.isArray(n))&&t.push(`profile must be an object`)}if(`tool`in e){let n=e.tool;if(typeof n!=`object`||!n||Array.isArray(n))t.push(`tool must be an object`);else{let e=n;for(let[n,r]of Object.entries(e))typeof r!=`string`&&r!==void 0&&t.push(`tool.${n} must be a string`)}}return t}function qn(e,t,n){try{h.unlinkSync(e),t.info(`deleted invalid config`,{path:e})}catch{t.warn(`failed to delete invalid config`,{path:e})}return Bn(zn(),t),t.error(`recreated default config, please review and restart`,{path:e}),{valid:!1,exists:!0,errors:n,shouldExit:!0}}const Jn=[`workspaceDir`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`,`logLevel`];function Yn(e){return Jn.includes(e)}function Xn(e){return[`trace`,`debug`,`info`,`warn`,`error`].includes(e)}function Zn(){return g.join(v.homedir(),Ln,In)}function Qn(){let e=Zn();if(!h.existsSync(e))return{};try{let t=h.readFileSync(e,`utf-8`);return JSON.parse(t)}catch{return{}}}function $n(e){let t=Zn(),n=g.dirname(t);h.existsSync(n)||h.mkdirSync(n,{recursive:!0}),h.writeFileSync(t,`${JSON.stringify(e,null,2)}\n`,`utf-8`)}var er=class{name=`set`;constructor(e){this.options=e}async execute(e){let{logger:t}=e;if(this.options.length===0)return t.error(`No configuration key-value pairs provided`),t.info(`Usage: tnmsc --set key=value or tnmsc set key=value`),t.info(`Valid keys: ${Jn.join(`, `)}`),{success:!1,filesAffected:0,dirsAffected:0,message:`No options provided`};let n=Qn(),r=[],i=[];for(let[e,a]of this.options){if(!Yn(e)){r.push(`Invalid key: ${e} (valid keys: ${Jn.join(`, `)})`);continue}if(e===`logLevel`&&!Xn(a)){r.push(`Invalid logLevel value: ${a} (must be: trace, debug, info, warn, or error)`);continue}let o=n[e];n[e]=a,o!==a&&i.push(`${e}=${a}`),t.info(`configuration updated`,{key:e,value:a})}if(i.length>0&&($n(n),t.info(`global config written`,{path:Zn()})),r.length>0)for(let e of r)t.error(e);let a=r.length===0,o=a?`Configuration updated: ${i.join(`, `)}`:`Partial update: ${i.join(`, `)}. Errors: ${r.join(`, `)}`;return{success:a,filesAffected:i.length>0?1:0,dirsAffected:0,message:o}}},tr=class{name=`unknown`;constructor(e){this.unknownCmd=e}async execute(e){return console.error(`Unknown command: ${this.unknownCmd}`),console.error(`Run "tnmsc help" for available commands.`),{success:!1,filesAffected:0,dirsAffected:0}}};const nr={default:{websearch:`web_search`,webfetch:`web_fetch`,readFile:`read_file`,writeFile:`write_file`,executeCommand:`execute_command`,todolistWrite:`todolist_write`,grep:`grep`},claudeCode:{readFile:`Read`,writeFile:`Write`,executeCommand:`Execute`,todolistWrite:`TodoWrite`},kiro:{websearch:`remote_web_search`,webfetch:`webFetch`,readFile:`readFile`,writeFile:`fsWrite`,executeCommand:`executeBash`,todolistWrite:`todolistWrite`,grep:`grepSearch`}};let rr=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}({}),ir=function(e){return e.Win=`win`,e.Mac=`mac`,e.Linux=`linux`,e.Unknown=`unknown`,e}({});var ar=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()}}collectOsInfo(){let e=v.platform();return{platform:e,arch:v.arch(),hostname:v.hostname(),homedir:v.homedir(),tmpdir:v.tmpdir(),type:v.type(),release:v.release(),shellKind:this.detectShellKind(),kind:this.detectOsKind(e)}}detectOsKind(e){switch(e){case`win32`:return ir.Win;case`darwin`:return ir.Mac;case`linux`:case`freebsd`:case`openbsd`:case`sunos`:case`aix`:return ir.Linux;default:return ir.Unknown}}detectShellKind(){let e=(m.env.SHELL??m.env.ComSpec??``).toLowerCase();return e.includes(`bash`)?rr.Bash:e.includes(`zsh`)?rr.Zsh:e.includes(`fish`)?rr.Fish:e.includes(`pwsh`)?rr.Pwsh:e.includes(`powershell`)?rr.PowerShell:e.includes(`cmd`)?rr.Cmd:e.endsWith(`/sh`)?rr.Sh:rr.Unknown}collectEnvContext(){return{...m.env}}collectProfile(){return this.userConfig?.profile==null?{}:this.userConfig.profile}collectToolReferences(){let e={...nr.default};return this.toolPreset===`claudeCode`?{...e,...nr.claudeCode}:this.toolPreset===`kiro`?{...e,...nr.kiro}:e}};let or=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 sr=class{registrations=[];globalScope=null;setGlobalScope(e){this.globalScope=e}getGlobalScope(){return this.globalScope}register(e,t,n=or.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))typeof r==`object`&&r&&!Array.isArray(r)?t[n]=this.deepMerge(t[n],r):t[n]=r;return t}deepMerge(e,t){if(e==null)return{...t};let n={...e};for(let[e,r]of Object.entries(t))typeof r==`object`&&r&&!Array.isArray(r)&&typeof n[e]==`object`&&n[e]!==null&&!Array.isArray(n[e])?n[e]=this.deepMerge(n[e],r):n[e]=r;return n}clear(){this.registrations.length=0,this.globalScope=null}};function cr(e){let t=[...e],n=t[0];n!=null&&lr(n)&&t.shift();let r=t[0];return r!=null&&ur(r)&&t.shift(),t}function lr(e){let t=[`node`,`nodejs`,`bun`,`deno`,`tsx`,`ts-node`,`npx`,`pnpx`,`yarn`,`pnpm`],n=e.toLowerCase().replace(/\\/g,`/`);return t.some(e=>RegExp(`(?:^|/)${e}(?:\\.exe|\\.cmd|\\.ps1)?$`,`i`).test(n)||n===e)}function ur(e){return!!(/\.(?:m?[jt]s|cjs)$/.test(e)||/[/\\]/.test(e)&&!e.startsWith(`-`)||/^(?:@[\w-]+\/)?[\w-]+$/.test(e)&&!e.startsWith(`-`))}const dr=new Set([`help`,`version`,`outdated`,`init`,`dry-run`,`clean`,`set`]),fr=new Map([[`--trace`,`trace`],[`--debug`,`debug`],[`--info`,`info`],[`--warn`,`warn`],[`--error`,`error`]]),pr=new Map([[`trace`,0],[`debug`,1],[`info`,2],[`warn`,3],[`error`,4]]);function mr(e){let{logLevelFlags:t}=e;if(t.length===0)return;let n=t[0],r=pr.get(n)??4;for(let e of t){let t=pr.get(e)??4;t<r&&(r=t,n=e)}return n}function hr(e){let{helpFlag:t,versionFlag:n,subcommand:r,dryRun:i,unknownCommand:a,setOption:o,positional:s}=e;if(n)return new Gt;if(t)return new qt;if(a!=null)return new tr(a);if(r===`version`)return new Gt;if(r===`help`)return new qt;if(r===`outdated`)return new wn;if(r===`init`)return new fn;if(r===`dry-run`)return new Ht;if(r===`clean`)return i?new Vt:new Et;if(r===`set`||o.length>0){let e=[];for(let t of s){let n=t.indexOf(`=`);n>0&&e.push([t.slice(0,n),t.slice(n+1)])}return new er([...o,...e])}return new Ut}function gr(e){let t={subcommand:void 0,helpFlag:!1,versionFlag:!1,dryRun:!1,logLevel:void 0,logLevelFlags:[],setOption:[],unknownCommand:void 0,positional:[],unknown:[]},n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i!=null){if(i===`--`){t.positional.push(...e.slice(r+1).filter(e=>e!=null));break}if(i.startsWith(`--`)){let n=i.split(`=`),a=n[0]??``,o=fr.get(a);if(o!=null){t.logLevelFlags.push(o),t.logLevel=o;continue}switch(a){case`--help`:t.helpFlag=!0;break;case`--version`:t.versionFlag=!0;break;case`--dry-run`:t.dryRun=!0;break;case`--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;default:t.unknown.push(`-${n}`)}continue}if(!n){n=!0,dr.has(i)?t.subcommand=i:t.unknownCommand=i;continue}t.positional.push(i)}}return t}var _r=class{logger;args;outputPlugins=[];constructor(...e){this.args=gr(cr(e.filter(e=>e!=null)));let t=mr(this.args);t!=null&&En(t),this.logger=Fn(`PluginPipeline`,t),this.logger.debug(`initialized`,{args:this.args})}registerOutputPlugins(e){return this.outputPlugins.push(...e),this}async run(e){Cn(this.logger);let{context:t,outputPlugins:n,userConfigOptions:r}=e;this.registerOutputPlugins([...n]);let i=this.resolveCommand(),a=this.createCommandContext(t,r);await i.execute(a)}resolveCommand(){return hr(this.args)}createCommandContext(e,t){return{logger:this.logger,outputPlugins:this.outputPlugins,collectedInputContext:e,userConfigOptions:t,createCleanContext:t=>this.createCleanContext(e,t),createWriteContext:t=>this.createWriteContext(e,t)}}createCleanContext(e,t){return{logger:this.logger,fs:h,path:g,glob:gt.default,collectedInputContext:e,dryRun:t}}createWriteContext(e,t){return{logger:this.logger,fs:h,path:g,glob:gt.default,collectedInputContext:e,dryRun:t,registeredPluginNames:this.outputPlugins.map(e=>e.name)}}buildDependencyGraph(e){let t=new Map;for(let n of e){let e=n.dependsOn??[];t.set(n.name,[...e])}return t}validateDependencies(e){let t=new Set(e.map(e=>e.name));for(let n of e){let e=n.dependsOn??[];for(let r of e)if(!t.has(r))throw new a(n.name,r)}}topologicalSort(t){this.validateDependencies(t);let n=new Map;for(let e of t)n.set(e.name,e);let r=new Map;for(let e of t)r.set(e.name,0);let i=new Map;for(let e of t)i.set(e.name,[]);for(let e of t){let t=e.dependsOn??[];for(let n of t){r.set(e.name,(r.get(e.name)??0)+1);let t=i.get(n)??[];t.push(e.name),i.set(n,t)}}let a=[];for(let e of t)r.get(e.name)===0&&a.push(e.name);let o=[];for(;a.length>0;){let e=a.shift(),s=n.get(e);o.push(s);let c=(i.get(e)??[]).sort((e,n)=>t.findIndex(t=>t.name===e)-t.findIndex(e=>e.name===n));for(let e of c){let t=(r.get(e)??0)-1;r.set(e,t),t===0&&a.push(e)}}if(o.length!==t.length)throw new e(this.findCyclePath(t,r));return o}findCyclePath(e,t){let n=new Set;for(let[e,r]of t)r>0&&n.add(e);let r=new Map;for(let t of e)if(n.has(t.name)){let e=(t.dependsOn??[]).filter(e=>n.has(e));r.set(t.name,e)}let i=new Set,a=[],o=e=>{if(a.includes(e))return a.push(e),!0;if(i.has(e))return!1;i.add(e),a.push(e);for(let t of r.get(e)??[])if(o(t))return!0;return a.pop(),!1};for(let e of n){if(o(e)){let e=a.indexOf(a[a.length-1]);return a.slice(e)}i.clear(),a.length=0}return Array.from(n)}async executePluginsInOrder(e,t,n=!1,r){if(e.length===0)return{};let i=this.topologicalSort(e),a=new ar({userConfig:r}).collect(),o=new sr;o.setGlobalScope(a),this.logger.debug(`global scope collected`,{osInfo:{platform:a.os.platform,arch:a.os.arch,shellKind:a.os.shellKind},hasProfile:Object.keys(a.profile).length>0,hasTool:Object.keys(a.tool).length>0});let s=new Map,c={};for(let e of i){let r=this.buildDependencyContext(e,s),i={...t,dependencyContext:r,globalScope:a,scopeRegistry:o},l=e;l.executeEffects!=null&&await l.executeEffects(i,n);let u=await e.collect(i);s.set(e.name,u),c=this.mergeContexts(c,u);let d=e;if(d.getRegisteredScopes!=null){let t=d.getRegisteredScopes();for(let{namespace:n,values:r}of t)o.register(n,r,or.PluginRegistered),this.logger.debug(`plugin scope registered`,{plugin:e.name,namespace:n,keys:Object.keys(r)})}}return c}buildDependencyContext(e,t){if((e.dependsOn??[]).length===0)return{};let n=this.collectTransitiveDependencies(e,t),r={};for(let e of n){let n=t.get(e);n!=null&&(r=this.mergeContexts(r,n))}return r}collectTransitiveDependencies(e,t){let n=new Set,r=[];return(e=>{for(let i of e)n.has(i)||(n.add(i),t.get(i)!=null&&r.push(i))})(e.dependsOn??[]),r}mergeContexts(e,t){let n=e.workspace;if(t.workspace!=null)if(n!=null){let e=new Map;for(let t of n.projects)e.set(t.name,t);for(let n of t.workspace.projects)e.set(n.name,n);n={directory:t.workspace.directory??n.directory,projects:Array.from(e.values())}}else n=t.workspace;let r=t.externalProjects==null?e.externalProjects:[...e.externalProjects??[],...t.externalProjects],i=t.ideConfigFiles==null?e.ideConfigFiles:[...e.ideConfigFiles??[],...t.ideConfigFiles],a=t.fastCommands==null?e.fastCommands:[...e.fastCommands??[],...t.fastCommands],o=t.subAgents==null?e.subAgents:[...e.subAgents??[],...t.subAgents],s=t.skills==null?e.skills:[...e.skills??[],...t.skills],c=t.aiAgentIgnoreConfigFiles==null?e.aiAgentIgnoreConfigFiles:[...e.aiAgentIgnoreConfigFiles??[],...t.aiAgentIgnoreConfigFiles],l=t.globalMemory??e.globalMemory,u=t.shadowSourceProjectDir??e.shadowSourceProjectDir,d=t.readmePrompts==null?e.readmePrompts:[...e.readmePrompts??[],...t.readmePrompts];return{...n==null?{}:{workspace:n},...r==null?{}:{externalProjects:r},...i==null?{}:{ideConfigFiles:i},...a==null?{}:{fastCommands:a},...o==null?{}:{subAgents:o},...s==null?{}:{skills:s},...c==null?{}:{aiAgentIgnoreConfigFiles:c},...l==null?{}:{globalMemory:l},...u==null?{}:{shadowSourceProjectDir:u},...d==null?{}:{readmePrompts:d}}}};const vr={...Yt,externalProjects:[],excludePatterns:{},fastCommandSeriesOptions:{},plugins:[]};function yr(e){return{...e.workspaceDir==null?{}:{workspaceDir:e.workspaceDir},...e.shadowSourceProjectDir==null?{}:{shadowSourceProjectDir:e.shadowSourceProjectDir},...e.shadowSkillSourceDir==null?{}:{shadowSkillSourceDir:e.shadowSkillSourceDir},...e.shadowFastCommandDir==null?{}:{shadowFastCommandDir:e.shadowFastCommandDir},...e.shadowSubAgentDir==null?{}:{shadowSubAgentDir:e.shadowSubAgentDir},...e.globalMemoryFile==null?{}:{globalMemoryFile:e.globalMemoryFile},...e.shadowProjectsDir==null?{}:{shadowProjectsDir:e.shadowProjectsDir},...e.externalProjects==null?{}:{externalProjects:e.externalProjects},...e.excludePatterns==null?{}:{excludePatterns:e.excludePatterns},...e.fastCommandSeriesOptions==null?{}:{fastCommandSeriesOptions:e.fastCommandSeriesOptions},...e.logLevel==null?{}:{logLevel:e.logLevel}}}function br(...e){return e.reduce((e,t)=>xr(e,t),{...vr})}function xr(e,t){let n=t.externalProjects,r=t.plugins,i=t.excludePatterns,a=t.fastCommandSeriesOptions;return{...e,...t,externalProjects:[...e.externalProjects,...n??[]],plugins:[...e.plugins,...r??[]],excludePatterns:Sr(e.excludePatterns,i),fastCommandSeriesOptions:Cr(e.fastCommandSeriesOptions,a)}}function Sr(e,t){let n={...e};if(t)for(let[e,r]of Object.entries(t))n[e]=[...n[e]??[],...r];return n}function Cr(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 wr(e){return`pluginOptions`in e||`configLoaderOptions`in e||`loadUserConfig`in e}async function Tr(e={}){Gn().shouldExit&&m.exit(1);let t,n,r;wr(e)?(t=e.pluginOptions??{},n=e.loadUserConfig??!0,r=e.cwd):(t=e,n=!0);let i={},a=!1,o=[],s;if(n){let e=Wn(r);a=e.found,o=e.sources,e.found&&(i=yr(e.config),s=e.config)}let c=br(i,t),{plugins:l=[],logLevel:u}=c,d=Fn(`defineConfig`,u);a?d.info(`user config loaded`,{sources:o}):d.info(`no user config found, using defaults`,{workspaceDir:vr.workspaceDir,shadowSourceProjectDir:vr.shadowSourceProjectDir,shadowSkillSourceDir:vr.shadowSkillSourceDir,shadowFastCommandDir:vr.shadowFastCommandDir,shadowSubAgentDir:vr.shadowSubAgentDir,globalMemoryFile:vr.globalMemoryFile,shadowProjectsDir:vr.shadowProjectsDir,logLevel:vr.logLevel});let f={logger:d,userConfigOptions:c,fs:h,path:g,glob:gt.default},p=l.filter(e=>e.type===Dt.Input),_=l.filter(e=>e.type===Dt.Output),v=await new _r().executePluginsInOrder(p,f,!1,s);if(v.workspace==null)throw Error(`Workspace not initialized by any plugin`);let y={workspace:v.workspace,ideConfigFiles:v.ideConfigFiles??[],...v.externalProjects!=null&&{externalProjects:v.externalProjects},...v.fastCommands!=null&&{fastCommands:v.fastCommands},...v.subAgents!=null&&{subAgents:v.subAgents},...v.skills!=null&&{skills:v.skills},...v.globalMemory!=null&&{globalMemory:v.globalMemory},...v.aiAgentIgnoreConfigFiles!=null&&{aiAgentIgnoreConfigFiles:v.aiAgentIgnoreConfigFiles},...v.shadowSourceProjectDir!=null&&{shadowSourceProjectDir:v.shadowSourceProjectDir},...v.readmePrompts!=null&&{readmePrompts:v.readmePrompts}};return v.shadowSourceProjectDir!=null&&Xt(v.shadowSourceProjectDir,d),{context:y,outputPlugins:_,userConfigOptions:c}}const z=Nr(/[A-Za-z]/),B=Nr(/[\dA-Za-z]/),Er=Nr(/[#-'*+\--9=?A-Z^-~]/);function Dr(e){return e!==null&&(e<32||e===127)}const Or=Nr(/\d/),kr=Nr(/[\dA-Fa-f]/),Ar=Nr(/[!-/:-@[-`{-~]/);function V(e){return e!==null&&e<-2}function H(e){return e!==null&&(e<0||e===32)}function U(e){return e===-2||e===-1||e===32}const jr=Nr(/\p{P}|\p{S}/u),Mr=Nr(/\s/);function Nr(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}var Pr=re(j(((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 Fr=Object.assign(Ir(Error),{eval:Ir(EvalError),range:Ir(RangeError),reference:Ir(ReferenceError),syntax:Ir(SyntaxError),type:Ir(TypeError),uri:Ir(URIError)});function Ir(e){return t.displayName=e.displayName||e.name,t;function t(t,...n){return new e(t&&(0,Pr.default)(t,...n))}}const Lr={}.hasOwnProperty,Rr={yaml:`-`,toml:`+`};function zr(e){let t=[],n=-1,r=Array.isArray(e)?e:e?[e]:[`yaml`];for(;++n<r.length;)t[n]=Br(r[n]);return t}function Br(e){let t=e;if(typeof t==`string`){if(!Lr.call(Rr,t))throw Fr("Missing matter definition for `%s`",t);t={type:t,marker:Rr[t]}}else if(typeof t!=`object`)throw Fr("Expected matter to be an object, not `%j`",t);if(!Lr.call(t,`type`))throw Fr("Missing `type` in matter `%j`",t);if(!Lr.call(t,`fence`)&&!Lr.call(t,`marker`))throw Fr("Missing `marker` or `fence` in matter `%j`",t);return t}function Vr(e){let t=zr(e),n={},r=-1;for(;++r<t.length;){let e=t[r],i=Ur(e,`open`).charCodeAt(0),a=Hr(e),o=n[i];Array.isArray(o)?o.push(a):n[i]=[a]}return{flow:n}}function Hr(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=Ur(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),U(e)?(l.enter(`whitespace`),h(e)):g(e)):e===s.charCodeAt(c++)?(l.consume(e),m):d(e)}function h(e){return U(e)?(l.consume(e),h):(l.exit(`whitespace`),g(e))}function g(t){return V(t)?(l.exit(r),l.enter(`lineEnding`),l.consume(t),l.exit(`lineEnding`),s=Ur(e,`close`),c=0,l.attempt(o,b,_)):d(t)}function _(e){return e===null||V(e)?y(e):(l.enter(a),v(e))}function v(e){return e===null||V(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),U(t)?(e.enter(`whitespace`),l(t)):u(t)):t===s.charCodeAt(a++)?(e.consume(t),c):n(t)}function l(t){return U(t)?(e.consume(t),l):(e.exit(`whitespace`),u(t))}function u(i){return i===null||V(i)?(e.exit(r),t(i)):n(i)}}}function Ur(e,t){return e.marker?Wr(e.marker,t).repeat(3):Wr(e.fence,t)}function Wr(e,t){return typeof e==`string`?e:e[t]}function Gr(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function Kr(e){let t=zr(e),n={},r={},i=-1;for(;++i<t.length;){let e=t[i];n[e.type]=qr(e),r[e.type]=Jr,r[e.type+`Value`]=Yr}return{enter:n,exit:r}}function qr(e){return t;function t(t){this.enter({type:e.type,value:``},t),this.buffer()}}function Jr(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 Yr(e){this.config.enter.data.call(this,e),this.config.exit.data.call(this,e)}function Xr(e){let t=[],n={},r=zr(e),i=-1;for(;++i<r.length;){let e=r[i];n[e.type]=Zr(e);let a=Qr(e,`open`);t.push({atBreak:!0,character:a.charAt(0),after:Gr(a.charAt(1))})}return{unsafe:t,handlers:n}}function Zr(e){let t=Qr(e,`open`),n=Qr(e,`close`);return r;function r(e){return t+(e.value?`
|
|
143
|
+
`}function dn(e,t,n){let r=e;return r=r.replace(Jt.SHADOW_SOURCE_PROJECT,n),r=r.replace(Jt.WORKSPACE,t),r.startsWith(`~`)&&(r=g.join(v.homedir(),r.slice(1))),g.normalize(r)}var fn=class{name=`init`;async execute(e){let{logger:t,userConfigOptions:n}=e;t.info(`initializing shadow source project structure`,{command:`init`});let r=dn(n.workspaceDir,``,``),i=nn(dn(n.shadowSourceProjectDir,r,``),{logger:t}),a=i.createdDirs.length===0&&i.createdFiles.length===0?`All ${i.existedDirs.length} directories and ${i.existedFiles.length} files already exist`:`Created ${i.createdDirs.length} directories and ${i.createdFiles.length} files (${i.existedDirs.length} dirs, ${i.existedFiles.length} files already existed)`;return t.info(`initialization complete`,{dirsCreated:i.createdDirs.length,filesCreated:i.createdFiles.length,dirsExisted:i.existedDirs.length,filesExisted:i.existedFiles.length}),{success:i.success,filesAffected:i.createdFiles.length,dirsAffected:i.createdDirs.length,message:a}}};function pn(){return`@truenine/memory-sync-cli`}function mn(){return`https://registry.npmjs.org/${pn()}/latest`}function hn(e){let t=e.replace(/^v/,``),n=/^(\d+)\.(\d+)\.(\d+)/.exec(t);return n==null?null:[Number.parseInt(n[1],10),Number.parseInt(n[2],10),Number.parseInt(n[3],10)]}function gn(e,t){let n=hn(e),r=hn(t);if(n==null||r==null)return 0;for(let e=0;e<3;e++){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1}return 0}const _n=3e3;async function vn(){let e=new AbortController,t=setTimeout(()=>e.abort(),_n);typeof t==`object`&&`unref`in t&&t.unref();try{let n=await fetch(mn(),{headers:{Accept:`application/json`},signal:e.signal});if(clearTimeout(t),!n.ok)return{error:`HTTP ${n.status}: ${n.statusText}`};let r=await n.json();return r.version==null?{error:`Invalid response: missing version field`}:{version:r.version}}catch(e){return clearTimeout(t),e instanceof Error?e.name===`TimeoutError`||e.name===`AbortError`?{error:`Request timeout after ${_n}ms`}:{error:e.message}:{error:`Unknown network error`}}}function yn(){return`2026.10107.0`}async function bn(){let e=yn();if(e===`dev`)return{status:`development`,localVersion:e,remoteVersion:null};let t=await vn();if(`error`in t)return{status:`current`,localVersion:e,remoteVersion:null,error:t.error};let n=t.version,r=gn(e,n);return r<0?{status:`outdated`,localVersion:e,remoteVersion:n}:r>0?{status:`development`,localVersion:e,remoteVersion:n}:{status:`current`,localVersion:e,remoteVersion:n}}function xn(e,t){let{status:n,localVersion:r,remoteVersion:i}=e;switch(n){case`outdated`:t.warn(`Version outdated: ${r} → ${i}. Run 'npm i -g ${pn()}@latest' to update.`);break;case`current`:e.error==null?t.info(`Version ${r} is up to date.`):t.error(`Version check failed: ${e.error}`);break;case`development`:i==null?t.debug(`Running in development mode, version check skipped.`):t.info(`Development version detected: ${r} > ${i}. Thanks for contributing!`);break}}function Sn(){return new Date().getMinutes()%2==0}function Cn(e){Sn()&&bn().then(t=>{(t.status===`outdated`||t.error!=null)&&xn(t,e)}).catch(t=>{let n=t instanceof Error?t.message:`Unknown error`;e.error(`Version check failed: ${n}`)})}var wn=class{name=`outdated`;async execute(e){let t=await bn();return xn(t,e.logger),{success:!0,filesAffected:0,dirsAffected:0,message:`Version status: ${t.status}`}}};let Tn;function En(e){Tn=e}function Dn(){return Tn}const On={error:y.red,warn:y.yellow,info:y.cyan,debug:y.magenta,trace:y.gray,fatal:y.bgRed},kn={silent:0,fatal:1,error:2,warn:3,info:4,debug:5,trace:6};function An(e){return e===null?y.dim(`null`):e===void 0?y.dim(`undefined`):typeof e==`boolean`?y.yellow(String(e)):typeof e==`number`?y.blue(String(e)):typeof e==`string`?y.green(`"${e}"`):Array.isArray(e)?e.length===0?`[]`:`[${e.map(e=>An(e)).join(`,`)}]`:typeof e==`object`?jn(e):String(e)}function jn(e){let t=Object.entries(e);return t.length===0?`{}`:`{${t.map(([e,t])=>`${/^[\w$]+$/.test(e)?y.magenta(e):y.yellow(`"${e}"`)}:${An(t)}`).join(`,`)}}`}function Mn(){let e=new Date;return`${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}.${String(e.getMilliseconds()).padStart(3,`0`)}`}function Nn(e,t,n,r){let i=Mn(),a=On[e]??y.white,o={$:[i,e,t],_:r!=null&&Object.keys(r).length>0?{[String(n)]:r}:n},s={$:[i,a(e.toUpperCase()),t]},c=r!=null&&Object.keys(r).length>0?{[String(n)]:r}:n,l=jn({...s,_:c});return console.log(l),o}function Pn(e,t,n){let r=kn[e],i=kn[n];return(n,...a)=>r>i?{$:[Mn(),e,t],_:n}:typeof n==`string`?Nn(e,t,n,a.length===1&&typeof a[0]==`object`&&a[0]!==null?a[0]:a.length>0?{args:a}:void 0):typeof n==`object`&&n?Nn(e,t,``,n):Nn(e,t,n)}function Fn(e,t){let n=t??Tn??m.env.LOG_LEVEL??`info`;return{error:Pn(`error`,e,n),warn:Pn(`warn`,e,n),info:Pn(`info`,e,n),debug:Pn(`debug`,e,n),trace:Pn(`trace`,e,n),fatal:Pn(`fatal`,e,n)}}const In=`.tnmsc.json`,Ln=`.aindex`;function Rn(){return g.join(v.homedir(),Ln,In)}function zn(){return{...Yt}}function Bn(e,t){let n=Rn(),r=g.dirname(n);h.existsSync(r)||h.mkdirSync(r,{recursive:!0}),h.writeFileSync(n,`${JSON.stringify(e,null,2)}\n`,`utf8`),t.info(`global config created`,{path:n})}var Vn=class{configFileName;searchCwd;searchGlobal;customSearchPaths;logger;constructor(e={}){this.configFileName=e.configFileName??In,this.searchCwd=e.searchCwd??!0,this.searchGlobal=e.searchGlobal??!0,this.customSearchPaths=e.searchPaths??[],this.logger=Fn(`ConfigLoader`)}getSearchPaths(e=m.cwd()){let t=[];for(let e of this.customSearchPaths)t.push(this.resolveTilde(e));return this.searchCwd&&t.push(g.join(e,this.configFileName)),this.searchGlobal&&t.push(g.join(v.homedir(),Ln,this.configFileName)),t}loadFromFile(e){let t=this.resolveTilde(e);try{if(!h.existsSync(t))return{config:{},source:null,found:!1};let e=h.readFileSync(t,`utf8`),n=this.parseConfig(e,t);return this.logger.debug(`loaded`,{source:t}),{config:n,source:t,found:!0}}catch(e){return this.logger.warn(`load failed`,{path:t,error:e}),{config:{},source:null,found:!1}}}load(e=m.cwd()){let t=this.getSearchPaths(e),n=[];for(let e of t){let t=this.loadFromFile(e);t.found&&n.push(t)}return{config:this.mergeConfigs(n.map(e=>e.config)),sources:n.map(e=>e.source).filter(e=>e!==null),found:n.length>0}}parseConfig(e,t){try{let n=JSON.parse(e);if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`Config must be a JSON object`);return this.validateConfig(n,t)}catch(e){throw e instanceof SyntaxError?Error(`Invalid JSON in ${t}: ${e.message}`):e}}validateConfig(e,t){let n={},r=[];for(let t of[`workspaceDir`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`])t in e&&(typeof e[t]==`string`?n[t]=e[t]:r.push(`${t} must be a string`));if(`logLevel`in e){let t=[`trace`,`debug`,`info`,`warn`,`error`],i=e.logLevel;typeof i==`string`&&t.includes(i)?n.logLevel=i:r.push(`logLevel must be one of: ${t.join(`, `)}`)}if(`externalProjects`in e){let t=e.externalProjects;Array.isArray(t)?t.every(e=>typeof e==`string`)?n.externalProjects=t:r.push(`externalProjects must be an array of strings`):r.push(`externalProjects must be an array`)}if(`excludePatterns`in e){let t=e.excludePatterns;if(typeof t==`object`&&t){let e=t,i={},a=!0;for(let[t,n]of Object.entries(e))Array.isArray(n)&&n.every(e=>typeof e==`string`)?i[t]=n:(r.push(`excludePatterns.${t} must be an array of strings`),a=!1);a&&(n.excludePatterns=i)}else r.push(`excludePatterns must be an object`)}if(`profile`in e){let t=e.profile;typeof t==`object`&&t&&!Array.isArray(t)?n.profile=t:r.push(`profile must be an object`)}if(`tool`in e){let t=e.tool;if(typeof t==`object`&&t&&!Array.isArray(t)){let e=t,i={},a=!0;for(let[t,n]of Object.entries(e))typeof n==`string`||n===void 0?i[t]=n:(r.push(`tool.${t} must be a string`),a=!1);a&&(n.tool=i)}else r.push(`tool must be an object`)}return r.length>0&&this.logger.warn(`validation warnings`,{path:t,errors:r}),n}mergeConfigs(e){if(e.length===0)return{};let t=e[0];return e.length===1&&t!=null?t:[...e].reverse().reduce((e,t)=>{let n=[...e.externalProjects??[],...t.externalProjects??[]],r=this.mergeExcludePatterns(e.excludePatterns,t.excludePatterns);return{...e,...t,...n.length>0?{externalProjects:n}:{},...r==null?{}:{excludePatterns:r}}},{})}mergeExcludePatterns(e,t){if(e==null&&t==null)return null;if(e==null)return t??null;if(t==null)return e;let n={...e};for(let[e,r]of Object.entries(t))n[e]=[...n[e]??[],...r];return n}resolveTilde(e){return e.startsWith(`~`)?g.join(v.homedir(),e.slice(1)):e}};let Hn=null;function Un(e){return(e||!Hn)&&(Hn=new Vn(e)),Hn}function Wn(e){return Un().load(e)}function Gn(){let e=Fn(`ConfigLoader`),t=Rn();if(!h.existsSync(t))return e.warn(`global config not found, creating default config`,{path:t}),Bn(zn(),e),{valid:!0,exists:!1,errors:[],shouldExit:!1};let n;try{n=h.readFileSync(t,`utf8`)}catch(n){let r=n instanceof Error?n.message:String(n);return e.error(`failed to read global config`,{path:t,error:r}),qn(t,e,[`Failed to read config: ${r}`])}let r;try{r=JSON.parse(n)}catch(n){let r=n instanceof Error?n.message:String(n);return e.error(`invalid JSON in global config`,{path:t,error:r}),qn(t,e,[`Invalid JSON: ${r}`])}if(typeof r!=`object`||!r||Array.isArray(r))return e.error(`global config must be a JSON object`,{path:t}),qn(t,e,[`Config must be a JSON object`]);let i=Kn(r);if(i.length>0){for(let n of i)e.error(`config validation error`,{path:t,error:n});return qn(t,e,i)}return{valid:!0,exists:!0,errors:[],shouldExit:!1}}function Kn(e){let t=[];for(let n of[`workspaceDir`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`])n in e&&typeof e[n]!=`string`&&t.push(`${n} must be a string`);if(`logLevel`in e){let n=[`trace`,`debug`,`info`,`warn`,`error`],r=e.logLevel;(typeof r!=`string`||!n.includes(r))&&t.push(`logLevel must be one of: ${n.join(`, `)}`)}if(`externalProjects`in e){let n=e.externalProjects;Array.isArray(n)?n.every(e=>typeof e==`string`)||t.push(`externalProjects must be an array of strings`):t.push(`externalProjects must be an array`)}if(`excludePatterns`in e){let n=e.excludePatterns;if(typeof n!=`object`||!n||Array.isArray(n))t.push(`excludePatterns must be an object`);else{let e=n;for(let[n,r]of Object.entries(e))(!Array.isArray(r)||!r.every(e=>typeof e==`string`))&&t.push(`excludePatterns.${n} must be an array of strings`)}}if(`profile`in e){let n=e.profile;(typeof n!=`object`||!n||Array.isArray(n))&&t.push(`profile must be an object`)}if(!(`tool`in e))return t;let n=e.tool;if(typeof n!=`object`||!n||Array.isArray(n))t.push(`tool must be an object`);else{let e=n;for(let[n,r]of Object.entries(e))typeof r!=`string`&&r!==void 0&&t.push(`tool.${n} must be a string`)}return t}function qn(e,t,n){try{h.unlinkSync(e),t.info(`deleted invalid config`,{path:e})}catch{t.warn(`failed to delete invalid config`,{path:e})}return Bn(zn(),t),t.error(`recreated default config, please review and restart`,{path:e}),{valid:!1,exists:!0,errors:n,shouldExit:!0}}const Jn=[`workspaceDir`,`shadowSourceProjectDir`,`shadowSkillSourceDir`,`shadowFastCommandDir`,`shadowSubAgentDir`,`globalMemoryFile`,`shadowProjectsDir`,`logLevel`];function Yn(e){return Jn.includes(e)}function Xn(e){return[`trace`,`debug`,`info`,`warn`,`error`].includes(e)}function Zn(){return g.join(v.homedir(),Ln,In)}function Qn(){let e=Zn();if(!h.existsSync(e))return{};try{let t=h.readFileSync(e,`utf8`);return JSON.parse(t)}catch{return{}}}function $n(e){let t=Zn(),n=g.dirname(t);h.existsSync(n)||h.mkdirSync(n,{recursive:!0}),h.writeFileSync(t,`${JSON.stringify(e,null,2)}\n`,`utf8`)}var er=class{name=`set`;constructor(e){this.options=e}async execute(e){let{logger:t}=e;if(this.options.length===0)return t.error(`No configuration key-value pairs provided`),t.info(`Usage: tnmsc --set key=value or tnmsc set key=value`),t.info(`Valid keys: ${Jn.join(`, `)}`),{success:!1,filesAffected:0,dirsAffected:0,message:`No options provided`};let n=Qn(),r=[],i=[];for(let[e,a]of this.options){if(!Yn(e)){r.push(`Invalid key: ${e} (valid keys: ${Jn.join(`, `)})`);continue}if(e===`logLevel`&&!Xn(a)){r.push(`Invalid logLevel value: ${a} (must be: trace, debug, info, warn, or error)`);continue}let o=n[e];n[e]=a,o!==a&&i.push(`${e}=${a}`),t.info(`configuration updated`,{key:e,value:a})}if(i.length>0&&($n(n),t.info(`global config written`,{path:Zn()})),r.length>0)for(let e of r)t.error(e);let a=r.length===0,o=a?`Configuration updated: ${i.join(`, `)}`:`Partial update: ${i.join(`, `)}. Errors: ${r.join(`, `)}`;return{success:a,filesAffected:i.length>0?1:0,dirsAffected:0,message:o}}},tr=class{name=`unknown`;constructor(e){this.unknownCmd=e}async execute(e){return console.error(`Unknown command: ${this.unknownCmd}`),console.error(`Run "tnmsc help" for available commands.`),{success:!1,filesAffected:0,dirsAffected:0}}};const nr={default:{websearch:`web_search`,webfetch:`web_fetch`,readFile:`read_file`,writeFile:`write_file`,executeCommand:`execute_command`,todolistWrite:`todolist_write`,grep:`grep`},claudeCode:{readFile:`Read`,writeFile:`Write`,executeCommand:`Execute`,todolistWrite:`TodoWrite`},kiro:{websearch:`remote_web_search`,webfetch:`webFetch`,readFile:`readFile`,writeFile:`fsWrite`,executeCommand:`executeBash`,todolistWrite:`todolistWrite`,grep:`grepSearch`}};let rr=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}({}),ir=function(e){return e.Win=`win`,e.Mac=`mac`,e.Linux=`linux`,e.Unknown=`unknown`,e}({});var ar=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=v.platform();return{platform:e,arch:v.arch(),hostname:v.hostname(),homedir:v.homedir(),tmpdir:v.tmpdir(),type:v.type(),release:v.release(),shellKind:this.detectShellKind(),kind:this.detectOsKind(e)}}detectOsKind(e){switch(e){case`win32`:return ir.Win;case`darwin`:return ir.Mac;case`linux`:case`freebsd`:case`openbsd`:case`sunos`:case`aix`:return ir.Linux;default:return ir.Unknown}}detectShellKind(){let e=(m.env.SHELL??m.env.ComSpec??``).toLowerCase();return e.includes(`bash`)?rr.Bash:e.includes(`zsh`)?rr.Zsh:e.includes(`fish`)?rr.Fish:e.includes(`pwsh`)?rr.Pwsh:e.includes(`powershell`)?rr.PowerShell:e.includes(`cmd`)?rr.Cmd:e.endsWith(`/sh`)?rr.Sh:rr.Unknown}collectEnvContext(){return{...m.env}}collectProfile(){return this.userConfig?.profile==null?{}:this.userConfig.profile}collectToolReferences(){let e={...nr.default};return this.toolPreset===`claudeCode`?{...e,...nr.claudeCode}:this.toolPreset===`kiro`?{...e,...nr.kiro}:e}createMdComponent(){let e=(e=>e.when===!1?null:e.children);return e.Line=e=>e.when===!1?null:e.children,e}};let or=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 sr=class{registrations=[];globalScope=null;setGlobalScope(e){this.globalScope=e}getGlobalScope(){return this.globalScope}register(e,t,n=or.PluginRegistered){this.registrations.push({namespace:e,values:t,priority:n})}getRegistrations(){return this.registrations}merge(e){let t={};this.globalScope!=null&&(t.os={...this.globalScope.os},t.env={...this.globalScope.env},t.profile={...this.globalScope.profile},t.tool={...this.globalScope.tool});let n=[...this.registrations].sort((e,t)=>e.priority-t.priority);for(let e of n)t[e.namespace]=this.deepMerge(t[e.namespace],e.values);if(e!=null)for(let[n,r]of Object.entries(e))t[n]=typeof r==`object`&&r&&!Array.isArray(r)?this.deepMerge(t[n],r):r;return t}deepMerge(e,t){if(e==null)return{...t};let n={...e};for(let[e,r]of Object.entries(t))n[e]=typeof r==`object`&&r&&!Array.isArray(r)&&typeof n[e]==`object`&&n[e]!==null&&!Array.isArray(n[e])?this.deepMerge(n[e],r):r;return n}clear(){this.registrations.length=0,this.globalScope=null}};function cr(e){let t=[...e],n=t[0];n!=null&&lr(n)&&t.shift();let r=t[0];return r!=null&&ur(r)&&t.shift(),t}function lr(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 ur(e){return/\.(?:m?[jt]s|cjs)$/.test(e)||/[/\\]/.test(e)&&!e.startsWith(`-`)?!0:/^(?:@[\w-]+\/)?[\w-]+$/.test(e)&&!e.startsWith(`-`)}const dr=new Set([`help`,`version`,`outdated`,`init`,`dry-run`,`clean`,`set`]),fr=new Map([[`--trace`,`trace`],[`--debug`,`debug`],[`--info`,`info`],[`--warn`,`warn`],[`--error`,`error`]]),pr=new Map([[`trace`,0],[`debug`,1],[`info`,2],[`warn`,3],[`error`,4]]);function mr(e){let{logLevelFlags:t}=e;if(t.length===0)return;let n=t[0],r=pr.get(n)??4;for(let e of t){let t=pr.get(e)??4;t<r&&(r=t,n=e)}return n}function hr(e){let{helpFlag:t,versionFlag:n,subcommand:r,dryRun:i,unknownCommand:a,setOption:o,positional:s}=e;if(n)return new Gt;if(t)return new qt;if(a!=null)return new tr(a);if(r===`version`)return new Gt;if(r===`help`)return new qt;if(r===`outdated`)return new wn;if(r===`init`)return new fn;if(r===`dry-run`)return new Ht;if(r===`clean`)return i?new Vt:new Et;if(r!==`set`||o.length>0)return new Ut;let c=[];for(let e of s){let t=e.indexOf(`=`);t>0&&c.push([e.slice(0,t),e.slice(t+1)])}return new er([...o,...c])}function gr(e){let t={subcommand:void 0,helpFlag:!1,versionFlag:!1,dryRun:!1,logLevel:void 0,logLevelFlags:[],setOption:[],unknownCommand:void 0,positional:[],unknown:[]},n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i!=null){if(i===`--`){t.positional.push(...e.slice(r+1).filter(e=>e!=null));break}if(i.startsWith(`--`)){let n=i.split(`=`),a=n[0]??``,o=fr.get(a);if(o!=null){t.logLevelFlags.push(o),t.logLevel=o;continue}switch(a){case`--help`:t.helpFlag=!0;break;case`--version`:t.versionFlag=!0;break;case`--dry-run`:t.dryRun=!0;break;case`--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;default:t.unknown.push(`-${n}`)}continue}if(!n){n=!0,dr.has(i)?t.subcommand=i:t.unknownCommand=i;continue}t.positional.push(i)}}return t}var _r=class{logger;args;outputPlugins=[];constructor(...e){this.args=gr(cr(e.filter(e=>e!=null)));let t=mr(this.args);t!=null&&En(t),this.logger=Fn(`PluginPipeline`,t),this.logger.debug(`initialized`,{args:this.args})}registerOutputPlugins(e){return this.outputPlugins.push(...e),this}async run(e){Cn(this.logger);let{context:t,outputPlugins:n,userConfigOptions:r}=e;this.registerOutputPlugins([...n]);let i=this.resolveCommand(),a=this.createCommandContext(t,r);await i.execute(a)}resolveCommand(){return hr(this.args)}createCommandContext(e,t){return{logger:this.logger,outputPlugins:this.outputPlugins,collectedInputContext:e,userConfigOptions:t,createCleanContext:t=>this.createCleanContext(e,t),createWriteContext:t=>this.createWriteContext(e,t)}}createCleanContext(e,t){return{logger:this.logger,fs:h,path:g,glob:gt.default,collectedInputContext:e,dryRun:t}}createWriteContext(e,t){return{logger:this.logger,fs:h,path:g,glob:gt.default,collectedInputContext:e,dryRun:t,registeredPluginNames:this.outputPlugins.map(e=>e.name)}}buildDependencyGraph(e){let t=new Map;for(let n of e){let e=n.dependsOn??[];t.set(n.name,[...e])}return t}validateDependencies(e){let t=new Set(e.map(e=>e.name));for(let n of e){let e=n.dependsOn??[];for(let r of e)if(!t.has(r))throw new a(n.name,r)}}topologicalSort(t){this.validateDependencies(t);let n=new Map;for(let e of t)n.set(e.name,e);let r=new Map;for(let e of t)r.set(e.name,0);let i=new Map;for(let e of t)i.set(e.name,[]);for(let e of t){let t=e.dependsOn??[];for(let n of t){r.set(e.name,(r.get(e.name)??0)+1);let t=i.get(n)??[];t.push(e.name),i.set(n,t)}}let a=[];for(let e of t)r.get(e.name)===0&&a.push(e.name);let o=[];for(;a.length>0;){let e=a.shift(),s=n.get(e);o.push(s);let c=(i.get(e)??[]).sort((e,n)=>t.findIndex(t=>t.name===e)-t.findIndex(e=>e.name===n));for(let e of c){let t=(r.get(e)??0)-1;r.set(e,t),t===0&&a.push(e)}}if(o.length===t.length)return o;throw new e(this.findCyclePath(t,r))}findCyclePath(e,t){let n=new Set;for(let[e,r]of t)r>0&&n.add(e);let r=new Map;for(let t of e)if(n.has(t.name)){let e=(t.dependsOn??[]).filter(e=>n.has(e));r.set(t.name,e)}let i=new Set,a=[],o=e=>{if(a.includes(e))return a.push(e),!0;if(i.has(e))return!1;i.add(e),a.push(e);for(let t of r.get(e)??[])if(o(t))return!0;return a.pop(),!1};for(let e of n){if(o(e)){let e=a.indexOf(a.at(-1));return a.slice(e)}i.clear(),a.length=0}return[...n]}async executePluginsInOrder(e,t,n=!1,r){if(e.length===0)return{};let i=this.topologicalSort(e),a=new ar({userConfig:r}).collect(),o=new sr;o.setGlobalScope(a),this.logger.debug(`global scope collected`,{osInfo:{platform:a.os.platform,arch:a.os.arch,shellKind:a.os.shellKind},hasProfile:Object.keys(a.profile).length>0,hasTool:Object.keys(a.tool).length>0});let s=new Map,c={};for(let e of i){let r=this.buildDependencyContext(e,s),i={...t,dependencyContext:r,globalScope:a,scopeRegistry:o},l=e;l.executeEffects!=null&&await l.executeEffects(i,n);let u=await e.collect(i);s.set(e.name,u),c=this.mergeContexts(c,u);let d=e;if(d.getRegisteredScopes!=null){let t=d.getRegisteredScopes();for(let{namespace:n,values:r}of t)o.register(n,r,or.PluginRegistered),this.logger.debug(`plugin scope registered`,{plugin:e.name,namespace:n,keys:Object.keys(r)})}}return c}buildDependencyContext(e,t){if((e.dependsOn??[]).length===0)return{};let n=this.collectTransitiveDependencies(e,t),r={};for(let e of n){let n=t.get(e);n!=null&&(r=this.mergeContexts(r,n))}return r}collectTransitiveDependencies(e,t){let n=new Set,r=[];return(e=>{for(let i of e)n.has(i)||(n.add(i),t.get(i)!=null&&r.push(i))})(e.dependsOn??[]),r}mergeContexts(e,t){let{workspace:n}=e;if(t.workspace!=null)if(n!=null){let e=new Map;for(let t of n.projects)e.set(t.name,t);for(let n of t.workspace.projects)e.set(n.name,n);n={directory:t.workspace.directory??n.directory,projects:[...e.values()]}}else ({workspace:n}=t);let r=t.externalProjects==null?e.externalProjects:[...e.externalProjects??[],...t.externalProjects],i=t.ideConfigFiles==null?e.ideConfigFiles:[...e.ideConfigFiles??[],...t.ideConfigFiles],a=t.fastCommands==null?e.fastCommands:[...e.fastCommands??[],...t.fastCommands],o=t.subAgents==null?e.subAgents:[...e.subAgents??[],...t.subAgents],s=t.skills==null?e.skills:[...e.skills??[],...t.skills],c=t.aiAgentIgnoreConfigFiles==null?e.aiAgentIgnoreConfigFiles:[...e.aiAgentIgnoreConfigFiles??[],...t.aiAgentIgnoreConfigFiles],l=t.globalMemory??e.globalMemory,u=t.shadowSourceProjectDir??e.shadowSourceProjectDir,d=t.readmePrompts==null?e.readmePrompts:[...e.readmePrompts??[],...t.readmePrompts];return{...n==null?{}:{workspace:n},...r==null?{}:{externalProjects:r},...i==null?{}:{ideConfigFiles:i},...a==null?{}:{fastCommands:a},...o==null?{}:{subAgents:o},...s==null?{}:{skills:s},...c==null?{}:{aiAgentIgnoreConfigFiles:c},...l==null?{}:{globalMemory:l},...u==null?{}:{shadowSourceProjectDir:u},...d==null?{}:{readmePrompts:d}}}};const vr={...Yt,externalProjects:[],excludePatterns:{},fastCommandSeriesOptions:{},plugins:[]};function yr(e){return{...e.workspaceDir==null?{}:{workspaceDir:e.workspaceDir},...e.shadowSourceProjectDir==null?{}:{shadowSourceProjectDir:e.shadowSourceProjectDir},...e.shadowSkillSourceDir==null?{}:{shadowSkillSourceDir:e.shadowSkillSourceDir},...e.shadowFastCommandDir==null?{}:{shadowFastCommandDir:e.shadowFastCommandDir},...e.shadowSubAgentDir==null?{}:{shadowSubAgentDir:e.shadowSubAgentDir},...e.globalMemoryFile==null?{}:{globalMemoryFile:e.globalMemoryFile},...e.shadowProjectsDir==null?{}:{shadowProjectsDir:e.shadowProjectsDir},...e.externalProjects==null?{}:{externalProjects:e.externalProjects},...e.excludePatterns==null?{}:{excludePatterns:e.excludePatterns},...e.fastCommandSeriesOptions==null?{}:{fastCommandSeriesOptions:e.fastCommandSeriesOptions},...e.logLevel==null?{}:{logLevel:e.logLevel}}}function br(...e){return e.reduce((e,t)=>xr(e,t),{...vr})}function xr(e,t){let n=t.externalProjects,r=t.plugins,i=t.excludePatterns,a=t.fastCommandSeriesOptions;return{...e,...t,externalProjects:[...e.externalProjects,...n??[]],plugins:[...e.plugins,...r??[]],excludePatterns:Sr(e.excludePatterns,i),fastCommandSeriesOptions:Cr(e.fastCommandSeriesOptions,a)}}function Sr(e,t){let n={...e};if(t)for(let[e,r]of Object.entries(t))n[e]=[...n[e]??[],...r];return n}function Cr(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 wr(e){return`pluginOptions`in e||`configLoaderOptions`in e||`loadUserConfig`in e}async function Tr(e={}){Gn().shouldExit&&m.exit(1);let t,n,r;wr(e)?({pluginOptions:r={},cwd:n}={pluginOptions:e.pluginOptions,cwd:e.cwd},t=e.loadUserConfig??!0):(r=e,t=!0);let i={},a=!1,o=[],s;if(t){let e=Wn(n);a=e.found,o=e.sources,e.found&&(i=yr(e.config),s=e.config)}let c=br(i,r),{plugins:l=[],logLevel:u}=c,d=Fn(`defineConfig`,u);a?d.info(`user config loaded`,{sources:o}):d.info(`no user config found, using defaults`,{workspaceDir:vr.workspaceDir,shadowSourceProjectDir:vr.shadowSourceProjectDir,shadowSkillSourceDir:vr.shadowSkillSourceDir,shadowFastCommandDir:vr.shadowFastCommandDir,shadowSubAgentDir:vr.shadowSubAgentDir,globalMemoryFile:vr.globalMemoryFile,shadowProjectsDir:vr.shadowProjectsDir,logLevel:vr.logLevel});let f={logger:d,userConfigOptions:c,fs:h,path:g,glob:gt.default},p=l.filter(e=>e.type===Dt.Input),_=l.filter(e=>e.type===Dt.Output),v=await new _r().executePluginsInOrder(p,f,!1,s);if(v.workspace==null)throw Error(`Workspace not initialized by any plugin`);let y={workspace:v.workspace,ideConfigFiles:v.ideConfigFiles??[],...v.externalProjects!=null&&{externalProjects:v.externalProjects},...v.fastCommands!=null&&{fastCommands:v.fastCommands},...v.subAgents!=null&&{subAgents:v.subAgents},...v.skills!=null&&{skills:v.skills},...v.globalMemory!=null&&{globalMemory:v.globalMemory},...v.aiAgentIgnoreConfigFiles!=null&&{aiAgentIgnoreConfigFiles:v.aiAgentIgnoreConfigFiles},...v.shadowSourceProjectDir!=null&&{shadowSourceProjectDir:v.shadowSourceProjectDir},...v.readmePrompts!=null&&{readmePrompts:v.readmePrompts}};return v.shadowSourceProjectDir!=null&&Xt(v.shadowSourceProjectDir,d),{context:y,outputPlugins:_,userConfigOptions:c}}const z=Nr(/[A-Za-z]/),B=Nr(/[\dA-Za-z]/),Er=Nr(/[#-'*+\--9=?A-Z^-~]/);function Dr(e){return e!==null&&(e<32||e===127)}const Or=Nr(/\d/),kr=Nr(/[\dA-Fa-f]/),Ar=Nr(/[!-/:-@[-`{-~]/);function V(e){return e!==null&&e<-2}function H(e){return e!==null&&(e<0||e===32)}function U(e){return e===-2||e===-1||e===32}const jr=Nr(/\p{P}|\p{S}/u),Mr=Nr(/\s/);function Nr(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}var Pr=re(j(((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 Fr=Object.assign(Ir(Error),{eval:Ir(EvalError),range:Ir(RangeError),reference:Ir(ReferenceError),syntax:Ir(SyntaxError),type:Ir(TypeError),uri:Ir(URIError)});function Ir(e){return t.displayName=e.displayName||e.name,t;function t(t,...n){return new e(t&&(0,Pr.default)(t,...n))}}const Lr={}.hasOwnProperty,Rr={yaml:`-`,toml:`+`};function zr(e){let t=[],n=-1,r=Array.isArray(e)?e:e?[e]:[`yaml`];for(;++n<r.length;)t[n]=Br(r[n]);return t}function Br(e){let t=e;if(typeof t==`string`){if(!Lr.call(Rr,t))throw Fr("Missing matter definition for `%s`",t);t={type:t,marker:Rr[t]}}else if(typeof t!=`object`)throw Fr("Expected matter to be an object, not `%j`",t);if(!Lr.call(t,`type`))throw Fr("Missing `type` in matter `%j`",t);if(!Lr.call(t,`fence`)&&!Lr.call(t,`marker`))throw Fr("Missing `marker` or `fence` in matter `%j`",t);return t}function Vr(e){let t=zr(e),n={},r=-1;for(;++r<t.length;){let e=t[r],i=Ur(e,`open`).charCodeAt(0),a=Hr(e),o=n[i];Array.isArray(o)?o.push(a):n[i]=[a]}return{flow:n}}function Hr(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=Ur(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),U(e)?(l.enter(`whitespace`),h(e)):g(e)):e===s.charCodeAt(c++)?(l.consume(e),m):d(e)}function h(e){return U(e)?(l.consume(e),h):(l.exit(`whitespace`),g(e))}function g(t){return V(t)?(l.exit(r),l.enter(`lineEnding`),l.consume(t),l.exit(`lineEnding`),s=Ur(e,`close`),c=0,l.attempt(o,b,_)):d(t)}function _(e){return e===null||V(e)?y(e):(l.enter(a),v(e))}function v(e){return e===null||V(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),U(t)?(e.enter(`whitespace`),l(t)):u(t)):t===s.charCodeAt(a++)?(e.consume(t),c):n(t)}function l(t){return U(t)?(e.consume(t),l):(e.exit(`whitespace`),u(t))}function u(i){return i===null||V(i)?(e.exit(r),t(i)):n(i)}}}function Ur(e,t){return e.marker?Wr(e.marker,t).repeat(3):Wr(e.fence,t)}function Wr(e,t){return typeof e==`string`?e:e[t]}function Gr(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function Kr(e){let t=zr(e),n={},r={},i=-1;for(;++i<t.length;){let e=t[i];n[e.type]=qr(e),r[e.type]=Jr,r[e.type+`Value`]=Yr}return{enter:n,exit:r}}function qr(e){return t;function t(t){this.enter({type:e.type,value:``},t),this.buffer()}}function Jr(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 Yr(e){this.config.enter.data.call(this,e),this.config.exit.data.call(this,e)}function Xr(e){let t=[],n={},r=zr(e),i=-1;for(;++i<r.length;){let e=r[i];n[e.type]=Zr(e);let a=Qr(e,`open`);t.push({atBreak:!0,character:a.charAt(0),after:Gr(a.charAt(1))})}return{unsafe:t,handlers:n}}function Zr(e){let t=Qr(e,`open`),n=Qr(e,`close`);return r;function r(e){return t+(e.value?`
|
|
144
144
|
`+e.value:``)+`
|
|
145
145
|
`+n}}function Qr(e,t){return e.marker?$r(e.marker,t).repeat(3):$r(e.fence,t)}function $r(e,t){return typeof e==`string`?e:e[t]}function ei(e){let t=this,n=e||`yaml`,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Vr(n)),a.push(Kr(n)),o.push(Xr(n))}function ti(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 ni=(function(e){if(e==null)return si;if(typeof e==`function`)return oi(e);if(typeof e==`object`)return Array.isArray(e)?ri(e):ii(e);if(typeof e==`string`)return ai(e);throw Error(`Expected function, string, or object as test`)});function ri(e){let t=[],n=-1;for(;++n<e.length;)t[n]=ni(e[n]);return oi(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function ii(e){let t=e;return oi(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function ai(e){return oi(t);function t(t){return t&&t.type===e}}function oi(e){return t;function t(t,n,r){return!!(ci(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function si(){return!0}function ci(e){return typeof e==`object`&&!!e&&`type`in e}function li(e){return`\x1B[33m`+e+`\x1B[39m`}const ui=[];function di(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=ni(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 (`+li(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=ui,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=fi(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 fi(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?ui:[e]}function pi(e,t,n){let r=ni((n||{}).ignore||[]),i=mi(t),a=-1;for(;++a<i.length;)di(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 mi(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([hi(e[0]),gi(e[1])])}return t}function hi(e){return typeof e==`string`?new RegExp(Gr(e),`g`):e}function gi(e){return typeof e==`function`?e:function(){return e}}const _i=`phrasing`,vi=[`autolink`,`link`,`image`,`label`];function yi(){return{transforms:[Di],enter:{literalAutolink:xi,literalAutolinkEmail:Si,literalAutolinkHttp:Si,literalAutolinkWww:Si},exit:{literalAutolink:Ei,literalAutolinkEmail:Ti,literalAutolinkHttp:Ci,literalAutolinkWww:wi}}}function bi(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:_i,notInConstruct:vi},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:_i,notInConstruct:vi},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:_i,notInConstruct:vi}]}}function xi(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function Si(e){this.config.enter.autolinkProtocol.call(this,e)}function Ci(e){this.config.exit.autolinkProtocol.call(this,e)}function wi(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 Ti(e){this.config.exit.autolinkEmail.call(this,e)}function Ei(e){this.exit(e)}function Di(e){pi(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Oi],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,ki]],{ignore:[`link`,`linkReference`]})}function Oi(e,t,n,r,i){let a=``;if(!Mi(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!Ai(n)))return!1;let o=ji(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 ki(e,t,n,r){return!Mi(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function Ai(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 ji(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=ti(e,`(`),a=ti(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 Mi(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||Mr(n)||jr(n))&&(!t||n!==47)}function Ni(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}Ui.peek=Hi;function Pi(){this.buffer()}function Fi(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Ii(){this.buffer()}function Li(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function Ri(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ni(this.sliceSerialize(e)).toLowerCase(),n.label=t}function zi(e){this.exit(e)}function Bi(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ni(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Vi(e){this.exit(e)}function Hi(){return`[`}function Ui(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 Wi(){return{enter:{gfmFootnoteCallString:Pi,gfmFootnoteCall:Fi,gfmFootnoteDefinitionLabelString:Ii,gfmFootnoteDefinition:Li},exit:{gfmFootnoteCallString:Ri,gfmFootnoteCall:zi,gfmFootnoteDefinitionLabelString:Bi,gfmFootnoteDefinition:Vi}}}function Gi(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Ui},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?`
|
|
146
146
|
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?qi:Ki))),s(),o}}function Ki(e,t,n){return t===0?e:qi(e,t,n)}function qi(e,t,n){return(n?``:` `)+e}const Ji=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];$i.peek=ea;function Yi(){return{canContainEols:[`delete`],enter:{strikethrough:Zi},exit:{strikethrough:Qi}}}function Xi(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:Ji}],handlers:{delete:$i}}}function Zi(e){this.enter({type:`delete`,children:[]},e)}function Qi(e){this.exit(e)}function $i(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function ea(){return`~`}function ta(e){return e.length}function na(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||ta,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=ra(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=ia(r[d]);else{let e=ia(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&!(n.alignDelimiters===!1&&i===``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
|
|
@@ -275,11 +275,11 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
275
275
|
`,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(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 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 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(`
|
|
276
276
|
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
277
277
|
`,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;case`space`:case`comment`:default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),Hd=j((e=>{var t=Pd(),n=_d(),r=vd(),i=Hu(),a=J(),o=Bd(),s=Vd();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})),Ud=re(j((e=>{var t=Pd(),n=_d(),r=hd(),i=vd(),a=Pu(),o=J(),s=Gu(),c=Y(),l=qu(),u=Yu();Rd();var d=zd(),f=Bd(),p=Vd(),m=Hd(),h=Ou();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=m.parse,e.parseAllDocuments=m.parseAllDocuments,e.parseDocument=m.parseDocument,e.stringify=m.stringify,e.visit=h.visit,e.visitAsync=h.visitAsync}))(),1);function Wd(e,t){let n=Object.fromEntries(Object.entries(e).filter(([e,t])=>t!=null));return Object.keys(n).length===0?`---
|
|
278
|
-
---`:`---\n${Ud.stringify(n,{singleQuote:t?.singleQuote??!1,lineWidth:t?.lineWidth??0}).trimEnd()}\n---`}function Gd(e,t,n){return e==null||Object.keys(e).length===0?t:`${Wd(e,n)}\n${t}`}function Kd(e){let t=vu().use(nu).use(pl).use(ei,[`yaml`]).parse(e),n,r,i=[];for(let e of t.children)if(e.type===`yaml`){let t=e;r=t.value;try{n=Ud.parse(t.value)}catch{}}else i.push(e);let a=e;return r!=null&&(a=e.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,``)),{...n!=null&&{yamlFrontMatter:n},...r!=null&&{rawFrontMatter:r},markdownAst:t,markdownContents:i,contentWithoutFrontMatter:a}}var qd=class{type;name;_log;get log(){return this._log??=Fn(this.name),this._log}dependsOn;constructor(e,t,n){this.name=e,this.type=t,n!=null&&(this.dependsOn=n)}},Jd=class extends qd{globalConfigDir;outputFileName;registryWriterCache=new Map;writeEffects=[];cleanEffects=[];constructor(e,t){super(e,Dt.Output,t?.dependsOn),this.globalConfigDir=t?.globalConfigDir??``,this.outputFileName=t?.outputFileName??``}registerWriteEffect(e,t){this.writeEffects.push({name:e,handler:t})}registerCleanEffect(e,t){this.cleanEffects.push({name:e,handler:t})}async executeWriteEffects(e){let t=[];for(let n of this.writeEffects){if(e.dryRun===!0){this.log.trace({action:`dryRun`,type:`effect`,name:n.name}),t.push({success:!0,description:`Would execute write effect: ${n.name}`});continue}try{let r=await n.handler(e);if(r.success)this.log.trace({action:`effect`,name:n.name,status:`success`});else{let e=r.error instanceof Error?r.error.message:String(r.error);this.log.error({action:`effect`,name:n.name,status:`failed`,error:e})}t.push(r)}catch(e){let r=e instanceof Error?e.message:String(e);this.log.error({action:`effect`,name:n.name,status:`failed`,error:r}),t.push({success:!1,error:e,description:`Write effect failed: ${n.name}`})}}return t}async executeCleanEffects(e){let t=[];for(let n of this.cleanEffects){if(e.dryRun===!0){this.log.trace({action:`dryRun`,type:`effect`,name:n.name}),t.push({success:!0,description:`Would execute clean effect: ${n.name}`});continue}try{let r=await n.handler(e);if(r.success)this.log.trace({action:`effect`,name:n.name,status:`success`});else{let e=r.error instanceof Error?r.error.message:String(r.error);this.log.error({action:`effect`,name:n.name,status:`failed`,error:e})}t.push(r)}catch(e){let r=e instanceof Error?e.message:String(e);this.log.error({action:`effect`,name:n.name,status:`failed`,error:r}),t.push({success:!1,error:e,description:`Clean effect failed: ${n.name}`})}}return t}isRelativePath(e){return e.pathKind===N.Relative}toRelativePath(e){return this.isRelativePath(e)?e:{pathKind:N.Relative,path:e.path,basePath:``,getDirectoryName:e.getDirectoryName,getAbsolutePath:()=>e.path}}resolveFullPath(e,t){let n;n=e.pathKind===N.Absolute?e.path:this.isRelativePath(e)?g.resolve(e.basePath,e.path):g.resolve(m.cwd(),e.path);let r=t??this.outputFileName;return r?g.join(n,r):n}createRelativePath(e,t,n){return{pathKind:N.Relative,path:e,basePath:t,getDirectoryName:n,getAbsolutePath:()=>g.join(t,e)}}createFileRelativePath(e,t){let n=g.join(e.path,t);return{pathKind:N.Relative,path:n,basePath:e.basePath,getDirectoryName:()=>e.getDirectoryName(),getAbsolutePath:()=>g.join(e.basePath,n)}}getGlobalConfigDir(){return g.join(this.getHomeDir(),this.globalConfigDir)}getHomeDir(){return v.homedir()}joinPath(...e){return g.join(...e)}resolvePath(...e){return g.resolve(...e)}dirname(e){return g.dirname(e)}basename(e,t){return g.basename(e,t)}writeFileSync(e,t,n=`
|
|
278
|
+
---`:`---\n${Ud.stringify(n,{singleQuote:t?.singleQuote??!1,lineWidth:t?.lineWidth??0}).trimEnd()}\n---`}function Gd(e,t,n){return e==null||Object.keys(e).length===0?t:`${Wd(e,n)}\n${t}`}function Kd(e){let t=vu().use(nu).use(pl).use(ei,[`yaml`]).parse(e),n,r,i=[];for(let e of t.children)if(e.type===`yaml`){let t=e;r=t.value;try{n=Ud.parse(t.value)}catch{}}else i.push(e);let a=e;return r!=null&&(a=e.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,``)),{...n!=null&&{yamlFrontMatter:n},...r!=null&&{rawFrontMatter:r},markdownAst:t,markdownContents:i,contentWithoutFrontMatter:a}}var qd=class{type;name;_log;get log(){return this._log??=Fn(this.name),this._log}dependsOn;constructor(e,t,n){this.name=e,this.type=t,n!=null&&(this.dependsOn=n)}},Jd=class extends qd{globalConfigDir;outputFileName;registryWriterCache=new Map;writeEffects=[];cleanEffects=[];constructor(e,t){super(e,Dt.Output,t?.dependsOn),this.globalConfigDir=t?.globalConfigDir??``,this.outputFileName=t?.outputFileName??``}registerWriteEffect(e,t){this.writeEffects.push({name:e,handler:t})}registerCleanEffect(e,t){this.cleanEffects.push({name:e,handler:t})}async executeWriteEffects(e){let t=[];for(let n of this.writeEffects){if(e.dryRun===!0){this.log.trace({action:`dryRun`,type:`effect`,name:n.name}),t.push({success:!0,description:`Would execute write effect: ${n.name}`});continue}try{let r=await n.handler(e);if(r.success)this.log.trace({action:`effect`,name:n.name,status:`success`});else{let e=r.error instanceof Error?r.error.message:String(r.error);this.log.error({action:`effect`,name:n.name,status:`failed`,error:e})}t.push(r)}catch(e){let r=e instanceof Error?e.message:String(e);this.log.error({action:`effect`,name:n.name,status:`failed`,error:r}),t.push({success:!1,error:e,description:`Write effect failed: ${n.name}`})}}return t}async executeCleanEffects(e){let t=[];for(let n of this.cleanEffects){if(e.dryRun===!0){this.log.trace({action:`dryRun`,type:`effect`,name:n.name}),t.push({success:!0,description:`Would execute clean effect: ${n.name}`});continue}try{let r=await n.handler(e);if(r.success)this.log.trace({action:`effect`,name:n.name,status:`success`});else{let e=r.error instanceof Error?r.error.message:String(r.error);this.log.error({action:`effect`,name:n.name,status:`failed`,error:e})}t.push(r)}catch(e){let r=e instanceof Error?e.message:String(e);this.log.error({action:`effect`,name:n.name,status:`failed`,error:r}),t.push({success:!1,error:e,description:`Clean effect failed: ${n.name}`})}}return t}isRelativePath(e){return e.pathKind===N.Relative}toRelativePath(e){return this.isRelativePath(e)?e:{pathKind:N.Relative,path:e.path,basePath:``,getDirectoryName:e.getDirectoryName,getAbsolutePath:()=>e.path}}resolveFullPath(e,t){let n;n=e.pathKind===N.Absolute?e.path:this.isRelativePath(e)?g.resolve(e.basePath,e.path):g.resolve(m.cwd(),e.path);let r=t??this.outputFileName;return r?g.join(n,r):n}createRelativePath(e,t,n){return{pathKind:N.Relative,path:e,basePath:t,getDirectoryName:n,getAbsolutePath:()=>g.join(t,e)}}createFileRelativePath(e,t){let n=g.join(e.path,t);return{pathKind:N.Relative,path:n,basePath:e.basePath,getDirectoryName:()=>e.getDirectoryName(),getAbsolutePath:()=>g.join(e.basePath,n)}}getGlobalConfigDir(){return g.join(this.getHomeDir(),this.globalConfigDir)}getHomeDir(){return v.homedir()}joinPath(...e){return g.join(...e)}resolvePath(...e){return g.resolve(...e)}dirname(e){return g.dirname(e)}basename(e,t){return g.basename(e,t)}writeFileSync(e,t,n=`utf8`){h.writeFileSync(e,t,n)}writeFileSyncBuffer(e,t){h.writeFileSync(e,t)}ensureDirectory(e){h.existsSync(e)||h.mkdirSync(e,{recursive:!0})}existsSync(e){return h.existsSync(e)}readdirSync(e,t){return t?.withFileTypes===!0?h.readdirSync(e,{withFileTypes:!0}):h.readdirSync(e)}async writeFile(e,t,n,r){let i=g.dirname(t),a=g.basename(t),o={pathKind:N.Relative,path:a,basePath:i,getDirectoryName:()=>g.basename(i),getAbsolutePath:()=>t};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`file`,path:t,label:r}),{path:o,success:!0,skipped:!1};try{return this.ensureDirectory(i),h.writeFileSync(t,n,`utf8`),this.log.trace({action:`write`,type:`file`,path:t,label:r}),{path:o,success:!0}}catch(e){let n=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`file`,path:t,label:r,error:n}),{path:o,success:!1,error:e}}}async writePromptFile(e,t,n,r){let i=this.resolveFullPath(t),a=this.toRelativePath(t);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`promptFile`,path:i,label:r}),{path:a,success:!0,skipped:!1};try{let e=g.dirname(i);return this.ensureDirectory(e),h.writeFileSync(i,n,`utf8`),this.log.trace({action:`write`,type:`promptFile`,path:i,label:r}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`promptFile`,path:i,label:r,error:t}),{path:a,success:!1,error:e}}}buildMarkdownContent(e,t){return Gd(t,e)}buildMarkdownContentWithRaw(e,t,n){return t!=null&&Object.keys(t).length>0?Gd(t,e):n!=null&&n.length>0?`---\n${n}\n---\n${e}`:e}extractGlobalMemoryContent(e){return e.collectedInputContext.globalMemory?.content}combineGlobalWithContent(e,t,n){let{separator:r=`
|
|
279
279
|
|
|
280
|
-
`,skipIfEmpty:i=!0,position:a=`before`}=n??{};if(i&&(e==null||e.trim().length===0))return t;let o=e??``;return a===`after`?`${t}${r}${o}`:`${o}${r}${t}`}transformFastCommandName(e,t){let{includeSeriesPrefix:n=!0,seriesSeparator:r=`_`}=t??{};return!n||e.series==null?`${e.commandName}.md`:`${e.series}${r}${e.commandName}.md`}getFastCommandSeriesOptions(e){let t=e.pluginOptions?.fastCommandSeriesOptions,n=t?.pluginOverrides?.[this.name],r=n?.includeSeriesPrefix??t?.includeSeriesPrefix,i=n?.seriesSeparator;return r!=null&&i!=null?{includeSeriesPrefix:r,seriesSeparator:i}:r==null?i==null?{}:{seriesSeparator:i}:{includeSeriesPrefix:r}}getTransformOptionsFromContext(e,t){let n=this.getFastCommandSeriesOptions(e),r=n.includeSeriesPrefix??t?.includeSeriesPrefix,i=n.seriesSeparator??t?.seriesSeparator;return r!=null&&i!=null?{includeSeriesPrefix:r,seriesSeparator:i}:r==null?i==null?{}:{seriesSeparator:i}:{includeSeriesPrefix:r}}shouldSkipDueToPlugin(e,t){let n=e.registeredPluginNames;return n==null?!1:n.includes(t)}async onWriteComplete(e,t){let n=t.files.filter(e=>e.success).length,r=t.files.filter(e=>e.skipped).length,i=t.files.filter(e=>!e.success&&!e.skipped).length;this.log.trace({action:e.dryRun===!0?`dryRun`:`complete`,type:`writeSummary`,success:n,skipped:r,failed:i}),await this.executeWriteEffects(e)}async onCleanComplete(e){await this.executeCleanEffects(e)}getRegistryWriter(e){let t=e.name,n=this.registryWriterCache.get(t);if(n!=null)return n;let r=new e(this.log);return this.registryWriterCache.set(t,r),r}async registerInRegistry(e,t,n){return e.register(t,n.dryRun)}};const Yd=`AGENTS.md`;var Xd=class extends Jd{constructor(){super(`AgentsOutputPlugin`,{outputFileName:Yd})}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.rootMemoryPrompt!=null&&e.dirFromWorkspacePath!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,Yd)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,Yd));return t}async canWrite(e){let{workspace:t}=e.collectedInputContext;return t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t){let t=r.name??`unknown`,i=r.dirFromWorkspacePath;if(i!=null){if(r.rootMemoryPrompt!=null){let a=await this.writePromptFile(e,i,r.rootMemoryPrompt.content,`project:${t}/root`);n.push(a)}if(r.childMemoryPrompts!=null)for(let i of r.childMemoryPrompts){let r=await this.writePromptFile(e,i.dir,i.content,`project:${t}/child:${i.workingChildDirectoryPath?.path??`unknown`}`);n.push(r)}}}return{files:n,dirs:r}}},X=class extends qd{inputEffects=[];registeredScopes=[];constructor(e,t){super(e,Dt.Input,t)}registerEffect(e,t,n=0){this.inputEffects.push({name:e,handler:t,priority:n}),this.inputEffects.sort((e,t)=>(e.priority??0)-(t.priority??0))}async executeEffects(e,t=!1){let n=[];if(this.inputEffects.length===0)return n;let{workspaceDir:r,shadowProjectDir:i}=this.resolveBasePaths(e.userConfigOptions),a={logger:this.log,fs:e.fs,path:e.path,glob:e.glob,spawn:x,userConfigOptions:e.userConfigOptions,workspaceDir:r,shadowProjectDir:i,dryRun:t};for(let e of this.inputEffects){if(t){this.log.trace({action:`dryRun`,type:`inputEffect`,name:e.name}),n.push({success:!0,description:`Would execute input effect: ${e.name}`});continue}try{let t=await e.handler(a);if(t.success)this.log.trace({action:`inputEffect`,name:e.name,status:`success`,description:t.description}),t.modifiedFiles!=null&&t.modifiedFiles.length>0&&this.log.debug({action:`inputEffect`,name:e.name,modifiedFiles:t.modifiedFiles}),t.deletedFiles!=null&&t.deletedFiles.length>0&&this.log.debug({action:`inputEffect`,name:e.name,deletedFiles:t.deletedFiles});else{let n=t.error instanceof Error?t.error.message:String(t.error);this.log.error({action:`inputEffect`,name:e.name,status:`failed`,error:n})}n.push(t)}catch(t){let r=t instanceof Error?t.message:String(t);this.log.error({action:`inputEffect`,name:e.name,status:`failed`,error:r}),n.push({success:!1,error:t,description:`Input effect failed: ${e.name}`})}}return n}hasEffects(){return this.inputEffects.length>0}getEffectCount(){return this.inputEffects.length}registerScope(e,t){this.registeredScopes.push({namespace:e,values:t}),this.log.debug({action:`registerScope`,namespace:e,keys:Object.keys(t)})}getRegisteredScopes(){return this.registeredScopes}clearRegisteredScopes(){this.registeredScopes.length=0,this.log.debug({action:`clearRegisteredScopes`})}resolveBasePaths(e){let t=e.workspaceDir,n=this.resolvePath(t,``,``),r=e.shadowSourceProjectDir;return{workspaceDir:n,shadowProjectDir:this.resolvePath(r,n,``)}}resolvePath(e,t,n){let r=e;return r.startsWith(Jt.USER_HOME)&&(r=r.replace(Jt.USER_HOME,v.homedir())),r.includes(Jt.SHADOW_SOURCE_PROJECT)&&(r=r.replace(Jt.SHADOW_SOURCE_PROJECT,n)),r.includes(Jt.WORKSPACE)&&(r=r.replace(Jt.WORKSPACE,t)),g.normalize(r)}readAndParseMarkdown(e,t){return Kd(t.readFileSync(e,`
|
|
281
|
-
`)){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 af(e,t,n){let r=e.trim();if(r===``)throw Error(`Empty value cannot be evaluated`);if(r===`true`)return!0;if(r===`false`)return!1;if(r===`null`)return null;if(/^-?\d+(?:\.\d+)?$/.test(r))return Number(r);if(r.startsWith(`"`)&&r.endsWith(`"`))return of(r.slice(1,-1),`"`);if(r.startsWith(`'`)&&r.endsWith(`'`))return of(r.slice(1,-1),`'`);if(r.startsWith("`")&&r.endsWith("`")){let e=r.slice(1,-1);if(
|
|
282
|
-
`).replace(/\\r/g,`\r`).replace(/\\t/g,` `).replace(/\\"/g,`"`).replace(/\\'/g,`'`).replace(/\\\\/g,`\\`)}function sf(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`&&a)return a;let o=n==null?``:` in file "${n}"`;throw Error(`Variable "${e}" resolved to unsupported type: ${typeof a}${o}`)}function cf(e,t,n){let r=e.slice(1,-1).trim();if(r===``)return[];if(t==null)try{let t=uf(e),n=JSON.parse(t);if(Array.isArray(n))return n}catch{}return df(r).map(e=>af(e.trim(),t,n))}function lf(e,t,n){let r=e.slice(1,-1).trim();if(r===``)return{};if(t==null)try{let t=uf(e),n=JSON.parse(t);if(typeof n==`object`&&n&&!Array.isArray(n))return n}catch{}let i={},a=ff(r);for(let e of a){let r=pf(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]=af(o,t,n)}return i}function uf(e){let t=``,n=null,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(r){t+=a,r=!1;continue}if(a===`\\`){t+=a,r=!0;continue}if(n!=null){a===n?(t+=`"`,n=null):a===`"`&&n===`'`?t+=`\\"`:t+=a;continue}if(a===`"`||a===`'`){t+=`"`,n=a;continue}if(a===`:`&&i>0){let e=t.length-1;for(;e>=0&&/\s/.test(t.charAt(e));)e--;let n=e+1;for(;e>=0&&/[\w$]/.test(t.charAt(e));)e--;if(e++,e>0&&t.charAt(e-1)!==`"`){let r=t.slice(e,n);r.length>0&&/^[\w$]+$/.test(r)&&(t=`${t.slice(0,e)}"${r}"`)}}t+=a}return t}function df(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 ff(e){return df(e)}function pf(e){let t=null,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){n=!1;continue}if(i===`\\`){n=!0;continue}if(t!=null){i===t&&(t=null);continue}if(i===`"`||i===`'`||i==="`"){t=i;continue}if(i===`:`)return r}return-1}function mf(e,t){let n=e.attributes.find(e=>e.type===`mdxJsxAttribute`&&e.name===`when`);if(n==null||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=o(n.value.value,t.scope);return e===`true`||e===`1`}catch{return!1}return!1}async function hf(e,t,n){return!mf(e,t)||e.children.length===0?[]:n(e.children,t)}async function gf(e,t){if(!mf(e,t)||e.children.length===0)return[];let n=_f(e.children,t);return n===``?[]:[{type:`text`,value:n}]}function _f(e,t){let n=``;for(let r of e)if(r.type===`text`)n+=r.value;else if(r.type===`mdxTextExpression`)try{n+=o(r.value,t.scope)}catch{}else `children`in r&&Array.isArray(r.children)&&(n+=_f(r.children,t));return n}function vf(){i(`Md`,hf),i(`Md.Line`,gf)}function yf(e){return vu().use(nu).use(pl).use(ei,[`yaml`]).use(C).parse(e)}vf();function bf(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))typeof r==`object`&&r&&!Array.isArray(r)&&typeof n[e]==`object`&&n[e]!==null&&!Array.isArray(n[e])?n[e]={...n[e],...r}:n[e]=r;return n}async function xf(e,t){let n=yf(e),r=bf(t?.globalScope,t?.scope),i=c(),a;if(t?.extractMetadata===!0){let e=n.children.find(e=>e.type===`yaml`),i;if(e!=null)try{i=Ud.parse(e.value)}catch{}a=tf(n.children.filter(e=>e.type===`mdxjsEsm`),{...i!=null&&{yamlFrontMatter:i},scope:r,...t?.basePath!=null&&{filePath:t.basePath}}),n.children=n.children.filter(e=>e.type!==`yaml`&&e.type!==`mdxjsEsm`)}let o=await u(n,{scope:r,components:i,processingStack:[],...t?.basePath!=null&&{basePath:t.basePath}}),s=vu().use(ei,[`yaml`]).use(pl).use(S,{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 Sf=`CLAUDE.md`,Z=`.claude`,Cf=`commands`,wf=`agents`,Tf=`skills`,Ef=[Cf,wf,Tf];var Df=class extends Jd{constructor(){super(`ClaudeCodeCLIOutputPlugin`,{globalConfigDir:Z,outputFileName:Sf})}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.dirFromWorkspacePath!=null)for(let n of Ef){let r=g.join(e.dirFromWorkspacePath.path,Z,n);t.push({pathKind:N.Relative,path:r,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>g.join(e.dirFromWorkspacePath.basePath,r)})}return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{skills:r}=e.collectedInputContext;for(let e of n){if(e.rootMemoryPrompt!=null&&e.dirFromWorkspacePath!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,Sf)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,Sf));if(r!=null&&e.dirFromWorkspacePath!=null)for(let n of r){let r=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),i=g.join(e.dirFromWorkspacePath.path,Z,Tf,r);if(t.push({pathKind:N.Relative,path:g.join(i,`SKILL.md`),basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>r,getAbsolutePath:()=>g.join(e.dirFromWorkspacePath.basePath,i,`SKILL.md`)}),n.childDocs!=null)for(let a of n.childDocs){let n=a.dir.path.replace(/\.mdx$/,`.md`),o=g.join(i,n);t.push({pathKind:N.Relative,path:o,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>r,getAbsolutePath:()=>g.join(e.dirFromWorkspacePath.basePath,o)})}if(n.resources!=null)for(let a of n.resources){let n=g.join(i,a.relativePath);t.push({pathKind:N.Relative,path:n,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>r,getAbsolutePath:()=>g.join(e.dirFromWorkspacePath.basePath,n)})}}}return t}async registerGlobalOutputFiles(e){let{globalMemory:t}=e.collectedInputContext;if(t==null)return[];let n=this.getGlobalConfigDir();return[{pathKind:N.Relative,path:Sf,basePath:n,getDirectoryName:()=>Z,getAbsolutePath:()=>g.join(n,Sf)}]}async canWrite(e){let{workspace:t,globalMemory:n,fastCommands:r,subAgents:i,skills:a}=e.collectedInputContext,o=t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0),s=n!=null,c=(r?.length??0)>0,l=(i?.length??0)>0,u=(a?.length??0)>0;return!o&&!s&&!c&&!l&&!u?(this.log.trace({action:`skip`,reason:`noOutputs`}),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{fastCommands:n,subAgents:r,skills:i}=e.collectedInputContext,a=[],o=[];for(let o of t){let t=o.name??`unknown`,s=o.dirFromWorkspacePath;if(s!=null){if(o.rootMemoryPrompt!=null){let n=await this.writePromptFile(e,s,o.rootMemoryPrompt.content,`project:${t}/root`);a.push(n)}if(o.childMemoryPrompts!=null)for(let n of o.childMemoryPrompts){let r=await this.writePromptFile(e,n.dir,n.content,`project:${t}/child:${n.workingChildDirectoryPath?.path??`unknown`}`);a.push(r)}if(n!=null)for(let t of n){let n=await this.writeFastCommand(e,s,t);a.push(...n)}if(r!=null)for(let t of r){let n=await this.writeSubAgent(e,s,t);a.push(...n)}if(i!=null)for(let t of i){let n=await this.writeSkill(e,s,t);a.push(...n)}}}return{files:a,dirs:o}}async writeGlobalOutputs(e){let{globalMemory:t}=e.collectedInputContext,n=[],r=[];if(t==null)return{files:n,dirs:r};let i=this.getGlobalConfigDir(),a=g.join(i,Sf),o={pathKind:N.Relative,path:Sf,basePath:i,getDirectoryName:()=>Z,getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMemory`,path:a}),{files:[{path:o,success:!0,skipped:!1}],dirs:r};try{this.ensureDirectory(i),h.writeFileSync(a,t.content,`utf-8`),this.log.trace({action:`write`,type:`globalMemory`,path:a}),n.push({path:o,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalMemory`,path:a,error:t}),n.push({path:o,success:!1,error:e})}return{files:n,dirs:r}}async writeFastCommand(e,t,n){let r=[],i=this.getTransformOptionsFromContext(e),a=this.transformFastCommandName(n,i),o=g.join(t.basePath,t.path,Z,Cf),s=g.join(o,a),c={pathKind:N.Relative,path:g.join(t.path,Z,Cf,a),basePath:t.basePath,getDirectoryName:()=>Cf,getAbsolutePath:()=>s},l=n.content,u=n.yamlFrontMatter,d=!1;if(n.rawMdxContent!=null){this.log.debug(`recompiling fast command with claudeCode preset`,{file:n.dir.getAbsolutePath(),hasRawContent:!0,rawContentLength:n.rawMdxContent.length});try{let e=new ar({toolPreset:`claudeCode`}).collect();this.log.debug(`claudeCode tool scope`,{tool:e.tool});let t=await xf(n.rawMdxContent,{globalScope:e,extractMetadata:!0,basePath:n.dir.basePath});l=t.content,u=t.metadata.fields,d=!0,this.log.debug(`recompiled front matter`,{frontMatter:u})}catch(e){this.log.warn(`failed to recompile fast command with claudeCode preset, using default`,{file:n.dir.getAbsolutePath(),error:e instanceof Error?e.message:String(e)})}}else this.log.debug(`no rawMdxContent available for fast command`,{file:n.dir.getAbsolutePath()});let f=d?this.buildMarkdownContent(l,u):this.buildMarkdownContentWithRaw(l,u,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`fastCommand`,path:s}),[{path:c,success:!0,skipped:!1}];try{this.ensureDirectory(o),h.writeFileSync(s,f,`utf-8`),this.log.trace({action:`write`,type:`fastCommand`,path:s}),r.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`fastCommand`,path:s,error:t}),r.push({path:c,success:!1,error:e})}return r}async writeSubAgent(e,t,n){let r=[],i=n.dir.path.endsWith(`.md`)?n.dir.path:`${n.dir.path}.md`,a=g.join(t.basePath,t.path,Z,wf),o=g.join(a,i),s={pathKind:N.Relative,path:g.join(t.path,Z,wf,i),basePath:t.basePath,getDirectoryName:()=>wf,getAbsolutePath:()=>o},c=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`subAgent`,path:o}),[{path:s,success:!0,skipped:!1}];try{this.ensureDirectory(a),h.writeFileSync(o,c,`utf-8`),this.log.trace({action:`write`,type:`subAgent`,path:o}),r.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`subAgent`,path:o,error:t}),r.push({path:s,success:!1,error:e})}return r}async writeSkill(e,t,n){let r=[],i=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),a=g.join(t.basePath,t.path,Z,Tf,i),o=g.join(a,`SKILL.md`),s={pathKind:N.Relative,path:g.join(t.path,Z,Tf,i,`SKILL.md`),basePath:t.basePath,getDirectoryName:()=>i,getAbsolutePath:()=>o},c=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skill`,path:o}),[{path:s,success:!0,skipped:!1}];try{if(this.ensureDirectory(a),h.writeFileSync(o,c,`utf-8`),this.log.trace({action:`write`,type:`skill`,path:o}),r.push({path:s,success:!0}),n.childDocs!=null)for(let o of n.childDocs){let n=await this.writeSkillReferenceDocument(e,a,i,o,t);r.push(...n)}if(n.resources!=null)for(let o of n.resources){let n=await this.writeSkillResource(e,a,i,o,t);r.push(...n)}}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skill`,path:o,error:t}),r.push({path:s,success:!1,error:e})}return r}async writeSkillReferenceDocument(e,t,n,r,i){let a=[],o=r.dir.path.replace(/\.mdx$/,`.md`),s=g.join(t,o),c={pathKind:N.Relative,path:g.join(i.path,Z,Tf,n,o),basePath:i.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillRefDoc`,path:s}),[{path:c,success:!0,skipped:!1}];try{let e=g.dirname(s);this.ensureDirectory(e),h.writeFileSync(s,r.content,`utf-8`),this.log.trace({action:`write`,type:`skillRefDoc`,path:s}),a.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillRefDoc`,path:s,error:t}),a.push({path:c,success:!1,error:e})}return a}async writeSkillResource(e,t,n,r,i){let a=[],o=g.join(t,r.relativePath),s={pathKind:N.Relative,path:g.join(i.path,Z,Tf,n,r.relativePath),basePath:i.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>o};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillResource`,path:o}),[{path:s,success:!0,skipped:!1}];try{let e=g.dirname(o);this.ensureDirectory(e),h.writeFileSync(o,r.content,`utf-8`),this.log.trace({action:`write`,type:`skillResource`,path:o}),a.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillResource`,path:o,error:t}),a.push({path:s,success:!1,error:e})}return a}};const Of=`AGENTS.md`,kf=`.codex`,Af=`prompts`,jf=`skills`,Mf=`SKILL.md`;var Nf=class extends Jd{constructor(){super(`CodexCLIOutputPlugin`,{globalConfigDir:kf,outputFileName:Of,dependsOn:[`AgentsOutputPlugin`]})}async registerProjectOutputDirs(){return[]}async registerProjectOutputFiles(){return[]}async registerGlobalOutputDirs(e){let t=this.getGlobalConfigDir(),n=[],r=g.join(t,Af);n.push({pathKind:N.Relative,path:Af,basePath:t,getDirectoryName:()=>Af,getAbsolutePath:()=>r});let{skills:i}=e.collectedInputContext;if(i!=null&&i.length>0)for(let e of i){let r=e.yamlFrontMatter?.name??e.dir.getDirectoryName(),i=g.join(t,jf,r);n.push({pathKind:N.Relative,path:g.join(jf,r),basePath:t,getDirectoryName:()=>r,getAbsolutePath:()=>i})}return n}async registerGlobalOutputFiles(){let e=this.getGlobalConfigDir();return[{pathKind:N.Relative,path:Of,basePath:e,getDirectoryName:()=>kf,getAbsolutePath:()=>g.join(e,Of)}]}async canWrite(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=t!=null,a=(n?.length??0)>0,o=(r?.length??0)>0;return!i&&!a&&!o?(this.log.trace({action:`skip`,reason:`noOutputs`}),!1):!0}async writeProjectOutputs(){return{files:[],dirs:[]}}async writeGlobalOutputs(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=[];if(t!=null){let n=this.getGlobalConfigDir(),r=g.join(n,Of),a={pathKind:N.Relative,path:Of,basePath:n,getDirectoryName:()=>kf,getAbsolutePath:()=>r};if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`globalMemory`,path:r}),i.push({path:a,success:!0,skipped:!1});else try{this.ensureDirectory(n),h.writeFileSync(r,t.content,`utf-8`),this.log.trace({action:`write`,type:`globalMemory`,path:r}),i.push({path:a,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalMemory`,path:r,error:t}),i.push({path:a,success:!1,error:e})}}if(n!=null&&n.length>0){let t=this.getGlobalConfigDir();for(let r of n){let n=await this.writeGlobalFastCommand(e,t,r);i.push(...n)}}if(r!=null&&r.length>0){let t=this.getGlobalConfigDir();for(let n of r){let r=await this.writeGlobalSkill(e,t,n);i.push(...r)}}return{files:i,dirs:a}}async writeGlobalFastCommand(e,t,n){let r=[],i=this.getTransformOptionsFromContext(e),a=this.transformFastCommandName(n,i),o=g.join(t,Af),s=g.join(o,a),c={pathKind:N.Relative,path:g.join(Af,a),basePath:t,getDirectoryName:()=>Af,getAbsolutePath:()=>s},l=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalFastCommand`,path:s}),[{path:c,success:!0,skipped:!1}];try{this.ensureDirectory(o),h.writeFileSync(s,l,`utf-8`),this.log.trace({action:`write`,type:`globalFastCommand`,path:s}),r.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalFastCommand`,path:s,error:t}),r.push({path:c,success:!1,error:e})}return r}async writeGlobalSkill(e,t,n){let r=[],i=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),a=g.join(t,jf,i),o=g.join(a,Mf),s={pathKind:N.Relative,path:g.join(jf,i,Mf),basePath:t,getDirectoryName:()=>i,getAbsolutePath:()=>o},c=this.buildCodexSkillContent(n);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalSkill`,path:o}),[{path:s,success:!0,skipped:!1}];try{if(this.ensureDirectory(a),h.writeFileSync(o,c,`utf-8`),this.log.trace({action:`write`,type:`globalSkill`,path:o}),r.push({path:s,success:!0}),n.childDocs!=null)for(let o of n.childDocs){let n=await this.writeSkillReferenceDocument(e,a,i,o,t);r.push(...n)}if(n.resources!=null)for(let o of n.resources){let n=await this.writeSkillResource(e,a,i,o,t);r.push(...n)}}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalSkill`,path:o,error:t}),r.push({path:s,success:!1,error:e})}return r}buildCodexSkillContent(e){let t=e.yamlFrontMatter,n=this.normalizeSkillName(t.name,64),r=this.normalizeToSingleLine(t.description,1024),i={};t.displayName!=null&&(i[`short-description`]=t.displayName),t.version!=null&&(i.version=t.version),t.author!=null&&(i.author=t.author),t.keywords!=null&&t.keywords.length>0&&(i.keywords=[...t.keywords]);let a={name:n,description:r};return Object.keys(i).length>0&&(a.metadata=i),t.allowTools!=null&&t.allowTools.length>0&&(a[`allowed-tools`]=t.allowTools.join(` `)),Gd(a,e.content)}normalizeSkillName(e,t){let n=e.toLowerCase().replace(/[^a-z0-9-]/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``);return n.length>t&&(n=n.slice(0,t).replace(/-+$/,``)),n}normalizeToSingleLine(e,t){let n=e.replace(/[\r\n]+/g,` `).replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-3)}...`:n}async writeSkillReferenceDocument(e,t,n,r,i){let a=[],o=r.dir.path.replace(/\.mdx$/,`.md`),s=g.join(t,o),c={pathKind:N.Relative,path:g.join(jf,n,o),basePath:i,getDirectoryName:()=>n,getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillRefDoc`,path:s}),[{path:c,success:!0,skipped:!1}];try{let e=g.dirname(s);this.ensureDirectory(e),h.writeFileSync(s,r.content,`utf-8`),this.log.trace({action:`write`,type:`skillRefDoc`,path:s}),a.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillRefDoc`,path:s,error:t}),a.push({path:c,success:!1,error:e})}return a}async writeSkillResource(e,t,n,r,i){let a=[],o=g.join(t,r.relativePath),s={pathKind:N.Relative,path:g.join(jf,n,r.relativePath),basePath:i,getDirectoryName:()=>n,getAbsolutePath:()=>o};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillResource`,path:o}),[{path:s,success:!0,skipped:!1}];try{let e=g.dirname(o);this.ensureDirectory(e),h.writeFileSync(o,r.content,`utf-8`),this.log.trace({action:`write`,type:`skillResource`,path:o}),a.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillResource`,path:o,error:t}),a.push({path:s,success:!1,error:e})}return a}};const Pf=`AGENTS.md`,Q=`.factory`,Ff=`commands`,If=`agents`,Lf=`skills`,Rf=[Ff,If,Lf];var zf=class extends Jd{constructor(){super(`DroidCLIOutputPlugin`,{globalConfigDir:Q,outputFileName:Pf})}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.dirFromWorkspacePath!=null)for(let n of Rf){let r=g.join(e.dirFromWorkspacePath.path,Q,n);t.push({pathKind:N.Relative,path:r,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>g.join(e.dirFromWorkspacePath.basePath,r)})}return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{skills:r}=e.collectedInputContext;for(let e of n)if(e.dirFromWorkspacePath!=null&&r!=null)for(let n of r){let r=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),i=g.join(e.dirFromWorkspacePath.path,Q,Lf,r);if(t.push({pathKind:N.Relative,path:g.join(i,`SKILL.md`),basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>r,getAbsolutePath:()=>g.join(e.dirFromWorkspacePath.basePath,i,`SKILL.md`)}),n.childDocs!=null)for(let a of n.childDocs){let n=a.dir.path.replace(/\.mdx$/,`.md`),o=g.join(i,n);t.push({pathKind:N.Relative,path:o,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>r,getAbsolutePath:()=>g.join(e.dirFromWorkspacePath.basePath,o)})}if(n.resources!=null)for(let a of n.resources){let n=g.join(i,a.relativePath);t.push({pathKind:N.Relative,path:n,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>r,getAbsolutePath:()=>g.join(e.dirFromWorkspacePath.basePath,n)})}}return t}async registerGlobalOutputFiles(e){let{globalMemory:t}=e.collectedInputContext;if(t==null)return[];let n=this.getGlobalConfigDir();return[{pathKind:N.Relative,path:Pf,basePath:n,getDirectoryName:()=>Q,getAbsolutePath:()=>g.join(n,Pf)}]}async canWrite(e){let{globalMemory:t,fastCommands:n,subAgents:r,skills:i}=e.collectedInputContext,a=t!=null,o=(n?.length??0)>0,s=(r?.length??0)>0,c=(i?.length??0)>0;return!a&&!o&&!s&&!c?(this.log.trace({action:`skip`,reason:`noOutputs`}),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{fastCommands:n,subAgents:r,skills:i}=e.collectedInputContext,a=[],o=[];for(let o of t){let t=o.dirFromWorkspacePath;if(t!=null){if(n!=null)for(let r of n){let n=await this.writeFastCommand(e,t,r);a.push(...n)}if(r!=null)for(let n of r){let r=await this.writeSubAgent(e,t,n);a.push(...r)}if(i!=null)for(let n of i){let r=await this.writeSkill(e,t,n);a.push(...r)}}}return{files:a,dirs:o}}async writeGlobalOutputs(e){let{globalMemory:t}=e.collectedInputContext,n=[],r=[];if(t==null)return{files:n,dirs:r};let i=this.getGlobalConfigDir(),a=g.join(i,Pf),o={pathKind:N.Relative,path:Pf,basePath:i,getDirectoryName:()=>Q,getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMemory`,path:a}),{files:[{path:o,success:!0,skipped:!1}],dirs:r};try{this.ensureDirectory(i),h.writeFileSync(a,t.content,`utf-8`),this.log.trace({action:`write`,type:`globalMemory`,path:a}),n.push({path:o,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalMemory`,path:a,error:t}),n.push({path:o,success:!1,error:e})}return{files:n,dirs:r}}async writeFastCommand(e,t,n){let r=[],i=this.getTransformOptionsFromContext(e),a=this.transformFastCommandName(n,i),o=g.join(t.basePath,t.path,Q,Ff),s=g.join(o,a),c={pathKind:N.Relative,path:g.join(t.path,Q,Ff,a),basePath:t.basePath,getDirectoryName:()=>Ff,getAbsolutePath:()=>s},l=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`fastCommand`,path:s}),[{path:c,success:!0,skipped:!1}];try{this.ensureDirectory(o),h.writeFileSync(s,l,`utf-8`),this.log.trace({action:`write`,type:`fastCommand`,path:s}),r.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`fastCommand`,path:s,error:t}),r.push({path:c,success:!1,error:e})}return r}async writeSubAgent(e,t,n){let r=[],i=n.dir.path.endsWith(`.md`)?n.dir.path:`${n.dir.path}.md`,a=g.join(t.basePath,t.path,Q,If),o=g.join(a,i),s={pathKind:N.Relative,path:g.join(t.path,Q,If,i),basePath:t.basePath,getDirectoryName:()=>If,getAbsolutePath:()=>o},c=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`subAgent`,path:o}),[{path:s,success:!0,skipped:!1}];try{this.ensureDirectory(a),h.writeFileSync(o,c,`utf-8`),this.log.trace({action:`write`,type:`subAgent`,path:o}),r.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`subAgent`,path:o,error:t}),r.push({path:s,success:!1,error:e})}return r}async writeSkill(e,t,n){let r=[],i=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),a=g.join(t.basePath,t.path,Q,Lf,i),o=g.join(a,`SKILL.md`),s={pathKind:N.Relative,path:g.join(t.path,Q,Lf,i,`SKILL.md`),basePath:t.basePath,getDirectoryName:()=>i,getAbsolutePath:()=>o},c=n.yamlFrontMatter==null?void 0:{name:n.yamlFrontMatter.name,description:n.yamlFrontMatter.description},l=this.buildMarkdownContent(n.content,c);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skill`,path:o}),[{path:s,success:!0,skipped:!1}];try{if(this.ensureDirectory(a),h.writeFileSync(o,l,`utf-8`),this.log.trace({action:`write`,type:`skill`,path:o}),r.push({path:s,success:!0}),n.childDocs!=null)for(let o of n.childDocs){let n=await this.writeSkillReferenceDocument(e,a,i,o,t);r.push(...n)}if(n.resources!=null)for(let o of n.resources){let n=await this.writeSkillResource(e,a,i,o,t);r.push(...n)}}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skill`,path:o,error:t}),r.push({path:s,success:!1,error:e})}return r}async writeSkillReferenceDocument(e,t,n,r,i){let a=[],o=r.dir.path.replace(/\.mdx$/,`.md`),s=g.join(t,o),c={pathKind:N.Relative,path:g.join(i.path,Q,Lf,n,o),basePath:i.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillRefDoc`,path:s}),[{path:c,success:!0,skipped:!1}];try{let e=g.dirname(s);this.ensureDirectory(e),h.writeFileSync(s,r.content,`utf-8`),this.log.trace({action:`write`,type:`skillRefDoc`,path:s}),a.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillRefDoc`,path:s,error:t}),a.push({path:c,success:!1,error:e})}return a}async writeSkillResource(e,t,n,r,i){let a=[],o=g.join(t,r.relativePath),s={pathKind:N.Relative,path:g.join(i.path,Q,Lf,n,r.relativePath),basePath:i.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>o};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillResource`,path:o}),[{path:s,success:!0,skipped:!1}];try{let e=g.dirname(o);this.ensureDirectory(e),h.writeFileSync(o,r.content,`utf-8`),this.log.trace({action:`write`,type:`skillResource`,path:o}),a.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillResource`,path:o,error:t}),a.push({path:s,success:!1,error:e})}return a}},Bf=class extends X{constructor(){super(`FastCommandInputPlugin`)}extractSeriesInfo(e){let t=e.replace(/\.mdx$/,``),n=t.indexOf(`_`);return n===-1?{commandName:t}:{series:t.substring(0,n),commandName:t.substring(n+1)}}async collect(e){let{userConfigOptions:n,logger:r,globalScope:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(n),s=n.shadowFastCommandDir,c=this.resolvePath(s,a,o),l=[];if(e.fs.existsSync(c)&&e.fs.statSync(c).isDirectory()){let n=e.fs.readdirSync(c,{withFileTypes:!0});for(let a of n)if(a.isFile()&&a.name.endsWith(`.mdx`)){let n=e.path.join(c,a.name);try{let o=e.fs.readFileSync(n,`utf-8`),s=Kd(o),u=await xf(o,{globalScope:i,extractMetadata:!0,basePath:c}),d=s.yamlFrontMatter!=null||Object.keys(u.metadata.fields).length>0?{...s.yamlFrontMatter,...u.metadata.fields}:void 0;if(d!=null){let e=Ft(d,n);for(let t of e.warnings)r.debug(t);if(!e.valid)throw new t(e.errors,n)}let f=u.content,p=this.extractSeriesInfo(a.name);r.debug(`fast command metadata extracted`,{command:a.name,source:u.metadata.source,hasYaml:s.yamlFrontMatter!=null,hasExport:Object.keys(u.metadata.fields).length>0}),l.push({type:Ot.FastCommand,content:f,length:f.length,filePathKind:N.Relative,...d!=null&&{yamlFrontMatter:d},...s.rawFrontMatter!=null&&{rawFrontMatter:s.rawFrontMatter},markdownAst:s.markdownAst,markdownContents:s.markdownContents,dir:{pathKind:N.Relative,path:a.name,basePath:c,getDirectoryName:()=>a.name.replace(/\.mdx$/,``),getAbsolutePath:()=>n},...p.series!=null&&{series:p.series},commandName:p.commandName,rawMdxContent:o})}catch(e){r.error(`failed to parse fast command`,{file:n,error:e})}}}return{fastCommands:l}}};const Vf=`GEMINI.md`,Hf=`.gemini`;var Uf=class extends Jd{constructor(){super(`GeminiCLIOutputPlugin`,{globalConfigDir:Hf,outputFileName:Vf})}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.rootMemoryPrompt!=null&&e.dirFromWorkspacePath!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,Vf)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,Vf));return t}async registerGlobalOutputFiles(e){let{globalMemory:t}=e.collectedInputContext;if(t==null)return[];let n=this.getGlobalConfigDir();return[{pathKind:N.Relative,path:Vf,basePath:n,getDirectoryName:()=>Hf,getAbsolutePath:()=>g.join(n,Vf)}]}async canWrite(e){let{workspace:t,globalMemory:n}=e.collectedInputContext;return!t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)&&n==null?(this.log.trace({action:`skip`,reason:`noOutputs`}),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t){let t=r.name??`unknown`,i=r.dirFromWorkspacePath;if(i!=null){if(r.rootMemoryPrompt!=null){let a=await this.writePromptFile(e,i,r.rootMemoryPrompt.content,`project:${t}/root`);n.push(a)}if(r.childMemoryPrompts!=null)for(let i of r.childMemoryPrompts){let r=await this.writePromptFile(e,i.dir,i.content,`project:${t}/child:${i.workingChildDirectoryPath?.path??`unknown`}`);n.push(r)}}}return{files:n,dirs:r}}async writeGlobalOutputs(e){let{globalMemory:t}=e.collectedInputContext,n=[],r=[];if(t==null)return{files:n,dirs:r};let i=this.getGlobalConfigDir(),a=g.join(i,Vf),o={pathKind:N.Relative,path:Vf,basePath:i,getDirectoryName:()=>Hf,getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMemory`,path:a}),{files:[{path:o,success:!0,skipped:!1}],dirs:r};try{this.ensureDirectory(i),h.writeFileSync(a,t.content,`utf-8`),this.log.trace({action:`write`,type:`globalMemory`,path:a}),n.push({path:o,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalMemory`,path:a,error:t}),n.push({path:o,success:!1,error:e})}return{files:n,dirs:r}}};const Wf=`.skills`,Gf=`SKILL.md`,Kf=`mcp.json`;var qf=class extends Jd{constructor(){super(`GenericSkillsOutputPlugin`,{globalConfigDir:``,outputFileName:Gf})}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{skills:r}=e.collectedInputContext;if(r==null||r.length===0)return t;for(let e of n){if(e.dirFromWorkspacePath==null)continue;let n=this.joinPath(e.dirFromWorkspacePath.path,Wf);t.push({pathKind:N.Relative,path:n,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>Wf,getAbsolutePath:()=>this.joinPath(e.dirFromWorkspacePath.basePath,n)})}return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{skills:r}=e.collectedInputContext;if(r==null||r.length===0)return t;for(let e of n){if(e.dirFromWorkspacePath==null)continue;let n=this.joinPath(e.dirFromWorkspacePath.basePath,e.dirFromWorkspacePath.path,Wf);for(let i of r){let r=i.yamlFrontMatter.name,a=this.joinPath(n,r);if(t.push({pathKind:N.Relative,path:this.joinPath(Wf,r,Gf),basePath:this.joinPath(e.dirFromWorkspacePath.basePath,e.dirFromWorkspacePath.path),getDirectoryName:()=>r,getAbsolutePath:()=>this.joinPath(a,Gf)}),i.mcpConfig!=null&&t.push({pathKind:N.Relative,path:this.joinPath(Wf,r,Kf),basePath:this.joinPath(e.dirFromWorkspacePath.basePath,e.dirFromWorkspacePath.path),getDirectoryName:()=>r,getAbsolutePath:()=>this.joinPath(a,Kf)}),i.childDocs!=null)for(let n of i.childDocs){let i=n.relativePath.replace(/\.mdx$/,`.md`);t.push({pathKind:N.Relative,path:this.joinPath(Wf,r,i),basePath:this.joinPath(e.dirFromWorkspacePath.basePath,e.dirFromWorkspacePath.path),getDirectoryName:()=>r,getAbsolutePath:()=>this.joinPath(a,i)})}if(i.resources!=null)for(let n of i.resources)t.push({pathKind:N.Relative,path:this.joinPath(Wf,r,n.relativePath),basePath:this.joinPath(e.dirFromWorkspacePath.basePath,e.dirFromWorkspacePath.path),getDirectoryName:()=>r,getAbsolutePath:()=>this.joinPath(a,n.relativePath)})}}return t}async registerGlobalOutputDirs(){return[]}async registerGlobalOutputFiles(){return[]}async canWrite(e){let{skills:t}=e.collectedInputContext,{projects:n}=e.collectedInputContext.workspace;return t==null||t.length===0?(this.log.trace({action:`skip`,reason:`noSkills`}),!1):n.length===0?(this.log.trace({action:`skip`,reason:`noProjects`}),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{skills:n}=e.collectedInputContext,r=[],i=[];if(n==null||n.length===0)return{files:r,dirs:i};for(let i of t){if(i.dirFromWorkspacePath==null)continue;let t=this.joinPath(i.dirFromWorkspacePath.basePath,i.dirFromWorkspacePath.path,Wf);for(let i of n){let n=await this.writeSkill(e,i,t);r.push(...n)}}return{files:r,dirs:i}}async writeGlobalOutputs(){return{files:[],dirs:[]}}async writeSkill(e,t,n){let r=[],i=t.yamlFrontMatter.name,a=this.joinPath(n,i),o=this.joinPath(a,Gf),s={pathKind:N.Relative,path:Gf,basePath:a,getDirectoryName:()=>i,getAbsolutePath:()=>o},c=this.buildSkillFrontMatter(t),l=t.content,u=Gd(c,l);if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`skill`,path:o}),r.push({path:s,success:!0,skipped:!1});else try{this.ensureDirectory(a),this.writeFileSync(o,u),this.log.trace({action:`write`,type:`skill`,path:o}),r.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skill`,path:o,error:t}),r.push({path:s,success:!1,error:e})}if(t.mcpConfig!=null){let n=await this.writeMcpConfig(e,t,a);r.push(n)}if(t.childDocs!=null)for(let n of t.childDocs){let t=await this.writeChildDoc(e,n,a,i);r.push(t)}if(t.resources!=null)for(let n of t.resources){let t=await this.writeResource(e,n,a,i);r.push(t)}return r}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:t.name,description:t.description,...t.displayName!=null&&{displayName:t.displayName},...t.keywords!=null&&t.keywords.length>0&&{keywords:t.keywords},...t.author!=null&&{author:t.author},...t.version!=null&&{version:t.version},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}async writeMcpConfig(e,t,n){let r=t.yamlFrontMatter.name,i=this.joinPath(n,Kf),a={pathKind:N.Relative,path:Kf,basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>i},o=t.mcpConfig.rawContent;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfig`,path:i}),{path:a,success:!0,skipped:!1};try{return this.ensureDirectory(n),this.writeFileSync(i,o),this.log.trace({action:`write`,type:`mcpConfig`,path:i}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`mcpConfig`,path:i,error:t}),{path:a,success:!1,error:e}}}async writeChildDoc(e,t,n,r){let i=t.relativePath.replace(/\.mdx$/,`.md`),a=this.joinPath(n,i),o={pathKind:N.Relative,path:i,basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>a},s=t.content;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`childDoc`,path:a}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,s),this.log.trace({action:`write`,type:`childDoc`,path:a}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`childDoc`,path:a,error:t}),{path:o,success:!1,error:e}}}async writeResource(e,t,n,r){let i=this.joinPath(n,t.relativePath),a={pathKind:N.Relative,path:t.relativePath,basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>i};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`resource`,path:i}),{path:a,success:!0,skipped:!1};try{let e=this.dirname(i);if(this.ensureDirectory(e),t.encoding===`base64`){let e=w.from(t.content,`base64`);this.writeFileSyncBuffer(i,e)}else this.writeFileSync(i,t.content);return this.log.trace({action:`write`,type:`resource`,path:i}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`resource`,path:i,error:t}),{path:a,success:!1,error:e}}}},Jf=class extends X{constructor(){super(`GlobalMemoryInputPlugin`)}async collect(e){let{userConfigOptions:t,fs:n,path:r,globalScope:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.globalMemoryFile,c=this.resolvePath(s,a,o);if(!n.existsSync(c))return this.log.warn({action:`collect`,reason:`fileNotFound`,path:c}),{};if(!n.statSync(c).isFile())return this.log.warn({action:`collect`,reason:`notAFile`,path:c}),{};let l=n.readFileSync(c,`utf-8`),u=Kd(l),f;if(i!=null)try{f=await xf(l,{globalScope:i,basePath:r.dirname(c)})}catch(e){throw e instanceof d&&(this.log.error(`MDX compilation failed: ${e.message}`),this.log.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),this.log.error(`For example, if using {profile.name}, add a "profile" section with "name" field to your config.`),m.exit(1)),e}else f=u.contentWithoutFrontMatter;return this.log.debug({action:`collect`,path:c,contentLength:f.length}),{globalMemory:{type:Ot.GlobalMemory,content:f,length:f.length,filePathKind:N.Relative,...u.rawFrontMatter!=null&&{rawFrontMatter:u.rawFrontMatter},markdownAst:u.markdownAst,markdownContents:u.markdownContents,dir:{pathKind:N.Relative,path:r.basename(c),basePath:r.dirname(c),getDirectoryName:()=>r.basename(c),getAbsolutePath:()=>c},parentDirectoryPath:{type:Mt.UserHome,directory:{pathKind:N.Relative,path:``,basePath:v.homedir(),getDirectoryName:()=>r.basename(v.homedir()),getAbsolutePath:()=>v.homedir()}}}}}},Yf=class extends X{constructor(){super(`IdeConfigInputPlugin`)}collect(e){let{userConfigOptions:t,fs:n,path:r}=e,{shadowProjectDir:i}=this.resolveBasePaths(t),a=[`.editorconfig`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`,`.vscode/settings.json`,`.vscode/extensions.json`],o=[];for(let e of a){let t=r.join(i,e);if(n.existsSync(t)&&n.statSync(t).isFile()){let i=n.readFileSync(t,`utf-8`),a=P.Original;e.includes(`.vscode`)?a=P.VSCode:e.includes(`.idea`)?a=P.IntellijIDEA:e.includes(`.editorconfig`)&&(a=P.EditorConfig),o.push({type:a,content:i,length:i.length,filePathKind:N.Absolute,dir:{pathKind:N.Absolute,path:t,getDirectoryName:()=>r.basename(t)}})}}return{ideConfigFiles:o}}};const Xf=`.idea`,Zf=[`.editorconfig`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`];var Qf=class extends Jd{constructor(){super(`JetBrainsIDECodeStyleConfigOutputPlugin`)}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{ideConfigFiles:r}=e.collectedInputContext;if(!r.some(e=>e.type===P.IntellijIDEA||e.type===P.EditorConfig))return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&e.isPromptSourceProject!==!0)for(let e of Zf){let r=this.joinPath(n.path,e);t.push({pathKind:N.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>this.dirname(e),getAbsolutePath:()=>this.resolvePath(n.basePath,r)})}}return t}async canWrite(e){let{ideConfigFiles:t}=e.collectedInputContext;return t.some(e=>e.type===P.IntellijIDEA||e.type===P.EditorConfig)?!0:(this.log.debug(`skipped`,{reason:`no JetBrains IDE config files found`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{ideConfigFiles:n}=e.collectedInputContext,r=[],i=[],a=n.filter(e=>e.type===P.IntellijIDEA||e.type===P.EditorConfig);for(let n of t){let t=n.dirFromWorkspacePath;if(t==null)continue;let i=n.name??`unknown`;for(let n of a){let a=await this.writeConfigFile(e,t,n,`project:${i}`);r.push(a)}}return{files:r,dirs:i}}async writeConfigFile(e,t,n,r){let i=this.getTargetRelativePath(n),a=this.resolvePath(t.basePath,t.path,i),o={pathKind:N.Relative,path:this.joinPath(t.path,i),basePath:t.basePath,getDirectoryName:()=>this.dirname(i),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`config`,path:a,label:r}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,n.content),this.log.trace({action:`write`,type:`config`,path:a,label:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`config`,path:a,label:r,error:t}),{path:o,success:!1,error:e}}}getTargetRelativePath(e){let t=e.dir.path;if(e.type===P.EditorConfig)return`.editorconfig`;if(e.type===P.IntellijIDEA){let e=t.indexOf(Xf);return e===-1?this.joinPath(Xf,`codeStyles`,this.basename(t)):t.substring(e)}return this.basename(t)}},$f=class{registryPath;log;constructor(e,t){this.registryPath=this.resolvePath(e),this.log=t??Fn(this.constructor.name)}resolvePath(e){return e.startsWith(`~`)?g.join(v.homedir(),e.slice(1)):g.resolve(e)}getRegistryDir(){return g.dirname(this.registryPath)}ensureRegistryDir(){let e=this.getRegistryDir();h.existsSync(e)||h.mkdirSync(e,{recursive:!0})}read(){if(!h.existsSync(this.registryPath))return this.log.debug(`registry not found`,{path:this.registryPath}),this.createInitialRegistry();try{let e=h.readFileSync(this.registryPath,`utf-8`);return JSON.parse(e)}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error(`parse failed`,{path:this.registryPath,error:t}),this.createInitialRegistry()}}write(e,t){let n={...e,lastUpdated:new Date().toISOString()};if(t===!0)return this.log.trace({action:`dryRun`,type:`registry`,path:this.registryPath}),!0;let r=`${this.registryPath}.tmp.${Date.now()}`;try{this.ensureRegistryDir();let e=JSON.stringify(n,null,2);return h.writeFileSync(r,e,`utf-8`),h.renameSync(r,this.registryPath),this.log.trace({action:`write`,type:`registry`,path:this.registryPath}),!0}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`registry`,path:this.registryPath,error:t});try{h.existsSync(r)&&h.unlinkSync(r)}catch{}return!1}}register(e,t){let n=[],r=this.read(),i=this.merge(r,e),a=this.write(i,t);for(let r of e){let e=this.getEntryName(r);a?(n.push({success:!0,entryName:e}),t===!0?this.log.trace({action:`dryRun`,type:`registerEntry`,entryName:e}):this.log.trace({action:`register`,type:`entry`,entryName:e})):(n.push({success:!1,entryName:e,error:Error(`Failed to write registry file`)}),this.log.error(`register entry failed`,{entryName:e}))}return n}generateEntryId(e){let t=`${Date.now()}-${Math.random().toString(36).substring(2,8)}`;return e==null?t:`${e}-${t}`}},ep=class e extends $f{static REGISTRY_PATH=`~/.kiro/powers/registry.json`;static DEFAULT_VERSION=`1.0.0`;constructor(t){super(e.REGISTRY_PATH,t)}createInitialRegistry(){return{version:e.DEFAULT_VERSION,powers:{},repoSources:{},lastUpdated:new Date().toISOString()}}getEntryName(e){return e.name}merge(e,t){let n={...e.powers},r={...e.repoSources};for(let e of t){n[e.name]=e;let t=this.buildRepoSource(e),i=e.source.repoId??e.name;r[i]=t}return{version:e.version,powers:n,repoSources:r,...e.kiroRecommendedRepo!=null&&{kiroRecommendedRepo:e.kiroRecommendedRepo},lastUpdated:e.lastUpdated}}buildPowerEntry(e,t){let{yamlFrontMatter:n,mcpConfig:r}=e,i={type:`repo`,repoId:this.generateEntryId(`local`),repoName:t},a=r==null?null:Object.keys(r.mcpServers);return{name:n.name,description:n.description,...a!=null&&a.length>0&&{mcpServers:a},...n.author!=null&&{author:n.author},keywords:n.keywords??[],...n.displayName!=null&&{displayName:n.displayName},installed:!0,installedAt:new Date().toISOString(),installPath:t,source:i,sourcePath:t}}getOfficialRegistry(){try{return JSON.parse({version:`1.0.0`,powers:{postman:{name:`postman`,description:`Automate API testing and collection management with Postman - create workspaces, collections, environments, and run tests programmatically`,displayName:`API Testing with Postman`,author:`Postman`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/postman.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/postman`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`postman`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},figma:{name:`figma`,description:`Connect Figma designs to code components - automatically generate design system rules, map UI components to Figma designs, and maintain design-code consistency`,displayName:`Design to Code with Figma`,author:`Figma`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/figma.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/figma`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`figma`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"netlify-deployment":{name:`netlify-deployment`,description:`Deploy React, Next.js, Vue, and other modern web apps to Netlify's global CDN with automatic builds.`,displayName:`Deploy web apps with Netlify`,author:`Netlify`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/netlify.png`,repositoryUrl:`https://github.com/netlify/context-and-tools/tree/main/context/steering/netlify-deployment-power`,license:``,repositoryCloneUrl:`git@github.com:netlify/context-and-tools.git`,pathInRepo:`context/steering/netlify-deployment-power`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"amazon-aurora-postgresql":{name:`amazon-aurora-postgresql`,description:`Build applications backed by Aurora PostgreSQL by leveraging Aurora PostgreSQL specific best practices.`,displayName:`Build applications with Aurora PostgreSQL`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/amazon-aurora.png`,repositoryUrl:`https://github.com/awslabs/mcp/tree/main/src/postgres-mcp-server/kiro_power`,license:``,repositoryCloneUrl:`git@github.com:awslabs/mcp.git`,pathInRepo:`src/postgres-mcp-server/kiro_power`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"supabase-hosted":{name:`supabase-hosted`,description:`Build applications with Supabase's Postgres database, authentication, storage, and real-time subscriptions`,displayName:`Build a backend with Supabase`,author:`Supabase`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/supabase.png`,repositoryUrl:`https://github.com/supabase-community/kiro-powers/tree/main/powers/supabase-hosted`,license:``,repositoryCloneUrl:`git@github.com:supabase-community/kiro-powers.git`,pathInRepo:`powers/supabase-hosted`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"supabase-local":{name:`supabase-local`,description:`Local development with Supabase allows you to work on your projects in a self-contained environment on your local machine.`,displayName:`Build a backend (local) with Supabase`,author:`Supabase`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/supabase.png`,repositoryUrl:`https://github.com/supabase-community/kiro-powers/tree/main/powers/supabase-local`,license:``,repositoryCloneUrl:`git@github.com:supabase-community/kiro-powers.git`,pathInRepo:`powers/supabase-local`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},terraform:{name:`terraform`,description:`Build and manage Infrastructure as Code with Terraform - access registry providers, modules, policies, and HCP Terraform workflow management`,displayName:`Deploy infrastructure with Terraform`,author:`HashiCorp`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/terraform.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/terraform`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`terraform`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},strands:{name:`strands`,description:`Build AI agents with Strands Agent SDK using Bedrock, Anthropic, OpenAI, Gemini, or Llama models`,displayName:`Build an agent with Strands`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/strands.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/strands`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`strands`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aws-agentcore":{name:`aws-agentcore`,description:`Amazon Bedrock AgentCore is an agentic platform for building, deploying, and operating effective agents.`,displayName:`Build an agent with Amazon Bedrock AgentCore`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/agentcore.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aws-agentcore`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aws-agentcore`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},neon:{name:`neon`,description:`Serverless Postgres with database branching, autoscaling, and scale-to-zero - perfect for modern development workflows`,displayName:`Build a database with Neon`,author:`Neon`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/neon.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/neon`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`neon`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},datadog:{name:`datadog`,description:`Query logs, metrics, traces, RUM events, incidents, and monitors from Datadog for production debugging and performance analysis`,displayName:`Datadog Observability`,author:`Datadog`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/datadog.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/datadog`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`datadog`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},dynatrace:{name:`dynatrace`,description:`Query logs, metrics, traces, problems, and Kubernetes events from Dynatrace using DQL for production debugging and performance analysis`,displayName:`Dynatrace Observability`,author:`Dynatrace`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/dynatrace.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/dynatrace`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`dynatrace`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},stripe:{name:`stripe`,description:`Build payment integrations with Stripe - accept payments, manage subscriptions, handle billing, and process refunds`,displayName:`Stripe Payments`,author:`Stripe`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/stripe.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/stripe`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`stripe`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aws-infrastructure-as-code":{name:`aws-infrastructure-as-code`,description:`Build well-architected AWS infrastructure with CDK using latest documentation, best practices, and code samples. Validate CloudFormation templates, check resource configuration security compliance, and troubleshoot deployments.`,displayName:`Build AWS infrastructure with CDK and CloudFormation`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/iac.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aws-infrastructure-as-code`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aws-infrastructure-as-code`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"power-builder":{name:`power-builder`,description:`Complete guide for building and testing new Kiro Powers with templates, best practices, and validation`,displayName:`Build a Power`,author:`Kiro Team`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/power-builder`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`power-builder`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"saas-builder":{name:`saas-builder`,description:`Build production ready multi-tenant SaaS applications with serverless architecture, integrated billing, and enterprise grade security`,displayName:`SaaS Builder`,author:`Allen Helton`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/saas-builder`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`saas-builder`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"cloud-architect":{name:`cloud-architect`,description:`Build AWS infrastructure with CDK in Python following AWS Well-Architected framework best practices`,displayName:`Build infrastructure on AWS`,author:`Christian Bonzelet`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/cloud-architect`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`cloud-architect`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aurora-dsql":{name:`aurora-dsql`,description:`For PostgreSQL compatible serverless distributed SQL database with Aurora DSQL, manage schemas, execute queries, and handle migrations with DSQL-specific constraints`,displayName:`Deploy a distributed SQL database on AWS`,author:`Rolf Koski`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aurora-dsql`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aurora-dsql`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}}},repoSources:{},lastUpdated:`2025-12-28T20:19:10.824Z`,kiroRecommendedRepo:{url:`https://prod.download.desktop.kiro.dev/powers/default_registry.json`,lastFetch:`2025-12-28T20:19:10.823Z`,powerCount:18}})}catch{this.log.debug(`Failed to parse official registry, using empty registry`)}return this.createInitialRegistry()}unregisterLocalPowers(e){let t={...this.getOfficialRegistry(),lastUpdated:new Date().toISOString()};return this.log.trace({action:e===!0?`dryRun`:`reset`,type:`registry`,powerCount:Object.keys(t.powers).length}),this.write(t,e)}buildRepoSource(e){let t=new Date().toISOString();return{name:e.sourcePath??e.installPath??e.name,type:`local`,enabled:!0,addedAt:t,powerCount:1,...e.sourcePath!=null&&{path:e.sourcePath},lastSync:t}}};const tp=`GLOBAL.md`,np=`.kiro`,$=`steering`,rp=`settings`,ip=`mcp.json`,ap=`POWER.md`;var op=class extends Jd{constructor(){super(`KiroCLIOutputPlugin`,{globalConfigDir:np,outputFileName:tp}),this.registerCleanEffect(`registry-cleanup`,async e=>this.getRegistryWriter(ep).unregisterLocalPowers(e.dryRun)?{success:!0,description:`Reset registry to official state`}:{success:!1,error:Error(`Failed to clean registry`),description:`Failed to reset registry`}),this.registerCleanEffect(`mcp-settings-cleanup`,async e=>{let t=this.getGlobalSettingsDir(),n=this.joinPath(t,ip),r={mcpServers:{},powers:{mcpServers:{}}};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpSettingsCleanup`,path:n}),{success:!0,description:`Would reset mcp.json to empty shell`};try{return this.ensureDirectory(t),this.writeFileSync(n,JSON.stringify(r,null,2)),this.log.trace({action:`clean`,type:`mcpSettingsCleanup`,path:n}),{success:!0,description:`Reset mcp.json to empty shell`}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`clean`,type:`mcpSettingsCleanup`,path:n,error:t}),{success:!1,error:e,description:`Failed to reset mcp.json`}}})}getGlobalSettingsDir(){return this.joinPath(this.getHomeDir(),np,rp)}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n){if(e.dirFromWorkspacePath==null)continue;let n=this.joinPath(e.dirFromWorkspacePath.path,np,$);t.push({pathKind:N.Relative,path:n,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(e.dirFromWorkspacePath.basePath,n)})}return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.dirFromWorkspacePath!=null&&e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts){let r=this.buildSteeringFileName(n),i=this.joinPath(e.dirFromWorkspacePath.path,np,$,r);t.push({pathKind:N.Relative,path:i,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(e.dirFromWorkspacePath.basePath,i)})}return t}async registerGlobalOutputDirs(){let e=this.getGlobalSteeringDir(),t=[{pathKind:N.Relative,path:$,basePath:this.joinPath(this.getGlobalConfigDir()),getDirectoryName:()=>$,getAbsolutePath:()=>e}],n=this.getKiroPowersDir(),r=this.listInstalledPowers(n);for(let e of r){let r=this.joinPath(n,e);t.push({pathKind:N.Relative,path:e,basePath:n,getDirectoryName:()=>e,getAbsolutePath:()=>r})}let i=this.getKiroPowersReposDir();return t.push({pathKind:N.Relative,path:`repos`,basePath:this.joinPath(this.getHomeDir(),`.kiro/powers`),getDirectoryName:()=>`repos`,getAbsolutePath:()=>i}),t}listInstalledPowers(e){try{return this.existsSync(e)?this.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name):[]}catch{return this.log.debug({action:`listInstalledPowers`,error:`Failed to read powers directory`}),[]}}async registerGlobalOutputFiles(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=this.getGlobalSteeringDir();if(t!=null&&i.push({pathKind:N.Relative,path:tp,basePath:a,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(a,tp)}),n!=null)for(let e of n){let t=this.buildFastCommandSteeringFileName(e);i.push({pathKind:N.Relative,path:t,basePath:a,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(a,t)})}if(r!=null){let e=this.getKiroPowersDir();for(let t of r){let n=t.yamlFrontMatter.name,r=this.joinPath(e,n);if(i.push({pathKind:N.Relative,path:ap,basePath:r,getDirectoryName:()=>n,getAbsolutePath:()=>this.joinPath(r,ap)}),t.mcpConfig!=null&&i.push({pathKind:N.Relative,path:ip,basePath:r,getDirectoryName:()=>n,getAbsolutePath:()=>this.joinPath(r,ip)}),t.childDocs!=null){let e=this.joinPath(r,$);for(let n of t.childDocs){let t=n.dir.path.replace(/\.mdx$/,`.md`);i.push({pathKind:N.Relative,path:this.joinPath($,t),basePath:r,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(e,t)})}}if(t.resources!=null){let e=this.joinPath(r,$);for(let n of t.resources)i.push({pathKind:N.Relative,path:this.joinPath($,n.relativePath),basePath:r,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(e,n.relativePath)})}}if(r.some(e=>e.mcpConfig!=null)){let e=this.getGlobalSettingsDir();i.push({pathKind:N.Relative,path:ip,basePath:e,getDirectoryName:()=>rp,getAbsolutePath:()=>this.joinPath(e,ip)})}}return i}async canWrite(e){let{workspace:t,globalMemory:n,fastCommands:r,skills:i}=e.collectedInputContext,a=t.projects.some(e=>(e.childMemoryPrompts?.length??0)>0),o=n!=null,s=(r?.length??0)>0,c=(i?.length??0)>0;return!a&&!o&&!s&&!c?(this.log.trace({action:`skip`,reason:`noOutputs`}),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t)if(r.dirFromWorkspacePath!=null&&r.childMemoryPrompts!=null)for(let t of r.childMemoryPrompts){let i=await this.writeSteeringFile(e,r,t);n.push(i)}return{files:n,dirs:r}}async writeGlobalOutputs(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=[],o=[];if(t!=null){let n=this.getGlobalSteeringDir(),r=this.joinPath(n,tp),a={pathKind:N.Relative,path:tp,basePath:n,getDirectoryName:()=>$,getAbsolutePath:()=>r};if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`globalMemory`,path:r}),i.push({path:a,success:!0,skipped:!1});else try{this.ensureDirectory(n),this.writeFileSync(r,t.content),this.log.trace({action:`write`,type:`globalMemory`,path:r}),i.push({path:a,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalMemory`,path:r,error:t}),i.push({path:a,success:!1,error:e})}}if(n!=null)for(let t of n){let n=await this.writeFastCommandSteeringFile(e,t);i.push(n)}if(r!=null&&r.length>0){this.log.debug(`Processing ${r.length} skills as Kiro Powers`);for(let t of r){let{fileResults:n,registryResult:r}=await this.writeSkillAsPower(e,t);i.push(...n),o.push(r)}let t=await this.writeGlobalMcpSettings(e,r);t!=null&&i.push(t),this.logRegistryResults(o,e.dryRun)}return{files:i,dirs:a}}async writeGlobalMcpSettings(e,t){let n={};for(let e of t){if(e.mcpConfig==null)continue;let t=e.yamlFrontMatter.name,r=e.mcpConfig.mcpServers;for(let[e,i]of Object.entries(r)){let r=`power-${t}-${e}`;n[r]=i}}if(Object.keys(n).length===0)return null;let r=this.getGlobalSettingsDir(),i=this.joinPath(r,ip),a={pathKind:N.Relative,path:ip,basePath:r,getDirectoryName:()=>rp,getAbsolutePath:()=>i},o={mcpServers:{},powers:{mcpServers:n}},s=JSON.stringify(o,null,2);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMcpSettings`,path:i,serverCount:Object.keys(n).length}),{path:a,success:!0,skipped:!1};try{return this.ensureDirectory(r),this.writeFileSync(i,s),this.log.trace({action:`write`,type:`globalMcpSettings`,path:i,serverCount:Object.keys(n).length}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalMcpSettings`,path:i,error:t}),{path:a,success:!1,error:e}}}logRegistryResults(e,t){let n=e.filter(e=>e.success).length,r=e.filter(e=>!e.success).length;if(n>0&&this.log.trace({action:t===!0?`dryRun`:`register`,type:`registrySummary`,successCount:n}),r>0){this.log.error({action:`register`,type:`registrySummary`,failCount:r});for(let t of e)if(!t.success){let e=t.error?.message??`Unknown error`;this.log.error({action:`register`,type:`registryEntry`,entryName:t.entryName,error:e})}}}getGlobalSteeringDir(){return this.joinPath(this.getGlobalConfigDir(),$)}getKiroPowersDir(){return this.joinPath(this.getHomeDir(),`.kiro/powers/installed`)}getKiroPowersReposDir(){return this.joinPath(this.getHomeDir(),`.kiro/powers/repos`)}buildPowerFrontMatter(e){return Gd({name:e.name,displayName:e.displayName,description:e.description,keywords:e.keywords,author:e.author},``).trimEnd()}async writeSkillAsPower(e,t){let n=[],r=t.yamlFrontMatter.name,i=this.joinPath(this.getKiroPowersDir(),r),a=this.joinPath(i,ap),o={pathKind:N.Relative,path:ap,basePath:i,getDirectoryName:()=>r,getAbsolutePath:()=>a},s=`${this.buildPowerFrontMatter(t.yamlFrontMatter)}\n${t.content}`;if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`skillPower`,path:a}),n.push({path:o,success:!0,skipped:!1});else try{this.ensureDirectory(i),this.writeFileSync(a,s),this.log.trace({action:`write`,type:`skillPower`,path:a}),n.push({path:o,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillPower`,path:a,error:t}),n.push({path:o,success:!1,error:e})}if(t.childDocs!=null){let r=this.joinPath(i,$);for(let a of t.childDocs){let t=a.dir.path.replace(/\.mdx$/,`.md`),o=this.joinPath(r,t),s={pathKind:N.Relative,path:this.joinPath($,t),basePath:i,getDirectoryName:()=>$,getAbsolutePath:()=>o},c=a.content;if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`refDoc`,path:o}),n.push({path:s,success:!0,skipped:!1});else try{let e=this.dirname(o);this.ensureDirectory(e),this.writeFileSync(o,c),this.log.trace({action:`write`,type:`refDoc`,path:o}),n.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`refDoc`,path:o,error:t}),n.push({path:s,success:!1,error:e})}}}if(t.resources!=null){let r=this.joinPath(i,$);for(let a of t.resources){let t=this.joinPath(r,a.relativePath),o={pathKind:N.Relative,path:this.joinPath($,a.relativePath),basePath:i,getDirectoryName:()=>$,getAbsolutePath:()=>t};if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`resource`,path:t}),n.push({path:o,success:!0,skipped:!1});else try{let e=this.dirname(t);this.ensureDirectory(e),this.writeFileSync(t,a.content),this.log.trace({action:`write`,type:`resource`,path:t}),n.push({path:o,success:!0})}catch(e){let r=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`resource`,path:t,error:r}),n.push({path:o,success:!1,error:e})}}}if(t.mcpConfig!=null){let r=await this.writeSkillMcpConfig(e,t,i);n.push(r)}let c=this.getRegistryWriter(ep),l=c.buildPowerEntry(t,i);return{fileResults:n,registryResult:(await this.registerInRegistry(c,[l],e))[0]??{success:!1,entryName:r,error:Error(`No registry result returned`)}}}async writeSkillMcpConfig(e,t,n){let r=t.yamlFrontMatter.name,i=this.joinPath(n,ip),a={pathKind:N.Relative,path:ip,basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>i},o=t.mcpConfig.rawContent;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfig`,path:i,skill:r}),{path:a,success:!0,skipped:!1};try{return this.ensureDirectory(n),this.writeFileSync(i,o),this.log.trace({action:`write`,type:`mcpConfig`,path:i,skill:r}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`mcpConfig`,path:i,error:t}),{path:a,success:!1,error:e}}}buildFastCommandSteeringFileName(e){return this.transformFastCommandName(e,{includeSeriesPrefix:!0,seriesSeparator:`-`})}buildFastCommandSteeringContent(e){let t=e.yamlFrontMatter?.description;return Gd({inclusion:`manual`,description:t!=null&&t.length>0?t:null},e.content)}async writeFastCommandSteeringFile(e,t){let n=this.getGlobalSteeringDir(),r=this.buildFastCommandSteeringFileName(t),i=this.joinPath(n,r),a={pathKind:N.Relative,path:r,basePath:n,getDirectoryName:()=>$,getAbsolutePath:()=>i},o=this.buildFastCommandSteeringContent(t);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`fastCommandSteering`,path:i}),{path:a,success:!0,skipped:!1};try{return this.ensureDirectory(n),this.writeFileSync(i,o),this.log.trace({action:`write`,type:`fastCommandSteering`,path:i}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`fastCommandSteering`,path:i,error:t}),{path:a,success:!1,error:e}}}buildSteeringFileName(e){return`kiro-${(e.workingChildDirectoryPath?.path??e.dir.path).replace(/\\/g,`/`).replace(/^\/+|\/+$/g,``).replace(/\//g,`-`)}.md`}buildSteeringContent(e){return Gd({inclusion:`fileMatch`,fileMatchPattern:`${(e.workingChildDirectoryPath?.path??e.dir.path).replace(/\\/g,`/`)}/**`},e.content)}async writeSteeringFile(e,t,n){let r=t.dirFromWorkspacePath,i=this.buildSteeringFileName(n),a=this.joinPath(r.basePath,r.path,np,$),o=this.joinPath(a,i),s={pathKind:N.Relative,path:this.joinPath(r.path,np,$,i),basePath:r.basePath,getDirectoryName:()=>$,getAbsolutePath:()=>o},c=this.buildSteeringContent(n);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`steeringFile`,path:o}),{path:s,success:!0,skipped:!1};try{return this.ensureDirectory(a),this.writeFileSync(o,c),this.log.trace({action:`write`,type:`steeringFile`,path:o}),{path:s,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`steeringFile`,path:o,error:t}),{path:s,success:!1,error:e}}}},sp=class extends X{constructor(){super(`MarkdownWhitespaceCleanupEffectInputPlugin`),this.registerEffect(`markdown-whitespace-cleanup`,this.cleanupWhitespace.bind(this),30)}async cleanupWhitespace(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=[],s=[],c=[],l=[n.join(r,`src`),n.join(r,`app`),n.join(r,`dist`)];for(let n of l){if(!t.existsSync(n)){a.debug({action:`whitespace-cleanup`,message:`Directory does not exist, skipping`,dir:n});continue}this.processDirectory(e,n,o,s,c,i??!1)}let u=c.length>0;return u&&a.warn({action:`whitespace-cleanup`,errors:c.map(e=>({path:e.path,error:e.error.message}))}),{success:!u,description:i?`Would modify ${o.length} files, skip ${s.length} files`:`Modified ${o.length} files, skipped ${s.length} files`,modifiedFiles:o,skippedFiles:s,...u&&{error:Error(`${c.length} errors occurred during cleanup`)}}}processDirectory(e,t,n,r,i,a){let{fs:o,path:s,logger:c}=e,l;try{l=o.readdirSync(t,{withFileTypes:!0})}catch(e){i.push({path:t,error:e}),c.warn({action:`whitespace-cleanup`,message:`Failed to read directory`,path:t,error:e.message});return}for(let o of l){let c=s.join(t,o.name);o.isDirectory()?this.processDirectory(e,c,n,r,i,a):o.isFile()&&o.name.endsWith(`.md`)&&this.processMarkdownFile(e,c,n,r,i,a)}}processMarkdownFile(e,t,n,r,i,a){let{fs:o,logger:s}=e;try{let e=o.readFileSync(t,`utf-8`),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,`utf-8`),n.push(t),s.debug({action:`whitespace-cleanup`,modified:t}))}catch(e){i.push({path:t,error:e}),s.warn({action:`whitespace-cleanup`,message:`Failed to process file`,path:t,error:e.message})}}cleanMarkdownContent(e){let t=this.detectLineEnding(e),n=e.split(/\r?\n/).map(e=>e.replace(/[ \t]+$/,``)),r=[],i=0;for(let e of n)e===``?(i++,i<=2&&r.push(e)):(i=0,r.push(e));return r.join(t)}detectLineEnding(e){return e.includes(`\r
|
|
280
|
+
`,skipIfEmpty:i=!0,position:a=`before`}=n??{};if(i&&(e==null||e.trim().length===0))return t;let o=e??``;return a===`after`?`${t}${r}${o}`:`${o}${r}${t}`}transformFastCommandName(e,t){let{includeSeriesPrefix:n=!0,seriesSeparator:r=`_`}=t??{};return!n||e.series==null?`${e.commandName}.md`:`${e.series}${r}${e.commandName}.md`}getFastCommandSeriesOptions(e){let t=e.pluginOptions?.fastCommandSeriesOptions,n=t?.pluginOverrides?.[this.name],r=n?.includeSeriesPrefix??t?.includeSeriesPrefix,i=n?.seriesSeparator;return r!=null&&i!=null?{includeSeriesPrefix:r,seriesSeparator:i}:r==null?i==null?{}:{seriesSeparator:i}:{includeSeriesPrefix:r}}getTransformOptionsFromContext(e,t){let n=this.getFastCommandSeriesOptions(e),r=n.includeSeriesPrefix??t?.includeSeriesPrefix,i=n.seriesSeparator??t?.seriesSeparator;return r!=null&&i!=null?{includeSeriesPrefix:r,seriesSeparator:i}:r==null?i==null?{}:{seriesSeparator:i}:{includeSeriesPrefix:r}}shouldSkipDueToPlugin(e,t){let n=e.registeredPluginNames;return n==null?!1:n.includes(t)}async onWriteComplete(e,t){let n=t.files.filter(e=>e.success).length,r=t.files.filter(e=>e.skipped).length,i=t.files.filter(e=>!e.success&&!e.skipped).length;this.log.trace({action:e.dryRun===!0?`dryRun`:`complete`,type:`writeSummary`,success:n,skipped:r,failed:i}),await this.executeWriteEffects(e)}async onCleanComplete(e){await this.executeCleanEffects(e)}getRegistryWriter(e){let t=e.name,n=this.registryWriterCache.get(t);if(n!=null)return n;let r=new e(this.log);return this.registryWriterCache.set(t,r),r}async registerInRegistry(e,t,n){return e.register(t,n.dryRun)}};const Yd=`AGENTS.md`;var Xd=class extends Jd{constructor(){super(`AgentsOutputPlugin`,{outputFileName:Yd})}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.rootMemoryPrompt!=null&&e.dirFromWorkspacePath!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,Yd)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,Yd));return t}async canWrite(e){let{workspace:t}=e.collectedInputContext;return t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t){let t=r.name??`unknown`,i=r.dirFromWorkspacePath;if(i!=null){if(r.rootMemoryPrompt!=null){let a=await this.writePromptFile(e,i,r.rootMemoryPrompt.content,`project:${t}/root`);n.push(a)}if(r.childMemoryPrompts!=null)for(let i of r.childMemoryPrompts){let r=await this.writePromptFile(e,i.dir,i.content,`project:${t}/child:${i.workingChildDirectoryPath?.path??`unknown`}`);n.push(r)}}}return{files:n,dirs:r}}},X=class extends qd{inputEffects=[];registeredScopes=[];constructor(e,t){super(e,Dt.Input,t)}registerEffect(e,t,n=0){this.inputEffects.push({name:e,handler:t,priority:n}),this.inputEffects.sort((e,t)=>(e.priority??0)-(t.priority??0))}async executeEffects(e,t=!1){let n=[];if(this.inputEffects.length===0)return n;let{workspaceDir:r,shadowProjectDir:i}=this.resolveBasePaths(e.userConfigOptions),a={logger:this.log,fs:e.fs,path:e.path,glob:e.glob,spawn:x,userConfigOptions:e.userConfigOptions,workspaceDir:r,shadowProjectDir:i,dryRun:t};for(let e of this.inputEffects){if(t){this.log.trace({action:`dryRun`,type:`inputEffect`,name:e.name}),n.push({success:!0,description:`Would execute input effect: ${e.name}`});continue}try{let t=await e.handler(a);if(t.success)this.log.trace({action:`inputEffect`,name:e.name,status:`success`,description:t.description}),t.modifiedFiles!=null&&t.modifiedFiles.length>0&&this.log.debug({action:`inputEffect`,name:e.name,modifiedFiles:t.modifiedFiles}),t.deletedFiles!=null&&t.deletedFiles.length>0&&this.log.debug({action:`inputEffect`,name:e.name,deletedFiles:t.deletedFiles});else{let n=t.error instanceof Error?t.error.message:String(t.error);this.log.error({action:`inputEffect`,name:e.name,status:`failed`,error:n})}n.push(t)}catch(t){let r=t instanceof Error?t.message:String(t);this.log.error({action:`inputEffect`,name:e.name,status:`failed`,error:r}),n.push({success:!1,error:t,description:`Input effect failed: ${e.name}`})}}return n}hasEffects(){return this.inputEffects.length>0}getEffectCount(){return this.inputEffects.length}registerScope(e,t){this.registeredScopes.push({namespace:e,values:t}),this.log.debug({action:`registerScope`,namespace:e,keys:Object.keys(t)})}getRegisteredScopes(){return this.registeredScopes}clearRegisteredScopes(){this.registeredScopes.length=0,this.log.debug({action:`clearRegisteredScopes`})}resolveBasePaths(e){let t=e.workspaceDir,n=this.resolvePath(t,``,``),r=e.shadowSourceProjectDir;return{workspaceDir:n,shadowProjectDir:this.resolvePath(r,n,``)}}resolvePath(e,t,n){let r=e;return r.startsWith(Jt.USER_HOME)&&(r=r.replace(Jt.USER_HOME,v.homedir())),r.includes(Jt.SHADOW_SOURCE_PROJECT)&&(r=r.replace(Jt.SHADOW_SOURCE_PROJECT,n)),r.includes(Jt.WORKSPACE)&&(r=r.replace(Jt.WORKSPACE,t)),g.normalize(r)}readAndParseMarkdown(e,t){return Kd(t.readFileSync(e,`utf8`))}};const Zd=[`.qoderignore`,`.cursorignore`,`.warpindexignore`];var Qd=class extends X{constructor(){super(`AIAgentIgnoreConfigFileInputPlugin`)}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{shadowProjectDir:a}=this.resolveBasePaths(t),o=[];for(let e of Zd){let t=i.join(a,e);if(r.existsSync(t)&&r.statSync(t).isFile())try{let i=r.readFileSync(t,`utf8`);o.push({fileName:e,content:i}),n.debug(`read ignore file`,{path:t})}catch(e){n.warn(`failed to read ignore file`,{path:t,error:e})}}return{aiAgentIgnoreConfigFiles:o}}};const $d=[`.qoderignore`,`.cursorignore`,`.warpindexignore`];var ef=class extends Jd{constructor(){super(`AIAgentIgnoreConfigFileOutputPlugin`)}async registerProjectOutputDirs(){return[]}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.dirFromWorkspacePath!=null&&e.isPromptSourceProject!==!0)for(let n of $d){let r=g.join(e.dirFromWorkspacePath.path,n);t.push({pathKind:N.Relative,path:r,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>g.basename(e.dirFromWorkspacePath.path),getAbsolutePath:()=>g.join(e.dirFromWorkspacePath.basePath,r)})}return t}async registerGlobalOutputDirs(){return[]}async registerGlobalOutputFiles(){return[]}async canWrite(e){let{aiAgentIgnoreConfigFiles:t}=e.collectedInputContext;return t?.length===0?(this.log.debug(`skipped`,{reason:`no ignore config files to write`}),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{aiAgentIgnoreConfigFiles:n}=e.collectedInputContext,r=[],i=[];if(n==null||n.length===0)return{files:r,dirs:i};for(let i of t){let t=i.dirFromWorkspacePath;if(t==null)continue;let a=i.name??`unknown`;for(let i of n){let n=await this.writeIgnoreFile(e,t,i,`project:${a}/${i.fileName}`);r.push(n)}}return{files:r,dirs:i}}async writeIgnoreFile(e,t,n,r){let i=g.join(t.path,n.fileName),a=g.join(t.basePath,i),o={pathKind:N.Relative,path:i,basePath:t.basePath,getDirectoryName:()=>g.basename(t.path),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`ignoreFile`,path:a,label:r}),{path:o,success:!0,skipped:!1};try{return h.writeFileSync(a,n.content,`utf8`),this.log.trace({action:`write`,type:`ignoreFile`,path:a,label:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`ignoreFile`,path:a,label:r,error:t}),{path:o,success:!1,error:e}}}};function tf(e,t={}){let n={},{yamlFrontMatter:r,scope:i,filePath:a}=t;for(let t of e){let e=nf(t,i,a);Object.assign(n,e)}let o=Object.keys(n).length>0,s=r!=null&&Object.keys(r).length>0,c;return c=o&&s?`mixed`:o?`export`:`yaml`,{fields:{...r,...n},source:c}}function nf(e,t,n){let r={},i=e.value.trim(),a=/^export\s+default\s+/.exec(i);if(a!=null){let e=a[0].length,o=rf(i,e);if(o!=null)try{let e=af(o.trim(),t,n);typeof e==`object`&&e&&!Array.isArray(e)&&Object.assign(r,e)}catch(e){let t=e instanceof Error?e.message:String(e),r=n==null?``:` in file "${n}"`;throw Error(`Cannot statically evaluate export default${r}: ${t}`)}return r}let o=/export\s+const\s+(\w+)\s*=\s*/g,s=o.exec(i);for(;s!==null;){let e=s[1];if(e==null){s=o.exec(i);continue}let a=rf(i,s.index+s[0].length);if(a==null){s=o.exec(i);continue}try{let i=af(a.trim(),t,n);e===`metadata`&&typeof i==`object`&&i&&!Array.isArray(i)?Object.assign(r,i):r[e]=i}catch(t){let r=t instanceof Error?t.message:String(t),i=n==null?``:` in file "${n}"`;throw Error(`Cannot statically evaluate export "${e}"${i}: ${r}`)}s=o.exec(i)}return r}function rf(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&&(t===`;`||t===`
|
|
281
|
+
`)){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 af(e,t,n){let r=e.trim();if(r===``)throw Error(`Empty value cannot be evaluated`);if(r===`true`)return!0;if(r===`false`)return!1;if(r===`null`)return null;if(/^-?\d+(?:\.\d+)?$/.test(r))return Number(r);if(r.startsWith(`"`)&&r.endsWith(`"`))return of(r.slice(1,-1),`"`);if(r.startsWith(`'`)&&r.endsWith(`'`))return of(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 of(e,"`")}if(r.startsWith(`[`)&&r.endsWith(`]`))return cf(r,t,n);if(r.startsWith(`{`)&&r.endsWith(`}`))return lf(r,t,n);if(/^[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*$/i.test(r))return sf(r,t,n);let i=n==null?``:` in file "${n}"`;throw Error(`Expression "${r}" cannot be statically evaluated${i}`)}function of(e,t){return e.replaceAll(`\\n`,`
|
|
282
|
+
`).replaceAll(`\\r`,`\r`).replaceAll(`\\t`,` `).replaceAll(`\\"`,`"`).replaceAll(`\\'`,`'`).replaceAll(`\\\\`,`\\`)}function sf(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 cf(e,t,n){let r=e.slice(1,-1).trim();if(r===``)return[];if(t==null)try{let t=uf(e),n=JSON.parse(t);if(Array.isArray(n))return n}catch{}return df(r).map(e=>af(e.trim(),t,n))}function lf(e,t,n){let r=e.slice(1,-1).trim();if(r===``)return{};if(t==null)try{let t=uf(e),n=JSON.parse(t);if(typeof n==`object`&&n&&!Array.isArray(n))return n}catch{}let i={},a=ff(r);for(let e of a){let r=pf(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]=af(o,t,n)}return i}function uf(e){let t=``,n=null,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(r){t+=a,r=!1;continue}if(a===`\\`){t+=a,r=!0;continue}if(n!=null){a===n?(t+=`"`,n=null):a===`"`&&n===`'`?t+=`\\"`:t+=a;continue}if(a===`"`||a===`'`){t+=`"`,n=a;continue}if(a===`:`&&i>0){let e=t.length-1;for(;e>=0&&/\s/.test(t.charAt(e));)e--;let n=e+1;for(;e>=0&&/[\w$]/.test(t.charAt(e));)e--;if(e++,e>0&&t.charAt(e-1)!==`"`){let r=t.slice(e,n);r.length>0&&/^[\w$]+$/.test(r)&&(t=`${t.slice(0,e)}"${r}"`)}}t+=a}return t}function df(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 ff(e){return df(e)}function pf(e){let t=null,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){n=!1;continue}if(i===`\\`){n=!0;continue}if(t!=null){i===t&&(t=null);continue}if(i===`"`||i===`'`||i==="`"){t=i;continue}if(i===`:`)return r}return-1}function mf(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=o(n.value.value,t.scope);return e===`true`||e===`1`}catch{return!1}return!1}async function hf(e,t,n){return!mf(e,t)||e.children.length===0?[]:n(e.children,t)}async function gf(e,t){if(!mf(e,t)||e.children.length===0)return[];let n=_f(e.children,t);return n===``?[]:[{type:`text`,value:n}]}function _f(e,t){let n=``;for(let r of e)if(r.type===`text`)n+=r.value;else if(r.type===`mdxTextExpression`)try{n+=o(r.value,t.scope)}catch{}else `children`in r&&Array.isArray(r.children)&&(n+=_f(r.children,t));return n}function vf(){i(`Md`,hf),i(`Md.Line`,gf)}function yf(e){return vu().use(nu).use(pl).use(ei,[`yaml`]).use(C).parse(e)}vf();function bf(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 xf(e,t){let n=yf(e),r=bf(t?.globalScope,t?.scope),i=c(),a;if(t?.extractMetadata===!0){let e=n.children.find(e=>e.type===`yaml`),i;if(e!=null)try{i=Ud.parse(e.value)}catch{}a=tf(n.children.filter(e=>e.type===`mdxjsEsm`),{...i!=null&&{yamlFrontMatter:i},scope:r,...t?.basePath!=null&&{filePath:t.basePath}}),n.children=n.children.filter(e=>e.type!==`yaml`&&e.type!==`mdxjsEsm`)}let o=await u(n,{scope:r,components:i,processingStack:[],...t?.basePath!=null&&{basePath:t.basePath}}),s=vu().use(ei,[`yaml`]).use(pl).use(S,{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 Sf=`CLAUDE.md`,Z=`.claude`,Cf=`commands`,wf=`agents`,Tf=`skills`,Ef=[Cf,wf,Tf];var Df=class extends Jd{constructor(){super(`ClaudeCodeCLIOutputPlugin`,{globalConfigDir:Z,outputFileName:Sf})}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.dirFromWorkspacePath!=null)for(let n of Ef){let r=g.join(e.dirFromWorkspacePath.path,Z,n);t.push({pathKind:N.Relative,path:r,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>g.join(e.dirFromWorkspacePath.basePath,r)})}return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{skills:r}=e.collectedInputContext;for(let e of n){if(e.rootMemoryPrompt!=null&&e.dirFromWorkspacePath!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,Sf)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,Sf));if(r!=null&&e.dirFromWorkspacePath!=null)for(let n of r){let r=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),i=g.join(e.dirFromWorkspacePath.path,Z,Tf,r);if(t.push({pathKind:N.Relative,path:g.join(i,`SKILL.md`),basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>r,getAbsolutePath:()=>g.join(e.dirFromWorkspacePath.basePath,i,`SKILL.md`)}),n.childDocs!=null)for(let a of n.childDocs){let n=a.dir.path.replace(/\.mdx$/,`.md`),o=g.join(i,n);t.push({pathKind:N.Relative,path:o,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>r,getAbsolutePath:()=>g.join(e.dirFromWorkspacePath.basePath,o)})}if(n.resources!=null)for(let a of n.resources){let n=g.join(i,a.relativePath);t.push({pathKind:N.Relative,path:n,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>r,getAbsolutePath:()=>g.join(e.dirFromWorkspacePath.basePath,n)})}}}return t}async registerGlobalOutputFiles(e){let{globalMemory:t}=e.collectedInputContext;if(t==null)return[];let n=this.getGlobalConfigDir();return[{pathKind:N.Relative,path:Sf,basePath:n,getDirectoryName:()=>Z,getAbsolutePath:()=>g.join(n,Sf)}]}async canWrite(e){let{workspace:t,globalMemory:n,fastCommands:r,subAgents:i,skills:a}=e.collectedInputContext,o=t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0),s=n!=null,c=(r?.length??0)>0,l=(i?.length??0)>0,u=(a?.length??0)>0;return o||s||c||l||u?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{fastCommands:n,subAgents:r,skills:i}=e.collectedInputContext,a=[],o=[];for(let o of t){let t=o.name??`unknown`,s=o.dirFromWorkspacePath;if(s!=null){if(o.rootMemoryPrompt!=null){let n=await this.writePromptFile(e,s,o.rootMemoryPrompt.content,`project:${t}/root`);a.push(n)}if(o.childMemoryPrompts!=null)for(let n of o.childMemoryPrompts){let r=await this.writePromptFile(e,n.dir,n.content,`project:${t}/child:${n.workingChildDirectoryPath?.path??`unknown`}`);a.push(r)}if(n!=null)for(let t of n){let n=await this.writeFastCommand(e,s,t);a.push(...n)}if(r!=null)for(let t of r){let n=await this.writeSubAgent(e,s,t);a.push(...n)}if(i!=null)for(let t of i){let n=await this.writeSkill(e,s,t);a.push(...n)}}}return{files:a,dirs:o}}async writeGlobalOutputs(e){let{globalMemory:t}=e.collectedInputContext,n=[],r=[];if(t==null)return{files:n,dirs:r};let i=this.getGlobalConfigDir(),a=g.join(i,Sf),o={pathKind:N.Relative,path:Sf,basePath:i,getDirectoryName:()=>Z,getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMemory`,path:a}),{files:[{path:o,success:!0,skipped:!1}],dirs:r};try{this.ensureDirectory(i),h.writeFileSync(a,t.content,`utf8`),this.log.trace({action:`write`,type:`globalMemory`,path:a}),n.push({path:o,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalMemory`,path:a,error:t}),n.push({path:o,success:!1,error:e})}return{files:n,dirs:r}}async writeFastCommand(e,t,n){let r=[],i=this.getTransformOptionsFromContext(e),a=this.transformFastCommandName(n,i),o=g.join(t.basePath,t.path,Z,Cf),s=g.join(o,a),c={pathKind:N.Relative,path:g.join(t.path,Z,Cf,a),basePath:t.basePath,getDirectoryName:()=>Cf,getAbsolutePath:()=>s},l=n.content,u=n.yamlFrontMatter,d=!1;if(n.rawMdxContent!=null){this.log.debug(`recompiling fast command with claudeCode preset`,{file:n.dir.getAbsolutePath(),hasRawContent:!0,rawContentLength:n.rawMdxContent.length});try{let e=new ar({toolPreset:`claudeCode`}).collect();this.log.debug(`claudeCode tool scope`,{tool:e.tool});let t=await xf(n.rawMdxContent,{globalScope:e,extractMetadata:!0,basePath:n.dir.basePath});l=t.content,u=t.metadata.fields,d=!0,this.log.debug(`recompiled front matter`,{frontMatter:u})}catch(e){this.log.warn(`failed to recompile fast command with claudeCode preset, using default`,{file:n.dir.getAbsolutePath(),error:e instanceof Error?e.message:String(e)})}}else this.log.debug(`no rawMdxContent available for fast command`,{file:n.dir.getAbsolutePath()});let f=d?this.buildMarkdownContent(l,u):this.buildMarkdownContentWithRaw(l,u,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`fastCommand`,path:s}),[{path:c,success:!0,skipped:!1}];try{this.ensureDirectory(o),h.writeFileSync(s,f,`utf8`),this.log.trace({action:`write`,type:`fastCommand`,path:s}),r.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`fastCommand`,path:s,error:t}),r.push({path:c,success:!1,error:e})}return r}async writeSubAgent(e,t,n){let r=[],i=n.dir.path.endsWith(`.md`)?n.dir.path:`${n.dir.path}.md`,a=g.join(t.basePath,t.path,Z,wf),o=g.join(a,i),s={pathKind:N.Relative,path:g.join(t.path,Z,wf,i),basePath:t.basePath,getDirectoryName:()=>wf,getAbsolutePath:()=>o},c=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`subAgent`,path:o}),[{path:s,success:!0,skipped:!1}];try{this.ensureDirectory(a),h.writeFileSync(o,c,`utf8`),this.log.trace({action:`write`,type:`subAgent`,path:o}),r.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`subAgent`,path:o,error:t}),r.push({path:s,success:!1,error:e})}return r}async writeSkill(e,t,n){let r=[],i=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),a=g.join(t.basePath,t.path,Z,Tf,i),o=g.join(a,`SKILL.md`),s={pathKind:N.Relative,path:g.join(t.path,Z,Tf,i,`SKILL.md`),basePath:t.basePath,getDirectoryName:()=>i,getAbsolutePath:()=>o},c=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skill`,path:o}),[{path:s,success:!0,skipped:!1}];try{if(this.ensureDirectory(a),h.writeFileSync(o,c,`utf8`),this.log.trace({action:`write`,type:`skill`,path:o}),r.push({path:s,success:!0}),n.childDocs!=null)for(let o of n.childDocs){let n=await this.writeSkillReferenceDocument(e,a,i,o,t);r.push(...n)}if(n.resources!=null)for(let o of n.resources){let n=await this.writeSkillResource(e,a,i,o,t);r.push(...n)}}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skill`,path:o,error:t}),r.push({path:s,success:!1,error:e})}return r}async writeSkillReferenceDocument(e,t,n,r,i){let a=[],o=r.dir.path.replace(/\.mdx$/,`.md`),s=g.join(t,o),c={pathKind:N.Relative,path:g.join(i.path,Z,Tf,n,o),basePath:i.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillRefDoc`,path:s}),[{path:c,success:!0,skipped:!1}];try{let e=g.dirname(s);this.ensureDirectory(e),h.writeFileSync(s,r.content,`utf8`),this.log.trace({action:`write`,type:`skillRefDoc`,path:s}),a.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillRefDoc`,path:s,error:t}),a.push({path:c,success:!1,error:e})}return a}async writeSkillResource(e,t,n,r,i){let a=[],o=g.join(t,r.relativePath),s={pathKind:N.Relative,path:g.join(i.path,Z,Tf,n,r.relativePath),basePath:i.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>o};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillResource`,path:o}),[{path:s,success:!0,skipped:!1}];try{let e=g.dirname(o);this.ensureDirectory(e),h.writeFileSync(o,r.content,`utf8`),this.log.trace({action:`write`,type:`skillResource`,path:o}),a.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillResource`,path:o,error:t}),a.push({path:s,success:!1,error:e})}return a}};const Of=`AGENTS.md`,kf=`.codex`,Af=`prompts`,jf=`skills`,Mf=`SKILL.md`;var Nf=class extends Jd{constructor(){super(`CodexCLIOutputPlugin`,{globalConfigDir:kf,outputFileName:Of,dependsOn:[`AgentsOutputPlugin`]})}async registerProjectOutputDirs(){return[]}async registerProjectOutputFiles(){return[]}async registerGlobalOutputDirs(e){let t=this.getGlobalConfigDir(),n=[],r=g.join(t,Af);n.push({pathKind:N.Relative,path:Af,basePath:t,getDirectoryName:()=>Af,getAbsolutePath:()=>r});let{skills:i}=e.collectedInputContext;if(i!=null&&i.length>0)for(let e of i){let r=e.yamlFrontMatter?.name??e.dir.getDirectoryName(),i=g.join(t,jf,r);n.push({pathKind:N.Relative,path:g.join(jf,r),basePath:t,getDirectoryName:()=>r,getAbsolutePath:()=>i})}return n}async registerGlobalOutputFiles(){let e=this.getGlobalConfigDir();return[{pathKind:N.Relative,path:Of,basePath:e,getDirectoryName:()=>kf,getAbsolutePath:()=>g.join(e,Of)}]}async canWrite(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=t!=null,a=(n?.length??0)>0,o=(r?.length??0)>0;return i||a||o?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(){return{files:[],dirs:[]}}async writeGlobalOutputs(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=[];if(t!=null){let n=this.getGlobalConfigDir(),r=g.join(n,Of),a={pathKind:N.Relative,path:Of,basePath:n,getDirectoryName:()=>kf,getAbsolutePath:()=>r};if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`globalMemory`,path:r}),i.push({path:a,success:!0,skipped:!1});else try{this.ensureDirectory(n),h.writeFileSync(r,t.content,`utf8`),this.log.trace({action:`write`,type:`globalMemory`,path:r}),i.push({path:a,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalMemory`,path:r,error:t}),i.push({path:a,success:!1,error:e})}}if(n!=null&&n.length>0){let t=this.getGlobalConfigDir();for(let r of n){let n=await this.writeGlobalFastCommand(e,t,r);i.push(...n)}}if(r==null||r.length===0)return{files:i,dirs:a};let o=this.getGlobalConfigDir();for(let t of r){let n=await this.writeGlobalSkill(e,o,t);i.push(...n)}return{files:i,dirs:a}}async writeGlobalFastCommand(e,t,n){let r=[],i=this.getTransformOptionsFromContext(e),a=this.transformFastCommandName(n,i),o=g.join(t,Af),s=g.join(o,a),c={pathKind:N.Relative,path:g.join(Af,a),basePath:t,getDirectoryName:()=>Af,getAbsolutePath:()=>s},l=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalFastCommand`,path:s}),[{path:c,success:!0,skipped:!1}];try{this.ensureDirectory(o),h.writeFileSync(s,l,`utf8`),this.log.trace({action:`write`,type:`globalFastCommand`,path:s}),r.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalFastCommand`,path:s,error:t}),r.push({path:c,success:!1,error:e})}return r}async writeGlobalSkill(e,t,n){let r=[],i=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),a=g.join(t,jf,i),o=g.join(a,Mf),s={pathKind:N.Relative,path:g.join(jf,i,Mf),basePath:t,getDirectoryName:()=>i,getAbsolutePath:()=>o},c=this.buildCodexSkillContent(n);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalSkill`,path:o}),[{path:s,success:!0,skipped:!1}];try{if(this.ensureDirectory(a),h.writeFileSync(o,c,`utf8`),this.log.trace({action:`write`,type:`globalSkill`,path:o}),r.push({path:s,success:!0}),n.childDocs!=null)for(let o of n.childDocs){let n=await this.writeSkillReferenceDocument(e,a,i,o,t);r.push(...n)}if(n.resources!=null)for(let o of n.resources){let n=await this.writeSkillResource(e,a,i,o,t);r.push(...n)}}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalSkill`,path:o,error:t}),r.push({path:s,success:!1,error:e})}return r}buildCodexSkillContent(e){let t=e.yamlFrontMatter,n=this.normalizeSkillName(t.name,64),r=this.normalizeToSingleLine(t.description,1024),i={};t.displayName!=null&&(i[`short-description`]=t.displayName),t.version!=null&&(i.version=t.version),t.author!=null&&(i.author=t.author),t.keywords!=null&&t.keywords.length>0&&(i.keywords=[...t.keywords]);let a={name:n,description:r};return Object.keys(i).length>0&&(a.metadata=i),t.allowTools!=null&&t.allowTools.length>0&&(a[`allowed-tools`]=t.allowTools.join(` `)),Gd(a,e.content)}normalizeSkillName(e,t){let n=e.toLowerCase().replaceAll(/[^a-z0-9-]/g,`-`).replaceAll(/-+/g,`-`).replaceAll(/^-+|-+$/g,``);return n.length>t&&(n=n.slice(0,t).replace(/-+$/,``)),n}normalizeToSingleLine(e,t){let n=e.replaceAll(/[\r\n]+/g,` `).replaceAll(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-3)}...`:n}async writeSkillReferenceDocument(e,t,n,r,i){let a=[],o=r.dir.path.replace(/\.mdx$/,`.md`),s=g.join(t,o),c={pathKind:N.Relative,path:g.join(jf,n,o),basePath:i,getDirectoryName:()=>n,getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillRefDoc`,path:s}),[{path:c,success:!0,skipped:!1}];try{let e=g.dirname(s);this.ensureDirectory(e),h.writeFileSync(s,r.content,`utf8`),this.log.trace({action:`write`,type:`skillRefDoc`,path:s}),a.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillRefDoc`,path:s,error:t}),a.push({path:c,success:!1,error:e})}return a}async writeSkillResource(e,t,n,r,i){let a=[],o=g.join(t,r.relativePath),s={pathKind:N.Relative,path:g.join(jf,n,r.relativePath),basePath:i,getDirectoryName:()=>n,getAbsolutePath:()=>o};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillResource`,path:o}),[{path:s,success:!0,skipped:!1}];try{let e=g.dirname(o);this.ensureDirectory(e),h.writeFileSync(o,r.content,`utf8`),this.log.trace({action:`write`,type:`skillResource`,path:o}),a.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillResource`,path:o,error:t}),a.push({path:s,success:!1,error:e})}return a}};const Pf=`AGENTS.md`,Q=`.factory`,Ff=`commands`,If=`agents`,Lf=`skills`,Rf=[Ff,If,Lf];var zf=class extends Jd{constructor(){super(`DroidCLIOutputPlugin`,{globalConfigDir:Q,outputFileName:Pf})}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.dirFromWorkspacePath!=null)for(let n of Rf){let r=g.join(e.dirFromWorkspacePath.path,Q,n);t.push({pathKind:N.Relative,path:r,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>g.join(e.dirFromWorkspacePath.basePath,r)})}return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{skills:r}=e.collectedInputContext;for(let e of n)if(e.dirFromWorkspacePath!=null&&r!=null)for(let n of r){let r=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),i=g.join(e.dirFromWorkspacePath.path,Q,Lf,r);if(t.push({pathKind:N.Relative,path:g.join(i,`SKILL.md`),basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>r,getAbsolutePath:()=>g.join(e.dirFromWorkspacePath.basePath,i,`SKILL.md`)}),n.childDocs!=null)for(let a of n.childDocs){let n=a.dir.path.replace(/\.mdx$/,`.md`),o=g.join(i,n);t.push({pathKind:N.Relative,path:o,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>r,getAbsolutePath:()=>g.join(e.dirFromWorkspacePath.basePath,o)})}if(n.resources!=null)for(let a of n.resources){let n=g.join(i,a.relativePath);t.push({pathKind:N.Relative,path:n,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>r,getAbsolutePath:()=>g.join(e.dirFromWorkspacePath.basePath,n)})}}return t}async registerGlobalOutputFiles(e){let{globalMemory:t}=e.collectedInputContext;if(t==null)return[];let n=this.getGlobalConfigDir();return[{pathKind:N.Relative,path:Pf,basePath:n,getDirectoryName:()=>Q,getAbsolutePath:()=>g.join(n,Pf)}]}async canWrite(e){let{globalMemory:t,fastCommands:n,subAgents:r,skills:i}=e.collectedInputContext,a=t!=null,o=(n?.length??0)>0,s=(r?.length??0)>0,c=(i?.length??0)>0;return a||o||s||c?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{fastCommands:n,subAgents:r,skills:i}=e.collectedInputContext,a=[],o=[];for(let o of t){let t=o.dirFromWorkspacePath;if(t!=null){if(n!=null)for(let r of n){let n=await this.writeFastCommand(e,t,r);a.push(...n)}if(r!=null)for(let n of r){let r=await this.writeSubAgent(e,t,n);a.push(...r)}if(i!=null)for(let n of i){let r=await this.writeSkill(e,t,n);a.push(...r)}}}return{files:a,dirs:o}}async writeGlobalOutputs(e){let{globalMemory:t}=e.collectedInputContext,n=[],r=[];if(t==null)return{files:n,dirs:r};let i=this.getGlobalConfigDir(),a=g.join(i,Pf),o={pathKind:N.Relative,path:Pf,basePath:i,getDirectoryName:()=>Q,getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMemory`,path:a}),{files:[{path:o,success:!0,skipped:!1}],dirs:r};try{this.ensureDirectory(i),h.writeFileSync(a,t.content,`utf8`),this.log.trace({action:`write`,type:`globalMemory`,path:a}),n.push({path:o,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalMemory`,path:a,error:t}),n.push({path:o,success:!1,error:e})}return{files:n,dirs:r}}async writeFastCommand(e,t,n){let r=[],i=this.getTransformOptionsFromContext(e),a=this.transformFastCommandName(n,i),o=g.join(t.basePath,t.path,Q,Ff),s=g.join(o,a),c={pathKind:N.Relative,path:g.join(t.path,Q,Ff,a),basePath:t.basePath,getDirectoryName:()=>Ff,getAbsolutePath:()=>s},l=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`fastCommand`,path:s}),[{path:c,success:!0,skipped:!1}];try{this.ensureDirectory(o),h.writeFileSync(s,l,`utf8`),this.log.trace({action:`write`,type:`fastCommand`,path:s}),r.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`fastCommand`,path:s,error:t}),r.push({path:c,success:!1,error:e})}return r}async writeSubAgent(e,t,n){let r=[],i=n.dir.path.endsWith(`.md`)?n.dir.path:`${n.dir.path}.md`,a=g.join(t.basePath,t.path,Q,If),o=g.join(a,i),s={pathKind:N.Relative,path:g.join(t.path,Q,If,i),basePath:t.basePath,getDirectoryName:()=>If,getAbsolutePath:()=>o},c=this.buildMarkdownContentWithRaw(n.content,n.yamlFrontMatter,n.rawFrontMatter);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`subAgent`,path:o}),[{path:s,success:!0,skipped:!1}];try{this.ensureDirectory(a),h.writeFileSync(o,c,`utf8`),this.log.trace({action:`write`,type:`subAgent`,path:o}),r.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`subAgent`,path:o,error:t}),r.push({path:s,success:!1,error:e})}return r}async writeSkill(e,t,n){let r=[],i=n.yamlFrontMatter?.name??n.dir.getDirectoryName(),a=g.join(t.basePath,t.path,Q,Lf,i),o=g.join(a,`SKILL.md`),s={pathKind:N.Relative,path:g.join(t.path,Q,Lf,i,`SKILL.md`),basePath:t.basePath,getDirectoryName:()=>i,getAbsolutePath:()=>o},c=n.yamlFrontMatter==null?void 0:{name:n.yamlFrontMatter.name,description:n.yamlFrontMatter.description},l=this.buildMarkdownContent(n.content,c);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skill`,path:o}),[{path:s,success:!0,skipped:!1}];try{if(this.ensureDirectory(a),h.writeFileSync(o,l,`utf8`),this.log.trace({action:`write`,type:`skill`,path:o}),r.push({path:s,success:!0}),n.childDocs!=null)for(let o of n.childDocs){let n=await this.writeSkillReferenceDocument(e,a,i,o,t);r.push(...n)}if(n.resources!=null)for(let o of n.resources){let n=await this.writeSkillResource(e,a,i,o,t);r.push(...n)}}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skill`,path:o,error:t}),r.push({path:s,success:!1,error:e})}return r}async writeSkillReferenceDocument(e,t,n,r,i){let a=[],o=r.dir.path.replace(/\.mdx$/,`.md`),s=g.join(t,o),c={pathKind:N.Relative,path:g.join(i.path,Q,Lf,n,o),basePath:i.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>s};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillRefDoc`,path:s}),[{path:c,success:!0,skipped:!1}];try{let e=g.dirname(s);this.ensureDirectory(e),h.writeFileSync(s,r.content,`utf8`),this.log.trace({action:`write`,type:`skillRefDoc`,path:s}),a.push({path:c,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillRefDoc`,path:s,error:t}),a.push({path:c,success:!1,error:e})}return a}async writeSkillResource(e,t,n,r,i){let a=[],o=g.join(t,r.relativePath),s={pathKind:N.Relative,path:g.join(i.path,Q,Lf,n,r.relativePath),basePath:i.basePath,getDirectoryName:()=>n,getAbsolutePath:()=>o};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`skillResource`,path:o}),[{path:s,success:!0,skipped:!1}];try{let e=g.dirname(o);this.ensureDirectory(e),h.writeFileSync(o,r.content,`utf8`),this.log.trace({action:`write`,type:`skillResource`,path:o}),a.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillResource`,path:o,error:t}),a.push({path:s,success:!1,error:e})}return a}},Bf=class extends X{constructor(){super(`FastCommandInputPlugin`)}extractSeriesInfo(e){let t=e.replace(/\.mdx$/,``),n=t.indexOf(`_`);return n===-1?{commandName:t}:{series:t.slice(0,Math.max(0,n)),commandName:t.slice(Math.max(0,n+1))}}async collect(e){let{userConfigOptions:n,logger:r,globalScope:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(n),s=n.shadowFastCommandDir,c=this.resolvePath(s,a,o),l=[];if(!(e.fs.existsSync(c)&&e.fs.statSync(c).isDirectory()))return{fastCommands:l};let u=e.fs.readdirSync(c,{withFileTypes:!0});for(let n of u)if(n.isFile()&&n.name.endsWith(`.mdx`)){let a=e.path.join(c,n.name);try{let o=e.fs.readFileSync(a,`utf8`),s=Kd(o),u=await xf(o,{globalScope:i,extractMetadata:!0,basePath:c}),d=s.yamlFrontMatter!=null||Object.keys(u.metadata.fields).length>0?{...s.yamlFrontMatter,...u.metadata.fields}:void 0;if(d!=null){let e=Ft(d,a);for(let t of e.warnings)r.debug(t);if(!e.valid)throw new t(e.errors,a)}let{content:f}=u,p=this.extractSeriesInfo(n.name);r.debug(`fast command metadata extracted`,{command:n.name,source:u.metadata.source,hasYaml:s.yamlFrontMatter!=null,hasExport:Object.keys(u.metadata.fields).length>0}),l.push({type:Ot.FastCommand,content:f,length:f.length,filePathKind:N.Relative,...d!=null&&{yamlFrontMatter:d},...s.rawFrontMatter!=null&&{rawFrontMatter:s.rawFrontMatter},markdownAst:s.markdownAst,markdownContents:s.markdownContents,dir:{pathKind:N.Relative,path:n.name,basePath:c,getDirectoryName:()=>n.name.replace(/\.mdx$/,``),getAbsolutePath:()=>a},...p.series!=null&&{series:p.series},commandName:p.commandName,rawMdxContent:o})}catch(e){r.error(`failed to parse fast command`,{file:a,error:e})}}return{fastCommands:l}}};const Vf=`GEMINI.md`,Hf=`.gemini`;var Uf=class extends Jd{constructor(){super(`GeminiCLIOutputPlugin`,{globalConfigDir:Hf,outputFileName:Vf})}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.rootMemoryPrompt!=null&&e.dirFromWorkspacePath!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,Vf)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,Vf));return t}async registerGlobalOutputFiles(e){let{globalMemory:t}=e.collectedInputContext;if(t==null)return[];let n=this.getGlobalConfigDir();return[{pathKind:N.Relative,path:Vf,basePath:n,getDirectoryName:()=>Hf,getAbsolutePath:()=>g.join(n,Vf)}]}async canWrite(e){let{workspace:t,globalMemory:n}=e.collectedInputContext;return t.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)||n!=null?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t){let t=r.name??`unknown`,i=r.dirFromWorkspacePath;if(i!=null){if(r.rootMemoryPrompt!=null){let a=await this.writePromptFile(e,i,r.rootMemoryPrompt.content,`project:${t}/root`);n.push(a)}if(r.childMemoryPrompts!=null)for(let i of r.childMemoryPrompts){let r=await this.writePromptFile(e,i.dir,i.content,`project:${t}/child:${i.workingChildDirectoryPath?.path??`unknown`}`);n.push(r)}}}return{files:n,dirs:r}}async writeGlobalOutputs(e){let{globalMemory:t}=e.collectedInputContext,n=[],r=[];if(t==null)return{files:n,dirs:r};let i=this.getGlobalConfigDir(),a=g.join(i,Vf),o={pathKind:N.Relative,path:Vf,basePath:i,getDirectoryName:()=>Hf,getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMemory`,path:a}),{files:[{path:o,success:!0,skipped:!1}],dirs:r};try{this.ensureDirectory(i),h.writeFileSync(a,t.content,`utf8`),this.log.trace({action:`write`,type:`globalMemory`,path:a}),n.push({path:o,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalMemory`,path:a,error:t}),n.push({path:o,success:!1,error:e})}return{files:n,dirs:r}}};const Wf=`.skills`,Gf=`SKILL.md`,Kf=`mcp.json`;var qf=class extends Jd{constructor(){super(`GenericSkillsOutputPlugin`,{globalConfigDir:``,outputFileName:Gf})}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{skills:r}=e.collectedInputContext;if(r==null||r.length===0)return t;for(let e of n){if(e.dirFromWorkspacePath==null)continue;let n=this.joinPath(e.dirFromWorkspacePath.path,Wf);t.push({pathKind:N.Relative,path:n,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>Wf,getAbsolutePath:()=>this.joinPath(e.dirFromWorkspacePath.basePath,n)})}return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{skills:r}=e.collectedInputContext;if(r==null||r.length===0)return t;for(let e of n){if(e.dirFromWorkspacePath==null)continue;let n=this.joinPath(e.dirFromWorkspacePath.basePath,e.dirFromWorkspacePath.path,Wf);for(let i of r){let r=i.yamlFrontMatter.name,a=this.joinPath(n,r);if(t.push({pathKind:N.Relative,path:this.joinPath(Wf,r,Gf),basePath:this.joinPath(e.dirFromWorkspacePath.basePath,e.dirFromWorkspacePath.path),getDirectoryName:()=>r,getAbsolutePath:()=>this.joinPath(a,Gf)}),i.mcpConfig!=null&&t.push({pathKind:N.Relative,path:this.joinPath(Wf,r,Kf),basePath:this.joinPath(e.dirFromWorkspacePath.basePath,e.dirFromWorkspacePath.path),getDirectoryName:()=>r,getAbsolutePath:()=>this.joinPath(a,Kf)}),i.childDocs!=null)for(let n of i.childDocs){let i=n.relativePath.replace(/\.mdx$/,`.md`);t.push({pathKind:N.Relative,path:this.joinPath(Wf,r,i),basePath:this.joinPath(e.dirFromWorkspacePath.basePath,e.dirFromWorkspacePath.path),getDirectoryName:()=>r,getAbsolutePath:()=>this.joinPath(a,i)})}if(i.resources!=null)for(let n of i.resources)t.push({pathKind:N.Relative,path:this.joinPath(Wf,r,n.relativePath),basePath:this.joinPath(e.dirFromWorkspacePath.basePath,e.dirFromWorkspacePath.path),getDirectoryName:()=>r,getAbsolutePath:()=>this.joinPath(a,n.relativePath)})}}return t}async registerGlobalOutputDirs(){return[]}async registerGlobalOutputFiles(){return[]}async canWrite(e){let{skills:t}=e.collectedInputContext,{projects:n}=e.collectedInputContext.workspace;return t==null||t.length===0?(this.log.trace({action:`skip`,reason:`noSkills`}),!1):n.length===0?(this.log.trace({action:`skip`,reason:`noProjects`}),!1):!0}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{skills:n}=e.collectedInputContext,r=[],i=[];if(n==null||n.length===0)return{files:r,dirs:i};for(let i of t){if(i.dirFromWorkspacePath==null)continue;let t=this.joinPath(i.dirFromWorkspacePath.basePath,i.dirFromWorkspacePath.path,Wf);for(let i of n){let n=await this.writeSkill(e,i,t);r.push(...n)}}return{files:r,dirs:i}}async writeGlobalOutputs(){return{files:[],dirs:[]}}async writeSkill(e,t,n){let r=[],i=t.yamlFrontMatter.name,a=this.joinPath(n,i),o=this.joinPath(a,Gf),s={pathKind:N.Relative,path:Gf,basePath:a,getDirectoryName:()=>i,getAbsolutePath:()=>o},c=this.buildSkillFrontMatter(t),l=t.content,u=Gd(c,l);if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`skill`,path:o}),r.push({path:s,success:!0,skipped:!1});else try{this.ensureDirectory(a),this.writeFileSync(o,u),this.log.trace({action:`write`,type:`skill`,path:o}),r.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skill`,path:o,error:t}),r.push({path:s,success:!1,error:e})}if(t.mcpConfig!=null){let n=await this.writeMcpConfig(e,t,a);r.push(n)}if(t.childDocs!=null)for(let n of t.childDocs){let t=await this.writeChildDoc(e,n,a,i);r.push(t)}if(t.resources!=null)for(let n of t.resources){let t=await this.writeResource(e,n,a,i);r.push(t)}return r}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:t.name,description:t.description,...t.displayName!=null&&{displayName:t.displayName},...t.keywords!=null&&t.keywords.length>0&&{keywords:t.keywords},...t.author!=null&&{author:t.author},...t.version!=null&&{version:t.version},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}async writeMcpConfig(e,t,n){let r=t.yamlFrontMatter.name,i=this.joinPath(n,Kf),a={pathKind:N.Relative,path:Kf,basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>i},o=t.mcpConfig.rawContent;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfig`,path:i}),{path:a,success:!0,skipped:!1};try{return this.ensureDirectory(n),this.writeFileSync(i,o),this.log.trace({action:`write`,type:`mcpConfig`,path:i}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`mcpConfig`,path:i,error:t}),{path:a,success:!1,error:e}}}async writeChildDoc(e,t,n,r){let i=t.relativePath.replace(/\.mdx$/,`.md`),a=this.joinPath(n,i),o={pathKind:N.Relative,path:i,basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>a},s=t.content;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`childDoc`,path:a}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,s),this.log.trace({action:`write`,type:`childDoc`,path:a}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`childDoc`,path:a,error:t}),{path:o,success:!1,error:e}}}async writeResource(e,t,n,r){let i=this.joinPath(n,t.relativePath),a={pathKind:N.Relative,path:t.relativePath,basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>i};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`resource`,path:i}),{path:a,success:!0,skipped:!1};try{let e=this.dirname(i);if(this.ensureDirectory(e),t.encoding===`base64`){let e=w.from(t.content,`base64`);this.writeFileSyncBuffer(i,e)}else this.writeFileSync(i,t.content);return this.log.trace({action:`write`,type:`resource`,path:i}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`resource`,path:i,error:t}),{path:a,success:!1,error:e}}}},Jf=class extends X{constructor(){super(`GlobalMemoryInputPlugin`)}async collect(e){let{userConfigOptions:t,fs:n,path:r,globalScope:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.globalMemoryFile,c=this.resolvePath(s,a,o);if(!n.existsSync(c))return this.log.warn({action:`collect`,reason:`fileNotFound`,path:c}),{};if(!n.statSync(c).isFile())return this.log.warn({action:`collect`,reason:`notAFile`,path:c}),{};let l=n.readFileSync(c,`utf8`),u=Kd(l),f;if(i!=null)try{f=await xf(l,{globalScope:i,basePath:r.dirname(c)})}catch(e){throw e instanceof d&&(this.log.error(`MDX compilation failed: ${e.message}`),this.log.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),this.log.error(`For example, if using {profile.name}, add a "profile" section with "name" field to your config.`),m.exit(1)),e}else f=u.contentWithoutFrontMatter;return this.log.debug({action:`collect`,path:c,contentLength:f.length}),{globalMemory:{type:Ot.GlobalMemory,content:f,length:f.length,filePathKind:N.Relative,...u.rawFrontMatter!=null&&{rawFrontMatter:u.rawFrontMatter},markdownAst:u.markdownAst,markdownContents:u.markdownContents,dir:{pathKind:N.Relative,path:r.basename(c),basePath:r.dirname(c),getDirectoryName:()=>r.basename(c),getAbsolutePath:()=>c},parentDirectoryPath:{type:Mt.UserHome,directory:{pathKind:N.Relative,path:``,basePath:v.homedir(),getDirectoryName:()=>r.basename(v.homedir()),getAbsolutePath:()=>v.homedir()}}}}}},Yf=class extends X{constructor(){super(`IdeConfigInputPlugin`)}collect(e){let{userConfigOptions:t,fs:n,path:r}=e,{shadowProjectDir:i}=this.resolveBasePaths(t),a=[`.editorconfig`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`,`.vscode/settings.json`,`.vscode/extensions.json`],o=[];for(let e of a){let t=r.join(i,e);if(n.existsSync(t)&&n.statSync(t).isFile()){let i=n.readFileSync(t,`utf8`),a=P.Original;e.includes(`.vscode`)?a=P.VSCode:e.includes(`.idea`)?a=P.IntellijIDEA:e.includes(`.editorconfig`)&&(a=P.EditorConfig),o.push({type:a,content:i,length:i.length,filePathKind:N.Absolute,dir:{pathKind:N.Absolute,path:t,getDirectoryName:()=>r.basename(t)}})}}return{ideConfigFiles:o}}};const Xf=`.idea`,Zf=[`.editorconfig`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`];var Qf=class extends Jd{constructor(){super(`JetBrainsIDECodeStyleConfigOutputPlugin`)}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{ideConfigFiles:r}=e.collectedInputContext;if(!r.some(e=>e.type===P.IntellijIDEA||e.type===P.EditorConfig))return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&e.isPromptSourceProject!==!0)for(let e of Zf){let r=this.joinPath(n.path,e);t.push({pathKind:N.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>this.dirname(e),getAbsolutePath:()=>this.resolvePath(n.basePath,r)})}}return t}async canWrite(e){let{ideConfigFiles:t}=e.collectedInputContext;return t.some(e=>e.type===P.IntellijIDEA||e.type===P.EditorConfig)?!0:(this.log.debug(`skipped`,{reason:`no JetBrains IDE config files found`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{ideConfigFiles:n}=e.collectedInputContext,r=[],i=[],a=n.filter(e=>e.type===P.IntellijIDEA||e.type===P.EditorConfig);for(let n of t){let t=n.dirFromWorkspacePath;if(t==null)continue;let i=n.name??`unknown`;for(let n of a){let a=await this.writeConfigFile(e,t,n,`project:${i}`);r.push(a)}}return{files:r,dirs:i}}async writeConfigFile(e,t,n,r){let i=this.getTargetRelativePath(n),a=this.resolvePath(t.basePath,t.path,i),o={pathKind:N.Relative,path:this.joinPath(t.path,i),basePath:t.basePath,getDirectoryName:()=>this.dirname(i),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`config`,path:a,label:r}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,n.content),this.log.trace({action:`write`,type:`config`,path:a,label:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`config`,path:a,label:r,error:t}),{path:o,success:!1,error:e}}}getTargetRelativePath(e){let t=e.dir.path;if(e.type===P.EditorConfig)return`.editorconfig`;if(e.type!==P.IntellijIDEA)return this.basename(t);let n=t.indexOf(Xf);return n===-1?this.joinPath(Xf,`codeStyles`,this.basename(t)):t.slice(Math.max(0,n))}},$f=class extends X{constructor(){super(`MarkdownWhitespaceCleanupEffectInputPlugin`),this.registerEffect(`markdown-whitespace-cleanup`,this.cleanupWhitespace.bind(this),30)}async cleanupWhitespace(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=[],s=[],c=[],l=[n.join(r,`src`),n.join(r,`app`),n.join(r,`dist`)];for(let n of l){if(!t.existsSync(n)){a.debug({action:`whitespace-cleanup`,message:`Directory does not exist, skipping`,dir:n});continue}this.processDirectory(e,n,o,s,c,i??!1)}let u=c.length>0;return u&&a.warn({action:`whitespace-cleanup`,errors:c.map(e=>({path:e.path,error:e.error.message}))}),{success:!u,description:i?`Would modify ${o.length} files, skip ${s.length} files`:`Modified ${o.length} files, skipped ${s.length} files`,modifiedFiles:o,skippedFiles:s,...u&&{error:Error(`${c.length} errors occurred during cleanup`)}}}processDirectory(e,t,n,r,i,a){let{fs:o,path:s,logger:c}=e,l;try{l=o.readdirSync(t,{withFileTypes:!0})}catch(e){i.push({path:t,error:e}),c.warn({action:`whitespace-cleanup`,message:`Failed to read directory`,path:t,error:e.message});return}for(let o of l){let c=s.join(t,o.name);o.isDirectory()?this.processDirectory(e,c,n,r,i,a):o.isFile()&&o.name.endsWith(`.md`)&&this.processMarkdownFile(e,c,n,r,i,a)}}processMarkdownFile(e,t,n,r,i,a){let{fs:o,logger:s}=e;try{let e=o.readFileSync(t,`utf8`),i=this.cleanMarkdownContent(e);if(e===i){r.push(t),s.debug({action:`whitespace-cleanup`,skipped:t,reason:`no changes needed`});return}a?(s.debug({action:`whitespace-cleanup`,dryRun:!0,wouldModify:t}),n.push(t)):(o.writeFileSync(t,i,`utf8`),n.push(t),s.debug({action:`whitespace-cleanup`,modified:t}))}catch(e){i.push({path:t,error:e}),s.warn({action:`whitespace-cleanup`,message:`Failed to process file`,path:t,error:e.message})}}cleanMarkdownContent(e){let t=this.detectLineEnding(e),n=e.split(/\r?\n/).map(e=>e.replace(/[ \t]+$/,``)),r=[],i=0;for(let e of n)e===``?(i++,i<=2&&r.push(e)):(i=0,r.push(e));return r.join(t)}detectLineEnding(e){return e.includes(`\r
|
|
283
283
|
`)?`\r
|
|
284
284
|
`:`
|
|
285
|
-
`}collect(e){return{}}},cp=class extends X{constructor(){super(`OrphanFileCleanupEffectInputPlugin`),this.registerEffect(`orphan-file-cleanup`,this.cleanupOrphanFiles.bind(this),20)}async cleanupOrphanFiles(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=n.join(r,`dist`),s=[],c=[],l=[];if(!t.existsSync(o))return a.debug({action:`orphan-cleanup`,message:`dist/ directory does not exist, skipping`,distDir:o}),{success:!0,description:`dist/ directory does not exist, nothing to clean`,deletedFiles:s,deletedDirs:c};for(let r of[`skills`,`commands`,`agents`,`app`]){let a=n.join(o,r);t.existsSync(a)&&this.cleanupDirectory(e,a,r,s,c,l,i??!1)}let u=l.length>0;return u&&a.warn({action:`orphan-cleanup`,errors:l.map(e=>({path:e.path,error:e.error.message}))}),{success:!u,description:i?`Would delete ${s.length} files and ${c.length} directories`:`Deleted ${s.length} files and ${c.length} directories`,deletedFiles:s,deletedDirs:c,...u&&{error:Error(`${l.length} errors occurred during cleanup`)}}}cleanupDirectory(e,t,n,r,i,a,o){let{fs:s,path:c,shadowProjectDir:l,logger:u}=e,d;try{d=s.readdirSync(t,{withFileTypes:!0})}catch(e){a.push({path:t,error:e}),u.warn({action:`orphan-cleanup`,message:`Failed to read directory`,path:t,error:e.message});return}for(let f of d){let d=c.join(t,f.name);if(f.isDirectory())this.cleanupDirectory(e,d,n,r,i,a,o),this.removeEmptyDirectory(e,d,i,a,o);else if(f.isFile()&&this.isOrphanFile(e,d,n,l))if(o)u.debug({action:`orphan-cleanup`,dryRun:!0,wouldDelete:d}),r.push(d);else try{s.unlinkSync(d),r.push(d),u.debug({action:`orphan-cleanup`,deleted:d})}catch(e){a.push({path:d,error:e}),u.warn({action:`orphan-cleanup`,message:`Failed to delete file`,path:d,error:e.message})}}}isOrphanFile(e,t,n,r){let{fs:i,path:a}=e,o=a.basename(t),s=o.endsWith(`.mdx`),c=a.join(r,`dist`,n),l=a.relative(c,t),u=a.dirname(l),d=o.replace(/\.mdx$/,``);if(s)return!this.getPossibleSourcePaths(a,r,n,d,u).some(e=>i.existsSync(e));{let e=[];return n===`app`?e.push(a.join(r,`app`,l)):e.push(a.join(r,`src`,n,l)),!e.some(e=>i.existsSync(e))}}getPossibleSourcePaths(e,t,n,r,i){switch(n){case`skills`:return i===`.`?[e.join(t,`src`,`skills`,r,`SKILL.cn.mdx`),e.join(t,`src`,`skills`,`${r}.cn.mdx`)]:[e.join(t,`src`,`skills`,i,`${r}.cn.mdx`)];case`commands`:return i===`.`?[e.join(t,`src`,`commands`,`${r}.cn.mdx`)]:[e.join(t,`src`,`commands`,i,`${r}.cn.mdx`)];case`agents`:return i===`.`?[e.join(t,`src`,`agents`,`${r}.cn.mdx`)]:[e.join(t,`src`,`agents`,i,`${r}.cn.mdx`)];case`app`:return i===`.`?[e.join(t,`app`,`${r}.cn.mdx`)]:[e.join(t,`app`,i,`${r}.cn.mdx`)];default:return[]}}removeEmptyDirectory(e,t,n,r,i){let{fs:a,logger:o}=e;try{a.readdirSync(t).length===0&&(i?(o.debug({action:`orphan-cleanup`,dryRun:!0,wouldDeleteDir:t}),n.push(t)):(a.rmdirSync(t),n.push(t),o.debug({action:`orphan-cleanup`,deletedDir:t})))}catch(e){r.push({path:t,error:e}),o.warn({action:`orphan-cleanup`,message:`Failed to check/remove directory`,path:t,error:e.message})}}collect(e){return{}}};const lp=`agt.mdx`;var up=class extends X{constructor(){super(`ProjectPromptInputPlugin`,[`ShadowProjectInputPlugin`])}async collect(e){let{dependencyContext:t,fs:n,userConfigOptions:r,path:i,globalScope:a}=e,{workspaceDir:o,shadowProjectDir:s}=this.resolveBasePaths(r),c=r.shadowProjectsDir,l=this.resolvePath(c,o,s),u=t.workspace;if(u==null)return this.log.warn(`No workspace found in dependency context, skipping project prompt enhancement`),{};let d=u.projects??[],f=await Promise.all(d.map(async t=>{let r=t.name;if(r==null)return t;let o=i.join(l,r);if(!n.existsSync(o)||!n.statSync(o).isDirectory())return t;let s=t.dirFromWorkspacePath?.getAbsolutePath(),c=await this.readRootMemoryPrompt(e,o,a),u=s==null?[]:await this.scanChildMemoryPrompts(e,o,s,a);return{...t,...c!=null&&{rootMemoryPrompt:c},...u.length>0&&{childMemoryPrompts:u}}}));return{workspace:{directory:u.directory,projects:f}}}async readRootMemoryPrompt(e,t,n){let{fs:r,path:i,logger:a}=e,o=i.join(t,lp);if(!(!r.existsSync(o)||!r.statSync(o).isFile()))try{let e=r.readFileSync(o,`utf-8`),i=Kd(e),s;try{s=await xf(e,{globalScope:n,basePath:t})}catch(e){throw e instanceof d&&(a.error(`MDX compilation failed in ${o}: ${e.message}`),a.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),m.exit(1)),e}return{type:Ot.ProjectRootMemory,content:s,length:s.length,filePathKind:N.Relative,...i.yamlFrontMatter!=null&&{yamlFrontMatter:i.yamlFrontMatter},...i.rawFrontMatter!=null&&{rawFrontMatter:i.rawFrontMatter},markdownAst:i.markdownAst,markdownContents:i.markdownContents,dir:{pathKind:N.Root,path:``,getDirectoryName:()=>``}}}catch(e){a.error(`Failed to read root memory prompt at ${o}`,{error:e});return}}async scanChildMemoryPrompts(e,t,n,r){let{logger:i}=e,a=[];try{await this.scanDirectoryRecursive(e,t,t,n,a,r)}catch(e){i.error(`Failed to scan child memory prompts at ${t}`,{error:e})}return a}async scanDirectoryRecursive(e,t,n,r,i,a){let{fs:o,path:s}=e,c=o.readdirSync(n,{withFileTypes:!0});for(let l of c){if(!l.isDirectory()||l.name.startsWith(`.`)||l.name===`node_modules`)continue;let c=s.join(n,l.name),u=s.join(c,lp);if(o.existsSync(u)&&o.statSync(u).isFile()){let n=await this.readChildMemoryPrompt(e,t,c,r,a);n!=null&&i.push(n)}await this.scanDirectoryRecursive(e,t,c,r,i,a)}}async readChildMemoryPrompt(e,t,n,r,i){let{fs:a,path:o,logger:s}=e,c=o.join(n,lp);try{let e=a.readFileSync(c,`utf-8`),l=Kd(e),u;try{u=await xf(e,{globalScope:i,basePath:n})}catch(e){throw e instanceof d&&(s.error(`MDX compilation failed in ${c}: ${e.message}`),s.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),m.exit(1)),e}let f=o.relative(t,n),p=o.join(r,f),h=o.basename(n);return{type:Ot.ProjectChildrenMemory,content:u,length:u.length,filePathKind:N.Relative,...l.yamlFrontMatter!=null&&{yamlFrontMatter:l.yamlFrontMatter},...l.rawFrontMatter!=null&&{rawFrontMatter:l.rawFrontMatter},markdownAst:l.markdownAst,markdownContents:l.markdownContents,dir:{pathKind:N.Relative,path:f,basePath:r,getDirectoryName:()=>h,getAbsolutePath:()=>p},workingChildDirectoryPath:{pathKind:N.Relative,path:f,basePath:r,getDirectoryName:()=>h,getAbsolutePath:()=>p}}}catch(e){s.error(`Failed to read child memory prompt at ${c}`,{error:e});return}}};const dp=`README.md`;var fp=class extends Jd{constructor(){super(`ReadmeMdConfigFileOutputPlugin`,{outputFileName:dp})}async registerProjectOutputFiles(e){let t=[],{readmePrompts:n}=e.collectedInputContext;if(n==null||n.length===0)return t;for(let e of n){let n=e.targetDir,r=g.join(n.path,dp);t.push({pathKind:N.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>n.getDirectoryName(),getAbsolutePath:()=>g.join(n.basePath,r)})}return t}async canWrite(e){let{readmePrompts:t}=e.collectedInputContext;return t==null||t.length===0?(this.log.debug(`skipped`,{reason:`no README prompts to write`}),!1):!0}async writeProjectOutputs(e){let t=[],n=[],{readmePrompts:r}=e.collectedInputContext;if(r==null||r.length===0)return{files:t,dirs:n};for(let n of r){let r=await this.writeReadmeFile(e,n);t.push(r)}return{files:t,dirs:n}}async writeReadmeFile(e,t){let n=t.targetDir,r=g.join(n.path,dp),i=g.join(n.basePath,r),a=t.content,o={pathKind:N.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>n.getDirectoryName(),getAbsolutePath:()=>i},s=t.isRoot?`project:${t.projectName}/README.md`:`project:${t.projectName}/${n.path}/README.md`;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`readme`,path:i,label:s}),{path:o,success:!0,skipped:!1};try{let e=g.dirname(i);return h.existsSync(e)||h.mkdirSync(e,{recursive:!0}),h.writeFileSync(i,a,`utf-8`),this.log.trace({action:`write`,type:`readme`,path:i,label:s}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`readme`,path:i,label:s,error:t}),{path:o,success:!1,error:e}}}},pp=class extends X{constructor(){super(`ReadmeMdInputPlugin`,[`ShadowProjectInputPlugin`])}async collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i,globalScope:a}=e,{workspaceDir:o,shadowProjectDir:s}=this.resolveBasePaths(t),c=t.shadowProjectsDir,l=this.resolvePath(c,o,s),u=[];if(!r.existsSync(l)||!r.statSync(l).isDirectory())return n.debug(`shadow projects directory does not exist`,{path:l}),{readmePrompts:u};try{let t=r.readdirSync(l,{withFileTypes:!0});for(let n of t){if(!n.isDirectory())continue;let t=n.name,r=i.join(l,t);await this.collectReadmeFiles(e,r,t,o,``,u,a)}}catch(e){n.error(`failed to scan shadow projects`,{path:l,error:e})}return{readmePrompts:u}}async collectReadmeFiles(e,t,n,r,i,a,o){let{fs:s,path:c,logger:l}=e,u=i===``,f=c.join(t,`readme.mdx`);if(s.existsSync(f)&&s.statSync(f).isFile())try{let e=s.readFileSync(f,`utf-8`),p;if(o!=null)try{p=await xf(e,{globalScope:o,basePath:t})}catch(e){throw e instanceof d&&(l.error(`MDX compilation failed in ${f}: ${e.message}`),l.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),m.exit(1)),e}else p=e;let h=u?n:c.join(n,i),g={pathKind:N.Relative,path:h,basePath:r,getDirectoryName:()=>u?n:c.basename(i),getAbsolutePath:()=>c.resolve(r,h)},_={pathKind:N.Relative,path:c.dirname(f),basePath:r,getDirectoryName:()=>c.basename(c.dirname(f)),getAbsolutePath:()=>c.dirname(f)};a.push({type:Ot.Readme,content:p,length:p.length,filePathKind:N.Relative,projectName:n,targetDir:g,isRoot:u,markdownContents:[],dir:_})}catch(e){l.warn(`failed to read readme`,{path:f,error:e})}try{let l=s.readdirSync(t,{withFileTypes:!0});for(let s of l)if(s.isDirectory()){let l=u?s.name:c.join(i,s.name),d=c.join(t,s.name);await this.collectReadmeFiles(e,d,n,r,l,a,o)}}catch(e){l.warn(`failed to scan directory`,{path:t,error:e})}}},mp=class extends X{constructor(){super(`ShadowProjectInputPlugin`)}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.shadowProjectsDir,c=this.resolvePath(s,a,o),l=i.basename(o),u=[];if(r.existsSync(c)&&r.statSync(c).isDirectory())try{let e=r.readdirSync(c,{withFileTypes:!0});for(let t of e)if(t.isDirectory()){let e=t.name===l;u.push({name:t.name,...e&&{isPromptSourceProject:!0},dirFromWorkspacePath:{pathKind:N.Relative,path:t.name,basePath:a,getDirectoryName:()=>t.name,getAbsolutePath:()=>i.resolve(a,t.name)}})}}catch(e){n.error(`failed to scan shadow projects`,{path:c,error:e})}if(u.length===0&&r.existsSync(a)&&r.statSync(a).isDirectory()){n.debug(`no projects in dist/app/, falling back to workspace scan`,{workspaceDir:a});try{let e=r.readdirSync(a,{withFileTypes:!0});for(let t of e)if(t.isDirectory()&&!t.name.startsWith(`.`)){let e=t.name===l;u.push({name:t.name,...e&&{isPromptSourceProject:!0},dirFromWorkspacePath:{pathKind:N.Relative,path:t.name,basePath:a,getDirectoryName:()=>t.name,getAbsolutePath:()=>i.resolve(a,t.name)}})}}catch(e){n.error(`failed to scan workspace directory`,{path:a,error:e})}}return{workspace:{directory:{pathKind:N.Absolute,path:a,getDirectoryName:()=>i.basename(a)},projects:u}}}},hp=class extends X{constructor(){super(`SkillInputPlugin`)}readMcpConfig(e,t,n){let r=g.join(e,`mcp.json`);if(t.existsSync(r)){if(!t.statSync(r).isFile()){n.warn(`mcp.json is not a file`,{skillDir:e});return}try{let i=t.readFileSync(r,`utf-8`),a=JSON.parse(i);if(a.mcpServers==null||typeof a.mcpServers!=`object`){n.warn(`mcp.json missing mcpServers field`,{skillDir:e});return}return{type:Ot.SkillMcpConfig,mcpServers:a.mcpServers,rawContent:i}}catch(t){n.warn(`failed to parse mcp.json`,{skillDir:e,error:t});return}}}isBinaryResourceExtension(e){return zt.includes(e.toLowerCase())}getResourceCategory(e){let t=e.toLowerCase();return[`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.ico`,`.bmp`,`.tiff`,`.svg`].includes(t)?`image`:`.kt,.java,.py,.pyi,.pyx,.ts,.tsx,.js,.jsx,.mjs,.cjs,.go,.rs,.c,.cpp,.cc,.h,.hpp,.hxx,.cs,.fs,.fsx,.vb,.rb,.php,.swift,.scala,.groovy,.lua,.r,.jl,.ex,.exs,.erl,.clj,.cljs,.hs,.ml,.mli,.nim,.zig,.v,.dart,.vue,.svelte,.d.ts,.d.mts,.d.cts`.split(`,`).includes(t)?`code`:[`.sql`,`.json`,`.jsonc`,`.json5`,`.xml`,`.xsd`,`.xsl`,`.xslt`,`.yaml`,`.yml`,`.toml`,`.csv`,`.tsv`,`.graphql`,`.gql`,`.proto`].includes(t)?`data`:[`.txt`,`.text`,`.rtf`,`.log`,`.docx`,`.doc`,`.xlsx`,`.xls`,`.pptx`,`.ppt`,`.pdf`,`.odt`,`.ods`,`.odp`].includes(t)?`document`:[`.ini`,`.conf`,`.cfg`,`.config`,`.properties`,`.env`,`.envrc`,`.editorconfig`,`.gitignore`,`.gitattributes`,`.npmrc`,`.nvmrc`,`.npmignore`,`.eslintrc`,`.prettierrc`,`.stylelintrc`,`.babelrc`,`.browserslistrc`].includes(t)?`config`:[`.sh`,`.bash`,`.zsh`,`.fish`,`.ps1`,`.psm1`,`.psd1`,`.bat`,`.cmd`].includes(t)?`script`:`.exe,.dll,.so,.dylib,.bin,.wasm,.class,.jar,.war,.pyd,.pyc,.pyo,.zip,.tar,.gz,.bz2,.7z,.rar,.ttf,.otf,.woff,.woff2,.eot,.db,.sqlite,.sqlite3`.split(`,`).includes(t)?`binary`:`other`}getMimeType(e){return{".ts":`text/typescript`,".tsx":`text/typescript`,".js":`text/javascript`,".jsx":`text/javascript`,".json":`application/json`,".py":`text/x-python`,".java":`text/x-java`,".kt":`text/x-kotlin`,".go":`text/x-go`,".rs":`text/x-rust`,".c":`text/x-c`,".cpp":`text/x-c++`,".cs":`text/x-csharp`,".rb":`text/x-ruby`,".php":`text/x-php`,".swift":`text/x-swift`,".scala":`text/x-scala`,".sql":`application/sql`,".xml":`application/xml`,".yaml":`text/yaml`,".yml":`text/yaml`,".toml":`text/toml`,".csv":`text/csv`,".graphql":`application/graphql`,".txt":`text/plain`,".pdf":`application/pdf`,".docx":`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,".xlsx":`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,".html":`text/html`,".css":`text/css`,".svg":`image/svg+xml`,".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".webp":`image/webp`,".ico":`image/x-icon`,".bmp":`image/bmp`}[e.toLowerCase()]}scanSkillDirectory(e,t,n,r=``){let i=[],a=[],o=r?g.join(e,r):e;try{let s=t.readdirSync(o,{withFileTypes:!0});for(let c of s){let s=r?`${r}/${c.name}`:c.name;if(c.isDirectory()){let r=this.scanSkillDirectory(e,t,n,s);i.push(...r.childDocs),a.push(...r.resources)}else if(c.isFile()){let l=g.join(o,c.name);if(c.name.endsWith(`.mdx`)){if(r===``&&c.name===`skill.mdx`)continue;try{let n=Kd(t.readFileSync(l,`utf-8`)),r=n.contentWithoutFrontMatter;i.push({type:Ot.SkillChildDoc,content:r,length:r.length,filePathKind:N.Relative,markdownAst:n.markdownAst,markdownContents:n.markdownContents,...n.rawFrontMatter!=null&&{rawFrontMatter:n.rawFrontMatter},relativePath:s,dir:{pathKind:N.Relative,path:s,basePath:e,getDirectoryName:()=>g.dirname(s),getAbsolutePath:()=>l}})}catch(e){n.warn(`failed to read child doc`,{path:s,error:e})}}else{if(r===``&&c.name===`mcp.json`)continue;let e=g.extname(c.name),i,o,u;try{if(this.isBinaryResourceExtension(e)){let e=t.readFileSync(l);i=e.toString(`base64`),o=`base64`,u=e.length}else i=t.readFileSync(l,`utf-8`),o=`text`,u=w.byteLength(i,`utf-8`);let n=this.getMimeType(e),r={type:Ot.SkillResource,extension:e,fileName:c.name,relativePath:s,content:i,encoding:o,category:this.getResourceCategory(e),length:u};n==null?a.push(r):a.push({...r,mimeType:n})}catch(e){n.warn(`failed to read resource file`,{path:s,error:e})}}}}}catch(e){n.warn(`failed to scan directory`,{path:o,error:e})}return{childDocs:i,resources:a}}async collect(e){let{userConfigOptions:n,logger:r,globalScope:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(n),s=n.shadowSkillSourceDir,c=this.resolvePath(s,a,o),l=[];if(e.fs.existsSync(c)&&e.fs.statSync(c).isDirectory()){let n=e.fs.readdirSync(c,{withFileTypes:!0});for(let a of n)if(a.isDirectory()){let n=e.path.join(c,a.name,`skill.mdx`);if(e.fs.existsSync(n)&&e.fs.statSync(n).isFile())try{let o=e.fs.readFileSync(n,`utf-8`),s=Kd(o),u=await xf(o,{globalScope:i,extractMetadata:!0,basePath:e.path.join(c,a.name)}),d={...s.yamlFrontMatter,...u.metadata.fields},f=Pt(d,n);for(let e of f.warnings)r.debug(e);if(!f.valid)throw new t(f.errors,n);let p=u.content,m=e.path.join(c,a.name),h=this.readMcpConfig(m,e.fs,r),{childDocs:_,resources:v}=this.scanSkillDirectory(m,e.fs,r);r.debug(`skill metadata extracted`,{skill:a.name,source:u.metadata.source,hasYaml:s.yamlFrontMatter!=null,hasExport:Object.keys(u.metadata.fields).length>0}),l.push({type:Ot.Skill,content:p,length:p.length,filePathKind:N.Relative,yamlFrontMatter:d.name==null?{name:a.name,description:``}:d,...s.rawFrontMatter!=null&&{rawFrontMatter:s.rawFrontMatter},markdownAst:s.markdownAst,markdownContents:s.markdownContents,...h!=null&&{mcpConfig:h},..._.length>0&&{childDocs:_},...v.length>0&&{resources:v},dir:{pathKind:N.Relative,path:a.name,basePath:c,getDirectoryName:()=>a.name,getAbsolutePath:()=>g.join(c,a.name)}})}catch(e){r.error(`failed to parse skill`,{file:n,error:e})}}}return{skills:l}}},gp=class extends X{constructor(){super(`SkillNonSrcFileSyncEffectInputPlugin`),this.registerEffect(`skill-non-src-file-sync`,this.syncNonSrcFiles.bind(this),10)}async syncNonSrcFiles(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=n.join(r,`src`,`skills`),s=n.join(r,`dist`,`skills`),c=[],l=[],u=[],d=[];if(!t.existsSync(o))return a.debug({action:`skill-sync`,message:`src/skills/ directory does not exist, skipping`,srcSkillsDir:o}),{success:!0,description:`src/skills/ directory does not exist, nothing to sync`,copiedFiles:c,skippedFiles:l,createdDirs:u};this.syncDirectoryRecursive(e,o,s,``,c,l,u,d,i??!1);let f=d.length>0;return f&&a.warn({action:`skill-sync`,errors:d.map(e=>({path:e.path,error:e.error.message}))}),{success:!f,description:i?`Would copy ${c.length} files, skip ${l.length} files`:`Copied ${c.length} files, skipped ${l.length} files`,copiedFiles:c,skippedFiles:l,createdDirs:u,...f&&{error:Error(`${d.length} errors occurred during sync`)},modifiedFiles:c}}syncDirectoryRecursive(e,t,n,r,i,a,o,s,c){let{fs:l,path:u,logger:d}=e,f=r?u.join(t,r):t;if(!l.existsSync(f))return;let p;try{p=l.readdirSync(f,{withFileTypes:!0})}catch(e){s.push({path:f,error:e}),d.warn({action:`skill-sync`,message:`Failed to read directory`,path:f,error:e.message});return}for(let f of p){let p=r?u.join(r,f.name):f.name,m=u.join(t,p),h=u.join(n,p);if(f.isDirectory())this.syncDirectoryRecursive(e,t,n,p,i,a,o,s,c);else if(f.isFile()){if(f.name.endsWith(`.cn.mdx`))continue;let e=u.dirname(h);if(!l.existsSync(e))if(c)d.debug({action:`skill-sync`,dryRun:!0,wouldCreateDir:e}),o.push(e);else try{l.mkdirSync(e,{recursive:!0}),o.push(e),d.debug({action:`skill-sync`,createdDir:e})}catch(t){s.push({path:e,error:t}),d.warn({action:`skill-sync`,message:`Failed to create directory`,path:e,error:t.message});continue}if(l.existsSync(h))try{let e=l.readFileSync(m),t=l.readFileSync(h);if(this.computeHash(e)===this.computeHash(t)){a.push(h),d.debug({action:`skill-sync`,skipped:h,reason:`identical content`});continue}}catch(e){d.debug({action:`skill-sync`,message:`Could not compare files, will copy`,path:h,error:e.message})}if(c)d.debug({action:`skill-sync`,dryRun:!0,wouldCopy:{from:m,to:h}}),i.push(h);else try{l.copyFileSync(m,h),i.push(h),d.debug({action:`skill-sync`,copied:{from:m,to:h}})}catch(e){s.push({path:h,error:e}),d.warn({action:`skill-sync`,message:`Failed to copy file`,from:m,to:h,error:e.message})}}}}computeHash(e){return T(`sha256`).update(e).digest(`hex`)}collect(e){return{}}},_p=class extends X{constructor(){super(`SubAgentInputPlugin`)}async collect(e){let{userConfigOptions:n,logger:r,fs:i,path:a,globalScope:o}=e,{workspaceDir:s,shadowProjectDir:c}=this.resolveBasePaths(n),l=n.shadowSubAgentDir,u=this.resolvePath(l,s,c),d=[];if(i.existsSync(u)&&i.statSync(u).isDirectory())try{let e=i.readdirSync(u,{withFileTypes:!0});for(let n of e)if(n.isFile()&&n.name.endsWith(`.mdx`)){let e=a.join(u,n.name),s=i.readFileSync(e,`utf-8`),c=Kd(s),l=await xf(s,{globalScope:o,extractMetadata:!0,basePath:u}),f=c.yamlFrontMatter!=null||Object.keys(l.metadata.fields).length>0?{...c.yamlFrontMatter,...l.metadata.fields}:void 0;if(f!=null){let n=It(f,e);for(let e of n.warnings)r.debug(e);if(!n.valid)throw new t(n.errors,e)}let p=l.content;r.debug(`sub agent metadata extracted`,{agent:n.name,source:l.metadata.source,hasYaml:c.yamlFrontMatter!=null,hasExport:Object.keys(l.metadata.fields).length>0}),d.push({type:Ot.SubAgent,content:p,length:p.length,filePathKind:N.Relative,...f!=null&&{yamlFrontMatter:f},...c.rawFrontMatter!=null&&{rawFrontMatter:c.rawFrontMatter},markdownAst:c.markdownAst,markdownContents:c.markdownContents,dir:{pathKind:N.Relative,path:n.name,basePath:u,getDirectoryName:()=>n.name.replace(/\.mdx$/,``),getAbsolutePath:()=>e}})}}catch(e){r.error(`Failed to scan sub agents at ${u}`,{error:e})}return{subAgents:d}}};const vp=`WARP.md`;var yp=class extends Jd{constructor(){super(`WarpIDEOutputPlugin`,{outputFileName:vp})}isAgentsPluginRegistered(e){return`registeredPluginNames`in e&&e.registeredPluginNames!=null?e.registeredPluginNames.includes(`AgentsOutputPlugin`):!1}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,r=this.isAgentsPluginRegistered(e);for(let e of n)if(e.dirFromWorkspacePath!=null){if(r)t.push(this.createFileRelativePath(e.dirFromWorkspacePath,vp));else if(e.rootMemoryPrompt!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,vp)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,vp))}return t}async canWrite(e){let t=this.isAgentsPluginRegistered(e),{workspace:n,globalMemory:r}=e.collectedInputContext;return t?r==null?(this.log.debug(`skipped`,{reason:`AgentsOutputPlugin registered but no global memory`}),!1):!0:n.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)?!0:(this.log.debug(`skipped`,{reason:`no outputs to write`}),!1)}async writeProjectOutputs(e){let t=this.isAgentsPluginRegistered(e),{workspace:n,globalMemory:r}=e.collectedInputContext,{projects:i}=n,a=[],o=[];if(t){if(r==null)return{files:[],dirs:[]};for(let t of i){let n=t.dirFromWorkspacePath;if(n==null)continue;let i=t.name??`unknown`,o=await this.writePromptFile(e,n,r.content,`project:${i}/global-warp`);a.push(o)}return{files:a,dirs:o}}let s=this.extractGlobalMemoryContent(e);for(let t of i){let n=t.name??`unknown`,r=t.dirFromWorkspacePath;if(r!=null){if(t.rootMemoryPrompt!=null){let i=this.combineGlobalWithContent(s,t.rootMemoryPrompt.content),o=await this.writePromptFile(e,r,i,`project:${n}/root`);a.push(o)}if(t.childMemoryPrompts!=null)for(let r of t.childMemoryPrompts){let t=await this.writePromptFile(e,r.dir,r.content,`project:${n}/child:${r.workingChildDirectoryPath?.path??`unknown`}`);a.push(t)}}}return{files:a,dirs:o}}},bp=class extends X{constructor(){super(`WorkspaceInputPlugin`)}collect(e){let{userConfigOptions:t}=e,{workspaceDir:n,shadowProjectDir:r}=this.resolveBasePaths(t),i=t.externalProjects.map(e=>{let t=this.resolvePath(e,n,r);return{name:g.basename(t),dirFromWorkspacePath:{pathKind:N.Relative,path:t,basePath:n,getDirectoryName:()=>g.basename(t)}}});return{workspace:{directory:{pathKind:N.Absolute,path:n,getDirectoryName:()=>g.basename(n)},projects:[]},shadowSourceProjectDir:r,...i.length>0&&{externalProjects:i}}}};const xp=`.vscode`,Sp=[`.vscode/settings.json`,`.vscode/extensions.json`];var Cp=class extends Jd{constructor(){super(`VisualStudioCodeIDEConfigOutputPlugin`)}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{ideConfigFiles:r}=e.collectedInputContext;if(!r.some(e=>e.type===P.VSCode))return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&e.isPromptSourceProject!==!0)for(let e of Sp){let r=this.joinPath(n.path,e);t.push({pathKind:N.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>this.dirname(e),getAbsolutePath:()=>this.resolvePath(n.basePath,r)})}}return t}async canWrite(e){let{ideConfigFiles:t}=e.collectedInputContext;return t.some(e=>e.type===P.VSCode)?!0:(this.log.debug(`skipped`,{reason:`no VS Code config files found`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{ideConfigFiles:n}=e.collectedInputContext,r=[],i=[],a=n.filter(e=>e.type===P.VSCode);for(let n of t){let t=n.dirFromWorkspacePath;if(t==null)continue;let i=n.name??`unknown`;for(let n of a){let a=await this.writeConfigFile(e,t,n,`project:${i}`);r.push(a)}}return{files:r,dirs:i}}async writeConfigFile(e,t,n,r){let i=this.getTargetRelativePath(n),a=this.resolvePath(t.basePath,t.path,i),o={pathKind:N.Relative,path:this.joinPath(t.path,i),basePath:t.basePath,getDirectoryName:()=>this.dirname(i),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`config`,path:a,label:r}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,n.content),this.log.trace({action:`write`,type:`config`,path:a,label:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`config`,path:a,label:r,error:t}),{path:o,success:!1,error:e}}}getTargetRelativePath(e){let t=e.dir.path;if(e.type===P.VSCode){let e=t.indexOf(xp);return e===-1?this.joinPath(xp,this.basename(t)):t.substring(e)}return this.basename(t)}},wp=Tr({plugins:[new Xd,new ef,new Df,new Nf,new zf,new Uf,new qf,new op,new yp,new Qf,new Cp,new fp,new gp,new cp,new sp,new bp,new mp,new Qd,new Yf,new hp,new Bf,new _p,new Jf,new up,new pp]}),Tp=wp;async function Ep(){let e=await wp;await new _r(...m.argv).run(e)}Ep().catch(e=>{console.error(e)});export{e as CircularDependencyError,kt as ClaudeCodeCLISubAgentColors,At as CodingAgentTools,Vn as ConfigLoader,s as ConfigValidationError,In as DEFAULT_CONFIG_FILE_NAME,Ln as DEFAULT_GLOBAL_CONFIG_DIR,Bt as DEFAULT_SHADOW_SOURCE_PROJECT_STRUCTURE,Yt as DEFAULT_USER_CONFIG,l as ExportParseError,N as FilePathKind,Mt as GlobalConfigDirectoryType,P as IDEKind,t as MetadataValidationError,a as MissingDependencyError,jt as NamingCaseKind,Jt as PathPlaceholders,Dt as PluginKind,Ot as PromptKind,F as SHADOW_SOURCE_DIR_NAMES,I as SHADOW_SOURCE_FILE_NAMES,L as SHADOW_SOURCE_RELATIVE_PATHS,zt as SKILL_RESOURCE_BINARY_EXTENSIONS,Rt as SKILL_RESOURCE_TEXT_EXTENSIONS,d as ScopeError,n as UndefinedNamespaceError,r as UndefinedVariableError,Lt as applyMetadataDefaults,vt as checkCanClean,bt as checkCanWrite,Xt as checkVersionControl,_t as collectAllPluginOutputs,Fn as createLogger,Tp as default,Tr as defineConfig,yt as executeOnCleanComplete,xt as executeWriteOutputs,nn as generateShadowSourceProject,Un as getConfigLoader,zn as getDefaultUserConfig,Rn as getGlobalConfigPath,Dn as getGlobalLogLevel,Wn as loadUserConfig,br as mergeConfig,En as setGlobalLogLevel,Gn as validateAndEnsureGlobalConfig,Nt as validateExportMetadata,Ft as validateFastCommandMetadata,Zt as validateShadowSourceProject,Pt as validateSkillMetadata,It as validateSubAgentMetadata};
|
|
285
|
+
`}collect(e){return{}}},ep=class extends X{constructor(){super(`OrphanFileCleanupEffectInputPlugin`),this.registerEffect(`orphan-file-cleanup`,this.cleanupOrphanFiles.bind(this),20)}async cleanupOrphanFiles(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=n.join(r,`dist`),s=[],c=[],l=[];if(!t.existsSync(o))return a.debug({action:`orphan-cleanup`,message:`dist/ directory does not exist, skipping`,distDir:o}),{success:!0,description:`dist/ directory does not exist, nothing to clean`,deletedFiles:s,deletedDirs:c};for(let r of[`skills`,`commands`,`agents`,`app`]){let a=n.join(o,r);t.existsSync(a)&&this.cleanupDirectory(e,a,r,s,c,l,i??!1)}let u=l.length>0;return u&&a.warn({action:`orphan-cleanup`,errors:l.map(e=>({path:e.path,error:e.error.message}))}),{success:!u,description:i?`Would delete ${s.length} files and ${c.length} directories`:`Deleted ${s.length} files and ${c.length} directories`,deletedFiles:s,deletedDirs:c,...u&&{error:Error(`${l.length} errors occurred during cleanup`)}}}cleanupDirectory(e,t,n,r,i,a,o){let{fs:s,path:c,shadowProjectDir:l,logger:u}=e,d;try{d=s.readdirSync(t,{withFileTypes:!0})}catch(e){a.push({path:t,error:e}),u.warn({action:`orphan-cleanup`,message:`Failed to read directory`,path:t,error:e.message});return}for(let f of d){let d=c.join(t,f.name);if(f.isDirectory())this.cleanupDirectory(e,d,n,r,i,a,o),this.removeEmptyDirectory(e,d,i,a,o);else if(f.isFile()&&this.isOrphanFile(e,d,n,l))if(o)u.debug({action:`orphan-cleanup`,dryRun:!0,wouldDelete:d}),r.push(d);else try{s.unlinkSync(d),r.push(d),u.debug({action:`orphan-cleanup`,deleted:d})}catch(e){a.push({path:d,error:e}),u.warn({action:`orphan-cleanup`,message:`Failed to delete file`,path:d,error:e.message})}}}isOrphanFile(e,t,n,r){let{fs:i,path:a}=e,o=a.basename(t),s=o.endsWith(`.mdx`),c=a.join(r,`dist`,n),l=a.relative(c,t),u=a.dirname(l),d=o.replace(/\.mdx$/,``);if(s)return!this.getPossibleSourcePaths(a,r,n,d,u).some(e=>i.existsSync(e));{let e=[];return n===`app`?e.push(a.join(r,`app`,l)):e.push(a.join(r,`src`,n,l)),!e.some(e=>i.existsSync(e))}}getPossibleSourcePaths(e,t,n,r,i){switch(n){case`skills`:return i===`.`?[e.join(t,`src`,`skills`,r,`SKILL.cn.mdx`),e.join(t,`src`,`skills`,`${r}.cn.mdx`)]:[e.join(t,`src`,`skills`,i,`${r}.cn.mdx`)];case`commands`:return i===`.`?[e.join(t,`src`,`commands`,`${r}.cn.mdx`)]:[e.join(t,`src`,`commands`,i,`${r}.cn.mdx`)];case`agents`:return i===`.`?[e.join(t,`src`,`agents`,`${r}.cn.mdx`)]:[e.join(t,`src`,`agents`,i,`${r}.cn.mdx`)];case`app`:return i===`.`?[e.join(t,`app`,`${r}.cn.mdx`)]:[e.join(t,`app`,i,`${r}.cn.mdx`)];default:return[]}}removeEmptyDirectory(e,t,n,r,i){let{fs:a,logger:o}=e;try{a.readdirSync(t).length===0&&(i?(o.debug({action:`orphan-cleanup`,dryRun:!0,wouldDeleteDir:t}),n.push(t)):(a.rmdirSync(t),n.push(t),o.debug({action:`orphan-cleanup`,deletedDir:t})))}catch(e){r.push({path:t,error:e}),o.warn({action:`orphan-cleanup`,message:`Failed to check/remove directory`,path:t,error:e.message})}}collect(e){return{}}},tp=class{registryPath;log;constructor(e,t){this.registryPath=this.resolvePath(e),this.log=t??Fn(this.constructor.name)}resolvePath(e){return e.startsWith(`~`)?g.join(v.homedir(),e.slice(1)):g.resolve(e)}getRegistryDir(){return g.dirname(this.registryPath)}ensureRegistryDir(){let e=this.getRegistryDir();h.existsSync(e)||h.mkdirSync(e,{recursive:!0})}read(){if(!h.existsSync(this.registryPath))return this.log.debug(`registry not found`,{path:this.registryPath}),this.createInitialRegistry();try{let e=h.readFileSync(this.registryPath,`utf8`);return JSON.parse(e)}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error(`parse failed`,{path:this.registryPath,error:t}),this.createInitialRegistry()}}write(e,t){let n={...e,lastUpdated:new Date().toISOString()};if(t===!0)return this.log.trace({action:`dryRun`,type:`registry`,path:this.registryPath}),!0;let r=`${this.registryPath}.tmp.${Date.now()}`;try{this.ensureRegistryDir();let e=JSON.stringify(n,null,2);return h.writeFileSync(r,e,`utf8`),h.renameSync(r,this.registryPath),this.log.trace({action:`write`,type:`registry`,path:this.registryPath}),!0}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`registry`,path:this.registryPath,error:t});try{h.existsSync(r)&&h.unlinkSync(r)}catch{}return!1}}register(e,t){let n=[],r=this.read(),i=this.merge(r,e),a=this.write(i,t);for(let r of e){let e=this.getEntryName(r);a?(n.push({success:!0,entryName:e}),t===!0?this.log.trace({action:`dryRun`,type:`registerEntry`,entryName:e}):this.log.trace({action:`register`,type:`entry`,entryName:e})):(n.push({success:!1,entryName:e,error:Error(`Failed to write registry file`)}),this.log.error(`register entry failed`,{entryName:e}))}return n}generateEntryId(e){let t=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return e==null?t:`${e}-${t}`}},np=class extends X{constructor(){super(`SkillNonSrcFileSyncEffectInputPlugin`),this.registerEffect(`skill-non-src-file-sync`,this.syncNonSrcFiles.bind(this),10)}async syncNonSrcFiles(e){let{fs:t,path:n,shadowProjectDir:r,dryRun:i,logger:a}=e,o=n.join(r,`src`,`skills`),s=n.join(r,`dist`,`skills`),c=[],l=[],u=[],d=[];if(!t.existsSync(o))return a.debug({action:`skill-sync`,message:`src/skills/ directory does not exist, skipping`,srcSkillsDir:o}),{success:!0,description:`src/skills/ directory does not exist, nothing to sync`,copiedFiles:c,skippedFiles:l,createdDirs:u};this.syncDirectoryRecursive(e,o,s,``,c,l,u,d,i??!1);let f=d.length>0;return f&&a.warn({action:`skill-sync`,errors:d.map(e=>({path:e.path,error:e.error.message}))}),{success:!f,description:i?`Would copy ${c.length} files, skip ${l.length} files`:`Copied ${c.length} files, skipped ${l.length} files`,copiedFiles:c,skippedFiles:l,createdDirs:u,...f&&{error:Error(`${d.length} errors occurred during sync`)},modifiedFiles:c}}syncDirectoryRecursive(e,t,n,r,i,a,o,s,c){let{fs:l,path:u,logger:d}=e,f=r?u.join(t,r):t;if(!l.existsSync(f))return;let p;try{p=l.readdirSync(f,{withFileTypes:!0})}catch(e){s.push({path:f,error:e}),d.warn({action:`skill-sync`,message:`Failed to read directory`,path:f,error:e.message});return}for(let f of p){let p=r?u.join(r,f.name):f.name,m=u.join(t,p),h=u.join(n,p);if(f.isDirectory())this.syncDirectoryRecursive(e,t,n,p,i,a,o,s,c);else if(f.isFile()){if(f.name.endsWith(`.cn.mdx`))continue;let e=u.dirname(h);if(!l.existsSync(e))if(c)d.debug({action:`skill-sync`,dryRun:!0,wouldCreateDir:e}),o.push(e);else try{l.mkdirSync(e,{recursive:!0}),o.push(e),d.debug({action:`skill-sync`,createdDir:e})}catch(t){s.push({path:e,error:t}),d.warn({action:`skill-sync`,message:`Failed to create directory`,path:e,error:t.message});continue}if(l.existsSync(h))try{let e=l.readFileSync(m),t=l.readFileSync(h);if(this.computeHash(e)===this.computeHash(t)){a.push(h),d.debug({action:`skill-sync`,skipped:h,reason:`identical content`});continue}}catch(e){d.debug({action:`skill-sync`,message:`Could not compare files, will copy`,path:h,error:e.message})}if(c)d.debug({action:`skill-sync`,dryRun:!0,wouldCopy:{from:m,to:h}}),i.push(h);else try{l.copyFileSync(m,h),i.push(h),d.debug({action:`skill-sync`,copied:{from:m,to:h}})}catch(e){s.push({path:h,error:e}),d.warn({action:`skill-sync`,message:`Failed to copy file`,from:m,to:h,error:e.message})}}}}computeHash(e){return T(`sha256`).update(e).digest(`hex`)}collect(e){return{}}},rp=class e extends tp{static REGISTRY_PATH=`~/.kiro/powers/registry.json`;static DEFAULT_VERSION=`1.0.0`;constructor(t){super(e.REGISTRY_PATH,t)}createInitialRegistry(){return{version:e.DEFAULT_VERSION,powers:{},repoSources:{},lastUpdated:new Date().toISOString()}}getEntryName(e){return e.name}merge(e,t){let n={...e.powers},r={...e.repoSources};for(let e of t){n[e.name]=e;let t=this.buildRepoSource(e),i=e.source.repoId??e.name;r[i]=t}return{version:e.version,powers:n,repoSources:r,...e.kiroRecommendedRepo!=null&&{kiroRecommendedRepo:e.kiroRecommendedRepo},lastUpdated:e.lastUpdated}}buildPowerEntry(e,t){let{yamlFrontMatter:n,mcpConfig:r}=e,i={type:`repo`,repoId:this.generateEntryId(`local`),repoName:t},a=r==null?null:Object.keys(r.mcpServers);return{name:n.name,description:n.description,...a!=null&&a.length>0&&{mcpServers:a},...n.author!=null&&{author:n.author},keywords:n.keywords??[],...n.displayName!=null&&{displayName:n.displayName},installed:!0,installedAt:new Date().toISOString(),installPath:t,source:i,sourcePath:t}}getOfficialRegistry(){try{return JSON.parse({version:`1.0.0`,powers:{postman:{name:`postman`,description:`Automate API testing and collection management with Postman - create workspaces, collections, environments, and run tests programmatically`,displayName:`API Testing with Postman`,author:`Postman`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/postman.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/postman`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`postman`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},figma:{name:`figma`,description:`Connect Figma designs to code components - automatically generate design system rules, map UI components to Figma designs, and maintain design-code consistency`,displayName:`Design to Code with Figma`,author:`Figma`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/figma.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/figma`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`figma`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"netlify-deployment":{name:`netlify-deployment`,description:`Deploy React, Next.js, Vue, and other modern web apps to Netlify's global CDN with automatic builds.`,displayName:`Deploy web apps with Netlify`,author:`Netlify`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/netlify.png`,repositoryUrl:`https://github.com/netlify/context-and-tools/tree/main/context/steering/netlify-deployment-power`,license:``,repositoryCloneUrl:`git@github.com:netlify/context-and-tools.git`,pathInRepo:`context/steering/netlify-deployment-power`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"amazon-aurora-postgresql":{name:`amazon-aurora-postgresql`,description:`Build applications backed by Aurora PostgreSQL by leveraging Aurora PostgreSQL specific best practices.`,displayName:`Build applications with Aurora PostgreSQL`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/amazon-aurora.png`,repositoryUrl:`https://github.com/awslabs/mcp/tree/main/src/postgres-mcp-server/kiro_power`,license:``,repositoryCloneUrl:`git@github.com:awslabs/mcp.git`,pathInRepo:`src/postgres-mcp-server/kiro_power`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"supabase-hosted":{name:`supabase-hosted`,description:`Build applications with Supabase's Postgres database, authentication, storage, and real-time subscriptions`,displayName:`Build a backend with Supabase`,author:`Supabase`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/supabase.png`,repositoryUrl:`https://github.com/supabase-community/kiro-powers/tree/main/powers/supabase-hosted`,license:``,repositoryCloneUrl:`git@github.com:supabase-community/kiro-powers.git`,pathInRepo:`powers/supabase-hosted`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"supabase-local":{name:`supabase-local`,description:`Local development with Supabase allows you to work on your projects in a self-contained environment on your local machine.`,displayName:`Build a backend (local) with Supabase`,author:`Supabase`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/supabase.png`,repositoryUrl:`https://github.com/supabase-community/kiro-powers/tree/main/powers/supabase-local`,license:``,repositoryCloneUrl:`git@github.com:supabase-community/kiro-powers.git`,pathInRepo:`powers/supabase-local`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},terraform:{name:`terraform`,description:`Build and manage Infrastructure as Code with Terraform - access registry providers, modules, policies, and HCP Terraform workflow management`,displayName:`Deploy infrastructure with Terraform`,author:`HashiCorp`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/terraform.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/terraform`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`terraform`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},strands:{name:`strands`,description:`Build AI agents with Strands Agent SDK using Bedrock, Anthropic, OpenAI, Gemini, or Llama models`,displayName:`Build an agent with Strands`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/strands.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/strands`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`strands`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aws-agentcore":{name:`aws-agentcore`,description:`Amazon Bedrock AgentCore is an agentic platform for building, deploying, and operating effective agents.`,displayName:`Build an agent with Amazon Bedrock AgentCore`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/agentcore.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aws-agentcore`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aws-agentcore`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},neon:{name:`neon`,description:`Serverless Postgres with database branching, autoscaling, and scale-to-zero - perfect for modern development workflows`,displayName:`Build a database with Neon`,author:`Neon`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/neon.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/neon`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`neon`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},datadog:{name:`datadog`,description:`Query logs, metrics, traces, RUM events, incidents, and monitors from Datadog for production debugging and performance analysis`,displayName:`Datadog Observability`,author:`Datadog`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/datadog.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/datadog`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`datadog`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},dynatrace:{name:`dynatrace`,description:`Query logs, metrics, traces, problems, and Kubernetes events from Dynatrace using DQL for production debugging and performance analysis`,displayName:`Dynatrace Observability`,author:`Dynatrace`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/dynatrace.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/dynatrace`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`dynatrace`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},stripe:{name:`stripe`,description:`Build payment integrations with Stripe - accept payments, manage subscriptions, handle billing, and process refunds`,displayName:`Stripe Payments`,author:`Stripe`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/stripe.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/stripe`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`stripe`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aws-infrastructure-as-code":{name:`aws-infrastructure-as-code`,description:`Build well-architected AWS infrastructure with CDK using latest documentation, best practices, and code samples. Validate CloudFormation templates, check resource configuration security compliance, and troubleshoot deployments.`,displayName:`Build AWS infrastructure with CDK and CloudFormation`,author:`AWS`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/iac.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aws-infrastructure-as-code`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aws-infrastructure-as-code`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"power-builder":{name:`power-builder`,description:`Complete guide for building and testing new Kiro Powers with templates, best practices, and validation`,displayName:`Build a Power`,author:`Kiro Team`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/power-builder`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`power-builder`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"saas-builder":{name:`saas-builder`,description:`Build production ready multi-tenant SaaS applications with serverless architecture, integrated billing, and enterprise grade security`,displayName:`SaaS Builder`,author:`Allen Helton`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/saas-builder`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`saas-builder`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"cloud-architect":{name:`cloud-architect`,description:`Build AWS infrastructure with CDK in Python following AWS Well-Architected framework best practices`,displayName:`Build infrastructure on AWS`,author:`Christian Bonzelet`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/cloud-architect`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`cloud-architect`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}},"aurora-dsql":{name:`aurora-dsql`,description:`For PostgreSQL compatible serverless distributed SQL database with Aurora DSQL, manage schemas, execute queries, and handle migrations with DSQL-specific constraints`,displayName:`Deploy a distributed SQL database on AWS`,author:`Rolf Koski`,iconUrl:`https://prod.download.desktop.kiro.dev/powers/icons/power.png`,repositoryUrl:`https://github.com/kirodotdev/powers/tree/main/aurora-dsql`,license:``,repositoryCloneUrl:`git@github.com:kirodotdev/powers.git`,pathInRepo:`aurora-dsql`,repositoryBranch:`main`,installed:!1,keywords:[],source:{type:`registry`}}},repoSources:{},lastUpdated:`2025-12-28T20:19:10.824Z`,kiroRecommendedRepo:{url:`https://prod.download.desktop.kiro.dev/powers/default_registry.json`,lastFetch:`2025-12-28T20:19:10.823Z`,powerCount:18}})}catch{this.log.debug(`Failed to parse official registry, using empty registry`)}return this.createInitialRegistry()}unregisterLocalPowers(e){let t={...this.getOfficialRegistry(),lastUpdated:new Date().toISOString()};return this.log.trace({action:e===!0?`dryRun`:`reset`,type:`registry`,powerCount:Object.keys(t.powers).length}),this.write(t,e)}buildRepoSource(e){let t=new Date().toISOString();return{name:e.sourcePath??e.installPath??e.name,type:`local`,enabled:!0,addedAt:t,powerCount:1,...e.sourcePath!=null&&{path:e.sourcePath},lastSync:t}}};const ip=`GLOBAL.md`,ap=`.kiro`,$=`steering`,op=`settings`,sp=`mcp.json`,cp=`POWER.md`;var lp=class extends Jd{constructor(){super(`KiroCLIOutputPlugin`,{globalConfigDir:ap,outputFileName:ip}),this.registerCleanEffect(`registry-cleanup`,async e=>this.getRegistryWriter(rp).unregisterLocalPowers(e.dryRun)?{success:!0,description:`Reset registry to official state`}:{success:!1,error:Error(`Failed to clean registry`),description:`Failed to reset registry`}),this.registerCleanEffect(`mcp-settings-cleanup`,async e=>{let t=this.getGlobalSettingsDir(),n=this.joinPath(t,sp),r={mcpServers:{},powers:{mcpServers:{}}};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpSettingsCleanup`,path:n}),{success:!0,description:`Would reset mcp.json to empty shell`};try{return this.ensureDirectory(t),this.writeFileSync(n,JSON.stringify(r,null,2)),this.log.trace({action:`clean`,type:`mcpSettingsCleanup`,path:n}),{success:!0,description:`Reset mcp.json to empty shell`}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`clean`,type:`mcpSettingsCleanup`,path:n,error:t}),{success:!1,error:e,description:`Failed to reset mcp.json`}}})}getGlobalSettingsDir(){return this.joinPath(this.getHomeDir(),ap,op)}async registerProjectOutputDirs(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n){if(e.dirFromWorkspacePath==null)continue;let n=this.joinPath(e.dirFromWorkspacePath.path,ap,$);t.push({pathKind:N.Relative,path:n,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(e.dirFromWorkspacePath.basePath,n)})}return t}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace;for(let e of n)if(e.dirFromWorkspacePath!=null&&e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts){let r=this.buildSteeringFileName(n),i=this.joinPath(e.dirFromWorkspacePath.path,ap,$,r);t.push({pathKind:N.Relative,path:i,basePath:e.dirFromWorkspacePath.basePath,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(e.dirFromWorkspacePath.basePath,i)})}return t}async registerGlobalOutputDirs(){let e=this.getGlobalSteeringDir(),t=[{pathKind:N.Relative,path:$,basePath:this.joinPath(this.getGlobalConfigDir()),getDirectoryName:()=>$,getAbsolutePath:()=>e}],n=this.getKiroPowersDir(),r=this.listInstalledPowers(n);for(let e of r){let r=this.joinPath(n,e);t.push({pathKind:N.Relative,path:e,basePath:n,getDirectoryName:()=>e,getAbsolutePath:()=>r})}let i=this.getKiroPowersReposDir();return t.push({pathKind:N.Relative,path:`repos`,basePath:this.joinPath(this.getHomeDir(),`.kiro/powers`),getDirectoryName:()=>`repos`,getAbsolutePath:()=>i}),t}listInstalledPowers(e){try{return this.existsSync(e)?this.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name):[]}catch{return this.log.debug({action:`listInstalledPowers`,error:`Failed to read powers directory`}),[]}}async registerGlobalOutputFiles(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=this.getGlobalSteeringDir();if(t!=null&&i.push({pathKind:N.Relative,path:ip,basePath:a,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(a,ip)}),n!=null)for(let e of n){let t=this.buildFastCommandSteeringFileName(e);i.push({pathKind:N.Relative,path:t,basePath:a,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(a,t)})}if(r==null)return i;let o=this.getKiroPowersDir();for(let e of r){let t=e.yamlFrontMatter.name,n=this.joinPath(o,t);if(i.push({pathKind:N.Relative,path:cp,basePath:n,getDirectoryName:()=>t,getAbsolutePath:()=>this.joinPath(n,cp)}),e.mcpConfig!=null&&i.push({pathKind:N.Relative,path:sp,basePath:n,getDirectoryName:()=>t,getAbsolutePath:()=>this.joinPath(n,sp)}),e.childDocs!=null){let t=this.joinPath(n,$);for(let r of e.childDocs){let e=r.dir.path.replace(/\.mdx$/,`.md`);i.push({pathKind:N.Relative,path:this.joinPath($,e),basePath:n,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(t,e)})}}if(e.resources!=null){let t=this.joinPath(n,$);for(let r of e.resources)i.push({pathKind:N.Relative,path:this.joinPath($,r.relativePath),basePath:n,getDirectoryName:()=>$,getAbsolutePath:()=>this.joinPath(t,r.relativePath)})}}if(!r.some(e=>e.mcpConfig!=null))return i;let s=this.getGlobalSettingsDir();return i.push({pathKind:N.Relative,path:sp,basePath:s,getDirectoryName:()=>op,getAbsolutePath:()=>this.joinPath(s,sp)}),i}async canWrite(e){let{workspace:t,globalMemory:n,fastCommands:r,skills:i}=e.collectedInputContext,a=t.projects.some(e=>(e.childMemoryPrompts?.length??0)>0),o=n!=null,s=(r?.length??0)>0,c=(i?.length??0)>0;return a||o||s||c?!0:(this.log.trace({action:`skip`,reason:`noOutputs`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,n=[],r=[];for(let r of t)if(r.dirFromWorkspacePath!=null&&r.childMemoryPrompts!=null)for(let t of r.childMemoryPrompts){let i=await this.writeSteeringFile(e,r,t);n.push(i)}return{files:n,dirs:r}}async writeGlobalOutputs(e){let{globalMemory:t,fastCommands:n,skills:r}=e.collectedInputContext,i=[],a=[],o=[];if(t!=null){let n=this.getGlobalSteeringDir(),r=this.joinPath(n,ip),a={pathKind:N.Relative,path:ip,basePath:n,getDirectoryName:()=>$,getAbsolutePath:()=>r};if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`globalMemory`,path:r}),i.push({path:a,success:!0,skipped:!1});else try{this.ensureDirectory(n),this.writeFileSync(r,t.content),this.log.trace({action:`write`,type:`globalMemory`,path:r}),i.push({path:a,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`globalMemory`,path:r,error:t}),i.push({path:a,success:!1,error:e})}}if(n!=null)for(let t of n){let n=await this.writeFastCommandSteeringFile(e,t);i.push(n)}if(r==null||r.length===0)return{files:i,dirs:a};this.log.debug(`Processing ${r.length} skills as Kiro Powers`);for(let t of r){let{fileResults:n,registryResult:r}=await this.writeSkillAsPower(e,t);i.push(...n),o.push(r)}let s=await this.writeGlobalMcpSettings(e,r);return s!=null&&i.push(s),this.logRegistryResults(o,e.dryRun),{files:i,dirs:a}}async writeGlobalMcpSettings(e,t){let n={};for(let e of t){if(e.mcpConfig==null)continue;let t=e.yamlFrontMatter.name,{mcpServers:r}=e.mcpConfig;for(let[e,i]of Object.entries(r)){let r=`power-${t}-${e}`;n[r]=i}}if(Object.keys(n).length===0)return null;let r=this.getGlobalSettingsDir(),i=this.joinPath(r,sp),a={pathKind:N.Relative,path:sp,basePath:r,getDirectoryName:()=>op,getAbsolutePath:()=>i},o={mcpServers:{},powers:{mcpServers:n}},s=JSON.stringify(o,null,2);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`globalMcpSettings`,path:i,serverCount:Object.keys(n).length}),{path:a,success:!0,skipped:!1};try{return this.ensureDirectory(r),this.writeFileSync(i,s),this.log.trace({action:`write`,type:`globalMcpSettings`,path:i,serverCount:Object.keys(n).length}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`globalMcpSettings`,path:i,error:t}),{path:a,success:!1,error:e}}}logRegistryResults(e,t){let n=e.filter(e=>e.success).length,r=e.filter(e=>!e.success).length;if(n>0&&this.log.trace({action:t===!0?`dryRun`:`register`,type:`registrySummary`,successCount:n}),!(r<=0)){this.log.error({action:`register`,type:`registrySummary`,failCount:r});for(let t of e)if(!t.success){let e=t.error?.message??`Unknown error`;this.log.error({action:`register`,type:`registryEntry`,entryName:t.entryName,error:e})}}}getGlobalSteeringDir(){return this.joinPath(this.getGlobalConfigDir(),$)}getKiroPowersDir(){return this.joinPath(this.getHomeDir(),`.kiro/powers/installed`)}getKiroPowersReposDir(){return this.joinPath(this.getHomeDir(),`.kiro/powers/repos`)}buildPowerFrontMatter(e){return Gd({name:e.name,displayName:e.displayName,description:e.description,keywords:e.keywords,author:e.author},``).trimEnd()}async writeSkillAsPower(e,t){let n=[],r=t.yamlFrontMatter.name,i=this.joinPath(this.getKiroPowersDir(),r),a=this.joinPath(i,cp),o={pathKind:N.Relative,path:cp,basePath:i,getDirectoryName:()=>r,getAbsolutePath:()=>a},s=`${this.buildPowerFrontMatter(t.yamlFrontMatter)}\n${t.content}`;if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`skillPower`,path:a}),n.push({path:o,success:!0,skipped:!1});else try{this.ensureDirectory(i),this.writeFileSync(a,s),this.log.trace({action:`write`,type:`skillPower`,path:a}),n.push({path:o,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`skillPower`,path:a,error:t}),n.push({path:o,success:!1,error:e})}if(t.childDocs!=null){let r=this.joinPath(i,$);for(let a of t.childDocs){let t=a.dir.path.replace(/\.mdx$/,`.md`),o=this.joinPath(r,t),s={pathKind:N.Relative,path:this.joinPath($,t),basePath:i,getDirectoryName:()=>$,getAbsolutePath:()=>o},c=a.content;if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`refDoc`,path:o}),n.push({path:s,success:!0,skipped:!1});else try{let e=this.dirname(o);this.ensureDirectory(e),this.writeFileSync(o,c),this.log.trace({action:`write`,type:`refDoc`,path:o}),n.push({path:s,success:!0})}catch(e){let t=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`refDoc`,path:o,error:t}),n.push({path:s,success:!1,error:e})}}}if(t.resources!=null){let r=this.joinPath(i,$);for(let a of t.resources){let t=this.joinPath(r,a.relativePath),o={pathKind:N.Relative,path:this.joinPath($,a.relativePath),basePath:i,getDirectoryName:()=>$,getAbsolutePath:()=>t};if(e.dryRun===!0)this.log.trace({action:`dryRun`,type:`resource`,path:t}),n.push({path:o,success:!0,skipped:!1});else try{let e=this.dirname(t);this.ensureDirectory(e),this.writeFileSync(t,a.content),this.log.trace({action:`write`,type:`resource`,path:t}),n.push({path:o,success:!0})}catch(e){let r=e instanceof Error?e.message:String(e);this.log.error({action:`write`,type:`resource`,path:t,error:r}),n.push({path:o,success:!1,error:e})}}}if(t.mcpConfig!=null){let r=await this.writeSkillMcpConfig(e,t,i);n.push(r)}let c=this.getRegistryWriter(rp),l=c.buildPowerEntry(t,i);return{fileResults:n,registryResult:(await this.registerInRegistry(c,[l],e))[0]??{success:!1,entryName:r,error:Error(`No registry result returned`)}}}async writeSkillMcpConfig(e,t,n){let r=t.yamlFrontMatter.name,i=this.joinPath(n,sp),a={pathKind:N.Relative,path:sp,basePath:n,getDirectoryName:()=>r,getAbsolutePath:()=>i},o=t.mcpConfig.rawContent;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`mcpConfig`,path:i,skill:r}),{path:a,success:!0,skipped:!1};try{return this.ensureDirectory(n),this.writeFileSync(i,o),this.log.trace({action:`write`,type:`mcpConfig`,path:i,skill:r}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`mcpConfig`,path:i,error:t}),{path:a,success:!1,error:e}}}buildFastCommandSteeringFileName(e){return this.transformFastCommandName(e,{includeSeriesPrefix:!0,seriesSeparator:`-`})}buildFastCommandSteeringContent(e){let t=e.yamlFrontMatter?.description;return Gd({inclusion:`manual`,description:t!=null&&t.length>0?t:null},e.content)}async writeFastCommandSteeringFile(e,t){let n=this.getGlobalSteeringDir(),r=this.buildFastCommandSteeringFileName(t),i=this.joinPath(n,r),a={pathKind:N.Relative,path:r,basePath:n,getDirectoryName:()=>$,getAbsolutePath:()=>i},o=this.buildFastCommandSteeringContent(t);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`fastCommandSteering`,path:i}),{path:a,success:!0,skipped:!1};try{return this.ensureDirectory(n),this.writeFileSync(i,o),this.log.trace({action:`write`,type:`fastCommandSteering`,path:i}),{path:a,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`fastCommandSteering`,path:i,error:t}),{path:a,success:!1,error:e}}}buildSteeringFileName(e){return`kiro-${(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`)}.md`}buildSteeringContent(e){return Gd({inclusion:`fileMatch`,fileMatchPattern:`${(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`)}/**`},e.content)}async writeSteeringFile(e,t,n){let r=t.dirFromWorkspacePath,i=this.buildSteeringFileName(n),a=this.joinPath(r.basePath,r.path,ap,$),o=this.joinPath(a,i),s={pathKind:N.Relative,path:this.joinPath(r.path,ap,$,i),basePath:r.basePath,getDirectoryName:()=>$,getAbsolutePath:()=>o},c=this.buildSteeringContent(n);if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`steeringFile`,path:o}),{path:s,success:!0,skipped:!1};try{return this.ensureDirectory(a),this.writeFileSync(o,c),this.log.trace({action:`write`,type:`steeringFile`,path:o}),{path:s,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`steeringFile`,path:o,error:t}),{path:s,success:!1,error:e}}}};const up=`agt.mdx`;var dp=class extends X{constructor(){super(`ProjectPromptInputPlugin`,[`ShadowProjectInputPlugin`])}async collect(e){let{dependencyContext:t,fs:n,userConfigOptions:r,path:i,globalScope:a}=e,{workspaceDir:o,shadowProjectDir:s}=this.resolveBasePaths(r),c=r.shadowProjectsDir,l=this.resolvePath(c,o,s),u=t.workspace;if(u==null)return this.log.warn(`No workspace found in dependency context, skipping project prompt enhancement`),{};let d=u.projects??[],f=await Promise.all(d.map(async t=>{let r=t.name;if(r==null)return t;let o=i.join(l,r);if(!n.existsSync(o)||!n.statSync(o).isDirectory())return t;let s=t.dirFromWorkspacePath?.getAbsolutePath(),c=await this.readRootMemoryPrompt(e,o,a),u=s==null?[]:await this.scanChildMemoryPrompts(e,o,s,a);return{...t,...c!=null&&{rootMemoryPrompt:c},...u.length>0&&{childMemoryPrompts:u}}}));return{workspace:{directory:u.directory,projects:f}}}async readRootMemoryPrompt(e,t,n){let{fs:r,path:i,logger:a}=e,o=i.join(t,up);if(!(!r.existsSync(o)||!r.statSync(o).isFile()))try{let e=r.readFileSync(o,`utf8`),i=Kd(e),s;try{s=await xf(e,{globalScope:n,basePath:t})}catch(e){throw e instanceof d&&(a.error(`MDX compilation failed in ${o}: ${e.message}`),a.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),m.exit(1)),e}return{type:Ot.ProjectRootMemory,content:s,length:s.length,filePathKind:N.Relative,...i.yamlFrontMatter!=null&&{yamlFrontMatter:i.yamlFrontMatter},...i.rawFrontMatter!=null&&{rawFrontMatter:i.rawFrontMatter},markdownAst:i.markdownAst,markdownContents:i.markdownContents,dir:{pathKind:N.Root,path:``,getDirectoryName:()=>``}}}catch(e){a.error(`Failed to read root memory prompt at ${o}`,{error:e});return}}async scanChildMemoryPrompts(e,t,n,r){let{logger:i}=e,a=[];try{await this.scanDirectoryRecursive(e,t,t,n,a,r)}catch(e){i.error(`Failed to scan child memory prompts at ${t}`,{error:e})}return a}async scanDirectoryRecursive(e,t,n,r,i,a){let{fs:o,path:s}=e,c=o.readdirSync(n,{withFileTypes:!0});for(let l of c){if(!l.isDirectory()||l.name.startsWith(`.`)||l.name===`node_modules`)continue;let c=s.join(n,l.name),u=s.join(c,up);if(o.existsSync(u)&&o.statSync(u).isFile()){let n=await this.readChildMemoryPrompt(e,t,c,r,a);n!=null&&i.push(n)}await this.scanDirectoryRecursive(e,t,c,r,i,a)}}async readChildMemoryPrompt(e,t,n,r,i){let{fs:a,path:o,logger:s}=e,c=o.join(n,up);try{let e=a.readFileSync(c,`utf8`),l=Kd(e),u;try{u=await xf(e,{globalScope:i,basePath:n})}catch(e){throw e instanceof d&&(s.error(`MDX compilation failed in ${c}: ${e.message}`),s.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),m.exit(1)),e}let f=o.relative(t,n),p=o.join(r,f),h=o.basename(n);return{type:Ot.ProjectChildrenMemory,content:u,length:u.length,filePathKind:N.Relative,...l.yamlFrontMatter!=null&&{yamlFrontMatter:l.yamlFrontMatter},...l.rawFrontMatter!=null&&{rawFrontMatter:l.rawFrontMatter},markdownAst:l.markdownAst,markdownContents:l.markdownContents,dir:{pathKind:N.Relative,path:f,basePath:r,getDirectoryName:()=>h,getAbsolutePath:()=>p},workingChildDirectoryPath:{pathKind:N.Relative,path:f,basePath:r,getDirectoryName:()=>h,getAbsolutePath:()=>p}}}catch(e){s.error(`Failed to read child memory prompt at ${c}`,{error:e});return}}};const fp=`README.md`;var pp=class extends Jd{constructor(){super(`ReadmeMdConfigFileOutputPlugin`,{outputFileName:fp})}async registerProjectOutputFiles(e){let t=[],{readmePrompts:n}=e.collectedInputContext;if(n==null||n.length===0)return t;for(let e of n){let{targetDir:n}=e,r=g.join(n.path,fp);t.push({pathKind:N.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>n.getDirectoryName(),getAbsolutePath:()=>g.join(n.basePath,r)})}return t}async canWrite(e){let{readmePrompts:t}=e.collectedInputContext;return t?.length===0?(this.log.debug(`skipped`,{reason:`no README prompts to write`}),!1):!0}async writeProjectOutputs(e){let t=[],n=[],{readmePrompts:r}=e.collectedInputContext;if(r==null||r.length===0)return{files:t,dirs:n};for(let n of r){let r=await this.writeReadmeFile(e,n);t.push(r)}return{files:t,dirs:n}}async writeReadmeFile(e,t){let{targetDir:n}=t,r=g.join(n.path,fp),i=g.join(n.basePath,r),a=t.content,o={pathKind:N.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>n.getDirectoryName(),getAbsolutePath:()=>i},s=t.isRoot?`project:${t.projectName}/README.md`:`project:${t.projectName}/${n.path}/README.md`;if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`readme`,path:i,label:s}),{path:o,success:!0,skipped:!1};try{let e=g.dirname(i);return h.existsSync(e)||h.mkdirSync(e,{recursive:!0}),h.writeFileSync(i,a,`utf8`),this.log.trace({action:`write`,type:`readme`,path:i,label:s}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`readme`,path:i,label:s,error:t}),{path:o,success:!1,error:e}}}},mp=class extends X{constructor(){super(`ReadmeMdInputPlugin`,[`ShadowProjectInputPlugin`])}async collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i,globalScope:a}=e,{workspaceDir:o,shadowProjectDir:s}=this.resolveBasePaths(t),c=t.shadowProjectsDir,l=this.resolvePath(c,o,s),u=[];if(!r.existsSync(l)||!r.statSync(l).isDirectory())return n.debug(`shadow projects directory does not exist`,{path:l}),{readmePrompts:u};try{let t=r.readdirSync(l,{withFileTypes:!0});for(let n of t){if(!n.isDirectory())continue;let t=n.name,r=i.join(l,t);await this.collectReadmeFiles(e,r,t,o,``,u,a)}}catch(e){n.error(`failed to scan shadow projects`,{path:l,error:e})}return{readmePrompts:u}}async collectReadmeFiles(e,t,n,r,i,a,o){let{fs:s,path:c,logger:l}=e,u=i===``,f=c.join(t,`readme.mdx`);if(s.existsSync(f)&&s.statSync(f).isFile())try{let e=s.readFileSync(f,`utf8`),p;if(o!=null)try{p=await xf(e,{globalScope:o,basePath:t})}catch(e){throw e instanceof d&&(l.error(`MDX compilation failed in ${f}: ${e.message}`),l.error(`Please check your configuration file (~/.aindex/.tnmsc.json) and ensure all required variables are defined.`),m.exit(1)),e}else p=e;let h=u?n:c.join(n,i),g={pathKind:N.Relative,path:h,basePath:r,getDirectoryName:()=>u?n:c.basename(i),getAbsolutePath:()=>c.resolve(r,h)},_={pathKind:N.Relative,path:c.dirname(f),basePath:r,getDirectoryName:()=>c.basename(c.dirname(f)),getAbsolutePath:()=>c.dirname(f)};a.push({type:Ot.Readme,content:p,length:p.length,filePathKind:N.Relative,projectName:n,targetDir:g,isRoot:u,markdownContents:[],dir:_})}catch(e){l.warn(`failed to read readme`,{path:f,error:e})}try{let l=s.readdirSync(t,{withFileTypes:!0});for(let s of l)if(s.isDirectory()){let l=u?s.name:c.join(i,s.name),d=c.join(t,s.name);await this.collectReadmeFiles(e,d,n,r,l,a,o)}}catch(e){l.warn(`failed to scan directory`,{path:t,error:e})}}},hp=class extends X{constructor(){super(`ShadowProjectInputPlugin`)}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(t),s=t.shadowProjectsDir,c=this.resolvePath(s,a,o),l=i.basename(o),u=[];if(r.existsSync(c)&&r.statSync(c).isDirectory())try{let e=r.readdirSync(c,{withFileTypes:!0});for(let t of e)if(t.isDirectory()){let e=t.name===l;u.push({name:t.name,...e&&{isPromptSourceProject:!0},dirFromWorkspacePath:{pathKind:N.Relative,path:t.name,basePath:a,getDirectoryName:()=>t.name,getAbsolutePath:()=>i.resolve(a,t.name)}})}}catch(e){n.error(`failed to scan shadow projects`,{path:c,error:e})}if(u.length===0&&r.existsSync(a)&&r.statSync(a).isDirectory()){n.debug(`no projects in dist/app/, falling back to workspace scan`,{workspaceDir:a});try{let e=r.readdirSync(a,{withFileTypes:!0});for(let t of e)if(t.isDirectory()&&!t.name.startsWith(`.`)){let e=t.name===l;u.push({name:t.name,...e&&{isPromptSourceProject:!0},dirFromWorkspacePath:{pathKind:N.Relative,path:t.name,basePath:a,getDirectoryName:()=>t.name,getAbsolutePath:()=>i.resolve(a,t.name)}})}}catch(e){n.error(`failed to scan workspace directory`,{path:a,error:e})}}return{workspace:{directory:{pathKind:N.Absolute,path:a,getDirectoryName:()=>i.basename(a)},projects:u}}}};function gp(e){return e.replaceAll(/(!?\[)([^\]]*)(\]\()([^)]+)(\))/g,(e,t,n,r,i,a)=>{let o=n.replaceAll(/\.mdx$/g,`.md`).replaceAll(/\.mdx(?=#|\?|$)/g,`.md`);return/^(?:https?:)?\/\//.test(i)?`${t}${o}${r}${i}${a}`:`${t}${o}${r}${i.replace(/\.mdx$/,`.md`).replace(/\.mdx#/,`.md#`).replace(/\.mdx\?/,`.md?`)}${a}`})}var _p=class extends X{constructor(){super(`SkillInputPlugin`)}readMcpConfig(e,t,n){let r=g.join(e,`mcp.json`);if(t.existsSync(r)){if(!t.statSync(r).isFile()){n.warn(`mcp.json is not a file`,{skillDir:e});return}try{let i=t.readFileSync(r,`utf8`),a=JSON.parse(i);if(a.mcpServers==null||typeof a.mcpServers!=`object`){n.warn(`mcp.json missing mcpServers field`,{skillDir:e});return}return{type:Ot.SkillMcpConfig,mcpServers:a.mcpServers,rawContent:i}}catch(t){n.warn(`failed to parse mcp.json`,{skillDir:e,error:t});return}}}isBinaryResourceExtension(e){return zt.includes(e.toLowerCase())}getResourceCategory(e){let t=e.toLowerCase();return[`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.ico`,`.bmp`,`.tiff`,`.svg`].includes(t)?`image`:`.kt,.java,.py,.pyi,.pyx,.ts,.tsx,.js,.jsx,.mjs,.cjs,.go,.rs,.c,.cpp,.cc,.h,.hpp,.hxx,.cs,.fs,.fsx,.vb,.rb,.php,.swift,.scala,.groovy,.lua,.r,.jl,.ex,.exs,.erl,.clj,.cljs,.hs,.ml,.mli,.nim,.zig,.v,.dart,.vue,.svelte,.d.ts,.d.mts,.d.cts`.split(`,`).includes(t)?`code`:[`.sql`,`.json`,`.jsonc`,`.json5`,`.xml`,`.xsd`,`.xsl`,`.xslt`,`.yaml`,`.yml`,`.toml`,`.csv`,`.tsv`,`.graphql`,`.gql`,`.proto`].includes(t)?`data`:[`.txt`,`.text`,`.rtf`,`.log`,`.docx`,`.doc`,`.xlsx`,`.xls`,`.pptx`,`.ppt`,`.pdf`,`.odt`,`.ods`,`.odp`].includes(t)?`document`:[`.ini`,`.conf`,`.cfg`,`.config`,`.properties`,`.env`,`.envrc`,`.editorconfig`,`.gitignore`,`.gitattributes`,`.npmrc`,`.nvmrc`,`.npmignore`,`.eslintrc`,`.prettierrc`,`.stylelintrc`,`.babelrc`,`.browserslistrc`].includes(t)?`config`:[`.sh`,`.bash`,`.zsh`,`.fish`,`.ps1`,`.psm1`,`.psd1`,`.bat`,`.cmd`].includes(t)?`script`:`.exe,.dll,.so,.dylib,.bin,.wasm,.class,.jar,.war,.pyd,.pyc,.pyo,.zip,.tar,.gz,.bz2,.7z,.rar,.ttf,.otf,.woff,.woff2,.eot,.db,.sqlite,.sqlite3`.split(`,`).includes(t)?`binary`:`other`}getMimeType(e){return{".ts":`text/typescript`,".tsx":`text/typescript`,".js":`text/javascript`,".jsx":`text/javascript`,".json":`application/json`,".py":`text/x-python`,".java":`text/x-java`,".kt":`text/x-kotlin`,".go":`text/x-go`,".rs":`text/x-rust`,".c":`text/x-c`,".cpp":`text/x-c++`,".cs":`text/x-csharp`,".rb":`text/x-ruby`,".php":`text/x-php`,".swift":`text/x-swift`,".scala":`text/x-scala`,".sql":`application/sql`,".xml":`application/xml`,".yaml":`text/yaml`,".yml":`text/yaml`,".toml":`text/toml`,".csv":`text/csv`,".graphql":`application/graphql`,".txt":`text/plain`,".pdf":`application/pdf`,".docx":`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,".xlsx":`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,".html":`text/html`,".css":`text/css`,".svg":`image/svg+xml`,".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".webp":`image/webp`,".ico":`image/x-icon`,".bmp":`image/bmp`}[e.toLowerCase()]}scanSkillDirectory(e,t,n,r=``){let i=[],a=[],o=r?g.join(e,r):e;try{let s=t.readdirSync(o,{withFileTypes:!0});for(let c of s){let s=r?`${r}/${c.name}`:c.name;if(c.isDirectory()){let r=this.scanSkillDirectory(e,t,n,s);i.push(...r.childDocs),a.push(...r.resources)}else if(c.isFile()){let l=g.join(o,c.name);if(c.name.endsWith(`.mdx`)){if(r===``&&c.name===`skill.mdx`)continue;try{let n=Kd(t.readFileSync(l,`utf8`)),r=gp(n.contentWithoutFrontMatter);i.push({type:Ot.SkillChildDoc,content:r,length:r.length,filePathKind:N.Relative,markdownAst:n.markdownAst,markdownContents:n.markdownContents,...n.rawFrontMatter!=null&&{rawFrontMatter:n.rawFrontMatter},relativePath:s,dir:{pathKind:N.Relative,path:s,basePath:e,getDirectoryName:()=>g.dirname(s),getAbsolutePath:()=>l}})}catch(e){n.warn(`failed to read child doc`,{path:s,error:e})}}else{if(r===``&&c.name===`mcp.json`)continue;let e=g.extname(c.name),i,o,u;try{if(this.isBinaryResourceExtension(e)){let e=t.readFileSync(l);i=e.toString(`base64`),o=`base64`,{length:u}=e}else i=t.readFileSync(l,`utf8`),o=`text`,{length:u}=w.from(i,`utf8`);let n=this.getMimeType(e),r={type:Ot.SkillResource,extension:e,fileName:c.name,relativePath:s,content:i,encoding:o,category:this.getResourceCategory(e),length:u};n==null?a.push(r):a.push({...r,mimeType:n})}catch(e){n.warn(`failed to read resource file`,{path:s,error:e})}}}}}catch(e){n.warn(`failed to scan directory`,{path:o,error:e})}return{childDocs:i,resources:a}}async collect(e){let{userConfigOptions:n,logger:r,globalScope:i}=e,{workspaceDir:a,shadowProjectDir:o}=this.resolveBasePaths(n),s=n.shadowSkillSourceDir,c=this.resolvePath(s,a,o),l=[];if(!(e.fs.existsSync(c)&&e.fs.statSync(c).isDirectory()))return{skills:l};let u=e.fs.readdirSync(c,{withFileTypes:!0});for(let n of u)if(n.isDirectory()){let a=e.path.join(c,n.name,`skill.mdx`);if(e.fs.existsSync(a)&&e.fs.statSync(a).isFile())try{let o=e.fs.readFileSync(a,`utf8`),s=Kd(o),u=await xf(o,{globalScope:i,extractMetadata:!0,basePath:e.path.join(c,n.name)}),d={...s.yamlFrontMatter,...u.metadata.fields},f=Pt(d,a);for(let e of f.warnings)r.debug(e);if(!f.valid)throw new t(f.errors,a);let p=gp(u.content),m=e.path.join(c,n.name),h=this.readMcpConfig(m,e.fs,r),{childDocs:_,resources:v}=this.scanSkillDirectory(m,e.fs,r);r.debug(`skill metadata extracted`,{skill:n.name,source:u.metadata.source,hasYaml:s.yamlFrontMatter!=null,hasExport:Object.keys(u.metadata.fields).length>0}),l.push({type:Ot.Skill,content:p,length:p.length,filePathKind:N.Relative,yamlFrontMatter:d.name==null?{name:n.name,description:``}:d,...s.rawFrontMatter!=null&&{rawFrontMatter:s.rawFrontMatter},markdownAst:s.markdownAst,markdownContents:s.markdownContents,...h!=null&&{mcpConfig:h},..._.length>0&&{childDocs:_},...v.length>0&&{resources:v},dir:{pathKind:N.Relative,path:n.name,basePath:c,getDirectoryName:()=>n.name,getAbsolutePath:()=>g.join(c,n.name)}})}catch(e){r.error(`failed to parse skill`,{file:a,error:e})}}return{skills:l}}},vp=class extends X{constructor(){super(`SubAgentInputPlugin`)}async collect(e){let{userConfigOptions:n,logger:r,fs:i,path:a,globalScope:o}=e,{workspaceDir:s,shadowProjectDir:c}=this.resolveBasePaths(n),l=n.shadowSubAgentDir,u=this.resolvePath(l,s,c),d=[];if(i.existsSync(u)&&i.statSync(u).isDirectory())try{let e=i.readdirSync(u,{withFileTypes:!0});for(let n of e)if(n.isFile()&&n.name.endsWith(`.mdx`)){let e=a.join(u,n.name),s=i.readFileSync(e,`utf8`),c=Kd(s),l=await xf(s,{globalScope:o,extractMetadata:!0,basePath:u}),f=c.yamlFrontMatter!=null||Object.keys(l.metadata.fields).length>0?{...c.yamlFrontMatter,...l.metadata.fields}:void 0;if(f!=null){let n=It(f,e);for(let e of n.warnings)r.debug(e);if(!n.valid)throw new t(n.errors,e)}let{content:p}=l;r.debug(`sub agent metadata extracted`,{agent:n.name,source:l.metadata.source,hasYaml:c.yamlFrontMatter!=null,hasExport:Object.keys(l.metadata.fields).length>0}),d.push({type:Ot.SubAgent,content:p,length:p.length,filePathKind:N.Relative,...f!=null&&{yamlFrontMatter:f},...c.rawFrontMatter!=null&&{rawFrontMatter:c.rawFrontMatter},markdownAst:c.markdownAst,markdownContents:c.markdownContents,dir:{pathKind:N.Relative,path:n.name,basePath:u,getDirectoryName:()=>n.name.replace(/\.mdx$/,``),getAbsolutePath:()=>e}})}}catch(e){r.error(`Failed to scan sub agents at ${u}`,{error:e})}return{subAgents:d}}};const yp=`WARP.md`;var bp=class extends Jd{constructor(){super(`WarpIDEOutputPlugin`,{outputFileName:yp})}isAgentsPluginRegistered(e){return`registeredPluginNames`in e&&e.registeredPluginNames!=null?e.registeredPluginNames.includes(`AgentsOutputPlugin`):!1}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,r=this.isAgentsPluginRegistered(e);for(let e of n)if(e.dirFromWorkspacePath!=null){if(r)t.push(this.createFileRelativePath(e.dirFromWorkspacePath,yp));else if(e.rootMemoryPrompt!=null&&t.push(this.createFileRelativePath(e.dirFromWorkspacePath,yp)),e.childMemoryPrompts!=null)for(let n of e.childMemoryPrompts)n.dir!=null&&this.isRelativePath(n.dir)&&t.push(this.createFileRelativePath(n.dir,yp))}return t}async canWrite(e){let t=this.isAgentsPluginRegistered(e),{workspace:n,globalMemory:r}=e.collectedInputContext;return t?r==null?(this.log.debug(`skipped`,{reason:`AgentsOutputPlugin registered but no global memory`}),!1):!0:n.projects.some(e=>e.rootMemoryPrompt!=null||(e.childMemoryPrompts?.length??0)>0)?!0:(this.log.debug(`skipped`,{reason:`no outputs to write`}),!1)}async writeProjectOutputs(e){let t=this.isAgentsPluginRegistered(e),{workspace:n,globalMemory:r}=e.collectedInputContext,{projects:i}=n,a=[],o=[];if(t){if(r==null)return{files:[],dirs:[]};for(let t of i){let n=t.dirFromWorkspacePath;if(n==null)continue;let i=t.name??`unknown`,o=await this.writePromptFile(e,n,r.content,`project:${i}/global-warp`);a.push(o)}return{files:a,dirs:o}}let s=this.extractGlobalMemoryContent(e);for(let t of i){let n=t.name??`unknown`,r=t.dirFromWorkspacePath;if(r!=null){if(t.rootMemoryPrompt!=null){let i=this.combineGlobalWithContent(s,t.rootMemoryPrompt.content),o=await this.writePromptFile(e,r,i,`project:${n}/root`);a.push(o)}if(t.childMemoryPrompts!=null)for(let r of t.childMemoryPrompts){let t=await this.writePromptFile(e,r.dir,r.content,`project:${n}/child:${r.workingChildDirectoryPath?.path??`unknown`}`);a.push(t)}}}return{files:a,dirs:o}}},xp=class extends X{constructor(){super(`WorkspaceInputPlugin`)}collect(e){let{userConfigOptions:t}=e,{workspaceDir:n,shadowProjectDir:r}=this.resolveBasePaths(t),i=t.externalProjects.map(e=>{let t=this.resolvePath(e,n,r);return{name:g.basename(t),dirFromWorkspacePath:{pathKind:N.Relative,path:t,basePath:n,getDirectoryName:()=>g.basename(t)}}});return{workspace:{directory:{pathKind:N.Absolute,path:n,getDirectoryName:()=>g.basename(n)},projects:[]},shadowSourceProjectDir:r,...i.length>0&&{externalProjects:i}}}};const Sp=`.vscode`,Cp=[`.vscode/settings.json`,`.vscode/extensions.json`];var wp=class extends Jd{constructor(){super(`VisualStudioCodeIDEConfigOutputPlugin`)}async registerProjectOutputFiles(e){let t=[],{projects:n}=e.collectedInputContext.workspace,{ideConfigFiles:r}=e.collectedInputContext;if(!r.some(e=>e.type===P.VSCode))return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null&&e.isPromptSourceProject!==!0)for(let e of Cp){let r=this.joinPath(n.path,e);t.push({pathKind:N.Relative,path:r,basePath:n.basePath,getDirectoryName:()=>this.dirname(e),getAbsolutePath:()=>this.resolvePath(n.basePath,r)})}}return t}async canWrite(e){let{ideConfigFiles:t}=e.collectedInputContext;return t.some(e=>e.type===P.VSCode)?!0:(this.log.debug(`skipped`,{reason:`no VS Code config files found`}),!1)}async writeProjectOutputs(e){let{projects:t}=e.collectedInputContext.workspace,{ideConfigFiles:n}=e.collectedInputContext,r=[],i=[],a=n.filter(e=>e.type===P.VSCode);for(let n of t){let t=n.dirFromWorkspacePath;if(t==null)continue;let i=n.name??`unknown`;for(let n of a){let a=await this.writeConfigFile(e,t,n,`project:${i}`);r.push(a)}}return{files:r,dirs:i}}async writeConfigFile(e,t,n,r){let i=this.getTargetRelativePath(n),a=this.resolvePath(t.basePath,t.path,i),o={pathKind:N.Relative,path:this.joinPath(t.path,i),basePath:t.basePath,getDirectoryName:()=>this.dirname(i),getAbsolutePath:()=>a};if(e.dryRun===!0)return this.log.trace({action:`dryRun`,type:`config`,path:a,label:r}),{path:o,success:!0,skipped:!1};try{let e=this.dirname(a);return this.ensureDirectory(e),this.writeFileSync(a,n.content),this.log.trace({action:`write`,type:`config`,path:a,label:r}),{path:o,success:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return this.log.error({action:`write`,type:`config`,path:a,label:r,error:t}),{path:o,success:!1,error:e}}}getTargetRelativePath(e){let t=e.dir.path;if(e.type!==P.VSCode)return this.basename(t);let n=t.indexOf(Sp);return n===-1?this.joinPath(Sp,this.basename(t)):t.slice(Math.max(0,n))}},Tp=Tr({plugins:[new Xd,new ef,new Df,new Nf,new zf,new Uf,new qf,new lp,new bp,new Qf,new wp,new pp,new np,new ep,new $f,new xp,new hp,new Qd,new Yf,new _p,new Bf,new vp,new Jf,new dp,new mp]});async function Ep(){let e=await Tp;await new _r(...m.argv).run(e)}Ep().catch(e=>{console.error(e)});export{e as CircularDependencyError,kt as ClaudeCodeCLISubAgentColors,At as CodingAgentTools,Vn as ConfigLoader,s as ConfigValidationError,In as DEFAULT_CONFIG_FILE_NAME,Ln as DEFAULT_GLOBAL_CONFIG_DIR,Bt as DEFAULT_SHADOW_SOURCE_PROJECT_STRUCTURE,Yt as DEFAULT_USER_CONFIG,l as ExportParseError,N as FilePathKind,Mt as GlobalConfigDirectoryType,P as IDEKind,t as MetadataValidationError,a as MissingDependencyError,jt as NamingCaseKind,Jt as PathPlaceholders,Dt as PluginKind,Ot as PromptKind,F as SHADOW_SOURCE_DIR_NAMES,I as SHADOW_SOURCE_FILE_NAMES,L as SHADOW_SOURCE_RELATIVE_PATHS,zt as SKILL_RESOURCE_BINARY_EXTENSIONS,Rt as SKILL_RESOURCE_TEXT_EXTENSIONS,d as ScopeError,n as UndefinedNamespaceError,r as UndefinedVariableError,Lt as applyMetadataDefaults,vt as checkCanClean,bt as checkCanWrite,Xt as checkVersionControl,_t as collectAllPluginOutputs,Fn as createLogger,Tp as default,Tr as defineConfig,yt as executeOnCleanComplete,xt as executeWriteOutputs,nn as generateShadowSourceProject,Un as getConfigLoader,zn as getDefaultUserConfig,Rn as getGlobalConfigPath,Dn as getGlobalLogLevel,Wn as loadUserConfig,br as mergeConfig,En as setGlobalLogLevel,Gn as validateAndEnsureGlobalConfig,Nt as validateExportMetadata,Ft as validateFastCommandMetadata,Zt as validateShadowSourceProject,Pt as validateSkillMetadata,It as validateSubAgentMetadata};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class extends Error{constructor(e){super(`Circular dependency detected: ${e.join(` -> `)}`),this.cycle=e,this.name=`CircularDependencyError`}},t=class extends Error{constructor(e,t){super(`Plugin "${e}" depends on non-existent plugin "${t}"`),this.pluginName=e,this.missingDependency=t,this.name=`MissingDependencyError`}},n=class extends Error{constructor(e,t,n){super(e),this.expression=t,this.filePath=n,this.name=`ScopeError`}},r=class extends n{constructor(e,t,n){let r=n!=null&&n.length>0?`Undefined variable "${e}" in expression "${t}" (file: ${n})`:`Undefined variable "${e}" in expression "${t}"`;super(r,t,n),this.variableName=e,this.name=`UndefinedVariableError`}},i=class extends n{constructor(e,t,n){let r=n!=null&&n.length>0?`Undefined namespace "${e}" in expression "${t}" (file: ${n})`:`Undefined namespace "${e}" in expression "${t}"`;super(r,t,n),this.namespace=e,this.name=`UndefinedNamespaceError`}},a=class extends Error{constructor(e,t,n){let r=n!=null&&n.length>0,i=t!=null&&t.length>0,a=r?`${e} (export: ${t}, file: ${n})`:i?`${e} (export: ${t})`:e;super(a),this.exportName=t,this.filePath=n,this.name=`ExportParseError`}},o=class extends Error{constructor(e,t){let n=t!=null&&t.length>0?`Missing required metadata fields: ${e.join(`, `)} (file: ${t})`:`Missing required metadata fields: ${e.join(`, `)}`;super(n),this.missingFields=e,this.filePath=t,this.name=`MetadataValidationError`}},s=class extends Error{constructor(e,t,n){let r=n!=null&&n.length>0?`Invalid configuration field "${e}": ${t} (file: ${n})`:`Invalid configuration field "${e}": ${t}`;super(r),this.field=e,this.reason=t,this.filePath=n,this.name=`ConfigValidationError`}};const c=new Map;function l(e,t){c.set(e,t)}function u(){return new Map(c)}function d(e){return c.has(e)}function f(e,t,n){let r=e.trim();return r===``?``:/^[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*$/i.test(r)?p(r,t,n?.filePath):m(r,t,n?.filePath)}function p(e,t,n){let a=e.split(`.`),o=a[0];if(o==null||!(o in t))throw new i(o??``,e,n);let s=t[o];for(let t=1;t<a.length;t++){let i=a[t];if(i==null)continue;if(s==null)throw new r(i,e,n);if(typeof s!=`object`)throw TypeError(`Cannot read property "${i}" of ${typeof s} in expression "${e}"`);let o=s;if(!(i in o))throw new r(i,e,n);s=o[i]}return h(s)}function m(e,t,n){let r=Object.keys(t),a=r.map(e=>t[e]);try{return h(Function(...r,`return (${e})`)(...a))}catch(t){let r=t instanceof Error?t.message:String(t);if(r.includes(`is not defined`)){let t=/(\w+) is not defined/.exec(r);if(t?.[1]!=null)throw new i(t[1],e,n)}let a=n==null?``:` (file: ${n})`;throw Error(`Failed to evaluate expression: "${e}"${a}\nCause: ${r}`)}}function h(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 g(e,t){return e===null?!1:t.components.has(e)||d(e)}async function _(e){return async(t,n)=>(await e({type:`root`,children:t},n)).children}async function v(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 _(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 y(e,t){let n=e.name?.toLowerCase();if(n==null)return null;switch(n){case`pre`:return S(e,t);case`a`:return C(e,t);case`strong`:case`b`:return w(e,t);case`em`:case`i`:return T(e,t);case`img`:return E(e,t);case`blockquote`:return D(e,t);default:return null}}function b(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`?f(r.value.value,n.scope):r.value===null?``:null}function x(e,t){let n=``;for(let r of e.children)r.type===`text`?n+=r.value:r.type===`mdxTextExpression`?n+=f(r.value,t.scope):(r.type===`mdxJsxFlowElement`||r.type===`mdxJsxTextElement`)&&(n+=x(r,t));return n}function S(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=b(n,`className`,t)??``,i=/language-(\w+)/.exec(r)?.[1],a=x(n,t);return[{type:`code`,lang:i??null,value:a.trim()}]}function C(e,t){let n=b(e,`href`,t);if(n==null||n===``)return null;let r=x(e,t);return[{type:`paragraph`,children:[{type:`link`,url:n,title:b(e,`title`,t)??null,children:[{type:`text`,value:r}]}]}]}function w(e,t){let n={type:`strong`,children:[{type:`text`,value:x(e,t)}]};return e.type,[{type:`paragraph`,children:[n]}]}function T(e,t){let n={type:`emphasis`,children:[{type:`text`,value:x(e,t)}]};return e.type,[{type:`paragraph`,children:[n]}]}function E(e,t){let n=b(e,`src`,t);if(n==null||n===``)return null;let r={type:`image`,url:n,alt:b(e,`alt`,t)??``,title:b(e,`title`,t)??null};return e.type,[{type:`paragraph`,children:[r]}]}function D(e,t){return[{type:`blockquote`,children:[{type:`paragraph`,children:[{type:`text`,value:x(e,t)}]}]}]}function O(e){return e==null?!1:JSON.stringify(e).includes(`"JSX`)}async function k(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`?A(i.expression,t,n):[]}async function A(e,t,n){return e.type===`JSXElement`?I(e,t,n):e.type===`JSXFragment`?L(e,t,n):e.type===`LogicalExpression`?j(e,t,n):e.type===`ConditionalExpression`?M(e,t,n):e.type===`SequenceExpression`?N(e,t,n):e.type===`ArrayExpression`?P(e,t,n):K(e,t)}async function j(e,t,n){let r=await F(e.left,t,n);return e.operator===`&&`?W(r)?A(e.right,t,n):[]:e.operator===`||`?W(r)?U(e.left)?A(e.left,t,n):G(r):A(e.right,t,n):e.operator===`??`?r==null?A(e.right,t,n):U(e.left)?A(e.left,t,n):G(r):[]}async function M(e,t,n){return W(await F(e.test,t,n))?A(e.consequent,t,n):A(e.alternate,t,n)}async function N(e,t,n){let r=[];for(let i of e.expressions){let e=await A(i,t,n);r.push(...e)}return r}async function P(e,t,n){let r=[];for(let i of e.elements)if(i!=null)if(i.type===`SpreadElement`){let e=await A(i.argument,t,n);r.push(...e)}else{let e=await A(i,t,n);r.push(...e)}return r}async function F(e,t,n){if(U(e))return!0;if(e.type===`Literal`)return e.value;if(e.type===`Identifier`)return e.name===`undefined`?void 0:e.name===`NaN`?NaN:e.name===`Infinity`?1/0:t.scope[e.name];if(e.type===`UnaryExpression`){let r=await F(e.argument,t,n);return e.operator===`!`?!W(r):e.operator===`-`?-r:e.operator===`+`?+r:e.operator===`typeof`?typeof r:void 0}if(e.type===`BinaryExpression`){let r=await F(e.left,t,n),i=await F(e.right,t,n);return e.operator===`===`?r===i:e.operator===`!==`?r!==i:e.operator===`==`?r===i:e.operator===`!=`?r!==i:e.operator===`<`?r<i:e.operator===`<=`?r<=i:e.operator===`>`?r>i:e.operator===`>=`?r>=i:e.operator===`+`?r+i:e.operator===`-`?r-i:e.operator===`*`?r*i:e.operator===`/`?r/i:e.operator===`%`?r%i:void 0}if(e.type===`LogicalExpression`){let r=await F(e.left,t,n);return e.operator===`&&`?W(r)?F(e.right,t,n):r:e.operator===`||`?W(r)?r:F(e.right,t,n):e.operator===`??`?r??F(e.right,t,n):void 0}if(e.type===`MemberExpression`){let r=await F(e.object,t,n);if(r==null)return;if(e.computed)return r[await F(e.property,t,n)];let{name:i}=e.property;return r[i]}if(e.type===`ConditionalExpression`)return W(await F(e.test,t,n))?F(e.consequent,t,n):F(e.alternate,t,n);let r=H(e);if(r!==``)try{let e=f(r,t.scope);return e===`true`?!0:e===`false`?!1:e===`null`?null:e===`undefined`||e===``?void 0:/^-?\d+(?:\.\d+)?$/.test(e)?Number(e):e}catch{return}}async function I(e,t,n){let r=z(e,t);if(r.name!=null&&g(r.name,t)){let{processAst:e}=await import(`./transformer-DSxGGz-0.mjs`);return v(r,t,e)}return y(r,t)??(r.children.length>0?n(r.children,t):[])}async function L(e,t,n){let r=[];for(let i of e.children){let e=await R(i,t,n);r.push(...e)}return r}async function R(e,t,n){if(e.type===`JSXElement`)return I(e,t,n);if(e.type===`JSXFragment`)return L(e,t,n);if(e.type===`JSXText`){let t=e.value.trim();return t===``?[]:[{type:`paragraph`,children:[{type:`text`,value:t}]}]}return e.type===`JSXExpressionContainer`?e.expression.type===`JSXEmptyExpression`?[]:A(e.expression,t,n):e.type===`JSXSpreadChild`?A(e.expression,t,n):[]}function z(e,t){let n=e.openingElement,r=null;n.name.type===`JSXIdentifier`?{name:r}=n.name:n.name.type===`JSXMemberExpression`?r=B(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:H(e.value.expression)}),i.push({type:`mdxJsxAttribute`,name:t,value:n})}else e.type===`JSXSpreadAttribute`&&i.push({type:`mdxJsxExpressionAttribute`,value:`...${H(e.argument)}`});let a=[];for(let n of e.children){let e=V(n,t);e!=null&&a.push(...e)}return{type:`mdxJsxFlowElement`,name:r,attributes:i,children:a}}function B(e){return e.object.type===`JSXIdentifier`?`${e.object.name}.${e.property.name}`:`${B(e.object)}.${e.property.name}`}function V(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[z(e,t)];if(e.type===`JSXFragment`){let n=[];for(let r of e.children){let e=V(r,t);e!=null&&n.push(...e)}return n}return e.type===`JSXExpressionContainer`?e.expression.type===`JSXEmptyExpression`?null:[{type:`paragraph`,children:[{type:`text`,value:H(e.expression)}]}]:e.type===`JSXSpreadChild`?[{type:`paragraph`,children:[{type:`text`,value:`...${H(e.expression)}`}]}]:null}function H(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=H(e.object);return e.computed?`${t}[${H(e.property)}]`:`${t}.${e.property.name}`}if(e.type===`CallExpression`)return`${H(e.callee)}(${e.arguments.map(e=>H(e)).join(`, `)})`;if(e.type===`BinaryExpression`||e.type===`LogicalExpression`){let t=H(e.left),n=H(e.right);return`(${t} ${e.operator} ${n})`}if(e.type===`UnaryExpression`){let t=H(e.argument);return`${e.operator}${t}`}if(e.type===`ConditionalExpression`)return`(${H(e.test)} ? ${H(e.consequent)} : ${H(e.alternate)})`;if(e.type===`ArrayExpression`)return`[${e.elements.filter(e=>e!=null&&e.type!==`SpreadElement`).map(e=>H(e)).join(`, `)}]`;if(e.type===`ObjectExpression`)return`{${e.properties.filter(e=>e.type===`Property`).map(e=>`${e.key.type===`Identifier`?e.key.name:H(e.key)}: ${H(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+=`\${${H(e.expressions[n])}}`);return t+="`",t}return e.type===`SpreadElement`?`...${H(e.argument)}`:``}function U(e){return e.type===`JSXElement`||e.type===`JSXFragment`}function W(e){return!!e}function G(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 K(e,t){let n=H(e);if(n===``)return[];try{return G(f(n,t.scope))}catch{return[]}}function q(e){if(!(e.includes(`/`)&&/\.\w+$/.test(e)))return e;let t=e.lastIndexOf(`/`);return e.slice(t+1)}async function J(e,t){return Y(e,t)}async function Y(e,t){let n=[];for(let r of e.children){let e=await X(r,t);n.push(...e)}return{type:`root`,children:n}}async function X(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(O(r))return k(n,t,async(e,t)=>(await J({type:`root`,children:e},t)).children);let a=f(n.value,t.scope);return a===``?[]:[{type:`paragraph`,children:[{type:`text`,value:a}]}]}if(e.type===`mdxJsxFlowElement`)return Z(e,t);if(e.type===`link`){let n=e,r=(await Q(n.children,t)).map(e=>e.type===`text`?{...e,value:q(e.value)}:e);return[{...n,children:r}]}if(!(`children`in e&&Array.isArray(e.children)))return[e];let n=await Q(e.children,t);return[{...e,children:n}]}async function Z(e,t){return e.name!=null&&g(e.name,t)?v(e,t,J):y(e,t)??[]}async function Q(e,t){let n=[];for(let r of e){if(r.type===`mdxTextExpression`){let e=r,i=e.value.trim();if(i.startsWith(`/*`)&&i.endsWith(`*/`))continue;let a={type:`text`,value:f(e.value,t.scope)};n.push(a);continue}if(r.type===`mdxJsxTextElement`){let e=r;if(e.name!=null&&g(e.name,t)){let r=await v(e,t,J);for(let e of r)e.type===`paragraph`&&`children`in e?n.push(...e.children):n.push(e);continue}let i=y(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 Q(r.children,t);if(r.type===`link`){let t=e.map(e=>e.type===`text`?{...e,value:q(e.value)}:e);n.push({...r,children:t});continue}n.push({...r,children:e});continue}n.push(r)}return n}export{e as a,o as c,i as d,r as f,l as i,t as l,f as n,s as o,u as r,a as s,J as t,n as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./transformer--AYrc-x_.mjs";export{e as processAst};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truenine/memory-sync-cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2026.
|
|
4
|
+
"version": "2026.10107.0",
|
|
5
5
|
"description": "TrueNine Life CLI Tools",
|
|
6
6
|
"author": "TrueNine",
|
|
7
7
|
"license": "UNLICENSED",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"yaml": "^2.8.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@truenine/eslint9-config": "^2026.
|
|
53
|
+
"@truenine/eslint9-config": "^2026.10107.100",
|
|
54
54
|
"@types/estree": "^1.0.8",
|
|
55
55
|
"@types/estree-jsx": "^1.0.5",
|
|
56
56
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./transformer-DWtwnW2T.mjs";export{e as processAst};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=class extends Error{constructor(e){super(`Circular dependency detected: ${e.join(` -> `)}`),this.cycle=e,this.name=`CircularDependencyError`}},t=class extends Error{constructor(e,t){super(`Plugin "${e}" depends on non-existent plugin "${t}"`),this.pluginName=e,this.missingDependency=t,this.name=`MissingDependencyError`}},n=class extends Error{constructor(e,t,n){super(e),this.expression=t,this.filePath=n,this.name=`ScopeError`}},r=class extends n{constructor(e,t,n){let r=n!=null&&n.length>0?`Undefined variable "${e}" in expression "${t}" (file: ${n})`:`Undefined variable "${e}" in expression "${t}"`;super(r,t,n),this.variableName=e,this.name=`UndefinedVariableError`}},i=class extends n{constructor(e,t,n){let r=n!=null&&n.length>0?`Undefined namespace "${e}" in expression "${t}" (file: ${n})`:`Undefined namespace "${e}" in expression "${t}"`;super(r,t,n),this.namespace=e,this.name=`UndefinedNamespaceError`}},a=class extends Error{constructor(e,t,n){let r=n!=null&&n.length>0,i=t!=null&&t.length>0,a=r?`${e} (export: ${t}, file: ${n})`:i?`${e} (export: ${t})`:e;super(a),this.exportName=t,this.filePath=n,this.name=`ExportParseError`}},o=class extends Error{constructor(e,t){let n=t!=null&&t.length>0?`Missing required metadata fields: ${e.join(`, `)} (file: ${t})`:`Missing required metadata fields: ${e.join(`, `)}`;super(n),this.missingFields=e,this.filePath=t,this.name=`MetadataValidationError`}},s=class extends Error{constructor(e,t,n){let r=n!=null&&n.length>0?`Invalid configuration field "${e}": ${t} (file: ${n})`:`Invalid configuration field "${e}": ${t}`;super(r),this.field=e,this.reason=t,this.filePath=n,this.name=`ConfigValidationError`}};const c=new Map;function l(e,t){c.set(e,t)}function u(){return new Map(c)}function d(e){return c.has(e)}function f(e,t,n){let r=e.trim();return r===``?``:/^[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*$/i.test(r)?p(r,t,n?.filePath):m(r,t,n?.filePath)}function p(e,t,n){let a=e.split(`.`),o=a[0];if(o==null||!(o in t))throw new i(o??``,e,n);let s=t[o];for(let t=1;t<a.length;t++){let i=a[t];if(i==null)continue;if(s==null)throw new r(i,e,n);if(typeof s!=`object`)throw TypeError(`Cannot read property "${i}" of ${typeof s} in expression "${e}"`);let o=s;if(!(i in o))throw new r(i,e,n);s=o[i]}return h(s)}function m(e,t,n){let r=Object.keys(t),a=r.map(e=>t[e]);try{return h(Function(...r,`return (${e})`)(...a))}catch(t){let r=t instanceof Error?t.message:String(t);if(r.includes(`is not defined`)){let t=/(\w+) is not defined/.exec(r);if(t?.[1]!=null)throw new i(t[1],e,n)}let a=n==null?``:` (file: ${n})`;throw Error(`Failed to evaluate expression: "${e}"${a}\nCause: ${r}`)}}function h(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 g(e,t){return e===null?!1:t.components.has(e)||d(e)}async function _(e){return async(t,n)=>(await e({type:`root`,children:t},n)).children}async function v(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 _(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 y(e,t){let n=e.name?.toLowerCase();if(n==null)return null;switch(n){case`pre`:return S(e,t);case`a`:return C(e,t);case`strong`:case`b`:return w(e,t);case`em`:case`i`:return T(e,t);case`img`:return E(e,t);case`blockquote`:return D(e,t);default:return null}}function b(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`?f(r.value.value,n.scope):r.value===null?``:null}function x(e,t){let n=``;for(let r of e.children)r.type===`text`?n+=r.value:r.type===`mdxTextExpression`?n+=f(r.value,t.scope):(r.type===`mdxJsxFlowElement`||r.type===`mdxJsxTextElement`)&&(n+=x(r,t));return n}function S(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=(b(n,`className`,t)??``).match(/language-(\w+)/)?.[1],i=x(n,t);return[{type:`code`,lang:r??null,value:i.trim()}]}function C(e,t){let n=b(e,`href`,t);if(n==null||n===``)return null;let r=x(e,t);return[{type:`paragraph`,children:[{type:`link`,url:n,title:b(e,`title`,t)??null,children:[{type:`text`,value:r}]}]}]}function w(e,t){let n={type:`strong`,children:[{type:`text`,value:x(e,t)}]};return e.type,[{type:`paragraph`,children:[n]}]}function T(e,t){let n={type:`emphasis`,children:[{type:`text`,value:x(e,t)}]};return e.type,[{type:`paragraph`,children:[n]}]}function E(e,t){let n=b(e,`src`,t);if(n==null||n===``)return null;let r={type:`image`,url:n,alt:b(e,`alt`,t)??``,title:b(e,`title`,t)??null};return e.type,[{type:`paragraph`,children:[r]}]}function D(e,t){return[{type:`blockquote`,children:[{type:`paragraph`,children:[{type:`text`,value:x(e,t)}]}]}]}function O(e){return e==null?!1:JSON.stringify(e).includes(`"JSX`)}async function k(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`?A(i.expression,t,n):[]}async function A(e,t,n){return e.type===`JSXElement`?I(e,t,n):e.type===`JSXFragment`?L(e,t,n):e.type===`LogicalExpression`?j(e,t,n):e.type===`ConditionalExpression`?M(e,t,n):e.type===`SequenceExpression`?N(e,t,n):e.type===`ArrayExpression`?P(e,t,n):K(e,t)}async function j(e,t,n){let r=await F(e.left,t,n);return e.operator===`&&`?W(r)?A(e.right,t,n):[]:e.operator===`||`?W(r)?U(e.left)?A(e.left,t,n):G(r):A(e.right,t,n):e.operator===`??`?r==null?A(e.right,t,n):U(e.left)?A(e.left,t,n):G(r):[]}async function M(e,t,n){return W(await F(e.test,t,n))?A(e.consequent,t,n):A(e.alternate,t,n)}async function N(e,t,n){let r=[];for(let i of e.expressions){let e=await A(i,t,n);r.push(...e)}return r}async function P(e,t,n){let r=[];for(let i of e.elements)if(i!=null)if(i.type===`SpreadElement`){let e=await A(i.argument,t,n);r.push(...e)}else{let e=await A(i,t,n);r.push(...e)}return r}async function F(e,t,n){if(U(e))return!0;if(e.type===`Literal`)return e.value;if(e.type===`Identifier`)return e.name===`undefined`?void 0:e.name===`NaN`?NaN:e.name===`Infinity`?1/0:t.scope[e.name];if(e.type===`UnaryExpression`){let r=await F(e.argument,t,n);return e.operator===`!`?!W(r):e.operator===`-`?-r:e.operator===`+`?+r:e.operator===`typeof`?typeof r:void 0}if(e.type===`BinaryExpression`){let r=await F(e.left,t,n),i=await F(e.right,t,n);return e.operator===`===`?r===i:e.operator===`!==`?r!==i:e.operator===`==`?r===i:e.operator===`!=`?r!==i:e.operator===`<`?r<i:e.operator===`<=`?r<=i:e.operator===`>`?r>i:e.operator===`>=`?r>=i:e.operator===`+`?r+i:e.operator===`-`?r-i:e.operator===`*`?r*i:e.operator===`/`?r/i:e.operator===`%`?r%i:void 0}if(e.type===`LogicalExpression`){let r=await F(e.left,t,n);return e.operator===`&&`?W(r)?F(e.right,t,n):r:e.operator===`||`?W(r)?r:F(e.right,t,n):e.operator===`??`?r??F(e.right,t,n):void 0}if(e.type===`MemberExpression`){let r=await F(e.object,t,n);return r==null?void 0:e.computed?r[await F(e.property,t,n)]:r[e.property.name]}if(e.type===`ConditionalExpression`)return W(await F(e.test,t,n))?F(e.consequent,t,n):F(e.alternate,t,n);let r=H(e);if(r!==``)try{let e=f(r,t.scope);return e===`true`?!0:e===`false`?!1:e===`null`?null:e===`undefined`||e===``?void 0:/^-?\d+(?:\.\d+)?$/.test(e)?Number(e):e}catch{return}}async function I(e,t,n){let r=z(e,t);if(r.name!=null&&g(r.name,t)){let{processAst:e}=await import(`./transformer-C6dH3CdE.mjs`);return v(r,t,e)}return y(r,t)??(r.children.length>0?n(r.children,t):[])}async function L(e,t,n){let r=[];for(let i of e.children){let e=await R(i,t,n);r.push(...e)}return r}async function R(e,t,n){if(e.type===`JSXElement`)return I(e,t,n);if(e.type===`JSXFragment`)return L(e,t,n);if(e.type===`JSXText`){let t=e.value.trim();return t===``?[]:[{type:`paragraph`,children:[{type:`text`,value:t}]}]}return e.type===`JSXExpressionContainer`?e.expression.type===`JSXEmptyExpression`?[]:A(e.expression,t,n):e.type===`JSXSpreadChild`?A(e.expression,t,n):[]}function z(e,t){let n=e.openingElement,r=null;n.name.type===`JSXIdentifier`?r=n.name.name:n.name.type===`JSXMemberExpression`?r=B(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:H(e.value.expression)}),i.push({type:`mdxJsxAttribute`,name:t,value:n})}else e.type===`JSXSpreadAttribute`&&i.push({type:`mdxJsxExpressionAttribute`,value:`...${H(e.argument)}`});let a=[];for(let n of e.children){let e=V(n,t);e!=null&&a.push(...e)}return{type:`mdxJsxFlowElement`,name:r,attributes:i,children:a}}function B(e){return e.object.type===`JSXIdentifier`?`${e.object.name}.${e.property.name}`:`${B(e.object)}.${e.property.name}`}function V(e,t){if(e.type===`JSXText`){let t=e.value;return t.trim()===``?null:[{type:`paragraph`,children:[{type:`text`,value:t}]}]}if(e.type===`JSXElement`)return[z(e,t)];if(e.type===`JSXFragment`){let n=[];for(let r of e.children){let e=V(r,t);e!=null&&n.push(...e)}return n}return e.type===`JSXExpressionContainer`?e.expression.type===`JSXEmptyExpression`?null:[{type:`paragraph`,children:[{type:`text`,value:H(e.expression)}]}]:e.type===`JSXSpreadChild`?[{type:`paragraph`,children:[{type:`text`,value:`...${H(e.expression)}`}]}]:null}function H(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=H(e.object);return e.computed?`${t}[${H(e.property)}]`:`${t}.${e.property.name}`}if(e.type===`CallExpression`)return`${H(e.callee)}(${e.arguments.map(e=>H(e)).join(`, `)})`;if(e.type===`BinaryExpression`||e.type===`LogicalExpression`){let t=H(e.left),n=H(e.right);return`(${t} ${e.operator} ${n})`}if(e.type===`UnaryExpression`){let t=H(e.argument);return`${e.operator}${t}`}if(e.type===`ConditionalExpression`)return`(${H(e.test)} ? ${H(e.consequent)} : ${H(e.alternate)})`;if(e.type===`ArrayExpression`)return`[${e.elements.filter(e=>e!=null&&e.type!==`SpreadElement`).map(e=>H(e)).join(`, `)}]`;if(e.type===`ObjectExpression`)return`{${e.properties.filter(e=>e.type===`Property`).map(e=>`${e.key.type===`Identifier`?e.key.name:H(e.key)}: ${H(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+=`\${${H(e.expressions[n])}}`);return t+="`",t}return e.type===`SpreadElement`?`...${H(e.argument)}`:``}function U(e){return e.type===`JSXElement`||e.type===`JSXFragment`}function W(e){return!!e}function G(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 K(e,t){let n=H(e);if(n===``)return[];try{return G(f(n,t.scope))}catch{return[]}}async function q(e,t){return J(e,t)}async function J(e,t){let n=[];for(let r of e.children){let e=await Y(r,t);n.push(...e)}return{type:`root`,children:n}}async function Y(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(O(r))return k(n,t,async(e,t)=>(await q({type:`root`,children:e},t)).children);let a=f(n.value,t.scope);return a===``?[]:[{type:`paragraph`,children:[{type:`text`,value:a}]}]}if(e.type===`mdxJsxFlowElement`)return X(e,t);if(`children`in e&&Array.isArray(e.children)){let n=await Z(e.children,t);return[{...e,children:n}]}return[e]}async function X(e,t){return e.name!=null&&g(e.name,t)?v(e,t,q):y(e,t)??[]}async function Z(e,t){let n=[];for(let r of e){if(r.type===`mdxTextExpression`){let e=r,i=e.value.trim();if(i.startsWith(`/*`)&&i.endsWith(`*/`))continue;let a={type:`text`,value:f(e.value,t.scope)};n.push(a);continue}if(r.type===`mdxJsxTextElement`){let e=r;if(e.name!=null&&g(e.name,t)){let r=await v(e,t,q);for(let e of r)if(e.type===`paragraph`&&`children`in e){let t=e;n.push(...t.children)}else n.push(e);continue}let i=y(e,t);if(i!=null)for(let e of i)if(e.type===`paragraph`&&`children`in e){let t=e;n.push(...t.children)}else n.push(e);continue}if(`children`in r&&Array.isArray(r.children)){let e=await Z(r.children,t);n.push({...r,children:e});continue}n.push(r)}return n}export{e as a,o as c,i as d,r as f,l as i,t as l,f as n,s as o,u as r,a as s,q as t,n as u};
|